Skip to content

Commit 53baa15

Browse files
committed
Merge branch 'nightly-with-mathlib' of https://github.com/leanprover/lean4 into joachim/issue10749
2 parents 846efe3 + 106b0fa commit 53baa15

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+904
-572
lines changed

src/Init/Control/Lawful/Basic.lean

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ theorem bind_pure_unit [Monad m] [LawfulMonad m] {x : m PUnit} : (x >>= fun _ =>
170170
theorem map_congr [Functor m] {x : m α} {f g : α → β} (h : ∀ a, f a = g a) : (f <$> x : m β) = g <$> x := by
171171
simp [funext h]
172172

173+
@[deprecated seq_eq_bind_map (since := "2025-10-26")]
173174
theorem seq_eq_bind {α β : Type u} [Monad m] [LawfulMonad m] (mf : m (α → β)) (x : m α) : mf <*> x = mf >>= fun f => f <$> x := by
174175
rw [bind_map]
175176

@@ -256,14 +257,3 @@ instance : LawfulMonad Id := by
256257
@[simp] theorem run_seq (f : Id (α → β)) (x : Id α) : (f <*> x).run = f.run x.run := rfl
257258

258259
end Id
259-
260-
/-! # Option -/
261-
262-
instance : LawfulMonad Option := LawfulMonad.mk'
263-
(id_map := fun x => by cases x <;> rfl)
264-
(pure_bind := fun _ _ => rfl)
265-
(bind_assoc := fun x _ _ => by cases x <;> rfl)
266-
(bind_pure_comp := fun _ x => by cases x <;> rfl)
267-
268-
instance : LawfulApplicative Option := inferInstance
269-
instance : LawfulFunctor Option := inferInstance

src/Init/Control/Lawful/Instances.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,12 +189,12 @@ instance [Monad m] [LawfulMonad m] : LawfulMonad (OptionT m) where
189189

190190
@[simp] theorem run_seq [Monad m] [LawfulMonad m] (f : OptionT m (α → β)) (x : OptionT m α) :
191191
(f <*> x).run = Option.elimM f.run (pure none) (fun f => Option.map f <$> x.run) := by
192-
simp [seq_eq_bind, Option.elimM, Option.elim]
192+
simp [seq_eq_bind_map, Option.elimM, Option.elim]
193193

194194
@[simp] theorem run_seqLeft [Monad m] [LawfulMonad m] (x : OptionT m α) (y : OptionT m β) :
195195
(x <* y).run = Option.elimM x.run (pure none)
196196
(fun x => Option.map (Function.const β x) <$> y.run) := by
197-
simp [seqLeft_eq, seq_eq_bind, Option.elimM, OptionT.run_bind]
197+
simp [seqLeft_eq, seq_eq_bind_map, Option.elimM, OptionT.run_bind]
198198

199199
@[simp] theorem run_seqRight [Monad m] [LawfulMonad m] (x : OptionT m α) (y : OptionT m β) :
200200
(x *> y).run = Option.elimM x.run (pure none) (Function.const α y.run) := by
@@ -219,7 +219,7 @@ instance : LawfulMonad Option := LawfulMonad.mk'
219219
(id_map := fun x => by cases x <;> rfl)
220220
(pure_bind := fun _ _ => by rfl)
221221
(bind_assoc := fun a _ _ => by cases a <;> rfl)
222-
(bind_pure_comp := bind_pure_comp)
222+
(bind_pure_comp := fun _ x => by cases x <;> rfl)
223223

224224
instance : LawfulApplicative Option := inferInstance
225225
instance : LawfulFunctor Option := inferInstance

src/Init/Control/Lawful/MonadLift/Lemmas.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ theorem monadLift_map [LawfulMonad m] [LawfulMonad n] (f : α → β) (ma : m α
2323

2424
theorem monadLift_seq [LawfulMonad m] [LawfulMonad n] (mf : m (α → β)) (ma : m α) :
2525
monadLift (mf <*> ma) = monadLift mf <*> (monadLift ma : n α) := by
26-
simp only [seq_eq_bind, monadLift_map, monadLift_bind]
26+
simp only [seq_eq_bind_map, monadLift_map, monadLift_bind]
2727

2828
theorem monadLift_seqLeft [LawfulMonad m] [LawfulMonad n] (x : m α) (y : m β) :
2929
monadLift (x <* y) = (monadLift x : n α) <* (monadLift y : n β) := by

src/Init/Core.lean

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1359,8 +1359,12 @@ namespace Subtype
13591359
theorem exists_of_subtype {α : Type u} {p : α → Prop} : { x // p x } → Exists (fun x => p x)
13601360
| ⟨a, h⟩ => ⟨a, h⟩
13611361

1362-
variable {α : Type u} {p : α → Prop}
1362+
variable {α : Sort u} {p : α → Prop}
13631363

1364+
protected theorem ext : ∀ {a1 a2 : {x // p x}}, val a1 = val a2 → a1 = a2
1365+
| ⟨_, _⟩, ⟨_, _⟩, rfl => rfl
1366+
1367+
@[deprecated Subtype.ext (since := "2025-10-26")]
13641368
protected theorem eq : ∀ {a1 a2 : {x // p x}}, val a1 = val a2 → a1 = a2
13651369
| ⟨_, _⟩, ⟨_, _⟩, rfl => rfl
13661370

@@ -1375,9 +1379,9 @@ instance {α : Type u} {p : α → Prop} [BEq α] [ReflBEq α] : ReflBEq {x : α
13751379
rfl {x} := BEq.refl x.1
13761380

13771381
instance {α : Type u} {p : α → Prop} [BEq α] [LawfulBEq α] : LawfulBEq {x : α // p x} where
1378-
eq_of_beq h := Subtype.eq (eq_of_beq h)
1382+
eq_of_beq h := Subtype.ext (eq_of_beq h)
13791383

1380-
instance {α : Type u} {p : α → Prop} [DecidableEq α] : DecidableEq {x : α // p x} :=
1384+
instance {α : Sort u} {p : α → Prop} [DecidableEq α] : DecidableEq {x : α // p x} :=
13811385
fun ⟨a, h₁⟩ ⟨b, h₂⟩ =>
13821386
if h : a = b then isTrue (by subst h; exact rfl)
13831387
else isFalse (fun h' => Subtype.noConfusion h' (fun h' => absurd h' h))
@@ -1494,20 +1498,24 @@ protected theorem PSigma.eta {α : Sort u} {β : α → Sort v} {a₁ a₂ : α}
14941498

14951499
/-! # Universe polymorphic unit -/
14961500

1501+
theorem PUnit.ext (a b : PUnit) : a = b := by
1502+
cases a; cases b; exact rfl
1503+
1504+
@[deprecated PUnit.ext (since := "2025-10-26")]
14971505
theorem PUnit.subsingleton (a b : PUnit) : a = b := by
14981506
cases a; cases b; exact rfl
14991507

15001508
theorem PUnit.eq_punit (a : PUnit) : a = ⟨⟩ :=
1501-
PUnit.subsingleton a ⟨⟩
1509+
PUnit.ext a ⟨⟩
15021510

15031511
instance : Subsingleton PUnit :=
1504-
Subsingleton.intro PUnit.subsingleton
1512+
Subsingleton.intro PUnit.ext
15051513

15061514
instance : Inhabited PUnit where
15071515
default := ⟨⟩
15081516

15091517
instance : DecidableEq PUnit :=
1510-
fun a b => isTrue (PUnit.subsingleton a b)
1518+
fun a b => isTrue (PUnit.ext a b)
15111519

15121520
/-! # Setoid -/
15131521

src/Init/Data/Array/Bootstrap.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ theorem foldlM_toList.aux [Monad m]
3131
· cases Nat.not_le_of_gt ‹_› (Nat.zero_add _ ▸ H)
3232
· rename_i i; rw [Nat.succ_add] at H
3333
simp [foldlM_toList.aux (j := j+1) H]
34-
rw (occs := [2]) [← List.getElem_cons_drop_succ_eq_drop ‹_›]
34+
rw (occs := [2]) [← List.getElem_cons_drop ‹_›]
3535
simp
3636
· rw [List.drop_of_length_le (Nat.ge_of_not_lt ‹_›)]; simp
3737

src/Init/Data/Array/GetLit.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,6 @@ where
5050
getLit_eq (xs : Array α) (i : Nat) (h₁ : xs.size = n) (h₂ : i < n) : xs.getLit i h₁ h₂ = getElem xs.toList i ((id (α := xs.toList.length = n) h₁) ▸ h₂) :=
5151
rfl
5252
go (i : Nat) (hi : i ≤ xs.size) : toListLitAux xs n hsz i hi (xs.toList.drop i) = xs.toList := by
53-
induction i <;> simp only [List.drop, toListLitAux, getLit_eq, List.getElem_cons_drop_succ_eq_drop, *]
53+
induction i <;> simp only [List.drop, toListLitAux, getLit_eq, List.getElem_cons_drop, *]
5454

5555
end Array

src/Init/Data/Array/Lemmas.lean

Lines changed: 48 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -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-
270268
theorem 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 α} (
817815
theorem 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")]
820823
theorem 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

18541857
theorem 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+
18561862
theorem 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")]
20612078
theorem 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

21052122
theorem 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

21342152
theorem 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

21592177
theorem 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

21732191
theorem 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

22372251
theorem 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.
36233637
grind_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 =]
36313640
theorem 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")]
42794289
theorem 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")]
42984309
theorem 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

src/Init/Data/Array/Lex/Lemmas.lean

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,18 @@ grind_pattern _root_.List.le_toArray => l₁.toArray ≤ l₂.toArray
3434
grind_pattern lt_toList => xs.toList < ys.toList
3535
grind_pattern le_toList => xs.toList ≤ ys.toList
3636

37+
@[simp]
38+
protected theorem not_lt [LT α] {xs ys : Array α} : ¬ xs < ys ↔ ys ≤ xs := Iff.rfl
39+
40+
@[deprecated Array.not_lt (since := "2025-10-26")]
3741
protected theorem not_lt_iff_ge [LT α] {xs ys : Array α} : ¬ xs < ys ↔ ys ≤ xs := Iff.rfl
42+
43+
@[simp]
44+
protected theorem not_le [LT α] {xs ys : Array α} :
45+
¬ xs ≤ ys ↔ ys < xs :=
46+
Classical.not_not
47+
48+
@[deprecated Array.not_le (since := "2025-10-26")]
3849
protected theorem not_le_iff_gt [LT α] {xs ys : Array α} :
3950
¬ xs ≤ ys ↔ ys < xs :=
4051
Classical.not_not
@@ -178,12 +189,6 @@ protected theorem le_total [LT α]
178189
[i : Std.Asymm (· < · : α → α → Prop)] (xs ys : Array α) : xs ≤ ys ∨ ys ≤ xs :=
179190
List.le_total xs.toList ys.toList
180191

181-
@[simp] protected theorem not_lt [LT α]
182-
{xs ys : Array α} : ¬ xs < ys ↔ ys ≤ xs := Iff.rfl
183-
184-
@[simp] protected theorem not_le [LT α]
185-
{xs ys : Array α} : ¬ ys ≤ xs ↔ xs < ys := Classical.not_not
186-
187192
protected theorem le_of_lt [LT α]
188193
[i : Std.Asymm (· < · : α → α → Prop)]
189194
{xs ys : Array α} (h : xs < ys) : xs ≤ ys :=

0 commit comments

Comments
 (0)