Skip to content

Commit 6cf2f54

Browse files
authored
Support for multimasks in slot updates (#2657)
* support for multimasks * syntax correction * test correction
1 parent 3921a7a commit 6cf2f54

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

kevm-pyk/src/kevm_pyk/kproj/evm-semantics/lemmas/slot-updates.k

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,12 @@ module SLOT-UPDATES [symbolic]
2525
// SHIFT appropriate, and in the latter case, the slot will appear on the LHS of the |Int.
2626

2727
// 1. Slot masking using &Int
28-
rule [mask-b-and]:
28+
rule [multimask-b-and]:
2929
MASK:Int &Int SLOT:Int =>
30+
( MASK |Int ( 2 ^Int ( 8 *Int ( #getMaskShiftBytes(MASK) +Int #getMaskWidthBytes(MASK) ) ) -Int 1 ) )
31+
&Int
3032
#asWord ( #buf ( 32, SLOT ) [ 32 -Int ( #getMaskShiftBytes(MASK) +Int #getMaskWidthBytes(MASK) ) := #buf ( #getMaskWidthBytes(MASK), 0 ) ] )
31-
requires #isMask(MASK) andBool #rangeUInt(256, SLOT)
33+
requires 0 <=Int #getMaskShiftBytes(MASK) andBool 0 <=Int #getMaskWidthBytes(MASK) andBool #rangeUInt(256, SLOT)
3234
[simplification, concrete(MASK), preserves-definedness]
3335

3436
// 2a. |Int and +Bytes, update to be done in left

tests/specs/functional/slot-updates-spec.k

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,4 +191,17 @@ module SLOT-UPDATES-SPEC
191191
andBool notBool #asWord ( #range(BA, lengthBytes(BA) -Int (log2Int(X +Int 1) /Int 8), log2Int(X +Int 1) /Int 8) ) <=Int Y
192192
andBool X ==Int 2 ^Int ( 8 *Int 5 ) -Int 1 // 5 can be replaced by any number between 0 and 32
193193

194+
claim [slot-update-14]:
195+
<k> runLemma (
196+
#asWord ( #range (
197+
#buf ( 32 ,
198+
80750600743933639278906278912030932992000 |Int
199+
( 664984632478924800 |Int
200+
( 115792089237316195423570985008687885552524791327314281033844573408277819293695 &Int
201+
#asWord ( #range ( #buf ( 32 , #lookup ( STORAGE1:Map , 0 ) ) , 0 , 14 ) +Bytes
202+
b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" +Bytes
203+
#range ( #buf ( 32 , #lookup ( STORAGE1:Map , 0 ) ) , 27 , 4 ) +Bytes b"\x02" ) ) ) ) ,
204+
31 , 1 ) ) <=Int 2 )
205+
=> doneLemma ( true ) ... </k>
206+
194207
endmodule

0 commit comments

Comments
 (0)