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

Commit 6876fa1

Browse files
committed
refactor(category_theory/shift): improve automation (#18670)
1 parent e8ac631 commit 6876fa1

File tree

7 files changed

+843
-785
lines changed

7 files changed

+843
-785
lines changed

src/category_theory/differential_object.lean

Lines changed: 38 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Scott Morrison
55
-/
66
import data.int.basic
7-
import category_theory.shift
7+
import category_theory.shift.basic
88
import category_theory.concrete_category.basic
99

1010
/-!
@@ -220,52 +220,67 @@ def shift_functor (n : ℤ) : differential_object C ⥤ differential_object C :=
220220
←functor.map_comp_assoc, X.d_squared, functor.map_zero, zero_comp] },
221221
map := λ X Y f,
222222
{ f := f.f⟦n⟧',
223-
comm' := by { dsimp, rw [category.assoc, shift_comm_hom_comp, ← functor.map_comp_assoc,
224-
f.comm, functor.map_comp_assoc], }, },
223+
comm' := begin
224+
dsimp,
225+
erw [category.assoc, shift_comm_hom_comp, ← functor.map_comp_assoc, f.comm,
226+
functor.map_comp_assoc],
227+
refl,
228+
end, },
225229
map_id' := by { intros X, ext1, dsimp, rw functor.map_id },
226230
map_comp' := by { intros X Y Z f g, ext1, dsimp, rw functor.map_comp } }
227231

228-
local attribute [simp] eq_to_hom_map
229-
local attribute [reducible] discrete.add_monoidal shift_comm
230-
231232
/-- The shift functor on `differential_object C` is additive. -/
232233
@[simps] def shift_functor_add (m n : ℤ) :
233234
shift_functor C (m + n) ≅ shift_functor C m ⋙ shift_functor C n :=
234235
begin
235236
refine nat_iso.of_components (λ X, mk_iso (shift_add X.X _ _) _) _,
236237
{ dsimp,
237-
-- This is just `simp, simp [eq_to_hom_map]`.
238-
simp_rw [category.assoc, obj_μ_inv_app, μ_inv_hom_app_assoc, functor.map_comp, obj_μ_app,
239-
category.assoc, μ_naturality_assoc, μ_inv_hom_app_assoc, obj_μ_inv_app, category.assoc,
240-
μ_naturalityₗ_assoc, μ_inv_hom_app_assoc, μ_inv_naturalityᵣ_assoc],
241-
simp only [eq_to_hom_map, eq_to_hom_app, eq_to_iso.hom, eq_to_hom_trans_assoc,
242-
eq_to_iso.inv], },
238+
rw [← cancel_epi ((shift_functor_add C m n).inv.app X.X)],
239+
simp only [category.assoc, iso.inv_hom_id_app_assoc],
240+
erw [← nat_trans.naturality_assoc],
241+
dsimp,
242+
simp only [functor.map_comp, category.assoc,
243+
shift_functor_comm_hom_app_comp_shift_shift_functor_add_hom_app 1 m n X.X,
244+
iso.inv_hom_id_app_assoc], },
243245
{ intros X Y f, ext, dsimp, exact nat_trans.naturality _ _ }
244246
end
245247

246-
local attribute [reducible] endofunctor_monoidal_category
247-
248248
section
249-
local attribute [instance] endofunctor_monoidal_category
250249

251250
/-- The shift by zero is naturally isomorphic to the identity. -/
252251
@[simps]
253-
def shift_ε : 𝟭 (differential_object C) ≅ shift_functor C 0 :=
252+
def shift_zero : shift_functor C 0 ≅ 𝟭 (differential_object C) :=
254253
begin
255-
refine nat_iso.of_components (λ X, mk_iso ((shift_monoidal_functor C ℤ).ε_iso.app X.X) _) _,
256-
{ dsimp, simp, dsimp, simp },
257-
{ introv, ext, dsimp, simp }
254+
refine nat_iso.of_components (λ X, mk_iso ((shift_functor_zero C ℤ).app X.X) _) _,
255+
{ erw [← nat_trans.naturality],
256+
dsimp,
257+
simp only [shift_functor_zero_hom_app_shift, category.assoc], },
258+
{ tidy, },
258259
end
259260

260261
end
261262

262-
local attribute [simp] eq_to_hom_map
263-
264263
instance : has_shift (differential_object C) ℤ :=
265264
has_shift_mk _ _
266265
{ F := shift_functor C,
267-
ε := shift_ε C,
268-
μ := λ m n, (shift_functor_add C m n).symm }
266+
zero := shift_zero C,
267+
add := shift_functor_add C,
268+
assoc_hom_app := λ m₁ m₂ m₃ X, begin
269+
ext1,
270+
convert shift_functor_add_assoc_hom_app m₁ m₂ m₃ X.X,
271+
dsimp [shift_functor_add'],
272+
simpa,
273+
end,
274+
zero_add_hom_app := λ n X, begin
275+
ext1,
276+
convert shift_functor_add_zero_add_hom_app n X.X,
277+
simpa,
278+
end,
279+
add_zero_hom_app := λ n X, begin
280+
ext1,
281+
convert shift_functor_add_add_zero_hom_app n X.X,
282+
simpa,
283+
end, }
269284

270285
end differential_object
271286

src/category_theory/graded_object.lean

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Authors: Scott Morrison
55
-/
66
import algebra.group_power.lemmas
77
import category_theory.pi.basic
8-
import category_theory.shift
8+
import category_theory.shift.basic
99
import category_theory.concrete_category.basic
1010

1111
/-!
@@ -106,11 +106,12 @@ instance has_shift {β : Type*} [add_comm_group β] (s : β) :
106106
has_shift (graded_object_with_shift s C) ℤ :=
107107
has_shift_mk _ _
108108
{ F := λ n, comap (λ _, C) $ λ (b : β), b + n • s,
109-
ε := (comap_id β (λ _, C)).symm ≪≫ (comap_eq C (by { ext, simp })),
110-
μ := λ m n, comap_comp _ _ _ ≪≫ comap_eq C (by { ext, simp [add_zsmul, add_comm] }),
111-
left_unitality := by { introv, ext, dsimp, simpa },
112-
right_unitality := by { introv, ext, dsimp, simpa },
113-
associativity := by { introv, ext, dsimp, simp } }
109+
zero := comap_eq C (by { ext, simp }) ≪≫ comap_id β (λ _, C),
110+
add := λ m n, comap_eq C (by { ext, simp [add_zsmul, add_comm], }) ≪≫
111+
(comap_comp _ _ _).symm,
112+
assoc_hom_app := λ m₁ m₂ m₃ X, by { ext, dsimp, simp, },
113+
zero_add_hom_app := λ n X, by { ext, dsimp, simpa, },
114+
add_zero_hom_app := λ n X, by { ext, dsimp, simpa, }, }
114115

115116
@[simp] lemma shift_functor_obj_apply {β : Type*} [add_comm_group β]
116117
(s : β) (X : β → C) (t : β) (n : ℤ) :

0 commit comments

Comments
 (0)