-
Notifications
You must be signed in to change notification settings - Fork 259
/
Equalizers.lean
216 lines (182 loc) · 9.12 KB
/
Equalizers.lean
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
/-
Copyright (c) 2020 Bhavik Mehta. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Bhavik Mehta, Andrew Yang
-/
import Mathlib.CategoryTheory.Limits.Shapes.Equalizers
import Mathlib.CategoryTheory.Limits.Shapes.BinaryProducts
import Mathlib.CategoryTheory.Limits.Preserves.Shapes.Pullbacks
import Mathlib.CategoryTheory.Limits.Preserves.Shapes.BinaryProducts
/-!
# Constructing equalizers from pullbacks and binary products.
If a category has pullbacks and binary products, then it has equalizers.
TODO: generalize universe
-/
noncomputable section
universe v v' u u'
open CategoryTheory CategoryTheory.Category
namespace CategoryTheory.Limits
variable {C : Type u} [Category.{v} C]
variable {D : Type u'} [Category.{v'} D] (G : C ⥤ D)
-- We hide the "implementation details" inside a namespace
namespace HasEqualizersOfHasPullbacksAndBinaryProducts
variable [HasBinaryProducts C] [HasPullbacks C]
/-- Define the equalizing object -/
abbrev constructEqualizer (F : WalkingParallelPair ⥤ C) : C :=
pullback (prod.lift (𝟙 _) (F.map WalkingParallelPairHom.left))
(prod.lift (𝟙 _) (F.map WalkingParallelPairHom.right))
/-- Define the equalizing morphism -/
abbrev pullbackFst (F : WalkingParallelPair ⥤ C) :
constructEqualizer F ⟶ F.obj WalkingParallelPair.zero :=
pullback.fst _ _
theorem pullbackFst_eq_pullback_snd (F : WalkingParallelPair ⥤ C) :
pullbackFst F = pullback.snd _ _ := by
convert (eq_whisker pullback.condition Limits.prod.fst :
(_ : constructEqualizer F ⟶ F.obj WalkingParallelPair.zero) = _) <;> simp
/-- Define the equalizing cone -/
abbrev equalizerCone (F : WalkingParallelPair ⥤ C) : Cone F :=
Cone.ofFork
(Fork.ofι (pullbackFst F)
(by
conv_rhs => rw [pullbackFst_eq_pullback_snd]
convert (eq_whisker pullback.condition Limits.prod.snd :
(_ : constructEqualizer F ⟶ F.obj WalkingParallelPair.one) = _) using 1 <;> simp))
/-- Show the equalizing cone is a limit -/
def equalizerConeIsLimit (F : WalkingParallelPair ⥤ C) : IsLimit (equalizerCone F) where
lift := by
intro c; apply pullback.lift (c.π.app _) (c.π.app _)
ext <;> simp
fac := by rintro c (_ | _) <;> simp
uniq := by
intro c _ J
have J0 := J WalkingParallelPair.zero; simp at J0
apply pullback.hom_ext
· rwa [limit.lift_π]
· erw [limit.lift_π, ← J0, pullbackFst_eq_pullback_snd]
end HasEqualizersOfHasPullbacksAndBinaryProducts
open HasEqualizersOfHasPullbacksAndBinaryProducts
-- This is not an instance, as it is not always how one wants to construct equalizers!
/-- Any category with pullbacks and binary products, has equalizers. -/
theorem hasEqualizers_of_hasPullbacks_and_binary_products [HasBinaryProducts C] [HasPullbacks C] :
HasEqualizers C :=
{ has_limit := fun F =>
HasLimit.mk
{ cone := equalizerCone F
isLimit := equalizerConeIsLimit F } }
attribute [local instance] hasPullback_of_preservesPullback
/-- A functor that preserves pullbacks and binary products also presrves equalizers. -/
def preservesEqualizersOfPreservesPullbacksAndBinaryProducts [HasBinaryProducts C] [HasPullbacks C]
[PreservesLimitsOfShape (Discrete WalkingPair) G] [PreservesLimitsOfShape WalkingCospan G] :
PreservesLimitsOfShape WalkingParallelPair G :=
⟨fun {K} =>
preservesLimitOfPreservesLimitCone (equalizerConeIsLimit K) <|
{ lift := fun c => by
refine pullback.lift ?_ ?_ ?_ ≫ (PreservesPullback.iso _ _ _ ).inv
· exact c.π.app WalkingParallelPair.zero
· exact c.π.app WalkingParallelPair.zero
apply (mapIsLimitOfPreservesOfIsLimit G _ _ (prodIsProd _ _)).hom_ext
rintro (_ | _)
· simp only [Category.assoc, ← G.map_comp, prod.lift_fst, BinaryFan.π_app_left,
BinaryFan.mk_fst]
· simp only [BinaryFan.π_app_right, BinaryFan.mk_snd, Category.assoc, ← G.map_comp,
prod.lift_snd]
exact
(c.π.naturality WalkingParallelPairHom.left).symm.trans
(c.π.naturality WalkingParallelPairHom.right)
fac := fun c j => by
rcases j with (_ | _) <;>
simp only [Category.comp_id, PreservesPullback.iso_inv_fst, Cone.ofFork_π, G.map_comp,
PreservesPullback.iso_inv_fst_assoc, Functor.mapCone_π_app, eqToHom_refl,
Category.assoc, Fork.ofι_π_app, pullback.lift_fst, pullback.lift_fst_assoc]
exact (c.π.naturality WalkingParallelPairHom.left).symm.trans (Category.id_comp _)
uniq := fun s m h => by
rw [Iso.eq_comp_inv]
have := h WalkingParallelPair.zero
dsimp [equalizerCone] at this
ext <;>
simp only [PreservesPullback.iso_hom_snd, Category.assoc,
PreservesPullback.iso_hom_fst, pullback.lift_fst, pullback.lift_snd,
Category.comp_id, ← pullbackFst_eq_pullback_snd, ← this] }⟩
-- We hide the "implementation details" inside a namespace
namespace HasCoequalizersOfHasPushoutsAndBinaryCoproducts
variable [HasBinaryCoproducts C] [HasPushouts C]
/-- Define the equalizing object -/
abbrev constructCoequalizer (F : WalkingParallelPair ⥤ C) : C :=
pushout (coprod.desc (𝟙 _) (F.map WalkingParallelPairHom.left))
(coprod.desc (𝟙 _) (F.map WalkingParallelPairHom.right))
/-- Define the equalizing morphism -/
abbrev pushoutInl (F : WalkingParallelPair ⥤ C) :
F.obj WalkingParallelPair.one ⟶ constructCoequalizer F :=
pushout.inl _ _
theorem pushoutInl_eq_pushout_inr (F : WalkingParallelPair ⥤ C) :
pushoutInl F = pushout.inr _ _ := by
convert (whisker_eq Limits.coprod.inl pushout.condition :
(_ : F.obj _ ⟶ constructCoequalizer _) = _) <;> simp
/-- Define the equalizing cocone -/
abbrev coequalizerCocone (F : WalkingParallelPair ⥤ C) : Cocone F :=
Cocone.ofCofork
(Cofork.ofπ (pushoutInl F) (by
conv_rhs => rw [pushoutInl_eq_pushout_inr]
convert (whisker_eq Limits.coprod.inr pushout.condition :
(_ : F.obj _ ⟶ constructCoequalizer _) = _) using 1 <;> simp))
/-- Show the equalizing cocone is a colimit -/
def coequalizerCoconeIsColimit (F : WalkingParallelPair ⥤ C) : IsColimit (coequalizerCocone F) where
desc := by
intro c; apply pushout.desc (c.ι.app _) (c.ι.app _)
ext <;> simp
fac := by rintro c (_ | _) <;> simp
uniq := by
intro c m J
have J1 : pushoutInl F ≫ m = c.ι.app WalkingParallelPair.one := by
simpa using J WalkingParallelPair.one
apply pushout.hom_ext
· rw [colimit.ι_desc]
exact J1
· rw [colimit.ι_desc, ← pushoutInl_eq_pushout_inr]
exact J1
end HasCoequalizersOfHasPushoutsAndBinaryCoproducts
open HasCoequalizersOfHasPushoutsAndBinaryCoproducts
-- This is not an instance, as it is not always how one wants to construct equalizers!
/-- Any category with pullbacks and binary products, has equalizers. -/
theorem hasCoequalizers_of_hasPushouts_and_binary_coproducts [HasBinaryCoproducts C]
[HasPushouts C] : HasCoequalizers C :=
{
has_colimit := fun F =>
HasColimit.mk
{ cocone := coequalizerCocone F
isColimit := coequalizerCoconeIsColimit F } }
attribute [local instance] hasPushout_of_preservesPushout
/-- A functor that preserves pushouts and binary coproducts also presrves coequalizers. -/
def preservesCoequalizersOfPreservesPushoutsAndBinaryCoproducts [HasBinaryCoproducts C]
[HasPushouts C] [PreservesColimitsOfShape (Discrete WalkingPair) G]
[PreservesColimitsOfShape WalkingSpan G] : PreservesColimitsOfShape WalkingParallelPair G :=
⟨fun {K} =>
preservesColimitOfPreservesColimitCocone (coequalizerCoconeIsColimit K) <|
{ desc := fun c => by
refine (PreservesPushout.iso _ _ _).inv ≫ pushout.desc ?_ ?_ ?_
· exact c.ι.app WalkingParallelPair.one
· exact c.ι.app WalkingParallelPair.one
apply (mapIsColimitOfPreservesOfIsColimit G _ _ (coprodIsCoprod _ _)).hom_ext
rintro (_ | _)
· simp only [BinaryCofan.ι_app_left, BinaryCofan.mk_inl, Category.assoc, ←
G.map_comp_assoc, coprod.inl_desc]
· simp only [BinaryCofan.ι_app_right, BinaryCofan.mk_inr, Category.assoc, ←
G.map_comp_assoc, coprod.inr_desc]
exact
(c.ι.naturality WalkingParallelPairHom.left).trans
(c.ι.naturality WalkingParallelPairHom.right).symm
fac := fun c j => by
rcases j with (_ | _) <;>
simp only [Functor.mapCocone_ι_app, Cocone.ofCofork_ι, Category.id_comp,
eqToHom_refl, Category.assoc, Functor.map_comp, Cofork.ofπ_ι_app, pushout.inl_desc,
PreservesPushout.inl_iso_inv_assoc]
exact (c.ι.naturality WalkingParallelPairHom.left).trans (Category.comp_id _)
uniq := fun s m h => by
rw [Iso.eq_inv_comp]
have := h WalkingParallelPair.one
dsimp [coequalizerCocone] at this
ext <;>
simp only [PreservesPushout.inl_iso_hom_assoc, Category.id_comp, pushout.inl_desc,
pushout.inr_desc, PreservesPushout.inr_iso_hom_assoc, ← pushoutInl_eq_pushout_inr, ←
this] }⟩
end CategoryTheory.Limits