spot/tests/core/alternating.test
Alexandre Duret-Lutz 096c78a3f8 autfilt: handle alternation with --equivalent-to and friends
* bin/autfilt.cc (ensure_deterministic): Remove alternation on demand.
(process_automaton): Prefer twa::intersects() over
product()/is_empty().
* spot/twa/twa.cc (remove_fin_maybe): Also remove alternation.
* tests/core/alternating.test: More tests.
2016-12-29 12:57:53 +01:00

275 lines
5.1 KiB
Bash

#!/bin/sh
# -*- coding: utf-8 -*-
# Copyright (C) 2016 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
cat >alt.hoa <<EOF
HOA: v1.1
States: 7
Start: 0&2
acc-name: co-Buchi
Acceptance: 1 Fin(0)
AP: 2 "b" "a"
properties: trans-labels explicit-labels state-acc univ-branch very-weak
spot.highlight.edges: 2 5 7 2
--BODY--
State: 0 "((((a) U (b)) && GF(b)) && FG(a))"
[(0)] 3&1
[(!0 & 1)] 5&3&1
State: 1 "FG(a)" {0}
[(1)] 2
[t] 1
State: 2 "G(a)"
[(1)] 2
State: 3 "GF(b)"
[(0)] 3
[(!0)] 4&3
State: 4 "F(b)" {0}
[(0)] 6
[(!0)] 4
State: 5 "((a) U (b))" {0}
[(0)] 6
[(!0 & 1)] 5
State: 6 "t"
[t] 6
--END--
EOF
autfilt --dot=bans alt.hoa >alt.dot
cat >expect.dot <<EOF
digraph G {
rankdir=LR
label="Fin(⓿)"
labelloc="t"
I [label="", style=invis, width=0]
I -> -11 [arrowhead=onormal]
-11 [label=<>,shape=point]
-11 -> 0
-11 -> 2
subgraph cluster_0 {
color=green
label=""
2 [label="G(a)"]
}
subgraph cluster_1 {
color=red
label=""
1 [label="FG(a)\n⓿"]
}
subgraph cluster_2 {
color=green
label=""
6 [label="t"]
}
subgraph cluster_3 {
color=red
label=""
4 [label="F(b)\n⓿"]
}
subgraph cluster_4 {
color=green
label=""
3 [label="GF(b)"]
}
subgraph cluster_5 {
color=red
label=""
5 [label="((a) U (b))\n⓿"]
}
subgraph cluster_6 {
color=black
label=""
0 [label="((((a) U (b)) && GF(b)) && FG(a))"]
}
0 -> -1 [label="b", arrowhead=onormal]
-1 [label=<>,shape=point]
-1 -> 1
-1 -> 3
0 -> -4 [label="a & !b", style=bold, color="#F15854", arrowhead=onormal]
-4 [label=<>,shape=point]
-4 -> 1 [style=bold, color="#F15854"]
-4 -> 3 [style=bold, color="#F15854"]
-4 -> 5 [style=bold, color="#F15854"]
1 -> 2 [label="a"]
1 -> 1 [label="1"]
2 -> 2 [label="a"]
3 -> 3 [label="b"]
3 -> -8 [label="!b", style=bold, color="#FAA43A", arrowhead=onormal]
-8 [label=<>,shape=point]
-8 -> 3 [style=bold, color="#FAA43A"]
-8 -> 4 [style=bold, color="#FAA43A"]
4 -> 6 [label="b"]
4 -> 4 [label="!b"]
5 -> 6 [label="b"]
5 -> 5 [label="a & !b"]
6 -> 6 [label="1"]
}
EOF
diff expect.dot alt.dot
autfilt --trust=no --check=strength alt.hoa | grep properties: >output
cat >expected <<EOF
properties: univ-branch trans-labels explicit-labels state-acc
properties: very-weak
EOF
diff output expected
cat >out.hoa <<EOF
HOA: v1
tool: "ltl3dra" "0.2.2"
name: "VWAA for GFa"
States: 3
Start: 0
acc-name: co-Buchi
Acceptance: 1 Fin(0)
AP: 1 "a"
properties: trans-labels explicit-labels state-acc univ-branch very-weak
--BODY--
State: 0 "GF(a)"
[t] 0&1
State: 1 "F(a)" {0}
[(0)] 2
[t] 1
State: 2 "t"
[t] 2
--END--
EOF
test 3 = `autfilt --stats=%s out.hoa`
test 2 = `autfilt --tgba --stats=%s out.hoa`
# If we have a weak input, remove-fin can just transform co-Büchi into
# Büchi.
autfilt --remove-fin out.hoa >res
cat >expected <<EOF
HOA: v1
States: 3
Start: 0
AP: 1 "a"
acc-name: Buchi
Acceptance: 1 Inf(0)
properties: univ-branch trans-labels explicit-labels state-acc complete
properties: very-weak
--BODY--
State: 0 {0}
[t] 0&1
State: 1
[0] 2
[t] 1
State: 2 {0}
[t] 2
--END--
EOF
diff expected res
# If we do not know that the input is weak, remove-fin will call
# remove_alternation().
autfilt --remove-fin --trust-hoa=no out.hoa >res
cat >expected <<EOF
HOA: v1
States: 2
Start: 0
AP: 1 "a"
acc-name: Buchi
Acceptance: 1 Inf(0)
properties: trans-labels explicit-labels trans-acc complete
--BODY--
State: 0
[t] 1 {0}
State: 1
[t] 1
[0] 1 {0}
--END--
EOF
diff expected res
cat >ex1<<EOF
HOA: v1
States: 3
Start: 0
AP: 1 "a"
acc-name: co-Buchi
Acceptance: 1 Fin(0)
properties: univ-branch trans-labels explicit-labels trans-acc complete
properties: deterministic
--BODY--
State: 0
[0] 0
[!0] 0&1
State: 1
[!0] 1 {0}
[0] 2
State: 2
[t] 2
--END--
EOF
cat >ex2<<EOF
HOA: v1
States: 3
Start: 0&1
AP: 1 "a"
acc-name: co-Buchi
Acceptance: 1 Fin(0)
properties: univ-branch trans-labels explicit-labels trans-acc complete
properties: deterministic
--BODY--
State: 0
[0] 0
[!0] 0&1
State: 1
[!0] 1 {0}
[0] 2
State: 2
[t] 2
--END--
EOF
cat >ex3<<EOF
HOA: v1
States: 3
Start: 0
AP: 1 "a"
acc-name: co-Buchi
Acceptance: 1 Fin(0)
properties: univ-branch trans-labels explicit-labels trans-acc complete
properties: deterministic
--BODY--
State: 0
[0] 1
[!0] 0&1
State: 1
[!0] 1 {0}
[0] 2
State: 2
[t] 2
--END--
EOF
autfilt -q --equivalent-to=ex1 ex2
autfilt -q --included-in=ex1 ex2
autfilt -q --equivalent-to=ex1 ex3 && exit 1
autfilt -q --intersect=ex1 ex3
: