synthesis: fix suboptimal colorization after LAR

* spot/twaalgos/synthesis.cc (ltl_to_game): In LAR and LAR_OLD mode,
for max odd and colorize the game after the split, not before.  The
previous code used to colorize twice, and could waste up to 4 colors
in the process.
* tests/core/ltlsynt.test, tests/python/_mealy.ipynb,
tests/python/games.ipynb, tests/python/synthesis.ipynb,
tests/python/synthesis.py: Adjust all test cases to reflect the fact
that the game uses fewer colors.
This commit is contained in:
Alexandre Duret-Lutz 2022-03-17 14:30:05 +01:00
parent c1e6340228
commit 75818fde13
6 changed files with 1820 additions and 1806 deletions

View file

@ -3,6 +3,7 @@
{
"cell_type": "code",
"execution_count": 1,
"id": "8bca10b8",
"metadata": {},
"outputs": [],
"source": [
@ -12,6 +13,7 @@
},
{
"cell_type": "markdown",
"id": "c73e997a",
"metadata": {},
"source": [
"Test the Mealy printer."
@ -20,6 +22,7 @@
{
"cell_type": "code",
"execution_count": 2,
"id": "f8eff7ed",
"metadata": {},
"outputs": [],
"source": [
@ -29,6 +32,7 @@
{
"cell_type": "code",
"execution_count": 3,
"id": "ad3c80bc",
"metadata": {},
"outputs": [
{
@ -49,6 +53,7 @@
{
"cell_type": "code",
"execution_count": 4,
"id": "50130d85",
"metadata": {},
"outputs": [
{
@ -60,82 +65,78 @@
"<!-- Generated by graphviz version 2.43.0 (0)\n",
" -->\n",
"<!-- Pages: 1 -->\n",
"<svg width=\"247pt\" height=\"212pt\"\n",
" viewBox=\"0.00 0.00 247.00 212.07\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
"<svg width=\"212pt\" height=\"212pt\"\n",
" viewBox=\"0.00 0.00 212.00 212.07\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
"<g id=\"graph0\" class=\"graph\" transform=\"scale(1.0 1.0) rotate(0) translate(4 208.07)\">\n",
"<polygon fill=\"white\" stroke=\"transparent\" points=\"-4,4 -4,-208.07 243,-208.07 243,4 -4,4\"/>\n",
"<text text-anchor=\"start\" x=\"8\" y=\"-189.87\" font-family=\"Lato\" font-size=\"14.00\">Inf(</text>\n",
"<text text-anchor=\"start\" x=\"29\" y=\"-189.87\" font-family=\"Lato\" font-size=\"14.00\" fill=\"#6a3d9a\">❸</text>\n",
"<text text-anchor=\"start\" x=\"45\" y=\"-189.87\" font-family=\"Lato\" font-size=\"14.00\">) | (Fin(</text>\n",
"<text text-anchor=\"start\" x=\"87\" y=\"-189.87\" font-family=\"Lato\" font-size=\"14.00\" fill=\"#ff7f00\">❷</text>\n",
"<text text-anchor=\"start\" x=\"103\" y=\"-189.87\" font-family=\"Lato\" font-size=\"14.00\">) &amp; (Inf(</text>\n",
"<text text-anchor=\"start\" x=\"149\" y=\"-189.87\" font-family=\"Lato\" font-size=\"14.00\" fill=\"#ff4da0\">❶</text>\n",
"<text text-anchor=\"start\" x=\"165\" y=\"-189.87\" font-family=\"Lato\" font-size=\"14.00\">) | Fin(</text>\n",
"<text text-anchor=\"start\" x=\"203\" y=\"-189.87\" font-family=\"Lato\" font-size=\"14.00\" fill=\"#1f78b4\">⓿</text>\n",
"<text text-anchor=\"start\" x=\"219\" y=\"-189.87\" font-family=\"Lato\" font-size=\"14.00\">)))</text>\n",
"<text text-anchor=\"start\" x=\"64\" y=\"-175.87\" font-family=\"Lato\" font-size=\"14.00\">[parity max odd 4]</text>\n",
"<polygon fill=\"white\" stroke=\"transparent\" points=\"-4,4 -4,-208.07 208,-208.07 208,4 -4,4\"/>\n",
"<text text-anchor=\"start\" x=\"54.5\" y=\"-189.87\" font-family=\"Lato\" font-size=\"14.00\">Inf(</text>\n",
"<text text-anchor=\"start\" x=\"75.5\" y=\"-189.87\" font-family=\"Lato\" font-size=\"14.00\" fill=\"#ff4da0\">❶</text>\n",
"<text text-anchor=\"start\" x=\"91.5\" y=\"-189.87\" font-family=\"Lato\" font-size=\"14.00\">) | Fin(</text>\n",
"<text text-anchor=\"start\" x=\"129.5\" y=\"-189.87\" font-family=\"Lato\" font-size=\"14.00\" fill=\"#1f78b4\">⓿</text>\n",
"<text text-anchor=\"start\" x=\"145.5\" y=\"-189.87\" font-family=\"Lato\" font-size=\"14.00\">)</text>\n",
"<text text-anchor=\"start\" x=\"70.5\" y=\"-175.87\" font-family=\"Lato\" font-size=\"14.00\">[Streett 1]</text>\n",
"<!-- I -->\n",
"<!-- 0 -->\n",
"<g id=\"node2\" class=\"node\">\n",
"<title>0</title>\n",
"<ellipse fill=\"#ffffaa\" stroke=\"#33a02c\" stroke-width=\"2\" cx=\"73.5\" cy=\"-75.07\" rx=\"18\" ry=\"18\"/>\n",
"<text text-anchor=\"middle\" x=\"73.5\" y=\"-71.37\" font-family=\"Lato\" font-size=\"14.00\">0</text>\n",
"<ellipse fill=\"#ffffaa\" stroke=\"#33a02c\" stroke-width=\"2\" cx=\"56\" cy=\"-75.07\" rx=\"18\" ry=\"18\"/>\n",
"<text text-anchor=\"middle\" x=\"56\" y=\"-71.37\" font-family=\"Lato\" font-size=\"14.00\">0</text>\n",
"</g>\n",
"<!-- I&#45;&gt;0 -->\n",
"<g id=\"edge1\" class=\"edge\">\n",
"<title>I&#45;&gt;0</title>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M18.65,-75.07C20.29,-75.07 34.65,-75.07 48.13,-75.07\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"55.44,-75.07 48.44,-78.22 51.94,-75.07 48.44,-75.07 48.44,-75.07 48.44,-75.07 51.94,-75.07 48.44,-71.92 55.44,-75.07 55.44,-75.07\"/>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M1.15,-75.07C2.79,-75.07 17.15,-75.07 30.63,-75.07\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"37.94,-75.07 30.94,-78.22 34.44,-75.07 30.94,-75.07 30.94,-75.07 30.94,-75.07 34.44,-75.07 30.94,-71.92 37.94,-75.07 37.94,-75.07\"/>\n",
"</g>\n",
"<!-- 1 -->\n",
"<g id=\"node3\" class=\"node\">\n",
"<title>1</title>\n",
"<polygon fill=\"#ffffaa\" stroke=\"#33a02c\" stroke-width=\"2\" points=\"194.5,-133.07 167.5,-115.07 194.5,-97.07 221.5,-115.07 194.5,-133.07\"/>\n",
"<text text-anchor=\"middle\" x=\"194.5\" y=\"-111.37\" font-family=\"Lato\" font-size=\"14.00\">1</text>\n",
"<polygon fill=\"#ffffaa\" stroke=\"#33a02c\" stroke-width=\"2\" points=\"177,-133.07 150,-115.07 177,-97.07 204,-115.07 177,-133.07\"/>\n",
"<text text-anchor=\"middle\" x=\"177\" y=\"-111.37\" font-family=\"Lato\" font-size=\"14.00\">1</text>\n",
"</g>\n",
"<!-- 0&#45;&gt;1 -->\n",
"<g id=\"edge2\" class=\"edge\">\n",
"<title>0&#45;&gt;1</title>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M79.63,-92.21C84.76,-105.97 94.14,-124.4 109.5,-133.07 129.34,-144.27 155.4,-135.7 173.2,-126.96\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"179.82,-123.52 175.06,-129.54 176.72,-125.13 173.61,-126.75 173.61,-126.75 173.61,-126.75 176.72,-125.13 172.16,-123.95 179.82,-123.52 179.82,-123.52\"/>\n",
"<text text-anchor=\"start\" x=\"110\" y=\"-156.87\" font-family=\"Lato\" font-size=\"14.00\">!a &amp; !c</text>\n",
"<text text-anchor=\"start\" x=\"121.5\" y=\"-141.87\" font-family=\"Lato\" font-size=\"14.00\" fill=\"#ff4da0\">❶</text>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M62.13,-92.21C67.26,-105.97 76.64,-124.4 92,-133.07 111.84,-144.27 137.9,-135.7 155.7,-126.96\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"162.32,-123.52 157.56,-129.54 159.22,-125.13 156.11,-126.75 156.11,-126.75 156.11,-126.75 159.22,-125.13 154.66,-123.95 162.32,-123.52 162.32,-123.52\"/>\n",
"<text text-anchor=\"start\" x=\"92.5\" y=\"-156.87\" font-family=\"Lato\" font-size=\"14.00\">!a &amp; !c</text>\n",
"<text text-anchor=\"start\" x=\"104\" y=\"-141.87\" font-family=\"Lato\" font-size=\"14.00\" fill=\"#ff4da0\">❶</text>\n",
"</g>\n",
"<!-- 2 -->\n",
"<g id=\"node4\" class=\"node\">\n",
"<title>2</title>\n",
"<polygon fill=\"#ffffaa\" stroke=\"#33a02c\" stroke-width=\"2\" points=\"194.5,-53.07 167.5,-35.07 194.5,-17.07 221.5,-35.07 194.5,-53.07\"/>\n",
"<text text-anchor=\"middle\" x=\"194.5\" y=\"-31.37\" font-family=\"Lato\" font-size=\"14.00\">2</text>\n",
"<polygon fill=\"#ffffaa\" stroke=\"#33a02c\" stroke-width=\"2\" points=\"177,-53.07 150,-35.07 177,-17.07 204,-35.07 177,-53.07\"/>\n",
"<text text-anchor=\"middle\" x=\"177\" y=\"-31.37\" font-family=\"Lato\" font-size=\"14.00\">2</text>\n",
"</g>\n",
"<!-- 0&#45;&gt;2 -->\n",
"<g id=\"edge3\" class=\"edge\">\n",
"<title>0&#45;&gt;2</title>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M87.62,-63.58C93.86,-58.69 101.65,-53.37 109.5,-50.07 126.19,-43.04 146.1,-39.3 162.35,-37.32\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"169.53,-36.52 162.92,-40.42 166.05,-36.91 162.57,-37.29 162.57,-37.29 162.57,-37.29 166.05,-36.91 162.23,-34.16 169.53,-36.52 169.53,-36.52\"/>\n",
"<text text-anchor=\"start\" x=\"117\" y=\"-68.87\" font-family=\"Lato\" font-size=\"14.00\">a | c</text>\n",
"<text text-anchor=\"start\" x=\"121.5\" y=\"-53.87\" font-family=\"Lato\" font-size=\"14.00\" fill=\"#ff4da0\">❶</text>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M70.12,-63.58C76.36,-58.69 84.15,-53.37 92,-50.07 108.69,-43.04 128.6,-39.3 144.85,-37.32\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"152.03,-36.52 145.42,-40.42 148.55,-36.91 145.07,-37.29 145.07,-37.29 145.07,-37.29 148.55,-36.91 144.73,-34.16 152.03,-36.52 152.03,-36.52\"/>\n",
"<text text-anchor=\"start\" x=\"99.5\" y=\"-68.87\" font-family=\"Lato\" font-size=\"14.00\">a | c</text>\n",
"<text text-anchor=\"start\" x=\"104\" y=\"-53.87\" font-family=\"Lato\" font-size=\"14.00\" fill=\"#ff4da0\">❶</text>\n",
"</g>\n",
"<!-- 1&#45;&gt;0 -->\n",
"<g id=\"edge4\" class=\"edge\">\n",
"<title>1&#45;&gt;0</title>\n",
"<path fill=\"none\" stroke=\"#33a02c\" stroke-width=\"2\" d=\"M176.84,-108.84C168.63,-105.81 158.58,-102.17 149.5,-99.07 132.27,-93.18 112.66,-86.92 97.82,-82.27\"/>\n",
"<polygon fill=\"#33a02c\" stroke=\"#33a02c\" stroke-width=\"2\" points=\"90.95,-80.13 98.57,-79.21 94.44,-80.69 97.78,-81.74 97.63,-82.21 97.48,-82.69 94.14,-81.65 96.69,-85.22 90.95,-80.13 90.95,-80.13\"/>\n",
"<text text-anchor=\"start\" x=\"109.5\" y=\"-117.87\" font-family=\"Lato\" font-size=\"14.00\">!b &amp; !d</text>\n",
"<text text-anchor=\"start\" x=\"121.5\" y=\"-102.87\" font-family=\"Lato\" font-size=\"14.00\" fill=\"#6a3d9a\">❸</text>\n",
"<path fill=\"none\" stroke=\"#33a02c\" stroke-width=\"2\" d=\"M159.34,-108.84C151.13,-105.81 141.08,-102.17 132,-99.07 114.77,-93.18 95.16,-86.92 80.32,-82.27\"/>\n",
"<polygon fill=\"#33a02c\" stroke=\"#33a02c\" stroke-width=\"2\" points=\"73.45,-80.13 81.07,-79.21 76.94,-80.69 80.28,-81.74 80.13,-82.21 79.98,-82.69 76.64,-81.65 79.19,-85.22 73.45,-80.13 73.45,-80.13\"/>\n",
"<text text-anchor=\"start\" x=\"92\" y=\"-117.87\" font-family=\"Lato\" font-size=\"14.00\">!b &amp; !d</text>\n",
"<text text-anchor=\"start\" x=\"104\" y=\"-102.87\" font-family=\"Lato\" font-size=\"14.00\" fill=\"#ff4da0\">❶</text>\n",
"</g>\n",
"<!-- 2&#45;&gt;0 -->\n",
"<g id=\"edge5\" class=\"edge\">\n",
"<title>2&#45;&gt;0</title>\n",
"<path fill=\"none\" stroke=\"#33a02c\" stroke-width=\"2\" d=\"M182.23,-25.06C165.46,-11.43 133.34,9.67 109.5,-5.07 93.56,-14.92 84.64,-34.46 79.8,-50.4\"/>\n",
"<polygon fill=\"#33a02c\" stroke=\"#33a02c\" stroke-width=\"2\" points=\"77.85,-57.43 76.69,-49.84 78.31,-53.92 79.24,-50.55 79.72,-50.68 80.2,-50.82 79.27,-54.19 82.76,-51.52 77.85,-57.43 77.85,-57.43\"/>\n",
"<text text-anchor=\"start\" x=\"116\" y=\"-23.87\" font-family=\"Lato\" font-size=\"14.00\">b | d</text>\n",
"<text text-anchor=\"start\" x=\"121.5\" y=\"-8.87\" font-family=\"Lato\" font-size=\"14.00\" fill=\"#6a3d9a\">❸</text>\n",
"<path fill=\"none\" stroke=\"#33a02c\" stroke-width=\"2\" d=\"M164.73,-25.06C147.96,-11.43 115.84,9.67 92,-5.07 76.06,-14.92 67.14,-34.46 62.3,-50.4\"/>\n",
"<polygon fill=\"#33a02c\" stroke=\"#33a02c\" stroke-width=\"2\" points=\"60.35,-57.43 59.19,-49.84 60.81,-53.92 61.74,-50.55 62.22,-50.68 62.7,-50.82 61.77,-54.19 65.26,-51.52 60.35,-57.43 60.35,-57.43\"/>\n",
"<text text-anchor=\"start\" x=\"98.5\" y=\"-23.87\" font-family=\"Lato\" font-size=\"14.00\">b | d</text>\n",
"<text text-anchor=\"start\" x=\"104\" y=\"-8.87\" font-family=\"Lato\" font-size=\"14.00\" fill=\"#ff4da0\">❶</text>\n",
"</g>\n",
"</g>\n",
"</svg>\n"
],
"text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f300caabba0> >"
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f32ec50ce40> >"
]
},
"execution_count": 4,
@ -150,6 +151,7 @@
{
"cell_type": "code",
"execution_count": 5,
"id": "3d56cda6",
"metadata": {},
"outputs": [],
"source": [
@ -159,6 +161,7 @@
{
"cell_type": "code",
"execution_count": 6,
"id": "c24548a1",
"metadata": {},
"outputs": [
{
@ -213,7 +216,7 @@
"</svg>\n"
],
"text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f300c179300> >"
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f32ec571c30> >"
]
},
"execution_count": 6,
@ -228,6 +231,7 @@
{
"cell_type": "code",
"execution_count": 7,
"id": "88f2c0e0",
"metadata": {},
"outputs": [],
"source": [
@ -237,6 +241,7 @@
{
"cell_type": "code",
"execution_count": 8,
"id": "e626997e",
"metadata": {},
"outputs": [
{
@ -285,7 +290,7 @@
"</svg>\n"
],
"text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f300c179300> >"
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f32ec571c30> >"
]
},
"execution_count": 8,
@ -300,7 +305,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
@ -314,7 +319,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.10"
"version": "3.9.2"
}
},
"nbformat": 4,