This implements Couvreur's FM'99 ltl2tgba translation.

* src/tgba/bdddict.cc (bdd_dict::is_registered): Split as ...
(bdd_dict::is_registered_proposition, bdd_dict::is_registered_state,
bdd_dict::is_registered_accepting_variable): ... these.
* src/tgba/bdddict.hh: Likewise.
* src/tgba/tgbaexplicit.cc (tgba_explicit::set_init_state): New method.
(tgba_explicit::declare_accepting_condition): Arrange so that this
function can be called during the construction of the automaton.
(tgba_explicit::complement_all_accepting_conditions): New method.
(tgba_explicit::has_accepting_condition): Adjust to call
bdd_dict::is_registered_accepting_variable.
* src/tgba/tgbaexplicit.hh (tgba_explicit::set_init_state,
tgba_explicit::complement_all_accepting_conditions): New methods.
* src/tgbaalgos/ltl2tgba_fm.cc, src/tgbaalgos/ltl2tgba_fm.hh:
New files.
* src/tgbaalgos/Makefile.am (tgbaalgos_HEADERS,
libtgbaalgos_la_SOURCES): Add them.
* src/tgbaalgos/ltl2tgba.hh: Add bibtex entry in comment.
* src/tgbatest/Makefile.am (check_PROGRAMS): Remove spotlbtt
and tbalbtt.
(tbalbtt_SOURCES, tbalbtt_CXXFLAGS, spotlbtt_SOURCES): Remove.
* src/tgbatest/spotlbtt.cc: Delete, superseded by "ltl2tgba -F -t".
* src/tgbatest/ltl2tgba.cc: Implement the -f and -F options.
* src/tgbatest/spotlbtt.test: Use "ltl2tgba -F -t" instead of
"spotlbtt", "ltl2tgba -F -t -D" instead of "tbalbtt", and add
also check the ltl2tgba_fm translator.
* wrap/python/spot.i: Wrap ltl2tgba_fm.
* wrap/python/cgi/ltl2tgba.in: Add radio buttons to select
between ltl2tgba and ltl2tgba_fm.
* wrap/python/tests/ltl2tgba.py: Add support for the -f option.
* wrap/python/tests/ltl2tgba.test: Try the -f option.
This commit is contained in:
Alexandre Duret-Lutz 2003-08-15 01:33:09 +00:00
parent 256d800580
commit 2b9f17202c
17 changed files with 820 additions and 159 deletions

View file

@ -161,30 +161,33 @@ namespace spot
}
bool
bdd_dict::is_registered(const ltl::formula* f, const void* by_me)
bdd_dict::is_registered_proposition(const ltl::formula* f, const void* by_me)
{
int var;
fv_map::iterator fi = var_map.find(f);
if (fi != var_map.end())
{
var = fi->second;
}
else
{
fi = now_map.find(f);
if (fi != now_map.end())
{
var = fi->second;
}
else
{
fi = acc_map.find(f);
if (fi == acc_map.end())
return false;
var = fi->second;
}
}
ref_set& s = var_refs[var];
if (fi == var_map.end())
return false;
ref_set& s = var_refs[fi->second];
return s.find(by_me) != s.end();
}
bool
bdd_dict::is_registered_state(const ltl::formula* f, const void* by_me)
{
fv_map::iterator fi = now_map.find(f);
if (fi == now_map.end())
return false;
ref_set& s = var_refs[fi->second];
return s.find(by_me) != s.end();
}
bool
bdd_dict::is_registered_accepting_variable(const ltl::formula* f,
const void* by_me)
{
fv_map::iterator fi = acc_map.find(f);
if (fi == acc_map.end())
return false;
ref_set& s = var_refs[fi->second];
return s.find(by_me) != s.end();
}

View file

@ -91,8 +91,13 @@ namespace spot
/// Usually called in the destructor if \a me.
void unregister_all_my_variables(const void* me);
/// @{
/// Check whether formula \a f has already been registered by \a by_me.
bool is_registered(const ltl::formula* f, const void* by_me);
bool is_registered_proposition(const ltl::formula* f, const void* by_me);
bool is_registered_state(const ltl::formula* f, const void* by_me);
bool is_registered_accepting_variable(const ltl::formula* f,
const void* by_me);
/// @}
/// \brief Dump all variables for debugging.
/// \param os The output stream.

View file

@ -111,6 +111,7 @@ namespace spot
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;
@ -119,6 +120,14 @@ namespace spot
return i->second;
}
void
tgba_explicit::set_init_state(const std::string& state)
{
tgba_explicit::state* s = add_state(state);
init_ = s;
}
tgba_explicit::transition*
tgba_explicit::create_transition(const std::string& source,
const std::string& dest)
@ -159,13 +168,40 @@ namespace spot
{
int v = dict_->register_accepting_variable(f, this);
ltl::destroy(f);
neg_accepting_conditions_ &= bdd_nithvar(v);
bdd neg = bdd_nithvar(v);
neg_accepting_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)->accepting_conditions &= neg;
}
all_accepting_conditions_computed_ = false;
}
void
tgba_explicit::complement_all_accepting_conditions()
{
bdd all = all_accepting_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)->accepting_conditions = all - (*i2)->accepting_conditions;
}
}
}
bool
tgba_explicit::has_accepting_condition(ltl::formula* f) const
{
return dict_->is_registered(f, this);
return dict_->is_registered_accepting_variable(f, this);
}
bdd
@ -185,6 +221,9 @@ namespace spot
assert(0);
}
bdd_dict::fv_map::iterator i = dict_->acc_map.find(f);
assert(has_accepting_condition(f));
/* If this second assert fails and the first doesn't,
things are badly broken. This has already happened. */
assert(i != dict_->acc_map.end());
ltl::destroy(f);
bdd v = bdd_ithvar(i->second);

View file

@ -29,6 +29,8 @@ namespace spot
state* dest;
};
void set_init_state(const std::string& state);
transition*
create_transition(const std::string& source, const std::string& dest);
@ -37,6 +39,7 @@ namespace spot
void declare_accepting_condition(ltl::formula* f);
bool has_accepting_condition(ltl::formula* f) const;
void add_accepting_condition(transition* t, ltl::formula* f);
void complement_all_accepting_conditions();
// tgba interface
virtual ~tgba_explicit();