ltlsynt: allow regular expressions in --ins/--outs

* bin/ltlsynt.cc: Implement this.
* doc/org/ltlsynt.org, NEWS: Adjust documentation.
* tests/core/ltlsynt.test: Add test cases.
This commit is contained in:
Alexandre Duret-Lutz 2024-02-17 12:56:28 +01:00
parent 31462d84ba
commit 15b876d368
4 changed files with 227 additions and 117 deletions

View file

@ -22,12 +22,15 @@ specifically as Mealy machines). In the automaton representing the
controller, the acceptance condition is irrelevant and trivially true.
=ltlsynt= has three mandatory options:
- =--ins=: a comma-separated list of input atomic propositions;
- =--outs=: a comma-separated list of output atomic propositions;
- =--ins=: a comma-separated list of input atomic propositions, or input regexes enclosed in slashes;
- =--outs=: a comma-separated list of output atomic propositions, or output regexes enclosed in slashes;
- =--formula= or =--file=: a specification in LTL or PSL.
One of =--ins= or =--outs= may be omitted, as any atomic proposition not listed
as input can be assumed to be output and vice versa.
One of =--ins= or =--outs= may be omitted, as any atomic proposition
not listed as input can be assumed to be output and vice versa. If
both are omitted, =ltlsynts= will assume ~--ins=/^[iI]/~ and
~--outs=/^[oO]/~, i.e., atomic propositions will be classified as
input or output based on their first letter.
The following example illustrates the synthesis of a controller
ensuring that input =i1= and =i2= are both true initially if and only
@ -36,7 +39,7 @@ Note that this is an equivalence, not an implication.
#+NAME: example
#+BEGIN_SRC sh :exports both
ltlsynt --ins=i1,i2 -f '(i1 & i2) <-> F(o1 & X(!o1))'
ltlsynt -f '(i1 & i2) <-> F(o1 & X(!o1))'
#+END_SRC
#+RESULTS: example
@ -55,24 +58,27 @@ State: 0
[0&1&2] 1
[!0&2 | !1&2] 2
State: 1
[!2] 0
[!2] 1
State: 2
[2] 2
--END--
#+end_example
The output is composed of two parts:
- The first one is a single line =REALIZABLE= or =UNREALIZABLE=; the presence of this
line, required by the [[http://http://www.syntcomp.org/][SyntComp competition]], can be disabled with option =--hide-status=.
- The second one, only present in the =REALIZABLE= case, is an automaton describing the controller.
- The first part is a single line stating =REALIZABLE= or
=UNREALIZABLE=; the presence of this line, required by the [[http://http://www.syntcomp.org/][SyntComp
competition]], can be disabled with option =--hide-status=.
- The second part, only present in the =REALIZABLE= case, is an
automaton describing the controller.
The controller contains the line =controllable-AP: 2=, which means that this automaton
should be interpreted as a Mealy machine where =o0= is part of the output.
Using the =--dot= option, makes it easier to visualize this machine.
The controller contains the line =controllable-AP: 2=, which means
that this automaton should be interpreted as a Mealy machine where
=o0= is part of the output. Using the =--dot= option, makes it easier
to visualize this machine.
#+NAME: exampledot
#+BEGIN_SRC sh :exports code
ltlsynt --ins=i1,i2 -f '(i1 & i2) <-> F(o1 & X(!o1))' --hide-status --dot
ltlsynt -f '(i1 & i2) <-> F(o1 & X(!o1))' --hide-status --dot
#+END_SRC
#+BEGIN_SRC dot :file ltlsyntex.svg :var txt=exampledot :exports results
@ -99,28 +105,32 @@ flag. This is the output format required for the [[http://syntcomp.org/][SYNTCOM
#+NAME: exampleaig
#+BEGIN_SRC sh :exports both
ltlsynt --ins=i1,i2 -f '(i1 & i2) <-> F(o1 & X(!o1))' --aiger
ltlsynt -f '(i1 & i2) <-> F(o1 & X(!o1))' --aiger
#+END_SRC
#+RESULTS: exampleaig
#+begin_example
REALIZABLE
aag 14 2 2 1 10
aag 18 2 2 1 14
2
4
6 14
8 29
6 23
8 37
7
10 7 9
12 4 10
14 2 12
16 7 8
18 4 16
20 5 7
22 21 19
24 2 23
26 3 7
28 27 25
10 6 9
12 4 9
14 5 10
16 13 15
18 2 17
20 3 10
22 19 21
24 7 8
26 4 24
28 5 7
30 27 29
32 2 31
34 3 7
36 33 35
i0 i1
i1 i2
o0 o1
@ -132,7 +142,7 @@ the controller:
#+NAME: exampleaigdot
#+BEGIN_SRC sh :exports code
ltlsynt --ins=i1,i2 -f '(i1 & i2) <-> F(o1 & X(!o1))' --hide-status --aiger --dot
ltlsynt -f '(i1 & i2) <-> F(o1 & X(!o1))' --hide-status --aiger --dot
#+END_SRC
#+BEGIN_SRC dot :file ltlsyntexaig.svg :var txt=exampleaigdot :exports results
@ -147,7 +157,7 @@ circles represent inversions (or negations), colored triangles are
used to represent input signals (at the bottom) and output signals (at
the top), and finally rectangles represent latches. A latch is a one
bit register that delays the signal by one step. Initially, all
latches are assumed to contain =false=, and them emit their value from
latches are assumed to contain =false=, and they emit their value from
the =L0_out= and =L1_out= rectangles at the bottom. Their input value,
to be emitted at the next step, is received via the =L0_in= and =L1_in=
boxes at the top. In =ltlsynt='s encoding, the set of latches is used
@ -172,8 +182,9 @@ be synthesized using =syfco= and =ltlsynt=:
ltlsynt --tlsf FILE
#+END_SRC
The above =--tlsf= option will call =syfco= to perform the conversion
and extract output signals, as if you had used:
The above =--tlsf= option will call =syfco= (which must be on your
=$PATH=) to perform the conversion and extract output signals, as if
you had used:
#+BEGIN_SRC sh :export code
LTL=$(syfco -f ltlxba -m fully FILE)
@ -181,6 +192,7 @@ OUT=$(syfco --print-output-signals FILE)
ltlsynt --formula="$LTL" --outs="$OUT"
#+END_SRC
* Internal details
The tool reduces the synthesis problem to a parity game, and solves the parity
@ -237,13 +249,13 @@ be tried by separating them using commas. For instance
You can also ask =ltlsynt= to print to obtained parity game into
[[https://github.com/tcsprojects/pgsolver][PGSolver]] format, with the flag =--print-pg=, or in the HOA format,
using =--print-game-hoa=. These flag deactivate the resolution of the
using =--print-game-hoa=. These flags deactivate the resolution of the
parity game. Note that if any of those flag is used with =--dot=, the game
will be printed in the Dot format instead:
#+NAME: examplegamedot
#+BEGIN_SRC sh :exports code
ltlsynt --ins=i1,i2 -f '(i1 & i2) <-> F(o1 & X(!o1))' --print-game-hoa --dot
ltlsynt -f '(i1 & i2) <-> F(o1 & X(!o1))' --print-game-hoa --dot
#+END_SRC
#+BEGIN_SRC dot :file ltlsyntexgame.svg :var txt=examplegamedot :exports results
$txt