Skip to content

Commit 36f0ed3

Browse files
committed
chore: remove CoeFun instances where FunLike is available
During the port we found that `FunLike` is robust enough not to need an extra `CoeFun` shortcut. Let's see if that rule can be consistently applied to the whole of the library. There is still duplication between `FunLike` and `CoeFun` for `Grp`, `Mon`, `CommGrp` and `CommMon`, which will need a more thorough fix. See also #17866.
1 parent 36759bf commit 36f0ed3

23 files changed

Lines changed: 2 additions & 112 deletions

File tree

Mathlib/Algebra/MonoidAlgebra/Defs.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ instance MonoidAlgebra.instIsCancelAdd [IsCancelAdd k] : IsCancelAdd (MonoidAlge
8686
inferInstanceAs (IsCancelAdd (G →₀ k))
8787

8888
instance MonoidAlgebra.coeFun : CoeFun (MonoidAlgebra k G) fun _ => G → k :=
89-
Finsupp.instCoeFun
89+
inferInstanceAs (CoeFun (G →₀ k) _)
9090

9191
end
9292

@@ -823,7 +823,7 @@ instance instIsCancelAdd [IsCancelAdd k] : IsCancelAdd (AddMonoidAlgebra k G) :=
823823
inferInstanceAs (IsCancelAdd (G →₀ k))
824824

825825
instance coeFun : CoeFun k[G] fun _ => G → k :=
826-
Finsupp.instCoeFun
826+
inferInstanceAs (CoeFun (G →₀ k) _)
827827

828828
end AddMonoidAlgebra
829829

Mathlib/Algebra/Order/AbsoluteValue.lean

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,6 @@ def Simps.apply (f : AbsoluteValue R S) : R → S :=
7777

7878
initialize_simps_projections AbsoluteValue (toMulHom_toFun → apply)
7979

80-
/-- Helper instance for when there's too many metavariables to apply `DFunLike.has_coe_to_fun`
81-
directly. -/
82-
instance : CoeFun (AbsoluteValue R S) fun _ => R → S :=
83-
DFunLike.hasCoeToFun
84-
8580
@[simp]
8681
theorem coe_toMulHom : ⇑abv.toMulHom = abv :=
8782
rfl

Mathlib/Algebra/Polynomial/Module/Basic.lean

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,6 @@ noncomputable instance : Module S (PolynomialModule R M) :=
5656
instance instFunLike : FunLike (PolynomialModule R M) ℕ M :=
5757
Finsupp.instFunLike
5858

59-
instance : CoeFun (PolynomialModule R M) fun _ => ℕ → M :=
60-
Finsupp.instCoeFun
61-
6259
theorem zero_apply (i : ℕ) : (0 : PolynomialModule R M) i = 0 :=
6360
Finsupp.zero_apply
6461

Mathlib/Algebra/Ring/CentroidHom.lean

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,6 @@ instance : CentroidHomClass (CentroidHom α) α where
102102
map_mul_right f := f.map_mul_right'
103103

104104

105-
/-- Helper instance for when there's too many metavariables to apply `DFunLike.CoeFun`
106-
directly. -/
107-
/- Porting note: Lean gave me `unknown constant 'DFunLike.CoeFun'` and says `CoeFun` is a type
108-
mismatch, so I used `library_search`. -/
109-
instance : CoeFun (CentroidHom α) fun _ ↦ α → α :=
110-
inferInstanceAs (CoeFun (CentroidHom α) fun _ ↦ α → α)
111-
112105
-- Porting note: removed @[simp]; not in normal form. (`toAddMonoidHom_eq_coe` below ensures that
113106
-- the LHS simplifies to the RHS anyway.)
114107
theorem toFun_eq_coe {f : CentroidHom α} : f.toFun = f := rfl

Mathlib/Analysis/Distribution/SchwartzSpace.lean

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,6 @@ instance instFunLike : FunLike 𝓢(E, F) E F where
9090
coe f := f.toFun
9191
coe_injective' f g h := by cases f; cases g; congr
9292

93-
/-- Helper instance for when there's too many metavariables to apply `DFunLike.hasCoeToFun`. -/
94-
instance instCoeFun : CoeFun 𝓢(E, F) fun _ => E → F :=
95-
DFunLike.hasCoeToFun
96-
9793
/-- All derivatives of a Schwartz function are rapidly decaying. -/
9894
theorem decay (f : 𝓢(E, F)) (k n : ℕ) :
9995
∃ C : ℝ, 0 < C ∧ ∀ x, ‖x‖ ^ k * ‖iteratedFDeriv ℝ n f x‖ ≤ C := by

Mathlib/Analysis/Normed/Algebra/Norm.lean

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,6 @@ instance algebraNormClass : AlgebraNormClass (AlgebraNorm R S) R S where
7070
eq_zero_of_map_eq_zero f := f.eq_zero_of_map_eq_zero' _
7171
map_smul_eq_mul f := f.smul'
7272

73-
/-- Helper instance for when there's too many metavariables to apply `fun_like.has_coe_to_fun`. -/
74-
instance : CoeFun (AlgebraNorm R S) fun _ => S → ℝ :=
75-
DFunLike.hasCoeToFun
76-
7773
theorem toFun_eq_coe (p : AlgebraNorm R S) : p.toFun = p := rfl
7874

7975
@[ext]
@@ -160,10 +156,6 @@ instance mulAlgebraNormClass : MulAlgebraNormClass (MulAlgebraNorm R S) R S wher
160156
eq_zero_of_map_eq_zero f := f.eq_zero_of_map_eq_zero' _
161157
map_smul_eq_mul f := f.smul'
162158

163-
/-- Helper instance for when there's too many metavariables to apply `fun_like.has_coe_to_fun`. -/
164-
instance : CoeFun (MulAlgebraNorm R S) fun _ => S → ℝ :=
165-
DFunLike.hasCoeToFun
166-
167159
theorem toFun_eq_coe (p : MulAlgebraNorm R S) : p.toFun = p := rfl
168160

169161
@[ext]

Mathlib/Analysis/Normed/Group/Seminorm.lean

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -181,12 +181,6 @@ instance groupSeminormClass : GroupSeminormClass (GroupSeminorm E) E ℝ where
181181
map_mul_le_add f := f.mul_le'
182182
map_inv_eq_map f := f.inv'
183183

184-
/-- Helper instance for when there's too many metavariables to apply `DFunLike.hasCoeToFun`. -/
185-
@[to_additive "Helper instance for when there's too many metavariables to apply
186-
`DFunLike.hasCoeToFun`. "]
187-
instance : CoeFun (GroupSeminorm E) fun _ => E → ℝ :=
188-
⟨DFunLike.coe⟩
189-
190184
@[to_additive (attr := simp)]
191185
theorem toFun_eq_coe : p.toFun = p :=
192186
rfl
@@ -447,10 +441,6 @@ instance nonarchAddGroupSeminormClass :
447441
map_zero f := f.map_zero'
448442
map_neg_eq_map' f := f.neg'
449443

450-
/-- Helper instance for when there's too many metavariables to apply `DFunLike.hasCoeToFun`. -/
451-
instance : CoeFun (NonarchAddGroupSeminorm E) fun _ => E → ℝ :=
452-
⟨DFunLike.coe⟩
453-
454444
-- Porting note: `simpNF` said the left hand side simplified to this
455445
@[simp]
456446
theorem toZeroHom_eq_coe : ⇑p.toZeroHom = p := by
@@ -667,13 +657,6 @@ instance groupNormClass : GroupNormClass (GroupNorm E) E ℝ where
667657
map_inv_eq_map f := f.inv'
668658
eq_one_of_map_eq_zero f := f.eq_one_of_map_eq_zero' _
669659

670-
/-- Helper instance for when there's too many metavariables to apply `DFunLike.hasCoeToFun`
671-
directly. -/
672-
@[to_additive "Helper instance for when there's too many metavariables to apply
673-
`DFunLike.hasCoeToFun` directly. "]
674-
instance : CoeFun (GroupNorm E) fun _ => E → ℝ :=
675-
DFunLike.hasCoeToFun
676-
677660
-- Porting note: `simpNF` told me the left-hand side simplified to this
678661
@[to_additive (attr := simp)]
679662
theorem toGroupSeminorm_eq_coe : ⇑p.toGroupSeminorm = p :=
@@ -799,10 +782,6 @@ instance nonarchAddGroupNormClass : NonarchAddGroupNormClass (NonarchAddGroupNor
799782
map_neg_eq_map' f := f.neg'
800783
eq_zero_of_map_eq_zero f := f.eq_zero_of_map_eq_zero' _
801784

802-
/-- Helper instance for when there's too many metavariables to apply `DFunLike.hasCoeToFun`. -/
803-
noncomputable instance : CoeFun (NonarchAddGroupNorm E) fun _ => E → ℝ :=
804-
DFunLike.hasCoeToFun
805-
806785
-- Porting note: `simpNF` told me the left-hand side simplified to this
807786
@[simp]
808787
theorem toNonarchAddGroupSeminorm_eq_coe : ⇑p.toNonarchAddGroupSeminorm = p :=

Mathlib/Analysis/Normed/Operator/LinearIsometry.lean

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -486,11 +486,6 @@ instance instSemilinearIsometryEquivClass :
486486
map_smulₛₗ e := map_smulₛₗ e.toLinearEquiv
487487
norm_map e := e.norm_map'
488488

489-
-- TODO: Shouldn't these `CoeFun` instances be scrapped?
490-
/-- Helper instance for when there's too many metavariables to apply `DFunLike.hasCoeToFun`
491-
directly. -/
492-
instance instCoeFun : CoeFun (E ≃ₛₗᵢ[σ₁₂] E₂) fun _ ↦ E → E₂ := ⟨DFunLike.coe⟩
493-
494489
theorem coe_injective : @Function.Injective (E ≃ₛₗᵢ[σ₁₂] E₂) (E → E₂) (↑) :=
495490
DFunLike.coe_injective
496491

Mathlib/Combinatorics/Young/SemistandardTableau.lean

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,6 @@ instance instFunLike {μ : YoungDiagram} : FunLike (SemistandardYoungTableau μ)
6868
cases T'
6969
congr
7070

71-
/-- Helper instance for when there's too many metavariables to apply `CoeFun.coe` directly. -/
72-
instance {μ : YoungDiagram} : CoeFun (SemistandardYoungTableau μ) fun _ ↦ ℕ → ℕ → ℕ :=
73-
inferInstance
74-
7571
@[simp]
7672
theorem to_fun_eq_coe {μ : YoungDiagram} {T : SemistandardYoungTableau μ} :
7773
T.entry = (T : ℕ → ℕ → ℕ) :=

Mathlib/Data/DFinsupp/Basic.lean

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,6 @@ instance instDFunLike : DFunLike (Π₀ i, β i) ι β :=
8181
congr
8282
subsingleton ⟩
8383

84-
/-- Helper instance for when there are too many metavariables to apply `DFunLike.coeFunForall`
85-
directly. -/
86-
instance : CoeFun (Π₀ i, β i) fun _ => ∀ i, β i :=
87-
inferInstance
88-
8984
@[simp]
9085
theorem toFun_eq_coe (f : Π₀ i, β i) : f.toFun = f :=
9186
rfl

0 commit comments

Comments
 (0)