Improve SCC simplification by removing implied acceptance conditions.
Spot 0.7.1 used to need 190 acceptance conditions to translate the 188 literature formulae. With this patch we are down to 185. That's not an impressive, but there are only ~20 formulae that require more than 1 acceptance conditions; hence little room for improvement. * src/misc/bddlt.hh (bdd_hash): New function. * src/misc/accconv.hh, src/misc/accconv.cc: New files. * src/misc/Makefile.am: Add them. * src/tgbaalgos/scc.cc (scc_map::build_map): Adjust to record all combination of acceptance conditions occurring in a SCC. * src/tgbaalgos/scc.hh (scc_map::scc::useful_acc): Update description. * src/tgbaalgos/sccfilter.cc (scc_filter): Simplify acceptance conditions that are always implied by another acceptance conditions. Previously, we only removed acceptance conditions that where always present in accepting SCCs. * src/tgbatest/sccsimpl.test: New file. * src/tgbatest/Makefile.am (TESTS): Add it.
This commit is contained in:
parent
9d232af82f
commit
d9fc75e94e
10 changed files with 401 additions and 28 deletions
|
|
@ -30,6 +30,7 @@ nodist_misc_HEADERS = _config.h
|
|||
DISTCLEANFILES = _config.h
|
||||
|
||||
misc_HEADERS = \
|
||||
accconv.hh \
|
||||
bareword.hh \
|
||||
bddalloc.hh \
|
||||
bddlt.hh \
|
||||
|
|
@ -54,6 +55,7 @@ misc_HEADERS = \
|
|||
|
||||
noinst_LTLIBRARIES = libmisc.la
|
||||
libmisc_la_SOURCES = \
|
||||
accconv.cc \
|
||||
bareword.cc \
|
||||
bddalloc.cc \
|
||||
bddop.cc \
|
||||
|
|
|
|||
87
src/misc/accconv.cc
Normal file
87
src/misc/accconv.cc
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
// Copyright (C) 2011 Laboratoire de Recherche et Developpement de
|
||||
// l'Epita (LRDE)
|
||||
//
|
||||
// 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.
|
||||
|
||||
#include <cassert>
|
||||
#include "accconv.hh"
|
||||
|
||||
namespace spot
|
||||
{
|
||||
bdd acceptance_convertor::as_positive_product(bdd acc)
|
||||
{
|
||||
// Lookup in cache.
|
||||
bdd_cache_t::const_iterator it = pos_prod_cache_.find(acc);
|
||||
if (it != pos_prod_cache_.end())
|
||||
return it->second;
|
||||
|
||||
// Split the sum
|
||||
bdd res = bddtrue;
|
||||
bdd all = acc;
|
||||
while (all != bddfalse)
|
||||
{
|
||||
bdd one = bdd_satone(all);
|
||||
all -= one;
|
||||
// Lookup the subproduct in the cache.
|
||||
it = pos_prod_cache_.find(one);
|
||||
if (it != pos_prod_cache_.end())
|
||||
{
|
||||
res &= it->second;
|
||||
continue;
|
||||
}
|
||||
// Otherwise, strip negative variables.
|
||||
bdd pos = bddfalse;
|
||||
bdd cur = one;
|
||||
while (cur != bddfalse)
|
||||
{
|
||||
bdd low = bdd_low(cur);
|
||||
if (low == bddfalse)
|
||||
{
|
||||
pos = bdd_ithvar(bdd_var(cur));
|
||||
break;
|
||||
}
|
||||
cur = low;
|
||||
}
|
||||
assert(pos != bddfalse);
|
||||
// Cache result for subproduct.
|
||||
pos_prod_cache_[one] = pos;
|
||||
// Augment final result.
|
||||
res &= pos;
|
||||
}
|
||||
|
||||
// Cache final result.
|
||||
pos_prod_cache_[acc] = res;
|
||||
return res;
|
||||
};
|
||||
|
||||
bdd acceptance_convertor::as_full_product(bdd acc)
|
||||
{
|
||||
// Lookup in cache.
|
||||
bdd_cache_t::const_iterator it = full_prod_cache_.find(acc);
|
||||
if (it != full_prod_cache_.end())
|
||||
return it->second;
|
||||
|
||||
bdd pos = as_positive_product(acc);
|
||||
bdd res = bdd_exist(allneg_, pos) & pos;
|
||||
|
||||
// Cache final result.
|
||||
full_prod_cache_[acc] = res;
|
||||
return res;
|
||||
}
|
||||
|
||||
}
|
||||
53
src/misc/accconv.hh
Normal file
53
src/misc/accconv.hh
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
// Copyright (C) 2011 Laboratoire de Recherche et Developpement de
|
||||
// l'Epita (LRDE)
|
||||
//
|
||||
// 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.
|
||||
|
||||
#ifndef SPOT_MISC_ACCCONV_HH
|
||||
# define SPOT_MISC_ACCCONV_HH
|
||||
|
||||
#include <bdd.h>
|
||||
#include "misc/hash.hh"
|
||||
#include "misc/bddlt.hh"
|
||||
|
||||
namespace spot
|
||||
{
|
||||
/// \brief Help class to convert between acceptance conditions to
|
||||
/// other BDD formats.
|
||||
class acceptance_convertor
|
||||
{
|
||||
public:
|
||||
acceptance_convertor(bdd allneg)
|
||||
: allneg_(allneg)
|
||||
{
|
||||
}
|
||||
|
||||
bdd as_positive_product(bdd acc);
|
||||
|
||||
bdd as_full_product(bdd acc);
|
||||
|
||||
protected:
|
||||
bdd allneg_;
|
||||
typedef Sgi::hash_map<bdd, bdd, bdd_hash> bdd_cache_t;
|
||||
bdd_cache_t pos_prod_cache_;
|
||||
bdd_cache_t full_prod_cache_;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // SPOT_MISC_ACCCONV_HH
|
||||
|
|
@ -1,3 +1,5 @@
|
|||
// Copyright (C) 2011 Laboratoire de Recherche et Developpement de
|
||||
// l'Epita (LRDE).
|
||||
// Copyright (C) 2003, 2004 Laboratoire d'Informatique de Paris 6 (LIP6),
|
||||
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
|
||||
// et Marie Curie.
|
||||
|
|
@ -38,6 +40,19 @@ namespace spot
|
|||
return left.id() < right.id();
|
||||
}
|
||||
};
|
||||
|
||||
/// \brief Hash functor for BDDs.
|
||||
/// \ingroup misc_tools
|
||||
struct bdd_hash :
|
||||
public std::unary_function<const bdd&, size_t>
|
||||
{
|
||||
size_t
|
||||
operator()(const bdd& b) const
|
||||
{
|
||||
return b.id();
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // SPOT_MISC_BDDLT_HH
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue