* Makefile.am, configure.ac, doc/Makefile.am, iface/Makefile.am, iface/gspn/Makefile.am, iface/gspn/common.cc, iface/gspn/common.hh, iface/gspn/dottyeesrg.cc, iface/gspn/dottygspn.cc, iface/gspn/eesrg.cc, iface/gspn/eesrg.hh, iface/gspn/gspn.cc, iface/gspn/gspn.hh, iface/gspn/ltlgspn.cc, src/Makefile.am, src/ltlast/Makefile.am, src/ltlast/allnodes.hh, src/ltlast/atomic_prop.cc, src/ltlast/atomic_prop.hh, src/ltlast/binop.cc, src/ltlast/binop.hh, src/ltlast/constant.cc, src/ltlast/constant.hh, src/ltlast/formula.cc, src/ltlast/formula.hh, src/ltlast/multop.cc, src/ltlast/multop.hh, src/ltlast/predecl.hh, src/ltlast/refformula.cc, src/ltlast/refformula.hh, src/ltlast/unop.cc, src/ltlast/unop.hh, src/ltlast/visitor.hh, src/ltlenv/Makefile.am, src/ltlenv/defaultenv.cc, src/ltlenv/defaultenv.hh, src/ltlenv/environment.hh, src/ltlparse/Makefile.am, src/ltlparse/fmterror.cc, src/ltlparse/ltlparse.yy, src/ltlparse/ltlscan.ll, src/ltlparse/parsedecl.hh, src/ltlparse/public.hh, src/ltltest/Makefile.am, src/ltltest/defs.in, src/ltltest/equals.cc, src/ltltest/equals.test, src/ltltest/lunabbrev.test, src/ltltest/nenoform.test, src/ltltest/parse.test, src/ltltest/parseerr.test, src/ltltest/readltl.cc, src/ltltest/tostring.cc, src/ltltest/tostring.test, src/ltltest/tunabbrev.test, src/ltltest/tunenoform.test, src/ltlvisit/Makefile.am, src/ltlvisit/clone.cc, src/ltlvisit/clone.hh, src/ltlvisit/destroy.cc, src/ltlvisit/destroy.hh, src/ltlvisit/dotty.cc, src/ltlvisit/dotty.hh, src/ltlvisit/dump.cc, src/ltlvisit/dump.hh, src/ltlvisit/lunabbrev.cc, src/ltlvisit/lunabbrev.hh, src/ltlvisit/nenoform.cc, src/ltlvisit/nenoform.hh, src/ltlvisit/postfix.cc, src/ltlvisit/postfix.hh, src/ltlvisit/tostring.cc, src/ltlvisit/tostring.hh, src/ltlvisit/tunabbrev.cc, src/ltlvisit/tunabbrev.hh, src/misc/Makefile.am, src/misc/bddalloc.cc, src/misc/bddalloc.hh, src/misc/bddlt.hh, src/misc/hash.hh, src/misc/minato.cc, src/misc/minato.hh, src/misc/version.cc, src/misc/version.hh, src/tgba/Makefile.am, src/tgba/bdddict.cc, src/tgba/bdddict.hh, src/tgba/bddprint.cc, src/tgba/bddprint.hh, src/tgba/public.hh, src/tgba/state.hh, src/tgba/statebdd.cc, src/tgba/statebdd.hh, src/tgba/succiter.hh, src/tgba/succiterconcrete.cc, src/tgba/succiterconcrete.hh, src/tgba/tgba.cc, src/tgba/tgba.hh, src/tgba/tgbabddconcrete.cc, src/tgba/tgbabddconcrete.hh, src/tgba/tgbabddconcretefactory.cc, src/tgba/tgbabddconcretefactory.hh, src/tgba/tgbabddconcreteproduct.cc, src/tgba/tgbabddconcreteproduct.hh, src/tgba/tgbabddcoredata.cc, src/tgba/tgbabddcoredata.hh, src/tgba/tgbabddfactory.hh, src/tgba/tgbaexplicit.cc, src/tgba/tgbaexplicit.hh, src/tgba/tgbaproduct.cc, src/tgba/tgbaproduct.hh, src/tgba/tgbatba.cc, src/tgba/tgbatba.hh, src/tgbaalgos/Makefile.am, src/tgbaalgos/dotty.cc, src/tgbaalgos/dotty.hh, src/tgbaalgos/dupexp.cc, src/tgbaalgos/dupexp.hh, src/tgbaalgos/emptinesscheck.cc, src/tgbaalgos/emptinesscheck.hh, src/tgbaalgos/lbtt.cc, src/tgbaalgos/lbtt.hh, src/tgbaalgos/ltl2tgba_fm.cc, src/tgbaalgos/ltl2tgba_fm.hh, src/tgbaalgos/ltl2tgba_lacim.cc, src/tgbaalgos/ltl2tgba_lacim.hh, src/tgbaalgos/magic.cc, src/tgbaalgos/magic.hh, src/tgbaalgos/reachiter.cc, src/tgbaalgos/reachiter.hh, src/tgbaalgos/save.cc, src/tgbaalgos/save.hh, src/tgbaparse/Makefile.am, src/tgbaparse/fmterror.cc, src/tgbaparse/parsedecl.hh, src/tgbaparse/public.hh, src/tgbaparse/tgbaparse.yy, src/tgbaparse/tgbascan.ll, src/tgbatest/Makefile.am, src/tgbatest/bddprod.test, src/tgbatest/defs.in, src/tgbatest/dupexp.test, src/tgbatest/emptchk.test, src/tgbatest/emptchke.test, src/tgbatest/explicit.test, src/tgbatest/explpro2.test, src/tgbatest/explpro3.test, src/tgbatest/explprod.test, src/tgbatest/ltl2tgba.test, src/tgbatest/ltlprod.test, src/tgbatest/mixprod.test, src/tgbatest/readsave.test, src/tgbatest/spotlbtt.test, src/tgbatest/tgbaread.test, src/tgbatest/tripprod.test, wrap/Makefile.am, wrap/python/Makefile.am, wrap/python/buddy.i, wrap/python/spot.i, wrap/python/cgi/Makefile.am, wrap/python/cgi/ltl2tgba.in, wrap/python/tests/Makefile.am, wrap/python/tests/bddnqueen.py, wrap/python/tests/interdep.py, wrap/python/tests/ltl2tgba.py, wrap/python/tests/ltl2tgba.test, wrap/python/tests/ltlparse.py, wrap/python/tests/ltlsimple.py, wrap/python/tests/run.in: Add Copyright license.
302 lines
9.4 KiB
Python
302 lines
9.4 KiB
Python
#!@PYTHON@
|
|
# -*- python -*-
|
|
# Copyright (C) 2003 Laboratoire d'Informatique de Paris 6 (LIP6),
|
|
# département Systèmes Répartis Coopératifs (SRC), Université Pierre
|
|
# et Marie Curie.
|
|
#
|
|
# This file is part of Spot, a model checking library.
|
|
#
|
|
# Spot is free software; you can redistribute it and/or modify it
|
|
# under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# Spot is distributed in the hope that it will be useful, but WITHOUT
|
|
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
|
# License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with Spot; see the file COPYING. If not, write to the Free
|
|
# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
|
# 02111-1307, USA.
|
|
|
|
import sys
|
|
import os
|
|
import cgi
|
|
import cgitb; cgitb.enable()
|
|
|
|
sys.path.insert(0, '@pythondir@')
|
|
# Directory for temporary files (images and other auxiliary files).
|
|
imgdir = 'spotimg'
|
|
|
|
# Cleanup stale files from our image directory.
|
|
os.system('find ' + imgdir + ' -type f -amin +10 -print | xargs rm -f')
|
|
|
|
myself = os.environ['SCRIPT_NAME'];
|
|
form = cgi.FieldStorage()
|
|
filled = form.has_key('formula')
|
|
# FIXME: This assumes Apache.
|
|
uid = os.environ['UNIQUE_ID'];
|
|
imgprefix = imgdir + '/' + uid
|
|
|
|
def escaped_print_dot(dict, what):
|
|
print '<pre>'; sys.stdout.flush()
|
|
s = spot.ostringstream()
|
|
spot.bdd_print_dot(s, dict, what)
|
|
print cgi.escape(s.str())
|
|
del s
|
|
print '</pre>'; sys.stdout.flush()
|
|
|
|
def escaped_print_set(dict, what):
|
|
print '<pre>'; sys.stdout.flush()
|
|
s = spot.ostringstream()
|
|
spot.bdd_print_set(s, dict, what)
|
|
print cgi.escape(s.str())
|
|
del s
|
|
print '</pre>'; sys.stdout.flush()
|
|
|
|
|
|
print "Content-Type: text/html"
|
|
print
|
|
|
|
os.close(sys.stderr.fileno())
|
|
os.dup2(sys.stdout.fileno(), sys.stderr.fileno())
|
|
|
|
import spot
|
|
|
|
print "<TITLE>LTL-to-Büchi test</TITLE>"
|
|
print "<H1>Input</H1>"
|
|
|
|
formula = form.getfirst('formula', '')
|
|
|
|
options = [
|
|
('show_parse', 'show traces during parsing', 0),
|
|
('show_formula_dot', 'print the formula as .dot', 0),
|
|
('show_formula_gif', 'draw the formula', 0),
|
|
('show_automaton_dot', 'print Büchi automaton as .dot', 0),
|
|
('show_automaton_gif', 'draw Büchi automaton', 1),
|
|
('show_degen_dot', 'print degeneralized Büchi automaton as .dot', 0),
|
|
('show_degen_gif', 'draw degeneralized Büchi automaton', 0),
|
|
('show_dictionnay', 'print BDD dictionary', 0),
|
|
('show_relation_dot', 'print the transition relation as .dot', 0),
|
|
('show_relation_set', 'print the transition relation as a BDD set', 0),
|
|
('show_relation_gif', 'draw the transition relation', 0),
|
|
('show_acceptance_dot', 'print the acceptance relation as .dot' , 0),
|
|
('show_acceptance_set', 'print the acceptance relation as a BDD set', 0),
|
|
('show_acceptance_gif', 'draw the acceptance relation', 0),
|
|
('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>
|
|
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:
|
|
val = int(form.getfirst(opt, 0))
|
|
else:
|
|
val = arg
|
|
if val:
|
|
str = "checked"
|
|
else:
|
|
str = ""
|
|
globals()[opt] = val
|
|
print '<INPUT type="checkbox" name="%s" value="1" %s>%s<br>' % (opt, str,
|
|
desc)
|
|
print '</TD></TR></TABLE><INPUT type="submit" value="Send"></FORM>'
|
|
|
|
if not filled:
|
|
sys.exit(0)
|
|
|
|
print "<hr><H1>Output</H1>"
|
|
|
|
env = spot.default_environment.instance()
|
|
|
|
print "<H2>LTL Formula</H2>"
|
|
|
|
if show_parse: print '<pre>'
|
|
sys.stdout.flush()
|
|
sys.stderr.flush()
|
|
|
|
pel = spot.empty_parse_error_list()
|
|
f = spot.parse(formula, pel, env, show_parse)
|
|
if show_parse: print '</pre>'
|
|
|
|
print '<font color="red"><pre>'
|
|
err = spot.format_parse_errors(spot.get_cout(), formula, pel)
|
|
print '</pre></font>'
|
|
|
|
if not f:
|
|
print '<p><b>Aborting...</b></p>'
|
|
sys.exit(0)
|
|
if err:
|
|
print '<p><b>Continuing anyway...</b></p>'
|
|
|
|
print "<p>Formula is<code>", f, "</code></p>"
|
|
|
|
if show_formula_dot:
|
|
print '<pre>'; sys.stdout.flush()
|
|
s = spot.ostringstream()
|
|
spot.dotty(s, f)
|
|
print cgi.escape(s.str())
|
|
del s
|
|
print '</pre>'; sys.stdout.flush()
|
|
if show_formula_gif:
|
|
outfile = spot.ofstream(imgprefix + '-f.dot')
|
|
spot.dotty(outfile, f)
|
|
del outfile
|
|
os.spawnlp(os.P_WAIT, 'dot', 'dot', '-Tgif', '-Gsize=14,14', '-o',
|
|
imgprefix + '-f.gif', imgprefix + '-f.dot')
|
|
os.spawnlp(os.P_WAIT, 'convert', 'convert',
|
|
imgprefix + '-f.gif', imgprefix + '-f.png')
|
|
print '<img src="' + imgprefix + '-f.png">'
|
|
|
|
|
|
print '<H2>Automaton</H2>'
|
|
|
|
dict = spot.bdd_dict()
|
|
|
|
print '<p>Building automaton...',
|
|
sys.stdout.flush()
|
|
|
|
if trans_lacim:
|
|
automaton = spot.ltl_to_tgba_lacim(f, dict)
|
|
elif trans_fm:
|
|
automaton = spot.ltl_to_tgba_fm(f, dict)
|
|
|
|
print 'done.</p>'
|
|
sys.stdout.flush()
|
|
|
|
if show_automaton_dot:
|
|
print '<pre>'; sys.stdout.flush()
|
|
s = spot.ostringstream()
|
|
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, automaton)
|
|
del outfile
|
|
os.spawnlp(os.P_WAIT, 'dot', 'dot', '-Tgif', '-Gsize=14,14', '-o',
|
|
imgprefix + '-a.gif', imgprefix + '-a.dot')
|
|
os.spawnlp(os.P_WAIT, 'convert', 'convert',
|
|
imgprefix + '-a.gif', imgprefix + '-a.png')
|
|
print '<img src="' + imgprefix + '-a.png">'
|
|
|
|
|
|
if show_degen_dot or show_degen_gif:
|
|
print '<H3>Degeneralized automaton</H3>'
|
|
degen = spot.tgba_tba_proxy(automaton)
|
|
if show_degen_dot:
|
|
print '<pre>'; sys.stdout.flush()
|
|
s = spot.ostringstream()
|
|
spot.dotty_reachable(s, degen)
|
|
print cgi.escape(s.str())
|
|
del s
|
|
print '</pre>'; sys.stdout.flush()
|
|
if show_degen_gif:
|
|
outfile = spot.ofstream(imgprefix + '-d.dot')
|
|
spot.dotty_reachable(outfile, degen)
|
|
del outfile
|
|
os.spawnlp(os.P_WAIT, 'dot', 'dot', '-Tgif', '-Gsize=14,14', '-o',
|
|
imgprefix + '-d.gif', imgprefix + '-d.dot')
|
|
os.spawnlp(os.P_WAIT, 'convert', 'convert',
|
|
imgprefix + '-d.gif', imgprefix + '-d.png')
|
|
print '<img src="' + imgprefix + '-d.png">'
|
|
else:
|
|
degen = 0
|
|
|
|
if show_dictionnay:
|
|
print '<H3>BDD dictionary</H3>'
|
|
print '<pre>'
|
|
sys.stdout.flush()
|
|
automaton.get_dict().dump(spot.get_cout())
|
|
print '</pre>'
|
|
|
|
if (type(automaton) == spot.tgba_bdd_concretePtr
|
|
and (show_relation_dot or show_relation_set or show_relation_gif)):
|
|
print '<H3>Transition relation</H3>'
|
|
if show_relation_dot:
|
|
escaped_print_dot(automaton.get_dict(),
|
|
automaton.get_core_data().relation)
|
|
if show_relation_set:
|
|
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, 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')
|
|
os.spawnlp(os.P_WAIT, 'convert', 'convert',
|
|
imgprefix + '-b.gif', imgprefix + '-b.png')
|
|
print '<img src="' + imgprefix + '-b.png">'
|
|
|
|
if (type(automaton) == spot.tgba_bdd_concretePtr
|
|
and (show_acceptance_dot or show_acceptance_set or show_acceptance_gif)):
|
|
print '<H3>Acceptance relation</H3>'
|
|
if show_acceptance_dot:
|
|
escaped_print_dot(automaton.get_dict(),
|
|
automaton.get_core_data().accepting_conditions)
|
|
if show_acceptance_set:
|
|
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, 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')
|
|
os.spawnlp(os.P_WAIT, 'convert', 'convert',
|
|
imgprefix + '-c.gif', imgprefix + '-c.png')
|
|
print '<img src="' + imgprefix + '-c.png">'
|
|
|
|
if show_lbtt:
|
|
print '<H3>LBTT conversion</H3>'
|
|
if degen:
|
|
print '<H4>Conversion of the generalized automaton</H4>'
|
|
print '<pre>'
|
|
sys.stdout.flush()
|
|
spot.lbtt_reachable(spot.get_cout(), automaton)
|
|
print '</pre>'
|
|
if degen:
|
|
print '<H4>Conversion of the degeneralized automaton</H4>'
|
|
print '<pre>'
|
|
sys.stdout.flush()
|
|
spot.lbtt_reachable(spot.get_cout(), degen)
|
|
print '</pre>'
|
|
|
|
sys.stdout.flush()
|
|
|
|
spot.destroy(f)
|
|
# Make sure degen is cleared before automaton.
|
|
del degen
|
|
del automaton
|
|
|
|
print '<hr>'
|
|
print 'ltl2tgba.py @PACKAGE_VERSION@; Spot', spot.version()
|