Introduce cube data structure

* README, configure.ac, spot/Makefile.am,
spot/twacube/Makefile.am, spot/twacube/cube.cc,
spot/twacube/cube.hh, tests/Makefile.am,
tests/core/.gitignore, tests/core/cube.cc,
tests/core/cube.test: here.
This commit is contained in:
Etienne Renault 2015-11-30 15:31:17 +01:00
parent b7abe6f4b4
commit 7c3fdd6b97
10 changed files with 443 additions and 1 deletions

View file

@ -67,6 +67,7 @@ check_PROGRAMS = \
core/checkpsl \
core/checkta \
core/consterm \
core/cube \
core/emptchk \
core/equals \
core/graph \
@ -118,6 +119,7 @@ core_randtgba_SOURCES = core/randtgba.cc
core_taatgba_SOURCES = core/taatgba.cc
core_tgbagraph_SOURCES = core/twagraph.cc
core_consterm_SOURCES = core/consterm.cc
core_cube_SOURCES = core/cube.cc
core_equals_SOURCES = core/equalsf.cc
core_kind_SOURCES = core/kind.cc
core_length_SOURCES = core/length.cc
@ -152,6 +154,7 @@ core_tunenoform_CPPFLAGS = $(AM_CPPFLAGS) -DNENOFORM -DUNABBREV='"^ieFG"'
TESTS_tl = \
core/bare.test \
core/cube.test \
core/parse.test \
core/parseerr.test \
core/utf8.test \

View file

@ -8,6 +8,7 @@ checkpsl
checkta
complement
consterm
cube
defs
.deps
*.dot

58
tests/core/cube.cc Normal file
View file

@ -0,0 +1,58 @@
// -*- coding: utf-8 -*-
// Copyright (C) 2015, 2016 Laboratoire de Recherche et Développement
// de l'Epita.
//
// 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 <iostream>
#include <spot/twacube/cube.hh>
int main()
{
std::vector<std::string> aps = {"a", "b", "c", "d", "e"};
spot::cubeset cs(aps.size());
spot::cube mc = cs.alloc();
cs.set_true_var(mc, 0);
cs.set_false_var(mc, 3);
std::cout << "size : " << cs.size() << '\n';
std::cout << "cube : " << cs.dump(mc, aps) << '\n';
std::cout << "valid : " << cs.is_valid(mc) << '\n';
std::cout << "intersect(c,c) : " << cs.intersect(mc, mc) << '\n';
spot::cube mc1 = cs.alloc();
cs.set_false_var(mc1, 0);
cs.set_true_var(mc1, 1);
std::cout << "size : " << cs.size() << '\n';
std::cout << "cube : " << cs.dump(mc1, aps) << '\n';
std::cout << "valid : " << cs.is_valid(mc1) << '\n';
std::cout << "intersect(c1,c1) : " << cs.intersect(mc1, mc1) << '\n';
std::cout << "intersect(c,c1) : " << cs.intersect(mc, mc1) << '\n';
std::cout << "intersect(c1,c) : " << cs.intersect(mc1, mc) << '\n';
spot::cube mc2 = cs.alloc();
cs.set_true_var(mc2, 1);
cs.set_true_var(mc2, 3);
std::cout << "size : " << cs.size() << '\n';
std::cout << "cube : " << cs.dump(mc2, aps) << '\n';
std::cout << "valid : " << cs.is_valid(mc2) << '\n';
std::cout << "intersect(c2,c1) : " << cs.intersect(mc1, mc2) << '\n';
std::cout << "intersect(c2,c) : " << cs.intersect(mc, mc2) << '\n';
cs.release(mc2);
cs.release(mc1);
cs.release(mc);
}

53
tests/core/cube.test Executable file
View file

@ -0,0 +1,53 @@
#!/bin/sh
# -*- coding: utf-8 -*-
# Copyright (C) 2015, 2016 Laboratoire de Recherche et Développement 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/>.
# While running some benchmark, Tomáš Babiak found that Spot took too
# much time (i.e. >1h) to translate those six formulae. It turns out
# that the WDBA minimization was performed after the degeneralization
# algorithm, while this is not necessary (WDBA will produce a BA, so
# we may as well skip degeneralization). Translating these formulae
# in the test-suite ensure that they don't take too much time (the
# buildfarm will timeout if it does).
. ./defs
set -e
run 0 ../cube > stdout
cat >expected <<EOF
size : 5
cube : a&!d
valid : 1
intersect(c,c) : 1
size : 5
cube : !a&b
valid : 1
intersect(c1,c1) : 1
intersect(c,c1) : 0
intersect(c1,c) : 0
size : 5
cube : b&d
valid : 1
intersect(c2,c1) : 1
intersect(c2,c) : 0
EOF
diff stdout expected