hoaparse.test 24 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 >$1.out && exit 1
30
31
32
33
34
   test $? = 2
   cat $1.err
   diff $1.err $1.exp
}

35
36
37
expectok()
{
   cat >$1.exp
38
   ../../bin/autfilt --hoa "$@" >$1.out
39
40
41
42
43
   test $? = 0
   cat $1.out
   diff $1.out $1.exp
}

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
69
70
71
72
73
74
75
76

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--
77
78
79
80
81
82
83
84
2 1t
2 1
1 -1 "b"
0 -1 & "a" ! "b"
-1
1 0
2 0 -1 t
-1
85
86
87
88
89
90
91
92
93
EOF

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.
94
95
96
97
input:13.1: state number is larger than state count...
input:12.1: ... declared here.
input:18.1: state number is larger than state count...
input:12.1: ... declared here.
98
99
EOF

100
101
102
103
104
105
106
107
cat >input <<EOF
HOA: v1
States: 1
Start: 0
AP: 1 "a"
Acceptance: 1 Inf(0)
--BODY--
State: 0 {0}
108
[2] 0
109
110
111
112
113
114
State: 0 {0}
[t] 0
--END--
EOF

expecterr input <<EOF
115
116
input:8.2: AP number is larger than the number of APs...
input:4.1-5: ... declared here
117
118
119
input:9.1-8: redeclaration of state 0
EOF

120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
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
144
145
input:4.1-3: ignoring this redeclaration of APs...
input:2.1-5: ... previously declared here.
146
147
148
149
150
151
152
153
EOF

cat >input <<EOF
HOA: v1
AP: 1 "a"
States: 0
Start: 1
--BODY--
154
155
State: 0 {0 1}
[0] 0 {0}
156
157
158
159
--END--
EOF

expecterr input <<EOF
160
input:4.1-8: initial state number is larger than state count...
161
162
input:3.1-9: ... declared here.
input:1.1-4.8: missing 'Acceptance:' header
163
164
165
166
167
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.
168
169
170
171
172
EOF

cat >input <<EOF
HOA: v1
AP: 1 "a"
173
174
Start: 1
States: 1
175
176
177
178
179
180
181
--BODY--
--END--
EOF

expecterr input <<EOF
input:3.1-8: initial state number is larger than state count...
input:4.1-9: ... declared here.
182
input:1.1-4.9: missing 'Acceptance:' header
183
184
185
186
187
188
189
190
191
192
193
194
195
EOF

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

expecterr input <<EOF
196
input:5.1-13: ignoring this redefinition of the acceptance condition...
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
input:2.1-13: ... previously defined here.
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

219
# Let's have two broken automata in a row...
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
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--
EOF

expecterr input <<EOF
238
239
input:5.19: number is larger than the count of acceptance sets...
input:5.1-13: ... declared here.
240
input:12.6-7: unsupported version of the HOA format
241
input:12.1-7: missing 'Acceptance:' header
242
EOF
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

cat >input<<EOF
    HOA: v1
    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)
properties: trans-labels explicit-labels state-acc complete deterministic
--BODY--
State: 0 {0}
274
[!0&!1] 2
275
[0&!1] 0
276
277
278
[!0&1] 1
[0&1] 1
State: 1 {1}
279
280
281
282
[!0&!1] 1
[0&!1] 1
[!0&1] 1
[0&1] 1
283
State: 2 {0}
284
285
286
287
288
289
290
291
292
293
294
295
296
297
[!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"
298
    properties: state-labels complete
299
300
301
302
303
304
305
306
307
308
309
    --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--
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
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--
328
329
330
EOF

expecterr input <<EOF
331
332
333
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'
334
335
336
337
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
338
339
340
341
EOF

cat >input<<EOF
    HOA: v1
342
    tool: "test"
343
344
345
346
    States: 3
    Start: 0
    acc-name: generalized-Buchi 2
    Acceptance: 2 (Inf(0) & Inf(1))
347
    properties: implicit-labels explicit-labels /* ? */ complete
348
349
350
351
352
353
354
355
356
357
358
359
360
    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--
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
    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))
    properties: implicit-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 }
      [t] 2
    --END--
399
400
401
EOF

expecterr input <<EOF
402
403
404
405
406
407
408
input:7.17-31: 'property: implicit-labels' is incompatible with...
input:7.33-47: ... 'property: explicit-labels'.
input:15.7: too many transition for this state, ignoring this one
input:27.33-44: 'property: state-labels' is incompatible with...
input:27.17-31: ... 'property: implicit-labels'.
input:57.7-9: transition label used although the automaton was...
input:46.17-31: ... declared with 'property: implicit-labels' here
409
EOF
Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
410
411
412
413
414
415
416
417
418
419
420
421


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 */
422
    properties: state-labels /* this is bogus */
Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
423
424
425
426
427
428
429
430
431
432
433
    --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
434
435
436
input:13.13-15: unknown alias @bc
input:13.5-16: transition label used although the automaton was...
input:10.17-28: ... declared with 'property: state-labels' here
Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
437
input:14.12-14: unknown alias @bc
438
439
input:15.12-14: unknown alias @bc
input:16.11-13: unknown alias @bc
Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
440
441
442
443
444
445
446
EOF

cat >input <<EOF
    HOA: v1
    name: "GFa & GF(b & c)"
    States: 1
    Start: 0
447
    acc-name: who cares
Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
448
449
450
451
452
453
454
455
456
457
458
    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--
459
/* Some comment */
460
461
462
463
464
465
466
467
468
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
469
470
471
472
EOF

expectok input <<EOF
HOA: v1
473
name: "GFa & GF(b & c)"
Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
474
475
476
477
478
479
480
481
482
483
484
485
486
States: 1
Start: 0
AP: 3 "a" "b" "c"
acc-name: generalized-Buchi 2
Acceptance: 2 Inf(0)&Inf(1)
properties: trans-labels explicit-labels trans-acc complete deterministic
--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--
487
488
489
490
491
492
493
494
495
496
497
498
499
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
500
EOF
Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
501

502
503
504
505
506
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
507
508
cat >input <<EOF
HOA: v1
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
--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
525
States: 2
526
name: "survivor"
Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
527
528
529
530
531
532
533
534
535
536
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
537
[f] 0
Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
538
539
540
--END--
EOF

541
542
543
544
545
546
547
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

548
# DOS-style new lines should have the same output.
549
perl -pi -e 's/$/\r/' input
550
551
552
553
../../bin/autfilt --hoa input 2>stderr && exit 1
cat stderr
diff stderr input.exp

554
cat >expected <<EOF
Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
555
HOA: v1
556
name: "survivor"
Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
States: 2
Start: 0
AP: 1 "a"
acc-name: generalized-Buchi 3
Acceptance: 3 Inf(0)&Inf(1)&Inf(2)
properties: trans-labels explicit-labels trans-acc complete deterministic
--BODY--
State: 0
[0] 1 {0 1}
[!0] 0 {0}
State: 1
[!0] 1 {1 2}
[0] 0 {1 2}
--END--
EOF
572
573

diff expected input.out
574

575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
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
619

620
# Mix HOA with neverclaims and LBTT automata
621
622
623
624
625
626
cat >input <<EOF
HOA: v1
States: 2
Start: 0
Start: 1
Start: 0 /* duplicate */
627
AP: 2 "a" "\"b\""
628
629
630
631
632
633
634
635
636
Acceptance: 1 Inf(0)
--BODY--
State: 0 {0}
[1] 1
[!1] 0
State: 1
[!0] 1
[0] 0
--END--
637

638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
/* 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


661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
never  {    /* a U b */
T0_init:
        if
        :: ((b)) -> goto accept_all
        :: ((a)) -> goto T0_init
        fi;
accept_all:
        skip
}


never {
  start: if :: false -> goto T0 fi;
  T0: false
}
676
677
678
679
680
EOF

expectok input <<EOF
HOA: v1
States: 3
681
Start: 2
682
AP: 2 "a" "\"b\""
683
684
685
686
acc-name: Buchi
Acceptance: 1 Inf(0)
properties: trans-labels explicit-labels state-acc complete
--BODY--
687
State: 0 {0}
688
[1] 1
689
[!1] 0
690
691
State: 1
[!0] 1
692
693
[0] 0
State: 2
694
[1] 1
695
696
697
[!1] 0
[!0] 1
[0] 0
698
--END--
699
HOA: v1
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
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
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
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--
748
749
750
751
752
753
754
755
756
757
758
759
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
760
[!1] 0  /* nested /* comment */ */
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
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)
properties: trans-labels explicit-labels state-acc complete deterministic
--BODY--
State: 0 {0}
[1] 1
[!1] 0
State: 1
[!0] 1
[0] 0
--END--
EOF
784

785
786
787
788
cat >input <<EOF
HOA: v1
States: 3
Start: 0
789
790
791
AP: 2 "a" "b"/* multi
line
comment */
792
793
794
795
796
797
798
799
800
801
802
803
804
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--
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
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--
832
833
834
EOF

expecterr input <<EOF
835
836
837
838
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
839
840
841
842
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'.
843
844
EOF

845
846
847

cat >input <<EOF
HOA: v1
848
849
850
States: /* multi-line
comment
*/2
851
Start: 0
852
853
Important: 4 very important "with multi-line
string!"
854
855
856
857
858
859
860
861
862
AP: 0
Acceptance: 1 Inf(0)
--BODY--
State: 0 {0} 1
State: 1 0
--END--
EOF

expecterr input <<EOF
863
input:6.1-7.8: ignoring unsupported header "Important:"
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
	(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)
properties: trans-labels explicit-labels state-acc complete deterministic
--BODY--
State: 0 {0}
[t] 1
State: 1
[t] 0
--END--
EOF

diff expected input.out
884

885
# DOS-style new lines should have the same output.
886
perl -pe -e 's/$/\r/' input
887
888
889
890
../../bin/autfilt --hoa input 2>stderr && exit 1
cat stderr
diff stderr input.exp
diff expected input.out
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935

# 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
EOF

936
se='syntax error, unexpected'  # this is just to keep lines short
937
end='end of file or HOA: or never or LBTT header'
938
expecterr input <<EOF
939
input:8.11: $se identifier, expecting integer or '}'
940
input:8.10-12: ignoring this invalid acceptance set
941
input:11.2: $se identifier
942
input:11.1-3: ignoring this invalid label
943
input:21.5-7: $se string, expecting integer
944
input:25.1: $se \$undefined, expecting $end
945
input:25.1-12: ignoring leading garbage
946
input:32.1-5: $se header name, expecting --END-- or State:
947
input:37.1: $se 't', expecting $end
948
autfilt: failed to read automaton from input
949
EOF
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
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

# 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
1016
1017
input:4.7-26.1: unclosed string
input:26.1: syntax error, unexpected end of file
1018
1019
autfilt: failed to read automaton from input
EOF
1020
1021
1022
1023

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

1025
1026
1027
run 2 ../ltl2tgba -XH foob 2>output.err
grep 'foob:1.1: Cannot open file foob' output.err

1028
1029
1030
1031
# Make sure we can read multiple automata from stdin
../../bin/ltl2tgba 'a U b' 'GFa' --hoa | grep -v '^name:' > input
../../bin/autfilt --hoa < input | ../../bin/autfilt --hoa > output
diff input output
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053



# 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

run 0 ../ltl2tgba -d -XH input 2> output.err
grep -- "--BODY--" output.err
grep "identifier.*v1" output.err
1054
1055
1056
1057
1058
1059
1060
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
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134



# 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
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
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212

# 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--
State: 0
[5] 5
[t] 4
[0] 3
[0&1&2] 2
[0&1&2&3 | 0&1&2&4] 1
State: 1 {0}
[t] 4
[0] 3
[0&1&2] 2
[0&1&2&3 | 0&1&2&4] 1
State: 2
[t] 2
[3 | 4] 1
State: 3
[t] 3
[1&2] 2
[1&2&3 | 1&2&4] 1
State: 4
[t] 4
[0] 3
[0&1&2] 2
[0&1&2&3 | 0&1&2&4] 1
State: 5 {0}
[t] 5
--END--
EOF