Commit b83d6d7f authored by Alexandre Duret-Lutz's avatar Alexandre Duret-Lutz
Browse files

autfilt: %w shows an accepting word

* src/bin/autfilt.cc: Support %w.
* src/tgbatest/readsave.test: Test it.
parent a626a32d
......@@ -49,6 +49,9 @@
#include "hoaparse/public.hh"
#include "tgbaalgos/sccinfo.hh"
#include "tgbaalgos/randomize.hh"
#include "tgbaalgos/gtec/gtec.hh"
#include "tgbaalgos/reducerun.hh"
#include "tgbaalgos/word.hh"
#include "tgbaalgos/are_isomorphic.hh"
......@@ -144,6 +147,8 @@ static const argp_option options[] =
"1 if the output is complete, 0 otherwise", 0 },
{ "%r", 0, 0, OPTION_DOC | OPTION_NO_USAGE,
"processing time (excluding parsing) in seconds", 0 },
{ "%w", 0, 0, OPTION_DOC | OPTION_NO_USAGE,
"one word accepted by the output automaton", 0 },
{ "%%", 0, 0, OPTION_DOC | OPTION_NO_USAGE,
"a single %", 0 },
/**************************************************/
......@@ -427,6 +432,7 @@ namespace
declare('m', &aut_name_);
declare('S', &haut_states_);
declare('T', &haut_trans_);
declare('w', &aut_word_);
}
/// \brief print the configured statistics.
......@@ -481,6 +487,26 @@ namespace
if (has('C'))
haut_scc_ = spot::scc_info(haut->aut).scc_count();
if (has('w'))
{
auto res = spot::couvreur99(aut)->check();
if (res)
{
auto run = res->accepting_run();
assert(run);
run = reduce_run(aut, run);
spot::tgba_word w(run);
w.simplify();
std::ostringstream out;
w.print(out, aut->get_dict());
aut_word_ = out.str();
}
else
{
aut_word_.val().clear();
}
}
return this->spot::stat_printer::print(aut, 0, run_time);
}
......@@ -488,6 +514,7 @@ namespace
spot::printable_value<const char*> filename_;
spot::printable_value<std::string> haut_name_;
spot::printable_value<std::string> aut_name_;
spot::printable_value<std::string> aut_word_;
spot::printable_value<unsigned> haut_states_;
spot::printable_value<unsigned> haut_edges_;
spot::printable_value<unsigned> haut_trans_;
......
......@@ -270,3 +270,17 @@ EOF
$autfilt --merge -Hm input --name="%E->%e edges, %T->%t transitions" > output
diff output expected
cat <<EOF | $ltl2tgba -x degen-skip=1 -F- --ba -H > tmp.hoa
a U b
false
!b && Xb && GFa
EOF
$autfilt <tmp.hoa --stats='"%M","%w"' > output
cat >expected <<EOF
"a U b","cycle{b}"
"0",""
"!b & X(b & GFa)","!b; cycle{a & b}"
EOF
diff output expected
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment