autfilt.org 33.7 KB
Newer Older
1
# -*- coding: utf-8 -*-
2
#+TITLE: =autfilt=
3
#+DESCRIPTION: Spot command-line tool for filtering, transforming, and converting ω-automata.
Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
4
#+INCLUDE: setup.org
5
#+HTML_LINK_UP: tools.html
6
#+PROPERTY: header-args:sh :results verbatim :exports both
7
8
9

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

10
11
The tool operates a loop over 5 phases:
- input one automaton
12
- optionally pre-process the automaton
13
14
- optionally filter the automaton (i.e., decide whether to ignore the
  automaton or continue with it)
15
- optionally post-process the automaton (to simply it or change its acceptance)
16
17
18
19
20
21
- 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.

22
23
* Conversion between formats

24
=autfilt= can read automata written in the [[http://adl.github.io/hoaf/][Hanoi Omega Automata
25
26
27
28
29
30
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.)
31

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

36
#+BEGIN_SRC sh :results silent
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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

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

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

67
The =--spin= option implicitly requires a degeneralization:
68

69
#+BEGIN_SRC sh
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
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

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

91
#+BEGIN_SRC sh
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
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.


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

#+RESULTS:
#+begin_example
117
118
119
120
121
122
123
124
125
126
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
127
128
129
#+end_example

The following =%= sequences are available:
130
#+BEGIN_SRC sh :exports results
131
ltl2tgba --help | sed -n '/ sequences:/,/^$/p' | sed '1d;$d'
132
133
134
#+END_SRC
#+RESULTS:
#+begin_example
135
136
137
138
  %<                         the part of the line before the formula if it
                             comes from a column extracted from a CSV file
  %>                         the part of the line after the formula if it comes
                             from a column extracted from a CSV file
139
  %%                         a single %
140
141
142
143
144
145
146
  %a                         number of acceptance sets
  %c, %[LETTERS]c            number of SCCs; you may filter the SCCs to count
                             using the following LETTERS, possibly
                             concatenated: (a) accepting, (r) rejecting, (c)
                             complete, (v) trivial, (t) terminal, (w) weak,
                             (iw) inherently weak. Use uppercase letters to
                             negate them.
147
  %d                         1 if the output is deterministic, 0 otherwise
148
149
  %e                         number of reachable edges
  %f                         the formula, in Spot's syntax
150
  %F                         name of the input file
151
152
153
154
155
156
157
158
159
160
161
162
  %g, %[LETTERS]g            acceptance condition (in HOA syntax); add brackets
                             to print an acceptance name instead and LETTERS to
                             tweak the format: (0) no parameters, (a)
                             accentuated, (b) abbreviated, (d) style used in
                             dot output, (g) no generalized parameter, (l)
                             recognize Street-like and Rabin-like, (m) no main
                             parameter, (p) no parity parameter, (o) name
                             unknown acceptance as 'other', (s) shorthand for
                             'lo0'.
  %h                         the automaton in HOA format on a single line (use
                             %[opt]h to specify additional options as in
                             --hoa=opt)
163
  %L                         location in the input file
164
  %m                         name of the automaton
165
166
  %n                         number of nondeterministic states in output
  %p                         1 if the output is complete, 0 otherwise
167
168
169
170
171
172
173
174
  %r                         wall-clock time elapsed in seconds (excluding
                             parsing)
  %R, %[LETTERS]R            CPU time (excluding parsing), in seconds; Add
                             LETTERS to restrict to(u) user time, (s) system
                             time, (p) parent process, or (c) children
                             processes.
  %s                         number of reachable states
  %t                         number of reachable transitions
175
176
177
178
179
  %u, %[e]u                  number of states (or [e]dges) with universal
                             branching
  %u, %[LETTER]u             1 if the automaton contains some universal
                             branching (or a number of [s]tates or [e]dges with
                             universal branching)
180
  %w                         one word accepted by the output automaton
181
182
183
184
185
186
187
188
  %x, %[LETTERS]x            number of atomic propositions declared in the
                             automaton;  add LETTERS to list atomic
                             propositions with (n) no quoting, (s) occasional
                             double-quotes with C-style escape, (d)
                             double-quotes with C-style escape, (c)
                             double-quotes with CSV-style escape, (p) between
                             parentheses, any extra non-alphanumeric character
                             will be used to separate propositions
189
190
191
192
193
194
195
196
#+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.

197
198
* Filtering automata

199
200
=autfilt= offers multiple options to filter automata based on
different characteristics of the automaton.
201

202
#+BEGIN_SRC sh :exports results
203
204
205
206
autfilt --help | sed -n '/Filtering options.*:/,/^$/p' | sed '1d;$d'
#+END_SRC
#+RESULTS:
#+begin_example
207
208
209
210
      --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
211
                             in RANGE
212
      --accept-word=WORD     keep automata that accept WORD
213
      --acceptance-is=NAME|FORMULA
214
                             match automata with given acceptance condition
215
      --ap=RANGE             match automata with a number of (declared) atomic
216
                             propositions in RANGE
217
218
      --are-isomorphic=FILENAME   keep automata that are isomorphic to the
                             automaton in FILENAME
219
      --edges=RANGE          keep automata whose number of edges is in RANGE
220
      --equivalent-to=FILENAME   keep automata that are equivalent
221
                             (language-wise) to the automaton in FILENAME
222
223
224
225
      --has-exist-branching  keep automata that use existential branching
                             (i.e., make non-deterministic choices)
      --has-univ-branching   keep alternating automata that use universal
                             branching
226
227
      --included-in=FILENAME keep automata whose languages are included in that
                             of the automaton from FILENAME
228
229
230
231
232
      --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.
233
234
      --intersect=FILENAME   keep automata whose languages have an non-empty
                             intersection with the automaton from FILENAME
235
236
237
      --is-alternating       keep only automata using universal branching
      --is-colored           keep colored automata (i.e., exactly one
                             acceptance mark per transition or state)
238
239
240
      --is-complete          keep complete automata
      --is-deterministic     keep deterministic automata
      --is-empty             keep automata with an empty language
241
      --is-inherently-weak   keep only inherently weak automata
242
      --is-semi-deterministic   keep semi-deterministic automata
243
244
      --is-stutter-invariant keep automata representing stutter-invariant
                             properties
245
246
      --is-terminal          keep only terminal automata
      --is-unambiguous       keep only unambiguous automata
247
      --is-very-weak         keep only very-weak automata
248
      --is-weak              keep only weak automata
249
250
      --nondet-states=RANGE  keep automata whose number of nondeterministic
                             states is in RANGE
251
252
  -N, --nth=RANGE            assuming input automata are numbered from 1, keep
                             only those in RANGE
253
254
255
      --rej-sccs=RANGE, --rejecting-sccs=RANGE
                             keep automata whose number of non-trivial
                             rejecting SCCs is in RANGE
256
      --reject-word=WORD     keep automata that reject WORD
257
258
259
260
261
262
263
264
265
266
267
268
      --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
269
270
271
  -u, --unique               do not output the same automaton twice (same in
                             the sense that they are isomorphic)
  -v, --invert-match         select non-matching automata
272
273
274
      --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.
275
276
277
278
279
#+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.

280
281
282
283
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.
284

285
* Simplifying automata and changing acceptance conditions
286
287
288
   :PROPERTIES:
   :header-args:sh: :results verbatim :exports results
   :END:
289
290
291
292
293
294
295
296

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:

297
#+BEGIN_SRC sh
298
299
300
autfilt --help | sed -n '/Output automaton type:/,/^$/p' | sed '1d;$d'
#+END_SRC
#+RESULTS:
301
302
#+begin_example
  -B, --ba                   Büchi Automaton (with state-based acceptance)
303
304
305
      --cobuchi, --coBuchi   automaton with co-Büchi acceptance (will
                             recognize a superset of the input language if not
                             co-Büchi realizable)
306
307
308
309
310
311
312
313
314
315
316
317
  -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
318

319
These options specify any simplification goal:
320

321
#+BEGIN_SRC sh
322
autfilt --help | sed -n '/Simplification goal:/,/^$/p' | sed '1d;$d'
323
324
#+END_SRC
#+RESULTS:
325
:   -a, --any                  no preference, do not bother making it small or
326
:                              deterministic
327
328
329
:   -D, --deterministic        prefer deterministic automata (combine with
:                              --generic to be sure to obtain a deterministic
:                              automaton)
330
331
332
:       --small                prefer small automata

Finally, the following switches control the amount of effort applied
333
toward the desired goal:
334

335
#+BEGIN_SRC sh
336
autfilt --help | sed -n '/Simplification level:/,/^$/p' | sed '1d;$d'
337
338
339
#+END_SRC
#+RESULTS:
:       --high                 all available optimizations (slow)
340
:       --low                  minimal optimizations (fast)
341
:       --medium               moderate optimizations
342
343
344


By default, =--any --low= is used, which cause all simplifications to
345
346
347
348
349
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
350
351
352
353
354
355
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
356
357
358
359
360
  =--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).
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
- 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
387
deterministic automata, because the minimization might reduce them.)
388
389

If that first procedure failed, and the input automaton is not
390
391
392
393
394
395
396
397
398
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.
399
400
401
402
403

* Transformations

The following transformations are available:

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

#+RESULTS:
Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
409
410
#+begin_example
      --cleanup-acceptance   remove unused acceptance sets from the automaton
411
412
      --cnf-acceptance       put the acceptance condition in Conjunctive Normal
                             Form
413
414
      --complement           complement each automaton (different strategies
                             are used)
Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
415
416
      --complement-acceptance   complement the acceptance condition (without
                             touching the automaton)
417
418
419
420
421
422
      --decompose-scc=t|w|s|N|aN, --decompose-strength=t|w|s|N|aN
                             extract the (t) terminal, (w) weak, or (s) strong
                             part of an automaton or (N) the subautomaton
                             leading to the Nth SCC, or (aN) to the Nth
                             accepting SCC (option can be combined with commas
                             to extract multiple parts)
Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
423
424
425
      --destut               allow less stuttering
      --dnf-acceptance       put the acceptance condition in Disjunctive Normal
                             Form
426
      --dualize              dualize each automaton
427
428
429
430
431
      --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.
432
433
434
435
436
437
438
439
440
441
442
      --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
443
444
      --instut[=1|2]         allow more stuttering (two possible algorithms)
      --keep-states=NUM[,NUM...]   only keep specified states.  The first state
445
446
                             will be the new initial state.  Implies
                             --remove-unreachable-states.
Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
447
448
449
450
      --mask-acc=NUM[,NUM...]   remove all transitions in specified acceptance
                             sets
      --merge-transitions    merge transitions with same destination and
                             acceptance
451
452
453
454
455
      --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
456
457
      --randomize[=s|t]      randomize states and transitions (specify 's' or
                             't' to randomize only states or transitions)
458
459
460
      --remove-ap=AP[=0|=1][,AP...]
                             remove atomic propositions either by existential
                             quantification, or by assigning them 0 or 1
461
462
      --remove-dead-states   remove states that are unreachable, or that cannot
                             belong to an infinite path
463
464
      --remove-fin           rewrite the automaton without using Fin acceptance

465
466
467
      --remove-unreachable-states
                             remove states that are unreachable from the
                             initial state
468
469
      --remove-unused-ap     remove declared atomic propositions that are not
                             used
470
      --sat-minimize[=options]   minimize the automaton using a SAT solver
471
472
473
474
475
476
477
                             (only works for deterministic automata). Supported
                             options are acc=STRING, states=N, max-states=N,
                             sat-incr=N, sat-incr-steps=N, sat-langmap,
                             sat-naive, colored, preproc=N. Spot uses by
                             default its PicoSAT distribution but an external
                             SATsolver can be set thanks to the SPOT_SATSOLVER
                             environment variable(see spot-x).
478
479
480
      --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
481
482
483
      --simplify-acceptance  simplify the acceptance condition by merging
                             identical acceptance sets and by simplifying some
                             terms containing complementary sets
484
485
486
487
      --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)
488
489
490
491
492
493
      --split-edges          split edges into transitions labeled by
                             conjunctions of all atomic propositions, so they
                             can be read as letters
      --streett-like         convert to an automaton with Streett-like
                             acceptance. Works only with acceptance condition
                             in DNF
Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
494
495
      --strip-acceptance     remove the acceptance condition and all acceptance
                             sets
496
497
498
499
500
      --sum=FILENAME, --sum-or=FILENAME
                             build the sum with the automaton in FILENAME to
                             sum languages
      --sum-and=FILENAME     build the sum with the automaton in FILENAME to
                             intersect languages
Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
501
#+end_example
502

503
504
505
506
507
508
* 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=).

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

#+RESULTS:
514
515
516
517
518
519
520
521
522
523
524
525
526
527
#+begin_example
      --highlight-accepting-run[=NUM]
                             highlight one accepting run using color NUM
      --highlight-languages  highlight states that recognize identical
                             languages
      --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
#+end_example
528

529
530
Color numbers are indices in some hard-coded color palette.  It is the
same palette that is currently used to display colored acceptance
531
532
sets, but this might change in the future.

533
534
* Examples

535
** Acceptance transformations
536
537
538
   :PROPERTIES:
   :header-args:sh: :results verbatim :exports code
   :END:
539

540
541
Here is an automaton with transition-based acceptance:

542
#+BEGIN_SRC sh :results silent
543
544
545
546
547
cat >aut-ex1.hoa<<EOF
HOA: v1
States: 3
Start: 0
AP: 2 "a" "b"
548
Acceptance: 5 Inf(0)&Fin(1)&Fin(4) | Inf(2)&Inf(3) | Inf(1)
549
550
551
552
--BODY--
State: 0 {3}
[t] 0
[0] 1 {1}
553
[!0] 2 {0 4}
554
555
556
State: 1 {3}
[1] 0
[0&1] 1 {0}
557
[!0&1] 2 {2 4}
558
559
560
State: 2
[!1] 0
[0&!1] 1 {0}
561
[!0&!1] 2 {0 4}
562
563
564
565
--END--
EOF
#+END_SRC

566
567
(Note: that the =--dot= option used below uses some default options
discussed [[file:oaut.org::#default-dot][on another page]].)
568
569

#+NAME: autfilt-ex1
570
#+BEGIN_SRC sh
571
autfilt aut-ex1.hoa --dot
572
573
#+END_SRC

574
575
#+BEGIN_SRC dot :file autfilt-ex1.svg :var txt=autfilt-ex1 :exports results
  $txt
576
577
578
#+END_SRC

#+RESULTS:
579
[[file:autfilt-ex1.svg]]
580

581
Using =-S= will "push" the acceptance membership of the transitions to the states:
582
583

#+NAME: autfilt-ex2
584
585
#+BEGIN_SRC sh
autfilt -S aut-ex1.hoa --dot
586
587
#+END_SRC

588
#+BEGIN_SRC dot :file autfilt-ex2.svg :var txt=autfilt-ex2 :exports results
589
590
591
592
$txt
#+END_SRC

#+RESULTS:
593
[[file:autfilt-ex2.svg]]
594

595
Using =--cnf-acceptance= simply rewrites the acceptance condition in Conjunctive Normal Form:
596
597

#+NAME: autfilt-ex3
598
#+BEGIN_SRC sh
599
autfilt --cnf-acceptance aut-ex1.hoa --dot
600
601
#+END_SRC

602
#+BEGIN_SRC dot :file autfilt-ex3.svg :var txt=autfilt-ex3 :exports results
603
604
605
606
$txt
#+END_SRC

#+RESULTS:
607
[[file:autfilt-ex3.svg]]
608
609


610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
Using =--simplify-acc= applies several rules (like unit-propagation, detection
of identical acceptance sets, etc) to simplify the acceptance formula of an automaton.

#+NAME: autfilt-ex3b
#+BEGIN_SRC sh
autfilt --simplify-acc aut-ex1.hoa --dot
#+END_SRC

#+BEGIN_SRC dot :file autfilt-ex3b.svg :var txt=autfilt-ex3b :exports results
  $txt
#+END_SRC

#+RESULTS:
[[file:autfilt-ex3b.svg]]


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.  Fin removal does
not simplify the automaton constructed, so additionally passing
=--small= will help reduce the automaton.
631
632

#+NAME: autfilt-ex4
633
#+BEGIN_SRC sh
634
autfilt --remove-fin --small aut-ex1.hoa --dot
635
636
#+END_SRC

637
#+BEGIN_SRC dot :file autfilt-ex4.svg :var txt=autfilt-ex4 :exports results
638
639
640
641
$txt
#+END_SRC

#+RESULTS:
642
[[file:autfilt-ex4.svg]]
643
644
645
646
647
648

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
649
#+BEGIN_SRC sh
650
autfilt --mask-acc=1,2 aut-ex1.hoa --dot
651
652
#+END_SRC

653
#+BEGIN_SRC dot :file autfilt-ex5.svg :var txt=autfilt-ex5 :exports results
654
655
656
657
$txt
#+END_SRC

#+RESULTS:
658
[[file:autfilt-ex5.svg]]
659

660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694

The =--colored-parity= request a transformation to parity acceptance.
The "colored" part of the option mean that each edge should be
colored by one acceptance sets.  (Using =--parity= would allow edges
without any color.)

#+NAME: autfilt-ex6
#+BEGIN_SRC sh
autfilt --colored-parity aut-ex1.hoa --dot
#+END_SRC

#+BEGIN_SRC dot :file autfilt-ex6.svg :var txt=autfilt-ex6 :exports results
$txt
#+END_SRC

#+RESULTS:
[[file:autfilt-ex6.svg]]

A specific type of parity acceptance can be forced by passing it as an
argument of the =--parity= or =--colored-parity= option.

#+NAME: autfilt-ex6b
#+BEGIN_SRC sh
autfilt --parity='min odd' aut-ex1.hoa --dot
#+END_SRC

#+BEGIN_SRC dot :file autfilt-ex6b.svg :var txt=autfilt-ex6b :exports results
$txt
#+END_SRC

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



695
** Atomic proposition removal
696
697
698
   :PROPERTIES:
   :header-args:sh: :results verbatim :exports code
   :END:
699
700
701
702
703
704
705
706
707
708

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
709
#+BEGIN_SRC sh
710
autfilt --remove-ap=a aut-ex1.hoa --dot
711
712
#+END_SRC

713
#+BEGIN_SRC dot :file autfilt-ex6a.svg :var txt=autfilt-ex6a :exports results
714
715
716
717
$txt
#+END_SRC

#+RESULTS:
718
[[file:autfilt-ex6a.svg]]
719
720

#+NAME: autfilt-ex6b
721
#+BEGIN_SRC sh
722
autfilt --remove-ap=a=0 aut-ex1.hoa --dot
723
724
#+END_SRC

725
#+BEGIN_SRC dot :file autfilt-ex6b.svg :var txt=autfilt-ex6b :exports results
726
727
728
729
$txt
#+END_SRC

#+RESULTS:
730
[[file:autfilt-ex6b.svg]]
731
732

#+NAME: autfilt-ex6c
733
#+BEGIN_SRC sh
734
autfilt --remove-ap=a=1 aut-ex1.hoa --dot
735
736
#+END_SRC

737
#+BEGIN_SRC dot :file autfilt-ex6c.svg :var txt=autfilt-ex6c :exports results
738
739
740
741
$txt
#+END_SRC

#+RESULTS:
742
[[file:autfilt-ex6c.svg]]
743

744
** Testing word acceptance
745
746
747
748
   :PROPERTIES:
   :header-args:sh: :results verbatim :exports both
   :END:

749

750
The following example checks whether the formula ~a U b U c~ accepts
751
the word ~a&!b&!c; cycle{!a&!b&c}~.
752

753
#+BEGIN_SRC sh
754
ltl2tgba 'a U b U c' |
755
  autfilt --accept-word 'a&!b&!c; cycle{!a&!b&c}' -q  && echo "word accepted"
756
757
758
#+END_SRC
#+RESULTS:
: word accepted
759
760
761
762
763
764
765
766

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=).

767
#+BEGIN_SRC sh
768
randltl -n -1 a b | ltlfilt --simplify --uniq | ltl2tgba |
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
  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
786
787
788
789
790
791
792
793
794
795
796

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:

797
#+BEGIN_SRC sh
798
randltl -n -1 a b | ltlfilt --simplify --remove-wm |
799
    ltldo ltl2dstar --name=%f | autfilt --states=4 --stats=%M -n 5
800
801
802
803
804
805
806
807
#+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))
808
809
810

** Decorations
   :PROPERTIES:
811
   :header-args:sh: :results verbatim :exports code
812
813
   :END:

814
We know from a previous example that formula =a U b U c= accepts the
815
816
817
818
word =b; cycle{c}=.  We can actually highlight the corresponding
run in the automaton:

#+NAME: highlight-word
819
#+BEGIN_SRC sh
820
821
822
ltl2tgba 'a U b U c' | autfilt --highlight-word='a&!b&!c; cycle{!a&!b&c}' -d
#+END_SRC

823
#+BEGIN_SRC dot :file autfilt-hlword.svg :var txt=highlight-word :exports results
824
825
826
827
$txt
#+END_SRC

#+RESULTS:
828
[[file:autfilt-hlword.svg]]
829
830
831
832
833
834
835
836


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
837
#+BEGIN_SRC sh
838
839
840
841
842
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

843
#+BEGIN_SRC dot :file autfilt-hlword2.svg :var txt=highlight-word2 :exports results
844
845
846
847
  $txt
#+END_SRC

#+RESULTS:
848
[[file:autfilt-hlword2.svg]]
849
850
851
852
853
854
855
856



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

#+NAME: highlight-nondet
857
#+BEGIN_SRC sh
858
859
860
861
ltl2tgba 'F((b R a) W Gb)' |
    autfilt --highlight-nondet-states=5 --highlight-nondet-edges=1 -d
#+END_SRC

862
#+BEGIN_SRC dot :file autfilt-hlnondet.svg :var txt=highlight-nondet :exports results
863
864
865
866
  $txt
#+END_SRC

#+RESULTS:
867
[[file:autfilt-hlnondet.svg]]
868
869
870
871
872


#+BEGIN_SRC sh :results silent :exports results
rm -f example.hoa aut-ex1.hoa
#+END_SRC
873
874
875
876
877
878
879
880
881
882

#  LocalWords:  utf html args pre LBTT's dstar lbtt SRC EOF DOTEXTRA
#  LocalWords:  rankdir invis init fi randaut acc SCCs det tgba sed
#  LocalWords:  CSV iw dges tates sccs ap SCC nondet rej triv ba Dax
#  LocalWords:  cobuchi coBuchi superset sbacc determinized al ATVA
#  LocalWords:  Safra Redziejowski cnf scc aN subautomaton destut dnf
#  LocalWords:  dualize APs rabin gra streett gsa instut NUM incr aut
#  LocalWords:  langmap preproc PicoSAT SATsolver SATSOLVER svg txt
#  LocalWords:  randltl ltlfilt uniq Fb XF ltldo wm Gb GFa FG hlword
#  LocalWords:  hlnondet