Add boolean Xor operation and simplifier - #727
Open
twizmwazin wants to merge 1 commit into
Open
Conversation
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>
Member
|
Corpus decompilation diffs can be found at angr/dec-snapshots@master...angr/claripy_727 |
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! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a first-class boolean
Xoroperation, ported from thefeat/better-canonicalizationbranch (just the Xor pieces — independent of the And/Or work in #725).Xor = operations.op("Xor", (Bool, Bool), Bool)inclaripy/ast/bool.py, withBool.__xor__/Bool.__rxor__operator overloads.claripy.Xor.boolean_xor_simplifierthat folds away a concrete operand:Xor(x, False)→xXor(x, True)→~xThe z3 (
_op_raw_Xor) and concrete (_op_xor) backends already handle the"Xor"op, and"Xor"is already inoperations.commutative_operations, so this change only wires up the AST constructor, the public export, and the simplifier.Testing
test_xor_simplification,test_xor_concrete, andtest_xor_solvetotests/test_bool.py.ruff checkclean.🤖 Generated with Claude Code