Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More Prop simplification rules #628

Merged
merged 1 commit into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
This should improve issues when "Unexpected Symbolic Arguments to Opcode" was
unnecessarily output

## Added
- More simplification rules for Props

## [0.54.2] - 2024-12-12

## Fixed
Expand Down
5 changes: 5 additions & 0 deletions src/EVM/Expr.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1220,7 +1220,9 @@ simplifyProp prop =
go (PLEq _ (Lit x)) | x == maxLit = PBool True
go (PLT (Lit val) (Var _)) | val == maxLit = PBool False
go (PLEq (Var _) (Lit val)) | val == maxLit = PBool True
go (PLT a b) | a == b = PBool False
go (PLT (Lit l) (Lit r)) = PBool (l < r)
go (PLEq a b) | a == b = PBool True
go (PLEq (Lit l) (Lit r)) = PBool (l <= r)
go (PLEq a (Max b _)) | a == b = PBool True
go (PLEq a (Max _ b)) | a == b = PBool True
Expand All @@ -1232,6 +1234,9 @@ simplifyProp prop =
go (PNeg (PBool b)) = PBool (Prelude.not b)
go (PNeg (PNeg a)) = a

-- Empty buf
go (PEq (Lit 0) (BufLength k)) = peq k (ConcreteBuf "")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure this is a simplification?
Is it better on the SMT level to compare arrays instead of computing buffer length and comparing it to 0?


-- solc specific stuff
go (PEq (Lit 0) (IsZero (IsZero (Eq a b)))) = PNeg (peq a b)

Expand Down
Loading