diff --git a/spot/tl/formula.hh b/spot/tl/formula.hh index 6dad5a318..f104bf496 100644 --- a/spot/tl/formula.hh +++ b/spot/tl/formula.hh @@ -799,6 +799,20 @@ namespace spot return formula(fnode::ap(name)); } + /// \brief Build an atomic proposition from... an atomic proposition. + /// + /// The only practical interest of this methods is for the Python + /// bindings, where ap() can therefore work both from string or + /// atomic propositions. + static formula ap(const formula& a) + { + if (a.kind() == op::ap) + return a; + else + throw std::invalid_argument("atomic propositions cannot be " + "constructed from arbitrary formulas"); + } + /// \brief Build a unary operator. /// \pre \a o should be one of op::Not, op::X, op::F, op::G, /// op::Closure, op::NegClosure, op::NegClosureMarked. diff --git a/tests/python/ltsmin.ipynb b/tests/python/ltsmin.ipynb index 2401b5f70..069a0c5e1 100644 --- a/tests/python/ltsmin.ipynb +++ b/tests/python/ltsmin.ipynb @@ -18,7 +18,7 @@ "version": "3.5.1" }, "name": "", - "signature": "sha256:0c10865a9a58374d983e19129ce565c14e590067c1eedf4f12dfe62fa3f58a02" + "signature": "sha256:d1444ee3c1e56aaa453ac171d129f0ba4486e1e194debc51965d45429a844334" }, "nbformat": 3, "nbformat_minor": 0, @@ -447,7 +447,7 @@ "\n" ], "text": [ - " *' at 0x7fda50a73c90> >" + " *' at 0x7f7b280d08a0> >" ] } ], @@ -726,7 +726,7 @@ "" ], "text": [ - "" + "" ] } ], @@ -1082,7 +1082,7 @@ "" ], "text": [ - "" + "" ] } ], @@ -1152,7 +1152,7 @@ "\n" ], "text": [ - " *' at 0x7fda58aa2270> >" + " *' at 0x7f7b2fcf8090> >" ] } ], @@ -1314,11 +1314,46 @@ "\n" ], "text": [ - " *' at 0x7fda50a736f0> >" + " *' at 0x7f7b280d08d0> >" ] } ], "prompt_number": 13 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def model_check(f, m):\n", + " f = spot.formula(f)\n", + " ss = m.kripke(spot.atomic_prop_collect(f))\n", + " nf = spot.formula_Not(f).translate()\n", + " return spot.otf_product(ss, nf).is_empty() " + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 14 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "model_check('\"a<1\" R \"b > 1\"', m)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "metadata": {}, + "output_type": "pyout", + "prompt_number": 15, + "text": [ + "False" + ] + } + ], + "prompt_number": 15 } ], "metadata": {}