Skip to content

Commit dd46575

Browse files
committed
chore(CategoryTheory/Limits): make Pi.mapIso a def (#38368)
Currently, `simp` unfolds `Pi.mapIso` which makes the general (co)limit API leak through. We also fix `Sigma.mapIso`, `Pi.map` and `Sigma.map`.
1 parent c1e30e1 commit dd46575

8 files changed

Lines changed: 50 additions & 56 deletions

File tree

Mathlib/CategoryTheory/Limits/Constructions/Filtered.lean

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,7 @@ def liftToFinsetColimIso : liftToFinset C α ⋙ colim ≅ colim :=
161161
ext J
162162
simp only [liftToFinset_obj_obj]
163163
ext j
164-
simp only [liftToFinset, ι_colimMap_assoc, liftToFinsetObj_obj, Discrete.functor_obj_eq_as,
165-
Discrete.natTrans_app, liftToFinsetColimIso_aux, liftToFinsetColimIso_aux_assoc,
166-
ι_colimMap])
164+
simp [liftToFinset, liftToFinsetColimIso_aux, liftToFinsetColimIso_aux_assoc])
167165

168166
end
169167

@@ -273,7 +271,7 @@ def liftToFinsetEvaluationIso (I : Finset (Discrete α)) :
273271
liftToFinset C α ⋙ (evaluation _ _).obj ⟨I⟩ ≅
274272
(Functor.whiskeringLeft _ _ _).obj (Discrete.functor (·.val)) ⋙ lim (J := Discrete I) :=
275273
NatIso.ofComponents (fun _ => HasLimit.isoOfNatIso (Discrete.natIso fun _ => Iso.refl _))
276-
fun _ => by dsimp; ext; simp
274+
fun _ => by dsimp; ext; simp [Pi.map]
277275

278276
end ProductsFromFiniteCofiltered
279277

Mathlib/CategoryTheory/Limits/FormalCoproducts/Cech.lean

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,7 @@ lemma mapPower_comp (U : FormalCoproduct.{w} C) {α β γ : Type t}
142142
· cat_disch
143143
· dsimp
144144
ext
145-
dsimp
146-
simp only [Category.comp_id, Category.assoc, Pi.lift_π]
147-
apply Pi.lift_π
145+
simp [Function.comp_def]
148146

149147
set_option backward.isDefEq.respectTransparency false in
150148
@[reassoc]
@@ -155,9 +153,7 @@ lemma mapPower_powerMap {U V : FormalCoproduct.{w} C} (f : U ⟶ V)
155153
· cat_disch
156154
· dsimp
157155
ext
158-
simp only [Function.comp_apply, limit.lift_map, Cone.postcompose, Fan.mk_pt, Category.comp_id,
159-
Category.assoc, limit.lift_π, Fan.mk_π_app, Pi.map_π]
160-
apply limit.lift_π
156+
simp [Function.comp_def]
161157

162158
set_option backward.isDefEq.respectTransparency false in
163159
@[reassoc (attr := simp)]

Mathlib/CategoryTheory/Limits/Shapes/Biproducts.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -611,9 +611,9 @@ instance biproduct.map_epi {f g : J → C} [HasBiproduct f] [HasBiproduct g] (p
611611
have : biproduct.map p =
612612
(biproduct.isoCoproduct _).hom ≫ Sigma.map p ≫ (biproduct.isoCoproduct _).inv := by
613613
ext
614-
simp only [map_π, isoCoproduct_hom, isoCoproduct_inv, Category.assoc, ι_desc_assoc,
615-
ι_colimMap_assoc, Discrete.functor_obj_eq_as, Discrete.natTrans_app, colimit.ι_desc_assoc,
616-
Cofan.mk_pt, Cofan.mk_ι_app, ι_π, ι_π_assoc]
614+
simp only [map_π, ι_π_assoc, isoCoproduct_hom, isoCoproduct_inv, Category.assoc, ι_desc_assoc,
615+
Sigma.ι_map_assoc, colimit.ι_desc_assoc, Discrete.functor_obj_eq_as, Cofan.mk_pt,
616+
Cofan.mk_ι_app, ι_π]
617617
split
618618
all_goals simp_all
619619
rw [this]

Mathlib/CategoryTheory/Limits/Shapes/Products.lean

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -325,13 +325,13 @@ def Cofan.isColimitTrans {X : α → C} (c : Cofan X) (hc : IsColimit c)
325325
/-- Construct a morphism between categorical products (indexed by the same type)
326326
from a family of morphisms between the factors.
327327
-/
328-
abbrev Pi.map {f g : β → C} [HasProduct f] [HasProduct g] (p : ∀ b, f b ⟶ g b) : ∏ᶜ f ⟶ ∏ᶜ g :=
328+
def Pi.map {f g : β → C} [HasProduct f] [HasProduct g] (p : ∀ b, f b ⟶ g b) : ∏ᶜ f ⟶ ∏ᶜ g :=
329329
limMap (Discrete.natTrans fun X => p X.as)
330330

331331
set_option backward.isDefEq.respectTransparency false in
332-
@[reassoc (attr := simp high), elementwise nosimp]
332+
@[reassoc (attr := simp), elementwise nosimp]
333333
lemma Pi.map_π {f g : β → C} [HasProduct f] [HasProduct g] (p : ∀ b, f b ⟶ g b) (b : β) :
334-
Pi.map p ≫ Pi.π g b = Pi.π f b ≫ p b := by simp
334+
Pi.map p ≫ Pi.π g b = Pi.π f b ≫ p b := by simp [Pi.map]
335335

336336
@[simp]
337337
lemma Pi.map_id {f : α → C} [HasProduct f] : Pi.map (fun a => 𝟙 (f a)) = 𝟙 (∏ᶜ f) := by
@@ -390,9 +390,19 @@ lemma Pi.map'_eq {f : α → C} {g : β → C} [HasProduct f] [HasProduct g] {p
390390
/-- Construct an isomorphism between categorical products (indexed by the same type)
391391
from a family of isomorphisms between the factors.
392392
-/
393-
abbrev Pi.mapIso {f g : β → C} [HasProductsOfShape β C] (p : ∀ b, f b ≅ g b) : ∏ᶜ f ≅ ∏ᶜ g :=
393+
def Pi.mapIso {f g : β → C} [HasProductsOfShape β C] (p : ∀ b, f b ≅ g b) : ∏ᶜ f ≅ ∏ᶜ g :=
394394
lim.mapIso (Discrete.natIso fun X => p X.as)
395395

396+
@[reassoc (attr := simp)]
397+
lemma Pi.mapIso_hom_π {f g : β → C} [HasProductsOfShape β C] (p : ∀ b, f b ≅ g b) (b : β) :
398+
(Pi.mapIso p).hom ≫ π _ _ = π _ _ ≫ (p b).hom :=
399+
limMap_π _ _
400+
401+
@[reassoc (attr := simp)]
402+
lemma Pi.mapIso_inv_π {f g : β → C} [HasProductsOfShape β C] (p : ∀ b, f b ≅ g b) (b : β) :
403+
(Pi.mapIso p).inv ≫ π _ _ = π _ _ ≫ (p b).inv :=
404+
limMap_π _ _
405+
396406
instance Pi.map_isIso {f g : β → C} [HasProductsOfShape β C] (p : ∀ b, f b ⟶ g b)
397407
[∀ b, IsIso <| p b] : IsIso <| Pi.map p :=
398408
inferInstanceAs (IsIso (Pi.mapIso (fun b ↦ asIso (p b))).hom)
@@ -445,14 +455,14 @@ end
445455
/-- Construct a morphism between categorical coproducts (indexed by the same type)
446456
from a family of morphisms between the factors.
447457
-/
448-
abbrev Sigma.map {f g : β → C} [HasCoproduct f] [HasCoproduct g] (p : ∀ b, f b ⟶ g b) :
458+
def Sigma.map {f g : β → C} [HasCoproduct f] [HasCoproduct g] (p : ∀ b, f b ⟶ g b) :
449459
∐ f ⟶ ∐ g :=
450460
colimMap (Discrete.natTrans fun X => p X.as)
451461

452462
set_option backward.isDefEq.respectTransparency false in
453-
@[reassoc (attr := simp high)]
463+
@[reassoc (attr := simp)]
454464
lemma Sigma.ι_map {f g : β → C} [HasCoproduct f] [HasCoproduct g] (p : ∀ b, f b ⟶ g b) (b : β) :
455-
Sigma.ι f b ≫ Sigma.map p = p b ≫ Sigma.ι g b := by simp
465+
Sigma.ι f b ≫ Sigma.map p = p b ≫ Sigma.ι g b := by simp [Sigma.map]
456466

457467
@[simp]
458468
lemma Sigma.map_id {f : α → C} [HasCoproduct f] : Sigma.map (fun a => 𝟙 (f a)) = 𝟙 (∐ f) := by
@@ -514,9 +524,19 @@ lemma Sigma.map'_eq {f : α → C} {g : β → C} [HasCoproduct f] [HasCoproduct
514524
/-- Construct an isomorphism between categorical coproducts (indexed by the same type)
515525
from a family of isomorphisms between the factors.
516526
-/
517-
abbrev Sigma.mapIso {f g : β → C} [HasCoproductsOfShape β C] (p : ∀ b, f b ≅ g b) : ∐ f ≅ ∐ g :=
527+
def Sigma.mapIso {f g : β → C} [HasCoproductsOfShape β C] (p : ∀ b, f b ≅ g b) : ∐ f ≅ ∐ g :=
518528
colim.mapIso (Discrete.natIso fun X => p X.as)
519529

530+
@[reassoc (attr := simp)]
531+
lemma Sigma.ι_mapIso_hom {f g : β → C} [HasCoproductsOfShape β C] (p : ∀ b, f b ≅ g b) (b : β) :
532+
ι _ _ ≫ (Sigma.mapIso p).hom = (p b).hom ≫ ι _ _ :=
533+
ι_colimMap _ _
534+
535+
@[reassoc (attr := simp)]
536+
lemma Sigma.ι_mapIso_inv {f g : β → C} [HasCoproductsOfShape β C] (p : ∀ b, f b ≅ g b) (b : β) :
537+
ι _ _ ≫ (Sigma.mapIso p).inv = (p b).inv ≫ ι _ _ :=
538+
ι_colimMap _ _
539+
520540
instance Sigma.map_isIso {f g : β → C} [HasCoproductsOfShape β C] (p : ∀ b, f b ⟶ g b)
521541
[∀ b, IsIso <| p b] : IsIso (Sigma.map p) :=
522542
inferInstanceAs (IsIso (Sigma.mapIso (fun b ↦ asIso (p b))).hom)

Mathlib/CategoryTheory/Limits/Shapes/SequentialProduct.lean

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ lemma functorMap_commSq_aux {n m k : ℕ} (h : n ≤ m) (hh : ¬(k < m)) :
8686
rw [this, op_comp, Functor.map_comp]
8787
slice_lhs 2 4 => rw [ih]
8888
simp only [Functor.ofOpSequence_obj, homOfLE_leOfHom, Functor.ofOpSequence_map_homOfLE_succ,
89-
functorMap, dite_eq_ite, limMap_π_assoc, Discrete.functor_obj_eq_as, Discrete.natTrans_app]
89+
functorMap, dite_eq_ite, Pi.map_π_assoc]
9090
split_ifs
9191
simp [dif_neg (by lia : ¬(k < m))]
9292

@@ -129,10 +129,9 @@ noncomputable def cone : Cone (Functor.ofOpSequence (functorMap f)) where
129129
f m ≫ eqToHom (functorObj_eq_neg h).symm) (fun n ↦ ?_)
130130
apply Limits.Pi.hom_ext
131131
intro m
132-
simp only [Functor.const_obj_obj, Functor.ofOpSequence_obj, homOfLE_leOfHom,
133-
Functor.const_obj_map, Category.id_comp, limMap_π, Discrete.functor_obj_eq_as,
134-
Discrete.natTrans_app, Functor.ofOpSequence_map_homOfLE_succ, functorMap, Category.assoc,
135-
limMap_π_assoc]
132+
simp only [Functor.const_obj_obj, dite_eq_ite, Functor.ofOpSequence_obj, homOfLE_leOfHom,
133+
Functor.const_obj_map, Category.id_comp, Pi.map_π, Functor.ofOpSequence_map_homOfLE_succ,
134+
functorMap, Category.assoc, Pi.map_π_assoc]
136135
split
137136
· simp [dif_pos (by lia : m < n + 1)]
138137
· split
@@ -147,16 +146,14 @@ set_option backward.isDefEq.respectTransparency false in
147146
lemma cone_π_app_comp_Pi_π_pos (m n : ℕ) (h : n < m) : (cone f).π.app ⟨m⟩ ≫
148147
Pi.π (fun i ↦ if _ : i < m then M i else N i) n =
149148
Pi.π _ n ≫ eqToHom (functorObj_eq_pos h).symm := by
150-
simp only [Functor.const_obj_obj, dite_eq_ite, Functor.ofOpSequence_obj, cone_π_app, limMap_π,
151-
Discrete.functor_obj_eq_as, Discrete.natTrans_app]
149+
simp only [Functor.const_obj_obj, dite_eq_ite, Functor.ofOpSequence_obj, cone_π_app, Pi.map_π]
152150
rw [dif_pos h]
153151

154152
set_option backward.isDefEq.respectTransparency false in
155153
@[reassoc]
156154
lemma cone_π_app_comp_Pi_π_neg (m n : ℕ) (h : ¬(n < m)) : (cone f).π.app ⟨m⟩ ≫ Pi.π _ n =
157155
Pi.π _ n ≫ f n ≫ eqToHom (functorObj_eq_neg h).symm := by
158-
simp only [Functor.const_obj_obj, dite_eq_ite, Functor.ofOpSequence_obj, cone_π_app, limMap_π,
159-
Discrete.functor_obj_eq_as, Discrete.natTrans_app]
156+
simp only [Functor.const_obj_obj, dite_eq_ite, Functor.ofOpSequence_obj, cone_π_app, Pi.map_π]
160157
rw [dif_neg h]
161158

162159
set_option backward.isDefEq.respectTransparency false in
@@ -196,8 +193,7 @@ noncomputable def isLimit : IsLimit (cone f) where
196193
rw [dif_pos h, dif_pos (by lia)]
197194
rw [← eqToHom_trans h₁ h₂]
198195
slice_lhs 2 4 => rw [ih (by lia)]
199-
simp only [functorMap, dite_eq_ite, Pi.π, limMap_π_assoc, Discrete.functor_obj_eq_as,
200-
Discrete.natTrans_app]
196+
simp only [functorMap, dite_eq_ite, Pi.π, Pi.map_π_assoc]
201197
split_ifs
202198
rw [dif_pos (by lia)]
203199
simp

Mathlib/CategoryTheory/SmallObject/Construction.lean

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,9 +255,7 @@ lemma functorMap_comm :
255255
functorObjLeft f πX ≫ functorMapTgt f τ =
256256
functorMapSrc f τ ≫ functorObjLeft f πY := by
257257
ext ⟨i, t, b, w⟩
258-
simp only [ι_colimMap_assoc, Discrete.natTrans_app, ι_colimMap,
259-
ι_functorMapTgt f τ i t b w _ rfl,
260-
ι_functorMapSrc_assoc f τ i t b w _ rfl]
258+
simp [ι_functorMapTgt f τ i t b w _ rfl, ι_functorMapSrc_assoc f τ i t b w _ rfl]
261259

262260
variable [HasPushout (functorObjTop f πX) (functorObjLeft f πX)]
263261
[HasPushout (functorObjTop f πY) (functorObjLeft f πY)]

Mathlib/CategoryTheory/Triangulated/Basic.lean

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -368,10 +368,6 @@ def productTriangle.π (j : J) :
368368
hom₁ := Pi.π _ j
369369
hom₂ := Pi.π _ j
370370
hom₃ := Pi.π _ j
371-
comm₃ := by
372-
dsimp
373-
rw [← piComparison_comp_π, assoc, IsIso.inv_hom_id_assoc]
374-
simp only [limMap_π, Discrete.natTrans_app]
375371

376372
/-- The fan given by `productTriangle T`. -/
377373
@[simp]
@@ -411,9 +407,7 @@ lemma productTriangle.zero₃₁ [HasZeroMorphisms C]
411407
change _ ≫ (Pi.lift (fun j => Pi.π _ j ≫ (T j).mor₁))⟦(1 : ℤ)⟧' = 0
412408
rw [assoc, ← cancel_mono (piComparison _ _), zero_comp, assoc, assoc]
413409
ext j
414-
simp only [map_lift_piComparison, assoc, limit.lift_π, Fan.mk_π_app, zero_comp,
415-
Functor.map_comp, ← piComparison_comp_π_assoc, IsIso.inv_hom_id_assoc,
416-
limMap_π_assoc, Discrete.natTrans_app, h j, comp_zero]
410+
simp [h j]
417411

418412
end
419413

Mathlib/Topology/Sheaves/SheafCondition/EqualizerProducts.lean

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -144,15 +144,11 @@ def diagram.isoOfIso (α : F ≅ G) : diagram F U ≅ diagram.{v'} G U :=
144144
rintro ⟨⟩ ⟨⟩ ⟨⟩
145145
· simp
146146
· dsimp
147-
ext
148-
simp only [leftRes, limit.lift_map, limit.lift_π, Cone.postcompose_obj_π,
149-
NatTrans.comp_app, Fan.mk_π_app, Discrete.natIso_hom_app, Iso.app_hom, Category.assoc,
150-
NatTrans.naturality, limMap_π_assoc]
147+
refine Pi.hom_ext _ _ fun b ↦ ?_
148+
simp [leftRes]
151149
· dsimp [diagram]
152-
ext
153-
simp only [rightRes, limit.lift_map, limit.lift_π, Cone.postcompose_obj_π,
154-
NatTrans.comp_app, Fan.mk_π_app, Discrete.natIso_hom_app, Iso.app_hom, Category.assoc,
155-
NatTrans.naturality, limMap_π_assoc]
150+
refine Pi.hom_ext _ _ fun b ↦ ?_
151+
simp [rightRes]
156152
· simp)
157153

158154
set_option backward.isDefEq.respectTransparency false in
@@ -166,13 +162,9 @@ def fork.isoOfIso (α : F ≅ G) :
166162
fapply Fork.ext
167163
· apply α.app
168164
· dsimp
169-
ext
165+
refine Pi.hom_ext _ _ fun b ↦ ?_
170166
dsimp only [Fork.ι]
171-
-- Ugh, `simp` can't unfold abbreviations.
172-
simp only [res, diagram.isoOfIso, piOpens.isoOfIso, Cone.postcompose_obj_π,
173-
NatTrans.comp_app, fork_π_app_walkingParallelPair_zero, NatIso.ofComponents_inv_app,
174-
Functor.mapIso_inv, lim_map, limit.lift_map, Category.assoc, limit.lift_π, Fan.mk_π_app,
175-
Discrete.natIso_inv_app, Iso.app_inv, NatTrans.naturality, Iso.hom_inv_id_app_assoc]
167+
simp [res, diagram.isoOfIso]
176168

177169
end SheafConditionEqualizerProducts
178170

0 commit comments

Comments
 (0)