Commit 06d3bc67 authored by Alexandre Duret-Lutz's avatar Alexandre Duret-Lutz

restructure the complementation code

The previous code was sometime doing the work of remove_fin() in
addition to complementing the acceptance conditions.  This separate
the two operations clearly.  Also the specialized code for
complementing weak automata is now a specialized code for remove_fin()
on weak automata.

* src/twaalgos/dtgbacomp.hh, src/twaalgos/dtgbacomp.cc: Rename as ...
* src/twaalgos/complement.hh, src/twaalgos/complement.cc: ... these.
* src/twaalgos/Makefile.am: Adjust.
* src/twaalgos/complement.hh (dtgba_complement): Rename as ...
(dtwa_complement): ... this, and restrict the purpose to completion
and accetance complementation.  Further acceptance simplification
can be done with remove_fin() and to_generalized_buchi().
* src/twaalgos/remfin.cc (remove_fin): Specialize handling of weak
automata using the code that was originally in dtgba_complement().
Also mark the output as state-based when the input has to Inf.
* src/twaalgos/postproc.cc, src/twaalgos/postproc.hh: Make sure
scc_filter is always called after to_generalized_buchi().
* bench/stutter/stutter_invariance_randomgraph.cc,
src/bin/ltlcross.cc, src/tests/ikwiad.cc, src/twaalgos/minimize.cc,
src/twaalgos/powerset.cc, src/twaalgos/stutter.cc: Adjust usage.
* src/tests/dstar.test, src/tests/ltl2dstar4.test,
src/tests/remfin.test: Adjust expected outputs.
* wrap/python/spot_impl.i: Export dtwa_complement().
parent fb642c6d
New in spot 1.99.4a (not yet released) New in spot 1.99.4a (not yet released)
* Rename dtgba_complement() as dtwa_complement(), rename the header
as complement.hh, and restrict the purpose of this function to
just complete the automaton and complement its acceptance
condition. Any further acceptance condition transformation
can be done with to_generalized_buchi() or remove_fin().
* The remove_fin() has learnt how to better deal with automata that
are declared as weak. This code was previously in
dtgba_complement().
Python: Python:
* Add bindings for complete(). * Add bindings for complete() and dtwa_complement()
* Formulas now have a custom __format__ function. See * Formulas now have a custom __format__ function. See
https://spot.lrde.epita.fr/tut01.html for examples. https://spot.lrde.epita.fr/tut01.html for examples.
......
...@@ -19,7 +19,8 @@ ...@@ -19,7 +19,8 @@
#include "misc/timer.hh" #include "misc/timer.hh"
#include "tl/apcollect.hh" #include "tl/apcollect.hh"
#include "twaalgos/dtgbacomp.hh" #include "twaalgos/complement.hh"
#include "twaalgos/remfin.hh"
#include "twaalgos/randomgraph.hh" #include "twaalgos/randomgraph.hh"
#include "twaalgos/dot.hh" #include "twaalgos/dot.hh"
#include "twaalgos/product.hh" #include "twaalgos/product.hh"
...@@ -80,7 +81,7 @@ main(int argc, char** argv) ...@@ -80,7 +81,7 @@ main(int argc, char** argv)
true); true);
} }
while (a->is_empty()); while (a->is_empty());
auto na = spot::dtgba_complement(a); auto na = spot::remove_fin(spot::dtwa_complement(a));
std::cout << d << ',' << props_n << ',' << seed; std::cout << d << ',' << props_n << ',' << seed;
stats.print(a); stats.print(a);
......
...@@ -53,7 +53,7 @@ ...@@ -53,7 +53,7 @@
#include "twaalgos/isweakscc.hh" #include "twaalgos/isweakscc.hh"
#include "twaalgos/reducerun.hh" #include "twaalgos/reducerun.hh"
#include "twaalgos/word.hh" #include "twaalgos/word.hh"
#include "twaalgos/dtgbacomp.hh" #include "twaalgos/complement.hh"
#include "twaalgos/cleanacc.hh" #include "twaalgos/cleanacc.hh"
#include "misc/formater.hh" #include "misc/formater.hh"
#include "twaalgos/stats.hh" #include "twaalgos/stats.hh"
...@@ -1016,7 +1016,7 @@ namespace ...@@ -1016,7 +1016,7 @@ namespace
if (!no_complement && pos[n] if (!no_complement && pos[n]
&& ((want_stats && !(*pstats)[n].nondeterministic) && ((want_stats && !(*pstats)[n].nondeterministic)
|| (!want_stats && is_deterministic(pos[n])))) || (!want_stats && is_deterministic(pos[n]))))
comp_pos[n] = dtgba_complement(pos[n]); comp_pos[n] = dtwa_complement(pos[n]);
} }
// ---------- Negative Formula ---------- // ---------- Negative Formula ----------
...@@ -1056,7 +1056,7 @@ namespace ...@@ -1056,7 +1056,7 @@ namespace
if (!no_complement && neg[n] if (!no_complement && neg[n]
&& ((want_stats && !(*nstats)[n].nondeterministic) && ((want_stats && !(*nstats)[n].nondeterministic)
|| (!want_stats && is_deterministic(neg[n])))) || (!want_stats && is_deterministic(neg[n]))))
comp_neg[n] = dtgba_complement(neg[n]); comp_neg[n] = dtwa_complement(neg[n]);
} }
} }
......
...@@ -244,7 +244,7 @@ digraph G { ...@@ -244,7 +244,7 @@ digraph G {
node [shape="circle"] node [shape="circle"]
I [label="", style=invis, width=0] I [label="", style=invis, width=0]
I -> 0 I -> 0
0 [label="0"] 0 [label="0", peripheries=2]
0 -> 1 [label="!a & !b"] 0 -> 1 [label="!a & !b"]
0 -> 2 [label="a & !b"] 0 -> 2 [label="a & !b"]
1 [label="1", peripheries=2] 1 [label="1", peripheries=2]
......
...@@ -60,7 +60,8 @@ ...@@ -60,7 +60,8 @@
#include "twaalgos/simulation.hh" #include "twaalgos/simulation.hh"
#include "twaalgos/compsusp.hh" #include "twaalgos/compsusp.hh"
#include "twaalgos/powerset.hh" #include "twaalgos/powerset.hh"
#include "twaalgos/dtgbacomp.hh" #include "twaalgos/complement.hh"
#include "twaalgos/remfin.hh"
#include "twaalgos/complete.hh" #include "twaalgos/complete.hh"
#include "twaalgos/dtbasat.hh" #include "twaalgos/dtbasat.hh"
#include "twaalgos/dtgbasat.hh" #include "twaalgos/dtgbasat.hh"
...@@ -338,7 +339,7 @@ checked_main(int argc, char** argv) ...@@ -338,7 +339,7 @@ checked_main(int argc, char** argv)
bool opt_determinize = false; bool opt_determinize = false;
unsigned opt_determinize_threshold = 0; unsigned opt_determinize_threshold = 0;
unsigned opt_o_threshold = 0; unsigned opt_o_threshold = 0;
bool opt_dtgbacomp = false; bool opt_dtwacomp = false;
bool reject_bigger = false; bool reject_bigger = false;
bool opt_monitor = false; bool opt_monitor = false;
bool containment = false; bool containment = false;
...@@ -411,7 +412,7 @@ checked_main(int argc, char** argv) ...@@ -411,7 +412,7 @@ checked_main(int argc, char** argv)
} }
else if (!strcmp(argv[formula_index], "-DC")) else if (!strcmp(argv[formula_index], "-DC"))
{ {
opt_dtgbacomp = true; opt_dtwacomp = true;
} }
else if (!strncmp(argv[formula_index], "-DS", 3) else if (!strncmp(argv[formula_index], "-DS", 3)
|| !strncmp(argv[formula_index], "-DT", 3)) || !strncmp(argv[formula_index], "-DT", 3))
...@@ -1203,14 +1204,14 @@ checked_main(int argc, char** argv) ...@@ -1203,14 +1204,14 @@ checked_main(int argc, char** argv)
a = satminimized; a = satminimized;
} }
if (opt_dtgbacomp) if (opt_dtwacomp)
{ {
tm.start("DTGBA complement"); tm.start("DTωA complement");
a = dtgba_complement(ensure_digraph(a)); a = remove_fin(dtwa_complement(ensure_digraph(a)));
tm.stop("DTGBA complement"); tm.stop("DTωA complement");
} }
if (opt_determinize || opt_dtgbacomp || opt_dtbasat >= 0 if (opt_determinize || opt_dtwacomp || opt_dtbasat >= 0
|| opt_dtgbasat >= 0) || opt_dtgbasat >= 0)
{ {
if (scc_filter && (reduction_dir_sim || reduction_rev_sim)) if (scc_filter && (reduction_dir_sim || reduction_rev_sim))
......
...@@ -41,13 +41,13 @@ $ltlfilt -f '(GFa -> GFb) & (GFc -> GFd)' -l | ...@@ -41,13 +41,13 @@ $ltlfilt -f '(GFa -> GFb) & (GFc -> GFd)' -l |
ltl2dstar --ltl2nba=spin:$ltl2tgba@-s $STR - - | ltl2dstar --ltl2nba=spin:$ltl2tgba@-s $STR - - |
$autfilt --tgba --stats '%S %E %A %s %e %t %a %d' | $autfilt --tgba --stats '%S %E %A %s %e %t %a %d' |
tee out tee out
test "`cat out`" = '9 144 4 25 416 416 2 0' test "`cat out`" = '9 144 4 25 149 416 2 0'
$ltlfilt -f '(GFa -> GFb) & (GFc -> GFd)' -l | $ltlfilt -f '(GFa -> GFb) & (GFc -> GFd)' -l |
ltl2dstar --ltl2nba=spin:$ltl2tgba@-s $STR - - | ltl2dstar --ltl2nba=spin:$ltl2tgba@-s $STR - - |
SPOT_STREETT_CONV_MIN=1 $autfilt --tgba --stats '%S %E %A %s %e %t %a %d' | SPOT_STREETT_CONV_MIN=1 $autfilt --tgba --stats '%S %E %A %s %e %t %a %d' |
tee out tee out
test "`cat out`" = '9 144 4 25 482 482 2 0' test "`cat out`" = '9 144 4 25 218 482 2 0'
LTL2DSTAR="ltl2dstar $STR --ltl2nba=spin:$ltl2tgba@-s %L" LTL2DSTAR="ltl2dstar $STR --ltl2nba=spin:$ltl2tgba@-s %L"
......
...@@ -218,20 +218,13 @@ Acceptance: 1 Inf(0) ...@@ -218,20 +218,13 @@ Acceptance: 1 Inf(0)
properties: trans-labels explicit-labels state-acc properties: trans-labels explicit-labels state-acc
--BODY-- --BODY--
State: 0 State: 0
[0&1] 0 [t] 0
[!0&!1] 0 [!0] 1
[!0&1] 0 [!1] 2
[0&!1] 0
[!0&!1] 1
[!0&1] 1
[!0&!1] 2
[0&!1] 2
State: 1 {0} State: 1 {0}
[!0&!1] 1 [!0] 1
[!0&1] 1
State: 2 {0} State: 2 {0}
[!0&!1] 2 [!1] 2
[0&!1] 2
--END-- --END--
HOA: v1 HOA: v1
States: 4 States: 4
...@@ -275,7 +268,7 @@ State: 2 ...@@ -275,7 +268,7 @@ State: 2
[!1] 0 [!1] 0
[0&!1] 1 {0} [0&!1] 1 {0}
[!0&!1] 2 {0} [!0&!1] 2 {0}
[!0&!1] 3 {0} [!0&!1] 3
State: 3 State: 3
[!0&!1] 3 {0 1 4} [!0&!1] 3 {0 1 4}
--END-- --END--
...@@ -325,31 +318,30 @@ Acceptance: 2 Inf(1) | Inf(0) ...@@ -325,31 +318,30 @@ Acceptance: 2 Inf(1) | Inf(0)
properties: trans-labels explicit-labels state-acc properties: trans-labels explicit-labels state-acc
--BODY-- --BODY--
State: 0 State: 0
[!0] 6
[0] 0 [0] 0
[!0] 6
[0] 8 [0] 8
[0] 9 [0] 9
State: 1 {0 1} State: 1 {0 1}
[!0] 3 [t] 3
[0] 3
State: 2 {0 1} State: 2 {0 1}
[!0] 5
[0] 1 [0] 1
[!0] 5
State: 3 {0 1} State: 3 {0 1}
[!0] 6
[0] 0 [0] 0
State: 4 {0 1}
[!0] 6 [!0] 6
State: 4 {0 1}
[0] 4 [0] 4
[!0] 6
State: 5 {0 1} State: 5 {0 1}
[!0] 7
[0] 3 [0] 3
[!0] 7
State: 6 State: 6
[!0] 6
[0] 0 [0] 0
State: 7 {1}
[!0] 6 [!0] 6
State: 7 {1}
[0] 4 [0] 4
[!0] 6
State: 8 State: 8
[0] 8 [0] 8
State: 9 {1} State: 9 {1}
...@@ -547,68 +539,61 @@ Acceptance: 1 Inf(0) ...@@ -547,68 +539,61 @@ Acceptance: 1 Inf(0)
properties: trans-labels explicit-labels state-acc properties: trans-labels explicit-labels state-acc
--BODY-- --BODY--
State: 0 State: 0
[0&1] 0 [t] 0
[!0&!1] 0 [!0] 1
[!0&1] 0 [!1] 2
[0&!1] 0
[!0&!1] 1
[!0&1] 1
[!0&!1] 2
[0&!1] 2
State: 1 {0} State: 1 {0}
[!0&!1] 1 [!0] 1
[!0&1] 1
State: 2 {0} State: 2 {0}
[!0&!1] 2 [!1] 2
[0&!1] 2
--END-- --END--
HOA: v1 HOA: v1
States: 4 States: 4
Start: 0 Start: 0
AP: 2 "a" "b" AP: 2 "a" "b"
acc-name: generalized-Buchi 2 acc-name: Buchi
Acceptance: 2 Inf(0)&Inf(1) Acceptance: 1 Inf(0)
properties: trans-labels explicit-labels trans-acc properties: trans-labels explicit-labels trans-acc
--BODY-- --BODY--
State: 0 State: 0
[t] 0 {0 1} [t] 0 {0}
[0] 1 {0 1} [0] 1 {0}
[!0] 2 {0 1} [!0] 2 {0}
State: 1 State: 1
[1] 0 {1} [1] 0
[0&1] 1 {1} [0&1] 1
[!0&1] 2 {0 1} [!0&1] 2 {0}
State: 2 State: 2
[!1] 0 [!1] 0
[0&!1] 1 [0&!1] 1
[!0&!1] 2 [!0&!1] 2
[!0&!1] 3 [!0&!1] 3
State: 3 State: 3
[!0&!1] 3 {0 1} [!0&!1] 3 {0}
--END-- --END--
HOA: v1 HOA: v1
States: 4 States: 4
Start: 0 Start: 0
AP: 2 "a" "b" AP: 2 "a" "b"
acc-name: generalized-Buchi 2 acc-name: Buchi
Acceptance: 2 Inf(0)&Inf(1) Acceptance: 1 Inf(0)
properties: trans-labels explicit-labels trans-acc properties: trans-labels explicit-labels trans-acc
--BODY-- --BODY--
State: 0 State: 0
[t] 0 {1} [t] 0
[0] 1 {1} [0] 1
[!0] 2 {0 1} [!0] 2 {0}
State: 1 State: 1
[1] 0 {1} [1] 0
[0&1] 1 {0 1} [0&1] 1 {0}
[!0&1] 2 {0 1} [!0&1] 2 {0}
State: 2 State: 2
[!1] 0 [!1] 0
[0&!1] 1 {0 1} [0&!1] 1 {0}
[!0&!1] 2 {0 1} [!0&!1] 2 {0}
[!0&!1] 3 {0 1} [!0&!1] 3
State: 3 State: 3
[!0&!1] 3 {0 1} [!0&!1] 3 {0}
--END-- --END--
HOA: v1 HOA: v1
States: 1 States: 1
...@@ -646,47 +631,42 @@ State: 0 ...@@ -646,47 +631,42 @@ State: 0
[!0] 0 [!0] 0
[0] 1 [0] 1
State: 1 {0} State: 1 {0}
[!0] 1 [t] 1
[0] 1
--END-- --END--
HOA: v1 HOA: v1
States: 10 States: 9
Start: 2 Start: 2
AP: 1 "p1" AP: 1 "p1"
acc-name: Buchi acc-name: Buchi
Acceptance: 1 Inf(0) Acceptance: 1 Inf(0)
properties: trans-labels explicit-labels state-acc properties: trans-labels explicit-labels trans-acc
--BODY-- --BODY--
State: 0 State: 0
[!0] 6
[0] 0 [0] 0
[!0] 6
[0] 8 [0] 8
[0] 9 State: 1
State: 1 {0} [t] 3
[!0] 3 State: 2
[0] 3
State: 2 {0}
[!0] 5
[0] 1 [0] 1
State: 3 {0} [!0] 5
[!0] 6 State: 3
[0] 0 [0] 0
State: 4 {0}
[!0] 6 [!0] 6
[0] 4 State: 4
State: 5 {0} [0] 4 {0}
[!0] 7 [!0] 6
State: 5
[0] 3 [0] 3
[!0] 7
State: 6 State: 6
[!0] 6
[0] 0 [0] 0
State: 7 {0}
[!0] 6 [!0] 6
[0] 4 State: 7
[0] 4 {0}
[!0] 6
State: 8 State: 8
[0] 8 [0] 8 {0}
State: 9 {0}
[0] 9
--END-- --END--
HOA: v1 HOA: v1
States: 15 States: 15
...@@ -694,83 +674,75 @@ Start: 13 ...@@ -694,83 +674,75 @@ Start: 13
AP: 2 "p1" "p0" AP: 2 "p1" "p0"
acc-name: Buchi acc-name: Buchi
Acceptance: 1 Inf(0) Acceptance: 1 Inf(0)
properties: trans-labels explicit-labels state-acc properties: trans-labels explicit-labels trans-acc
--BODY-- --BODY--
State: 0 {0} State: 0
[0&1] 0 {0}
[!0&1] 1 {0}
[0&!1] 11 {0}
[!0&!1] 12 [!0&!1] 12
[0&!1] 11 State: 1
[!0&1] 1 [0&1] 0 {0}
[0&1] 0 [!0&1] 1 {0}
State: 1 {0} [0&!1] 11 {0}
[!0&!1] 12 [!0&!1] 12
[0&!1] 11 State: 2
[!0&1] 1 [!0&1] 2 {0}
[0&1] 0
State: 2 {0}
[!0&!1] 10
[0&!1] 11
[!0&1] 2
[0&1] 9 [0&1] 9
State: 3 {0} [!0&!1] 10 {0}
[!0&!1] 12 [0&!1] 11 {0}
[0&!1] 11 State: 3
[!0&1] 1 [!0&1] 1 {0}
[0&1] 3 [0&1] 3 {0}
State: 4 {0} [0&!1] 11 {0}
[!0&!1] 12 [!0&!1] 12
[0&!1] 12 State: 4
[!0&1] 4 [!0&1] 4 {0}
[0&1] 7 [0&1] 7 {0}
State: 5 {0} [!1] 12
[!0&!1] 10 State: 5
[0&!1] 12 [!0&1] 5 {0}
[!0&1] 5
[0&1] 8 [0&1] 8
State: 6 {0} [!0&!1] 10 {0}
[!0&!1] 12
[0&!1] 11
[!0&1] 4
[0&1] 6
State: 7 {0}
[!0&!1] 12
[0&!1] 12 [0&!1] 12
[!0&1] 4 State: 6
[0&1] 7 [!0&1] 4 {0}
State: 8 [0&1] 6 {0}
[0&!1] 11 {0}
[!0&!1] 12 [!0&!1] 12
[0&!1] 12 State: 7
[!0&1] 8 [!0&1] 4 {0}
[0&1] 8 [0&1] 7 {0}
[!0&1] 14 [!1] 12
[0&1] 14 State: 8
[1] 8
[!1] 12
[1] 14
State: 9 State: 9
[!0&!1] 12
[0&!1] 11
[!0&1] 1 [!0&1] 1
[0&1] 3 [0&1] 3
State: 10 {0}
[!0&!1] 10
[0&!1] 12