reduccmp.test 9.23 KB
Newer Older
1
#! /bin/sh
2
# Copyright (C) 2009, 2010, 2011, 2012 Laboratoire de Recherche et Developpement
Guillaume Sadegh's avatar
Guillaume Sadegh committed
3
4
# de l'Epita (LRDE).
# Copyright (C) 2004, 2006 Laboratoire d'Informatique de Paris 6 (LIP6),
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# dpartement Systmes Rpartis Coopratifs (SRC), Universit Pierre
# et Marie Curie.
#
# 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 2 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 Spot; see the file COPYING.  If not, write to the Free
# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.


26
# Check LTL reductions
27
28
29

. ./defs || exit 1

30
for x in ../reduccmp ../reductaustr; do
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45

  # No reduction
  run 0 $x 'a U b' 'a U b'
  run 0 $x 'a R b' 'a R b'
  run 0 $x 'a & b' 'a & b'
  run 0 $x 'a | b' 'a | b'
  run 0 $x 'a & (a U b)' 'a & (a U b)'
  run 0 $x 'a | (a U b)' 'a | (a U b)'

  # Syntactic reduction
  run 0 $x 'a & (!b R !a)' 'false'
  run 0 $x '(!b R !a) & a' 'false'
  run 0 $x 'a & (!b R !a) & c' 'false'
  run 0 $x 'c & (!b R !a) & a' 'false'

46
47
48
49
50
  run 0 $x 'a & (!b M !a)' 'false'
  run 0 $x '(!b M !a) & a' 'false'
  run 0 $x 'a & (!b M !a) & c' 'false'
  run 0 $x 'c & (!b M !a) & a' 'false'

51
52
53
54
55
56
  run 0 $x 'a & (b U a)' 'a'
  run 0 $x '(b U a) & a' 'a'
  run 0 $x 'a | (b U a)' '(b U a)'
  run 0 $x '(b U a) | a' '(b U a)'
  run 0 $x 'a U (b U a)' '(b U a)'

57
58
59
60
61
62
  run 0 $x 'a & (b W a)' 'a'
  run 0 $x '(b W a) & a' 'a'
  run 0 $x 'a | (b W a)' '(b W a)'
  run 0 $x '(b W a) | a' '(b W a)'
  run 0 $x 'a W (b W a)' '(b W a)'

63
64
65
66
67
68
  run 0 $x 'a & (b U a) & a' 'a'
  run 0 $x 'a & (b U a) & a' 'a'
  run 0 $x 'a | (b U a) | a' '(b U a)'
  run 0 $x 'a | (b U a) | a' '(b U a)'
  run 0 $x 'a U (b U a)' '(b U a)'

69
70
71
72
73
  run 0 $x 'a <-> !a' '0'
  run 0 $x 'a <-> a' '1'
  run 0 $x 'a ^ a' '0'
  run 0 $x 'a ^ !a' '1'

74
75
76
77
78
  run 0 $x 'GFa | FGa' 'GFa'
  run 0 $x 'XXGa | GFa' 'GFa'
  run 0 $x 'GFa & FGa' 'FGa'
  run 0 $x 'XXGa & GFa' 'XXGa'

79
  # Basic reductions
80
81
82
83
84
85
  run 0 $x 'X(true)' 'true'
  run 0 $x 'X(false)' 'false'
  run 0 $x 'F(true)' 'true'
  run 0 $x 'F(false)' 'false'

  run 0 $x 'XGF(f)' 'GF(f)'
86

87
88
89
  case $x in
   *tau*);;
   *)
90
91
92
93
94
95
96
97
     run 0 $x 'G(true)' 'true'
     run 0 $x 'G(false)' 'false'

     run 0 $x 'a M 1' 'Fa'
     run 0 $x 'a W 0' 'Ga'
     run 0 $x '1 U a' 'Fa'
     run 0 $x '0 R a' 'Ga'

98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
     run 0 $x 'G(a R b)' 'G(b)'

     run 0 $x 'FX(a)' 'XF(a)'
     run 0 $x 'GX(a)' 'XG(a)'

     run 0 $x 'X(a) U X(b)' 'X(a U b)'
     run 0 $x 'X(a) R X(b)' 'X(a R b)'
     run 0 $x 'Xa & Xb' 'X(a & b)'
     run 0 $x 'Xa | Xb' 'X(a | b)'

     run 0 $x '(a U b) & (c U b)' '(a & c) U b'
     run 0 $x '(a R b) & (a R c)' 'a R (b & c)'
     run 0 $x '(a U b) | (a U c)' 'a U (b | c)'
     run 0 $x '(a R b) | (c R b)' '(a | c) R b'

113
     run 0 $x 'Xa & FGb' 'X(a & FGb)'
114
115
     run 0 $x 'Xa | FGb' 'X(a | FGb)'
     run 0 $x 'Xa & GFb' 'X(a & GFb)'
116
     run 0 $x 'Xa | GFb' 'X(a | GFb)'
117
118
119
120
121
122
123
     # The following is not reduced to F(a) & GFb.  because
     # (1) is does not help the translate the formula into a
     #     smaller automaton, and ...
     run 0 $x 'F(a & GFb)' 'F(a & GFb)'
     # (2) ... it would hinder this useful reduction (that helps to
     #     produce a smaller automaton)
     run 0 $x 'F(f1 & GF(f2)) | F(a & GF(b))' 'F((f1&GFf2)|(a&GFb))'
124
125
126
127
     # FIXME: Don't we want the opposite rewriting?
     # rewriting Fa & GFb as  F(a & GFb) seems better, but
     # it not clear how that scales to Fa & Fb & GFc...
     run 0 $x 'Fa & GFb' 'Fa & GFb'
128
     run 0 $x 'G(a | GFb)' 'Ga | GFb'
129
130
131
     # The following is not reduced to F(a & c) & GF(b) for the same
     # reason as above.
     run 0 $x 'F(a & GFb & c)' 'F(a & GFb & c)'
132
     run 0 $x 'G(a | GFb | c)' 'G(a | c) | GFb'
133

134
135
     run 0 $x 'GFa <=> GFb' 'G(Fa&Fb)|FG(!a&!b)'

136
137
     run 0 $x 'Gb W a' 'Gb|a'
     run 0 $x 'Fb M Fa' 'Fa & Fb'
138
139
140
141
142

     run 0 $x 'a U (b | G(a) | c)' 'a W (b | c)'
     run 0 $x 'a U (G(a))' 'Ga'
     run 0 $x '(a U b) | (a W c)' 'a W (b | c)'
     run 0 $x '(a U b) | Ga' 'a W b'
143
144
145
146
147

     run 0 $x 'a R (b & F(a) & c)' 'a M (b & c)'
     run 0 $x 'a R (F(a))' 'Fa'
     run 0 $x '(a R b) & (a M c)' 'a M (b & c)'
     run 0 $x '(a R b) & Fa' 'a M b'
148
149
150
151
152

     run 0 $x '(a U b) & (c W b)' '(a & c) U b'
     run 0 $x '(a W b) & (c W b)' '(a & c) W b'
     run 0 $x '(a R b) | (c M b)' '(a | c) R b'
     run 0 $x '(a M b) | (c M b)' '(a | c) M b'
153
154
155
156
157
158

     run 0 $x '(a R b) | Gb' 'a R b'
     run 0 $x '(a M b) | Gb' 'a R b'
     run 0 $x '(a U b) & Fb' 'a U b'
     run 0 $x '(a W b) & Fb' 'a U b'
     run 0 $x '(a M b) | Gb | (c M b)' '(a | c) R b'
159
160
161
162
163

     run 0 $x 'GFGa' 'FGa'
     run 0 $x 'b R Ga' 'Ga'
     run 0 $x 'b R FGa' 'FGa'

164
165
166
167
168
     run 0 $x 'G(!a M a) M 1' '0'
     run 0 $x 'G(!a M a) U 1' '1'
     run 0 $x 'a R (!a M a)' '0'
     run 0 $x 'a W (!a M a)' 'Ga'

169
170
171
172
173
     run 0 $x 'F(a U b)' 'Fb'
     run 0 $x 'F(a M b)' 'F(a & b)'
     run 0 $x 'G(a R b)' 'Gb'
     run 0 $x 'G(a W b)' 'G(a | b)'

174
175
176
177
178
179
180
181
182
183
     run 0 $x 'a & XGa' 'Ga'
     run 0 $x 'a & XG(a&b)' '(XGb)&(Ga)'
     run 0 $x 'a & b & XG(a&b)'  'G(a&b)'
     run 0 $x 'a & b & X(Ga&Gb)'  'G(a&b)'
     run 0 $x 'a & b & XGa &XG(b)'  'G(a&b)'
     run 0 $x 'a & b & XGa & XGc' 'b & Ga & XGc'
     run 0 $x 'a & b & X(G(a&d) & b) & X(Gc)' 'b & Ga & X(b & G(c&d))'
     run 0 $x 'a|b|c|X(F(a|b)|F(c)|Gd)' 'F(a|b|c)|XGd'
     run 0 $x 'b|c|X(F(a|b)|F(c)|Gd)' 'b|c|X(F(a|b|c)|Gd)'

184
185
186
187
188
189
190
     # Syntactic implication
     run 0 $x '(a & b) R (a R c)' '(a & b)R c'
     run 0 $x 'a R ((a & b) R c)' '(a & b)R c'
     run 0 $x 'a R ((a & b) M c)' '(a & b)M c'
     run 0 $x 'a M ((a & b) M c)' '(a & b)M c'
     run 0 $x '(a & b) M (a R c)' '(a & b)M c'
     run 0 $x '(a & b) M (a M c)' '(a & b)M c'
191

192
193
194
195
196
197
198
199
200
201
202
203
204
205
     run 0 $x 'a U ((a & b) U c)' 'a U c'
     run 0 $x '(a&c) U (b R (c U d))' 'b R (c U d)'
     run 0 $x '(a&c) U (b R (c W d))' 'b R (c W d)'
     run 0 $x '(a&c) U (b M (c U d))' 'b M (c U d)'
     run 0 $x '(a&c) U (b M (c W d))' 'b M (c W d)'

     run 0 $x '(a R c) R (b & a)' 'c R (b & a)'
     run 0 $x '(a M c) R (b & a)' 'c R (b & a)'

     run 0 $x 'a W ((a&b) U c)' 'a W c'
     run 0 $x 'a W ((a&b) W c)' 'a W c'

     run 0 $x '(a M c) M (b&a)' 'c M (b&a)'

206
207
208
     # Eventuality and universality class reductions
     run 0 $x 'Fa M b' 'Fa & b'
     run 0 $x 'GFa M b' 'GFa & b'
209
210
211
212
213

     run 0 $x 'Fa|Xb|GFc' 'Fa | X(b|GFc)'
     run 0 $x 'Fa|GFc' 'F(a|GFc)'
     run 0 $x 'FGa|GFc' 'F(Ga|GFc)'
     run 0 $x 'Ga&Xb&FGc' 'Ga & X(b&FGc)'
214
     run 0 $x 'Ga&Xb&GFc' 'Ga & X(b&GFc)'
215
     run 0 $x 'Ga&GFc' 'G(a&Fc)'
216
217
218
219
220
221
222
223
     run 0 $x 'G(a|b|GFc|GFd|FGe|FGf)' 'G(a|b)|GF(c|d)|F(Ge|Gf)'
     run 0 $x 'G(a|b)|GFc|GFd|FGe|FGf' 'G(a|b)|GF(c|d)|F(Ge|Gf)'
     run 0 $x 'X(a|b)|GFc|GFd|FGe|FGf' 'X(a|b|GF(c|d)|F(Ge|Gf))'
     run 0 $x 'Xa&Xb&GFc&GFd&Ge' 'X(a&b&G(Fc&Fd))&Ge'

     # F comes in front when possible...
     run 0 $x 'GFc|GFd|FGe|FGf' 'F(GF(c|d)|Ge|Gf)'
     run 0 $x 'G(GFc|GFd|FGe|FGf)' 'F(GF(c|d)|Ge|Gf)'
224
225
226
227

     # Because reduccmp will translate the formula,
     # this also check for an old bug in ltl2tgba_fm.
     run 0 $x '{(c&!c)[->0..1]}!' '0'
228
229
230
231
232
233

     # Tricky case that used to break the translator,
     # because it was translating closer on-the-fly
     # without pruning the rational automaton.
     run 0 $x '{(c&!c)[=2]}' '0'

234
235
236
237
238
239
240
     run 0 $x '{a && b && c*} <>-> d' 'a&b&c&d'
     run 0 $x '{a && b && c[*1..3]} <>-> d' 'a&b&c&d'
     run 0 $x '{a && b && c[->0..2]} <>-> d' 'a&b&c&d'
     run 0 $x '{a && b && c[+]} <>-> d' 'a&b&c&d'
     run 0 $x '{a && b && c[=1]} <>-> d' 'a&b&c&d'
     run 0 $x '{a && b && d[=2]} <>-> d' '0'
     run 0 $x '{a && b && d[*2..]} <>-> d' '0'
241
     run 0 $x '{a && b && d[->2..4]} <>-> d' '0'
242
     run 0 $x '{a && { c* : b* : (g|h)*}} <>-> d' 'a & c & b & (g | h) & d'
243
244
245
246
247
248
249
250
     run 0 $x '{a && {b;c}} <>-> d' '0'
     run 0 $x '{a && {b;c:e}} <>-> d' '0'
     run 0 $x '{a && {b*;c*}} <>-> d' '{a && {b*|c*}} <>-> d' # until better
     run 0 $x '{a && {b*;c*:e}} <>-> d' '{a && {b*|c*} && e} <>-> d' #	idem
     run 0 $x '{a && {b*;c}} <>-> d' 'a & c & d'
     run 0 $x '{a && {b*;c:e}} <>-> d' 'a & c & d & e'
     run 0 $x '{a && {b;c*}} <>-> d' 'a & b & d'
     run 0 $x '{a && {b;c*:e}} <>-> d' 'a & b & d & e'
251
252
253
254
255
256
257
258
259
260
     run 0 $x '{{b1;r1*} && {b2 ; r2*}} <>-> x' \
              '{{b1&&b2};{r1*&&r2*}} <>-> x'
     run 0 $x '{{b1;r1*}&&{b2;r2*}} <>-> x' \
              '{{b1&&b2};{r1*&&r2*}} <>-> x'
     run 0 $x '{{r1*;b1}&&{r2*;b2}} <>-> x' \
              '{{r1*&&r2*};{b1&&b2}} <>-> x'
     run 0 $x '{{r1*;b1}&&{r2*;b2}} <>-> x' \
              '{{r1*&&r2*};{b1&&b2}} <>-> x'
     run 0 $x '{{a;b*;c}&&{d;e*}&&{f*;g}&&{h*}} <>-> x' \
              '{{f*;g}&&{h*}&&{{a&&d};{e* && {b*;c}}}} <>-> x'
261
262
263
     ;;
  esac

264
265
  run 0 $x 'a R (b W G(c))' 'a R (b W G(c))' #not reduced

266
267
268
  run 0 $x 'a M ((a&b) R c)' 'a M ((a&b) R c)' #not reduced.
  run 0 $x '(a&b) W (a U c)' '(a&b) W (a U c)' #not reduced.

269
  # Eventuality and universality class reductions
270
271
272
273
274
  run 0 $x 'FFa' 'Fa'
  run 0 $x 'FGFa' 'GFa'
  run 0 $x 'b U Fa' 'Fa'
  run 0 $x 'b U GFa' 'GFa'
  run 0 $x 'Ga' 'Ga'
275
276

  run 0 $x 'a U XXXFb' 'XXXFb'
277
done