partial_degeneralize: handle original-state correctly

Reported by Florian Renkin

* spot/twaalgos/degen.cc (partial_degeneralize): Update
original-state when partial_degeneralize is executed more
than once in a loop.
* tests/python/pdegen.py: Add test case.
This commit is contained in:
Alexandre Duret-Lutz 2020-02-07 12:27:53 +01:00
parent febbe5c2e3
commit 71f1f2fb96
2 changed files with 61 additions and 1 deletions

View file

@ -1082,8 +1082,28 @@ namespace spot
twa_graph_ptr
partial_degeneralize(twa_graph_ptr a)
{
bool composeorig = false;
while (acc_cond::mark_t m = is_partially_degeneralizable(a))
a = partial_degeneralize(a, m);
{
twa_graph_ptr b = partial_degeneralize(a, m);
// After the first partial degeneralization, we need to compose
// the original-states, so that original-states still appear
// to reference the original automaton.
if (composeorig)
{
auto origa =
a->get_named_prop<std::vector<unsigned>>("original-states");
auto origb =
b->get_named_prop<std::vector<unsigned>>("original-states");
for (auto& s: *origb)
s = (*origa)[s];
}
else
{
composeorig = true;
}
a = b;
}
return a;
}