twagraph: remove bddfalse edges in purge_dead_states

* spot/twa/twagraph.cc (purge_dead_states): Be bddfalse-aware!
* spot/twa/twagraph.hh, NEWS: Document this.
* tests/python/alternating.py, tests/python/twagraph.py: Add some
test cases.
This commit is contained in:
Alexandre Duret-Lutz 2021-11-19 22:13:20 +01:00
parent 59690dd041
commit 5f49209caf
5 changed files with 33 additions and 6 deletions

View file

@ -618,7 +618,7 @@ namespace spot
auto& t = g_.edge_storage(tid);
todo.back().second = t.next_succ;
unsigned dst = t.dst;
if (useful[dst] != 1)
if (useful[dst] != 1 && t.cond != bddfalse)
{
todo.emplace_back(dst, g_.state_storage(dst).succ);
useful[dst] = 1;
@ -674,9 +674,12 @@ namespace spot
}
unsigned dst = *begin++;
if (begin == end)
// that was the last destination, update the stack for
// the next edge.
{
if (tid != 0)
do
tid = g_.edge_storage(tid).next_succ;
while (tid && g_.edge_storage(tid).cond == bddfalse);
if (tid != 0)
beginend(g_.edge_storage(tid).dst, begin, end);
}
@ -684,6 +687,8 @@ namespace spot
{
auto& ss = g_.state_storage(dst);
unsigned succ = ss.succ;
while (succ && g_.edge_storage(succ).cond == bddfalse)
succ = g_.edge_storage(succ).next_succ;
if (succ == 0U)
continue;
useful[dst] = 1;

View file

@ -611,7 +611,8 @@ namespace spot
/// Dead states are all the states that cannot be part of
/// an infinite run of the automaton. This includes
/// states without successors, unreachable states, and states
/// that only have dead successors.
/// that only have dead successors. Transition labeled
/// by bddfalse are also removed.
///
/// This function runs in linear time on non-alternating automata,
/// but its current implementation can be quadratic when removing