Commit 260a141b authored by Alexandre Duret-Lutz's avatar Alexandre Duret-Lutz

improve fuse_marks_here by detecting more patterns

This remove some restrictions that prevented fuse_marks_here from
simplifying certain patterns, as noted in the first comment of
issue #405.

* spot/twaalgos/cleanacc.cc (find_interm_rec, find_fusable): Remove
some unnecessary restrictions to singleton marks, and replace the hack
put one non-singleton mark at the beginning of the singleton list by a
sort.
* tests/python/simplacc.py: Add two test cases.
* tests/python/automata.ipynb, tests/core/remfin.test: Improve
expected results.
* NEWS: Mention the bug.
parent 645935f7
Pipeline #19097 passed with stages
in 145 minutes and 46 seconds
......@@ -42,6 +42,12 @@ New in spot 2.9.0.dev (not yet released)
bits. This affects the output of "ltlcross --csv" and
"--stats=%t" for many tools.
- simplify_acceptance() missed some patterns it should have been
able to simplify. For instance Fin(0)&(Fin(1)|Fin(2)|Fin(4))
should simplify to Fin(1)|Fin(2)|Fin(4) adter adding {1,2,4} to
every place where 0 occur, and then the acceptance would be
renumbered to Fin(0)|Fin(1)|Fin(2). This is now fixed.
New in spot 2.9 (2020-04-30)
Command-line tools:
......
......@@ -390,7 +390,7 @@ namespace spot
case acc_cond::acc_op::FinNeg:
{
auto m = pos[-1].mark;
if (op == wanted && m.is_singleton())
if (op == wanted)
{
res |= m;
}
......@@ -427,7 +427,7 @@ namespace spot
if (op == wanted)
{
auto m = pos[-1].mark;
if (!seen && m.is_singleton())
if (!seen)
{
seen = true;
res |= m;
......@@ -512,9 +512,9 @@ namespace spot
case acc_cond::acc_op::Inf:
case acc_cond::acc_op::Fin:
{
auto m = pos[-1].mark;
if (op == wanted && m.is_singleton())
singletons.emplace_back(m, pos);
if (op == wanted)
singletons.emplace_back(pos[-1].mark,
pos);
pos -= 2;
}
break;
......@@ -526,20 +526,20 @@ namespace spot
// {b,d} can receive {a} if they
// (b and d) are both used once.
if (auto m = find_interm_rec(pos))
{
singletons.emplace_back(m, pos);
// move this to the front, to
// be sure it is the first
// recipient tried.
swap(singletons.front(),
singletons.back());
}
singletons.emplace_back(m, pos);
pos -= pos->sub.size + 1;
break;
}
}
while (pos > rend);
// sort the singletons vector: we want
// those that are not really singleton to
// be first to they can become recipient
std::partition(singletons.begin(), singletons.end(),
[&] (auto s)
{ return !s.first.is_singleton(); });
acc_cond::mark_t can_receive = {};
for (auto p: singletons)
if ((p.first & once) == p.first)
......
......@@ -292,8 +292,6 @@ State: 1
--END--
EOF
acctwelve='Inf(0)&Inf(1)&Inf(2)&Inf(3)&Inf(4)&Inf(5)'
acctwelve=$acctwelve'&Inf(6)&Inf(7)&Inf(8)&Inf(9)&Inf(10)&Inf(11)'
cat >expected <<EOF
HOA: v1
States: 3
......@@ -339,21 +337,22 @@ HOA: v1
States: 3
Start: 0
AP: 2 "a" "b"
Acceptance: 3 (Inf(1)&Inf(2)) | Inf(0)
acc-name: generalized-Buchi 2
Acceptance: 2 Inf(0)&Inf(1)
properties: trans-labels explicit-labels trans-acc
--BODY--
State: 0
[t] 0 {2}
[0] 1 {2}
[!0] 2 {0 2}
[t] 0 {1}
[0] 1 {1}
[!0] 2 {0 1}
State: 1
[1] 0 {2}
[0&1] 1 {0 2}
[!0&1] 2 {1 2}
[1] 0 {1}
[0&1] 1 {0 1}
[!0&1] 2 {0 1}
State: 2
[!1] 0
[0&!1] 1 {0}
[!0&!1] 2 {0}
[0&!1] 1 {0 1}
[!0&!1] 2 {0 1}
--END--
HOA: v1
States: 1
......@@ -867,7 +866,7 @@ HOA: v1
States: 6
Start: 0
AP: 3 "a" "b" "c"
Acceptance: 4 (Inf(0)&Inf(2)&Inf(3)) | (Inf(0)&Inf(1)&Inf(3))
Acceptance: 3 (Inf(1)&Inf(2)) | (Inf(0)&Inf(2))
properties: trans-labels explicit-labels trans-acc
--BODY--
State: 0
......@@ -883,16 +882,16 @@ State: 1
[2] 4
[!2] 5
State: 2
[0] 2 {0 1 3}
[0] 2 {0 2}
State: 3
[0&2] 2 {0 1 3}
[0&!2] 3 {0 1}
[0&2] 2 {0 2}
[0&!2] 3 {0}
State: 4
[1 | 2] 4 {0 2 3}
[!1&!2] 5 {0 2}
[1 | 2] 4 {1 2}
[!1&!2] 5 {1}
State: 5
[2] 4 {0 2 3}
[!2] 5 {0 2}
[2] 4 {1 2}
[!2] 5 {1}
--END--
EOF
......
This diff is collapsed.
......@@ -50,6 +50,16 @@ State: 5 [!0&1] 4 {3 5} [!0&1] 3 {2 4} [!0&1] 2 {2 3} [!0&!1] 0 {0}
[!0&1] 7 {0 4 5} [0&1] 5 {2} State: 6 [0&!1] 7 [0&!1] 1 {1 4} [0&1]
4 {1 4} State: 7 [0&1] 3 {2 3} [0&1] 0 [!0&!1] 6 [0&1] 1 State: 8 [0&1]
3 [!0&!1] 0 [0&1] 9 State: 9 [0&!1] 7 {4 5} [!0&1] 8 {0} [0&1] 9 --END--
/* Derived from issue #405. */
HOA: v1 States: 2 Start: 0 AP: 2 "p0" "p1" Acceptance: 4 Fin(0) &
(Fin(1)|Fin(2)|Fin(3)) properties: trans-labels explicit-labels trans-acc
--BODY-- State: 0 [!0&!1] 0 {0 1 3} [0&1] 1 {0 2} [0&!1] 0 {2} State:
1 [0&1] 0 {0 2} [0&1] 1 {1} [0&!1] 1 --END--
/* More complex version of the previous automaton */
HOA: v1 States: 2 Start: 0 AP: 2 "p0" "p1" Acceptance: 5 Fin(0) &
(((Fin(1)|Fin(2)|Fin(3))&Inf(4)|Fin(3))) properties: trans-labels
explicit-labels trans-acc --BODY-- State: 0 [!0&!1] 0 {0 1 3} [0&1] 1
{0 2} [0&!1] 0 {2} State: 1 [0&1] 0 {0 2} [0&1] 1 {1} [0&!1] 1 {4} --END--
"""))
res = []
......@@ -80,4 +90,8 @@ assert res == [
'((Inf(1) & Fin(2)) | Fin(5)) & (Inf(0) | (Inf(1) & (Inf(3) | Fin(4))))',
'Inf(0)',
'Fin(0)',
'Fin(0)|Fin(1)|Fin(2)',
'Inf(0)&Inf(1)&Inf(2)',
'((Fin(0)|Fin(1)) & Inf(3)) | Fin(2)',
'((Inf(0)&Inf(1)) | Fin(3)) & Inf(2)',
]
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