Repository navigation
Expand file tree
/
Copy pathCorrect.lean
More file actions
48 lines (38 loc) · 1.91 KB
/
Copy pathCorrect.lean
File metadata and controls
48 lines (38 loc) · 1.91 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
import FeProofs.Constant.Constructor
import FeProofs.Constant.Answer
import Stele.Refine
/-!
# FeConstant 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.Constant
set_option maxRecDepth 2000000
theorem feConstantNoDispatch {σ σ₀ A I} {g : UInt256}
(hcode : I.code = feConstantBytecode) (hsize : I.calldata.size < UInt256.size)
(hnm : ∀ i, i < 1 → (feConstantSelBytes i == I.calldata.extract 0 4) = false) :
runtimeRefinementFor config contract σ σ₀ g A I := by
by_cases hsz : 4 ≤ I.calldata.size
· exact (feConstantX_noMatch (g := Sat256.ofUInt256 g) hcode hsz hsize hnm)
|>.reEquivNoDispatch hcode (feConstantDispatch_none_nomatch hnm)
· have hshort : I.calldata.size < 4 := by omega
exact (feConstantX_short (g := Sat256.ofUInt256 g) hcode hshort)
|>.reEquivNoDispatch hcode (feConstantDispatch_none_short hshort)
theorem feConstantNoSelectorMatches {I : ExecutionEnv}
(h0 : ¬ selIs I (feConstantSelBytes 0)) :
∀ i, i < 1 → (feConstantSelBytes i == I.calldata.extract 0 4) = false := by
intro i hi
interval_cases i
· simpa [selIs] using h0
theorem feConstantCorrect :
runtimeRefinement config (feConstantBytecode) contract := by
refine ⟨fun σ σ₀ g A I hcode hsize ↦ ?_⟩
by_cases h0 : selIs I (feConstantSelBytes 0)
· exact feConstantAnswerBody hcode hsize h0
· exact feConstantNoDispatch hcode hsize (feConstantNoSelectorMatches h0)
theorem feConstantContractCorrect :
contractRefinement config feConstantCreationBytecode contract :=
contractRefinement.of_constant feConstantConstructorCorrect feConstantCorrect
end FeProofs.Constant