Commits

Leonardo de Moura committed 345c744

Added Xor to z3py

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>

  • Participants
  • Parent commits 6ffaadd

Comments (0)

Files changed (1)

     b = s.cast(b)
     return BoolRef(Z3_mk_implies(ctx.ref(), a.as_ast(), b.as_ast()), ctx)
 
+def Xor(a, b, ctx=None):
+    """Create a Z3 Xor expression.
+
+    >>> p, q = Bools('p q')
+    >>> Xor(p, q)
+    Xor(p, q)
+    >>> simplify(Xor(p, q))
+    Not(p) == q
+    """
+    ctx = _get_ctx(_ctx_from_ast_arg_list([a, b], ctx))
+    s = BoolSort(ctx)
+    a = s.cast(a)
+    b = s.cast(b)
+    return BoolRef(Z3_mk_xor(ctx.ref(), a.as_ast(), b.as_ast()), ctx)
+
 def Not(a, ctx=None):
     """Create a Z3 not expression or probe.