Commit 102ef043 authored by Alexandre Duret-Lutz's avatar Alexandre Duret-Lutz

simplify_acc: loop over the simplifications

* spot/twaalgos/cleanacc.cc (simplify_acceptance_here): Run the
simplifications in a loop until the condition does not change anymore.
* tests/python/simplacc.py, tests/core/accsimpl.test,
tests/core/remfin.test, tests/python/merge.py,
tests/python/simplacc.py, tests/python/toparity.py: Update expected
results.
* tests/python/automata.ipynb: Update the failing example to a more
interesting one, matching the one in doc/org/autfilt.org.
parent b62e1bb1
......@@ -617,20 +617,20 @@ namespace spot
twa_graph_ptr simplify_acceptance_here(twa_graph_ptr aut)
{
cleanup_acceptance_here(aut, false);
merge_identical_marks_here(aut);
if (!aut->acc().is_generalized_buchi())
for (;;)
{
cleanup_acceptance_here(aut, false);
merge_identical_marks_here(aut);
if (aut->acc().is_generalized_buchi())
break;
acc_cond::acc_code old = aut->get_acceptance();
simplify_complementary_marks_here(aut);
fuse_marks_here(aut);
aut->set_acceptance(aut->acc().unit_propagation());
if (old == aut->get_acceptance())
break;
}
cleanup_acceptance_here(aut, true);
auto prop_cond = aut->acc().unit_propagation();
if (prop_cond != aut->acc())
{
aut->set_acceptance(prop_cond);
cleanup_acceptance_here(aut, true);
}
return aut;
}
......
......@@ -72,4 +72,4 @@ State: 0
--END--
EOF
autcross --language-preserved 'autfilt --simplify-acc' -F frenkin
test 1,4,2 = "`autfilt --simplify-acc frenkin --stats=%s,%e,%a`"
test 1,4,1 = "`autfilt --simplify-acc frenkin --stats=%s,%e,%a`"
......@@ -313,27 +313,25 @@ State: 2 {0}
[!1] 2
--END--
HOA: v1
States: 4
States: 3
Start: 0
AP: 2 "a" "b"
Acceptance: 4 Inf(0) | Inf(3) | (Inf(1)&Inf(2))
acc-name: Buchi
Acceptance: 1 Inf(0)
properties: trans-labels explicit-labels trans-acc
--BODY--
State: 0
[t] 0 {2 3}
[0] 1 {2 3}
[!0] 2 {2 3}
[t] 0 {0}
[0] 1 {0}
[!0] 2 {0}
State: 1
[1] 0 {2}
[0&1] 1 {2}
[!0&1] 2 {1 2}
[1] 0 {0}
[0&1] 1 {0}
[!0&1] 2 {0}
State: 2
[!1] 0
[0&!1] 1
[!0&!1] 2
[!0&!1] 3
State: 3
[!0&!1] 3 {0}
[0&!1] 1 {0}
[!0&!1] 2 {0}
--END--
HOA: v1
States: 3
......@@ -915,7 +913,7 @@ State: 2 {0}
[!1] 2
--END--
HOA: v1
States: 4
States: 3
Start: 0
AP: 2 "a" "b"
acc-name: Buchi
......@@ -927,16 +925,13 @@ State: 0
[0] 1 {0}
[!0] 2 {0}
State: 1
[1] 0
[0&1] 1
[1] 0 {0}
[0&1] 1 {0}
[!0&1] 2 {0}
State: 2
[!1] 0
[0&!1] 1
[!0&!1] 2
[!0&!1] 3
State: 3
[!0&!1] 3 {0}
[0&!1] 1 {0}
[!0&!1] 2 {0}
--END--
HOA: v1
States: 3
......
This source diff could not be displayed because it is too large. You can view the blob instead.
#!/usr/bin/python3
# -*- mode: python; coding: utf-8 -*-
# Copyright (C) 2017 Laboratoire de Recherche et Développement de
# Copyright (C) 2017, 2020 Laboratoire de Recherche et Développement de
# l'EPITA.
#
# This file is part of Spot, a model checking library.
......@@ -78,8 +78,7 @@ assert hoa == """HOA: v1
States: 3
Start: 0
AP: 2 "a" "b"
acc-name: parity min even 2
Acceptance: 2 Inf(0) | Fin(1)
Acceptance: 2 Fin(1) | Inf(0)
properties: trans-labels explicit-labels trans-acc
--BODY--
State: 0
......
......@@ -57,23 +57,28 @@ for a in auts:
b = spot.simplify_acceptance(a)
assert b.equivalent_to(a)
res.append(str(b.get_acceptance()))
c = spot.simplify_acceptance(b)
assert b.get_acceptance() == c.get_acceptance()
a.set_acceptance(a.num_sets(), a.get_acceptance().complement())
b = spot.simplify_acceptance(a)
assert b.equivalent_to(a)
res.append(str(b.get_acceptance()))
c = spot.simplify_acceptance(b)
assert b.get_acceptance() == c.get_acceptance()
assert res == [
'Inf(0)',
'Fin(0)',
'Inf(1) & Fin(0)',
'Fin(0) & Inf(1)',
'Fin(1) | Inf(0)',
'Inf(1) & (Fin(0) | Inf(2))',
'(Fin(0) | Inf(2)) & Inf(1)',
'Fin(1) | (Fin(2) & Inf(0))',
'(Fin(1) | Inf(2)) & Inf(0)',
'Fin(0) | (Fin(2) & Inf(1))',
'((Fin(1) | Inf(2)) & Inf(5)) | (Fin(0) & (Fin(1) | (Fin(3) & Inf(4))))',
'(Fin(5) | (Fin(2) & Inf(1))) & (Inf(0) | ((Fin(4) | Inf(3)) & Inf(1)))',
'Inf(1) | Inf(0)',
'Fin(1) & Fin(0)',
'Inf(0)',
'Fin(0)',
]
......@@ -288,7 +288,7 @@ State: 4
[0&!1] 4
[0&1] 4 {1 2 4}
--END--
"""), [9, 6, 7, 7, 6, 6, 6])
"""), [9, 6, 6, 6, 7, 6, 6])
test(spot.automaton("""
HOA: v1
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment