python: more conventional __repr__ for several types
* NEWS: Mention the change. * python/spot/__init__.py: Add _repr_latex_ for twa_word, and remove __repr__ and __str__ for atomic_prop_set. * python/spot/impl.i: Implement __repr__ and __str__ for atomic_prop_set. Fix __repr__ for trival, acc_code, acc_cond, mark_t. Remove __repr__ for twa_run and twa_word. * tests/python/acc_cond.ipynb, tests/python/accparse.ipynb, tests/python/atva16-fig2a.ipynb, tests/python/automata.ipynb, tests/python/bdditer.py, tests/python/contains.ipynb, tests/python/gen.ipynb, tests/python/highlighting.ipynb, tests/python/ltlsimple.py, tests/python/ltsmin-dve.ipynb, tests/python/product.ipynb, tests/python/relabel.py, tests/python/satmin.ipynb tests/python/stutter-inv.ipynb, tests/python/word.ipynb: Adjust test cases. * tests/python/formulas.ipynb: Add test for atomic_prop_set.
This commit is contained in:
parent
c3b7a691e4
commit
60296317c7
19 changed files with 686 additions and 700 deletions
|
|
@ -14,7 +14,8 @@
|
|||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import spot"
|
||||
"import spot\n",
|
||||
"from IPython.display import display # not needed with recent Jupyter"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
|
@ -35,7 +36,7 @@
|
|||
"$p_{1} \\mathbin{\\mathsf{U}} (p_{2} \\mathbin{\\mathsf{R}} (p_{3} \\land \\lnot p_{4}))$"
|
||||
],
|
||||
"text/plain": [
|
||||
"p1 U (p2 R (p3 & !p4))"
|
||||
"spot.formula(\"p1 U (p2 R (p3 & !p4))\")"
|
||||
]
|
||||
},
|
||||
"execution_count": 2,
|
||||
|
|
@ -59,7 +60,7 @@
|
|||
"$\\{a \\mathbin{\\mathsf{;}} b^{\\star} \\mathbin{\\mathsf{;}} c^+\\}\\mathrel{\\Diamond\\kern-1.7pt\\raise.4pt\\hbox{$\\mathord{\\rightarrow}$}} \\mathsf{G} \\mathsf{F} b$"
|
||||
],
|
||||
"text/plain": [
|
||||
"{a;b[*];c[+]}<>-> GFb"
|
||||
"spot.formula(\"{a;b[*];c[+]}<>-> GFb\")"
|
||||
]
|
||||
},
|
||||
"execution_count": 3,
|
||||
|
|
@ -89,7 +90,7 @@
|
|||
"$c \\land (a \\lor b)$"
|
||||
],
|
||||
"text/plain": [
|
||||
"c & (a | b)"
|
||||
"spot.formula(\"c & (a | b)\")"
|
||||
]
|
||||
},
|
||||
"execution_count": 4,
|
||||
|
|
@ -119,7 +120,7 @@
|
|||
"$c \\land (a \\lor b)$"
|
||||
],
|
||||
"text/plain": [
|
||||
"c & (a | b)"
|
||||
"spot.formula(\"c & (a | b)\")"
|
||||
]
|
||||
},
|
||||
"execution_count": 5,
|
||||
|
|
@ -422,7 +423,7 @@
|
|||
"$\\unicode{x201C}\\mathit{a > b}\\unicode{x201D} \\land \\unicode{x201C}\\mathit{proc[2]@init}\\unicode{x201D} \\land \\mathsf{G} \\mathsf{F} \\mathit{\\_foo\\_}$"
|
||||
],
|
||||
"text/plain": [
|
||||
"\"a > b\" & \"proc[2]@init\" & GF_foo_"
|
||||
"spot.formula(\"\\\"a > b\\\" & \\\"proc[2]@init\\\" & GF_foo_\")"
|
||||
]
|
||||
},
|
||||
"execution_count": 15,
|
||||
|
|
@ -445,7 +446,7 @@
|
|||
"$a \\land b \\land \\mathsf{G} \\mathsf{F} c$"
|
||||
],
|
||||
"text/plain": [
|
||||
"a & b & GFc"
|
||||
"spot.formula(\"a & b & GFc\")"
|
||||
]
|
||||
},
|
||||
"execution_count": 16,
|
||||
|
|
@ -468,7 +469,7 @@
|
|||
"$p_{0} \\land p_{1} \\land \\mathsf{G} \\mathsf{F} p_{2}$"
|
||||
],
|
||||
"text/plain": [
|
||||
"p0 & p1 & GFp2"
|
||||
"spot.formula(\"p0 & p1 & GFp2\")"
|
||||
]
|
||||
},
|
||||
"execution_count": 17,
|
||||
|
|
@ -719,7 +720,7 @@
|
|||
"$\\mathsf{F} (a \\land \\mathsf{X} (\\lnot a \\land b))$"
|
||||
],
|
||||
"text/plain": [
|
||||
"F(a & X(!a & b))"
|
||||
"spot.formula(\"F(a & X(!a & b))\")"
|
||||
]
|
||||
},
|
||||
"execution_count": 21,
|
||||
|
|
@ -749,7 +750,7 @@
|
|||
"$\\mathsf{F} (a \\land ((a \\land (a \\mathbin{\\mathsf{U}} (\\lnot a \\land b)) \\land ((\\lnot b \\mathbin{\\mathsf{U}} \\lnot a) \\lor (b \\mathbin{\\mathsf{U}} \\lnot a))) \\lor (\\lnot a \\land (\\lnot a \\mathbin{\\mathsf{U}} (a \\land \\lnot a \\land b)) \\land ((\\lnot b \\mathbin{\\mathsf{U}} a) \\lor (b \\mathbin{\\mathsf{U}} a))) \\lor (b \\land (b \\mathbin{\\mathsf{U}} (\\lnot a \\land b \\land \\lnot b)) \\land ((\\lnot a \\mathbin{\\mathsf{U}} \\lnot b) \\lor (a \\mathbin{\\mathsf{U}} \\lnot b))) \\lor (\\lnot b \\land (\\lnot b \\mathbin{\\mathsf{U}} (\\lnot a \\land b)) \\land ((\\lnot a \\mathbin{\\mathsf{U}} b) \\lor (a \\mathbin{\\mathsf{U}} b))) \\lor (\\lnot a \\land b \\land (\\mathsf{G} \\lnot a \\lor \\mathsf{G} a) \\land (\\mathsf{G} \\lnot b \\lor \\mathsf{G} b))))$"
|
||||
],
|
||||
"text/plain": [
|
||||
"F(a & ((a & (a U (!a & b)) & ((!b U !a) | (b U !a))) | (!a & (!a U (a & !a & b)) & ((!b U a) | (b U a))) | (b & (b U (!a & b & !b)) & ((!a U !b) | (a U !b))) | (!b & (!b U (!a & b)) & ((!a U b) | (a U b))) | (!a & b & (G!a | Ga) & (G!b | Gb))))"
|
||||
"spot.formula(\"F(a & ((a & (a U (!a & b)) & ((!b U !a) | (b U !a))) | (!a & (!a U (a & !a & b)) & ((!b U a) | (b U a))) | (b & (b U (!a & b & !b)) & ((!a U !b) | (a U !b))) | (!b & (!b U (!a & b)) & ((!a U b) | (a U b))) | (!a & b & (G!a | Ga) & (G!b | Gb))))\")"
|
||||
]
|
||||
},
|
||||
"execution_count": 22,
|
||||
|
|
@ -779,7 +780,7 @@
|
|||
"$(\\bot \\mathbin{\\mathsf{R}} \\lnot (a \\leftrightarrow b)) \\rightarrow (\\top \\mathbin{\\mathsf{U}} (a \\leftrightarrow b))$"
|
||||
],
|
||||
"text/plain": [
|
||||
"(0 R !(a <-> b)) -> (1 U (a <-> b))"
|
||||
"spot.formula(\"(0 R !(a <-> b)) -> (1 U (a <-> b))\")"
|
||||
]
|
||||
},
|
||||
"execution_count": 23,
|
||||
|
|
@ -803,7 +804,7 @@
|
|||
"$(\\top \\mathbin{\\mathsf{U}} ((a \\land b) \\lor (\\lnot a \\land \\lnot b))) \\lor \\lnot (\\bot \\mathbin{\\mathsf{R}} ((\\lnot a \\land b) \\lor (a \\land \\lnot b)))$"
|
||||
],
|
||||
"text/plain": [
|
||||
"(1 U ((a & b) | (!a & !b))) | !(0 R ((!a & b) | (a & !b)))"
|
||||
"spot.formula(\"(1 U ((a & b) | (!a & !b))) | !(0 R ((!a & b) | (a & !b)))\")"
|
||||
]
|
||||
},
|
||||
"execution_count": 24,
|
||||
|
|
@ -850,6 +851,46 @@
|
|||
"# operator, you can count both with\n",
|
||||
"print(\"FU\", spot.nesting_depth(f, \"FU\"))"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Collecting the set of atomic propositions used by a formula:"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 26,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"spot.atomic_prop_set([spot.formula(\"a\"), spot.formula(\"b\"), spot.formula(\"c\"), spot.formula(\"d\")])\n",
|
||||
"{\"a\", \"b\", \"c\", \"d\"}\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/latex": [
|
||||
"$\\{\\unicode{x201C}a\\unicode{x201D}, \\unicode{x201C}b\\unicode{x201D}, \\unicode{x201C}c\\unicode{x201D}, \\unicode{x201C}d\\unicode{x201D}\\}$"
|
||||
],
|
||||
"text/plain": [
|
||||
"spot.atomic_prop_set([spot.formula(\"a\"), spot.formula(\"b\"), spot.formula(\"c\"), spot.formula(\"d\")])"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"ap = spot.atomic_prop_collect(f)\n",
|
||||
"print(repr(ap)) # print as an atomic_prop_set object\n",
|
||||
"print(ap) # print as a string\n",
|
||||
"display(ap) # LaTeX-style, for notebooks"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
|
|
@ -868,7 +909,7 @@
|
|||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.6.5"
|
||||
"version": "3.6.7"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue