Skip to content

Commit 675f2fd

Browse files
committed
feat: (co/bi/)products unchanged by reindexing and isomorphism of factors (#6259)
Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
1 parent b76454f commit 675f2fd

File tree

4 files changed

+95
-4
lines changed

4 files changed

+95
-4
lines changed

Mathlib/Algebra/Homology/DifferentialObject.lean

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,7 @@ def dgoToHomologicalComplex :
100100
comm' := fun i j h => by
101101
dsimp at h ⊢
102102
subst h
103-
simp [Category.comp_id, eqToHom_refl, dif_pos rfl, Category.assoc,
104-
eqToHom_f']
103+
simp only [dite_true, Category.assoc, eqToHom_f']
105104
-- Porting note: this `rw` used to be part of the `simp`.
106105
have : f.f i ≫ Y.d i = X.d i ≫ f.f _ := (congr_fun f.comm i).symm
107106
rw [reassoc_of% this] }
@@ -146,7 +145,7 @@ to the category of homological complexes in `V`.
146145
-/
147146
@[simps]
148147
def dgoEquivHomologicalComplex :
149-
DifferentialObject ℤ (GradedObjectWithShift b V) ≌
148+
DifferentialObject ℤ (GradedObjectWithShift b V) ≌
150149
HomologicalComplex V (ComplexShape.up' b) where
151150
functor := dgoToHomologicalComplex b V
152151
inverse := homologicalComplexToDGO b V

Mathlib/CategoryTheory/EqToHom.lean

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,35 @@ theorem eqToHom_comp_iff {X X' Y : C} (p : X = X') (f : X ⟶ Y) (g : X' ⟶ Y)
6969
mpr := fun h => h ▸ by simp [whisker_eq _ h] }
7070
#align category_theory.eq_to_hom_comp_iff CategoryTheory.eqToHom_comp_iff
7171

72+
/-- We can push `eqToHom` to the left through families of morphisms. -/
73+
-- The simpNF linter incorrectly claims that this will never apply.
74+
-- https://github.com/leanprover-community/mathlib4/issues/5049
75+
@[reassoc (attr := simp, nolint simpNF)]
76+
theorem eqToHom_naturality {f g : β → C} (z : ∀ b, f b ⟶ g b) {j j' : β} (w : j = j') :
77+
z j ≫ eqToHom (by simp [w]) = eqToHom (by simp [w]) ≫ z j' := by
78+
cases w
79+
simp
80+
81+
/-- A variant on `eqToHom_naturality` that helps Lean identify the families `f` and `g`. -/
82+
-- The simpNF linter incorrectly claims that this will never apply.
83+
-- https://github.com/leanprover-community/mathlib4/issues/5049
84+
@[reassoc (attr := simp, nolint simpNF)]
85+
theorem eqToHom_iso_hom_naturality {f g : β → C} (z : ∀ b, f b ≅ g b) {j j' : β} (w : j = j') :
86+
(z j).hom ≫ eqToHom (by simp [w]) = eqToHom (by simp [w]) ≫ (z j').hom := by
87+
cases w
88+
simp
89+
90+
/-- A variant on `eqToHom_naturality` that helps Lean identify the families `f` and `g`. -/
91+
-- The simpNF linter incorrectly claims that this will never apply.
92+
-- https://github.com/leanprover-community/mathlib4/issues/5049
93+
@[reassoc (attr := simp, nolint simpNF)]
94+
theorem eqToHom_iso_inv_naturality {f g : β → C} (z : ∀ b, f b ≅ g b) {j j' : β} (w : j = j') :
95+
(z j).inv ≫ eqToHom (by simp [w]) = eqToHom (by simp [w]) ≫ (z j').inv := by
96+
cases w
97+
simp
98+
7299
/- Porting note: simpNF complains about this not reducing but it is clearly used
73-
in `congrArg_mrp_hom_left`. It has been no-linted. -/
100+
in `congrArg_mpr_hom_left`. It has been no-linted. -/
74101
/-- Reducible form of congrArg_mpr_hom_left -/
75102
@[simp, nolint simpNF]
76103
theorem congrArg_cast_hom_left {X Y Z : C} (p : X = Y) (q : Y ⟶ Z) :

Mathlib/CategoryTheory/Limits/Shapes/Biproducts.lean

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,53 @@ def biproduct.mapIso {f g : J → C} [HasBiproduct f] [HasBiproduct g] (p : ∀
583583
inv := biproduct.map fun b => (p b).inv
584584
#align category_theory.limits.biproduct.map_iso CategoryTheory.Limits.biproduct.mapIso
585585

586+
/-- Two biproducts which differ by an equivalence in the indexing type,
587+
and up to isomorphism in the factors, are isomorphic.
588+
589+
Unfortunately there are two natural ways to define each direction of this isomorphism
590+
(because it is true for both products and coproducts separately).
591+
We give the alternative definitions as lemmas below.
592+
-/
593+
@[simps]
594+
def biproduct.whisker_equiv {f : J → C} {g : K → C} (e : J ≃ K) (w : ∀ j, g (e j) ≅ f j)
595+
[HasBiproduct f] [HasBiproduct g] : ⨁ f ≅ ⨁ g where
596+
hom := biproduct.desc fun j => (w j).inv ≫ biproduct.ι g (e j)
597+
inv := biproduct.desc fun k => eqToHom (by simp) ≫ (w (e.symm k)).hom ≫ biproduct.ι f _
598+
599+
lemma biproduct.whisker_equiv_hom_eq_lift {f : J → C} {g : K → C} (e : J ≃ K)
600+
(w : ∀ j, g (e j) ≅ f j) [HasBiproduct f] [HasBiproduct g] :
601+
(biproduct.whisker_equiv e w).hom =
602+
biproduct.lift fun k => biproduct.π f (e.symm k) ≫ (w _).inv ≫ eqToHom (by simp) := by
603+
simp only [whisker_equiv_hom]
604+
ext k j
605+
by_cases h : k = e j
606+
· subst h
607+
simp
608+
· simp only [ι_desc_assoc, Category.assoc, ne_eq, lift_π]
609+
rw [biproduct.ι_π_ne, biproduct.ι_π_ne_assoc]
610+
· simp
611+
· rintro rfl
612+
simp at h
613+
· exact Ne.symm h
614+
615+
lemma biproduct.whisker_equiv_inv_eq_lift {f : J → C} {g : K → C} (e : J ≃ K)
616+
(w : ∀ j, g (e j) ≅ f j) [HasBiproduct f] [HasBiproduct g] :
617+
(biproduct.whisker_equiv e w).inv =
618+
biproduct.lift fun j => biproduct.π g (e j) ≫ (w j).hom := by
619+
simp only [whisker_equiv_inv]
620+
ext j k
621+
by_cases h : k = e j
622+
· subst h
623+
simp only [ι_desc_assoc, ← eqToHom_iso_hom_naturality_assoc w (e.symm_apply_apply j).symm,
624+
Equiv.symm_apply_apply, eqToHom_comp_ι, Category.assoc, bicone_ι_π_self, Category.comp_id,
625+
lift_π, bicone_ι_π_self_assoc]
626+
· simp only [ι_desc_assoc, Category.assoc, ne_eq, lift_π]
627+
rw [biproduct.ι_π_ne, biproduct.ι_π_ne_assoc]
628+
· simp
629+
· exact h
630+
· rintro rfl
631+
simp at h
632+
586633
instance (f : ι → Type _) (g : (i : ι) → (f i) → C)
587634
[∀ i, HasBiproduct (g i)] [HasBiproduct fun i => ⨁ g i] :
588635
HasBiproduct fun p : Σ i, f i => g p.1 p.2 where

Mathlib/CategoryTheory/Limits/Shapes/Products.lean

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,24 @@ abbrev Sigma.mapIso {f g : β → C} [HasCoproductsOfShape β C] (p : ∀ b, f b
260260
colim.mapIso (Discrete.natIso fun X => p X.as)
261261
#align category_theory.limits.sigma.map_iso CategoryTheory.Limits.Sigma.mapIso
262262

263+
/-- Two products which differ by an equivalence in the indexing type,
264+
and up to isomorphism in the factors, are isomorphic.
265+
-/
266+
@[simps]
267+
def Pi.whisker_equiv {f : J → C} {g : K → C} (e : J ≃ K) (w : ∀ j, g (e j) ≅ f j)
268+
[HasProduct f] [HasProduct g] : ∏ f ≅ ∏ g where
269+
hom := Pi.lift fun k => Pi.π f (e.symm k) ≫ (w _).inv ≫ eqToHom (by simp)
270+
inv := Pi.lift fun j => Pi.π g (e j) ≫ (w j).hom
271+
272+
/-- Two coproducts which differ by an equivalence in the indexing type,
273+
and up to isomorphism in the factors, are isomorphic.
274+
-/
275+
@[simps]
276+
def Sigma.whisker_equiv {f : J → C} {g : K → C} (e : J ≃ K) (w : ∀ j, g (e j) ≅ f j)
277+
[HasCoproduct f] [HasCoproduct g] : ∐ f ≅ ∐ g where
278+
hom := Sigma.desc fun j => (w j).inv ≫ Sigma.ι g (e j)
279+
inv := Sigma.desc fun k => eqToHom (by simp) ≫ (w (e.symm k)).hom ≫ Sigma.ι f _
280+
263281
instance (f : ι → Type _) (g : (i : ι) → (f i) → C)
264282
[∀ i, HasProduct (g i)] [HasProduct fun i => ∏ g i] :
265283
HasProduct fun p : Σ i, f i => g p.1 p.2 where

0 commit comments

Comments
 (0)