@@ -265,8 +265,6 @@ theorem push_eq_push {a b : α} {xs ys : Array α} : xs.push a = ys.push b ↔ a
265265 · rintro ⟨rfl, rfl⟩
266266 rfl
267267
268- theorem push_eq_append_singleton {as : Array α} {x : α} : as.push x = as ++ #[x] := rfl
269-
270268theorem exists_push_of_ne_empty {xs : Array α} (h : xs ≠ #[]) :
271269 ∃ (ys : Array α) (a : α), xs = ys.push a := by
272270 rcases xs with ⟨xs⟩
@@ -817,6 +815,11 @@ theorem contains_eq_true_of_mem [BEq α] [ReflBEq α] {a : α} {as : Array α} (
817815theorem elem_iff [BEq α] [LawfulBEq α] {a : α} {xs : Array α} :
818816 elem a xs = true ↔ a ∈ xs := ⟨mem_of_contains_eq_true, contains_eq_true_of_mem⟩
819817
818+ @[grind =]
819+ theorem contains_iff_mem [BEq α] [LawfulBEq α] {a : α} {xs : Array α} :
820+ xs.contains a = true ↔ a ∈ xs := ⟨mem_of_contains_eq_true, contains_eq_true_of_mem⟩
821+
822+ @[deprecated contains_iff_mem (since := " 2025-10-26" )]
820823theorem contains_iff [BEq α] [LawfulBEq α] {a : α} {xs : Array α} :
821824 xs.contains a = true ↔ a ∈ xs := ⟨mem_of_contains_eq_true, contains_eq_true_of_mem⟩
822825
@@ -1139,7 +1142,7 @@ where
11391142 aux (i bs) :
11401143 mapM.map f xs i bs = (xs.toList.drop i).foldlM (fun bs a => bs.push <$> f a) bs := by
11411144 unfold mapM.map; split
1142- · rw [← List.getElem_cons_drop_succ_eq_drop ‹_›]
1145+ · rw [← List.getElem_cons_drop ‹_›]
11431146 simp only [aux (i + 1 ), map_eq_pure_bind, List.foldlM_cons, bind_assoc,
11441147 pure_bind]
11451148 rfl
@@ -1853,6 +1856,9 @@ theorem getElem_of_append {xs ys zs : Array α} (eq : xs = ys.push a ++ zs) (h :
18531856
18541857theorem push_eq_append {a : α} {as : Array α} : as.push a = as ++ #[a] := rfl
18551858
1859+ @[deprecated push_eq_append (since := " 2025-10-26" )]
1860+ theorem push_eq_append_singleton {as : Array α} {x : α} : as.push x = as ++ #[x] := rfl
1861+
18561862theorem append_inj {xs₁ xs₂ ys₁ ys₂ : Array α} (h : xs₁ ++ ys₁ = xs₂ ++ ys₂) (hl : xs₁.size = xs₂.size) :
18571863 xs₁ = xs₂ ∧ ys₁ = ys₂ := by
18581864 rcases xs₁ with ⟨s₁⟩
@@ -2053,11 +2059,22 @@ theorem append_eq_map_iff {f : α → β} :
20532059 | nil => simp
20542060 | cons as => induction as.toList <;> simp [*]
20552061
2056- @[simp] theorem flatten_toArray_map {L : List (List α)} :
2062+ @[simp] theorem flatten_toArray_map_toArray {L : List (List α)} :
20572063 (L.map List.toArray).toArray.flatten = L.flatten.toArray := by
20582064 apply ext'
20592065 simp [Function.comp_def]
20602066
2067+ @[deprecated flatten_toArray_map_toArray (since := " 2025-10-26" )]
2068+ theorem flatten_toArray_map {L : List (List α)} :
2069+ (L.map List.toArray).toArray.flatten = L.flatten.toArray := by
2070+ simp
2071+
2072+ @[grind =]
2073+ theorem flatten_map_toArray_toArray {L : List (List α)} :
2074+ (L.toArray.map List.toArray).flatten = L.flatten.toArray := by
2075+ simp
2076+
2077+ @[deprecated flatten_map_toArray_toArray (since := " 2025-10-26" )]
20612078theorem flatten_map_toArray {L : List (List α)} :
20622079 (L.toArray.map List.toArray).flatten = L.flatten.toArray := by
20632080 simp
@@ -2104,32 +2121,33 @@ theorem forall_mem_flatten {p : α → Prop} {xss : Array (Array α)} :
21042121
21052122theorem flatten_eq_flatMap {xss : Array (Array α)} : flatten xss = xss.flatMap id := by
21062123 induction xss using array₂_induction
2107- rw [flatten_toArray_map , List.flatten_eq_flatMap]
2124+ rw [flatten_toArray_map_toArray , List.flatten_eq_flatMap]
21082125 simp [List.flatMap_map]
21092126
21102127@[simp, grind _=_] theorem map_flatten {f : α → β} {xss : Array (Array α)} :
21112128 (flatten xss).map f = (map (map f) xss).flatten := by
21122129 induction xss using array₂_induction with
21132130 | of xss =>
2114- simp only [flatten_toArray_map , List.map_toArray, List.map_flatten, List.map_map,
2131+ simp only [flatten_toArray_map_toArray , List.map_toArray, List.map_flatten, List.map_map,
21152132 Function.comp_def]
2116- rw [← Function.comp_def, ← List.map_map, flatten_toArray_map ]
2133+ rw [← Function.comp_def, ← List.map_map, flatten_toArray_map_toArray ]
21172134
21182135@[simp, grind =] theorem filterMap_flatten {f : α → Option β} {xss : Array (Array α)} {stop : Nat} (w : stop = xss.flatten.size) :
21192136 filterMap f (flatten xss) 0 stop = flatten (map (filterMap f) xss) := by
21202137 subst w
21212138 induction xss using array₂_induction
2122- simp only [flatten_toArray_map, List.size_toArray, List.length_flatten, List.filterMap_toArray',
2123- List.filterMap_flatten, List.map_toArray, List.map_map, Function.comp_def]
2124- rw [← Function.comp_def, ← List.map_map, flatten_toArray_map]
2139+ simp only [flatten_toArray_map_toArray, List.size_toArray, List.length_flatten,
2140+ List.filterMap_toArray', List.filterMap_flatten, List.map_toArray, List.map_map,
2141+ Function.comp_def]
2142+ rw [← Function.comp_def, ← List.map_map, flatten_toArray_map_toArray]
21252143
21262144@[simp, grind =] theorem filter_flatten {p : α → Bool} {xss : Array (Array α)} {stop : Nat} (w : stop = xss.flatten.size) :
21272145 filter p (flatten xss) 0 stop = flatten (map (filter p) xss) := by
21282146 subst w
21292147 induction xss using array₂_induction
2130- simp only [flatten_toArray_map , List.size_toArray, List.length_flatten, List.filter_toArray' ,
2131- List.filter_flatten, List.map_toArray, List.map_map, Function.comp_def]
2132- rw [← Function.comp_def, ← List.map_map, flatten_toArray_map ]
2148+ simp only [flatten_toArray_map_toArray , List.size_toArray, List.length_flatten,
2149+ List.filter_toArray', List. filter_flatten, List.map_toArray, List.map_map, Function.comp_def]
2150+ rw [← Function.comp_def, ← List.map_map, flatten_toArray_map_toArray ]
21332151
21342152theorem flatten_filter_not_isEmpty {xss : Array (Array α)} :
21352153 flatten (xss.filter fun xs => !xs.isEmpty) = xss.flatten := by
@@ -2152,23 +2170,23 @@ theorem flatten_filter_ne_empty [DecidablePred fun xs : Array α => xs ≠ #[]]
21522170 induction xss using array₂_induction
21532171 rcases xs with ⟨l⟩
21542172 have this : [l.toArray] = [l].map List.toArray := by simp
2155- simp only [List.push_toArray, flatten_toArray_map , List.append_toArray]
2156- rw [this , ← List.map_append, flatten_toArray_map ]
2173+ simp only [List.push_toArray, flatten_toArray_map_toArray , List.append_toArray]
2174+ rw [this , ← List.map_append, flatten_toArray_map_toArray ]
21572175 simp
21582176
21592177theorem flatten_flatten {xss : Array (Array (Array α))} : flatten (flatten xss) = flatten (map flatten xss) := by
21602178 induction xss using array₃_induction with
21612179 | of xss =>
2162- rw [flatten_toArray_map ]
2180+ rw [flatten_toArray_map_toArray ]
21632181 have : (xss.map (fun xs => xs.map List.toArray)).flatten = xss.flatten.map List.toArray := by
21642182 induction xss with
21652183 | nil => simp
21662184 | cons xs xss ih =>
21672185 simp only [List.map_cons, List.flatten_cons, ih, List.map_append]
2168- rw [this , flatten_toArray_map , List.flatten_flatten, ← List.map_toArray, Array.map_map,
2186+ rw [this , flatten_toArray_map_toArray , List.flatten_flatten, ← List.map_toArray, Array.map_map,
21692187 ← List.map_toArray, map_map, Function.comp_def]
2170- simp only [Function.comp_apply, flatten_toArray_map ]
2171- rw [List.map_toArray, ← Function.comp_def, ← List.map_map, flatten_toArray_map ]
2188+ simp only [Function.comp_apply, flatten_toArray_map_toArray ]
2189+ rw [List.map_toArray, ← Function.comp_def, ← List.map_map, flatten_toArray_map_toArray ]
21722190
21732191theorem flatten_eq_push_iff {xss : Array (Array α)} {ys : Array α} {y : α} :
21742192 xss.flatten = ys.push y ↔
@@ -2177,13 +2195,13 @@ theorem flatten_eq_push_iff {xss : Array (Array α)} {ys : Array α} {y : α} :
21772195 induction xss using array₂_induction with
21782196 | of xs =>
21792197 rcases ys with ⟨ys⟩
2180- rw [flatten_toArray_map , List.push_toArray, mk.injEq, List.flatten_eq_append_iff]
2198+ rw [flatten_toArray_map_toArray , List.push_toArray, mk.injEq, List.flatten_eq_append_iff]
21812199 constructor
21822200 · rintro (⟨as, bs, rfl, rfl, h⟩ | ⟨as, bs, c, cs, ds, rfl, rfl, h⟩)
21832201 · rw [List.singleton_eq_flatten_iff] at h
21842202 obtain ⟨xs, ys, rfl, h₁, h₂⟩ := h
21852203 exact ⟨((as ++ xs).map List.toArray).toArray, #[], (ys.map List.toArray).toArray, by simp,
2186- by simpa using h₂, by rw [flatten_toArray_map ]; simpa⟩
2204+ by simpa using h₂, by rw [flatten_toArray_map_toArray ]; simpa⟩
21872205 · rw [List.singleton_eq_append_iff] at h
21882206 obtain (⟨h₁, h₂⟩ | ⟨h₁, h₂⟩) := h
21892207 · simp at h₁
@@ -2228,10 +2246,6 @@ theorem eq_iff_flatten_eq {xss₁ xss₂ : Array (Array α)} :
22282246 rw [List.map_inj_right]
22292247 simp +contextual
22302248
2231- theorem flatten_toArray_map_toArray {xss : List (List α)} :
2232- (xss.map List.toArray).toArray.flatten = xss.flatten.toArray := by
2233- simp
2234-
22352249/-! ### flatMap -/
22362250
22372251theorem flatMap_def {xs : Array α} {f : α → Array β} : xs.flatMap f = flatten (map f xs) := by
@@ -2535,8 +2549,8 @@ theorem getElem?_swap {xs : Array α} {i j : Nat} (hi hj) {k : Nat} : (xs.swap i
25352549 split <;> rename_i h₃
25362550 · simp only [← h₃, Nat.not_le.2 (Nat.lt_succ_self _), Nat.le_refl, false_and]
25372551 exact (List.getElem?_reverse' (Eq.trans (by simp +arith) h)).symm
2538- simp only [Nat.succ_le , Nat.lt_iff_le_and_ne.trans (and_iff_left h₃),
2539- Nat.lt_succ .symm.trans (Nat.lt_iff_le_and_ne.trans (and_iff_left (Ne.symm h₂)))]
2552+ simp only [Nat.succ_le_iff , Nat.lt_iff_le_and_ne.trans (and_iff_left h₃),
2553+ Nat.lt_succ_iff .symm.trans (Nat.lt_iff_le_and_ne.trans (and_iff_left (Ne.symm h₂)))]
25402554 · rw [H]; split <;> rename_i h₂
25412555 · cases Nat.le_antisymm (Nat.not_lt.1 h₁) (Nat.le_trans h₂.1 h₂.2 )
25422556 cases Nat.le_antisymm h₂.1 h₂.2
@@ -2551,7 +2565,7 @@ theorem getElem?_swap {xs : Array α} {i j : Nat} (hi hj) {k : Nat} : (xs.swap i
25512565 split
25522566 · rfl
25532567 · rename_i h
2554- simp only [← show k < _ + 1 ↔ _ from Nat.lt_succ (n := xs.size - 1 ), this , Nat.zero_le,
2568+ simp only [← show k < _ + 1 ↔ _ from Nat.lt_succ_iff (n := xs.size - 1 ), this , Nat.zero_le,
25552569 true_and, Nat.not_lt] at h
25562570 rw [List.getElem?_eq_none_iff.2 ‹_›, List.getElem?_eq_none_iff.2 (xs.toList.length_reverse ▸ ‹_›)]
25572571
@@ -2699,8 +2713,8 @@ theorem extract_loop_eq_aux {xs ys : Array α} {size start : Nat} :
26992713 | zero => rw [extract_loop_zero, extract_loop_zero, append_empty]
27002714 | succ size ih =>
27012715 if h : start < xs.size then
2702- rw [extract_loop_succ (h := h), ih, push_eq_append_singleton ]
2703- rw [extract_loop_succ (h := h), ih (ys := #[].push _), push_eq_append_singleton , empty_append]
2716+ rw [extract_loop_succ (h := h), ih, push_eq_append ]
2717+ rw [extract_loop_succ (h := h), ih (ys := #[].push _), push_eq_append , empty_append]
27042718 rw [append_assoc]
27052719 else
27062720 rw [extract_loop_of_ge (h := Nat.le_of_not_lt h)]
@@ -3622,11 +3636,6 @@ theorem contains_iff_exists_mem_beq [BEq α] {xs : Array α} {a : α} :
36223636-- With `LawfulBEq α`, it would be better to use `contains_iff_mem` directly.
36233637grind_pattern contains_iff_exists_mem_beq => xs.contains a
36243638
3625- @[grind =]
3626- theorem contains_iff_mem [BEq α] [LawfulBEq α] {xs : Array α} {a : α} :
3627- xs.contains a ↔ a ∈ xs := by
3628- simp
3629-
36303639@[simp, grind =]
36313640theorem contains_toList [BEq α] {xs : Array α} {x : α} :
36323641 xs.toList.contains x = xs.contains x := by
@@ -4276,6 +4285,7 @@ theorem getElem_fin_eq_getElem_toList {xs : Array α} {i : Fin xs.size} : xs[i]
42764285@[simp] theorem ugetElem_eq_getElem {xs : Array α} {i : USize} (h : i.toNat < xs.size) :
42774286 xs[i] = xs[i.toNat] := rfl
42784287
4288+ @[deprecated getElem?_eq_none (since := " 2025-10-26" )]
42794289theorem getElem ?_size_le {xs : Array α} {i : Nat} (h : xs.size ≤ i) : xs[i]? = none := by
42804290 simp [getElem?_neg, h]
42814291
@@ -4295,6 +4305,7 @@ theorem getElem?_push_lt {xs : Array α} {x : α} {i : Nat} (h : i < xs.size) :
42954305 (xs.push x)[i]? = some xs[i] := by
42964306 rw [getElem?_pos (xs.push x) i (size_push _ ▸ Nat.lt_succ_of_lt h), getElem_push_lt]
42974307
4308+ @[deprecated getElem?_push_size (since := " 2025-10-26" )]
42984309theorem getElem ?_push_eq {xs : Array α} {x : α} : (xs.push x)[xs.size]? = some x := by
42994310 rw [getElem?_pos (xs.push x) xs.size (size_push _ ▸ Nat.lt_succ_self xs.size), getElem_push_eq]
43004311
@@ -4426,7 +4437,8 @@ theorem uset_toArray {l : List α} {i : USize} {a : α} {h : i.toNat < l.toArray
44264437 apply ext'
44274438 simp
44284439
4429- @[simp, grind =] theorem flatten_toArray {L : List (List α)} :
4440+ @[deprecated Array.flatten_map_toArray_toArray (since := " 2025-10-26" )]
4441+ theorem flatten_toArray {L : List (List α)} :
44304442 (L.toArray.map List.toArray).flatten = L.flatten.toArray := by
44314443 apply ext'
44324444 simp
0 commit comments