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 = \
ta.hh \
taexplicit.hh \
taproduct.hh \
tgbta.hh \
tgbtaexplicit.hh \
tgbtaproduct.hh
tgta.hh \
tgtaexplicit.hh \
tgtaproduct.hh
noinst_LTLIBRARIES = libta.la
libta_la_SOURCES = \
ta.cc \
taproduct.cc \
tgbta.cc \
tgbtaexplicit.cc \
tgta.cc \
tgtaexplicit.cc \
taexplicit.cc \
tgbtaproduct.cc
tgtaproduct.cc
......@@ -51,7 +51,7 @@ namespace spot
///
/// The Testing Automata (TA) were introduced by
/// 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
/// Theoretical Computer Science.Elsevier.
///
......@@ -69,7 +69,7 @@ namespace spot
/// Browsing such automaton can be achieved using two functions:
/// \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
/// 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,
/// we never represent transitions! Transition informations are
......@@ -98,7 +98,7 @@ namespace spot
/// artificial initial state have one transition to each real initial state,
/// and this transition is labeled by the corresponding initial condition.
/// (For more details, see the paper cited above)
spot::state*
virtual spot::state*
get_artificial_initial_state() const
{
return 0;
......@@ -114,7 +114,7 @@ namespace spot
succ_iter(const spot::state* state) const = 0;
/// \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
/// responsability of the caller to \c delete it when no
......
......@@ -105,7 +105,6 @@ namespace spot
return (*i_)->acceptance_conditions;
}
////////////////////////////////////////
// state_ta_explicit
......@@ -141,19 +140,19 @@ namespace spot
if (transitions_ == 0)
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;
transitions_by_condition[(t->condition).id()] = transitions_condition;
trans_by_condition = new transitions;
transitions_by_condition[(t->condition).id()] = trans_by_condition;
}
state_ta_explicit::transitions::iterator it_trans;
bool transition_found = false;
for (it_trans = transitions_condition->begin(); (it_trans
!= transitions_condition->end() && !transition_found); it_trans++)
for (it_trans = trans_by_condition->begin(); (it_trans
!= trans_by_condition->end() && !transition_found); it_trans++)
{
transition_found = ((*it_trans)->dest == t->dest);
if (transition_found)
......@@ -166,12 +165,12 @@ namespace spot
{
if (add_at_beginning)
{
transitions_condition->push_front(t);
trans_by_condition->push_front(t);
transitions_->push_front(t);
}
else
{
transitions_condition->push_back(t);
trans_by_condition->push_back(t);
transitions_->push_back(t);
}
......@@ -290,11 +289,16 @@ namespace spot
== (dest)->get_tgba_condition());
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 (dest_is_livelock_accepting)
set_livelock_accepting_state(true);
if (!is_livelock_accepting_state() && dest_is_livelock_accepting)
{
set_livelock_accepting_state(true);
stuttering_reachable_livelock
= dest->stuttering_reachable_livelock;
}
if (dest->is_initial_state())
set_initial_state(true);
}
......@@ -321,7 +325,7 @@ namespace spot
void
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;
// We don't destroy the transitions in the state's destructor because
// they are not cloned.
......@@ -340,6 +344,7 @@ namespace spot
++i;
}
transitions_ = 0;
}
////////////////////////////////////////
......
......@@ -227,6 +227,7 @@ namespace spot
void
free_transitions();
state_ta_explicit* stuttering_reachable_livelock;
private:
const state* tgba_state_;
const bdd tgba_condition_;
......
......@@ -81,7 +81,6 @@ namespace spot
ta_succ_iterator_product::~ta_succ_iterator_product()
{
// ta_->free_state(current_state_);
delete current_state_;
current_state_ = 0;
delete ta_succ_it_;
......@@ -315,6 +314,17 @@ namespace spot
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*
ta_product::get_dict() const
{
......@@ -349,6 +359,7 @@ namespace spot
}
bool
ta_product::is_initial_state(const spot::state* s) const
{
......@@ -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
{
/// \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
/// automaton and that of Kripke structure.
......@@ -104,7 +104,7 @@ namespace spot
bool
is_stuttering_transition() const;
private:
protected:
//@{
/// Internal routines to advance to the next successor.
void
......@@ -135,7 +135,7 @@ namespace spot
/// \brief A lazy product between a Testing automaton and a Kripke structure.
/// (States are computed on the fly.)
/// \ingroup emptiness_check
/// \ingroup ta_emptiness_check
class ta_product : public ta
{
public:
......@@ -153,6 +153,9 @@ namespace spot
virtual ta_succ_iterator_product*
succ_iter(const spot::state* s) const;
virtual ta_succ_iterator_product*
succ_iter(const spot::state* s, bdd changeset) const;
virtual bdd_dict*
get_dict() const;
......@@ -169,7 +172,7 @@ namespace spot
is_initial_state(const spot::state* s) const;
/// \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
is_hole_state_in_ta_component(const spot::state* s) const;
......@@ -205,6 +208,23 @@ namespace spot
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
......@@ -18,15 +18,15 @@
// Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
#include "tgbta.hh"
#include "tgta.hh"
namespace spot
{
tgbta::tgbta()
tgta::tgta()
{};
tgbta::~tgbta()
tgta::~tgta()
{};
......
......@@ -25,15 +25,56 @@
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:
tgbta();
tgta();
public:
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*
succ_iter_by_changeset(const spot::state* s, bdd change_set) const =0;
......
......@@ -20,7 +20,7 @@
#include "ltlast/atomic_prop.hh"
#include "ltlast/constant.hh"
#include "tgbtaexplicit.hh"
#include "tgtaexplicit.hh"
#include "tgba/formula2bdd.hh"
#include "misc/bddop.hh"
#include "ltlvisit/tostring.hh"
......@@ -30,69 +30,68 @@
namespace spot
{
tgbta_explicit::tgbta_explicit(const tgba* tgba, bdd all_acceptance_conditions,
state_ta_explicit* artificial_initial_state) :
ta_explicit(tgba, all_acceptance_conditions, artificial_initial_state)
{
}
tgta_explicit::tgta_explicit(const tgba* tgba, bdd all_acceptance_conditions,
state_ta_explicit* artificial_initial_state) :
ta_explicit(tgba, all_acceptance_conditions, artificial_initial_state)
{
}
state*
tgbta_explicit::get_init_state() const
{
return ta_explicit::get_artificial_initial_state();
}
tgba_succ_iterator*
tgbta_explicit::succ_iter(const spot::state* state,
const spot::state*,
const tgba*) const
{
return ta_explicit::succ_iter(state);
}
bdd
tgbta_explicit::compute_support_conditions(const spot::state* in) const
{
return get_tgba()->support_conditions(((const state_ta_explicit*) in)->get_tgba_state());
}
bdd
tgbta_explicit::compute_support_variables(const spot::state* in) const
{
return get_tgba()->support_variables(((const state_ta_explicit*) in)->get_tgba_state());
}
bdd_dict*
tgbta_explicit::get_dict() const
{
return ta_explicit::get_dict();
}
bdd
tgbta_explicit::all_acceptance_conditions() const
{
return ta_explicit::all_acceptance_conditions();
}
bdd
tgbta_explicit::neg_acceptance_conditions() const
{
return get_tgba()->neg_acceptance_conditions();
}
std::string
tgbta_explicit::format_state(const spot::state* s) const
{
return ta_explicit::format_state(s);
}
spot::tgba_succ_iterator* tgbta_explicit::succ_iter_by_changeset(const spot::state* s, bdd change_set) const
{
return ta_explicit::succ_iter(s,change_set);
}
tgta_explicit::get_init_state() const
{
return ta_explicit::get_artificial_initial_state();
}
tgba_succ_iterator*
tgta_explicit::succ_iter(const spot::state* state, const spot::state*,
const tgba*) const
{
return ta_explicit::succ_iter(state);
}
bdd
tgta_explicit::compute_support_conditions(const spot::state* in) const
{
return get_tgba()->support_conditions(
((const state_ta_explicit*) in)->get_tgba_state());
}
bdd
tgta_explicit::compute_support_variables(const spot::state* in) const
{
return get_tgba()->support_variables(
((const state_ta_explicit*) in)->get_tgba_state());
}
bdd_dict*
tgta_explicit::get_dict() const
{
return ta_explicit::get_dict();
}
bdd
tgta_explicit::all_acceptance_conditions() const
{
return ta_explicit::all_acceptance_conditions();
}
bdd
tgta_explicit::neg_acceptance_conditions() const
{
return get_tgba()->neg_acceptance_conditions();
}
std::string
tgta_explicit::format_state(const spot::state* s) const
{
return ta_explicit::format_state(s);
}
spot::tgba_succ_iterator*
tgta_explicit::succ_iter_by_changeset(const spot::state* s, bdd chngset) const
{
return ta_explicit::succ_iter(s, chngset);
}
}
......@@ -18,8 +18,8 @@
// Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
#ifndef SPOT_TA_TGBTAEXPLICIT_HH
# define SPOT_TA_TGBTAEXPLICIT_HH
#ifndef SPOT_TA_TGTAEXPLICIT_HH
# define SPOT_TA_TGTAEXPLICIT_HH
#include "misc/hash.hh"
#include <list>
......@@ -29,38 +29,46 @@
#include <cassert>
#include "misc/bddlt.hh"
#include "taexplicit.hh"
#include "tgbta.hh"
#include "tgta.hh"
namespace spot
{
class tgbta_explicit : public tgbta, public ta_explicit
/// Explicit representation of a spot::tgta.
/// \ingroup ta_representation
class tgta_explicit : public tgta, public ta_explicit
{
public:
tgbta_explicit(const tgba* tgba, bdd all_acceptance_conditions,
state_ta_explicit* artificial_initial_state) ;
tgta_explicit(const tgba* tgba, bdd all_acceptance_conditions,
state_ta_explicit* artificial_initial_state);
// tgba interface
virtual spot::state* get_init_state() const;
virtual tgba_succ_iterator*
succ_iter(const spot::state* local_state,
const spot::state* global_state = 0,
const tgba* global_automaton = 0) const;
virtual bdd_dict* get_dict() const;
// tgba interface
virtual spot::state*
get_init_state() const;
virtual tgba_succ_iterator*
succ_iter(const spot::state* local_state, const spot::state* global_state =
0, const tgba* global_automaton = 0) const;
virtual bdd_dict*
get_dict() const;
virtual bdd all_acceptance_conditions() const;
virtual bdd neg_acceptance_conditions() const;
virtual bdd
all_acceptance_conditions() const;
virtual bdd
neg_acceptance_conditions() const;
virtual std::string format_state(const spot::state* s) const;
virtual std::string
format_state(const spot::state* s) const;
virtual tgba_succ_iterator* succ_iter_by_changeset(const spot::state* s, bdd change_set) const;
protected:
virtual bdd compute_support_conditions(const spot::state* state) const;
virtual bdd compute_support_variables(const spot::state* state) const;
virtual tgba_succ_iterator*
succ_iter_by_changeset(const spot::state* s, bdd change_set) const;
protected:
virtual bdd
compute_support_conditions(const spot::state* state) const;
virtual bdd
compute_support_variables(const spot::state* state) const;
};
}
#endif // SPOT_TA_TGBTAEXPLICIT_HH
#endif // SPOT_TA_TGTAEXPLICIT_HH
......@@ -28,7 +28,7 @@
#define trace while (0) std::clog
#endif
#include "tgbtaproduct.hh"
#include "tgtaproduct.hh"
#include <string>
#include <cassert>
#include "misc/hashfunc.hh"
......@@ -38,19 +38,19 @@ namespace spot
{
////////////////////////////////////////////////////////////
// tgbta_succ_iterator_product
// tgta_succ_iterator_product