Let's close #212 even if this does not cover the 32 sets. * spot/twaalgos/dot.cc: Change the palette. * doc/org/autfilt.org, NEWS: Adjust documentation. * tests/core/alternating.test, tests/core/readsave.test, tests/core/tgbagraph.test, tests/python/_altscc.ipynb, tests/python/alternation.ipynb, tests/python/atva16-fig2a.ipynb, tests/python/automata-io.ipynb, tests/python/automata.ipynb, tests/python/decompose.ipynb, tests/python/gen.ipynb, tests/python/highlighting.ipynb, tests/python/ltsmin-dve.ipynb, tests/python/piperead.ipynb, tests/python/product.ipynb, tests/python/randaut.ipynb, tests/python/word.ipynb: Adjust test cases.
682 lines
31 KiB
Text
682 lines
31 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.3"
|
|
},
|
|
"name": ""
|
|
},
|
|
"nbformat": 3,
|
|
"nbformat_minor": 0,
|
|
"worksheets": [
|
|
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"import spot\n",
|
|
"spot.setup()"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"prompt_number": 1
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"Let's build a small automaton to use as example."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"aut = spot.translate('G(Fa <-> XXb)'); aut"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"metadata": {},
|
|
"output_type": "pyout",
|
|
"prompt_number": 2,
|
|
"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=\"465pt\" height=\"215pt\"\n",
|
|
" viewBox=\"0.00 0.00 464.50 215.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 211)\">\n",
|
|
"<title>G</title>\n",
|
|
"<polygon fill=\"white\" stroke=\"none\" points=\"-4,4 -4,-211 460.5,-211 460.5,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=\"-55\" rx=\"18\" ry=\"18\"/>\n",
|
|
"<text text-anchor=\"middle\" x=\"56\" y=\"-51.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,-55C2.79388,-55 17.1543,-55 30.6317,-55\"/>\n",
|
|
"<polygon fill=\"black\" stroke=\"black\" points=\"37.9419,-55 30.9419,-58.1501 34.4419,-55 30.9419,-55.0001 30.9419,-55.0001 30.9419,-55.0001 34.4419,-55 30.9418,-51.8501 37.9419,-55 37.9419,-55\"/>\n",
|
|
"</g>\n",
|
|
"<!-- 1 -->\n",
|
|
"<g id=\"node3\" class=\"node\"><title>1</title>\n",
|
|
"<ellipse fill=\"#ffffaa\" stroke=\"black\" cx=\"139\" cy=\"-86\" rx=\"18\" ry=\"18\"/>\n",
|
|
"<text text-anchor=\"middle\" x=\"139\" y=\"-82.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=\"M73.003,-61.1246C85.0955,-65.7526 101.855,-72.1668 115.327,-77.3227\"/>\n",
|
|
"<polygon fill=\"black\" stroke=\"black\" points=\"122.03,-79.8881 114.367,-80.3279 118.761,-78.6371 115.493,-77.386 115.493,-77.386 115.493,-77.386 118.761,-78.6371 116.619,-74.4441 122.03,-79.8881 122.03,-79.8881\"/>\n",
|
|
"<text text-anchor=\"start\" x=\"94\" y=\"-75.8\" font-family=\"Lato\" font-size=\"14.00\">a</text>\n",
|
|
"</g>\n",
|
|
"<!-- 2 -->\n",
|
|
"<g id=\"node4\" class=\"node\"><title>2</title>\n",
|
|
"<ellipse fill=\"#ffffaa\" stroke=\"black\" cx=\"139\" cy=\"-18\" rx=\"18\" ry=\"18\"/>\n",
|
|
"<text text-anchor=\"middle\" x=\"139\" y=\"-14.3\" font-family=\"Lato\" font-size=\"14.00\">2</text>\n",
|
|
"</g>\n",
|
|
"<!-- 0->2 -->\n",
|
|
"<g id=\"edge3\" class=\"edge\"><title>0->2</title>\n",
|
|
"<path fill=\"none\" stroke=\"black\" d=\"M72.6176,-47.866C84.9439,-42.2355 102.291,-34.3117 116.019,-28.0406\"/>\n",
|
|
"<polygon fill=\"black\" stroke=\"black\" points=\"122.43,-25.1121 117.372,-30.8858 119.247,-26.5663 116.063,-28.0206 116.063,-28.0206 116.063,-28.0206 119.247,-26.5663 114.754,-25.1554 122.43,-25.1121 122.43,-25.1121\"/>\n",
|
|
"<text text-anchor=\"start\" x=\"92\" y=\"-41.8\" font-family=\"Lato\" font-size=\"14.00\">!a</text>\n",
|
|
"</g>\n",
|
|
"<!-- 3 -->\n",
|
|
"<g id=\"node5\" class=\"node\"><title>3</title>\n",
|
|
"<ellipse fill=\"#ffffaa\" stroke=\"black\" cx=\"218\" cy=\"-107\" rx=\"18\" ry=\"18\"/>\n",
|
|
"<text text-anchor=\"middle\" x=\"218\" y=\"-103.3\" font-family=\"Lato\" font-size=\"14.00\">3</text>\n",
|
|
"</g>\n",
|
|
"<!-- 1->3 -->\n",
|
|
"<g id=\"edge4\" class=\"edge\"><title>1->3</title>\n",
|
|
"<path fill=\"none\" stroke=\"black\" d=\"M156.708,-90.5567C167.403,-93.4737 181.445,-97.3031 193.286,-100.533\"/>\n",
|
|
"<polygon fill=\"black\" stroke=\"black\" points=\"200.325,-102.452 192.743,-103.649 196.948,-101.531 193.571,-100.61 193.571,-100.61 193.571,-100.61 196.948,-101.531 194.4,-97.5713 200.325,-102.452 200.325,-102.452\"/>\n",
|
|
"<text text-anchor=\"start\" x=\"175\" y=\"-100.8\" font-family=\"Lato\" font-size=\"14.00\">a</text>\n",
|
|
"</g>\n",
|
|
"<!-- 4 -->\n",
|
|
"<g id=\"node6\" class=\"node\"><title>4</title>\n",
|
|
"<ellipse fill=\"#ffffaa\" stroke=\"black\" cx=\"327\" cy=\"-71\" rx=\"18\" ry=\"18\"/>\n",
|
|
"<text text-anchor=\"middle\" x=\"327\" y=\"-67.3\" font-family=\"Lato\" font-size=\"14.00\">4</text>\n",
|
|
"</g>\n",
|
|
"<!-- 1->4 -->\n",
|
|
"<g id=\"edge5\" class=\"edge\"><title>1->4</title>\n",
|
|
"<path fill=\"none\" stroke=\"black\" d=\"M155.656,-78.8828C167.543,-73.8869 184.441,-67.6441 200,-65 235.174,-59.0223 276.609,-63.083 302.091,-66.8263\"/>\n",
|
|
"<polygon fill=\"black\" stroke=\"black\" points=\"309.149,-67.9155 301.75,-69.9609 305.69,-67.3817 302.231,-66.8478 302.231,-66.8478 302.231,-66.8478 305.69,-67.3817 302.711,-63.7347 309.149,-67.9155 309.149,-67.9155\"/>\n",
|
|
"<text text-anchor=\"start\" x=\"212.5\" y=\"-68.8\" font-family=\"Lato\" font-size=\"14.00\">!a</text>\n",
|
|
"</g>\n",
|
|
"<!-- 5 -->\n",
|
|
"<g id=\"node7\" class=\"node\"><title>5</title>\n",
|
|
"<ellipse fill=\"#ffffaa\" stroke=\"black\" cx=\"327\" cy=\"-179\" rx=\"18\" ry=\"18\"/>\n",
|
|
"<text text-anchor=\"middle\" x=\"327\" y=\"-175.3\" font-family=\"Lato\" font-size=\"14.00\">5</text>\n",
|
|
"</g>\n",
|
|
"<!-- 1->5 -->\n",
|
|
"<g id=\"edge6\" class=\"edge\"><title>1->5</title>\n",
|
|
"<path fill=\"none\" stroke=\"black\" d=\"M145.052,-103.353C152.731,-126.145 169.745,-165.231 200,-182 232.013,-199.743 275.986,-193.018 302.622,-186.225\"/>\n",
|
|
"<polygon fill=\"black\" stroke=\"black\" points=\"309.65,-184.328 303.713,-189.194 306.271,-185.24 302.892,-186.153 302.892,-186.153 302.892,-186.153 306.271,-185.24 302.071,-183.111 309.65,-184.328 309.65,-184.328\"/>\n",
|
|
"<text text-anchor=\"start\" x=\"212.5\" y=\"-195.8\" font-family=\"Lato\" font-size=\"14.00\">!a</text>\n",
|
|
"</g>\n",
|
|
"<!-- 2->3 -->\n",
|
|
"<g id=\"edge7\" class=\"edge\"><title>2->3</title>\n",
|
|
"<path fill=\"none\" stroke=\"black\" d=\"M151.362,-31.1323C164.441,-46.2502 186.023,-71.1956 200.846,-88.3285\"/>\n",
|
|
"<polygon fill=\"black\" stroke=\"black\" points=\"205.592,-93.8139 198.63,-90.5811 203.302,-91.167 201.012,-88.5201 201.012,-88.5201 201.012,-88.5201 203.302,-91.167 203.394,-86.4591 205.592,-93.8139 205.592,-93.8139\"/>\n",
|
|
"<text text-anchor=\"start\" x=\"175\" y=\"-68.8\" font-family=\"Lato\" font-size=\"14.00\">a</text>\n",
|
|
"</g>\n",
|
|
"<!-- 2->4 -->\n",
|
|
"<g id=\"edge8\" class=\"edge\"><title>2->4</title>\n",
|
|
"<path fill=\"none\" stroke=\"black\" d=\"M156.924,-21.8749C185.025,-28.4443 242.977,-42.5668 291,-58 295.032,-59.2959 299.287,-60.7772 303.387,-62.2649\"/>\n",
|
|
"<polygon fill=\"black\" stroke=\"black\" points=\"310.075,-64.7429 302.417,-65.2646 306.793,-63.5269 303.511,-62.3108 303.511,-62.3108 303.511,-62.3108 306.793,-63.5269 304.605,-59.3571 310.075,-64.7429 310.075,-64.7429\"/>\n",
|
|
"<text text-anchor=\"start\" x=\"212.5\" y=\"-44.8\" font-family=\"Lato\" font-size=\"14.00\">!a</text>\n",
|
|
"</g>\n",
|
|
"<!-- 6 -->\n",
|
|
"<g id=\"node8\" class=\"node\"><title>6</title>\n",
|
|
"<ellipse fill=\"#ffffaa\" stroke=\"black\" cx=\"436\" cy=\"-22\" rx=\"18\" ry=\"18\"/>\n",
|
|
"<text text-anchor=\"middle\" x=\"436\" y=\"-18.3\" font-family=\"Lato\" font-size=\"14.00\">6</text>\n",
|
|
"</g>\n",
|
|
"<!-- 2->6 -->\n",
|
|
"<g id=\"edge9\" class=\"edge\"><title>2->6</title>\n",
|
|
"<path fill=\"none\" stroke=\"black\" d=\"M157.136,-18.2323C207.034,-18.9089 352.372,-20.8796 410.528,-21.6682\"/>\n",
|
|
"<polygon fill=\"black\" stroke=\"black\" points=\"417.817,-21.767 410.775,-24.8217 414.317,-21.7195 410.818,-21.672 410.818,-21.672 410.818,-21.672 414.317,-21.7195 410.861,-18.5223 417.817,-21.767 417.817,-21.767\"/>\n",
|
|
"<text text-anchor=\"start\" x=\"267\" y=\"-24.8\" font-family=\"Lato\" font-size=\"14.00\">!a</text>\n",
|
|
"</g>\n",
|
|
"<!-- 3->3 -->\n",
|
|
"<g id=\"edge10\" class=\"edge\"><title>3->3</title>\n",
|
|
"<path fill=\"none\" stroke=\"black\" d=\"M211.266,-124.037C209.892,-133.858 212.137,-143 218,-143 222.397,-143 224.759,-137.858 225.086,-131.143\"/>\n",
|
|
"<polygon fill=\"black\" stroke=\"black\" points=\"224.734,-124.037 228.226,-130.873 224.907,-127.533 225.08,-131.029 225.08,-131.029 225.08,-131.029 224.907,-127.533 221.934,-131.185 224.734,-124.037 224.734,-124.037\"/>\n",
|
|
"<text text-anchor=\"start\" x=\"201\" y=\"-161.8\" font-family=\"Lato\" font-size=\"14.00\">a & b</text>\n",
|
|
"<text text-anchor=\"start\" x=\"210\" y=\"-146.8\" font-family=\"Lato\" font-size=\"14.00\" fill=\"#1f78b4\">\u24ff</text>\n",
|
|
"</g>\n",
|
|
"<!-- 3->4 -->\n",
|
|
"<g id=\"edge11\" class=\"edge\"><title>3->4</title>\n",
|
|
"<path fill=\"none\" stroke=\"black\" d=\"M234.442,-114.796C249.614,-121.291 273.039,-128.132 291,-119 301.558,-113.632 309.687,-103.42 315.441,-93.7909\"/>\n",
|
|
"<polygon fill=\"black\" stroke=\"black\" points=\"318.882,-87.604 318.233,-95.2526 317.181,-90.6629 315.48,-93.7218 315.48,-93.7218 315.48,-93.7218 317.181,-90.6629 312.727,-92.1909 318.882,-87.604 318.882,-87.604\"/>\n",
|
|
"<text text-anchor=\"start\" x=\"254\" y=\"-126.8\" font-family=\"Lato\" font-size=\"14.00\">!a & b</text>\n",
|
|
"</g>\n",
|
|
"<!-- 3->5 -->\n",
|
|
"<g id=\"edge12\" class=\"edge\"><title>3->5</title>\n",
|
|
"<path fill=\"none\" stroke=\"black\" d=\"M230.453,-120.313C236.909,-127.314 245.39,-135.722 254,-142 269.46,-153.274 288.841,-163.021 303.599,-169.677\"/>\n",
|
|
"<polygon fill=\"black\" stroke=\"black\" points=\"310.024,-172.512 302.348,-172.568 306.822,-171.099 303.62,-169.686 303.62,-169.686 303.62,-169.686 306.822,-171.099 304.891,-166.804 310.024,-172.512 310.024,-172.512\"/>\n",
|
|
"<text text-anchor=\"start\" x=\"254\" y=\"-166.8\" font-family=\"Lato\" font-size=\"14.00\">!a & b</text>\n",
|
|
"</g>\n",
|
|
"<!-- 4->3 -->\n",
|
|
"<g id=\"edge13\" class=\"edge\"><title>4->3</title>\n",
|
|
"<path fill=\"none\" stroke=\"black\" d=\"M308.918,-72.5299C294.007,-74.2807 271.999,-77.8816 254,-85 248.953,-86.9961 243.833,-89.7328 239.124,-92.5982\"/>\n",
|
|
"<polygon fill=\"black\" stroke=\"black\" points=\"233.003,-96.5281 237.192,-90.0954 235.949,-94.6371 238.894,-92.7462 238.894,-92.7462 238.894,-92.7462 235.949,-94.6371 240.596,-95.3969 233.003,-96.5281 233.003,-96.5281\"/>\n",
|
|
"<text text-anchor=\"start\" x=\"255.5\" y=\"-103.8\" font-family=\"Lato\" font-size=\"14.00\">a & b</text>\n",
|
|
"<text text-anchor=\"start\" x=\"264.5\" y=\"-88.8\" font-family=\"Lato\" font-size=\"14.00\" fill=\"#1f78b4\">\u24ff</text>\n",
|
|
"</g>\n",
|
|
"<!-- 4->4 -->\n",
|
|
"<g id=\"edge14\" class=\"edge\"><title>4->4</title>\n",
|
|
"<path fill=\"none\" stroke=\"black\" d=\"M317.767,-86.5414C315.169,-96.9087 318.246,-107 327,-107 333.702,-107 337.077,-101.085 337.124,-93.6591\"/>\n",
|
|
"<polygon fill=\"black\" stroke=\"black\" points=\"336.233,-86.5414 340.229,-93.0955 336.668,-90.0143 337.103,-93.4871 337.103,-93.4871 337.103,-93.4871 336.668,-90.0143 333.977,-93.8788 336.233,-86.5414 336.233,-86.5414\"/>\n",
|
|
"<text text-anchor=\"start\" x=\"308.5\" y=\"-110.8\" font-family=\"Lato\" font-size=\"14.00\">!a & b</text>\n",
|
|
"</g>\n",
|
|
"<!-- 5->6 -->\n",
|
|
"<g id=\"edge15\" class=\"edge\"><title>5->6</title>\n",
|
|
"<path fill=\"none\" stroke=\"black\" d=\"M337.875,-164.511C356.984,-136.471 399.072,-74.7167 421.037,-42.4872\"/>\n",
|
|
"<polygon fill=\"black\" stroke=\"black\" points=\"425.149,-36.4538 423.81,-44.0122 423.178,-39.3459 421.207,-42.2381 421.207,-42.2381 421.207,-42.2381 423.178,-39.3459 418.604,-40.4641 425.149,-36.4538 425.149,-36.4538\"/>\n",
|
|
"<text text-anchor=\"start\" x=\"363\" y=\"-126.8\" font-family=\"Lato\" font-size=\"14.00\">!a & b</text>\n",
|
|
"</g>\n",
|
|
"<!-- 6->6 -->\n",
|
|
"<g id=\"edge16\" class=\"edge\"><title>6->6</title>\n",
|
|
"<path fill=\"none\" stroke=\"black\" d=\"M426.767,-37.5414C424.169,-47.9087 427.246,-58 436,-58 442.702,-58 446.077,-52.0847 446.124,-44.6591\"/>\n",
|
|
"<polygon fill=\"black\" stroke=\"black\" points=\"445.233,-37.5414 449.229,-44.0955 445.668,-41.0143 446.103,-44.4871 446.103,-44.4871 446.103,-44.4871 445.668,-41.0143 442.977,-44.8788 445.233,-37.5414 445.233,-37.5414\"/>\n",
|
|
"<text text-anchor=\"start\" x=\"415.5\" y=\"-76.8\" font-family=\"Lato\" font-size=\"14.00\">!a & !b</text>\n",
|
|
"<text text-anchor=\"start\" x=\"428\" y=\"-61.8\" font-family=\"Lato\" font-size=\"14.00\" fill=\"#1f78b4\">\u24ff</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 0x7fdf783f0510> >"
|
|
]
|
|
}
|
|
],
|
|
"prompt_number": 2
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"Build an accepting run:"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"run = aut.accepting_run(); run"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"metadata": {},
|
|
"output_type": "pyout",
|
|
"prompt_number": 3,
|
|
"text": [
|
|
"Prefix:\n",
|
|
" 0\n",
|
|
" | a\n",
|
|
" 1\n",
|
|
" | a\n",
|
|
"Cycle:\n",
|
|
" 3\n",
|
|
" | a & b\t{0}"
|
|
]
|
|
}
|
|
],
|
|
"prompt_number": 3
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"Accessing the contents of the run can be done via the `prefix` and `cycle` lists."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"print(spot.bdd_format_formula(aut.get_dict(), run.prefix[0].label))\n",
|
|
"print(run.cycle[0].acc)"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"output_type": "stream",
|
|
"stream": "stdout",
|
|
"text": [
|
|
"a\n",
|
|
"{0}\n"
|
|
]
|
|
}
|
|
],
|
|
"prompt_number": 4
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"To convert the run into a word, using `spot.twa_word()`. Note that our runs are labeled by Boolean formulas that are not necessarily a conjunction of all involved litterals. The word is just the projection of the run on its labels."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"word = spot.twa_word(run); word"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"metadata": {},
|
|
"output_type": "pyout",
|
|
"prompt_number": 5,
|
|
"text": [
|
|
"a; a; cycle{a & b}"
|
|
]
|
|
}
|
|
],
|
|
"prompt_number": 5
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"Accessing the different formulas (stored as BDDs) can be done again via the `prefix` and `cycle` lists."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"print(spot.bdd_format_formula(aut.get_dict(), word.prefix[0]))\n",
|
|
"print(spot.bdd_format_formula(aut.get_dict(), word.prefix[1]))\n",
|
|
"print(spot.bdd_format_formula(aut.get_dict(), word.cycle[0]))"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"output_type": "stream",
|
|
"stream": "stdout",
|
|
"text": [
|
|
"a\n",
|
|
"a\n",
|
|
"a & b\n"
|
|
]
|
|
}
|
|
],
|
|
"prompt_number": 6
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"Calling `simplifify()` will produce a shorter word that is compatible with the original word. For instance in the above word, the initial `a` is compatible with both `a & b` and `a & !b`. The word obtained by restricting `a` to `a & b` is therefore still accepted, allowing us to remove the prefix."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"word.simplify()\n",
|
|
"word"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"metadata": {},
|
|
"output_type": "pyout",
|
|
"prompt_number": 7,
|
|
"text": [
|
|
"cycle{a & b}"
|
|
]
|
|
}
|
|
],
|
|
"prompt_number": 7
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"Such a simplified word can be created directly from the automaton:"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"aut.accepting_word()"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"metadata": {},
|
|
"output_type": "pyout",
|
|
"prompt_number": 8,
|
|
"text": [
|
|
"cycle{a & b}"
|
|
]
|
|
}
|
|
],
|
|
"prompt_number": 8
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"Words can be created using the `parse_word` function:"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"print(spot.parse_word('a; b; cycle{a&b}'))\n",
|
|
"print(spot.parse_word('cycle{a&bb|bac&(aaa|bbb)}'))\n",
|
|
"print(spot.parse_word('a; b;b; qiwuei;\"a;b&c;a\" ;cycle{a}'))"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"output_type": "stream",
|
|
"stream": "stdout",
|
|
"text": [
|
|
"a; b; cycle{a & b}\n",
|
|
"cycle{(a & bb) | (aaa & bac) | (bac & bbb)}\n",
|
|
"a; b; b; qiwuei; \"a;b&c;a\"; cycle{a}\n"
|
|
]
|
|
}
|
|
],
|
|
"prompt_number": 9
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"# make sure that we can parse a word back after it has been printed\n",
|
|
"spot.parse_word(str(spot.parse_word('a;b&a;cycle{!a&!b}')))"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"metadata": {},
|
|
"output_type": "pyout",
|
|
"prompt_number": 10,
|
|
"text": [
|
|
"a; a & b; cycle{!a & !b}"
|
|
]
|
|
}
|
|
],
|
|
"prompt_number": 10
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"Words can be easily converted as automata"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"w1 = spot.parse_word('a; !a; cycle{a; !a; a}')"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"prompt_number": 11
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"w1.as_automaton()"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"metadata": {},
|
|
"output_type": "pyout",
|
|
"prompt_number": 12,
|
|
"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=\"406pt\" height=\"74pt\"\n",
|
|
" viewBox=\"0.00 0.00 406.00 74.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 70)\">\n",
|
|
"<title>G</title>\n",
|
|
"<polygon fill=\"white\" stroke=\"none\" points=\"-4,4 -4,-70 402,-70 402,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",
|
|
"<!-- 1 -->\n",
|
|
"<g id=\"node3\" class=\"node\"><title>1</title>\n",
|
|
"<ellipse fill=\"#ffffaa\" stroke=\"black\" cx=\"135\" cy=\"-18\" rx=\"18\" ry=\"18\"/>\n",
|
|
"<text text-anchor=\"middle\" x=\"135\" 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.0888,-18C84.5562,-18 98.1196,-18 109.693,-18\"/>\n",
|
|
"<polygon fill=\"black\" stroke=\"black\" points=\"116.959,-18 109.959,-21.1501 113.459,-18 109.959,-18.0001 109.959,-18.0001 109.959,-18.0001 113.459,-18 109.959,-14.8501 116.959,-18 116.959,-18\"/>\n",
|
|
"<text text-anchor=\"start\" x=\"92\" y=\"-21.8\" font-family=\"Lato\" font-size=\"14.00\">a</text>\n",
|
|
"</g>\n",
|
|
"<!-- 2 -->\n",
|
|
"<g id=\"node4\" class=\"node\"><title>2</title>\n",
|
|
"<ellipse fill=\"#ffffaa\" stroke=\"black\" cx=\"218\" cy=\"-18\" rx=\"18\" ry=\"18\"/>\n",
|
|
"<text text-anchor=\"middle\" x=\"218\" y=\"-14.3\" font-family=\"Lato\" font-size=\"14.00\">2</text>\n",
|
|
"</g>\n",
|
|
"<!-- 1->2 -->\n",
|
|
"<g id=\"edge3\" class=\"edge\"><title>1->2</title>\n",
|
|
"<path fill=\"none\" stroke=\"black\" d=\"M153.178,-18C164.669,-18 179.959,-18 192.693,-18\"/>\n",
|
|
"<polygon fill=\"black\" stroke=\"black\" points=\"199.847,-18 192.847,-21.1501 196.347,-18 192.847,-18.0001 192.847,-18.0001 192.847,-18.0001 196.347,-18 192.847,-14.8501 199.847,-18 199.847,-18\"/>\n",
|
|
"<text text-anchor=\"start\" x=\"171\" y=\"-21.8\" font-family=\"Lato\" font-size=\"14.00\">!a</text>\n",
|
|
"</g>\n",
|
|
"<!-- 3 -->\n",
|
|
"<g id=\"node5\" class=\"node\"><title>3</title>\n",
|
|
"<ellipse fill=\"#ffffaa\" stroke=\"black\" cx=\"297\" cy=\"-48\" rx=\"18\" ry=\"18\"/>\n",
|
|
"<text text-anchor=\"middle\" x=\"297\" y=\"-44.3\" font-family=\"Lato\" font-size=\"14.00\">3</text>\n",
|
|
"</g>\n",
|
|
"<!-- 2->3 -->\n",
|
|
"<g id=\"edge4\" class=\"edge\"><title>2->3</title>\n",
|
|
"<path fill=\"none\" stroke=\"black\" d=\"M234.954,-24.216C246.105,-28.5603 261.15,-34.4223 273.515,-39.2395\"/>\n",
|
|
"<polygon fill=\"black\" stroke=\"black\" points=\"280.066,-41.7919 272.4,-42.1858 276.805,-40.5213 273.544,-39.2507 273.544,-39.2507 273.544,-39.2507 276.805,-40.5213 274.687,-36.3156 280.066,-41.7919 280.066,-41.7919\"/>\n",
|
|
"<text text-anchor=\"start\" x=\"254\" y=\"-36.8\" font-family=\"Lato\" font-size=\"14.00\">a</text>\n",
|
|
"</g>\n",
|
|
"<!-- 4 -->\n",
|
|
"<g id=\"node6\" class=\"node\"><title>4</title>\n",
|
|
"<ellipse fill=\"#ffffaa\" stroke=\"black\" cx=\"380\" cy=\"-18\" rx=\"18\" ry=\"18\"/>\n",
|
|
"<text text-anchor=\"middle\" x=\"380\" y=\"-14.3\" font-family=\"Lato\" font-size=\"14.00\">4</text>\n",
|
|
"</g>\n",
|
|
"<!-- 3->4 -->\n",
|
|
"<g id=\"edge5\" class=\"edge\"><title>3->4</title>\n",
|
|
"<path fill=\"none\" stroke=\"black\" d=\"M314.003,-42.073C326.017,-37.6233 342.638,-31.4675 356.064,-26.4947\"/>\n",
|
|
"<polygon fill=\"black\" stroke=\"black\" points=\"362.753,-24.0174 357.283,-29.4026 359.471,-25.233 356.189,-26.4487 356.189,-26.4487 356.189,-26.4487 359.471,-25.233 355.095,-23.4948 362.753,-24.0174 362.753,-24.0174\"/>\n",
|
|
"<text text-anchor=\"start\" x=\"333\" y=\"-37.8\" font-family=\"Lato\" font-size=\"14.00\">!a</text>\n",
|
|
"</g>\n",
|
|
"<!-- 4->2 -->\n",
|
|
"<g id=\"edge6\" class=\"edge\"><title>4->2</title>\n",
|
|
"<path fill=\"none\" stroke=\"black\" d=\"M362.276,-13.9842C349.433,-11.115 331.209,-7.50646 315,-6 299.069,-4.51934 294.922,-4.4234 279,-6 266.86,-7.20214 253.537,-9.74069 242.536,-12.1747\"/>\n",
|
|
"<polygon fill=\"black\" stroke=\"black\" points=\"235.677,-13.744 241.798,-9.11188 239.089,-12.9632 242.501,-12.1825 242.501,-12.1825 242.501,-12.1825 239.089,-12.9632 243.204,-15.2532 235.677,-13.744 235.677,-13.744\"/>\n",
|
|
"<text text-anchor=\"start\" x=\"293.5\" y=\"-9.8\" font-family=\"Lato\" font-size=\"14.00\">a</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 0x7fdf783f0e40> >"
|
|
]
|
|
}
|
|
],
|
|
"prompt_number": 12
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"The rest of this pages tests some syntax errors, you (humans) may skip it, but the test suite will not."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"print(spot.parse_word('a; b&!a; b'))"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"ename": "SyntaxError",
|
|
"evalue": "\n>>> a; b&!a; b\n ^\nA twa_word must contain a cycle\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 \n>>> a; b&!a; b\n ^\nA twa_word must contain a cycle\n\n"
|
|
]
|
|
}
|
|
],
|
|
"prompt_number": 13
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"print(spot.parse_word('a; b; c}'))"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"ename": "SyntaxError",
|
|
"evalue": "\n>>> a; b; c}\n ^\nExpected ';' delimiter: '}' stands for ending a cycle\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 \n>>> a; b; c}\n ^\nExpected ';' delimiter: '}' stands for ending a cycle\n\n"
|
|
]
|
|
}
|
|
],
|
|
"prompt_number": 14
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"print(spot.parse_word('a; cycle{}'))"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"ename": "SyntaxError",
|
|
"evalue": "\n>>> a; cycle{}\n ^\nempty input\n\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 \n>>> a; cycle{}\n ^\nempty input\n\n\n"
|
|
]
|
|
}
|
|
],
|
|
"prompt_number": 15
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"print(spot.parse_word('a; cycle{!a}; a'))"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"ename": "SyntaxError",
|
|
"evalue": "\n>>> a; cycle{!a}; a\n ^\nInput should be finished after cycle\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 \n>>> a; cycle{!a}; a\n ^\nInput should be finished after cycle\n\n"
|
|
]
|
|
}
|
|
],
|
|
"prompt_number": 16
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"# Creating an empty word is OK...\n",
|
|
"w = spot.twa_word(spot._bdd_dict)"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"prompt_number": 17
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"# ... as long as this word is not printed.\n",
|
|
"print(w)"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"ename": "RuntimeError",
|
|
"evalue": "a twa_word may not have an empty cycle",
|
|
"output_type": "pyerr",
|
|
"traceback": [
|
|
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
|
|
"\u001b[0;31mRuntimeError\u001b[0m Traceback (most recent call last)",
|
|
"\u001b[0;32m<ipython-input-18-971829bb8f5f>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0;31m# ... as long as this word is not printed.\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mw\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
|
|
"\u001b[0;32m/home/adl/git/spot/python/spot/impl.py\u001b[0m in \u001b[0;36m__str__\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 4160\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4161\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0m__str__\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;34m->\u001b[0m \u001b[0;34m\"std::string\"\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 4162\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0m_impl\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mtwa_word___str__\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 4163\u001b[0m \u001b[0mtwa_word_swigregister\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0m_impl\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mtwa_word_swigregister\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4164\u001b[0m \u001b[0mtwa_word_swigregister\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mtwa_word\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
|
|
"\u001b[0;31mRuntimeError\u001b[0m: a twa_word may not have an empty cycle"
|
|
]
|
|
}
|
|
],
|
|
"prompt_number": 18
|
|
}
|
|
],
|
|
"metadata": {}
|
|
}
|
|
]
|
|
}
|