spot/tests/python/ltsmin-pml.ipynb
Alexandre Duret-Lutz ed04e2b421 adjust tests to SpinS 1.1
* tests/python/ipnbdoctest.py: Adjust sanitize function.
* tests/python/ltsmin-pml.ipynb: Adjust expected output.
2016-06-22 21:26:35 +02:00

669 lines
No EOL
39 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.1"
},
"name": "",
"signature": "sha256:07d2378b77f0b3c281fb9907deb011c1716ab64dab3726379c60ae42d5f4dd80"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"cell_type": "code",
"collapsed": false,
"input": [
"import spot\n",
"import spot.ltsmin\n",
"# The following line causes the notebook to exit with 77 if spins is not \n",
"# installed, therefore skipping this test in the test suite.\n",
"spot.ltsmin.require('spins')\n",
"spot.setup()"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 1
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"There are two ways to load a Promela model: from a file or from a cell. \n",
"\n",
"Loading from a cell\n",
"-------------------\n",
"\n",
"Using the `%%pml` magic will save the model in a temporary file, call `spins` to compile it, load the resulting shared library, and store the result into an object whose name is passed as an argument to `%%pml`."
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"%%pml model\n",
"active proctype P() {\n",
"int a = 0;\n",
"int b = 0;\n",
"x: if\n",
" :: d_step {a < 3 && b < 3; a = a + 1; } goto x;\n",
" :: d_step {a < 3 && b < 3; b = b + 1; } goto x;\n",
"fi;\n",
"}"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stderr",
"text": [
"SpinS Promela Compiler - version 1.1 (3-Feb-2015)\n",
"(C) University of Twente, Formal Methods and Tools group\n",
"\n",
"Parsing tmpmmk02hmw.pml...\n",
"Parsing tmpmmk02hmw.pml done (0.0 sec)\n",
"\n",
"Optimizing graphs...\n",
" StateMerging changed 0 states/transitions.\n",
" RemoveUselessActions changed 2 states/transitions.\n",
" RemoveUselessGotos changed 2 states/transitions.\n",
" RenumberAll changed 1 states/transitions.\n",
"Optimization done (0.0 sec)\n",
"\n",
"Generating next-state function ...\n",
" Instantiating processes\n",
" Statically binding references\n",
" Creating transitions\n",
"Generating next-state function done (0.0 sec)\n",
"\n",
"Creating state vector\n",
"Creating state labels\n",
"Generating transitions/state dependency matrices (2 / 3 slots) ... \n",
"\n",
" [.......... ]\n",
" [.................... ]\n",
" [.............................. ]\n",
" [........................................ ]\n",
" [..................................................]\n",
" Found 5 / 15 ( 33.3%) Guard/slot reads \n",
"\n",
" [......................... ]\n",
" [..................................................]\n",
" Found 6 / 6 (100.0%) Transition/slot tests \n",
"\n",
" [........ ]\n",
" [................ ]\n",
" [......................... ]\n",
" [................................. ]\n",
" [......................................... ]\n",
" [..................................................]\n",
" Found 2, 4, 4 / 18 ( 11.1%, 22.2%, 22.2%) Actions/slot r,W,w \n",
"\n",
" [......................... ]\n",
" [..................................................]\n",
" Found 2, 4, 4 / 6 ( 33.3%, 66.7%, 66.7%) Atomics/slot r,W,w \n",
"\n",
" [......................... ]\n",
" [..................................................]\n",
" Found 6, 4, 4 / 6 (100.0%, 66.7%, 66.7%) Transition/slot r,W,w \n",
"Generating transition/state dependency matrices done (0.0 sec)\n",
"\n",
"Generating guard dependency matrices (5 guards) ...\n",
"\n",
" [.... ]\n",
" [........ ]\n",
" [............ ]\n",
" [................ ]\n",
" [.................... ]\n",
" [......................... ]\n",
" [............................. ]\n",
" [................................. ]\n",
" [..................................... ]\n",
" [......................................... ]\n",
" Found 3 / 12 ( 25.0%) Guard/guard dependencies \n",
"\n",
" [..... ]\n",
" [.......... ]\n",
" [............... ]\n",
" [.................... ]\n",
" [......................... ]\n",
" [.............................. ]\n",
" [................................... ]\n",
" [........................................ ]\n",
" [............................................. ]\n",
" [..................................................]\n",
" Found 8 / 10 ( 80.0%) Transition/guard writes \n",
"\n",
" Found 4 / 4 (100.0%) Transition/transition writes \n",
"\n",
" [.... ]\n",
" [........ ]\n",
" [............ ]\n",
" [................ ]\n",
" [.................... ]\n",
" [......................... ]\n",
" [............................. ]\n",
" [................................. ]\n",
" [..................................... ]\n",
" [......................................... ]\n",
" Found 2 / 12 ( 16.7%) !MCE guards \n",
"\n",
" [......................... ]\n",
" Found 1 / 2 ( 50.0%) !MCE transitions \n",
"\n",
" [.. ]\n",
" [.... ]\n",
" [...... ]\n",
" [........ ]\n",
" [.......... ]\n",
" [............ ]\n",
" [.............. ]\n",
" [................ ]\n",
" [.................. ]\n",
" [.................... ]\n",
" [...................... ]\n",
" [........................ ]\n",
" [.......................... ]\n",
" [............................ ]\n",
" [.............................. ]\n",
" [................................ ]\n",
" [.................................. ]\n",
" [.................................... ]\n",
" [...................................... ]\n",
" [........................................ ]\n",
" [.......................................... ]\n",
" [............................................ ]\n",
" [.............................................. ]\n",
" [................................................ ]\n",
" [..................................................]\n",
" Found 7 / 25 ( 28.0%) !ICE guards \n",
"\n",
" [..... ]\n",
" [.......... ]\n",
" [............... ]\n",
" [.................... ]\n",
" [......................... ]\n",
" [.............................. ]\n",
" [................................... ]\n",
" [........................................ ]\n",
" [............................................. ]\n",
" [..................................................]\n",
" Found 10 / 10 (100.0%) !NES guards \n",
"\n",
" [............ ]\n",
" [......................... ]\n",
" [..................................... ]\n",
" [..................................................]\n",
" Found 4 / 4 (100.0%) !NES transitions \n",
"\n",
" [..... ]\n",
" [.......... ]\n",
" [............... ]\n",
" [.................... ]\n",
" [......................... ]\n",
" [.............................. ]\n",
" [................................... ]\n",
" [........................................ ]\n",
" [............................................. ]\n",
" [..................................................]\n",
" Found 8 / 10 ( 80.0%) !NDS guards \n",
"\n",
" [..... ]\n",
" [.......... ]\n",
" [............... ]\n",
" [.................... ]\n",
" [......................... ]\n",
" [.............................. ]\n",
" [................................... ]\n",
" [........................................ ]\n",
" [............................................. ]\n",
" [..................................................]\n",
" Found 0 / 10 ( 0.0%) MDS guards \n",
"\n",
" [..... ]\n",
" [.......... ]\n",
" [............... ]\n",
" [.................... ]\n",
" [......................... ]\n",
" [.............................. ]\n",
" [................................... ]\n",
" [........................................ ]\n",
" [............................................. ]\n",
" [..................................................]\n",
" Found 4 / 10 ( 40.0%) MES guards \n",
"\n",
" [............ ]\n",
" [......................... ]\n",
" [..................................... ]\n",
" [..................................................]\n",
" Found 0 / 4 ( 0.0%) !NDS transitions \n",
"\n",
" [......................... ]\n",
" Found 0 / 2 ( 0.0%) !DNA transitions \n",
"\n",
" [......................... ]\n",
" [..................................................]\n",
" [..................................................]\n",
" Found 2 / 2 (100.0%) Commuting actions \n",
"Generating guard dependency matrices done (0.0 sec)\n",
"\n",
"Written C code to /home/adl/git/spot/tests/python/tmpmmk02hmw.pml.spins.c\n",
"Compiled C code to PINS library tmpmmk02hmw.pml.spins\n",
"\n"
]
}
],
"prompt_number": 2
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Yes, the `spins` compiler is quite verbose. Printing the resulting `model` object will show information about the variables in that model. "
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"model"
],
"language": "python",
"metadata": {},
"outputs": [
{
"metadata": {},
"output_type": "pyout",
"prompt_number": 3,
"text": [
"ltsmin model with the following variables:\n",
" P_0._pc: pc\n",
" P_0.a: int\n",
" P_0.b: int"
]
}
],
"prompt_number": 3
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"To instantiate a Kripke structure, one should provide a list of atomic proposition to observe."
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"k = model.kripke(['P_0.a < 2', 'P_0.b > 1']); k"
],
"language": "python",
"metadata": {},
"outputs": [
{
"metadata": {},
"output_type": "pyout",
"prompt_number": 4,
"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=\"734pt\" height=\"107pt\"\n",
" viewBox=\"0.00 0.00 734.00 106.70\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
"<g id=\"graph0\" class=\"graph\" transform=\"scale(0.340094 0.340094) rotate(0) translate(4 309.74)\">\n",
"<title>G</title>\n",
"<polygon fill=\"white\" stroke=\"none\" points=\"-4,4 -4,-309.74 2154.23,-309.74 2154.23,4 -4,4\"/>\n",
"<!-- I -->\n",
"<!-- 0 -->\n",
"<g id=\"node2\" class=\"node\"><title>0</title>\n",
"<ellipse fill=\"#ffffaa\" stroke=\"black\" cx=\"197.513\" cy=\"-152.87\" rx=\"160.526\" ry=\"26.7407\"/>\n",
"<text text-anchor=\"middle\" x=\"197.513\" y=\"-156.67\" font-family=\"Lato\" font-size=\"14.00\">P_0._pc=0, P_0.a=0, P_0.b=0</text>\n",
"<text text-anchor=\"middle\" x=\"197.513\" y=\"-141.67\" font-family=\"Lato\" font-size=\"14.00\">&quot;P_0.a &lt; 2&quot; &amp; !&quot;P_0.b &gt; 1&quot; &amp; !dead</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.14171,-152.87C2.49749,-152.87 13.4781,-152.87 29.6043,-152.87\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"36.8175,-152.87 29.8175,-156.02 33.3175,-152.87 29.8175,-152.87 29.8175,-152.87 29.8175,-152.87 33.3175,-152.87 29.8174,-149.72 36.8175,-152.87 36.8175,-152.87\"/>\n",
"</g>\n",
"<!-- 1 -->\n",
"<g id=\"node3\" class=\"node\"><title>1</title>\n",
"<ellipse fill=\"#ffffaa\" stroke=\"black\" cx=\"554.54\" cy=\"-188.87\" rx=\"160.526\" ry=\"26.7407\"/>\n",
"<text text-anchor=\"middle\" x=\"554.54\" y=\"-192.67\" font-family=\"Lato\" font-size=\"14.00\">P_0._pc=0, P_0.a=1, P_0.b=0</text>\n",
"<text text-anchor=\"middle\" x=\"554.54\" y=\"-177.67\" font-family=\"Lato\" font-size=\"14.00\">&quot;P_0.a &lt; 2&quot; &amp; !&quot;P_0.b &gt; 1&quot; &amp; !dead</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=\"M335.268,-166.737C359.625,-169.207 385.064,-171.786 409.613,-174.276\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"416.855,-175.01 409.573,-177.438 413.373,-174.657 409.891,-174.304 409.891,-174.304 409.891,-174.304 413.373,-174.657 410.209,-171.17 416.855,-175.01 416.855,-175.01\"/>\n",
"</g>\n",
"<!-- 2 -->\n",
"<g id=\"node4\" class=\"node\"><title>2</title>\n",
"<ellipse fill=\"#ffffaa\" stroke=\"black\" cx=\"554.54\" cy=\"-116.87\" rx=\"160.526\" ry=\"26.7407\"/>\n",
"<text text-anchor=\"middle\" x=\"554.54\" y=\"-120.67\" font-family=\"Lato\" font-size=\"14.00\">P_0._pc=0, P_0.a=0, P_0.b=1</text>\n",
"<text text-anchor=\"middle\" x=\"554.54\" y=\"-105.67\" font-family=\"Lato\" font-size=\"14.00\">&quot;P_0.a &lt; 2&quot; &amp; !&quot;P_0.b &gt; 1&quot; &amp; !dead</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=\"M335.268,-139.003C359.625,-136.533 385.064,-133.954 409.613,-131.464\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"416.855,-130.73 410.209,-134.57 413.373,-131.083 409.891,-131.436 409.891,-131.436 409.891,-131.436 413.373,-131.083 409.573,-128.302 416.855,-130.73 416.855,-130.73\"/>\n",
"</g>\n",
"<!-- 3 -->\n",
"<g id=\"node5\" class=\"node\"><title>3</title>\n",
"<ellipse fill=\"#ffffaa\" stroke=\"black\" cx=\"914.395\" cy=\"-224.87\" rx=\"163.183\" ry=\"26.7407\"/>\n",
"<text text-anchor=\"middle\" x=\"914.395\" y=\"-228.67\" font-family=\"Lato\" font-size=\"14.00\">P_0._pc=0, P_0.a=2, P_0.b=0</text>\n",
"<text text-anchor=\"middle\" x=\"914.395\" y=\"-213.67\" font-family=\"Lato\" font-size=\"14.00\">!&quot;P_0.a &lt; 2&quot; &amp; !&quot;P_0.b &gt; 1&quot; &amp; !dead</text>\n",
"</g>\n",
"<!-- 1&#45;&gt;3 -->\n",
"<g id=\"edge4\" class=\"edge\"><title>1&#45;&gt;3</title>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M692.617,-202.66C717.222,-205.135 742.946,-207.723 767.783,-210.222\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"774.763,-210.924 767.483,-213.357 771.28,-210.573 767.798,-210.223 767.798,-210.223 767.798,-210.223 771.28,-210.573 768.113,-207.089 774.763,-210.924 774.763,-210.924\"/>\n",
"</g>\n",
"<!-- 4 -->\n",
"<g id=\"node6\" class=\"node\"><title>4</title>\n",
"<ellipse fill=\"#ffffaa\" stroke=\"black\" cx=\"914.395\" cy=\"-152.87\" rx=\"160.526\" ry=\"26.7407\"/>\n",
"<text text-anchor=\"middle\" x=\"914.395\" y=\"-156.67\" font-family=\"Lato\" font-size=\"14.00\">P_0._pc=0, P_0.a=1, P_0.b=1</text>\n",
"<text text-anchor=\"middle\" x=\"914.395\" y=\"-141.67\" font-family=\"Lato\" font-size=\"14.00\">&quot;P_0.a &lt; 2&quot; &amp; !&quot;P_0.b &gt; 1&quot; &amp; !dead</text>\n",
"</g>\n",
"<!-- 1&#45;&gt;4 -->\n",
"<g id=\"edge5\" class=\"edge\"><title>1&#45;&gt;4</title>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M692.617,-175.08C717.763,-172.55 744.078,-169.903 769.419,-167.354\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"776.539,-166.638 769.89,-170.473 773.057,-166.988 769.574,-167.338 769.574,-167.338 769.574,-167.338 773.057,-166.988 769.259,-164.204 776.539,-166.638 776.539,-166.638\"/>\n",
"</g>\n",
"<!-- 2&#45;&gt;4 -->\n",
"<g id=\"edge6\" class=\"edge\"><title>2&#45;&gt;4</title>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M692.617,-130.66C717.763,-133.19 744.078,-135.837 769.419,-138.386\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"776.539,-139.102 769.259,-141.536 773.057,-138.752 769.574,-138.402 769.574,-138.402 769.574,-138.402 773.057,-138.752 769.89,-135.268 776.539,-139.102 776.539,-139.102\"/>\n",
"</g>\n",
"<!-- 5 -->\n",
"<g id=\"node7\" class=\"node\"><title>5</title>\n",
"<ellipse fill=\"#ffffaa\" stroke=\"black\" cx=\"914.395\" cy=\"-80.8701\" rx=\"158.284\" ry=\"26.7407\"/>\n",
"<text text-anchor=\"middle\" x=\"914.395\" y=\"-84.6701\" font-family=\"Lato\" font-size=\"14.00\">P_0._pc=0, P_0.a=0, P_0.b=2</text>\n",
"<text text-anchor=\"middle\" x=\"914.395\" y=\"-69.6701\" font-family=\"Lato\" font-size=\"14.00\">&quot;P_0.a &lt; 2&quot; &amp; &quot;P_0.b &gt; 1&quot; &amp; !dead</text>\n",
"</g>\n",
"<!-- 2&#45;&gt;5 -->\n",
"<g id=\"edge7\" class=\"edge\"><title>2&#45;&gt;5</title>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M692.617,-103.08C718.124,-100.514 744.832,-97.8273 770.508,-95.2443\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"777.721,-94.5187 771.072,-98.3537 774.239,-94.8691 770.756,-95.2195 770.756,-95.2195 770.756,-95.2195 774.239,-94.8691 770.441,-92.0853 777.721,-94.5187 777.721,-94.5187\"/>\n",
"</g>\n",
"<!-- 6 -->\n",
"<g id=\"node8\" class=\"node\"><title>6</title>\n",
"<ellipse fill=\"#ffffaa\" stroke=\"black\" cx=\"1277.08\" cy=\"-260.87\" rx=\"160.526\" ry=\"26.7407\"/>\n",
"<text text-anchor=\"middle\" x=\"1277.08\" y=\"-264.67\" font-family=\"Lato\" font-size=\"14.00\">P_0._pc=0, P_0.a=3, P_0.b=0</text>\n",
"<text text-anchor=\"middle\" x=\"1277.08\" y=\"-249.67\" font-family=\"Lato\" font-size=\"14.00\">!&quot;P_0.a &lt; 2&quot; &amp; !&quot;P_0.b &gt; 1&quot; &amp; dead</text>\n",
"</g>\n",
"<!-- 3&#45;&gt;6 -->\n",
"<g id=\"edge8\" class=\"edge\"><title>3&#45;&gt;6</title>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M1054.33,-238.737C1079.63,-241.263 1106.09,-243.903 1131.55,-246.445\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"1138.7,-247.159 1131.42,-249.598 1135.22,-246.811 1131.74,-246.463 1131.74,-246.463 1131.74,-246.463 1135.22,-246.811 1132.05,-243.329 1138.7,-247.159 1138.7,-247.159\"/>\n",
"</g>\n",
"<!-- 7 -->\n",
"<g id=\"node9\" class=\"node\"><title>7</title>\n",
"<ellipse fill=\"#ffffaa\" stroke=\"black\" cx=\"1277.08\" cy=\"-188.87\" rx=\"163.183\" ry=\"26.7407\"/>\n",
"<text text-anchor=\"middle\" x=\"1277.08\" y=\"-192.67\" font-family=\"Lato\" font-size=\"14.00\">P_0._pc=0, P_0.a=2, P_0.b=1</text>\n",
"<text text-anchor=\"middle\" x=\"1277.08\" y=\"-177.67\" font-family=\"Lato\" font-size=\"14.00\">!&quot;P_0.a &lt; 2&quot; &amp; !&quot;P_0.b &gt; 1&quot; &amp; !dead</text>\n",
"</g>\n",
"<!-- 3&#45;&gt;7 -->\n",
"<g id=\"edge9\" class=\"edge\"><title>3&#45;&gt;7</title>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M1054.33,-211.003C1079.09,-208.532 1104.95,-205.95 1129.91,-203.46\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"1136.92,-202.76 1130.27,-206.589 1133.44,-203.107 1129.95,-203.455 1129.95,-203.455 1129.95,-203.455 1133.44,-203.107 1129.64,-200.321 1136.92,-202.76 1136.92,-202.76\"/>\n",
"</g>\n",
"<!-- 4&#45;&gt;7 -->\n",
"<g id=\"edge10\" class=\"edge\"><title>4&#45;&gt;7</title>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M1052.53,-166.557C1077.83,-169.083 1104.35,-171.729 1129.91,-174.281\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"1137.09,-174.998 1129.81,-177.437 1133.61,-174.65 1130.13,-174.302 1130.13,-174.302 1130.13,-174.302 1133.61,-174.65 1130.44,-171.168 1137.09,-174.998 1137.09,-174.998\"/>\n",
"</g>\n",
"<!-- 8 -->\n",
"<g id=\"node10\" class=\"node\"><title>8</title>\n",
"<ellipse fill=\"#ffffaa\" stroke=\"black\" cx=\"1277.08\" cy=\"-116.87\" rx=\"158.284\" ry=\"26.7407\"/>\n",
"<text text-anchor=\"middle\" x=\"1277.08\" y=\"-120.67\" font-family=\"Lato\" font-size=\"14.00\">P_0._pc=0, P_0.a=1, P_0.b=2</text>\n",
"<text text-anchor=\"middle\" x=\"1277.08\" y=\"-105.67\" font-family=\"Lato\" font-size=\"14.00\">&quot;P_0.a &lt; 2&quot; &amp; &quot;P_0.b &gt; 1&quot; &amp; !dead</text>\n",
"</g>\n",
"<!-- 4&#45;&gt;8 -->\n",
"<g id=\"edge11\" class=\"edge\"><title>4&#45;&gt;8</title>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M1052.53,-139.183C1078.85,-136.555 1106.49,-133.797 1133,-131.151\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"1140.08,-130.444 1133.43,-134.274 1136.6,-130.792 1133.12,-131.139 1133.12,-131.139 1133.12,-131.139 1136.6,-130.792 1132.8,-128.005 1140.08,-130.444 1140.08,-130.444\"/>\n",
"</g>\n",
"<!-- 5&#45;&gt;8 -->\n",
"<g id=\"edge12\" class=\"edge\"><title>5&#45;&gt;8</title>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M1051.24,-94.4288C1077.91,-97.091 1105.97,-99.8913 1132.87,-102.577\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"1140.06,-103.294 1132.78,-105.733 1136.57,-102.946 1133.09,-102.598 1133.09,-102.598 1133.09,-102.598 1136.57,-102.946 1133.4,-99.4639 1140.06,-103.294 1140.06,-103.294\"/>\n",
"</g>\n",
"<!-- 9 -->\n",
"<g id=\"node11\" class=\"node\"><title>9</title>\n",
"<ellipse fill=\"#ffffaa\" stroke=\"black\" cx=\"1277.08\" cy=\"-26.8701\" rx=\"155.627\" ry=\"26.7407\"/>\n",
"<text text-anchor=\"middle\" x=\"1277.08\" y=\"-30.6701\" font-family=\"Lato\" font-size=\"14.00\">P_0._pc=0, P_0.a=0, P_0.b=3</text>\n",
"<text text-anchor=\"middle\" x=\"1277.08\" y=\"-15.6701\" font-family=\"Lato\" font-size=\"14.00\">&quot;P_0.a &lt; 2&quot; &amp; &quot;P_0.b &gt; 1&quot; &amp; dead</text>\n",
"</g>\n",
"<!-- 5&#45;&gt;9 -->\n",
"<g id=\"edge13\" class=\"edge\"><title>5&#45;&gt;9</title>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M1033.75,-63.1511C1071.64,-57.4773 1113.7,-51.1809 1151.99,-45.4477\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"1159.1,-44.384 1152.64,-48.5358 1155.64,-44.9022 1152.17,-45.4205 1152.17,-45.4205 1152.17,-45.4205 1155.64,-44.9022 1151.71,-42.3052 1159.1,-44.384 1159.1,-44.384\"/>\n",
"</g>\n",
"<!-- 6&#45;&gt;6 -->\n",
"<g id=\"edge14\" class=\"edge\"><title>6&#45;&gt;6</title>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M1210.76,-285.787C1205.33,-296.536 1227.43,-305.74 1277.08,-305.74 1315.09,-305.74 1336.95,-300.345 1342.68,-292.992\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"1343.4,-285.787 1345.84,-293.065 1343.05,-289.269 1342.7,-292.752 1342.7,-292.752 1342.7,-292.752 1343.05,-289.269 1339.57,-292.439 1343.4,-285.787 1343.4,-285.787\"/>\n",
"</g>\n",
"<!-- 10 -->\n",
"<g id=\"node12\" class=\"node\"><title>10</title>\n",
"<ellipse fill=\"#ffffaa\" stroke=\"black\" cx=\"1636.93\" cy=\"-224.87\" rx=\"160.526\" ry=\"26.7407\"/>\n",
"<text text-anchor=\"middle\" x=\"1636.93\" y=\"-228.67\" font-family=\"Lato\" font-size=\"14.00\">P_0._pc=0, P_0.a=3, P_0.b=1</text>\n",
"<text text-anchor=\"middle\" x=\"1636.93\" y=\"-213.67\" font-family=\"Lato\" font-size=\"14.00\">!&quot;P_0.a &lt; 2&quot; &amp; !&quot;P_0.b &gt; 1&quot; &amp; dead</text>\n",
"</g>\n",
"<!-- 7&#45;&gt;10 -->\n",
"<g id=\"edge15\" class=\"edge\"><title>7&#45;&gt;10</title>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M1416.95,-202.84C1441.44,-205.305 1467,-207.875 1491.64,-210.354\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"1498.91,-211.086 1491.63,-213.519 1495.43,-210.735 1491.94,-210.385 1491.94,-210.385 1491.94,-210.385 1495.43,-210.735 1492.26,-207.251 1498.91,-211.086 1498.91,-211.086\"/>\n",
"</g>\n",
"<!-- 11 -->\n",
"<g id=\"node13\" class=\"node\"><title>11</title>\n",
"<ellipse fill=\"#ffffaa\" stroke=\"black\" cx=\"1636.93\" cy=\"-152.87\" rx=\"160.526\" ry=\"26.7407\"/>\n",
"<text text-anchor=\"middle\" x=\"1636.93\" y=\"-156.67\" font-family=\"Lato\" font-size=\"14.00\">P_0._pc=0, P_0.a=2, P_0.b=2</text>\n",
"<text text-anchor=\"middle\" x=\"1636.93\" y=\"-141.67\" font-family=\"Lato\" font-size=\"14.00\">!&quot;P_0.a &lt; 2&quot; &amp; &quot;P_0.b &gt; 1&quot; &amp; !dead</text>\n",
"</g>\n",
"<!-- 7&#45;&gt;11 -->\n",
"<g id=\"edge16\" class=\"edge\"><title>7&#45;&gt;11</title>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M1416.95,-174.9C1441.44,-172.436 1467,-169.865 1491.64,-167.386\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"1498.91,-166.655 1492.26,-170.49 1495.43,-167.005 1491.94,-167.355 1491.94,-167.355 1491.94,-167.355 1495.43,-167.005 1491.63,-164.221 1498.91,-166.655 1498.91,-166.655\"/>\n",
"</g>\n",
"<!-- 8&#45;&gt;11 -->\n",
"<g id=\"edge17\" class=\"edge\"><title>8&#45;&gt;11</title>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M1413.62,-130.506C1439.12,-133.071 1465.87,-135.761 1491.62,-138.352\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"1498.85,-139.08 1491.57,-141.513 1495.37,-138.73 1491.89,-138.379 1491.89,-138.379 1491.89,-138.379 1495.37,-138.73 1492.2,-135.245 1498.85,-139.08 1498.85,-139.08\"/>\n",
"</g>\n",
"<!-- 12 -->\n",
"<g id=\"node14\" class=\"node\"><title>12</title>\n",
"<ellipse fill=\"#ffffaa\" stroke=\"black\" cx=\"1636.93\" cy=\"-62.8701\" rx=\"155.627\" ry=\"26.7407\"/>\n",
"<text text-anchor=\"middle\" x=\"1636.93\" y=\"-66.6701\" font-family=\"Lato\" font-size=\"14.00\">P_0._pc=0, P_0.a=1, P_0.b=3</text>\n",
"<text text-anchor=\"middle\" x=\"1636.93\" y=\"-51.6701\" font-family=\"Lato\" font-size=\"14.00\">&quot;P_0.a &lt; 2&quot; &amp; &quot;P_0.b &gt; 1&quot; &amp; dead</text>\n",
"</g>\n",
"<!-- 8&#45;&gt;12 -->\n",
"<g id=\"edge18\" class=\"edge\"><title>8&#45;&gt;12</title>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M1396.24,-99.0388C1433.43,-93.4282 1474.58,-87.2182 1512.14,-81.5503\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"1519.11,-80.4985 1512.66,-84.6578 1515.65,-81.0208 1512.19,-81.5431 1512.19,-81.5431 1512.19,-81.5431 1515.65,-81.0208 1511.72,-78.4284 1519.11,-80.4985 1519.11,-80.4985\"/>\n",
"</g>\n",
"<!-- 9&#45;&gt;9 -->\n",
"<g id=\"edge19\" class=\"edge\"><title>9&#45;&gt;9</title>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M1211,-51.3317C1204.71,-62.2753 1226.73,-71.7401 1277.08,-71.7401 1315.62,-71.7401 1337.57,-66.192 1342.91,-58.6799\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"1343.15,-51.3317 1346.07,-58.4316 1343.04,-54.8298 1342.92,-58.3279 1342.92,-58.3279 1342.92,-58.3279 1343.04,-54.8298 1339.78,-58.2242 1343.15,-51.3317 1343.15,-51.3317\"/>\n",
"</g>\n",
"<!-- 10&#45;&gt;10 -->\n",
"<g id=\"edge20\" class=\"edge\"><title>10&#45;&gt;10</title>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M1571.35,-249.787C1565.98,-260.536 1587.84,-269.74 1636.93,-269.74 1674.52,-269.74 1696.14,-264.345 1701.8,-256.992\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"1702.51,-249.787 1704.96,-257.063 1702.17,-253.27 1701.83,-256.753 1701.83,-256.753 1701.83,-256.753 1702.17,-253.27 1698.69,-256.443 1702.51,-249.787 1702.51,-249.787\"/>\n",
"</g>\n",
"<!-- 13 -->\n",
"<g id=\"node15\" class=\"node\"><title>13</title>\n",
"<ellipse fill=\"#ffffaa\" stroke=\"black\" cx=\"1991.84\" cy=\"-197.87\" rx=\"158.284\" ry=\"26.7407\"/>\n",
"<text text-anchor=\"middle\" x=\"1991.84\" y=\"-201.67\" font-family=\"Lato\" font-size=\"14.00\">P_0._pc=0, P_0.a=3, P_0.b=2</text>\n",
"<text text-anchor=\"middle\" x=\"1991.84\" y=\"-186.67\" font-family=\"Lato\" font-size=\"14.00\">!&quot;P_0.a &lt; 2&quot; &amp; &quot;P_0.b &gt; 1&quot; &amp; dead</text>\n",
"</g>\n",
"<!-- 11&#45;&gt;13 -->\n",
"<g id=\"edge21\" class=\"edge\"><title>11&#45;&gt;13</title>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M1765.34,-169.116C1795.32,-172.938 1827.34,-177.022 1857.57,-180.876\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"1864.8,-181.799 1857.46,-184.038 1861.33,-181.356 1857.86,-180.913 1857.86,-180.913 1857.86,-180.913 1861.33,-181.356 1858.26,-177.789 1864.8,-181.799 1864.8,-181.799\"/>\n",
"</g>\n",
"<!-- 14 -->\n",
"<g id=\"node16\" class=\"node\"><title>14</title>\n",
"<ellipse fill=\"#ffffaa\" stroke=\"black\" cx=\"1991.84\" cy=\"-107.87\" rx=\"158.284\" ry=\"26.7407\"/>\n",
"<text text-anchor=\"middle\" x=\"1991.84\" y=\"-111.67\" font-family=\"Lato\" font-size=\"14.00\">P_0._pc=0, P_0.a=2, P_0.b=3</text>\n",
"<text text-anchor=\"middle\" x=\"1991.84\" y=\"-96.6701\" font-family=\"Lato\" font-size=\"14.00\">!&quot;P_0.a &lt; 2&quot; &amp; &quot;P_0.b &gt; 1&quot; &amp; dead</text>\n",
"</g>\n",
"<!-- 11&#45;&gt;14 -->\n",
"<g id=\"edge22\" class=\"edge\"><title>11&#45;&gt;14</title>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M1765.34,-136.624C1795.32,-132.802 1827.34,-128.718 1857.57,-124.864\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"1864.8,-123.941 1858.26,-127.952 1861.33,-124.384 1857.86,-124.827 1857.86,-124.827 1857.86,-124.827 1861.33,-124.384 1857.46,-121.702 1864.8,-123.941 1864.8,-123.941\"/>\n",
"</g>\n",
"<!-- 12&#45;&gt;12 -->\n",
"<g id=\"edge23\" class=\"edge\"><title>12&#45;&gt;12</title>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M1571.59,-87.3317C1565.37,-98.2753 1587.15,-107.74 1636.93,-107.74 1675.05,-107.74 1696.75,-102.192 1702.03,-94.6799\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"1702.27,-87.3317 1705.19,-94.4305 1702.16,-90.8298 1702.04,-94.328 1702.04,-94.328 1702.04,-94.328 1702.16,-90.8298 1698.89,-94.2254 1702.27,-87.3317 1702.27,-87.3317\"/>\n",
"</g>\n",
"<!-- 13&#45;&gt;13 -->\n",
"<g id=\"edge24\" class=\"edge\"><title>13&#45;&gt;13</title>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M1926.26,-222.787C1920.89,-233.536 1942.75,-242.74 1991.84,-242.74 2029.42,-242.74 2051.05,-237.345 2056.71,-229.992\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"2057.42,-222.787 2059.87,-230.063 2057.07,-226.27 2056.73,-229.753 2056.73,-229.753 2056.73,-229.753 2057.07,-226.27 2053.6,-229.443 2057.42,-222.787 2057.42,-222.787\"/>\n",
"</g>\n",
"<!-- 14&#45;&gt;14 -->\n",
"<g id=\"edge25\" class=\"edge\"><title>14&#45;&gt;14</title>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M1926.26,-132.787C1920.89,-143.536 1942.75,-152.74 1991.84,-152.74 2029.42,-152.74 2051.05,-147.345 2056.71,-139.992\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"2057.42,-132.787 2059.87,-140.063 2057.07,-136.27 2056.73,-139.753 2056.73,-139.753 2056.73,-139.753 2057.07,-136.27 2053.6,-139.443 2057.42,-132.787 2057.42,-132.787\"/>\n",
"</g>\n",
"</g>\n",
"</svg>\n"
],
"text": [
"<spot.impl.kripke; proxy of <Swig Object of type 'std::shared_ptr< spot::kripke > *' at 0x7fe0808e0240> >"
]
}
],
"prompt_number": 4
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"And then from this Kripke structure you can do some model checking using the same functions as illustrated in `ltsmin-dve.ipynb`.\n",
"\n",
"Loading from a `*.pml` file\n",
"---------------------------\n",
"\n",
"Another option is to use `ltsmin.load()` to load a Promela file directly. In order for this test-case to be self-contained, we are going to write the Promela file first, but in practice you probably already have your model."
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"!rm -rf test1.pml"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 5
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"%%file test1.pml\n",
"active proctype P() {\n",
"int a = 0;\n",
"int b = 0;\n",
"x: if\n",
" :: d_step {a < 3 && b < 3; a = a + 1; } goto x;\n",
" :: d_step {a < 3 && b < 3; b = b + 1; } goto x;\n",
"fi;\n",
"}"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"Writing test1.pml\n"
]
}
],
"prompt_number": 6
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Now load it:"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"model2 = spot.ltsmin.load('test1.pml')"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 7
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"model2"
],
"language": "python",
"metadata": {},
"outputs": [
{
"metadata": {},
"output_type": "pyout",
"prompt_number": 8,
"text": [
"ltsmin model with the following variables:\n",
" P_0._pc: pc\n",
" P_0.a: int\n",
" P_0.b: int"
]
}
],
"prompt_number": 8
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"!rm -f test1.pml test1.pml.spins.c test1.pml.spins"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 9
}
],
"metadata": {}
}
]
}