File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -448,6 +448,19 @@ theorem forall_mem_iff_getElem {l : List α} {p : α → Prop} :
448448 (∀ x ∈ l, p x) ↔ ∀ (i : ℕ) (_ : i < l.length), p l[i] := by
449449 simp [mem_iff_getElem, @forall_swap α]
450450
451+ theorem get_surjective_iff {l : List α} : (∀ x, x ∈ l) ↔ l.get.Surjective :=
452+ ⟨fun h x ↦ mem_iff_get.mp <| h x, fun h x ↦ mem_iff_get.mpr <| h x⟩
453+
454+ theorem getElem_surjective_iff {l : List α} :
455+ (∀ x, x ∈ l) ↔ (fun (n : Fin l.length) ↦ l[n]).Surjective :=
456+ get_surjective_iff
457+
458+ theorem getElem?_surjective_iff {l : List α} : (∀ x, x ∈ l) ↔ (fun (n : ℕ) ↦ l[n]?).Surjective := by
459+ refine ⟨fun h x ↦ ?_, fun h x ↦ mem_iff_getElem?.mpr <| h x⟩
460+ cases x with
461+ | none => exact ⟨l.length, getElem?_eq_none le_rfl⟩
462+ | some x => exact mem_iff_getElem?.mp <| h x
463+
451464theorem get_tail (l : List α) (i) (h : i < l.tail.length)
452465 (h' : i + 1 < l.length := (by simp only [length_tail] at h; cutsat)) :
453466 l.tail.get ⟨i, h⟩ = l.get ⟨i + 1 , h'⟩ := by
You can’t perform that action at this time.
0 commit comments