twa: add accepting_run() and accepting_word() methods

Fixes #153.

* spot/twa/twa.cc, spot/twa/twa.hh: Add the methods.
* bin/autfilt.cc, bin/common_aoutput.hh, bin/ltlcross.cc,
tests/python/highlighting.ipynb, tests/python/word.ipynb: Use
them to simplify the code.
* NEWS: Mention them.
This commit is contained in:
Alexandre Duret-Lutz 2016-07-18 23:20:49 +02:00
parent 3836ea8d18
commit 014a9dbd6b
8 changed files with 145 additions and 71 deletions

View file

@ -1019,9 +1019,8 @@ namespace
if (aut->acc().uses_fin_acceptance())
error(2, 0,
"--highlight-word does not yet work with Fin acceptance");
if (auto res =
spot::couvreur99(spot::product(aut, word_aut.first))->check())
res->accepting_run()->project(aut)->highlight(word_aut.second);
if (auto run = spot::product(aut, word_aut.first)->accepting_run())
run->project(aut)->highlight(word_aut.second);
}
const double conversion_time = sw.stop();

View file

@ -178,15 +178,10 @@ public:
}
if (has('w'))
{
auto res = spot::couvreur99(aut)->check();
if (res)
if (auto word = aut->accepting_word())
{
auto run = res->accepting_run();
assert(run);
spot::twa_word w(run->reduce());
w.simplify();
std::ostringstream out;
out << w;
out << *word;
aut_word_ = out.str();
}
else

View file

@ -682,8 +682,8 @@ namespace
std::cerr << '\n';
}
auto res = spot::couvreur99(prod)->check();
if (res)
auto w = prod->accepting_word();
if (w)
{
std::ostream& err = global_error();
err << "error: ";
@ -695,24 +695,12 @@ namespace
err << "*Comp(P" << j << ')';
else
err << "*N" << j;
err << " is nonempty";
auto run = res->accepting_run();
if (run)
{
std::cerr << "; both automata accept the infinite word\n"
<< " ";
spot::twa_word w(run->reduce());
w.simplify();
example() << w << '\n';
}
else
{
std::cerr << '\n';
}
err << " is nonempty; both automata accept the infinite word\n"
<< " ";
example() << *w << '\n';
end_error();
}
return !!res;
return !!w;
}
static bool