gen: rename genltl() to ltl_pattern() and introduce ltl_patterns()

* spot/gen/formulas.hh, spot/gen/formulas.cc (genltl): Rename as...
(ltl_pattern): This.
(ltl_pattern_max): New function.
* bin/genltl.cc: Adjust names, and simplify using ltl_pattern_max().
* python/spot/gen.i (ltl_patterns): New function.
* tests/python/gen.py: Test it.
* tests/python/gen.ipynb: New file to document the spot.gen package.
* tests/Makefile.am, doc/org/tut.org: Add gen.ipynb.
This commit is contained in:
Alexandre Duret-Lutz 2017-04-26 14:32:01 +02:00
parent 2dc115fe2c
commit 540b971355
8 changed files with 640 additions and 55 deletions

View file

@ -53,3 +53,36 @@ using namespace spot;
%include <spot/gen/automata.hh>
%include <spot/gen/formulas.hh>
%pythoncode %{
def ltl_patterns(*args):
"""
Generate LTL patterns.
The arguments should be have one of these three forms:
- (id, n)
- (id, min, max)
- id
In the first case, the pattern id=n is generated. In the second
case, all pattern id=n for min<=n<=max are generated. The
third case is a shorthand for (id, 1, 10), except when
id denotes one of the hard-coded list of LTL formulas (like,
DAC_PATTERNS, EH_PATTERNS, etc.) where all formulas from that
list are output.
"""
for spec in args:
if type(spec) is int:
pat = spec
min = 1
max = ltl_pattern_max(spec) or 10
else:
ls = len(spec)
if ls == 2:
pat, min, max = spec[0], spec[1], spec[1]
elif ls == 3:
pat, min, max = spec
else:
raise RuntimeError("invalid pattern specification")
for n in range(min, max + 1):
yield ltl_pattern(pat, n)
%}