Introduce tgba_explicit_labelled<label> so that we can build
tgba_explicit instances labelled by other objects than strings. * src/tgba/tgbaexplicit.cc, src/tgba/tgbaexplicit.hh: Split tgba_explicit in two levels: tgba_explicit with unlabelled states, and tgba_explicit_labelled templated by the type of the label. Define tgba_explicit_string (with the interface of the former tgba_explicit class) and tgba_explicit_formula for future use in ltl2tgba.cc. * src/tgba/tgbareduc.cc, src/tgba/tgbareduc.hh, src/tgbaalgos/cutscc.cc, src/tgbaalgos/dupexp.cc, src/tgbaalgos/emptiness.cc, src/tgbaalgos/ltl2tgba_fm.cc, src/tgbaalgos/powerset.cc, src/tgbaalgos/randomgraph.cc, src/tgbaparse/public.hh, src/tgbaparse/tgbaparse.yy, src/tgbatest/explicit.cc, src/tgbatest/ltl2tgba.cc: Adjust to use tgba_explicit_string when appropriate.
This commit is contained in:
parent
d3dcecc6c3
commit
4e22bb8b09
15 changed files with 284 additions and 191 deletions
19
ChangeLog
19
ChangeLog
|
|
@ -1,3 +1,22 @@
|
||||||
|
2009-11-10 Alexandre Duret-Lutz <adl@lrde.epita.fr>
|
||||||
|
|
||||||
|
Introduce tgba_explicit_labelled<label> so that we can build
|
||||||
|
tgba_explicit instances labelled by other objects than strings.
|
||||||
|
|
||||||
|
* src/tgba/tgbaexplicit.cc, src/tgba/tgbaexplicit.hh:
|
||||||
|
Split tgba_explicit in two levels: tgba_explicit with unlabelled
|
||||||
|
states, and tgba_explicit_labelled templated by the type of
|
||||||
|
the label. Define tgba_explicit_string (with the interface
|
||||||
|
of the former tgba_explicit class) and tgba_explicit_formula
|
||||||
|
for future use in ltl2tgba.cc.
|
||||||
|
* src/tgba/tgbareduc.cc, src/tgba/tgbareduc.hh,
|
||||||
|
src/tgbaalgos/cutscc.cc, src/tgbaalgos/dupexp.cc,
|
||||||
|
src/tgbaalgos/emptiness.cc, src/tgbaalgos/ltl2tgba_fm.cc,
|
||||||
|
src/tgbaalgos/powerset.cc, src/tgbaalgos/randomgraph.cc,
|
||||||
|
src/tgbaparse/public.hh, src/tgbaparse/tgbaparse.yy,
|
||||||
|
src/tgbatest/explicit.cc, src/tgbatest/ltl2tgba.cc: Adjust to
|
||||||
|
use tgba_explicit_string when appropriate.
|
||||||
|
|
||||||
2009-11-09 Alexandre Duret-Lutz <adl@lrde.epita.fr>
|
2009-11-09 Alexandre Duret-Lutz <adl@lrde.epita.fr>
|
||||||
|
|
||||||
Do not use the Boost macro from the Autoconf macro archive.
|
Do not use the Boost macro from the Autoconf macro archive.
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@
|
||||||
#include "tgba/formula2bdd.hh"
|
#include "tgba/formula2bdd.hh"
|
||||||
#include "misc/bddop.hh"
|
#include "misc/bddop.hh"
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
#include "ltlvisit/tostring.hh"
|
||||||
|
|
||||||
namespace spot
|
namespace spot
|
||||||
{
|
{
|
||||||
|
|
@ -121,45 +122,9 @@ namespace spot
|
||||||
|
|
||||||
tgba_explicit::~tgba_explicit()
|
tgba_explicit::~tgba_explicit()
|
||||||
{
|
{
|
||||||
ns_map::iterator i;
|
|
||||||
for (i = name_state_map_.begin(); i != name_state_map_.end(); ++i)
|
|
||||||
{
|
|
||||||
tgba_explicit::state::iterator i2;
|
|
||||||
for (i2 = i->second->begin(); i2 != i->second->end(); ++i2)
|
|
||||||
delete *i2;
|
|
||||||
delete i->second;
|
|
||||||
}
|
|
||||||
dict_->unregister_all_my_variables(this);
|
dict_->unregister_all_my_variables(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
tgba_explicit::state*
|
|
||||||
tgba_explicit::add_state(const std::string& name)
|
|
||||||
{
|
|
||||||
ns_map::iterator i = name_state_map_.find(name);
|
|
||||||
if (i == name_state_map_.end())
|
|
||||||
{
|
|
||||||
tgba_explicit::state* s = new tgba_explicit::state;
|
|
||||||
name_state_map_[name] = s;
|
|
||||||
state_name_map_[s] = name;
|
|
||||||
|
|
||||||
// The first state we add is the inititial state.
|
|
||||||
// It can also be overridden with set_init_state().
|
|
||||||
if (!init_)
|
|
||||||
init_ = s;
|
|
||||||
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
return i->second;
|
|
||||||
}
|
|
||||||
|
|
||||||
tgba_explicit::state*
|
|
||||||
tgba_explicit::set_init_state(const std::string& state)
|
|
||||||
{
|
|
||||||
tgba_explicit::state* s = add_state(state);
|
|
||||||
init_ = s;
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
tgba_explicit::transition*
|
tgba_explicit::transition*
|
||||||
tgba_explicit::create_transition(state* source, const state* dest)
|
tgba_explicit::create_transition(state* source, const state* dest)
|
||||||
{
|
{
|
||||||
|
|
@ -170,18 +135,6 @@ namespace spot
|
||||||
source->push_back(t);
|
source->push_back(t);
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
tgba_explicit::transition*
|
|
||||||
tgba_explicit::create_transition(const std::string& source,
|
|
||||||
const std::string& dest)
|
|
||||||
{
|
|
||||||
// It's important that the source be created before the
|
|
||||||
// destination, so the first encountered source becomes the
|
|
||||||
// default initial state.
|
|
||||||
state* s = add_state(source);
|
|
||||||
return create_transition(s, add_state(dest));
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
tgba_explicit::add_condition(transition* t, const ltl::formula* f)
|
tgba_explicit::add_condition(transition* t, const ltl::formula* f)
|
||||||
{
|
{
|
||||||
|
|
@ -196,26 +149,6 @@ namespace spot
|
||||||
t->condition &= f;
|
t->condition &= f;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
tgba_explicit::declare_acceptance_condition(const ltl::formula* f)
|
|
||||||
{
|
|
||||||
int v = dict_->register_acceptance_variable(f, this);
|
|
||||||
f->destroy();
|
|
||||||
bdd neg = bdd_nithvar(v);
|
|
||||||
neg_acceptance_conditions_ &= neg;
|
|
||||||
|
|
||||||
// Append neg to all acceptance conditions.
|
|
||||||
ns_map::iterator i;
|
|
||||||
for (i = name_state_map_.begin(); i != name_state_map_.end(); ++i)
|
|
||||||
{
|
|
||||||
tgba_explicit::state::iterator i2;
|
|
||||||
for (i2 = i->second->begin(); i2 != i->second->end(); ++i2)
|
|
||||||
(*i2)->acceptance_conditions &= neg;
|
|
||||||
}
|
|
||||||
|
|
||||||
all_acceptance_conditions_computed_ = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
tgba_explicit::copy_acceptance_conditions_of(const tgba *a)
|
tgba_explicit::copy_acceptance_conditions_of(const tgba *a)
|
||||||
{
|
{
|
||||||
|
|
@ -226,52 +159,6 @@ namespace spot
|
||||||
neg_acceptance_conditions_ = f;
|
neg_acceptance_conditions_ = f;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
tgba_explicit::complement_all_acceptance_conditions()
|
|
||||||
{
|
|
||||||
bdd all = all_acceptance_conditions();
|
|
||||||
ns_map::iterator i;
|
|
||||||
for (i = name_state_map_.begin(); i != name_state_map_.end(); ++i)
|
|
||||||
{
|
|
||||||
tgba_explicit::state::iterator i2;
|
|
||||||
for (i2 = i->second->begin(); i2 != i->second->end(); ++i2)
|
|
||||||
{
|
|
||||||
(*i2)->acceptance_conditions = all - (*i2)->acceptance_conditions;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
tgba_explicit::merge_transitions()
|
|
||||||
{
|
|
||||||
ns_map::iterator i;
|
|
||||||
for (i = name_state_map_.begin(); i != name_state_map_.end(); ++i)
|
|
||||||
{
|
|
||||||
state::iterator t1;
|
|
||||||
for (t1 = i->second->begin(); t1 != i->second->end(); ++t1)
|
|
||||||
{
|
|
||||||
bdd acc = (*t1)->acceptance_conditions;
|
|
||||||
const state* dest = (*t1)->dest;
|
|
||||||
|
|
||||||
// Find another transition with the same destination and
|
|
||||||
// acceptance conditions.
|
|
||||||
state::iterator t2 = t1;
|
|
||||||
++t2;
|
|
||||||
while (t2 != i->second->end())
|
|
||||||
{
|
|
||||||
state::iterator t2copy = t2++;
|
|
||||||
if ((*t2copy)->acceptance_conditions == acc
|
|
||||||
&& (*t2copy)->dest == dest)
|
|
||||||
{
|
|
||||||
(*t1)->condition |= (*t2copy)->condition;
|
|
||||||
delete *t2copy;
|
|
||||||
i->second->erase(t2copy);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
tgba_explicit::has_acceptance_condition(const ltl::formula* f) const
|
tgba_explicit::has_acceptance_condition(const ltl::formula* f) const
|
||||||
{
|
{
|
||||||
|
|
@ -317,7 +204,7 @@ namespace spot
|
||||||
{
|
{
|
||||||
// Fix empty automata by adding a lone initial state.
|
// Fix empty automata by adding a lone initial state.
|
||||||
if (!init_)
|
if (!init_)
|
||||||
const_cast<tgba_explicit*>(this)->add_state("empty");
|
const_cast<tgba_explicit*>(this)->add_default_init();
|
||||||
return new state_explicit(init_);
|
return new state_explicit(init_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -368,16 +255,6 @@ namespace spot
|
||||||
return dict_;
|
return dict_;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string
|
|
||||||
tgba_explicit::format_state(const spot::state* s) const
|
|
||||||
{
|
|
||||||
const state_explicit* se = dynamic_cast<const state_explicit*>(s);
|
|
||||||
assert(se);
|
|
||||||
sn_map::const_iterator i = state_name_map_.find(se->get_state());
|
|
||||||
assert(i != state_name_map_.end());
|
|
||||||
return i->second;
|
|
||||||
}
|
|
||||||
|
|
||||||
bdd
|
bdd
|
||||||
tgba_explicit::all_acceptance_conditions() const
|
tgba_explicit::all_acceptance_conditions() const
|
||||||
{
|
{
|
||||||
|
|
@ -396,4 +273,42 @@ namespace spot
|
||||||
return neg_acceptance_conditions_;
|
return neg_acceptance_conditions_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tgba_explicit::state*
|
||||||
|
tgba_explicit_string::add_default_init()
|
||||||
|
{
|
||||||
|
return add_state("empty");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string
|
||||||
|
tgba_explicit_string::format_state(const spot::state* s) const
|
||||||
|
{
|
||||||
|
const state_explicit* se = dynamic_cast<const state_explicit*>(s);
|
||||||
|
assert(se);
|
||||||
|
sn_map::const_iterator i = state_name_map_.find(se->get_state());
|
||||||
|
assert(i != state_name_map_.end());
|
||||||
|
return i->second;
|
||||||
|
}
|
||||||
|
|
||||||
|
tgba_explicit_formula::~tgba_explicit_formula()
|
||||||
|
{
|
||||||
|
ns_map::iterator i;
|
||||||
|
for (i = name_state_map_.begin(); i != name_state_map_.end(); ++i)
|
||||||
|
i->first->destroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
tgba_explicit::state* tgba_explicit_formula::add_default_init()
|
||||||
|
{
|
||||||
|
return add_state(ltl::constant::true_instance());
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string
|
||||||
|
tgba_explicit_formula::format_state(const spot::state* s) const
|
||||||
|
{
|
||||||
|
const state_explicit* se = dynamic_cast<const state_explicit*>(s);
|
||||||
|
assert(se);
|
||||||
|
sn_map::const_iterator i = state_name_map_.find(se->get_state());
|
||||||
|
assert(i != state_name_map_.end());
|
||||||
|
return ltl::to_string(i->second);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
// Copyright (C) 2003, 2004, 2006 Laboratoire d'Informatique de Paris 6 (LIP6),
|
// Copyright (C) 2003, 2004, 2006, 2009 Laboratoire d'Informatique de
|
||||||
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
|
// Paris 6 (LIP6), département Systèmes Répartis Coopératifs (SRC),
|
||||||
// et Marie Curie.
|
// Université Pierre et Marie Curie.
|
||||||
//
|
//
|
||||||
// This file is part of Spot, a model checking library.
|
// This file is part of Spot, a model checking library.
|
||||||
//
|
//
|
||||||
|
|
@ -26,12 +26,14 @@
|
||||||
#include <list>
|
#include <list>
|
||||||
#include "tgba.hh"
|
#include "tgba.hh"
|
||||||
#include "ltlast/formula.hh"
|
#include "ltlast/formula.hh"
|
||||||
|
#include <cassert>
|
||||||
|
|
||||||
namespace spot
|
namespace spot
|
||||||
{
|
{
|
||||||
// Forward declarations. See below.
|
// Forward declarations. See below.
|
||||||
class state_explicit;
|
class state_explicit;
|
||||||
class tgba_explicit_succ_iterator;
|
class tgba_explicit_succ_iterator;
|
||||||
|
class tgba_explicit;
|
||||||
|
|
||||||
/// Explicit representation of a spot::tgba.
|
/// Explicit representation of a spot::tgba.
|
||||||
/// \ingroup tgba_representation
|
/// \ingroup tgba_representation
|
||||||
|
|
@ -51,17 +53,15 @@ namespace spot
|
||||||
const state* dest;
|
const state* dest;
|
||||||
};
|
};
|
||||||
|
|
||||||
state* set_init_state(const std::string& state);
|
/// Add a default initial state.
|
||||||
|
virtual state* add_default_init() = 0;
|
||||||
|
|
||||||
transition*
|
|
||||||
create_transition(const std::string& source, const std::string& dest);
|
|
||||||
transition*
|
transition*
|
||||||
create_transition(state* source, const state* dest);
|
create_transition(state* source, const state* dest);
|
||||||
|
|
||||||
void add_condition(transition* t, const ltl::formula* f);
|
void add_condition(transition* t, const ltl::formula* f);
|
||||||
/// This assumes that all variables in \a f are known from dict.
|
/// This assumes that all variables in \a f are known from dict.
|
||||||
void add_conditions(transition* t, bdd f);
|
void add_conditions(transition* t, bdd f);
|
||||||
void declare_acceptance_condition(const ltl::formula* f);
|
|
||||||
|
|
||||||
/// \brief Copy the acceptance conditions of a tgba.
|
/// \brief Copy the acceptance conditions of a tgba.
|
||||||
///
|
///
|
||||||
|
|
@ -73,12 +73,6 @@ namespace spot
|
||||||
void add_acceptance_condition(transition* t, const ltl::formula* f);
|
void add_acceptance_condition(transition* t, const ltl::formula* f);
|
||||||
/// This assumes that all acceptance conditions in \a f are known from dict.
|
/// This assumes that all acceptance conditions in \a f are known from dict.
|
||||||
void add_acceptance_conditions(transition* t, bdd f);
|
void add_acceptance_conditions(transition* t, bdd f);
|
||||||
void complement_all_acceptance_conditions();
|
|
||||||
void merge_transitions();
|
|
||||||
|
|
||||||
/// Return the tgba_explicit::state for \a name, creating the state if
|
|
||||||
/// it does not exist.
|
|
||||||
state* add_state(const std::string& name);
|
|
||||||
|
|
||||||
// tgba interface
|
// tgba interface
|
||||||
virtual ~tgba_explicit();
|
virtual ~tgba_explicit();
|
||||||
|
|
@ -88,23 +82,18 @@ namespace spot
|
||||||
const spot::state* global_state = 0,
|
const spot::state* global_state = 0,
|
||||||
const tgba* global_automaton = 0) const;
|
const tgba* global_automaton = 0) const;
|
||||||
virtual bdd_dict* get_dict() const;
|
virtual bdd_dict* get_dict() const;
|
||||||
virtual std::string format_state(const spot::state* state) const;
|
|
||||||
|
|
||||||
virtual bdd all_acceptance_conditions() const;
|
virtual bdd all_acceptance_conditions() const;
|
||||||
virtual bdd neg_acceptance_conditions() const;
|
virtual bdd neg_acceptance_conditions() const;
|
||||||
|
|
||||||
|
virtual std::string format_state(const spot::state* s) const = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual bdd compute_support_conditions(const spot::state* state) const;
|
virtual bdd compute_support_conditions(const spot::state* state) const;
|
||||||
virtual bdd compute_support_variables(const spot::state* state) const;
|
virtual bdd compute_support_variables(const spot::state* state) const;
|
||||||
|
|
||||||
bdd get_acceptance_condition(const ltl::formula* f);
|
bdd get_acceptance_condition(const ltl::formula* f);
|
||||||
|
|
||||||
typedef Sgi::hash_map<const std::string, tgba_explicit::state*,
|
|
||||||
string_hash> ns_map;
|
|
||||||
typedef Sgi::hash_map<const tgba_explicit::state*, std::string,
|
|
||||||
ptr_hash<tgba_explicit::state> > sn_map;
|
|
||||||
ns_map name_state_map_;
|
|
||||||
sn_map state_name_map_;
|
|
||||||
bdd_dict* dict_;
|
bdd_dict* dict_;
|
||||||
tgba_explicit::state* init_;
|
tgba_explicit::state* init_;
|
||||||
mutable bdd all_acceptance_conditions_;
|
mutable bdd all_acceptance_conditions_;
|
||||||
|
|
@ -118,6 +107,7 @@ namespace spot
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// States used by spot::tgba_explicit.
|
/// States used by spot::tgba_explicit.
|
||||||
/// \ingroup tgba_representation
|
/// \ingroup tgba_representation
|
||||||
class state_explicit : public spot::state
|
class state_explicit : public spot::state
|
||||||
|
|
@ -168,6 +158,177 @@ namespace spot
|
||||||
bdd all_acceptance_conditions_;
|
bdd all_acceptance_conditions_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// A tgba_explicit instance with states labeled by a given type.
|
||||||
|
template<typename label, typename label_hash>
|
||||||
|
class tgba_explicit_labelled: public tgba_explicit
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
typedef label label_t;
|
||||||
|
typedef Sgi::hash_map<label, tgba_explicit::state*,
|
||||||
|
label_hash> ns_map;
|
||||||
|
typedef Sgi::hash_map<const tgba_explicit::state*, label,
|
||||||
|
ptr_hash<tgba_explicit::state> > sn_map;
|
||||||
|
ns_map name_state_map_;
|
||||||
|
sn_map state_name_map_;
|
||||||
|
public:
|
||||||
|
tgba_explicit_labelled(bdd_dict* dict) : tgba_explicit(dict) {};
|
||||||
|
|
||||||
|
bool has_state(const label& name)
|
||||||
|
{
|
||||||
|
return name_state_map_.find(name) != name_state_map_.end();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Return the tgba_explicit::state for \a name, creating the state if
|
||||||
|
/// it does not exist.
|
||||||
|
state* add_state(const label& name)
|
||||||
|
{
|
||||||
|
typename ns_map::iterator i = name_state_map_.find(name);
|
||||||
|
if (i == name_state_map_.end())
|
||||||
|
{
|
||||||
|
tgba_explicit::state* s = new tgba_explicit::state;
|
||||||
|
name_state_map_[name] = s;
|
||||||
|
state_name_map_[s] = name;
|
||||||
|
|
||||||
|
// The first state we add is the inititial state.
|
||||||
|
// It can also be overridden with set_init_state().
|
||||||
|
if (!init_)
|
||||||
|
init_ = s;
|
||||||
|
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
return i->second;
|
||||||
|
}
|
||||||
|
|
||||||
|
state*
|
||||||
|
set_init_state(const label& state)
|
||||||
|
{
|
||||||
|
tgba_explicit::state* s = add_state(state);
|
||||||
|
init_ = s;
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
transition*
|
||||||
|
create_transition(state* source, const state* dest)
|
||||||
|
{
|
||||||
|
return tgba_explicit::create_transition(source, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
transition*
|
||||||
|
create_transition(const label& source, const label& dest)
|
||||||
|
{
|
||||||
|
// It's important that the source be created before the
|
||||||
|
// destination, so the first source encountered becomes the
|
||||||
|
// default initial state.
|
||||||
|
state* s = add_state(source);
|
||||||
|
return tgba_explicit::create_transition(s, add_state(dest));
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
complement_all_acceptance_conditions()
|
||||||
|
{
|
||||||
|
bdd all = all_acceptance_conditions();
|
||||||
|
typename ns_map::iterator i;
|
||||||
|
for (i = name_state_map_.begin(); i != name_state_map_.end(); ++i)
|
||||||
|
{
|
||||||
|
tgba_explicit::state::iterator i2;
|
||||||
|
for (i2 = i->second->begin(); i2 != i->second->end(); ++i2)
|
||||||
|
{
|
||||||
|
(*i2)->acceptance_conditions = all - (*i2)->acceptance_conditions;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
declare_acceptance_condition(const ltl::formula* f)
|
||||||
|
{
|
||||||
|
int v = dict_->register_acceptance_variable(f, this);
|
||||||
|
f->destroy();
|
||||||
|
bdd neg = bdd_nithvar(v);
|
||||||
|
neg_acceptance_conditions_ &= neg;
|
||||||
|
|
||||||
|
// Append neg to all acceptance conditions.
|
||||||
|
typename ns_map::iterator i;
|
||||||
|
for (i = name_state_map_.begin(); i != name_state_map_.end(); ++i)
|
||||||
|
{
|
||||||
|
tgba_explicit::state::iterator i2;
|
||||||
|
for (i2 = i->second->begin(); i2 != i->second->end(); ++i2)
|
||||||
|
(*i2)->acceptance_conditions &= neg;
|
||||||
|
}
|
||||||
|
|
||||||
|
all_acceptance_conditions_computed_ = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
merge_transitions()
|
||||||
|
{
|
||||||
|
typename ns_map::iterator i;
|
||||||
|
for (i = name_state_map_.begin(); i != name_state_map_.end(); ++i)
|
||||||
|
{
|
||||||
|
state::iterator t1;
|
||||||
|
for (t1 = i->second->begin(); t1 != i->second->end(); ++t1)
|
||||||
|
{
|
||||||
|
bdd acc = (*t1)->acceptance_conditions;
|
||||||
|
const state* dest = (*t1)->dest;
|
||||||
|
|
||||||
|
// Find another transition with the same destination and
|
||||||
|
// acceptance conditions.
|
||||||
|
state::iterator t2 = t1;
|
||||||
|
++t2;
|
||||||
|
while (t2 != i->second->end())
|
||||||
|
{
|
||||||
|
state::iterator t2copy = t2++;
|
||||||
|
if ((*t2copy)->acceptance_conditions == acc
|
||||||
|
&& (*t2copy)->dest == dest)
|
||||||
|
{
|
||||||
|
(*t1)->condition |= (*t2copy)->condition;
|
||||||
|
delete *t2copy;
|
||||||
|
i->second->erase(t2copy);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
virtual
|
||||||
|
~tgba_explicit_labelled()
|
||||||
|
{
|
||||||
|
typename ns_map::iterator i;
|
||||||
|
for (i = name_state_map_.begin(); i != name_state_map_.end(); ++i)
|
||||||
|
{
|
||||||
|
tgba_explicit::state::iterator i2;
|
||||||
|
for (i2 = i->second->begin(); i2 != i->second->end(); ++i2)
|
||||||
|
delete *i2;
|
||||||
|
delete i->second;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
class tgba_explicit_string:
|
||||||
|
public tgba_explicit_labelled<std::string, string_hash>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
tgba_explicit_string(bdd_dict* dict):
|
||||||
|
tgba_explicit_labelled<std::string, string_hash>(dict)
|
||||||
|
{};
|
||||||
|
virtual state* add_default_init();
|
||||||
|
virtual std::string format_state(const spot::state* s) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
class tgba_explicit_formula:
|
||||||
|
public tgba_explicit_labelled<const ltl::formula*, ltl::formula_ptr_hash>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
tgba_explicit_formula(bdd_dict* dict):
|
||||||
|
tgba_explicit_labelled<const ltl::formula*, ltl::formula_ptr_hash>(dict)
|
||||||
|
{};
|
||||||
|
virtual ~tgba_explicit_formula();
|
||||||
|
virtual state* add_default_init();
|
||||||
|
virtual std::string format_state(const spot::state* s) const;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // SPOT_TGBA_TGBAEXPLICIT_HH
|
#endif // SPOT_TGBA_TGBAEXPLICIT_HH
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright (C) 2004, 2005, 2008 Laboratoire d'Informatique de Paris
|
// Copyright (C) 2004, 2005, 2008, 2009 Laboratoire d'Informatique de Paris
|
||||||
// 6 (LIP6), département Systèmes Répartis Coopératifs (SRC),
|
// 6 (LIP6), département Systèmes Répartis Coopératifs (SRC),
|
||||||
// Université Pierre et Marie Curie.
|
// Université Pierre et Marie Curie.
|
||||||
//
|
//
|
||||||
|
|
@ -31,7 +31,7 @@ namespace spot
|
||||||
|
|
||||||
tgba_reduc::tgba_reduc(const tgba* a,
|
tgba_reduc::tgba_reduc(const tgba* a,
|
||||||
const numbered_state_heap_factory* nshf)
|
const numbered_state_heap_factory* nshf)
|
||||||
: tgba_explicit(a->get_dict()),
|
: tgba_explicit_string(a->get_dict()),
|
||||||
tgba_reachable_iterator_breadth_first(a),
|
tgba_reachable_iterator_breadth_first(a),
|
||||||
h_(nshf->build())
|
h_(nshf->build())
|
||||||
{
|
{
|
||||||
|
|
@ -203,10 +203,8 @@ namespace spot
|
||||||
const std::string ss = automata_->format_state(source);
|
const std::string ss = automata_->format_state(source);
|
||||||
const std::string sd = automata_->format_state(dest);
|
const std::string sd = automata_->format_state(dest);
|
||||||
|
|
||||||
tgba_explicit::state* s
|
tgba_explicit::state* s = tgba_explicit_string::add_state(ss);
|
||||||
= tgba_explicit::add_state(ss);
|
tgba_explicit::state* d = tgba_explicit_string::add_state(sd);
|
||||||
tgba_explicit::state* d
|
|
||||||
= tgba_explicit::add_state(sd);
|
|
||||||
|
|
||||||
transition* t = new transition();
|
transition* t = new transition();
|
||||||
t->dest = d;
|
t->dest = d;
|
||||||
|
|
@ -241,9 +239,9 @@ namespace spot
|
||||||
bdd acc_simul;
|
bdd acc_simul;
|
||||||
std::list<state*> ltmp;
|
std::list<state*> ltmp;
|
||||||
const tgba_explicit::state* s1 =
|
const tgba_explicit::state* s1 =
|
||||||
name_state_map_[tgba_explicit::format_state(s)];
|
name_state_map_[tgba_explicit_string::format_state(s)];
|
||||||
const tgba_explicit::state* s2 =
|
const tgba_explicit::state* s2 =
|
||||||
name_state_map_[tgba_explicit::format_state(simul)];
|
name_state_map_[tgba_explicit_string::format_state(simul)];
|
||||||
|
|
||||||
sp_map::iterator i = state_predecessor_map_.find(s1);
|
sp_map::iterator i = state_predecessor_map_.find(s1);
|
||||||
if (i == state_predecessor_map_.end()) // 0 predecessor
|
if (i == state_predecessor_map_.end()) // 0 predecessor
|
||||||
|
|
@ -323,12 +321,12 @@ namespace spot
|
||||||
// predecessor in state_predecessor_map_.
|
// predecessor in state_predecessor_map_.
|
||||||
|
|
||||||
ns_map::iterator k =
|
ns_map::iterator k =
|
||||||
name_state_map_.find(tgba_explicit::format_state(s));
|
name_state_map_.find(tgba_explicit_string::format_state(s));
|
||||||
if (k == name_state_map_.end()) // 0 predecessor
|
if (k == name_state_map_.end()) // 0 predecessor
|
||||||
return;
|
return;
|
||||||
|
|
||||||
tgba_explicit::state* st =
|
tgba_explicit::state* st =
|
||||||
name_state_map_[tgba_explicit::format_state(s)];
|
name_state_map_[tgba_explicit_string::format_state(s)];
|
||||||
|
|
||||||
// for all successor q of s, we remove s of the predecessor of q.
|
// for all successor q of s, we remove s of the predecessor of q.
|
||||||
// Note that the initial node can't be removed.
|
// Note that the initial node can't be removed.
|
||||||
|
|
@ -370,9 +368,9 @@ namespace spot
|
||||||
tgba_reduc::merge_state(const spot::state* sim1, const spot::state* sim2)
|
tgba_reduc::merge_state(const spot::state* sim1, const spot::state* sim2)
|
||||||
{
|
{
|
||||||
const tgba_explicit::state* s1 =
|
const tgba_explicit::state* s1 =
|
||||||
name_state_map_[tgba_explicit::format_state(sim1)];
|
name_state_map_[tgba_explicit_string::format_state(sim1)];
|
||||||
const tgba_explicit::state* s2 =
|
const tgba_explicit::state* s2 =
|
||||||
name_state_map_[tgba_explicit::format_state(sim2)];
|
name_state_map_[tgba_explicit_string::format_state(sim2)];
|
||||||
const tgba_explicit::state* stmp = s1;
|
const tgba_explicit::state* stmp = s1;
|
||||||
const spot::state* simtmp = sim1;
|
const spot::state* simtmp = sim1;
|
||||||
|
|
||||||
|
|
@ -612,7 +610,7 @@ namespace spot
|
||||||
|
|
||||||
if (sm->second == n)
|
if (sm->second == n)
|
||||||
{
|
{
|
||||||
s1 = name_state_map_[tgba_explicit::format_state(s)];
|
s1 = name_state_map_[tgba_explicit_string::format_state(s)];
|
||||||
s1 = const_cast<tgba_explicit::state*>(s1);
|
s1 = const_cast<tgba_explicit::state*>(s1);
|
||||||
for (state::iterator i = s1->begin();
|
for (state::iterator i = s1->begin();
|
||||||
i != s1->end(); ++i)
|
i != s1->end(); ++i)
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright (C) 2004, 2005, 2006, 2008 Laboratoire d'Informatique de
|
// Copyright (C) 2004, 2005, 2006, 2008, 2009 Laboratoire d'Informatique de
|
||||||
// Paris 6 (LIP6), département Systèmes Répartis Coopératifs (SRC),
|
// Paris 6 (LIP6), département Systèmes Répartis Coopératifs (SRC),
|
||||||
// Université Pierre et Marie Curie.
|
// Université Pierre et Marie Curie.
|
||||||
//
|
//
|
||||||
|
|
@ -51,7 +51,7 @@ namespace spot
|
||||||
/// Explicit automata used in reductions.
|
/// Explicit automata used in reductions.
|
||||||
/// \ingroup tgba_representation
|
/// \ingroup tgba_representation
|
||||||
class tgba_reduc:
|
class tgba_reduc:
|
||||||
public tgba_explicit, public tgba_reachable_iterator_breadth_first
|
public tgba_explicit_string, public tgba_reachable_iterator_breadth_first
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
tgba_reduc(const tgba* a,
|
tgba_reduc(const tgba* a,
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ namespace spot
|
||||||
tgba* cut_scc(const tgba* a, const scc_map& m,
|
tgba* cut_scc(const tgba* a, const scc_map& m,
|
||||||
const std::set<unsigned>* s)
|
const std::set<unsigned>* s)
|
||||||
{
|
{
|
||||||
tgba_explicit* sub_a = new tgba_explicit(a->get_dict());
|
tgba_explicit_string* sub_a = new tgba_explicit_string(a->get_dict());
|
||||||
state* cur = a->get_init_state();
|
state* cur = a->get_init_state();
|
||||||
std::queue<state*> tovisit;
|
std::queue<state*> tovisit;
|
||||||
typedef Sgi::hash_set<const state*,
|
typedef Sgi::hash_set<const state*,
|
||||||
|
|
@ -418,4 +418,3 @@ namespace spot
|
||||||
return iter_count;
|
return iter_count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright (C) 2003, 2004 Laboratoire d'Informatique de Paris 6 (LIP6),
|
// Copyright (C) 2003, 2004, 2009 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,12 +34,12 @@ namespace spot
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
dupexp_iter(const tgba* a)
|
dupexp_iter(const tgba* a)
|
||||||
: T(a), out_(new tgba_explicit(a->get_dict()))
|
: T(a), out_(new tgba_explicit_string(a->get_dict()))
|
||||||
{
|
{
|
||||||
out_->copy_acceptance_conditions_of(a);
|
out_->copy_acceptance_conditions_of(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
tgba_explicit*
|
tgba_explicit_string*
|
||||||
result()
|
result()
|
||||||
{
|
{
|
||||||
return out_;
|
return out_;
|
||||||
|
|
@ -62,7 +62,7 @@ namespace spot
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
tgba_explicit* out_;
|
tgba_explicit_string* out_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // anonymous
|
} // anonymous
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright (C) 2004, 2005 Laboratoire d'Informatique de Paris 6 (LIP6),
|
// Copyright (C) 2004, 2005, 2009 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.
|
||||||
//
|
//
|
||||||
|
|
@ -292,7 +292,7 @@ namespace spot
|
||||||
tgba*
|
tgba*
|
||||||
tgba_run_to_tgba(const tgba* a, const tgba_run* run)
|
tgba_run_to_tgba(const tgba* a, const tgba_run* run)
|
||||||
{
|
{
|
||||||
tgba_explicit* res = new tgba_explicit(a->get_dict());
|
tgba_explicit_string* res = new tgba_explicit_string(a->get_dict());
|
||||||
res->copy_acceptance_conditions_of(a);
|
res->copy_acceptance_conditions_of(a);
|
||||||
|
|
||||||
const state* s = a->get_init_state();
|
const state* s = a->get_init_state();
|
||||||
|
|
|
||||||
|
|
@ -195,7 +195,8 @@ namespace spot
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
conj_bdd_to_acc(tgba_explicit* a, bdd b, tgba_explicit::transition* t)
|
conj_bdd_to_acc(tgba_explicit_string* a, bdd b,
|
||||||
|
tgba_explicit::transition* t)
|
||||||
{
|
{
|
||||||
assert(b != bddfalse);
|
assert(b != bddfalse);
|
||||||
while (b != bddtrue)
|
while (b != bddtrue)
|
||||||
|
|
@ -775,7 +776,7 @@ namespace spot
|
||||||
formulae_seen.insert(f2);
|
formulae_seen.insert(f2);
|
||||||
formulae_to_translate.insert(f2);
|
formulae_to_translate.insert(f2);
|
||||||
|
|
||||||
tgba_explicit* a = new tgba_explicit(dict);
|
tgba_explicit_string* a = new tgba_explicit_string(dict);
|
||||||
|
|
||||||
a->set_init_state(to_string(f2));
|
a->set_init_state(to_string(f2));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright (C) 2004 Laboratoire d'Informatique de Paris 6 (LIP6),
|
// Copyright (C) 2004, 2009 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.
|
||||||
//
|
//
|
||||||
|
|
@ -40,7 +40,7 @@ namespace spot
|
||||||
|
|
||||||
power_set seen;
|
power_set seen;
|
||||||
todo_list todo;
|
todo_list todo;
|
||||||
tgba_explicit* res = new tgba_explicit(aut->get_dict());
|
tgba_explicit_string* res = new tgba_explicit_string(aut->get_dict());
|
||||||
|
|
||||||
state_set states;
|
state_set states;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -95,7 +95,7 @@ namespace spot
|
||||||
ltl::environment* env)
|
ltl::environment* env)
|
||||||
{
|
{
|
||||||
assert(n > 0);
|
assert(n > 0);
|
||||||
tgba_explicit* res = new tgba_explicit(dict);
|
tgba_explicit_string* res = new tgba_explicit_string(dict);
|
||||||
|
|
||||||
int props_n = ap->size();
|
int props_n = ap->size();
|
||||||
int* props = new int[props_n];
|
int* props = new int[props_n];
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
// Copyright (C) 2003, 2004, 2005, 2006 Laboratoire d'Informatique de
|
// Copyright (C) 2003, 2004, 2005, 2006, 2009 Laboratoire
|
||||||
// Paris 6 (LIP6), département Systèmes Répartis Coopératifs (SRC),
|
// d'Informatique de Paris 6 (LIP6), département Systèmes Répartis
|
||||||
// Université Pierre et Marie Curie.
|
// Coopératifs (SRC), Université Pierre et Marie Curie.
|
||||||
//
|
//
|
||||||
// This file is part of Spot, a model checking library.
|
// This file is part of Spot, a model checking library.
|
||||||
//
|
//
|
||||||
|
|
@ -62,7 +62,7 @@ namespace spot
|
||||||
/// was parsed succesfully, check \a error_list for emptiness.
|
/// was parsed succesfully, check \a error_list for emptiness.
|
||||||
///
|
///
|
||||||
/// \warning This function is not reentrant.
|
/// \warning This function is not reentrant.
|
||||||
tgba_explicit* tgba_parse(const std::string& filename,
|
tgba_explicit_string* tgba_parse(const std::string& filename,
|
||||||
tgba_parse_error_list& error_list,
|
tgba_parse_error_list& error_list,
|
||||||
bdd_dict* dict,
|
bdd_dict* dict,
|
||||||
ltl::environment& env
|
ltl::environment& env
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ typedef std::map<std::string, bdd> formula_cache;
|
||||||
%parse-param {spot::tgba_parse_error_list& error_list}
|
%parse-param {spot::tgba_parse_error_list& error_list}
|
||||||
%parse-param {spot::ltl::environment& parse_environment}
|
%parse-param {spot::ltl::environment& parse_environment}
|
||||||
%parse-param {spot::ltl::environment& parse_envacc}
|
%parse-param {spot::ltl::environment& parse_envacc}
|
||||||
%parse-param {spot::tgba_explicit*& result}
|
%parse-param {spot::tgba_explicit_string*& result}
|
||||||
%parse-param {formula_cache& fcache}
|
%parse-param {formula_cache& fcache}
|
||||||
%union
|
%union
|
||||||
{
|
{
|
||||||
|
|
@ -233,7 +233,7 @@ tgbayy::parser::error(const location_type& location,
|
||||||
|
|
||||||
namespace spot
|
namespace spot
|
||||||
{
|
{
|
||||||
tgba_explicit*
|
tgba_explicit_string*
|
||||||
tgba_parse(const std::string& name,
|
tgba_parse(const std::string& name,
|
||||||
tgba_parse_error_list& error_list,
|
tgba_parse_error_list& error_list,
|
||||||
bdd_dict* dict,
|
bdd_dict* dict,
|
||||||
|
|
@ -249,7 +249,7 @@ namespace spot
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
formula_cache fcache;
|
formula_cache fcache;
|
||||||
tgba_explicit* result = new tgba_explicit(dict);
|
tgba_explicit_string* result = new tgba_explicit_string(dict);
|
||||||
tgbayy::parser parser(error_list, env, envacc, result, fcache);
|
tgbayy::parser parser(error_list, env, envacc, result, fcache);
|
||||||
parser.set_debug_level(debug);
|
parser.set_debug_level(debug);
|
||||||
parser.parse();
|
parser.parse();
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright (C) 2003, 2004 Laboratoire d'Informatique de Paris 6 (LIP6),
|
// Copyright (C) 2003, 2004, 2009 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.
|
||||||
//
|
//
|
||||||
|
|
@ -33,7 +33,7 @@ main()
|
||||||
|
|
||||||
spot::ltl::default_environment& e =
|
spot::ltl::default_environment& e =
|
||||||
spot::ltl::default_environment::instance();
|
spot::ltl::default_environment::instance();
|
||||||
spot::tgba_explicit* a = new spot::tgba_explicit(dict);
|
spot::tgba_explicit_string* a = new spot::tgba_explicit_string(dict);
|
||||||
|
|
||||||
typedef spot::tgba_explicit::transition trans;
|
typedef spot::tgba_explicit::transition trans;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -202,7 +202,7 @@ main(int argc, char** argv)
|
||||||
bool show_fc = false;
|
bool show_fc = false;
|
||||||
spot::ltl::environment& env(spot::ltl::default_environment::instance());
|
spot::ltl::environment& env(spot::ltl::default_environment::instance());
|
||||||
spot::ltl::atomic_prop_set* unobservables = 0;
|
spot::ltl::atomic_prop_set* unobservables = 0;
|
||||||
spot::tgba_explicit* system = 0;
|
spot::tgba_explicit_string* system = 0;
|
||||||
spot::tgba* product = 0;
|
spot::tgba* product = 0;
|
||||||
spot::tgba* product_to_free = 0;
|
spot::tgba* product_to_free = 0;
|
||||||
spot::bdd_dict* dict = new spot::bdd_dict();
|
spot::bdd_dict* dict = new spot::bdd_dict();
|
||||||
|
|
@ -574,7 +574,7 @@ main(int argc, char** argv)
|
||||||
if (from_file)
|
if (from_file)
|
||||||
{
|
{
|
||||||
spot::tgba_parse_error_list pel;
|
spot::tgba_parse_error_list pel;
|
||||||
spot::tgba_explicit* e;
|
spot::tgba_explicit_string* e;
|
||||||
tm.start("parsing automaton");
|
tm.start("parsing automaton");
|
||||||
to_free = a = e = spot::tgba_parse(input, pel, dict,
|
to_free = a = e = spot::tgba_parse(input, pel, dict,
|
||||||
env, env, debug_opt);
|
env, env, debug_opt);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue