diff --git a/NEWS b/NEWS index fb9e30850..3bfcd22b7 100644 --- a/NEWS +++ b/NEWS @@ -6,7 +6,7 @@ New in spot 1.99.7a (not yet released) exception instead of using an assertion that could be disabled. * The load_ltsmin() function has been split in two. Now you should - first call ltsmin_model::load(filename) to create an ltlmin_model, + first call ltsmin_model::load(filename) to create an ltsmin_model, and then call the ltsmin_model::kripke(...) method to create an automaton that can be iterated on the fly. The intermediate object can be queried about the supported variables and their @@ -23,6 +23,9 @@ New in spot 1.99.7a (not yet released) possible. This is similar to the "k" option already supported by print_hoa(), and is useful when printing Kripke structures. + * Option "k" is automatically passed used by print_dot() and + print_hoa() when printing Kripke structures. + Python: * The ltsmin interface has been binded in Python. See diff --git a/spot/twaalgos/dot.cc b/spot/twaalgos/dot.cc index 5d0f98b0d..44d30f2eb 100644 --- a/spot/twaalgos/dot.cc +++ b/spot/twaalgos/dot.cc @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -663,6 +664,9 @@ namespace spot const char* options) { dotty_output d(os, options); + // Enable automatic state labels for Kripke structure. + if (std::dynamic_pointer_cast(g)) + d.parse_opts("k"); auto aut = std::dynamic_pointer_cast(g); if (!aut || (d.max_states_given() && aut->num_states() >= d.max_states())) aut = copy(g, twa::prop_set::all(), true, d.max_states() - 1); diff --git a/spot/twaalgos/hoa.cc b/spot/twaalgos/hoa.cc index b2e7e7c77..ac5eafe99 100644 --- a/spot/twaalgos/hoa.cc +++ b/spot/twaalgos/hoa.cc @@ -33,6 +33,7 @@ #include #include #include +#include namespace spot { @@ -575,15 +576,28 @@ namespace spot std::ostream& print_hoa(std::ostream& os, - const const_twa_ptr& aut, - const char* opt) + const const_twa_ptr& aut, + const char* opt) { auto a = std::dynamic_pointer_cast(aut); if (!a) a = make_twa_graph(aut, twa::prop_set::all()); - return print_hoa(os, a, opt); + // for Kripke structures, automatically append "k" to the options. + char* tmpopt = nullptr; + if (std::dynamic_pointer_cast(aut)) + { + unsigned n = opt ? strlen(opt) : 0; + tmpopt = new char[n + 2]; + if (opt) + strcpy(tmpopt, opt); + tmpopt[n] = 'k'; + tmpopt[n + 1] = 0; + } + print_hoa(os, a, tmpopt ? tmpopt : opt); + delete[] tmpopt; + return os; } } diff --git a/tests/core/parse_print_test.cc b/tests/core/parse_print_test.cc index 5b6dcb1c0..272451bd9 100644 --- a/tests/core/parse_print_test.cc +++ b/tests/core/parse_print_test.cc @@ -44,7 +44,7 @@ int main(int argc, char** argv) } if (!paut->ks) break; - print_hoa(std::cout, paut->ks, "k"); + print_hoa(std::cout, paut->ks); } return return_value; } diff --git a/tests/ltsmin/modelcheck.cc b/tests/ltsmin/modelcheck.cc index ed81b09e7..69b315cc9 100644 --- a/tests/ltsmin/modelcheck.cc +++ b/tests/ltsmin/modelcheck.cc @@ -243,7 +243,7 @@ checked_main(int argc, char **argv) if (output == Kripke) { tm.start("kripke output"); - spot::print_hoa(std::cout, model, "k"); + spot::print_hoa(std::cout, model); tm.stop("kripke output"); goto safe_exit; } diff --git a/tests/python/ltsmin.ipynb b/tests/python/ltsmin.ipynb index 79ea17038..a4b291568 100644 --- a/tests/python/ltsmin.ipynb +++ b/tests/python/ltsmin.ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:984524909cc32e22143f3480e43c1951947d6885bf691c3b694cf0fd1b6b81d9" + "signature": "sha256:fa0fbee36e16c4615d30141ace5f7aa76009d478e4a4e2b088b6093b25f8bc69" }, "nbformat": 3, "nbformat_minor": 0, @@ -162,7 +162,7 @@ "collapsed": false, "input": [ "k = m.kripke([\"a<1\", \"b>2\"])\n", - "k.show('.k')" + "k" ], "language": "python", "metadata": {}, @@ -172,186 +172,193 @@ "output_type": "pyout", "prompt_number": 6, "svg": [ - "\n", - "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", "G\n", - "\n", + "\n", "\n", "\n", - "0\n", - "\n", - "a=0, b=0, Q=0\n", - ""a<1" & !"b>2" & !dead\n", + "0\n", + "\n", + "a=0, b=0, Q=0\n", + ""a<1" & !"b>2" & !dead\n", "\n", "\n", - "I->0\n", - "\n", - "\n", + "I->0\n", + "\n", + "\n", "\n", "\n", - "1\n", - "\n", - "a=1, b=0, Q=0\n", - "!"a<1" & !"b>2" & !dead\n", + "1\n", + "\n", + "a=1, b=0, Q=0\n", + "!"a<1" & !"b>2" & !dead\n", "\n", "\n", - "0->1\n", - "\n", - "\n", + "0->1\n", + "\n", + "\n", "\n", "\n", - "2\n", - "\n", - "a=0, b=1, Q=0\n", - ""a<1" & !"b>2" & !dead\n", + "2\n", + "\n", + "a=0, b=1, Q=0\n", + ""a<1" & !"b>2" & !dead\n", "\n", "\n", - "0->2\n", - "\n", - "\n", + "0->2\n", + "\n", + "\n", "\n", "\n", - "3\n", - "\n", - "a=2, b=0, Q=0\n", - "!"a<1" & !"b>2" & !dead\n", + "3\n", + "\n", + "a=2, b=0, Q=0\n", + "!"a<1" & !"b>2" & !dead\n", "\n", "\n", - "1->3\n", - "\n", - "\n", + "1->3\n", + "\n", + "\n", "\n", "\n", - "4\n", - "\n", - "a=1, b=1, Q=0\n", - "!"a<1" & !"b>2" & !dead\n", + "4\n", + "\n", + "a=1, b=1, Q=0\n", + "!"a<1" & !"b>2" & !dead\n", "\n", "\n", - "1->4\n", - "\n", - "\n", + "1->4\n", + "\n", + "\n", "\n", "\n", - "2->4\n", - "\n", - "\n", + "2->4\n", + "\n", + "\n", "\n", "\n", - "5\n", - "\n", - "a=0, b=2, Q=0\n", - ""a<1" & !"b>2" & !dead\n", + "5\n", + "\n", + "a=0, b=2, Q=0\n", + ""a<1" & !"b>2" & !dead\n", "\n", "\n", - "2->5\n", - "\n", - "\n", + "2->5\n", + "\n", + "\n", "\n", "\n", - "6\n", - "\n", - "a=3, b=0, Q=0\n", - "!"a<1" & !"b>2" & dead\n", + "6\n", + "\n", + "a=3, b=0, Q=0\n", + "!"a<1" & !"b>2" & dead\n", "\n", "\n", - "3->6\n", - "\n", - "\n", + "3->6\n", + "\n", + "\n", "\n", "\n", - "7\n", - "\n", - "a=2, b=1, Q=0\n", - "...\n", + "7\n", + "\n", + "a=2, b=1, Q=0\n", + "...\n", "\n", "\n", - "3->7\n", - "\n", - "\n", + "3->7\n", + "\n", + "\n", "\n", "\n", - "4->7\n", - "\n", - "\n", + "4->7\n", + "\n", + "\n", "\n", "\n", - "8\n", - "\n", - "a=1, b=2, Q=0\n", - "...\n", + "8\n", + "\n", + "a=1, b=2, Q=0\n", + "...\n", "\n", "\n", - "4->8\n", - "\n", - "\n", + "4->8\n", + "\n", + "\n", "\n", "\n", - "5->8\n", - "\n", - "\n", + "5->8\n", + "\n", + "\n", "\n", "\n", - "u5\n", - "\n", - "...\n", + "u5\n", + "\n", + "...\n", "\n", "\n", - "5->u5\n", - "\n", - "\n", + "5->u5\n", + "\n", + "\n", "\n", "\n", - "9\n", - "\n", - "a=0, b=3, Q=0\n", - "...\n", + "9\n", + "\n", + "a=0, b=3, Q=0\n", + "...\n", "\n", "\n", - "5->9\n", - "\n", - "\n", + "5->9\n", + "\n", + "\n", "\n", "\n", - "6->6\n", - "\n", - "\n", + "6->6\n", + "\n", + "\n", "\n", "\n", - "u7\n", - "\n", - "...\n", + "u7\n", + "\n", + "...\n", "\n", "\n", - "7->u7\n", - "\n", - "\n", + "7->u7\n", + "\n", + "\n", "\n", "\n", - "u8\n", - "\n", - "...\n", + "u8\n", + "\n", + "...\n", "\n", "\n", - "8->u8\n", - "\n", - "\n", + "8->u8\n", + "\n", + "\n", "\n", "\n", - "u9\n", - "\n", - "...\n", + "u9\n", + "\n", + "...\n", "\n", "\n", - "9->u9\n", - "\n", - "\n", + "9->u9\n", + "\n", + "\n", "\n", "\n", - "" + "\n" ], "text": [ - "" + " *' at 0x7f6211db0600> >" ] } ], @@ -361,7 +368,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "k.show('.k<15')" + "k.show('.<15')" ], "language": "python", "metadata": {}, @@ -630,7 +637,7 @@ "" ], "text": [ - "" + "" ] } ], @@ -640,7 +647,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "k.show('.k<0') # unlimited output" + "k.show('.<0') # unlimited output" ], "language": "python", "metadata": {}, @@ -986,7 +993,7 @@ "" ], "text": [ - "" + "" ] } ], @@ -1056,7 +1063,7 @@ "\n" ], "text": [ - " *' at 0x7f9e12e0b060> >" + " *' at 0x7f621de1c2d0> >" ] } ], @@ -1218,7 +1225,7 @@ "\n" ], "text": [ - " *' at 0x7f9dfed0bf30> >" + " *' at 0x7f6211db0cc0> >" ] } ], @@ -1230,7 +1237,8 @@ "input": [], "language": "python", "metadata": {}, - "outputs": [] + "outputs": [], + "prompt_number": 10 } ], "metadata": {}