import spot
import spot.gen as sg
spot.setup(show_default='.an')
from IPython.display import display
Generation of LTL formulas is done via the ltl_pattern()
function. This takes two arguments: a pattern id, and a pattern size (or index if the id refers to a list).
sg.ltl_pattern(sg.LTL_AND_GF, 3)
sg.ltl_pattern(sg.LTL_CCJ_BETA_PRIME, 4)
To see the list of supported patterns, the easiest way is to look at the --help
output of genltl
. The above pattern for instance is attached to option --ccj-beta-prime
. The name of the pattern identifier is the same using capital letters, underscores, and an LTL_
prefix. If a pattern has multiple aliased options in genltl
, the first one used for the identifier (e.g., genltl
accept both --dac-patterns
and --spec-patterns
as synonyms to denote the patterns of spot.gen.LTL_DAC_PATTERNS
).
Multiple patterns can be generated using the ltl_patterns()
function. It's arguments should be either can be:
(id, n)
: in this case the pattern id
with size/index n
is returned,(id, min, max)
: in this case the patterns are output for all n
between min
and max
included,id
: then this is equivalent to (id, 1, 10)
if the pattern has now upper bound, or (id, 1, upper)
if the patter id
has an upper bound upper
. This is mostly used when the pattern id correspond to a hard-coded list of formulas.Here is an example showing these three types of arguments:
for f in sg.ltl_patterns((sg.LTL_GH_R, 3), (sg.LTL_AND_FG, 1, 3), sg.LTL_EH_PATTERNS):
display(f)
Some LTL patterns take two arguments. In this case, the arguments passed to ltl_pattern()
should be one of:
(id, n, m)
giving the value of both arguments,(id, min1, max1, min2, max2)
specifying a range for both arguments,(id, n)
equivalent to (id, n, n)
,id
equivalent to (id, 1, 3, 1, 3)
.for f in sg.ltl_patterns(sg.LTL_SEJK_F):
display(f)
for f in sg.ltl_patterns((sg.LTL_SEJK_F, 2, 3), (sg.LTL_SEJK_F, 2), (sg.LTL_SEJK_F, 1, 2, 1, 2)):
display(f)
We currently have only a couple of generators of automata:
examples = []
for p in (sg.AUT_KS_NCA, sg.AUT_L_DSA, sg.AUT_L_NBA, sg.AUT_M_NBA,
sg.AUT_CYCLIST_PROOF_DBA, sg.AUT_CYCLIST_TRACE_NBA,
sg.AUT_CYCLE_LOG_NBA, sg.AUT_CYCLE_ONEHOT_NBA):
aut = sg.aut_pattern(p, 3)
aut.set_name(sg.aut_pattern_name(p) + "=3")
examples.append(aut)
display(*examples)
Multiple automata can be generated using the aut_patterns()
function, which works similarly to ltl_patterns()
.
for aut in sg.aut_patterns(sg.AUT_KS_NCA):
print(aut.num_states())