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
|
|
@ -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
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue