alternating.test 6.84 KB
Newer Older
1
2
#!/bin/sh
# -*- coding: utf-8 -*-
3
4
# Copyright (C) 2016, 2017 Laboratoire de Recherche et Développement
# de l'Epita (LRDE).
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#
# 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
27
Start: 0&2
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
57
58
59
60
61
62
63
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]
64
65
  I -> -11 [arrowhead=onormal]
    -11 [label=<>,shape=point]
66
67
    -11 -> 0
    -11 -> 2
68
69
70
  subgraph cluster_0 {
  color=green
  label=""
71
  2 [label="G(a)"]
72
73
74
75
  }
  subgraph cluster_1 {
  color=red
  label=""
76
  1 [label="FG(a)\n⓿"]
77
78
79
80
  }
  subgraph cluster_2 {
  color=green
  label=""
81
  6 [label="t"]
82
83
  }
  subgraph cluster_3 {
84
  color=red
85
  label=""
86
  4 [label="F(b)\n⓿"]
87
88
  }
  subgraph cluster_4 {
89
  color=green
90
  label=""
91
  3 [label="GF(b)"]
92
93
94
95
96
97
98
99
100
  }
  subgraph cluster_5 {
  color=red
  label=""
  5 [label="((a) U (b))\n⓿"]
  }
  subgraph cluster_6 {
  color=black
  label=""
101
  0 [label="((((a) U (b)) && GF(b)) && FG(a))"]
102
  }
103
104
  0 -> -1 [label="b", arrowhead=onormal]
    -1 [label=<>,shape=point]
105
    -1 -> 1
106
107
108
    -1 -> 3
  0 -> -4 [label="a & !b", style=bold, color="#F15854", arrowhead=onormal]
    -4 [label=<>,shape=point]
109
    -4 -> 1 [style=bold, color="#F15854"]
110
111
    -4 -> 3 [style=bold, color="#F15854"]
    -4 -> 5 [style=bold, color="#F15854"]
112
113
114
115
  1 -> 2 [label="a"]
  1 -> 1 [label="1"]
  2 -> 2 [label="a"]
  3 -> 3 [label="b"]
116
117
  3 -> -8 [label="!b", style=bold, color="#FAA43A", arrowhead=onormal]
    -8 [label=<>,shape=point]
118
    -8 -> 3 [style=bold, color="#FAA43A"]
119
    -8 -> 4 [style=bold, color="#FAA43A"]
120
121
122
123
124
125
126
127
128
  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
129
130
131
132
133
134
135

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
136
137
138
139
140
141
142
143
144
145
146
147
148
149


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)"
150
 [t] 0&1
151
152
153
154
155
156
157
158
159
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`
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174

# 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}
175
[t] 0&1
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274


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

275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321

cat >ex4<<EOF
HOA: v1
States: 5
Start: 0&2&4
AP: 1 "a"
acc-name: co-Buchi
Acceptance: 1 Fin(0)
properties: univ-branch trans-labels explicit-labels trans-acc
properties: deterministic
--BODY--
State: 0
[0] 0
[!0] 0&2
State: 1
[t] 1&4
State: 2
[!0] 2 {0}
[0] 3
State: 3
[t] 3
State: 4
--END--
EOF

cat >expect4<<EOF
HOA: v1
States: 4
Start: 0&1&3
AP: 1 "a"
acc-name: co-Buchi
Acceptance: 1 Fin(0)
properties: univ-branch trans-labels explicit-labels trans-acc
properties: deterministic
--BODY--
State: 0
[0] 0
[!0] 0&1
State: 1
[!0] 1 {0}
[0] 2
State: 2
[t] 2
State: 3
--END--
EOF

322
run 0 autfilt --remove-unreachable-states ex4 > out4
323
diff expect4 out4
324
run 0 autfilt --remove-dead-states ex4 > out4
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
diff ex2 out4


cat >ex5<<EOF
HOA: v1
States: 2
Start: 0&1
AP: 1 "a"
acc-name: co-Buchi
Acceptance: 1 Fin(0)
--BODY--
State: 0
State: 1
--END--
EOF

341
run 0 autfilt --remove-dead-states ex5 > out5
342
343
344
345
346
347
348
349
350
351
352
353
354
cat >expect <<EOF
HOA: v1
States: 1
Start: 0
AP: 1 "a"
acc-name: co-Buchi
Acceptance: 1 Fin(0)
properties: trans-labels explicit-labels state-acc deterministic
--BODY--
State: 0
--END--
EOF
diff out5 expect
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376

# Detect cases where alternation-removal cannot work.
cat >in <<EOF
HOA: v1
name: "SLAA for p1 & FGp1"
States: 3
Start: 0&1
AP: 1 "p1"
acc-name: co-Buchi
Acceptance: 1 Fin(0)
properties: univ-branch trans-labels explicit-labels trans-acc
properties: deterministic
--BODY--
State: 0 "p1"
[0] 2
State: 1 "FGp1"
[0] 1
[!0] 1 {0}
State: 2 "t"
[t] 2
--END--
EOF
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
autfilt --tgba in 2>out && exit 1
grep 'autfilt.*weak.*alternating' out

cat >in <<EOF
HOA: v1
States: 4
AP: 2 "a" "b"
Start: 0&1
Acceptance: 1 Inf(0)
--BODY--
State: 0 {0}
[0] 2
State: 2 /*{0}*/
[0] 0
State: 1 {0}
[1] 3
State: 3 /*{0}*/
[1] 1
--END--
EOF
autfilt --tgba in 2>out && exit 1
398
grep 'autfilt.*weak.*alternating' out