Commit f6575d2e authored by Alexandre Duret-Lutz's avatar Alexandre Duret-Lutz

improve cleanup_parity() and colorize_parity()

Fixes #384.

* spot/twaalgos/parity.cc: Here.
* tests/core/parity2.test, tests/python/highlighting.ipynb,
tests/python/parity.py: Adjust test cases.
* tests/python/parity.ipynb: Improve the presentation.
* NEWS: Mention the change.
parent f0b77e21
...@@ -103,6 +103,11 @@ New in spot 2.7.5.dev (not yet released) ...@@ -103,6 +103,11 @@ New in spot 2.7.5.dev (not yet released)
F(G(a & Fb) = FGa & GFb (unless option "reduce_size_strictly") F(G(a & Fb) = FGa & GFb (unless option "reduce_size_strictly")
G(F(a & Gb)) = GFa & FGb (unless option "reduce_size_strictly") G(F(a & Gb)) = GFa & FGb (unless option "reduce_size_strictly")
- cleanup_parity() and colorize_parity() were cleaned up a bit,
resulting in fewer colors used in some cases. In particular,
colorize_parity() learned that coloring transitiant edges does not
require the introduction of a new color.
New in spot 2.7.5 (2019-06-05) New in spot 2.7.5 (2019-06-05)
Build: Build:
......
This diff is collapsed.
...@@ -245,12 +245,12 @@ name: "(p0 W XXGp0) & G(Fp1 & FGp2)" ...@@ -245,12 +245,12 @@ name: "(p0 W XXGp0) & G(Fp1 & FGp2)"
States: 5 States: 5
Start: 0 Start: 0
AP: 3 "p0" "p1" "p2" AP: 3 "p0" "p1" "p2"
acc-name: parity max even 3 acc-name: Streett 1
Acceptance: 3 Inf(2) | (Fin(1) & Inf(0)) Acceptance: 2 Fin(0) | Inf(1)
properties: trans-labels explicit-labels trans-acc colored properties: trans-labels explicit-labels trans-acc colored
--BODY-- --BODY--
State: 0 State: 0
[0] 0 {1} [0] 0 {0}
[!0] 1 {0} [!0] 1 {0}
[0&1&2] 2 {0} [0&1&2] 2 {0}
State: 1 State: 1
...@@ -258,14 +258,14 @@ State: 1 ...@@ -258,14 +258,14 @@ State: 1
[1&2] 4 {0} [1&2] 4 {0}
State: 2 State: 2
[!0] 1 {0} [!0] 1 {0}
[0&!1&2] 2 {1} [0&!1&2] 2 {0}
[0&1&2] 2 {2} [0&1&2] 2 {1}
State: 3 State: 3
[0] 3 {1} [0] 3 {0}
[0&1&2] 4 {0} [0&1&2] 4 {0}
State: 4 State: 4
[0&!1&2] 4 {1} [0&!1&2] 4 {0}
[0&1&2] 4 {2} [0&1&2] 4 {1}
--END-- --END--
HOA: v1 HOA: v1
name: "FGa" name: "FGa"
...@@ -304,24 +304,24 @@ name: "(p0 W XXGp0) & G(Fp1 & FGp2)" ...@@ -304,24 +304,24 @@ name: "(p0 W XXGp0) & G(Fp1 & FGp2)"
States: 5 States: 5
Start: 0 Start: 0
AP: 3 "p0" "p1" "p2" AP: 3 "p0" "p1" "p2"
acc-name: parity min odd 4 acc-name: parity min odd 3
Acceptance: 4 Fin(0) & (Inf(1) | (Fin(2) & Inf(3))) Acceptance: 3 Fin(0) & (Inf(1) | Fin(2))
properties: trans-labels explicit-labels trans-acc colored properties: trans-labels explicit-labels trans-acc colored
--BODY-- --BODY--
State: 0 State: 0
[0] 0 {2} [0] 0 {2}
[!0] 1 {3} [!0] 1 {2}
[0&1&2] 2 {3} [0&1&2] 2 {2}
State: 1 State: 1
[t] 3 {3} [t] 3 {2}
[1&2] 4 {3} [1&2] 4 {2}
State: 2 State: 2
[!0] 1 {3} [!0] 1 {2}
[0&1&2] 2 {1} [0&1&2] 2 {1}
[0&!1&2] 2 {2} [0&!1&2] 2 {2}
State: 3 State: 3
[0] 3 {2} [0] 3 {2}
[0&1&2] 4 {3} [0&1&2] 4 {2}
State: 4 State: 4
[0&1&2] 4 {1} [0&1&2] 4 {1}
[0&!1&2] 4 {2} [0&!1&2] 4 {2}
...@@ -980,21 +980,21 @@ name: "(p0 W XXGp0) & G(Fp1 & FGp2)" ...@@ -980,21 +980,21 @@ name: "(p0 W XXGp0) & G(Fp1 & FGp2)"
States: 5 States: 5
Start: 0 Start: 0
AP: 3 "p0" "p1" "p2" AP: 3 "p0" "p1" "p2"
acc-name: parity min odd 4 acc-name: parity min odd 3
Acceptance: 4 Fin(0) & (Inf(1) | (Fin(2) & Inf(3))) Acceptance: 3 Fin(0) & (Inf(1) | Fin(2))
properties: trans-labels explicit-labels trans-acc colored properties: trans-labels explicit-labels trans-acc colored
properties: deterministic properties: deterministic
--BODY-- --BODY--
State: 0 State: 0
[0&!1 | 0&!2] 0 {2} [0&!1 | 0&!2] 0 {2}
[!0] 1 {3} [!0] 1 {2}
[0&1&2] 2 {1} [0&1&2] 2 {1}
State: 1 State: 1
[!1 | !2] 3 {3} [!1 | !2] 3 {2}
[1&2] 4 {3} [1&2] 4 {2}
State: 2 State: 2
[0&!2] 0 {0} [0&!2] 0 {0}
[!0] 1 {3} [!0] 1 {2}
[0&1&2] 2 {1} [0&1&2] 2 {1}
[0&!1&2] 2 {2} [0&!1&2] 2 {2}
State: 3 State: 3
...@@ -1042,21 +1042,21 @@ name: "(p0 W XXGp0) & G(Fp1 & FGp2)" ...@@ -1042,21 +1042,21 @@ name: "(p0 W XXGp0) & G(Fp1 & FGp2)"
States: 5 States: 5
Start: 0 Start: 0
AP: 3 "p0" "p1" "p2" AP: 3 "p0" "p1" "p2"
acc-name: parity min odd 4 acc-name: parity min odd 3
Acceptance: 4 Fin(0) & (Inf(1) | (Fin(2) & Inf(3))) Acceptance: 3 Fin(0) & (Inf(1) | Fin(2))
properties: trans-labels explicit-labels trans-acc colored properties: trans-labels explicit-labels trans-acc colored
properties: deterministic properties: deterministic
--BODY-- --BODY--
State: 0 State: 0
[0&!1 | 0&!2] 0 {2} [0&!1 | 0&!2] 0 {2}
[!0] 1 {3} [!0] 1 {2}
[0&1&2] 2 {1} [0&1&2] 2 {1}
State: 1 State: 1
[!1 | !2] 3 {3} [!1 | !2] 3 {2}
[1&2] 4 {3} [1&2] 4 {2}
State: 2 State: 2
[0&!2] 0 {0} [0&!2] 0 {0}
[!0] 1 {3} [!0] 1 {2}
[0&1&2] 2 {1} [0&1&2] 2 {1}
[0&!1&2] 2 {2} [0&!1&2] 2 {2}
State: 3 State: 3
...@@ -1527,7 +1527,6 @@ ltlcross 'ltl2tgba -P' 'ltl2tgba -P"odd max"' 'ltl2tgba -P"even min"' \ ...@@ -1527,7 +1527,6 @@ ltlcross 'ltl2tgba -P' 'ltl2tgba -P"odd max"' 'ltl2tgba -P"even min"' \
'ltl2tgba -p' 'ltl2tgba -p"odd max"' 'ltl2tgba -p"even min"' \ 'ltl2tgba -p' 'ltl2tgba -p"odd max"' 'ltl2tgba -p"even min"' \
-f FGa -f 'GFa&GFb' -f 'GF(a <-> XXXb)' -f '(p0 W XXGp0) & GFp1 & FGp2' -f FGa -f 'GFa&GFb' -f 'GF(a <-> XXXb)' -f '(p0 W XXGp0) & GFp1 & FGp2'
# Test the behavior of our determinization on Max Michel automata. # Test the behavior of our determinization on Max Michel automata.
# Any change to Spot that lowers the output.states is welcome :-) # Any change to Spot that lowers the output.states is welcome :-)
genaut --m-nba=1..4 | autcross --language-preserved 'autfilt -D' --csv=out.csv genaut --m-nba=1..4 | autcross --language-preserved 'autfilt -D' --csv=out.csv
......
...@@ -240,7 +240,7 @@ ...@@ -240,7 +240,7 @@
"</svg>\n" "</svg>\n"
], ],
"text/plain": [ "text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f55b80ee2a0> >" "<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f52302b76f0> >"
] ]
}, },
"execution_count": 4, "execution_count": 4,
...@@ -352,7 +352,7 @@ ...@@ -352,7 +352,7 @@
"</svg>\n" "</svg>\n"
], ],
"text/plain": [ "text/plain": [
"<spot.twa; proxy of <Swig Object of type 'std::shared_ptr< spot::twa > *' at 0x7f55b8012060> >" "<spot.twa; proxy of <Swig Object of type 'std::shared_ptr< spot::twa > *' at 0x7f523026d2d0> >"
] ]
}, },
"execution_count": 5, "execution_count": 5,
...@@ -462,7 +462,7 @@ ...@@ -462,7 +462,7 @@
"</svg>\n" "</svg>\n"
], ],
"text/plain": [ "text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f55b80ee2a0> >" "<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f52302b76f0> >"
] ]
}, },
"execution_count": 6, "execution_count": 6,
...@@ -695,7 +695,7 @@ ...@@ -695,7 +695,7 @@
"</svg>\n" "</svg>\n"
], ],
"text/plain": [ "text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f55b8012840> >" "<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f523026d540> >"
] ]
}, },
"execution_count": 8, "execution_count": 8,
...@@ -890,7 +890,7 @@ ...@@ -890,7 +890,7 @@
"</svg>\n" "</svg>\n"
], ],
"text/plain": [ "text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f55b8012840> >" "<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f523026d540> >"
] ]
}, },
"execution_count": 11, "execution_count": 11,
...@@ -1228,7 +1228,7 @@ ...@@ -1228,7 +1228,7 @@
"</svg>\n" "</svg>\n"
], ],
"text/plain": [ "text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f55b802f5d0> >" "<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f523026dc30> >"
] ]
}, },
"metadata": {}, "metadata": {},
...@@ -1489,7 +1489,7 @@ ...@@ -1489,7 +1489,7 @@
"</svg>\n" "</svg>\n"
], ],
"text/plain": [ "text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f55b802f5d0> >" "<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f523026dab0> >"
] ]
}, },
"metadata": {}, "metadata": {},
...@@ -1672,7 +1672,7 @@ ...@@ -1672,7 +1672,7 @@
"</svg>\n" "</svg>\n"
], ],
"text/plain": [ "text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f55b802f630> >" "<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f523026d720> >"
] ]
}, },
"metadata": {}, "metadata": {},
...@@ -1789,7 +1789,7 @@ ...@@ -1789,7 +1789,7 @@
"</svg>\n" "</svg>\n"
], ],
"text/plain": [ "text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f55b802f720> >" "<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f523026df60> >"
] ]
}, },
"metadata": {}, "metadata": {},
...@@ -1844,7 +1844,7 @@ ...@@ -1844,7 +1844,7 @@
"</svg>\n" "</svg>\n"
], ],
"text/plain": [ "text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f55b802f3f0> >" "<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f523026de10> >"
] ]
}, },
"metadata": {}, "metadata": {},
...@@ -1938,7 +1938,7 @@ ...@@ -1938,7 +1938,7 @@
"</svg>\n" "</svg>\n"
], ],
"text/plain": [ "text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f55b8089e40> >" "<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f523026d720> >"
] ]
}, },
"execution_count": 14, "execution_count": 14,
...@@ -2067,7 +2067,7 @@ ...@@ -2067,7 +2067,7 @@
"</svg>\n" "</svg>\n"
], ],
"text/plain": [ "text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f55b8089e40> >" "<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f523026d720> >"
] ]
}, },
"metadata": {}, "metadata": {},
...@@ -2132,7 +2132,7 @@ ...@@ -2132,7 +2132,7 @@
"</svg>\n" "</svg>\n"
], ],
"text/plain": [ "text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f55b802f720> >" "<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f523026df60> >"
] ]
}, },
"metadata": {}, "metadata": {},
...@@ -2187,7 +2187,7 @@ ...@@ -2187,7 +2187,7 @@
"</svg>\n" "</svg>\n"
], ],
"text/plain": [ "text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f55b802f3f0> >" "<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f523026de10> >"
] ]
}, },
"metadata": {}, "metadata": {},
...@@ -2418,7 +2418,7 @@ ...@@ -2418,7 +2418,7 @@
"</svg>\n" "</svg>\n"
], ],
"text/plain": [ "text/plain": [
"<spot.impl.twa_product; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_product > *' at 0x7f55b802f360> >" "<spot.impl.twa_product; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_product > *' at 0x7f52302b77b0> >"
] ]
}, },
"metadata": {}, "metadata": {},
...@@ -2503,7 +2503,7 @@ ...@@ -2503,7 +2503,7 @@
"</svg>\n" "</svg>\n"
], ],
"text/plain": [ "text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f55b802f2a0> >" "<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f5230302450> >"
] ]
}, },
"metadata": {}, "metadata": {},
...@@ -2600,7 +2600,7 @@ ...@@ -2600,7 +2600,7 @@
"</svg>\n" "</svg>\n"
], ],
"text/plain": [ "text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f55b802f0f0> >" "<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f523026d9c0> >"
] ]
}, },
"metadata": {}, "metadata": {},
...@@ -2769,7 +2769,7 @@ ...@@ -2769,7 +2769,7 @@
"</svg>\n" "</svg>\n"
], ],
"text/plain": [ "text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f55b802f960> >" "<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f523027d4b0> >"
] ]
}, },
"execution_count": 19, "execution_count": 19,
...@@ -2937,7 +2937,7 @@ ...@@ -2937,7 +2937,7 @@
"</svg>\n" "</svg>\n"
], ],
"text/plain": [ "text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f55b802f960> >" "<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f523027d4b0> >"
] ]
}, },
"execution_count": 20, "execution_count": 20,
...@@ -3100,7 +3100,7 @@ ...@@ -3100,7 +3100,7 @@
"</svg>\n" "</svg>\n"
], ],
"text/plain": [ "text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f55b802f960> >" "<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f523027d4b0> >"
] ]
}, },
"metadata": {}, "metadata": {},
...@@ -3575,7 +3575,7 @@ ...@@ -3575,7 +3575,7 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.7.2+" "version": "3.6.4"
} }
}, },
"nbformat": 4, "nbformat": 4,
......
This diff is collapsed.
#!/usr/bin/python3 #!/usr/bin/python3
# -*- mode: python; coding: utf-8 -*- # -*- mode: python; coding: utf-8 -*-
# Copyright (C) 2018 Laboratoire de Recherche et Développement de # Copyright (C) 2018, 2019 Laboratoire de Recherche et Développement de
# l'EPITA. # l'EPITA.
# #
# This file is part of Spot, a model checking library. # This file is part of Spot, a model checking library.
...@@ -21,47 +21,47 @@ ...@@ -21,47 +21,47 @@
import spot import spot
for f in ('FGa', 'GFa & GFb & FGc', 'XXX(a U b)'): # for f in ('FGa', 'GFa & GFb & FGc', 'XXX(a U b)'):
a1 = spot.translate(f, 'parity') # a1 = spot.translate(f, 'parity')
assert a1.acc().is_parity() # assert a1.acc().is_parity()
a2 = spot.translate(f).postprocess('parity') # a2 = spot.translate(f).postprocess('parity')
assert a2.acc().is_parity() # assert a2.acc().is_parity()
a3 = spot.translate(f, 'det').postprocess('parity', 'colored') # a3 = spot.translate(f, 'det').postprocess('parity', 'colored')
assert a3.acc().is_parity() # assert a3.acc().is_parity()
assert spot.is_colored(a3) # assert spot.is_colored(a3)
#
a = spot.translate('GFa & GFb') # a = spot.translate('GFa & GFb')
try: # try:
spot.change_parity_here(a, spot.parity_kind_same, spot.parity_style_even) # spot.change_parity_here(a, spot.parity_kind_same, spot.parity_style_even)
except RuntimeError as e: # except RuntimeError as e:
assert 'input should have parity acceptance' in str(e) # assert 'input should have parity acceptance' in str(e)
else: # else:
exit(2) # exit(2)
#
a = spot.automaton(""" # a = spot.automaton("""
HOA: v1 # HOA: v1
States: 1 # States: 1
Start: 0 # Start: 0
AP: 1 "a" # AP: 1 "a"
Acceptance: 2 Fin(0) & Inf(1) # Acceptance: 2 Fin(0) & Inf(1)
--BODY-- # --BODY--
State: 0 # State: 0
[t] 0 {0} # [t] 0 {0}
--END-- # --END--
""") # """)
spot.cleanup_parity_here(a) # spot.cleanup_parity_here(a)
assert a.to_str() == """HOA: v1 # assert a.to_str() == """HOA: v1
States: 1 # States: 1
Start: 0 # Start: 0
AP: 1 "a" # AP: 1 "a"
acc-name: none # acc-name: none
Acceptance: 0 f # Acceptance: 0 f
properties: trans-labels explicit-labels state-acc complete # properties: trans-labels explicit-labels state-acc complete
properties: deterministic # properties: deterministic
--BODY-- # --BODY--
State: 0 # State: 0
[t] 0 # [t] 0
--END--""" # --END--"""
a = spot.automaton(""" a = spot.automaton("""
HOA: v1 HOA: v1
...@@ -87,4 +87,3 @@ properties: deterministic ...@@ -87,4 +87,3 @@ properties: deterministic
State: 0 State: 0
[t] 0 [t] 0
--END--""" --END--"""
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