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:
Alexandre Duret-Lutz 2003-08-15 01:33:09 +00:00
parent 256d800580
commit 2b9f17202c
17 changed files with 820 additions and 159 deletions

View file

@ -12,8 +12,6 @@ check_PROGRAMS = \
ltlprod \
mixprod \
readsave \
spotlbtt \
tbalbtt \
tgbaread \
tripprod
@ -27,11 +25,8 @@ ltlmagic_SOURCES = ltlmagic.cc
ltlprod_SOURCES = ltlprod.cc
mixprod_SOURCES = mixprod.cc
readsave_SOURCES = readsave.cc
tbalbtt_SOURCES = spotlbtt.cc
tbalbtt_CXXFLAGS = -DTBA
tgbaread_SOURCES = tgbaread.cc
tripprod_SOURCES = tripprod.cc
spotlbtt_SOURCES = spotlbtt.cc
# Keep this sorted by STRENGTH. Test basic things first,
# because such failures will be easier to diagnose and fix.

View file

@ -1,9 +1,12 @@
#include <iostream>
#include <cassert>
#include <fstream>
#include <string>
#include "ltlvisit/destroy.hh"
#include "ltlast/allnodes.hh"
#include "ltlparse/public.hh"
#include "tgbaalgos/ltl2tgba.hh"
#include "tgbaalgos/ltl2tgba_fm.hh"
#include "tgba/bddprint.hh"
#include "tgbaalgos/dotty.hh"
#include "tgbaalgos/lbtt.hh"
@ -13,6 +16,7 @@ void
syntax(char* prog)
{
std::cerr << "Usage: "<< prog << " [OPTIONS...] formula" << std::endl
<< " "<< prog << " -F [OPTIONS...] file" << std::endl
<< std::endl
<< "Options:" << std::endl
<< " -a display the accepting_conditions BDD, not the reachability graph"
@ -20,6 +24,9 @@ syntax(char* prog)
<< " -A same as -a, but as a set" << std::endl
<< " -d turn on traces during parsing" << std::endl
<< " -D degeneralize the automaton" << std::endl
<< " -f use Couvreur's FM algorithm for translation"
<< std::endl
<< " -F read the formula from the file" << std::endl
<< " -r display the relation BDD, not the reachability graph"
<< std::endl
<< " -R same as -r, but as a set" << std::endl
@ -36,6 +43,8 @@ main(int argc, char** argv)
bool debug_opt = false;
bool degeneralize_opt = false;
bool fm_opt = false;
bool file_opt = false;
int output = 0;
int formula_index = 0;
@ -62,6 +71,14 @@ main(int argc, char** argv)
{
degeneralize_opt = true;
}
else if (!strcmp(argv[formula_index], "-f"))
{
fm_opt = true;
}
else if (!strcmp(argv[formula_index], "-F"))
{
file_opt = true;
}
else if (!strcmp(argv[formula_index], "-r"))
{
output = 1;
@ -84,19 +101,46 @@ main(int argc, char** argv)
}
}
std::string input;
if (file_opt)
{
std::ifstream fin(argv[formula_index]);
if (! fin)
{
std::cerr << "Cannot open " << argv[formula_index] << std::endl;
exit(2);
}
if (! std::getline(fin, input, '\0'))
{
std::cerr << "Cannot read " << argv[formula_index] << std::endl;
exit(2);
}
}
else
{
input = argv[formula_index];
}
spot::ltl::environment& env(spot::ltl::default_environment::instance());
spot::ltl::parse_error_list pel;
spot::ltl::formula* f = spot::ltl::parse(argv[formula_index],
pel, env, debug_opt);
spot::ltl::formula* f = spot::ltl::parse(input, pel, env, debug_opt);
exit_code =
spot::ltl::format_parse_errors(std::cerr, argv[formula_index], pel);
exit_code = spot::ltl::format_parse_errors(std::cerr, input, pel);
spot::bdd_dict* dict = new spot::bdd_dict();
if (f)
{
spot::tgba_bdd_concrete* concrete = spot::ltl_to_tgba(f, dict);
spot::tgba* a = concrete;
spot::tgba_bdd_concrete* concrete = 0;
spot::tgba* to_free = 0;
spot::tgba* a = 0;
if (fm_opt)
to_free = a = spot::ltl_to_tgba_fm(f, dict);
else
to_free = a = concrete = spot::ltl_to_tgba(f, dict);
spot::ltl::destroy(f);
spot::tgba* degeneralized = 0;
@ -109,20 +153,26 @@ main(int argc, char** argv)
spot::dotty_reachable(std::cout, a);
break;
case 1:
spot::bdd_print_dot(std::cout, concrete->get_dict(),
concrete->get_core_data().relation);
if (concrete)
spot::bdd_print_dot(std::cout, concrete->get_dict(),
concrete->get_core_data().relation);
break;
case 2:
spot::bdd_print_dot(std::cout, concrete->get_dict(),
concrete->get_core_data().accepting_conditions);
if (concrete)
spot::bdd_print_dot(std::cout, concrete->get_dict(),
concrete->
get_core_data().accepting_conditions);
break;
case 3:
spot::bdd_print_set(std::cout, concrete->get_dict(),
concrete->get_core_data().relation);
if (concrete)
spot::bdd_print_set(std::cout, concrete->get_dict(),
concrete->get_core_data().relation);
break;
case 4:
spot::bdd_print_set(std::cout, concrete->get_dict(),
concrete->get_core_data().accepting_conditions);
if (concrete)
spot::bdd_print_set(std::cout, concrete->get_dict(),
concrete->
get_core_data().accepting_conditions);
break;
case 5:
a->get_dict()->dump(std::cout);
@ -137,7 +187,7 @@ main(int argc, char** argv)
if (degeneralize_opt)
delete degeneralized;
delete concrete;
delete to_free;
}
else
{

View file

@ -1,74 +0,0 @@
#include <iostream>
#include <fstream>
#include <cassert>
#include <string>
#include "ltlvisit/destroy.hh"
#include "ltlast/allnodes.hh"
#include "ltlparse/public.hh"
#include "tgbaalgos/ltl2tgba.hh"
#include "tgbaalgos/lbtt.hh"
#include "tgba/tgbatba.hh"
void
syntax(char* prog)
{
std::cerr << "Usage: "<< prog << " file" << std::endl;
exit(2);
}
int
main(int argc, char** argv)
{
int exit_code = 0;
if (argc != 2)
syntax(argv[0]);
std::ifstream fin(argv[1]);
if (! fin)
{
std::cerr << "Cannot open " << argv[1] << std::endl;
exit(2);
}
std::string input;
if (! std::getline(fin, input, '\0'))
{
std::cerr << "Cannot read " << argv[1] << std::endl;
exit(2);
}
spot::bdd_dict* dict = new spot::bdd_dict();
spot::ltl::environment& env(spot::ltl::default_environment::instance());
spot::ltl::parse_error_list pel;
spot::ltl::formula* f = spot::ltl::parse(input, pel, env);
exit_code = spot::ltl::format_parse_errors(std::cerr, input, pel);
if (f)
{
spot::tgba* a;
spot::tgba* c = a = spot::ltl_to_tgba(f, dict);
spot::ltl::destroy(f);
#ifdef TBA
spot::tgba* d = a = new spot::tgba_tba_proxy(a);
#endif
spot::lbtt_reachable(std::cout, a);
#ifdef TBA
delete d;
#endif
delete c;
}
else
{
exit_code = 1;
}
assert(spot::ltl::atomic_prop::instance_count() == 0);
assert(spot::ltl::unop::instance_count() == 0);
assert(spot::ltl::binop::instance_count() == 0);
assert(spot::ltl::multop::instance_count() == 0);
delete dict;
return exit_code;
}

View file

@ -7,15 +7,29 @@ set -e
cat > config <<EOF
Algorithm
{
Name = "Spot"
Path = "${LBTT_TRANSLATE} --spot ./spotlbtt"
Name = "Spot (Couvreur -- LaCIM)"
Path = "${LBTT_TRANSLATE} --spot './ltl2tgba -F -t'"
Enabled = yes
}
Algorithm
{
Name = "Spot TBA"
Path = "${LBTT_TRANSLATE} --spot ./tbalbtt"
Name = "Spot (Couvreur -- LACIM), degeneralized"
Path = "${LBTT_TRANSLATE} --spot './ltl2tgba -F -t -D'"
Enabled = yes
}
Algorithm
{
Name = "Spot (Couvreur -- FM)"
Path = "${LBTT_TRANSLATE} --spot './ltl2tgba -F -f -t'"
Enabled = yes
}
Algorithm
{
Name = "Spot (Couvreur -- FM), degeneralized"
Path = "${LBTT_TRANSLATE} --spot './ltl2tgba -F -f -t -D'"
Enabled = yes
}