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

Use 'const formula*' instead of 'formula*' everywhere.

The distinction makes no sense since Spot 0.5, where we switched from
mutable furmulae to immutable formulae.  The difference between
const_visitor and visitor made no sense either.  They have been merged
into one: visitor.

* iface/dve2/dve2check.cc, iface/gspn/ltlgspn.cc,
src/eltlparse/eltlparse.yy, src/eltlparse/public.hh,
src/evtgbatest/ltl2evtgba.cc, src/kripkeparse/kripkeparse.yy,
src/ltlast/atomic_prop.cc, src/ltlast/atomic_prop.hh,
src/ltlast/automatop.cc, src/ltlast/automatop.hh, src/ltlast/binop.cc,
src/ltlast/binop.hh, src/ltlast/bunop.cc, src/ltlast/bunop.hh,
src/ltlast/constant.cc, src/ltlast/constant.hh, src/ltlast/formula.cc,
src/ltlast/formula.hh, src/ltlast/formula_tree.cc,
src/ltlast/formula_tree.hh, src/ltlast/multop.cc,
src/ltlast/multop.hh, src/ltlast/predecl.hh, src/ltlast/refformula.cc,
src/ltlast/refformula.hh, src/ltlast/unop.cc, src/ltlast/unop.hh,
src/ltlast/visitor.hh, src/ltlenv/declenv.cc, src/ltlenv/declenv.hh,
src/ltlenv/defaultenv.cc, src/ltlenv/defaultenv.hh,
src/ltlenv/environment.hh, src/ltlparse/ltlfile.cc,
src/ltlparse/ltlfile.hh, src/ltlparse/ltlparse.yy,
src/ltlparse/public.hh, src/ltltest/consterm.cc,
src/ltltest/equals.cc, src/ltltest/genltl.cc, src/ltltest/kind.cc,
src/ltltest/length.cc, src/ltltest/randltl.cc, src/ltltest/readltl.cc,
src/ltltest/reduc.cc, src/ltltest/syntimpl.cc,
src/ltltest/tostring.cc, src/ltlvisit/apcollect.cc,
src/ltlvisit/apcollect.hh, src/ltlvisit/clone.cc,
src/ltlvisit/clone.hh, src/ltlvisit/contain.cc,
src/ltlvisit/contain.hh, src/ltlvisit/dotty.cc,
src/ltlvisit/length.cc, src/ltlvisit/lunabbrev.cc,
src/ltlvisit/lunabbrev.hh, src/ltlvisit/mark.cc, src/ltlvisit/mark.hh,
src/ltlvisit/nenoform.cc, src/ltlvisit/nenoform.hh,
src/ltlvisit/postfix.cc, src/ltlvisit/postfix.hh,
src/ltlvisit/randomltl.cc, src/ltlvisit/randomltl.hh,
src/ltlvisit/reduce.cc, src/ltlvisit/reduce.hh,
src/ltlvisit/simpfg.cc, src/ltlvisit/simpfg.hh,
src/ltlvisit/simplify.cc, src/ltlvisit/simplify.hh,
src/ltlvisit/snf.cc, src/ltlvisit/snf.hh, src/ltlvisit/tostring.cc,
src/ltlvisit/tunabbrev.cc, src/ltlvisit/tunabbrev.hh,
src/ltlvisit/wmunabbrev.cc, src/ltlvisit/wmunabbrev.hh,
src/neverparse/neverclaimparse.yy, src/sabatest/sabacomplementtgba.cc,
src/tgba/bdddict.cc, src/tgba/formula2bdd.cc, src/tgba/taatgba.cc,
src/tgba/taatgba.hh, src/tgbaalgos/eltl2tgba_lacim.cc,
src/tgbaalgos/ltl2taa.cc, src/tgbaalgos/ltl2tgba_fm.cc,
src/tgbaalgos/ltl2tgba_lacim.cc, src/tgbaalgos/minimize.cc,
src/tgbaalgos/randomgraph.cc, src/tgbaparse/tgbaparse.yy,
src/tgbatest/complementation.cc, src/tgbatest/ltl2tgba.cc,
src/tgbatest/ltlprod.cc, src/tgbatest/mixprod.cc,
src/tgbatest/randtgba.cc: Massive adjustment!
* src/tgbatest/reductgba.cc: Delete.
parent 0f0ada82
......@@ -6,10 +6,6 @@ New in spot 0.8.3a:
Expressions (SERE), and a couple of operators to bridge SERE and
LTL. See doc/tl/tl.pdf for the list of operators and their
semantics.
- The constructors for temporal formulae will perform some trivial
simplifications based on associativity, commutativity,
idempotence, and neutral elements. See doc/tl/tl.pdf for the
list of such simplifications.
- Formula rewritings have been completely revamped, and augmented
with rules for PSL operators (and some new LTL rules as well).
See doc/tl/tl.pdf for the list of the rewritings implemented.
......@@ -51,13 +47,24 @@ New in spot 0.8.3a:
* Interface changes:
- Operators ->, <->, U, W, R, and M are now parsed as
right-associative to better match the PSL standard.
- The constructors for temporal formulae will perform some trivial
simplifications based on associativity, commutativity,
idempotence, and neutral elements. See doc/tl/tl.pdf for the
list of such simplifications.
- Formula instances now have many methods to inspect their
properties (membership to syntactic classes, absence of X
operator, etc...) in constant time.
- LTL/PSL formulae are now handled everywhere as 'const formula*'
and not just 'formula*'. This reflects the true nature of these
(immutable) formula objects, and cleanups a lot of code.
Unfortunately, it is a backward incompatible change: you may have
to add 'const' to a couple of lines in your code, and change
'ltl::const_vistitor' into 'ltl::visitor' if you have written a
custom visitor.
- The new entry point for LTL/PSL simplifications is the function
ltl_simplifier::simplify() declared in src/ltlvisit/simplify.hh.
The ltl_simplifier class implements a cache.
Functions such as reduce() or reduce_tau03() are deprecated.
- Formula instances now have many methods to inspect their
properties (membership to syntactic classes, absence of X
operator, etc...) in constant time.
- The old game-theory-based implementations for direct and delayed
simulation reductions have been removed. The old direct
simulation would only work on degeneralized automata, and yet
......
// Copyright (C) 2011 Laboratoire de Recherche et Developpement de
// Copyright (C) 2011, 2012 Laboratoire de Recherche et Developpement de
// l'Epita (LRDE)
//
// This file is part of Spot, a model checking library.
......@@ -177,8 +177,8 @@ main(int argc, char **argv)
spot::tgba* product = 0;
spot::emptiness_check_instantiator* echeck_inst = 0;
int exit_code = 0;
spot::ltl::formula* f = 0;
spot::ltl::formula* deadf = 0;
const spot::ltl::formula* f = 0;
const spot::ltl::formula* deadf = 0;
if (dead == 0 || !strcasecmp(dead, "true"))
{
......@@ -222,7 +222,7 @@ main(int argc, char **argv)
{
spot::ltl::ltl_simplifier_options opt(true, true, true, true, true);
spot::ltl::ltl_simplifier simp(opt);
spot::ltl::formula* r = simp.simplify(f);
const spot::ltl::formula* r = simp.simplify(f);
f->destroy();
f = r;
}
......
// Copyright (C) 2003, 2004, 2006, 2007, 2008, 2009 Laboratoire
// d'Informatique de Paris 6 (LIP6), dpartement Systmes Rpartis
// Coopratifs (SRC), Universit Pierre et Marie Curie.
// -*- coding: utf-8 -*-
// Copyright (C) 2008, 2009, 2011, 2012 Laboratoire de Recherche et
// Developpement de l'Epita (LRDE)
// Copyright (C) 2003, 2004, 2006, 2007 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.
//
......@@ -229,8 +232,8 @@ main(int argc, char **argv)
}
spot::ltl::parse_error_list pel;
spot::ltl::formula* f = spot::ltl::parse(argv[formula_index + 1],
pel, env);
const spot::ltl::formula* f =
spot::ltl::parse(argv[formula_index + 1], pel, env);
if (spot::ltl::format_parse_errors(std::cerr,
argv[formula_index + 1], pel))
......
......@@ -64,7 +64,7 @@ namespace spot
%parse-param {spot::eltl::aliasmap& amap}
%parse-param {spot::eltl::parse_error_list_t &pe}
%parse-param {spot::ltl::environment &parse_environment}
%parse-param {spot::ltl::formula* &result}
%parse-param {const spot::ltl::formula* &result}
%lex-param {spot::eltl::parse_error_list_t &pe}
%expect 0
%pure-parser
......@@ -74,7 +74,7 @@ namespace spot
std::string* sval;
spot::ltl::nfa* nval;
spot::ltl::automatop::vec* aval;
spot::ltl::formula* fval;
const spot::ltl::formula* fval;
/// To handle aliases.
spot::ltl::formula_tree::node* pval;
......@@ -520,7 +520,7 @@ namespace spot
{
namespace eltl
{
formula*
const formula*
parse_file(const std::string& name,
parse_error_list& error_list,
environment& env,
......@@ -533,7 +533,7 @@ namespace spot
spair("-", std::string("Cannot open file ") + name)));
return 0;
}
formula* result = 0;
const formula* result = 0;
nfamap nmap;
aliasmap amap;
parse_error_list_t pe;
......@@ -546,14 +546,14 @@ namespace spot
return result;
}
formula*
const formula*
parse_string(const std::string& eltl_string,
parse_error_list& error_list,
environment& env,
bool debug)
{
flex_scan_string(eltl_string.c_str());
formula* result = 0;
const formula* result = 0;
nfamap nmap;
aliasmap amap;
parse_error_list_t pe;
......
// Copyright (C) 2008, 2010 Laboratoire de Recherche et Développement
// de l'Epita (LRDE).
// -*- coding: utf-8 -*-
// Copyright (C) 2008, 2010, 2012 Laboratoire de Recherche et
// Développement de l'Epita (LRDE).
//
// This file is part of Spot, a model checking library.
//
......@@ -64,10 +65,11 @@ namespace spot
/// 0 if the file could not be opened.
///
/// \warning This function is not reentrant.
formula* parse_file(const std::string& filename,
parse_error_list& error_list,
environment& env = default_environment::instance(),
bool debug = false);
const formula* parse_file(const std::string& filename,
parse_error_list& error_list,
environment& env =
default_environment::instance(),
bool debug = false);
/// \brief Build a formula from an ELTL string.
/// \param eltl_string The string to parse.
......@@ -79,10 +81,11 @@ namespace spot
/// 0 if the input was unparsable.
///
/// \warning This function is not reentrant.
formula* parse_string(const std::string& eltl_string,
parse_error_list& error_list,
environment& env = default_environment::instance(),
bool debug = false);
const formula* parse_string(const std::string& eltl_string,
parse_error_list& error_list,
environment& env =
default_environment::instance(),
bool debug = false);
/// \brief Format diagnostics produced by spot::eltl::parse.
/// \param os Where diagnostics should be output.
......
// Copyright (C) 2008, 2009 Laboratoire de Recherche et Dveloppement
// de l'Epita (LRDE).
// -*- coding: utf-8 -*-
// Copyright (C) 2008, 2009, 2012 Laboratoire de Recherche et
// Développement de l'Epita (LRDE).
// Copyright (C) 2004 Laboratoire d'Informatique de Paris 6
// (LIP6), dpartement Systmes Rpartis Coopratifs (SRC), Universit
// (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.
......@@ -84,7 +85,7 @@ main(int argc, char** argv)
while (tok)
{
unobservables->insert
(static_cast<spot::ltl::atomic_prop*>(env.require(tok)));
(static_cast<const spot::ltl::atomic_prop*>(env.require(tok)));
tok = strtok(0, ", \t;");
}
}
......@@ -100,7 +101,7 @@ main(int argc, char** argv)
spot::bdd_dict* dict = new spot::bdd_dict();
spot::ltl::formula* f = 0;
const spot::ltl::formula* f = 0;
{
spot::ltl::parse_error_list pel;
......
// Copyright (C) 2011 Laboratoire de Recherche et Developpement
// -*- coding: utf-8 -*-
// Copyright (C) 2011, 2012 Laboratoire de Recherche et Développement
// de l'Epita (LRDE)
//
// This file is part of Spot, a model checking library.
......@@ -48,7 +49,7 @@ typedef std::map<std::string, bdd> formula_cache;
{
int token;
std::string* str;
spot::ltl::formula* f;
const spot::ltl::formula* f;
std::list<std::string*>* list;
}
......@@ -113,7 +114,7 @@ strident "," condition "," follow_list ";"
if (i == fcache.end())
{
parse_error_list pel;
formula* f = spot::ltl::parse(*$3, pel, parse_environment);
const formula* f = spot::ltl::parse(*$3, pel, parse_environment);
for (parse_error_list::iterator i = pel.begin();
i != pel.end(); ++i)
{
......@@ -158,7 +159,7 @@ string: STRING
{
$$ = $1;
error_list.push_back(spot::kripke_parse_error(@1,
"unterminated string"));
"unterminated string"));
}
;
......
// Copyright (C) 2009, 2010, 2011 Laboratoire de Recherche et Dveloppement
// de l'Epita (LRDE).
// -*- coding: utf-8 -*-
// Copyright (C) 2009, 2010, 2011, 2012 Laboratoire de Recherche et
// Développement de l'Epita (LRDE).
// Copyright (C) 2003, 2004, 2005 Laboratoire d'Informatique de
// Paris 6 (LIP6), dpartement Systmes Rpartis Coopratifs (SRC),
// Universit Pierre et Marie Curie.
// 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.
//
......@@ -71,13 +72,7 @@ namespace spot
}
void
atomic_prop::accept(visitor& v)
{
v.visit(this);
}
void
atomic_prop::accept(const_visitor& v) const
atomic_prop::accept(visitor& v) const
{
v.visit(this);
}
......@@ -96,18 +91,19 @@ namespace spot
atomic_prop::map atomic_prop::instances;
atomic_prop*
const atomic_prop*
atomic_prop::instance(const std::string& name, environment& env)
{
pair p(name, &env);
// FIXME: Use lower_bound, or a hash_map.
map::iterator i = instances.find(p);
const atomic_prop* ap;
if (i != instances.end())
{
return static_cast<atomic_prop*>(i->second->clone());
}
atomic_prop* ap = new atomic_prop(name, env);
instances[p] = ap;
return static_cast<atomic_prop*>(ap->clone());
ap = i->second;
else
ap = instances[p] = new atomic_prop(name, env);
ap->clone();
return ap;
}
unsigned
......
......@@ -45,10 +45,10 @@ namespace spot
public:
/// Build an atomic proposition with name \a name in
/// environment \a env.
static atomic_prop* instance(const std::string& name, environment& env);
static const atomic_prop*
instance(const std::string& name, environment& env);
virtual void accept(visitor& visitor);
virtual void accept(const_visitor& visitor) const;
virtual void accept(visitor& visitor) const;
/// Get the name of the atomic proposition.
const std::string& name() const;
......@@ -68,7 +68,7 @@ namespace spot
virtual ~atomic_prop();
typedef std::pair<std::string, environment*> pair;
typedef std::map<pair, atomic_prop*> map;
typedef std::map<pair, const atomic_prop*> map;
static map instances;
private:
......
// Copyright (C) 2008, 2009, 2010, 2011 Laboratoire de Recherche et
// Developpement de l'Epita (LRDE)
// -*- coding: utf-8 -*-
// Copyright (C) 2008, 2009, 2010, 2011, 2012 Laboratoire de Recherche
// et Développement de l'Epita (LRDE)
//
// This file is part of Spot, a model checking library.
//
......@@ -84,36 +85,34 @@ namespace spot
}
void
automatop::accept(visitor& v)
{
v.visit(this);
}
void
automatop::accept(const_visitor& v) const
automatop::accept(visitor& v) const
{
v.visit(this);
}
automatop::map automatop::instances;
automatop*
const automatop*
automatop::instance(const nfa::ptr nfa, vec* v, bool negated)
{
assert(nfa != 0);
triplet p(std::make_pair(nfa, negated), v);
map::iterator i = instances.find(p);
const automatop* res;
if (i != instances.end())
{
// The instance already exists.
for (vec::iterator vi = v->begin(); vi != v->end(); ++vi)
(*vi)->destroy();
delete v;
return static_cast<automatop*>(i->second->clone());
res = i->second;
}
else
{
res = instances[p] = new automatop(nfa, v, negated);
}
automatop* res = new automatop(nfa, v, negated);
instances[p] = res;
return static_cast<automatop*>(res->clone());
res->clone();
return res;
}
unsigned
......@@ -128,12 +127,6 @@ namespace spot
return (*children_)[n];
}
formula*
automatop::nth(unsigned n)
{
return (*children_)[n];
}
const spot::ltl::nfa::ptr
automatop::get_nfa() const
{
......@@ -165,6 +158,5 @@ namespace spot
}
return os;
}
}
}
// Copyright (C) 2008, 2009 Laboratoire de Recherche et Developpement
// de l'Epita (LRDE)
// -*- coding: utf-8 -*-
// Copyright (C) 2008, 2009, 2012 Laboratoire de Recherche et
// Développement de l'Epita (LRDE)
//
// This file is part of Spot, a model checking library.
//
......@@ -40,7 +41,7 @@ namespace spot
{
public:
/// List of formulae.
typedef std::vector<formula*> vec;
typedef std::vector<const formula*> vec;
/// \brief Build a spot::ltl::automatop with many children.
///
......@@ -48,11 +49,10 @@ namespace spot
/// the caller should allocate it with \c new, but not use it
/// (especially not destroy it) after it has been passed to
/// spot::ltl::automatop.
static automatop*
static const automatop*
instance(const nfa::ptr nfa, vec* v, bool negated);
virtual void accept(visitor& v);
virtual void accept(const_visitor& v) const;
virtual void accept(visitor& v) const;
/// Get the number of argument.
unsigned size() const;
......@@ -60,10 +60,6 @@ namespace spot
///
/// Starting with \a n = 0.
const formula* nth(unsigned n) const;
/// \brief Get the nth argument.
///
/// Starting with \a n = 0.
formula* nth(unsigned n);
/// Get the NFA of this operator.
const spot::ltl::nfa::ptr get_nfa() const;
......@@ -96,7 +92,7 @@ namespace spot
return *p1.second < *p2.second;
}
};
typedef std::map<triplet, automatop*, tripletcmp> map;
typedef std::map<triplet, const automatop*, tripletcmp> map;
static map instances;
automatop(const nfa::ptr, vec* v, bool negated);
......
// Copyright (C) 2009, 2010, 2011 Laboratoire de Recherche et Dveloppement
// de l'Epita (LRDE).
// -*- coding: utf-8 -*-
// Copyright (C) 2009, 2010, 2011, 2012 Laboratoire de Recherche et
// Développement de l'Epita (LRDE).
// Copyright (C) 2003, 2005 Laboratoire d'Informatique de Paris
// 6 (LIP6), dpartement Systmes Rpartis Coopratifs (SRC),
// Universit Pierre et Marie Curie.
// 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.
//
......@@ -34,7 +35,7 @@ namespace spot
{
namespace ltl
{
binop::binop(type op, formula* first, formula* second)
binop::binop(type op, const formula* first, const formula* second)
: ref_formula(BinOp), op_(op), first_(first), second_(second)
{
// Beware: (f U g) is a pure eventuality if both operands
......@@ -270,13 +271,7 @@ namespace spot
}
void
binop::accept(visitor& v)
{
v.visit(this);
}
void
binop::accept(const_visitor& v) const
binop::accept(visitor& v) const
{
v.visit(this);
}
......@@ -287,24 +282,12 @@ namespace spot
return first_;
}
formula*
binop::first()
{
return first_;
}
const formula*
binop::second() const
{
return second_;
}
formula*
binop::second()
{
return second_;
}
binop::type
binop::op() const
{
......@@ -344,8 +327,8 @@ namespace spot
binop::map binop::instances;
formula*
binop::instance(type op, formula* first, formula* second)
const formula*
binop::instance(type op, const formula* first, const formula* second)
{
// Sort the operands of commutative operators, so that for
// example the formula instance for 'a xor b' is the same as
......@@ -544,17 +527,22 @@ namespace spot
pairf pf(first, second);
pair p(op, pf);
// FIXME: Use lower_bound or hash_map.
map::iterator i = instances.find(p);
const binop* res;
if (i != instances.end())
{
// This instance already exists.
first->destroy();
second->destroy();
return static_cast<binop*>(i->second->clone());
res = i->second;
}
else
{
res = instances[p] = new binop(op, first, second);
}
binop* ap = new binop(op, first, second);
instances[p] = ap;
return static_cast<binop*>(ap->clone());
res->clone();
return res;
}
unsigned
......
......@@ -106,19 +106,16 @@ namespace spot
/// - [*0] []-> Exp = 1
/// - Exp []-> 1 = 1
/// - boolExp <>-> Exp = !boolExp | Exp
static formula* instance(type op, formula* first, formula* second);
static const formula* instance(type op,
const formula* first,
const formula* second);
virtual void accept(visitor& v);
virtual void accept(const_visitor& v) const;
virtual void accept(visitor& v) const;
/// Get the first operand.
const formula* first() const;
/// Get the first operand.
formula* first();
/// Get the second operand.
const formula* second() const;
/// Get the second operand.
formula* second();
/// Get the type of this operator.
type op() const;
......@@ -135,18 +132,18 @@ namespace spot
static std::ostream& dump_instances(std::ostream& os);
protected:
typedef std::pair<formula*, formula*> pairf;
typedef std::pair<const formula*, const formula*> pairf;
typedef std::pair<type, pairf> pair;
typedef std::map<pair, binop*> map;
typedef std::map<pair, const binop*> map;
static map instances;
binop(type op, formula* first, formula* second);
binop(type op, const formula* first, const formula* second);
virtual ~binop();
private:
type op_;
formula* first_;
formula* second_;
const formula* first_;
const formula* second_;
};
/// \brief Cast \a f into a binop
......@@ -154,12 +151,12 @@ namespace spot
/// Cast \a f into a binop iff it is a binop instance. Return 0
/// otherwise. This is faster than \c dynamic_cast.
inline
binop*
is_binop(formula* f)
const binop*
is_binop(const formula* f)
{
if (f->kind() != formula::BinOp)
return 0;
return static_cast<binop*>(f);
return static_cast<const binop*>(f);
}
/// \brief Cast \a f into a binop if it has type \a op.
......@@ -167,15 +164,13 @@ namespace spot
/// Cast \a f into a binop iff it is a unop instance with operator \a op.
/// Returns 0 otherwise.
inline
binop*
is_binop(formula* f, binop::type op)
const binop*
is_binop(const formula* f, binop::type op)
{
if (f->kind() != formula::BinOp)
return 0;
binop* bo = static_cast<binop*>(f);
if (bo->op() != op)
return 0;
return bo;
if (const binop* bo = is_binop(f))
if (bo->op() == op)
return bo;
return 0;
}
/// \brief Cast \a f into a binop if it has type \a op1 or \a op2.
......@@ -183,15 +178,12 @@ namespace spot
/// Cast \a f into a binop iff it is a unop instance with operator \a op1 or
/// \a op2. Returns 0 otherwise.
inline