Skip to content

Add boolean Xor operation and simplifier - #727

Open
twizmwazin wants to merge 1 commit into
masterfrom
feat/bool-xor
Open

Add boolean Xor operation and simplifier#727
twizmwazin wants to merge 1 commit into
masterfrom
feat/bool-xor

Conversation

@twizmwazin

Copy link
Copy Markdown
Member

Summary

Adds a first-class boolean Xor operation, ported from the feat/better-canonicalization branch (just the Xor pieces — independent of the And/Or work in #725).

  • Xor = operations.op("Xor", (Bool, Bool), Bool) in claripy/ast/bool.py, with Bool.__xor__ / Bool.__rxor__ operator overloads.
  • Exported as claripy.Xor.
  • A boolean_xor_simplifier that folds away a concrete operand:
    • Xor(x, False)x
    • Xor(x, True)~x

The z3 (_op_raw_Xor) and concrete (_op_xor) backends already handle the "Xor" op, and "Xor" is already in operations.commutative_operations, so this change only wires up the AST constructor, the public export, and the simplifier.

Testing

  • Added test_xor_simplification, test_xor_concrete, and test_xor_solve to tests/test_bool.py.
  • Full claripy suite: 333 passed, 1 skipped.
  • ruff check clean.

🤖 Generated with Claude Code

Expose a Bool Xor operation (with __xor__/__rxor__ operator overloads and
a public claripy.Xor export) and a simplifier that folds away a concrete
operand:
  Xor(x, False) -> x
  Xor(x, True)  -> ~x

The z3 and concrete backends already handle the "Xor" op, and it is
already listed in operations.commutative_operations, so this only wires up
the AST constructor and simplification. Ported from the
feat/better-canonicalization branch.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@angr-bot

angr-bot commented Jun 6, 2026

Copy link
Copy Markdown
Member

Corpus decompilation diffs can be found at angr/dec-snapshots@master...angr/claripy_727

@rhelmot

rhelmot commented Jun 7, 2026

Copy link
Copy Markdown
Member

Hey claude :3 I hear you like bugs - well I just got you a fresh batch to chew on! the typecheck pass failed to launch the first time, but I reran it and woahhhhh there's some regressions! go fetch boy! go get that code typechecking!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants