Skip to content

Commit efcdaff

Browse files
PetarMaxPetar Maksimovic
andauthored
simpler Jal proof (#65)
Co-authored-by: Petar Maksimovic <[email protected]>
1 parent 5690223 commit efcdaff

File tree

1 file changed

+19
-43
lines changed

1 file changed

+19
-43
lines changed

SP1Chips/JalChip.lean

Lines changed: 19 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -100,49 +100,25 @@ theorem SP1JAL_correct
100100
Bool.and_self, bind_pure_comp, Functor.map_map, bind_map_left, EStateM.run_bind,
101101
run_bool_bit_backwards, sign_extend, Sail.BitVec.signExtend, ← h_sign_extend]
102102

103-
have h13_is_bool : Main[13] = 0 ∨ Main[13] = 1 := by aesop
104-
have h6_lt : Main[6].val < 2^5 := by aesop
105-
106-
cases h13_is_bool with
107-
| inl h13_is_0 =>
108-
simp [h13_is_0] at cstrs
109-
have h6 : Main[6] ≠ 0 := by aesop
110-
have h6' : ∀ p : ↑Main[6] < 2 ^ 5, (BitVec.ofNatLT Main[6].val p : BitVec 5) ≠ 0#5 := by
111-
refine fun p h => h6 ?_
112-
simp [← BitVec.toFin_inj] at h
113-
rw [← Fin.val_inj] at h
114-
simpa using h
115-
specialize h6' h6_lt
116-
rw [BitVec.ofNatLT_eq_ofNat] at h6'
117-
rw [run_readReg]
118-
simp [h6, read_pc]
119-
rw [run_readReg]
120-
simp [Std.ExtDHashMap.get?_insert, read_pc]
121-
simp [hmod]
122-
rw [run_readReg]
123-
simp [Std.ExtDHashMap.get?_insert, Std.ExtDHashMap.get?_eq_some_get h_misa]
124-
rw [run_readReg]
125-
simp [BitVec.ofNatLT_eq_ofNat, h6', h_add']
126-
simp [Word.toBitVec64, Word.toNat]
127-
have h_add_pc : List.Forall SP1Constraint.toProp (AddOperation.constraints
128-
#v[Main[3], Main[4], Main[5], 0] #v[4, 0, 0, 0]
129-
{value := #v[Main[26], Main[27], Main[28], Main[29]]} 1) := by aesop
130-
have h_add_pc' := (AddOperation.correct _ _ _ _ rfl h_add_pc pc_isU64 Word.four_isU64).2
131-
simp [Word.toBitVec64, Word.toNat] at h_add_pc'
132-
rw [h_add_pc', BitVec.ofNatLT_eq_ofNat]
133-
134-
| inr h13_is_1 =>
135-
simp [h13_is_1] at cstrs
136-
have h6 : Main[6] = 0 := by aesop
137-
simp [h6]
138-
rw [run_readReg]
139-
simp [read_pc]
140-
rw [run_readReg]
141-
simp [Std.ExtDHashMap.get?_insert, read_pc, hmod]
142-
rw [run_readReg]
143-
simp [Std.ExtDHashMap.get?_insert, Std.ExtDHashMap.get?_eq_some_get h_misa]
144-
rw [run_readReg]
145-
simp [h_add', Word.toBitVec64, Word.toNat]
103+
split_ifs with m6 m6b m6b <;>
104+
simp [← BitVec.toNat_inj] at m6 m6b <;>
105+
[ skip; omega; omega; skip ] <;>
106+
rw [run_readReg] <;>
107+
simp [read_pc] <;>
108+
rw [run_readReg] <;>
109+
simp [Std.ExtDHashMap.get?_insert, read_pc, hmod] <;>
110+
rw [run_readReg] <;>
111+
simp [Std.ExtDHashMap.get?_insert, Std.ExtDHashMap.get?_eq_some_get h_misa] <;>
112+
rw [run_readReg]
113+
. simp [h_add', Word.toBitVec64, Word.toNat]
114+
. simp [BitVec.ofNatLT_eq_ofNat, h_add']
115+
simp [Word.toBitVec64, Word.toNat]
116+
have h_add_pc : List.Forall SP1Constraint.toProp (AddOperation.constraints
117+
#v[Main[3], Main[4], Main[5], 0] #v[4, 0, 0, 0]
118+
{value := #v[Main[26], Main[27], Main[28], Main[29]]} 1) := by aesop
119+
have h_add_pc' := (AddOperation.correct _ _ _ _ rfl h_add_pc pc_isU64 Word.four_isU64).2
120+
simp [Word.toBitVec64, Word.toNat] at h_add_pc'
121+
rw [h_add_pc', BitVec.ofNatLT_eq_ofNat]
146122

147123
end JalChip
148124

0 commit comments

Comments
 (0)