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 manipulated 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++.
Examples in Python and C++
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.ipynbcovers the basics of LTL/PSL formula parsing and printing, with some light operationsautomata.ipynbcovers translation from formulas to automata, automata printing, and some lights transformationsautomata-io.ipynbshows how to save and read automata from filespiperead.ipynbshows how to save and read automata output from other commands, using pipesrandaut.ipynbshows a simple case where therandautcommands generated random automata, which are displayed in a table before and after acceptance simplificationaccparse.ipynbexercises the acceptance condition parseracc_cond.ipynbdocuments the interface for manipulating acceptance conditionsproduct.ipynbshows how to re-implement the product of two automata in Pythonrandltl.ipynbdemonstrates a Python-version ofrandltldecompose.ipynbillustrates thedecompose_strength(),decompose_acc_scc()anddecompose_scc()functionstestingaut.ipynbshows the steps necessary to build a testing automatonltsmin-dve.ipynbloading a DiVinE model using the LTSmin interface.ltsmin-pml.ipynbloading a Promela model using the LTSmin interface.word.ipynbexample for thetwa_runandtwa_wordclasses.highlighting.ipynbshows how to highlight states or edges in automata.atva16-fig2a.ipynbfirst example from our ATVA'16 tool paper.atva16-fig2b.ipynbsecond example from our ATVA'16 tool paper.alternation.ipynbexamples of alternating automata.