In [1]:
import spot
Generate random formulas from specified atomic propositions:
In [2]:
f = spot.randltl(['a', 'b', 'c'])
for i in range(3):
print(next(f))
Generate random formulas using 3 atomic propositions:
In [3]:
f = spot.randltl(3)
for i in range(3):
print(next(f))
By default, there is no limit to the number of formulas generated.
To specify a number of formulas:
In [4]:
f = spot.randltl(3, 4)
for formula in f:
print(formula)
Seed for the pseudo random number generator (default: 0).
In [5]:
f = spot.randltl(3, seed=11)
print(next(f))
Type of formulas to output: 'ltl', 'psl', 'bool' or 'sere' (default: 'ltl').
In [6]:
f = spot.randltl(3, output='psl', seed=332)
print(next(f))
Allow duplicate formulas (default: False).
In [7]:
f = spot.randltl(1, allow_dups=True)
print(next(f))
print(next(f))
print(next(f))
Tree size of the formulas generated, before mandatory simplifications (default: 15).
In [8]:
f = spot.randltl(3, tree_size=30, seed=11)
print(next(f))
A range can be specified as a tuple:
In [9]:
f = spot.randltl(3, tree_size=(1, 40))
print(next(f))
print(next(f))
In [10]:
f = spot.randltl(3, output='bool', boolean_priorities='and=10,or=0')
for i in range(5):
print(next(f))
To see which operators are available along with their default priorities:
In [11]:
spot.randltl(3, output='psl', dump_priorities=True)
0 No rewriting
1 basic rewritings and eventual/universal rules
2 additional syntactic implication rules
3 better implications using containment
default: 3
In [12]:
f = spot.randltl(3, simplify=0, seed=5)
print(next(f))
f = spot.randltl(3, simplify=3, seed=5)
print(next(f))
most boolean functions found in the class formula can be used to filter the random formula generator like this:
In [13]:
f = spot.randltl(3, 20).is_syntactic_stutter_invariant()
for formula in f:
print(formula)
likewise, functions from formula to formula can be applied to map the iterator:
In [14]:
f = spot.randltl(2, 6).remove_x()
for formula in f:
print(formula)
Since the boolean filters and mapping functions return an iterator of the same type, these operations can be chained like this:
In [15]:
f = spot.randltl(3, 20).is_syntactic_stutter_invariant().relabel(spot.Abc).simplify()
for formula in f:
print(formula)
In [16]:
for formula in spot.randltl(3, 10).simplify().unabbreviate("WMGFR"): print(formula)
In [16]: