-
Notifications
You must be signed in to change notification settings - Fork 259
/
DifferentialObject.lean
326 lines (257 loc) · 12 KB
/
DifferentialObject.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
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
/-
Copyright (c) 2020 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Scott Morrison
-/
import Mathlib.Algebra.Group.Basic
import Mathlib.Data.Int.Cast.Defs
import Mathlib.CategoryTheory.Shift.Basic
import Mathlib.CategoryTheory.ConcreteCategory.Basic
#align_import category_theory.differential_object from "leanprover-community/mathlib"@"6876fa15e3158ff3e4a4e2af1fb6e1945c6e8803"
/-!
# Differential objects in a category.
A differential object in a category with zero morphisms and a shift is
an object `X` equipped with
a morphism `d : obj ⟶ obj⟦1⟧`, such that `d^2 = 0`.
We build the category of differential objects, and some basic constructions
such as the forgetful functor, zero morphisms and zero objects, and the shift functor
on differential objects.
-/
open CategoryTheory.Limits
universe v u
namespace CategoryTheory
variable (S : Type*) [AddMonoidWithOne S] (C : Type u) [Category.{v} C]
variable [HasZeroMorphisms C] [HasShift C S]
/-- A differential object in a category with zero morphisms and a shift is
an object `obj` equipped with
a morphism `d : obj ⟶ obj⟦1⟧`, such that `d^2 = 0`. -/
-- Porting note(#5171): removed `@[nolint has_nonempty_instance]`
structure DifferentialObject where
/-- The underlying object of a differential object. -/
obj : C
/-- The differential of a differential object. -/
d : obj ⟶ obj⟦(1 : S)⟧
/-- The differential `d` satisfies that `d² = 0`. -/
d_squared : d ≫ d⟦(1 : S)⟧' = 0 := by aesop_cat
#align category_theory.differential_object CategoryTheory.DifferentialObject
set_option linter.uppercaseLean3 false in
#align category_theory.differential_object.X CategoryTheory.DifferentialObject.obj
attribute [reassoc (attr := simp)] DifferentialObject.d_squared
variable {S C}
namespace DifferentialObject
/-- A morphism of differential objects is a morphism commuting with the differentials. -/
@[ext] -- Porting note(#5171): removed `nolint has_nonempty_instance`
structure Hom (X Y : DifferentialObject S C) where
/-- The morphism between underlying objects of the two differentiable objects. -/
f : X.obj ⟶ Y.obj
comm : X.d ≫ f⟦1⟧' = f ≫ Y.d := by aesop_cat
#align category_theory.differential_object.hom CategoryTheory.DifferentialObject.Hom
attribute [reassoc (attr := simp)] Hom.comm
namespace Hom
/-- The identity morphism of a differential object. -/
@[simps]
def id (X : DifferentialObject S C) : Hom X X where
f := 𝟙 X.obj
#align category_theory.differential_object.hom.id CategoryTheory.DifferentialObject.Hom.id
/-- The composition of morphisms of differential objects. -/
@[simps]
def comp {X Y Z : DifferentialObject S C} (f : Hom X Y) (g : Hom Y Z) : Hom X Z where
f := f.f ≫ g.f
#align category_theory.differential_object.hom.comp CategoryTheory.DifferentialObject.Hom.comp
end Hom
instance categoryOfDifferentialObjects : Category (DifferentialObject S C) where
Hom := Hom
id := Hom.id
comp f g := Hom.comp f g
#align category_theory.differential_object.category_of_differential_objects CategoryTheory.DifferentialObject.categoryOfDifferentialObjects
-- Porting note: added
@[ext]
theorem ext {A B : DifferentialObject S C} {f g : A ⟶ B} (w : f.f = g.f := by aesop_cat) : f = g :=
Hom.ext _ _ w
@[simp]
theorem id_f (X : DifferentialObject S C) : (𝟙 X : X ⟶ X).f = 𝟙 X.obj := rfl
#align category_theory.differential_object.id_f CategoryTheory.DifferentialObject.id_f
@[simp]
theorem comp_f {X Y Z : DifferentialObject S C} (f : X ⟶ Y) (g : Y ⟶ Z) :
(f ≫ g).f = f.f ≫ g.f :=
rfl
#align category_theory.differential_object.comp_f CategoryTheory.DifferentialObject.comp_f
@[simp]
theorem eqToHom_f {X Y : DifferentialObject S C} (h : X = Y) :
Hom.f (eqToHom h) = eqToHom (congr_arg _ h) := by
subst h
rw [eqToHom_refl, eqToHom_refl]
rfl
#align category_theory.differential_object.eq_to_hom_f CategoryTheory.DifferentialObject.eqToHom_f
variable (S C)
/-- The forgetful functor taking a differential object to its underlying object. -/
def forget : DifferentialObject S C ⥤ C where
obj X := X.obj
map f := f.f
#align category_theory.differential_object.forget CategoryTheory.DifferentialObject.forget
instance forget_faithful : (forget S C).Faithful where
#align category_theory.differential_object.forget_faithful CategoryTheory.DifferentialObject.forget_faithful
variable [(shiftFunctor C (1 : S)).PreservesZeroMorphisms]
instance {X Y : DifferentialObject S C} : Zero (X ⟶ Y) := ⟨{f := 0}⟩
variable {S C}
@[simp]
theorem zero_f (P Q : DifferentialObject S C) : (0 : P ⟶ Q).f = 0 := rfl
#align category_theory.differential_object.zero_f CategoryTheory.DifferentialObject.zero_f
instance hasZeroMorphisms : HasZeroMorphisms (DifferentialObject S C) where
#align category_theory.differential_object.has_zero_morphisms CategoryTheory.DifferentialObject.hasZeroMorphisms
/-- An isomorphism of differential objects gives an isomorphism of the underlying objects. -/
@[simps]
def isoApp {X Y : DifferentialObject S C} (f : X ≅ Y) : X.obj ≅ Y.obj where
hom := f.hom.f
inv := f.inv.f
hom_inv_id := by rw [← comp_f, Iso.hom_inv_id, id_f]
inv_hom_id := by rw [← comp_f, Iso.inv_hom_id, id_f]
#align category_theory.differential_object.iso_app CategoryTheory.DifferentialObject.isoApp
@[simp]
theorem isoApp_refl (X : DifferentialObject S C) : isoApp (Iso.refl X) = Iso.refl X.obj := rfl
#align category_theory.differential_object.iso_app_refl CategoryTheory.DifferentialObject.isoApp_refl
@[simp]
theorem isoApp_symm {X Y : DifferentialObject S C} (f : X ≅ Y) : isoApp f.symm = (isoApp f).symm :=
rfl
#align category_theory.differential_object.iso_app_symm CategoryTheory.DifferentialObject.isoApp_symm
@[simp]
theorem isoApp_trans {X Y Z : DifferentialObject S C} (f : X ≅ Y) (g : Y ≅ Z) :
isoApp (f ≪≫ g) = isoApp f ≪≫ isoApp g := rfl
#align category_theory.differential_object.iso_app_trans CategoryTheory.DifferentialObject.isoApp_trans
/-- An isomorphism of differential objects can be constructed
from an isomorphism of the underlying objects that commutes with the differentials. -/
@[simps]
def mkIso {X Y : DifferentialObject S C} (f : X.obj ≅ Y.obj) (hf : X.d ≫ f.hom⟦1⟧' = f.hom ≫ Y.d) :
X ≅ Y where
hom := ⟨f.hom, hf⟩
inv := ⟨f.inv, by
rw [← Functor.mapIso_inv, Iso.comp_inv_eq, Category.assoc, Iso.eq_inv_comp, Functor.mapIso_hom,
hf]⟩
hom_inv_id := by ext1; dsimp; exact f.hom_inv_id
inv_hom_id := by ext1; dsimp; exact f.inv_hom_id
#align category_theory.differential_object.mk_iso CategoryTheory.DifferentialObject.mkIso
end DifferentialObject
namespace Functor
universe v' u'
variable (D : Type u') [Category.{v'} D]
variable [HasZeroMorphisms D] [HasShift D S]
/-- A functor `F : C ⥤ D` which commutes with shift functors on `C` and `D` and preserves zero
morphisms can be lifted to a functor `DifferentialObject S C ⥤ DifferentialObject S D`. -/
@[simps]
def mapDifferentialObject (F : C ⥤ D)
(η : (shiftFunctor C (1 : S)).comp F ⟶ F.comp (shiftFunctor D (1 : S)))
(hF : ∀ c c', F.map (0 : c ⟶ c') = 0) : DifferentialObject S C ⥤ DifferentialObject S D where
obj X :=
{ obj := F.obj X.obj
d := F.map X.d ≫ η.app X.obj
d_squared := by
rw [Functor.map_comp, ← Functor.comp_map F (shiftFunctor D (1 : S))]
slice_lhs 2 3 => rw [← η.naturality X.d]
rw [Functor.comp_map]
slice_lhs 1 2 => rw [← F.map_comp, X.d_squared, hF]
rw [zero_comp, zero_comp] }
map f :=
{ f := F.map f.f
comm := by
dsimp
slice_lhs 2 3 => rw [← Functor.comp_map F (shiftFunctor D (1 : S)), ← η.naturality f.f]
slice_lhs 1 2 => rw [Functor.comp_map, ← F.map_comp, f.comm, F.map_comp]
rw [Category.assoc] }
map_id := by intros; ext; simp [autoParam]
map_comp := by intros; ext; simp [autoParam]
#align category_theory.functor.map_differential_object CategoryTheory.Functor.mapDifferentialObject
end Functor
end CategoryTheory
namespace CategoryTheory
namespace DifferentialObject
variable (S : Type*) [AddMonoidWithOne S] (C : Type u) [Category.{v} C]
variable [HasZeroObject C] [HasZeroMorphisms C] [HasShift C S]
variable [(shiftFunctor C (1 : S)).PreservesZeroMorphisms]
open scoped ZeroObject
instance hasZeroObject : HasZeroObject (DifferentialObject S C) where
zero := ⟨{ obj := 0, d := 0 },
{ unique_to := fun X => ⟨⟨⟨{ f := 0 }⟩, fun f => by ext⟩⟩,
unique_from := fun X => ⟨⟨⟨{ f := 0 }⟩, fun f => by ext⟩⟩ }⟩
#align category_theory.differential_object.has_zero_object CategoryTheory.DifferentialObject.hasZeroObject
end DifferentialObject
namespace DifferentialObject
variable (S : Type*) [AddMonoidWithOne S]
variable (C : Type (u + 1)) [LargeCategory C] [ConcreteCategory C] [HasZeroMorphisms C]
variable [HasShift C S]
instance concreteCategoryOfDifferentialObjects : ConcreteCategory (DifferentialObject S C) where
forget := forget S C ⋙ CategoryTheory.forget C
#align category_theory.differential_object.concrete_category_of_differential_objects CategoryTheory.DifferentialObject.concreteCategoryOfDifferentialObjects
instance : HasForget₂ (DifferentialObject S C) C where
forget₂ := forget S C
end DifferentialObject
/-! The category of differential objects itself has a shift functor. -/
namespace DifferentialObject
variable {S : Type*} [AddCommGroupWithOne S] (C : Type u) [Category.{v} C]
variable [HasZeroMorphisms C] [HasShift C S]
noncomputable section
/-- The shift functor on `DifferentialObject S C`. -/
@[simps]
def shiftFunctor (n : S) : DifferentialObject S C ⥤ DifferentialObject S C where
obj X :=
{ obj := X.obj⟦n⟧
d := X.d⟦n⟧' ≫ (shiftComm _ _ _).hom
d_squared := by
rw [Functor.map_comp, Category.assoc, shiftComm_hom_comp_assoc, ← Functor.map_comp_assoc,
X.d_squared, Functor.map_zero, zero_comp] }
map f :=
{ f := f.f⟦n⟧'
comm := by
dsimp
erw [Category.assoc, shiftComm_hom_comp, ← Functor.map_comp_assoc, f.comm,
Functor.map_comp_assoc]
rfl }
map_id X := by ext1; dsimp; rw [Functor.map_id]
map_comp f g := by ext1; dsimp; rw [Functor.map_comp]
#align category_theory.differential_object.shift_functor CategoryTheory.DifferentialObject.shiftFunctor
/-- The shift functor on `DifferentialObject S C` is additive. -/
@[simps!]
nonrec def shiftFunctorAdd (m n : S) :
shiftFunctor C (m + n) ≅ shiftFunctor C m ⋙ shiftFunctor C n := by
refine NatIso.ofComponents (fun X => mkIso (shiftAdd X.obj _ _) ?_) (fun f => ?_)
· dsimp
rw [← cancel_epi ((shiftFunctorAdd C m n).inv.app X.obj)]
simp only [Category.assoc, Iso.inv_hom_id_app_assoc]
erw [← NatTrans.naturality_assoc]
dsimp
simp only [Functor.map_comp, Category.assoc,
shiftFunctorComm_hom_app_comp_shift_shiftFunctorAdd_hom_app 1 m n X.obj,
Iso.inv_hom_id_app_assoc]
· ext; dsimp; exact NatTrans.naturality _ _
#align category_theory.differential_object.shift_functor_add CategoryTheory.DifferentialObject.shiftFunctorAdd
section
/-- The shift by zero is naturally isomorphic to the identity. -/
@[simps!]
def shiftZero : shiftFunctor C (0 : S) ≅ 𝟭 (DifferentialObject S C) := by
refine NatIso.ofComponents (fun X => mkIso ((shiftFunctorZero C S).app X.obj) ?_) (fun f => ?_)
· erw [← NatTrans.naturality]
dsimp
simp only [shiftFunctorZero_hom_app_shift, Category.assoc]
· aesop_cat
#align category_theory.differential_object.shift_zero CategoryTheory.DifferentialObject.shiftZero
end
instance : HasShift (DifferentialObject S C) S :=
hasShiftMk _ _
{ F := shiftFunctor C
zero := shiftZero C
add := shiftFunctorAdd C
assoc_hom_app := fun m₁ m₂ m₃ X => by
ext1
convert shiftFunctorAdd_assoc_hom_app m₁ m₂ m₃ X.obj
dsimp [shiftFunctorAdd']
simp
zero_add_hom_app := fun n X => by
ext1
convert shiftFunctorAdd_zero_add_hom_app n X.obj
simp
add_zero_hom_app := fun n X => by
ext1
convert shiftFunctorAdd_add_zero_hom_app n X.obj
simp }
end
end DifferentialObject
end CategoryTheory