Doxygen comments.

* src/ta/ta.cc, src/ta/ta.hh, src/ta/taexplicit.hh,
src/ta/taproduct.cc, src/ta/taproduct.hh, src/ta/tgbtaexplicit.cc,
src/ta/taexplicit.cc, src/ta/tgbtaproduct.cc,
src/taalgos/emptinessta.cc, src/taalgos/emptinessta.hh,
src/taalgos/tgba2ta.cc, src/taalgos/tgba2ta.hh,
src/tgbatest/ltl2ta.test, src/tgbatest/ltl2tgba.cc: Add Doxygen
comments.
This commit is contained in:
Ala-Eddine Ben-Salem 2012-01-26 17:34:22 +01:00 committed by Alexandre Duret-Lutz
parent a13d2c8fc7
commit c76e651bad
14 changed files with 425 additions and 202 deletions

View file

@ -43,11 +43,11 @@ namespace spot
ta_check::~ta_check()
{
}
bool
ta_check::check(bool disable_second_pass)
ta_check::check(bool disable_second_pass,
disable_heuristic_for_livelock_detection)
{
// We use five main data in this algorithm:
@ -67,14 +67,12 @@ namespace spot
int num = 1;
// * todo: the depth-first search stack. This holds pairs of the
// form (STATE, ITERATOR) where ITERATOR is a ta_succ_iterator
// form (STATE, ITERATOR) where ITERATOR is a ta_succ_iterator_product
// over the successors of STATE. In our use, ITERATOR should
// always be freed when TODO is popped, but STATE should not because
// it is also used as a key in H.
std::stack<pair_state_iter> todo;
Sgi::hash_map<const state*, std::string, state_ptr_hash, state_ptr_equal>
colour;
@ -88,7 +86,8 @@ namespace spot
bool livelock_acceptance_states_not_found = true;
bool activate_heuristic = (is_full_2_pass_ == disable_second_pass);
bool activate_heuristic = !disable_heuristic_for_livelock_detection
&& (is_full_2_pass_ == disable_second_pass);
// Setup depth-first search from initial states.
const ta* ta_ = a_->get_ta();
@ -117,7 +116,7 @@ namespace spot
scc.push(num);
arc.push(bddfalse);
ta_succ_iterator* iter = a_->succ_iter(init);
ta_succ_iterator_product* iter = a_->succ_iter(init);
iter->first();
todo.push(pair_state_iter(init, iter));
@ -133,7 +132,7 @@ namespace spot
state* curr = todo.top().first;
// We are looking at the next successor in SUCC.
ta_succ_iterator* succ = todo.top().second;
ta_succ_iterator_product* succ = todo.top().second;
// If there is no more successor, backtrack.
if (succ->done())
@ -147,7 +146,8 @@ namespace spot
trace
<< "PASS 1 : backtrack" << std::endl;
if (a_->is_livelock_accepting_state(curr))
if (a_->is_livelock_accepting_state(curr)
&& !a_->is_accepting_state(curr))
{
livelock_acceptance_states_not_found = false;
trace
@ -241,7 +241,7 @@ namespace spot
scc.push(num);
arc.push(acc_cond);
ta_succ_iterator* iter = a_->succ_iter(dest);
ta_succ_iterator_product* iter = a_->succ_iter(dest);
iter->first();
todo.push(pair_state_iter(dest, iter));
//colour[dest] = GREY;
@ -315,10 +315,11 @@ namespace spot
a_->get_dict(), scc.top().condition) << std::endl;
trace
<< "PASS 1: a_->all_acceptance_conditions() : "
<< ( a_->all_acceptance_conditions()) << std::endl;
<< (a_->all_acceptance_conditions()) << std::endl;
trace
<< "PASS 1 CYCLE and (scc.top().condition == a_->all_acceptance_conditions()) : "
<< (scc.top().condition == a_->all_acceptance_conditions()) << std::endl;
<< "PASS 1 CYCLE and (scc.top().condition == a_->all_acceptance_conditions()) : "
<< (scc.top().condition
== a_->all_acceptance_conditions()) << std::endl;
trace
<< "PASS 1: bddtrue : " << (a_->all_acceptance_conditions()
@ -407,7 +408,7 @@ namespace spot
}
bool
ta_check::livelock_detection(const ta* t)
ta_check::livelock_detection(const ta_product* t)
{
// We use five main data in this algorithm:
@ -460,7 +461,7 @@ namespace spot
h->insert(init, ++num);
sscc.push(num);
sscc.top().is_accepting = t->is_livelock_accepting_state(init);
ta_succ_iterator* iter = t->succ_iter(init);
ta_succ_iterator_product* iter = t->succ_iter(init);
iter->first();
todo.push(pair_state_iter(init, iter));
inc_depth();
@ -473,7 +474,7 @@ namespace spot
state* curr = todo.top().first;
// We are looking at the next successor in SUCC.
ta_succ_iterator* succ = todo.top().second;
ta_succ_iterator_product* succ = todo.top().second;
// If there is no more successor, backtrack.
if (succ->done())
@ -554,7 +555,7 @@ namespace spot
sscc.push(num);
sscc.top().is_accepting = t->is_livelock_accepting_state(dest);
ta_succ_iterator* iter = t->succ_iter(dest);
ta_succ_iterator_product* iter = t->succ_iter(dest);
iter->first();
todo.push(pair_state_iter(dest, iter));
inc_depth();
@ -651,26 +652,24 @@ namespace spot
delete h;
}
void
ta_check::clear(numbered_state_heap* h, std::stack<pair_state_iter> todo,
spot::ta_succ_iterator* init_states_it)
{
ta_check::clear(numbered_state_heap* h, std::stack<pair_state_iter> todo,
spot::ta_succ_iterator* init_states_it)
{
set_states(states() + h->size());
set_states(states() + h->size());
delete init_states_it;
// Release all iterators in TODO.
while (!todo.empty())
{
delete todo.top().second;
todo.pop();
dec_depth();
}
delete h;
}
// Release all iterators in TODO.
while (!todo.empty())
{
delete todo.top().second;
todo.pop();
dec_depth();
}
delete h;
}
std::ostream&
ta_check::print_stats(std::ostream& os) const

View file

@ -36,11 +36,54 @@ namespace spot
namespace
{
typedef std::pair<spot::state*, ta_succ_iterator*> pair_state_iter;
typedef std::pair<spot::state*, ta_succ_iterator_product*> pair_state_iter;
}
/// \brief An implementation of the ta emptiness-check algorithm.
/// \addtogroup emptiness_check Emptiness-checks
/// \ingroup ta_algorithms
///
/// See the documentation for spot::ta.
/// \brief Check whether the language of a product between a Kripke structure
/// and a TA is empty. It works for both standard and generalized form of TA.
///
/// you should call \c check to check the product automaton.
/// If \c check() returns false, then the product automaton
/// was found empty. Otherwise the automaton accepts some run.
///
/// This is based on the following paper.
/// \verbatim
/// @InProceedings{ geldenhuys.06.spin,
/// author = {Jaco Geldenhuys and Henri Hansen},
/// title = {Larger Automata and Less Work for {LTL} Model Checking},
/// booktitle = {Proceedings of the 13th International SPIN Workshop
/// (SPIN'06)},
/// year = {2006},
/// pages = {53--70},
/// series = {Lecture Notes in Computer Science},
/// volume = {3925},
/// publisher = {Springer}
/// }
/// \endverbatim
///
/// the implementation of \c check is inspired from the two-pass algorithm
/// of the paper above:
/// - the fist-pass detect all Buchi-accepting cycles and includes
// the heuristic proposed in the paper to detect some
/// livelock-accepting cycles.
/// - the second-pass detect all livelock-accepting cycles.
/// In addition, we add some optimizations to the fist pass:
/// 1- Detection of all (livelock-accepting) cycles containing a least
/// one state that is both livelock and accepting states
/// 2- Detection of all livelock-accepting cycles containing a least
/// one state (k,t) such as its "TA component" t is a livelock-accepting
/// state that has no successors in the TA automaton.
///
/// The implementation of each pass is a SCC-based algorithm inspired
/// from spot::gtec.hh.
/// \brief An implementation of the emptiness-check algorithm for a product
/// between a TA and a Kripke structure
///
/// See the paper cited above.
class ta_check : public ec_statistics
{
public:
@ -48,26 +91,38 @@ namespace spot
virtual
~ta_check();
/// Check whether the automaton's language is empty.
/// \brief Check whether the TA product automaton contains an accepting run:
/// it detects the two kinds of accepting runs: Buchi-accepting runs
/// and livelock-accepting runs. This emptiness check algorithm can also
/// check a product using the generalized form of TA.
///
/// Return false if the product automaton accepts no run, otherwise true
///
/// \param disable_second_pass: is used to disable the second pass when
/// when it is not necessary, for example when all the livelock-accepting
/// states of the TA automaton have no successors, we call this kind of
/// TA as STA (Single-pass Testing Automata)
/// (see spot::tgba2ta::add_artificial_livelock_accepting_state() for an
/// automatic transformation of any TA automaton into STA automaton
///
/// \param disable_heuristic_for_livelock_detection: disable the heuristic
/// used in the first pass to detect livelock-accepting runs,
/// this heuristic is described in the paper cited above
virtual bool
check(bool disable_second_pass = false);
check(bool disable_second_pass = false,
bool disable_heuristic_for_livelock_detection = false);
/// \brief Check whether the product automaton contains
/// a livelock-accepting run
/// Return false if the product automaton accepts no livelock-accepting run,
/// otherwise true
virtual bool
livelock_detection(const ta* t);
livelock_detection(const ta_product* t);
/// Print statistics, if any.
virtual std::ostream&
print_stats(std::ostream& os) const;
/// \brief Return the status of the emptiness-check.
///
/// When check() succeed, the status should be passed along
/// to spot::counter_example.
///
/// This status should not be deleted, it is a pointer
/// to a member of this class that will be deleted when
/// the ta object is deleted.
// const tgba_check_status* result() const;
protected:
void
clear(numbered_state_heap* h, std::stack<pair_state_iter> todo, std::queue<
@ -77,19 +132,23 @@ namespace spot
clear(numbered_state_heap* h, std::stack<pair_state_iter> todo,
spot::ta_succ_iterator* init_states_it);
/// the heuristic for livelock-accepting runs detection, it's described
/// in the paper cited above
bool
heuristic_livelock_detection(const state * stuttering_succ,
numbered_state_heap* h, int h_livelock_root, std::set<const state*,
state_ptr_less_than> liveset_curr);
const ta_product* a_; ///< The automaton.
option_map o_; ///< The options
// Force the second pass
bool is_full_2_pass_;
// * scc: a stack of strongly connected components (SCC)
// scc: a stack of strongly connected components (SCC)
scc_stack_ta scc;
// * sscc: a stack of strongly stuttering-connected components (SSCC)
// sscc: a stack of strongly stuttering-connected components (SSCC)
scc_stack_ta sscc;
};

View file

@ -48,7 +48,6 @@ namespace spot
ta_explicit*
build_ta(ta_explicit* ta, bdd atomic_propositions_set_,
bool artificial_initial_state_mode,
bool artificial_livelock_accepting_state_mode, bool degeneralized)
{
@ -70,7 +69,8 @@ namespace spot
{
init_state = new state_ta_explicit(tgba_init_state->clone(),
satone_tgba_condition, true,
((tgba_sba_proxy*) tgba_)->state_is_accepting(tgba_init_state));
((const tgba_sba_proxy*) tgba_)->state_is_accepting(
tgba_init_state));
}
else
{
@ -117,10 +117,13 @@ namespace spot
if (degeneralized)
{
new_dest = new state_ta_explicit(tgba_state->clone(),
dest_condition, false,
((tgba_sba_proxy*) tgba_)->state_is_accepting(
tgba_state));
new_dest
= new state_ta_explicit(
tgba_state->clone(),
dest_condition,
false,
((const tgba_sba_proxy*) tgba_)->state_is_accepting(
tgba_state));
}
else
@ -133,7 +136,7 @@ namespace spot
if (dest != new_dest)
{
// the state dest already exists in the testing automata
// the state dest already exists in the testing automata
new_dest->get_tgba_state()->destroy();
delete new_dest;
}
@ -158,22 +161,21 @@ namespace spot
state_ta_explicit* artificial_livelock_accepting_state = 0;
trace << "*** build_ta: artificial_livelock_accepting_state_mode = ***"
<< artificial_livelock_accepting_state_mode << std::endl;
trace
<< "*** build_ta: artificial_livelock_accepting_state_mode = ***"
<< artificial_livelock_accepting_state_mode << std::endl;
if (artificial_livelock_accepting_state_mode)
{
artificial_livelock_accepting_state =
new state_ta_explicit(ta->get_tgba()->get_init_state(), bddtrue,
false, false, true, 0);
trace << "*** build_ta: artificial_livelock_accepting_state = ***"
<< artificial_livelock_accepting_state << std::endl;
artificial_livelock_accepting_state = new state_ta_explicit(
ta->get_tgba()->get_init_state(), bddtrue, false, false, true, 0);
trace
<< "*** build_ta: artificial_livelock_accepting_state = ***"
<< artificial_livelock_accepting_state << std::endl;
}
compute_livelock_acceptance_states(ta, artificial_livelock_accepting_state);
return ta;
@ -203,7 +205,7 @@ namespace spot
tgba_init_state->destroy();
// build ta automata:
build_ta(ta, atomic_propositions_set_, artificial_initial_state_mode,
build_ta(ta, atomic_propositions_set_,
artificial_livelock_accepting_state_mode, degeneralized);
return ta;
}
@ -221,9 +223,11 @@ namespace spot
== artificial_livelock_accepting_state);
trace
<< "*** add_artificial_livelock_accepting_state: assert(artificial_livelock_accepting_state_added == artificial_livelock_accepting_state) = ***"
<< (artificial_livelock_accepting_state_added
== artificial_livelock_accepting_state) << std::endl;
<< "*** add_artificial_livelock_accepting_state: "
<< "assert(artificial_livelock_accepting_state_added == "
<< "artificial_livelock_accepting_state) = ***"
<< (artificial_livelock_accepting_state_added
== artificial_livelock_accepting_state) << std::endl;
ta::states_set_t states_set = testing_automata->get_states_set();
ta::states_set_t::iterator it;
@ -250,7 +254,7 @@ namespace spot
(dest)->get_transitions();
bool dest_trans_empty = dest_trans == 0 || dest_trans->empty();
//TODO TA++
//TA++
if (dest->is_livelock_accepting_state()
&& (!dest->is_accepting_state() || dest_trans_empty))
{
@ -260,7 +264,6 @@ namespace spot
}
//remove hole successors states
if (dest_trans_empty)
{
source->get_transitions((*it_trans)->condition)->remove(
@ -325,7 +328,8 @@ namespace spot
// * h: a hash of all visited nodes, with their order,
// (it is called "Hash" in Couvreur's paper)
numbered_state_heap* h =
numbered_state_heap_hash_map_factory::instance()->build(); ///< Heap of visited states.
numbered_state_heap_hash_map_factory::instance()->build();
///< Heap of visited states.
// * num: the number of visited nodes. Used to set the order of each
// visited node,
@ -424,14 +428,17 @@ namespace spot
assert(*spi.second != -1);
*spi.second = -1;
if (is_livelock_accepting_sscc)
{//if it is an accepting sscc
//add the state to G (=the livelock-accepting states set)
{//if it is an accepting sscc add the state to
//G (=the livelock-accepting states set)
state_ta_explicit * livelock_accepting_state =
down_cast<state_ta_explicit*> (*i);
livelock_accepting_state->set_livelock_accepting_state(
livelock_accepting_state->set_livelock_accepting_state(
true);
//case STA (Single-pass Testing Automata) or case
//STGTA (Single-pass Transition-based Generalised Testing Automata)
if (artificial_livelock_accepting_state != 0)
livelock_accepting_state->set_accepting_state(
true);
@ -498,8 +505,8 @@ namespace spot
if (*spi.second == -1)
continue;
trace << "***compute_livelock_acceptance_states: CYCLE***"
<< std::endl;
trace
<< "***compute_livelock_acceptance_states: CYCLE***" << std::endl;
if (!curr->compare(dest))
{
@ -512,13 +519,14 @@ namespace spot
== testing_automata->all_acceptance_conditions()))
{
self_loop_state->set_livelock_accepting_state(true);
if (artificial_livelock_accepting_state != 0) self_loop_state->set_accepting_state(true);
if (artificial_livelock_accepting_state != 0)
self_loop_state->set_accepting_state(true);
}
trace
<< "***compute_livelock_acceptance_states: CYCLE: self_loop_state***"
<< std::endl;
<< "***compute_livelock_acceptance_states: CYCLE: self_loop_state***"
<< std::endl;
}
@ -566,16 +574,16 @@ namespace spot
delete h;
trace
<< "*** compute_livelock_acceptance_states: PRE call add_artificial_livelock_accepting_state() method ... (artificial_livelock_accepting_state != 0) :***"
<< (artificial_livelock_accepting_state != 0) << std::endl;
<< "*** compute_livelock_acceptance_states: PRE call add_artificial_livelock_accepting_state() method ... (artificial_livelock_accepting_state != 0) :***"
<< (artificial_livelock_accepting_state != 0) << std::endl;
if (artificial_livelock_accepting_state != 0)
add_artificial_livelock_accepting_state(testing_automata,
artificial_livelock_accepting_state);
trace
<< "*** compute_livelock_acceptance_states: POST call add_artificial_livelock_accepting_state() method ***"
<< std::endl;
<< "*** compute_livelock_acceptance_states: POST call add_artificial_livelock_accepting_state() method ***"
<< std::endl;
}
tgbta_explicit*
@ -591,9 +599,10 @@ namespace spot
tgba_->all_acceptance_conditions(), ta_init_state);
// build ta automata:
build_ta(tgbta, atomic_propositions_set_, true, true, false);
build_ta(tgbta, atomic_propositions_set_, true, false);
trace << "***tgba_to_tgbta: POST build_ta***" << std::endl;
trace
<< "***tgba_to_tgbta: POST build_ta***" << std::endl;
// adapt a ta automata to build tgbta automata :
ta::states_set_t states_set = tgbta->get_states_set();
@ -622,13 +631,13 @@ namespace spot
if (trans_empty || state->is_accepting_state())
{
trace
<< "***tgba_to_tgbta: PRE if (state->is_livelock_accepting_state()) ... create_transition ***"
<< std::endl;
<< "***tgba_to_tgbta: PRE if (state->is_livelock_accepting_state()) ... create_transition ***"
<< std::endl;
tgbta->create_transition(state, bdd_stutering_transition,
tgbta->all_acceptance_conditions(), state);
trace
<< "***tgba_to_tgbta: POST if (state->is_livelock_accepting_state()) ... create_transition ***"
<< std::endl;
<< "***tgba_to_tgbta: POST if (state->is_livelock_accepting_state()) ... create_transition ***"
<< std::endl;
}
@ -640,7 +649,8 @@ namespace spot
state->set_livelock_accepting_state(false);
state->set_accepting_state(false);
trace << "***tgba_to_tgbta: POST create_transition ***" << std::endl;
trace
<< "***tgba_to_tgbta: POST create_transition ***" << std::endl;
}

View file

@ -34,22 +34,73 @@
namespace spot
{
/// \brief Build a spot::tgba_explicit* from an LTL formula.
/// \ingroup tgba_ta
///
/// This is based on the following paper.
/// \verbatim
/// @InProceedings{ geldenhuys.06.spin,
/// author = {Jaco Geldenhuys and Henri Hansen},
/// title = {Larger Automata and Less Work for {LTL} Model Checking},
/// booktitle = {Proceedings of the 13th International SPIN Workshop
/// (SPIN'06)},
/// year = {2006},
/// pages = {53--70},
/// series = {Lecture Notes in Computer Science},
/// volume = {3925},
/// publisher = {Springer}
/// }
/// \endverbatim
///
/// \param tgba_to_convert The TGBA automaton to convert into a TA automaton
///
/// \param atomic_propositions_set The set of atomic propositions used in the
/// input TGBA \a tgba_to_convert
///
/// \param artificial_initial_state_mode When set, the algorithm will build
/// a TA automaton with an unique initial state. This
/// artificial initial state have one transition to each real initial state,
/// and this transition is labeled by the corresponding initial condition.
/// (see spot::ta::get_artificial_initial_state())
///
/// \param STA_mode When set, the returned TA
/// automaton is a STA (Single-pass Testing Automata): a STA automaton is a TA
/// where: for every livelock-accepting state s, if s is not also a
/// Buchi-accepting state, then s has no successors. A STA product requires
/// only one-pass emptiness check algorithm (see spot::ta_check::check)
///
/// \param degeneralized When false, the returned automaton is a generalized
/// form of TA, called TGTA (Transition-based Generalized Testing Automaton).
/// Like TGBA, TGTA use Generalized Büchi acceptance
/// conditions intead of Büchi-accepting states: there are several acceptance
/// sets (of transitions), and a path is accepted if it traverses
/// at least one transition of each set infinitely often or if it contains a
/// livelock-accepting cycle.
///
/// \return A spot::ta_explicit that recognizes the same language as the
/// TGBA \a tgba_to_convert.
ta_explicit*
tgba_to_ta(const tgba* tgba_to_convert, bdd atomic_propositions_set,
bool artificial_initial_state_mode = true,
bool artificial_livelock_accepting_state_mode = false,
bool artificial_initial_state_mode = true, bool STA_mode = false,
bool degeneralized = true);
//artificial_livelock_accepting_state is used in the case of TA+ automata
void
compute_livelock_acceptance_states(ta_explicit* testing_automata, state_ta_explicit* artificial_livelock_accepting_state = 0);
stgta_explicit*
tgba_to_stgta(const tgba* tgba_to_convert, bdd atomic_propositions_set);
void
add_artificial_livelock_accepting_state(ta_explicit* testing_automata,
state_ta_explicit* artificial_livelock_accepting_state);
tgbta_explicit*
tgba_to_tgbta(const tgba* tgba_to_convert, bdd atomic_propositions_set);
//artificial_livelock_accepting_state is used in the case of
//STA (Single-pass Testing Automata) or in the case
//STGTA (Single-pass Transition-based Generalised Testing Automata)
void
compute_livelock_acceptance_states(ta_explicit* testing_automata,
state_ta_explicit* artificial_livelock_accepting_state = 0);
//artificial_livelock_accepting_state is added to transform TA into
//STA (Single-pass Testing Automata) or to transform TGTA into
//STGTA (Single-pass Transition-based Generalised Testing Automata)
void
add_artificial_livelock_accepting_state(ta_explicit* testing_automata,
state_ta_explicit* artificial_livelock_accepting_state);
}