@@ -79,13 +79,53 @@ def idxOf? [DecidableEq α] (xs : List α) (y: α) (i : Nat := 0) : Option Nat :
7979 then Option.some i
8080 else idxOf? xs y (i + 1 )
8181
82+ theorem idxOf_length' [DecidableEq α] {y: α} (h: idxOf? xs y n = some i):
83+ i < List.length xs + n := by
84+ induction xs generalizing i n with
85+ | nil =>
86+ simp [idxOf?] at h
87+ | cons x xs ih =>
88+ simp [idxOf?] at h
89+ split_ifs at h
90+ case pos hxy =>
91+ simp_all
92+ case neg hxy =>
93+ simp_all
94+ have ih' := @ih (n + 1 )
95+ rw [Nat.add_assoc]
96+ nth_rewrite 2 [Nat.add_comm]
97+ apply ih' h
98+
8299theorem idxOf_length [DecidableEq α] {y: α} (h: idxOf? xs y = some i):
83100 i < List.length xs := by
84- sorry
101+ apply idxOf_length' (n := 0 ) h
85102
86- theorem idxOf?_eq_none_iff [DecidableEq α] {l : List α} {a : α} :
87- idxOf? l a = none ↔ a ∉ l := by
88- sorry
103+ theorem idxOf?_eq_none_iff' [DecidableEq α] {xs : List α} {y : α} :
104+ idxOf? xs y i = none ↔ y ∉ xs := by
105+ induction xs generalizing i with
106+ | nil =>
107+ simp [idxOf?]
108+ | cons x xs ih =>
109+ simp [idxOf?]
110+ split_ifs
111+ case pos h =>
112+ subst_vars
113+ -- aesop?
114+ simp_all only [not_true_eq_false, false_and]
115+ case neg h =>
116+ have ih' := ih (i := i + 1 )
117+ -- aesop?
118+ simp_all only [iff_and_self]
119+ intro a
120+ simp_all only [not_false_eq_true, iff_true]
121+ apply Aesop.BuiltinRules.not_intro
122+ intro a_1
123+ subst a_1
124+ simp_all only [not_true_eq_false]
125+
126+ theorem idxOf?_eq_none_iff [DecidableEq α] {xs : List α} {y : α} :
127+ idxOf? xs y = none ↔ y ∉ xs := by
128+ apply idxOf?_eq_none_iff' (i := 0 )
89129
90130def indices [DecidableEq α] {xs: List α} (ys: { ys': List α // ∀ x ∈ xs, x ∈ ys' }): List.Vector (Fin (List.length ys.val)) (List.length xs) :=
91131 match xs with
0 commit comments