convert: BDD to cube conversions
* README, configure.ac, spot/Makefile.am, spot/twacube_algos/Makefile.am, spot/twacube_algos/convert.cc spot/twacube_algos/convert.hh, tests/core/cube.cc, tests/core/cube.test: here.
This commit is contained in:
parent
7c3fdd6b97
commit
8d57700d6a
8 changed files with 257 additions and 1 deletions
32
spot/twacube_algos/Makefile.am
Normal file
32
spot/twacube_algos/Makefile.am
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
## -*- coding: utf-8 -*-
|
||||
## Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016 Laboratoire
|
||||
## de Recherche et Développement 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.
|
||||
##
|
||||
## 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 3 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
AM_CPPFLAGS = -I$(top_builddir) -I$(top_srcdir) $(BUDDY_CPPFLAGS)
|
||||
AM_CXXFLAGS = $(WARNING_CXXFLAGS)
|
||||
|
||||
twacube_algosdir = $(pkgincludedir)/twacube_algos
|
||||
|
||||
twacube_algos_HEADERS = convert.hh
|
||||
|
||||
noinst_LTLIBRARIES = libtwacube_algos.la
|
||||
libtwacube_algos_la_SOURCES = \
|
||||
convert.cc
|
||||
61
spot/twacube_algos/convert.cc
Normal file
61
spot/twacube_algos/convert.cc
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
// -*- coding: utf-8 -*-
|
||||
// Copyright (C) 2015, 2016 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 3 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include <spot/twacube_algos/convert.hh>
|
||||
#include <assert.h>
|
||||
|
||||
namespace spot
|
||||
{
|
||||
spot::cube satone_to_cube(bdd one, cubeset& cubeset,
|
||||
std::unordered_map<int, int>& binder)
|
||||
{
|
||||
auto cube = cubeset.alloc();
|
||||
while (one != bddtrue)
|
||||
{
|
||||
if (bdd_high(one) == bddfalse)
|
||||
{
|
||||
assert(binder.find(bdd_var(one)) != binder.end());
|
||||
cubeset.set_false_var(cube, binder[bdd_var(one)]);
|
||||
one = bdd_low(one);
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(binder.find(bdd_var(one)) != binder.end());
|
||||
cubeset.set_true_var(cube, binder[bdd_var(one)]);
|
||||
one = bdd_high(one);
|
||||
}
|
||||
}
|
||||
return cube;
|
||||
}
|
||||
|
||||
bdd cube_to_bdd(spot::cube cube, const cubeset& cubeset,
|
||||
std::unordered_map<int, int>& reverse_binder)
|
||||
{
|
||||
bdd result = bddtrue;
|
||||
for (unsigned int i = 0; i < cubeset.size(); ++i)
|
||||
{
|
||||
assert(reverse_binder.find(i) != reverse_binder.end());
|
||||
if (cubeset.is_false_var(cube, i))
|
||||
result &= bdd_nithvar(reverse_binder[i]);
|
||||
if (cubeset.is_true_var(cube, i))
|
||||
result &= bdd_ithvar(reverse_binder[i]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
40
spot/twacube_algos/convert.hh
Normal file
40
spot/twacube_algos/convert.hh
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
// -*- coding: utf-8 -*-
|
||||
// Copyright (C) 2015, 2016 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 3 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <bddx.h>
|
||||
#include <unordered_map>
|
||||
#include <spot/misc/common.hh>
|
||||
#include <spot/twacube/cube.hh>
|
||||
|
||||
namespace spot
|
||||
{
|
||||
/// \brief Transform one truth assignment represented as a BDD
|
||||
/// into a \a cube cube passed in parameter. The parameter
|
||||
/// \a binder map bdd indexes to cube indexes.
|
||||
SPOT_API spot::cube satone_to_cube(bdd one, cubeset& cubeset,
|
||||
std::unordered_map<int, int>& binder);
|
||||
|
||||
/// \brief Transform a \a cube cube into bdd using the map
|
||||
/// that bind cube indexes to bdd indexes.
|
||||
SPOT_API bdd cube_to_bdd(spot::cube cube, const cubeset& cubeset,
|
||||
std::unordered_map<int, int>& reverse_binder);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue