fix(normalize): Add Xor simplification to simplify_boolean#906
Closed
aryanjsingh wants to merge 1 commit intoCPMpy:masterfrom
Closed
fix(normalize): Add Xor simplification to simplify_boolean#906aryanjsingh wants to merge 1 commit intoCPMpy:masterfrom
aryanjsingh wants to merge 1 commit intoCPMpy:masterfrom
Conversation
Collaborator
|
Hi aryan, Thanks for submitting a PR. I'm not sure why you closed it? It does look like you are introducing a whole lot of code. I've looked a bit closer into the bug, and there are 2 things:
The 2nd one is the less obvious one that needs attention, but even if it would be fixed, the 1st would still be a needless waste of effort. So instead of adding xor to simplification, perhaps we should add simplification before the xor decomposition... |
Merged
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
This PR adds support for simplifying
Xorexpressions within thesimplify_booleantransformation. This prevents premature decomposition ofXorwith constant values, which could lead to errors in later transformations likelinearizeas reported in the issue.Changes
simplify_booleantransformation. This is done by adding a new case in thevisit_operatormethod of theSimplifyVisitorclass. The logic correctly handles constantBoolValarguments, simplifying the expression before it can be decomposed incorrectly by later transformations.test_xor_simplifyto verify the new simplification logic for theXoroperator. This test includes the specific case from the issue, as well as other edge cases to ensure correctness.Related Issue
Closes #747