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

set -e

25
26
ltl2tgba=ltl2tgba
autfilt=autfilt
27
28
29
30
31
32
33
34
35
36

$ltl2tgba 'GFa & GFb' -H | run 0 $autfilt --sbacc -H > out.hoa

cat >expected<<EOF
HOA: v1
States: 4
Start: 0
AP: 2 "a" "b"
acc-name: generalized-Buchi 2
Acceptance: 2 Inf(0)&Inf(1)
37
properties: trans-labels explicit-labels state-acc complete
38
properties: deterministic stutter-invariant
39
--BODY--
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
State: 0 {0}
[0&!1] 0
[0&1] 1
[!0&!1] 2
[!0&1] 3
State: 1 {0 1}
[0&!1] 0
[0&1] 1
[!0&!1] 2
[!0&1] 3
State: 2
[0&!1] 0
[0&1] 1
[!0&!1] 2
[!0&1] 3
State: 3 {1}
[0&!1] 0
[0&1] 1
[!0&!1] 2
[!0&1] 3
60
61
62
63
64
--END--
EOF

diff out.hoa expected

65
# This procedure should be acceptance-agnostic.
66
67
68
69
cat >in.hoa<<EOF
HOA: v1
Start: 0
AP: 1 "a"
70
Acceptance: 2 Fin(0)|Inf(1)
71
72
73
74
75
76
77
78
--BODY--
State: 0
[0] 1
State: 1 {0}
[0] 2
State: 2
[0] 0 {1}
--END--
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/* The following example used to be converted into a
   3-state automaton instead of just 2 states, due to
   a typo in the code. */
HOA: v1
States: 2
Start: 1
AP: 2 "a" "b"
Acceptance: 2 Fin(0) & Inf(1)
--BODY--
State: 0
[t] 0 {0}
State: 1
[1] 0
[0&!1] 1 {1}
--END--

95
96
97
98
99
100
101
102
103
EOF

run 0 $autfilt --state-based-acceptance in.hoa -H > out.hoa

cat >expected <<EOF
HOA: v1
States: 3
Start: 0
AP: 1 "a"
104
acc-name: Streett 1
105
Acceptance: 2 Fin(0) | Inf(1)
106
107
108
109
properties: trans-labels explicit-labels state-acc deterministic
--BODY--
State: 0 {1}
[0] 1
110
State: 1 {0}
111
[0] 2
112
State: 2 {0 1}
113
114
[0] 0
--END--
115
116
117
118
119
120
121
122
123
124
125
126
127
128
HOA: v1
States: 2
Start: 0
AP: 2 "a" "b"
acc-name: Rabin 1
Acceptance: 2 Fin(0) & Inf(1)
properties: trans-labels explicit-labels state-acc deterministic
--BODY--
State: 0 {1}
[0&!1] 0
[1] 1
State: 1
[t] 1
--END--
129
130
131
132
133
134
135
EOF

diff out.hoa expected

$autfilt --sba -H expected > out.hoa
diff out.hoa expected

136
$autfilt --strip-acc -H expected -n1 > out.hoa
137
138
139
140
141
142
143
cat >expected <<EOF
HOA: v1
States: 3
Start: 0
AP: 1 "a"
acc-name: all
Acceptance: 0 t
144
properties: trans-labels explicit-labels state-acc deterministic weak
145
146
147
148
149
150
151
152
153
154
--BODY--
State: 0
[0] 1
State: 1
[0] 2
State: 2
[0] 0
--END--
EOF
diff out.hoa expected
155

156
randltl --weak-fairness -n 20 2 |
157
158
159
160
161
    ltlcross "$ltl2tgba -DH %f >%O" \
             "$ltl2tgba -S %f >%O" \
             "$ltl2tgba -H %f | $autfilt -H >%O"

test 4 = `ltl2tgba -S 'F(a & X(!a &Xb))' --any --stats=%s`
162
163
164
165
166
167
168
169
170
171
172
173
174
175
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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226


# Test case from Thibaud Michaud.  This used to fail, because sbacc()
# would remove acceptance marks from all rejecting SCCS...
cat >tm.hoa <<EOF
HOA: v1
States: 5
Start: 1
AP: 4 "req" "go" "ack" "cancel"
acc-name: parity max odd 3
Acceptance: 3 Fin(2) & (Inf(1) | Fin(0))
properties: trans-labels explicit-labels trans-acc colored complete
properties: deterministic
--BODY--
State: 0
[t] 1 {0}
State: 1
[!0] 0 {0}
[0] 2 {0}
State: 2
[2] 1 {0}
[!2] 3 {0}
State: 3
[t] 4 {0}
State: 4
[2] 1 {2}
[!2] 3 {1}
--END--
EOF
autfilt --sbacc tm.hoa > out.hoa
autfilt -q --equivalent-to out.hoa tm.hoa

# Tautological acceptances are converted to "t"
cat >taut.hoa <<EOF
HOA: v1
States: 2
Start: 1
AP: 0
Acceptance: 2 Fin(0) | Inf(0) | Fin(1)
--BODY--
State: 0
[t] 1 {0}
State: 1
[t] 0
[t] 1 {1}
--END--
EOF
cat >expect.hoa <<EOF
HOA: v1
States: 2
Start: 1
AP: 0
acc-name: all
Acceptance: 0 t
properties: trans-labels explicit-labels state-acc complete weak
--BODY--
State: 0
[t] 1
State: 1
[t] 0
[t] 1
--END--
EOF
autfilt --sbacc taut.hoa > out.hoa
diff out.hoa expect.hoa