spot/src/ltlvisit/reduce.hh
Alexandre Duret-Lutz 546260e7a0 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.
2012-04-28 09:30:36 +02:00

124 lines
4 KiB
C++

// Copyright (C) 2004, 2006, 2010 Laboratoire d'Informatique de Paris 6 (LIP6),
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
// et Marie Curie.
//
// 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 2 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 Spot; see the file COPYING. If not, write to the Free
// Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
#ifndef SPOT_LTLVISIT_REDUCE_HH
# define SPOT_LTLVISIT_REDUCE_HH
#include "ltlast/formula.hh"
#include "ltlast/visitor.hh"
namespace spot
{
namespace ltl
{
/// \addtogroup ltl_rewriting
/// @{
/// Options for spot::ltl::reduce.
enum reduce_options
{
/// No reduction.
Reduce_None = 0,
/// Basic reductions.
Reduce_Basics = 1,
/// Somenzi & Bloem syntactic implication.
Reduce_Syntactic_Implications = 2,
/// Etessami & Holzmann eventuality and universality reductions.
Reduce_Eventuality_And_Universality = 4,
/// Tauriainen containment checks.
Reduce_Containment_Checks = 8,
/// Tauriainen containment checks (stronger version).
Reduce_Containment_Checks_Stronger = 16,
/// All reductions.
Reduce_All = -1U
};
/// \brief Reduce a formula \a f.
///
/// \param f the formula to reduce
/// \param opt a conjonction of spot::ltl::reduce_options specifying
/// which optimizations to apply.
/// \return the reduced formula
formula* reduce(const formula* f, int opt = Reduce_All);
/// @}
/// \brief Check whether a formula is a pure eventuality.
/// \ingroup ltl_misc
///
/// Pure eventuality formulae are defined in
/// \verbatim
/// @InProceedings{ etessami.00.concur,
/// author = {Kousha Etessami and Gerard J. Holzmann},
/// title = {Optimizing {B\"u}chi Automata},
/// booktitle = {Proceedings of the 11th International Conference on
/// Concurrency Theory (Concur'2000)},
/// pages = {153--167},
/// year = {2000},
/// editor = {C. Palamidessi},
/// volume = {1877},
/// series = {Lecture Notes in Computer Science},
/// publisher = {Springer-Verlag}
/// }
/// \endverbatim
///
/// A word that satisfies a pure eventuality can be prefixed by
/// anything and still satisfies the formula.
///
/// \deprecated Use f->is_eventual() instead.
#if __GNUC__
bool is_eventual(const formula* f) __attribute__ ((deprecated));
#else
bool is_eventual(const formula* f);
#endif
/// \brief Check whether a formula is purely universal.
/// \ingroup ltl_misc
///
/// Purely universal formulae are defined in
/// \verbatim
/// @InProceedings{ etessami.00.concur,
/// author = {Kousha Etessami and Gerard J. Holzmann},
/// title = {Optimizing {B\"u}chi Automata},
/// booktitle = {Proceedings of the 11th International Conference on
/// Concurrency Theory (Concur'2000)},
/// pages = {153--167},
/// year = {2000},
/// editor = {C. Palamidessi},
/// volume = {1877},
/// series = {Lecture Notes in Computer Science},
/// publisher = {Springer-Verlag}
/// }
/// \endverbatim
///
/// Any (non-empty) suffix of a word that satisfies if purely
/// universal formula also satisfies the formula.
///
/// \deprecated Use f->is_universal() instead.
#if __GNUC__
bool is_universal(const formula* f) __attribute__ ((deprecated));
#else
bool is_universal(const formula* f);
#endif
}
}
#endif // SPOT_LTLVISIT_REDUCE_HH