hoa: add option 'b' to build an alias-based basis for all labels

Related to issue #563.

* spot/twaalgos/hoa.hh (create_alias_basis): New function.
* spot/twaalgos/hoa.cc (create_alias_basis): New function.
(print_hoa): Add support for option 'b' and create_alias_basis
in this case.
* bin/common_aoutput.cc, NEWS: Document -Hb.
* tests/core/readsave.test, tests/python/aliases.py: Add test cases.
This commit is contained in:
Alexandre Duret-Lutz 2024-03-22 14:41:42 +01:00
parent 03a4f01184
commit 7e228e86ee
6 changed files with 129 additions and 12 deletions

View file

@ -685,7 +685,7 @@ EOF
diff output2 expect2
SPOT_DEFAULT_FORMAT=hoa=k autfilt expect2 >output2b
SPOT_DEFAULT_FORMAT=hoa=kb autfilt expect2 >output2b
cat >expect2b <<EOF
HOA: v1
@ -695,12 +695,15 @@ AP: 2 "p0" "p1"
acc-name: all
Acceptance: 0 t
properties: state-labels explicit-labels state-acc deterministic weak
Alias: @0 !0&1 | 0&!1
Alias: @1 !0&!1
Alias: @2 !@1&!@0
--BODY--
State: [!0&!1] 0
State: [@1] 0
1
State: [0&1] 1
State: [@2] 1
2
State: [!0&!1] 2
State: [@1] 2
0
--END--
EOF
@ -732,7 +735,7 @@ State: 5
EOF
autfilt -H --remove-unreach input >output3
autfilt -H --remove-dead input >>output3
autfilt -Hb --remove-dead input >>output3
cat >expect3 <<EOF
HOA: v1
@ -759,13 +762,16 @@ AP: 2 "p0" "p1"
acc-name: all
Acceptance: 0 t
properties: trans-labels explicit-labels state-acc deterministic weak
Alias: @0 !0&1 | 0&!1
Alias: @1 !0&!1
Alias: @2 !@1&!@0
--BODY--
State: 0
[!0&!1] 1
[@1] 1
State: 1
[0&1] 2
[@2] 2
State: 2
[!0&!1] 0
[@1] 0
--END--
EOF

View file

@ -108,6 +108,51 @@ State: 0
[@p0&2 | @p1&2] 0
--END--""")
s2b = aut.to_str('hoa', 'b')
tc.assertTrue(spot.are_equivalent(aut, spot.automaton(s2b)))
tc.assertEqual(s2b, """HOA: v1
States: 1
Start: 0
AP: 3 "x" "y" "z"
acc-name: all
Acceptance: 0 t
properties: trans-labels explicit-labels state-acc complete very-weak
Alias: @0 !0&!1&!2
Alias: @1 0&!1&!2
Alias: @2 !0&1&!2
Alias: @3 0&1&!2
Alias: @4 !0&!1&2
Alias: @5 0&1&2
Alias: @6 0&!1&2
Alias: @7 !@6&!@5&!@4&!@3&!@2&!@1&!@0
--BODY--
State: 0
[@6 | @5 | @3 | @1] 0
[@7 | @4 | @2 | @0] 0
[@7 | @5 | @3 | @2] 0
[@6 | @4 | @1 | @0] 0
[@4 | @0] 0
[@7 | @6 | @5 | @3 | @2 | @1] 0
[@7 | @2] 0
[@6 | @5 | @4 | @3 | @1 | @0] 0
[@6 | @1] 0
[@7 | @5 | @4 | @3 | @2 | @0] 0
[@7 | @4 | @2 | @0] 0
[@6 | @4 | @1 | @0] 0
[@7 | @6 | @2 | @1] 0
[@7 | @6 | @4 | @2 | @1 | @0] 0
[t] 0
[t] 0
[t] 0
[@5 | @3] 0
[@6 | @5 | @3 | @1] 0
[@7 | @5 | @3 | @2] 0
[@5 | @4 | @3 | @0] 0
[@5 | @4] 0
[@4] 0
[@7 | @6 | @5] 0
--END--""")
# Check what happens to aliases when an AP has been removed, but
# the aliases have been preserved...
rem = spot.remove_ap()