Commit 5a706300 authored by Ala-Eddine Ben-Salem's avatar Ala-Eddine Ben-Salem Committed by Alexandre Duret-Lutz
Browse files

Stable version of TGTA approach implementation (automaton + product)

* src/ta/tgta.hh, src/ta/tgta.cc, src/ta/tgtaexplicit.hh,
src/ta/tgtaexplicit.hh, src/ta/tgtaproduct.hh, src/ta/tgtaproduct.cc,
src/taalgos/minimize.cc, src/taalgos/minimize.hh,
src/taalgos/emptinessta.hh, src/taalgos/emptinessta.hh,
src/taalgos/emptinessta.cc, src/taalgos/tgba2ta.hh,
src/taalgos/tgba2ta.cc: rename tgbta to tgta
in this source files.
* src/ta/tgbtaexplicit.hh, src/ta/tgbtaproduct.hh,  src/ta/tgbta.cc,
src/ta/tgbtaproduct.cc, src/ta/tgbta.hh, src/ta/tgbtaexplicit.cc:
Rename as...
* src/ta/taexplicit.cc, src/ta/taexplicit.hh, src/ta/taproduct.cc,
src/ta/taproduct.hh, src/ta/tgtaexplicit.cc: ... these.
* src/taalgos/sba2ta.hh, src/taalgos/sba2ta.cc: deleted because
the implementation of all the transformations beteween TGBA and
the different forms of TA are new implemented in src/taalgos/tgba2ta.hh
 and src/taalgos/tgba2ta.cc.
* src/tgbatest/ltl2tgba.cc: rename the options of commands that build
the different forms of TA.
* src/ta/ta.hh: BUG Fix
* src/ta/Makefile.am, src/tgbatest/ltl2ta.test: impacts of this renaming
parent c76e651b
...@@ -27,16 +27,16 @@ ta_HEADERS = \ ...@@ -27,16 +27,16 @@ ta_HEADERS = \
ta.hh \ ta.hh \
taexplicit.hh \ taexplicit.hh \
taproduct.hh \ taproduct.hh \
tgbta.hh \ tgta.hh \
tgbtaexplicit.hh \ tgtaexplicit.hh \
tgbtaproduct.hh tgtaproduct.hh
noinst_LTLIBRARIES = libta.la noinst_LTLIBRARIES = libta.la
libta_la_SOURCES = \ libta_la_SOURCES = \
ta.cc \ ta.cc \
taproduct.cc \ taproduct.cc \
tgbta.cc \ tgta.cc \
tgbtaexplicit.cc \ tgtaexplicit.cc \
taexplicit.cc \ taexplicit.cc \
tgbtaproduct.cc tgtaproduct.cc
...@@ -51,7 +51,7 @@ namespace spot ...@@ -51,7 +51,7 @@ namespace spot
/// ///
/// The Testing Automata (TA) were introduced by /// The Testing Automata (TA) were introduced by
/// Henri Hansen, Wojciech Penczek and Antti Valmari /// Henri Hansen, Wojciech Penczek and Antti Valmari
/// in "Stuttering-insensitive automata for on-the-fly de- tection of livelock /// in "Stuttering-insensitive automata for on-the-fly detection of livelock
/// properties" In Proc. of FMICSÕ02, vol. 66(2) of Electronic Notes in /// properties" In Proc. of FMICSÕ02, vol. 66(2) of Electronic Notes in
/// Theoretical Computer Science.Elsevier. /// Theoretical Computer Science.Elsevier.
/// ///
...@@ -69,7 +69,7 @@ namespace spot ...@@ -69,7 +69,7 @@ namespace spot
/// Browsing such automaton can be achieved using two functions: /// Browsing such automaton can be achieved using two functions:
/// \c get_initial_states_set or \c get_artificial_initial_state, and \c /// \c get_initial_states_set or \c get_artificial_initial_state, and \c
/// succ_iter. The former returns the initial state(s) while the latter lists /// succ_iter. The former returns the initial state(s) while the latter lists
/// the successor states of any state (filtred by transition "changeset"). /// the successor states of any state (filtred by "changeset").
/// ///
/// Note that although this is a transition-based automata, /// Note that although this is a transition-based automata,
/// we never represent transitions! Transition informations are /// we never represent transitions! Transition informations are
...@@ -98,7 +98,7 @@ namespace spot ...@@ -98,7 +98,7 @@ namespace spot
/// artificial initial state have one transition to each real initial state, /// artificial initial state have one transition to each real initial state,
/// and this transition is labeled by the corresponding initial condition. /// and this transition is labeled by the corresponding initial condition.
/// (For more details, see the paper cited above) /// (For more details, see the paper cited above)
spot::state* virtual spot::state*
get_artificial_initial_state() const get_artificial_initial_state() const
{ {
return 0; return 0;
...@@ -114,7 +114,7 @@ namespace spot ...@@ -114,7 +114,7 @@ namespace spot
succ_iter(const spot::state* state) const = 0; succ_iter(const spot::state* state) const = 0;
/// \brief Get an iterator over the successors of \a state /// \brief Get an iterator over the successors of \a state
/// filtred by the changeset labeling the transitions /// filtred by the changeset on transitions
/// ///
/// The iterator has been allocated with \c new. It is the /// The iterator has been allocated with \c new. It is the
/// responsability of the caller to \c delete it when no /// responsability of the caller to \c delete it when no
......
...@@ -105,7 +105,6 @@ namespace spot ...@@ -105,7 +105,6 @@ namespace spot
return (*i_)->acceptance_conditions; return (*i_)->acceptance_conditions;
} }
//////////////////////////////////////// ////////////////////////////////////////
// state_ta_explicit // state_ta_explicit
...@@ -141,19 +140,19 @@ namespace spot ...@@ -141,19 +140,19 @@ namespace spot
if (transitions_ == 0) if (transitions_ == 0)
transitions_ = new transitions; transitions_ = new transitions;
transitions* transitions_condition = get_transitions(t->condition); transitions* trans_by_condition = get_transitions(t->condition);
if (transitions_condition == 0) if (trans_by_condition == 0)
{ {
transitions_condition = new transitions; trans_by_condition = new transitions;
transitions_by_condition[(t->condition).id()] = transitions_condition; transitions_by_condition[(t->condition).id()] = trans_by_condition;
} }
state_ta_explicit::transitions::iterator it_trans; state_ta_explicit::transitions::iterator it_trans;
bool transition_found = false; bool transition_found = false;
for (it_trans = transitions_condition->begin(); (it_trans for (it_trans = trans_by_condition->begin(); (it_trans
!= transitions_condition->end() && !transition_found); it_trans++) != trans_by_condition->end() && !transition_found); it_trans++)
{ {
transition_found = ((*it_trans)->dest == t->dest); transition_found = ((*it_trans)->dest == t->dest);
if (transition_found) if (transition_found)
...@@ -166,12 +165,12 @@ namespace spot ...@@ -166,12 +165,12 @@ namespace spot
{ {
if (add_at_beginning) if (add_at_beginning)
{ {
transitions_condition->push_front(t); trans_by_condition->push_front(t);
transitions_->push_front(t); transitions_->push_front(t);
} }
else else
{ {
transitions_condition->push_back(t); trans_by_condition->push_back(t);
transitions_->push_back(t); transitions_->push_back(t);
} }
...@@ -290,11 +289,16 @@ namespace spot ...@@ -290,11 +289,16 @@ namespace spot
== (dest)->get_tgba_condition()); == (dest)->get_tgba_condition());
bool dest_is_livelock_accepting = dest->is_livelock_accepting_state(); bool dest_is_livelock_accepting = dest->is_livelock_accepting_state();
//Before deleting stuttering transitions, propaged back livelock and initial state's properties //Before deleting stuttering transitions, propaged back livelock
//and initial state's properties
if (is_stuttering_transition) if (is_stuttering_transition)
{ {
if (dest_is_livelock_accepting) if (!is_livelock_accepting_state() && dest_is_livelock_accepting)
set_livelock_accepting_state(true); {
set_livelock_accepting_state(true);
stuttering_reachable_livelock
= dest->stuttering_reachable_livelock;
}
if (dest->is_initial_state()) if (dest->is_initial_state())
set_initial_state(true); set_initial_state(true);
} }
...@@ -321,7 +325,7 @@ namespace spot ...@@ -321,7 +325,7 @@ namespace spot
void void
state_ta_explicit::free_transitions() state_ta_explicit::free_transitions()
{ {
state_ta_explicit::transitions* trans = get_transitions(); state_ta_explicit::transitions* trans = transitions_;
state_ta_explicit::transitions::iterator it_trans; state_ta_explicit::transitions::iterator it_trans;
// We don't destroy the transitions in the state's destructor because // We don't destroy the transitions in the state's destructor because
// they are not cloned. // they are not cloned.
...@@ -340,6 +344,7 @@ namespace spot ...@@ -340,6 +344,7 @@ namespace spot
++i; ++i;
} }
transitions_ = 0;
} }
//////////////////////////////////////// ////////////////////////////////////////
......
...@@ -227,6 +227,7 @@ namespace spot ...@@ -227,6 +227,7 @@ namespace spot
void void
free_transitions(); free_transitions();
state_ta_explicit* stuttering_reachable_livelock;
private: private:
const state* tgba_state_; const state* tgba_state_;
const bdd tgba_condition_; const bdd tgba_condition_;
......
...@@ -81,7 +81,6 @@ namespace spot ...@@ -81,7 +81,6 @@ namespace spot
ta_succ_iterator_product::~ta_succ_iterator_product() ta_succ_iterator_product::~ta_succ_iterator_product()
{ {
// ta_->free_state(current_state_);
delete current_state_; delete current_state_;
current_state_ = 0; current_state_ = 0;
delete ta_succ_it_; delete ta_succ_it_;
...@@ -315,6 +314,17 @@ namespace spot ...@@ -315,6 +314,17 @@ namespace spot
return new ta_succ_iterator_product(stp, ta_, kripke_); return new ta_succ_iterator_product(stp, ta_, kripke_);
} }
ta_succ_iterator_product*
ta_product::succ_iter(const spot::state* s, bdd changeset) const
{
const state_ta_product* stp = down_cast<const state_ta_product*> (s);
assert(s);
return new ta_succ_iterator_product_by_changeset(stp, ta_, kripke_,
changeset);
}
bdd_dict* bdd_dict*
ta_product::get_dict() const ta_product::get_dict() const
{ {
...@@ -349,6 +359,7 @@ namespace spot ...@@ -349,6 +359,7 @@ namespace spot
} }
bool bool
ta_product::is_initial_state(const spot::state* s) const ta_product::is_initial_state(const spot::state* s) const
{ {
...@@ -400,4 +411,62 @@ namespace spot ...@@ -400,4 +411,62 @@ namespace spot
} }
ta_succ_iterator_product_by_changeset::ta_succ_iterator_product_by_changeset(
const state_ta_product* s, const ta* t, const kripke* k, bdd changeset) :
ta_succ_iterator_product(s, t, k)
{
current_condition_ = changeset;
}
void
ta_succ_iterator_product_by_changeset::next_kripke_dest()
{
if (!kripke_succ_it_)
return;
if (kripke_current_dest_state == 0)
{
kripke_succ_it_->first();
}
else
{
kripke_current_dest_state->destroy();
kripke_current_dest_state = 0;
kripke_succ_it_->next();
}
// If one of the two successor sets is empty initially, we reset
// kripke_succ_it_, so that done() can detect this situation easily. (We
// choose to reset kripke_succ_it_ because this variable is already used by
// done().)
if (kripke_succ_it_->done())
{
delete kripke_succ_it_;
kripke_succ_it_ = 0;
return;
}
kripke_current_dest_state = kripke_succ_it_->current_state();
bdd kripke_current_dest_condition = kripke_->state_condition(
kripke_current_dest_state);
if (current_condition_ != bdd_setxor(kripke_source_condition,
kripke_current_dest_condition))
next_kripke_dest();
is_stuttering_transition_ = (kripke_source_condition
== kripke_current_dest_condition);
if (!is_stuttering_transition_)
{
ta_succ_it_ = ta_->succ_iter(source_->get_ta_state(),
current_condition_);
ta_succ_it_->first();
}
}
} }
...@@ -28,7 +28,7 @@ namespace spot ...@@ -28,7 +28,7 @@ namespace spot
{ {
/// \brief A state for spot::ta_product. /// \brief A state for spot::ta_product.
/// \ingroup emptiness_check /// \ingroup ta_emptiness_check
/// ///
/// This state is in fact a pair of state: the state from the TA /// This state is in fact a pair of state: the state from the TA
/// automaton and that of Kripke structure. /// automaton and that of Kripke structure.
...@@ -104,7 +104,7 @@ namespace spot ...@@ -104,7 +104,7 @@ namespace spot
bool bool
is_stuttering_transition() const; is_stuttering_transition() const;
private: protected:
//@{ //@{
/// Internal routines to advance to the next successor. /// Internal routines to advance to the next successor.
void void
...@@ -135,7 +135,7 @@ namespace spot ...@@ -135,7 +135,7 @@ namespace spot
/// \brief A lazy product between a Testing automaton and a Kripke structure. /// \brief A lazy product between a Testing automaton and a Kripke structure.
/// (States are computed on the fly.) /// (States are computed on the fly.)
/// \ingroup emptiness_check /// \ingroup ta_emptiness_check
class ta_product : public ta class ta_product : public ta
{ {
public: public:
...@@ -153,6 +153,9 @@ namespace spot ...@@ -153,6 +153,9 @@ namespace spot
virtual ta_succ_iterator_product* virtual ta_succ_iterator_product*
succ_iter(const spot::state* s) const; succ_iter(const spot::state* s) const;
virtual ta_succ_iterator_product*
succ_iter(const spot::state* s, bdd changeset) const;
virtual bdd_dict* virtual bdd_dict*
get_dict() const; get_dict() const;
...@@ -169,7 +172,7 @@ namespace spot ...@@ -169,7 +172,7 @@ namespace spot
is_initial_state(const spot::state* s) const; is_initial_state(const spot::state* s) const;
/// \brief Return true if the state \a s has no succeseurs /// \brief Return true if the state \a s has no succeseurs
/// in the ta automaton (the TA component of the product automaton) /// in the TA automaton (the TA component of the product automaton)
virtual bool virtual bool
is_hole_state_in_ta_component(const spot::state* s) const; is_hole_state_in_ta_component(const spot::state* s) const;
...@@ -205,6 +208,23 @@ namespace spot ...@@ -205,6 +208,23 @@ namespace spot
operator=(const ta_product&); operator=(const ta_product&);
}; };
class ta_succ_iterator_product_by_changeset : public ta_succ_iterator_product
{
public:
ta_succ_iterator_product_by_changeset(const state_ta_product* s,
const ta* t, const kripke* k, bdd changeset);
/// \brief Move to the next successor in the kripke structure
void
next_kripke_dest();
};
} }
#endif // SPOT_TA_TAPRODUCT_HH #endif // SPOT_TA_TAPRODUCT_HH
...@@ -18,15 +18,15 @@ ...@@ -18,15 +18,15 @@
// Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA // Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA. // 02111-1307, USA.
#include "tgbta.hh" #include "tgta.hh"
namespace spot namespace spot
{ {
tgbta::tgbta() tgta::tgta()
{}; {};
tgbta::~tgbta() tgta::~tgta()
{}; {};
......
...@@ -25,15 +25,56 @@ ...@@ -25,15 +25,56 @@
namespace spot namespace spot
{ {
class tgbta : public tgba
/// \brief A Transition-based Generalized Testing Automaton (TGTA).
/// \ingroup ta_essentials
///
/// Transition-based Generalized Testing Automaton (TGTA) is a new kind of
/// automaton that combines features from both TA and TGBA.
/// From TA, we take the idea of labeling transitions with changesets,
/// however we remove the use of livelock-acceptance (because it may require
/// a two-pass emptiness check), and the implicit stuttering. From TGBA, we
/// inherit the use of transition-based generalized acceptance conditions.
/// The resulting Chimera, which we call \emph{Transition-based
/// Generalized Testing Automaton} (TGTA), accepts only
/// stuttering-insensitive languages like TA, and inherits advantages from
/// both TA and TGBA: it has a simple one-pass emptiness-check procedure
/// (the same as algorithm the one for TGBA), and can benefit from reductions
/// based on the stuttering of the properties pretty much like a TA.
/// Livelock acceptance states, which are no longer supported are emulated
///using states with a Büchi accepting self-loop labeled by empty changeset.
///
/// Browsing such automaton can be achieved using two functions:
/// \c get_initial_state and \c
/// succ_iter. The former returns the initial state(s) while the latter lists
/// the successor states of any state. A second implementation of \c succ_iter
/// returns only the successors reached through a changeset passed as
/// a parameter.
///
/// 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 tgta : public tgba
{ {
protected: protected:
tgbta(); tgta();
public: public:
virtual virtual
~tgbta(); ~tgta();
/// \brief Get an iterator over the successors of \a state
/// filtred by the value of the changeset on transitions between the
/// \a state and his successors
///
/// The iterator has been allocated with \c new. It is the
/// responsability of the caller to \c delete it when no
/// longer needed.
///
virtual tgba_succ_iterator* virtual tgba_succ_iterator*
succ_iter_by_changeset(const spot::state* s, bdd change_set) const =0; succ_iter_by_changeset(const spot::state* s, bdd change_set) const =0;
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
#include "ltlast/atomic_prop.hh" #include "ltlast/atomic_prop.hh"
#include "ltlast/constant.hh" #include "ltlast/constant.hh"
#include "tgbtaexplicit.hh" #include "tgtaexplicit.hh"
#include "tgba/formula2bdd.hh" #include "tgba/formula2bdd.hh"
#include "misc/bddop.hh" #include "misc/bddop.hh"
#include "ltlvisit/tostring.hh" #include "ltlvisit/tostring.hh"
...@@ -30,69 +30,68 @@ ...@@ -30,69 +30,68 @@
namespace spot namespace spot
{ {
tgta_explicit::tgta_explicit(const tgba* tgba, bdd all_acceptance_conditions,
tgbta_explicit::tgbta_explicit(const tgba* tgba, bdd all_acceptance_conditions, state_ta_explicit* artificial_initial_state) :
state_ta_explicit* artificial_initial_state) : ta_explicit(tgba, all_acceptance_conditions, artificial_initial_state)
ta_explicit(tgba, all_acceptance_conditions, artificial_initial_state) {
{ }
}
state* state*
tgbta_explicit::get_init_state() const tgta_explicit::get_init_state() const
{ {
return ta_explicit::get_artificial_initial_state(); return ta_explicit::get_artificial_initial_state();
} }
tgba_succ_iterator* tgba_succ_iterator*
tgbta_explicit::succ_iter(const spot::state* state, tgta_explicit::succ_iter(const spot::state* state, const spot::state*,
const spot::state*, const tgba*) const
const tgba*) const {
{ return ta_explicit::succ_iter(state);
return ta_explicit::succ_iter(state); }
}
bdd
bdd tgta_explicit::compute_support_conditions(const spot::state* in) const
tgbta_explicit::compute_support_conditions(const spot::state* in) const {
{ return get_tgba()->support_conditions(
return get_tgba()->support_conditions(((const state_ta_explicit*) in)->get_tgba_state()); ((const state_ta_explicit*) in)->get_tgba_state());
} }
bdd bdd
tgbta_explicit::compute_support_variables(const spot::state* in) const tgta_explicit::compute_support_variables(const spot::state* in) const
{ {
return get_tgba()->support_variables(((const state_ta_explicit*) in)->get_tgba_state()); return get_tgba()->support_variables(
} ((const state_ta_explicit*) in)->get_tgba_state());
}
bdd_dict*
tgbta_explicit::get_dict() const bdd_dict*
{ tgta_explicit::get_dict() const
return ta_explicit::get_dict(); {
} return ta_explicit::get_dict();
}
bdd
tgbta_explicit::all_acceptance_conditions() const bdd
{ tgta_explicit::all_acceptance_conditions() const
{
return ta_explicit::all_acceptance_conditions();
} return ta_explicit::all_acceptance_conditions();
}
bdd
tgbta_explicit::neg_acceptance_conditions() const bdd
{ tgta_explicit::neg_acceptance_conditions() const
return get_tgba()->neg_acceptance_conditions();