source stringlengths 17 118 | lean4 stringlengths 0 335k |
|---|---|
.lake/packages/mathlib/Mathlib/CategoryTheory/HomCongr.lean | import Mathlib.CategoryTheory.Iso
/-!
# Conjugate morphisms by isomorphisms
We define
`CategoryTheory.Iso.homCongr : (X ≅ X₁) → (Y ≅ Y₁) → (X ⟶ Y) ≃ (X₁ ⟶ Y₁)`,
cf. `Equiv.arrowCongr`,
and `CategoryTheory.Iso.isoCongr : (f : X₁ ≅ X₂) → (g : Y₁ ≅ Y₂) → (X₁ ≅ Y₁) ≃ (X₂ ≅ Y₂)`.
As corollaries, an isomorphism `α : X ≅ Y` defines
- a monoid isomorphism
`CategoryTheory.Iso.conj : End X ≃* End Y` by `α.conj f = α.inv ≫ f ≫ α.hom`;
- a group isomorphism `CategoryTheory.Iso.conjAut : Aut X ≃* Aut Y` by
`α.conjAut f = α.symm ≪≫ f ≪≫ α`
which can be found in `CategoryTheory.Conj`.
-/
set_option mathlib.tactic.category.grind true
universe v u
namespace CategoryTheory
namespace Iso
variable {C : Type u} [Category.{v} C]
/-- If `X` is isomorphic to `X₁` and `Y` is isomorphic to `Y₁`, then
there is a natural bijection between `X ⟶ Y` and `X₁ ⟶ Y₁`. See also `Equiv.arrowCongr`. -/
@[simps]
def homCongr {X Y X₁ Y₁ : C} (α : X ≅ X₁) (β : Y ≅ Y₁) : (X ⟶ Y) ≃ (X₁ ⟶ Y₁) where
toFun f := α.inv ≫ f ≫ β.hom
invFun f := α.hom ≫ f ≫ β.inv
left_inv f :=
show α.hom ≫ (α.inv ≫ f ≫ β.hom) ≫ β.inv = f by
rw [Category.assoc, Category.assoc, β.hom_inv_id, α.hom_inv_id_assoc, Category.comp_id]
right_inv f :=
show α.inv ≫ (α.hom ≫ f ≫ β.inv) ≫ β.hom = f by
rw [Category.assoc, Category.assoc, β.inv_hom_id, α.inv_hom_id_assoc, Category.comp_id]
theorem homCongr_comp {X Y Z X₁ Y₁ Z₁ : C} (α : X ≅ X₁) (β : Y ≅ Y₁) (γ : Z ≅ Z₁) (f : X ⟶ Y)
(g : Y ⟶ Z) : α.homCongr γ (f ≫ g) = α.homCongr β f ≫ β.homCongr γ g := by simp
theorem homCongr_refl {X Y : C} (f : X ⟶ Y) : (Iso.refl X).homCongr (Iso.refl Y) f = f := by simp
theorem homCongr_trans {X₁ Y₁ X₂ Y₂ X₃ Y₃ : C} (α₁ : X₁ ≅ X₂) (β₁ : Y₁ ≅ Y₂) (α₂ : X₂ ≅ X₃)
(β₂ : Y₂ ≅ Y₃) (f : X₁ ⟶ Y₁) :
(α₁ ≪≫ α₂).homCongr (β₁ ≪≫ β₂) f = (α₁.homCongr β₁).trans (α₂.homCongr β₂) f := by simp
@[simp]
theorem homCongr_symm {X₁ Y₁ X₂ Y₂ : C} (α : X₁ ≅ X₂) (β : Y₁ ≅ Y₂) :
(α.homCongr β).symm = α.symm.homCongr β.symm :=
rfl
attribute [grind _=_] Iso.trans_assoc
attribute [grind =] Iso.symm_self_id Iso.self_symm_id Iso.refl_trans Iso.trans_refl
attribute [local grind =] Function.LeftInverse Function.RightInverse in
/-- If `X` is isomorphic to `X₁` and `Y` is isomorphic to `Y₁`, then
there is a bijection between `X ≅ Y` and `X₁ ≅ Y₁`. -/
@[simps]
def isoCongr {X₁ Y₁ X₂ Y₂ : C} (f : X₁ ≅ X₂) (g : Y₁ ≅ Y₂) : (X₁ ≅ Y₁) ≃ (X₂ ≅ Y₂) where
toFun h := f.symm.trans <| h.trans <| g
invFun h := f.trans <| h.trans <| g.symm
left_inv := by cat_disch
right_inv := by cat_disch
/-- If `X₁` is isomorphic to `X₂`, then there is a bijection between `X₁ ≅ Y` and `X₂ ≅ Y`. -/
def isoCongrLeft {X₁ X₂ Y : C} (f : X₁ ≅ X₂) : (X₁ ≅ Y) ≃ (X₂ ≅ Y) :=
isoCongr f (Iso.refl _)
/-- If `Y₁` is isomorphic to `Y₂`, then there is a bijection between `X ≅ Y₁` and `X ≅ Y₂`. -/
def isoCongrRight {X Y₁ Y₂ : C} (g : Y₁ ≅ Y₂) : (X ≅ Y₁) ≃ (X ≅ Y₂) :=
isoCongr (Iso.refl _) g
end Iso
namespace Functor
universe v₁ u₁
variable {C : Type u} [Category.{v} C] {D : Type u₁} [Category.{v₁} D] (F : C ⥤ D)
theorem map_homCongr {X Y X₁ Y₁ : C} (α : X ≅ X₁) (β : Y ≅ Y₁) (f : X ⟶ Y) :
F.map (Iso.homCongr α β f) = Iso.homCongr (F.mapIso α) (F.mapIso β) (F.map f) := by simp
theorem map_isoCongr {X Y X₁ Y₁ : C} (α : X ≅ X₁) (β : Y ≅ Y₁) (f : X ≅ Y) :
F.mapIso (Iso.isoCongr α β f) = Iso.isoCongr (F.mapIso α) (F.mapIso β) (F.mapIso f) := by
simp
end Functor
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/EpiMono.lean | import Mathlib.CategoryTheory.Opposites
import Mathlib.CategoryTheory.Groupoid
/-!
# Facts about epimorphisms and monomorphisms.
The definitions of `Epi` and `Mono` are in `CategoryTheory.Category`,
since they are used by some lemmas for `Iso`, which is used everywhere.
-/
universe v₁ v₂ u₁ u₂
namespace CategoryTheory
variable {C : Type u₁} [Category.{v₁} C]
instance unop_mono_of_epi {A B : Cᵒᵖ} (f : A ⟶ B) [Epi f] : Mono f.unop :=
⟨fun _ _ eq => Quiver.Hom.op_inj ((cancel_epi f).1 (Quiver.Hom.unop_inj eq))⟩
instance unop_epi_of_mono {A B : Cᵒᵖ} (f : A ⟶ B) [Mono f] : Epi f.unop :=
⟨fun _ _ eq => Quiver.Hom.op_inj ((cancel_mono f).1 (Quiver.Hom.unop_inj eq))⟩
instance op_mono_of_epi {A B : C} (f : A ⟶ B) [Epi f] : Mono f.op :=
⟨fun _ _ eq => Quiver.Hom.unop_inj ((cancel_epi f).1 (Quiver.Hom.op_inj eq))⟩
instance op_epi_of_mono {A B : C} (f : A ⟶ B) [Mono f] : Epi f.op :=
⟨fun _ _ eq => Quiver.Hom.unop_inj ((cancel_mono f).1 (Quiver.Hom.op_inj eq))⟩
@[simp]
lemma op_mono_iff {X Y : C} (f : X ⟶ Y) :
Mono f.op ↔ Epi f :=
⟨fun _ ↦ unop_epi_of_mono f.op, fun _ ↦ inferInstance⟩
@[simp]
lemma op_epi_iff {X Y : C} (f : X ⟶ Y) :
Epi f.op ↔ Mono f :=
⟨fun _ ↦ unop_mono_of_epi f.op, fun _ ↦ inferInstance⟩
@[simp]
lemma unop_mono_iff {X Y : Cᵒᵖ} (f : X ⟶ Y) :
Mono f.unop ↔ Epi f :=
⟨fun _ ↦ op_epi_of_mono f.unop, fun _ ↦ inferInstance⟩
@[simp]
lemma unop_epi_iff {X Y : Cᵒᵖ} (f : X ⟶ Y) :
Epi f.unop ↔ Mono f :=
⟨fun _ ↦ op_mono_of_epi f.unop, fun _ ↦ inferInstance⟩
/-- A split monomorphism is a morphism `f : X ⟶ Y` with a given retraction `retraction f : Y ⟶ X`
such that `f ≫ retraction f = 𝟙 X`.
Every split monomorphism is a monomorphism.
-/
@[ext, aesop apply safe (rule_sets := [CategoryTheory])]
structure SplitMono {X Y : C} (f : X ⟶ Y) where
/-- The map splitting `f` -/
retraction : Y ⟶ X
/-- `f` composed with `retraction` is the identity -/
id : f ≫ retraction = 𝟙 X := by cat_disch
attribute [reassoc (attr := simp)] SplitMono.id
/-- `IsSplitMono f` is the assertion that `f` admits a retraction -/
class IsSplitMono {X Y : C} (f : X ⟶ Y) : Prop where
/-- There is a splitting -/
exists_splitMono : Nonempty (SplitMono f)
/-- A composition of `SplitMono` is a `SplitMono`. -/
@[simps]
def SplitMono.comp {X Y Z : C} {f : X ⟶ Y} {g : Y ⟶ Z} (smf : SplitMono f) (smg : SplitMono g) :
SplitMono (f ≫ g) where
retraction := smg.retraction ≫ smf.retraction
/-- A constructor for `IsSplitMono f` taking a `SplitMono f` as an argument -/
theorem IsSplitMono.mk' {X Y : C} {f : X ⟶ Y} (sm : SplitMono f) : IsSplitMono f :=
⟨Nonempty.intro sm⟩
/-- A split epimorphism is a morphism `f : X ⟶ Y` with a given section `section_ f : Y ⟶ X`
such that `section_ f ≫ f = 𝟙 Y`.
(Note that `section` is a reserved keyword, so we append an underscore.)
Every split epimorphism is an epimorphism.
-/
@[ext, aesop apply safe (rule_sets := [CategoryTheory])]
structure SplitEpi {X Y : C} (f : X ⟶ Y) where
/-- The map splitting `f` -/
section_ : Y ⟶ X
/-- `section_` composed with `f` is the identity -/
id : section_ ≫ f = 𝟙 Y := by cat_disch
attribute [reassoc (attr := simp)] SplitEpi.id
/-- `IsSplitEpi f` is the assertion that `f` admits a section -/
class IsSplitEpi {X Y : C} (f : X ⟶ Y) : Prop where
/-- There is a splitting -/
exists_splitEpi : Nonempty (SplitEpi f)
/-- A composition of `SplitEpi` is a split `SplitEpi`. -/
@[simps]
def SplitEpi.comp {X Y Z : C} {f : X ⟶ Y} {g : Y ⟶ Z} (sef : SplitEpi f) (seg : SplitEpi g) :
SplitEpi (f ≫ g) where
section_ := seg.section_ ≫ sef.section_
/-- A constructor for `IsSplitEpi f` taking a `SplitEpi f` as an argument -/
theorem IsSplitEpi.mk' {X Y : C} {f : X ⟶ Y} (se : SplitEpi f) : IsSplitEpi f :=
⟨Nonempty.intro se⟩
/-- The chosen retraction of a split monomorphism. -/
noncomputable def retraction {X Y : C} (f : X ⟶ Y) [hf : IsSplitMono f] : Y ⟶ X :=
hf.exists_splitMono.some.retraction
@[reassoc (attr := simp)]
theorem IsSplitMono.id {X Y : C} (f : X ⟶ Y) [hf : IsSplitMono f] : f ≫ retraction f = 𝟙 X :=
hf.exists_splitMono.some.id
/-- The retraction of a split monomorphism has an obvious section. -/
def SplitMono.splitEpi {X Y : C} {f : X ⟶ Y} (sm : SplitMono f) : SplitEpi sm.retraction where
section_ := f
/-- The retraction of a split monomorphism is itself a split epimorphism. -/
instance retraction_isSplitEpi {X Y : C} (f : X ⟶ Y) [IsSplitMono f] :
IsSplitEpi (retraction f) :=
IsSplitEpi.mk' (SplitMono.splitEpi _)
/-- A split mono which is epi is an iso. -/
theorem isIso_of_epi_of_isSplitMono {X Y : C} (f : X ⟶ Y) [IsSplitMono f] [Epi f] : IsIso f :=
⟨⟨retraction f, ⟨by simp, by simp [← cancel_epi f]⟩⟩⟩
/-- The chosen section of a split epimorphism.
(Note that `section` is a reserved keyword, so we append an underscore.)
-/
noncomputable def section_ {X Y : C} (f : X ⟶ Y) [hf : IsSplitEpi f] : Y ⟶ X :=
hf.exists_splitEpi.some.section_
@[reassoc (attr := simp)]
theorem IsSplitEpi.id {X Y : C} (f : X ⟶ Y) [hf : IsSplitEpi f] : section_ f ≫ f = 𝟙 Y :=
hf.exists_splitEpi.some.id
/-- The section of a split epimorphism has an obvious retraction. -/
def SplitEpi.splitMono {X Y : C} {f : X ⟶ Y} (se : SplitEpi f) : SplitMono se.section_ where
retraction := f
/-- The section of a split epimorphism is itself a split monomorphism. -/
instance section_isSplitMono {X Y : C} (f : X ⟶ Y) [IsSplitEpi f] : IsSplitMono (section_ f) :=
IsSplitMono.mk' (SplitEpi.splitMono _)
/-- A split epi which is mono is an iso. -/
theorem isIso_of_mono_of_isSplitEpi {X Y : C} (f : X ⟶ Y) [Mono f] [IsSplitEpi f] : IsIso f :=
⟨⟨section_ f, ⟨by simp [← cancel_mono f], by simp⟩⟩⟩
/-- Every iso is a split mono. -/
instance (priority := 100) IsSplitMono.of_iso {X Y : C} (f : X ⟶ Y) [IsIso f] : IsSplitMono f :=
IsSplitMono.mk' { retraction := inv f }
/-- Every iso is a split epi. -/
instance (priority := 100) IsSplitEpi.of_iso {X Y : C} (f : X ⟶ Y) [IsIso f] : IsSplitEpi f :=
IsSplitEpi.mk' { section_ := inv f }
theorem SplitMono.mono {X Y : C} {f : X ⟶ Y} (sm : SplitMono f) : Mono f :=
{ right_cancellation := fun g h w => by replace w := w =≫ sm.retraction; simpa using w }
/-- Every split mono is a mono. -/
instance (priority := 100) IsSplitMono.mono {X Y : C} (f : X ⟶ Y) [hf : IsSplitMono f] : Mono f :=
hf.exists_splitMono.some.mono
theorem SplitEpi.epi {X Y : C} {f : X ⟶ Y} (se : SplitEpi f) : Epi f :=
{ left_cancellation := fun g h w => by replace w := se.section_ ≫= w; simpa using w }
/-- Every split epi is an epi. -/
instance (priority := 100) IsSplitEpi.epi {X Y : C} (f : X ⟶ Y) [hf : IsSplitEpi f] : Epi f :=
hf.exists_splitEpi.some.epi
instance {X Y Z : C} {f : X ⟶ Y} {g : Y ⟶ Z} [hf : IsSplitMono f] [hg : IsSplitMono g] :
IsSplitMono (f ≫ g) := IsSplitMono.mk' <| hf.exists_splitMono.some.comp hg.exists_splitMono.some
instance {X Y Z : C} {f : X ⟶ Y} {g : Y ⟶ Z} [hf : IsSplitEpi f] [hg : IsSplitEpi g] :
IsSplitEpi (f ≫ g) := IsSplitEpi.mk' <| hf.exists_splitEpi.some.comp hg.exists_splitEpi.some
/-- Every split mono whose retraction is mono is an iso. -/
theorem IsIso.of_mono_retraction' {X Y : C} {f : X ⟶ Y} (hf : SplitMono f) [Mono <| hf.retraction] :
IsIso f :=
⟨⟨hf.retraction, ⟨by simp, (cancel_mono_id <| hf.retraction).mp (by simp)⟩⟩⟩
/-- Every split mono whose retraction is mono is an iso. -/
theorem IsIso.of_mono_retraction {X Y : C} (f : X ⟶ Y) [hf : IsSplitMono f]
[hf' : Mono <| retraction f] : IsIso f :=
@IsIso.of_mono_retraction' _ _ _ _ _ hf.exists_splitMono.some hf'
/-- Every split epi whose section is epi is an iso. -/
theorem IsIso.of_epi_section' {X Y : C} {f : X ⟶ Y} (hf : SplitEpi f) [Epi <| hf.section_] :
IsIso f :=
⟨⟨hf.section_, ⟨(cancel_epi_id <| hf.section_).mp (by simp), by simp⟩⟩⟩
/-- Every split epi whose section is epi is an iso. -/
theorem IsIso.of_epi_section {X Y : C} (f : X ⟶ Y) [hf : IsSplitEpi f] [hf' : Epi <| section_ f] :
IsIso f :=
@IsIso.of_epi_section' _ _ _ _ _ hf.exists_splitEpi.some hf'
-- FIXME this has unnecessarily become noncomputable!
/-- A category where every morphism has a `Trunc` retraction is computably a groupoid. -/
noncomputable def Groupoid.ofTruncSplitMono
(all_split_mono : ∀ {X Y : C} (f : X ⟶ Y), Trunc (IsSplitMono f)) : Groupoid.{v₁} C := by
apply Groupoid.ofIsIso
intro X Y f
have ⟨a,_⟩ := Trunc.exists_rep <| all_split_mono f
have ⟨b,_⟩ := Trunc.exists_rep <| all_split_mono <| retraction f
apply IsIso.of_mono_retraction
section
variable (C)
/-- A split mono category is a category in which every monomorphism is split. -/
class SplitMonoCategory : Prop where
/-- All monos are split -/
isSplitMono_of_mono : ∀ {X Y : C} (f : X ⟶ Y) [Mono f], IsSplitMono f
/-- A split epi category is a category in which every epimorphism is split. -/
class SplitEpiCategory : Prop where
/-- All epis are split -/
isSplitEpi_of_epi : ∀ {X Y : C} (f : X ⟶ Y) [Epi f], IsSplitEpi f
end
/-- In a category in which every monomorphism is split, every monomorphism splits. This is not an
instance because it would create an instance loop. -/
theorem isSplitMono_of_mono [SplitMonoCategory C] {X Y : C} (f : X ⟶ Y) [Mono f] : IsSplitMono f :=
SplitMonoCategory.isSplitMono_of_mono _
/-- In a category in which every epimorphism is split, every epimorphism splits. This is not an
instance because it would create an instance loop. -/
theorem isSplitEpi_of_epi [SplitEpiCategory C] {X Y : C} (f : X ⟶ Y) [Epi f] : IsSplitEpi f :=
SplitEpiCategory.isSplitEpi_of_epi _
section
variable {D : Type u₂} [Category.{v₂} D]
/-- Split monomorphisms are also absolute monomorphisms. -/
@[simps]
def SplitMono.map {X Y : C} {f : X ⟶ Y} (sm : SplitMono f) (F : C ⥤ D) : SplitMono (F.map f) where
retraction := F.map sm.retraction
id := by rw [← Functor.map_comp, SplitMono.id, Functor.map_id]
/-- Split epimorphisms are also absolute epimorphisms. -/
@[simps]
def SplitEpi.map {X Y : C} {f : X ⟶ Y} (se : SplitEpi f) (F : C ⥤ D) : SplitEpi (F.map f) where
section_ := F.map se.section_
id := by rw [← Functor.map_comp, SplitEpi.id, Functor.map_id]
instance {X Y : C} (f : X ⟶ Y) [hf : IsSplitMono f] (F : C ⥤ D) : IsSplitMono (F.map f) :=
IsSplitMono.mk' (hf.exists_splitMono.some.map F)
instance {X Y : C} (f : X ⟶ Y) [hf : IsSplitEpi f] (F : C ⥤ D) : IsSplitEpi (F.map f) :=
IsSplitEpi.mk' (hf.exists_splitEpi.some.map F)
end
section
/-- When `f` is an epimorphism, `f ≫ g` is epic iff `g` is. -/
@[simp]
lemma epi_comp_iff_of_epi {X Y Z : C} (f : X ⟶ Y) [Epi f] (g : Y ⟶ Z) :
Epi (f ≫ g) ↔ Epi g :=
⟨fun _ ↦ epi_of_epi f _, fun _ ↦ inferInstance⟩
/-- When `g` is an isomorphism, `f ≫ g` is epic iff `f` is. -/
@[simp]
lemma epi_comp_iff_of_isIso {X Y Z : C} (f : X ⟶ Y) (g : Y ⟶ Z) [IsIso g] :
Epi (f ≫ g) ↔ Epi f := by
refine ⟨fun h ↦ ?_, fun h ↦ inferInstance⟩
simpa using (inferInstance : Epi ((f ≫ g) ≫ inv g))
/-- When `f` is an isomorphism, `f ≫ g` is monic iff `g` is. -/
@[simp]
lemma mono_comp_iff_of_isIso {X Y Z : C} (f : X ⟶ Y) [IsIso f] (g : Y ⟶ Z) :
Mono (f ≫ g) ↔ Mono g := by
refine ⟨fun h ↦ ?_, fun h ↦ inferInstance⟩
simpa using (inferInstance : Mono (inv f ≫ f ≫ g))
/-- When `g` is a monomorphism, `f ≫ g` is monic iff `f` is. -/
@[simp]
lemma mono_comp_iff_of_mono {X Y Z : C} (f : X ⟶ Y) (g : Y ⟶ Z) [Mono g] :
Mono (f ≫ g) ↔ Mono f :=
⟨fun _ ↦ mono_of_mono _ g, fun _ ↦ inferInstance⟩
end
section Opposite
variable {X Y : C} {f : X ⟶ Y}
/-- The opposite of a split mono is a split epi. -/
def SplitMono.op (h : SplitMono f) : SplitEpi f.op where
section_ := h.retraction.op
id := Quiver.Hom.unop_inj (by simp)
/-- The opposite of a split epi is a split mono. -/
def SplitEpi.op (h : SplitEpi f) : SplitMono f.op where
retraction := h.section_.op
id := Quiver.Hom.unop_inj (by simp)
instance [IsSplitMono f] : IsSplitEpi f.op :=
.mk' IsSplitMono.exists_splitMono.some.op
instance [IsSplitEpi f] : IsSplitMono f.op :=
.mk' IsSplitEpi.exists_splitEpi.some.op
end Opposite
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Retract.lean | import Mathlib.CategoryTheory.Comma.Arrow
import Mathlib.CategoryTheory.EpiMono
/-!
# Retracts
Defines retracts of objects and morphisms.
-/
universe v v' u u'
namespace CategoryTheory
variable {C : Type u} [Category.{v} C] {D : Type u'} [Category.{v'} D]
/-- An object `X` is a retract of `Y` if there are morphisms `i : X ⟶ Y` and `r : Y ⟶ X` such
that `i ≫ r = 𝟙 X`. -/
structure Retract (X Y : C) where
/-- the split monomorphism -/
i : X ⟶ Y
/-- the split epimorphism -/
r : Y ⟶ X
retract : i ≫ r = 𝟙 X := by cat_disch
namespace Retract
attribute [reassoc (attr := simp)] retract
variable {X Y : C} (h : Retract X Y)
open Opposite
/-- Retracts are preserved when passing to the opposite category. -/
@[simps]
def op : Retract (op X) (op Y) where
i := h.r.op
r := h.i.op
retract := by simp [← op_comp, h.retract]
/-- If `X` is a retract of `Y`, then `F.obj X` is a retract of `F.obj Y`. -/
@[simps]
def map (F : C ⥤ D) : Retract (F.obj X) (F.obj Y) where
i := F.map h.i
r := F.map h.r
retract := by rw [← F.map_comp h.i h.r, h.retract, F.map_id]
/-- a retract determines a split epimorphism. -/
@[simps] def splitEpi : SplitEpi h.r where
section_ := h.i
/-- a retract determines a split monomorphism. -/
@[simps] def splitMono : SplitMono h.i where
retraction := h.r
instance : IsSplitEpi h.r := ⟨⟨h.splitEpi⟩⟩
instance : IsSplitMono h.i := ⟨⟨h.splitMono⟩⟩
variable (X) in
/-- Any object is a retract of itself. -/
@[simps]
def refl : Retract X X where
i := 𝟙 X
r := 𝟙 X
/-- A retract of a retract is a retract. -/
@[simps]
def trans {Z : C} (h' : Retract Y Z) : Retract X Z where
i := h.i ≫ h'.i
r := h'.r ≫ h.r
/-- If `e : X ≅ Y`, then `X` is a retract of `Y`. -/
def ofIso (e : X ≅ Y) : Retract X Y where
i := e.hom
r := e.inv
end Retract
/--
```
X -------> Z -------> X
| | |
f g f
| | |
v v v
Y -------> W -------> Y
```
A morphism `f : X ⟶ Y` is a retract of `g : Z ⟶ W` if there are morphisms `i : f ⟶ g`
and `r : g ⟶ f` in the arrow category such that `i ≫ r = 𝟙 f`. -/
abbrev RetractArrow {X Y Z W : C} (f : X ⟶ Y) (g : Z ⟶ W) := Retract (Arrow.mk f) (Arrow.mk g)
namespace RetractArrow
variable {X Y Z W : C} {f : X ⟶ Y} {g : Z ⟶ W} (h : RetractArrow f g)
@[reassoc]
lemma i_w : h.i.left ≫ g = f ≫ h.i.right := h.i.w
@[reassoc]
lemma r_w : h.r.left ≫ f = g ≫ h.r.right := h.r.w
/-- The top of a retract diagram of morphisms determines a retract of objects. -/
@[simps!]
def left : Retract X Z := h.map Arrow.leftFunc
/-- The bottom of a retract diagram of morphisms determines a retract of objects. -/
@[simps!]
def right : Retract Y W := h.map Arrow.rightFunc
@[reassoc (attr := simp)]
lemma retract_left : h.i.left ≫ h.r.left = 𝟙 X := h.left.retract
@[reassoc (attr := simp)]
lemma retract_right : h.i.right ≫ h.r.right = 𝟙 Y := h.right.retract
instance : IsSplitEpi h.r.left := ⟨⟨h.left.splitEpi⟩⟩
instance : IsSplitEpi h.r.right := ⟨⟨h.right.splitEpi⟩⟩
instance : IsSplitMono h.i.left := ⟨⟨h.left.splitMono⟩⟩
instance : IsSplitMono h.i.right := ⟨⟨h.right.splitMono⟩⟩
/-- If a morphism `f` is a retract of `g`, then `f.op` is a retract of `g.op`. -/
@[simps]
def op : RetractArrow f.op g.op where
i.left := h.r.right.op
i.right := h.r.left.op
i.w := by simp [← op_comp]
r.left := h.i.right.op
r.right := h.i.left.op
r.w := by simp [← op_comp]
retract := by ext <;> simp [← op_comp]
/-- If a morphism `f` in the opposite category is a retract of `g`,
then `f.unop` is a retract of `g.unop`. -/
@[simps]
def unop {X Y Z W : Cᵒᵖ} {f : X ⟶ Y} {g : Z ⟶ W} (h : RetractArrow f g)
: RetractArrow f.unop g.unop where
i.left := h.r.right.unop
i.right := h.r.left.unop
i.w := by simp [← unop_comp]
r.left := h.i.right.unop
r.right := h.i.left.unop
r.w := by simp [← unop_comp]
retract := by ext <;> simp [← unop_comp]
end RetractArrow
namespace Iso
/-- If `X` is isomorphic to `Y`, then `X` is a retract of `Y`. -/
@[simps]
def retract {X Y : C} (e : X ≅ Y) : Retract X Y where
i := e.hom
r := e.inv
end Iso
/-- If `X` is a retract of `Y`, then for any natural transformation `τ`,
the natural transformation `τ.app X` is a retract of `τ.app Y`. -/
@[simps]
def NatTrans.retractArrowApp {F G : C ⥤ D}
(τ : F ⟶ G) {X Y : C} (h : Retract X Y) : RetractArrow (τ.app X) (τ.app Y) where
i := Arrow.homMk (F.map h.i) (G.map h.i) (by simp)
r := Arrow.homMk (F.map h.r) (G.map h.r) (by simp)
retract := by ext <;> simp [← Functor.map_comp]
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/CofilteredSystem.lean | import Mathlib.Topology.Category.TopCat.Limits.Konig
/-!
# Cofiltered systems
This file deals with properties of cofiltered (and inverse) systems.
## Main definitions
Given a functor `F : J ⥤ Type v`:
* For `j : J`, `F.eventualRange j` is the intersection of all ranges of morphisms `F.map f`
where `f` has codomain `j`.
* `F.IsMittagLeffler` states that the functor `F` satisfies the Mittag-Leffler
condition: the ranges of morphisms `F.map f` (with `f` having codomain `j`) stabilize.
* If `J` is cofiltered `F.toEventualRanges` is the subfunctor of `F` obtained by restriction
to `F.eventualRange`.
* `F.toPreimages` restricts a functor to preimages of a given set in some `F.obj i`. If `J` is
cofiltered, then it is Mittag-Leffler if `F` is, see `IsMittagLeffler.toPreimages`.
## Main statements
* `nonempty_sections_of_finite_cofiltered_system` shows that if `J` is cofiltered and each
`F.obj j` is nonempty and finite, `F.sections` is nonempty.
* `nonempty_sections_of_finite_inverse_system` is a specialization of the above to `J` being a
directed set (and `F : Jᵒᵖ ⥤ Type v`).
* `isMittagLeffler_of_exists_finite_range` shows that if `J` is cofiltered and for all `j`,
there exists some `i` and `f : i ⟶ j` such that the range of `F.map f` is finite, then
`F` is Mittag-Leffler.
* `surjective_toEventualRanges` shows that if `F` is Mittag-Leffler, then `F.toEventualRanges`
has all morphisms `F.map f` surjective.
## TODO
* Prove [Stacks: Lemma 0597](https://stacks.math.columbia.edu/tag/0597)
## References
* [Stacks: Mittag-Leffler systems](https://stacks.math.columbia.edu/tag/0594)
## Tags
Mittag-Leffler, surjective, eventual range, inverse system,
-/
universe u v w
open CategoryTheory CategoryTheory.IsCofiltered Set CategoryTheory.FunctorToTypes
section FiniteKonig
/-- This bootstraps `nonempty_sections_of_finite_inverse_system`. In this version,
the `F` functor is between categories of the same universe, and it is an easy
corollary to `TopCat.nonempty_limitCone_of_compact_t2_cofiltered_system`. -/
theorem nonempty_sections_of_finite_cofiltered_system.init {J : Type u} [SmallCategory J]
[IsCofilteredOrEmpty J] (F : J ⥤ Type u) [hf : ∀ j, Finite (F.obj j)]
[hne : ∀ j, Nonempty (F.obj j)] : F.sections.Nonempty := by
let F' : J ⥤ TopCat := F ⋙ TopCat.discrete
haveI : ∀ j, DiscreteTopology (F'.obj j) := fun _ => ⟨rfl⟩
haveI : ∀ j, Finite (F'.obj j) := hf
haveI : ∀ j, Nonempty (F'.obj j) := hne
obtain ⟨⟨u, hu⟩⟩ := TopCat.nonempty_limitCone_of_compact_t2_cofiltered_system.{u} F'
exact ⟨u, hu⟩
/-- The cofiltered limit of nonempty finite types is nonempty.
See `nonempty_sections_of_finite_inverse_system` for a specialization to inverse limits. -/
theorem nonempty_sections_of_finite_cofiltered_system {J : Type u} [Category.{w} J]
[IsCofilteredOrEmpty J] (F : J ⥤ Type v) [∀ j : J, Finite (F.obj j)]
[∀ j : J, Nonempty (F.obj j)] : F.sections.Nonempty := by
-- Step 1: lift everything to the `max u v w` universe.
let J' : Type max w v u := AsSmall.{max w v} J
let down : J' ⥤ J := AsSmall.down
let F' : J' ⥤ Type max u v w := down ⋙ F ⋙ uliftFunctor.{max u w, v}
haveI : ∀ i, Nonempty (F'.obj i) := fun i => ⟨⟨Classical.arbitrary (F.obj (down.obj i))⟩⟩
haveI : ∀ i, Finite (F'.obj i) := fun i => Finite.of_equiv (F.obj (down.obj i)) Equiv.ulift.symm
-- Step 2: apply the bootstrap theorem
cases isEmpty_or_nonempty J
· fconstructor <;> apply isEmptyElim
haveI : IsCofiltered J := ⟨⟩
obtain ⟨u, hu⟩ := nonempty_sections_of_finite_cofiltered_system.init F'
-- Step 3: interpret the results
use fun j => (u ⟨j⟩).down
intro j j' f
have h := @hu (⟨j⟩ : J') (⟨j'⟩ : J') (ULift.up f)
simp only [F', down, AsSmall.down, Functor.comp_map, uliftFunctor_map] at h
simp_rw [← h]
/-- The inverse limit of nonempty finite types is nonempty.
See `nonempty_sections_of_finite_cofiltered_system` for a generalization to cofiltered limits.
That version applies in almost all cases, and the only difference is that this version
allows `J` to be empty.
This may be regarded as a generalization of Kőnig's lemma.
To specialize: given a locally finite connected graph, take `Jᵒᵖ` to be `ℕ` and
`F j` to be length-`j` paths that start from an arbitrary fixed vertex.
Elements of `F.sections` can be read off as infinite rays in the graph. -/
theorem nonempty_sections_of_finite_inverse_system {J : Type u} [Preorder J] [IsDirected J (· ≤ ·)]
(F : Jᵒᵖ ⥤ Type v) [∀ j : Jᵒᵖ, Finite (F.obj j)] [∀ j : Jᵒᵖ, Nonempty (F.obj j)] :
F.sections.Nonempty := nonempty_sections_of_finite_cofiltered_system F
end FiniteKonig
namespace CategoryTheory
namespace Functor
variable {J : Type u} [Category J] (F : J ⥤ Type v) {i j k : J} (s : Set (F.obj i))
/-- The eventual range of the functor `F : J ⥤ Type v` at index `j : J` is the intersection
of the ranges of all maps `F.map f` with `i : J` and `f : i ⟶ j`. -/
def eventualRange (j : J) :=
⋂ (i) (f : i ⟶ j), range (F.map f)
theorem mem_eventualRange_iff {x : F.obj j} :
x ∈ F.eventualRange j ↔ ∀ ⦃i⦄ (f : i ⟶ j), x ∈ range (F.map f) :=
mem_iInter₂
/-- The functor `F : J ⥤ Type v` satisfies the Mittag-Leffler condition if for all `j : J`,
there exists some `i : J` and `f : i ⟶ j` such that for all `k : J` and `g : k ⟶ j`, the range
of `F.map f` is contained in that of `F.map g`;
in other words (see `isMittagLeffler_iff_eventualRange`), the eventual range at `j` is attained
by some `f : i ⟶ j`. -/
def IsMittagLeffler : Prop :=
∀ j : J, ∃ (i : _) (f : i ⟶ j), ∀ ⦃k⦄ (g : k ⟶ j), range (F.map f) ⊆ range (F.map g)
theorem isMittagLeffler_iff_eventualRange :
F.IsMittagLeffler ↔ ∀ j : J, ∃ (i : _) (f : i ⟶ j), F.eventualRange j = range (F.map f) :=
forall_congr' fun _ =>
exists₂_congr fun _ _ =>
⟨fun h => (iInter₂_subset _ _).antisymm <| subset_iInter₂ h, fun h => h ▸ iInter₂_subset⟩
theorem IsMittagLeffler.subset_image_eventualRange (h : F.IsMittagLeffler) (f : j ⟶ i) :
F.eventualRange i ⊆ F.map f '' F.eventualRange j := by
obtain ⟨k, g, hg⟩ := F.isMittagLeffler_iff_eventualRange.1 h j
rw [hg]; intro x hx
obtain ⟨x, rfl⟩ := F.mem_eventualRange_iff.1 hx (g ≫ f)
exact ⟨_, ⟨x, rfl⟩, by rw [map_comp_apply]⟩
theorem eventualRange_eq_range_precomp (f : i ⟶ j) (g : j ⟶ k)
(h : F.eventualRange k = range (F.map g)) : F.eventualRange k = range (F.map <| f ≫ g) := by
apply subset_antisymm
· apply iInter₂_subset
· rw [h, F.map_comp]
apply range_comp_subset_range
theorem isMittagLeffler_of_surjective (h : ∀ ⦃i j : J⦄ (f : i ⟶ j), (F.map f).Surjective) :
F.IsMittagLeffler :=
fun j => ⟨j, 𝟙 j, fun k g => by rw [map_id, types_id, range_id, (h g).range_eq]⟩
/-- The subfunctor of `F` obtained by restricting to the preimages of a set `s ∈ F.obj i`. -/
@[simps]
def toPreimages : J ⥤ Type v where
obj j := ⋂ f : j ⟶ i, F.map f ⁻¹' s
map g := MapsTo.restrict (F.map g) _ _ fun x h => by
rw [mem_iInter] at h ⊢
intro f
rw [← mem_preimage, preimage_preimage, mem_preimage]
convert h (g ≫ f); rw [F.map_comp]; rfl
map_id j := by
simp +unfoldPartialApp only [MapsTo.restrict, Subtype.map, F.map_id]
ext
rfl
map_comp f g := by
simp +unfoldPartialApp only [MapsTo.restrict, Subtype.map, F.map_comp]
rfl
instance toPreimages_finite [∀ j, Finite (F.obj j)] : ∀ j, Finite ((F.toPreimages s).obj j) :=
fun _ => Subtype.finite
variable [IsCofilteredOrEmpty J]
theorem eventualRange_mapsTo (f : j ⟶ i) :
(F.eventualRange j).MapsTo (F.map f) (F.eventualRange i) := fun x hx => by
rw [mem_eventualRange_iff] at hx ⊢
intro k f'
obtain ⟨l, g, g', he⟩ := cospan f f'
obtain ⟨x, rfl⟩ := hx g
rw [← map_comp_apply, he, F.map_comp]
exact ⟨_, rfl⟩
theorem IsMittagLeffler.eq_image_eventualRange (h : F.IsMittagLeffler) (f : j ⟶ i) :
F.eventualRange i = F.map f '' F.eventualRange j :=
(h.subset_image_eventualRange F f).antisymm <| mapsTo_iff_image_subset.1
(F.eventualRange_mapsTo f)
theorem eventualRange_eq_iff {f : i ⟶ j} :
F.eventualRange j = range (F.map f) ↔
∀ ⦃k⦄ (g : k ⟶ i), range (F.map f) ⊆ range (F.map <| g ≫ f) := by
rw [subset_antisymm_iff, eventualRange, and_iff_right (iInter₂_subset _ _), subset_iInter₂_iff]
refine ⟨fun h k g => h _ _, fun h j' f' => ?_⟩
obtain ⟨k, g, g', he⟩ := cospan f f'
refine (h g).trans ?_
rw [he, F.map_comp]
apply range_comp_subset_range
theorem isMittagLeffler_iff_subset_range_comp : F.IsMittagLeffler ↔ ∀ j : J, ∃ (i : _) (f : i ⟶ j),
∀ ⦃k⦄ (g : k ⟶ i), range (F.map f) ⊆ range (F.map <| g ≫ f) := by
simp_rw [isMittagLeffler_iff_eventualRange, eventualRange_eq_iff]
theorem IsMittagLeffler.toPreimages (h : F.IsMittagLeffler) : (F.toPreimages s).IsMittagLeffler :=
(isMittagLeffler_iff_subset_range_comp _).2 fun j => by
obtain ⟨j₁, g₁, f₁, -⟩ := IsCofilteredOrEmpty.cone_objs i j
obtain ⟨j₂, f₂, h₂⟩ := F.isMittagLeffler_iff_eventualRange.1 h j₁
refine ⟨j₂, f₂ ≫ f₁, fun j₃ f₃ => ?_⟩
rintro _ ⟨⟨x, hx⟩, rfl⟩
have : F.map f₂ x ∈ F.eventualRange j₁ := by
rw [h₂]
exact ⟨_, rfl⟩
obtain ⟨y, hy, h₃⟩ := h.subset_image_eventualRange F (f₃ ≫ f₂) this
refine ⟨⟨y, mem_iInter.2 fun g₂ => ?_⟩, Subtype.ext ?_⟩
· obtain ⟨j₄, f₄, h₄⟩ := IsCofilteredOrEmpty.cone_maps g₂ ((f₃ ≫ f₂) ≫ g₁)
obtain ⟨y, rfl⟩ := F.mem_eventualRange_iff.1 hy f₄
rw [← map_comp_apply] at h₃
rw [mem_preimage, ← map_comp_apply, h₄, ← Category.assoc, map_comp_apply, h₃,
← map_comp_apply]
apply mem_iInter.1 hx
· simp_rw [toPreimages_map, MapsTo.val_restrict_apply]
rw [← Category.assoc, map_comp_apply, h₃, map_comp_apply]
theorem isMittagLeffler_of_exists_finite_range
(h : ∀ j : J, ∃ (i : _) (f : i ⟶ j), (range <| F.map f).Finite) : F.IsMittagLeffler := by
intro j
obtain ⟨i, hi, hf⟩ := h j
obtain ⟨m, ⟨i, f, hm⟩, hmin⟩ := Finset.wellFoundedLT.wf.has_min
{ s : Finset (F.obj j) | ∃ (i : _) (f : i ⟶ j), ↑s = range (F.map f) }
⟨_, i, hi, hf.coe_toFinset⟩
refine ⟨i, f, fun k g =>
(directedOn_range.mp <| F.ranges_directed j).is_bot_of_is_min ⟨⟨i, f⟩, rfl⟩ ?_ _ ⟨⟨k, g⟩, rfl⟩⟩
rintro _ ⟨⟨k', g'⟩, rfl⟩ hl
refine (eq_of_le_of_not_lt hl ?_).ge
have := hmin _ ⟨k', g', (m.finite_toSet.subset <| hm.substr hl).coe_toFinset⟩
rwa [Finset.lt_iff_ssubset, ← Finset.coe_ssubset, Set.Finite.coe_toFinset, hm] at this
/-- The subfunctor of `F` obtained by restricting to the eventual range at each index. -/
@[simps]
def toEventualRanges : J ⥤ Type v where
obj j := F.eventualRange j
map f := (F.eventualRange_mapsTo f).restrict _ _ _
map_id i := by
simp +unfoldPartialApp only [MapsTo.restrict, Subtype.map, F.map_id]
ext
rfl
map_comp _ _ := by
simp +unfoldPartialApp only [MapsTo.restrict, Subtype.map, F.map_comp]
rfl
instance toEventualRanges_finite [∀ j, Finite (F.obj j)] : ∀ j, Finite (F.toEventualRanges.obj j) :=
fun _ => Subtype.finite
/-- The sections of the functor `F : J ⥤ Type v` are in bijection with the sections of
`F.toEventualRanges`. -/
def toEventualRangesSectionsEquiv : F.toEventualRanges.sections ≃ F.sections where
toFun s := ⟨_, fun f => Subtype.coe_inj.2 <| s.prop f⟩
invFun s :=
⟨fun _ => ⟨_, mem_iInter₂.2 fun _ f => ⟨_, s.prop f⟩⟩, fun f => Subtype.ext <| s.prop f⟩
/-- If `F` satisfies the Mittag-Leffler condition, its restriction to eventual ranges is a
surjective functor. -/
theorem surjective_toEventualRanges (h : F.IsMittagLeffler) ⦃i j⦄ (f : i ⟶ j) :
(F.toEventualRanges.map f).Surjective := fun ⟨x, hx⟩ => by
obtain ⟨y, hy, rfl⟩ := h.subset_image_eventualRange F f hx
exact ⟨⟨y, hy⟩, rfl⟩
/-- If `F` is nonempty at each index and Mittag-Leffler, then so is `F.toEventualRanges`. -/
theorem toEventualRanges_nonempty (h : F.IsMittagLeffler) [∀ j : J, Nonempty (F.obj j)] (j : J) :
Nonempty (F.toEventualRanges.obj j) := by
let ⟨i, f, h⟩ := F.isMittagLeffler_iff_eventualRange.1 h j
rw [toEventualRanges_obj, h]
infer_instance
/-- If `F` has all arrows surjective, then it "factors through a poset". -/
theorem thin_diagram_of_surjective (Fsur : ∀ ⦃i j : J⦄ (f : i ⟶ j), (F.map f).Surjective) {i j}
(f g : i ⟶ j) : F.map f = F.map g :=
let ⟨k, φ, hφ⟩ := IsCofilteredOrEmpty.cone_maps f g
(Fsur φ).injective_comp_right <| by simp_rw [← types_comp, ← F.map_comp, hφ]
theorem toPreimages_nonempty_of_surjective [hFn : ∀ j : J, Nonempty (F.obj j)]
(Fsur : ∀ ⦃i j : J⦄ (f : i ⟶ j), (F.map f).Surjective) (hs : s.Nonempty) (j) :
Nonempty ((F.toPreimages s).obj j) := by
simp only [toPreimages_obj, nonempty_coe_sort, nonempty_iInter, mem_preimage]
obtain h | ⟨⟨ji⟩⟩ := isEmpty_or_nonempty (j ⟶ i)
· exact ⟨(hFn j).some, fun ji => h.elim ji⟩
· obtain ⟨y, ys⟩ := hs
obtain ⟨x, rfl⟩ := Fsur ji y
exact ⟨x, fun ji' => (F.thin_diagram_of_surjective Fsur ji' ji).symm ▸ ys⟩
theorem eval_section_injective_of_eventually_injective {j}
(Finj : ∀ (i) (f : i ⟶ j), (F.map f).Injective) (i) (f : i ⟶ j) :
(fun s : F.sections => s.val j).Injective := by
refine fun s₀ s₁ h => Subtype.ext <| funext fun k => ?_
obtain ⟨m, mi, mk, _⟩ := IsCofilteredOrEmpty.cone_objs i k
dsimp at h
rw [← s₀.prop (mi ≫ f), ← s₁.prop (mi ≫ f)] at h
rw [← s₀.prop mk, ← s₁.prop mk]
exact congr_arg _ (Finj m (mi ≫ f) h)
section FiniteCofilteredSystem
variable [∀ j : J, Nonempty (F.obj j)] [∀ j : J, Finite (F.obj j)]
(Fsur : ∀ ⦃i j : J⦄ (f : i ⟶ j), (F.map f).Surjective)
include Fsur
theorem eval_section_surjective_of_surjective (i : J) :
(fun s : F.sections => s.val i).Surjective := fun x => by
let s : Set (F.obj i) := {x}
haveI := F.toPreimages_nonempty_of_surjective s Fsur (singleton_nonempty x)
obtain ⟨sec, h⟩ := nonempty_sections_of_finite_cofiltered_system (F.toPreimages s)
refine ⟨⟨fun j => (sec j).val, fun jk => by simpa [Subtype.ext_iff] using h jk⟩, ?_⟩
· have := (sec i).prop
simp only [mem_iInter, mem_preimage] at this
have := this (𝟙 i)
rwa [map_id_apply] at this
theorem eventually_injective [Nonempty J] [Finite F.sections] :
∃ j, ∀ (i) (f : i ⟶ j), (F.map f).Injective := by
haveI : ∀ j, Fintype (F.obj j) := fun j => Fintype.ofFinite (F.obj j)
haveI : Fintype F.sections := Fintype.ofFinite F.sections
have card_le : ∀ j, Fintype.card (F.obj j) ≤ Fintype.card F.sections :=
fun j => Fintype.card_le_of_surjective _ (F.eval_section_surjective_of_surjective Fsur j)
let fn j := Fintype.card F.sections - Fintype.card (F.obj j)
refine ⟨fn.argmin,
fun i f => ((Fintype.bijective_iff_surjective_and_card _).2
⟨Fsur f, le_antisymm ?_ (Fintype.card_le_of_surjective _ <| Fsur f)⟩).1⟩
rw [← Nat.sub_le_sub_iff_left (card_le i)]
apply fn.argmin_le
end FiniteCofilteredSystem
end Functor
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Balanced.lean | import Mathlib.CategoryTheory.EpiMono
/-!
# Balanced categories
A category is called balanced if any morphism that is both monic and epic is an isomorphism.
Balanced categories arise frequently. For example, categories in which every monomorphism
(or epimorphism) is strong are balanced. Examples of this are abelian categories and toposes, such
as the category of types.
-/
universe v u
namespace CategoryTheory
variable {C : Type u} [Category.{v} C]
section
variable (C)
/-- A category is called balanced if any morphism that is both monic and epic is an isomorphism. -/
class Balanced : Prop where
isIso_of_mono_of_epi : ∀ {X Y : C} (f : X ⟶ Y) [Mono f] [Epi f], IsIso f
end
theorem isIso_of_mono_of_epi [Balanced C] {X Y : C} (f : X ⟶ Y) [Mono f] [Epi f] : IsIso f :=
Balanced.isIso_of_mono_of_epi _
theorem isIso_iff_mono_and_epi [Balanced C] {X Y : C} (f : X ⟶ Y) : IsIso f ↔ Mono f ∧ Epi f :=
⟨fun _ => ⟨inferInstance, inferInstance⟩, fun ⟨_, _⟩ => isIso_of_mono_of_epi _⟩
section
attribute [local instance] isIso_of_mono_of_epi
instance balanced_opposite [Balanced C] : Balanced Cᵒᵖ :=
{ isIso_of_mono_of_epi := fun f fmono fepi => by
rw [← Quiver.Hom.op_unop f]
exact isIso_of_op _ }
end
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/GradedObject.lean | import Mathlib.CategoryTheory.ConcreteCategory.Basic
import Mathlib.CategoryTheory.Shift.Basic
import Mathlib.Data.Set.Subsingleton
import Mathlib.Algebra.Group.Int.Defs
/-!
# The category of graded objects
For any type `β`, a `β`-graded object over some category `C` is just
a function `β → C` into the objects of `C`.
We put the "pointwise" category structure on these, as the non-dependent specialization of
`CategoryTheory.Pi`.
We describe the `comap` functors obtained by precomposing with functions `β → γ`.
As a consequence a fixed element (e.g. `1`) in an additive group `β` provides a shift
functor on `β`-graded objects
When `C` has coproducts we construct the `total` functor `GradedObject β C ⥤ C`,
show that it is faithful, and deduce that when `C` is concrete so is `GradedObject β C`.
A covariant functoriality of `GradedObject β C` with respect to the index set `β` is also
introduced: if `p : I → J` is a map such that `C` has coproducts indexed by `p ⁻¹' {j}`, we
have a functor `map : GradedObject I C ⥤ GradedObject J C`.
-/
namespace CategoryTheory
open Category Limits
universe w v u
/-- A type synonym for `β → C`, used for `β`-graded objects in a category `C`. -/
def GradedObject (β : Type w) (C : Type u) : Type max w u :=
β → C
-- Satisfying the inhabited linter...
instance inhabitedGradedObject (β : Type w) (C : Type u) [Inhabited C] :
Inhabited (GradedObject β C) :=
⟨fun _ => Inhabited.default⟩
-- `s` is here to distinguish type synonyms asking for different shifts
/-- A type synonym for `β → C`, used for `β`-graded objects in a category `C`
with a shift functor given by translation by `s`.
-/
@[nolint unusedArguments]
abbrev GradedObjectWithShift {β : Type w} [AddCommGroup β] (_ : β) (C : Type u) : Type max w u :=
GradedObject β C
namespace GradedObject
variable {C : Type u} [Category.{v} C]
@[simps!]
instance categoryOfGradedObjects (β : Type w) : Category.{max w v} (GradedObject β C) :=
CategoryTheory.pi fun _ => C
@[ext]
lemma hom_ext {β : Type*} {X Y : GradedObject β C} (f g : X ⟶ Y) (h : ∀ x, f x = g x) : f = g := by
funext
apply h
/-- The projection of a graded object to its `i`-th component. -/
@[simps]
def eval {β : Type w} (b : β) : GradedObject β C ⥤ C where
obj X := X b
map f := f b
section
variable {β : Type*} (X Y : GradedObject β C)
/-- Constructor for isomorphisms in `GradedObject` -/
@[simps]
def isoMk (e : ∀ i, X i ≅ Y i) : X ≅ Y where
hom i := (e i).hom
inv i := (e i).inv
variable {X Y}
-- this lemma is not an instance as it may create a loop with `isIso_apply_of_isIso`
lemma isIso_of_isIso_apply (f : X ⟶ Y) [hf : ∀ i, IsIso (f i)] :
IsIso f := by
change IsIso (isoMk X Y (fun i => asIso (f i))).hom
infer_instance
instance isIso_apply_of_isIso (f : X ⟶ Y) [IsIso f] (i : β) : IsIso (f i) := by
change IsIso ((eval i).map f)
infer_instance
end
end GradedObject
namespace Iso
variable {C D E J : Type*} [Category C] [Category D] [Category E]
{X Y : GradedObject J C}
@[reassoc (attr := simp)]
lemma hom_inv_id_eval (e : X ≅ Y) (j : J) :
e.hom j ≫ e.inv j = 𝟙 _ := by
rw [← GradedObject.categoryOfGradedObjects_comp, e.hom_inv_id,
GradedObject.categoryOfGradedObjects_id]
@[reassoc (attr := simp)]
lemma inv_hom_id_eval (e : X ≅ Y) (j : J) :
e.inv j ≫ e.hom j = 𝟙 _ := by
rw [← GradedObject.categoryOfGradedObjects_comp, e.inv_hom_id,
GradedObject.categoryOfGradedObjects_id]
@[reassoc (attr := simp)]
lemma map_hom_inv_id_eval (e : X ≅ Y) (F : C ⥤ D) (j : J) :
F.map (e.hom j) ≫ F.map (e.inv j) = 𝟙 _ := by
rw [← F.map_comp, ← GradedObject.categoryOfGradedObjects_comp, e.hom_inv_id,
GradedObject.categoryOfGradedObjects_id, Functor.map_id]
@[reassoc (attr := simp)]
lemma map_inv_hom_id_eval (e : X ≅ Y) (F : C ⥤ D) (j : J) :
F.map (e.inv j) ≫ F.map (e.hom j) = 𝟙 _ := by
rw [← F.map_comp, ← GradedObject.categoryOfGradedObjects_comp, e.inv_hom_id,
GradedObject.categoryOfGradedObjects_id, Functor.map_id]
@[reassoc (attr := simp)]
lemma map_hom_inv_id_eval_app (e : X ≅ Y) (F : C ⥤ D ⥤ E) (j : J) (Y : D) :
(F.map (e.hom j)).app Y ≫ (F.map (e.inv j)).app Y = 𝟙 _ := by
rw [← NatTrans.comp_app, ← F.map_comp, hom_inv_id_eval,
Functor.map_id, NatTrans.id_app]
@[reassoc (attr := simp)]
lemma map_inv_hom_id_eval_app (e : X ≅ Y) (F : C ⥤ D ⥤ E) (j : J) (Y : D) :
(F.map (e.inv j)).app Y ≫ (F.map (e.hom j)).app Y = 𝟙 _ := by
rw [← NatTrans.comp_app, ← F.map_comp, inv_hom_id_eval,
Functor.map_id, NatTrans.id_app]
end Iso
namespace GradedObject
variable {C : Type u} [Category.{v} C]
section
variable (C)
/-- Pull back an `I`-graded object in `C` to a `J`-graded object along a function `J → I`. -/
abbrev comap {I J : Type*} (h : J → I) : GradedObject I C ⥤ GradedObject J C :=
Pi.comap (fun _ => C) h
@[simp]
theorem eqToHom_proj {I : Type*} {x x' : GradedObject I C} (h : x = x') (i : I) :
(eqToHom h : x ⟶ x') i = eqToHom (funext_iff.mp h i) := by
subst h
rfl
/-- The natural isomorphism comparing between
pulling back along two propositionally equal functions.
-/
@[simps]
def comapEq {β γ : Type w} {f g : β → γ} (h : f = g) : comap C f ≅ comap C g where
hom := { app := fun X b => eqToHom (by dsimp; simp only [h]) }
inv := { app := fun X b => eqToHom (by dsimp; simp only [h]) }
theorem comapEq_symm {β γ : Type w} {f g : β → γ} (h : f = g) :
comapEq C h.symm = (comapEq C h).symm := by cat_disch
theorem comapEq_trans {β γ : Type w} {f g h : β → γ} (k : f = g) (l : g = h) :
comapEq C (k.trans l) = comapEq C k ≪≫ comapEq C l := by cat_disch
theorem eqToHom_apply {β : Type w} {X Y : β → C} (h : X = Y) (b : β) :
(eqToHom h : X ⟶ Y) b = eqToHom (by rw [h]) := by
subst h
rfl
/-- The equivalence between β-graded objects and γ-graded objects,
given an equivalence between β and γ.
-/
@[simps]
def comapEquiv {β γ : Type w} (e : β ≃ γ) : GradedObject β C ≌ GradedObject γ C where
functor := comap C (e.symm : γ → β)
inverse := comap C (e : β → γ)
counitIso :=
(Pi.comapComp (fun _ => C) _ _).trans (comapEq C (by ext; simp))
unitIso :=
(comapEq C (by ext; simp)).trans (Pi.comapComp _ _ _).symm
end
instance hasShift {β : Type*} [AddCommGroup β] (s : β) : HasShift (GradedObjectWithShift s C) ℤ :=
hasShiftMk _ _
{ F := fun n => comap C fun b : β => b + n • s
zero := comapEq C (by cat_disch) ≪≫ Pi.comapId β fun _ => C
add := fun m n => comapEq C (by ext; dsimp; rw [add_comm m n, add_zsmul, add_assoc]) ≪≫
(Pi.comapComp _ _ _).symm }
@[simp]
theorem shiftFunctor_obj_apply {β : Type*} [AddCommGroup β] (s : β) (X : β → C) (t : β) (n : ℤ) :
(shiftFunctor (GradedObjectWithShift s C) n).obj X t = X (t + n • s) :=
rfl
@[simp]
theorem shiftFunctor_map_apply {β : Type*} [AddCommGroup β] (s : β)
{X Y : GradedObjectWithShift s C} (f : X ⟶ Y) (t : β) (n : ℤ) :
(shiftFunctor (GradedObjectWithShift s C) n).map f t = f (t + n • s) :=
rfl
instance [HasZeroMorphisms C] (β : Type w) (X Y : GradedObject β C) : Zero (X ⟶ Y) :=
⟨fun _ => 0⟩
@[simp]
theorem zero_apply [HasZeroMorphisms C] (β : Type w) (X Y : GradedObject β C) (b : β) :
(0 : X ⟶ Y) b = 0 :=
rfl
instance hasZeroMorphisms [HasZeroMorphisms C] (β : Type w) :
HasZeroMorphisms.{max w v} (GradedObject β C) where
section
open ZeroObject
instance hasZeroObject [HasZeroObject C] [HasZeroMorphisms C] (β : Type w) :
HasZeroObject.{max w v} (GradedObject β C) := by
refine ⟨⟨fun _ => 0, fun X => ⟨⟨⟨fun b => 0⟩, fun f => ?_⟩⟩, fun X =>
⟨⟨⟨fun b => 0⟩, fun f => ?_⟩⟩⟩⟩ <;> cat_disch
end
end GradedObject
namespace GradedObject
-- The universes get a little hairy here, so we restrict the universe level for the grading to 0.
-- Since we're typically interested in grading by ℤ or a finite group, this should be okay.
-- If you're grading by things in higher universes, have fun!
variable (β : Type)
variable (C : Type u) [Category.{v} C]
variable [HasCoproducts.{0} C]
section
/-- The total object of a graded object is the coproduct of the graded components.
-/
noncomputable def total : GradedObject β C ⥤ C where
obj X := ∐ fun i : β => X i
map f := Limits.Sigma.map fun i => f i
end
variable [HasZeroMorphisms C]
/--
The `total` functor taking a graded object to the coproduct of its graded components is faithful.
To prove this, we need to know that the coprojections into the coproduct are monomorphisms,
which follows from the fact we have zero morphisms and decidable equality for the grading.
-/
instance : (total β C).Faithful where
map_injective {X Y} f g w := by
ext i
replace w := Sigma.ι (fun i : β => X i) i ≫= w
erw [colimit.ι_map, colimit.ι_map] at w
replace w : f i ≫ colimit.ι (Discrete.functor Y) ⟨i⟩ =
g i ≫ colimit.ι (Discrete.functor Y) ⟨i⟩ := by simpa
exact Mono.right_cancellation _ _ w
end GradedObject
namespace GradedObject
noncomputable section
variable (β : Type)
variable (C : Type (u + 1)) [LargeCategory C] [HasForget C] [HasCoproducts.{0} C]
[HasZeroMorphisms C]
instance : HasForget (GradedObject β C) where forget := total β C ⋙ forget C
instance : HasForget₂ (GradedObject β C) C where forget₂ := total β C
end
end GradedObject
namespace GradedObject
variable {I J K : Type*} {C : Type*} [Category C]
(X Y Z : GradedObject I C) (φ : X ⟶ Y) (e : X ≅ Y) (ψ : Y ⟶ Z) (p : I → J)
/-- If `X : GradedObject I C` and `p : I → J`, `X.mapObjFun p j` is the family of objects `X i`
for `i : I` such that `p i = j`. -/
abbrev mapObjFun (j : J) (i : p ⁻¹' {j}) : C := X i
variable (j : J)
/-- Given `X : GradedObject I C` and `p : I → J`, `X.HasMap p` is the condition that
for all `j : J`, the coproduct of all `X i` such `p i = j` exists. -/
abbrev HasMap : Prop := ∀ (j : J), HasCoproduct (X.mapObjFun p j)
variable {X Y} in
lemma hasMap_of_iso (e : X ≅ Y) (p : I → J) [HasMap X p] : HasMap Y p := fun j => by
have α : Discrete.functor (X.mapObjFun p j) ≅ Discrete.functor (Y.mapObjFun p j) :=
Discrete.natIso (fun ⟨i, _⟩ => (GradedObject.eval i).mapIso e)
exact hasColimit_of_iso α.symm
section
variable [X.HasMap p] [Y.HasMap p]
/-- Given `X : GradedObject I C` and `p : I → J`, `X.mapObj p` is the graded object by `J`
which in degree `j` consists of the coproduct of the `X i` such that `p i = j`. -/
noncomputable def mapObj : GradedObject J C := fun j => ∐ (X.mapObjFun p j)
/-- The canonical inclusion `X i ⟶ X.mapObj p j` when `i : I` and `j : J` are such
that `p i = j`. -/
noncomputable def ιMapObj (i : I) (j : J) (hij : p i = j) : X i ⟶ X.mapObj p j :=
Sigma.ι (X.mapObjFun p j) ⟨i, hij⟩
/-- Given `X : GradedObject I C`, `p : I → J` and `j : J`,
`CofanMapObjFun X p j` is the type `Cofan (X.mapObjFun p j)`. The point object of
such colimits cofans are isomorphic to `X.mapObj p j`, see `CofanMapObjFun.iso`. -/
abbrev CofanMapObjFun (j : J) : Type _ := Cofan (X.mapObjFun p j)
-- in order to use the cofan API, some definitions below
-- have a `simp` attribute rather than `simps`
/-- Constructor for `CofanMapObjFun X p j`. -/
@[simp]
def CofanMapObjFun.mk (j : J) (pt : C) (ι' : ∀ (i : I) (_ : p i = j), X i ⟶ pt) :
CofanMapObjFun X p j :=
Cofan.mk pt (fun ⟨i, hi⟩ => ι' i hi)
/-- The tautological cofan corresponding to the coproduct decomposition of `X.mapObj p j`. -/
@[simp]
noncomputable def cofanMapObj (j : J) : CofanMapObjFun X p j :=
CofanMapObjFun.mk X p j (X.mapObj p j) (fun i hi => X.ιMapObj p i j hi)
/-- Given `X : GradedObject I C`, `p : I → J` and `j : J`, `X.mapObj p j` satisfies
the universal property of the coproduct of those `X i` such that `p i = j`. -/
noncomputable def isColimitCofanMapObj (j : J) : IsColimit (X.cofanMapObj p j) :=
colimit.isColimit _
@[ext]
lemma mapObj_ext {A : C} {j : J} (f g : X.mapObj p j ⟶ A)
(hfg : ∀ (i : I) (hij : p i = j), X.ιMapObj p i j hij ≫ f = X.ιMapObj p i j hij ≫ g) :
f = g :=
Cofan.IsColimit.hom_ext (X.isColimitCofanMapObj p j) _ _ (fun ⟨i, hij⟩ => hfg i hij)
/-- This is the morphism `X.mapObj p j ⟶ A` constructed from a family of
morphisms `X i ⟶ A` for all `i : I` such that `p i = j`. -/
noncomputable def descMapObj {A : C} {j : J} (φ : ∀ (i : I) (_ : p i = j), X i ⟶ A) :
X.mapObj p j ⟶ A :=
Cofan.IsColimit.desc (X.isColimitCofanMapObj p j) (fun ⟨i, hi⟩ => φ i hi)
@[reassoc (attr := simp)]
lemma ι_descMapObj {A : C} {j : J}
(φ : ∀ (i : I) (_ : p i = j), X i ⟶ A) (i : I) (hi : p i = j) :
X.ιMapObj p i j hi ≫ X.descMapObj p φ = φ i hi := by
apply Cofan.IsColimit.fac
end
namespace CofanMapObjFun
lemma hasMap (c : ∀ j, CofanMapObjFun X p j) (hc : ∀ j, IsColimit (c j)) :
X.HasMap p := fun j => ⟨_, hc j⟩
variable {j X p}
variable [X.HasMap p]
variable {c : CofanMapObjFun X p j} (hc : IsColimit c)
/-- If `c : CofanMapObjFun X p j` is a colimit cofan, this is the induced
isomorphism `c.pt ≅ X.mapObj p j`. -/
noncomputable def iso : c.pt ≅ X.mapObj p j :=
IsColimit.coconePointUniqueUpToIso hc (X.isColimitCofanMapObj p j)
@[reassoc (attr := simp)]
lemma inj_iso_hom (i : I) (hi : p i = j) :
c.inj ⟨i, hi⟩ ≫ (c.iso hc).hom = X.ιMapObj p i j hi := by
apply IsColimit.comp_coconePointUniqueUpToIso_hom
@[reassoc (attr := simp)]
lemma ιMapObj_iso_inv (i : I) (hi : p i = j) :
X.ιMapObj p i j hi ≫ (c.iso hc).inv = c.inj ⟨i, hi⟩ := by
apply IsColimit.comp_coconePointUniqueUpToIso_inv
end CofanMapObjFun
variable {X Y}
variable [X.HasMap p] [Y.HasMap p]
/-- The canonical morphism of `J`-graded objects `X.mapObj p ⟶ Y.mapObj p` induced by
a morphism `X ⟶ Y` of `I`-graded objects and a map `p : I → J`. -/
noncomputable def mapMap : X.mapObj p ⟶ Y.mapObj p := fun j =>
X.descMapObj p (fun i hi => φ i ≫ Y.ιMapObj p i j hi)
@[reassoc (attr := simp)]
lemma ι_mapMap (i : I) (j : J) (hij : p i = j) :
X.ιMapObj p i j hij ≫ mapMap φ p j = φ i ≫ Y.ιMapObj p i j hij := by
simp only [mapMap, ι_descMapObj]
lemma congr_mapMap (φ₁ φ₂ : X ⟶ Y) (h : φ₁ = φ₂) : mapMap φ₁ p = mapMap φ₂ p := by
subst h
rfl
variable (X)
@[simp]
lemma mapMap_id : mapMap (𝟙 X) p = 𝟙 _ := by cat_disch
variable {X Z}
@[simp, reassoc]
lemma mapMap_comp [Z.HasMap p] : mapMap (φ ≫ ψ) p = mapMap φ p ≫ mapMap ψ p := by cat_disch
/-- The isomorphism of `J`-graded objects `X.mapObj p ≅ Y.mapObj p` induced by an
isomorphism `X ≅ Y` of graded objects and a map `p : I → J`. -/
@[simps]
noncomputable def mapIso : X.mapObj p ≅ Y.mapObj p where
hom := mapMap e.hom p
inv := mapMap e.inv p
variable (C)
/-- Given a map `p : I → J`, this is the functor `GradedObject I C ⥤ GradedObject J C` which
sends an `I`-object `X` to the graded object `X.mapObj p` which in degree `j : J` is given
by the coproduct of those `X i` such that `p i = j`. -/
@[simps]
noncomputable def map [∀ (j : J), HasColimitsOfShape (Discrete (p ⁻¹' {j})) C] :
GradedObject I C ⥤ GradedObject J C where
obj X := X.mapObj p
map φ := mapMap φ p
variable {C} (X Y)
variable (q : J → K) (r : I → K) (hpqr : ∀ i, q (p i) = r i)
section
variable (k : K) (c : ∀ (j : J), q j = k → X.CofanMapObjFun p j)
(hc : ∀ j hj, IsColimit (c j hj))
(c' : Cofan (fun (j : q ⁻¹' {k}) => (c j.1 j.2).pt)) (hc' : IsColimit c')
/-- Given maps `p : I → J`, `q : J → K` and `r : I → K` such that `q.comp p = r`,
`X : GradedObject I C`, `k : K`, the datum of cofans `X.CofanMapObjFun p j` for all
`j : J` and of a cofan for all the points of these cofans, this is a cofan of
type `X.CofanMapObjFun r k`, which is a colimit (see `isColimitCofanMapObjComp`) if the
given cofans are. -/
@[simp]
def cofanMapObjComp : X.CofanMapObjFun r k :=
CofanMapObjFun.mk _ _ _ c'.pt (fun i hi =>
(c (p i) (by rw [hpqr, hi])).inj ⟨i, rfl⟩ ≫ c'.inj (⟨p i, by
rw [Set.mem_preimage, Set.mem_singleton_iff, hpqr, hi]⟩))
/-- Given maps `p : I → J`, `q : J → K` and `r : I → K` such that `q.comp p = r`,
`X : GradedObject I C`, `k : K`, the cofan constructed by `cofanMapObjComp` is a colimit.
In other words, if we have, for all `j : J` such that `hj : q j = k`,
a colimit cofan `c j hj` which computes the coproduct of the `X i` such that `p i = j`,
and also a colimit cofan which computes the coproduct of the points of these `c j hj`, then
the point of this latter cofan computes the coproduct of the `X i` such that `r i = k`. -/
@[simp]
def isColimitCofanMapObjComp :
IsColimit (cofanMapObjComp X p q r hpqr k c c') :=
mkCofanColimit _
(fun s => Cofan.IsColimit.desc hc'
(fun ⟨j, (hj : q j = k)⟩ => Cofan.IsColimit.desc (hc j hj)
(fun ⟨i, (hi : p i = j)⟩ => s.inj ⟨i, by
simp only [Set.mem_preimage, Set.mem_singleton_iff, ← hpqr, hi, hj]⟩)))
(fun s ⟨i, (hi : r i = k)⟩ => by simp)
(fun s m hm => by
apply Cofan.IsColimit.hom_ext hc'
rintro ⟨j, rfl : q j = k⟩
apply Cofan.IsColimit.hom_ext (hc j rfl)
rintro ⟨i, rfl : p i = j⟩
dsimp
rw [Cofan.IsColimit.fac, Cofan.IsColimit.fac, ← hm]
dsimp
rw [assoc])
include hpqr in
lemma hasMap_comp [(X.mapObj p).HasMap q] : X.HasMap r :=
fun k => ⟨_, isColimitCofanMapObjComp X p q r hpqr k _
(fun j _ => X.isColimitCofanMapObj p j) _ ((X.mapObj p).isColimitCofanMapObj q k)⟩
end
variable [HasZeroMorphisms C] [DecidableEq J] (i : I) (j : J)
/-- The canonical inclusion `X i ⟶ X.mapObj p j` when `p i = j`, the zero morphism otherwise. -/
noncomputable def ιMapObjOrZero : X i ⟶ X.mapObj p j :=
if h : p i = j
then X.ιMapObj p i j h
else 0
lemma ιMapObjOrZero_eq (h : p i = j) : X.ιMapObjOrZero p i j = X.ιMapObj p i j h := dif_pos h
lemma ιMapObjOrZero_eq_zero (h : p i ≠ j) : X.ιMapObjOrZero p i j = 0 := dif_neg h
variable {X Y} in
@[reassoc (attr := simp)]
lemma ιMapObjOrZero_mapMap :
X.ιMapObjOrZero p i j ≫ mapMap φ p j = φ i ≫ Y.ιMapObjOrZero p i j := by
by_cases h : p i = j
· simp only [ιMapObjOrZero_eq _ _ _ _ h, ι_mapMap]
· simp only [ιMapObjOrZero_eq_zero _ _ _ _ h, zero_comp, comp_zero]
end GradedObject
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/PUnit.lean | import Mathlib.CategoryTheory.Functor.Const
import Mathlib.CategoryTheory.Discrete.Basic
/-!
# The category `Discrete PUnit`
We define `star : C ⥤ Discrete PUnit` sending everything to `PUnit.star`,
show that any two functors to `Discrete PUnit` are naturally isomorphic,
and construct the equivalence `(Discrete PUnit ⥤ C) ≌ C`.
-/
universe w v u
-- morphism levels before object levels. See note [category theory universes].
namespace CategoryTheory
variable (C : Type u) [Category.{v} C]
namespace Functor
/-- The constant functor sending everything to `PUnit.star`. -/
@[simps!]
def star : C ⥤ Discrete PUnit.{w + 1} :=
(Functor.const _).obj ⟨⟨⟩⟩
variable {C}
/-- Any two functors to `Discrete PUnit` are isomorphic. -/
@[simps!]
def punitExt (F G : C ⥤ Discrete PUnit.{w + 1}) : F ≅ G :=
NatIso.ofComponents fun X => eqToIso (by simp only [eq_iff_true_of_subsingleton])
/-- Any two functors to `Discrete PUnit` are *equal*.
You probably want to use `punitExt` instead of this. -/
theorem punit_ext' (F G : C ⥤ Discrete PUnit.{w + 1}) : F = G :=
Functor.ext fun X => by simp only [eq_iff_true_of_subsingleton]
/-- The functor from `Discrete PUnit` sending everything to the given object. -/
abbrev fromPUnit (X : C) : Discrete PUnit.{w + 1} ⥤ C :=
(Functor.const _).obj X
/-- Functors from `Discrete PUnit` are equivalent to the category itself. -/
@[simps]
def equiv : Discrete PUnit.{w + 1} ⥤ C ≌ C where
functor :=
{ obj := fun F => F.obj ⟨⟨⟩⟩
map := fun θ => θ.app ⟨⟨⟩⟩ }
inverse := Functor.const _
unitIso := NatIso.ofComponents fun _ => Discrete.natIso fun _ => Iso.refl _
counitIso := NatIso.ofComponents Iso.refl
end Functor
/-- A category being equivalent to `PUnit` is equivalent to it having a unique morphism between
any two objects. (In fact, such a category is also a groupoid;
see `CategoryTheory.Groupoid.ofHomUnique`) -/
theorem equiv_punit_iff_unique :
Nonempty (C ≌ Discrete PUnit.{w + 1}) ↔ Nonempty C ∧ ∀ x y : C, Nonempty <| Unique (x ⟶ y) := by
constructor
· rintro ⟨h⟩
refine ⟨⟨h.inverse.obj ⟨⟨⟩⟩⟩, fun x y => Nonempty.intro ?_⟩
let f : x ⟶ y := by
have hx : x ⟶ h.inverse.obj ⟨⟨⟩⟩ := by convert h.unit.app x
have hy : h.inverse.obj ⟨⟨⟩⟩ ⟶ y := by convert h.unitInv.app y
exact hx ≫ hy
suffices sub : Subsingleton (x ⟶ y) from uniqueOfSubsingleton f
have : ∀ z, z = h.unit.app x ≫ (h.functor ⋙ h.inverse).map z ≫ h.unitInv.app y := by
intro z
simp
apply Subsingleton.intro
intro a b
rw [this a, this b]
simp only [Functor.comp_map]
congr 3
apply ULift.ext
simp [eq_iff_true_of_subsingleton]
· rintro ⟨⟨p⟩, h⟩
haveI := fun x y => (h x y).some
refine
Nonempty.intro
(CategoryTheory.Equivalence.mk ((Functor.const _).obj ⟨⟨⟩⟩)
((@Functor.const <| Discrete PUnit).obj p) ?_ (by apply Functor.punitExt))
exact
NatIso.ofComponents fun _ =>
{ hom := default
inv := default }
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/ExtremalEpi.lean | import Mathlib.CategoryTheory.Subobject.Lattice
import Mathlib.CategoryTheory.Limits.Shapes.StrongEpi
/-!
# Extremal epimorphisms
An extremal epimorphism `p : X ⟶ Y` is an epimorphism which does not factor
through any proper subobject of `Y`. In case the category has equalizers,
we show that a morphism `p : X ⟶ Y` which does not factor through
any proper subobject of `Y` is automatically an epimorphism, and also
an extremal epimorphism. We also show that a strong epimorphism
is an extremal epimorphism, and that both notions coincide when
the category has pullbacks.
## References
* https://ncatlab.org/nlab/show/extremal+epimorphism
-/
universe v u
namespace CategoryTheory
open Limits
variable {C : Type u} [Category.{v} C] {X Y : C}
/-- An extremal epimorphism `f : X ⟶ Y` is an epimorphism which does not
factor through any proper subobject of `Y`. -/
class ExtremalEpi (f : X ⟶ Y) : Prop extends Epi f where
isIso (f) {Z : C} (p : X ⟶ Z) (i : Z ⟶ Y) (fac : p ≫ i = f) [Mono i] : IsIso i
variable (f : X ⟶ Y)
lemma ExtremalEpi.subobject_eq_top [ExtremalEpi f]
{A : Subobject Y} (hA : Subobject.Factors A f) : A = ⊤ := by
rw [← Subobject.isIso_arrow_iff_eq_top]
exact isIso f (Subobject.factorThru A f hA) _ (by simp)
lemma ExtremalEpi.mk_of_hasEqualizers [HasEqualizers C]
(hf : ∀ ⦃Z : C⦄ (p : X ⟶ Z) (i : Z ⟶ Y) (_ : p ≫ i = f) [Mono i], IsIso i) :
ExtremalEpi f where
left_cancellation {Z} p q h := by
have := hf (equalizer.lift f h) (equalizer.ι p q) (by simp)
rw [← cancel_epi (equalizer.ι p q), equalizer.condition]
isIso := by tauto
instance [StrongEpi f] : ExtremalEpi f where
isIso {Z} p i fac _ := by
have sq : CommSq p f i (𝟙 Y) := { }
exact ⟨sq.lift, by simp [← cancel_mono i], by simp⟩
lemma extremalEpi_iff_strongEpi_of_hasPullbacks [HasPullbacks C] :
ExtremalEpi f ↔ StrongEpi f := by
refine ⟨fun _ ↦ ⟨inferInstance, fun A B i _ ↦ ⟨fun {t b} sq ↦ ⟨⟨?_⟩⟩⟩⟩,
fun _ ↦ inferInstance⟩
have := ExtremalEpi.isIso f (pullback.lift _ _ sq.w)
(pullback.snd _ _) (by simp)
exact
{ l := inv (pullback.snd i b) ≫ pullback.fst _ _
fac_left := by
rw [← cancel_mono i, sq.w, Category.assoc, Category.assoc]
congr 1
rw [← cancel_epi (pullback.snd i b), IsIso.hom_inv_id_assoc,
pullback.condition]
fac_right := by simp [pullback.condition] }
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/NatTrans.lean | import Mathlib.Tactic.CategoryTheory.Reassoc
/-!
# Natural transformations
Defines natural transformations between functors.
A natural transformation `α : NatTrans F G` consists of morphisms `α.app X : F.obj X ⟶ G.obj X`,
and the naturality squares `α.naturality f : F.map f ≫ α.app Y = α.app X ≫ G.map f`,
where `f : X ⟶ Y`.
Note that we make `NatTrans.naturality` a simp lemma, with the preferred simp normal form
pushing components of natural transformations to the left.
See also `CategoryTheory.FunctorCat`, where we provide the category structure on
functors and natural transformations.
Introduces notations
* `τ.app X` for the components of natural transformations,
* `F ⟶ G` for the type of natural transformations between functors `F` and `G`
(this and the next require `CategoryTheory.FunctorCat`),
* `σ ≫ τ` for vertical compositions, and
* `σ ◫ τ` for horizontal compositions.
-/
set_option mathlib.tactic.category.grind true
namespace CategoryTheory
-- declare the `v`'s first; see note [category theory universes].
universe v₁ v₂ v₃ v₄ u₁ u₂ u₃ u₄
variable {C : Type u₁} [Category.{v₁} C] {D : Type u₂} [Category.{v₂} D]
/-- `NatTrans F G` represents a natural transformation between functors `F` and `G`.
The field `app` provides the components of the natural transformation.
Naturality is expressed by `α.naturality`.
-/
@[ext]
structure NatTrans (F G : C ⥤ D) : Type max u₁ v₂ where
/-- The component of a natural transformation. -/
app : ∀ X : C, F.obj X ⟶ G.obj X
/-- The naturality square for a given morphism. -/
naturality : ∀ ⦃X Y : C⦄ (f : X ⟶ Y), F.map f ≫ app Y = app X ≫ G.map f := by cat_disch
-- Rather arbitrarily, we say that the 'simpler' form is
-- components of natural transformations moving earlier.
attribute [reassoc (attr := simp)] NatTrans.naturality
attribute [grind _=_] NatTrans.naturality
theorem congr_app {F G : C ⥤ D} {α β : NatTrans F G} (h : α = β) (X : C) : α.app X = β.app X := by
cat_disch
namespace NatTrans
/-- `NatTrans.id F` is the identity natural transformation on a functor `F`. -/
protected def id (F : C ⥤ D) : NatTrans F F where app X := 𝟙 (F.obj X)
@[simp]
theorem id_app' (F : C ⥤ D) (X : C) : (NatTrans.id F).app X = 𝟙 (F.obj X) := rfl
instance (F : C ⥤ D) : Inhabited (NatTrans F F) := ⟨NatTrans.id F⟩
open Category
open CategoryTheory.Functor
section
variable {F G H : C ⥤ D}
/-- `vcomp α β` is the vertical compositions of natural transformations. -/
def vcomp (α : NatTrans F G) (β : NatTrans G H) : NatTrans F H where
app X := α.app X ≫ β.app X
-- functor_category will rewrite (vcomp α β) to (α ≫ β), so this is not a
-- suitable simp lemma. We will declare the variant vcomp_app' there.
theorem vcomp_app (α : NatTrans F G) (β : NatTrans G H) (X : C) :
(vcomp α β).app X = α.app X ≫ β.app X := rfl
attribute [grind =] vcomp_app
end
/-- The diagram
```
F(f) F(g) F(h)
F X ----> F Y ----> F U ----> F U
| | | |
| α(X) | α(Y) | α(U) | α(V)
v v v v
G X ----> G Y ----> G U ----> G V
G(f) G(g) G(h)
```
commutes.
-/
example {F G : C ⥤ D} (α : NatTrans F G) {X Y U V : C} (f : X ⟶ Y) (g : Y ⟶ U) (h : U ⟶ V) :
α.app X ≫ G.map f ≫ G.map g ≫ G.map h = F.map f ≫ F.map g ≫ F.map h ≫ α.app V := by
grind
end NatTrans
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Subterminal.lean | import Mathlib.CategoryTheory.Limits.Shapes.BinaryProducts
import Mathlib.CategoryTheory.Limits.Shapes.Terminal
import Mathlib.CategoryTheory.Subobject.MonoOver
/-!
# Subterminal objects
Subterminal objects are the objects which can be thought of as subobjects of the terminal object.
In fact, the definition can be constructed to not require a terminal object, by defining `A` to be
subterminal iff for any `Z`, there is at most one morphism `Z ⟶ A`.
An alternate definition is that the diagonal morphism `A ⟶ A ⨯ A` is an isomorphism.
In this file we define subterminal objects and show the equivalence of these three definitions.
We also construct the subcategory of subterminal objects.
## TODO
* Define exponential ideals, and show this subcategory is an exponential ideal.
* Use the above to show that in a locally Cartesian closed category, every subobject lattice
is Cartesian closed (equivalently, a Heyting algebra).
-/
universe v₁ v₂ u₁ u₂
noncomputable section
namespace CategoryTheory
open Limits Category
variable {C : Type u₁} [Category.{v₁} C] {A : C}
/-- An object `A` is subterminal iff for any `Z`, there is at most one morphism `Z ⟶ A`. -/
def IsSubterminal (A : C) : Prop :=
∀ ⦃Z : C⦄ (f g : Z ⟶ A), f = g
theorem IsSubterminal.def : IsSubterminal A ↔ ∀ ⦃Z : C⦄ (f g : Z ⟶ A), f = g :=
Iff.rfl
/-- If `A` is subterminal, the unique morphism from it to a terminal object is a monomorphism.
The converse of `isSubterminal_of_mono_isTerminal_from`.
-/
theorem IsSubterminal.mono_isTerminal_from (hA : IsSubterminal A) {T : C} (hT : IsTerminal T) :
Mono (hT.from A) :=
{ right_cancellation := fun _ _ _ => hA _ _ }
/-- If `A` is subterminal, the unique morphism from it to the terminal object is a monomorphism.
The converse of `isSubterminal_of_mono_terminal_from`.
-/
theorem IsSubterminal.mono_terminal_from [HasTerminal C] (hA : IsSubterminal A) :
Mono (terminal.from A) :=
hA.mono_isTerminal_from terminalIsTerminal
/-- If the unique morphism from `A` to a terminal object is a monomorphism, `A` is subterminal.
The converse of `IsSubterminal.mono_isTerminal_from`.
-/
theorem isSubterminal_of_mono_isTerminal_from {T : C} (hT : IsTerminal T) [Mono (hT.from A)] :
IsSubterminal A := fun Z f g => by
rw [← cancel_mono (hT.from A)]
apply hT.hom_ext
/-- If the unique morphism from `A` to the terminal object is a monomorphism, `A` is subterminal.
The converse of `IsSubterminal.mono_terminal_from`.
-/
theorem isSubterminal_of_mono_terminal_from [HasTerminal C] [Mono (terminal.from A)] :
IsSubterminal A := fun Z f g => by
rw [← cancel_mono (terminal.from A)]
subsingleton
theorem isSubterminal_of_isTerminal {T : C} (hT : IsTerminal T) : IsSubterminal T := fun _ _ _ =>
hT.hom_ext _ _
theorem isSubterminal_of_terminal [HasTerminal C] : IsSubterminal (⊤_ C) := fun _ _ _ => by
subsingleton
/-- If `A` is subterminal, its diagonal morphism is an isomorphism.
The converse of `isSubterminal_of_isIso_diag`.
-/
theorem IsSubterminal.isIso_diag (hA : IsSubterminal A) [HasBinaryProduct A A] : IsIso (diag A) :=
⟨⟨Limits.prod.fst,
⟨by simp, by
rw [IsSubterminal.def] at hA
cat_disch⟩⟩⟩
/-- If the diagonal morphism of `A` is an isomorphism, then it is subterminal.
The converse of `isSubterminal.isIso_diag`.
-/
theorem isSubterminal_of_isIso_diag [HasBinaryProduct A A] [IsIso (diag A)] : IsSubterminal A :=
fun Z f g => by
have : (Limits.prod.fst : A ⨯ A ⟶ _) = Limits.prod.snd := by simp [← cancel_epi (diag A)]
rw [← prod.lift_fst f g, this, prod.lift_snd]
/-- If `A` is subterminal, it is isomorphic to `A ⨯ A`. -/
@[simps!]
def IsSubterminal.isoDiag (hA : IsSubterminal A) [HasBinaryProduct A A] : A ⨯ A ≅ A := by
letI := IsSubterminal.isIso_diag hA
apply (asIso (diag A)).symm
variable (C)
/-- The (full sub)category of subterminal objects.
TODO: If `C` is the category of sheaves on a topological space `X`, this category is equivalent
to the lattice of open subsets of `X`. More generally, if `C` is a topos, this is the lattice of
"external truth values".
-/
def Subterminals (C : Type u₁) [Category.{v₁} C] :=
ObjectProperty.FullSubcategory fun A : C => IsSubterminal A
instance (C : Type u₁) [Category.{v₁} C] : Category (Subterminals C) :=
ObjectProperty.FullSubcategory.category _
instance [HasTerminal C] : Inhabited (Subterminals C) :=
⟨⟨⊤_ C, isSubterminal_of_terminal⟩⟩
/-- The inclusion of the subterminal objects into the original category. -/
@[simps!]
def subterminalInclusion : Subterminals C ⥤ C :=
ObjectProperty.ι _
instance (C : Type u₁) [Category.{v₁} C] : (subterminalInclusion C).Full :=
ObjectProperty.full_ι _
instance (C : Type u₁) [Category.{v₁} C] : (subterminalInclusion C).Faithful :=
ObjectProperty.faithful_ι _
instance subterminals_thin (X Y : Subterminals C) : Subsingleton (X ⟶ Y) :=
⟨fun f g => Y.2 f g⟩
/--
The category of subterminal objects is equivalent to the category of monomorphisms to the terminal
object (which is in turn equivalent to the subobjects of the terminal object).
-/
@[simps]
def subterminalsEquivMonoOverTerminal [HasTerminal C] : Subterminals C ≌ MonoOver (⊤_ C) where
functor :=
{ obj := fun X => ⟨Over.mk (terminal.from X.1), X.2.mono_terminal_from⟩
map := fun f => MonoOver.homMk f (by ext1 ⟨⟨⟩⟩) }
inverse :=
{ obj := fun X =>
⟨X.obj.left, fun Z f g => by
rw [← cancel_mono X.arrow]
subsingleton⟩
map := fun f => f.1 }
unitIso := NatIso.ofComponents (fun X => Iso.refl X) (by subsingleton)
counitIso := NatIso.ofComponents (fun X => MonoOver.isoMk (Iso.refl _)) (by subsingleton)
functor_unitIso_comp := by subsingleton
@[simp]
theorem subterminals_to_monoOver_terminal_comp_forget [HasTerminal C] :
(subterminalsEquivMonoOverTerminal C).functor ⋙ MonoOver.forget _ ⋙ Over.forget _ =
subterminalInclusion C :=
rfl
@[simp]
theorem monoOver_terminal_to_subterminals_comp [HasTerminal C] :
(subterminalsEquivMonoOverTerminal C).inverse ⋙ subterminalInclusion C =
MonoOver.forget _ ⋙ Over.forget _ :=
rfl
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Elementwise.lean | import Mathlib.Tactic.CategoryTheory.Elementwise
import Mathlib.CategoryTheory.ConcreteCategory.Basic
/-!
# Use the `elementwise` attribute to create applied versions of lemmas.
Usually we would use `@[elementwise]` at the point of definition,
however some early parts of the category theory library are imported by `Tactic.Elementwise`,
so we need to add the attribute after the fact.
-/
/-! We now add some `elementwise` attributes to lemmas that were proved earlier. -/
open CategoryTheory
attribute [elementwise (attr := simp)] Iso.hom_inv_id Iso.inv_hom_id
-- This list is incomplete, and it would probably be useful to add more.
set_option linter.existingAttributeWarning false in
attribute [elementwise (attr := simp)] IsIso.hom_inv_id IsIso.inv_hom_id |
.lake/packages/mathlib/Mathlib/CategoryTheory/UnivLE.lean | import Mathlib.CategoryTheory.EssentialImage
import Mathlib.CategoryTheory.Types.Basic
import Mathlib.Logic.UnivLE
/-!
# Universe inequalities and essential surjectivity of `uliftFunctor`.
We show `UnivLE.{max u v, v} ↔ EssSurj (uliftFunctor.{u, v} : Type v ⥤ Type max u v)`.
-/
open CategoryTheory
universe u v
noncomputable section
theorem UnivLE.ofEssSurj (w : (uliftFunctor.{u, v} : Type v ⥤ Type max u v).EssSurj) :
UnivLE.{max u v, v} where
small α := by
obtain ⟨a', ⟨m⟩⟩ := w.mem_essImage α
exact ⟨a', ⟨(Iso.toEquiv m).symm.trans Equiv.ulift⟩⟩
instance EssSurj.ofUnivLE [UnivLE.{max u v, v}] :
(uliftFunctor.{u, v} : Type v ⥤ Type max u v).EssSurj where
mem_essImage α :=
⟨Shrink α, ⟨Equiv.toIso (Equiv.ulift.trans (equivShrink α).symm)⟩⟩
theorem UnivLE_iff_essSurj :
UnivLE.{max u v, v} ↔ (uliftFunctor.{u, v} : Type v ⥤ Type max u v).EssSurj :=
⟨fun _ => inferInstance, fun w => UnivLE.ofEssSurj w⟩
instance [UnivLE.{max u v, v}] : uliftFunctor.{u, v}.IsEquivalence where
def UnivLE.witness [UnivLE.{max u v, v}] : Type u ⥤ Type v :=
uliftFunctor.{v, u} ⋙ (uliftFunctor.{u, v}).inv
instance [UnivLE.{max u v, v}] : UnivLE.witness.{u, v}.Faithful :=
inferInstanceAs <| Functor.Faithful (_ ⋙ _)
instance [UnivLE.{max u v, v}] : UnivLE.witness.{u, v}.Full :=
inferInstanceAs <| Functor.Full (_ ⋙ _) |
.lake/packages/mathlib/Mathlib/CategoryTheory/CodiscreteCategory.lean | import Mathlib.CategoryTheory.EqToHom
import Mathlib.CategoryTheory.Pi.Basic
import Mathlib.Data.ULift
import Mathlib.CategoryTheory.Category.Cat
import Mathlib.CategoryTheory.Adjunction.Basic
/-!
# Codiscrete categories
We define `Codiscrete A` as an alias for the type `A`,
and use this type alias to provide a `Category` instance
whose Hom type are Unit types.
`Codiscrete.functor` promotes a function `f : C → A` (for any category `C`) to a functor
`f : C ⥤ Codiscrete A`.
Similarly, `Codiscrete.natTrans` and `Codiscrete.natIso` promote `I`-indexed families of morphisms,
or `I`-indexed families of isomorphisms to natural transformations or natural isomorphisms.
We define `functorToCat : Type u ⥤ Cat.{0,u}` which sends a type to the codiscrete category and show
it is right adjoint to `Cat.objects.`
-/
namespace CategoryTheory
universe u v w
-- This is intentionally a structure rather than a type synonym
-- to enforce using `CodiscreteEquiv` (or `Codiscrete.mk` and `Codiscrete.as`) to move between
-- `Codiscrete α` and `α`. Otherwise there is too much API leakage.
/-- A wrapper for promoting any type to a category,
with a unique morphism between any two objects of the category.
-/
@[ext, aesop safe cases (rule_sets := [CategoryTheory])]
structure Codiscrete (α : Type u) where
/-- A wrapper for promoting any type to a category,
with a unique morphism between any two objects of the category. -/
as : α
@[simp]
theorem Codiscrete.mk_as {α : Type u} (X : Codiscrete α) : Codiscrete.mk X.as = X := rfl
/-- `Codiscrete α` is equivalent to the original type `α`. -/
@[simps]
def codiscreteEquiv {α : Type u} : Codiscrete α ≃ α where
toFun := Codiscrete.as
invFun := Codiscrete.mk
left_inv := by cat_disch
right_inv := by cat_disch
instance {α : Type u} [DecidableEq α] : DecidableEq (Codiscrete α) :=
codiscreteEquiv.decidableEq
namespace Codiscrete
instance (A : Type*) : Category (Codiscrete A) where
Hom _ _ := Unit
id _ := ⟨⟩
comp _ _ := ⟨⟩
section
variable {C : Type u} [Category.{v} C] {A : Type w}
/-- Any function `C → A` lifts to a functor `C ⥤ Codiscrete A`. -/
def functor (F : C → A) : C ⥤ Codiscrete A where
obj := Codiscrete.mk ∘ F
map _ := ⟨⟩
/-- The underlying function `C → A` of a functor `C ⥤ Codiscrete A`. -/
def invFunctor (F : C ⥤ Codiscrete A) : C → A := Codiscrete.as ∘ F.obj
/-- Given two functors to a codiscrete category, there is a trivial natural transformation. -/
def natTrans {F G : C ⥤ Codiscrete A} : F ⟶ G where
app _ := ⟨⟩
/-- Given two functors into a codiscrete category, the trivial natural transformation is a
natural isomorphism. -/
def natIso {F G : C ⥤ Codiscrete A} : F ≅ G where
hom := natTrans
inv := natTrans
/-- Every functor `F` to a codiscrete category is naturally isomorphic {(actually, equal)} to
`Codiscrete.as ∘ F.obj`. -/
@[simps!]
def natIsoFunctor {F : C ⥤ Codiscrete A} : F ≅ functor (Codiscrete.as ∘ F.obj) := Iso.refl _
end
/-- A function induces a functor between codiscrete categories. -/
def functorOfFun {A B : Type*} (f : A → B) : Codiscrete A ⥤ Codiscrete B :=
functor (f ∘ Codiscrete.as)
open Opposite
/-- A codiscrete category is equivalent to its opposite category. -/
def oppositeEquivalence (A : Type*) : (Codiscrete A)ᵒᵖ ≌ Codiscrete A where
functor := functor (fun x ↦ Codiscrete.as x.unop)
inverse := (functor (fun x ↦ Codiscrete.as x.unop)).rightOp
unitIso := NatIso.ofComponents (fun _ => by exact Iso.refl _)
counitIso := natIso
/-- `Codiscrete.functorToCat` turns a type into a codiscrete category. -/
def functorToCat : Type u ⥤ Cat.{0,u} where
obj A := Cat.of (Codiscrete A)
map := functorOfFun
open Adjunction Cat
/-- For a category `C` and type `A`, there is an equivalence between functions `objects.obj C ⟶ A`
and functors `C ⥤ Codiscrete A`. -/
def equivFunctorToCodiscrete {C : Type u} [Category.{v} C] {A : Type w} :
(C → A) ≃ (C ⥤ Codiscrete A) where
toFun := functor
invFun := invFunctor
/-- The functor that turns a type into a codiscrete category is right adjoint to the objects
functor. -/
def adj : objects ⊣ functorToCat := mkOfHomEquiv {
homEquiv := fun _ _ => equivFunctorToCodiscrete
homEquiv_naturality_left_symm := fun _ _ => rfl
homEquiv_naturality_right := fun _ _ => rfl }
/-- Components of the unit of the adjunction `Cat.objects ⊣ Codiscrete.functorToCat`. -/
def unitApp (C : Type u) [Category.{v} C] : C ⥤ Codiscrete C := functor id
/-- Components of the counit of the adjunction `Cat.objects ⊣ Codiscrete.functorToCat` -/
def counitApp (A : Type u) : Codiscrete A → A := Codiscrete.as
lemma adj_unit_app (X : Cat.{0, u}) :
adj.unit.app X = unitApp X := rfl
lemma adj_counit_app (A : Type u) :
adj.counit.app A = counitApp A := rfl
/-- Left triangle equality of the adjunction `Cat.objects ⊣ Codiscrete.functorToCat`,
as a universe polymorphic statement. -/
lemma left_triangle_components (C : Type u) [Category.{v} C] :
(counitApp C).comp (unitApp C).obj = id :=
rfl
/-- Right triangle equality of the adjunction `Cat.objects ⊣ Codiscrete.functorToCat`,
stated using a composition of functors. -/
lemma right_triangle_components (X : Type u) :
unitApp (Codiscrete X) ⋙ functorOfFun (counitApp X) = 𝟭 (Codiscrete X) :=
rfl
end Codiscrete
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/FullSubcategory.lean | import Mathlib.CategoryTheory.Functor.FullyFaithful
deprecated_module "Auto-generated deprecation" (since := "2025-04-23") |
.lake/packages/mathlib/Mathlib/CategoryTheory/Groupoid.lean | import Mathlib.CategoryTheory.ObjectProperty.FullSubcategory
import Mathlib.CategoryTheory.Products.Basic
import Mathlib.CategoryTheory.Pi.Basic
import Mathlib.CategoryTheory.Category.Basic
import Mathlib.Combinatorics.Quiver.Symmetric
import Mathlib.CategoryTheory.Functor.ReflectsIso.Basic
import Mathlib.CategoryTheory.MorphismProperty.Basic
/-!
# Groupoids
We define `Groupoid` as a typeclass extending `Category`,
asserting that all morphisms have inverses.
The instance `IsIso.ofGroupoid (f : X ⟶ Y) : IsIso f` means that you can then write
`inv f` to access the inverse of any morphism `f`.
`Groupoid.isoEquivHom : (X ≅ Y) ≃ (X ⟶ Y)` provides the equivalence between
isomorphisms and morphisms in a groupoid.
We provide a (non-instance) constructor `Groupoid.ofIsIso` from an existing category
with `IsIso f` for every `f`.
## See also
See also `CategoryTheory.Core` for the groupoid of isomorphisms in a category.
-/
namespace CategoryTheory
universe v v₂ u u₂
-- morphism levels before object levels. See note [category theory universes].
/-- A `Groupoid` is a category such that all morphisms are isomorphisms. -/
class Groupoid (obj : Type u) : Type max u (v + 1) extends Category.{v} obj where
/-- The inverse morphism -/
inv : ∀ {X Y : obj}, (X ⟶ Y) → (Y ⟶ X)
/-- `inv f` composed `f` is the identity -/
inv_comp : ∀ {X Y : obj} (f : X ⟶ Y), comp (inv f) f = id Y := by cat_disch
/-- `f` composed with `inv f` is the identity -/
comp_inv : ∀ {X Y : obj} (f : X ⟶ Y), comp f (inv f) = id X := by cat_disch
initialize_simps_projections Groupoid (-Hom)
/-- A `LargeGroupoid` is a groupoid
where the objects live in `Type (u+1)` while the morphisms live in `Type u`.
-/
abbrev LargeGroupoid (C : Type (u + 1)) : Type (u + 1) :=
Groupoid.{u} C
/-- A `SmallGroupoid` is a groupoid
where the objects and morphisms live in the same universe.
-/
abbrev SmallGroupoid (C : Type u) : Type (u + 1) :=
Groupoid.{u} C
section
variable {C : Type u} [Groupoid.{v} C] {X Y : C}
-- see Note [lower instance priority]
instance (priority := 100) IsIso.of_groupoid (f : X ⟶ Y) : IsIso f :=
⟨⟨Groupoid.inv f, Groupoid.comp_inv f, Groupoid.inv_comp f⟩⟩
@[simp]
theorem Groupoid.inv_eq_inv (f : X ⟶ Y) : Groupoid.inv f = CategoryTheory.inv f :=
IsIso.eq_inv_of_hom_inv_id <| Groupoid.comp_inv f
/-- `Groupoid.inv` is involutive. -/
@[simps]
def Groupoid.invEquiv : (X ⟶ Y) ≃ (Y ⟶ X) :=
⟨Groupoid.inv, Groupoid.inv, fun f => by simp, fun f => by simp⟩
instance (priority := 100) groupoidHasInvolutiveReverse : Quiver.HasInvolutiveReverse C where
reverse' f := Groupoid.inv f
inv' f := by
dsimp [Quiver.reverse]
simp
@[simp]
theorem Groupoid.reverse_eq_inv (f : X ⟶ Y) : Quiver.reverse f = Groupoid.inv f :=
rfl
instance functorMapReverse {D : Type*} [Groupoid D] (F : C ⥤ D) : F.toPrefunctor.MapReverse where
map_reverse' f := by simp
variable (X Y)
/-- In a groupoid, isomorphisms are equivalent to morphisms. -/
@[simps!]
def Groupoid.isoEquivHom : (X ≅ Y) ≃ (X ⟶ Y) where
toFun := Iso.hom
invFun f := { hom := f, inv := Groupoid.inv f }
variable (C)
/-- The functor from a groupoid `C` to its opposite sending every morphism to its inverse. -/
@[simps]
noncomputable def Groupoid.invFunctor : C ⥤ Cᵒᵖ where
obj := Opposite.op
map {_ _} f := (inv f).op
end
section
/-- A Prop-valued typeclass asserting that a given category is a groupoid. -/
class IsGroupoid (C : Type u) [Category.{v} C] : Prop where
all_isIso {X Y : C} (f : X ⟶ Y) : IsIso f := by infer_instance
attribute [instance] IsGroupoid.all_isIso
noncomputable instance {C : Type u} [Groupoid.{v} C] : IsGroupoid C where
variable {C : Type u} [Category.{v} C]
/-- Promote (noncomputably) an `IsGroupoid` to a `Groupoid` structure. -/
noncomputable def Groupoid.ofIsGroupoid [IsGroupoid C] :
Groupoid.{v} C where
inv := fun f => CategoryTheory.inv f
/-- A category where every morphism `IsIso` is a groupoid. -/
noncomputable def Groupoid.ofIsIso (all_is_iso : ∀ {X Y : C} (f : X ⟶ Y), IsIso f) :
Groupoid.{v} C where
inv := fun f => CategoryTheory.inv f
inv_comp := fun f => Classical.choose_spec (all_is_iso f).out|>.right
/-- A category with a unique morphism between any two objects is a groupoid -/
def Groupoid.ofHomUnique (all_unique : ∀ {X Y : C}, Unique (X ⟶ Y)) : Groupoid.{v} C where
inv _ := all_unique.default
end
lemma isGroupoid_of_reflects_iso {C D : Type*} [Category C] [Category D]
(F : C ⥤ D) [F.ReflectsIsomorphisms] [IsGroupoid D] :
IsGroupoid C where
all_isIso _ := isIso_of_reflects_iso _ F
/-- A category equipped with a fully faithful functor to a groupoid is fully faithful -/
def Groupoid.ofFullyFaithfulToGroupoid {C : Type*} [𝒞 : Category C] {D : Type u} [Groupoid.{v} D]
(F : C ⥤ D) (h : F.FullyFaithful) : Groupoid C :=
{ 𝒞 with
inv f := h.preimage <| Groupoid.inv (F.map f)
inv_comp f := by
apply h.map_injective
simp
comp_inv f := by
apply h.map_injective
simp }
instance InducedCategory.groupoid {C : Type u} (D : Type u₂) [Groupoid.{v} D] (F : C → D) :
Groupoid.{v} (InducedCategory D F) :=
Groupoid.ofFullyFaithfulToGroupoid (inducedFunctor F) (fullyFaithfulInducedFunctor F)
instance InducedCategory.isGroupoid {C : Type u} (D : Type u₂)
[Category.{v} D] [IsGroupoid D] (F : C → D) :
IsGroupoid (InducedCategory D F) :=
isGroupoid_of_reflects_iso (inducedFunctor F)
section
instance groupoidPi {I : Type u} {J : I → Type u₂} [∀ i, Groupoid.{v} (J i)] :
Groupoid.{max u v} (∀ i : I, J i) where
inv f := fun i : I => Groupoid.inv (f i)
comp_inv := fun f => by funext i; apply Groupoid.comp_inv
inv_comp := fun f => by funext i; apply Groupoid.inv_comp
instance groupoidProd {α : Type u} {β : Type v} [Groupoid.{u₂} α] [Groupoid.{v₂} β] :
Groupoid.{max u₂ v₂} (α × β) where
inv f := (Groupoid.inv f.1, Groupoid.inv f.2)
instance isGroupoidPi {I : Type u} {J : I → Type u₂}
[∀ i, Category.{v} (J i)] [∀ i, IsGroupoid (J i)] :
IsGroupoid (∀ i : I, J i) where
all_isIso f := (isIso_pi_iff f).mpr (fun _ ↦ inferInstance)
instance isGroupoidProd {α : Type u} {β : Type u₂} [Category.{v} α] [Category.{v₂} β]
[IsGroupoid α] [IsGroupoid β] :
IsGroupoid (α × β) where
all_isIso f := (isIso_prod_iff (f := f)).mpr ⟨inferInstance, inferInstance⟩
end
open MorphismProperty in
lemma isGroupoid_iff_isomorphisms_eq_top (C : Type*) [Category C] :
IsGroupoid C ↔ isomorphisms C = ⊤ := by
constructor
· rw [eq_top_iff]
intro _ _
simp only [isomorphisms.iff, top_apply]
infer_instance
· intro h
exact ⟨of_eq_top h⟩
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Quotient.lean | import Mathlib.CategoryTheory.NatIso
import Mathlib.CategoryTheory.EqToHom
import Mathlib.CategoryTheory.Groupoid
/-!
# Quotient category
Constructs the quotient of a category by an arbitrary family of relations on its hom-sets,
by introducing a type synonym for the objects, and identifying homs as necessary.
This is analogous to 'the quotient of a group by the normal closure of a subset', rather
than 'the quotient of a group by a normal subgroup'. When taking the quotient by a congruence
relation, `functor_map_eq_iff` says that no unnecessary identifications have been made.
-/
/-- A `HomRel` on `C` consists of a relation on every hom-set. -/
def HomRel (C) [Quiver C] :=
∀ ⦃X Y : C⦄, (X ⟶ Y) → (X ⟶ Y) → Prop
deriving Inhabited
namespace CategoryTheory
open Functor
section
variable {C D : Type*} [Category C] [Category D] (F : C ⥤ D)
/-- A functor induces a `HomRel` on its domain, relating those maps that have the same image. -/
def Functor.homRel : HomRel C :=
fun _ _ f g ↦ F.map f = F.map g
@[simp]
lemma Functor.homRel_iff {X Y : C} (f g : X ⟶ Y) :
F.homRel f g ↔ F.map f = F.map g := Iff.rfl
end
variable {C : Type _} [Category C] (r : HomRel C)
/-- A `HomRel` is a congruence when it's an equivalence on every hom-set, and it can be composed
from left and right. -/
class Congruence : Prop where
/-- `r` is an equivalence on every hom-set. -/
equivalence : ∀ {X Y}, _root_.Equivalence (@r X Y)
/-- Precomposition with an arrow respects `r`. -/
compLeft : ∀ {X Y Z} (f : X ⟶ Y) {g g' : Y ⟶ Z}, r g g' → r (f ≫ g) (f ≫ g')
/-- Postcomposition with an arrow respects `r`. -/
compRight : ∀ {X Y Z} {f f' : X ⟶ Y} (g : Y ⟶ Z), r f f' → r (f ≫ g) (f' ≫ g)
/-- For `F : C ⥤ D`, `F.homRel` is a congruence. -/
instance Functor.congruence_homRel {C D : Type*} [Category C] [Category D] (F : C ⥤ D) :
Congruence F.homRel where
equivalence :=
{ refl := fun _ ↦ rfl
symm := by aesop
trans := by aesop }
compLeft := by aesop
compRight := by aesop
/-- A type synonym for `C`, thought of as the objects of the quotient category. -/
@[ext]
structure Quotient (r : HomRel C) where
/-- The object of `C`. -/
as : C
instance [Inhabited C] : Inhabited (Quotient r) :=
⟨{ as := default }⟩
namespace Quotient
/-- Generates the closure of a family of relations w.r.t. composition from left and right. -/
inductive CompClosure (r : HomRel C) ⦃s t : C⦄ : (s ⟶ t) → (s ⟶ t) → Prop
| intro {a b : C} (f : s ⟶ a) (m₁ m₂ : a ⟶ b) (g : b ⟶ t) (h : r m₁ m₂) :
CompClosure r (f ≫ m₁ ≫ g) (f ≫ m₂ ≫ g)
theorem CompClosure.of {a b : C} (m₁ m₂ : a ⟶ b) (h : r m₁ m₂) : CompClosure r m₁ m₂ := by
simpa using CompClosure.intro (𝟙 _) m₁ m₂ (𝟙 _) h
theorem comp_left {a b c : C} (f : a ⟶ b) :
∀ (g₁ g₂ : b ⟶ c) (_ : CompClosure r g₁ g₂), CompClosure r (f ≫ g₁) (f ≫ g₂)
| _, _, ⟨x, m₁, m₂, y, h⟩ => by simpa using CompClosure.intro (f ≫ x) m₁ m₂ y h
theorem comp_right {a b c : C} (g : b ⟶ c) :
∀ (f₁ f₂ : a ⟶ b) (_ : CompClosure r f₁ f₂), CompClosure r (f₁ ≫ g) (f₂ ≫ g)
| _, _, ⟨x, m₁, m₂, y, h⟩ => by simpa using CompClosure.intro x m₁ m₂ (y ≫ g) h
/-- Hom-sets of the quotient category. -/
def Hom (s t : Quotient r) :=
Quot <| @CompClosure C _ r s.as t.as
instance (a : Quotient r) : Inhabited (Hom r a a) :=
⟨Quot.mk _ (𝟙 a.as)⟩
/-- Composition in the quotient category. -/
def comp ⦃a b c : Quotient r⦄ : Hom r a b → Hom r b c → Hom r a c := fun hf hg ↦
Quot.liftOn hf
(fun f ↦
Quot.liftOn hg (fun g ↦ Quot.mk _ (f ≫ g)) fun g₁ g₂ h ↦
Quot.sound <| comp_left r f g₁ g₂ h)
fun f₁ f₂ h ↦ Quot.inductionOn hg fun g ↦ Quot.sound <| comp_right r g f₁ f₂ h
@[simp]
theorem comp_mk {a b c : Quotient r} (f : a.as ⟶ b.as) (g : b.as ⟶ c.as) :
comp r (Quot.mk _ f) (Quot.mk _ g) = Quot.mk _ (f ≫ g) :=
rfl
instance category : Category (Quotient r) where
Hom := Hom r
id a := Quot.mk _ (𝟙 a.as)
comp := @comp _ _ r
comp_id f := Quot.inductionOn f <| by simp
id_comp f := Quot.inductionOn f <| by simp
assoc f g h := Quot.inductionOn f <| Quot.inductionOn g <| Quot.inductionOn h <| by simp
noncomputable section
variable {G : Type*} [Groupoid G] (r : HomRel G)
/-- Inverse of a map in the quotient category of a groupoid. -/
protected def inv {X Y : Quotient r} (f : X ⟶ Y) : Y ⟶ X :=
Quot.liftOn f (fun f' => Quot.mk _ (Groupoid.inv f')) (fun _ _ con => by
rcases con with ⟨_, f, g, _, hfg⟩
have := Quot.sound <| CompClosure.intro (Groupoid.inv g) f g (Groupoid.inv f) hfg
simp only [Groupoid.inv_eq_inv, IsIso.hom_inv_id, Category.comp_id,
IsIso.inv_hom_id_assoc] at this
simp only [Groupoid.inv_eq_inv, IsIso.inv_comp, Category.assoc]
repeat rw [← comp_mk]
rw [this])
@[simp]
theorem inv_mk {X Y : Quotient r} (f : X.as ⟶ Y.as) :
Quotient.inv r (Quot.mk _ f) = Quot.mk _ (Groupoid.inv f) :=
rfl
/-- The quotient of a groupoid is a groupoid. -/
instance groupoid : Groupoid (Quotient r) where
inv f := Quotient.inv r f
inv_comp f := Quot.inductionOn f <| by simp [CategoryStruct.comp, CategoryStruct.id]
comp_inv f := Quot.inductionOn f <| by simp [CategoryStruct.comp, CategoryStruct.id]
end
/-- The functor from a category to its quotient. -/
def functor : C ⥤ Quotient r where
obj a := { as := a }
map f := Quot.mk _ f
instance full_functor : (functor r).Full where
map_surjective f := ⟨Quot.out f, by simp [functor]⟩
instance essSurj_functor : (functor r).EssSurj where
mem_essImage Y := ⟨Y.as, ⟨eqToIso rfl⟩⟩
instance [Unique C] : Unique (Quotient r) where
uniq a := by ext; subsingleton
instance [∀ (x y : C), Subsingleton (x ⟶ y)] (x y : Quotient r) :
Subsingleton (x ⟶ y) := (full_functor r).map_surjective.subsingleton
protected theorem induction {P : ∀ {a b : Quotient r}, (a ⟶ b) → Prop}
(h : ∀ {x y : C} (f : x ⟶ y), P ((functor r).map f)) :
∀ {a b : Quotient r} (f : a ⟶ b), P f := by
rintro ⟨x⟩ ⟨y⟩ ⟨f⟩
exact h f
protected theorem sound {a b : C} {f₁ f₂ : a ⟶ b} (h : r f₁ f₂) :
(functor r).map f₁ = (functor r).map f₂ := by
simpa using Quot.sound (CompClosure.intro (𝟙 a) f₁ f₂ (𝟙 b) h)
lemma compClosure_iff_self [h : Congruence r] {X Y : C} (f g : X ⟶ Y) :
CompClosure r f g ↔ r f g := by
constructor
· rintro ⟨hfg⟩
exact Congruence.compLeft _ (Congruence.compRight _ (by assumption))
· exact CompClosure.of _ _ _
@[simp]
theorem compClosure_eq_self [h : Congruence r] :
CompClosure r = r := by
ext
simp only [compClosure_iff_self]
theorem functor_map_eq_iff [h : Congruence r] {X Y : C} (f f' : X ⟶ Y) :
(functor r).map f = (functor r).map f' ↔ r f f' := by
dsimp [functor]
rw [Equivalence.quot_mk_eq_iff, compClosure_eq_self r]
simpa only [compClosure_eq_self r] using h.equivalence
theorem functor_homRel_eq_compClosure_eqvGen {X Y : C} (f g : X ⟶ Y) :
(functor r).homRel f g ↔ Relation.EqvGen (@CompClosure C _ r X Y) f g :=
Quot.eq
theorem compClosure.congruence :
Congruence fun X Y => Relation.EqvGen (@CompClosure C _ r X Y) := by
convert inferInstanceAs (Congruence (functor r).homRel)
ext
rw [functor_homRel_eq_compClosure_eqvGen]
variable {D : Type _} [Category D] (F : C ⥤ D)
/-- The induced functor on the quotient category. -/
def lift (H : ∀ (x y : C) (f₁ f₂ : x ⟶ y), r f₁ f₂ → F.map f₁ = F.map f₂) : Quotient r ⥤ D where
obj a := F.obj a.as
map hf :=
Quot.liftOn hf (fun f ↦ F.map f)
(by
rintro _ _ ⟨_, _, _, _, h⟩
simp [H _ _ _ _ h])
map_id a := F.map_id a.as
map_comp := by
rintro a b c ⟨f⟩ ⟨g⟩
exact F.map_comp f g
variable (H : ∀ (x y : C) (f₁ f₂ : x ⟶ y), r f₁ f₂ → F.map f₁ = F.map f₂)
theorem lift_spec : functor r ⋙ lift r F H = F := by
tauto
theorem lift_unique (Φ : Quotient r ⥤ D) (hΦ : functor r ⋙ Φ = F) : Φ = lift r F H := by
subst_vars
fapply Functor.hext
· rintro X
dsimp [lift, Functor]
congr
· rintro _ _ f
dsimp [lift, Functor]
refine Quot.inductionOn f fun _ ↦ ?_
simp only [heq_eq_eq]
congr
lemma lift_unique' (F₁ F₂ : Quotient r ⥤ D) (h : functor r ⋙ F₁ = functor r ⋙ F₂) :
F₁ = F₂ := by
rw [lift_unique r (functor r ⋙ F₂) _ F₂ rfl]; swap
· rintro X Y f g h
dsimp
rw [Quotient.sound r h]
apply lift_unique
rw [h]
/-- The original functor factors through the induced functor. -/
def lift.isLift : functor r ⋙ lift r F H ≅ F :=
NatIso.ofComponents fun _ ↦ Iso.refl _
@[simp]
theorem lift.isLift_hom (X : C) : (lift.isLift r F H).hom.app X = 𝟙 (F.obj X) :=
rfl
@[simp]
theorem lift.isLift_inv (X : C) : (lift.isLift r F H).inv.app X = 𝟙 (F.obj X) :=
rfl
theorem lift_obj_functor_obj (X : C) :
(lift r F H).obj ((functor r).obj X) = F.obj X := rfl
theorem lift_map_functor_map {X Y : C} (f : X ⟶ Y) :
(lift r F H).map ((functor r).map f) = F.map f :=
rfl
variable {r}
lemma natTrans_ext {F G : Quotient r ⥤ D} (τ₁ τ₂ : F ⟶ G)
(h : whiskerLeft (Quotient.functor r) τ₁ = whiskerLeft (Quotient.functor r) τ₂) : τ₁ = τ₂ :=
NatTrans.ext (by ext1 ⟨X⟩; exact NatTrans.congr_app h X)
variable (r)
/-- In order to define a natural transformation `F ⟶ G` with `F G : Quotient r ⥤ D`, it suffices
to do so after precomposing with `Quotient.functor r`. -/
def natTransLift {F G : Quotient r ⥤ D} (τ : Quotient.functor r ⋙ F ⟶ Quotient.functor r ⋙ G) :
F ⟶ G where
app := fun ⟨X⟩ => τ.app X
naturality := fun ⟨X⟩ ⟨Y⟩ => by
rintro ⟨f⟩
exact τ.naturality f
@[simp]
lemma natTransLift_app (F G : Quotient r ⥤ D)
(τ : Quotient.functor r ⋙ F ⟶ Quotient.functor r ⋙ G) (X : C) :
(natTransLift r τ).app ((Quotient.functor r).obj X) = τ.app X := rfl
@[reassoc]
lemma comp_natTransLift {F G H : Quotient r ⥤ D}
(τ : Quotient.functor r ⋙ F ⟶ Quotient.functor r ⋙ G)
(τ' : Quotient.functor r ⋙ G ⟶ Quotient.functor r ⋙ H) :
natTransLift r τ ≫ natTransLift r τ' = natTransLift r (τ ≫ τ') := by cat_disch
@[simp]
lemma natTransLift_id (F : Quotient r ⥤ D) :
natTransLift r (𝟙 (Quotient.functor r ⋙ F)) = 𝟙 _ := by cat_disch
/-- In order to define a natural isomorphism `F ≅ G` with `F G : Quotient r ⥤ D`, it suffices
to do so after precomposing with `Quotient.functor r`. -/
@[simps]
def natIsoLift {F G : Quotient r ⥤ D} (τ : Quotient.functor r ⋙ F ≅ Quotient.functor r ⋙ G) :
F ≅ G where
hom := natTransLift _ τ.hom
inv := natTransLift _ τ.inv
hom_inv_id := by rw [comp_natTransLift, τ.hom_inv_id, natTransLift_id]
inv_hom_id := by rw [comp_natTransLift, τ.inv_hom_id, natTransLift_id]
variable (D)
instance full_whiskeringLeft_functor :
((whiskeringLeft C _ D).obj (functor r)).Full where
map_surjective f := ⟨natTransLift r f, by cat_disch⟩
instance faithful_whiskeringLeft_functor :
((whiskeringLeft C _ D).obj (functor r)).Faithful := ⟨by apply natTrans_ext⟩
end Quotient
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Simple.lean | import Mathlib.CategoryTheory.Limits.Shapes.ZeroMorphisms
import Mathlib.CategoryTheory.Limits.Shapes.Kernels
import Mathlib.CategoryTheory.Abelian.Basic
import Mathlib.CategoryTheory.Subobject.Lattice
import Mathlib.Order.Atoms
/-!
# Simple objects
We define simple objects in any category with zero morphisms.
A simple object is an object `Y` such that any monomorphism `f : X ⟶ Y`
is either an isomorphism or zero (but not both).
This is formalized as a `Prop`-valued typeclass `Simple X`.
In some contexts, especially representation theory, simple objects are called "irreducibles".
If a morphism `f` out of a simple object is nonzero and has a kernel, then that kernel is zero.
(We state this as `kernel.ι f = 0`, but should add `kernel f ≅ 0`.)
When the category is abelian, being simple is the same as being cosimple (although we do not
state a separate typeclass for this).
As a consequence, any nonzero epimorphism out of a simple object is an isomorphism,
and any nonzero morphism into a simple object has trivial cokernel.
We show that any simple object is indecomposable.
-/
noncomputable section
open CategoryTheory.Limits
namespace CategoryTheory
universe v u
variable {C : Type u} [Category.{v} C]
section
variable [HasZeroMorphisms C]
/-- An object is simple if monomorphisms into it are (exclusively) either isomorphisms or zero. -/
class Simple (X : C) : Prop where
mono_isIso_iff_nonzero : ∀ {Y : C} (f : Y ⟶ X) [Mono f], IsIso f ↔ f ≠ 0
/-- A nonzero monomorphism to a simple object is an isomorphism. -/
theorem isIso_of_mono_of_nonzero {X Y : C} [Simple Y] {f : X ⟶ Y} [Mono f] (w : f ≠ 0) : IsIso f :=
(Simple.mono_isIso_iff_nonzero f).mpr w
theorem Simple.of_iso {X Y : C} [Simple Y] (i : X ≅ Y) : Simple X :=
{ mono_isIso_iff_nonzero := fun f m => by
constructor
· intro h w
have j : IsIso (f ≫ i.hom) := by infer_instance
rw [Simple.mono_isIso_iff_nonzero] at j
subst w
simp at j
· intro h
have j : IsIso (f ≫ i.hom) := by
apply isIso_of_mono_of_nonzero
intro w
apply h
simpa using (cancel_mono i.inv).2 w
rw [← Category.comp_id f, ← i.hom_inv_id, ← Category.assoc]
infer_instance }
theorem Simple.iff_of_iso {X Y : C} (i : X ≅ Y) : Simple X ↔ Simple Y :=
⟨fun _ => Simple.of_iso i.symm, fun _ => Simple.of_iso i⟩
theorem kernel_zero_of_nonzero_from_simple {X Y : C} [Simple X] {f : X ⟶ Y} [HasKernel f]
(w : f ≠ 0) : kernel.ι f = 0 := by
classical
by_contra h
haveI := isIso_of_mono_of_nonzero h
exact w (eq_zero_of_epi_kernel f)
-- See also `mono_of_nonzero_from_simple`, which requires `Preadditive C`.
/-- A nonzero morphism `f` to a simple object is an epimorphism
(assuming `f` has an image, and `C` has equalizers).
-/
theorem epi_of_nonzero_to_simple [HasEqualizers C] {X Y : C} [Simple Y] {f : X ⟶ Y} [HasImage f]
(w : f ≠ 0) : Epi f := by
rw [← image.fac f]
haveI : IsIso (image.ι f) := isIso_of_mono_of_nonzero fun h => w (eq_zero_of_image_eq_zero h)
apply epi_comp
theorem mono_to_simple_zero_of_not_iso {X Y : C} [Simple Y] {f : X ⟶ Y} [Mono f]
(w : IsIso f → False) : f = 0 := by
classical
by_contra h
exact w (isIso_of_mono_of_nonzero h)
theorem id_nonzero (X : C) [Simple.{v} X] : 𝟙 X ≠ 0 :=
(Simple.mono_isIso_iff_nonzero (𝟙 X)).mp (by infer_instance)
instance (X : C) [Simple.{v} X] : Nontrivial (End X) :=
nontrivial_of_ne 1 _ (id_nonzero X)
section
theorem Simple.not_isZero (X : C) [Simple X] : ¬IsZero X := by
simpa [Limits.IsZero.iff_id_eq_zero] using id_nonzero X
variable [HasZeroObject C]
open ZeroObject
variable (C)
/-- We don't want the definition of 'simple' to include the zero object, so we check that here. -/
theorem zero_not_simple [Simple (0 : C)] : False :=
(Simple.mono_isIso_iff_nonzero (0 : (0 : C) ⟶ (0 : C))).mp ⟨⟨0, by simp⟩⟩ rfl
end
end
-- We next make the dual arguments, but for this we must be in an abelian category.
section Abelian
variable [Abelian C]
/-- In an abelian category, an object satisfying the dual of the definition of a simple object is
simple. -/
theorem simple_of_cosimple (X : C) (h : ∀ {Z : C} (f : X ⟶ Z) [Epi f], IsIso f ↔ f ≠ 0) :
Simple X :=
⟨fun {Y} f I => by
classical
fconstructor
· intros
have hx := cokernel.π_of_epi f
by_contra h
subst h
exact (h _).mp (cokernel.π_of_zero _ _) hx
· intro hf
suffices Epi f by exact isIso_of_mono_of_epi _
apply Preadditive.epi_of_cokernel_zero
by_contra h'
exact cokernel_not_iso_of_nonzero hf ((h _).mpr h')⟩
/-- A nonzero epimorphism from a simple object is an isomorphism. -/
theorem isIso_of_epi_of_nonzero {X Y : C} [Simple X] {f : X ⟶ Y} [Epi f] (w : f ≠ 0) : IsIso f :=
-- `f ≠ 0` means that `kernel.ι f` is not an iso, and hence zero, and hence `f` is a mono.
haveI : Mono f :=
Preadditive.mono_of_kernel_zero (mono_to_simple_zero_of_not_iso (kernel_not_iso_of_nonzero w))
isIso_of_mono_of_epi f
theorem cokernel_zero_of_nonzero_to_simple {X Y : C} [Simple Y] {f : X ⟶ Y} (w : f ≠ 0) :
cokernel.π f = 0 := by
classical
by_contra h
haveI := isIso_of_epi_of_nonzero h
exact w (eq_zero_of_mono_cokernel f)
theorem epi_from_simple_zero_of_not_iso {X Y : C} [Simple X] {f : X ⟶ Y} [Epi f]
(w : IsIso f → False) : f = 0 := by
classical
by_contra h
exact w (isIso_of_epi_of_nonzero h)
end Abelian
section Indecomposable
variable [Preadditive C] [HasBinaryBiproducts C]
-- There are another three potential variations of this lemma,
-- but as any one suffices to prove `indecomposable_of_simple` we will not give them all.
theorem Biprod.isIso_inl_iff_isZero (X Y : C) : IsIso (biprod.inl : X ⟶ X ⊞ Y) ↔ IsZero Y := by
rw [biprod.isIso_inl_iff_id_eq_fst_comp_inl, ← biprod.total, add_eq_left]
constructor
· intro h
replace h := h =≫ biprod.snd
simpa [← IsZero.iff_isSplitEpi_eq_zero (biprod.snd : X ⊞ Y ⟶ Y)] using h
· intro h
rw [IsZero.iff_isSplitEpi_eq_zero (biprod.snd : X ⊞ Y ⟶ Y)] at h
rw [h, zero_comp]
/-- Any simple object in a preadditive category is indecomposable. -/
theorem indecomposable_of_simple (X : C) [Simple X] : Indecomposable X :=
⟨Simple.not_isZero X, fun Y Z i => by
refine or_iff_not_imp_left.mpr fun h => ?_
rw [IsZero.iff_isSplitMono_eq_zero (biprod.inl : Y ⟶ Y ⊞ Z)] at h
change biprod.inl ≠ 0 at h
have : Simple (Y ⊞ Z) := Simple.of_iso i.symm
rw [← Simple.mono_isIso_iff_nonzero biprod.inl] at h
rwa [Biprod.isIso_inl_iff_isZero] at h⟩
end Indecomposable
section Subobject
variable [HasZeroMorphisms C] [HasZeroObject C]
open ZeroObject
open Subobject
instance {X : C} [Simple X] : Nontrivial (Subobject X) :=
nontrivial_of_not_isZero (Simple.not_isZero X)
instance {X : C} [Simple X] : IsSimpleOrder (Subobject X) where
eq_bot_or_eq_top := by
rintro ⟨⟨⟨Y : C, ⟨⟨⟩⟩, f : Y ⟶ X⟩, m : Mono f⟩⟩
change mk f = ⊥ ∨ mk f = ⊤
by_cases h : f = 0
· exact Or.inl (mk_eq_bot_iff_zero.mpr h)
· refine Or.inr ((isIso_iff_mk_eq_top _).mp ((Simple.mono_isIso_iff_nonzero f).mpr h))
/-- If `X` has subobject lattice `{⊥, ⊤}`, then `X` is simple. -/
theorem simple_of_isSimpleOrder_subobject (X : C) [IsSimpleOrder (Subobject X)] : Simple X := by
constructor; intro Y f hf; constructor
· intro i
rw [Subobject.isIso_iff_mk_eq_top] at i
intro w
rw [← Subobject.mk_eq_bot_iff_zero] at w
exact IsSimpleOrder.bot_ne_top (w.symm.trans i)
· intro i
rcases IsSimpleOrder.eq_bot_or_eq_top (Subobject.mk f) with (h | h)
· rw [Subobject.mk_eq_bot_iff_zero] at h
exact False.elim (i h)
· exact (Subobject.isIso_iff_mk_eq_top _).mpr h
/-- `X` is simple iff it has subobject lattice `{⊥, ⊤}`. -/
theorem simple_iff_subobject_isSimpleOrder (X : C) : Simple X ↔ IsSimpleOrder (Subobject X) :=
⟨by
intro h
infer_instance, by
intro h
exact simple_of_isSimpleOrder_subobject X⟩
/-- A subobject is simple iff it is an atom in the subobject lattice. -/
theorem subobject_simple_iff_isAtom {X : C} (Y : Subobject X) : Simple (Y : C) ↔ IsAtom Y :=
(simple_iff_subobject_isSimpleOrder _).trans
((OrderIso.isSimpleOrder_iff (subobjectOrderIso Y)).trans Set.isSimpleOrder_Iic_iff_isAtom)
end Subobject
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Conj.lean | import Mathlib.Algebra.Group.Units.Equiv
import Mathlib.CategoryTheory.Endomorphism
import Mathlib.CategoryTheory.HomCongr
/-!
# Conjugate morphisms by isomorphisms
An isomorphism `α : X ≅ Y` defines
- a monoid isomorphism
`CategoryTheory.Iso.conj : End X ≃* End Y` by `α.conj f = α.inv ≫ f ≫ α.hom`;
- a group isomorphism `CategoryTheory.Iso.conjAut : Aut X ≃* Aut Y` by
`α.conjAut f = α.symm ≪≫ f ≪≫ α`
using
`CategoryTheory.Iso.homCongr : (X ≅ X₁) → (Y ≅ Y₁) → (X ⟶ Y) ≃ (X₁ ⟶ Y₁)`
and `CategoryTheory.Iso.isoCongr : (f : X₁ ≅ X₂) → (g : Y₁ ≅ Y₂) → (X₁ ≅ Y₁) ≃ (X₂ ≅ Y₂)`
which are defined in `CategoryTheory.HomCongr`.
-/
universe v u
namespace CategoryTheory
namespace Iso
variable {C : Type u} [Category.{v} C]
variable {X Y : C} (α : X ≅ Y)
/-- An isomorphism between two objects defines a monoid isomorphism between their
monoid of endomorphisms. -/
def conj : End X ≃* End Y :=
{ homCongr α α with map_mul' := fun f g => homCongr_comp α α α g f }
theorem conj_apply (f : End X) : α.conj f = α.inv ≫ f ≫ α.hom :=
rfl
@[simp]
theorem conj_comp (f g : End X) : α.conj (f ≫ g) = α.conj f ≫ α.conj g :=
map_mul α.conj g f
@[simp]
theorem conj_id : α.conj (𝟙 X) = 𝟙 Y :=
map_one α.conj
@[simp]
theorem refl_conj (f : End X) : (Iso.refl X).conj f = f := by
rw [conj_apply, Iso.refl_inv, Iso.refl_hom, Category.id_comp, Category.comp_id]
@[simp]
theorem trans_conj {Z : C} (β : Y ≅ Z) (f : End X) : (α ≪≫ β).conj f = β.conj (α.conj f) :=
homCongr_trans α α β β f
@[simp]
theorem symm_self_conj (f : End X) : α.symm.conj (α.conj f) = f := by
rw [← trans_conj, α.self_symm_id, refl_conj]
@[simp]
theorem self_symm_conj (f : End Y) : α.conj (α.symm.conj f) = f :=
α.symm.symm_self_conj f
@[simp]
theorem conj_pow (f : End X) (n : ℕ) : α.conj (f ^ n) = α.conj f ^ n :=
α.conj.toMonoidHom.map_pow f n
-- TODO: change definition so that `conjAut_apply` becomes a `rfl`?
/-- `conj` defines a group isomorphisms between groups of automorphisms -/
def conjAut : Aut X ≃* Aut Y :=
(Aut.unitsEndEquivAut X).symm.trans <| (Units.mapEquiv α.conj).trans <| Aut.unitsEndEquivAut Y
theorem conjAut_apply (f : Aut X) : α.conjAut f = α.symm ≪≫ f ≪≫ α := by cat_disch
@[simp]
theorem conjAut_hom (f : Aut X) : (α.conjAut f).hom = α.conj f.hom :=
rfl
@[simp]
theorem trans_conjAut {Z : C} (β : Y ≅ Z) (f : Aut X) :
(α ≪≫ β).conjAut f = β.conjAut (α.conjAut f) := by
simp only [conjAut_apply, Iso.trans_symm, Iso.trans_assoc]
@[simp]
theorem conjAut_mul (f g : Aut X) : α.conjAut (f * g) = α.conjAut f * α.conjAut g :=
map_mul α.conjAut f g
@[simp]
theorem conjAut_trans (f g : Aut X) : α.conjAut (f ≪≫ g) = α.conjAut f ≪≫ α.conjAut g :=
conjAut_mul α g f
@[simp]
theorem conjAut_pow (f : Aut X) (n : ℕ) : α.conjAut (f ^ n) = α.conjAut f ^ n :=
map_pow α.conjAut f n
@[simp]
theorem conjAut_zpow (f : Aut X) (n : ℤ) : α.conjAut (f ^ n) = α.conjAut f ^ n :=
map_zpow α.conjAut f n
end Iso
namespace Functor
universe v₁ u₁
variable {C : Type u} [Category.{v} C] {D : Type u₁} [Category.{v₁} D] (F : C ⥤ D)
theorem map_conj {X Y : C} (α : X ≅ Y) (f : End X) :
F.map (α.conj f) = (F.mapIso α).conj (F.map f) :=
map_homCongr F α α f
theorem map_conjAut (F : C ⥤ D) {X Y : C} (α : X ≅ Y) (f : Aut X) :
F.mapIso (α.conjAut f) = (F.mapIso α).conjAut (F.mapIso f) := by
ext; simp only [mapIso_hom, Iso.conjAut_hom, F.map_conj]
-- alternative proof: by simp only [Iso.conjAut_apply, F.mapIso_trans, F.mapIso_symm]
end Functor
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Adhesive.lean | import Mathlib.CategoryTheory.Extensive
import Mathlib.CategoryTheory.Limits.Shapes.KernelPair
import Mathlib.CategoryTheory.Limits.Constructions.EpiMono
/-!
# Adhesive categories
## Main definitions
- `CategoryTheory.IsPushout.IsVanKampen`: A convenience formulation for a pushout being
a van Kampen colimit.
- `CategoryTheory.Adhesive`: A category is adhesive if it has pushouts and pullbacks along
monomorphisms, and such pushouts are van Kampen.
## Main Results
- `CategoryTheory.Type.adhesive`: The category of `Type` is adhesive.
- `CategoryTheory.Adhesive.isPullback_of_isPushout_of_mono_left`: In adhesive categories,
pushouts along monomorphisms are pullbacks.
- `CategoryTheory.Adhesive.mono_of_isPushout_of_mono_left`: In adhesive categories,
monomorphisms are stable under pushouts.
- `CategoryTheory.Adhesive.toRegularMonoCategory`: Monomorphisms in adhesive categories are
regular (this implies that adhesive categories are balanced).
- `CategoryTheory.adhesive_functor`: The category `C ⥤ D` is adhesive if `D`
has all pullbacks and all pushouts and is adhesive
## References
- https://ncatlab.org/nlab/show/adhesive+category
- [Stephen Lack and Paweł Sobociński, Adhesive Categories][adhesive2004]
-/
namespace CategoryTheory
open Limits
universe v' u' v u
variable {J : Type v'} [Category.{u'} J] {C : Type u} [Category.{v} C]
variable {W X Y Z : C} {f : W ⟶ X} {g : W ⟶ Y} {h : X ⟶ Z} {i : Y ⟶ Z}
-- This only makes sense when the original diagram is a pushout.
/-- A convenience formulation for a pushout being a van Kampen colimit.
See `IsPushout.isVanKampen_iff` below. -/
@[nolint unusedArguments]
def IsPushout.IsVanKampen (_ : IsPushout f g h i) : Prop :=
∀ ⦃W' X' Y' Z' : C⦄ (f' : W' ⟶ X') (g' : W' ⟶ Y') (h' : X' ⟶ Z') (i' : Y' ⟶ Z') (αW : W' ⟶ W)
(αX : X' ⟶ X) (αY : Y' ⟶ Y) (αZ : Z' ⟶ Z) (_ : IsPullback f' αW αX f)
(_ : IsPullback g' αW αY g) (_ : CommSq h' αX αZ h) (_ : CommSq i' αY αZ i)
(_ : CommSq f' g' h' i'), IsPushout f' g' h' i' ↔ IsPullback h' αX αZ h ∧ IsPullback i' αY αZ i
theorem IsPushout.IsVanKampen.flip {H : IsPushout f g h i} (H' : H.IsVanKampen) :
H.flip.IsVanKampen := by
introv W' hf hg hh hi w
simpa only [IsPushout.flip_iff, IsPullback.flip_iff, and_comm] using
H' g' f' i' h' αW αY αX αZ hg hf hi hh w.flip
theorem IsPushout.isVanKampen_iff (H : IsPushout f g h i) :
H.IsVanKampen ↔ IsVanKampenColimit (PushoutCocone.mk h i H.w) := by
constructor
· intro H F' c' α fα eα hα
refine Iff.trans ?_
((H (F'.map WalkingSpan.Hom.fst) (F'.map WalkingSpan.Hom.snd) (c'.ι.app _) (c'.ι.app _)
(α.app _) (α.app _) (α.app _) fα (by convert hα WalkingSpan.Hom.fst)
(by convert hα WalkingSpan.Hom.snd) ?_ ?_ ?_).trans ?_)
· have : F'.map WalkingSpan.Hom.fst ≫ c'.ι.app WalkingSpan.left =
F'.map WalkingSpan.Hom.snd ≫ c'.ι.app WalkingSpan.right := by
simp only [Cocone.w]
rw [(IsColimit.equivOfNatIsoOfIso (diagramIsoSpan F') c' (PushoutCocone.mk _ _ this)
_).nonempty_congr]
· exact ⟨fun h => ⟨⟨this⟩, h⟩, fun h => h.2⟩
· refine Cocones.ext (Iso.refl c'.pt) ?_
rintro (_ | _ | _) <;> dsimp <;>
simp only [c'.w, Category.id_comp, Category.comp_id]
· exact ⟨NatTrans.congr_app eα.symm _⟩
· exact ⟨NatTrans.congr_app eα.symm _⟩
· exact ⟨by simp⟩
constructor
· rintro ⟨h₁, h₂⟩ (_ | _ | _)
· rw [← c'.w WalkingSpan.Hom.fst]; exact (hα WalkingSpan.Hom.fst).paste_horiz h₁
exacts [h₁, h₂]
· intro h; exact ⟨h _, h _⟩
· introv H W' hf hg hh hi w
refine
Iff.trans ?_ ((H w.cocone ⟨by rintro (_ | _ | _); exacts [αW, αX, αY], ?_⟩ αZ ?_ ?_).trans ?_)
rotate_left
· rintro i _ (_ | _ | _)
· dsimp; simp only [Functor.map_id, Category.comp_id, Category.id_comp]
exacts [hf.w, hg.w]
· ext (_ | _ | _)
· dsimp
rw [PushoutCocone.condition_zero, Category.assoc]
erw [hh.w]
rw [hf.w_assoc]
exacts [hh.w.symm, hi.w.symm]
· rintro i _ (_ | _ | _)
· dsimp; simp_rw [Functor.map_id]
exact IsPullback.of_horiz_isIso ⟨by rw [Category.comp_id, Category.id_comp]⟩
exacts [hf, hg]
· constructor
· intro h; exact ⟨h WalkingCospan.left, h WalkingCospan.right⟩
· rintro ⟨h₁, h₂⟩ (_ | _ | _)
· dsimp; rw [PushoutCocone.condition_zero]; exact hf.paste_horiz h₁
exacts [h₁, h₂]
· exact ⟨fun h => h.2, fun h => ⟨w, h⟩⟩
theorem is_coprod_iff_isPushout {X E Y YE : C} (c : BinaryCofan X E) (hc : IsColimit c) {f : X ⟶ Y}
{iY : Y ⟶ YE} {fE : c.pt ⟶ YE} (H : CommSq f c.inl iY fE) :
Nonempty (IsColimit (BinaryCofan.mk (c.inr ≫ fE) iY)) ↔ IsPushout f c.inl iY fE := by
constructor
· rintro ⟨h⟩
refine ⟨H, ⟨Limits.PushoutCocone.isColimitAux' _ ?_⟩⟩
intro s
dsimp
refine ⟨h.desc (BinaryCofan.mk (c.inr ≫ s.inr) s.inl), h.fac _ ⟨WalkingPair.right⟩, ?_, ?_⟩
· apply BinaryCofan.IsColimit.hom_ext hc
· rw [← H.w_assoc]; erw [h.fac _ ⟨WalkingPair.right⟩]; exact s.condition
· rw [← Category.assoc]; exact h.fac _ ⟨WalkingPair.left⟩
· intro m e₁ e₂
apply BinaryCofan.IsColimit.hom_ext h
· dsimp
rw [Category.assoc, e₂, eq_comm]; exact h.fac _ ⟨WalkingPair.left⟩
· refine e₁.trans (Eq.symm ?_); exact h.fac _ _
· refine fun H => ⟨?_⟩
fapply Limits.BinaryCofan.isColimitMk
· exact fun s => H.isColimit.desc (PushoutCocone.mk s.inr _ <|
(hc.fac (BinaryCofan.mk (f ≫ s.inr) s.inl) ⟨WalkingPair.left⟩).symm)
· intro s
rw [Category.assoc]
erw [H.isColimit.fac _ WalkingSpan.right]
erw [hc.fac]
rfl
· intro s; exact H.isColimit.fac _ WalkingSpan.left
· intro s m e₁ e₂
apply PushoutCocone.IsColimit.hom_ext H.isColimit
· symm; exact (H.isColimit.fac _ WalkingSpan.left).trans e₂.symm
· rw [H.isColimit.fac _ WalkingSpan.right]
apply BinaryCofan.IsColimit.hom_ext hc
· erw [hc.fac]
erw [← H.w_assoc]
rw [e₂]
rfl
· refine ((Category.assoc _ _ _).symm.trans e₁).trans ?_; symm; exact hc.fac _ _
theorem IsPushout.isVanKampen_inl {W E X Z : C} (c : BinaryCofan W E) [FinitaryExtensive C]
[HasPullbacks C] (hc : IsColimit c) (f : W ⟶ X) (h : X ⟶ Z) (i : c.pt ⟶ Z)
(H : IsPushout f c.inl h i) : H.IsVanKampen := by
obtain ⟨hc₁⟩ := (is_coprod_iff_isPushout c hc H.1).mpr H
introv W' hf hg hh hi w
obtain ⟨hc₂⟩ := ((BinaryCofan.isVanKampen_iff _).mp (FinitaryExtensive.vanKampen c hc)
(BinaryCofan.mk _ (pullback.fst _ _)) _ _ _ hg.w.symm pullback.condition.symm).mpr
⟨hg, IsPullback.of_hasPullback αY c.inr⟩
refine (is_coprod_iff_isPushout _ hc₂ w).symm.trans ?_
refine ((BinaryCofan.isVanKampen_iff _).mp (FinitaryExtensive.vanKampen _ hc₁)
(BinaryCofan.mk _ _) (pullback.snd _ _) _ _ ?_ hh.w.symm).trans ?_
· dsimp; rw [← pullback.condition_assoc, Category.assoc, hi.w]
constructor
· rintro ⟨hc₃, hc₄⟩
refine ⟨hc₄, ?_⟩
let Y'' := pullback αZ i
let cmp : Y' ⟶ Y'' := pullback.lift i' αY hi.w
have e₁ : (g' ≫ cmp) ≫ pullback.snd _ _ = αW ≫ c.inl := by
rw [Category.assoc, pullback.lift_snd, hg.w]
have e₂ : (pullback.fst _ _ ≫ cmp : pullback αY c.inr ⟶ _) ≫ pullback.snd _ _ =
pullback.snd _ _ ≫ c.inr := by
rw [Category.assoc, pullback.lift_snd, pullback.condition]
obtain ⟨hc₄⟩ := ((BinaryCofan.isVanKampen_iff _).mp (FinitaryExtensive.vanKampen c hc)
(BinaryCofan.mk _ _) αW _ _ e₁.symm e₂.symm).mpr <| by
constructor
· apply IsPullback.of_right _ e₁ (IsPullback.of_hasPullback _ _)
rw [Category.assoc, pullback.lift_fst, ← H.w, ← w.w]; exact hf.paste_horiz hc₄
· apply IsPullback.of_right _ e₂ (IsPullback.of_hasPullback _ _)
rw [Category.assoc, pullback.lift_fst]; exact hc₃
rw [← Category.id_comp αZ, ← show cmp ≫ pullback.snd _ _ = αY from pullback.lift_snd _ _ _]
apply IsPullback.paste_vert _ (IsPullback.of_hasPullback αZ i)
have : cmp = (hc₂.coconePointUniqueUpToIso hc₄).hom := by
apply BinaryCofan.IsColimit.hom_ext hc₂
exacts [(hc₂.comp_coconePointUniqueUpToIso_hom hc₄ ⟨WalkingPair.left⟩).symm,
(hc₂.comp_coconePointUniqueUpToIso_hom hc₄ ⟨WalkingPair.right⟩).symm]
rw [this]
exact IsPullback.of_vert_isIso ⟨by rw [← this, Category.comp_id, pullback.lift_fst]⟩
· rintro ⟨hc₃, hc₄⟩
exact ⟨(IsPullback.of_hasPullback αY c.inr).paste_horiz hc₄, hc₃⟩
theorem IsPushout.IsVanKampen.isPullback_of_mono_left [Mono f] {H : IsPushout f g h i}
(H' : H.IsVanKampen) : IsPullback f g h i :=
((H' (𝟙 _) g g (𝟙 Y) (𝟙 _) f (𝟙 _) i (IsKernelPair.id_of_mono f)
(IsPullback.of_vert_isIso ⟨by simp⟩) H.1.flip ⟨rfl⟩ ⟨by simp⟩).mp
(IsPushout.of_horiz_isIso ⟨by simp⟩)).1.flip
theorem IsPushout.IsVanKampen.isPullback_of_mono_right [Mono g] {H : IsPushout f g h i}
(H' : H.IsVanKampen) : IsPullback f g h i :=
((H' f (𝟙 _) (𝟙 _) f (𝟙 _) (𝟙 _) g h (IsPullback.of_vert_isIso ⟨by simp⟩)
(IsKernelPair.id_of_mono g) ⟨rfl⟩ H.1 ⟨by simp⟩).mp
(IsPushout.of_vert_isIso ⟨by simp⟩)).2
theorem IsPushout.IsVanKampen.mono_of_mono_left [Mono f] {H : IsPushout f g h i}
(H' : H.IsVanKampen) : Mono i :=
IsKernelPair.mono_of_isIso_fst
((H' (𝟙 _) g g (𝟙 Y) (𝟙 _) f (𝟙 _) i (IsKernelPair.id_of_mono f)
(IsPullback.of_vert_isIso ⟨by simp⟩) H.1.flip ⟨rfl⟩ ⟨by simp⟩).mp
(IsPushout.of_horiz_isIso ⟨by simp⟩)).2
theorem IsPushout.IsVanKampen.mono_of_mono_right [Mono g] {H : IsPushout f g h i}
(H' : H.IsVanKampen) : Mono h :=
IsKernelPair.mono_of_isIso_fst
((H' f (𝟙 _) (𝟙 _) f (𝟙 _) (𝟙 _) g h (IsPullback.of_vert_isIso ⟨by simp⟩)
(IsKernelPair.id_of_mono g) ⟨rfl⟩ H.1 ⟨by simp⟩).mp
(IsPushout.of_vert_isIso ⟨by simp⟩)).1
/-- A category is adhesive if it has pushouts and pullbacks along monomorphisms,
and such pushouts are van Kampen. -/
class Adhesive (C : Type u) [Category.{v} C] : Prop where
[hasPullback_of_mono_left : ∀ {X Y S : C} (f : X ⟶ S) (g : Y ⟶ S) [Mono f], HasPullback f g]
[hasPushout_of_mono_left : ∀ {X Y S : C} (f : S ⟶ X) (g : S ⟶ Y) [Mono f], HasPushout f g]
van_kampen : ∀ {W X Y Z : C} {f : W ⟶ X} {g : W ⟶ Y} {h : X ⟶ Z} {i : Y ⟶ Z} [Mono f]
(H : IsPushout f g h i), H.IsVanKampen
attribute [instance] Adhesive.hasPullback_of_mono_left Adhesive.hasPushout_of_mono_left
theorem Adhesive.van_kampen' [Adhesive C] [Mono g] (H : IsPushout f g h i) : H.IsVanKampen :=
(Adhesive.van_kampen H.flip).flip
theorem Adhesive.isPullback_of_isPushout_of_mono_left [Adhesive C] (H : IsPushout f g h i)
[Mono f] : IsPullback f g h i :=
(Adhesive.van_kampen H).isPullback_of_mono_left
theorem Adhesive.isPullback_of_isPushout_of_mono_right [Adhesive C] (H : IsPushout f g h i)
[Mono g] : IsPullback f g h i :=
(Adhesive.van_kampen' H).isPullback_of_mono_right
theorem Adhesive.mono_of_isPushout_of_mono_left [Adhesive C] (H : IsPushout f g h i) [Mono f] :
Mono i :=
(Adhesive.van_kampen H).mono_of_mono_left
theorem Adhesive.mono_of_isPushout_of_mono_right [Adhesive C] (H : IsPushout f g h i) [Mono g] :
Mono h :=
(Adhesive.van_kampen' H).mono_of_mono_right
instance Type.adhesive : Adhesive (Type u) :=
⟨fun {_ _ _ _ f _ _ _ _} H =>
(IsPushout.isVanKampen_inl _ (Types.isCoprodOfMono f) _ _ _ H.flip).flip⟩
noncomputable instance (priority := 100) Adhesive.toRegularMonoCategory [Adhesive C] :
IsRegularMonoCategory C :=
⟨fun f _ => ⟨{
Z := pushout f f
left := pushout.inl _ _
right := pushout.inr _ _
w := pushout.condition
isLimit := (Adhesive.isPullback_of_isPushout_of_mono_left
(IsPushout.of_hasPushout f f)).isLimitFork }⟩⟩
-- This then implies that adhesive categories are balanced
example [Adhesive C] : Balanced C :=
inferInstance
section functor
universe v'' u''
variable {D : Type u''} [Category.{v''} D]
instance adhesive_functor [Adhesive C] [HasPullbacks C] [HasPushouts C] :
Adhesive (D ⥤ C) := by
constructor
intro W X Y Z f g h i hf H
rw [IsPushout.isVanKampen_iff]
apply isVanKampenColimit_of_evaluation
intro x
refine (IsVanKampenColimit.precompose_isIso_iff (diagramIsoSpan _).inv).mp ?_
refine IsVanKampenColimit.of_iso ?_ (PushoutCocone.isoMk _).symm
refine (IsPushout.isVanKampen_iff (H.map ((evaluation _ _).obj x))).mp ?_
apply Adhesive.van_kampen
theorem adhesive_of_preserves_and_reflects (F : C ⥤ D) [Adhesive D]
[H₁ : ∀ {X Y S : C} (f : X ⟶ S) (g : Y ⟶ S) [Mono f], HasPullback f g]
[H₂ : ∀ {X Y S : C} (f : S ⟶ X) (g : S ⟶ Y) [Mono f], HasPushout f g]
[PreservesLimitsOfShape WalkingCospan F]
[ReflectsLimitsOfShape WalkingCospan F]
[PreservesColimitsOfShape WalkingSpan F]
[ReflectsColimitsOfShape WalkingSpan F] :
Adhesive C := by
apply Adhesive.mk (hasPullback_of_mono_left := H₁) (hasPushout_of_mono_left := H₂)
intro W X Y Z f g h i hf H
rw [IsPushout.isVanKampen_iff]
refine IsVanKampenColimit.of_mapCocone F ?_
refine (IsVanKampenColimit.precompose_isIso_iff (diagramIsoSpan _).inv).mp ?_
refine IsVanKampenColimit.of_iso ?_ (PushoutCocone.isoMk _).symm
refine (IsPushout.isVanKampen_iff (H.map F)).mp ?_
apply Adhesive.van_kampen
theorem adhesive_of_preserves_and_reflects_isomorphism (F : C ⥤ D)
[Adhesive D] [HasPullbacks C] [HasPushouts C]
[PreservesLimitsOfShape WalkingCospan F]
[PreservesColimitsOfShape WalkingSpan F]
[F.ReflectsIsomorphisms] :
Adhesive C := by
haveI : ReflectsLimitsOfShape WalkingCospan F :=
reflectsLimitsOfShape_of_reflectsIsomorphisms
haveI : ReflectsColimitsOfShape WalkingSpan F :=
reflectsColimitsOfShape_of_reflectsIsomorphisms
exact adhesive_of_preserves_and_reflects F
theorem adhesive_of_reflective [HasPullbacks D] [Adhesive C] [HasPullbacks C] [HasPushouts C]
[H₂ : ∀ {X Y S : D} (f : S ⟶ X) (g : S ⟶ Y) [Mono f], HasPushout f g]
{Gl : C ⥤ D} {Gr : D ⥤ C} (adj : Gl ⊣ Gr) [Gr.Full] [Gr.Faithful]
[PreservesLimitsOfShape WalkingCospan Gl] :
Adhesive D := by
have := adj.leftAdjoint_preservesColimits
have := adj.rightAdjoint_preservesLimits
apply Adhesive.mk (hasPushout_of_mono_left := H₂)
intro W X Y Z f g h i _ H
have := Adhesive.van_kampen (IsPushout.of_hasPushout (Gr.map f) (Gr.map g))
rw [IsPushout.isVanKampen_iff] at this ⊢
refine (IsVanKampenColimit.precompose_isIso_iff
(Functor.isoWhiskerLeft _ (asIso adj.counit) ≪≫ Functor.rightUnitor _).hom).mp ?_
refine ((this.precompose_isIso (spanCompIso _ _ _).hom).map_reflective adj).of_iso
(IsColimit.uniqueUpToIso ?_ ?_)
· exact isColimitOfPreserves Gl ((IsColimit.precomposeHomEquiv _ _).symm <| pushoutIsPushout _ _)
· exact (IsColimit.precomposeHomEquiv _ _).symm H.isColimit
end functor
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/ChosenFiniteProducts.lean | import Mathlib.CategoryTheory.Monoidal.Cartesian.Basic
deprecated_module (since := "2025-05-15") |
.lake/packages/mathlib/Mathlib/CategoryTheory/GlueData.lean | import Mathlib.Tactic.CategoryTheory.Elementwise
import Mathlib.CategoryTheory.Limits.Shapes.Multiequalizer
import Mathlib.CategoryTheory.Limits.Constructions.EpiMono
import Mathlib.CategoryTheory.Limits.Preserves.Limits
import Mathlib.CategoryTheory.Limits.Types.Coproducts
/-!
# Gluing data
We define `GlueData` as a family of data needed to glue topological spaces, schemes, etc. We
provide the API to realize it as a multispan diagram, and also state lemmas about its
interaction with a functor that preserves certain pullbacks.
-/
noncomputable section
open CategoryTheory.Limits
namespace CategoryTheory
universe v u₁ u₂
variable (C : Type u₁) [Category.{v} C] {C' : Type u₂} [Category.{v} C']
/-- A gluing datum consists of
1. An index type `J`
2. An object `U i` for each `i : J`.
3. An object `V i j` for each `i j : J`.
4. A monomorphism `f i j : V i j ⟶ U i` for each `i j : J`.
5. A transition map `t i j : V i j ⟶ V j i` for each `i j : J`.
such that
6. `f i i` is an isomorphism.
7. `t i i` is the identity.
8. The pullback for `f i j` and `f i k` exists.
9. `V i j ×[U i] V i k ⟶ V i j ⟶ V j i` factors through `V j k ×[U j] V j i ⟶ V j i` via some
`t' : V i j ×[U i] V i k ⟶ V j k ×[U j] V j i`.
10. `t' i j k ≫ t' j k i ≫ t' k i j = 𝟙 _`.
-/
structure GlueData where
/-- The index type `J` of a gluing datum -/
J : Type v
/-- For each `i : J`, an object `U i` -/
U : J → C
/-- For each `i j : J`, an object `V i j` -/
V : J × J → C
/-- For each `i j : J`, a monomorphism `f i j : V i j ⟶ U i` -/
f : ∀ i j, V (i, j) ⟶ U i
f_mono : ∀ i j, Mono (f i j) := by infer_instance
f_hasPullback : ∀ i j k, HasPullback (f i j) (f i k) := by infer_instance
f_id : ∀ i, IsIso (f i i) := by infer_instance
/-- For each `i j : J`, a transition map `t i j : V i j ⟶ V j i` -/
t : ∀ i j, V (i, j) ⟶ V (j, i)
t_id : ∀ i, t i i = 𝟙 _
/-- The morphism via which `V i j ×[U i] V i k ⟶ V i j ⟶ V j i` factors through
`V j k ×[U j] V j i ⟶ V j i` -/
t' : ∀ i j k, pullback (f i j) (f i k) ⟶ pullback (f j k) (f j i)
t_fac : ∀ i j k, t' i j k ≫ pullback.snd _ _ = pullback.fst _ _ ≫ t i j
cocycle : ∀ i j k, t' i j k ≫ t' j k i ≫ t' k i j = 𝟙 _
attribute [simp] GlueData.t_id
attribute [instance] GlueData.f_id GlueData.f_mono GlueData.f_hasPullback
attribute [reassoc] GlueData.t_fac GlueData.cocycle
namespace GlueData
variable {C}
variable (D : GlueData C)
@[simp]
theorem t'_iij (i j : D.J) : D.t' i i j = (pullbackSymmetry _ _).hom := by
have eq₁ := D.t_fac i i j
have eq₂ := (IsIso.eq_comp_inv (D.f i i)).mpr (@pullback.condition _ _ _ _ _ _ (D.f i j) _)
rw [D.t_id, Category.comp_id, eq₂] at eq₁
have eq₃ := (IsIso.eq_comp_inv (D.f i i)).mp eq₁
rw [Category.assoc, ← pullback.condition, ← Category.assoc] at eq₃
exact
Mono.right_cancellation _ _
((Mono.right_cancellation _ _ eq₃).trans (pullbackSymmetry_hom_comp_fst _ _).symm)
theorem t'_jii (i j : D.J) : D.t' j i i = pullback.fst _ _ ≫ D.t j i ≫ inv (pullback.snd _ _) := by
rw [← Category.assoc, ← D.t_fac]
simp
theorem t'_iji (i j : D.J) : D.t' i j i = pullback.fst _ _ ≫ D.t i j ≫ inv (pullback.snd _ _) := by
rw [← Category.assoc, ← D.t_fac]
simp
@[reassoc, elementwise (attr := simp)]
theorem t_inv (i j : D.J) : D.t i j ≫ D.t j i = 𝟙 _ := by
have eq : (pullbackSymmetry (D.f i i) (D.f i j)).hom =
pullback.snd _ _ ≫ inv (pullback.fst _ _) := by simp
have := D.cocycle i j i
rw [D.t'_iij, D.t'_jii, D.t'_iji, fst_eq_snd_of_mono_eq, eq] at this
simp only [Category.assoc, IsIso.inv_hom_id_assoc] at this
rw [← IsIso.eq_inv_comp, ← Category.assoc, IsIso.comp_inv_eq] at this
simpa using this
theorem t'_inv (i j k : D.J) :
D.t' i j k ≫ (pullbackSymmetry _ _).hom ≫ D.t' j i k ≫ (pullbackSymmetry _ _).hom = 𝟙 _ := by
rw [← cancel_mono (pullback.fst (D.f i j) (D.f i k))]
simp [t_fac, t_fac_assoc]
instance t_isIso (i j : D.J) : IsIso (D.t i j) :=
⟨⟨D.t j i, D.t_inv _ _, D.t_inv _ _⟩⟩
instance t'_isIso (i j k : D.J) : IsIso (D.t' i j k) :=
⟨⟨D.t' j k i ≫ D.t' k i j, D.cocycle _ _ _, by simpa using D.cocycle _ _ _⟩⟩
@[reassoc]
theorem t'_comp_eq_pullbackSymmetry (i j k : D.J) :
D.t' j k i ≫ D.t' k i j =
(pullbackSymmetry _ _).hom ≫ D.t' j i k ≫ (pullbackSymmetry _ _).hom := by
trans inv (D.t' i j k)
· exact IsIso.eq_inv_of_hom_inv_id (D.cocycle _ _ _)
· rw [← cancel_mono (pullback.fst (D.f i j) (D.f i k))]
simp [t_fac, t_fac_assoc]
/-- (Implementation) The disjoint union of `U i`. -/
def sigmaOpens [HasCoproduct D.U] : C :=
∐ D.U
/-- (Implementation) The diagram to take colimit of. -/
def diagram : MultispanIndex (.prod D.J) C where
left := D.V
right := D.U
fst := fun ⟨i, j⟩ => D.f i j
snd := fun ⟨i, j⟩ => D.t i j ≫ D.f j i
@[simp]
theorem diagram_fst (i j : D.J) : D.diagram.fst ⟨i, j⟩ = D.f i j :=
rfl
@[simp]
theorem diagram_snd (i j : D.J) : D.diagram.snd ⟨i, j⟩ = D.t i j ≫ D.f j i :=
rfl
@[simp]
theorem diagram_left : D.diagram.left = D.V :=
rfl
@[simp]
theorem diagram_right : D.diagram.right = D.U :=
rfl
section
variable [HasMulticoequalizer D.diagram]
/-- The glued object given a family of gluing data. -/
def glued : C :=
multicoequalizer D.diagram
/-- The map `D.U i ⟶ D.glued` for each `i`. -/
def ι (i : D.J) : D.U i ⟶ D.glued :=
Multicoequalizer.π D.diagram i
@[elementwise (attr := simp)]
theorem glue_condition (i j : D.J) : D.t i j ≫ D.f j i ≫ D.ι j = D.f i j ≫ D.ι i :=
(Category.assoc _ _ _).symm.trans (Multicoequalizer.condition D.diagram ⟨i, j⟩).symm
/-- The pullback cone spanned by `V i j ⟶ U i` and `V i j ⟶ U j`.
This will often be a pullback diagram. -/
def vPullbackCone (i j : D.J) : PullbackCone (D.ι i) (D.ι j) :=
PullbackCone.mk (D.f i j) (D.t i j ≫ D.f j i) (by simp)
variable [HasColimits C]
/-- The projection `∐ D.U ⟶ D.glued` given by the colimit. -/
def π : D.sigmaOpens ⟶ D.glued :=
Multicoequalizer.sigmaπ D.diagram
instance π_epi : Epi D.π := by
unfold π
infer_instance
end
theorem types_π_surjective (D : GlueData Type*) : Function.Surjective D.π :=
(epi_iff_surjective _).mp inferInstance
theorem types_ι_jointly_surjective (D : GlueData (Type v)) (x : D.glued) :
∃ (i : _) (y : D.U i), D.ι i y = x := by
delta CategoryTheory.GlueData.ι
simp_rw [← Multicoequalizer.ι_sigmaπ D.diagram]
rcases D.types_π_surjective x with ⟨x', rfl⟩
--have := colimit.isoColimitCocone (Types.coproductColimitCocone _)
rw [← show (colimit.isoColimitCocone (Types.coproductColimitCocone.{v, v} _)).inv _ = x' from
ConcreteCategory.congr_hom
(colimit.isoColimitCocone (Types.coproductColimitCocone _)).hom_inv_id x']
rcases (colimit.isoColimitCocone (Types.coproductColimitCocone _)).hom x' with ⟨i, y⟩
exact ⟨i, y, by
simp
rfl ⟩
variable (F : C ⥤ C')
section
variable [∀ i j k, PreservesLimit (cospan (D.f i j) (D.f i k)) F]
instance (i j k : D.J) : HasPullback (F.map (D.f i j)) (F.map (D.f i k)) :=
⟨⟨⟨_, isLimitOfHasPullbackOfPreservesLimit F (D.f i j) (D.f i k)⟩⟩⟩
/-- A functor that preserves the pullbacks of `f i j` and `f i k` can map a family of glue data. -/
@[simps]
def mapGlueData : GlueData C' where
J := D.J
U i := F.obj (D.U i)
V i := F.obj (D.V i)
f i j := F.map (D.f i j)
f_mono _ _ := preserves_mono_of_preservesLimit _ _
f_id _ := inferInstance
t i j := F.map (D.t i j)
t_id i := by
simp
t' i j k :=
(PreservesPullback.iso F (D.f i j) (D.f i k)).inv ≫
F.map (D.t' i j k) ≫ (PreservesPullback.iso F (D.f j k) (D.f j i)).hom
t_fac i j k := by simpa [Iso.inv_comp_eq] using congr_arg (fun f => F.map f) (D.t_fac i j k)
cocycle i j k := by
simp only [Category.assoc, Iso.hom_inv_id_assoc, ← Functor.map_comp_assoc, D.cocycle,
Iso.inv_hom_id, CategoryTheory.Functor.map_id, Category.id_comp]
/-- The diagram of the image of a `GlueData` under a functor `F` is naturally isomorphic to the
original diagram of the `GlueData` via `F`.
-/
def diagramIso : D.diagram.multispan ⋙ F ≅ (D.mapGlueData F).diagram.multispan :=
NatIso.ofComponents
(fun x =>
match x with
| WalkingMultispan.left _ => Iso.refl _
| WalkingMultispan.right _ => Iso.refl _)
(by
rintro (⟨_, _⟩ | _) _ (_ | _ | _)
· erw [Category.comp_id, Category.id_comp, Functor.map_id]
rfl
· erw [Category.comp_id, Category.id_comp]
rfl
· erw [Category.comp_id, Category.id_comp, Functor.map_comp]
rfl
· erw [Category.comp_id, Category.id_comp, Functor.map_id]
rfl)
@[simp]
theorem diagramIso_app_left (i : D.J × D.J) :
(D.diagramIso F).app (WalkingMultispan.left i) = Iso.refl _ :=
rfl
@[simp]
theorem diagramIso_app_right (i : D.J) :
(D.diagramIso F).app (WalkingMultispan.right i) = Iso.refl _ :=
rfl
@[simp]
theorem diagramIso_hom_app_left (i : D.J × D.J) :
(D.diagramIso F).hom.app (WalkingMultispan.left i) = 𝟙 _ :=
rfl
@[simp]
theorem diagramIso_hom_app_right (i : D.J) :
(D.diagramIso F).hom.app (WalkingMultispan.right i) = 𝟙 _ :=
rfl
@[simp]
theorem diagramIso_inv_app_left (i : D.J × D.J) :
(D.diagramIso F).inv.app (WalkingMultispan.left i) = 𝟙 _ :=
rfl
@[simp]
theorem diagramIso_inv_app_right (i : D.J) :
(D.diagramIso F).inv.app (WalkingMultispan.right i) = 𝟙 _ :=
rfl
end
variable [HasMulticoequalizer D.diagram] [PreservesColimit D.diagram.multispan F]
theorem hasColimit_multispan_comp : HasColimit (D.diagram.multispan ⋙ F) :=
⟨⟨⟨_, isColimitOfPreserves _ (colimit.isColimit _)⟩⟩⟩
attribute [local instance] hasColimit_multispan_comp
variable [∀ i j k, PreservesLimit (cospan (D.f i j) (D.f i k)) F]
theorem hasColimit_mapGlueData_diagram : HasMulticoequalizer (D.mapGlueData F).diagram :=
hasColimit_of_iso (D.diagramIso F).symm
attribute [local instance] hasColimit_mapGlueData_diagram
/-- If `F` preserves the gluing, we obtain an iso between the glued objects. -/
def gluedIso : F.obj D.glued ≅ (D.mapGlueData F).glued :=
haveI : HasColimit (MultispanIndex.multispan (diagram (mapGlueData D F))) := inferInstance
preservesColimitIso F D.diagram.multispan ≪≫ Limits.HasColimit.isoOfNatIso (D.diagramIso F)
@[reassoc (attr := simp)]
theorem ι_gluedIso_hom (i : D.J) : F.map (D.ι i) ≫ (D.gluedIso F).hom = (D.mapGlueData F).ι i := by
haveI : HasColimit (MultispanIndex.multispan (diagram (mapGlueData D F))) := inferInstance
erw [ι_preservesColimitIso_hom_assoc]
rw [HasColimit.isoOfNatIso_ι_hom]
erw [Category.id_comp]
rfl
@[reassoc (attr := simp)]
theorem ι_gluedIso_inv (i : D.J) : (D.mapGlueData F).ι i ≫ (D.gluedIso F).inv = F.map (D.ι i) := by
rw [Iso.comp_inv_eq, ι_gluedIso_hom]
/-- If `F` preserves the gluing, and reflects the pullback of `U i ⟶ glued` and `U j ⟶ glued`,
then `F` reflects the fact that `V_pullback_cone` is a pullback. -/
def vPullbackConeIsLimitOfMap (i j : D.J) [ReflectsLimit (cospan (D.ι i) (D.ι j)) F]
(hc : IsLimit ((D.mapGlueData F).vPullbackCone i j)) : IsLimit (D.vPullbackCone i j) := by
apply isLimitOfReflects F
apply (isLimitMapConePullbackConeEquiv _ _).symm _
let e : cospan (F.map (D.ι i)) (F.map (D.ι j)) ≅
cospan ((D.mapGlueData F).ι i) ((D.mapGlueData F).ι j) :=
NatIso.ofComponents
(fun x => by
cases x
exacts [D.gluedIso F, Iso.refl _])
(by rintro (_ | _) (_ | _) (_ | _ | _) <;> simp)
apply IsLimit.postcomposeHomEquiv e _ _
apply hc.ofIsoLimit
refine Cones.ext (Iso.refl _) ?_
rintro (_ | _ | _)
all_goals simp [e]; rfl
/-- If there is a forgetful functor into `Type` that preserves enough (co)limits, then `D.ι` will
be jointly surjective. -/
theorem ι_jointly_surjective (F : C ⥤ Type v) [PreservesColimit D.diagram.multispan F]
[∀ i j k : D.J, PreservesLimit (cospan (D.f i j) (D.f i k)) F] (x : F.obj D.glued) :
∃ (i : _) (y : F.obj (D.U i)), F.map (D.ι i) y = x := by
let e := D.gluedIso F
obtain ⟨i, y, eq⟩ := (D.mapGlueData F).types_ι_jointly_surjective (e.hom x)
replace eq := congr_arg e.inv eq
change ((D.mapGlueData F).ι i ≫ e.inv) y = (e.hom ≫ e.inv) x at eq
rw [e.hom_inv_id, D.ι_gluedIso_inv] at eq
exact ⟨i, y, eq⟩
end GlueData
section GlueData'
/--
This is a variant of `GlueData` that only requires conditions on `V (i, j)` when `i ≠ j`.
See `GlueData.ofGlueData'`
-/
structure GlueData' where
/-- Indexing type of a glue data. -/
J : Type v
/-- Objects of a glue data to be glued. -/
U : J → C
/-- Objects representing the intersections. -/
V : ∀ (i j : J), i ≠ j → C
/-- The inclusion maps of the intersection into the object. -/
f : ∀ i j h, V i j h ⟶ U i
f_mono : ∀ i j h, Mono (f i j h) := by infer_instance
f_hasPullback : ∀ i j k hij hik, HasPullback (f i j hij) (f i k hik) := by infer_instance
/-- The transition maps between the intersections. -/
t : ∀ i j h, V i j h ⟶ V j i h.symm
/-- The transition maps between the intersection of intersections. -/
t' : ∀ i j k hij hik hjk,
pullback (f i j hij) (f i k hik) ⟶ pullback (f j k hjk) (f j i hij.symm)
t_fac : ∀ i j k hij hik hjk, t' i j k hij hik hjk ≫ pullback.snd _ _ =
pullback.fst _ _ ≫ t i j hij
t_inv : ∀ i j hij, t i j hij ≫ t j i hij.symm = 𝟙 _
cocycle : ∀ i j k hij hik hjk, t' i j k hij hik hjk ≫
t' j k i hjk hij.symm hik.symm ≫ t' k i j hik.symm hjk.symm hij = 𝟙 _
attribute [local instance] GlueData'.f_mono GlueData'.f_hasPullback
attribute [reassoc (attr := simp)] GlueData'.t_inv GlueData'.cocycle
variable {C}
open scoped Classical in
/-- (Implementation detail) the constructed `GlueData.f` from a `GlueData'`. -/
abbrev GlueData'.f' (D : GlueData' C) (i j : D.J) :
(if h : i = j then D.U i else D.V i j h) ⟶ D.U i :=
if h : i = j then eqToHom (dif_pos h) else eqToHom (dif_neg h) ≫ D.f i j h
instance (D : GlueData' C) (i j : D.J) :
Mono (D.f' i j) := by dsimp [GlueData'.f']; split_ifs <;> infer_instance
instance (D : GlueData' C) (i : D.J) :
IsIso (D.f' i i) := by simp only [GlueData'.f', ↓reduceDIte]; infer_instance
instance (D : GlueData' C) (i j k : D.J) :
HasPullback (D.f' i j) (D.f' i k) := by
if hij : i = j then
apply (config := { allowSynthFailures := true }) hasPullback_of_left_iso
simp only [GlueData'.f', dif_pos hij]
infer_instance
else if hik : i = k then
apply (config := { allowSynthFailures := true }) hasPullback_of_right_iso
simp only [GlueData'.f', dif_pos hik]
infer_instance
else
have {X Y Z : C} (f : X ⟶ Y) (e : Z = X) : eqToHom e ≫ f ≍ f := by subst e; simp
convert D.f_hasPullback i j k hij hik <;> simp [GlueData'.f', hij, hik, this]
open scoped Classical in
/-- (Implementation detail) the constructed `GlueData.t'` from a `GlueData'`. -/
def GlueData'.t'' (D : GlueData' C) (i j k : D.J) :
pullback (D.f' i j) (D.f' i k) ⟶ pullback (D.f' j k) (D.f' j i) :=
if hij : i = j then
(pullbackSymmetry _ _).hom ≫
pullback.map _ _ _ _ (eqToHom (by aesop)) (eqToHom (by aesop)) (eqToHom (by aesop))
(by aesop) (by aesop)
else if hik : i = k then
have : IsIso (pullback.snd (D.f' j k) (D.f' j i)) := by
subst hik; infer_instance
pullback.fst _ _ ≫ eqToHom (dif_neg hij) ≫ D.t _ _ _ ≫
eqToHom (dif_neg (Ne.symm hij)).symm ≫ inv (pullback.snd _ _)
else if hjk : j = k then
have : IsIso (pullback.snd (D.f' j k) (D.f' j i)) := by
apply (config := { allowSynthFailures := true }) pullback_snd_iso_of_left_iso
simp only [hjk, GlueData'.f', ↓reduceDIte]
infer_instance
pullback.fst _ _ ≫ eqToHom (dif_neg hij) ≫ D.t _ _ _ ≫
eqToHom (dif_neg (Ne.symm hij)).symm ≫ inv (pullback.snd _ _)
else
haveI := Ne.symm hij
pullback.map _ _ _ _ (eqToHom (by aesop)) (eqToHom (by rw [dif_neg hik]))
(eqToHom (by simp)) (by delta f'; aesop) (by delta f'; aesop) ≫
D.t' i j k hij hik hjk ≫
pullback.map _ _ _ _ (eqToHom (by aesop)) (eqToHom (by aesop)) (eqToHom (by simp))
(by delta f'; aesop) (by delta f'; aesop)
open scoped Classical in
/--
The constructed `GlueData` of a `GlueData'`, where `GlueData'` is a variant of `GlueData` that only
requires conditions on `V (i, j)` when `i ≠ j`.
-/
def GlueData.ofGlueData' (D : GlueData' C) : GlueData C where
J := D.J
U := D.U
V ij := if h : ij.1 = ij.2 then D.U ij.1 else D.V ij.1 ij.2 h
f i j := D.f' i j
f_id i := by simp only [↓reduceDIte, GlueData'.f']; infer_instance
t i j := if h : i = j then eqToHom (by simp [h]) else
eqToHom (dif_neg h) ≫ D.t i j h ≫ eqToHom (dif_neg (Ne.symm h)).symm
t_id i := by simp
t' := D.t''
t_fac i j k := by
delta GlueData'.t''
obtain rfl | _ := eq_or_ne i j
· simp
obtain rfl | _ := eq_or_ne i k
· simp [*]
obtain rfl | _ := eq_or_ne j k
· simp [*]
· simp [*, reassoc_of% D.t_fac]
cocycle i j k := by
delta GlueData'.t''
if hij : i = j then
subst hij
if hik : i = k then
subst hik
ext <;> simp
else
simp [hik, Ne.symm hik, fst_eq_snd_of_mono_eq]
else if hik : i = k then
subst hik
ext <;> simp [hij, Ne.symm hij, fst_eq_snd_of_mono_eq, pullback.condition_assoc]
else if hjk : j = k then
subst hjk
ext <;> simp [hij, Ne.symm hij, fst_eq_snd_of_mono_eq]
else
ext <;> simp [hij, Ne.symm hij, hik, Ne.symm hik, hjk, Ne.symm hjk,
pullback.map_comp_assoc]
end GlueData'
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/ConnectedComponents.lean | import Mathlib.Data.List.Chain
import Mathlib.CategoryTheory.IsConnected
import Mathlib.CategoryTheory.Sigma.Basic
import Mathlib.CategoryTheory.ObjectProperty.FullSubcategory
/-!
# Connected components of a category
Defines a type `ConnectedComponents J` indexing the connected components of a category, and the
full subcategories giving each connected component: `Component j : Type u₁`.
We show that each `Component j` is in fact connected.
We show every category can be expressed as a disjoint union of its connected components, in
particular `Decomposed J` is the category (definitionally) given by the sigma-type of the connected
components of `J`, and it is shown that this is equivalent to `J`.
-/
universe v₁ v₂ v₃ u₁ u₂
noncomputable section
open CategoryTheory.Category
namespace CategoryTheory
attribute [instance 100] IsConnected.is_nonempty
variable {J : Type u₁} [Category.{v₁} J]
/-- This type indexes the connected components of the category `J`. -/
def ConnectedComponents (J : Type u₁) [Category.{v₁} J] : Type u₁ :=
Quotient (Zigzag.setoid J)
/-- The map `ConnectedComponents J → ConnectedComponents K` induced by a functor `J ⥤ K`. -/
def Functor.mapConnectedComponents {K : Type u₂} [Category.{v₂} K] (F : J ⥤ K)
(x : ConnectedComponents J) : ConnectedComponents K :=
x |> Quotient.lift (Quotient.mk (Zigzag.setoid _) ∘ F.obj)
(fun _ _ ↦ Quot.sound ∘ zigzag_obj_of_zigzag F)
@[simp]
lemma Functor.mapConnectedComponents_mk {K : Type u₂} [Category.{v₂} K] (F : J ⥤ K) (j : J) :
F.mapConnectedComponents (Quotient.mk _ j) = Quotient.mk _ (F.obj j) := rfl
instance [Inhabited J] : Inhabited (ConnectedComponents J) :=
⟨Quotient.mk'' default⟩
/-- Every function from connected components of a category gives a functor to discrete category -/
def ConnectedComponents.functorToDiscrete (X : Type*)
(f : ConnectedComponents J → X) : J ⥤ Discrete X where
obj Y := Discrete.mk (f (Quotient.mk (Zigzag.setoid _) Y))
map g := Discrete.eqToHom (congrArg f (Quotient.sound (Zigzag.of_hom g)))
/-- Every functor to a discrete category gives a function from connected components -/
def ConnectedComponents.liftFunctor (J) [Category J] {X : Type*} (F : J ⥤ Discrete X) :
(ConnectedComponents J → X) :=
Quotient.lift (fun c => (F.obj c).as)
(fun _ _ h => eq_of_zigzag X (zigzag_obj_of_zigzag F h))
/-- Functions from connected components and functors to discrete category are in bijection -/
def ConnectedComponents.typeToCatHomEquiv (J) [Category J] (X : Type*) :
(ConnectedComponents J → X) ≃ (J ⥤ Discrete X) where
toFun := ConnectedComponents.functorToDiscrete _
invFun := ConnectedComponents.liftFunctor _
left_inv f := funext fun x ↦ by
obtain ⟨x, h⟩ := Quotient.exists_rep x
rw [← h]
rfl
right_inv fctr :=
Functor.hext (fun _ ↦ rfl) (fun c d f ↦
have : Subsingleton (fctr.obj c ⟶ fctr.obj d) := Discrete.instSubsingletonDiscreteHom _ _
(Subsingleton.elim (fctr.map f) _).symm.heq)
/-- Given an index for a connected component, this is the property of the
objects which belong to this component. -/
def ConnectedComponents.objectProperty (j : ConnectedComponents J) :
ObjectProperty J := fun k => Quotient.mk'' k = j
/-- Given an index for a connected component, produce the actual component as a full subcategory. -/
abbrev ConnectedComponents.Component (j : ConnectedComponents J) : Type u₁ :=
j.objectProperty.FullSubcategory
/-- The inclusion functor from a connected component to the whole category. -/
abbrev ConnectedComponents.ι (j : ConnectedComponents J) : j.Component ⥤ J := j.objectProperty.ι
/-- The connected component of an object in a category. -/
abbrev ConnectedComponents.mk (j : J) : ConnectedComponents J :=
Quotient.mk'' j
/-- Each connected component of the category is nonempty. -/
instance (j : ConnectedComponents J) : Nonempty j.Component := by
induction j using Quotient.inductionOn'
exact ⟨⟨_, rfl⟩⟩
instance (j : ConnectedComponents J) : Inhabited j.Component :=
Classical.inhabited_of_nonempty'
/-- Each connected component of the category is connected. -/
instance (j : ConnectedComponents J) : IsConnected j.Component := by
-- Show it's connected by constructing a zigzag (in `j.Component`) between any two objects
apply isConnected_of_zigzag
rintro ⟨j₁, hj₁⟩ ⟨j₂, rfl⟩
-- We know that the underlying objects j₁ j₂ have some zigzag between them in `J`
have h₁₂ : Zigzag j₁ j₂ := Quotient.exact' hj₁
-- Get an explicit zigzag as a list
rcases List.exists_isChain_cons_of_relationReflTransGen h₁₂ with ⟨l, hl₁, hl₂⟩
-- Everything which has a zigzag to j₂ can be lifted to the same component as `j₂`.
let f : ∀ x, Zigzag x j₂ → (ConnectedComponents.mk j₂).Component :=
fun x h => ⟨x, Quotient.sound' h⟩
-- Everything in our chosen zigzag from `j₁` to `j₂` has a zigzag to `j₂`.
have hf : ∀ a : J, a ∈ l → Zigzag a j₂ := by
intro i hi
apply hl₁.backwards_cons_induction (fun t => Zigzag t j₂) _ hl₂ _ _ _ (List.mem_of_mem_tail hi)
· intro j k
apply Relation.ReflTransGen.head
· apply Relation.ReflTransGen.refl
-- Now lift the zigzag from `j₁` to `j₂` in `J` to the same thing in `j.Component`.
refine ⟨l.pmap f hf, ?_, by grind⟩
refine @List.isChain_cons_pmap_of_isChain_cons _ _ Zag _ _ f
(fun x y _ _ h => ?_) _ _ h₁₂ hl₁ _
exact zag_of_zag_obj (ConnectedComponents.ι _) h
/-- The disjoint union of `J`'s connected components, written explicitly as a sigma-type with the
category structure.
This category is equivalent to `J`.
-/
abbrev Decomposed (J : Type u₁) [Category.{v₁} J] :=
Σ j : ConnectedComponents J, j.Component
-- This name may cause clashes further down the road, and so might need to be changed.
/--
The inclusion of each component into the decomposed category. This is just `sigma.incl` but having
this abbreviation helps guide typeclass search to get the right category instance on `decomposed J`.
-/
abbrev inclusion (j : ConnectedComponents J) : j.Component ⥤ Decomposed J :=
Sigma.incl _
/-- The forward direction of the equivalence between the decomposed category and the original. -/
@[simps!]
def decomposedTo (J : Type u₁) [Category.{v₁} J] : Decomposed J ⥤ J :=
Sigma.desc ConnectedComponents.ι
@[simp]
theorem inclusion_comp_decomposedTo (j : ConnectedComponents J) :
inclusion j ⋙ decomposedTo J = ConnectedComponents.ι j :=
rfl
instance : (decomposedTo J).Full where
map_surjective := by
rintro ⟨j', X, hX⟩ ⟨k', Y, hY⟩ f
dsimp at f
have : j' = k' := by
rw [← hX, ← hY, Quotient.eq'']
exact Relation.ReflTransGen.single (Or.inl ⟨f⟩)
subst this
exact ⟨Sigma.SigmaHom.mk f, rfl⟩
instance : (decomposedTo J).Faithful where
map_injective := by
rintro ⟨_, j, rfl⟩ ⟨_, k, hY⟩ ⟨f⟩ ⟨_⟩ rfl
rfl
instance : (decomposedTo J).EssSurj where mem_essImage j := ⟨⟨_, j, rfl⟩, ⟨Iso.refl _⟩⟩
instance : (decomposedTo J).IsEquivalence where
/-- This gives that any category is equivalent to a disjoint union of connected categories. -/
@[simps! functor]
def decomposedEquiv : Decomposed J ≌ J :=
(decomposedTo J).asEquivalence
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Square.lean | import Mathlib.CategoryTheory.Comma.Arrow
import Mathlib.CategoryTheory.CommSq
/-!
# The category of commutative squares
In this file, we define a bundled version of `CommSq`
which allows to consider commutative squares as
objects in a category `Square C`.
The four objects in a commutative square are
numbered as follows:
```
X₁ --> X₂
| |
v v
X₃ --> X₄
```
We define the flip functor, and two equivalences with
the category `Arrow (Arrow C)`, depending on whether
we consider a commutative square as a horizontal
morphism between two vertical maps (`arrowArrowEquivalence`)
or a vertical morphism between two horizontal
maps (`arrowArrowEquivalence'`).
-/
universe v v' u u'
namespace CategoryTheory
open Category
variable (C : Type u) [Category.{v} C] {D : Type u'} [Category.{v'} D]
/-- The category of commutative squares in a category. -/
structure Square where
/-- the top-left object -/
{X₁ : C}
/-- the top-right object -/
{X₂ : C}
/-- the bottom-left object -/
{X₃ : C}
/-- the bottom-right object -/
{X₄ : C}
/-- the top morphism -/
f₁₂ : X₁ ⟶ X₂
/-- the left morphism -/
f₁₃ : X₁ ⟶ X₃
/-- the right morphism -/
f₂₄ : X₂ ⟶ X₄
/-- the bottom morphism -/
f₃₄ : X₃ ⟶ X₄
fac : f₁₂ ≫ f₂₄ = f₁₃ ≫ f₃₄
namespace Square
variable {C}
lemma commSq (sq : Square C) : CommSq sq.f₁₂ sq.f₁₃ sq.f₂₄ sq.f₃₄ where
w := sq.fac
/-- A morphism between two commutative squares consists of 4 morphisms
which extend these two squares into a commuting cube. -/
@[ext]
structure Hom (sq₁ sq₂ : Square C) where
/-- the top-left morphism -/
τ₁ : sq₁.X₁ ⟶ sq₂.X₁
/-- the top-right morphism -/
τ₂ : sq₁.X₂ ⟶ sq₂.X₂
/-- the bottom-left morphism -/
τ₃ : sq₁.X₃ ⟶ sq₂.X₃
/-- the bottom-right morphism -/
τ₄ : sq₁.X₄ ⟶ sq₂.X₄
comm₁₂ : sq₁.f₁₂ ≫ τ₂ = τ₁ ≫ sq₂.f₁₂ := by cat_disch
comm₁₃ : sq₁.f₁₃ ≫ τ₃ = τ₁ ≫ sq₂.f₁₃ := by cat_disch
comm₂₄ : sq₁.f₂₄ ≫ τ₄ = τ₂ ≫ sq₂.f₂₄ := by cat_disch
comm₃₄ : sq₁.f₃₄ ≫ τ₄ = τ₃ ≫ sq₂.f₃₄ := by cat_disch
namespace Hom
attribute [reassoc (attr := simp)] comm₁₂ comm₁₃ comm₂₄ comm₃₄
/-- The identity of a commutative square. -/
@[simps]
def id (sq : Square C) : Hom sq sq where
τ₁ := 𝟙 _
τ₂ := 𝟙 _
τ₃ := 𝟙 _
τ₄ := 𝟙 _
/-- The composition of morphisms of squares. -/
@[simps]
def comp {sq₁ sq₂ sq₃ : Square C} (f : Hom sq₁ sq₂) (g : Hom sq₂ sq₃) : Hom sq₁ sq₃ where
τ₁ := f.τ₁ ≫ g.τ₁
τ₂ := f.τ₂ ≫ g.τ₂
τ₃ := f.τ₃ ≫ g.τ₃
τ₄ := f.τ₄ ≫ g.τ₄
end Hom
@[simps!]
instance category : Category (Square C) where
Hom := Hom
id := Hom.id
comp := Hom.comp
@[ext]
lemma hom_ext {sq₁ sq₂ : Square C} {f g : sq₁ ⟶ sq₂}
(h₁ : f.τ₁ = g.τ₁) (h₂ : f.τ₂ = g.τ₂)
(h₃ : f.τ₃ = g.τ₃) (h₄ : f.τ₄ = g.τ₄) : f = g :=
Hom.ext h₁ h₂ h₃ h₄
/-- Constructor for isomorphisms in `Square c` -/
def isoMk {sq₁ sq₂ : Square C} (e₁ : sq₁.X₁ ≅ sq₂.X₁) (e₂ : sq₁.X₂ ≅ sq₂.X₂)
(e₃ : sq₁.X₃ ≅ sq₂.X₃) (e₄ : sq₁.X₄ ≅ sq₂.X₄)
(comm₁₂ : sq₁.f₁₂ ≫ e₂.hom = e₁.hom ≫ sq₂.f₁₂)
(comm₁₃ : sq₁.f₁₃ ≫ e₃.hom = e₁.hom ≫ sq₂.f₁₃)
(comm₂₄ : sq₁.f₂₄ ≫ e₄.hom = e₂.hom ≫ sq₂.f₂₄)
(comm₃₄ : sq₁.f₃₄ ≫ e₄.hom = e₃.hom ≫ sq₂.f₃₄) :
sq₁ ≅ sq₂ where
hom :=
{ τ₁ := e₁.hom
τ₂ := e₂.hom
τ₃ := e₃.hom
τ₄ := e₄.hom }
inv :=
{ τ₁ := e₁.inv
τ₂ := e₂.inv
τ₃ := e₃.inv
τ₄ := e₄.inv
comm₁₂ := by simp only [← cancel_mono e₂.hom, assoc, Iso.inv_hom_id,
comp_id, comm₁₂, Iso.inv_hom_id_assoc]
comm₁₃ := by simp only [← cancel_mono e₃.hom, assoc, Iso.inv_hom_id,
comp_id, comm₁₃, Iso.inv_hom_id_assoc]
comm₂₄ := by simp only [← cancel_mono e₄.hom, assoc, Iso.inv_hom_id,
comp_id, comm₂₄, Iso.inv_hom_id_assoc]
comm₃₄ := by simp only [← cancel_mono e₄.hom, assoc, Iso.inv_hom_id,
comp_id, comm₃₄, Iso.inv_hom_id_assoc] }
/-- Flipping a square by switching the top-right and the bottom-left objects. -/
@[simps]
def flip (sq : Square C) : Square C where
f₁₂ := sq.f₁₃
f₁₃ := sq.f₁₂
f₂₄ := sq.f₃₄
f₃₄ := sq.f₂₄
fac := sq.fac.symm
/-- The functor which flips commutative squares. -/
@[simps]
def flipFunctor : Square C ⥤ Square C where
obj := flip
map φ :=
{ τ₁ := φ.τ₁
τ₂ := φ.τ₃
τ₃ := φ.τ₂
τ₄ := φ.τ₄ }
/-- Flipping commutative squares is an auto-equivalence. -/
@[simps]
def flipEquivalence : Square C ≌ Square C where
functor := flipFunctor
inverse := flipFunctor
unitIso := Iso.refl _
counitIso := Iso.refl _
/-- The functor `Square C ⥤ Arrow (Arrow C)` which sends a
commutative square `sq` to the obvious arrow from the left morphism of `sq`
to the right morphism of `sq`. -/
@[simps!]
def toArrowArrowFunctor : Square C ⥤ Arrow (Arrow C) where
obj sq := Arrow.mk (Arrow.homMk _ _ sq.fac : Arrow.mk sq.f₁₃ ⟶ Arrow.mk sq.f₂₄)
map φ := Arrow.homMk (Arrow.homMk _ _ φ.comm₁₃.symm)
(Arrow.homMk _ _ φ.comm₂₄.symm)
/-- The functor `Arrow (Arrow C) ⥤ Square C` which sends
a morphism `Arrow.mk f ⟶ Arrow.mk g` to the commutative square
with `f` on the left side and `g` on the right side. -/
@[simps!]
def fromArrowArrowFunctor : Arrow (Arrow C) ⥤ Square C where
obj f := { fac := f.hom.w, .. }
map φ :=
{ τ₁ := φ.left.left
τ₂ := φ.right.left
τ₃ := φ.left.right
τ₄ := φ.right.right
comm₁₂ := Arrow.leftFunc.congr_map φ.w.symm
comm₁₃ := φ.left.w.symm
comm₂₄ := φ.right.w.symm
comm₃₄ := Arrow.rightFunc.congr_map φ.w.symm }
/-- The equivalence `Square C ≌ Arrow (Arrow C)` which sends a
commutative square `sq` to the obvious arrow from the left morphism of `sq`
to the right morphism of `sq`. -/
@[simps]
def arrowArrowEquivalence : Square C ≌ Arrow (Arrow C) where
functor := toArrowArrowFunctor
inverse := fromArrowArrowFunctor
unitIso := Iso.refl _
counitIso := Iso.refl _
/-- The functor `Square C ⥤ Arrow (Arrow C)` which sends a
commutative square `sq` to the obvious arrow from the top morphism of `sq`
to the bottom morphism of `sq`. -/
@[simps!]
def toArrowArrowFunctor' : Square C ⥤ Arrow (Arrow C) where
obj sq := Arrow.mk (Arrow.homMk _ _ sq.fac.symm : Arrow.mk sq.f₁₂ ⟶ Arrow.mk sq.f₃₄)
map φ := Arrow.homMk (Arrow.homMk _ _ φ.comm₁₂.symm)
(Arrow.homMk _ _ φ.comm₃₄.symm)
/-- The functor `Arrow (Arrow C) ⥤ Square C` which sends
a morphism `Arrow.mk f ⟶ Arrow.mk g` to the commutative square
with `f` on the top side and `g` on the bottom side. -/
@[simps!]
def fromArrowArrowFunctor' : Arrow (Arrow C) ⥤ Square C where
obj f := { fac := f.hom.w.symm, .. }
map φ :=
{ τ₁ := φ.left.left
τ₂ := φ.left.right
τ₃ := φ.right.left
τ₄ := φ.right.right
comm₁₂ := φ.left.w.symm
comm₁₃ := Arrow.leftFunc.congr_map φ.w.symm
comm₂₄ := Arrow.rightFunc.congr_map φ.w.symm
comm₃₄ := φ.right.w.symm }
/-- The equivalence `Square C ≌ Arrow (Arrow C)` which sends a
commutative square `sq` to the obvious arrow from the top morphism of `sq`
to the bottom morphism of `sq`. -/
@[simps]
def arrowArrowEquivalence' : Square C ≌ Arrow (Arrow C) where
functor := toArrowArrowFunctor'
inverse := fromArrowArrowFunctor'
unitIso := Iso.refl _
counitIso := Iso.refl _
/-- The top-left evaluation `Square C ⥤ C`. -/
@[simps]
def evaluation₁ : Square C ⥤ C where
obj sq := sq.X₁
map φ := φ.τ₁
/-- The top-right evaluation `Square C ⥤ C`. -/
@[simps]
def evaluation₂ : Square C ⥤ C where
obj sq := sq.X₂
map φ := φ.τ₂
/-- The bottom-left evaluation `Square C ⥤ C`. -/
@[simps]
def evaluation₃ : Square C ⥤ C where
obj sq := sq.X₃
map φ := φ.τ₃
/-- The bottom-right evaluation `Square C ⥤ C`. -/
@[simps]
def evaluation₄ : Square C ⥤ C where
obj sq := sq.X₄
map φ := φ.τ₄
/-- The map `Square C → Square Cᵒᵖ` which switches `X₁` and `X₃`, but
does not move `X₂` and `X₃`. -/
@[simps]
protected def op (sq : Square C) : Square Cᵒᵖ where
f₁₂ := sq.f₂₄.op
f₁₃ := sq.f₃₄.op
f₂₄ := sq.f₁₂.op
f₃₄ := sq.f₁₃.op
fac := Quiver.Hom.unop_inj sq.fac
/-- The map `Square Cᵒᵖ → Square C` which switches `X₁` and `X₃`, but
does not move `X₂` and `X₃`. -/
@[simps]
protected def unop (sq : Square Cᵒᵖ) : Square C where
f₁₂ := sq.f₂₄.unop
f₁₃ := sq.f₃₄.unop
f₂₄ := sq.f₁₂.unop
f₃₄ := sq.f₁₃.unop
fac := Quiver.Hom.op_inj sq.fac
/-- The functor `(Square C)ᵒᵖ ⥤ Square Cᵒᵖ`. -/
@[simps]
def opFunctor : (Square C)ᵒᵖ ⥤ Square Cᵒᵖ where
obj sq := sq.unop.op
map φ :=
{ τ₁ := φ.unop.τ₄.op
τ₂ := φ.unop.τ₂.op
τ₃ := φ.unop.τ₃.op
τ₄ := φ.unop.τ₁.op
comm₁₂ := Quiver.Hom.unop_inj (by simp)
comm₁₃ := Quiver.Hom.unop_inj (by simp)
comm₂₄ := Quiver.Hom.unop_inj (by simp)
comm₃₄ := Quiver.Hom.unop_inj (by simp) }
/-- The functor `(Square Cᵒᵖ)ᵒᵖ ⥤ Square Cᵒᵖ`. -/
def unopFunctor : (Square Cᵒᵖ)ᵒᵖ ⥤ Square C where
obj sq := sq.unop.unop
map φ :=
{ τ₁ := φ.unop.τ₄.unop
τ₂ := φ.unop.τ₂.unop
τ₃ := φ.unop.τ₃.unop
τ₄ := φ.unop.τ₁.unop
comm₁₂ := Quiver.Hom.op_inj (by simp)
comm₁₃ := Quiver.Hom.op_inj (by simp)
comm₂₄ := Quiver.Hom.op_inj (by simp)
comm₃₄ := Quiver.Hom.op_inj (by simp) }
/-- The equivalence `(Square C)ᵒᵖ ≌ Square Cᵒᵖ`. -/
def opEquivalence : (Square C)ᵒᵖ ≌ Square Cᵒᵖ where
functor := opFunctor
inverse := unopFunctor.rightOp
unitIso := Iso.refl _
counitIso := Iso.refl _
/-- The image of a commutative square by a functor. -/
@[simps]
def map (sq : Square C) (F : C ⥤ D) : Square D where
f₁₂ := F.map sq.f₁₂
f₁₃ := F.map sq.f₁₃
f₂₄ := F.map sq.f₂₄
f₃₄ := F.map sq.f₃₄
fac := by simpa using F.congr_map sq.fac
end Square
variable {C}
namespace Functor
/-- The functor `Square C ⥤ Square D` induced by a functor `C ⥤ D`. -/
@[simps]
def mapSquare (F : C ⥤ D) : Square C ⥤ Square D where
obj sq := sq.map F
map φ :=
{ τ₁ := F.map φ.τ₁
τ₂ := F.map φ.τ₂
τ₃ := F.map φ.τ₃
τ₄ := F.map φ.τ₄
comm₁₂ := by simpa only [Functor.map_comp] using F.congr_map φ.comm₁₂
comm₁₃ := by simpa only [Functor.map_comp] using F.congr_map φ.comm₁₃
comm₂₄ := by simpa only [Functor.map_comp] using F.congr_map φ.comm₂₄
comm₃₄ := by simpa only [Functor.map_comp] using F.congr_map φ.comm₃₄ }
end Functor
/-- The natural transformation `F.mapSquare ⟶ G.mapSquare` induces
by a natural transformation `F ⟶ G`. -/
@[simps]
def NatTrans.mapSquare {F G : C ⥤ D} (τ : F ⟶ G) :
F.mapSquare ⟶ G.mapSquare where
app sq :=
{ τ₁ := τ.app _
τ₂ := τ.app _
τ₃ := τ.app _
τ₄ := τ.app _ }
/-- The functor `(C ⥤ D) ⥤ Square C ⥤ Square D`. -/
@[simps]
def Square.mapFunctor : (C ⥤ D) ⥤ Square C ⥤ Square D where
obj F := F.mapSquare
map τ := NatTrans.mapSquare τ
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Endomorphism.lean | import Mathlib.Algebra.Group.Action.Defs
import Mathlib.Algebra.Group.Equiv.Defs
import Mathlib.Algebra.Group.Opposite
import Mathlib.Algebra.Group.Units.Hom
import Mathlib.CategoryTheory.Groupoid
/-!
# Endomorphisms
Definition and basic properties of endomorphisms and automorphisms of an object in a category.
For each `X : C`, we provide `CategoryTheory.End X := X ⟶ X` with a monoid structure,
and `CategoryTheory.Aut X := X ≅ X` with a group structure.
-/
universe v v' u u'
namespace CategoryTheory
/-- Endomorphisms of an object in a category. Arguments order in multiplication agrees with
`Function.comp`, not with `CategoryTheory.CategoryStruct.comp`. -/
def End {C : Type u} [CategoryStruct.{v} C] (X : C) := X ⟶ X
namespace End
section Struct
variable {C : Type u} [CategoryStruct.{v} C] (X : C)
protected instance one : One (End X) := ⟨𝟙 X⟩
protected instance inhabited : Inhabited (End X) := ⟨𝟙 X⟩
/-- Multiplication of endomorphisms agrees with `Function.comp`, not with
`CategoryTheory.CategoryStruct.comp`. -/
protected instance mul : Mul (End X) := ⟨fun x y => y ≫ x⟩
variable {X}
/-- Assist the typechecker by expressing a morphism `X ⟶ X` as a term of `CategoryTheory.End X`. -/
def of (f : X ⟶ X) : End X := f
/-- Assist the typechecker by expressing an endomorphism `f : CategoryTheory.End X` as a term of
`X ⟶ X`. -/
def asHom (f : End X) : X ⟶ X := f
-- TODO: to fix defeq abuse, this should be `(1 : End x) = of (𝟙 X)`.
-- But that would require many more extra simp lemmas to get rid of the `of`.
@[simp]
theorem one_def : (1 : End X) = 𝟙 X := rfl
-- TODO: to fix defeq abuse, this should be `xs * ys = of (ys ≫ xs)`.
-- But that would require many more extra simp lemmas to get rid of the `of`.
@[simp]
theorem mul_def (xs ys : End X) : xs * ys = ys ≫ xs := rfl
end Struct
/-- Endomorphisms of an object form a monoid -/
instance monoid {C : Type u} [Category.{v} C] {X : C} : Monoid (End X) where
mul_one := Category.id_comp
one_mul := Category.comp_id
mul_assoc := fun x y z => (Category.assoc z y x).symm
section MulAction
variable {C : Type u} [Category.{v} C]
open Opposite
instance mulActionRight {X Y : C} : MulAction (End Y) (X ⟶ Y) where
smul r f := f ≫ r
one_smul := Category.comp_id
mul_smul _ _ _ := Eq.symm <| Category.assoc _ _ _
instance mulActionLeft {X Y : C} : MulAction (End X)ᵐᵒᵖ (X ⟶ Y) where
smul r f := r.unop ≫ f
one_smul := Category.id_comp
mul_smul _ _ _ := Category.assoc _ _ _
theorem smul_right {X Y : C} {r : End Y} {f : X ⟶ Y} : r • f = f ≫ r :=
rfl
theorem smul_left {X Y : C} {r : (End X)ᵐᵒᵖ} {f : X ⟶ Y} : r • f = r.unop ≫ f :=
rfl
end MulAction
/-- In a groupoid, endomorphisms form a group -/
instance group {C : Type u} [Groupoid.{v} C] (X : C) : Group (End X) where
inv_mul_cancel := Groupoid.comp_inv
inv := Groupoid.inv
end End
theorem isUnit_iff_isIso {C : Type u} [Category.{v} C] {X : C} (f : End X) :
IsUnit (f : End X) ↔ IsIso f :=
⟨fun h => { out := ⟨h.unit.inv, ⟨h.unit.inv_val, h.unit.val_inv⟩⟩ }, fun h =>
⟨⟨f, inv f, by simp, by simp⟩, rfl⟩⟩
variable {C : Type u} [Category.{v} C] (X : C)
/-- Automorphisms of an object in a category.
The order of arguments in multiplication agrees with
`Function.comp`, not with `CategoryTheory.CategoryStruct.comp`.
-/
def Aut (X : C) := X ≅ X
namespace Aut
@[ext]
lemma ext {X : C} {φ₁ φ₂ : Aut X} (h : φ₁.hom = φ₂.hom) : φ₁ = φ₂ :=
Iso.ext h
protected instance inhabited : Inhabited (Aut X) := ⟨Iso.refl X⟩
instance : Group (Aut X) where
one := Iso.refl X
inv := Iso.symm
mul x y := Iso.trans y x
mul_assoc _ _ _ := (Iso.trans_assoc _ _ _).symm
one_mul := Iso.trans_refl
mul_one := Iso.refl_trans
inv_mul_cancel := Iso.self_symm_id
theorem Aut_mul_def (f g : Aut X) : f * g = g.trans f := rfl
theorem Aut_inv_def (f : Aut X) : f⁻¹ = f.symm := rfl
/-- Units in the monoid of endomorphisms of an object
are (multiplicatively) equivalent to automorphisms of that object.
-/
def unitsEndEquivAut : (End X)ˣ ≃* Aut X where
toFun f := ⟨f.1, f.2, f.4, f.3⟩
invFun f := ⟨f.1, f.2, f.4, f.3⟩
map_mul' f g := by cases f; cases g; rfl
/-- The inclusion of `Aut X` to `End X` as a monoid homomorphism. -/
@[simps!]
def toEnd (X : C) : Aut X →* End X := (Units.coeHom (End X)).comp (Aut.unitsEndEquivAut X).symm
/-- Isomorphisms induce isomorphisms of the automorphism group -/
def autMulEquivOfIso {X Y : C} (h : X ≅ Y) : Aut X ≃* Aut Y where
toFun x := { hom := h.inv ≫ x.hom ≫ h.hom, inv := h.inv ≫ x.inv ≫ h.hom }
invFun y := { hom := h.hom ≫ y.hom ≫ h.inv, inv := h.hom ≫ y.inv ≫ h.inv }
left_inv _ := by cat_disch
right_inv _ := by cat_disch
map_mul' := by simp [Aut_mul_def]
end Aut
namespace Functor
variable {D : Type u'} [Category.{v'} D] (f : C ⥤ D)
/-- `f.map` as a monoid hom between endomorphism monoids. -/
@[simps]
def mapEnd : End X →* End (f.obj X) where
toFun := f.map
map_mul' x y := f.map_comp y x
map_one' := f.map_id X
/-- `f.mapIso` as a group hom between automorphism groups. -/
def mapAut : Aut X →* Aut (f.obj X) where
toFun := f.mapIso
map_mul' x y := f.mapIso_trans y x
map_one' := f.mapIso_refl X
namespace FullyFaithful
variable {f}
variable (hf : FullyFaithful f)
/-- `mulEquivEnd` as an isomorphism between endomorphism monoids. -/
@[simps!]
noncomputable def mulEquivEnd (X : C) :
End X ≃* End (f.obj X) where
toEquiv := hf.homEquiv
__ := mapEnd X f
/-- `mulEquivAut` as an isomorphism between automorphism groups. -/
@[simps!]
noncomputable def autMulEquivOfFullyFaithful (X : C) :
Aut X ≃* Aut (f.obj X) where
toEquiv := hf.isoEquiv
__ := mapAut X f
end FullyFaithful
end Functor
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/DinatTrans.lean | import Mathlib.CategoryTheory.Opposites
/-!
# Dinatural transformations
Dinatural transformations are special kinds of transformations between
functors `F G : Cᵒᵖ ⥤ C ⥤ D` which depend both covariantly and contravariantly
on the same category (also known as difunctors).
A dinatural transformation is a family of morphisms given only on *the diagonal* of the two
functors, and is such that a certain naturality hexagon commutes.
Note that dinatural transformations cannot be composed with each other (since the outer
hexagon does not commute in general), but can still be "pre/post-composed" with
ordinary natural transformations.
## References
* <https://ncatlab.org/nlab/show/dinatural+transformation>
-/
namespace CategoryTheory
universe v₁ v₂ v₃ v₄ u₁ u₂ u₃ u₄
variable {C : Type u₁} [Category.{v₁} C] {D : Type u₂} [Category.{v₂} D]
open Opposite
/-- Dinatural transformations between two difunctors. -/
structure DinatTrans (F G : Cᵒᵖ ⥤ C ⥤ D) : Type max u₁ v₂ where
/-- The component of a natural transformation. -/
app (X : C) : (F.obj (op X)).obj X ⟶ (G.obj (op X)).obj X
/-- The commutativity square for a given morphism. -/
dinaturality {X Y : C} (f : X ⟶ Y) :
(F.map f.op).app X ≫ app X ≫ (G.obj (op X)).map f =
(F.obj (op Y)).map f ≫ app Y ≫ (G.map f.op).app Y := by cat_disch
attribute [reassoc (attr := simp)] DinatTrans.dinaturality
namespace DinatTrans
/-- Notation for dinatural transformations. -/
scoped infixr:50 " ⤞ " => DinatTrans
variable {F G H : Cᵒᵖ ⥤ C ⥤ D}
/-- Post-composition with a natural transformation. -/
@[simps]
def compNatTrans (δ : F ⤞ G) (α : G ⟶ H) : F ⤞ H where
app X := δ.app X ≫ (α.app (op X)).app X
dinaturality f := by
rw [Category.assoc, Category.assoc, ← NatTrans.naturality_app,
← δ.dinaturality_assoc f, NatTrans.naturality]
/-- Pre-composition with a natural transformation. -/
@[simps]
def precompNatTrans (δ : G ⤞ H) (α : F ⟶ G) : F ⤞ H where
app X := (α.app (op X)).app X ≫ δ.app X
end DinatTrans
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/WithTerminal.lean | import Mathlib.CategoryTheory.WithTerminal.Basic
deprecated_module (since := "2025-04-10") |
.lake/packages/mathlib/Mathlib/CategoryTheory/Action.lean | import Mathlib.CategoryTheory.Elements
import Mathlib.CategoryTheory.IsConnected
import Mathlib.CategoryTheory.SingleObj
import Mathlib.GroupTheory.GroupAction.Quotient
import Mathlib.GroupTheory.SemidirectProduct
/-!
# Actions as functors and as categories
From a multiplicative action M ↻ X, we can construct a functor from M to the category of
types, mapping the single object of M to X and an element `m : M` to the map `X → X` given by
multiplication by `m`.
This functor induces a category structure on X -- a special case of the category of elements.
A morphism `x ⟶ y` in this category is simply a scalar `m : M` such that `m • x = y`. In the case
where M is a group, this category is a groupoid -- the *action groupoid*.
-/
open MulAction SemidirectProduct
namespace CategoryTheory
universe u
variable (M : Type*) [Monoid M] (X : Type u) [MulAction M X]
/-- A multiplicative action M ↻ X viewed as a functor mapping the single object of M to X
and an element `m : M` to the map `X → X` given by multiplication by `m`. -/
@[simps]
def actionAsFunctor : SingleObj M ⥤ Type u where
obj _ := X
map := (· • ·)
map_id _ := funext <| MulAction.one_smul
map_comp f g := funext fun x => (smul_smul g f x).symm
/-- A multiplicative action M ↻ X induces a category structure on X, where a morphism
from x to y is a scalar taking x to y. Due to implementation details, the object type
of this category is not equal to X, but is in bijection with X. -/
def ActionCategory :=
(actionAsFunctor M X).Elements
instance : Category (ActionCategory M X) := by
dsimp only [ActionCategory]
infer_instance
namespace ActionCategory
/-- The projection from the action category to the monoid, mapping a morphism to its
label. -/
def π : ActionCategory M X ⥤ SingleObj M :=
CategoryOfElements.π _
@[simp]
theorem π_map (p q : ActionCategory M X) (f : p ⟶ q) : (π M X).map f = f.val :=
rfl
@[simp]
theorem π_obj (p : ActionCategory M X) : (π M X).obj p = SingleObj.star M :=
Unit.ext _ _
variable {M X}
/-- The canonical map `ActionCategory M X → X`. It is given by `fun x => x.snd`, but
has a more explicit type. -/
protected def back : ActionCategory M X → X := fun x => x.snd
instance : CoeTC X (ActionCategory M X) :=
⟨fun x => ⟨(), x⟩⟩
@[simp]
theorem coe_back (x : X) : ActionCategory.back (x : ActionCategory M X) = x :=
rfl
@[simp]
theorem back_coe (x : ActionCategory M X) : ↑x.back = x := by cases x; rfl
variable (M X)
/-- An object of the action category given by M ↻ X corresponds to an element of X. -/
def objEquiv : X ≃ ActionCategory M X where
toFun x := x
invFun x := x.back
left_inv := coe_back
right_inv := back_coe
theorem hom_as_subtype (p q : ActionCategory M X) : (p ⟶ q) = { m : M // m • p.back = q.back } :=
rfl
instance [Inhabited X] : Inhabited (ActionCategory M X) :=
⟨show X from default⟩
instance [Nonempty X] : Nonempty (ActionCategory M X) :=
Nonempty.map (objEquiv M X) inferInstance
variable {X} (x : X)
/-- The stabilizer of a point is isomorphic to the endomorphism monoid at the
corresponding point. In fact they are definitionally equivalent. -/
def stabilizerIsoEnd : stabilizerSubmonoid M x ≃* @End (ActionCategory M X) _ x :=
MulEquiv.refl _
@[simp]
theorem stabilizerIsoEnd_apply (f : stabilizerSubmonoid M x) :
(stabilizerIsoEnd M x) f = f :=
rfl
@[simp 1100]
theorem stabilizerIsoEnd_symm_apply (f : End _) : (stabilizerIsoEnd M x).symm f = f :=
rfl
variable {M}
@[simp]
protected theorem id_val (x : ActionCategory M X) : Subtype.val (𝟙 x) = 1 :=
rfl
@[simp]
protected theorem comp_val {x y z : ActionCategory M X} (f : x ⟶ y) (g : y ⟶ z) :
(f ≫ g).val = g.val * f.val :=
rfl
instance [IsPretransitive M X] [Nonempty X] : IsConnected (ActionCategory M X) :=
zigzag_isConnected fun x y =>
Relation.ReflTransGen.single <|
Or.inl <| nonempty_subtype.mpr (show _ from exists_smul_eq M x.back y.back)
section Group
variable {G : Type*} [Group G] [MulAction G X]
instance : Groupoid (ActionCategory G X) :=
CategoryTheory.groupoidOfElements _
/-- Any subgroup of `G` is a vertex group in its action groupoid. -/
def endMulEquivSubgroup (H : Subgroup G) : End (objEquiv G (G ⧸ H) ↑(1 : G)) ≃* H :=
MulEquiv.trans (stabilizerIsoEnd G ((1 : G) : G ⧸ H)).symm
(MulEquiv.subgroupCongr <| stabilizer_quotient H)
/-- A target vertex `t` and a scalar `g` determine a morphism in the action groupoid. -/
def homOfPair (t : X) (g : G) : @Quiver.Hom (ActionCategory G X) _ (g⁻¹ • t :) t :=
Subtype.mk g (smul_inv_smul g t)
@[simp]
theorem homOfPair.val (t : X) (g : G) : (homOfPair t g).val = g :=
rfl
/-- Any morphism in the action groupoid is given by some pair. -/
protected def cases {P : ∀ ⦃a b : ActionCategory G X⦄, (a ⟶ b) → Sort*}
(hyp : ∀ t g, P (homOfPair t g)) ⦃a b⦄ (f : a ⟶ b) : P f := by
refine cast ?_ (hyp b.back f.val)
rcases a with ⟨⟨⟩, a : X⟩
rcases b with ⟨⟨⟩, b : X⟩
rcases f with ⟨g : G, h : g • a = b⟩
cases inv_smul_eq_iff.mpr h.symm
rfl
@[deprecated (since := "2025-08-21")]
alias cases' := ActionCategory.cases
variable {H : Type*} [Group H]
/-- Given `G` acting on `X`, a functor from the corresponding action groupoid to a group `H`
can be curried to a group homomorphism `G →* (X → H) ⋊ G`. -/
@[simps]
def curry (F : ActionCategory G X ⥤ SingleObj H) : G →* (X → H) ⋊[mulAutArrow] G :=
have F_map_eq : ∀ {a b} {f : a ⟶ b}, F.map f = (F.map (homOfPair b.back f.val) : H) := by
apply ActionCategory.cases
intros
rfl
{ toFun := fun g => ⟨fun b => F.map (homOfPair b g), g⟩
map_one' := by
dsimp
ext1
· ext b
exact F_map_eq.symm.trans (F.map_id b)
rfl
map_mul' := by
intro g h
ext b
· exact F_map_eq.symm.trans (F.map_comp (homOfPair (g⁻¹ • b) h) (homOfPair b g))
rfl }
/-- Given `G` acting on `X`, a group homomorphism `φ : G →* (X → H) ⋊ G` can be uncurried to
a functor from the action groupoid to `H`, provided that `φ g = (_, g)` for all `g`. -/
@[simps]
def uncurry (F : G →* (X → H) ⋊[mulAutArrow] G) (sane : ∀ g, (F g).right = g) :
ActionCategory G X ⥤ SingleObj H where
obj _ := ()
map {_ b} f := (F f.val).left b.back
map_id x := by
dsimp
rw [F.map_one]
rfl
map_comp f g := by
cases g using ActionCategory.cases
simp [SingleObj.comp_as_mul, sane]
rfl
end Group
end ActionCategory
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/EssentialImage.lean | import Mathlib.CategoryTheory.NatIso
import Mathlib.CategoryTheory.ObjectProperty.ClosedUnderIsomorphisms
import Mathlib.CategoryTheory.ObjectProperty.FullSubcategory
/-!
# Essential image of a functor
The essential image `essImage` of a functor consists of the objects in the target category which
are isomorphic to an object in the image of the object function.
This, for instance, allows us to talk about objects belonging to a subcategory expressed as a
functor rather than a subtype, preserving the principle of equivalence. For example this lets us
define exponential ideals.
The essential image can also be seen as a subcategory of the target category, and witnesses that
a functor decomposes into an essentially surjective functor and a fully faithful functor.
(TODO: show that this decomposition forms an orthogonal factorisation system).
-/
universe v₁ v₂ v₃ u₁ u₂ u₃
noncomputable section
namespace CategoryTheory
variable {C : Type u₁} {D : Type u₂} {E : Type u₃}
[Category.{v₁} C] [Category.{v₂} D] [Category.{v₃} E] {F : C ⥤ D} {G : D ⥤ E}
namespace Functor
/-- The essential image of a functor `F` consists of those objects in the target category which are
isomorphic to an object in the image of the function `F.obj`. In other words, this is the closure
under isomorphism of the function `F.obj`.
This is the "non-evil" way of describing the image of a functor.
-/
def essImage (F : C ⥤ D) : ObjectProperty D := fun Y => ∃ X : C, Nonempty (F.obj X ≅ Y)
/-- Get the witnessing object that `Y` is in the subcategory given by `F`. -/
def essImage.witness {Y : D} (h : F.essImage Y) : C :=
h.choose
/-- Extract the isomorphism between `F.obj h.witness` and `Y` itself. -/
def essImage.getIso {Y : D} (h : F.essImage Y) : F.obj h.witness ≅ Y :=
Classical.choice h.choose_spec
/-- Being in the essential image is a "hygienic" property: it is preserved under isomorphism. -/
theorem essImage.ofIso {Y Y' : D} (h : Y ≅ Y') (hY : essImage F Y) : essImage F Y' :=
hY.imp fun _ => Nonempty.map (· ≪≫ h)
instance : F.essImage.IsClosedUnderIsomorphisms where
of_iso e h := essImage.ofIso e h
/-- If `Y` is in the essential image of `F` then it is in the essential image of `F'` as long as
`F ≅ F'`.
-/
theorem essImage.ofNatIso {F' : C ⥤ D} (h : F ≅ F') {Y : D} (hY : essImage F Y) :
essImage F' Y :=
hY.imp fun X => Nonempty.map fun t => h.symm.app X ≪≫ t
/-- Isomorphic functors have equal essential images. -/
theorem essImage_eq_of_natIso {F' : C ⥤ D} (h : F ≅ F') : essImage F = essImage F' :=
funext fun _ => propext ⟨essImage.ofNatIso h, essImage.ofNatIso h.symm⟩
/-- An object in the image is in the essential image. -/
theorem obj_mem_essImage (F : D ⥤ C) (Y : D) : essImage F (F.obj Y) :=
⟨Y, ⟨Iso.refl _⟩⟩
/-- The essential image of a functor, interpreted as a full subcategory of the target category. -/
abbrev EssImageSubcategory (F : C ⥤ D) := F.essImage.FullSubcategory
lemma essImage_ext (F : C ⥤ D) {X Y : F.EssImageSubcategory} (f g : X ⟶ Y)
(h : F.essImage.ι.map f = F.essImage.ι.map g) : f = g :=
F.essImage.ι.map_injective h
/--
Given a functor `F : C ⥤ D`, we have an (essentially surjective) functor from `C` to the essential
image of `F`.
-/
@[simps!]
def toEssImage (F : C ⥤ D) : C ⥤ F.EssImageSubcategory :=
F.essImage.lift F (obj_mem_essImage _)
/-- The functor `F` factorises through its essential image, where the first functor is essentially
surjective and the second is fully faithful.
-/
@[simps!]
def toEssImageCompι (F : C ⥤ D) : F.toEssImage ⋙ F.essImage.ι ≅ F :=
ObjectProperty.liftCompιIso _ _ _
/-- A functor `F : C ⥤ D` is essentially surjective if every object of `D` is in the essential
image of `F`. In other words, for every `Y : D`, there is some `X : C` with `F.obj X ≅ Y`. -/
@[stacks 001C]
class EssSurj (F : C ⥤ D) : Prop where
/-- All the objects of the target category are in the essential image. -/
mem_essImage (Y : D) : F.essImage Y
instance EssSurj.toEssImage : EssSurj F.toEssImage where
mem_essImage := fun ⟨_, hY⟩ =>
⟨_, ⟨⟨_, _, hY.getIso.hom_inv_id, hY.getIso.inv_hom_id⟩⟩⟩
theorem essSurj_of_surj (h : Function.Surjective F.obj) : EssSurj F where
mem_essImage Y := by
obtain ⟨X, rfl⟩ := h Y
apply obj_mem_essImage
section EssSurj
variable (F)
variable [F.EssSurj]
/-- Given an essentially surjective functor, we can find a preimage for every object `Y` in the
codomain. Applying the functor to this preimage will yield an object isomorphic to `Y`, see
`obj_obj_preimage_iso`. -/
def objPreimage (Y : D) : C :=
essImage.witness (@EssSurj.mem_essImage _ _ _ _ F _ Y)
/-- Applying an essentially surjective functor to a preimage of `Y` yields an object that is
isomorphic to `Y`. -/
def objObjPreimageIso (Y : D) : F.obj (F.objPreimage Y) ≅ Y :=
Functor.essImage.getIso _
/-- The induced functor of a faithful functor is faithful. -/
instance Faithful.toEssImage (F : C ⥤ D) [Faithful F] : Faithful F.toEssImage := by
dsimp only [Functor.toEssImage]
infer_instance
/-- The induced functor of a full functor is full. -/
instance Full.toEssImage (F : C ⥤ D) [Full F] : Full F.toEssImage := by
dsimp only [Functor.toEssImage]
infer_instance
instance instEssSurjId : EssSurj (𝟭 C) where
mem_essImage Y := ⟨Y, ⟨Iso.refl _⟩⟩
lemma essSurj_of_iso {F G : C ⥤ D} [EssSurj F] (α : F ≅ G) : EssSurj G where
mem_essImage Y := Functor.essImage.ofNatIso α (EssSurj.mem_essImage Y)
instance essSurj_comp (F : C ⥤ D) (G : D ⥤ E) [F.EssSurj] [G.EssSurj] :
(F ⋙ G).EssSurj where
mem_essImage Z := ⟨_, ⟨G.mapIso (F.objObjPreimageIso _) ≪≫ G.objObjPreimageIso Z⟩⟩
lemma essSurj_of_comp_fully_faithful (F : C ⥤ D) (G : D ⥤ E) [(F ⋙ G).EssSurj]
[G.Faithful] [G.Full] : F.EssSurj where
mem_essImage X := ⟨_, ⟨G.preimageIso ((F ⋙ G).objObjPreimageIso (G.obj X))⟩⟩
variable {F} {X : E}
/-- Pre-composing by an essentially surjective functor doesn't change the essential image. -/
lemma essImage_comp_apply_of_essSurj : (F ⋙ G).essImage X ↔ G.essImage X where
mp := fun ⟨Y, ⟨e⟩⟩ ↦ ⟨F.obj Y, ⟨e⟩⟩
mpr := fun ⟨Y, ⟨e⟩⟩ ↦
let ⟨Z, ⟨e'⟩⟩ := Functor.EssSurj.mem_essImage Y; ⟨Z, ⟨(G.mapIso e').trans e⟩⟩
/-- Pre-composing by an essentially surjective functor doesn't change the essential image. -/
@[simp] lemma essImage_comp_of_essSurj : (F ⋙ G).essImage = G.essImage :=
funext fun _X ↦ propext essImage_comp_apply_of_essSurj
end EssSurj
variable {J C D : Type*} [Category J] [Category C] [Category D]
(G : J ⥤ D) (F : C ⥤ D) [F.Full] [F.Faithful] (hG : ∀ j, F.essImage (G.obj j))
/-- Lift a functor `G : J ⥤ D` to the essential image of a fully faithful functor `F : C ⥤ D` to a
functor `G' : J ⥤ C` such that `G' ⋙ F ≅ G`. See `essImage.liftFunctorCompIso`. -/
@[simps] def essImage.liftFunctor : J ⥤ C where
obj j := F.toEssImage.objPreimage ⟨G.obj j, hG j⟩
-- TODO: `map` isn't type-correct:
-- It conflates `⟨G.obj i, hG i⟩ ⟶ ⟨G.obj j, hG j⟩` and `G.obj i ⟶ G.obj j`.
map {i j} f := F.preimage <|
(F.toEssImage.objObjPreimageIso ⟨G.obj i, hG i⟩).hom ≫ G.map f ≫
(F.toEssImage.objObjPreimageIso ⟨G.obj j, hG j⟩).inv
map_id i := F.map_injective <| by
simpa [-Iso.hom_inv_id] using (F.toEssImage.objObjPreimageIso ⟨G.obj i, hG i⟩).hom_inv_id
map_comp {i j k} f g := F.map_injective <| by
simp only [Functor.map_comp, Category.assoc, Functor.map_preimage]
congr 2
symm
convert (F.toEssImage.objObjPreimageIso ⟨G.obj j, hG j⟩).inv_hom_id_assoc (G.map g ≫
(F.toEssImage.objObjPreimageIso ⟨G.obj k, hG k⟩).inv)
/-- A functor `G : J ⥤ D` to the essential image of a fully faithful functor `F : C ⥤ D` does
factor through `essImage.liftFunctor G F hG`. -/
@[simps!] def essImage.liftFunctorCompIso : essImage.liftFunctor G F hG ⋙ F ≅ G :=
NatIso.ofComponents
(fun i ↦ F.essImage.ι.mapIso (F.toEssImage.objObjPreimageIso ⟨G.obj i, hG _⟩))
fun {i j} f ↦ by
simp only [Functor.comp_obj, liftFunctor_obj, Functor.comp_map, liftFunctor_map,
Functor.map_preimage, Functor.mapIso_hom, ObjectProperty.ι_map, Category.assoc]
congr 1
convert Category.comp_id _
exact (F.toEssImage.objObjPreimageIso ⟨G.obj j, hG j⟩).inv_hom_id
end Functor
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/InducedCategory.lean | import Mathlib.CategoryTheory.Functor.FullyFaithful
/-!
# Induced categories and full subcategories
Given a category `D` and a function `F : C → D `from a type `C` to the
objects of `D`, there is an essentially unique way to give `C` a
category structure such that `F` becomes a fully faithful functor,
namely by taking $$ Hom_C(X, Y) = Hom_D(FX, FY) $$. We call this the
category induced from `D` along `F`.
## Implementation notes
It looks odd to make `D` an explicit argument of `InducedCategory`,
when it is determined by the argument `F` anyways. The reason to make `D`
explicit is in order to control its syntactic form, so that instances
like `InducedCategory.has_forget₂` (elsewhere) refer to the correct
form of `D`. This is used to set up several algebraic categories like
def CommMon : Type (u+1) := InducedCategory Mon (Bundled.map @CommMonoid.toMonoid)
-- not `InducedCategory (Bundled Monoid) (Bundled.map @CommMonoid.toMonoid)`,
-- even though `MonCat = Bundled Monoid`!
-/
namespace CategoryTheory
universe v v₂ u₁ u₂
-- morphism levels before object levels. See note [category theory universes].
section Induced
variable {C : Type u₁} (D : Type u₂) [Category.{v} D]
variable (F : C → D)
/-- `InducedCategory D F`, where `F : C → D`, is a typeclass synonym for `C`,
which provides a category structure so that the morphisms `X ⟶ Y` are the morphisms
in `D` from `F X` to `F Y`.
-/
@[nolint unusedArguments]
def InducedCategory (_F : C → D) : Type u₁ :=
C
variable {D}
instance InducedCategory.hasCoeToSort {α : Sort*} [CoeSort D α] :
CoeSort (InducedCategory D F) α :=
⟨fun c => F c⟩
instance InducedCategory.category : Category.{v} (InducedCategory D F) where
Hom X Y := F X ⟶ F Y
id X := 𝟙 (F X)
comp f g := f ≫ g
variable {F} in
/-- Construct an isomorphism in the induced category
from an isomorphism in the original category. -/
@[simps] def InducedCategory.isoMk {X Y : InducedCategory D F} (f : F X ≅ F Y) : X ≅ Y where
hom := f.hom
inv := f.inv
hom_inv_id := f.hom_inv_id
inv_hom_id := f.inv_hom_id
/-- The forgetful functor from an induced category to the original category,
forgetting the extra data.
-/
@[simps]
def inducedFunctor : InducedCategory D F ⥤ D where
obj := F
map f := f
/-- The induced functor `inducedFunctor F : InducedCategory D F ⥤ D` is fully faithful. -/
def fullyFaithfulInducedFunctor : (inducedFunctor F).FullyFaithful where
preimage f := f
instance InducedCategory.full : (inducedFunctor F).Full :=
(fullyFaithfulInducedFunctor F).full
instance InducedCategory.faithful : (inducedFunctor F).Faithful :=
(fullyFaithfulInducedFunctor F).faithful
end Induced
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/SmallRepresentatives.lean | import Mathlib.CategoryTheory.Equivalence
import Mathlib.SetTheory.Cardinal.Order
/-!
# Representatives of small categories
Given a type `Ω : Type w`, we construct a structure `SmallCategoryOfSet Ω : Type w`
which consists of the data and axioms that allows to define a category
structure such that the type of objects and morphisms identify to subtypes of `Ω`.
This allows to define a small family of small categories
`SmallCategoryOfSet.categoryFamily : SmallCategoryOfSet Ω → Type w`
which, up to equivalence, represents all categories such that
types of objects and morphisms have cardinalities less than or equal to
that of `Ω` (see `SmallCategoryOfSet.exists_equivalence`).
-/
universe w v u
namespace CategoryTheory
variable (Ω : Type w)
/-- Structure which allows to construct a category whose types
of objects and morphisms are subtypes of a fixed type `Ω`. -/
structure SmallCategoryOfSet where
/-- objects -/
obj : Set Ω
/-- morphisms -/
hom (X Y : obj) : Set Ω
/-- identity morphisms -/
id (X : obj) : hom X X
/-- the composition of morphisms -/
comp {X Y Z : obj} (f : hom X Y) (g : hom Y Z) : hom X Z
id_comp {X Y : obj} (f : hom X Y) : comp (id _) f = f := by cat_disch
comp_id {X Y : obj} (f : hom X Y) : comp f (id _) = f := by cat_disch
assoc {X Y Z T : obj} (f : hom X Y) (g : hom Y Z) (h : hom Z T) :
comp (comp f g) h = comp f (comp g h) := by cat_disch
namespace SmallCategoryOfSet
attribute [simp] id_comp comp_id assoc
@[simps]
instance (S : SmallCategoryOfSet Ω) : SmallCategory S.obj where
Hom X Y := S.hom X Y
id := S.id
comp := S.comp
/-- The family of all categories such that the types of objects and
morphisms are subtypes of a given type `Ω`. -/
abbrev categoryFamily : SmallCategoryOfSet Ω → Type w := fun S ↦ S.obj
end SmallCategoryOfSet
variable (C : Type u) [Category.{v} C]
/-- Helper structure for the construction of a term in `SmallCategoryOfSet`.
This involves the choice of bijections between types of objects and morphisms
in a category `C` and subtypes of a type `Ω`. -/
structure CoreSmallCategoryOfSet where
/-- objects -/
obj : Set Ω
/-- morphisms -/
hom (X Y : obj) : Set Ω
/-- a bijection between the types of objects -/
objEquiv : obj ≃ C
/-- a bijection between the types of morphisms -/
homEquiv {X Y : obj} : hom X Y ≃ (objEquiv X ⟶ objEquiv Y)
namespace CoreSmallCategoryOfSet
variable {Ω C} (h : CoreSmallCategoryOfSet Ω C)
/-- The `SmallCategoryOfSet` structure induced by a
`CoreSmallCategoryOfSet` structure. -/
@[simps]
def smallCategoryOfSet : SmallCategoryOfSet Ω where
obj := h.obj
hom := h.hom
id X := h.homEquiv.symm (𝟙 _)
comp f g := h.homEquiv.symm (h.homEquiv f ≫ h.homEquiv g)
/-- Given `h : CoreSmallCategoryOfSet Ω C`, this is the
obvious functor `h.smallCategoryOfSet.obj ⥤ C`. -/
@[simps!]
def functor : h.smallCategoryOfSet.obj ⥤ C where
obj := h.objEquiv
map := h.homEquiv
map_id _ := by rw [SmallCategoryOfSet.id_def]; simp
map_comp _ _ := by rw [SmallCategoryOfSet.comp_def]; simp
/-- Given `h : CoreSmallCategoryOfSet Ω C`,
the obvious functor `h.smallCategoryOfSet.obj ⥤ C` is fully faithful. -/
def fullyFaithfulFunctor : h.functor.FullyFaithful where
preimage := h.homEquiv.symm
instance : h.functor.IsEquivalence where
faithful := h.fullyFaithfulFunctor.faithful
full := h.fullyFaithfulFunctor.full
essSurj.mem_essImage Y := by
obtain ⟨X, rfl⟩ := h.objEquiv.surjective Y
exact ⟨_, ⟨Iso.refl _⟩⟩
/-- Given `h : CoreSmallCategoryOfSet Ω C`,
the obvious functor `h.smallCategoryOfSet.obj ⥤ C` is an equivalence. -/
noncomputable def equivalence : h.smallCategoryOfSet.obj ≌ C :=
h.functor.asEquivalence
end CoreSmallCategoryOfSet
namespace SmallCategoryOfSet
lemma exists_equivalence (C : Type u) [Category.{v} C]
(h₁ : Cardinal.lift.{w} (Cardinal.mk C) ≤ Cardinal.lift.{u} (Cardinal.mk Ω))
(h₂ : ∀ (X Y : C), Cardinal.lift.{w} (Cardinal.mk (X ⟶ Y)) ≤
Cardinal.lift.{v} (Cardinal.mk Ω)) :
∃ (h : SmallCategoryOfSet Ω), Nonempty (categoryFamily Ω h ≌ C) := by
let f₁ := (Cardinal.lift_mk_le'.1 h₁).some
let f₂ (X Y) := (Cardinal.lift_mk_le'.1 (h₂ X Y)).some
let e := Equiv.ofInjective _ f₁.injective
let h : CoreSmallCategoryOfSet Ω C :=
{ obj := Set.range f₁
hom X Y := Set.range (f₂ (e.symm X) (e.symm Y))
objEquiv := e.symm
homEquiv {_ _} := by simpa using (Equiv.ofInjective _ ((f₂ _ _).injective)).symm }
exact ⟨h.smallCategoryOfSet, ⟨h.equivalence⟩⟩
end SmallCategoryOfSet
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/SingleObj.lean | import Mathlib.CategoryTheory.Endomorphism
import Mathlib.CategoryTheory.FinCategory.Basic
import Mathlib.CategoryTheory.Category.Cat
import Mathlib.Algebra.Category.MonCat.Basic
import Mathlib.Combinatorics.Quiver.SingleObj
import Mathlib.Algebra.Group.Units.Equiv
/-!
# Single-object category
Single object category with a given monoid of endomorphisms.
It is defined to facilitate transferring some definitions and lemmas (e.g., conjugacy etc.)
from category theory to monoids and groups.
## Main definitions
Given a type `M` with a monoid structure, `SingleObj M` is `Unit` type with `Category` structure
such that `End (SingleObj M).star` is the monoid `M`. This can be extended to a functor
`MonCat ⥤ Cat`.
If `M` is a group, then `SingleObj M` is a groupoid.
An element `x : M` can be reinterpreted as an element of `End (SingleObj.star M)` using
`SingleObj.toEnd`.
## Implementation notes
- `categoryStruct.comp` on `End (SingleObj.star M)` is `flip (*)`, not `(*)`. This way
multiplication on `End` agrees with the multiplication on `M`.
- By default, Lean puts instances into `CategoryTheory` namespace instead of
`CategoryTheory.SingleObj`, so we give all names explicitly.
-/
assert_not_exists MonoidWithZero
universe u v w
namespace CategoryTheory
/-- Abbreviation that allows writing `CategoryTheory.SingleObj` rather than `Quiver.SingleObj`.
-/
abbrev SingleObj :=
Quiver.SingleObj
namespace SingleObj
variable (M G : Type u)
/-- One and `flip (*)` become `id` and `comp` for morphisms of the single object category. -/
instance categoryStruct [One M] [Mul M] : CategoryStruct (SingleObj M) where
Hom _ _ := M
comp x y := y * x
id _ := 1
variable [Monoid M] [Group G]
/-- Monoid laws become category laws for the single object category. -/
instance category : Category (SingleObj M) where
comp_id := one_mul
id_comp := mul_one
assoc x y z := (mul_assoc z y x).symm
theorem id_as_one (x : SingleObj M) : 𝟙 x = 1 :=
rfl
theorem comp_as_mul {x y z : SingleObj M} (f : x ⟶ y) (g : y ⟶ z) : f ≫ g = g * f :=
rfl
/-- If `M` is finite and in universe zero, then `SingleObj M` is a `FinCategory`. -/
instance finCategoryOfFintype (M : Type) [Fintype M] [Monoid M] : FinCategory (SingleObj M) where
/-- Groupoid structure on `SingleObj M`. -/
@[stacks 0019]
instance groupoid : Groupoid (SingleObj G) where
inv x := x⁻¹
inv_comp := mul_inv_cancel
comp_inv := inv_mul_cancel
theorem inv_as_inv {x y : SingleObj G} (f : x ⟶ y) : inv f = f⁻¹ := by
apply IsIso.inv_eq_of_hom_inv_id
rw [comp_as_mul, inv_mul_cancel, id_as_one]
/-- Abbreviation that allows writing `CategoryTheory.SingleObj.star` rather than
`Quiver.SingleObj.star`.
-/
abbrev star : SingleObj M :=
Quiver.SingleObj.star M
/-- The endomorphisms monoid of the only object in `SingleObj M` is equivalent to the original
monoid `M`. -/
def toEnd : M ≃* End (SingleObj.star M) :=
{ Equiv.refl M with map_mul' := fun _ _ => rfl }
theorem toEnd_def (x : M) : toEnd M x = x :=
rfl
variable (N : Type v) [Monoid N]
/-- There is a 1-1 correspondence between monoid homomorphisms `M → N` and functors between the
corresponding single-object categories. It means that `SingleObj` is a fully faithful functor. -/
@[stacks 001F "We do not characterize when the functor is full or faithful."]
def mapHom : (M →* N) ≃ SingleObj M ⥤ SingleObj N where
toFun f :=
{ obj := id
map := ⇑f
map_id := fun _ => f.map_one
map_comp := fun x y => f.map_mul y x }
invFun f :=
{ toFun := fun x => f.map ((toEnd M) x)
map_one' := f.map_id _
map_mul' := fun x y => f.map_comp y x }
left_inv := by cat_disch
right_inv := by cat_disch
theorem mapHom_id : mapHom M M (MonoidHom.id M) = 𝟭 _ :=
rfl
variable {M N G}
theorem mapHom_comp (f : M →* N) {P : Type w} [Monoid P] (g : N →* P) :
mapHom M P (g.comp f) = mapHom M N f ⋙ mapHom N P g :=
rfl
variable {C : Type v} [Category.{w} C]
/-- Given a function `f : C → G` from a category to a group, we get a functor
`C ⥤ G` sending any morphism `x ⟶ y` to `f y * (f x)⁻¹`. -/
@[simps]
def differenceFunctor (f : C → G) : C ⥤ SingleObj G where
obj _ := ()
map {x y} _ := f y * (f x)⁻¹
map_id := by
intro
simp only [SingleObj.id_as_one, mul_inv_cancel]
map_comp := by
intros
rw [SingleObj.comp_as_mul, ← mul_assoc, mul_left_inj, mul_assoc, inv_mul_cancel, mul_one]
/-- A monoid homomorphism `f: M → End X` into the endomorphisms of an object `X` of a category `C`
induces a functor `SingleObj M ⥤ C`. -/
@[simps]
def functor {X : C} (f : M →* End X) : SingleObj M ⥤ C where
obj _ := X
map a := f a
map_id _ := MonoidHom.map_one f
map_comp a b := MonoidHom.map_mul f b a
/-- Construct a natural transformation between functors `SingleObj M ⥤ C` by
giving a compatible morphism `SingleObj.star M`. -/
@[simps]
def natTrans {F G : SingleObj M ⥤ C} (u : F.obj (SingleObj.star M) ⟶ G.obj (SingleObj.star M))
(h : ∀ a : M, F.map a ≫ u = u ≫ G.map a) : F ⟶ G where
app _ := u
naturality _ _ a := h a
end SingleObj
end CategoryTheory
open CategoryTheory
namespace MonoidHom
variable {M : Type u} {N : Type v} [Monoid M] [Monoid N]
/-- Reinterpret a monoid homomorphism `f : M → N` as a functor `(single_obj M) ⥤ (single_obj N)`.
See also `CategoryTheory.SingleObj.mapHom` for an equivalence between these types. -/
abbrev toFunctor (f : M →* N) : SingleObj M ⥤ SingleObj N :=
SingleObj.mapHom M N f
@[simp]
theorem comp_toFunctor (f : M →* N) {P : Type w} [Monoid P] (g : N →* P) :
(g.comp f).toFunctor = f.toFunctor ⋙ g.toFunctor :=
rfl
variable (M)
@[simp]
theorem id_toFunctor : (id M).toFunctor = 𝟭 _ :=
rfl
end MonoidHom
namespace MulEquiv
variable {M : Type u} {N : Type v} [Monoid M] [Monoid N]
/-- Reinterpret a monoid isomorphism `f : M ≃* N` as an equivalence `SingleObj M ≌ SingleObj N`. -/
@[simps!]
def toSingleObjEquiv (e : M ≃* N) : SingleObj M ≌ SingleObj N where
functor := e.toMonoidHom.toFunctor
inverse := e.symm.toMonoidHom.toFunctor
unitIso := eqToIso (by
rw [← MonoidHom.comp_toFunctor, ← MonoidHom.id_toFunctor]
congr 1
simp)
counitIso := eqToIso (by
rw [← MonoidHom.comp_toFunctor, ← MonoidHom.id_toFunctor]
congr 1
simp)
end MulEquiv
namespace Units
variable (M : Type u) [Monoid M]
/-- The units in a monoid are (multiplicatively) equivalent to
the automorphisms of `star` when we think of the monoid as a single-object category. -/
def toAut : Mˣ ≃* Aut (SingleObj.star M) :=
MulEquiv.trans (Units.mapEquiv (SingleObj.toEnd M))
(Aut.unitsEndEquivAut (SingleObj.star M))
@[simp]
theorem toAut_hom (x : Mˣ) : (toAut M x).hom = SingleObj.toEnd M x :=
rfl
@[simp]
theorem toAut_inv (x : Mˣ) : (toAut M x).inv = SingleObj.toEnd M (x⁻¹ : Mˣ) :=
rfl
end Units
namespace MonCat
open CategoryTheory
/-- The fully faithful functor from `MonCat` to `Cat`. -/
def toCat : MonCat ⥤ Cat where
obj x := Cat.of (SingleObj x)
map {x y} f := SingleObj.mapHom x y f.hom
instance toCat_full : toCat.Full where
map_surjective y :=
let ⟨x, h⟩ := (SingleObj.mapHom _ _).surjective y
⟨ofHom x, h⟩
instance toCat_faithful : toCat.Faithful where
map_injective h := MonCat.hom_ext <| by rwa [toCat, (SingleObj.mapHom _ _).apply_eq_iff_eq] at h
end MonCat |
.lake/packages/mathlib/Mathlib/CategoryTheory/Opposites.lean | import Mathlib.CategoryTheory.Equivalence
/-!
# Opposite categories
We provide a category instance on `Cᵒᵖ`.
The morphisms `X ⟶ Y` are defined to be the morphisms `unop Y ⟶ unop X` in `C`.
Here `Cᵒᵖ` is an irreducible typeclass synonym for `C`
(it is the same one used in the algebra library).
We also provide various mechanisms for constructing opposite morphisms, functors,
and natural transformations.
Unfortunately, because we do not have a definitional equality `op (op X) = X`,
there are quite a few variations that are needed in practice.
-/
universe v₁ v₂ u₁ u₂
-- morphism levels before object levels. See note [category theory universes].
open Opposite
variable {C : Type u₁}
section Quiver
variable [Quiver.{v₁} C]
theorem Quiver.Hom.op_inj {X Y : C} :
Function.Injective (Quiver.Hom.op : (X ⟶ Y) → (Opposite.op Y ⟶ Opposite.op X)) := fun _ _ H =>
congr_arg Quiver.Hom.unop H
theorem Quiver.Hom.unop_inj {X Y : Cᵒᵖ} :
Function.Injective (Quiver.Hom.unop : (X ⟶ Y) → (Opposite.unop Y ⟶ Opposite.unop X)) :=
fun _ _ H => congr_arg Quiver.Hom.op H
@[simp]
theorem Quiver.Hom.unop_op {X Y : C} (f : X ⟶ Y) : f.op.unop = f :=
rfl
@[simp]
theorem Quiver.Hom.unop_op' {X Y : Cᵒᵖ} {x} :
@Quiver.Hom.unop C _ X Y no_index (Opposite.op (unop := x)) = x := rfl
@[simp]
theorem Quiver.Hom.op_unop {X Y : Cᵒᵖ} (f : X ⟶ Y) : f.unop.op = f :=
rfl
@[simp] theorem Quiver.Hom.unop_mk {X Y : Cᵒᵖ} (f : X ⟶ Y) : Quiver.Hom.unop {unop := f} = f := rfl
end Quiver
namespace CategoryTheory
section
variable [CategoryStruct.{v₁} C]
/-- The opposite `CategoryStruct`. -/
instance CategoryStruct.opposite : CategoryStruct.{v₁} Cᵒᵖ where
comp f g := (g.unop ≫ f.unop).op
id X := (𝟙 (unop X)).op
@[simp]
theorem unop_id {X : Cᵒᵖ} : (𝟙 X).unop = 𝟙 (unop X) :=
rfl
@[simp]
theorem op_id_unop {X : Cᵒᵖ} : (𝟙 (unop X)).op = 𝟙 X :=
rfl
@[simp, grind _=_]
theorem op_comp {X Y Z : C} {f : X ⟶ Y} {g : Y ⟶ Z} : (f ≫ g).op = g.op ≫ f.op :=
rfl
@[simp]
theorem op_id {X : C} : (𝟙 X).op = 𝟙 (op X) :=
rfl
@[simp]
theorem unop_comp {X Y Z : Cᵒᵖ} {f : X ⟶ Y} {g : Y ⟶ Z} : (f ≫ g).unop = g.unop ≫ f.unop :=
rfl
@[simp]
theorem unop_id_op {X : C} : (𝟙 (op X)).unop = 𝟙 X :=
rfl
-- This lemma is needed to prove `Category.opposite` below.
theorem op_comp_unop {X Y Z : Cᵒᵖ} (f : X ⟶ Y) (g : Y ⟶ Z) : (g.unop ≫ f.unop).op = f ≫ g :=
rfl
end
open Functor
variable [Category.{v₁} C]
/-- The opposite category. -/
@[stacks 001M]
instance Category.opposite : Category.{v₁} Cᵒᵖ where
__ := CategoryStruct.opposite
comp_id f := by rw [← op_comp_unop, unop_id, id_comp, Quiver.Hom.op_unop]
id_comp f := by rw [← op_comp_unop, unop_id, comp_id, Quiver.Hom.op_unop]
assoc f g h := by simp only [← op_comp_unop, Quiver.Hom.unop_op, assoc]
-- Note: these need to be proven manually as the original lemmas are only stated in terms
-- of `CategoryStruct`s!
theorem op_comp_assoc {X Y Z : C} {f : X ⟶ Y} {g : Y ⟶ Z} {Z' : Cᵒᵖ} {h : op X ⟶ Z'} :
(f ≫ g).op ≫ h = g.op ≫ f.op ≫ h := by
simp only [op_comp, Category.assoc]
theorem unop_comp_assoc {X Y Z : Cᵒᵖ} {f : X ⟶ Y} {g : Y ⟶ Z} {Z' : C} {h : unop X ⟶ Z'} :
(f ≫ g).unop ≫ h = g.unop ≫ f.unop ≫ h := by
simp only [unop_comp, Category.assoc]
section
variable (C)
/-- The functor from the double-opposite of a category to the underlying category. -/
@[simps]
def unopUnop : Cᵒᵖᵒᵖ ⥤ C where
obj X := unop (unop X)
map f := f.unop.unop
/-- The functor from a category to its double-opposite. -/
@[simps]
def opOp : C ⥤ Cᵒᵖᵒᵖ where
obj X := op (op X)
map f := f.op.op
/-- The double opposite category is equivalent to the original. -/
@[simps]
def opOpEquivalence : Cᵒᵖᵒᵖ ≌ C where
functor := unopUnop C
inverse := opOp C
unitIso := Iso.refl (𝟭 Cᵒᵖᵒᵖ)
counitIso := Iso.refl (opOp C ⋙ unopUnop C)
instance : (opOp C).IsEquivalence :=
(opOpEquivalence C).isEquivalence_inverse
instance : (unopUnop C).IsEquivalence :=
(opOpEquivalence C).isEquivalence_functor
end
/-- If `f` is an isomorphism, so is `f.op` -/
instance isIso_op {X Y : C} (f : X ⟶ Y) [IsIso f] : IsIso f.op :=
⟨⟨(inv f).op, ⟨Quiver.Hom.unop_inj (by simp), Quiver.Hom.unop_inj (by simp)⟩⟩⟩
/-- If `f.op` is an isomorphism `f` must be too.
(This cannot be an instance as it would immediately loop!)
-/
theorem isIso_of_op {X Y : C} (f : X ⟶ Y) [IsIso f.op] : IsIso f :=
⟨⟨(inv f.op).unop, ⟨Quiver.Hom.op_inj (by simp), Quiver.Hom.op_inj (by simp)⟩⟩⟩
theorem isIso_op_iff {X Y : C} (f : X ⟶ Y) : IsIso f.op ↔ IsIso f :=
⟨fun _ => isIso_of_op _, fun _ => inferInstance⟩
theorem isIso_unop_iff {X Y : Cᵒᵖ} (f : X ⟶ Y) : IsIso f.unop ↔ IsIso f := by
rw [← isIso_op_iff f.unop, Quiver.Hom.op_unop]
instance isIso_unop {X Y : Cᵒᵖ} (f : X ⟶ Y) [IsIso f] : IsIso f.unop :=
(isIso_unop_iff _).2 inferInstance
@[simp]
theorem op_inv {X Y : C} (f : X ⟶ Y) [IsIso f] : (inv f).op = inv f.op := by
apply IsIso.eq_inv_of_hom_inv_id
rw [← op_comp, IsIso.inv_hom_id, op_id]
@[simp]
theorem unop_inv {X Y : Cᵒᵖ} (f : X ⟶ Y) [IsIso f] : (inv f).unop = inv f.unop := by
apply IsIso.eq_inv_of_hom_inv_id
rw [← unop_comp, IsIso.inv_hom_id, unop_id]
namespace Functor
section
variable {D : Type u₂} [Category.{v₂} D]
/-- The opposite of a functor, i.e. considering a functor `F : C ⥤ D` as a functor `Cᵒᵖ ⥤ Dᵒᵖ`.
In informal mathematics no distinction is made between these. -/
@[simps]
protected def op (F : C ⥤ D) : Cᵒᵖ ⥤ Dᵒᵖ where
obj X := op (F.obj (unop X))
map f := (F.map f.unop).op
/-- Given a functor `F : Cᵒᵖ ⥤ Dᵒᵖ` we can take the "unopposite" functor `F : C ⥤ D`.
In informal mathematics no distinction is made between these.
-/
@[simps]
protected def unop (F : Cᵒᵖ ⥤ Dᵒᵖ) : C ⥤ D where
obj X := unop (F.obj (op X))
map f := (F.map f.op).unop
/-- The isomorphism between `F.op.unop` and `F`. -/
@[simps!]
def opUnopIso (F : C ⥤ D) : F.op.unop ≅ F :=
NatIso.ofComponents fun _ => Iso.refl _
/-- The isomorphism between `F.unop.op` and `F`. -/
@[simps!]
def unopOpIso (F : Cᵒᵖ ⥤ Dᵒᵖ) : F.unop.op ≅ F :=
NatIso.ofComponents fun _ => Iso.refl _
variable (C D)
/-- Taking the opposite of a functor is functorial.
-/
@[simps]
def opHom : (C ⥤ D)ᵒᵖ ⥤ Cᵒᵖ ⥤ Dᵒᵖ where
obj F := (unop F).op
map α :=
{ app := fun X => (α.unop.app (unop X)).op
naturality := fun _ _ f => Quiver.Hom.unop_inj (α.unop.naturality f.unop).symm }
/-- Take the "unopposite" of a functor is functorial.
-/
@[simps]
def opInv : (Cᵒᵖ ⥤ Dᵒᵖ) ⥤ (C ⥤ D)ᵒᵖ where
obj F := op F.unop
map α :=
Quiver.Hom.op
{ app := fun X => (α.app (op X)).unop
naturality := fun _ _ f => Quiver.Hom.op_inj <| (α.naturality f.op).symm }
variable {C D}
section Compositions
variable {E : Type*} [Category E]
/-- Compatibility of `Functor.op` with respect to functor composition. -/
@[simps!]
def opComp (F : C ⥤ D) (G : D ⥤ E) : (F ⋙ G).op ≅ F.op ⋙ G.op := Iso.refl _
/-- Compatibility of `Functor.unop` with respect to functor composition. -/
@[simps!]
def unopComp (F : Cᵒᵖ ⥤ Dᵒᵖ) (G : Dᵒᵖ ⥤ Eᵒᵖ) : (F ⋙ G).unop ≅ F.unop ⋙ G.unop := Iso.refl _
variable (C) in
/-- `Functor.op` transforms identity functors to identity functors. -/
@[simps!]
def opId : (𝟭 C).op ≅ 𝟭 (Cᵒᵖ) := Iso.refl _
variable (C) in
/-- `Functor.unop` transforms identity functors to identity functors. -/
@[simps!]
def unopId : (𝟭 Cᵒᵖ).unop ≅ 𝟭 C := Iso.refl _
end Compositions
/--
Another variant of the opposite of functor, turning a functor `C ⥤ Dᵒᵖ` into a functor `Cᵒᵖ ⥤ D`.
In informal mathematics no distinction is made.
-/
@[simps]
protected def leftOp (F : C ⥤ Dᵒᵖ) : Cᵒᵖ ⥤ D where
obj X := unop (F.obj (unop X))
map f := (F.map f.unop).unop
/--
Another variant of the opposite of functor, turning a functor `Cᵒᵖ ⥤ D` into a functor `C ⥤ Dᵒᵖ`.
In informal mathematics no distinction is made.
-/
@[simps]
protected def rightOp (F : Cᵒᵖ ⥤ D) : C ⥤ Dᵒᵖ where
obj X := op (F.obj (op X))
map f := (F.map f.op).op
lemma rightOp_map_unop {F : Cᵒᵖ ⥤ D} {X Y} (f : X ⟶ Y) :
(F.rightOp.map f).unop = F.map f.op := rfl
instance {F : C ⥤ D} [Full F] : Full F.op where
map_surjective f := ⟨(F.preimage f.unop).op, by simp⟩
instance {F : C ⥤ D} [Faithful F] : Faithful F.op where
map_injective h := Quiver.Hom.unop_inj <| by simpa using map_injective F (Quiver.Hom.op_inj h)
/-- The opposite of a fully faithful functor is fully faithful. -/
protected def FullyFaithful.op {F : C ⥤ D} (hF : F.FullyFaithful) : F.op.FullyFaithful where
preimage {X Y} f := .op <| hF.preimage f.unop
/-- If F is faithful then the right_op of F is also faithful. -/
instance rightOp_faithful {F : Cᵒᵖ ⥤ D} [Faithful F] : Faithful F.rightOp where
map_injective h := Quiver.Hom.op_inj (map_injective F (Quiver.Hom.op_inj h))
/-- If F is faithful then the left_op of F is also faithful. -/
instance leftOp_faithful {F : C ⥤ Dᵒᵖ} [Faithful F] : Faithful F.leftOp where
map_injective h := Quiver.Hom.unop_inj (map_injective F (Quiver.Hom.unop_inj h))
instance rightOp_full {F : Cᵒᵖ ⥤ D} [Full F] : Full F.rightOp where
map_surjective f := ⟨(F.preimage f.unop).unop, by simp⟩
instance leftOp_full {F : C ⥤ Dᵒᵖ} [Full F] : Full F.leftOp where
map_surjective f := ⟨(F.preimage f.op).op, by simp⟩
/-- The opposite of a fully faithful functor is fully faithful. -/
protected def FullyFaithful.leftOp {F : C ⥤ Dᵒᵖ} (hF : F.FullyFaithful) :
F.leftOp.FullyFaithful where
preimage {X Y} f := .op <| hF.preimage f.op
/-- The opposite of a fully faithful functor is fully faithful. -/
protected def FullyFaithful.rightOp {F : Cᵒᵖ ⥤ D} (hF : F.FullyFaithful) :
F.rightOp.FullyFaithful where
preimage {X Y} f := .unop <| hF.preimage f.unop
/-- Compatibility of `Functor.rightOp` with respect to functor composition. -/
@[simps!]
def rightOpComp {E : Type*} [Category E] (F : Cᵒᵖ ⥤ D) (G : D ⥤ E) :
(F ⋙ G).rightOp ≅ F.rightOp ⋙ G.op :=
Iso.refl _
/-- Compatibility of `Functor.leftOp` with respect to functor composition. -/
@[simps!]
def leftOpComp {E : Type*} [Category E] (F : C ⥤ D) (G : D ⥤ Eᵒᵖ) :
(F ⋙ G).leftOp ≅ F.op ⋙ G.leftOp :=
Iso.refl _
section
variable (C)
/-- `Functor.rightOp` sends identity functors to the canonical isomorphism `opOp`. -/
@[simps!]
def rightOpId : (𝟭 Cᵒᵖ).rightOp ≅ opOp C := Iso.refl _
/-- `Functor.leftOp` sends identity functors to the canonical isomorphism `unopUnop`. -/
@[simps!]
def leftOpId : (𝟭 Cᵒᵖ).leftOp ≅ unopUnop C := Iso.refl _
end
/-- The isomorphism between `F.leftOp.rightOp` and `F`. -/
@[simps!]
def leftOpRightOpIso (F : C ⥤ Dᵒᵖ) : F.leftOp.rightOp ≅ F :=
NatIso.ofComponents fun _ => Iso.refl _
/-- The isomorphism between `F.rightOp.leftOp` and `F`. -/
@[simps!]
def rightOpLeftOpIso (F : Cᵒᵖ ⥤ D) : F.rightOp.leftOp ≅ F :=
NatIso.ofComponents fun _ => Iso.refl _
/-- Whenever possible, it is advisable to use the isomorphism `rightOpLeftOpIso`
instead of this equality of functors. -/
theorem rightOp_leftOp_eq (F : Cᵒᵖ ⥤ D) : F.rightOp.leftOp = F := by
cases F
rfl
end
end Functor
namespace NatTrans
variable {D : Type u₂} [Category.{v₂} D]
section
variable {F G : C ⥤ D}
/-- The opposite of a natural transformation. -/
@[simps]
protected def op (α : F ⟶ G) : G.op ⟶ F.op where
app X := (α.app (unop X)).op
naturality X Y f := Quiver.Hom.unop_inj (by simp)
@[simp]
theorem op_id (F : C ⥤ D) : NatTrans.op (𝟙 F) = 𝟙 F.op :=
rfl
@[simp, reassoc]
theorem op_comp {H : C ⥤ D} (α : F ⟶ G) (β : G ⟶ H) :
NatTrans.op (α ≫ β) = NatTrans.op β ≫ NatTrans.op α :=
rfl
@[reassoc]
lemma op_whiskerRight {E : Type*} [Category E] {H : D ⥤ E} (α : F ⟶ G) :
NatTrans.op (whiskerRight α H) =
(Functor.opComp _ _).hom ≫ whiskerRight (NatTrans.op α) H.op ≫ (Functor.opComp _ _).inv := by
cat_disch
@[reassoc]
lemma op_whiskerLeft {E : Type*} [Category E] {H : E ⥤ C} (α : F ⟶ G) :
NatTrans.op (whiskerLeft H α) =
(Functor.opComp _ _).hom ≫ whiskerLeft H.op (NatTrans.op α) ≫ (Functor.opComp _ _).inv := by
cat_disch
/-- The "unopposite" of a natural transformation. -/
@[simps]
protected def unop {F G : Cᵒᵖ ⥤ Dᵒᵖ} (α : F ⟶ G) : G.unop ⟶ F.unop where
app X := (α.app (op X)).unop
naturality X Y f := Quiver.Hom.op_inj (by simp)
@[simp]
theorem unop_id (F : Cᵒᵖ ⥤ Dᵒᵖ) : NatTrans.unop (𝟙 F) = 𝟙 F.unop :=
rfl
@[simp, reassoc]
theorem unop_comp {F G H : Cᵒᵖ ⥤ Dᵒᵖ} (α : F ⟶ G) (β : G ⟶ H) :
NatTrans.unop (α ≫ β) = NatTrans.unop β ≫ NatTrans.unop α :=
rfl
@[reassoc]
lemma unop_whiskerRight {F G : Cᵒᵖ ⥤ Dᵒᵖ} {E : Type*} [Category E] {H : Dᵒᵖ ⥤ Eᵒᵖ} (α : F ⟶ G) :
NatTrans.unop (whiskerRight α H) =
(Functor.unopComp _ _).hom ≫ whiskerRight (NatTrans.unop α) H.unop ≫
(Functor.unopComp _ _).inv := by
cat_disch
@[reassoc]
lemma unop_whiskerLeft {F G : Cᵒᵖ ⥤ Dᵒᵖ} {E : Type*} [Category E] {H : Eᵒᵖ ⥤ Cᵒᵖ} (α : F ⟶ G) :
NatTrans.unop (whiskerLeft H α) =
(Functor.unopComp _ _).hom ≫ whiskerLeft H.unop (NatTrans.unop α) ≫
(Functor.unopComp _ _).inv := by
cat_disch
/-- Given a natural transformation `α : F.op ⟶ G.op`,
we can take the "unopposite" of each component obtaining a natural transformation `G ⟶ F`.
-/
@[simps]
protected def removeOp (α : F.op ⟶ G.op) : G ⟶ F where
app X := (α.app (op X)).unop
naturality X Y f :=
Quiver.Hom.op_inj <| by simpa only [Functor.op_map] using (α.naturality f.op).symm
@[simp]
theorem removeOp_id (F : C ⥤ D) : NatTrans.removeOp (𝟙 F.op) = 𝟙 F :=
rfl
/-- Given a natural transformation `α : F.unop ⟶ G.unop`, we can take the opposite of each
component obtaining a natural transformation `G ⟶ F`. -/
@[simps]
protected def removeUnop {F G : Cᵒᵖ ⥤ Dᵒᵖ} (α : F.unop ⟶ G.unop) : G ⟶ F where
app X := (α.app (unop X)).op
naturality X Y f :=
Quiver.Hom.unop_inj <| by simpa only [Functor.unop_map] using (α.naturality f.unop).symm
@[simp]
theorem removeUnop_id (F : Cᵒᵖ ⥤ Dᵒᵖ) : NatTrans.removeUnop (𝟙 F.unop) = 𝟙 F :=
rfl
end
section
variable {F G H : C ⥤ Dᵒᵖ}
/-- Given a natural transformation `α : F ⟶ G`, for `F G : C ⥤ Dᵒᵖ`,
taking `unop` of each component gives a natural transformation `G.leftOp ⟶ F.leftOp`.
-/
@[simps]
protected def leftOp (α : F ⟶ G) : G.leftOp ⟶ F.leftOp where
app X := (α.app (unop X)).unop
naturality X Y f := Quiver.Hom.op_inj (by simp)
@[simp]
theorem leftOp_id : NatTrans.leftOp (𝟙 F : F ⟶ F) = 𝟙 F.leftOp :=
rfl
@[simp]
theorem leftOp_comp (α : F ⟶ G) (β : G ⟶ H) : NatTrans.leftOp (α ≫ β) =
NatTrans.leftOp β ≫ NatTrans.leftOp α :=
rfl
@[reassoc]
lemma leftOpWhiskerRight {E : Type*} [Category E] {H : E ⥤ C} (α : F ⟶ G) :
(whiskerLeft H α).leftOp = (Functor.leftOpComp H G).hom ≫ whiskerLeft _ α.leftOp ≫
(Functor.leftOpComp H F).inv := by
cat_disch
/-- Given a natural transformation `α : F.leftOp ⟶ G.leftOp`, for `F G : C ⥤ Dᵒᵖ`,
taking `op` of each component gives a natural transformation `G ⟶ F`.
-/
@[simps]
protected def removeLeftOp (α : F.leftOp ⟶ G.leftOp) : G ⟶ F where
app X := (α.app (op X)).op
naturality X Y f :=
Quiver.Hom.unop_inj <| by simpa only [Functor.leftOp_map] using (α.naturality f.op).symm
@[simp]
theorem removeLeftOp_id : NatTrans.removeLeftOp (𝟙 F.leftOp) = 𝟙 F :=
rfl
end
section
variable {F G H : Cᵒᵖ ⥤ D}
/-- Given a natural transformation `α : F ⟶ G`, for `F G : Cᵒᵖ ⥤ D`,
taking `op` of each component gives a natural transformation `G.rightOp ⟶ F.rightOp`.
-/
@[simps]
protected def rightOp (α : F ⟶ G) : G.rightOp ⟶ F.rightOp where
app _ := (α.app _).op
naturality X Y f := Quiver.Hom.unop_inj (by simp)
@[simp]
theorem rightOp_id : NatTrans.rightOp (𝟙 F : F ⟶ F) = 𝟙 F.rightOp :=
rfl
@[simp]
theorem rightOp_comp (α : F ⟶ G) (β : G ⟶ H) : NatTrans.rightOp (α ≫ β) =
NatTrans.rightOp β ≫ NatTrans.rightOp α :=
rfl
@[reassoc]
lemma rightOpWhiskerRight {E : Type*} [Category E] {H : D ⥤ E} (α : F ⟶ G) :
(whiskerRight α H).rightOp = (Functor.rightOpComp G H).hom ≫ whiskerRight α.rightOp H.op ≫
(Functor.rightOpComp F H).inv := by
cat_disch
/-- Given a natural transformation `α : F.rightOp ⟶ G.rightOp`, for `F G : Cᵒᵖ ⥤ D`,
taking `unop` of each component gives a natural transformation `G ⟶ F`.
-/
@[simps]
protected def removeRightOp (α : F.rightOp ⟶ G.rightOp) : G ⟶ F where
app X := (α.app X.unop).unop
naturality X Y f :=
Quiver.Hom.op_inj <| by simpa only [Functor.rightOp_map] using (α.naturality f.unop).symm
@[simp]
theorem removeRightOp_id : NatTrans.removeRightOp (𝟙 F.rightOp) = 𝟙 F :=
rfl
end
end NatTrans
namespace Iso
variable {X Y : C}
/-- The opposite isomorphism.
-/
@[simps]
protected def op (α : X ≅ Y) : op Y ≅ op X where
hom := α.hom.op
inv := α.inv.op
hom_inv_id := Quiver.Hom.unop_inj α.inv_hom_id
inv_hom_id := Quiver.Hom.unop_inj α.hom_inv_id
/-- The isomorphism obtained from an isomorphism in the opposite category. -/
@[simps]
def unop {X Y : Cᵒᵖ} (f : X ≅ Y) : Y.unop ≅ X.unop where
hom := f.hom.unop
inv := f.inv.unop
hom_inv_id := by simp only [← unop_comp, f.inv_hom_id, unop_id]
inv_hom_id := by simp only [← unop_comp, f.hom_inv_id, unop_id]
@[simp]
theorem unop_op {X Y : Cᵒᵖ} (f : X ≅ Y) : f.unop.op = f := by (ext; rfl)
@[simp]
theorem op_unop {X Y : C} (f : X ≅ Y) : f.op.unop = f := by (ext; rfl)
variable (X) in
@[simp]
theorem op_refl : Iso.op (Iso.refl X) = Iso.refl (op X) := rfl
@[simp]
theorem op_trans {Z : C} (α : X ≅ Y) (β : Y ≅ Z) :
Iso.op (α ≪≫ β) = Iso.op β ≪≫ Iso.op α :=
rfl
@[simp]
theorem op_symm (α : X ≅ Y) : Iso.op α.symm = (Iso.op α).symm := rfl
@[simp]
theorem unop_refl (X : Cᵒᵖ) : Iso.unop (Iso.refl X) = Iso.refl X.unop := rfl
@[simp]
theorem unop_trans {X Y Z : Cᵒᵖ} (α : X ≅ Y) (β : Y ≅ Z) :
Iso.unop (α ≪≫ β) = Iso.unop β ≪≫ Iso.unop α :=
rfl
@[simp]
theorem unop_symm {X Y : Cᵒᵖ} (α : X ≅ Y) : Iso.unop α.symm = (Iso.unop α).symm := rfl
section
variable {D : Type*} [Category D] {F G : C ⥤ Dᵒᵖ} (e : F ≅ G) (X : C)
@[reassoc (attr := simp)]
lemma unop_hom_inv_id_app : (e.hom.app X).unop ≫ (e.inv.app X).unop = 𝟙 _ := by
rw [← unop_comp, inv_hom_id_app, unop_id]
@[reassoc (attr := simp)]
lemma unop_inv_hom_id_app : (e.inv.app X).unop ≫ (e.hom.app X).unop = 𝟙 _ := by
rw [← unop_comp, hom_inv_id_app, unop_id]
end
end Iso
namespace NatIso
variable {D : Type u₂} [Category.{v₂} D]
variable {F G : C ⥤ D}
/-- The natural isomorphism between opposite functors `G.op ≅ F.op` induced by a natural
isomorphism between the original functors `F ≅ G`. -/
@[simps]
protected def op (α : F ≅ G) : G.op ≅ F.op where
hom := NatTrans.op α.hom
inv := NatTrans.op α.inv
hom_inv_id := by ext; dsimp; rw [← op_comp]; rw [α.inv_hom_id_app]; rfl
inv_hom_id := by ext; dsimp; rw [← op_comp]; rw [α.hom_inv_id_app]; rfl
@[simp]
theorem op_refl : NatIso.op (Iso.refl F) = Iso.refl F.op := rfl
@[simp]
theorem op_trans {H : C ⥤ D} (α : F ≅ G) (β : G ≅ H) :
NatIso.op (α ≪≫ β) = NatIso.op β ≪≫ NatIso.op α :=
rfl
@[simp]
theorem op_symm (α : F ≅ G) : NatIso.op α.symm = (NatIso.op α).symm := rfl
/-- The natural isomorphism between functors `G ≅ F` induced by a natural isomorphism
between the opposite functors `F.op ≅ G.op`. -/
@[simps]
protected def removeOp (α : F.op ≅ G.op) : G ≅ F where
hom := NatTrans.removeOp α.hom
inv := NatTrans.removeOp α.inv
/-- The natural isomorphism between functors `G.unop ≅ F.unop` induced by a natural isomorphism
between the original functors `F ≅ G`. -/
@[simps]
protected def unop {F G : Cᵒᵖ ⥤ Dᵒᵖ} (α : F ≅ G) : G.unop ≅ F.unop where
hom := NatTrans.unop α.hom
inv := NatTrans.unop α.inv
@[simp]
theorem unop_refl (F : Cᵒᵖ ⥤ Dᵒᵖ) : NatIso.unop (Iso.refl F) = Iso.refl F.unop := rfl
@[simp]
theorem unop_trans {F G H : Cᵒᵖ ⥤ Dᵒᵖ} (α : F ≅ G) (β : G ≅ H) :
NatIso.unop (α ≪≫ β) = NatIso.unop β ≪≫ NatIso.unop α :=
rfl
@[simp]
theorem unop_symm {F G : Cᵒᵖ ⥤ Dᵒᵖ} (α : F ≅ G) : NatIso.unop α.symm = (NatIso.unop α).symm := rfl
lemma op_isoWhiskerRight {E : Type*} [Category E] {H : D ⥤ E} (α : F ≅ G) :
NatIso.op (isoWhiskerRight α H) =
(Functor.opComp _ _) ≪≫ isoWhiskerRight (NatIso.op α) H.op ≪≫ (Functor.opComp _ _).symm := by
cat_disch
lemma op_isoWhiskerLeft {E : Type*} [Category E] {H : E ⥤ C} (α : F ≅ G) :
NatIso.op (isoWhiskerLeft H α) =
(Functor.opComp _ _) ≪≫ isoWhiskerLeft H.op (NatIso.op α) ≪≫ (Functor.opComp _ _).symm := by
cat_disch
lemma unop_whiskerRight {F G : Cᵒᵖ ⥤ Dᵒᵖ} {E : Type*} [Category E] {H : Dᵒᵖ ⥤ Eᵒᵖ} (α : F ≅ G) :
NatIso.unop (isoWhiskerRight α H) =
(Functor.unopComp _ _) ≪≫ isoWhiskerRight (NatIso.unop α) H.unop ≪≫
(Functor.unopComp _ _).symm := by
cat_disch
lemma unop_whiskerLeft {F G : Cᵒᵖ ⥤ Dᵒᵖ} {E : Type*} [Category E] {H : Eᵒᵖ ⥤ Cᵒᵖ} (α : F ≅ G) :
NatIso.unop (isoWhiskerLeft H α) =
(Functor.unopComp _ _) ≪≫ isoWhiskerLeft H.unop (NatIso.unop α) ≪≫
(Functor.unopComp _ _).symm := by
cat_disch
lemma op_leftUnitor :
NatIso.op F.leftUnitor =
F.op.leftUnitor.symm ≪≫
isoWhiskerRight (Functor.opId C).symm F.op ≪≫
(Functor.opComp _ _).symm := by
cat_disch
lemma op_rightUnitor :
NatIso.op F.rightUnitor =
F.op.rightUnitor.symm ≪≫
isoWhiskerLeft F.op (Functor.opId D).symm ≪≫
(Functor.opComp _ _).symm := by
cat_disch
lemma op_associator {E E' : Type*} [Category E] [Category E'] {F : C ⥤ D} {G : D ⥤ E} {H : E ⥤ E'} :
NatIso.op (Functor.associator F G H) =
Functor.opComp _ _ ≪≫ isoWhiskerLeft F.op (Functor.opComp _ _) ≪≫
(Functor.associator F.op G.op H.op).symm ≪≫
isoWhiskerRight (Functor.opComp _ _).symm H.op ≪≫ (Functor.opComp _ _).symm := by
cat_disch
lemma unop_leftUnitor {F : Cᵒᵖ ⥤ Dᵒᵖ} :
NatIso.unop F.leftUnitor =
F.unop.leftUnitor.symm ≪≫
isoWhiskerRight (Functor.unopId C).symm F.unop ≪≫
(Functor.unopComp _ _).symm := by
cat_disch
lemma unop_rightUnitor {F : Cᵒᵖ ⥤ Dᵒᵖ} :
NatIso.unop F.rightUnitor =
F.unop.rightUnitor.symm ≪≫
isoWhiskerLeft F.unop (Functor.unopId D).symm ≪≫
(Functor.unopComp _ _).symm := by
cat_disch
lemma unop_associator {E E' : Type*} [Category E] [Category E']
{F : Cᵒᵖ ⥤ Dᵒᵖ} {G : Dᵒᵖ ⥤ Eᵒᵖ} {H : Eᵒᵖ ⥤ E'ᵒᵖ} :
NatIso.unop (Functor.associator F G H) =
Functor.unopComp _ _ ≪≫ isoWhiskerLeft F.unop (Functor.unopComp _ _) ≪≫
(Functor.associator F.unop G.unop H.unop).symm ≪≫
isoWhiskerRight (Functor.unopComp _ _).symm H.unop ≪≫ (Functor.unopComp _ _).symm := by
cat_disch
end NatIso
namespace Equivalence
variable {D : Type u₂} [Category.{v₂} D]
/-- An equivalence between categories gives an equivalence between the opposite categories.
-/
@[simps]
def op (e : C ≌ D) : Cᵒᵖ ≌ Dᵒᵖ where
functor := e.functor.op
inverse := e.inverse.op
unitIso := (NatIso.op e.unitIso).symm
counitIso := (NatIso.op e.counitIso).symm
functor_unitIso_comp X := by
apply Quiver.Hom.unop_inj
simp
/-- An equivalence between opposite categories gives an equivalence between the original categories.
-/
@[simps]
def unop (e : Cᵒᵖ ≌ Dᵒᵖ) : C ≌ D where
functor := e.functor.unop
inverse := e.inverse.unop
unitIso := (NatIso.unop e.unitIso).symm
counitIso := (NatIso.unop e.counitIso).symm
functor_unitIso_comp X := by
apply Quiver.Hom.op_inj
simp
/-- An equivalence between `C` and `Dᵒᵖ` gives an equivalence between `Cᵒᵖ` and `D`. -/
@[simps!] def leftOp (e : C ≌ Dᵒᵖ) : Cᵒᵖ ≌ D := e.op.trans (opOpEquivalence D)
/-- An equivalence between `Cᵒᵖ` and `D` gives an equivalence between `C` and `Dᵒᵖ`. -/
@[simps!] def rightOp (e : Cᵒᵖ ≌ D) : C ≌ Dᵒᵖ := (opOpEquivalence C).symm.trans e.op
end Equivalence
/-- The equivalence between arrows of the form `A ⟶ B` and `B.unop ⟶ A.unop`. Useful for building
adjunctions.
Note that this (definitionally) gives variants
```
def opEquiv' (A : C) (B : Cᵒᵖ) : (Opposite.op A ⟶ B) ≃ (B.unop ⟶ A) :=
opEquiv _ _
def opEquiv'' (A : Cᵒᵖ) (B : C) : (A ⟶ Opposite.op B) ≃ (B ⟶ A.unop) :=
opEquiv _ _
def opEquiv''' (A B : C) : (Opposite.op A ⟶ Opposite.op B) ≃ (B ⟶ A) :=
opEquiv _ _
```
-/
@[simps]
def opEquiv (A B : Cᵒᵖ) : (A ⟶ B) ≃ (B.unop ⟶ A.unop) where
toFun f := f.unop
invFun g := g.op
instance subsingleton_of_unop (A B : Cᵒᵖ) [Subsingleton (unop B ⟶ unop A)] : Subsingleton (A ⟶ B) :=
(opEquiv A B).subsingleton
instance decidableEqOfUnop (A B : Cᵒᵖ) [DecidableEq (unop B ⟶ unop A)] : DecidableEq (A ⟶ B) :=
(opEquiv A B).decidableEq
/-- The equivalence between isomorphisms of the form `A ≅ B` and `B.unop ≅ A.unop`.
Note this is definitionally the same as the other three variants:
* `(Opposite.op A ≅ B) ≃ (B.unop ≅ A)`
* `(A ≅ Opposite.op B) ≃ (B ≅ A.unop)`
* `(Opposite.op A ≅ Opposite.op B) ≃ (B ≅ A)`
-/
@[simps]
def isoOpEquiv (A B : Cᵒᵖ) : (A ≅ B) ≃ (B.unop ≅ A.unop) where
toFun f := f.unop
invFun g := g.op
namespace Functor
variable (C)
variable (D : Type u₂) [Category.{v₂} D]
/-- The equivalence of functor categories induced by `op` and `unop`.
-/
@[simps]
def opUnopEquiv : (C ⥤ D)ᵒᵖ ≌ Cᵒᵖ ⥤ Dᵒᵖ where
functor := opHom _ _
inverse := opInv _ _
unitIso :=
NatIso.ofComponents (fun F => F.unop.opUnopIso.op)
(by
intro F G f
dsimp [opUnopIso]
rw [show f = f.unop.op by simp, ← op_comp, ← op_comp]
congr 1
cat_disch)
counitIso := NatIso.ofComponents fun F => F.unopOpIso
/-- The equivalence of functor categories induced by `leftOp` and `rightOp`.
-/
@[simps!]
def leftOpRightOpEquiv : (Cᵒᵖ ⥤ D)ᵒᵖ ≌ C ⥤ Dᵒᵖ where
functor :=
{ obj := fun F => F.unop.rightOp
map := fun η => NatTrans.rightOp η.unop }
inverse :=
{ obj := fun F => op F.leftOp
map := fun η => η.leftOp.op }
unitIso :=
NatIso.ofComponents (fun F => F.unop.rightOpLeftOpIso.op)
(by
intro F G η
dsimp
rw [show η = η.unop.op by simp, ← op_comp, ← op_comp]
congr 1
cat_disch)
counitIso := NatIso.ofComponents fun F => F.leftOpRightOpIso
instance {F : C ⥤ D} [EssSurj F] : EssSurj F.op where
mem_essImage X := ⟨op _, ⟨(F.objObjPreimageIso X.unop).op.symm⟩⟩
instance {F : Cᵒᵖ ⥤ D} [EssSurj F] : EssSurj F.rightOp where
mem_essImage X := ⟨_, ⟨(F.objObjPreimageIso X.unop).op.symm⟩⟩
instance {F : C ⥤ Dᵒᵖ} [EssSurj F] : EssSurj F.leftOp where
mem_essImage X := ⟨op _, ⟨(F.objObjPreimageIso (op X)).unop.symm⟩⟩
instance {F : C ⥤ D} [IsEquivalence F] : IsEquivalence F.op where
instance {F : Cᵒᵖ ⥤ D} [IsEquivalence F] : IsEquivalence F.rightOp where
instance {F : C ⥤ Dᵒᵖ} [IsEquivalence F] : IsEquivalence F.leftOp where
end Functor
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Thin.lean | import Mathlib.CategoryTheory.Functor.Category
import Mathlib.CategoryTheory.Iso
/-!
# Thin categories
A thin category (also known as a sparse category) is a category with at most one morphism between
each pair of objects.
Examples include posets, but also some indexing categories (diagrams) for special shapes of
(co)limits.
To construct a category instance one only needs to specify the `category_struct` part,
as the axioms hold for free.
If `C` is thin, then the category of functors to `C` is also thin.
Further, to show two objects are isomorphic in a thin category, it suffices only to give a morphism
in each direction.
-/
universe v₁ v₂ u₁ u₂
namespace CategoryTheory
variable {C : Type u₁}
section
variable [CategoryStruct.{v₁} C] [Quiver.IsThin C]
/-- Construct a category instance from a category_struct, using the fact that
hom spaces are subsingletons to prove the axioms. -/
def thin_category : Category C where
end
-- We don't assume anything about where the category instance on `C` came from.
-- In particular this allows `C` to be a preorder, with the category instance inherited from the
-- preorder structure.
variable [Category.{v₁} C] {D : Type u₂} [Category.{v₂} D]
variable [Quiver.IsThin C]
/-- If `C` is a thin category, then `D ⥤ C` is a thin category. -/
instance functor_thin : Quiver.IsThin (D ⥤ C) := fun _ _ =>
⟨fun α β => NatTrans.ext (by subsingleton)⟩
/-- To show `X ≅ Y` in a thin category, it suffices to just give any morphism in each direction. -/
def iso_of_both_ways {X Y : C} (f : X ⟶ Y) (g : Y ⟶ X) :
X ≅ Y where
hom := f
inv := g
instance subsingleton_iso {X Y : C} : Subsingleton (X ≅ Y) :=
⟨by
intro i₁ i₂
ext1
subsingleton⟩
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Grothendieck.lean | import Mathlib.CategoryTheory.Category.Cat.AsSmall
import Mathlib.CategoryTheory.Elements
import Mathlib.CategoryTheory.Comma.Over.Basic
/-!
# The Grothendieck construction
Given a functor `F : C ⥤ Cat`, the objects of `Grothendieck F`
consist of dependent pairs `(b, f)`, where `b : C` and `f : F.obj c`,
and a morphism `(b, f) ⟶ (b', f')` is a pair `β : b ⟶ b'` in `C`, and
`φ : (F.map β).obj f ⟶ f'`
`Grothendieck.functor` makes the Grothendieck construction into a functor from the functor category
`C ⥤ Cat` to the over category `Over C` in the category of categories.
Categories such as `PresheafedSpace` are in fact examples of this construction,
and it may be interesting to try to generalize some of the development there.
## Implementation notes
Really we should treat `Cat` as a 2-category, and allow `F` to be a 2-functor.
There is also a closely related construction starting with `G : Cᵒᵖ ⥤ Cat`,
where morphisms consists again of `β : b ⟶ b'` and `φ : f ⟶ (F.map (op β)).obj f'`.
## Notable constructions
- `Grothendieck F` is the Grothendieck construction.
- Elements of `Grothendieck F` whose base is `c : C` can be transported along `f : c ⟶ d` using
`transport`.
- A natural transformation `α : F ⟶ G` induces `map α : Grothendieck F ⥤ Grothendieck G`.
- The Grothendieck construction and `map` together form a functor (`functor`) from the functor
category `E ⥤ Cat` to the over category `Over E`.
- A functor `G : D ⥤ C` induces `pre F G : Grothendieck (G ⋙ F) ⥤ Grothendieck F`.
## References
See also `CategoryTheory.Functor.Elements` for the category of elements of functor `F : C ⥤ Type`.
* https://stacks.math.columbia.edu/tag/02XV
* https://ncatlab.org/nlab/show/Grothendieck+construction
-/
universe w u v u₁ v₁ u₂ v₂
namespace CategoryTheory
open Functor
variable {C : Type u} [Category.{v} C]
variable {D : Type u₁} [Category.{v₁} D]
variable (F : C ⥤ Cat.{v₂, u₂})
/--
The Grothendieck construction (often written as `∫ F` in mathematics) for a functor `F : C ⥤ Cat`
gives a category whose
* objects `X` consist of `X.base : C` and `X.fiber : F.obj base`
* morphisms `f : X ⟶ Y` consist of
`base : X.base ⟶ Y.base` and
`f.fiber : (F.map base).obj X.fiber ⟶ Y.fiber`
-/
structure Grothendieck where
/-- The underlying object in `C` -/
base : C
/-- The object in the fiber of the base object. -/
fiber : F.obj base
namespace Grothendieck
variable {F}
/-- A morphism in the Grothendieck category `F : C ⥤ Cat` consists of
`base : X.base ⟶ Y.base` and `f.fiber : (F.map base).obj X.fiber ⟶ Y.fiber`.
-/
structure Hom (X Y : Grothendieck F) where
/-- The morphism between base objects. -/
base : X.base ⟶ Y.base
/-- The morphism from the pushforward to the source fiber object to the target fiber object. -/
fiber : (F.map base).obj X.fiber ⟶ Y.fiber
@[ext (iff := false)]
theorem ext {X Y : Grothendieck F} (f g : Hom X Y) (w_base : f.base = g.base)
(w_fiber : eqToHom (by rw [w_base]) ≫ f.fiber = g.fiber) : f = g := by
cases f; cases g
congr
dsimp at w_base
cat_disch
/-- The identity morphism in the Grothendieck category.
-/
def id (X : Grothendieck F) : Hom X X where
base := 𝟙 X.base
fiber := eqToHom (by simp)
instance (X : Grothendieck F) : Inhabited (Hom X X) :=
⟨id X⟩
/-- Composition of morphisms in the Grothendieck category.
-/
def comp {X Y Z : Grothendieck F} (f : Hom X Y) (g : Hom Y Z) : Hom X Z where
base := f.base ≫ g.base
fiber :=
eqToHom (by simp) ≫ (F.map g.base).map f.fiber ≫ g.fiber
attribute [local simp] eqToHom_map
instance : Category (Grothendieck F) where
Hom X Y := Grothendieck.Hom X Y
id X := Grothendieck.id X
comp f g := Grothendieck.comp f g
comp_id {X Y} f := by
ext
· simp [comp, id]
· dsimp [comp, id]
rw [← NatIso.naturality_2 (eqToIso (F.map_id Y.base)) f.fiber]
simp
id_comp f := by ext <;> simp [comp, id]
assoc f g h := by
ext
· simp [comp]
· dsimp [comp, id]
rw [← NatIso.naturality_2 (eqToIso (F.map_comp _ _)) f.fiber]
simp
@[simp]
theorem id_base (X : Grothendieck F) :
Hom.base (𝟙 X) = 𝟙 X.base :=
rfl
@[simp]
theorem id_fiber (X : Grothendieck F) :
Hom.fiber (𝟙 X) = eqToHom (by simp) :=
rfl
@[simp]
theorem comp_base {X Y Z : Grothendieck F} (f : X ⟶ Y) (g : Y ⟶ Z) :
(f ≫ g).base = f.base ≫ g.base :=
rfl
@[simp]
theorem comp_fiber {X Y Z : Grothendieck F} (f : X ⟶ Y) (g : Y ⟶ Z) :
Hom.fiber (f ≫ g) =
eqToHom (by simp) ≫ (F.map g.base).map f.fiber ≫ g.fiber :=
rfl
theorem congr {X Y : Grothendieck F} {f g : X ⟶ Y} (h : f = g) :
f.fiber = eqToHom (by subst h; rfl) ≫ g.fiber := by
subst h
simp
@[simp]
theorem base_eqToHom {X Y : Grothendieck F} (h : X = Y) :
(eqToHom h).base = eqToHom (congrArg Grothendieck.base h) := by subst h; rfl
@[simp]
theorem fiber_eqToHom {X Y : Grothendieck F} (h : X = Y) :
(eqToHom h).fiber = eqToHom (by subst h; simp) := by subst h; rfl
lemma eqToHom_eq {X Y : Grothendieck F} (hF : X = Y) :
eqToHom hF = { base := eqToHom (by subst hF; rfl), fiber := eqToHom (by subst hF; simp) } := by
subst hF
rfl
section Transport
/--
If `F : C ⥤ Cat` is a functor and `t : c ⟶ d` is a morphism in `C`, then `transport` maps each
`c`-based element of `Grothendieck F` to a `d`-based element.
-/
@[simps]
def transport (x : Grothendieck F) {c : C} (t : x.base ⟶ c) : Grothendieck F :=
⟨c, (F.map t).obj x.fiber⟩
/--
If `F : C ⥤ Cat` is a functor and `t : c ⟶ d` is a morphism in `C`, then `transport` maps each
`c`-based element `x` of `Grothendieck F` to a `d`-based element `x.transport t`.
`toTransport` is the morphism `x ⟶ x.transport t` induced by `t` and the identity on fibers.
-/
@[simps]
def toTransport (x : Grothendieck F) {c : C} (t : x.base ⟶ c) : x ⟶ x.transport t :=
⟨t, 𝟙 _⟩
/--
Construct an isomorphism in a Grothendieck construction from isomorphisms in its base and fiber.
-/
@[simps]
def isoMk {X Y : Grothendieck F} (e₁ : X.base ≅ Y.base)
(e₂ : (F.map e₁.hom).obj X.fiber ≅ Y.fiber) :
X ≅ Y where
hom := ⟨e₁.hom, e₂.hom⟩
inv := ⟨e₁.inv, (F.map e₁.inv).map e₂.inv ≫
eqToHom (Functor.congr_obj (F.mapIso e₁).hom_inv_id X.fiber)⟩
hom_inv_id := Grothendieck.ext _ _ (by simp) (by simp)
inv_hom_id := Grothendieck.ext _ _ (by simp) (by
have := Functor.congr_hom (F.mapIso e₁).inv_hom_id e₂.inv
dsimp at this
simp [this])
/--
If `F : C ⥤ Cat` and `x : Grothendieck F`, then every `C`-isomorphism `α : x.base ≅ c` induces
an isomorphism between `x` and its transport along `α`
-/
@[simps!]
def transportIso (x : Grothendieck F) {c : C} (α : x.base ≅ c) :
x.transport α.hom ≅ x := (isoMk α (Iso.refl _)).symm
end Transport
section
variable (F)
/-- The forgetful functor from `Grothendieck F` to the source category. -/
@[simps!]
def forget : Grothendieck F ⥤ C where
obj X := X.1
map f := f.1
end
section
variable {G : C ⥤ Cat}
/-- The Grothendieck construction is functorial: a natural transformation `α : F ⟶ G` induces
a functor `Grothendieck.map : Grothendieck F ⥤ Grothendieck G`.
-/
@[simps!]
def map (α : F ⟶ G) : Grothendieck F ⥤ Grothendieck G where
obj X :=
{ base := X.base
fiber := (α.app X.base).obj X.fiber }
map {X Y} f :=
{ base := f.base
fiber := (eqToHom (α.naturality f.base).symm).app X.fiber ≫ (α.app Y.base).map f.fiber }
map_id X := by simp only [Cat.eqToHom_app, id_fiber, eqToHom_map, eqToHom_trans]; rfl
map_comp {X Y Z} f g := by
dsimp
congr 1
simp only [← Category.assoc, Functor.map_comp, eqToHom_map]
congr 1
simp only [Cat.eqToHom_app, Cat.comp_obj, eqToHom_trans, eqToHom_map, Category.assoc,
← Cat.comp_map]
rw [Functor.congr_hom (α.naturality g.base).symm f.fiber]
simp
theorem map_obj {α : F ⟶ G} (X : Grothendieck F) :
(Grothendieck.map α).obj X = ⟨X.base, (α.app X.base).obj X.fiber⟩ := rfl
theorem map_map {α : F ⟶ G} {X Y : Grothendieck F} {f : X ⟶ Y} :
(Grothendieck.map α).map f =
⟨f.base, (eqToHom (α.naturality f.base).symm).app X.fiber ≫ (α.app Y.base).map f.fiber⟩ := rfl
/-- The functor `Grothendieck.map α : Grothendieck F ⥤ Grothendieck G` lies over `C`. -/
theorem functor_comp_forget {α : F ⟶ G} :
Grothendieck.map α ⋙ Grothendieck.forget G = Grothendieck.forget F := rfl
theorem map_id_eq : map (𝟙 F) = 𝟙 (Cat.of <| Grothendieck <| F) := by
fapply Functor.ext
· intro X
rfl
· intro X Y f
simp [map_map]
rfl
/-- Making the equality of functors into an isomorphism. Note: we should avoid equality of functors
if possible, and we should prefer `mapIdIso` to `map_id_eq` whenever we can. -/
def mapIdIso : map (𝟙 F) ≅ 𝟙 (Cat.of <| Grothendieck <| F) := eqToIso map_id_eq
variable {H : C ⥤ Cat}
theorem map_comp_eq (α : F ⟶ G) (β : G ⟶ H) :
map (α ≫ β) = map α ⋙ map β := by
fapply Functor.ext
· intro X
rfl
· intro X Y f
simp only [map_map, map_obj_base, NatTrans.comp_app, Cat.comp_obj, Cat.comp_map,
eqToHom_refl, Functor.comp_map, Functor.map_comp, Category.comp_id, Category.id_comp]
fapply Grothendieck.ext
· rfl
· simp
/-- Making the equality of functors into an isomorphism. Note: we should avoid equality of functors
if possible, and we should prefer `map_comp_iso` to `map_comp_eq` whenever we can. -/
def mapCompIso (α : F ⟶ G) (β : G ⟶ H) : map (α ≫ β) ≅ map α ⋙ map β := eqToIso (map_comp_eq α β)
variable (F)
/-- The inverse functor to build the equivalence `compAsSmallFunctorEquivalence`. -/
@[simps]
def compAsSmallFunctorEquivalenceInverse :
Grothendieck F ⥤ Grothendieck (F ⋙ Cat.asSmallFunctor.{w}) where
obj X := ⟨X.base, AsSmall.up.obj X.fiber⟩
map f := ⟨f.base, AsSmall.up.map f.fiber⟩
/-- The functor to build the equivalence `compAsSmallFunctorEquivalence`. -/
@[simps]
def compAsSmallFunctorEquivalenceFunctor :
Grothendieck (F ⋙ Cat.asSmallFunctor.{w}) ⥤ Grothendieck F where
obj X := ⟨X.base, AsSmall.down.obj X.fiber⟩
map f := ⟨f.base, AsSmall.down.map f.fiber⟩
map_id _ := by apply Grothendieck.ext <;> simp
map_comp _ _ := by apply Grothendieck.ext <;> simp [down_comp]
/-- Taking the Grothendieck construction on `F ⋙ asSmallFunctor`, where
`asSmallFunctor : Cat ⥤ Cat` is the functor which turns each category into a small category of a
(potentially) larger universe, is equivalent to the Grothendieck construction on `F` itself. -/
@[simps]
def compAsSmallFunctorEquivalence :
Grothendieck (F ⋙ Cat.asSmallFunctor.{w}) ≌ Grothendieck F where
functor := compAsSmallFunctorEquivalenceFunctor F
inverse := compAsSmallFunctorEquivalenceInverse F
counitIso := Iso.refl _
unitIso := Iso.refl _
variable {F} in
/-- Mapping a Grothendieck construction along the whiskering of any natural transformation
`α : F ⟶ G` with the functor `asSmallFunctor : Cat ⥤ Cat` is naturally isomorphic to conjugating
`map α` with the equivalence between `Grothendieck (F ⋙ asSmallFunctor)` and `Grothendieck F`. -/
def mapWhiskerRightAsSmallFunctor (α : F ⟶ G) :
map (whiskerRight α Cat.asSmallFunctor.{w}) ≅
(compAsSmallFunctorEquivalence F).functor ⋙ map α ⋙
(compAsSmallFunctorEquivalence G).inverse :=
NatIso.ofComponents
(fun X => Iso.refl _)
(fun f => by
fapply Grothendieck.ext
· simp [compAsSmallFunctorEquivalenceInverse]
· simp only [compAsSmallFunctorEquivalence_functor, compAsSmallFunctorEquivalence_inverse,
Functor.comp_obj, compAsSmallFunctorEquivalenceInverse_obj_base, map_obj_base,
compAsSmallFunctorEquivalenceFunctor_obj_base, Cat.asSmallFunctor_obj, Cat.of_α,
Iso.refl_hom, Functor.comp_map, comp_base, id_base,
compAsSmallFunctorEquivalenceInverse_map_base, map_map_base,
compAsSmallFunctorEquivalenceFunctor_map_base, Cat.asSmallFunctor_map, map_obj_fiber,
whiskerRight_app, AsSmall.down_obj, AsSmall.up_obj_down,
compAsSmallFunctorEquivalenceInverse_obj_fiber,
compAsSmallFunctorEquivalenceFunctor_obj_fiber, comp_fiber, map_map_fiber,
AsSmall.down_map, down_comp, eqToHom_down, AsSmall.up_map_down, Functor.map_comp,
eqToHom_map, id_fiber, Category.assoc, eqToHom_trans_assoc,
compAsSmallFunctorEquivalenceInverse_map_fiber,
compAsSmallFunctorEquivalenceFunctor_map_fiber, eqToHom_comp_iff, comp_eqToHom_iff]
simp only [conj_eqToHom_iff_heq']
rw [G.map_id]
simp )
end
/-- The Grothendieck construction as a functor from the functor category `E ⥤ Cat` to the
over category `Over E`. -/
def functor {E : Cat.{v, u}} : (E ⥤ Cat.{v,u}) ⥤ Over (T := Cat.{v,u}) E where
obj F := Over.mk (X := E) (Y := Cat.of (Grothendieck F)) (Grothendieck.forget F)
map {_ _} α := Over.homMk (X:= E) (Grothendieck.map α) Grothendieck.functor_comp_forget
map_id F := by
ext
exact Grothendieck.map_id_eq (F := F)
map_comp α β := by
simp [Grothendieck.map_comp_eq α β]
rfl
variable (G : C ⥤ Type w)
/-- Auxiliary definition for `grothendieckTypeToCat`, to speed up elaboration. -/
@[simps!]
def grothendieckTypeToCatFunctor : Grothendieck (G ⋙ typeToCat) ⥤ G.Elements where
obj X := ⟨X.1, X.2.as⟩
map f := ⟨f.1, f.2.1.1⟩
/-- Auxiliary definition for `grothendieckTypeToCat`, to speed up elaboration. -/
@[simps!]
def grothendieckTypeToCatInverse : G.Elements ⥤ Grothendieck (G ⋙ typeToCat) where
obj X := ⟨X.1, ⟨X.2⟩⟩
map f := ⟨f.1, ⟨⟨f.2⟩⟩⟩
/-- The Grothendieck construction applied to a functor to `Type`
(thought of as a functor to `Cat` by realising a type as a discrete category)
is the same as the 'category of elements' construction.
-/
@[simps!]
def grothendieckTypeToCat : Grothendieck (G ⋙ typeToCat) ≌ G.Elements where
functor := grothendieckTypeToCatFunctor G
inverse := grothendieckTypeToCatInverse G
unitIso :=
NatIso.ofComponents
(fun X => by
rcases X with ⟨_, ⟨⟩⟩
exact Iso.refl _)
(by
rintro ⟨_, ⟨⟩⟩ ⟨_, ⟨⟩⟩ ⟨base, ⟨⟨f⟩⟩⟩
dsimp at *
simp
rfl)
counitIso :=
NatIso.ofComponents
(fun X => by
cases X
exact Iso.refl _)
(by
rintro ⟨⟩ ⟨⟩ ⟨f, e⟩
dsimp at *
simp
rfl)
functor_unitIso_comp := by
rintro ⟨_, ⟨⟩⟩
simp
rfl
section Pre
variable (F)
/-- Applying a functor `G : D ⥤ C` to the base of the Grothendieck construction induces a functor
`Grothendieck (G ⋙ F) ⥤ Grothendieck F`. -/
@[simps]
def pre (G : D ⥤ C) : Grothendieck (G ⋙ F) ⥤ Grothendieck F where
obj X := ⟨G.obj X.base, X.fiber⟩
map f := ⟨G.map f.base, f.fiber⟩
map_id X := Grothendieck.ext _ _ (G.map_id _) (by simp)
map_comp f g := Grothendieck.ext _ _ (G.map_comp _ _) (by simp)
@[simp]
theorem pre_id : pre F (𝟭 C) = 𝟭 _ := rfl
/--
An natural isomorphism between functors `G ≅ H` induces a natural isomorphism between the canonical
morphism `pre F G` and `pre F H`, up to composition with
`Grothendieck (G ⋙ F) ⥤ Grothendieck (H ⋙ F)`.
-/
def preNatIso {G H : D ⥤ C} (α : G ≅ H) :
pre F G ≅ map (whiskerRight α.hom F) ⋙ (pre F H) :=
NatIso.ofComponents
(fun X => (transportIso ⟨G.obj X.base, X.fiber⟩ (α.app X.base)).symm)
(fun f => by fapply Grothendieck.ext <;> simp)
/--
Given an equivalence of categories `G`, `preInv _ G` is the (weak) inverse of the `pre _ G.functor`.
-/
def preInv (G : D ≌ C) : Grothendieck F ⥤ Grothendieck (G.functor ⋙ F) :=
map (whiskerRight G.counitInv F) ⋙ Grothendieck.pre (G.functor ⋙ F) G.inverse
variable {F} in
lemma pre_comp_map (G : D ⥤ C) {H : C ⥤ Cat} (α : F ⟶ H) :
pre F G ⋙ map α = map (whiskerLeft G α) ⋙ pre H G := rfl
variable {F} in
lemma pre_comp_map_assoc (G : D ⥤ C) {H : C ⥤ Cat} (α : F ⟶ H) {E : Type*} [Category E]
(K : Grothendieck H ⥤ E) : pre F G ⋙ map α ⋙ K= map (whiskerLeft G α) ⋙ pre H G ⋙ K := rfl
variable {E : Type*} [Category E] in
@[simp]
lemma pre_comp (G : D ⥤ C) (H : E ⥤ D) : pre F (H ⋙ G) = pre (G ⋙ F) H ⋙ pre F G := rfl
/--
Let `G` be an equivalence of categories. The functor induced via `pre` by `G.functor ⋙ G.inverse`
is naturally isomorphic to the functor induced via `map` by a whiskered version of `G`'s inverse
unit.
-/
protected def preUnitIso (G : D ≌ C) :
map (whiskerRight G.unitInv _) ≅ pre (G.functor ⋙ F) (G.functor ⋙ G.inverse) :=
preNatIso _ G.unitIso.symm |>.symm
/--
Given a functor `F : C ⥤ Cat` and an equivalence of categories `G : D ≌ C`, the functor
`pre F G.functor` is an equivalence between `Grothendieck (G.functor ⋙ F)` and `Grothendieck F`.
-/
def preEquivalence (G : D ≌ C) : Grothendieck (G.functor ⋙ F) ≌ Grothendieck F where
functor := pre F G.functor
inverse := preInv F G
unitIso := by
refine (eqToIso ?_)
≪≫ (Grothendieck.preUnitIso F G |> isoWhiskerLeft (map _))
≪≫ (pre_comp_map_assoc G.functor _ _ |> Eq.symm |> eqToIso)
calc
_ = map (𝟙 _) := map_id_eq.symm
_ = map _ := ?_
_ = map _ ⋙ map _ := map_comp_eq _ _
congr; ext X
simp only [Functor.comp_obj, Functor.comp_map, ← Functor.map_comp, Functor.id_obj,
Functor.map_id, NatTrans.comp_app, NatTrans.id_app, whiskerLeft_app, whiskerRight_app,
Equivalence.counitInv_functor_comp]
counitIso := preNatIso F G.counitIso.symm |>.symm
functor_unitIso_comp := by
intro X
simp only [preInv, Grothendieck.preUnitIso, pre_id,
Iso.trans_hom, eqToIso.hom, eqToHom_app, eqToHom_refl, isoWhiskerLeft_hom, NatTrans.comp_app]
fapply Grothendieck.ext <;> simp [preNatIso, transportIso]
variable {F} in
/--
Let `F, F' : C ⥤ Cat` be functor, `G : D ≌ C` an equivalence and `α : F ⟶ F'` a natural
transformation.
Left-whiskering `α` by `G` and then taking the Grothendieck construction is, up to isomorphism,
the same as taking the Grothendieck construction of `α` and using the equivalences `pre F G`
and `pre F' G` to match the expected type:
```
Grothendieck (G.functor ⋙ F) ≌ Grothendieck F ⥤ Grothendieck F' ≌ Grothendieck (G.functor ⋙ F')
```
-/
def mapWhiskerLeftIsoConjPreMap {F' : C ⥤ Cat} (G : D ≌ C) (α : F ⟶ F') :
map (whiskerLeft G.functor α) ≅
(preEquivalence F G).functor ⋙ map α ⋙ (preEquivalence F' G).inverse :=
(Functor.rightUnitor _).symm ≪≫ isoWhiskerLeft _ (preEquivalence F' G).unitIso
end Pre
section FunctorFrom
variable {E : Type*} [Category E]
variable (F) in
/-- The inclusion of a fiber `F.obj c` of a functor `F : C ⥤ Cat` into its Grothendieck
construction. -/
@[simps obj map]
def ι (c : C) : F.obj c ⥤ Grothendieck F where
obj d := ⟨c, d⟩
map f := ⟨𝟙 _, eqToHom (by simp) ≫ f⟩
map_id d := by
dsimp
congr
simp only [Category.comp_id]
map_comp f g := by
apply Grothendieck.ext _ _ (by simp)
simp only [comp_base, ← Category.assoc, eqToHom_trans, comp_fiber, Functor.map_comp,
eqToHom_map]
congr 1
simp only [eqToHom_comp_iff, Category.assoc, eqToHom_trans_assoc]
apply Functor.congr_hom (F.map_id _).symm
instance faithful_ι (c : C) : (ι F c).Faithful where
map_injective f := by
injection f with _ f
rwa [cancel_epi] at f
/-- Every morphism `f : X ⟶ Y` in the base category induces a natural transformation from the fiber
inclusion `ι F X` to the composition `F.map f ⋙ ι F Y`. -/
@[simps]
def ιNatTrans {X Y : C} (f : X ⟶ Y) : ι F X ⟶ F.map f ⋙ ι F Y where
app d := ⟨f, 𝟙 _⟩
naturality _ _ _ := by
simp only [ι, Functor.comp_obj, Functor.comp_map]
exact Grothendieck.ext _ _ (by simp) (by simp [eqToHom_map])
variable (fib : ∀ c, F.obj c ⥤ E) (hom : ∀ {c c' : C} (f : c ⟶ c'), fib c ⟶ F.map f ⋙ fib c')
variable (hom_id : ∀ c, hom (𝟙 c) = eqToHom (by simp only [Functor.map_id]; rfl))
variable (hom_comp : ∀ c₁ c₂ c₃ (f : c₁ ⟶ c₂) (g : c₂ ⟶ c₃), hom (f ≫ g) =
hom f ≫ whiskerLeft (F.map f) (hom g) ≫ eqToHom (by simp only [Functor.map_comp]; rfl))
/-- Construct a functor from `Grothendieck F` to another category `E` by providing a family of
functors on the fibers of `Grothendieck F`, a family of natural transformations on morphisms in the
base of `Grothendieck F` and coherence data for this family of natural transformations. -/
@[simps]
def functorFrom : Grothendieck F ⥤ E where
obj X := (fib X.base).obj X.fiber
map {X Y} f := (hom f.base).app X.fiber ≫ (fib Y.base).map f.fiber
map_id X := by simp [hom_id]
map_comp f g := by simp [hom_comp]
/-- `Grothendieck.ι F c` composed with `Grothendieck.functorFrom` is isomorphic a functor on a fiber
on `F` supplied as the first argument to `Grothendieck.functorFrom`. -/
def ιCompFunctorFrom (c : C) : ι F c ⋙ (functorFrom fib hom hom_id hom_comp) ≅ fib c :=
NatIso.ofComponents (fun _ => Iso.refl _) (fun f => by simp [hom_id])
end FunctorFrom
/-- The fiber inclusion `ι F c` composed with `map α` is isomorphic to `α.app c ⋙ ι F' c`. -/
@[simps!]
def ιCompMap {F' : C ⥤ Cat} (α : F ⟶ F') (c : C) : ι F c ⋙ map α ≅ α.app c ⋙ ι F' c :=
NatIso.ofComponents (fun X => Iso.refl _) (fun f => by simp [map])
end Grothendieck
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Widesubcategory.lean | import Mathlib.CategoryTheory.Functor.FullyFaithful
import Mathlib.CategoryTheory.MorphismProperty.Composition
/-!
# Wide subcategories
A wide subcategory of a category `C` is a subcategory containing all the objects of `C`.
## Main declarations
Given a category `D`, a function `F : C → D` from a type `C` to the objects of `D`,
and a morphism property `P` on `D` which contains identities and is stable under
composition, the type class `InducedWideCategory D F P` is a typeclass
synonym for `C` which comes equipped with a category structure whose morphisms `X ⟶ Y` are the
morphisms in `D` which have the property `P`.
The instance `WideSubcategory.category` provides a category structure on `WideSubcategory P`
whose objects are the objects of `C` and morphisms are the morphisms in `C` which have the
property `P`.
-/
namespace CategoryTheory
universe v₁ v₂ u₁ u₂
open MorphismProperty
section Induced
variable {C : Type u₁} (D : Type u₂) [Category.{v₁} D]
variable (F : C → D) (P : MorphismProperty D) [P.IsMultiplicative]
/-- `InducedWideCategory D F P`, where `F : C → D`, is a typeclass synonym for `C`,
which provides a category structure so that the morphisms `X ⟶ Y` are the morphisms
in `D` from `F X` to `F Y` which satisfy a property `P : MorphismProperty D` that is multiplicative.
-/
@[nolint unusedArguments]
def InducedWideCategory (_F : C → D) (_P : MorphismProperty D) [IsMultiplicative _P] :=
C
variable {D}
instance InducedWideCategory.hasCoeToSort {α : Sort*} [CoeSort D α] :
CoeSort (InducedWideCategory D F P) α :=
⟨fun c => F c⟩
@[simps!]
instance InducedWideCategory.category :
Category (InducedWideCategory D F P) where
Hom X Y := {f : F X ⟶ F Y | P f}
id X := ⟨𝟙 (F X), P.id_mem (F X)⟩
comp {_ _ _} f g := ⟨f.1 ≫ g.1, P.comp_mem _ _ f.2 g.2⟩
/-- The forgetful functor from an induced wide category to the original category. -/
@[simps]
def wideInducedFunctor : InducedWideCategory D F P ⥤ D where
obj := F
map {_ _} f := f.1
/-- The induced functor `wideInducedFunctor F P : InducedWideCategory D F P ⥤ D`
is faithful. -/
instance InducedWideCategory.faithful : (wideInducedFunctor F P).Faithful where
map_injective {X Y} f g eq := by
cases f
cases g
aesop
end Induced
section WideSubcategory
variable {C : Type u₁} [Category.{v₁} C]
variable (P : MorphismProperty C) [IsMultiplicative P]
/--
Structure for wide subcategories. Objects ignore the morphism property.
-/
@[ext, nolint unusedArguments]
structure WideSubcategory (_P : MorphismProperty C) [IsMultiplicative _P] where
/-- The category of which this is a wide subcategory -/
obj : C
instance WideSubcategory.category : Category.{v₁} (WideSubcategory P) :=
InducedWideCategory.category WideSubcategory.obj P
@[simp]
lemma WideSubcategory.id_def (X : WideSubcategory P) : (CategoryStruct.id X).1 = 𝟙 X.obj := rfl
@[simp]
lemma WideSubcategory.comp_def {X Y Z : WideSubcategory P} (f : X ⟶ Y) (g : Y ⟶ Z) :
(f ≫ g).1 = (f.1 ≫ g.1 : X.obj ⟶ Z.obj) := rfl
/-- The forgetful functor from a wide subcategory into the original category
("forgetting" the condition).
-/
def wideSubcategoryInclusion : WideSubcategory P ⥤ C :=
wideInducedFunctor WideSubcategory.obj P
@[simp]
theorem wideSubcategoryInclusion.obj (X) : (wideSubcategoryInclusion P).obj X = X.obj :=
rfl
@[simp]
theorem wideSubcategoryInclusion.map {X Y} {f : X ⟶ Y} :
(wideSubcategoryInclusion P).map f = f.1 :=
rfl
/-- The inclusion of a wide subcategory is faithful. -/
instance wideSubcategory.faithful : (wideSubcategoryInclusion P).Faithful :=
inferInstanceAs (wideInducedFunctor WideSubcategory.obj P).Faithful
end WideSubcategory
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/PEmpty.lean | import Mathlib.CategoryTheory.Discrete.Basic
/-!
# The empty category
Defines a category structure on `PEmpty`, and the unique functor `PEmpty ⥤ C` for any category `C`.
-/
universe w v v' u u'
-- morphism levels before object levels. See note [category theory universes].
namespace CategoryTheory
variable (C : Type u) [Category.{v} C] (D : Type u') [Category.{v'} D]
instance (α : Type*) [IsEmpty α] : IsEmpty (Discrete α) := Function.isEmpty Discrete.as
/-- The (unique) functor from an empty category. -/
def functorOfIsEmpty [IsEmpty C] : C ⥤ D where
obj := isEmptyElim
map := fun {X} ↦ isEmptyElim X
map_id := fun {X} ↦ isEmptyElim X
map_comp := fun {X} ↦ isEmptyElim X
variable {C D}
/-- Any two functors out of an empty category are isomorphic. -/
def Functor.isEmptyExt [IsEmpty C] (F G : C ⥤ D) : F ≅ G :=
NatIso.ofComponents isEmptyElim (fun {X} ↦ isEmptyElim X)
variable (C D)
/-- The equivalence between two empty categories. -/
def equivalenceOfIsEmpty [IsEmpty C] [IsEmpty D] : C ≌ D where
functor := functorOfIsEmpty C D
inverse := functorOfIsEmpty D C
unitIso := Functor.isEmptyExt _ _
counitIso := Functor.isEmptyExt _ _
functor_unitIso_comp := isEmptyElim
/-- Equivalence between two empty categories. -/
def emptyEquivalence : Discrete.{w} PEmpty ≌ Discrete.{v} PEmpty := equivalenceOfIsEmpty _ _
namespace Functor
/-- The canonical functor out of the empty category. -/
def empty : Discrete.{w} PEmpty ⥤ C :=
Discrete.functor PEmpty.elim
variable {C}
/-- Any two functors out of the empty category are isomorphic. -/
def emptyExt (F G : Discrete.{w} PEmpty ⥤ C) : F ≅ G :=
Discrete.natIso fun x => x.as.elim
/-- Any functor out of the empty category is isomorphic to the canonical functor from the empty
category.
-/
def uniqueFromEmpty (F : Discrete.{w} PEmpty ⥤ C) : F ≅ empty C :=
emptyExt _ _
/-- Any two functors out of the empty category are *equal*. You probably want to use
`emptyExt` instead of this.
-/
theorem empty_ext' (F G : Discrete.{w} PEmpty ⥤ C) : F = G :=
Functor.ext (fun x => x.as.elim) fun x _ _ => x.as.elim
end Functor
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/EqToHom.lean | import Mathlib.CategoryTheory.Opposites
/-!
# 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!
-/
universe v₁ v₂ v₃ u₁ u₂ u₃
-- morphism levels before object levels. See note [category theory universes].
namespace CategoryTheory
open Opposite
/-- 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.
-/
def eqToHom {C : Type u₁} [CategoryStruct.{v₁} C] {X Y : C} (p : X = Y) :
X ⟶ Y := by
rw [p]
exact 𝟙 _
@[simp]
theorem eqToHom_refl {C : Type u₁} [CategoryStruct.{v₁} C] (X : C) (p : X = X) :
eqToHom p = 𝟙 X :=
rfl
variable {C : Type u₁} [Category.{v₁} C]
@[reassoc (attr := simp)]
theorem eqToHom_trans {X Y Z : C} (p : X = Y) (q : Y = Z) :
eqToHom p ≫ eqToHom q = eqToHom (p.trans q) := by
cases p
cases q
simp
/-- `eqToHom h` is heterogeneously equal to the identity of its domain. -/
lemma eqToHom_heq_id_dom (X Y : C) (h : X = Y) : eqToHom h ≍ 𝟙 X := by
subst h; rfl
/-- `eqToHom h` is heterogeneously equal to the identity of its codomain. -/
lemma eqToHom_heq_id_cod (X Y : C) (h : X = Y) : eqToHom h ≍ 𝟙 Y := by
subst h; rfl
/-- Two morphisms are conjugate via eqToHom if and only if they are heterogeneously equal.
Note this used to be in the Functor namespace, where it doesn't belong. -/
theorem conj_eqToHom_iff_heq {W X Y Z : C} (f : W ⟶ X) (g : Y ⟶ Z) (h : W = Y) (h' : X = Z) :
f = eqToHom h ≫ g ≫ eqToHom h'.symm ↔ f ≍ g := by
cases h
cases h'
simp
theorem conj_eqToHom_iff_heq' {C} [Category C] {W X Y Z : C}
(f : W ⟶ X) (g : Y ⟶ Z) (h : W = Y) (h' : Z = X) :
f = eqToHom h ≫ g ≫ eqToHom h' ↔ f ≍ g := conj_eqToHom_iff_heq _ _ _ h'.symm
theorem comp_eqToHom_iff {X Y Y' : C} (p : Y = Y') (f : X ⟶ Y) (g : X ⟶ Y') :
f ≫ eqToHom p = g ↔ f = g ≫ eqToHom p.symm :=
{ mp := fun h => h ▸ by simp
mpr := fun h => by simp [eq_whisker h (eqToHom p)] }
theorem eqToHom_comp_iff {X X' Y : C} (p : X = X') (f : X ⟶ Y) (g : X' ⟶ Y) :
eqToHom p ≫ g = f ↔ g = eqToHom p.symm ≫ f :=
{ mp := fun h => h ▸ by simp
mpr := fun h => h ▸ by simp }
theorem eqToHom_comp_heq {C} [Category C] {W X Y : C}
(f : Y ⟶ X) (h : W = Y) : eqToHom h ≫ f ≍ f := by
rw [← conj_eqToHom_iff_heq _ _ h rfl, eqToHom_refl, Category.comp_id]
@[simp] theorem eqToHom_comp_heq_iff {C} [Category C] {W X Y Z Z' : C}
(f : Y ⟶ X) (g : Z ⟶ Z') (h : W = Y) :
eqToHom h ≫ f ≍ g ↔ f ≍ g :=
⟨(eqToHom_comp_heq ..).symm.trans, (eqToHom_comp_heq ..).trans⟩
@[simp] theorem heq_eqToHom_comp_iff {C} [Category C] {W X Y Z Z' : C}
(f : Y ⟶ X) (g : Z ⟶ Z') (h : W = Y) :
g ≍ eqToHom h ≫ f ↔ g ≍ f :=
⟨(·.trans (eqToHom_comp_heq ..)), (·.trans (eqToHom_comp_heq ..).symm)⟩
theorem comp_eqToHom_heq {C} [Category C] {X Y Z : C}
(f : X ⟶ Y) (h : Y = Z) : f ≫ eqToHom h ≍ f := by
rw [← conj_eqToHom_iff_heq' _ _ rfl h, eqToHom_refl, Category.id_comp]
@[simp] theorem comp_eqToHom_heq_iff {C} [Category C] {W X Y Z Z' : C}
(f : X ⟶ Y) (g : Z ⟶ Z') (h : Y = W) :
f ≫ eqToHom h ≍ g ↔ f ≍ g :=
⟨(comp_eqToHom_heq ..).symm.trans, (comp_eqToHom_heq ..).trans⟩
@[simp] theorem heq_comp_eqToHom_iff {C} [Category C] {W X Y Z Z' : C}
(f : X ⟶ Y) (g : Z ⟶ Z') (h : Y = W) :
g ≍ f ≫ eqToHom h ↔ g ≍ f :=
⟨(·.trans (comp_eqToHom_heq ..)), (·.trans (comp_eqToHom_heq ..).symm)⟩
theorem heq_comp {C} [Category C] {X Y Z X' Y' Z' : C}
{f : X ⟶ Y} {g : Y ⟶ Z} {f' : X' ⟶ Y'} {g' : Y' ⟶ Z'}
(eq1 : X = X') (eq2 : Y = Y') (eq3 : Z = Z')
(H1 : f ≍ f') (H2 : g ≍ g') :
f ≫ g ≍ f' ≫ g' := by
grind
variable {β : Sort*}
/-- We can push `eqToHom` to the left through families of morphisms. -/
@[reassoc (attr := simp)]
theorem eqToHom_naturality {f g : β → C} (z : ∀ b, f b ⟶ g b) {j j' : β} (w : j = j') :
z j ≫ eqToHom (by simp [w]) = eqToHom (by simp [w]) ≫ z j' := by
cases w
simp
/-- A variant on `eqToHom_naturality` that helps Lean identify the families `f` and `g`. -/
@[reassoc (attr := simp)]
theorem eqToHom_iso_hom_naturality {f g : β → C} (z : ∀ b, f b ≅ g b) {j j' : β} (w : j = j') :
(z j).hom ≫ eqToHom (by simp [w]) = eqToHom (by simp [w]) ≫ (z j').hom := by
cases w
simp
/-- A variant on `eqToHom_naturality` that helps Lean identify the families `f` and `g`. -/
@[reassoc (attr := simp)]
theorem eqToHom_iso_inv_naturality {f g : β → C} (z : ∀ b, f b ≅ g b) {j j' : β} (w : j = j') :
(z j).inv ≫ eqToHom (by simp [w]) = eqToHom (by simp [w]) ≫ (z j').inv := by
cases w
simp
/-- Reducible form of congrArg_mpr_hom_left -/
@[simp]
theorem congrArg_cast_hom_left {X Y Z : C} (p : X = Y) (q : Y ⟶ Z) :
cast (congrArg (fun W : C => W ⟶ Z) p.symm) q = eqToHom p ≫ q := by
cases p
simp
/-- 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.
-/
theorem congrArg_mpr_hom_left {X Y Z : C} (p : X = Y) (q : Y ⟶ Z) :
(congrArg (fun W : C => W ⟶ Z) p).mpr q = eqToHom p ≫ q := by
cases p
simp
/-- Reducible form of `congrArg_mpr_hom_right` -/
@[simp]
theorem congrArg_cast_hom_right {X Y Z : C} (p : X ⟶ Y) (q : Z = Y) :
cast (congrArg (fun W : C => X ⟶ W) q.symm) p = p ≫ eqToHom q.symm := by
cases q
simp
/-- 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.
-/
theorem congrArg_mpr_hom_right {X Y Z : C} (p : X ⟶ Y) (q : Z = Y) :
(congrArg (fun W : C => X ⟶ W) q).mpr p = p ≫ eqToHom q.symm := by
cases q
simp
/-- 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.
-/
def eqToIso {X Y : C} (p : X = Y) : X ≅ Y :=
⟨eqToHom p, eqToHom p.symm, by simp, by simp⟩
@[simp]
theorem eqToIso.hom {X Y : C} (p : X = Y) : (eqToIso p).hom = eqToHom p :=
rfl
@[simp]
theorem eqToIso.inv {X Y : C} (p : X = Y) : (eqToIso p).inv = eqToHom p.symm :=
rfl
@[simp]
theorem eqToIso_refl {X : C} (p : X = X) : eqToIso p = Iso.refl X :=
rfl
@[simp]
theorem eqToIso_trans {X Y Z : C} (p : X = Y) (q : Y = Z) :
eqToIso p ≪≫ eqToIso q = eqToIso (p.trans q) := by ext; simp
@[simp]
theorem eqToHom_op {X Y : C} (h : X = Y) : (eqToHom h).op = eqToHom (congr_arg op h.symm) := by
cases h
rfl
@[simp]
theorem eqToHom_unop {X Y : Cᵒᵖ} (h : X = Y) :
(eqToHom h).unop = eqToHom (congr_arg unop h.symm) := by
cases h
rfl
instance {X Y : C} (h : X = Y) : IsIso (eqToHom h) :=
(eqToIso h).isIso_hom
@[simp]
theorem inv_eqToHom {X Y : C} (h : X = Y) : inv (eqToHom h) = eqToHom h.symm := by
cat_disch
variable {D : Type u₂} [Category.{v₂} D]
namespace Functor
/-- Proving equality between functors. This isn't an extensionality lemma,
because usually you don't really want to do this. -/
theorem ext {F G : C ⥤ D} (h_obj : ∀ X, F.obj X = G.obj X)
(h_map : ∀ X Y f,
F.map f = eqToHom (h_obj X) ≫ G.map f ≫ eqToHom (h_obj Y).symm := by cat_disch) :
F = G := by
match F, G with
| mk F_obj _ _ _, mk G_obj _ _ _ =>
obtain rfl : F_obj = G_obj := by
ext X
apply h_obj
congr
funext X Y f
simpa using h_map X Y f
lemma ext_of_iso {F G : C ⥤ D} (e : F ≅ G) (hobj : ∀ X, F.obj X = G.obj X)
(happ : ∀ X, e.hom.app X = eqToHom (hobj X) := by cat_disch) : F = G :=
Functor.ext hobj (fun X Y f => by
rw [← cancel_mono (e.hom.app Y), e.hom.naturality f, happ, happ, Category.assoc,
Category.assoc, eqToHom_trans, eqToHom_refl, Category.comp_id])
/-- Proving equality between functors using heterogeneous equality. -/
theorem hext {F G : C ⥤ D} (h_obj : ∀ X, F.obj X = G.obj X)
(h_map : ∀ (X Y) (f : X ⟶ Y), F.map f ≍ G.map f) : F = G :=
Functor.ext h_obj fun _ _ f => (conj_eqToHom_iff_heq _ _ (h_obj _) (h_obj _)).2 <| h_map _ _ f
-- Using equalities between functors.
theorem congr_obj {F G : C ⥤ D} (h : F = G) (X) : F.obj X = G.obj X := by rw [h]
@[reassoc]
theorem congr_hom {F G : C ⥤ D} (h : F = G) {X Y} (f : X ⟶ Y) :
F.map f = eqToHom (congr_obj h X) ≫ G.map f ≫ eqToHom (congr_obj h Y).symm := by
subst h; simp
theorem congr_inv_of_congr_hom (F G : C ⥤ D) {X Y : C} (e : X ≅ Y) (hX : F.obj X = G.obj X)
(hY : F.obj Y = G.obj Y)
(h₂ : F.map e.hom = eqToHom (by rw [hX]) ≫ G.map e.hom ≫ eqToHom (by rw [hY])) :
F.map e.inv = eqToHom (by rw [hY]) ≫ G.map e.inv ≫ eqToHom (by rw [hX]) := by
simp only [← IsIso.Iso.inv_hom e, Functor.map_inv, h₂, IsIso.inv_comp, inv_eqToHom,
Category.assoc]
section HEq
-- Composition of functors and maps w.r.t. heq
variable {E : Type u₃} [Category.{v₃} E] {F G : C ⥤ D} {X Y Z : C} {f : X ⟶ Y} {g : Y ⟶ Z}
theorem map_comp_heq (hx : F.obj X = G.obj X) (hy : F.obj Y = G.obj Y) (hz : F.obj Z = G.obj Z)
(hf : F.map f ≍ G.map f) (hg : F.map g ≍ G.map g) :
F.map (f ≫ g) ≍ G.map (f ≫ g) := by
rw [F.map_comp, G.map_comp]
congr
theorem map_comp_heq' (hobj : ∀ X : C, F.obj X = G.obj X)
(hmap : ∀ {X Y} (f : X ⟶ Y), F.map f ≍ G.map f) :
F.map (f ≫ g) ≍ G.map (f ≫ g) := by
rw [Functor.hext hobj fun _ _ => hmap]
theorem precomp_map_heq (H : E ⥤ C) (hmap : ∀ {X Y} (f : X ⟶ Y), F.map f ≍ G.map f) {X Y : E}
(f : X ⟶ Y) : (H ⋙ F).map f ≍ (H ⋙ G).map f :=
hmap _
theorem postcomp_map_heq (H : D ⥤ E) (hx : F.obj X = G.obj X) (hy : F.obj Y = G.obj Y)
(hmap : F.map f ≍ G.map f) : (F ⋙ H).map f ≍ (G ⋙ H).map f := by
dsimp
congr
theorem postcomp_map_heq' (H : D ⥤ E) (hobj : ∀ X : C, F.obj X = G.obj X)
(hmap : ∀ {X Y} (f : X ⟶ Y), F.map f ≍ G.map f) :
(F ⋙ H).map f ≍ (G ⋙ H).map f := by rw [Functor.hext hobj fun _ _ => hmap]
theorem hcongr_hom {F G : C ⥤ D} (h : F = G) {X Y} (f : X ⟶ Y) : F.map f ≍ G.map f := by
rw [h]
end HEq
end Functor
/-- 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 `attribute [local simp] eqToHom_map`, however.
-/
theorem eqToHom_map (F : C ⥤ D) {X Y : C} (p : X = Y) :
F.map (eqToHom p) = eqToHom (congr_arg F.obj p) := by cases p; simp
@[reassoc (attr := simp)]
theorem eqToHom_map_comp (F : C ⥤ D) {X Y Z : C} (p : X = Y) (q : Y = Z) :
F.map (eqToHom p) ≫ F.map (eqToHom q) = F.map (eqToHom <| p.trans q) := by cat_disch
/-- See the note on `eqToHom_map` regarding using this as a `simp` lemma.
-/
theorem eqToIso_map (F : C ⥤ D) {X Y : C} (p : X = Y) :
F.mapIso (eqToIso p) = eqToIso (congr_arg F.obj p) := by ext; cases p; simp
@[simp]
theorem eqToIso_map_trans (F : C ⥤ D) {X Y Z : C} (p : X = Y) (q : Y = Z) :
F.mapIso (eqToIso p) ≪≫ F.mapIso (eqToIso q) = F.mapIso (eqToIso <| p.trans q) := by cat_disch
@[simp]
theorem eqToHom_app {F G : C ⥤ D} (h : F = G) (X : C) :
(eqToHom h : F ⟶ G).app X = eqToHom (Functor.congr_obj h X) := by subst h; rfl
theorem NatTrans.congr {F G : C ⥤ D} (α : F ⟶ G) {X Y : C} (h : X = Y) :
α.app X = F.map (eqToHom h) ≫ α.app Y ≫ G.map (eqToHom h.symm) := by
rw [α.naturality_assoc]
simp [eqToHom_map]
theorem eq_conj_eqToHom {X Y : C} (f : X ⟶ Y) : f = eqToHom rfl ≫ f ≫ eqToHom rfl := by
simp only [Category.id_comp, eqToHom_refl, Category.comp_id]
theorem dcongr_arg {ι : Type*} {F G : ι → C} (α : ∀ i, F i ⟶ G i) {i j : ι} (h : i = j) :
α i = eqToHom (congr_arg F h) ≫ α j ≫ eqToHom (congr_arg G h.symm) := by
subst h
simp
/-- If `T ≃ D` is a bijection and `D` is a category, then
`InducedCategory D e` is equivalent to `D`. -/
@[simps]
def Equivalence.induced {T : Type*} (e : T ≃ D) :
InducedCategory D e ≌ D where
functor := inducedFunctor e
inverse :=
{ obj := e.symm
map {X Y} f := show e (e.symm X) ⟶ e (e.symm Y) from
eqToHom (e.apply_symm_apply X) ≫ f ≫
eqToHom (e.apply_symm_apply Y).symm
map_comp {X Y Z} f g := by
dsimp
rw [Category.assoc]
erw [Category.assoc]
rw [Category.assoc, eqToHom_trans_assoc, eqToHom_refl, Category.id_comp] }
unitIso := NatIso.ofComponents (fun _ ↦ eqToIso (by simp)) (fun {X Y} f ↦ by
dsimp
erw [eqToHom_trans_assoc _ (by simp), eqToHom_refl, Category.id_comp]
rfl )
counitIso := NatIso.ofComponents (fun _ ↦ eqToIso (by simp))
functor_unitIso_comp X := eqToHom_trans (by simp) (by simp)
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Whiskering.lean | import Mathlib.Tactic.CategoryTheory.IsoReassoc
import Mathlib.CategoryTheory.Functor.Category
import Mathlib.CategoryTheory.Functor.FullyFaithful
/-!
# Whiskering
Given a functor `F : C ⥤ D` and functors `G H : D ⥤ E` and a natural transformation `α : G ⟶ H`,
we can construct a new natural transformation `F ⋙ G ⟶ F ⋙ H`,
called `whiskerLeft F α`. This is the same as the horizontal composition of `𝟙 F` with `α`.
This operation is functorial in `F`, and we package this as `whiskeringLeft`. Here
`(whiskeringLeft.obj F).obj G` is `F ⋙ G`, and
`(whiskeringLeft.obj F).map α` is `whiskerLeft F α`.
(That is, we might have alternatively named this as the "left composition functor".)
We also provide analogues for composition on the right, and for these operations on isomorphisms.
We show the associators an unitor natural isomorphisms satisfy the triangle and pentagon
identities.
-/
namespace CategoryTheory
namespace Functor
universe u₁ v₁ u₂ v₂ u₃ v₃ u₄ v₄
section
variable {C : Type u₁} [Category.{v₁} C] {D : Type u₂} [Category.{v₂} D] {E : Type u₃}
[Category.{v₃} E]
/-- If `α : G ⟶ H` then `whiskerLeft F α : F ⋙ G ⟶ F ⋙ H` has components `α.app (F.obj X)`. -/
@[simps]
def whiskerLeft (F : C ⥤ D) {G H : D ⥤ E} (α : G ⟶ H) :
F ⋙ G ⟶ F ⋙ H where
app X := α.app (F.obj X)
naturality X Y f := by rw [Functor.comp_map, Functor.comp_map, α.naturality]
@[simp]
lemma id_hcomp (F : C ⥤ D) {G H : D ⥤ E} (α : G ⟶ H) : 𝟙 F ◫ α = whiskerLeft F α := by
ext
simp
/-- If `α : G ⟶ H` then `whiskerRight α F : G ⋙ F ⟶ H ⋙ F` has components `F.map (α.app X)`. -/
@[simps]
def whiskerRight {G H : C ⥤ D} (α : G ⟶ H) (F : D ⥤ E) :
G ⋙ F ⟶ H ⋙ F where
app X := F.map (α.app X)
naturality X Y f := by
rw [Functor.comp_map, Functor.comp_map, ← F.map_comp, ← F.map_comp, α.naturality]
@[simp]
lemma hcomp_id {G H : C ⥤ D} (α : G ⟶ H) (F : D ⥤ E) : α ◫ 𝟙 F = whiskerRight α F := by
ext
simp
variable (C D E)
/-- Left-composition gives a functor `(C ⥤ D) ⥤ ((D ⥤ E) ⥤ (C ⥤ E))`.
`(whiskeringLeft.obj F).obj G` is `F ⋙ G`, and
`(whiskeringLeft.obj F).map α` is `whiskerLeft F α`.
-/
@[simps]
def whiskeringLeft : (C ⥤ D) ⥤ (D ⥤ E) ⥤ C ⥤ E where
obj F :=
{ obj := fun G => F ⋙ G
map := fun α => whiskerLeft F α }
map τ :=
{ app := fun H =>
{ app := fun c => H.map (τ.app c)
naturality := fun X Y f => by dsimp; rw [← H.map_comp, ← H.map_comp, ← τ.naturality] }
naturality := fun X Y f => by ext; dsimp; rw [f.naturality] }
/-- Right-composition gives a functor `(D ⥤ E) ⥤ ((C ⥤ D) ⥤ (C ⥤ E))`.
`(whiskeringRight.obj H).obj F` is `F ⋙ H`, and
`(whiskeringRight.obj H).map α` is `whiskerRight α H`.
-/
@[simps]
def whiskeringRight : (D ⥤ E) ⥤ (C ⥤ D) ⥤ C ⥤ E where
obj H :=
{ obj := fun F => F ⋙ H
map := fun α => whiskerRight α H }
map τ :=
{ app := fun F =>
{ app := fun c => τ.app (F.obj c)
naturality := fun X Y f => by dsimp; rw [τ.naturality] }
naturality := fun X Y f => by ext; dsimp; rw [← NatTrans.naturality] }
variable {C} {D} {E}
instance faithful_whiskeringRight_obj {F : D ⥤ E} [F.Faithful] :
((whiskeringRight C D E).obj F).Faithful where
map_injective hαβ := by
ext X
exact F.map_injective <| congr_fun (congr_arg NatTrans.app hαβ) X
/-- If `F : D ⥤ E` is fully faithful, then so is
`(whiskeringRight C D E).obj F : (C ⥤ D) ⥤ C ⥤ E`. -/
@[simps]
def FullyFaithful.whiskeringRight {F : D ⥤ E} (hF : F.FullyFaithful)
(C : Type*) [Category C] :
((whiskeringRight C D E).obj F).FullyFaithful where
preimage f :=
{ app := fun X => hF.preimage (f.app X)
naturality := fun _ _ g => by
apply hF.map_injective
dsimp
simp only [map_comp, map_preimage]
apply f.naturality }
theorem whiskeringLeft_obj_id : (whiskeringLeft C C E).obj (𝟭 _) = 𝟭 _ :=
rfl
/-- The isomorphism between left-whiskering on the identity functor and the identity of the functor
between the resulting functor categories. -/
@[simps!]
def whiskeringLeftObjIdIso : (whiskeringLeft C C E).obj (𝟭 _) ≅ 𝟭 _ :=
Iso.refl _
theorem whiskeringLeft_obj_comp {D' : Type u₄} [Category.{v₄} D'] (F : C ⥤ D) (G : D ⥤ D') :
(whiskeringLeft C D' E).obj (F ⋙ G) =
(whiskeringLeft D D' E).obj G ⋙ (whiskeringLeft C D E).obj F :=
rfl
/-- The isomorphism between left-whiskering on the composition of functors and the composition
of two left-whiskering applications. -/
@[simps!]
def whiskeringLeftObjCompIso {D' : Type u₄} [Category.{v₄} D'] (F : C ⥤ D) (G : D ⥤ D') :
(whiskeringLeft C D' E).obj (F ⋙ G) ≅
(whiskeringLeft D D' E).obj G ⋙ (whiskeringLeft C D E).obj F :=
Iso.refl _
theorem whiskeringRight_obj_id : (whiskeringRight E C C).obj (𝟭 _) = 𝟭 _ :=
rfl
/-- The isomorphism between right-whiskering on the identity functor and the identity of the functor
between the resulting functor categories. -/
@[simps!]
def whiskeringRightObjIdIso : (whiskeringRight E C C).obj (𝟭 _) ≅ 𝟭 _ :=
Iso.refl _
theorem whiskeringRight_obj_comp {D' : Type u₄} [Category.{v₄} D'] (F : C ⥤ D) (G : D ⥤ D') :
(whiskeringRight E C D).obj F ⋙ (whiskeringRight E D D').obj G =
(whiskeringRight E C D').obj (F ⋙ G) :=
rfl
/-- The isomorphism between right-whiskering on the composition of functors and the composition
of two right-whiskering applications. -/
@[simps!]
def whiskeringRightObjCompIso {D' : Type u₄} [Category.{v₄} D'] (F : C ⥤ D) (G : D ⥤ D') :
(whiskeringRight E C D).obj F ⋙ (whiskeringRight E D D').obj G ≅
(whiskeringRight E C D').obj (F ⋙ G) :=
Iso.refl _
instance full_whiskeringRight_obj {F : D ⥤ E} [F.Faithful] [F.Full] :
((whiskeringRight C D E).obj F).Full :=
((Functor.FullyFaithful.ofFullyFaithful F).whiskeringRight C).full
@[simp]
theorem whiskerLeft_id (F : C ⥤ D) {G : D ⥤ E} :
whiskerLeft F (NatTrans.id G) = NatTrans.id (F.comp G) :=
rfl
@[simp]
theorem whiskerLeft_id' (F : C ⥤ D) {G : D ⥤ E} : whiskerLeft F (𝟙 G) = 𝟙 (F.comp G) :=
rfl
@[simp]
theorem whiskerRight_id {G : C ⥤ D} (F : D ⥤ E) :
whiskerRight (NatTrans.id G) F = NatTrans.id (G.comp F) :=
((whiskeringRight C D E).obj F).map_id _
@[simp]
theorem whiskerRight_id' {G : C ⥤ D} (F : D ⥤ E) : whiskerRight (𝟙 G) F = 𝟙 (G.comp F) :=
((whiskeringRight C D E).obj F).map_id _
@[simp, reassoc]
theorem whiskerLeft_comp (F : C ⥤ D) {G H K : D ⥤ E} (α : G ⟶ H) (β : H ⟶ K) :
whiskerLeft F (α ≫ β) = whiskerLeft F α ≫ whiskerLeft F β :=
rfl
@[simp, reassoc]
theorem whiskerRight_comp {G H K : C ⥤ D} (α : G ⟶ H) (β : H ⟶ K) (F : D ⥤ E) :
whiskerRight (α ≫ β) F = whiskerRight α F ≫ whiskerRight β F :=
((whiskeringRight C D E).obj F).map_comp α β
@[reassoc]
theorem whiskerLeft_comp_whiskerRight {F G : C ⥤ D} {H K : D ⥤ E} (α : F ⟶ G) (β : H ⟶ K) :
whiskerLeft F β ≫ whiskerRight α K = whiskerRight α H ≫ whiskerLeft G β := by
ext
simp
lemma NatTrans.hcomp_eq_whiskerLeft_comp_whiskerRight {F G : C ⥤ D} {H K : D ⥤ E}
(α : F ⟶ G) (β : H ⟶ K) : α ◫ β = whiskerLeft F β ≫ whiskerRight α K := by
ext
simp
/-- If `α : G ≅ H` is a natural isomorphism then
`isoWhiskerLeft F α : (F ⋙ G) ≅ (F ⋙ H)` has components `α.app (F.obj X)`.
-/
def isoWhiskerLeft (F : C ⥤ D) {G H : D ⥤ E} (α : G ≅ H) : F ⋙ G ≅ F ⋙ H :=
((whiskeringLeft C D E).obj F).mapIso α
@[simp]
theorem isoWhiskerLeft_hom (F : C ⥤ D) {G H : D ⥤ E} (α : G ≅ H) :
(isoWhiskerLeft F α).hom = whiskerLeft F α.hom :=
rfl
@[simp]
theorem isoWhiskerLeft_inv (F : C ⥤ D) {G H : D ⥤ E} (α : G ≅ H) :
(isoWhiskerLeft F α).inv = whiskerLeft F α.inv :=
rfl
lemma isoWhiskerLeft_symm (F : C ⥤ D) {G H : D ⥤ E} (α : G ≅ H) :
(isoWhiskerLeft F α).symm = isoWhiskerLeft F α.symm :=
rfl
@[simp]
lemma isoWhiskerLeft_refl (F : C ⥤ D) (G : D ⥤ E) :
isoWhiskerLeft F (Iso.refl G) = Iso.refl _ :=
rfl
/-- If `α : G ≅ H` then
`isoWhiskerRight α F : (G ⋙ F) ≅ (H ⋙ F)` has components `F.map_iso (α.app X)`.
-/
def isoWhiskerRight {G H : C ⥤ D} (α : G ≅ H) (F : D ⥤ E) : G ⋙ F ≅ H ⋙ F :=
((whiskeringRight C D E).obj F).mapIso α
@[simp]
theorem isoWhiskerRight_hom {G H : C ⥤ D} (α : G ≅ H) (F : D ⥤ E) :
(isoWhiskerRight α F).hom = whiskerRight α.hom F :=
rfl
@[simp]
theorem isoWhiskerRight_inv {G H : C ⥤ D} (α : G ≅ H) (F : D ⥤ E) :
(isoWhiskerRight α F).inv = whiskerRight α.inv F :=
rfl
lemma isoWhiskerRight_symm {G H : C ⥤ D} (α : G ≅ H) (F : D ⥤ E) :
(isoWhiskerRight α F).symm = isoWhiskerRight α.symm F :=
rfl
@[simp]
lemma isoWhiskerRight_refl (F : C ⥤ D) (G : D ⥤ E) :
isoWhiskerRight (Iso.refl F) G = Iso.refl _ := by
cat_disch
instance isIso_whiskerLeft (F : C ⥤ D) {G H : D ⥤ E} (α : G ⟶ H) [IsIso α] :
IsIso (whiskerLeft F α) :=
(isoWhiskerLeft F (asIso α)).isIso_hom
instance isIso_whiskerRight {G H : C ⥤ D} (α : G ⟶ H) (F : D ⥤ E) [IsIso α] :
IsIso (whiskerRight α F) :=
(isoWhiskerRight (asIso α) F).isIso_hom
@[simp]
theorem inv_whiskerRight {G H : C ⥤ D} (α : G ⟶ H) (F : D ⥤ E) [IsIso α] :
inv (whiskerRight α F) = whiskerRight (inv α) F := by
symm
apply IsIso.eq_inv_of_inv_hom_id
simp [← whiskerRight_comp]
@[simp]
theorem inv_whiskerLeft (F : C ⥤ D) {G H : D ⥤ E} (α : G ⟶ H) [IsIso α] :
inv (whiskerLeft F α) = whiskerLeft F (inv α) := by
symm
apply IsIso.eq_inv_of_inv_hom_id
simp [← whiskerLeft_comp]
@[simp, reassoc]
theorem isoWhiskerLeft_trans (F : C ⥤ D) {G H K : D ⥤ E} (α : G ≅ H) (β : H ≅ K) :
isoWhiskerLeft F (α ≪≫ β) = isoWhiskerLeft F α ≪≫ isoWhiskerLeft F β :=
rfl
@[simp, reassoc]
theorem isoWhiskerRight_trans {G H K : C ⥤ D} (α : G ≅ H) (β : H ≅ K) (F : D ⥤ E) :
isoWhiskerRight (α ≪≫ β) F = isoWhiskerRight α F ≪≫ isoWhiskerRight β F :=
((whiskeringRight C D E).obj F).mapIso_trans α β
@[reassoc]
theorem isoWhiskerLeft_trans_isoWhiskerRight {F G : C ⥤ D} {H K : D ⥤ E} (α : F ≅ G) (β : H ≅ K) :
isoWhiskerLeft F β ≪≫ isoWhiskerRight α K = isoWhiskerRight α H ≪≫ isoWhiskerLeft G β := by
ext
simp
variable {B : Type u₄} [Category.{v₄} B]
@[simp]
theorem whiskerLeft_twice (F : B ⥤ C) (G : C ⥤ D) {H K : D ⥤ E} (α : H ⟶ K) :
whiskerLeft F (whiskerLeft G α) =
(Functor.associator _ _ _).inv ≫ whiskerLeft (F ⋙ G) α ≫ (Functor.associator _ _ _).hom := by
cat_disch
@[simp]
theorem whiskerRight_twice {H K : B ⥤ C} (F : C ⥤ D) (G : D ⥤ E) (α : H ⟶ K) :
whiskerRight (whiskerRight α F) G =
(Functor.associator _ _ _).hom ≫ whiskerRight α (F ⋙ G) ≫ (Functor.associator _ _ _).inv := by
cat_disch
theorem whiskerRight_left (F : B ⥤ C) {G H : C ⥤ D} (α : G ⟶ H) (K : D ⥤ E) :
whiskerRight (whiskerLeft F α) K =
(Functor.associator _ _ _).hom ≫ whiskerLeft F (whiskerRight α K) ≫
(Functor.associator _ _ _).inv := by
cat_disch
@[simp]
theorem isoWhiskerLeft_twice (F : B ⥤ C) (G : C ⥤ D) {H K : D ⥤ E} (α : H ≅ K) :
isoWhiskerLeft F (isoWhiskerLeft G α) =
(Functor.associator _ _ _).symm ≪≫ isoWhiskerLeft (F ⋙ G) α ≪≫ Functor.associator _ _ _ := by
cat_disch
@[simp, reassoc]
theorem isoWhiskerRight_twice {H K : B ⥤ C} (F : C ⥤ D) (G : D ⥤ E) (α : H ≅ K) :
isoWhiskerRight (isoWhiskerRight α F) G =
Functor.associator _ _ _ ≪≫ isoWhiskerRight α (F ⋙ G) ≪≫ (Functor.associator _ _ _).symm := by
cat_disch
@[reassoc]
theorem isoWhiskerRight_left (F : B ⥤ C) {G H : C ⥤ D} (α : G ≅ H) (K : D ⥤ E) :
isoWhiskerRight (isoWhiskerLeft F α) K =
Functor.associator _ _ _ ≪≫ isoWhiskerLeft F (isoWhiskerRight α K) ≪≫
(Functor.associator _ _ _).symm := by
cat_disch
@[reassoc]
theorem isoWhiskerLeft_right (F : B ⥤ C) {G H : C ⥤ D} (α : G ≅ H) (K : D ⥤ E) :
isoWhiskerLeft F (isoWhiskerRight α K) =
(Functor.associator _ _ _).symm ≪≫ isoWhiskerRight (isoWhiskerLeft F α) K ≪≫
Functor.associator _ _ _ := by
cat_disch
end
universe u₅ v₅
variable {A : Type u₁} [Category.{v₁} A] {B : Type u₂} [Category.{v₂} B]
{C : Type u₃} [Category.{v₃} C] {D : Type u₄} [Category.{v₄} D] {E : Type u₅} [Category.{v₅} E]
(F : A ⥤ B) (G : B ⥤ C) (H : C ⥤ D) (K : D ⥤ E)
@[reassoc]
theorem triangleIso :
associator F (𝟭 B) G ≪≫ isoWhiskerLeft F (leftUnitor G) =
isoWhiskerRight (rightUnitor F) G := by cat_disch
@[reassoc]
theorem pentagonIso :
isoWhiskerRight (associator F G H) K ≪≫
associator F (G ⋙ H) K ≪≫ isoWhiskerLeft F (associator G H K) =
associator (F ⋙ G) H K ≪≫ associator F G (H ⋙ K) := by cat_disch
theorem triangle :
(associator F (𝟭 B) G).hom ≫ whiskerLeft F (leftUnitor G).hom =
whiskerRight (rightUnitor F).hom G := by cat_disch
theorem pentagon :
whiskerRight (associator F G H).hom K ≫
(associator F (G ⋙ H) K).hom ≫ whiskerLeft F (associator G H K).hom =
(associator (F ⋙ G) H K).hom ≫ (associator F G (H ⋙ K)).hom := by cat_disch
variable {C₁ C₂ C₃ D₁ D₂ D₃ : Type*} [Category C₁] [Category C₂] [Category C₃]
[Category D₁] [Category D₂] [Category D₃] (E : Type*) [Category E]
/-- The obvious functor `(C₁ ⥤ D₁) ⥤ (C₂ ⥤ D₂) ⥤ (D₁ ⥤ D₂ ⥤ E) ⥤ (C₁ ⥤ C₂ ⥤ E)`. -/
@[simps!]
def whiskeringLeft₂ :
(C₁ ⥤ D₁) ⥤ (C₂ ⥤ D₂) ⥤ (D₁ ⥤ D₂ ⥤ E) ⥤ (C₁ ⥤ C₂ ⥤ E) where
obj F₁ :=
{ obj := fun F₂ ↦
(whiskeringRight D₁ (D₂ ⥤ E) (C₂ ⥤ E)).obj ((whiskeringLeft C₂ D₂ E).obj F₂) ⋙
(whiskeringLeft C₁ D₁ (C₂ ⥤ E)).obj F₁
map := fun φ ↦ whiskerRight
((whiskeringRight D₁ (D₂ ⥤ E) (C₂ ⥤ E)).map ((whiskeringLeft C₂ D₂ E).map φ)) _ }
map ψ :=
{ app := fun F₂ ↦ whiskerLeft _ ((whiskeringLeft C₁ D₁ (C₂ ⥤ E)).map ψ) }
/-- Auxiliary definition for `whiskeringLeft₃`. -/
@[simps!]
def whiskeringLeft₃ObjObjObj (F₁ : C₁ ⥤ D₁) (F₂ : C₂ ⥤ D₂) (F₃ : C₃ ⥤ D₃) :
(D₁ ⥤ D₂ ⥤ D₃ ⥤ E) ⥤ C₁ ⥤ C₂ ⥤ C₃ ⥤ E :=
(whiskeringRight _ _ _).obj (((whiskeringLeft₂ E).obj F₂).obj F₃) ⋙
(whiskeringLeft C₁ D₁ _).obj F₁
/-- Auxiliary definition for `whiskeringLeft₃`. -/
@[simps]
def whiskeringLeft₃ObjObjMap (F₁ : C₁ ⥤ D₁) (F₂ : C₂ ⥤ D₂) {F₃ F₃' : C₃ ⥤ D₃} (τ₃ : F₃ ⟶ F₃') :
whiskeringLeft₃ObjObjObj E F₁ F₂ F₃ ⟶
whiskeringLeft₃ObjObjObj E F₁ F₂ F₃' where
app F := whiskerLeft _ (whiskerLeft _ (((whiskeringLeft₂ E).obj F₂).map τ₃))
variable (C₃ D₃) in
/-- Auxiliary definition for `whiskeringLeft₃`. -/
@[simps]
def whiskeringLeft₃ObjObj (F₁ : C₁ ⥤ D₁) (F₂ : C₂ ⥤ D₂) :
(C₃ ⥤ D₃) ⥤ (D₁ ⥤ D₂ ⥤ D₃ ⥤ E) ⥤ (C₁ ⥤ C₂ ⥤ C₃ ⥤ E) where
obj F₃ := whiskeringLeft₃ObjObjObj E F₁ F₂ F₃
map τ₃ := whiskeringLeft₃ObjObjMap E F₁ F₂ τ₃
variable (C₃ D₃) in
/-- Auxiliary definition for `whiskeringLeft₃`. -/
@[simps]
def whiskeringLeft₃ObjMap (F₁ : C₁ ⥤ D₁) {F₂ F₂' : C₂ ⥤ D₂} (τ₂ : F₂ ⟶ F₂') :
whiskeringLeft₃ObjObj C₃ D₃ E F₁ F₂ ⟶ whiskeringLeft₃ObjObj C₃ D₃ E F₁ F₂' where
app F₃ := whiskerRight ((whiskeringRight _ _ _).map (((whiskeringLeft₂ E).map τ₂).app F₃)) _
variable (C₂ C₃ D₂ D₃) in
/-- Auxiliary definition for `whiskeringLeft₃`. -/
@[simps]
def whiskeringLeft₃Obj (F₁ : C₁ ⥤ D₁) :
(C₂ ⥤ D₂) ⥤ (C₃ ⥤ D₃) ⥤ (D₁ ⥤ D₂ ⥤ D₃ ⥤ E) ⥤ (C₁ ⥤ C₂ ⥤ C₃ ⥤ E) where
obj F₂ := whiskeringLeft₃ObjObj C₃ D₃ E F₁ F₂
map τ₂ := whiskeringLeft₃ObjMap C₃ D₃ E F₁ τ₂
variable (C₂ C₃ D₂ D₃) in
/-- Auxiliary definition for `whiskeringLeft₃`. -/
@[simps]
def whiskeringLeft₃Map {F₁ F₁' : C₁ ⥤ D₁} (τ₁ : F₁ ⟶ F₁') :
whiskeringLeft₃Obj C₂ C₃ D₂ D₃ E F₁ ⟶ whiskeringLeft₃Obj C₂ C₃ D₂ D₃ E F₁' where
app F₂ := { app F₃ := whiskerLeft _ ((whiskeringLeft _ _ _).map τ₁) }
/-- The obvious functor
`(C₁ ⥤ D₁) ⥤ (C₂ ⥤ D₂) ⥤ (C₃ ⥤ D₃) ⥤ (D₁ ⥤ D₂ ⥤ D₃ ⥤ E) ⥤ (C₁ ⥤ C₂ ⥤ C₃ ⥤ E)`. -/
@[simps!]
def whiskeringLeft₃ :
(C₁ ⥤ D₁) ⥤ (C₂ ⥤ D₂) ⥤ (C₃ ⥤ D₃) ⥤ (D₁ ⥤ D₂ ⥤ D₃ ⥤ E) ⥤ (C₁ ⥤ C₂ ⥤ C₃ ⥤ E) where
obj F₁ := whiskeringLeft₃Obj C₂ C₃ D₂ D₃ E F₁
map τ₁ := whiskeringLeft₃Map C₂ C₃ D₂ D₃ E τ₁
variable {E}
/-- The "postcomposition" with a functor `E ⥤ E'` gives a functor
`(E ⥤ E') ⥤ (C₁ ⥤ C₂ ⥤ E) ⥤ C₁ ⥤ C₂ ⥤ E'`. -/
@[simps!]
def postcompose₂ {E' : Type*} [Category E'] :
(E ⥤ E') ⥤ (C₁ ⥤ C₂ ⥤ E) ⥤ C₁ ⥤ C₂ ⥤ E' :=
whiskeringRight C₂ _ _ ⋙ whiskeringRight C₁ _ _
/-- The "postcomposition" with a functor `E ⥤ E'` gives a functor
`(E ⥤ E') ⥤ (C₁ ⥤ C₂ ⥤ C₃ ⥤ E) ⥤ C₁ ⥤ C₂ ⥤ C₃ ⥤ E'`. -/
@[simps!]
def postcompose₃ {E' : Type*} [Category E'] :
(E ⥤ E') ⥤ (C₁ ⥤ C₂ ⥤ C₃ ⥤ E) ⥤ C₁ ⥤ C₂ ⥤ C₃ ⥤ E' :=
whiskeringRight C₃ _ _ ⋙ whiskeringRight C₂ _ _ ⋙ whiskeringRight C₁ _ _
end Functor
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Iso.lean | import Mathlib.Tactic.CategoryTheory.Reassoc
/-!
# Isomorphisms
This file defines isomorphisms between objects of a category.
## Main definitions
- `structure Iso` : a bundled isomorphism between two objects of a category;
- `class IsIso` : an unbundled version of `iso`;
note that `IsIso f` is a `Prop`, and only asserts the existence of an inverse.
Of course, this inverse is unique, so it doesn't cost us much to use choice to retrieve it.
- `inv f`, for the inverse of a morphism with `[IsIso f]`
- `asIso` : convert from `IsIso` to `Iso` (noncomputable);
- `of_iso` : convert from `Iso` to `IsIso`;
- standard operations on isomorphisms (composition, inverse etc)
## Notation
- `X ≅ Y` : same as `Iso X Y`;
- `α ≪≫ β` : composition of two isomorphisms; it is called `Iso.trans`
## Tags
category, category theory, isomorphism
-/
set_option mathlib.tactic.category.grind true
universe v u
-- morphism levels before object levels. See note [category theory universes].
namespace CategoryTheory
open Category
/-- An isomorphism (a.k.a. an invertible morphism) between two objects of a category.
The inverse morphism is bundled.
See also `CategoryTheory.Core` for the category with the same objects and isomorphisms playing
the role of morphisms. -/
@[stacks 0017]
structure Iso {C : Type u} [Category.{v} C] (X Y : C) where
/-- The forward direction of an isomorphism. -/
hom : X ⟶ Y
/-- The backwards direction of an isomorphism. -/
inv : Y ⟶ X
/-- Composition of the two directions of an isomorphism is the identity on the source. -/
hom_inv_id : hom ≫ inv = 𝟙 X := by cat_disch
/-- Composition of the two directions of an isomorphism in reverse order
is the identity on the target. -/
inv_hom_id : inv ≫ hom = 𝟙 Y := by cat_disch
attribute [reassoc (attr := simp), grind =] Iso.hom_inv_id Iso.inv_hom_id
/-- Notation for an isomorphism in a category. -/
infixr:10 " ≅ " => Iso -- type as \cong or \iso
variable {C : Type u} [Category.{v} C] {X Y Z : C}
namespace Iso
set_option linter.style.commandStart false in -- false positive, calc blocks
@[ext, grind ext]
theorem ext ⦃α β : X ≅ Y⦄ (w : α.hom = β.hom) : α = β :=
suffices α.inv = β.inv by grind [Iso]
calc
α.inv = α.inv ≫ β.hom ≫ β.inv := by grind
_ = β.inv := by grind
/-- Inverse isomorphism. -/
@[symm]
def symm (I : X ≅ Y) : Y ≅ X where
hom := I.inv
inv := I.hom
@[simp, grind =]
theorem symm_hom (α : X ≅ Y) : α.symm.hom = α.inv :=
rfl
@[simp, grind =]
theorem symm_inv (α : X ≅ Y) : α.symm.inv = α.hom :=
rfl
@[simp, grind =]
theorem symm_mk {X Y : C} (hom : X ⟶ Y) (inv : Y ⟶ X) (hom_inv_id) (inv_hom_id) :
Iso.symm { hom, inv, hom_inv_id := hom_inv_id, inv_hom_id := inv_hom_id } =
{ hom := inv, inv := hom, hom_inv_id := inv_hom_id, inv_hom_id := hom_inv_id } :=
rfl
@[simp, grind =]
theorem symm_symm_eq {X Y : C} (α : X ≅ Y) : α.symm.symm = α := rfl
theorem symm_bijective {X Y : C} : Function.Bijective (symm : (X ≅ Y) → _) :=
Function.bijective_iff_has_inverse.mpr ⟨_, symm_symm_eq, symm_symm_eq⟩
@[simp]
theorem symm_eq_iff {X Y : C} {α β : X ≅ Y} : α.symm = β.symm ↔ α = β :=
symm_bijective.injective.eq_iff
theorem nonempty_iso_symm (X Y : C) : Nonempty (X ≅ Y) ↔ Nonempty (Y ≅ X) :=
⟨fun h => ⟨h.some.symm⟩, fun h => ⟨h.some.symm⟩⟩
/-- Identity isomorphism. -/
@[refl, simps (attr := grind =)]
def refl (X : C) : X ≅ X where
hom := 𝟙 X
inv := 𝟙 X
instance : Inhabited (X ≅ X) := ⟨Iso.refl X⟩
theorem nonempty_iso_refl (X : C) : Nonempty (X ≅ X) := ⟨default⟩
@[simp, grind =]
theorem refl_symm (X : C) : (Iso.refl X).symm = Iso.refl X := rfl
/-- Composition of two isomorphisms -/
@[simps (attr := grind =)]
def trans (α : X ≅ Y) (β : Y ≅ Z) : X ≅ Z where
hom := α.hom ≫ β.hom
inv := β.inv ≫ α.inv
@[simps]
instance instTransIso : Trans (α := C) (· ≅ ·) (· ≅ ·) (· ≅ ·) where
trans := trans
/-- Notation for composition of isomorphisms. -/
infixr:80 " ≪≫ " => Iso.trans -- type as `\ll \gg`.
@[simp, grind =]
theorem trans_mk {X Y Z : C} (hom : X ⟶ Y) (inv : Y ⟶ X) (hom_inv_id) (inv_hom_id)
(hom' : Y ⟶ Z) (inv' : Z ⟶ Y) (hom_inv_id') (inv_hom_id') (hom_inv_id'') (inv_hom_id'') :
Iso.trans ⟨hom, inv, hom_inv_id, inv_hom_id⟩ ⟨hom', inv', hom_inv_id', inv_hom_id'⟩ =
⟨hom ≫ hom', inv' ≫ inv, hom_inv_id'', inv_hom_id''⟩ :=
rfl
@[simp, grind _=_]
theorem trans_symm (α : X ≅ Y) (β : Y ≅ Z) : (α ≪≫ β).symm = β.symm ≪≫ α.symm :=
rfl
@[simp, grind _=_]
theorem trans_assoc {Z' : C} (α : X ≅ Y) (β : Y ≅ Z) (γ : Z ≅ Z') :
(α ≪≫ β) ≪≫ γ = α ≪≫ β ≪≫ γ := by
ext; simp only [trans_hom, Category.assoc]
@[simp]
theorem refl_trans (α : X ≅ Y) : Iso.refl X ≪≫ α = α := by ext; apply Category.id_comp
@[simp]
theorem trans_refl (α : X ≅ Y) : α ≪≫ Iso.refl Y = α := by ext; apply Category.comp_id
@[simp]
theorem symm_self_id (α : X ≅ Y) : α.symm ≪≫ α = Iso.refl Y :=
ext α.inv_hom_id
@[simp]
theorem self_symm_id (α : X ≅ Y) : α ≪≫ α.symm = Iso.refl X :=
ext α.hom_inv_id
@[simp]
theorem symm_self_id_assoc (α : X ≅ Y) (β : Y ≅ Z) : α.symm ≪≫ α ≪≫ β = β := by
rw [← trans_assoc, symm_self_id, refl_trans]
@[simp]
theorem self_symm_id_assoc (α : X ≅ Y) (β : X ≅ Z) : α ≪≫ α.symm ≪≫ β = β := by
rw [← trans_assoc, self_symm_id, refl_trans]
theorem inv_comp_eq (α : X ≅ Y) {f : X ⟶ Z} {g : Y ⟶ Z} : α.inv ≫ f = g ↔ f = α.hom ≫ g :=
⟨fun H => by simp [H.symm], fun H => by simp [H]⟩
theorem eq_inv_comp (α : X ≅ Y) {f : X ⟶ Z} {g : Y ⟶ Z} : g = α.inv ≫ f ↔ α.hom ≫ g = f :=
(inv_comp_eq α.symm).symm
theorem comp_inv_eq (α : X ≅ Y) {f : Z ⟶ Y} {g : Z ⟶ X} : f ≫ α.inv = g ↔ f = g ≫ α.hom :=
⟨fun H => by simp [H.symm], fun H => by simp [H]⟩
theorem eq_comp_inv (α : X ≅ Y) {f : Z ⟶ Y} {g : Z ⟶ X} : g = f ≫ α.inv ↔ g ≫ α.hom = f :=
(comp_inv_eq α.symm).symm
theorem inv_eq_inv (f g : X ≅ Y) : f.inv = g.inv ↔ f.hom = g.hom :=
have : ∀ {X Y : C} (f g : X ≅ Y), f.hom = g.hom → f.inv = g.inv := fun f g h => by rw [ext h]
⟨this f.symm g.symm, this f g⟩
theorem hom_comp_eq_id (α : X ≅ Y) {f : Y ⟶ X} : α.hom ≫ f = 𝟙 X ↔ f = α.inv := by
rw [← eq_inv_comp, comp_id]
theorem comp_hom_eq_id (α : X ≅ Y) {f : Y ⟶ X} : f ≫ α.hom = 𝟙 Y ↔ f = α.inv := by
rw [← eq_comp_inv, id_comp]
theorem inv_comp_eq_id (α : X ≅ Y) {f : X ⟶ Y} : α.inv ≫ f = 𝟙 Y ↔ f = α.hom :=
hom_comp_eq_id α.symm
theorem comp_inv_eq_id (α : X ≅ Y) {f : X ⟶ Y} : f ≫ α.inv = 𝟙 X ↔ f = α.hom :=
comp_hom_eq_id α.symm
theorem hom_eq_inv (α : X ≅ Y) (β : Y ≅ X) : α.hom = β.inv ↔ β.hom = α.inv := by
rw [← symm_inv, inv_eq_inv α.symm β, eq_comm]
rfl
attribute [local grind] Function.LeftInverse Function.RightInverse
/-- The bijection `(Z ⟶ X) ≃ (Z ⟶ Y)` induced by `α : X ≅ Y`. -/
@[simps]
def homToEquiv (α : X ≅ Y) {Z : C} : (Z ⟶ X) ≃ (Z ⟶ Y) where
toFun f := f ≫ α.hom
invFun g := g ≫ α.inv
left_inv := by cat_disch
right_inv := by cat_disch
/-- The bijection `(X ⟶ Z) ≃ (Y ⟶ Z)` induced by `α : X ≅ Y`. -/
@[simps]
def homFromEquiv (α : X ≅ Y) {Z : C} : (X ⟶ Z) ≃ (Y ⟶ Z) where
toFun f := α.inv ≫ f
invFun g := α.hom ≫ g
left_inv := by cat_disch
right_inv := by cat_disch
end Iso
/-- The `IsIso` typeclass expresses that a morphism is invertible.
Given a morphism `f` with `IsIso f`, one can view `f` as an isomorphism via `asIso f` and get
the inverse using `inv f`. -/
class IsIso (f : X ⟶ Y) : Prop where
/-- The existence of an inverse morphism. -/
out : ∃ inv : Y ⟶ X, f ≫ inv = 𝟙 X ∧ inv ≫ f = 𝟙 Y
/-- The inverse of a morphism `f` when we have `[IsIso f]`.
-/
noncomputable def inv (f : X ⟶ Y) [I : IsIso f] : Y ⟶ X :=
Classical.choose I.1
namespace IsIso
@[simp, grind =]
theorem hom_inv_id (f : X ⟶ Y) [I : IsIso f] : f ≫ inv f = 𝟙 X :=
(Classical.choose_spec I.1).left
@[simp, grind =]
theorem inv_hom_id (f : X ⟶ Y) [I : IsIso f] : inv f ≫ f = 𝟙 Y :=
(Classical.choose_spec I.1).right
-- FIXME putting @[reassoc] on the `hom_inv_id` above somehow unfolds `inv`
-- This happens even if we make `inv` irreducible!
-- I don't understand how this is happening: it is likely a bug.
-- attribute [reassoc] hom_inv_id inv_hom_id
-- #print hom_inv_id_assoc
-- theorem CategoryTheory.IsIso.hom_inv_id_assoc {X Y : C} (f : X ⟶ Y) [I : IsIso f]
-- {Z : C} (h : X ⟶ Z),
-- f ≫ Classical.choose (_ : Exists fun inv ↦ f ≫ inv = 𝟙 X ∧ inv ≫ f = 𝟙 Y) ≫ h = h := ...
@[simp]
theorem hom_inv_id_assoc (f : X ⟶ Y) [I : IsIso f] {Z} (g : X ⟶ Z) : f ≫ inv f ≫ g = g := by
simp [← Category.assoc]
@[simp]
theorem inv_hom_id_assoc (f : X ⟶ Y) [I : IsIso f] {Z} (g : Y ⟶ Z) : inv f ≫ f ≫ g = g := by
simp [← Category.assoc]
end IsIso
lemma Iso.isIso_hom (e : X ≅ Y) : IsIso e.hom :=
⟨e.inv, by simp only [hom_inv_id], by simp⟩
lemma Iso.isIso_inv (e : X ≅ Y) : IsIso e.inv := e.symm.isIso_hom
attribute [instance] Iso.isIso_hom Iso.isIso_inv
open IsIso
/-- Reinterpret a morphism `f` with an `IsIso f` instance as an `Iso`. -/
noncomputable def asIso (f : X ⟶ Y) [IsIso f] : X ≅ Y :=
⟨f, inv f, hom_inv_id f, inv_hom_id f⟩
-- Porting note: the `IsIso f` argument had been instance implicit,
-- but we've changed it to implicit as a `rw` in `Mathlib/CategoryTheory/Closed/Functor.lean`
-- was failing to generate it by typeclass search.
@[simp]
theorem asIso_hom (f : X ⟶ Y) [IsIso f] : (asIso f).hom = f :=
rfl
-- Porting note: the `IsIso f` argument had been instance implicit,
-- but we've changed it to implicit as a `rw` in `Mathlib/CategoryTheory/Closed/Functor.lean`
-- was failing to generate it by typeclass search.
@[simp]
theorem asIso_inv (f : X ⟶ Y) [IsIso f] : (asIso f).inv = inv f :=
rfl
namespace IsIso
-- see Note [lower instance priority]
instance (priority := 100) epi_of_iso (f : X ⟶ Y) [IsIso f] : Epi f where
left_cancellation g h w := by
rw [← IsIso.inv_hom_id_assoc f g, w, IsIso.inv_hom_id_assoc f h]
-- see Note [lower instance priority]
instance (priority := 100) mono_of_iso (f : X ⟶ Y) [IsIso f] : Mono f where
right_cancellation g h w := by
rw [← Category.comp_id g, ← Category.comp_id h, ← IsIso.hom_inv_id f,
← Category.assoc, w, ← Category.assoc]
@[aesop apply safe (rule_sets := [CategoryTheory]), grind ←=]
theorem inv_eq_of_hom_inv_id {f : X ⟶ Y} [IsIso f] {g : Y ⟶ X} (hom_inv_id : f ≫ g = 𝟙 X) :
inv f = g := by
have := congrArg (inv f ≫ ·) hom_inv_id
grind
theorem inv_eq_of_inv_hom_id {f : X ⟶ Y} [IsIso f] {g : Y ⟶ X} (inv_hom_id : g ≫ f = 𝟙 Y) :
inv f = g := by
have := congrArg (· ≫ inv f) inv_hom_id
grind
@[aesop apply safe (rule_sets := [CategoryTheory])]
theorem eq_inv_of_hom_inv_id {f : X ⟶ Y} [IsIso f] {g : Y ⟶ X} (hom_inv_id : f ≫ g = 𝟙 X) :
g = inv f :=
(inv_eq_of_hom_inv_id hom_inv_id).symm
theorem eq_inv_of_inv_hom_id {f : X ⟶ Y} [IsIso f] {g : Y ⟶ X} (inv_hom_id : g ≫ f = 𝟙 Y) :
g = inv f :=
(inv_eq_of_inv_hom_id inv_hom_id).symm
instance id (X : C) : IsIso (𝟙 X) := ⟨⟨𝟙 X, by simp⟩⟩
variable {f : X ⟶ Y} {h : Y ⟶ Z}
instance inv_isIso [IsIso f] : IsIso (inv f) :=
(asIso f).isIso_inv
/- The following instance has lower priority for the following reason:
Suppose we are given `f : X ≅ Y` with `X Y : Type u`.
Without the lower priority, typeclass inference cannot deduce `IsIso f.hom`
because `f.hom` is defeq to `(fun x ↦ x) ≫ f.hom`, triggering a loop. -/
instance (priority := 900) comp_isIso [IsIso f] [IsIso h] : IsIso (f ≫ h) :=
(asIso f ≪≫ asIso h).isIso_hom
/--
The composition of isomorphisms is an isomorphism. Here the arguments of type `IsIso` are
explicit, to make this easier to use with the `refine` tactic, for instance.
-/
lemma comp_isIso' (_ : IsIso f) (_ : IsIso h) : IsIso (f ≫ h) := inferInstance
@[simp]
theorem inv_id : inv (𝟙 X) = 𝟙 X := by
apply inv_eq_of_hom_inv_id
simp
@[simp, reassoc]
theorem inv_comp [IsIso f] [IsIso h] : inv (f ≫ h) = inv h ≫ inv f := by
apply inv_eq_of_hom_inv_id
simp
@[simp]
theorem inv_inv [IsIso f] : inv (inv f) = f := by
apply inv_eq_of_hom_inv_id
simp
@[simp]
theorem Iso.inv_inv (f : X ≅ Y) : inv f.inv = f.hom := by
apply inv_eq_of_hom_inv_id
simp
@[simp]
theorem Iso.inv_hom (f : X ≅ Y) : inv f.hom = f.inv := by
apply inv_eq_of_hom_inv_id
simp
@[simp]
theorem inv_comp_eq (α : X ⟶ Y) [IsIso α] {f : X ⟶ Z} {g : Y ⟶ Z} : inv α ≫ f = g ↔ f = α ≫ g :=
(asIso α).inv_comp_eq
@[simp]
theorem eq_inv_comp (α : X ⟶ Y) [IsIso α] {f : X ⟶ Z} {g : Y ⟶ Z} : g = inv α ≫ f ↔ α ≫ g = f :=
(asIso α).eq_inv_comp
@[simp]
theorem comp_inv_eq (α : X ⟶ Y) [IsIso α] {f : Z ⟶ Y} {g : Z ⟶ X} : f ≫ inv α = g ↔ f = g ≫ α :=
(asIso α).comp_inv_eq
@[simp]
theorem eq_comp_inv (α : X ⟶ Y) [IsIso α] {f : Z ⟶ Y} {g : Z ⟶ X} : g = f ≫ inv α ↔ g ≫ α = f :=
(asIso α).eq_comp_inv
theorem of_isIso_comp_left {X Y Z : C} (f : X ⟶ Y) (g : Y ⟶ Z) [IsIso f] [IsIso (f ≫ g)] :
IsIso g := by
rw [← id_comp g, ← inv_hom_id f, assoc]
infer_instance
theorem of_isIso_comp_right {X Y Z : C} (f : X ⟶ Y) (g : Y ⟶ Z) [IsIso g] [IsIso (f ≫ g)] :
IsIso f := by
rw [← comp_id f, ← hom_inv_id g, ← assoc]
infer_instance
theorem of_isIso_fac_left {X Y Z : C} {f : X ⟶ Y} {g : Y ⟶ Z} {h : X ⟶ Z} [IsIso f]
[hh : IsIso h] (w : f ≫ g = h) : IsIso g := by
rw [← w] at hh
exact of_isIso_comp_left f g
theorem of_isIso_fac_right {X Y Z : C} {f : X ⟶ Y} {g : Y ⟶ Z} {h : X ⟶ Z} [IsIso g]
[hh : IsIso h] (w : f ≫ g = h) : IsIso f := by
rw [← w] at hh
exact of_isIso_comp_right f g
end IsIso
@[simp]
theorem isIso_comp_left_iff {X Y Z : C} (f : X ⟶ Y) (g : Y ⟶ Z) [IsIso f] :
IsIso (f ≫ g) ↔ IsIso g :=
⟨fun _ ↦ IsIso.of_isIso_comp_left f g, fun _ ↦ inferInstance⟩
@[simp]
theorem isIso_comp_right_iff {X Y Z : C} (f : X ⟶ Y) (g : Y ⟶ Z) [IsIso g] :
IsIso (f ≫ g) ↔ IsIso f :=
⟨fun _ ↦ IsIso.of_isIso_comp_right f g, fun _ ↦ inferInstance⟩
open IsIso
theorem eq_of_inv_eq_inv {f g : X ⟶ Y} [IsIso f] [IsIso g] (p : inv f = inv g) : f = g := by
apply (cancel_epi (inv f)).1
rw [inv_hom_id, p, inv_hom_id]
theorem IsIso.inv_eq_inv {f g : X ⟶ Y} [IsIso f] [IsIso g] : inv f = inv g ↔ f = g :=
Iso.inv_eq_inv (asIso f) (asIso g)
theorem hom_comp_eq_id (g : X ⟶ Y) [IsIso g] {f : Y ⟶ X} : g ≫ f = 𝟙 X ↔ f = inv g :=
(asIso g).hom_comp_eq_id
theorem comp_hom_eq_id (g : X ⟶ Y) [IsIso g] {f : Y ⟶ X} : f ≫ g = 𝟙 Y ↔ f = inv g :=
(asIso g).comp_hom_eq_id
theorem inv_comp_eq_id (g : X ⟶ Y) [IsIso g] {f : X ⟶ Y} : inv g ≫ f = 𝟙 Y ↔ f = g :=
(asIso g).inv_comp_eq_id
theorem comp_inv_eq_id (g : X ⟶ Y) [IsIso g] {f : X ⟶ Y} : f ≫ inv g = 𝟙 X ↔ f = g :=
(asIso g).comp_inv_eq_id
theorem isIso_of_hom_comp_eq_id (g : X ⟶ Y) [IsIso g] {f : Y ⟶ X} (h : g ≫ f = 𝟙 X) : IsIso f := by
rw [(hom_comp_eq_id _).mp h]
infer_instance
theorem isIso_of_comp_hom_eq_id (g : X ⟶ Y) [IsIso g] {f : Y ⟶ X} (h : f ≫ g = 𝟙 Y) : IsIso f := by
rw [(comp_hom_eq_id _).mp h]
infer_instance
namespace Iso
@[aesop apply safe (rule_sets := [CategoryTheory])]
theorem inv_ext {f : X ≅ Y} {g : Y ⟶ X} (hom_inv_id : f.hom ≫ g = 𝟙 X) : f.inv = g :=
((hom_comp_eq_id f).1 hom_inv_id).symm
@[aesop apply safe (rule_sets := [CategoryTheory])]
theorem inv_ext' {f : X ≅ Y} {g : Y ⟶ X} (hom_inv_id : f.hom ≫ g = 𝟙 X) : g = f.inv :=
(hom_comp_eq_id f).1 hom_inv_id
/-!
All these cancellation lemmas can be solved by `simp [cancel_mono]` (or `simp [cancel_epi]`),
but with the current design `cancel_mono` is not a good `simp` lemma,
because it generates a typeclass search.
When we can see syntactically that a morphism is a `mono` or an `epi`
because it came from an isomorphism, it's fine to do the cancellation via `simp`.
In the longer term, it might be worth exploring making `mono` and `epi` structures,
rather than typeclasses, with coercions back to `X ⟶ Y`.
Presumably we could write `X ↪ Y` and `X ↠ Y`.
-/
@[simp]
theorem cancel_iso_hom_left {X Y Z : C} (f : X ≅ Y) (g g' : Y ⟶ Z) :
f.hom ≫ g = f.hom ≫ g' ↔ g = g' := by
simp only [cancel_epi]
@[simp]
theorem cancel_iso_inv_left {X Y Z : C} (f : Y ≅ X) (g g' : Y ⟶ Z) :
f.inv ≫ g = f.inv ≫ g' ↔ g = g' := by
simp only [cancel_epi]
@[simp]
theorem cancel_iso_hom_right {X Y Z : C} (f f' : X ⟶ Y) (g : Y ≅ Z) :
f ≫ g.hom = f' ≫ g.hom ↔ f = f' := by
simp only [cancel_mono]
@[simp]
theorem cancel_iso_inv_right {X Y Z : C} (f f' : X ⟶ Y) (g : Z ≅ Y) :
f ≫ g.inv = f' ≫ g.inv ↔ f = f' := by
simp only [cancel_mono]
/-
Unfortunately cancelling an isomorphism from the right of a chain of compositions is awkward.
We would need separate lemmas for each chain length (worse: for each pair of chain lengths).
We provide two more lemmas, for case of three morphisms, because this actually comes up in practice,
but then stop.
-/
@[simp]
theorem cancel_iso_hom_right_assoc {W X X' Y Z : C} (f : W ⟶ X) (g : X ⟶ Y) (f' : W ⟶ X')
(g' : X' ⟶ Y) (h : Y ≅ Z) : f ≫ g ≫ h.hom = f' ≫ g' ≫ h.hom ↔ f ≫ g = f' ≫ g' := by
simp only [← Category.assoc, cancel_mono]
@[simp]
theorem cancel_iso_inv_right_assoc {W X X' Y Z : C} (f : W ⟶ X) (g : X ⟶ Y) (f' : W ⟶ X')
(g' : X' ⟶ Y) (h : Z ≅ Y) : f ≫ g ≫ h.inv = f' ≫ g' ≫ h.inv ↔ f ≫ g = f' ≫ g' := by
simp only [← Category.assoc, cancel_mono]
section
variable {D : Type*} [Category D] {X Y : C} (e : X ≅ Y)
@[reassoc (attr := simp), grind =]
lemma map_hom_inv_id (F : C ⥤ D) :
F.map e.hom ≫ F.map e.inv = 𝟙 _ := by grind
@[reassoc (attr := simp), grind =]
lemma map_inv_hom_id (F : C ⥤ D) :
F.map e.inv ≫ F.map e.hom = 𝟙 _ := by grind
end
end Iso
namespace Functor
universe u₁ v₁ u₂ v₂
variable {D : Type u₂}
variable [Category.{v₂} D]
/-- A functor `F : C ⥤ D` sends isomorphisms `i : X ≅ Y` to isomorphisms `F.obj X ≅ F.obj Y` -/
@[simps]
def mapIso (F : C ⥤ D) {X Y : C} (i : X ≅ Y) : F.obj X ≅ F.obj Y where
hom := F.map i.hom
inv := F.map i.inv
@[simp]
theorem mapIso_symm (F : C ⥤ D) {X Y : C} (i : X ≅ Y) : F.mapIso i.symm = (F.mapIso i).symm :=
rfl
@[simp]
theorem mapIso_trans (F : C ⥤ D) {X Y Z : C} (i : X ≅ Y) (j : Y ≅ Z) :
F.mapIso (i ≪≫ j) = F.mapIso i ≪≫ F.mapIso j := by
ext; apply Functor.map_comp
@[simp]
theorem mapIso_refl (F : C ⥤ D) (X : C) : F.mapIso (Iso.refl X) = Iso.refl (F.obj X) :=
Iso.ext <| F.map_id X
instance map_isIso (F : C ⥤ D) (f : X ⟶ Y) [IsIso f] : IsIso (F.map f) :=
(F.mapIso (asIso f)).isIso_hom
@[simp]
theorem map_inv (F : C ⥤ D) {X Y : C} (f : X ⟶ Y) [IsIso f] : F.map (inv f) = inv (F.map f) := by
apply eq_inv_of_hom_inv_id
simp [← F.map_comp]
@[reassoc]
theorem map_hom_inv (F : C ⥤ D) {X Y : C} (f : X ⟶ Y) [IsIso f] :
F.map f ≫ F.map (inv f) = 𝟙 (F.obj X) := by simp
@[reassoc]
theorem map_inv_hom (F : C ⥤ D) {X Y : C} (f : X ⟶ Y) [IsIso f] :
F.map (inv f) ≫ F.map f = 𝟙 (F.obj Y) := by simp
end Functor
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/NatIso.lean | import Mathlib.CategoryTheory.Functor.Category
import Mathlib.CategoryTheory.Iso
/-!
# Natural isomorphisms
For the most part, natural isomorphisms are just another sort of isomorphism.
We provide some special support for extracting components:
* if `α : F ≅ G`, then `α.app X : F.obj X ≅ G.obj X`,
and building natural isomorphisms from components:
*
```
NatIso.ofComponents
(app : ∀ X : C, F.obj X ≅ G.obj X)
(naturality : ∀ {X Y : C} (f : X ⟶ Y), F.map f ≫ (app Y).hom = (app X).hom ≫ G.map f) :
F ≅ G
```
only needing to check naturality in one direction.
## Implementation
Note that `NatIso` is a namespace without a corresponding definition;
we put some declarations that are specifically about natural isomorphisms in the `Iso`
namespace so that they are available using dot notation.
-/
set_option mathlib.tactic.category.grind true
-- declare the `v`'s first; see `CategoryTheory.Category` for an explanation
universe v₁ v₂ v₃ v₄ u₁ u₂ u₃ u₄
namespace CategoryTheory
open NatTrans
variable {C : Type u₁} [Category.{v₁} C] {D : Type u₂} [Category.{v₂} D] {E : Type u₃}
[Category.{v₃} E] {E' : Type u₄} [Category.{v₄} E']
namespace Iso
/-- The application of a natural isomorphism to an object. We put this definition in a different
namespace, so that we can use `α.app` -/
@[simps (attr := grind =)]
def app {F G : C ⥤ D} (α : F ≅ G) (X : C) :
F.obj X ≅ G.obj X where
hom := α.hom.app X
inv := α.inv.app X
@[reassoc (attr := simp), grind =]
theorem hom_inv_id_app {F G : C ⥤ D} (α : F ≅ G) (X : C) :
α.hom.app X ≫ α.inv.app X = 𝟙 (F.obj X) := by cat_disch
@[reassoc (attr := simp), grind =]
theorem inv_hom_id_app {F G : C ⥤ D} (α : F ≅ G) (X : C) :
α.inv.app X ≫ α.hom.app X = 𝟙 (G.obj X) := by cat_disch
@[reassoc (attr := simp)]
lemma hom_inv_id_app_app {F G : C ⥤ D ⥤ E} (e : F ≅ G) (X₁ : C) (X₂ : D) :
(e.hom.app X₁).app X₂ ≫ (e.inv.app X₁).app X₂ = 𝟙 _ := by cat_disch
@[reassoc (attr := simp)]
lemma inv_hom_id_app_app {F G : C ⥤ D ⥤ E} (e : F ≅ G) (X₁ : C) (X₂ : D) :
(e.inv.app X₁).app X₂ ≫ (e.hom.app X₁).app X₂ = 𝟙 _ := by cat_disch
@[reassoc (attr := simp)]
lemma hom_inv_id_app_app_app {F G : C ⥤ D ⥤ E ⥤ E'} (e : F ≅ G)
(X₁ : C) (X₂ : D) (X₃ : E) :
((e.hom.app X₁).app X₂).app X₃ ≫ ((e.inv.app X₁).app X₂).app X₃ = 𝟙 _ := by cat_disch
@[reassoc (attr := simp)]
lemma inv_hom_id_app_app_app {F G : C ⥤ D ⥤ E ⥤ E'} (e : F ≅ G)
(X₁ : C) (X₂ : D) (X₃ : E) :
((e.inv.app X₁).app X₂).app X₃ ≫ ((e.hom.app X₁).app X₂).app X₃ = 𝟙 _ := by cat_disch
end Iso
namespace NatIso
open CategoryTheory.Category CategoryTheory.Functor
@[simp]
theorem trans_app {F G H : C ⥤ D} (α : F ≅ G) (β : G ≅ H) (X : C) :
(α ≪≫ β).app X = α.app X ≪≫ β.app X :=
rfl
variable {F G : C ⥤ D}
instance hom_app_isIso (α : F ≅ G) (X : C) : IsIso (α.hom.app X) :=
⟨⟨α.inv.app X, ⟨by grind, by grind⟩⟩⟩
instance inv_app_isIso (α : F ≅ G) (X : C) : IsIso (α.inv.app X) :=
⟨⟨α.hom.app X, ⟨by grind, by grind⟩⟩⟩
section
/-!
Unfortunately we need a separate set of cancellation lemmas for components of natural isomorphisms,
because the `simp` normal form is `α.hom.app X`, rather than `α.app.hom X`.
(With the latter, the morphism would be visibly part of an isomorphism, so general lemmas about
isomorphisms would apply.)
In the future, we should consider a redesign that changes this simp norm form,
but for now it breaks too many proofs.
-/
variable (α : F ≅ G)
@[simp]
theorem cancel_natIso_hom_left {X : C} {Z : D} (g g' : G.obj X ⟶ Z) :
α.hom.app X ≫ g = α.hom.app X ≫ g' ↔ g = g' := by simp only [cancel_epi, refl]
@[simp]
theorem cancel_natIso_inv_left {X : C} {Z : D} (g g' : F.obj X ⟶ Z) :
α.inv.app X ≫ g = α.inv.app X ≫ g' ↔ g = g' := by simp only [cancel_epi, refl]
@[simp]
theorem cancel_natIso_hom_right {X : D} {Y : C} (f f' : X ⟶ F.obj Y) :
f ≫ α.hom.app Y = f' ≫ α.hom.app Y ↔ f = f' := by simp only [cancel_mono, refl]
@[simp]
theorem cancel_natIso_inv_right {X : D} {Y : C} (f f' : X ⟶ G.obj Y) :
f ≫ α.inv.app Y = f' ≫ α.inv.app Y ↔ f = f' := by simp only [cancel_mono, refl]
@[simp]
theorem cancel_natIso_hom_right_assoc {W X X' : D} {Y : C} (f : W ⟶ X) (g : X ⟶ F.obj Y)
(f' : W ⟶ X') (g' : X' ⟶ F.obj Y) :
f ≫ g ≫ α.hom.app Y = f' ≫ g' ≫ α.hom.app Y ↔ f ≫ g = f' ≫ g' := by
simp only [← Category.assoc, cancel_mono, refl]
@[simp]
theorem cancel_natIso_inv_right_assoc {W X X' : D} {Y : C} (f : W ⟶ X) (g : X ⟶ G.obj Y)
(f' : W ⟶ X') (g' : X' ⟶ G.obj Y) :
f ≫ g ≫ α.inv.app Y = f' ≫ g' ≫ α.inv.app Y ↔ f ≫ g = f' ≫ g' := by
simp only [← Category.assoc, cancel_mono, refl]
attribute [grind ←=] CategoryTheory.IsIso.inv_eq_of_hom_inv_id
@[simp]
theorem inv_inv_app {F G : C ⥤ D} (e : F ≅ G) (X : C) : inv (e.inv.app X) = e.hom.app X := by
cat_disch
end
variable {X Y : C}
@[reassoc]
theorem naturality_1 (α : F ≅ G) (f : X ⟶ Y) : α.inv.app X ≫ F.map f ≫ α.hom.app Y = G.map f := by
simp
@[reassoc]
theorem naturality_2 (α : F ≅ G) (f : X ⟶ Y) : α.hom.app X ≫ G.map f ≫ α.inv.app Y = F.map f := by
simp
@[reassoc]
theorem naturality_1' (α : F ⟶ G) (f : X ⟶ Y) {_ : IsIso (α.app X)} :
inv (α.app X) ≫ F.map f ≫ α.app Y = G.map f := by simp
@[reassoc (attr := simp)]
theorem naturality_2' (α : F ⟶ G) (f : X ⟶ Y) {_ : IsIso (α.app Y)} :
α.app X ≫ G.map f ≫ inv (α.app Y) = F.map f := by cat_disch
/-- The components of a natural isomorphism are isomorphisms.
-/
instance isIso_app_of_isIso (α : F ⟶ G) [IsIso α] (X) : IsIso (α.app X) :=
⟨⟨(inv α).app X, ⟨by grind, by grind⟩⟩⟩
@[simp]
theorem isIso_inv_app (α : F ⟶ G) {_ : IsIso α} (X) : (inv α).app X = inv (α.app X) := by cat_disch
@[simp]
theorem inv_map_inv_app (F : C ⥤ D ⥤ E) {X Y : C} (e : X ≅ Y) (Z : D) :
inv ((F.map e.inv).app Z) = (F.map e.hom).app Z := by cat_disch
/-- Construct a natural isomorphism between functors by giving object level isomorphisms,
and checking naturality only in the forward direction.
-/
@[simps (attr := grind =)]
def ofComponents (app : ∀ X : C, F.obj X ≅ G.obj X)
(naturality : ∀ {X Y : C} (f : X ⟶ Y),
F.map f ≫ (app Y).hom = (app X).hom ≫ G.map f := by cat_disch) :
F ≅ G where
hom := { app := fun X => (app X).hom }
inv :=
{ app := fun X => (app X).inv,
naturality := fun X Y f => by
have h := congr_arg (fun f => (app X).inv ≫ f ≫ (app Y).inv) (naturality f).symm
simp only [Iso.inv_hom_id_assoc, Iso.hom_inv_id, assoc, comp_id] at h
exact h }
@[simp]
theorem ofComponents.app (app' : ∀ X : C, F.obj X ≅ G.obj X) (naturality) (X) :
(ofComponents app' naturality).app X = app' X := by cat_disch
-- Making this an instance would cause a typeclass inference loop with `isIso_app_of_isIso`.
/-- A natural transformation is an isomorphism if all its components are isomorphisms.
-/
theorem isIso_of_isIso_app (α : F ⟶ G) [∀ X : C, IsIso (α.app X)] : IsIso α :=
(ofComponents (fun X => asIso (α.app X)) (by simp)).isIso_hom
/-- Horizontal composition of natural isomorphisms. -/
@[simps]
def hcomp {F G : C ⥤ D} {H I : D ⥤ E} (α : F ≅ G) (β : H ≅ I) : F ⋙ H ≅ G ⋙ I where
hom := α.hom ◫ β.hom
inv := α.inv ◫ β.inv
theorem isIso_map_iff {F₁ F₂ : C ⥤ D} (e : F₁ ≅ F₂) {X Y : C} (f : X ⟶ Y) :
IsIso (F₁.map f) ↔ IsIso (F₂.map f) := by
revert F₁ F₂
suffices ∀ {F₁ F₂ : C ⥤ D} (_ : F₁ ≅ F₂) (_ : IsIso (F₁.map f)), IsIso (F₂.map f) from
fun F₁ F₂ e => ⟨this e, this e.symm⟩
intro F₁ F₂ e hf
exact IsIso.mk ⟨e.inv.app Y ≫ inv (F₁.map f) ≫ e.hom.app X, by cat_disch⟩
end NatIso
lemma NatTrans.isIso_iff_isIso_app {F G : C ⥤ D} (τ : F ⟶ G) :
IsIso τ ↔ ∀ X, IsIso (τ.app X) :=
⟨fun _ ↦ inferInstance, fun _ ↦ NatIso.isIso_of_isIso_app _⟩
namespace Functor
variable (F : C ⥤ D) (obj : C → D) (e : ∀ X, F.obj X ≅ obj X)
/-- Constructor for a functor that is isomorphic to a given functor `F : C ⥤ D`,
while being definitionally equal on objects to a given map `obj : C → D`
such that for all `X : C`, we have an isomorphism `F.obj X ≅ obj X`. -/
@[simps obj]
def copyObj : C ⥤ D where
obj := obj
map f := (e _).inv ≫ F.map f ≫ (e _).hom
/-- The functor constructed with `copyObj` is isomorphic to the given functor. -/
@[simps!]
def isoCopyObj : F ≅ F.copyObj obj e :=
NatIso.ofComponents e (by simp [Functor.copyObj])
end Functor
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Equivalence.lean | import Mathlib.CategoryTheory.Functor.FullyFaithful
import Mathlib.CategoryTheory.ObjectProperty.FullSubcategory
import Mathlib.CategoryTheory.Whiskering
import Mathlib.CategoryTheory.EssentialImage
import Mathlib.Tactic.CategoryTheory.Slice
/-!
# Equivalence of categories
An equivalence of categories `C` and `D` is a pair of functors `F : C ⥤ D` and `G : D ⥤ C` such
that `η : 𝟭 C ≅ F ⋙ G` and `ε : G ⋙ F ≅ 𝟭 D`. In many situations, equivalences are a better
notion of "sameness" of categories than the stricter isomorphism of categories.
Recall that one way to express that two functors `F : C ⥤ D` and `G : D ⥤ C` are adjoint is using
two natural transformations `η : 𝟭 C ⟶ F ⋙ G` and `ε : G ⋙ F ⟶ 𝟭 D`, called the unit and the
counit, such that the compositions `F ⟶ FGF ⟶ F` and `G ⟶ GFG ⟶ G` are the identity. Unfortunately,
it is not the case that the natural isomorphisms `η` and `ε` in the definition of an equivalence
automatically give an adjunction. However, it is true that
* if one of the two compositions is the identity, then so is the other, and
* given an equivalence of categories, it is always possible to refine `η` in such a way that the
identities are satisfied.
For this reason, in mathlib we define an equivalence to be a "half-adjoint equivalence", which is
a tuple `(F, G, η, ε)` as in the first paragraph such that the composite `F ⟶ FGF ⟶ F` is the
identity. By the remark above, this already implies that the tuple is an "adjoint equivalence",
i.e., that the composite `G ⟶ GFG ⟶ G` is also the identity.
We also define essentially surjective functors and show that a functor is an equivalence if and only
if it is full, faithful and essentially surjective.
## Main definitions
* `Equivalence`: bundled (half-)adjoint equivalences of categories
* `Functor.EssSurj`: type class on a functor `F` containing the data of the preimages
and the isomorphisms `F.obj (preimage d) ≅ d`.
* `Functor.IsEquivalence`: type class on a functor `F` which is full, faithful and
essentially surjective.
## Main results
* `Equivalence.mk`: upgrade an equivalence to a (half-)adjoint equivalence
* `isEquivalence_iff_of_iso`: when `F` and `G` are isomorphic functors,
`F` is an equivalence iff `G` is.
* `Functor.asEquivalenceFunctor`: construction of an equivalence of categories from
a functor `F` which satisfies the property `F.IsEquivalence` (i.e. `F` is full, faithful
and essentially surjective).
## Notation
We write `C ≌ D` (`\backcong`, not to be confused with `≅`/`\cong`) for a bundled equivalence.
-/
namespace CategoryTheory
open CategoryTheory.Functor NatIso Category
-- declare the `v`'s first; see `CategoryTheory.Category` for an explanation
universe v₁ v₂ v₃ u₁ u₂ u₃
/-- An equivalence of categories.
We define an equivalence between `C` and `D`, with notation `C ≌ D`, as a half-adjoint equivalence:
a pair of functors `F : C ⥤ D` and `G : D ⥤ C` with a unit `η : 𝟭 C ≅ F ⋙ G` and counit
`ε : G ⋙ F ≅ 𝟭 D`, such that the natural isomorphisms `η` and `ε` satisfy the triangle law for
`F`: namely, `Fη ≫ εF = 𝟙 F`. Or, in other words, the composite `F` ⟶ `F ⋙ G ⋙ F` ⟶ `F` is the
identity.
In `unit_inverse_comp`, we show that this is sufficient to establish a full adjoint
equivalence. I.e., the composite `G` ⟶ `G ⋙ F ⋙ G` ⟶ `G` is also the identity.
The triangle equation `functor_unitIso_comp` is written as a family of equalities between
morphisms. It is more complicated if we write it as an equality of natural transformations, because
then we would either have to insert natural transformations like `F ⟶ F𝟭` or abuse defeq. -/
@[ext, stacks 001J]
structure Equivalence (C : Type u₁) (D : Type u₂) [Category.{v₁} C] [Category.{v₂} D] where mk' ::
/-- The forwards direction of an equivalence. -/
functor : C ⥤ D
/-- The backwards direction of an equivalence. -/
inverse : D ⥤ C
/-- The composition `functor ⋙ inverse` is isomorphic to the identity. -/
unitIso : 𝟭 C ≅ functor ⋙ inverse
/-- The composition `inverse ⋙ functor` is isomorphic to the identity. -/
counitIso : inverse ⋙ functor ≅ 𝟭 D
/-- The triangle law for the forwards direction of an equivalence: the unit and counit compose
to the identity when whiskered along the forwards direction.
We state this as a family of equalities among morphisms instead of an equality of natural
transformations to avoid abusing defeq or inserting natural transformations like `F ⟶ F𝟭`. -/
functor_unitIso_comp :
∀ X : C, functor.map (unitIso.hom.app X) ≫ counitIso.hom.app (functor.obj X) =
𝟙 (functor.obj X) := by cat_disch
@[inherit_doc Equivalence]
infixr:10 " ≌ " => Equivalence
variable {C : Type u₁} [Category.{v₁} C] {D : Type u₂} [Category.{v₂} D]
namespace Equivalence
/-- The unit of an equivalence of categories. -/
abbrev unit (e : C ≌ D) : 𝟭 C ⟶ e.functor ⋙ e.inverse :=
e.unitIso.hom
/-- The counit of an equivalence of categories. -/
abbrev counit (e : C ≌ D) : e.inverse ⋙ e.functor ⟶ 𝟭 D :=
e.counitIso.hom
/-- The inverse of the unit of an equivalence of categories. -/
abbrev unitInv (e : C ≌ D) : e.functor ⋙ e.inverse ⟶ 𝟭 C :=
e.unitIso.inv
/-- The inverse of the counit of an equivalence of categories. -/
abbrev counitInv (e : C ≌ D) : 𝟭 D ⟶ e.inverse ⋙ e.functor :=
e.counitIso.inv
section CategoryStructure
instance : Category (C ≌ D) where
Hom e f := e.functor ⟶ f.functor
id e := 𝟙 e.functor
comp {a b c} f g := (f ≫ g : a.functor ⟶ _)
/-- Promote a natural transformation `e.functor ⟶ f.functor` to a morphism in `C ≌ D`. -/
def mkHom {e f : C ≌ D} (η : e.functor ⟶ f.functor) : e ⟶ f := η
/-- Recover a natural transformation between `e.functor` and `f.functor` from the data of
a morphism `e ⟶ f`. -/
def asNatTrans {e f : C ≌ D} (η : e ⟶ f) : e.functor ⟶ f.functor := η
@[ext]
lemma hom_ext {e f : C ≌ D} {α β : e ⟶ f} (h : asNatTrans α = asNatTrans β) : α = β := h
@[simp]
lemma mkHom_asNatTrans {e f : C ≌ D} (η : e.functor ⟶ f.functor) :
mkHom (asNatTrans η) = η :=
rfl
@[simp]
lemma asNatTrans_mkHom {e f : C ≌ D} (η : e ⟶ f) :
asNatTrans (mkHom η) = η :=
rfl
@[simp]
lemma id_asNatTrans {e : C ≌ D} : asNatTrans (𝟙 e) = 𝟙 _ := rfl
@[simp, reassoc]
lemma comp_asNatTrans {e f g : C ≌ D} (α : e ⟶ f) (β : f ⟶ g) :
asNatTrans (α ≫ β) = asNatTrans α ≫ asNatTrans β :=
rfl
@[simp]
lemma mkHom_id_functor {e : C ≌ D} : mkHom (𝟙 e.functor) = 𝟙 e := rfl
@[simp, reassoc]
lemma mkHom_comp {e f g : C ≌ D} (α : e.functor ⟶ f.functor) (β : f.functor ⟶ g.functor) :
mkHom (α ≫ β) = mkHom α ≫ mkHom β :=
rfl
/-- Construct an isomorphism in `C ≌ D` from a natural isomorphism between the functors
of the equivalences. -/
@[simps]
def mkIso {e f : C ≌ D} (η : e.functor ≅ f.functor) : e ≅ f where
hom := mkHom η.hom
inv := mkHom η.inv
variable (C D) in
/-- The `functor` functor that sends an equivalence of categories to its functor. -/
@[simps!]
def functorFunctor : (C ≌ D) ⥤ C ⥤ D where
obj f := f.functor
map α := asNatTrans α
end CategoryStructure
/- While these abbreviations are convenient, they also cause some trouble,
preventing structure projections from unfolding. -/
@[simp]
theorem Equivalence_mk'_unit (functor inverse unit_iso counit_iso f) :
(⟨functor, inverse, unit_iso, counit_iso, f⟩ : C ≌ D).unit = unit_iso.hom :=
rfl
@[simp]
theorem Equivalence_mk'_counit (functor inverse unit_iso counit_iso f) :
(⟨functor, inverse, unit_iso, counit_iso, f⟩ : C ≌ D).counit = counit_iso.hom :=
rfl
@[simp]
theorem Equivalence_mk'_unitInv (functor inverse unit_iso counit_iso f) :
(⟨functor, inverse, unit_iso, counit_iso, f⟩ : C ≌ D).unitInv = unit_iso.inv :=
rfl
@[simp]
theorem Equivalence_mk'_counitInv (functor inverse unit_iso counit_iso f) :
(⟨functor, inverse, unit_iso, counit_iso, f⟩ : C ≌ D).counitInv = counit_iso.inv :=
rfl
@[reassoc]
theorem counit_naturality (e : C ≌ D) {X Y : D} (f : X ⟶ Y) :
e.functor.map (e.inverse.map f) ≫ e.counit.app Y = e.counit.app X ≫ f :=
e.counit.naturality f
@[reassoc]
theorem unit_naturality (e : C ≌ D) {X Y : C} (f : X ⟶ Y) :
e.unit.app X ≫ e.inverse.map (e.functor.map f) = f ≫ e.unit.app Y :=
(e.unit.naturality f).symm
@[reassoc]
theorem counitInv_naturality (e : C ≌ D) {X Y : D} (f : X ⟶ Y) :
e.counitInv.app X ≫ e.functor.map (e.inverse.map f) = f ≫ e.counitInv.app Y :=
(e.counitInv.naturality f).symm
@[reassoc]
theorem unitInv_naturality (e : C ≌ D) {X Y : C} (f : X ⟶ Y) :
e.inverse.map (e.functor.map f) ≫ e.unitInv.app Y = e.unitInv.app X ≫ f :=
e.unitInv.naturality f
@[reassoc (attr := simp)]
theorem functor_unit_comp (e : C ≌ D) (X : C) :
e.functor.map (e.unit.app X) ≫ e.counit.app (e.functor.obj X) = 𝟙 (e.functor.obj X) :=
e.functor_unitIso_comp X
@[reassoc (attr := simp)]
theorem counitInv_functor_comp (e : C ≌ D) (X : C) :
e.counitInv.app (e.functor.obj X) ≫ e.functor.map (e.unitInv.app X) = 𝟙 (e.functor.obj X) := by
simpa using Iso.inv_eq_inv
(e.functor.mapIso (e.unitIso.app X) ≪≫ e.counitIso.app (e.functor.obj X)) (Iso.refl _)
theorem counitInv_app_functor (e : C ≌ D) (X : C) :
e.counitInv.app (e.functor.obj X) = e.functor.map (e.unit.app X) := by
symm
simp only [id_obj, comp_obj, counitInv]
rw [← Iso.app_inv, ← Iso.comp_hom_eq_id (e.counitIso.app _), Iso.app_hom, functor_unit_comp]
rfl
theorem counit_app_functor (e : C ≌ D) (X : C) :
e.counit.app (e.functor.obj X) = e.functor.map (e.unitInv.app X) := by
simpa using Iso.hom_comp_eq_id (e.functor.mapIso (e.unitIso.app X)) (f := e.counit.app _)
/-- The other triangle equality. The proof follows the following proof in Globular:
http://globular.science/1905.001 -/
@[reassoc (attr := simp)]
theorem unit_inverse_comp (e : C ≌ D) (Y : D) :
e.unit.app (e.inverse.obj Y) ≫ e.inverse.map (e.counit.app Y) = 𝟙 (e.inverse.obj Y) := by
rw [← id_comp (e.inverse.map _), ← map_id e.inverse, ← counitInv_functor_comp, map_comp]
dsimp
rw [← Iso.hom_inv_id_assoc (e.unitIso.app _) (e.inverse.map (e.functor.map _)), Iso.app_hom,
Iso.app_inv]
slice_lhs 2 3 => rw [← e.unit_naturality]
slice_lhs 1 2 => rw [← e.unit_naturality]
slice_lhs 4 4 =>
rw [← Iso.hom_inv_id_assoc (e.inverse.mapIso (e.counitIso.app _)) (e.unitInv.app _)]
slice_lhs 3 4 =>
dsimp only [Functor.mapIso_hom, Iso.app_hom]
rw [← map_comp e.inverse, e.counit_naturality, e.counitIso.hom_inv_id_app]
dsimp only [Functor.comp_obj]
rw [map_id]
dsimp only [comp_obj, id_obj]
rw [id_comp]
slice_lhs 2 3 =>
dsimp only [Functor.mapIso_inv, Iso.app_inv]
rw [← map_comp e.inverse, ← e.counitInv_naturality, map_comp]
slice_lhs 3 4 => rw [e.unitInv_naturality]
slice_lhs 4 5 =>
rw [← map_comp e.inverse, ← map_comp e.functor, e.unitIso.hom_inv_id_app]
dsimp only [Functor.id_obj]
rw [map_id, map_id]
dsimp only [comp_obj, id_obj]
rw [id_comp]
slice_lhs 3 4 => rw [← e.unitInv_naturality]
slice_lhs 2 3 =>
rw [← map_comp e.inverse, e.counitInv_naturality, e.counitIso.hom_inv_id_app]
dsimp only [Functor.comp_obj]
simp
@[reassoc (attr := simp)]
theorem inverse_counitInv_comp (e : C ≌ D) (Y : D) :
e.inverse.map (e.counitInv.app Y) ≫ e.unitInv.app (e.inverse.obj Y) = 𝟙 (e.inverse.obj Y) := by
simpa using Iso.inv_eq_inv
(e.unitIso.app (e.inverse.obj Y) ≪≫ e.inverse.mapIso (e.counitIso.app Y)) (Iso.refl _)
theorem unit_app_inverse (e : C ≌ D) (Y : D) :
e.unit.app (e.inverse.obj Y) = e.inverse.map (e.counitInv.app Y) := by
simpa using Iso.comp_hom_eq_id (e.inverse.mapIso (e.counitIso.app Y)) (f := e.unit.app _)
theorem unitInv_app_inverse (e : C ≌ D) (Y : D) :
e.unitInv.app (e.inverse.obj Y) = e.inverse.map (e.counit.app Y) := by
rw [← Iso.app_inv, ← Iso.app_hom, ← mapIso_hom, Eq.comm, ← Iso.hom_eq_inv]
simpa using unit_app_inverse e Y
@[reassoc, simp]
theorem fun_inv_map (e : C ≌ D) (X Y : D) (f : X ⟶ Y) :
e.functor.map (e.inverse.map f) = e.counit.app X ≫ f ≫ e.counitInv.app Y :=
(NatIso.naturality_2 e.counitIso f).symm
@[reassoc, simp]
theorem inv_fun_map (e : C ≌ D) (X Y : C) (f : X ⟶ Y) :
e.inverse.map (e.functor.map f) = e.unitInv.app X ≫ f ≫ e.unit.app Y :=
(NatIso.naturality_1 e.unitIso f).symm
section
-- In this section we convert an arbitrary equivalence to a half-adjoint equivalence.
variable {F : C ⥤ D} {G : D ⥤ C} (η : 𝟭 C ≅ F ⋙ G) (ε : G ⋙ F ≅ 𝟭 D)
/-- If `η : 𝟭 C ≅ F ⋙ G` is part of a (not necessarily half-adjoint) equivalence, we can upgrade it
to a refined natural isomorphism `adjointifyη η : 𝟭 C ≅ F ⋙ G` which exhibits the properties
required for a half-adjoint equivalence. See `Equivalence.mk`. -/
def adjointifyη : 𝟭 C ≅ F ⋙ G := by
calc
𝟭 C ≅ F ⋙ G := η
_ ≅ F ⋙ 𝟭 D ⋙ G := isoWhiskerLeft F (leftUnitor G).symm
_ ≅ F ⋙ (G ⋙ F) ⋙ G := isoWhiskerLeft F (isoWhiskerRight ε.symm G)
_ ≅ F ⋙ G ⋙ F ⋙ G := isoWhiskerLeft F (associator G F G)
_ ≅ (F ⋙ G) ⋙ F ⋙ G := (associator F G (F ⋙ G)).symm
_ ≅ 𝟭 C ⋙ F ⋙ G := isoWhiskerRight η.symm (F ⋙ G)
_ ≅ F ⋙ G := leftUnitor (F ⋙ G)
@[reassoc]
theorem adjointify_η_ε (X : C) :
F.map ((adjointifyη η ε).hom.app X) ≫ ε.hom.app (F.obj X) = 𝟙 (F.obj X) := by
dsimp [adjointifyη, Trans.trans]
simp only [comp_id, assoc, map_comp]
have := ε.hom.naturality (F.map (η.inv.app X)); dsimp at this; rw [this]; clear this
rw [← assoc _ _ (F.map _)]
have := ε.hom.naturality (ε.inv.app <| F.obj X); dsimp at this; rw [this]; clear this
have := (ε.app <| F.obj X).hom_inv_id; dsimp at this; rw [this]; clear this
rw [id_comp]; have := (F.mapIso <| η.app X).hom_inv_id; dsimp at this; rw [this]
end
/-- Every equivalence of categories consisting of functors `F` and `G` such that `F ⋙ G` and
`G ⋙ F` are naturally isomorphic to identity functors can be transformed into a half-adjoint
equivalence without changing `F` or `G`. -/
protected def mk (F : C ⥤ D) (G : D ⥤ C) (η : 𝟭 C ≅ F ⋙ G) (ε : G ⋙ F ≅ 𝟭 D) : C ≌ D :=
⟨F, G, adjointifyη η ε, ε, adjointify_η_ε η ε⟩
/-- Equivalence of categories is reflexive. -/
@[refl, simps]
def refl : C ≌ C :=
⟨𝟭 C, 𝟭 C, Iso.refl _, Iso.refl _, fun _ => Category.id_comp _⟩
instance : Inhabited (C ≌ C) :=
⟨refl⟩
/-- Equivalence of categories is symmetric. -/
@[symm, simps]
def symm (e : C ≌ D) : D ≌ C :=
⟨e.inverse, e.functor, e.counitIso.symm, e.unitIso.symm, e.inverse_counitInv_comp⟩
@[simp]
lemma mkHom_id_inverse {e : C ≌ D} : mkHom (𝟙 e.inverse) = 𝟙 e.symm := rfl
variable {E : Type u₃} [Category.{v₃} E]
/-- Equivalence of categories is transitive. -/
@[trans, simps]
def trans (e : C ≌ D) (f : D ≌ E) : C ≌ E where
functor := e.functor ⋙ f.functor
inverse := f.inverse ⋙ e.inverse
unitIso := e.unitIso ≪≫ isoWhiskerRight (e.functor.rightUnitor.symm ≪≫
isoWhiskerLeft _ f.unitIso ≪≫ (Functor.associator _ _ _ ).symm) _ ≪≫ Functor.associator _ _ _
counitIso := (Functor.associator _ _ _ ).symm ≪≫ isoWhiskerRight ((Functor.associator _ _ _ ) ≪≫
isoWhiskerLeft _ e.counitIso ≪≫ f.inverse.rightUnitor) _ ≪≫ f.counitIso
-- We wouldn't have needed to give this proof if we'd used `Equivalence.mk`,
-- but we choose to avoid using that here, for the sake of good structure projection `simp`
-- lemmas.
functor_unitIso_comp X := by
dsimp
simp only [comp_id, id_comp, map_comp, fun_inv_map, comp_obj, id_obj, counitInv,
functor_unit_comp_assoc, assoc]
slice_lhs 2 3 => rw [← Functor.map_comp, Iso.inv_hom_id_app]
simp
/-- Composing a functor with both functors of an equivalence yields a naturally isomorphic
functor. -/
def funInvIdAssoc (e : C ≌ D) (F : C ⥤ E) : e.functor ⋙ e.inverse ⋙ F ≅ F :=
(Functor.associator _ _ _).symm ≪≫ isoWhiskerRight e.unitIso.symm F ≪≫ F.leftUnitor
@[simp]
theorem funInvIdAssoc_hom_app (e : C ≌ D) (F : C ⥤ E) (X : C) :
(funInvIdAssoc e F).hom.app X = F.map (e.unitInv.app X) := by
dsimp [funInvIdAssoc]
simp
@[simp]
theorem funInvIdAssoc_inv_app (e : C ≌ D) (F : C ⥤ E) (X : C) :
(funInvIdAssoc e F).inv.app X = F.map (e.unit.app X) := by
dsimp [funInvIdAssoc]
simp
/-- Composing a functor with both functors of an equivalence yields a naturally isomorphic
functor. -/
def invFunIdAssoc (e : C ≌ D) (F : D ⥤ E) : e.inverse ⋙ e.functor ⋙ F ≅ F :=
(Functor.associator _ _ _).symm ≪≫ isoWhiskerRight e.counitIso F ≪≫ F.leftUnitor
@[simp]
theorem invFunIdAssoc_hom_app (e : C ≌ D) (F : D ⥤ E) (X : D) :
(invFunIdAssoc e F).hom.app X = F.map (e.counit.app X) := by
dsimp [invFunIdAssoc]
simp
@[simp]
theorem invFunIdAssoc_inv_app (e : C ≌ D) (F : D ⥤ E) (X : D) :
(invFunIdAssoc e F).inv.app X = F.map (e.counitInv.app X) := by
dsimp [invFunIdAssoc]
simp
/-- If `C` is equivalent to `D`, then `C ⥤ E` is equivalent to `D ⥤ E`. -/
@[simps! functor inverse unitIso counitIso]
def congrLeft (e : C ≌ D) : C ⥤ E ≌ D ⥤ E where
functor := (whiskeringLeft _ _ _).obj e.inverse
inverse := (whiskeringLeft _ _ _).obj e.functor
unitIso := (NatIso.ofComponents fun F => (e.funInvIdAssoc F).symm)
counitIso := (NatIso.ofComponents fun F => e.invFunIdAssoc F)
functor_unitIso_comp F := by
ext X
dsimp
simp only [funInvIdAssoc_inv_app, id_obj, comp_obj, invFunIdAssoc_hom_app,
Functor.comp_map, ← F.map_comp, unit_inverse_comp, map_id]
/-- If `C` is equivalent to `D`, then `E ⥤ C` is equivalent to `E ⥤ D`. -/
@[simps! functor inverse unitIso counitIso]
def congrRight (e : C ≌ D) : E ⥤ C ≌ E ⥤ D where
functor := (whiskeringRight _ _ _).obj e.functor
inverse := (whiskeringRight _ _ _).obj e.inverse
unitIso := NatIso.ofComponents
fun F => F.rightUnitor.symm ≪≫ isoWhiskerLeft F e.unitIso ≪≫ Functor.associator _ _ _
counitIso := NatIso.ofComponents
fun F => Functor.associator _ _ _ ≪≫ isoWhiskerLeft F e.counitIso ≪≫ F.rightUnitor
variable (E) in
/-- Promoting `Equivalence.congrRight` to a functor. -/
@[simps]
def congrRightFunctor : (C ≌ D) ⥤ ((E ⥤ C) ≌ (E ⥤ D)) where
obj e := e.congrRight
map {e f} α := mkHom <| (whiskeringRight _ _ _).map <| asNatTrans α
section CancellationLemmas
variable (e : C ≌ D)
/- We need special forms of `cancel_natIso_hom_right(_assoc)` and
`cancel_natIso_inv_right(_assoc)` for units and counits, because neither `simp` or `rw` will apply
those lemmas in this setting without providing `e.unitIso` (or similar) as an explicit argument.
We also provide the lemmas for length four compositions, since they're occasionally useful.
(e.g. in proving that equivalences take monos to monos) -/
@[simp]
theorem cancel_unit_right {X Y : C} (f f' : X ⟶ Y) :
f ≫ e.unit.app Y = f' ≫ e.unit.app Y ↔ f = f' := by simp only [cancel_mono]
@[simp]
theorem cancel_unitInv_right {X Y : C} (f f' : X ⟶ e.inverse.obj (e.functor.obj Y)) :
f ≫ e.unitInv.app Y = f' ≫ e.unitInv.app Y ↔ f = f' := by simp only [cancel_mono]
@[simp]
theorem cancel_counit_right {X Y : D} (f f' : X ⟶ e.functor.obj (e.inverse.obj Y)) :
f ≫ e.counit.app Y = f' ≫ e.counit.app Y ↔ f = f' := by simp only [cancel_mono]
@[simp]
theorem cancel_counitInv_right {X Y : D} (f f' : X ⟶ Y) :
f ≫ e.counitInv.app Y = f' ≫ e.counitInv.app Y ↔ f = f' := by simp only [cancel_mono]
@[simp]
theorem cancel_unit_right_assoc {W X X' Y : C} (f : W ⟶ X) (g : X ⟶ Y) (f' : W ⟶ X') (g' : X' ⟶ Y) :
f ≫ g ≫ e.unit.app Y = f' ≫ g' ≫ e.unit.app Y ↔ f ≫ g = f' ≫ g' := by
simp only [← Category.assoc, cancel_mono]
@[simp]
theorem cancel_counitInv_right_assoc {W X X' Y : D} (f : W ⟶ X) (g : X ⟶ Y) (f' : W ⟶ X')
(g' : X' ⟶ Y) : f ≫ g ≫ e.counitInv.app Y = f' ≫ g' ≫ e.counitInv.app Y ↔ f ≫ g = f' ≫ g' := by
simp only [← Category.assoc, cancel_mono]
@[simp]
theorem cancel_unit_right_assoc' {W X X' Y Y' Z : C} (f : W ⟶ X) (g : X ⟶ Y) (h : Y ⟶ Z)
(f' : W ⟶ X') (g' : X' ⟶ Y') (h' : Y' ⟶ Z) :
f ≫ g ≫ h ≫ e.unit.app Z = f' ≫ g' ≫ h' ≫ e.unit.app Z ↔ f ≫ g ≫ h = f' ≫ g' ≫ h' := by
simp only [← Category.assoc, cancel_mono]
@[simp]
theorem cancel_counitInv_right_assoc' {W X X' Y Y' Z : D} (f : W ⟶ X) (g : X ⟶ Y) (h : Y ⟶ Z)
(f' : W ⟶ X') (g' : X' ⟶ Y') (h' : Y' ⟶ Z) :
f ≫ g ≫ h ≫ e.counitInv.app Z = f' ≫ g' ≫ h' ≫ e.counitInv.app Z ↔
f ≫ g ≫ h = f' ≫ g' ≫ h' := by simp only [← Category.assoc, cancel_mono]
end CancellationLemmas
section
-- There's of course a monoid structure on `C ≌ C`,
-- but let's not encourage using it.
-- The power structure is nevertheless useful.
/-- Natural number powers of an auto-equivalence. Use `(^)` instead. -/
def powNat (e : C ≌ C) : ℕ → (C ≌ C)
| 0 => Equivalence.refl
| 1 => e
| n + 2 => e.trans (powNat e (n + 1))
/-- Powers of an auto-equivalence. Use `(^)` instead. -/
def pow (e : C ≌ C) : ℤ → (C ≌ C)
| Int.ofNat n => e.powNat n
| Int.negSucc n => e.symm.powNat (n + 1)
instance : Pow (C ≌ C) ℤ :=
⟨pow⟩
@[simp]
theorem pow_zero (e : C ≌ C) : e ^ (0 : ℤ) = Equivalence.refl :=
rfl
@[simp]
theorem pow_one (e : C ≌ C) : e ^ (1 : ℤ) = e :=
rfl
@[simp]
theorem pow_neg_one (e : C ≌ C) : e ^ (-1 : ℤ) = e.symm :=
rfl
-- TODO as necessary, add the natural isomorphisms `(e^a).trans e^b ≅ e^(a+b)`.
-- At this point, we haven't even defined the category of equivalences.
-- Note: the better formulation of this would involve `HasShift`.
end
/-- The functor of an equivalence of categories is essentially surjective. -/
@[stacks 02C3]
instance essSurj_functor (e : C ≌ E) : e.functor.EssSurj :=
⟨fun Y => ⟨e.inverse.obj Y, ⟨e.counitIso.app Y⟩⟩⟩
instance essSurj_inverse (e : C ≌ E) : e.inverse.EssSurj :=
e.symm.essSurj_functor
/-- The functor of an equivalence of categories is fully faithful. -/
def fullyFaithfulFunctor (e : C ≌ E) : e.functor.FullyFaithful where
preimage {X Y} f := e.unitIso.hom.app X ≫ e.inverse.map f ≫ e.unitIso.inv.app Y
/-- The inverse of an equivalence of categories is fully faithful. -/
def fullyFaithfulInverse (e : C ≌ E) : e.inverse.FullyFaithful where
preimage {X Y} f := e.counitIso.inv.app X ≫ e.functor.map f ≫ e.counitIso.hom.app Y
/-- The functor of an equivalence of categories is faithful. -/
@[stacks 02C3]
instance faithful_functor (e : C ≌ E) : e.functor.Faithful :=
e.fullyFaithfulFunctor.faithful
instance faithful_inverse (e : C ≌ E) : e.inverse.Faithful :=
e.fullyFaithfulInverse.faithful
/-- The functor of an equivalence of categories is full. -/
@[stacks 02C3]
instance full_functor (e : C ≌ E) : e.functor.Full :=
e.fullyFaithfulFunctor.full
instance full_inverse (e : C ≌ E) : e.inverse.Full :=
e.fullyFaithfulInverse.full
/-- If `e : C ≌ D` is an equivalence of categories, and `iso : e.functor ≅ G` is
an isomorphism, then there is an equivalence of categories whose functor is `G`. -/
@[simps!]
def changeFunctor (e : C ≌ D) {G : C ⥤ D} (iso : e.functor ≅ G) : C ≌ D where
functor := G
inverse := e.inverse
unitIso := e.unitIso ≪≫ isoWhiskerRight iso _
counitIso := isoWhiskerLeft _ iso.symm ≪≫ e.counitIso
/-- Compatibility of `changeFunctor` with identity isomorphisms of functors -/
theorem changeFunctor_refl (e : C ≌ D) : e.changeFunctor (Iso.refl _) = e := by cat_disch
/-- Compatibility of `changeFunctor` with the composition of isomorphisms of functors -/
theorem changeFunctor_trans (e : C ≌ D) {G G' : C ⥤ D} (iso₁ : e.functor ≅ G) (iso₂ : G ≅ G') :
(e.changeFunctor iso₁).changeFunctor iso₂ = e.changeFunctor (iso₁ ≪≫ iso₂) := by cat_disch
/-- If `e : C ≌ D` is an equivalence of categories, and `iso : e.functor ≅ G` is
an isomorphism, then there is an equivalence of categories whose inverse is `G`. -/
@[simps!]
def changeInverse (e : C ≌ D) {G : D ⥤ C} (iso : e.inverse ≅ G) : C ≌ D where
functor := e.functor
inverse := G
unitIso := e.unitIso ≪≫ isoWhiskerLeft _ iso
counitIso := isoWhiskerRight iso.symm _ ≪≫ e.counitIso
functor_unitIso_comp X := by
dsimp
rw [← map_comp_assoc, assoc, iso.hom_inv_id_app, comp_id, functor_unit_comp]
end Equivalence
/-- A functor is an equivalence of categories if it is faithful, full and
essentially surjective. -/
class Functor.IsEquivalence (F : C ⥤ D) : Prop where
faithful : F.Faithful := by infer_instance
full : F.Full := by infer_instance
essSurj : F.EssSurj := by infer_instance
instance Equivalence.isEquivalence_functor (F : C ≌ D) : IsEquivalence F.functor where
instance Equivalence.isEquivalence_inverse (F : C ≌ D) : IsEquivalence F.inverse :=
F.symm.isEquivalence_functor
namespace Functor
namespace IsEquivalence
attribute [instance] faithful full essSurj
/-- To see that a functor is an equivalence, it suffices to provide an inverse functor `G` such that
`F ⋙ G` and `G ⋙ F` are naturally isomorphic to identity functors. -/
protected lemma mk' {F : C ⥤ D} (G : D ⥤ C) (η : 𝟭 C ≅ F ⋙ G) (ε : G ⋙ F ≅ 𝟭 D) :
IsEquivalence F :=
inferInstanceAs (IsEquivalence (Equivalence.mk F G η ε).functor)
end IsEquivalence
/-- A quasi-inverse `D ⥤ C` to a functor that `F : C ⥤ D` that is an equivalence,
i.e. faithful, full, and essentially surjective. -/
noncomputable def inv (F : C ⥤ D) [F.IsEquivalence] : D ⥤ C where
obj X := F.objPreimage X
map {X Y} f := F.preimage ((F.objObjPreimageIso X).hom ≫ f ≫ (F.objObjPreimageIso Y).inv)
map_id X := by apply F.map_injective; simp
map_comp {X Y Z} f g := by apply F.map_injective; simp
/-- Interpret a functor that is an equivalence as an equivalence. -/
@[simps functor, stacks 02C3]
noncomputable def asEquivalence (F : C ⥤ D) [F.IsEquivalence] : C ≌ D where
functor := F
inverse := F.inv
unitIso := NatIso.ofComponents
(fun X => (F.preimageIso <| F.objObjPreimageIso <| F.obj X).symm)
(fun f => F.map_injective (by simp [inv]))
counitIso := NatIso.ofComponents F.objObjPreimageIso (by simp [inv])
instance isEquivalence_refl : IsEquivalence (𝟭 C) :=
Equivalence.refl.isEquivalence_functor
instance isEquivalence_inv (F : C ⥤ D) [IsEquivalence F] : IsEquivalence F.inv :=
F.asEquivalence.symm.isEquivalence_functor
variable {E : Type u₃} [Category.{v₃} E]
instance isEquivalence_trans (F : C ⥤ D) (G : D ⥤ E) [IsEquivalence F] [IsEquivalence G] :
IsEquivalence (F ⋙ G) where
instance (F : C ⥤ D) [IsEquivalence F] : IsEquivalence ((whiskeringLeft C D E).obj F) :=
(inferInstance : IsEquivalence (Equivalence.congrLeft F.asEquivalence).inverse)
instance (F : C ⥤ D) [IsEquivalence F] : IsEquivalence ((whiskeringRight E C D).obj F) :=
(inferInstance : IsEquivalence (Equivalence.congrRight F.asEquivalence).functor)
end Functor
namespace Functor
@[simp]
theorem fun_inv_map (F : C ⥤ D) [IsEquivalence F] (X Y : D) (f : X ⟶ Y) :
F.map (F.inv.map f) = F.asEquivalence.counit.app X ≫ f ≫ F.asEquivalence.counitInv.app Y := by
simpa using (NatIso.naturality_2 (α := F.asEquivalence.counitIso) (f := f)).symm
@[simp]
theorem inv_fun_map (F : C ⥤ D) [IsEquivalence F] (X Y : C) (f : X ⟶ Y) :
F.inv.map (F.map f) = F.asEquivalence.unitInv.app X ≫ f ≫ F.asEquivalence.unit.app Y := by
simpa using (NatIso.naturality_1 (α := F.asEquivalence.unitIso) (f := f)).symm
lemma isEquivalence_of_iso {F G : C ⥤ D} (e : F ≅ G) [F.IsEquivalence] : G.IsEquivalence :=
((asEquivalence F).changeFunctor e).isEquivalence_functor
lemma isEquivalence_iff_of_iso {F G : C ⥤ D} (e : F ≅ G) :
F.IsEquivalence ↔ G.IsEquivalence :=
⟨fun _ => isEquivalence_of_iso e, fun _ => isEquivalence_of_iso e.symm⟩
/-- If `G` and `F ⋙ G` are equivalence of categories, then `F` is also an equivalence. -/
lemma isEquivalence_of_comp_right {E : Type*} [Category E] (F : C ⥤ D) (G : D ⥤ E)
[IsEquivalence G] [IsEquivalence (F ⋙ G)] : IsEquivalence F := by
rw [isEquivalence_iff_of_iso (F.rightUnitor.symm ≪≫ isoWhiskerLeft F (G.asEquivalence.unitIso))]
exact ((F ⋙ G).asEquivalence.trans G.asEquivalence.symm).isEquivalence_functor
/-- If `F` and `F ⋙ G` are equivalence of categories, then `G` is also an equivalence. -/
lemma isEquivalence_of_comp_left {E : Type*} [Category E] (F : C ⥤ D) (G : D ⥤ E)
[IsEquivalence F] [IsEquivalence (F ⋙ G)] : IsEquivalence G := by
rw [isEquivalence_iff_of_iso (G.leftUnitor.symm ≪≫
isoWhiskerRight F.asEquivalence.counitIso.symm G)]
exact (F.asEquivalence.symm.trans (F ⋙ G).asEquivalence).isEquivalence_functor
end Functor
namespace Equivalence
instance essSurjInducedFunctor {C' : Type*} (e : C' ≃ D) : (inducedFunctor e).EssSurj where
mem_essImage Y := ⟨e.symm Y, by simpa using ⟨default⟩⟩
noncomputable instance inducedFunctorOfEquiv {C' : Type*} (e : C' ≃ D) :
IsEquivalence (inducedFunctor e) where
noncomputable instance fullyFaithfulToEssImage (F : C ⥤ D) [F.Full] [F.Faithful] :
IsEquivalence F.toEssImage where
end Equivalence
/-- An equality of properties of objects of a category `C` induces an equivalence of the
respective induced full subcategories of `C`. -/
@[simps]
def ObjectProperty.fullSubcategoryCongr {P P' : ObjectProperty C} (h : P = P') :
P.FullSubcategory ≌ P'.FullSubcategory where
functor := ObjectProperty.ιOfLE h.le
inverse := ObjectProperty.ιOfLE h.symm.le
unitIso := Iso.refl _
counitIso := Iso.refl _
namespace Iso
variable {E : Type u₃} [Category.{v₃} E] {F : C ⥤ E} {G : C ⥤ D} {H : D ⥤ E}
/-- Construct an isomorphism `F ⋙ H.inverse ≅ G` from an isomorphism `F ≅ G ⋙ H.functor`. -/
@[simps!]
def compInverseIso {H : D ≌ E} (i : F ≅ G ⋙ H.functor) : F ⋙ H.inverse ≅ G :=
isoWhiskerRight i H.inverse ≪≫
associator G _ H.inverse ≪≫ isoWhiskerLeft G H.unitIso.symm ≪≫ G.rightUnitor
/-- Construct an isomorphism `G ≅ F ⋙ H.inverse` from an isomorphism `G ⋙ H.functor ≅ F`. -/
@[simps!]
def isoCompInverse {H : D ≌ E} (i : G ⋙ H.functor ≅ F) : G ≅ F ⋙ H.inverse :=
G.rightUnitor.symm ≪≫ isoWhiskerLeft G H.unitIso ≪≫ (associator _ _ _).symm ≪≫
isoWhiskerRight i H.inverse
/-- Construct an isomorphism `G.inverse ⋙ F ≅ H` from an isomorphism `F ≅ G.functor ⋙ H`. -/
@[simps!]
def inverseCompIso {G : C ≌ D} (i : F ≅ G.functor ⋙ H) : G.inverse ⋙ F ≅ H :=
isoWhiskerLeft G.inverse i ≪≫ (associator _ _ _).symm ≪≫
isoWhiskerRight G.counitIso H ≪≫ H.leftUnitor
/-- Construct an isomorphism `H ≅ G.inverse ⋙ F` from an isomorphism `G.functor ⋙ H ≅ F`. -/
@[simps!]
def isoInverseComp {G : C ≌ D} (i : G.functor ⋙ H ≅ F) : H ≅ G.inverse ⋙ F :=
H.leftUnitor.symm ≪≫ isoWhiskerRight G.counitIso.symm H ≪≫ associator _ _ _
≪≫ isoWhiskerLeft G.inverse i
/-- As a special case, given two equivalences `G` and `G'` between the same categories,
construct an isomorphism `G.inverse ≅ G.inverse` from an isomorphism `G.functor ≅ G.functor`. -/
@[simps!]
def isoInverseOfIsoFunctor {G G' : C ≌ D} (i : G.functor ≅ G'.functor) : G.inverse ≅ G'.inverse :=
isoCompInverse ((isoWhiskerLeft G.inverse i).symm ≪≫ G.counitIso) ≪≫ leftUnitor G'.inverse
/-- As a special case, given two equivalences `G` and `G'` between the same categories,
construct an isomorphism `G.functor ≅ G.functor` from an isomorphism `G.inverse ≅ G.inverse`. -/
@[simps!]
def isoFunctorOfIsoInverse {G G' : C ≌ D} (i : G.inverse ≅ G'.inverse) : G.functor ≅ G'.functor :=
isoInverseOfIsoFunctor (G := G.symm) (G' := G'.symm) i
/-- Sanity check: `isoFunctorOfIsoInverse (isoInverseOfIsoFunctor i)` is just `i`. -/
@[simp]
lemma isoFunctorOfIsoInverse_isoInverseOfIsoFunctor {G G' : C ≌ D} (i : G.functor ≅ G'.functor) :
isoFunctorOfIsoInverse (isoInverseOfIsoFunctor i) = i := by
ext X
simp [← NatTrans.naturality]
@[simp]
lemma isoInverseOfIsoFunctor_isoFunctorOfIsoInverse {G G' : C ≌ D} (i : G.inverse ≅ G'.inverse) :
isoInverseOfIsoFunctor (isoFunctorOfIsoInverse i) = i :=
isoFunctorOfIsoInverse_isoInverseOfIsoFunctor (G := G.symm) (G' := G'.symm) i
end Iso
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/IsConnected.lean | import Mathlib.Data.List.Chain
import Mathlib.CategoryTheory.PUnit
import Mathlib.CategoryTheory.Groupoid
import Mathlib.CategoryTheory.Category.ULift
/-!
# Connected category
Define a connected category as a _nonempty_ category for which every functor
to a discrete category is isomorphic to the constant functor.
NB. Some authors include the empty category as connected, we do not.
We instead are interested in categories with exactly one 'connected
component'.
We give some equivalent definitions:
- A nonempty category for which every functor to a discrete category is
constant on objects.
See `any_functor_const_on_obj` and `Connected.of_any_functor_const_on_obj`.
- A nonempty category for which every function `F` for which the presence of a
morphism `f : j₁ ⟶ j₂` implies `F j₁ = F j₂` must be constant everywhere.
See `constant_of_preserves_morphisms` and `Connected.of_constant_of_preserves_morphisms`.
- A nonempty category for which any subset of its elements containing the
default and closed under morphisms is everything.
See `induct_on_objects` and `Connected.of_induct`.
- A nonempty category for which every object is related under the reflexive
transitive closure of the relation "there is a morphism in some direction
from `j₁` to `j₂`".
See `connected_zigzag` and `zigzag_connected`.
- A nonempty category for which for any two objects there is a sequence of
morphisms (some reversed) from one to the other.
See `exists_zigzag'` and `connected_of_zigzag`.
We also prove the result that the functor given by `(X × -)` preserves any
connected limit. That is, any limit of shape `J` where `J` is a connected
category is preserved by the functor `(X × -)`. This appears in `CategoryTheory.Limits.Connected`.
-/
universe w₁ w₂ v₁ v₂ u₁ u₂
noncomputable section
open CategoryTheory.Category CategoryTheory.Functor
open Opposite
namespace CategoryTheory
/-- A possibly empty category for which every functor to a discrete category is constant.
-/
class IsPreconnected (J : Type u₁) [Category.{v₁} J] : Prop where
iso_constant :
∀ {α : Type u₁} (F : J ⥤ Discrete α) (j : J), Nonempty (F ≅ (Functor.const J).obj (F.obj j))
attribute [inherit_doc IsPreconnected] IsPreconnected.iso_constant
/-- We define a connected category as a _nonempty_ category for which every
functor to a discrete category is constant.
NB. Some authors include the empty category as connected, we do not.
We instead are interested in categories with exactly one 'connected
component'.
This allows us to show that the functor X ⨯ - preserves connected limits. -/
@[stacks 002S]
class IsConnected (J : Type u₁) [Category.{v₁} J] : Prop extends IsPreconnected J where
[is_nonempty : Nonempty J]
attribute [instance 100] IsConnected.is_nonempty
variable {J : Type u₁} [Category.{v₁} J]
variable {K : Type u₂} [Category.{v₂} K]
namespace IsPreconnected.IsoConstantAux
/-- Implementation detail of `isoConstant`. -/
private def liftToDiscrete {α : Type u₂} (F : J ⥤ Discrete α) : J ⥤ Discrete J where
obj j := have := Nonempty.intro j
Discrete.mk (Function.invFun F.obj (F.obj j))
map {j _} f := have := Nonempty.intro j
⟨⟨congr_arg (Function.invFun F.obj) (Discrete.ext (Discrete.eq_of_hom (F.map f)))⟩⟩
/-- Implementation detail of `isoConstant`. -/
private def factorThroughDiscrete {α : Type u₂} (F : J ⥤ Discrete α) :
liftToDiscrete F ⋙ Discrete.functor F.obj ≅ F :=
NatIso.ofComponents (fun _ => eqToIso Function.apply_invFun_apply) (by cat_disch)
end IsPreconnected.IsoConstantAux
/-- If `J` is connected, any functor `F : J ⥤ Discrete α` is isomorphic to
the constant functor with value `F.obj j` (for any choice of `j`).
-/
def isoConstant [IsPreconnected J] {α : Type u₂} (F : J ⥤ Discrete α) (j : J) :
F ≅ (Functor.const J).obj (F.obj j) :=
(IsPreconnected.IsoConstantAux.factorThroughDiscrete F).symm
≪≫ isoWhiskerRight (IsPreconnected.iso_constant _ j).some _
≪≫ NatIso.ofComponents (fun _ => eqToIso Function.apply_invFun_apply) (by simp)
/-- If `J` is connected, any functor to a discrete category is constant on objects.
The converse is given in `IsConnected.of_any_functor_const_on_obj`.
-/
theorem any_functor_const_on_obj [IsPreconnected J] {α : Type u₂} (F : J ⥤ Discrete α) (j j' : J) :
F.obj j = F.obj j' := by
ext; exact ((isoConstant F j').hom.app j).down.1
/-- If any functor to a discrete category is constant on objects, J is connected.
The converse of `any_functor_const_on_obj`.
-/
theorem IsPreconnected.of_any_functor_const_on_obj
(h : ∀ {α : Type u₁} (F : J ⥤ Discrete α), ∀ j j' : J, F.obj j = F.obj j') :
IsPreconnected J where
iso_constant := fun F j' => ⟨NatIso.ofComponents fun j => eqToIso (h F j j')⟩
instance IsPreconnected.prod [IsPreconnected J] [IsPreconnected K] : IsPreconnected (J × K) := by
refine .of_any_functor_const_on_obj (fun {a} F ⟨j, k⟩ ⟨j', k'⟩ => ?_)
exact (any_functor_const_on_obj (Prod.sectL J k ⋙ F) j j').trans
(any_functor_const_on_obj (Prod.sectR j' K ⋙ F) k k')
instance IsConnected.prod [IsConnected J] [IsConnected K] : IsConnected (J × K) where
/-- If any functor to a discrete category is constant on objects, J is connected.
The converse of `any_functor_const_on_obj`.
-/
theorem IsConnected.of_any_functor_const_on_obj [Nonempty J]
(h : ∀ {α : Type u₁} (F : J ⥤ Discrete α), ∀ j j' : J, F.obj j = F.obj j') : IsConnected J :=
{ IsPreconnected.of_any_functor_const_on_obj h with }
/-- If `J` is connected, then given any function `F` such that the presence of a
morphism `j₁ ⟶ j₂` implies `F j₁ = F j₂`, we have that `F` is constant.
This can be thought of as a local-to-global property.
The converse is shown in `IsConnected.of_constant_of_preserves_morphisms`
-/
theorem constant_of_preserves_morphisms [IsPreconnected J] {α : Type u₂} (F : J → α)
(h : ∀ (j₁ j₂ : J) (_ : j₁ ⟶ j₂), F j₁ = F j₂) (j j' : J) : F j = F j' := by
simpa using
any_functor_const_on_obj
{ obj := Discrete.mk ∘ F
map := fun f => eqToHom (by ext; exact h _ _ f) }
j j'
/-- If `J` is connected, then given any function `F` such that the presence of a
morphism `j₁ ⟶ j₂` implies `F j₁ = F j₂`, there exists `a` such that `F j = a`
holds for any `j`. See `constant_of_preserves_morphisms` for a different
formulation of the fact that `F` is constant.
This can be thought of as a local-to-global property.
The converse is shown in `IsConnected.of_constant_of_preserves_morphisms`
-/
theorem constant_of_preserves_morphisms' [IsConnected J] {α : Type u₂} (F : J → α)
(h : ∀ (j₁ j₂ : J) (_ : j₁ ⟶ j₂), F j₁ = F j₂) :
∃ (a : α), ∀ (j : J), F j = a :=
⟨F (Classical.arbitrary _), fun _ ↦ constant_of_preserves_morphisms _ h _ _⟩
/-- `J` is connected if: given any function `F : J → α` which is constant for any
`j₁, j₂` for which there is a morphism `j₁ ⟶ j₂`, then `F` is constant.
This can be thought of as a local-to-global property.
The converse of `constant_of_preserves_morphisms`.
-/
theorem IsPreconnected.of_constant_of_preserves_morphisms
(h : ∀ {α : Type u₁} (F : J → α),
(∀ {j₁ j₂ : J} (_ : j₁ ⟶ j₂), F j₁ = F j₂) → ∀ j j' : J, F j = F j') :
IsPreconnected J :=
IsPreconnected.of_any_functor_const_on_obj fun F =>
h F.obj fun f => by ext; exact Discrete.eq_of_hom (F.map f)
/-- `J` is connected if: given any function `F : J → α` which is constant for any
`j₁, j₂` for which there is a morphism `j₁ ⟶ j₂`, then `F` is constant.
This can be thought of as a local-to-global property.
The converse of `constant_of_preserves_morphisms`.
-/
theorem IsConnected.of_constant_of_preserves_morphisms [Nonempty J]
(h : ∀ {α : Type u₁} (F : J → α),
(∀ {j₁ j₂ : J} (_ : j₁ ⟶ j₂), F j₁ = F j₂) → ∀ j j' : J, F j = F j') :
IsConnected J :=
{ IsPreconnected.of_constant_of_preserves_morphisms h with }
/-- An inductive-like property for the objects of a connected category.
If the set `p` is nonempty, and `p` is closed under morphisms of `J`,
then `p` contains all of `J`.
The converse is given in `IsConnected.of_induct`.
-/
theorem induct_on_objects [IsPreconnected J] (p : Set J) {j₀ : J} (h0 : j₀ ∈ p)
(h1 : ∀ {j₁ j₂ : J} (_ : j₁ ⟶ j₂), j₁ ∈ p ↔ j₂ ∈ p) (j : J) : j ∈ p := by
let aux (j₁ j₂ : J) (f : j₁ ⟶ j₂) := congrArg ULift.up <| (h1 f).eq
injection constant_of_preserves_morphisms (fun k => ULift.up.{u₁} (k ∈ p)) aux j j₀ with i
rwa [i]
/--
If any maximal connected component containing some element j₀ of J is all of J, then J is connected.
The converse of `induct_on_objects`.
-/
theorem IsConnected.of_induct {j₀ : J}
(h : ∀ p : Set J, j₀ ∈ p → (∀ {j₁ j₂ : J} (_ : j₁ ⟶ j₂), j₁ ∈ p ↔ j₂ ∈ p) → ∀ j : J, j ∈ p) :
IsConnected J :=
have := Nonempty.intro j₀
IsConnected.of_constant_of_preserves_morphisms fun {α} F a => by
have w := h { j | F j = F j₀ } rfl (fun {j₁} {j₂} f => by
change F j₁ = F j₀ ↔ F j₂ = F j₀
simp [a f])
intro j j'
rw [w j, w j']
attribute [local instance] uliftCategory in
/-- Lifting the universe level of morphisms and objects preserves connectedness. -/
instance [hc : IsConnected J] : IsConnected (ULiftHom.{v₂} (ULift.{u₂} J)) := by
apply IsConnected.of_induct
· rintro p hj₀ h ⟨j⟩
let p' : Set J := {j : J | p ⟨j⟩}
have hj₀' : Classical.choice hc.is_nonempty ∈ p' := by
simp only [p']
exact hj₀
apply induct_on_objects p' hj₀' fun f => h ((ULiftHomULiftCategory.equiv J).functor.map f)
/-- Another induction principle for `IsPreconnected J`:
given a type family `Z : J → Sort*` and
a rule for transporting in *both* directions along a morphism in `J`,
we can transport an `x : Z j₀` to a point in `Z j` for any `j`.
-/
theorem isPreconnected_induction [IsPreconnected J] (Z : J → Sort*)
(h₁ : ∀ {j₁ j₂ : J} (_ : j₁ ⟶ j₂), Z j₁ → Z j₂) (h₂ : ∀ {j₁ j₂ : J} (_ : j₁ ⟶ j₂), Z j₂ → Z j₁)
{j₀ : J} (x : Z j₀) (j : J) : Nonempty (Z j) :=
(induct_on_objects { j | Nonempty (Z j) } ⟨x⟩
(fun f => ⟨by rintro ⟨y⟩; exact ⟨h₁ f y⟩, by rintro ⟨y⟩; exact ⟨h₂ f y⟩⟩)
j :)
/-- If `J` and `K` are equivalent, then if `J` is preconnected then `K` is as well. -/
theorem isPreconnected_of_equivalent {K : Type u₂} [Category.{v₂} K] [IsPreconnected J]
(e : J ≌ K) : IsPreconnected K where
iso_constant F k :=
⟨calc
F ≅ e.inverse ⋙ e.functor ⋙ F := (e.invFunIdAssoc F).symm
_ ≅ e.inverse ⋙ (Functor.const J).obj ((e.functor ⋙ F).obj (e.inverse.obj k)) :=
isoWhiskerLeft e.inverse (isoConstant (e.functor ⋙ F) (e.inverse.obj k))
_ ≅ e.inverse ⋙ (Functor.const J).obj (F.obj k) :=
isoWhiskerLeft _ ((F ⋙ Functor.const J).mapIso (e.counitIso.app k))
_ ≅ (Functor.const K).obj (F.obj k) := NatIso.ofComponents fun _ => Iso.refl _⟩
lemma isPreconnected_iff_of_equivalence {K : Type u₂} [Category.{v₂} K] (e : J ≌ K) :
IsPreconnected J ↔ IsPreconnected K :=
⟨fun _ => isPreconnected_of_equivalent e, fun _ => isPreconnected_of_equivalent e.symm⟩
/-- If `J` and `K` are equivalent, then if `J` is connected then `K` is as well. -/
theorem isConnected_of_equivalent {K : Type u₂} [Category.{v₂} K] (e : J ≌ K) [IsConnected J] :
IsConnected K :=
{ is_nonempty := Nonempty.map e.functor.obj (by infer_instance)
toIsPreconnected := isPreconnected_of_equivalent e }
lemma isConnected_iff_of_equivalence {K : Type u₂} [Category.{v₂} K] (e : J ≌ K) :
IsConnected J ↔ IsConnected K :=
⟨fun _ => isConnected_of_equivalent e, fun _ => isConnected_of_equivalent e.symm⟩
/-- If `J` is preconnected, then `Jᵒᵖ` is preconnected as well. -/
instance isPreconnected_op [IsPreconnected J] : IsPreconnected Jᵒᵖ where
iso_constant := fun {α} F X =>
⟨NatIso.ofComponents fun Y =>
eqToIso (Discrete.ext (Discrete.eq_of_hom ((Nonempty.some
(IsPreconnected.iso_constant (F.rightOp ⋙ (Discrete.opposite α).functor) (unop X))).app
(unop Y)).hom))⟩
/-- If `J` is connected, then `Jᵒᵖ` is connected as well. -/
instance isConnected_op [IsConnected J] : IsConnected Jᵒᵖ where
is_nonempty := Nonempty.intro (op (Classical.arbitrary J))
theorem isPreconnected_of_isPreconnected_op [IsPreconnected Jᵒᵖ] : IsPreconnected J :=
isPreconnected_of_equivalent (opOpEquivalence J)
theorem isConnected_of_isConnected_op [IsConnected Jᵒᵖ] : IsConnected J :=
isConnected_of_equivalent (opOpEquivalence J)
variable (J) in
@[simp]
theorem isConnected_op_iff_isConnected : IsConnected Jᵒᵖ ↔ IsConnected J :=
⟨fun _ => isConnected_of_isConnected_op, fun _ => isConnected_op⟩
/-- j₁ and j₂ are related by `Zag` if there is a morphism between them. -/
def Zag (j₁ j₂ : J) : Prop :=
Nonempty (j₁ ⟶ j₂) ∨ Nonempty (j₂ ⟶ j₁)
@[refl] theorem Zag.refl (X : J) : Zag X X := Or.inl ⟨𝟙 _⟩
theorem zag_symmetric : Symmetric (@Zag J _) := fun _ _ h => h.symm
@[symm] theorem Zag.symm {j₁ j₂ : J} (h : Zag j₁ j₂) : Zag j₂ j₁ := zag_symmetric h
theorem Zag.of_hom {j₁ j₂ : J} (f : j₁ ⟶ j₂) : Zag j₁ j₂ := Or.inl ⟨f⟩
theorem Zag.of_inv {j₁ j₂ : J} (f : j₂ ⟶ j₁) : Zag j₁ j₂ := Or.inr ⟨f⟩
/-- `j₁` and `j₂` are related by `Zigzag` if there is a chain of
morphisms from `j₁` to `j₂`, with backward morphisms allowed.
-/
def Zigzag : J → J → Prop :=
Relation.ReflTransGen Zag
theorem zigzag_symmetric : Symmetric (@Zigzag J _) :=
Relation.ReflTransGen.symmetric zag_symmetric
theorem zigzag_equivalence : _root_.Equivalence (@Zigzag J _) :=
_root_.Equivalence.mk Relation.reflexive_reflTransGen (fun h => zigzag_symmetric h)
(fun h g => Relation.transitive_reflTransGen h g)
@[refl] theorem Zigzag.refl (X : J) : Zigzag X X := zigzag_equivalence.refl _
@[symm] theorem Zigzag.symm {j₁ j₂ : J} (h : Zigzag j₁ j₂) : Zigzag j₂ j₁ := zigzag_symmetric h
@[trans] theorem Zigzag.trans {j₁ j₂ j₃ : J} (h₁ : Zigzag j₁ j₂) (h₂ : Zigzag j₂ j₃) :
Zigzag j₁ j₃ :=
zigzag_equivalence.trans h₁ h₂
instance : Trans (α := J) (Zigzag · ·) (Zigzag · ·) (Zigzag · ·) where
trans := Zigzag.trans
theorem Zigzag.of_zag {j₁ j₂ : J} (h : Zag j₁ j₂) : Zigzag j₁ j₂ :=
Relation.ReflTransGen.single h
theorem Zigzag.of_hom {j₁ j₂ : J} (f : j₁ ⟶ j₂) : Zigzag j₁ j₂ :=
of_zag (Zag.of_hom f)
theorem Zigzag.of_inv {j₁ j₂ : J} (f : j₂ ⟶ j₁) : Zigzag j₁ j₂ :=
of_zag (Zag.of_inv f)
theorem Zigzag.of_zag_trans {j₁ j₂ j₃ : J} (h₁ : Zag j₁ j₂) (h₂ : Zag j₂ j₃) : Zigzag j₁ j₃ :=
trans (of_zag h₁) (of_zag h₂)
instance : Trans (α := J) (Zag · ·) (Zigzag · ·) (Zigzag · ·) where
trans h h' := Zigzag.trans (.of_zag h) h'
instance : Trans (α := J) (Zigzag · ·) (Zag · ·) (Zigzag · ·) where
trans h h' := Zigzag.trans h (.of_zag h')
instance : Trans (α := J) (Zag · ·) (Zag · ·) (Zigzag · ·) where
trans := Zigzag.of_zag_trans
theorem Zigzag.of_hom_hom {j₁ j₂ j₃ : J} (f₁₂ : j₁ ⟶ j₂) (f₂₃ : j₂ ⟶ j₃) : Zigzag j₁ j₃ :=
(of_hom f₁₂).trans (of_hom f₂₃)
theorem Zigzag.of_hom_inv {j₁ j₂ j₃ : J} (f₁₂ : j₁ ⟶ j₂) (f₃₂ : j₃ ⟶ j₂) : Zigzag j₁ j₃ :=
(of_hom f₁₂).trans (of_inv f₃₂)
theorem Zigzag.of_inv_hom {j₁ j₂ j₃ : J} (f₂₁ : j₂ ⟶ j₁) (f₂₃ : j₂ ⟶ j₃) : Zigzag j₁ j₃ :=
(of_inv f₂₁).trans (of_hom f₂₃)
theorem Zigzag.of_inv_inv {j₁ j₂ j₃ : J} (f₂₁ : j₂ ⟶ j₁) (f₃₂ : j₃ ⟶ j₂) : Zigzag j₁ j₃ :=
(of_inv f₂₁).trans (of_inv f₃₂)
/-- The setoid given by the equivalence relation `Zigzag`. A quotient for this
setoid is a connected component of the category.
-/
def Zigzag.setoid (J : Type u₂) [Category.{v₁} J] : Setoid J where
r := Zigzag
iseqv := zigzag_equivalence
/-- If there is a zigzag from `j₁` to `j₂`, then there is a zigzag from `F j₁` to
`F j₂` as long as `F` is a prefunctor.
-/
theorem zigzag_prefunctor_obj_of_zigzag (F : J ⥤q K) {j₁ j₂ : J} (h : Zigzag j₁ j₂) :
Zigzag (F.obj j₁) (F.obj j₂) :=
h.lift _ fun _ _ => Or.imp (Nonempty.map fun f => F.map f) (Nonempty.map fun f => F.map f)
/-- If there is a zigzag from `j₁` to `j₂`, then there is a zigzag from `F j₁` to
`F j₂` as long as `F` is a functor.
-/
theorem zigzag_obj_of_zigzag (F : J ⥤ K) {j₁ j₂ : J} (h : Zigzag j₁ j₂) :
Zigzag (F.obj j₁) (F.obj j₂) :=
zigzag_prefunctor_obj_of_zigzag F.toPrefunctor h
/-- A Zag in a discrete category entails an equality of its extremities -/
lemma eq_of_zag (X) {a b : Discrete X} (h : Zag a b) : a.as = b.as :=
h.elim (fun ⟨f⟩ ↦ Discrete.eq_of_hom f) (fun ⟨f⟩ ↦ (Discrete.eq_of_hom f).symm)
/-- A zigzag in a discrete category entails an equality of its extremities -/
lemma eq_of_zigzag (X) {a b : Discrete X} (h : Zigzag a b) : a.as = b.as := by
induction h with
| refl => rfl
| tail _ h eq => exact eq.trans (eq_of_zag _ h)
-- TODO: figure out the right way to generalise this to `Zigzag`.
theorem zag_of_zag_obj (F : J ⥤ K) [F.Full] {j₁ j₂ : J} (h : Zag (F.obj j₁) (F.obj j₂)) :
Zag j₁ j₂ :=
Or.imp (Nonempty.map F.preimage) (Nonempty.map F.preimage) h
/-- Any equivalence relation containing (⟶) holds for all pairs of a connected category. -/
theorem equiv_relation [IsPreconnected J] (r : J → J → Prop) (hr : _root_.Equivalence r)
(h : ∀ {j₁ j₂ : J} (_ : j₁ ⟶ j₂), r j₁ j₂) : ∀ j₁ j₂ : J, r j₁ j₂ := by
intro j₁ j₂
have z : ∀ j : J, r j₁ j :=
induct_on_objects {k | r j₁ k} (hr.1 j₁)
fun f => ⟨fun t => hr.3 t (h f), fun t => hr.3 t (hr.2 (h f))⟩
exact z j₂
/-- In a connected category, any two objects are related by `Zigzag`. -/
theorem isPreconnected_zigzag [IsPreconnected J] (j₁ j₂ : J) : Zigzag j₁ j₂ :=
equiv_relation _ zigzag_equivalence
(fun f => Relation.ReflTransGen.single (Or.inl (Nonempty.intro f))) _ _
theorem zigzag_isPreconnected (h : ∀ j₁ j₂ : J, Zigzag j₁ j₂) : IsPreconnected J := by
apply IsPreconnected.of_constant_of_preserves_morphisms
intro α F hF j j'
specialize h j j'
induction h with
| refl => rfl
| tail _ hj ih =>
rw [ih]
rcases hj with (⟨⟨hj⟩⟩|⟨⟨hj⟩⟩)
exacts [hF hj, (hF hj).symm]
/-- If any two objects in a nonempty category are related by `Zigzag`, the category is connected.
-/
theorem zigzag_isConnected [Nonempty J] (h : ∀ j₁ j₂ : J, Zigzag j₁ j₂) : IsConnected J :=
{ zigzag_isPreconnected h with }
theorem exists_zigzag' [IsConnected J] (j₁ j₂ : J) :
∃ l, List.IsChain Zag (j₁ :: l) ∧ List.getLast (j₁ :: l) (List.cons_ne_nil _ _) = j₂ :=
List.exists_isChain_cons_of_relationReflTransGen (isPreconnected_zigzag _ _)
/-- If any two objects in a nonempty category are linked by a sequence of (potentially reversed)
morphisms, then J is connected.
The converse of `exists_zigzag'`.
-/
theorem isPreconnected_of_zigzag (h : ∀ j₁ j₂ : J, ∃ l,
List.IsChain Zag (j₁ :: l) ∧ List.getLast (j₁ :: l) (List.cons_ne_nil _ _) = j₂) :
IsPreconnected J := by
apply zigzag_isPreconnected
intro j₁ j₂
rcases h j₁ j₂ with ⟨l, hl₁, hl₂⟩
apply List.relationReflTransGen_of_exists_isChain_cons l hl₁ hl₂
/-- If any two objects in a nonempty category are linked by a sequence of (potentially reversed)
morphisms, then J is connected.
The converse of `exists_zigzag'`.
-/
theorem isConnected_of_zigzag [Nonempty J] (h : ∀ j₁ j₂ : J, ∃ l,
List.IsChain Zag (j₁ :: l) ∧ List.getLast (j₁ :: l) (List.cons_ne_nil _ _) = j₂) :
IsConnected J :=
{ isPreconnected_of_zigzag h with }
/-- If `Discrete α` is connected, then `α` is (type-)equivalent to `PUnit`. -/
def discreteIsConnectedEquivPUnit {α : Type u₁} [IsConnected (Discrete α)] : α ≃ PUnit :=
Discrete.equivOfEquivalence.{u₁, u₁}
{ functor := Functor.star (Discrete α)
inverse := Discrete.functor fun _ => Classical.arbitrary _
unitIso := isoConstant _ (Classical.arbitrary _)
counitIso := Functor.punitExt _ _ }
variable {C : Type w₂} [Category.{w₁} C]
/-- For objects `X Y : C`, any natural transformation `α : const X ⟶ const Y` from a connected
category must be constant.
This is the key property of connected categories which we use to establish properties about limits.
-/
theorem nat_trans_from_is_connected [IsPreconnected J] {X Y : C}
(α : (Functor.const J).obj X ⟶ (Functor.const J).obj Y) :
∀ j j' : J, α.app j = (α.app j' : X ⟶ Y) :=
@constant_of_preserves_morphisms _ _ _ (X ⟶ Y) (fun j => α.app j) fun _ _ f => by
simpa using (α.naturality f).symm
instance [IsConnected J] : (Functor.const J : C ⥤ J ⥤ C).Full where
map_surjective f := ⟨f.app (Classical.arbitrary J), by
ext j
apply nat_trans_from_is_connected f (Classical.arbitrary J) j⟩
theorem nonempty_hom_of_preconnected_groupoid {G} [Groupoid G] [IsPreconnected G] :
∀ x y : G, Nonempty (x ⟶ y) := by
refine equiv_relation _ ?_ fun {j₁ j₂} => Nonempty.intro
exact
⟨fun j => ⟨𝟙 _⟩,
fun {j₁ j₂} => Nonempty.map fun f => inv f,
fun {_ _ _} => Nonempty.map2 (· ≫ ·)⟩
attribute [instance] nonempty_hom_of_preconnected_groupoid
instance isPreconnected_of_subsingleton [Subsingleton J] : IsPreconnected J where
iso_constant {α} F j := ⟨NatIso.ofComponents (fun x ↦ eqToIso (by simp [Subsingleton.allEq x j]))⟩
instance isConnected_of_nonempty_and_subsingleton [Nonempty J] [Subsingleton J] :
IsConnected J where
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Elements.lean | import Mathlib.CategoryTheory.Comma.StructuredArrow.Basic
import Mathlib.CategoryTheory.Category.Cat
/-!
# The category of elements
This file defines the category of elements, also known as (a special case of) the Grothendieck
construction.
Given a functor `F : C ⥤ Type`, an object of `F.Elements` is a pair `(X : C, x : F.obj X)`.
A morphism `(X, x) ⟶ (Y, y)` is a morphism `f : X ⟶ Y` in `C`, so `F.map f` takes `x` to `y`.
## Implementation notes
This construction is equivalent to a special case of a comma construction, so this is mostly just a
more convenient API. We prove the equivalence in
`CategoryTheory.CategoryOfElements.structuredArrowEquivalence`.
## References
* [Emily Riehl, *Category Theory in Context*, Section 2.4][riehl2017]
* <https://en.wikipedia.org/wiki/Category_of_elements>
* <https://ncatlab.org/nlab/show/category+of+elements>
## Tags
category of elements, Grothendieck construction, comma category
-/
namespace CategoryTheory
universe w v u
variable {C : Type u} [Category.{v} C]
/-- The type of objects for the category of elements of a functor `F : C ⥤ Type`
is a pair `(X : C, x : F.obj X)`.
-/
def Functor.Elements (F : C ⥤ Type w) :=
Σ c : C, F.obj c
/-- Constructor for the type `F.Elements` when `F` is a functor to types. -/
abbrev Functor.elementsMk (F : C ⥤ Type w) (X : C) (x : F.obj X) : F.Elements := ⟨X, x⟩
lemma Functor.Elements.ext {F : C ⥤ Type w} (x y : F.Elements) (h₁ : x.fst = y.fst)
(h₂ : F.map (eqToHom h₁) x.snd = y.snd) : x = y := by
cases x
cases y
cases h₁
simp only [eqToHom_refl, FunctorToTypes.map_id_apply] at h₂
simp [h₂]
/-- The category structure on `F.Elements`, for `F : C ⥤ Type`.
A morphism `(X, x) ⟶ (Y, y)` is a morphism `f : X ⟶ Y` in `C`, so `F.map f` takes `x` to `y`. -/
instance categoryOfElements (F : C ⥤ Type w) : Category.{v} F.Elements where
Hom p q := { f : p.1 ⟶ q.1 // (F.map f) p.2 = q.2 }
id p := ⟨𝟙 p.1, by simp⟩
comp {X Y Z} f g := ⟨f.val ≫ g.val, by simp [f.2, g.2]⟩
/-- Natural transformations are mapped to functors between category of elements -/
@[simps]
def NatTrans.mapElements {F G : C ⥤ Type w} (φ : F ⟶ G) : F.Elements ⥤ G.Elements where
obj := fun ⟨X, x⟩ ↦ ⟨_, φ.app X x⟩
map {p q} := fun ⟨f, h⟩ ↦ ⟨f, by have hb := congrFun (φ.naturality f) p.2; cat_disch⟩
/-- The functor mapping functors `C ⥤ Type w` to their category of elements -/
@[simps]
def Functor.elementsFunctor : (C ⥤ Type w) ⥤ Cat where
obj F := Cat.of F.Elements
map n := NatTrans.mapElements n
namespace CategoryOfElements
/-- Constructor for morphisms in the category of elements of a functor to types. -/
@[simps]
def homMk {F : C ⥤ Type w} (x y : F.Elements) (f : x.1 ⟶ y.1) (hf : F.map f x.snd = y.snd) :
x ⟶ y :=
⟨f, hf⟩
@[ext]
theorem ext (F : C ⥤ Type w) {x y : F.Elements} (f g : x ⟶ y) (w : f.val = g.val) : f = g :=
Subtype.ext w
@[simp]
theorem comp_val {F : C ⥤ Type w} {p q r : F.Elements} {f : p ⟶ q} {g : q ⟶ r} :
(f ≫ g).val = f.val ≫ g.val :=
rfl
@[simp]
theorem id_val {F : C ⥤ Type w} {p : F.Elements} : (𝟙 p : p ⟶ p).val = 𝟙 p.1 :=
rfl
@[simp]
theorem map_snd {F : C ⥤ Type w} {p q : F.Elements} (f : p ⟶ q) : (F.map f.val) p.2 = q.2 :=
f.property
/-- Constructor for isomorphisms in the category of elements of a functor to types. -/
@[simps]
def isoMk {F : C ⥤ Type w} (x y : F.Elements) (e : x.1 ≅ y.1) (he : F.map e.hom x.snd = y.snd) :
x ≅ y where
hom := homMk x y e.hom he
inv := homMk y x e.inv (by rw [← he, FunctorToTypes.map_inv_map_hom_apply])
end CategoryOfElements
instance groupoidOfElements {G : Type u} [Groupoid.{v} G] (F : G ⥤ Type w) :
Groupoid F.Elements where
inv {p q} f :=
⟨Groupoid.inv f.val,
calc
F.map (Groupoid.inv f.val) q.2 = F.map (Groupoid.inv f.val) (F.map f.val p.2) := by rw [f.2]
_ = (F.map f.val ≫ F.map (Groupoid.inv f.val)) p.2 := rfl
_ = p.2 := by
rw [← F.map_comp]
simp
⟩
inv_comp _ := by
ext
simp
comp_inv _ := by
ext
simp
namespace CategoryOfElements
variable (F : C ⥤ Type w)
/-- The functor out of the category of elements which forgets the element. -/
@[simps]
def π : F.Elements ⥤ C where
obj X := X.1
map f := f.val
instance : (π F).Faithful where
instance : (π F).ReflectsIsomorphisms where
reflects {X Y} f h := ⟨⟨⟨inv ((π F).map f),
by rw [← map_snd f, ← FunctorToTypes.map_comp_apply]; simp⟩, by cat_disch⟩⟩
/-- A natural transformation between functors induces a functor between the categories of elements.
-/
@[simps]
def map {F₁ F₂ : C ⥤ Type w} (α : F₁ ⟶ F₂) : F₁.Elements ⥤ F₂.Elements where
obj t := ⟨t.1, α.app t.1 t.2⟩
map {t₁ t₂} k := ⟨k.1, by simpa [map_snd] using (FunctorToTypes.naturality _ _ α k.1 t₁.2).symm⟩
@[simp]
theorem map_π {F₁ F₂ : C ⥤ Type w} (α : F₁ ⟶ F₂) : map α ⋙ π F₂ = π F₁ :=
rfl
/-- The forward direction of the equivalence `F.Elements ≅ (*, F)`. -/
def toStructuredArrow : F.Elements ⥤ StructuredArrow PUnit F where
obj X := StructuredArrow.mk fun _ => X.2
map {X Y} f := StructuredArrow.homMk f.val (by funext; simp [f.2])
@[simp]
theorem toStructuredArrow_obj (X) :
(toStructuredArrow F).obj X =
{ left := ⟨⟨⟩⟩
right := X.1
hom := fun _ => X.2 } :=
rfl
@[simp]
theorem to_comma_map_right {X Y} (f : X ⟶ Y) : ((toStructuredArrow F).map f).right = f.val :=
rfl
/-- The reverse direction of the equivalence `F.Elements ≅ (*, F)`. -/
def fromStructuredArrow : StructuredArrow PUnit F ⥤ F.Elements where
obj X := ⟨X.right, X.hom PUnit.unit⟩
map f := ⟨f.right, congr_fun f.w.symm PUnit.unit⟩
@[simp]
theorem fromStructuredArrow_obj (X) : (fromStructuredArrow F).obj X = ⟨X.right, X.hom PUnit.unit⟩ :=
rfl
@[simp]
theorem fromStructuredArrow_map {X Y} (f : X ⟶ Y) :
(fromStructuredArrow F).map f = ⟨f.right, congr_fun f.w.symm PUnit.unit⟩ :=
rfl
/-- The equivalence between the category of elements `F.Elements`
and the comma category `(*, F)`. -/
@[simps]
def structuredArrowEquivalence : F.Elements ≌ StructuredArrow PUnit F where
functor := toStructuredArrow F
inverse := fromStructuredArrow F
unitIso := Iso.refl _
counitIso := Iso.refl _
open Opposite
/-- The forward direction of the equivalence `F.Elementsᵒᵖ ≅ (yoneda, F)`,
given by `CategoryTheory.yonedaEquiv`.
-/
@[simps]
def toCostructuredArrow (F : Cᵒᵖ ⥤ Type v) : F.Elementsᵒᵖ ⥤ CostructuredArrow yoneda F where
obj X := CostructuredArrow.mk (yonedaEquiv.symm (unop X).2)
map f :=
CostructuredArrow.homMk f.unop.val.unop (by
ext Z y
dsimp [yonedaEquiv]
simp only [FunctorToTypes.map_comp_apply, ← f.unop.2])
/-- The reverse direction of the equivalence `F.Elementsᵒᵖ ≅ (yoneda, F)`,
given by `CategoryTheory.yonedaEquiv`.
-/
@[simps]
def fromCostructuredArrow (F : Cᵒᵖ ⥤ Type v) : (CostructuredArrow yoneda F)ᵒᵖ ⥤ F.Elements where
obj X := ⟨op (unop X).1, yonedaEquiv.1 (unop X).3⟩
map {X Y} f :=
⟨f.unop.1.op, by
convert (congr_fun ((unop X).hom.naturality f.unop.left.op) (𝟙 _)).symm
simp only [Equiv.toFun_as_coe, Quiver.Hom.unop_op, yonedaEquiv_apply, types_comp_apply,
Category.comp_id, yoneda_obj_map]
have : yoneda.map f.unop.left ≫ (unop X).hom = (unop Y).hom := by
convert f.unop.3
rw [← this]
simp only [yoneda_map_app, FunctorToTypes.comp]
rw [Category.id_comp]⟩
@[simp]
theorem fromCostructuredArrow_obj_mk (F : Cᵒᵖ ⥤ Type v) {X : C} (f : yoneda.obj X ⟶ F) :
(fromCostructuredArrow F).obj (op (CostructuredArrow.mk f)) = ⟨op X, yonedaEquiv.1 f⟩ :=
rfl
/-- The equivalence `F.Elementsᵒᵖ ≅ (yoneda, F)` given by yoneda lemma. -/
@[simps]
def costructuredArrowYonedaEquivalence (F : Cᵒᵖ ⥤ Type v) :
F.Elementsᵒᵖ ≌ CostructuredArrow yoneda F where
functor := toCostructuredArrow F
inverse := (fromCostructuredArrow F).rightOp
unitIso :=
NatIso.ofComponents
(fun X ↦ Iso.op (CategoryOfElements.isoMk _ _ (Iso.refl _) (by simp))) (by
rintro ⟨x⟩ ⟨y⟩ ⟨f : y ⟶ x⟩
exact Quiver.Hom.unop_inj (by ext; simp))
counitIso := NatIso.ofComponents (fun X ↦ CostructuredArrow.isoMk (Iso.refl _))
/-- The equivalence `(-.Elements)ᵒᵖ ≅ (yoneda, -)` of is actually a natural isomorphism of functors.
-/
theorem costructuredArrow_yoneda_equivalence_naturality {F₁ F₂ : Cᵒᵖ ⥤ Type v} (α : F₁ ⟶ F₂) :
(map α).op ⋙ toCostructuredArrow F₂ = toCostructuredArrow F₁ ⋙ CostructuredArrow.map α := by
fapply Functor.ext
· intro X
simp only [CostructuredArrow.map_mk, toCostructuredArrow_obj, Functor.op_obj,
Functor.comp_obj]
congr
ext _ f
simpa using congr_fun (α.naturality f.op).symm (unop X).snd
· simp
/-- The equivalence `F.elementsᵒᵖ ≌ (yoneda, F)` is compatible with the forgetful functors. -/
@[simps!]
def costructuredArrowYonedaEquivalenceFunctorProj (F : Cᵒᵖ ⥤ Type v) :
(costructuredArrowYonedaEquivalence F).functor ⋙ CostructuredArrow.proj _ _ ≅ (π F).leftOp :=
Iso.refl _
/-- The equivalence `F.elementsᵒᵖ ≌ (yoneda, F)` is compatible with the forgetful functors. -/
@[simps!]
def costructuredArrowYonedaEquivalenceInverseπ (F : Cᵒᵖ ⥤ Type v) :
(costructuredArrowYonedaEquivalence F).inverse ⋙ (π F).leftOp ≅ CostructuredArrow.proj _ _ :=
Iso.refl _
/-- The opposite of the category of elements of a presheaf of types
is equivalent to a category of costructured arrows for the Yoneda embedding functor. -/
@[simps]
def costructuredArrowULiftYonedaEquivalence (F : Cᵒᵖ ⥤ Type max w v) :
F.Elementsᵒᵖ ≌ CostructuredArrow uliftYoneda.{w} F where
functor :=
{ obj x := CostructuredArrow.mk (uliftYonedaEquiv.{w}.symm x.unop.2)
map f := CostructuredArrow.homMk f.1.1.unop (by
dsimp
rw [← uliftYonedaEquiv_symm_map, map_snd]) }
inverse :=
{ obj X := op (F.elementsMk _ (uliftYonedaEquiv.{w} X.hom))
map f := (homMk _ _ f.left.op (by
dsimp
rw [← CostructuredArrow.w f, uliftYonedaEquiv_naturality, Quiver.Hom.unop_op])).op }
unitIso := NatIso.ofComponents (fun x ↦ Iso.op (isoMk _ _ (Iso.refl _) (by simp)))
(fun f ↦ Quiver.Hom.unop_inj (by aesop))
counitIso := NatIso.ofComponents (fun X ↦ CostructuredArrow.isoMk (Iso.refl _))
/-- The equivalence of categories `costructuredArrowULiftYonedaEquivalence`
commutes with the projections. -/
def costructuredArrowULiftYonedaEquivalenceFunctorCompProjIso (F : Cᵒᵖ ⥤ Type max w v) :
(costructuredArrowULiftYonedaEquivalence.{w} F).functor ⋙ CostructuredArrow.proj _ _ ≅
(π F).leftOp :=
Iso.refl _
end CategoryOfElements
namespace Functor
/--
The initial object in the category of elements for a representable functor. In `isInitial` it is
shown that this is initial.
-/
def Elements.initial (A : C) : (yoneda.obj A).Elements :=
⟨Opposite.op A, 𝟙 _⟩
/-- Show that `Elements.initial A` is initial in the category of elements for the `yoneda` functor.
-/
def Elements.isInitial (A : C) : Limits.IsInitial (Elements.initial A) where
desc s := ⟨s.pt.2.op, Category.comp_id _⟩
uniq s m _ := by
simp_rw [← m.2]
dsimp [Elements.initial]
simp
fac := by rintro s ⟨⟨⟩⟩
end Functor
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/DifferentialObject.lean | import Mathlib.Algebra.Group.Basic
import Mathlib.Data.Int.Cast.Defs
import Mathlib.CategoryTheory.Shift.Basic
import Mathlib.CategoryTheory.ConcreteCategory.Basic
/-!
# Differential objects in a category.
A differential object in a category with zero morphisms and a shift is
an object `X` equipped with
a morphism `d : obj ⟶ obj⟦1⟧`, such that `d^2 = 0`.
We build the category of differential objects, and some basic constructions
such as the forgetful functor, zero morphisms and zero objects, and the shift functor
on differential objects.
-/
open CategoryTheory.Limits
universe v u
namespace CategoryTheory
variable (S : Type*) [AddMonoidWithOne S] (C : Type u) [Category.{v} C]
variable [HasZeroMorphisms C] [HasShift C S]
/-- A differential object in a category with zero morphisms and a shift is
an object `obj` equipped with
a morphism `d : obj ⟶ obj⟦1⟧`, such that `d^2 = 0`. -/
structure DifferentialObject where
/-- The underlying object of a differential object. -/
obj : C
/-- The differential of a differential object. -/
d : obj ⟶ obj⟦(1 : S)⟧
/-- The differential `d` satisfies that `d² = 0`. -/
d_squared : d ≫ d⟦(1 : S)⟧' = 0 := by cat_disch
attribute [reassoc (attr := simp)] DifferentialObject.d_squared
variable {S C}
namespace DifferentialObject
/-- A morphism of differential objects is a morphism commuting with the differentials. -/
@[ext]
structure Hom (X Y : DifferentialObject S C) where
/-- The morphism between underlying objects of the two differentiable objects. -/
f : X.obj ⟶ Y.obj
comm : X.d ≫ f⟦1⟧' = f ≫ Y.d := by cat_disch
attribute [reassoc (attr := simp)] Hom.comm
namespace Hom
/-- The identity morphism of a differential object. -/
@[simps]
def id (X : DifferentialObject S C) : Hom X X where
f := 𝟙 X.obj
/-- The composition of morphisms of differential objects. -/
@[simps]
def comp {X Y Z : DifferentialObject S C} (f : Hom X Y) (g : Hom Y Z) : Hom X Z where
f := f.f ≫ g.f
end Hom
instance categoryOfDifferentialObjects : Category (DifferentialObject S C) where
Hom := Hom
id := Hom.id
comp f g := Hom.comp f g
@[ext]
theorem ext {A B : DifferentialObject S C} {f g : A ⟶ B} (w : f.f = g.f := by cat_disch) : f = g :=
Hom.ext w
@[simp]
theorem id_f (X : DifferentialObject S C) : (𝟙 X : X ⟶ X).f = 𝟙 X.obj := rfl
@[simp]
theorem comp_f {X Y Z : DifferentialObject S C} (f : X ⟶ Y) (g : Y ⟶ Z) :
(f ≫ g).f = f.f ≫ g.f :=
rfl
@[simp]
theorem eqToHom_f {X Y : DifferentialObject S C} (h : X = Y) :
Hom.f (eqToHom h) = eqToHom (congr_arg _ h) := by
subst h
rw [eqToHom_refl, eqToHom_refl]
rfl
variable (S C)
/-- The forgetful functor taking a differential object to its underlying object. -/
def forget : DifferentialObject S C ⥤ C where
obj X := X.obj
map f := f.f
instance forget_faithful : (forget S C).Faithful where
variable {S C}
section
variable [(shiftFunctor C (1 : S)).PreservesZeroMorphisms]
instance {X Y : DifferentialObject S C} : Zero (X ⟶ Y) := ⟨{f := 0}⟩
@[simp]
theorem zero_f (P Q : DifferentialObject S C) : (0 : P ⟶ Q).f = 0 := rfl
instance hasZeroMorphisms : HasZeroMorphisms (DifferentialObject S C) where
end
/-- An isomorphism of differential objects gives an isomorphism of the underlying objects. -/
@[simps]
def isoApp {X Y : DifferentialObject S C} (f : X ≅ Y) : X.obj ≅ Y.obj where
hom := f.hom.f
inv := f.inv.f
hom_inv_id := by rw [← comp_f, Iso.hom_inv_id, id_f]
inv_hom_id := by rw [← comp_f, Iso.inv_hom_id, id_f]
@[simp]
theorem isoApp_refl (X : DifferentialObject S C) : isoApp (Iso.refl X) = Iso.refl X.obj := rfl
@[simp]
theorem isoApp_symm {X Y : DifferentialObject S C} (f : X ≅ Y) : isoApp f.symm = (isoApp f).symm :=
rfl
@[simp]
theorem isoApp_trans {X Y Z : DifferentialObject S C} (f : X ≅ Y) (g : Y ≅ Z) :
isoApp (f ≪≫ g) = isoApp f ≪≫ isoApp g := rfl
/-- An isomorphism of differential objects can be constructed
from an isomorphism of the underlying objects that commutes with the differentials. -/
@[simps]
def mkIso {X Y : DifferentialObject S C} (f : X.obj ≅ Y.obj) (hf : X.d ≫ f.hom⟦1⟧' = f.hom ≫ Y.d) :
X ≅ Y where
hom := ⟨f.hom, hf⟩
inv := ⟨f.inv, by
rw [← Functor.mapIso_inv, Iso.comp_inv_eq, Category.assoc, Iso.eq_inv_comp, Functor.mapIso_hom,
hf]⟩
hom_inv_id := by ext1; dsimp; exact f.hom_inv_id
inv_hom_id := by ext1; dsimp; exact f.inv_hom_id
end DifferentialObject
namespace Functor
universe v' u'
variable (D : Type u') [Category.{v'} D]
variable [HasZeroMorphisms D] [HasShift D S]
/-- A functor `F : C ⥤ D` which commutes with shift functors on `C` and `D` and preserves zero
morphisms can be lifted to a functor `DifferentialObject S C ⥤ DifferentialObject S D`. -/
@[simps]
def mapDifferentialObject (F : C ⥤ D)
(η : (shiftFunctor C (1 : S)).comp F ⟶ F.comp (shiftFunctor D (1 : S)))
(hF : ∀ c c', F.map (0 : c ⟶ c') = 0) : DifferentialObject S C ⥤ DifferentialObject S D where
obj X :=
{ obj := F.obj X.obj
d := F.map X.d ≫ η.app X.obj
d_squared := by
rw [Functor.map_comp, ← Functor.comp_map F (shiftFunctor D (1 : S))]
slice_lhs 2 3 => rw [← η.naturality X.d]
rw [Functor.comp_map]
slice_lhs 1 2 => rw [← F.map_comp, X.d_squared, hF]
rw [zero_comp, zero_comp] }
map f :=
{ f := F.map f.f
comm := by
dsimp
slice_lhs 2 3 => rw [← Functor.comp_map F (shiftFunctor D (1 : S)), ← η.naturality f.f]
slice_lhs 1 2 => rw [Functor.comp_map, ← F.map_comp, f.comm, F.map_comp]
rw [Category.assoc] }
map_id := by intros; ext; simp
map_comp := by intros; ext; simp
end Functor
end CategoryTheory
namespace CategoryTheory
namespace DifferentialObject
variable (S : Type*) [AddMonoidWithOne S] (C : Type u) [Category.{v} C]
variable [HasZeroObject C] [HasZeroMorphisms C] [HasShift C S]
variable [(shiftFunctor C (1 : S)).PreservesZeroMorphisms]
open scoped ZeroObject
instance hasZeroObject : HasZeroObject (DifferentialObject S C) where
zero := ⟨{ obj := 0, d := 0 },
{ unique_to := fun X => ⟨⟨⟨{ f := 0 }⟩, fun f => by ext⟩⟩,
unique_from := fun X => ⟨⟨⟨{ f := 0 }⟩, fun f => by ext⟩⟩ }⟩
end DifferentialObject
namespace DifferentialObject
section HasForget
variable (S : Type*) [AddMonoidWithOne S]
variable (C : Type (u + 1)) [LargeCategory C] [HasForget C] [HasZeroMorphisms C]
variable [HasShift C S]
instance hasForgetOfDifferentialObjects : HasForget (DifferentialObject S C) where
forget := forget S C ⋙ CategoryTheory.forget C
instance : HasForget₂ (DifferentialObject S C) C where
forget₂ := forget S C
end HasForget
section ConcreteCategory
variable (S : Type*) [AddMonoidWithOne S]
variable (C : Type (u + 1)) [LargeCategory C] [HasZeroMorphisms C]
variable {FC : C → C → Type*} {CC : C → Type*} [∀ X Y, FunLike (FC X Y) (CC X) (CC Y)]
variable [ConcreteCategory C FC] [HasShift C S]
/--
The type of `C`-morphisms that can be lifted back to morphisms in the category `DifferentialObject`.
-/
abbrev HomSubtype (X Y : DifferentialObject S C) :=
{ f : FC X.obj Y.obj // X.d ≫ (ConcreteCategory.ofHom f)⟦1⟧' = (ConcreteCategory.ofHom f) ≫ Y.d }
instance (X Y : DifferentialObject S C) :
FunLike (HomSubtype S C X Y) (CC X.obj) (CC Y.obj) where
coe f := f.1
coe_injective' _ _ h := Subtype.ext (DFunLike.coe_injective h)
instance concreteCategoryOfDifferentialObjects :
ConcreteCategory (DifferentialObject S C) (HomSubtype S C) where
hom f := ⟨ConcreteCategory.hom (C := C) f.1, by simp [ConcreteCategory.ofHom_hom]⟩
ofHom f := ⟨ConcreteCategory.ofHom (C := C) f, by simpa [ConcreteCategory.hom_ofHom] using f.2⟩
hom_ofHom _ := by dsimp; ext; simp [ConcreteCategory.hom_ofHom]
ofHom_hom _ := by ext; simp [ConcreteCategory.ofHom_hom]
id_apply := ConcreteCategory.id_apply (C := C)
comp_apply _ _ := ConcreteCategory.comp_apply (C := C) _ _
end ConcreteCategory
end DifferentialObject
/-! The category of differential objects itself has a shift functor. -/
namespace DifferentialObject
variable {S : Type*} [AddCommGroupWithOne S] (C : Type u) [Category.{v} C]
variable [HasZeroMorphisms C] [HasShift C S]
noncomputable section
/-- The shift functor on `DifferentialObject S C`. -/
@[simps]
def shiftFunctor (n : S) : DifferentialObject S C ⥤ DifferentialObject S C where
obj X :=
{ obj := X.obj⟦n⟧
d := X.d⟦n⟧' ≫ (shiftComm _ _ _).hom
d_squared := by
rw [Functor.map_comp, Category.assoc, shiftComm_hom_comp_assoc, ← Functor.map_comp_assoc,
X.d_squared, Functor.map_zero, zero_comp] }
map f :=
{ f := f.f⟦n⟧'
comm := by
dsimp
rw [Category.assoc]
erw [shiftComm_hom_comp]
rw [← Functor.map_comp_assoc, f.comm, Functor.map_comp_assoc]
rfl }
map_id X := by ext1; dsimp; rw [Functor.map_id]
map_comp f g := by ext1; dsimp; rw [Functor.map_comp]
/-- The shift functor on `DifferentialObject S C` is additive. -/
@[simps!]
nonrec def shiftFunctorAdd (m n : S) :
shiftFunctor C (m + n) ≅ shiftFunctor C m ⋙ shiftFunctor C n := by
refine NatIso.ofComponents (fun X => mkIso (shiftAdd X.obj _ _) ?_) (fun f => ?_)
· dsimp
rw [← cancel_epi ((shiftFunctorAdd C m n).inv.app X.obj)]
simp only [Category.assoc, Iso.inv_hom_id_app_assoc]
rw [← NatTrans.naturality_assoc]
dsimp
simp only [Functor.map_comp, Category.assoc,
shiftFunctorComm_hom_app_comp_shift_shiftFunctorAdd_hom_app 1 m n X.obj,
Iso.inv_hom_id_app_assoc]
· ext; dsimp; exact NatTrans.naturality _ _
section
/-- The shift by zero is naturally isomorphic to the identity. -/
@[simps!]
def shiftZero : shiftFunctor C (0 : S) ≅ 𝟭 (DifferentialObject S C) := by
refine NatIso.ofComponents (fun X => mkIso ((shiftFunctorZero C S).app X.obj) ?_) (fun f => ?_)
· erw [← NatTrans.naturality]
dsimp
simp only [shiftFunctorZero_hom_app_shift, Category.assoc]
· cat_disch
end
instance : HasShift (DifferentialObject S C) S :=
hasShiftMk _ _
{ F := shiftFunctor C
zero := shiftZero C
add := shiftFunctorAdd C
assoc_hom_app := fun m₁ m₂ m₃ X => by
ext1
convert shiftFunctorAdd_assoc_hom_app m₁ m₂ m₃ X.obj
dsimp [shiftFunctorAdd']
simp
zero_add_hom_app := fun n X => by
ext1
convert shiftFunctorAdd_zero_add_hom_app n X.obj
simp
add_zero_hom_app := fun n X => by
ext1
convert shiftFunctorAdd_add_zero_hom_app n X.obj
simp }
end
end DifferentialObject
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Noetherian.lean | import Mathlib.CategoryTheory.Subobject.ArtinianObject
import Mathlib.CategoryTheory.Subobject.NoetherianObject
/-!
# Artinian and Noetherian categories
An Artinian category is a category in which objects do not
have infinite decreasing sequences of subobjects.
A Noetherian category is a category in which objects do not
have infinite increasing sequences of subobjects.
Note: In the file, `CategoryTheory.Subobject.ArtinianObject`,
it is shown that any nonzero Artinian object has a simple subobject.
## Future work
The Jordan-Hölder theorem, following https://stacks.math.columbia.edu/tag/0FCK.
-/
namespace CategoryTheory
open CategoryTheory.Limits
@[deprecated (since := "2025-07-11")] alias NoetherianObject := IsNoetherianObject
@[deprecated (since := "2025-07-11")] alias ArtinianObject := IsArtinianObject
variable (C : Type*) [Category C]
/-- A category is Noetherian if it is essentially small and all objects are Noetherian. -/
class Noetherian : Prop extends EssentiallySmall C where
isNoetherianObject : ∀ X : C, IsNoetherianObject X
attribute [instance] Noetherian.isNoetherianObject
/-- A category is Artinian if it is essentially small and all objects are Artinian. -/
class Artinian : Prop extends EssentiallySmall C where
isArtinianObject : ∀ X : C, IsArtinianObject X
attribute [instance] Artinian.isArtinianObject
open Subobject
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Countable.lean | import Mathlib.CategoryTheory.EssentiallySmall
import Mathlib.CategoryTheory.FinCategory.Basic
import Mathlib.Data.Fintype.EquivFin
import Mathlib.Data.Countable.Small
/-!
# Countable categories
A category is countable in this sense if it has countably many objects and countably many morphisms.
-/
universe w v u
noncomputable section
namespace CategoryTheory
instance discreteCountable {α : Type*} [Countable α] : Countable (Discrete α) :=
Countable.of_equiv α discreteEquiv.symm
/-- A category with countably many objects and morphisms. -/
class CountableCategory (J : Type*) [Category J] : Prop where
countableObj : Countable J := by infer_instance
countableHom : ∀ j j' : J, Countable (j ⟶ j') := by infer_instance
attribute [instance] CountableCategory.countableObj CountableCategory.countableHom
instance countableCategoryDiscreteOfCountable (J : Type*) [Countable J] :
CountableCategory (Discrete J) where
instance : CountableCategory ℕ where
namespace CountableCategory
variable (α : Type u) [Category.{v} α] [CountableCategory α]
/-- A countable category `α` is equivalent to a category with objects in `Type`. -/
abbrev ObjAsType : Type :=
InducedCategory α (equivShrink.{0} α).symm
instance : Countable (ObjAsType α) := Countable.of_equiv α (equivShrink.{0} α)
instance {i j : ObjAsType α} : Countable (i ⟶ j) :=
CountableCategory.countableHom ((equivShrink.{0} α).symm i) _
instance : CountableCategory (ObjAsType α) where
/-- The constructed category is indeed equivalent to `α`. -/
noncomputable def objAsTypeEquiv : ObjAsType α ≌ α :=
(inducedFunctor (equivShrink.{0} α).symm).asEquivalence
/-- A countable category `α` is equivalent to a *small* category with objects in `Type`. -/
def HomAsType := ShrinkHoms (ObjAsType α)
instance : LocallySmall.{0} (ObjAsType α) where
hom_small _ _ := inferInstance
instance : SmallCategory (HomAsType α) := inferInstanceAs <| SmallCategory (ShrinkHoms _)
instance : Countable (HomAsType α) := Countable.of_equiv α (equivShrink.{0} α)
instance {i j : HomAsType α} : Countable (i ⟶ j) :=
Countable.of_equiv ((ShrinkHoms.equivalence _).inverse.obj i ⟶
(ShrinkHoms.equivalence _).inverse.obj j)
(Functor.FullyFaithful.ofFullyFaithful _).homEquiv.symm
instance : CountableCategory (HomAsType α) where
/-- The constructed category is indeed equivalent to `α`. -/
noncomputable def homAsTypeEquiv : HomAsType α ≌ α :=
(ShrinkHoms.equivalence _).symm.trans (objAsTypeEquiv _)
end CountableCategory
instance (α : Type*) [Category α] [FinCategory α] : CountableCategory α where
open Opposite
/-- The opposite of a countable category is countable. -/
instance countableCategoryOpposite {J : Type*} [Category J] [CountableCategory J] :
CountableCategory Jᵒᵖ where
countableObj := Countable.of_equiv _ equivToOpposite
countableHom j j' := Countable.of_equiv _ (opEquiv j j').symm
attribute [local instance] uliftCategory in
/-- Applying `ULift` to morphisms and objects of a category preserves countability. -/
instance countableCategoryUlift {J : Type v} [Category J] [CountableCategory J] :
CountableCategory.{max w v} (ULiftHom.{w, max w v} (ULift.{w, v} J)) where
countableObj := instCountableULift
countableHom := fun i j =>
have : Countable ((ULiftHom.objDown i).down ⟶ (ULiftHom.objDown j).down) := inferInstance
instCountableULift
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/FintypeCat.lean | import Mathlib.CategoryTheory.ConcreteCategory.Basic
import Mathlib.CategoryTheory.Endomorphism
import Mathlib.CategoryTheory.Skeletal
import Mathlib.Data.Finite.Prod
/-!
# The category of finite types.
We define the category of finite types, denoted `FintypeCat` as
(bundled) types with a `Fintype` instance.
We also define `FintypeCat.Skeleton`, the standard skeleton of `FintypeCat` whose objects
are `Fin n` for `n : ℕ`. We prove that the obvious inclusion functor
`FintypeCat.Skeleton ⥤ FintypeCat` is an equivalence of categories in
`FintypeCat.Skeleton.equivalence`.
We prove that `FintypeCat.Skeleton` is a skeleton of `FintypeCat` in `FintypeCat.isSkeleton`.
-/
open CategoryTheory
/-- The category of finite types. -/
structure FintypeCat where
/-- Construct a bundled `FintypeCat` from the underlying type and typeclass. -/
of ::
/-- The underlying type. -/
carrier : Type*
[str : Fintype carrier]
attribute [instance] FintypeCat.str
namespace FintypeCat
instance instCoeSort : CoeSort FintypeCat Type* :=
⟨carrier⟩
instance : Inhabited FintypeCat :=
⟨of PEmpty⟩
instance {X : FintypeCat} : Fintype X :=
X.2
instance : Category FintypeCat :=
InducedCategory.category carrier
/-- The fully faithful embedding of `FintypeCat` into the category of types. -/
@[simps!]
def incl : FintypeCat ⥤ Type* :=
inducedFunctor _
instance : incl.Full := InducedCategory.full _
instance : incl.Faithful := InducedCategory.faithful _
instance (X Y : FintypeCat) : FunLike (X ⟶ Y) X Y where
coe f := f
coe_injective' _ _ h := h
instance concreteCategoryFintype : ConcreteCategory FintypeCat (· ⟶ ·) where
hom f := f
ofHom f := f
/- Help typeclass inference infer fullness of forgetful functor. -/
instance : (forget FintypeCat).Full := inferInstanceAs <| FintypeCat.incl.Full
@[simp]
theorem id_apply (X : FintypeCat) (x : X) : (𝟙 X : X → X) x = x :=
rfl
@[simp]
theorem comp_apply {X Y Z : FintypeCat} (f : X ⟶ Y) (g : Y ⟶ Z) (x : X) : (f ≫ g) x = g (f x) :=
rfl
-- Isn't `@[simp]` because `simp` can prove it after importing `Mathlib.CategoryTheory.Elementwise`.
lemma hom_inv_id_apply {X Y : FintypeCat} (f : X ≅ Y) (x : X) : f.inv (f.hom x) = x :=
congr_fun f.hom_inv_id x
-- Isn't `@[simp]` because `simp` can prove it after importing `Mathlib.CategoryTheory.Elementwise`.
lemma inv_hom_id_apply {X Y : FintypeCat} (f : X ≅ Y) (y : Y) : f.hom (f.inv y) = y :=
congr_fun f.inv_hom_id y
@[ext]
lemma hom_ext {X Y : FintypeCat} (f g : X ⟶ Y) (h : ∀ x, f x = g x) : f = g := by
funext
apply h
-- See `equivEquivIso` in the root namespace for the analogue in `Type`.
/-- Equivalences between finite types are the same as isomorphisms in `FintypeCat`. -/
@[simps]
def equivEquivIso {A B : FintypeCat} : A ≃ B ≃ (A ≅ B) where
toFun e :=
{ hom := e
inv := e.symm }
invFun i :=
{ toFun := i.hom
invFun := i.inv
left_inv := congr_fun i.hom_inv_id
right_inv := congr_fun i.inv_hom_id }
left_inv := by cat_disch
right_inv := by cat_disch
instance (X Y : FintypeCat) : Finite (X ⟶ Y) :=
inferInstanceAs <| Finite (X → Y)
instance (X Y : FintypeCat) : Finite (X ≅ Y) :=
Finite.of_injective _ (fun _ _ h ↦ Iso.ext h)
instance (X : FintypeCat) : Finite (Aut X) :=
inferInstanceAs <| Finite (X ≅ X)
universe u
/--
The "standard" skeleton for `FintypeCat`. This is the full subcategory of `FintypeCat`
spanned by objects of the form `ULift (Fin n)` for `n : ℕ`. We parameterize the objects
of `Fintype.Skeleton` directly as `ULift ℕ`, as the type `ULift (Fin m) ≃ ULift (Fin n)`
is nonempty if and only if `n = m`. Specifying universes, `Skeleton : Type u` is a small
skeletal category equivalent to `Fintype.{u}`.
-/
def Skeleton : Type u :=
ULift ℕ
namespace Skeleton
/-- Given any natural number `n`, this creates the associated object of `Fintype.Skeleton`. -/
def mk : ℕ → Skeleton :=
ULift.up
instance : Inhabited Skeleton :=
⟨mk 0⟩
/-- Given any object of `Fintype.Skeleton`, this returns the associated natural number. -/
def len : Skeleton → ℕ :=
ULift.down
@[ext]
theorem ext (X Y : Skeleton) : X.len = Y.len → X = Y :=
ULift.ext _ _
instance : SmallCategory Skeleton.{u} where
Hom X Y := ULift.{u} (Fin X.len) → ULift.{u} (Fin Y.len)
id _ := id
comp f g := g ∘ f
theorem is_skeletal : Skeletal Skeleton.{u} := fun X Y ⟨h⟩ =>
ext _ _ <|
Fin.equiv_iff_eq.mp <|
Nonempty.intro <|
{ toFun := fun x => (h.hom ⟨x⟩).down
invFun := fun x => (h.inv ⟨x⟩).down
left_inv := by
intro a
change ULift.down _ = _
rw [ULift.up_down]
change ((h.hom ≫ h.inv) _).down = _
simp
rfl
right_inv := by
intro a
change ULift.down _ = _
rw [ULift.up_down]
change ((h.inv ≫ h.hom) _).down = _
simp
rfl }
/-- The canonical fully faithful embedding of `Fintype.Skeleton` into `FintypeCat`. -/
def incl : Skeleton.{u} ⥤ FintypeCat.{u} where
obj X := FintypeCat.of (ULift (Fin X.len))
map f := f
instance : incl.Full where map_surjective f := ⟨f, rfl⟩
instance : incl.Faithful where
instance : incl.EssSurj :=
Functor.EssSurj.mk fun X =>
let F := Fintype.equivFin X
⟨mk (Fintype.card X),
Nonempty.intro
{ hom := F.symm ∘ ULift.down
inv := ULift.up ∘ F }⟩
noncomputable instance : incl.IsEquivalence where
/-- The equivalence between `Fintype.Skeleton` and `Fintype`. -/
noncomputable def equivalence : Skeleton ≌ FintypeCat :=
incl.asEquivalence
@[simp]
theorem incl_mk_nat_card (n : ℕ) : Fintype.card (incl.obj (mk n)) = n := by
convert Finset.card_fin n
apply Fintype.ofEquiv_card
end Skeleton
/-- `Fintype.Skeleton` is a skeleton of `Fintype`. -/
lemma isSkeleton : IsSkeletonOf FintypeCat Skeleton Skeleton.incl where
skel := Skeleton.is_skeletal
eqv := by infer_instance
section Universes
universe v
/-- If `u` and `v` are two arbitrary universes, we may construct a functor
`uSwitch.{u, v} : FintypeCat.{u} ⥤ FintypeCat.{v}` by sending
`X : FintypeCat.{u}` to `ULift.{v} (Fin (Fintype.card X))`. -/
noncomputable def uSwitch : FintypeCat.{u} ⥤ FintypeCat.{v} where
obj X := FintypeCat.of <| ULift.{v} (Fin (Fintype.card X))
map {X Y} f x := ULift.up <| (Fintype.equivFin Y) (f ((Fintype.equivFin X).symm x.down))
map_comp {X Y Z} f g := by funext; simp
/-- Switching the universe of an object `X : FintypeCat.{u}` does not change `X` up to equivalence
of types. This is natural in the sense that it commutes with `uSwitch.map f` for
any `f : X ⟶ Y` in `FintypeCat.{u}`. -/
noncomputable def uSwitchEquiv (X : FintypeCat.{u}) :
uSwitch.{u, v}.obj X ≃ X :=
Equiv.ulift.trans (Fintype.equivFin X).symm
lemma uSwitchEquiv_naturality {X Y : FintypeCat.{u}} (f : X ⟶ Y)
(x : uSwitch.{u, v}.obj X) :
f (X.uSwitchEquiv x) = Y.uSwitchEquiv (uSwitch.map f x) := by
simp only [uSwitch, uSwitchEquiv, Equiv.trans_apply, Equiv.ulift_apply, Equiv.symm_apply_apply]
lemma uSwitchEquiv_symm_naturality {X Y : FintypeCat.{u}} (f : X ⟶ Y) (x : X) :
uSwitch.map f (X.uSwitchEquiv.symm x) = Y.uSwitchEquiv.symm (f x) := by
rw [← Equiv.apply_eq_iff_eq_symm_apply, ← uSwitchEquiv_naturality f,
Equiv.apply_symm_apply]
lemma uSwitch_map_uSwitch_map {X Y : FintypeCat.{u}} (f : X ⟶ Y) :
uSwitch.map (uSwitch.map f) =
(equivEquivIso ((uSwitch.obj X).uSwitchEquiv.trans X.uSwitchEquiv)).hom ≫
f ≫ (equivEquivIso ((uSwitch.obj Y).uSwitchEquiv.trans
Y.uSwitchEquiv)).inv := rfl
/-- `uSwitch.{u, v}` is an equivalence of categories with quasi-inverse `uSwitch.{v, u}`. -/
noncomputable def uSwitchEquivalence : FintypeCat.{u} ≌ FintypeCat.{v} where
functor := uSwitch
inverse := uSwitch
unitIso := NatIso.ofComponents (fun X ↦ (equivEquivIso <|
(uSwitch.obj X).uSwitchEquiv.trans X.uSwitchEquiv).symm) <| by
simp [uSwitch_map_uSwitch_map]
counitIso := NatIso.ofComponents (fun X ↦ equivEquivIso <|
(uSwitch.obj X).uSwitchEquiv.trans X.uSwitchEquiv) <| by
simp [uSwitch_map_uSwitch_map]
functor_unitIso_comp X := by
ext x
simp [← uSwitchEquiv_naturality]
instance : uSwitch.IsEquivalence :=
uSwitchEquivalence.isEquivalence_functor
end Universes
end FintypeCat
namespace FunctorToFintypeCat
universe u v w
variable {C : Type u} [Category.{v} C] (F G : C ⥤ FintypeCat.{w}) {X Y : C}
lemma naturality (σ : F ⟶ G) (f : X ⟶ Y) (x : F.obj X) :
σ.app Y (F.map f x) = G.map f (σ.app X x) :=
congr_fun (σ.naturality f) x
end FunctorToFintypeCat |
.lake/packages/mathlib/Mathlib/CategoryTheory/CommSq.lean | import Mathlib.CategoryTheory.Comma.Arrow
/-!
# Commutative squares
This file provides an API for commutative squares in categories.
If `top`, `left`, `right` and `bottom` are four morphisms which are the edges
of a square, `CommSq top left right bottom` is the predicate that this
square is commutative.
The structure `CommSq` is extended in `CategoryTheory/Shapes/Limits/CommSq.lean`
as `IsPullback` and `IsPushout` in order to define pullback and pushout squares.
## Future work
Refactor `LiftStruct` from `Arrow.lean` and lifting properties using `CommSq.lean`.
-/
namespace CategoryTheory
variable {C : Type*} [Category C]
/-- The proposition that a square
```
W ---f---> X
| |
g h
| |
v v
Y ---i---> Z
```
is a commuting square.
-/
structure CommSq {W X Y Z : C} (f : W ⟶ X) (g : W ⟶ Y) (h : X ⟶ Z) (i : Y ⟶ Z) : Prop where
/-- The square commutes. -/
w : f ≫ h = g ≫ i := by cat_disch
attribute [reassoc] CommSq.w
namespace CommSq
variable {W X Y Z : C} {f : W ⟶ X} {g : W ⟶ Y} {h : X ⟶ Z} {i : Y ⟶ Z}
theorem flip (p : CommSq f g h i) : CommSq g f i h :=
⟨p.w.symm⟩
theorem of_arrow {f g : Arrow C} (h : f ⟶ g) : CommSq f.hom h.left h.right g.hom :=
⟨h.w.symm⟩
/-- The commutative square in the opposite category associated to a commutative square. -/
theorem op (p : CommSq f g h i) : CommSq i.op h.op g.op f.op :=
⟨by simp only [← op_comp, p.w]⟩
/-- The commutative square associated to a commutative square in the opposite category. -/
theorem unop {W X Y Z : Cᵒᵖ} {f : W ⟶ X} {g : W ⟶ Y} {h : X ⟶ Z} {i : Y ⟶ Z} (p : CommSq f g h i) :
CommSq i.unop h.unop g.unop f.unop :=
⟨by simp only [← unop_comp, p.w]⟩
theorem vert_inv {g : W ≅ Y} {h : X ≅ Z} (p : CommSq f g.hom h.hom i) :
CommSq i g.inv h.inv f :=
⟨by rw [Iso.comp_inv_eq, Category.assoc, Iso.eq_inv_comp, p.w]⟩
theorem horiz_inv {f : W ≅ X} {i : Y ≅ Z} (p : CommSq f.hom g h i.hom) :
CommSq f.inv h g i.inv :=
flip (vert_inv (flip p))
/-- The horizontal composition of two commutative squares as below is a commutative square.
```
W ---f---> X ---f'--> X'
| | |
g h h'
| | |
v v v
Y ---i---> Z ---i'--> Z'
```
-/
lemma horiz_comp {W X X' Y Z Z' : C} {f : W ⟶ X} {f' : X ⟶ X'} {g : W ⟶ Y} {h : X ⟶ Z}
{h' : X' ⟶ Z'} {i : Y ⟶ Z} {i' : Z ⟶ Z'} (hsq₁ : CommSq f g h i) (hsq₂ : CommSq f' h h' i') :
CommSq (f ≫ f') g h' (i ≫ i') :=
⟨by rw [← Category.assoc, Category.assoc, ← hsq₁.w, hsq₂.w, Category.assoc]⟩
/-- The vertical composition of two commutative squares as below is a commutative square.
```
W ---f---> X
| |
g h
| |
v v
Y ---i---> Z
| |
g' h'
| |
v v
Y'---i'--> Z'
```
-/
lemma vert_comp {W X Y Y' Z Z' : C} {f : W ⟶ X} {g : W ⟶ Y} {g' : Y ⟶ Y'} {h : X ⟶ Z}
{h' : Z ⟶ Z'} {i : Y ⟶ Z} {i' : Y' ⟶ Z'} (hsq₁ : CommSq f g h i) (hsq₂ : CommSq i g' h' i') :
CommSq f (g ≫ g') (h ≫ h') i' :=
flip (horiz_comp (flip hsq₁) (flip hsq₂))
section
variable {W X Y : C}
theorem eq_of_mono {f : W ⟶ X} {g : W ⟶ X} {i : X ⟶ Y} [Mono i] (sq : CommSq f g i i) : f = g :=
(cancel_mono i).1 sq.w
theorem eq_of_epi {f : W ⟶ X} {h : X ⟶ Y} {i : X ⟶ Y} [Epi f] (sq : CommSq f f h i) : h = i :=
(cancel_epi f).1 sq.w
end
end CommSq
namespace Functor
variable {D : Type*} [Category D]
variable (F : C ⥤ D) {W X Y Z : C} {f : W ⟶ X} {g : W ⟶ Y} {h : X ⟶ Z} {i : Y ⟶ Z}
theorem map_commSq (s : CommSq f g h i) : CommSq (F.map f) (F.map g) (F.map h) (F.map i) :=
⟨by simpa using congr_arg (fun k : W ⟶ Z => F.map k) s.w⟩
end Functor
alias CommSq.map := Functor.map_commSq
namespace CommSq
variable {A B X Y : C} {f : A ⟶ X} {i : A ⟶ B} {p : X ⟶ Y} {g : B ⟶ Y}
/-- Now we consider a square:
```
A ---f---> X
| |
i p
| |
v v
B ---g---> Y
```
The datum of a lift in a commutative square, i.e. an up-right-diagonal
morphism which makes both triangles commute. -/
@[ext]
structure LiftStruct (sq : CommSq f i p g) where
/-- The lift. -/
l : B ⟶ X
/-- The upper left triangle commutes. -/
fac_left : i ≫ l = f := by cat_disch
/-- The lower right triangle commutes. -/
fac_right : l ≫ p = g := by cat_disch
namespace LiftStruct
/-- A `LiftStruct` for a commutative square gives a `LiftStruct` for the
corresponding square in the opposite category. -/
@[simps]
def op {sq : CommSq f i p g} (l : LiftStruct sq) : LiftStruct sq.op where
l := l.l.op
fac_left := by rw [← op_comp, l.fac_right]
fac_right := by rw [← op_comp, l.fac_left]
/-- A `LiftStruct` for a commutative square in the opposite category
gives a `LiftStruct` for the corresponding square in the original category. -/
@[simps]
def unop {A B X Y : Cᵒᵖ} {f : A ⟶ X} {i : A ⟶ B} {p : X ⟶ Y} {g : B ⟶ Y} {sq : CommSq f i p g}
(l : LiftStruct sq) : LiftStruct sq.unop where
l := l.l.unop
fac_left := by rw [← unop_comp, l.fac_right]
fac_right := by rw [← unop_comp, l.fac_left]
/-- Equivalences of `LiftStruct` for a square and the corresponding square
in the opposite category. -/
@[simps]
def opEquiv (sq : CommSq f i p g) : LiftStruct sq ≃ LiftStruct sq.op where
toFun := op
invFun := unop
left_inv := by cat_disch
right_inv := by cat_disch
/-- Equivalences of `LiftStruct` for a square in the opposite category and
the corresponding square in the original category. -/
def unopEquiv {A B X Y : Cᵒᵖ} {f : A ⟶ X} {i : A ⟶ B} {p : X ⟶ Y} {g : B ⟶ Y}
(sq : CommSq f i p g) : LiftStruct sq ≃ LiftStruct sq.unop where
toFun := unop
invFun := op
left_inv := by cat_disch
right_inv := by cat_disch
end LiftStruct
instance subsingleton_liftStruct_of_epi (sq : CommSq f i p g) [Epi i] :
Subsingleton (LiftStruct sq) :=
⟨fun l₁ l₂ => by
ext
rw [← cancel_epi i]
simp only [LiftStruct.fac_left]⟩
instance subsingleton_liftStruct_of_mono (sq : CommSq f i p g) [Mono p] :
Subsingleton (LiftStruct sq) :=
⟨fun l₁ l₂ => by
ext
rw [← cancel_mono p]
simp only [LiftStruct.fac_right]⟩
variable (sq : CommSq f i p g)
/-- The assertion that a square has a `LiftStruct`. -/
class HasLift : Prop where
/-- Square has a `LiftStruct`. -/
exists_lift : Nonempty sq.LiftStruct
namespace HasLift
variable {sq} in
theorem mk' (l : sq.LiftStruct) : HasLift sq :=
⟨Nonempty.intro l⟩
theorem iff : HasLift sq ↔ Nonempty sq.LiftStruct := by
constructor
exacts [fun h => h.exists_lift, fun h => mk h]
theorem iff_op : HasLift sq ↔ HasLift sq.op := by
rw [iff, iff]
exact Nonempty.congr (LiftStruct.opEquiv sq).toFun (LiftStruct.opEquiv sq).invFun
theorem iff_unop {A B X Y : Cᵒᵖ} {f : A ⟶ X} {i : A ⟶ B} {p : X ⟶ Y} {g : B ⟶ Y}
(sq : CommSq f i p g) : HasLift sq ↔ HasLift sq.unop := by
rw [iff, iff]
exact Nonempty.congr (LiftStruct.unopEquiv sq).toFun (LiftStruct.unopEquiv sq).invFun
end HasLift
/-- A choice of a diagonal morphism that is part of a `LiftStruct` when
the square has a lift. -/
noncomputable def lift [hsq : HasLift sq] : B ⟶ X :=
hsq.exists_lift.some.l
@[reassoc (attr := simp)]
theorem fac_left [hsq : HasLift sq] : i ≫ sq.lift = f :=
hsq.exists_lift.some.fac_left
@[reassoc (attr := simp)]
theorem fac_right [hsq : HasLift sq] : sq.lift ≫ p = g :=
hsq.exists_lift.some.fac_right
end CommSq
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Subpresheaf/Finite.lean | import Mathlib.CategoryTheory.Subpresheaf.OfSection
/-!
# Subpresheaves that are generated by finitely many sections
Given `F : Cᵒᵖ ⥤ Type w`, `G : Subpresheaf F`, objects `X : ι → Cᵒᵖ` and sections
`x : (i : ι) → F.obj (X i)`, we define a predicate `G.IsGeneratedBy x` saying
that `G` is the subpresheaf generated by the sections `x i`. If this holds for
a finite index type `ι`, we say that `G` is "finite", and this gives a type
class `G.IsFinite`.
-/
universe w'' w' w v u
namespace CategoryTheory
open Opposite
variable {C : Type u} [Category.{v} C] {F : Cᵒᵖ ⥤ Type w}
namespace Subpresheaf
variable (G : Subpresheaf F)
section
variable {ι : Type w'} {X : ι → Cᵒᵖ} (x : (i : ι) → F.obj (X i))
/-- A subpresheaf `G : Subpresheaf F` is generated by sections `x i : F.obj (X i)`
if `⨆ (i : ι), ofSection (x i) = G`. -/
def IsGeneratedBy : Prop := ⨆ (i : ι), ofSection (x i) = G
lemma isGeneratedBy_iff : G.IsGeneratedBy x ↔ ⨆ (i : ι), ofSection (x i) = G := Iff.rfl
namespace IsGeneratedBy
variable {G x} (h : G.IsGeneratedBy x)
include h
lemma iSup_eq : ⨆ (i : ι), ofSection (x i) = G := h
lemma ofSection_le (i : ι) : ofSection (x i) ≤ G := by
rw [← h.iSup_eq]
exact le_iSup (fun i ↦ ofSection (x i)) i
lemma mem (i : ι) : x i ∈ G.obj (X i) := by
rw [← ofSection_le_iff]
exact h.ofSection_le i
lemma of_equiv {ι' : Type w''} (e : ι' ≃ ι) :
G.IsGeneratedBy (fun i' ↦ x (e i')) := by
rw [isGeneratedBy_iff, ← h.iSup_eq]
exact Equiv.iSup_congr e (congrFun rfl)
lemma image {F' : Cᵒᵖ ⥤ Type w} (f : F ⟶ F') :
(G.image f).IsGeneratedBy (fun i ↦ f.app _ (x i)) := by
simp only [isGeneratedBy_iff, ← h.iSup_eq, image_iSup, ofSection_image]
end IsGeneratedBy
end
/-- A subpresheaf of types is "finite" if it is generated by finitely many sections. -/
class IsFinite : Prop where
exists_isGeneratedBy :
∃ (ι : Type) (_ : Finite ι) (X : ι → Cᵒᵖ) (x : (i : ι) → F.obj (X i)),
Nonempty (G.IsGeneratedBy x)
namespace IsFinite
variable [hG : G.IsFinite]
/-- A choice of index type for the generating sections of a finitely generated subpresheaf. -/
def Index : Type := hG.exists_isGeneratedBy.choose
instance : Finite (Index G) := hG.exists_isGeneratedBy.choose_spec.choose
variable {G}
/-- Objects on which a choice of generating sections of a finitely generated subpresheaf
are defined. -/
noncomputable def X : Index G → Cᵒᵖ :=
hG.exists_isGeneratedBy.choose_spec.choose_spec.choose
/-- A choice of generating sections of a finitely generated subpresheaf. -/
noncomputable def x : (i : Index G) → F.obj (X i) :=
hG.exists_isGeneratedBy.choose_spec.choose_spec.choose_spec.choose
end IsFinite
lemma isGeneratedBy_of_isFinite [hG : G.IsFinite] :
G.IsGeneratedBy (IsFinite.x (G := G)) :=
hG.exists_isGeneratedBy.choose_spec.choose_spec.choose_spec.choose_spec.some
lemma IsGeneratedBy.isFinite
{ι : Type w'} [Finite ι] {X : ι → Cᵒᵖ} {x : (i : ι) → F.obj (X i)}
(h : G.IsGeneratedBy x) : G.IsFinite := by
obtain ⟨n, ⟨e⟩⟩ := Finite.exists_equiv_fin ι
exact ⟨Fin n, inferInstance, _, _, ⟨h.of_equiv e.symm⟩⟩
lemma image_isFinite [G.IsFinite] {F' : Cᵒᵖ ⥤ Type w} (f : F ⟶ F') :
(G.image f).IsFinite :=
((isGeneratedBy_of_isFinite G).image f).isFinite
end Subpresheaf
variable (F)
section
variable {ι : Type w'} {X : ι → Cᵒᵖ} (x : (i : ι) → F.obj (X i))
/-- The condition that a presheaf of types `F : Cᵒᵖ ⥤ Type w` is generated by
a family of sections. -/
abbrev PresheafIsGeneratedBy : Prop := (⊤ : Subpresheaf F).IsGeneratedBy x
namespace PresheafIsGeneratedBy
variable {F x} (h : PresheafIsGeneratedBy F x) {F' : Cᵒᵖ ⥤ Type w} (f : F ⟶ F')
include h
lemma range : (Subpresheaf.range f).IsGeneratedBy (fun i ↦ f.app _ (x i)) := by
simpa only [← Subpresheaf.image_top] using h.image f
lemma of_epi [Epi f] : PresheafIsGeneratedBy F' (fun i ↦ f.app _ (x i)) := by
simpa only [Subpresheaf.range_eq_top f] using h.range f
end PresheafIsGeneratedBy
end
/-- A presheaf is "finite" if it is generated by finitely many sections. -/
abbrev PresheafIsFinite : Prop := (⊤ : Subpresheaf F).IsFinite
lemma presheafIsGeneratedBy_of_isFinite [PresheafIsFinite F] :
PresheafIsGeneratedBy F (Subpresheaf.IsFinite.x (G := ⊤)) :=
(Subpresheaf.isGeneratedBy_of_isFinite (⊤ : Subpresheaf F))
lemma Subpresheaf.range_isFinite [PresheafIsFinite F] {F' : Cᵒᵖ ⥤ Type w} (f : F ⟶ F') :
(Subpresheaf.range f).IsFinite :=
((presheafIsGeneratedBy_of_isFinite F).range f).isFinite
lemma presheafIsFinite_of_epi [PresheafIsFinite F] {F' : Cᵒᵖ ⥤ Type w} (f : F ⟶ F') [Epi f] :
PresheafIsFinite F' :=
((presheafIsGeneratedBy_of_isFinite F).of_epi f).isFinite
lemma yoneda_obj_isGeneratedBy (X : C) :
PresheafIsGeneratedBy (yoneda.obj X) (fun (_ : Unit) ↦ 𝟙 X) := by
simp only [Subpresheaf.isGeneratedBy_iff]
ext U u
simp only [yoneda_obj_obj, Subpresheaf.iSup_obj, Set.mem_iUnion,
exists_const, Subpresheaf.top_obj, Set.top_eq_univ, Set.mem_univ, iff_true]
exact ⟨u.op, by simp⟩
instance (X : C) : PresheafIsFinite (yoneda.obj X) :=
(yoneda_obj_isGeneratedBy X).isFinite
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Subpresheaf/OfSection.lean | import Mathlib.CategoryTheory.Subpresheaf.Image
import Mathlib.CategoryTheory.Yoneda
/-!
# The subpresheaf generated by a section
Given a presheaf of types `F : Cᵒᵖ ⥤ Type w` and a section `x : F.obj X`,
we define `Subpresheaf.ofSection x : Subpresheaf F` as the subpresheaf
of `F` generated by `x`.
-/
universe w v u
namespace CategoryTheory
variable {C : Type u} [Category.{v} C]
namespace Subpresheaf
section
variable {F : Cᵒᵖ ⥤ Type w} {X : Cᵒᵖ} (x : F.obj X)
/-- The subpresheaf of `F : Cᵒᵖ ⥤ Type w` that is generated
by a section `x : F.obj X`. -/
@[simps -isSimp]
def ofSection : Subpresheaf F where
obj U := setOf (fun u ↦ ∃ (f : X ⟶ U), F.map f x = u)
map {U V} g := by
rintro _ ⟨f, rfl⟩
exact ⟨f ≫ g, by simp⟩
lemma mem_ofSection_obj : x ∈ (ofSection x).obj X := ⟨𝟙 _, by simp⟩
@[simp]
lemma ofSection_le_iff (G : Subpresheaf F) :
ofSection x ≤ G ↔ x ∈ G.obj X := by
constructor
· intro hx
exact hx _ (mem_ofSection_obj x)
· rintro hx U _ ⟨f, rfl⟩
exact G.map f hx
@[simp]
lemma ofSection_image {F' : Cᵒᵖ ⥤ Type w} (f : F ⟶ F') :
(ofSection x).image f = ofSection (f.app _ x) := by
apply le_antisymm
· rw [image_le_iff, ofSection_le_iff, preimage_obj, Set.mem_preimage]
exact ⟨𝟙 X, by simp⟩
· simp only [ofSection_le_iff, image_obj, Set.mem_image]
exact ⟨x, mem_ofSection_obj x, rfl⟩
end
section
variable {F : Cᵒᵖ ⥤ Type v}
lemma ofSection_eq_range {X : Cᵒᵖ} (x : F.obj X) :
ofSection x = range (yonedaEquiv.symm x) := by
ext U y
simp only [ofSection_obj, Set.mem_setOf_eq, Opposite.op_unop, range_obj, yoneda_obj_obj,
Set.mem_range]
constructor
· rintro ⟨f, rfl⟩
exact ⟨f.unop, rfl⟩
· rintro ⟨f, rfl⟩
exact ⟨f.op, rfl⟩
lemma range_eq_ofSection {X : C} (f : yoneda.obj X ⟶ F) :
range f = ofSection (yonedaEquiv f) := by
rw [ofSection_eq_range, Equiv.symm_apply_apply]
end
section
variable {F : Cᵒᵖ ⥤ Type max v w}
lemma ofSection_eq_range' {X : Cᵒᵖ} (x : F.obj X) :
ofSection x = range (uliftYonedaEquiv.symm x) := by
ext U y
dsimp [uliftYonedaEquiv]
simp only [Set.mem_range, ULift.exists]
constructor
· rintro ⟨f, rfl⟩
exact ⟨f.unop, rfl⟩
· rintro ⟨f, rfl⟩
exact ⟨f.op, rfl⟩
lemma range_eq_ofSection' {X : C} (f : yoneda.obj X ⋙ uliftFunctor.{w} ⟶ F) :
range f = ofSection (uliftYonedaEquiv f) := by
rw [ofSection_eq_range', Equiv.symm_apply_apply]
end
end Subpresheaf
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Subpresheaf/Image.lean | import Mathlib.CategoryTheory.Subpresheaf.Basic
import Mathlib.CategoryTheory.Limits.FunctorCategory.EpiMono
import Mathlib.CategoryTheory.Limits.Types.Colimits
/-!
# The image of a subpresheaf
Given a morphism of presheaves of types `p : F' ⟶ F`, we define its range
`Subpresheaf.range p`. More generally, if `G' : Subpresheaf F'`, we
define `G'.image p : Subpresheaf F` as the image of `G'` by `f`, and
if `G : Subpresheaf F`, we define its preimage `G.preimage f : Subpresheaf F'`.
-/
universe w v u
namespace CategoryTheory
variable {C : Type u} [Category.{v} C] {F F' F'' : Cᵒᵖ ⥤ Type w}
namespace Subpresheaf
section range
/-- The range of a morphism of presheaves of types, as a subpresheaf of the target. -/
@[simps]
def range (p : F' ⟶ F) : Subpresheaf F where
obj U := Set.range (p.app U)
map := by
rintro U V i _ ⟨x, rfl⟩
exact ⟨_, FunctorToTypes.naturality _ _ p i x⟩
variable (F) in
lemma range_id : range (𝟙 F) = ⊤ := by aesop
@[simp]
lemma range_ι (G : Subpresheaf F) : range G.ι = G := by aesop
end range
section lift
variable (f : F' ⟶ F) {G : Subpresheaf F} (hf : range f ≤ G)
/-- If the image of a morphism falls in a subpresheaf, then the morphism factors through it. -/
@[simps!]
def lift : F' ⟶ G.toPresheaf where
app U x := ⟨f.app U x, hf U (by simp)⟩
naturality _ _ g := by
ext x
simpa [Subtype.ext_iff] using FunctorToTypes.naturality _ _ f g x
@[reassoc (attr := simp)]
theorem lift_ι : lift f hf ≫ G.ι = f := rfl
end lift
section range
variable (p : F' ⟶ F)
/-- Given a morphism `p : F' ⟶ F` of presheaves of types, this is the morphism
from `F'` to its range. -/
def toRange :
F' ⟶ (range p).toPresheaf :=
lift p (by rfl)
@[reassoc (attr := simp)]
lemma toRange_ι : toRange p ≫ (range p).ι = p := rfl
lemma toRange_app_val {i : Cᵒᵖ} (x : F'.obj i) :
((toRange p).app i x).val = p.app i x := by
simp [toRange]
@[simp]
lemma range_toRange : range (toRange p) = ⊤ := by
ext i ⟨x, hx⟩
dsimp at hx ⊢
simp only [Set.mem_range, Set.mem_univ, iff_true]
simp only [Set.mem_range] at hx
obtain ⟨y, rfl⟩ := hx
exact ⟨y, rfl⟩
lemma epi_iff_range_eq_top :
Epi p ↔ range p = ⊤ := by
simp [NatTrans.epi_iff_epi_app, epi_iff_surjective, Subpresheaf.ext_iff, funext_iff,
Set.range_eq_univ]
lemma range_eq_top [Epi p] : range p = ⊤ := by rwa [← epi_iff_range_eq_top]
instance : Epi (toRange p) := by simp [epi_iff_range_eq_top]
instance [Mono p] : IsIso (toRange p) := by
have := mono_of_mono_fac (toRange_ι p)
rw [NatTrans.isIso_iff_isIso_app]
intro i
rw [isIso_iff_bijective]
constructor
· rw [← mono_iff_injective]
infer_instance
· rw [← epi_iff_surjective]
infer_instance
lemma range_comp_le (f : F ⟶ F') (g : F' ⟶ F'') :
range (f ≫ g) ≤ range g := fun _ _ _ ↦ by aesop
end range
section image
variable (G : Subpresheaf F) (f : F ⟶ F')
/-- The image of a subpresheaf by a morphism of presheaves of types. -/
@[simps]
def image : Subpresheaf F' where
obj i := (f.app i) '' (G.obj i)
map := by
rintro Δ Δ' φ _ ⟨x, hx, rfl⟩
exact ⟨F.map φ x, G.map φ hx, by apply FunctorToTypes.naturality⟩
lemma image_top : (⊤ : Subpresheaf F).image f = range f := by aesop
@[simp]
lemma image_iSup {ι : Type*} (G : ι → Subpresheaf F) (f : F ⟶ F') :
(⨆ i, G i).image f = ⨆ i, (G i).image f := by aesop
lemma image_comp (g : F' ⟶ F'') :
G.image (f ≫ g) = (G.image f).image g := by aesop
lemma range_comp (g : F' ⟶ F'') :
range (f ≫ g) = (range f).image g := by aesop
end image
section preimage
/-- The preimage of a subpresheaf by a morphism of presheaves of types. -/
@[simps]
def preimage (G : Subpresheaf F) (p : F' ⟶ F) : Subpresheaf F' where
obj n := p.app n ⁻¹' (G.obj n)
map f := (Set.preimage_mono (G.map f)).trans (by
simp only [Set.preimage_preimage, FunctorToTypes.naturality _ _ p f]
rfl)
@[simp]
lemma preimage_id (G : Subpresheaf F) :
G.preimage (𝟙 F) = G := by aesop
lemma preimage_comp (G : Subpresheaf F) (f : F'' ⟶ F') (g : F' ⟶ F) :
G.preimage (f ≫ g) = (G.preimage g).preimage f := by aesop
lemma image_le_iff (G : Subpresheaf F) (f : F ⟶ F') (G' : Subpresheaf F') :
G.image f ≤ G' ↔ G ≤ G'.preimage f := by
simp [Subpresheaf.le_def]
/-- Given a morphism `p : F' ⟶ F` of presheaves of types and `G : Subpresheaf F`,
this is the morphism from the preimage of `G` by `p` to `G`. -/
def fromPreimage (G : Subpresheaf F) (p : F' ⟶ F) :
(G.preimage p).toPresheaf ⟶ G.toPresheaf :=
lift ((G.preimage p).ι ≫ p) (by
rw [range_comp, range_ι, image_le_iff])
@[reassoc]
lemma fromPreimage_ι (G : Subpresheaf F) (p : F' ⟶ F) :
G.fromPreimage p ≫ G.ι = (G.preimage p).ι ≫ p := rfl
lemma preimage_eq_top_iff (G : Subpresheaf F) (p : F' ⟶ F) :
G.preimage p = ⊤ ↔ range p ≤ G := by
rw [← image_top, image_le_iff]
simp
@[simp]
lemma preimage_image_of_epi (G : Subpresheaf F) (p : F' ⟶ F) [hp : Epi p] :
(G.preimage p).image p = G := by
apply le_antisymm
· rw [image_le_iff]
· intro i x hx
simp only [NatTrans.epi_iff_epi_app, epi_iff_surjective] at hp
obtain ⟨y, rfl⟩ := hp _ x
exact ⟨y, hx, rfl⟩
end preimage
end Subpresheaf
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Subpresheaf/Basic.lean | import Mathlib.CategoryTheory.Elementwise
import Mathlib.Data.Set.Lattice.Image
/-!
# Subpresheaf of types
We define the subpresheaf of a type-valued presheaf.
## Main results
- `CategoryTheory.Subpresheaf` :
A subpresheaf of a presheaf of types.
-/
universe w v u
open Opposite CategoryTheory
namespace CategoryTheory
variable {C : Type u} [Category.{v} C]
/-- A subpresheaf of a presheaf consists of a subset of `F.obj U` for every `U`,
compatible with the restriction maps `F.map i`. -/
@[ext]
structure Subpresheaf (F : Cᵒᵖ ⥤ Type w) where
/-- If `G` is a sub-presheaf of `F`, then the sections of `G` on `U` forms a subset of sections of
`F` on `U`. -/
obj : ∀ U, Set (F.obj U)
/-- If `G` is a sub-presheaf of `F` and `i : U ⟶ V`, then for each `G`-sections on `U` `x`,
`F i x` is in `F(V)`. -/
map : ∀ {U V : Cᵒᵖ} (i : U ⟶ V), obj U ⊆ F.map i ⁻¹' obj V
variable {F F' F'' : Cᵒᵖ ⥤ Type w} (G G' : Subpresheaf F)
instance : PartialOrder (Subpresheaf F) :=
PartialOrder.lift Subpresheaf.obj (fun _ _ => Subpresheaf.ext)
instance : CompleteLattice (Subpresheaf F) where
sup F G :=
{ obj U := F.obj U ⊔ G.obj U
map _ _ := by
rintro (h|h)
· exact Or.inl (F.map _ h)
· exact Or.inr (G.map _ h) }
le_sup_left _ _ _ := by simp
le_sup_right _ _ _ := by simp
sup_le F G H h₁ h₂ U := by
rintro x (h|h)
· exact h₁ _ h
· exact h₂ _ h
inf S T :=
{ obj U := S.obj U ⊓ T.obj U
map _ _ h := ⟨S.map _ h.1, T.map _ h.2⟩}
inf_le_left _ _ _ _ h := h.1
inf_le_right _ _ _ _ h := h.2
le_inf _ _ _ h₁ h₂ _ _ h := ⟨h₁ _ h, h₂ _ h⟩
sSup S :=
{ obj U := sSup (Set.image (fun T ↦ T.obj U) S)
map f x hx := by
obtain ⟨_, ⟨F, h, rfl⟩, h'⟩ := hx
simp only [Set.sSup_eq_sUnion, Set.sUnion_image, Set.preimage_iUnion,
Set.mem_iUnion, Set.mem_preimage, exists_prop]
exact ⟨_, h, F.map f h'⟩ }
le_sSup _ _ _ _ _ := by aesop
sSup_le _ _ _ _ _ := by aesop
sInf S :=
{ obj U := sInf (Set.image (fun T ↦ T.obj U) S)
map f x hx := by
rintro _ ⟨F, h, rfl⟩
exact F.map f (hx _ ⟨_, h, rfl⟩) }
sInf_le _ _ _ _ _ := by aesop
le_sInf _ _ _ _ _ := by aesop
bot :=
{ obj U := ⊥
map := by simp }
bot_le _ _ := bot_le
top :=
{ obj U := ⊤
map := by simp }
le_top _ _ := le_top
namespace Subpresheaf
lemma le_def (S T : Subpresheaf F) : S ≤ T ↔ ∀ U, S.obj U ≤ T.obj U := Iff.rfl
variable (F)
@[simp] lemma top_obj (i : Cᵒᵖ) : (⊤ : Subpresheaf F).obj i = ⊤ := rfl
@[simp] lemma bot_obj (i : Cᵒᵖ) : (⊥ : Subpresheaf F).obj i = ⊥ := rfl
variable {F}
lemma sSup_obj (S : Set (Subpresheaf F)) (U : Cᵒᵖ) :
(sSup S).obj U = sSup (Set.image (fun T ↦ T.obj U) S) := rfl
lemma sInf_obj (S : Set (Subpresheaf F)) (U : Cᵒᵖ) :
(sInf S).obj U = sInf (Set.image (fun T ↦ T.obj U) S) := rfl
@[simp]
lemma iSup_obj {ι : Type*} (S : ι → Subpresheaf F) (U : Cᵒᵖ) :
(⨆ i, S i).obj U = ⋃ i, (S i).obj U := by
simp [iSup, sSup_obj]
@[simp]
lemma iInf_obj {ι : Type*} (S : ι → Subpresheaf F) (U : Cᵒᵖ) :
(⨅ i, S i).obj U = ⋂ i, (S i).obj U := by
simp [iInf, sInf_obj]
@[simp]
lemma max_obj (S T : Subpresheaf F) (i : Cᵒᵖ) :
(S ⊔ T).obj i = S.obj i ∪ T.obj i := rfl
@[simp]
lemma min_obj (S T : Subpresheaf F) (i : Cᵒᵖ) :
(S ⊓ T).obj i = S.obj i ∩ T.obj i := rfl
lemma max_min (S₁ S₂ T : Subpresheaf F) :
(S₁ ⊔ S₂) ⊓ T = (S₁ ⊓ T) ⊔ (S₂ ⊓ T) := by
aesop
lemma iSup_min {ι : Type*} (S : ι → Subpresheaf F) (T : Subpresheaf F) :
(⨆ i, S i) ⊓ T = ⨆ i, S i ⊓ T := by
aesop
instance : Nonempty (Subpresheaf F) :=
inferInstance
/-- The subpresheaf as a presheaf. -/
@[simps!]
def toPresheaf : Cᵒᵖ ⥤ Type w where
obj U := G.obj U
map := @fun _ _ i x => ⟨F.map i x, G.map i x.prop⟩
map_id X := by
ext ⟨x, _⟩
dsimp
simp only [FunctorToTypes.map_id_apply]
map_comp := @fun X Y Z i j => by
ext ⟨x, _⟩
dsimp
simp only [FunctorToTypes.map_comp_apply]
instance {U} : CoeHead (G.toPresheaf.obj U) (F.obj U) where
coe := Subtype.val
/-- The inclusion of a subpresheaf to the original presheaf. -/
@[simps]
def ι : G.toPresheaf ⟶ F where app _ x := x
instance : Mono G.ι :=
⟨@fun _ _ _ e =>
NatTrans.ext <|
funext fun U => funext fun x => Subtype.ext <| congr_fun (congr_app e U) x⟩
/-- The inclusion of a subpresheaf to a larger subpresheaf -/
@[simps]
def homOfLe {G G' : Subpresheaf F} (h : G ≤ G') : G.toPresheaf ⟶ G'.toPresheaf where
app U x := ⟨x, h U x.prop⟩
instance {G G' : Subpresheaf F} (h : G ≤ G') : Mono (Subpresheaf.homOfLe h) :=
⟨fun _ _ e =>
NatTrans.ext <|
funext fun U =>
funext fun x =>
Subtype.ext <| (congr_arg Subtype.val <| (congr_fun (congr_app e U) x :) :)⟩
@[reassoc (attr := simp)]
theorem homOfLe_ι {G G' : Subpresheaf F} (h : G ≤ G') :
Subpresheaf.homOfLe h ≫ G'.ι = G.ι := by
ext
rfl
instance : IsIso (Subpresheaf.ι (⊤ : Subpresheaf F)) := by
refine @NatIso.isIso_of_isIso_app _ _ _ _ _ _ _ ?_
intro X
rw [isIso_iff_bijective]
exact ⟨Subtype.coe_injective, fun x => ⟨⟨x, _root_.trivial⟩, rfl⟩⟩
attribute [local instance] Types.instFunLike Types.instConcreteCategory in
theorem eq_top_iff_isIso : G = ⊤ ↔ IsIso G.ι := by
constructor
· rintro rfl
infer_instance
· intro H
ext U x
apply (iff_of_eq (iff_true _)).mpr
rw [← IsIso.inv_hom_id_apply (G.ι.app U) x]
exact ((inv (G.ι.app U)) x).2
theorem nat_trans_naturality (f : F' ⟶ G.toPresheaf) {U V : Cᵒᵖ} (i : U ⟶ V)
(x : F'.obj U) : (f.app V (F'.map i x)).1 = F.map i (f.app U x).1 :=
congr_arg Subtype.val (FunctorToTypes.naturality _ _ f i x)
end Subpresheaf
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Subpresheaf/Subobject.lean | import Mathlib.CategoryTheory.Subpresheaf.Image
import Mathlib.CategoryTheory.Subobject.Basic
/-!
# Comparison between `Subpresheaf`, `MonoOver` and `Subobject`
Given a presheaf of types `F : Cᵒᵖ ⥤ Type w`, we define an equivalence
of categories `Subpresheaf.equivalenceMonoOver F : Subpresheaf F ≌ MonoOver F`
and an order isomorphism `Subpresheaf.orderIsoSubject F : Subpresheaf F ≃o Subobject F`.
-/
universe w v u
namespace CategoryTheory
variable {C : Type u} [Category.{v} C] (F : Cᵒᵖ ⥤ Type w)
namespace Subpresheaf
/-- The equivalence of categories `Subpresheaf F ≌ MonoOver F`. -/
@[simps]
noncomputable def equivalenceMonoOver : Subpresheaf F ≌ MonoOver F where
functor :=
{ obj A := MonoOver.mk' A.ι
map {A B} f := MonoOver.homMk (Subpresheaf.homOfLe (leOfHom f)) }
inverse :=
{ obj X := Subpresheaf.range X.arrow
map {X Y} f := homOfLE (by
rw [← MonoOver.w f]
apply range_comp_le ) }
unitIso := NatIso.ofComponents (fun A ↦ eqToIso (by simp))
counitIso := NatIso.ofComponents
(fun X ↦ MonoOver.isoMk ((asIso (toRange X.arrow)).symm))
variable {F} in
@[simp]
lemma range_subobjectMk_ι (A : Subpresheaf F) :
range (Subobject.mk A.ι).arrow = A :=
(((equivalenceMonoOver F).trans
(ThinSkeleton.equivalence _).symm).unitIso.app A).to_eq.symm
variable {F} in
@[simp]
lemma subobjectMk_range_arrow (X : Subobject F) :
Subobject.mk (range X.arrow).ι = X :=
(((equivalenceMonoOver F).trans
(ThinSkeleton.equivalence _).symm).counitIso.app X).to_eq
/-- The order isomorphism `Subpresheaf F ≃o MonoOver F`. -/
@[simps]
noncomputable def orderIsoSubobject : Subpresheaf F ≃o Subobject F where
toFun A := Subobject.mk A.ι
invFun X := Subpresheaf.range X.arrow
left_inv A := by simp
right_inv X := by simp
map_rel_iff' {A B} := by
constructor
· intro h
have : range (Subobject.mk A.ι).arrow ≤ range (Subobject.mk B.ι).arrow :=
leOfHom (((equivalenceMonoOver F).trans
(ThinSkeleton.equivalence _).symm).inverse.map (homOfLE h))
simpa using this
· intro h
exact leOfHom (((equivalenceMonoOver F).trans
(ThinSkeleton.equivalence _).symm).functor.map (homOfLE h))
end Subpresheaf
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Subpresheaf/Sieves.lean | import Mathlib.CategoryTheory.Subpresheaf.Basic
import Mathlib.CategoryTheory.Sites.IsSheafFor
/-!
# Sieves attached to subpresheaves
Given a subpresheaf `G` of a presheaf of types `F : Cᵒᵖ ⥤ Type w` and
a section `s : F.obj U`, we define a sieve `G.sieveOfSection s : Sieve (unop U)`
and the associated compatible family of elements with values in `G.toPresheaf`.
-/
universe w v u
namespace CategoryTheory.Subpresheaf
open Opposite
variable {C : Type u} [Category.{v} C] {F : Cᵒᵖ ⥤ Type w} (G : Subpresheaf F)
/-- Given a subpresheaf `G` of `F`, an `F`-section `s` on `U`, we may define a sieve of `U`
consisting of all `f : V ⟶ U` such that the restriction of `s` along `f` is in `G`. -/
@[simps]
def sieveOfSection {U : Cᵒᵖ} (s : F.obj U) : Sieve (unop U) where
arrows V f := F.map f.op s ∈ G.obj (op V)
downward_closed := @fun V W i hi j => by
simp only [op_unop, op_comp, FunctorToTypes.map_comp_apply]
exact G.map _ hi
/-- Given an `F`-section `s` on `U` and a subpresheaf `G`, we may define a family of elements in
`G` consisting of the restrictions of `s` -/
def familyOfElementsOfSection {U : Cᵒᵖ} (s : F.obj U) :
(G.sieveOfSection s).1.FamilyOfElements G.toPresheaf := fun _ i hi => ⟨F.map i.op s, hi⟩
theorem family_of_elements_compatible {U : Cᵒᵖ} (s : F.obj U) :
(G.familyOfElementsOfSection s).Compatible := by
intro Y₁ Y₂ Z g₁ g₂ f₁ f₂ h₁ h₂ e
refine Subtype.ext ?_ -- Porting note: `ext1` does not work here
change F.map g₁.op (F.map f₁.op s) = F.map g₂.op (F.map f₂.op s)
rw [← FunctorToTypes.map_comp_apply, ← FunctorToTypes.map_comp_apply, ← op_comp, ← op_comp, e]
end CategoryTheory.Subpresheaf |
.lake/packages/mathlib/Mathlib/CategoryTheory/Subpresheaf/Equalizer.lean | import Mathlib.CategoryTheory.Limits.Shapes.Equalizers
import Mathlib.CategoryTheory.Subpresheaf.Image
/-!
# The equalizer of two morphisms of presheaves, as a subpresheaf
If `F₁` and `F₂` are presheaves of types, `A : Subpresheaf F₁`, and
`f` and `g` are two morphisms `A.toPresheaf ⟶ F₂`, we introduce
`Subcomplex.equalizer f g`, which is the subpresheaf of `F₁` contained in `A`
where `f` and `g` coincide.
-/
universe w v u
namespace CategoryTheory
variable {C : Type u} [Category.{v} C] {F₁ F₂ : Cᵒᵖ ⥤ Type w} {A : Subpresheaf F₁}
(f g : A.toPresheaf ⟶ F₂)
namespace Subpresheaf
/-- The equalizer of two morphisms of presheaves of types of the form
`A.toPresheaf ⟶ F₂` with `A : Subpresheaf F₁`, as a subcomplex of `F₁`. -/
@[simps -isSimp]
protected def equalizer : Subpresheaf F₁ where
obj U := setOf (fun x ↦ ∃ (hx : x ∈ A.obj _), f.app _ ⟨x, hx⟩ = g.app _ ⟨x, hx⟩)
map φ x := by
rintro ⟨hx, h⟩
exact ⟨A.map _ hx,
(FunctorToTypes.naturality _ _ f φ ⟨x, hx⟩).trans (Eq.trans (by rw [h])
(FunctorToTypes.naturality _ _ g φ ⟨x, hx⟩).symm)⟩
attribute [local simp] equalizer_obj
lemma equalizer_le : Subpresheaf.equalizer f g ≤ A :=
fun _ _ h ↦ h.1
@[simp]
lemma equalizer_self : Subpresheaf.equalizer f f = A := by aesop
lemma mem_equalizer_iff {i : Cᵒᵖ} (x : A.toPresheaf.obj i) :
x.1 ∈ (Subpresheaf.equalizer f g).obj i ↔ f.app i x = g.app i x := by
simp
lemma range_le_equalizer_iff {G : Cᵒᵖ ⥤ Type w} (φ : G ⟶ A.toPresheaf) :
range (φ ≫ A.ι) ≤ Subpresheaf.equalizer f g ↔ φ ≫ f = φ ≫ g := by
rw [NatTrans.ext_iff]
simp [le_def, Set.subset_def, funext_iff, CategoryTheory.types_ext_iff]
lemma equalizer_eq_iff :
Subpresheaf.equalizer f g = A ↔ f = g := by
have := range_le_equalizer_iff f g (𝟙 _)
simp only [Category.id_comp, range_ι] at this
rw [← this]
constructor
· intro h
rw [h]
· intro h
exact le_antisymm (equalizer_le f g) h
/-- Given two morphisms `f` and `g` in `A.toPresheaf ⟶ F₂`, this is the monomorphism
of presheaves corresponding to the inclusion `Subpresheaf.equalizer f g ≤ A`. -/
def equalizer.ι : (Subpresheaf.equalizer f g).toPresheaf ⟶ A.toPresheaf :=
homOfLe (equalizer_le f g)
instance : Mono (equalizer.ι f g) := by
dsimp [equalizer.ι]
infer_instance
@[reassoc (attr := simp)]
lemma equalizer.ι_ι : equalizer.ι f g ≫ A.ι = (Subpresheaf.equalizer f g).ι := rfl
@[reassoc]
lemma equalizer.condition : equalizer.ι f g ≫ f = equalizer.ι f g ≫ g := by
simp [← range_le_equalizer_iff]
/-- Given two morphisms `f` and `g` in `A.toPresheaf ⟶ F₂`, if `φ : G ⟶ A.toPresheaf`
is such that `φ ≫ f = φ ≫ g`, then this is the lifted morphism
`G ⟶ (Subpresheaf.equalizer f g).toPresheaf`. This is part of the universal
property of the equalizer that is satisfied by
the presheaf `(Subpresheaf.equalizer f g).toPresheaf`. -/
def equalizer.lift {G : Cᵒᵖ ⥤ Type w} (φ : G ⟶ A.toPresheaf)
(w : φ ≫ f = φ ≫ g) :
G ⟶ (Subpresheaf.equalizer f g).toPresheaf :=
Subpresheaf.lift (φ ≫ A.ι) (by simpa only [range_le_equalizer_iff] using w)
@[reassoc (attr := simp)]
lemma equalizer.lift_ι' {G : Cᵒᵖ ⥤ Type w} (φ : G ⟶ A.toPresheaf)
(w : φ ≫ f = φ ≫ g) :
equalizer.lift f g φ w ≫ (Subpresheaf.equalizer f g).ι = φ ≫ A.ι :=
rfl
@[reassoc (attr := simp)]
lemma equalizer.lift_ι {G : Cᵒᵖ ⥤ Type w} (φ : G ⟶ A.toPresheaf)
(w : φ ≫ f = φ ≫ g) :
equalizer.lift f g φ w ≫ equalizer.ι f g = φ :=
rfl
/-- The (limit) fork which expresses `(Subpresheaf.equalizer f g).toPresheaf` as
the equalizer of `f` and `g`. -/
@[simps! pt]
def equalizer.fork : Limits.Fork f g :=
Limits.Fork.ofι (equalizer.ι f g) (equalizer.condition f g)
@[simp]
lemma equalizer.fork_ι :
(equalizer.fork f g).ι = equalizer.ι f g := rfl
/-- `(Subpresheaf.equalizer f g).toPresheaf` is the equalizer of `f` and `g`. -/
def equalizer.forkIsLimit : Limits.IsLimit (equalizer.fork f g) :=
Limits.Fork.IsLimit.mk _
(fun s ↦ equalizer.lift _ _ s.ι s.condition)
(fun s ↦ by dsimp)
(fun s m hm ↦ by simp [← cancel_mono (Subpresheaf.equalizer f g).ι, ← hm])
end Subpresheaf
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Functor/Flat.lean | import Mathlib.CategoryTheory.Filtered.Connected
import Mathlib.CategoryTheory.Limits.ConeCategory
import Mathlib.CategoryTheory.Limits.FilteredColimitCommutesFiniteLimit
import Mathlib.CategoryTheory.Limits.Preserves.Filtered
import Mathlib.CategoryTheory.Limits.Preserves.FunctorCategory
import Mathlib.CategoryTheory.Limits.Bicones
import Mathlib.CategoryTheory.Limits.Comma
import Mathlib.CategoryTheory.Limits.Preserves.Finite
import Mathlib.CategoryTheory.Limits.Preserves.Opposites
import Mathlib.CategoryTheory.Limits.Shapes.FiniteLimits
/-!
# Representably flat functors
We define representably flat functors as functors such that the category of structured arrows
over `X` is cofiltered for each `X`. This concept is also known as flat functors as in [Elephant]
Remark C2.3.7, and this name is suggested by Mike Shulman in
https://golem.ph.utexas.edu/category/2011/06/flat_functors_and_morphisms_of.html to avoid
confusion with other notions of flatness.
This definition is equivalent to left exact functors (functors that preserves finite limits) when
`C` has all finite limits.
## Main results
* `flat_of_preservesFiniteLimits`: If `F : C ⥤ D` preserves finite limits and `C` has all finite
limits, then `F` is flat.
* `preservesFiniteLimits_of_flat`: If `F : C ⥤ D` is flat, then it preserves all finite limits.
* `preservesFiniteLimits_iff_flat`: If `C` has all finite limits,
then `F` is flat iff `F` is left_exact.
* `lan_preservesFiniteLimits_of_flat`: If `F : C ⥤ D` is a flat functor between small categories,
then the functor `Lan F.op` between presheaves of sets preserves all finite limits.
* `flat_iff_lan_flat`: If `C`, `D` are small and `C` has all finite limits, then `F` is flat iff
`Lan F.op : (Cᵒᵖ ⥤ Type*) ⥤ (Dᵒᵖ ⥤ Type*)` is flat.
* `preservesFiniteLimits_iff_lanPreservesFiniteLimits`: If `C`, `D` are small and `C` has all
finite limits, then `F` preserves finite limits iff `Lan F.op : (Cᵒᵖ ⥤ Type*) ⥤ (Dᵒᵖ ⥤ Type*)`
does.
-/
universe w v₁ v₂ v₃ u₁ u₂ u₃
open CategoryTheory
open CategoryTheory.Limits
open Opposite
namespace CategoryTheory
section RepresentablyFlat
variable {C : Type u₁} [Category.{v₁} C] {D : Type u₂} [Category.{v₂} D]
variable {E : Type u₃} [Category.{v₃} E]
/-- A functor `F : C ⥤ D` is representably flat if the comma category `(X/F)` is cofiltered for
each `X : D`.
-/
class RepresentablyFlat (F : C ⥤ D) : Prop where
cofiltered : ∀ X : D, IsCofiltered (StructuredArrow X F)
/-- A functor `F : C ⥤ D` is representably coflat if the comma category `(F/X)` is filtered for
each `X : D`. -/
class RepresentablyCoflat (F : C ⥤ D) : Prop where
filtered : ∀ X : D, IsFiltered (CostructuredArrow F X)
attribute [instance] RepresentablyFlat.cofiltered RepresentablyCoflat.filtered
variable (F : C ⥤ D)
instance RepresentablyFlat.of_isRightAdjoint [F.IsRightAdjoint] : RepresentablyFlat F where
cofiltered _ := IsCofiltered.of_isInitial _ (mkInitialOfLeftAdjoint _ (.ofIsRightAdjoint F) _)
instance RepresentablyCoflat.of_isLeftAdjoint [F.IsLeftAdjoint] : RepresentablyCoflat F where
filtered _ := IsFiltered.of_isTerminal _ (mkTerminalOfRightAdjoint _ (.ofIsLeftAdjoint F) _)
theorem RepresentablyFlat.id : RepresentablyFlat (𝟭 C) := inferInstance
theorem RepresentablyCoflat.id : RepresentablyCoflat (𝟭 C) := inferInstance
instance RepresentablyFlat.comp (G : D ⥤ E) [RepresentablyFlat F]
[RepresentablyFlat G] : RepresentablyFlat (F ⋙ G) := by
refine ⟨fun X => IsCofiltered.of_cone_nonempty.{0} _ (fun {J} _ _ H => ?_)⟩
obtain ⟨c₁⟩ := IsCofiltered.cone_nonempty (H ⋙ StructuredArrow.pre X F G)
let H₂ : J ⥤ StructuredArrow c₁.pt.right F :=
{ obj := fun j => StructuredArrow.mk (c₁.π.app j).right
map := fun {j j'} f =>
StructuredArrow.homMk (H.map f).right (congrArg CommaMorphism.right (c₁.w f)) }
obtain ⟨c₂⟩ := IsCofiltered.cone_nonempty H₂
simp only [H₂] at c₂
exact ⟨⟨StructuredArrow.mk (c₁.pt.hom ≫ G.map c₂.pt.hom),
⟨fun j => StructuredArrow.homMk (c₂.π.app j).right (by simp [← G.map_comp]),
fun j j' f => by simpa using (c₂.w f).symm⟩⟩⟩
section
variable {F}
/-- Being a representably flat functor is closed under natural isomorphisms. -/
theorem RepresentablyFlat.of_iso [RepresentablyFlat F] {G : C ⥤ D} (α : F ≅ G) :
RepresentablyFlat G where
cofiltered _ := IsCofiltered.of_equivalence (StructuredArrow.mapNatIso α)
theorem RepresentablyCoflat.of_iso [RepresentablyCoflat F] {G : C ⥤ D} (α : F ≅ G) :
RepresentablyCoflat G where
filtered _ := IsFiltered.of_equivalence (CostructuredArrow.mapNatIso α)
end
theorem representablyCoflat_op_iff : RepresentablyCoflat F.op ↔ RepresentablyFlat F := by
refine ⟨fun _ => ⟨fun X => ?_⟩, fun _ => ⟨fun ⟨X⟩ => ?_⟩⟩
· suffices IsFiltered (StructuredArrow X F)ᵒᵖ from isCofiltered_of_isFiltered_op _
apply IsFiltered.of_equivalence (structuredArrowOpEquivalence _ _).symm
· suffices IsCofiltered (CostructuredArrow F.op (op X))ᵒᵖ from isFiltered_of_isCofiltered_op _
suffices IsCofiltered (StructuredArrow X F)ᵒᵖᵒᵖ from
IsCofiltered.of_equivalence (structuredArrowOpEquivalence _ _).op
apply IsCofiltered.of_equivalence (opOpEquivalence _)
theorem representablyFlat_op_iff : RepresentablyFlat F.op ↔ RepresentablyCoflat F := by
refine ⟨fun _ => ⟨fun X => ?_⟩, fun _ => ⟨fun ⟨X⟩ => ?_⟩⟩
· suffices IsCofiltered (CostructuredArrow F X)ᵒᵖ from isFiltered_of_isCofiltered_op _
apply IsCofiltered.of_equivalence (costructuredArrowOpEquivalence _ _).symm
· suffices IsFiltered (StructuredArrow (op X) F.op)ᵒᵖ from isCofiltered_of_isFiltered_op _
suffices IsFiltered (CostructuredArrow F X)ᵒᵖᵒᵖ from
IsFiltered.of_equivalence (costructuredArrowOpEquivalence _ _).op
apply IsFiltered.of_equivalence (opOpEquivalence _)
instance [RepresentablyFlat F] : RepresentablyCoflat F.op :=
(representablyCoflat_op_iff F).2 inferInstance
instance [RepresentablyCoflat F] : RepresentablyFlat F.op :=
(representablyFlat_op_iff F).2 inferInstance
instance RepresentablyCoflat.comp (G : D ⥤ E) [RepresentablyCoflat F] [RepresentablyCoflat G] :
RepresentablyCoflat (F ⋙ G) :=
(representablyFlat_op_iff _).1 <| inferInstanceAs <| RepresentablyFlat (F.op ⋙ G.op)
lemma final_of_representablyFlat [h : RepresentablyFlat F] : F.Final where
out _ := IsCofiltered.isConnected _
lemma initial_of_representablyCoflat [h : RepresentablyCoflat F] : F.Initial where
out _ := IsFiltered.isConnected _
end RepresentablyFlat
section HasLimit
variable {C : Type u₁} [Category.{v₁} C] {D : Type u₂} [Category.{v₂} D]
theorem flat_of_preservesFiniteLimits [HasFiniteLimits C] (F : C ⥤ D) [PreservesFiniteLimits F] :
RepresentablyFlat F :=
⟨fun X =>
haveI : HasFiniteLimits (StructuredArrow X F) := by
apply hasFiniteLimits_of_hasFiniteLimits_of_size.{v₁} (StructuredArrow X F)
exact fun _ _ _ => HasLimitsOfShape.mk
IsCofiltered.of_hasFiniteLimits _⟩
theorem coflat_of_preservesFiniteColimits [HasFiniteColimits C] (F : C ⥤ D)
[PreservesFiniteColimits F] : RepresentablyCoflat F :=
let _ := preservesFiniteLimits_op F
(representablyFlat_op_iff _).1 (flat_of_preservesFiniteLimits _)
namespace PreservesFiniteLimitsOfFlat
open StructuredArrow
variable {J : Type v₁} [SmallCategory J] [FinCategory J] {K : J ⥤ C}
variable (F : C ⥤ D) [RepresentablyFlat F] {c : Cone K} (hc : IsLimit c) (s : Cone (K ⋙ F))
/-- (Implementation).
Given a limit cone `c : cone K` and a cone `s : cone (K ⋙ F)` with `F` representably flat,
`s` can factor through `F.mapCone c`.
-/
noncomputable def lift : s.pt ⟶ F.obj c.pt :=
let s' := IsCofiltered.cone (s.toStructuredArrow ⋙ StructuredArrow.pre _ K F)
s'.pt.hom ≫
(F.map <|
hc.lift <|
(Cones.postcompose
({ app := fun _ => 𝟙 _ } :
(s.toStructuredArrow ⋙ pre s.pt K F) ⋙ proj s.pt F ⟶ K)).obj <|
(StructuredArrow.proj s.pt F).mapCone s')
theorem fac (x : J) : lift F hc s ≫ (F.mapCone c).π.app x = s.π.app x := by
simp [lift, ← Functor.map_comp]
theorem uniq {K : J ⥤ C} {c : Cone K} (hc : IsLimit c) (s : Cone (K ⋙ F))
(f₁ f₂ : s.pt ⟶ F.obj c.pt) (h₁ : ∀ j : J, f₁ ≫ (F.mapCone c).π.app j = s.π.app j)
(h₂ : ∀ j : J, f₂ ≫ (F.mapCone c).π.app j = s.π.app j) : f₁ = f₂ := by
-- We can make two cones over the diagram of `s` via `f₁` and `f₂`.
let α₁ : (F.mapCone c).toStructuredArrow ⋙ map f₁ ⟶ s.toStructuredArrow :=
{ app := fun X => eqToHom (by simp [← h₁]) }
let α₂ : (F.mapCone c).toStructuredArrow ⋙ map f₂ ⟶ s.toStructuredArrow :=
{ app := fun X => eqToHom (by simp [← h₂]) }
let c₁ : Cone (s.toStructuredArrow ⋙ pre s.pt K F) :=
(Cones.postcompose (Functor.whiskerRight α₁ (pre s.pt K F) :)).obj
(c.toStructuredArrowCone F f₁)
let c₂ : Cone (s.toStructuredArrow ⋙ pre s.pt K F) :=
(Cones.postcompose (Functor.whiskerRight α₂ (pre s.pt K F) :)).obj
(c.toStructuredArrowCone F f₂)
-- The two cones can then be combined and we may obtain a cone over the two cones since
-- `StructuredArrow s.pt F` is cofiltered.
let c₀ := IsCofiltered.cone (biconeMk _ c₁ c₂)
let g₁ : c₀.pt ⟶ c₁.pt := c₀.π.app Bicone.left
let g₂ : c₀.pt ⟶ c₂.pt := c₀.π.app Bicone.right
-- Then `g₁.right` and `g₂.right` are two maps from the same cone into the `c`.
have : ∀ j : J, g₁.right ≫ c.π.app j = g₂.right ≫ c.π.app j := by
intro j
injection c₀.π.naturality (BiconeHom.left j) with _ e₁
injection c₀.π.naturality (BiconeHom.right j) with _ e₂
convert e₁.symm.trans e₂ <;> simp [c₁, c₂]
have : c.extend g₁.right = c.extend g₂.right := by
unfold Cone.extend
congr 1
ext x
apply this
-- And thus they are equal as `c` is the limit.
have : g₁.right = g₂.right := calc
g₁.right = hc.lift (c.extend g₁.right) := by
apply hc.uniq (c.extend _)
aesop
_ = hc.lift (c.extend g₂.right) := by
congr
_ = g₂.right := by
symm
apply hc.uniq (c.extend _)
aesop
-- Finally, since `fᵢ` factors through `F(gᵢ)`, the result follows.
calc
f₁ = 𝟙 _ ≫ f₁ := by simp
_ = c₀.pt.hom ≫ F.map g₁.right := g₁.w
_ = c₀.pt.hom ≫ F.map g₂.right := by rw [this]
_ = 𝟙 _ ≫ f₂ := g₂.w.symm
_ = f₂ := by simp
end PreservesFiniteLimitsOfFlat
/-- Representably flat functors preserve finite limits. -/
lemma preservesFiniteLimits_of_flat (F : C ⥤ D) [RepresentablyFlat F] :
PreservesFiniteLimits F := by
apply preservesFiniteLimits_of_preservesFiniteLimitsOfSize
intro J _ _; constructor
intro K; constructor
intro c hc
constructor
exact
{ lift := PreservesFiniteLimitsOfFlat.lift F hc
fac := PreservesFiniteLimitsOfFlat.fac F hc
uniq := fun s m h => by
apply PreservesFiniteLimitsOfFlat.uniq F hc
· exact h
· exact PreservesFiniteLimitsOfFlat.fac F hc s }
/-- Representably coflat functors preserve finite colimits. -/
lemma preservesFiniteColimits_of_coflat (F : C ⥤ D) [RepresentablyCoflat F] :
PreservesFiniteColimits F :=
letI _ := preservesFiniteLimits_of_flat F.op
preservesFiniteColimits_of_op _
/-- If `C` is finitely complete, then `F : C ⥤ D` is representably flat iff it preserves
finite limits.
-/
lemma preservesFiniteLimits_iff_flat [HasFiniteLimits C] (F : C ⥤ D) :
RepresentablyFlat F ↔ PreservesFiniteLimits F :=
⟨fun _ ↦ preservesFiniteLimits_of_flat F, fun _ ↦ flat_of_preservesFiniteLimits F⟩
/-- If `C` is finitely cocomplete, then `F : C ⥤ D` is representably coflat iff it preserves
finite colimits. -/
lemma preservesFiniteColimits_iff_coflat [HasFiniteColimits C] (F : C ⥤ D) :
RepresentablyCoflat F ↔ PreservesFiniteColimits F :=
⟨fun _ => preservesFiniteColimits_of_coflat F, fun _ => coflat_of_preservesFiniteColimits F⟩
end HasLimit
section SmallCategory
variable {C D : Type u₁} [SmallCategory C] [SmallCategory D] (E : Type u₂) [Category.{u₁} E]
/-- (Implementation)
The evaluation of `F.lan` at `X` is the colimit over the costructured arrows over `X`.
-/
noncomputable def lanEvaluationIsoColim (F : C ⥤ D) (X : D)
[∀ X : D, HasColimitsOfShape (CostructuredArrow F X) E] :
F.lan ⋙ (evaluation D E).obj X ≅
(Functor.whiskeringLeft _ _ E).obj (CostructuredArrow.proj F X) ⋙ colim :=
NatIso.ofComponents (fun G =>
IsColimit.coconePointUniqueUpToIso
(Functor.isPointwiseLeftKanExtensionLeftKanExtensionUnit F G X)
(colimit.isColimit _)) (fun {G₁ G₂} φ => by
apply (Functor.isPointwiseLeftKanExtensionLeftKanExtensionUnit F G₁ X).hom_ext
intro T
have h₁ := fun (G : C ⥤ E) => IsColimit.comp_coconePointUniqueUpToIso_hom
(Functor.isPointwiseLeftKanExtensionLeftKanExtensionUnit F G X) (colimit.isColimit _) T
have h₂ := congr_app (F.lanUnit.naturality φ) T.left
dsimp at h₁ h₂ ⊢
simp only [Category.assoc] at h₁ ⊢
simp only [Functor.lan, Functor.lanUnit] at h₂ ⊢
rw [reassoc_of% h₁, NatTrans.naturality_assoc, ← reassoc_of% h₂, h₁,
ι_colimMap, Functor.whiskerLeft_app]
rfl)
variable [HasForget.{u₁} E] [HasLimits E] [HasColimits E]
variable [ReflectsLimits (forget E)] [PreservesFilteredColimits (forget E)]
variable [PreservesLimits (forget E)]
/-- If `F : C ⥤ D` is a representably flat functor between small categories, then the functor
`Lan F.op` that takes presheaves over `C` to presheaves over `D` preserves finite limits.
-/
noncomputable instance lan_preservesFiniteLimits_of_flat (F : C ⥤ D) [RepresentablyFlat F] :
PreservesFiniteLimits (F.op.lan : _ ⥤ Dᵒᵖ ⥤ E) := by
apply preservesFiniteLimits_of_preservesFiniteLimitsOfSize.{u₁}
intro J _ _
apply preservesLimitsOfShape_of_evaluation (F.op.lan : (Cᵒᵖ ⥤ E) ⥤ Dᵒᵖ ⥤ E) J
intro K
haveI : IsFiltered (CostructuredArrow F.op K) :=
IsFiltered.of_equivalence (structuredArrowOpEquivalence F (unop K))
exact preservesLimitsOfShape_of_natIso (lanEvaluationIsoColim _ _ _).symm
instance lan_flat_of_flat (F : C ⥤ D) [RepresentablyFlat F] :
RepresentablyFlat (F.op.lan : _ ⥤ Dᵒᵖ ⥤ E) :=
flat_of_preservesFiniteLimits _
variable [HasFiniteLimits C]
instance lan_preservesFiniteLimits_of_preservesFiniteLimits (F : C ⥤ D)
[PreservesFiniteLimits F] : PreservesFiniteLimits (F.op.lan : _ ⥤ Dᵒᵖ ⥤ E) := by
haveI := flat_of_preservesFiniteLimits F
infer_instance
theorem flat_iff_lan_flat (F : C ⥤ D) :
RepresentablyFlat F ↔ RepresentablyFlat (F.op.lan : _ ⥤ Dᵒᵖ ⥤ Type u₁) :=
⟨fun _ => inferInstance, fun H => by
haveI := preservesFiniteLimits_of_flat (F.op.lan : _ ⥤ Dᵒᵖ ⥤ Type u₁)
haveI : PreservesFiniteLimits F := by
apply preservesFiniteLimits_of_preservesFiniteLimitsOfSize.{u₁}
intros; apply preservesLimit_of_lan_preservesLimit
apply flat_of_preservesFiniteLimits⟩
/-- If `C` is finitely complete, then `F : C ⥤ D` preserves finite limits iff
`Lan F.op : (Cᵒᵖ ⥤ Type*) ⥤ (Dᵒᵖ ⥤ Type*)` preserves finite limits.
-/
lemma preservesFiniteLimits_iff_lan_preservesFiniteLimits (F : C ⥤ D) :
PreservesFiniteLimits F ↔ PreservesFiniteLimits (F.op.lan : _ ⥤ Dᵒᵖ ⥤ Type u₁) :=
⟨fun _ ↦ inferInstance,
fun _ ↦ preservesFiniteLimits_of_preservesFiniteLimitsOfSize.{u₁} _
(fun _ _ _ ↦ preservesLimit_of_lan_preservesLimit _ _)⟩
end SmallCategory
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Functor/EpiMono.lean | import Mathlib.CategoryTheory.EpiMono
import Mathlib.CategoryTheory.Limits.Shapes.StrongEpi
import Mathlib.CategoryTheory.LiftingProperties.Adjunction
/-!
# Preservation and reflection of monomorphisms and epimorphisms
We provide typeclasses that state that a functor preserves or reflects monomorphisms or
epimorphisms.
-/
open CategoryTheory
universe v₁ v₂ v₃ u₁ u₂ u₃
namespace CategoryTheory.Functor
variable {C : Type u₁} [Category.{v₁} C] {D : Type u₂} [Category.{v₂} D] {E : Type u₃}
[Category.{v₃} E]
/-- A functor preserves monomorphisms if it maps monomorphisms to monomorphisms. -/
class PreservesMonomorphisms (F : C ⥤ D) : Prop where
/-- A functor preserves monomorphisms if it maps monomorphisms to monomorphisms. -/
preserves : ∀ {X Y : C} (f : X ⟶ Y) [Mono f], Mono (F.map f)
instance map_mono (F : C ⥤ D) [PreservesMonomorphisms F] {X Y : C} (f : X ⟶ Y) [Mono f] :
Mono (F.map f) :=
PreservesMonomorphisms.preserves f
/-- A functor preserves epimorphisms if it maps epimorphisms to epimorphisms. -/
class PreservesEpimorphisms (F : C ⥤ D) : Prop where
/-- A functor preserves epimorphisms if it maps epimorphisms to epimorphisms. -/
preserves : ∀ {X Y : C} (f : X ⟶ Y) [Epi f], Epi (F.map f)
instance map_epi (F : C ⥤ D) [PreservesEpimorphisms F] {X Y : C} (f : X ⟶ Y) [Epi f] :
Epi (F.map f) :=
PreservesEpimorphisms.preserves f
/-- A functor reflects monomorphisms if morphisms that are mapped to monomorphisms are themselves
monomorphisms. -/
class ReflectsMonomorphisms (F : C ⥤ D) : Prop where
/-- A functor reflects monomorphisms if morphisms that are mapped to monomorphisms are themselves
monomorphisms. -/
reflects : ∀ {X Y : C} (f : X ⟶ Y), Mono (F.map f) → Mono f
theorem mono_of_mono_map (F : C ⥤ D) [ReflectsMonomorphisms F] {X Y : C} {f : X ⟶ Y}
(h : Mono (F.map f)) : Mono f :=
ReflectsMonomorphisms.reflects f h
/-- A functor reflects epimorphisms if morphisms that are mapped to epimorphisms are themselves
epimorphisms. -/
class ReflectsEpimorphisms (F : C ⥤ D) : Prop where
/-- A functor reflects epimorphisms if morphisms that are mapped to epimorphisms are themselves
epimorphisms. -/
reflects : ∀ {X Y : C} (f : X ⟶ Y), Epi (F.map f) → Epi f
theorem epi_of_epi_map (F : C ⥤ D) [ReflectsEpimorphisms F] {X Y : C} {f : X ⟶ Y}
(h : Epi (F.map f)) : Epi f :=
ReflectsEpimorphisms.reflects f h
instance preservesMonomorphisms_comp (F : C ⥤ D) (G : D ⥤ E) [PreservesMonomorphisms F]
[PreservesMonomorphisms G] : PreservesMonomorphisms (F ⋙ G) where
preserves f h := by
rw [comp_map]
exact inferInstance
instance preservesEpimorphisms_comp (F : C ⥤ D) (G : D ⥤ E) [PreservesEpimorphisms F]
[PreservesEpimorphisms G] : PreservesEpimorphisms (F ⋙ G) where
preserves f h := by
rw [comp_map]
exact inferInstance
instance reflectsMonomorphisms_comp (F : C ⥤ D) (G : D ⥤ E) [ReflectsMonomorphisms F]
[ReflectsMonomorphisms G] : ReflectsMonomorphisms (F ⋙ G) where
reflects _ h := F.mono_of_mono_map (G.mono_of_mono_map h)
instance reflectsEpimorphisms_comp (F : C ⥤ D) (G : D ⥤ E) [ReflectsEpimorphisms F]
[ReflectsEpimorphisms G] : ReflectsEpimorphisms (F ⋙ G) where
reflects _ h := F.epi_of_epi_map (G.epi_of_epi_map h)
theorem preservesEpimorphisms_of_preserves_of_reflects (F : C ⥤ D) (G : D ⥤ E)
[PreservesEpimorphisms (F ⋙ G)] [ReflectsEpimorphisms G] : PreservesEpimorphisms F :=
⟨fun f _ => G.epi_of_epi_map <| show Epi ((F ⋙ G).map f) from inferInstance⟩
theorem preservesMonomorphisms_of_preserves_of_reflects (F : C ⥤ D) (G : D ⥤ E)
[PreservesMonomorphisms (F ⋙ G)] [ReflectsMonomorphisms G] : PreservesMonomorphisms F :=
⟨fun f _ => G.mono_of_mono_map <| show Mono ((F ⋙ G).map f) from inferInstance⟩
theorem reflectsEpimorphisms_of_preserves_of_reflects (F : C ⥤ D) (G : D ⥤ E)
[PreservesEpimorphisms G] [ReflectsEpimorphisms (F ⋙ G)] : ReflectsEpimorphisms F :=
⟨fun f _ => (F ⋙ G).epi_of_epi_map <| show Epi (G.map (F.map f)) from inferInstance⟩
theorem reflectsMonomorphisms_of_preserves_of_reflects (F : C ⥤ D) (G : D ⥤ E)
[PreservesMonomorphisms G] [ReflectsMonomorphisms (F ⋙ G)] : ReflectsMonomorphisms F :=
⟨fun f _ => (F ⋙ G).mono_of_mono_map <| show Mono (G.map (F.map f)) from inferInstance⟩
lemma preservesMonomorphisms.of_natTrans {F G : C ⥤ D} [PreservesMonomorphisms F]
(f : G ⟶ F) [∀ X, Mono (f.app X)] :
PreservesMonomorphisms G where
preserves {X Y} π hπ := by
suffices Mono (G.map π ≫ f.app Y) from mono_of_mono (G.map π) (f.app Y)
rw [f.naturality π]
infer_instance
theorem preservesMonomorphisms.of_iso {F G : C ⥤ D} [PreservesMonomorphisms F] (α : F ≅ G) :
PreservesMonomorphisms G :=
of_natTrans α.inv
theorem preservesMonomorphisms.iso_iff {F G : C ⥤ D} (α : F ≅ G) :
PreservesMonomorphisms F ↔ PreservesMonomorphisms G :=
⟨fun _ => preservesMonomorphisms.of_iso α, fun _ => preservesMonomorphisms.of_iso α.symm⟩
lemma preservesEpimorphisms.of_natTrans {F G : C ⥤ D} [PreservesEpimorphisms F]
(f : F ⟶ G) [∀ X, Epi (f.app X)] :
PreservesEpimorphisms G where
preserves {X Y} π hπ := by
suffices Epi (f.app X ≫ G.map π) from epi_of_epi (f.app X) (G.map π)
rw [← f.naturality π]
infer_instance
theorem preservesEpimorphisms.of_iso {F G : C ⥤ D} [PreservesEpimorphisms F] (α : F ≅ G) :
PreservesEpimorphisms G :=
of_natTrans α.hom
theorem preservesEpimorphisms.iso_iff {F G : C ⥤ D} (α : F ≅ G) :
PreservesEpimorphisms F ↔ PreservesEpimorphisms G :=
⟨fun _ => preservesEpimorphisms.of_iso α, fun _ => preservesEpimorphisms.of_iso α.symm⟩
theorem reflectsMonomorphisms.of_iso {F G : C ⥤ D} [ReflectsMonomorphisms F] (α : F ≅ G) :
ReflectsMonomorphisms G :=
{ reflects := fun {X} {Y} f h => by
apply F.mono_of_mono_map
suffices F.map f = (α.app X).hom ≫ G.map f ≫ (α.app Y).inv from this ▸ mono_comp _ _
rw [← Category.assoc, Iso.eq_comp_inv, Iso.app_hom, Iso.app_hom, NatTrans.naturality] }
theorem reflectsMonomorphisms.iso_iff {F G : C ⥤ D} (α : F ≅ G) :
ReflectsMonomorphisms F ↔ ReflectsMonomorphisms G :=
⟨fun _ => reflectsMonomorphisms.of_iso α, fun _ => reflectsMonomorphisms.of_iso α.symm⟩
theorem reflectsEpimorphisms.of_iso {F G : C ⥤ D} [ReflectsEpimorphisms F] (α : F ≅ G) :
ReflectsEpimorphisms G :=
{ reflects := fun {X} {Y} f h => by
apply F.epi_of_epi_map
suffices F.map f = (α.app X).hom ≫ G.map f ≫ (α.app Y).inv from this ▸ epi_comp _ _
rw [← Category.assoc, Iso.eq_comp_inv, Iso.app_hom, Iso.app_hom, NatTrans.naturality] }
theorem reflectsEpimorphisms.iso_iff {F G : C ⥤ D} (α : F ≅ G) :
ReflectsEpimorphisms F ↔ ReflectsEpimorphisms G :=
⟨fun _ => reflectsEpimorphisms.of_iso α, fun _ => reflectsEpimorphisms.of_iso α.symm⟩
theorem preservesEpimorphisms_of_adjunction {F : C ⥤ D} {G : D ⥤ C} (adj : F ⊣ G) :
PreservesEpimorphisms F :=
{ preserves := fun {X} {Y} f hf =>
⟨by
intro Z g h H
replace H := congr_arg (adj.homEquiv X Z) H
rwa [adj.homEquiv_naturality_left, adj.homEquiv_naturality_left, cancel_epi,
Equiv.apply_eq_iff_eq] at H⟩ }
@[deprecated (since := "2025-07-27")]
alias preservesEpimorphsisms_of_adjunction := preservesEpimorphisms_of_adjunction
instance (priority := 100) preservesEpimorphisms_of_isLeftAdjoint (F : C ⥤ D) [IsLeftAdjoint F] :
PreservesEpimorphisms F :=
preservesEpimorphisms_of_adjunction (Adjunction.ofIsLeftAdjoint F)
theorem preservesMonomorphisms_of_adjunction {F : C ⥤ D} {G : D ⥤ C} (adj : F ⊣ G) :
PreservesMonomorphisms G :=
{ preserves := fun {X} {Y} f hf =>
⟨by
intro Z g h H
replace H := congr_arg (adj.homEquiv Z Y).symm H
rwa [adj.homEquiv_naturality_right_symm, adj.homEquiv_naturality_right_symm, cancel_mono,
Equiv.apply_eq_iff_eq] at H⟩ }
instance (priority := 100) preservesMonomorphisms_of_isRightAdjoint (F : C ⥤ D) [IsRightAdjoint F] :
PreservesMonomorphisms F :=
preservesMonomorphisms_of_adjunction (Adjunction.ofIsRightAdjoint F)
instance (priority := 100) reflectsMonomorphisms_of_faithful (F : C ⥤ D) [Faithful F] :
ReflectsMonomorphisms F where
reflects {X} {Y} f _ :=
⟨fun {Z} g h hgh =>
F.map_injective ((cancel_mono (F.map f)).1 (by rw [← F.map_comp, hgh, F.map_comp]))⟩
instance (priority := 100) reflectsEpimorphisms_of_faithful (F : C ⥤ D) [Faithful F] :
ReflectsEpimorphisms F where
reflects {X} {Y} f _ :=
⟨fun {Z} g h hgh =>
F.map_injective ((cancel_epi (F.map f)).1 (by rw [← F.map_comp, hgh, F.map_comp]))⟩
instance {F G : C ⥤ D} (f : F ⟶ G) [IsSplitEpi f] (X : C) : IsSplitEpi (f.app X) :=
inferInstanceAs (IsSplitEpi (((evaluation C D).obj X).map f))
instance {F G : C ⥤ D} (f : F ⟶ G) [IsSplitMono f] (X : C) : IsSplitMono (f.app X) :=
inferInstanceAs (IsSplitMono (((evaluation C D).obj X).map f))
lemma preservesEpimorphisms.ofRetract {F G : C ⥤ D} (r : Retract G F) [F.PreservesEpimorphisms] :
G.PreservesEpimorphisms where
preserves := (preservesEpimorphisms.of_natTrans r.r).preserves
lemma preservesMonomorphisms.ofRetract {F G : C ⥤ D} (r : Retract G F) [F.PreservesMonomorphisms] :
G.PreservesMonomorphisms where
preserves := (preservesMonomorphisms.of_natTrans r.i).preserves
section
variable (F : C ⥤ D) {X Y : C} (f : X ⟶ Y)
/-- If `F` is a fully faithful functor, split epimorphisms are preserved and reflected by `F`. -/
noncomputable def splitEpiEquiv [Full F] [Faithful F] : SplitEpi f ≃ SplitEpi (F.map f) where
toFun f := f.map F
invFun s := ⟨F.preimage s.section_, by
apply F.map_injective
simp only [map_comp, map_preimage, map_id]
apply SplitEpi.id⟩
left_inv := by cat_disch
right_inv x := by cat_disch
@[simp]
theorem isSplitEpi_iff [Full F] [Faithful F] : IsSplitEpi (F.map f) ↔ IsSplitEpi f := by
constructor
· intro h
exact IsSplitEpi.mk' ((splitEpiEquiv F f).invFun h.exists_splitEpi.some)
· intro h
exact IsSplitEpi.mk' ((splitEpiEquiv F f).toFun h.exists_splitEpi.some)
/-- If `F` is a fully faithful functor, split monomorphisms are preserved and reflected by `F`. -/
noncomputable def splitMonoEquiv [Full F] [Faithful F] : SplitMono f ≃ SplitMono (F.map f) where
toFun f := f.map F
invFun s := ⟨F.preimage s.retraction, by
apply F.map_injective
simp only [map_comp, map_preimage, map_id]
apply SplitMono.id⟩
left_inv := by cat_disch
right_inv x := by cat_disch
@[simp]
theorem isSplitMono_iff [Full F] [Faithful F] : IsSplitMono (F.map f) ↔ IsSplitMono f := by
constructor
· intro h
exact IsSplitMono.mk' ((splitMonoEquiv F f).invFun h.exists_splitMono.some)
· intro h
exact IsSplitMono.mk' ((splitMonoEquiv F f).toFun h.exists_splitMono.some)
@[simp]
theorem epi_map_iff_epi [hF₁ : PreservesEpimorphisms F] [hF₂ : ReflectsEpimorphisms F] :
Epi (F.map f) ↔ Epi f := by
constructor
· exact F.epi_of_epi_map
· intro h
exact F.map_epi f
@[simp]
theorem mono_map_iff_mono [hF₁ : PreservesMonomorphisms F] [hF₂ : ReflectsMonomorphisms F] :
Mono (F.map f) ↔ Mono f := by
constructor
· exact F.mono_of_mono_map
· intro h
exact F.map_mono f
/-- If `F : C ⥤ D` is an equivalence of categories and `C` is a `split_epi_category`,
then `D` also is. -/
theorem splitEpiCategoryImpOfIsEquivalence [IsEquivalence F] [SplitEpiCategory C] :
SplitEpiCategory D :=
⟨fun {X} {Y} f => by
intro
rw [← F.inv.isSplitEpi_iff f]
apply isSplitEpi_of_epi⟩
end
end CategoryTheory.Functor
namespace CategoryTheory.Adjunction
variable {C D : Type*} [Category C] [Category D] {F : C ⥤ D} {F' : D ⥤ C} {A B : C}
theorem strongEpi_map_of_strongEpi (adj : F ⊣ F') (f : A ⟶ B) [F'.PreservesMonomorphisms]
[F.PreservesEpimorphisms] [StrongEpi f] : StrongEpi (F.map f) :=
⟨inferInstance, fun X Y Z => by
intro
rw [adj.hasLiftingProperty_iff]
infer_instance⟩
instance strongEpi_map_of_isEquivalence [F.IsEquivalence] (f : A ⟶ B) [_h : StrongEpi f] :
StrongEpi (F.map f) :=
F.asEquivalence.toAdjunction.strongEpi_map_of_strongEpi f
instance (adj : F ⊣ F') {X : C} {Y : D} (f : F.obj X ⟶ Y) [hf : Mono f] [F.ReflectsMonomorphisms] :
Mono (adj.homEquiv _ _ f) :=
F.mono_of_mono_map <| by
rw [← (homEquiv adj X Y).symm_apply_apply f] at hf
exact mono_of_mono_fac (adj.homEquiv_counit _ _ _).symm
end CategoryTheory.Adjunction
namespace CategoryTheory.Functor
variable {C D : Type*} [Category C] [Category D] {F : C ⥤ D} {A B : C} (f : A ⟶ B)
@[simp]
theorem strongEpi_map_iff_strongEpi_of_isEquivalence [IsEquivalence F] :
StrongEpi (F.map f) ↔ StrongEpi f := by
constructor
· intro
have e : Arrow.mk f ≅ Arrow.mk (F.inv.map (F.map f)) :=
Arrow.isoOfNatIso F.asEquivalence.unitIso (Arrow.mk f)
rw [StrongEpi.iff_of_arrow_iso e]
infer_instance
· intro
infer_instance
end CategoryTheory.Functor |
.lake/packages/mathlib/Mathlib/CategoryTheory/Functor/Category.lean | import Mathlib.CategoryTheory.NatTrans
import Mathlib.CategoryTheory.Iso
/-!
# The category of functors and natural transformations between two fixed categories.
We provide the category instance on `C ⥤ D`, with morphisms the natural transformations.
At the end of the file, we provide the left and right unitors, and the associator,
for functor composition.
(In fact functor composition is definitionally associative, but very often relying on this causes
extremely slow elaboration, so it is better to insert it explicitly.)
## Universes
If `C` and `D` are both small categories at the same universe level,
this is another small category at that level.
However if `C` and `D` are both large categories at the same universe level,
this is a small category at the next higher level.
-/
set_option mathlib.tactic.category.grind true
namespace CategoryTheory
-- declare the `v`'s first; see note [category theory universes].
universe v₁ v₂ v₃ v₄ u₁ u₂ u₃ u₄
open NatTrans Category CategoryTheory.Functor
variable (C : Type u₁) [Category.{v₁} C] (D : Type u₂) [Category.{v₂} D]
attribute [local simp] vcomp_app
variable {C D} {E : Type u₃} [Category.{v₃} E]
variable {E' : Type u₄} [Category.{v₄} E']
variable {F G H I : C ⥤ D}
attribute [local grind =] NatTrans.id_app' in
/-- `Functor.category C D` gives the category structure on functors and natural transformations
between categories `C` and `D`.
Notice that if `C` and `D` are both small categories at the same universe level,
this is another small category at that level.
However if `C` and `D` are both large categories at the same universe level,
this is a small category at the next higher level.
-/
instance Functor.category : Category.{max u₁ v₂} (C ⥤ D) where
Hom F G := NatTrans F G
id F := NatTrans.id F
comp α β := vcomp α β
namespace NatTrans
@[ext, grind ext]
theorem ext' {α β : F ⟶ G} (w : α.app = β.app) : α = β := NatTrans.ext w
@[simp]
theorem vcomp_eq_comp (α : F ⟶ G) (β : G ⟶ H) : vcomp α β = α ≫ β := rfl
theorem vcomp_app' (α : F ⟶ G) (β : G ⟶ H) (X : C) : (α ≫ β).app X = α.app X ≫ β.app X := rfl
theorem congr_app {α β : F ⟶ G} (h : α = β) (X : C) : α.app X = β.app X := by rw [h]
@[simp, grind =]
theorem id_app (F : C ⥤ D) (X : C) : (𝟙 F : F ⟶ F).app X = 𝟙 (F.obj X) := rfl
@[simp, grind _=_]
theorem comp_app {F G H : C ⥤ D} (α : F ⟶ G) (β : G ⟶ H) (X : C) :
(α ≫ β).app X = α.app X ≫ β.app X := rfl
attribute [reassoc] comp_app
@[reassoc]
theorem app_naturality {F G : C ⥤ D ⥤ E} (T : F ⟶ G) (X : C) {Y Z : D} (f : Y ⟶ Z) :
(F.obj X).map f ≫ (T.app X).app Z = (T.app X).app Y ≫ (G.obj X).map f :=
(T.app X).naturality f
@[reassoc (attr := simp)]
theorem naturality_app {F G : C ⥤ D ⥤ E} (T : F ⟶ G) (Z : D) {X Y : C} (f : X ⟶ Y) :
(F.map f).app Z ≫ (T.app Y).app Z = (T.app X).app Z ≫ (G.map f).app Z :=
congr_fun (congr_arg app (T.naturality f)) Z
@[reassoc]
theorem naturality_app_app {F G : C ⥤ D ⥤ E ⥤ E'}
(α : F ⟶ G) {X₁ Y₁ : C} (f : X₁ ⟶ Y₁) (X₂ : D) (X₃ : E) :
((F.map f).app X₂).app X₃ ≫ ((α.app Y₁).app X₂).app X₃ =
((α.app X₁).app X₂).app X₃ ≫ ((G.map f).app X₂).app X₃ :=
congr_app (NatTrans.naturality_app α X₂ f) X₃
/-- A natural transformation is a monomorphism if each component is. -/
theorem mono_of_mono_app (α : F ⟶ G) [∀ X : C, Mono (α.app X)] : Mono α :=
⟨fun g h eq => by
ext X
rw [← cancel_mono (α.app X), ← comp_app, eq, comp_app]⟩
/-- A natural transformation is an epimorphism if each component is. -/
theorem epi_of_epi_app (α : F ⟶ G) [∀ X : C, Epi (α.app X)] : Epi α :=
⟨fun g h eq => by
ext X
rw [← cancel_epi (α.app X), ← comp_app, eq, comp_app]⟩
/-- The monoid of natural transformations of the identity is commutative. -/
lemma id_comm (α β : (𝟭 C) ⟶ (𝟭 C)) : α ≫ β = β ≫ α := by
ext X
exact (α.naturality (β.app X)).symm
/-- `hcomp α β` is the horizontal composition of natural transformations. -/
@[simps (attr := grind =)]
def hcomp {H I : D ⥤ E} (α : F ⟶ G) (β : H ⟶ I) : F ⋙ H ⟶ G ⋙ I where
app := fun X : C => β.app (F.obj X) ≫ I.map (α.app X)
/-- Notation for horizontal composition of natural transformations. -/
infixl:80 " ◫ " => hcomp
theorem hcomp_id_app {H : D ⥤ E} (α : F ⟶ G) (X : C) : (α ◫ 𝟙 H).app X = H.map (α.app X) := by
simp
theorem id_hcomp_app {H : E ⥤ C} (α : F ⟶ G) (X : E) : (𝟙 H ◫ α).app X = α.app _ := by simp
-- Note that we don't yet prove a `hcomp_assoc` lemma here: even stating it is painful, because we
-- need to use associativity of functor composition. (It's true without the explicit associator,
-- because functor composition is definitionally associative,
-- but relying on the definitional equality causes bad problems with elaboration later.)
theorem exchange {I J K : D ⥤ E} (α : F ⟶ G) (β : G ⟶ H) (γ : I ⟶ J) (δ : J ⟶ K) :
(α ≫ β) ◫ (γ ≫ δ) = (α ◫ γ) ≫ β ◫ δ := by
cat_disch
end NatTrans
namespace Functor
/-- Flip the arguments of a bifunctor. See also `Currying.lean`. -/
@[simps (attr := grind =) obj_obj obj_map]
protected def flip (F : C ⥤ D ⥤ E) : D ⥤ C ⥤ E where
obj k :=
{ obj := fun j => (F.obj j).obj k,
map := fun f => (F.map f).app k, }
map f := { app := fun j => (F.obj j).map f }
-- `@[simps]` doesn't produce a nicely stated lemma here:
-- the implicit arguments for `app` use the definition of `flip`, rather than `flip` itself.
@[simp, grind =] theorem flip_map_app (F : C ⥤ D ⥤ E) {d d' : D} (f : d ⟶ d') (c : C) :
(F.flip.map f).app c = (F.obj c).map f := rfl
/-- The left unitor, a natural isomorphism `((𝟭 _) ⋙ F) ≅ F`.
-/
@[simps]
def leftUnitor (F : C ⥤ D) :
𝟭 C ⋙ F ≅ F where
hom := { app := fun X => 𝟙 (F.obj X) }
inv := { app := fun X => 𝟙 (F.obj X) }
/-- The right unitor, a natural isomorphism `(F ⋙ (𝟭 B)) ≅ F`.
-/
@[simps]
def rightUnitor (F : C ⥤ D) :
F ⋙ 𝟭 D ≅ F where
hom := { app := fun X => 𝟙 (F.obj X) }
inv := { app := fun X => 𝟙 (F.obj X) }
/-- The associator for functors, a natural isomorphism `((F ⋙ G) ⋙ H) ≅ (F ⋙ (G ⋙ H))`.
(In fact, `iso.refl _` will work here, but it tends to make Lean slow later,
and it's usually best to insert explicit associators.)
-/
@[simps]
def associator (F : C ⥤ D) (G : D ⥤ E) (H : E ⥤ E') :
(F ⋙ G) ⋙ H ≅ F ⋙ G ⋙ H where
hom := { app := fun _ => 𝟙 _ }
inv := { app := fun _ => 𝟙 _ }
protected theorem assoc (F : C ⥤ D) (G : D ⥤ E) (H : E ⥤ E') : (F ⋙ G) ⋙ H = F ⋙ G ⋙ H :=
rfl
end Functor
variable (C D E) in
/-- The functor `(C ⥤ D ⥤ E) ⥤ D ⥤ C ⥤ E` which flips the variables. -/
@[simps]
def flipFunctor : (C ⥤ D ⥤ E) ⥤ D ⥤ C ⥤ E where
obj F := F.flip
map {F₁ F₂} φ :=
{ app := fun Y =>
{ app := fun X => (φ.app X).app Y } }
namespace Iso
@[reassoc (attr := simp)]
theorem map_hom_inv_id_app {X Y : C} (e : X ≅ Y) (F : C ⥤ D ⥤ E) (Z : D) :
(F.map e.hom).app Z ≫ (F.map e.inv).app Z = 𝟙 _ := by
cat_disch
@[reassoc (attr := simp)]
theorem map_inv_hom_id_app {X Y : C} (e : X ≅ Y) (F : C ⥤ D ⥤ E) (Z : D) :
(F.map e.inv).app Z ≫ (F.map e.hom).app Z = 𝟙 _ := by
cat_disch
end Iso
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Functor/CurryingThree.lean | import Mathlib.CategoryTheory.Functor.Currying
import Mathlib.CategoryTheory.Functor.Trifunctor
import Mathlib.CategoryTheory.Products.Associator
/-!
# Currying of functors in three variables
We study the equivalence of categories
`currying₃ : (C₁ ⥤ C₂ ⥤ C₃ ⥤ E) ≌ C₁ × C₂ × C₃ ⥤ E`.
-/
namespace CategoryTheory
namespace Functor
variable {C₁ C₂ C₁₂ C₃ C₂₃ D₁ D₂ D₃ E : Type*}
[Category C₁] [Category C₂] [Category C₃] [Category C₁₂] [Category C₂₃]
[Category D₁] [Category D₂] [Category D₃] [Category E]
/-- The equivalence of categories `(C₁ ⥤ C₂ ⥤ C₃ ⥤ E) ≌ C₁ × C₂ × C₃ ⥤ E`
given by the curryfication of functors in three variables. -/
def currying₃ : (C₁ ⥤ C₂ ⥤ C₃ ⥤ E) ≌ C₁ × C₂ × C₃ ⥤ E :=
currying.trans (currying.trans (prod.associativity C₁ C₂ C₃).congrLeft)
/-- Uncurrying a functor in three variables. -/
abbrev uncurry₃ : (C₁ ⥤ C₂ ⥤ C₃ ⥤ E) ⥤ C₁ × C₂ × C₃ ⥤ E := currying₃.functor
/-- Currying a functor in three variables. -/
abbrev curry₃ : (C₁ × C₂ × C₃ ⥤ E) ⥤ C₁ ⥤ C₂ ⥤ C₃ ⥤ E := currying₃.inverse
/-- Uncurrying functors in three variables gives a fully faithful functor. -/
def fullyFaithfulUncurry₃ :
(uncurry₃ : (C₁ ⥤ C₂ ⥤ C₃ ⥤ E) ⥤ (C₁ × C₂ × C₃ ⥤ E)).FullyFaithful :=
currying₃.fullyFaithfulFunctor
@[simp]
lemma curry₃_obj_map_app_app (F : C₁ × C₂ × C₃ ⥤ E)
{X₁ Y₁ : C₁} (f : X₁ ⟶ Y₁) (X₂ : C₂) (X₃ : C₃) :
(((curry₃.obj F).map f).app X₂).app X₃ = F.map ⟨f, 𝟙 X₂, 𝟙 X₃⟩ := rfl
@[simp]
lemma curry₃_obj_obj_map_app (F : C₁ × C₂ × C₃ ⥤ E)
(X₁ : C₁) {X₂ Y₂ : C₂} (f : X₂ ⟶ Y₂) (X₃ : C₃) :
(((curry₃.obj F).obj X₁).map f).app X₃ = F.map ⟨𝟙 X₁, f, 𝟙 X₃⟩ := rfl
@[simp]
lemma curry₃_obj_obj_obj_map (F : C₁ × C₂ × C₃ ⥤ E)
(X₁ : C₁) (X₂ : C₂) {X₃ Y₃ : C₃} (f : X₃ ⟶ Y₃) :
(((curry₃.obj F).obj X₁).obj X₂).map f = F.map ⟨𝟙 X₁, 𝟙 X₂, f⟩ := rfl
@[simp]
lemma curry₃_map_app_app_app {F G : C₁ × C₂ × C₃ ⥤ E} (f : F ⟶ G)
(X₁ : C₁) (X₂ : C₂) (X₃ : C₃) :
(((curry₃.map f).app X₁).app X₂).app X₃ = f.app ⟨X₁, X₂, X₃⟩ := rfl
@[simp]
lemma currying₃_unitIso_hom_app_app_app_app (F : C₁ ⥤ C₂ ⥤ C₃ ⥤ E)
(X₁ : C₁) (X₂ : C₂) (X₃ : C₃) :
(((currying₃.unitIso.hom.app F).app X₁).app X₂).app X₃ = 𝟙 _ := by
simp [currying₃, Equivalence.unit]
@[simp]
lemma currying₃_unitIso_inv_app_app_app_app (F : C₁ ⥤ C₂ ⥤ C₃ ⥤ E)
(X₁ : C₁) (X₂ : C₂) (X₃ : C₃) :
(((currying₃.unitIso.inv.app F).app X₁).app X₂).app X₃ = 𝟙 _ := by
simp [currying₃, Equivalence.unitInv]
/-- Given functors `F₁ : C₁ ⥤ D₁`, `F₂ : C₂ ⥤ D₂`, `F₃ : C₃ ⥤ D₃`
and `G : D₁ × D₂ × D₃ ⥤ E`, this is the isomorphism between
`curry₃.obj (F₁.prod (F₂.prod F₃) ⋙ G) : C₁ ⥤ C₂ ⥤ C₃ ⥤ E`
and `F₁ ⋙ curry₃.obj G ⋙ ((whiskeringLeft₂ E).obj F₂).obj F₃`. -/
@[simps!]
def curry₃ObjProdComp (F₁ : C₁ ⥤ D₁) (F₂ : C₂ ⥤ D₂) (F₃ : C₃ ⥤ D₃) (G : D₁ × D₂ × D₃ ⥤ E) :
curry₃.obj (F₁.prod (F₂.prod F₃) ⋙ G) ≅
F₁ ⋙ curry₃.obj G ⋙ ((whiskeringLeft₂ E).obj F₂).obj F₃ :=
NatIso.ofComponents
(fun X₁ ↦ NatIso.ofComponents
(fun X₂ ↦ NatIso.ofComponents (fun X₃ ↦ Iso.refl _)))
/-- `bifunctorComp₁₂` can be described in terms of the curryfication of functors. -/
@[simps!]
def bifunctorComp₁₂Iso (F₁₂ : C₁ ⥤ C₂ ⥤ C₁₂) (G : C₁₂ ⥤ C₃ ⥤ E) :
bifunctorComp₁₂ F₁₂ G ≅ curry.obj (uncurry.obj F₁₂ ⋙ G) :=
NatIso.ofComponents (fun _ => NatIso.ofComponents (fun _ => Iso.refl _))
/-- `bifunctorComp₂₃` can be described in terms of the curryfication of functors. -/
@[simps!]
def bifunctorComp₂₃Iso (F : C₁ ⥤ C₂₃ ⥤ E) (G₂₃ : C₂ ⥤ C₃ ⥤ C₂₃) :
bifunctorComp₂₃ F G₂₃ ≅
curry.obj (curry.obj (prod.associator _ _ _ ⋙
uncurry.obj (uncurry.obj G₂₃ ⋙ F.flip).flip)) :=
NatIso.ofComponents (fun _ ↦ NatIso.ofComponents (fun _ ↦
NatIso.ofComponents (fun _ ↦ Iso.refl _)))
/--
Flip the first and third arguments in a trifunctor.
-/
@[simps!]
def flip₁₃ (F : C₁ ⥤ C₂ ⥤ C₃ ⥤ E) : C₃ ⥤ C₂ ⥤ C₁ ⥤ E where
obj G := {
obj H := {
obj K := ((F.obj K).obj H).obj G
map f := ((F.map f).app _).app _ }
map g := { app X := ((F.obj X).map g).app _ } }
map h := { app X := { app Y := ((F.obj Y).obj X).map h } }
/--
Flip the first and third arguments in a trifunctor, as a functor.
-/
@[simps!]
def flip₁₃Functor : (C₁ ⥤ C₂ ⥤ C₃ ⥤ E) ⥤ (C₃ ⥤ C₂ ⥤ C₁ ⥤ E) where
obj F := F.flip₁₃
map f := {
app X := {
app Y := {
app Z := ((f.app _).app _).app _
naturality _ _ g := by
simp [← NatTrans.comp_app] } } }
/--
Flip the second and third arguments in a trifunctor.
-/
@[simps!]
def flip₂₃ (F : C₁ ⥤ C₂ ⥤ C₃ ⥤ E) : C₁ ⥤ C₃ ⥤ C₂ ⥤ E where
obj G := (F.obj G).flip
map f := (flipFunctor _ _ _).map (F.map f)
/--
Flip the second and third arguments in a trifunctor, as a functor.
-/
@[simps!]
def flip₂₃Functor : (C₁ ⥤ C₂ ⥤ C₃ ⥤ E) ⥤ (C₁ ⥤ C₃ ⥤ C₂ ⥤ E) where
obj F := F.flip₂₃
map f := {
app X := {
app Y := {
app Z := ((f.app _).app _).app _
naturality _ _ g := by
simp [← NatTrans.comp_app] } }
naturality _ _ g := by
ext
simp only [flip₂₃_obj_obj_obj, NatTrans.comp_app, flip₂₃_map_app_app]
simp [← NatTrans.comp_app] }
end Functor
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Functor/Basic.lean | import Mathlib.CategoryTheory.Category.Basic
import Mathlib.Combinatorics.Quiver.Prefunctor
import Mathlib.Tactic.CategoryTheory.CheckCompositions
/-!
# Functors
Defines a functor between categories, extending a `Prefunctor` between quivers.
Introduces, in the `CategoryTheory` scope, notations `C ⥤ D` for the type of all functors
from `C` to `D`, `𝟭` for the identity functor and `⋙` for functor composition.
TODO: Switch to using the `⇒` arrow.
-/
set_option mathlib.tactic.category.grind true
namespace CategoryTheory
-- declare the `v`'s first; see note [category theory universes].
universe v v₁ v₂ v₃ u u₁ u₂ u₃
section
/-- `Functor C D` represents a functor between categories `C` and `D`.
To apply a functor `F` to an object use `F.obj X`, and to a morphism use `F.map f`.
The axiom `map_id` expresses preservation of identities, and
`map_comp` expresses functoriality. -/
@[stacks 001B]
structure Functor (C : Type u₁) [Category.{v₁} C] (D : Type u₂) [Category.{v₂} D] :
Type max v₁ v₂ u₁ u₂ where
/-- The action of a functor on objects. -/
obj : C → D
/-- The action of a functor on morphisms. -/
map : ∀ {X Y : C}, (X ⟶ Y) → ((obj X) ⟶ (obj Y))
/-- A functor preserves identity morphisms. -/
map_id : ∀ X : C, map (𝟙 X) = 𝟙 (obj X) := by cat_disch
/-- A functor preserves composition. -/
map_comp : ∀ {X Y Z : C} (f : X ⟶ Y) (g : Y ⟶ Z), map (f ≫ g) = map f ≫ map g := by cat_disch
end
/-- Notation for a functor between categories. -/
-- A functor is basically a function, so give ⥤ a similar precedence to → (25).
-- For example, `C × D ⥤ E` should parse as `(C × D) ⥤ E` not `C × (D ⥤ E)`.
scoped[CategoryTheory] infixr:26 " ⥤ " => Functor -- type as \func
attribute [simp] Functor.map_id Functor.map_comp
attribute [grind =] Functor.map_id
attribute [grind _=_] Functor.map_comp
-- Note: We manually add this lemma which could be generated by `reassoc`,
-- since we will import this file into `Mathlib/Tactic/Reassoc.lean`.
lemma Functor.map_comp_assoc {C : Type u₁} [Category C] {D : Type u₂} [Category D] (F : C ⥤ D)
{X Y Z : C} (f : X ⟶ Y) (g : Y ⟶ Z) {W : D} (h : F.obj Z ⟶ W) :
(F.map (f ≫ g)) ≫ h = F.map f ≫ F.map g ≫ h := by
grind
namespace Functor
section
variable (C : Type u₁) [Category.{v₁} C]
initialize_simps_projections Functor
-- We don't use `@[simps]` here because we want `C` implicit for the simp lemmas.
/-- `𝟭 C` is the identity functor on a category `C`. -/
protected def id : C ⥤ C where
obj X := X
map f := f
/-- Notation for the identity functor on a category. -/
scoped[CategoryTheory] notation "𝟭" => Functor.id -- Type this as `\sb1`
instance : Inhabited (C ⥤ C) :=
⟨Functor.id C⟩
variable {C}
@[simp, grind =]
theorem id_obj (X : C) : (𝟭 C).obj X = X := rfl
@[simp, grind =]
theorem id_map {X Y : C} (f : X ⟶ Y) : (𝟭 C).map f = f := rfl
end
section
variable {C : Type u₁} [Category.{v₁} C] {D : Type u₂} [Category.{v₂} D]
{E : Type u₃} [Category.{v₃} E]
/-- The prefunctor between the underlying quivers. -/
@[simps]
def toPrefunctor (F : C ⥤ D) : Prefunctor C D := { F with }
theorem congr_map (F : C ⥤ D) {X Y : C} {f g : X ⟶ Y}
(h : f = g) : F.map f = F.map g := by
rw [h]
/-- `F ⋙ G` is the composition of a functor `F` and a functor `G` (`F` first, then `G`).
-/
@[simps (attr := grind =) obj]
def comp (F : C ⥤ D) (G : D ⥤ E) : C ⥤ E where
obj X := G.obj (F.obj X)
map f := G.map (F.map f)
/-- Notation for composition of functors. -/
scoped[CategoryTheory] infixr:80 " ⋙ " => Functor.comp
@[simp, grind =]
theorem comp_map (F : C ⥤ D) (G : D ⥤ E) {X Y : C} (f : X ⟶ Y) :
(F ⋙ G).map f = G.map (F.map f) := rfl
-- These are not simp lemmas because rewriting along equalities between functors
-- is not necessarily a good idea.
-- Natural isomorphisms are also provided in `Whiskering.lean`.
protected theorem comp_id (F : C ⥤ D) : F ⋙ 𝟭 D = F := by cases F; rfl
protected theorem id_comp (F : C ⥤ D) : 𝟭 C ⋙ F = F := by cases F; rfl
@[simp]
theorem map_dite (F : C ⥤ D) {X Y : C} {P : Prop} [Decidable P]
(f : P → (X ⟶ Y)) (g : ¬P → (X ⟶ Y)) :
F.map (if h : P then f h else g h) = if h : P then F.map (f h) else F.map (g h) := by
cat_disch
@[simp]
theorem toPrefunctor_comp (F : C ⥤ D) (G : D ⥤ E) :
F.toPrefunctor.comp G.toPrefunctor = (F ⋙ G).toPrefunctor := rfl
lemma toPrefunctor_injective {F G : C ⥤ D} (h : F.toPrefunctor = G.toPrefunctor) :
F = G := by
obtain ⟨obj, map, _, _⟩ := F
obtain ⟨obj', map', _, _⟩ := G
obtain rfl : obj = obj' := congr_arg Prefunctor.obj h
obtain rfl : @map = @map' := by simpa [Functor.toPrefunctor] using h
rfl
end
end Functor
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Functor/OfSequence.lean | import Mathlib.CategoryTheory.Category.Preorder
import Mathlib.CategoryTheory.EqToHom
/-!
# Functors from the category of the ordered set `ℕ`
In this file, we provide a constructor `Functor.ofSequence`
for functors `ℕ ⥤ C` which takes as an input a sequence
of morphisms `f : X n ⟶ X (n + 1)` for all `n : ℕ`.
We also provide a constructor `NatTrans.ofSequence` for natural
transformations between functors `ℕ ⥤ C` which allows to check
the naturality condition only for morphisms `n ⟶ n + 1`.
The duals of the above for functors `ℕᵒᵖ ⥤ C` are given by `Functor.ofOpSequence` and
`NatTrans.ofOpSequence`.
-/
namespace CategoryTheory
open Category
variable {C : Type*} [Category C]
namespace Functor
variable {X : ℕ → C} (f : ∀ n, X n ⟶ X (n + 1))
namespace OfSequence
lemma congr_f (i j : ℕ) (h : i = j) :
f i = eqToHom (by rw [h]) ≫ f j ≫ eqToHom (by rw [h]) := by
subst h
simp
/-- The morphism `X i ⟶ X j` obtained by composing morphisms of
the form `X n ⟶ X (n + 1)` when `i ≤ j`. -/
def map : ∀ {X : ℕ → C} (_ : ∀ n, X n ⟶ X (n + 1)) (i j : ℕ), i ≤ j → (X i ⟶ X j)
| _, _, 0, 0 => fun _ ↦ 𝟙 _
| _, f, 0, 1 => fun _ ↦ f 0
| _, f, 0, l + 1 => fun _ ↦ f 0 ≫ map (fun n ↦ f (n + 1)) 0 l (by omega)
| _, _, _ + 1, 0 => nofun
| _, f, k + 1, l + 1 => fun _ ↦ map (fun n ↦ f (n + 1)) k l (by omega)
lemma map_id (i : ℕ) : map f i i (by cutsat) = 𝟙 _ := by
revert X f
induction i with
| zero => intros; rfl
| succ _ hi =>
intro X f
apply hi
lemma map_le_succ (i : ℕ) : map f i (i + 1) (by cutsat) = f i := by
revert X f
induction i with
| zero => intros; rfl
| succ _ hi =>
intro X f
apply hi
@[reassoc]
lemma map_comp (i j k : ℕ) (hij : i ≤ j) (hjk : j ≤ k) :
map f i k (hij.trans hjk) = map f i j hij ≫ map f j k hjk := by
induction i generalizing X j k with
| zero =>
induction j generalizing X k with
| zero =>
rw [map_id, id_comp]
| succ j hj =>
obtain (_ | _ | k) := k
· cutsat
· obtain rfl : j = 0 := by cutsat
rw [map_id, comp_id]
· simp only [map, Nat.reduceAdd]
rw [hj (fun n ↦ f (n + 1)) (k + 1) (by cutsat) (by cutsat)]
obtain _ | j := j
all_goals simp [map]
| succ i hi =>
rcases j, k with ⟨(_ | j), (_ | k)⟩
· cutsat
· cutsat
· cutsat
· exact hi _ j k (by cutsat) (by cutsat)
-- `map` has good definitional properties when applied to explicit natural numbers
example : map f 5 5 (by cutsat) = 𝟙 _ := rfl
example : map f 0 3 (by cutsat) = f 0 ≫ f 1 ≫ f 2 := rfl
example : map f 3 7 (by cutsat) = f 3 ≫ f 4 ≫ f 5 ≫ f 6 := rfl
end OfSequence
/-- The functor `ℕ ⥤ C` constructed from a sequence of
morphisms `f : X n ⟶ X (n + 1)` for all `n : ℕ`. -/
@[simps obj]
def ofSequence : ℕ ⥤ C where
obj := X
map {i j} φ := OfSequence.map f i j (leOfHom φ)
map_id i := OfSequence.map_id f i
map_comp {i j k} α β := OfSequence.map_comp f i j k (leOfHom α) (leOfHom β)
@[simp]
lemma ofSequence_map_homOfLE_succ (n : ℕ) :
(ofSequence f).map (homOfLE (Nat.le_add_right n 1)) = f n :=
OfSequence.map_le_succ f n
end Functor
namespace NatTrans
variable {F G : ℕ ⥤ C} (app : ∀ (n : ℕ), F.obj n ⟶ G.obj n)
(naturality : ∀ (n : ℕ), F.map (homOfLE (n.le_add_right 1)) ≫ app (n + 1) =
app n ≫ G.map (homOfLE (n.le_add_right 1)))
/-- Constructor for natural transformations `F ⟶ G` in `ℕ ⥤ C` which takes as inputs
the morphisms `F.obj n ⟶ G.obj n` for all `n : ℕ` and the naturality condition only
for morphisms of the form `n ⟶ n + 1`. -/
@[simps app]
def ofSequence : F ⟶ G where
app := app
naturality := by
intro i j φ
obtain ⟨k, hk⟩ := Nat.exists_eq_add_of_le (leOfHom φ)
obtain rfl := Subsingleton.elim φ (homOfLE (by omega))
revert i j
induction k with
| zero =>
intro i j hk
obtain rfl : j = i := by omega
simp
| succ k hk =>
intro i j hk'
obtain rfl : j = i + k + 1 := by omega
simp only [← homOfLE_comp (show i ≤ i + k by omega) (show i + k ≤ i + k + 1 by omega),
Functor.map_comp, assoc, naturality, reassoc_of% (hk rfl)]
end NatTrans
namespace Functor
variable {X : ℕ → C} (f : ∀ n, X (n + 1) ⟶ X n)
/-- The functor `ℕᵒᵖ ⥤ C` constructed from a sequence of
morphisms `f : X (n + 1) ⟶ X n` for all `n : ℕ`. -/
@[simps! obj]
def ofOpSequence : ℕᵒᵖ ⥤ C := (ofSequence (fun n ↦ (f n).op)).leftOp
-- `ofOpSequence` has good definitional properties when applied to explicit natural numbers
example : (ofOpSequence f).map (homOfLE (show 5 ≤ 5 by cutsat)).op = 𝟙 _ := rfl
example : (ofOpSequence f).map (homOfLE (show 0 ≤ 3 by cutsat)).op = (f 2 ≫ f 1) ≫ f 0 := rfl
example : (ofOpSequence f).map (homOfLE (show 3 ≤ 7 by cutsat)).op =
((f 6 ≫ f 5) ≫ f 4) ≫ f 3 := rfl
@[simp]
lemma ofOpSequence_map_homOfLE_succ (n : ℕ) :
(ofOpSequence f).map (homOfLE (Nat.le_add_right n 1)).op = f n := by
simp [ofOpSequence]
end Functor
namespace NatTrans
variable {F G : ℕᵒᵖ ⥤ C} (app : ∀ (n : ℕ), F.obj ⟨n⟩ ⟶ G.obj ⟨n⟩)
(naturality : ∀ (n : ℕ), F.map (homOfLE (n.le_add_right 1)).op ≫ app n =
app (n + 1) ≫ G.map (homOfLE (n.le_add_right 1)).op)
/-- Constructor for natural transformations `F ⟶ G` in `ℕᵒᵖ ⥤ C` which takes as inputs
the morphisms `F.obj ⟨n⟩ ⟶ G.obj ⟨n⟩` for all `n : ℕ` and the naturality condition only
for morphisms of the form `n ⟶ n + 1`. -/
@[simps!]
def ofOpSequence : F ⟶ G where
app n := app n.unop
naturality _ _ f := by
let φ : G.rightOp ⟶ F.rightOp := ofSequence (fun n ↦ (app n).op)
(fun n ↦ Quiver.Hom.unop_inj (naturality n).symm)
exact Quiver.Hom.op_inj (φ.naturality f.unop).symm
end NatTrans
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Functor/Const.lean | import Mathlib.CategoryTheory.Opposites
/-!
# The constant functor
`const J : C ⥤ (J ⥤ C)` is the functor that sends an object `X : C` to the functor `J ⥤ C` sending
every object in `J` to `X`, and every morphism to `𝟙 X`.
When `J` is nonempty, `const` is faithful.
We have `(const J).obj X ⋙ F ≅ (const J).obj (F.obj X)` for any `F : C ⥤ D`.
-/
-- declare the `v`'s first; see `CategoryTheory.Category` for an explanation
universe v₁ v₂ v₃ u₁ u₂ u₃
open CategoryTheory
namespace CategoryTheory.Functor
variable (J : Type u₁) [Category.{v₁} J]
variable {C : Type u₂} [Category.{v₂} C]
/-- The functor sending `X : C` to the constant functor `J ⥤ C` sending everything to `X`.
-/
@[simps]
def const : C ⥤ J ⥤ C where
obj X :=
{ obj := fun _ => X
map := fun _ => 𝟙 X }
map f := { app := fun _ => f }
namespace const
open Opposite
variable {J}
/-- The constant functor `Jᵒᵖ ⥤ Cᵒᵖ` sending everything to `op X`
is (naturally isomorphic to) the opposite of the constant functor `J ⥤ C` sending everything to `X`.
-/
@[simps]
def opObjOp (X : C) : (const Jᵒᵖ).obj (op X) ≅ ((const J).obj X).op where
hom := { app := fun _ => 𝟙 _ }
inv := { app := fun _ => 𝟙 _ }
/-- The constant functor `Jᵒᵖ ⥤ C` sending everything to `unop X`
is (naturally isomorphic to) the opposite of
the constant functor `J ⥤ Cᵒᵖ` sending everything to `X`.
-/
def opObjUnop (X : Cᵒᵖ) : (const Jᵒᵖ).obj (unop X) ≅ ((const J).obj X).leftOp where
hom := { app := fun _ => 𝟙 _ }
inv := { app := fun _ => 𝟙 _ }
-- Lean needs some help with universes here.
@[simp]
theorem opObjUnop_hom_app (X : Cᵒᵖ) (j : Jᵒᵖ) : (opObjUnop.{v₁, v₂} X).hom.app j = 𝟙 _ :=
rfl
@[simp]
theorem opObjUnop_inv_app (X : Cᵒᵖ) (j : Jᵒᵖ) : (opObjUnop.{v₁, v₂} X).inv.app j = 𝟙 _ :=
rfl
@[simp]
theorem unop_functor_op_obj_map (X : Cᵒᵖ) {j₁ j₂ : J} (f : j₁ ⟶ j₂) :
(unop ((Functor.op (const J)).obj X)).map f = 𝟙 (unop X) :=
rfl
end const
section
variable {D : Type u₃} [Category.{v₃} D]
/-- These are actually equal, of course, but not definitionally equal
(the equality requires F.map (𝟙 _) = 𝟙 _). A natural isomorphism is
more convenient than an equality between functors (compare id_to_iso). -/
@[simps]
def constComp (X : C) (F : C ⥤ D) : (const J).obj X ⋙ F ≅ (const J).obj (F.obj X) where
hom := { app := fun _ => 𝟙 _ }
inv := { app := fun _ => 𝟙 _ }
/-- If `J` is nonempty, then the constant functor over `J` is faithful. -/
instance [Nonempty J] : Faithful (const J : C ⥤ J ⥤ C) where
map_injective e := NatTrans.congr_app e (Classical.arbitrary J)
/-- The canonical isomorphism
`F ⋙ Functor.const J ≅ Functor.const F ⋙ (whiskeringRight J _ _).obj L`. -/
@[simps!]
def compConstIso (F : C ⥤ D) :
F ⋙ Functor.const J ≅ Functor.const J ⋙ (whiskeringRight J C D).obj F :=
NatIso.ofComponents
(fun X => NatIso.ofComponents (fun _ => Iso.refl _) (by simp))
(by cat_disch)
/-- The canonical isomorphism
`const D ⋙ (whiskeringLeft J _ _).obj F ≅ const J` -/
@[simps!]
def constCompWhiskeringLeftIso (F : J ⥤ D) :
const D ⋙ (whiskeringLeft J D C).obj F ≅ const J :=
NatIso.ofComponents fun X => NatIso.ofComponents fun Y => Iso.refl _
end
end CategoryTheory.Functor |
.lake/packages/mathlib/Mathlib/CategoryTheory/Functor/Trifunctor.lean | import Mathlib.CategoryTheory.Functor.Category
/-!
# Trifunctors obtained by composition of bifunctors
Given two bifunctors `F₁₂ : C₁ ⥤ C₂ ⥤ C₁₂` and `G : C₁₂ ⥤ C₃ ⥤ C₄`, we define
the trifunctor `bifunctorComp₁₂ F₁₂ G : C₁ ⥤ C₂ ⥤ C₃ ⥤ C₄` which sends three
objects `X₁ : C₁`, `X₂ : C₂` and `X₃ : C₃` to `G.obj ((F₁₂.obj X₁).obj X₂)).obj X₃`.
Similarly, given two bifunctors `F : C₁ ⥤ C₂₃ ⥤ C₄` and `G₂₃ : C₂ ⥤ C₃ ⥤ C₂₃`, we define
the trifunctor `bifunctorComp₂₃ F G₂₃ : C₁ ⥤ C₂ ⥤ C₃ ⥤ C₄` which sends three
objects `X₁ : C₁`, `X₂ : C₂` and `X₃ : C₃` to `(F.obj X₁).obj ((G₂₃.obj X₂).obj X₃)`.
-/
namespace CategoryTheory
variable {C₁ C₂ C₃ C₄ C₁₂ C₂₃ : Type*} [Category C₁] [Category C₂] [Category C₃]
[Category C₄] [Category C₁₂] [Category C₂₃]
section bifunctorComp₁₂Functor
/-- Auxiliary definition for `bifunctorComp₁₂`. -/
@[simps]
def bifunctorComp₁₂Obj (F₁₂ : C₁ ⥤ C₂ ⥤ C₁₂) (G : C₁₂ ⥤ C₃ ⥤ C₄) (X₁ : C₁) :
C₂ ⥤ C₃ ⥤ C₄ where
obj X₂ :=
{ obj := fun X₃ => (G.obj ((F₁₂.obj X₁).obj X₂)).obj X₃
map := fun {_ _} φ => (G.obj ((F₁₂.obj X₁).obj X₂)).map φ }
map {X₂ Y₂} φ :=
{ app := fun X₃ => (G.map ((F₁₂.obj X₁).map φ)).app X₃ }
/-- Given two bifunctors `F₁₂ : C₁ ⥤ C₂ ⥤ C₁₂` and `G : C₁₂ ⥤ C₃ ⥤ C₄`, this is
the trifunctor `C₁ ⥤ C₂ ⥤ C₃ ⥤ C₄` obtained by composition. -/
@[simps]
def bifunctorComp₁₂ (F₁₂ : C₁ ⥤ C₂ ⥤ C₁₂) (G : C₁₂ ⥤ C₃ ⥤ C₄) :
C₁ ⥤ C₂ ⥤ C₃ ⥤ C₄ where
obj X₁ := bifunctorComp₁₂Obj F₁₂ G X₁
map {X₁ Y₁} φ :=
{ app := fun X₂ =>
{ app := fun X₃ => (G.map ((F₁₂.map φ).app X₂)).app X₃ }
naturality := fun {X₂ Y₂} ψ => by
ext X₃
dsimp
simp only [← NatTrans.comp_app, ← G.map_comp, NatTrans.naturality] }
/-- Auxiliary definition for `bifunctorComp₁₂Functor`. -/
@[simps]
def bifunctorComp₁₂FunctorObj (F₁₂ : C₁ ⥤ C₂ ⥤ C₁₂) :
(C₁₂ ⥤ C₃ ⥤ C₄) ⥤ C₁ ⥤ C₂ ⥤ C₃ ⥤ C₄ where
obj G := bifunctorComp₁₂ F₁₂ G
map {G G'} φ :=
{ app X₁ :=
{ app X₂ :=
{ app X₃ := (φ.app ((F₁₂.obj X₁).obj X₂)).app X₃ }
naturality := fun X₂ Y₂ f ↦ by
ext X₃
dsimp
simp only [← NatTrans.comp_app, NatTrans.naturality] }
naturality X₁ Y₁ f := by
ext X₂ X₃
dsimp
simp only [← NatTrans.comp_app, NatTrans.naturality] }
/-- Auxiliary definition for `bifunctorComp₁₂Functor`. -/
@[simps]
def bifunctorComp₁₂FunctorMap {F₁₂ F₁₂' : C₁ ⥤ C₂ ⥤ C₁₂} (φ : F₁₂ ⟶ F₁₂') :
bifunctorComp₁₂FunctorObj (C₃ := C₃) (C₄ := C₄) F₁₂ ⟶ bifunctorComp₁₂FunctorObj F₁₂' where
app G :=
{ app X₁ :=
{ app X₂ := { app X₃ := (G.map ((φ.app X₁).app X₂)).app X₃ }
naturality := fun X₂ Y₂ f ↦ by
ext X₃
dsimp
simp only [← NatTrans.comp_app, NatTrans.naturality, ← G.map_comp] }
naturality X₁ Y₁ f := by
ext X₂ X₃
dsimp
simp only [← NatTrans.comp_app, NatTrans.naturality, ← G.map_comp] }
naturality G G' f := by
ext X₁ X₂ X₃
dsimp
simp only [← NatTrans.comp_app, NatTrans.naturality]
/-- The functor `(C₁ ⥤ C₂ ⥤ C₁₂) ⥤ (C₁₂ ⥤ C₃ ⥤ C₄) ⥤ C₁ ⥤ C₂ ⥤ C₃ ⥤ C₄` which
sends `F₁₂ : C₁ ⥤ C₂ ⥤ C₁₂` and `G : C₁₂ ⥤ C₃ ⥤ C₄` to the functor
`bifunctorComp₁₂ F₁₂ G : C₁ ⥤ C₂ ⥤ C₃ ⥤ C₄`. -/
@[simps]
def bifunctorComp₁₂Functor : (C₁ ⥤ C₂ ⥤ C₁₂) ⥤ (C₁₂ ⥤ C₃ ⥤ C₄) ⥤ C₁ ⥤ C₂ ⥤ C₃ ⥤ C₄ where
obj := bifunctorComp₁₂FunctorObj
map := bifunctorComp₁₂FunctorMap
end bifunctorComp₁₂Functor
section bifunctorComp₂₃Functor
/-- Auxiliary definition for `bifunctorComp₂₃`. -/
@[simps]
def bifunctorComp₂₃Obj (F : C₁ ⥤ C₂₃ ⥤ C₄) (G₂₃ : C₂ ⥤ C₃ ⥤ C₂₃) (X₁ : C₁) :
C₂ ⥤ C₃ ⥤ C₄ where
obj X₂ :=
{ obj X₃ := (F.obj X₁).obj ((G₂₃.obj X₂).obj X₃)
map φ := (F.obj X₁).map ((G₂₃.obj X₂).map φ) }
map {X₂ Y₂} φ :=
{ app X₃ := (F.obj X₁).map ((G₂₃.map φ).app X₃)
naturality X₃ Y₃ φ := by
dsimp
simp only [← Functor.map_comp, NatTrans.naturality] }
/-- Given two bifunctors `F : C₁ ⥤ C₂₃ ⥤ C₄` and `G₂₃ : C₂ ⥤ C₃ ⥤ C₄`, this is
the trifunctor `C₁ ⥤ C₂ ⥤ C₃ ⥤ C₄` obtained by composition. -/
@[simps]
def bifunctorComp₂₃ (F : C₁ ⥤ C₂₃ ⥤ C₄) (G₂₃ : C₂ ⥤ C₃ ⥤ C₂₃) :
C₁ ⥤ C₂ ⥤ C₃ ⥤ C₄ where
obj X₁ := bifunctorComp₂₃Obj F G₂₃ X₁
map {X₁ Y₁} φ :=
{ app := fun X₂ =>
{ app := fun X₃ => (F.map φ).app ((G₂₃.obj X₂).obj X₃) } }
/-- Auxiliary definition for `bifunctorComp₂₃Functor`. -/
@[simps]
def bifunctorComp₂₃FunctorObj (F : C₁ ⥤ C₂₃ ⥤ C₄) :
(C₂ ⥤ C₃ ⥤ C₂₃) ⥤ C₁ ⥤ C₂ ⥤ C₃ ⥤ C₄ where
obj G₂₃ := bifunctorComp₂₃ F G₂₃
map {G₂₃ G₂₃'} φ :=
{ app X₁ :=
{ app X₂ :=
{ app X₃ := (F.obj X₁).map ((φ.app X₂).app X₃)
naturality X₃ Y₃ f := by
dsimp
simp only [← Functor.map_comp, NatTrans.naturality] }
naturality X₂ Y₂ f := by
ext X₃
dsimp
simp only [← NatTrans.comp_app, ← Functor.map_comp, NatTrans.naturality] } }
/-- Auxiliary definition for `bifunctorComp₂₃Functor`. -/
@[simps]
def bifunctorComp₂₃FunctorMap {F F' : C₁ ⥤ C₂₃ ⥤ C₄} (φ : F ⟶ F') :
bifunctorComp₂₃FunctorObj F (C₂ := C₂) (C₃ := C₃) ⟶ bifunctorComp₂₃FunctorObj F' where
app G₂₃ :=
{ app X₁ := { app X₂ := { app X₃ := (φ.app X₁).app ((G₂₃.obj X₂).obj X₃) } }
naturality X₁ Y₁ f := by
ext X₂ X₃
dsimp
simp only [← NatTrans.comp_app, NatTrans.naturality] }
/-- The functor `(C₁ ⥤ C₂₃ ⥤ C₄) ⥤ (C₂ ⥤ C₃ ⥤ C₂₃) ⥤ C₁ ⥤ C₂ ⥤ C₃ ⥤ C₄` which
sends `F : C₁ ⥤ C₂₃ ⥤ C₄` and `G₂₃ : C₂ ⥤ C₃ ⥤ C₂₃` to the
functor `bifunctorComp₂₃ F G₂₃ : C₁ ⥤ C₂ ⥤ C₃ ⥤ C₄`. -/
@[simps]
def bifunctorComp₂₃Functor :
(C₁ ⥤ C₂₃ ⥤ C₄) ⥤ (C₂ ⥤ C₃ ⥤ C₂₃) ⥤ C₁ ⥤ C₂ ⥤ C₃ ⥤ C₄ where
obj := bifunctorComp₂₃FunctorObj
map := bifunctorComp₂₃FunctorMap
end bifunctorComp₂₃Functor
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Functor/Functorial.lean | import Mathlib.CategoryTheory.Functor.Basic
/-!
# Unbundled functors, as a typeclass decorating the object-level function.
-/
namespace CategoryTheory
-- declare the `v`'s first; see `CategoryTheory.Category` for an explanation
universe v v₁ v₂ v₃ u u₁ u₂ u₃
variable {C : Type u₁} [Category.{v₁} C] {D : Type u₂} [Category.{v₂} D]
-- Perhaps in the future we could redefine `Functor` in terms of this, but that isn't the
-- immediate plan.
/-- An unbundled functor. -/
class Functorial (F : C → D) : Type max v₁ v₂ u₁ u₂ where
/-- If `F : C → D` (just a function) has `[Functorial F]`,
we can write `map F f : F X ⟶ F Y` for the action of `F` on a morphism `f : X ⟶ Y`. -/
map (F) : ∀ {X Y : C}, (X ⟶ Y) → (F X ⟶ F Y)
/-- A functorial map preserves identities. -/
map_id : ∀ {X : C}, map (𝟙 X) = 𝟙 (F X) := by cat_disch
/-- A functorial map preserves composition of morphisms. -/
map_comp : ∀ {X Y Z : C} {f : X ⟶ Y} {g : Y ⟶ Z}, map (f ≫ g) = map f ≫ map g := by
cat_disch
attribute [simp, grind =] Functorial.map_id Functorial.map_comp
export Functorial (map)
namespace Functor
/-- Bundle a functorial function as a functor.
-/
def of (F : C → D) [I : Functorial.{v₁, v₂} F] : C ⥤ D :=
{ I with obj := F
map := Functorial.map F }
end Functor
instance (F : C ⥤ D) : Functorial.{v₁, v₂} F.obj :=
{ F with map := F.map }
@[simp, grind =]
theorem map_functorial_obj (F : C ⥤ D) {X Y : C} (f : X ⟶ Y) : map F.obj f = F.map f :=
rfl
instance functorial_id : Functorial.{v₁, v₁} (id : C → C) where map f := f
section
variable {E : Type u₃} [Category.{v₃} E]
-- This is no longer viable as an instance in Lean 3.7,
-- #lint reports an instance loop
-- Will this be a problem?
/-- `G ∘ F` is a functorial if both `F` and `G` are.
-/
def functorial_comp (F : C → D) [Functorial.{v₁, v₂} F] (G : D → E) [Functorial.{v₂, v₃} G] :
Functorial.{v₁, v₃} (G ∘ F) :=
{ Functor.of F ⋙ Functor.of G with map := fun f => map G (map F f) }
end
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Functor/FullyFaithful.lean | import Mathlib.CategoryTheory.NatIso
import Mathlib.Logic.Equiv.Defs
/-!
# Full and faithful functors
We define typeclasses `Full` and `Faithful`, decorating functors. These typeclasses
carry no data. However, we also introduce a structure `Functor.FullyFaithful` which
contains the data of the inverse map `(F.obj X ⟶ F.obj Y) ⟶ (X ⟶ Y)` of the
map induced on morphisms by a functor `F`.
## Main definitions and results
* Use `F.map_injective` to retrieve the fact that `F.map` is injective when `[Faithful F]`.
* Similarly, `F.map_surjective` states that `F.map` is surjective when `[Full F]`.
* Use `F.preimage` to obtain preimages of morphisms when `[Full F]`.
* We prove some basic "cancellation" lemmas for full and/or faithful functors, as well as a
construction for "dividing" a functor by a faithful functor, see `Faithful.div`.
See `CategoryTheory.Equivalence.of_fullyFaithful_ess_surj` for the fact that a functor is an
equivalence if and only if it is fully faithful and essentially surjective.
-/
-- declare the `v`'s first; see `CategoryTheory.Category` for an explanation
universe v₁ v₂ v₃ u₁ u₂ u₃
namespace CategoryTheory
variable {C : Type u₁} [Category.{v₁} C] {D : Type u₂} [Category.{v₂} D] {E : Type*} [Category E]
namespace Functor
/-- A functor `F : C ⥤ D` is full if for each `X Y : C`, `F.map` is surjective. -/
@[stacks 001C]
class Full (F : C ⥤ D) : Prop where
map_surjective {X Y : C} : Function.Surjective (F.map (X := X) (Y := Y))
/-- A functor `F : C ⥤ D` is faithful if for each `X Y : C`, `F.map` is injective. -/
@[stacks 001C]
class Faithful (F : C ⥤ D) : Prop where
/-- `F.map` is injective for each `X Y : C`. -/
map_injective : ∀ {X Y : C}, Function.Injective (F.map : (X ⟶ Y) → (F.obj X ⟶ F.obj Y)) := by
cat_disch
variable {X Y : C}
@[grind inj]
theorem map_injective (F : C ⥤ D) [Faithful F] :
Function.Injective <| (F.map : (X ⟶ Y) → (F.obj X ⟶ F.obj Y)) :=
Faithful.map_injective
lemma map_injective_iff (F : C ⥤ D) [Faithful F] {X Y : C} (f g : X ⟶ Y) :
F.map f = F.map g ↔ f = g :=
⟨fun h => F.map_injective h, fun h => by rw [h]⟩
theorem mapIso_injective (F : C ⥤ D) [Faithful F] :
Function.Injective <| (F.mapIso : (X ≅ Y) → (F.obj X ≅ F.obj Y)) := fun _ _ h =>
Iso.ext (map_injective F (congr_arg Iso.hom h :))
theorem map_surjective (F : C ⥤ D) [Full F] :
Function.Surjective (F.map : (X ⟶ Y) → (F.obj X ⟶ F.obj Y)) :=
Full.map_surjective
/-- The choice of a preimage of a morphism under a full functor. -/
noncomputable def preimage (F : C ⥤ D) [Full F] (f : F.obj X ⟶ F.obj Y) : X ⟶ Y :=
(F.map_surjective f).choose
@[simp]
theorem map_preimage (F : C ⥤ D) [Full F] {X Y : C} (f : F.obj X ⟶ F.obj Y) :
F.map (preimage F f) = f :=
(F.map_surjective f).choose_spec
variable {F : C ⥤ D} {X Y Z : C}
section
variable [Full F] [F.Faithful]
@[simp]
theorem preimage_id : F.preimage (𝟙 (F.obj X)) = 𝟙 X :=
F.map_injective (by simp)
@[simp]
theorem preimage_comp (f : F.obj X ⟶ F.obj Y) (g : F.obj Y ⟶ F.obj Z) :
F.preimage (f ≫ g) = F.preimage f ≫ F.preimage g :=
F.map_injective (by simp)
@[simp]
theorem preimage_map (f : X ⟶ Y) : F.preimage (F.map f) = f :=
F.map_injective (by simp)
variable (F)
/-- If `F : C ⥤ D` is fully faithful, every isomorphism `F.obj X ≅ F.obj Y` has a preimage. -/
@[simps]
noncomputable def preimageIso (f : F.obj X ≅ F.obj Y) :
X ≅ Y where
hom := F.preimage f.hom
inv := F.preimage f.inv
hom_inv_id := F.map_injective (by simp)
inv_hom_id := F.map_injective (by simp)
@[simp]
theorem preimageIso_mapIso (f : X ≅ Y) : F.preimageIso (F.mapIso f) = f := by
ext
simp
end
variable (F) in
/-- Structure containing the data of inverse map `(F.obj X ⟶ F.obj Y) ⟶ (X ⟶ Y)` of `F.map`
in order to express that `F` is a fully faithful functor. -/
structure FullyFaithful where
/-- The inverse map `(F.obj X ⟶ F.obj Y) ⟶ (X ⟶ Y)` of `F.map`. -/
preimage {X Y : C} (f : F.obj X ⟶ F.obj Y) : X ⟶ Y
map_preimage {X Y : C} (f : F.obj X ⟶ F.obj Y) : F.map (preimage f) = f := by cat_disch
preimage_map {X Y : C} (f : X ⟶ Y) : preimage (F.map f) = f := by cat_disch
namespace FullyFaithful
attribute [simp] map_preimage preimage_map
variable (F) in
/-- A `FullyFaithful` structure can be obtained from the assumption the `F` is both
full and faithful. -/
noncomputable def ofFullyFaithful [F.Full] [F.Faithful] :
F.FullyFaithful where
preimage := F.preimage
variable (C) in
/-- The identity functor is fully faithful. -/
@[simps]
def id : (𝟭 C).FullyFaithful where
preimage f := f
section
variable (hF : F.FullyFaithful)
include hF
/-- The equivalence `(X ⟶ Y) ≃ (F.obj X ⟶ F.obj Y)` given by `h : F.FullyFaithful`. -/
@[simps]
def homEquiv {X Y : C} : (X ⟶ Y) ≃ (F.obj X ⟶ F.obj Y) where
toFun := F.map
invFun := hF.preimage
left_inv _ := by simp
right_inv _ := by simp
lemma map_injective {X Y : C} {f g : X ⟶ Y} (h : F.map f = F.map g) : f = g :=
hF.homEquiv.injective h
lemma map_surjective {X Y : C} :
Function.Surjective (F.map : (X ⟶ Y) → (F.obj X ⟶ F.obj Y)) :=
hF.homEquiv.surjective
lemma map_bijective (X Y : C) :
Function.Bijective (F.map : (X ⟶ Y) → (F.obj X ⟶ F.obj Y)) :=
hF.homEquiv.bijective
@[simp]
lemma preimage_id {X : C} :
hF.preimage (𝟙 (F.obj X)) = 𝟙 X :=
hF.map_injective (by simp)
@[simp, reassoc]
lemma preimage_comp {X Y Z : C} (f : F.obj X ⟶ F.obj Y) (g : F.obj Y ⟶ F.obj Z) :
hF.preimage (f ≫ g) = hF.preimage f ≫ hF.preimage g :=
hF.map_injective (by simp)
lemma full : F.Full where
map_surjective := hF.map_surjective
lemma faithful : F.Faithful where
map_injective := hF.map_injective
instance : Subsingleton F.FullyFaithful where
allEq h₁ h₂ := by
have := h₁.faithful
cases h₁ with | mk f₁ hf₁ _ => cases h₂ with | mk f₂ hf₂ _ =>
simp only [Functor.FullyFaithful.mk.injEq]
ext
apply F.map_injective
rw [hf₁, hf₂]
/-- The unique isomorphism `X ≅ Y` which induces an isomorphism `F.obj X ≅ F.obj Y`
when `hF : F.FullyFaithful`. -/
@[simps]
def preimageIso {X Y : C} (e : F.obj X ≅ F.obj Y) : X ≅ Y where
hom := hF.preimage e.hom
inv := hF.preimage e.inv
hom_inv_id := hF.map_injective (by simp)
inv_hom_id := hF.map_injective (by simp)
lemma isIso_of_isIso_map {X Y : C} (f : X ⟶ Y) [IsIso (F.map f)] :
IsIso f := by
simpa using (hF.preimageIso (asIso (F.map f))).isIso_hom
/-- The equivalence `(X ≅ Y) ≃ (F.obj X ≅ F.obj Y)` given by `h : F.FullyFaithful`. -/
@[simps]
def isoEquiv {X Y : C} : (X ≅ Y) ≃ (F.obj X ≅ F.obj Y) where
toFun := F.mapIso
invFun := hF.preimageIso
left_inv := by cat_disch
right_inv := by cat_disch
/-- Fully faithful functors are stable by composition. -/
@[simps]
def comp {G : D ⥤ E} (hG : G.FullyFaithful) : (F ⋙ G).FullyFaithful where
preimage f := hF.preimage (hG.preimage f)
end
/-- If `F ⋙ G` is fully faithful and `G` is faithful, then `F` is fully faithful. -/
def ofCompFaithful {G : D ⥤ E} [G.Faithful] (hFG : (F ⋙ G).FullyFaithful) :
F.FullyFaithful where
preimage f := hFG.preimage (G.map f)
map_preimage f := G.map_injective (hFG.map_preimage (G.map f))
preimage_map f := hFG.preimage_map f
end FullyFaithful
end Functor
section
variable (F : C ⥤ D) [F.Full] [F.Faithful] {X Y : C}
/-- If the image of a morphism under a fully faithful functor in an isomorphism,
then the original morphisms is also an isomorphism.
-/
theorem isIso_of_fully_faithful (f : X ⟶ Y) [IsIso (F.map f)] : IsIso f :=
⟨⟨F.preimage (inv (F.map f)), ⟨F.map_injective (by simp), F.map_injective (by simp)⟩⟩⟩
end
end CategoryTheory
namespace CategoryTheory
namespace Functor
variable {C : Type u₁} [Category.{v₁} C]
instance Full.id : Full (𝟭 C) where map_surjective := Function.surjective_id
instance Faithful.id : Functor.Faithful (𝟭 C) := { }
variable {D : Type u₂} [Category.{v₂} D] {E : Type u₃} [Category.{v₃} E]
variable (F F' : C ⥤ D) (G : D ⥤ E)
instance Faithful.comp [F.Faithful] [G.Faithful] : (F ⋙ G).Faithful where
map_injective p := F.map_injective (G.map_injective p)
theorem Faithful.of_comp [(F ⋙ G).Faithful] : F.Faithful :=
-- Porting note: (F ⋙ G).map_injective.of_comp has the incorrect type
{ map_injective := fun {_ _} => Function.Injective.of_comp (F ⋙ G).map_injective }
instance (priority := 100) [Quiver.IsThin C] : F.Faithful where
section
variable {F F'}
/-- If `F` is full, and naturally isomorphic to some `F'`, then `F'` is also full. -/
lemma Full.of_iso [Full F] (α : F ≅ F') : Full F' where
map_surjective {X Y} f :=
⟨F.preimage ((α.app X).hom ≫ f ≫ (α.app Y).inv), by simp [← NatIso.naturality_1 α]⟩
theorem Faithful.of_iso [F.Faithful] (α : F ≅ F') : F'.Faithful :=
{ map_injective := fun h =>
F.map_injective (by rw [← NatIso.naturality_1 α.symm, h, NatIso.naturality_1 α.symm]) }
end
variable {F G}
theorem Faithful.of_comp_iso {H : C ⥤ E} [H.Faithful] (h : F ⋙ G ≅ H) : F.Faithful :=
@Faithful.of_comp _ _ _ _ _ _ F G (Faithful.of_iso h.symm)
alias _root_.CategoryTheory.Iso.faithful_of_comp := Faithful.of_comp_iso
-- We could prove this from `Faithful.of_comp_iso` using `eq_to_iso`,
-- but that would introduce a cyclic import.
theorem Faithful.of_comp_eq {H : C ⥤ E} [ℋ : H.Faithful] (h : F ⋙ G = H) : F.Faithful :=
@Faithful.of_comp _ _ _ _ _ _ F G (h.symm ▸ ℋ)
alias _root_.Eq.faithful_of_comp := Faithful.of_comp_eq
variable (F G)
/-- “Divide” a functor by a faithful functor. -/
protected def Faithful.div (F : C ⥤ E) (G : D ⥤ E) [G.Faithful] (obj : C → D)
(h_obj : ∀ X, G.obj (obj X) = F.obj X) (map : ∀ {X Y}, (X ⟶ Y) → (obj X ⟶ obj Y))
(h_map : ∀ {X Y} {f : X ⟶ Y}, G.map (map f) ≍ F.map f) : C ⥤ D :=
{ obj, map := @map,
map_id := by
intro X
apply G.map_injective
grind
map_comp := by grind }
-- This follows immediately from `Functor.hext` (`Functor.hext h_obj @h_map`),
-- but importing `CategoryTheory.EqToHom` causes an import loop:
-- CategoryTheory.EqToHom → CategoryTheory.Opposites →
-- CategoryTheory.Equivalence → CategoryTheory.FullyFaithful
theorem Faithful.div_comp (F : C ⥤ E) [F.Faithful] (G : D ⥤ E) [G.Faithful] (obj : C → D)
(h_obj : ∀ X, G.obj (obj X) = F.obj X) (map : ∀ {X Y}, (X ⟶ Y) → (obj X ⟶ obj Y))
(h_map : ∀ {X Y} {f : X ⟶ Y}, G.map (map f) ≍ F.map f) :
Faithful.div F G obj @h_obj @map @h_map ⋙ G = F := by
obtain ⟨F_obj, _, _, _⟩ := F; obtain ⟨G_obj, _, _, _⟩ := G
unfold Faithful.div Functor.comp
have : F_obj = G_obj ∘ obj := (funext h_obj).symm
subst this
congr
simp only [Function.comp_apply, heq_eq_eq] at h_map
ext
exact h_map
theorem Faithful.div_faithful (F : C ⥤ E) [F.Faithful] (G : D ⥤ E) [G.Faithful] (obj : C → D)
(h_obj : ∀ X, G.obj (obj X) = F.obj X) (map : ∀ {X Y}, (X ⟶ Y) → (obj X ⟶ obj Y))
(h_map : ∀ {X Y} {f : X ⟶ Y}, G.map (map f) ≍ F.map f) :
Functor.Faithful (Faithful.div F G obj @h_obj @map @h_map) :=
(Faithful.div_comp F G _ h_obj _ @h_map).faithful_of_comp
instance Full.comp [Full F] [Full G] : Full (F ⋙ G) where
map_surjective f := ⟨F.preimage (G.preimage f), by simp⟩
/-- If `F ⋙ G` is full and `G` is faithful, then `F` is full. -/
lemma Full.of_comp_faithful [Full <| F ⋙ G] [G.Faithful] : Full F where
map_surjective f := ⟨(F ⋙ G).preimage (G.map f), G.map_injective ((F ⋙ G).map_preimage _)⟩
/-- If `F ⋙ G` is full and `G` is faithful, then `F` is full. -/
lemma Full.of_comp_faithful_iso {F : C ⥤ D} {G : D ⥤ E} {H : C ⥤ E} [Full H] [G.Faithful]
(h : F ⋙ G ≅ H) : Full F := by
have := Full.of_iso h.symm
exact Full.of_comp_faithful F G
/-- Given a natural isomorphism between `F ⋙ H` and `G ⋙ H` for a fully faithful functor `H`, we
can 'cancel' it to give a natural iso between `F` and `G`.
-/
noncomputable def fullyFaithfulCancelRight {F G : C ⥤ D} (H : D ⥤ E) [Full H] [H.Faithful]
(comp_iso : F ⋙ H ≅ G ⋙ H) : F ≅ G :=
NatIso.ofComponents (fun X => H.preimageIso (comp_iso.app X)) fun f =>
H.map_injective (by simpa using comp_iso.hom.naturality f)
@[simp]
theorem fullyFaithfulCancelRight_hom_app {F G : C ⥤ D} {H : D ⥤ E} [Full H] [H.Faithful]
(comp_iso : F ⋙ H ≅ G ⋙ H) (X : C) :
(fullyFaithfulCancelRight H comp_iso).hom.app X = H.preimage (comp_iso.hom.app X) :=
rfl
@[simp]
theorem fullyFaithfulCancelRight_inv_app {F G : C ⥤ D} {H : D ⥤ E} [Full H] [H.Faithful]
(comp_iso : F ⋙ H ≅ G ⋙ H) (X : C) :
(fullyFaithfulCancelRight H comp_iso).inv.app X = H.preimage (comp_iso.inv.app X) :=
rfl
end Functor
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Functor/TwoSquare.lean | import Mathlib.CategoryTheory.Whiskering
import Mathlib.CategoryTheory.Opposites
import Mathlib.Tactic.CategoryTheory.Slice
/-!
# 2-squares of functors
Given four functors `T`, `L`, `R` and `B`, a 2-square `TwoSquare T L R B` consists of
a natural transformation `w : T ⋙ R ⟶ L ⋙ B`:
```
T
C₁ ⥤ C₂
L | | R
v v
C₃ ⥤ C₄
B
```
We define operations to paste such squares horizontally and vertically and prove the interchange
law of those two operations.
## TODO
Generalize all of this to double categories.
-/
universe v₁ v₂ v₃ v₄ v₅ v₆ v₇ v₈ v₉ u₁ u₂ u₃ u₄ u₅ u₆ u₇ u₈ u₉
namespace CategoryTheory
open Category Functor
variable {C₁ : Type u₁} {C₂ : Type u₂} {C₃ : Type u₃} {C₄ : Type u₄}
[Category.{v₁} C₁] [Category.{v₂} C₂] [Category.{v₃} C₃] [Category.{v₄} C₄]
(T : C₁ ⥤ C₂) (L : C₁ ⥤ C₃) (R : C₂ ⥤ C₄) (B : C₃ ⥤ C₄)
/-- A `2`-square consists of a natural transformation `T ⋙ R ⟶ L ⋙ B`
involving fours functors `T`, `L`, `R`, `B` that are on the
top/left/right/bottom sides of a square of categories. -/
def TwoSquare := T ⋙ R ⟶ L ⋙ B
namespace TwoSquare
/-- Constructor for `TwoSquare`. -/
abbrev mk (α : T ⋙ R ⟶ L ⋙ B) : TwoSquare T L R B := α
variable {T} {L} {R} {B} in
/-- The natural transformation associated to a 2-square. -/
abbrev natTrans (w : TwoSquare T L R B) : T ⋙ R ⟶ L ⋙ B := w
/-- The type of 2-squares on functors `T`, `L`, `R`, and `B` is trivially equivalent to
the type of natural transformations `T ⋙ R ⟶ L ⋙ B`. -/
@[simps]
def equivNatTrans : TwoSquare T L R B ≃ (T ⋙ R ⟶ L ⋙ B) where
toFun := natTrans
invFun := mk T L R B
variable {T L R B}
/-- The opposite of a `2`-square. -/
def op (α : TwoSquare T L R B) : TwoSquare L.op T.op B.op R.op := NatTrans.op α
@[simp]
lemma natTrans_op (α : TwoSquare T L R B) :
α.op.natTrans = NatTrans.op α.natTrans := rfl
@[ext]
lemma ext (w w' : TwoSquare T L R B) (h : ∀ (X : C₁), w.natTrans.app X = w'.natTrans.app X) :
w = w' :=
NatTrans.ext (funext h)
/-- The horizontal identity 2-square. -/
@[simps!]
def hId (L : C₁ ⥤ C₃) : TwoSquare (𝟭 _) L L (𝟭 _) :=
𝟙 _
/-- Notation for the horizontal identity 2-square. -/
scoped notation "𝟙ₕ" => hId -- type as \b1\_h
/-- The vertical identity 2-square. -/
@[simps!]
def vId (T : C₁ ⥤ C₂) : TwoSquare T (𝟭 _) (𝟭 _) T :=
𝟙 _
/-- Notation for the vertical identity 2-square. -/
scoped notation "𝟙ᵥ" => vId -- type as \b1\_v
/-- Whiskering a 2-square with a natural transformation at the top. -/
@[simps!]
protected def whiskerTop {T' : C₁ ⥤ C₂} (w : TwoSquare T' L R B) (α : T ⟶ T') : TwoSquare T L R B :=
.mk _ _ _ _ <| whiskerRight α R ≫ w.natTrans
/-- Whiskering a 2-square with a natural transformation at the left side. -/
@[simps!]
protected def whiskerLeft {L' : C₁ ⥤ C₃} (w : TwoSquare T L R B) (α : L ⟶ L') :
TwoSquare T L' R B :=
.mk _ _ _ _ <| w.natTrans ≫ whiskerRight α B
/-- Whiskering a 2-square with a natural transformation at the right side. -/
@[simps!]
protected def whiskerRight {R' : C₂ ⥤ C₄} (w : TwoSquare T L R' B) (α : R ⟶ R') :
TwoSquare T L R B :=
.mk _ _ _ _ <| whiskerLeft T α ≫ w.natTrans
/-- Whiskering a 2-square with a natural transformation at the bottom. -/
@[simps!]
protected def whiskerBottom {B' : C₃ ⥤ C₄} (w : TwoSquare T L R B) (α : B ⟶ B') :
TwoSquare T L R B' :=
.mk _ _ _ _ <| w.natTrans ≫ whiskerLeft L α
variable {C₅ : Type u₅} {C₆ : Type u₆} {C₇ : Type u₇} {C₈ : Type u₈}
[Category.{v₅} C₅] [Category.{v₆} C₆] [Category.{v₇} C₇] [Category.{v₈} C₈]
{T' : C₂ ⥤ C₅} {R' : C₅ ⥤ C₆} {B' : C₄ ⥤ C₆} {L' : C₃ ⥤ C₇} {R'' : C₄ ⥤ C₈} {B'' : C₇ ⥤ C₈}
/-- The horizontal composition of 2-squares. -/
@[simps!]
def hComp (w : TwoSquare T L R B) (w' : TwoSquare T' R R' B') :
TwoSquare (T ⋙ T') L R' (B ⋙ B') :=
.mk _ _ _ _ <| (associator _ _ _).hom ≫ (whiskerLeft T w'.natTrans) ≫
(associator _ _ _).inv ≫ (whiskerRight w.natTrans B') ≫ (associator _ _ _).hom
/-- Notation for the horizontal composition of 2-squares. -/
scoped infixr:80 " ≫ₕ " => hComp -- type as \gg\_h
/-- The vertical composition of 2-squares. -/
@[simps!]
def vComp (w : TwoSquare T L R B) (w' : TwoSquare B L' R'' B'') :
TwoSquare T (L ⋙ L') (R ⋙ R'') B'' :=
.mk _ _ _ _ <| (associator _ _ _).inv ≫ whiskerRight w.natTrans R'' ≫
(associator _ _ _).hom ≫ whiskerLeft L w'.natTrans ≫ (associator _ _ _).inv
/-- Notation for the vertical composition of 2-squares. -/
scoped infixr:80 " ≫ᵥ " => vComp -- type as \gg\_v
section Interchange
variable {C₉ : Type u₉} [Category.{v₉} C₉] {R₃ : C₆ ⥤ C₉} {B₃ : C₈ ⥤ C₉}
/-- When composing 2-squares which form a diagram of grid, composing horizontally first yields the
same result as composing vertically first. -/
lemma hCompVCompHComp (w₁ : TwoSquare T L R B) (w₂ : TwoSquare T' R R' B')
(w₃ : TwoSquare B L' R'' B'') (w₄ : TwoSquare B' R'' R₃ B₃) :
(w₁ ≫ₕ w₂) ≫ᵥ (w₃ ≫ₕ w₄) = (w₁ ≫ᵥ w₃) ≫ₕ (w₂ ≫ᵥ w₄) := by
unfold hComp vComp whiskerLeft whiskerRight
ext c
simp only [comp_obj, NatTrans.comp_app, associator_hom_app, associator_inv_app, comp_id, id_comp,
map_comp, assoc]
slice_rhs 2 3 =>
rw [← Functor.comp_map _ B₃, ← w₄.naturality]
simp
end Interchange
end TwoSquare
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Functor/Currying.lean | import Mathlib.CategoryTheory.EqToHom
import Mathlib.CategoryTheory.Products.Basic
/-!
# Curry and uncurry, as functors.
We define `curry : ((C × D) ⥤ E) ⥤ (C ⥤ (D ⥤ E))` and `uncurry : (C ⥤ (D ⥤ E)) ⥤ ((C × D) ⥤ E)`,
and verify that they provide an equivalence of categories
`currying : (C ⥤ (D ⥤ E)) ≌ ((C × D) ⥤ E)`.
This is used in `CategoryTheory.Category.Cat.CartesianClosed` to equip the category of small
categories `Cat.{u, u}` with a Cartesian closed structure.
-/
namespace CategoryTheory
namespace Functor
universe v₁ v₂ v₃ v₄ v₅ u₁ u₂ u₃ u₄ u₅
variable {B : Type u₁} [Category.{v₁} B] {C : Type u₂} [Category.{v₂} C] {D : Type u₃}
[Category.{v₃} D] {E : Type u₄} [Category.{v₄} E] {H : Type u₅} [Category.{v₅} H]
/-- The uncurrying functor, taking a functor `C ⥤ (D ⥤ E)` and producing a functor `(C × D) ⥤ E`.
-/
@[simps]
def uncurry : (C ⥤ D ⥤ E) ⥤ C × D ⥤ E where
obj F :=
{ obj := fun X => (F.obj X.1).obj X.2
map := fun {X} {Y} f => (F.map f.1).app X.2 ≫ (F.obj Y.1).map f.2
map_comp := fun f g => by
simp only [prod_comp_fst, prod_comp_snd, Functor.map_comp, NatTrans.comp_app,
Category.assoc]
slice_lhs 2 3 => rw [← NatTrans.naturality]
rw [Category.assoc] }
map T :=
{ app := fun X => (T.app X.1).app X.2
naturality := fun X Y f => by
simp only [Category.assoc]
slice_lhs 2 3 => rw [NatTrans.naturality]
slice_lhs 1 2 => rw [← NatTrans.comp_app, NatTrans.naturality, NatTrans.comp_app]
rw [Category.assoc] }
/-- The object level part of the currying functor. (See `curry` for the functorial version.)
-/
def curryObj (F : C × D ⥤ E) : C ⥤ D ⥤ E where
obj X :=
{ obj := fun Y => F.obj (X, Y)
map := fun g => F.map (𝟙 X, g)
map_id := fun Y => by simp only; rw [← prod_id]; exact F.map_id ⟨X,Y⟩
map_comp := fun f g => by simp [← F.map_comp]}
map f :=
{ app := fun Y => F.map (f, 𝟙 Y)
naturality := fun {Y} {Y'} g => by simp [← F.map_comp] }
map_id := fun X => by ext Y; exact F.map_id _
map_comp := fun f g => by ext Y; simp [← F.map_comp]
/-- The currying functor, taking a functor `(C × D) ⥤ E` and producing a functor `C ⥤ (D ⥤ E)`.
-/
@[simps! obj_obj_obj obj_obj_map obj_map_app map_app_app]
def curry : (C × D ⥤ E) ⥤ C ⥤ D ⥤ E where
obj F := curryObj F
map T :=
{ app := fun X =>
{ app := fun Y => T.app (X, Y)
naturality := fun Y Y' g => by
dsimp [curryObj]
rw [NatTrans.naturality] }
naturality := fun X X' f => by
ext; dsimp [curryObj]
rw [NatTrans.naturality] }
-- create projection simp lemmas even though this isn't a `{ .. }`.
/-- The equivalence of functor categories given by currying/uncurrying.
-/
@[simps!]
def currying : C ⥤ D ⥤ E ≌ C × D ⥤ E where
functor := uncurry
inverse := curry
unitIso := NatIso.ofComponents (fun _ ↦ NatIso.ofComponents
(fun _ ↦ NatIso.ofComponents (fun _ ↦ Iso.refl _)))
counitIso := NatIso.ofComponents
(fun F ↦ NatIso.ofComponents (fun _ ↦ Iso.refl _) (by
rintro ⟨X₁, X₂⟩ ⟨Y₁, Y₂⟩ ⟨f₁, f₂⟩
dsimp at f₁ f₂ ⊢
simp only [← F.map_comp, prod_comp, Category.comp_id, Category.id_comp]))
/-- The equivalence of functor categories given by flipping. -/
@[simps!]
def flipping : C ⥤ D ⥤ E ≌ D ⥤ C ⥤ E where
functor := flipFunctor _ _ _
inverse := flipFunctor _ _ _
unitIso := NatIso.ofComponents (fun _ ↦ NatIso.ofComponents
(fun _ ↦ NatIso.ofComponents (fun _ ↦ Iso.refl _)))
counitIso := NatIso.ofComponents (fun _ ↦ NatIso.ofComponents
(fun _ ↦ NatIso.ofComponents (fun _ ↦ Iso.refl _)))
/-- The functor `uncurry : (C ⥤ D ⥤ E) ⥤ C × D ⥤ E` is fully faithful. -/
def fullyFaithfulUncurry : (uncurry : (C ⥤ D ⥤ E) ⥤ C × D ⥤ E).FullyFaithful :=
currying.fullyFaithfulFunctor
instance : (uncurry : (C ⥤ D ⥤ E) ⥤ C × D ⥤ E).Full :=
fullyFaithfulUncurry.full
instance : (uncurry : (C ⥤ D ⥤ E) ⥤ C × D ⥤ E).Faithful :=
fullyFaithfulUncurry.faithful
/-- Given functors `F₁ : C ⥤ D`, `F₂ : C' ⥤ D'` and `G : D × D' ⥤ E`, this is the isomorphism
between `curry.obj ((F₁.prod F₂).comp G)` and
`F₁ ⋙ curry.obj G ⋙ (whiskeringLeft C' D' E).obj F₂` in the category `C ⥤ C' ⥤ E`. -/
@[simps!]
def curryObjProdComp {C' D' : Type*} [Category C'] [Category D']
(F₁ : C ⥤ D) (F₂ : C' ⥤ D') (G : D × D' ⥤ E) :
curry.obj ((F₁.prod F₂).comp G) ≅
F₁ ⋙ curry.obj G ⋙ (whiskeringLeft C' D' E).obj F₂ :=
NatIso.ofComponents (fun X₁ ↦ NatIso.ofComponents (fun X₂ ↦ Iso.refl _))
/-- `F.flip` is isomorphic to uncurrying `F`, swapping the variables, and currying. -/
@[simps!]
def flipIsoCurrySwapUncurry (F : C ⥤ D ⥤ E) : F.flip ≅ curry.obj (Prod.swap _ _ ⋙ uncurry.obj F) :=
NatIso.ofComponents fun d => NatIso.ofComponents fun _ => Iso.refl _
/-- The uncurrying of `F.flip` is isomorphic to
swapping the factors followed by the uncurrying of `F`. -/
@[simps!]
def uncurryObjFlip (F : C ⥤ D ⥤ E) : uncurry.obj F.flip ≅ Prod.swap _ _ ⋙ uncurry.obj F :=
NatIso.ofComponents fun _ => Iso.refl _
variable (B C D E)
/-- A version of `CategoryTheory.whiskeringRight` for bifunctors, obtained by uncurrying,
applying `whiskeringRight` and currying back
-/
@[simps!]
def whiskeringRight₂ : (C ⥤ D ⥤ E) ⥤ (B ⥤ C) ⥤ (B ⥤ D) ⥤ B ⥤ E :=
uncurry ⋙
whiskeringRight _ _ _ ⋙ (whiskeringLeft _ _ _).obj (prodFunctorToFunctorProd _ _ _) ⋙ curry
variable {B C D E}
lemma uncurry_obj_curry_obj (F : B × C ⥤ D) : uncurry.obj (curry.obj F) = F :=
Functor.ext (by simp) (fun ⟨x₁, x₂⟩ ⟨y₁, y₂⟩ ⟨f₁, f₂⟩ => by
dsimp
simp only [← F.map_comp, Category.id_comp, Category.comp_id, prod_comp])
lemma curry_obj_injective {F₁ F₂ : C × D ⥤ E} (h : curry.obj F₁ = curry.obj F₂) :
F₁ = F₂ := by
rw [← uncurry_obj_curry_obj F₁, ← uncurry_obj_curry_obj F₂, h]
lemma curry_obj_uncurry_obj (F : B ⥤ C ⥤ D) : curry.obj (uncurry.obj F) = F :=
Functor.ext (fun _ => Functor.ext (by simp) (by simp)) (by cat_disch)
lemma uncurry_obj_injective {F₁ F₂ : B ⥤ C ⥤ D} (h : uncurry.obj F₁ = uncurry.obj F₂) :
F₁ = F₂ := by
rw [← curry_obj_uncurry_obj F₁, ← curry_obj_uncurry_obj F₂, h]
lemma flip_flip (F : B ⥤ C ⥤ D) : F.flip.flip = F := rfl
lemma flip_injective {F₁ F₂ : B ⥤ C ⥤ D} (h : F₁.flip = F₂.flip) :
F₁ = F₂ := by
rw [← flip_flip F₁, ← flip_flip F₂, h]
lemma uncurry_obj_curry_obj_flip_flip (F₁ : B ⥤ C) (F₂ : D ⥤ E) (G : C × E ⥤ H) :
uncurry.obj (F₂ ⋙ (F₁ ⋙ curry.obj G).flip).flip = (F₁.prod F₂) ⋙ G :=
Functor.ext (by simp) (fun ⟨x₁, x₂⟩ ⟨y₁, y₂⟩ ⟨f₁, f₂⟩ => by
dsimp
simp only [Category.id_comp, Category.comp_id, ← G.map_comp, prod_comp])
lemma uncurry_obj_curry_obj_flip_flip' (F₁ : B ⥤ C) (F₂ : D ⥤ E) (G : C × E ⥤ H) :
uncurry.obj (F₁ ⋙ (F₂ ⋙ (curry.obj G).flip).flip) = (F₁.prod F₂) ⋙ G :=
Functor.ext (by simp) (fun ⟨x₁, x₂⟩ ⟨y₁, y₂⟩ ⟨f₁, f₂⟩ => by
dsimp
simp only [Category.id_comp, Category.comp_id, ← G.map_comp, prod_comp])
/-- Natural isomorphism witnessing `comp_flip_uncurry_eq`. -/
@[simps!]
def compFlipUncurryIso (F : B ⥤ D) (G : D ⥤ C ⥤ E) :
uncurry.obj (F ⋙ G).flip ≅ (𝟭 C).prod F ⋙ uncurry.obj G.flip := .refl _
lemma comp_flip_uncurry_eq (F : B ⥤ D) (G : D ⥤ C ⥤ E) :
uncurry.obj (F ⋙ G).flip = (𝟭 C).prod F ⋙ uncurry.obj G.flip := rfl
/-- Natural isomorphism witnessing `comp_flip_curry_eq`. -/
@[simps!]
def curryObjCompIso (F : C × B ⥤ D) (G : D ⥤ E) :
(curry.obj (F ⋙ G)).flip ≅ (curry.obj F).flip ⋙ (whiskeringRight _ _ _).obj G := .refl _
lemma curry_obj_comp_flip (F : C × B ⥤ D) (G : D ⥤ E) :
(curry.obj (F ⋙ G)).flip =
(curry.obj F).flip ⋙ (whiskeringRight _ _ _).obj G := rfl
/-- The equivalence of types of bifunctors giving by flipping the arguments. -/
@[simps!]
def flippingEquiv : C ⥤ D ⥤ E ≃ D ⥤ C ⥤ E where
toFun F := F.flip
invFun F := F.flip
left_inv _ := rfl
right_inv _ := rfl
/-- The equivalence of types of bifunctors given by currying. -/
@[simps!]
def curryingEquiv : C ⥤ D ⥤ E ≃ C × D ⥤ E where
toFun F := uncurry.obj F
invFun G := curry.obj G
left_inv := curry_obj_uncurry_obj
right_inv := uncurry_obj_curry_obj
/-- The flipped equivalence of types of bifunctors given by currying. -/
@[simps!]
def curryingFlipEquiv : D ⥤ C ⥤ E ≃ C × D ⥤ E :=
flippingEquiv.trans curryingEquiv
end Functor
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Functor/FunctorHom.lean | import Mathlib.CategoryTheory.Monoidal.FunctorCategory
import Mathlib.CategoryTheory.Monoidal.Types.Basic
import Mathlib.CategoryTheory.Enriched.Basic
/-!
# Internal hom in functor categories
Given functors `F G : C ⥤ D`, define a functor `functorHom F G` from `C` to `Type max v' v u`,
which is a proxy for the "internal hom" functor Hom(F ⊗ coyoneda(-), G). This is used to show
that the functor category `C ⥤ D` is enriched over `C ⥤ Type max v' v u`. This is also useful
for showing that `C ⥤ Type max w v u` is monoidal closed.
See `Mathlib/CategoryTheory/Closed/FunctorToTypes.lean`.
-/
universe w v' v u u'
open CategoryTheory MonoidalCategory
variable {C : Type u} [Category.{v} C] {D : Type u'} [Category.{v'} D]
variable (F G : C ⥤ D)
namespace CategoryTheory.Functor
/-- Given functors `F G : C ⥤ D`, `HomObj F G A` is a proxy for the type
of "morphisms" `F ⊗ A ⟶ G`, where `A : C ⥤ Type w` (`w` an arbitrary universe). -/
@[ext]
structure HomObj (A : C ⥤ Type w) where
/-- The morphism `F.obj c ⟶ G.obj c` associated with `a : A.obj c`. -/
app (c : C) (a : A.obj c) : F.obj c ⟶ G.obj c
naturality {c d : C} (f : c ⟶ d) (a : A.obj c) :
F.map f ≫ app d (A.map f a) = app c a ≫ G.map f := by cat_disch
/-- When `F`, `G`, and `A` are all functors `C ⥤ Type w`, then `HomObj F G A` is in
bijection with `F ⊗ A ⟶ G`. -/
@[simps]
def homObjEquiv (F G A : C ⥤ Type w) : (HomObj F G A) ≃ (F ⊗ A ⟶ G) where
toFun a := ⟨fun X ⟨x, y⟩ ↦ a.app X y x, fun X Y f ↦ by
ext ⟨x, y⟩
erw [congr_fun (a.naturality f y) x]
rfl ⟩
invFun a := ⟨fun X y x ↦ a.app X (x, y), fun φ y ↦ by
ext x
erw [congr_fun (a.naturality φ) (x, y)]
rfl ⟩
left_inv _ := by aesop
right_inv _ := by aesop
namespace HomObj
attribute [reassoc (attr := simp)] naturality
variable {F G} {A : C ⥤ Type w}
lemma congr_app {f g : HomObj F G A} (h : f = g) (X : C)
(a : A.obj X) : f.app X a = g.app X a := by subst h; rfl
/-- Given a natural transformation `F ⟶ G`, get a term of `HomObj F G A` by "ignoring" `A`. -/
@[simps]
def ofNatTrans (f : F ⟶ G) : HomObj F G A where
app X _ := f.app X
/-- The identity `HomObj F F A`. -/
@[simps!]
def id (A : C ⥤ Type w) : HomObj F F A := ofNatTrans (𝟙 F)
/-- Composition of `f : HomObj F G A` with `g : HomObj G M A`. -/
@[simps]
def comp {M : C ⥤ D} (f : HomObj F G A) (g : HomObj G M A) : HomObj F M A where
app X a := f.app X a ≫ g.app X a
/-- Given a morphism `A' ⟶ A`, send a term of `HomObj F G A` to a term of `HomObj F G A'`. -/
@[simps]
def map {A' : C ⥤ Type w} (f : A' ⟶ A) (x : HomObj F G A) : HomObj F G A' where
app Δ a := x.app Δ (f.app Δ a)
naturality {Δ Δ'} φ a := by
rw [← x.naturality φ (f.app Δ a), FunctorToTypes.naturality _ _ f φ a]
end HomObj
/-- The contravariant functor taking `A : C ⥤ Type w` to `HomObj F G A`, i.e. Hom(F ⊗ -, G). -/
@[simps]
def homObjFunctor : (C ⥤ Type w)ᵒᵖ ⥤ Type max w v' u where
obj A := HomObj F G A.unop
map {A A'} f x :=
{ app := fun X a ↦ x.app X (f.unop.app _ a)
naturality := fun {X Y} φ a ↦ by
rw [← HomObj.naturality]
congr 2
exact congr_fun (f.unop.naturality φ) a }
/-- Composition of `homObjFunctor` with the co-Yoneda embedding, i.e. Hom(F ⊗ coyoneda(-), G).
When `F G : C ⥤ Type max v' v u`, this is the internal hom of `F` and `G`: see
`Mathlib/CategoryTheory/Closed/FunctorToTypes.lean`. -/
def functorHom (F G : C ⥤ D) : C ⥤ Type max v' v u := coyoneda.rightOp ⋙ homObjFunctor.{v} F G
variable {F G} in
@[ext]
lemma functorHom_ext {X : C} {x y : (F.functorHom G).obj X}
(h : ∀ (Y : C) (f : X ⟶ Y), x.app Y f = y.app Y f) : x = y :=
HomObj.ext (by ext; apply h)
/-- The equivalence `(A ⟶ F.functorHom G) ≃ HomObj F G A`. -/
@[simps]
def functorHomEquiv (A : C ⥤ Type max u v v') : (A ⟶ F.functorHom G) ≃ HomObj F G A where
toFun φ :=
{ app := fun X a ↦ (φ.app X a).app X (𝟙 _)
naturality := fun {X Y} f a => by
rw [← (φ.app X a).naturality f (𝟙 _)]
have := HomObj.congr_app (congr_fun (φ.naturality f) a) Y (𝟙 _)
dsimp [functorHom, homObjFunctor] at this
aesop }
invFun x :=
{ app := fun X a ↦ { app := fun Y f => x.app Y (A.map f a) }
naturality := fun X Y f => by
ext
dsimp only [types_comp_apply]
rw [← FunctorToTypes.map_comp_apply]
rfl }
left_inv φ := by
ext X a Y f
exact (HomObj.congr_app (congr_fun (φ.naturality f) a) Y (𝟙 _)).trans
(congr_arg ((φ.app X a).app Y) (by simp))
right_inv x := by simp
variable {F G} in
/-- Morphisms `(𝟙_ (C ⥤ Type max v' v u) ⟶ F.functorHom G)` are in bijection with
morphisms `F ⟶ G`. -/
@[simps]
def natTransEquiv : (𝟙_ (C ⥤ Type max v' v u) ⟶ F.functorHom G) ≃ (F ⟶ G) where
toFun f := ⟨fun X ↦ (f.app X (PUnit.unit)).app X (𝟙 _), by
intro X Y φ
rw [← (f.app X (PUnit.unit)).naturality φ]
congr 1
have := HomObj.congr_app (congr_fun (f.naturality φ) PUnit.unit) Y (𝟙 Y)
dsimp [functorHom, homObjFunctor] at this
aesop ⟩
invFun f := { app _ _ := HomObj.ofNatTrans f }
left_inv f := by
ext X a Y φ
have := HomObj.congr_app (congr_fun (f.naturality φ) PUnit.unit) Y (𝟙 Y)
dsimp [functorHom, homObjFunctor] at this
aesop
end CategoryTheory.Functor
open Functor
namespace CategoryTheory.Enriched.Functor
@[simp]
lemma natTransEquiv_symm_app_app_apply (F G : C ⥤ D) (f : F ⟶ G)
{X : C} {a : (𝟙_ (C ⥤ Type (max v' v u))).obj X} (Y : C) {φ : X ⟶ Y} :
((natTransEquiv.symm f).app X a).app Y φ = f.app Y := rfl
@[simp]
lemma natTransEquiv_symm_whiskerRight_functorHom_app (K L : C ⥤ D) (X : C) (f : K ⟶ K)
(x : 𝟙_ _ ⊗ (K.functorHom L).obj X) :
((natTransEquiv.symm f ▷ K.functorHom L).app X x) =
(HomObj.ofNatTrans f, x.2) := rfl
@[simp]
lemma functorHom_whiskerLeft_natTransEquiv_symm_app (K L : C ⥤ D) (X : C) (f : L ⟶ L)
(x : (K.functorHom L).obj X ⊗ 𝟙_ _) :
((K.functorHom L ◁ natTransEquiv.symm f).app X x) =
(x.1, HomObj.ofNatTrans f) := rfl
@[simp]
lemma whiskerLeft_app_apply (K L M N : C ⥤ D)
(g : L.functorHom M ⊗ M.functorHom N ⟶ L.functorHom N)
{X : C} (a : (K.functorHom L ⊗ L.functorHom M ⊗ M.functorHom N).obj X) :
(K.functorHom L ◁ g).app X a = ⟨a.1, g.app X a.2⟩ := rfl
@[simp]
lemma whiskerRight_app_apply (K L M N : C ⥤ D)
(f : K.functorHom L ⊗ L.functorHom M ⟶ K.functorHom M)
{X : C} (a : ((K.functorHom L ⊗ L.functorHom M) ⊗ M.functorHom N).obj X) :
(f ▷ M.functorHom N).app X a = ⟨f.app X a.1, a.2⟩ := rfl
@[simp]
lemma associator_inv_apply (K L M N : C ⥤ D) {X : C}
(x : ((K.functorHom L) ⊗ (L.functorHom M) ⊗ (M.functorHom N)).obj X) :
(α_ ((K.functorHom L).obj X) ((L.functorHom M).obj X) ((M.functorHom N).obj X)).inv x =
⟨⟨x.1, x.2.1⟩, x.2.2⟩ := rfl
@[simp]
lemma associator_hom_apply (K L M N : C ⥤ D) {X : C}
(x : (((K.functorHom L) ⊗ (L.functorHom M)) ⊗ (M.functorHom N)).obj X) :
(α_ ((K.functorHom L).obj X) ((L.functorHom M).obj X) ((M.functorHom N).obj X)).hom x =
⟨x.1.1, x.1.2, x.2⟩ := rfl
noncomputable instance : EnrichedCategory (C ⥤ Type max v' v u) (C ⥤ D) where
Hom := functorHom
id F := natTransEquiv.symm (𝟙 F)
comp F G H := { app := fun _ ⟨f, g⟩ => f.comp g }
end CategoryTheory.Enriched.Functor |
.lake/packages/mathlib/Mathlib/CategoryTheory/Functor/Hom.lean | import Mathlib.CategoryTheory.Products.Basic
import Mathlib.CategoryTheory.Types.Basic
/-!
The hom functor, sending `(X, Y)` to the type `X ⟶ Y`.
-/
universe v u
open Opposite
open CategoryTheory
namespace CategoryTheory.Functor
variable (C : Type u) [Category.{v} C]
/-- `Functor.hom` is the hom-pairing, sending `(X, Y)` to `X ⟶ Y`, contravariant in `X` and
covariant in `Y`. -/
@[simps]
def hom : Cᵒᵖ × C ⥤ Type v where
obj p := unop p.1 ⟶ p.2
map f h := f.1.unop ≫ h ≫ f.2
end CategoryTheory.Functor |
.lake/packages/mathlib/Mathlib/CategoryTheory/Functor/Derived/RightDerived.lean | import Mathlib.CategoryTheory.Functor.KanExtension.Basic
import Mathlib.CategoryTheory.Localization.Predicate
/-!
# Right derived functors
In this file, given a functor `F : C ⥤ H`, and `L : C ⥤ D` that is a
localization functor for `W : MorphismProperty C`, we define
`F.totalRightDerived L W : D ⥤ H` as the left Kan extension of `F`
along `L`: it is defined if the type class `F.HasRightDerivedFunctor W`
asserting the existence of a left Kan extension is satisfied.
(The name `totalRightDerived` is to avoid name-collision with
`Functor.rightDerived` which are the right derived functors in
the context of abelian categories.)
Given `RF : D ⥤ H` and `α : F ⟶ L ⋙ RF`, we also introduce a type class
`F.IsRightDerivedFunctor α W` saying that `α` is a left Kan extension of `F`
along the localization functor `L`.
## TODO
- refactor `Functor.rightDerived` (and `Functor.leftDerived`) when the necessary
material enters mathlib: derived categories, injective/projective derivability
structures, existence of derived functors from derivability structures.
## References
* https://ncatlab.org/nlab/show/derived+functor
-/
namespace CategoryTheory
namespace Functor
variable {C C' D D' H H' : Type _} [Category C] [Category C']
[Category D] [Category D'] [Category H] [Category H']
(RF RF' RF'' : D ⥤ H) {F F' F'' : C ⥤ H} (e : F ≅ F') {L : C ⥤ D}
(α : F ⟶ L ⋙ RF) (α' : F' ⟶ L ⋙ RF') (α'' : F'' ⟶ L ⋙ RF'') (α'₂ : F ⟶ L ⋙ RF')
(W : MorphismProperty C)
/-- A functor `RF : D ⥤ H` is a right derived functor of `F : C ⥤ H`
if it is equipped with a natural transformation `α : F ⟶ L ⋙ RF`
which makes it a left Kan extension of `F` along `L`,
where `L : C ⥤ D` is a localization functor for `W : MorphismProperty C`. -/
class IsRightDerivedFunctor (RF : D ⥤ H) {F : C ⥤ H} {L : C ⥤ D} (α : F ⟶ L ⋙ RF)
(W : MorphismProperty C) [L.IsLocalization W] : Prop where
isLeftKanExtension (RF α) : RF.IsLeftKanExtension α
lemma isRightDerivedFunctor_iff_isLeftKanExtension [L.IsLocalization W] :
RF.IsRightDerivedFunctor α W ↔ RF.IsLeftKanExtension α := by
constructor
· exact fun _ => IsRightDerivedFunctor.isLeftKanExtension RF α W
· exact fun h => ⟨h⟩
variable {RF RF'} in
lemma isRightDerivedFunctor_iff_of_iso (α' : F ⟶ L ⋙ RF') (W : MorphismProperty C)
[L.IsLocalization W] (e : RF ≅ RF') (comm : α ≫ whiskerLeft L e.hom = α') :
RF.IsRightDerivedFunctor α W ↔ RF'.IsRightDerivedFunctor α' W := by
simp only [isRightDerivedFunctor_iff_isLeftKanExtension]
exact isLeftKanExtension_iff_of_iso e _ _ comm
section
variable [L.IsLocalization W] [RF.IsRightDerivedFunctor α W]
/-- Constructor for natural transformations from a right derived functor. -/
noncomputable def rightDerivedDesc (G : D ⥤ H) (β : F ⟶ L ⋙ G) : RF ⟶ G :=
have := IsRightDerivedFunctor.isLeftKanExtension RF α W
RF.descOfIsLeftKanExtension α G β
@[reassoc (attr := simp)]
lemma rightDerived_fac (G : D ⥤ H) (β : F ⟶ L ⋙ G) :
α ≫ whiskerLeft L (RF.rightDerivedDesc α W G β) = β :=
have := IsRightDerivedFunctor.isLeftKanExtension RF α W
RF.descOfIsLeftKanExtension_fac α G β
@[reassoc (attr := simp)]
lemma rightDerived_fac_app (G : D ⥤ H) (β : F ⟶ L ⋙ G) (X : C) :
α.app X ≫ (RF.rightDerivedDesc α W G β).app (L.obj X) = β.app X :=
have := IsRightDerivedFunctor.isLeftKanExtension RF α W
RF.descOfIsLeftKanExtension_fac_app α G β X
include W in
lemma rightDerived_ext (G : D ⥤ H) (γ₁ γ₂ : RF ⟶ G)
(hγ : α ≫ whiskerLeft L γ₁ = α ≫ whiskerLeft L γ₂) : γ₁ = γ₂ :=
have := IsRightDerivedFunctor.isLeftKanExtension RF α W
RF.hom_ext_of_isLeftKanExtension α γ₁ γ₂ hγ
/-- The natural transformation `RF ⟶ RF'` on right derived functors that is
induced by a natural transformation `F ⟶ F'`. -/
noncomputable def rightDerivedNatTrans (τ : F ⟶ F') : RF ⟶ RF' :=
RF.rightDerivedDesc α W RF' (τ ≫ α')
@[reassoc (attr := simp)]
lemma rightDerivedNatTrans_fac (τ : F ⟶ F') :
α ≫ whiskerLeft L (rightDerivedNatTrans RF RF' α α' W τ) = τ ≫ α' := by
dsimp only [rightDerivedNatTrans]
simp
@[reassoc (attr := simp)]
lemma rightDerivedNatTrans_app (τ : F ⟶ F') (X : C) :
α.app X ≫ (rightDerivedNatTrans RF RF' α α' W τ).app (L.obj X) =
τ.app X ≫ α'.app X := by
dsimp only [rightDerivedNatTrans]
simp
@[simp]
lemma rightDerivedNatTrans_id :
rightDerivedNatTrans RF RF α α W (𝟙 F) = 𝟙 RF :=
rightDerived_ext RF α W _ _ _ (by simp)
variable [RF'.IsRightDerivedFunctor α' W]
@[reassoc (attr := simp)]
lemma rightDerivedNatTrans_comp (τ : F ⟶ F') (τ' : F' ⟶ F'') :
rightDerivedNatTrans RF RF' α α' W τ ≫ rightDerivedNatTrans RF' RF'' α' α'' W τ' =
rightDerivedNatTrans RF RF'' α α'' W (τ ≫ τ') :=
rightDerived_ext RF α W _ _ _ (by simp)
/-- The natural isomorphism `RF ≅ RF'` on right derived functors that is
induced by a natural isomorphism `F ≅ F'`. -/
@[simps]
noncomputable def rightDerivedNatIso (τ : F ≅ F') :
RF ≅ RF' where
hom := rightDerivedNatTrans RF RF' α α' W τ.hom
inv := rightDerivedNatTrans RF' RF α' α W τ.inv
/-- Uniqueness (up to a natural isomorphism) of the right derived functor. -/
noncomputable abbrev rightDerivedUnique [RF'.IsRightDerivedFunctor α'₂ W] : RF ≅ RF' :=
rightDerivedNatIso RF RF' α α'₂ W (Iso.refl F)
lemma isRightDerivedFunctor_iff_isIso_rightDerivedDesc (G : D ⥤ H) (β : F ⟶ L ⋙ G) :
G.IsRightDerivedFunctor β W ↔ IsIso (RF.rightDerivedDesc α W G β) := by
rw [isRightDerivedFunctor_iff_isLeftKanExtension]
have := IsRightDerivedFunctor.isLeftKanExtension _ α W
exact isLeftKanExtension_iff_isIso _ α _ (by simp)
end
variable (F)
/-- A functor `F : C ⥤ H` has a right derived functor with respect to
`W : MorphismProperty C` if it has a left Kan extension along
`W.Q : C ⥤ W.Localization` (or any localization functor `L : C ⥤ D`
for `W`, see `hasRightDerivedFunctor_iff`). -/
class HasRightDerivedFunctor : Prop where
hasLeftKanExtension' : HasLeftKanExtension W.Q F
variable (L)
variable [L.IsLocalization W]
lemma hasRightDerivedFunctor_iff :
F.HasRightDerivedFunctor W ↔ HasLeftKanExtension L F := by
have : HasRightDerivedFunctor F W ↔ HasLeftKanExtension W.Q F :=
⟨fun h => h.hasLeftKanExtension', fun h => ⟨h⟩⟩
rw [this, hasLeftExtension_iff_postcomp₁ (Localization.compUniqFunctor W.Q L W) F]
variable {F}
include e in
lemma hasRightDerivedFunctor_iff_of_iso :
HasRightDerivedFunctor F W ↔ HasRightDerivedFunctor F' W := by
rw [hasRightDerivedFunctor_iff F W.Q W, hasRightDerivedFunctor_iff F' W.Q W,
hasLeftExtension_iff_of_iso₂ W.Q e]
variable (F)
lemma HasRightDerivedFunctor.hasLeftKanExtension [HasRightDerivedFunctor F W] :
HasLeftKanExtension L F := by
simpa only [← hasRightDerivedFunctor_iff F L W]
variable {F L W}
lemma HasRightDerivedFunctor.mk' [RF.IsRightDerivedFunctor α W] :
HasRightDerivedFunctor F W := by
have := IsRightDerivedFunctor.isLeftKanExtension RF α W
simpa only [hasRightDerivedFunctor_iff F L W] using HasLeftKanExtension.mk RF α
section
variable (F) [F.HasRightDerivedFunctor W] (L W)
/-- Given a functor `F : C ⥤ H`, and a localization functor `L : D ⥤ H` for `W`,
this is the right derived functor `D ⥤ H` of `F`, i.e. the left Kan extension
of `F` along `L`. -/
noncomputable def totalRightDerived : D ⥤ H :=
have := HasRightDerivedFunctor.hasLeftKanExtension F L W
leftKanExtension L F
/-- The canonical natural transformation `F ⟶ L ⋙ F.totalRightDerived L W`. -/
noncomputable def totalRightDerivedUnit : F ⟶ L ⋙ F.totalRightDerived L W :=
have := HasRightDerivedFunctor.hasLeftKanExtension F L W
leftKanExtensionUnit L F
instance : (F.totalRightDerived L W).IsRightDerivedFunctor
(F.totalRightDerivedUnit L W) W where
isLeftKanExtension := by
dsimp [totalRightDerived, totalRightDerivedUnit]
infer_instance
end
end Functor
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Functor/Derived/LeftDerived.lean | import Mathlib.CategoryTheory.Functor.KanExtension.Basic
import Mathlib.CategoryTheory.Localization.Predicate
/-!
# Left derived functors
In this file, given a functor `F : C ⥤ H`, and `L : C ⥤ D` that is a
localization functor for `W : MorphismProperty C`, we define
`F.totalLeftDerived L W : D ⥤ H` as the right Kan extension of `F`
along `L`: it is defined if the type class `F.HasLeftDerivedFunctor W`
asserting the existence of a right Kan extension is satisfied.
(The name `totalLeftDerived` is to avoid name-collision with
`Functor.leftDerived` which are the left derived functors in
the context of abelian categories.)
Given `LF : D ⥤ H` and `α : L ⋙ RF ⟶ F`, we also introduce a type class
`F.IsLeftDerivedFunctor α W` saying that `α` is a right Kan extension of `F`
along the localization functor `L`.
(This file was obtained by dualizing the results in the file
`Mathlib.CategoryTheory.Functor.Derived.RightDerived`.)
## References
* https://ncatlab.org/nlab/show/derived+functor
-/
namespace CategoryTheory
namespace Functor
variable {C C' D D' H H' : Type _} [Category C] [Category C']
[Category D] [Category D'] [Category H] [Category H']
(LF'' LF' LF : D ⥤ H) {F F' F'' : C ⥤ H} (e : F ≅ F') {L : C ⥤ D}
(α'' : L ⋙ LF'' ⟶ F'') (α' : L ⋙ LF' ⟶ F') (α : L ⋙ LF ⟶ F) (α'₂ : L ⋙ LF' ⟶ F)
(W : MorphismProperty C)
/-- A functor `LF : D ⥤ H` is a left derived functor of `F : C ⥤ H`
if it is equipped with a natural transformation `α : L ⋙ LF ⟶ F`
which makes it a right Kan extension of `F` along `L`,
where `L : C ⥤ D` is a localization functor for `W : MorphismProperty C`. -/
class IsLeftDerivedFunctor (LF : D ⥤ H) {F : C ⥤ H} {L : C ⥤ D} (α : L ⋙ LF ⟶ F)
(W : MorphismProperty C) [L.IsLocalization W] : Prop where
isRightKanExtension (LF α) : LF.IsRightKanExtension α
lemma isLeftDerivedFunctor_iff_isRightKanExtension [L.IsLocalization W] :
LF.IsLeftDerivedFunctor α W ↔ LF.IsRightKanExtension α := by
constructor
· exact fun _ => IsLeftDerivedFunctor.isRightKanExtension LF α W
· exact fun h => ⟨h⟩
variable {RF RF'} in
lemma isLeftDerivedFunctor_iff_of_iso (α' : L ⋙ LF' ⟶ F) (W : MorphismProperty C)
[L.IsLocalization W] (e : LF ≅ LF') (comm : whiskerLeft L e.hom ≫ α' = α) :
LF.IsLeftDerivedFunctor α W ↔ LF'.IsLeftDerivedFunctor α' W := by
simp only [isLeftDerivedFunctor_iff_isRightKanExtension]
exact isRightKanExtension_iff_of_iso e _ _ comm
section
variable [L.IsLocalization W] [LF.IsLeftDerivedFunctor α W]
/-- Constructor for natural transformations to a left derived functor. -/
noncomputable def leftDerivedLift (G : D ⥤ H) (β : L ⋙ G ⟶ F) : G ⟶ LF :=
have := IsLeftDerivedFunctor.isRightKanExtension LF α W
LF.liftOfIsRightKanExtension α G β
@[reassoc (attr := simp)]
lemma leftDerived_fac (G : D ⥤ H) (β : L ⋙ G ⟶ F) :
whiskerLeft L (LF.leftDerivedLift α W G β) ≫ α = β :=
have := IsLeftDerivedFunctor.isRightKanExtension LF α W
LF.liftOfIsRightKanExtension_fac α G β
@[reassoc (attr := simp)]
lemma leftDerived_fac_app (G : D ⥤ H) (β : L ⋙ G ⟶ F) (X : C) :
(LF.leftDerivedLift α W G β).app (L.obj X) ≫ α.app X = β.app X :=
have := IsLeftDerivedFunctor.isRightKanExtension LF α W
LF.liftOfIsRightKanExtension_fac_app α G β X
include W in
lemma leftDerived_ext (G : D ⥤ H) (γ₁ γ₂ : G ⟶ LF)
(hγ : whiskerLeft L γ₁ ≫ α = whiskerLeft L γ₂ ≫ α) : γ₁ = γ₂ :=
have := IsLeftDerivedFunctor.isRightKanExtension LF α W
LF.hom_ext_of_isRightKanExtension α γ₁ γ₂ hγ
/-- The natural transformation `LF' ⟶ LF` on left derived functors that is
induced by a natural transformation `F' ⟶ F`. -/
noncomputable def leftDerivedNatTrans (τ : F' ⟶ F) : LF' ⟶ LF :=
LF.leftDerivedLift α W LF' (α' ≫ τ)
@[reassoc (attr := simp)]
lemma leftDerivedNatTrans_fac (τ : F' ⟶ F) :
whiskerLeft L (leftDerivedNatTrans LF' LF α' α W τ) ≫ α = α' ≫ τ := by
dsimp only [leftDerivedNatTrans]
simp
@[reassoc (attr := simp)]
lemma leftDerivedNatTrans_app (τ : F' ⟶ F) (X : C) :
(leftDerivedNatTrans LF' LF α' α W τ).app (L.obj X) ≫ α.app X =
α'.app X ≫ τ.app X := by
dsimp only [leftDerivedNatTrans]
simp
@[simp]
lemma leftDerivedNatTrans_id :
leftDerivedNatTrans LF LF α α W (𝟙 F) = 𝟙 LF :=
leftDerived_ext LF α W _ _ _ (by simp)
variable [LF'.IsLeftDerivedFunctor α' W]
@[reassoc (attr := simp)]
lemma leftDerivedNatTrans_comp (τ' : F'' ⟶ F') (τ : F' ⟶ F) :
leftDerivedNatTrans LF'' LF' α'' α' W τ' ≫ leftDerivedNatTrans LF' LF α' α W τ =
leftDerivedNatTrans LF'' LF α'' α W (τ' ≫ τ) :=
leftDerived_ext LF α W _ _ _ (by simp)
/-- The natural isomorphism `LF' ≅ LF` on left derived functors that is
induced by a natural isomorphism `F' ≅ F`. -/
@[simps]
noncomputable def leftDerivedNatIso (τ : F' ≅ F) :
LF' ≅ LF where
hom := leftDerivedNatTrans LF' LF α' α W τ.hom
inv := leftDerivedNatTrans LF LF' α α' W τ.inv
/-- Uniqueness (up to a natural isomorphism) of the left derived functor. -/
noncomputable abbrev leftDerivedUnique [LF'.IsLeftDerivedFunctor α'₂ W] : LF ≅ LF' :=
leftDerivedNatIso LF LF' α α'₂ W (Iso.refl F)
lemma isLeftDerivedFunctor_iff_isIso_leftDerivedLift (G : D ⥤ H) (β : L ⋙ G ⟶ F) :
G.IsLeftDerivedFunctor β W ↔ IsIso (LF.leftDerivedLift α W G β) := by
rw [isLeftDerivedFunctor_iff_isRightKanExtension]
have := IsLeftDerivedFunctor.isRightKanExtension _ α W
exact isRightKanExtension_iff_isIso _ α _ (by simp)
end
variable (F)
/-- A functor `F : C ⥤ H` has a left derived functor with respect to
`W : MorphismProperty C` if it has a right Kan extension along
`W.Q : C ⥤ W.Localization` (or any localization functor `L : C ⥤ D`
for `W`, see `hasLeftDerivedFunctor_iff`). -/
class HasLeftDerivedFunctor : Prop where
hasRightKanExtension' : HasRightKanExtension W.Q F
variable (L)
variable [L.IsLocalization W]
lemma hasLeftDerivedFunctor_iff :
F.HasLeftDerivedFunctor W ↔ HasRightKanExtension L F := by
have : HasLeftDerivedFunctor F W ↔ HasRightKanExtension W.Q F :=
⟨fun h => h.hasRightKanExtension', fun h => ⟨h⟩⟩
rw [this, hasRightExtension_iff_postcomp₁ (Localization.compUniqFunctor W.Q L W) F]
variable {F}
include e in
lemma hasLeftDerivedFunctor_iff_of_iso :
HasLeftDerivedFunctor F W ↔ HasLeftDerivedFunctor F' W := by
rw [hasLeftDerivedFunctor_iff F W.Q W, hasLeftDerivedFunctor_iff F' W.Q W,
hasRightExtension_iff_of_iso₂ W.Q e]
variable (F)
lemma HasLeftDerivedFunctor.hasRightKanExtension [HasLeftDerivedFunctor F W] :
HasRightKanExtension L F := by
simpa only [← hasLeftDerivedFunctor_iff F L W]
variable {F L W}
lemma HasLeftDerivedFunctor.mk' [LF.IsLeftDerivedFunctor α W] :
HasLeftDerivedFunctor F W := by
have := IsLeftDerivedFunctor.isRightKanExtension LF α W
simpa only [hasLeftDerivedFunctor_iff F L W] using HasRightKanExtension.mk LF α
section
variable (F) [F.HasLeftDerivedFunctor W] (L W)
/-- Given a functor `F : C ⥤ H`, and a localization functor `L : D ⥤ H` for `W`,
this is the left derived functor `D ⥤ H` of `F`, i.e. the right Kan extension
of `F` along `L`. -/
noncomputable def totalLeftDerived : D ⥤ H :=
have := HasLeftDerivedFunctor.hasRightKanExtension F L W
rightKanExtension L F
/-- The canonical natural transformation `L ⋙ F.totalLeftDerived L W ⟶ F`. -/
noncomputable def totalLeftDerivedCounit : L ⋙ F.totalLeftDerived L W ⟶ F :=
have := HasLeftDerivedFunctor.hasRightKanExtension F L W
rightKanExtensionCounit L F
instance : (F.totalLeftDerived L W).IsLeftDerivedFunctor
(F.totalLeftDerivedCounit L W) W where
isRightKanExtension := by
dsimp [totalLeftDerived, totalLeftDerivedCounit]
infer_instance
end
end Functor
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Functor/Derived/PointwiseRightDerived.lean | import Mathlib.CategoryTheory.Functor.Derived.RightDerived
import Mathlib.CategoryTheory.Functor.KanExtension.Pointwise
import Mathlib.CategoryTheory.Localization.StructuredArrow
/-!
# Pointwise right derived functors
We define the pointwise right derived functors using the notion
of pointwise left Kan extensions.
We show that if `F : C ⥤ H` inverts `W : MorphismProperty C`,
then it has a pointwise right derived functor.
-/
universe v₁ v₂ v₃ u₁ u₂ u₃
namespace CategoryTheory
open Category Limits
namespace Functor
variable {C : Type u₁} {D : Type u₂} {H : Type u₃}
[Category.{v₁} C] [Category.{v₂} D] [Category.{v₃} H]
(F' : D ⥤ H) (F : C ⥤ H) (L : C ⥤ D) (α : F ⟶ L ⋙ F') (W : MorphismProperty C)
/-- Given `F : C ⥤ H`, `W : MorphismProperty C` and `X : C`, we say that `F` has a
pointwise right derived functor at `X` if `F` has a left Kan extension
at `L.obj X` for any localization functor `L : C ⥤ D` for `W`. In the
definition, this is stated for `L := W.Q`, see `hasPointwiseRightDerivedFunctorAt_iff`
for the more general equivalence. -/
class HasPointwiseRightDerivedFunctorAt (X : C) : Prop where
/-- Use the more general `hasColimit` lemma instead, see also
`hasPointwiseRightDerivedFunctorAt_iff` -/
hasColimit' : HasPointwiseLeftKanExtensionAt W.Q F (W.Q.obj X)
/-- A functor `F : C ⥤ H` has a pointwise right derived functor with respect to
`W : MorphismProperty C` if it has a pointwise right derived functor at `X`
for any `X : C`. -/
abbrev HasPointwiseRightDerivedFunctor := ∀ (X : C), F.HasPointwiseRightDerivedFunctorAt W X
lemma hasPointwiseRightDerivedFunctorAt_iff [L.IsLocalization W] (X : C) :
F.HasPointwiseRightDerivedFunctorAt W X ↔
HasPointwiseLeftKanExtensionAt L F (L.obj X) := by
rw [← hasPointwiseLeftKanExtensionAt_iff_of_equivalence W.Q L F
(Localization.uniq W.Q L W) (Localization.compUniqFunctor W.Q L W) (W.Q.obj X) (L.obj X)
((Localization.compUniqFunctor W.Q L W).app X)]
exact ⟨fun h ↦ h.hasColimit', fun h ↦ ⟨h⟩⟩
lemma HasPointwiseRightDerivedFunctorAt.hasColimit
[L.IsLocalization W] (X : C) [F.HasPointwiseRightDerivedFunctorAt W X] :
HasPointwiseLeftKanExtensionAt L F (L.obj X) := by
rwa [← hasPointwiseRightDerivedFunctorAt_iff F L W]
lemma hasPointwiseRightDerivedFunctorAt_iff_of_mem {X Y : C} (w : X ⟶ Y) (hw : W w) :
F.HasPointwiseRightDerivedFunctorAt W X ↔
F.HasPointwiseRightDerivedFunctorAt W Y := by
simp only [F.hasPointwiseRightDerivedFunctorAt_iff W.Q W]
exact hasPointwiseLeftKanExtensionAt_iff_of_iso W.Q F (Localization.isoOfHom W.Q W w hw)
section
variable [F.HasPointwiseRightDerivedFunctor W]
lemma hasPointwiseLeftKanExtension_of_hasPointwiseRightDerivedFunctor [L.IsLocalization W] :
HasPointwiseLeftKanExtension L F := fun Y ↦ by
have := Localization.essSurj L W
rw [← hasPointwiseLeftKanExtensionAt_iff_of_iso _ F (L.objObjPreimageIso Y),
← F.hasPointwiseRightDerivedFunctorAt_iff L W]
infer_instance
lemma hasRightDerivedFunctor_of_hasPointwiseRightDerivedFunctor :
F.HasRightDerivedFunctor W where
hasLeftKanExtension' := by
have := F.hasPointwiseLeftKanExtension_of_hasPointwiseRightDerivedFunctor W.Q W
infer_instance
attribute [instance] hasRightDerivedFunctor_of_hasPointwiseRightDerivedFunctor
variable {F L}
/-- A right derived functor is a pointwise right derived functor when
there exists a pointwise right derived functor. -/
noncomputable def isPointwiseLeftKanExtensionOfHasPointwiseRightDerivedFunctor
[L.IsLocalization W] [F'.IsRightDerivedFunctor α W] :
(LeftExtension.mk _ α).IsPointwiseLeftKanExtension :=
have := hasPointwiseLeftKanExtension_of_hasPointwiseRightDerivedFunctor F L
have := IsRightDerivedFunctor.isLeftKanExtension F' α W
isPointwiseLeftKanExtensionOfIsLeftKanExtension F' α
end
section
variable {F L}
/-- If `L : C ⥤ D` is a localization functor for `W` and `e : F ≅ L ⋙ G` is an isomorphism,
then `e.hom` makes `G` a pointwise left Kan extension of `F` along `L` at `L.obj Y`
for any `Y : C`. -/
def isPointwiseLeftKanExtensionAtOfIsoOfIsLocalization
{G : D ⥤ H} (e : F ≅ L ⋙ G) [L.IsLocalization W] (Y : C) :
(LeftExtension.mk _ e.hom).IsPointwiseLeftKanExtensionAt (L.obj Y) where
desc s := e.inv.app Y ≫ s.ι.app (CostructuredArrow.mk (𝟙 (L.obj Y)))
fac s j := by
refine Localization.induction_costructuredArrow L W _ (by simp)
(fun X₁ X₂ f φ hφ ↦ ?_) (fun X₁ X₂ w hw φ hφ ↦ ?_) j
· have eq := s.ι.naturality
(CostructuredArrow.homMk f : CostructuredArrow.mk (L.map f ≫ φ) ⟶ CostructuredArrow.mk φ)
dsimp at eq hφ ⊢
rw [comp_id] at eq
rw [assoc] at hφ
rw [assoc, map_comp_assoc, ← eq, ← hφ, NatTrans.naturality_assoc, comp_map]
· have : IsIso (F.map w) := by
have := Localization.inverts L W w hw
rw [← NatIso.naturality_2 e w]
dsimp
infer_instance
have eq := s.ι.naturality
(CostructuredArrow.homMk w : CostructuredArrow.mk φ ⟶ CostructuredArrow.mk
((Localization.isoOfHom L W w hw).inv ≫ φ))
dsimp at eq hφ ⊢
rw [comp_id] at eq
rw [assoc] at hφ
rw [map_comp, assoc, assoc, ← cancel_epi (F.map w), eq, ← hφ,
NatTrans.naturality_assoc, comp_map, ← G.map_comp_assoc]
simp
uniq s m hm := by
have := hm (CostructuredArrow.mk (𝟙 (L.obj Y)))
dsimp at this m hm ⊢
simp only [← this, map_id, comp_id, Iso.inv_hom_id_app_assoc]
/-- If `L` is a localization functor for `W` and `e : F ≅ L ⋙ G` is an isomorphism,
then `e.hom` makes `G` a pointwise left Kan extension of `F` along `L`. -/
noncomputable def isPointwiseLeftKanExtensionOfIsoOfIsLocalization
{G : D ⥤ H} (e : F ≅ L ⋙ G) [L.IsLocalization W] :
(LeftExtension.mk _ e.hom).IsPointwiseLeftKanExtension := fun Y ↦
have := Localization.essSurj L W
(LeftExtension.mk _ e.hom).isPointwiseLeftKanExtensionAtEquivOfIso'
(L.objObjPreimageIso Y) (isPointwiseLeftKanExtensionAtOfIsoOfIsLocalization W e _)
/-- Let `L : C ⥤ D` be a localization functor for `W`, if an extension `E`
of `F : C ⥤ H` along `L` is such that the natural transformation
`E.hom : F ⟶ L ⋙ E.right` is an isomorphism, then `E` is a pointwise
left Kan extension. -/
noncomputable def LeftExtension.isPointwiseLeftKanExtensionOfIsIsoOfIsLocalization
(E : LeftExtension L F) [IsIso E.hom] [L.IsLocalization W] :
E.IsPointwiseLeftKanExtension :=
Functor.isPointwiseLeftKanExtensionOfIsoOfIsLocalization W (asIso E.hom)
lemma hasPointwiseRightDerivedFunctor_of_inverts
(F : C ⥤ H) {W : MorphismProperty C} (hF : W.IsInvertedBy F) :
F.HasPointwiseRightDerivedFunctor W := by
intro X
rw [hasPointwiseRightDerivedFunctorAt_iff F W.Q W]
exact (isPointwiseLeftKanExtensionOfIsoOfIsLocalization W
(Localization.fac F hF W.Q).symm).hasPointwiseLeftKanExtension _
lemma isRightDerivedFunctor_of_inverts
[L.IsLocalization W] (F' : D ⥤ H) (e : L ⋙ F' ≅ F) :
F'.IsRightDerivedFunctor e.inv W where
isLeftKanExtension :=
(isPointwiseLeftKanExtensionOfIsoOfIsLocalization W e.symm).isLeftKanExtension
instance [L.IsLocalization W] (hF : W.IsInvertedBy F) :
(Localization.lift F hF L).IsRightDerivedFunctor (Localization.fac F hF L).inv W :=
isRightDerivedFunctor_of_inverts W _ _
variable {W} in
lemma isIso_of_isRightDerivedFunctor_of_inverts [L.IsLocalization W]
{F : C ⥤ H} (RF : D ⥤ H) (α : F ⟶ L ⋙ RF)
(hF : W.IsInvertedBy F) [RF.IsRightDerivedFunctor α W] :
IsIso α := by
have : α = (Localization.fac F hF L).inv ≫
whiskerLeft _ (rightDerivedUnique _ _ (Localization.fac F hF L).inv α W).hom := by simp
rw [this]
infer_instance
variable {W} in
lemma isRightDerivedFunctor_iff_of_inverts [L.IsLocalization W]
{F : C ⥤ H} (RF : D ⥤ H) (α : F ⟶ L ⋙ RF)
(hF : W.IsInvertedBy F) :
RF.IsRightDerivedFunctor α W ↔ IsIso α :=
⟨fun _ ↦ isIso_of_isRightDerivedFunctor_of_inverts RF α hF, fun _ ↦
isRightDerivedFunctor_of_inverts W RF (asIso α).symm⟩
end
end Functor
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Functor/Derived/Adjunction.lean | import Mathlib.CategoryTheory.Functor.Derived.LeftDerived
import Mathlib.CategoryTheory.Functor.Derived.RightDerived
/-!
# Derived adjunction
Assume that functors `G : C₁ ⥤ C₂` and `F : C₂ ⥤ C₁` are part of an
adjunction `adj : G ⊣ F`, that we have localization
functors `L₁ : C₁ ⥤ D₁` and `L₂ : C₂ ⥤ D₂` with respect to
classes of morphisms `W₁` and `W₂`, and that `G` admits
a left derived functor `G' : D₁ ⥤ D₂` and `F` a right derived
functor `F' : D₂ ⥤ D₁`. We show that there is an adjunction
`G' ⊣ F'` under the additional assumption that `F'` and `G'`
are *absolute* derived functors, i.e. they remain derived
functors after the post-composition with any functor
(we actually only need to know that `G' ⋙ F'` is the
left derived functor of `G ⋙ L₂ ⋙ F'` and
that `F' ⋙ G'` is the right derived functor of `F ⋙ L₁ ⋙ G'`).
## References
* [Georges Maltsiniotis, *Le théorème de Quillen, d'adjonction des
foncteurs dérivés, revisité*][Maltsiniotis2007]
-/
namespace CategoryTheory
variable {C₁ C₂ D₁ D₂ : Type*} [Category C₁] [Category C₂] [Category D₁] [Category D₂]
{G : C₁ ⥤ C₂} {F : C₂ ⥤ C₁} (adj : G ⊣ F)
{L₁ : C₁ ⥤ D₁} {L₂ : C₂ ⥤ D₂} (W₁ : MorphismProperty C₁) (W₂ : MorphismProperty C₂)
[L₁.IsLocalization W₁] [L₂.IsLocalization W₂]
{G' : D₁ ⥤ D₂} {F' : D₂ ⥤ D₁}
(α : L₁ ⋙ G' ⟶ G ⋙ L₂) (β : F ⋙ L₁ ⟶ L₂ ⋙ F')
namespace Adjunction
open Functor
/-- Auxiliary definition for `Adjunction.derived`. -/
@[simps]
def derived' [G'.IsLeftDerivedFunctor α W₁] [F'.IsRightDerivedFunctor β W₂]
(η : 𝟭 D₁ ⟶ G' ⋙ F') (ε : F' ⋙ G' ⟶ 𝟭 D₂)
(hη : ∀ (X₁ : C₁), η.app (L₁.obj X₁) ≫ F'.map (α.app X₁) =
L₁.map (adj.unit.app X₁) ≫ β.app (G.obj X₁) := by cat_disch)
(hε : ∀ (X₂ : C₂), G'.map (β.app X₂) ≫ ε.app (L₂.obj X₂) =
α.app (F.obj X₂) ≫ L₂.map (adj.counit.app X₂) := by cat_disch) : G' ⊣ F' where
unit := η
counit := ε
left_triangle_components := by
suffices G'.leftUnitor.inv ≫ whiskerRight η G' ≫ (Functor.associator _ _ _ ).hom ≫
whiskerLeft G' ε ≫ G'.rightUnitor.hom = 𝟙 _ from
fun Y₁ ↦ by simpa using congr_app this Y₁
apply G'.leftDerived_ext α W₁
ext X₁
have eq₁ := ε.naturality (α.app X₁)
have eq₂ := G'.congr_map (hη X₁)
have eq₃ := α.naturality (adj.unit.app X₁)
dsimp at eq₁ eq₂ eq₃ ⊢
simp only [Functor.map_comp] at eq₂
rw [Category.assoc, Category.assoc, Category.assoc, Category.comp_id,
Category.id_comp, Category.id_comp, Category.id_comp, ← eq₁, reassoc_of% eq₂,
hε (G.obj X₁), reassoc_of% eq₃, ← L₂.map_comp, adj.left_triangle_components,
Functor.map_id, Category.comp_id]
right_triangle_components := by
suffices F'.leftUnitor.inv ≫ whiskerLeft F' η ≫ (Functor.associator _ _ _).inv ≫
whiskerRight ε F' ≫ F'.rightUnitor.hom = 𝟙 _ from
fun Y₂ ↦ by simpa using congr_app this Y₂
apply F'.rightDerived_ext β W₂
ext X₂
have eq₁ := η.naturality (β.app X₂)
have eq₂ := F'.congr_map (hε X₂)
have eq₃ := β.naturality (adj.counit.app X₂)
dsimp at eq₁ eq₂ eq₃ ⊢
simp only [Functor.map_comp] at eq₂
rw [Category.comp_id, Category.comp_id, Category.id_comp, Category.id_comp,
reassoc_of% eq₁, eq₂, reassoc_of% (hη (F.obj X₂)), ← eq₃, ← L₁.map_comp_assoc,
adj.right_triangle_components, Functor.map_id, Category.id_comp]
section
variable [(G' ⋙ F').IsLeftDerivedFunctor
((Functor.associator _ _ _).inv ≫ whiskerRight α F') W₁]
/-- The unit of the derived adjunction, see `Adjunction.derived`. -/
noncomputable def derivedη : 𝟭 D₁ ⟶ G' ⋙ F' :=
(G' ⋙ F').leftDerivedLift ((Functor.associator _ _ _).inv ≫ whiskerRight α F') W₁ _
(L₁.rightUnitor.hom ≫ L₁.leftUnitor.inv ≫ whiskerRight adj.unit L₁ ≫
(Functor.associator _ _ _).hom ≫ whiskerLeft G β ≫ (Functor.associator _ _ _).inv)
@[reassoc (attr := simp)]
lemma derivedη_fac_app (X₁ : C₁) :
(adj.derivedη W₁ α β).app (L₁.obj X₁) ≫ F'.map (α.app X₁) =
L₁.map (adj.unit.app X₁) ≫ β.app (G.obj X₁) := by
simpa using ((G' ⋙ F').leftDerived_fac_app ((Functor.associator _ _ _).inv ≫
whiskerRight α F') W₁ _ (L₁.rightUnitor.hom ≫ L₁.leftUnitor.inv ≫ whiskerRight adj.unit L₁ ≫
(Functor.associator _ _ _).hom ≫ whiskerLeft G β ≫ (Functor.associator _ _ _).inv)) X₁
end
section
variable [(F' ⋙ G').IsRightDerivedFunctor
(whiskerRight β G' ≫ (Functor.associator _ _ _).hom) W₂]
/-- The counit of the derived adjunction, see `Adjunction.derived`. -/
noncomputable def derivedε : F' ⋙ G' ⟶ 𝟭 D₂ :=
(F' ⋙ G').rightDerivedDesc (whiskerRight β G' ≫ (Functor.associator _ _ _).hom) W₂ _
((Functor.associator _ _ _).hom ≫ whiskerLeft F α ≫ (Functor.associator _ _ _).inv ≫
whiskerRight adj.counit _ ≫ L₂.leftUnitor.hom ≫ L₂.rightUnitor.inv)
@[reassoc (attr := simp)]
lemma derivedε_fac_app (X₂ : C₂) :
G'.map (β.app X₂) ≫ (adj.derivedε W₂ α β).app (L₂.obj X₂) =
α.app (F.obj X₂) ≫ L₂.map (adj.counit.app X₂) := by
simpa using ((F' ⋙ G').rightDerived_fac_app
(whiskerRight β G' ≫ (Functor.associator _ _ _).hom) W₂ _
((Functor.associator _ _ _).hom ≫ whiskerLeft F α ≫ (Functor.associator _ _ _).inv ≫
whiskerRight adj.counit _ ≫ L₂.leftUnitor.hom ≫ L₂.rightUnitor.inv)) X₂
end
/-- An adjunction between functors induces an adjunction between the
corresponding left/right derived functors, when these derived
functors are *absolute*, i.e. they remain derived functors
after the post-composition with any functor.
(One actually only needs that `G' ⋙ F'` is the left derived functor of
`G ⋙ L₂ ⋙ F'` and that `F' ⋙ G'` is the right derived functor of
`F ⋙ L₁ ⋙ G'`). -/
@[simps!]
noncomputable def derived [G'.IsLeftDerivedFunctor α W₁] [F'.IsRightDerivedFunctor β W₂]
[(G' ⋙ F').IsLeftDerivedFunctor
((Functor.associator _ _ _).inv ≫ whiskerRight α F') W₁]
[(F' ⋙ G').IsRightDerivedFunctor
(whiskerRight β G' ≫ (Functor.associator _ _ _).hom) W₂] : G' ⊣ F' :=
adj.derived' W₁ W₂ α β (adj.derivedη W₁ α β) (adj.derivedε W₂ α β)
end Adjunction
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Functor/KanExtension/Dense.lean | import Mathlib.CategoryTheory.Functor.KanExtension.DenseAt
import Mathlib.CategoryTheory.Limits.Presheaf
import Mathlib.CategoryTheory.Generator.StrongGenerator
/-!
# Dense functors
A functor `F : C ⥤ D` is dense (`F.IsDense`) if `𝟭 D` is a pointwise
left Kan extension of `F` along itself, i.e. any `Y : D` is the
colimit of all `F.obj X` for all morphisms `F.obj X ⟶ Y` (which
is the condition `F.DenseAt Y`).
When `F` is full, we show that this
is equivalent to saying that the restricted Yoneda functor
`D ⥤ Cᵒᵖ ⥤ Type _` is fully faithful (see the lemma
`Functor.isDense_iff_fullyFaithful_restrictedULiftYoneda`).
We also show that the range of a dense functor is a strong
generator (see `Functor.isStrongGenerator_of_isDense`).
## References
* https://ncatlab.org/nlab/show/dense+subcategory
-/
universe w v₁ v₂ u₁ u₂
namespace CategoryTheory
open Limits Opposite Presheaf
variable {C : Type u₁} {D : Type u₂} [Category.{v₁} C] [Category.{v₂} D]
namespace Functor
/-- A functor `F : C ⥤ D` is dense if any `Y : D` is a canonical colimit
relatively to `F`. -/
class IsDense (F : C ⥤ D) : Prop where
isDenseAt (F) (Y : D) : F.isDenseAt Y
/-- This is a choice of structure `F.DenseAt Y` when `F : C ⥤ D`
is dense, and `Y : D`. -/
noncomputable def denseAt (F : C ⥤ D) [F.IsDense] (Y : D) : F.DenseAt Y :=
(IsDense.isDenseAt F Y).some
lemma isDense_iff_nonempty_isPointwiseLeftKanExtension (F : C ⥤ D) :
F.IsDense ↔
Nonempty ((LeftExtension.mk _ (rightUnitor F).inv).IsPointwiseLeftKanExtension) :=
⟨fun _ ↦ ⟨fun _ ↦ F.denseAt _⟩, fun ⟨h⟩ ↦ ⟨fun _ ↦ ⟨h _⟩⟩⟩
variable (F : C ⥤ D)
instance [F.IsDense] : (restrictedULiftYoneda.{w} F).Faithful where
map_injective h :=
(F.denseAt _).hom_ext' (fun X p ↦ by
simpa using ULift.up_injective (congr_fun (NatTrans.congr_app h (op X)) (ULift.up p)))
instance [F.IsDense] : (restrictedULiftYoneda.{w} F).Full where
map_surjective {Y Z} f := by
let c : Cocone (CostructuredArrow.proj F Y ⋙ F) :=
{ pt := Z
ι :=
{ app g := ((f.app (op g.left)) (ULift.up g.hom)).down
naturality g₁ g₂ φ := by
simpa [uliftFunctor, uliftYoneda,
restrictedULiftYoneda, ← ULift.down_inj] using
(congr_fun (f.naturality φ.left.op) (ULift.up g₂.hom)).symm }}
refine ⟨(F.denseAt Y).desc c, ?_⟩
ext ⟨X⟩ ⟨x⟩
have := (F.denseAt Y).fac c (.mk x)
dsimp [c] at this
simpa using ULift.down_injective this
variable {F} in
lemma IsDense.of_fullyFaithful_restrictedULiftYoneda [F.Full]
(h : (restrictedULiftYoneda.{w} F).FullyFaithful) :
F.IsDense where
isDenseAt Y := by
let φ (s : Cocone (CostructuredArrow.proj F Y ⋙ F)) :
(restrictedULiftYoneda.{w} F).obj Y ⟶ (restrictedULiftYoneda F).obj s.pt :=
{ app := fun ⟨X⟩ ⟨x⟩ ↦ ULift.up (s.ι.app (.mk x))
naturality := by
rintro ⟨X₁⟩ ⟨X₂⟩ ⟨f⟩
ext ⟨x⟩
let α : CostructuredArrow.mk (F.map f ≫ x) ⟶ CostructuredArrow.mk x :=
CostructuredArrow.homMk f
simp [uliftYoneda, ← s.w α, α] }
have hφ (s) (j) : (restrictedULiftYoneda F).map j.hom ≫ φ s =
(restrictedULiftYoneda F).map (s.ι.app j) := by
ext ⟨X⟩ ⟨x⟩
let α : .mk (x ≫ j.hom) ⟶ j := CostructuredArrow.homMk (F.preimage x)
have := s.w α
dsimp [uliftYoneda, φ, α] at this ⊢
rw [← this, map_preimage]
exact
⟨{desc s := (h.preimage (φ s))
fac s j := h.map_injective (by simp [hφ])
uniq s m hm := h.map_injective (by
ext ⟨X⟩ ⟨x⟩
simp [uliftYoneda, φ, ← hm])}⟩
lemma isDense_iff_fullyFaithful_restrictedULiftYoneda [F.Full] :
F.IsDense ↔ Nonempty (restrictedULiftYoneda.{w} F).FullyFaithful :=
⟨fun _ ↦ ⟨FullyFaithful.ofFullyFaithful _⟩,
fun ⟨h⟩ ↦ IsDense.of_fullyFaithful_restrictedULiftYoneda h⟩
open ObjectProperty in
lemma isStrongGenerator_of_isDense [F.IsDense] :
IsStrongGenerator (.ofObj F.obj) :=
(IsStrongGenerator.mk_of_exists_colimitsOfShape.{max u₁ u₂ v₁ v₂,
max u₁ v₁ v₂} (fun Y ↦ ⟨_, _, ⟨{
ι := _
diag := _
isColimit := (IsColimit.whiskerEquivalence (F.denseAt Y)
((ShrinkHoms.equivalence _).symm.trans ((Shrink.equivalence _)).symm))
prop_diag_obj := by simp }⟩⟩))
end Functor
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Functor/KanExtension/Preserves.lean | import Mathlib.CategoryTheory.Functor.KanExtension.Adjunction
import Mathlib.CategoryTheory.Limits.Preserves.Basic
/-!
# Preservation of Kan extensions
Given functors `F : A ⥤ B`, `L : B ⥤ C`, and `G : B ⥤ D`,
we introduce a typeclass `G.PreservesLeftKanExtension F L` which encodes the fact that
the left Kan extension of `F` along `L` is preserved by the functor `G`.
When the Kan extension is pointwise, it suffices that `G` preserves (co)limits of the relevant
diagrams.
We introduce the dual typeclass `G.PreservesRightKanExtension`.
-/
namespace CategoryTheory.Functor
variable {A B C D : Type*} [Category A] [Category B] [Category C] [Category D]
(G : B ⥤ D) (F : A ⥤ B) (L : A ⥤ C)
noncomputable section
section LeftKanExtension
/-- `G.PreservesLeftKanExtension F L` asserts that `G` preserves all left Kan extensions
of `F` along `L`. See `PreservesLeftKanExtension.mk_of_preserves_isLeftKanExtension` for a
constructor taking a single left Kan extension as input. -/
class PreservesLeftKanExtension where
preserves : ∀ (F' : C ⥤ B) (α : F ⟶ L ⋙ F') [IsLeftKanExtension F' α],
IsLeftKanExtension (F' ⋙ G) <| whiskerRight α G ≫ (Functor.associator _ _ _).hom
/-- Alternative constructor for `PreservesLeftKanExtension`, phrased in terms of
`LeftExtension.IsUniversal` instead. See `PreservesLeftKanExtension.mk_of_preserves_isUniversal`
for a similar constructor taking as input a single `LeftExtension`. -/
lemma PreservesLeftKanExtension.mk'
(preserves : ∀ {E : LeftExtension L F}, E.IsUniversal →
Nonempty (LeftExtension.postcompose₂ L F G |>.obj E).IsUniversal) :
G.PreservesLeftKanExtension F L where
preserves _ _ h :=
⟨⟨Limits.IsInitial.equivOfIso
(LeftExtension.postcompose₂ObjMkIso _ _) <| (preserves h.nonempty_isUniversal.some).some⟩⟩
/-- Show that `G` preserves left Kan extensions if it maps some left Kan extension to a left
Kan extension. -/
lemma PreservesLeftKanExtension.mk_of_preserves_isLeftKanExtension
(F' : C ⥤ B) (α : F ⟶ L ⋙ F') [IsLeftKanExtension F' α]
(h : IsLeftKanExtension (F' ⋙ G) <| whiskerRight α G ≫ (Functor.associator _ _ _).hom) :
G.PreservesLeftKanExtension F L :=
.mk fun F'' α' h ↦
isLeftKanExtension_of_iso
(isoWhiskerRight (leftKanExtensionUnique F' α F'' α') G)
(whiskerRight α G ≫ (Functor.associator _ _ _).hom)
(whiskerRight α' G ≫ (Functor.associator _ _ _).hom)
(by ext x; simp [← G.map_comp])
/-- Show that `G` preserves left Kan extensions if it maps some left Kan extension to a left
Kan extension, phrased in terms of `IsUniversal`. -/
lemma PreservesLeftKanExtension.mk_of_preserves_isUniversal (E : LeftExtension L F)
(hE : E.IsUniversal) (h : Nonempty (LeftExtension.postcompose₂ L F G |>.obj E).IsUniversal) :
G.PreservesLeftKanExtension F L :=
.mk' G F L fun hE' ↦
⟨Limits.IsInitial.equivOfIso
(LeftExtension.postcompose₂ L F G|>.mapIso <| Limits.IsInitial.uniqueUpToIso hE hE') h.some⟩
attribute [instance] PreservesLeftKanExtension.preserves
/-- `G.PreservesLeftKanExtensionAt F L c` asserts that `G` preserves all pointwise left Kan
extensions of `F` along `L` at the point `c`. -/
class PreservesPointwiseLeftKanExtensionAt (c : C) where
/-- `G` preserves every pointwise extensions of `F` along `L` at `c`. -/
preserves : ∀ (E : LeftExtension L F), E.IsPointwiseLeftKanExtensionAt c →
Nonempty ((LeftExtension.postcompose₂ L F G |>.obj E).IsPointwiseLeftKanExtensionAt c)
/-- `G.PreservesLeftKanExtension F L` asserts that `G` preserves all pointwise left Kan extensions
of `F` along `L`. -/
abbrev PreservesPointwiseLeftKanExtension := ∀ c : C, PreservesPointwiseLeftKanExtensionAt G F L c
variable {F L} in
/-- Given a pointwise left Kan extension of `F` along `L` at `c`, exhibits
`(LeftExtension.whiskerRight L F G).obj E` as a pointwise left Kan extension of `F ⋙ G` along
`L` at `c`. -/
def LeftExtension.IsPointwiseLeftKanExtensionAt.postcompose {c : C}
[PreservesPointwiseLeftKanExtensionAt G F L c]
{E : LeftExtension L F} (hE : E.IsPointwiseLeftKanExtensionAt c) :
LeftExtension.postcompose₂ L F G |>.obj E |>.IsPointwiseLeftKanExtensionAt c :=
PreservesPointwiseLeftKanExtensionAt.preserves E hE |>.some
variable {F L} in
/-- Given a pointwise left Kan extension of `F` along `L`, exhibits
`(LeftExtension.whiskerRight L F G).obj E` as a pointwise left Kan extension of `F ⋙ G` along
`L`. -/
def LeftExtension.IsPointwiseLeftKanExtension.postcompose
[PreservesPointwiseLeftKanExtension G F L]
{E : LeftExtension L F} (hE : E.IsPointwiseLeftKanExtension) :
LeftExtension.postcompose₂ L F G |>.obj E |>.IsPointwiseLeftKanExtension := fun c ↦
(hE c).postcompose G
/-- The cocone at a point of the whiskering right by `G`of an extension is isomorphic to the
action of `G` on the cocone at that point for the original extension. -/
@[simps!]
def LeftExtension.coconeAtWhiskerRightIso (E : LeftExtension L F) (c : C) :
(LeftExtension.postcompose₂ L F G |>.obj E).coconeAt c ≅ G.mapCocone (E.coconeAt c) :=
Limits.Cocones.ext (Iso.refl _)
/-- If `G` preserves any pointwise left Kan extension of `F` along `L` at `c`, then it preserves
all of them. -/
lemma PreservesPointwiseLeftKanExtensionAt.mk' (c : C) {E : LeftExtension L F}
(hE : E.IsPointwiseLeftKanExtensionAt c)
(hGE : (LeftExtension.postcompose₂ L F G |>.obj E).IsPointwiseLeftKanExtensionAt c) :
G.PreservesPointwiseLeftKanExtensionAt F L c where
preserves E' hE' :=
⟨Limits.IsColimit.ofIsoColimit hGE <|
(E.coconeAtWhiskerRightIso G F L c) ≪≫
(Limits.Cocones.functoriality _ _).mapIso (hE.uniqueUpToIso hE') ≪≫
(E'.coconeAtWhiskerRightIso G F L c).symm⟩
instance hasLeftKanExtension_of_preserves [L.HasLeftKanExtension F]
[PreservesLeftKanExtension G F L] : L.HasLeftKanExtension (F ⋙ G) :=
@HasLeftKanExtension.mk _ _ _ _ _ _ _ _ _ _ <|
letI : (L.leftKanExtension F).IsLeftKanExtension <| L.leftKanExtensionUnit F := by
infer_instance
PreservesLeftKanExtension.preserves (L.leftKanExtension F) (L.leftKanExtensionUnit F)
instance hasPointwiseLeftKanExtension_of_preserves [L.HasPointwiseLeftKanExtension F]
[PreservesPointwiseLeftKanExtension G F L] : L.HasPointwiseLeftKanExtension (F ⋙ G) :=
(pointwiseLeftKanExtensionIsPointwiseLeftKanExtension
L F |>.postcompose G).hasPointwiseLeftKanExtension
/-- Extract an isomorphism `(leftKanExtension L F) ⋙ G ≅ leftKanExtension L (F ⋙ G)` when `G`
preserves left Kan extensions. -/
def leftKanExtensionCompIsoOfPreserves [PreservesLeftKanExtension G F L]
[L.HasLeftKanExtension F] :
L.leftKanExtension F ⋙ G ≅ L.leftKanExtension (F ⋙ G) :=
leftKanExtensionUnique
(L.leftKanExtension F ⋙ G)
(whiskerRight (L.leftKanExtensionUnit F) G ≫ (Functor.associator _ _ _).hom)
(L.leftKanExtension <| F ⋙ G)
(L.leftKanExtensionUnit <| F ⋙ G)
section
variable [PreservesLeftKanExtension G F L] [L.HasLeftKanExtension F]
@[reassoc (attr := simp)]
lemma leftKanExtensionCompIsoOfPreserves_hom_fac :
whiskerRight (L.leftKanExtensionUnit F) G ≫ (Functor.associator _ _ _).hom ≫
whiskerLeft L (leftKanExtensionCompIsoOfPreserves G F L).hom =
(L.leftKanExtensionUnit <| F ⋙ G) := by
simpa [leftKanExtensionCompIsoOfPreserves] using
descOfIsLeftKanExtension_fac
(α := whiskerRight (L.leftKanExtensionUnit F) G ≫ (Functor.associator _ _ _).hom)
(β := L.leftKanExtensionUnit (F ⋙ G))
@[reassoc (attr := simp)]
lemma leftKanExtensionCompIsoOfPreserves_hom_fac_app (a : A) :
G.map ((L.leftKanExtensionUnit F).app a) ≫
(G.leftKanExtensionCompIsoOfPreserves F L).hom.app (L.obj a) =
(L.leftKanExtensionUnit (F ⋙ G)).app a := by
simpa [-leftKanExtensionCompIsoOfPreserves_hom_fac] using
NatTrans.congr_app (leftKanExtensionCompIsoOfPreserves_hom_fac G F L) a
@[reassoc (attr := simp)]
lemma leftKanExtensionCompIsoOfPreserves_inv_fac :
(L.leftKanExtensionUnit <| F ⋙ G) ≫
whiskerLeft L (leftKanExtensionCompIsoOfPreserves G F L).inv =
whiskerRight (L.leftKanExtensionUnit F) G ≫ (Functor.associator _ _ _).hom := by
simp [leftKanExtensionCompIsoOfPreserves]
@[reassoc (attr := simp)]
lemma leftKanExtensionCompIsoOfPreserves_inv_fac_app (a : A) :
(L.leftKanExtensionUnit (F ⋙ G)).app a ≫
(G.leftKanExtensionCompIsoOfPreserves F L).inv.app (L.obj a) =
G.map ((L.leftKanExtensionUnit F).app a) := by
simpa [-leftKanExtensionCompIsoOfPreserves_inv_fac] using
NatTrans.congr_app (leftKanExtensionCompIsoOfPreserves_inv_fac G F L) a
end
/-- A functor that preserves the colimit of `CostructuredArrow.proj L c ⋙ F` preserves
the pointwise left Kan extension of `F` along `L` at `c`. -/
instance preservesPointwiseLeftKanExtensionAtOfPreservesColimit (c : C)
[Limits.PreservesColimit (CostructuredArrow.proj L c ⋙ F) G] :
G.PreservesPointwiseLeftKanExtensionAt F L c where
preserves E p :=
⟨Limits.IsColimit.ofIsoColimit
(Limits.PreservesColimit.preserves p).some
(E.coconeAtWhiskerRightIso G _ _ c).symm⟩
/-- If there is a pointwise left Kan extension of `F` along `L`, and if `G` preserves them,
then `G` preserves left Kan extensions of `F` along `L`. -/
instance preservesPointwiseLKEOfHasPointwiseAndPreservesPointwise
[HasPointwiseLeftKanExtension L F] [G.PreservesPointwiseLeftKanExtension F L] :
G.PreservesLeftKanExtension F L where
preserves F' α _ :=
(LeftExtension.isPointwiseLeftKanExtensionEquivOfIso (LeftExtension.postcompose₂ObjMkIso G α) <|
(isPointwiseLeftKanExtensionOfIsLeftKanExtension F' α).postcompose G).isLeftKanExtension
/-- Extract an isomorphism
`(pointwiseLeftKanExtension L F) ⋙ G ≅ pointwiseLeftKanExtension L (F ⋙ G)` when `G` preserves
left Kan extensions. -/
def pointwiseLeftKanExtensionCompIsoOfPreserves
[PreservesPointwiseLeftKanExtension G F L]
[L.HasPointwiseLeftKanExtension F] :
L.pointwiseLeftKanExtension F ⋙ G ≅ L.pointwiseLeftKanExtension (F ⋙ G) :=
leftKanExtensionUnique
(L.pointwiseLeftKanExtension F ⋙ G)
(whiskerRight (L.pointwiseLeftKanExtensionUnit F) G ≫ (Functor.associator _ _ _).hom)
(L.pointwiseLeftKanExtension <| F ⋙ G)
(L.pointwiseLeftKanExtensionUnit <| F ⋙ G)
section
variable [PreservesPointwiseLeftKanExtension G F L] [L.HasPointwiseLeftKanExtension F]
@[reassoc (attr := simp)]
lemma pointwiseLeftKanExtensionCompIsoOfPreserves_hom_fac :
whiskerRight (L.pointwiseLeftKanExtensionUnit F) G ≫ (Functor.associator _ _ _).hom ≫
whiskerLeft L (pointwiseLeftKanExtensionCompIsoOfPreserves G F L).hom =
(L.pointwiseLeftKanExtensionUnit <| F ⋙ G) := by
simpa [pointwiseLeftKanExtensionCompIsoOfPreserves] using
descOfIsLeftKanExtension_fac
(α := whiskerRight (L.pointwiseLeftKanExtensionUnit F) G ≫ (Functor.associator _ _ _).hom)
(β := L.pointwiseLeftKanExtensionUnit <| F ⋙ G)
@[reassoc]
lemma pointwiseLeftKanExtensionCompIsoOfPreserves_hom_fac_app (a : A) :
G.map ((L.pointwiseLeftKanExtensionUnit F).app a) ≫
(G.pointwiseLeftKanExtensionCompIsoOfPreserves F L).hom.app (L.obj a) =
(L.pointwiseLeftKanExtensionUnit <| F ⋙ G).app a := by
simpa [-pointwiseLeftKanExtensionCompIsoOfPreserves_hom_fac] using
NatTrans.congr_app (pointwiseLeftKanExtensionCompIsoOfPreserves_hom_fac G F L) a
@[reassoc (attr := simp)]
lemma pointwiseLeftKanExtensionCompIsoOfPreserves_inv_fac :
(L.pointwiseLeftKanExtensionUnit <| F ⋙ G) ≫
whiskerLeft L (pointwiseLeftKanExtensionCompIsoOfPreserves G F L).inv =
whiskerRight (L.pointwiseLeftKanExtensionUnit F) G ≫ (Functor.associator _ _ _).hom := by
simp [pointwiseLeftKanExtensionCompIsoOfPreserves]
@[reassoc]
lemma pointwiseLeftKanExtensionCompIsoOfPreserves_fac_app (a : A) :
(L.pointwiseLeftKanExtensionUnit <| F ⋙ G).app a ≫
(G.pointwiseLeftKanExtensionCompIsoOfPreserves F L).inv.app (L.obj a) =
G.map (L.pointwiseLeftKanExtensionUnit F |>.app a) := by
simpa [-pointwiseLeftKanExtensionCompIsoOfPreserves_inv_fac] using
NatTrans.congr_app (pointwiseLeftKanExtensionCompIsoOfPreserves_inv_fac G F L) a
end
/-- `G.PreservesLeftKanExtensions L` means that `G : B ⥤ D` preserves all left Kan extensions along
`L : A ⥤ C` of every functor `A ⥤ B`. -/
abbrev PreservesLeftKanExtensions := ∀ (F : A ⥤ B), G.PreservesLeftKanExtension F L
/-- `G.PreservesPointwiseLeftKanExtensions L` means that `G : B ⥤ D` preserves all pointwise left
Kan extensions along `L : A ⥤ C` of every functor `A ⥤ B`. -/
abbrev PreservesPointwiseLeftKanExtensions :=
∀ (F : A ⥤ B), G.PreservesPointwiseLeftKanExtension F L
/-- Commuting a functor that preserves left Kan extensions with the `lan` functor. -/
@[simps!]
def lanCompIsoOfPreserves [G.PreservesLeftKanExtensions L]
[∀ F : A ⥤ B, HasLeftKanExtension L F]
[∀ F : A ⥤ D, HasLeftKanExtension L F] :
L.lan ⋙ (whiskeringRight _ _ _).obj G ≅ (whiskeringRight _ _ _).obj G ⋙ L.lan :=
NatIso.ofComponents (fun F ↦ leftKanExtensionCompIsoOfPreserves _ _ _)
(fun {F F'} η ↦ by
apply hom_ext_of_isLeftKanExtension (L.leftKanExtension F ⋙ G)
(whiskerRight (L.leftKanExtensionUnit F) G ≫ (Functor.associator _ _ _).hom)
dsimp [lan]
ext
simp [← G.map_comp_assoc])
end LeftKanExtension
section RightKanExtension
/-- `G.PreservesRightKanExtension F L` asserts that `G` preserves all right Kan extensions
of `F` along `L`. See `PreservesRightKanExtension.mk_of_preserves_isRightKanExtension` for a
constructor taking a single right Kan extension as input. -/
class PreservesRightKanExtension where
preserves : ∀ (F' : C ⥤ B) (α : L ⋙ F' ⟶ F) [IsRightKanExtension F' α],
IsRightKanExtension (F' ⋙ G) <| (Functor.associator _ _ _).inv ≫ whiskerRight α G
/-- Alternative constructor for `PreservesRightKanExtension`, phrased in terms of
`RightExtension.IsUniversal` instead. See `PreservesRightKanExtension.mk_of_preserves_isUniversal`
for a similar constructor taking as input a single `RightExtension`. -/
lemma PreservesRightKanExtension.mk'
(preserves : ∀ {E : RightExtension L F}, E.IsUniversal →
Nonempty (RightExtension.postcompose₂ L F G |>.obj E).IsUniversal) :
G.PreservesRightKanExtension F L where
preserves _ _ h :=
⟨⟨Limits.IsTerminal.equivOfIso
(RightExtension.postcompose₂ObjMkIso _ _) <| (preserves h.nonempty_isUniversal.some).some⟩⟩
/-- Show that `G` preserves right Kan extensions if it maps some right Kan extension to a right
Kan extension. -/
lemma PreservesRightKanExtension.mk_of_preserves_isRightKanExtension
(F' : C ⥤ B) (α : L ⋙ F' ⟶ F) [IsRightKanExtension F' α]
(h : IsRightKanExtension (F' ⋙ G) <| (Functor.associator _ _ _).inv ≫ whiskerRight α G) :
G.PreservesRightKanExtension F L :=
.mk fun F'' α' h ↦
isRightKanExtension_of_iso
(isoWhiskerRight (rightKanExtensionUnique F' α F'' α') G)
((Functor.associator _ _ _).inv ≫ whiskerRight α G)
((Functor.associator _ _ _).inv ≫ whiskerRight α' G)
(by ext x; simp [← G.map_comp])
/-- Show that `G` preserves right Kan extensions if it maps some right Kan extension to a left
Kan extension, phrased in terms of `IsUniversal`. -/
lemma PreservesRightKanExtension.mk_of_preserves_isUniversal (E : RightExtension L F)
(hE : E.IsUniversal) (h : Nonempty (RightExtension.postcompose₂ L F G |>.obj E).IsUniversal) :
G.PreservesRightKanExtension F L :=
.mk' G F L fun hE' ↦
⟨Limits.IsTerminal.equivOfIso
(RightExtension.postcompose₂ L F G |>.mapIso
<| Limits.IsTerminal.uniqueUpToIso hE hE') h.some⟩
attribute [instance] PreservesRightKanExtension.preserves
/-- `G.PreservesRightKanExtensionAt F L c` asserts that `G` preserves all right pointwise right Kan
extensions of `F` along `L` at `c`. -/
class PreservesPointwiseRightKanExtensionAt (c : C) where
/-- `G` preserves every pointwise extensions of `F` along `L` at `c`. -/
preserves : ∀ (E : RightExtension L F), E.IsPointwiseRightKanExtensionAt c →
Nonempty ((RightExtension.postcompose₂ L F G |>.obj E).IsPointwiseRightKanExtensionAt c)
/-- `G.PreservesRightKanExtensions L` asserts that `G` preserves all pointwise right Kan
extensions of `F` along `L` for every `F`. -/
abbrev PreservesPointwiseRightKanExtension := ∀ c : C, PreservesPointwiseRightKanExtensionAt G F L c
variable {F L} in
/-- Given a pointwise right Kan extension of `F` along `L` at `c`, exhibits
`(RightExtension.whiskerRight L F G).obj E` as a pointwise right Kan extension of `F ⋙ G` along
`L` at `c`. -/
def RightExtension.IsPointwiseRightKanExtensionAt.postcompose {c : C}
[PreservesPointwiseRightKanExtensionAt G F L c]
{E : RightExtension L F} (hE : E.IsPointwiseRightKanExtensionAt c) :
RightExtension.postcompose₂ L F G |>.obj E |>.IsPointwiseRightKanExtensionAt c :=
PreservesPointwiseRightKanExtensionAt.preserves E hE |>.some
variable {F L} in
/-- Given a pointwise right Kan extension of `F` along `L`, exhibits
`(RightExtension.whiskerRight L F G).obj E` as a pointwise right Kan extension of `F ⋙ G` at `L`. -/
def RightExtension.IsPointwiseRightKanExtension.postcompose
[PreservesPointwiseRightKanExtension G F L]
{E : RightExtension L F} (hE : E.IsPointwiseRightKanExtension) :
RightExtension.postcompose₂ L F G |>.obj E |>.IsPointwiseRightKanExtension := fun c ↦
(hE c).postcompose G
/-- The cone at a point of the whiskering right by `G`of an extension is isomorphic to the
action of `G` on the cone at that point for the original extension. -/
@[simps!]
def RightExtension.coneAtWhiskerRightIso (E : RightExtension L F) (c : C) :
(RightExtension.postcompose₂ L F G |>.obj E).coneAt c ≅ G.mapCone (E.coneAt c) :=
Limits.Cones.ext (Iso.refl _)
/-- If `G` preserves any pointwise right Kan extension of `F` along `L` at `c`, then it preserves
all of them. -/
lemma PreservesPointwiseRightKanExtensionAt.mk' (c : C) {E : RightExtension L F}
(hE : E.IsPointwiseRightKanExtensionAt c)
(hGE : (RightExtension.postcompose₂ L F G |>.obj E).IsPointwiseRightKanExtensionAt c) :
G.PreservesPointwiseRightKanExtensionAt F L c where
preserves E' hE' :=
⟨Limits.IsLimit.ofIsoLimit hGE <|
(E.coneAtWhiskerRightIso G F L c) ≪≫
(Limits.Cones.functoriality _ _).mapIso (hE.uniqueUpToIso hE') ≪≫
(E'.coneAtWhiskerRightIso G F L c).symm⟩
instance hasRightKanExtension_of_preserves [L.HasRightKanExtension F]
[PreservesRightKanExtension G F L] : L.HasRightKanExtension (F ⋙ G) :=
@HasRightKanExtension.mk _ _ _ _ _ _ _ _ _ _ <|
letI : (L.rightKanExtension F).IsRightKanExtension <| L.rightKanExtensionCounit F := by
infer_instance
PreservesRightKanExtension.preserves (L.rightKanExtension F) (L.rightKanExtensionCounit F)
instance hasPointwiseRightKanExtension_of_preserves [L.HasPointwiseRightKanExtension F]
[PreservesPointwiseRightKanExtension G F L] : L.HasPointwiseRightKanExtension (F ⋙ G) :=
(pointwiseRightKanExtensionIsPointwiseRightKanExtension
L F |>.postcompose G).hasPointwiseRightKanExtension
/-- Extract an isomorphism `rightKanExtension L F ⋙ G ≅ rightKanExtension L (F ⋙ G)` when `G`
preserves right Kan extensions. -/
def rightKanExtensionCompIsoOfPreserves [PreservesRightKanExtension G F L]
[L.HasRightKanExtension F] :
L.rightKanExtension F ⋙ G ≅ L.rightKanExtension (F ⋙ G) :=
rightKanExtensionUnique
(L.rightKanExtension F ⋙ G)
((Functor.associator _ _ _).inv ≫ whiskerRight (L.rightKanExtensionCounit F) G)
(L.rightKanExtension <| F ⋙ G)
(L.rightKanExtensionCounit <| F ⋙ G)
section
variable [PreservesRightKanExtension G F L] [L.HasRightKanExtension F]
@[reassoc (attr := simp)]
lemma rightKanExtensionCompIsoOfPreserves_hom_fac :
whiskerLeft L (rightKanExtensionCompIsoOfPreserves G F L).hom ≫
(L.rightKanExtensionCounit <| F ⋙ G) =
(Functor.associator _ _ _).inv ≫ whiskerRight (L.rightKanExtensionCounit F) G := by
simp [rightKanExtensionCompIsoOfPreserves]
@[reassoc (attr := simp)]
lemma rightKanExtensionCompIsoOfPreserves_hom_fac_app (a : A) :
(G.rightKanExtensionCompIsoOfPreserves F L).hom.app (L.obj a) ≫
(L.rightKanExtensionCounit (F ⋙ G)).app a =
G.map (L.rightKanExtensionCounit F |>.app a) := by
simp [rightKanExtensionCompIsoOfPreserves]
@[reassoc (attr := simp)]
lemma rightKanExtensionCompIsoOfPreserves_inv_fac :
whiskerLeft L (rightKanExtensionCompIsoOfPreserves G F L).inv ≫
((Functor.associator _ _ _).inv ≫ whiskerRight (L.rightKanExtensionCounit F) G) =
(L.rightKanExtensionCounit <| F ⋙ G) := by
simp [rightKanExtensionCompIsoOfPreserves]
@[reassoc (attr := simp)]
lemma rightKanExtensionCompIsoOfPreserves_inv_fac_app (a : A) :
(G.rightKanExtensionCompIsoOfPreserves F L).inv.app (L.obj a) ≫
G.map (L.rightKanExtensionCounit F |>.app a) =
(L.rightKanExtensionCounit (F ⋙ G)).app a := by
simpa [-rightKanExtensionCompIsoOfPreserves_inv_fac] using
NatTrans.congr_app (rightKanExtensionCompIsoOfPreserves_inv_fac G F L) a
end
/-- A functor that preserves the limit of `(StructuredArrow.proj L c ⋙ F)` preserves
the pointwise right Kan extension of `F` along `L` at c. -/
instance preservesPointwiseRightKanExtensionAtOfPreservesLimit (c : C)
[Limits.PreservesLimit (StructuredArrow.proj c L ⋙ F) G] :
G.PreservesPointwiseRightKanExtensionAt F L c where
preserves E p :=
⟨Limits.IsLimit.ofIsoLimit
(Limits.PreservesLimit.preserves p).some
(E.coneAtWhiskerRightIso G _ _ c).symm⟩
/-- If there is a pointwise right Kan extension of `F` along `L`, and if `G` preserves them,
then `G` preserves right Kan extensions of `F` along `L`. -/
instance preservesPointwiseRKEOfHasPointwiseAndPreservesPointwise
[HasPointwiseRightKanExtension L F] [G.PreservesPointwiseRightKanExtension F L] :
G.PreservesRightKanExtension F L where
preserves F' α _ :=
(RightExtension.isPointwiseRightKanExtensionEquivOfIso
(RightExtension.postcompose₂ObjMkIso G α) <|
(isPointwiseRightKanExtensionOfIsRightKanExtension F' α).postcompose G).isRightKanExtension
/-- Extract an isomorphism
`L.pointwiseRightKanExtension F ⋙ G ≅ L.pointwiseRightKanExtension (F ⋙ G)` when `G` preserves
right Kan extensions. -/
def pointwiseRightKanExtensionCompIsoOfPreserves
[PreservesPointwiseRightKanExtension G F L]
[L.HasPointwiseRightKanExtension F] :
L.pointwiseRightKanExtension F ⋙ G ≅ L.pointwiseRightKanExtension (F ⋙ G) :=
rightKanExtensionUnique
(L.pointwiseRightKanExtension F ⋙ G)
((Functor.associator _ _ _).inv ≫ whiskerRight (L.pointwiseRightKanExtensionCounit F) G)
(L.pointwiseRightKanExtension <| F ⋙ G)
(L.pointwiseRightKanExtensionCounit <| F ⋙ G)
section
variable [PreservesPointwiseRightKanExtension G F L]
[L.HasPointwiseRightKanExtension F]
@[reassoc (attr := simp)]
lemma pointwiseRightKanExtensionCompIsoOfPreserves_hom_fac :
whiskerLeft L (pointwiseRightKanExtensionCompIsoOfPreserves G F L).hom ≫
(L.pointwiseRightKanExtensionCounit <| F ⋙ G) =
(Functor.associator _ _ _).inv ≫ whiskerRight (L.pointwiseRightKanExtensionCounit F) G := by
simp [pointwiseRightKanExtensionCompIsoOfPreserves]
@[reassoc]
lemma pointwiseRightKanExtensionCompIsoOfPreserves_hom_fac_app (a : A) :
(G.pointwiseRightKanExtensionCompIsoOfPreserves F L).hom.app (L.obj a) ≫
(L.pointwiseRightKanExtensionCounit <| F ⋙ G).app a =
G.map (L.pointwiseRightKanExtensionCounit F |>.app a) := by
simpa [-pointwiseRightKanExtensionCompIsoOfPreserves_hom_fac] using
NatTrans.congr_app (pointwiseRightKanExtensionCompIsoOfPreserves_hom_fac G F L) a
@[reassoc (attr := simp)]
lemma pointwiseRightKanExtensionCompIsoOfPreserves_inv_fac :
whiskerLeft L (pointwiseRightKanExtensionCompIsoOfPreserves G F L).inv ≫
(Functor.associator _ _ _).inv ≫ whiskerRight (L.pointwiseRightKanExtensionCounit F) G =
(L.pointwiseRightKanExtensionCounit <| F ⋙ G) := by
simp [pointwiseRightKanExtensionCompIsoOfPreserves]
@[reassoc]
lemma pointwiseRightKanExtensionCompIsoOfPreserves_inv_fac_app (a : A) :
(G.pointwiseRightKanExtensionCompIsoOfPreserves F L).inv.app (L.obj a) ≫
G.map (L.pointwiseRightKanExtensionCounit F |>.app a) =
(L.pointwiseRightKanExtensionCounit <| F ⋙ G).app a := by
simpa [-pointwiseRightKanExtensionCompIsoOfPreserves_inv_fac] using
NatTrans.congr_app (pointwiseRightKanExtensionCompIsoOfPreserves_inv_fac G F L) a
end
/-- `G.PreservesRightKanExtensions L` means that `G : B ⥤ D` preserves all right Kan extensions
along `L : A ⥤ C` of every functor `A ⥤ B`. -/
abbrev PreservesRightKanExtensions := ∀ (F : A ⥤ B), G.PreservesRightKanExtension F L
/-- `G.PreservesPointwiseRightKanExtensions L` means that `G : B ⥤ D` preserves all pointwise right
Kan extensions along `L : A ⥤ C` of every functor `A ⥤ B`. -/
abbrev PreservesPointwiseRightKanExtensions :=
∀ (F : A ⥤ B), G.PreservesPointwiseRightKanExtension F L
/-- Commuting a functor that preserves right Kan extensions with the `ran` functor. -/
@[simps!]
def ranCompIsoOfPreserves [G.PreservesRightKanExtensions L]
[∀ F : A ⥤ B, HasRightKanExtension L F] [∀ F : A ⥤ D, HasRightKanExtension L F] :
L.ran ⋙ (whiskeringRight _ _ _).obj G ≅ (whiskeringRight _ _ _).obj G ⋙ L.ran :=
NatIso.ofComponents (fun F ↦ rightKanExtensionCompIsoOfPreserves _ _ _)
(fun {F F'} η ↦ by
apply hom_ext_of_isRightKanExtension
(L.rightKanExtension <| F' ⋙ G)
(L.rightKanExtensionCounit <| F' ⋙ G)
dsimp [ran]
ext
simp only [comp_obj, Category.assoc, rightKanExtensionCompIsoOfPreserves_hom_fac,
NatTrans.comp_app, whiskerLeft_app, whiskerRight_app, associator_inv_app, Category.id_comp,
liftOfIsRightKanExtension_fac, rightKanExtensionCompIsoOfPreserves_hom_fac_assoc,
← G.map_comp]
simp)
end RightKanExtension
end
end CategoryTheory.Functor |
.lake/packages/mathlib/Mathlib/CategoryTheory/Functor/KanExtension/Pointwise.lean | import Mathlib.CategoryTheory.Functor.KanExtension.Basic
/-!
# Pointwise Kan extensions
In this file, we define the notion of pointwise (left) Kan extension. Given two functors
`L : C ⥤ D` and `F : C ⥤ H`, and `E : LeftExtension L F`, we introduce a cocone
`E.coconeAt Y` for the functor `CostructuredArrow.proj L Y ⋙ F : CostructuredArrow L Y ⥤ H`
the point of which is `E.right.obj Y`, and the type `E.IsPointwiseLeftKanExtensionAt Y`
which expresses that `E.coconeAt Y` is colimit. When this holds for all `Y : D`,
we may say that `E` is a pointwise left Kan extension (`E.IsPointwiseLeftKanExtension`).
Conversely, when `CostructuredArrow.proj L Y ⋙ F` has a colimit, we say that
`F` has a pointwise left Kan extension at `Y : D` (`HasPointwiseLeftKanExtensionAt L F Y`),
and if this holds for all `Y : D`, we construct a functor
`pointwiseLeftKanExtension L F : D ⥤ H` and show it is a pointwise Kan extension.
A dual API for pointwise right Kan extension is also formalized.
## References
* https://ncatlab.org/nlab/show/Kan+extension
-/
namespace CategoryTheory
open Category Limits
namespace Functor
variable {C D D' H : Type*} [Category C] [Category D] [Category D'] [Category H]
(L : C ⥤ D) (L' : C ⥤ D') (F : C ⥤ H)
/-- The condition that a functor `F` has a pointwise left Kan extension along `L` at `Y`.
It means that the functor `CostructuredArrow.proj L Y ⋙ F : CostructuredArrow L Y ⥤ H`
has a colimit. -/
abbrev HasPointwiseLeftKanExtensionAt (Y : D) :=
HasColimit (CostructuredArrow.proj L Y ⋙ F)
/-- The condition that a functor `F` has a pointwise left Kan extension along `L`: it means
that it has a pointwise left Kan extension at any object. -/
abbrev HasPointwiseLeftKanExtension := ∀ (Y : D), HasPointwiseLeftKanExtensionAt L F Y
/-- The condition that a functor `F` has a pointwise right Kan extension along `L` at `Y`.
It means that the functor `StructuredArrow.proj Y L ⋙ F : StructuredArrow Y L ⥤ H`
has a limit. -/
abbrev HasPointwiseRightKanExtensionAt (Y : D) :=
HasLimit (StructuredArrow.proj Y L ⋙ F)
/-- The condition that a functor `F` has a pointwise right Kan extension along `L`: it means
that it has a pointwise right Kan extension at any object. -/
abbrev HasPointwiseRightKanExtension := ∀ (Y : D), HasPointwiseRightKanExtensionAt L F Y
lemma hasPointwiseLeftKanExtensionAt_iff_of_iso {Y₁ Y₂ : D} (e : Y₁ ≅ Y₂) :
HasPointwiseLeftKanExtensionAt L F Y₁ ↔
HasPointwiseLeftKanExtensionAt L F Y₂ := by
revert Y₁ Y₂ e
suffices ∀ ⦃Y₁ Y₂ : D⦄ (_ : Y₁ ≅ Y₂) [HasPointwiseLeftKanExtensionAt L F Y₁],
HasPointwiseLeftKanExtensionAt L F Y₂ from
fun Y₁ Y₂ e => ⟨fun _ => this e, fun _ => this e.symm⟩
intro Y₁ Y₂ e _
change HasColimit ((CostructuredArrow.mapIso e.symm).functor ⋙ CostructuredArrow.proj L Y₁ ⋙ F)
infer_instance
lemma hasPointwiseRightKanExtensionAt_iff_of_iso {Y₁ Y₂ : D} (e : Y₁ ≅ Y₂) :
HasPointwiseRightKanExtensionAt L F Y₁ ↔
HasPointwiseRightKanExtensionAt L F Y₂ := by
revert Y₁ Y₂ e
suffices ∀ ⦃Y₁ Y₂ : D⦄ (_ : Y₁ ≅ Y₂) [HasPointwiseRightKanExtensionAt L F Y₁],
HasPointwiseRightKanExtensionAt L F Y₂ from
fun Y₁ Y₂ e => ⟨fun _ => this e, fun _ => this e.symm⟩
intro Y₁ Y₂ e _
change HasLimit ((StructuredArrow.mapIso e.symm).functor ⋙ StructuredArrow.proj Y₁ L ⋙ F)
infer_instance
variable {L} in
/-- `HasPointwiseLeftKanExtensionAt` is invariant when we replace `L` by an equivalent functor. -/
lemma hasPointwiseLeftKanExtensionAt_iff_of_natIso {L' : C ⥤ D} (e : L ≅ L') (Y : D) :
HasPointwiseLeftKanExtensionAt L F Y ↔
HasPointwiseLeftKanExtensionAt L' F Y := by
revert L L' e
suffices ∀ ⦃L L' : C ⥤ D⦄ (_ : L ≅ L') [HasPointwiseLeftKanExtensionAt L F Y],
HasPointwiseLeftKanExtensionAt L' F Y from
fun L L' e => ⟨fun _ => this e, fun _ => this e.symm⟩
intro L L' e _
let Φ : CostructuredArrow L' Y ≌ CostructuredArrow L Y := Comma.mapLeftIso _ e.symm
let e' : CostructuredArrow.proj L' Y ⋙ F ≅
Φ.functor ⋙ CostructuredArrow.proj L Y ⋙ F := Iso.refl _
exact hasColimit_of_iso e'
variable {L} in
/-- `HasPointwiseRightKanExtensionAt` is invariant when we replace `L` by an equivalent functor. -/
lemma hasPointwiseRightKanExtensionAt_iff_of_natIso {L' : C ⥤ D} (e : L ≅ L') (Y : D) :
HasPointwiseRightKanExtensionAt L F Y ↔
HasPointwiseRightKanExtensionAt L' F Y := by
revert L L' e
suffices ∀ ⦃L L' : C ⥤ D⦄ (_ : L ≅ L') [HasPointwiseRightKanExtensionAt L F Y],
HasPointwiseRightKanExtensionAt L' F Y from
fun L L' e => ⟨fun _ => this e, fun _ => this e.symm⟩
intro L L' e _
let Φ : StructuredArrow Y L' ≌ StructuredArrow Y L := Comma.mapRightIso _ e.symm
let e' : StructuredArrow.proj Y L' ⋙ F ≅
Φ.functor ⋙ StructuredArrow.proj Y L ⋙ F := Iso.refl _
exact hasLimit_of_iso e'.symm
lemma hasPointwiseLeftKanExtensionAt_of_equivalence
(E : D ≌ D') (eL : L ⋙ E.functor ≅ L') (Y : D) (Y' : D') (e : E.functor.obj Y ≅ Y')
[HasPointwiseLeftKanExtensionAt L F Y] :
HasPointwiseLeftKanExtensionAt L' F Y' := by
rw [← hasPointwiseLeftKanExtensionAt_iff_of_natIso F eL,
hasPointwiseLeftKanExtensionAt_iff_of_iso _ F e.symm]
let Φ := CostructuredArrow.post L E.functor Y
have : HasColimit ((asEquivalence Φ).functor ⋙
CostructuredArrow.proj (L ⋙ E.functor) (E.functor.obj Y) ⋙ F) :=
(inferInstance : HasPointwiseLeftKanExtensionAt L F Y)
exact hasColimit_of_equivalence_comp (asEquivalence Φ)
lemma hasPointwiseLeftKanExtensionAt_iff_of_equivalence
(E : D ≌ D') (eL : L ⋙ E.functor ≅ L') (Y : D) (Y' : D') (e : E.functor.obj Y ≅ Y') :
HasPointwiseLeftKanExtensionAt L F Y ↔
HasPointwiseLeftKanExtensionAt L' F Y' := by
constructor
· intro
exact hasPointwiseLeftKanExtensionAt_of_equivalence L L' F E eL Y Y' e
· intro
exact hasPointwiseLeftKanExtensionAt_of_equivalence L' L F E.symm
(isoWhiskerRight eL.symm _ ≪≫ Functor.associator _ _ _ ≪≫
isoWhiskerLeft L E.unitIso.symm ≪≫ L.rightUnitor) Y' Y
(E.inverse.mapIso e.symm ≪≫ E.unitIso.symm.app Y)
lemma hasPointwiseRightKanExtensionAt_of_equivalence
(E : D ≌ D') (eL : L ⋙ E.functor ≅ L') (Y : D) (Y' : D') (e : E.functor.obj Y ≅ Y')
[HasPointwiseRightKanExtensionAt L F Y] :
HasPointwiseRightKanExtensionAt L' F Y' := by
rw [← hasPointwiseRightKanExtensionAt_iff_of_natIso F eL,
hasPointwiseRightKanExtensionAt_iff_of_iso _ F e.symm]
let Φ := StructuredArrow.post Y L E.functor
have : HasLimit ((asEquivalence Φ).functor ⋙
StructuredArrow.proj (E.functor.obj Y) (L ⋙ E.functor) ⋙ F) :=
(inferInstance : HasPointwiseRightKanExtensionAt L F Y)
exact hasLimit_of_equivalence_comp (asEquivalence Φ)
lemma hasPointwiseRightKanExtensionAt_iff_of_equivalence
(E : D ≌ D') (eL : L ⋙ E.functor ≅ L') (Y : D) (Y' : D') (e : E.functor.obj Y ≅ Y') :
HasPointwiseRightKanExtensionAt L F Y ↔
HasPointwiseRightKanExtensionAt L' F Y' := by
constructor
· intro
exact hasPointwiseRightKanExtensionAt_of_equivalence L L' F E eL Y Y' e
· intro
exact hasPointwiseRightKanExtensionAt_of_equivalence L' L F E.symm
(isoWhiskerRight eL.symm _ ≪≫ Functor.associator _ _ _ ≪≫
isoWhiskerLeft L E.unitIso.symm ≪≫ L.rightUnitor) Y' Y
(E.inverse.mapIso e.symm ≪≫ E.unitIso.symm.app Y)
namespace LeftExtension
variable {F L}
variable (E : LeftExtension L F)
/-- The cocone for `CostructuredArrow.proj L Y ⋙ F` attached to `E : LeftExtension L F`.
The point of this cocone is `E.right.obj Y` -/
@[simps]
def coconeAt (Y : D) : Cocone (CostructuredArrow.proj L Y ⋙ F) where
pt := E.right.obj Y
ι :=
{ app := fun g => E.hom.app g.left ≫ E.right.map g.hom
naturality := fun g₁ g₂ φ => by
dsimp
rw [← CostructuredArrow.w φ]
simp only [NatTrans.naturality_assoc, Functor.comp_map,
Functor.map_comp, comp_id] }
variable (L F) in
/-- The cocones for `CostructuredArrow.proj L Y ⋙ F`, as a functor from `LeftExtension L F`. -/
@[simps]
def coconeAtFunctor (Y : D) :
LeftExtension L F ⥤ Cocone (CostructuredArrow.proj L Y ⋙ F) where
obj E := E.coconeAt Y
map {E E'} φ := CoconeMorphism.mk (φ.right.app Y) (fun G => by
dsimp
rw [← StructuredArrow.w φ]
simp)
/-- A left extension `E : LeftExtension L F` is a pointwise left Kan extension at `Y` when
`E.coconeAt Y` is a colimit cocone. -/
def IsPointwiseLeftKanExtensionAt (Y : D) := IsColimit (E.coconeAt Y)
instance (Y : D) : Subsingleton (E.IsPointwiseLeftKanExtensionAt Y) :=
inferInstanceAs (Subsingleton (IsColimit _))
variable {E} in
lemma IsPointwiseLeftKanExtensionAt.hasPointwiseLeftKanExtensionAt
{Y : D} (h : E.IsPointwiseLeftKanExtensionAt Y) :
HasPointwiseLeftKanExtensionAt L F Y := ⟨_, h⟩
lemma IsPointwiseLeftKanExtensionAt.isIso_hom_app
{X : C} (h : E.IsPointwiseLeftKanExtensionAt (L.obj X)) [L.Full] [L.Faithful] :
IsIso (E.hom.app X) := by
simpa using h.isIso_ι_app_of_isTerminal _ CostructuredArrow.mkIdTerminal
/-- The condition of being a pointwise left Kan extension at an object `Y` is
unchanged by replacing `Y` by an isomorphic object `Y'`. -/
def isPointwiseLeftKanExtensionAtOfIso'
{Y : D} (hY : E.IsPointwiseLeftKanExtensionAt Y) {Y' : D} (e : Y ≅ Y') :
E.IsPointwiseLeftKanExtensionAt Y' :=
IsColimit.ofIsoColimit (hY.whiskerEquivalence (CostructuredArrow.mapIso e.symm))
(Cocones.ext (E.right.mapIso e))
/-- The condition of being a pointwise left Kan extension at an object `Y` is
unchanged by replacing `Y` by an isomorphic object `Y'`. -/
def isPointwiseLeftKanExtensionAtEquivOfIso' {Y Y' : D} (e : Y ≅ Y') :
E.IsPointwiseLeftKanExtensionAt Y ≃ E.IsPointwiseLeftKanExtensionAt Y' where
toFun h := E.isPointwiseLeftKanExtensionAtOfIso' h e
invFun h := E.isPointwiseLeftKanExtensionAtOfIso' h e.symm
left_inv h := by subsingleton
right_inv h := by subsingleton
namespace IsPointwiseLeftKanExtensionAt
variable {E} {Y : D} (h : E.IsPointwiseLeftKanExtensionAt Y)
include h in
lemma hom_ext' {T : H} {f g : E.right.obj Y ⟶ T}
(hfg : ∀ ⦃X : C⦄ (φ : L.obj X ⟶ Y),
E.hom.app X ≫ E.right.map φ ≫ f = E.hom.app X ≫ E.right.map φ ≫ g) : f = g :=
h.hom_ext (fun j ↦ by simpa using hfg j.hom)
@[reassoc]
lemma comp_homEquiv_symm {Z : H}
(φ : CostructuredArrow.proj L Y ⋙ F ⟶ (Functor.const _).obj Z)
(g : CostructuredArrow L Y) :
E.hom.app g.left ≫ E.right.map g.hom ≫ h.homEquiv.symm φ = φ.app g := by
simpa using h.ι_app_homEquiv_symm φ g
variable [HasColimit (CostructuredArrow.proj L Y ⋙ F)]
/-- A pointwise left Kan extension of `F` along `L` applied to an object `Y` is isomorphic to
`colimit (CostructuredArrow.proj L Y ⋙ F)`. -/
noncomputable def isoColimit :
E.right.obj Y ≅ colimit (CostructuredArrow.proj L Y ⋙ F) :=
h.coconePointUniqueUpToIso (colimit.isColimit _)
@[reassoc (attr := simp)]
lemma ι_isoColimit_inv (g : CostructuredArrow L Y) :
colimit.ι _ g ≫ h.isoColimit.inv = E.hom.app g.left ≫ E.right.map g.hom :=
IsColimit.comp_coconePointUniqueUpToIso_inv _ _ _
@[reassoc (attr := simp)]
lemma ι_isoColimit_hom (g : CostructuredArrow L Y) :
E.hom.app g.left ≫ E.right.map g.hom ≫ h.isoColimit.hom =
colimit.ι (CostructuredArrow.proj L Y ⋙ F) g := by
simpa using h.comp_coconePointUniqueUpToIso_hom (colimit.isColimit _) g
end IsPointwiseLeftKanExtensionAt
/-- Given `E : Functor.LeftExtension L F`, this is the property of objects where
`E` is a pointwise left Kan extension. -/
def isPointwiseLeftKanExtensionAt : ObjectProperty D :=
fun Y ↦ Nonempty (E.IsPointwiseLeftKanExtensionAt Y)
instance : E.isPointwiseLeftKanExtensionAt.IsClosedUnderIsomorphisms where
of_iso e h := ⟨E.isPointwiseLeftKanExtensionAtOfIso' h.some e⟩
/-- A left extension `E : LeftExtension L F` is a pointwise left Kan extension when
it is a pointwise left Kan extension at any object. -/
abbrev IsPointwiseLeftKanExtension := ∀ (Y : D), E.IsPointwiseLeftKanExtensionAt Y
variable {E E'}
/-- If two left extensions `E` and `E'` are isomorphic, `E` is a pointwise
left Kan extension at `Y` iff `E'` is. -/
def isPointwiseLeftKanExtensionAtEquivOfIso (e : E ≅ E') (Y : D) :
E.IsPointwiseLeftKanExtensionAt Y ≃ E'.IsPointwiseLeftKanExtensionAt Y :=
IsColimit.equivIsoColimit ((coconeAtFunctor L F Y).mapIso e)
/-- If two left extensions `E` and `E'` are isomorphic, `E` is a pointwise
left Kan extension iff `E'` is. -/
def isPointwiseLeftKanExtensionEquivOfIso (e : E ≅ E') :
E.IsPointwiseLeftKanExtension ≃ E'.IsPointwiseLeftKanExtension where
toFun h := fun Y => (isPointwiseLeftKanExtensionAtEquivOfIso e Y) (h Y)
invFun h := fun Y => (isPointwiseLeftKanExtensionAtEquivOfIso e Y).symm (h Y)
left_inv h := by simp
right_inv h := by simp
variable (h : E.IsPointwiseLeftKanExtension)
include h
lemma IsPointwiseLeftKanExtension.hasPointwiseLeftKanExtension :
HasPointwiseLeftKanExtension L F :=
fun Y => (h Y).hasPointwiseLeftKanExtensionAt
/-- The (unique) morphism from a pointwise left Kan extension. -/
def IsPointwiseLeftKanExtension.homFrom (G : LeftExtension L F) : E ⟶ G :=
StructuredArrow.homMk
{ app := fun Y => (h Y).desc (LeftExtension.coconeAt G Y)
naturality := fun Y₁ Y₂ φ => (h Y₁).hom_ext (fun X => by
rw [(h Y₁).fac_assoc (coconeAt G Y₁) X]
simpa using (h Y₂).fac (coconeAt G Y₂) ((CostructuredArrow.map φ).obj X)) }
(by
ext X
simpa using (h (L.obj X)).fac (LeftExtension.coconeAt G _) (CostructuredArrow.mk (𝟙 _)))
lemma IsPointwiseLeftKanExtension.hom_ext
{G : LeftExtension L F} {f₁ f₂ : E ⟶ G} : f₁ = f₂ := by
ext Y
apply (h Y).hom_ext
intro X
have eq₁ := congr_app (StructuredArrow.w f₁) X.left
have eq₂ := congr_app (StructuredArrow.w f₂) X.left
dsimp at eq₁ eq₂ ⊢
simp only [assoc, NatTrans.naturality]
rw [reassoc_of% eq₁, reassoc_of% eq₂]
/-- A pointwise left Kan extension is universal, i.e. it is a left Kan extension. -/
def IsPointwiseLeftKanExtension.isUniversal : E.IsUniversal :=
IsInitial.ofUniqueHom h.homFrom (fun _ _ => h.hom_ext)
lemma IsPointwiseLeftKanExtension.isLeftKanExtension :
E.right.IsLeftKanExtension E.hom where
nonempty_isUniversal := ⟨h.isUniversal⟩
lemma IsPointwiseLeftKanExtension.hasLeftKanExtension :
HasLeftKanExtension L F :=
have := h.isLeftKanExtension
HasLeftKanExtension.mk E.right E.hom
lemma IsPointwiseLeftKanExtension.isIso_hom [L.Full] [L.Faithful] :
IsIso (E.hom) :=
have := fun X => (h (L.obj X)).isIso_hom_app
NatIso.isIso_of_isIso_app ..
end LeftExtension
namespace RightExtension
variable {F L}
variable (E E' : RightExtension L F)
/-- The cone for `StructuredArrow.proj Y L ⋙ F` attached to `E : RightExtension L F`.
The point of this cone is `E.left.obj Y` -/
@[simps]
def coneAt (Y : D) : Cone (StructuredArrow.proj Y L ⋙ F) where
pt := E.left.obj Y
π :=
{ app := fun g ↦ E.left.map g.hom ≫ E.hom.app g.right
naturality := fun g₁ g₂ φ ↦ by
dsimp
rw [assoc, id_comp, ← StructuredArrow.w φ, Functor.map_comp, assoc]
congr 1
apply E.hom.naturality }
variable (L F) in
/-- The cones for `StructuredArrow.proj Y L ⋙ F`, as a functor from `RightExtension L F`. -/
@[simps]
def coneAtFunctor (Y : D) :
RightExtension L F ⥤ Cone (StructuredArrow.proj Y L ⋙ F) where
obj E := E.coneAt Y
map {E E'} φ := ConeMorphism.mk (φ.left.app Y) (fun G ↦ by
dsimp
rw [← CostructuredArrow.w φ]
simp)
/-- A right extension `E : RightExtension L F` is a pointwise right Kan extension at `Y` when
`E.coneAt Y` is a limit cone. -/
def IsPointwiseRightKanExtensionAt (Y : D) := IsLimit (E.coneAt Y)
instance (Y : D) : Subsingleton (E.IsPointwiseRightKanExtensionAt Y) :=
inferInstanceAs (Subsingleton (IsLimit _))
variable {E} in
lemma IsPointwiseRightKanExtensionAt.hasPointwiseRightKanExtensionAt
{Y : D} (h : E.IsPointwiseRightKanExtensionAt Y) :
HasPointwiseRightKanExtensionAt L F Y := ⟨_, h⟩
lemma IsPointwiseRightKanExtensionAt.isIso_hom_app
{X : C} (h : E.IsPointwiseRightKanExtensionAt (L.obj X)) [L.Full] [L.Faithful] :
IsIso (E.hom.app X) := by
simpa using h.isIso_π_app_of_isInitial _ StructuredArrow.mkIdInitial
/-- The condition of being a pointwise right Kan extension at an object `Y` is
unchanged by replacing `Y` by an isomorphic object `Y'`. -/
def isPointwiseRightKanExtensionAtOfIso'
{Y : D} (hY : E.IsPointwiseRightKanExtensionAt Y) {Y' : D} (e : Y ≅ Y') :
E.IsPointwiseRightKanExtensionAt Y' :=
IsLimit.ofIsoLimit (hY.whiskerEquivalence (StructuredArrow.mapIso e.symm))
(Cones.ext (E.left.mapIso e))
/-- The condition of being a pointwise right Kan extension at an object `Y` is
unchanged by replacing `Y` by an isomorphic object `Y'`. -/
def isPointwiseRightKanExtensionAtEquivOfIso' {Y Y' : D} (e : Y ≅ Y') :
E.IsPointwiseRightKanExtensionAt Y ≃ E.IsPointwiseRightKanExtensionAt Y' where
toFun h := E.isPointwiseRightKanExtensionAtOfIso' h e
invFun h := E.isPointwiseRightKanExtensionAtOfIso' h e.symm
left_inv h := by subsingleton
right_inv h := by subsingleton
namespace IsPointwiseRightKanExtensionAt
variable {E} {Y : D} (h : E.IsPointwiseRightKanExtensionAt Y)
include h in
lemma hom_ext' {T : H} {f g : T ⟶ E.left.obj Y}
(hfg : ∀ ⦃X : C⦄ (φ : Y ⟶ L.obj X),
f ≫ E.left.map φ ≫ E.hom.app X = g ≫ E.left.map φ ≫ E.hom.app X) : f = g :=
h.hom_ext (fun j ↦ hfg j.hom)
variable [HasLimit (StructuredArrow.proj Y L ⋙ F)]
/-- A pointwise right Kan extension of `F` along `L` applied to an object `Y` is isomorphic to
`limit (StructuredArrow.proj Y L ⋙ F)`. -/
noncomputable def isoLimit :
E.left.obj Y ≅ limit (StructuredArrow.proj Y L ⋙ F) :=
h.conePointUniqueUpToIso (limit.isLimit _)
@[reassoc (attr := simp)]
lemma isoLimit_hom_π (g : StructuredArrow Y L) :
h.isoLimit.hom ≫ limit.π _ g = E.left.map g.hom ≫ E.hom.app g.right :=
IsLimit.conePointUniqueUpToIso_hom_comp _ _ _
@[reassoc (attr := simp)]
lemma isoLimit_inv_π (g : StructuredArrow Y L) :
h.isoLimit.inv ≫ E.left.map g.hom ≫ E.hom.app g.right =
limit.π (StructuredArrow.proj Y L ⋙ F) g := by
simpa using h.conePointUniqueUpToIso_inv_comp (limit.isLimit _) g
end IsPointwiseRightKanExtensionAt
/-- Given `E : Functor.RightExtension L F`, this is the property of objects where
`E` is a pointwise right Kan extension. -/
def isPointwiseRightKanExtensionAt : ObjectProperty D :=
fun Y ↦ Nonempty (E.IsPointwiseRightKanExtensionAt Y)
instance : E.isPointwiseRightKanExtensionAt.IsClosedUnderIsomorphisms where
of_iso e h := ⟨E.isPointwiseRightKanExtensionAtOfIso' h.some e⟩
/-- A right extension `E : RightExtension L F` is a pointwise right Kan extension when
it is a pointwise right Kan extension at any object. -/
abbrev IsPointwiseRightKanExtension := ∀ (Y : D), E.IsPointwiseRightKanExtensionAt Y
variable {E E'}
/-- If two right extensions `E` and `E'` are isomorphic, `E` is a pointwise
right Kan extension at `Y` iff `E'` is. -/
def isPointwiseRightKanExtensionAtEquivOfIso (e : E ≅ E') (Y : D) :
E.IsPointwiseRightKanExtensionAt Y ≃ E'.IsPointwiseRightKanExtensionAt Y :=
IsLimit.equivIsoLimit ((coneAtFunctor L F Y).mapIso e)
/-- If two right extensions `E` and `E'` are isomorphic, `E` is a pointwise
right Kan extension iff `E'` is. -/
def isPointwiseRightKanExtensionEquivOfIso (e : E ≅ E') :
E.IsPointwiseRightKanExtension ≃ E'.IsPointwiseRightKanExtension where
toFun h := fun Y => (isPointwiseRightKanExtensionAtEquivOfIso e Y) (h Y)
invFun h := fun Y => (isPointwiseRightKanExtensionAtEquivOfIso e Y).symm (h Y)
left_inv h := by simp
right_inv h := by simp
variable (h : E.IsPointwiseRightKanExtension)
include h
lemma IsPointwiseRightKanExtension.hasPointwiseRightKanExtension :
HasPointwiseRightKanExtension L F :=
fun Y => (h Y).hasPointwiseRightKanExtensionAt
/-- The (unique) morphism to a pointwise right Kan extension. -/
def IsPointwiseRightKanExtension.homTo (G : RightExtension L F) : G ⟶ E :=
CostructuredArrow.homMk
{ app := fun Y ↦ (h Y).lift (RightExtension.coneAt G Y)
naturality := fun Y₁ Y₂ φ ↦ (h Y₂).hom_ext (fun X ↦ by
rw [assoc, (h Y₂).fac (coneAt G Y₂) X]
simpa using ((h Y₁).fac (coneAt G Y₁) ((StructuredArrow.map φ).obj X)).symm) }
(by
ext X
simpa using (h (L.obj X)).fac (RightExtension.coneAt G _) (StructuredArrow.mk (𝟙 _)) )
lemma IsPointwiseRightKanExtension.hom_ext
{G : RightExtension L F} {f₁ f₂ : G ⟶ E} : f₁ = f₂ := by
ext Y
apply (h Y).hom_ext
intro X
have eq₁ := congr_app (CostructuredArrow.w f₁) X.right
have eq₂ := congr_app (CostructuredArrow.w f₂) X.right
dsimp at eq₁ eq₂ ⊢
simp only [← NatTrans.naturality_assoc, eq₁, eq₂]
/-- A pointwise right Kan extension is universal, i.e. it is a right Kan extension. -/
def IsPointwiseRightKanExtension.isUniversal : E.IsUniversal :=
IsTerminal.ofUniqueHom h.homTo (fun _ _ => h.hom_ext)
lemma IsPointwiseRightKanExtension.isRightKanExtension :
E.left.IsRightKanExtension E.hom where
nonempty_isUniversal := ⟨h.isUniversal⟩
lemma IsPointwiseRightKanExtension.hasRightKanExtension :
HasRightKanExtension L F :=
have := h.isRightKanExtension
HasRightKanExtension.mk E.left E.hom
lemma IsPointwiseRightKanExtension.isIso_hom [L.Full] [L.Faithful] :
IsIso (E.hom) :=
have := fun X => (h (L.obj X)).isIso_hom_app
NatIso.isIso_of_isIso_app ..
end RightExtension
section
variable [HasPointwiseLeftKanExtension L F]
/-- The constructed pointwise left Kan extension when `HasPointwiseLeftKanExtension L F` holds. -/
@[simps]
noncomputable def pointwiseLeftKanExtension : D ⥤ H where
obj Y := colimit (CostructuredArrow.proj L Y ⋙ F)
map {Y₁ Y₂} f :=
colimit.desc (CostructuredArrow.proj L Y₁ ⋙ F)
(Cocone.mk (colimit (CostructuredArrow.proj L Y₂ ⋙ F))
{ app := fun g => colimit.ι (CostructuredArrow.proj L Y₂ ⋙ F)
((CostructuredArrow.map f).obj g)
naturality := fun g₁ g₂ φ => by
simpa using colimit.w (CostructuredArrow.proj L Y₂ ⋙ F)
((CostructuredArrow.map f).map φ) })
map_id Y := colimit.hom_ext (fun j => by
dsimp
simp only [colimit.ι_desc, comp_id]
congr
apply CostructuredArrow.map_id)
map_comp {Y₁ Y₂ Y₃} f f' := colimit.hom_ext (fun j => by
dsimp
simp only [colimit.ι_desc, colimit.ι_desc_assoc, comp_obj, CostructuredArrow.proj_obj]
congr 1
apply CostructuredArrow.map_comp)
/-- The unit of the constructed pointwise left Kan extension when
`HasPointwiseLeftKanExtension L F` holds. -/
@[simps]
noncomputable def pointwiseLeftKanExtensionUnit : F ⟶ L ⋙ pointwiseLeftKanExtension L F where
app X := colimit.ι (CostructuredArrow.proj L (L.obj X) ⋙ F)
(CostructuredArrow.mk (𝟙 (L.obj X)))
naturality {X₁ X₂} f := by
simp only [comp_obj, pointwiseLeftKanExtension_obj, comp_map,
pointwiseLeftKanExtension_map, colimit.ι_desc, CostructuredArrow.map_mk]
rw [id_comp]
let φ : CostructuredArrow.mk (L.map f) ⟶ CostructuredArrow.mk (𝟙 (L.obj X₂)) :=
CostructuredArrow.homMk f
exact colimit.w (CostructuredArrow.proj L (L.obj X₂) ⋙ F) φ
/-- The functor `pointwiseLeftKanExtension L F` is a pointwise left Kan
extension of `F` along `L`. -/
noncomputable def pointwiseLeftKanExtensionIsPointwiseLeftKanExtension :
(LeftExtension.mk _ (pointwiseLeftKanExtensionUnit L F)).IsPointwiseLeftKanExtension :=
fun X => IsColimit.ofIsoColimit (colimit.isColimit _) (Cocones.ext (Iso.refl _) (fun j => by
dsimp
simp only [comp_id, colimit.ι_desc, CostructuredArrow.map_mk]
congr 1
rw [id_comp, ← CostructuredArrow.eq_mk]))
/-- The functor `pointwiseLeftKanExtension L F` is a left Kan extension of `F` along `L`. -/
noncomputable def pointwiseLeftKanExtensionIsUniversal :
(LeftExtension.mk _ (pointwiseLeftKanExtensionUnit L F)).IsUniversal :=
(pointwiseLeftKanExtensionIsPointwiseLeftKanExtension L F).isUniversal
instance : (pointwiseLeftKanExtension L F).IsLeftKanExtension
(pointwiseLeftKanExtensionUnit L F) where
nonempty_isUniversal := ⟨pointwiseLeftKanExtensionIsUniversal L F⟩
instance : HasLeftKanExtension L F :=
HasLeftKanExtension.mk _ (pointwiseLeftKanExtensionUnit L F)
/-- An auxiliary cocone used in the lemma `pointwiseLeftKanExtension_desc_app` -/
@[simps]
def costructuredArrowMapCocone (G : D ⥤ H) (α : F ⟶ L ⋙ G) (Y : D) :
Cocone (CostructuredArrow.proj L Y ⋙ F) where
pt := G.obj Y
ι := {
app := fun f ↦ α.app f.left ≫ G.map f.hom
naturality := by simp [← G.map_comp] }
@[simp]
lemma pointwiseLeftKanExtension_desc_app (G : D ⥤ H) (α : F ⟶ L ⋙ G) (Y : D) :
((pointwiseLeftKanExtension L F).descOfIsLeftKanExtension (pointwiseLeftKanExtensionUnit L F)
G α |>.app Y) = colimit.desc _ (costructuredArrowMapCocone L F G α Y) := by
let β : L.pointwiseLeftKanExtension F ⟶ G :=
{ app := fun Y ↦ colimit.desc _ (costructuredArrowMapCocone L F G α Y) }
have h : (pointwiseLeftKanExtension L F).descOfIsLeftKanExtension
(pointwiseLeftKanExtensionUnit L F) G α = β := by
apply hom_ext_of_isLeftKanExtension (α := pointwiseLeftKanExtensionUnit L F)
aesop
exact NatTrans.congr_app h Y
variable {F L}
/-- If `F` admits a pointwise left Kan extension along `L`, then any left Kan extension of `F`
along `L` is a pointwise left Kan extension. -/
noncomputable def isPointwiseLeftKanExtensionOfIsLeftKanExtension (F' : D ⥤ H) (α : F ⟶ L ⋙ F')
[F'.IsLeftKanExtension α] :
(LeftExtension.mk _ α).IsPointwiseLeftKanExtension :=
LeftExtension.isPointwiseLeftKanExtensionEquivOfIso
(IsColimit.coconePointUniqueUpToIso (pointwiseLeftKanExtensionIsUniversal L F)
(F'.isUniversalOfIsLeftKanExtension α))
(pointwiseLeftKanExtensionIsPointwiseLeftKanExtension L F)
end
section
variable [HasPointwiseRightKanExtension L F]
/-- The constructed pointwise right Kan extension
when `HasPointwiseRightKanExtension L F` holds. -/
@[simps]
noncomputable def pointwiseRightKanExtension : D ⥤ H where
obj Y := limit (StructuredArrow.proj Y L ⋙ F)
map {Y₁ Y₂} f := limit.lift (StructuredArrow.proj Y₂ L ⋙ F)
(Cone.mk (limit (StructuredArrow.proj Y₁ L ⋙ F))
{ app := fun g ↦ limit.π (StructuredArrow.proj Y₁ L ⋙ F)
((StructuredArrow.map f).obj g)
naturality := fun g₁ g₂ φ ↦ by
simpa using (limit.w (StructuredArrow.proj Y₁ L ⋙ F)
((StructuredArrow.map f).map φ)).symm })
map_id Y := limit.hom_ext (fun j => by
dsimp
simp only [limit.lift_π, id_comp]
congr
apply StructuredArrow.map_id)
map_comp {Y₁ Y₂ Y₃} f f' := limit.hom_ext (fun j => by
dsimp
simp only [limit.lift_π, assoc]
congr 1
apply StructuredArrow.map_comp)
/-- The counit of the constructed pointwise right Kan extension when
`HasPointwiseRightKanExtension L F` holds. -/
@[simps]
noncomputable def pointwiseRightKanExtensionCounit :
L ⋙ pointwiseRightKanExtension L F ⟶ F where
app X := limit.π (StructuredArrow.proj (L.obj X) L ⋙ F)
(StructuredArrow.mk (𝟙 (L.obj X)))
naturality {X₁ X₂} f := by
simp only [comp_obj, pointwiseRightKanExtension_obj, comp_map,
pointwiseRightKanExtension_map, limit.lift_π, StructuredArrow.map_mk]
rw [comp_id]
let φ : StructuredArrow.mk (𝟙 (L.obj X₁)) ⟶ StructuredArrow.mk (L.map f) :=
StructuredArrow.homMk f
exact (limit.w (StructuredArrow.proj (L.obj X₁) L ⋙ F) φ).symm
/-- The functor `pointwiseRightKanExtension L F` is a pointwise right Kan
extension of `F` along `L`. -/
noncomputable def pointwiseRightKanExtensionIsPointwiseRightKanExtension :
(RightExtension.mk _ (pointwiseRightKanExtensionCounit L F)).IsPointwiseRightKanExtension :=
fun X => IsLimit.ofIsoLimit (limit.isLimit _) (Cones.ext (Iso.refl _) (fun j => by
dsimp
simp only [limit.lift_π, StructuredArrow.map_mk, id_comp]
congr
rw [comp_id, ← StructuredArrow.eq_mk]))
/-- The functor `pointwiseRightKanExtension L F` is a right Kan extension of `F` along `L`. -/
noncomputable def pointwiseRightKanExtensionIsUniversal :
(RightExtension.mk _ (pointwiseRightKanExtensionCounit L F)).IsUniversal :=
(pointwiseRightKanExtensionIsPointwiseRightKanExtension L F).isUniversal
instance : (pointwiseRightKanExtension L F).IsRightKanExtension
(pointwiseRightKanExtensionCounit L F) where
nonempty_isUniversal := ⟨pointwiseRightKanExtensionIsUniversal L F⟩
instance : HasRightKanExtension L F :=
HasRightKanExtension.mk _ (pointwiseRightKanExtensionCounit L F)
/-- An auxiliary cocone used in the lemma `pointwiseRightKanExtension_lift_app` -/
@[simps]
def structuredArrowMapCone (G : D ⥤ H) (α : L ⋙ G ⟶ F) (Y : D) :
Cone (StructuredArrow.proj Y L ⋙ F) where
pt := G.obj Y
π := {
app := fun f ↦ G.map f.hom ≫ α.app f.right
naturality := by simp [← α.naturality, ← G.map_comp_assoc] }
@[simp]
lemma pointwiseRightKanExtension_lift_app (G : D ⥤ H) (α : L ⋙ G ⟶ F) (Y : D) :
((pointwiseRightKanExtension L F).liftOfIsRightKanExtension
(pointwiseRightKanExtensionCounit L F) G α |>.app Y) =
limit.lift _ (structuredArrowMapCone L F G α Y) := by
let β : G ⟶ L.pointwiseRightKanExtension F :=
{ app := fun Y ↦ limit.lift _ (structuredArrowMapCone L F G α Y) }
have h : (pointwiseRightKanExtension L F).liftOfIsRightKanExtension
(pointwiseRightKanExtensionCounit L F) G α = β := by
apply hom_ext_of_isRightKanExtension (α := pointwiseRightKanExtensionCounit L F)
aesop
exact NatTrans.congr_app h Y
variable {F L}
/-- If `F` admits a pointwise right Kan extension along `L`, then any right Kan extension of `F`
along `L` is a pointwise right Kan extension. -/
noncomputable def isPointwiseRightKanExtensionOfIsRightKanExtension (F' : D ⥤ H) (α : L ⋙ F' ⟶ F)
[F'.IsRightKanExtension α] :
(RightExtension.mk _ α).IsPointwiseRightKanExtension :=
RightExtension.isPointwiseRightKanExtensionEquivOfIso
(IsLimit.conePointUniqueUpToIso (pointwiseRightKanExtensionIsUniversal L F)
(F'.isUniversalOfIsRightKanExtension α))
(pointwiseRightKanExtensionIsPointwiseRightKanExtension L F)
end
end Functor
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Functor/KanExtension/Basic.lean | import Mathlib.CategoryTheory.Comma.StructuredArrow.Basic
import Mathlib.CategoryTheory.Limits.Shapes.Equivalence
import Mathlib.CategoryTheory.Limits.Preserves.Shapes.Terminal
/-!
# Kan extensions
The basic definitions for Kan extensions of functors is introduced in this file. Part of API
is parallel to the definitions for bicategories (see `CategoryTheory.Bicategory.Kan.IsKan`).
(The bicategory API cannot be used directly here because it would not allow the universe
polymorphism which is necessary for some applications.)
Given a natural transformation `α : L ⋙ F' ⟶ F`, we define the property
`F'.IsRightKanExtension α` which expresses that `(F', α)` is a right Kan
extension of `F` along `L`, i.e. that it is a terminal object in a
category `RightExtension L F` of costructured arrows. The condition
`F'.IsLeftKanExtension α` for `α : F ⟶ L ⋙ F'` is defined similarly.
We also introduce typeclasses `HasRightKanExtension L F` and `HasLeftKanExtension L F`
which assert the existence of a right or left Kan extension, and chosen Kan extensions
are obtained as `leftKanExtension L F` and `rightKanExtension L F`.
## References
* https://ncatlab.org/nlab/show/Kan+extension
-/
namespace CategoryTheory
open Category Limits Functor
namespace Functor
variable {C C' H D D' : Type*} [Category C] [Category C'] [Category H] [Category D] [Category D']
/-- Given two functors `L : C ⥤ D` and `F : C ⥤ H`, this is the category of functors
`F' : D ⥤ H` equipped with a natural transformation `L ⋙ F' ⟶ F`. -/
abbrev RightExtension (L : C ⥤ D) (F : C ⥤ H) :=
CostructuredArrow ((whiskeringLeft C D H).obj L) F
/-- Given two functors `L : C ⥤ D` and `F : C ⥤ H`, this is the category of functors
`F' : D ⥤ H` equipped with a natural transformation `F ⟶ L ⋙ F'`. -/
abbrev LeftExtension (L : C ⥤ D) (F : C ⥤ H) :=
StructuredArrow F ((whiskeringLeft C D H).obj L)
/-- Constructor for objects of the category `Functor.RightExtension L F`. -/
@[simps!]
def RightExtension.mk (F' : D ⥤ H) {L : C ⥤ D} {F : C ⥤ H} (α : L ⋙ F' ⟶ F) :
RightExtension L F :=
CostructuredArrow.mk α
/-- Constructor for objects of the category `Functor.LeftExtension L F`. -/
@[simps!]
def LeftExtension.mk (F' : D ⥤ H) {L : C ⥤ D} {F : C ⥤ H} (α : F ⟶ L ⋙ F') :
LeftExtension L F :=
StructuredArrow.mk α
section
variable (F' : D ⥤ H) {L : C ⥤ D} {F : C ⥤ H} (α : L ⋙ F' ⟶ F)
/-- Given `α : L ⋙ F' ⟶ F`, the property `F'.IsRightKanExtension α` asserts that
`(F', α)` is a terminal object in the category `RightExtension L F`, i.e. that `(F', α)`
is a right Kan extension of `F` along `L`. -/
class IsRightKanExtension : Prop where
nonempty_isUniversal : Nonempty (RightExtension.mk F' α).IsUniversal
variable [F'.IsRightKanExtension α]
/-- If `(F', α)` is a right Kan extension of `F` along `L`, then `(F', α)` is a terminal object
in the category `RightExtension L F`. -/
noncomputable def isUniversalOfIsRightKanExtension : (RightExtension.mk F' α).IsUniversal :=
IsRightKanExtension.nonempty_isUniversal.some
/-- If `(F', α)` is a right Kan extension of `F` along `L` and `β : L ⋙ G ⟶ F` is
a natural transformation, this is the induced morphism `G ⟶ F'`. -/
noncomputable def liftOfIsRightKanExtension (G : D ⥤ H) (β : L ⋙ G ⟶ F) : G ⟶ F' :=
(F'.isUniversalOfIsRightKanExtension α).lift (RightExtension.mk G β)
@[reassoc (attr := simp)]
lemma liftOfIsRightKanExtension_fac (G : D ⥤ H) (β : L ⋙ G ⟶ F) :
whiskerLeft L (F'.liftOfIsRightKanExtension α G β) ≫ α = β :=
(F'.isUniversalOfIsRightKanExtension α).fac (RightExtension.mk G β)
@[reassoc (attr := simp)]
lemma liftOfIsRightKanExtension_fac_app (G : D ⥤ H) (β : L ⋙ G ⟶ F) (X : C) :
(F'.liftOfIsRightKanExtension α G β).app (L.obj X) ≫ α.app X = β.app X :=
NatTrans.congr_app (F'.liftOfIsRightKanExtension_fac α G β) X
lemma hom_ext_of_isRightKanExtension {G : D ⥤ H} (γ₁ γ₂ : G ⟶ F')
(hγ : whiskerLeft L γ₁ ≫ α = whiskerLeft L γ₂ ≫ α) : γ₁ = γ₂ :=
(F'.isUniversalOfIsRightKanExtension α).hom_ext hγ
/-- If `(F', α)` is a right Kan extension of `F` along `L`, then this
is the induced bijection `(G ⟶ F') ≃ (L ⋙ G ⟶ F)` for all `G`. -/
@[simps!]
noncomputable def homEquivOfIsRightKanExtension (G : D ⥤ H) :
(G ⟶ F') ≃ (L ⋙ G ⟶ F) where
toFun β := whiskerLeft _ β ≫ α
invFun β := liftOfIsRightKanExtension _ α _ β
left_inv β := Functor.hom_ext_of_isRightKanExtension _ α _ _ (by simp)
right_inv := by cat_disch
lemma isRightKanExtension_of_iso {F' F'' : D ⥤ H} (e : F' ≅ F'') {L : C ⥤ D} {F : C ⥤ H}
(α : L ⋙ F' ⟶ F) (α' : L ⋙ F'' ⟶ F) (comm : whiskerLeft L e.hom ≫ α' = α)
[F'.IsRightKanExtension α] : F''.IsRightKanExtension α' where
nonempty_isUniversal := ⟨IsTerminal.ofIso (F'.isUniversalOfIsRightKanExtension α)
(CostructuredArrow.isoMk e comm)⟩
lemma isRightKanExtension_iff_of_iso {F' F'' : D ⥤ H} (e : F' ≅ F'') {L : C ⥤ D} {F : C ⥤ H}
(α : L ⋙ F' ⟶ F) (α' : L ⋙ F'' ⟶ F) (comm : whiskerLeft L e.hom ≫ α' = α) :
F'.IsRightKanExtension α ↔ F''.IsRightKanExtension α' := by
constructor
· intro
exact isRightKanExtension_of_iso e α α' comm
· intro
refine isRightKanExtension_of_iso e.symm α' α ?_
rw [← comm, ← whiskerLeft_comp_assoc, Iso.symm_hom, e.inv_hom_id, whiskerLeft_id', id_comp]
/-- Right Kan extensions of isomorphic functors are isomorphic. -/
@[simps]
noncomputable def rightKanExtensionUniqueOfIso {G : C ⥤ H} (i : F ≅ G) (G' : D ⥤ H)
(β : L ⋙ G' ⟶ G) [G'.IsRightKanExtension β] : F' ≅ G' where
hom := liftOfIsRightKanExtension _ β F' (α ≫ i.hom)
inv := liftOfIsRightKanExtension _ α G' (β ≫ i.inv)
hom_inv_id := F'.hom_ext_of_isRightKanExtension α _ _ (by simp)
inv_hom_id := G'.hom_ext_of_isRightKanExtension β _ _ (by simp)
/-- Two right Kan extensions are (canonically) isomorphic. -/
@[simps!]
noncomputable def rightKanExtensionUnique
(F'' : D ⥤ H) (α' : L ⋙ F'' ⟶ F) [F''.IsRightKanExtension α'] : F' ≅ F'' :=
rightKanExtensionUniqueOfIso F' α (Iso.refl _) F'' α'
lemma isRightKanExtension_iff_isIso {F' : D ⥤ H} {F'' : D ⥤ H} (φ : F'' ⟶ F')
{L : C ⥤ D} {F : C ⥤ H} (α : L ⋙ F' ⟶ F) (α' : L ⋙ F'' ⟶ F)
(comm : whiskerLeft L φ ≫ α = α') [F'.IsRightKanExtension α] :
F''.IsRightKanExtension α' ↔ IsIso φ := by
constructor
· intro
rw [F'.hom_ext_of_isRightKanExtension α φ (rightKanExtensionUnique _ α' _ α).hom
(by simp [comm])]
infer_instance
· intro
rw [isRightKanExtension_iff_of_iso (asIso φ) α' α comm]
infer_instance
end
section
variable (F' : D ⥤ H) {L : C ⥤ D} {F : C ⥤ H} (α : F ⟶ L ⋙ F')
/-- Given `α : F ⟶ L ⋙ F'`, the property `F'.IsLeftKanExtension α` asserts that
`(F', α)` is an initial object in the category `LeftExtension L F`, i.e. that `(F', α)`
is a left Kan extension of `F` along `L`. -/
class IsLeftKanExtension : Prop where
nonempty_isUniversal : Nonempty (LeftExtension.mk F' α).IsUniversal
variable [F'.IsLeftKanExtension α]
/-- If `(F', α)` is a left Kan extension of `F` along `L`, then `(F', α)` is an initial object
in the category `LeftExtension L F`. -/
noncomputable def isUniversalOfIsLeftKanExtension : (LeftExtension.mk F' α).IsUniversal :=
IsLeftKanExtension.nonempty_isUniversal.some
/-- If `(F', α)` is a left Kan extension of `F` along `L` and `β : F ⟶ L ⋙ G` is
a natural transformation, this is the induced morphism `F' ⟶ G`. -/
noncomputable def descOfIsLeftKanExtension (G : D ⥤ H) (β : F ⟶ L ⋙ G) : F' ⟶ G :=
(F'.isUniversalOfIsLeftKanExtension α).desc (LeftExtension.mk G β)
@[reassoc (attr := simp)]
lemma descOfIsLeftKanExtension_fac (G : D ⥤ H) (β : F ⟶ L ⋙ G) :
α ≫ whiskerLeft L (F'.descOfIsLeftKanExtension α G β) = β :=
(F'.isUniversalOfIsLeftKanExtension α).fac (LeftExtension.mk G β)
@[reassoc (attr := simp)]
lemma descOfIsLeftKanExtension_fac_app (G : D ⥤ H) (β : F ⟶ L ⋙ G) (X : C) :
α.app X ≫ (F'.descOfIsLeftKanExtension α G β).app (L.obj X) = β.app X :=
NatTrans.congr_app (F'.descOfIsLeftKanExtension_fac α G β) X
lemma hom_ext_of_isLeftKanExtension {G : D ⥤ H} (γ₁ γ₂ : F' ⟶ G)
(hγ : α ≫ whiskerLeft L γ₁ = α ≫ whiskerLeft L γ₂) : γ₁ = γ₂ :=
(F'.isUniversalOfIsLeftKanExtension α).hom_ext hγ
/-- If `(F', α)` is a left Kan extension of `F` along `L`, then this
is the induced bijection `(F' ⟶ G) ≃ (F ⟶ L ⋙ G)` for all `G`. -/
@[simps!]
noncomputable def homEquivOfIsLeftKanExtension (G : D ⥤ H) :
(F' ⟶ G) ≃ (F ⟶ L ⋙ G) where
toFun β := α ≫ whiskerLeft _ β
invFun β := descOfIsLeftKanExtension _ α _ β
left_inv β := Functor.hom_ext_of_isLeftKanExtension _ α _ _ (by simp)
right_inv := by cat_disch
lemma isLeftKanExtension_of_iso {F' : D ⥤ H} {F'' : D ⥤ H} (e : F' ≅ F'')
{L : C ⥤ D} {F : C ⥤ H} (α : F ⟶ L ⋙ F') (α' : F ⟶ L ⋙ F'')
(comm : α ≫ whiskerLeft L e.hom = α') [F'.IsLeftKanExtension α] :
F''.IsLeftKanExtension α' where
nonempty_isUniversal := ⟨IsInitial.ofIso (F'.isUniversalOfIsLeftKanExtension α)
(StructuredArrow.isoMk e comm)⟩
lemma isLeftKanExtension_iff_of_iso {F' F'' : D ⥤ H} (e : F' ≅ F'')
{L : C ⥤ D} {F : C ⥤ H} (α : F ⟶ L ⋙ F') (α' : F ⟶ L ⋙ F'')
(comm : α ≫ whiskerLeft L e.hom = α') :
F'.IsLeftKanExtension α ↔ F''.IsLeftKanExtension α' := by
constructor
· intro
exact isLeftKanExtension_of_iso e α α' comm
· intro
refine isLeftKanExtension_of_iso e.symm α' α ?_
rw [← comm, assoc, ← whiskerLeft_comp, Iso.symm_hom, e.hom_inv_id, whiskerLeft_id', comp_id]
/-- Left Kan extensions of isomorphic functors are isomorphic. -/
@[simps]
noncomputable def leftKanExtensionUniqueOfIso {G : C ⥤ H} (i : F ≅ G) (G' : D ⥤ H)
(β : G ⟶ L ⋙ G') [G'.IsLeftKanExtension β] : F' ≅ G' where
hom := descOfIsLeftKanExtension _ α G' (i.hom ≫ β)
inv := descOfIsLeftKanExtension _ β F' (i.inv ≫ α)
hom_inv_id := F'.hom_ext_of_isLeftKanExtension α _ _ (by simp)
inv_hom_id := G'.hom_ext_of_isLeftKanExtension β _ _ (by simp)
/-- Two left Kan extensions are (canonically) isomorphic. -/
@[simps!]
noncomputable def leftKanExtensionUnique
(F'' : D ⥤ H) (α' : F ⟶ L ⋙ F'') [F''.IsLeftKanExtension α'] : F' ≅ F'' :=
leftKanExtensionUniqueOfIso F' α (Iso.refl _) F'' α'
lemma isLeftKanExtension_iff_isIso {F' : D ⥤ H} {F'' : D ⥤ H} (φ : F' ⟶ F'')
{L : C ⥤ D} {F : C ⥤ H} (α : F ⟶ L ⋙ F') (α' : F ⟶ L ⋙ F'')
(comm : α ≫ whiskerLeft L φ = α') [F'.IsLeftKanExtension α] :
F''.IsLeftKanExtension α' ↔ IsIso φ := by
constructor
· intro
rw [F'.hom_ext_of_isLeftKanExtension α φ (leftKanExtensionUnique _ α _ α').hom
(by simp [comm])]
infer_instance
· intro
exact isLeftKanExtension_of_iso (asIso φ) α α' comm
end
/-- This property `HasRightKanExtension L F` holds when the functor `F` has a right
Kan extension along `L`. -/
abbrev HasRightKanExtension (L : C ⥤ D) (F : C ⥤ H) := HasTerminal (RightExtension L F)
lemma HasRightKanExtension.mk (F' : D ⥤ H) {L : C ⥤ D} {F : C ⥤ H} (α : L ⋙ F' ⟶ F)
[F'.IsRightKanExtension α] : HasRightKanExtension L F :=
(F'.isUniversalOfIsRightKanExtension α).hasTerminal
/-- This property `HasLeftKanExtension L F` holds when the functor `F` has a left
Kan extension along `L`. -/
abbrev HasLeftKanExtension (L : C ⥤ D) (F : C ⥤ H) := HasInitial (LeftExtension L F)
lemma HasLeftKanExtension.mk (F' : D ⥤ H) {L : C ⥤ D} {F : C ⥤ H} (α : F ⟶ L ⋙ F')
[F'.IsLeftKanExtension α] : HasLeftKanExtension L F :=
(F'.isUniversalOfIsLeftKanExtension α).hasInitial
section
variable (L : C ⥤ D) (F : C ⥤ H) [HasRightKanExtension L F]
/-- A chosen right Kan extension when `[HasRightKanExtension L F]` holds. -/
noncomputable def rightKanExtension : D ⥤ H := (⊤_ _ : RightExtension L F).left
/-- The counit of the chosen right Kan extension `rightKanExtension L F`. -/
noncomputable def rightKanExtensionCounit : L ⋙ rightKanExtension L F ⟶ F :=
(⊤_ _ : RightExtension L F).hom
instance : (L.rightKanExtension F).IsRightKanExtension (L.rightKanExtensionCounit F) where
nonempty_isUniversal := ⟨terminalIsTerminal⟩
@[ext]
lemma rightKanExtension_hom_ext {G : D ⥤ H} (γ₁ γ₂ : G ⟶ rightKanExtension L F)
(hγ : whiskerLeft L γ₁ ≫ rightKanExtensionCounit L F =
whiskerLeft L γ₂ ≫ rightKanExtensionCounit L F) :
γ₁ = γ₂ :=
hom_ext_of_isRightKanExtension _ _ _ _ hγ
end
section
variable (L : C ⥤ D) (F : C ⥤ H) [HasLeftKanExtension L F]
/-- A chosen left Kan extension when `[HasLeftKanExtension L F]` holds. -/
noncomputable def leftKanExtension : D ⥤ H := (⊥_ _ : LeftExtension L F).right
/-- The unit of the chosen left Kan extension `leftKanExtension L F`. -/
noncomputable def leftKanExtensionUnit : F ⟶ L ⋙ leftKanExtension L F :=
(⊥_ _ : LeftExtension L F).hom
instance : (L.leftKanExtension F).IsLeftKanExtension (L.leftKanExtensionUnit F) where
nonempty_isUniversal := ⟨initialIsInitial⟩
@[ext]
lemma leftKanExtension_hom_ext {G : D ⥤ H} (γ₁ γ₂ : leftKanExtension L F ⟶ G)
(hγ : leftKanExtensionUnit L F ≫ whiskerLeft L γ₁ =
leftKanExtensionUnit L F ≫ whiskerLeft L γ₂) : γ₁ = γ₂ :=
hom_ext_of_isLeftKanExtension _ _ _ _ hγ
end
section
variable {L : C ⥤ D} {L' : C ⥤ D'} (G : D ⥤ D')
/-- The functor `LeftExtension L' F ⥤ LeftExtension L F`
induced by a natural transformation `L' ⟶ L ⋙ G'`. -/
@[simps!]
def LeftExtension.postcomp₁ (f : L' ⟶ L ⋙ G) (F : C ⥤ H) :
LeftExtension L' F ⥤ LeftExtension L F :=
StructuredArrow.map₂ (F := (whiskeringLeft D D' H).obj G) (G := 𝟭 _) (𝟙 _)
((whiskeringLeft C D' H).map f)
/-- The functor `RightExtension L' F ⥤ RightExtension L F`
induced by a natural transformation `L ⋙ G ⟶ L'`. -/
@[simps!]
def RightExtension.postcomp₁ (f : L ⋙ G ⟶ L') (F : C ⥤ H) :
RightExtension L' F ⥤ RightExtension L F :=
CostructuredArrow.map₂ (F := (whiskeringLeft D D' H).obj G) (G := 𝟭 _)
((whiskeringLeft C D' H).map f) (𝟙 _)
variable [IsEquivalence G]
noncomputable instance (f : L' ⟶ L ⋙ G) [IsIso f] (F : C ⥤ H) :
IsEquivalence (LeftExtension.postcomp₁ G f F) := by
apply StructuredArrow.isEquivalenceMap₂
noncomputable instance (f : L ⋙ G ⟶ L') [IsIso f] (F : C ⥤ H) :
IsEquivalence (RightExtension.postcomp₁ G f F) := by
apply CostructuredArrow.isEquivalenceMap₂
variable {G} in
lemma hasLeftExtension_iff_postcomp₁ (e : L ⋙ G ≅ L') (F : C ⥤ H) :
HasLeftKanExtension L' F ↔ HasLeftKanExtension L F :=
(LeftExtension.postcomp₁ G e.inv F).asEquivalence.hasInitial_iff
variable {G} in
lemma hasRightExtension_iff_postcomp₁ (e : L ⋙ G ≅ L') (F : C ⥤ H) :
HasRightKanExtension L' F ↔ HasRightKanExtension L F :=
(RightExtension.postcomp₁ G e.hom F).asEquivalence.hasTerminal_iff
variable (e : L ⋙ G ≅ L') (F : C ⥤ H)
/-- Given an isomorphism `e : L ⋙ G ≅ L'`, a left extension of `F` along `L'` is universal
iff the corresponding left extension of `L` along `L` is. -/
noncomputable def LeftExtension.isUniversalPostcomp₁Equiv (ex : LeftExtension L' F) :
ex.IsUniversal ≃ ((LeftExtension.postcomp₁ G e.inv F).obj ex).IsUniversal := by
apply IsInitial.isInitialIffObj (LeftExtension.postcomp₁ G e.inv F)
/-- Given an isomorphism `e : L ⋙ G ≅ L'`, a right extension of `F` along `L'` is universal
iff the corresponding right extension of `L` along `L` is. -/
noncomputable def RightExtension.isUniversalPostcomp₁Equiv (ex : RightExtension L' F) :
ex.IsUniversal ≃ ((RightExtension.postcomp₁ G e.hom F).obj ex).IsUniversal := by
apply IsTerminal.isTerminalIffObj (RightExtension.postcomp₁ G e.hom F)
variable {F F'}
lemma isLeftKanExtension_iff_postcomp₁ (α : F ⟶ L' ⋙ F') :
F'.IsLeftKanExtension α ↔ (G ⋙ F').IsLeftKanExtension
(α ≫ whiskerRight e.inv _ ≫ (associator _ _ _).hom) := by
let eq : (LeftExtension.mk _ α).IsUniversal ≃
(LeftExtension.mk _
(α ≫ whiskerRight e.inv _ ≫ (associator _ _ _).hom)).IsUniversal :=
(LeftExtension.isUniversalPostcomp₁Equiv G e F _).trans
(IsInitial.equivOfIso (StructuredArrow.isoMk (Iso.refl _)))
constructor
· exact fun _ => ⟨⟨eq (isUniversalOfIsLeftKanExtension _ _)⟩⟩
· exact fun _ => ⟨⟨eq.symm (isUniversalOfIsLeftKanExtension _ _)⟩⟩
lemma isRightKanExtension_iff_postcomp₁ (α : L' ⋙ F' ⟶ F) :
F'.IsRightKanExtension α ↔ (G ⋙ F').IsRightKanExtension
((associator _ _ _).inv ≫ whiskerRight e.hom F' ≫ α) := by
let eq : (RightExtension.mk _ α).IsUniversal ≃
(RightExtension.mk _
((associator _ _ _).inv ≫ whiskerRight e.hom F' ≫ α)).IsUniversal :=
(RightExtension.isUniversalPostcomp₁Equiv G e F _).trans
(IsTerminal.equivOfIso (CostructuredArrow.isoMk (Iso.refl _)))
constructor
· exact fun _ => ⟨⟨eq (isUniversalOfIsRightKanExtension _ _)⟩⟩
· exact fun _ => ⟨⟨eq.symm (isUniversalOfIsRightKanExtension _ _)⟩⟩
end
section
variable (L : C ⥤ D) (F : C ⥤ H) (G : H ⥤ D')
/-- Given a left extension `E` of `F : C ⥤ H` along `L : C ⥤ D` and a functor `G : H ⥤ D'`,
`E.postcompose₂ G` is the extension of `F ⋙ G` along `L` obtained by whiskering by `G`
on the right. -/
@[simps!]
def LeftExtension.postcompose₂ : LeftExtension L F ⥤ LeftExtension L (F ⋙ G) :=
StructuredArrow.map₂
(F := (whiskeringRight _ _ _).obj G)
(G := (whiskeringRight _ _ _).obj G)
(𝟙 _) ({app _ := (associator _ _ _).hom})
/-- Given a right extension `E` of `F : C ⥤ H` along `L : C ⥤ D` and a functor `G : H ⥤ D'`,
`E.postcompose₂ G` is the extension of `F ⋙ G` along `L` obtained by whiskering by `G`
on the right. -/
@[simps!]
def RightExtension.postcompose₂ : RightExtension L F ⥤ RightExtension L (F ⋙ G) :=
CostructuredArrow.map₂
(F := (whiskeringRight _ _ _).obj G)
(G := (whiskeringRight _ _ _).obj G)
({app _ := associator _ _ _|>.inv}) (𝟙 _)
variable {L F} {F' : D ⥤ H}
/-- An isomorphism to describe the action of `LeftExtension.postcompose₂` on terms of the form
`LeftExtension.mk _ α`. -/
@[simps!]
def LeftExtension.postcompose₂ObjMkIso (α : F ⟶ L ⋙ F') :
(LeftExtension.postcompose₂ L F G).obj (.mk F' α) ≅
.mk (F' ⋙ G) <| whiskerRight α G ≫ (associator _ _ _).hom :=
StructuredArrow.isoMk (.refl _)
/-- An isomorphism to describe the action of `RightExtension.postcompose₂` on terms of the form
`RightExtension.mk _ α`. -/
@[simps!]
def RightExtension.postcompose₂ObjMkIso (α : L ⋙ F' ⟶ F) :
(RightExtension.postcompose₂ L F G).obj (.mk F' α) ≅
.mk (F' ⋙ G) <| (associator _ _ _).inv ≫ whiskerRight α G :=
CostructuredArrow.isoMk (.refl _)
end
section
variable (L : C ⥤ D) (F : C ⥤ H) (F' : D ⥤ H) (G : C' ⥤ C)
/-- The functor `LeftExtension L F ⥤ LeftExtension (G ⋙ L) (G ⋙ F)`
obtained by precomposition. -/
@[simps!]
def LeftExtension.precomp : LeftExtension L F ⥤ LeftExtension (G ⋙ L) (G ⋙ F) :=
StructuredArrow.map₂ (F := 𝟭 _) (G := (whiskeringLeft C' C H).obj G) (𝟙 _) (𝟙 _)
/-- The functor `RightExtension L F ⥤ RightExtension (G ⋙ L) (G ⋙ F)`
obtained by precomposition. -/
@[simps!]
def RightExtension.precomp : RightExtension L F ⥤ RightExtension (G ⋙ L) (G ⋙ F) :=
CostructuredArrow.map₂ (F := 𝟭 _) (G := (whiskeringLeft C' C H).obj G) (𝟙 _) (𝟙 _)
variable [IsEquivalence G]
noncomputable instance : IsEquivalence (LeftExtension.precomp L F G) := by
apply StructuredArrow.isEquivalenceMap₂
noncomputable instance : IsEquivalence (RightExtension.precomp L F G) := by
apply CostructuredArrow.isEquivalenceMap₂
/-- If `G` is an equivalence, then a left extension of `F` along `L` is universal iff
the corresponding left extension of `G ⋙ F` along `G ⋙ L` is. -/
noncomputable def LeftExtension.isUniversalPrecompEquiv (e : LeftExtension L F) :
e.IsUniversal ≃ ((LeftExtension.precomp L F G).obj e).IsUniversal := by
apply IsInitial.isInitialIffObj (LeftExtension.precomp L F G)
/-- If `G` is an equivalence, then a right extension of `F` along `L` is universal iff
the corresponding left extension of `G ⋙ F` along `G ⋙ L` is. -/
noncomputable def RightExtension.isUniversalPrecompEquiv (e : RightExtension L F) :
e.IsUniversal ≃ ((RightExtension.precomp L F G).obj e).IsUniversal := by
apply IsTerminal.isTerminalIffObj (RightExtension.precomp L F G)
variable {F L}
lemma isLeftKanExtension_iff_precomp (α : F ⟶ L ⋙ F') :
F'.IsLeftKanExtension α ↔ F'.IsLeftKanExtension
(whiskerLeft G α ≫ (associator _ _ _).inv) := by
let eq : (LeftExtension.mk _ α).IsUniversal ≃ (LeftExtension.mk _
(whiskerLeft G α ≫ (associator _ _ _).inv)).IsUniversal :=
(LeftExtension.isUniversalPrecompEquiv L F G _).trans
(IsInitial.equivOfIso (StructuredArrow.isoMk (Iso.refl _)))
constructor
· exact fun _ => ⟨⟨eq (isUniversalOfIsLeftKanExtension _ _)⟩⟩
· exact fun _ => ⟨⟨eq.symm (isUniversalOfIsLeftKanExtension _ _)⟩⟩
lemma isRightKanExtension_iff_precomp (α : L ⋙ F' ⟶ F) :
F'.IsRightKanExtension α ↔
F'.IsRightKanExtension ((associator _ _ _).hom ≫ whiskerLeft G α) := by
let eq : (RightExtension.mk _ α).IsUniversal ≃ (RightExtension.mk _
((associator _ _ _).hom ≫ whiskerLeft G α)).IsUniversal :=
(RightExtension.isUniversalPrecompEquiv L F G _).trans
(IsTerminal.equivOfIso (CostructuredArrow.isoMk (Iso.refl _)))
constructor
· exact fun _ => ⟨⟨eq (isUniversalOfIsRightKanExtension _ _)⟩⟩
· exact fun _ => ⟨⟨eq.symm (isUniversalOfIsRightKanExtension _ _)⟩⟩
end
section
variable {L L' : C ⥤ D} (iso₁ : L ≅ L') (F : C ⥤ H)
/-- The equivalence `RightExtension L F ≌ RightExtension L' F` induced by
a natural isomorphism `L ≅ L'`. -/
def rightExtensionEquivalenceOfIso₁ : RightExtension L F ≌ RightExtension L' F :=
CostructuredArrow.mapNatIso ((whiskeringLeft C D H).mapIso iso₁)
include iso₁ in
lemma hasRightExtension_iff_of_iso₁ : HasRightKanExtension L F ↔ HasRightKanExtension L' F :=
(rightExtensionEquivalenceOfIso₁ iso₁ F).hasTerminal_iff
/-- The equivalence `LeftExtension L F ≌ LeftExtension L' F` induced by
a natural isomorphism `L ≅ L'`. -/
@[simps!]
def leftExtensionEquivalenceOfIso₁ : LeftExtension L F ≌ LeftExtension L' F :=
StructuredArrow.mapNatIso ((whiskeringLeft C D H).mapIso iso₁)
include iso₁ in
lemma hasLeftExtension_iff_of_iso₁ : HasLeftKanExtension L F ↔ HasLeftKanExtension L' F :=
(leftExtensionEquivalenceOfIso₁ iso₁ F).hasInitial_iff
end
section
variable (L : C ⥤ D) {F F' : C ⥤ H} (iso₂ : F ≅ F')
/-- The equivalence `RightExtension L F ≌ RightExtension L F'` induced by
a natural isomorphism `F ≅ F'`. -/
def rightExtensionEquivalenceOfIso₂ : RightExtension L F ≌ RightExtension L F' :=
CostructuredArrow.mapIso iso₂
include iso₂ in
lemma hasRightExtension_iff_of_iso₂ : HasRightKanExtension L F ↔ HasRightKanExtension L F' :=
(rightExtensionEquivalenceOfIso₂ L iso₂).hasTerminal_iff
/-- The equivalence `LeftExtension L F ≌ LeftExtension L F'` induced by
a natural isomorphism `F ≅ F'`. -/
def leftExtensionEquivalenceOfIso₂ : LeftExtension L F ≌ LeftExtension L F' :=
StructuredArrow.mapIso iso₂
include iso₂ in
lemma hasLeftExtension_iff_of_iso₂ : HasLeftKanExtension L F ↔ HasLeftKanExtension L F' :=
(leftExtensionEquivalenceOfIso₂ L iso₂).hasInitial_iff
end
section
variable {L : C ⥤ D} {F₁ F₂ : C ⥤ H}
/-- When two left extensions `α₁ : LeftExtension L F₁` and `α₂ : LeftExtension L F₂`
are essentially the same via an isomorphism of functors `F₁ ≅ F₂`,
then `α₁` is universal iff `α₂` is. -/
noncomputable def LeftExtension.isUniversalEquivOfIso₂
(α₁ : LeftExtension L F₁) (α₂ : LeftExtension L F₂) (e : F₁ ≅ F₂)
(e' : α₁.right ≅ α₂.right)
(h : α₁.hom ≫ whiskerLeft L e'.hom = e.hom ≫ α₂.hom) :
α₁.IsUniversal ≃ α₂.IsUniversal :=
(IsInitial.isInitialIffObj (leftExtensionEquivalenceOfIso₂ L e).functor α₁).trans
(IsInitial.equivOfIso (StructuredArrow.isoMk e'
(by simp [leftExtensionEquivalenceOfIso₂, h])))
lemma isLeftKanExtension_iff_of_iso₂ {F₁' F₂' : D ⥤ H} (α₁ : F₁ ⟶ L ⋙ F₁') (α₂ : F₂ ⟶ L ⋙ F₂')
(e : F₁ ≅ F₂) (e' : F₁' ≅ F₂') (h : α₁ ≫ whiskerLeft L e'.hom = e.hom ≫ α₂) :
F₁'.IsLeftKanExtension α₁ ↔ F₂'.IsLeftKanExtension α₂ := by
let eq := LeftExtension.isUniversalEquivOfIso₂ (LeftExtension.mk _ α₁)
(LeftExtension.mk _ α₂) e e' h
constructor
· exact fun _ => ⟨⟨eq.1 (isUniversalOfIsLeftKanExtension F₁' α₁)⟩⟩
· exact fun _ => ⟨⟨eq.2 (isUniversalOfIsLeftKanExtension F₂' α₂)⟩⟩
/-- When two right extensions `α₁ : RightExtension L F₁` and `α₂ : RightExtension L F₂`
are essentially the same via an isomorphism of functors `F₁ ≅ F₂`,
then `α₁` is universal iff `α₂` is. -/
noncomputable def RightExtension.isUniversalEquivOfIso₂
(α₁ : RightExtension L F₁) (α₂ : RightExtension L F₂) (e : F₁ ≅ F₂)
(e' : α₁.left ≅ α₂.left)
(h : whiskerLeft L e'.hom ≫ α₂.hom = α₁.hom ≫ e.hom) :
α₁.IsUniversal ≃ α₂.IsUniversal :=
(IsTerminal.isTerminalIffObj (rightExtensionEquivalenceOfIso₂ L e).functor α₁).trans
(IsTerminal.equivOfIso (CostructuredArrow.isoMk e'
(by simp [rightExtensionEquivalenceOfIso₂, h])))
lemma isRightKanExtension_iff_of_iso₂ {F₁' F₂' : D ⥤ H} (α₁ : L ⋙ F₁' ⟶ F₁) (α₂ : L ⋙ F₂' ⟶ F₂)
(e : F₁ ≅ F₂) (e' : F₁' ≅ F₂') (h : whiskerLeft L e'.hom ≫ α₂ = α₁ ≫ e.hom) :
F₁'.IsRightKanExtension α₁ ↔ F₂'.IsRightKanExtension α₂ := by
let eq := RightExtension.isUniversalEquivOfIso₂ (RightExtension.mk _ α₁)
(RightExtension.mk _ α₂) e e' h
constructor
· exact fun _ => ⟨⟨eq.1 (isUniversalOfIsRightKanExtension F₁' α₁)⟩⟩
· exact fun _ => ⟨⟨eq.2 (isUniversalOfIsRightKanExtension F₂' α₂)⟩⟩
end
section transitivity
/-- A variant of `LeftExtension.precomp` where we precompose, and then
"whisker" the diagram by a given natural transformation `(α : F₀ ⟶ L ⋙ F₁)` -/
@[simps!]
def LeftExtension.precomp₂
{F₀ : C ⥤ H} {L : C ⥤ D} {F₁ : D ⥤ H} (L' : D ⥤ D') (α : F₀ ⟶ L ⋙ F₁) :
L'.LeftExtension F₁ ⥤ (L ⋙ L').LeftExtension F₀ :=
LeftExtension.precomp L' F₁ L ⋙ StructuredArrow.map α
variable
{L : C ⥤ D} {L' : D ⥤ D'}
{F₀ : C ⥤ H} {F₁ : D ⥤ H} {F₂ : D' ⥤ H}
(α : F₀ ⟶ L ⋙ F₁)
/-- If the right extension defined by `α : F₀ ⟶ L ⋙ F₁` is universal,
then for every `L' : D ⥤ D'`, `F₁ : D ⥤ H`, if an extension
`b : L'.LeftExtension F₁` is universal, so is the "pasted" extension
`(LeftExtension.precomp₂ L' α).obj b`. -/
def LeftExtension.isUniversalPrecomp₂
(hα : (LeftExtension.mk F₁ α).IsUniversal)
{b : L'.LeftExtension F₁} (hb : b.IsUniversal) :
((LeftExtension.precomp₂ L' α).obj b).IsUniversal := by
letI (y : (L ⋙ L').LeftExtension F₀) :
Unique ((precomp₂ L' α).obj b ⟶ y) := by
let u : L'.LeftExtension F₁ :=
mk y.right <|
hα.desc <| LeftExtension.mk _ <|
y.hom ≫ (L.associator L' y.right).hom
refine
⟨⟨StructuredArrow.homMk (hb.desc u) <| by
ext x
haveI hb_fac_app := congr_app (hb.fac u) (L.obj x)
haveI hα_fac_app :=
congr_app (hα.fac <| LeftExtension.mk _ <|
y.hom ≫ (L.associator L' y.right).hom) x
dsimp at hα_fac_app hb_fac_app
simp [hb_fac_app, u, hα_fac_app]⟩, fun a => ?_⟩
dsimp
ext1
apply hb.hom_ext
apply hα.hom_ext
ext t
dsimp
have a_w_t := congr_app a.w t
have hb_fac_app := congr_app (hb.fac u) (L.obj t)
have hα_fac_app :=
congr_app
(hα.fac <| LeftExtension.mk _ <|
y.hom ≫ (L.associator L' y.right).hom) t
dsimp at hb_fac_app hα_fac_app
simp only [precomp₂_obj_left, const_obj_obj, whiskeringLeft_obj_obj,
comp_obj, StructuredArrow.left_eq_id, const_obj_map, id_comp,
precomp₂_obj_right, whiskeringLeft_obj_map, NatTrans.comp_app,
precomp₂_obj_hom_app, whiskerLeft_app, assoc] at a_w_t
simp [← a_w_t, hb_fac_app, u, hα_fac_app]
apply IsInitial.ofUnique
/-- If the left extension defined by `α : F₀ ⟶ L ⋙ F₁` is universal,
then for every `L' : D ⥤ D'`, `F₁ : D ⥤ H`, if an extension
`b : L'.LeftExtension F₁` is such that the "pasted" extension
`(LeftExtension.precomp₂ L' α).obj b` is universal, then `b` is itself
universal. -/
def LeftExtension.isUniversalOfPrecomp₂
(hα : (LeftExtension.mk F₁ α).IsUniversal)
{b : L'.LeftExtension F₁}
(hb : ((LeftExtension.precomp₂ L' α).obj b).IsUniversal) :
b.IsUniversal := by
letI (y : L'.LeftExtension F₁) : Unique (b ⟶ y) := by
let u : (LeftExtension.precomp₂ L' α).obj b ⟶
(LeftExtension.precomp₂ L' α).obj y := hb.to _
haveI := u.w
simp only [precomp₂_obj_left, const_obj_obj, precomp₂_obj_right,
whiskeringLeft_obj_obj, StructuredArrow.left_eq_id, const_obj_map, id_comp,
whiskeringLeft_obj_map] at this
refine
⟨⟨StructuredArrow.homMk u.right <| by
apply hα.hom_ext
ext t
have := congr_app u.w t
simp only [precomp₂_obj_left, const_obj_obj, precomp₂_obj_right,
whiskeringLeft_obj_obj, comp_obj, StructuredArrow.left_eq_id,
const_obj_map, id_comp, precomp₂_obj_hom_app, whiskeringLeft_obj_map,
NatTrans.comp_app, whiskerLeft_app, assoc] at this
simp [this]⟩, fun a => ?_⟩
dsimp
ext1
apply hb.hom_ext
ext t
have := congr_app u.w t
have a_w := a.w
simp only [precomp₂_obj_left, const_obj_obj, precomp₂_obj_right,
whiskeringLeft_obj_obj, comp_obj, StructuredArrow.left_eq_id,
const_obj_map, id_comp, precomp₂_obj_hom_app, whiskeringLeft_obj_map,
NatTrans.comp_app, whiskerLeft_app, assoc] at this a_w
simp [← this, a_w]
apply IsInitial.ofUnique
/-- If the left extension defined by `α : F₀ ⟶ L ⋙ F₁` is universal,
then for every `L' : D ⥤ D'`, `F₁ : D ⥤ H`, an extension
`b : L'.LeftExtension F₁` is universal if and only if
`(LeftExtension.precomp₂ L' α).obj b` is universal. -/
def LeftExtension.isUniversalPrecomp₂Equiv
(hα : (LeftExtension.mk F₁ α).IsUniversal)
(b : L'.LeftExtension F₁) :
b.IsUniversal ≃ ((LeftExtension.precomp₂ L' α).obj b).IsUniversal where
toFun h := LeftExtension.isUniversalPrecomp₂ α hα h
invFun h := LeftExtension.isUniversalOfPrecomp₂ α hα h
left_inv x := by subsingleton
right_inv x := by subsingleton
theorem isLeftKanExtension_iff_postcompose [F₁.IsLeftKanExtension α]
{F₂ : D' ⥤ H} (L'' : C ⥤ D') (e : L ⋙ L' ≅ L'') (β : F₁ ⟶ L' ⋙ F₂)
(γ : F₀ ⟶ L'' ⋙ F₂)
(hγ :
α ≫ whiskerLeft _ β ≫
(Functor.associator _ _ _).inv ≫ whiskerRight e.hom F₂ =
γ := by aesop_cat) :
F₂.IsLeftKanExtension β ↔ F₂.IsLeftKanExtension γ := by
let Ψ := leftExtensionEquivalenceOfIso₁ e F₀
obtain ⟨⟨hα⟩⟩ := (inferInstance : F₁.IsLeftKanExtension α)
refine ⟨fun ⟨⟨h⟩⟩ => ⟨⟨?_⟩⟩, fun ⟨⟨h⟩⟩ => ⟨⟨?_⟩⟩⟩
· apply IsInitial.isInitialIffObj Ψ.inverse _|>.invFun
haveI := LeftExtension.isUniversalPrecomp₂ α hα h
let i :
(LeftExtension.precomp₂ L' α).obj (LeftExtension.mk F₂ β) ≅
Ψ.inverse.obj (LeftExtension.mk F₂ γ) :=
StructuredArrow.isoMk (NatIso.ofComponents fun _ ↦ .refl _) <| by
ext x
simp [Ψ, ← congr_app hγ x, ← Functor.map_comp]
exact IsInitial.ofIso this i
· apply LeftExtension.isUniversalOfPrecomp₂ α hα
apply IsInitial.isInitialIffObj Ψ.functor _|>.invFun
let i :
(LeftExtension.mk F₂ γ) ≅
Ψ.functor.obj <| (LeftExtension.precomp₂ L' α).obj <|
LeftExtension.mk F₂ β :=
StructuredArrow.isoMk (NatIso.ofComponents fun _ ↦ .refl _)
exact IsInitial.ofIso h i
end transitivity
section Colimit
variable (F' : D ⥤ H) {L : C ⥤ D} {F : C ⥤ H} (α : F ⟶ L ⋙ F') [F'.IsLeftKanExtension α]
/-- Construct a cocone for a left Kan extension `F' : D ⥤ H` of `F : C ⥤ H` along a functor
`L : C ⥤ D` given a cocone for `F`. -/
@[simps]
noncomputable def coconeOfIsLeftKanExtension (c : Cocone F) : Cocone F' where
pt := c.pt
ι := F'.descOfIsLeftKanExtension α _ c.ι
/-- If `c` is a colimit cocone for a functor `F : C ⥤ H` and `α : F ⟶ L ⋙ F'` is the unit of any
left Kan extension `F' : D ⥤ H` of `F` along `L : C ⥤ D`, then `coconeOfIsLeftKanExtension α c` is
a colimit cocone, too. -/
@[simps]
noncomputable def isColimitCoconeOfIsLeftKanExtension {c : Cocone F} (hc : IsColimit c) :
IsColimit (F'.coconeOfIsLeftKanExtension α c) where
desc s := hc.desc (Cocone.mk _ (α ≫ whiskerLeft L s.ι))
fac s := by
have : F'.descOfIsLeftKanExtension α ((const D).obj c.pt) c.ι ≫
(Functor.const _).map (hc.desc (Cocone.mk _ (α ≫ whiskerLeft L s.ι))) = s.ι :=
F'.hom_ext_of_isLeftKanExtension α _ _ (by cat_disch)
exact congr_app this
uniq s m hm := hc.hom_ext (fun j ↦ by
have := hm (L.obj j)
nth_rw 1 [← F'.descOfIsLeftKanExtension_fac_app α ((const D).obj c.pt)]
dsimp at this ⊢
rw [assoc, this, IsColimit.fac, NatTrans.comp_app, whiskerLeft_app])
variable [HasColimit F] [HasColimit F']
/-- If `F' : D ⥤ H` is a left Kan extension of `F : C ⥤ H` along `L : C ⥤ D`, the colimit over `F'`
is isomorphic to the colimit over `F`. -/
noncomputable def colimitIsoOfIsLeftKanExtension : colimit F' ≅ colimit F :=
IsColimit.coconePointUniqueUpToIso (colimit.isColimit F')
(F'.isColimitCoconeOfIsLeftKanExtension α (colimit.isColimit F))
@[reassoc (attr := simp)]
lemma ι_colimitIsoOfIsLeftKanExtension_hom (i : C) :
α.app i ≫ colimit.ι F' (L.obj i) ≫ (F'.colimitIsoOfIsLeftKanExtension α).hom =
colimit.ι F i := by
simp [colimitIsoOfIsLeftKanExtension]
@[reassoc (attr := simp)]
lemma ι_colimitIsoOfIsLeftKanExtension_inv (i : C) :
colimit.ι F i ≫ (F'.colimitIsoOfIsLeftKanExtension α).inv =
α.app i ≫ colimit.ι F' (L.obj i) := by
rw [Iso.comp_inv_eq, assoc, ι_colimitIsoOfIsLeftKanExtension_hom]
end Colimit
section Limit
variable (F' : D ⥤ H) {L : C ⥤ D} {F : C ⥤ H} (α : L ⋙ F' ⟶ F) [F'.IsRightKanExtension α]
/-- Construct a cone for a right Kan extension `F' : D ⥤ H` of `F : C ⥤ H` along a functor
`L : C ⥤ D` given a cone for `F`. -/
@[simps]
noncomputable def coneOfIsRightKanExtension (c : Cone F) : Cone F' where
pt := c.pt
π := F'.liftOfIsRightKanExtension α _ c.π
/-- If `c` is a limit cone for a functor `F : C ⥤ H` and `α : L ⋙ F' ⟶ F` is the counit of any
right Kan extension `F' : D ⥤ H` of `F` along `L : C ⥤ D`, then `coneOfIsRightKanExtension α c` is
a limit cone, too. -/
@[simps]
noncomputable def isLimitConeOfIsRightKanExtension {c : Cone F} (hc : IsLimit c) :
IsLimit (F'.coneOfIsRightKanExtension α c) where
lift s := hc.lift (Cone.mk _ (whiskerLeft L s.π ≫ α))
fac s := by
have : (Functor.const _).map (hc.lift (Cone.mk _ (whiskerLeft L s.π ≫ α))) ≫
F'.liftOfIsRightKanExtension α ((const D).obj c.pt) c.π = s.π :=
F'.hom_ext_of_isRightKanExtension α _ _ (by cat_disch)
exact congr_app this
uniq s m hm := hc.hom_ext (fun j ↦ by
have := hm (L.obj j)
nth_rw 1 [← F'.liftOfIsRightKanExtension_fac_app α ((const D).obj c.pt)]
dsimp at this ⊢
rw [← assoc, this, IsLimit.fac, NatTrans.comp_app, whiskerLeft_app])
variable [HasLimit F] [HasLimit F']
/-- If `F' : D ⥤ H` is a right Kan extension of `F : C ⥤ H` along `L : C ⥤ D`, the limit over `F'`
is isomorphic to the limit over `F`. -/
noncomputable def limitIsoOfIsRightKanExtension : limit F' ≅ limit F :=
IsLimit.conePointUniqueUpToIso (limit.isLimit F')
(F'.isLimitConeOfIsRightKanExtension α (limit.isLimit F))
@[reassoc (attr := simp)]
lemma limitIsoOfIsRightKanExtension_inv_π (i : C) :
(F'.limitIsoOfIsRightKanExtension α).inv ≫ limit.π F' (L.obj i) ≫ α.app i = limit.π F i := by
simp [limitIsoOfIsRightKanExtension]
@[reassoc (attr := simp)]
lemma limitIsoOfIsRightKanExtension_hom_π (i : C) :
(F'.limitIsoOfIsRightKanExtension α).hom ≫ limit.π F i = limit.π F' (L.obj i) ≫ α.app i := by
rw [← Iso.eq_inv_comp, limitIsoOfIsRightKanExtension_inv_π]
end Limit
section
variable {L : C ≌ D} {F₀ : C ⥤ H} {F₁ : D ⥤ H}
variable (F₀) in
instance isLeftKanExtensionId : F₀.IsLeftKanExtension F₀.leftUnitor.inv where
nonempty_isUniversal := ⟨StructuredArrow.mkIdInitial⟩
variable (F₀) in
instance isRightKanExtensionId : F₀.IsRightKanExtension F₀.leftUnitor.hom where
nonempty_isUniversal := ⟨CostructuredArrow.mkIdTerminal⟩
instance isLeftKanExtensionAlongEquivalence (α : F₀ ≅ L.functor ⋙ F₁) :
F₁.IsLeftKanExtension α.hom := by
refine ⟨⟨?_⟩⟩
apply LeftExtension.isUniversalPostcomp₁Equiv
(G := L.functor) L.functor.leftUnitor F₀ _|>.invFun
refine IsInitial.ofUniqueHom
(fun y ↦ StructuredArrow.homMk <| α.inv ≫ y.hom ≫ y.right.leftUnitor.hom) ?_
intro y m
ext x
simpa using α.inv.app x ≫= congr_app m.w.symm x
instance isLeftKanExtensionAlongEquivalence' (L : C ⥤ D) (α : F₀ ⟶ L ⋙ F₁)
[IsEquivalence L] [IsIso α] :
F₁.IsLeftKanExtension α :=
inferInstanceAs <|
F₁.IsLeftKanExtension (asIso α : F₀ ≅ (asEquivalence L).functor ⋙ F₁).hom
instance isRightKanExtensionAlongEquivalence (α : L.functor ⋙ F₁ ≅ F₀) :
F₁.IsRightKanExtension α.hom := by
refine ⟨⟨?_⟩⟩
apply RightExtension.isUniversalPostcomp₁Equiv
(G := L.functor) L.functor.leftUnitor F₀ _|>.invFun
refine IsTerminal.ofUniqueHom
(fun y ↦ CostructuredArrow.homMk <| y.left.leftUnitor.inv ≫ y.hom ≫ α.inv) ?_
intro y m
ext x
simpa using congr_app m.w x =≫ α.inv.app x
instance isRightKanExtensionAlongEquivalence' (L : C ⥤ D) (α : L ⋙ F₁ ⟶ F₀)
[IsEquivalence L] [IsIso α] :
F₁.IsRightKanExtension α :=
inferInstanceAs <|
F₁.IsRightKanExtension (asIso α : (asEquivalence L).functor ⋙ F₁ ≅ F₀).hom
end
end Functor
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Functor/KanExtension/DenseAt.lean | import Mathlib.CategoryTheory.Functor.KanExtension.Pointwise
/-!
# Canonical colimits, or functors that are dense at an object
Given a functor `F : C ⥤ D` and `Y : D`, we say that `F` is dense at `Y` (`F.DenseAt Y`),
if `Y` identifies to the colimit of all `F.obj X` for `X : C`
and `f : F.obj X ⟶ Y`, i.e. `Y` identifies to the colimit of
the obvious functor `CostructuredArrow F Y ⥤ D`. In some references,
it is also said that `Y` is a canonical colimit relatively to `F`.
While `F.DenseAt Y` contains data, we also introduce the
corresponding property `isDenseAt F` of objects of `D`.
## TODO
* formalize dense subcategories
* show the presheaves of types are canonical colimits relatively
to the Yoneda embedding
## References
* https://ncatlab.org/nlab/show/dense+functor
-/
universe v₁ v₂ u₁ u₂
namespace CategoryTheory
open Limits
variable {C : Type u₁} {D : Type u₂} [Category.{v₁} C] [Category.{v₂} D]
(F : C ⥤ D)
namespace Functor
/-- A functor `F : C ⥤ D` is dense at `Y : D` if the obvious natural transformation
`F ⟶ F ⋙ 𝟭 D` makes `𝟭 D` a pointwise left Kan extension of `F` along itself at `Y`,
i.e. `Y` identifies to the colimit of the obvious functor `CostructuredArrow F Y ⥤ D`. -/
abbrev DenseAt (Y : D) : Type max u₁ u₂ v₂ :=
(Functor.LeftExtension.mk (𝟭 D) F.rightUnitor.inv).IsPointwiseLeftKanExtensionAt Y
variable {F} {Y : D} (hY : F.DenseAt Y)
/-- If `F : C ⥤ D` is dense at `Y : D`, then it is also at `Y'`
if `Y` and `Y'` are isomorphic. -/
def DenseAt.ofIso {Y' : D} (e : Y ≅ Y') : F.DenseAt Y' :=
LeftExtension.isPointwiseLeftKanExtensionAtOfIso' _ hY e
/-- If `F : C ⥤ D` is dense at `Y : D`, and `G` is a functor that is isomorphic to `F`,
then `G` is also dense at `Y`. -/
def DenseAt.ofNatIso {G : C ⥤ D} (e : F ≅ G) : G.DenseAt Y :=
(IsColimit.equivOfNatIsoOfIso
((Functor.associator _ _ _).symm ≪≫ Functor.isoWhiskerLeft _ e) _ _
(by exact Cocones.ext (Iso.refl _)))
(hY.whiskerEquivalence (CostructuredArrow.mapNatIso e.symm))
/-- If `F : C ⥤ D` is dense at `Y : D`, then so is `G ⋙ F` if `G` is an equivalence. -/
noncomputable def DenseAt.precompEquivalence
{C' : Type*} [Category C'] (G : C' ⥤ C) [G.IsEquivalence] :
(G ⋙ F).DenseAt Y :=
hY.whiskerEquivalence (CostructuredArrow.pre G F Y).asEquivalence
/-- If `F : C ⥤ D` is dense at `Y : D` and `G : D ⥤ D'` is an equivalence,
then `F ⋙ G` is dense at `G.obj Y`. -/
noncomputable def DenseAt.postcompEquivalence
{D' : Type*} [Category D'] (G : D ⥤ D') [G.IsEquivalence] :
(F ⋙ G).DenseAt (G.obj Y) :=
IsColimit.ofWhiskerEquivalence (CostructuredArrow.post F G Y).asEquivalence
(IsColimit.ofIsoColimit ((isColimitOfPreserves G hY)) (Cocones.ext (Iso.refl _)))
variable (F) in
/-- Given a functor `F : C ⥤ D`, this is the property of objects `Y : D` such
that `F` is dense at `Y`. -/
def isDenseAt : ObjectProperty D :=
fun Y ↦ Nonempty (F.DenseAt Y)
lemma isDenseAt_eq_isPointwiseLeftKanExtensionAt :
F.isDenseAt =
(Functor.LeftExtension.mk (𝟭 D) F.rightUnitor.inv).isPointwiseLeftKanExtensionAt :=
rfl
instance : F.isDenseAt.IsClosedUnderIsomorphisms := by
rw [isDenseAt_eq_isPointwiseLeftKanExtensionAt]
infer_instance
lemma congr_isDenseAt {G : C ⥤ D} (e : F ≅ G) :
F.isDenseAt = G.isDenseAt := by
ext X
exact ⟨fun ⟨h⟩ ↦ ⟨h.ofNatIso e⟩, fun ⟨h⟩ ↦ ⟨h.ofNatIso e.symm⟩⟩
end Functor
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Functor/KanExtension/Adjunction.lean | import Mathlib.CategoryTheory.Functor.KanExtension.Pointwise
import Mathlib.CategoryTheory.Limits.Shapes.Grothendieck
import Mathlib.CategoryTheory.Comma.StructuredArrow.Functor
/-! # The Kan extension functor
Given a functor `L : C ⥤ D`, we define the left Kan extension functor
`L.lan : (C ⥤ H) ⥤ (D ⥤ H)` which sends a functor `F : C ⥤ H` to its
left Kan extension along `L`. This is defined if all `F` have such
a left Kan extension. It is shown that `L.lan` is the left adjoint to
the functor `(D ⥤ H) ⥤ (C ⥤ H)` given by the precomposition
with `L` (see `Functor.lanAdjunction`).
Similarly, we define the right Kan extension functor
`L.ran : (C ⥤ H) ⥤ (D ⥤ H)` which sends a functor `F : C ⥤ H` to its
right Kan extension along `L`.
-/
namespace CategoryTheory
open Category Limits
namespace Functor
variable {C D : Type*} [Category C] [Category D] (L : C ⥤ D) {H : Type*} [Category H]
section lan
section
variable [∀ (F : C ⥤ H), HasLeftKanExtension L F]
/-- The left Kan extension functor `(C ⥤ H) ⥤ (D ⥤ H)` along a functor `C ⥤ D`. -/
noncomputable def lan : (C ⥤ H) ⥤ (D ⥤ H) where
obj F := leftKanExtension L F
map {F₁ F₂} φ := descOfIsLeftKanExtension _ (leftKanExtensionUnit L F₁) _
(φ ≫ leftKanExtensionUnit L F₂)
/-- The natural transformation `F ⟶ L ⋙ (L.lan).obj G`. -/
noncomputable def lanUnit : (𝟭 (C ⥤ H)) ⟶ L.lan ⋙ (whiskeringLeft C D H).obj L where
app F := leftKanExtensionUnit L F
naturality {F₁ F₂} φ := by ext; simp [lan]
instance (F : C ⥤ H) : (L.lan.obj F).IsLeftKanExtension (L.lanUnit.app F) := by
dsimp [lan, lanUnit]
infer_instance
end
/-- If there exists a pointwise left Kan extension of `F` along `L`,
then `L.lan.obj G` is a pointwise left Kan extension of `F`. -/
noncomputable def isPointwiseLeftKanExtensionLeftKanExtensionUnit
(F : C ⥤ H) [HasPointwiseLeftKanExtension L F] :
(LeftExtension.mk _ (L.leftKanExtensionUnit F)).IsPointwiseLeftKanExtension :=
isPointwiseLeftKanExtensionOfIsLeftKanExtension (F := F) _ (leftKanExtensionUnit L F)
section
open CostructuredArrow
variable (F : C ⥤ H) [HasPointwiseLeftKanExtension L F]
/-- If a left Kan extension is pointwise, then evaluating it at an object is isomorphic to
taking a colimit. -/
noncomputable def leftKanExtensionObjIsoColimit [HasLeftKanExtension L F] (X : D) :
(L.leftKanExtension F).obj X ≅ colimit (proj L X ⋙ F) :=
LeftExtension.IsPointwiseLeftKanExtensionAt.isoColimit (F := F)
(isPointwiseLeftKanExtensionLeftKanExtensionUnit L F X)
@[reassoc (attr := simp)]
lemma ι_leftKanExtensionObjIsoColimit_inv [HasLeftKanExtension L F] (X : D)
(f : CostructuredArrow L X) :
colimit.ι _ f ≫ (L.leftKanExtensionObjIsoColimit F X).inv =
(L.leftKanExtensionUnit F).app f.left ≫ (L.leftKanExtension F).map f.hom := by
simp [leftKanExtensionObjIsoColimit]
@[reassoc (attr := simp)]
lemma ι_leftKanExtensionObjIsoColimit_hom (X : D) (f : CostructuredArrow L X) :
(L.leftKanExtensionUnit F).app f.left ≫ (L.leftKanExtension F).map f.hom ≫
(L.leftKanExtensionObjIsoColimit F X).hom =
colimit.ι (proj L X ⋙ F) f :=
LeftExtension.IsPointwiseLeftKanExtensionAt.ι_isoColimit_hom (F := F)
(isPointwiseLeftKanExtensionLeftKanExtensionUnit L F X) f
lemma leftKanExtensionUnit_leftKanExtension_map_leftKanExtensionObjIsoColimit_hom (X : D)
(f : CostructuredArrow L X) :
(leftKanExtensionUnit L F).app f.left ≫ (leftKanExtension L F).map f.hom ≫
(L.leftKanExtensionObjIsoColimit F X).hom =
colimit.ι (proj L X ⋙ F) f :=
LeftExtension.IsPointwiseLeftKanExtensionAt.ι_isoColimit_hom (F := F)
(isPointwiseLeftKanExtensionLeftKanExtensionUnit L F X) f
@[reassoc (attr := simp)]
lemma leftKanExtensionUnit_leftKanExtensionObjIsoColimit_hom (X : C) :
(L.leftKanExtensionUnit F).app X ≫ (L.leftKanExtensionObjIsoColimit F (L.obj X)).hom =
colimit.ι (proj L (L.obj X) ⋙ F) (CostructuredArrow.mk (𝟙 _)) := by
simpa using leftKanExtensionUnit_leftKanExtension_map_leftKanExtensionObjIsoColimit_hom L F
(L.obj X) (CostructuredArrow.mk (𝟙 _))
@[instance]
theorem hasColimit_map_comp_ι_comp_grothendieckProj {X Y : D} (f : X ⟶ Y) :
HasColimit ((functor L).map f ⋙ Grothendieck.ι (functor L) Y ⋙ grothendieckProj L ⋙ F) :=
hasColimit_of_iso (isoWhiskerRight (mapCompιCompGrothendieckProj L f) F)
@[deprecated (since := "2025-07-27")]
alias hasColimit_map_comp_ι_comp_grotendieckProj := hasColimit_map_comp_ι_comp_grothendieckProj
/-- The left Kan extension of `F : C ⥤ H` along a functor `L : C ⥤ D` is isomorphic to the
fiberwise colimit of the projection functor on the Grothendieck construction of the costructured
arrow category composed with `F`. -/
@[simps!]
noncomputable def leftKanExtensionIsoFiberwiseColimit [HasLeftKanExtension L F] :
leftKanExtension L F ≅ fiberwiseColimit (grothendieckProj L ⋙ F) :=
letI : ∀ X, HasColimit (Grothendieck.ι (functor L) X ⋙ grothendieckProj L ⋙ F) :=
fun X => hasColimit_of_iso <| Iso.symm <|
isoWhiskerRight (eqToIso ((functor L).map_id X)) _ ≪≫
Functor.leftUnitor (Grothendieck.ι (functor L) X ⋙ grothendieckProj L ⋙ F)
Iso.symm <| NatIso.ofComponents
(fun X => HasColimit.isoOfNatIso (isoWhiskerRight (ιCompGrothendieckProj L X) F) ≪≫
(leftKanExtensionObjIsoColimit L F X).symm)
fun f => colimit.hom_ext (by simp)
end
section HasLeftKanExtension
variable [∀ (F : C ⥤ H), HasLeftKanExtension L F]
variable (H) in
/-- The left Kan extension functor `L.Lan` is left adjoint to the precomposition by `L`. -/
noncomputable def lanAdjunction : L.lan ⊣ (whiskeringLeft C D H).obj L :=
Adjunction.mkOfHomEquiv
{ homEquiv := fun F G => homEquivOfIsLeftKanExtension _ (L.lanUnit.app F) G
homEquiv_naturality_left_symm := fun {F₁ F₂ G} f α =>
hom_ext_of_isLeftKanExtension _ (L.lanUnit.app F₁) _ _ (by
ext X
dsimp [homEquivOfIsLeftKanExtension]
rw [descOfIsLeftKanExtension_fac_app, NatTrans.comp_app, ← assoc]
have h := congr_app (L.lanUnit.naturality f) X
dsimp at h ⊢
rw [← h, assoc, descOfIsLeftKanExtension_fac_app] )
homEquiv_naturality_right := fun {F G₁ G₂} β f => by
dsimp [homEquivOfIsLeftKanExtension]
rw [assoc] }
variable (H) in
@[simp]
lemma lanAdjunction_unit : (L.lanAdjunction H).unit = L.lanUnit := by
ext F : 2
dsimp [lanAdjunction, homEquivOfIsLeftKanExtension]
simp
lemma lanAdjunction_counit_app (G : D ⥤ H) :
(L.lanAdjunction H).counit.app G =
descOfIsLeftKanExtension (L.lan.obj (L ⋙ G)) (L.lanUnit.app (L ⋙ G)) G (𝟙 (L ⋙ G)) :=
rfl
@[reassoc (attr := simp)]
lemma lanUnit_app_whiskerLeft_lanAdjunction_counit_app (G : D ⥤ H) :
L.lanUnit.app (L ⋙ G) ≫ whiskerLeft L ((L.lanAdjunction H).counit.app G) = 𝟙 (L ⋙ G) := by
simp [lanAdjunction_counit_app]
@[reassoc (attr := simp)]
lemma lanUnit_app_app_lanAdjunction_counit_app_app (G : D ⥤ H) (X : C) :
(L.lanUnit.app (L ⋙ G)).app X ≫ ((L.lanAdjunction H).counit.app G).app (L.obj X) = 𝟙 _ :=
congr_app (L.lanUnit_app_whiskerLeft_lanAdjunction_counit_app G) X
lemma isIso_lanAdjunction_counit_app_iff (G : D ⥤ H) :
IsIso ((L.lanAdjunction H).counit.app G) ↔ G.IsLeftKanExtension (𝟙 (L ⋙ G)) :=
(isLeftKanExtension_iff_isIso _ (L.lanUnit.app (L ⋙ G)) _ (by simp)).symm
lemma isIso_lanAdjunction_homEquiv_symm_iff {F : C ⥤ H} {G : D ⥤ H} (α : F ⟶ L ⋙ G) :
IsIso (((L.lanAdjunction H).homEquiv _ _).symm α) ↔ G.IsLeftKanExtension α :=
(isLeftKanExtension_iff_isIso ((((L.lanAdjunction H).homEquiv _ _).symm α))
(L.lanUnit.app F) α (by simp [lanAdjunction])).symm
/-- Composing the left Kan extension of `L : C ⥤ D` with `colim` on shapes `D` is isomorphic
to `colim` on shapes `C`. -/
@[simps!]
noncomputable def lanCompColimIso [HasColimitsOfShape C H] [HasColimitsOfShape D H] :
L.lan ⋙ colim ≅ colim (C := H) :=
Iso.symm <| NatIso.ofComponents
(fun G ↦ (colimitIsoOfIsLeftKanExtension _ (L.lanUnit.app G)).symm)
(fun f ↦ colimit.hom_ext (fun i ↦ by
dsimp
rw [ι_colimMap_assoc, ι_colimitIsoOfIsLeftKanExtension_inv,
ι_colimitIsoOfIsLeftKanExtension_inv_assoc, ι_colimMap, ← assoc, ← assoc]
congr 1
exact congr_app (L.lanUnit.naturality f) i))
end HasLeftKanExtension
section HasPointwiseLeftKanExtension
variable (G : C ⥤ H) [L.HasPointwiseLeftKanExtension G]
variable [HasColimitsOfShape D H]
instance : HasColimit (CostructuredArrow.grothendieckProj L ⋙ G) :=
hasColimit_of_hasColimit_fiberwiseColimit_of_hasColimit _
variable [HasColimitsOfShape C H]
/-- If `G : C ⥤ H` admits a left Kan extension along a functor `L : C ⥤ D` and `H` has colimits of
shape `C` and `D`, then the colimit of `G` is isomorphic to the colimit of a canonical functor
`Grothendieck (CostructuredArrow.functor L) ⥤ H` induced by `L` and `G`. -/
noncomputable def colimitIsoColimitGrothendieck :
colimit G ≅ colimit (CostructuredArrow.grothendieckProj L ⋙ G) := calc
colimit G
≅ colimit (leftKanExtension L G) :=
(colimitIsoOfIsLeftKanExtension _ (L.leftKanExtensionUnit G)).symm
_ ≅ colimit (fiberwiseColimit (CostructuredArrow.grothendieckProj L ⋙ G)) :=
HasColimit.isoOfNatIso (leftKanExtensionIsoFiberwiseColimit L G)
_ ≅ colimit (CostructuredArrow.grothendieckProj L ⋙ G) :=
colimitFiberwiseColimitIso _
@[reassoc (attr := simp)]
lemma ι_colimitIsoColimitGrothendieck_inv (X : Grothendieck (CostructuredArrow.functor L)) :
colimit.ι (CostructuredArrow.grothendieckProj L ⋙ G) X ≫
(colimitIsoColimitGrothendieck L G).inv =
colimit.ι G ((CostructuredArrow.proj L X.base).obj X.fiber) := by
simp [colimitIsoColimitGrothendieck]
@[reassoc (attr := simp)]
lemma ι_colimitIsoColimitGrothendieck_hom (X : C) :
colimit.ι G X ≫ (colimitIsoColimitGrothendieck L G).hom =
colimit.ι (CostructuredArrow.grothendieckProj L ⋙ G) ⟨L.obj X, .mk (𝟙 _)⟩ := by
rw [← Iso.eq_comp_inv]
exact (ι_colimitIsoColimitGrothendieck_inv L G ⟨L.obj X, .mk (𝟙 _)⟩).symm
end HasPointwiseLeftKanExtension
section
variable [Full L] [Faithful L]
instance (F : C ⥤ H) (X : C) [HasPointwiseLeftKanExtension L F]
[∀ (F : C ⥤ H), HasLeftKanExtension L F] :
IsIso ((L.lanUnit.app F).app X) :=
(isPointwiseLeftKanExtensionLeftKanExtensionUnit L F (L.obj X)).isIso_hom_app
instance (F : C ⥤ H) [HasPointwiseLeftKanExtension L F]
[∀ (F : C ⥤ H), HasLeftKanExtension L F] :
IsIso (L.lanUnit.app F) :=
NatIso.isIso_of_isIso_app _
instance coreflective [∀ (F : C ⥤ H), HasPointwiseLeftKanExtension L F] :
IsIso (L.lanUnit (H := H)) := by
apply NatIso.isIso_of_isIso_app _
instance (F : C ⥤ H) [HasPointwiseLeftKanExtension L F]
[∀ (F : C ⥤ H), HasLeftKanExtension L F] :
IsIso ((L.lanAdjunction H).unit.app F) := by
rw [lanAdjunction_unit]
infer_instance
instance coreflective' [∀ (F : C ⥤ H), HasPointwiseLeftKanExtension L F] :
IsIso (L.lanAdjunction H).unit := by
apply NatIso.isIso_of_isIso_app _
end
end lan
section ran
section
variable [∀ (F : C ⥤ H), HasRightKanExtension L F]
/-- The right Kan extension functor `(C ⥤ H) ⥤ (D ⥤ H)` along a functor `C ⥤ D`. -/
noncomputable def ran : (C ⥤ H) ⥤ (D ⥤ H) where
obj F := rightKanExtension L F
map {F₁ F₂} φ := liftOfIsRightKanExtension _ (rightKanExtensionCounit L F₂) _
(rightKanExtensionCounit L F₁ ≫ φ)
/-- The natural transformation `L ⋙ (L.lan).obj G ⟶ L`. -/
noncomputable def ranCounit : L.ran ⋙ (whiskeringLeft C D H).obj L ⟶ (𝟭 (C ⥤ H)) where
app F := rightKanExtensionCounit L F
naturality {F₁ F₂} φ := by ext; simp [ran]
instance (F : C ⥤ H) : (L.ran.obj F).IsRightKanExtension (L.ranCounit.app F) := by
dsimp [ran, ranCounit]
infer_instance
/-- If there exists a pointwise right Kan extension of `F` along `L`,
then `L.ran.obj G` is a pointwise right Kan extension of `F`. -/
noncomputable def isPointwiseRightKanExtensionRanCounit
(F : C ⥤ H) [HasPointwiseRightKanExtension L F] :
(RightExtension.mk _ (L.ranCounit.app F)).IsPointwiseRightKanExtension :=
isPointwiseRightKanExtensionOfIsRightKanExtension (F := F) _ (L.ranCounit.app F)
/-- If a right Kan extension is pointwise, then evaluating it at an object is isomorphic to
taking a limit. -/
noncomputable def ranObjObjIsoLimit (F : C ⥤ H) [HasPointwiseRightKanExtension L F] (X : D) :
(L.ran.obj F).obj X ≅ limit (StructuredArrow.proj X L ⋙ F) :=
RightExtension.IsPointwiseRightKanExtensionAt.isoLimit (F := F)
(isPointwiseRightKanExtensionRanCounit L F X)
@[reassoc (attr := simp)]
lemma ranObjObjIsoLimit_hom_π
(F : C ⥤ H) [HasPointwiseRightKanExtension L F] (X : D) (f : StructuredArrow X L) :
(L.ranObjObjIsoLimit F X).hom ≫ limit.π _ f =
(L.ran.obj F).map f.hom ≫ (L.ranCounit.app F).app f.right := by
simp [ranObjObjIsoLimit, ran, ranCounit]
@[reassoc (attr := simp)]
lemma ranObjObjIsoLimit_inv_π
(F : C ⥤ H) [HasPointwiseRightKanExtension L F] (X : D) (f : StructuredArrow X L) :
(L.ranObjObjIsoLimit F X).inv ≫ (L.ran.obj F).map f.hom ≫ (L.ranCounit.app F).app f.right =
limit.π _ f :=
RightExtension.IsPointwiseRightKanExtensionAt.isoLimit_inv_π (F := F)
(isPointwiseRightKanExtensionRanCounit L F X) f
variable (H) in
/-- The right Kan extension functor `L.ran` is right adjoint to the
precomposition by `L`. -/
noncomputable def ranAdjunction : (whiskeringLeft C D H).obj L ⊣ L.ran :=
Adjunction.mkOfHomEquiv
{ homEquiv := fun F G =>
(homEquivOfIsRightKanExtension (α := L.ranCounit.app G) _ F).symm
homEquiv_naturality_right := fun {F G₁ G₂} β f ↦
hom_ext_of_isRightKanExtension _ (L.ranCounit.app G₂) _ _ (by
ext X
dsimp [homEquivOfIsRightKanExtension]
rw [liftOfIsRightKanExtension_fac_app, NatTrans.comp_app, assoc]
have h := congr_app (L.ranCounit.naturality f) X
dsimp at h ⊢
rw [h, liftOfIsRightKanExtension_fac_app_assoc])
homEquiv_naturality_left_symm := fun {F₁ F₂ G} β f ↦ by
dsimp [homEquivOfIsRightKanExtension]
rw [assoc] }
variable (H) in
@[simp]
lemma ranAdjunction_counit : (L.ranAdjunction H).counit = L.ranCounit := by
ext F : 2
dsimp [ranAdjunction, homEquivOfIsRightKanExtension]
simp
lemma ranAdjunction_unit_app (G : D ⥤ H) :
(L.ranAdjunction H).unit.app G =
liftOfIsRightKanExtension (L.ran.obj (L ⋙ G)) (L.ranCounit.app (L ⋙ G)) G (𝟙 (L ⋙ G)) :=
rfl
@[reassoc (attr := simp)]
lemma ranCounit_app_whiskerLeft_ranAdjunction_unit_app (G : D ⥤ H) :
whiskerLeft L ((L.ranAdjunction H).unit.app G) ≫ L.ranCounit.app (L ⋙ G) = 𝟙 (L ⋙ G) := by
simp [ranAdjunction_unit_app]
@[reassoc (attr := simp)]
lemma ranCounit_app_app_ranAdjunction_unit_app_app (G : D ⥤ H) (X : C) :
((L.ranAdjunction H).unit.app G).app (L.obj X) ≫ (L.ranCounit.app (L ⋙ G)).app X = 𝟙 _ :=
congr_app (L.ranCounit_app_whiskerLeft_ranAdjunction_unit_app G) X
lemma isIso_ranAdjunction_unit_app_iff (G : D ⥤ H) :
IsIso ((L.ranAdjunction H).unit.app G) ↔ G.IsRightKanExtension (𝟙 (L ⋙ G)) :=
(isRightKanExtension_iff_isIso _ (L.ranCounit.app (L ⋙ G)) _ (by simp)).symm
lemma isIso_ranAdjunction_homEquiv_iff {F : C ⥤ H} {G : D ⥤ H} (α : L ⋙ G ⟶ F) :
IsIso (((L.ranAdjunction H).homEquiv _ _) α) ↔ G.IsRightKanExtension α :=
(isRightKanExtension_iff_isIso ((((L.ranAdjunction H).homEquiv _ _) α))
(L.ranCounit.app F) α (by simp [ranAdjunction])).symm
/-- Composing the right Kan extension of `L : C ⥤ D` with `lim` on shapes `D` is isomorphic
to `lim` on shapes `C`. -/
@[simps!]
noncomputable def ranCompLimIso (L : C ⥤ D) [∀ (G : C ⥤ H), L.HasRightKanExtension G]
[HasLimitsOfShape C H] [HasLimitsOfShape D H] : L.ran ⋙ lim ≅ lim (C := H) :=
NatIso.ofComponents
(fun G ↦ limitIsoOfIsRightKanExtension _ (L.ranCounit.app G))
(fun f ↦ limit.hom_ext (fun i ↦ by
dsimp
rw [assoc, assoc, limMap_π, limitIsoOfIsRightKanExtension_hom_π_assoc,
limitIsoOfIsRightKanExtension_hom_π, limMap_π_assoc]
congr 1
exact congr_app (L.ranCounit.naturality f) i))
end
section
variable [Full L] [Faithful L]
instance (F : C ⥤ H) (X : C) [HasPointwiseRightKanExtension L F]
[∀ (F : C ⥤ H), HasRightKanExtension L F] :
IsIso ((L.ranCounit.app F).app X) :=
(isPointwiseRightKanExtensionRanCounit L F (L.obj X)).isIso_hom_app
instance (F : C ⥤ H) [HasPointwiseRightKanExtension L F]
[∀ (F : C ⥤ H), HasRightKanExtension L F] :
IsIso (L.ranCounit.app F) :=
NatIso.isIso_of_isIso_app _
instance reflective [∀ (F : C ⥤ H), HasPointwiseRightKanExtension L F] :
IsIso (L.ranCounit (H := H)) := by
apply NatIso.isIso_of_isIso_app _
instance (F : C ⥤ H) [HasPointwiseRightKanExtension L F]
[∀ (F : C ⥤ H), HasRightKanExtension L F] :
IsIso ((L.ranAdjunction H).counit.app F) := by
rw [ranAdjunction_counit]
infer_instance
instance reflective' [∀ (F : C ⥤ H), HasPointwiseRightKanExtension L F] :
IsIso (L.ranAdjunction H).counit := by
apply NatIso.isIso_of_isIso_app _
end
end ran
end Functor
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Functor/ReflectsIso/Balanced.lean | import Mathlib.CategoryTheory.Functor.ReflectsIso.Basic
import Mathlib.CategoryTheory.Balanced
import Mathlib.CategoryTheory.Functor.EpiMono
/-!
# Balanced categories and functors reflecting isomorphisms
If a category is `C`, and a functor out of `C` reflects epimorphisms and monomorphisms,
then the functor reflects isomorphisms.
Furthermore, categories that admits a functor that `ReflectsIsomorphisms`, `PreservesEpimorphisms`
and `PreservesMonomorphisms` are balanced.
-/
open CategoryTheory CategoryTheory.Functor
namespace CategoryTheory
variable {C : Type*} [Category C]
{D : Type*} [Category D]
instance (priority := 100) reflectsIsomorphisms_of_reflectsMonomorphisms_of_reflectsEpimorphisms
[Balanced C] (F : C ⥤ D) [ReflectsMonomorphisms F] [ReflectsEpimorphisms F] :
F.ReflectsIsomorphisms where
reflects f hf := by
haveI : Epi f := epi_of_epi_map F inferInstance
haveI : Mono f := mono_of_mono_map F inferInstance
exact isIso_of_mono_of_epi f
lemma Functor.balanced_of_preserves (F : C ⥤ D)
[F.ReflectsIsomorphisms] [F.PreservesEpimorphisms] [F.PreservesMonomorphisms] [Balanced D] :
Balanced C where
isIso_of_mono_of_epi f _ _ := by
rw [← isIso_iff_of_reflects_iso (F := F)]
exact isIso_of_mono_of_epi _
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Functor/ReflectsIso/Basic.lean | import Mathlib.CategoryTheory.Whiskering
import Mathlib.CategoryTheory.Iso
import Mathlib.CategoryTheory.Functor.FullyFaithful
/-!
# Functors which reflect isomorphisms
A functor `F` reflects isomorphisms if whenever `F.map f` is an isomorphism, `f` was too.
It is formalized as a `Prop`-valued typeclass `ReflectsIsomorphisms F`.
Any fully faithful functor reflects isomorphisms.
-/
namespace CategoryTheory
open Functor
variable {C : Type*} [Category C]
{D : Type*} [Category D]
{E : Type*} [Category E]
section ReflectsIso
/-- Define what it means for a functor `F : C ⥤ D` to reflect isomorphisms: for any
morphism `f : A ⟶ B`, if `F.map f` is an isomorphism then `f` is as well.
Note that we do not assume or require that `F` is faithful.
-/
class Functor.ReflectsIsomorphisms (F : C ⥤ D) : Prop where
/-- For any `f`, if `F.map f` is an iso, then so was `f`. -/
reflects : ∀ {A B : C} (f : A ⟶ B) [IsIso (F.map f)], IsIso f
/-- If `F` reflects isos and `F.map f` is an iso, then `f` is an iso. -/
theorem isIso_of_reflects_iso {A B : C} (f : A ⟶ B) (F : C ⥤ D) [IsIso (F.map f)]
[F.ReflectsIsomorphisms] : IsIso f :=
ReflectsIsomorphisms.reflects F f
lemma isIso_iff_of_reflects_iso {A B : C} (f : A ⟶ B) (F : C ⥤ D) [F.ReflectsIsomorphisms] :
IsIso (F.map f) ↔ IsIso f :=
⟨fun _ => isIso_of_reflects_iso f F, fun _ => inferInstance⟩
lemma Functor.FullyFaithful.reflectsIsomorphisms {F : C ⥤ D} (hF : F.FullyFaithful) :
F.ReflectsIsomorphisms where
reflects _ _ := hF.isIso_of_isIso_map _
instance (priority := 100) reflectsIsomorphisms_of_full_and_faithful
(F : C ⥤ D) [F.Full] [F.Faithful] :
F.ReflectsIsomorphisms :=
(Functor.FullyFaithful.ofFullyFaithful F).reflectsIsomorphisms
instance reflectsIsomorphisms_comp (F : C ⥤ D) (G : D ⥤ E)
[F.ReflectsIsomorphisms] [G.ReflectsIsomorphisms] :
(F ⋙ G).ReflectsIsomorphisms :=
⟨fun f (hf : IsIso (G.map _)) => by
haveI := isIso_of_reflects_iso (F.map f) G
exact isIso_of_reflects_iso f F⟩
lemma reflectsIsomorphisms_of_comp (F : C ⥤ D) (G : D ⥤ E)
[(F ⋙ G).ReflectsIsomorphisms] : F.ReflectsIsomorphisms where
reflects f _ := by
rw [← isIso_iff_of_reflects_iso _ (F ⋙ G)]
dsimp
infer_instance
instance (F : D ⥤ E) [F.ReflectsIsomorphisms] :
((whiskeringRight C D E).obj F).ReflectsIsomorphisms where
reflects {X Y} f _ := by
rw [NatTrans.isIso_iff_isIso_app]
intro Z
rw [← isIso_iff_of_reflects_iso _ F]
change IsIso ((((whiskeringRight C D E).obj F).map f).app Z)
infer_instance
end ReflectsIso
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/GradedObject/Monoidal.lean | import Mathlib.CategoryTheory.GradedObject.Unitor
import Mathlib.Data.Fintype.Prod
/-!
# The monoidal category structures on graded objects
Assuming that `C` is a monoidal category and that `I` is an additive monoid,
we introduce a partially defined tensor product on the category `GradedObject I C`:
given `X₁` and `X₂` two objects in `GradedObject I C`, we define
`GradedObject.Monoidal.tensorObj X₁ X₂` under the assumption `HasTensor X₁ X₂`
that the coproduct of `X₁ i ⊗ X₂ j` for `i + j = n` exists for any `n : I`.
Under suitable assumptions about the existence of coproducts and the
preservation of certain coproducts by the tensor products in `C`, we
obtain a monoidal category structure on `GradedObject I C`.
In particular, if `C` has finite coproducts to which the tensor
product commutes, we obtain a monoidal category structure on `GradedObject ℕ C`.
-/
universe u
namespace CategoryTheory
open Limits MonoidalCategory Category
variable {I : Type u} [AddMonoid I] {C : Type*} [Category C] [MonoidalCategory C]
namespace GradedObject
/-- The tensor product of two graded objects `X₁` and `X₂` exists if for any `n`,
the coproduct of the objects `X₁ i ⊗ X₂ j` for `i + j = n` exists. -/
abbrev HasTensor (X₁ X₂ : GradedObject I C) : Prop :=
HasMap (((mapBifunctor (curriedTensor C) I I).obj X₁).obj X₂) (fun ⟨i, j⟩ => i + j)
lemma hasTensor_of_iso {X₁ X₂ Y₁ Y₂ : GradedObject I C}
(e₁ : X₁ ≅ Y₁) (e₂ : X₂ ≅ Y₂) [HasTensor X₁ X₂] :
HasTensor Y₁ Y₂ := by
let e : ((mapBifunctor (curriedTensor C) I I).obj X₁).obj X₂ ≅
((mapBifunctor (curriedTensor C) I I).obj Y₁).obj Y₂ := isoMk _ _
(fun ⟨i, j⟩ ↦ (eval i).mapIso e₁ ⊗ᵢ (eval j).mapIso e₂)
exact hasMap_of_iso e _
namespace Monoidal
/-- The tensor product of two graded objects. -/
noncomputable abbrev tensorObj (X₁ X₂ : GradedObject I C) [HasTensor X₁ X₂] :
GradedObject I C :=
mapBifunctorMapObj (curriedTensor C) (fun ⟨i, j⟩ => i + j) X₁ X₂
section
variable (X₁ X₂ : GradedObject I C) [HasTensor X₁ X₂]
/-- The inclusion of a summand in a tensor product of two graded objects. -/
noncomputable def ιTensorObj (i₁ i₂ i₁₂ : I) (h : i₁ + i₂ = i₁₂) :
X₁ i₁ ⊗ X₂ i₂ ⟶ tensorObj X₁ X₂ i₁₂ :=
ιMapBifunctorMapObj (curriedTensor C) _ _ _ _ _ _ h
variable {X₁ X₂}
@[ext]
lemma tensorObj_ext {A : C} {j : I} (f g : tensorObj X₁ X₂ j ⟶ A)
(h : ∀ (i₁ i₂ : I) (hi : i₁ + i₂ = j),
ιTensorObj X₁ X₂ i₁ i₂ j hi ≫ f = ιTensorObj X₁ X₂ i₁ i₂ j hi ≫ g) : f = g := by
apply mapObj_ext
rintro ⟨i₁, i₂⟩ hi
exact h i₁ i₂ hi
/-- Constructor for morphisms from a tensor product of two graded objects. -/
noncomputable def tensorObjDesc {A : C} {k : I}
(f : ∀ (i₁ i₂ : I) (_ : i₁ + i₂ = k), X₁ i₁ ⊗ X₂ i₂ ⟶ A) : tensorObj X₁ X₂ k ⟶ A :=
mapBifunctorMapObjDesc f
@[reassoc (attr := simp)]
lemma ι_tensorObjDesc {A : C} {k : I}
(f : ∀ (i₁ i₂ : I) (_ : i₁ + i₂ = k), X₁ i₁ ⊗ X₂ i₂ ⟶ A) (i₁ i₂ : I) (hi : i₁ + i₂ = k) :
ιTensorObj X₁ X₂ i₁ i₂ k hi ≫ tensorObjDesc f = f i₁ i₂ hi := by
apply ι_mapBifunctorMapObjDesc
end
/-- The morphism `tensorObj X₁ Y₁ ⟶ tensorObj X₂ Y₂` induced by morphisms of graded
objects `f : X₁ ⟶ X₂` and `g : Y₁ ⟶ Y₂`. -/
noncomputable def tensorHom {X₁ X₂ Y₁ Y₂ : GradedObject I C} (f : X₁ ⟶ X₂) (g : Y₁ ⟶ Y₂)
[HasTensor X₁ Y₁] [HasTensor X₂ Y₂] :
tensorObj X₁ Y₁ ⟶ tensorObj X₂ Y₂ :=
mapBifunctorMapMap _ _ f g
@[reassoc (attr := simp)]
lemma ι_tensorHom {X₁ X₂ Y₁ Y₂ : GradedObject I C} (f : X₁ ⟶ X₂) (g : Y₁ ⟶ Y₂)
[HasTensor X₁ Y₁] [HasTensor X₂ Y₂] (i₁ i₂ i₁₂ : I) (h : i₁ + i₂ = i₁₂) :
ιTensorObj X₁ Y₁ i₁ i₂ i₁₂ h ≫ tensorHom f g i₁₂ =
(f i₁ ⊗ₘ g i₂) ≫ ιTensorObj X₂ Y₂ i₁ i₂ i₁₂ h := by
rw [tensorHom_def, assoc]
apply ι_mapBifunctorMapMap
/-- The morphism `tensorObj X Y₁ ⟶ tensorObj X Y₂` induced by a morphism of graded objects
`φ : Y₁ ⟶ Y₂`. -/
noncomputable abbrev whiskerLeft (X : GradedObject I C) {Y₁ Y₂ : GradedObject I C} (φ : Y₁ ⟶ Y₂)
[HasTensor X Y₁] [HasTensor X Y₂] : tensorObj X Y₁ ⟶ tensorObj X Y₂ :=
tensorHom (𝟙 X) φ
/-- The morphism `tensorObj X₁ Y ⟶ tensorObj X₂ Y` induced by a morphism of graded objects
`φ : X₁ ⟶ X₂`. -/
noncomputable abbrev whiskerRight {X₁ X₂ : GradedObject I C} (φ : X₁ ⟶ X₂) (Y : GradedObject I C)
[HasTensor X₁ Y] [HasTensor X₂ Y] : tensorObj X₁ Y ⟶ tensorObj X₂ Y :=
tensorHom φ (𝟙 Y)
@[simp]
lemma id_tensorHom_id (X Y : GradedObject I C) [HasTensor X Y] :
tensorHom (𝟙 X) (𝟙 Y) = 𝟙 _ := by
dsimp [tensorHom, mapBifunctorMapMap]
simp only [Functor.map_id, NatTrans.id_app, comp_id, mapMap_id]
rfl
@[deprecated (since := "2025-07-14")] alias tensor_id := id_tensorHom_id
@[reassoc]
lemma tensorHom_comp_tensorHom {X₁ X₂ X₃ Y₁ Y₂ Y₃ : GradedObject I C} (f₁ : X₁ ⟶ X₂) (f₂ : X₂ ⟶ X₃)
(g₁ : Y₁ ⟶ Y₂) (g₂ : Y₂ ⟶ Y₃) [HasTensor X₁ Y₁] [HasTensor X₂ Y₂] [HasTensor X₃ Y₃] :
tensorHom f₁ g₁ ≫ tensorHom f₂ g₂ = tensorHom (f₁ ≫ f₂) (g₁ ≫ g₂) := by
dsimp only [tensorHom, mapBifunctorMapMap]
rw [← mapMap_comp]
apply congr_mapMap
simp
/-- The isomorphism `tensorObj X₁ Y₁ ≅ tensorObj X₂ Y₂` induced by isomorphisms of graded
objects `e : X₁ ≅ X₂` and `e' : Y₁ ≅ Y₂`. -/
@[simps]
noncomputable def tensorIso {X₁ X₂ Y₁ Y₂ : GradedObject I C} (e : X₁ ≅ X₂) (e' : Y₁ ≅ Y₂)
[HasTensor X₁ Y₁] [HasTensor X₂ Y₂] :
tensorObj X₁ Y₁ ≅ tensorObj X₂ Y₂ where
hom := tensorHom e.hom e'.hom
inv := tensorHom e.inv e'.inv
hom_inv_id := by simp [tensorHom_comp_tensorHom]
inv_hom_id := by simp [tensorHom_comp_tensorHom]
lemma tensorHom_def {X₁ X₂ Y₁ Y₂ : GradedObject I C} (f : X₁ ⟶ X₂) (g : Y₁ ⟶ Y₂)
[HasTensor X₁ Y₁] [HasTensor X₂ Y₂] [HasTensor X₂ Y₁] :
tensorHom f g = whiskerRight f Y₁ ≫ whiskerLeft X₂ g := by
rw [tensorHom_comp_tensorHom, id_comp, comp_id]
/-- This is the addition map `I × I × I → I` for an additive monoid `I`. -/
def r₁₂₃ : I × I × I → I := fun ⟨i, j, k⟩ => i + j + k
/-- Auxiliary definition for `associator`. -/
@[reducible] def ρ₁₂ : BifunctorComp₁₂IndexData (r₁₂₃ : _ → I) where
I₁₂ := I
p := fun ⟨i₁, i₂⟩ => i₁ + i₂
q := fun ⟨i₁₂, i₃⟩ => i₁₂ + i₃
hpq := fun _ => rfl
/-- Auxiliary definition for `associator`. -/
@[reducible] def ρ₂₃ : BifunctorComp₂₃IndexData (r₁₂₃ : _ → I) where
I₂₃ := I
p := fun ⟨i₂, i₃⟩ => i₂ + i₃
q := fun ⟨i₁₂, i₃⟩ => i₁₂ + i₃
hpq _ := (add_assoc _ _ _).symm
variable (I) in
/-- Auxiliary definition for `associator`. -/
@[reducible]
def triangleIndexData : TriangleIndexData (r₁₂₃ : _ → I) (fun ⟨i₁, i₃⟩ => i₁ + i₃) where
p₁₂ := fun ⟨i₁, i₂⟩ => i₁ + i₂
p₂₃ := fun ⟨i₂, i₃⟩ => i₂ + i₃
hp₁₂ := fun _ => rfl
hp₂₃ := fun _ => (add_assoc _ _ _).symm
h₁ := add_zero
h₃ := zero_add
/-- Given three graded objects `X₁`, `X₂`, `X₃` in `GradedObject I C`, this is the
assumption that for all `i₁₂ : I` and `i₃ : I`, the tensor product functor `- ⊗ X₃ i₃`
commutes with the coproduct of the objects `X₁ i₁ ⊗ X₂ i₂` such that `i₁ + i₂ = i₁₂`. -/
abbrev _root_.CategoryTheory.GradedObject.HasGoodTensor₁₂Tensor (X₁ X₂ X₃ : GradedObject I C) :=
HasGoodTrifunctor₁₂Obj (curriedTensor C) (curriedTensor C) ρ₁₂ X₁ X₂ X₃
/-- Given three graded objects `X₁`, `X₂`, `X₃` in `GradedObject I C`, this is the
assumption that for all `i₁ : I` and `i₂₃ : I`, the tensor product functor `X₁ i₁ ⊗ -`
commutes with the coproduct of the objects `X₂ i₂ ⊗ X₃ i₃` such that `i₂ + i₃ = i₂₃`. -/
abbrev _root_.CategoryTheory.GradedObject.HasGoodTensorTensor₂₃ (X₁ X₂ X₃ : GradedObject I C) :=
HasGoodTrifunctor₂₃Obj (curriedTensor C) (curriedTensor C) ρ₂₃ X₁ X₂ X₃
section
variable (Z : C) (X₁ X₂ X₃ : GradedObject I C)
{Y₁ Y₂ Y₃ : GradedObject I C}
section
variable [HasTensor X₂ X₃] [HasTensor X₁ (tensorObj X₂ X₃)] [HasTensor Y₂ Y₃]
[HasTensor Y₁ (tensorObj Y₂ Y₃)]
/-- The inclusion `X₁ i₁ ⊗ X₂ i₂ ⊗ X₃ i₃ ⟶ tensorObj X₁ (tensorObj X₂ X₃) j`
when `i₁ + i₂ + i₃ = j`. -/
noncomputable def ιTensorObj₃ (i₁ i₂ i₃ j : I) (h : i₁ + i₂ + i₃ = j) :
X₁ i₁ ⊗ X₂ i₂ ⊗ X₃ i₃ ⟶ tensorObj X₁ (tensorObj X₂ X₃) j :=
X₁ i₁ ◁ ιTensorObj X₂ X₃ i₂ i₃ _ rfl ≫ ιTensorObj X₁ (tensorObj X₂ X₃) i₁ (i₂ + i₃) j
(by rw [← add_assoc, h])
@[reassoc]
lemma ιTensorObj₃_eq (i₁ i₂ i₃ j : I) (h : i₁ + i₂ + i₃ = j) (i₂₃ : I) (h' : i₂ + i₃ = i₂₃) :
ιTensorObj₃ X₁ X₂ X₃ i₁ i₂ i₃ j h =
(X₁ i₁ ◁ ιTensorObj X₂ X₃ i₂ i₃ i₂₃ h') ≫
ιTensorObj X₁ (tensorObj X₂ X₃) i₁ i₂₃ j (by rw [← h', ← add_assoc, h]) := by
subst h'
rfl
variable {X₁ X₂ X₃}
@[reassoc (attr := simp)]
lemma ιTensorObj₃_tensorHom (f₁ : X₁ ⟶ Y₁) (f₂ : X₂ ⟶ Y₂) (f₃ : X₃ ⟶ Y₃)
(i₁ i₂ i₃ j : I) (h : i₁ + i₂ + i₃ = j) :
ιTensorObj₃ X₁ X₂ X₃ i₁ i₂ i₃ j h ≫ tensorHom f₁ (tensorHom f₂ f₃) j =
(f₁ i₁ ⊗ₘ f₂ i₂ ⊗ₘ f₃ i₃) ≫ ιTensorObj₃ Y₁ Y₂ Y₃ i₁ i₂ i₃ j h := by
rw [ιTensorObj₃_eq _ _ _ i₁ i₂ i₃ j h _ rfl,
ιTensorObj₃_eq _ _ _ i₁ i₂ i₃ j h _ rfl, assoc, ι_tensorHom,
← id_tensorHom, ← id_tensorHom, MonoidalCategory.tensorHom_comp_tensorHom_assoc, ι_tensorHom,
MonoidalCategory.tensorHom_comp_tensorHom_assoc, id_comp, comp_id]
@[ext (iff := false)]
lemma tensorObj₃_ext {j : I} {A : C} (f g : tensorObj X₁ (tensorObj X₂ X₃) j ⟶ A)
[H : HasGoodTensorTensor₂₃ X₁ X₂ X₃]
(h : ∀ (i₁ i₂ i₃ : I) (hi : i₁ + i₂ + i₃ = j),
ιTensorObj₃ X₁ X₂ X₃ i₁ i₂ i₃ j hi ≫ f = ιTensorObj₃ X₁ X₂ X₃ i₁ i₂ i₃ j hi ≫ g) :
f = g := by
apply mapBifunctorBifunctor₂₃MapObj_ext (H := H)
intro i₁ i₂ i₃ hi
exact h i₁ i₂ i₃ hi
end
section
variable [HasTensor X₁ X₂] [HasTensor (tensorObj X₁ X₂) X₃] [HasTensor Y₁ Y₂]
[HasTensor (tensorObj Y₁ Y₂) Y₃]
/-- The inclusion `X₁ i₁ ⊗ X₂ i₂ ⊗ X₃ i₃ ⟶ tensorObj (tensorObj X₁ X₂) X₃ j`
when `i₁ + i₂ + i₃ = j`. -/
noncomputable def ιTensorObj₃' (i₁ i₂ i₃ j : I) (h : i₁ + i₂ + i₃ = j) :
(X₁ i₁ ⊗ X₂ i₂) ⊗ X₃ i₃ ⟶ tensorObj (tensorObj X₁ X₂) X₃ j :=
(ιTensorObj X₁ X₂ i₁ i₂ (i₁ + i₂) rfl ▷ X₃ i₃) ≫
ιTensorObj (tensorObj X₁ X₂) X₃ (i₁ + i₂) i₃ j h
@[reassoc]
lemma ιTensorObj₃'_eq (i₁ i₂ i₃ j : I) (h : i₁ + i₂ + i₃ = j) (i₁₂ : I)
(h' : i₁ + i₂ = i₁₂) :
ιTensorObj₃' X₁ X₂ X₃ i₁ i₂ i₃ j h =
(ιTensorObj X₁ X₂ i₁ i₂ i₁₂ h' ▷ X₃ i₃) ≫
ιTensorObj (tensorObj X₁ X₂) X₃ i₁₂ i₃ j (by rw [← h', h]) := by
subst h'
rfl
variable {X₁ X₂ X₃}
@[reassoc (attr := simp)]
lemma ιTensorObj₃'_tensorHom (f₁ : X₁ ⟶ Y₁) (f₂ : X₂ ⟶ Y₂) (f₃ : X₃ ⟶ Y₃)
(i₁ i₂ i₃ j : I) (h : i₁ + i₂ + i₃ = j) :
ιTensorObj₃' X₁ X₂ X₃ i₁ i₂ i₃ j h ≫ tensorHom (tensorHom f₁ f₂) f₃ j =
((f₁ i₁ ⊗ₘ f₂ i₂) ⊗ₘ f₃ i₃) ≫ ιTensorObj₃' Y₁ Y₂ Y₃ i₁ i₂ i₃ j h := by
rw [ιTensorObj₃'_eq _ _ _ i₁ i₂ i₃ j h _ rfl,
ιTensorObj₃'_eq _ _ _ i₁ i₂ i₃ j h _ rfl, assoc, ι_tensorHom,
← tensorHom_id, ← tensorHom_id, MonoidalCategory.tensorHom_comp_tensorHom_assoc, id_comp,
ι_tensorHom, MonoidalCategory.tensorHom_comp_tensorHom_assoc, comp_id]
@[ext (iff := false)]
lemma tensorObj₃'_ext {j : I} {A : C} (f g : tensorObj (tensorObj X₁ X₂) X₃ j ⟶ A)
[H : HasGoodTensor₁₂Tensor X₁ X₂ X₃]
(h : ∀ (i₁ i₂ i₃ : I) (h : i₁ + i₂ + i₃ = j),
ιTensorObj₃' X₁ X₂ X₃ i₁ i₂ i₃ j h ≫ f = ιTensorObj₃' X₁ X₂ X₃ i₁ i₂ i₃ j h ≫ g) :
f = g := by
apply mapBifunctor₁₂BifunctorMapObj_ext (H := H)
intro i₁ i₂ i₃ hi
exact h i₁ i₂ i₃ hi
end
section
variable [HasTensor X₁ X₂] [HasTensor (tensorObj X₁ X₂) X₃] [HasTensor X₂ X₃]
[HasTensor X₁ (tensorObj X₂ X₃)]
/-- The associator isomorphism for graded objects. -/
noncomputable def associator [HasGoodTensor₁₂Tensor X₁ X₂ X₃] [HasGoodTensorTensor₂₃ X₁ X₂ X₃] :
tensorObj (tensorObj X₁ X₂) X₃ ≅ tensorObj X₁ (tensorObj X₂ X₃) :=
mapBifunctorAssociator (MonoidalCategory.curriedAssociatorNatIso C) ρ₁₂ ρ₂₃ X₁ X₂ X₃
@[reassoc (attr := simp)]
lemma ιTensorObj₃'_associator_hom
[HasGoodTensor₁₂Tensor X₁ X₂ X₃] [HasGoodTensorTensor₂₃ X₁ X₂ X₃]
(i₁ i₂ i₃ j : I) (h : i₁ + i₂ + i₃ = j) :
ιTensorObj₃' X₁ X₂ X₃ i₁ i₂ i₃ j h ≫ (associator X₁ X₂ X₃).hom j =
(α_ _ _ _).hom ≫ ιTensorObj₃ X₁ X₂ X₃ i₁ i₂ i₃ j h :=
ι_mapBifunctorAssociator_hom (MonoidalCategory.curriedAssociatorNatIso C)
ρ₁₂ ρ₂₃ X₁ X₂ X₃ i₁ i₂ i₃ j h
@[reassoc (attr := simp)]
lemma ιTensorObj₃_associator_inv
[HasGoodTensor₁₂Tensor X₁ X₂ X₃] [HasGoodTensorTensor₂₃ X₁ X₂ X₃]
(i₁ i₂ i₃ j : I) (h : i₁ + i₂ + i₃ = j) :
ιTensorObj₃ X₁ X₂ X₃ i₁ i₂ i₃ j h ≫ (associator X₁ X₂ X₃).inv j =
(α_ _ _ _).inv ≫ ιTensorObj₃' X₁ X₂ X₃ i₁ i₂ i₃ j h :=
ι_mapBifunctorAssociator_inv (MonoidalCategory.curriedAssociatorNatIso C)
ρ₁₂ ρ₂₃ X₁ X₂ X₃ i₁ i₂ i₃ j h
variable {X₁ X₂ X₃}
variable [HasTensor Y₁ Y₂] [HasTensor (tensorObj Y₁ Y₂) Y₃] [HasTensor Y₂ Y₃]
[HasTensor Y₁ (tensorObj Y₂ Y₃)] in
lemma associator_naturality (f₁ : X₁ ⟶ Y₁) (f₂ : X₂ ⟶ Y₂) (f₃ : X₃ ⟶ Y₃)
[HasGoodTensor₁₂Tensor X₁ X₂ X₃] [HasGoodTensorTensor₂₃ X₁ X₂ X₃]
[HasGoodTensor₁₂Tensor Y₁ Y₂ Y₃] [HasGoodTensorTensor₂₃ Y₁ Y₂ Y₃] :
tensorHom (tensorHom f₁ f₂) f₃ ≫ (associator Y₁ Y₂ Y₃).hom =
(associator X₁ X₂ X₃).hom ≫ tensorHom f₁ (tensorHom f₂ f₃) := by
cat_disch
end
/-- Given `Z : C` and three graded objects `X₁`, `X₂` and `X₃` in `GradedObject I C`,
this typeclass expresses that functor `Z ⊗ _` commutes with the coproduct of
the objects `X₁ i₁ ⊗ (X₂ i₂ ⊗ X₃ i₃)` such that `i₁ + i₂ + i₃ = j` for a certain `j`.
See lemma `left_tensor_tensorObj₃_ext`. -/
abbrev _root_.CategoryTheory.GradedObject.HasLeftTensor₃ObjExt (j : I) := PreservesColimit
(Discrete.functor fun (i : { i : (I × I × I) | i.1 + i.2.1 + i.2.2 = j }) ↦
(((mapTrifunctor (bifunctorComp₂₃ (curriedTensor C)
(curriedTensor C)) I I I).obj X₁).obj X₂).obj X₃ i)
((curriedTensor C).obj Z)
variable {X₁ X₂ X₃}
variable [HasTensor X₂ X₃] [HasTensor X₁ (tensorObj X₂ X₃)]
@[ext (iff := false)]
lemma left_tensor_tensorObj₃_ext {j : I} {A : C} (Z : C)
(f g : Z ⊗ tensorObj X₁ (tensorObj X₂ X₃) j ⟶ A)
[H : HasGoodTensorTensor₂₃ X₁ X₂ X₃]
[hZ : HasLeftTensor₃ObjExt Z X₁ X₂ X₃ j]
(h : ∀ (i₁ i₂ i₃ : I) (h : i₁ + i₂ + i₃ = j),
(_ ◁ ιTensorObj₃ X₁ X₂ X₃ i₁ i₂ i₃ j h) ≫ f =
(_ ◁ ιTensorObj₃ X₁ X₂ X₃ i₁ i₂ i₃ j h) ≫ g) : f = g := by
refine (@isColimitOfPreserves C _ C _ _ _ _ ((curriedTensor C).obj Z) _
(isColimitCofan₃MapBifunctorBifunctor₂₃MapObj (H := H) (j := j)) hZ).hom_ext ?_
intro ⟨⟨i₁, i₂, i₃⟩, hi⟩
exact h _ _ _ hi
end
section
variable (X₁ X₂ X₃ X₄ : GradedObject I C)
[HasTensor X₃ X₄] [HasTensor X₂ (tensorObj X₃ X₄)]
[HasTensor X₁ (tensorObj X₂ (tensorObj X₃ X₄))]
/-- The inclusion
`X₁ i₁ ⊗ X₂ i₂ ⊗ X₃ i₃ ⊗ X₄ i₄ ⟶ tensorObj X₁ (tensorObj X₂ (tensorObj X₃ X₄)) j`
when `i₁ + i₂ + i₃ + i₄ = j`. -/
noncomputable def ιTensorObj₄ (i₁ i₂ i₃ i₄ j : I) (h : i₁ + i₂ + i₃ + i₄ = j) :
X₁ i₁ ⊗ X₂ i₂ ⊗ X₃ i₃ ⊗ X₄ i₄ ⟶ tensorObj X₁ (tensorObj X₂ (tensorObj X₃ X₄)) j :=
(_ ◁ ιTensorObj₃ X₂ X₃ X₄ i₂ i₃ i₄ _ rfl) ≫
ιTensorObj X₁ (tensorObj X₂ (tensorObj X₃ X₄)) i₁ (i₂ + i₃ + i₄) j
(by rw [← h, ← add_assoc, ← add_assoc])
lemma ιTensorObj₄_eq (i₁ i₂ i₃ i₄ j : I) (h : i₁ + i₂ + i₃ + i₄ = j) (i₂₃₄ : I)
(hi : i₂ + i₃ + i₄ = i₂₃₄) :
ιTensorObj₄ X₁ X₂ X₃ X₄ i₁ i₂ i₃ i₄ j h =
(_ ◁ ιTensorObj₃ X₂ X₃ X₄ i₂ i₃ i₄ _ hi) ≫
ιTensorObj X₁ (tensorObj X₂ (tensorObj X₃ X₄)) i₁ i₂₃₄ j
(by rw [← hi, ← add_assoc, ← add_assoc, h]) := by
subst hi
rfl
/-- Given four graded objects, this is the condition
`HasLeftTensor₃ObjExt (X₁ i₁) X₂ X₃ X₄ i₂₃₄` for all indices `i₁` and `i₂₃₄`,
see the lemma `tensorObj₄_ext`. -/
abbrev _root_.CategoryTheory.GradedObject.HasTensor₄ObjExt :=
∀ (i₁ i₂₃₄ : I), HasLeftTensor₃ObjExt (X₁ i₁) X₂ X₃ X₄ i₂₃₄
variable {X₁ X₂ X₃ X₄}
@[ext (iff := false)]
lemma tensorObj₄_ext {j : I} {A : C} (f g : tensorObj X₁ (tensorObj X₂ (tensorObj X₃ X₄)) j ⟶ A)
[HasGoodTensorTensor₂₃ X₂ X₃ X₄]
[H : HasTensor₄ObjExt X₁ X₂ X₃ X₄]
(h : ∀ (i₁ i₂ i₃ i₄ : I) (h : i₁ + i₂ + i₃ + i₄ = j),
ιTensorObj₄ X₁ X₂ X₃ X₄ i₁ i₂ i₃ i₄ j h ≫ f =
ιTensorObj₄ X₁ X₂ X₃ X₄ i₁ i₂ i₃ i₄ j h ≫ g) : f = g := by
apply tensorObj_ext
intro i₁ i₂₃₄ h'
apply left_tensor_tensorObj₃_ext
intro i₂ i₃ i₄ h''
have hj : i₁ + i₂ + i₃ + i₄ = j := by simp only [← h', ← h'', add_assoc]
simpa only [assoc, ιTensorObj₄_eq X₁ X₂ X₃ X₄ i₁ i₂ i₃ i₄ j hj i₂₃₄ h''] using h i₁ i₂ i₃ i₄ hj
end
section Pentagon
variable (X₁ X₂ X₃ X₄ : GradedObject I C)
[HasTensor X₁ X₂] [HasTensor X₂ X₃] [HasTensor X₃ X₄]
[HasTensor (tensorObj X₁ X₂) X₃] [HasTensor X₁ (tensorObj X₂ X₃)]
[HasTensor (tensorObj X₂ X₃) X₄] [HasTensor X₂ (tensorObj X₃ X₄)]
[HasTensor (tensorObj (tensorObj X₁ X₂) X₃) X₄]
[HasTensor (tensorObj X₁ (tensorObj X₂ X₃)) X₄]
[HasTensor X₁ (tensorObj (tensorObj X₂ X₃) X₄)]
[HasTensor X₁ (tensorObj X₂ (tensorObj X₃ X₄))]
[HasTensor (tensorObj X₁ X₂) (tensorObj X₃ X₄)]
[HasGoodTensor₁₂Tensor X₁ X₂ X₃] [HasGoodTensorTensor₂₃ X₁ X₂ X₃]
[HasGoodTensor₁₂Tensor X₁ (tensorObj X₂ X₃) X₄]
[HasGoodTensorTensor₂₃ X₁ (tensorObj X₂ X₃) X₄]
[HasGoodTensor₁₂Tensor X₂ X₃ X₄] [HasGoodTensorTensor₂₃ X₂ X₃ X₄]
[HasGoodTensor₁₂Tensor (tensorObj X₁ X₂) X₃ X₄]
[HasGoodTensorTensor₂₃ (tensorObj X₁ X₂) X₃ X₄]
[HasGoodTensor₁₂Tensor X₁ X₂ (tensorObj X₃ X₄)]
[HasGoodTensorTensor₂₃ X₁ X₂ (tensorObj X₃ X₄)]
[HasTensor₄ObjExt X₁ X₂ X₃ X₄]
@[reassoc]
lemma pentagon_inv :
tensorHom (𝟙 X₁) (associator X₂ X₃ X₄).inv ≫ (associator X₁ (tensorObj X₂ X₃) X₄).inv ≫
tensorHom (associator X₁ X₂ X₃).inv (𝟙 X₄) =
(associator X₁ X₂ (tensorObj X₃ X₄)).inv ≫ (associator (tensorObj X₁ X₂) X₃ X₄).inv := by
ext j i₁ i₂ i₃ i₄ h
dsimp only [categoryOfGradedObjects_comp]
conv_lhs =>
rw [ιTensorObj₄_eq X₁ X₂ X₃ X₄ i₁ i₂ i₃ i₄ j h _ rfl, assoc, ι_tensorHom_assoc]
dsimp only [categoryOfGradedObjects_id, id_eq, eq_mpr_eq_cast, cast_eq]
rw [id_tensorHom, ← MonoidalCategory.whiskerLeft_comp_assoc, ιTensorObj₃_associator_inv,
ιTensorObj₃'_eq X₂ X₃ X₄ i₂ i₃ i₄ _ rfl _ rfl, MonoidalCategory.whiskerLeft_comp_assoc,
MonoidalCategory.whiskerLeft_comp_assoc,
← ιTensorObj₃_eq_assoc X₁ (tensorObj X₂ X₃) X₄ i₁ (i₂ + i₃) i₄ j
(by simp only [← add_assoc, h]) _ rfl, ιTensorObj₃_associator_inv_assoc,
ιTensorObj₃'_eq_assoc X₁ (tensorObj X₂ X₃) X₄ i₁ (i₂ + i₃) i₄ j
(by simp only [← add_assoc, h]) (i₁ + i₂ + i₃) (by rw [add_assoc]), ι_tensorHom]
dsimp only [id_eq, eq_mpr_eq_cast, categoryOfGradedObjects_id]
rw [tensorHom_id, whisker_assoc_symm_assoc, Iso.hom_inv_id_assoc,
← MonoidalCategory.comp_whiskerRight_assoc, ← MonoidalCategory.comp_whiskerRight_assoc,
← ιTensorObj₃_eq X₁ X₂ X₃ i₁ i₂ i₃ _ rfl _ rfl, ιTensorObj₃_associator_inv,
MonoidalCategory.comp_whiskerRight_assoc, MonoidalCategory.pentagon_inv_assoc]
conv_rhs =>
rw [ιTensorObj₄_eq X₁ X₂ X₃ X₄ i₁ i₂ i₃ i₄ _ _ _ rfl,
ιTensorObj₃_eq X₂ X₃ X₄ i₂ i₃ i₄ _ rfl _ rfl, assoc,
MonoidalCategory.whiskerLeft_comp_assoc,
← ιTensorObj₃_eq_assoc X₁ X₂ (tensorObj X₃ X₄) i₁ i₂ (i₃ + i₄) j
(by rw [← add_assoc, h]) (i₂ + i₃ + i₄) (by rw [add_assoc]),
ιTensorObj₃_associator_inv_assoc, associator_inv_naturality_right_assoc,
ιTensorObj₃'_eq_assoc X₁ X₂ (tensorObj X₃ X₄) i₁ i₂ (i₃ + i₄) j
(by rw [← add_assoc, h]) _ rfl, whisker_exchange_assoc,
← ιTensorObj₃_eq_assoc (tensorObj X₁ X₂) X₃ X₄ (i₁ + i₂) i₃ i₄ j h _ rfl,
ιTensorObj₃_associator_inv, whiskerRight_tensor_assoc, Iso.hom_inv_id_assoc,
ιTensorObj₃'_eq (tensorObj X₁ X₂) X₃ X₄ (i₁ + i₂) i₃ i₄ j h _ rfl,
← MonoidalCategory.comp_whiskerRight_assoc,
← ιTensorObj₃'_eq X₁ X₂ X₃ i₁ i₂ i₃ _ rfl _ rfl]
lemma pentagon : tensorHom (associator X₁ X₂ X₃).hom (𝟙 X₄) ≫
(associator X₁ (tensorObj X₂ X₃) X₄).hom ≫ tensorHom (𝟙 X₁) (associator X₂ X₃ X₄).hom =
(associator (tensorObj X₁ X₂) X₃ X₄).hom ≫ (associator X₁ X₂ (tensorObj X₃ X₄)).hom := by
rw [← cancel_epi (associator (tensorObj X₁ X₂) X₃ X₄).inv,
← cancel_epi (associator X₁ X₂ (tensorObj X₃ X₄)).inv, Iso.inv_hom_id_assoc,
Iso.inv_hom_id, ← pentagon_inv_assoc]
simp [tensorHom_comp_tensorHom, tensorHom_comp_tensorHom_assoc]
end Pentagon
section TensorUnit
variable [DecidableEq I] [HasInitial C]
/-- The unit of the tensor product on graded objects is `(single₀ I).obj (𝟙_ C)`. -/
noncomputable def tensorUnit : GradedObject I C := (single₀ I).obj (𝟙_ C)
/-- The canonical isomorphism `tensorUnit 0 ≅ 𝟙_ C` -/
noncomputable def tensorUnit₀ : (tensorUnit : GradedObject I C) 0 ≅ 𝟙_ C :=
singleObjApplyIso (0 : I) (𝟙_ C)
/-- `tensorUnit i` is an initial object when `i ≠ 0`. -/
noncomputable def isInitialTensorUnitApply (i : I) (hi : i ≠ 0) :
IsInitial ((tensorUnit : GradedObject I C) i) :=
isInitialSingleObjApply _ _ _ hi
end TensorUnit
section LeftUnitor
variable [DecidableEq I] [HasInitial C]
[∀ X₂, PreservesColimit (Functor.empty.{0} C) ((curriedTensor C).flip.obj X₂)]
(X X' : GradedObject I C)
instance : HasTensor tensorUnit X :=
mapBifunctorLeftUnitor_hasMap _ _ (leftUnitorNatIso C) _ zero_add _
instance : HasMap (((mapBifunctor (curriedTensor C) I I).obj
((single₀ I).obj (𝟙_ C))).obj X) (fun ⟨i₁, i₂⟩ => i₁ + i₂) :=
(inferInstance : HasTensor tensorUnit X)
/-- The left unitor isomorphism for graded objects. -/
noncomputable def leftUnitor : tensorObj tensorUnit X ≅ X :=
mapBifunctorLeftUnitor (curriedTensor C) (𝟙_ C)
(leftUnitorNatIso C) (fun (⟨i₁, i₂⟩ : I × I) => i₁ + i₂) zero_add X
lemma leftUnitor_inv_apply (i : I) :
(leftUnitor X).inv i = (λ_ (X i)).inv ≫ tensorUnit₀.inv ▷ (X i) ≫
ιTensorObj tensorUnit X 0 i i (zero_add i) := rfl
variable {X X'}
@[reassoc (attr := simp)]
lemma leftUnitor_naturality (φ : X ⟶ X') :
tensorHom (𝟙 (tensorUnit)) φ ≫ (leftUnitor X').hom =
(leftUnitor X).hom ≫ φ := by
apply mapBifunctorLeftUnitor_naturality
end LeftUnitor
section RightUnitor
variable [DecidableEq I] [HasInitial C]
[∀ X₁, PreservesColimit (Functor.empty.{0} C) ((curriedTensor C).obj X₁)]
(X X' : GradedObject I C)
instance : HasTensor X tensorUnit :=
mapBifunctorRightUnitor_hasMap (curriedTensor C) _
(rightUnitorNatIso C) _ add_zero _
instance : HasMap (((mapBifunctor (curriedTensor C) I I).obj X).obj
((single₀ I).obj (𝟙_ C))) (fun ⟨i₁, i₂⟩ => i₁ + i₂) :=
(inferInstance : HasTensor X tensorUnit)
/-- The right unitor isomorphism for graded objects. -/
noncomputable def rightUnitor : tensorObj X tensorUnit ≅ X :=
mapBifunctorRightUnitor (curriedTensor C) (𝟙_ C)
(rightUnitorNatIso C) (fun (⟨i₁, i₂⟩ : I × I) => i₁ + i₂) add_zero X
lemma rightUnitor_inv_apply (i : I) :
(rightUnitor X).inv i = (ρ_ (X i)).inv ≫ (X i) ◁ tensorUnit₀.inv ≫
ιTensorObj X tensorUnit i 0 i (add_zero i) := rfl
variable {X X'}
@[reassoc (attr := simp)]
lemma rightUnitor_naturality (φ : X ⟶ X') :
tensorHom φ (𝟙 (tensorUnit)) ≫ (rightUnitor X').hom =
(rightUnitor X).hom ≫ φ := by
apply mapBifunctorRightUnitor_naturality
end RightUnitor
section Triangle
variable [DecidableEq I] [HasInitial C]
[∀ X₁, PreservesColimit (Functor.empty.{0} C) ((curriedTensor C).obj X₁)]
[∀ X₂, PreservesColimit (Functor.empty.{0} C)
((curriedTensor C).flip.obj X₂)]
(X₁ X₃ : GradedObject I C) [HasTensor X₁ X₃]
[HasTensor (tensorObj X₁ tensorUnit) X₃] [HasTensor X₁ (tensorObj tensorUnit X₃)]
[HasGoodTensor₁₂Tensor X₁ tensorUnit X₃] [HasGoodTensorTensor₂₃ X₁ tensorUnit X₃]
lemma triangle :
(associator X₁ tensorUnit X₃).hom ≫ tensorHom (𝟙 X₁) (leftUnitor X₃).hom =
tensorHom (rightUnitor X₁).hom (𝟙 X₃) := by
convert mapBifunctor_triangle (curriedAssociatorNatIso C) (𝟙_ C)
(rightUnitorNatIso C) (leftUnitorNatIso C) (triangleIndexData I) X₁ X₃ (by simp)
all_goals assumption
end Triangle
end Monoidal
section
variable
[∀ (X₁ X₂ : GradedObject I C), HasTensor X₁ X₂]
[∀ (X₁ X₂ X₃ : GradedObject I C), HasGoodTensor₁₂Tensor X₁ X₂ X₃]
[∀ (X₁ X₂ X₃ : GradedObject I C), HasGoodTensorTensor₂₃ X₁ X₂ X₃]
[DecidableEq I] [HasInitial C]
[∀ X₁, PreservesColimit (Functor.empty.{0} C) ((curriedTensor C).obj X₁)]
[∀ X₂, PreservesColimit (Functor.empty.{0} C) ((curriedTensor C).flip.obj X₂)]
[∀ (X₁ X₂ X₃ X₄ : GradedObject I C), HasTensor₄ObjExt X₁ X₂ X₃ X₄]
noncomputable instance monoidalCategory : MonoidalCategory (GradedObject I C) where
tensorObj X Y := Monoidal.tensorObj X Y
tensorHom f g := Monoidal.tensorHom f g
tensorHom_def f g := Monoidal.tensorHom_def f g
whiskerLeft X _ _ φ := Monoidal.whiskerLeft X φ
whiskerRight {_ _ φ Y} := Monoidal.whiskerRight φ Y
tensorUnit := Monoidal.tensorUnit
associator X₁ X₂ X₃ := Monoidal.associator X₁ X₂ X₃
associator_naturality f₁ f₂ f₃ := Monoidal.associator_naturality f₁ f₂ f₃
leftUnitor X := Monoidal.leftUnitor X
leftUnitor_naturality := Monoidal.leftUnitor_naturality
rightUnitor X := Monoidal.rightUnitor X
rightUnitor_naturality := Monoidal.rightUnitor_naturality
tensorHom_comp_tensorHom f₁ f₂ g₁ g₂ := Monoidal.tensorHom_comp_tensorHom f₁ g₁ f₂ g₂
pentagon X₁ X₂ X₃ X₄ := Monoidal.pentagon X₁ X₂ X₃ X₄
triangle X₁ X₂ := Monoidal.triangle X₁ X₂
end
section
instance (n : ℕ) : Finite ((fun (i : ℕ × ℕ) => i.1 + i.2) ⁻¹' {n}) := by
refine Finite.of_injective (fun ⟨⟨i₁, i₂⟩, (hi : i₁ + i₂ = n)⟩ =>
((⟨i₁, by cutsat⟩, ⟨i₂, by cutsat⟩) : Fin (n + 1) × Fin (n + 1) )) ?_
rintro ⟨⟨_, _⟩, _⟩ ⟨⟨_, _⟩, _⟩ h
simpa using h
instance (n : ℕ) : Finite ({ i : (ℕ × ℕ × ℕ) | i.1 + i.2.1 + i.2.2 = n }) := by
refine Finite.of_injective (fun ⟨⟨i₁, i₂, i₃⟩, (hi : i₁ + i₂ + i₃ = n)⟩ =>
(⟨⟨i₁, by cutsat⟩, ⟨i₂, by cutsat⟩, ⟨i₃, by cutsat⟩⟩ :
Fin (n + 1) × Fin (n + 1) × Fin (n + 1))) ?_
rintro ⟨⟨_, _, _⟩, _⟩ ⟨⟨_, _, _⟩, _⟩ h
simpa using h
/-!
The monoidal category structure on `GradedObject ℕ C` can be inferred
from the assumptions `[HasFiniteCoproducts C]`,
`[∀ (X : C), PreservesFiniteCoproducts ((curriedTensor C).obj X)]` and
`[∀ (X : C), PreservesFiniteCoproducts ((curriedTensor C).flip.obj X)]`.
This requires importing `Mathlib/CategoryTheory/Limits/Preserves/Finite.lean`.
-/
end
end GradedObject
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/GradedObject/Bifunctor.lean | import Mathlib.CategoryTheory.GradedObject
/-!
# The action of bifunctors on graded objects
Given a bifunctor `F : C₁ ⥤ C₂ ⥤ C₃` and types `I` and `J`, we construct an obvious functor
`mapBifunctor F I J : GradedObject I C₁ ⥤ GradedObject J C₂ ⥤ GradedObject (I × J) C₃`.
When we have a map `p : I × J → K` and that suitable coproducts exists, we also get
a functor
`mapBifunctorMap F p : GradedObject I C₁ ⥤ GradedObject J C₂ ⥤ GradedObject K C₃`.
In case `p : I × I → I` is the addition on a monoid and `F` is the tensor product on a monoidal
category `C`, these definitions shall be used in order to construct a monoidal structure
on `GradedObject I C` (TODO @joelriou).
-/
namespace CategoryTheory
open Category
variable {C₁ C₂ C₃ : Type*} [Category C₁] [Category C₂] [Category C₃]
(F : C₁ ⥤ C₂ ⥤ C₃)
namespace GradedObject
/-- Given a bifunctor `F : C₁ ⥤ C₂ ⥤ C₃` and types `I` and `J`, this is the obvious
functor `GradedObject I C₁ ⥤ GradedObject J C₂ ⥤ GradedObject (I × J) C₃`. -/
@[simps]
def mapBifunctor (I J : Type*) :
GradedObject I C₁ ⥤ GradedObject J C₂ ⥤ GradedObject (I × J) C₃ where
obj X :=
{ obj := fun Y ij => (F.obj (X ij.1)).obj (Y ij.2)
map := fun φ ij => (F.obj (X ij.1)).map (φ ij.2) }
map φ :=
{ app := fun Y ij => (F.map (φ ij.1)).app (Y ij.2) }
section
variable {I J K : Type*} (p : I × J → K)
/-- Given a bifunctor `F : C₁ ⥤ C₂ ⥤ C₃`, graded objects `X : GradedObject I C₁` and
`Y : GradedObject J C₂` and a map `p : I × J → K`, this is the `K`-graded object sending
`k` to the coproduct of `(F.obj (X i)).obj (Y j)` for `p ⟨i, j⟩ = k`. -/
noncomputable def mapBifunctorMapObj (X : GradedObject I C₁) (Y : GradedObject J C₂)
[HasMap (((mapBifunctor F I J).obj X).obj Y) p] : GradedObject K C₃ :=
(((mapBifunctor F I J).obj X).obj Y).mapObj p
/-- The inclusion of `(F.obj (X i)).obj (Y j)` in `mapBifunctorMapObj F p X Y k`
when `i + j = k`. -/
noncomputable def ιMapBifunctorMapObj
(X : GradedObject I C₁) (Y : GradedObject J C₂)
[HasMap (((mapBifunctor F I J).obj X).obj Y) p]
(i : I) (j : J) (k : K) (h : p ⟨i, j⟩ = k) :
(F.obj (X i)).obj (Y j) ⟶ mapBifunctorMapObj F p X Y k :=
(((mapBifunctor F I J).obj X).obj Y).ιMapObj p ⟨i, j⟩ k h
/-- The maps `mapBifunctorMapObj F p X₁ Y₁ ⟶ mapBifunctorMapObj F p X₂ Y₂` which express
the functoriality of `mapBifunctorMapObj`, see `mapBifunctorMap`. -/
noncomputable def mapBifunctorMapMap {X₁ X₂ : GradedObject I C₁} (f : X₁ ⟶ X₂)
{Y₁ Y₂ : GradedObject J C₂} (g : Y₁ ⟶ Y₂)
[HasMap (((mapBifunctor F I J).obj X₁).obj Y₁) p]
[HasMap (((mapBifunctor F I J).obj X₂).obj Y₂) p] :
mapBifunctorMapObj F p X₁ Y₁ ⟶ mapBifunctorMapObj F p X₂ Y₂ :=
GradedObject.mapMap (((mapBifunctor F I J).map f).app Y₁ ≫
((mapBifunctor F I J).obj X₂).map g) p
@[reassoc (attr := simp)]
lemma ι_mapBifunctorMapMap {X₁ X₂ : GradedObject I C₁} (f : X₁ ⟶ X₂)
{Y₁ Y₂ : GradedObject J C₂} (g : Y₁ ⟶ Y₂)
[HasMap (((mapBifunctor F I J).obj X₁).obj Y₁) p]
[HasMap (((mapBifunctor F I J).obj X₂).obj Y₂) p]
(i : I) (j : J) (k : K) (h : p ⟨i, j⟩ = k) :
ιMapBifunctorMapObj F p X₁ Y₁ i j k h ≫ mapBifunctorMapMap F p f g k =
(F.map (f i)).app (Y₁ j) ≫ (F.obj (X₂ i)).map (g j) ≫
ιMapBifunctorMapObj F p X₂ Y₂ i j k h := by
simp [ιMapBifunctorMapObj, mapBifunctorMapMap]
@[ext]
lemma mapBifunctorMapObj_ext {X : GradedObject I C₁} {Y : GradedObject J C₂} {A : C₃} {k : K}
[HasMap (((mapBifunctor F I J).obj X).obj Y) p]
{f g : mapBifunctorMapObj F p X Y k ⟶ A}
(h : ∀ (i : I) (j : J) (hij : p ⟨i, j⟩ = k),
ιMapBifunctorMapObj F p X Y i j k hij ≫ f = ιMapBifunctorMapObj F p X Y i j k hij ≫ g) :
f = g := by
apply mapObj_ext
rintro ⟨i, j⟩ hij
exact h i j hij
variable {F p} in
/-- Constructor for morphisms from `mapBifunctorMapObj F p X Y k`. -/
noncomputable def mapBifunctorMapObjDesc
{X : GradedObject I C₁} {Y : GradedObject J C₂} {A : C₃} {k : K}
[HasMap (((mapBifunctor F I J).obj X).obj Y) p]
(f : ∀ (i : I) (j : J) (_ : p ⟨i, j⟩ = k), (F.obj (X i)).obj (Y j) ⟶ A) :
mapBifunctorMapObj F p X Y k ⟶ A :=
descMapObj _ _ (fun ⟨i, j⟩ hij => f i j hij)
@[reassoc (attr := simp)]
lemma ι_mapBifunctorMapObjDesc {X : GradedObject I C₁} {Y : GradedObject J C₂} {A : C₃} {k : K}
[HasMap (((mapBifunctor F I J).obj X).obj Y) p]
(f : ∀ (i : I) (j : J) (_ : p ⟨i, j⟩ = k), (F.obj (X i)).obj (Y j) ⟶ A)
(i : I) (j : J) (hij : p ⟨i, j⟩ = k) :
ιMapBifunctorMapObj F p X Y i j k hij ≫ mapBifunctorMapObjDesc f = f i j hij := by
apply ι_descMapObj
section
variable {X₁ X₂ : GradedObject I C₁} {Y₁ Y₂ : GradedObject J C₂}
[HasMap (((mapBifunctor F I J).obj X₁).obj Y₁) p]
[HasMap (((mapBifunctor F I J).obj X₂).obj Y₂) p]
/-- The isomorphism `mapBifunctorMapObj F p X₁ Y₁ ≅ mapBifunctorMapObj F p X₂ Y₂`
induced by isomorphisms `X₁ ≅ X₂` and `Y₁ ≅ Y₂`. -/
@[simps]
noncomputable def mapBifunctorMapMapIso (e : X₁ ≅ X₂) (e' : Y₁ ≅ Y₂) :
mapBifunctorMapObj F p X₁ Y₁ ≅ mapBifunctorMapObj F p X₂ Y₂ where
hom := mapBifunctorMapMap F p e.hom e'.hom
inv := mapBifunctorMapMap F p e.inv e'.inv
hom_inv_id := by ext; simp
inv_hom_id := by ext; simp
instance (f : X₁ ⟶ X₂) (g : Y₁ ⟶ Y₂) [IsIso f] [IsIso g] :
IsIso (mapBifunctorMapMap F p f g) :=
(inferInstance : IsIso (mapBifunctorMapMapIso F p (asIso f) (asIso g)).hom)
end
attribute [local simp] mapBifunctorMapMap
/-- Given a bifunctor `F : C₁ ⥤ C₂ ⥤ C₃` and a map `p : I × J → K`, this is the
functor `GradedObject I C₁ ⥤ GradedObject J C₂ ⥤ GradedObject K C₃` sending
`X : GradedObject I C₁` and `Y : GradedObject J C₂` to the `K`-graded object sending
`k` to the coproduct of `(F.obj (X i)).obj (Y j)` for `p ⟨i, j⟩ = k`. -/
@[simps]
noncomputable def mapBifunctorMap [∀ X Y, HasMap (((mapBifunctor F I J).obj X).obj Y) p] :
GradedObject I C₁ ⥤ GradedObject J C₂ ⥤ GradedObject K C₃ where
obj X :=
{ obj := fun Y => mapBifunctorMapObj F p X Y
map := fun ψ => mapBifunctorMapMap F p (𝟙 X) ψ }
map {X₁ X₂} φ :=
{ app := fun Y => mapBifunctorMapMap F p φ (𝟙 Y)
naturality := fun {Y₁ Y₂} ψ => by
dsimp
simp only [Functor.map_id, NatTrans.id_app, id_comp, comp_id,
← mapMap_comp, NatTrans.naturality] }
end
end GradedObject
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/GradedObject/Single.lean | import Mathlib.CategoryTheory.GradedObject
/-!
# The graded object in a single degree
In this file, we define the functor `GradedObject.single j : C ⥤ GradedObject J C`
which sends an object `X : C` to the graded object which is `X` in degree `j` and
the initial object of `C` in other degrees.
-/
namespace CategoryTheory
open Limits
namespace GradedObject
variable {J : Type*} {C : Type*} [Category C] [HasInitial C] [DecidableEq J]
/-- The functor which sends `X : C` to the graded object which is `X` in degree `j`
and the initial object in other degrees. -/
noncomputable def single (j : J) : C ⥤ GradedObject J C where
obj X i := if i = j then X else ⊥_ C
map {X₁ X₂} f i :=
if h : i = j then eqToHom (if_pos h) ≫ f ≫ eqToHom (if_pos h).symm
else eqToHom (by dsimp; rw [if_neg h, if_neg h])
variable (J) in
/-- The functor which sends `X : C` to the graded object which is `X` in degree `0`
and the initial object in nonzero degrees. -/
noncomputable abbrev single₀ [Zero J] : C ⥤ GradedObject J C := single 0
/-- The canonical isomorphism `(single j).obj X i ≅ X` when `i = j`. -/
noncomputable def singleObjApplyIsoOfEq (j : J) (X : C) (i : J) (h : i = j) :
(single j).obj X i ≅ X := eqToIso (if_pos h)
/-- The canonical isomorphism `(single j).obj X j ≅ X`. -/
noncomputable abbrev singleObjApplyIso (j : J) (X : C) :
(single j).obj X j ≅ X := singleObjApplyIsoOfEq j X j rfl
/-- The object `(single j).obj X i` is initial when `i ≠ j`. -/
noncomputable def isInitialSingleObjApply (j : J) (X : C) (i : J) (h : i ≠ j) :
IsInitial ((single j).obj X i) := by
dsimp [single]
rw [if_neg h]
exact initialIsInitial
lemma singleObjApplyIsoOfEq_inv_single_map (j : J) {X Y : C} (f : X ⟶ Y) (i : J) (h : i = j) :
(singleObjApplyIsoOfEq j X i h).inv ≫ (single j).map f i =
f ≫ (singleObjApplyIsoOfEq j Y i h).inv := by
subst h
simp [singleObjApplyIsoOfEq, single]
lemma single_map_singleObjApplyIsoOfEq_hom (j : J) {X Y : C} (f : X ⟶ Y) (i : J) (h : i = j) :
(single j).map f i ≫ (singleObjApplyIsoOfEq j Y i h).hom =
(singleObjApplyIsoOfEq j X i h).hom ≫ f := by
subst h
simp [singleObjApplyIsoOfEq, single]
@[reassoc (attr := simp)]
lemma singleObjApplyIso_inv_single_map (j : J) {X Y : C} (f : X ⟶ Y) :
(singleObjApplyIso j X).inv ≫ (single j).map f j = f ≫ (singleObjApplyIso j Y).inv := by
apply singleObjApplyIsoOfEq_inv_single_map
@[reassoc (attr := simp)]
lemma single_map_singleObjApplyIso_hom (j : J) {X Y : C} (f : X ⟶ Y) :
(single j).map f j ≫ (singleObjApplyIso j Y).hom = (singleObjApplyIso j X).hom ≫ f := by
apply single_map_singleObjApplyIsoOfEq_hom
variable (C) in
/-- The composition of the single functor `single j : C ⥤ GradedObject J C` and the
evaluation functor `eval j` identifies to the identity functor. -/
@[simps!]
noncomputable def singleCompEval (j : J) : single j ⋙ eval j ≅ 𝟭 C :=
NatIso.ofComponents (singleObjApplyIso j) (by simp)
end GradedObject
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/GradedObject/Trifunctor.lean | import Mathlib.CategoryTheory.GradedObject.Bifunctor
import Mathlib.CategoryTheory.Functor.Trifunctor
/-!
# The action of trifunctors on graded objects
Given a trifunctor `F. C₁ ⥤ C₂ ⥤ C₃ ⥤ C₄` and types `I₁`, `I₂` and `I₃`, we define a functor
`GradedObject I₁ C₁ ⥤ GradedObject I₂ C₂ ⥤ GradedObject I₃ C₃ ⥤ GradedObject (I₁ × I₂ × I₃) C₄`
(see `mapTrifunctor`). When we have a map `p : I₁ × I₂ × I₃ → J` and suitable coproducts
exists, we define a functor
`GradedObject I₁ C₁ ⥤ GradedObject I₂ C₂ ⥤ GradedObject I₃ C₃ ⥤ GradedObject J C₄`
(see `mapTrifunctorMap`) which sends graded objects `X₁`, `X₂`, `X₃` to the graded object
which sets `j` to the coproduct of the objects `((F.obj (X₁ i₁)).obj (X₂ i₂)).obj (X₃ i₃)`
for `p ⟨i₁, i₂, i₃⟩ = j`.
This shall be used in order to construct the associator isomorphism for the monoidal
category structure on `GradedObject I C` induced by a monoidal structure on `C` and
an additive monoid structure on `I` (TODO @joelriou).
-/
namespace CategoryTheory
open Category Limits
variable {C₁ C₂ C₃ C₄ C₁₂ C₂₃ : Type*}
[Category C₁] [Category C₂] [Category C₃] [Category C₄] [Category C₁₂] [Category C₂₃]
namespace GradedObject
section
variable (F F' : C₁ ⥤ C₂ ⥤ C₃ ⥤ C₄)
/-- Auxiliary definition for `mapTrifunctor`. -/
@[simps]
def mapTrifunctorObj {I₁ : Type*} (X₁ : GradedObject I₁ C₁) (I₂ I₃ : Type*) :
GradedObject I₂ C₂ ⥤ GradedObject I₃ C₃ ⥤ GradedObject (I₁ × I₂ × I₃) C₄ where
obj X₂ :=
{ obj := fun X₃ x => ((F.obj (X₁ x.1)).obj (X₂ x.2.1)).obj (X₃ x.2.2)
map := fun {_ _} φ x => ((F.obj (X₁ x.1)).obj (X₂ x.2.1)).map (φ x.2.2) }
map {X₂ Y₂} φ :=
{ app := fun X₃ x => ((F.obj (X₁ x.1)).map (φ x.2.1)).app (X₃ x.2.2) }
/-- Given a trifunctor `F : C₁ ⥤ C₂ ⥤ C₃ ⥤ C₄` and types `I₁`, `I₂`, `I₃`,
this is the obvious functor
`GradedObject I₁ C₁ ⥤ GradedObject I₂ C₂ ⥤ GradedObject I₃ C₃ ⥤ GradedObject (I₁ × I₂ × I₃) C₄`.
-/
@[simps]
def mapTrifunctor (I₁ I₂ I₃ : Type*) :
GradedObject I₁ C₁ ⥤ GradedObject I₂ C₂ ⥤ GradedObject I₃ C₃ ⥤
GradedObject (I₁ × I₂ × I₃) C₄ where
obj X₁ := mapTrifunctorObj F X₁ I₂ I₃
map {X₁ Y₁} φ :=
{ app := fun X₂ =>
{ app := fun X₃ x => ((F.map (φ x.1)).app (X₂ x.2.1)).app (X₃ x.2.2) }
naturality := fun {X₂ Y₂} ψ => by
ext X₃ x
dsimp
simp only [← NatTrans.comp_app]
congr 1
rw [NatTrans.naturality] }
end
section
variable {F F' : C₁ ⥤ C₂ ⥤ C₃ ⥤ C₄}
/-- The natural transformation `mapTrifunctor F I₁ I₂ I₃ ⟶ mapTrifunctor F' I₁ I₂ I₃`
induced by a natural transformation `F ⟶ F` of trifunctors. -/
@[simps]
def mapTrifunctorMapNatTrans (α : F ⟶ F') (I₁ I₂ I₃ : Type*) :
mapTrifunctor F I₁ I₂ I₃ ⟶ mapTrifunctor F' I₁ I₂ I₃ where
app X₁ :=
{ app := fun X₂ =>
{ app := fun _ _ => ((α.app _).app _).app _ }
naturality := fun {X₂ Y₂} φ => by
ext X₃ ⟨i₁, i₂, i₃⟩
dsimp
simp only [← NatTrans.comp_app, NatTrans.naturality] }
naturality := fun {X₁ Y₁} φ => by
ext X₂ X₃ ⟨i₁, i₂, i₃⟩
dsimp
simp only [← NatTrans.comp_app, NatTrans.naturality]
/-- The natural isomorphism `mapTrifunctor F I₁ I₂ I₃ ≅ mapTrifunctor F' I₁ I₂ I₃`
induced by a natural isomorphism `F ≅ F` of trifunctors. -/
@[simps]
def mapTrifunctorMapIso (e : F ≅ F') (I₁ I₂ I₃ : Type*) :
mapTrifunctor F I₁ I₂ I₃ ≅ mapTrifunctor F' I₁ I₂ I₃ where
hom := mapTrifunctorMapNatTrans e.hom I₁ I₂ I₃
inv := mapTrifunctorMapNatTrans e.inv I₁ I₂ I₃
hom_inv_id := by
ext X₁ X₂ X₃ ⟨i₁, i₂, i₃⟩
dsimp
simp only [← NatTrans.comp_app, e.hom_inv_id, NatTrans.id_app]
inv_hom_id := by
ext X₁ X₂ X₃ ⟨i₁, i₂, i₃⟩
dsimp
simp only [← NatTrans.comp_app, e.inv_hom_id, NatTrans.id_app]
end
section
variable (F : C₁ ⥤ C₂ ⥤ C₃ ⥤ C₄)
variable {I₁ I₂ I₃ J : Type*} (p : I₁ × I₂ × I₃ → J)
/-- Given a trifunctor `F : C₁ ⥤ C₂ ⥤ C₃ ⥤ C₃`, graded objects `X₁ : GradedObject I₁ C₁`,
`X₂ : GradedObject I₂ C₂`, `X₃ : GradedObject I₃ C₃`, and a map `p : I₁ × I₂ × I₃ → J`,
this is the `J`-graded object sending `j` to the coproduct of
`((F.obj (X₁ i₁)).obj (X₂ i₂)).obj (X₃ i₃)` for `p ⟨i₁, i₂, i₃⟩ = k`. -/
noncomputable def mapTrifunctorMapObj (X₁ : GradedObject I₁ C₁) (X₂ : GradedObject I₂ C₂)
(X₃ : GradedObject I₃ C₃)
[HasMap ((((mapTrifunctor F I₁ I₂ I₃).obj X₁).obj X₂).obj X₃) p] :
GradedObject J C₄ :=
((((mapTrifunctor F I₁ I₂ I₃).obj X₁).obj X₂).obj X₃).mapObj p
/-- The obvious inclusion
`((F.obj (X₁ i₁)).obj (X₂ i₂)).obj (X₃ i₃) ⟶ mapTrifunctorMapObj F p X₁ X₂ X₃ j` when
`p ⟨i₁, i₂, i₃⟩ = j`. -/
noncomputable def ιMapTrifunctorMapObj (X₁ : GradedObject I₁ C₁) (X₂ : GradedObject I₂ C₂)
(X₃ : GradedObject I₃ C₃) (i₁ : I₁) (i₂ : I₂) (i₃ : I₃) (j : J) (h : p ⟨i₁, i₂, i₃⟩ = j)
[HasMap ((((mapTrifunctor F I₁ I₂ I₃).obj X₁).obj X₂).obj X₃) p] :
((F.obj (X₁ i₁)).obj (X₂ i₂)).obj (X₃ i₃) ⟶ mapTrifunctorMapObj F p X₁ X₂ X₃ j :=
((((mapTrifunctor F I₁ I₂ I₃).obj X₁).obj X₂).obj X₃).ιMapObj p ⟨i₁, i₂, i₃⟩ j h
/-- The maps `mapTrifunctorMapObj F p X₁ X₂ X₃ ⟶ mapTrifunctorMapObj F p Y₁ Y₂ Y₃` which
express the functoriality of `mapTrifunctorMapObj`, see `mapTrifunctorMap` -/
noncomputable def mapTrifunctorMapMap {X₁ Y₁ : GradedObject I₁ C₁} (f₁ : X₁ ⟶ Y₁)
{X₂ Y₂ : GradedObject I₂ C₂} (f₂ : X₂ ⟶ Y₂)
{X₃ Y₃ : GradedObject I₃ C₃} (f₃ : X₃ ⟶ Y₃)
[HasMap ((((mapTrifunctor F I₁ I₂ I₃).obj X₁).obj X₂).obj X₃) p]
[HasMap ((((mapTrifunctor F I₁ I₂ I₃).obj Y₁).obj Y₂).obj Y₃) p] :
mapTrifunctorMapObj F p X₁ X₂ X₃ ⟶ mapTrifunctorMapObj F p Y₁ Y₂ Y₃ :=
GradedObject.mapMap ((((mapTrifunctor F I₁ I₂ I₃).map f₁).app X₂).app X₃ ≫
(((mapTrifunctor F I₁ I₂ I₃).obj Y₁).map f₂).app X₃ ≫
(((mapTrifunctor F I₁ I₂ I₃).obj Y₁).obj Y₂).map f₃) p
@[reassoc (attr := simp)]
lemma ι_mapTrifunctorMapMap {X₁ Y₁ : GradedObject I₁ C₁} (f₁ : X₁ ⟶ Y₁)
{X₂ Y₂ : GradedObject I₂ C₂} (f₂ : X₂ ⟶ Y₂)
{X₃ Y₃ : GradedObject I₃ C₃} (f₃ : X₃ ⟶ Y₃)
[HasMap ((((mapTrifunctor F I₁ I₂ I₃).obj X₁).obj X₂).obj X₃) p]
[HasMap ((((mapTrifunctor F I₁ I₂ I₃).obj Y₁).obj Y₂).obj Y₃) p]
(i₁ : I₁) (i₂ : I₂) (i₃ : I₃) (j : J) (h : p ⟨i₁, i₂, i₃⟩ = j) :
ιMapTrifunctorMapObj F p X₁ X₂ X₃ i₁ i₂ i₃ j h ≫ mapTrifunctorMapMap F p f₁ f₂ f₃ j =
((F.map (f₁ i₁)).app (X₂ i₂)).app (X₃ i₃) ≫
((F.obj (Y₁ i₁)).map (f₂ i₂)).app (X₃ i₃) ≫
((F.obj (Y₁ i₁)).obj (Y₂ i₂)).map (f₃ i₃) ≫
ιMapTrifunctorMapObj F p Y₁ Y₂ Y₃ i₁ i₂ i₃ j h := by
dsimp only [ιMapTrifunctorMapObj, mapTrifunctorMapMap]
rw [ι_mapMap]
dsimp
rw [assoc, assoc]
@[ext]
lemma mapTrifunctorMapObj_ext {X₁ : GradedObject I₁ C₁} {X₂ : GradedObject I₂ C₂}
{X₃ : GradedObject I₃ C₃} {Y : C₄} (j : J)
[HasMap ((((mapTrifunctor F I₁ I₂ I₃).obj X₁).obj X₂).obj X₃) p]
{φ φ' : mapTrifunctorMapObj F p X₁ X₂ X₃ j ⟶ Y}
(h : ∀ (i₁ : I₁) (i₂ : I₂) (i₃ : I₃) (h : p ⟨i₁, i₂, i₃⟩ = j),
ιMapTrifunctorMapObj F p X₁ X₂ X₃ i₁ i₂ i₃ j h ≫ φ =
ιMapTrifunctorMapObj F p X₁ X₂ X₃ i₁ i₂ i₃ j h ≫ φ') : φ = φ' := by
apply mapObj_ext
rintro ⟨i₁, i₂, i₃⟩ hi
apply h
instance (X₁ : GradedObject I₁ C₁) (X₂ : GradedObject I₂ C₂) (X₃ : GradedObject I₃ C₃)
[h : HasMap ((((mapTrifunctor F I₁ I₂ I₃).obj X₁).obj X₂).obj X₃) p] :
HasMap (((mapTrifunctorObj F X₁ I₂ I₃).obj X₂).obj X₃) p := h
/-- Given a trifunctor `F : C₁ ⥤ C₂ ⥤ C₃ ⥤ C₄`, a map `p : I₁ × I₂ × I₃ → J`, and
graded objects `X₁ : GradedObject I₁ C₁`, `X₂ : GradedObject I₂ C₂` and `X₃ : GradedObject I₃ C₃`,
this is the `J`-graded object sending `j` to the coproduct of
`((F.obj (X₁ i₁)).obj (X₂ i₂)).obj (X₃ i₃)` for `p ⟨i₁, i₂, i₃⟩ = j`. -/
@[simps]
noncomputable def mapTrifunctorMapFunctorObj (X₁ : GradedObject I₁ C₁)
[∀ X₂ X₃, HasMap ((((mapTrifunctor F I₁ I₂ I₃).obj X₁).obj X₂).obj X₃) p] :
GradedObject I₂ C₂ ⥤ GradedObject I₃ C₃ ⥤ GradedObject J C₄ where
obj X₂ :=
{ obj := fun X₃ => mapTrifunctorMapObj F p X₁ X₂ X₃
map := fun {_ _} φ => mapTrifunctorMapMap F p (𝟙 X₁) (𝟙 X₂) φ
map_id := fun X₃ => by
ext j i₁ i₂ i₃ h
simp only [ι_mapTrifunctorMapMap, categoryOfGradedObjects_id, Functor.map_id,
NatTrans.id_app, id_comp, comp_id]
map_comp := fun {X₃ Y₃ Z₃} φ ψ => by
ext j i₁ i₂ i₃ h
simp only [ι_mapTrifunctorMapMap, categoryOfGradedObjects_id, Functor.map_id,
NatTrans.id_app, categoryOfGradedObjects_comp, Functor.map_comp, assoc, id_comp,
ι_mapTrifunctorMapMap_assoc] }
map {X₂ Y₂} φ :=
{ app := fun X₃ => mapTrifunctorMapMap F p (𝟙 X₁) φ (𝟙 X₃)
naturality := fun {X₃ Y₃} ψ => by
ext j i₁ i₂ i₃ h
dsimp
simp only [ι_mapTrifunctorMapMap_assoc, categoryOfGradedObjects_id, Functor.map_id,
NatTrans.id_app, ι_mapTrifunctorMapMap, id_comp, NatTrans.naturality_assoc] }
map_id X₂ := by
ext X₃ j i₁ i₂ i₃ h
simp only [ι_mapTrifunctorMapMap, categoryOfGradedObjects_id, Functor.map_id,
NatTrans.id_app, id_comp, comp_id]
map_comp {X₂ Y₂ Z₂} φ ψ := by
ext X₃ j i₁ i₂ i₃
simp only [ι_mapTrifunctorMapMap, categoryOfGradedObjects_id, Functor.map_id,
NatTrans.id_app, categoryOfGradedObjects_comp, Functor.map_comp, NatTrans.comp_app,
id_comp, assoc, ι_mapTrifunctorMapMap_assoc]
/-- Given a trifunctor `F : C₁ ⥤ C₂ ⥤ C₃ ⥤ C₄` and a map `p : I₁ × I₂ × I₃ → J`,
this is the functor
`GradedObject I₁ C₁ ⥤ GradedObject I₂ C₂ ⥤ GradedObject I₃ C₃ ⥤ GradedObject J C₄`
sending `X₁ : GradedObject I₁ C₁`, `X₂ : GradedObject I₂ C₂` and `X₃ : GradedObject I₃ C₃`
to the `J`-graded object sending `j` to the coproduct of
`((F.obj (X₁ i₁)).obj (X₂ i₂)).obj (X₃ i₃)` for `p ⟨i₁, i₂, i₃⟩ = j`. -/
noncomputable def mapTrifunctorMap
[∀ X₁ X₂ X₃, HasMap ((((mapTrifunctor F I₁ I₂ I₃).obj X₁).obj X₂).obj X₃) p] :
GradedObject I₁ C₁ ⥤ GradedObject I₂ C₂ ⥤ GradedObject I₃ C₃ ⥤ GradedObject J C₄ where
obj X₁ := mapTrifunctorMapFunctorObj F p X₁
map := fun {X₁ Y₁} φ =>
{ app := fun X₂ =>
{ app := fun X₃ => mapTrifunctorMapMap F p φ (𝟙 X₂) (𝟙 X₃)
naturality := fun {X₃ Y₃} φ => by
dsimp
ext j i₁ i₂ i₃ h
dsimp
simp only [ι_mapTrifunctorMapMap_assoc, categoryOfGradedObjects_id, Functor.map_id,
NatTrans.id_app, ι_mapTrifunctorMapMap, id_comp, NatTrans.naturality_assoc] }
naturality := fun {X₂ Y₂} ψ => by
ext X₃ j
dsimp
ext i₁ i₂ i₃ h
simp only [ι_mapTrifunctorMapMap_assoc, categoryOfGradedObjects_id, Functor.map_id,
NatTrans.id_app, ι_mapTrifunctorMapMap, id_comp,
NatTrans.naturality_app_assoc] }
attribute [simps] mapTrifunctorMap
end
section
variable (F₁₂ : C₁ ⥤ C₂ ⥤ C₁₂) (G : C₁₂ ⥤ C₃ ⥤ C₄)
{I₁ I₂ I₃ J : Type*} (r : I₁ × I₂ × I₃ → J)
/-- Given a map `r : I₁ × I₂ × I₃ → J`, a `BifunctorComp₁₂IndexData r` consists of the data
of a type `I₁₂`, maps `p : I₁ × I₂ → I₁₂` and `q : I₁₂ × I₃ → J`, such that `r` is obtained
by composition of `p` and `q`. -/
structure BifunctorComp₁₂IndexData where
/-- an auxiliary type -/
I₁₂ : Type*
/-- a map `I₁ × I₂ → I₁₂` -/
p : I₁ × I₂ → I₁₂
/-- a map `I₁₂ × I₃ → J` -/
q : I₁₂ × I₃ → J
hpq (i : I₁ × I₂ × I₃) : q ⟨p ⟨i.1, i.2.1⟩, i.2.2⟩ = r i
variable {r} (ρ₁₂ : BifunctorComp₁₂IndexData r)
(X₁ : GradedObject I₁ C₁) (X₂ : GradedObject I₂ C₂) (X₃ : GradedObject I₃ C₃)
/-- Given bifunctors `F₁₂ : C₁ ⥤ C₂ ⥤ C₁₂`, `G : C₁₂ ⥤ C₃ ⥤ C₄`, graded objects
`X₁ : GradedObject I₁ C₁`, `X₂ : GradedObject I₂ C₂`, `X₃ : GradedObject I₃ C₃` and
`ρ₁₂ : BifunctorComp₁₂IndexData r`, this asserts that for all `i₁₂ : ρ₁₂.I₁₂` and `i₃ : I₃`,
the functor `G(-, X₃ i₃)` commutes with the coproducts of the `F₁₂(X₁ i₁, X₂ i₂)`
such that `ρ₁₂.p ⟨i₁, i₂⟩ = i₁₂`. -/
abbrev HasGoodTrifunctor₁₂Obj :=
∀ (i₁₂ : ρ₁₂.I₁₂) (i₃ : I₃), PreservesColimit
(Discrete.functor (mapObjFun (((mapBifunctor F₁₂ I₁ I₂).obj X₁).obj X₂) ρ₁₂.p i₁₂))
((Functor.flip G).obj (X₃ i₃))
variable [HasMap (((mapBifunctor F₁₂ I₁ I₂).obj X₁).obj X₂) ρ₁₂.p]
[HasMap (((mapBifunctor G ρ₁₂.I₁₂ I₃).obj (mapBifunctorMapObj F₁₂ ρ₁₂.p X₁ X₂)).obj X₃) ρ₁₂.q]
/-- The inclusion of `(G.obj ((F₁₂.obj (X₁ i₁)).obj (X₂ i₂))).obj (X₃ i₃)` in
`mapBifunctorMapObj G ρ₁₂.q (mapBifunctorMapObj F₁₂ ρ₁₂.p X₁ X₂) X₃ j`
when `r (i₁, i₂, i₃) = j`. -/
noncomputable def ιMapBifunctor₁₂BifunctorMapObj (i₁ : I₁) (i₂ : I₂) (i₃ : I₃) (j : J)
(h : r (i₁, i₂, i₃) = j) :
(G.obj ((F₁₂.obj (X₁ i₁)).obj (X₂ i₂))).obj (X₃ i₃) ⟶
mapBifunctorMapObj G ρ₁₂.q (mapBifunctorMapObj F₁₂ ρ₁₂.p X₁ X₂) X₃ j :=
(G.map (ιMapBifunctorMapObj F₁₂ ρ₁₂.p X₁ X₂ i₁ i₂ _ rfl)).app (X₃ i₃) ≫
ιMapBifunctorMapObj G ρ₁₂.q (mapBifunctorMapObj F₁₂ ρ₁₂.p X₁ X₂) X₃ (ρ₁₂.p ⟨i₁, i₂⟩) i₃ j
(by rw [← h, ← ρ₁₂.hpq])
@[reassoc]
lemma ιMapBifunctor₁₂BifunctorMapObj_eq (i₁ : I₁) (i₂ : I₂) (i₃ : I₃) (j : J)
(h : r (i₁, i₂, i₃) = j) (i₁₂ : ρ₁₂.I₁₂) (h₁₂ : ρ₁₂.p ⟨i₁, i₂⟩ = i₁₂) :
ιMapBifunctor₁₂BifunctorMapObj F₁₂ G ρ₁₂ X₁ X₂ X₃ i₁ i₂ i₃ j h =
(G.map (ιMapBifunctorMapObj F₁₂ ρ₁₂.p X₁ X₂ i₁ i₂ i₁₂ h₁₂)).app (X₃ i₃) ≫
ιMapBifunctorMapObj G ρ₁₂.q (mapBifunctorMapObj F₁₂ ρ₁₂.p X₁ X₂) X₃ i₁₂ i₃ j
(by rw [← h₁₂, ← h, ← ρ₁₂.hpq]) := by
subst h₁₂
rfl
/-- The cofan consisting of the inclusions given by `ιMapBifunctor₁₂BifunctorMapObj`. -/
noncomputable def cofan₃MapBifunctor₁₂BifunctorMapObj (j : J) :
((((mapTrifunctor (bifunctorComp₁₂ F₁₂ G) I₁ I₂ I₃).obj X₁).obj X₂).obj
X₃).CofanMapObjFun r j :=
Cofan.mk (mapBifunctorMapObj G ρ₁₂.q (mapBifunctorMapObj F₁₂ ρ₁₂.p X₁ X₂) X₃ j)
(fun ⟨⟨i₁, i₂, i₃⟩, (hi : r ⟨i₁, i₂, i₃⟩ = j)⟩ =>
ιMapBifunctor₁₂BifunctorMapObj F₁₂ G ρ₁₂ X₁ X₂ X₃ i₁ i₂ i₃ j hi)
variable [H : HasGoodTrifunctor₁₂Obj F₁₂ G ρ₁₂ X₁ X₂ X₃]
/-- The cofan `cofan₃MapBifunctor₁₂BifunctorMapObj` is a colimit, see the induced isomorphism
`mapBifunctorComp₁₂MapObjIso`. -/
noncomputable def isColimitCofan₃MapBifunctor₁₂BifunctorMapObj (j : J) :
IsColimit (cofan₃MapBifunctor₁₂BifunctorMapObj F₁₂ G ρ₁₂ X₁ X₂ X₃ j) := by
let c₁₂ := fun i₁₂ => (((mapBifunctor F₁₂ I₁ I₂).obj X₁).obj X₂).cofanMapObj ρ₁₂.p i₁₂
have h₁₂ : ∀ i₁₂, IsColimit (c₁₂ i₁₂) := fun i₁₂ =>
(((mapBifunctor F₁₂ I₁ I₂).obj X₁).obj X₂).isColimitCofanMapObj ρ₁₂.p i₁₂
let c := (((mapBifunctor G ρ₁₂.I₁₂ I₃).obj
(mapBifunctorMapObj F₁₂ ρ₁₂.p X₁ X₂)).obj X₃).cofanMapObj ρ₁₂.q j
have hc : IsColimit c := (((mapBifunctor G ρ₁₂.I₁₂ I₃).obj
(mapBifunctorMapObj F₁₂ ρ₁₂.p X₁ X₂)).obj X₃).isColimitCofanMapObj ρ₁₂.q j
let c₁₂' := fun (i : ρ₁₂.q ⁻¹' {j}) => (G.flip.obj (X₃ i.1.2)).mapCocone (c₁₂ i.1.1)
have hc₁₂' : ∀ i, IsColimit (c₁₂' i) := fun i => isColimitOfPreserves _ (h₁₂ i.1.1)
let Z := (((mapTrifunctor (bifunctorComp₁₂ F₁₂ G) I₁ I₂ I₃).obj X₁).obj X₂).obj X₃
let p' : I₁ × I₂ × I₃ → ρ₁₂.I₁₂ × I₃ := fun ⟨i₁, i₂, i₃⟩ => ⟨ρ₁₂.p ⟨i₁, i₂⟩, i₃⟩
let e : ∀ (i₁₂ : ρ₁₂.I₁₂) (i₃ : I₃), p' ⁻¹' {(i₁₂, i₃)} ≃ ρ₁₂.p ⁻¹' {i₁₂} := fun i₁₂ i₃ =>
{ toFun := fun ⟨⟨i₁, i₂, i₃'⟩, hi⟩ => ⟨⟨i₁, i₂⟩, by cat_disch⟩
invFun := fun ⟨⟨i₁, i₂⟩, hi⟩ => ⟨⟨i₁, i₂, i₃⟩, by cat_disch⟩
left_inv := fun ⟨⟨i₁, i₂, i₃'⟩, hi⟩ => by
obtain rfl : i₃ = i₃' := by cat_disch
rfl }
let c₁₂'' : ∀ (i : ρ₁₂.q ⁻¹' {j}), CofanMapObjFun Z p' (i.1.1, i.1.2) :=
fun ⟨⟨i₁₂, i₃⟩, hi⟩ => by
refine (Cocones.precompose (Iso.hom ?_)).obj ((Cocones.whiskeringEquivalence
(Discrete.equivalence (e i₁₂ i₃))).functor.obj (c₁₂' ⟨⟨i₁₂, i₃⟩, hi⟩))
refine (Discrete.natIso (fun ⟨⟨i₁, i₂, i₃'⟩, hi⟩ =>
(G.obj ((F₁₂.obj (X₁ i₁)).obj (X₂ i₂))).mapIso (eqToIso ?_)))
obtain rfl : i₃' = i₃ := congr_arg _root_.Prod.snd hi
rfl
have h₁₂'' : ∀ i, IsColimit (c₁₂'' i) := fun _ =>
(IsColimit.precomposeHomEquiv _ _).symm (IsColimit.whiskerEquivalenceEquiv _ (hc₁₂' _))
refine IsColimit.ofIsoColimit (isColimitCofanMapObjComp Z p' ρ₁₂.q r ρ₁₂.hpq j
(fun ⟨i₁₂, i₃⟩ h => c₁₂'' ⟨⟨i₁₂, i₃⟩, h⟩) (fun ⟨i₁₂, i₃⟩ h => h₁₂'' ⟨⟨i₁₂, i₃⟩, h⟩) c hc)
(Cocones.ext (Iso.refl _) (fun ⟨⟨i₁, i₂, i₃⟩, h⟩ => ?_))
dsimp [Cofan.inj, c₁₂'', Z, p']
rw [comp_id, Functor.map_id, id_comp]
rfl
variable {F₁₂ G ρ₁₂ X₁ X₂ X₃}
include ρ₁₂ in
lemma HasGoodTrifunctor₁₂Obj.hasMap :
HasMap ((((mapTrifunctor (bifunctorComp₁₂ F₁₂ G) I₁ I₂ I₃).obj X₁).obj X₂).obj X₃) r :=
fun j => ⟨_, isColimitCofan₃MapBifunctor₁₂BifunctorMapObj F₁₂ G ρ₁₂ X₁ X₂ X₃ j⟩
variable (F₁₂ G ρ₁₂ X₁ X₂ X₃)
section
variable [HasMap ((((mapTrifunctor (bifunctorComp₁₂ F₁₂ G) I₁ I₂ I₃).obj X₁).obj X₂).obj X₃) r]
/-- The action on graded objects of a trifunctor obtained by composition of two
bifunctors can be computed as a composition of the actions of these two bifunctors. -/
noncomputable def mapBifunctorComp₁₂MapObjIso :
mapTrifunctorMapObj (bifunctorComp₁₂ F₁₂ G) r X₁ X₂ X₃ ≅
mapBifunctorMapObj G ρ₁₂.q (mapBifunctorMapObj F₁₂ ρ₁₂.p X₁ X₂) X₃ :=
isoMk _ _ (fun j => (CofanMapObjFun.iso
(isColimitCofan₃MapBifunctor₁₂BifunctorMapObj F₁₂ G ρ₁₂ X₁ X₂ X₃ j)).symm)
@[reassoc (attr := simp)]
lemma ι_mapBifunctorComp₁₂MapObjIso_hom (i₁ : I₁) (i₂ : I₂) (i₃ : I₃) (j : J)
(h : r (i₁, i₂, i₃) = j) :
ιMapTrifunctorMapObj (bifunctorComp₁₂ F₁₂ G) r X₁ X₂ X₃ i₁ i₂ i₃ j h ≫
(mapBifunctorComp₁₂MapObjIso F₁₂ G ρ₁₂ X₁ X₂ X₃).hom j =
ιMapBifunctor₁₂BifunctorMapObj F₁₂ G ρ₁₂ X₁ X₂ X₃ i₁ i₂ i₃ j h := by
dsimp [mapBifunctorComp₁₂MapObjIso]
apply CofanMapObjFun.ιMapObj_iso_inv
@[reassoc (attr := simp)]
lemma ι_mapBifunctorComp₁₂MapObjIso_inv (i₁ : I₁) (i₂ : I₂) (i₃ : I₃) (j : J)
(h : r (i₁, i₂, i₃) = j) :
ιMapBifunctor₁₂BifunctorMapObj F₁₂ G ρ₁₂ X₁ X₂ X₃ i₁ i₂ i₃ j h ≫
(mapBifunctorComp₁₂MapObjIso F₁₂ G ρ₁₂ X₁ X₂ X₃).inv j =
ιMapTrifunctorMapObj (bifunctorComp₁₂ F₁₂ G) r X₁ X₂ X₃ i₁ i₂ i₃ j h :=
CofanMapObjFun.inj_iso_hom
(isColimitCofan₃MapBifunctor₁₂BifunctorMapObj F₁₂ G ρ₁₂ X₁ X₂ X₃ j) _ h
end
variable {X₁ X₂ X₃ F₁₂ G ρ₁₂}
variable {j : J} {A : C₄}
@[ext]
lemma mapBifunctor₁₂BifunctorMapObj_ext {A : C₄}
{f g : mapBifunctorMapObj G ρ₁₂.q (mapBifunctorMapObj F₁₂ ρ₁₂.p X₁ X₂) X₃ j ⟶ A}
(h : ∀ (i₁ : I₁) (i₂ : I₂) (i₃ : I₃) (h : r ⟨i₁, i₂, i₃⟩ = j),
ιMapBifunctor₁₂BifunctorMapObj F₁₂ G ρ₁₂ X₁ X₂ X₃ i₁ i₂ i₃ j h ≫ f =
ιMapBifunctor₁₂BifunctorMapObj F₁₂ G ρ₁₂ X₁ X₂ X₃ i₁ i₂ i₃ j h ≫ g) : f = g := by
apply Cofan.IsColimit.hom_ext (isColimitCofan₃MapBifunctor₁₂BifunctorMapObj F₁₂ G ρ₁₂ X₁ X₂ X₃ j)
rintro ⟨i, hi⟩
exact h _ _ _ hi
section
variable (f : ∀ (i₁ : I₁) (i₂ : I₂) (i₃ : I₃) (_ : r ⟨i₁, i₂, i₃⟩ = j),
(G.obj ((F₁₂.obj (X₁ i₁)).obj (X₂ i₂))).obj (X₃ i₃) ⟶ A)
/-- Constructor for morphisms from
`mapBifunctorMapObj G ρ₁₂.q (mapBifunctorMapObj F₁₂ ρ₁₂.p X₁ X₂) X₃ j`. -/
noncomputable def mapBifunctor₁₂BifunctorDesc :
mapBifunctorMapObj G ρ₁₂.q (mapBifunctorMapObj F₁₂ ρ₁₂.p X₁ X₂) X₃ j ⟶ A :=
Cofan.IsColimit.desc (isColimitCofan₃MapBifunctor₁₂BifunctorMapObj F₁₂ G ρ₁₂ X₁ X₂ X₃ j)
(fun i ↦ f i.1.1 i.1.2.1 i.1.2.2 i.2)
@[reassoc (attr := simp)]
lemma ι_mapBifunctor₁₂BifunctorDesc
(i₁ : I₁) (i₂ : I₂) (i₃ : I₃) (h : r ⟨i₁, i₂, i₃⟩ = j) :
ιMapBifunctor₁₂BifunctorMapObj F₁₂ G ρ₁₂ X₁ X₂ X₃ i₁ i₂ i₃ j h ≫
mapBifunctor₁₂BifunctorDesc f = f i₁ i₂ i₃ h :=
Cofan.IsColimit.fac
(isColimitCofan₃MapBifunctor₁₂BifunctorMapObj F₁₂ G ρ₁₂ X₁ X₂ X₃ j) _ ⟨_, h⟩
end
end
section
variable (F : C₁ ⥤ C₂₃ ⥤ C₄) (G₂₃ : C₂ ⥤ C₃ ⥤ C₂₃)
{I₁ I₂ I₃ J : Type*} (r : I₁ × I₂ × I₃ → J)
/-- Given a map `r : I₁ × I₂ × I₃ → J`, a `BifunctorComp₂₃IndexData r` consists of the data
of a type `I₂₃`, maps `p : I₂ × I₃ → I₂₃` and `q : I₁ × I₂₃ → J`, such that `r` is obtained
by composition of `p` and `q`. -/
structure BifunctorComp₂₃IndexData where
/-- an auxiliary type -/
I₂₃ : Type*
/-- a map `I₂ × I₃ → I₂₃` -/
p : I₂ × I₃ → I₂₃
/-- a map `I₁ × I₂₃ → J` -/
q : I₁ × I₂₃ → J
hpq (i : I₁ × I₂ × I₃) : q ⟨i.1, p i.2⟩ = r i
variable {r} (ρ₂₃ : BifunctorComp₂₃IndexData r)
(X₁ : GradedObject I₁ C₁) (X₂ : GradedObject I₂ C₂) (X₃ : GradedObject I₃ C₃)
/-- Given bifunctors `F : C₁ ⥤ C₂₃ ⥤ C₄`, `G₂₃ : C₂ ⥤ C₃ ⥤ C₂₃`, graded objects
`X₁ : GradedObject I₁ C₁`, `X₂ : GradedObject I₂ C₂`, `X₃ : GradedObject I₃ C₃` and
`ρ₂₃ : BifunctorComp₂₃IndexData r`, this asserts that for all `i₁ : I₁` and `i₂₃ : ρ₂₃.I₂₃`,
the functor `F(X₁ i₁, _)` commutes with the coproducts of the `G₂₃(X₂ i₂, X₃ i₃)`
such that `ρ₂₃.p ⟨i₂, i₃⟩ = i₂₃`. -/
abbrev HasGoodTrifunctor₂₃Obj :=
∀ (i₁ : I₁) (i₂₃ : ρ₂₃.I₂₃), PreservesColimit (Discrete.functor
(mapObjFun (((mapBifunctor G₂₃ I₂ I₃).obj X₂).obj X₃) ρ₂₃.p i₂₃)) (F.obj (X₁ i₁))
variable [HasMap (((mapBifunctor G₂₃ I₂ I₃).obj X₂).obj X₃) ρ₂₃.p]
[HasMap (((mapBifunctor F I₁ ρ₂₃.I₂₃).obj X₁).obj (mapBifunctorMapObj G₂₃ ρ₂₃.p X₂ X₃)) ρ₂₃.q]
/-- The inclusion of `(F.obj (X₁ i₁)).obj ((G₂₃.obj (X₂ i₂)).obj (X₃ i₃))` in
`mapBifunctorMapObj F ρ₂₃.q X₁ (mapBifunctorMapObj G₂₃ ρ₂₃.p X₂ X₃) j`
when `r (i₁, i₂, i₃) = j`. -/
noncomputable def ιMapBifunctorBifunctor₂₃MapObj (i₁ : I₁) (i₂ : I₂) (i₃ : I₃) (j : J)
(h : r (i₁, i₂, i₃) = j) :
(F.obj (X₁ i₁)).obj ((G₂₃.obj (X₂ i₂)).obj (X₃ i₃)) ⟶
mapBifunctorMapObj F ρ₂₃.q X₁ (mapBifunctorMapObj G₂₃ ρ₂₃.p X₂ X₃) j :=
(F.obj (X₁ i₁)).map (ιMapBifunctorMapObj G₂₃ ρ₂₃.p X₂ X₃ i₂ i₃ _ rfl) ≫
ιMapBifunctorMapObj F ρ₂₃.q X₁ (mapBifunctorMapObj G₂₃ ρ₂₃.p X₂ X₃) i₁ (ρ₂₃.p ⟨i₂, i₃⟩) j
(by rw [← h, ← ρ₂₃.hpq])
@[reassoc]
lemma ιMapBifunctorBifunctor₂₃MapObj_eq (i₁ : I₁) (i₂ : I₂) (i₃ : I₃) (j : J)
(h : r (i₁, i₂, i₃) = j) (i₂₃ : ρ₂₃.I₂₃) (h₂₃ : ρ₂₃.p ⟨i₂, i₃⟩ = i₂₃) :
ιMapBifunctorBifunctor₂₃MapObj F G₂₃ ρ₂₃ X₁ X₂ X₃ i₁ i₂ i₃ j h =
(F.obj (X₁ i₁)).map (ιMapBifunctorMapObj G₂₃ ρ₂₃.p X₂ X₃ i₂ i₃ i₂₃ h₂₃) ≫
ιMapBifunctorMapObj F ρ₂₃.q X₁ (mapBifunctorMapObj G₂₃ ρ₂₃.p X₂ X₃) i₁ i₂₃ j
(by rw [← h, ← h₂₃, ← ρ₂₃.hpq]) := by
subst h₂₃
rfl
/-- The cofan consisting of the inclusions given by `ιMapBifunctorBifunctor₂₃MapObj`. -/
noncomputable def cofan₃MapBifunctorBifunctor₂₃MapObj (j : J) :
((((mapTrifunctor (bifunctorComp₂₃ F G₂₃) I₁ I₂ I₃).obj X₁).obj X₂).obj
X₃).CofanMapObjFun r j :=
Cofan.mk (mapBifunctorMapObj F ρ₂₃.q X₁ (mapBifunctorMapObj G₂₃ ρ₂₃.p X₂ X₃) j)
(fun ⟨⟨i₁, i₂, i₃⟩, (hi : r ⟨i₁, i₂, i₃⟩ = j)⟩ =>
ιMapBifunctorBifunctor₂₃MapObj F G₂₃ ρ₂₃ X₁ X₂ X₃ i₁ i₂ i₃ j hi)
variable [H : HasGoodTrifunctor₂₃Obj F G₂₃ ρ₂₃ X₁ X₂ X₃]
/-- The cofan `cofan₃MapBifunctorBifunctor₂₃MapObj` is a colimit, see the induced isomorphism
`mapBifunctorComp₁₂MapObjIso`. -/
noncomputable def isColimitCofan₃MapBifunctorBifunctor₂₃MapObj (j : J) :
IsColimit (cofan₃MapBifunctorBifunctor₂₃MapObj F G₂₃ ρ₂₃ X₁ X₂ X₃ j) := by
let c₂₃ := fun i₂₃ => (((mapBifunctor G₂₃ I₂ I₃).obj X₂).obj X₃).cofanMapObj ρ₂₃.p i₂₃
have h₂₃ : ∀ i₂₃, IsColimit (c₂₃ i₂₃) := fun i₂₃ =>
(((mapBifunctor G₂₃ I₂ I₃).obj X₂).obj X₃).isColimitCofanMapObj ρ₂₃.p i₂₃
let c := (((mapBifunctor F I₁ ρ₂₃.I₂₃).obj X₁).obj
(mapBifunctorMapObj G₂₃ ρ₂₃.p X₂ X₃)).cofanMapObj ρ₂₃.q j
have hc : IsColimit c := (((mapBifunctor F I₁ ρ₂₃.I₂₃).obj X₁).obj
(mapBifunctorMapObj G₂₃ ρ₂₃.p X₂ X₃)).isColimitCofanMapObj ρ₂₃.q j
let c₂₃' := fun (i : ρ₂₃.q ⁻¹' {j}) => (F.obj (X₁ i.1.1)).mapCocone (c₂₃ i.1.2)
have hc₂₃' : ∀ i, IsColimit (c₂₃' i) := fun i => isColimitOfPreserves _ (h₂₃ i.1.2)
let Z := (((mapTrifunctor (bifunctorComp₂₃ F G₂₃) I₁ I₂ I₃).obj X₁).obj X₂).obj X₃
let p' : I₁ × I₂ × I₃ → I₁ × ρ₂₃.I₂₃ := fun ⟨i₁, i₂, i₃⟩ => ⟨i₁, ρ₂₃.p ⟨i₂, i₃⟩⟩
let e : ∀ (i₁ : I₁) (i₂₃ : ρ₂₃.I₂₃), p' ⁻¹' {(i₁, i₂₃)} ≃ ρ₂₃.p ⁻¹' {i₂₃} := fun i₁ i₂₃ =>
{ toFun := fun ⟨⟨i₁', i₂, i₃⟩, hi⟩ => ⟨⟨i₂, i₃⟩, by cat_disch⟩
invFun := fun ⟨⟨i₂, i₃⟩, hi⟩ => ⟨⟨i₁, i₂, i₃⟩, by cat_disch⟩
left_inv := fun ⟨⟨i₁', i₂, i₃⟩, hi⟩ => by
obtain rfl : i₁ = i₁' := by cat_disch
rfl }
let c₂₃'' : ∀ (i : ρ₂₃.q ⁻¹' {j}), CofanMapObjFun Z p' (i.1.1, i.1.2) :=
fun ⟨⟨i₁, i₂₃⟩, hi⟩ => by
refine (Cocones.precompose (Iso.hom ?_)).obj ((Cocones.whiskeringEquivalence
(Discrete.equivalence (e i₁ i₂₃))).functor.obj (c₂₃' ⟨⟨i₁, i₂₃⟩, hi⟩))
refine Discrete.natIso (fun ⟨⟨i₁', i₂, i₃⟩, hi⟩ => eqToIso ?_)
obtain rfl : i₁' = i₁ := congr_arg _root_.Prod.fst hi
rfl
have h₂₃'' : ∀ i, IsColimit (c₂₃'' i) := fun _ =>
(IsColimit.precomposeHomEquiv _ _).symm (IsColimit.whiskerEquivalenceEquiv _ (hc₂₃' _))
refine IsColimit.ofIsoColimit (isColimitCofanMapObjComp Z p' ρ₂₃.q r ρ₂₃.hpq j
(fun ⟨i₁, i₂₃⟩ h => c₂₃'' ⟨⟨i₁, i₂₃⟩, h⟩) (fun ⟨i₁, i₂₃⟩ h => h₂₃'' ⟨⟨i₁, i₂₃⟩, h⟩) c hc)
(Cocones.ext (Iso.refl _) (fun ⟨⟨i₁, i₂, i₃⟩, h⟩ => ?_))
dsimp [Cofan.inj, c₂₃'', Z, p', e]
rw [comp_id, id_comp]
rfl
variable {F₁₂ G ρ₁₂ X₁ X₂ X₃}
include ρ₂₃ in
lemma HasGoodTrifunctor₂₃Obj.hasMap :
HasMap ((((mapTrifunctor (bifunctorComp₂₃ F G₂₃) I₁ I₂ I₃).obj X₁).obj X₂).obj X₃) r :=
fun j => ⟨_, isColimitCofan₃MapBifunctorBifunctor₂₃MapObj F G₂₃ ρ₂₃ X₁ X₂ X₃ j⟩
variable (F₁₂ G ρ₁₂ X₁ X₂ X₃)
section
variable [HasMap ((((mapTrifunctor (bifunctorComp₂₃ F G₂₃) I₁ I₂ I₃).obj X₁).obj X₂).obj X₃) r]
/-- The action on graded objects of a trifunctor obtained by composition of two
bifunctors can be computed as a composition of the actions of these two bifunctors. -/
noncomputable def mapBifunctorComp₂₃MapObjIso :
mapTrifunctorMapObj (bifunctorComp₂₃ F G₂₃) r X₁ X₂ X₃ ≅
mapBifunctorMapObj F ρ₂₃.q X₁ (mapBifunctorMapObj G₂₃ ρ₂₃.p X₂ X₃) :=
isoMk _ _ (fun j => (CofanMapObjFun.iso
(isColimitCofan₃MapBifunctorBifunctor₂₃MapObj F G₂₃ ρ₂₃ X₁ X₂ X₃ j)).symm)
@[reassoc (attr := simp)]
lemma ι_mapBifunctorComp₂₃MapObjIso_hom (i₁ : I₁) (i₂ : I₂) (i₃ : I₃) (j : J)
(h : r (i₁, i₂, i₃) = j) :
ιMapTrifunctorMapObj (bifunctorComp₂₃ F G₂₃) r X₁ X₂ X₃ i₁ i₂ i₃ j h ≫
(mapBifunctorComp₂₃MapObjIso F G₂₃ ρ₂₃ X₁ X₂ X₃).hom j =
ιMapBifunctorBifunctor₂₃MapObj F G₂₃ ρ₂₃ X₁ X₂ X₃ i₁ i₂ i₃ j h := by
dsimp [mapBifunctorComp₂₃MapObjIso]
apply CofanMapObjFun.ιMapObj_iso_inv
@[reassoc (attr := simp)]
lemma ι_mapBifunctorComp₂₃MapObjIso_inv (i₁ : I₁) (i₂ : I₂) (i₃ : I₃) (j : J)
(h : r (i₁, i₂, i₃) = j) :
ιMapBifunctorBifunctor₂₃MapObj F G₂₃ ρ₂₃ X₁ X₂ X₃ i₁ i₂ i₃ j h ≫
(mapBifunctorComp₂₃MapObjIso F G₂₃ ρ₂₃ X₁ X₂ X₃).inv j =
ιMapTrifunctorMapObj (bifunctorComp₂₃ F G₂₃) r X₁ X₂ X₃ i₁ i₂ i₃ j h :=
CofanMapObjFun.inj_iso_hom
(isColimitCofan₃MapBifunctorBifunctor₂₃MapObj F G₂₃ ρ₂₃ X₁ X₂ X₃ j) _ h
end
variable {X₁ X₂ X₃ F G₂₃ ρ₂₃}
variable {j : J} {A : C₄}
@[ext]
lemma mapBifunctorBifunctor₂₃MapObj_ext
{f g : mapBifunctorMapObj F ρ₂₃.q X₁ (mapBifunctorMapObj G₂₃ ρ₂₃.p X₂ X₃) j ⟶ A}
(h : ∀ (i₁ : I₁) (i₂ : I₂) (i₃ : I₃) (h : r ⟨i₁, i₂, i₃⟩ = j),
ιMapBifunctorBifunctor₂₃MapObj F G₂₃ ρ₂₃ X₁ X₂ X₃ i₁ i₂ i₃ j h ≫ f =
ιMapBifunctorBifunctor₂₃MapObj F G₂₃ ρ₂₃ X₁ X₂ X₃ i₁ i₂ i₃ j h ≫ g) : f = g := by
apply Cofan.IsColimit.hom_ext (isColimitCofan₃MapBifunctorBifunctor₂₃MapObj F G₂₃ ρ₂₃ X₁ X₂ X₃ j)
rintro ⟨i, hi⟩
exact h _ _ _ hi
section
variable
(f : ∀ (i₁ : I₁) (i₂ : I₂) (i₃ : I₃) (_ : r ⟨i₁, i₂, i₃⟩ = j),
(F.obj (X₁ i₁)).obj ((G₂₃.obj (X₂ i₂)).obj (X₃ i₃)) ⟶ A)
/-- Constructor for morphisms from
`mapBifunctorMapObj F ρ₂₃.q X₁ (mapBifunctorMapObj G₂₃ ρ₂₃.p X₂ X₃) j`. -/
noncomputable def mapBifunctorBifunctor₂₃Desc :
mapBifunctorMapObj F ρ₂₃.q X₁ (mapBifunctorMapObj G₂₃ ρ₂₃.p X₂ X₃) j ⟶ A :=
Cofan.IsColimit.desc (isColimitCofan₃MapBifunctorBifunctor₂₃MapObj F G₂₃ ρ₂₃ X₁ X₂ X₃ j)
(fun i ↦ f i.1.1 i.1.2.1 i.1.2.2 i.2)
@[reassoc (attr := simp)]
lemma ι_mapBifunctorBifunctor₂₃Desc
(i₁ : I₁) (i₂ : I₂) (i₃ : I₃) (h : r ⟨i₁, i₂, i₃⟩ = j) :
ιMapBifunctorBifunctor₂₃MapObj F G₂₃ ρ₂₃ X₁ X₂ X₃ i₁ i₂ i₃ j h ≫
mapBifunctorBifunctor₂₃Desc f = f i₁ i₂ i₃ h :=
Cofan.IsColimit.fac
(isColimitCofan₃MapBifunctorBifunctor₂₃MapObj F G₂₃ ρ₂₃ X₁ X₂ X₃ j) _ ⟨_, h⟩
end
end
end GradedObject
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/GradedObject/Associator.lean | import Mathlib.CategoryTheory.GradedObject.Trifunctor
/-!
# The associator for actions of bifunctors on graded objects
Given functors `F₁₂ : C₁ ⥤ C₂ ⥤ C₁₂`, `G : C₁₂ ⥤ C₃ ⥤ C₄`,
`F : C₁ ⥤ C₂₃ ⥤ C₄`, `G₂₃ : C₂ ⥤ C₃ ⥤ C₂₃` equipped with an isomorphism
`associator : bifunctorComp₁₂ F₁₂ G ≅ bifunctorComp₂₃ F G₂₃` (which informally means
that we have natural isomorphisms `G(F₁₂(X₁, X₂), X₃) ≅ F(X₁, G₂₃(X₂, X₃))`),
a map `r : I₁ × I₂ × I₃ → J`, and data `ρ₁₂ : BifunctorComp₁₂IndexData r` and
`ρ₂₃ : BifunctorComp₂₃IndexData r`, then if `X₁ : GradedObject I₁ C₁`,
`X₂ : GradedObject I₂ C₂` and `X₃ : GradedObject I₃ C₃`
satisfy suitable assumptions, we construct an isomorphism
`mapBifunctorAssociator associator ρ₁₂ ρ₂₃ X₁ X₂ X₃` between
`mapBifunctorMapObj G ρ₁₂.q (mapBifunctorMapObj F₁₂ ρ₁₂.p X₁ X₂) X₃` and
`mapBifunctorMapObj F ρ₂₃.q X₁ (mapBifunctorMapObj G₂₃ ρ₂₃.p X₂ X₃)` in the category
`GradedObject J C₄`.
This construction shall be used in the definition of the monoidal category structure
on graded objects indexed by an additive monoid.
-/
namespace CategoryTheory
open Category
namespace GradedObject
variable {C₁ C₂ C₁₂ C₂₃ C₃ C₄ : Type*}
[Category C₁] [Category C₂] [Category C₃] [Category C₄] [Category C₁₂] [Category C₂₃]
{F₁₂ : C₁ ⥤ C₂ ⥤ C₁₂} {G : C₁₂ ⥤ C₃ ⥤ C₄}
{F : C₁ ⥤ C₂₃ ⥤ C₄} {G₂₃ : C₂ ⥤ C₃ ⥤ C₂₃}
(associator : bifunctorComp₁₂ F₁₂ G ≅ bifunctorComp₂₃ F G₂₃)
{I₁ I₂ I₃ J : Type*} {r : I₁ × I₂ × I₃ → J}
(ρ₁₂ : BifunctorComp₁₂IndexData r) (ρ₂₃ : BifunctorComp₂₃IndexData r)
(X₁ : GradedObject I₁ C₁) (X₂ : GradedObject I₂ C₂) (X₃ : GradedObject I₃ C₃)
[HasMap (((mapBifunctor F₁₂ I₁ I₂).obj X₁).obj X₂) ρ₁₂.p]
[HasMap (((mapBifunctor G ρ₁₂.I₁₂ I₃).obj (mapBifunctorMapObj F₁₂ ρ₁₂.p X₁ X₂)).obj X₃) ρ₁₂.q]
[HasMap (((mapBifunctor G₂₃ I₂ I₃).obj X₂).obj X₃) ρ₂₃.p]
[HasMap (((mapBifunctor F I₁ ρ₂₃.I₂₃).obj X₁).obj (mapBifunctorMapObj G₂₃ ρ₂₃.p X₂ X₃)) ρ₂₃.q]
[H₁₂ : HasGoodTrifunctor₁₂Obj F₁₂ G ρ₁₂ X₁ X₂ X₃]
[H₂₃ : HasGoodTrifunctor₂₃Obj F G₂₃ ρ₂₃ X₁ X₂ X₃]
/-- Associator isomorphism for the action of bifunctors on graded objects. -/
noncomputable def mapBifunctorAssociator :
mapBifunctorMapObj G ρ₁₂.q (mapBifunctorMapObj F₁₂ ρ₁₂.p X₁ X₂) X₃ ≅
mapBifunctorMapObj F ρ₂₃.q X₁ (mapBifunctorMapObj G₂₃ ρ₂₃.p X₂ X₃) :=
have := H₁₂.hasMap
have := H₂₃.hasMap
(mapBifunctorComp₁₂MapObjIso F₁₂ G ρ₁₂ X₁ X₂ X₃).symm ≪≫
mapIso ((((mapTrifunctorMapIso associator I₁ I₂ I₃).app X₁).app X₂).app X₃) r ≪≫
mapBifunctorComp₂₃MapObjIso F G₂₃ ρ₂₃ X₁ X₂ X₃
@[reassoc (attr := simp, nolint unusedHavesSuffices)]
lemma ι_mapBifunctorAssociator_hom (i₁ : I₁) (i₂ : I₂) (i₃ : I₃) (j : J) (h : r (i₁, i₂, i₃) = j) :
ιMapBifunctor₁₂BifunctorMapObj F₁₂ G ρ₁₂ X₁ X₂ X₃ i₁ i₂ i₃ j h ≫
(mapBifunctorAssociator associator ρ₁₂ ρ₂₃ X₁ X₂ X₃).hom j =
((associator.hom.app (X₁ i₁)).app (X₂ i₂)).app (X₃ i₃) ≫
ιMapBifunctorBifunctor₂₃MapObj F G₂₃ ρ₂₃ X₁ X₂ X₃ i₁ i₂ i₃ j h := by
dsimp [mapBifunctorAssociator]
rw [ι_mapBifunctorComp₁₂MapObjIso_inv_assoc, ιMapTrifunctorMapObj,
ι_mapMap_assoc, mapTrifunctorMapNatTrans_app_app_app]
erw [ι_mapBifunctorComp₂₃MapObjIso_hom]
@[reassoc (attr := simp)]
lemma ι_mapBifunctorAssociator_inv (i₁ : I₁) (i₂ : I₂) (i₃ : I₃) (j : J) (h : r (i₁, i₂, i₃) = j) :
ιMapBifunctorBifunctor₂₃MapObj F G₂₃ ρ₂₃ X₁ X₂ X₃ i₁ i₂ i₃ j h ≫
(mapBifunctorAssociator associator ρ₁₂ ρ₂₃ X₁ X₂ X₃).inv j =
((associator.inv.app (X₁ i₁)).app (X₂ i₂)).app (X₃ i₃) ≫
ιMapBifunctor₁₂BifunctorMapObj F₁₂ G ρ₁₂ X₁ X₂ X₃ i₁ i₂ i₃ j h := by
rw [← cancel_mono ((mapBifunctorAssociator associator ρ₁₂ ρ₂₃ X₁ X₂ X₃).hom j),
assoc, assoc, Iso.inv_hom_id_eval, comp_id, ι_mapBifunctorAssociator_hom,
← NatTrans.comp_app_assoc, ← NatTrans.comp_app, Iso.inv_hom_id_app,
NatTrans.id_app, NatTrans.id_app, id_comp]
end GradedObject
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/GradedObject/Unitor.lean | import Mathlib.CategoryTheory.GradedObject.Associator
import Mathlib.CategoryTheory.GradedObject.Single
/-!
# The left and right unitors
Given a bifunctor `F : C ⥤ D ⥤ D`, an object `X : C` such that `F.obj X ≅ 𝟭 D` and a
map `p : I × J → J` such that `hp : ∀ (j : J), p ⟨0, j⟩ = j`,
we define an isomorphism of `J`-graded objects for any `Y : GradedObject J D`.
`mapBifunctorLeftUnitor F X e p hp Y : mapBifunctorMapObj F p ((single₀ I).obj X) Y ≅ Y`.
Under similar assumptions, we also obtain a right unitor isomorphism
`mapBifunctorMapObj F p X ((single₀ I).obj Y) ≅ X`. Finally,
the lemma `mapBifunctor_triangle` promotes a triangle identity involving functors
to a triangle identity for the induced functors on graded objects.
-/
namespace CategoryTheory
open Category Limits
namespace GradedObject
section LeftUnitor
variable {C D I J : Type*} [Category C] [Category D]
[Zero I] [DecidableEq I] [HasInitial C]
(F : C ⥤ D ⥤ D) (X : C) (e : F.obj X ≅ 𝟭 D)
[∀ (Y : D), PreservesColimit (Functor.empty.{0} C) (F.flip.obj Y)]
(p : I × J → J) (hp : ∀ (j : J), p ⟨0, j⟩ = j)
(Y Y' : GradedObject J D) (φ : Y ⟶ Y')
/-- Given `F : C ⥤ D ⥤ D`, `X : C`, `e : F.obj X ≅ 𝟭 D` and `Y : GradedObject J D`,
this is the isomorphism `((mapBifunctor F I J).obj ((single₀ I).obj X)).obj Y a ≅ Y a.2`
when `a : I × J` is such that `a.1 = 0`. -/
@[simps!]
noncomputable def mapBifunctorObjSingle₀ObjIso (a : I × J) (ha : a.1 = 0) :
((mapBifunctor F I J).obj ((single₀ I).obj X)).obj Y a ≅ Y a.2 :=
(F.mapIso (singleObjApplyIsoOfEq _ X _ ha)).app _ ≪≫ e.app (Y a.2)
/-- Given `F : C ⥤ D ⥤ D`, `X : C` and `Y : GradedObject J D`,
`((mapBifunctor F I J).obj ((single₀ I).obj X)).obj Y a` is an initial object
when `a : I × J` is such that `a.1 ≠ 0`. -/
noncomputable def mapBifunctorObjSingle₀ObjIsInitial (a : I × J) (ha : a.1 ≠ 0) :
IsInitial (((mapBifunctor F I J).obj ((single₀ I).obj X)).obj Y a) :=
IsInitial.isInitialObj (F.flip.obj (Y a.2)) _ (isInitialSingleObjApply _ _ _ ha)
/-- Given `F : C ⥤ D ⥤ D`, `X : C`, `e : F.obj X ≅ 𝟭 D`, `Y : GradedObject J D` and
`p : I × J → J` such that `p ⟨0, j⟩ = j` for all `j`,
this is the (colimit) cofan which shall be used to construct the isomorphism
`mapBifunctorMapObj F p ((single₀ I).obj X) Y ≅ Y`, see `mapBifunctorLeftUnitor`. -/
noncomputable def mapBifunctorLeftUnitorCofan (hp : ∀ (j : J), p ⟨0, j⟩ = j) (Y) (j : J) :
(((mapBifunctor F I J).obj ((single₀ I).obj X)).obj Y).CofanMapObjFun p j :=
CofanMapObjFun.mk _ _ _ (Y j) (fun a ha =>
if ha : a.1 = 0 then
(mapBifunctorObjSingle₀ObjIso F X e Y a ha).hom ≫ eqToHom (by aesop)
else
(mapBifunctorObjSingle₀ObjIsInitial F X Y a ha).to _)
@[simp, reassoc]
lemma mapBifunctorLeftUnitorCofan_inj (j : J) :
(mapBifunctorLeftUnitorCofan F X e p hp Y j).inj ⟨⟨0, j⟩, hp j⟩ =
(F.map (singleObjApplyIso (0 : I) X).hom).app (Y j) ≫ e.hom.app (Y j) := by
simp [mapBifunctorLeftUnitorCofan]
/-- The cofan `mapBifunctorLeftUnitorCofan F X e p hp Y j` is a colimit. -/
noncomputable def mapBifunctorLeftUnitorCofanIsColimit (j : J) :
IsColimit (mapBifunctorLeftUnitorCofan F X e p hp Y j) :=
mkCofanColimit _
(fun s => e.inv.app (Y j) ≫
(F.map (singleObjApplyIso (0 : I) X).inv).app (Y j) ≫ s.inj ⟨⟨0, j⟩, hp j⟩)
(fun s => by
rintro ⟨⟨i, j'⟩, h⟩
by_cases hi : i = 0
· subst hi
simp only [Set.mem_preimage, hp, Set.mem_singleton_iff] at h
subst h
simp
· apply IsInitial.hom_ext
exact mapBifunctorObjSingle₀ObjIsInitial _ _ _ _ hi)
(fun s m hm => by simp [← hm ⟨⟨0, j⟩, hp j⟩])
include e hp in
lemma mapBifunctorLeftUnitor_hasMap :
HasMap (((mapBifunctor F I J).obj ((single₀ I).obj X)).obj Y) p :=
CofanMapObjFun.hasMap _ _ _ (mapBifunctorLeftUnitorCofanIsColimit F X e p hp Y)
variable [HasMap (((mapBifunctor F I J).obj ((single₀ I).obj X)).obj Y) p]
[HasMap (((mapBifunctor F I J).obj ((single₀ I).obj X)).obj Y') p]
/-- Given `F : C ⥤ D ⥤ D`, `X : C`, `e : F.obj X ≅ 𝟭 D`, `Y : GradedObject J D` and
`p : I × J → J` such that `p ⟨0, j⟩ = j` for all `j`,
this is the left unitor isomorphism `mapBifunctorMapObj F p ((single₀ I).obj X) Y ≅ Y`. -/
noncomputable def mapBifunctorLeftUnitor : mapBifunctorMapObj F p ((single₀ I).obj X) Y ≅ Y :=
isoMk _ _ (fun j => (CofanMapObjFun.iso
(mapBifunctorLeftUnitorCofanIsColimit F X e p hp Y j)).symm)
@[reassoc (attr := simp)]
lemma ι_mapBifunctorLeftUnitor_hom_apply (j : J) :
ιMapBifunctorMapObj F p ((single₀ I).obj X) Y 0 j j (hp j) ≫
(mapBifunctorLeftUnitor F X e p hp Y).hom j =
(F.map (singleObjApplyIso (0 : I) X).hom).app _ ≫ e.hom.app (Y j) := by
dsimp [mapBifunctorLeftUnitor]
erw [CofanMapObjFun.ιMapObj_iso_inv]
rw [mapBifunctorLeftUnitorCofan_inj]
lemma mapBifunctorLeftUnitor_inv_apply (j : J) :
(mapBifunctorLeftUnitor F X e p hp Y).inv j =
e.inv.app (Y j) ≫ (F.map (singleObjApplyIso (0 : I) X).inv).app (Y j) ≫
ιMapBifunctorMapObj F p ((single₀ I).obj X) Y 0 j j (hp j) := rfl
variable {Y Y'}
@[reassoc]
lemma mapBifunctorLeftUnitor_inv_naturality :
φ ≫ (mapBifunctorLeftUnitor F X e p hp Y').inv =
(mapBifunctorLeftUnitor F X e p hp Y).inv ≫ mapBifunctorMapMap F p (𝟙 _) φ := by
ext j
dsimp
rw [mapBifunctorLeftUnitor_inv_apply, mapBifunctorLeftUnitor_inv_apply, assoc, assoc,
ι_mapBifunctorMapMap]
dsimp
rw [Functor.map_id, NatTrans.id_app, id_comp, ← NatTrans.naturality_assoc,
← NatTrans.naturality_assoc]
rfl
@[reassoc]
lemma mapBifunctorLeftUnitor_naturality :
mapBifunctorMapMap F p (𝟙 _) φ ≫ (mapBifunctorLeftUnitor F X e p hp Y').hom =
(mapBifunctorLeftUnitor F X e p hp Y).hom ≫ φ := by
rw [← cancel_mono (mapBifunctorLeftUnitor F X e p hp Y').inv, assoc, assoc, Iso.hom_inv_id,
comp_id, mapBifunctorLeftUnitor_inv_naturality, Iso.hom_inv_id_assoc]
end LeftUnitor
section RightUnitor
variable {C D I J : Type*} [Category C] [Category D]
[Zero I] [DecidableEq I] [HasInitial C]
(F : D ⥤ C ⥤ D) (Y : C) (e : F.flip.obj Y ≅ 𝟭 D)
[∀ (X : D), PreservesColimit (Functor.empty.{0} C) (F.obj X)]
(p : J × I → J)
(hp : ∀ (j : J), p ⟨j, 0⟩ = j) (X X' : GradedObject J D) (φ : X ⟶ X')
/-- Given `F : D ⥤ C ⥤ D`, `Y : C`, `e : F.flip.obj X ≅ 𝟭 D` and `X : GradedObject J D`,
this is the isomorphism `((mapBifunctor F J I).obj X).obj ((single₀ I).obj Y) a ≅ Y a.2`
when `a : J × I` is such that `a.2 = 0`. -/
@[simps!]
noncomputable def mapBifunctorObjObjSingle₀Iso (a : J × I) (ha : a.2 = 0) :
((mapBifunctor F J I).obj X).obj ((single₀ I).obj Y) a ≅ X a.1 :=
Functor.mapIso _ (singleObjApplyIsoOfEq _ Y _ ha) ≪≫ e.app (X a.1)
/-- Given `F : D ⥤ C ⥤ D`, `Y : C` and `X : GradedObject J D`,
`((mapBifunctor F J I).obj X).obj ((single₀ I).obj X) a` is an initial when `a : J × I`
is such that `a.2 ≠ 0`. -/
noncomputable def mapBifunctorObjObjSingle₀IsInitial (a : J × I) (ha : a.2 ≠ 0) :
IsInitial (((mapBifunctor F J I).obj X).obj ((single₀ I).obj Y) a) :=
IsInitial.isInitialObj (F.obj (X a.1)) _ (isInitialSingleObjApply _ _ _ ha)
/-- Given `F : D ⥤ C ⥤ D`, `Y : C`, `e : F.flip.obj Y ≅ 𝟭 D`, `X : GradedObject J D` and
`p : J × I → J` such that `p ⟨j, 0⟩ = j` for all `j`,
this is the (colimit) cofan which shall be used to construct the isomorphism
`mapBifunctorMapObj F p X ((single₀ I).obj Y) ≅ X`, see `mapBifunctorRightUnitor`. -/
noncomputable def mapBifunctorRightUnitorCofan (hp : ∀ (j : J), p ⟨j, 0⟩ = j) (X) (j : J) :
(((mapBifunctor F J I).obj X).obj ((single₀ I).obj Y)).CofanMapObjFun p j :=
CofanMapObjFun.mk _ _ _ (X j) (fun a ha =>
if ha : a.2 = 0 then
(mapBifunctorObjObjSingle₀Iso F Y e X a ha).hom ≫ eqToHom (by aesop)
else
(mapBifunctorObjObjSingle₀IsInitial F Y X a ha).to _)
@[simp, reassoc]
lemma mapBifunctorRightUnitorCofan_inj (j : J) :
(mapBifunctorRightUnitorCofan F Y e p hp X j).inj ⟨⟨j, 0⟩, hp j⟩ =
(F.obj (X j)).map (singleObjApplyIso (0 : I) Y).hom ≫ e.hom.app (X j) := by
simp [mapBifunctorRightUnitorCofan]
/-- The cofan `mapBifunctorRightUnitorCofan F Y e p hp X j` is a colimit. -/
noncomputable def mapBifunctorRightUnitorCofanIsColimit (j : J) :
IsColimit (mapBifunctorRightUnitorCofan F Y e p hp X j) :=
mkCofanColimit _
(fun s => e.inv.app (X j) ≫
(F.obj (X j)).map (singleObjApplyIso (0 : I) Y).inv ≫ s.inj ⟨⟨j, 0⟩, hp j⟩)
(fun s => by
rintro ⟨⟨j', i⟩, h⟩
by_cases hi : i = 0
· subst hi
simp only [Set.mem_preimage, hp, Set.mem_singleton_iff] at h
subst h
dsimp
rw [mapBifunctorRightUnitorCofan_inj, assoc, Iso.hom_inv_id_app_assoc,
← Functor.map_comp_assoc, Iso.hom_inv_id, Functor.map_id, id_comp]
· apply IsInitial.hom_ext
exact mapBifunctorObjObjSingle₀IsInitial _ _ _ _ hi)
(fun s m hm => by
dsimp
rw [← hm ⟨⟨j, 0⟩, hp j⟩, mapBifunctorRightUnitorCofan_inj, assoc, ← Functor.map_comp_assoc,
Iso.inv_hom_id, Functor.map_id, id_comp, Iso.inv_hom_id_app_assoc])
include e hp in
lemma mapBifunctorRightUnitor_hasMap :
HasMap (((mapBifunctor F J I).obj X).obj ((single₀ I).obj Y)) p :=
CofanMapObjFun.hasMap _ _ _ (mapBifunctorRightUnitorCofanIsColimit F Y e p hp X)
variable [HasMap (((mapBifunctor F J I).obj X).obj ((single₀ I).obj Y)) p]
[HasMap (((mapBifunctor F J I).obj X').obj ((single₀ I).obj Y)) p]
/-- Given `F : D ⥤ C ⥤ D`, `Y : C`, `e : F.flip.obj Y ≅ 𝟭 D`, `X : GradedObject J D` and
`p : J × I → J` such that `p ⟨j, 0⟩ = j` for all `j`,
this is the right unitor isomorphism `mapBifunctorMapObj F p X ((single₀ I).obj Y) ≅ X`. -/
noncomputable def mapBifunctorRightUnitor : mapBifunctorMapObj F p X ((single₀ I).obj Y) ≅ X :=
isoMk _ _ (fun j => (CofanMapObjFun.iso
(mapBifunctorRightUnitorCofanIsColimit F Y e p hp X j)).symm)
@[reassoc (attr := simp)]
lemma ι_mapBifunctorRightUnitor_hom_apply (j : J) :
ιMapBifunctorMapObj F p X ((single₀ I).obj Y) j 0 j (hp j) ≫
(mapBifunctorRightUnitor F Y e p hp X).hom j =
(F.obj (X j)).map (singleObjApplyIso (0 : I) Y).hom ≫ e.hom.app (X j) := by
dsimp [mapBifunctorRightUnitor]
erw [CofanMapObjFun.ιMapObj_iso_inv]
rw [mapBifunctorRightUnitorCofan_inj]
lemma mapBifunctorRightUnitor_inv_apply (j : J) :
(mapBifunctorRightUnitor F Y e p hp X).inv j =
e.inv.app (X j) ≫ (F.obj (X j)).map (singleObjApplyIso (0 : I) Y).inv ≫
ιMapBifunctorMapObj F p X ((single₀ I).obj Y) j 0 j (hp j) := rfl
variable {Y}
@[reassoc]
lemma mapBifunctorRightUnitor_inv_naturality :
φ ≫ (mapBifunctorRightUnitor F Y e p hp X').inv =
(mapBifunctorRightUnitor F Y e p hp X).inv ≫ mapBifunctorMapMap F p φ (𝟙 _) := by
ext j
dsimp
rw [mapBifunctorRightUnitor_inv_apply, mapBifunctorRightUnitor_inv_apply, assoc, assoc,
ι_mapBifunctorMapMap]
dsimp
rw [Functor.map_id, id_comp, NatTrans.naturality_assoc]
erw [← NatTrans.naturality_assoc e.inv]
rfl
@[reassoc]
lemma mapBifunctorRightUnitor_naturality :
mapBifunctorMapMap F p φ (𝟙 _) ≫ (mapBifunctorRightUnitor F Y e p hp X').hom =
(mapBifunctorRightUnitor F Y e p hp X).hom ≫ φ := by
rw [← cancel_mono (mapBifunctorRightUnitor F Y e p hp X').inv, assoc, assoc, Iso.hom_inv_id,
comp_id, mapBifunctorRightUnitor_inv_naturality, Iso.hom_inv_id_assoc]
end RightUnitor
section
variable {I₁ I₂ I₃ J : Type*} [Zero I₂]
/-- Given two maps `r : I₁ × I₂ × I₃ → J` and `π : I₁ × I₃ → J`, this structure is the
input in the formulation of the triangle equality `mapBifunctor_triangle` which
relates the left and right unitor and the associator for `GradedObject.mapBifunctor`. -/
structure TriangleIndexData (r : I₁ × I₂ × I₃ → J) (π : I₁ × I₃ → J) where
/-- a map `I₁ × I₂ → I₁` -/
p₁₂ : I₁ × I₂ → I₁
hp₁₂ (i : I₁ × I₂ × I₃) : π ⟨p₁₂ ⟨i.1, i.2.1⟩, i.2.2⟩ = r i
/-- a map `I₂ × I₃ → I₃` -/
p₂₃ : I₂ × I₃ → I₃
hp₂₃ (i : I₁ × I₂ × I₃) : π ⟨i.1, p₂₃ i.2⟩ = r i
h₁ (i₁ : I₁) : p₁₂ (i₁, 0) = i₁
h₃ (i₃ : I₃) : p₂₃ (0, i₃) = i₃
variable {r : I₁ × I₂ × I₃ → J} {π : I₁ × I₃ → J} (τ : TriangleIndexData r π)
include τ
namespace TriangleIndexData
attribute [simp] h₁ h₃
lemma r_zero (i₁ : I₁) (i₃ : I₃) : r ⟨i₁, 0, i₃⟩ = π ⟨i₁, i₃⟩ := by
rw [← τ.hp₂₃, τ.h₃ i₃]
/-- The `BifunctorComp₁₂IndexData r` attached to a `TriangleIndexData r π`. -/
@[reducible]
def ρ₁₂ : BifunctorComp₁₂IndexData r where
I₁₂ := I₁
p := τ.p₁₂
q := π
hpq := τ.hp₁₂
/-- The `BifunctorComp₂₃IndexData r` attached to a `TriangleIndexData r π`. -/
@[reducible]
def ρ₂₃ : BifunctorComp₂₃IndexData r where
I₂₃ := I₃
p := τ.p₂₃
q := π
hpq := τ.hp₂₃
end TriangleIndexData
end
section Triangle
variable {C₁ C₂ C₃ D I₁ I₂ I₃ J : Type*} [Category C₁] [Category C₂] [Category C₃] [Category D]
[Zero I₂] [DecidableEq I₂] [HasInitial C₂]
{F₁ : C₁ ⥤ C₂ ⥤ C₁} {F₂ : C₂ ⥤ C₃ ⥤ C₃} {G : C₁ ⥤ C₃ ⥤ D}
(associator : bifunctorComp₁₂ F₁ G ≅ bifunctorComp₂₃ G F₂)
(X₂ : C₂) (e₁ : F₁.flip.obj X₂ ≅ 𝟭 C₁) (e₂ : F₂.obj X₂ ≅ 𝟭 C₃)
[∀ (X₁ : C₁), PreservesColimit (Functor.empty.{0} C₂) (F₁.obj X₁)]
[∀ (X₃ : C₃), PreservesColimit (Functor.empty.{0} C₂) (F₂.flip.obj X₃)]
{r : I₁ × I₂ × I₃ → J} {π : I₁ × I₃ → J}
(τ : TriangleIndexData r π)
(X₁ : GradedObject I₁ C₁) (X₃ : GradedObject I₃ C₃)
[HasMap (((mapBifunctor F₁ I₁ I₂).obj X₁).obj ((single₀ I₂).obj X₂)) τ.p₁₂]
[HasMap (((mapBifunctor G I₁ I₃).obj
(mapBifunctorMapObj F₁ τ.p₁₂ X₁ ((single₀ I₂).obj X₂))).obj X₃) π]
[HasMap (((mapBifunctor F₂ I₂ I₃).obj ((single₀ I₂).obj X₂)).obj X₃) τ.p₂₃]
[HasMap (((mapBifunctor G I₁ I₃).obj X₁).obj
(mapBifunctorMapObj F₂ τ.p₂₃ ((single₀ I₂).obj X₂) X₃)) π]
[HasGoodTrifunctor₁₂Obj F₁ G τ.ρ₁₂ X₁ ((single₀ I₂).obj X₂) X₃]
[HasGoodTrifunctor₂₃Obj G F₂ τ.ρ₂₃ X₁ ((single₀ I₂).obj X₂) X₃]
[HasMap (((mapBifunctor G I₁ I₃).obj X₁).obj X₃) π]
lemma mapBifunctor_triangle
(triangle : ∀ (X₁ : C₁) (X₃ : C₃), ((associator.hom.app X₁).app X₂).app X₃ ≫
(G.obj X₁).map (e₂.hom.app X₃) = (G.map (e₁.hom.app X₁)).app X₃) :
(mapBifunctorAssociator associator τ.ρ₁₂ τ.ρ₂₃ X₁ ((single₀ I₂).obj X₂) X₃).hom ≫
mapBifunctorMapMap G π (𝟙 X₁) (mapBifunctorLeftUnitor F₂ X₂ e₂ τ.p₂₃ τ.h₃ X₃).hom =
mapBifunctorMapMap G π (mapBifunctorRightUnitor F₁ X₂ e₁ τ.p₁₂ τ.h₁ X₁).hom (𝟙 X₃) := by
rw [← cancel_epi ((mapBifunctorMapMap G π
(mapBifunctorRightUnitor F₁ X₂ e₁ τ.p₁₂ τ.h₁ X₁).inv (𝟙 X₃)))]
ext j i₁ i₃ hj
simp only [categoryOfGradedObjects_comp, ι_mapBifunctorMapMap_assoc,
mapBifunctorRightUnitor_inv_apply, Functor.id_obj, Functor.flip_obj_obj, Functor.map_comp,
NatTrans.comp_app, categoryOfGradedObjects_id, Functor.map_id, id_comp, assoc,
ι_mapBifunctorMapMap]
congr 2
rw [← ιMapBifunctor₁₂BifunctorMapObj_eq_assoc F₁ G τ.ρ₁₂ _ _ _ i₁ 0 i₃ j
(by rw [τ.r_zero, hj]) i₁ (by simp), ι_mapBifunctorAssociator_hom_assoc,
ιMapBifunctorBifunctor₂₃MapObj_eq_assoc G F₂ τ.ρ₂₃ _ _ _ i₁ 0 i₃ j
(by rw [τ.r_zero, hj]) i₃ (by simp), ι_mapBifunctorMapMap]
dsimp
rw [Functor.map_id, NatTrans.id_app, id_comp,
← Functor.map_comp_assoc, ← NatTrans.comp_app_assoc, ← Functor.map_comp,
ι_mapBifunctorLeftUnitor_hom_apply F₂ X₂ e₂ τ.p₂₃ τ.h₃ X₃ i₃,
ι_mapBifunctorRightUnitor_hom_apply F₁ X₂ e₁ τ.p₁₂ τ.h₁ X₁ i₁]
dsimp
simp only [Functor.map_comp, NatTrans.comp_app, ← triangle (X₁ i₁) (X₃ i₃), ← assoc]
congr 2
symm
apply NatTrans.naturality_app (associator.hom.app (X₁ i₁))
end Triangle
end GradedObject
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/GradedObject/Braiding.lean | import Mathlib.CategoryTheory.GradedObject.Monoidal
import Mathlib.CategoryTheory.Monoidal.Braided.Basic
/-!
# The braided and symmetric category structures on graded objects
In this file, we construct the braiding
`GradedObject.Monoidal.braiding : tensorObj X Y ≅ tensorObj Y X`
for two objects `X` and `Y` in `GradedObject I C`, when `I` is a commutative
additive monoid (and suitable coproducts exist in a braided category `C`).
When `C` is a braided category and suitable assumptions are made, we obtain the braided category
structure on `GradedObject I C` and show that it is symmetric if `C` is symmetric.
-/
namespace CategoryTheory
open Category Limits
variable {I : Type*} [AddCommMonoid I] {C : Type*} [Category C] [MonoidalCategory C]
namespace GradedObject
namespace Monoidal
variable (X Y Z : GradedObject I C)
section Braided
variable [BraidedCategory C]
/-- The braiding `tensorObj X Y ≅ tensorObj Y X` when `X` and `Y` are graded objects
indexed by a commutative additive monoid. -/
noncomputable def braiding [HasTensor X Y] [HasTensor Y X] : tensorObj X Y ≅ tensorObj Y X where
hom k := tensorObjDesc (fun i j hij => (β_ _ _).hom ≫
ιTensorObj Y X j i k (by simpa only [add_comm j i] using hij))
inv k := tensorObjDesc (fun i j hij => (β_ _ _).inv ≫
ιTensorObj X Y j i k (by simpa only [add_comm j i] using hij))
variable {Y Z} in
lemma braiding_naturality_right [HasTensor X Y] [HasTensor Y X] [HasTensor X Z] [HasTensor Z X]
(f : Y ⟶ Z) :
whiskerLeft X f ≫ (braiding X Z).hom = (braiding X Y).hom ≫ whiskerRight f X := by
dsimp [braiding]
cat_disch
variable {X Y} in
lemma braiding_naturality_left [HasTensor Y Z] [HasTensor Z Y] [HasTensor X Z] [HasTensor Z X]
(f : X ⟶ Y) :
whiskerRight f Z ≫ (braiding Y Z).hom = (braiding X Z).hom ≫ whiskerLeft Z f := by
dsimp [braiding]
cat_disch
lemma hexagon_forward [HasTensor X Y] [HasTensor Y X] [HasTensor Y Z]
[HasTensor Z X] [HasTensor X Z]
[HasTensor (tensorObj X Y) Z] [HasTensor X (tensorObj Y Z)]
[HasTensor (tensorObj Y Z) X] [HasTensor Y (tensorObj Z X)]
[HasTensor (tensorObj Y X) Z] [HasTensor Y (tensorObj X Z)]
[HasGoodTensor₁₂Tensor X Y Z] [HasGoodTensorTensor₂₃ X Y Z]
[HasGoodTensor₁₂Tensor Y Z X] [HasGoodTensorTensor₂₃ Y Z X]
[HasGoodTensor₁₂Tensor Y X Z] [HasGoodTensorTensor₂₃ Y X Z] :
(associator X Y Z).hom ≫ (braiding X (tensorObj Y Z)).hom ≫ (associator Y Z X).hom =
whiskerRight (braiding X Y).hom Z ≫ (associator Y X Z).hom ≫
whiskerLeft Y (braiding X Z).hom := by
ext k i₁ i₂ i₃ h
dsimp [braiding]
conv_lhs => rw [ιTensorObj₃'_associator_hom_assoc, ιTensorObj₃_eq X Y Z i₁ i₂ i₃ k h _ rfl,
assoc, ι_tensorObjDesc_assoc, assoc, ← MonoidalCategory.id_tensorHom,
BraidedCategory.braiding_naturality_assoc,
BraidedCategory.braiding_tensor_right_hom, assoc, assoc, assoc, assoc, Iso.hom_inv_id_assoc,
MonoidalCategory.tensorHom_id,
← ιTensorObj₃'_eq_assoc Y Z X i₂ i₃ i₁ k (by rw [add_comm _ i₁, ← add_assoc, h]) _ rfl,
ιTensorObj₃'_associator_hom, Iso.inv_hom_id_assoc]
conv_rhs => rw [ιTensorObj₃'_eq X Y Z i₁ i₂ i₃ k h _ rfl, assoc, ι_tensorHom_assoc,
← MonoidalCategory.tensorHom_id,
MonoidalCategory.tensorHom_comp_tensorHom_assoc, id_comp, ι_tensorObjDesc,
categoryOfGradedObjects_id, MonoidalCategory.comp_tensor_id, assoc,
MonoidalCategory.tensorHom_id, MonoidalCategory.tensorHom_id,
← ιTensorObj₃'_eq_assoc Y X Z i₂ i₁ i₃ k
(by rw [add_comm i₂ i₁, h]) (i₁ + i₂) (add_comm i₂ i₁),
ιTensorObj₃'_associator_hom_assoc,
ιTensorObj₃_eq Y X Z i₂ i₁ i₃ k (by rw [add_comm i₂ i₁, h]) _ rfl, assoc,
ι_tensorHom, categoryOfGradedObjects_id, ← MonoidalCategory.tensorHom_id,
← MonoidalCategory.id_tensorHom,
← MonoidalCategory.id_tensor_comp_assoc,
ι_tensorObjDesc, MonoidalCategory.id_tensor_comp, assoc,
← MonoidalCategory.id_tensor_comp_assoc, MonoidalCategory.tensorHom_id,
MonoidalCategory.id_tensorHom, MonoidalCategory.whiskerLeft_comp, assoc,
← ιTensorObj₃_eq Y Z X i₂ i₃ i₁ k (by rw [add_comm _ i₁, ← add_assoc, h])
(i₁ + i₃) (add_comm _ _ )]
lemma hexagon_reverse [HasTensor X Y] [HasTensor Y Z] [HasTensor Z X]
[HasTensor Z Y] [HasTensor X Z]
[HasTensor (tensorObj X Y) Z] [HasTensor X (tensorObj Y Z)]
[HasTensor Z (tensorObj X Y)] [HasTensor (tensorObj Z X) Y]
[HasTensor X (tensorObj Z Y)] [HasTensor (tensorObj X Z) Y]
[HasGoodTensor₁₂Tensor X Y Z] [HasGoodTensorTensor₂₃ X Y Z]
[HasGoodTensor₁₂Tensor Z X Y] [HasGoodTensorTensor₂₃ Z X Y]
[HasGoodTensor₁₂Tensor X Z Y] [HasGoodTensorTensor₂₃ X Z Y] :
(associator X Y Z).inv ≫ (braiding (tensorObj X Y) Z).hom ≫ (associator Z X Y).inv =
whiskerLeft X (braiding Y Z).hom ≫ (associator X Z Y).inv ≫
whiskerRight (braiding X Z).hom Y := by
ext k i₁ i₂ i₃ h
dsimp [braiding]
conv_lhs => rw [ιTensorObj₃_associator_inv_assoc, ιTensorObj₃'_eq X Y Z i₁ i₂ i₃ k h _ rfl, assoc,
ι_tensorObjDesc_assoc, assoc, ← MonoidalCategory.tensorHom_id,
BraidedCategory.braiding_naturality_assoc,
BraidedCategory.braiding_tensor_left_hom, assoc, assoc, assoc, assoc, Iso.inv_hom_id_assoc,
MonoidalCategory.id_tensorHom,
← ιTensorObj₃_eq_assoc Z X Y i₃ i₁ i₂ k (by rw [add_assoc, add_comm i₃, h]) _ rfl,
ιTensorObj₃_associator_inv, Iso.hom_inv_id_assoc]
conv_rhs => rw [ιTensorObj₃_eq X Y Z i₁ i₂ i₃ k h _ rfl, assoc, ι_tensorHom_assoc,
← MonoidalCategory.id_tensorHom,
MonoidalCategory.tensorHom_comp_tensorHom_assoc, id_comp, ι_tensorObjDesc,
categoryOfGradedObjects_id, MonoidalCategory.id_tensor_comp, assoc,
MonoidalCategory.id_tensorHom, MonoidalCategory.id_tensorHom,
← ιTensorObj₃_eq_assoc X Z Y i₁ i₃ i₂ k
(by rw [add_assoc, add_comm i₃, ← add_assoc, h]) (i₂ + i₃) (add_comm _ _),
ιTensorObj₃_associator_inv_assoc,
ιTensorObj₃'_eq X Z Y i₁ i₃ i₂ k (by rw [add_assoc, add_comm i₃, ← add_assoc, h]) _ rfl,
assoc, ι_tensorHom, categoryOfGradedObjects_id, ← MonoidalCategory.tensorHom_id,
← MonoidalCategory.comp_tensor_id_assoc,
ι_tensorObjDesc, MonoidalCategory.comp_tensor_id, assoc,
MonoidalCategory.tensorHom_id, MonoidalCategory.tensorHom_id,
← ιTensorObj₃'_eq Z X Y i₃ i₁ i₂ k (by rw [add_assoc, add_comm i₃, h])
(i₁ + i₃) (add_comm _ _)]
end Braided
@[reassoc (attr := simp)]
lemma symmetry [SymmetricCategory C] [HasTensor X Y] [HasTensor Y X] :
(braiding X Y).hom ≫ (braiding Y X).hom = 𝟙 _ := by
dsimp [braiding]
cat_disch
end Monoidal
section Instances
variable
[∀ (X₁ X₂ : GradedObject I C), HasTensor X₁ X₂]
[∀ (X₁ X₂ X₃ : GradedObject I C), HasGoodTensor₁₂Tensor X₁ X₂ X₃]
[∀ (X₁ X₂ X₃ : GradedObject I C), HasGoodTensorTensor₂₃ X₁ X₂ X₃]
[DecidableEq I] [HasInitial C]
[∀ X₁, PreservesColimit (Functor.empty.{0} C)
((MonoidalCategory.curriedTensor C).obj X₁)]
[∀ X₂, PreservesColimit (Functor.empty.{0} C)
((MonoidalCategory.curriedTensor C).flip.obj X₂)]
[∀ (X₁ X₂ X₃ X₄ : GradedObject I C), HasTensor₄ObjExt X₁ X₂ X₃ X₄]
noncomputable instance braidedCategory [BraidedCategory C] :
BraidedCategory (GradedObject I C) where
braiding X Y := Monoidal.braiding X Y
braiding_naturality_left _ _:= Monoidal.braiding_naturality_left _ _
braiding_naturality_right _ _ _ _ := Monoidal.braiding_naturality_right _ _
hexagon_forward _ _ _ := Monoidal.hexagon_forward _ _ _
hexagon_reverse _ _ _ := Monoidal.hexagon_reverse _ _ _
noncomputable instance symmetricCategory [SymmetricCategory C] :
SymmetricCategory (GradedObject I C) where
symmetry _ _ := Monoidal.symmetry _ _
/-!
The braided/symmetric monoidal category structure on `GradedObject ℕ C` can
be inferred from the assumptions `[HasFiniteCoproducts C]`,
`[∀ (X : C), PreservesFiniteCoproducts ((curriedTensor C).obj X)]` and
`[∀ (X : C), PreservesFiniteCoproducts ((curriedTensor C).flip.obj X)]`.
This requires importing `Mathlib/CategoryTheory/Limits/Preserves/Finite.lean`.
-/
end Instances
end GradedObject
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/ChosenFiniteProducts/Over.lean | import Mathlib.CategoryTheory.Monoidal.Cartesian.Over
deprecated_module (since := "2025-05-15") |
.lake/packages/mathlib/Mathlib/CategoryTheory/ChosenFiniteProducts/InfSemilattice.lean | import Mathlib.CategoryTheory.Monoidal.Cartesian.InfSemilattice
deprecated_module (since := "2025-05-15") |
.lake/packages/mathlib/Mathlib/CategoryTheory/ChosenFiniteProducts/Cat.lean | import Mathlib.CategoryTheory.Monoidal.Cartesian.Cat
deprecated_module (since := "2025-05-15") |
.lake/packages/mathlib/Mathlib/CategoryTheory/ChosenFiniteProducts/FunctorCategory.lean | import Mathlib.CategoryTheory.Monoidal.Cartesian.FunctorCategory
deprecated_module (since := "2025-05-15") |
.lake/packages/mathlib/Mathlib/CategoryTheory/ObjectProperty/LimitsOfShape.lean | import Mathlib.CategoryTheory.ObjectProperty.Small
import Mathlib.CategoryTheory.Limits.Presentation
/-!
# Objects that are limits of objects satisfying a certain property
Given a property of objects `P : ObjectProperty C` and a category `J`,
we introduce two properties of objects `P.strictLimitsOfShape J`
and `P.limitsOfShape J`. The former contains exactly the objects
of the form `limit F` for any functor `F : J ⥤ C` that has
a limit and such that `F.obj j` satisfies `P` for any `j`, while
the latter contains all the objects that are isomorphic to
these "chosen" objects `limit F`.
Under certain circumstances, the type of objects satisfying
`P.strictLimitsOfShape J` is small: the main reason this variant is
introduced is to deduce that the full subcategory of `P.limitsOfShape J`
is essentially small.
By requiring `P.limitsOfShape J ≤ P`, we introduce a typeclass
`P.IsClosedUnderLimitsOfShape J`.
## TODO
* formalize the closure of `P` under finite limits (which require
iterating over `ℕ`), and more generally the closure under limits
indexed by a category whose type of arrows has a cardinality
that is bounded by a certain regular cardinal (@joelriou)
-/
universe w v'' v' u'' u' v u
namespace CategoryTheory.ObjectProperty
open Limits
variable {C : Type*} [Category C] (P : ObjectProperty C)
(J : Type u') [Category.{v'} J]
{J' : Type u''} [Category.{v''} J']
/-- The property of objects that are *equal* to `limit F` for some
functor `F : J ⥤ C` where all `F.obj j` satisfy `P`. -/
inductive strictLimitsOfShape : ObjectProperty C
| limit (F : J ⥤ C) [HasLimit F] (hF : ∀ j, P (F.obj j)) :
strictLimitsOfShape (limit F)
variable {P} in
lemma strictLimitsOfShape_monotone {Q : ObjectProperty C} (h : P ≤ Q) :
P.strictLimitsOfShape J ≤ Q.strictLimitsOfShape J := by
rintro _ ⟨F, hF⟩
exact ⟨F, fun j ↦ h _ (hF j)⟩
/-- A structure expressing that `X : C` is the limit of a functor
`diag : J ⥤ C` such that `P (diag.obj j)` holds for all `j`. -/
structure LimitOfShape (X : C) extends LimitPresentation J X where
prop_diag_obj (j : J) : P (diag.obj j)
namespace LimitOfShape
variable {P J}
/-- If `F : J ⥤ C` is a functor that has a limit and is such that for all `j`,
`F.obj j` satisfies a property `P`, then this structure expresses that `limit F`
is indeed a limit of objects satisfying `P`. -/
noncomputable def limit (F : J ⥤ C) [HasLimit F] (hF : ∀ j, P (F.obj j)) :
P.LimitOfShape J (limit F) where
toLimitPresentation := .limit F
prop_diag_obj := hF
/-- If `X` is a limit indexed by `J` of objects satisfying a property `P`, then
any object that is isomorphic to `X` also is. -/
@[simps toLimitPresentation]
def ofIso {X : C} (h : P.LimitOfShape J X) {Y : C} (e : X ≅ Y) :
P.LimitOfShape J Y where
toLimitPresentation := .ofIso h.toLimitPresentation e
prop_diag_obj := h.prop_diag_obj
/-- If `X` is a limit indexed by `J` of objects satisfying a property `P`,
it is also a limit indexed by `J` of objects satisfying `Q` if `P ≤ Q`. -/
@[simps toLimitPresentation]
def ofLE {X : C} (h : P.LimitOfShape J X) {Q : ObjectProperty C} (hPQ : P ≤ Q) :
Q.LimitOfShape J X where
toLimitPresentation := h.toLimitPresentation
prop_diag_obj j := hPQ _ (h.prop_diag_obj j)
/-- Change the index category for `ObjectProperty.LimitOfShape`. -/
@[simps toLimitPresentation]
noncomputable def reindex {X : C} (h : P.LimitOfShape J X) (G : J' ⥤ J) [G.Initial] :
P.LimitOfShape J' X where
toLimitPresentation := h.toLimitPresentation.reindex G
prop_diag_obj _ := h.prop_diag_obj _
end LimitOfShape
/-- The property of objects that are the point of a limit cone for a
functor `F : J ⥤ C` where all objects `F.obj j` satisfy `P`. -/
def limitsOfShape : ObjectProperty C :=
fun X ↦ Nonempty (P.LimitOfShape J X)
variable {P J} in
lemma LimitOfShape.limitsOfShape {X : C} (h : P.LimitOfShape J X) :
P.limitsOfShape J X :=
⟨h⟩
lemma strictLimitsOfShape_le_limitsOfShape :
P.strictLimitsOfShape J ≤ P.limitsOfShape J := by
rintro X ⟨F, hF⟩
exact ⟨.limit F hF⟩
instance : (P.limitsOfShape J).IsClosedUnderIsomorphisms where
of_iso := by rintro _ _ e ⟨h⟩; exact ⟨h.ofIso e⟩
@[simp]
lemma isoClosure_strictLimitsOfShape :
(P.strictLimitsOfShape J).isoClosure = P.limitsOfShape J := by
refine le_antisymm ?_ ?_
· rw [isoClosure_le_iff]
apply strictLimitsOfShape_le_limitsOfShape
· intro X ⟨h⟩
have := h.hasLimit
exact ⟨limit h.diag, strictLimitsOfShape.limit h.diag h.prop_diag_obj,
⟨h.isLimit.conePointUniqueUpToIso (limit.isLimit _)⟩⟩
variable {P} in
lemma limitsOfShape_monotone {Q : ObjectProperty C} (hPQ : P ≤ Q) :
P.limitsOfShape J ≤ Q.limitsOfShape J := by
intro X ⟨h⟩
exact ⟨h.ofLE hPQ⟩
@[simp]
lemma limitsOfShape_isoClosure :
P.isoClosure.limitsOfShape J = P.limitsOfShape J := by
refine le_antisymm ?_ (limitsOfShape_monotone _ P.le_isoClosure)
intro X ⟨h⟩
choose obj h₁ h₂ using h.prop_diag_obj
exact
⟨{ toLimitPresentation := h.changeDiag (h.diag.isoCopyObj obj (fun j ↦ (h₂ j).some)).symm
prop_diag_obj := h₁ }⟩
instance [ObjectProperty.Small.{w} P] [LocallySmall.{w} C] [Small.{w} J] [LocallySmall.{w} J] :
ObjectProperty.Small.{w} (P.strictLimitsOfShape J) := by
refine small_of_surjective
(f := fun (F : { F : J ⥤ P.FullSubcategory // HasLimit (F ⋙ P.ι) }) ↦
(⟨_, letI := F.2; ⟨F.1 ⋙ P.ι, fun j ↦ (F.1.obj j).2⟩⟩)) ?_
rintro ⟨_, ⟨F, hF⟩⟩
exact ⟨⟨P.lift F hF, by assumption⟩, rfl⟩
instance [ObjectProperty.Small.{w} P] [LocallySmall.{w} C] [Small.{w} J] [LocallySmall.{w} J] :
ObjectProperty.EssentiallySmall.{w} (P.limitsOfShape J) := by
rw [← isoClosure_strictLimitsOfShape]
infer_instance
/-- A property of objects satisfies `P.IsClosedUnderLimitsOfShape J` if it
is stable by limits of shape `J`. -/
@[mk_iff]
class IsClosedUnderLimitsOfShape (P : ObjectProperty C) (J : Type u') [Category.{v'} J] where
limitsOfShape_le (P J) : P.limitsOfShape J ≤ P
variable {P J} in
lemma IsClosedUnderLimitsOfShape.mk' [P.IsClosedUnderIsomorphisms]
(h : P.strictLimitsOfShape J ≤ P) :
P.IsClosedUnderLimitsOfShape J where
limitsOfShape_le := by
conv_rhs => rw [← P.isoClosure_eq_self]
rw [← isoClosure_strictLimitsOfShape]
exact monotone_isoClosure h
export IsClosedUnderLimitsOfShape (limitsOfShape_le)
section
variable {J} [P.IsClosedUnderLimitsOfShape J]
variable {P} in
lemma LimitOfShape.prop {X : C} (h : P.LimitOfShape J X) : P X :=
P.limitsOfShape_le J _ ⟨h⟩
lemma prop_of_isLimit {F : J ⥤ C} {c : Cone F} (hc : IsLimit c)
(hF : ∀ (j : J), P (F.obj j)) : P c.pt :=
P.limitsOfShape_le J _ ⟨{ diag := _, π := _, isLimit := hc, prop_diag_obj := hF }⟩
lemma prop_limit (F : J ⥤ C) [HasLimit F] (hF : ∀ (j : J), P (F.obj j)) :
P (limit F) :=
P.prop_of_isLimit (limit.isLimit F) hF
end
variable {J} in
lemma limitsOfShape_le_of_initial (G : J ⥤ J') [G.Initial] :
P.limitsOfShape J' ≤ P.limitsOfShape J :=
fun _h ⟨h⟩ ↦ ⟨h.reindex G⟩
variable {J} in
lemma limitsOfShape_congr (e : J ≌ J') :
P.limitsOfShape J = P.limitsOfShape J' :=
le_antisymm (P.limitsOfShape_le_of_initial e.inverse)
(P.limitsOfShape_le_of_initial e.functor)
variable {J} in
lemma isClosedUnderLimitsOfShape_iff_of_equivalence (e : J ≌ J') :
P.IsClosedUnderLimitsOfShape J ↔
P.IsClosedUnderLimitsOfShape J' := by
simp only [isClosedUnderLimitsOfShape_iff, P.limitsOfShape_congr e]
variable {P J} in
lemma IsClosedUnderLimitsOfShape.of_equivalence (e : J ≌ J')
[P.IsClosedUnderLimitsOfShape J] :
P.IsClosedUnderLimitsOfShape J' := by
rwa [← P.isClosedUnderLimitsOfShape_iff_of_equivalence e]
end ObjectProperty
namespace Limits
@[deprecated (since := "2025-09-22")] alias ClosedUnderLimitsOfShape :=
ObjectProperty.IsClosedUnderLimitsOfShape
@[deprecated (since := "2025-09-22")] alias closedUnderLimitsOfShape_of_limit :=
ObjectProperty.IsClosedUnderLimitsOfShape.mk'
@[deprecated (since := "2025-09-22")] alias ClosedUnderLimitsOfShape.limit :=
ObjectProperty.prop_limit
end CategoryTheory.Limits |
.lake/packages/mathlib/Mathlib/CategoryTheory/ObjectProperty/Extensions.lean | import Mathlib.Algebra.Homology.ShortComplex.ShortExact
import Mathlib.CategoryTheory.ObjectProperty.Basic
/-!
# Properties of objects that are closed under extensions
Given a category `C` and `P : ObjectProperty C`, we define a type
class `P.IsClosedUnderExtensions` expressing that the property
is closed under extensions.
-/
universe v v' u u'
namespace CategoryTheory
open Limits
variable {C : Type u} [Category.{v} C] {D : Type u'} [Category.{v'} D]
namespace ObjectProperty
variable (P : ObjectProperty C)
section
variable [HasZeroMorphisms C]
/-- Given `P : ObjectProperty C`, we say that `P` is closed under extensions
if whenever `0 ⟶ X₁ ⟶ X₂ ⟶ X₃ ⟶ 0` is a short exact short complex,
then `P X₁` and `P X₃` implies `P X₂`. -/
class IsClosedUnderExtensions : Prop where
prop_X₂_of_shortExact {S : ShortComplex C} (hS : S.ShortExact)
(h₁ : P S.X₁) (h₃ : P S.X₃) : P S.X₂
lemma prop_X₂_of_shortExact [P.IsClosedUnderExtensions]
{S : ShortComplex C} (hS : S.ShortExact)
(h₁ : P S.X₁) (h₃ : P S.X₃) : P S.X₂ :=
IsClosedUnderExtensions.prop_X₂_of_shortExact hS h₁ h₃
instance : (⊤ : ObjectProperty C).IsClosedUnderExtensions where
prop_X₂_of_shortExact := by simp
instance : IsClosedUnderExtensions (IsZero (C := C)) where
prop_X₂_of_shortExact hS h₁ h₃ :=
hS.exact.isZero_of_both_zeros (h₁.eq_of_src _ _) (h₃.eq_of_tgt _ _)
instance [P.IsClosedUnderExtensions] (F : D ⥤ C)
[HasZeroMorphisms D] [F.PreservesZeroMorphisms]
[PreservesFiniteLimits F] [PreservesFiniteColimits F] :
(P.inverseImage F).IsClosedUnderExtensions where
prop_X₂_of_shortExact hS h₁ h₃ := by
have := hS.mono_f
have := hS.epi_g
exact P.prop_X₂_of_shortExact (hS.map F) h₁ h₃
end
lemma prop_biprod {X₁ X₂ : C} (h₁ : P X₁) (h₂ : P X₂) [Preadditive C] [HasZeroObject C]
[P.IsClosedUnderExtensions] [HasBinaryBiproduct X₁ X₂] :
P (X₁ ⊞ X₂) :=
P.prop_X₂_of_shortExact
(ShortComplex.Splitting.ofHasBinaryBiproduct X₁ X₂).shortExact h₁ h₂
end ObjectProperty
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/ObjectProperty/Opposite.lean | import Mathlib.CategoryTheory.ObjectProperty.ClosedUnderIsomorphisms
import Mathlib.CategoryTheory.Opposites
/-!
# The opposite of a property of objects
-/
universe v u
namespace CategoryTheory.ObjectProperty
open Opposite
variable {C : Type u} [Category.{v} C]
/-- The property of objects of `Cᵒᵖ` corresponding to `P : ObjectProperty C`. -/
protected def op (P : ObjectProperty C) : ObjectProperty Cᵒᵖ :=
fun X ↦ P X.unop
/-- The property of objects of `C` corresponding to `P : ObjectProperty Cᵒᵖ`. -/
protected def unop (P : ObjectProperty Cᵒᵖ) : ObjectProperty C :=
fun X ↦ P (op X)
@[simp]
lemma op_iff (P : ObjectProperty C) (X : Cᵒᵖ) :
P.op X ↔ P X.unop := Iff.rfl
@[simp]
lemma unop_iff (P : ObjectProperty Cᵒᵖ) (X : C) :
P.unop X ↔ P (op X) := Iff.rfl
@[simp]
lemma op_unop (P : ObjectProperty Cᵒᵖ) : P.unop.op = P := rfl
@[simp]
lemma unop_op (P : ObjectProperty C) : P.op.unop = P := rfl
lemma op_injective {P Q : ObjectProperty C} (h : P.op = Q.op) : P = Q := by
rw [← P.unop_op, ← Q.unop_op, h]
lemma unop_injective {P Q : ObjectProperty Cᵒᵖ} (h : P.unop = Q.unop) : P = Q := by
rw [← P.op_unop, ← Q.op_unop, h]
lemma op_injective_iff {P Q : ObjectProperty C} :
P.op = Q.op ↔ P = Q :=
⟨op_injective, by rintro rfl; rfl⟩
lemma unop_injective_iff {P Q : ObjectProperty Cᵒᵖ} :
P.unop = Q.unop ↔ P = Q :=
⟨unop_injective, by rintro rfl; rfl⟩
lemma op_monotone {P Q : ObjectProperty C} (h : P ≤ Q) : P.op ≤ Q.op :=
fun _ hX ↦ h _ hX
lemma unop_monotone {P Q : ObjectProperty Cᵒᵖ} (h : P ≤ Q) : P.unop ≤ Q.unop :=
fun _ hX ↦ h _ hX
@[simp]
lemma op_monotone_iff {P Q : ObjectProperty C} : P.op ≤ Q.op ↔ P ≤ Q :=
⟨unop_monotone, op_monotone⟩
@[simp]
lemma unop_monotone_iff {P Q : ObjectProperty Cᵒᵖ} : P.unop ≤ Q.unop ↔ P ≤ Q :=
⟨op_monotone, unop_monotone⟩
instance (P : ObjectProperty C) [P.IsClosedUnderIsomorphisms] :
P.op.IsClosedUnderIsomorphisms where
of_iso e hX := P.prop_of_iso e.symm.unop hX
instance (P : ObjectProperty Cᵒᵖ) [P.IsClosedUnderIsomorphisms] :
P.unop.IsClosedUnderIsomorphisms where
of_iso e hX := P.prop_of_iso e.symm.op hX
lemma op_isoClosure (P : ObjectProperty C) :
P.isoClosure.op = P.op.isoClosure := by
ext ⟨X⟩
exact ⟨fun ⟨Y, h, ⟨e⟩⟩ ↦ ⟨op Y, h, ⟨e.op.symm⟩⟩,
fun ⟨Y, h, ⟨e⟩⟩ ↦ ⟨Y.unop, h, ⟨e.unop.symm⟩⟩⟩
lemma unop_isoClosure (P : ObjectProperty Cᵒᵖ) :
P.isoClosure.unop = P.unop.isoClosure := by
rw [← op_injective_iff, P.unop.op_isoClosure, op_unop, op_unop]
/-- The bijection `Subtype P.op ≃ Subtype P` for `P : ObjectProperty C`. -/
def subtypeOpEquiv (P : ObjectProperty C) :
Subtype P.op ≃ Subtype P where
toFun x := ⟨x.1.unop, x.2⟩
invFun x := ⟨op x.1, x.2⟩
@[simp]
lemma op_ofObj {ι : Type*} (X : ι → C) : (ofObj X).op = ofObj (fun i ↦ op (X i)) := by
ext Z
simp only [op_iff, ofObj_iff]
constructor
· rintro ⟨i, hi⟩
exact ⟨i, by rw [hi]⟩
· rintro ⟨i, hi⟩
exact ⟨i, by rw [← hi]⟩
@[simp]
lemma unop_ofObj {ι : Type*} (X : ι → Cᵒᵖ) : (ofObj X).unop = ofObj (fun i ↦ (X i).unop) :=
op_injective ((op_ofObj _).symm)
@[simp high]
lemma op_singleton (X : C) :
(singleton X).op = singleton (op X) := by
simp
@[simp high]
lemma unop_singleton (X : Cᵒᵖ) :
(singleton X).unop = singleton X.unop := by
simp
end CategoryTheory.ObjectProperty |
.lake/packages/mathlib/Mathlib/CategoryTheory/ObjectProperty/EpiMono.lean | import Mathlib.CategoryTheory.ObjectProperty.ClosedUnderIsomorphisms
import Mathlib.Algebra.Homology.ShortComplex.ShortExact
/-!
# Properties of objects that are closed under subobjects and quotients
Given a category `C` and `P : ObjectProperty C`, we define type classes
`P.IsClosedUnderSubobjects` and `P.IsClosedUnderQuotients` expressing
that `P` is closed under subobjects (resp. quotients).
-/
universe v v' u u'
namespace CategoryTheory
open Limits
variable {C : Type u} [Category.{v} C] {D : Type u'} [Category.{v'} D]
namespace ObjectProperty
variable (P : ObjectProperty C)
/-- Given `P : ObjectProperty C`, we say that `P` is closed under subobjects,
if for any monomorphism `X ⟶ Y`, `P Y` implies `P X`. -/
class IsClosedUnderSubobjects : Prop where
prop_of_mono {X Y : C} (f : X ⟶ Y) [Mono f] (hY : P Y) : P X
section
variable [P.IsClosedUnderSubobjects]
lemma prop_of_mono {X Y : C} (f : X ⟶ Y) [Mono f] (hY : P Y) : P X :=
IsClosedUnderSubobjects.prop_of_mono f hY
instance : P.IsClosedUnderIsomorphisms where
of_iso e := P.prop_of_mono e.inv
lemma prop_X₁_of_shortExact [HasZeroMorphisms C] {S : ShortComplex C} (hS : S.ShortExact)
(h₂ : P S.X₂) : P S.X₁ := by
have := hS.mono_f
exact P.prop_of_mono S.f h₂
instance (F : D ⥤ C) [F.PreservesMonomorphisms] :
(P.inverseImage F).IsClosedUnderSubobjects where
prop_of_mono f _ h := P.prop_of_mono (F.map f) h
end
section
/-- Given `P : ObjectProperty C`, we say that `P` is closed under quotients,
if for any epimorphism `X ⟶ Y`, `P X` implies `P Y`. -/
class IsClosedUnderQuotients : Prop where
prop_of_epi {X Y : C} (f : X ⟶ Y) [Epi f] (hX : P X) : P Y
variable [P.IsClosedUnderQuotients]
lemma prop_of_epi {X Y : C} (f : X ⟶ Y) [Epi f] (hX : P X) : P Y :=
IsClosedUnderQuotients.prop_of_epi f hX
instance : P.IsClosedUnderIsomorphisms where
of_iso e := P.prop_of_epi e.hom
lemma prop_X₃_of_shortExact [HasZeroMorphisms C] {S : ShortComplex C} (hS : S.ShortExact)
(h₂ : P S.X₂) : P S.X₃ := by
have := hS.epi_g
exact P.prop_of_epi S.g h₂
instance (F : D ⥤ C) [F.PreservesEpimorphisms] :
(P.inverseImage F).IsClosedUnderQuotients where
prop_of_epi f _ h := P.prop_of_epi (F.map f) h
end
instance : (⊤ : ObjectProperty C).IsClosedUnderSubobjects where
prop_of_mono := by simp
instance : (⊤ : ObjectProperty C).IsClosedUnderQuotients where
prop_of_epi := by simp
instance [HasZeroMorphisms C] : IsClosedUnderSubobjects (IsZero (C := C)) where
prop_of_mono f _ hX := IsZero.of_mono f hX
instance [HasZeroMorphisms C] : IsClosedUnderQuotients (IsZero (C := C)) where
prop_of_epi f _ hX := IsZero.of_epi f hX
end ObjectProperty
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/ObjectProperty/Retract.lean | import Mathlib.CategoryTheory.ObjectProperty.Basic
import Mathlib.CategoryTheory.Retract
/-! # Properties of objects which are stable under retracts
Given a category `C` and `P : ObjectProperty C` (i.e. `P : C → Prop`),
this file introduces the type class `P.IsStableUnderRetracts`.
-/
namespace CategoryTheory.ObjectProperty
variable {C : Type*} [Category C] (P : ObjectProperty C)
/-- A predicate `C → Prop` on the objects of a category is stable under retracts
if whenever `P Y`, then all the objects `X` that are retracts of `X` also satisfy `P X`. -/
class IsStableUnderRetracts where
of_retract {X Y : C} (_ : Retract X Y) (_ : P Y) : P X
lemma prop_of_retract [IsStableUnderRetracts P] {X Y : C} (h : Retract X Y) (hY : P Y) : P X :=
IsStableUnderRetracts.of_retract h hY
/-- The closure by retracts of a predicate on objects in a category. -/
def retractClosure : ObjectProperty C := fun X => ∃ (Y : C) (_ : P Y), Nonempty (Retract X Y)
lemma prop_retractClosure_iff (X : C) :
retractClosure P X ↔ ∃ (Y : C) (_ : P Y), Nonempty (Retract X Y) := by rfl
variable {P} in
lemma prop_retractClosure {X Y : C} (h : P Y) (r : Retract X Y) : retractClosure P X :=
⟨Y, h, ⟨r⟩⟩
lemma le_retractClosure : P ≤ retractClosure P :=
fun X hX => ⟨X, hX, ⟨Retract.refl X⟩⟩
variable {P Q} in
lemma monotone_retractClosure (h : P ≤ Q) : retractClosure P ≤ retractClosure Q := by
rintro X ⟨X', hX', ⟨e⟩⟩
exact ⟨X', h _ hX', ⟨e⟩⟩
lemma retractClosure_eq_self [IsStableUnderRetracts P] : retractClosure P = P := by
apply le_antisymm
· intro X ⟨Y, hY, ⟨e⟩⟩
exact prop_of_retract P e hY
· exact le_retractClosure P
lemma retractClosure_le_iff (Q : ObjectProperty C) [IsStableUnderRetracts Q] :
retractClosure P ≤ Q ↔ P ≤ Q :=
⟨(le_retractClosure P).trans,
fun h => (monotone_retractClosure h).trans (by rw [retractClosure_eq_self])⟩
instance : IsStableUnderRetracts (retractClosure P) where
of_retract := by
rintro X Y r₁ ⟨Z, hZ, ⟨r₂⟩⟩
refine ⟨Z, hZ, ⟨r₁.trans r₂⟩⟩
end CategoryTheory.ObjectProperty |
.lake/packages/mathlib/Mathlib/CategoryTheory/ObjectProperty/ColimitsClosure.lean | import Mathlib.CategoryTheory.ObjectProperty.LimitsClosure
import Mathlib.CategoryTheory.ObjectProperty.ColimitsOfShape
/-!
# Closure of a property of objects under colimits of certain shapes
In this file, given a property `P` of objects in a category `C` and
family of categories `J : α → Type _`, we introduce the closure
`P.colimitsClosure J` of `P` under colimits of shapes `J a` for all `a : α`,
and under certain smallness assumptions, we show that it is essentially small.
(We deduce these results about the closure under colimits by dualising the
results in the file `ObjectProperty.LimitsClosure`.)
-/
universe w w' t v' u' v u
namespace CategoryTheory.ObjectProperty
open Limits
variable {C : Type u} [Category.{v} C] (P : ObjectProperty C)
{α : Type t} (J : α → Type u') [∀ a, Category.{v'} (J a)]
/-- The closure of a property of objects of a category under colimits of
shape `J a` for a family of categories `J`. -/
inductive colimitsClosure : ObjectProperty C
| of_mem (X : C) (hX : P X) : colimitsClosure X
| of_isoClosure {X Y : C} (e : X ≅ Y) (hX : colimitsClosure X) : colimitsClosure Y
| of_colimitPresentation {X : C} {a : α} (pres : ColimitPresentation (J a) X)
(h : ∀ j, colimitsClosure (pres.diag.obj j)) : colimitsClosure X
@[simp]
lemma le_colimitsClosure : P ≤ P.colimitsClosure J :=
fun X hX ↦ .of_mem X hX
instance : (P.colimitsClosure J).IsClosedUnderIsomorphisms where
of_iso e hX := .of_isoClosure e hX
instance (a : α) : (P.colimitsClosure J).IsClosedUnderColimitsOfShape (J a) where
colimitsOfShape_le := by
rintro X ⟨hX⟩
exact .of_colimitPresentation hX.toColimitPresentation hX.prop_diag_obj
variable {P J} in
lemma colimitsClosure_le {Q : ObjectProperty C} [Q.IsClosedUnderIsomorphisms]
[∀ (a : α), Q.IsClosedUnderColimitsOfShape (J a)] (h : P ≤ Q) :
P.colimitsClosure J ≤ Q := by
intro X hX
induction hX with
| of_mem X hX => exact h _ hX
| of_isoClosure e hX hX' => exact Q.prop_of_iso e hX'
| of_colimitPresentation pres h h' => exact Q.prop_of_isColimit pres.isColimit h'
variable {P} in
lemma colimitsClosure_monotone {Q : ObjectProperty C} (h : P ≤ Q) :
P.colimitsClosure J ≤ Q.colimitsClosure J :=
colimitsClosure_le (h.trans (Q.le_colimitsClosure J))
lemma colimitsClosure_isoClosure :
P.isoClosure.colimitsClosure J = P.colimitsClosure J := by
refine le_antisymm (colimitsClosure_le ?_)
(colimitsClosure_monotone _ P.le_isoClosure)
rw [isoClosure_le_iff]
exact le_colimitsClosure P J
lemma colimitsClosure_eq_unop_limitsClosure :
P.colimitsClosure J = (P.op.limitsClosure (fun a ↦ (J a)ᵒᵖ)).unop := by
refine le_antisymm ?_ ?_
· apply colimitsClosure_le
rw [← op_monotone_iff, op_unop]
apply le_limitsClosure
· rw [← op_monotone_iff, op_unop]
apply limitsClosure_le
rw [op_monotone_iff]
apply le_colimitsClosure
instance [ObjectProperty.EssentiallySmall.{w} P] [LocallySmall.{w} C] [Small.{w} α]
[∀ a, Small.{w} (J a)] [∀ a, LocallySmall.{w} (J a)] :
ObjectProperty.EssentiallySmall.{w} (P.colimitsClosure J) := by
rw [colimitsClosure_eq_unop_limitsClosure]
have (a : α) : Small.{w} (J a)ᵒᵖ := Opposite.small
infer_instance
end CategoryTheory.ObjectProperty |
.lake/packages/mathlib/Mathlib/CategoryTheory/ObjectProperty/FullSubcategory.lean | import Mathlib.CategoryTheory.InducedCategory
import Mathlib.CategoryTheory.ObjectProperty.Basic
/-!
# The full subcategory associated to a property of objects
Given a category `C` and `P : ObjectProperty C`, we define
a category structure on the type `P.FullSubcategory`
of objects in `C` satisfying `P`.
-/
universe v v' u u'
namespace CategoryTheory
namespace ObjectProperty
variable {C : Type u} [Category.{v} C]
section
variable (P : ObjectProperty C)
/--
A subtype-like structure for full subcategories. Morphisms just ignore the property. We don't use
actual subtypes since the simp-normal form `↑X` of `X.val` does not work well for full
subcategories. -/
@[ext, stacks 001D "We do not define 'strictly full' subcategories."]
structure FullSubcategory where
/-- The category of which this is a full subcategory -/
obj : C
/-- The predicate satisfied by all objects in this subcategory -/
property : P obj
instance FullSubcategory.category : Category.{v} P.FullSubcategory :=
InducedCategory.category FullSubcategory.obj
-- these lemmas are not particularly well-typed, so would probably be dangerous as simp lemmas
lemma FullSubcategory.id_def (X : P.FullSubcategory) : 𝟙 X = 𝟙 X.obj := rfl
lemma FullSubcategory.comp_def {X Y Z : P.FullSubcategory} (f : X ⟶ Y) (g : Y ⟶ Z) :
f ≫ g = (f ≫ g : X.obj ⟶ Z.obj) := rfl
/-- The forgetful functor from a full subcategory into the original category
("forgetting" the condition).
-/
def ι : P.FullSubcategory ⥤ C :=
inducedFunctor FullSubcategory.obj
@[simp]
theorem ι_obj {X} : P.ι.obj X = X.obj :=
rfl
@[simp]
theorem ι_map {X Y} {f : X ⟶ Y} : P.ι.map f = f :=
rfl
/-- The inclusion of a full subcategory is fully faithful. -/
abbrev fullyFaithfulι :
P.ι.FullyFaithful :=
fullyFaithfulInducedFunctor _
instance full_ι : P.ι.Full := P.fullyFaithfulι.full
instance faithful_ι : P.ι.Faithful := P.fullyFaithfulι.faithful
/-- Constructor for isomorphisms in `P.FullSubcategory` when
`P : ObjectProperty C`. -/
@[simps]
def isoMk {X Y : P.FullSubcategory} (e : P.ι.obj X ≅ P.ι.obj Y) : X ≅ Y where
hom := e.hom
inv := e.inv
hom_inv_id := e.hom_inv_id
inv_hom_id := e.inv_hom_id
variable {P} {P' : ObjectProperty C}
/-- If `P` and `P'` are properties of objects such that `P ≤ P'`, there is
an induced functor `P.FullSubcategory ⥤ P'.FullSubcategory`. -/
@[simps]
def ιOfLE (h : P ≤ P') : P.FullSubcategory ⥤ P'.FullSubcategory where
obj X := ⟨X.1, h _ X.2⟩
map f := f
/-- If `h : P ≤ P'`, then `ιOfLE h` is fully faithful. -/
def fullyFaithfulιOfLE (h : P ≤ P') :
(ιOfLE h).FullyFaithful where
preimage f := f
instance full_ιOfLE (h : P ≤ P') : (ιOfLE h).Full := (fullyFaithfulιOfLE h).full
instance faithful_ιOfLE (h : P ≤ P') : (ιOfLE h).Faithful := (fullyFaithfulιOfLE h).faithful
/-- If `h : P ≤ P'` is an inequality of properties of objects,
this is the obvious isomorphism `ιOfLE h ⋙ P'.ι ≅ P.ι`. -/
def ιOfLECompιIso (h : P ≤ P') : ιOfLE h ⋙ P'.ι ≅ P.ι := Iso.refl _
end
section lift
variable {D : Type u'} [Category.{v'} D] (P Q : ObjectProperty D)
(F : C ⥤ D) (hF : ∀ X, P (F.obj X))
/-- A functor which maps objects to objects satisfying a certain property induces a lift through
the full subcategory of objects satisfying that property. -/
@[simps]
def lift : C ⥤ FullSubcategory P where
obj X := ⟨F.obj X, hF X⟩
map f := F.map f
/-- Composing the lift of a functor through a full subcategory with the inclusion yields the
original functor. This is actually true definitionally. -/
def liftCompιIso : P.lift F hF ⋙ P.ι ≅ F := Iso.refl _
@[simp]
lemma ι_obj_lift_obj (X : C) :
P.ι.obj ((P.lift F hF).obj X) = F.obj X := rfl
@[simp]
lemma ι_obj_lift_map {X Y : C} (f : X ⟶ Y) :
P.ι.map ((P.lift F hF).map f) = F.map f := rfl
instance [F.Faithful] : (P.lift F hF).Faithful :=
Functor.Faithful.of_comp_iso (P.liftCompιIso F hF)
instance [F.Full] : (P.lift F hF).Full :=
Functor.Full.of_comp_faithful_iso (P.liftCompιIso F hF)
variable {Q}
/-- When `h : P ≤ Q`, this is the canonical isomorphism
`P.lift F hF ⋙ ιOfLE h ≅ Q.lift F _`. -/
def liftCompιOfLEIso (h : P ≤ Q) :
P.lift F hF ⋙ ιOfLE h ≅ Q.lift F (fun X ↦ h _ (hF X)) := Iso.refl _
end lift
end ObjectProperty
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/ObjectProperty/Basic.lean | import Mathlib.CategoryTheory.Category.Basic
import Mathlib.CategoryTheory.Functor.Basic
import Mathlib.CategoryTheory.Iso
import Mathlib.Order.Basic
/-!
# Properties of objects in a category
Given a category `C`, we introduce an abbreviation `ObjectProperty C`
for predicates `C → Prop`.
## TODO
* refactor the file `Limits.FullSubcategory` in order to rename `ClosedUnderLimitsOfShape`
as `ObjectProperty.IsClosedUnderLimitsOfShape` (and make it a type class)
* refactor the file `Triangulated.Subcategory` in order to make it a type class
regarding terms in `ObjectProperty C` when `C` is pretriangulated
-/
universe v v' u u'
namespace CategoryTheory
/-- A property of objects in a category `C` is a predicate `C → Prop`. -/
@[nolint unusedArguments]
abbrev ObjectProperty (C : Type u) [Category.{v} C] : Type u := C → Prop
namespace ObjectProperty
variable {C : Type u} {D : Type u'} [Category.{v} C] [Category.{v'} D]
lemma le_def {P Q : ObjectProperty C} :
P ≤ Q ↔ ∀ (X : C), P X → Q X := Iff.rfl
/-- The inverse image of a property of objects by a functor. -/
def inverseImage (P : ObjectProperty D) (F : C ⥤ D) : ObjectProperty C :=
fun X ↦ P (F.obj X)
@[simp]
lemma prop_inverseImage_iff (P : ObjectProperty D) (F : C ⥤ D) (X : C) :
P.inverseImage F X ↔ P (F.obj X) := Iff.rfl
/-- The essential image of a property of objects by a functor. -/
def map (P : ObjectProperty C) (F : C ⥤ D) : ObjectProperty D :=
fun Y ↦ ∃ (X : C), P X ∧ Nonempty (F.obj X ≅ Y)
lemma prop_map_iff (P : ObjectProperty C) (F : C ⥤ D) (Y : D) :
P.map F Y ↔ ∃ (X : C), P X ∧ Nonempty (F.obj X ≅ Y) := Iff.rfl
lemma prop_map_obj (P : ObjectProperty C) (F : C ⥤ D) {X : C} (hX : P X) :
P.map F (F.obj X) :=
⟨X, hX, ⟨Iso.refl _⟩⟩
/-- The strict image of a property of objects by a functor. -/
inductive strictMap (P : ObjectProperty C) (F : C ⥤ D) : ObjectProperty D
| mk (X : C) (hX : P X) : strictMap P F (F.obj X)
lemma strictMap_iff (P : ObjectProperty C) (F : C ⥤ D) (Y : D) :
P.strictMap F Y ↔ ∃ (X : C), P X ∧ F.obj X = Y :=
⟨by rintro ⟨X, hX⟩; exact ⟨X, hX, rfl⟩, by rintro ⟨X, hX, rfl⟩; exact ⟨X, hX⟩⟩
lemma strictMap_obj (P : ObjectProperty C) (F : C ⥤ D) {X : C} (hX : P X) :
P.strictMap F (F.obj X) :=
⟨X, hX⟩
/-- The typeclass associated to `P : ObjectProperty C`. -/
@[mk_iff]
class Is (P : ObjectProperty C) (X : C) : Prop where
prop : P X
lemma prop_of_is (P : ObjectProperty C) (X : C) [P.Is X] : P X := by rwa [← P.is_iff]
lemma is_of_prop (P : ObjectProperty C) {X : C} (hX : P X) : P.Is X := by rwa [P.is_iff]
section
variable {ι : Type u'} (X : ι → C)
/-- The property of objects that is satisfied by the `X i` for a family
of objects `X : ι : C`. -/
inductive ofObj : ObjectProperty C
| mk (i : ι) : ofObj (X i)
@[simp]
lemma ofObj_apply (i : ι) : ofObj X (X i) := ⟨i⟩
lemma ofObj_iff (Y : C) : ofObj X Y ↔ ∃ i, X i = Y := by
constructor
· rintro ⟨i⟩
exact ⟨i, rfl⟩
· rintro ⟨i, rfl⟩
exact ⟨i⟩
lemma ofObj_le_iff (P : ObjectProperty C) :
ofObj X ≤ P ↔ ∀ i, P (X i) :=
⟨fun h i ↦ h _ (by simp), fun h ↦ by rintro _ ⟨i⟩; exact h i⟩
@[simp]
lemma strictMap_ofObj (F : C ⥤ D) :
(ofObj X).strictMap F = ofObj (F.obj ∘ X) := by
ext Y
simp [ofObj_iff, strictMap_iff]
end
/-- The property of objects in a category that is satisfied by a single object `X : C`. -/
abbrev singleton (X : C) : ObjectProperty C := ofObj (fun (_ : Unit) ↦ X)
@[simp]
lemma singleton_iff (X Y : C) : singleton X Y ↔ X = Y := by simp [ofObj_iff]
@[simp]
lemma singleton_le_iff {X : C} {P : ObjectProperty C} :
singleton X ≤ P ↔ P X := by
simp [ofObj_le_iff]
@[simp high]
lemma strictMap_singleton (X : C) (F : C ⥤ D) :
(singleton X).strictMap F = singleton (F.obj X) := by
ext
simp [strictMap_iff]
/-- The property of objects in a category that is satisfied by `X : C` and `Y : C`. -/
def pair (X Y : C) : ObjectProperty C :=
ofObj (Sum.elim (fun (_ : Unit) ↦ X) (fun (_ : Unit) ↦ Y))
@[simp]
lemma pair_iff (X Y Z : C) :
pair X Y Z ↔ X = Z ∨ Y = Z := by
constructor
· rintro ⟨_ | _⟩ <;> tauto
· rintro (rfl | rfl); exacts [⟨Sum.inl .unit⟩, ⟨Sum.inr .unit⟩]
end ObjectProperty
end CategoryTheory |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.