Speedup syntactic_implication() by using a cache.

* src/ltlvisit/syntimpl.hh (syntactic_implication,
syntactic_implication_neg): Move as member of ...
(syntactic_implication_cache): ... this new class, that holds
a cache of results to speedup these functions.
* src/ltlvisit/syntimpl.cc: Adjust to use (lookup, populate,
and cleanup) the cache.
* src/ltltest/syntimpl.cc: Likewise.
* src/ltlvisit/reduce.hh (reduce): Take an optional
syntactic_implication_cache parameter.
* src/ltlvisit/reduce.cc: Adjust to use a
syntactic_implication_cache.
* src/ltltest/equals.cc: Call dump_instances() to help debugging.
This commit is contained in:
Alexandre Duret-Lutz 2010-12-09 18:53:31 +01:00
parent 20c088a45a
commit 4ef7805e73
6 changed files with 211 additions and 99 deletions

View file

@ -1,4 +1,4 @@
// Copyright (C) 2008, 2009 Laboratoire de Recherche et Développement
// Copyright (C) 2008, 2009, 2010 Laboratoire de Recherche et Développement
// de l'Epita (LRDE).
// Copyright (C) 2003, 2004, 2006 Laboratoire d'Informatique de
// Paris 6 (LIP6), département Systèmes Répartis Coopératifs (SRC),
@ -99,6 +99,7 @@ main(int argc, char** argv)
f1 = spot::ltl::reduce(f1);
tmp->destroy();
spot::ltl::dump(std::cout, f1);
std::cout << std::endl;
#endif
#ifdef REDUC_TAU
spot::ltl::formula* tmp;
@ -106,6 +107,7 @@ main(int argc, char** argv)
f1 = spot::ltl::reduce_tau03(f1, false);
tmp->destroy();
spot::ltl::dump(std::cout, f1);
std::cout << std::endl;
#endif
#ifdef REDUC_TAUSTR
spot::ltl::formula* tmp;
@ -113,16 +115,23 @@ main(int argc, char** argv)
f1 = spot::ltl::reduce_tau03(f1, true);
tmp->destroy();
spot::ltl::dump(std::cout, f1);
std::cout << std::endl;
#endif
int exit_code = f1 != f2;
f1->destroy();
f2->destroy();
spot::ltl::atomic_prop::dump_instances(std::cerr);
spot::ltl::unop::dump_instances(std::cerr);
spot::ltl::binop::dump_instances(std::cerr);
spot::ltl::multop::dump_instances(std::cerr);
spot::ltl::automatop::dump_instances(std::cerr);
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);
assert(spot::ltl::automatop::instance_count() == 0);
return exit_code;
}

View file

@ -1,4 +1,4 @@
// Copyright (C) 2008, 2009 Laboratoire de Recherche et Développement
// Copyright (C) 2008, 2009, 2010 Laboratoire de Recherche et Développement
// de l'Epita (LRDE).
// Copyright (C) 2004 Laboratoire d'Informatique de Paris 6
// (LIP6), département Systèmes Répartis Coopératifs (SRC), Université
@ -67,12 +67,14 @@ main(int argc, char** argv)
std::string f2s = spot::ltl::to_string(f2);
int exit_return = 0;
spot::ltl::syntactic_implication_cache* c =
new spot::ltl::syntactic_implication_cache;
switch (opt)
{
case 0:
std::cout << "Test f1 < f2" << std::endl;
if (spot::ltl::syntactic_implication(f1, f2))
if (c->syntactic_implication(f1, f2))
{
std::cout << f1s << " < " << f2s << std::endl;
exit_return = 1;
@ -81,7 +83,7 @@ main(int argc, char** argv)
case 1:
std::cout << "Test !f1 < f2" << std::endl;
if (spot::ltl::syntactic_implication_neg(f1, f2, false))
if (c->syntactic_implication_neg(f1, f2, false))
{
std::cout << "!(" << f1s << ") < " << f2s << std::endl;
exit_return = 1;
@ -90,7 +92,7 @@ main(int argc, char** argv)
case 2:
std::cout << "Test f1 < !f2" << std::endl;
if (spot::ltl::syntactic_implication_neg(f1, f2, true))
if (c->syntactic_implication_neg(f1, f2, true))
{
std::cout << f1s << " < !(" << f2s << ")" << std::endl;
exit_return = 1;
@ -107,6 +109,9 @@ main(int argc, char** argv)
f2->destroy();
ftmp1->destroy();
ftmp2->destroy();
delete c;
assert(spot::ltl::atomic_prop::instance_count() == 0);
assert(spot::ltl::unop::instance_count() == 0);
assert(spot::ltl::binop::instance_count() == 0);