Documentation

Mathlib.CategoryTheory.EqToHom

Morphisms from equations between objects. #

When working categorically, sometimes one encounters an equation h : X = Y between objects.

Your initial aversion to this is natural and appropriate: you're in for some trouble, and if there is another way to approach the problem that won't rely on this equality, it may be worth pursuing.

You have two options:

  1. Use the equality h as one normally would in Lean (e.g. using rw and subst). This may immediately cause difficulties, because in category theory everything is dependently typed, and equations between objects quickly lead to nasty goals with eq.rec.
  2. Promote h to a morphism using eqToHom h : X ⟶ Y, or eqToIso h : X ≅ Y.

This file introduces various simp lemmas which in favourable circumstances result in the various eqToHom morphisms to drop out at the appropriate moment!

def CategoryTheory.eqToHom {C : Type u₁} [CategoryTheory.Category.{v₁, u₁} C] {X : C} {Y : C} (p : X = Y) :
X Y

An equality X = Y gives us a morphism X ⟶ Y.

It is typically better to use this, rather than rewriting by the equality then using 𝟙 _ which usually leads to dependent type theory hell.

Equations
Instances For
    @[simp]
    theorem CategoryTheory.eqToHom_naturality_assoc {C : Type u₁} [CategoryTheory.Category.{v₁, u₁} C] {β : Sort u_1} {f : βC} {g : βC} (z : (b : β) → f b g b) {j : β} {j' : β} (w : j = j') {Z : C} (h : g j' Z) :
    @[simp]
    theorem CategoryTheory.eqToHom_naturality {C : Type u₁} [CategoryTheory.Category.{v₁, u₁} C] {β : Sort u_1} {f : βC} {g : βC} (z : (b : β) → f b g b) {j : β} {j' : β} (w : j = j') :

    We can push eqToHom to the left through families of morphisms.

    @[simp]
    theorem CategoryTheory.eqToHom_iso_hom_naturality_assoc {C : Type u₁} [CategoryTheory.Category.{v₁, u₁} C] {β : Sort u_1} {f : βC} {g : βC} (z : (b : β) → f b g b) {j : β} {j' : β} (w : j = j') {Z : C} (h : g j' Z) :
    @[simp]
    theorem CategoryTheory.eqToHom_iso_hom_naturality {C : Type u₁} [CategoryTheory.Category.{v₁, u₁} C] {β : Sort u_1} {f : βC} {g : βC} (z : (b : β) → f b g b) {j : β} {j' : β} (w : j = j') :

    A variant on eqToHom_naturality that helps Lean identify the families f and g.

    @[simp]
    theorem CategoryTheory.eqToHom_iso_inv_naturality_assoc {C : Type u₁} [CategoryTheory.Category.{v₁, u₁} C] {β : Sort u_1} {f : βC} {g : βC} (z : (b : β) → f b g b) {j : β} {j' : β} (w : j = j') {Z : C} (h : f j' Z) :
    @[simp]
    theorem CategoryTheory.eqToHom_iso_inv_naturality {C : Type u₁} [CategoryTheory.Category.{v₁, u₁} C] {β : Sort u_1} {f : βC} {g : βC} (z : (b : β) → f b g b) {j : β} {j' : β} (w : j = j') :

    A variant on eqToHom_naturality that helps Lean identify the families f and g.

    @[simp]
    theorem CategoryTheory.congrArg_cast_hom_left {C : Type u₁} [CategoryTheory.Category.{v₁, u₁} C] {X : C} {Y : C} {Z : C} (p : X = Y) (q : Y Z) :

    Reducible form of congrArg_mpr_hom_left

    theorem CategoryTheory.congrArg_mpr_hom_left {C : Type u₁} [CategoryTheory.Category.{v₁, u₁} C] {X : C} {Y : C} {Z : C} (p : X = Y) (q : Y Z) :

    If we (perhaps unintentionally) perform equational rewriting on the source object of a morphism, we can replace the resulting _.mpr f term by a composition with an eqToHom.

    It may be advisable to introduce any necessary eqToHom morphisms manually, rather than relying on this lemma firing.

    @[simp]
    theorem CategoryTheory.congrArg_cast_hom_right {C : Type u₁} [CategoryTheory.Category.{v₁, u₁} C] {X : C} {Y : C} {Z : C} (p : X Y) (q : Z = Y) :

    Reducible form of congrArg_mpr_hom_right

    theorem CategoryTheory.congrArg_mpr_hom_right {C : Type u₁} [CategoryTheory.Category.{v₁, u₁} C] {X : C} {Y : C} {Z : C} (p : X Y) (q : Z = Y) :

    If we (perhaps unintentionally) perform equational rewriting on the target object of a morphism, we can replace the resulting _.mpr f term by a composition with an eqToHom.

    It may be advisable to introduce any necessary eqToHom morphisms manually, rather than relying on this lemma firing.

    def CategoryTheory.eqToIso {C : Type u₁} [CategoryTheory.Category.{v₁, u₁} C] {X : C} {Y : C} (p : X = Y) :
    X Y

    An equality X = Y gives us an isomorphism X ≅ Y.

    It is typically better to use this, rather than rewriting by the equality then using Iso.refl _ which usually leads to dependent type theory hell.

    Equations
    Instances For
      @[simp]
      @[simp]
      @[simp]
      theorem CategoryTheory.eqToHom_unop {C : Type u₁} [CategoryTheory.Category.{v₁, u₁} C] {X : Cᵒᵖ} {Y : Cᵒᵖ} (h : X = Y) :
      (CategoryTheory.eqToHom h).unop = CategoryTheory.eqToHom (_ : Y.unop = X.unop)
      theorem CategoryTheory.Functor.ext {C : Type u₁} [CategoryTheory.Category.{v₁, u₁} C] {D : Type u₂} [CategoryTheory.Category.{v₂, u₂} D] {F : CategoryTheory.Functor C D} {G : CategoryTheory.Functor C D} (h_obj : ∀ (X : C), F.obj X = G.obj X) (h_map : autoParam (∀ (X Y : C) (f : X Y), F.map f = CategoryTheory.CategoryStruct.comp (CategoryTheory.eqToHom (h_obj X)) (CategoryTheory.CategoryStruct.comp (G.map f) (CategoryTheory.eqToHom (_ : G.obj Y = F.obj Y)))) _auto✝) :
      F = G

      Proving equality between functors. This isn't an extensionality lemma, because usually you don't really want to do this.

      Two morphisms are conjugate via eqToHom if and only if they are heterogeneously equal.

      theorem CategoryTheory.Functor.hext {C : Type u₁} [CategoryTheory.Category.{v₁, u₁} C] {D : Type u₂} [CategoryTheory.Category.{v₂, u₂} D] {F : CategoryTheory.Functor C D} {G : CategoryTheory.Functor C D} (h_obj : ∀ (X : C), F.obj X = G.obj X) (h_map : ∀ (X Y : C) (f : X Y), HEq (F.map f) (G.map f)) :
      F = G

      Proving equality between functors using heterogeneous equality.

      theorem CategoryTheory.Functor.congr_inv_of_congr_hom {C : Type u₁} [CategoryTheory.Category.{v₁, u₁} C] {D : Type u₂} [CategoryTheory.Category.{v₂, u₂} D] (F : CategoryTheory.Functor C D) (G : CategoryTheory.Functor C D) {X : C} {Y : C} (e : X Y) (hX : F.obj X = G.obj X) (hY : F.obj Y = G.obj Y) (h₂ : F.map e.hom = CategoryTheory.CategoryStruct.comp (CategoryTheory.eqToHom (_ : F.obj X = G.obj X)) (CategoryTheory.CategoryStruct.comp (G.map e.hom) (CategoryTheory.eqToHom (_ : G.obj Y = F.obj Y)))) :
      F.map e.inv = CategoryTheory.CategoryStruct.comp (CategoryTheory.eqToHom (_ : F.obj Y = G.obj Y)) (CategoryTheory.CategoryStruct.comp (G.map e.inv) (CategoryTheory.eqToHom (_ : G.obj X = F.obj X)))
      theorem CategoryTheory.Functor.congr_map {C : Type u₁} [CategoryTheory.Category.{v₁, u₁} C] {D : Type u₂} [CategoryTheory.Category.{v₂, u₂} D] (F : CategoryTheory.Functor C D) {X : C} {Y : C} {f : X Y} {g : X Y} (h : f = g) :
      F.map f = F.map g
      theorem CategoryTheory.Functor.map_comp_heq {C : Type u₁} [CategoryTheory.Category.{v₁, u₁} C] {D : Type u₂} [CategoryTheory.Category.{v₂, u₂} D] {F : CategoryTheory.Functor C D} {G : CategoryTheory.Functor C D} {X : C} {Y : C} {Z : C} {f : X Y} {g : Y Z} (hx : F.obj X = G.obj X) (hy : F.obj Y = G.obj Y) (hz : F.obj Z = G.obj Z) (hf : HEq (F.map f) (G.map f)) (hg : HEq (F.map g) (G.map g)) :
      theorem CategoryTheory.Functor.map_comp_heq' {C : Type u₁} [CategoryTheory.Category.{v₁, u₁} C] {D : Type u₂} [CategoryTheory.Category.{v₂, u₂} D] {F : CategoryTheory.Functor C D} {G : CategoryTheory.Functor C D} {X : C} {Y : C} {Z : C} {f : X Y} {g : Y Z} (hobj : ∀ (X : C), F.obj X = G.obj X) (hmap : ∀ {X Y : C} (f : X Y), HEq (F.map f) (G.map f)) :
      theorem CategoryTheory.Functor.precomp_map_heq {C : Type u₁} [CategoryTheory.Category.{v₁, u₁} C] {D : Type u₂} [CategoryTheory.Category.{v₂, u₂} D] {E : Type u₃} [CategoryTheory.Category.{v₃, u₃} E] {F : CategoryTheory.Functor C D} {G : CategoryTheory.Functor C D} (H : CategoryTheory.Functor E C) (hmap : ∀ {X Y : C} (f : X Y), HEq (F.map f) (G.map f)) {X : E} {Y : E} (f : X Y) :
      theorem CategoryTheory.Functor.postcomp_map_heq {C : Type u₁} [CategoryTheory.Category.{v₁, u₁} C] {D : Type u₂} [CategoryTheory.Category.{v₂, u₂} D] {E : Type u₃} [CategoryTheory.Category.{v₃, u₃} E] {F : CategoryTheory.Functor C D} {G : CategoryTheory.Functor C D} {X : C} {Y : C} {f : X Y} (H : CategoryTheory.Functor D E) (hx : F.obj X = G.obj X) (hy : F.obj Y = G.obj Y) (hmap : HEq (F.map f) (G.map f)) :
      theorem CategoryTheory.Functor.postcomp_map_heq' {C : Type u₁} [CategoryTheory.Category.{v₁, u₁} C] {D : Type u₂} [CategoryTheory.Category.{v₂, u₂} D] {E : Type u₃} [CategoryTheory.Category.{v₃, u₃} E] {F : CategoryTheory.Functor C D} {G : CategoryTheory.Functor C D} {X : C} {Y : C} {f : X Y} (H : CategoryTheory.Functor D E) (hobj : ∀ (X : C), F.obj X = G.obj X) (hmap : ∀ {X Y : C} (f : X Y), HEq (F.map f) (G.map f)) :
      theorem CategoryTheory.Functor.hcongr_hom {C : Type u₁} [CategoryTheory.Category.{v₁, u₁} C] {D : Type u₂} [CategoryTheory.Category.{v₂, u₂} D] {F : CategoryTheory.Functor C D} {G : CategoryTheory.Functor C D} (h : F = G) {X : C} {Y : C} (f : X Y) :
      HEq (F.map f) (G.map f)
      theorem CategoryTheory.eqToHom_map {C : Type u₁} [CategoryTheory.Category.{v₁, u₁} C] {D : Type u₂} [CategoryTheory.Category.{v₂, u₂} D] (F : CategoryTheory.Functor C D) {X : C} {Y : C} (p : X = Y) :
      F.map (CategoryTheory.eqToHom p) = CategoryTheory.eqToHom (_ : F.obj X = F.obj Y)

      This is not always a good idea as a @[simp] lemma, as we lose the ability to use results that interact with F, e.g. the naturality of a natural transformation.

      In some files it may be appropriate to use local attribute [simp] eqToHom_map, however.

      theorem CategoryTheory.eqToIso_map {C : Type u₁} [CategoryTheory.Category.{v₁, u₁} C] {D : Type u₂} [CategoryTheory.Category.{v₂, u₂} D] (F : CategoryTheory.Functor C D) {X : C} {Y : C} (p : X = Y) :
      F.mapIso (CategoryTheory.eqToIso p) = CategoryTheory.eqToIso (_ : F.obj X = F.obj Y)

      See the note on eqToHom_map regarding using this as a simp lemma.

      theorem CategoryTheory.dcongr_arg {C : Type u₁} [CategoryTheory.Category.{v₁, u₁} C] {ι : Type u_1} {F : ιC} {G : ιC} (α : (i : ι) → F i G i) {i : ι} {j : ι} (h : i = j) :