ltl2tgba.test 9.02 KB
Newer Older
1
#!/bin/sh
2
# -*- coding: utf-8 -*-
3
4
5
6
7
# Copyright (C) 2009-2017 Laboratoire de Recherche et Développement de
# l'Epita (LRDE).
# Copyright (C) 2003-2004 Laboratoire d'Informatique de Paris 6
# (LIP6), département Systèmes Répartis Coopératifs (SRC), Université
# Pierre et Marie Curie.
Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
8
9
10
11
12
#
# 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
13
# the Free Software Foundation; either version 3 of the License, or
Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
14
15
16
17
18
19
20
21
# (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
22
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
23

24
25
26
27
28

. ./defs

set -e

29
30
31
32
33
34
35
36
37
38
39
40
cat >check.txt <<\EOF
a
a U b
X a
a & b & c
a | b | (c U (d & (g U (h ^ i))))
Xa & (b U !a) & (b U !a)
Fa & Xb & GFc & Gd
Fa & Xa & GFc & Gc
Fc & X(a | Xb) & GF(a | Xb) & Gc
a R (b R c)
(a U b) U (c U d)
41

42
((Xp2)U(X(1)))&(p1 R(p2 R p0))
43

44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
{a*;c}<>->GFb
{((a*;b;c)*)&((b*;a;c)*)}<>->x
{(g;y;r)*}<>->x
G({(g;y;r)*}<>->x)
G({(a;b)*}<>->x)&G({(c;d)*}<>->y)
# try sub-braces
G({{a;b}*}[]->x)&G({{c;d}*}[]->y)
{([*0] + a):c*:([*0] + b)}<>->d
{a;e;f:(g*);h}<>->d
{(a:b)* & (c*:d)}<>->e
{(a:b)*}
G{(a:b)*}
{a;b}
{(a;b)*}
G{(a;b)*}
{a*}[]->{b*}
{a*}[]=>{b*}
{a*&b}
{a*&b*}
{((!c;b*) & d);e}
{(a* & (c;b*) & d);e}
{[*2];a[*2..4]}|->b
{a[*2..5] && b[*..3]}|->c
{{[+];a;[+]} && {[+];b;[+]}}<>->c
{(a[->3]) & {[+];b}}<>->c
69
70
# This formula (built by a random formula generator), exhibited an
# infinite recursion in the translation:
71
{(a|[*0])[*];1}
72
73
# Example from "Beyond Hardware Verification" by Glazberg, Moulin, Orni,
# Ruah, Zarpas (2007).
74
{[*];req;ack}|=>{start;busy[*];done}
75
76
# Examples from "Property-by-Example Guide: a Handbook of PSL Examples"
# by Ben David and Orni (2005)/
77
78
79
80
81
82
# - 2.27.A
{end[=3]}(false)
# - 3.5.A
{[*]; {read[=3]} && {write[=2]}} |=> {(!read && !write)[*]; ready}
# - 2.33  (abridged to fit in 80 cols)
{[*];st&&comp_d_en;!comp_d_en&&good_c;{st_v[->]}&&{stop[=0];true}}|->{!d_out}
83

84
85
# Some tricky cases that require the rational automaton to be pruned
# before it is used in the translation.
86
87
{{b[*];c} | {{a && !a}}[=2]}
{((a&!b);((!a&!b)*))&&(!b*;(!a&b))}
88
89
90
# When translating this formula, we expect the translator to ignore
# `a;(f&!f)[=2];c' on one side because it as already seen it on the
# other side.
91
{c;a;(f&!f)[=2];c}|{b;a;(!f&f)[=2];c}
92
93

# these were mis-translated in Spot 0.9
94
95
96
97
98
99
G!{(b;1)*;a}
(G!{(b;1)*;a} && ({1;1[*3]*}[]->{(b&!a)[*2];!b&!a}))
EOF

run 0 ../checkpsl check.txt

100
# Make sure False has one acceptance set when generating Büchi automata
101
test 1 -eq `ltl2tgba -B false --stats %a`
102

103
104
test "`echo 1,2,a,4 | ltl2tgba -F-/3 --stats='%<,%f,%>'`" = "1,2,a,4"

105
106
107
# In particular, Spot 0.9 would incorrectly reject the sequence:
# (a̅b;a̅b;a̅b̅);(a̅b;a̅b;a̅b̅);(a̅b;a̅b;a̅b̅);... in 'G!{(b;1)*;a}'
# This means the following automaton was incorrectly empty in Spot 0.9.
108
run 0 ../ikwiad -e -R3 '(G!{(b;1)*;a} && ({1;1[*3]*}[]->{(b&!a)[*2];!b&!a}))'
109

110
111
# Make sure 'a U (b U c)' has 3 states and 6 transitions,
# before and after degeneralization.
112
for opt in '' -DT -DS; do
113
  ../ikwiad -ks -f -R3 $opt 'a U (b U c)' > stdout
114
  grep 'edges: 6$' stdout
115
116
  grep 'states: 3$' stdout
done
117
118
119

# Make sure '!(Ga U b)' has 3 states and 6 transitions,
# before and after degeneralization.
120
for opt in '' -DT -DS; do
121
  ../ikwiad -kt -f -R3 $opt '!(Ga U b)' > stdout
122
123
  grep 'transitions: 11$' stdout
  grep 'edges: 6$' stdout
124
125
126
127
128
  grep 'states: 3$' stdout
done

# Make sure 'Ga U b' has 4 states and 6 transitions,
# before and after degeneralization.
129
for opt in '' -DT -DS; do
130
  ../ikwiad -kt -f -R3 $opt 'Ga U b' > stdout
131
132
  grep 'transitions: 12$' stdout
  grep 'edges: 6$' stdout
133
134
  grep 'states: 4$' stdout
done
135
136
137
138

# Make sure '(G (p -> F q)) && ((X (p) U q) || ! X (p U (p && q)))'
# has 6 states and 15 transitions, before and after degeneralization.
f='(G (p -> F q)) && ((X (p) U q) || ! X (p U (p && q)))'
139
for opt in '' -DT -DS; do
140
  ../ikwiad -ks -f -R3 $opt "$f" > stdout
141
  grep 'edges: 15$' stdout
142
  grep 'states: 6$' stdout
143
  ../ikwiad -ks -f -R3f $opt "$f" > stdout
144
  grep 'edges: 15$' stdout
145
  grep 'states: 6$' stdout
146
done
147
148
149
150

# Make sure 'GFa & GFb & GFc & GFd & GFe & GFf'
# has 7 states and 34 transitions after degeneralization.
f='GFa & GFb & GFc & GFd & GFe & GFg'
151
../ikwiad -ks -DS -x -f "$f" > stdout
152
grep 'edges: 34$' stdout
153
grep 'states: 7$' stdout
154
155
156

# Make sure 'Ga & XXXX!a' is minimized to one state.
f='Ga & XXXX!a'
157
../ikwiad -ks -f "$f" > stdout
158
grep 'edges: 4$' stdout
159
grep 'states: 5$' stdout
160
../ikwiad -ks -Rm -f "$f" > stdout
161
grep 'edges: 0$' stdout
162
grep 'states: 1$' stdout
163
164

# Make sure a monitor for F(a & F(b)) accepts everything.
165
run 0 ../ikwiad -M -f "F(a & F(b))" | grep ' ->' > stdout
166
cat >expected <<EOF
167
168
  I -> 0
  0 -> 0 [label="1"]
169
170
EOF
cmp stdout expected
171
172

# This formula caused a segfault with Spot 0.7.
173
run 0 ../ikwiad -Rm -ks -f "Gq|Gr|(G(q|FGp)&G(r|FG!p))" >stdout
174
grep 'edges: 5$' stdout
175
176
177
grep 'states: 3$' stdout

# Adding -R3 used to make it work...
178
run 0 ../ikwiad -R3 -Rm -ks -f "Gq|Gr|(G(q|FGp)&G(r|FG!p))" >stdout
179
grep 'edges: 5$' stdout
180
grep 'states: 3$' stdout
181
182

# Make sure FGa|GFb has the same number of states/transitions when
183
184
# output as a never claim or are a degeneralized BA in HOAF.
# The option -R1q -R1t used to cause two degeneralizations to
185
# occur.
186
187
188
189
run 0 ../ikwiad -R1q -R1t -N 'FGa|FGb' > out.never
run 0 ../ikwiad -XN -kt out.never > count.never
run 0 ../ikwiad -R1q -R1t -DS -H 'FGa|FGb' > out.hoa
run 0 ../ikwiad -XH -kt out.hoa > count.hoa
190
cmp count.never count.hoa
191
192

# The following automaton should have only 4 states.
193
run 0 ../ikwiad -R3 -ks -f '(p&XF!p)|(!p&XFp)|X(Fp&F!p)' >stdout
194
grep 'edges: 7$' stdout
195
grep 'states: 4$' stdout
196
197
198

# A bug in the translation of !{xxx} when xxx reduces to false caused
# the following formula to be considered equivalent to anything...
199
200
ltlfilt -f '!{[*2] && [*0..1]}' --equivalent-to 'false' && exit 1
ltlfilt -f '!{[*2] && [*0..1]}' --equivalent-to 'true'
201
202

# Test some equivalences fixed in Spot 1.1.4
203
204
205
206
207
208
ltlfilt    -f '{{a;b}[*]}'  --equivalent-to 'a & Xb'
ltlfilt -r -f '{{a;b}[*]}'  --equivalent-to 'a & Xb'
ltlfilt    -f '!{{a;b}[*]}' --equivalent-to '!a | X!b'
ltlfilt -r -f '!{{a;b}[*]}' --equivalent-to '!a | X!b'
ltlfilt    -f '{a[*];b[*]}' --equivalent-to 'a | b'
ltlfilt -r -f '{a[*];b[*]}' --equivalent-to 'a | b'
209

210
211

# A couple of tests for the [:*i..j] operator
212
ltlfilt -q    -f '{{a;b}[:*1..2];c}' \
213
		  --equivalent-to '(a&X(b&Xc)) | a&(X(b&a&X(b&Xc)))'
214
ltlfilt -q -r -f '{{a;b}[:*1..2];c}' \
215
		  --equivalent-to '(a&X(b&Xc)) | a&(X(b&a&X(b&Xc)))'
216
217
218
219
ltlfilt -q    -f '{{a*}[:+];c}' --equivalent-to 'Xc R a'
ltlfilt -q -r -f '{{a*}[:+];c}' --equivalent-to 'Xc R a'
ltlfilt -q    -f '{c && {b | [*0]}[:+]}' --equivalent-to 'c & b'
ltlfilt -q -r -f '{c && {b | [*0]}[:+]}' --equivalent-to 'c & b'
220

221
# test unknown dot options
222
ltl2tgba --dot=@ a 2>stderr && exit 1
223
grep 'ltl2tgba: unknown option.*@' stderr
224
225
226

# Make sure the count of AP is correct through never claims or LBTT
ltl2tgba -f a -s | autfilt -q --ap=1 --lbtt | autfilt -q --ap=1
227
228
229
230
231
232

# Such a large formula will fill the BuDDy unicity table and trigger a
# resize.  At the time this test is introduced, this is the only place
# of the test-suite where this resize is triggered, so do not remove
# it unless you can find another place that triggers that.
genltl --go-theta=18 | ltl2tgba --low --any -q
233
234
235
236
237
238
239
240

# Calling ltl2tgba once for two formulas should give the same result
# as calling twice on each formula.  We had a problem where the order
# of atomic propositions would be sensible to the formulas seen
# before.
(ltl2tgba Fb ; ltl2tgba 'GFa & GFb') >out1
ltl2tgba Fb 'GFa & GFb' >out2
diff out1 out2
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257

# Because atomic proposition were not released by bdd_dict, different
# order of transitions could be observed in automata output after a
# previous translation by the same process.  (issue #262).
ltl2tgba --low --any 'Xp1 xor (Fp1 M (!p1 M (Fp0 W p1)))' \
         'Fp0 -> XXG(1 U Gp1)' > res1
ltl2tgba --low --any 'Xp1 xor (Fp1 M (!p1 M (Fp0 W p1)))' >res2
ltl2tgba --low --any 'Fp0 -> XXG(1 U Gp1)' >>res2
diff res1 res2

# The same should work when printing SCCs or atomic propositions
s='--stats=%c,%[,]x'
ltl2tgba --low --any 'Xp1 xor (Fp1 M (!p1 M (Fp0 W p1)))' \
         'Fp0 -> XXG(1 U Gp1)' "$s" >res1
ltl2tgba --low --any 'Xp1 xor (Fp1 M (!p1 M (Fp0 W p1)))' "$s" >res2
ltl2tgba --low --any 'Fp0 -> XXG(1 U Gp1)' "$s" >>res2
diff res1 res2
258
259
260
261
262
263
264
265

# Another case where different but isomorphic automata
# were output (issue #262 again).
f1='F(Gp0 <-> Gp1)'
f2='Gp1 | FGp0'
(ltl2tgba -xsimul=1 --low "$f1"; ltl2tgba -xsimul=1 --low "$f2") > res1
ltl2tgba -xsimul=1 --low "$f1" "$f2" > res2
diff res1 res2
266
267

test 3 = `ltl2tgba -f 'G(Fa & Fb) U a' --stats=%s`
268
269
270
271
272

# issue #286, the following automaton caused the print_hoa() function to
# report inconsistent "universal" property.
ltl2tgba --low 'X(((1) U (p1)) | (((p1) | (F(p0))) U ((0) R ((p2) M (p1)))))'>o
grep deterministic o