zlktree: fix handling of automata with false acceptance

Reported by Florian.

* spot/twaalgos/zlktree.cc (zielonka_tree_transform, acd_transform):
Here.
* tests/python/zlktree.py: Add test cases.
This commit is contained in:
Alexandre Duret-Lutz 2021-10-07 11:11:49 +02:00
parent 0ec1ee6de3
commit 9b3956f892
2 changed files with 18 additions and 8 deletions

View file

@ -242,7 +242,9 @@ namespace spot
{ {
auto res = make_twa_graph(a->get_dict()); auto res = make_twa_graph(a->get_dict());
res->copy_ap_of(a); res->copy_ap_of(a);
zielonka_tree zlk(a->get_acceptance()); auto& acc = a->get_acceptance();
zielonka_tree zlk(acc);
acc_cond::mark_t mask = acc.used_sets();
// Preserve determinism, weakness, and stutter-invariance // Preserve determinism, weakness, and stutter-invariance
res->prop_copy(a, { false, true, true, true, true, true }); res->prop_copy(a, { false, true, true, true, true, true });
@ -289,7 +291,7 @@ namespace spot
for (auto& i: a->out(s.first)) for (auto& i: a->out(s.first))
{ {
auto [newbranch, prio] = zlk.step(branch, i.acc); auto [newbranch, prio] = zlk.step(branch, i.acc & mask);
zlk_state d(i.dst, newbranch); zlk_state d(i.dst, newbranch);
unsigned dst = new_state(d); unsigned dst = new_state(d);
max_color = std::max(max_color, prio); max_color = std::max(max_color, prio);
@ -1146,12 +1148,10 @@ namespace spot
} }
} }
if (!colored && max_level == 0) bool extra = colored || max_level > 0;
res->set_acceptance(0, acc_cond::acc_code::t()); res->set_acceptance(max_color + extra,
else acc_cond::acc_code::parity_min(!is_even,
res->set_acceptance(max_color + 1, max_color + extra));
acc_cond::acc_code::parity_min(!is_even,
max_color + 1));
// compose original-states with the any previously existing one. // compose original-states with the any previously existing one.
if (auto old_orig_states = if (auto old_orig_states =

View file

@ -124,3 +124,13 @@ except RuntimeError as e:
assert 'unknown node' in str(e) assert 'unknown node' in str(e)
else: else:
report_missing_exception() report_missing_exception()
a = spot.translate('true')
a.set_acceptance(spot.acc_cond('f'))
b = spot.acd_transform(a)
assert a.equivalent_to(b)
a = spot.translate('true')
a.set_acceptance(spot.acc_cond('f'))
b = spot.zielonka_tree_transform(a)
assert a.equivalent_to(b)