tools: Add a --format option

* src/bin/common_output.cc: Add option --format and implement
it.
* src/bin/ltlfilt.cc, src/bin/randltl.cc: Document the
supported %-sequences.
* src/bin/genltl.cc: Document the %-sequences, and supply
the name of the pattern to output_formula().
* doc/org/genltl.org, doc/org/ioltl.org, doc/org/ltlfilt.org,
NEWS: Document it.
* src/ltltest/latex.test: Use it.
This commit is contained in:
Alexandre Duret-Lutz 2013-09-22 22:02:10 +02:00
parent 983feb5290
commit ce5ea829bd
9 changed files with 297 additions and 77 deletions

View file

@ -47,7 +47,7 @@ genltl --help | sed -n '/Pattern selection:/,/^$/p' | sed '1d;$d'
(p1 U (p2 U (... U pn)))
#+end_example
An example is probably all it takes to explain how this tool works:
An example is probably all it takes to understand how this tool works:
#+BEGIN_SRC sh :results verbatim :exports both
genltl --and-gf=1..5 --u-left=1..5
@ -69,9 +69,47 @@ p1 U p2
=genltl= supports the [[file:ioltl.org][common option for output of LTL formulas]], so you
may output these pattern for various tools.
Note that for the =--lbt= output, each formula is relabeled using
For instance here is the same formulas, but formatted in a way that is
suitable for being included in a LaTeX table.
#+BEGIN_SRC sh :results verbatim :exports both
genltl --and-gf=1..5 --u-left=1..5 --latex --format='%F & %L & $%f$ \\'
#+END_SRC
#+RESULTS:
#+begin_example
and-gf & 1 & $\G \F p_{1}$ \\
and-gf & 2 & $\G \F p_{1} \land \G \F p_{2}$ \\
and-gf & 3 & $\G \F p_{1} \land \G \F p_{2} \land \G \F p_{3}$ \\
and-gf & 4 & $\G \F p_{1} \land \G \F p_{2} \land \G \F p_{3} \land \G \F p_{4}$ \\
and-gf & 5 & $\G \F p_{1} \land \G \F p_{2} \land \G \F p_{3} \land \G \F p_{4} \land \G \F p_{5}$ \\
u-left & 1 & $p_{1}$ \\
u-left & 2 & $p_{1} \U p_{2}$ \\
u-left & 3 & $(p_{1} \U p_{2}) \U p_{3}$ \\
u-left & 4 & $((p_{1} \U p_{2}) \U p_{3}) \U p_{4}$ \\
u-left & 5 & $(((p_{1} \U p_{2}) \U p_{3}) \U p_{4}) \U p_{5}$ \\
#+end_example
Note that for the =--lbt= syntax, each formula is relabeled using
=p0=, =p1=, ... before it is output, when the pattern (like
=--ccj-alpha=) use different names.
=--ccj-alpha=) use different names. Compare:
#+BEGIN_SRC sh :results verbatim :exports both
genltl --ccj-alpha=3
#+END_SRC
#+RESULTS:
: F(F(Fq3 & q2) & q1) & F(F(Fp3 & p2) & p1)
with
#+BEGIN_SRC sh :results verbatim :exports both
genltl --ccj-alpha=3 --lbt
#+END_SRC
#+RESULTS:
: & F & p2 F & p1 F p0 F & F & F p3 p4 p5
This is because most tools using =lbt='s syntax require atomic
propositions to have the form =pNN=.
# LocalWords: genltl num toc LTL scalable SRC sed gh pn fg FG gf qn
# LocalWords: ccj Xp XXp Xq XXq rv GFp lbt

View file

@ -141,7 +141,10 @@ ltlfilt --help | sed -n '/Output options:/,/^$/p' | sed '1d;$d'
#+END_SRC
#+RESULTS:
: -8, --utf8 output using UTF-8 characters
: --format=FORMAT specify how each line should be output (default:
: "%f")
: -l, --lbt output in LBT's syntax
: --latex output using LaTeX macros
: -p, --full-parentheses output fully-parenthesized formulas
: -s, --spin output in Spin's syntax
: --spot output in Spot's syntax (default)
@ -150,8 +153,14 @@ ltlfilt --help | sed -n '/Output options:/,/^$/p' | sed '1d;$d'
# LocalWords: syntaxes LTL PSL num toc SRC ltl tgba sed FILENAME
The =--spot=, =--utf-8=, =--spin=, =--wring= options select different
output syntaxes as seen in [[tab:formula-syntaxes][the above table]]. The =-p= option can
be used to request that parentheses be used at all levels.
output syntaxes as seen in [[tab:formula-syntaxes][the above table]].
Option =--latex= causes formulas to be output using LaTeX macros for
each operator. You may define these macros as you wish, and some
example definitions are in =doc/tl/spotltl.sty=.
The =-p= option can be used to request that parentheses be used at all
levels.
Note that by default Spot always outputs parentheses around operators
such as =U=, because not all tools agree on their associativity. For
@ -162,5 +171,16 @@ with read it as =(a U b) U c=.
The =--lbt= option requests an output in LBT's prefix format, and in
that case discussing associativity and parentheses makes no sense.
The =--format= option can be used to fine-tune the way the formula is
output. Not using the =--format= option is equivalent to using
=--format=%f=. The semantic of the available =%=-sequences differ
from tool to tool:
| | =%f= | =%F= | =%L= |
|-----------+----------------+----------------+-------------------|
| [[file:ltlfilt.org][=ltlfilt=]] | output formula | input filename | input line |
| [[file:genltl.org][=genltl=]] | output formula | pattern name | pattern parameter |
| [[file:randltl.org][=randltl=]] | output formula | (empty) | formula number |
# LocalWords: lbt LBT's filename UTF gfa GFa ltlfilt LBTT scheck
# LocalWords: utf associativity

View file

@ -253,6 +253,23 @@ It is therefore equivalent, but that is not a surprise since the
[[http://homepages.inf.ed.ac.uk/kousha/note_on_stut_tl_lpi.ps][this procedure]] (calling the =remove_x()= function, and building automata
to check the equivalence of the resulting formula with the original one).
* Using =--format=
The =--format= option can be used the alter the way formulas are output (for instance use
#+HTML: <code>--latex --format='$%f$'</code>
to enclose formula in LaTeX format with =$...$=). You may also find
=--format= useful in more complex scenarios. For instance you could
print the only the line numbers containing formulas matching some
criterion. In the following, we print only the numbers of the lines
of =scheck.ltl= that contain guarantee formulas:
#+BEGIN_SRC sh :results verbatim :exports both
ltlfilt --lbt-input -F scheck.ltl --guarantee --format=%L
#+END_SRC
#+RESULTS:
: 2
: 3
: 4
# LocalWords: ltlfilt num toc LTL PSL syntaxes LBT's SRC GFp scheck
# LocalWords: ltl EOF lbt Gp Fp Xp XFp XXp randltl ary nnf wm abc