Skip to content

Commit cf53478

Browse files
JovanGerbjoelriou
andcommitted
feat(CategoryTheory/Limits/Cones): use to_dual (#35031)
This PR uses `to_dual` to generate `Cocone` from `Cone`. Notes: - Sadly, it is not possible to translate `cones : Cᵒᵖ ⥤ Type max u₁ v₃` and `cocones : C ⥤ Type max u₁ v₃` (and similarly `yoneda` and `coyoneda`), because one version has `ᵒᵖ` in the type and the other doesn't. To allow dualizing `Cone.extend`, I've inlined the definition of `Cone.extensions`. - This PR makes many changes in other files where `to_dual` tags were missing. Only the minimal necessary changes have been made. Those files may be extended with more `to_dual` tags in future PRs. - `Cone.extendIso` and `Cocone.extendIso` weren't compatible for `to_dual` because they were the other way around. I chose to swap the direction of the isomorphisms in `Cone.extendIso`. Similarly `precomposeEquivalence` and `postComposeEquivalence` weren't compatible. I chose to swap the direction of an isomorphism in `precomposeEquivalence`. These changes required a few adaptations in `Mathlib.CategoryTheory.Limits.IsLimit` and elsewhere. Co-authored-by: Joël Riou <37772949+joelriou@users.noreply.github.com>
1 parent fdab30b commit cf53478

File tree

12 files changed

+207
-525
lines changed

12 files changed

+207
-525
lines changed

Mathlib/CategoryTheory/Category/Basic.lean

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ class CategoryStruct (obj : Type u) : Type max u (v + 1) extends Quiver.{v} obj
127127
comp : ∀ {X Y Z : obj}, (X ⟶ Y) → (Y ⟶ Z) → (X ⟶ Z)
128128

129129
attribute [trans, to_dual self (reorder := X Z, 6 7)] CategoryStruct.comp
130+
attribute [to_dual self (reorder := comp (X Z, 4 5))] CategoryStruct.mk
130131

131132
initialize_simps_projections CategoryStruct (-toQuiver_Hom, -Hom)
132133

@@ -244,6 +245,15 @@ attribute [simp, grind _=_] Category.assoc
244245

245246
initialize_simps_projections Category (-Hom)
246247

248+
/-- `Category.mk'` is the dual of `Category.mk`, which we need for `to_dual`.
249+
Please avoid using this directly. -/
250+
@[to_dual existing mk]
251+
abbrev Category.mk' {obj : Type u} [CategoryStruct.{v} obj]
252+
(id_comp : ∀ {X Y : obj} (f : Y ⟶ X), f ≫ 𝟙 X = f)
253+
(comp_id : ∀ {X Y : obj} (f : Y ⟶ X), 𝟙 Y ≫ f = f)
254+
(assoc : ∀ {W X Y Z : obj} (f : X ⟶ W) (g : Y ⟶ X) (h : Z ⟶ Y), h ≫ g ≫ f = (h ≫ g) ≫ f) :
255+
Category.{v, u} obj where
256+
247257
example {C} [Category C] {X Y : C} (f : X ⟶ Y) : 𝟙 X ≫ f = f := by simp
248258
example {C} [Category C] {X Y : C} (f : X ⟶ Y) : f ≫ 𝟙 Y = f := by simp
249259

Mathlib/CategoryTheory/Equivalence.lean

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -403,35 +403,23 @@ functor. -/
403403
def funInvIdAssoc (e : C ≌ D) (F : C ⥤ E) : e.functor ⋙ e.inverse ⋙ F ≅ F :=
404404
(Functor.associator _ _ _).symm ≪≫ isoWhiskerRight e.unitIso.symm F ≪≫ F.leftUnitor
405405

406-
@[simp]
406+
@[to_dual (attr := simp) funInvIdAssoc_inv_app]
407407
theorem funInvIdAssoc_hom_app (e : C ≌ D) (F : C ⥤ E) (X : C) :
408408
(funInvIdAssoc e F).hom.app X = F.map (e.unitInv.app X) := by
409409
dsimp [funInvIdAssoc]
410410
simp
411411

412-
@[simp]
413-
theorem funInvIdAssoc_inv_app (e : C ≌ D) (F : C ⥤ E) (X : C) :
414-
(funInvIdAssoc e F).inv.app X = F.map (e.unit.app X) := by
415-
dsimp [funInvIdAssoc]
416-
simp
417-
418412
/-- Composing a functor with both functors of an equivalence yields a naturally isomorphic
419413
functor. -/
420414
def invFunIdAssoc (e : C ≌ D) (F : D ⥤ E) : e.inverse ⋙ e.functor ⋙ F ≅ F :=
421415
(Functor.associator _ _ _).symm ≪≫ isoWhiskerRight e.counitIso F ≪≫ F.leftUnitor
422416

423-
@[simp]
417+
@[to_dual (attr := simp) invFunIdAssoc_inv_app]
424418
theorem invFunIdAssoc_hom_app (e : C ≌ D) (F : D ⥤ E) (X : D) :
425419
(invFunIdAssoc e F).hom.app X = F.map (e.counit.app X) := by
426420
dsimp [invFunIdAssoc]
427421
simp
428422

429-
@[simp]
430-
theorem invFunIdAssoc_inv_app (e : C ≌ D) (F : D ⥤ E) (X : D) :
431-
(invFunIdAssoc e F).inv.app X = F.map (e.counitInv.app X) := by
432-
dsimp [invFunIdAssoc]
433-
simp
434-
435423
/-- If `C` is equivalent to `D`, then `C ⥤ E` is equivalent to `D ⥤ E`. -/
436424
@[simps! functor inverse unitIso_hom_app unitIso_inv_app counitIso_hom_app counitIso_inv_app]
437425
def congrLeft (e : C ≌ D) : C ⥤ E ≌ D ⥤ E where

Mathlib/CategoryTheory/Functor/Basic.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ attribute [simp] Functor.map_id Functor.map_comp
5757
attribute [grind =] Functor.map_id
5858
attribute [grind _=_] Functor.map_comp
5959
attribute [to_dual self] Functor.map Functor.map_comp
60+
attribute [to_dual self (reorder := map (X Y), map_comp (X Z, f g))] Functor.mk
6061

6162
-- Note: We manually add this lemma which could be generated by `reassoc`,
6263
-- since we will import this file into `Mathlib/Tactic/CategoryTheory/Reassoc.lean`.

Mathlib/CategoryTheory/Functor/FullyFaithful.lean

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,20 @@ namespace Functor
4545
class Full (F : C ⥤ D) : Prop where
4646
map_surjective {X Y : C} : Function.Surjective (F.map (X := X) (Y := Y))
4747

48+
attribute [to_dual self] Full.map_surjective Full.mk
49+
4850
/-- A functor `F : C ⥤ D` is faithful if for each `X Y : C`, `F.map` is injective. -/
4951
@[stacks 001C]
5052
class Faithful (F : C ⥤ D) : Prop where
5153
/-- `F.map` is injective for each `X Y : C`. -/
5254
map_injective : ∀ {X Y : C}, Function.Injective (F.map : (X ⟶ Y) → (F.obj X ⟶ F.obj Y)) := by
5355
cat_disch
5456

57+
attribute [to_dual self] Faithful.map_injective Faithful.mk
58+
5559
variable {X Y : C}
5660

57-
@[grind inj]
61+
@[grind inj, to_dual self]
5862
theorem map_injective (F : C ⥤ D) [Faithful F] :
5963
Function.Injective <| (F.map : (X ⟶ Y) → (F.obj X ⟶ F.obj Y)) :=
6064
Faithful.map_injective
@@ -72,10 +76,11 @@ theorem map_surjective (F : C ⥤ D) [Full F] :
7276
Full.map_surjective
7377

7478
/-- The choice of a preimage of a morphism under a full functor. -/
79+
@[to_dual self]
7580
noncomputable def preimage (F : C ⥤ D) [Full F] (f : F.obj X ⟶ F.obj Y) : X ⟶ Y :=
7681
(F.map_surjective f).choose
7782

78-
@[simp]
83+
@[simp, to_dual self]
7984
theorem map_preimage (F : C ⥤ D) [Full F] {X Y : C} (f : F.obj X ⟶ F.obj Y) :
8085
F.map (preimage F f) = f :=
8186
(F.map_surjective f).choose_spec

Mathlib/CategoryTheory/Functor/ReflectsIso/Basic.lean

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ class Functor.ReflectsIsomorphisms (F : C ⥤ D) : Prop where
3939
/-- For any `f`, if `F.map f` is an iso, then so was `f`. -/
4040
reflects : ∀ {A B : C} (f : A ⟶ B) [IsIso (F.map f)], IsIso f
4141

42+
attribute [to_dual self] Functor.ReflectsIsomorphisms.reflects Functor.ReflectsIsomorphisms.mk
43+
4244
/-- If `F` reflects isos and `F.map f` is an iso, then `f` is an iso. -/
4345
theorem isIso_of_reflects_iso {A B : C} (f : A ⟶ B) (F : C ⥤ D) [IsIso (F.map f)]
4446
[F.ReflectsIsomorphisms] : IsIso f :=

Mathlib/CategoryTheory/Iso.lean

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -272,16 +272,16 @@ instance Iso.isIso_inv (e : X ≅ Y) : IsIso e.inv := e.symm.isIso_hom
272272

273273
open IsIso
274274

275-
/-- Reinterpret a morphism `f` with an `IsIso f` instance as an `Iso`. -/
276-
@[to_dual none]
275+
/-- Reinterpret a morphism `f : X ⟶ Y` with an `IsIso f` instance as `X ≅ Y`. -/
276+
@[to_dual asIso' /-- Reinterpret a morphism `f : X ⟶ Y` with an `IsIso f` instance as `Y ≅ X`. -/]
277277
noncomputable def asIso (f : X ⟶ Y) [IsIso f] : X ≅ Y :=
278278
⟨f, inv f, hom_inv_id f, inv_hom_id f⟩
279279

280-
@[simp, to_dual none]
280+
@[to_dual (attr := simp) asIso'_hom]
281281
theorem asIso_hom (f : X ⟶ Y) [IsIso f] : (asIso f).hom = f :=
282282
rfl
283283

284-
@[simp, to_dual none]
284+
@[to_dual (attr := simp) asIso'_inv]
285285
theorem asIso_inv (f : X ⟶ Y) [IsIso f] : (asIso f).inv = inv f :=
286286
rfl
287287

0 commit comments

Comments
 (0)