This implements Couvreur's FM'99 ltl2tgba translation.
* src/tgba/bdddict.cc (bdd_dict::is_registered): Split as ... (bdd_dict::is_registered_proposition, bdd_dict::is_registered_state, bdd_dict::is_registered_accepting_variable): ... these. * src/tgba/bdddict.hh: Likewise. * src/tgba/tgbaexplicit.cc (tgba_explicit::set_init_state): New method. (tgba_explicit::declare_accepting_condition): Arrange so that this function can be called during the construction of the automaton. (tgba_explicit::complement_all_accepting_conditions): New method. (tgba_explicit::has_accepting_condition): Adjust to call bdd_dict::is_registered_accepting_variable. * src/tgba/tgbaexplicit.hh (tgba_explicit::set_init_state, tgba_explicit::complement_all_accepting_conditions): New methods. * src/tgbaalgos/ltl2tgba_fm.cc, src/tgbaalgos/ltl2tgba_fm.hh: New files. * src/tgbaalgos/Makefile.am (tgbaalgos_HEADERS, libtgbaalgos_la_SOURCES): Add them. * src/tgbaalgos/ltl2tgba.hh: Add bibtex entry in comment. * src/tgbatest/Makefile.am (check_PROGRAMS): Remove spotlbtt and tbalbtt. (tbalbtt_SOURCES, tbalbtt_CXXFLAGS, spotlbtt_SOURCES): Remove. * src/tgbatest/spotlbtt.cc: Delete, superseded by "ltl2tgba -F -t". * src/tgbatest/ltl2tgba.cc: Implement the -f and -F options. * src/tgbatest/spotlbtt.test: Use "ltl2tgba -F -t" instead of "spotlbtt", "ltl2tgba -F -t -D" instead of "tbalbtt", and add also check the ltl2tgba_fm translator. * wrap/python/spot.i: Wrap ltl2tgba_fm. * wrap/python/cgi/ltl2tgba.in: Add radio buttons to select between ltl2tgba and ltl2tgba_fm. * wrap/python/tests/ltl2tgba.py: Add support for the -f option. * wrap/python/tests/ltl2tgba.test: Try the -f option.
This commit is contained in:
parent
256d800580
commit
2b9f17202c
17 changed files with 820 additions and 159 deletions
|
|
@ -68,9 +68,29 @@ options = [
|
|||
('show_lbtt', 'convert automaton for LBTT', 0),
|
||||
]
|
||||
|
||||
default_translator = 'trans_lacim';
|
||||
translators = [
|
||||
('trans_lacim', 'Convreur/LaCIM'),
|
||||
('trans_fm', 'Convreur/FM'),
|
||||
]
|
||||
|
||||
print """<FORM action="%s" method="post"><P>
|
||||
Formula to translate: <INPUT type="text" name="formula" value="%s"><BR>
|
||||
Options:<TABLE><TR><TD>""" % (myself, formula)
|
||||
Translator:<TABLE><TR><TD>""" % (myself, formula)
|
||||
|
||||
|
||||
trans = form.getfirst("trans", default_translator)
|
||||
for opt, desc, in translators:
|
||||
if trans == opt:
|
||||
str = "checked"
|
||||
else:
|
||||
str = ""
|
||||
globals()[opt] = str
|
||||
print '<INPUT type="radio" name="trans" value="%s" %s>%s<br>' % (opt, str,
|
||||
desc)
|
||||
|
||||
print """</TD></TR></TABLE>
|
||||
Options:<TABLE><TR><TD>"""
|
||||
|
||||
for opt, desc, arg, in options:
|
||||
if formula:
|
||||
|
|
@ -140,7 +160,10 @@ dict = spot.bdd_dict()
|
|||
print '<p>Building automaton...',
|
||||
sys.stdout.flush()
|
||||
|
||||
concrete = spot.ltl_to_tgba(f, dict)
|
||||
if trans_lacim:
|
||||
automaton = spot.ltl_to_tgba(f, dict)
|
||||
elif trans_fm:
|
||||
automaton = spot.ltl_to_tgba_fm(f, dict)
|
||||
|
||||
print 'done.</p>'
|
||||
sys.stdout.flush()
|
||||
|
|
@ -148,14 +171,14 @@ sys.stdout.flush()
|
|||
if show_automaton_dot:
|
||||
print '<pre>'; sys.stdout.flush()
|
||||
s = spot.ostringstream()
|
||||
spot.dotty_reachable(s, concrete)
|
||||
spot.dotty_reachable(s, automaton)
|
||||
print cgi.escape(s.str())
|
||||
del s
|
||||
print '</pre>'; sys.stdout.flush()
|
||||
|
||||
if show_automaton_gif:
|
||||
outfile = spot.ofstream(imgprefix + '-a.dot')
|
||||
spot.dotty_reachable(outfile, concrete)
|
||||
spot.dotty_reachable(outfile, automaton)
|
||||
del outfile
|
||||
os.spawnlp(os.P_WAIT, 'dot', 'dot', '-Tgif', '-Gsize=14,14', '-o',
|
||||
imgprefix + '-a.gif', imgprefix + '-a.dot')
|
||||
|
|
@ -166,7 +189,7 @@ if show_automaton_gif:
|
|||
|
||||
if show_degen_dot or show_degen_gif:
|
||||
print '<H3>Degeneralized automaton</H3>'
|
||||
degen = spot.tgba_tba_proxy(concrete)
|
||||
degen = spot.tgba_tba_proxy(automaton)
|
||||
if show_degen_dot:
|
||||
print '<pre>'; sys.stdout.flush()
|
||||
s = spot.ostringstream()
|
||||
|
|
@ -190,21 +213,22 @@ if show_dictionnay:
|
|||
print '<H3>BDD dictionary</H3>'
|
||||
print '<pre>'
|
||||
sys.stdout.flush()
|
||||
concrete.get_dict().dump(spot.get_cout())
|
||||
automaton.get_dict().dump(spot.get_cout())
|
||||
print '</pre>'
|
||||
|
||||
if show_relation_dot or show_relation_set or show_relation_gif:
|
||||
if (type(automaton) == spot.tgba_bdd_concrete
|
||||
and (show_relation_dot or show_relation_set or show_relation_gif)):
|
||||
print '<H3>Transition relation</H3>'
|
||||
if show_relation_dot:
|
||||
escaped_print_dot(concrete.get_dict(),
|
||||
concrete.get_core_data().relation)
|
||||
escaped_print_dot(automaton.get_dict(),
|
||||
automaton.get_core_data().relation)
|
||||
if show_relation_set:
|
||||
escaped_print_set(concrete.get_dict(),
|
||||
concrete.get_core_data().relation)
|
||||
escaped_print_set(automaton.get_dict(),
|
||||
automaton.get_core_data().relation)
|
||||
if show_relation_gif:
|
||||
outfile = spot.ofstream(imgprefix + '-b.dot')
|
||||
spot.bdd_print_dot(outfile, concrete.get_dict(),
|
||||
concrete.get_core_data().relation)
|
||||
spot.bdd_print_dot(outfile, automaton.get_dict(),
|
||||
automaton.get_core_data().relation)
|
||||
del outfile
|
||||
os.spawnlp(os.P_WAIT, 'dot', 'dot', '-Tgif', '-Gsize=14,14', '-o',
|
||||
imgprefix + '-b.gif', imgprefix + '-b.dot')
|
||||
|
|
@ -212,18 +236,19 @@ if show_relation_dot or show_relation_set or show_relation_gif:
|
|||
imgprefix + '-b.gif', imgprefix + '-b.png')
|
||||
print '<img src="' + imgprefix + '-b.png">'
|
||||
|
||||
if show_acceptance_dot or show_acceptance_set or show_acceptance_gif:
|
||||
if (type(automaton) == spot.tgba_bdd_concrete
|
||||
and (show_acceptance_dot or show_acceptance_set or show_acceptance_gif)):
|
||||
print '<H3>Acceptance relation</H3>'
|
||||
if show_acceptance_dot:
|
||||
escaped_print_dot(concrete.get_dict(),
|
||||
concrete.get_core_data().accepting_conditions)
|
||||
escaped_print_dot(automaton.get_dict(),
|
||||
automaton.get_core_data().accepting_conditions)
|
||||
if show_acceptance_set:
|
||||
escaped_print_set(concrete.get_dict(),
|
||||
concrete.get_core_data().accepting_conditions)
|
||||
escaped_print_set(automaton.get_dict(),
|
||||
automaton.get_core_data().accepting_conditions)
|
||||
if show_acceptance_gif:
|
||||
outfile = spot.ofstream(imgprefix + '-c.dot')
|
||||
spot.bdd_print_dot(outfile, concrete.get_dict(),
|
||||
concrete.get_core_data().accepting_conditions)
|
||||
spot.bdd_print_dot(outfile, automaton.get_dict(),
|
||||
automaton.get_core_data().accepting_conditions)
|
||||
del outfile
|
||||
os.spawnlp(os.P_WAIT, 'dot', 'dot', '-Tgif', '-Gsize=14,14', '-o',
|
||||
imgprefix + '-c.gif', imgprefix + '-c.dot')
|
||||
|
|
@ -237,7 +262,7 @@ if show_lbtt:
|
|||
print '<H4>Conversion of the generalized automaton</H4>'
|
||||
print '<pre>'
|
||||
sys.stdout.flush()
|
||||
spot.lbtt_reachable(spot.get_cout(), concrete)
|
||||
spot.lbtt_reachable(spot.get_cout(), automaton)
|
||||
print '</pre>'
|
||||
if degen:
|
||||
print '<H4>Conversion of the degeneralized automaton</H4>'
|
||||
|
|
@ -248,9 +273,10 @@ if show_lbtt:
|
|||
|
||||
sys.stdout.flush()
|
||||
|
||||
# Make sure degen is cleared before concrete.
|
||||
spot.destroy(f)
|
||||
# Make sure degen is cleared before automaton.
|
||||
del degen
|
||||
del concrete
|
||||
del automaton
|
||||
|
||||
print '<hr>'
|
||||
print 'ltl2tgba.py @PACKAGE_VERSION@; Spot', spot.version()
|
||||
|
|
|
|||
|
|
@ -49,6 +49,7 @@
|
|||
#include "tgba/tgbatba.hh"
|
||||
|
||||
#include "tgbaalgos/ltl2tgba.hh"
|
||||
#include "tgbaalgos/ltl2tgba_fm.hh"
|
||||
#include "tgbaalgos/dotty.hh"
|
||||
#include "tgbaalgos/lbtt.hh"
|
||||
#include "tgbaalgos/magic.hh"
|
||||
|
|
@ -84,6 +85,7 @@ using namespace spot;
|
|||
%include "ltlvisit/tunabbrev.hh"
|
||||
|
||||
%feature("new") spot::ltl_to_tgba;
|
||||
%feature("new") spot::ltl_to_tgba_fm;
|
||||
%feature("new") spot::tgba::get_init_state;
|
||||
%feature("new") spot::tgba::succ_iter;
|
||||
%feature("new") spot::tgba_succ_iterator::current_state;
|
||||
|
|
@ -104,6 +106,7 @@ using namespace spot;
|
|||
%include "tgba/tgbatba.hh"
|
||||
|
||||
%include "tgbaalgos/ltl2tgba.hh"
|
||||
%include "tgbaalgos/ltl2tgba_fm.hh"
|
||||
%include "tgbaalgos/dotty.hh"
|
||||
%include "tgbaalgos/lbtt.hh"
|
||||
%include "tgbaalgos/magic.hh"
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ Options:
|
|||
-A same as -a, but as a set
|
||||
-d turn on traces during parsing
|
||||
-D degeneralize the automaton
|
||||
-f use Couvreur's FM algorithm for translation
|
||||
-r display the relation BDD, not the reachability graph
|
||||
-R same as -r, but as a set
|
||||
-t display reachable states in LBTT's format
|
||||
|
|
@ -23,7 +24,7 @@ Options:
|
|||
|
||||
prog = sys.argv[0]
|
||||
try:
|
||||
opts, args = getopt.getopt(sys.argv[1:], 'aAdDrRtv')
|
||||
opts, args = getopt.getopt(sys.argv[1:], 'aAdDfrRtv')
|
||||
except getopt.GetoptError:
|
||||
usage(prog)
|
||||
|
||||
|
|
@ -31,6 +32,7 @@ exit_code = 0
|
|||
debug_opt = 0
|
||||
degeneralize_opt = None
|
||||
output = 0
|
||||
fm_opt = 0
|
||||
|
||||
for o, a in opts:
|
||||
if o == '-a':
|
||||
|
|
@ -41,6 +43,8 @@ for o, a in opts:
|
|||
debug_opt = 1
|
||||
elif o == '-D':
|
||||
degeneralize_opt = 1
|
||||
elif o == '-f':
|
||||
fm_opt = 1
|
||||
elif o == '-r':
|
||||
output = 1
|
||||
elif o == '-R':
|
||||
|
|
@ -65,14 +69,17 @@ p = spot.empty_parse_error_list()
|
|||
f = spot.parse(args[0], p, e, debug_opt)
|
||||
if spot.format_parse_errors(cerr, args[0], p):
|
||||
exit_code = 1
|
||||
|
||||
|
||||
dict = spot.bdd_dict()
|
||||
|
||||
if f:
|
||||
concrete = spot.ltl_to_tgba(f, dict)
|
||||
if fm_opt:
|
||||
a = spot.ltl_to_tgba_fm(f, dict)
|
||||
concrete = 0
|
||||
else:
|
||||
a = concrete = spot.ltl_to_tgba(f, dict)
|
||||
spot.destroy(f)
|
||||
del f
|
||||
a = concrete
|
||||
|
||||
degeneralized = None
|
||||
if degeneralize_opt:
|
||||
|
|
@ -81,18 +88,22 @@ if f:
|
|||
if output == 0:
|
||||
spot.dotty_reachable(cout, a)
|
||||
elif output == 1:
|
||||
spot.bdd_print_dot(cout, concrete.get_dict(),
|
||||
concrete.get_core_data().relation)
|
||||
if concrete:
|
||||
spot.bdd_print_dot(cout, concrete.get_dict(),
|
||||
concrete.get_core_data().relation)
|
||||
elif output == 2:
|
||||
spot.bdd_print_dot(cout, concrete.get_dict(),
|
||||
concrete.get_core_data().accepting_conditions)
|
||||
if concrete:
|
||||
spot.bdd_print_dot(cout, concrete.get_dict(),
|
||||
concrete.get_core_data().accepting_conditions)
|
||||
elif output == 3:
|
||||
spot.bdd_print_set(cout, concrete.get_dict(),
|
||||
concrete.get_core_data().relation)
|
||||
if concrete:
|
||||
spot.bdd_print_set(cout, concrete.get_dict(),
|
||||
concrete.get_core_data().relation)
|
||||
print
|
||||
elif output == 4:
|
||||
spot.bdd_print_set(cout, concrete.get_dict(),
|
||||
concrete.get_core_data().accepting_conditions)
|
||||
if concrete:
|
||||
spot.bdd_print_set(cout, concrete.get_dict(),
|
||||
concrete.get_core_data().accepting_conditions)
|
||||
print
|
||||
elif output == 5:
|
||||
a.get_dict().dump(cout)
|
||||
|
|
@ -116,4 +127,3 @@ assert spot.atomic_prop.instance_count() == 0
|
|||
assert spot.unop.instance_count() == 0
|
||||
assert spot.binop.instance_count() == 0
|
||||
assert spot.multop.instance_count() == 0
|
||||
|
||||
|
|
|
|||
|
|
@ -14,3 +14,13 @@ set -e
|
|||
./run ltl2tgba.py 'Fa & Xb & GFc & Gd'
|
||||
./run ltl2tgba.py 'Fa & Xa & GFc & Gc'
|
||||
./run ltl2tgba.py 'Fc & X(a | Xb) & GF(a | Xb) & Gc'
|
||||
|
||||
./run ltl2tgba.py -f a
|
||||
./run ltl2tgba.py -f 'a U b'
|
||||
./run ltl2tgba.py -f 'X a'
|
||||
./run ltl2tgba.py -f 'a & b & c'
|
||||
./run ltl2tgba.py -f 'a | b | (c U (d & (g U (h ^ i))))'
|
||||
./run ltl2tgba.py -f 'Xa & (b U !a) & (b U !a)'
|
||||
./run ltl2tgba.py -f 'Fa & Xb & GFc & Gd'
|
||||
./run ltl2tgba.py -f 'Fa & Xa & GFc & Gc'
|
||||
./run ltl2tgba.py -f 'Fc & X(a | Xb) & GF(a | Xb) & Gc'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue