remove_x: Implement detection of stutter-invariant LTL formulas.
* src/bin/ltlfilt.cc: Add options --remove-x and --stutter-invariant. * src/ltlvisit/remove_x.cc, src/ltlvisit/remove_x.hh: New files. * src/ltlvisit/Makefile.am: Add them. * src/ltltest/remove_x.test: New file. * src/ltltest/Makefile.am: Add it. * NEWS: Mention the new algorithms.
This commit is contained in:
parent
8896c3d5da
commit
a7bfb42de7
7 changed files with 282 additions and 1 deletions
|
|
@ -1,5 +1,5 @@
|
|||
## -*- coding: utf-8 -*-
|
||||
## Copyright (C) 2010, 2011, 2012 Laboratoire de Recherche et
|
||||
## Copyright (C) 2010, 2011, 2012, 2013 Laboratoire de Recherche et
|
||||
## Developpement de l'Epita (LRDE).
|
||||
## Copyright (C) 2004, 2005, 2006 Laboratoire d'Informatique de Paris 6 (LIP6),
|
||||
## département Systèmes Répartis Coopératifs (SRC), Université Pierre
|
||||
|
|
@ -41,6 +41,7 @@ ltlvisit_HEADERS = \
|
|||
randomltl.hh \
|
||||
reduce.hh \
|
||||
relabel.hh \
|
||||
remove_x.hh \
|
||||
simpfg.hh \
|
||||
simplify.hh \
|
||||
snf.hh \
|
||||
|
|
@ -65,6 +66,7 @@ libltlvisit_la_SOURCES = \
|
|||
randomltl.cc \
|
||||
reduce.cc \
|
||||
relabel.cc \
|
||||
remove_x.cc \
|
||||
simpfg.cc \
|
||||
simplify.cc \
|
||||
snf.cc \
|
||||
|
|
|
|||
133
src/ltlvisit/remove_x.cc
Normal file
133
src/ltlvisit/remove_x.cc
Normal file
|
|
@ -0,0 +1,133 @@
|
|||
// Copyright (C) 2013 Laboratoire de Recherche et Developpement de
|
||||
// l'Epita (LRDE).
|
||||
//
|
||||
// This file is part of Spot, a model checking library.
|
||||
//
|
||||
// Spot is free software; you can redistribute it and/or modify it
|
||||
// under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Spot is distributed in the hope that it will be useful, but WITHOUT
|
||||
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
// License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include "ltlast/allnodes.hh"
|
||||
#include "ltlvisit/simplify.hh"
|
||||
#include "ltlvisit/clone.hh"
|
||||
#include "ltlvisit/apcollect.hh"
|
||||
|
||||
namespace spot
|
||||
{
|
||||
namespace ltl
|
||||
{
|
||||
namespace
|
||||
{
|
||||
|
||||
#define AND(x, y) multop::instance(multop::And, (x), (y))
|
||||
#define OR(x, y) multop::instance(multop::Or, (x), (y))
|
||||
#define NOT(x) unop::instance(unop::Not, (x))
|
||||
#define G(x) unop::instance(unop::G, (x))
|
||||
#define U(x, y) binop::instance(binop::U, (x), (y))
|
||||
|
||||
class remove_x_visitor : public clone_visitor
|
||||
{
|
||||
typedef clone_visitor super;
|
||||
atomic_prop_set aps;
|
||||
|
||||
public:
|
||||
remove_x_visitor(const formula* f)
|
||||
{
|
||||
atomic_prop_collect(f, &aps);
|
||||
}
|
||||
|
||||
virtual
|
||||
~remove_x_visitor()
|
||||
{
|
||||
}
|
||||
|
||||
using super::visit;
|
||||
void visit(const unop* uo)
|
||||
{
|
||||
const formula* c = recurse(uo->child());
|
||||
|
||||
unop::type op = uo->op();
|
||||
if (op != unop::X)
|
||||
{
|
||||
result_ = unop::instance(op, c);
|
||||
return;
|
||||
}
|
||||
multop::vec* vo = new multop::vec;
|
||||
for (atomic_prop_set::const_iterator i = aps.begin();
|
||||
i != aps.end(); ++i)
|
||||
{
|
||||
// First line
|
||||
multop::vec* va1 = new multop::vec;
|
||||
const formula* npi = NOT((*i)->clone());
|
||||
va1->push_back((*i)->clone());
|
||||
va1->push_back(U((*i)->clone(), AND(npi, c->clone())));
|
||||
for (atomic_prop_set::const_iterator j = aps.begin();
|
||||
j != aps.end(); ++j)
|
||||
if (*j != *i)
|
||||
va1->push_back(OR(U((*j)->clone(), npi->clone()),
|
||||
U(NOT((*j)->clone()), npi->clone())));
|
||||
vo->push_back(multop::instance(multop::And, va1));
|
||||
// Second line
|
||||
multop::vec* va2 = new multop::vec;
|
||||
va2->push_back(npi->clone());
|
||||
va2->push_back(U(npi->clone(), AND((*i)->clone(), c->clone())));
|
||||
for (atomic_prop_set::const_iterator j = aps.begin();
|
||||
j != aps.end(); ++j)
|
||||
if (*j != *i)
|
||||
va2->push_back(OR(U((*j)->clone(), (*i)->clone()),
|
||||
U(NOT((*j)->clone()), (*i)->clone())));
|
||||
vo->push_back(multop::instance(multop::And, va2));
|
||||
}
|
||||
const formula* l12 = multop::instance(multop::Or, vo);
|
||||
// Third line
|
||||
multop::vec* va3 = new multop::vec;
|
||||
for (atomic_prop_set::const_iterator i = aps.begin();
|
||||
i != aps.end(); ++i)
|
||||
{
|
||||
va3->push_back(OR(G((*i)->clone()),
|
||||
G(NOT((*i)->clone()))));
|
||||
}
|
||||
result_ = OR(l12, AND(multop::instance(multop::And, va3), c));
|
||||
return;
|
||||
}
|
||||
|
||||
virtual const formula* recurse(const formula* f)
|
||||
{
|
||||
if (f->is_X_free())
|
||||
return f->clone();
|
||||
f->accept(*this);
|
||||
return this->result();
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
const formula* remove_x(const formula* f)
|
||||
{
|
||||
remove_x_visitor v(f);
|
||||
return v.recurse(f);
|
||||
}
|
||||
|
||||
bool is_stutter_insensitive(const formula* f)
|
||||
{
|
||||
assert(f->is_ltl_formula());
|
||||
if (f->is_X_free())
|
||||
return true;
|
||||
const formula* g = remove_x(f);
|
||||
ltl_simplifier ls;
|
||||
bool res = ls.are_equivalent(f, g);
|
||||
g->destroy();
|
||||
return res;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
70
src/ltlvisit/remove_x.hh
Normal file
70
src/ltlvisit/remove_x.hh
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
// Copyright (C) 2013 Laboratoire de Recherche et Developpement de
|
||||
// l'Epita (LRDE).
|
||||
//
|
||||
// This file is part of Spot, a model checking library.
|
||||
//
|
||||
// Spot is free software; you can redistribute it and/or modify it
|
||||
// under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Spot is distributed in the hope that it will be useful, but WITHOUT
|
||||
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
// License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#ifndef SPOT_LTLVISIT_REMOVE_X_HH
|
||||
# define SPOT_LTLVISIT_REMOVE_X_HH
|
||||
|
||||
namespace spot
|
||||
{
|
||||
namespace ltl
|
||||
{
|
||||
class formula;
|
||||
|
||||
/// \brief Rewrite a stutter-insensitive formula \a f without
|
||||
/// using the X operator.
|
||||
///
|
||||
/// This function may also be applied to stutter-sensitive formulas,
|
||||
/// but in that case the resulting formula is not equivalent.
|
||||
///
|
||||
/// \verbatim
|
||||
/// @Article{ etessami.00.ipl,
|
||||
/// author = {Kousha Etessami},
|
||||
/// title = {A note on a question of {P}eled and {W}ilke regarding
|
||||
/// stutter-invariant {LTL}},
|
||||
/// journal = {Information Processing Letters},
|
||||
/// volume = {75},
|
||||
/// number = {6},
|
||||
/// year = {2000},
|
||||
/// pages = {261--263}
|
||||
/// }
|
||||
/// \endverbatim
|
||||
const formula* remove_x(const formula* f);
|
||||
|
||||
/// \brief Whether an LTL formula \a f is stutter-insensitive.
|
||||
///
|
||||
/// This is simply achieved by checking whether the output of
|
||||
/// <code>remove_x(f)</code> is equivalent to \a f. This only
|
||||
/// works for LTL formulas, not PSL formulas.
|
||||
///
|
||||
/// \verbatim
|
||||
/// @Article{ etessami.00.ipl,
|
||||
/// author = {Kousha Etessami},
|
||||
/// title = {A note on a question of {P}eled and {W}ilke regarding
|
||||
/// stutter-invariant {LTL}},
|
||||
/// journal = {Information Processing Letters},
|
||||
/// volume = {75},
|
||||
/// number = {6},
|
||||
/// year = {2000},
|
||||
/// pages = {261--263}
|
||||
/// }
|
||||
/// \endverbatim
|
||||
bool is_stutter_insensitive(const formula* f);
|
||||
}
|
||||
}
|
||||
|
||||
#endif // SPOT_LTLVISIT_ETESSAMI00_HH
|
||||
Loading…
Add table
Add a link
Reference in a new issue