Skip to content

Commit c3cf7cb

Browse files
committed
feat(CategoryTheory/Elements): initially small if functor is (co)representable (#34117)
We show that `Functor.Elements F` has an initial element if `F` is (co)representable and that categories with initial element are initially small.
1 parent 2edfed3 commit c3cf7cb

File tree

4 files changed

+79
-7
lines changed

4 files changed

+79
-7
lines changed

Mathlib/CategoryTheory/Elements.lean

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,32 @@ end CategoryOfElements
306306

307307
namespace Functor
308308

309+
/-- The initial object in `F.Elements` if `F` is representable. -/
310+
@[simps]
311+
def Elements.initialOfRepresentableBy {F : Cᵒᵖ ⥤ Type*} {X : C} (h : F.RepresentableBy X) :
312+
F.Elements :=
313+
⟨.op X, h.homEquiv (𝟙 X)⟩
314+
315+
/-- If `F` is represented by `X`, `X` with its universal element is the initial object of
316+
`F.Elements.` -/
317+
def Elements.isInitialOfRepresentableBy {F : Cᵒᵖ ⥤ Type*} {X : C} (h : F.RepresentableBy X) :
318+
Limits.IsInitial (initialOfRepresentableBy h) :=
319+
.ofUniqueHom (fun Y ↦ ⟨h.homEquiv.symm Y.snd |>.op, by simp [← h.homEquiv_comp]⟩) fun Y m ↦ by
320+
simp [← m.2, ← h.homEquiv_unop_comp]
321+
322+
/-- The initial object in `F.Elements` if `F` is corepresentable. -/
323+
@[simps]
324+
def Elements.initialOfCorepresentableBy {F : C ⥤ Type*} {X : C} (h : F.CorepresentableBy X) :
325+
F.Elements :=
326+
⟨X, h.homEquiv (𝟙 X)⟩
327+
328+
/-- If `F` is corepresented by `X`, `X` with its universal element is the initial object of
329+
`F.Elements.` -/
330+
def Elements.isInitialOfCorepresentableBy {F : C ⥤ Type*} {X : C} (h : F.CorepresentableBy X) :
331+
Limits.IsInitial (initialOfCorepresentableBy h) :=
332+
.ofUniqueHom (fun Y ↦ ⟨h.homEquiv.symm Y.snd, by simp [← h.homEquiv_comp]⟩) fun Y m ↦ by
333+
simp [← m.2, ← h.homEquiv_comp]
334+
309335
/--
310336
The initial object in the category of elements for a representable functor. In `isInitial` it is
311337
shown that this is initial.
@@ -315,13 +341,8 @@ def Elements.initial (A : C) : (yoneda.obj A).Elements :=
315341

316342
/-- Show that `Elements.initial A` is initial in the category of elements for the `yoneda` functor.
317343
-/
318-
def Elements.isInitial (A : C) : Limits.IsInitial (Elements.initial A) where
319-
desc s := ⟨s.pt.2.op, Category.comp_id _⟩
320-
uniq s m _ := by
321-
simp_rw [← m.2]
322-
dsimp [Elements.initial]
323-
simp
324-
fac := by rintro s ⟨⟨⟩⟩
344+
def Elements.isInitial (A : C) : Limits.IsInitial (Elements.initial A) :=
345+
isInitialOfRepresentableBy (.yoneda A)
325346

326347
end Functor
327348

Mathlib/CategoryTheory/Limits/Elements.lean

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ public import Mathlib.CategoryTheory.Elements
99
public import Mathlib.CategoryTheory.Limits.Types.Limits
1010
public import Mathlib.CategoryTheory.Limits.Creates
1111
public import Mathlib.CategoryTheory.Limits.Preserves.Limits
12+
public import Mathlib.CategoryTheory.Limits.Shapes.Terminal
1213

1314
/-!
1415
# Limits in the category of elements
@@ -17,6 +18,14 @@ We show that if `C` has limits of shape `I` and `A : C ⥤ Type w` preserves lim
1718
the category of elements of `A` has limits of shape `I` and the forgetful functor
1819
`π : A.Elements ⥤ C` creates them.
1920
21+
## Further results
22+
23+
- If `A` is (co)representable, then `A.Elements` has an initial object.
24+
25+
## TODOs
26+
27+
- Show that `A` is (co)representable if `A.Elements` has an initial object.
28+
2029
-/
2130

2231
@[expose] public section
@@ -105,6 +114,16 @@ noncomputable instance : CreatesLimitsOfShape I (π A) where
105114
instance : HasLimitsOfShape I A.Elements :=
106115
hasLimitsOfShape_of_hasLimitsOfShape_createsLimitsOfShape (π A)
107116

117+
section Initial
118+
119+
instance {F : Cᵒᵖ ⥤ Type*} [F.IsRepresentable] : HasInitial F.Elements :=
120+
(Functor.Elements.isInitialOfRepresentableBy F.representableBy).hasInitial
121+
122+
instance {F : C ⥤ Type*} [F.IsCorepresentable] : HasInitial F.Elements :=
123+
(Functor.Elements.isInitialOfCorepresentableBy F.corepresentableBy).hasInitial
124+
125+
end Initial
126+
108127
end CategoryOfElements
109128

110129
end CategoryTheory

Mathlib/CategoryTheory/Limits/FinallySmall.lean

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ theorem finallySmall_of_final_of_essentiallySmall [EssentiallySmall.{w} K] (F :
8181
have := finallySmall_of_essentiallySmall K
8282
finallySmall_of_final_of_finallySmall F
8383

84+
instance [Limits.HasTerminal J] : FinallySmall.{w} J :=
85+
have := Functor.final_const_terminal (C := PUnit.{w + 1}) (D := J)
86+
.mk' ((Functor.const PUnit.{w + 1}).obj (⊤_ J))
87+
8488
end FinallySmall
8589

8690
section InitiallySmall
@@ -130,6 +134,10 @@ theorem initiallySmall_of_initial_of_essentiallySmall [EssentiallySmall.{w} K]
130134
have := initiallySmall_of_essentiallySmall K
131135
initiallySmall_of_initial_of_initiallySmall F
132136

137+
instance [Limits.HasInitial J] : InitiallySmall.{w} J :=
138+
have := Functor.initial_const_initial (C := PUnit.{w + 1}) (D := J)
139+
.mk' ((Functor.const PUnit.{w + 1}).obj (⊥_ J))
140+
133141
end InitiallySmall
134142

135143
instance {J : Type u} [Category.{v} J] [InitiallySmall.{w} J] : FinallySmall.{w} Jᵒᵖ where

Mathlib/CategoryTheory/Yoneda.lean

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,11 @@ lemma RepresentableBy.comp_homEquiv_symm {F : Cᵒᵖ ⥤ Type v} {Y : C}
242242
f ≫ e.homEquiv.symm x = e.homEquiv.symm (F.map f.op x) :=
243243
e.homEquiv.injective (by simp [homEquiv_comp])
244244

245+
lemma RepresentableBy.homEquiv_unop_comp {F : Cᵒᵖ ⥤ Type*} {Y : C}
246+
(h : F.RepresentableBy Y) {X : Cᵒᵖ} {X' : C} (f : Opposite.op X' ⟶ X) (g : X' ⟶ Y) :
247+
h.homEquiv (f.unop ≫ g) = F.map f (h.homEquiv g) :=
248+
h.homEquiv_comp _ _
249+
245250
/-- If `F ≅ F'`, and `F` is representable, then `F'` is representable. -/
246251
def RepresentableBy.ofIso {F F' : Cᵒᵖ ⥤ Type v} {Y : C} (e : F.RepresentableBy Y) (e' : F ≅ F') :
247252
F'.RepresentableBy Y where
@@ -330,6 +335,15 @@ def representableByEquiv {F : Cᵒᵖ ⥤ Type v₁} {Y : C} :
330335
{ homEquiv := (e.app _).toEquiv
331336
homEquiv_comp := fun {X X'} f g ↦ congr_fun (e.hom.naturality f.op) g }
332337

338+
/-- `yoneda.obj X` is represented by `X`. -/
339+
protected def RepresentableBy.yoneda (X : C) : (yoneda.obj X).RepresentableBy X :=
340+
Functor.representableByEquiv.symm (Iso.refl _)
341+
342+
@[simp]
343+
lemma RepresentableBy.coyoneda_homEquiv (X Y : C) :
344+
(RepresentableBy.yoneda X).homEquiv = Equiv.refl (Y ⟶ X) :=
345+
rfl
346+
333347
/-- The isomorphism `yoneda.obj Y ≅ F` induced by `e : F.RepresentableBy Y`. -/
334348
def RepresentableBy.toIso {F : Cᵒᵖ ⥤ Type v₁} {Y : C} (e : F.RepresentableBy Y) :
335349
yoneda.obj Y ≅ F :=
@@ -346,6 +360,16 @@ def corepresentableByEquiv {F : C ⥤ Type v₁} {X : C} :
346360
{ homEquiv := (e.app _).toEquiv
347361
homEquiv_comp := fun {X X'} f g ↦ congr_fun (e.hom.naturality f) g }
348362

363+
/-- `coyoneda.obj X` is represented by `X`. -/
364+
protected def CorepresentableBy.coyoneda (X : Cᵒᵖ) :
365+
(coyoneda.obj X).CorepresentableBy X.unop :=
366+
Functor.corepresentableByEquiv.symm (Iso.refl _)
367+
368+
@[simp]
369+
lemma CorepresentableBy.coyoneda_homEquiv (X : Cᵒᵖ) (Y : C) :
370+
(CorepresentableBy.coyoneda X).homEquiv = Equiv.refl (X.unop ⟶ Y) :=
371+
rfl
372+
349373
/-- The isomorphism `coyoneda.obj (op X) ≅ F` induced by `e : F.CorepresentableBy X`. -/
350374
def CorepresentableBy.toIso {F : C ⥤ Type v₁} {X : C} (e : F.CorepresentableBy X) :
351375
coyoneda.obj (op X) ≅ F :=

0 commit comments

Comments
 (0)