Repository navigation
Expand file tree
/
Copy pathCorrect.lean
More file actions
56 lines (46 loc) · 2.63 KB
/
Copy pathCorrect.lean
File metadata and controls
56 lines (46 loc) · 2.63 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
53
54
55
56
import FeProofs.IndexedPackedStore.Constructor
import FeProofs.IndexedPackedStore.Set
import FeProofs.IndexedPackedStore.SetTwo
import FeProofs.IndexedPackedStore.Get
import Stele.Refine
/-!
# FeIndexedPackedStore 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.IndexedPackedStore
set_option maxRecDepth 2000000
theorem feIndexedPackedStoreNoDispatch {σ σ₀ A I} {g : UInt256}
(hcode : I.code = feIndexedPackedStoreBytecode) (hsize : I.calldata.size < UInt256.size)
(hnm : ∀ i, i < 3 → (feIndexedPackedStoreSelBytes i == I.calldata.extract 0 4) = false) :
runtimeRefinementFor config contract σ σ₀ g A I := by
by_cases hsz : 4 ≤ I.calldata.size
· exact (feIndexedPackedStoreX_noMatch (g := Sat256.ofUInt256 g) hcode hsz hsize hnm)
|>.reEquivNoDispatch hcode (feIndexedPackedStoreDispatch_none_nomatch hnm)
· have hshort : I.calldata.size < 4 := by omega
exact (feIndexedPackedStoreX_short (g := Sat256.ofUInt256 g) hcode hshort)
|>.reEquivNoDispatch hcode (feIndexedPackedStoreDispatch_none_short hshort)
theorem feIndexedPackedStoreNoSelectorMatches {I : ExecutionEnv}
(h0 : ¬ selIs I (feIndexedPackedStoreSelBytes 0)) (h1 : ¬ selIs I (feIndexedPackedStoreSelBytes 1)) (h2 : ¬ selIs I (feIndexedPackedStoreSelBytes 2)) :
∀ i, i < 3 → (feIndexedPackedStoreSelBytes i == I.calldata.extract 0 4) = false := by
intro i hi
interval_cases i
· simpa [selIs] using h0
· simpa [selIs] using h1
· simpa [selIs] using h2
theorem feIndexedPackedStoreCorrect :
runtimeRefinement config (feIndexedPackedStoreBytecode) contract := by
refine ⟨fun σ σ₀ g A I hcode hsize ↦ ?_⟩
by_cases h0 : selIs I (feIndexedPackedStoreSelBytes 0)
· exact feIndexedPackedStoreSetBody hcode hsize h0
· by_cases h1 : selIs I (feIndexedPackedStoreSelBytes 1)
· exact feIndexedPackedStoreSetTwoBody hcode hsize h1
· by_cases h2 : selIs I (feIndexedPackedStoreSelBytes 2)
· exact feIndexedPackedStoreGetBody hcode hsize h2
· exact feIndexedPackedStoreNoDispatch hcode hsize (feIndexedPackedStoreNoSelectorMatches h0 h1 h2)
theorem feIndexedPackedStoreContractCorrect :
contractRefinement config feIndexedPackedStoreCreationBytecode contract :=
contractRefinement.of_constant feIndexedPackedStoreConstructorCorrect feIndexedPackedStoreCorrect
end FeProofs.IndexedPackedStore