Before this change, all automata would construct their own

dictionaries (map of BDD variables to LTL formulae).  This was
cumbersome, because to multiply two automata we had to build a
common dictionary (the union of the two LTL formula spaces), and
install wrappers to translate each automaton's BDD answers into
the common dictionary.  This translation, that had to be repeated
when several products were nested, was time consuming and was a
hindrance for some optimizations.
In the new scheme, all automata involved in a product must
share the same dictionary.  An empty dictionary should be
constructed by the user and passed to the automaton' constructors
as necessary.
This huge change removes most code than it adds.

* src/Makefile.am (libspot_la_LIBADD): Add misc/libmisc.la.
* src/misc/bddalloc.hh, src/misc/bddalloc.cc: New files.  These
partly replace src/tgba/bddfactory.hh and src/tgba/bddfactory.cc.
* src/misc/Makefile.am: Adjust to build bddalloc.hh and bddalloc.cc.
* src/tgba/bddfactory.hh, src/tgba/bddfactory.cc,
src/tgba/dictunion.hh, src/tgba/dictunion.cc,
src/tgba/tgbabdddict.hh, src/tgba/tgbabdddict.cc,
src/tgba/tgbabddtranslatefactory.hh,
src/tgba/tgbabddtranslatefactory.cc,
src/tgba/tgbatranslateproxy.hh, src/tgba/tgbatranslateproxy.cc:
Delete.
* src/tgba/bdddict.hh, src/tgba/bdddict.cc: New files.  These
replaces tgbabdddict.hh and tgbabdddict.cc, and also part of
bddfactory.hh and bddfactory.cc.
* src/tgba/bddprint.cc, src/tgba/bddprint.hh: Adjust to
use bdd_dict* instead of tgba_bdd_dict&.
* src/tgba/succiterconcrete.cc (succ_iter_concrete::next()):
Get next_to_now from the dictionary.
* src/tgba/tgba.hh (tgba::get_dict): Return a bdd_dict*,
not a const tgba_bdd_dict*.
* src/tgba/tgbabddconcrete.cc, src/tgba/tgbabddconcrete.hh:
Adjust to use the new dictionary, stored in data_.
* src/tgba/tgbabddconcretefactory.cc,
src/tgba/tgbabddconcretefactory.hh: Likewise.  Plus
now_to_next_ is now also stored in the dictionary.
* src/tgba/tgbabddconcreteproduct.cc: Likewise.  Now
that both operand share the same product, there is not
point in using tgba_bdd_translate_factory.
* src/tgba/tgbabddcoredata.cc, src/tgba/tgbabddcoredata.hh:
Store a bdd_dict (taken as constructor argument).
(tgba_bdd_core_data::~tgba_bdd_core_data): Remove.
(tgba_bdd_core_data::translate): Remove.
(tgba_bdd_core_data::next_to_now): Remove (now in dict).
(tgba_bdd_core_data::dict): New pointer.
* src/tgba/tgbabddfactory.hh: (tgba_bdd_factory::get_dict): Remove.
* src/tgba/tgbaexplicit.cc, src/tgba/tgbaexplicit.hh:
Adjust to use the new dictionary.
* src/tgba/tgbaproduct.cc, src/tgba/tgbaproduct.hh: Likewise.  Do
not use tgba_bdd_dict_union and tgba_bdd_translate_proxy anymore.
* src/tgbaalgos/lbtt.cc, src/tgbaalgos/save.cc: Adjust to
use bdd_dict* instead of tgba_bdd_dict&.
* src/tgbaalgos/ltl2tgba.cc, src/tgbaalgos/ltl2tgba.cc: Likewise.
(ltl_to_tgba): Take a dict argument.
* src/tgbaparse/public.hh (tgba_parse): Take a dict argument.
* src/tgbaparse/tgbaparse.yy (tgba_parse): Take a dict argument.
* src/tgbatest/explicit.cc, src/tgbatest/explprod.cc,
src/tgbatest/ltlprod.cc, src/tgbatest/mixprod.cc,
src/tgbatest/readsave.cc, src/tgbatest/spotlbtt.cc,
src/tgbatest/tgbaread.cc, src/tgbatest/tripprod.cc: Instantiate
a dictionary, and pass it to the automata' constructors.
* src/tgbatest/ltl2tgba.cc: Likewise, and remove the -o (defrag)
option.
* iface/gspn/gspn.hh (tgba_gspn::tgba_gspn): Take a bdd_dict argument.
(tgba_gspn::get_dict): Adjust return type.
* iface/gspn/gspn.cc: Do not use bdd_factory, adjust to
use the new dictionary instead.
This commit is contained in:
Alexandre Duret-Lutz 2003-07-14 21:42:59 +00:00
parent 3013ba8da6
commit cab3be9795
52 changed files with 930 additions and 1034 deletions

View file

@ -1,29 +1,40 @@
#include <iostream>
#include <cassert>
#include "ltlenv/defaultenv.hh"
#include "tgba/tgbaexplicit.hh"
#include "tgbaalgos/dotty.hh"
#include "ltlast/allnodes.hh"
int
main()
{
spot::bdd_dict* dict = new spot::bdd_dict();
spot::ltl::default_environment& e =
spot::ltl::default_environment::instance();
spot::tgba_explicit a;
spot::tgba_explicit* a = new spot::tgba_explicit(dict);
typedef spot::tgba_explicit::transition trans;
trans* t1 = a.create_transition("state 0", "state 1");
trans* t2 = a.create_transition("state 1", "state 2");
trans* t3 = a.create_transition("state 2", "state 0");
a.add_condition(t2, e.require("a"));
a.add_condition(t3, e.require("b"));
a.add_condition(t3, e.require("c"));
a.declare_accepting_condition(e.require("p"));
a.declare_accepting_condition(e.require("q"));
a.declare_accepting_condition(e.require("r"));
a.add_accepting_condition(t1, e.require("p"));
a.add_accepting_condition(t1, e.require("q"));
a.add_accepting_condition(t2, e.require("r"));
trans* t1 = a->create_transition("state 0", "state 1");
trans* t2 = a->create_transition("state 1", "state 2");
trans* t3 = a->create_transition("state 2", "state 0");
a->add_condition(t2, e.require("a"));
a->add_condition(t3, e.require("b"));
a->add_condition(t3, e.require("c"));
a->declare_accepting_condition(e.require("p"));
a->declare_accepting_condition(e.require("q"));
a->declare_accepting_condition(e.require("r"));
a->add_accepting_condition(t1, e.require("p"));
a->add_accepting_condition(t1, e.require("q"));
a->add_accepting_condition(t2, e.require("r"));
spot::dotty_reachable(std::cout, a);
spot::dotty_reachable(std::cout, *a);
delete a;
delete dict;
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);
}

View file

@ -22,13 +22,15 @@ main(int argc, char** argv)
if (argc != 3)
syntax(argv[0]);
spot::bdd_dict* dict = new spot::bdd_dict();
spot::ltl::environment& env(spot::ltl::default_environment::instance());
spot::tgba_parse_error_list pel1;
spot::tgba_explicit* a1 = spot::tgba_parse(argv[1], pel1, env);
spot::tgba_explicit* a1 = spot::tgba_parse(argv[1], pel1, dict, env);
if (spot::format_tgba_parse_errors(std::cerr, pel1))
return 2;
spot::tgba_parse_error_list pel2;
spot::tgba_explicit* a2 = spot::tgba_parse(argv[2], pel2, env);
spot::tgba_explicit* a2 = spot::tgba_parse(argv[2], pel2, dict, env);
if (spot::format_tgba_parse_errors(std::cerr, pel2))
return 2;
@ -44,5 +46,6 @@ main(int argc, char** argv)
delete a1;
delete a2;
assert(spot::ltl::atomic_prop::instance_count() == 0);
delete dict;
return exit_code;
}

View file

@ -5,7 +5,6 @@
#include "ltlparse/public.hh"
#include "tgbaalgos/ltl2tgba.hh"
#include "tgba/bddprint.hh"
#include "tgba/tgbabddtranslatefactory.hh"
#include "tgbaalgos/dotty.hh"
#include "tgbaalgos/lbtt.hh"
@ -19,7 +18,6 @@ syntax(char* prog)
<< std::endl
<< " -A same as -a, but as a set" << std::endl
<< " -d turn on traces during parsing" << std::endl
<< " -o re-order BDD variables in the automata" << std::endl
<< " -r display the relation BDD, not the reachability graph"
<< std::endl
<< " -R same as -r, but as a set" << std::endl
@ -35,7 +33,6 @@ main(int argc, char** argv)
int exit_code = 0;
bool debug_opt = false;
bool defrag_opt = false;
int output = 0;
int formula_index = 0;
@ -58,10 +55,6 @@ main(int argc, char** argv)
{
debug_opt = true;
}
else if (!strcmp(argv[formula_index], "-o"))
{
defrag_opt = true;
}
else if (!strcmp(argv[formula_index], "-r"))
{
output = 1;
@ -84,7 +77,6 @@ main(int argc, char** argv)
}
}
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],
@ -93,12 +85,11 @@ main(int argc, char** argv)
exit_code =
spot::ltl::format_parse_errors(std::cerr, argv[formula_index], pel);
spot::bdd_dict* dict = new spot::bdd_dict();
if (f)
{
spot::tgba_bdd_concrete a = spot::ltl_to_tgba(f);
spot::tgba_bdd_concrete a = spot::ltl_to_tgba(f, dict);
spot::ltl::destroy(f);
if (defrag_opt)
a = spot::defrag(a);
switch (output)
{
case 0:
@ -121,7 +112,7 @@ main(int argc, char** argv)
a.get_core_data().accepting_conditions);
break;
case 5:
a.get_dict().dump(std::cout);
a.get_dict()->dump(std::cout);
break;
case 6:
spot::lbtt_reachable(std::cout, a);
@ -139,5 +130,6 @@ main(int argc, char** argv)
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

@ -37,9 +37,10 @@ main(int argc, char** argv)
if (spot::ltl::format_parse_errors(std::cerr, argv[2], pel2))
return 2;
spot::bdd_dict* dict = new spot::bdd_dict();
{
spot::tgba_bdd_concrete a1 = spot::ltl_to_tgba(f1);
spot::tgba_bdd_concrete a2 = spot::ltl_to_tgba(f2);
spot::tgba_bdd_concrete a1 = spot::ltl_to_tgba(f1, dict);
spot::tgba_bdd_concrete a2 = spot::ltl_to_tgba(f2, dict);
spot::ltl::destroy(f1);
spot::ltl::destroy(f2);
@ -56,5 +57,6 @@ main(int argc, char** argv)
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

@ -24,6 +24,8 @@ main(int argc, char** argv)
if (argc != 3)
syntax(argv[0]);
spot::bdd_dict* dict = new spot::bdd_dict();
spot::ltl::environment& env(spot::ltl::default_environment::instance());
spot::ltl::parse_error_list pel1;
@ -32,12 +34,12 @@ main(int argc, char** argv)
return 2;
spot::tgba_parse_error_list pel2;
spot::tgba_explicit* a2 = spot::tgba_parse(argv[2], pel2, env);
spot::tgba_explicit* a2 = spot::tgba_parse(argv[2], pel2, dict, env);
if (spot::format_tgba_parse_errors(std::cerr, pel2))
return 2;
{
spot::tgba_bdd_concrete a1 = spot::ltl_to_tgba(f1);
spot::tgba_bdd_concrete a1 = spot::ltl_to_tgba(f1, dict);
spot::ltl::destroy(f1);
spot::tgba_product p(a1, *a2);
@ -49,5 +51,6 @@ main(int argc, char** argv)
assert(spot::ltl::multop::instance_count() == 0);
delete a2;
assert(spot::ltl::atomic_prop::instance_count() == 0);
delete dict;
return exit_code;
}

View file

@ -1,7 +1,9 @@
#include <iostream>
#include <cassert>
#include "tgbaparse/public.hh"
#include "tgba/tgbaexplicit.hh"
#include "tgbaalgos/save.hh"
#include "ltlast/allnodes.hh"
void
syntax(char* prog)
@ -29,10 +31,12 @@ main(int argc, char** argv)
filename_index = 2;
}
spot::bdd_dict* dict = new spot::bdd_dict();
spot::ltl::environment& env(spot::ltl::default_environment::instance());
spot::tgba_parse_error_list pel;
spot::tgba_explicit* a = spot::tgba_parse(argv[filename_index],
pel, env, debug);
pel, dict, env, debug);
exit_code =
spot::format_tgba_parse_errors(std::cerr, pel);
@ -46,5 +50,12 @@ main(int argc, char** argv)
{
exit_code = 1;
}
delete dict;
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);
return exit_code;
}

View file

@ -35,9 +35,11 @@ main(int argc, char** argv)
if (! std::getline(fin, input, '\0'))
{
std::cerr << "Cannot read " << argv[1] << std::endl;
exit(2);
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);
@ -46,7 +48,7 @@ main(int argc, char** argv)
if (f)
{
spot::tgba_bdd_concrete a = spot::ltl_to_tgba(f);
spot::tgba_bdd_concrete a = spot::ltl_to_tgba(f, dict);
spot::ltl::destroy(f);
spot::lbtt_reachable(std::cout, a);
}
@ -59,5 +61,6 @@ main(int argc, char** argv)
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

@ -1,7 +1,9 @@
#include <iostream>
#include <cassert>
#include "tgbaparse/public.hh"
#include "tgba/tgbaexplicit.hh"
#include "tgbaalgos/dotty.hh"
#include "ltlast/allnodes.hh"
void
syntax(char* prog)
@ -29,10 +31,12 @@ main(int argc, char** argv)
filename_index = 2;
}
spot::bdd_dict* dict = new spot::bdd_dict();
spot::ltl::environment& env(spot::ltl::default_environment::instance());
spot::tgba_parse_error_list pel;
spot::tgba_explicit* a = spot::tgba_parse(argv[filename_index],
pel, env, debug);
pel, dict, env, debug);
if (spot::format_tgba_parse_errors(std::cerr, pel))
return 2;
@ -46,5 +50,12 @@ main(int argc, char** argv)
{
return 1;
}
delete dict;
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);
return 0;
}

View file

@ -22,17 +22,19 @@ main(int argc, char** argv)
if (argc != 4)
syntax(argv[0]);
spot::bdd_dict* dict = new spot::bdd_dict();
spot::ltl::environment& env(spot::ltl::default_environment::instance());
spot::tgba_parse_error_list pel1;
spot::tgba_explicit* a1 = spot::tgba_parse(argv[1], pel1, env);
spot::tgba_explicit* a1 = spot::tgba_parse(argv[1], pel1, dict, env);
if (spot::format_tgba_parse_errors(std::cerr, pel1))
return 2;
spot::tgba_parse_error_list pel2;
spot::tgba_explicit* a2 = spot::tgba_parse(argv[2], pel2, env);
spot::tgba_explicit* a2 = spot::tgba_parse(argv[2], pel2, dict, env);
if (spot::format_tgba_parse_errors(std::cerr, pel2))
return 2;
spot::tgba_parse_error_list pel3;
spot::tgba_explicit* a3 = spot::tgba_parse(argv[3], pel3, env);
spot::tgba_explicit* a3 = spot::tgba_parse(argv[3], pel3, dict, env);
if (spot::format_tgba_parse_errors(std::cerr, pel3))
return 2;
@ -50,5 +52,6 @@ main(int argc, char** argv)
delete a2;
delete a3;
assert(spot::ltl::atomic_prop::instance_count() == 0);
delete dict;
return exit_code;
}