sccsimpl.test 4.57 KB
Newer Older
1
#!/bin/sh
2
3
# Copyright (C) 2011, 2013 Laboratoire de Recherche et Developpement
# de l'Epita
4
5
6
7
8
#
# 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
9
# the Free Software Foundation; either version 3 of the License, or
10
11
12
13
14
15
16
17
# (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
18
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56

. ./defs

set -e

# This file tests the logic for simplifying superfluous
# acceptance conditions.  Especially those whose presence
# are implied by others.  This simplification is done as
# part of option -R3.


# The following automaton was generated for
# G((!p0 | !p2 | (!p1 W (!p1 & p3 & X(!p1 U p4)))) U p1)
# The formula does not really matter (except to show how
# such automata can occur).  The important point is that the
# acceptance condition "p4", used a lot, is always present
# when "p1" is used.  So the "p4" acceptance can be removed.
cat <<EOF > aut.txt
acc = "p4" "p1";
S1, S1, "p1", "p4" "p1";
S1, S1, "!p0 | !p2", "p4";
S1, S2, "p3", "p4";
S1, S3, "1", "p4";
S2, S1, "p1 & p4", "p4" "p1";
S2, S1, "(p4 & !p0) | (p4 & !p2)", "p4";
S2, S2, "p3 & p4", "p4";
S2, S2, "(!p1 & !p0) | (!p1 & !p2) | (!p1 & p3)",;
S2, S3, "p4", "p4";
S2, S4, "!p1",;
S3, S2, "!p1 & p3", "p4";
S3, S3, "!p1", "p4";
S4, S2, "!p1 & p3 & p4", "p4";
S4, S2, "!p1 & p3",;
S4, S3, "!p1 & p4", "p4";
S4, S4, "!p1",;
EOF

run 0 ../ltl2tgba -X -R3 -b aut.txt > out.txt
57
grep '^acc = "[^"]*";$' out.txt
58
59
60
61
62
63
64
65
66
67
68


# Here, acceptances A and C can both be removed.
cat <<EOF > aut2.txt
acc = A B C D;
S1, S1, "a", A;
S1, S1, "b", A B;
S1, S1, "c", A B C;
S1, S1, "d", C D;
EOF
run 0 ../ltl2tgba -X -R3 -b aut2.txt > out2.txt
69
grep '^acc = "." ".";$' out2.txt || exit 1
70
71
72
73
74
75
76
77
78
79
80
81
82
# only 4 lines output, because the "b" and "c" lines have been merged.
test `wc -l < out2.txt` = 4


# Here, acceptances A and B can both be removed.
cat <<EOF > aut3.txt
acc = A B C D;
S1, S1, "a", A;
S1, S1, "b", A B;
S1, S1, "c", A B C;
S1, S1, "d", B D;
EOF
run 0 ../ltl2tgba -X -R3 -b aut3.txt > out3.txt
83
grep '^acc = "." ".";$' out3.txt || exit 1
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# only 4 lines output, because the "a" and "b" lines have been merged.
test `wc -l < out3.txt` = 4


# No simplification possible here
cat <<EOF > aut4.txt
acc = A B C D;
S1, S1, "a", A;
S1, S1, "b", A B;
S1, S1, "c", A B C;
S1, S1, "d", B D;
S1, S1, "e", C D;
EOF
run 0 ../ltl2tgba -X -R3 -b aut4.txt > out4.txt
test `grep '^acc' out4.txt | wc -w` = 6
test `wc -l < out4.txt` = 6


# Make sure nothing wrong (like an assert())
# happens when no acceptance conditions are used.
cat <<EOF > aut5.txt
acc = ;
S1, S1, "a", ;
S1, S1, "b", ;
S1, S1, "c", ;
EOF
run 0 ../ltl2tgba -X -R3 -b aut5.txt > out5.txt
test `wc -l < out5.txt` = 2


# Here, one of A,B and one of C,D can be removed.
cat <<EOF > aut6.txt
acc = A B C D;
S1, S1, "a", A B;
S1, S1, "b", A B;
S1, S1, "c", C D;
S1, S1, "d", C D;
EOF
run 0 ../ltl2tgba -X -R3 -b aut6.txt > out6.txt
test `grep '^acc' out6.txt | wc -w` = 4
test `wc -l < out6.txt` = 3


# This automaton comes from the formula
# 1 U (p0 & (!p1 R ((1 U !p2) & (1 U !p3))))
# and and early implementation of our simplification
# missed the simplification.
cat <<EOF > aut7.txt
acc = ZZ "!p3" "!p2";
S1, S2, "p0 & !p2 & !p3 & !p1", ZZ "!p3" "!p2";
S1, S1, "!p0 | p1 | p2 | p3", "!p3" "!p2";
S1, S3, "p0 & p2 & !p3 & !p1", ZZ "!p3";
S1, S4, "p0 & p3 & !p2 & !p1", ZZ "!p2";
S1, S5, "(p0 & p2 & !p1) | (p0 & p3 & !p1)", ZZ;
S1, S6, "p0 & p1 & !p2 & !p3", ZZ "!p3" "!p2";
S1, S6, "(p0 & p1 & !p3) | (p0 & p2 & !p3)", ZZ "!p3";
S1, S6, "(p0 & p1 & !p2) | (p0 & p3 & !p2)", ZZ "!p2";
S1, S6, "(p0 & p1) | (p0 & p2) | (p0 & p3)", ZZ;
S2, S2, "1", ZZ "!p3" "!p2";
S3, S2, "!p2", ZZ "!p3" "!p2";
S3, S3, "p2", ZZ "!p3";
S4, S2, "!p3", ZZ "!p3" "!p2";
S4, S4, "p3", ZZ "!p2";
S5, S2, "!p2 & !p3", ZZ "!p3" "!p2";
S5, S3, "p2 & !p3", ZZ "!p3";
S5, S4, "p3 & !p2", ZZ "!p2";
S5, S5, "p2 | p3", ZZ;
S6, S2, "!p2 & !p3 & !p1", ZZ "!p3" "!p2";
S6, S3, "p2 & !p3 & !p1", ZZ "!p3";
S6, S4, "p3 & !p2 & !p1", ZZ "!p2";
S6, S5, "(p2 & !p1) | (p3 & !p1)", ZZ;
S6, S6, "p1 & !p2 & !p3", ZZ "!p3" "!p2";
S6, S6, "(p1 & !p3) | (p2 & !p3)", ZZ "!p3";
S6, S6, "(p1 & !p2) | (p3 & !p2)", ZZ "!p2";
S6, S6, "p1 | p2 | p3", ZZ;
EOF
run 0 ../ltl2tgba -X -R3 -b aut7.txt > out7.txt
test `grep '^acc' out7.txt | wc -w` = 4