Skip to content

Commit 33896e2

Browse files
authored
note down pc issue (#38)
1 parent 02071a4 commit 33896e2

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

SP1Chips/AddChip.lean

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def specAdd (rs2 rs1 rd : regidx) : StateM SP1State Unit := do
7474

7575
-- TODO(gzgz): this should be auto-generate-able from our constraints.
7676
def sp1Add (Main : Vector BabyBear 23) : StateM SP1State Unit := do
77-
incrementPC
77+
set_pc (Main[3].val + 4) -- dt: This should actually be coming from `CPUState.constraints` send
7878
let op_a := regidx.Regidx Main[4].val
7979
update_reg op_a (BitVec.ofNat 32 (↑Main[20] + ↑Main[21] * 65536))
8080

@@ -83,7 +83,8 @@ into the proper registers, then the add chip conforms to the spec. -/
8383
theorem SP1AddChip_Correct (Main : Vector BabyBear 23)
8484
(h_cstrs : SP1ConstraintList.allHold (constraints Main))
8585
(h_is_real : Main[22] = 1)
86-
(pc : BitVec 32) (reg_state : regidx → BitVec 32)
86+
(pc : BitVec 32) (hpc : pc = Main[3].val)
87+
(reg_state : regidx → BitVec 32)
8788
(hmem₁ : reg_state (regidx.Regidx Main[10].val) = .ofNat 32 (Main[11] + Main[12] * 65536))
8889
(hmem₂ : reg_state (regidx.Regidx Main[15].val) = .ofNat 32 (Main[16] + Main[17] * 65536)) :
8990
(sp1Add Main).run (pc, reg_state) = (specAdd (.Regidx Main[15].val) (.Regidx Main[10].val) (.Regidx Main[4].val)).run (pc, reg_state) := by
@@ -117,6 +118,7 @@ theorem SP1AddChip_Correct (Main : Vector BabyBear 23)
117118

118119
simp only [BabyBearPrime, BitVec.natCast_eq_ofNat, StateT.run_modify, StateT.run_bind,
119120
StateT.run_get, bind_pure_comp, map_pure, Prod.map_apply, id_eq]
121+
simp [hpc]
120122
refine congr_arg (fun out => pure (_, (_, out))) (funext fun reg => ?_)
121123
by_cases hreg : (regidx.Regidx (BitVec.ofNat 5 ↑Main[4])) = reg
122124
· rw [hreg, Function.update_self, Function.update_self, hmem₁, hmem₂,

0 commit comments

Comments
 (0)