@@ -140,13 +140,13 @@ theorem getElem_of_getElem? {xs : Array α} : xs[i]? = some a → ∃ h : i < xs
140140theorem some_eq_getElem ?_iff {xs : Array α} : some b = xs[i]? ↔ ∃ h : i < xs.size, xs[i] = b := by
141141 rw [eq_comm, getElem?_eq_some_iff]
142142
143- @[simp] theorem some_getElem_eq_getElem ?_iff (xs : Array α) (i : Nat) (h : i < xs.size) :
143+ theorem some_getElem_eq_getElem ?_iff (xs : Array α) (i : Nat) (h : i < xs.size) :
144144 (some xs[i] = xs[i]?) ↔ True := by
145- simp [h]
145+ simp
146146
147- @[simp] theorem getElem ?_eq_some_getElem_iff (xs : Array α) (i : Nat) (h : i < xs.size) :
147+ theorem getElem ?_eq_some_getElem_iff (xs : Array α) (i : Nat) (h : i < xs.size) :
148148 (xs[i]? = some xs[i]) ↔ True := by
149- simp [h]
149+ simp
150150
151151theorem getElem_eq_iff {xs : Array α} {i : Nat} {h : i < xs.size} : xs[i] = x ↔ xs[i]? = some x := by
152152 simp only [getElem?_eq_some_iff]
@@ -186,12 +186,11 @@ theorem getElem?_push {xs : Array α} {x} : (xs.push x)[i]? = if i = xs.size the
186186 simp [getElem?_def, getElem_push]
187187 (repeat' split) <;> first | rfl | omega
188188
189- @[simp] theorem getElem ?_push_size {xs : Array α} {x} : (xs.push x)[xs.size]? = some x := by
190- simp [getElem?_push]
189+ theorem getElem ?_push_size {xs : Array α} {x} : (xs.push x)[xs.size]? = some x := by
190+ simp
191191
192- @[simp] theorem getElem_singleton {a : α} {i : Nat} (h : i < 1 ) : #[a][i] = a :=
193- match i, h with
194- | 0 , _ => rfl
192+ theorem getElem_singleton {a : α} {i : Nat} (h : i < 1 ) : #[a][i] = a := by
193+ simp
195194
196195@[grind]
197196theorem getElem ?_singleton {a : α} {i : Nat} : #[a][i]? = if i = 0 then some a else none := by
@@ -423,8 +422,7 @@ theorem eq_empty_iff_forall_not_mem {xs : Array α} : xs = #[] ↔ ∀ a, a ∉
423422theorem eq_of_mem_singleton (h : a ∈ #[b]) : a = b := by
424423 simpa using h
425424
426- @[simp] theorem mem_singleton {a b : α} : a ∈ #[b] ↔ a = b :=
427- ⟨eq_of_mem_singleton, (by simp [·])⟩
425+ theorem mem_singleton {a b : α} : a ∈ #[b] ↔ a = b := by simp
428426
429427theorem forall_mem_push {p : α → Prop } {xs : Array α} {a : α} :
430428 (∀ x, x ∈ xs.push a → p x) ↔ p a ∧ ∀ x, x ∈ xs → p x := by
@@ -868,8 +866,8 @@ theorem elem_eq_mem [BEq α] [LawfulBEq α] {a : α} {xs : Array α} :
868866@[simp, grind] theorem contains_eq_mem [BEq α] [LawfulBEq α] {a : α} {xs : Array α} :
869867 xs.contains a = decide (a ∈ xs) := by rw [← elem_eq_contains, elem_eq_mem]
870868
871- @[simp, grind] theorem any_empty [BEq α] {p : α → Bool} : (#[] : Array α).any p = false := by simp
872- @[simp, grind] theorem all_empty [BEq α] {p : α → Bool} : (#[] : Array α).all p = true := by simp
869+ @[grind] theorem any_empty [BEq α] {p : α → Bool} : (#[] : Array α).any p = false := by simp
870+ @[grind] theorem all_empty [BEq α] {p : α → Bool} : (#[] : Array α).all p = true := by simp
873871
874872/-- Variant of `any_push` with a side condition on `stop`. -/
875873@[simp, grind] theorem any_push' [BEq α] {xs : Array α} {a : α} {p : α → Bool} (h : stop = xs.size + 1 ) :
@@ -1228,7 +1226,7 @@ where
12281226@[simp] theorem mapM_empty [Monad m] (f : α → m β) : mapM f #[] = pure #[] := by
12291227 rw [mapM, mapM.map]; rfl
12301228
1231- @[simp, grind] theorem map_empty {f : α → β} : map f #[] = #[] := mapM_empty f
1229+ @[grind] theorem map_empty {f : α → β} : map f #[] = #[] := by simp
12321230
12331231@[simp, grind] theorem map_push {f : α → β} {as : Array α} {x : α} :
12341232 (as.push x).map f = (as.map f).push (f x) := by
@@ -1813,7 +1811,8 @@ theorem toArray_append {xs : List α} {ys : Array α} :
18131811
18141812theorem singleton_eq_toArray_singleton {a : α} : #[a] = [a].toArray := rfl
18151813
1816- @[simp] theorem empty_append_fun : ((#[] : Array α) ++ ·) = id := by
1814+ @[deprecated empty_append (since := " 2025-05-26" )]
1815+ theorem empty_append_fun : ((#[] : Array α) ++ ·) = id := by
18171816 funext ⟨l⟩
18181817 simp
18191818
@@ -1964,8 +1963,8 @@ theorem append_left_inj {xs₁ xs₂ : Array α} (ys) : xs₁ ++ ys = xs₂ ++ y
19641963theorem eq_empty_of_append_eq_empty {xs ys : Array α} (h : xs ++ ys = #[]) : xs = #[] ∧ ys = #[] :=
19651964 append_eq_empty_iff.mp h
19661965
1967- @[simp] theorem empty_eq_append_iff {xs ys : Array α} : #[] = xs ++ ys ↔ xs = #[] ∧ ys = #[] := by
1968- rw [eq_comm, append_eq_empty_iff]
1966+ theorem empty_eq_append_iff {xs ys : Array α} : #[] = xs ++ ys ↔ xs = #[] ∧ ys = #[] := by
1967+ simp
19691968
19701969theorem append_ne_empty_of_left_ne_empty {xs ys : Array α} (h : xs ≠ #[]) : xs ++ ys ≠ #[] := by
19711970 simp_all
@@ -2033,7 +2032,7 @@ theorem append_eq_append_iff {ws xs ys zs : Array α} :
20332032 simp only [List.append_toArray, List.set_toArray, List.set_append]
20342033 split <;> simp
20352034
2036- @[simp] theorem set_append_left {xs ys : Array α} {i : Nat} {x : α} (h : i < xs.size) :
2035+ @[simp] theorem set_append_left {xs ys : Array α} {i : Nat} {x : α} (h : i < xs.size) :
20372036 (xs ++ ys).set i x (by simp; omega) = xs.set i x ++ ys := by
20382037 simp [set_append, h]
20392038
@@ -2108,14 +2107,13 @@ theorem append_eq_map_iff {f : α → β} :
21082107 | nil => simp
21092108 | cons as => induction as.toList <;> simp [*]
21102109
2111- @[simp] theorem flatten_map_toArray {L : List (List α)} :
2112- (L.toArray. map List.toArray).flatten = L.flatten.toArray := by
2110+ @[simp] theorem flatten_toArray_map {L : List (List α)} :
2111+ (L.map List.toArray).toArray .flatten = L.flatten.toArray := by
21132112 apply ext'
21142113 simp [Function.comp_def]
21152114
2116- @[simp] theorem flatten_toArray_map {L : List (List α)} :
2117- (L.map List.toArray).toArray.flatten = L.flatten.toArray := by
2118- rw [← flatten_map_toArray]
2115+ theorem flatten_map_toArray {L : List (List α)} :
2116+ (L.toArray.map List.toArray).flatten = L.flatten.toArray := by
21192117 simp
21202118
21212119-- We set this to lower priority so that `flatten_toArray_map` is applied first when relevant.
@@ -2143,8 +2141,8 @@ theorem mem_flatten : ∀ {xss : Array (Array α)}, a ∈ xss.flatten ↔ ∃ xs
21432141 induction xss using array₂_induction
21442142 simp
21452143
2146- @[simp] theorem empty_eq_flatten_iff {xss : Array (Array α)} : #[] = xss.flatten ↔ ∀ xs ∈ xss, xs = #[] := by
2147- rw [eq_comm, flatten_eq_empty_iff]
2144+ theorem empty_eq_flatten_iff {xss : Array (Array α)} : #[] = xss.flatten ↔ ∀ xs ∈ xss, xs = #[] := by
2145+ simp
21482146
21492147theorem flatten_ne_empty_iff {xss : Array (Array α)} : xss.flatten ≠ #[] ↔ ∃ xs, xs ∈ xss ∧ xs ≠ #[] := by
21502148 simp
@@ -2284,15 +2282,9 @@ theorem eq_iff_flatten_eq {xss₁ xss₂ : Array (Array α)} :
22842282 rw [List.map_inj_right]
22852283 simp +contextual
22862284
2287- @[simp] theorem flatten_toArray_map_toArray {xss : List (List α)} :
2285+ theorem flatten_toArray_map_toArray {xss : List (List α)} :
22882286 (xss.map List.toArray).toArray.flatten = xss.flatten.toArray := by
2289- simp [flatten]
2290- suffices ∀ as, List.foldl (fun acc bs => acc ++ bs) as (List.map List.toArray xss) = as ++ xss.flatten.toArray by
2291- simpa using this #[]
2292- intro as
2293- induction xss generalizing as with
2294- | nil => simp
2295- | cons xs xss ih => simp [ih]
2287+ simp
22962288
22972289/-! ### flatMap -/
22982290
@@ -2322,13 +2314,9 @@ theorem flatMap_toArray_cons {β} {f : α → Array β} {a : α} {as : List α}
23222314 intro cs
23232315 induction as generalizing cs <;> simp_all
23242316
2325- @[simp, grind =] theorem flatMap_toArray {β} {f : α → Array β} {as : List α} :
2317+ theorem flatMap_toArray {β} {f : α → Array β} {as : List α} :
23262318 as.toArray.flatMap f = (as.flatMap (fun a => (f a).toList)).toArray := by
2327- induction as with
2328- | nil => simp
2329- | cons a as ih =>
2330- apply ext'
2331- simp [ih, flatMap_toArray_cons]
2319+ simp
23322320
23332321@[simp] theorem flatMap_id {xss : Array (Array α)} : xss.flatMap id = xss.flatten := by simp [flatMap_def]
23342322
@@ -3030,19 +3018,21 @@ theorem take_size {xs : Array α} : xs.take xs.size = xs := by
30303018 | succ n ih =>
30313019 simp [shrink.loop, ih]
30323020
3033- @[simp] theorem size_shrink {xs : Array α} {i : Nat} : (xs.shrink i).size = min i xs.size := by
3021+ -- This doesn't need to be a simp lemma, as shortly we will simplify `shrink` to `take`.
3022+ theorem size_shrink {xs : Array α} {i : Nat} : (xs.shrink i).size = min i xs.size := by
30343023 simp [shrink]
30353024 omega
30363025
3037- @[simp] theorem getElem_shrink {xs : Array α} {i j : Nat} (h : j < (xs.shrink i).size) :
3038- (xs.shrink i)[j] = xs[j]'(by simp at h; omega) := by
3026+ -- This doesn't need to be a simp lemma, as shortly we will simplify `shrink` to `take`.
3027+ theorem getElem_shrink {xs : Array α} {i j : Nat} (h : j < (xs.shrink i).size) :
3028+ (xs.shrink i)[j] = xs[j]'(by simp [size_shrink] at h; omega) := by
30393029 simp [shrink]
30403030
3041- @[simp] theorem toList_shrink {xs : Array α} {i : Nat} : (xs.shrink i).toList = xs.toList.take i := by
3042- apply List.ext_getElem <;> simp
3043-
30443031@[simp] theorem shrink_eq_take {xs : Array α} {i : Nat} : xs.shrink i = xs.take i := by
3045- ext <;> simp
3032+ ext <;> simp [size_shrink, getElem_shrink]
3033+
3034+ theorem toList_shrink {xs : Array α} {i : Nat} : (xs.shrink i).toList = xs.toList.take i := by
3035+ simp
30463036
30473037/-! ### foldlM and foldrM -/
30483038
@@ -4572,8 +4562,8 @@ Our goal is to have `simp` "pull `List.toArray` outwards" as much as possible.
45724562
45734563theorem toListRev_toArray {l : List α} : l.toArray.toListRev = l.reverse := by simp
45744564
4575- @[simp, grind =] theorem take_toArray {l : List α} {i : Nat} : l.toArray.take i = (l.take i).toArray := by
4576- apply Array.ext <;> simp
4565+ @[grind =] theorem take_toArray {l : List α} {i : Nat} : l.toArray.take i = (l.take i).toArray := by
4566+ simp
45774567
45784568@[simp, grind =] theorem mapM_toArray [Monad m] [LawfulMonad m] {f : α → m β} {l : List α} :
45794569 l.toArray.mapM f = List.toArray <$> l.mapM f := by
0 commit comments