acc: introduce fin_one_extract()
* spot/twa/acc.cc, spot/twa/acc.hh (acc_cond::fin_one_extract, acc_code::acc_cond::fin_one_extract): New methods. * python/spot/impl.i: Add support for the return type. * tests/python/acc_cond.ipynb: Test them.
This commit is contained in:
parent
2d1cb0ddcd
commit
7fedb3dc61
4 changed files with 246 additions and 16 deletions
|
|
@ -1409,6 +1409,80 @@
|
|||
"print(acc.top_disjuncts())\n",
|
||||
"print(acc.top_conjuncts())"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"`fin_one()` return the number of one color `x` that appears as `Fin(x)` in the formula, or `-1` if the formula is Fin-less.\n",
|
||||
"\n",
|
||||
"The variant `fin_one_extract()` consider the acceptance condition as a disjunction (if the top-level operator is not a disjunction, we just assume the formula is a disjunction with only one disjunct), and return a pair `(x,c)` where `c` is the disjunction of all disjuncts of the original formula where `Fin(x)` appear. Also this function tries to choose an `x` such that one of the disjunct has the form `...&Fin(x)&...` if possible: this is visible in the third example, where 5 is prefered to 2."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 55,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"(4, (Fin(0) | Inf(1)) & (Fin(2) | Inf(3)))\n",
|
||||
"0\n",
|
||||
"(0, spot.acc_cond(4, \"(Fin(0) | Inf(1)) & (Fin(2) | Inf(3))\"))\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"print(acc)\n",
|
||||
"print(acc.fin_one())\n",
|
||||
"print(acc.fin_one_extract())"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 56,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"(6, (Fin(0) & Inf(1)) | (Fin(2) & Inf(3)) | (Fin(4) & Inf(5)))\n",
|
||||
"0\n",
|
||||
"(0, spot.acc_cond(6, \"Fin(0) & Inf(1)\"))\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"acc2 = spot.acc_cond('Rabin 3')\n",
|
||||
"print(acc2)\n",
|
||||
"print(acc2.fin_one())\n",
|
||||
"print(acc2.fin_one_extract())"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 57,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"(6, (Inf(0) & (Fin(2) | Inf(3))) | (Inf(4) & Fin(5)) | ((Inf(0)&Inf(5)) & (Fin(0)|Fin(5))))\n",
|
||||
"2\n",
|
||||
"(5, spot.acc_cond(6, \"(Inf(4) & Fin(5)) | ((Inf(0)&Inf(5)) & (Fin(0)|Fin(5)))\"))\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"acc3 = spot.acc_cond('Inf(0)&(Fin(2)|Inf(3)) | Inf(4)&Fin(5) | Inf(0)&Inf(5)&(Fin(5)|Fin(0))')\n",
|
||||
"print(acc3)\n",
|
||||
"print(acc3.fin_one())\n",
|
||||
"print(acc3.fin_one_extract())"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
|
|
@ -1427,7 +1501,7 @@
|
|||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.7.3rc1"
|
||||
"version": "3.9.2"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue