Skip to content

Commit 1ec33a4

Browse files
committed
chore: cleanup set_option linter.deprecated (#19701)
Remove several uses of deprecated lemmas in non-deprecated lemmas. Also convert all `set_option linter.deprecated false` to `set_option linter.deprecated false in`, so it is easier for us to count via regex what remains. I think ``` set_option linter\.deprecated false.*(?:(?:\n/--.*?-/\n(?!.*deprecated))|\n(?!.*deprecated|/--)) ``` is the correct regex to use now: it accounts properly for intervening doc-strings. It now reports that there are only ~~three~~ one! file~~s~~ that use `set_option linter.deprecated false` on non-deprecated declarations, namely: * ~~Mathlib.Data.List.Permutation~~ (fixed by moving some List theorems earlier) * ~~Mathlib.LinearAlgebra.CliffordAlgebra.Grading~~ (replace `AlgHom.map_zero` with just `map_zero`; only costs 2000 heartbeats) * Mathlib.SetTheory.Ordinal.Arithmetic (which is a mess)
1 parent 19e3a19 commit 1ec33a4

File tree

17 files changed

+194
-67
lines changed

17 files changed

+194
-67
lines changed

Mathlib/Algebra/BigOperators/Group/List.lean

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Authors: Johannes Hölzl, Floris van Doorn, Sébastien Gouëzel, Alex J. Best
55
-/
66
import Mathlib.Algebra.Divisibility.Basic
77
import Mathlib.Algebra.Group.Int
8+
import Mathlib.Data.List.Lemmas
89
import Mathlib.Data.List.Dedup
910
import Mathlib.Data.List.Flatten
1011
import Mathlib.Data.List.Pairwise
@@ -661,22 +662,10 @@ lemma mem_mem_ranges_iff_lt_sum (l : List ℕ) {n : ℕ} :
661662
(∃ s ∈ l.ranges, n ∈ s) ↔ n < l.sum := by
662663
rw [← mem_range, ← ranges_flatten, mem_flatten]
663664

664-
@[simp]
665-
theorem length_flatMap (l : List α) (f : α → List β) :
666-
length (List.flatMap l f) = sum (map (length ∘ f) l) := by
667-
rw [List.flatMap, length_flatten, map_map]
668-
669665
@[deprecated (since := "2024-10-16")] alias length_bind := length_flatMap
670666

671-
lemma countP_flatMap (p : β → Bool) (l : List α) (f : α → List β) :
672-
countP p (l.flatMap f) = sum (map (countP p ∘ f) l) := by
673-
rw [List.flatMap, countP_flatten, map_map]
674-
675667
@[deprecated (since := "2024-10-16")] alias countP_bind := countP_flatMap
676668

677-
lemma count_flatMap [BEq β] (l : List α) (f : α → List β) (x : β) :
678-
count x (l.flatMap f) = sum (map (count x ∘ f) l) := countP_flatMap _ _ _
679-
680669
@[deprecated (since := "2024-10-16")] alias count_bind := count_flatMap
681670

682671
/-- In a flatten, taking the first elements up to an index which is the sum of the lengths of the

Mathlib/Analysis/Analytic/Composition.lean

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,16 +1051,15 @@ theorem length_sigmaCompositionAux (a : Composition n) (b : Composition a.length
10511051
show List.length ((splitWrtComposition a.blocks b)[i.1]) = blocksFun b i by
10521052
rw [getElem_map_rev List.length, getElem_of_eq (map_length_splitWrtComposition _ _)]; rfl
10531053

1054-
set_option linter.deprecated false in
10551054
theorem blocksFun_sigmaCompositionAux (a : Composition n) (b : Composition a.length)
10561055
(i : Fin b.length) (j : Fin (blocksFun b i)) :
10571056
blocksFun (sigmaCompositionAux a b ⟨i, (length_gather a b).symm ▸ i.2⟩)
10581057
⟨j, (length_sigmaCompositionAux a b i).symm ▸ j.2⟩ =
1059-
blocksFun a (embedding b i j) :=
1060-
show get (get _ ⟨_, _⟩) ⟨_, _⟩ = a.blocks.get ⟨_, _⟩ by
1061-
rw [get_of_eq (get_splitWrtComposition _ _ _), get_drop', get_take']; rfl
1058+
blocksFun a (embedding b i j) := by
1059+
unfold sigmaCompositionAux
1060+
rw [blocksFun, get_eq_getElem, getElem_of_eq (getElem_splitWrtComposition _ _ _ _),
1061+
getElem_drop, getElem_take]; rfl
10621062

1063-
set_option linter.deprecated false in
10641063
/-- Auxiliary lemma to prove that the composition of formal multilinear series is associative.
10651064
10661065
Consider a composition `a` of `n` and a composition `b` of `a.length`. Grouping together some

Mathlib/Data/List/Basic.lean

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -831,17 +831,13 @@ theorem get_reverse (l : List α) (i : Nat) (h1 h2) :
831831
dsimp
832832
omega
833833

834-
set_option linter.deprecated false
835-
836834
theorem get_reverse' (l : List α) (n) (hn') :
837835
l.reverse.get n = l.get ⟨l.length - 1 - n, hn'⟩ := by
838-
rw [eq_comm]
839-
convert get_reverse l.reverse n (by simpa) n.2 using 1
840836
simp
841837

842838
theorem eq_cons_of_length_one {l : List α} (h : l.length = 1) : l = [l.get ⟨0, by omega⟩] := by
843839
refine ext_get (by convert h) fun n h₁ h₂ => ?_
844-
simp only [get_singleton]
840+
simp
845841
congr
846842
omega
847843

Mathlib/Data/List/Lemmas.lean

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,18 @@ variable {α β γ : Type*}
1717

1818
namespace List
1919

20+
@[simp]
21+
theorem length_flatMap (l : List α) (f : α → List β) :
22+
length (List.flatMap l f) = sum (map (length ∘ f) l) := by
23+
rw [List.flatMap, length_flatten, map_map]
24+
25+
lemma countP_flatMap (p : β → Bool) (l : List α) (f : α → List β) :
26+
countP p (l.flatMap f) = sum (map (countP p ∘ f) l) := by
27+
rw [List.flatMap, countP_flatten, map_map]
28+
29+
lemma count_flatMap [BEq β] (l : List α) (f : α → List β) (x : β) :
30+
count x (l.flatMap f) = sum (map (count x ∘ f) l) := countP_flatMap _ _ _
31+
2032
@[deprecated (since := "2024-08-20")] alias getElem_reverse' := getElem_reverse
2133

2234
theorem tail_reverse_eq_reverse_dropLast (l : List α) :

Mathlib/Data/List/Permutation.lean

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Copyright (c) 2014 Parikshit Khanna. All rights reserved.
33
Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Parikshit Khanna, Jeremy Avigad, Leonardo de Moura, Floris van Doorn, Mario Carneiro
55
-/
6-
import Mathlib.Data.List.Flatten
6+
import Mathlib.Data.List.Lemmas
77
import Mathlib.Data.Nat.Factorial.Basic
88
import Mathlib.Data.List.Count
99
import Mathlib.Data.List.Duplicate
@@ -181,20 +181,18 @@ theorem mem_foldr_permutationsAux2 {t : α} {ts : List α} {r L : List (List α)
181181
simp only [mem_permutationsAux2', ← this, or_comm, and_left_comm, mem_append, mem_flatMap,
182182
append_assoc, cons_append, exists_prop]
183183

184-
set_option linter.deprecated false in
185184
theorem length_foldr_permutationsAux2 (t : α) (ts : List α) (r L : List (List α)) :
186185
length (foldr (fun y r => (permutationsAux2 t ts r y id).2) r L) =
187-
Nat.sum (map length L) + length r := by
188-
simp [foldr_permutationsAux2, Function.comp_def, length_permutationsAux2, length_flatMap']
186+
(map length L).sum + length r := by
187+
simp [foldr_permutationsAux2, Function.comp_def, length_permutationsAux2, length_flatMap]
189188

190-
set_option linter.deprecated false in
191189
theorem length_foldr_permutationsAux2' (t : α) (ts : List α) (r L : List (List α)) (n)
192190
(H : ∀ l ∈ L, length l = n) :
193191
length (foldr (fun y r => (permutationsAux2 t ts r y id).2) r L) = n * length L + length r := by
194-
rw [length_foldr_permutationsAux2, (_ : Nat.sum (map length L) = n * length L)]
192+
rw [length_foldr_permutationsAux2, (_ : (map length L).sum = n * length L)]
195193
induction' L with l L ih
196194
· simp
197-
have sum_map : Nat.sum (map length L) = n * length L := ih fun l m => H l (mem_cons_of_mem _ m)
195+
have sum_map : (map length L).sum = n * length L := ih fun l m => H l (mem_cons_of_mem _ m)
198196
have length_l : length l = n := H _ (mem_cons_self _ _)
199197
simp [sum_map, length_l, Nat.mul_add, Nat.add_comm, mul_succ]
200198

Mathlib/LinearAlgebra/CliffordAlgebra/Grading.lean

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,7 @@ theorem GradedAlgebra.lift_ι_eq (i' : ZMod 2) (x' : evenOdd Q i') :
9999
· rw [Nat.succ_eq_add_one, add_comm, Nat.cast_add, Nat.cast_one]
100100
rfl
101101
| zero =>
102-
set_option linter.deprecated false in
103-
rw [AlgHom.map_zero]
102+
rw [map_zero]
104103
apply Eq.symm
105104
apply DFinsupp.single_eq_zero.mpr; rfl
106105
| add x y hx hy ihx ihy =>

Mathlib/LinearAlgebra/Prod.lean

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -830,20 +830,21 @@ variable {N : Type*} [AddCommGroup M] [Module R M] [AddCommGroup N] [Module R N]
830830

831831
open Function
832832

833-
set_option linter.deprecated false
834-
833+
set_option linter.deprecated false in
835834
/-- An auxiliary construction for `tunnel`.
836835
The composition of `f`, followed by the isomorphism back to `K`,
837836
followed by the inclusion of this submodule back into `M`. -/
838837
@[deprecated "No deprecation message was provided." (since := "2024-06-05")]
839838
def tunnelAux (f : M × N →ₗ[R] M) (Kφ : ΣK : Submodule R M, K ≃ₗ[R] M) : M × N →ₗ[R] M :=
840839
(Kφ.1.subtype.comp Kφ.2.symm.toLinearMap).comp f
841840

841+
set_option linter.deprecated false in
842842
@[deprecated "No deprecation message was provided." (since := "2024-06-05")]
843843
theorem tunnelAux_injective (f : M × N →ₗ[R] M) (i : Injective f)
844844
(Kφ : ΣK : Submodule R M, K ≃ₗ[R] M) : Injective (tunnelAux f Kφ) :=
845845
(Subtype.val_injective.comp Kφ.2.symm.injective).comp i
846846

847+
set_option linter.deprecated false in
847848
/-- Auxiliary definition for `tunnel`. -/
848849
@[deprecated "No deprecation message was provided." (since := "2024-06-05")]
849850
def tunnel' (f : M × N →ₗ[R] M) (i : Injective f) : ℕ → ΣK : Submodule R M, K ≃ₗ[R] M
@@ -853,6 +854,7 @@ def tunnel' (f : M × N →ₗ[R] M) (i : Injective f) : ℕ → ΣK : Submodule
853854
((Submodule.fst R M N).equivMapOfInjective _
854855
(tunnelAux_injective f i (tunnel' f i n))).symm.trans (Submodule.fstEquiv R M N)⟩
855856

857+
set_option linter.deprecated false in
856858
/-- Give an injective map `f : M × N →ₗ[R] M` we can find a nested sequence of submodules
857859
all isomorphic to `M`.
858860
-/
@@ -865,26 +867,30 @@ def tunnel (f : M × N →ₗ[R] M) (i : Injective f) : ℕ →o (Submodule R M)
865867
rw [Submodule.map_comp, Submodule.map_comp]
866868
apply Submodule.map_subtype_le⟩
867869

870+
set_option linter.deprecated false in
868871
/-- Give an injective map `f : M × N →ₗ[R] M` we can find a sequence of submodules
869872
all isomorphic to `N`.
870873
-/
871874
@[deprecated "No deprecation message was provided." (since := "2024-06-05")]
872875
def tailing (f : M × N →ₗ[R] M) (i : Injective f) (n : ℕ) : Submodule R M :=
873876
(Submodule.snd R M N).map (tunnelAux f (tunnel' f i n))
874877

878+
set_option linter.deprecated false in
875879
/-- Each `tailing f i n` is a copy of `N`. -/
876880
@[deprecated "No deprecation message was provided." (since := "2024-06-05")]
877881
def tailingLinearEquiv (f : M × N →ₗ[R] M) (i : Injective f) (n : ℕ) : tailing f i n ≃ₗ[R] N :=
878882
((Submodule.snd R M N).equivMapOfInjective _ (tunnelAux_injective f i (tunnel' f i n))).symm.trans
879883
(Submodule.sndEquiv R M N)
880884

885+
set_option linter.deprecated false in
881886
@[deprecated "No deprecation message was provided." (since := "2024-06-05")]
882887
theorem tailing_le_tunnel (f : M × N →ₗ[R] M) (i : Injective f) (n : ℕ) :
883888
tailing f i n ≤ OrderDual.ofDual (α := Submodule R M) (tunnel f i n) := by
884889
dsimp [tailing, tunnelAux]
885890
rw [Submodule.map_comp, Submodule.map_comp]
886891
apply Submodule.map_subtype_le
887892

893+
set_option linter.deprecated false in
888894
@[deprecated "No deprecation message was provided." (since := "2024-06-05")]
889895
theorem tailing_disjoint_tunnel_succ (f : M × N →ₗ[R] M) (i : Injective f) (n : ℕ) :
890896
Disjoint (tailing f i n) (OrderDual.ofDual (α := Submodule R M) <| tunnel f i (n + 1)) := by
@@ -894,6 +900,7 @@ theorem tailing_disjoint_tunnel_succ (f : M × N →ₗ[R] M) (i : Injective f)
894900
Submodule.comap_map_eq_of_injective (tunnelAux_injective _ i _), inf_comm,
895901
Submodule.fst_inf_snd, Submodule.map_bot]
896902

903+
set_option linter.deprecated false in
897904
@[deprecated "No deprecation message was provided." (since := "2024-06-05")]
898905
theorem tailing_sup_tunnel_succ_le_tunnel (f : M × N →ₗ[R] M) (i : Injective f) (n : ℕ) :
899906
tailing f i n ⊔ (OrderDual.ofDual (α := Submodule R M) <| tunnel f i (n + 1)) ≤
@@ -902,19 +909,23 @@ theorem tailing_sup_tunnel_succ_le_tunnel (f : M × N →ₗ[R] M) (i : Injectiv
902909
rw [← Submodule.map_sup, sup_comm, Submodule.fst_sup_snd, Submodule.map_comp, Submodule.map_comp]
903910
apply Submodule.map_subtype_le
904911

912+
set_option linter.deprecated false in
905913
/-- The supremum of all the copies of `N` found inside the tunnel. -/
906914
@[deprecated "No deprecation message was provided." (since := "2024-06-05")]
907915
def tailings (f : M × N →ₗ[R] M) (i : Injective f) : ℕ → Submodule R M :=
908916
partialSups (tailing f i)
909917

918+
set_option linter.deprecated false in
910919
@[simp, deprecated "No deprecation message was provided." (since := "2024-06-05")]
911920
theorem tailings_zero (f : M × N →ₗ[R] M) (i : Injective f) : tailings f i 0 = tailing f i 0 := by
912921
simp [tailings]
913922

923+
set_option linter.deprecated false in
914924
@[simp, deprecated "No deprecation message was provided." (since := "2024-06-05")]
915925
theorem tailings_succ (f : M × N →ₗ[R] M) (i : Injective f) (n : ℕ) :
916926
tailings f i (n + 1) = tailings f i n ⊔ tailing f i (n + 1) := by simp [tailings]
917927

928+
set_option linter.deprecated false in
918929
@[deprecated "No deprecation message was provided." (since := "2024-06-05")]
919930
theorem tailings_disjoint_tunnel (f : M × N →ₗ[R] M) (i : Injective f) (n : ℕ) :
920931
Disjoint (tailings f i n) (OrderDual.ofDual (α := Submodule R M) <| tunnel f i (n + 1)) := by
@@ -927,6 +938,7 @@ theorem tailings_disjoint_tunnel (f : M × N →ₗ[R] M) (i : Injective f) (n :
927938
· apply Disjoint.mono_right _ ih
928939
apply tailing_sup_tunnel_succ_le_tunnel
929940

941+
set_option linter.deprecated false in
930942
@[deprecated "No deprecation message was provided." (since := "2024-06-05")]
931943
theorem tailings_disjoint_tailing (f : M × N →ₗ[R] M) (i : Injective f) (n : ℕ) :
932944
Disjoint (tailings f i n) (tailing f i (n + 1)) :=

Mathlib/Order/Extension/Well.lean

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,9 @@ end IsWellFounded
7070

7171
namespace WellFounded
7272

73-
set_option linter.deprecated false
74-
7573
variable (hwf : WellFounded r)
7674

75+
set_option linter.deprecated false in
7776
/-- An arbitrary well order on `α` that extends `r`.
7877
7978
The construction maps `r` into two well-orders: the first map is `WellFounded.rank`, which is not
@@ -89,12 +88,14 @@ noncomputable def wellOrderExtension : LinearOrder α :=
8988
@LinearOrder.lift' α (Ordinal ×ₗ Cardinal) _ (fun a : α => (hwf.rank a, embeddingToCardinal a))
9089
fun _ _ h => embeddingToCardinal.injective <| congr_arg Prod.snd h
9190

91+
set_option linter.deprecated false in
9292
@[deprecated IsWellFounded.wellOrderExtension.isWellFounded_lt (since := "2024-09-07")]
9393
instance wellOrderExtension.isWellFounded_lt : IsWellFounded α hwf.wellOrderExtension.lt :=
9494
⟨InvImage.wf (fun a : α => (hwf.rank a, embeddingToCardinal a)) <|
9595
Ordinal.lt_wf.prod_lex Cardinal.lt_wf⟩
9696

9797
include hwf in
98+
set_option linter.deprecated false in
9899
/-- Any well-founded relation can be extended to a well-ordering on that type. -/
99100
@[deprecated IsWellFounded.exists_well_order_ge (since := "2024-09-07")]
100101
theorem exists_well_order_ge : ∃ s, r ≤ s ∧ IsWellOrder α s :=

0 commit comments

Comments
 (0)