ltlcross
ltlcross
is a tool for cross-comparing the output of LTL-to-Büchi
translators. It is actually a Spot-based clone of LBTT, the
LTL-to-Büchi Translator Testbench, that essentially performs the
same sanity checks.
The main motivations for rewriting this tool were:
- support for PSL formulas in addition to LTL
- more statistics, especially:
- the number of logical transitions represented by each physical edge,
- the number of deterministic states and automata
- the number of SCCs with their various strengths (nonaccepting, terminal, weak, strong)
- the number of terminal, weak, and strong automata
- output in a format that can be more easily be post-processed,
- more precise time measurement (LBTT was only precise to 1/100 of a second, reporting most times as "0.00s").
Although ltlcross
performs the same sanity checks as LBTT, it does
not implement any of the interactive features of LBTT. In our almost
10-year usage of LBTT, we never had to use its interactive features to
understand bugs in our translation. Therefore ltlcross
will report
problems, but you will be on your own to investigate and fix them.
The core of ltlcross
is a loop that does the following steps:
- Input a formula
- Translate the formula and its negation using each configured translator.
If there are 3 translators, the positive and negative translations
will be denoted
P0
,N0
,P1
,N1
,P2
,N2
. - Build the products of these automata with a random state-space (the same
state-space for all translations). (If the
--products=N
option is given,N
products are performed instead.) - Perform sanity checks between all these automata to detect any problem.
- Gather statistics if requested.
Table of Contents
Formula selection
Formulas to translate should be specified using the common input options.
Standard input is read if no -f
or -F
option is given.
Configuring translators
Each translator should be specified as a string that use some of the following character sequences:
%f,%s,%l,%w the formula as a (quoted) string in Spot, Spin, LBT, or Wring's syntax %F,%S,%L,%W the formula as a file in Spot, Spin, LBT, or Wring's syntax %N,%T the output automaton as a Never claim, or in LBTT's format
For instance here is how we could cross-compare the never claims
output by spin
and ltl2tgba
for the formulas GFa
and X(a U b)
.
ltlcross -f 'GFa' -f 'X(a U b)' 'ltl2tgba -s %s >%N' 'spin -f %s >%N'
When ltlcross
executes these commands, %s
will be replaced
by the formula in Spin's syntax, and %N
will be replaced by a
temporary file into which the output of the translator is redirected
before it is read back by ltlcross
.
([](<>(a))) Running [P0]: ltl2tgba -s '([](<>(a)))' >'lck-o0-RLb5ZM' Running [P1]: spin -f '([](<>(a)))' >'lck-o1-YfD6Bz' Running [N0]: ltl2tgba -s '(!([](<>(a))))' >'lck-o0-xwxpem' Running [N1]: spin -f '(!([](<>(a))))' >'lck-o1-8533T8' Performing sanity checks and gathering statistics... (X((a) U (b))) Running [P0]: ltl2tgba -s '(X((a) U (b)))' >'lck-o0-DKzICV' Running [P1]: spin -f '(X((a) U (b)))' >'lck-o1-nhwNoI' Running [N0]: ltl2tgba -s '(!(X((a) U (b))))' >'lck-o0-URi9av' Running [N1]: spin -f '(!(X((a) U (b))))' >'lck-o1-zr6N0h' Performing sanity checks and gathering statistics... No problem detected.
ltlcross
can only read two kinds of output:
- Never claims (only if they are restricted to representing an
automaton using
if
,goto
, andskip
statements) such as those output byspin
,ltl2ba
,ltl3ba
, orltl2tgba --spin
. These should be indicated using%N
. - LBTT's format, which supports generalized Büchi automata with
either state-based acceptance or transition-based acceptance.
This output is used for instance by
lbt
,modella
, orltl2tgba --lbtt
. These should be indicated using%T
.
Of course all configured tools need not the same %
sequences.
Getting statistics
Detailed statistics about the result of each translation, and the
product of that resulting automaton with the random state-space, can
be obtained using the --csv=FILE
or --json=FILE
option.
CSV or JSON output (or both!)
The following compare ltl2tgba
, spin
, and lbt
on three random
formula (where W
and M
operators have been rewritten away because
they are not supported by spin
and lbt
).
randltl -n 2 a b | ltlfilt --remove-wm | ltlcross --csv=results.csv \ 'ltl2tgba -s %f >%N' \ 'spin -f %s >%N' \ 'lbt < %L >%T'
-:1: (G(((p0) U ((p0) & (G(p1)))) R ((G(p1)) | ((p0) U ((p0) & (G(p1))))))) Running [P0]: ltl2tgba -s '(G(((p0) U ((p0) & (G(p1)))) R ((G(p1)) | ((p0) U ((p0) & (G(p1)))))))' >'lck-o0-ZsA0oQ' Running [P1]: spin -f '([](((p0) U ((p0) && ([](p1)))) V (([](p1)) || ((p0) U ((p0) && ([](p1)))))))' >'lck-o1-laziJD' Running [P2]: lbt < 'lck-i0-1TLr82' >'lck-o2-7DNu4q' Running [N0]: ltl2tgba -s '(!(G(((p0) U ((p0) & (G(p1)))) R ((G(p1)) | ((p0) U ((p0) & (G(p1))))))))' >'lck-o0-b6ZzL1' Running [N1]: spin -f '(!([](((p0) U ((p0) && ([](p1)))) V (([](p1)) || ((p0) U ((p0) && ([](p1))))))))' >'lck-o1-L8fEaP' Running [N2]: lbt < 'lck-i0-Jbg2pe' >'lck-o2-b0ghAC' Performing sanity checks and gathering statistics... -:2: (!((G(F(p0))) -> (F(p1)))) Running [P0]: ltl2tgba -s '(!((G(F(p0))) -> (F(p1))))' >'lck-o0-1NVkJf' Running [P1]: spin -f '(!((<>(p1)) || (!([](<>(p0))))))' >'lck-o1-ddKqm4' Running [P2]: lbt < 'lck-i1-9qMN9q' >'lck-o2-38PPZS' Running [N0]: ltl2tgba -s '(G(F(p0))) -> (F(p1))' >'lck-o0-bJthhw' Running [N1]: spin -f '(<>(p1)) || (!([](<>(p0))))' >'lck-o1-XL4zYk' Running [N2]: lbt < 'lck-i1-V7vyDH' >'lck-o2-z989F9' Performing sanity checks and gathering statistics... No problem detected.
After this execution, the file results.csv
contains the following:
"formula", "tool", "states", "edges", "transitions", "acc", "scc", "nonacc_scc", "terminal_scc", "weak_scc", "strong_scc", "nondet_states", "nondet_aut", "terminal_aut", "weak_aut", "strong_aut", "time", "product_states", "product_transitions", "product_scc" "(G(((p0) U ((p0) & (G(p1)))) R ((G(p1)) | ((p0) U ((p0) & (G(p1)))))))", "ltl2tgba -s %f >%N", 3, 5, 9, 1, 3, 2, 0, 1, 0, 2, 1, 0, 1, 0, 0.0247916, 401, 5168, 3 "(G(((p0) U ((p0) & (G(p1)))) R ((G(p1)) | ((p0) U ((p0) & (G(p1)))))))", "spin -f %s >%N", 6, 13, 18, 1, 3, 2, 0, 0, 1, 6, 1, 0, 0, 1, 0.00583836, 999, 14414, 5 "(G(((p0) U ((p0) & (G(p1)))) R ((G(p1)) | ((p0) U ((p0) & (G(p1)))))))", "lbt < %L >%T", 8, 41, 51, 1, 3, 2, 0, 0, 1, 8, 1, 0, 0, 1, 0.001993, 1397, 43175, 5 "(!(G(((p0) U ((p0) & (G(p1)))) R ((G(p1)) | ((p0) U ((p0) & (G(p1))))))))", "ltl2tgba -s %f >%N", 4, 10, 16, 1, 3, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0.0234398, 797, 16411, 3 "(!(G(((p0) U ((p0) & (G(p1)))) R ((G(p1)) | ((p0) U ((p0) & (G(p1))))))))", "spin -f %s >%N", 7, 24, 63, 1, 4, 2, 1, 0, 1, 6, 1, 0, 0, 1, 0.00338619, 1400, 64822, 4 "(!(G(((p0) U ((p0) & (G(p1)))) R ((G(p1)) | ((p0) U ((p0) & (G(p1))))))))", "lbt < %L >%T", 39, 286, 614, 3, 28, 26, 1, 0, 1, 33, 1, 0, 0, 1, 0.00242263, 7583, 600472, 4394 "(!((G(F(p0))) -> (F(p1))))", "ltl2tgba -s %f >%N", 2, 4, 4, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0.0236119, 399, 4130, 1 "(!((G(F(p0))) -> (F(p1))))", "spin -f %s >%N", 2, 3, 5, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0.00194096, 399, 5174, 1 "(!((G(F(p0))) -> (F(p1))))", "lbt < %L >%T", 5, 10, 15, 1, 4, 3, 0, 0, 1, 5, 1, 0, 0, 1, 0.00195495, 407, 6333, 9 "(G(F(p0))) -> (F(p1))", "ltl2tgba -s %f >%N", 3, 5, 11, 1, 3, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0.0238844, 600, 11305, 3 "(G(F(p0))) -> (F(p1))", "spin -f %s >%N", 3, 5, 14, 1, 3, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0.00174447, 600, 14397, 3 "(G(F(p0))) -> (F(p1))", "lbt < %L >%T", 11, 18, 54, 2, 11, 9, 1, 1, 0, 5, 1, 0, 1, 0, 0.00193817, 1245, 25838, 449
This can be loaded in any spreadsheet application. Although we only
supplied 2 random generated formulas, the output contains 4 formulas because
ltlcross
had to translate the positive and negative version of each.
If we had used the option --json=results.json
instead of (or in
addition to) --cvs=results.csv
, the file results.json
would have
contained the following JSON output.
{ "tool": [ "ltl2tgba -s %f >%N", "spin -f %s >%N", "lbt < %L >%T" ], "formula": [ "(G(((p0) U ((p0) & (G(p1)))) R ((G(p1)) | ((p0) U ((p0) & (G(p1)))))))", "(!(G(((p0) U ((p0) & (G(p1)))) R ((G(p1)) | ((p0) U ((p0) & (G(p1))))))))", "(!((G(F(p0))) -> (F(p1))))", "(G(F(p0))) -> (F(p1))" ], "fields": [ "formula", "tool", "states", "edges", "transitions", "acc", "scc", "nonacc_scc", "terminal_scc", "weak_scc", "strong_scc", "nondet_states", "nondet_aut", "terminal_aut", "weak_aut", "strong_aut", "time", "product_states", "product_transitions", "product_scc" ], "inputs": [ 0, 1 ], "results": [ [ 0, 0, 3, 5, 9, 1, 3, 2, 0, 1, 0, 2, 1, 0, 1, 0, 0.0247916, 401, 5168, 3 ], [ 0, 1, 6, 13, 18, 1, 3, 2, 0, 0, 1, 6, 1, 0, 0, 1, 0.00583836, 999, 14414, 5 ], [ 0, 2, 8, 41, 51, 1, 3, 2, 0, 0, 1, 8, 1, 0, 0, 1, 0.001993, 1397, 43175, 5 ], [ 1, 0, 4, 10, 16, 1, 3, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0.0234398, 797, 16411, 3 ], [ 1, 1, 7, 24, 63, 1, 4, 2, 1, 0, 1, 6, 1, 0, 0, 1, 0.00338619, 1400, 64822, 4 ], [ 1, 2, 39, 286, 614, 3, 28, 26, 1, 0, 1, 33, 1, 0, 0, 1, 0.00242263, 7583, 600472, 4394 ], [ 2, 0, 2, 4, 4, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0.0236119, 399, 4130, 1 ], [ 2, 1, 2, 3, 5, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0.00194096, 399, 5174, 1 ], [ 2, 2, 5, 10, 15, 1, 4, 3, 0, 0, 1, 5, 1, 0, 0, 1, 0.00195495, 407, 6333, 9 ], [ 3, 0, 3, 5, 11, 1, 3, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0.0238844, 600, 11305, 3 ], [ 3, 1, 3, 5, 14, 1, 3, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0.00174447, 600, 14397, 3 ], [ 3, 2, 11, 18, 54, 2, 11, 9, 1, 1, 0, 5, 1, 0, 1, 0, 0.00193817, 1245, 25838, 449 ] ] }
Here the fields
table describes the columns of the results
table.
The inputs
tables lists the columns that are considered as inputs
for the experiments. The values in the columns corresponding to the
fields formula
and tool
contains indices relative to the formula
and tool
tables. This format is more compact when dealing with lots
of translators and formulas, because they don't have to be repeated on
each line as in the CSV version.
JSON data can be easily processed in any language. For instance the
following Python3 script averages each column for each tool, and
presents the results in a form that can almost be copied into a LaTeX
table (the %
in the tool names have to be taken care of). Note that
for simplicity we assume that the first two columns are inputs,
instead of reading the inputs
field.
#!/usr/bin/python3 import json data = json.load(open('results.json')) datacols = range(2, len(data["fields"])) # Index results by tool results = { t:[] for t in range(0, len(data["tool"])) } for l in data["results"]: results[l[1]].append(l) # Average columns for each tool, and display them as a table print("%-18s & count & %s \\\\" % ("tool", " & ".join(data["fields"][2:]))) for i in range(0, len(data["tool"])): c = len(results[i]) sums = ["%6.1f" % (sum([x[j] for x in results[i]])/c) for j in datacols] print("%-18s & %3d & %s \\\\" % (data["tool"][i], c, " & ".join(sums)))
tool & count & states & edges & transitions & acc & scc & nonacc_scc & terminal_scc & weak_scc & strong_scc & nondet_states & nondet_aut & terminal_aut & weak_aut & strong_aut & time & product_states & product_transitions & product_scc \\ ltl2tgba -s %f >%N & 4 & 3.0 & 6.0 & 10.0 & 1.0 & 2.5 & 1.0 & 0.5 & 0.5 & 0.5 & 0.8 & 0.5 & 0.0 & 0.5 & 0.5 & 0.0 & 549.2 & 9253.5 & 2.5 \\ spin -f %s >%N & 4 & 4.5 & 11.2 & 25.0 & 1.0 & 2.8 & 1.2 & 0.5 & 0.2 & 0.8 & 3.5 & 1.0 & 0.0 & 0.2 & 0.8 & 0.0 & 849.5 & 24701.8 & 3.2 \\ lbt < %L >%T & 4 & 15.8 & 88.8 & 183.5 & 1.8 & 11.5 & 10.0 & 0.5 & 0.2 & 0.8 & 12.8 & 1.0 & 0.0 & 0.2 & 0.8 & 0.0 & 2658.0 & 168954.5 & 1214.2 \\
The script bench/ltl2tgba/sum.py
is a more evolved version of the
above script that generates two kinds of LaTeX tables.
When computing such statistics, you should be aware that inputs for
which a tool failed to generate an automaton (e.g. it crashed, or it
was killed if you used ltlcross
's --timeout
option to limit run
time) are not represented in the CSV or JSON files. However data for
bogus automata are still included: as shown below ltlcross
will
report inconsistencies between automata as errors, but it does not try
to guess who is incorrect.
Description of the columns
formula
and tool
contain the formula translated and the command
run to translate it. In the CSV, these columns contain the actual
text. In the JSON output, these column contains an index into the
formula
and tool
table declared separately.
states
, edged
, transitions
, acc
are size measures for the
automaton that was translated. acc
counts the number of acceptance
sets. When building (degeneralized) Büchi automata, it will always be
1
, so its value is meaningful only when evaluating translations to
generalized Büchi automata. edges
counts the actual number of edges
in the graph supporting the automaton; an edge (labeled by a Boolean
formula) might actually represent several transitions (each labeled by
assignment of all atomic propositions). For instance in an automaton
where the atomic proposition are \(a\) and \(b\), one edge labeled by
\(a\lor b\) actually represents three transitions \(a b\), \(a\bar b\), and
\(\bar a b\).
The following picture displays two automata for the LTL formula a U b
. They both have 2 states and 3 edges, however they differ in the
number of transitions (7 versus 8), because the initial self-loop is
more constrained in the first automaton. A smaller number of
transition is therefore an indication of a more constrained automaton.
scc
counts the number of strongly-connected components in the automaton. These SCCs are
also partitioned on four sets based on their strengths:
nonacc_scc
for non-accepting SCCs (such as states A1 and A2 in the previous picture)terminal_scc
for SCCs that consist of a single state with an accepting self-loop labeled by true (such as states B1 and B2 in the previous picture)weak_scc
for non-terminal SCCs in which all cycles are accepting- and
strong_scc
for accepting SCCs in which some cycles are not accepting.
These SCC strengths can be used to compute the strength of the automaton as a whole:
- an automaton is terminal if it contains only non-accepting or terminal SCCs,
- an automaton is weak if it it contains only non-accepting, terminal, or weak SCCs,
- an automaton is strong if it contains at least one strong SCC.
This classification is used to fill the terminal_aut
, weak_aut
,
strong_aut
columns with Boolean values. Only one of these should
contain 1
. We usually prefer terminal automata over weak automata,
and weak automata over strong automata, because the emptiness check
of terminal (and weak) automata is easier.
nondetstates
counts the number of non-deterministic states in the
automaton. nondeterministic
is a Boolean value indicating if the
automaton is not deterministic. For instance in the previous picture
showing two automata for a U b
, the first automaton is deterministic
(these two fields will contain 0), while the second automaton contain
a nondeterministic state (state A2 has two possible successors for the
assignment \(ab\)) and is therefore not deterministic.
time
obviously contains the time used by the translation. Time is
measured with some high-resolution clock when available (that's
nanosecond accuracy under Linux), but because translator commands are
executed through a shell, it also includes the time to start a shell.
(This extra cost apply identically to all translators, so it is not unfair.)
Finally, product_states
, product_transitions
, and product_scc
count the number of state, transitions and strongly-connect components
in the product that has been built between the translated automaton
and a random model. For a given formula, the same random model is of
course used against the automata translated by all tools. Comparing
the size of these product might give another indication of the
"conciseness" of a translated automaton.
There is of course a certain "luck factor" in the size of the product.
Maybe some translator built a very dumb automaton, with many useless
states, in which just a very tiny part is translated concisely. By
luck, the random model generated might synchronize with this tiny part
only, and ignore the part with all the useless states. A way to
lessen this luck factor is to increase the number of products
performed against the translated automaton. If option --products=N
is used, N
products are builds instead of one, and the fields
product_states
, product_transitions
, and product_scc
contain
average values.
Detecting problems
If a translator exits with a non-zero status code, or fails to output
an automaton ltlcross
can read, and error will be displayed and the
result of the translation will be discarded.
Otherwise ltlcross
performs the following checks on all translated
formulas (\(P_i\) and \(N_i\) designate respectively the translation of
positive and negative formulas by the ith translator).
- Intersection check: \(P_i\otimes N_j\) must be empty for all
pairs of \((i,j)\).
A single failing translator might generate a lot of lines of the form:
error: P0*N1 is nonempty error: P1*N0 is nonempty error: P1*N1 is nonempty error: P1*N2 is nonempty error: P1*N3 is nonempty error: P1*N4 is nonempty error: P1*N5 is nonempty error: P1*N6 is nonempty error: P1*N7 is nonempty error: P1*N8 is nonempty error: P1*N9 is nonempty error: P2*N1 is nonempty error: P3*N1 is nonempty error: P4*N1 is nonempty error: P5*N1 is nonempty error: P6*N1 is nonempty error: P7*N1 is nonempty error: P8*N1 is nonempty error: P9*N1 is nonempty
In this example, translator number
1
looks clearly faulty (at least the other 9 translators do not contradict each other). - Cross-comparison checks: for some state-space \(S\),
all \(P_i\otimes S\) are either all empty, or all non-empty.
Similarly all \(N_i\otimes S\) are either all empty, or all non-empty.
A cross-comparison failure could be displayed as:
error: {P0,P2,P3,P4,P5,P6,P7,P8,P9} disagree with {P1} when evaluating the state-space
If
--products=N
is used withN
greater than one, the number of the state-space is also printed. This number is of no use by itself, except to explain why you may get multiple disagreement between the same sets of automata. - Consistency check:
For each \(i\), the products \(P_i\otimes S\) and \(N_i\otimes S\) actually cover all states of \(S\). Because \(S\) does not have any deadlock, any of its infinite path must be accepted by \(P_i\) or \(N_i\) (or both).
An error in that case is displayed as
error: inconsistency between P1 and N1
If
--products=N
is used withN
greater than one, the number of the state-space in which the inconsistency was detected is also printed.
The above checks are similar to those that are performed by LBTT.
If any problem was reported during the translation of one of the
formulas, ltlcheck
will exit with an exit status of 1
. Statistics
(if requested) are output nonetheless, and include any faulty
automaton as well.
Miscellaneous options
--stop-on-error
The --stop-on-error
will cause ltlcross
to abort on the first
detected error. This include failure to start some translator, read
its output, or failure to passe the sanity checks. Timeouts are
allowed.
One use for this option is when ltlcross
is used in combination with
randltl
to check translators on an infinite stream of formulas.
For instance the following will cross-compare ltl2tgba
against
ltl3ba
until it finds an error, or your interrupt the command, or it
runs out of memory (the hash tables used by randltl
and ltlcross
to remove duplicate formulas will keep growing).
randltl -n -1 --tree-size 10..25 a b c | ltlcross --stop-on-error 'ltl2tgba --lbtt %f >%T' 'ltl3ba -f %s >%N'
--no-check
The --no-check
option disables all sanity checks, and only use the supplied
formulas in their positive form.
When checks are enabled, the negated formulas are intermixed with the
positives ones in the results. Therefore the --no-check
option can
be used to gather statistics about a specific set of formulas.