From 2b46cb4bab72f4f9048032abb9978a4d146f7c15 Mon Sep 17 00:00:00 2001 From: Alexandre Duret-Lutz Date: Sun, 7 Nov 2010 11:15:56 +0100 Subject: [PATCH] Add interface for and test the bdd_setxor() function added to Buddy. * wrap/python/buddy.i (bdd_setxor): New function. * wrap/python/tests/setxor.py: New file. * wrap/python/tests/Makefile.am (TESTS): Add setxor.py. --- ChangeLog | 10 +++++++- wrap/python/buddy.i | 2 ++ wrap/python/tests/Makefile.am | 5 +++- wrap/python/tests/setxor.py | 47 +++++++++++++++++++++++++++++++++++ 4 files changed, 62 insertions(+), 2 deletions(-) create mode 100755 wrap/python/tests/setxor.py diff --git a/ChangeLog b/ChangeLog index a4da966d6..a080d0c0c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,8 +1,16 @@ +2010-11-07 Alexandre Duret-Lutz + + Add interface for and test the bdd_setxor() function added to Buddy. + + * wrap/python/buddy.i (bdd_setxor): New function. + * wrap/python/tests/setxor.py: New file. + * wrap/python/tests/Makefile.am (TESTS): Add setxor.py. + 2010-11-06 Alexandre Duret-Lutz * src/Makefile.am (libspot_la_LIBADD): Rename libneverclaimparse.la as libneverparse.la. - * src/neverparse/Makefile.am: Install files in + * src/neverparse/Makefile.am: Install files in $(pkgincludedir)/neverparse, not $(pkgincludedir)/neverclaimparse. 2010-11-06 Alexandre Duret-Lutz diff --git a/wrap/python/buddy.i b/wrap/python/buddy.i index 0b9542c8b..f9aee345e 100644 --- a/wrap/python/buddy.i +++ b/wrap/python/buddy.i @@ -1,3 +1,4 @@ +// Copyright (C) 2010 Laboratoire de Recherche et Développement de l'EPITA. // 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. @@ -155,6 +156,7 @@ bdd bdd_or(const bdd &l, const bdd &r); bdd bdd_xor(const bdd &l, const bdd &r); bdd bdd_imp(const bdd &l, const bdd &r); bdd bdd_biimp(const bdd &l, const bdd &r); +bdd bdd_setxor(const bdd &l, const bdd &r); bdd bdd_ite(const bdd &f, const bdd &g, const bdd &h); bdd bdd_exist(const bdd &r, const bdd &var); bdd bdd_existcomp(const bdd &r, const bdd &var); diff --git a/wrap/python/tests/Makefile.am b/wrap/python/tests/Makefile.am index 28ff34b4c..d694e4984 100644 --- a/wrap/python/tests/Makefile.am +++ b/wrap/python/tests/Makefile.am @@ -1,3 +1,5 @@ +## Copyright (C) 2010 Labortatoire de Recherche et Développement de +## l'EPITA. ## Copyright (C) 2003, 2004, 2005 Laboratoire d'Informatique de Paris 6 (LIP6), ## département Systèmes Répartis Coopératifs (SRC), Université Pierre ## et Marie Curie. @@ -35,4 +37,5 @@ TESTS = \ interdep.py \ minato.py \ modgray.py \ - optionmap.py + optionmap.py \ + setxor.py diff --git a/wrap/python/tests/setxor.py b/wrap/python/tests/setxor.py new file mode 100755 index 000000000..05856bf32 --- /dev/null +++ b/wrap/python/tests/setxor.py @@ -0,0 +1,47 @@ +# -*- mode: python; coding: iso-8859-1 -*- +# Copyright (C) 2010 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 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. + +import ltihooks +import sys +from buddy import * + +bdd_init(10000, 10000) +bdd_setvarnum(5) + +V = [bdd_ithvar(i) for i in range(5)] + +a = V[0] & -V[1] & V[2] & -V[3] +b = V[0] & V[1] & V[2] & -V[3] +c = -V[0] & V[1] & -V[2] & -V[3] + +assert(c == bdd_setxor(a,b)) +assert(c == bdd_setxor(b,a)) +assert(a == bdd_setxor(b,c)) +assert(a == bdd_setxor(c,b)) +assert(b == bdd_setxor(a,c)) +assert(b == bdd_setxor(c,a)) + +d = V[1] & V[2] & -V[3] & V[4] +e = V[0] & V[1] & -V[2] & -V[3] & V[4] + +assert(e == bdd_setxor(a,d)) +assert(e == bdd_setxor(d,a)) + +bdd_done()