genltl: add support for --sejk-f=n,m
Together with the previous patch, this Fixes #353. Implementing this required to extend our interface two support two-parameter patterns. * spot/gen/formulas.cc, spot/gen/formulas.hh: Implement it. * bin/genltl.cc: Add --sejk-f. * bin/common_output.cc, bin/common_output.hh: Adjust to handle "line numbers" that are not integers (e.g., "3,2"), since those are used to display pattern parameters. * bin/ltlfilt.cc: Adjust. * python/spot/gen.i: Add support for two-parameters patterns. * tests/core/genltl.test, tests/python/gen.ipynb: Augment. * NEWS: Mention it.
This commit is contained in:
parent
c76df95c69
commit
939f63eec9
10 changed files with 462 additions and 53 deletions
|
|
@ -24,7 +24,8 @@ set -e
|
|||
# Make sure the name of each pattern is correctly output by %F.
|
||||
opts=`genltl --help | sed -n '/=RANGE/{
|
||||
s/^ *//
|
||||
s/[=[].*/=1/p
|
||||
s/=RANGE\[\?,RANGE.*/=1,1/p
|
||||
s/\[\?=RANGE.*/=1/p
|
||||
}'`
|
||||
res=`genltl $opts --format="--%F=%L"`
|
||||
test "$opts" = "$res"
|
||||
|
|
@ -95,27 +96,38 @@ genltl --dac=1..5 --eh=1..5 >output2
|
|||
diff output output2
|
||||
|
||||
genltl --tv-f1=1:3 --tv-f2=1:3 --tv-g1=1:3 --tv-g2=1:3 --tv-uu=1:3 \
|
||||
--format=%F,%L,%f >output
|
||||
--sejk-f='0:2,0:3' --format='%F,"%L",%f' >output
|
||||
cat >expected <<EOF
|
||||
tv-f1,1,G(p -> q)
|
||||
tv-f1,2,G(p -> (q | Xq))
|
||||
tv-f1,3,G(p -> (q | Xq | XXq))
|
||||
tv-f2,1,G(p -> q)
|
||||
tv-f2,2,G(p -> (q | Xq))
|
||||
tv-f2,3,G(p -> (q | X(q | Xq)))
|
||||
tv-g1,1,G(p -> q)
|
||||
tv-g1,2,G(p -> (q & Xq))
|
||||
tv-g1,3,G(p -> (q & Xq & XXq))
|
||||
tv-g2,1,G(p -> q)
|
||||
tv-g2,2,G(p -> (q & Xq))
|
||||
tv-g2,3,G(p -> (q & X(q & Xq)))
|
||||
tv-uu,1,G(p1 -> (p1 U p2))
|
||||
tv-uu,2,G(p1 -> (p1 U (p2 & (p2 U p3))))
|
||||
tv-uu,3,G(p1 -> (p1 U (p2 & (p2 U (p3 & (p3 U p4))))))
|
||||
tv-f1,"1",G(p -> q)
|
||||
tv-f1,"2",G(p -> (q | Xq))
|
||||
tv-f1,"3",G(p -> (q | Xq | XXq))
|
||||
tv-f2,"1",G(p -> q)
|
||||
tv-f2,"2",G(p -> (q | Xq))
|
||||
tv-f2,"3",G(p -> (q | X(q | Xq)))
|
||||
tv-g1,"1",G(p -> q)
|
||||
tv-g1,"2",G(p -> (q & Xq))
|
||||
tv-g1,"3",G(p -> (q & Xq & XXq))
|
||||
tv-g2,"1",G(p -> q)
|
||||
tv-g2,"2",G(p -> (q & Xq))
|
||||
tv-g2,"3",G(p -> (q & X(q & Xq)))
|
||||
tv-uu,"1",G(p1 -> (p1 U p2))
|
||||
tv-uu,"2",G(p1 -> (p1 U (p2 & (p2 U p3))))
|
||||
tv-uu,"3",G(p1 -> (p1 U (p2 & (p2 U (p3 & (p3 U p4))))))
|
||||
sejk-f,"0,0",GFa0 U b
|
||||
sejk-f,"0,1",GFa0 U Xb
|
||||
sejk-f,"0,2",GFa0 U XXb
|
||||
sejk-f,"0,3",GFa0 U XXXb
|
||||
sejk-f,"1,0",GFa1 U G(GFa0 U b)
|
||||
sejk-f,"1,1",GFa1 U G(GFa0 U Xb)
|
||||
sejk-f,"1,2",GFa1 U G(GFa0 U XXb)
|
||||
sejk-f,"1,3",GFa1 U G(GFa0 U XXXb)
|
||||
sejk-f,"2,0",GFa2 U G(GFa1 U G(GFa0 U b))
|
||||
sejk-f,"2,1",GFa2 U G(GFa1 U G(GFa0 U Xb))
|
||||
sejk-f,"2,2",GFa2 U G(GFa1 U G(GFa0 U XXb))
|
||||
sejk-f,"2,3",GFa2 U G(GFa1 U G(GFa0 U XXXb))
|
||||
EOF
|
||||
diff output expected
|
||||
|
||||
|
||||
genltl --kr-n2=1..2 --kr-nlogn=1..2 --kr-n=1..2 --gxf-and=0..3 --fxg-or=0..3 \
|
||||
--format=%F=%L,%f |
|
||||
ltl2tgba --low --det -F-/2 --stats='%<,%s' > out
|
||||
|
|
|
|||
|
|
@ -295,6 +295,219 @@
|
|||
" display(f)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Some LTL patterns take two arguments. In this case, the arguments passed to `ltl_pattern()` should be one of:\n",
|
||||
"- `(id, n, m)` giving the value of both arguments,\n",
|
||||
"- `(id, min1, max1, min2, max2)` specifying a range for both arguments,\n",
|
||||
"- `(id, n)` equivalent to `(id, n, n)`,\n",
|
||||
"- `id` equivalent to `(id, 1, 3, 1, 3)`."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/latex": [
|
||||
"$\\mathsf{G} \\mathsf{F} a_{1} \\mathbin{\\mathsf{U}} \\mathsf{G} (\\mathsf{G} \\mathsf{F} a_{0} \\mathbin{\\mathsf{U}} \\mathsf{X} b)$"
|
||||
],
|
||||
"text/plain": [
|
||||
"GFa1 U G(GFa0 U Xb)"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/latex": [
|
||||
"$\\mathsf{G} \\mathsf{F} a_{1} \\mathbin{\\mathsf{U}} \\mathsf{G} (\\mathsf{G} \\mathsf{F} a_{0} \\mathbin{\\mathsf{U}} \\mathsf{X} \\mathsf{X} b)$"
|
||||
],
|
||||
"text/plain": [
|
||||
"GFa1 U G(GFa0 U XXb)"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/latex": [
|
||||
"$\\mathsf{G} \\mathsf{F} a_{1} \\mathbin{\\mathsf{U}} \\mathsf{G} (\\mathsf{G} \\mathsf{F} a_{0} \\mathbin{\\mathsf{U}} \\mathsf{X} \\mathsf{X} \\mathsf{X} b)$"
|
||||
],
|
||||
"text/plain": [
|
||||
"GFa1 U G(GFa0 U XXXb)"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/latex": [
|
||||
"$\\mathsf{G} \\mathsf{F} a_{2} \\mathbin{\\mathsf{U}} \\mathsf{G} (\\mathsf{G} \\mathsf{F} a_{1} \\mathbin{\\mathsf{U}} \\mathsf{G} (\\mathsf{G} \\mathsf{F} a_{0} \\mathbin{\\mathsf{U}} \\mathsf{X} b))$"
|
||||
],
|
||||
"text/plain": [
|
||||
"GFa2 U G(GFa1 U G(GFa0 U Xb))"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/latex": [
|
||||
"$\\mathsf{G} \\mathsf{F} a_{2} \\mathbin{\\mathsf{U}} \\mathsf{G} (\\mathsf{G} \\mathsf{F} a_{1} \\mathbin{\\mathsf{U}} \\mathsf{G} (\\mathsf{G} \\mathsf{F} a_{0} \\mathbin{\\mathsf{U}} \\mathsf{X} \\mathsf{X} b))$"
|
||||
],
|
||||
"text/plain": [
|
||||
"GFa2 U G(GFa1 U G(GFa0 U XXb))"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/latex": [
|
||||
"$\\mathsf{G} \\mathsf{F} a_{2} \\mathbin{\\mathsf{U}} \\mathsf{G} (\\mathsf{G} \\mathsf{F} a_{1} \\mathbin{\\mathsf{U}} \\mathsf{G} (\\mathsf{G} \\mathsf{F} a_{0} \\mathbin{\\mathsf{U}} \\mathsf{X} \\mathsf{X} \\mathsf{X} b))$"
|
||||
],
|
||||
"text/plain": [
|
||||
"GFa2 U G(GFa1 U G(GFa0 U XXXb))"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/latex": [
|
||||
"$\\mathsf{G} \\mathsf{F} a_{3} \\mathbin{\\mathsf{U}} \\mathsf{G} (\\mathsf{G} \\mathsf{F} a_{2} \\mathbin{\\mathsf{U}} \\mathsf{G} (\\mathsf{G} \\mathsf{F} a_{1} \\mathbin{\\mathsf{U}} \\mathsf{G} (\\mathsf{G} \\mathsf{F} a_{0} \\mathbin{\\mathsf{U}} \\mathsf{X} b)))$"
|
||||
],
|
||||
"text/plain": [
|
||||
"GFa3 U G(GFa2 U G(GFa1 U G(GFa0 U Xb)))"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/latex": [
|
||||
"$\\mathsf{G} \\mathsf{F} a_{3} \\mathbin{\\mathsf{U}} \\mathsf{G} (\\mathsf{G} \\mathsf{F} a_{2} \\mathbin{\\mathsf{U}} \\mathsf{G} (\\mathsf{G} \\mathsf{F} a_{1} \\mathbin{\\mathsf{U}} \\mathsf{G} (\\mathsf{G} \\mathsf{F} a_{0} \\mathbin{\\mathsf{U}} \\mathsf{X} \\mathsf{X} b)))$"
|
||||
],
|
||||
"text/plain": [
|
||||
"GFa3 U G(GFa2 U G(GFa1 U G(GFa0 U XXb)))"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/latex": [
|
||||
"$\\mathsf{G} \\mathsf{F} a_{3} \\mathbin{\\mathsf{U}} \\mathsf{G} (\\mathsf{G} \\mathsf{F} a_{2} \\mathbin{\\mathsf{U}} \\mathsf{G} (\\mathsf{G} \\mathsf{F} a_{1} \\mathbin{\\mathsf{U}} \\mathsf{G} (\\mathsf{G} \\mathsf{F} a_{0} \\mathbin{\\mathsf{U}} \\mathsf{X} \\mathsf{X} \\mathsf{X} b)))$"
|
||||
],
|
||||
"text/plain": [
|
||||
"GFa3 U G(GFa2 U G(GFa1 U G(GFa0 U XXXb)))"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"for f in sg.ltl_patterns(sg.LTL_SEJK_F):\n",
|
||||
" display(f)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 6,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/latex": [
|
||||
"$\\mathsf{G} \\mathsf{F} a_{2} \\mathbin{\\mathsf{U}} \\mathsf{G} (\\mathsf{G} \\mathsf{F} a_{1} \\mathbin{\\mathsf{U}} \\mathsf{G} (\\mathsf{G} \\mathsf{F} a_{0} \\mathbin{\\mathsf{U}} \\mathsf{X} \\mathsf{X} \\mathsf{X} b))$"
|
||||
],
|
||||
"text/plain": [
|
||||
"GFa2 U G(GFa1 U G(GFa0 U XXXb))"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/latex": [
|
||||
"$\\mathsf{G} \\mathsf{F} a_{2} \\mathbin{\\mathsf{U}} \\mathsf{G} (\\mathsf{G} \\mathsf{F} a_{1} \\mathbin{\\mathsf{U}} \\mathsf{G} (\\mathsf{G} \\mathsf{F} a_{0} \\mathbin{\\mathsf{U}} \\mathsf{X} \\mathsf{X} b))$"
|
||||
],
|
||||
"text/plain": [
|
||||
"GFa2 U G(GFa1 U G(GFa0 U XXb))"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/latex": [
|
||||
"$\\mathsf{G} \\mathsf{F} a_{1} \\mathbin{\\mathsf{U}} \\mathsf{G} (\\mathsf{G} \\mathsf{F} a_{0} \\mathbin{\\mathsf{U}} \\mathsf{X} b)$"
|
||||
],
|
||||
"text/plain": [
|
||||
"GFa1 U G(GFa0 U Xb)"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/latex": [
|
||||
"$\\mathsf{G} \\mathsf{F} a_{1} \\mathbin{\\mathsf{U}} \\mathsf{G} (\\mathsf{G} \\mathsf{F} a_{0} \\mathbin{\\mathsf{U}} \\mathsf{X} \\mathsf{X} b)$"
|
||||
],
|
||||
"text/plain": [
|
||||
"GFa1 U G(GFa0 U XXb)"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/latex": [
|
||||
"$\\mathsf{G} \\mathsf{F} a_{2} \\mathbin{\\mathsf{U}} \\mathsf{G} (\\mathsf{G} \\mathsf{F} a_{1} \\mathbin{\\mathsf{U}} \\mathsf{G} (\\mathsf{G} \\mathsf{F} a_{0} \\mathbin{\\mathsf{U}} \\mathsf{X} b))$"
|
||||
],
|
||||
"text/plain": [
|
||||
"GFa2 U G(GFa1 U G(GFa0 U Xb))"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/latex": [
|
||||
"$\\mathsf{G} \\mathsf{F} a_{2} \\mathbin{\\mathsf{U}} \\mathsf{G} (\\mathsf{G} \\mathsf{F} a_{1} \\mathbin{\\mathsf{U}} \\mathsf{G} (\\mathsf{G} \\mathsf{F} a_{0} \\mathbin{\\mathsf{U}} \\mathsf{X} \\mathsf{X} b))$"
|
||||
],
|
||||
"text/plain": [
|
||||
"GFa2 U G(GFa1 U G(GFa0 U XXb))"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"for f in sg.ltl_patterns((sg.LTL_SEJK_F, 2, 3), (sg.LTL_SEJK_F, 2), (sg.LTL_SEJK_F, 1, 2, 1, 2)):\n",
|
||||
" display(f)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
|
|
@ -306,7 +519,7 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"execution_count": 7,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
|
|
@ -977,7 +1190,7 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 6,
|
||||
"execution_count": 8,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue