Skip to content

Commit 1c557d3

Browse files
committed
proved findFinIdx lemma
1 parent 0cc2b8c commit 1c557d3

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

Pullback/UnquoteTy/SSA.lean

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,14 @@ def DVector.get : {L : List Type} → (v : DVector L) → (i : Fin L.length) →
132132
| .cons _ _, (a, _), ⟨0, _⟩ => a
133133
| .cons _ _, (_, as), ⟨Nat.succ i, h⟩ => DVector.get as ⟨i, Nat.le_of_succ_le_succ h⟩
134134

135-
theorem Array.find?_eq_getElem_findFinIdx? {α : Type u} (xs : Array α) (p : α → Bool): xs.find? p = (xs.findFinIdx? p).map (xs[·]) := by sorry
135+
theorem Array.find?_eq_getElem_findFinIdx? {α : Type u} (xs : Array α) (p : α → Bool) :
136+
xs.find? p = (xs.findFinIdx? p).map (xs[·]) := by
137+
rcases xs with ⟨xs⟩; ext
138+
simp [List.findFinIdx?_eq_pmap_findIdx?, List.findIdx?_eq_fst_find?_zipIdx,
139+
List.find?_eq_some_iff_getElem]
140+
constructor
141+
· rintro ⟨_, _, _, rfl, _⟩; grind
142+
· grind
136143

137144
-- (a : α, true) means break (a : α, false) means continue
138145
def SSA.loop {α : Type u} [Inhabited α] (init : α) (step : α → α × Bool) : α := sorry

0 commit comments

Comments
 (0)