Skip to content

Commit dc6387b

Browse files
committed
refactor(CategoryTheory/Shift): export Functor.CommShift.commShiftIso (#31504)
The isomorphism of commutation with shifts `Functor.CommShift.iso` is renamed `Functor.CommShift.commShiftIso` and exported as `Functor.commShiftIso` (which was a definition previously). This allows to generate a few equational lemmas automatically. A few `erw` are also removed.
1 parent 9e5cdbf commit dc6387b

File tree

11 files changed

+79
-112
lines changed

11 files changed

+79
-112
lines changed

Mathlib/Algebra/Homology/HomotopyCategory/Shift.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,14 +231,14 @@ def mapCochainComplexShiftIso (n : ℤ) :
231231

232232
instance commShiftMapCochainComplex :
233233
(F.mapHomologicalComplex (ComplexShape.up ℤ)).CommShift ℤ where
234-
iso := F.mapCochainComplexShiftIso
235-
zero := by
234+
commShiftIso := F.mapCochainComplexShiftIso
235+
commShiftIso_zero := by
236236
ext
237237
rw [CommShift.isoZero_hom_app]
238238
dsimp
239239
simp only [CochainComplex.shiftFunctorZero_inv_app_f, CochainComplex.shiftFunctorZero_hom_app_f,
240240
HomologicalComplex.XIsoOfEq, eqToIso, eqToHom_map, eqToHom_trans, eqToHom_refl]
241-
add := fun a b => by
241+
commShiftIso_add := fun a b => by
242242
ext
243243
rw [CommShift.isoAdd_hom_app]
244244
dsimp

Mathlib/CategoryTheory/Shift/Adjunction.lean

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -227,17 +227,15 @@ namespace CommShift
227227

228228

229229
/-- Constructor for `Adjunction.CommShift`. -/
230-
lemma mk' (h : NatTrans.CommShift adj.unit A) :
230+
lemma mk' (_ : NatTrans.CommShift adj.unit A) :
231231
adj.CommShift A where
232232
commShift_counit := ⟨fun a ↦ by
233233
ext
234234
simp only [Functor.comp_obj, Functor.id_obj, NatTrans.comp_app,
235235
Functor.commShiftIso_comp_hom_app, Functor.whiskerRight_app, assoc, Functor.whiskerLeft_app,
236236
Functor.commShiftIso_id_hom_app, comp_id]
237237
refine (compatibilityCounit_of_compatibilityUnit adj _ _ (fun X ↦ ?_) _).symm
238-
simpa only [NatTrans.comp_app,
239-
Functor.commShiftIso_id_hom_app, Functor.whiskerRight_app, id_comp,
240-
Functor.commShiftIso_comp_hom_app] using congr_app (h.shift_comm a) X⟩
238+
simpa [Functor.commShiftIso_comp_hom_app] using NatTrans.shift_app_comm adj.unit a X⟩
241239

242240
variable [adj.CommShift A]
243241

@@ -370,15 +368,15 @@ open RightAdjointCommShift in
370368
Given an adjunction `F ⊣ G` and a `CommShift` structure on `F`, this constructs
371369
the unique compatible `CommShift` structure on `G`.
372370
-/
373-
@[simps]
371+
@[simps -isSimp]
374372
noncomputable def rightAdjointCommShift [F.CommShift A] : G.CommShift A where
375-
iso a := iso adj a
376-
zero := by
373+
commShiftIso a := iso adj a
374+
commShiftIso_zero := by
377375
refine CommShift.compatibilityUnit_unique_right adj (F.commShiftIso 0) _ _
378376
(compatibilityUnit_iso adj 0) ?_
379377
rw [F.commShiftIso_zero]
380378
exact CommShift.compatibilityUnit_isoZero adj
381-
add a b := by
379+
commShiftIso_add a b := by
382380
refine CommShift.compatibilityUnit_unique_right adj (F.commShiftIso (a + b)) _ _
383381
(compatibilityUnit_iso adj (a + b)) ?_
384382
rw [F.commShiftIso_add]
@@ -454,15 +452,15 @@ open LeftAdjointCommShift in
454452
Given an adjunction `F ⊣ G` and a `CommShift` structure on `G`, this constructs
455453
the unique compatible `CommShift` structure on `F`.
456454
-/
457-
@[simps]
455+
@[simps -isSimp]
458456
noncomputable def leftAdjointCommShift [G.CommShift A] : F.CommShift A where
459-
iso a := iso adj a
460-
zero := by
457+
commShiftIso a := iso adj a
458+
commShiftIso_zero := by
461459
refine CommShift.compatibilityUnit_unique_left adj _ _ (G.commShiftIso 0)
462460
(compatibilityUnit_iso adj 0) ?_
463461
rw [G.commShiftIso_zero]
464462
exact CommShift.compatibilityUnit_isoZero adj
465-
add a b := by
463+
commShiftIso_add a b := by
466464
refine CommShift.compatibilityUnit_unique_left adj _ _ (G.commShiftIso (a + b))
467465
(compatibilityUnit_iso adj (a + b)) ?_
468466
rw [G.commShiftIso_add]

Mathlib/CategoryTheory/Shift/CommShift.lean

Lines changed: 29 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -104,24 +104,25 @@ end CommShift
104104
/-- A functor `F` commutes with the shift by a monoid `A` if it is equipped with
105105
commutation isomorphisms with the shifts by all `a : A`, and these isomorphisms
106106
satisfy coherence properties with respect to `0 : A` and the addition in `A`. -/
107-
class CommShift where
107+
class CommShift (F : C ⥤ D) (A : Type*) [AddMonoid A] [HasShift C A] [HasShift D A] where
108108
/-- The commutation isomorphisms for all `a`-shifts this functor is equipped with -/
109-
iso (a : A) : shiftFunctor C a ⋙ F ≅ F ⋙ shiftFunctor D a
110-
zero : iso 0 = CommShift.isoZero F A := by cat_disch
111-
add (a b : A) : iso (a + b) = CommShift.isoAdd (iso a) (iso b) := by cat_disch
109+
commShiftIso (F) (a : A) : shiftFunctor C a ⋙ F ≅ F ⋙ shiftFunctor D a
110+
commShiftIso_zero (F) (A) : commShiftIso 0 = CommShift.isoZero F A := by cat_disch
111+
commShiftIso_add (F) (a b : A) :
112+
commShiftIso (a + b) = CommShift.isoAdd (commShiftIso a) (commShiftIso b) := by cat_disch
112113

113114
variable {A}
114115

116+
export CommShift (commShiftIso commShiftIso_zero commShiftIso_add)
117+
118+
@[deprecated (since := "2025-11-11")] alias CommShift.iso := commShiftIso
119+
@[deprecated (since := "2025-11-11")] alias CommShift.zero := commShiftIso_zero
120+
@[deprecated (since := "2025-11-11")] alias CommShift.add := commShiftIso_add
121+
115122
section
116123

117124
variable [F.CommShift A]
118125

119-
/-- If a functor `F` commutes with the shift by `A` (i.e. `[F.CommShift A]`), then
120-
`F.commShiftIso a` is the given isomorphism `shiftFunctor C a ⋙ F ≅ F ⋙ shiftFunctor D a`. -/
121-
def commShiftIso (a : A) :
122-
shiftFunctor C a ⋙ F ≅ F ⋙ shiftFunctor D a :=
123-
CommShift.iso a
124-
125126
-- Note: The following two lemmas are introduced in order to have more proofs work `by simp`.
126127
-- Indeed, `simp only [(F.commShiftIso a).hom.naturality f]` would almost never work because
127128
-- of the compositions of functors which appear in both the source and target of
@@ -139,23 +140,12 @@ lemma commShiftIso_inv_naturality {X Y : C} (f : X ⟶ Y) (a : A) :
139140
(F.commShiftIso a).inv.app X ≫ F.map (f⟦a⟧') :=
140141
(F.commShiftIso a).inv.naturality f
141142

142-
variable (A)
143-
144-
lemma commShiftIso_zero :
145-
F.commShiftIso (0 : A) = CommShift.isoZero F A :=
146-
CommShift.zero
147-
143+
variable (A) in
148144
set_option linter.docPrime false in
149145
lemma commShiftIso_zero' (a : A) (h : a = 0) :
150146
F.commShiftIso a = CommShift.isoZero' F A a h := by
151147
subst h; rw [CommShift.isoZero'_eq_isoZero, commShiftIso_zero]
152148

153-
variable {A}
154-
155-
lemma commShiftIso_add (a b : A) :
156-
F.commShiftIso (a + b) = CommShift.isoAdd (F.commShiftIso a) (F.commShiftIso b) :=
157-
CommShift.add a b
158-
159149
lemma commShiftIso_add' {a b c : A} (h : a + b = c) :
160150
F.commShiftIso c = CommShift.isoAdd' h (F.commShiftIso a) (F.commShiftIso b) := by
161151
subst h
@@ -166,19 +156,21 @@ end
166156
namespace CommShift
167157

168158
variable (C) in
159+
@[simps! -isSimp commShiftIso_hom_app commShiftIso_inv_app]
169160
instance id : CommShift (𝟭 C) A where
170-
iso := fun _ => rightUnitor _ ≪≫ (leftUnitor _).symm
161+
commShiftIso := fun _ => rightUnitor _ ≪≫ (leftUnitor _).symm
171162

163+
@[simps! -isSimp commShiftIso_hom_app commShiftIso_inv_app]
172164
instance comp [F.CommShift A] [G.CommShift A] : (F ⋙ G).CommShift A where
173-
iso a := (Functor.associator _ _ _).symm ≪≫ isoWhiskerRight (F.commShiftIso a) _ ≪≫
165+
commShiftIso a := (Functor.associator _ _ _).symm ≪≫ isoWhiskerRight (F.commShiftIso a) _ ≪≫
174166
Functor.associator _ _ _ ≪≫ isoWhiskerLeft _ (G.commShiftIso a) ≪≫
175167
(Functor.associator _ _ _).symm
176-
zero := by
168+
commShiftIso_zero := by
177169
ext X
178170
dsimp
179171
simp only [id_comp, comp_id, commShiftIso_zero, isoZero_hom_app, ← Functor.map_comp_assoc,
180172
assoc, Iso.inv_hom_id_app, id_obj, comp_map, comp_obj]
181-
add := fun a b => by
173+
commShiftIso_add := fun a b => by
182174
ext X
183175
dsimp
184176
simp only [commShiftIso_add, isoAdd_hom_app]
@@ -188,23 +180,12 @@ instance comp [F.CommShift A] [G.CommShift A] : (F ⋙ G).CommShift A where
188180

189181
end CommShift
190182

191-
@[simp]
192-
lemma commShiftIso_id_hom_app (a : A) (X : C) :
193-
(commShiftIso (𝟭 C) a).hom.app X = 𝟙 _ := comp_id _
194-
195-
@[simp]
196-
lemma commShiftIso_id_inv_app (a : A) (X : C) :
197-
(commShiftIso (𝟭 C) a).inv.app X = 𝟙 _ := comp_id _
198-
199-
lemma commShiftIso_comp_hom_app [F.CommShift A] [G.CommShift A] (a : A) (X : C) :
200-
(commShiftIso (F ⋙ G) a).hom.app X =
201-
G.map ((commShiftIso F a).hom.app X) ≫ (commShiftIso G a).hom.app (F.obj X) := by
202-
simp [commShiftIso, CommShift.iso]
183+
alias commShiftIso_id_hom_app := CommShift.id_commShiftIso_hom_app
184+
alias commShiftIso_id_inv_app := CommShift.id_commShiftIso_inv_app
185+
alias commShiftIso_comp_hom_app := CommShift.comp_commShiftIso_hom_app
186+
alias commShiftIso_comp_inv_app := CommShift.comp_commShiftIso_inv_app
203187

204-
lemma commShiftIso_comp_inv_app [F.CommShift A] [G.CommShift A] (a : A) (X : C) :
205-
(commShiftIso (F ⋙ G) a).inv.app X =
206-
(commShiftIso G a).inv.app (F.obj X) ≫ G.map ((commShiftIso F a).inv.app X) := by
207-
simp [commShiftIso, CommShift.iso]
188+
attribute [simp] commShiftIso_id_hom_app commShiftIso_id_inv_app
208189

209190
variable {B}
210191

@@ -354,16 +335,13 @@ variable {C D E : Type*} [Category C] [Category D]
354335

355336
/-- If `e : F ≅ G` is an isomorphism of functors and if `F` commutes with the
356337
shift, then `G` also commutes with the shift. -/
338+
@[simps! -isSimp commShiftIso_hom_app commShiftIso_inv_app]
357339
def ofIso : G.CommShift A where
358-
iso a := isoWhiskerLeft _ e.symm ≪≫ F.commShiftIso a ≪≫ isoWhiskerRight e _
359-
zero := by
340+
commShiftIso a := isoWhiskerLeft _ e.symm ≪≫ F.commShiftIso a ≪≫ isoWhiskerRight e _
341+
commShiftIso_zero := by
360342
ext X
361-
simp only [comp_obj, F.commShiftIso_zero A, Iso.trans_hom, isoWhiskerLeft_hom,
362-
Iso.symm_hom, isoWhiskerRight_hom, NatTrans.comp_app, whiskerLeft_app,
363-
isoZero_hom_app, whiskerRight_app, assoc]
364-
erw [← e.inv.naturality_assoc, ← NatTrans.naturality,
365-
e.inv_hom_id_app_assoc]
366-
add a b := by
343+
simp [F.commShiftIso_zero, ← NatTrans.naturality]
344+
commShiftIso_add a b := by
367345
ext X
368346
simp only [comp_obj, F.commShiftIso_add, Iso.trans_hom, isoWhiskerLeft_hom,
369347
Iso.symm_hom, isoWhiskerRight_hom, NatTrans.comp_app, whiskerLeft_app,
@@ -376,9 +354,7 @@ lemma ofIso_compatibility :
376354
letI := ofIso e A
377355
NatTrans.CommShift e.hom A := by
378356
letI := ofIso e A
379-
refine ⟨fun a => ?_⟩
380-
dsimp [commShiftIso, ofIso]
381-
rw [← whiskerLeft_comp_assoc, e.hom_inv_id, whiskerLeft_id', id_comp]
357+
exact ⟨fun a => by ext; simp [ofIso_commShiftIso_hom_app]⟩
382358

383359
end CommShift
384360

Mathlib/CategoryTheory/Shift/Induced.lean

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -209,20 +209,21 @@ noncomputable def Functor.CommShift.ofInduced :
209209
F.CommShift A := by
210210
letI := HasShift.induced F A s i
211211
exact
212-
{ iso := fun a => (i a).symm
213-
zero := by
212+
{ commShiftIso := fun a => (i a).symm
213+
commShiftIso_zero := by
214214
ext X
215215
dsimp
216216
simp only [isoZero_hom_app, shiftFunctorZero_inv_app_obj_of_induced,
217217
← F.map_comp_assoc, Iso.hom_inv_id_app, F.map_id, Category.id_comp]
218-
add := fun a b => by
218+
commShiftIso_add := fun a b => by
219219
ext X
220220
dsimp
221221
simp only [isoAdd_hom_app, Iso.symm_hom, shiftFunctorAdd_inv_app_obj_of_induced,
222222
shiftFunctor_of_induced]
223-
erw [← Functor.map_comp_assoc, Iso.inv_hom_id_app, Functor.map_id,
224-
Category.id_comp, Iso.inv_hom_id_app_assoc, ← F.map_comp_assoc, Iso.hom_inv_id_app,
225-
F.map_id, Category.id_comp] }
223+
rw [← Functor.map_comp_assoc, Iso.inv_hom_id_app]
224+
dsimp
225+
rw [Functor.map_id, Category.id_comp, Iso.inv_hom_id_app_assoc,
226+
← F.map_comp_assoc, Iso.hom_inv_id_app, F.map_id, Category.id_comp] }
226227

227228
lemma Functor.commShiftIso_eq_ofInduced (a : A) :
228229
letI := HasShift.induced F A s i

Mathlib/CategoryTheory/Shift/Localization.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,8 @@ end commShiftOfLocalization
167167
is induced by a functor which commutes with the shift, then
168168
this functor commutes with the shift. -/
169169
noncomputable def commShiftOfLocalization : F'.CommShift A where
170-
iso := commShiftOfLocalization.iso L W F F'
171-
zero := by
170+
commShiftIso := commShiftOfLocalization.iso L W F F'
171+
commShiftIso_zero := by
172172
ext1
173173
apply natTrans_ext L W
174174
intro X
@@ -179,7 +179,7 @@ noncomputable def commShiftOfLocalization : F'.CommShift A where
179179
dsimp
180180
simp only [← Functor.map_comp_assoc, ← Functor.map_comp,
181181
Iso.inv_hom_id_app, id_obj, map_id, Category.id_comp, Iso.hom_inv_id_app_assoc]
182-
add a b := by
182+
commShiftIso_add a b := by
183183
ext1
184184
apply natTrans_ext L W
185185
intro X

Mathlib/CategoryTheory/Shift/Opposite.lean

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,7 @@ with the naive shift: `shiftFunctor (OppositeShift C A) n` is `(shiftFunctor C n
7777
@[nolint unusedArguments]
7878
def OppositeShift (A : Type*) [AddMonoid A] [HasShift C A] := Cᵒᵖ
7979

80-
instance : Category (OppositeShift C A) := by
81-
dsimp only [OppositeShift]
82-
infer_instance
80+
instance : Category (OppositeShift C A) := inferInstanceAs (Category Cᵒᵖ)
8381

8482
noncomputable instance : HasShift (OppositeShift C A) A :=
8583
hasShiftMk Cᵒᵖ A (HasShift.mkShiftCoreOp C A)
@@ -88,9 +86,8 @@ instance [HasZeroObject C] : HasZeroObject (OppositeShift C A) := by
8886
dsimp only [OppositeShift]
8987
infer_instance
9088

91-
instance [Preadditive C] : Preadditive (OppositeShift C A) := by
92-
dsimp only [OppositeShift]
93-
infer_instance
89+
instance [Preadditive C] : Preadditive (OppositeShift C A) :=
90+
inferInstanceAs (Preadditive Cᵒᵖ)
9491

9592
instance [Preadditive C] (n : A) [(shiftFunctor C n).Additive] :
9693
(shiftFunctor (OppositeShift C A) n).Additive := by
@@ -166,15 +163,15 @@ Given a `CommShift` structure on `F`, this is the corresponding `CommShift` stru
166163
-/
167164
noncomputable instance commShiftOp [CommShift F A] :
168165
CommShift (OppositeShift.functor A F) A where
169-
iso a := (NatIso.op (F.commShiftIso a)).symm
170-
zero := by
166+
commShiftIso a := (NatIso.op (F.commShiftIso a)).symm
167+
commShiftIso_zero := by
171168
rw [commShiftIso_zero]
172169
ext
173170
simp only [op_obj, comp_obj, Iso.symm_hom, NatIso.op_inv, NatTrans.op_app,
174171
CommShift.isoZero_inv_app, op_comp, CommShift.isoZero_hom_app]
175172
erw [oppositeShiftFunctorZero_inv_app, oppositeShiftFunctorZero_hom_app]
176173
rfl
177-
add a b := by
174+
commShiftIso_add a b := by
178175
rw [commShiftIso_add]
179176
ext
180177
simp only [op_obj, comp_obj, Iso.symm_hom, NatIso.op_inv, NatTrans.op_app,
@@ -189,18 +186,18 @@ lemma commShiftOp_iso_eq [CommShift F A] (a : A) :
189186
Given a `CommShift` structure on `OppositeShift.functor F` (for the naive shifts on the opposite
190187
categories), this is the corresponding `CommShift` structure on `F`.
191188
-/
192-
@[simps]
189+
@[simps -isSimp]
193190
noncomputable def commShiftUnop
194191
[CommShift (OppositeShift.functor A F) A] : CommShift F A where
195-
iso a := NatIso.removeOp ((OppositeShift.functor A F).commShiftIso a).symm
196-
zero := by
192+
commShiftIso a := NatIso.removeOp ((OppositeShift.functor A F).commShiftIso a).symm
193+
commShiftIso_zero := by
197194
rw [commShiftIso_zero]
198195
ext
199196
simp only [comp_obj, NatIso.removeOp_hom, Iso.symm_hom, NatTrans.removeOp_app, op_obj,
200197
CommShift.isoZero_inv_app, unop_comp, CommShift.isoZero_hom_app]
201198
erw [oppositeShiftFunctorZero_hom_app, oppositeShiftFunctorZero_inv_app]
202199
rfl
203-
add a b := by
200+
commShiftIso_add a b := by
204201
rw [commShiftIso_add]
205202
ext
206203
simp only [comp_obj, NatIso.removeOp_hom, Iso.symm_hom, NatTrans.removeOp_app, op_obj,
@@ -244,7 +241,7 @@ instance : NatTrans.CommShift (OppositeShift.natIsoId C A).hom A where
244241
shift_comm _ := by
245242
ext
246243
dsimp [OppositeShift.natIsoId, Functor.commShiftOp_iso_eq]
247-
simp only [Functor.commShiftIso_id_hom_app, Functor.comp_obj, Functor.id_obj, Functor.map_id,
244+
simp only [Functor.commShiftIso_id_hom_app, Functor.map_id,
248245
comp_id, Functor.commShiftIso_id_inv_app, CategoryTheory.op_id, id_comp]
249246
rfl
250247

Mathlib/CategoryTheory/Shift/Pullback.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,16 +161,16 @@ namespace Functor
161161
commutes with their pullbacks by an additive map `φ`.
162162
-/
163163
noncomputable instance commShiftPullback : (PullbackShift.functor φ F).CommShift A where
164-
iso a := isoWhiskerRight (pullbackShiftIso C φ a (φ a) rfl) F ≪≫
164+
commShiftIso a := isoWhiskerRight (pullbackShiftIso C φ a (φ a) rfl) F ≪≫
165165
F.commShiftIso (φ a) ≪≫ isoWhiskerLeft _ (pullbackShiftIso D φ a (φ a) rfl).symm
166-
zero := by
166+
commShiftIso_zero := by
167167
ext
168168
dsimp
169169
simp only [F.commShiftIso_zero' (A := B) (φ 0) (by rw [map_zero]), CommShift.isoZero'_hom_app,
170170
assoc, CommShift.isoZero_hom_app, pullbackShiftFunctorZero'_hom_app, map_comp,
171171
pullbackShiftFunctorZero'_inv_app]
172172
rfl
173-
add _ _ := by
173+
commShiftIso_add _ _ := by
174174
ext
175175
simp only [PullbackShift.functor, comp_obj, Iso.trans_hom, isoWhiskerRight_hom,
176176
isoWhiskerLeft_hom, Iso.symm_hom, NatTrans.comp_app, whiskerRight_app, whiskerLeft_app,

0 commit comments

Comments
 (0)