diff --git a/NEWS b/NEWS index d3e21ebb2..f86d8aa3d 100644 --- a/NEWS +++ b/NEWS @@ -30,6 +30,11 @@ New in spot 2.5.3.dev (not yet released) "exiting transitions". This can be used to display alternating automata in a way many people expect. + - print_dot() has a new option "K" to cancel the effect of "k" + (which uses state labels whenever possible). This is most useful + when one want to force transition-labeling of a Kripke structure, + where "k" is usually the default. + - cleanup_parity() and cleanup_parity_here() are smarter and now remove from the acceptance condition the parity colors that are not used in the automaton. diff --git a/bin/common_aoutput.cc b/bin/common_aoutput.cc index 1a1eafadb..b844b3d18 100644 --- a/bin/common_aoutput.cc +++ b/bin/common_aoutput.cc @@ -88,7 +88,7 @@ static const argp_option options[] = /**************************************************/ { nullptr, 0, nullptr, 0, "Output format:", 3 }, { "dot", 'd', - "1|a|A|b|B|c|C(COLOR)|e|f(FONT)|h|k|n|N|o|r|R|s|t|u|v|y|+INT|(g)) + // Enable state labels for Kripke structure. + if (std::dynamic_pointer_cast(g) + && !d.uppercase_k_seen()) d.parse_opts("k"); auto aut = std::dynamic_pointer_cast(g); if (!aut || (d.max_states_given() && aut->num_states() >= d.max_states())) diff --git a/tests/python/ipnbdoctest.py b/tests/python/ipnbdoctest.py index 3f3bab32f..dc05fce22 100755 --- a/tests/python/ipnbdoctest.py +++ b/tests/python/ipnbdoctest.py @@ -115,12 +115,16 @@ def canonicalize(s, type, ignores): s = re.sub(r' fill="black"', '', s) s = re.sub(r' stroke="transparent"', ' stroke="none"', s) s = re.sub(r'>', '>\n<title>', s) + # tooltips with a ", " are likely to have \n which was not + # well supported by 2.38. + s = re.sub(r'<a xlink:title=".*?, .*?">\n', '<a xlink:title="...">\n', s, + flags=re.DOTALL) # Different Pandas versions produce different CSS styles (when there is a # style). s = re.sub(r'<style[ a-z]*>.*</style>\n', '', s, flags=re.DOTALL) # Table that contains enc.user are log from the SAT-solver. They contain # timing result we cannot compare between runs. - s = re.sub(r'<table.*dataframe.*enc.user.*</table>', '<table></table>', s, + s = re.sub(r'<table.*dataframe.*?enc.user.*?</table>', '<table></table>', s, flags=re.DOTALL) for n, p in enumerate(ignores): diff --git a/tests/python/ltsmin-pml.ipynb b/tests/python/ltsmin-pml.ipynb index 91d1d87bb..67dba3ed2 100644 --- a/tests/python/ltsmin-pml.ipynb +++ b/tests/python/ltsmin-pml.ipynb @@ -38,8 +38,8 @@ "SpinS Promela Compiler - version 1.1 (3-Feb-2015)\n", "(C) University of Twente, Formal Methods and Tools group\n", "\n", - "Parsing tmpqado0fcz.pml...\n", - "Parsing tmpqado0fcz.pml done (0.0 sec)\n", + "Parsing tmp_kk6cvzf.pml...\n", + "Parsing tmp_kk6cvzf.pml done (0.0 sec)\n", "\n", "Optimizing graphs...\n", " StateMerging changed 0 states/transitions.\n", @@ -225,8 +225,8 @@ " 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/tmpqado0fcz.pml.spins.c\n", - "Compiled C code to PINS library tmpqado0fcz.pml.spins\n", + "Written C code to /home/adl/git/spot/tests/python/tmp_kk6cvzf.pml.spins.c\n", + "Compiled C code to PINS library tmp_kk6cvzf.pml.spins\n", "\n" ] } @@ -560,7 +560,7 @@ "</svg>\n" ], "text/plain": [ - "<spot.impl.kripke; proxy of <Swig Object of type 'std::shared_ptr< spot::kripke > *' at 0x7f0cd1edc630> >" + "<spot.impl.kripke; proxy of <Swig Object of type 'std::shared_ptr< spot::kripke > *' at 0x7fa8d4065b40> >" ] }, "execution_count": 4, @@ -576,8 +576,696 @@ "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", + "And then from this Kripke structure you can do some model checking using the same functions as illustrated in `ltsmin-dve.ipynb`." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "For displaying Kripke structures more compactly, it can be useful to use option `1` to move all state labels in tooltips (mouse over the state to see them):" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "<svg height=\"280pt\" viewBox=\"0.00 0.00 454.79 280.00\" width=\"455pt\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n", + "<g class=\"graph\" id=\"graph0\" transform=\"scale(1 1) rotate(0) translate(4 276)\">\n", + "<polygon fill=\"#ffffff\" points=\"-4,4 -4,-276 450.7924,-276 450.7924,4 -4,4\" stroke=\"transparent\"/>\n", + "<text fill=\"#000000\" font-family=\"Lato\" font-size=\"14.00\" text-anchor=\"start\" x=\"220.3962\" y=\"-256.8\">t</text>\n", + "<text fill=\"#000000\" font-family=\"Lato\" font-size=\"14.00\" text-anchor=\"start\" x=\"212.3962\" y=\"-241.8\">[all]</text>\n", + "<!-- I -->\n", + "<!-- 0 -->\n", + "<g class=\"node\" id=\"node2\">\n", + "<title>0\n", + "\n", + "\n", + "0\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "I->0\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "1\n", + "\n", + "\n", + "1\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "0->1\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "2\n", + "\n", + "\n", + "2\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "0->2\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "3\n", + "\n", + "\n", + "3\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "1->3\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "4\n", + "\n", + "\n", + "4\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "1->4\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "2->4\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "5\n", + "\n", + "\n", + "5\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "2->5\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "6\n", + "\n", + "\n", + "6\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "3->6\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "7\n", + "\n", + "\n", + "7\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "3->7\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "4->7\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "8\n", + "\n", + "\n", + "8\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "4->8\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "5->8\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "9\n", + "\n", + "\n", + "9\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "5->9\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "6->6\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "10\n", + "\n", + "\n", + "10\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "7->10\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "11\n", + "\n", + "\n", + "11\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "7->11\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "8->11\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "12\n", + "\n", + "\n", + "12\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "8->12\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "9->9\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "10->10\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "13\n", + "\n", + "\n", + "13\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "11->13\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "14\n", + "\n", + "\n", + "14\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "11->14\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "12->12\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "13->13\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "14->14\n", + "\n", + "\n", + "\n", + "\n", + "" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "k.show('.1')" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Another option is to use option `K` to disable to state-labeling (that is enabled by default for Kripke structure) and use transition-labeling instead. Combining with `1`, this will preserve the state's data as a tooltip." + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "\n", + "t\n", + "[all]\n", + "\n", + "\n", + "\n", + "0\n", + "\n", + "\n", + "0\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "I->0\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "1\n", + "\n", + "\n", + "1\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "0->1\n", + "\n", + "\n", + ""P_0.a < 2" & !"P_0.b > 1" & !dead\n", + "\n", + "\n", + "\n", + "2\n", + "\n", + "\n", + "2\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "0->2\n", + "\n", + "\n", + ""P_0.a < 2" & !"P_0.b > 1" & !dead\n", + "\n", + "\n", + "\n", + "3\n", + "\n", + "\n", + "3\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "1->3\n", + "\n", + "\n", + ""P_0.a < 2" & !"P_0.b > 1" & !dead\n", + "\n", + "\n", + "\n", + "4\n", + "\n", + "\n", + "4\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "1->4\n", + "\n", + "\n", + ""P_0.a < 2" & !"P_0.b > 1" & !dead\n", + "\n", + "\n", + "\n", + "2->4\n", + "\n", + "\n", + ""P_0.a < 2" & !"P_0.b > 1" & !dead\n", + "\n", + "\n", + "\n", + "5\n", + "\n", + "\n", + "5\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "2->5\n", + "\n", + "\n", + ""P_0.a < 2" & !"P_0.b > 1" & !dead\n", + "\n", + "\n", + "\n", + "6\n", + "\n", + "\n", + "6\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "3->6\n", + "\n", + "\n", + "!"P_0.a < 2" & !"P_0.b > 1" & !dead\n", + "\n", + "\n", + "\n", + "7\n", + "\n", + "\n", + "7\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "3->7\n", + "\n", + "\n", + "!"P_0.a < 2" & !"P_0.b > 1" & !dead\n", + "\n", + "\n", + "\n", + "4->7\n", + "\n", + "\n", + ""P_0.a < 2" & !"P_0.b > 1" & !dead\n", + "\n", + "\n", + "\n", + "8\n", + "\n", + "\n", + "8\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "4->8\n", + "\n", + "\n", + ""P_0.a < 2" & !"P_0.b > 1" & !dead\n", + "\n", + "\n", + "\n", + "5->8\n", + "\n", + "\n", + ""P_0.a < 2" & "P_0.b > 1" & !dead\n", + "\n", + "\n", + "\n", + "9\n", + "\n", + "\n", + "9\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "5->9\n", + "\n", + "\n", + ""P_0.a < 2" & "P_0.b > 1" & !dead\n", + "\n", + "\n", + "\n", + "6->6\n", + "\n", + "\n", + "!"P_0.a < 2" & !"P_0.b > 1" & dead\n", + "\n", + "\n", + "\n", + "10\n", + "\n", + "\n", + "10\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "7->10\n", + "\n", + "\n", + "!"P_0.a < 2" & !"P_0.b > 1" & !dead\n", + "\n", + "\n", + "\n", + "11\n", + "\n", + "\n", + "11\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "7->11\n", + "\n", + "\n", + "!"P_0.a < 2" & !"P_0.b > 1" & !dead\n", + "\n", + "\n", + "\n", + "8->11\n", + "\n", + "\n", + ""P_0.a < 2" & "P_0.b > 1" & !dead\n", + "\n", + "\n", + "\n", + "12\n", + "\n", + "\n", + "12\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "8->12\n", + "\n", + "\n", + ""P_0.a < 2" & "P_0.b > 1" & !dead\n", + "\n", + "\n", + "\n", + "9->9\n", + "\n", + "\n", + ""P_0.a < 2" & "P_0.b > 1" & dead\n", + "\n", + "\n", + "\n", + "10->10\n", + "\n", + "\n", + "!"P_0.a < 2" & !"P_0.b > 1" & dead\n", + "\n", + "\n", + "\n", + "13\n", + "\n", + "\n", + "13\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "11->13\n", + "\n", + "\n", + "!"P_0.a < 2" & "P_0.b > 1" & !dead\n", + "\n", + "\n", + "\n", + "14\n", + "\n", + "\n", + "14\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "11->14\n", + "\n", + "\n", + "!"P_0.a < 2" & "P_0.b > 1" & !dead\n", + "\n", + "\n", + "\n", + "12->12\n", + "\n", + "\n", + ""P_0.a < 2" & "P_0.b > 1" & dead\n", + "\n", + "\n", + "\n", + "13->13\n", + "\n", + "\n", + "!"P_0.a < 2" & "P_0.b > 1" & dead\n", + "\n", + "\n", + "\n", + "14->14\n", + "\n", + "\n", + "!"P_0.a < 2" & "P_0.b > 1" & dead\n", + "\n", + "\n", + "" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "k.show('.1K')" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ "Loading from a `*.pml` file\n", "---------------------------\n", "\n", @@ -586,7 +1274,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 7, "metadata": {}, "outputs": [], "source": [ @@ -595,7 +1283,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 8, "metadata": {}, "outputs": [ { @@ -627,7 +1315,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 9, "metadata": {}, "outputs": [], "source": [ @@ -636,7 +1324,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 10, "metadata": {}, "outputs": [ { @@ -648,7 +1336,7 @@ " P_0.b: int" ] }, - "execution_count": 8, + "execution_count": 10, "metadata": {}, "output_type": "execute_result" } @@ -659,7 +1347,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 11, "metadata": {}, "outputs": [], "source": [