autfilt.org 36.8 KB
Newer Older
1
# -*- coding: utf-8 -*-
2
#+TITLE: =autfilt=
3
#+DESCRIPTION: Spot command-line tool for filtering, tranforming, and converting ω-automata.
4
5
#+SETUPFILE: setup.org
#+HTML_LINK_UP: tools.html
6
7
8

The =autfilt= tool can filter, transform, and convert a stream of automata.

9
10
11
12
13
The tool operates a loop over 5 phases:
- input one automaton
- optionally preprocess the automaton
- optionally filter the automaton (i.e., decide whether to ignore the
  automaton or continue with it)
14
- optionally postprocess the automaton (to simply it or change its acceptance)
15
16
17
18
19
20
- output the automaton

The simplest way to use the tool is simply to use it for input and
output (i.e., format conversion) without any transformation and
filtering.

21
22
* Conversion between formats

23
=autfilt= can read automata written in the [[http://adl.github.io/hoaf/][Hanoi Omega Automata
24
25
26
27
28
29
Format]], as [[http://spinroot.com/spin/Man/never.html][Spin never claims]], using [[http://www.tcs.hut.fi/Software/lbtt/doc/html/Format-for-automata.html][LBTT's format]], or using
[[http://www.ltl2dstar.de/docs/ltl2dstar.html][=ltl2dstar='s format]].  Automata in those formats (even a mix of those
formats) can be concatenated in the same stream, =autfilt= will
process them in batch.  (The only restriction is that inside a file an
automaton in LBTT's format may not follow an automaton in
=ltl2dstar='s format.)
30

31
32
By default the output uses the HOA format.  This can be changed using
[[file:oaut.org][the common output options]] like =--spin=, =--lbtt=, =--dot=,
33
=--stats=...
34

35
#+BEGIN_SRC sh :results silent :exports both
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
cat >example.hoa <<EOF
HOA: v1
States: 1
Start: 0
AP: 1 "p0"
Acceptance: 1 Inf(0)
--BODY--
State: 0
[0] 0 {0}
[!0] 0
--END--
EOF
autfilt example.hoa --dot
#+END_SRC

51
#+BEGIN_SRC sh :results verbatim :exports results
52
SPOT_DOTEXTRA= autfilt example.hoa --dot
53
54
#+END_SRC

55
56
#+RESULTS:
: digraph G {
57
:   rankdir=LR
58
:   node [shape="circle"]
59
60
61
62
63
:   I [label="", style=invis, width=0]
:   I -> 0
:   0 [label="0"]
:   0 -> 0 [label="p0\n{0}"]
:   0 -> 0 [label="!p0"]
64
65
: }

66
The =--spin= option implicitly requires a degeneralization:
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87

#+BEGIN_SRC sh :results verbatim :exports both
autfilt example.hoa --spin
#+END_SRC

#+RESULTS:
#+begin_example
never {
accept_init:
  if
  :: ((p0)) -> goto accept_init
  :: ((!(p0))) -> goto T0_S2
  fi;
T0_S2:
  if
  :: ((p0)) -> goto accept_init
  :: ((!(p0))) -> goto T0_S2
  fi;
}
#+end_example

88
89
Option =--lbtt= only works for Büchi or generalized Büchi acceptance.

90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#+BEGIN_SRC sh :results verbatim :exports both
autfilt example.hoa --lbtt
#+END_SRC

#+RESULTS:
: 1 1t
: 0 1
: 0 0 -1 p0
: 0 -1 ! p0
: -1

* Displaying statistics

One special output format of =autfilt= is the statistic output.  For
instance the following command calls [[file:randaut.org][=randaut=]] to generate 10 random
automata, and pipe the result into =autfilt= to display various
statistics.


#+BEGIN_SRC sh :results verbatim :exports both
110
randaut -n 10 -A0..2 -Q10..20 -e0.05 2 |
111
112
113
114
115
autfilt --stats='%s states, %e edges, %a acc-sets, %c SCCs, det=%d'
#+END_SRC

#+RESULTS:
#+begin_example
116
117
118
119
120
121
122
123
124
125
16 states, 30 edges, 1 acc-sets, 3 SCCs, det=0
20 states, 42 edges, 2 acc-sets, 1 SCCs, det=0
15 states, 27 edges, 2 acc-sets, 1 SCCs, det=0
10 states, 17 edges, 1 acc-sets, 1 SCCs, det=1
13 states, 25 edges, 1 acc-sets, 1 SCCs, det=0
11 states, 18 edges, 0 acc-sets, 1 SCCs, det=0
19 states, 41 edges, 2 acc-sets, 1 SCCs, det=0
11 states, 18 edges, 0 acc-sets, 1 SCCs, det=0
12 states, 21 edges, 1 acc-sets, 5 SCCs, det=0
18 states, 37 edges, 1 acc-sets, 5 SCCs, det=0
126
127
128
129
130
131
132
133
134
#+end_example

The following =%= sequences are available:
#+BEGIN_SRC sh :results verbatim :exports results
autfilt --help | sed -n '/^  %%/,/^$/p' | sed '$d'
#+END_SRC
#+RESULTS:
#+begin_example
  %%                         a single %
135
  %A, %a                     number of acceptance sets
136
137
138
139
  %C, %c                     number of SCCs
  %d                         1 if the output is deterministic, 0 otherwise
  %E, %e                     number of edges
  %F                         name of the input file
140
141
142
  %G, %g                     acceptance condition (in HOA syntax)
  %L                         location in the input file
  %M, %m                     name of the automaton
143
144
  %n                         number of nondeterministic states in output
  %p                         1 if the output is complete, 0 otherwise
145
  %r                         processing time (excluding parsing) in seconds
146
147
  %S, %s                     number of states
  %T, %t                     number of transitions
148
  %w                         one word accepted by the output automaton
149
150
151
152
153
154
155
156
#+end_example

When a letter is available both as uppercase and lowercase, the
uppercase version refer to the input automaton, while the lowercase
refer to the output automaton.  Of course this distinction makes sense
only if =autfilt= was instructed to perform an operation on the input
automaton.

157
158
* Filtering automata

159
160
=autfilt= offers multiple options to filter automata based on
different characteristics of the automaton.
161
162
163
164
165
166

#+BEGIN_SRC sh :results verbatim :exports results
autfilt --help | sed -n '/Filtering options.*:/,/^$/p' | sed '1d;$d'
#+END_SRC
#+RESULTS:
#+begin_example
167
168
169
170
      --acc-sccs=RANGE, --accepting-sccs=RANGE
                             keep automata whose number of non-trivial
                             accepting SCCs is in RANGE
      --acc-sets=RANGE       keep automata whose number of acceptance sets is
171
                             in RANGE
172
      --accept-word=WORD     keep automata that accept WORD
173
      --ap=RANGE             match automata with a number of (declared) atomic
174
                             propositions in RANGE
175
176
      --are-isomorphic=FILENAME   keep automata that are isomorphic to the
                             automaton in FILENAME
177
      --edges=RANGE          keep automata whose number of edges is in RANGE
178
179
180
181
      --equivalent-to=FILENAME   keep automata thare are equivalent
                             (language-wise) to the automaton in FILENAME
      --included-in=FILENAME keep automata whose languages are included in that
                             of the automaton from FILENAME
182
183
184
185
186
      --inherently-weak-sccs=RANGE
                             keep automata whose number of accepting
                             inherently-weak SCCs is in RANGE.  An accepting
                             SCC is inherently weak if it does not have a
                             rejecting cycle.
187
188
189
190
191
      --intersect=FILENAME   keep automata whose languages have an non-empty
                             intersection with the automaton from FILENAME
      --is-complete          keep complete automata
      --is-deterministic     keep deterministic automata
      --is-empty             keep automata with an empty language
192
      --is-inherently-weak   keep only inherently weak automata
193
194
      --is-stutter-invariant keep automata representing stutter-invariant
                             properties
195
196
197
      --is-terminal          keep only terminal automata
      --is-unambiguous       keep only unambiguous automata
      --is-weak              keep only weak automata
198
199
200
201
202
      --nondet-states=RANGE  keep automata whose number of nondeterministic
                             states is in RANGE
      --rej-sccs=RANGE, --rejecting-sccs=RANGE
                             keep automata whose number of non-trivial
                             rejecting SCCs is in RANGE
203
      --reject-word=WORD     keep automata that reject WORD
204
205
206
207
208
209
210
211
212
213
214
215
      --sccs=RANGE           keep automata whose number of SCCs is in RANGE
      --states=RANGE         keep automata whose number of states is in RANGE
      --terminal-sccs=RANGE  keep automata whose number of accepting terminal
                             SCCs is in RANGE.  Terminal SCCs are weak and
                             complete.
      --triv-sccs=RANGE, --trivial-sccs=RANGE
                             keep automata whose number of trivial SCCs is in
                             RANGE
      --unused-ap=RANGE      match automata with a number of declared, but
                             unused atomic propositions in RANGE
      --used-ap=RANGE        match automata with a number of used atomic
                             propositions in RANGE
216
217
218
  -u, --unique               do not output the same automaton twice (same in
                             the sense that they are isomorphic)
  -v, --invert-match         select non-matching automata
219
220
221
      --weak-sccs=RANGE      keep automata whose number of accepting weak SCCs
                             is in RANGE.  In a weak SCC, all transitions
                             belong to the same acceptance sets.
222
223
224
225
226
#+end_example

For instance =--states=2..5 --acc-sets=3= will /keep/ only automata that
use 3 acceptance sets, and that have between 2 and 5 states.

227
228
229
230
Except for =--unique=, all these filters can be inverted using option
=-v=.  Using =--states=2..5 --acc-sets=3 -v= will /drop/ all automata
that use 3 acceptance sets and that have between 2 and 5 states, and
keep the others.
231

232
233
234
235
236
237
238
239
240
241
242
243
244
* Simplifying automata

The standard set of automata simplification routines (these are often
referred to as the "post-processing" routines, because these are the
procedures performed by [[file:ltl2tgba.org][=ltl2tgba=]] after translating a formula into a
TGBA) are available through the following options.

This set of options controls the desired type of output automaton:

#+BEGIN_SRC sh :results verbatim :exports results
autfilt --help | sed -n '/Output automaton type:/,/^$/p' | sed '1d;$d'
#+END_SRC
#+RESULTS:
245
246
247
248
249
250
251
252
253
254
255
256
257
258
#+begin_example
  -B, --ba                   Büchi Automaton (with state-based acceptance)
  -C, --complete             output a complete automaton
  -G, --generic              any acceptance is allowed (default)
  -M, --monitor              Monitor (accepts all finite prefixes of the given
                             property)
  -p, --colored-parity[=any|min|max|odd|even|min odd|min even|max odd|max
      even]                  colored automaton with parity acceptance
  -P, --parity[=any|min|max|odd|even|min odd|min even|max odd|max even]
                             automaton with parity acceptance
  -S, --state-based-acceptance, --sbacc
                             define the acceptance using states
      --tgba                 Transition-based Generalized Büchi Automaton
#+end_example
259

260
These options specify any simplification goal:
261
262

#+BEGIN_SRC sh :results verbatim :exports results
263
autfilt --help | sed -n '/Simplification goal:/,/^$/p' | sed '1d;$d'
264
265
#+END_SRC
#+RESULTS:
266
:   -a, --any                  no preference, do not bother making it small or
267
:                              deterministic
268
269
270
271
:   -D, --deterministic        prefer deterministic automata
:       --small                prefer small automata

Finally, the following switches control the amount of effort applied
272
toward the desired goal:
273
274

#+BEGIN_SRC sh :results verbatim :exports results
275
autfilt --help | sed -n '/Simplification level:/,/^$/p' | sed '1d;$d'
276
277
278
#+END_SRC
#+RESULTS:
:       --high                 all available optimizations (slow)
279
:       --low                  minimal optimizations (fast)
280
:       --medium               moderate optimizations
281
282
283


By default, =--any --low= is used, which cause all simplifications to
284
285
286
287
288
be skipped.  However if any goal is given, than the simplification level
defaults to =--high= (unless specified otherwise).  If a simplification
level is given without specifying any goal, then the goal default to =--small=.

So if you want to reduce the size of the automaton, try =--small= and
289
290
291
292
293
294
if you want to try to make (or keep) it deterministic use
=--deterministic=.

Note that the =--deterministic= flag has two possible behaviors
depending on the constraints on the acceptance conditions:
- When =autfilt= is configured to work with generic acceptance (the
295
296
297
298
299
  =--generic= option, which is the default) or parity acceptance
  (using =--parity= or =--colored-parity=), then the =--deterministic=
  flag will do whatever it takes to output a deterministic automaton,
  and this includes changing the acceptance condition if needed (see
  below).
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
- If options =--tgba= or =--ba= are used, the =--deterministic= option
  is taken as a /preference/: =autfilt= will try to favor determinism
  in the output, but it may not always succeed and may output
  non-deterministic automata.  Note that if =autfilt --deterministic
  --tgba= fails to output a deterministic automaton, it does not
  necessarily implies that a deterministic TGBA does not exist: it
  just implies that =autfilt= could not find it.


** Determinization

Spot has basically two ways to determinize automata, and that it uses
when =--deterministic= is passed.

- Automata that express obligation properties (this can be decided),
  can be *determinized and minimized* into weak Büchi automata, as
  discussed by [[http://www.daxc.de/eth/paper/atva07.pdf][Dax at al. (ATVA'07)]].

- Büchi automata (preferably with transition-based acceptance) can be
  determinized into parity automata using a Safra-like procedure close
  to the one presented by [[http://www.romanredz.se/papers/FI2012.pdf][Redziejowski (Fund. Inform. 119)]], with a few
  additional tricks.  This procedure does not necessarily produce a
  minimal automaton.

When =--deterministic= is used, the first of these two procedures is
attempted on any supplied automaton.  (It's even attempted for
deterministic automata, because that might reduce them.)

If that first procedure failed, and the input automaton is not
329
330
331
332
333
334
335
336
337
deterministic and =--generic= (the default for =autfilt=), =--parity=
or =--colorized-parity= is used, then the second procedure is used.
In this case, automata will be first converted to transition-based
Büchi automata if their acceptance condition is more complex.

The difference between =--parity= and =--colored-parity= parity is
that the latter requests all transitions (or all states when
state-based acceptance is used) to belong to exactly one acceptance
set.
338
339
340
341
342
343
344
345
346
347

* Transformations

The following transformations are available:

#+BEGIN_SRC sh :results verbatim :exports results
autfilt --help | sed -n '/Transformations:/,/^$/p' | sed '1d;$d'
#+END_SRC

#+RESULTS:
Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
348
349
#+begin_example
      --cleanup-acceptance   remove unused acceptance sets from the automaton
350
351
      --cnf-acceptance       put the acceptance condition in Conjunctive Normal
                             Form
352
353
      --complement           complement each automaton (currently support only
                             deterministic automata)
Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
354
355
      --complement-acceptance   complement the acceptance condition (without
                             touching the automaton)
356
357
358
      --decompose-strength=t|w|s   extract the (t) terminal, (w) weak, or (s)
                             strong part of an automaton (letters may be
                             combined to combine more strengths in the output)
Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
359
360
361
      --destut               allow less stuttering
      --dnf-acceptance       put the acceptance condition in Disjunctive Normal
                             Form
362
363
364
365
366
      --exclusive-ap=AP,AP,...   if any of those APs occur in the automaton,
                             restrict all edges to ensure two of them may not
                             be true at the same time.  Use this option
                             multiple times to declare independent groups of
                             exclusive propositions.
367
368
369
370
371
372
373
374
375
376
377
      --generalized-rabin[=unique-inf|share-inf], --gra[=unique-inf|share-inf]
                             rewrite the acceptance condition as generalized
                             Rabin; the default "unique-inf" option uses the
                             generalized Rabin definition from the HOA format;
                             the "share-inf" option allows clauses to share Inf
                             sets, therefore reducing the number of sets
      --generalized-streett[=unique-fin|share-fin], --gsa[=unique-fin|share-fin]                                                          rewrite the
                             acceptance condition as generalized Streett; the
                             "share-fin" option allows clauses to share Fin
                             sets, therefore reducing the number of sets; the
                             default "unique-fin" does not
Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
378
379
      --instut[=1|2]         allow more stuttering (two possible algorithms)
      --keep-states=NUM[,NUM...]   only keep specified states.  The first state
380
381
                             will be the new initial state.  Implies
                             --remove-unreachable-states.
Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
382
383
384
385
      --mask-acc=NUM[,NUM...]   remove all transitions in specified acceptance
                             sets
      --merge-transitions    merge transitions with same destination and
                             acceptance
386
387
388
389
390
      --product=FILENAME, --product-and=FILENAME
                             build the product with the automaton in FILENAME
                             to intersect languages
      --product-or=FILENAME  build the product with the automaton in FILENAME
                             to sum languages
Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
391
392
      --randomize[=s|t]      randomize states and transitions (specify 's' or
                             't' to randomize only states or transitions)
393
394
395
      --remove-ap=AP[=0|=1][,AP...]
                             remove atomic propositions either by existential
                             quantification, or by assigning them 0 or 1
396
397
      --remove-dead-states   remove states that are unreachable, or that cannot
                             belong to an infinite path
398
399
      --remove-fin           rewrite the automaton without using Fin
                             acceptance
400
401
402
      --remove-unreachable-states
                             remove states that are unreachable from the
                             initial state
403
404
      --remove-unused-ap     remove declared atomic propositions that are not
                             used
405
      --sat-minimize[=options]   minimize the automaton using a SAT solver
406
                             (only works for deterministic automata)
407
408
409
410
411
412
413
      --separate-sets        if both Inf(x) and Fin(x) appear in the acceptance
                             condition, replace Fin(x) by a new Fin(y) and
                             adjust the automaton
      --simplify-exclusive-ap   if --exclusive-ap is used, assume those AP
                             groups are actually exclusive in the system to
                             simplify the expression of transition labels
                             (implies --merge-transitions)
Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
414
415
416
      --strip-acceptance     remove the acceptance condition and all acceptance
                             sets
#+end_example
417

418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
* Decorations

Decorations work by coloring some states or edges in the automaton.
They are only useful when the automaton is output in Dot format (with
=--dot= or =-d=) or HOA v1.1 format (with =-H1.1= or =--hoa=1.1=).

#+BEGIN_SRC sh :results verbatim :exports results
autfilt --help | sed -n '/^ *Decorations.*:/,/^$/p' | sed '1d;$d'
#+END_SRC

#+RESULTS:
:       --highlight-nondet[=NUM]   highlight nondeterministic states and edges
:                              with color NUM
:       --highlight-nondet-edges[=NUM]
:                              highlight nondeterministic edges with color NUM
:       --highlight-nondet-states[=NUM]
:                              highlight nondeterministic states with color NUM
:       --highlight-word=[NUM,]WORD
:                              highlight one run matching WORD using color NUM

438
439
Color numbers are indices in some hard-coded color palette.  It is the
same palette that is currently used to display colored acceptance
440
441
sets, but this might change in the future.

442
443
* Examples

444
445
** Acceptance transformations

446
447
Here is an automaton with transition-based acceptance:

448
#+BEGIN_SRC sh :results silent :exports both
449
450
451
452
453
cat >aut-ex1.hoa<<EOF
HOA: v1
States: 3
Start: 0
AP: 2 "a" "b"
454
Acceptance: 4 Inf(0)&Fin(1)&Fin(3) | Inf(2)&Inf(3) | Inf(1)
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
--BODY--
State: 0 {3}
[t] 0
[0] 1 {1}
[!0] 2 {0}
State: 1 {3}
[1] 0
[0&1] 1 {0}
[!0&1] 2 {2}
State: 2
[!1] 0
[0&!1] 1 {0}
[!0&!1] 2 {0}
--END--
EOF
#+END_SRC

472
473
(Note: that the =--dot= option used below uses some default options
discussed [[file:oaut.org::#default-dot][on another page]].)
474
475

#+NAME: autfilt-ex1
476
#+BEGIN_SRC sh :results verbatim :exports code
477
autfilt aut-ex1.hoa --dot
478
479
480
481
482
483
#+END_SRC

#+RESULTS: autfilt-ex1
#+begin_example
digraph G {
  rankdir=LR
484
  label=<(Fin(<font color="#F17CB0">❶</font>) &amp; Fin(<font color="#B276B2">❸</font>) &amp; Inf(<font color="#5DA5DA">⓿</font>)) | (Inf(<font color="#FAA43A">❷</font>)&amp;Inf(<font color="#B276B2">❸</font>)) | Inf(<font color="#F17CB0">❶</font>)>
485
486
487
488
  labelloc="t"
  fontname="Lato"
  node [fontname="Lato"]
  edge [fontname="Lato"]
489
  node[style=filled, fillcolor="#ffffa0"] edge[arrowhead=vee, arrowsize=.7]
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
  I [label="", style=invis, width=0]
  I -> 0
  0 [label="0"]
  0 -> 0 [label=<1<br/><font color="#B276B2">❸</font>>]
  0 -> 1 [label=<a<br/><font color="#F17CB0">❶</font><font color="#B276B2">❸</font>>]
  0 -> 2 [label=<!a<br/><font color="#5DA5DA">⓿</font><font color="#B276B2">❸</font>>]
  1 [label="1"]
  1 -> 0 [label=<b<br/><font color="#B276B2">❸</font>>]
  1 -> 1 [label=<a &amp; b<br/><font color="#5DA5DA">⓿</font><font color="#B276B2">❸</font>>]
  1 -> 2 [label=<!a &amp; b<br/><font color="#FAA43A">❷</font><font color="#B276B2">❸</font>>]
  2 [label="2"]
  2 -> 0 [label=<!b>]
  2 -> 1 [label=<a &amp; !b<br/><font color="#5DA5DA">⓿</font>>]
  2 -> 2 [label=<!a &amp; !b<br/><font color="#5DA5DA">⓿</font>>]
}
#+end_example

507
508
#+BEGIN_SRC dot :file autfilt-ex1.svg :var txt=autfilt-ex1 :exports results
  $txt
509
510
511
#+END_SRC

#+RESULTS:
512
[[file:autfilt-ex1.svgz]]
513

514
Using =-S= will "push" the acceptance membership of the transitions to the states:
515
516

#+NAME: autfilt-ex2
517
#+BEGIN_SRC sh :results verbatim :exports code
518
autfilt -S aut-ex1.hoa --dot=
519
520
521
522
523
524
#+END_SRC

#+RESULTS: autfilt-ex2
#+begin_example
digraph G {
  rankdir=LR
525
  label=<(Fin(<font color="#F17CB0">❶</font>) &amp; Fin(<font color="#B276B2">❸</font>) &amp; Inf(<font color="#5DA5DA">⓿</font>)) | (Inf(<font color="#FAA43A">❷</font>)&amp;Inf(<font color="#B276B2">❸</font>)) | Inf(<font color="#F17CB0">❶</font>)>
526
  labelloc="t"
527
  node [shape="circle"]
528
529
530
  fontname="Lato"
  node [fontname="Lato"]
  edge [fontname="Lato"]
531
  node[style=filled, fillcolor="#ffffa0"] edge[arrowhead=vee, arrowsize=.7]
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
  I [label="", style=invis, width=0]
  I -> 0
  0 [label=<0<br/><font color="#B276B2">❸</font>>]
  0 -> 0 [label=<1>]
  0 -> 1 [label=<a>]
  0 -> 2 [label=<!a>]
  1 [label=<1<br/><font color="#F17CB0">❶</font><font color="#B276B2">❸</font>>]
  1 -> 0 [label=<b>]
  1 -> 6 [label=<a &amp; b>]
  1 -> 7 [label=<!a &amp; b>]
  2 [label=<2<br/><font color="#5DA5DA">⓿</font><font color="#B276B2">❸</font>>]
  2 -> 3 [label=<!b>]
  2 -> 4 [label=<a &amp; !b>]
  2 -> 5 [label=<!a &amp; !b>]
  3 [label=<3>]
  3 -> 0 [label=<1>]
  3 -> 1 [label=<a>]
  3 -> 2 [label=<!a>]
  4 [label=<4<br/><font color="#5DA5DA">⓿</font>>]
  4 -> 0 [label=<b>]
  4 -> 6 [label=<a &amp; b>]
  4 -> 7 [label=<!a &amp; b>]
  5 [label=<5<br/><font color="#5DA5DA">⓿</font>>]
  5 -> 3 [label=<!b>]
  5 -> 4 [label=<a &amp; !b>]
  5 -> 5 [label=<!a &amp; !b>]
  6 [label=<6<br/><font color="#5DA5DA">⓿</font><font color="#B276B2">❸</font>>]
  6 -> 0 [label=<b>]
  6 -> 6 [label=<a &amp; b>]
  6 -> 7 [label=<!a &amp; b>]
  7 [label=<7<br/><font color="#FAA43A">❷</font><font color="#B276B2">❸</font>>]
  7 -> 3 [label=<!b>]
  7 -> 4 [label=<a &amp; !b>]
  7 -> 5 [label=<!a &amp; !b>]
}
#+end_example

569
#+BEGIN_SRC dot :file autfilt-ex2.svg :var txt=autfilt-ex2 :exports results
570
571
572
573
$txt
#+END_SRC

#+RESULTS:
574
[[file:autfilt-ex2.svg]]
575

576
Using =--cnf-acceptance= simply rewrites the acceptance condition in Conjunctive Normal Form:
577
578

#+NAME: autfilt-ex3
579
#+BEGIN_SRC sh :results verbatim :exports code
580
autfilt --cnf-acceptance aut-ex1.hoa --dot
581
582
583
584
585
586
#+END_SRC

#+RESULTS: autfilt-ex3
#+begin_example
digraph G {
  rankdir=LR
587
  label=<(Inf(<font color="#5DA5DA">⓿</font>) | Inf(<font color="#F17CB0">❶</font>) | Inf(<font color="#B276B2">❸</font>)) &amp; (Fin(<font color="#B276B2">❸</font>) | Inf(<font color="#F17CB0">❶</font>) | Inf(<font color="#FAA43A">❷</font>))>
588
589
590
591
  labelloc="t"
  fontname="Lato"
  node [fontname="Lato"]
  edge [fontname="Lato"]
592
  node[style=filled, fillcolor="#ffffa0"] edge[arrowhead=vee, arrowsize=.7]
593
594
595
596
  I [label="", style=invis, width=0]
  I -> 0
  0 [label="0"]
  0 -> 0 [label=<1<br/><font color="#B276B2">❸</font>>]
597
  0 -> 1 [label=<a<br/><font color="#F17CB0">❶</font><font color="#B276B2">❸</font>>]
598
599
600
601
602
603
604
605
606
607
608
609
  0 -> 2 [label=<!a<br/><font color="#5DA5DA">⓿</font><font color="#B276B2">❸</font>>]
  1 [label="1"]
  1 -> 0 [label=<b<br/><font color="#B276B2">❸</font>>]
  1 -> 1 [label=<a &amp; b<br/><font color="#5DA5DA">⓿</font><font color="#B276B2">❸</font>>]
  1 -> 2 [label=<!a &amp; b<br/><font color="#FAA43A">❷</font><font color="#B276B2">❸</font>>]
  2 [label="2"]
  2 -> 0 [label=<!b>]
  2 -> 1 [label=<a &amp; !b<br/><font color="#5DA5DA">⓿</font>>]
  2 -> 2 [label=<!a &amp; !b<br/><font color="#5DA5DA">⓿</font>>]
}
#+end_example

610
#+BEGIN_SRC dot :file autfilt-ex3.svg :var txt=autfilt-ex3 :exports results
611
612
613
614
$txt
#+END_SRC

#+RESULTS:
615
[[file:autfilt-ex3.svg]]
616
617
618
619
620
621
622


Using =--remove-fin= transforms the automaton to remove all traces
of Fin-acceptance: this usually requires adding non-deterministic jumps to
altered copies of strongly-connected components.

#+NAME: autfilt-ex4
623
#+BEGIN_SRC sh :results verbatim :exports code
624
autfilt --remove-fin aut-ex1.hoa --dot
625
626
627
628
629
630
631
632
633
634
635
#+END_SRC

#+RESULTS: autfilt-ex4
#+begin_example
digraph G {
  rankdir=LR
  label=<Inf(<font color="#5DA5DA">⓿</font>) | Inf(<font color="#F17CB0">❶</font>) | (Inf(<font color="#FAA43A">❷</font>)&amp;Inf(<font color="#B276B2">❸</font>))>
  labelloc="t"
  fontname="Lato"
  node [fontname="Lato"]
  edge [fontname="Lato"]
636
  node[style=filled, fillcolor="#ffffa0"] edge[arrowhead=vee, arrowsize=.7]
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
  I [label="", style=invis, width=0]
  I -> 0
  0 [label="0"]
  0 -> 0 [label=<1<br/><font color="#B276B2">❸</font>>]
  0 -> 1 [label=<a<br/><font color="#F17CB0">❶</font><font color="#B276B2">❸</font>>]
  0 -> 2 [label=<!a<br/><font color="#B276B2">❸</font>>]
  1 [label="1"]
  1 -> 0 [label=<b<br/><font color="#B276B2">❸</font>>]
  1 -> 1 [label=<a &amp; b<br/><font color="#B276B2">❸</font>>]
  1 -> 2 [label=<!a &amp; b<br/><font color="#FAA43A">❷</font><font color="#B276B2">❸</font>>]
  2 [label="2"]
  2 -> 0 [label=<!b>]
  2 -> 1 [label=<a &amp; !b>]
  2 -> 2 [label=<!a &amp; !b>]
  2 -> 3 [label=<!a &amp; !b>]
  3 [label="3"]
  3 -> 3 [label=<!a &amp; !b<br/><font color="#5DA5DA">⓿</font>>]
}
#+end_example

657
#+BEGIN_SRC dot :file autfilt-ex4.svg :var txt=autfilt-ex4 :exports results
658
659
660
661
$txt
#+END_SRC

#+RESULTS:
662
[[file:autfilt-ex4.svg]]
663
664
665
666
667
668

Use =--mask-acc=NUM= to remove some acceptances sets and all
transitions they contain.  The acceptance condition will be updated to
reflect the fact that these sets can never be visited.

#+NAME: autfilt-ex5
669
#+BEGIN_SRC sh :results verbatim :exports code
670
autfilt --mask-acc=1,2 aut-ex1.hoa --dot
671
672
673
674
675
676
677
678
679
680
681
#+END_SRC

#+RESULTS: autfilt-ex5
#+begin_example
digraph G {
  rankdir=LR
  label=<Fin(<font color="#F17CB0">❶</font>) &amp; Inf(<font color="#5DA5DA">⓿</font>)>
  labelloc="t"
  fontname="Lato"
  node [fontname="Lato"]
  edge [fontname="Lato"]
682
  node[style=filled, fillcolor="#ffffa0"] edge[arrowhead=vee, arrowsize=.7]
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
  I [label="", style=invis, width=0]
  I -> 0
  0 [label="0"]
  0 -> 0 [label=<1<br/><font color="#F17CB0">❶</font>>]
  0 -> 1 [label=<!a<br/><font color="#5DA5DA">⓿</font><font color="#F17CB0">❶</font>>]
  1 [label="1"]
  1 -> 0 [label=<!b>]
  1 -> 2 [label=<a &amp; !b<br/><font color="#5DA5DA">⓿</font>>]
  1 -> 1 [label=<!a &amp; !b<br/><font color="#5DA5DA">⓿</font>>]
  2 [label="2"]
  2 -> 0 [label=<b<br/><font color="#F17CB0">❶</font>>]
  2 -> 2 [label=<a &amp; b<br/><font color="#5DA5DA">⓿</font><font color="#F17CB0">❶</font>>]
}
#+end_example

698
#+BEGIN_SRC dot :file autfilt-ex5.svg :var txt=autfilt-ex5 :exports results
699
700
701
702
$txt
#+END_SRC

#+RESULTS:
703
[[file:autfilt-ex5.svg]]
704

705
** Atomic proposition removal
706
707
708
709
710
711
712
713
714
715

Atomic propositions can be removed from an automaton in three ways:
- use ~--remove-ap=a~ to remove =a= by existential quantification, i.e., both =a= and its negation will be replaced by true.
  This does not remove any transition.
- use ~--remove-ap=a=0~ to keep only transitions compatible with =!a= (i.e, transitions requiring =a= will be removed).
- use ~--remove-ap=a=1~ to keep only transitions compatible with =a= (i.e, transitions requiring =!a= will be removed).

Here are the results of these three options on our example:

#+NAME: autfilt-ex6a
716
#+BEGIN_SRC sh :results verbatim :exports code
717
autfilt --remove-ap=a aut-ex1.hoa --dot
718
719
720
721
722
723
724
725
726
727
728
#+END_SRC

#+RESULTS: autfilt-ex6a
#+begin_example
digraph G {
  rankdir=LR
  label=<(Fin(<font color="#F17CB0">❶</font>) &amp; Fin(<font color="#B276B2">❸</font>) &amp; Inf(<font color="#5DA5DA">⓿</font>)) | (Inf(<font color="#FAA43A">❷</font>)&amp;Inf(<font color="#B276B2">❸</font>)) | Inf(<font color="#F17CB0">❶</font>)>
  labelloc="t"
  fontname="Lato"
  node [fontname="Lato"]
  edge [fontname="Lato"]
729
  node[style=filled, fillcolor="#ffffa0"] edge[arrowhead=vee, arrowsize=.7]
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
  I [label="", style=invis, width=0]
  I -> 0
  0 [label="0"]
  0 -> 0 [label=<1<br/><font color="#B276B2">❸</font>>]
  0 -> 1 [label=<1<br/><font color="#F17CB0">❶</font><font color="#B276B2">❸</font>>]
  0 -> 2 [label=<1<br/><font color="#5DA5DA">⓿</font><font color="#B276B2">❸</font>>]
  1 [label="1"]
  1 -> 0 [label=<b<br/><font color="#B276B2">❸</font>>]
  1 -> 1 [label=<b<br/><font color="#5DA5DA">⓿</font><font color="#B276B2">❸</font>>]
  1 -> 2 [label=<b<br/><font color="#FAA43A">❷</font><font color="#B276B2">❸</font>>]
  2 [label="2"]
  2 -> 0 [label=<!b>]
  2 -> 1 [label=<!b<br/><font color="#5DA5DA">⓿</font>>]
  2 -> 2 [label=<!b<br/><font color="#5DA5DA">⓿</font>>]
}
#+end_example

747
#+BEGIN_SRC dot :file autfilt-ex6a.svg :var txt=autfilt-ex6a :exports results
748
749
750
751
$txt
#+END_SRC

#+RESULTS:
752
[[file:autfilt-ex6a.svg]]
753
754

#+NAME: autfilt-ex6b
755
#+BEGIN_SRC sh :results verbatim :exports code
756
autfilt --remove-ap=a=0 aut-ex1.hoa --dot
757
758
759
760
761
762
763
764
765
766
767
#+END_SRC

#+RESULTS: autfilt-ex6b
#+begin_example
digraph G {
  rankdir=LR
  label=<(Fin(<font color="#F17CB0">❶</font>) &amp; Fin(<font color="#B276B2">❸</font>) &amp; Inf(<font color="#5DA5DA">⓿</font>)) | (Inf(<font color="#FAA43A">❷</font>)&amp;Inf(<font color="#B276B2">❸</font>)) | Inf(<font color="#F17CB0">❶</font>)>
  labelloc="t"
  fontname="Lato"
  node [fontname="Lato"]
  edge [fontname="Lato"]
768
  node[style=filled, fillcolor="#ffffa0"] edge[arrowhead=vee, arrowsize=.7]
769
770
771
772
773
774
775
776
777
778
779
  I [label="", style=invis, width=0]
  I -> 0
  0 [label="0"]
  0 -> 0 [label=<1<br/><font color="#B276B2">❸</font>>]
  0 -> 1 [label=<1<br/><font color="#5DA5DA">⓿</font><font color="#B276B2">❸</font>>]
  1 [label="1"]
  1 -> 0 [label=<!b>]
  1 -> 1 [label=<!b<br/><font color="#5DA5DA">⓿</font>>]
}
#+end_example

780
#+BEGIN_SRC dot :file autfilt-ex6b.svg :var txt=autfilt-ex6b :exports results
781
782
783
784
$txt
#+END_SRC

#+RESULTS:
785
[[file:autfilt-ex6b.svg]]
786
787

#+NAME: autfilt-ex6c
788
#+BEGIN_SRC sh :results verbatim :exports code
789
autfilt --remove-ap=a=1 aut-ex1.hoa --dot
790
791
792
793
#+END_SRC

#+RESULTS: autfilt-ex6c

794
#+BEGIN_SRC dot :file autfilt-ex6c.svg :var txt=autfilt-ex6c :exports results
795
796
797
798
$txt
#+END_SRC

#+RESULTS:
799
[[file:autfilt-ex6c.svg]]
800

801
** Testing word acceptance
802

803
The following example checks whether the formula ~a U b U c~ accepts
804
the word ~a&!b&!c; cycle{!a&!b&c}~.
805

806
807
#+BEGIN_SRC sh :results verbatim :exports both
ltl2tgba 'a U b U c' |
808
  autfilt --accept-word 'a&!b&!c; cycle{!a&!b&c}' -q  && echo "word accepted"
809
810
811
#+END_SRC
#+RESULTS:
: word accepted
812
813
814
815
816
817
818
819

Here is an example where we generate an infinite stream of random LTL
formulas using [[file:randltl.org][=randltl=]], convert them all to automata using
[[file:ltl2tgba.org][=ltl2tgba=]], filter out the first 10 automata that accept both the
words =a&!b;cycle{!a&!b}= and =!a&!b;cycle{a&b}= yet reject any word
of the form =cycle{b}=, and display the associated formula (which was
stored as the name of the automaton by =ltl2tgba=).

820
#+BEGIN_SRC sh :results verbatim :exports both
821
randltl -n -1 a b | ltlfilt --simplify --uniq | ltl2tgba |
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
  autfilt --accept-word='a&!b;cycle{!a&!b}' --accept-word='!a&!b;cycle{a&b}' \
          --reject-word='cycle{b}' --stats=%M -n 10
#+END_SRC

#+RESULTS:
#+begin_example
F!b
!b
F(!a & !b)
(!a & (XX!a | (!a W F!b))) R !b
F(Fb R !b)
Fa R F!b
Fa U !b
!b & X(!b W Ga)
Fb R F!b
XF!b U (!b & (!a | G!b))
#+end_example
839
840
841
842
843
844
845
846
847
848
849
850
851

Note that the above example could be simplified using the
=--accept-word= and =--reject-word= options of =ltlfilt= directly.
However this demonstrates that using =--stats=%M=, it is possible to
filter formulas based on some properties of automata that have been
generated by from them.  The translator needs not be =ltl2tgba=: other
tools can be wrapped with [[file:ltldo.org][=ltldo --name=%f=]] to ensure they work well
in a pipeline and preserve the formula name in the HOA output.  For
example Here is a list of 5 LTL formulas that =ltl2dstar= converts to
Rabin automata that have exactly 4 states:

#+BEGIN_SRC sh :results verbatim :exports both
randltl -n -1 a b | ltlfilt --simplify --remove-wm |
852
    ltldo ltl2dstar --name=%f | autfilt --states=4 --stats=%M -n 5
853
854
855
856
857
858
859
860
#+END_SRC

#+RESULTS:
: Gb | G!b
: b R (a | b)
: (a & !b & (b | (F!a U (!b & F!a)))) | (!a & (b | (!b & (Ga R (b | Ga)))))
: (a & (a U !b)) | (!a & (!a R b))
: a | G((a & GFa) | (!a & FG!a))
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899

** Decorations
   :PROPERTIES:
   :CUSTOM_ID: decorations
   :END:

We know from a previous exemple that formula =a U b U c= accepts the
word =b; cycle{c}=.  We can actually highlight the corresponding
run in the automaton:

#+NAME: highlight-word
#+BEGIN_SRC sh :results verbatim :exports code
ltl2tgba 'a U b U c' | autfilt --highlight-word='a&!b&!c; cycle{!a&!b&c}' -d
#+END_SRC

#+RESULTS: highlight-word
#+begin_example
digraph G {
  rankdir=LR
  node [shape="circle"]
  node [style="filled", fillcolor="#ffffa0"]
  fontname="Lato"
  node [fontname="Lato"]
  edge [fontname="Lato"]
  edge[arrowhead=vee, arrowsize=.7]
  I [label="", style=invis, width=0]
  I -> 2
  0 [label="0", peripheries=2]
  0 -> 0 [label=<1>, style=bold, color="#F17CB0"]
  1 [label="1"]
  1 -> 0 [label=<c>]
  1 -> 1 [label=<b &amp; !c>]
  2 [label="2"]
  2 -> 0 [label=<c>, style=bold, color="#F17CB0"]
  2 -> 1 [label=<!a &amp; b &amp; !c>]
  2 -> 2 [label=<a &amp; !c>, style=bold, color="#F17CB0"]
}
#+end_example

900
#+BEGIN_SRC dot :file autfilt-hlword.svg :var txt=highlight-word :exports results
901
902
903
904
$txt
#+END_SRC

#+RESULTS:
905
[[file:autfilt-hlword.svg]]
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
936
937
938
939
940
941
942
943


We can change the color by prefixing the word with a number and a
comma.  Also it is possible to highlight multiple words, but a
transition may only have one color so late highlights will overwrite
previous ones.

#+NAME: highlight-word2
#+BEGIN_SRC sh :results verbatim :exports code
ltl2tgba 'a U b U c' |
  autfilt --highlight-word=5,'a&!b&!c; cycle{!a&!b&c}' \
          --highlight-word=4,'!a&b&!c; cycle{!a&!b&c}' -d
#+END_SRC

#+RESULTS: highlight-word2
#+begin_example
digraph G {
  rankdir=LR
  node [shape="circle"]
  node [style="filled", fillcolor="#ffffa0"]
  fontname="Lato"
  node [fontname="Lato"]
  edge [fontname="Lato"]
  edge[arrowhead=vee, arrowsize=.7]
  I [label="", style=invis, width=0]
  I -> 2
  0 [label="0", peripheries=2]
  0 -> 0 [label=<1>, style=bold, color="#60BD68"]
  1 [label="1"]
  1 -> 0 [label=<c>, style=bold, color="#60BD68"]
  1 -> 1 [label=<b &amp; !c>]
  2 [label="2"]
  2 -> 0 [label=<c>, style=bold, color="#F15854"]
  2 -> 1 [label=<!a &amp; b &amp; !c>, style=bold, color="#60BD68"]
  2 -> 2 [label=<a &amp; !c>, style=bold, color="#F15854"]
}
#+end_example

944
#+BEGIN_SRC dot :file autfilt-hlword2.svg :var txt=highlight-word2 :exports results
945
946
947
948
  $txt
#+END_SRC

#+RESULTS:
949
[[file:autfilt-hlword2.svg]]
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



Another useful thing to highlight is nondeterminism.  One can
highlight states or edges where nondeterministic choices need to be
made.

#+NAME: highlight-nondet
#+BEGIN_SRC sh :results verbatim :exports code
ltl2tgba 'F((b R a) W Gb)' |
    autfilt --highlight-nondet-states=5 --highlight-nondet-edges=1 -d
#+END_SRC

#+RESULTS: highlight-nondet
#+begin_example
digraph G {
  rankdir=LR
  node [shape="circle"]
  node [style="filled", fillcolor="#ffffa0"]
  fontname="Lato"
  node [fontname="Lato"]
  edge [fontname="Lato"]
  edge[arrowhead=vee, arrowsize=.7]
  I [label="", style=invis, width=0]
  I -> 1
  0 [label="0"]
  0 -> 0 [label=<b<br/><font color="#5DA5DA">⓿</font>>]
  1 [label="1", style="bold,filled", color="#F15854"]
  1 -> 0 [label=<!a &amp; b>, style=bold, color="#5DA5DA"]
  1 -> 1 [label=<1>, style=bold, color="#5DA5DA"]
  1 -> 2 [label=<a &amp; b>]
  1 -> 3 [label=<a &amp; !b>]
  2 [label="2"]
  2 -> 0 [label=<!a &amp; b>]
  2 -> 2 [label=<a &amp; b<br/><font color="#5DA5DA">⓿</font>>]
  2 -> 3 [label=<a &amp; !b<br/><font color="#5DA5DA">⓿</font>>]
  3 [label="3"]
  3 -> 2 [label=<a &amp; b<br/><font color="#5DA5DA">⓿</font>>]
  3 -> 3 [label=<a &amp; !b<br/><font color="#5DA5DA">⓿</font>>]
}
#+end_example

992
#+BEGIN_SRC dot :file autfilt-hlnondet.svg :var txt=highlight-nondet :exports results
993
994
995
996
  $txt
#+END_SRC

#+RESULTS:
997
[[file:autfilt-hlnondet.svg]]
998
999
1000
1001
1002


#+BEGIN_SRC sh :results silent :exports results
rm -f example.hoa aut-ex1.hoa
#+END_SRC