Fixes #319. * spot/twaalgos/dot.cc: Enable "a" by default. * bin/common_aoutput.cc, NEWS: Document it. * doc/org/autfilt.org, doc/org/concepts.org, doc/org/dstar2tgba.org, doc/org/hierarchy.org, doc/org/ltl2tgba.org, doc/org/oaut.org, doc/org/randaut.org, doc/org/satmin.org, doc/org/tut23.org, doc/org/tut24.org, doc/org/tut30.org, doc/org/tut31.org: Adjust or simplify the documentation. * tests/core/det.test, tests/core/dstar.test, tests/core/monitor.test, tests/core/neverclaimread.test, tests/core/readsave.test, tests/core/tgbagraph.test, tests/core/wdba.test, tests/python/_autparserr.ipynb, tests/python/automata-io.ipynb, tests/python/automata.ipynb, tests/python/highlighting.ipynb tests/python/ltsmin-dve.ipynb, tests/python/ltsmin-pml.ipynb, tests/python/product.ipynb, tests/python/testingaut.ipynb, tests/python/word.ipynb: Adjust test cases.
562 lines
28 KiB
Text
562 lines
28 KiB
Text
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 1,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"import spot\n",
|
|
"spot.setup()"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"Let's build a small automaton to use as example."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 2,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"image/svg+xml": [
|
|
"<?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=\"202pt\"\n",
|
|
" viewBox=\"0.00 0.00 464.50 202.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 198)\">\n",
|
|
"<title>G</title>\n",
|
|
"<polygon fill=\"white\" stroke=\"none\" points=\"-4,4 -4,-198 460.5,-198 460.5,4 -4,4\"/>\n",
|
|
"<text text-anchor=\"start\" x=\"207.25\" y=\"-179.8\" font-family=\"Lato\" font-size=\"14.00\">Inf(</text>\n",
|
|
"<text text-anchor=\"start\" x=\"229.25\" y=\"-179.8\" font-family=\"Lato\" font-size=\"14.00\" fill=\"#1f78b4\">⓿</text>\n",
|
|
"<text text-anchor=\"start\" x=\"245.25\" y=\"-179.8\" font-family=\"Lato\" font-size=\"14.00\">)</text>\n",
|
|
"<text text-anchor=\"start\" x=\"205.25\" y=\"-165.8\" font-family=\"Lato\" font-size=\"14.00\">[Büchi]</text>\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=\"139\" cy=\"-18\" rx=\"18\" ry=\"18\"/>\n",
|
|
"<text text-anchor=\"middle\" x=\"139\" 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.178,-18C85.6688,-18 100.959,-18 113.693,-18\"/>\n",
|
|
"<polygon fill=\"black\" stroke=\"black\" points=\"120.847,-18 113.847,-21.1501 117.347,-18 113.847,-18.0001 113.847,-18.0001 113.847,-18.0001 117.347,-18 113.847,-14.8501 120.847,-18 120.847,-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=\"-79\" rx=\"18\" ry=\"18\"/>\n",
|
|
"<text text-anchor=\"middle\" x=\"218\" y=\"-75.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.766,-28.9056C166.03,-38.6209 184.099,-52.936 197.786,-63.7783\"/>\n",
|
|
"<polygon fill=\"black\" stroke=\"black\" points=\"203.353,-68.1888 195.91,-66.3112 200.61,-66.0154 197.866,-63.8421 197.866,-63.8421 197.866,-63.8421 200.61,-66.0154 199.822,-61.373 203.353,-68.1888 203.353,-68.1888\"/>\n",
|
|
"<text text-anchor=\"start\" x=\"175\" y=\"-53.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=\"327\" cy=\"-51\" rx=\"18\" ry=\"18\"/>\n",
|
|
"<text text-anchor=\"middle\" x=\"327\" y=\"-47.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=\"M157.272,-20.511C185.389,-24.6769 242.767,-33.504 291,-43 294.652,-43.719 298.505,-44.538 302.266,-45.371\"/>\n",
|
|
"<polygon fill=\"black\" stroke=\"black\" points=\"309.309,-46.9679 301.786,-48.492 305.896,-46.194 302.483,-45.42 302.483,-45.42 302.483,-45.42 305.896,-46.194 303.179,-42.348 309.309,-46.9679 309.309,-46.9679\"/>\n",
|
|
"<text text-anchor=\"start\" x=\"212.5\" y=\"-35.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=\"436\" cy=\"-22\" rx=\"18\" ry=\"18\"/>\n",
|
|
"<text text-anchor=\"middle\" x=\"436\" y=\"-18.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=\"M157.382,-17.8002C179.736,-17.5541 219.759,-17.1502 254,-17 270.444,-16.9279 274.558,-16.7146 291,-17 333.016,-17.7292 381.897,-19.6544 410.541,-20.892\"/>\n",
|
|
"<polygon fill=\"black\" stroke=\"black\" points=\"417.716,-21.2059 410.585,-24.0468 414.219,-21.0529 410.722,-20.8998 410.722,-20.8998 410.722,-20.8998 414.219,-21.0529 410.86,-17.7529 417.716,-21.2059 417.716,-21.2059\"/>\n",
|
|
"<text text-anchor=\"start\" x=\"267\" y=\"-20.8\" font-family=\"Lato\" font-size=\"14.00\">!a</text>\n",
|
|
"</g>\n",
|
|
"<!-- 2->2 -->\n",
|
|
"<g id=\"edge6\" class=\"edge\"><title>2->2</title>\n",
|
|
"<path fill=\"none\" stroke=\"black\" d=\"M211.266,-96.0373C209.892,-105.858 212.137,-115 218,-115 222.397,-115 224.759,-109.858 225.086,-103.143\"/>\n",
|
|
"<polygon fill=\"black\" stroke=\"black\" points=\"224.734,-96.0373 228.226,-102.873 224.907,-99.533 225.08,-103.029 225.08,-103.029 225.08,-103.029 224.907,-99.533 221.934,-103.185 224.734,-96.0373 224.734,-96.0373\"/>\n",
|
|
"<text text-anchor=\"start\" x=\"201\" y=\"-133.8\" font-family=\"Lato\" font-size=\"14.00\">a & b</text>\n",
|
|
"<text text-anchor=\"start\" x=\"210\" y=\"-118.8\" font-family=\"Lato\" font-size=\"14.00\" fill=\"#1f78b4\">⓿</text>\n",
|
|
"</g>\n",
|
|
"<!-- 2->3 -->\n",
|
|
"<g id=\"edge7\" class=\"edge\"><title>2->3</title>\n",
|
|
"<path fill=\"none\" stroke=\"black\" d=\"M231.092,-66.5202C237.345,-60.9508 245.449,-54.9814 254,-52 269.38,-46.6377 287.754,-46.4746 302.091,-47.6074\"/>\n",
|
|
"<polygon fill=\"black\" stroke=\"black\" points=\"309.184,-48.2973 301.912,-50.7547 305.7,-47.9584 302.217,-47.6195 302.217,-47.6195 302.217,-47.6195 305.7,-47.9584 302.522,-44.4843 309.184,-48.2973 309.184,-48.2973\"/>\n",
|
|
"<text text-anchor=\"start\" x=\"254\" y=\"-55.8\" font-family=\"Lato\" font-size=\"14.00\">!a & b</text>\n",
|
|
"</g>\n",
|
|
"<!-- 5 -->\n",
|
|
"<g id=\"node7\" class=\"node\"><title>5</title>\n",
|
|
"<ellipse fill=\"#ffffaa\" stroke=\"black\" cx=\"327\" cy=\"-140\" rx=\"18\" ry=\"18\"/>\n",
|
|
"<text text-anchor=\"middle\" x=\"327\" y=\"-136.3\" font-family=\"Lato\" font-size=\"14.00\">5</text>\n",
|
|
"</g>\n",
|
|
"<!-- 2->5 -->\n",
|
|
"<g id=\"edge8\" class=\"edge\"><title>2->5</title>\n",
|
|
"<path fill=\"none\" stroke=\"black\" d=\"M231.561,-91.398C237.925,-97.2386 245.987,-104.003 254,-109 269.382,-118.592 288.25,-126.595 302.812,-132.066\"/>\n",
|
|
"<polygon fill=\"black\" stroke=\"black\" points=\"309.58,-134.544 301.924,-135.095 306.293,-133.341 303.007,-132.137 303.007,-132.137 303.007,-132.137 306.293,-133.341 304.09,-129.179 309.58,-134.544 309.58,-134.544\"/>\n",
|
|
"<text text-anchor=\"start\" x=\"254\" y=\"-130.8\" font-family=\"Lato\" font-size=\"14.00\">!a & b</text>\n",
|
|
"</g>\n",
|
|
"<!-- 3->2 -->\n",
|
|
"<g id=\"edge9\" class=\"edge\"><title>3->2</title>\n",
|
|
"<path fill=\"none\" stroke=\"black\" d=\"M310.663,-59.0732C304.666,-61.9449 297.644,-64.9668 291,-67 275.418,-71.7682 257.324,-74.7739 243.173,-76.5847\"/>\n",
|
|
"<polygon fill=\"black\" stroke=\"black\" points=\"236.167,-77.4257 242.741,-73.4638 239.642,-77.0085 243.117,-76.5914 243.117,-76.5914 243.117,-76.5914 239.642,-77.0085 243.492,-79.7189 236.167,-77.4257 236.167,-77.4257\"/>\n",
|
|
"<text text-anchor=\"start\" x=\"255.5\" y=\"-93.8\" font-family=\"Lato\" font-size=\"14.00\">a & b</text>\n",
|
|
"<text text-anchor=\"start\" x=\"264.5\" y=\"-78.8\" font-family=\"Lato\" font-size=\"14.00\" fill=\"#1f78b4\">⓿</text>\n",
|
|
"</g>\n",
|
|
"<!-- 3->3 -->\n",
|
|
"<g id=\"edge10\" class=\"edge\"><title>3->3</title>\n",
|
|
"<path fill=\"none\" stroke=\"black\" d=\"M317.767,-66.5414C315.169,-76.9087 318.246,-87 327,-87 333.702,-87 337.077,-81.0847 337.124,-73.6591\"/>\n",
|
|
"<polygon fill=\"black\" stroke=\"black\" points=\"336.233,-66.5414 340.229,-73.0955 336.668,-70.0143 337.103,-73.4871 337.103,-73.4871 337.103,-73.4871 336.668,-70.0143 333.977,-73.8788 336.233,-66.5414 336.233,-66.5414\"/>\n",
|
|
"<text text-anchor=\"start\" x=\"308.5\" y=\"-90.8\" font-family=\"Lato\" font-size=\"14.00\">!a & b</text>\n",
|
|
"</g>\n",
|
|
"<!-- 4->4 -->\n",
|
|
"<g id=\"edge11\" class=\"edge\"><title>4->4</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\">⓿</text>\n",
|
|
"</g>\n",
|
|
"<!-- 5->4 -->\n",
|
|
"<g id=\"edge12\" class=\"edge\"><title>5->4</title>\n",
|
|
"<path fill=\"none\" stroke=\"black\" d=\"M339.86,-126.921C358.901,-105.922 396.358,-64.6141 418.163,-40.5684\"/>\n",
|
|
"<polygon fill=\"black\" stroke=\"black\" points=\"423.087,-35.1375 420.719,-42.439 420.736,-37.7303 418.385,-40.3231 418.385,-40.3231 418.385,-40.3231 420.736,-37.7303 416.052,-38.2071 423.087,-35.1375 423.087,-35.1375\"/>\n",
|
|
"<text text-anchor=\"start\" x=\"363\" y=\"-101.8\" font-family=\"Lato\" font-size=\"14.00\">!a & b</text>\n",
|
|
"</g>\n",
|
|
"</g>\n",
|
|
"</svg>\n"
|
|
],
|
|
"text/plain": [
|
|
"<spot.impl.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7fbc9033b090> >"
|
|
]
|
|
},
|
|
"execution_count": 2,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"aut = spot.translate('!a & G(Fa <-> XXb)'); aut"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"Build an accepting run:"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 3,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"Prefix:\n",
|
|
" 0\n",
|
|
" | !a\n",
|
|
" 1\n",
|
|
" | a\n",
|
|
"Cycle:\n",
|
|
" 2\n",
|
|
" | a & b\t{0}"
|
|
]
|
|
},
|
|
"execution_count": 3,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"run = aut.accepting_run(); run"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"Accessing the contents of the run can be done via the `prefix` and `cycle` lists."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 4,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"!a\n",
|
|
"{0}\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"print(spot.bdd_format_formula(aut.get_dict(), run.prefix[0].label))\n",
|
|
"print(run.cycle[0].acc)"
|
|
]
|
|
},
|
|
{
|
|
"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",
|
|
"execution_count": 5,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"!a; a; cycle{a & b}"
|
|
]
|
|
},
|
|
"execution_count": 5,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"word = spot.twa_word(run); word"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"A word can be represented as a collection of signals (one for each atomic proposition). The cycle part is shown twice."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 6,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"image/svg+xml": [
|
|
"<svg height=\"112\" version=\"1.1\" width=\"200\" xmlns=\"http://www.w3.org/2000/svg\">\n",
|
|
"<rect fill=\"#f4f4f4\" height=\"100\" width=\"200\" x=\"0\" y=\"0\"/>\n",
|
|
"<line stroke=\"white\" stroke-width=\"4\" x1=\"100\" x2=\"100\" y1=\"0\" y2=\"100\"/>\n",
|
|
"<line stroke=\"white\" stroke-width=\"4\" x1=\"150\" x2=\"150\" y1=\"0\" y2=\"100\"/>\n",
|
|
"<line stroke=\"white\" stroke-width=\"4\" x1=\"0\" x2=\"200\" y1=\"0\" y2=\"0\"/><text font-size=\"20\" text-anchor=\"start\" x=\"3\" y=\"30\">a</text><line stroke=\"white\" stroke-width=\"1\" x1=\"50\" x2=\"50\" y1=\"0\" y2=\"50\"/><line stroke=\"#ff0000\" stroke-width=\"2\" x1=\"0\" x2=\"50\" y1=\"45\" y2=\"45\"/><line stroke=\"white\" stroke-width=\"1\" x1=\"100\" x2=\"100\" y1=\"0\" y2=\"50\"/><line stroke=\"#ff0000\" stroke-width=\"2\" x1=\"50\" x2=\"50\" y1=\"5\" y2=\"45\"/><line stroke=\"#ff0000\" stroke-width=\"2\" x1=\"50\" x2=\"100\" y1=\"5\" y2=\"5\"/><line stroke=\"white\" stroke-width=\"1\" x1=\"150\" x2=\"150\" y1=\"0\" y2=\"50\"/><line stroke=\"#ff0000\" stroke-width=\"2\" x1=\"100\" x2=\"150\" y1=\"5\" y2=\"5\"/><line stroke=\"white\" stroke-width=\"1\" x1=\"200\" x2=\"200\" y1=\"0\" y2=\"50\"/><line stroke=\"#ff0000\" stroke-width=\"2\" x1=\"150\" x2=\"200\" y1=\"5\" y2=\"5\"/><line stroke=\"white\" stroke-width=\"4\" x1=\"0\" x2=\"200\" y1=\"50\" y2=\"50\"/><text font-size=\"20\" text-anchor=\"start\" x=\"3\" y=\"80\">b</text><line stroke=\"white\" stroke-width=\"1\" x1=\"50\" x2=\"50\" y1=\"50\" y2=\"100\"/><line stroke=\"white\" stroke-width=\"1\" x1=\"100\" x2=\"100\" y1=\"50\" y2=\"100\"/><line stroke=\"white\" stroke-width=\"1\" x1=\"150\" x2=\"150\" y1=\"50\" y2=\"100\"/><line stroke=\"#ff0000\" stroke-width=\"2\" x1=\"100\" x2=\"150\" y1=\"55\" y2=\"55\"/><line stroke=\"white\" stroke-width=\"1\" x1=\"200\" x2=\"200\" y1=\"50\" y2=\"100\"/><line stroke=\"#ff0000\" stroke-width=\"2\" x1=\"150\" x2=\"200\" y1=\"55\" y2=\"55\"/><text font-size=\"10\" text-anchor=\"start\" x=\"0\" y=\"110\">prefix</text><text font-size=\"10\" text-anchor=\"start\" x=\"100\" y=\"110\">cycle</text>\n",
|
|
"<text font-size=\"10\" text-anchor=\"start\" x=\"150\" y=\"110\">cycle</text></svg>"
|
|
],
|
|
"text/plain": [
|
|
"<IPython.core.display.SVG object>"
|
|
]
|
|
},
|
|
"execution_count": 6,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"word.show()"
|
|
]
|
|
},
|
|
{
|
|
"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",
|
|
"execution_count": 7,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"!a\n",
|
|
"a\n",
|
|
"a & b\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"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]))"
|
|
]
|
|
},
|
|
{
|
|
"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",
|
|
"execution_count": 8,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"!a; cycle{a & b}"
|
|
]
|
|
},
|
|
"execution_count": 8,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"word.simplify()\n",
|
|
"word"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"Such a simplified word can be created directly from the automaton:"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 9,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"!a; cycle{a & b}"
|
|
]
|
|
},
|
|
"execution_count": 9,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"aut.accepting_word()"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"Words can be created using the `parse_word` function:"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 10,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"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"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"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}'))"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 11,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"a; a & b; cycle{!a & !b; !a & b}"
|
|
]
|
|
},
|
|
"execution_count": 11,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"# make sure that we can parse a word back after it has been printed\n",
|
|
"w = spot.parse_word(str(spot.parse_word('a;b&a;cycle{!a&!b;!a&b}'))); w"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 12,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"image/svg+xml": [
|
|
"<svg height=\"112\" version=\"1.1\" width=\"300\" xmlns=\"http://www.w3.org/2000/svg\">\n",
|
|
"<rect fill=\"#f4f4f4\" height=\"100\" width=\"300\" x=\"0\" y=\"0\"/>\n",
|
|
"<line stroke=\"white\" stroke-width=\"4\" x1=\"100\" x2=\"100\" y1=\"0\" y2=\"100\"/>\n",
|
|
"<line stroke=\"white\" stroke-width=\"4\" x1=\"200\" x2=\"200\" y1=\"0\" y2=\"100\"/>\n",
|
|
"<line stroke=\"white\" stroke-width=\"4\" x1=\"0\" x2=\"300\" y1=\"0\" y2=\"0\"/><text font-size=\"20\" text-anchor=\"start\" x=\"3\" y=\"30\">a</text><line stroke=\"white\" stroke-width=\"1\" x1=\"50\" x2=\"50\" y1=\"0\" y2=\"50\"/><line stroke=\"#ff0000\" stroke-width=\"2\" x1=\"0\" x2=\"50\" y1=\"5\" y2=\"5\"/><line stroke=\"white\" stroke-width=\"1\" x1=\"100\" x2=\"100\" y1=\"0\" y2=\"50\"/><line stroke=\"#ff0000\" stroke-width=\"2\" x1=\"50\" x2=\"100\" y1=\"5\" y2=\"5\"/><line stroke=\"white\" stroke-width=\"1\" x1=\"150\" x2=\"150\" y1=\"0\" y2=\"50\"/><line stroke=\"#ff0000\" stroke-width=\"2\" x1=\"100\" x2=\"100\" y1=\"5\" y2=\"45\"/><line stroke=\"#ff0000\" stroke-width=\"2\" x1=\"100\" x2=\"150\" y1=\"45\" y2=\"45\"/><line stroke=\"white\" stroke-width=\"1\" x1=\"200\" x2=\"200\" y1=\"0\" y2=\"50\"/><line stroke=\"#ff0000\" stroke-width=\"2\" x1=\"150\" x2=\"200\" y1=\"45\" y2=\"45\"/><line stroke=\"white\" stroke-width=\"1\" x1=\"250\" x2=\"250\" y1=\"0\" y2=\"50\"/><line stroke=\"#ff0000\" stroke-width=\"2\" x1=\"200\" x2=\"250\" y1=\"45\" y2=\"45\"/><line stroke=\"white\" stroke-width=\"1\" x1=\"300\" x2=\"300\" y1=\"0\" y2=\"50\"/><line stroke=\"#ff0000\" stroke-width=\"2\" x1=\"250\" x2=\"300\" y1=\"45\" y2=\"45\"/><line stroke=\"white\" stroke-width=\"4\" x1=\"0\" x2=\"300\" y1=\"50\" y2=\"50\"/><text font-size=\"20\" text-anchor=\"start\" x=\"3\" y=\"80\">b</text><line stroke=\"white\" stroke-width=\"1\" x1=\"50\" x2=\"50\" y1=\"50\" y2=\"100\"/><line stroke=\"white\" stroke-width=\"1\" x1=\"100\" x2=\"100\" y1=\"50\" y2=\"100\"/><line stroke=\"#ff0000\" stroke-width=\"2\" x1=\"50\" x2=\"100\" y1=\"55\" y2=\"55\"/><line stroke=\"white\" stroke-width=\"1\" x1=\"150\" x2=\"150\" y1=\"50\" y2=\"100\"/><line stroke=\"#ff0000\" stroke-width=\"2\" x1=\"100\" x2=\"100\" y1=\"55\" y2=\"95\"/><line stroke=\"#ff0000\" stroke-width=\"2\" x1=\"100\" x2=\"150\" y1=\"95\" y2=\"95\"/><line stroke=\"white\" stroke-width=\"1\" x1=\"200\" x2=\"200\" y1=\"50\" y2=\"100\"/><line stroke=\"#ff0000\" stroke-width=\"2\" x1=\"150\" x2=\"150\" y1=\"55\" y2=\"95\"/><line stroke=\"#ff0000\" stroke-width=\"2\" x1=\"150\" x2=\"200\" y1=\"55\" y2=\"55\"/><line stroke=\"white\" stroke-width=\"1\" x1=\"250\" x2=\"250\" y1=\"50\" y2=\"100\"/><line stroke=\"#ff0000\" stroke-width=\"2\" x1=\"200\" x2=\"200\" y1=\"55\" y2=\"95\"/><line stroke=\"#ff0000\" stroke-width=\"2\" x1=\"200\" x2=\"250\" y1=\"95\" y2=\"95\"/><line stroke=\"white\" stroke-width=\"1\" x1=\"300\" x2=\"300\" y1=\"50\" y2=\"100\"/><line stroke=\"#ff0000\" stroke-width=\"2\" x1=\"250\" x2=\"250\" y1=\"55\" y2=\"95\"/><line stroke=\"#ff0000\" stroke-width=\"2\" x1=\"250\" x2=\"300\" y1=\"55\" y2=\"55\"/><text font-size=\"10\" text-anchor=\"start\" x=\"0\" y=\"110\">prefix</text><text font-size=\"10\" text-anchor=\"start\" x=\"100\" y=\"110\">cycle</text>\n",
|
|
"<text font-size=\"10\" text-anchor=\"start\" x=\"200\" y=\"110\">cycle</text></svg>"
|
|
],
|
|
"text/plain": [
|
|
"<IPython.core.display.SVG object>"
|
|
]
|
|
},
|
|
"execution_count": 12,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"w.show()"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"Words can be easily converted as automata"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 13,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"image/svg+xml": [
|
|
"<?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=\"380pt\" height=\"86pt\"\n",
|
|
" viewBox=\"0.00 0.00 380.00 86.36\" 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 82.3636)\">\n",
|
|
"<title>G</title>\n",
|
|
"<polygon fill=\"white\" stroke=\"none\" points=\"-4,4 -4,-82.3636 376,-82.3636 376,4 -4,4\"/>\n",
|
|
"<text text-anchor=\"start\" x=\"183\" y=\"-63.1636\" font-family=\"Lato\" font-size=\"14.00\">t</text>\n",
|
|
"<text text-anchor=\"start\" x=\"175\" y=\"-48.1636\" font-family=\"Lato\" font-size=\"14.00\">[all]</text>\n",
|
|
"<!-- I -->\n",
|
|
"<!-- 0 -->\n",
|
|
"<g id=\"node2\" class=\"node\"><title>0</title>\n",
|
|
"<ellipse fill=\"#ffffaa\" stroke=\"black\" cx=\"56\" cy=\"-22.3636\" rx=\"18\" ry=\"18\"/>\n",
|
|
"<text text-anchor=\"middle\" x=\"56\" y=\"-18.6636\" 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,-22.3636C2.79388,-22.3636 17.1543,-22.3636 30.6317,-22.3636\"/>\n",
|
|
"<polygon fill=\"black\" stroke=\"black\" points=\"37.9419,-22.3636 30.9419,-25.5137 34.4419,-22.3636 30.9419,-22.3637 30.9419,-22.3637 30.9419,-22.3637 34.4419,-22.3636 30.9418,-19.2137 37.9419,-22.3636 37.9419,-22.3636\"/>\n",
|
|
"</g>\n",
|
|
"<!-- 1 -->\n",
|
|
"<g id=\"node3\" class=\"node\"><title>1</title>\n",
|
|
"<ellipse fill=\"#ffffaa\" stroke=\"black\" cx=\"135\" cy=\"-22.3636\" rx=\"18\" ry=\"18\"/>\n",
|
|
"<text text-anchor=\"middle\" x=\"135\" y=\"-18.6636\" 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,-22.3636C84.5562,-22.3636 98.1196,-22.3636 109.693,-22.3636\"/>\n",
|
|
"<polygon fill=\"black\" stroke=\"black\" points=\"116.959,-22.3636 109.959,-25.5137 113.459,-22.3636 109.959,-22.3637 109.959,-22.3637 109.959,-22.3637 113.459,-22.3636 109.959,-19.2137 116.959,-22.3636 116.959,-22.3636\"/>\n",
|
|
"<text text-anchor=\"start\" x=\"92\" y=\"-26.1636\" 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=\"241\" cy=\"-22.3636\" rx=\"18\" ry=\"18\"/>\n",
|
|
"<text text-anchor=\"middle\" x=\"241\" y=\"-18.6636\" 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.173,-22.3636C170.185,-22.3636 196.399,-22.3636 215.575,-22.3636\"/>\n",
|
|
"<polygon fill=\"black\" stroke=\"black\" points=\"222.801,-22.3636 215.801,-25.5137 219.301,-22.3636 215.801,-22.3637 215.801,-22.3637 215.801,-22.3637 219.301,-22.3636 215.801,-19.2137 222.801,-22.3636 222.801,-22.3636\"/>\n",
|
|
"<text text-anchor=\"start\" x=\"171\" y=\"-26.1636\" font-family=\"Lato\" font-size=\"14.00\">a & b</text>\n",
|
|
"</g>\n",
|
|
"<!-- 3 -->\n",
|
|
"<g id=\"node5\" class=\"node\"><title>3</title>\n",
|
|
"<ellipse fill=\"#ffffaa\" stroke=\"black\" cx=\"354\" cy=\"-22.3636\" rx=\"18\" ry=\"18\"/>\n",
|
|
"<text text-anchor=\"middle\" x=\"354\" y=\"-18.6636\" 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=\"M259.344,-22.3636C277.998,-22.3636 307.797,-22.3636 328.763,-22.3636\"/>\n",
|
|
"<polygon fill=\"black\" stroke=\"black\" points=\"335.778,-22.3636 328.778,-25.5137 332.278,-22.3636 328.778,-22.3637 328.778,-22.3637 328.778,-22.3637 332.278,-22.3636 328.778,-19.2137 335.778,-22.3636 335.778,-22.3636\"/>\n",
|
|
"<text text-anchor=\"start\" x=\"277\" y=\"-26.1636\" font-family=\"Lato\" font-size=\"14.00\">!a & !b</text>\n",
|
|
"</g>\n",
|
|
"<!-- 3->2 -->\n",
|
|
"<g id=\"edge5\" class=\"edge\"><title>3->2</title>\n",
|
|
"<path fill=\"none\" stroke=\"black\" d=\"M338.689,-12.4979C332.598,-8.87012 325.237,-5.20137 318,-3.36359 300.338,1.1212 294.662,1.1212 277,-3.36359 272.137,-4.59835 267.219,-6.65963 262.668,-8.97969\"/>\n",
|
|
"<polygon fill=\"black\" stroke=\"black\" points=\"256.311,-12.4979 260.91,-6.35207 259.374,-10.803 262.436,-9.10812 262.436,-9.10812 262.436,-9.10812 259.374,-10.803 263.961,-11.8642 256.311,-12.4979 256.311,-12.4979\"/>\n",
|
|
"<text text-anchor=\"start\" x=\"279\" y=\"-7.16359\" font-family=\"Lato\" font-size=\"14.00\">!a & b</text>\n",
|
|
"</g>\n",
|
|
"</g>\n",
|
|
"</svg>\n"
|
|
],
|
|
"text/plain": [
|
|
"<spot.impl.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7fbc902577b0> >"
|
|
]
|
|
},
|
|
"execution_count": 13,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"w.as_automaton()"
|
|
]
|
|
}
|
|
],
|
|
"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.6.4+"
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 2
|
|
}
|