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

Removing #rangeBool reasoning #2616

Merged
merged 5 commits into from
Sep 10, 2024
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
13 changes: 4 additions & 9 deletions kevm-pyk/src/kevm_pyk/kproj/evm-semantics/lemmas/lemmas.k
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,6 @@ module LEMMAS-WITHOUT-SLOT-UPDATES [symbolic]

rule #isPrecompiledAccount(#newAddr(_, _), _) => false [simplification]

// ########################
// #rangeBool reasoning
// ########################

rule [rangeBool-not-zero-l]: notBool (X ==Int 0) => X ==Int 1 requires #rangeBool(X) [simplification]
rule [rangeBool-not-zero-r]: notBool (0 ==Int X) => X ==Int 1 requires #rangeBool(X) [simplification]
rule [rangeBool-not-one-l]: notBool (X ==Int 1) => X ==Int 0 requires #rangeBool(X) [simplification]
rule [rangeBool-not-one-r]: notBool (1 ==Int X) => X ==Int 0 requires #rangeBool(X) [simplification]

// ########################
// bool2Word reasoning
// ########################
Expand Down Expand Up @@ -99,6 +90,10 @@ module LEMMAS-WITHOUT-SLOT-UPDATES [symbolic]
rule [b2w-bxor-one]: 1 xorInt bool2Word(Y) => bool2Word(notBool Y) [simplification, comm]
rule [b2w-bxor]: bool2Word(X) xorInt bool2Word(Y) => bool2Word ( (X andBool notBool Y) orBool (notBool X andBool Y) ) [simplification]

// Relationship with `#rangeBool`
rule [b2w-rangeBool-eq-not-zero-l]: bool2Word (notBool (X ==Int 0)) => X requires #rangeBool(X) [simplification, comm]
rule [b2w-rangeBool-eq-not-zero-r]: bool2Word (notBool (0 ==Int X)) => X requires #rangeBool(X) [simplification, comm]

Comment on lines +93 to +96
Copy link
Member

Choose a reason for hiding this comment

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

Do we also want the ones for X ==Int 1 and 1 ==Int X?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think so, at least not for now, because these ones (the one with X ==Int 0 specifically, and then I added the commutative version) come from the compiler as a check that something is a bool.

// As part of multiplication
rule [b2w-mul-lt-l]: bool2Word(B) *Int C <Int A => (B andBool C <Int A) orBool (notBool B andBool 0 <Int A) [simplification]
rule [b2w-mul-le-l]: bool2Word(B) *Int C <=Int A => (B andBool C <=Int A) orBool (notBool B andBool 0 <=Int A) [simplification]
Expand Down
2 changes: 2 additions & 0 deletions tests/specs/examples/sum-to-n-foundry-spec.k
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ module VERIFICATION
imports INFINITE-GAS
imports EVM

rule [rangeBool-not-zero-l]: notBool (X ==Int 0) => X ==Int 1 requires #rangeBool(X) [simplification]
ehildenb marked this conversation as resolved.
Show resolved Hide resolved

rule N xorInt maxUInt256 => maxUInt256 -Int N
requires #rangeUInt(256, N)
[simplification]
Expand Down
Loading