spot/src/tests/remfin.test
Alexandre Duret-Lutz 06d3bc67ea 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().
2015-10-13 22:34:02 +02:00

827 lines
12 KiB
Bash
Executable file

#!/bin/sh
# -*- coding: utf-8 -*-
# Copyright (C) 2015 Laboratoire de Recherche et Développement
# de l'Epita (LRDE).
#
# This file is part of Spot, a model checking library.
#
# Spot is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# Spot is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
# License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
. ./defs
set -e
autfilt=../../bin/autfilt
cat >test1 <<EOF
/*
** This was a TGBA for GFa & GFb, but
** the acceptance has been changed to Fin(0)|Fin(1)
** so this is now the complement automaton.
*/
HOA: v1
States: 1
Start: 0
AP: 2 "a" "b"
Acceptance: 2 Fin(0)|Fin(1)
--BODY--
State: 0
[0&1] 0 {0 1}
[!0&!1] 0
[!0&1] 0 {1}
[0&!1] 0 {0}
--END--
/*
** This one has a mix of Inf and Fin acceptance, but no interference
** between the Fin sets
*/
HOA: v1
States: 3
Start: 0
AP: 2 "a" "b"
Acceptance: 5 Inf(0)&Fin(1)&Fin(3) | Inf(2)&Inf(3) | Inf(4)
--BODY--
State: 0 {3 4}
[t] 0
[0] 1 {1}
[!0] 2 {0}
State: 1 {3}
[1] 0
[0&1] 1 {0}
[!0&1] 2 {2}
State: 2
[!1] 0
[0&!1] 1 {0}
[!0&!1] 2 {0}
--END--
/*
** This one is similar, but Inf(0) is used in two terms, so
** we need to introduce extra sets in the output.
*/
HOA: v1
States: 3
Start: 0
AP: 2 "a" "b"
acc-name: Buchi
Acceptance: 4 Inf(0)&Fin(1)&Fin(3) | Inf(2)&Inf(3) | Inf(0)
--BODY--
State: 0 {3}
[t] 0
[0] 1 {1}
[!0] 2 {0}
State: 1 {3}
[1] 0
[0&1] 1 {0}
[!0&1] 2 {2}
State: 2
[!1] 0
[0&!1] 1 {0}
[!0&!1] 2 {0}
--END--
/*
** The t and f acceptance.
*/
HOA: v1
States: 1
Start: 0
Acceptance: 0 f
--BODY--
State: 0
--END--
HOA: v1
States: 1
Start: 0
Acceptance: 0 t
--BODY--
State: 0
[t] 0
--END--
/* An example from ltl2dstar.
** No new state should be added.
*/
HOA: v1
States: 2
acc-name: Rabin 1
Acceptance: 2 (Fin(0)&Inf(1))
Start: 0
AP: 1 "p0"
--BODY--
State: 0 {}
0
1
State: 1 {1}
1
1
--END--
HOA: v1
States: 8
Start: 2
AP: 1 "p1"
Acceptance: 4 (Fin(3) & Inf(0)) | (Fin(1) & Fin(3)) |
(Fin(1) & Inf(2)) | (Inf(0)&Inf(2))
properties: trans-labels explicit-labels state-acc complete deterministic
--BODY--
State: 0
[!0] 6
[0] 0
State: 1 {2}
[!0] 3
[0] 3
State: 2 {2}
[!0] 5
[0] 1
State: 3 {2}
[!0] 6
[0] 0
State: 4 {2}
[!0] 6
[0] 4
State: 5 {2}
[!0] 7
[0] 3
State: 6 {1 2}
[!0] 6
[0] 0
State: 7 {3}
[!0] 6
[0] 4
--END--
/* echo 'i F ^ F p1 U p0 V G p0 p1 F V f p0' | ltl2dstar -H - - | fmt */
HOA: v1 States: 14 properties: implicit-labels
trans-labels no-univ-branch deterministic complete comment:
"Union{Safra[NBA=9],Safra[NBA=2]}" acc-name: Rabin 5 Acceptance: 10
(Fin(0)&Inf(1))|(Fin(2)&Inf(3))|(Fin(4)&Inf(5))|(Fin(6)&Inf(7))|(Fin(8)&Inf(9))
Start: 13 AP: 2 "p1" "p0" --BODY-- State: 0 {3 4 7 9} 12 11 1 0 State:
1 {5 6 9} 12 11 1 0 State: 2 {3 4 6 9} 10 11 2 9 State: 3 {3 4 6 9}
12 11 1 3 State: 4 {3 4 6 9} 12 12 4 7 State: 5 {1 2 4 6 9} 10 12 5 8
State: 6 {1 2 4 6 9} 12 11 4 6 State: 7 {1 2 4 6 9} 12 12 4 7 State:
8 {0 2 4 6 9} 12 12 8 8 State: 9 {2 4 6 9} 12 11 1 3 State: 10 {1 2 4
6 8} 10 12 5 8 State: 11 {1 2 4 6 8} 12 11 8 6 State: 12 {0 2 4 6 8}
12 12 8 8 State: 13 {2 4 6 8} 10 11 2 3 --END--
/* ltlfilt -l -f '(F((p1) R (p0))) | (G(F(p0)))' | ltl2dstar -H - - |
./autfilt --merge -H | fmt
This one is DBA-type, however because some unused acceptance sets are
removed before calling remfin(), that function could miss the fact
that this was a Rabin automaton...
*/
HOA: v1 States: 4 Start: 0 AP: 2 "p1" "p0" acc-name: Rabin 3 Acceptance:
6 (Fin(0) & Inf(1)) | (Fin(2) & Inf(3)) | (Fin(4) & Inf(5)) properties:
trans-labels explicit-labels state-acc complete deterministic --BODY--
State: 0 {2} [!1] 0 [0&1] 2 [!0&1] 3 State: 1 {1 2} [!1] 1 [1] 2 State:
2 {1 2 5} [!1] 1 [1] 2 State: 3 {3 5} [!1] 0 [0&1] 2 [!0&1] 3 --END--
/*
ltlfilt -f '(X((X(p0)) R ((!(p1)) | (X(p0)))))' -l |
ltl2dstar --automata=streett -H --ltl2nba=spin:ltl2tgba@-s - - |
fmt
This Streett automaton can be seen as a Rabin-like automaton with
two pairs. So the BA-type check should apply. During testing, it
triggered assertions.
*/
HOA: v1 States: 6 properties: implicit-labels trans-labels no-univ-branch
deterministic complete comment: "Streett{Safra[NBA=5]}" acc-name: Streett
1 Acceptance: 2 (Fin(0)|Inf(1)) Start: 5 AP: 2 "p0" "p1" --BODY-- State:
0 {0} 0 0 0 0 State: 1 {0} 0 2 0 2 State: 2 {1} 2 2 2 2 State: 3 {}
3 2 1 2 State: 4 {} 3 3 1 1 State: 5 {} 4 4 4 4 --END--
/*
ltlfilt -l -f '(F(!((1) U (!((G(p0)) -> (p1))))))' | ltl2dstar -H - - | fmt
This Rabin automaton was incorrectly reduced at some point.
*/
HOA: v1 States: 4 properties: implicit-labels trans-labels no-univ-branch
deterministic complete stutter-insensitive comment: "Safra[NBA=3]"
acc-name: Rabin 2 Acceptance: 4 (Fin(0)&Inf(1))|(Fin(2)&Inf(3)) Start:
1 AP: 2 "p0" "p1" --BODY-- State: 0 {2} 2 0 2 3 State: 1 {0 2} 2 1 2 2
State: 2 {1 2} 2 0 2 2 State: 3 {3} 2 0 2 3 --END--
EOF
cat >expected <<EOF
HOA: v1
States: 3
Start: 0
AP: 2 "a" "b"
acc-name: Buchi
Acceptance: 1 Inf(0)
properties: trans-labels explicit-labels state-acc
--BODY--
State: 0
[t] 0
[!0] 1
[!1] 2
State: 1 {0}
[!0] 1
State: 2 {0}
[!1] 2
--END--
HOA: v1
States: 4
Start: 0
AP: 2 "a" "b"
Acceptance: 4 Inf(0) | Inf(3) | (Inf(1)&Inf(2))
properties: trans-labels explicit-labels trans-acc
--BODY--
State: 0
[t] 0 {2 3}
[0] 1 {2 3}
[!0] 2 {2 3}
State: 1
[1] 0 {2}
[0&1] 1 {2}
[!0&1] 2 {1 2}
State: 2
[!1] 0
[0&!1] 1
[!0&!1] 2
[!0&!1] 3
State: 3
[!0&!1] 3 {0}
--END--
HOA: v1
States: 4
Start: 0
AP: 2 "a" "b"
Acceptance: 5 (Inf(0)&Inf(1)&Inf(4)) | Inf(0) | (Inf(2)&Inf(3))
properties: trans-labels explicit-labels trans-acc
--BODY--
State: 0
[t] 0 {3}
[0] 1 {3}
[!0] 2 {0 3}
State: 1
[1] 0 {3}
[0&1] 1 {0 3}
[!0&1] 2 {2 3}
State: 2
[!1] 0
[0&!1] 1 {0}
[!0&!1] 2 {0}
[!0&!1] 3
State: 3
[!0&!1] 3 {0 1 4}
--END--
HOA: v1
States: 1
Start: 0
AP: 0
acc-name: none
Acceptance: 0 f
properties: trans-labels explicit-labels state-acc deterministic
--BODY--
State: 0
--END--
HOA: v1
States: 1
Start: 0
AP: 0
acc-name: all
Acceptance: 0 t
properties: trans-labels explicit-labels state-acc complete
properties: deterministic
--BODY--
State: 0
[t] 0
--END--
HOA: v1
States: 2
Start: 0
AP: 1 "p0"
acc-name: Buchi
Acceptance: 1 Inf(0)
properties: trans-labels explicit-labels state-acc complete
properties: deterministic
--BODY--
State: 0
[!0] 0
[0] 1
State: 1 {0}
[!0] 1
[0] 1
--END--
HOA: v1
States: 10
Start: 2
AP: 1 "p1"
Acceptance: 2 Inf(1) | Inf(0)
properties: trans-labels explicit-labels state-acc
--BODY--
State: 0
[0] 0
[!0] 6
[0] 8
[0] 9
State: 1 {0 1}
[t] 3
State: 2 {0 1}
[0] 1
[!0] 5
State: 3 {0 1}
[0] 0
[!0] 6
State: 4 {0 1}
[0] 4
[!0] 6
State: 5 {0 1}
[0] 3
[!0] 7
State: 6
[0] 0
[!0] 6
State: 7 {1}
[0] 4
[!0] 6
State: 8
[0] 8
State: 9 {1}
[0] 9
--END--
HOA: v1
States: 15
Start: 13
AP: 2 "p1" "p0"
acc-name: Buchi
Acceptance: 1 Inf(0)
properties: trans-labels explicit-labels state-acc
--BODY--
State: 0 {0}
[!0&!1] 12
[0&!1] 11
[!0&1] 1
[0&1] 0
State: 1 {0}
[!0&!1] 12
[0&!1] 11
[!0&1] 1
[0&1] 0
State: 2 {0}
[!0&!1] 10
[0&!1] 11
[!0&1] 2
[0&1] 9
State: 3 {0}
[!0&!1] 12
[0&!1] 11
[!0&1] 1
[0&1] 3
State: 4 {0}
[!0&!1] 12
[0&!1] 12
[!0&1] 4
[0&1] 7
State: 5 {0}
[!0&!1] 10
[0&!1] 12
[!0&1] 5
[0&1] 8
State: 6 {0}
[!0&!1] 12
[0&!1] 11
[!0&1] 4
[0&1] 6
State: 7 {0}
[!0&!1] 12
[0&!1] 12
[!0&1] 4
[0&1] 7
State: 8
[!0&!1] 12
[0&!1] 12
[!0&1] 8
[0&1] 8
[!0&1] 14
[0&1] 14
State: 9
[!0&!1] 12
[0&!1] 11
[!0&1] 1
[0&1] 3
State: 10 {0}
[!0&!1] 10
[0&!1] 12
[!0&1] 5
[0&1] 8
State: 11 {0}
[!0&!1] 12
[0&!1] 11
[!0&1] 8
[0&1] 6
State: 12
[!0&!1] 12
[0&!1] 12
[!0&1] 8
[0&1] 8
State: 13
[!0&!1] 10
[0&!1] 11
[!0&1] 2
[0&1] 3
State: 14 {0}
[!0&1] 14
[0&1] 14
--END--
HOA: v1
States: 4
Start: 0
AP: 2 "p1" "p0"
acc-name: Buchi
Acceptance: 1 Inf(0)
properties: trans-labels explicit-labels state-acc complete
properties: deterministic
--BODY--
State: 0
[!1] 0
[0&1] 2
[!0&1] 3
State: 1 {0}
[!1] 1
[1] 2
State: 2 {0}
[!1] 1
[1] 2
State: 3 {0}
[!1] 0
[0&1] 2
[!0&1] 3
--END--
HOA: v1
States: 6
Start: 5
AP: 2 "p0" "p1"
acc-name: Buchi
Acceptance: 1 Inf(0)
properties: trans-labels explicit-labels state-acc complete
properties: deterministic
--BODY--
State: 0
[!0&!1] 0
[0&!1] 0
[!0&1] 0
[0&1] 0
State: 1
[!0&!1] 0
[0&!1] 2
[!0&1] 0
[0&1] 2
State: 2 {0}
[!0&!1] 2
[0&!1] 2
[!0&1] 2
[0&1] 2
State: 3 {0}
[!0&!1] 3
[0&!1] 2
[!0&1] 1
[0&1] 2
State: 4
[!0&!1] 3
[0&!1] 3
[!0&1] 1
[0&1] 1
State: 5
[!0&!1] 4
[0&!1] 4
[!0&1] 4
[0&1] 4
--END--
HOA: v1
States: 5
Start: 1
AP: 2 "p0" "p1"
acc-name: Buchi
Acceptance: 1 Inf(0)
properties: trans-labels explicit-labels state-acc
--BODY--
State: 0
[!0&!1] 2
[0&!1] 0
[!0&1] 2
[0&1] 3
State: 1
[!0&!1] 2
[0&!1] 1
[!0&1] 2
[0&1] 2
State: 2 {0}
[!0&!1] 2
[0&!1] 0
[!0&1] 2
[0&1] 2
State: 3
[!0&!1] 2
[0&!1] 0
[!0&1] 2
[0&1] 3
[0&1] 4
State: 4 {0}
[0&1] 4
--END--
EOF
cat >expected-tgba <<EOF
HOA: v1
States: 3
Start: 0
AP: 2 "a" "b"
acc-name: Buchi
Acceptance: 1 Inf(0)
properties: trans-labels explicit-labels state-acc
--BODY--
State: 0
[t] 0
[!0] 1
[!1] 2
State: 1 {0}
[!0] 1
State: 2 {0}
[!1] 2
--END--
HOA: v1
States: 4
Start: 0
AP: 2 "a" "b"
acc-name: Buchi
Acceptance: 1 Inf(0)
properties: trans-labels explicit-labels trans-acc
--BODY--
State: 0
[t] 0 {0}
[0] 1 {0}
[!0] 2 {0}
State: 1
[1] 0
[0&1] 1
[!0&1] 2 {0}
State: 2
[!1] 0
[0&!1] 1
[!0&!1] 2
[!0&!1] 3
State: 3
[!0&!1] 3 {0}
--END--
HOA: v1
States: 4
Start: 0
AP: 2 "a" "b"
acc-name: Buchi
Acceptance: 1 Inf(0)
properties: trans-labels explicit-labels trans-acc
--BODY--
State: 0
[t] 0
[0] 1
[!0] 2 {0}
State: 1
[1] 0
[0&1] 1 {0}
[!0&1] 2 {0}
State: 2
[!1] 0
[0&!1] 1 {0}
[!0&!1] 2 {0}
[!0&!1] 3
State: 3
[!0&!1] 3 {0}
--END--
HOA: v1
States: 1
Start: 0
AP: 0
acc-name: all
Acceptance: 0 t
properties: trans-labels explicit-labels state-acc deterministic
properties: stutter-invariant inherently-weak
--BODY--
State: 0
--END--
HOA: v1
States: 1
Start: 0
AP: 0
acc-name: all
Acceptance: 0 t
properties: trans-labels explicit-labels state-acc complete
properties: deterministic
--BODY--
State: 0
[t] 0
--END--
HOA: v1
States: 2
Start: 0
AP: 1 "p0"
acc-name: Buchi
Acceptance: 1 Inf(0)
properties: trans-labels explicit-labels state-acc complete
properties: deterministic
--BODY--
State: 0
[!0] 0
[0] 1
State: 1 {0}
[t] 1
--END--
HOA: v1
States: 9
Start: 2
AP: 1 "p1"
acc-name: Buchi
Acceptance: 1 Inf(0)
properties: trans-labels explicit-labels trans-acc
--BODY--
State: 0
[0] 0
[!0] 6
[0] 8
State: 1
[t] 3
State: 2
[0] 1
[!0] 5
State: 3
[0] 0
[!0] 6
State: 4
[0] 4 {0}
[!0] 6
State: 5
[0] 3
[!0] 7
State: 6
[0] 0
[!0] 6
State: 7
[0] 4 {0}
[!0] 6
State: 8
[0] 8 {0}
--END--
HOA: v1
States: 15
Start: 13
AP: 2 "p1" "p0"
acc-name: Buchi
Acceptance: 1 Inf(0)
properties: trans-labels explicit-labels trans-acc
--BODY--
State: 0
[0&1] 0 {0}
[!0&1] 1 {0}
[0&!1] 11 {0}
[!0&!1] 12
State: 1
[0&1] 0 {0}
[!0&1] 1 {0}
[0&!1] 11 {0}
[!0&!1] 12
State: 2
[!0&1] 2 {0}
[0&1] 9
[!0&!1] 10 {0}
[0&!1] 11 {0}
State: 3
[!0&1] 1 {0}
[0&1] 3 {0}
[0&!1] 11 {0}
[!0&!1] 12
State: 4
[!0&1] 4 {0}
[0&1] 7 {0}
[!1] 12
State: 5
[!0&1] 5 {0}
[0&1] 8
[!0&!1] 10 {0}
[0&!1] 12
State: 6
[!0&1] 4 {0}
[0&1] 6 {0}
[0&!1] 11 {0}
[!0&!1] 12
State: 7
[!0&1] 4 {0}
[0&1] 7 {0}
[!1] 12
State: 8
[1] 8
[!1] 12
[1] 14
State: 9
[!0&1] 1
[0&1] 3
[0&!1] 11
[!0&!1] 12
State: 10
[!0&1] 5 {0}
[0&1] 8
[!0&!1] 10 {0}
[0&!1] 12
State: 11
[0&1] 6 {0}
[!0&1] 8
[0&!1] 11 {0}
[!0&!1] 12
State: 12
[1] 8
[!1] 12
State: 13
[!0&1] 2
[0&1] 3
[!0&!1] 10
[0&!1] 11
State: 14
[1] 14 {0}
--END--
HOA: v1
States: 4
Start: 0
AP: 2 "p1" "p0"
acc-name: Buchi
Acceptance: 1 Inf(0)
properties: trans-labels explicit-labels state-acc complete
properties: deterministic
--BODY--
State: 0
[!1] 0
[0&1] 2
[!0&1] 3
State: 1 {0}
[!1] 1
[1] 2
State: 2 {0}
[!1] 1
[1] 2
State: 3 {0}
[!1] 0
[0&1] 2
[!0&1] 3
--END--
HOA: v1
States: 5
Start: 4
AP: 2 "p0" "p1"
acc-name: Buchi
Acceptance: 1 Inf(0)
properties: trans-labels explicit-labels trans-acc deterministic
--BODY--
State: 0
[0] 1
State: 1
[t] 1 {0}
State: 2
[!0&1] 0
[0] 1 {0}
[!0&!1] 2 {0}
State: 3
[1] 0
[!1] 2
State: 4
[t] 3
--END--
HOA: v1
States: 5
Start: 1
AP: 2 "p0" "p1"
acc-name: Buchi
Acceptance: 1 Inf(0)
properties: trans-labels explicit-labels state-acc
--BODY--
State: 0
[0&!1] 0
[!0] 2
[0&1] 3
State: 1
[0&!1] 1
[!0 | 1] 2
State: 2 {0}
[0&!1] 0
[!0 | 1] 2
State: 3
[0&!1] 0
[!0] 2
[0&1] 3
[0&1] 4
State: 4 {0}
[0&1] 4
--END--
EOF
run 0 $autfilt -H --remove-fin test1 > output
cat output
diff -u output expected
run 0 $autfilt -H --tgba test1 > output
cat output
diff -u output expected-tgba