Commit 546260e7 authored by Alexandre Duret-Lutz's avatar Alexandre Duret-Lutz
Browse files

Maintain basic LTL properties using a bitfield inside formula objects.

This bitfield is easily updated as the formulae are constructed.
Doing so avoids many AST recursions to compute these properties
individually.  This patch removes the eventual_universal_visitor,
as well as the kind_of() function.

* src/ltlast/formula.hh (is_boolean, is_sugar_free_boolean,
is_in_nenoform, is_X_free, is_sugar_free_ltl,
is_ltl_formula, is_eltl_formula, is_psl_formula, is_eventual,
is_universal, is_marked): New methods to query formula
properties in constant time.
(get_props, ltl_prop): A method and structure for
implementation as a field bit in an unsigned, for fast
computation.
(print_formula_props): New function.
* src/ltlast/formula.cc (print_formula_props): Implement it.
* src/ltlast/atomic_prop.cc, src/ltlast/binop.cc,
src/ltlast/bunop.cc, src/ltlast/constant.cc, src/ltlast/multop.cc,
src/ltlast/unop.cc, src/ltlast/automatop.cc: Compute the
properties as instances are constructed.
* src/ltlparse/ltlparse.yy: Update to use is_boolean() instead
of kind_of().
* src/ltltest/kind.cc: Update to use print_formula_props().
* src/ltltest/kind.test: Adjust to test eventual and universal
properties.
* src/ltlvisit/kind.cc, src/ltlvisit/kind.hh: Delete these files.
* src/ltlvisit/Makefile.am: Remove kind.hh and kind.cc.
* src/ltlvisit/reduce.cc (recurse_eu, eventual_universal_visitor):
Remove, no longer needed.
(reduce_visitor, is_eventual, is_universal): Adjust to
use formula::is_eventual(), and formula::is_universal().
* src/ltlvisit/reduce.hh (is_eventual, is_universal): Declare as
deprecated.
parent 1671aa5d
// Copyright (C) 2009 Laboratoire de Recherche et Dveloppement
// Copyright (C) 2009, 2010 Laboratoire de Recherche et Dveloppement
// de l'Epita (LRDE).
// Copyright (C) 2003, 2004, 2005 Laboratoire d'Informatique de
// Paris 6 (LIP6), dpartement Systmes Rpartis Coopratifs (SRC),
......@@ -34,6 +34,17 @@ namespace spot
atomic_prop::atomic_prop(const std::string& name, environment& env)
: name_(name), env_(&env)
{
is.boolean = true;
is.sugar_free_boolean = true;
is.in_nenoform = true;
is.X_free = true;
is.sugar_free_ltl = true;
is.ltl_formula = true;
is.eltl_formula = true;
is.psl_formula = true;
is.eventual = false;
is.universal = false;
is.not_marked = true;
}
atomic_prop::~atomic_prop()
......
// Copyright (C) 2008, 2009 Laboratoire de Recherche et Developpement
// Copyright (C) 2008, 2009, 2010 Laboratoire de Recherche et Developpement
// de l'Epita (LRDE)
//
// This file is part of Spot, a model checking library.
......@@ -30,6 +30,21 @@ namespace spot
automatop::automatop(const nfa::ptr nfa, vec* v, bool negated)
: nfa_(nfa), children_(v), negated_(negated)
{
is.boolean = false;
is.sugar_free_boolean = true;
is.in_nenoform = true;
is.X_free = true;
is.sugar_free_ltl = true;
is.ltl_formula = false;
is.eltl_formula = true;
is.psl_formula = false;
is.eventual = false;
is.universal = false;
is.not_marked = true;
unsigned s = v->size();
for (unsigned i = 0; i < s; ++i)
props &= (*v)[i]->get_props();
}
automatop::~automatop()
......
......@@ -36,6 +36,65 @@ namespace spot
binop::binop(type op, formula* first, formula* second)
: op_(op), first_(first), second_(second)
{
// Beware: (f U g) is purely eventual if both operands
// are purely eventual, unlike in the proceedings of
// Concur'00. (The revision of the paper available at
// http://www.bell-labs.com/project/TMP/ is fixed.) See
// also http://arxiv.org/abs/1011.4214 for a discussion
// about this problem. (Which we fixed in 2005 thanks
// to LBTT.)
// This means that we can use the following line to handle
// all cases of (f U g), (f R g), (f W g), (f M g) for
// universality and eventuality.
props = first->get_props() & second->get_props();
switch (op)
{
case Xor:
case Implies:
case Equiv:
is.sugar_free_boolean = false;
is.in_nenoform = false;
break;
case EConcatMarked:
is.not_marked = false;
// fall through
case EConcat:
case UConcat: