Skip to content

Commit 84d4c63

Browse files
authored
minor update to slot updates to align with tutorial (#2647)
1 parent 4a2692c commit 84d4c63

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

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

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -36,43 +36,43 @@ module SLOT-UPDATES [symbolic]
3636
A |Int #asWord ( B1 +Bytes B2 ) =>
3737
#asWord ( #buf ( 32 -Int lengthBytes(B2), (A /Int (2 ^Int (8 *Int lengthBytes(B2)))) |Int #asWord ( B1 ) ) +Bytes B2 )
3838
requires #rangeUInt(256, A) andBool A modInt (2 ^Int (8 *Int lengthBytes(B2))) ==Int 0 andBool lengthBytes(B1 +Bytes B2) <=Int 32
39-
[simplification, preserves-definedness]
39+
[simplification(40), comm, preserves-definedness]
4040

4141
// 2b. |Int of +Bytes, update to be done in right
4242
rule [bor-update-to-right]:
4343
A |Int #asWord ( B1 +Bytes B2 ) =>
4444
#asWord ( B1 +Bytes #buf ( lengthBytes(B2), A |Int #asWord ( B2 ) ) )
4545
requires 0 <=Int A andBool A <Int 2 ^Int (8 *Int lengthBytes(B2)) andBool lengthBytes(B2) <=Int 32
46-
[simplification, preserves-definedness]
46+
[simplification(40), comm, preserves-definedness]
4747

4848
// 3a. Update with explicit shift and symbolic slot
4949
rule [bor-update-with-shift]:
5050
( SHIFT *Int X ) |Int Y => #asWord ( #buf( 32 -Int ( log2Int(SHIFT) /Int 8 ), X ) +Bytes #buf( log2Int(SHIFT) /Int 8, Y ) )
5151
requires #isByteShift(SHIFT)
5252
andBool 0 <=Int X andBool X <Int 2 ^Int (8 *Int (32 -Int ( log2Int(SHIFT) /Int 8 )))
5353
andBool 0 <=Int Y andBool Y <Int SHIFT
54-
[simplification, concrete(SHIFT), comm, preserves-definedness]
54+
[simplification(42), concrete(SHIFT), comm, preserves-definedness]
5555

56-
// 3b. Buffer cropping
56+
// 3b. Update with implicit shift and symbolic slot
57+
rule [bor-update-without-shift]:
58+
X |Int Y => #asWord ( #buf ( 32 -Int #getFirstOneBit(X) /Int 8, X /Int ( 2 ^Int ( 8 *Int ( #getFirstOneBit(X) /Int 8 ) ) ) ) +Bytes
59+
#buf ( #getFirstOneBit(X) /Int 8, Y ) )
60+
requires #rangeUInt(256, X) andBool 0 <=Int #getFirstOneBit(X)
61+
andBool 0 <=Int Y andBool Y <Int 2 ^Int ( 8 *Int ( #getFirstOneBit(X) /Int 8 ) )
62+
[simplification(42), concrete(X), preserves-definedness]
63+
64+
// 4. Buffer cropping
5765
rule [buf-asWord-crop]:
5866
#buf (W:Int , #asWord(B:Bytes)) => #range(B, lengthBytes(B) -Int W, W)
5967
requires 0 <=Int W andBool W <=Int 32 andBool W <Int lengthBytes(B)
6068
andBool #asWord ( #range(B, 0, lengthBytes(B) -Int W) ) ==Int 0
6169
[simplification, concrete(W), preserves-definedness]
6270

63-
// 3c. Splitting the updated buffer into the updated value and the trailing zeros, explicit shift
64-
rule [buf-split-l]:
71+
// 5. Splitting the updated buffer into the updated value and the trailing zeros
72+
rule [buf-split-on-shift]:
6573
#buf ( W, SHIFT *Int X ) => #buf( W -Int ( log2Int(SHIFT) /Int 8 ), X ) +Bytes #buf( log2Int(SHIFT) /Int 8, 0)
6674
requires 0 <=Int W andBool W <=Int 32 andBool #isByteShift(SHIFT)
6775
andBool 0 <=Int X andBool X <Int 2 ^Int (8 *Int (W -Int ( log2Int(SHIFT) /Int 8)))
6876
[simplification, concrete(W, SHIFT), preserves-definedness]
6977

70-
// 3d. Splitting the updated buffer into the updated value and the trailing zeros, implicit shift
71-
rule [bor-split]:
72-
X |Int Y => #asWord ( #buf ( 32 -Int #getFirstOneBit(X) /Int 8, X /Int ( 2 ^Int ( 8 *Int ( #getFirstOneBit(X) /Int 8 ) ) ) ) +Bytes
73-
#buf ( #getFirstOneBit(X) /Int 8, Y ) )
74-
requires #rangeUInt(256, X) andBool 0 <=Int #getFirstOneBit(X)
75-
andBool 0 <=Int Y andBool Y <Int 2 ^Int ( 8 *Int ( #getFirstOneBit(X) /Int 8 ) )
76-
[simplification, concrete(X), preserves-definedness]
77-
7878
endmodule

0 commit comments

Comments
 (0)