Add a new form of TA with a Single-pass emptiness check (STA)
* src/ta/ta.cc, src/ta/ta.hh, src/ta/taexplicit.cc, src/ta/taexplicit.hh, src/ta/taproduct.cc,src/ta/taproduct.hh, src/taalgos/dotty.cc, src/taalgos/emptinessta.cc, src/taalgos/emptinessta.hh, src/taalgos/minimize.cc, src/taalgos/reachiter.cc, src/taalgos/sba2ta.cc, src/taalgos/sba2ta.hh, src/tgbatest/ltl2ta.test, src/tgbatest/ltl2tgba.cc: Impacts of the implementation of a new variant of TA, called STA, which involve a Single-pass emptiness check. The new options (-in and -lv) added to build the new variants of TA allow to add two artificial states: 1- an initial artificial state to have an unique initial state (-in) 2- a livelock artificial state which has no successors in order to obtain the new form of TA which requires only a Single-pass emptiness- check: STA (-lv).
This commit is contained in:
parent
310973f88c
commit
782ba0010b
15 changed files with 1224 additions and 711 deletions
|
|
@ -18,7 +18,7 @@
|
|||
// Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
// 02111-1307, USA.
|
||||
|
||||
// #define TRACE
|
||||
//#define TRACE
|
||||
|
||||
#include <iostream>
|
||||
#ifdef TRACE
|
||||
|
|
@ -34,7 +34,7 @@
|
|||
namespace spot
|
||||
{
|
||||
|
||||
ta_check::ta_check(const ta* a, option_map o) :
|
||||
ta_check::ta_check(const ta_product* a, option_map o) :
|
||||
a_(a), o_(o)
|
||||
{
|
||||
is_full_2_pass_ = o.get("is_full_2_pass", 0);
|
||||
|
|
@ -46,7 +46,7 @@ namespace spot
|
|||
}
|
||||
|
||||
bool
|
||||
ta_check::check()
|
||||
ta_check::check(bool disable_second_pass)
|
||||
{
|
||||
|
||||
// We use five main data in this algorithm:
|
||||
|
|
@ -54,7 +54,7 @@ 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,
|
||||
|
|
@ -71,276 +71,291 @@ namespace spot
|
|||
std::stack<spot::state*> init_set;
|
||||
|
||||
Sgi::hash_map<const state*, std::string, state_ptr_hash, state_ptr_equal>
|
||||
colour;
|
||||
colour;
|
||||
|
||||
trace
|
||||
<< "PASS 1" << std::endl;
|
||||
//const std::string WHITE = "W";
|
||||
//const std::string GREY = "G";
|
||||
//const std::string BLUE = "B";
|
||||
//const std::string BLACK = "BK";
|
||||
|
||||
Sgi::hash_map<const state*, std::set<const state*, state_ptr_less_than>,
|
||||
state_ptr_hash, state_ptr_equal> liveset;
|
||||
state_ptr_hash, state_ptr_equal> liveset;
|
||||
|
||||
std::stack<spot::state*> livelock_roots;
|
||||
|
||||
bool livelock_acceptance_states_not_found = true;
|
||||
|
||||
const ta::states_set_t init_states_set = a_->get_initial_states_set();
|
||||
|
||||
ta::states_set_t::const_iterator it;
|
||||
for (it = init_states_set.begin(); it != init_states_set.end(); it++)
|
||||
{
|
||||
state* init_state = (*it);
|
||||
init_set.push(init_state);
|
||||
//colour[init_state] = WHITE;
|
||||
state* init_state = (*it);
|
||||
init_set.push(init_state);
|
||||
|
||||
}
|
||||
|
||||
while (!init_set.empty())
|
||||
{
|
||||
// Setup depth-first search from initial states.
|
||||
// Setup depth-first search from initial states.
|
||||
|
||||
{
|
||||
state* init = init_set.top();
|
||||
init_set.pop();
|
||||
{
|
||||
state* init = init_set.top();
|
||||
init_set.pop();
|
||||
|
||||
numbered_state_heap::state_index_p h_init = h->find(init);
|
||||
numbered_state_heap::state_index_p h_init = h->find(init);
|
||||
|
||||
if (h_init.first)
|
||||
continue;
|
||||
if (h_init.first)
|
||||
continue;
|
||||
|
||||
h->insert(init, ++num);
|
||||
scc.push(num);
|
||||
h->insert(init, ++num);
|
||||
scc.push(num);
|
||||
|
||||
ta_succ_iterator* iter = a_->succ_iter(init);
|
||||
iter->first();
|
||||
todo.push(pair_state_iter(init, iter));
|
||||
//colour[init] = GREY;
|
||||
inc_depth();
|
||||
ta_succ_iterator* iter = a_->succ_iter(init);
|
||||
iter->first();
|
||||
todo.push(pair_state_iter(init, iter));
|
||||
|
||||
//push potential root of live-lock accepting cycle
|
||||
if (a_->is_livelock_accepting_state(init))
|
||||
livelock_roots.push(init);
|
||||
inc_depth();
|
||||
|
||||
}
|
||||
//push potential root of live-lock accepting cycle
|
||||
if (a_->is_livelock_accepting_state(init))
|
||||
livelock_roots.push(init);
|
||||
|
||||
while (!todo.empty())
|
||||
{
|
||||
}
|
||||
|
||||
state* curr = todo.top().first;
|
||||
while (!todo.empty())
|
||||
{
|
||||
|
||||
// We are looking at the next successor in SUCC.
|
||||
ta_succ_iterator* succ = todo.top().second;
|
||||
state* curr = todo.top().first;
|
||||
|
||||
// If there is no more successor, backtrack.
|
||||
if (succ->done())
|
||||
{
|
||||
// We have explored all successors of state CURR.
|
||||
// We are looking at the next successor in SUCC.
|
||||
ta_succ_iterator* succ = todo.top().second;
|
||||
|
||||
// If there is no more successor, backtrack.
|
||||
if (succ->done())
|
||||
{
|
||||
// We have explored all successors of state CURR.
|
||||
|
||||
|
||||
// Backtrack TODO.
|
||||
todo.pop();
|
||||
dec_depth();
|
||||
trace
|
||||
<< "PASS 1 : backtrack" << std::endl;
|
||||
// Backtrack TODO.
|
||||
todo.pop();
|
||||
dec_depth();
|
||||
trace
|
||||
<< "PASS 1 : backtrack" << std::endl;
|
||||
|
||||
// fill rem with any component removed,
|
||||
numbered_state_heap::state_index_p spi =
|
||||
h->index(curr->clone());
|
||||
assert(spi.first);
|
||||
if (a_->is_livelock_accepting_state(curr))
|
||||
{
|
||||
livelock_acceptance_states_not_found = false;
|
||||
trace
|
||||
<< "PASS 1 : livelock accepting state found" << std::endl;
|
||||
|
||||
scc.rem().push_front(curr);
|
||||
inc_depth();
|
||||
}
|
||||
|
||||
// set the h value of the Backtracked state to negative value.
|
||||
// colour[curr] = BLUE;
|
||||
*spi.second = -std::abs(*spi.second);
|
||||
// fill rem with any component removed,
|
||||
numbered_state_heap::state_index_p spi =
|
||||
h->index(curr->clone());
|
||||
assert(spi.first);
|
||||
|
||||
// Backtrack livelock_roots.
|
||||
if (!livelock_roots.empty() && !livelock_roots.top()->compare(
|
||||
curr))
|
||||
livelock_roots.pop();
|
||||
scc.rem().push_front(curr);
|
||||
inc_depth();
|
||||
|
||||
// When backtracking the root of an SSCC, we must also
|
||||
// remove that SSCC from the ROOT stacks. We must
|
||||
// discard from H all reachable states from this SSCC.
|
||||
assert(!scc.empty());
|
||||
if (scc.top().index == std::abs(*spi.second))
|
||||
{
|
||||
// removing states
|
||||
std::list<state*>::iterator i;
|
||||
// set the h value of the Backtracked state to negative value.
|
||||
// colour[curr] = BLUE;
|
||||
*spi.second = -std::abs(*spi.second);
|
||||
|
||||
for (i = scc.rem().begin(); i != scc.rem().end(); ++i)
|
||||
{
|
||||
numbered_state_heap::state_index_p spi = h->index(
|
||||
(*i)->clone());
|
||||
assert(spi.first->compare(*i) == 0);
|
||||
assert(*spi.second != -1);
|
||||
*spi.second = -1;
|
||||
//colour[*i] = BLACK;
|
||||
// Backtrack livelock_roots.
|
||||
if (!livelock_roots.empty() && !livelock_roots.top()->compare(
|
||||
curr))
|
||||
livelock_roots.pop();
|
||||
|
||||
}
|
||||
dec_depth(scc.rem().size());
|
||||
scc.pop();
|
||||
}
|
||||
// When backtracking the root of an SSCC, we must also
|
||||
// remove that SSCC from the ROOT stacks. We must
|
||||
// discard from H all reachable states from this SSCC.
|
||||
assert(!scc.empty());
|
||||
if (scc.top().index == std::abs(*spi.second))
|
||||
{
|
||||
// removing states
|
||||
std::list<state*>::iterator i;
|
||||
|
||||
delete succ;
|
||||
// Do not delete CURR: it is a key in H.
|
||||
continue;
|
||||
}
|
||||
for (i = scc.rem().begin(); i != scc.rem().end(); ++i)
|
||||
{
|
||||
numbered_state_heap::state_index_p spi = h->index(
|
||||
(*i)->clone());
|
||||
assert(spi.first->compare(*i) == 0);
|
||||
assert(*spi.second != -1);
|
||||
*spi.second = -1;
|
||||
//colour[*i] = BLACK;
|
||||
|
||||
// We have a successor to look at.
|
||||
inc_transitions();
|
||||
trace
|
||||
<< "PASS 1: transition" << std::endl;
|
||||
// Fetch the values destination state we are interested in...
|
||||
state* dest = succ->current_state();
|
||||
}
|
||||
dec_depth(scc.rem().size());
|
||||
scc.pop();
|
||||
}
|
||||
|
||||
//may be Buchi accepting scc
|
||||
scc.top().is_accepting = a_->is_accepting_state(curr)
|
||||
&& !succ->is_stuttering_transition();
|
||||
delete succ;
|
||||
// Do not delete CURR: it is a key in H.
|
||||
continue;
|
||||
}
|
||||
|
||||
bool is_stuttering_transition = succ->is_stuttering_transition();
|
||||
// We have a successor to look at.
|
||||
inc_transitions();
|
||||
trace
|
||||
<< "PASS 1: transition" << std::endl;
|
||||
// Fetch the values destination state we are interested in...
|
||||
state* dest = succ->current_state();
|
||||
|
||||
// ... and point the iterator to the next successor, for
|
||||
// the next iteration.
|
||||
succ->next();
|
||||
// We do not need SUCC from now on.
|
||||
bool curr_is_livelock_hole_state_in_ta_component =
|
||||
(a_->is_hole_state_in_ta_component(curr))
|
||||
&& a_->is_livelock_accepting_state(curr);
|
||||
|
||||
// Are we going to a new state?
|
||||
numbered_state_heap::state_index_p spi = h->find(dest);
|
||||
//may be Buchi accepting scc or livelock accepting state (contains a TA hole and livelock accepting state)
|
||||
scc.top().is_accepting = (a_->is_accepting_state(curr)
|
||||
&& !succ->is_stuttering_transition())
|
||||
|| curr_is_livelock_hole_state_in_ta_component;
|
||||
|
||||
// Is this a new state?
|
||||
if (!spi.first)
|
||||
{
|
||||
// Number it, stack it, and register its successors
|
||||
// for later processing.
|
||||
h->insert(dest, ++num);
|
||||
scc.push(num);
|
||||
bool is_stuttering_transition = succ->is_stuttering_transition();
|
||||
|
||||
ta_succ_iterator* iter = a_->succ_iter(dest);
|
||||
iter->first();
|
||||
todo.push(pair_state_iter(dest, iter));
|
||||
//colour[dest] = GREY;
|
||||
inc_depth();
|
||||
// ... and point the iterator to the next successor, for
|
||||
// the next iteration.
|
||||
succ->next();
|
||||
// We do not need SUCC from now on.
|
||||
|
||||
//push potential root of live-lock accepting cycle
|
||||
if (a_->is_livelock_accepting_state(dest)
|
||||
&& !is_stuttering_transition)
|
||||
livelock_roots.push(dest);
|
||||
// Are we going to a new state?
|
||||
numbered_state_heap::state_index_p spi = h->find(dest);
|
||||
|
||||
continue;
|
||||
}
|
||||
// Is this a new state?
|
||||
if (!spi.first)
|
||||
{
|
||||
// Number it, stack it, and register its successors
|
||||
// for later processing.
|
||||
h->insert(dest, ++num);
|
||||
scc.push(num);
|
||||
|
||||
// If we have reached a dead component, ignore it.
|
||||
if (*spi.second == -1)
|
||||
continue;
|
||||
ta_succ_iterator* iter = a_->succ_iter(dest);
|
||||
iter->first();
|
||||
todo.push(pair_state_iter(dest, iter));
|
||||
//colour[dest] = GREY;
|
||||
inc_depth();
|
||||
|
||||
// Now this is the most interesting case. We have reached a
|
||||
// state S1 which is already part of a non-dead SSCC. Any such
|
||||
// non-dead SSCC has necessarily been crossed by our path to
|
||||
// this state: there is a state S2 in our path which belongs
|
||||
// to this SSCC too. We are going to merge all states between
|
||||
// this S1 and S2 into this SSCC.
|
||||
//
|
||||
// This merge is easy to do because the order of the SSCC in
|
||||
// ROOT is ascending: we just have to merge all SSCCs from the
|
||||
// top of ROOT that have an index greater to the one of
|
||||
// the SSCC of S2 (called the "threshold").
|
||||
int threshold = std::abs(*spi.second);
|
||||
std::list<state*> rem;
|
||||
bool acc = false;
|
||||
//push potential root of live-lock accepting cycle
|
||||
if (a_->is_livelock_accepting_state(dest)
|
||||
&& !is_stuttering_transition)
|
||||
livelock_roots.push(dest);
|
||||
|
||||
while (threshold < scc.top().index)
|
||||
{
|
||||
assert(!scc.empty());
|
||||
continue;
|
||||
}
|
||||
|
||||
acc |= scc.top().is_accepting;
|
||||
// If we have reached a dead component, ignore it.
|
||||
if (*spi.second == -1)
|
||||
continue;
|
||||
|
||||
rem.splice(rem.end(), scc.rem());
|
||||
scc.pop();
|
||||
// Now this is the most interesting case. We have reached a
|
||||
// state S1 which is already part of a non-dead SSCC. Any such
|
||||
// non-dead SSCC has necessarily been crossed by our path to
|
||||
// this state: there is a state S2 in our path which belongs
|
||||
// to this SSCC too. We are going to merge all states between
|
||||
// this S1 and S2 into this SSCC.
|
||||
//
|
||||
// This merge is easy to do because the order of the SSCC in
|
||||
// ROOT is ascending: we just have to merge all SSCCs from the
|
||||
// top of ROOT that have an index greater to the one of
|
||||
// the SSCC of S2 (called the "threshold").
|
||||
int threshold = std::abs(*spi.second);
|
||||
std::list<state*> rem;
|
||||
bool acc = false;
|
||||
|
||||
}
|
||||
// Note that we do not always have
|
||||
// threshold == scc.top().index
|
||||
// after this loop, the SSCC whose index is threshold might have
|
||||
// been merged with a lower SSCC.
|
||||
while (threshold < scc.top().index)
|
||||
{
|
||||
assert(!scc.empty());
|
||||
|
||||
// Accumulate all acceptance conditions into the merged SSCC.
|
||||
scc.top().is_accepting |= acc;
|
||||
acc |= scc.top().is_accepting;
|
||||
|
||||
scc.rem().splice(scc.rem().end(), rem);
|
||||
if (scc.top().is_accepting)
|
||||
{
|
||||
clear(h, todo, init_set);
|
||||
trace
|
||||
<< "PASS 1: SUCCESS" << std::endl;
|
||||
return true;
|
||||
}
|
||||
rem.splice(rem.end(), scc.rem());
|
||||
scc.pop();
|
||||
|
||||
//ADDLINKS
|
||||
if (!is_full_2_pass_ && a_->is_livelock_accepting_state(curr)
|
||||
&& is_stuttering_transition)
|
||||
{
|
||||
trace
|
||||
<< "PASS 1: heuristic livelock detection " << std::endl;
|
||||
const state* dest = spi.first;
|
||||
std::set<const state*, state_ptr_less_than> liveset_dest =
|
||||
liveset[dest];
|
||||
}
|
||||
// Note that we do not always have
|
||||
// threshold == scc.top().index
|
||||
// after this loop, the SSCC whose index is threshold might have
|
||||
// been merged with a lower SSCC.
|
||||
|
||||
std::set<const state*, state_ptr_less_than> liveset_curr =
|
||||
liveset[curr];
|
||||
// Accumulate all acceptance conditions into the merged SSCC.
|
||||
scc.top().is_accepting |= acc;
|
||||
|
||||
int h_livelock_root = 0;
|
||||
if (!livelock_roots.empty())
|
||||
h_livelock_root = *(h->find((livelock_roots.top()))).second;
|
||||
scc.rem().splice(scc.rem().end(), rem);
|
||||
if (scc.top().is_accepting)
|
||||
{
|
||||
clear(h, todo, init_set);
|
||||
trace
|
||||
<< "PASS 1: SUCCESS" << std::endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (heuristic_livelock_detection(dest, h, h_livelock_root,
|
||||
liveset_curr))
|
||||
{
|
||||
clear(h, todo, init_set);
|
||||
return true;
|
||||
}
|
||||
//ADDLINKS
|
||||
if (!is_full_2_pass_ && a_->is_livelock_accepting_state(curr)
|
||||
&& is_stuttering_transition)
|
||||
{
|
||||
trace
|
||||
<< "PASS 1: heuristic livelock detection " << std::endl;
|
||||
const state* dest = spi.first;
|
||||
std::set<const state*, state_ptr_less_than> liveset_dest =
|
||||
liveset[dest];
|
||||
|
||||
std::set<const state*, state_ptr_less_than>::const_iterator it;
|
||||
for (it = liveset_dest.begin(); it != liveset_dest.end(); it++)
|
||||
{
|
||||
const state* succ = (*it);
|
||||
if (heuristic_livelock_detection(succ, h, h_livelock_root,
|
||||
liveset_curr))
|
||||
{
|
||||
clear(h, todo, init_set);
|
||||
return true;
|
||||
}
|
||||
std::set<const state*, state_ptr_less_than> liveset_curr =
|
||||
liveset[curr];
|
||||
|
||||
}
|
||||
int h_livelock_root = 0;
|
||||
if (!livelock_roots.empty())
|
||||
h_livelock_root = *(h->find((livelock_roots.top()))).second;
|
||||
|
||||
}
|
||||
}
|
||||
if (heuristic_livelock_detection(dest, h, h_livelock_root,
|
||||
liveset_curr))
|
||||
{
|
||||
clear(h, todo, init_set);
|
||||
return true;
|
||||
}
|
||||
|
||||
std::set<const state*, state_ptr_less_than>::const_iterator it;
|
||||
for (it = liveset_dest.begin(); it != liveset_dest.end(); it++)
|
||||
{
|
||||
const state* succ = (*it);
|
||||
if (heuristic_livelock_detection(succ, h, h_livelock_root,
|
||||
liveset_curr))
|
||||
{
|
||||
clear(h, todo, init_set);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
clear(h, todo, init_set);
|
||||
|
||||
if (disable_second_pass || livelock_acceptance_states_not_found)
|
||||
return false;
|
||||
|
||||
return livelock_detection(a_);
|
||||
}
|
||||
|
||||
bool
|
||||
ta_check::heuristic_livelock_detection(const state * u,
|
||||
numbered_state_heap* h, int h_livelock_root, std::set<const state*,
|
||||
state_ptr_less_than> liveset_curr)
|
||||
state_ptr_less_than> liveset_curr)
|
||||
{
|
||||
numbered_state_heap::state_index_p hu = h->find(u);
|
||||
|
||||
if (*hu.second > 0) // colour[u] == GREY
|
||||
{
|
||||
|
||||
if (*hu.second >= h_livelock_root)
|
||||
{
|
||||
trace
|
||||
<< "PASS 1: heuristic livelock detection SUCCESS" << std::endl;
|
||||
return true;
|
||||
}
|
||||
if (*hu.second >= h_livelock_root)
|
||||
{
|
||||
trace
|
||||
<< "PASS 1: heuristic livelock detection SUCCESS" << std::endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
liveset_curr.insert(u);
|
||||
liveset_curr.insert(u);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
@ -358,7 +373,7 @@ 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,
|
||||
|
|
@ -378,195 +393,191 @@ namespace spot
|
|||
// * init: the set of the depth-first search initial states
|
||||
std::stack<spot::state*> init_set;
|
||||
|
||||
|
||||
|
||||
const ta::states_set_t init_states_set = a_->get_initial_states_set();
|
||||
ta::states_set_t::const_iterator it;
|
||||
for (it = init_states_set.begin(); it != init_states_set.end(); it++)
|
||||
{
|
||||
state* init_state = (*it);
|
||||
init_set.push(init_state);
|
||||
|
||||
state* init_state = (*it);
|
||||
init_set.push(init_state);
|
||||
|
||||
}
|
||||
|
||||
|
||||
while (!init_set.empty())
|
||||
{
|
||||
// Setup depth-first search from initial states.
|
||||
{
|
||||
state* init = init_set.top();
|
||||
init_set.pop();
|
||||
numbered_state_heap::state_index_p h_init = h->find(init);
|
||||
// Setup depth-first search from initial states.
|
||||
{
|
||||
state* init = init_set.top();
|
||||
init_set.pop();
|
||||
numbered_state_heap::state_index_p h_init = h->find(init);
|
||||
|
||||
if (h_init.first)
|
||||
continue;
|
||||
if (h_init.first)
|
||||
continue;
|
||||
|
||||
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);
|
||||
iter->first();
|
||||
todo.push(pair_state_iter(init, iter));
|
||||
inc_depth();
|
||||
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);
|
||||
iter->first();
|
||||
todo.push(pair_state_iter(init, iter));
|
||||
inc_depth();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
while (!todo.empty())
|
||||
{
|
||||
while (!todo.empty())
|
||||
{
|
||||
|
||||
state* curr = todo.top().first;
|
||||
state* curr = todo.top().first;
|
||||
|
||||
// We are looking at the next successor in SUCC.
|
||||
ta_succ_iterator* succ = todo.top().second;
|
||||
// We are looking at the next successor in SUCC.
|
||||
ta_succ_iterator* succ = todo.top().second;
|
||||
|
||||
// If there is no more successor, backtrack.
|
||||
if (succ->done())
|
||||
{
|
||||
// We have explored all successors of state CURR.
|
||||
// If there is no more successor, backtrack.
|
||||
if (succ->done())
|
||||
{
|
||||
// We have explored all successors of state CURR.
|
||||
|
||||
// Backtrack TODO.
|
||||
todo.pop();
|
||||
dec_depth();
|
||||
trace
|
||||
<< "PASS 2 : backtrack" << std::endl;
|
||||
// Backtrack TODO.
|
||||
todo.pop();
|
||||
dec_depth();
|
||||
trace
|
||||
<< "PASS 2 : backtrack" << std::endl;
|
||||
|
||||
// fill rem with any component removed,
|
||||
numbered_state_heap::state_index_p spi =
|
||||
h->index(curr->clone());
|
||||
assert(spi.first);
|
||||
// fill rem with any component removed,
|
||||
numbered_state_heap::state_index_p spi =
|
||||
h->index(curr->clone());
|
||||
assert(spi.first);
|
||||
|
||||
sscc.rem().push_front(curr);
|
||||
inc_depth();
|
||||
sscc.rem().push_front(curr);
|
||||
inc_depth();
|
||||
|
||||
// When backtracking the root of an SSCC, we must also
|
||||
// remove that SSCC from the ROOT stacks. We must
|
||||
// discard from H all reachable states from this SSCC.
|
||||
assert(!sscc.empty());
|
||||
if (sscc.top().index == *spi.second)
|
||||
{
|
||||
// removing states
|
||||
std::list<state*>::iterator i;
|
||||
// When backtracking the root of an SSCC, we must also
|
||||
// remove that SSCC from the ROOT stacks. We must
|
||||
// discard from H all reachable states from this SSCC.
|
||||
assert(!sscc.empty());
|
||||
if (sscc.top().index == *spi.second)
|
||||
{
|
||||
// removing states
|
||||
std::list<state*>::iterator i;
|
||||
|
||||
for (i = sscc.rem().begin(); i != sscc.rem().end(); ++i)
|
||||
{
|
||||
numbered_state_heap::state_index_p spi = h->index(
|
||||
(*i)->clone());
|
||||
assert(spi.first->compare(*i) == 0);
|
||||
assert(*spi.second != -1);
|
||||
*spi.second = -1;
|
||||
}
|
||||
dec_depth(sscc.rem().size());
|
||||
sscc.pop();
|
||||
}
|
||||
for (i = sscc.rem().begin(); i != sscc.rem().end(); ++i)
|
||||
{
|
||||
numbered_state_heap::state_index_p spi = h->index(
|
||||
(*i)->clone());
|
||||
assert(spi.first->compare(*i) == 0);
|
||||
assert(*spi.second != -1);
|
||||
*spi.second = -1;
|
||||
}
|
||||
dec_depth(sscc.rem().size());
|
||||
sscc.pop();
|
||||
}
|
||||
|
||||
delete succ;
|
||||
// Do not delete CURR: it is a key in H.
|
||||
delete succ;
|
||||
// Do not delete CURR: it is a key in H.
|
||||
|
||||
continue;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
// We have a successor to look at.
|
||||
inc_transitions();
|
||||
trace
|
||||
<< "PASS 2 : transition" << std::endl;
|
||||
// Fetch the values destination state we are interested in...
|
||||
state* dest = succ->current_state();
|
||||
// We have a successor to look at.
|
||||
inc_transitions();
|
||||
trace
|
||||
<< "PASS 2 : transition" << std::endl;
|
||||
// Fetch the values destination state we are interested in...
|
||||
state* dest = succ->current_state();
|
||||
|
||||
bool is_stuttering_transition = succ->is_stuttering_transition();
|
||||
// ... and point the iterator to the next successor, for
|
||||
// the next iteration.
|
||||
succ->next();
|
||||
// We do not need SUCC from now on.
|
||||
bool is_stuttering_transition = succ->is_stuttering_transition();
|
||||
// ... and point the iterator to the next successor, for
|
||||
// the next iteration.
|
||||
succ->next();
|
||||
// We do not need SUCC from now on.
|
||||
|
||||
numbered_state_heap::state_index_p spi = h->find(dest);
|
||||
numbered_state_heap::state_index_p spi = h->find(dest);
|
||||
|
||||
// Is this a new state?
|
||||
if (!spi.first)
|
||||
{
|
||||
// Is this a new state?
|
||||
if (!spi.first)
|
||||
{
|
||||
|
||||
// Are we going to a new state through a stuttering transition?
|
||||
// Are we going to a new state through a stuttering transition?
|
||||
|
||||
if (!is_stuttering_transition)
|
||||
{
|
||||
init_set.push(dest);
|
||||
continue;
|
||||
}
|
||||
if (!is_stuttering_transition)
|
||||
{
|
||||
init_set.push(dest);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Number it, stack it, and register its successors
|
||||
// for later processing.
|
||||
h->insert(dest, ++num);
|
||||
sscc.push(num);
|
||||
sscc.top().is_accepting = t->is_livelock_accepting_state(dest);
|
||||
// Number it, stack it, and register its successors
|
||||
// for later processing.
|
||||
h->insert(dest, ++num);
|
||||
sscc.push(num);
|
||||
sscc.top().is_accepting = t->is_livelock_accepting_state(dest);
|
||||
|
||||
ta_succ_iterator* iter = t->succ_iter(dest);
|
||||
iter->first();
|
||||
todo.push(pair_state_iter(dest, iter));
|
||||
inc_depth();
|
||||
continue;
|
||||
}
|
||||
ta_succ_iterator* iter = t->succ_iter(dest);
|
||||
iter->first();
|
||||
todo.push(pair_state_iter(dest, iter));
|
||||
inc_depth();
|
||||
continue;
|
||||
}
|
||||
|
||||
// If we have reached a dead component, ignore it.
|
||||
if (*spi.second == -1)
|
||||
continue;
|
||||
// If we have reached a dead component, ignore it.
|
||||
if (*spi.second == -1)
|
||||
continue;
|
||||
|
||||
//self loop state
|
||||
if (!curr->compare(spi.first))
|
||||
{
|
||||
state * self_loop_state = (curr);
|
||||
//self loop state
|
||||
if (!curr->compare(spi.first))
|
||||
{
|
||||
state * self_loop_state = (curr);
|
||||
|
||||
if (t->is_livelock_accepting_state(self_loop_state))
|
||||
{
|
||||
clear(h, todo, init_set);
|
||||
trace
|
||||
<< "PASS 2: SUCCESS" << std::endl;
|
||||
return true;
|
||||
}
|
||||
if (t->is_livelock_accepting_state(self_loop_state))
|
||||
{
|
||||
clear(h, todo, init_set);
|
||||
trace
|
||||
<< "PASS 2: SUCCESS" << std::endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Now this is the most interesting case. We have reached a
|
||||
// state S1 which is already part of a non-dead SSCC. Any such
|
||||
// non-dead SSCC has necessarily been crossed by our path to
|
||||
// this state: there is a state S2 in our path which belongs
|
||||
// to this SSCC too. We are going to merge all states between
|
||||
// this S1 and S2 into this SSCC.
|
||||
//
|
||||
// This merge is easy to do because the order of the SSCC in
|
||||
// ROOT is ascending: we just have to merge all SSCCs from the
|
||||
// top of ROOT that have an index greater to the one of
|
||||
// the SSCC of S2 (called the "threshold").
|
||||
int threshold = *spi.second;
|
||||
std::list<state*> rem;
|
||||
bool acc = false;
|
||||
// Now this is the most interesting case. We have reached a
|
||||
// state S1 which is already part of a non-dead SSCC. Any such
|
||||
// non-dead SSCC has necessarily been crossed by our path to
|
||||
// this state: there is a state S2 in our path which belongs
|
||||
// to this SSCC too. We are going to merge all states between
|
||||
// this S1 and S2 into this SSCC.
|
||||
//
|
||||
// This merge is easy to do because the order of the SSCC in
|
||||
// ROOT is ascending: we just have to merge all SSCCs from the
|
||||
// top of ROOT that have an index greater to the one of
|
||||
// the SSCC of S2 (called the "threshold").
|
||||
int threshold = *spi.second;
|
||||
std::list<state*> rem;
|
||||
bool acc = false;
|
||||
|
||||
while (threshold < sscc.top().index)
|
||||
{
|
||||
assert(!sscc.empty());
|
||||
while (threshold < sscc.top().index)
|
||||
{
|
||||
assert(!sscc.empty());
|
||||
|
||||
acc |= sscc.top().is_accepting;
|
||||
acc |= sscc.top().is_accepting;
|
||||
|
||||
rem.splice(rem.end(), sscc.rem());
|
||||
sscc.pop();
|
||||
rem.splice(rem.end(), sscc.rem());
|
||||
sscc.pop();
|
||||
|
||||
}
|
||||
// Note that we do not always have
|
||||
// threshold == sscc.top().index
|
||||
// after this loop, the SSCC whose index is threshold might have
|
||||
// been merged with a lower SSCC.
|
||||
}
|
||||
// Note that we do not always have
|
||||
// threshold == sscc.top().index
|
||||
// after this loop, the SSCC whose index is threshold might have
|
||||
// been merged with a lower SSCC.
|
||||
|
||||
// Accumulate all acceptance conditions into the merged SSCC.
|
||||
sscc.top().is_accepting |= acc;
|
||||
// Accumulate all acceptance conditions into the merged SSCC.
|
||||
sscc.top().is_accepting |= acc;
|
||||
|
||||
sscc.rem().splice(sscc.rem().end(), rem);
|
||||
if (sscc.top().is_accepting)
|
||||
{
|
||||
clear(h, todo, init_set);
|
||||
trace
|
||||
<< "PASS 2: SUCCESS" << std::endl;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
sscc.rem().splice(sscc.rem().end(), rem);
|
||||
if (sscc.top().is_accepting)
|
||||
{
|
||||
clear(h, todo, init_set);
|
||||
trace
|
||||
<< "PASS 2: SUCCESS" << std::endl;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
clear(h, todo, init_set);
|
||||
|
|
@ -582,16 +593,16 @@ namespace spot
|
|||
|
||||
while (!init_states.empty())
|
||||
{
|
||||
a_->free_state(init_states.top());
|
||||
init_states.pop();
|
||||
a_->free_state(init_states.top());
|
||||
init_states.pop();
|
||||
}
|
||||
|
||||
// Release all iterators in TODO.
|
||||
while (!todo.empty())
|
||||
{
|
||||
delete todo.top().second;
|
||||
todo.pop();
|
||||
dec_depth();
|
||||
delete todo.top().second;
|
||||
todo.pop();
|
||||
dec_depth();
|
||||
}
|
||||
delete h;
|
||||
}
|
||||
|
|
@ -604,7 +615,7 @@ namespace spot
|
|||
|
||||
//TODO sscc;
|
||||
os << scc.size() << " strongly connected components in search stack"
|
||||
<< std::endl;
|
||||
<< std::endl;
|
||||
os << transitions() << " transitions explored" << std::endl;
|
||||
os << max_depth() << " items max in DFS search stack" << std::endl;
|
||||
return os;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue