Skip to content

Commit b752209

Browse files
committed
include/, kevm-pyk/, tests/specs/: rework/simplify allBut64th logic
1 parent 9730d23 commit b752209

File tree

7 files changed

+8
-11
lines changed

7 files changed

+8
-11
lines changed

include/kframework/evm.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2327,8 +2327,7 @@ There are several helpers for calculating gas (most of them also specified in th
23272327
23282328
syntax Int ::= #allBut64th ( Int ) [function, total, smtlib(gas_allBut64th)]
23292329
// ----------------------------------------------------------------------------
2330-
rule [allBut64th.pos]: #allBut64th(N) => N -Int (N /Int 64) requires 0 <=Int N
2331-
rule [allBut64th.neg]: #allBut64th(N) => 0 requires N <Int 0
2330+
rule [allBut64th]: #allBut64th(N) => N -Int (N /Int 64)
23322331
```
23332332

23342333
```{.k .nobytes}

include/kframework/infinite-gas.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,8 @@ module INFINITE-GAS-COMMON
141141
rule Cextra(_, _, _, _) <Int #gas(_) => true [simplification]
142142
rule Cextra(_, _, _, _) <Int pow256 => true [simplification]
143143
144-
rule 0 <=Int #allBut64th(_) => true [simplification]
145-
rule #allBut64th(G) <Int #gas(G') => true requires G <Int #gas(G') [simplification]
144+
rule 0 <=Int #allBut64th(G) => true requires 0 <=Int G [simplification]
145+
rule #allBut64th(G) <Int G' => true requires G <Int G' [simplification]
146146
147147
rule 0 <=Int _:ScheduleConst < _:Schedule > => true [simplification]
148148
rule _:ScheduleConst < _:Schedule > <Int #gas(_) => true [simplification]

include/kframework/lemmas/lemmas.k

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ module LEMMAS [symbolic]
2727
rule maxUInt48 &Int X <Int pow48 => true requires 0 <=Int X [simplification, smt-lemma]
2828
rule maxUInt160 &Int X <Int pow160 => true requires 0 <=Int X [simplification, smt-lemma]
2929

30-
rule (X /Int 64) +Int #allBut64th(X) => X requires 0 <=Int X [simplification]
30+
rule (X /Int 64) +Int #allBut64th(X) => X [simplification]
3131

3232
// ########################
3333
// Set Reasoning

kevm-pyk/src/kevm_pyk/kevm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def hook_namespaces() -> List[str]:
121121
@staticmethod
122122
def concrete_rules() -> List[str]:
123123
return [
124-
'EVM.allBut64th.pos',
124+
'EVM.allBut64th',
125125
'EVM.Caddraccess',
126126
'EVM.Cbalance.new',
127127
'EVM.Cbalance.old',

tests/specs/concrete-rules.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
EVM.allBut64th.pos
1+
EVM.allBut64th
22
EVM.Caddraccess
33
EVM.Cbalance.new
44
EVM.Cbalance.old

tests/specs/functional/infinite-gas-spec.k

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ module INFINITE-GAS-SPEC
3333

3434
claim <k> runLemma(((VGas -Int (#allBut64th(VGas +Int -2655) +Int 700)) +Int #allBut64th(VGas +Int -2655)) +Int -7244) => doneLemma(VGas +Int -7944) ... </k>
3535

36-
claim [allBut64th-1]: <k> runLemma(((VGAS +Int -32247) /Int 64) +Int #allBut64th(VGAS +Int -32247)) => doneLemma(VGAS +Int -32247) ... </k> requires 0 <=Int VGAS
37-
3836
claim <k> runLemma(X +Int (0 -Int ABI_wad)) => doneLemma(X -Int ABI_wad) ... </k>
3937

4038
claim <k> runLemma(#memoryUsageUpdate(#memoryUsageUpdate(MEMORYUSED_CELL, 0, 32), 32, 32)) => doneLemma(#memoryUsageUpdate(MEMORYUSED_CELL, 32, 32)) ... </k>
@@ -56,8 +54,6 @@ module INFINITE-GAS-SPEC
5654
claim <k> runLemma(#gas(#gas(G1 -Int G2) +Int #allBut64th(G3))) => doneLemma(#gas((G1 -Int G2) +Int #allBut64th(G3))) ... </k> requires 0 <Int G3
5755
claim <k> runLemma(#gas(#gas(G1 -Int G2) -Int #allBut64th(G3))) => doneLemma(#gas((G1 -Int G2) -Int #allBut64th(G3))) ... </k> requires 0 <Int G3 andBool G3 <Int #gas(G1 -Int G2)
5856

59-
claim <k> runLemma(#gas(G) +Int (#allBut64th((VGas -Int Csstore(ISTANBUL, V1, V2, V3)) +Int -3232) +Int -3232)) => doneLemma(#gas(G +Int (#allBut64th((VGas -Int Csstore(ISTANBUL, V1, V2, V3)) +Int -3232) +Int -3232))) ... </k>
60-
claim <k> runLemma(#gas(G) +Int ((#allBut64th(VGas -Int Csstore(ISTANBUL, V1, V2, V3)) -Int Csstore(ISTANBUL, V1', V2', V3')) +Int -3232)) => doneLemma(#gas(G +Int ((#allBut64th(VGas -Int Csstore(ISTANBUL, V1, V2, V3)) -Int Csstore(ISTANBUL, V1', V2', V3')) +Int -3232))) ... </k>
6157

6258
claim <k> runLemma(#gas(G) -Int Cmem(SCHED, #memoryUsageUpdate(MU, W0, 32))) => doneLemma(#gas(G -Int Cmem(SCHED, #memoryUsageUpdate(MU, W0, 32)))) ... </k>
6359
requires #rangeUInt(256, MU) andBool #rangeUInt(256, W0)

tests/specs/functional/lemmas-spec.k

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ module LEMMAS-SPEC
6666
=> doneLemma(368263281805664599098893944405654396525700029268) ... </k>
6767
requires #rangeUInt(256, X)
6868

69+
claim [allBut64th-1]: <k> runLemma(((VGAS +Int -32247) /Int 64) +Int #allBut64th(VGAS +Int -32247)) => doneLemma(VGAS +Int -32247) ... </k>
70+
6971
// Buffer write simplifications
7072
// ----------------------------
7173

0 commit comments

Comments
 (0)