Add support for computing operator nesting depth
* spot/tl/hierarchy.hh, spot/tl/hierarchy.cc (nesting_depth): New function. * python/spot/__init__.py: Also make it a method of formula in Python * bin/common_output.cc, bin/common_output.hh: Implement --stats=%[OP]n. * NEWS: Mention it. * tests/core/format.test, tests/python/formulas.ipynb: Test it.
This commit is contained in:
parent
49b76bcf66
commit
62d1e0219d
8 changed files with 218 additions and 25 deletions
|
|
@ -23,21 +23,31 @@
|
|||
|
||||
set -e
|
||||
|
||||
genltl --dac=1..10 --stats='%s,%b,%x,%f' > output
|
||||
genltl --dac=1..10 --stats='%s,%b,%x,%f,%[G]n,%[FUM]n,%[~GUM]n' > output
|
||||
cat >expected <<EOF
|
||||
3,2,1,G!p0
|
||||
7,6,2,Fp0 -> (!p1 U p0)
|
||||
6,5,2,G(p0 -> G!p1)
|
||||
13,9,3,G((p0 & !p1 & Fp1) -> (!p2 U p1))
|
||||
10,6,3,G((p0 & !p1) -> (!p2 W p1))
|
||||
2,2,1,Fp0
|
||||
7,3,2,!p0 W (!p0 & p1)
|
||||
9,8,2,G!p0 | F(p0 & Fp1)
|
||||
13,6,3,G((p0 & !p1) -> (!p1 W (!p1 & p2)))
|
||||
13,6,3,G((p0 & !p1) -> (!p1 U (!p1 & p2)))
|
||||
3,2,1,G!p0,1,0,1
|
||||
7,6,2,Fp0 -> (!p1 U p0),0,1,1
|
||||
6,5,2,G(p0 -> G!p1),2,0,2
|
||||
13,9,3,G((p0 & !p1 & Fp1) -> (!p2 U p1)),1,1,2
|
||||
10,6,3,G((p0 & !p1) -> (!p2 W p1)),1,0,1
|
||||
2,2,1,Fp0,0,1,0
|
||||
7,3,2,!p0 W (!p0 & p1),0,0,0
|
||||
9,8,2,G!p0 | F(p0 & Fp1),1,2,1
|
||||
13,6,3,G((p0 & !p1) -> (!p1 W (!p1 & p2))),1,0,1
|
||||
13,6,3,G((p0 & !p1) -> (!p1 U (!p1 & p2))),1,1,2
|
||||
EOF
|
||||
diff output expected
|
||||
|
||||
genltl --dac --stats='%n' 2> stderr && exit 1
|
||||
cat stderr
|
||||
grep -F "genltl: %n expects arguments" stderr
|
||||
ltlfilt -f a --stats='%[]n' 2> stderr && exit 1
|
||||
cat stderr
|
||||
grep -F "ltlfilt: %n expects arguments" stderr
|
||||
randltl 2 --stats='%[;]n' 2> stderr && exit 1
|
||||
cat stderr
|
||||
grep "randltl: .*unknown.*;" stderr
|
||||
|
||||
genltl --dac | ltlfilt --output='ap-%x.ltl'
|
||||
test 4 = `wc -l<ap-1.ltl`
|
||||
test 10 = `wc -l<ap-2.ltl`
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.5.3rc1"
|
||||
"version": "3.6.4rc1"
|
||||
},
|
||||
"name": ""
|
||||
},
|
||||
|
|
@ -636,7 +636,7 @@
|
|||
{
|
||||
"metadata": {},
|
||||
"output_type": "pyout",
|
||||
"prompt_number": 22,
|
||||
"prompt_number": 18,
|
||||
"svg": [
|
||||
"<svg height=\"210\" version=\"1.1\" width=\"220\" xmlns=\"http://www.w3.org/2000/svg\">\n",
|
||||
"<polygon fill=\"cyan\" opacity=\".2\" points=\"20,0 200,120 200,210 20,210\"/>\n",
|
||||
|
|
@ -668,7 +668,7 @@
|
|||
]
|
||||
}
|
||||
],
|
||||
"prompt_number": 22
|
||||
"prompt_number": 18
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
|
|
@ -682,13 +682,13 @@
|
|||
{
|
||||
"metadata": {},
|
||||
"output_type": "pyout",
|
||||
"prompt_number": 24,
|
||||
"prompt_number": 19,
|
||||
"text": [
|
||||
"'recurrence'"
|
||||
]
|
||||
}
|
||||
],
|
||||
"prompt_number": 24
|
||||
"prompt_number": 19
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
|
|
@ -705,13 +705,13 @@
|
|||
],
|
||||
"metadata": {},
|
||||
"output_type": "pyout",
|
||||
"prompt_number": 18,
|
||||
"prompt_number": 20,
|
||||
"text": [
|
||||
"F(a & X(!a & b))"
|
||||
]
|
||||
}
|
||||
],
|
||||
"prompt_number": 18
|
||||
"prompt_number": 20
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
|
|
@ -735,13 +735,13 @@
|
|||
],
|
||||
"metadata": {},
|
||||
"output_type": "pyout",
|
||||
"prompt_number": 19,
|
||||
"prompt_number": 21,
|
||||
"text": [
|
||||
"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))))"
|
||||
]
|
||||
}
|
||||
],
|
||||
"prompt_number": 19
|
||||
"prompt_number": 21
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
|
|
@ -766,13 +766,13 @@
|
|||
],
|
||||
"metadata": {},
|
||||
"output_type": "pyout",
|
||||
"prompt_number": 20,
|
||||
"prompt_number": 22,
|
||||
"text": [
|
||||
"(0 R !(a <-> b)) -> (1 U (a <-> b))"
|
||||
]
|
||||
}
|
||||
],
|
||||
"prompt_number": 20
|
||||
"prompt_number": 22
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
|
|
@ -789,13 +789,51 @@
|
|||
],
|
||||
"metadata": {},
|
||||
"output_type": "pyout",
|
||||
"prompt_number": 21,
|
||||
"prompt_number": 23,
|
||||
"text": [
|
||||
"(1 U ((a & b) | (!a & !b))) | !(0 R ((!a & b) | (a & !b)))"
|
||||
]
|
||||
}
|
||||
],
|
||||
"prompt_number": 21
|
||||
"prompt_number": 23
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Nesting level of operators"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"collapsed": false,
|
||||
"input": [
|
||||
"f = spot.formula('F(b & X(a U b U ((a W Fb) | (c U d))))')\n",
|
||||
"print(\"U\", spot.nesting_depth(f, spot.op_U))\n",
|
||||
"print(\"F\", spot.nesting_depth(f, spot.op_F))\n",
|
||||
"# These following two are syntactic sugar for the above two\n",
|
||||
"print(\"U\", spot.nesting_depth(f, \"U\"))\n",
|
||||
"print(\"F\", spot.nesting_depth(f, \"F\"))\n",
|
||||
"# If you want to consider \"U\" and \"F\" are a similar type of\n",
|
||||
"# operator, you can count both with\n",
|
||||
"print(\"FU\", spot.nesting_depth(f, \"FU\"))"
|
||||
],
|
||||
"language": "python",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"output_type": "stream",
|
||||
"stream": "stdout",
|
||||
"text": [
|
||||
"U 3\n",
|
||||
"F 2\n",
|
||||
"U 3\n",
|
||||
"F 2\n",
|
||||
"FU 4\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"prompt_number": 24
|
||||
}
|
||||
],
|
||||
"metadata": {}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue