python: add a spot.automata(filename) interface, yielding automata
* src/hoaparse/fmterror.cc, src/hoaparse/public.hh, src/hoaparse/hoaparse.yy (hoa_stream_parser::parse_strict): New method that raises an exception whenever a syntax error is encountered. * src/ltlparse/public.hh (parse_error): Move ... * src/misc/common.hh: ... here. * wrap/python/spot_impl.i: Wrap the hoa output. * wrap/python/spot.py: Implement spot.automata. * wrap/python/tests/automata-io.ipynb: New test. * wrap/python/tests/Makefile.am: Add it.
This commit is contained in:
parent
8e6b35e5e3
commit
25de479e12
9 changed files with 701 additions and 22 deletions
|
|
@ -80,6 +80,46 @@ formula.__init__ = _formula_str_ctor
|
|||
formula.to_str = _formula_to_str
|
||||
formula.show_ast = _render_formula_as_svg
|
||||
|
||||
def _tgba_to_str(a, format='hoa', opt=None):
|
||||
format = format.lower()
|
||||
if format == 'hoa':
|
||||
ostr = ostringstream()
|
||||
hoa_reachable(ostr, a, opt)
|
||||
return ostr.str()
|
||||
if format == 'dot':
|
||||
ostr = ostringstream()
|
||||
dotty_reachable(ostr, a, opt)
|
||||
return ostr.str()
|
||||
if format == 'spin':
|
||||
ostr = ostringstream()
|
||||
never_claim_reachable(ostr, a, opt)
|
||||
return ostr.str()
|
||||
if format == 'lbtt':
|
||||
ostr = ostringstream()
|
||||
lbtt_reachable(ostr, a, bool(opt))
|
||||
return ostr.str()
|
||||
raise ValueError("unknown string format: " + format)
|
||||
|
||||
def _tgba_save(a, filename, format='hoa', opt=None, append=False):
|
||||
with open(filename, 'a' if append else 'w') as f:
|
||||
s = a.to_str(format, opt)
|
||||
f.write(s)
|
||||
if s[-1] != '\n':
|
||||
f.write('\n')
|
||||
return a
|
||||
|
||||
tgba.to_str = _tgba_to_str
|
||||
tgba.save = _tgba_save
|
||||
|
||||
def automata(filename):
|
||||
p = hoa_stream_parser(filename, True)
|
||||
while True:
|
||||
a = p.parse_strict(_bdd_dict)
|
||||
if a == None:
|
||||
return
|
||||
yield a
|
||||
|
||||
|
||||
def translate(formula, output='tgba', pref='small', level='high',
|
||||
complete=False):
|
||||
"""Translate a formula into an automaton.
|
||||
|
|
|
|||
|
|
@ -74,6 +74,7 @@ namespace std {
|
|||
#include <sstream>
|
||||
#include <signal.h>
|
||||
|
||||
#include "misc/common.hh"
|
||||
#include "misc/version.hh"
|
||||
#include "misc/minato.hh"
|
||||
#include "misc/optionmap.hh"
|
||||
|
|
@ -135,6 +136,7 @@ namespace std {
|
|||
#include "tgbaalgos/postproc.hh"
|
||||
#include "tgbaalgos/stutter.hh"
|
||||
#include "tgbaalgos/translate.hh"
|
||||
#include "tgbaalgos/hoa.hh"
|
||||
|
||||
#include "hoaparse/public.hh"
|
||||
|
||||
|
|
@ -182,7 +184,7 @@ using namespace spot;
|
|||
try {
|
||||
$action
|
||||
}
|
||||
catch (const spot::ltl::parse_error& e)
|
||||
catch (const spot::parse_error& e)
|
||||
{
|
||||
std::string er("\n");
|
||||
er += e.what();
|
||||
|
|
@ -278,6 +280,7 @@ namespace spot {
|
|||
%include "tgbaalgos/postproc.hh"
|
||||
%include "tgbaalgos/stutter.hh"
|
||||
%include "tgbaalgos/translate.hh"
|
||||
%include "tgbaalgos/hoa.hh"
|
||||
|
||||
%include "hoaparse/public.hh"
|
||||
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ check_SCRIPTS = run
|
|||
TESTS = \
|
||||
alarm.py \
|
||||
automata.ipynb \
|
||||
automata-io.ipynb \
|
||||
bddnqueen.py \
|
||||
formulas.ipynb \
|
||||
implies.py \
|
||||
|
|
|
|||
595
wrap/python/tests/automata-io.ipynb
Normal file
595
wrap/python/tests/automata-io.ipynb
Normal file
|
|
@ -0,0 +1,595 @@
|
|||
{
|
||||
"metadata": {
|
||||
"name": "",
|
||||
"signature": "sha256:8a904efb232462e4b08337adba95ad1f6c71494bad4a9d4b3872cbbb3bec76d6"
|
||||
},
|
||||
"nbformat": 3,
|
||||
"nbformat_minor": 0,
|
||||
"worksheets": [
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"collapsed": false,
|
||||
"input": [
|
||||
"import os\n",
|
||||
"from IPython.display import display\n",
|
||||
"# Note that Spot (loaded by the kernel) will store a copy of\n",
|
||||
"# the environment variables the first time it reads them, so\n",
|
||||
"# if you change those variables, the new values will be ignored\n",
|
||||
"# until you restart the kernel.\n",
|
||||
"os.environ['SPOT_DOTEXTRA'] = 'size=\"10.2,5\" node[style=filled,fillcolor=\"#ffffaa\"] edge[arrowhead=vee, arrowsize=.7]'\n",
|
||||
"os.environ['SPOT_DOTDEFAULT'] = 'rbcf(Lato)'\n",
|
||||
"import spot"
|
||||
],
|
||||
"language": "python",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"prompt_number": 1
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"collapsed": false,
|
||||
"input": [
|
||||
"a = spot.translate('a U b')\n",
|
||||
"for fmt in ('hoa', 'spin', 'dot', 'lbtt'):\n",
|
||||
" print(a.to_str(fmt))"
|
||||
],
|
||||
"language": "python",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"output_type": "stream",
|
||||
"stream": "stdout",
|
||||
"text": [
|
||||
"HOA: v1\n",
|
||||
"States: 2\n",
|
||||
"Start: 1\n",
|
||||
"AP: 2 \"a\" \"b\"\n",
|
||||
"acc-name: Buchi\n",
|
||||
"Acceptance: 1 Inf(0)\n",
|
||||
"properties: trans-labels explicit-labels state-acc deterministic\n",
|
||||
"properties: stutter-invariant inherently-weak\n",
|
||||
"--BODY--\n",
|
||||
"State: 0 {0}\n",
|
||||
"[t] 0\n",
|
||||
"State: 1\n",
|
||||
"[1] 0\n",
|
||||
"[0&!1] 1\n",
|
||||
"--END--\n",
|
||||
"never {\n",
|
||||
"T0_init:\n",
|
||||
" if\n",
|
||||
" :: ((b)) -> goto accept_all\n",
|
||||
" :: ((a) && (!(b))) -> goto T0_init\n",
|
||||
" fi;\n",
|
||||
"accept_all:\n",
|
||||
" skip\n",
|
||||
"}\n",
|
||||
"\n",
|
||||
"digraph G {\n",
|
||||
" rankdir=LR\n",
|
||||
" node [shape=\"circle\"]\n",
|
||||
" fontname=\"Lato\"\n",
|
||||
" node [fontname=\"Lato\"]\n",
|
||||
" edge [fontname=\"Lato\"]\n",
|
||||
" size=\"10.2,5\" node[style=filled,fillcolor=\"#ffffaa\"] edge[arrowhead=vee, arrowsize=.7]\n",
|
||||
" I [label=\"\", style=invis, width=0]\n",
|
||||
" I -> 1\n",
|
||||
" 0 [label=<0<br/><font color=\"#5DA5DA\">\u24ff</font>>]\n",
|
||||
" 0 -> 0 [label=<1>]\n",
|
||||
" 1 [label=<1>]\n",
|
||||
" 1 -> 0 [label=<b>]\n",
|
||||
" 1 -> 1 [label=<a & !b>]\n",
|
||||
"}\n",
|
||||
"\n",
|
||||
"2 1t\n",
|
||||
"0 1\n",
|
||||
"1 -1 \"b\"\n",
|
||||
"0 -1 & \"a\" ! \"b\"\n",
|
||||
"-1\n",
|
||||
"1 0\n",
|
||||
"1 0 -1 t\n",
|
||||
"-1\n",
|
||||
"\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"prompt_number": 2
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"collapsed": false,
|
||||
"input": [
|
||||
"a.save('example.aut').save('example.aut', format='lbtt', append=True)"
|
||||
],
|
||||
"language": "python",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"metadata": {},
|
||||
"output_type": "pyout",
|
||||
"prompt_number": 3,
|
||||
"svg": [
|
||||
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n",
|
||||
"<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
|
||||
" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
|
||||
"<!-- Generated by graphviz version 2.38.0 (20140413.2041)\n",
|
||||
" -->\n",
|
||||
"<!-- Title: G Pages: 1 -->\n",
|
||||
"<svg width=\"181pt\" height=\"95pt\"\n",
|
||||
" viewBox=\"0.00 0.00 180.74 94.74\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
|
||||
"<g id=\"graph0\" class=\"graph\" transform=\"scale(1 1) rotate(0) translate(4 90.7401)\">\n",
|
||||
"<title>G</title>\n",
|
||||
"<polygon fill=\"white\" stroke=\"none\" points=\"-4,4 -4,-90.7401 176.74,-90.7401 176.74,4 -4,4\"/>\n",
|
||||
"<!-- I -->\n",
|
||||
"<!-- 1 -->\n",
|
||||
"<g id=\"node2\" class=\"node\"><title>1</title>\n",
|
||||
"<ellipse fill=\"#ffffaa\" stroke=\"black\" cx=\"56\" cy=\"-26.8701\" rx=\"18\" ry=\"18\"/>\n",
|
||||
"<text text-anchor=\"middle\" x=\"56\" y=\"-23.1701\" font-family=\"Lato\" font-size=\"14.00\">1</text>\n",
|
||||
"</g>\n",
|
||||
"<!-- I->1 -->\n",
|
||||
"<g id=\"edge1\" class=\"edge\"><title>I->1</title>\n",
|
||||
"<path fill=\"none\" stroke=\"black\" d=\"M1.15491,-26.8701C2.79388,-26.8701 17.1543,-26.8701 30.6317,-26.8701\"/>\n",
|
||||
"<polygon fill=\"black\" stroke=\"black\" points=\"37.9419,-26.8701 30.9419,-30.0202 34.4419,-26.8701 30.9419,-26.8702 30.9419,-26.8702 30.9419,-26.8702 34.4419,-26.8701 30.9418,-23.7202 37.9419,-26.8701 37.9419,-26.8701\"/>\n",
|
||||
"</g>\n",
|
||||
"<!-- 1->1 -->\n",
|
||||
"<g id=\"edge4\" class=\"edge\"><title>1->1</title>\n",
|
||||
"<path fill=\"none\" stroke=\"black\" d=\"M49.6208,-43.9074C48.3189,-53.728 50.4453,-62.8701 56,-62.8701 60.166,-62.8701 62.4036,-57.7276 62.7128,-51.0134\"/>\n",
|
||||
"<polygon fill=\"black\" stroke=\"black\" points=\"62.3792,-43.9074 65.8541,-50.7519 62.5434,-47.4035 62.7076,-50.8997 62.7076,-50.8997 62.7076,-50.8997 62.5434,-47.4035 59.561,-51.0474 62.3792,-43.9074 62.3792,-43.9074\"/>\n",
|
||||
"<text text-anchor=\"start\" x=\"37.5\" y=\"-66.6701\" font-family=\"Lato\" font-size=\"14.00\">a & !b</text>\n",
|
||||
"</g>\n",
|
||||
"<!-- 0 -->\n",
|
||||
"<g id=\"node3\" class=\"node\"><title>0</title>\n",
|
||||
"<ellipse fill=\"#ffffaa\" stroke=\"black\" cx=\"145.87\" cy=\"-26.8701\" rx=\"26.7407\" ry=\"26.7407\"/>\n",
|
||||
"<text text-anchor=\"start\" x=\"141.37\" y=\"-30.6701\" font-family=\"Lato\" font-size=\"14.00\">0</text>\n",
|
||||
"<text text-anchor=\"start\" x=\"137.87\" y=\"-15.6701\" font-family=\"Lato\" font-size=\"14.00\" fill=\"#5da5da\">\u24ff</text>\n",
|
||||
"</g>\n",
|
||||
"<!-- 1->0 -->\n",
|
||||
"<g id=\"edge3\" class=\"edge\"><title>1->0</title>\n",
|
||||
"<path fill=\"none\" stroke=\"black\" d=\"M74.3603,-26.8701C84.98,-26.8701 98.9179,-26.8701 111.595,-26.8701\"/>\n",
|
||||
"<polygon fill=\"black\" stroke=\"black\" points=\"118.879,-26.8701 111.88,-30.0202 115.379,-26.8701 111.879,-26.8702 111.879,-26.8702 111.879,-26.8702 115.379,-26.8701 111.879,-23.7202 118.879,-26.8701 118.879,-26.8701\"/>\n",
|
||||
"<text text-anchor=\"start\" x=\"92\" y=\"-30.6701\" font-family=\"Lato\" font-size=\"14.00\">b</text>\n",
|
||||
"</g>\n",
|
||||
"<!-- 0->0 -->\n",
|
||||
"<g id=\"edge2\" class=\"edge\"><title>0->0</title>\n",
|
||||
"<path fill=\"none\" stroke=\"black\" d=\"M136.949,-52.2401C136.334,-62.7939 139.308,-71.7401 145.87,-71.7401 150.894,-71.7401 153.815,-66.496 154.632,-59.3013\"/>\n",
|
||||
"<polygon fill=\"black\" stroke=\"black\" points=\"154.791,-52.2401 157.783,-59.3092 154.712,-55.7392 154.633,-59.2383 154.633,-59.2383 154.633,-59.2383 154.712,-55.7392 151.484,-59.1674 154.791,-52.2401 154.791,-52.2401\"/>\n",
|
||||
"<text text-anchor=\"middle\" x=\"145.87\" y=\"-75.5401\" font-family=\"Lato\" font-size=\"14.00\">1</text>\n",
|
||||
"</g>\n",
|
||||
"</g>\n",
|
||||
"</svg>\n"
|
||||
],
|
||||
"text": [
|
||||
"<spot_impl.tgba_digraph; proxy of <Swig Object of type 'std::shared_ptr< spot::tgba_digraph > *' at 0x7f156825d240> >"
|
||||
]
|
||||
}
|
||||
],
|
||||
"prompt_number": 3
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"collapsed": false,
|
||||
"input": [
|
||||
"!cat example.aut"
|
||||
],
|
||||
"language": "python",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"output_type": "stream",
|
||||
"stream": "stdout",
|
||||
"text": [
|
||||
"HOA: v1\r\n",
|
||||
"States: 2\r\n",
|
||||
"Start: 1\r\n",
|
||||
"AP: 2 \"a\" \"b\"\r\n",
|
||||
"acc-name: Buchi\r\n",
|
||||
"Acceptance: 1 Inf(0)\r\n",
|
||||
"properties: trans-labels explicit-labels state-acc deterministic\r\n",
|
||||
"properties: stutter-invariant inherently-weak\r\n",
|
||||
"--BODY--\r\n",
|
||||
"State: 0 {0}\r\n",
|
||||
"[t] 0\r\n",
|
||||
"State: 1\r\n",
|
||||
"[1] 0\r\n",
|
||||
"[0&!1] 1\r\n",
|
||||
"--END--\r\n",
|
||||
"2 1t\r\n",
|
||||
"0 1\r\n",
|
||||
"1 -1 \"b\"\r\n",
|
||||
"0 -1 & \"a\" ! \"b\"\r\n",
|
||||
"-1\r\n",
|
||||
"1 0\r\n",
|
||||
"1 0 -1 t\r\n",
|
||||
"-1\r\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"prompt_number": 4
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"collapsed": false,
|
||||
"input": [
|
||||
"for a in spot.automata('example.aut'):\n",
|
||||
" display(a)"
|
||||
],
|
||||
"language": "python",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"metadata": {},
|
||||
"output_type": "display_data",
|
||||
"svg": [
|
||||
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n",
|
||||
"<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
|
||||
" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
|
||||
"<!-- Generated by graphviz version 2.38.0 (20140413.2041)\n",
|
||||
" -->\n",
|
||||
"<!-- Title: G Pages: 1 -->\n",
|
||||
"<svg width=\"181pt\" height=\"95pt\"\n",
|
||||
" viewBox=\"0.00 0.00 180.74 94.74\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
|
||||
"<g id=\"graph0\" class=\"graph\" transform=\"scale(1 1) rotate(0) translate(4 90.7401)\">\n",
|
||||
"<title>G</title>\n",
|
||||
"<polygon fill=\"white\" stroke=\"none\" points=\"-4,4 -4,-90.7401 176.74,-90.7401 176.74,4 -4,4\"/>\n",
|
||||
"<!-- I -->\n",
|
||||
"<!-- 1 -->\n",
|
||||
"<g id=\"node2\" class=\"node\"><title>1</title>\n",
|
||||
"<ellipse fill=\"#ffffaa\" stroke=\"black\" cx=\"56\" cy=\"-26.8701\" rx=\"18\" ry=\"18\"/>\n",
|
||||
"<text text-anchor=\"middle\" x=\"56\" y=\"-23.1701\" font-family=\"Lato\" font-size=\"14.00\">1</text>\n",
|
||||
"</g>\n",
|
||||
"<!-- I->1 -->\n",
|
||||
"<g id=\"edge1\" class=\"edge\"><title>I->1</title>\n",
|
||||
"<path fill=\"none\" stroke=\"black\" d=\"M1.15491,-26.8701C2.79388,-26.8701 17.1543,-26.8701 30.6317,-26.8701\"/>\n",
|
||||
"<polygon fill=\"black\" stroke=\"black\" points=\"37.9419,-26.8701 30.9419,-30.0202 34.4419,-26.8701 30.9419,-26.8702 30.9419,-26.8702 30.9419,-26.8702 34.4419,-26.8701 30.9418,-23.7202 37.9419,-26.8701 37.9419,-26.8701\"/>\n",
|
||||
"</g>\n",
|
||||
"<!-- 1->1 -->\n",
|
||||
"<g id=\"edge4\" class=\"edge\"><title>1->1</title>\n",
|
||||
"<path fill=\"none\" stroke=\"black\" d=\"M49.6208,-43.9074C48.3189,-53.728 50.4453,-62.8701 56,-62.8701 60.166,-62.8701 62.4036,-57.7276 62.7128,-51.0134\"/>\n",
|
||||
"<polygon fill=\"black\" stroke=\"black\" points=\"62.3792,-43.9074 65.8541,-50.7519 62.5434,-47.4035 62.7076,-50.8997 62.7076,-50.8997 62.7076,-50.8997 62.5434,-47.4035 59.561,-51.0474 62.3792,-43.9074 62.3792,-43.9074\"/>\n",
|
||||
"<text text-anchor=\"start\" x=\"37.5\" y=\"-66.6701\" font-family=\"Lato\" font-size=\"14.00\">a & !b</text>\n",
|
||||
"</g>\n",
|
||||
"<!-- 0 -->\n",
|
||||
"<g id=\"node3\" class=\"node\"><title>0</title>\n",
|
||||
"<ellipse fill=\"#ffffaa\" stroke=\"black\" cx=\"145.87\" cy=\"-26.8701\" rx=\"26.7407\" ry=\"26.7407\"/>\n",
|
||||
"<text text-anchor=\"start\" x=\"141.37\" y=\"-30.6701\" font-family=\"Lato\" font-size=\"14.00\">0</text>\n",
|
||||
"<text text-anchor=\"start\" x=\"137.87\" y=\"-15.6701\" font-family=\"Lato\" font-size=\"14.00\" fill=\"#5da5da\">\u24ff</text>\n",
|
||||
"</g>\n",
|
||||
"<!-- 1->0 -->\n",
|
||||
"<g id=\"edge3\" class=\"edge\"><title>1->0</title>\n",
|
||||
"<path fill=\"none\" stroke=\"black\" d=\"M74.3603,-26.8701C84.98,-26.8701 98.9179,-26.8701 111.595,-26.8701\"/>\n",
|
||||
"<polygon fill=\"black\" stroke=\"black\" points=\"118.879,-26.8701 111.88,-30.0202 115.379,-26.8701 111.879,-26.8702 111.879,-26.8702 111.879,-26.8702 115.379,-26.8701 111.879,-23.7202 118.879,-26.8701 118.879,-26.8701\"/>\n",
|
||||
"<text text-anchor=\"start\" x=\"92\" y=\"-30.6701\" font-family=\"Lato\" font-size=\"14.00\">b</text>\n",
|
||||
"</g>\n",
|
||||
"<!-- 0->0 -->\n",
|
||||
"<g id=\"edge2\" class=\"edge\"><title>0->0</title>\n",
|
||||
"<path fill=\"none\" stroke=\"black\" d=\"M136.949,-52.2401C136.334,-62.7939 139.308,-71.7401 145.87,-71.7401 150.894,-71.7401 153.815,-66.496 154.632,-59.3013\"/>\n",
|
||||
"<polygon fill=\"black\" stroke=\"black\" points=\"154.791,-52.2401 157.783,-59.3092 154.712,-55.7392 154.633,-59.2383 154.633,-59.2383 154.633,-59.2383 154.712,-55.7392 151.484,-59.1674 154.791,-52.2401 154.791,-52.2401\"/>\n",
|
||||
"<text text-anchor=\"middle\" x=\"145.87\" y=\"-75.5401\" font-family=\"Lato\" font-size=\"14.00\">1</text>\n",
|
||||
"</g>\n",
|
||||
"</g>\n",
|
||||
"</svg>\n"
|
||||
],
|
||||
"text": [
|
||||
"<spot_impl.tgba_digraph; proxy of <Swig Object of type 'std::shared_ptr< spot::tgba_digraph > *' at 0x7f156825d210> >"
|
||||
]
|
||||
},
|
||||
{
|
||||
"metadata": {},
|
||||
"output_type": "display_data",
|
||||
"svg": [
|
||||
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n",
|
||||
"<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
|
||||
" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
|
||||
"<!-- Generated by graphviz version 2.38.0 (20140413.2041)\n",
|
||||
" -->\n",
|
||||
"<!-- Title: G Pages: 1 -->\n",
|
||||
"<svg width=\"163pt\" height=\"92pt\"\n",
|
||||
" viewBox=\"0.00 0.00 163.00 92.00\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
|
||||
"<g id=\"graph0\" class=\"graph\" transform=\"scale(1 1) rotate(0) translate(4 88)\">\n",
|
||||
"<title>G</title>\n",
|
||||
"<polygon fill=\"white\" stroke=\"none\" points=\"-4,4 -4,-88 159,-88 159,4 -4,4\"/>\n",
|
||||
"<!-- I -->\n",
|
||||
"<!-- 0 -->\n",
|
||||
"<g id=\"node2\" class=\"node\"><title>0</title>\n",
|
||||
"<ellipse fill=\"#ffffaa\" stroke=\"black\" cx=\"56\" cy=\"-18\" rx=\"18\" ry=\"18\"/>\n",
|
||||
"<text text-anchor=\"middle\" x=\"56\" y=\"-14.3\" font-family=\"Lato\" font-size=\"14.00\">0</text>\n",
|
||||
"</g>\n",
|
||||
"<!-- I->0 -->\n",
|
||||
"<g id=\"edge1\" class=\"edge\"><title>I->0</title>\n",
|
||||
"<path fill=\"none\" stroke=\"black\" d=\"M1.15491,-18C2.79388,-18 17.1543,-18 30.6317,-18\"/>\n",
|
||||
"<polygon fill=\"black\" stroke=\"black\" points=\"37.9419,-18 30.9419,-21.1501 34.4419,-18 30.9419,-18.0001 30.9419,-18.0001 30.9419,-18.0001 34.4419,-18 30.9418,-14.8501 37.9419,-18 37.9419,-18\"/>\n",
|
||||
"</g>\n",
|
||||
"<!-- 0->0 -->\n",
|
||||
"<g id=\"edge3\" class=\"edge\"><title>0->0</title>\n",
|
||||
"<path fill=\"none\" stroke=\"black\" d=\"M49.6208,-35.0373C48.3189,-44.8579 50.4453,-54 56,-54 60.166,-54 62.4036,-48.8576 62.7128,-42.1433\"/>\n",
|
||||
"<polygon fill=\"black\" stroke=\"black\" points=\"62.3792,-35.0373 65.8541,-41.8818 62.5434,-38.5335 62.7076,-42.0296 62.7076,-42.0296 62.7076,-42.0296 62.5434,-38.5335 59.561,-42.1774 62.3792,-35.0373 62.3792,-35.0373\"/>\n",
|
||||
"<text text-anchor=\"start\" x=\"37.5\" y=\"-57.8\" font-family=\"Lato\" font-size=\"14.00\">a & !b</text>\n",
|
||||
"</g>\n",
|
||||
"<!-- 1 -->\n",
|
||||
"<g id=\"node3\" class=\"node\"><title>1</title>\n",
|
||||
"<ellipse fill=\"#ffffaa\" stroke=\"black\" cx=\"137\" cy=\"-18\" rx=\"18\" ry=\"18\"/>\n",
|
||||
"<text text-anchor=\"middle\" x=\"137\" y=\"-14.3\" font-family=\"Lato\" font-size=\"14.00\">1</text>\n",
|
||||
"</g>\n",
|
||||
"<!-- 0->1 -->\n",
|
||||
"<g id=\"edge2\" class=\"edge\"><title>0->1</title>\n",
|
||||
"<path fill=\"none\" stroke=\"black\" d=\"M74.1418,-18C85.1153,-18 99.5214,-18 111.67,-18\"/>\n",
|
||||
"<polygon fill=\"black\" stroke=\"black\" points=\"118.892,-18 111.892,-21.1501 115.392,-18 111.892,-18.0001 111.892,-18.0001 111.892,-18.0001 115.392,-18 111.892,-14.8501 118.892,-18 118.892,-18\"/>\n",
|
||||
"<text text-anchor=\"start\" x=\"92\" y=\"-21.8\" font-family=\"Lato\" font-size=\"14.00\">b</text>\n",
|
||||
"</g>\n",
|
||||
"<!-- 1->1 -->\n",
|
||||
"<g id=\"edge4\" class=\"edge\"><title>1->1</title>\n",
|
||||
"<path fill=\"none\" stroke=\"black\" d=\"M129.969,-34.6641C128.406,-44.625 130.75,-54 137,-54 141.688,-54 144.178,-48.7266 144.471,-41.8876\"/>\n",
|
||||
"<polygon fill=\"black\" stroke=\"black\" points=\"144.031,-34.6641 147.601,-41.4598 144.244,-38.1576 144.456,-41.6511 144.456,-41.6511 144.456,-41.6511 144.244,-38.1576 141.312,-41.8425 144.031,-34.6641 144.031,-34.6641\"/>\n",
|
||||
"<text text-anchor=\"start\" x=\"132.5\" y=\"-72.8\" font-family=\"Lato\" font-size=\"14.00\">1</text>\n",
|
||||
"<text text-anchor=\"start\" x=\"129\" y=\"-57.8\" font-family=\"Lato\" font-size=\"14.00\" fill=\"#5da5da\">\u24ff</text>\n",
|
||||
"</g>\n",
|
||||
"</g>\n",
|
||||
"</svg>\n"
|
||||
],
|
||||
"text": [
|
||||
"<spot_impl.tgba_digraph; proxy of <Swig Object of type 'std::shared_ptr< spot::tgba_digraph > *' at 0x7f156825d420> >"
|
||||
]
|
||||
}
|
||||
],
|
||||
"prompt_number": 5
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Test `--ABORT--`\n",
|
||||
"----------------"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"collapsed": false,
|
||||
"input": [
|
||||
"%%file example.aut\n",
|
||||
"HOA: v1\n",
|
||||
"States: 2\n",
|
||||
"Start: 1\n",
|
||||
"AP: 2 \"a\" \"b\"\n",
|
||||
"acc-name: Buchi\n",
|
||||
"Acceptance: 1 Inf(0)\n",
|
||||
"--BODY--\n",
|
||||
"State: 0 {0}\n",
|
||||
"[t] 0\n",
|
||||
"--ABORT-- /* the previous automaton should be ignored */\n",
|
||||
"HOA: v1\n",
|
||||
"States: 2\n",
|
||||
"Start: 1\n",
|
||||
"AP: 2 \"a\" \"b\"\n",
|
||||
"Acceptance: 1 Inf(0)\n",
|
||||
"--BODY--\n",
|
||||
"State: 0 {0}\n",
|
||||
"[t] 0\n",
|
||||
"State: 1\n",
|
||||
"[1] 0\n",
|
||||
"[0&!1] 1\n",
|
||||
"--END--"
|
||||
],
|
||||
"language": "python",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"output_type": "stream",
|
||||
"stream": "stdout",
|
||||
"text": [
|
||||
"Overwriting example.aut\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"prompt_number": 6
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"collapsed": false,
|
||||
"input": [
|
||||
"for a in spot.automata('example.aut'):\n",
|
||||
" display(a)"
|
||||
],
|
||||
"language": "python",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"metadata": {},
|
||||
"output_type": "display_data",
|
||||
"svg": [
|
||||
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n",
|
||||
"<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
|
||||
" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
|
||||
"<!-- Generated by graphviz version 2.38.0 (20140413.2041)\n",
|
||||
" -->\n",
|
||||
"<!-- Title: G Pages: 1 -->\n",
|
||||
"<svg width=\"181pt\" height=\"95pt\"\n",
|
||||
" viewBox=\"0.00 0.00 180.74 94.74\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
|
||||
"<g id=\"graph0\" class=\"graph\" transform=\"scale(1 1) rotate(0) translate(4 90.7401)\">\n",
|
||||
"<title>G</title>\n",
|
||||
"<polygon fill=\"white\" stroke=\"none\" points=\"-4,4 -4,-90.7401 176.74,-90.7401 176.74,4 -4,4\"/>\n",
|
||||
"<!-- I -->\n",
|
||||
"<!-- 1 -->\n",
|
||||
"<g id=\"node2\" class=\"node\"><title>1</title>\n",
|
||||
"<ellipse fill=\"#ffffaa\" stroke=\"black\" cx=\"56\" cy=\"-26.8701\" rx=\"18\" ry=\"18\"/>\n",
|
||||
"<text text-anchor=\"middle\" x=\"56\" y=\"-23.1701\" font-family=\"Lato\" font-size=\"14.00\">1</text>\n",
|
||||
"</g>\n",
|
||||
"<!-- I->1 -->\n",
|
||||
"<g id=\"edge1\" class=\"edge\"><title>I->1</title>\n",
|
||||
"<path fill=\"none\" stroke=\"black\" d=\"M1.15491,-26.8701C2.79388,-26.8701 17.1543,-26.8701 30.6317,-26.8701\"/>\n",
|
||||
"<polygon fill=\"black\" stroke=\"black\" points=\"37.9419,-26.8701 30.9419,-30.0202 34.4419,-26.8701 30.9419,-26.8702 30.9419,-26.8702 30.9419,-26.8702 34.4419,-26.8701 30.9418,-23.7202 37.9419,-26.8701 37.9419,-26.8701\"/>\n",
|
||||
"</g>\n",
|
||||
"<!-- 1->1 -->\n",
|
||||
"<g id=\"edge4\" class=\"edge\"><title>1->1</title>\n",
|
||||
"<path fill=\"none\" stroke=\"black\" d=\"M49.6208,-43.9074C48.3189,-53.728 50.4453,-62.8701 56,-62.8701 60.166,-62.8701 62.4036,-57.7276 62.7128,-51.0134\"/>\n",
|
||||
"<polygon fill=\"black\" stroke=\"black\" points=\"62.3792,-43.9074 65.8541,-50.7519 62.5434,-47.4035 62.7076,-50.8997 62.7076,-50.8997 62.7076,-50.8997 62.5434,-47.4035 59.561,-51.0474 62.3792,-43.9074 62.3792,-43.9074\"/>\n",
|
||||
"<text text-anchor=\"start\" x=\"37.5\" y=\"-66.6701\" font-family=\"Lato\" font-size=\"14.00\">a & !b</text>\n",
|
||||
"</g>\n",
|
||||
"<!-- 0 -->\n",
|
||||
"<g id=\"node3\" class=\"node\"><title>0</title>\n",
|
||||
"<ellipse fill=\"#ffffaa\" stroke=\"black\" cx=\"145.87\" cy=\"-26.8701\" rx=\"26.7407\" ry=\"26.7407\"/>\n",
|
||||
"<text text-anchor=\"start\" x=\"141.37\" y=\"-30.6701\" font-family=\"Lato\" font-size=\"14.00\">0</text>\n",
|
||||
"<text text-anchor=\"start\" x=\"137.87\" y=\"-15.6701\" font-family=\"Lato\" font-size=\"14.00\" fill=\"#5da5da\">\u24ff</text>\n",
|
||||
"</g>\n",
|
||||
"<!-- 1->0 -->\n",
|
||||
"<g id=\"edge3\" class=\"edge\"><title>1->0</title>\n",
|
||||
"<path fill=\"none\" stroke=\"black\" d=\"M74.3603,-26.8701C84.98,-26.8701 98.9179,-26.8701 111.595,-26.8701\"/>\n",
|
||||
"<polygon fill=\"black\" stroke=\"black\" points=\"118.879,-26.8701 111.88,-30.0202 115.379,-26.8701 111.879,-26.8702 111.879,-26.8702 111.879,-26.8702 115.379,-26.8701 111.879,-23.7202 118.879,-26.8701 118.879,-26.8701\"/>\n",
|
||||
"<text text-anchor=\"start\" x=\"92\" y=\"-30.6701\" font-family=\"Lato\" font-size=\"14.00\">b</text>\n",
|
||||
"</g>\n",
|
||||
"<!-- 0->0 -->\n",
|
||||
"<g id=\"edge2\" class=\"edge\"><title>0->0</title>\n",
|
||||
"<path fill=\"none\" stroke=\"black\" d=\"M136.949,-52.2401C136.334,-62.7939 139.308,-71.7401 145.87,-71.7401 150.894,-71.7401 153.815,-66.496 154.632,-59.3013\"/>\n",
|
||||
"<polygon fill=\"black\" stroke=\"black\" points=\"154.791,-52.2401 157.783,-59.3092 154.712,-55.7392 154.633,-59.2383 154.633,-59.2383 154.633,-59.2383 154.712,-55.7392 151.484,-59.1674 154.791,-52.2401 154.791,-52.2401\"/>\n",
|
||||
"<text text-anchor=\"middle\" x=\"145.87\" y=\"-75.5401\" font-family=\"Lato\" font-size=\"14.00\">1</text>\n",
|
||||
"</g>\n",
|
||||
"</g>\n",
|
||||
"</svg>\n"
|
||||
],
|
||||
"text": [
|
||||
"<spot_impl.tgba_digraph; proxy of <Swig Object of type 'std::shared_ptr< spot::tgba_digraph > *' at 0x7f156825d630> >"
|
||||
]
|
||||
}
|
||||
],
|
||||
"prompt_number": 7
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Test syntax errors\n",
|
||||
"------------------"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"collapsed": false,
|
||||
"input": [
|
||||
"%%file example.aut\n",
|
||||
"HOA: v1\n",
|
||||
"States: 2\n",
|
||||
"Start: 1\n",
|
||||
"AP: 2 \"a\" \"b\"\n",
|
||||
"acc-name: Buchi\n",
|
||||
"Acceptance: 1 Inf(0)\n",
|
||||
"--BODY--\n",
|
||||
"State: 0 {0}\n",
|
||||
"[t] 1\n",
|
||||
"State: 1\n",
|
||||
"[t] 1\n",
|
||||
"--END--\n",
|
||||
"HOA: v1\n",
|
||||
"States: 2\n",
|
||||
"Start: 1\n",
|
||||
"AP: 2 \"a\" \"b\"\n",
|
||||
"Acceptance: 1 Inf(0)\n",
|
||||
"--BODY--\n",
|
||||
"State: 0 {0}\n",
|
||||
"[a] 3\n",
|
||||
"State: 1\n",
|
||||
"[1] 0\n",
|
||||
"[0&!1] 1\n",
|
||||
"--END--"
|
||||
],
|
||||
"language": "python",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"output_type": "stream",
|
||||
"stream": "stdout",
|
||||
"text": [
|
||||
"Overwriting example.aut\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"prompt_number": 8
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"collapsed": false,
|
||||
"input": [
|
||||
"for a in spot.automata('example.aut'):\n",
|
||||
" display(a)"
|
||||
],
|
||||
"language": "python",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"metadata": {},
|
||||
"output_type": "display_data",
|
||||
"svg": [
|
||||
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n",
|
||||
"<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
|
||||
" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
|
||||
"<!-- Generated by graphviz version 2.38.0 (20140413.2041)\n",
|
||||
" -->\n",
|
||||
"<!-- Title: G Pages: 1 -->\n",
|
||||
"<svg width=\"143pt\" height=\"108pt\"\n",
|
||||
" viewBox=\"0.00 0.00 142.74 107.87\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
|
||||
"<g id=\"graph0\" class=\"graph\" transform=\"scale(1 1) rotate(0) translate(4 103.87)\">\n",
|
||||
"<title>G</title>\n",
|
||||
"<polygon fill=\"white\" stroke=\"none\" points=\"-4,4 -4,-103.87 138.74,-103.87 138.74,4 -4,4\"/>\n",
|
||||
"<!-- I -->\n",
|
||||
"<!-- 1 -->\n",
|
||||
"<g id=\"node2\" class=\"node\"><title>1</title>\n",
|
||||
"<ellipse fill=\"#ffffaa\" stroke=\"black\" cx=\"116.74\" cy=\"-48.8701\" rx=\"18\" ry=\"18\"/>\n",
|
||||
"<text text-anchor=\"middle\" x=\"116.74\" y=\"-45.1701\" font-family=\"Lato\" font-size=\"14.00\">1</text>\n",
|
||||
"</g>\n",
|
||||
"<!-- I->1 -->\n",
|
||||
"<g id=\"edge1\" class=\"edge\"><title>I->1</title>\n",
|
||||
"<path fill=\"none\" stroke=\"black\" d=\"M27.9337,-71.8534C29.6818,-71.3958 67.0325,-61.6193 92.4507,-54.9661\"/>\n",
|
||||
"<polygon fill=\"black\" stroke=\"black\" points=\"99.264,-53.1827 93.2898,-58.0026 95.8781,-54.069 92.4921,-54.9553 92.4921,-54.9553 92.4921,-54.9553 95.8781,-54.069 91.6945,-51.908 99.264,-53.1827 99.264,-53.1827\"/>\n",
|
||||
"</g>\n",
|
||||
"<!-- 1->1 -->\n",
|
||||
"<g id=\"edge3\" class=\"edge\"><title>1->1</title>\n",
|
||||
"<path fill=\"none\" stroke=\"black\" d=\"M109.709,-65.5341C108.146,-75.4951 110.49,-84.8701 116.74,-84.8701 121.428,-84.8701 123.918,-79.5966 124.211,-72.7576\"/>\n",
|
||||
"<polygon fill=\"black\" stroke=\"black\" points=\"123.771,-65.5341 127.341,-72.3299 123.984,-69.0277 124.197,-72.5212 124.197,-72.5212 124.197,-72.5212 123.984,-69.0277 121.052,-72.7125 123.771,-65.5341 123.771,-65.5341\"/>\n",
|
||||
"<text text-anchor=\"middle\" x=\"116.74\" y=\"-88.6701\" font-family=\"Lato\" font-size=\"14.00\">1</text>\n",
|
||||
"</g>\n",
|
||||
"<!-- 0 -->\n",
|
||||
"<g id=\"node3\" class=\"node\"><title>0</title>\n",
|
||||
"<ellipse fill=\"#ffffaa\" stroke=\"black\" cx=\"26.8701\" cy=\"-26.8701\" rx=\"26.7407\" ry=\"26.7407\"/>\n",
|
||||
"<text text-anchor=\"start\" x=\"22.3701\" y=\"-30.6701\" font-family=\"Lato\" font-size=\"14.00\">0</text>\n",
|
||||
"<text text-anchor=\"start\" x=\"18.8701\" y=\"-15.6701\" font-family=\"Lato\" font-size=\"14.00\" fill=\"#5da5da\">\u24ff</text>\n",
|
||||
"</g>\n",
|
||||
"<!-- 0->1 -->\n",
|
||||
"<g id=\"edge2\" class=\"edge\"><title>0->1</title>\n",
|
||||
"<path fill=\"none\" stroke=\"black\" d=\"M53.2857,-33.2334C65.4583,-36.281 79.9525,-39.9099 91.9121,-42.9043\"/>\n",
|
||||
"<polygon fill=\"black\" stroke=\"black\" points=\"98.9878,-44.6758 91.4323,-46.0313 95.5926,-43.8257 92.1974,-42.9756 92.1974,-42.9756 92.1974,-42.9756 95.5926,-43.8257 92.9625,-39.9199 98.9878,-44.6758 98.9878,-44.6758\"/>\n",
|
||||
"<text text-anchor=\"middle\" x=\"76.2401\" y=\"-42.6701\" font-family=\"Lato\" font-size=\"14.00\">1</text>\n",
|
||||
"</g>\n",
|
||||
"</g>\n",
|
||||
"</svg>\n"
|
||||
],
|
||||
"text": [
|
||||
"<spot_impl.tgba_digraph; proxy of <Swig Object of type 'std::shared_ptr< spot::tgba_digraph > *' at 0x7f156825d510> >"
|
||||
]
|
||||
},
|
||||
{
|
||||
"ename": "SyntaxError",
|
||||
"evalue": "\nexample.aut:20.2: syntax error, unexpected identifier\nexample.aut:20.1-3: ignoring this invalid label\nexample.aut:20.5: state number is larger than state count...\nexample.aut:14.1-9: ... declared here.\n (<string>)",
|
||||
"output_type": "pyerr",
|
||||
"traceback": [
|
||||
"\u001b[0;36m File \u001b[0;32m\"<string>\"\u001b[0;36m, line \u001b[0;32munknown\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m \nexample.aut:20.2: syntax error, unexpected identifier\nexample.aut:20.1-3: ignoring this invalid label\nexample.aut:20.5: state number is larger than state count...\nexample.aut:14.1-9: ... declared here.\n\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"prompt_number": 9
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"collapsed": false,
|
||||
"input": [
|
||||
"rm example.aut"
|
||||
],
|
||||
"language": "python",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"prompt_number": 10
|
||||
}
|
||||
],
|
||||
"metadata": {}
|
||||
}
|
||||
]
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue