spot/tests/python/atva16-fig2a.ipynb
Alexandre Duret-Lutz a1260105a4 python: add the examples from the ATVA'16 paper
* tests/python/atva16-fig2a.ipynb, tests/python/atva16-fig2b.ipynb: New
files.
* tests/Makefile.am, doc/org/tut.org: Add them.
2016-06-17 14:18:48 +02:00

261 lines
13 KiB
Text

{
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.2rc1"
},
"name": ""
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This example is the left part of Fig.2 in our ATVA'16 paper titled \"*Spot 2.0 \u2014 a framework for LTL and \u03c9-automata manipulation*\"."
]
},
{
"cell_type": "code",
"collapsed": true,
"input": [
"import spot\n",
"spot.setup(show_default='.abr')"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 1
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"f = spot.formula('GFa <-> GFb'); f"
],
"language": "python",
"metadata": {},
"outputs": [
{
"latex": [
"$\\mathsf{G} \\mathsf{F} a \\leftrightarrow \\mathsf{G} \\mathsf{F} b$"
],
"metadata": {},
"output_type": "pyout",
"prompt_number": 2,
"text": [
"GFa <-> GFb"
]
}
],
"prompt_number": 2
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"f.translate()"
],
"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=\"288pt\" height=\"360pt\"\n",
" viewBox=\"0.00 0.00 288.47 360.00\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
"<g id=\"graph0\" class=\"graph\" transform=\"scale(0.947368 0.947368) rotate(0) translate(4 376)\">\n",
"<title>G</title>\n",
"<polygon fill=\"white\" stroke=\"none\" points=\"-4,4 -4,-376 300.5,-376 300.5,4 -4,4\"/>\n",
"<text text-anchor=\"start\" x=\"100.25\" y=\"-357.8\" font-family=\"Lato\" font-size=\"14.00\">Inf(</text>\n",
"<text text-anchor=\"start\" x=\"124.25\" y=\"-357.8\" font-family=\"Lato\" font-size=\"14.00\" fill=\"#5da5da\">\u24ff</text>\n",
"<text text-anchor=\"start\" x=\"137.25\" y=\"-357.8\" font-family=\"Lato\" font-size=\"14.00\">)&amp;Inf(</text>\n",
"<text text-anchor=\"start\" x=\"177.25\" y=\"-357.8\" font-family=\"Lato\" font-size=\"14.00\" fill=\"#f17cb0\">\u2776</text>\n",
"<text text-anchor=\"start\" x=\"190.25\" y=\"-357.8\" font-family=\"Lato\" font-size=\"14.00\">)</text>\n",
"<!-- I -->\n",
"<!-- 0 -->\n",
"<g id=\"node2\" class=\"node\"><title>0</title>\n",
"<ellipse fill=\"#ffffaa\" stroke=\"black\" cx=\"56\" cy=\"-105\" rx=\"18\" ry=\"18\"/>\n",
"<text text-anchor=\"middle\" x=\"56\" y=\"-101.3\" font-family=\"Lato\" font-size=\"14.00\">0</text>\n",
"</g>\n",
"<!-- I&#45;&gt;0 -->\n",
"<g id=\"edge1\" class=\"edge\"><title>I&#45;&gt;0</title>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M1.15491,-105C2.79388,-105 17.1543,-105 30.6317,-105\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"37.9419,-105 30.9419,-108.15 34.4419,-105 30.9419,-105 30.9419,-105 30.9419,-105 34.4419,-105 30.9418,-101.85 37.9419,-105 37.9419,-105\"/>\n",
"</g>\n",
"<!-- 1 -->\n",
"<g id=\"node3\" class=\"node\"><title>1</title>\n",
"<ellipse fill=\"#ffffaa\" stroke=\"black\" cx=\"144.5\" cy=\"-156\" rx=\"18\" ry=\"18\"/>\n",
"<text text-anchor=\"middle\" x=\"144.5\" y=\"-152.3\" font-family=\"Lato\" font-size=\"14.00\">1</text>\n",
"</g>\n",
"<!-- 0&#45;&gt;1 -->\n",
"<g id=\"edge2\" class=\"edge\"><title>0&#45;&gt;1</title>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M72.0672,-113.884C85.9591,-122.074 106.722,-134.316 122.288,-143.493\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"128.606,-147.218 120.976,-146.376 125.591,-145.441 122.576,-143.663 122.576,-143.663 122.576,-143.663 125.591,-145.441 124.175,-140.95 128.606,-147.218 128.606,-147.218\"/>\n",
"<text text-anchor=\"middle\" x=\"97\" y=\"-133.8\" font-family=\"Lato\" font-size=\"14.00\">1</text>\n",
"</g>\n",
"<!-- 2 -->\n",
"<g id=\"node4\" class=\"node\"><title>2</title>\n",
"<ellipse fill=\"#ffffaa\" stroke=\"black\" cx=\"272\" cy=\"-76\" rx=\"18\" ry=\"18\"/>\n",
"<text text-anchor=\"middle\" x=\"272\" y=\"-72.3\" font-family=\"Lato\" font-size=\"14.00\">2</text>\n",
"</g>\n",
"<!-- 0&#45;&gt;2 -->\n",
"<g id=\"edge3\" class=\"edge\"><title>0&#45;&gt;2</title>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M74.1508,-102.676C112.123,-97.5301 203.374,-85.1643 246.992,-79.2534\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"254.065,-78.295 247.551,-82.3565 250.596,-78.765 247.128,-79.2351 247.128,-79.2351 247.128,-79.2351 250.596,-78.765 246.705,-76.1136 254.065,-78.295 254.065,-78.295\"/>\n",
"<text text-anchor=\"start\" x=\"120\" y=\"-99.8\" font-family=\"Lato\" font-size=\"14.00\">!a &amp; !b</text>\n",
"</g>\n",
"<!-- 3 -->\n",
"<g id=\"node5\" class=\"node\"><title>3</title>\n",
"<ellipse fill=\"#ffffaa\" stroke=\"black\" cx=\"144.5\" cy=\"-18\" rx=\"18\" ry=\"18\"/>\n",
"<text text-anchor=\"middle\" x=\"144.5\" y=\"-14.3\" font-family=\"Lato\" font-size=\"14.00\">3</text>\n",
"</g>\n",
"<!-- 0&#45;&gt;3 -->\n",
"<g id=\"edge4\" class=\"edge\"><title>0&#45;&gt;3</title>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M69.3933,-92.535C84.1669,-77.676 108.963,-52.7363 125.764,-35.8381\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"131.13,-30.4419 128.428,-37.6268 128.662,-32.9239 126.194,-35.4059 126.194,-35.4059 126.194,-35.4059 128.662,-32.9239 123.96,-33.1849 131.13,-30.4419 131.13,-30.4419\"/>\n",
"<text text-anchor=\"middle\" x=\"97\" y=\"-72.8\" font-family=\"Lato\" font-size=\"14.00\">1</text>\n",
"</g>\n",
"<!-- 1&#45;&gt;1 -->\n",
"<g id=\"edge5\" class=\"edge\"><title>1&#45;&gt;1</title>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M142.42,-174.153C142.099,-183.539 142.793,-192 144.5,-192 145.754,-192 146.461,-187.437 146.621,-181.295\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"146.58,-174.153 149.77,-181.135 146.6,-177.653 146.62,-181.153 146.62,-181.153 146.62,-181.153 146.6,-177.653 143.47,-181.171 146.58,-174.153 146.58,-174.153\"/>\n",
"<text text-anchor=\"start\" x=\"123\" y=\"-210.8\" font-family=\"Lato\" font-size=\"14.00\">!a &amp; b</text>\n",
"<text text-anchor=\"start\" x=\"138\" y=\"-195.8\" font-family=\"Lato\" font-size=\"14.00\" fill=\"#f17cb0\">\u2776</text>\n",
"</g>\n",
"<!-- 1&#45;&gt;1 -->\n",
"<g id=\"edge6\" class=\"edge\"><title>1&#45;&gt;1</title>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M141.266,-173.906C139.109,-195 140.188,-222 144.5,-222 148.341,-222 149.616,-200.583 148.326,-180.997\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"147.734,-173.906 151.455,-180.62 148.025,-177.394 148.316,-180.882 148.316,-180.882 148.316,-180.882 148.025,-177.394 145.177,-181.144 147.734,-173.906 147.734,-173.906\"/>\n",
"<text text-anchor=\"start\" x=\"120\" y=\"-225.8\" font-family=\"Lato\" font-size=\"14.00\">!a &amp; !b</text>\n",
"</g>\n",
"<!-- 1&#45;&gt;1 -->\n",
"<g id=\"edge7\" class=\"edge\"><title>1&#45;&gt;1</title>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M140.372,-173.871C136.217,-201.525 137.593,-240 144.5,-240 150.84,-240 152.52,-207.578 149.539,-180.868\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"148.628,-173.871 152.655,-180.406 149.08,-177.342 149.532,-180.812 149.532,-180.812 149.532,-180.812 149.08,-177.342 146.408,-181.219 148.628,-173.871 148.628,-173.871\"/>\n",
"<text text-anchor=\"start\" x=\"126\" y=\"-257.8\" font-family=\"Lato\" font-size=\"14.00\">a &amp; b</text>\n",
"<text text-anchor=\"start\" x=\"131.5\" y=\"-243.8\" font-family=\"Lato\" font-size=\"14.00\" fill=\"#5da5da\">\u24ff</text>\n",
"<text text-anchor=\"start\" x=\"144.5\" y=\"-243.8\" font-family=\"Lato\" font-size=\"14.00\" fill=\"#f17cb0\">\u2776</text>\n",
"</g>\n",
"<!-- 1&#45;&gt;1 -->\n",
"<g id=\"edge8\" class=\"edge\"><title>1&#45;&gt;1</title>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M139.905,-173.612C133.288,-209.893 134.819,-268 144.5,-268 153.576,-268 155.489,-216.929 150.24,-180.651\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"149.095,-173.612 153.328,-180.015 149.657,-177.067 150.219,-180.521 150.219,-180.521 150.219,-180.521 149.657,-177.067 147.11,-181.027 149.095,-173.612 149.095,-173.612\"/>\n",
"<text text-anchor=\"start\" x=\"123\" y=\"-286.8\" font-family=\"Lato\" font-size=\"14.00\">a &amp; !b</text>\n",
"<text text-anchor=\"start\" x=\"138\" y=\"-271.8\" font-family=\"Lato\" font-size=\"14.00\" fill=\"#5da5da\">\u24ff</text>\n",
"</g>\n",
"<!-- 2&#45;&gt;2 -->\n",
"<g id=\"edge9\" class=\"edge\"><title>2&#45;&gt;2</title>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M261.849,-91.1666C258.772,-101.664 262.156,-112 272,-112 279.537,-112 283.287,-105.941 283.25,-98.39\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"282.151,-91.1666 286.318,-97.6135 282.678,-94.6269 283.204,-98.0871 283.204,-98.0871 283.204,-98.0871 282.678,-94.6269 280.09,-98.5607 282.151,-91.1666 282.151,-91.1666\"/>\n",
"<text text-anchor=\"start\" x=\"247.5\" y=\"-129.8\" font-family=\"Lato\" font-size=\"14.00\">!a &amp; !b</text>\n",
"<text text-anchor=\"start\" x=\"259\" y=\"-115.8\" font-family=\"Lato\" font-size=\"14.00\" fill=\"#5da5da\">\u24ff</text>\n",
"<text text-anchor=\"start\" x=\"272\" y=\"-115.8\" font-family=\"Lato\" font-size=\"14.00\" fill=\"#f17cb0\">\u2776</text>\n",
"</g>\n",
"<!-- 3&#45;&gt;2 -->\n",
"<g id=\"edge10\" class=\"edge\"><title>3&#45;&gt;2</title>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M161.141,-25.2285C183.217,-35.4311 223.626,-54.1061 248.802,-65.741\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"255.162,-68.6804 247.486,-68.6032 251.985,-67.2121 248.808,-65.7438 248.808,-65.7438 248.808,-65.7438 251.985,-67.2121 250.129,-62.8844 255.162,-68.6804 255.162,-68.6804\"/>\n",
"<text text-anchor=\"start\" x=\"187\" y=\"-61.8\" font-family=\"Lato\" font-size=\"14.00\">!a &amp; !b</text>\n",
"</g>\n",
"<!-- 3&#45;&gt;3 -->\n",
"<g id=\"edge11\" class=\"edge\"><title>3&#45;&gt;3</title>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M136.484,-34.2903C134.551,-44.3892 137.223,-54 144.5,-54 149.958,-54 152.826,-48.5939 153.103,-41.6304\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"152.516,-34.2903 156.214,-41.0172 152.795,-37.7792 153.074,-41.268 153.074,-41.268 153.074,-41.268 152.795,-37.7792 149.934,-41.5189 152.516,-34.2903 152.516,-34.2903\"/>\n",
"<text text-anchor=\"middle\" x=\"144.5\" y=\"-57.8\" font-family=\"Lato\" font-size=\"14.00\">1</text>\n",
"</g>\n",
"</g>\n",
"</svg>\n"
],
"text": [
"<spot.impl.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f77f87ba300> >"
]
}
],
"prompt_number": 3
},
{
"cell_type": "code",
"collapsed": true,
"input": [
"def implies(f, g):\n",
" f = spot.formula(f)\n",
" g = spot.formula_Not(spot.formula(g))\n",
" return spot.product(f.translate(), g.translate()).is_empty()\n",
"def equiv(f, g):\n",
" return implies(f, g) and implies(g, f)"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 4
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"equiv('a U (b U a)', 'b U a')"
],
"language": "python",
"metadata": {},
"outputs": [
{
"metadata": {},
"output_type": "pyout",
"prompt_number": 5,
"text": [
"True"
]
}
],
"prompt_number": 5
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"equiv('!(a U b)', '!a U !b')"
],
"language": "python",
"metadata": {},
"outputs": [
{
"metadata": {},
"output_type": "pyout",
"prompt_number": 6,
"text": [
"False"
]
}
],
"prompt_number": 6
}
],
"metadata": {}
}
]
}