Repository navigation
Expand file tree
/
Copy pathCorrect.lean
More file actions
52 lines (42 loc) · 2.19 KB
/
Copy pathCorrect.lean
File metadata and controls
52 lines (42 loc) · 2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import FeProofs.ScalarStore.Constructor
import FeProofs.ScalarStore.Set
import FeProofs.ScalarStore.Get
import Stele.Refine
/-!
# FeScalarStore correctness capstone (generated by `scripts/proof_skeleton.py`)
Thin top-level: the selector case split routes each selector to its per-function `…Body`
lemma, the shared revert paths close the rest, and the constructor is packaged into the
whole-contract refinement.
-/
open Stele ABI Ethereum Ethereum.EVM Reasoning.Theory Reasoning.Reach
namespace FeProofs.ScalarStore
set_option maxRecDepth 2000000
theorem feScalarStoreNoDispatch {σ σ₀ A I} {g : UInt256}
(hcode : I.code = feScalarStoreBytecode) (hsize : I.calldata.size < UInt256.size)
(hnm : ∀ i, i < 2 → (feScalarStoreSelBytes i == I.calldata.extract 0 4) = false) :
runtimeRefinementFor config contract σ σ₀ g A I := by
by_cases hsz : 4 ≤ I.calldata.size
· exact (feScalarStoreX_noMatch (g := Sat256.ofUInt256 g) hcode hsz hsize hnm)
|>.reEquivNoDispatch hcode (feScalarStoreDispatch_none_nomatch hnm)
· have hshort : I.calldata.size < 4 := by omega
exact (feScalarStoreX_short (g := Sat256.ofUInt256 g) hcode hshort)
|>.reEquivNoDispatch hcode (feScalarStoreDispatch_none_short hshort)
theorem feScalarStoreNoSelectorMatches {I : ExecutionEnv}
(h0 : ¬ selIs I (feScalarStoreSelBytes 0)) (h1 : ¬ selIs I (feScalarStoreSelBytes 1)) :
∀ i, i < 2 → (feScalarStoreSelBytes i == I.calldata.extract 0 4) = false := by
intro i hi
interval_cases i
· simpa [selIs] using h0
· simpa [selIs] using h1
theorem feScalarStoreCorrect :
runtimeRefinement config (feScalarStoreBytecode) contract := by
refine ⟨fun σ σ₀ g A I hcode hsize ↦ ?_⟩
by_cases h0 : selIs I (feScalarStoreSelBytes 0)
· exact feScalarStoreSetBody hcode hsize h0
· by_cases h1 : selIs I (feScalarStoreSelBytes 1)
· exact feScalarStoreGetBody hcode hsize h1
· exact feScalarStoreNoDispatch hcode hsize (feScalarStoreNoSelectorMatches h0 h1)
theorem feScalarStoreContractCorrect :
contractRefinement config feScalarStoreCreationBytecode contract :=
contractRefinement.of_constant feScalarStoreConstructorCorrect feScalarStoreCorrect
end FeProofs.ScalarStore