Enhance div_xy_y to support signed and unsigned division simplification#576
Open
Enhance div_xy_y to support signed and unsigned division simplification#576
div_xy_y to support signed and unsigned division simplification#576Conversation
587ac5e to
f3ee43e
Compare
0xkarmacoma
suggested changes
Sep 10, 2025
Contributor
0xkarmacoma
left a comment
There was a problem hiding this comment.
thanks @sidarth16, note that it would cool to add a couple unit tests to verify the functionality
deferring to @daejunpark for the actual div_xy_y logic safety.
There was a problem hiding this comment.
Pull Request Overview
This PR enhances the div_xy_y helper function to handle simplifications for both unsigned (DIV) and signed (SDIV) EVM operations. The enhancement allows expressions like (x * y) / x or (x * y) / y to be simplified automatically, improving symbolic reasoning performance in arithmetic analysis.
Key changes:
- Extended
div_xy_yto support signed division with a newsignedparameter - Updated the arithmetic operation handler to use
div_xy_yfor both DIV and SDIV operations - Removed TODO comments indicating this functionality was planned
Reviewed Changes
Copilot reviewed 2 out of 4 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| src/halmos/sevm.py | Enhanced div_xy_y with signed division support and integrated it into DIV/SDIV operations |
| src/halmos/bitvec.py | Removed TODO comments for division simplification functionality |
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 updates the
div_xy_yhelper to handle simplifications for both unsigned (DIV) and signed (SDIV) EVM operations. It allows expressions like(x * y) / xor(x * y) / yto be simplified automatically, improving symbolic reasoning and reducing complexity in arithmetic analysis.Changes
signed: boolparameter todiv_xy_y.arithto calldiv_xy_yfor both DIV and SDIV before falling back to generic operations.Notes