* src/tgba/succiter.hh (tgba_succ_iterator::current_state):
Return a state*, not a state_bdd. * src/tgba/succiterconcrete.hh (tgba_succ_iterator_concrete::current_state): Return a state_bdd*, not a state_bdd. * src/tgba/state.hh (state::as_bdd): New abstract method. * src/tgba/statebdd.hh (state_bdd::as_bdd): Move definitions ... * src/tgba/statebdd.cc (state_bdd::as_bdd): ... here. * src/tgba/tgba.hh: Add Doxygen comments. (tgba::succ_iter, tgba::get_init_state): Use state*, not state_bdd. * src/tgba/tgbabddconcrete.hh (tgba_bdd_concrete::get_init_state): Return a state_bdd*, not a state_bdd. (tgba_bdd_concrete::get_init_bdd): New method. (tgba_bdd_concrete::succ_uter): Take a state* as argument. * src/tgba/tgbabddconcrete.cc: Likewise. * src/tgba/tgbabddtranslatefactory.cc (tgba_bdd_translate_factory::tgba_bdd_translate_factory): Use tgba_bdd_concrete::get_init_bdd. * src/tgbaalgos/dotty.cc (dotty_state, dotty_rec, dotty): Adjust to use state* instead of state_bdd. * src/tgba/succlist.hh: Delete. (Leftover from a previous draft.)
This commit is contained in:
parent
d7e49255d3
commit
3f0e95f061
13 changed files with 139 additions and 64 deletions
25
ChangeLog
25
ChangeLog
|
|
@ -1,3 +1,28 @@
|
||||||
|
2003-05-27 Alexandre Duret-Lutz <aduret@src.lip6.fr>
|
||||||
|
|
||||||
|
* src/tgba/succiter.hh (tgba_succ_iterator::current_state):
|
||||||
|
Return a state*, not a state_bdd.
|
||||||
|
* src/tgba/succiterconcrete.hh
|
||||||
|
(tgba_succ_iterator_concrete::current_state): Return a state_bdd*,
|
||||||
|
not a state_bdd.
|
||||||
|
* src/tgba/state.hh (state::as_bdd): New abstract method.
|
||||||
|
* src/tgba/statebdd.hh (state_bdd::as_bdd): Move definitions ...
|
||||||
|
* src/tgba/statebdd.cc (state_bdd::as_bdd): ... here.
|
||||||
|
* src/tgba/tgba.hh: Add Doxygen comments.
|
||||||
|
(tgba::succ_iter, tgba::get_init_state): Use state*, not state_bdd.
|
||||||
|
* src/tgba/tgbabddconcrete.hh (tgba_bdd_concrete::get_init_state):
|
||||||
|
Return a state_bdd*, not a state_bdd.
|
||||||
|
(tgba_bdd_concrete::get_init_bdd): New method.
|
||||||
|
(tgba_bdd_concrete::succ_uter): Take a state* as argument.
|
||||||
|
* src/tgba/tgbabddconcrete.cc: Likewise.
|
||||||
|
* src/tgba/tgbabddtranslatefactory.cc
|
||||||
|
(tgba_bdd_translate_factory::tgba_bdd_translate_factory): Use
|
||||||
|
tgba_bdd_concrete::get_init_bdd.
|
||||||
|
* src/tgbaalgos/dotty.cc (dotty_state, dotty_rec, dotty): Adjust
|
||||||
|
to use state* instead of state_bdd.
|
||||||
|
* src/tgba/succlist.hh: Delete. (Leftover from a previous
|
||||||
|
draft.)
|
||||||
|
|
||||||
2003-05-26 Alexandre Duret-Lutz <aduret@src.lip6.fr>
|
2003-05-26 Alexandre Duret-Lutz <aduret@src.lip6.fr>
|
||||||
|
|
||||||
* src/tgbaalgos/dotty.cc, src/tgbaalgos/dotty.hh: New files.
|
* src/tgbaalgos/dotty.cc, src/tgbaalgos/dotty.hh: New files.
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
#ifndef SPOT_TGBA_STATE_HH
|
#ifndef SPOT_TGBA_STATE_HH
|
||||||
# define SPOT_TGBA_STATE_HH
|
# define SPOT_TGBA_STATE_HH
|
||||||
|
|
||||||
|
#include <bdd.h>
|
||||||
|
|
||||||
namespace spot
|
namespace spot
|
||||||
{
|
{
|
||||||
class state
|
class state
|
||||||
|
|
@ -16,6 +18,8 @@ namespace spot
|
||||||
// different automata.
|
// different automata.
|
||||||
virtual int compare(const state& other) const = 0;
|
virtual int compare(const state& other) const = 0;
|
||||||
|
|
||||||
|
virtual bdd as_bdd() const = 0;
|
||||||
|
|
||||||
virtual ~state()
|
virtual ~state()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,4 +13,11 @@ namespace spot
|
||||||
assert(o);
|
assert(o);
|
||||||
return o->as_bdd().id() - state_.id();
|
return o->as_bdd().id() - state_.id();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bdd
|
||||||
|
state_bdd::as_bdd() const
|
||||||
|
{
|
||||||
|
return state_;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,12 +14,7 @@ namespace spot
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bdd
|
virtual bdd as_bdd() const;
|
||||||
as_bdd() const
|
|
||||||
{
|
|
||||||
return state_;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual int compare(const state& other) const;
|
virtual int compare(const state& other) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef SPOT_TGBA_SUCCITER_H
|
#ifndef SPOT_TGBA_SUCCITER_H
|
||||||
# define SPOT_TGBA_SUCCITER_H
|
# define SPOT_TGBA_SUCCITER_H
|
||||||
|
|
||||||
#include "statebdd.hh"
|
#include "state.hh"
|
||||||
|
|
||||||
namespace spot
|
namespace spot
|
||||||
{
|
{
|
||||||
|
|
@ -20,7 +20,7 @@ namespace spot
|
||||||
virtual bool done() = 0;
|
virtual bool done() = 0;
|
||||||
|
|
||||||
// inspection
|
// inspection
|
||||||
virtual state_bdd current_state() = 0;
|
virtual state* current_state() = 0;
|
||||||
virtual bdd current_condition() = 0;
|
virtual bdd current_condition() = 0;
|
||||||
virtual bdd current_promise() = 0;
|
virtual bdd current_promise() = 0;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -40,11 +40,11 @@ namespace spot
|
||||||
return next_succ_set_ == bddfalse;
|
return next_succ_set_ == bddfalse;
|
||||||
}
|
}
|
||||||
|
|
||||||
state_bdd
|
state_bdd*
|
||||||
tgba_succ_iterator_concrete::current_state()
|
tgba_succ_iterator_concrete::current_state()
|
||||||
{
|
{
|
||||||
assert(!done());
|
assert(!done());
|
||||||
return bdd_exist(current_, data_.notnow_set);
|
return new state_bdd(bdd_exist(current_, data_.notnow_set));
|
||||||
}
|
}
|
||||||
|
|
||||||
bdd
|
bdd
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
#ifndef SPOT_TGBA_SUCCITERCONCRETE_HH
|
#ifndef SPOT_TGBA_SUCCITERCONCRETE_HH
|
||||||
# define SPOT_TGBA_SUCCITERCONCRETE_HH
|
# define SPOT_TGBA_SUCCITERCONCRETE_HH
|
||||||
|
|
||||||
|
#include "statebdd.hh"
|
||||||
#include "succiter.hh"
|
#include "succiter.hh"
|
||||||
#include "tgbabddcoredata.hh"
|
#include "tgbabddcoredata.hh"
|
||||||
|
|
||||||
|
|
@ -18,7 +19,7 @@ namespace spot
|
||||||
bool done();
|
bool done();
|
||||||
|
|
||||||
// inspection
|
// inspection
|
||||||
state_bdd current_state();
|
state_bdd* current_state();
|
||||||
bdd current_condition();
|
bdd current_condition();
|
||||||
bdd current_promise();
|
bdd current_promise();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
||||||
#ifndef SPOT_WAUTO_SUCCLIST_HH
|
|
||||||
# define SPOT_WAUTO_SUCCLIST_HH
|
|
||||||
|
|
||||||
namespace spot
|
|
||||||
{
|
|
||||||
|
|
||||||
struct successor_list
|
|
||||||
{
|
|
||||||
virtual
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif SPOT_WAUTO_SUCCLIST_HH
|
|
||||||
|
|
@ -1,12 +1,34 @@
|
||||||
#ifndef SPOT_TGBA_TGBA_HH
|
#ifndef SPOT_TGBA_TGBA_HH
|
||||||
# define SPOT_TGBA_TGBA_HH
|
# define SPOT_TGBA_TGBA_HH
|
||||||
|
|
||||||
#include "statebdd.hh"
|
#include "state.hh"
|
||||||
#include "succiter.hh"
|
#include "succiter.hh"
|
||||||
#include "tgbabdddict.hh"
|
#include "tgbabdddict.hh"
|
||||||
|
|
||||||
namespace spot
|
namespace spot
|
||||||
{
|
{
|
||||||
|
/// \brief A Transition-based Generalized Büchi Automaton.
|
||||||
|
///
|
||||||
|
/// The acronym TGBA (Transition-based Generalized Büchi Automaton)
|
||||||
|
/// was coined by Dimitra Giannakopoulou and Flavio Lerda
|
||||||
|
/// in "From States to Transitions: Improving Translation of LTL
|
||||||
|
/// Formulae to Büchi Automata". (FORTE'02)
|
||||||
|
///
|
||||||
|
/// TGBAs are transition-based, meanings their labels are put
|
||||||
|
/// on arcs, not on nodes. They use Generalized Büchi acceptance
|
||||||
|
/// conditions: there are several accepting sets (of
|
||||||
|
/// transitions), and a path can be accepted only if it traverse
|
||||||
|
/// at least one transition of each set infinitely often.
|
||||||
|
///
|
||||||
|
/// Browsing such automaton can be achieved using two functions.
|
||||||
|
/// \c get_init_state, and \c succ_iter. The former returns
|
||||||
|
/// the initial state while the latter allows to explore the
|
||||||
|
/// successor states of any state.
|
||||||
|
///
|
||||||
|
/// Note that although this is a transition-based automata,
|
||||||
|
/// we never represent transitions! Transition informations are
|
||||||
|
/// obtained by querying the iterator over the successors of
|
||||||
|
/// a state.
|
||||||
class tgba
|
class tgba
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
@ -15,9 +37,33 @@ namespace spot
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual state_bdd get_init_state() const = 0;
|
/// \brief Get the initial state of the automaton.
|
||||||
virtual tgba_succ_iterator* succ_iter(state_bdd state) const = 0;
|
///
|
||||||
|
/// The state has been allocated with \c new. It is the
|
||||||
|
/// responsability of the caller to \c delete it when no
|
||||||
|
/// longer needed.
|
||||||
|
virtual state* get_init_state() const = 0;
|
||||||
|
|
||||||
|
/// \brief Get an iterator over the successors of \a state.
|
||||||
|
///
|
||||||
|
/// The iterator has been allocated with \c new. It is the
|
||||||
|
/// responsability of the caller to \c delete it when no
|
||||||
|
/// longer needed.
|
||||||
|
///
|
||||||
|
/// \param state is the state whose successors are to be explored.
|
||||||
|
/// This pointer is not adopted in any way by \c succ_iter, and
|
||||||
|
/// it is still the caller's responsability to delete it when
|
||||||
|
/// appropriate (this can be done during the lifetime of
|
||||||
|
/// the iterator).
|
||||||
|
virtual tgba_succ_iterator* succ_iter(const state* state) const = 0;
|
||||||
|
|
||||||
|
/// \brief Get the dictionary associated to the automaton.
|
||||||
|
///
|
||||||
|
/// State are represented as BDDs. The dictionary allows
|
||||||
|
/// to map BDD variables back to formulae, and vice versa.
|
||||||
|
/// This is useful when dealing with several automata (which
|
||||||
|
/// may use the same BDD variable for different formula),
|
||||||
|
/// or simply when printing.
|
||||||
virtual const tgba_bdd_dict& get_dict() const = 0;
|
virtual const tgba_bdd_dict& get_dict() const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,16 +22,24 @@ namespace spot
|
||||||
init_ = s;
|
init_ = s;
|
||||||
}
|
}
|
||||||
|
|
||||||
state_bdd
|
state_bdd*
|
||||||
tgba_bdd_concrete::get_init_state() const
|
tgba_bdd_concrete::get_init_state() const
|
||||||
|
{
|
||||||
|
return new state_bdd(init_);
|
||||||
|
}
|
||||||
|
|
||||||
|
bdd
|
||||||
|
tgba_bdd_concrete::get_init_bdd() const
|
||||||
{
|
{
|
||||||
return init_;
|
return init_;
|
||||||
}
|
}
|
||||||
|
|
||||||
tgba_succ_iterator_concrete*
|
tgba_succ_iterator_concrete*
|
||||||
tgba_bdd_concrete::succ_iter(state_bdd state) const
|
tgba_bdd_concrete::succ_iter(const state* state) const
|
||||||
{
|
{
|
||||||
bdd succ_set = bdd_replace(bdd_exist(data_.relation & state.as_bdd(),
|
const state_bdd* s = dynamic_cast<const state_bdd*>(state);
|
||||||
|
assert(s);
|
||||||
|
bdd succ_set = bdd_replace(bdd_exist(data_.relation & s->as_bdd(),
|
||||||
data_.now_set),
|
data_.now_set),
|
||||||
data_.next_to_now);
|
data_.next_to_now);
|
||||||
return new tgba_succ_iterator_concrete(data_, succ_set);
|
return new tgba_succ_iterator_concrete(data_, succ_set);
|
||||||
|
|
|
||||||
|
|
@ -16,9 +16,10 @@ namespace spot
|
||||||
~tgba_bdd_concrete();
|
~tgba_bdd_concrete();
|
||||||
|
|
||||||
void set_init_state(bdd s);
|
void set_init_state(bdd s);
|
||||||
state_bdd get_init_state() const;
|
state_bdd* get_init_state() const;
|
||||||
|
bdd get_init_bdd() const;
|
||||||
|
|
||||||
tgba_succ_iterator_concrete* succ_iter(state_bdd state) const;
|
tgba_succ_iterator_concrete* succ_iter(const state* state) const;
|
||||||
|
|
||||||
const tgba_bdd_dict& get_dict() const;
|
const tgba_bdd_dict& get_dict() const;
|
||||||
const tgba_bdd_core_data& get_core_data() const;
|
const tgba_bdd_core_data& get_core_data() const;
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ namespace spot
|
||||||
data_.notvar_set = bdd_replace(in.notvar_set, rewrite);
|
data_.notvar_set = bdd_replace(in.notvar_set, rewrite);
|
||||||
data_.notprom_set = bdd_replace(in.notprom_set, rewrite);
|
data_.notprom_set = bdd_replace(in.notprom_set, rewrite);
|
||||||
|
|
||||||
init_ = bdd_replace(from.get_init_state().as_bdd(), rewrite);
|
init_ = bdd_replace(from.get_init_bdd(), rewrite);
|
||||||
|
|
||||||
bdd_freepair(rewrite);
|
bdd_freepair(rewrite);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include "tgba/tgba.hh"
|
||||||
#include "dotty.hh"
|
#include "dotty.hh"
|
||||||
#include "tgba/bddprint.hh"
|
#include "tgba/bddprint.hh"
|
||||||
|
|
||||||
|
|
@ -8,9 +9,9 @@ namespace spot
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
dotty_state(std::ostream& os,
|
dotty_state(std::ostream& os,
|
||||||
const tgba& g, state_bdd state, seen_map& m, int& node)
|
const tgba& g, state* st, seen_map& m, int& node)
|
||||||
{
|
{
|
||||||
bdd s = state.as_bdd();
|
bdd s = st->as_bdd();
|
||||||
seen_map::iterator i = m.find(s.id());
|
seen_map::iterator i = m.find(s.id());
|
||||||
|
|
||||||
// Already drawn?
|
// Already drawn?
|
||||||
|
|
@ -30,13 +31,13 @@ namespace spot
|
||||||
|
|
||||||
static void
|
static void
|
||||||
dotty_rec(std::ostream& os,
|
dotty_rec(std::ostream& os,
|
||||||
const tgba& g, state_bdd state, seen_map& m, int father)
|
const tgba& g, state* st, seen_map& m, int father)
|
||||||
{
|
{
|
||||||
tgba_succ_iterator* si = g.succ_iter(state);
|
tgba_succ_iterator* si = g.succ_iter(st);
|
||||||
for (si->first(); !si->done(); si->next())
|
for (si->first(); !si->done(); si->next())
|
||||||
{
|
{
|
||||||
int node;
|
int node;
|
||||||
state_bdd s = si->current_state();
|
state* s = si->current_state();
|
||||||
bool recurse = dotty_state(os, g, s, m, node);
|
bool recurse = dotty_state(os, g, s, m, node);
|
||||||
os << " " << father << " -> " << node << " [label=\"";
|
os << " " << father << " -> " << node << " [label=\"";
|
||||||
bdd_print_set(os, g.get_dict(), si->current_condition()) << "\\n";
|
bdd_print_set(os, g.get_dict(), si->current_condition()) << "\\n";
|
||||||
|
|
@ -44,6 +45,7 @@ namespace spot
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
if (recurse)
|
if (recurse)
|
||||||
dotty_rec(os, g, s, m, node);
|
dotty_rec(os, g, s, m, node);
|
||||||
|
delete s;
|
||||||
}
|
}
|
||||||
delete si;
|
delete si;
|
||||||
}
|
}
|
||||||
|
|
@ -52,7 +54,7 @@ namespace spot
|
||||||
dotty_reachable(std::ostream& os, const tgba& g)
|
dotty_reachable(std::ostream& os, const tgba& g)
|
||||||
{
|
{
|
||||||
seen_map m;
|
seen_map m;
|
||||||
state_bdd state = g.get_init_state();
|
state* state = g.get_init_state();
|
||||||
os << "digraph G {" << std::endl;
|
os << "digraph G {" << std::endl;
|
||||||
os << " size=\"7.26,10.69\"" << std::endl;
|
os << " size=\"7.26,10.69\"" << std::endl;
|
||||||
os << " 0 [label=\"\", style=invis]" << std::endl;
|
os << " 0 [label=\"\", style=invis]" << std::endl;
|
||||||
|
|
@ -61,6 +63,7 @@ namespace spot
|
||||||
os << " 0 -> " << init << std::endl;
|
os << " 0 -> " << init << std::endl;
|
||||||
dotty_rec(os, g, state, m, init);
|
dotty_rec(os, g, state, m, init);
|
||||||
os << "}" << std::endl;
|
os << "}" << std::endl;
|
||||||
|
delete state;
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue