dstar: implement dra_to_dba()
This is an implementation of Krishnan's ISAAC'94 paper to convert deterministic Rabin automata into DBA when possible. * src/dstarparse/dra2dba.cc: New file. * src/dstarparse/dstar2tgba.cc: New file. * src/dstarparse/Makefile.am: Add them. * src/dstarparse/nra2nba.cc (nra_to_nba): Adjust so that dra_to_dba() can call it using a masked automaton. * src/dstarparse/public.hh (dra_to_dba, dstar_to_tgba): Declare. * src/tgbatest/ltl2tgba.cc: Add an -XDD option. * src/tgbatest/dstar.test: More tests.
This commit is contained in:
parent
ce0aec604c
commit
9a7590a646
7 changed files with 516 additions and 23 deletions
|
|
@ -25,6 +25,9 @@
|
|||
. ./defs
|
||||
set -e
|
||||
|
||||
|
||||
# DRA generated with
|
||||
# ltlfilt -f 'a U b' -l | ltl2dstar --ltl2nba=spin:path/ltl2tgba@-s - -
|
||||
cat >dra.dstar <<EOF
|
||||
DRA v2 explicit
|
||||
Comment: "Safra[NBA=2]"
|
||||
|
|
@ -72,6 +75,28 @@ EOF
|
|||
|
||||
diff expected stdout
|
||||
|
||||
|
||||
run 0 ../ltl2tgba -XDD dra.dstar | tee stdout
|
||||
|
||||
cat >expected <<EOF
|
||||
digraph G {
|
||||
0 [label="", style=invis, height=0]
|
||||
0 -> 1
|
||||
1 [label="1"]
|
||||
1 -> 1 [label="a & !b\n"]
|
||||
1 -> 2 [label="b\n"]
|
||||
2 [label="3", peripheries=2]
|
||||
2 -> 2 [label="1\n{Acc[1]}"]
|
||||
}
|
||||
EOF
|
||||
|
||||
diff expected stdout
|
||||
|
||||
|
||||
|
||||
# DSA generated with
|
||||
# ltlfilt -f 'FGa' -l |
|
||||
# ltl2dstar --automata=streett --ltl2nba=spin:path/ltl2tgba@-s - -
|
||||
cat >dsa.dstar <<EOF
|
||||
DSA v2 explicit
|
||||
Comment: "Streett{Safra[NBA=2]}"
|
||||
|
|
@ -129,3 +154,82 @@ digraph G {
|
|||
EOF
|
||||
|
||||
diff expected stdout
|
||||
|
||||
|
||||
|
||||
|
||||
# DRA generated with
|
||||
# ltlfilt -f 'Ga | Fb' -l | ltl2dstar --ltl2nba=spin:path/ltl2tgba@-sD - -
|
||||
# (State name and comments added by hand to test the parser.)
|
||||
cat >dra.dstar <<EOF
|
||||
DRA v2 explicit
|
||||
Comment: "Union{Safra[NBA=1],Safra[NBA=2]}"
|
||||
States: 5
|
||||
Acceptance-Pairs: 2
|
||||
Start: 0
|
||||
AP: 2 "a" "b"
|
||||
---
|
||||
State: 0 "bla"
|
||||
Acc-Sig:
|
||||
1
|
||||
2 /* This is a comment */
|
||||
3
|
||||
4
|
||||
State: 1 "foo"
|
||||
Acc-Sig: -0
|
||||
1
|
||||
1 // This is another comment.
|
||||
3
|
||||
3
|
||||
State: 2 "baz"
|
||||
Acc-Sig: +0
|
||||
1
|
||||
2
|
||||
// more
|
||||
/// comment
|
||||
3
|
||||
4
|
||||
State: 3 "str\n\"ing"
|
||||
Acc-Sig: -0 +1
|
||||
3 /***
|
||||
**** Some multiline comment
|
||||
***/
|
||||
3
|
||||
3
|
||||
3
|
||||
State: 4 "more\"string\""
|
||||
Acc-Sig: +0 +1
|
||||
3
|
||||
4
|
||||
3
|
||||
4
|
||||
EOF
|
||||
|
||||
run 0 ../ltl2tgba -XDD dra.dstar | tee stdout
|
||||
|
||||
cat >expected <<EOF
|
||||
digraph G {
|
||||
0 [label="", style=invis, height=0]
|
||||
0 -> 1
|
||||
1 [label="1"]
|
||||
1 -> 2 [label="!a & !b\n"]
|
||||
1 -> 3 [label="a & !b\n"]
|
||||
1 -> 4 [label="b & !a\n"]
|
||||
1 -> 5 [label="a & b\n"]
|
||||
2 [label="2"]
|
||||
2 -> 2 [label="!b\n"]
|
||||
2 -> 4 [label="b\n"]
|
||||
3 [label="3", peripheries=2]
|
||||
3 -> 2 [label="!a & !b\n{Acc[1]}"]
|
||||
3 -> 3 [label="a & !b\n{Acc[1]}"]
|
||||
3 -> 4 [label="b & !a\n{Acc[1]}"]
|
||||
3 -> 5 [label="a & b\n{Acc[1]}"]
|
||||
4 [label="4", peripheries=2]
|
||||
4 -> 4 [label="1\n{Acc[1]}"]
|
||||
5 [label="5", peripheries=2]
|
||||
5 -> 4 [label="!a\n{Acc[1]}"]
|
||||
5 -> 5 [label="a\n{Acc[1]}"]
|
||||
}
|
||||
EOF
|
||||
|
||||
diff expected stdout
|
||||
|
|
|
|||
|
|
@ -124,6 +124,8 @@ syntax(char* prog)
|
|||
<< " ltl2dstar file" << std::endl
|
||||
<< " -XDB read the from an ltl2dstar file and convert it to "
|
||||
<< "TGBA" << std::endl
|
||||
<< " -XDD read the from an ltl2dstar file and convert it to "
|
||||
<< "TGBA,\n keeping it deterministic when possible\n"
|
||||
<< " -XL do not compute an automaton, read it from an"
|
||||
<< " LBTT file" << std::endl
|
||||
<< " -XN do not compute an automaton, read it from a"
|
||||
|
|
@ -368,6 +370,7 @@ main(int argc, char** argv)
|
|||
bool from_file = false;
|
||||
enum { ReadSpot, ReadLbtt, ReadNeverclaim, ReadDstar } readformat = ReadSpot;
|
||||
bool nra2nba = false;
|
||||
bool dra2dba = false;
|
||||
bool scc_filter = false;
|
||||
bool simpltl = false;
|
||||
spot::ltl::ltl_simplifier_options redopt(false, false, false, false,
|
||||
|
|
@ -917,6 +920,13 @@ main(int argc, char** argv)
|
|||
readformat = ReadDstar;
|
||||
nra2nba = true;
|
||||
}
|
||||
else if (!strcmp(argv[formula_index], "-XDD"))
|
||||
{
|
||||
from_file = true;
|
||||
readformat = ReadDstar;
|
||||
nra2nba = true;
|
||||
dra2dba = true;
|
||||
}
|
||||
else if (!strcmp(argv[formula_index], "-XL"))
|
||||
{
|
||||
from_file = true;
|
||||
|
|
@ -1104,11 +1114,22 @@ main(int argc, char** argv)
|
|||
spot::dstar_aut* daut;
|
||||
daut = spot::dstar_parse(input, pel, dict,
|
||||
env, debug_opt);
|
||||
tm.stop("parsing dstar");
|
||||
if (spot::format_dstar_parse_errors(std::cerr, input, pel))
|
||||
{
|
||||
delete to_free;
|
||||
delete dict;
|
||||
return 2;
|
||||
}
|
||||
tm.start("dstar2tgba");
|
||||
if (nra2nba)
|
||||
{
|
||||
if (daut->type == spot::Rabin)
|
||||
{
|
||||
to_free = a = spot::nra_to_nba(daut);
|
||||
if (dra2dba)
|
||||
to_free = a = spot::dstar_to_tgba(daut);
|
||||
else
|
||||
to_free = a = spot::nra_to_nba(daut);
|
||||
assume_sba = true;
|
||||
}
|
||||
else
|
||||
|
|
@ -1123,14 +1144,8 @@ main(int argc, char** argv)
|
|||
daut->aut = 0;
|
||||
assume_sba = false;
|
||||
}
|
||||
tm.stop("dstar2tgba");
|
||||
delete daut;
|
||||
tm.stop("parsing dstar");
|
||||
if (spot::format_dstar_parse_errors(std::cerr, input, pel))
|
||||
{
|
||||
delete to_free;
|
||||
delete dict;
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue