Commit 98c8725d authored by Alexandre Duret-Lutz's avatar Alexandre Duret-Lutz
Browse files

print_dot_psl: fix numbering of commutative operands

* spot/tl/dot.cc: Here.
* tests/python/formulas.ipynb: Add test case.
* NEWS: Mention the bug.
parent dc1f7133
Pipeline #5199 passed with stages
in 151 minutes and 40 seconds
New in spot 2.7.0.dev (not yet release)
Nothing yet.
Bugs fixed:
- The print_dot_psl() function would incorrectly number all but the
first children of commutative n-ary operators: in this case no
numbering was expected.
New in spot 2.7 (2018-12-11)
......
......@@ -122,7 +122,8 @@ namespace spot
else if (childnum == -1)
os_ << " [taillabel=\"R\"]";
os_ << ";\n";
++childnum;
if (childnum)
++childnum;
}
return src;
......
......@@ -27,17 +27,17 @@
spot.formula("p1 U (p2 R (p3 & !p4))")
%% Cell type:code id: tags:
``` python
g = spot.formula('{a;b*;c[+]}<>->GFb'); g
g = spot.formula('{a;b*;c[+]}<>->(GFb & c)'); g
```
%%%% Output: execute_result
$\{a \mathbin{\mathsf{;}} b^{\star} \mathbin{\mathsf{;}} c^+\}\mathrel{\Diamond\kern-1.7pt\raise.4pt\hbox{$\mathord{\rightarrow}$}} \mathsf{G} \mathsf{F} b$
spot.formula("{a;b[*];c[+]}<>-> GFb")
$\{a \mathbin{\mathsf{;}} b^{\star} \mathbin{\mathsf{;}} c^+\}\mathrel{\Diamond\kern-1.7pt\raise.4pt\hbox{$\mathord{\rightarrow}$}} (c \land \mathsf{G} \mathsf{F} b)$
spot.formula("{a;b[*];c[+]}<>-> (c & GFb)")
%% Cell type:markdown id: tags:
By default the parser recognizes an infix syntax, but when this fails, it tries to read the formula with the [LBT](http://www.tcs.hut.fi/Software/maria/tools/lbt/) syntax:
......@@ -224,11 +224,11 @@
print(g); g.show_ast()
```
%%%% Output: execute_result
![](data:image/svg+xml;utf8,<svg height="260pt" viewBox="0.00 0.00 269.00 260.00" width="269pt" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><g class="graph" id="graph0" transform="scale(1 1) rotate(0) translate(4 256)"><title>G</title><polygon fill="#ffffff" points="-4,4 -4,-256 265,-256 265,4 -4,4" stroke="transparent"/><!-- 0 --><g class="node" id="node1"><title>0</title><ellipse cx="98" cy="-234" fill="none" rx="40.8928" ry="18" stroke="#000000"/><text fill="#000000" font-family="Times,serif" font-size="14.00" text-anchor="middle" x="98" y="-230.3">EConcat</text></g><!-- 1 --><g class="node" id="node2"><title>1</title><ellipse cx="155" cy="-162" fill="none" rx="35.9954" ry="18" stroke="#000000"/><text fill="#000000" font-family="Times,serif" font-size="14.00" text-anchor="middle" x="155" y="-158.3">Concat</text></g><!-- 0&#45;&gt;1 --><g class="edge" id="edge6"><title>0-&gt;1</title><path d="M111.5082,-216.937C118.6068,-207.9703 127.4402,-196.8124 135.288,-186.8993" fill="none" stroke="#000000"/><polygon fill="#000000" points="138.1259,-188.9535 141.5888,-178.9405 132.6375,-184.6085 138.1259,-188.9535" stroke="#000000"/><text fill="#000000" font-family="Times,serif" font-size="14.00" text-anchor="middle" x="107.0082" y="-205.737">L</text></g><!-- 7 --><g class="node" id="node8"><title>7</title><ellipse cx="58" cy="-162" fill="none" rx="27" ry="18" stroke="#000000"/><text fill="#000000" font-family="Times,serif" font-size="14.00" text-anchor="middle" x="58" y="-158.3">G</text></g><!-- 0&#45;&gt;7 --><g class="edge" id="edge9"><title>0-&gt;7</title><path d="M88.1124,-216.2022C83.3928,-207.7071 77.6537,-197.3767 72.4568,-188.0223" fill="none" stroke="#000000"/><polygon fill="#000000" points="75.4145,-186.139 67.4985,-179.0972 69.2954,-189.5386 75.4145,-186.139" stroke="#000000"/><text fill="#000000" font-family="Times,serif" font-size="14.00" text-anchor="middle" x="83.1124" y="-205.0022">R</text></g><!-- 2 --><g class="node" id="node3"><title>2</title><polygon fill="none" points="261,-36 207,-36 207,0 261,0 261,-36" stroke="#000000"/><text fill="#000000" font-family="Times,serif" font-size="14.00" text-anchor="middle" x="234" y="-14.3">a</text></g><!-- 1&#45;&gt;2 --><g class="edge" id="edge1"><title>1-&gt;2</title><path d="M173.9318,-146.4771C184.9807,-136.5145 198.3956,-122.7193 207,-108 218.2008,-88.8391 225.1222,-64.624 229.1492,-46.139" fill="none" stroke="#000000"/><polygon fill="#000000" points="232.5946,-46.7593 231.1469,-36.2639 225.7336,-45.3713 232.5946,-46.7593" stroke="#000000"/><text fill="#000000" font-family="Times,serif" font-size="14.00" text-anchor="middle" x="170.4318" y="-135.2771">1</text></g><!-- 3 --><g class="node" id="node4"><title>3</title><ellipse cx="99" cy="-90" fill="none" rx="27" ry="18" stroke="#000000"/><text fill="#000000" font-family="Times,serif" font-size="14.00" text-anchor="middle" x="99" y="-86.3">Star</text></g><!-- 1&#45;&gt;3 --><g class="edge" id="edge3"><title>1-&gt;3</title><path d="M141.7288,-144.937C134.6536,-135.8403 125.8244,-124.4886 118.0315,-114.4691" fill="none" stroke="#000000"/><polygon fill="#000000" points="120.6927,-112.1897 111.7905,-106.4449 115.1672,-116.4873 120.6927,-112.1897" stroke="#000000"/><text fill="#000000" font-family="Times,serif" font-size="14.00" text-anchor="middle" x="138.2288" y="-133.737">2</text></g><!-- 5 --><g class="node" id="node6"><title>5</title><ellipse cx="171" cy="-90" fill="none" rx="27" ry="18" stroke="#000000"/><text fill="#000000" font-family="Times,serif" font-size="14.00" text-anchor="middle" x="171" y="-86.3">Star</text></g><!-- 1&#45;&gt;5 --><g class="edge" id="edge5"><title>1-&gt;5</title><path d="M159.0375,-143.8314C160.7941,-135.9266 162.8917,-126.4872 164.8363,-117.7365" fill="none" stroke="#000000"/><polygon fill="#000000" points="168.2665,-118.4346 167.0192,-107.9134 161.4332,-116.916 168.2665,-118.4346" stroke="#000000"/><text fill="#000000" font-family="Times,serif" font-size="14.00" text-anchor="middle" x="155.5375" y="-132.6314">3</text></g><!-- 4 --><g class="node" id="node5"><title>4</title><polygon fill="none" points="90,-36 36,-36 36,0 90,0 90,-36" stroke="#000000"/><text fill="#000000" font-family="Times,serif" font-size="14.00" text-anchor="middle" x="63" y="-14.3">b</text></g><!-- 3&#45;&gt;4 --><g class="edge" id="edge2"><title>3-&gt;4</title><path d="M90.2854,-72.5708C86.1772,-64.3544 81.1804,-54.3608 76.5911,-45.1821" fill="none" stroke="#000000"/><polygon fill="#000000" points="79.613,-43.3996 72.0103,-36.0206 73.352,-46.5301 79.613,-43.3996" stroke="#000000"/></g><!-- 6 --><g class="node" id="node7"><title>6</title><polygon fill="none" points="189,-36 135,-36 135,0 189,0 189,-36" stroke="#000000"/><text fill="#000000" font-family="Times,serif" font-size="14.00" text-anchor="middle" x="162" y="-14.3">c</text></g><!-- 5&#45;&gt;6 --><g class="edge" id="edge4"><title>5-&gt;6</title><path d="M168.7289,-71.8314C167.7664,-64.131 166.6218,-54.9743 165.5521,-46.4166" fill="none" stroke="#000000"/><polygon fill="#000000" points="169.0151,-45.9019 164.3017,-36.4133 162.0691,-46.7702 169.0151,-45.9019" stroke="#000000"/></g><!-- 8 --><g class="node" id="node9"><title>8</title><ellipse cx="27" cy="-90" fill="none" rx="27" ry="18" stroke="#000000"/><text fill="#000000" font-family="Times,serif" font-size="14.00" text-anchor="middle" x="27" y="-86.3">F</text></g><!-- 7&#45;&gt;8 --><g class="edge" id="edge8"><title>7-&gt;8</title><path d="M50.4958,-144.5708C46.905,-136.2309 42.5258,-126.0598 38.5254,-116.7686" fill="none" stroke="#000000"/><polygon fill="#000000" points="41.7119,-115.319 34.5426,-107.5182 35.2825,-118.0872 41.7119,-115.319" stroke="#000000"/></g><!-- 8&#45;&gt;4 --><g class="edge" id="edge7"><title>8-&gt;4</title><path d="M35.7146,-72.5708C39.8228,-64.3544 44.8196,-54.3608 49.4089,-45.1821" fill="none" stroke="#000000"/><polygon fill="#000000" points="52.648,-46.5301 53.9897,-36.0206 46.387,-43.3996 52.648,-46.5301" stroke="#000000"/></g></g></svg>)
![](data:image/svg+xml;utf8,<svg height="332pt" viewBox="0.00 0.00 299.00 332.00" width="299pt" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><g class="graph" id="graph0" transform="scale(1 1) rotate(0) translate(4 328)"><title>G</title><polygon fill="#ffffff" points="-4,4 -4,-328 295,-328 295,4 -4,4" stroke="transparent"/><!-- 0 --><g class="node" id="node1"><title>0</title><ellipse cx="177" cy="-306" fill="none" rx="40.8928" ry="18" stroke="#000000"/><text fill="#000000" font-family="Times,serif" font-size="14.00" text-anchor="middle" x="177" y="-302.3">EConcat</text></g><!-- 1 --><g class="node" id="node2"><title>1</title><ellipse cx="114" cy="-162" fill="none" rx="35.9954" ry="18" stroke="#000000"/><text fill="#000000" font-family="Times,serif" font-size="14.00" text-anchor="middle" x="114" y="-158.3">Concat</text></g><!-- 0&#45;&gt;1 --><g class="edge" id="edge6"><title>0-&gt;1</title><path d="M169.1484,-288.0535C158.2902,-263.2347 138.5973,-218.2224 125.9187,-189.2428" fill="none" stroke="#000000"/><polygon fill="#000000" points="128.9675,-187.4791 121.7527,-179.7204 122.5543,-190.2848 128.9675,-187.4791" stroke="#000000"/><text fill="#000000" font-family="Times,serif" font-size="14.00" text-anchor="middle" x="164.6484" y="-276.8535">L</text></g><!-- 7 --><g class="node" id="node8"><title>7</title><ellipse cx="209" cy="-234" fill="none" rx="27" ry="18" stroke="#000000"/><text fill="#000000" font-family="Times,serif" font-size="14.00" text-anchor="middle" x="209" y="-230.3">And</text></g><!-- 0&#45;&gt;7 --><g class="edge" id="edge11"><title>0-&gt;7</title><path d="M184.9101,-288.2022C188.619,-279.8574 193.1148,-269.7417 197.2135,-260.5197" fill="none" stroke="#000000"/><polygon fill="#000000" points="200.4282,-261.9042 201.2913,-251.3446 194.0315,-259.0612 200.4282,-261.9042" stroke="#000000"/><text fill="#000000" font-family="Times,serif" font-size="14.00" text-anchor="middle" x="179.9101" y="-277.0022">R</text></g><!-- 2 --><g class="node" id="node3"><title>2</title><polygon fill="none" points="54,-36 0,-36 0,0 54,0 54,-36" stroke="#000000"/><text fill="#000000" font-family="Times,serif" font-size="14.00" text-anchor="middle" x="27" y="-14.3">a</text></g><!-- 1&#45;&gt;2 --><g class="edge" id="edge1"><title>1-&gt;2</title><path d="M89.6281,-148.603C74.758,-139.1708 56.625,-125.1808 46,-108 34.5017,-89.407 29.8676,-64.9633 28.0445,-46.243" fill="none" stroke="#000000"/><polygon fill="#000000" points="31.5318,-45.9421 27.2801,-36.2378 24.5521,-46.4754 31.5318,-45.9421" stroke="#000000"/><text fill="#000000" font-family="Times,serif" font-size="14.00" text-anchor="middle" x="86.1281" y="-137.403">1</text></g><!-- 3 --><g class="node" id="node4"><title>3</title><ellipse cx="154" cy="-90" fill="none" rx="27" ry="18" stroke="#000000"/><text fill="#000000" font-family="Times,serif" font-size="14.00" text-anchor="middle" x="154" y="-86.3">Star</text></g><!-- 1&#45;&gt;3 --><g class="edge" id="edge3"><title>1-&gt;3</title><path d="M123.6829,-144.5708C128.3996,-136.0807 134.1706,-125.6929 139.407,-116.2674" fill="none" stroke="#000000"/><polygon fill="#000000" points="142.6094,-117.71 144.4063,-107.2687 136.4903,-114.3105 142.6094,-117.71" stroke="#000000"/><text fill="#000000" font-family="Times,serif" font-size="14.00" text-anchor="middle" x="120.1829" y="-133.3708">2</text></g><!-- 5 --><g class="node" id="node6"><title>5</title><ellipse cx="82" cy="-90" fill="none" rx="27" ry="18" stroke="#000000"/><text fill="#000000" font-family="Times,serif" font-size="14.00" text-anchor="middle" x="82" y="-86.3">Star</text></g><!-- 1&#45;&gt;5 --><g class="edge" id="edge5"><title>1-&gt;5</title><path d="M106.0899,-144.2022C102.381,-135.8574 97.8852,-125.7417 93.7865,-116.5197" fill="none" stroke="#000000"/><polygon fill="#000000" points="96.9685,-115.0612 89.7087,-107.3446 90.5718,-117.9042 96.9685,-115.0612" stroke="#000000"/><text fill="#000000" font-family="Times,serif" font-size="14.00" text-anchor="middle" x="102.5899" y="-133.0022">3</text></g><!-- 4 --><g class="node" id="node5"><title>4</title><polygon fill="none" points="267,-36 213,-36 213,0 267,0 267,-36" stroke="#000000"/><text fill="#000000" font-family="Times,serif" font-size="14.00" text-anchor="middle" x="240" y="-14.3">b</text></g><!-- 3&#45;&gt;4 --><g class="edge" id="edge2"><title>3-&gt;4</title><path d="M170.9908,-75.7751C182.2603,-66.3402 197.3476,-53.709 210.5409,-42.6634" fill="none" stroke="#000000"/><polygon fill="#000000" points="213.039,-45.1367 218.4598,-36.0336 208.5454,-39.7694 213.039,-45.1367" stroke="#000000"/></g><!-- 6 --><g class="node" id="node7"><title>6</title><polygon fill="none" points="172,-36 118,-36 118,0 172,0 172,-36" stroke="#000000"/><text fill="#000000" font-family="Times,serif" font-size="14.00" text-anchor="middle" x="145" y="-14.3">c</text></g><!-- 5&#45;&gt;6 --><g class="edge" id="edge4"><title>5-&gt;6</title><path d="M95.6701,-74.3771C103.514,-65.4125 113.5574,-53.9344 122.5323,-43.6774" fill="none" stroke="#000000"/><polygon fill="#000000" points="125.1819,-45.9643 129.1329,-36.1338 119.9138,-41.3548 125.1819,-45.9643" stroke="#000000"/></g><!-- 7&#45;&gt;6 --><g class="edge" id="edge7"><title>7-&gt;6</title><path d="M210.1584,-215.6415C211.4052,-184.6687 210.9012,-120.6548 190,-72 185.6198,-61.8035 178.6732,-52.0371 171.5362,-43.6819" fill="none" stroke="#000000"/><polygon fill="#000000" points="174.0158,-41.2056 164.7127,-36.1357 168.8236,-45.9005 174.0158,-41.2056" stroke="#000000"/></g><!-- 8 --><g class="node" id="node9"><title>8</title><ellipse cx="264" cy="-162" fill="none" rx="27" ry="18" stroke="#000000"/><text fill="#000000" font-family="Times,serif" font-size="14.00" text-anchor="middle" x="264" y="-158.3">G</text></g><!-- 7&#45;&gt;8 --><g class="edge" id="edge10"><title>7-&gt;8</title><path d="M221.4804,-217.6621C228.5124,-208.4564 237.4347,-196.7764 245.2883,-186.4953" fill="none" stroke="#000000"/><polygon fill="#000000" points="248.28,-188.3446 251.569,-178.2733 242.7172,-184.0953 248.28,-188.3446" stroke="#000000"/></g><!-- 9 --><g class="node" id="node10"><title>9</title><ellipse cx="264" cy="-90" fill="none" rx="27" ry="18" stroke="#000000"/><text fill="#000000" font-family="Times,serif" font-size="14.00" text-anchor="middle" x="264" y="-86.3">F</text></g><!-- 8&#45;&gt;9 --><g class="edge" id="edge9"><title>8-&gt;9</title><path d="M264,-143.8314C264,-136.131 264,-126.9743 264,-118.4166" fill="none" stroke="#000000"/><polygon fill="#000000" points="267.5001,-118.4132 264,-108.4133 260.5001,-118.4133 267.5001,-118.4132" stroke="#000000"/></g><!-- 9&#45;&gt;4 --><g class="edge" id="edge8"><title>9-&gt;4</title><path d="M258.0674,-72.2022C255.4049,-64.2146 252.2015,-54.6045 249.2362,-45.7087" fill="none" stroke="#000000"/><polygon fill="#000000" points="252.5138,-44.4731 246.031,-36.0931 245.873,-46.6868 252.5138,-44.4731" stroke="#000000"/></g></g></svg>)
<IPython.core.display.SVG object>
%% Cell type:markdown id: tags:
Any formula can also be classified in the temporal hierarchy of Manna & Pnueli
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment