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

Commit 8d24a1f

Browse files
jcommelinerdOne
andcommitted
refactor(category_theory/shift): make shifts more flexible (#10573)
Co-authored-by: Andrew Yang <the.erd.one@gmail.com> Co-authored-by: Andrew Yang <36414270+erdOne@users.noreply.github.com> Co-authored-by: erd1 <the.erd.one@gmail.com>
1 parent 0b80d0c commit 8d24a1f

File tree

7 files changed

+493
-205
lines changed

7 files changed

+493
-205
lines changed

src/algebra/homology/differential_object.lean

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ by { cases h, simp }
5454

5555
variables (b V)
5656

57+
local attribute [reducible] graded_object.has_shift
58+
5759
/--
5860
The functor from differential graded objects to homological complexes.
5961
-/
@@ -63,20 +65,23 @@ def dgo_to_homological_complex :
6365
homological_complex V (complex_shape.up' b) :=
6466
{ obj := λ X,
6567
{ X := λ i, X.X i,
66-
d := λ i j, if h : i + b = j then X.d i ≫ eq_to_hom (congr_arg X.X h) else 0,
67-
shape' := λ i j w, by { dsimp at w, rw dif_neg w, },
68+
d := λ i j, if h : i + b = j then
69+
X.d i ≫ X.X_eq_to_hom (show i + (1 : ℤ) • b = j, by simp [h]) else 0,
70+
shape' := λ i j w, by { dsimp at w, convert dif_neg w },
6871
d_comp_d' := λ i j k hij hjk, begin
6972
dsimp at hij hjk, substs hij hjk,
70-
simp only [category.comp_id, eq_to_hom_refl, dif_pos rfl],
71-
exact congr_fun (X.d_squared) i,
73+
have : X.d i ≫ X.d _ = _ := (congr_fun X.d_squared i : _),
74+
reassoc! this,
75+
simp [this],
7276
end },
7377
map := λ X Y f,
7478
{ f := f.f,
7579
comm' := λ i j h, begin
7680
dsimp at h ⊢,
7781
subst h,
78-
simp only [category.comp_id, eq_to_hom_refl, dif_pos rfl],
79-
exact (congr_fun f.comm i).symm
82+
have : f.f i ≫ Y.d i = X.d i ≫ f.f (i + 1 • b) := (congr_fun f.comm i).symm,
83+
reassoc! this,
84+
simp only [category.comp_id, eq_to_hom_refl, dif_pos rfl, this, category.assoc, eq_to_hom_f]
8085
end, } }
8186

8287
/--
@@ -88,7 +93,7 @@ def homological_complex_to_dgo :
8893
differential_object (graded_object_with_shift b V) :=
8994
{ obj := λ X,
9095
{ X := λ i, X.X i,
91-
d := λ i, X.d i (i + b),
96+
d := λ i, X.d i (i + 1b),
9297
d_squared' := by { ext i, dsimp, simp, } },
9398
map := λ X Y f,
9499
{ f := f.f,
@@ -117,13 +122,15 @@ nat_iso.of_components (λ X,
117122
{ f := λ i, 𝟙 (X.X i),
118123
comm' := λ i j h, begin
119124
dsimp at h ⊢, subst h,
120-
simp only [category.comp_id, category.id_comp, dif_pos rfl, eq_to_hom_refl],
125+
delta homological_complex_to_dgo,
126+
simp,
121127
end },
122128
inv :=
123129
{ f := λ i, 𝟙 (X.X i),
124130
comm' := λ i j h, begin
125131
dsimp at h ⊢, subst h,
126-
simp only [category.comp_id, category.id_comp, dif_pos rfl, eq_to_hom_refl],
132+
delta homological_complex_to_dgo,
133+
simp,
127134
end }, }) (by tidy)
128135

129136
/--

src/category_theory/differential_object.lean

Lines changed: 52 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ namespace category_theory
2525

2626
variables (C : Type u) [category.{v} C]
2727

28-
variables [has_zero_morphisms C] [has_shift C]
28+
-- TODO: generaize to `has_shift C A` for an arbitrary `[add_monoid A]` `[has_one A]`.
29+
variables [has_zero_morphisms C] [has_shift C ℤ]
2930

3031
/--
3132
A differential object in a category with zero morphisms and a shift is
@@ -126,7 +127,7 @@ from an isomorphism of the underlying objects that commutes with the differentia
126127
(f : X.X ≅ Y.X) (hf : X.d ≫ f.hom⟦1⟧' = f.hom ≫ Y.d) : X ≅ Y :=
127128
{ hom := ⟨f.hom, hf⟩,
128129
inv := ⟨f.inv, by { dsimp, rw [← functor.map_iso_inv, iso.comp_inv_eq, category.assoc,
129-
iso.eq_inv_comp, functor.map_iso_hom, hf], congr }⟩,
130+
iso.eq_inv_comp, functor.map_iso_hom, hf] }⟩,
130131
hom_inv_id' := by { ext1, dsimp, exact f.hom_inv_id },
131132
inv_hom_id' := by { ext1, dsimp, exact f.inv_hom_id } }
132133

@@ -136,20 +137,21 @@ namespace functor
136137

137138
universes v' u'
138139
variables (D : Type u') [category.{v'} D]
139-
variables [has_zero_morphisms D] [has_shift D]
140+
variables [has_zero_morphisms D] [has_shift D]
140141

141142
/--
142143
A functor `F : C ⥤ D` which commutes with shift functors on `C` and `D` and preserves zero morphisms
143144
can be lifted to a functor `differential_object C ⥤ differential_object D`.
144145
-/
145146
@[simps]
146-
def map_differential_object (F : C ⥤ D) (η : (shift C).functor.comp F ⟶ F.comp (shift D).functor)
147+
def map_differential_object (F : C ⥤ D)
148+
(η : (shift_functor C (1:ℤ)).comp F ⟶ F.comp (shift_functor D (1:ℤ)))
147149
(hF : ∀ c c', F.map (0 : c ⟶ c') = 0) :
148150
differential_object C ⥤ differential_object D :=
149151
{ obj := λ X, { X := F.obj X.X,
150152
d := F.map X.d ≫ η.app X.X,
151153
d_squared' := begin
152-
dsimp, rw [functor.map_comp, ← functor.comp_map F (shift D).functor],
154+
rw [functor.map_comp, ← functor.comp_map F (shift_functor D (1:ℤ))],
153155
slice_lhs 2 3 { rw [← η.naturality X.d] },
154156
rw [functor.comp_map],
155157
slice_lhs 1 2 { rw [← F.map_comp, X.d_squared, hF] },
@@ -158,7 +160,7 @@ def map_differential_object (F : C ⥤ D) (η : (shift C).functor.comp F ⟶ F.c
158160
map := λ X Y f, { f := F.map f.f,
159161
comm' := begin
160162
dsimp,
161-
slice_lhs 2 3 { rw [← functor.comp_map F (shift D).functor, ← η.naturality f.f] },
163+
slice_lhs 2 3 { rw [← functor.comp_map F (shift_functor D (1:ℤ)), ← η.naturality f.f] },
162164
slice_lhs 1 2 { rw [functor.comp_map, ← F.map_comp, f.comm, F.map_comp] },
163165
rw [category.assoc]
164166
end },
@@ -175,7 +177,7 @@ namespace differential_object
175177

176178
variables (C : Type u) [category.{v} C]
177179

178-
variables [has_zero_object C] [has_zero_morphisms C] [has_shift C]
180+
variables [has_zero_object C] [has_zero_morphisms C] [has_shift C]
179181

180182
open_locale zero_object
181183

@@ -191,7 +193,7 @@ end differential_object
191193
namespace differential_object
192194

193195
variables (C : Type (u+1)) [large_category C] [concrete_category C]
194-
[has_zero_morphisms C] [has_shift C]
196+
[has_zero_morphisms C] [has_shift C]
195197

196198
instance concrete_category_of_differential_objects :
197199
concrete_category (differential_object C) :=
@@ -206,132 +208,54 @@ end differential_object
206208
namespace differential_object
207209

208210
variables (C : Type u) [category.{v} C]
209-
variables [has_zero_morphisms C] [has_shift C]
211+
variables [has_zero_morphisms C] [has_shift C ℤ]
212+
213+
noncomputable theory
210214

211215
/-- The shift functor on `differential_object C`. -/
212216
@[simps]
213-
def shift_functor : differential_object C ⥤ differential_object C :=
217+
def shift_functor (n : ℤ) : differential_object C ⥤ differential_object C :=
214218
{ obj := λ X,
215-
{ X := X.X⟦1⟧,
216-
d := X.d⟦1⟧',
217-
d_squared' := begin
218-
dsimp,
219-
rw [←functor.map_comp, X.d_squared, is_equivalence_preserves_zero_morphisms],
220-
end },
221-
map := λ X Y f,
222-
{ f := f.f⟦1⟧',
223-
comm' := begin dsimp, rw [←functor.map_comp, f.comm, ←functor.map_comp], end, }, }
224-
225-
/-- The inverse shift functor on `differential C`, at the level of objects. -/
226-
@[simps]
227-
def shift_inverse_obj : differential_object C → differential_object C :=
228-
λ X,
229-
{ X := X.X⟦-1⟧,
230-
d := X.d⟦-1⟧' ≫ (shift C).unit_inv.app X.X ≫ (shift C).counit_inv.app X.X,
231-
d_squared' := begin
232-
dsimp,
233-
rw functor.map_comp,
234-
slice_lhs 3 4 { erw ←(shift C).counit_inv.naturality, },
235-
slice_lhs 2 3 { erw ←(shift C).unit_inv.naturality, },
236-
slice_lhs 1 2 { erw [←functor.map_comp, X.d_squared], },
237-
simp,
238-
end, }
239-
240-
/-- The inverse shift functor on `differential C`. -/
241-
@[simps]
242-
def shift_inverse : differential_object C ⥤ differential_object C :=
243-
{ obj := shift_inverse_obj C,
219+
{ X := X.X⟦n⟧,
220+
d := X.d⟦n⟧' ≫ (shift_comm _ _ _).hom,
221+
d_squared' := by rw [functor.map_comp, category.assoc, shift_comm_hom_comp_assoc,
222+
←functor.map_comp_assoc, X.d_squared, is_equivalence_preserves_zero_morphisms, zero_comp] },
244223
map := λ X Y f,
245-
{ f := f.f⟦-1⟧',
246-
comm' := begin
247-
dsimp,
248-
slice_lhs 3 4 { erw ←(shift C).counit_inv.naturality, },
249-
slice_lhs 2 3 { erw ←(shift C).unit_inv.naturality, },
250-
slice_lhs 1 2 { erw [←functor.map_comp, f.comm, functor.map_comp], },
251-
rw [category.assoc, category.assoc],
252-
end, }, }.
253-
254-
/-- The unit for the shift functor on `differential_object C`. -/
255-
@[simps]
256-
def shift_unit : 𝟭 (differential_object C) ⟶ shift_functor C ⋙ shift_inverse C :=
257-
{ app := λ X,
258-
{ f := (shift C).unit.app X.X,
259-
comm' := begin
260-
dsimp,
261-
slice_rhs 1 2 { erw ←(shift C).unit.naturality, },
262-
simp only [category.comp_id, functor.id_map, iso.hom_inv_id_app,
263-
category.assoc, equivalence.counit_inv_app_functor],
264-
end, }, }
265-
266-
/-- The inverse of the unit for the shift functor on `differential_object C`. -/
224+
{ f := f.f⟦n⟧',
225+
comm' := by { dsimp, rw [category.assoc, shift_comm_hom_comp, ← functor.map_comp_assoc,
226+
f.comm, functor.map_comp_assoc], }, },
227+
map_id' := by { intros X, ext1, dsimp, rw functor.map_id },
228+
map_comp' := by { intros X Y Z f g, ext1, dsimp, rw functor.map_comp } }
229+
230+
local attribute [instance] endofunctor_monoidal_category discrete.add_monoidal
231+
local attribute [reducible] endofunctor_monoidal_category discrete.add_monoidal shift_comm
232+
233+
/-- The shift functor on `differential_object C` is additive. -/
234+
@[simps] def shift_functor_add (m n : ℤ) :
235+
shift_functor C (m + n) ≅ shift_functor C m ⋙ shift_functor C n :=
236+
begin
237+
refine nat_iso.of_components (λ X, mk_iso (shift_add X.X _ _) _) _,
238+
{ dsimp,
239+
simp only [obj_μ_app, μ_naturality_assoc, μ_naturalityₗ_assoc, μ_inv_hom_app_assoc,
240+
category.assoc, obj_μ_inv_app, functor.map_comp, μ_inv_naturalityᵣ_assoc],
241+
simp [opaque_eq_to_iso] },
242+
{ intros X Y f, ext, dsimp, exact nat_trans.naturality _ _ }
243+
end
244+
245+
/-- The shift by zero is naturally isomorphic to the identity. -/
267246
@[simps]
268-
def shift_unit_inv : shift_functor C ⋙ shift_inverse C ⟶ 𝟭 (differential_object C) :=
269-
{ app := λ X,
270-
{ f := (shift C).unit_inv.app X.X,
271-
comm' := begin
272-
dsimp,
273-
slice_rhs 1 2 { erw ←(shift C).unit_inv.naturality, },
274-
rw [equivalence.counit_inv_app_functor],
275-
slice_lhs 3 4 { rw ←functor.map_comp, },
276-
simp only [iso.hom_inv_id_app, functor.comp_map, iso.hom_inv_id_app_assoc,
277-
nat_iso.cancel_nat_iso_inv_left, equivalence.inv_fun_map, category.assoc],
278-
dsimp,
279-
rw category_theory.functor.map_id,
280-
end, }, }.
281-
282-
/-- The unit isomorphism for the shift functor on `differential_object C`. -/
283-
@[simps]
284-
def shift_unit_iso : 𝟭 (differential_object C) ≅ shift_functor C ⋙ shift_inverse C :=
285-
{ hom := shift_unit C,
286-
inv := shift_unit_inv C, }.
287-
288-
/-- The counit for the shift functor on `differential_object C`. -/
289-
@[simps]
290-
def shift_counit : shift_inverse C ⋙ shift_functor C ⟶ 𝟭 (differential_object C) :=
291-
{ app := λ X,
292-
{ f := (shift C).counit.app X.X,
293-
comm' :=
294-
begin
295-
dsimp,
296-
slice_rhs 1 2 { erw ←(shift C).counit.naturality, },
297-
rw [(shift C).functor.map_comp, (shift C).functor.map_comp],
298-
slice_lhs 3 4 { erw [←functor.map_comp, iso.inv_hom_id_app, functor.map_id], },
299-
erw equivalence.counit_app_functor,
300-
rw category.comp_id,
301-
refl,
302-
end, }, }
303-
304-
/-- The inverse of the counit for the shift functor on `differential_object C`. -/
305-
@[simps]
306-
def shift_counit_inv : 𝟭 (differential_object C) ⟶ shift_inverse C ⋙ shift_functor C :=
307-
{ app := λ X,
308-
{ f := (shift C).counit_inv.app X.X,
309-
comm' :=
310-
begin
311-
dsimp,
312-
rw [(shift C).functor.map_comp, (shift C).functor.map_comp],
313-
slice_rhs 1 2 { erw ←(shift C).counit_inv.naturality, },
314-
rw ←equivalence.counit_app_functor,
315-
slice_rhs 2 3 { rw iso.inv_hom_id_app, },
316-
rw category.id_comp,
317-
refl,
318-
end, }, }
319-
320-
/-- The counit isomorphism for the shift functor on `differential_object C`. -/
321-
@[simps]
322-
def shift_counit_iso : shift_inverse C ⋙ shift_functor C ≅ 𝟭 (differential_object C) :=
323-
{ hom := shift_counit C,
324-
inv := shift_counit_inv C, }
325-
326-
/--
327-
The category of differential objects in `C` itself has a shift functor.
328-
-/
329-
instance : has_shift (differential_object C) :=
330-
{ shift :=
331-
{ functor := shift_functor C,
332-
inverse := shift_inverse C,
333-
unit_iso := shift_unit_iso C,
334-
counit_iso := shift_counit_iso C, } }
247+
def shift_ε : 𝟭 (differential_object C) ≅ shift_functor C 0 :=
248+
begin
249+
refine nat_iso.of_components (λ X, mk_iso ((shift_monoidal_functor C ℤ).ε_iso.app X.X) _) _,
250+
{ dsimp, simp, dsimp, simp },
251+
{ introv, ext, dsimp, simp }
252+
end
253+
254+
instance : has_shift (differential_object C) ℤ :=
255+
has_shift_mk _ _
256+
{ F := shift_functor C,
257+
ε := shift_ε C,
258+
μ := λ m n, (shift_functor_add C m n).symm }
335259

336260
end differential_object
337261

src/category_theory/graded_object.lean

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ begin
8383
end
8484

8585
@[simp] lemma eq_to_hom_apply {β : Type w} {X Y : Π b : β, C} (h : X = Y) (b : β) :
86-
(eq_to_hom h : X ⟶ Y) b = eq_to_hom (by subst h) :=
87-
by { subst h, refl }
86+
(eq_to_hom h : X ⟶ Y) b = eq_to_hom (by subst h) :=
87+
by { subst h, refl }
8888

8989
/--
9090
The equivalence between β-graded objects and γ-graded objects,
@@ -101,21 +101,26 @@ def comap_equiv {β γ : Type w} (e : β ≃ γ) :
101101

102102
end
103103

104+
local attribute [reducible, instance] endofunctor_monoidal_category discrete.add_monoidal
105+
104106
instance has_shift {β : Type*} [add_comm_group β] (s : β) :
105-
has_shift (graded_object_with_shift s C) :=
106-
{ shift := comap_equiv C
107-
{ to_fun := λ b, b-s,
108-
inv_fun := λ b, b+s,
109-
left_inv := λ x, (by simp),
110-
right_inv := λ x, (by simp), } }
111-
112-
@[simp] lemma shift_functor_obj_apply {β : Type*} [add_comm_group β] (s : β) (X : β → C) (t : β) :
113-
(shift (graded_object_with_shift s C)).functor.obj X t = X (t + s) :=
107+
has_shift (graded_object_with_shift s C) ℤ :=
108+
has_shift_mk _ _
109+
{ F := λ n, comap (λ _, C) $ λ (b : β), b + n • s,
110+
ε := (comap_id β (λ _, C)).symm ≪≫ (comap_eq C (by { ext, simp })),
111+
μ := λ m n, comap_comp _ _ _ ≪≫ comap_eq C (by { ext, simp [add_zsmul, add_comm] }),
112+
left_unitality := by { introv, ext, dsimp, simpa },
113+
right_unitality := by { introv, ext, dsimp, simpa },
114+
associativity := by { introv, ext, dsimp, simp } }
115+
116+
@[simp] lemma shift_functor_obj_apply {β : Type*} [add_comm_group β]
117+
(s : β) (X : β → C) (t : β) (n : ℤ) :
118+
(shift_functor (graded_object_with_shift s C) n).obj X t = X (t + n • s) :=
114119
rfl
115120

116121
@[simp] lemma shift_functor_map_apply {β : Type*} [add_comm_group β] (s : β)
117-
{X Y : graded_object_with_shift s C} (f : X ⟶ Y) (t : β) :
118-
(shift (graded_object_with_shift s C)).functor.map f t = f (t + s) :=
122+
{X Y : graded_object_with_shift s C} (f : X ⟶ Y) (t : β) (n : ℤ) :
123+
(shift_functor (graded_object_with_shift s C) n).map f t = f (t + n • s) :=
119124
rfl
120125

121126
instance has_zero_morphisms [has_zero_morphisms C] (β : Type w) :

0 commit comments

Comments
 (0)