parseaut.test 44.5 KB
Newer Older
1
2
#!/bin/sh
# -*- coding: utf-8 -*-
3
# Copyright (C) 2014, 2015 Laboratoire de Recherche et Développement de
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# 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

expecterr()
{
   cat >$1.exp
29
   ../../bin/autfilt --hoa "$@" 2>$1.err-t >$1.out && exit 1
30
   test $? = 2
31
32
33
34
   # If autfilt is compiled statically, the '.../lt-' parse of
   # its name is not stripped, and the error message show the
   # full path.
   sed 's:^\.\./\.\./bin/::' $1.err-t >$1.err
35
36
37
38
   cat $1.err
   diff $1.err $1.exp
}

39
40
41
expectok()
{
   cat >$1.exp
42
   ../../bin/autfilt --hoa "$@" >$1.out
43
44
45
46
47
   test $? = 0
   cat $1.out
   diff $1.out $1.exp
}

48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80

cat >input <<EOF
HOA: v1
States: 1
Start: 0
AP: 1 "a"
States: 2
Acceptance: 1 Inf(0)
--BODY--
State: 0 {0}
[0] 1
State: 1 {0}
[t] 1
--END--
EOF

expecterr input <<EOF
input:5.1-9: redefinition of the number of states...
input:2.1-9: ... previously defined here.
EOF

cat >input <<EOF
HOA: v1
States: 1
Start: 0
AP: 1 "a"
Acceptance: 1 Inf(0)
--BODY--
State: 0 {0}
[0] 1
State: 1 {0}
[t] 1
--END--
81
82
83
84
85
86
87
88
2 1t
2 1
1 -1 "b"
0 -1 & "a" ! "b"
-1
1 0
2 0 -1 t
-1
89
90
91
92
93
94
95
96
97
98
99
/* Another automaton.  Here we make sure that guard must
   be Boolean, even though we the LBT parser we use
   would accept LTL. */
2 1t
0 1
1 -1 G "b"
0 -1 & "a" ! "b"
-1
1 0
0 0 -1 t
-1
100
101
EOF

102
diff='different state numbers have been used'
103
104
105
106
107
108
109
expecterr input <<EOF
input:8.5: state number is larger than state count...
input:2.1-9: ... declared here.
input:9.8: state number is larger than state count...
input:2.1-9: ... declared here.
input:10.5: state number is larger than state count...
input:2.1-9: ... declared here.
110
input:12.1-19.2: 2 states have been declared, but 3 $diff
111
input:25.5-10: non-Boolean transition label (replaced by true)
112
113
EOF

114
115
116
117
118
119
120
121
cat >input <<EOF
HOA: v1
States: 1
Start: 0
AP: 1 "a"
Acceptance: 1 Inf(0)
--BODY--
State: 0 {0}
122
[2] 0
123
124
125
126
127
128
State: 0 {0}
[t] 0
--END--
EOF

expecterr input <<EOF
129
130
input:8.2: AP number is larger than the number of APs...
input:4.1-5: ... declared here
131
132
133
input:9.1-8: redeclaration of state 0
EOF

134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
cat >input <<EOF
HOA: v1
States: 0
AP: 1 "a" "b"
Acceptance: 0 t
--BODY--
--END--
EOF

expecterr input <<EOF
input:3.1-13: found 2 atomic propositions instead of the 1 announced
EOF

cat >input <<EOF
HOA: v1
AP: 1 "a"
States: 0
AP: 2 "a" "b"
Acceptance: 0 t
--BODY--
--END--
EOF

expecterr input <<EOF
158
159
input:4.1-3: ignoring this redeclaration of APs...
input:2.1-5: ... previously declared here.
160
161
162
163
EOF

cat >input <<EOF
HOA: v1
164
AP: 2 "a" "a"
165
166
167
States: 0
Start: 1
--BODY--
168
169
State: 0 {0 1}
[0] 0 {0}
170
171
172
173
--END--
EOF

expecterr input <<EOF
174
input:2.11-13: duplicate atomic proposition "a"
175
input:4.1-8: initial state number is larger than state count...
176
177
input:3.1-9: ... declared here.
input:1.1-4.8: missing 'Acceptance:' header
178
179
180
181
182
input:6.8: state number is larger than state count...
input:3.1-9: ... declared here.
input:6.10-14: ignoring acceptance sets because of missing acceptance condition
input:7.5: state number is larger than state count...
input:3.1-9: ... declared here.
183
input:4.1-8: initial state 1 has no definition
184
185
186
187
188
EOF

cat >input <<EOF
HOA: v1
AP: 1 "a"
189
190
Start: 1
States: 1
191
192
193
194
195
196
197
--BODY--
--END--
EOF

expecterr input <<EOF
input:3.1-8: initial state number is larger than state count...
input:4.1-9: ... declared here.
198
input:1.1-4.9: missing 'Acceptance:' header
199
input:3.1-8: initial state 1 has no definition
200
201
202
203
204
205
206
207
208
209
210
211
212
EOF

cat >input <<EOF
HOA: v1
Acceptance: 1 Inf(0)
Start: 0
States: 1
Acceptance: 1 Inf(0)
--BODY--
--END--
EOF

expecterr input <<EOF
213
input:5.1-13: ignoring this redefinition of the acceptance condition...
214
input:2.1-13: ... previously defined here.
215
input:3.1-8: initial state 0 has no definition
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
EOF

cat >input <<EOF
HOA: v1
Start: 0
AP: 1 "a"
States: 2
Acceptance: 1 Inf(0)
--BODY--
State: 0 {0}
[0] 1
State: 1 {1}
[t] 1
--END--
EOF

expecterr input <<EOF
input:9.11: number is larger than the count of acceptance sets...
input:5.1-13: ... declared here.
EOF

237
# Let's have two broken automata in a row...
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
cat >input <<EOF
HOA: v1
Start: 0
AP: 1 "a"
States: 2
Acceptance: 1 Inf(2)
--BODY--
State: 0 {0}
[0] 1
State: 1 {0}
[t] 1
--END--
HOA: v2
--BODY--
--END--
253
254
255
256
257
258
HOA: w1
--BODY--
--END--
HOA: v1_1
--BODY--
--END--
259
260
EOF

261
t='this might cause the following errors'
262
expecterr input <<EOF
263
264
input:5.19: number is larger than the count of acceptance sets...
input:5.1-13: ... declared here.
265
input:12.6-7: unsupported HOA version
266
input:12.1-7: missing 'Acceptance:' header
267
268
269
270
input:15.6-7: unknown HOA version
input:15.1-7: missing 'Acceptance:' header
input:18.6-9: we can read HOA v1 but this file uses v1_1; $t
input:18.1-9: missing 'Acceptance:' header
271
EOF
272
273

cat >input<<EOF
274
    HOA: v1a  /* version greater than 1, but assumed to be compatible */
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
    States: 3
    Start: 0
    acc-name: generalized-Buchi 2
    Acceptance: 2 (Inf(0) & Inf(1))
    AP: 2 "a" "b"
    --BODY--
    State: 0 "foo" { 0 }
      2  /* !a  & !b */
      0  /*  a  & !b */
      1  /* !a  &  b */
      1  /*  a  &  b */
    State: 1 { 1 }
      1 1 1 1       /* four transitions on one line */
    State: 2 "sink state" { 0 }
      2 2 2 2
    --END--
EOF

expectok input <<EOF
HOA: v1
States: 3
Start: 0
AP: 2 "a" "b"
acc-name: generalized-Buchi 2
Acceptance: 2 Inf(0)&Inf(1)
300
properties: trans-labels explicit-labels state-acc colored complete
301
properties: deterministic
302
--BODY--
303
State: 0 "foo" {0}
304
[!0&!1] 2
305
[0&!1] 0
306
307
308
[!0&1] 1
[0&1] 1
State: 1 {1}
309
310
311
312
[!0&!1] 1
[0&!1] 1
[!0&1] 1
[0&1] 1
313
State: 2 "sink state" {0}
314
315
316
317
318
319
320
321
322
323
324
325
326
327
[!0&!1] 2
[0&!1] 2
[!0&1] 2
[0&1] 2
--END--
EOF

cat >input<<EOF
    HOA: v1
    States: 3
    Start: 0
    acc-name: generalized-Buchi 2
    Acceptance: 2 (Inf(0) & Inf(1))
    AP: 2 "a" "b"
328
    properties: state-labels complete
329
330
331
332
333
334
335
336
337
338
339
    --BODY--
    State: 0 "foo" { 0 }
      2  /* !a  & !b */
      0  /*  a  & !b */
      1  /* !a  &  b */
      /* missing transition */
    State: 1 { 1 }
      1 1 1 1       /* four transitions on one line */
    State: 2 "sink state" { 0 }
      2 2 2 2
    --END--
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
HOA: v1
States: 3
Start: 0
acc-name: generalized-Buchi 2
Acceptance: 2 (Inf(0) & Inf(1))
AP: 2 "a" "b"
properties: implicit-labels complete
--BODY--
State: [t] 0 "foo" { 0 }
  2  /* !a  & !b */
  0  /*  a  & !b */
  1  /* !a  &  b */
  0  /*  a  &  b */
State: 1 { 1 }
  1 1 1 1       /* four transitions on one line */
State: 2 "sink state" { 0 }
  2 2 2 2
--END--
358
359
360
EOF

expecterr input <<EOF
361
362
363
input:9.5-12.7: not enough transitions for this state
input:10.7-12.7: these transitions have implicit labels but the automaton is...
input:7.17-28: ... declared with 'property: state-labels'
364
365
366
367
input:9.5-12.7: automaton is not complete...
input:7.30-37: ... despite 'property: complete'
input:27.8-10: state label used although the automaton was...
input:25.13-27: ... declared with 'property: implicit-labels' here
368
369
370
371
EOF

cat >input<<EOF
    HOA: v1
372
    tool: "test"
373
374
375
376
    States: 3
    Start: 0
    acc-name: generalized-Buchi 2
    Acceptance: 2 (Inf(0) & Inf(1))
377
    properties: implicit-labels explicit-labels /* ? */ complete
378
    properties: trans-acc state-acc /* ? */
379
380
381
382
383
384
385
386
387
388
389
390
391
    AP: 2 "a" "b"
    --BODY--
    State: 0 "foo" { 0 }
      2  /* !a  & !b */
      0  /*  a  & !b */
      1  /* !a  &  b */
      1  /*  a  &  b */
      2  /*  extra transition ! */
    State: 1 { 1 }
      1 1 1 1       /* four transitions on one line */
    State: 2 "sink state" { 0 }
      2 2 2 2
    --END--
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
    HOA: v1
    tool: "test"
    States: 3
    Start: 0
    acc-name: generalized-Buchi 2
    Acceptance: 2 (Inf(0) & Inf(1))
    properties: implicit-labels state-labels /* ? */
    AP: 2 "a" "b"
    --BODY--
    State: 0 "foo" { 0 }
      2  /* !a  & !b */
      0  /*  a  & !b */
      1  /* !a  &  b */
      1  /*  a  &  b */
    State: 1 { 1 }
      1 1 1 1       /* four transitions on one line */
    State: 2 "sink state" { 0 }
      2 2 2 2
    --END--
    HOA: v1
    tool: "test"
    States: 3
    Start: 0
    acc-name: generalized-Buchi 2
    Acceptance: 2 (Inf(0) & Inf(1))
417
    properties: implicit-labels trans-acc
418
419
420
421
422
423
424
425
426
427
428
429
    AP: 2 "a" "b"
    --BODY--
    State: 0 "foo" { 0 }
      2  /* !a  & !b */
      0  /*  a  & !b */
      1  /* !a  &  b */
      1  /*  a  &  b */
    State: 1 { 1 }
      1 1 1 1       /* four transitions on one line */
    State: 2 "sink state" { 0 }
      [t] 2
    --END--
430
431
432
EOF

expecterr input <<EOF
433
434
input:7.17-31: 'property: implicit-labels' is incompatible with...
input:7.33-47: ... 'property: explicit-labels'.
435
436
input:8.17-25: 'property: trans-acc' is incompatible with...
input:8.27-35: ... 'property: state-acc'.
437
input:16.7: too many transitions for this state, ignoring this one
438
439
440
441
442
443
input:28.33-44: 'property: state-labels' is incompatible with...
input:28.17-31: ... 'property: implicit-labels'.
input:50.20-24: state-based acceptance used despite...
input:47.33-41: ... declaration of transition-based acceptance.
input:58.7-9: transition label used although the automaton was...
input:47.17-31: ... declared with 'property: implicit-labels' here
444
EOF
Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
445
446
447
448
449
450
451
452
453
454
455
456


cat >input <<EOF
    HOA: v1
    name: "GFa & GF(b & c)"
    States: 1
    Start: 0
    acc-name: generalized-Buchi 2
    Acceptance: 2 (Inf(0) & Inf(1))
    AP: 3 "a" "b" "c"
    Alias: @a 0
    Alias: @a 1 & 2 /* should be @bc */
457
    properties: state-labels /* this is bogus */
458
                state-acc /* bogus as well */
Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
459
460
461
462
463
464
465
466
467
468
469
    --BODY--
    State: 0
    [!@a & !@bc] 0
    [@a & !@bc]  0 {0}
    [!@a & @bc]  0 {1}
    [@a & @bc]   0 {0 1}
    --END--
EOF

expecterr input <<EOF
input:9.5-19: ignoring redefinition of alias @a
470
471
input:14.13-15: unknown alias @bc
input:14.5-16: transition label used although the automaton was...
472
473
input:10.17-28: ... declared with 'property: state-labels' here
input:15.12-14: unknown alias @bc
474
475
476
477
input:15.20-22: trans-based acceptance used despite...
input:11.17-25: ... declaration of state-based acceptance.
input:16.12-14: unknown alias @bc
input:17.11-13: unknown alias @bc
Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
478
479
480
481
482
483
484
EOF

cat >input <<EOF
    HOA: v1
    name: "GFa & GF(b & c)"
    States: 1
    Start: 0
485
    acc-name: who cares
Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
486
487
488
489
490
491
492
493
494
495
496
    Acceptance: 2 (Inf(0) & Inf(1))
    AP: 3 "a" "b" "c"
    Alias: @a 0
    Alias: @bc 1 & 2
    --BODY--
    State: 0
    [!@a & !@bc] 0
    [@a & !@bc]  0 {0}
    [!@a & @bc]  0 {1}
    [@a & @bc]   0 {0 1}
    --END--
497
/* Some comment */
498
499
500
501
502
503
504
505
506
HOA: v1
States: 2
Start: 0
Acceptance: 0 t
AP: 1 "a"
--BODY--
State: [0] 0 1
State: [0] 1 1
--END--
Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
507
508
509
510
EOF

expectok input <<EOF
HOA: v1
511
name: "GFa & GF(b & c)"
Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
512
513
514
515
516
States: 1
Start: 0
AP: 3 "a" "b" "c"
acc-name: generalized-Buchi 2
Acceptance: 2 Inf(0)&Inf(1)
517
518
properties: trans-labels explicit-labels trans-acc complete
properties: deterministic
Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
519
520
521
522
523
524
525
--BODY--
State: 0
[!0&!1 | !0&!2] 0
[0&!1 | 0&!2] 0 {0}
[!0&1&2] 0 {1}
[0&1&2] 0 {0 1}
--END--
526
527
528
529
530
531
532
533
534
535
536
537
538
HOA: v1
States: 2
Start: 0
AP: 1 "a"
acc-name: all
Acceptance: 0 t
properties: trans-labels explicit-labels state-acc deterministic
--BODY--
State: 0
[0] 1
State: 1
[0] 1
--END--
Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
539
EOF
Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
540

541
542
543
544
545
expectok input --stats='%F:%L' <<EOF
input:1.5-16.11
input:18.1-26.7
EOF

Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
546
547
cat >input <<EOF
HOA: v1
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
--ABORT--
HOA: v1
States: 2
Start: 0
Acceptance: 2 (Inf(0) & Inf(!0)) &
     --ABORT----ABORT--
HOA: v1
States: 2
Start: 0
Acceptance: 2 (Inf(0) & Inf(!0)) & Inf(!1)
AP: 1 "a"
     --BODY-- State: 0 {0
}
[0] 1
[!0--ABORT--
HOA: v1
Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
564
States: 2
565
name: "survivor"
Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
566
567
568
569
570
571
572
573
574
575
Start: 0
Acceptance: 2 (Inf(0) & Inf(!0)) & Inf(!1)
AP: 1 "a"
--BODY--
State: 0 {0}
[0] 1
[!0] 0 {1}
State: 1
[!0] 1
[0] 0
576
[f] 0
Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
577
578
579
--END--
EOF

580
581
582
583
584
585
586
expecterr input <<EOF
input:1.1-2.9: aborted input automaton
input:3.1-7.14: aborted input automaton
input:7.15-23: aborted input automaton
input:8.1-16.12: aborted input automaton
EOF

587
# DOS-style new lines should have the same output.
588
perl -pi -e 's/$/\r/' input
589
590
591
592
../../bin/autfilt --hoa input 2>stderr && exit 1
cat stderr
diff stderr input.exp

593
cat >expected <<EOF
Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
594
HOA: v1
595
name: "survivor"
Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
596
597
598
599
600
States: 2
Start: 0
AP: 1 "a"
acc-name: generalized-Buchi 3
Acceptance: 3 Inf(0)&Inf(1)&Inf(2)
601
602
properties: trans-labels explicit-labels trans-acc complete
properties: deterministic
Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
603
604
605
606
607
608
609
610
611
--BODY--
State: 0
[0] 1 {0 1}
[!0] 0 {0}
State: 1
[!0] 1 {1 2}
[0] 0 {1 2}
--END--
EOF
612
613

diff expected input.out
614

615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
cat >input <<EOF
HOA: v1
States: 2
Start: 0
Start: 1
AP: 2 "a" "\"b\""
Acceptance: 1 Inf(0)
properties: deterministic
--BODY--
State: 0 {0}
[1] 1
[!1] 0
State: 1
[!0] 1
[0] 0
--END--
HOA: v1
States: 0
AP: 0
Acceptance: 1 Inf(0)
properties: complete
--BODY--
--END--
HOA: v1
States: 2
Start: 0
AP: 2 "a" "\"b\""
Acceptance: 1 Inf(0)
properties: deterministic
--BODY--
State: 0 {0}
[1] 1
[!1] 0
State: 1
[!0] 1
[!0] 0
--END--
EOF
expecterr input <<EOF
input:7.13-25: deterministic automata should have at most one initial state
input:20.13-20: complete automata should have at least one initial state
input:33.1-35.6: automaton is not deterministic...
input:28.13-25: ... despite 'property: deterministic'
EOF
659

660
# Mix HOA with neverclaims and LBTT automata
661
662
663
664
665
666
cat >input <<EOF
HOA: v1
States: 2
Start: 0
Start: 1
Start: 0 /* duplicate */
667
AP: 2 "a" "\"b\""
668
669
670
671
672
673
674
675
676
Acceptance: 1 Inf(0)
--BODY--
State: 0 {0}
[1] 1
[!1] 0
State: 1
[!0] 1
[0] 0
--END--
677

678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
/* some LBTT with mixed state/transition acceptance,
   just because we can */
4 2ts
0 1 -1
1 -1 "c"
2 -1 & "b" ! "c"
3 -1 ! "c"
-1
1 0 1 -1
1 0 -1 t
-1
2 0 -1
1 -1 "c"
2 -1 & "b" ! "c"
-1
3 0 -1
3 0 1 -1 & "a" "b"
3 1 -1 & "a" ! "b"
3 0 -1 & ! "a" "b"
3 -1 & ! "a" ! "b"
-1


701
702
703
never  {    /* a U b */
T0_init:
        if
704
705
        :: (b) -> goto accept_all
        :: (a) -> goto T0_init
706
707
708
709
710
711
712
713
714
715
        fi;
accept_all:
        skip
}


never {
  start: if :: false -> goto T0 fi;
  T0: false
}
716
717
718
719
720
EOF

expectok input <<EOF
HOA: v1
States: 3
721
Start: 2
722
AP: 2 "a" "\"b\""
723
724
725
726
acc-name: Buchi
Acceptance: 1 Inf(0)
properties: trans-labels explicit-labels state-acc complete
--BODY--
727
State: 0 {0}
728
[1] 1
729
[!1] 0
730
731
State: 1
[!0] 1
732
733
[0] 0
State: 2
734
[1] 1
735
736
737
[!1] 0
[!0] 1
[0] 0
738
--END--
739
HOA: v1
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
States: 4
Start: 0
AP: 3 "c" "b" "a"
acc-name: generalized-Buchi 2
Acceptance: 2 Inf(0)&Inf(1)
properties: trans-labels explicit-labels trans-acc
--BODY--
State: 0
[0] 1
[!0&1] 2
[!0] 3
State: 1
[t] 1 {0 1}
State: 2
[0] 1
[!0&1] 2
State: 3
[1&2] 3 {0 1}
[!1&2] 3 {0}
[1&!2] 3 {1}
[!1&!2] 3
--END--
HOA: v1
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
States: 2
Start: 0
AP: 2 "b" "a"
acc-name: Buchi
Acceptance: 1 Inf(0)
properties: trans-labels explicit-labels state-acc
--BODY--
State: 0
[0] 1
[1] 0
State: 1 {0}
[t] 1
--END--
HOA: v1
States: 2
Start: 0
AP: 0
acc-name: Buchi
Acceptance: 1 Inf(0)
properties: trans-labels explicit-labels state-acc deterministic
--BODY--
State: 0
[f] 1
State: 1
--END--
788
789
790
791
792
793
794
795
796
797
798
799
EOF

cat >input <<EOF
HOA: v1
States: 2
Start: 0
Start: 0  /* duplicate */
AP: 2 "a" "b"
Acceptance: 1 Inf(0)
--BODY--
State: 0 {0}
[1] 1
800
[!1] 0  /* nested /* comment */ */
801
802
803
804
805
806
807
808
809
810
811
812
813
State: 1
[!0] 1
[0] 0
--END--
EOF

expectok input <<EOF
HOA: v1
States: 2
Start: 0
AP: 2 "a" "b"
acc-name: Buchi
Acceptance: 1 Inf(0)
814
815
properties: trans-labels explicit-labels state-acc complete
properties: deterministic
816
817
818
819
820
821
822
823
824
--BODY--
State: 0 {0}
[1] 1
[!1] 0
State: 1
[!0] 1
[0] 0
--END--
EOF
825

826
827
828
829
cat >input <<EOF
HOA: v1
States: 3
Start: 0
830
831
832
AP: 2 "a" "b"/* multi
line
comment */
833
834
835
836
837
838
839
840
841
842
843
844
845
Acceptance: 1 Inf(0)
--BODY--
State: [1] 0 {0}
[!1] 0
 1
State: 1
[!0] 1
     2
State: 2
     1
[t] 2
   1 2
--END--
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
HOA: v1
States: 1
Start: 0
AP: 2 "a" "b"
Acceptance: 1 Inf(0)
properties: trans-labels /* this is bogus */
--BODY--
State: [1] 0 {0} 0
--END--
HOA: v1
States: 1
Start: 0
AP: 2 "a" "b"
Acceptance: 1 Inf(0)
properties: state-labels trans-labels /* this is bogus */
--BODY--
State: [1] 0 {0} 0
--END--
HOA: v1
States: 1
Start: 0
AP: 2 "a" "b"
Acceptance: 1 Inf(0)
properties: state-labels /* OK */
--BODY--
State: [1] 0 {0} 0
--END--
873
874
875
EOF

expecterr input <<EOF
876
877
878
879
input:10.1-4: cannot label this edge because...
input:9.8-10: ... the state is already labeled.
input:14.6: missing label for this edge (previous edge is labeled)
input:17.1-3: ignoring this label, because previous edge has no label
880
881
882
883
input:27.8-10: state label used although the automaton was...
input:25.13-24: ... declared with 'property: trans-labels' here
input:34.26-37: 'property: trans-labels' is incompatible with...
input:34.13-24: ... 'property: state-labels'.
884
885
EOF

886
887
888

cat >input <<EOF
HOA: v1
889
890
891
States: /* multi-line
comment
*/2
892
Start: 0
893
894
Important: 4 very important "with multi-line
string!"
895
896
897
898
899
900
901
902
903
AP: 0
Acceptance: 1 Inf(0)
--BODY--
State: 0 {0} 1
State: 1 0
--END--
EOF

expecterr input <<EOF
904
input:6.1-7.8: ignoring unsupported header "Important:"
905
906
907
908
909
910
911
912
913
914
	(but the capital indicates information that should not be ignored)
EOF

cat >expected <<EOF
HOA: v1
States: 2
Start: 0
AP: 0
acc-name: Buchi
Acceptance: 1 Inf(0)
915
916
properties: trans-labels explicit-labels state-acc complete
properties: deterministic
917
918
919
920
921
922
923
924
925
--BODY--
State: 0 {0}
[t] 1
State: 1
[t] 0
--END--
EOF

diff expected input.out
926

927
# DOS-style new lines should have the same output.
928
perl -pe -e 's/$/\r/' input
929
930
931
932
../../bin/autfilt --hoa input 2>stderr && exit 1
cat stderr
diff stderr input.exp
diff expected input.out
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975

# Error recovery

cat >input <<EOF
HOA: v1
States: 2
Start: 0
AP: 0
acc-name: Buchi
Acceptance: 1 Inf(0)
--BODY--
State: 0 {a}  /* not a digit */
[t] 1
State: 1
[a] 0         /* not a digit */
--END--
HOA: v1
Acceptance: 1 Inf(0)
States: 2
Start: 0
AP: 0
acc-name: Buchi
--BODY--
State: 0 {0}
[t] "f" 1     /* WTF? */
State: 1
[t] 0
--END--
some garbage HOA: v1
Acceptance: 1 Inf(0)
States: 2
Start: 0
AP: 0
acc-name: Buchi
--BODY--
Stat: 0 {0}  /* not State: */
[t] 1
State: 1
[t] 0
--END--
this is complete garbage!
--END--
and even more garbage
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
DRA v2 explicit
Comment: "Safra[NBA=2]"
States: 2
garbage  /* <<--- */
Acceptance-Pairs: 1
Start: 0
AP: 1 "a"
---
State: 0
Acc-Sig:
0
1
State: 1
Acc-Sig: +0
0
1
more garbage
DRA v2 explicit
Comment: "Safra[NBA=2]"
States: 2
Acceptance-Pairs: 1
Start: 0
AP: 1 "a"
---
State: 0
Acc-Sig:
0
1
State: 1
Acc-Sig: +0
0
1
HOA: v1
States: 1
Start: 0
AP: 0
Acceptance: 1 Inf(0)
--BODY--
State: 0 {0}
[t] 0
--END--
garbage
1018
1019
EOF

1020
se='syntax error, unexpected'  # this is just to keep lines short
1021
expecterr input <<EOF
1022
input:8.11: $se identifier, expecting integer or '}'
1023
input:8.10-12: ignoring this invalid acceptance set
1024
input:11.2: $se identifier
1025
input:11.1-3: ignoring this invalid label
1026
input:21.5-7: $se string, expecting integer
1027
input:25.1: $se \$undefined
1028
input:32.1-5: $se header name, expecting --END-- or State:
1029
input:28.1-8: initial state 0 has no definition
1030
input:25.1-12: leading garbage was ignored
1031
input:37.1: $se 't'
1032
1033
1034
1035
input:43.1: $se \$undefined
input:56.1: $se \$undefined, expecting State: or end of DSTAR automaton
input:37.1-39.21: leading garbage was ignored
input:81.1: $se \$undefined
1036
autfilt: failed to read automaton from input
1037
EOF
1038

1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
# More error recovery in DSTAR automata
cat >input <<EOF
DRA v2 explicit
Comment: "Safra[NBA=2]"
States: 3
States: 3
Start: 0
AP: 2 "a" "b"
---
State: 0
Acc-Sig:
1
0
2
2
1054
State: 1 "some name"
1055
1056
1057
1058
1059
Acc-Sig: -0
1
1
1
1
1060
State: 2 "another name"
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
Acc-Sig: +0
2
2
2
2
never { /* true */
accept_init:
	if
	:: (1) -> goto accept_init
	fi;
}
EOF

../../bin/autfilt input -H >output 2>&1 && exit 1
cat output
cat >expected <<EOF
input:1.16-4.9: redeclaration of state count
input:1.16-6.13: missing acceptance-pair count
input:15.11: no acceptance pairs have been declared
input:21.11: no acceptance pairs have been declared
HOA: v1
States: 3
Start: 0
AP: 2 "a" "b"
acc-name: all
Acceptance: 0 t
properties: trans-labels explicit-labels state-acc complete
properties: deterministic
--BODY--
State: 0
[0&!1] 0
[!0&!1] 1
[1] 2
1094
State: 1 "some name"
1095
[t] 1
1096
State: 2 "another name"
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
[t] 2
--END--
HOA: v1
States: 1
Start: 0
AP: 0
acc-name: Buchi
Acceptance: 1 Inf(0)
properties: trans-labels explicit-labels state-acc colored complete
properties: deterministic
--BODY--
State: 0 {0}
[t] 0
--END--
EOF
diff output expected

1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
# A comment can contain --BODY-- or --END--, so we do not want to be
# smart about it.
cat >input <<EOF
HOA: v1
States: 2
Start: 0
AP: 0
acc-name: Buchi /* unclosed comment
Acceptance: 1 Inf(0)
--BODY--
State: 0 {0}
[t] 1
State: 1
[t] 0
--END--
HOA: v1
States: 2
Start: 0
AP: 0
acc-name: Buchi
Acceptance: 1 Inf(0)
--BODY--
State: 0 {0}
[t] 1
State: 1
[t] 0
--END--
EOF

expecterr input <<EOF
input:5.17-25.1: unclosed comment
input:5.17-25.1: syntax error, unexpected end of file
autfilt: failed to read automaton from input
EOF

# Likewise for strings
cat >input <<EOF
HOA: v1
States: 2
Start: 0
tool: "unterminated string
AP: 0
acc-name: Buchi
Acceptance: 1 Inf(0)
--BODY--
State: 0 {0}
[t] 1
State: 1
[t] 0
--END--
HOA: v1
States: 2
Start: 0
AP: 0
acc-name: Buchi
Acceptance: 1 Inf(0)
--BODY--
State: 0 {0}
[t] 1
State: 1
[t] 0
--END--
EOF

expecterr input <<EOF
1179
1180
input:4.7-26.1: unclosed string
input:26.1: syntax error, unexpected end of file
1181
1182
autfilt: failed to read automaton from input
EOF
1183
1184
1185
1186

expecterr non-existant<<EOF
autfilt: Cannot open file non-existant
EOF
1187

1188
run 2 ../ikwiad -XH foob 2>output.err
1189
1190
grep 'foob:1.1: Cannot open file foob' output.err

1191
# Make sure we can read multiple automata from stdin
1192
1193
../../bin/ltl2tgba 'a U b' 'GFa' --hoa | grep -v '^name:' |
    sed 's/ stutter-invariant//;s/ inherently-weak//;/properties:$/d' > input
1194
1195
../../bin/autfilt --hoa < input | ../../bin/autfilt --hoa > output
diff input output
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214



# Parse something in debug mode, to exercise the %printer
cat >input <<EOF
HOA: v1
States: 2
Start: 0
AP: 0
acc-name: Buchi
Acceptance: 1 Inf(0)
--BODY--
State: 0 {0}
[t] 1
State: 1
[t] 0
--END--
EOF

1215
run 0 ../ikwiad -d -XH input 2> output.err
1216
1217
grep -- "--BODY--" output.err
grep "identifier.*v1" output.err
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298



# This was generated by
#      randaut -n 10 -Hl 3 -d 0.055 --seed=3 | fmt
cat > input <<EOF
HOA: v1 States: 10 Start: 0 AP: 3 "p0" "p1" "p2" acc-name: all Acceptance:
0 t properties: trans-labels explicit-labels state-acc deterministic
--BODY-- State: 0 [0&!1&2] 0 [0&1&2] 1 State: 1 [0&1&2] 2 State: 2
[!0&1&!2] 3 State: 3 [!0&1&!2] 4 State: 4 [!0&1&2] 1 [0&!1&!2] 5 State:
5 [!0&1&2] 6 State: 6 [!0&1&2] 7 State: 7 [0&1&2] 8 State: 8 [!0&!1&2]
9 State: 9 [0&1&2] 2 [!0&!1&!2] 6 [!0&1&!2] 1 --END-- HOA: v1 States: 10
Start: 0 AP: 3 "p0" "p1" "p2" acc-name: all Acceptance: 0 t properties:
trans-labels explicit-labels state-acc deterministic --BODY-- State: 0
[!0&1&2] 1 State: 1 [0&!1&!2] 2 State: 2 [!0&1&!2] 3 State: 3 [0&!1&2]
4 [!0&!1&!2] 5 [!0&1&!2] 6 State: 4 [!0&!1&!2] 7 [0&!1&2] 0 State: 5
[0&1&!2] 8 State: 6 [!0&1&!2] 7 State: 7 [!0&1&!2] 9 State: 8 [!0&1&2]
2 State: 9 [0&1&2] 6 --END-- HOA: v1 States: 10 Start: 0 AP: 3 "p0"
"p1" "p2" acc-name: all Acceptance: 0 t properties: trans-labels
explicit-labels state-acc deterministic --BODY-- State: 0 [0&1&!2]
1 State: 1 [0&1&!2] 2 [0&!1&!2] 3 State: 2 [!0&1&!2] 1 [!0&!1&!2] 4
State: 3 [0&1&!2] 5 State: 4 [!0&1&2] 3 [!0&!1&2] 6 State: 5 [0&1&!2]
7 State: 6 [!0&!1&!2] 8 State: 7 [!0&!1&!2] 5 State: 8 [!0&!1&!2] 9
[0&1&!2] 6 State: 9 [!0&1&2] 8 [0&!1&2] 4 [!0&!1&!2] 7 --END-- HOA:
v1 States: 10 Start: 0 AP: 3 "p0" "p1" "p2" acc-name: all Acceptance:
0 t properties: trans-labels explicit-labels state-acc --BODY-- State:
0 [0&1&2] 1 State: 1 [0&1&2] 2 State: 2 [0&!1&!2] 3 [0&!1&2] 4 [0&!1&2]
0 State: 3 [!0&1&2] 1 [0&!1&2] 2 [!0&!1&2] 5 State: 4 [0&1&!2] 6 State: 5
[!0&1&!2] 7 State: 6 [0&!1&!2] 2 State: 7 [!0&!1&2] 8 State: 8 [0&!1&!2]
9 State: 9 [!0&1&!2] 7 [!0&1&!2] 6 --END-- HOA: v1 States: 10 Start: 0 AP:
3 "p0" "p1" "p2" acc-name: all Acceptance: 0 t properties: trans-labels
explicit-labels state-acc --BODY-- State: 0 [!0&!1&2] 1 State: 1 [!0&!1&2]
2 State: 2 [0&1&!2] 3 State: 3 [!0&1&!2] 4 State: 4 [!0&1&2] 5 State:
5 [0&!1&!2] 6 State: 6 [!0&!1&!2] 5 [!0&!1&!2] 7 State: 7 [!0&!1&!2] 7
[!0&!1&2] 6 [0&!1&2] 8 State: 8 [0&1&2] 8 [0&1&!2] 9 State: 9 [0&!1&2]
2 --END-- HOA: v1 States: 10 Start: 0 AP: 3 "p0" "p1" "p2" acc-name:
all Acceptance: 0 t properties: trans-labels explicit-labels state-acc
deterministic --BODY-- State: 0 [!0&!1&2] 1 State: 1 [0&!1&!2] 2 State: 2
[!0&!1&2] 3 State: 3 [!0&!1&!2] 4 State: 4 [!0&1&!2] 5 State: 5 [!0&1&2]
6 State: 6 [0&1&!2] 1 [!0&!1&!2] 3 [!0&1&2] 7 State: 7 [0&1&2] 8 State:
8 [0&!1&!2] 7 [0&1&!2] 9 State: 9 [0&1&2] 0 --END-- HOA: v1 States: 10
Start: 0 AP: 3 "p0" "p1" "p2" acc-name: all Acceptance: 0 t properties:
trans-labels explicit-labels state-acc deterministic --BODY-- State: 0
[0&1&!2] 1 State: 1 [!0&1&2] 2 State: 2 [0&1&2] 3 State: 3 [0&1&!2] 4
State: 4 [!0&!1&2] 5 State: 5 [!0&!1&!2] 6 State: 6 [!0&1&!2] 7 State: 7
[!0&!1&!2] 3 [!0&1&2] 8 State: 8 [0&!1&2] 9 State: 9 [!0&!1&!2] 9 [0&!1&2]
3 [!0&1&!2] 2 --END-- HOA: v1 States: 10 Start: 0 AP: 3 "p0" "p1" "p2"
acc-name: all Acceptance: 0 t properties: trans-labels explicit-labels
state-acc --BODY-- State: 0 [0&!1&!2] 1 State: 1 [!0&!1&2] 2 [0&!1&2] 3
State: 2 [0&!1&2] 4 State: 3 [0&!1&!2] 5 [0&!1&!2] 6 State: 4 [0&!1&!2] 7
[0&!1&2] 3 State: 5 [!0&!1&!2] 8 State: 6 [!0&!1&2] 4 [0&!1&2] 6 State: 7
[0&!1&2] 4 [!0&!1&!2] 1 State: 8 [!0&1&2] 6 [0&1&2] 9 State: 9 [0&1&!2]
3 --END-- HOA: v1 States: 10 Start: 0 AP: 3 "p0" "p1" "p2" acc-name:
all Acceptance: 0 t properties: trans-labels explicit-labels state-acc
--BODY-- State: 0 [!0&1&2] 1 State: 1 [!0&!1&!2] 2 [!0&!1&2] 3 [!0&1&2]
4 [!0&1&2] 5 State: 2 [0&1&!2] 2 [0&!1&2] 6 State: 3 [0&1&2] 3 [0&!1&2] 7
[!0&1&2] 2 State: 4 [!0&!1&!2] 8 State: 5 [0&!1&!2] 2 [!0&!1&2] 6 State:
6 [!0&!1&2] 2 [!0&1&!2] 7 State: 7 [0&1&2] 9 State: 8 [!0&1&2] 7 State:
9 [!0&1&2] 2 --END-- HOA: v1 States: 10 Start: 0 AP: 3 "p0" "p1" "p2"
acc-name: all Acceptance: 0 t properties: trans-labels explicit-labels
state-acc deterministic --BODY-- State: 0 [!0&!1&!2] 1 State: 1 [0&1&!2] 2
[!0&!1&!2] 3 [0&!1&2] 4 State: 2 [0&1&!2] 5 State: 3 [!0&!1&!2] 6 State:
4 [!0&!1&!2] 7 State: 5 [!0&1&2] 2 State: 6 [!0&!1&2] 8 State: 7 [0&1&2]
9 State: 8 [0&!1&!2] 7 State: 9 [!0&1&!2] 1 [0&1&!2] 7 --END--
EOF

expectok input --is-deter --stats='%F:%L: %c' <<EOF
input:1.1-6.53: 2
input:6.55-12.28: 2
input:12.30-18.62: 5
input:30.11-35.51: 1
input:35.53-41.21: 3
input:53.22-58.62: 3
EOF

expectok input -v --is-deter --stats='%F:%L: %n' <<EOF
input:18.64-24.42: 2
input:24.44-30.9: 1
input:41.23-47.9: 1
input:47.11-53.20: 1
EOF
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349

# An example from ltl3ba
cat >input <<EOF
HOA: v1
tool: "ltl3ba" "1.1.0 - working copy"
name: "BA for GFa && GF(b&&c) && GF(d||e) || x"
States: 6
Start: 0
acc-name: Buchi
Acceptance: 1 Inf(0)
AP: 6 "a" "b" "c" "d" "e" "x"
properties: trans-labels explicit-labels state-acc no-univ-branch
--BODY--
State: 0 "T0_init"
 [(5)] 5
 [t] 4
 [(0)] 3
 [(0 & 1 & 2)] 2
 [(0 & 1 & 2 & !3 & 4) | (0 & 1 & 2 & 3)] 1
State: 1 "accept_S1" {0}
 [t] 4
 [(0)] 3
 [(0 & 1 & 2)] 2
 [(0 & 1 & 2 & !3 & 4) | (0 & 1 & 2 & 3)] 1
State: 2 "T2_S1"
 [t] 2
 [(!3 & 4) | (3)] 1
State: 3 "T1_S1"
 [t] 3
 [(1 & 2)] 2
 [(1 & 2 & !3 & 4) | (1 & 2 & 3)] 1
State: 4 "T0_S1"
 [t] 4
 [(0)] 3
 [(0 & 1 & 2)] 2
 [(0 & 1 & 2 & !3 & 4) | (0 & 1 & 2 & 3)] 1
State: 5 "accept_all" {0}
 [t] 5
--END--
EOF

expectok input <<EOF
HOA: v1
name: "BA for GFa && GF(b&&c) && GF(d||e) || x"
States: 6
Start: 0
AP: 6 "a" "b" "c" "d" "e" "x"
acc-name: Buchi
Acceptance: 1 Inf(0)
properties: trans-labels explicit-labels state-acc complete
--BODY--
1350
State: 0 "T0_init"
1351
1352
1353
1354
1355
[5] 5
[t] 4
[0] 3
[0&1&2] 2
[0&1&2&3 | 0&1&2&4] 1
1356
State: 1 "accept_S1" {0}
1357
1358
1359
1360
[t] 4
[0] 3
[0&1&2] 2
[0&1&2&3 | 0&1&2&4] 1
1361
State: 2 "T2_S1"
1362
1363
[t] 2
[3 | 4] 1
1364
State: 3 "T1_S1"
1365
1366
1367
[t] 3
[1&2] 2
[1&2&3 | 1&2&4] 1
1368
State: 4 "T0_S1"
1369
1370
1371
1372
[t] 4
[0] 3
[0&1&2] 2
[0&1&2&3 | 0&1&2&4] 1
1373
State: 5 "accept_all" {0}
1374
1375
1376
[t] 5
--END--
EOF
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418

# Another example from ltl3ba
# Here we make sure that we do not always need to create a fake
# initial state when multiple initial states are used.
cat >input <<EOF
HOA: v1
tool: "ltl3ba" "1.1.0 - working copy"
name: "TGBA for GFa && GF(b&&c) && GF(d||e) || x"
States: 3
Start: 0
Start: 2
acc-name: generalized-Buchi 3
Acceptance: 3 Inf(0) & Inf(1) & Inf(2)
AP: 6 "a" "b" "c" "d" "e" "x"
properties: trans-labels explicit-labels trans-acc no-univ-branch
--BODY--
State: 0 "(x)"
 [(5)] 1 {0 1 2}
State: 1 "t"
 [t] 1 {0 1 2}
State: 2 "G((F(a) && F((b) && (c))) && F((d) || (e)))"
 [t] 2
 [(0)] 2 {0}
 [(1 & 2)] 2 {1}
 [(0 & 1 & 2)] 2 {0 1}
 [(!3 & 4) | (3)] 2 {2}
 [(0 & !3 & 4) | (0 & 3)] 2 {0 2}
 [(1 & 2 & !3 & 4) | (1 & 2 & 3)] 2 {1 2}
 [(0 & 1 & 2 & !3 & 4) | (0 & 1 & 2 & 3)] 2 {0 1 2}
--END--
EOF

expectok input <<EOF
HOA: v1
name: "TGBA for GFa && GF(b&&c) && GF(d||e) || x"
States: 3
Start: 0
AP: 6 "a" "b" "c" "d" "e" "x"
acc-name: generalized-Buchi 3
Acceptance: 3 Inf(0)&Inf(1)&Inf(2)
properties: trans-labels explicit-labels trans-acc complete
--BODY--
1419
State: 0 "(x)"
1420
1421
1422
1423
1424
1425
1426
1427
1428
[5] 1 {0 1 2}
[t] 2
[0] 2
[1&2] 2
[0&1&2] 2
[3 | 4] 2
[0&3 | 0&4] 2
[1&2&3 | 1&2&4] 2
[0&1&2&3 | 0&1&2&4] 2
1429
State: 1 "t"
1430
[t] 1 {0 1 2}
1431
State: 2 "G((F(a) && F((b) && (c))) && F((d) || (e)))"
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
[t] 2
[0] 2 {0}
[1&2] 2 {1}
[0&1&2] 2 {0 1}
[3 | 4] 2 {2}
[0&3 | 0&4] 2 {0 2}
[1&2&3 | 1&2&4] 2 {1 2}
[0&1&2&3 | 0&1&2&4] 2 {0 1 2}
--END--
EOF
1442
1443


1444
# named states can be output as comments in never claim
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
cat >input <<EOF
HOA: v1
name: "a U b"
States: 2
Start: 1
AP: 2 "a" "b"
acc-name: Buchi
Acceptance: 1 Inf(0)
properties: trans-labels explicit-labels state-acc deterministic
--BODY--
State: 0 "s0" {0}
[t] 0
State: 1 "s1"
[1] 0
[0&!1] 1
--END--
EOF
expectok input --spin=c <<EOF
never { /* a U b */
T0_init: /* s1 */
  if
1466
  :: (b) -> goto accept_all
1467
1468
1469
1470
1471
1472
  :: ((a) && (!(b))) -> goto T0_init
  fi;
accept_all: /* s0 */
  skip
}
EOF
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516


# ltl3ba 1.1.1 has a bug where it outputs
#   Acceptance: 1 t
# when it meant
#   Acceptance: 1 Inf(0)
# and a development version of our parser would
# incorrectly interpret the former as the latter.

cat >input <<EOF
HOA: v1
tool: "ltl3ba" "1.1.1"
name: "TGBA for Fa"
States: 2
Start: 0
acc-name: generalized-Buchi 1
Acceptance: 1 t
AP: 1 "a"
properties: trans-labels explicit-labels trans-acc no-univ-branch
--BODY--
State: 0 "F(a)"
 [(0)] 1 {0}
 [(!0)] 0
State: 1 "t"
 [t] 1 {0}
--END--
/* Also try with more acceptance sets */
HOA: v1
States: 1
Start: 0
AP: 3 "a" "b" "c"
Acceptance: 5 Inf(0)&Inf(4)&Inf(2)&Inf(!2)
properties: trans-labels explicit-labels trans-acc complete deterministic
--BODY--
State: 0
[0&1&2] 0 {0 4 2}
[!0&1&2] 0 {4 2}
[0&!1&2] 0 {0 2}
[!0&!1&2] 0 {2}
[0&1&!2] 0 {0 4}
[!0&1&!2] 0 {4}
[0&!1&!2] 0 {0}
[!0&!1&!2] 0
--END--
1517
1518
1519
1520
HOA: v1
States: 2
Start: 0
AP: 2 "a" "b"
1521
acc-name: Rabin 2
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
Acceptance: 4 (Fin(0) & Inf(1)) | (Fin(2) & Inf(3))
properties: trans-labels explicit-labels state-acc deterministic
--BODY--
State: 0 {2}
[0&!1] 1
[!0&1] 0
[0&1] 1
State: 1 {1 2}
[!0&!1] 1
[0&!1] 1
[!0&1] 1
[0&1] 1
--END--
1535
1536
EOF

1537
expectok input -v --is-empty <<EOF
1538
1539
1540
1541
1542
HOA: v1
name: "TGBA for Fa"
States: 2
Start: 0
AP: 1 "a"
1543
Acceptance: 1 t
1544
1545
properties: trans-labels explicit-labels trans-acc complete
properties: deterministic
1546
1547
--BODY--
State: 0 "F(a)"
1548
[0] 1 {0}
1549
1550
[!0] 0
State: 1 "t"
1551
[t] 1 {0}
1552
1553
1554
1555
1556
--END--
HOA: v1
States: 1
Start: 0
AP: 3 "a" "b" "c"
1557
Acceptance: 6 Inf(0)&Inf(2)&Inf(4)&Inf(5)
1558
1559
properties: trans-labels explicit-labels trans-acc complete
properties: deterministic
1560
1561
--BODY--
State: 0
1562
1563
1564
1565
1566
1567
1568
1569
[0&1&2] 0 {0 2 4}
[!0&1&2] 0 {2 4}
[0&!1&2] 0 {0 2}
[!0&!1&2] 0 {2}
[0&1&!2] 0 {0 4 5}
[!0&1&!2] 0 {4 5}
[0&!1&!2] 0 {0 5}
[!0&!1&!2] 0 {5}
1570
--END--
1571
1572
1573
1574
HOA: v1
States: 2
Start: 0
AP: 2 "a" "b"
1575
acc-name: Rabin 2
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
Acceptance: 4 (Fin(0) & Inf(1)) | (Fin(2) & Inf(3))
properties: trans-labels explicit-labels state-acc deterministic
--BODY--
State: 0 {2}
[0&!1] 1
[!0&1] 0
[0&1] 1
State: 1 {1 2}
[!0&!1] 1
[0&!1] 1
[!0&1] 1
[0&1] 1
--END--
1589
EOF
1590
1591


1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
# Test removal of useless acceptance sets

# The mapping of acceptance sets for the second automaton is
#   input   ->  output
#     0     ->    0
#     1     ->   removed
#     2     ->    1
#     3     ->   removed
#     4     ->    2
#    !2     ->    3
expectok input --cleanup-acc <<EOF
HOA: v1
name: "TGBA for Fa"
States: 2
Start: 0
AP: 1 "a"
acc-name: all
Acceptance: 0 t
1610
1611
properties: trans-labels explicit-labels state-acc complete
properties: deterministic
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
--BODY--
State: 0 "F(a)"
[0] 1
[!0] 0
State: 1 "t"
[t] 1
--END--
HOA: v1
States: 1
Start: 0
AP: 3 "a" "b" "c"
acc-name: generalized-Buchi 4
Acceptance: 4 Inf(0)&Inf(1)&Inf(2)&Inf(3)
1625
1626
properties: trans-labels explicit-labels trans-acc complete
properties: deterministic
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
--BODY--
State: 0
[0&1&2] 0 {0 1 2}
[!0&1&2] 0 {1 2}
[0&!1&2] 0 {0 1}
[!0&!1&2] 0 {1}
[0&1&!2] 0 {0 2 3}
[!0&1&!2] 0 {2 3}
[0&!1&!2] 0 {0 3}
[!0&!1&!2] 0 {3}
--END--
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
HOA: v1
States: 2
Start: 0
AP: 2 "a" "b"
acc-name: Buchi
Acceptance: 1 Inf(0)
properties: trans-labels explicit-labels state-acc deterministic
--BODY--
State: 0
[0&!1] 1
[!0&1] 0
[0&1] 1
State: 1 {0}
[!0&!1] 1
[0&!1] 1
[!0&1] 1
[0&1] 1
--END--
1656
EOF
1657
1658
1659
1660


# Implicit labels

1661
1662
1663
1664
1665
1666
1667
1668
1669
../../bin/ltl2tgba -H 'GFa & GFb & (c U d)' >out.hoa
../../bin/ltl2tgba -C -Hi 'GFa & GFb & (c U d)' >out-i.hoa
../../bin/autfilt -C -Hi out.hoa --name=%M >out-i2.hoa
diff -u out-i.hoa out-i2.hoa
sed 's/ stutter-invariant//;/properties:$/d' <out-i.hoa >out-i3.hoa
../../bin/autfilt --trust-hoa=no -C -Hi out.hoa --name=%M >out-i2.hoa
diff -u out-i3.hoa out-i2.hoa


1670
1671
1672
1673
1674
1675
1676
1677
1678
1679

cat >expected <<EOF
HOA: v1
name: "(c U d) & G(Fa & Fb)"
States: 3
Start: 1
AP: 4 "c" "d" "a" "b"
acc-name: generalized-Buchi 2
Acceptance: 2 Inf(0)&Inf(1)
properties: implicit-labels trans-acc complete deterministic
1680
properties: stutter-invariant
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
--BODY--
State: 0
0
0
0
0
0 {0}
0 {0}
0 {0}
0 {0}
0 {1}
0 {1}
0 {1}
0 {1}
0 {0 1}
0 {0 1}
0 {0 1}
0 {0 1}
State: 1
2
1
0
0
2
1
0
0
2
1
0
0
2
1
0
0
State: 2
2
2
2
2
2
2
2
2
2
2