Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit 4b0a82c

Browse files
rwbartondigama0
authored andcommitted
feat(category_theory): preservation of (co)limits, (co)limits in functor categories
1 parent 6267717 commit 4b0a82c

File tree

3 files changed

+308
-0
lines changed

3 files changed

+308
-0
lines changed
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
-- Copyright (c) 2018 Scott Morrison. All rights reserved.
2+
-- Released under Apache 2.0 license as described in the file LICENSE.
3+
-- Authors: Scott Morrison
4+
5+
import category_theory.products
6+
import category_theory.limits.preserves
7+
8+
open category_theory category_theory.category
9+
10+
namespace category_theory.limits
11+
12+
universes u v
13+
14+
variables {C : Type u} [𝒞 : category.{u v} C]
15+
include 𝒞
16+
17+
variables {J K : Type v} [small_category J] [small_category K]
18+
19+
@[simp] lemma cone.functor_w {F : J ⥤ (K ⥤ C)} (c : cone F) {j j' : J} (f : j ⟶ j') (k : K) :
20+
(c.π.app j).app k ≫ (F.map f).app k = (c.π.app j').app k :=
21+
by convert ←nat_trans.congr_app (c.π.naturality f).symm k; apply id_comp
22+
23+
@[simp] lemma cocone.functor_w {F : J ⥤ (K ⥤ C)} (c : cocone F) {j j' : J} (f : j ⟶ j') (k : K) :
24+
(F.map f).app k ≫ (c.ι.app j').app k = (c.ι.app j).app k :=
25+
by convert ←nat_trans.congr_app (c.ι.naturality f) k; apply comp_id
26+
27+
@[simp] def functor_category_limit_cone [has_limits_of_shape J C] (F : J ⥤ K ⥤ C) :
28+
cone F :=
29+
{ X := F.flip ⋙ lim,
30+
π :=
31+
{ app := λ j,
32+
{ app := λ k, limit.π (F.flip.obj k) j },
33+
naturality' := λ j j' f,
34+
by ext k; convert (limit.w (F.flip.obj k) _).symm using 1; apply id_comp } }
35+
36+
@[simp] def functor_category_colimit_cocone [has_colimits_of_shape J C] (F : J ⥤ K ⥤ C) :
37+
cocone F :=
38+
{ X := F.flip ⋙ colim,
39+
ι :=
40+
{ app := λ j,
41+
{ app := λ k, colimit.ι (F.flip.obj k) j },
42+
naturality' := λ j j' f,
43+
by ext k; convert (colimit.w (F.flip.obj k) _) using 1; apply comp_id } }
44+
45+
@[simp] def evaluate_functor_category_limit_cone
46+
[has_limits_of_shape J C] (F : J ⥤ K ⥤ C) (k : K) :
47+
((evaluation K C).obj k).map_cone (functor_category_limit_cone F) ≅
48+
limit.cone (F.flip.obj k) :=
49+
cones.ext (iso.refl _) (by tidy)
50+
51+
@[simp] def evaluate_functor_category_colimit_cocone
52+
[has_colimits_of_shape J C] (F : J ⥤ K ⥤ C) (k : K) :
53+
((evaluation K C).obj k).map_cocone (functor_category_colimit_cocone F) ≅
54+
colimit.cocone (F.flip.obj k) :=
55+
cocones.ext (iso.refl _) (by tidy)
56+
57+
def functor_category_is_limit_cone [has_limits_of_shape J C] (F : J ⥤ K ⥤ C) :
58+
is_limit (functor_category_limit_cone F) :=
59+
{ lift := λ s,
60+
{ app := λ k, limit.lift (F.flip.obj k) (((evaluation K C).obj k).map_cone s),
61+
naturality' := λ k k' f,
62+
by ext; dsimp; simpa using (s.π.app j).naturality f },
63+
uniq' := λ s m w,
64+
begin
65+
ext1 k,
66+
exact is_limit.uniq _
67+
(((evaluation K C).obj k).map_cone s) (m.app k) (λ j, nat_trans.congr_app (w j) k)
68+
end }
69+
70+
def functor_category_is_colimit_cocone [has_colimits_of_shape.{u v} J C] (F : J ⥤ K ⥤ C) :
71+
is_colimit (functor_category_colimit_cocone F) :=
72+
{ desc := λ s,
73+
{ app := λ k, colimit.desc (F.flip.obj k) (((evaluation K C).obj k).map_cocone s),
74+
naturality' := λ k k' f,
75+
begin
76+
ext,
77+
rw [←assoc, ←assoc],
78+
dsimp [functor.flip],
79+
simpa using (s.ι.app j).naturality f
80+
end },
81+
uniq' := λ s m w,
82+
begin
83+
ext1 k,
84+
exact is_colimit.uniq _
85+
(((evaluation K C).obj k).map_cocone s) (m.app k) (λ j, nat_trans.congr_app (w j) k)
86+
end }
87+
88+
instance functor_category_has_limits_of_shape
89+
[has_limits_of_shape J C] : has_limits_of_shape J (K ⥤ C) :=
90+
λ F,
91+
{ cone := functor_category_limit_cone F,
92+
is_limit := functor_category_is_limit_cone F }
93+
94+
instance functor_category_has_colimits_of_shape
95+
[has_colimits_of_shape J C] : has_colimits_of_shape J (K ⥤ C) :=
96+
λ F,
97+
{ cocone := functor_category_colimit_cocone F,
98+
is_colimit := functor_category_is_colimit_cocone F }
99+
100+
instance functor_category_has_limits [has_limits C] : has_limits (K ⥤ C) :=
101+
λ J 𝒥, by resetI; apply_instance
102+
103+
instance functor_category_has_colimits [has_colimits C] : has_colimits (K ⥤ C) :=
104+
λ J 𝒥, by resetI; apply_instance
105+
106+
instance evaluation_preserves_limits_of_shape [has_limits_of_shape J C] (k : K) :
107+
preserves_limits_of_shape J ((evaluation K C).obj k) :=
108+
λ F, preserves_limit_of_preserves_limit_cone (limit.is_limit _) $
109+
is_limit.of_iso_limit (limit.is_limit _)
110+
(evaluate_functor_category_limit_cone F k).symm
111+
112+
instance evaluation_preserves_colimits_of_shape [has_colimits_of_shape J C] (k : K) :
113+
preserves_colimits_of_shape J ((evaluation K C).obj k) :=
114+
λ F, preserves_colimit_of_preserves_colimit_cocone (colimit.is_colimit _) $
115+
is_colimit.of_iso_colimit (colimit.is_colimit _)
116+
(evaluate_functor_category_colimit_cocone F k).symm
117+
118+
instance evaluation_preserves_limits [has_limits C] (k : K) :
119+
preserves_limits ((evaluation K C).obj k) :=
120+
λ J 𝒥, by resetI; apply_instance
121+
122+
instance evaluation_preserves_colimits [has_colimits C] (k : K) :
123+
preserves_colimits ((evaluation K C).obj k) :=
124+
λ J 𝒥, by resetI; apply_instance
125+
126+
end category_theory.limits

category_theory/limits/preserves.lean

Lines changed: 180 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
-- Copyright (c) 2018 Scott Morrison. All rights reserved.
2+
-- Released under Apache 2.0 license as described in the file LICENSE.
3+
-- Authors: Scott Morrison, Reid Barton
4+
5+
-- Preservation and reflection of (co)limits.
6+
7+
import category_theory.whiskering
8+
import category_theory.limits.limits
9+
10+
open category_theory
11+
12+
namespace category_theory.limits
13+
14+
universes u₁ u₂ u₃ v
15+
16+
variables {C : Type u₁} [𝒞 : category.{u₁ v} C]
17+
variables {D : Type u₂} [𝒟 : category.{u₂ v} D]
18+
include 𝒞 𝒟
19+
20+
variables {J : Type v} [small_category J] {K : J ⥤ C}
21+
22+
/- Note on "preservation of (co)limits"
23+
24+
There are various distinct notions of "preserving limits". The one we
25+
aim to capture here is: A functor F : C → D "preserves limits" if it
26+
sends every limit cone in C to a limit cone in D. Informally, F
27+
preserves all the limits which exist in C.
28+
29+
Note that:
30+
31+
* Of course, we do not want to require F to *strictly* take chosen
32+
limit cones of C to chosen limit cones of D. Indeed, the above
33+
definition makes no reference to a choice of limit cones so it makes
34+
sense without any conditions on C or D.
35+
36+
* Some diagrams in C may have no limit. In this case, there is no
37+
condition on the behavior of F on such diagrams. There are other
38+
notions (such as "flat functor") which impose conditions also on
39+
diagrams in C with no limits, but these are not considered here.
40+
41+
In order to be able to express the property of preserving limits of a
42+
certain form, we say that a functor F preserves the limit of a
43+
diagram K if F sends every limit cone on K to a limit cone. This is
44+
vacuously satisfied when K does not admit a limit, which is consistent
45+
with the above definition of "preserves limits".
46+
47+
-/
48+
49+
class preserves_limit (K : J ⥤ C) (F : C ⥤ D) :=
50+
(preserves : Π {c : cone K}, is_limit c → is_limit (F.map_cone c))
51+
class preserves_colimit (K : J ⥤ C) (F : C ⥤ D) :=
52+
(preserves : Π {c : cocone K}, is_colimit c → is_colimit (F.map_cocone c))
53+
54+
@[class] def preserves_limits_of_shape (J : Type v) [small_category J] (F : C ⥤ D) :=
55+
Π {K : J ⥤ C}, preserves_limit K F
56+
@[class] def preserves_colimits_of_shape (J : Type v) [small_category J] (F : C ⥤ D) :=
57+
Π {K : J ⥤ C}, preserves_colimit K F
58+
59+
@[class] def preserves_limits (F : C ⥤ D) :=
60+
Π {J : Type v} {𝒥 : small_category J}, by exactI preserves_limits_of_shape J F
61+
@[class] def preserves_colimits (F : C ⥤ D) :=
62+
Π {J : Type v} {𝒥 : small_category J}, by exactI preserves_colimits_of_shape J F
63+
64+
instance preserves_limit_of_preserves_limits_of_shape (F : C ⥤ D)
65+
[H : preserves_limits_of_shape J F] : preserves_limit K F :=
66+
H
67+
instance preserves_colimit_of_preserves_colimits_of_shape (F : C ⥤ D)
68+
[H : preserves_colimits_of_shape J F] : preserves_colimit K F :=
69+
H
70+
71+
instance preserves_limits_of_shape_of_preserves_limits (F : C ⥤ D)
72+
[H : preserves_limits F] : preserves_limits_of_shape J F :=
73+
@H J _
74+
instance preserves_colimits_of_shape_of_preserves_colimits (F : C ⥤ D)
75+
[H : preserves_colimits F] : preserves_colimits_of_shape J F :=
76+
@H J _
77+
78+
instance id_preserves_limits : preserves_limits (functor.id C) :=
79+
λ J 𝒥 K, by exactI ⟨λ c h,
80+
⟨λ s, h.lift ⟨s.X, λ j, s.π.app j, λ j j' f, s.π.naturality f⟩,
81+
by cases K; rcases c with ⟨_, _, _⟩; intros s j; cases s; exact h.fac _ j,
82+
by cases K; rcases c with ⟨_, _, _⟩; intros s m w; rcases s with ⟨_, _, _⟩; exact h.uniq _ m w⟩⟩
83+
84+
instance id_preserves_colimits : preserves_colimits (functor.id C) :=
85+
λ J 𝒥 K, by exactI ⟨λ c h,
86+
⟨λ s, h.desc ⟨s.X, λ j, s.ι.app j, λ j j' f, s.ι.naturality f⟩,
87+
by cases K; rcases c with ⟨_, _, _⟩; intros s j; cases s; exact h.fac _ j,
88+
by cases K; rcases c with ⟨_, _, _⟩; intros s m w; rcases s with ⟨_, _, _⟩; exact h.uniq _ m w⟩⟩
89+
90+
section
91+
variables {E : Type u₃} [ℰ : category.{u₃ v} E]
92+
variables (F : C ⥤ D) (G : D ⥤ E)
93+
94+
local attribute [elab_simple] preserves_limit.preserves preserves_colimit.preserves
95+
96+
instance comp_preserves_limit [preserves_limit K F] [preserves_limit (K ⋙ F) G] :
97+
preserves_limit K (F ⋙ G) :=
98+
⟨λ c h, preserves_limit.preserves G (preserves_limit.preserves F h)⟩
99+
100+
instance comp_preserves_colimit [preserves_colimit K F] [preserves_colimit (K ⋙ F) G] :
101+
preserves_colimit K (F ⋙ G) :=
102+
⟨λ c h, preserves_colimit.preserves G (preserves_colimit.preserves F h)⟩
103+
104+
end
105+
106+
/-- If F preserves one limit cone for the diagram K,
107+
then it preserves any limit cone for K. -/
108+
def preserves_limit_of_preserves_limit_cone {F : C ⥤ D} {t : cone K}
109+
(h : is_limit t) (hF : is_limit (F.map_cone t)) : preserves_limit K F :=
110+
⟨λ t' h', is_limit.of_iso_limit hF (functor.on_iso _ (is_limit.unique h h'))⟩
111+
112+
/-- If F preserves one colimit cocone for the diagram K,
113+
then it preserves any colimit cocone for K. -/
114+
def preserves_colimit_of_preserves_colimit_cocone {F : C ⥤ D} {t : cocone K}
115+
(h : is_colimit t) (hF : is_colimit (F.map_cocone t)) : preserves_colimit K F :=
116+
⟨λ t' h', is_colimit.of_iso_colimit hF (functor.on_iso _ (is_colimit.unique h h'))⟩
117+
118+
/-
119+
A functor F : C → D reflects limits if whenever the image of a cone
120+
under F is a limit cone in D, the cone was already a limit cone in C.
121+
Note that again we do not assume a priori that D actually has any
122+
limits.
123+
-/
124+
125+
class reflects_limit (K : J ⥤ C) (F : C ⥤ D) :=
126+
(reflects : Π {c : cone K}, is_limit (F.map_cone c) → is_limit c)
127+
class reflects_colimit (K : J ⥤ C) (F : C ⥤ D) :=
128+
(reflects : Π {c : cocone K}, is_colimit (F.map_cocone c) → is_colimit c)
129+
130+
@[class] def reflects_limits_of_shape (J : Type v) [small_category J] (F : C ⥤ D) :=
131+
Π {K : J ⥤ C}, reflects_limit K F
132+
@[class] def reflects_colimits_of_shape (J : Type v) [small_category J] (F : C ⥤ D) :=
133+
Π {K : J ⥤ C}, reflects_colimit K F
134+
135+
@[class] def reflects_limits (F : C ⥤ D) :=
136+
Π {J : Type v} {𝒥 : small_category J}, by exactI reflects_limits_of_shape J F
137+
@[class] def reflects_colimits (F : C ⥤ D) :=
138+
Π {J : Type v} {𝒥 : small_category J}, by exactI reflects_colimits_of_shape J F
139+
140+
instance reflects_limit_of_reflects_limits_of_shape (K : J ⥤ C) (F : C ⥤ D)
141+
[H : reflects_limits_of_shape J F] : reflects_limit K F :=
142+
H
143+
instance reflects_colimit_of_reflects_colimits_of_shape (K : J ⥤ C) (F : C ⥤ D)
144+
[H : reflects_colimits_of_shape J F] : reflects_colimit K F :=
145+
H
146+
147+
instance reflects_limits_of_shape_of_reflects_limits (F : C ⥤ D)
148+
[H : reflects_limits F] : reflects_limits_of_shape J F :=
149+
@H J _
150+
instance reflects_colimits_of_shape_of_reflects_colimits (F : C ⥤ D)
151+
[H : reflects_colimits F] : reflects_colimits_of_shape J F :=
152+
@H J _
153+
154+
instance id_reflects_limits : reflects_limits (functor.id C) :=
155+
λ J 𝒥 K, by exactI ⟨λ c h,
156+
⟨λ s, h.lift ⟨s.X, λ j, s.π.app j, λ j j' f, s.π.naturality f⟩,
157+
by cases K; rcases c with ⟨_, _, _⟩; intros s j; cases s; exact h.fac _ j,
158+
by cases K; rcases c with ⟨_, _, _⟩; intros s m w; rcases s with ⟨_, _, _⟩; exact h.uniq _ m w⟩⟩
159+
160+
instance id_reflects_colimits : reflects_colimits (functor.id C) :=
161+
λ J 𝒥 K, by exactI ⟨λ c h,
162+
⟨λ s, h.desc ⟨s.X, λ j, s.ι.app j, λ j j' f, s.ι.naturality f⟩,
163+
by cases K; rcases c with ⟨_, _, _⟩; intros s j; cases s; exact h.fac _ j,
164+
by cases K; rcases c with ⟨_, _, _⟩; intros s m w; rcases s with ⟨_, _, _⟩; exact h.uniq _ m w⟩⟩
165+
166+
section
167+
variables {E : Type u₃} [ℰ : category.{u₃ v} E]
168+
variables (F : C ⥤ D) (G : D ⥤ E)
169+
170+
instance comp_reflects_limit [reflects_limit K F] [reflects_limit (K ⋙ F) G] :
171+
reflects_limit K (F ⋙ G) :=
172+
⟨λ c h, reflects_limit.reflects (reflects_limit.reflects h)⟩
173+
174+
instance comp_reflects_colimit [reflects_colimit K F] [reflects_colimit (K ⋙ F) G] :
175+
reflects_colimit K (F ⋙ G) :=
176+
⟨λ c h, reflects_colimit.reflects (reflects_colimit.reflects h)⟩
177+
178+
end
179+
180+
end category_theory.limits

category_theory/natural_transformation.lean

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ begin
5959
subst hc
6060
end
6161

62+
lemma congr_app {α β : F ⟹ G} (h : α = β) (X : C) : α.app X = β.app X := by rw h
63+
6264
/-- `vcomp α β` is the vertical compositions of natural transformations. -/
6365
def vcomp (α : F ⟹ G) (β : G ⟹ H) : F ⟹ H :=
6466
{ app := λ X, (α.app X) ≫ (β.app X),

0 commit comments

Comments
 (0)