Skip to content

Commit

Permalink
Streamlining #asWord simplifications (#2301)
Browse files Browse the repository at this point in the history
* streamlining #asWord simplifications

* Set Version: 1.0.456

* alternative approach

* Set Version: 1.0.457

* Added `buf-asWord-invert` test claim; fixed a typo

* Set Version: 1.0.458

* more general claim

---------

Co-authored-by: devops <[email protected]>
Co-authored-by: Palina Tolmach <[email protected]>
  • Loading branch information
3 people authored Feb 20, 2024
1 parent 88c6735 commit fbacafc
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 9 deletions.
2 changes: 1 addition & 1 deletion kevm-pyk/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "kevm-pyk"
version = "1.0.457"
version = "1.0.458"
description = ""
authors = [
"Runtime Verification, Inc. <[email protected]>",
Expand Down
2 changes: 1 addition & 1 deletion kevm-pyk/src/kevm_pyk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
from typing import Final


VERSION: Final = '1.0.457'
VERSION: Final = '1.0.458'
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,9 @@ module BYTES-SIMPLIFICATION [symbolic]

rule [buf-asWord-invert-rl]:
#asWord ( #buf ( WB:Int, X:Int ) ) => X
requires 0 <=Int WB andBool WB <=Int 32
andBool 0 <=Int X andBool X <Int 2 ^Int (WB *Int 8)
requires 0 <=Int WB andBool 0 <=Int X andBool
( ( WB <=Int 32 andBool X <Int 2 ^Int (WB *Int 8) ) orBool
( WB >Int 32 andBool X <Int pow256 ) )
[simplification, concrete(WB)]

rule [buf-asWord-invert-rl-range]:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ module EVM-INT-SIMPLIFICATION-COMMON
// #asWord
// ###########################################################################

rule [asWord-lb]: 0 <=Int #asWord(_WS) => true [simplification, smt-lemma]
rule [asWord-ub]: #asWord(_WS) <Int pow256 => true [simplification, smt-lemma]

rule [asWord-lt]:
#asWord ( BA ) <Int X => true
requires 2 ^Int ( lengthBytes(BA) *Int 8) <=Int X
Expand Down
3 changes: 0 additions & 3 deletions kevm-pyk/src/kevm_pyk/kproj/evm-semantics/lemmas/lemmas.k
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,6 @@ module LEMMAS [symbolic]

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

rule 0 <=Int #asWord(_WS) => true [simplification]
rule #asWord(_WS) <Int pow256 => true [simplification]

// ########################
// Keccak
// ########################
Expand Down
2 changes: 1 addition & 1 deletion package/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.457
1.0.458
13 changes: 12 additions & 1 deletion tests/specs/functional/lemmas-spec.k
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ module LEMMAS-SPEC
claim <k> runLemma ( 160 ==Int #asWord ( #buf( 4, 160 ) +Bytes ( #range( #buf( 32 , _BUF ), 0, 28 ) ) ) >>Int 224 )
=> doneLemma( true ) ... </k>

// buffer range sinplification
// buffer range simplification
// ---------------------------
claim <k> runLemma ( #range((#buf(DATA_LEN, DATA) +Bytes _BUF), 0, DATA_LEN) )
=> doneLemma ( #range( #buf(DATA_LEN, DATA) , 0, DATA_LEN) ) ... </k>
Expand Down Expand Up @@ -614,6 +614,17 @@ module LEMMAS-SPEC
) ... </k>
requires #rangeUInt(32, VV0_x_114b9705)

// #asWord
// ----------------

claim [buf-asWord-invert]:
<k> runLemma(
#asWord ( #buf ( 63 , lengthBytes ( VV0_data_114b9705:Bytes ) ) ) <=Int maxUInt64
) => doneLemma(
true
) ... </k>
requires lengthBytes ( VV0_data_114b9705:Bytes ) <=Int 1073741824

// ecrecover
// ---------

Expand Down

0 comments on commit fbacafc

Please sign in to comment.