* src/ltlast/formula.hh (hash, dump, dump_, hash_key_): New members.
(formula_ptr_less_than, formula_ptr_hash): New class. * src/ltlast/atomic_prop.cc, src/ltlast/binop.cc, src/ltlast/constant.cc, src/ltlast/formula.cc, src/ltlast/multop.cc, src/ltlast/unop.cc: Adjust to handle dump_. * src/ltlvisit/apcollect.cc, src/ltlvisit/apcollect.hh: Sort the set using formula_ptr_less_than. * src/ltlvisit/dump.cc: Simplify using ->dump(). * src/tgbaalgos/ltl2tgba_fm.cc: Sort all maps to get deterministic results.
This commit is contained in:
parent
8a5e31f00e
commit
5069a565b6
12 changed files with 153 additions and 82 deletions
13
ChangeLog
13
ChangeLog
|
|
@ -1,3 +1,16 @@
|
||||||
|
2005-01-20 Alexandre Duret-Lutz <adl@src.lip6.fr>
|
||||||
|
|
||||||
|
* src/ltlast/formula.hh (hash, dump, dump_, hash_key_): New members.
|
||||||
|
(formula_ptr_less_than, formula_ptr_hash): New class.
|
||||||
|
* src/ltlast/atomic_prop.cc, src/ltlast/binop.cc,
|
||||||
|
src/ltlast/constant.cc, src/ltlast/formula.cc,
|
||||||
|
src/ltlast/multop.cc, src/ltlast/unop.cc: Adjust to handle dump_.
|
||||||
|
* src/ltlvisit/apcollect.cc, src/ltlvisit/apcollect.hh:
|
||||||
|
Sort the set using formula_ptr_less_than.
|
||||||
|
* src/ltlvisit/dump.cc: Simplify using ->dump().
|
||||||
|
* src/tgbaalgos/ltl2tgba_fm.cc: Sort all maps to get deterministic
|
||||||
|
results.
|
||||||
|
|
||||||
2005-01-18 Alexandre Duret-Lutz <adl@src.lip6.fr>
|
2005-01-18 Alexandre Duret-Lutz <adl@src.lip6.fr>
|
||||||
|
|
||||||
* src/tgbaalgos/tau03opt.hh (explicit_tau03_opt_search): Doco.
|
* src/tgbaalgos/tau03opt.hh (explicit_tau03_opt_search): Doco.
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright (C) 2003, 2004 Laboratoire d'Informatique de Paris 6 (LIP6),
|
// Copyright (C) 2003, 2004, 2005 Laboratoire d'Informatique de Paris 6 (LIP6),
|
||||||
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
|
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
|
||||||
// et Marie Curie.
|
// et Marie Curie.
|
||||||
//
|
//
|
||||||
|
|
@ -32,6 +32,8 @@ namespace spot
|
||||||
atomic_prop::atomic_prop(const std::string& name, environment& env)
|
atomic_prop::atomic_prop(const std::string& name, environment& env)
|
||||||
: name_(name), env_(&env)
|
: name_(name), env_(&env)
|
||||||
{
|
{
|
||||||
|
dump_ = "AP(" + name + ")";
|
||||||
|
set_key_();
|
||||||
}
|
}
|
||||||
|
|
||||||
atomic_prop::~atomic_prop()
|
atomic_prop::~atomic_prop()
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright (C) 2003 Laboratoire d'Informatique de Paris 6 (LIP6),
|
// Copyright (C) 2003, 2005 Laboratoire d'Informatique de Paris 6 (LIP6),
|
||||||
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
|
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
|
||||||
// et Marie Curie.
|
// et Marie Curie.
|
||||||
//
|
//
|
||||||
|
|
@ -31,6 +31,10 @@ namespace spot
|
||||||
binop::binop(type op, formula* first, formula* second)
|
binop::binop(type op, formula* first, formula* second)
|
||||||
: op_(op), first_(first), second_(second)
|
: op_(op), first_(first), second_(second)
|
||||||
{
|
{
|
||||||
|
dump_ = "binop(";
|
||||||
|
dump_ += op_name();
|
||||||
|
dump_ += ", " + first->dump() + ", " + second->dump() + ")";
|
||||||
|
set_key_();
|
||||||
}
|
}
|
||||||
|
|
||||||
binop::~binop()
|
binop::~binop()
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright (C) 2003 Laboratoire d'Informatique de Paris 6 (LIP6),
|
// Copyright (C) 2003, 2005 Laboratoire d'Informatique de Paris 6 (LIP6),
|
||||||
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
|
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
|
||||||
// et Marie Curie.
|
// et Marie Curie.
|
||||||
//
|
//
|
||||||
|
|
@ -30,6 +30,19 @@ namespace spot
|
||||||
constant::constant(type val)
|
constant::constant(type val)
|
||||||
: val_(val)
|
: val_(val)
|
||||||
{
|
{
|
||||||
|
switch (val)
|
||||||
|
{
|
||||||
|
case True:
|
||||||
|
dump_ = "constant(1)";
|
||||||
|
set_key_();
|
||||||
|
return;
|
||||||
|
case False:
|
||||||
|
dump_ = "constant(0)";
|
||||||
|
set_key_();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Unreachable code.
|
||||||
|
assert(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
constant::~constant()
|
constant::~constant()
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright (C) 2003 Laboratoire d'Informatique de Paris 6 (LIP6),
|
// Copyright (C) 2003, 2005 Laboratoire d'Informatique de Paris 6 (LIP6),
|
||||||
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
|
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
|
||||||
// et Marie Curie.
|
// et Marie Curie.
|
||||||
//
|
//
|
||||||
|
|
@ -20,6 +20,7 @@
|
||||||
// 02111-1307, USA.
|
// 02111-1307, USA.
|
||||||
|
|
||||||
#include "formula.hh"
|
#include "formula.hh"
|
||||||
|
#include "misc/hash.hh"
|
||||||
|
|
||||||
namespace spot
|
namespace spot
|
||||||
{
|
{
|
||||||
|
|
@ -55,5 +56,19 @@ namespace spot
|
||||||
// Not reference counted by default.
|
// Not reference counted by default.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const std::string&
|
||||||
|
formula::dump() const
|
||||||
|
{
|
||||||
|
return dump_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
formula::set_key_()
|
||||||
|
{
|
||||||
|
string_hash sh;
|
||||||
|
hash_key_ = sh(dump_);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,8 @@
|
||||||
#ifndef SPOT_LTLAST_FORMULA_HH
|
#ifndef SPOT_LTLAST_FORMULA_HH
|
||||||
# define SPOT_LTLAST_FORMULA_HH
|
# define SPOT_LTLAST_FORMULA_HH
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <cassert>
|
||||||
#include "predecl.hh"
|
#include "predecl.hh"
|
||||||
|
|
||||||
namespace spot
|
namespace spot
|
||||||
|
|
@ -89,6 +91,15 @@ namespace spot
|
||||||
/// want to release a whole formula, use spot::ltl::destroy() instead.
|
/// want to release a whole formula, use spot::ltl::destroy() instead.
|
||||||
static void unref(formula* f);
|
static void unref(formula* f);
|
||||||
|
|
||||||
|
/// Return a canonic representation of the formula
|
||||||
|
const std::string& dump() const;
|
||||||
|
|
||||||
|
/// Return a hash_key for the formula.
|
||||||
|
const size_t
|
||||||
|
hash() const
|
||||||
|
{
|
||||||
|
return hash_key_;
|
||||||
|
}
|
||||||
protected:
|
protected:
|
||||||
virtual ~formula();
|
virtual ~formula();
|
||||||
|
|
||||||
|
|
@ -97,8 +108,70 @@ namespace spot
|
||||||
/// \brief decrement reference counter if any, return true when
|
/// \brief decrement reference counter if any, return true when
|
||||||
/// the instance must be deleted (usually when the counter hits 0).
|
/// the instance must be deleted (usually when the counter hits 0).
|
||||||
virtual bool unref_();
|
virtual bool unref_();
|
||||||
|
|
||||||
|
/// \brief Compute key_ from dump_.
|
||||||
|
///
|
||||||
|
/// Should be called once in each object, after dump_ has been set.
|
||||||
|
void set_key_();
|
||||||
|
/// The canonic representation of the formula
|
||||||
|
std::string dump_;
|
||||||
|
/// \brief The hash key of this formula.
|
||||||
|
///
|
||||||
|
/// Initialized by set_key_().
|
||||||
|
size_t hash_key_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// \brief Strict Weak Ordering for <code>const formula*</code>.
|
||||||
|
/// \ingroup ltl_essentials
|
||||||
|
///
|
||||||
|
/// This is meant to be used as a comparison functor for
|
||||||
|
/// STL \c map whose key are of type <code>const formula*</code>.
|
||||||
|
///
|
||||||
|
/// For instance here is how one could declare
|
||||||
|
/// a map of \c const::formula*.
|
||||||
|
/// \code
|
||||||
|
/// // Remember how many times each formula has been seen.
|
||||||
|
/// std::map<const spot::ltl::formula*, int,
|
||||||
|
/// spot::formula_ptr_less_than> seen;
|
||||||
|
/// \endcode
|
||||||
|
struct formula_ptr_less_than:
|
||||||
|
public std::binary_function<const formula*, const formula*, bool>
|
||||||
|
{
|
||||||
|
bool
|
||||||
|
operator()(const formula* left, const formula* right) const
|
||||||
|
{
|
||||||
|
assert(left);
|
||||||
|
assert(right);
|
||||||
|
return left->hash() < right->hash();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/// \brief Hash Function for <code>const formula*</code>.
|
||||||
|
/// \ingroup ltl_essentials
|
||||||
|
/// \ingroup hash_funcs
|
||||||
|
///
|
||||||
|
/// This is meant to be used as a hash functor for
|
||||||
|
/// Sgi's \c hash_map whose key are of type <code>const formula*</code>.
|
||||||
|
///
|
||||||
|
/// For instance here is how one could declare
|
||||||
|
/// a map of \c const::formula*.
|
||||||
|
/// \code
|
||||||
|
/// // Remember how many times each formula has been seen.
|
||||||
|
/// Sgi::hash_map<const spot::ltl::formula*, int,
|
||||||
|
/// const spot::ltl::formula_ptr_hash> seen;
|
||||||
|
/// \endcode
|
||||||
|
struct formula_ptr_hash:
|
||||||
|
public std::unary_function<const formula*, size_t>
|
||||||
|
{
|
||||||
|
size_t
|
||||||
|
operator()(const formula* that) const
|
||||||
|
{
|
||||||
|
assert(that);
|
||||||
|
return that->hash();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright (C) 2003, 2004 Laboratoire d'Informatique de Paris 6 (LIP6),
|
// Copyright (C) 2003, 2004, 2005 Laboratoire d'Informatique de Paris 6 (LIP6),
|
||||||
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
|
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
|
||||||
// et Marie Curie.
|
// et Marie Curie.
|
||||||
//
|
//
|
||||||
|
|
@ -34,6 +34,15 @@ namespace spot
|
||||||
multop::multop(type op, vec* v)
|
multop::multop(type op, vec* v)
|
||||||
: op_(op), children_(v)
|
: op_(op), children_(v)
|
||||||
{
|
{
|
||||||
|
dump_ = "multop(";
|
||||||
|
dump_ += op_name();
|
||||||
|
unsigned max = v->size();
|
||||||
|
for (unsigned n = 0; n < max; ++n)
|
||||||
|
{
|
||||||
|
dump_ += ", " + (*v)[n]->dump();
|
||||||
|
}
|
||||||
|
dump_ += ")";
|
||||||
|
set_key_();
|
||||||
}
|
}
|
||||||
|
|
||||||
multop::~multop()
|
multop::~multop()
|
||||||
|
|
@ -131,7 +140,7 @@ namespace spot
|
||||||
v->insert(v->end(), inlined.begin(), inlined.end());
|
v->insert(v->end(), inlined.begin(), inlined.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::sort(v->begin(), v->end());
|
std::sort(v->begin(), v->end(), formula_ptr_less_than());
|
||||||
|
|
||||||
// Remove duplicates. We can't use std::unique(), because we
|
// Remove duplicates. We can't use std::unique(), because we
|
||||||
// must destroy() any formula we drop.
|
// must destroy() any formula we drop.
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright (C) 2003 Laboratoire d'Informatique de Paris 6 (LIP6),
|
// Copyright (C) 2003, 2005 Laboratoire d'Informatique de Paris 6 (LIP6),
|
||||||
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
|
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
|
||||||
// et Marie Curie.
|
// et Marie Curie.
|
||||||
//
|
//
|
||||||
|
|
@ -30,6 +30,10 @@ namespace spot
|
||||||
unop::unop(type op, formula* child)
|
unop::unop(type op, formula* child)
|
||||||
: op_(op), child_(child)
|
: op_(op), child_(child)
|
||||||
{
|
{
|
||||||
|
dump_ = "unop(";
|
||||||
|
dump_ += op_name();
|
||||||
|
dump_ += ", " + child->dump() + ")";
|
||||||
|
set_key_();
|
||||||
}
|
}
|
||||||
|
|
||||||
unop::~unop()
|
unop::~unop()
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright (C) 2004 Laboratoire d'Informatique de Paris 6 (LIP6),
|
// Copyright (C) 2004, 2005 Laboratoire d'Informatique de Paris 6 (LIP6),
|
||||||
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
|
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
|
||||||
// et Marie Curie.
|
// et Marie Curie.
|
||||||
//
|
//
|
||||||
|
|
@ -20,6 +20,7 @@
|
||||||
// 02111-1307, USA.
|
// 02111-1307, USA.
|
||||||
|
|
||||||
#include "apcollect.hh"
|
#include "apcollect.hh"
|
||||||
|
#include "ltlvisit/postfix.hh"
|
||||||
|
|
||||||
namespace spot
|
namespace spot
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright (C) 2004 Laboratoire d'Informatique de Paris 6 (LIP6),
|
// Copyright (C) 2004, 2005 Laboratoire d'Informatique de Paris 6 (LIP6),
|
||||||
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
|
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
|
||||||
// et Marie Curie.
|
// et Marie Curie.
|
||||||
//
|
//
|
||||||
|
|
@ -23,7 +23,7 @@
|
||||||
# define SPOT_LTLVISIT_APCOLLECT_HH
|
# define SPOT_LTLVISIT_APCOLLECT_HH
|
||||||
|
|
||||||
#include <set>
|
#include <set>
|
||||||
#include "ltlvisit/postfix.hh"
|
#include "ltlast/atomic_prop.hh"
|
||||||
|
|
||||||
namespace spot
|
namespace spot
|
||||||
{
|
{
|
||||||
|
|
@ -33,7 +33,7 @@ namespace spot
|
||||||
/// @{
|
/// @{
|
||||||
|
|
||||||
/// Set of atomic propositions.
|
/// Set of atomic propositions.
|
||||||
typedef std::set<spot::ltl::atomic_prop*> atomic_prop_set;
|
typedef std::set<atomic_prop*, formula_ptr_less_than> atomic_prop_set;
|
||||||
|
|
||||||
/// \brief Return the set of atomic propositions occurring in a formula.
|
/// \brief Return the set of atomic propositions occurring in a formula.
|
||||||
///
|
///
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright (C) 2003, 2004 Laboratoire d'Informatique de Paris 6 (LIP6),
|
// Copyright (C) 2003, 2004, 2005 Laboratoire d'Informatique de Paris 6 (LIP6),
|
||||||
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
|
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
|
||||||
// et Marie Curie.
|
// et Marie Curie.
|
||||||
//
|
//
|
||||||
|
|
@ -28,74 +28,10 @@ namespace spot
|
||||||
{
|
{
|
||||||
namespace ltl
|
namespace ltl
|
||||||
{
|
{
|
||||||
namespace
|
|
||||||
{
|
|
||||||
class dump_visitor: public const_visitor
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
dump_visitor(std::ostream& os)
|
|
||||||
: os_(os)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual
|
|
||||||
~dump_visitor()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
visit(const atomic_prop* ap)
|
|
||||||
{
|
|
||||||
os_ << "AP(" << ap->name() << ")";
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
visit(const constant* c)
|
|
||||||
{
|
|
||||||
os_ << "constant(" << c->val_name() << ")";
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
visit(const binop* bo)
|
|
||||||
{
|
|
||||||
os_ << "binop(" << bo->op_name() << ", ";
|
|
||||||
bo->first()->accept(*this);
|
|
||||||
os_ << ", ";
|
|
||||||
bo->second()->accept(*this);
|
|
||||||
os_ << ")";
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
visit(const unop* uo)
|
|
||||||
{
|
|
||||||
os_ << "unop(" << uo->op_name() << ", ";
|
|
||||||
uo->child()->accept(*this);
|
|
||||||
os_ << ")";
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
visit(const multop* mo)
|
|
||||||
{
|
|
||||||
os_ << "multop(" << mo->op_name() << ", ";
|
|
||||||
unsigned max = mo->size();
|
|
||||||
mo->nth(0)->accept(*this);
|
|
||||||
for (unsigned n = 1; n < max; ++n)
|
|
||||||
{
|
|
||||||
os_ << ", ";
|
|
||||||
mo->nth(n)->accept(*this);
|
|
||||||
}
|
|
||||||
os_ << ")";
|
|
||||||
}
|
|
||||||
private:
|
|
||||||
std::ostream& os_;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
std::ostream&
|
std::ostream&
|
||||||
dump(std::ostream& os, const formula* f)
|
dump(std::ostream& os, const formula* f)
|
||||||
{
|
{
|
||||||
dump_visitor v(os);
|
os << f->dump();
|
||||||
f->accept(v);
|
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright (C) 2003, 2004 Laboratoire d'Informatique de Paris 6 (LIP6),
|
// Copyright (C) 2003, 2004, 2005 Laboratoire d'Informatique de Paris 6 (LIP6),
|
||||||
// département Systčmes Répartis Coopératifs (SRC), Université Pierre
|
// département Systčmes Répartis Coopératifs (SRC), Université Pierre
|
||||||
// et Marie Curie.
|
// et Marie Curie.
|
||||||
//
|
//
|
||||||
|
|
@ -533,7 +533,7 @@ namespace spot
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef Sgi::hash_map<const formula*, bool, ptr_hash<formula> > pfl_map;
|
typedef Sgi::hash_map<const formula*, bool, formula_ptr_hash> pfl_map;
|
||||||
pfl_map pfl_;
|
pfl_map pfl_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -613,7 +613,7 @@ namespace spot
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef std::map<bdd, bdd, bdd_less_than> prom_map;
|
typedef std::map<bdd, bdd, bdd_less_than> prom_map;
|
||||||
typedef Sgi::hash_map<const formula*, prom_map, ptr_hash<formula> > dest_map;
|
typedef Sgi::hash_map<const formula*, prom_map, formula_ptr_hash> dest_map;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
fill_dests(translate_dict& d, dest_map& dests, bdd label, const formula* dest)
|
fill_dests(translate_dict& d, dest_map& dests, bdd label, const formula* dest)
|
||||||
|
|
@ -649,8 +649,9 @@ namespace spot
|
||||||
formula* f2 = negative_normal_form(f1);
|
formula* f2 = negative_normal_form(f1);
|
||||||
destroy(f1);
|
destroy(f1);
|
||||||
|
|
||||||
std::set<const formula*> formulae_seen;
|
typedef std::set<const formula*, formula_ptr_less_than> set_type;
|
||||||
std::set<const formula*> formulae_to_translate;
|
set_type formulae_seen;
|
||||||
|
set_type formulae_to_translate;
|
||||||
|
|
||||||
translate_dict d(dict);
|
translate_dict d(dict);
|
||||||
formula_canonizer fc(d);
|
formula_canonizer fc(d);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue