From 33391798a39b6232a50340f15af951d0ca6a9c79 Mon Sep 17 00:00:00 2001 From: Alexandre Duret-Lutz Date: Fri, 22 Apr 2016 18:48:03 +0200 Subject: [PATCH] python: export tgba_determinize * python/spot/impl.i: Here. * tests/python/automata.ipynb: Use it. * NEWS: Mention it. --- NEWS | 4 + python/spot/impl.i | 2 + tests/python/automata.ipynb | 291 ++++++++++++++++++++++++++++++++---- 3 files changed, 270 insertions(+), 27 deletions(-) diff --git a/NEWS b/NEWS index b89c16983..2b0472c9a 100644 --- a/NEWS +++ b/NEWS @@ -24,6 +24,10 @@ New in spot 2.0a (not yet released) * Add missing documentation for the option string passed to spot::make_emptiness_check_instantiator(). + Python: + + * The tgba_determinize() function is now accessible in Python. + Bug fixes: * Typo in documentation of the -H option in --help output. diff --git a/python/spot/impl.i b/python/spot/impl.i index 2a1db01ff..cd895afbd 100644 --- a/python/spot/impl.i +++ b/python/spot/impl.i @@ -123,6 +123,7 @@ #include #include #include +#include #include #include #include @@ -428,6 +429,7 @@ namespace std { %include %include %include +%include %include %include %include diff --git a/tests/python/automata.ipynb b/tests/python/automata.ipynb index 8fda68e28..e470761ee 100644 --- a/tests/python/automata.ipynb +++ b/tests/python/automata.ipynb @@ -18,7 +18,7 @@ "version": "3.4.3+" }, "name": "", - "signature": "sha256:93ecf5f37287bb2a03dcd63d41faa06f0ed9d8bcc403c73b24d1bf10404b3b1c" + "signature": "sha256:29d335e40a65f0ca04a3b2b07bfcbf92f794407b413644546d957487dcbf4bb1" }, "nbformat": 3, "nbformat_minor": 0, @@ -178,7 +178,7 @@ "\n" ], "text": [ - " *' at 0x7f7cfc093810> >" + " *' at 0x7f09a8369240> >" ] } ], @@ -317,7 +317,7 @@ "" ], "text": [ - "" + "" ] } ], @@ -470,7 +470,7 @@ "" ], "text": [ - "" + "" ] } ], @@ -570,7 +570,7 @@ "\n" ], "text": [ - " *' at 0x7f7cef37ee10> >" + " *' at 0x7f09a8323fc0> >" ] } ], @@ -640,7 +640,7 @@ "\n" ], "text": [ - " *' at 0x7f7cef37ecc0> >" + " *' at 0x7f09a8323e70> >" ] } ], @@ -716,7 +716,7 @@ "\n" ], "text": [ - " *' at 0x7f7cef37ed50> >" + " *' at 0x7f09a8323f00> >" ] } ], @@ -839,7 +839,7 @@ "" ], "text": [ - "" + "" ] } ], @@ -1029,7 +1029,7 @@ "" ], "text": [ - "" + "" ] } ], @@ -1176,7 +1176,7 @@ "\n" ], "text": [ - " *' at 0x7f7cef37ef60> >" + " *' at 0x7f09a8323f30> >" ] } ], @@ -1277,7 +1277,7 @@ "\n" ], "text": [ - " *' at 0x7f7cef37ef30> >" + " *' at 0x7f098bff3210> >" ] } ], @@ -1395,7 +1395,7 @@ "\n" ], "text": [ - " *' at 0x7f7cef37ef00> >" + " *' at 0x7f098bff3240> >" ] } ], @@ -1494,7 +1494,7 @@ "\n" ], "text": [ - " *' at 0x7f7cef37ed20> >" + " *' at 0x7f098bff3270> >" ] } ], @@ -1964,7 +1964,7 @@ "\n" ], "text": [ - " *' at 0x7f7cef37ef90> >" + " *' at 0x7f09a8323ed0> >" ] } ], @@ -2161,7 +2161,7 @@ "" ], "text": [ - "" + "" ] }, { @@ -2286,7 +2286,7 @@ "" ], "text": [ - "" + "" ] }, { @@ -2428,7 +2428,7 @@ "" ], "text": [ - "" + "" ] }, { @@ -2579,7 +2579,7 @@ "\n" ], "text": [ - " *' at 0x7f7cef37ecf0> >" + " *' at 0x7f098bff33f0> >" ] } ], @@ -2735,7 +2735,7 @@ "\n" ], "text": [ - " *' at 0x7f7cef37eed0> >" + " *' at 0x7f09a8323c60> >" ] } ], @@ -2805,7 +2805,7 @@ "\n" ], "text": [ - " *' at 0x7f7cef37ecf0> >" + " *' at 0x7f098bff31b0> >" ] } ], @@ -2877,7 +2877,7 @@ "" ], "text": [ - "" + "" ] }, { @@ -2930,7 +2930,7 @@ "" ], "text": [ - "" + "" ] }, { @@ -3042,7 +3042,7 @@ "" ], "text": [ - "" + "" ] }, { @@ -3154,20 +3154,257 @@ "" ], "text": [ - "" + "" ] } ], "prompt_number": 23 }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Explicit determinization after translation:" + ] + }, { "cell_type": "code", "collapsed": true, - "input": [], + "input": [ + "a = spot.translate('FGa')\n", + "display(a)\n", + "display(a.is_deterministic())" + ], "language": "python", "metadata": {}, - "outputs": [], - "prompt_number": 23 + "outputs": [ + { + "metadata": {}, + "output_type": "display_data", + "svg": [ + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "G\n", + "\n", + "\n", + "\n", + "1\n", + "\n", + "1\n", + "\n", + "\n", + "I->1\n", + "\n", + "\n", + "\n", + "\n", + "1->1\n", + "\n", + "\n", + "1\n", + "\n", + "\n", + "0\n", + "\n", + "0\n", + "\n", + "\n", + "1->0\n", + "\n", + "\n", + "a\n", + "\n", + "\n", + "0->0\n", + "\n", + "\n", + "a\n", + "\u24ff\n", + "\n", + "\n", + "\n" + ], + "text": [ + " *' at 0x7f09a82ac5d0> >" + ] + }, + { + "metadata": {}, + "output_type": "display_data", + "text": [ + "False" + ] + } + ], + "prompt_number": 24 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "spot.tgba_determinize(a).show('.ba')" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "metadata": {}, + "output_type": "pyout", + "prompt_number": 25, + "svg": [ + "\n", + "\n", + "G\n", + "\n", + "Fin(\n", + "\u24ff\n", + ") & Inf(\n", + "\u2776\n", + ")\n", + "\n", + "\n", + "0\n", + "\n", + "0\n", + "\n", + "\n", + "I->0\n", + "\n", + "\n", + "\n", + "\n", + "0->0\n", + "\n", + "\n", + "!a\n", + "\n", + "\n", + "1\n", + "\n", + "1\n", + "\n", + "\n", + "0->1\n", + "\n", + "\n", + "a\n", + "\u2776\n", + "\n", + "\n", + "1->0\n", + "\n", + "\n", + "!a\n", + "\u24ff\n", + "\n", + "\n", + "1->1\n", + "\n", + "\n", + "a\n", + "\u2776\n", + "\n", + "\n", + "" + ], + "text": [ + "" + ] + } + ], + "prompt_number": 25 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Determinization by `translate()`. The `generic` option allows any acceptance condition to be used instead of the default generalized B\u00fcchi." + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "spot.translate('FGa', 'generic', 'deterministic')" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "metadata": {}, + "output_type": "pyout", + "prompt_number": 26, + "svg": [ + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "G\n", + "\n", + "\n", + "\n", + "0\n", + "\n", + "0\n", + "\n", + "\n", + "I->0\n", + "\n", + "\n", + "\n", + "\n", + "0->0\n", + "\n", + "\n", + "!a\n", + "\n", + "\n", + "1\n", + "\n", + "1\n", + "\n", + "\n", + "0->1\n", + "\n", + "\n", + "a\n", + "\u2776\n", + "\n", + "\n", + "1->0\n", + "\n", + "\n", + "!a\n", + "\u24ff\n", + "\n", + "\n", + "1->1\n", + "\n", + "\n", + "a\n", + "\u2776\n", + "\n", + "\n", + "\n" + ], + "text": [ + " *' at 0x7f09a82ac480> >" + ] + } + ], + "prompt_number": 26 } ], "metadata": {} -- GitLab