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

improve alternation removal to match G&O construction

When dealternating the VWAA for GFa, our result had two states that
could not be fused by simulation because of unmatched acceptance mark.
With this change, the result can be simplified.

* spot/twaalgos/alternation.cc: Here.
* tests/core/alternating.test, tests/python/alternation.ipynb: Update
test case.
* NEWS: Mention it.
parent 6d9d35c9
Pipeline #1923 passed with stages
in 117 minutes and 58 seconds
......@@ -110,6 +110,11 @@ New in spot 2.5.3.dev (not yet released)
The code was buggy, hard to maintain, and these functions do not
seem to be used.
- spot::remove_alternation() was slightly improved on very-weak
alternating automata: the labeling of the outgoing transitions in
the resulting TGBA makes it more likely that simulation-based
reductions will reduce it.
Python:
- New spot.jupyter package. This currently contains a function for
......
......@@ -184,6 +184,7 @@ namespace spot
std::map<int, unsigned> var_to_state_;
std::vector<int> scc_to_var_;
std::map<int, acc_cond::mark_t> var_to_mark_;
std::vector<unsigned> mark_to_state_;
bdd all_vars_;
bdd all_marks_;
bdd all_states_;
......@@ -223,6 +224,7 @@ namespace spot
unsigned nc = si_.scc_count();
scc_to_var_.reserve(nc);
unsigned mark_pos = has_reject_more_;
mark_to_state_.resize(mark_pos);
bdd all_marks = bddtrue;
for (unsigned s = 0; s < nc; ++s)
{
......@@ -231,6 +233,7 @@ namespace spot
{
int v = d->register_anonymous_variables(1, this);
scc_to_var_.emplace_back(v);
mark_to_state_.push_back(si_.one_state_of(c));
var_to_mark_.emplace(v, acc_cond::mark_t({mark_pos++}));
bdd bv = bdd_ithvar(v);
all_marks &= bv;
......@@ -270,7 +273,7 @@ namespace spot
marked && (scc_s == scc_d) && (c == scc_class::reject_more);
dest &= bdd_ithvar(state_to_var_[d] + mark);
if (c == scc_class::reject_1 && scc_s == scc_d)
dest &= bdd_ithvar(scc_to_var_[scc_s]);
dest &= bdd_ithvar(scc_to_var_[scc_d]);
}
res |= e.cond & dest;
}
......@@ -464,6 +467,29 @@ namespace spot
bdd dest = bdd_existcomp(cube, all_vars_);
v.clear();
acc_cond::mark_t m = bdd_to_state(dest, v);
// if there is no promise "f" is between a state
// that does not have f, and a state that have
// "f", we can add one. Doing so will help later
// simplifications performed by postprocessor. An
// example where this is needed is the VWAA
// generated by ltl[23]ba for GFa. Without the
// next loop, the final TGBA has 2 states instead
// of 1.
for (unsigned m1: (all_marks - m).sets())
{
if (has_reject_more_ && m1 == 0)
continue;
auto& sv = s_to_ss[s];
unsigned ms = mark_to_state_[m1];
if (std::find(v.begin(), v.end(), ms) != v.end())
{
unsigned ms = mark_to_state_[m1];
if (std::find(sv.begin(), sv.end(), ms) == sv.end())
m.set(m1);
}
}
unsigned d = new_state(v, has_mark);
if (has_mark)
m.set(0);
......
......@@ -195,7 +195,7 @@ Acceptance: 1 Inf(0)
properties: trans-labels explicit-labels trans-acc complete
--BODY--
State: 0
[t] 1 {0}
[t] 1
State: 1
[t] 1
[0] 1 {0}
......
......@@ -1373,7 +1373,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 5,
"metadata": {},
"outputs": [
{
......@@ -1961,7 +1961,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 6,
"metadata": {},
"outputs": [
{
......@@ -2784,37 +2784,37 @@
"<!-- 0 -->\n",
"<g id=\"node2\" class=\"node\">\n",
"<title>0</title>\n",
"<ellipse fill=\"#ffffaa\" stroke=\"#000000\" cx=\"114\" cy=\"-420\" rx=\"27\" ry=\"18\"/>\n",
"<text text-anchor=\"middle\" x=\"114\" y=\"-416.3\" font-family=\"Lato\" font-size=\"14.00\" fill=\"#000000\">0</text>\n",
"<ellipse fill=\"#ffffaa\" stroke=\"#000000\" cx=\"115\" cy=\"-420\" rx=\"27\" ry=\"18\"/>\n",
"<text text-anchor=\"middle\" x=\"115\" y=\"-416.3\" font-family=\"Lato\" font-size=\"14.00\" fill=\"#000000\">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=\"#000000\" d=\"M114,-474.8767C114,-471.822 114,-458.0552 114,-445.0759\"/>\n",
"<polygon fill=\"#000000\" stroke=\"#000000\" points=\"114,-438.0193 117.1501,-445.0192 114,-441.5193 114.0001,-445.0193 114.0001,-445.0193 114.0001,-445.0193 114,-441.5193 110.8501,-445.0193 114,-438.0193 114,-438.0193\"/>\n",
"<path fill=\"none\" stroke=\"#000000\" d=\"M115,-474.8767C115,-471.822 115,-458.0552 115,-445.0759\"/>\n",
"<polygon fill=\"#000000\" stroke=\"#000000\" points=\"115,-438.0193 118.1501,-445.0192 115,-441.5193 115.0001,-445.0193 115.0001,-445.0193 115.0001,-445.0193 115,-441.5193 111.8501,-445.0193 115,-438.0193 115,-438.0193\"/>\n",
"</g>\n",
"<!-- 1 -->\n",
"<g id=\"node3\" class=\"node\">\n",
"<title>1</title>\n",
"<ellipse fill=\"#ffffaa\" stroke=\"#000000\" cx=\"114\" cy=\"-320\" rx=\"27\" ry=\"18\"/>\n",
"<text text-anchor=\"start\" x=\"104\" y=\"-316.3\" font-family=\"Lato\" font-size=\"14.00\" fill=\"#000000\">1,3</text>\n",
"<ellipse fill=\"#ffffaa\" stroke=\"#000000\" cx=\"115\" cy=\"-320\" rx=\"27\" ry=\"18\"/>\n",
"<text text-anchor=\"start\" x=\"105\" y=\"-316.3\" font-family=\"Lato\" font-size=\"14.00\" fill=\"#000000\">1,3</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=\"#000000\" d=\"M114,-401.6585C114,-385.8706 114,-362.929 114,-345.3797\"/>\n",
"<polygon fill=\"#000000\" stroke=\"#000000\" points=\"114,-338.2253 117.1501,-345.2252 114,-341.7253 114.0001,-345.2253 114.0001,-345.2253 114.0001,-345.2253 114,-341.7253 110.8501,-345.2253 114,-338.2253 114,-338.2253\"/>\n",
"<text text-anchor=\"start\" x=\"125.5\" y=\"-373.8\" font-family=\"Lato\" font-size=\"14.00\" fill=\"#000000\">1</text>\n",
"<text text-anchor=\"start\" x=\"114\" y=\"-359.8\" font-family=\"Lato\" font-size=\"14.00\" fill=\"#1f78b4\">⓿</text>\n",
"<text text-anchor=\"start\" x=\"130\" y=\"-359.8\" font-family=\"Lato\" font-size=\"14.00\" fill=\"#ff4da0\">❶</text>\n",
"<path fill=\"none\" stroke=\"#000000\" d=\"M115,-401.6585C115,-385.8706 115,-362.929 115,-345.3797\"/>\n",
"<polygon fill=\"#000000\" stroke=\"#000000\" points=\"115,-338.2253 118.1501,-345.2252 115,-341.7253 115.0001,-345.2253 115.0001,-345.2253 115.0001,-345.2253 115,-341.7253 111.8501,-345.2253 115,-338.2253 115,-338.2253\"/>\n",
"<text text-anchor=\"start\" x=\"126.5\" y=\"-373.8\" font-family=\"Lato\" font-size=\"14.00\" fill=\"#000000\">1</text>\n",
"<text text-anchor=\"start\" x=\"115\" y=\"-359.8\" font-family=\"Lato\" font-size=\"14.00\" fill=\"#1f78b4\">⓿</text>\n",
"<text text-anchor=\"start\" x=\"131\" y=\"-359.8\" font-family=\"Lato\" font-size=\"14.00\" fill=\"#ff4da0\">❶</text>\n",
"</g>\n",
"<!-- 1&#45;&gt;1 -->\n",
"<g id=\"edge3\" class=\"edge\">\n",
"<title>1&#45;&gt;1</title>\n",
"<path fill=\"none\" stroke=\"#000000\" d=\"M137.6146,-329.1461C148.9731,-330.2753 159,-327.2266 159,-320 159,-314.3542 152.8801,-311.2585 144.7865,-310.7126\"/>\n",
"<polygon fill=\"#000000\" stroke=\"#000000\" points=\"137.6146,-310.8539 144.5512,-307.5666 141.1139,-310.7849 144.6132,-310.7159 144.6132,-310.7159 144.6132,-310.7159 141.1139,-310.7849 144.6753,-313.8653 137.6146,-310.8539 137.6146,-310.8539\"/>\n",
"<text text-anchor=\"start\" x=\"162.5\" y=\"-323.8\" font-family=\"Lato\" font-size=\"14.00\" fill=\"#000000\">b</text>\n",
"<text text-anchor=\"start\" x=\"159\" y=\"-308.8\" font-family=\"Lato\" font-size=\"14.00\" fill=\"#1f78b4\">⓿</text>\n",
"<path fill=\"none\" stroke=\"#000000\" d=\"M138.6146,-329.1461C149.9731,-330.2753 160,-327.2266 160,-320 160,-314.3542 153.8801,-311.2585 145.7865,-310.7126\"/>\n",
"<polygon fill=\"#000000\" stroke=\"#000000\" points=\"138.6146,-310.8539 145.5512,-307.5666 142.1139,-310.7849 145.6132,-310.7159 145.6132,-310.7159 145.6132,-310.7159 142.1139,-310.7849 145.6753,-313.8653 138.6146,-310.8539 138.6146,-310.8539\"/>\n",
"<text text-anchor=\"start\" x=\"163.5\" y=\"-323.8\" font-family=\"Lato\" font-size=\"14.00\" fill=\"#000000\">b</text>\n",
"<text text-anchor=\"start\" x=\"160\" y=\"-308.8\" font-family=\"Lato\" font-size=\"14.00\" fill=\"#1f78b4\">⓿</text>\n",
"</g>\n",
"<!-- 2 -->\n",
"<g id=\"node4\" class=\"node\">\n",
......@@ -2825,8 +2825,8 @@
"<!-- 1&#45;&gt;2 -->\n",
"<g id=\"edge4\" class=\"edge\">\n",
"<title>1&#45;&gt;2</title>\n",
"<path fill=\"none\" stroke=\"#000000\" d=\"M96.8259,-305.9172C79.5378,-290.6561 53.6704,-264.6205 41,-236 27.7556,-206.083 25.5482,-167.9465 25.7858,-143.2564\"/>\n",
"<polygon fill=\"#000000\" stroke=\"#000000\" points=\"25.9285,-136.0496 28.9392,-143.1107 25.8592,-139.5489 25.7898,-143.0482 25.7898,-143.0482 25.7898,-143.0482 25.8592,-139.5489 22.6404,-142.9858 25.9285,-136.0496 25.9285,-136.0496\"/>\n",
"<path fill=\"none\" stroke=\"#000000\" d=\"M97.59,-305.9683C80.0645,-290.7488 53.8424,-264.7467 41,-236 27.6548,-206.1278 25.4715,-167.9806 25.742,-143.2759\"/>\n",
"<polygon fill=\"#000000\" stroke=\"#000000\" points=\"25.8951,-136.0645 28.8957,-143.1298 25.8208,-139.5637 25.7464,-143.0629 25.7464,-143.0629 25.7464,-143.0629 25.8208,-139.5637 22.5971,-142.996 25.8951,-136.0645 25.8951,-136.0645\"/>\n",
"<text text-anchor=\"start\" x=\"41\" y=\"-221.8\" font-family=\"Lato\" font-size=\"14.00\" fill=\"#000000\">a &amp; b</text>\n",
"<text text-anchor=\"start\" x=\"42\" y=\"-207.8\" font-family=\"Lato\" font-size=\"14.00\" fill=\"#1f78b4\">⓿</text>\n",
"<text text-anchor=\"start\" x=\"58\" y=\"-207.8\" font-family=\"Lato\" font-size=\"14.00\" fill=\"#ff4da0\">❶</text>\n",
......@@ -2840,10 +2840,9 @@
"<!-- 1&#45;&gt;3 -->\n",
"<g id=\"edge5\" class=\"edge\">\n",
"<title>1&#45;&gt;3</title>\n",
"<path fill=\"none\" stroke=\"#000000\" d=\"M103.5014,-303.0415C100.4578,-297.2234 97.5412,-290.5288 96,-284 92.9366,-271.0233 92.7942,-266.9422 96,-254 97.0705,-249.6784 98.7647,-245.3035 100.711,-241.1634\"/>\n",
"<polygon fill=\"#000000\" stroke=\"#000000\" points=\"103.9233,-234.8922 103.5355,-242.5585 102.3276,-238.0073 100.7319,-241.1224 100.7319,-241.1224 100.7319,-241.1224 102.3276,-238.0073 97.9283,-239.6863 103.9233,-234.8922 103.9233,-234.8922\"/>\n",
"<text text-anchor=\"start\" x=\"97.5\" y=\"-272.8\" font-family=\"Lato\" font-size=\"14.00\" fill=\"#000000\">!b</text>\n",
"<text text-anchor=\"start\" x=\"96\" y=\"-257.8\" font-family=\"Lato\" font-size=\"14.00\" fill=\"#1f78b4\">⓿</text>\n",
"<path fill=\"none\" stroke=\"#000000\" d=\"M105.0803,-302.978C102.2054,-297.1557 99.4518,-290.4746 98,-284 95.0826,-270.9898 95.0826,-267.0102 98,-254 98.9107,-249.9386 100.3336,-245.796 101.9774,-241.8351\"/>\n",
"<polygon fill=\"#000000\" stroke=\"#000000\" points=\"104.9008,-235.387 104.8792,-243.0631 103.4555,-238.5747 102.0103,-241.7624 102.0103,-241.7624 102.0103,-241.7624 103.4555,-238.5747 99.1414,-240.4617 104.9008,-235.387 104.9008,-235.387\"/>\n",
"<text text-anchor=\"start\" x=\"98\" y=\"-265.3\" font-family=\"Lato\" font-size=\"14.00\" fill=\"#000000\">!b</text>\n",
"</g>\n",
"<!-- 4 -->\n",
"<g id=\"node6\" class=\"node\">\n",
......@@ -2854,11 +2853,9 @@
"<!-- 1&#45;&gt;4 -->\n",
"<g id=\"edge6\" class=\"edge\">\n",
"<title>1&#45;&gt;4</title>\n",
"<path fill=\"none\" stroke=\"#000000\" d=\"M131.627,-306.1448C149.2395,-291.0693 175.2044,-265.1832 186,-236 196.7279,-206.9998 183.6544,-129.5648 173,-100 164.7809,-77.1929 148.5351,-54.8367 135.4831,-39.243\"/>\n",
"<path fill=\"none\" stroke=\"#000000\" d=\"M132.3877,-306.0906C149.76,-290.9709 175.3679,-265.0491 186,-236 196.6715,-206.8434 183.4964,-129.1265 173,-100 164.7809,-77.1929 148.5351,-54.8367 135.4831,-39.243\"/>\n",
"<polygon fill=\"#000000\" stroke=\"#000000\" points=\"130.8398,-33.8157 137.784,-37.0869 133.1151,-36.4752 135.3905,-39.1347 135.3905,-39.1347 135.3905,-39.1347 133.1151,-36.4752 132.9969,-41.1825 130.8398,-33.8157 130.8398,-33.8157\"/>\n",
"<text text-anchor=\"start\" x=\"188\" y=\"-171.8\" font-family=\"Lato\" font-size=\"14.00\" fill=\"#000000\">a &amp; !b</text>\n",
"<text text-anchor=\"start\" x=\"190.5\" y=\"-157.8\" font-family=\"Lato\" font-size=\"14.00\" fill=\"#1f78b4\">⓿</text>\n",
"<text text-anchor=\"start\" x=\"206.5\" y=\"-157.8\" font-family=\"Lato\" font-size=\"14.00\" fill=\"#ff4da0\">❶</text>\n",
"<text text-anchor=\"start\" x=\"188\" y=\"-164.3\" font-family=\"Lato\" font-size=\"14.00\" fill=\"#000000\">a &amp; !b</text>\n",
"</g>\n",
"<!-- 2&#45;&gt;2 -->\n",
"<g id=\"edge7\" class=\"edge\">\n",
......@@ -2874,15 +2871,13 @@
"<title>2&#45;&gt;4</title>\n",
"<path fill=\"none\" stroke=\"#000000\" d=\"M24.0726,-100.011C22.8274,-86.151 23.4336,-67.1893 33,-54 43.8935,-38.981 62.4057,-30.1574 79.1864,-25.0096\"/>\n",
"<polygon fill=\"#000000\" stroke=\"#000000\" points=\"86.2448,-23.021 80.3613,-27.9513 82.876,-23.9702 79.5071,-24.9193 79.5071,-24.9193 79.5071,-24.9193 82.876,-23.9702 78.6529,-21.8873 86.2448,-23.021 86.2448,-23.021\"/>\n",
"<text text-anchor=\"start\" x=\"33\" y=\"-71.8\" font-family=\"Lato\" font-size=\"14.00\" fill=\"#000000\">a &amp; !b</text>\n",
"<text text-anchor=\"start\" x=\"35.5\" y=\"-57.8\" font-family=\"Lato\" font-size=\"14.00\" fill=\"#1f78b4\">⓿</text>\n",
"<text text-anchor=\"start\" x=\"51.5\" y=\"-57.8\" font-family=\"Lato\" font-size=\"14.00\" fill=\"#ff4da0\">❶</text>\n",
"<text text-anchor=\"start\" x=\"33\" y=\"-64.3\" font-family=\"Lato\" font-size=\"14.00\" fill=\"#000000\">a &amp; !b</text>\n",
"</g>\n",
"<!-- 3&#45;&gt;1 -->\n",
"<g id=\"edge9\" class=\"edge\">\n",
"<title>3&#45;&gt;1</title>\n",
"<path fill=\"none\" stroke=\"#000000\" d=\"M114.8228,-236.0777C114.664,-252.2729 114.4294,-276.2033 114.2513,-294.3707\"/>\n",
"<polygon fill=\"#000000\" stroke=\"#000000\" points=\"114.1788,-301.7644 111.0976,-294.7339 114.2131,-298.2646 114.2475,-294.7648 114.2475,-294.7648 114.2475,-294.7648 114.2131,-298.2646 117.3973,-294.7957 114.1788,-301.7644 114.1788,-301.7644\"/>\n",
"<path fill=\"none\" stroke=\"#000000\" d=\"M115,-236.0777C115,-252.2729 115,-276.2033 115,-294.3707\"/>\n",
"<polygon fill=\"#000000\" stroke=\"#000000\" points=\"115,-301.7644 111.8501,-294.7644 115,-298.2644 115.0001,-294.7644 115.0001,-294.7644 115.0001,-294.7644 115,-298.2644 118.1501,-294.7645 115,-301.7644 115,-301.7644\"/>\n",
"<text text-anchor=\"start\" x=\"118.5\" y=\"-272.8\" font-family=\"Lato\" font-size=\"14.00\" fill=\"#000000\">b</text>\n",
"<text text-anchor=\"start\" x=\"115\" y=\"-257.8\" font-family=\"Lato\" font-size=\"14.00\" fill=\"#1f78b4\">⓿</text>\n",
"</g>\n",
......@@ -3028,8 +3023,7 @@
"<title>2&#45;&gt;4</title>\n",
"<path fill=\"none\" stroke=\"#000000\" d=\"M23.9747,-102.0388C22.5753,-87.7014 23.0216,-67.7983 33,-54 43.8723,-38.9657 62.3829,-30.1409 79.168,-24.9962\"/>\n",
"<polygon fill=\"#000000\" stroke=\"#000000\" points=\"86.2286,-23.0093 80.3437,-27.9378 82.8595,-23.9574 79.4903,-24.9056 79.4903,-24.9056 79.4903,-24.9056 82.8595,-23.9574 78.637,-21.8734 86.2286,-23.0093 86.2286,-23.0093\"/>\n",
"<text text-anchor=\"start\" x=\"33\" y=\"-72.8\" font-family=\"Lato\" font-size=\"14.00\" fill=\"#000000\">a &amp; !b</text>\n",
"<text text-anchor=\"start\" x=\"43.5\" y=\"-57.8\" font-family=\"Lato\" font-size=\"14.00\" fill=\"#1f78b4\">⓿</text>\n",
"<text text-anchor=\"start\" x=\"33\" y=\"-65.3\" font-family=\"Lato\" font-size=\"14.00\" fill=\"#000000\">a &amp; !b</text>\n",
"</g>\n",
"<!-- 3&#45;&gt;1 -->\n",
"<g id=\"edge9\" class=\"edge\">\n",
......
Supports Markdown
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