Skip to content

Commit 54792e9

Browse files
committed
refactor(*): abbreviation for non-dependent FunLike (#9833)
This follows up from #9785, which renamed `FunLike` to `DFunLike`, by introducing a new abbreviation `FunLike F α β := DFunLike F α (fun _ => β)`, to make the non-dependent use of `FunLike` easier. I searched for the pattern `DFunLike.*fun` and `DFunLike.*λ` in all files to replace expressions of the form `DFunLike F α (fun _ => β)` with `FunLike F α β`. I did this everywhere except for `extends` clauses for two reasons: it would conflict with #8386, and more importantly `extends` must directly refer to a structure with no unfolding of `def`s or `abbrev`s.
1 parent 58edd50 commit 54792e9

File tree

81 files changed

+182
-172
lines changed

Some content is hidden

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

81 files changed

+182
-172
lines changed

Archive/Hairer.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ namespace SmoothSupportedOn
4646

4747
variable {n : ℕ∞} {s : Set E}
4848

49-
instance : DFunLike (SmoothSupportedOn 𝕜 E F n s) E (fun _ ↦ F) where
49+
instance : FunLike (SmoothSupportedOn 𝕜 E F n s) E F where
5050
coe := Subtype.val
5151
coe_injective' := Subtype.coe_injective
5252

Mathlib/Algebra/Algebra/NonUnitalHom.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ variable [NonUnitalNonAssocSemiring C] [DistribMulAction R C]
124124
-- instance : CoeFun (A →ₙₐ[R] B) fun _ => A → B :=
125125
-- ⟨toFun⟩
126126

127-
instance : DFunLike (A →ₙₐ[R] B) A fun _ => B where
127+
instance : FunLike (A →ₙₐ[R] B) A B where
128128
coe f := f.toFun
129129
coe_injective' := by rintro ⟨⟨⟨f, _⟩, _⟩, _⟩ ⟨⟨⟨g, _⟩, _⟩, _⟩ h; congr
130130

Mathlib/Algebra/Category/GroupCat/Basic.lean

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ instance {X Y : GroupCat} : CoeFun (X ⟶ Y) fun _ => X → Y where
6666
coe (f : X →* Y) := f
6767

6868
@[to_additive]
69-
instance DFunLike_instance (X Y : GroupCat) : DFunLike (X ⟶ Y) X (fun _ => Y) :=
70-
show DFunLike (X →* Y) X (fun _ => Y) from inferInstance
69+
instance FunLike_instance (X Y : GroupCat) : FunLike (X ⟶ Y) X Y :=
70+
show FunLike (X →* Y) X Y from inferInstance
7171

7272
-- porting note: added
7373
@[to_additive (attr := simp)]
@@ -215,8 +215,8 @@ instance {X Y : CommGroupCat} : CoeFun (X ⟶ Y) fun _ => X → Y where
215215
coe (f : X →* Y) := f
216216

217217
@[to_additive]
218-
instance DFunLike_instance (X Y : CommGroupCat) : DFunLike (X ⟶ Y) X (fun _ => Y) :=
219-
show DFunLike (X →* Y) X (fun _ => Y) from inferInstance
218+
instance FunLike_instance (X Y : CommGroupCat) : FunLike (X ⟶ Y) X Y :=
219+
show FunLike (X →* Y) X Y from inferInstance
220220

221221
-- porting note: added
222222
@[to_additive (attr := simp)]

Mathlib/Algebra/Category/GroupWithZeroCat.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ instance : LargeCategory.{u} GroupWithZeroCat where
5353
assoc _ _ _ := MonoidWithZeroHom.comp_assoc _ _ _
5454

5555
-- porting note: was not necessary in mathlib
56-
instance {M N : GroupWithZeroCat} : DFunLike (M ⟶ N) M (fun _ => N) :=
56+
instance {M N : GroupWithZeroCat} : FunLike (M ⟶ N) M N :=
5757
fun f => f.toFun, fun f g h => by
5858
cases f
5959
cases g

Mathlib/Algebra/Category/ModuleCat/Monoidal/Closed.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ open MonoidalCategory
6767
-- porting note: `CoeFun` was replaced by `DFunLike`
6868
-- I can't seem to express the function coercion here without writing `@DFunLike.coe`.
6969
theorem monoidalClosed_curry {M N P : ModuleCat.{u} R} (f : M ⊗ N ⟶ P) (x : M) (y : N) :
70-
@DFunLike.coe _ _ _ LinearMap.instDFunLike
70+
@DFunLike.coe _ _ _ LinearMap.instFunLike
7171
((MonoidalClosed.curry f : N →ₗ[R] M →ₗ[R] P) y) x = f (x ⊗ₜ[R] y) :=
7272
rfl
7373
set_option linter.uppercaseLean3 false in
@@ -77,7 +77,7 @@ set_option linter.uppercaseLean3 false in
7777
theorem monoidalClosed_uncurry
7878
{M N P : ModuleCat.{u} R} (f : N ⟶ M ⟶[ModuleCat.{u} R] P) (x : M) (y : N) :
7979
MonoidalClosed.uncurry f (x ⊗ₜ[R] y) =
80-
@DFunLike.coe _ _ _ LinearMap.instDFunLike (f y) x :=
80+
@DFunLike.coe _ _ _ LinearMap.instFunLike (f y) x :=
8181
rfl
8282
set_option linter.uppercaseLean3 false in
8383
#align Module.monoidal_closed_uncurry ModuleCat.monoidalClosed_uncurry

Mathlib/Algebra/Category/MonCat/Basic.lean

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ instance {X Y : MonCat} : CoeFun (X ⟶ Y) fun _ => X → Y where
8686
coe (f : X →* Y) := f
8787

8888
@[to_additive]
89-
instance Hom_DFunLike (X Y : MonCat) : DFunLike (X ⟶ Y) X (fun _ => Y) :=
90-
show DFunLike (X →* Y) X (fun _ => Y) by infer_instance
89+
instance Hom_FunLike (X Y : MonCat) : FunLike (X ⟶ Y) X Y :=
90+
show FunLike (X →* Y) X Y by infer_instance
9191

9292
-- porting note: added
9393
@[to_additive (attr := simp)]
@@ -208,8 +208,8 @@ instance {X Y : CommMonCat} : CoeFun (X ⟶ Y) fun _ => X → Y where
208208
coe (f : X →* Y) := f
209209

210210
@[to_additive]
211-
instance Hom_DFunLike (X Y : CommMonCat) : DFunLike (X ⟶ Y) X (fun _ => Y) :=
212-
show DFunLike (X →* Y) X (fun _ => Y) by infer_instance
211+
instance Hom_FunLike (X Y : CommMonCat) : FunLike (X ⟶ Y) X Y :=
212+
show FunLike (X →* Y) X Y by infer_instance
213213

214214
-- porting note: added
215215
@[to_additive (attr := simp)]

Mathlib/Algebra/Category/MonCat/FilteredColimits.lean

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ def colimitCoconeIsColimit : IsColimit (colimitCocone.{v, u} F) where
330330
uniq t m h := MonoidHom.ext fun y => congr_fun
331331
((Types.colimitCoconeIsColimit (F ⋙ forget MonCat)).uniq ((forget MonCat).mapCocone t)
332332
((forget MonCat).map m)
333-
fun j => funext fun x => DFunLike.congr_fun (i := MonCat.Hom_DFunLike _ _) (h j) x) y
333+
fun j => funext fun x => DFunLike.congr_fun (i := MonCat.Hom_FunLike _ _) (h j) x) y
334334
#align Mon.filtered_colimits.colimit_cocone_is_colimit MonCat.FilteredColimits.colimitCoconeIsColimit
335335
#align AddMon.filtered_colimits.colimit_cocone_is_colimit AddMonCat.FilteredColimits.colimitCoconeIsColimit
336336

@@ -405,15 +405,15 @@ def colimitCoconeIsColimit : IsColimit (colimitCocone.{v, u} F) where
405405
MonCat.FilteredColimits.colimitDesc.{v, u} (F ⋙ forget₂ CommMonCat MonCat.{max v u})
406406
((forget₂ CommMonCat MonCat.{max v u}).mapCocone t)
407407
fac t j :=
408-
DFunLike.coe_injective (i := CommMonCat.Hom_DFunLike _ _) <|
408+
DFunLike.coe_injective (i := CommMonCat.Hom_FunLike _ _) <|
409409
(Types.colimitCoconeIsColimit.{v, u} (F ⋙ forget CommMonCat.{max v u})).fac
410410
((forget CommMonCat).mapCocone t) j
411411
uniq t m h :=
412-
DFunLike.coe_injective (i := CommMonCat.Hom_DFunLike _ _) <|
412+
DFunLike.coe_injective (i := CommMonCat.Hom_FunLike _ _) <|
413413
(Types.colimitCoconeIsColimit.{v, u} (F ⋙ forget CommMonCat.{max v u})).uniq
414414
((forget CommMonCat.{max v u}).mapCocone t)
415415
((forget CommMonCat.{max v u}).map m) fun j => funext fun x =>
416-
DFunLike.congr_fun (i := CommMonCat.Hom_DFunLike _ _) (h j) x
416+
DFunLike.congr_fun (i := CommMonCat.Hom_FunLike _ _) (h j) x
417417
#align CommMon.filtered_colimits.colimit_cocone_is_colimit CommMonCat.FilteredColimits.colimitCoconeIsColimit
418418
#align AddCommMon.filtered_colimits.colimit_cocone_is_colimit AddCommMonCat.FilteredColimits.colimitCoconeIsColimit
419419

Mathlib/Algebra/Category/Ring/Basic.lean

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ set_option linter.uppercaseLean3 false in
107107
@[simp]
108108
lemma RingEquiv_coe_eq {X Y : Type _} [Semiring X] [Semiring Y] (e : X ≃+* Y) :
109109
(@DFunLike.coe (SemiRingCat.of X ⟶ SemiRingCat.of Y) _ (fun _ => (forget SemiRingCat).obj _)
110-
ConcreteCategory.instDFunLike (e : X →+* Y) : X → Y) = ↑e :=
110+
ConcreteCategory.instFunLike (e : X →+* Y) : X → Y) = ↑e :=
111111
rfl
112112

113113
instance : Inhabited SemiRingCat :=
@@ -246,7 +246,7 @@ set_option linter.uppercaseLean3 false in
246246
@[simp]
247247
lemma RingEquiv_coe_eq {X Y : Type _} [Ring X] [Ring Y] (e : X ≃+* Y) :
248248
(@DFunLike.coe (RingCat.of X ⟶ RingCat.of Y) _ (fun _ => (forget RingCat).obj _)
249-
ConcreteCategory.instDFunLike (e : X →+* Y) : X → Y) = ↑e :=
249+
ConcreteCategory.instFunLike (e : X →+* Y) : X → Y) = ↑e :=
250250
rfl
251251

252252
instance hasForgetToSemiRingCat : HasForget₂ RingCat SemiRingCat :=
@@ -330,7 +330,7 @@ set_option linter.uppercaseLean3 false in
330330
lemma RingEquiv_coe_eq {X Y : Type _} [CommSemiring X] [CommSemiring Y] (e : X ≃+* Y) :
331331
(@DFunLike.coe (CommSemiRingCat.of X ⟶ CommSemiRingCat.of Y) _
332332
(fun _ => (forget CommSemiRingCat).obj _)
333-
ConcreteCategory.instDFunLike (e : X →+* Y) : X → Y) = ↑e :=
333+
ConcreteCategory.instFunLike (e : X →+* Y) : X → Y) = ↑e :=
334334
rfl
335335

336336
-- Porting note: I think this is now redundant.
@@ -445,7 +445,7 @@ set_option linter.uppercaseLean3 false in
445445
@[simp]
446446
lemma RingEquiv_coe_eq {X Y : Type _} [CommRing X] [CommRing Y] (e : X ≃+* Y) :
447447
(@DFunLike.coe (CommRingCat.of X ⟶ CommRingCat.of Y) _ (fun _ => (forget CommRingCat).obj _)
448-
ConcreteCategory.instDFunLike (e : X →+* Y) : X → Y) = ↑e :=
448+
ConcreteCategory.instFunLike (e : X →+* Y) : X → Y) = ↑e :=
449449
rfl
450450

451451
-- Porting note: I think this is now redundant.

Mathlib/Algebra/Category/SemigroupCat/Basic.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ theorem coe_of (R : Type u) [Mul R] : (MagmaCat.of R : Type u) = R :=
9999
@[to_additive (attr := simp)]
100100
lemma mulEquiv_coe_eq {X Y : Type _} [Mul X] [Mul Y] (e : X ≃* Y) :
101101
(@DFunLike.coe (MagmaCat.of X ⟶ MagmaCat.of Y) _ (fun _ => (forget MagmaCat).obj _)
102-
ConcreteCategory.instDFunLike (e : X →ₙ* Y) : X → Y) = ↑e :=
102+
ConcreteCategory.instFunLike (e : X →ₙ* Y) : X → Y) = ↑e :=
103103
rfl
104104

105105
/-- Typecheck a `MulHom` as a morphism in `MagmaCat`. -/
@@ -184,7 +184,7 @@ theorem coe_of (R : Type u) [Semigroup R] : (SemigroupCat.of R : Type u) = R :=
184184
@[to_additive (attr := simp)]
185185
lemma mulEquiv_coe_eq {X Y : Type _} [Semigroup X] [Semigroup Y] (e : X ≃* Y) :
186186
(@DFunLike.coe (SemigroupCat.of X ⟶ SemigroupCat.of Y) _ (fun _ => (forget SemigroupCat).obj _)
187-
ConcreteCategory.instDFunLike (e : X →ₙ* Y) : X → Y) = ↑e :=
187+
ConcreteCategory.instFunLike (e : X →ₙ* Y) : X → Y) = ↑e :=
188188
rfl
189189

190190
/-- Typecheck a `MulHom` as a morphism in `SemigroupCat`. -/

Mathlib/Algebra/Group/Freiman.lean

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ notation:25 (name := «FreimanHomLocal≺») A " →*[" n:25 "] " β:0 => Freima
8888
/-- `AddFreimanHomClass F A β n` states that `F` is a type of `n`-ary sums-preserving morphisms.
8989
You should extend this class when you extend `AddFreimanHom`. -/
9090
class AddFreimanHomClass (F : Type*) (A : outParam <| Set α) (β : outParam <| Type*)
91-
[AddCommMonoid α] [AddCommMonoid β] (n : ℕ) [DFunLike F α fun _ => β] : Prop where
91+
[AddCommMonoid α] [AddCommMonoid β] (n : ℕ) [FunLike F α β] : Prop where
9292
/-- An additive `n`-Freiman homomorphism preserves sums of `n` elements. -/
9393
map_sum_eq_map_sum' (f : F) {s t : Multiset α} (hsA : ∀ ⦃x⦄, x ∈ s → x ∈ A)
9494
(htA : ∀ ⦃x⦄, x ∈ t → x ∈ A) (hs : Multiset.card s = n) (ht : Multiset.card t = n)
@@ -102,15 +102,15 @@ You should extend this class when you extend `FreimanHom`. -/
102102
"`AddFreimanHomClass F A β n` states that `F` is a type of `n`-ary
103103
sums-preserving morphisms. You should extend this class when you extend `AddFreimanHom`."]
104104
class FreimanHomClass (F : Type*) (A : outParam <| Set α) (β : outParam <| Type*) [CommMonoid α]
105-
[CommMonoid β] (n : ℕ) [DFunLike F α fun _ => β] : Prop where
105+
[CommMonoid β] (n : ℕ) [FunLike F α β] : Prop where
106106
/-- An `n`-Freiman homomorphism preserves products of `n` elements. -/
107107
map_prod_eq_map_prod' (f : F) {s t : Multiset α} (hsA : ∀ ⦃x⦄, x ∈ s → x ∈ A)
108108
(htA : ∀ ⦃x⦄, x ∈ t → x ∈ A) (hs : Multiset.card s = n) (ht : Multiset.card t = n)
109109
(h : s.prod = t.prod) :
110110
(s.map f).prod = (t.map f).prod
111111
#align freiman_hom_class FreimanHomClass
112112

113-
variable [DFunLike F α fun _ => β]
113+
variable [FunLike F α β]
114114

115115
section CommMonoid
116116

@@ -154,11 +154,11 @@ theorem map_mul_map_eq_map_mul_map [FreimanHomClass F A β 2] (f : F) (ha : a
154154
namespace FreimanHom
155155

156156
@[to_additive]
157-
instance instDFunLike : DFunLike (A →*[n] β) α fun _ => β where
157+
instance instFunLike : FunLike (A →*[n] β) α β where
158158
coe := toFun
159159
coe_injective' f g h := by cases f; cases g; congr
160-
#align freiman_hom.fun_like FreimanHom.instDFunLike
161-
#align add_freiman_hom.fun_like AddFreimanHom.instDFunLike
160+
#align freiman_hom.fun_like FreimanHom.instFunLike
161+
#align add_freiman_hom.fun_like AddFreimanHom.instFunLike
162162

163163
@[to_additive addFreimanHomClass]
164164
instance freimanHomClass : FreimanHomClass (A →*[n] β) A β n where

0 commit comments

Comments
 (0)