Code Examples
Table of Contents
This section contains code examples for using Spot. This is a work in progress. Feel free to send suggestions of small tasks you would like to see illustrated here.
If you have difficulties compiling the C++ examples, check out these instructions.
Reading the concepts page might help if you are not familiar with some of the objects or concepts used here.
Examples with Shell, Python, and C++
All the following pages show how to perform the same task using the three interfaces supported by Spot: shell commands, Python, or C++.
- Parsing and Printing LTL Formulas
- Relabeling Formulas
- Testing the equivalence of two LTL formulas
- Translating an LTL formula into a never claim
- Translating an LTL formula into a monitor
- Working with LTL formulas with finite semantics
- Converting a never claim into HOA
- Converting Rabin (or Other) to Büchi, and simplifying it
- Removing alternation
Examples in Python and C++
- Constructing and transforming formulas
- Custom print of an automaton
- Printing a Büchi automaton in the "BA format"
- Creating an automaton by adding states and transitions
- Creating an alternating automaton by adding states and transitions
- Iterating over alternating automata
- Solving a safety game to decide direct simulation
- Creating an explicit Kripke structure
- Using the
bdd_dict
to associate atomic proposition to BDD variables, or allocate anonymous BDD variables (advanced)
Examples in C++ only
Examples in Python only
In directory python/tests
, the Spot tarball contains a small
collection of IPython notebooks. As the name of the directory implies,
these are part of the test suite for the Python bindings, however they
can be interesting to look at if you want to see more code examples.
For convenience, the following links offer static HTML renderings of these notebooks, but we strongly suggest interactively evaluating the real notebooks instead.
formulas.ipynb
covers the basics of LTL/PSL formula parsing and printing, with some light operationsautomata.ipynb
covers translation from formulas to automata, automata printing, and some lights transformationsautomata-io.ipynb
shows how to save and read automata from filesrandaut.ipynb
shows a simple case where therandaut
commands generated random automata, which are displayed in a table before and after acceptance simplificationaccparse.ipynb
exercises the acceptance condition parseracc_cond.ipynb
documents the interface for manipulating acceptance conditionscontains.ipynb
demonstrates containment checks between formulas or automatasplit.ipynb
illustrates various ways to split labelsparity.ipynb
documents algorithms for manipulating parity automata in Pythongames.ipynb
illustrates support for gamessynthesis.ipynb
illustrates support for game-based LTL reactive synthesisproduct.ipynb
shows how to re-implement the product of two automata in Pythonrandltl.ipynb
demonstrates a Python-version ofrandltl
gen.ipynb
show how to generate families of LTL formulas (as done ingenltl
) or automata (genaut
)decompose.ipynb
illustrates thedecompose_strength()
,decompose_acc_scc()
anddecompose_scc()
functionstestingaut.ipynb
shows the steps necessary to build a testing automatonltsmin-dve.ipynb
loading a DiVinE model using the LTSmin interface.ltsmin-pml.ipynb
loading a Promela model using the LTSmin interface.word.ipynb
example for thetwa_run
andtwa_word
classes.highlighting.ipynb
shows how to highlight states or edges in automata.atva16-fig2a.ipynb
first example from our ATVA'16 tool paper.atva16-fig2b.ipynb
second example from our ATVA'16 tool paper.cav22-figs.ipynb
figures from our CAV'22 tool paper.alternation.ipynb
examples of alternating automata.stutter-inv.ipynb
working with stutter-invariant formulas properties.satmin.ipynb
Python interface for SAT-based minimization of deterministic ω-automata.twagraph-internals.ipynb
Inner workings of thetwa_graph
class.aliases.ipynb
Support for HOA aliases.zlktree.ipynb
demonstration of Zielonka Trees and ACD