From bbb16b6fc7f95f75632fe50934ef4fbdf6f75bb4 Mon Sep 17 00:00:00 2001 From: Asger Hautop Drewsen Date: Tue, 5 Dec 2023 18:03:34 +0100 Subject: [PATCH] Improve BoolRef addition --- src/api/python/z3/z3.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/api/python/z3/z3.py b/src/api/python/z3/z3.py index 4d92af8b92c..18d3abc9d96 100644 --- a/src/api/python/z3/z3.py +++ b/src/api/python/z3/z3.py @@ -1572,7 +1572,12 @@ def sort(self): return BoolSortRef(Z3_get_sort(self.ctx_ref(), self.as_ast()), self.ctx) def __add__(self, other): - return If(self, 1, 0) + If(other, 1, 0) + if isinstance(other, BoolRef): + other = If(other, 1, 0) + return If(self, 1, 0) + other + + def __radd__(self, other): + return self + other def __rmul__(self, other): return self * other