diff --git a/dd/_abc.py b/dd/_abc.py index 281c7828..8da51aee 100644 --- a/dd/_abc.py +++ b/dd/_abc.py @@ -663,6 +663,12 @@ def __or__( ) -> 'Operator': r"""Disjunction `self \/ other`.""" + def __xor__( + self, + other + ) -> 'Operator': + r"""Exclusive or `self + other`.""" + def implies( self, other diff --git a/dd/autoref.py b/dd/autoref.py index 5618f796..4281be2c 100644 --- a/dd/autoref.py +++ b/dd/autoref.py @@ -812,6 +812,13 @@ def __or__( ) -> _Ref: return self._apply('or', other) + def __xor__( + self, + other: + _Ref + ) -> _Ref: + return self._apply('xor', other) + def implies( self, other: diff --git a/dd/buddy.pyx b/dd/buddy.pyx index bdf58fd8..bda0a0fa 100644 --- a/dd/buddy.pyx +++ b/dd/buddy.pyx @@ -451,3 +451,11 @@ cdef class Function: ) -> Function: r = buddy.bdd_or(self.node, other.node) return Function(r) + + def __xor__( + self, + other: + Function + ) -> Function: + r = buddy.bdd_xor(self.node, other.node) + return Function(r) \ No newline at end of file diff --git a/dd/cudd.pyx b/dd/cudd.pyx index 324f78d2..2b4d291b 100644 --- a/dd/cudd.pyx +++ b/dd/cudd.pyx @@ -3126,6 +3126,19 @@ cdef class Function: self.manager, self.node, other.node) return wrap(self.bdd, r) + def __xor__( + self: + Function, + other: + Function + ) -> Function: + if self.manager != other.manager: + raise ValueError( + '`self.manager != other.manager`') + r = Cudd_bddXor( + self.manager, self.node, other.node) + return wrap(self.bdd, r) + def implies( self: Function, diff --git a/dd/sylvan.pyx b/dd/sylvan.pyx index a631233b..ccb660de 100644 --- a/dd/sylvan.pyx +++ b/dd/sylvan.pyx @@ -1036,3 +1036,15 @@ cdef class Function: sy.LACE_ME_WRAP r = sy.sylvan_or(self.node, other.node) return wrap(self.bdd, r) + + def __xor__( + self: + Function, + other: + Function + ) -> Function: + if self.bdd is not other.bdd: + raise ValueError((self, other)) + sy.LACE_ME_WRAP + r = sy.sylvan_xor(self.node, other.node) + return wrap(self.bdd, r) \ No newline at end of file