From a9513c19989454ac4aeaa83bdb6310cf6386835d Mon Sep 17 00:00:00 2001
From: Asger Hautop Drewsen <asger@tyilo.com>
Date: Tue, 5 Dec 2023 18:12:25 +0100
Subject: [PATCH] Improve BoolRef addition (#7045)

---
 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 4d92af8b9..18d3abc9d 100644
--- a/src/api/python/z3/z3.py
+++ b/src/api/python/z3/z3.py
@@ -1572,7 +1572,12 @@ class BoolRef(ExprRef):
         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