path stringlengths 11 71 | content stringlengths 75 124k |
|---|---|
CategoryTheory\Adjunction\Limits.lean | /-
Copyright (c) 2019 Reid Barton. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Reid Barton, Johan Commelin
-/
import Mathlib.CategoryTheory.Adjunction.Basic
import Mathlib.CategoryTheory.Limits.Creates
/-!
# Adjunctions and limits
A left adjoint preserves colimits (`CategoryTheory.Adjunction.leftAdjointPreservesColimits`),
and a right adjoint preserves limits (`CategoryTheory.Adjunction.rightAdjointPreservesLimits`).
Equivalences create and reflect (co)limits.
(`CategoryTheory.Adjunction.isEquivalenceCreatesLimits`,
`CategoryTheory.Adjunction.isEquivalenceCreatesColimits`,
`CategoryTheory.Adjunction.isEquivalenceReflectsLimits`,
`CategoryTheory.Adjunction.isEquivalenceReflectsColimits`,)
In `CategoryTheory.Adjunction.coconesIso` we show that
when `F ⊣ G`,
the functor associating to each `Y` the cocones over `K ⋙ F` with cone point `Y`
is naturally isomorphic to
the functor associating to each `Y` the cocones over `K` with cone point `G.obj Y`.
-/
open Opposite
namespace CategoryTheory
open Functor Limits
universe v u v₁ v₂ v₀ u₁ u₂
namespace Adjunction
section ArbitraryUniverse
variable {C : Type u₁} [Category.{v₁} C] {D : Type u₂} [Category.{v₂} D]
variable {F : C ⥤ D} {G : D ⥤ C} (adj : F ⊣ G)
section PreservationColimits
variable {J : Type u} [Category.{v} J] (K : J ⥤ C)
/-- The right adjoint of `Cocones.functoriality K F : Cocone K ⥤ Cocone (K ⋙ F)`.
Auxiliary definition for `functorialityIsLeftAdjoint`.
-/
def functorialityRightAdjoint : Cocone (K ⋙ F) ⥤ Cocone K :=
Cocones.functoriality _ G ⋙
Cocones.precompose (K.rightUnitor.inv ≫ whiskerLeft K adj.unit ≫ (associator _ _ _).inv)
attribute [local simp] functorialityRightAdjoint
/-- The unit for the adjunction for `Cocones.functoriality K F : Cocone K ⥤ Cocone (K ⋙ F)`.
Auxiliary definition for `functorialityIsLeftAdjoint`.
-/
@[simps]
def functorialityUnit :
𝟭 (Cocone K) ⟶ Cocones.functoriality _ F ⋙ functorialityRightAdjoint adj K where
app c := { hom := adj.unit.app c.pt }
/-- The counit for the adjunction for `Cocones.functoriality K F : Cocone K ⥤ Cocone (K ⋙ F)`.
Auxiliary definition for `functorialityIsLeftAdjoint`.
-/
@[simps]
def functorialityCounit :
functorialityRightAdjoint adj K ⋙ Cocones.functoriality _ F ⟶ 𝟭 (Cocone (K ⋙ F)) where
app c := { hom := adj.counit.app c.pt }
/-- The functor `Cocones.functoriality K F : Cocone K ⥤ Cocone (K ⋙ F)` is a left adjoint. -/
def functorialityAdjunction : Cocones.functoriality K F ⊣ functorialityRightAdjoint adj K :=
mkOfUnitCounit
{ unit := functorialityUnit adj K
counit := functorialityCounit adj K}
/-- A left adjoint preserves colimits.
See <https://stacks.math.columbia.edu/tag/0038>.
-/
def leftAdjointPreservesColimits : PreservesColimitsOfSize.{v, u} F where
preservesColimitsOfShape :=
{ preservesColimit :=
{ preserves := fun hc =>
IsColimit.isoUniqueCoconeMorphism.inv fun _ =>
@Equiv.unique _ _ (IsColimit.isoUniqueCoconeMorphism.hom hc _)
((adj.functorialityAdjunction _).homEquiv _ _) } }
-- see Note [lower instance priority]
noncomputable instance (priority := 100) isEquivalencePreservesColimits
(E : C ⥤ D) [E.IsEquivalence] :
PreservesColimitsOfSize.{v, u} E :=
leftAdjointPreservesColimits E.adjunction
-- see Note [lower instance priority]
noncomputable instance (priority := 100) isEquivalenceReflectsColimits
(E : D ⥤ C) [E.IsEquivalence] :
ReflectsColimitsOfSize.{v, u} E where
reflectsColimitsOfShape :=
{ reflectsColimit :=
{ reflects := fun t =>
(isColimitOfPreserves E.inv t).mapCoconeEquiv E.asEquivalence.unitIso.symm } }
-- see Note [lower instance priority]
noncomputable instance (priority := 100) isEquivalenceCreatesColimits (H : D ⥤ C)
[H.IsEquivalence] :
CreatesColimitsOfSize.{v, u} H where
CreatesColimitsOfShape :=
{ CreatesColimit :=
{ lifts := fun c _ =>
{ liftedCocone := mapCoconeInv H c
validLift := mapCoconeMapCoconeInv H c } } }
-- verify the preserve_colimits instance works as expected:
noncomputable example (E : C ⥤ D) [E.IsEquivalence] (c : Cocone K) (h : IsColimit c) :
IsColimit (E.mapCocone c) :=
PreservesColimit.preserves h
theorem hasColimit_comp_equivalence (E : C ⥤ D) [E.IsEquivalence] [HasColimit K] :
HasColimit (K ⋙ E) :=
HasColimit.mk
{ cocone := E.mapCocone (colimit.cocone K)
isColimit := PreservesColimit.preserves (colimit.isColimit K) }
theorem hasColimit_of_comp_equivalence (E : C ⥤ D) [E.IsEquivalence] [HasColimit (K ⋙ E)] :
HasColimit K :=
@hasColimitOfIso _ _ _ _ (K ⋙ E ⋙ E.inv) K
(@hasColimit_comp_equivalence _ _ _ _ _ _ (K ⋙ E) E.inv _ _)
((Functor.rightUnitor _).symm ≪≫ isoWhiskerLeft K E.asEquivalence.unitIso)
/-- Transport a `HasColimitsOfShape` instance across an equivalence. -/
theorem hasColimitsOfShape_of_equivalence (E : C ⥤ D) [E.IsEquivalence] [HasColimitsOfShape J D] :
HasColimitsOfShape J C :=
⟨fun F => hasColimit_of_comp_equivalence F E⟩
/-- Transport a `HasColimitsOfSize` instance across an equivalence. -/
theorem has_colimits_of_equivalence (E : C ⥤ D) [E.IsEquivalence] [HasColimitsOfSize.{v, u} D] :
HasColimitsOfSize.{v, u} C :=
⟨fun _ _ => hasColimitsOfShape_of_equivalence E⟩
end PreservationColimits
section PreservationLimits
variable {J : Type u} [Category.{v} J] (K : J ⥤ D)
/-- The left adjoint of `Cones.functoriality K G : Cone K ⥤ Cone (K ⋙ G)`.
Auxiliary definition for `functorialityIsRightAdjoint`.
-/
def functorialityLeftAdjoint : Cone (K ⋙ G) ⥤ Cone K :=
Cones.functoriality _ F ⋙
Cones.postcompose ((associator _ _ _).hom ≫ whiskerLeft K adj.counit ≫ K.rightUnitor.hom)
attribute [local simp] functorialityLeftAdjoint
/-- The unit for the adjunction for `Cones.functoriality K G : Cone K ⥤ Cone (K ⋙ G)`.
Auxiliary definition for `functorialityIsRightAdjoint`.
-/
@[simps]
def functorialityUnit' :
𝟭 (Cone (K ⋙ G)) ⟶ functorialityLeftAdjoint adj K ⋙ Cones.functoriality _ G where
app c := { hom := adj.unit.app c.pt }
/-- The counit for the adjunction for `Cones.functoriality K G : Cone K ⥤ Cone (K ⋙ G)`.
Auxiliary definition for `functorialityIsRightAdjoint`.
-/
@[simps]
def functorialityCounit' :
Cones.functoriality _ G ⋙ functorialityLeftAdjoint adj K ⟶ 𝟭 (Cone K) where
app c := { hom := adj.counit.app c.pt }
/-- The functor `Cones.functoriality K G : Cone K ⥤ Cone (K ⋙ G)` is a right adjoint. -/
def functorialityAdjunction' : functorialityLeftAdjoint adj K ⊣ Cones.functoriality K G :=
mkOfUnitCounit
{ unit := functorialityUnit' adj K
counit := functorialityCounit' adj K }
/-- A right adjoint preserves limits.
See <https://stacks.math.columbia.edu/tag/0038>.
-/
def rightAdjointPreservesLimits : PreservesLimitsOfSize.{v, u} G where
preservesLimitsOfShape :=
{ preservesLimit :=
{ preserves := fun hc =>
IsLimit.isoUniqueConeMorphism.inv fun _ =>
@Equiv.unique _ _ (IsLimit.isoUniqueConeMorphism.hom hc _)
((adj.functorialityAdjunction' _).homEquiv _ _).symm } }
-- see Note [lower instance priority]
noncomputable instance (priority := 100) isEquivalencePreservesLimits
(E : D ⥤ C) [E.IsEquivalence] :
PreservesLimitsOfSize.{v, u} E :=
rightAdjointPreservesLimits E.asEquivalence.symm.toAdjunction
-- see Note [lower instance priority]
noncomputable instance (priority := 100) isEquivalenceReflectsLimits
(E : D ⥤ C) [E.IsEquivalence] :
ReflectsLimitsOfSize.{v, u} E where
reflectsLimitsOfShape :=
{ reflectsLimit :=
{ reflects := fun t =>
(isLimitOfPreserves E.inv t).mapConeEquiv E.asEquivalence.unitIso.symm } }
-- see Note [lower instance priority]
noncomputable instance (priority := 100) isEquivalenceCreatesLimits (H : D ⥤ C) [H.IsEquivalence] :
CreatesLimitsOfSize.{v, u} H where
CreatesLimitsOfShape :=
{ CreatesLimit :=
{ lifts := fun c _ =>
{ liftedCone := mapConeInv H c
validLift := mapConeMapConeInv H c } } }
-- verify the preserve_limits instance works as expected:
noncomputable example (E : D ⥤ C) [E.IsEquivalence] (c : Cone K) (h : IsLimit c) :
IsLimit (E.mapCone c) :=
PreservesLimit.preserves h
theorem hasLimit_comp_equivalence (E : D ⥤ C) [E.IsEquivalence] [HasLimit K] : HasLimit (K ⋙ E) :=
HasLimit.mk
{ cone := E.mapCone (limit.cone K)
isLimit := PreservesLimit.preserves (limit.isLimit K) }
theorem hasLimit_of_comp_equivalence (E : D ⥤ C) [E.IsEquivalence] [HasLimit (K ⋙ E)] :
HasLimit K :=
@hasLimitOfIso _ _ _ _ (K ⋙ E ⋙ E.inv) K
(@hasLimit_comp_equivalence _ _ _ _ _ _ (K ⋙ E) E.inv _ _)
(isoWhiskerLeft K E.asEquivalence.unitIso.symm ≪≫ Functor.rightUnitor _)
/-- Transport a `HasLimitsOfShape` instance across an equivalence. -/
theorem hasLimitsOfShape_of_equivalence (E : D ⥤ C) [E.IsEquivalence] [HasLimitsOfShape J C] :
HasLimitsOfShape J D :=
⟨fun F => hasLimit_of_comp_equivalence F E⟩
/-- Transport a `HasLimitsOfSize` instance across an equivalence. -/
theorem has_limits_of_equivalence (E : D ⥤ C) [E.IsEquivalence] [HasLimitsOfSize.{v, u} C] :
HasLimitsOfSize.{v, u} D :=
⟨fun _ _ => hasLimitsOfShape_of_equivalence E⟩
end PreservationLimits
/-- auxiliary construction for `coconesIso` -/
@[simp]
def coconesIsoComponentHom {J : Type u} [Category.{v} J] {K : J ⥤ C} (Y : D)
(t : ((cocones J D).obj (op (K ⋙ F))).obj Y) : (G ⋙ (cocones J C).obj (op K)).obj Y where
app j := (adj.homEquiv (K.obj j) Y) (t.app j)
naturality j j' f := by
erw [← adj.homEquiv_naturality_left, t.naturality]
dsimp
simp
/-- auxiliary construction for `coconesIso` -/
@[simp]
def coconesIsoComponentInv {J : Type u} [Category.{v} J] {K : J ⥤ C} (Y : D)
(t : (G ⋙ (cocones J C).obj (op K)).obj Y) : ((cocones J D).obj (op (K ⋙ F))).obj Y where
app j := (adj.homEquiv (K.obj j) Y).symm (t.app j)
naturality j j' f := by
erw [← adj.homEquiv_naturality_left_symm, ← adj.homEquiv_naturality_right_symm, t.naturality]
dsimp; simp
/-- auxiliary construction for `conesIso` -/
@[simp]
def conesIsoComponentHom {J : Type u} [Category.{v} J] {K : J ⥤ D} (X : Cᵒᵖ)
(t : (Functor.op F ⋙ (cones J D).obj K).obj X) : ((cones J C).obj (K ⋙ G)).obj X where
app j := (adj.homEquiv (unop X) (K.obj j)) (t.app j)
naturality j j' f := by
erw [← adj.homEquiv_naturality_right, ← t.naturality, Category.id_comp, Category.id_comp]
rfl
/-- auxiliary construction for `conesIso` -/
@[simp]
def conesIsoComponentInv {J : Type u} [Category.{v} J] {K : J ⥤ D} (X : Cᵒᵖ)
(t : ((cones J C).obj (K ⋙ G)).obj X) : (Functor.op F ⋙ (cones J D).obj K).obj X where
app j := (adj.homEquiv (unop X) (K.obj j)).symm (t.app j)
naturality j j' f := by
erw [← adj.homEquiv_naturality_right_symm, ← t.naturality, Category.id_comp, Category.id_comp]
end ArbitraryUniverse
variable {C : Type u₁} [Category.{v₀} C] {D : Type u₂} [Category.{v₀} D] {F : C ⥤ D} {G : D ⥤ C}
(adj : F ⊣ G)
-- Note: this is natural in K, but we do not yet have the tools to formulate that.
/-- When `F ⊣ G`,
the functor associating to each `Y` the cocones over `K ⋙ F` with cone point `Y`
is naturally isomorphic to
the functor associating to each `Y` the cocones over `K` with cone point `G.obj Y`.
-/
def coconesIso {J : Type u} [Category.{v} J] {K : J ⥤ C} :
(cocones J D).obj (op (K ⋙ F)) ≅ G ⋙ (cocones J C).obj (op K) :=
NatIso.ofComponents fun Y =>
{ hom := coconesIsoComponentHom adj Y
inv := coconesIsoComponentInv adj Y }
-- Note: this is natural in K, but we do not yet have the tools to formulate that.
/-- When `F ⊣ G`,
the functor associating to each `X` the cones over `K` with cone point `F.op.obj X`
is naturally isomorphic to
the functor associating to each `X` the cones over `K ⋙ G` with cone point `X`.
-/
def conesIso {J : Type u} [Category.{v} J] {K : J ⥤ D} :
F.op ⋙ (cones J D).obj K ≅ (cones J C).obj (K ⋙ G) :=
NatIso.ofComponents fun X =>
{ hom := conesIsoComponentHom adj X
inv := conesIsoComponentInv adj X }
end Adjunction
namespace Functor
variable {J C D : Type*} [Category J] [Category C] [Category D]
(F : C ⥤ D)
noncomputable instance [IsLeftAdjoint F] : PreservesColimitsOfShape J F :=
(Adjunction.ofIsLeftAdjoint F).leftAdjointPreservesColimits.preservesColimitsOfShape
noncomputable instance [IsLeftAdjoint F] : PreservesColimitsOfSize.{v, u} F where
noncomputable instance [IsRightAdjoint F] : PreservesLimitsOfShape J F :=
(Adjunction.ofIsRightAdjoint F).rightAdjointPreservesLimits.preservesLimitsOfShape
noncomputable instance [IsRightAdjoint F] : PreservesLimitsOfSize.{v, u} F where
end Functor
end CategoryTheory
|
CategoryTheory\Adjunction\Mates.lean | /-
Copyright (c) 2020 Bhavik Mehta. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Bhavik Mehta, Emily Riehl
-/
import Mathlib.CategoryTheory.Adjunction.Basic
import Mathlib.CategoryTheory.HomCongr
import Mathlib.Tactic.ApplyFun
/-!
# Mate of natural transformations
This file establishes the bijection between the 2-cells
L₁ R₁
C --→ D C ←-- D
G ↓ ↗ ↓ H G ↓ ↘ ↓ H
E --→ F E ←-- F
L₂ R₂
where `L₁ ⊣ R₁` and `L₂ ⊣ R₂`. The corresponding natural transformations are called mates.
This bijection includes a number of interesting cases as specializations. For instance, in the
special case where `G,H` are identity functors then the bijection preserves and reflects
isomorphisms (i.e. we have bijections`(L₂ ⟶ L₁) ≃ (R₁ ⟶ R₂)`, and if either side is an iso then the
other side is as well). This demonstrates that adjoints to a given functor are unique up to
isomorphism (since if `L₁ ≅ L₂` then we deduce `R₁ ≅ R₂`).
Another example arises from considering the square representing that a functor `H` preserves
products, in particular the morphism `HA ⨯ H- ⟶ H(A ⨯ -)`. Then provided `(A ⨯ -)` and `HA ⨯ -`
have left adjoints (for instance if the relevant categories are cartesian closed), the transferred
natural transformation is the exponential comparison morphism: `H(A ^ -) ⟶ HA ^ H-`.
Furthermore if `H` has a left adjoint `L`, this morphism is an isomorphism iff its mate
`L(HA ⨯ -) ⟶ A ⨯ L-` is an isomorphism, see
https://ncatlab.org/nlab/show/Frobenius+reciprocity#InCategoryTheory.
This also relates to Grothendieck's yoga of six operations, though this is not spelled out in
mathlib: https://ncatlab.org/nlab/show/six+operations.
-/
universe v₁ v₂ v₃ v₄ v₅ v₆ v₇ v₈ v₉ u₁ u₂ u₃ u₄ u₅ u₆ u₇ u₈ u₉
namespace CategoryTheory
open Category Functor Adjunction NatTrans
section mateEquiv
variable {C : Type u₁} {D : Type u₂}{E : Type u₃} {F : Type u₄}
variable [Category.{v₁} C] [Category.{v₂} D][Category.{v₃} E] [Category.{v₄} F]
variable {G : C ⥤ E} {H : D ⥤ F} {L₁ : C ⥤ D} {R₁ : D ⥤ C} {L₂ : E ⥤ F} {R₂ : F ⥤ E}
variable (adj₁ : L₁ ⊣ R₁) (adj₂ : L₂ ⊣ R₂)
/-- Suppose we have a square of functors (where the top and bottom are adjunctions `L₁ ⊣ R₁`
and `L₂ ⊣ R₂` respectively).
C ↔ D
G ↓ ↓ H
E ↔ F
Then we have a bijection between natural transformations `G ⋙ L₂ ⟶ L₁ ⋙ H` and
`R₁ ⋙ G ⟶ H ⋙ R₂`. This can be seen as a bijection of the 2-cells:
L₁ R₁
C --→ D C ←-- D
G ↓ ↗ ↓ H G ↓ ↘ ↓ H
E --→ F E ←-- F
L₂ R₂
Note that if one of the transformations is an iso, it does not imply the other is an iso.
-/
@[simps]
def mateEquiv : (G ⋙ L₂ ⟶ L₁ ⋙ H) ≃ (R₁ ⋙ G ⟶ H ⋙ R₂) where
toFun α :=
whiskerLeft (R₁ ⋙ G) adj₂.unit ≫
whiskerRight (whiskerLeft R₁ α) R₂ ≫
whiskerRight adj₁.counit (H ⋙ R₂)
invFun β :=
whiskerRight adj₁.unit (G ⋙ L₂) ≫
whiskerRight (whiskerLeft L₁ β) L₂ ≫
whiskerLeft (L₁ ⋙ H) adj₂.counit
left_inv α := by
ext
unfold whiskerRight whiskerLeft
simp only [comp_obj, id_obj, Functor.comp_map, comp_app, map_comp, assoc, counit_naturality,
counit_naturality_assoc, left_triangle_components_assoc]
rw [← assoc, ← Functor.comp_map, α.naturality, Functor.comp_map, assoc, ← H.map_comp,
left_triangle_components, map_id]
simp only [comp_obj, comp_id]
right_inv β := by
ext
unfold whiskerLeft whiskerRight
simp only [comp_obj, id_obj, Functor.comp_map, comp_app, map_comp, assoc,
unit_naturality_assoc, right_triangle_components_assoc]
rw [← assoc, ← Functor.comp_map, assoc, ← β.naturality, ← assoc, Functor.comp_map,
← G.map_comp, right_triangle_components, map_id, id_comp]
@[deprecated (since := "2024-07-09")] alias transferNatTrans := mateEquiv
/-- A component of a transposed version of the mates correspondence. -/
theorem mateEquiv_counit (α : G ⋙ L₂ ⟶ L₁ ⋙ H) (d : D) :
L₂.map ((mateEquiv adj₁ adj₂ α).app _) ≫ adj₂.counit.app _ =
α.app _ ≫ H.map (adj₁.counit.app d) := by
erw [Functor.map_comp]; simp
/-- A component of a transposed version of the inverse mates correspondence. -/
theorem mateEquiv_counit_symm (α : R₁ ⋙ G ⟶ H ⋙ R₂) (d : D) :
L₂.map (α.app _) ≫ adj₂.counit.app _ =
((mateEquiv adj₁ adj₂).symm α).app _ ≫ H.map (adj₁.counit.app d) := by
conv_lhs => rw [← (mateEquiv adj₁ adj₂).right_inv α]
exact (mateEquiv_counit adj₁ adj₂ ((mateEquiv adj₁ adj₂).symm α) d)
/- A component of a transposed version of the mates correspondence. -/
theorem unit_mateEquiv (α : G ⋙ L₂ ⟶ L₁ ⋙ H) (c : C) :
G.map (adj₁.unit.app c) ≫ (mateEquiv adj₁ adj₂ α).app _ =
adj₂.unit.app _ ≫ R₂.map (α.app _) := by
dsimp [mateEquiv]
rw [← adj₂.unit_naturality_assoc]
slice_lhs 2 3 =>
rw [← R₂.map_comp, ← Functor.comp_map G L₂, α.naturality]
rw [R₂.map_comp]
slice_lhs 3 4 =>
{
rw [← R₂.map_comp, Functor.comp_map L₁ H, ← H.map_comp, left_triangle_components]
}
simp only [comp_obj, map_id, comp_id]
/-- A component of a transposed version of the inverse mates correspondence. -/
theorem unit_mateEquiv_symm (α : R₁ ⋙ G ⟶ H ⋙ R₂) (c : C) :
G.map (adj₁.unit.app c) ≫ α.app _ =
adj₂.unit.app _ ≫ R₂.map (((mateEquiv adj₁ adj₂).symm α).app _) := by
conv_lhs => rw [← (mateEquiv adj₁ adj₂).right_inv α]
exact (unit_mateEquiv adj₁ adj₂ ((mateEquiv adj₁ adj₂).symm α) c)
end mateEquiv
section mateEquivVComp
variable {A : Type u₁} {B : Type u₂} {C : Type u₃} {D : Type u₄} {E : Type u₅} {F : Type u₆}
variable [Category.{v₁} A] [Category.{v₂} B][Category.{v₃} C]
variable [Category.{v₄} D] [Category.{v₅} E][Category.{v₆} F]
variable {G₁ : A ⥤ C}{G₂ : C ⥤ E}{H₁ : B ⥤ D}{H₂ : D ⥤ F}
variable {L₁ : A ⥤ B}{R₁ : B ⥤ A} {L₂ : C ⥤ D}{R₂ : D ⥤ C}{L₃ : E ⥤ F}{R₃ : F ⥤ E}
variable (adj₁ : L₁ ⊣ R₁) (adj₂ : L₂ ⊣ R₂) (adj₃ : L₃ ⊣ R₃)
/-- Squares between left adjoints can be composed "vertically" by pasting. -/
def leftAdjointSquare.vcomp :
(G₁ ⋙ L₂ ⟶ L₁ ⋙ H₁) → (G₂ ⋙ L₃ ⟶ L₂ ⋙ H₂) → ((G₁ ⋙ G₂) ⋙ L₃ ⟶ L₁ ⋙ (H₁ ⋙ H₂)) :=
fun α β ↦ (whiskerLeft G₁ β) ≫ (whiskerRight α H₂)
/-- Squares between right adjoints can be composed "vertically" by pasting. -/
def rightAdjointSquare.vcomp :
(R₁ ⋙ G₁ ⟶ H₁ ⋙ R₂) → (R₂ ⋙ G₂ ⟶ H₂ ⋙ R₃) → (R₁ ⋙ (G₁ ⋙ G₂) ⟶ (H₁ ⋙ H₂) ⋙ R₃) :=
fun α β ↦ (whiskerRight α G₂) ≫ (whiskerLeft H₁ β)
/-- The mates equivalence commutes with vertical composition. -/
theorem mateEquiv_vcomp
(α : G₁ ⋙ L₂ ⟶ L₁ ⋙ H₁) (β : G₂ ⋙ L₃ ⟶ L₂ ⋙ H₂) :
(mateEquiv (G := G₁ ⋙ G₂) (H := H₁ ⋙ H₂) adj₁ adj₃) (leftAdjointSquare.vcomp α β) =
rightAdjointSquare.vcomp (mateEquiv adj₁ adj₂ α) (mateEquiv adj₂ adj₃ β) := by
unfold leftAdjointSquare.vcomp rightAdjointSquare.vcomp mateEquiv
ext b
simp only [comp_obj, Equiv.coe_fn_mk, whiskerLeft_comp, whiskerLeft_twice, whiskerRight_comp,
assoc, comp_app, whiskerLeft_app, whiskerRight_app, id_obj, Functor.comp_map,
whiskerRight_twice]
slice_rhs 1 4 =>
{
rw [← assoc, ← assoc, ← unit_naturality (adj₃)]
}
rw [L₃.map_comp, R₃.map_comp]
slice_rhs 2 4 =>
{
rw [← R₃.map_comp, ← R₃.map_comp, ← assoc, ← L₃.map_comp, ← G₂.map_comp, ← G₂.map_comp]
rw [← Functor.comp_map G₂ L₃, β.naturality]
}
rw [(L₂ ⋙ H₂).map_comp, R₃.map_comp, R₃.map_comp]
slice_rhs 4 5 =>
{
rw [← R₃.map_comp, Functor.comp_map L₂ _, ← Functor.comp_map _ L₂, ← H₂.map_comp]
rw [adj₂.counit.naturality]
}
simp only [comp_obj, Functor.comp_map, map_comp, id_obj, Functor.id_map, assoc]
slice_rhs 4 5 =>
{
rw [← R₃.map_comp, ← H₂.map_comp, ← Functor.comp_map _ L₂, adj₂.counit.naturality]
}
simp only [comp_obj, id_obj, Functor.id_map, map_comp, assoc]
slice_rhs 3 4 =>
{
rw [← R₃.map_comp, ← H₂.map_comp, left_triangle_components]
}
simp only [map_id, id_comp]
end mateEquivVComp
section mateEquivHComp
variable {A : Type u₁} {B : Type u₂} {C : Type u₃} {D : Type u₄} {E : Type u₅} {F : Type u₆}
variable [Category.{v₁} A] [Category.{v₂} B][Category.{v₃} C]
variable [Category.{v₄} D] [Category.{v₅} E][Category.{v₆} F]
variable {G : A ⥤ D}{H : B ⥤ E}{K : C ⥤ F}
variable {L₁ : A ⥤ B}{R₁ : B ⥤ A} {L₂ : D ⥤ E}{R₂ : E ⥤ D}
variable {L₃ : B ⥤ C}{R₃ : C ⥤ B} {L₄ : E ⥤ F}{R₄ : F ⥤ E}
variable (adj₁ : L₁ ⊣ R₁) (adj₂ : L₂ ⊣ R₂) (adj₃ : L₃ ⊣ R₃) (adj₄ : L₄ ⊣ R₄)
/-- Squares between left adjoints can be composed "horizontally" by pasting. -/
def leftAdjointSquare.hcomp :
(G ⋙ L₂ ⟶ L₁ ⋙ H) → (H ⋙ L₄ ⟶ L₃ ⋙ K) → (G ⋙ (L₂ ⋙ L₄) ⟶ (L₁ ⋙ L₃) ⋙ K) := fun α β ↦
(whiskerRight α L₄) ≫ (whiskerLeft L₁ β)
/-- Squares between right adjoints can be composed "horizontally" by pasting. -/
def rightAdjointSquare.hcomp :
(R₁ ⋙ G ⟶ H ⋙ R₂) → (R₃ ⋙ H ⟶ K ⋙ R₄) → ((R₃ ⋙ R₁) ⋙ G ⟶ K ⋙ (R₄ ⋙ R₂)) := fun α β ↦
(whiskerLeft R₃ α) ≫ (whiskerRight β R₂)
/-- The mates equivalence commutes with horizontal composition of squares. -/
theorem mateEquiv_hcomp
(α : G ⋙ L₂ ⟶ L₁ ⋙ H) (β : H ⋙ L₄ ⟶ L₃ ⋙ K) :
(mateEquiv (adj₁.comp adj₃) (adj₂.comp adj₄)) (leftAdjointSquare.hcomp α β) =
rightAdjointSquare.hcomp (mateEquiv adj₁ adj₂ α) (mateEquiv adj₃ adj₄ β) := by
unfold leftAdjointSquare.hcomp rightAdjointSquare.hcomp mateEquiv Adjunction.comp
ext c
simp only [comp_obj, whiskerLeft_comp, whiskerLeft_twice, whiskerRight_comp, assoc,
Equiv.coe_fn_mk, comp_app, whiskerLeft_app, whiskerRight_app, id_obj, associator_inv_app,
Functor.comp_map, associator_hom_app, map_id, id_comp, whiskerRight_twice]
slice_rhs 2 4 =>
{
rw [← R₂.map_comp, ← R₂.map_comp, ← assoc, ← unit_naturality (adj₄)]
}
rw [R₂.map_comp, L₄.map_comp, R₄.map_comp, R₂.map_comp]
slice_rhs 4 5 =>
{
rw [← R₂.map_comp, ← R₄.map_comp, ← Functor.comp_map _ L₄ , β.naturality]
}
simp only [comp_obj, Functor.comp_map, map_comp, assoc]
end mateEquivHComp
section mateEquivSquareComp
variable {A : Type u₁} {B : Type u₂} {C : Type u₃}
variable {D : Type u₄} {E : Type u₅} {F : Type u₆}
variable {X : Type u₇} {Y : Type u₈} {Z : Type u₉}
variable [Category.{v₁} A] [Category.{v₂} B][Category.{v₃} C]
variable [Category.{v₄} D] [Category.{v₅} E][Category.{v₆} F]
variable [Category.{v₇} X] [Category.{v₈} Y][Category.{v₉} Z]
variable {G₁ : A ⥤ D} {H₁ : B ⥤ E} {K₁ : C ⥤ F} {G₂ : D ⥤ X} {H₂ : E ⥤ Y} {K₂ : F ⥤ Z}
variable {L₁ : A ⥤ B} {R₁ : B ⥤ A} {L₂ : B ⥤ C} {R₂ : C ⥤ B} {L₃ : D ⥤ E} {R₃ : E ⥤ D}
variable {L₄ : E ⥤ F} {R₄ : F ⥤ E} {L₅ : X ⥤ Y} {R₅ : Y ⥤ X} {L₆ : Y ⥤ Z} {R₆ : Z ⥤ Y}
variable (adj₁ : L₁ ⊣ R₁) (adj₂ : L₂ ⊣ R₂) (adj₃ : L₃ ⊣ R₃)
variable (adj₄ : L₄ ⊣ R₄) (adj₅ : L₅ ⊣ R₅) (adj₆ : L₆ ⊣ R₆)
/-- Squares of squares between left adjoints can be composed by iterating vertical and horizontal
composition.
-/
def leftAdjointSquare.comp
(α : G₁ ⋙ L₃ ⟶ L₁ ⋙ H₁) (β : H₁ ⋙ L₄ ⟶ L₂ ⋙ K₁)
(γ : G₂ ⋙ L₅ ⟶ L₃ ⋙ H₂) (δ : H₂ ⋙ L₆ ⟶ L₄ ⋙ K₂) :
((G₁ ⋙ G₂) ⋙ (L₅ ⋙ L₆)) ⟶ ((L₁ ⋙ L₂) ⋙ (K₁ ⋙ K₂)) :=
leftAdjointSquare.vcomp (leftAdjointSquare.hcomp α β) (leftAdjointSquare.hcomp γ δ)
theorem leftAdjointSquare.comp_vhcomp
(α : G₁ ⋙ L₃ ⟶ L₁ ⋙ H₁) (β : H₁ ⋙ L₄ ⟶ L₂ ⋙ K₁)
(γ : G₂ ⋙ L₅ ⟶ L₃ ⋙ H₂) (δ : H₂ ⋙ L₆ ⟶ L₄ ⋙ K₂) :
leftAdjointSquare.comp α β γ δ =
leftAdjointSquare.vcomp (leftAdjointSquare.hcomp α β) (leftAdjointSquare.hcomp γ δ) := rfl
/-- Horizontal and vertical composition of squares commutes.-/
theorem leftAdjointSquare.comp_hvcomp
(α : G₁ ⋙ L₃ ⟶ L₁ ⋙ H₁) (β : H₁ ⋙ L₄ ⟶ L₂ ⋙ K₁)
(γ : G₂ ⋙ L₅ ⟶ L₃ ⋙ H₂) (δ : H₂ ⋙ L₆ ⟶ L₄ ⋙ K₂) :
leftAdjointSquare.comp α β γ δ =
leftAdjointSquare.hcomp (leftAdjointSquare.vcomp α γ) (leftAdjointSquare.vcomp β δ) := by
unfold leftAdjointSquare.comp leftAdjointSquare.hcomp leftAdjointSquare.vcomp
unfold whiskerLeft whiskerRight
ext a
simp only [comp_obj, comp_app, map_comp, assoc]
slice_rhs 2 3 =>
{
rw [← Functor.comp_map _ L₆, δ.naturality]
}
simp only [comp_obj, Functor.comp_map, assoc]
/-- Squares of squares between right adjoints can be composed by iterating vertical and horizontal
composition.
-/
def rightAdjointSquare.comp
(α : R₁ ⋙ G₁ ⟶ H₁ ⋙ R₃) (β : R₂ ⋙ H₁ ⟶ K₁ ⋙ R₄)
(γ : R₃ ⋙ G₂ ⟶ H₂ ⋙ R₅) (δ : R₄ ⋙ H₂ ⟶ K₂ ⋙ R₆) :
((R₂ ⋙ R₁) ⋙ (G₁ ⋙ G₂) ⟶ (K₁ ⋙ K₂) ⋙ (R₆ ⋙ R₅)) :=
rightAdjointSquare.vcomp (rightAdjointSquare.hcomp α β) (rightAdjointSquare.hcomp γ δ)
theorem rightAdjointSquare.comp_vhcomp
(α : R₁ ⋙ G₁ ⟶ H₁ ⋙ R₃) (β : R₂ ⋙ H₁ ⟶ K₁ ⋙ R₄)
(γ : R₃ ⋙ G₂ ⟶ H₂ ⋙ R₅) (δ : R₄ ⋙ H₂ ⟶ K₂ ⋙ R₆) :
rightAdjointSquare.comp α β γ δ =
rightAdjointSquare.vcomp (rightAdjointSquare.hcomp α β) (rightAdjointSquare.hcomp γ δ) := rfl
/-- Horizontal and vertical composition of squares commutes.-/
theorem rightAdjointSquare.comp_hvcomp
(α : R₁ ⋙ G₁ ⟶ H₁ ⋙ R₃) (β : R₂ ⋙ H₁ ⟶ K₁ ⋙ R₄)
(γ : R₃ ⋙ G₂ ⟶ H₂ ⋙ R₅) (δ : R₄ ⋙ H₂ ⟶ K₂ ⋙ R₆) :
rightAdjointSquare.comp α β γ δ =
rightAdjointSquare.hcomp (rightAdjointSquare.vcomp α γ) (rightAdjointSquare.vcomp β δ) := by
unfold rightAdjointSquare.comp rightAdjointSquare.hcomp rightAdjointSquare.vcomp
unfold whiskerLeft whiskerRight
ext c
simp only [comp_obj, comp_app, map_comp, assoc]
slice_rhs 2 3 =>
{
rw [← Functor.comp_map _ R₅, ← γ.naturality]
}
simp only [comp_obj, Functor.comp_map, assoc]
/-- The mates equivalence commutes with composition of squares of squares. These results form the
basis for an isomorphism of double categories to be proven later.
-/
theorem mateEquiv_square
(α : G₁ ⋙ L₃ ⟶ L₁ ⋙ H₁) (β : H₁ ⋙ L₄ ⟶ L₂ ⋙ K₁)
(γ : G₂ ⋙ L₅ ⟶ L₃ ⋙ H₂) (δ : H₂ ⋙ L₆ ⟶ L₄ ⋙ K₂) :
(mateEquiv (G := G₁ ⋙ G₂) (H := K₁ ⋙ K₂) (adj₁.comp adj₂) (adj₅.comp adj₆))
(leftAdjointSquare.comp α β γ δ) =
rightAdjointSquare.comp
(mateEquiv adj₁ adj₃ α) (mateEquiv adj₂ adj₄ β)
(mateEquiv adj₃ adj₅ γ) (mateEquiv adj₄ adj₆ δ) := by
have vcomp :=
mateEquiv_vcomp (adj₁.comp adj₂) (adj₃.comp adj₄) (adj₅.comp adj₆)
(leftAdjointSquare.hcomp α β) (leftAdjointSquare.hcomp γ δ)
have hcomp1 := mateEquiv_hcomp adj₁ adj₃ adj₂ adj₄ α β
have hcomp2 := mateEquiv_hcomp adj₃ adj₅ adj₄ adj₆ γ δ
rw [hcomp1, hcomp2] at vcomp
exact vcomp
end mateEquivSquareComp
section conjugateEquiv
variable {C : Type u₁} {D : Type u₂}
variable [Category.{v₁} C] [Category.{v₂} D]
variable {L₁ L₂ : C ⥤ D} {R₁ R₂ : D ⥤ C}
variable (adj₁ : L₁ ⊣ R₁) (adj₂ : L₂ ⊣ R₂)
/-- Given two adjunctions `L₁ ⊣ R₁` and `L₂ ⊣ R₂` both between categories `C`, `D`, there is a
bijection between natural transformations `L₂ ⟶ L₁` and natural transformations `R₁ ⟶ R₂`. This is
defined as a special case of `mateEquiv`, where the two "vertical" functors are identity, modulo
composition with the unitors. Corresponding natural transformations are called `conjugateEquiv`.
TODO: Generalise to when the two vertical functors are equivalences rather than being exactly `𝟭`.
Furthermore, this bijection preserves (and reflects) isomorphisms, i.e. a transformation is an iso
iff its image under the bijection is an iso, see eg `CategoryTheory.conjugateIsoEquiv`.
This is in contrast to the general case `mateEquiv` which does not in general have this property.
-/
def conjugateEquiv : (L₂ ⟶ L₁) ≃ (R₁ ⟶ R₂) :=
calc
(L₂ ⟶ L₁) ≃ _ := (Iso.homCongr L₂.leftUnitor L₁.rightUnitor).symm
_ ≃ _ := mateEquiv adj₁ adj₂
_ ≃ (R₁ ⟶ R₂) := R₁.rightUnitor.homCongr R₂.leftUnitor
@[deprecated (since := "2024-07-09")] alias transferNatTransSelf := conjugateEquiv
/-- A component of a transposed form of the conjugation definition. -/
theorem conjugateEquiv_counit (α : L₂ ⟶ L₁) (d : D) :
L₂.map ((conjugateEquiv adj₁ adj₂ α).app _) ≫ adj₂.counit.app d =
α.app _ ≫ adj₁.counit.app d := by
dsimp [conjugateEquiv]
rw [id_comp, comp_id]
have := mateEquiv_counit adj₁ adj₂ (L₂.leftUnitor.hom ≫ α ≫ L₁.rightUnitor.inv) d
dsimp at this
rw [this]
simp only [comp_id, id_comp]
/-- A component of a transposed form of the inverse conjugation definition. -/
theorem conjugateEquiv_counit_symm (α : R₁ ⟶ R₂) (d : D) :
L₂.map (α.app _) ≫ adj₂.counit.app d =
((conjugateEquiv adj₁ adj₂).symm α).app _ ≫ adj₁.counit.app d := by
conv_lhs => rw [← (conjugateEquiv adj₁ adj₂).right_inv α]
exact (conjugateEquiv_counit adj₁ adj₂ ((conjugateEquiv adj₁ adj₂).symm α) d)
/-- A component of a transposed form of the conjugation definition. -/
theorem unit_conjugateEquiv (α : L₂ ⟶ L₁) (c : C) :
adj₁.unit.app _ ≫ (conjugateEquiv adj₁ adj₂ α).app _ =
adj₂.unit.app c ≫ R₂.map (α.app _) := by
dsimp [conjugateEquiv]
rw [id_comp, comp_id]
have := unit_mateEquiv adj₁ adj₂ (L₂.leftUnitor.hom ≫ α ≫ L₁.rightUnitor.inv) c
dsimp at this
rw [this]
simp
/-- A component of a transposed form of the inverse conjugation definition. -/
theorem unit_conjugateEquiv_symm (α : R₁ ⟶ R₂) (c : C) :
adj₁.unit.app _ ≫ α.app _ =
adj₂.unit.app c ≫ R₂.map (((conjugateEquiv adj₁ adj₂).symm α).app _) := by
conv_lhs => rw [← (conjugateEquiv adj₁ adj₂).right_inv α]
exact (unit_conjugateEquiv adj₁ adj₂ ((conjugateEquiv adj₁ adj₂).symm α) c)
@[simp]
theorem conjugateEquiv_id : conjugateEquiv adj₁ adj₁ (𝟙 _) = 𝟙 _ := by
ext
dsimp [conjugateEquiv, mateEquiv]
simp only [comp_id, map_id, id_comp, right_triangle_components]
@[simp]
theorem conjugateEquiv_symm_id : (conjugateEquiv adj₁ adj₁).symm (𝟙 _) = 𝟙 _ := by
rw [Equiv.symm_apply_eq]
simp only [conjugateEquiv_id]
theorem conjugateEquiv_adjunction_id {L R : C ⥤ C} (adj : L ⊣ R) (α : 𝟭 C ⟶ L) (c : C) :
(conjugateEquiv adj Adjunction.id α).app c = α.app (R.obj c) ≫ adj.counit.app c := by
dsimp [conjugateEquiv, mateEquiv, Adjunction.id]
simp only [comp_id, id_comp]
theorem conjugateEquiv_adjunction_id_symm {L R : C ⥤ C} (adj : L ⊣ R) (α : R ⟶ 𝟭 C) (c : C) :
((conjugateEquiv adj Adjunction.id).symm α).app c = adj.unit.app c ≫ α.app (L.obj c) := by
dsimp [conjugateEquiv, mateEquiv, Adjunction.id]
simp only [comp_id, id_comp]
end conjugateEquiv
section ConjugateComposition
variable {C : Type u₁} {D : Type u₂}
variable [Category.{v₁} C] [Category.{v₂} D]
variable {L₁ L₂ L₃ : C ⥤ D} {R₁ R₂ R₃ : D ⥤ C}
variable (adj₁ : L₁ ⊣ R₁) (adj₂ : L₂ ⊣ R₂) (adj₃ : L₃ ⊣ R₃)
theorem conjugateEquiv_comp (α : L₂ ⟶ L₁) (β : L₃ ⟶ L₂) :
conjugateEquiv adj₁ adj₂ α ≫ conjugateEquiv adj₂ adj₃ β =
conjugateEquiv adj₁ adj₃ (β ≫ α) := by
ext d
dsimp [conjugateEquiv, mateEquiv]
have vcomp := mateEquiv_vcomp adj₁ adj₂ adj₃
(L₂.leftUnitor.hom ≫ α ≫ L₁.rightUnitor.inv)
(L₃.leftUnitor.hom ≫ β ≫ L₂.rightUnitor.inv)
have vcompd := congr_app vcomp d
dsimp [mateEquiv, leftAdjointSquare.vcomp, rightAdjointSquare.vcomp] at vcompd
simp at vcompd
simp only [comp_id, id_comp, assoc, map_comp]
rw [vcompd]
theorem conjugateEquiv_symm_comp (α : R₁ ⟶ R₂) (β : R₂ ⟶ R₃) :
(conjugateEquiv adj₂ adj₃).symm β ≫ (conjugateEquiv adj₁ adj₂).symm α =
(conjugateEquiv adj₁ adj₃).symm (α ≫ β) := by
rw [Equiv.eq_symm_apply, ← conjugateEquiv_comp _ adj₂]
simp only [Equiv.apply_symm_apply]
theorem conjugateEquiv_comm {α : L₂ ⟶ L₁} {β : L₁ ⟶ L₂} (βα : β ≫ α = 𝟙 _) :
conjugateEquiv adj₁ adj₂ α ≫ conjugateEquiv adj₂ adj₁ β = 𝟙 _ := by
rw [conjugateEquiv_comp, βα, conjugateEquiv_id]
theorem conjugateEquiv_symm_comm {α : R₁ ⟶ R₂}{β : R₂ ⟶ R₁} (αβ : α ≫ β = 𝟙 _) :
(conjugateEquiv adj₂ adj₁).symm β ≫ (conjugateEquiv adj₁ adj₂).symm α = 𝟙 _ := by
rw [conjugateEquiv_symm_comp, αβ, conjugateEquiv_symm_id]
end ConjugateComposition
section ConjugateIsomorphism
variable {C : Type u₁} {D : Type u₂}
variable [Category.{v₁} C] [Category.{v₂} D]
variable {L₁ L₂ : C ⥤ D} {R₁ R₂ : D ⥤ C}
variable (adj₁ : L₁ ⊣ R₁) (adj₂ : L₂ ⊣ R₂)
/-- If `α` is an isomorphism between left adjoints, then its conjugate transformation is an
isomorphism. The converse is given in `conjugateEquiv_of_iso`.
-/
instance conjugateEquiv_iso (α : L₂ ⟶ L₁) [IsIso α] :
IsIso (conjugateEquiv adj₁ adj₂ α) :=
⟨⟨conjugateEquiv adj₂ adj₁ (inv α),
⟨conjugateEquiv_comm _ _ (by simp), conjugateEquiv_comm _ _ (by simp)⟩⟩⟩
/-- If `α` is an isomorphism between right adjoints, then its conjugate transformation is an
isomorphism. The converse is given in `conjugateEquiv_symm_of_iso`.
-/
instance conjugateEquiv_symm_iso (α : R₁ ⟶ R₂) [IsIso α] :
IsIso ((conjugateEquiv adj₁ adj₂).symm α) :=
⟨⟨(conjugateEquiv adj₂ adj₁).symm (inv α),
⟨conjugateEquiv_symm_comm _ _ (by simp), conjugateEquiv_symm_comm _ _ (by simp)⟩⟩⟩
/-- If `α` is a natural transformation between left adjoints whose conjugate natural transformation
is an isomorphism, then `α` is an isomorphism. The converse is given in `Conjugate_iso`.
-/
theorem conjugateEquiv_of_iso (α : L₂ ⟶ L₁) [IsIso (conjugateEquiv adj₁ adj₂ α)] :
IsIso α := by
suffices IsIso ((conjugateEquiv adj₁ adj₂).symm (conjugateEquiv adj₁ adj₂ α))
by simpa using this
infer_instance
/--
If `α` is a natural transformation between right adjoints whose conjugate natural transformation is
an isomorphism, then `α` is an isomorphism. The converse is given in `conjugateEquiv_symm_iso`.
-/
theorem conjugateEquiv_symm_of_iso (α : R₁ ⟶ R₂)
[IsIso ((conjugateEquiv adj₁ adj₂).symm α)] : IsIso α := by
suffices IsIso ((conjugateEquiv adj₁ adj₂) ((conjugateEquiv adj₁ adj₂).symm α))
by simpa using this
infer_instance
/-- Thus conjugation defines an equivalence between natural isomorphisms. -/
noncomputable def conjugateIsoEquiv : (L₂ ≅ L₁) ≃ (R₁ ≅ R₂) where
toFun α := asIso (conjugateEquiv adj₁ adj₂ α.hom)
invFun β := asIso ((conjugateEquiv adj₁ adj₂).symm β.hom)
left_inv := by aesop_cat
right_inv := by aesop_cat
end ConjugateIsomorphism
section IteratedmateEquiv
variable {A : Type u₁} {B : Type u₂}{C : Type u₃} {D : Type u₄}
variable [Category.{v₁} A] [Category.{v₂} B][Category.{v₃} C] [Category.{v₄} D]
variable {F₁ : A ⥤ C}{U₁ : C ⥤ A} {F₂ : B ⥤ D} {U₂ : D ⥤ B}
variable {L₁ : A ⥤ B} {R₁ : B ⥤ A} {L₂ : C ⥤ D} {R₂ : D ⥤ C}
variable (adj₁ : L₁ ⊣ R₁) (adj₂ : L₂ ⊣ R₂) (adj₃ : F₁ ⊣ U₁)(adj₄ : F₂ ⊣ U₂)
/-- When all four functors in a sequare are left adjoints, the mates operation can be iterated:
L₁ R₁ R₁
C --→ D C ←-- D C ←-- D
F₁ ↓ ↗ ↓ F₂ F₁ ↓ ↘ ↓ F₂ U₁ ↑ ↙ ↑ U₂
E --→ F E ←-- F E ←-- F
L₂ R₂ R₂
In this case the iterated mate equals the conjugate of the original transformation and is thus an
isomorphism if and only if the original transformation is. This explains why some Beck-Chevalley
natural transformations are natural isomorphisms.
-/
theorem iterated_mateEquiv_conjugateEquiv (α : F₁ ⋙ L₂ ⟶ L₁ ⋙ F₂) :
mateEquiv adj₄ adj₃ (mateEquiv adj₁ adj₂ α) =
conjugateEquiv (adj₁.comp adj₄) (adj₃.comp adj₂) α := by
ext d
unfold conjugateEquiv mateEquiv Adjunction.comp
simp only [comp_obj, Equiv.coe_fn_mk, whiskerLeft_comp, whiskerLeft_twice, whiskerRight_comp,
assoc, comp_app, whiskerLeft_app, whiskerRight_app, id_obj, Functor.comp_map, Iso.homCongr_symm,
Equiv.instTrans_trans, Equiv.trans_apply, Iso.homCongr_apply, Iso.symm_inv, Iso.symm_hom,
rightUnitor_inv_app, associator_inv_app, leftUnitor_hom_app, map_id, associator_hom_app,
Functor.id_map, comp_id, id_comp]
theorem iterated_mateEquiv_conjugateEquiv_symm (α : U₂ ⋙ R₁ ⟶ R₂ ⋙ U₁) :
(mateEquiv adj₁ adj₂).symm ((mateEquiv adj₄ adj₃).symm α) =
(conjugateEquiv (adj₁.comp adj₄) (adj₃.comp adj₂)).symm α := by
rw [Equiv.eq_symm_apply, ← iterated_mateEquiv_conjugateEquiv]
simp only [Equiv.apply_symm_apply]
end IteratedmateEquiv
section mateEquivconjugateEquivVComp
variable {A : Type u₁} {B : Type u₂} {C : Type u₃}{D : Type u₄}
variable [Category.{v₁} A] [Category.{v₂} B][Category.{v₃} C]
variable [Category.{v₄} D]
variable {G : A ⥤ C} {H : B ⥤ D}
variable {L₁ : A ⥤ B} {R₁ : B ⥤ A} {L₂ : C ⥤ D} {R₂ : D ⥤ C} {L₃ : C ⥤ D}{R₃ : D ⥤ C}
variable (adj₁ : L₁ ⊣ R₁) (adj₂ : L₂ ⊣ R₂) (adj₃ : L₃ ⊣ R₃)
/-- Composition of a squares between left adjoints with a conjugate square. -/
def leftAdjointSquareConjugate.vcomp :
(G ⋙ L₂ ⟶ L₁ ⋙ H) → (L₃ ⟶ L₂) → (G ⋙ L₃ ⟶ L₁ ⋙ H) :=
fun α β ↦ (whiskerLeft G β) ≫ α
/-- Composition of a squares between right adjoints with a conjugate square. -/
def rightAdjointSquareConjugate.vcomp :
(R₁ ⋙ G ⟶ H ⋙ R₂) → (R₂ ⟶ R₃) → (R₁ ⋙ G ⟶ H ⋙ R₃) :=
fun α β ↦ α ≫ (whiskerLeft H β)
/-- The mates equivalence commutes with this composition, essentially by `mateEquiv_vcomp`. -/
theorem mateEquiv_conjugateEquiv_vcomp
(α : G ⋙ L₂ ⟶ L₁ ⋙ H) (β : L₃ ⟶ L₂) :
(mateEquiv adj₁ adj₃) (leftAdjointSquareConjugate.vcomp α β) =
rightAdjointSquareConjugate.vcomp (mateEquiv adj₁ adj₂ α) (conjugateEquiv adj₂ adj₃ β) := by
ext b
have vcomp := mateEquiv_vcomp adj₁ adj₂ adj₃ α (L₃.leftUnitor.hom ≫ β ≫ L₂.rightUnitor.inv)
unfold leftAdjointSquare.vcomp rightAdjointSquare.vcomp at vcomp
unfold leftAdjointSquareConjugate.vcomp rightAdjointSquareConjugate.vcomp conjugateEquiv
have vcompb := congr_app vcomp b
simp at vcompb
unfold mateEquiv
simp only [comp_obj, Equiv.coe_fn_mk, whiskerLeft_comp, whiskerLeft_twice, whiskerRight_comp,
assoc, comp_app, whiskerLeft_app, whiskerRight_app, id_obj, Functor.comp_map, Iso.homCongr_symm,
Equiv.instTrans_trans, Equiv.trans_apply, Iso.homCongr_apply, Iso.symm_inv, Iso.symm_hom,
rightUnitor_inv_app, leftUnitor_hom_app, map_id, Functor.id_map, comp_id, id_comp]
exact vcompb
end mateEquivconjugateEquivVComp
section conjugateEquivmateEquivVComp
variable {A : Type u₁} {B : Type u₂} {C : Type u₃}{D : Type u₄}
variable [Category.{v₁} A] [Category.{v₂} B][Category.{v₃} C]
variable [Category.{v₄} D]
variable {G : A ⥤ C} {H : B ⥤ D}
variable {L₁ : A ⥤ B} {R₁ : B ⥤ A} {L₂ : A ⥤ B} {R₂ : B ⥤ A} {L₃ : C ⥤ D} {R₃ : D ⥤ C}
variable (adj₁ : L₁ ⊣ R₁) (adj₂ : L₂ ⊣ R₂) (adj₃ : L₃ ⊣ R₃)
/-- Composition of a conjugate square with a squares between left adjoints. -/
def leftAdjointConjugateSquare.vcomp :
(L₂ ⟶ L₁) → (G ⋙ L₃ ⟶ L₂ ⋙ H) → (G ⋙ L₃ ⟶ L₁ ⋙ H) :=
fun α β ↦ β ≫ (whiskerRight α H)
/-- Composition of a conjugate square with a squares between right adjoints. -/
def rightAdjointConjugateSquare.vcomp :
(R₁ ⟶ R₂) → (R₂ ⋙ G ⟶ H ⋙ R₃) → (R₁ ⋙ G ⟶ H ⋙ R₃) :=
fun α β ↦ (whiskerRight α G) ≫ β
/-- The mates equivalence commutes with this composition, essentially by `mateEquiv_vcomp`. -/
theorem conjugateEquiv_mateEquiv_vcomp
(α : L₂ ⟶ L₁) (β : G ⋙ L₃ ⟶ L₂ ⋙ H) :
(mateEquiv adj₁ adj₃) (leftAdjointConjugateSquare.vcomp α β) =
rightAdjointConjugateSquare.vcomp (conjugateEquiv adj₁ adj₂ α) (mateEquiv adj₂ adj₃ β) := by
ext b
have vcomp := mateEquiv_vcomp adj₁ adj₂ adj₃ (L₂.leftUnitor.hom ≫ α ≫ L₁.rightUnitor.inv) β
unfold leftAdjointSquare.vcomp rightAdjointSquare.vcomp at vcomp
unfold leftAdjointConjugateSquare.vcomp rightAdjointConjugateSquare.vcomp conjugateEquiv
have vcompb := congr_app vcomp b
simp at vcompb
unfold mateEquiv
simp only [comp_obj, Equiv.coe_fn_mk, whiskerLeft_comp, whiskerLeft_twice, whiskerRight_comp,
assoc, comp_app, whiskerLeft_app, whiskerRight_app, id_obj, Functor.comp_map, Iso.homCongr_symm,
Equiv.instTrans_trans, Equiv.trans_apply, Iso.homCongr_apply, Iso.symm_inv, Iso.symm_hom,
rightUnitor_inv_app, leftUnitor_hom_app, map_id, Functor.id_map, comp_id, id_comp]
exact vcompb
end conjugateEquivmateEquivVComp
end CategoryTheory
|
CategoryTheory\Adjunction\Opposites.lean | /-
Copyright (c) 2020 Bhavik Mehta. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Bhavik Mehta, Thomas Read, Andrew Yang
-/
import Mathlib.CategoryTheory.Adjunction.Basic
import Mathlib.CategoryTheory.Yoneda
import Mathlib.CategoryTheory.Opposites
/-!
# Opposite adjunctions
This file contains constructions to relate adjunctions of functors to adjunctions of their
opposites.
## Tags
adjunction, opposite, uniqueness
-/
open CategoryTheory
universe v₁ v₂ u₁ u₂
-- morphism levels before object levels. See note [CategoryTheory universes].
variable {C : Type u₁} [Category.{v₁} C] {D : Type u₂} [Category.{v₂} D]
namespace CategoryTheory.Adjunction
/-- If `G.op` is adjoint to `F.op` then `F` is adjoint to `G`. -/
-- Porting note: in mathlib3 we generated all the default `simps` lemmas.
-- However the `simpNF` linter correctly flags some of these as unsuitable simp lemmas.
-- `unit_app` and `counit_app` appear to suffice (tested in mathlib3).
-- See also the porting note on opAdjointOpOfAdjoint
@[simps! unit_app counit_app]
def adjointOfOpAdjointOp (F : C ⥤ D) (G : D ⥤ C) (h : G.op ⊣ F.op) : F ⊣ G :=
Adjunction.mkOfHomEquiv {
homEquiv := fun {X Y} =>
((h.homEquiv (Opposite.op Y) (Opposite.op X)).trans (opEquiv _ _)).symm.trans
(opEquiv _ _)
homEquiv_naturality_left_symm := by
-- Porting note: This proof was handled by `obviously` in mathlib3.
intros X' X Y f g
dsimp [opEquiv]
-- Porting note: Why is `erw` needed here?
-- https://github.com/leanprover-community/mathlib4/issues/5164
erw [homEquiv_unit, homEquiv_unit]
simp
homEquiv_naturality_right := by
-- Porting note: This proof was handled by `obviously` in mathlib3.
intros X Y Y' f g
dsimp [opEquiv]
-- Porting note: Why is `erw` needed here?
-- https://github.com/leanprover-community/mathlib4/issues/5164
erw [homEquiv_counit, homEquiv_counit]
simp }
/-- If `G` is adjoint to `F.op` then `F` is adjoint to `G.unop`. -/
def adjointUnopOfAdjointOp (F : C ⥤ D) (G : Dᵒᵖ ⥤ Cᵒᵖ) (h : G ⊣ F.op) : F ⊣ G.unop :=
adjointOfOpAdjointOp F G.unop (h.ofNatIsoLeft G.opUnopIso.symm)
/-- If `G.op` is adjoint to `F` then `F.unop` is adjoint to `G`. -/
def unopAdjointOfOpAdjoint (F : Cᵒᵖ ⥤ Dᵒᵖ) (G : D ⥤ C) (h : G.op ⊣ F) : F.unop ⊣ G :=
adjointOfOpAdjointOp _ _ (h.ofNatIsoRight F.opUnopIso.symm)
/-- If `G` is adjoint to `F` then `F.unop` is adjoint to `G.unop`. -/
def unopAdjointUnopOfAdjoint (F : Cᵒᵖ ⥤ Dᵒᵖ) (G : Dᵒᵖ ⥤ Cᵒᵖ) (h : G ⊣ F) : F.unop ⊣ G.unop :=
adjointUnopOfAdjointOp F.unop G (h.ofNatIsoRight F.opUnopIso.symm)
/-- If `G` is adjoint to `F` then `F.op` is adjoint to `G.op`. -/
@[simps! unit_app counit_app]
-- Porting note: in mathlib3 we generated all the default `simps` lemmas.
-- However the `simpNF` linter correctly flags some of these as unsuitable simp lemmas.
-- `unit_app` and `counit_app` appear to suffice (tested in mathlib3).
-- See also the porting note on adjointOfOpAdjointOp
def opAdjointOpOfAdjoint (F : C ⥤ D) (G : D ⥤ C) (h : G ⊣ F) : F.op ⊣ G.op :=
Adjunction.mkOfHomEquiv {
homEquiv := fun X Y =>
(opEquiv _ Y).trans ((h.homEquiv _ _).symm.trans (opEquiv X (Opposite.op _)).symm)
homEquiv_naturality_left_symm := by
-- Porting note: This proof was handled by `obviously` in mathlib3.
intros X' X Y f g
dsimp [opEquiv]
-- Porting note: Why is `erw` needed here?
-- https://github.com/leanprover-community/mathlib4/issues/5164
erw [homEquiv_unit, homEquiv_unit]
simp
homEquiv_naturality_right := by
-- Porting note: This proof was handled by `obviously` in mathlib3.
intros X' X Y f g
dsimp [opEquiv]
-- Porting note: Why is `erw` needed here?
-- https://github.com/leanprover-community/mathlib4/issues/5164
erw [homEquiv_counit, homEquiv_counit]
simp }
/-- If `G` is adjoint to `F.unop` then `F` is adjoint to `G.op`. -/
def adjointOpOfAdjointUnop (F : Cᵒᵖ ⥤ Dᵒᵖ) (G : D ⥤ C) (h : G ⊣ F.unop) : F ⊣ G.op :=
(opAdjointOpOfAdjoint F.unop _ h).ofNatIsoLeft F.opUnopIso
/-- If `G.unop` is adjoint to `F` then `F.op` is adjoint to `G`. -/
def opAdjointOfUnopAdjoint (F : C ⥤ D) (G : Dᵒᵖ ⥤ Cᵒᵖ) (h : G.unop ⊣ F) : F.op ⊣ G :=
(opAdjointOpOfAdjoint _ G.unop h).ofNatIsoRight G.opUnopIso
/-- If `G.unop` is adjoint to `F.unop` then `F` is adjoint to `G`. -/
def adjointOfUnopAdjointUnop (F : Cᵒᵖ ⥤ Dᵒᵖ) (G : Dᵒᵖ ⥤ Cᵒᵖ) (h : G.unop ⊣ F.unop) : F ⊣ G :=
(adjointOpOfAdjointUnop _ _ h).ofNatIsoRight G.opUnopIso
/-- If `F` and `F'` are both adjoint to `G`, there is a natural isomorphism
`F.op ⋙ coyoneda ≅ F'.op ⋙ coyoneda`.
We use this in combination with `fullyFaithfulCancelRight` to show left adjoints are unique.
-/
def leftAdjointsCoyonedaEquiv {F F' : C ⥤ D} {G : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F' ⊣ G) :
F.op ⋙ coyoneda ≅ F'.op ⋙ coyoneda :=
NatIso.ofComponents fun X =>
NatIso.ofComponents fun Y =>
((adj1.homEquiv X.unop Y).trans (adj2.homEquiv X.unop Y).symm).toIso
/-- Given two adjunctions, if the right adjoints are naturally isomorphic, then so are the left
adjoints.
Note: it is generally better to use `Adjunction.natIsoEquiv`, see the file `Adjunction.Unique`.
The reason this definition still exists is that apparently `CategoryTheory.extendAlongYonedaYoneda`
uses its definitional properties (TODO: figure out a way to avoid this).
-/
def natIsoOfRightAdjointNatIso {F F' : C ⥤ D} {G G' : D ⥤ C}
(adj1 : F ⊣ G) (adj2 : F' ⊣ G') (r : G ≅ G') : F ≅ F' :=
NatIso.removeOp ((Coyoneda.fullyFaithful.whiskeringRight _).isoEquiv.symm
(leftAdjointsCoyonedaEquiv adj2 (adj1.ofNatIsoRight r)))
/-- Given two adjunctions, if the left adjoints are naturally isomorphic, then so are the right
adjoints.
Note: it is generally better to use `Adjunction.natIsoEquiv`, see the file `Adjunction.Unique`.
-/
def natIsoOfLeftAdjointNatIso {F F' : C ⥤ D} {G G' : D ⥤ C}
(adj1 : F ⊣ G) (adj2 : F' ⊣ G') (l : F ≅ F') : G ≅ G' :=
NatIso.removeOp (natIsoOfRightAdjointNatIso (opAdjointOpOfAdjoint _ F' adj2)
(opAdjointOpOfAdjoint _ _ adj1) (NatIso.op l))
end CategoryTheory.Adjunction
|
CategoryTheory\Adjunction\Over.lean | /-
Copyright (c) 2021 Bhavik Mehta. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Bhavik Mehta, Andrew Yang
-/
import Mathlib.CategoryTheory.Adjunction.Mates
import Mathlib.CategoryTheory.Limits.Shapes.BinaryProducts
import Mathlib.CategoryTheory.Limits.Shapes.Pullback.HasPullback
import Mathlib.CategoryTheory.Monad.Products
/-!
# Adjunctions related to the over category
In a category with pullbacks, for any morphism `f : X ⟶ Y`, the functor
`Over.map f : Over X ⥤ Over Y` has a right adjoint `Over.pullback f`.
In a category with binary products, for any object `X` the functor
`Over.forget X : Over X ⥤ C` has a right adjoint `Over.star X`.
## Main declarations
- `Over.pullback f : Over Y ⥤ Over X` is the functor induced by a morphism `f : X ⟶ Y`.
- `Over.mapPullbackAdj` is the adjunction `Over.map f ⊣ Over.pullback f`.
- `star : C ⥤ Over X` is the functor induced by an object `X`.
- `forgetAdjStar` is the adjunction `forget X ⊣ star X`.
## TODO
Show `star X` itself has a right adjoint provided `C` is cartesian closed and has pullbacks.
-/
noncomputable section
universe v u
namespace CategoryTheory
open Category Limits Comonad
variable {C : Type u} [Category.{v} C] (X : C)
namespace Over
open Limits
variable [HasPullbacks C]
/-- In a category with pullbacks, a morphism `f : X ⟶ Y` induces a functor `Over Y ⥤ Over X`,
by pulling back a morphism along `f`. -/
@[simps! (config := { simpRhs := true}) obj_left obj_hom map_left]
def pullback {X Y : C} (f : X ⟶ Y) : Over Y ⥤ Over X where
obj g := Over.mk (pullback.snd g.hom f)
map := fun g {h} {k} =>
Over.homMk (pullback.lift (pullback.fst _ _ ≫ k.left) (pullback.snd _ _)
(by simp [pullback.condition]))
@[deprecated (since := "2024-05-15")]
noncomputable alias Limits.baseChange := Over.pullback
@[deprecated (since := "2024-07-08")]
noncomputable alias baseChange := pullback
/-- `Over.map f` is left adjoint to `Over.pullback f`. -/
@[simps! unit_app counit_app]
def mapPullbackAdj {X Y : C} (f : X ⟶ Y) : Over.map f ⊣ pullback f :=
Adjunction.mkOfHomEquiv
{ homEquiv := fun x y =>
{ toFun := fun u =>
Over.homMk (pullback.lift u.left x.hom <| by simp)
invFun := fun v => Over.homMk (v.left ≫ pullback.fst _ _) <| by
simp [← Over.w v, pullback.condition]
left_inv := by aesop_cat
right_inv := fun v => by
ext
dsimp
ext
· simp
· simpa using (Over.w v).symm } }
@[deprecated (since := "2024-07-08")]
noncomputable alias mapAdjunction := mapPullbackAdj
/-- pullback (𝟙 X) : Over X ⥤ Over X is the identity functor. -/
def pullbackId {X : C} : pullback (𝟙 X) ≅ 𝟭 _ :=
conjugateIsoEquiv (mapPullbackAdj (𝟙 _)) (Adjunction.id (C := Over _)) (Over.mapId _).symm
/-- pullback commutes with composition (up to natural isomorphism). -/
def pullbackComp {X Y Z : C} (f : X ⟶ Y) (g : Y ⟶ Z) :
pullback (f ≫ g) ≅ pullback g ⋙ pullback f :=
conjugateIsoEquiv (mapPullbackAdj _) ((mapPullbackAdj _).comp (mapPullbackAdj _))
(Over.mapComp _ _).symm
instance pullbackIsRightAdjoint {X Y : C} (f : X ⟶ Y) : (pullback f).IsRightAdjoint :=
⟨_, ⟨mapPullbackAdj f⟩⟩
/--
The functor from `C` to `Over X` which sends `Y : C` to `π₁ : X ⨯ Y ⟶ X`, sometimes denoted `X*`.
-/
@[simps! obj_left obj_hom map_left]
def star [HasBinaryProducts C] : C ⥤ Over X :=
cofree _ ⋙ coalgebraToOver X
/-- The functor `Over.forget X : Over X ⥤ C` has a right adjoint given by `star X`.
Note that the binary products assumption is necessary: the existence of a right adjoint to
`Over.forget X` is equivalent to the existence of each binary product `X ⨯ -`.
-/
def forgetAdjStar [HasBinaryProducts C] : forget X ⊣ star X :=
(coalgebraEquivOver X).symm.toAdjunction.comp (adj _)
/-- Note that the binary products assumption is necessary: the existence of a right adjoint to
`Over.forget X` is equivalent to the existence of each binary product `X ⨯ -`.
-/
instance [HasBinaryProducts C] : (forget X).IsLeftAdjoint :=
⟨_, ⟨forgetAdjStar X⟩⟩
end Over
@[deprecated (since := "2024-05-18")] noncomputable alias star := Over.star
@[deprecated (since := "2024-05-18")] noncomputable alias forgetAdjStar := Over.forgetAdjStar
namespace Under
variable [HasPushouts C]
/-- When `C` has pushouts, a morphism `f : X ⟶ Y` induces a functor `Under X ⥤ Under Y`,
by pushing a morphism forward along `f`. -/
@[simps]
def pushout {X Y : C} (f : X ⟶ Y) : Under X ⥤ Under Y where
obj x := Under.mk (pushout.inr x.hom f)
map := fun x {x'} {u} =>
Under.homMk (pushout.desc (u.right ≫ pushout.inl _ _) (pushout.inr _ _)
(by simp [← pushout.condition]))
/-- `Under.pushout f` is left adjoint to `Under.map f`. -/
@[simps! unit_app counit_app]
def mapPushoutAdj {X Y : C} (f : X ⟶ Y) : pushout f ⊣ map f :=
Adjunction.mkOfHomEquiv {
homEquiv := fun x y => {
toFun := fun u => Under.homMk (pushout.inl _ _ ≫ u.right) <| by
simp only [map_obj_hom]
rw [← Under.w u]
simp only [Functor.const_obj_obj, map_obj_right, Functor.id_obj, pushout_obj, mk_right,
mk_hom]
rw [← assoc, ← assoc, pushout.condition]
invFun := fun v => Under.homMk (pushout.desc v.right y.hom <| by simp)
left_inv := fun u => by
ext
dsimp
ext
· simp
· simpa using (Under.w u).symm
right_inv := by aesop_cat
}
}
/-- pushout (𝟙 X) : Under X ⥤ Under X is the identity functor. -/
def pushoutId {X : C} : pushout (𝟙 X) ≅ 𝟭 _ :=
(conjugateIsoEquiv (Adjunction.id (C := Under _)) (mapPushoutAdj (𝟙 _)) ).symm
(Under.mapId X).symm
/-- pushout commutes with composition (up to natural isomorphism). -/
def pullbackComp {X Y Z : C} (f : X ⟶ Y) (g : Y ⟶ Z) : pushout (f ≫ g) ≅ pushout f ⋙ pushout g :=
(conjugateIsoEquiv ((mapPushoutAdj _).comp (mapPushoutAdj _)) (mapPushoutAdj _) ).symm
(mapComp f g).symm
instance pushoutIsLeftAdjoint {X Y : C} (f : X ⟶ Y) : (pushout f).IsLeftAdjoint :=
⟨_, ⟨mapPushoutAdj f⟩⟩
end Under
end CategoryTheory
|
CategoryTheory\Adjunction\Reflective.lean | /-
Copyright (c) 2020 Bhavik Mehta. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Bhavik Mehta
-/
import Mathlib.CategoryTheory.Adjunction.FullyFaithful
import Mathlib.CategoryTheory.Functor.ReflectsIso
import Mathlib.CategoryTheory.HomCongr
/-!
# Reflective functors
Basic properties of reflective functors, especially those relating to their essential image.
Note properties of reflective functors relating to limits and colimits are included in
`Mathlib.CategoryTheory.Monad.Limits`.
-/
universe v₁ v₂ v₃ u₁ u₂ u₃
noncomputable section
namespace CategoryTheory
open Category Adjunction
variable {C : Type u₁} {D : Type u₂} {E : Type u₃}
variable [Category.{v₁} C] [Category.{v₂} D] [Category.{v₃} E]
/--
A functor is *reflective*, or *a reflective inclusion*, if it is fully faithful and right adjoint.
-/
class Reflective (R : D ⥤ C) extends R.Full, R.Faithful where
/-- a choice of a left adjoint to `R` -/
L : C ⥤ D
/-- `R` is a right adjoint -/
adj : L ⊣ R
variable (i : D ⥤ C)
/-- The reflector `C ⥤ D` when `R : D ⥤ C` is reflective. -/
def reflector [Reflective i] : C ⥤ D := Reflective.L (R := i)
/-- The adjunction `reflector i ⊣ i` when `i` is reflective. -/
def reflectorAdjunction [Reflective i] : reflector i ⊣ i := Reflective.adj
instance [Reflective i] : i.IsRightAdjoint := ⟨_, ⟨reflectorAdjunction i⟩⟩
instance [Reflective i] : (reflector i).IsLeftAdjoint := ⟨_, ⟨reflectorAdjunction i⟩⟩
/-- A reflective functor is fully faithful. -/
def Functor.fullyFaithfulOfReflective [Reflective i] : i.FullyFaithful :=
(reflectorAdjunction i).fullyFaithfulROfIsIsoCounit
-- TODO: This holds more generally for idempotent adjunctions, not just reflective adjunctions.
/-- For a reflective functor `i` (with left adjoint `L`), with unit `η`, we have `η_iL = iL η`.
-/
theorem unit_obj_eq_map_unit [Reflective i] (X : C) :
(reflectorAdjunction i).unit.app (i.obj ((reflector i).obj X)) =
i.map ((reflector i).map ((reflectorAdjunction i).unit.app X)) := by
rw [← cancel_mono (i.map ((reflectorAdjunction i).counit.app ((reflector i).obj X))),
← i.map_comp]
simp
/--
When restricted to objects in `D` given by `i : D ⥤ C`, the unit is an isomorphism. In other words,
`η_iX` is an isomorphism for any `X` in `D`.
More generally this applies to objects essentially in the reflective subcategory, see
`Functor.essImage.unit_isIso`.
-/
example [Reflective i] {B : D} : IsIso ((reflectorAdjunction i).unit.app (i.obj B)) :=
inferInstance
variable {i}
/-- If `A` is essentially in the image of a reflective functor `i`, then `η_A` is an isomorphism.
This gives that the "witness" for `A` being in the essential image can instead be given as the
reflection of `A`, with the isomorphism as `η_A`.
(For any `B` in the reflective subcategory, we automatically have that `ε_B` is an iso.)
-/
theorem Functor.essImage.unit_isIso [Reflective i] {A : C} (h : A ∈ i.essImage) :
IsIso ((reflectorAdjunction i).unit.app A) := by
rwa [isIso_unit_app_iff_mem_essImage]
/-- If `η_A` is a split monomorphism, then `A` is in the reflective subcategory. -/
theorem mem_essImage_of_unit_isSplitMono [Reflective i] {A : C}
[IsSplitMono ((reflectorAdjunction i).unit.app A)] : A ∈ i.essImage := by
let η : 𝟭 C ⟶ reflector i ⋙ i := (reflectorAdjunction i).unit
haveI : IsIso (η.app (i.obj ((reflector i).obj A))) :=
Functor.essImage.unit_isIso ((i.obj_mem_essImage _))
have : Epi (η.app A) := by
refine @epi_of_epi _ _ _ _ _ (retraction (η.app A)) (η.app A) ?_
rw [show retraction _ ≫ η.app A = _ from η.naturality (retraction (η.app A))]
apply epi_comp (η.app (i.obj ((reflector i).obj A)))
haveI := isIso_of_epi_of_isSplitMono (η.app A)
exact (reflectorAdjunction i).mem_essImage_of_unit_isIso A
/-- Composition of reflective functors. -/
instance Reflective.comp (F : C ⥤ D) (G : D ⥤ E) [Reflective F] [Reflective G] :
Reflective (F ⋙ G) where
L := reflector G ⋙ reflector F
adj := (reflectorAdjunction G).comp (reflectorAdjunction F)
/-- (Implementation) Auxiliary definition for `unitCompPartialBijective`. -/
def unitCompPartialBijectiveAux [Reflective i] (A : C) (B : D) :
(A ⟶ i.obj B) ≃ (i.obj ((reflector i).obj A) ⟶ i.obj B) :=
((reflectorAdjunction i).homEquiv _ _).symm.trans
(Functor.FullyFaithful.ofFullyFaithful i).homEquiv
/-- The description of the inverse of the bijection `unitCompPartialBijectiveAux`. -/
theorem unitCompPartialBijectiveAux_symm_apply [Reflective i] {A : C} {B : D}
(f : i.obj ((reflector i).obj A) ⟶ i.obj B) :
(unitCompPartialBijectiveAux _ _).symm f = (reflectorAdjunction i).unit.app A ≫ f := by
simp [unitCompPartialBijectiveAux]
/-- If `i` has a reflector `L`, then the function `(i.obj (L.obj A) ⟶ B) → (A ⟶ B)` given by
precomposing with `η.app A` is a bijection provided `B` is in the essential image of `i`.
That is, the function `fun (f : i.obj (L.obj A) ⟶ B) ↦ η.app A ≫ f` is bijective,
as long as `B` is in the essential image of `i`.
This definition gives an equivalence: the key property that the inverse can be described
nicely is shown in `unitCompPartialBijective_symm_apply`.
This establishes there is a natural bijection `(A ⟶ B) ≃ (i.obj (L.obj A) ⟶ B)`. In other words,
from the point of view of objects in `D`, `A` and `i.obj (L.obj A)` look the same: specifically
that `η.app A` is an isomorphism.
-/
def unitCompPartialBijective [Reflective i] (A : C) {B : C} (hB : B ∈ i.essImage) :
(A ⟶ B) ≃ (i.obj ((reflector i).obj A) ⟶ B) :=
calc
(A ⟶ B) ≃ (A ⟶ i.obj (Functor.essImage.witness hB)) := Iso.homCongr (Iso.refl _) hB.getIso.symm
_ ≃ (i.obj _ ⟶ i.obj (Functor.essImage.witness hB)) := unitCompPartialBijectiveAux _ _
_ ≃ (i.obj ((reflector i).obj A) ⟶ B) :=
Iso.homCongr (Iso.refl _) (Functor.essImage.getIso hB)
@[simp]
theorem unitCompPartialBijective_symm_apply [Reflective i] (A : C) {B : C} (hB : B ∈ i.essImage)
(f) : (unitCompPartialBijective A hB).symm f = (reflectorAdjunction i).unit.app A ≫ f := by
simp [unitCompPartialBijective, unitCompPartialBijectiveAux_symm_apply]
theorem unitCompPartialBijective_symm_natural [Reflective i] (A : C) {B B' : C} (h : B ⟶ B')
(hB : B ∈ i.essImage) (hB' : B' ∈ i.essImage) (f : i.obj ((reflector i).obj A) ⟶ B) :
(unitCompPartialBijective A hB').symm (f ≫ h) = (unitCompPartialBijective A hB).symm f ≫ h := by
simp
theorem unitCompPartialBijective_natural [Reflective i] (A : C) {B B' : C} (h : B ⟶ B')
(hB : B ∈ i.essImage) (hB' : B' ∈ i.essImage) (f : A ⟶ B) :
(unitCompPartialBijective A hB') (f ≫ h) = unitCompPartialBijective A hB f ≫ h := by
rw [← Equiv.eq_symm_apply, unitCompPartialBijective_symm_natural A h, Equiv.symm_apply_apply]
instance [Reflective i] (X : Functor.EssImageSubcategory i) :
IsIso (NatTrans.app (reflectorAdjunction i).unit X.obj) :=
Functor.essImage.unit_isIso X.property
-- Porting note: the following auxiliary definition and the next two lemmas were
-- introduced in order to ease the port
/-- The counit isomorphism of the equivalence `D ≌ i.EssImageSubcategory` given
by `equivEssImageOfReflective` when the functor `i` is reflective. -/
def equivEssImageOfReflective_counitIso_app [Reflective i] (X : Functor.EssImageSubcategory i) :
((Functor.essImageInclusion i ⋙ reflector i) ⋙ Functor.toEssImage i).obj X ≅ X := by
refine Iso.symm (@asIso _ _ X _ ((reflectorAdjunction i).unit.app X.obj) ?_)
refine @isIso_of_reflects_iso _ _ _ _ _ _ _ i.essImageInclusion ?_ _
dsimp
exact inferInstance
lemma equivEssImageOfReflective_map_counitIso_app_hom [Reflective i]
(X : Functor.EssImageSubcategory i) :
(Functor.essImageInclusion i).map (equivEssImageOfReflective_counitIso_app X).hom =
inv (NatTrans.app (reflectorAdjunction i).unit X.obj) := by
simp only [Functor.comp_obj, Functor.essImageInclusion_obj, Functor.toEssImage_obj_obj,
equivEssImageOfReflective_counitIso_app, asIso, Iso.symm_mk, Functor.essImageInclusion_map,
Functor.id_obj]
rfl
lemma equivEssImageOfReflective_map_counitIso_app_inv [Reflective i]
(X : Functor.EssImageSubcategory i) :
(Functor.essImageInclusion i).map (equivEssImageOfReflective_counitIso_app X).inv =
(NatTrans.app (reflectorAdjunction i).unit X.obj) := rfl
/-- If `i : D ⥤ C` is reflective, the inverse functor of `i ≌ F.essImage` can be explicitly
defined by the reflector. -/
@[simps]
def equivEssImageOfReflective [Reflective i] : D ≌ i.EssImageSubcategory where
functor := i.toEssImage
inverse := i.essImageInclusion ⋙ reflector i
unitIso :=
NatIso.ofComponents (fun X => (asIso <| (reflectorAdjunction i).counit.app X).symm)
(by
intro X Y f
dsimp
rw [IsIso.comp_inv_eq, Category.assoc, IsIso.eq_inv_comp]
exact ((reflectorAdjunction i).counit.naturality f).symm)
counitIso :=
NatIso.ofComponents equivEssImageOfReflective_counitIso_app
(by
intro X Y f
apply (Functor.essImageInclusion i).map_injective
have h := ((reflectorAdjunction i).unit.naturality f).symm
rw [Functor.id_map] at h
erw [Functor.map_comp, Functor.map_comp,
equivEssImageOfReflective_map_counitIso_app_hom,
equivEssImageOfReflective_map_counitIso_app_hom,
IsIso.comp_inv_eq, assoc, ← h, IsIso.inv_hom_id_assoc, Functor.comp_map])
functor_unitIso_comp := fun X => by
-- Porting note: this proof was automatically handled by the automation in mathlib
apply (Functor.essImageInclusion i).map_injective
erw [Functor.map_comp, equivEssImageOfReflective_map_counitIso_app_hom]
aesop_cat
/--
A functor is *coreflective*, or *a coreflective inclusion*, if it is fully faithful and left
adjoint.
-/
class Coreflective (L : C ⥤ D) extends L.Full, L.Faithful where
/-- a choice of a right adjoint to `L` -/
R : D ⥤ C
/-- `L` is a left adjoint -/
adj : L ⊣ R
variable (j : C ⥤ D)
/-- The coreflector `D ⥤ C` when `L : C ⥤ D` is coreflective. -/
def coreflector [Coreflective j] : D ⥤ C := Coreflective.R (L := j)
/-- The adjunction `j ⊣ coreflector j` when `j` is coreflective. -/
def coreflectorAdjunction [Coreflective j] : j ⊣ coreflector j := Coreflective.adj
instance [Coreflective j] : j.IsLeftAdjoint := ⟨_, ⟨coreflectorAdjunction j⟩⟩
instance [Coreflective j] : (coreflector j).IsRightAdjoint := ⟨_, ⟨coreflectorAdjunction j⟩⟩
/-- A coreflective functor is fully faithful. -/
def Functor.fullyFaithfulOfCoreflective [Coreflective j] : j.FullyFaithful :=
(coreflectorAdjunction j).fullyFaithfulLOfIsIsoUnit
lemma counit_obj_eq_map_counit [Coreflective j] (X : D) :
(coreflectorAdjunction j).counit.app (j.obj ((coreflector j).obj X)) =
j.map ((coreflector j).map ((coreflectorAdjunction j).counit.app X)) := by
rw [← cancel_epi (j.map ((coreflectorAdjunction j).unit.app ((coreflector j).obj X))),
← j.map_comp]
simp
example [Coreflective j] {B : C} : IsIso ((coreflectorAdjunction j).counit.app (j.obj B)) :=
inferInstance
variable {j}
lemma Functor.essImage.counit_isIso [Coreflective j] {A : D} (h : A ∈ j.essImage) :
IsIso ((coreflectorAdjunction j).counit.app A) := by
rwa [isIso_counit_app_iff_mem_essImage]
lemma mem_essImage_of_counit_isSplitEpi [Coreflective j] {A : D}
[IsSplitEpi ((coreflectorAdjunction j).counit.app A)] : A ∈ j.essImage := by
let ε : coreflector j ⋙ j ⟶ 𝟭 D := (coreflectorAdjunction j).counit
haveI : IsIso (ε.app (j.obj ((coreflector j).obj A))) :=
Functor.essImage.counit_isIso ((j.obj_mem_essImage _))
have : Mono (ε.app A) := by
refine @mono_of_mono _ _ _ _ _ (ε.app A) (section_ (ε.app A)) ?_
rw [show ε.app A ≫ section_ _ = _ from (ε.naturality (section_ (ε.app A))).symm]
apply mono_comp _ (ε.app (j.obj ((coreflector j).obj A)))
haveI := isIso_of_mono_of_isSplitEpi (ε.app A)
exact (coreflectorAdjunction j).mem_essImage_of_counit_isIso A
instance Coreflective.comp (F : C ⥤ D) (G : D ⥤ E) [Coreflective F] [Coreflective G] :
Coreflective (F ⋙ G) where
R := coreflector G ⋙ coreflector F
adj := (coreflectorAdjunction F).comp (coreflectorAdjunction G)
end CategoryTheory
|
CategoryTheory\Adjunction\Restrict.lean | /-
Copyright (c) 2019 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Scott Morrison
-/
import Mathlib.CategoryTheory.Adjunction.Basic
import Mathlib.CategoryTheory.HomCongr
/-!
# Restricting adjunctions
`Adjunction.restrictFullyFaithful` shows that an adjunction can be restricted along fully faithful
inclusions.
-/
namespace CategoryTheory.Adjunction
universe v₁ v₂ u₁ u₂ v₃ v₄ u₃ u₄
open Category Opposite
variable {C : Type u₁} [Category.{v₁} C]
variable {D : Type u₂} [Category.{v₂} D]
variable {C' : Type u₃} [Category.{v₃} C']
variable {D' : Type u₄} [Category.{v₄} D']
variable {iC : C ⥤ C'} {iD : D ⥤ D'}
{L' : C' ⥤ D'} {R' : D' ⥤ C'} (adj : L' ⊣ R') (hiC : iC.FullyFaithful) (hiD : iD.FullyFaithful)
{L : C ⥤ D} {R : D ⥤ C} (comm1 : iC ⋙ L' ≅ L ⋙ iD) (comm2 : iD ⋙ R' ≅ R ⋙ iC)
/-- If `C` is a full subcategory of `C'` and `D` is a full subcategory of `D'`, then we can restrict
an adjunction `L' ⊣ R'` where `L' : C' ⥤ D'` and `R' : D' ⥤ C'` to `C` and `D`.
The construction here is slightly more general, in that `C` is required only to have a full and
faithful "inclusion" functor `iC : C ⥤ C'` (and similarly `iD : D ⥤ D'`) which commute (up to
natural isomorphism) with the proposed restrictions.
-/
noncomputable def restrictFullyFaithful : L ⊣ R :=
Adjunction.mkOfHomEquiv
{ homEquiv := fun X Y =>
calc
(L.obj X ⟶ Y) ≃ (iD.obj (L.obj X) ⟶ iD.obj Y) := hiD.homEquiv
_ ≃ (L'.obj (iC.obj X) ⟶ iD.obj Y) := Iso.homCongr (comm1.symm.app X) (Iso.refl _)
_ ≃ (iC.obj X ⟶ R'.obj (iD.obj Y)) := adj.homEquiv _ _
_ ≃ (iC.obj X ⟶ iC.obj (R.obj Y)) := Iso.homCongr (Iso.refl _) (comm2.app Y)
_ ≃ (X ⟶ R.obj Y) := hiC.homEquiv.symm
homEquiv_naturality_left_symm := fun {X' X Y} f g => by
apply hiD.map_injective
simpa [Trans.trans] using (comm1.inv.naturality_assoc f _).symm
homEquiv_naturality_right := fun {X Y' Y} f g => by
apply hiC.map_injective
suffices R'.map (iD.map g) ≫ comm2.hom.app Y = comm2.hom.app Y' ≫ iC.map (R.map g) by
simp [Trans.trans, this]
apply comm2.hom.naturality g }
@[simp, reassoc]
lemma map_restrictFullyFaithful_unit_app (X : C) :
iC.map ((adj.restrictFullyFaithful hiC hiD comm1 comm2).unit.app X) =
adj.unit.app (iC.obj X) ≫ R'.map (comm1.hom.app X) ≫ comm2.hom.app (L.obj X) := by
simp [restrictFullyFaithful]
@[simp, reassoc]
lemma map_restrictFullyFaithful_counit_app (X : D) :
iD.map ((adj.restrictFullyFaithful hiC hiD comm1 comm2).counit.app X) =
comm1.inv.app (R.obj X) ≫ L'.map (comm2.inv.app X) ≫ adj.counit.app (iD.obj X) := by
dsimp [restrictFullyFaithful]
simp
lemma restrictFullyFaithful_homEquiv_apply {X : C} {Y : D} (f : L.obj X ⟶ Y) :
(adj.restrictFullyFaithful hiC hiD comm1 comm2).homEquiv X Y f =
hiC.preimage (adj.unit.app (iC.obj X) ≫ R'.map (comm1.hom.app X) ≫
R'.map (iD.map f) ≫ comm2.hom.app Y) := by
simp [restrictFullyFaithful]
end CategoryTheory.Adjunction
|
CategoryTheory\Adjunction\Unique.lean | /-
Copyright (c) 2020 Bhavik Mehta. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Bhavik Mehta, Thomas Read, Andrew Yang, Dagur Asgeirsson, Joël Riou
-/
import Mathlib.CategoryTheory.Adjunction.Basic
/-!
# Uniqueness of adjoints
This file shows that adjoints are unique up to natural isomorphism.
## Main results
* `Adjunction.natTransEquiv` and `Adjunction.natIsoEquiv` If `F ⊣ G` and `F' ⊣ G'` are adjunctions,
then there are equivalences `(G ⟶ G') ≃ (F' ⟶ F)` and `(G ≅ G') ≃ (F' ≅ F)`.
Everything else is deduced from this:
* `Adjunction.leftAdjointUniq` : If `F` and `F'` are both left adjoint to `G`, then they are
naturally isomorphic.
* `Adjunction.rightAdjointUniq` : If `G` and `G'` are both right adjoint to `F`, then they are
naturally isomorphic.
-/
open CategoryTheory
variable {C D : Type*} [Category C] [Category D]
namespace CategoryTheory.Adjunction
/--
If `F ⊣ G` and `F' ⊣ G'` are adjunctions, then giving a natural transformation `G ⟶ G'` is the
same as giving a natural transformation `F' ⟶ F`.
-/
@[simps]
def natTransEquiv {F F' : C ⥤ D} {G G' : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F' ⊣ G') :
(G ⟶ G') ≃ (F' ⟶ F) where
toFun f := {
app := fun X ↦ F'.map ((adj1.unit ≫ whiskerLeft F f).app X) ≫ adj2.counit.app _
naturality := by
intro X Y g
simp only [← Category.assoc, ← Functor.map_comp]
erw [(adj1.unit ≫ (whiskerLeft F f)).naturality]
simp
}
invFun f := {
app := fun X ↦ adj2.unit.app (G.obj X) ≫ G'.map (f.app (G.obj X) ≫ adj1.counit.app X)
naturality := by
intro X Y g
erw [← adj2.unit_naturality_assoc]
simp only [← Functor.map_comp]
simp
}
left_inv f := by
ext X
simp only [Functor.comp_obj, NatTrans.comp_app, Functor.id_obj, whiskerLeft_app,
Functor.map_comp, Category.assoc, unit_naturality_assoc, right_triangle_components_assoc]
erw [← f.naturality (adj1.counit.app X), ← Category.assoc]
simp
right_inv f := by
ext
simp
@[simp]
lemma natTransEquiv_id {F : C ⥤ D} {G : D ⥤ C} (adj : F ⊣ G) :
natTransEquiv adj adj (𝟙 _) = 𝟙 _ := by ext; simp
@[simp]
lemma natTransEquiv_id_symm {F : C ⥤ D} {G : D ⥤ C} (adj : F ⊣ G) :
(natTransEquiv adj adj).symm (𝟙 _) = 𝟙 _ := by ext; simp
@[simp]
lemma natTransEquiv_comp {F F' F'' : C ⥤ D} {G G' G'' : D ⥤ C}
(adj1 : F ⊣ G) (adj2 : F' ⊣ G') (adj3 : F'' ⊣ G'') (f : G ⟶ G') (g : G' ⟶ G'') :
natTransEquiv adj2 adj3 g ≫ natTransEquiv adj1 adj2 f = natTransEquiv adj1 adj3 (f ≫ g) := by
apply (natTransEquiv adj1 adj3).symm.injective
ext X
simp only [natTransEquiv_symm_apply_app, Functor.comp_obj, NatTrans.comp_app,
natTransEquiv_apply_app, Functor.id_obj, whiskerLeft_app, Functor.map_comp, Category.assoc,
unit_naturality_assoc, right_triangle_components_assoc, Equiv.symm_apply_apply,
← g.naturality_assoc, ← g.naturality]
simp only [← Category.assoc, unit_naturality, Functor.comp_obj, right_triangle_components,
Category.comp_id, ← f.naturality, Category.id_comp]
@[simp]
lemma natTransEquiv_comp_symm {F F' F'' : C ⥤ D} {G G' G'' : D ⥤ C}
(adj1 : F ⊣ G) (adj2 : F' ⊣ G') (adj3 : F'' ⊣ G'') (f : F' ⟶ F) (g : F'' ⟶ F') :
(natTransEquiv adj1 adj2).symm f ≫ (natTransEquiv adj2 adj3).symm g =
(natTransEquiv adj1 adj3).symm (g ≫ f) := by
apply (natTransEquiv adj1 adj3).injective
ext
simp
/--
If `F ⊣ G` and `F' ⊣ G'` are adjunctions, then giving a natural isomorphism `G ≅ G'` is the
same as giving a natural transformation `F' ≅ F`.
-/
@[simps]
def natIsoEquiv {F F' : C ⥤ D} {G G' : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F' ⊣ G') :
(G ≅ G') ≃ (F' ≅ F) where
toFun i := {
hom := natTransEquiv adj1 adj2 i.hom
inv := natTransEquiv adj2 adj1 i.inv
}
invFun i := {
hom := (natTransEquiv adj1 adj2).symm i.hom
inv := (natTransEquiv adj2 adj1).symm i.inv }
left_inv i := by simp
right_inv i := by simp
/-- If `F` and `F'` are both left adjoint to `G`, then they are naturally isomorphic. -/
def leftAdjointUniq {F F' : C ⥤ D} {G : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F' ⊣ G) : F ≅ F' :=
(natIsoEquiv adj1 adj2 (Iso.refl _)).symm
-- Porting note (#10618): removed simp as simp can prove this
theorem homEquiv_leftAdjointUniq_hom_app {F F' : C ⥤ D} {G : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F' ⊣ G)
(x : C) : adj1.homEquiv _ _ ((leftAdjointUniq adj1 adj2).hom.app x) = adj2.unit.app x := by
simp [leftAdjointUniq]
@[reassoc (attr := simp)]
theorem unit_leftAdjointUniq_hom {F F' : C ⥤ D} {G : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F' ⊣ G) :
adj1.unit ≫ whiskerRight (leftAdjointUniq adj1 adj2).hom G = adj2.unit := by
ext x
rw [NatTrans.comp_app, ← homEquiv_leftAdjointUniq_hom_app adj1 adj2]
simp [← G.map_comp]
@[reassoc (attr := simp)]
theorem unit_leftAdjointUniq_hom_app
{F F' : C ⥤ D} {G : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F' ⊣ G) (x : C) :
adj1.unit.app x ≫ G.map ((leftAdjointUniq adj1 adj2).hom.app x) = adj2.unit.app x := by
rw [← unit_leftAdjointUniq_hom adj1 adj2]; rfl
@[reassoc (attr := simp)]
theorem leftAdjointUniq_hom_counit {F F' : C ⥤ D} {G : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F' ⊣ G) :
whiskerLeft G (leftAdjointUniq adj1 adj2).hom ≫ adj2.counit = adj1.counit := by
ext x
simp only [Functor.comp_obj, Functor.id_obj, leftAdjointUniq, Iso.symm_hom, natIsoEquiv_apply_inv,
Iso.refl_inv, NatTrans.comp_app, whiskerLeft_app, natTransEquiv_apply_app, whiskerLeft_id',
Category.comp_id, Category.assoc]
rw [← adj1.counit_naturality, ← Category.assoc, ← F.map_comp]
simp
@[reassoc (attr := simp)]
theorem leftAdjointUniq_hom_app_counit {F F' : C ⥤ D} {G : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F' ⊣ G)
(x : D) :
(leftAdjointUniq adj1 adj2).hom.app (G.obj x) ≫ adj2.counit.app x = adj1.counit.app x := by
rw [← leftAdjointUniq_hom_counit adj1 adj2]
rfl
theorem leftAdjointUniq_inv_app {F F' : C ⥤ D} {G : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F' ⊣ G) (x : C) :
(leftAdjointUniq adj1 adj2).inv.app x = (leftAdjointUniq adj2 adj1).hom.app x :=
rfl
@[reassoc (attr := simp)]
theorem leftAdjointUniq_trans {F F' F'' : C ⥤ D} {G : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F' ⊣ G)
(adj3 : F'' ⊣ G) :
(leftAdjointUniq adj1 adj2).hom ≫ (leftAdjointUniq adj2 adj3).hom =
(leftAdjointUniq adj1 adj3).hom := by
simp [leftAdjointUniq]
@[reassoc (attr := simp)]
theorem leftAdjointUniq_trans_app {F F' F'' : C ⥤ D} {G : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F' ⊣ G)
(adj3 : F'' ⊣ G) (x : C) :
(leftAdjointUniq adj1 adj2).hom.app x ≫ (leftAdjointUniq adj2 adj3).hom.app x =
(leftAdjointUniq adj1 adj3).hom.app x := by
rw [← leftAdjointUniq_trans adj1 adj2 adj3]
rfl
@[simp]
theorem leftAdjointUniq_refl {F : C ⥤ D} {G : D ⥤ C} (adj1 : F ⊣ G) :
(leftAdjointUniq adj1 adj1).hom = 𝟙 _ := by
simp [leftAdjointUniq]
/-- If `G` and `G'` are both right adjoint to `F`, then they are naturally isomorphic. -/
def rightAdjointUniq {F : C ⥤ D} {G G' : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F ⊣ G') : G ≅ G' :=
(natIsoEquiv adj1 adj2).symm (Iso.refl _)
-- Porting note (#10618): simp can prove this
theorem homEquiv_symm_rightAdjointUniq_hom_app {F : C ⥤ D} {G G' : D ⥤ C} (adj1 : F ⊣ G)
(adj2 : F ⊣ G') (x : D) :
(adj2.homEquiv _ _).symm ((rightAdjointUniq adj1 adj2).hom.app x) = adj1.counit.app x := by
simp [rightAdjointUniq]
@[reassoc (attr := simp)]
theorem unit_rightAdjointUniq_hom_app {F : C ⥤ D} {G G' : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F ⊣ G')
(x : C) : adj1.unit.app x ≫ (rightAdjointUniq adj1 adj2).hom.app (F.obj x) =
adj2.unit.app x := by
simp only [Functor.id_obj, Functor.comp_obj, rightAdjointUniq, natIsoEquiv_symm_apply_hom,
Iso.refl_hom, natTransEquiv_symm_apply_app, NatTrans.id_app, Category.id_comp]
rw [← adj2.unit_naturality_assoc, ← G'.map_comp]
simp
@[reassoc (attr := simp)]
theorem unit_rightAdjointUniq_hom {F : C ⥤ D} {G G' : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F ⊣ G') :
adj1.unit ≫ whiskerLeft F (rightAdjointUniq adj1 adj2).hom = adj2.unit := by
ext x
simp
@[reassoc (attr := simp)]
theorem rightAdjointUniq_hom_app_counit {F : C ⥤ D} {G G' : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F ⊣ G')
(x : D) :
F.map ((rightAdjointUniq adj1 adj2).hom.app x) ≫ adj2.counit.app x = adj1.counit.app x := by
simp [rightAdjointUniq]
@[reassoc (attr := simp)]
theorem rightAdjointUniq_hom_counit {F : C ⥤ D} {G G' : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F ⊣ G') :
whiskerRight (rightAdjointUniq adj1 adj2).hom F ≫ adj2.counit = adj1.counit := by
ext
simp
theorem rightAdjointUniq_inv_app {F : C ⥤ D} {G G' : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F ⊣ G')
(x : D) : (rightAdjointUniq adj1 adj2).inv.app x = (rightAdjointUniq adj2 adj1).hom.app x :=
rfl
@[reassoc (attr := simp)]
theorem rightAdjointUniq_trans {F : C ⥤ D} {G G' G'' : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F ⊣ G')
(adj3 : F ⊣ G'') :
(rightAdjointUniq adj1 adj2).hom ≫ (rightAdjointUniq adj2 adj3).hom =
(rightAdjointUniq adj1 adj3).hom := by
simp [rightAdjointUniq]
@[reassoc (attr := simp)]
theorem rightAdjointUniq_trans_app {F : C ⥤ D} {G G' G'' : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F ⊣ G')
(adj3 : F ⊣ G'') (x : D) :
(rightAdjointUniq adj1 adj2).hom.app x ≫ (rightAdjointUniq adj2 adj3).hom.app x =
(rightAdjointUniq adj1 adj3).hom.app x := by
rw [← rightAdjointUniq_trans adj1 adj2 adj3]
rfl
@[simp]
theorem rightAdjointUniq_refl {F : C ⥤ D} {G : D ⥤ C} (adj1 : F ⊣ G) :
(rightAdjointUniq adj1 adj1).hom = 𝟙 _ := by
delta rightAdjointUniq
simp
end Adjunction
end CategoryTheory
|
CategoryTheory\Adjunction\Whiskering.lean | /-
Copyright (c) 2021 Adam Topaz. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Adam Topaz
-/
import Mathlib.CategoryTheory.Whiskering
import Mathlib.CategoryTheory.Adjunction.Basic
/-!
Given categories `C D E`, functors `F : D ⥤ E` and `G : E ⥤ D` with an adjunction
`F ⊣ G`, we provide the induced adjunction between the functor categories `C ⥤ D` and `C ⥤ E`,
and the functor categories `E ⥤ C` and `D ⥤ C`.
-/
namespace CategoryTheory.Adjunction
open CategoryTheory
variable (C : Type*) {D E : Type*} [Category C] [Category D] [Category E] {F : D ⥤ E} {G : E ⥤ D}
/-- Given an adjunction `F ⊣ G`, this provides the natural adjunction
`(whiskeringRight C _ _).obj F ⊣ (whiskeringRight C _ _).obj G`. -/
@[simps! unit_app_app counit_app_app]
protected def whiskerRight (adj : F ⊣ G) :
(whiskeringRight C D E).obj F ⊣ (whiskeringRight C E D).obj G :=
mkOfUnitCounit
{ unit :=
{ app := fun X =>
(Functor.rightUnitor _).inv ≫ whiskerLeft X adj.unit ≫ (Functor.associator _ _ _).inv
naturality := by intros; ext; dsimp; simp }
counit :=
{ app := fun X =>
(Functor.associator _ _ _).hom ≫ whiskerLeft X adj.counit ≫ (Functor.rightUnitor _).hom
naturality := by intros; ext; dsimp; simp }
left_triangle := by ext; dsimp; simp
right_triangle := by ext; dsimp; simp
}
/-- Given an adjunction `F ⊣ G`, this provides the natural adjunction
`(whiskeringLeft _ _ C).obj G ⊣ (whiskeringLeft _ _ C).obj F`. -/
@[simps! unit_app_app counit_app_app]
protected def whiskerLeft (adj : F ⊣ G) :
(whiskeringLeft E D C).obj G ⊣ (whiskeringLeft D E C).obj F :=
mkOfUnitCounit
{ unit :=
{ app := fun X =>
(Functor.leftUnitor _).inv ≫ whiskerRight adj.unit X ≫ (Functor.associator _ _ _).hom
naturality := by intros; ext; dsimp; simp }
counit :=
{ app := fun X =>
(Functor.associator _ _ _).inv ≫ whiskerRight adj.counit X ≫ (Functor.leftUnitor _).hom
naturality := by intros; ext; dsimp; simp }
left_triangle := by ext x; dsimp; simp [Category.id_comp, Category.comp_id, ← x.map_comp]
right_triangle := by ext x; dsimp; simp [Category.id_comp, Category.comp_id, ← x.map_comp]
}
end CategoryTheory.Adjunction
|
CategoryTheory\Bicategory\Adjunction.lean | /-
Copyright (c) 2023 Yuma Mizuno. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yuma Mizuno
-/
import Mathlib.Tactic.CategoryTheory.Coherence
/-!
# Adjunctions in bicategories
For 1-morphisms `f : a ⟶ b` and `g : b ⟶ a` in a bicategory, an adjunction between `f` and `g`
consists of a pair of 2-morphism `η : 𝟙 a ⟶ f ≫ g` and `ε : g ≫ f ⟶ 𝟙 b` satisfying the triangle
identities. The 2-morphism `η` is called the unit and `ε` is called the counit.
## Main definitions
* `Bicategory.Adjunction`: adjunctions between two 1-morphisms.
* `Bicategory.Equivalence`: adjoint equivalences between two objects.
* `Bicategory.mkOfAdjointifyCounit`: construct an adjoint equivalence from 2-isomorphisms
`η : 𝟙 a ≅ f ≫ g` and `ε : g ≫ f ≅ 𝟙 b`, by upgrading `ε` to a counit.
## Implementation notes
The computation of 2-morphisms in the proof is done using `calc` blocks. Typically,
the LHS and the RHS in each step of `calc` are related by simple rewriting up to associators
and unitors. So the proof for each step should be of the form `rw [...]; coherence`. In practice,
our proofs look like `rw [...]; simp [bicategoricalComp]; coherence`. The `simp` is not strictly
necessary, but it speeds up the proof and allow us to avoid increasing the `maxHeartbeats`.
The speedup is probably due to reducing the length of the expression e.g. by absorbing
identity maps or applying the pentagon relation. Such a hack may not be necessary if the
coherence tactic is improved. One possible way would be to perform such a simplification in the
preprocessing of the coherence tactic.
## TODO
* `Bicategory.mkOfAdjointifyUnit`: construct an adjoint equivalence from 2-isomorphisms
`η : 𝟙 a ≅ f ≫ g` and `ε : g ≫ f ≅ 𝟙 b`, by upgrading `η` to a unit.
-/
namespace CategoryTheory
namespace Bicategory
open Category
open scoped Bicategory
universe w v u
variable {B : Type u} [Bicategory.{w, v} B] {a b c : B} {f : a ⟶ b} {g : b ⟶ a}
/-- The 2-morphism defined by the following pasting diagram:
```
a ------ ▸ a
\ η ◥ \
f \ g / \ f
◢ / ε ◢
b ------ ▸ b
```
-/
def leftZigzag (η : 𝟙 a ⟶ f ≫ g) (ε : g ≫ f ⟶ 𝟙 b) :=
η ▷ f ⊗≫ f ◁ ε
/-- The 2-morphism defined by the following pasting diagram:
```
a ------ ▸ a
◥ \ η ◥
g / \ f / g
/ ε ◢ /
b ------ ▸ b
```
-/
def rightZigzag (η : 𝟙 a ⟶ f ≫ g) (ε : g ≫ f ⟶ 𝟙 b) :=
g ◁ η ⊗≫ ε ▷ g
theorem rightZigzag_idempotent_of_left_triangle
(η : 𝟙 a ⟶ f ≫ g) (ε : g ≫ f ⟶ 𝟙 b) (h : leftZigzag η ε = (λ_ _).hom ≫ (ρ_ _).inv) :
rightZigzag η ε ⊗≫ rightZigzag η ε = rightZigzag η ε := by
dsimp only [rightZigzag]
calc
_ = g ◁ η ⊗≫ ((ε ▷ g ▷ 𝟙 a) ≫ (𝟙 b ≫ g) ◁ η) ⊗≫ ε ▷ g := by
simp [bicategoricalComp]; coherence
_ = 𝟙 _ ⊗≫ g ◁ (η ▷ 𝟙 a ≫ (f ≫ g) ◁ η) ⊗≫ (ε ▷ (g ≫ f) ≫ 𝟙 b ◁ ε) ▷ g ⊗≫ 𝟙 _ := by
rw [← whisker_exchange]; simp [bicategoricalComp]; coherence
_ = g ◁ η ⊗≫ g ◁ leftZigzag η ε ▷ g ⊗≫ ε ▷ g := by
rw [← whisker_exchange, ← whisker_exchange]; simp [leftZigzag, bicategoricalComp]; coherence
_ = g ◁ η ⊗≫ ε ▷ g := by
rw [h]; simp [bicategoricalComp]; coherence
/-- Adjunction between two 1-morphisms. -/
structure Adjunction (f : a ⟶ b) (g : b ⟶ a) where
/-- The unit of an adjunction. -/
unit : 𝟙 a ⟶ f ≫ g
/-- The counit of an adjunction. -/
counit : g ≫ f ⟶ 𝟙 b
/-- The composition of the unit and the counit is equal to the identity up to unitors. -/
left_triangle : leftZigzag unit counit = (λ_ _).hom ≫ (ρ_ _).inv := by aesop_cat
/-- The composition of the unit and the counit is equal to the identity up to unitors. -/
right_triangle : rightZigzag unit counit = (ρ_ _).hom ≫ (λ_ _).inv := by aesop_cat
@[inherit_doc] scoped infixr:15 " ⊣ " => Bicategory.Adjunction
namespace Adjunction
attribute [simp] left_triangle right_triangle
attribute [local simp] leftZigzag rightZigzag
/-- Adjunction between identities. -/
def id (a : B) : 𝟙 a ⊣ 𝟙 a where
unit := (ρ_ _).inv
counit := (ρ_ _).hom
left_triangle := by dsimp; coherence
right_triangle := by dsimp; coherence
instance : Inhabited (Adjunction (𝟙 a) (𝟙 a)) :=
⟨id a⟩
section Composition
variable {f₁ : a ⟶ b} {g₁ : b ⟶ a} {f₂ : b ⟶ c} {g₂ : c ⟶ b}
/-- Auxiliary definition for `adjunction.comp`. -/
@[simp]
def compUnit (adj₁ : f₁ ⊣ g₁) (adj₂ : f₂ ⊣ g₂) : 𝟙 a ⟶ (f₁ ≫ f₂) ≫ g₂ ≫ g₁ :=
adj₁.unit ⊗≫ f₁ ◁ adj₂.unit ▷ g₁ ⊗≫ 𝟙 _
/-- Auxiliary definition for `adjunction.comp`. -/
@[simp]
def compCounit (adj₁ : f₁ ⊣ g₁) (adj₂ : f₂ ⊣ g₂) : (g₂ ≫ g₁) ≫ f₁ ≫ f₂ ⟶ 𝟙 c :=
𝟙 _ ⊗≫ g₂ ◁ adj₁.counit ▷ f₂ ⊗≫ adj₂.counit
theorem comp_left_triangle_aux (adj₁ : f₁ ⊣ g₁) (adj₂ : f₂ ⊣ g₂) :
leftZigzag (compUnit adj₁ adj₂) (compCounit adj₁ adj₂) = (λ_ _).hom ≫ (ρ_ _).inv := by
calc
_ = 𝟙 _ ⊗≫
adj₁.unit ▷ (f₁ ≫ f₂) ⊗≫
f₁ ◁ (adj₂.unit ▷ (g₁ ≫ f₁) ≫ (f₂ ≫ g₂) ◁ adj₁.counit) ▷ f₂ ⊗≫
(f₁ ≫ f₂) ◁ adj₂.counit ⊗≫ 𝟙 _ := by
simp [bicategoricalComp]; coherence
_ = 𝟙 _ ⊗≫
(leftZigzag adj₁.unit adj₁.counit) ▷ f₂ ⊗≫
f₁ ◁ (leftZigzag adj₂.unit adj₂.counit) ⊗≫ 𝟙 _ := by
rw [← whisker_exchange]; simp [bicategoricalComp]; coherence
_ = _ := by
simp_rw [left_triangle]; simp [bicategoricalComp]
theorem comp_right_triangle_aux (adj₁ : f₁ ⊣ g₁) (adj₂ : f₂ ⊣ g₂) :
rightZigzag (compUnit adj₁ adj₂) (compCounit adj₁ adj₂) = (ρ_ _).hom ≫ (λ_ _).inv := by
calc
_ = 𝟙 _ ⊗≫
(g₂ ≫ g₁) ◁ adj₁.unit ⊗≫
g₂ ◁ ((g₁ ≫ f₁) ◁ adj₂.unit ≫ adj₁.counit ▷ (f₂ ≫ g₂)) ▷ g₁ ⊗≫
adj₂.counit ▷ (g₂ ≫ g₁) ⊗≫ 𝟙 _ := by
simp [bicategoricalComp]; coherence
_ = 𝟙 _ ⊗≫
g₂ ◁ (rightZigzag adj₁.unit adj₁.counit) ⊗≫
(rightZigzag adj₂.unit adj₂.counit) ▷ g₁ ⊗≫ 𝟙 _ := by
rw [whisker_exchange]; simp [bicategoricalComp]; coherence
_ = _ := by
simp_rw [right_triangle]; simp [bicategoricalComp]
/-- Composition of adjunctions. -/
@[simps]
def comp (adj₁ : f₁ ⊣ g₁) (adj₂ : f₂ ⊣ g₂) : f₁ ≫ f₂ ⊣ g₂ ≫ g₁ where
unit := compUnit adj₁ adj₂
counit := compCounit adj₁ adj₂
left_triangle := by apply comp_left_triangle_aux
right_triangle := by apply comp_right_triangle_aux
end Composition
end Adjunction
noncomputable section
variable (η : 𝟙 a ≅ f ≫ g) (ε : g ≫ f ≅ 𝟙 b)
/-- The isomorphism version of `leftZigzag`. -/
def leftZigzagIso (η : 𝟙 a ≅ f ≫ g) (ε : g ≫ f ≅ 𝟙 b) :=
whiskerRightIso η f ≪⊗≫ whiskerLeftIso f ε
/-- The isomorphism version of `rightZigzag`. -/
def rightZigzagIso (η : 𝟙 a ≅ f ≫ g) (ε : g ≫ f ≅ 𝟙 b) :=
whiskerLeftIso g η ≪⊗≫ whiskerRightIso ε g
attribute [local simp] leftZigzagIso rightZigzagIso leftZigzag rightZigzag
@[simp]
theorem leftZigzagIso_hom : (leftZigzagIso η ε).hom = leftZigzag η.hom ε.hom :=
rfl
@[simp]
theorem rightZigzagIso_hom : (rightZigzagIso η ε).hom = rightZigzag η.hom ε.hom :=
rfl
@[simp]
theorem leftZigzagIso_inv : (leftZigzagIso η ε).inv = rightZigzag ε.inv η.inv := by
simp [bicategoricalComp, bicategoricalIsoComp]
@[simp]
theorem rightZigzagIso_inv : (rightZigzagIso η ε).inv = leftZigzag ε.inv η.inv := by
simp [bicategoricalComp, bicategoricalIsoComp]
@[simp]
theorem leftZigzagIso_symm : (leftZigzagIso η ε).symm = rightZigzagIso ε.symm η.symm :=
Iso.ext (leftZigzagIso_inv η ε)
@[simp]
theorem rightZigzagIso_symm : (rightZigzagIso η ε).symm = leftZigzagIso ε.symm η.symm :=
Iso.ext (rightZigzagIso_inv η ε)
instance : IsIso (leftZigzag η.hom ε.hom) := inferInstanceAs <| IsIso (leftZigzagIso η ε).hom
instance : IsIso (rightZigzag η.hom ε.hom) := inferInstanceAs <| IsIso (rightZigzagIso η ε).hom
theorem right_triangle_of_left_triangle (h : leftZigzag η.hom ε.hom = (λ_ f).hom ≫ (ρ_ f).inv) :
rightZigzag η.hom ε.hom = (ρ_ g).hom ≫ (λ_ g).inv := by
rw [← cancel_epi (rightZigzag η.hom ε.hom ≫ (λ_ g).hom ≫ (ρ_ g).inv)]
calc
_ = rightZigzag η.hom ε.hom ⊗≫ rightZigzag η.hom ε.hom := by coherence
_ = rightZigzag η.hom ε.hom := rightZigzag_idempotent_of_left_triangle _ _ h
_ = _ := by simp
/-- An auxiliary definition for `mkOfAdjointifyCounit`. -/
def adjointifyCounit (η : 𝟙 a ≅ f ≫ g) (ε : g ≫ f ≅ 𝟙 b) : g ≫ f ≅ 𝟙 b :=
whiskerLeftIso g ((ρ_ f).symm ≪≫ rightZigzagIso ε.symm η.symm ≪≫ λ_ f) ≪≫ ε
theorem adjointifyCounit_left_triangle (η : 𝟙 a ≅ f ≫ g) (ε : g ≫ f ≅ 𝟙 b) :
leftZigzagIso η (adjointifyCounit η ε) = λ_ f ≪≫ (ρ_ f).symm := by
apply Iso.ext
dsimp [adjointifyCounit, bicategoricalIsoComp]
calc
_ = 𝟙 _ ⊗≫ (η.hom ▷ (f ≫ 𝟙 b) ≫ (f ≫ g) ◁ f ◁ ε.inv) ⊗≫
f ◁ g ◁ η.inv ▷ f ⊗≫ f ◁ ε.hom := by
simp [bicategoricalComp]; coherence
_ = 𝟙 _ ⊗≫ f ◁ ε.inv ⊗≫ (η.hom ▷ (f ≫ g) ≫ (f ≫ g) ◁ η.inv) ▷ f ⊗≫ f ◁ ε.hom := by
rw [← whisker_exchange η.hom (f ◁ ε.inv)]; simp [bicategoricalComp]; coherence
_ = 𝟙 _ ⊗≫ f ◁ ε.inv ⊗≫ (η.inv ≫ η.hom) ▷ f ⊗≫ f ◁ ε.hom := by
rw [← whisker_exchange η.hom η.inv]; coherence
_ = 𝟙 _ ⊗≫ f ◁ (ε.inv ≫ ε.hom) := by
rw [Iso.inv_hom_id]; simp [bicategoricalComp]
_ = _ := by
rw [Iso.inv_hom_id]; simp [bicategoricalComp]
/-- Adjoint equivalences between two objects. -/
structure Equivalence (a b : B) where
/-- A 1-morphism in one direction. -/
hom : a ⟶ b
/-- A 1-morphism in the other direction. -/
inv : b ⟶ a
/-- The composition `hom ≫ inv` is isomorphic to the identity. -/
unit : 𝟙 a ≅ hom ≫ inv
/-- The composition `inv ≫ hom` is isomorphic to the identity. -/
counit : inv ≫ hom ≅ 𝟙 b
/-- The composition of the unit and the counit is equal to the identity up to unitors. -/
left_triangle : leftZigzagIso unit counit = λ_ hom ≪≫ (ρ_ hom).symm := by aesop_cat
@[inherit_doc] scoped infixr:10 " ≌ " => Bicategory.Equivalence
namespace Equivalence
/-- The identity 1-morphism is an equivalence. -/
def id (a : B) : a ≌ a := ⟨_, _, (ρ_ _).symm, ρ_ _, by ext; simp [bicategoricalIsoComp]⟩
instance : Inhabited (Equivalence a a) := ⟨id a⟩
theorem left_triangle_hom (e : a ≌ b) :
leftZigzag e.unit.hom e.counit.hom = (λ_ e.hom).hom ≫ (ρ_ e.hom).inv :=
congrArg Iso.hom e.left_triangle
theorem right_triangle (e : a ≌ b) :
rightZigzagIso e.unit e.counit = ρ_ e.inv ≪≫ (λ_ e.inv).symm :=
Iso.ext (right_triangle_of_left_triangle e.unit e.counit e.left_triangle_hom)
theorem right_triangle_hom (e : a ≌ b) :
rightZigzag e.unit.hom e.counit.hom = (ρ_ e.inv).hom ≫ (λ_ e.inv).inv :=
congrArg Iso.hom e.right_triangle
/-- Construct an adjoint equivalence from 2-isomorphisms by upgrading `ε` to a counit. -/
def mkOfAdjointifyCounit (η : 𝟙 a ≅ f ≫ g) (ε : g ≫ f ≅ 𝟙 b) : a ≌ b where
hom := f
inv := g
unit := η
counit := adjointifyCounit η ε
left_triangle := adjointifyCounit_left_triangle η ε
end Equivalence
end
noncomputable
section
/-- A structure giving a chosen right adjoint of a 1-morphism `left`. -/
structure RightAdjoint (left : a ⟶ b) where
/-- The right adjoint to `left`. -/
right : b ⟶ a
/-- The adjunction between `left` and `right`. -/
adj : left ⊣ right
/-- The existence of a right adjoint of `f`. -/
class IsLeftAdjoint (left : a ⟶ b) : Prop where mk' ::
nonempty : Nonempty (RightAdjoint left)
theorem IsLeftAdjoint.mk (adj : f ⊣ g) : IsLeftAdjoint f :=
⟨⟨g, adj⟩⟩
/-- Use the axiom of choice to extract a right adjoint from an `IsLeftAdjoint` instance. -/
def getRightAdjoint (f : a ⟶ b) [IsLeftAdjoint f] : RightAdjoint f :=
Classical.choice IsLeftAdjoint.nonempty
/-- The right adjoint of a 1-morphism. -/
def rightAdjoint (f : a ⟶ b) [IsLeftAdjoint f] : b ⟶ a :=
(getRightAdjoint f).right
/-- Evidence that `f⁺⁺` is a right adjoint of `f`. -/
def Adjunction.ofIsLeftAdjoint (f : a ⟶ b) [IsLeftAdjoint f] : f ⊣ rightAdjoint f :=
(getRightAdjoint f).adj
/-- A structure giving a chosen left adjoint of a 1-morphism `right`. -/
structure LeftAdjoint (right : b ⟶ a) where
/-- The left adjoint to `right`. -/
left : a ⟶ b
/-- The adjunction between `left` and `right`. -/
adj : left ⊣ right
/-- The existence of a left adjoint of `f`. -/
class IsRightAdjoint (right : b ⟶ a) : Prop where mk' ::
nonempty : Nonempty (LeftAdjoint right)
theorem IsRightAdjoint.mk (adj : f ⊣ g) : IsRightAdjoint g :=
⟨⟨f, adj⟩⟩
/-- Use the axiom of choice to extract a left adjoint from an `IsRightAdjoint` instance. -/
def getLeftAdjoint (f : b ⟶ a) [IsRightAdjoint f] : LeftAdjoint f :=
Classical.choice IsRightAdjoint.nonempty
/-- The left adjoint of a 1-morphism. -/
def leftAdjoint (f : b ⟶ a) [IsRightAdjoint f] : a ⟶ b :=
(getLeftAdjoint f).left
/-- Evidence that `f⁺` is a left adjoint of `f`. -/
def Adjunction.ofIsRightAdjoint (f : b ⟶ a) [IsRightAdjoint f] : leftAdjoint f ⊣ f :=
(getLeftAdjoint f).adj
end
end Bicategory
end CategoryTheory
|
CategoryTheory\Bicategory\Basic.lean | /-
Copyright (c) 2021 Yuma Mizuno. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yuma Mizuno
-/
import Mathlib.CategoryTheory.NatIso
/-!
# Bicategories
In this file we define typeclass for bicategories.
A bicategory `B` consists of
* objects `a : B`,
* 1-morphisms `f : a ⟶ b` between objects `a b : B`, and
* 2-morphisms `η : f ⟶ g` between 1-morphisms `f g : a ⟶ b` between objects `a b : B`.
We use `u`, `v`, and `w` as the universe variables for objects, 1-morphisms, and 2-morphisms,
respectively.
A typeclass for bicategories extends `CategoryTheory.CategoryStruct` typeclass. This means that
we have
* a composition `f ≫ g : a ⟶ c` for each 1-morphisms `f : a ⟶ b` and `g : b ⟶ c`, and
* an identity `𝟙 a : a ⟶ a` for each object `a : B`.
For each object `a b : B`, the collection of 1-morphisms `a ⟶ b` has a category structure. The
2-morphisms in the bicategory are implemented as the morphisms in this family of categories.
The composition of 1-morphisms is in fact an object part of a functor
`(a ⟶ b) ⥤ (b ⟶ c) ⥤ (a ⟶ c)`. The definition of bicategories in this file does not
require this functor directly. Instead, it requires the whiskering functions. For a 1-morphism
`f : a ⟶ b` and a 2-morphism `η : g ⟶ h` between 1-morphisms `g h : b ⟶ c`, there is a
2-morphism `whiskerLeft f η : f ≫ g ⟶ f ≫ h`. Similarly, for a 2-morphism `η : f ⟶ g`
between 1-morphisms `f g : a ⟶ b` and a 1-morphism `f : b ⟶ c`, there is a 2-morphism
`whiskerRight η h : f ≫ h ⟶ g ≫ h`. These satisfy the exchange law
`whiskerLeft f θ ≫ whiskerRight η i = whiskerRight η h ≫ whiskerLeft g θ`,
which is required as an axiom in the definition here.
-/
namespace CategoryTheory
universe w v u
open Category Iso
-- intended to be used with explicit universe parameters
/-- In a bicategory, we can compose the 1-morphisms `f : a ⟶ b` and `g : b ⟶ c` to obtain
a 1-morphism `f ≫ g : a ⟶ c`. This composition does not need to be strictly associative,
but there is a specified associator, `α_ f g h : (f ≫ g) ≫ h ≅ f ≫ (g ≫ h)`.
There is an identity 1-morphism `𝟙 a : a ⟶ a`, with specified left and right unitor
isomorphisms `λ_ f : 𝟙 a ≫ f ≅ f` and `ρ_ f : f ≫ 𝟙 a ≅ f`.
These associators and unitors satisfy the pentagon and triangle equations.
See https://ncatlab.org/nlab/show/bicategory.
-/
@[nolint checkUnivs]
class Bicategory (B : Type u) extends CategoryStruct.{v} B where
-- category structure on the collection of 1-morphisms:
homCategory : ∀ a b : B, Category.{w} (a ⟶ b) := by infer_instance
-- left whiskering:
whiskerLeft {a b c : B} (f : a ⟶ b) {g h : b ⟶ c} (η : g ⟶ h) : f ≫ g ⟶ f ≫ h
-- right whiskering:
whiskerRight {a b c : B} {f g : a ⟶ b} (η : f ⟶ g) (h : b ⟶ c) : f ≫ h ⟶ g ≫ h
-- associator:
associator {a b c d : B} (f : a ⟶ b) (g : b ⟶ c) (h : c ⟶ d) : (f ≫ g) ≫ h ≅ f ≫ g ≫ h
-- left unitor:
leftUnitor {a b : B} (f : a ⟶ b) : 𝟙 a ≫ f ≅ f
-- right unitor:
rightUnitor {a b : B} (f : a ⟶ b) : f ≫ 𝟙 b ≅ f
-- axioms for left whiskering:
whiskerLeft_id : ∀ {a b c} (f : a ⟶ b) (g : b ⟶ c), whiskerLeft f (𝟙 g) = 𝟙 (f ≫ g) := by
aesop_cat
whiskerLeft_comp :
∀ {a b c} (f : a ⟶ b) {g h i : b ⟶ c} (η : g ⟶ h) (θ : h ⟶ i),
whiskerLeft f (η ≫ θ) = whiskerLeft f η ≫ whiskerLeft f θ := by
aesop_cat
id_whiskerLeft :
∀ {a b} {f g : a ⟶ b} (η : f ⟶ g),
whiskerLeft (𝟙 a) η = (leftUnitor f).hom ≫ η ≫ (leftUnitor g).inv := by
aesop_cat
comp_whiskerLeft :
∀ {a b c d} (f : a ⟶ b) (g : b ⟶ c) {h h' : c ⟶ d} (η : h ⟶ h'),
whiskerLeft (f ≫ g) η =
(associator f g h).hom ≫ whiskerLeft f (whiskerLeft g η) ≫ (associator f g h').inv := by
aesop_cat
-- axioms for right whiskering:
id_whiskerRight : ∀ {a b c} (f : a ⟶ b) (g : b ⟶ c), whiskerRight (𝟙 f) g = 𝟙 (f ≫ g) := by
aesop_cat
comp_whiskerRight :
∀ {a b c} {f g h : a ⟶ b} (η : f ⟶ g) (θ : g ⟶ h) (i : b ⟶ c),
whiskerRight (η ≫ θ) i = whiskerRight η i ≫ whiskerRight θ i := by
aesop_cat
whiskerRight_id :
∀ {a b} {f g : a ⟶ b} (η : f ⟶ g),
whiskerRight η (𝟙 b) = (rightUnitor f).hom ≫ η ≫ (rightUnitor g).inv := by
aesop_cat
whiskerRight_comp :
∀ {a b c d} {f f' : a ⟶ b} (η : f ⟶ f') (g : b ⟶ c) (h : c ⟶ d),
whiskerRight η (g ≫ h) =
(associator f g h).inv ≫ whiskerRight (whiskerRight η g) h ≫ (associator f' g h).hom := by
aesop_cat
-- associativity of whiskerings:
whisker_assoc :
∀ {a b c d} (f : a ⟶ b) {g g' : b ⟶ c} (η : g ⟶ g') (h : c ⟶ d),
whiskerRight (whiskerLeft f η) h =
(associator f g h).hom ≫ whiskerLeft f (whiskerRight η h) ≫ (associator f g' h).inv := by
aesop_cat
-- exchange law of left and right whiskerings:
whisker_exchange :
∀ {a b c} {f g : a ⟶ b} {h i : b ⟶ c} (η : f ⟶ g) (θ : h ⟶ i),
whiskerLeft f θ ≫ whiskerRight η i = whiskerRight η h ≫ whiskerLeft g θ := by
aesop_cat
-- pentagon identity:
pentagon :
∀ {a b c d e} (f : a ⟶ b) (g : b ⟶ c) (h : c ⟶ d) (i : d ⟶ e),
whiskerRight (associator f g h).hom i ≫
(associator f (g ≫ h) i).hom ≫ whiskerLeft f (associator g h i).hom =
(associator (f ≫ g) h i).hom ≫ (associator f g (h ≫ i)).hom := by
aesop_cat
-- triangle identity:
triangle :
∀ {a b c} (f : a ⟶ b) (g : b ⟶ c),
(associator f (𝟙 b) g).hom ≫ whiskerLeft f (leftUnitor g).hom
= whiskerRight (rightUnitor f).hom g := by
aesop_cat
namespace Bicategory
scoped infixr:81 " ◁ " => Bicategory.whiskerLeft
scoped infixl:81 " ▷ " => Bicategory.whiskerRight
scoped notation "α_" => Bicategory.associator
scoped notation "λ_" => Bicategory.leftUnitor
scoped notation "ρ_" => Bicategory.rightUnitor
/-!
### Simp-normal form for 2-morphisms
Rewriting involving associators and unitors could be very complicated. We try to ease this
complexity by putting carefully chosen simp lemmas that rewrite any 2-morphisms into simp-normal
form defined below. Rewriting into simp-normal form is also useful when applying (forthcoming)
`coherence` tactic.
The simp-normal form of 2-morphisms is defined to be an expression that has the minimal number of
parentheses. More precisely,
1. it is a composition of 2-morphisms like `η₁ ≫ η₂ ≫ η₃ ≫ η₄ ≫ η₅` such that each `ηᵢ` is
either a structural 2-morphisms (2-morphisms made up only of identities, associators, unitors)
or non-structural 2-morphisms, and
2. each non-structural 2-morphism in the composition is of the form `f₁ ◁ f₂ ◁ f₃ ◁ η ▷ f₄ ▷ f₅`,
where each `fᵢ` is a 1-morphism that is not the identity or a composite and `η` is a
non-structural 2-morphisms that is also not the identity or a composite.
Note that `f₁ ◁ f₂ ◁ f₃ ◁ η ▷ f₄ ▷ f₅` is actually `f₁ ◁ (f₂ ◁ (f₃ ◁ ((η ▷ f₄) ▷ f₅)))`.
-/
attribute [instance] homCategory
attribute [reassoc]
whiskerLeft_comp id_whiskerLeft comp_whiskerLeft comp_whiskerRight whiskerRight_id
whiskerRight_comp whisker_assoc whisker_exchange
attribute [reassoc (attr := simp)] pentagon triangle
/-
The following simp attributes are put in order to rewrite any 2-morphisms into normal forms. There
are associators and unitors in the RHS in the several simp lemmas here (e.g. `id_whiskerLeft`),
which at first glance look more complicated than the LHS, but they will be eventually reduced by
the pentagon or the triangle identities, and more generally, (forthcoming) `coherence` tactic.
-/
attribute [simp]
whiskerLeft_id whiskerLeft_comp id_whiskerLeft comp_whiskerLeft id_whiskerRight comp_whiskerRight
whiskerRight_id whiskerRight_comp whisker_assoc
variable {B : Type u} [Bicategory.{w, v} B] {a b c d e : B}
@[reassoc (attr := simp)]
theorem whiskerLeft_hom_inv (f : a ⟶ b) {g h : b ⟶ c} (η : g ≅ h) :
f ◁ η.hom ≫ f ◁ η.inv = 𝟙 (f ≫ g) := by rw [← whiskerLeft_comp, hom_inv_id, whiskerLeft_id]
@[reassoc (attr := simp)]
theorem hom_inv_whiskerRight {f g : a ⟶ b} (η : f ≅ g) (h : b ⟶ c) :
η.hom ▷ h ≫ η.inv ▷ h = 𝟙 (f ≫ h) := by rw [← comp_whiskerRight, hom_inv_id, id_whiskerRight]
@[reassoc (attr := simp)]
theorem whiskerLeft_inv_hom (f : a ⟶ b) {g h : b ⟶ c} (η : g ≅ h) :
f ◁ η.inv ≫ f ◁ η.hom = 𝟙 (f ≫ h) := by rw [← whiskerLeft_comp, inv_hom_id, whiskerLeft_id]
@[reassoc (attr := simp)]
theorem inv_hom_whiskerRight {f g : a ⟶ b} (η : f ≅ g) (h : b ⟶ c) :
η.inv ▷ h ≫ η.hom ▷ h = 𝟙 (g ≫ h) := by rw [← comp_whiskerRight, inv_hom_id, id_whiskerRight]
/-- The left whiskering of a 2-isomorphism is a 2-isomorphism. -/
@[simps]
def whiskerLeftIso (f : a ⟶ b) {g h : b ⟶ c} (η : g ≅ h) : f ≫ g ≅ f ≫ h where
hom := f ◁ η.hom
inv := f ◁ η.inv
instance whiskerLeft_isIso (f : a ⟶ b) {g h : b ⟶ c} (η : g ⟶ h) [IsIso η] : IsIso (f ◁ η) :=
(whiskerLeftIso f (asIso η)).isIso_hom
@[simp]
theorem inv_whiskerLeft (f : a ⟶ b) {g h : b ⟶ c} (η : g ⟶ h) [IsIso η] :
inv (f ◁ η) = f ◁ inv η := by
apply IsIso.inv_eq_of_hom_inv_id
simp only [← whiskerLeft_comp, whiskerLeft_id, IsIso.hom_inv_id]
/-- The right whiskering of a 2-isomorphism is a 2-isomorphism. -/
@[simps!]
def whiskerRightIso {f g : a ⟶ b} (η : f ≅ g) (h : b ⟶ c) : f ≫ h ≅ g ≫ h where
hom := η.hom ▷ h
inv := η.inv ▷ h
instance whiskerRight_isIso {f g : a ⟶ b} (η : f ⟶ g) (h : b ⟶ c) [IsIso η] : IsIso (η ▷ h) :=
(whiskerRightIso (asIso η) h).isIso_hom
@[simp]
theorem inv_whiskerRight {f g : a ⟶ b} (η : f ⟶ g) (h : b ⟶ c) [IsIso η] :
inv (η ▷ h) = inv η ▷ h := by
apply IsIso.inv_eq_of_hom_inv_id
simp only [← comp_whiskerRight, id_whiskerRight, IsIso.hom_inv_id]
@[reassoc (attr := simp)]
theorem pentagon_inv (f : a ⟶ b) (g : b ⟶ c) (h : c ⟶ d) (i : d ⟶ e) :
f ◁ (α_ g h i).inv ≫ (α_ f (g ≫ h) i).inv ≫ (α_ f g h).inv ▷ i =
(α_ f g (h ≫ i)).inv ≫ (α_ (f ≫ g) h i).inv :=
eq_of_inv_eq_inv (by simp)
@[reassoc (attr := simp)]
theorem pentagon_inv_inv_hom_hom_inv (f : a ⟶ b) (g : b ⟶ c) (h : c ⟶ d) (i : d ⟶ e) :
(α_ f (g ≫ h) i).inv ≫ (α_ f g h).inv ▷ i ≫ (α_ (f ≫ g) h i).hom =
f ◁ (α_ g h i).hom ≫ (α_ f g (h ≫ i)).inv := by
rw [← cancel_epi (f ◁ (α_ g h i).inv), ← cancel_mono (α_ (f ≫ g) h i).inv]
simp
@[reassoc (attr := simp)]
theorem pentagon_inv_hom_hom_hom_inv (f : a ⟶ b) (g : b ⟶ c) (h : c ⟶ d) (i : d ⟶ e) :
(α_ (f ≫ g) h i).inv ≫ (α_ f g h).hom ▷ i ≫ (α_ f (g ≫ h) i).hom =
(α_ f g (h ≫ i)).hom ≫ f ◁ (α_ g h i).inv :=
eq_of_inv_eq_inv (by simp)
@[reassoc (attr := simp)]
theorem pentagon_hom_inv_inv_inv_inv (f : a ⟶ b) (g : b ⟶ c) (h : c ⟶ d) (i : d ⟶ e) :
f ◁ (α_ g h i).hom ≫ (α_ f g (h ≫ i)).inv ≫ (α_ (f ≫ g) h i).inv =
(α_ f (g ≫ h) i).inv ≫ (α_ f g h).inv ▷ i := by
simp [← cancel_epi (f ◁ (α_ g h i).inv)]
@[reassoc (attr := simp)]
theorem pentagon_hom_hom_inv_hom_hom (f : a ⟶ b) (g : b ⟶ c) (h : c ⟶ d) (i : d ⟶ e) :
(α_ (f ≫ g) h i).hom ≫ (α_ f g (h ≫ i)).hom ≫ f ◁ (α_ g h i).inv =
(α_ f g h).hom ▷ i ≫ (α_ f (g ≫ h) i).hom :=
eq_of_inv_eq_inv (by simp)
@[reassoc (attr := simp)]
theorem pentagon_hom_inv_inv_inv_hom (f : a ⟶ b) (g : b ⟶ c) (h : c ⟶ d) (i : d ⟶ e) :
(α_ f g (h ≫ i)).hom ≫ f ◁ (α_ g h i).inv ≫ (α_ f (g ≫ h) i).inv =
(α_ (f ≫ g) h i).inv ≫ (α_ f g h).hom ▷ i := by
rw [← cancel_epi (α_ f g (h ≫ i)).inv, ← cancel_mono ((α_ f g h).inv ▷ i)]
simp
@[reassoc (attr := simp)]
theorem pentagon_hom_hom_inv_inv_hom (f : a ⟶ b) (g : b ⟶ c) (h : c ⟶ d) (i : d ⟶ e) :
(α_ f (g ≫ h) i).hom ≫ f ◁ (α_ g h i).hom ≫ (α_ f g (h ≫ i)).inv =
(α_ f g h).inv ▷ i ≫ (α_ (f ≫ g) h i).hom :=
eq_of_inv_eq_inv (by simp)
@[reassoc (attr := simp)]
theorem pentagon_inv_hom_hom_hom_hom (f : a ⟶ b) (g : b ⟶ c) (h : c ⟶ d) (i : d ⟶ e) :
(α_ f g h).inv ▷ i ≫ (α_ (f ≫ g) h i).hom ≫ (α_ f g (h ≫ i)).hom =
(α_ f (g ≫ h) i).hom ≫ f ◁ (α_ g h i).hom := by
simp [← cancel_epi ((α_ f g h).hom ▷ i)]
@[reassoc (attr := simp)]
theorem pentagon_inv_inv_hom_inv_inv (f : a ⟶ b) (g : b ⟶ c) (h : c ⟶ d) (i : d ⟶ e) :
(α_ f g (h ≫ i)).inv ≫ (α_ (f ≫ g) h i).inv ≫ (α_ f g h).hom ▷ i =
f ◁ (α_ g h i).inv ≫ (α_ f (g ≫ h) i).inv :=
eq_of_inv_eq_inv (by simp)
theorem triangle_assoc_comp_left (f : a ⟶ b) (g : b ⟶ c) :
(α_ f (𝟙 b) g).hom ≫ f ◁ (λ_ g).hom = (ρ_ f).hom ▷ g :=
triangle f g
@[reassoc (attr := simp)]
theorem triangle_assoc_comp_right (f : a ⟶ b) (g : b ⟶ c) :
(α_ f (𝟙 b) g).inv ≫ (ρ_ f).hom ▷ g = f ◁ (λ_ g).hom := by rw [← triangle, inv_hom_id_assoc]
@[reassoc (attr := simp)]
theorem triangle_assoc_comp_right_inv (f : a ⟶ b) (g : b ⟶ c) :
(ρ_ f).inv ▷ g ≫ (α_ f (𝟙 b) g).hom = f ◁ (λ_ g).inv := by
simp [← cancel_mono (f ◁ (λ_ g).hom)]
@[reassoc (attr := simp)]
theorem triangle_assoc_comp_left_inv (f : a ⟶ b) (g : b ⟶ c) :
f ◁ (λ_ g).inv ≫ (α_ f (𝟙 b) g).inv = (ρ_ f).inv ▷ g := by
simp [← cancel_mono ((ρ_ f).hom ▷ g)]
@[reassoc]
theorem associator_naturality_left {f f' : a ⟶ b} (η : f ⟶ f') (g : b ⟶ c) (h : c ⟶ d) :
η ▷ g ▷ h ≫ (α_ f' g h).hom = (α_ f g h).hom ≫ η ▷ (g ≫ h) := by simp
@[reassoc]
theorem associator_inv_naturality_left {f f' : a ⟶ b} (η : f ⟶ f') (g : b ⟶ c) (h : c ⟶ d) :
η ▷ (g ≫ h) ≫ (α_ f' g h).inv = (α_ f g h).inv ≫ η ▷ g ▷ h := by simp
@[reassoc]
theorem whiskerRight_comp_symm {f f' : a ⟶ b} (η : f ⟶ f') (g : b ⟶ c) (h : c ⟶ d) :
η ▷ g ▷ h = (α_ f g h).hom ≫ η ▷ (g ≫ h) ≫ (α_ f' g h).inv := by simp
@[reassoc]
theorem associator_naturality_middle (f : a ⟶ b) {g g' : b ⟶ c} (η : g ⟶ g') (h : c ⟶ d) :
(f ◁ η) ▷ h ≫ (α_ f g' h).hom = (α_ f g h).hom ≫ f ◁ η ▷ h := by simp
@[reassoc]
theorem associator_inv_naturality_middle (f : a ⟶ b) {g g' : b ⟶ c} (η : g ⟶ g') (h : c ⟶ d) :
f ◁ η ▷ h ≫ (α_ f g' h).inv = (α_ f g h).inv ≫ (f ◁ η) ▷ h := by simp
@[reassoc]
theorem whisker_assoc_symm (f : a ⟶ b) {g g' : b ⟶ c} (η : g ⟶ g') (h : c ⟶ d) :
f ◁ η ▷ h = (α_ f g h).inv ≫ (f ◁ η) ▷ h ≫ (α_ f g' h).hom := by simp
@[reassoc]
theorem associator_naturality_right (f : a ⟶ b) (g : b ⟶ c) {h h' : c ⟶ d} (η : h ⟶ h') :
(f ≫ g) ◁ η ≫ (α_ f g h').hom = (α_ f g h).hom ≫ f ◁ g ◁ η := by simp
@[reassoc]
theorem associator_inv_naturality_right (f : a ⟶ b) (g : b ⟶ c) {h h' : c ⟶ d} (η : h ⟶ h') :
f ◁ g ◁ η ≫ (α_ f g h').inv = (α_ f g h).inv ≫ (f ≫ g) ◁ η := by simp
@[reassoc]
theorem comp_whiskerLeft_symm (f : a ⟶ b) (g : b ⟶ c) {h h' : c ⟶ d} (η : h ⟶ h') :
f ◁ g ◁ η = (α_ f g h).inv ≫ (f ≫ g) ◁ η ≫ (α_ f g h').hom := by simp
@[reassoc]
theorem leftUnitor_naturality {f g : a ⟶ b} (η : f ⟶ g) :
𝟙 a ◁ η ≫ (λ_ g).hom = (λ_ f).hom ≫ η := by
simp
@[reassoc]
theorem leftUnitor_inv_naturality {f g : a ⟶ b} (η : f ⟶ g) :
η ≫ (λ_ g).inv = (λ_ f).inv ≫ 𝟙 a ◁ η := by simp
theorem id_whiskerLeft_symm {f g : a ⟶ b} (η : f ⟶ g) : η = (λ_ f).inv ≫ 𝟙 a ◁ η ≫ (λ_ g).hom := by
simp
@[reassoc]
theorem rightUnitor_naturality {f g : a ⟶ b} (η : f ⟶ g) :
η ▷ 𝟙 b ≫ (ρ_ g).hom = (ρ_ f).hom ≫ η := by simp
@[reassoc]
theorem rightUnitor_inv_naturality {f g : a ⟶ b} (η : f ⟶ g) :
η ≫ (ρ_ g).inv = (ρ_ f).inv ≫ η ▷ 𝟙 b := by simp
theorem whiskerRight_id_symm {f g : a ⟶ b} (η : f ⟶ g) : η = (ρ_ f).inv ≫ η ▷ 𝟙 b ≫ (ρ_ g).hom := by
simp
theorem whiskerLeft_iff {f g : a ⟶ b} (η θ : f ⟶ g) : 𝟙 a ◁ η = 𝟙 a ◁ θ ↔ η = θ := by simp
theorem whiskerRight_iff {f g : a ⟶ b} (η θ : f ⟶ g) : η ▷ 𝟙 b = θ ▷ 𝟙 b ↔ η = θ := by simp
/-- We state it as a simp lemma, which is regarded as an involved version of
`id_whiskerRight f g : 𝟙 f ▷ g = 𝟙 (f ≫ g)`.
-/
@[reassoc, simp]
theorem leftUnitor_whiskerRight (f : a ⟶ b) (g : b ⟶ c) :
(λ_ f).hom ▷ g = (α_ (𝟙 a) f g).hom ≫ (λ_ (f ≫ g)).hom := by
rw [← whiskerLeft_iff, whiskerLeft_comp, ← cancel_epi (α_ _ _ _).hom, ←
cancel_epi ((α_ _ _ _).hom ▷ _), pentagon_assoc, triangle, ← associator_naturality_middle, ←
comp_whiskerRight_assoc, triangle, associator_naturality_left]
@[reassoc, simp]
theorem leftUnitor_inv_whiskerRight (f : a ⟶ b) (g : b ⟶ c) :
(λ_ f).inv ▷ g = (λ_ (f ≫ g)).inv ≫ (α_ (𝟙 a) f g).inv :=
eq_of_inv_eq_inv (by simp)
@[reassoc, simp]
theorem whiskerLeft_rightUnitor (f : a ⟶ b) (g : b ⟶ c) :
f ◁ (ρ_ g).hom = (α_ f g (𝟙 c)).inv ≫ (ρ_ (f ≫ g)).hom := by
rw [← whiskerRight_iff, comp_whiskerRight, ← cancel_epi (α_ _ _ _).inv, ←
cancel_epi (f ◁ (α_ _ _ _).inv), pentagon_inv_assoc, triangle_assoc_comp_right, ←
associator_inv_naturality_middle, ← whiskerLeft_comp_assoc, triangle_assoc_comp_right,
associator_inv_naturality_right]
@[reassoc, simp]
theorem whiskerLeft_rightUnitor_inv (f : a ⟶ b) (g : b ⟶ c) :
f ◁ (ρ_ g).inv = (ρ_ (f ≫ g)).inv ≫ (α_ f g (𝟙 c)).hom :=
eq_of_inv_eq_inv (by simp)
/-
It is not so obvious whether `leftUnitor_whiskerRight` or `leftUnitor_comp` should be a simp
lemma. Our choice is the former. One reason is that the latter yields the following loop:
[id_whiskerLeft] : 𝟙 a ◁ (ρ_ f).hom ==> (λ_ (f ≫ 𝟙 b)).hom ≫ (ρ_ f).hom ≫ (λ_ f).inv
[leftUnitor_comp] : (λ_ (f ≫ 𝟙 b)).hom ==> (α_ (𝟙 a) f (𝟙 b)).inv ≫ (λ_ f).hom ▷ 𝟙 b
[whiskerRight_id] : (λ_ f).hom ▷ 𝟙 b ==> (ρ_ (𝟙 a ≫ f)).hom ≫ (λ_ f).hom ≫ (ρ_ f).inv
[rightUnitor_comp] : (ρ_ (𝟙 a ≫ f)).hom ==> (α_ (𝟙 a) f (𝟙 b)).hom ≫ 𝟙 a ◁ (ρ_ f).hom
-/
@[reassoc]
theorem leftUnitor_comp (f : a ⟶ b) (g : b ⟶ c) :
(λ_ (f ≫ g)).hom = (α_ (𝟙 a) f g).inv ≫ (λ_ f).hom ▷ g := by simp
@[reassoc]
theorem leftUnitor_comp_inv (f : a ⟶ b) (g : b ⟶ c) :
(λ_ (f ≫ g)).inv = (λ_ f).inv ▷ g ≫ (α_ (𝟙 a) f g).hom := by simp
@[reassoc]
theorem rightUnitor_comp (f : a ⟶ b) (g : b ⟶ c) :
(ρ_ (f ≫ g)).hom = (α_ f g (𝟙 c)).hom ≫ f ◁ (ρ_ g).hom := by simp
@[reassoc]
theorem rightUnitor_comp_inv (f : a ⟶ b) (g : b ⟶ c) :
(ρ_ (f ≫ g)).inv = f ◁ (ρ_ g).inv ≫ (α_ f g (𝟙 c)).inv := by simp
@[simp]
theorem unitors_equal : (λ_ (𝟙 a)).hom = (ρ_ (𝟙 a)).hom := by
rw [← whiskerLeft_iff, ← cancel_epi (α_ _ _ _).hom, ← cancel_mono (ρ_ _).hom, triangle, ←
rightUnitor_comp, rightUnitor_naturality]
@[simp]
theorem unitors_inv_equal : (λ_ (𝟙 a)).inv = (ρ_ (𝟙 a)).inv := by simp [Iso.inv_eq_inv]
section
attribute [local simp] whisker_exchange
/-- Precomposition of a 1-morphism as a functor. -/
@[simps]
def precomp (c : B) (f : a ⟶ b) : (b ⟶ c) ⥤ (a ⟶ c) where
obj := (f ≫ ·)
map := (f ◁ ·)
/-- Precomposition of a 1-morphism as a functor from the category of 1-morphisms `a ⟶ b` into the
category of functors `(b ⟶ c) ⥤ (a ⟶ c)`. -/
@[simps]
def precomposing (a b c : B) : (a ⟶ b) ⥤ (b ⟶ c) ⥤ (a ⟶ c) where
obj f := precomp c f
map η := { app := (η ▷ ·) }
/-- Postcomposition of a 1-morphism as a functor. -/
@[simps]
def postcomp (a : B) (f : b ⟶ c) : (a ⟶ b) ⥤ (a ⟶ c) where
obj := (· ≫ f)
map := (· ▷ f)
/-- Postcomposition of a 1-morphism as a functor from the category of 1-morphisms `b ⟶ c` into the
category of functors `(a ⟶ b) ⥤ (a ⟶ c)`. -/
@[simps]
def postcomposing (a b c : B) : (b ⟶ c) ⥤ (a ⟶ b) ⥤ (a ⟶ c) where
obj f := postcomp a f
map η := { app := (· ◁ η) }
/-- Left component of the associator as a natural isomorphism. -/
@[simps!]
def associatorNatIsoLeft (a : B) (g : b ⟶ c) (h : c ⟶ d) :
(postcomposing a ..).obj g ⋙ (postcomposing ..).obj h ≅ (postcomposing ..).obj (g ≫ h) :=
NatIso.ofComponents (α_ · g h)
/-- Middle component of the associator as a natural isomorphism. -/
@[simps!]
def associatorNatIsoMiddle (f : a ⟶ b) (h : c ⟶ d) :
(precomposing ..).obj f ⋙ (postcomposing ..).obj h ≅
(postcomposing ..).obj h ⋙ (precomposing ..).obj f :=
NatIso.ofComponents (α_ f · h)
/-- Right component of the associator as a natural isomorphism. -/
@[simps!]
def associatorNatIsoRight (f : a ⟶ b) (g : b ⟶ c) (d : B) :
(precomposing _ _ d).obj (f ≫ g) ≅ (precomposing ..).obj g ⋙ (precomposing ..).obj f :=
NatIso.ofComponents (α_ f g ·)
/-- Left unitor as a natural isomorphism. -/
@[simps!]
def leftUnitorNatIso (a b : B) : (precomposing _ _ b).obj (𝟙 a) ≅ 𝟭 (a ⟶ b) :=
NatIso.ofComponents (λ_ ·)
/-- Right unitor as a natural isomorphism. -/
@[simps!]
def rightUnitorNatIso (a b : B) : (postcomposing a _ _).obj (𝟙 b) ≅ 𝟭 (a ⟶ b) :=
NatIso.ofComponents (ρ_ ·)
end
end Bicategory
end CategoryTheory
|
CategoryTheory\Bicategory\Coherence.lean | /-
Copyright (c) 2022 Yuma Mizuno. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yuma Mizuno, Junyan Xu
-/
import Mathlib.CategoryTheory.PathCategory
import Mathlib.CategoryTheory.Functor.FullyFaithful
import Mathlib.CategoryTheory.Bicategory.Free
import Mathlib.CategoryTheory.Bicategory.LocallyDiscrete
/-!
# The coherence theorem for bicategories
In this file, we prove the coherence theorem for bicategories, stated in the following form: the
free bicategory over any quiver is locally thin.
The proof is almost the same as the proof of the coherence theorem for monoidal categories that
has been previously formalized in mathlib, which is based on the proof described by Ilya Beylin
and Peter Dybjer. The idea is to view a path on a quiver as a normal form of a 1-morphism in the
free bicategory on the same quiver. A normalization procedure is then described by
`normalize : Pseudofunctor (FreeBicategory B) (LocallyDiscrete (Paths B))`, which is a
pseudofunctor from the free bicategory to the locally discrete bicategory on the path category.
It turns out that this pseudofunctor is locally an equivalence of categories, and the coherence
theorem follows immediately from this fact.
## Main statements
* `locally_thin` : the free bicategory is locally thin, that is, there is at most one
2-morphism between two fixed 1-morphisms.
## References
* [Ilya Beylin and Peter Dybjer, Extracting a proof of coherence for monoidal categories from a
proof of normalization for monoids][beylin1996]
-/
open Quiver (Path)
open Quiver.Path
namespace CategoryTheory
open Bicategory Category
universe v u
namespace FreeBicategory
variable {B : Type u} [Quiver.{v + 1} B]
/-- Auxiliary definition for `inclusionPath`. -/
@[simp]
def inclusionPathAux {a : B} : ∀ {b : B}, Path a b → Hom a b
| _, nil => Hom.id a
| _, cons p f => (inclusionPathAux p).comp (Hom.of f)
/- Porting note: Since the following instance was removed when porting
`CategoryTheory.Bicategory.Free`, we add it locally here. -/
/-- Category structure on `Hom a b`. In this file, we will use `Hom a b` for `a b : B`
(precisely, `FreeBicategory.Hom a b`) instead of the definitionally equal expression
`a ⟶ b` for `a b : FreeBicategory B`. The main reason is that we have to annoyingly write
`@Quiver.Hom (FreeBicategory B) _ a b` to get the latter expression when given `a b : B`. -/
local instance homCategory' (a b : B) : Category (Hom a b) :=
homCategory a b
/-- The discrete category on the paths includes into the category of 1-morphisms in the free
bicategory.
-/
def inclusionPath (a b : B) : Discrete (Path.{v + 1} a b) ⥤ Hom a b :=
Discrete.functor inclusionPathAux
/-- The inclusion from the locally discrete bicategory on the path category into the free bicategory
as a prelax functor. This will be promoted to a pseudofunctor after proving the coherence theorem.
See `inclusion`.
-/
def preinclusion (B : Type u) [Quiver.{v + 1} B] :
PrelaxFunctor (LocallyDiscrete (Paths B)) (FreeBicategory B) where
obj a := a.as
map {a b} f := (@inclusionPath B _ a.as b.as).obj f
map₂ η := (inclusionPath _ _).map η
@[simp]
theorem preinclusion_obj (a : B) : (preinclusion B).obj ⟨a⟩ = a :=
rfl
@[simp]
theorem preinclusion_map₂ {a b : B} (f g : Discrete (Path.{v + 1} a b)) (η : f ⟶ g) :
(preinclusion B).map₂ η = eqToHom (congr_arg _ (Discrete.ext (Discrete.eq_of_hom η))) := by
rcases η with ⟨⟨⟩⟩
cases Discrete.ext (by assumption)
convert (inclusionPath a b).map_id _
/-- The normalization of the composition of `p : Path a b` and `f : Hom b c`.
`p` will eventually be taken to be `nil` and we then get the normalization
of `f` alone, but the auxiliary `p` is necessary for Lean to accept the definition of
`normalizeIso` and the `whisker_left` case of `normalizeAux_congr` and `normalize_naturality`.
-/
@[simp]
def normalizeAux {a : B} : ∀ {b c : B}, Path a b → Hom b c → Path a c
| _, _, p, Hom.of f => p.cons f
| _, _, p, Hom.id _ => p
| _, _, p, Hom.comp f g => normalizeAux (normalizeAux p f) g
/-
We may define
```
def normalizeAux' : ∀ {a b : B}, Hom a b → Path a b
| _, _, (Hom.of f) => f.toPath
| _, _, (Hom.id b) => nil
| _, _, (Hom.comp f g) => (normalizeAux' f).comp (normalizeAux' g)
```
and define `normalizeAux p f` to be `p.comp (normalizeAux' f)` and this will be
equal to the above definition, but the equality proof requires `comp_assoc`, and it
thus lacks the correct definitional property to make the definition of `normalizeIso`
typecheck.
```
example {a b c : B} (p : Path a b) (f : Hom b c) :
normalizeAux p f = p.comp (normalizeAux' f) := by
induction f; rfl; rfl;
case comp _ _ _ _ _ ihf ihg => rw [normalizeAux, ihf, ihg]; apply comp_assoc
```
-/
/-- A 2-isomorphism between a partially-normalized 1-morphism in the free bicategory to the
fully-normalized 1-morphism.
-/
@[simp]
def normalizeIso {a : B} :
∀ {b c : B} (p : Path a b) (f : Hom b c),
(preinclusion B).map ⟨p⟩ ≫ f ≅ (preinclusion B).map ⟨normalizeAux p f⟩
| _, _, _, Hom.of _ => Iso.refl _
| _, _, _, Hom.id b => ρ_ _
| _, _, p, Hom.comp f g =>
(α_ _ _ _).symm ≪≫ whiskerRightIso (normalizeIso p f) g ≪≫ normalizeIso (normalizeAux p f) g
/-- Given a 2-morphism between `f` and `g` in the free bicategory, we have the equality
`normalizeAux p f = normalizeAux p g`.
-/
theorem normalizeAux_congr {a b c : B} (p : Path a b) {f g : Hom b c} (η : f ⟶ g) :
normalizeAux p f = normalizeAux p g := by
rcases η with ⟨η'⟩
apply @congr_fun _ _ fun p => normalizeAux p f
clear p η
induction η' with
| vcomp _ _ _ _ => apply Eq.trans <;> assumption
| whisker_left _ _ ih => funext; apply congr_fun ih
| whisker_right _ _ ih => funext; apply congr_arg₂ _ (congr_fun ih _) rfl
| _ => funext; rfl
/-- The 2-isomorphism `normalizeIso p f` is natural in `f`. -/
theorem normalize_naturality {a b c : B} (p : Path a b) {f g : Hom b c} (η : f ⟶ g) :
(preinclusion B).map ⟨p⟩ ◁ η ≫ (normalizeIso p g).hom =
(normalizeIso p f).hom ≫
(preinclusion B).map₂ (eqToHom (Discrete.ext (normalizeAux_congr p η))) := by
rcases η with ⟨η'⟩; clear η
induction η' with
| id => simp
| vcomp η θ ihf ihg =>
simp only [mk_vcomp, Bicategory.whiskerLeft_comp]
slice_lhs 2 3 => rw [ihg]
slice_lhs 1 2 => rw [ihf]
simp
-- p ≠ nil required! See the docstring of `normalizeAux`.
| whisker_left _ _ ih =>
dsimp
rw [associator_inv_naturality_right_assoc, whisker_exchange_assoc, ih]
simp
| whisker_right h η' ih =>
dsimp
rw [associator_inv_naturality_middle_assoc, ← comp_whiskerRight_assoc, ih, comp_whiskerRight]
have := dcongr_arg (fun x => (normalizeIso x h).hom) (normalizeAux_congr p (Quot.mk _ η'))
dsimp at this; simp [this]
| _ => simp
-- Porting note: the left-hand side is not in simp-normal form.
-- @[simp]
theorem normalizeAux_nil_comp {a b c : B} (f : Hom a b) (g : Hom b c) :
normalizeAux nil (f.comp g) = (normalizeAux nil f).comp (normalizeAux nil g) := by
induction g generalizing a with
| id => rfl
| of => rfl
| comp g _ ihf ihg => erw [ihg (f.comp g), ihf f, ihg g, comp_assoc]
/-- The normalization pseudofunctor for the free bicategory on a quiver `B`. -/
def normalize (B : Type u) [Quiver.{v + 1} B] :
Pseudofunctor (FreeBicategory B) (LocallyDiscrete (Paths B)) where
obj a := ⟨a⟩
map f := ⟨normalizeAux nil f⟩
map₂ η := eqToHom <| Discrete.ext <| normalizeAux_congr nil η
mapId a := eqToIso <| Discrete.ext rfl
mapComp f g := eqToIso <| Discrete.ext <| normalizeAux_nil_comp f g
/-- Auxiliary definition for `normalizeEquiv`. -/
def normalizeUnitIso (a b : FreeBicategory B) :
𝟭 (a ⟶ b) ≅ (normalize B).mapFunctor a b ⋙ @inclusionPath B _ a b :=
NatIso.ofComponents (fun f => (λ_ f).symm ≪≫ normalizeIso nil f)
(by
intro f g η
erw [leftUnitor_inv_naturality_assoc, assoc]
congr 1
exact normalize_naturality nil η)
/-- Normalization as an equivalence of categories. -/
def normalizeEquiv (a b : B) : Hom a b ≌ Discrete (Path.{v + 1} a b) :=
Equivalence.mk ((normalize _).mapFunctor a b) (inclusionPath a b) (normalizeUnitIso a b)
(Discrete.natIso fun f => eqToIso (by
induction' f with f
induction' f with _ _ _ _ ih
-- Porting note: `tidy` closes the goal in mathlib3 but `aesop` doesn't here.
· rfl
· ext1
injection ih with ih
conv_rhs => rw [← ih]
rfl))
/-- The coherence theorem for bicategories. -/
instance locally_thin {a b : FreeBicategory B} : Quiver.IsThin (a ⟶ b) := fun _ _ =>
⟨fun _ _ =>
(@normalizeEquiv B _ a b).functor.map_injective (Subsingleton.elim _ _)⟩
/-- Auxiliary definition for `inclusion`. -/
def inclusionMapCompAux {a b : B} :
∀ {c : B} (f : Path a b) (g : Path b c),
(preinclusion _).map (⟨f⟩ ≫ ⟨g⟩) ≅ (preinclusion _).map ⟨f⟩ ≫ (preinclusion _).map ⟨g⟩
| _, f, nil => (ρ_ ((preinclusion _).map ⟨f⟩)).symm
| _, f, cons g₁ g₂ => whiskerRightIso (inclusionMapCompAux f g₁) (Hom.of g₂) ≪≫ α_ _ _ _
/-- The inclusion pseudofunctor from the locally discrete bicategory on the path category into the
free bicategory.
-/
def inclusion (B : Type u) [Quiver.{v + 1} B] :
Pseudofunctor (LocallyDiscrete (Paths B)) (FreeBicategory B) :=
{ -- All the conditions for 2-morphisms are trivial thanks to the coherence theorem!
preinclusion B with
mapId := fun a => Iso.refl _
mapComp := fun f g => inclusionMapCompAux f.as g.as }
end FreeBicategory
end CategoryTheory
|
CategoryTheory\Bicategory\End.lean | /-
Copyright (c) 2022 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Scott Morrison
-/
import Mathlib.CategoryTheory.Bicategory.Basic
import Mathlib.CategoryTheory.Monoidal.Category
/-!
# Endomorphisms of an object in a bicategory, as a monoidal category.
-/
namespace CategoryTheory
variable {C : Type*} [Bicategory C]
/-- The endomorphisms of an object in a bicategory can be considered as a monoidal category. -/
def EndMonoidal (X : C) :=
X ⟶ X -- deriving Category
-- Porting note: Deriving this fails in the definition above.
-- Adding category instance manually.
instance (X : C) : Category (EndMonoidal X) :=
show Category (X ⟶ X) from inferInstance
instance (X : C) : Inhabited (EndMonoidal X) :=
⟨𝟙 X⟩
open Bicategory
open MonoidalCategory
open Bicategory
attribute [local simp] EndMonoidal in
instance (X : C) : MonoidalCategory (EndMonoidal X) where
tensorObj f g := f ≫ g
whiskerLeft {f g h} η := f ◁ η
whiskerRight {f g} η h := η ▷ h
tensorUnit := 𝟙 _
associator f g h := α_ f g h
leftUnitor f := λ_ f
rightUnitor f := ρ_ f
tensor_comp := by
intros
dsimp
rw [Bicategory.whiskerLeft_comp, Bicategory.comp_whiskerRight, Category.assoc, Category.assoc,
Bicategory.whisker_exchange_assoc]
end CategoryTheory
|
CategoryTheory\Bicategory\Extension.lean | /-
Copyright (c) 2023 Yuma Mizuno. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yuma Mizuno
-/
import Mathlib.CategoryTheory.Bicategory.Basic
import Mathlib.CategoryTheory.Comma.StructuredArrow
/-!
# Extensions and lifts in bicategories
We introduce the concept of extensions and lifts within the bicategorical framework. These concepts
are defined by commutative diagrams in the (1-)categorical context. Within the bicategorical
framework, commutative diagrams are replaced by 2-morphisms. Depending on the orientation of the
2-morphisms, we define both left and right extensions (likewise for lifts). The use of left and
right here is a common one in the theory of Kan extensions.
## Implementation notes
We define extensions and lifts as objects in certain comma categories (`StructuredArrow` for left,
and `CostructuredArrow` for right). See the file `CategoryTheory.StructuredArrow` for properties
about these categories. We introduce some intuitive aliases. For example, `LeftExtension.extension`
is an alias for `Comma.right`.
## References
* https://ncatlab.org/nlab/show/lifts+and+extensions
* https://ncatlab.org/nlab/show/Kan+extension
-/
namespace CategoryTheory
namespace Bicategory
universe w v u
variable {B : Type u} [Bicategory.{w, v} B] {a b c : B}
/-- Triangle diagrams for (left) extensions.
```
b
△ \
| \ extension △
f | \ | unit
| ◿
a - - - ▷ c
g
```
-/
abbrev LeftExtension (f : a ⟶ b) (g : a ⟶ c) := StructuredArrow g (precomp _ f)
namespace LeftExtension
variable {f : a ⟶ b} {g : a ⟶ c}
/-- The extension of `g` along `f`. -/
abbrev extension (t : LeftExtension f g) : b ⟶ c := t.right
/-- The 2-morphism filling the triangle diagram. -/
abbrev unit (t : LeftExtension f g) : g ⟶ f ≫ t.extension := t.hom
/-- Construct a left extension from a 1-morphism and a 2-morphism. -/
abbrev mk (h : b ⟶ c) (unit : g ⟶ f ≫ h) : LeftExtension f g :=
StructuredArrow.mk unit
variable {s t : LeftExtension f g}
/-- To construct a morphism between left extensions, we need a 2-morphism between the extensions,
and to check that it is compatible with the units. -/
abbrev homMk (η : s.extension ⟶ t.extension) (w : s.unit ≫ f ◁ η = t.unit := by aesop_cat) :
s ⟶ t :=
StructuredArrow.homMk η w
@[reassoc (attr := simp)]
theorem w (η : s ⟶ t) : s.unit ≫ f ◁ η.right = t.unit :=
StructuredArrow.w η
/-- The left extension along the identity. -/
def alongId (g : a ⟶ c) : LeftExtension (𝟙 a) g := .mk _ (λ_ g).inv
instance : Inhabited (LeftExtension (𝟙 a) g) := ⟨alongId g⟩
/-- Construct a left extension of `g : a ⟶ c` from a left extension of `g ≫ 𝟙 c`. -/
@[simps!]
def ofCompId (t : LeftExtension f (g ≫ 𝟙 c)) : LeftExtension f g :=
mk (extension t) ((ρ_ g).inv ≫ unit t)
/-- Whisker a 1-morphism to an extension.
```
b
△ \
| \ extension △
f | \ | unit
| ◿
a - - - ▷ c - - - ▷ x
g h
```
-/
def whisker (t : LeftExtension f g) {x : B} (h : c ⟶ x) : LeftExtension f (g ≫ h) :=
.mk _ <| t.unit ▷ h ≫ (α_ _ _ _).hom
@[simp]
theorem whisker_extension (t : LeftExtension f g) {x : B} (h : c ⟶ x) :
(t.whisker h).extension = t.extension ≫ h :=
rfl
@[simp]
theorem whisker_unit (t : LeftExtension f g) {x : B} (h : c ⟶ x) :
(t.whisker h).unit = t.unit ▷ h ≫ (α_ f t.extension h).hom :=
rfl
/-- Whiskering a 1-morphism is a functor. -/
@[simps]
def whiskering {x : B} (h : c ⟶ x) : LeftExtension f g ⥤ LeftExtension f (g ≫ h) where
obj t := t.whisker h
map η := LeftExtension.homMk (η.right ▷ h) <| by
simp [- LeftExtension.w, ← LeftExtension.w η]
/-- Define a morphism between left extensions by cancelling the whiskered identities. -/
@[simps! right]
def whiskerIdCancel
(s : LeftExtension f (g ≫ 𝟙 c)) {t : LeftExtension f g} (τ : s ⟶ t.whisker (𝟙 c)) :
s.ofCompId ⟶ t :=
LeftExtension.homMk (τ.right ≫ (ρ_ _).hom)
/-- Construct a morphism between whiskered extensions. -/
@[simps! right]
def whiskerHom (i : s ⟶ t) {x : B} (h : c ⟶ x) :
s.whisker h ⟶ t.whisker h :=
StructuredArrow.homMk (i.right ▷ h) <| by
rw [← cancel_mono (α_ _ _ _).inv]
calc
_ = (unit s ≫ f ◁ i.right) ▷ h := by simp [- LeftExtension.w]
_ = unit t ▷ h := congrArg (· ▷ h) (LeftExtension.w i)
_ = _ := by simp
/-- Construct an isomorphism between whiskered extensions. -/
def whiskerIso (i : s ≅ t) {x : B} (h : c ⟶ x) :
s.whisker h ≅ t.whisker h :=
Iso.mk (whiskerHom i.hom h) (whiskerHom i.inv h)
(StructuredArrow.hom_ext _ _ <|
calc
_ = (i.hom ≫ i.inv).right ▷ h := by simp [- Iso.hom_inv_id]
_ = 𝟙 _ := by simp [Iso.hom_inv_id])
(StructuredArrow.hom_ext _ _ <|
calc
_ = (i.inv ≫ i.hom).right ▷ h := by simp [- Iso.inv_hom_id]
_ = 𝟙 _ := by simp [Iso.inv_hom_id])
/-- The isomorphism between left extensions induced by a right unitor. -/
@[simps! hom_right inv_right]
def whiskerOfCompIdIsoSelf (t : LeftExtension f g) : (t.whisker (𝟙 c)).ofCompId ≅ t :=
StructuredArrow.isoMk (ρ_ (t.extension))
end LeftExtension
/-- Triangle diagrams for (left) lifts.
```
b
◹ |
lift / | △
/ | f | unit
/ ▽
c - - - ▷ a
g
```
-/
abbrev LeftLift (f : b ⟶ a) (g : c ⟶ a) := StructuredArrow g (postcomp _ f)
namespace LeftLift
variable {f : b ⟶ a} {g : c ⟶ a}
/-- The lift of `g` along `f`. -/
abbrev lift (t : LeftLift f g) : c ⟶ b := t.right
/-- The 2-morphism filling the triangle diagram. -/
abbrev unit (t : LeftLift f g) : g ⟶ t.lift ≫ f := t.hom
/-- Construct a left lift from a 1-morphism and a 2-morphism. -/
abbrev mk (h : c ⟶ b) (unit : g ⟶ h ≫ f) : LeftLift f g :=
StructuredArrow.mk unit
variable {s t : LeftLift f g}
/-- To construct a morphism between left lifts, we need a 2-morphism between the lifts,
and to check that it is compatible with the units. -/
abbrev homMk (η : s.lift ⟶ t.lift) (w : s.unit ≫ η ▷ f = t.unit := by aesop_cat) :
s ⟶ t :=
StructuredArrow.homMk η w
@[reassoc (attr := simp)]
theorem w (h : s ⟶ t) : s.unit ≫ h.right ▷ f = t.unit :=
StructuredArrow.w h
/-- The left lift along the identity. -/
def alongId (g : c ⟶ a) : LeftLift (𝟙 a) g := .mk _ (ρ_ g).inv
instance : Inhabited (LeftLift (𝟙 a) g) := ⟨alongId g⟩
/-- Construct a left lift along `g : c ⟶ a` from a left lift along `𝟙 c ≫ g`. -/
@[simps!]
def ofIdComp (t : LeftLift f (𝟙 c ≫ g)) : LeftLift f g :=
mk (lift t) ((λ_ _).inv ≫ unit t)
/-- Whisker a 1-morphism to a lift.
```
b
◹ |
lift / | △
/ | f | unit
/ ▽
x - - - ▷ c - - - ▷ a
h g
```
-/
def whisker (t : LeftLift f g) {x : B} (h : x ⟶ c) : LeftLift f (h ≫ g) :=
.mk _ <| h ◁ t.unit ≫ (α_ _ _ _).inv
@[simp]
theorem whisker_lift (t : LeftLift f g) {x : B} (h : x ⟶ c) :
(t.whisker h).lift = h ≫ t.lift :=
rfl
@[simp]
theorem whisker_unit (t : LeftLift f g) {x : B} (h : x ⟶ c) :
(t.whisker h).unit = h ◁ t.unit ≫ (α_ h t.lift f).inv :=
rfl
/-- Whiskering a 1-morphism is a functor. -/
@[simps]
def whiskering {x : B} (h : x ⟶ c) : LeftLift f g ⥤ LeftLift f (h ≫ g) where
obj t := t.whisker h
map η := LeftLift.homMk (h ◁ η.right) <| by
dsimp only [whisker_lift, whisker_unit]
rw [← LeftLift.w η]
simp [- LeftLift.w]
/-- Define a morphism between left lifts by cancelling the whiskered identities. -/
@[simps! right]
def whiskerIdCancel
(s : LeftLift f (𝟙 c ≫ g)) {t : LeftLift f g} (τ : s ⟶ t.whisker (𝟙 c)) :
s.ofIdComp ⟶ t :=
LeftLift.homMk (τ.right ≫ (λ_ _).hom)
/-- Construct a morphism between whiskered lifts. -/
@[simps! right]
def whiskerHom (i : s ⟶ t) {x : B} (h : x ⟶ c) :
s.whisker h ⟶ t.whisker h :=
StructuredArrow.homMk (h ◁ i.right) <| by
rw [← cancel_mono (α_ h _ _).hom]
calc
_ = h ◁ (unit s ≫ i.right ▷ f) := by simp [- LeftLift.w]
_ = h ◁ unit t := congrArg (h ◁ ·) (LeftLift.w i)
_ = _ := by simp
/-- Construct an isomorphism between whiskered lifts. -/
def whiskerIso (i : s ≅ t) {x : B} (h : x ⟶ c) :
s.whisker h ≅ t.whisker h :=
Iso.mk (whiskerHom i.hom h) (whiskerHom i.inv h)
(StructuredArrow.hom_ext _ _ <|
calc
_ = h ◁ (i.hom ≫ i.inv).right := by simp [- Iso.hom_inv_id]
_ = 𝟙 _ := by simp [Iso.hom_inv_id])
(StructuredArrow.hom_ext _ _ <|
calc
_ = h ◁ (i.inv ≫ i.hom).right := by simp [- Iso.inv_hom_id]
_ = 𝟙 _ := by simp [Iso.inv_hom_id])
/-- The isomorphism between left lifts induced by a left unitor. -/
@[simps! hom_right inv_right]
def whiskerOfIdCompIsoSelf (t : LeftLift f g) : (t.whisker (𝟙 c)).ofIdComp ≅ t :=
StructuredArrow.isoMk (λ_ (lift t))
end LeftLift
/-- Triangle diagrams for (right) extensions.
```
b
△ \
| \ extension | counit
f | \ ▽
| ◿
a - - - ▷ c
g
```
-/
abbrev RightExtension (f : a ⟶ b) (g : a ⟶ c) := CostructuredArrow (precomp _ f) g
namespace RightExtension
variable {f : a ⟶ b} {g : a ⟶ c}
/-- The extension of `g` along `f`. -/
abbrev extension (t : RightExtension f g) : b ⟶ c := t.left
/-- The 2-morphism filling the triangle diagram. -/
abbrev counit (t : RightExtension f g) : f ≫ t.extension ⟶ g := t.hom
/-- Construct a right extension from a 1-morphism and a 2-morphism. -/
abbrev mk (h : b ⟶ c) (counit : f ≫ h ⟶ g) : RightExtension f g :=
CostructuredArrow.mk counit
/-- To construct a morphism between right extensions, we need a 2-morphism between the extensions,
and to check that it is compatible with the counits. -/
abbrev homMk {s t : RightExtension f g} (η : s.extension ⟶ t.extension)
(w : f ◁ η ≫ t.counit = s.counit) : s ⟶ t :=
CostructuredArrow.homMk η w
@[reassoc (attr := simp)]
theorem w {s t : RightExtension f g} (η : s ⟶ t) :
f ◁ η.left ≫ t.counit = s.counit :=
CostructuredArrow.w η
/-- The right extension along the identity. -/
def alongId (g : a ⟶ c) : RightExtension (𝟙 a) g := .mk _ (λ_ g).hom
instance : Inhabited (RightExtension (𝟙 a) g) := ⟨alongId g⟩
end RightExtension
/-- Triangle diagrams for (right) lifts.
```
b
◹ |
lift / | | counit
/ | f ▽
/ ▽
c - - - ▷ a
g
```
-/
abbrev RightLift (f : b ⟶ a) (g : c ⟶ a) := CostructuredArrow (postcomp _ f) g
namespace RightLift
variable {f : b ⟶ a} {g : c ⟶ a}
/-- The lift of `g` along `f`. -/
abbrev lift (t : RightLift f g) : c ⟶ b := t.left
/-- The 2-morphism filling the triangle diagram. -/
abbrev counit (t : RightLift f g) : t.lift ≫ f ⟶ g := t.hom
/-- Construct a right lift from a 1-morphism and a 2-morphism. -/
abbrev mk (h : c ⟶ b) (counit : h ≫ f ⟶ g) : RightLift f g :=
CostructuredArrow.mk counit
/-- To construct a morphism between right lifts, we need a 2-morphism between the lifts,
and to check that it is compatible with the counits. -/
abbrev homMk {s t : RightLift f g} (η : s.lift ⟶ t.lift) (w : η ▷ f ≫ t.counit = s.counit) :
s ⟶ t :=
CostructuredArrow.homMk η w
@[reassoc (attr := simp)]
theorem w {s t : RightLift f g} (h : s ⟶ t) :
h.left ▷ f ≫ t.counit = s.counit :=
CostructuredArrow.w h
/-- The right lift along the identity. -/
def alongId (g : c ⟶ a) : RightLift (𝟙 a) g := .mk _ (ρ_ g).hom
instance : Inhabited (RightLift (𝟙 a) g) := ⟨alongId g⟩
end RightLift
end Bicategory
end CategoryTheory
|
CategoryTheory\Bicategory\Free.lean | /-
Copyright (c) 2022 Yuma Mizuno. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yuma Mizuno
-/
import Mathlib.CategoryTheory.Bicategory.Functor.Pseudofunctor
/-!
# Free bicategories
We define the free bicategory over a quiver. In this bicategory, the 1-morphisms are freely
generated by the arrows in the quiver, and the 2-morphisms are freely generated by the formal
identities, the formal unitors, and the formal associators modulo the relation derived from the
axioms of a bicategory.
## Main definitions
* `FreeBicategory B`: the free bicategory over a quiver `B`.
* `FreeBicategory.lift F`: the pseudofunctor from `FreeBicategory B` to `C` associated with a
prefunctor `F` from `B` to `C`.
-/
universe w w₁ w₂ v v₁ v₂ u u₁ u₂
namespace CategoryTheory
open Category Bicategory
open Bicategory
/-- Free bicategory over a quiver. Its objects are the same as those in the underlying quiver. -/
def FreeBicategory (B : Type u) :=
B
instance (B : Type u) : ∀ [Inhabited B], Inhabited (FreeBicategory B) := by
intro h
exact id h
namespace FreeBicategory
section
variable {B : Type u} [Quiver.{v + 1} B]
/-- 1-morphisms in the free bicategory. -/
inductive Hom : B → B → Type max u v
| of {a b : B} (f : a ⟶ b) : Hom a b
| id (a : B) : Hom a a
| comp {a b c : B} (f : Hom a b) (g : Hom b c) : Hom a c
instance (a b : B) [Inhabited (a ⟶ b)] : Inhabited (Hom a b) :=
⟨Hom.of default⟩
instance quiver : Quiver.{max u v + 1} (FreeBicategory B) where
Hom := fun a b : B => Hom a b
instance categoryStruct : CategoryStruct.{max u v} (FreeBicategory B) where
id := fun a : B => Hom.id a
comp := @fun _ _ _ => Hom.comp
/-- Representatives of 2-morphisms in the free bicategory. -/
-- Porting note(#5171): linter not ported yet
-- @[nolint has_nonempty_instance]
inductive Hom₂ : ∀ {a b : FreeBicategory B}, (a ⟶ b) → (a ⟶ b) → Type max u v
| id {a b} (f : a ⟶ b) : Hom₂ f f
| vcomp {a b} {f g h : a ⟶ b} (η : Hom₂ f g) (θ : Hom₂ g h) : Hom₂ f h
| whisker_left {a b c} (f : a ⟶ b) {g h : b ⟶ c} (η : Hom₂ g h) :
Hom₂ (f ≫ g) (f ≫ h)-- `η` cannot be earlier than `h` since it is a recursive argument.
| whisker_right {a b c} {f g : a ⟶ b} (h : b ⟶ c) (η : Hom₂ f g) : Hom₂ (f.comp h) (g.comp h)
| associator {a b c d} (f : a ⟶ b) (g : b ⟶ c) (h : c ⟶ d) :
Hom₂ ((f ≫ g) ≫ h) (f ≫ (g ≫ h))
| associator_inv {a b c d} (f : a ⟶ b) (g : b ⟶ c) (h : c ⟶ d) :
Hom₂ (f ≫ (g ≫ h)) ((f ≫ g) ≫ h)
| right_unitor {a b} (f : a ⟶ b) : Hom₂ (f ≫ (𝟙 b)) f
| right_unitor_inv {a b} (f : a ⟶ b) : Hom₂ f (f ≫ (𝟙 b))
| left_unitor {a b} (f : a ⟶ b) : Hom₂ ((𝟙 a) ≫ f) f
| left_unitor_inv {a b} (f : a ⟶ b) : Hom₂ f ((𝟙 a) ≫ f)
section
-- The following notations are only used in the definition of `Rel` to simplify the notation.
local infixr:0 " ≫ " => Hom₂.vcomp
local notation "𝟙" => Hom₂.id
local notation f " ◁ " η => Hom₂.whisker_left f η
local notation η " ▷ " h => Hom₂.whisker_right h η
local notation "α_" => Hom₂.associator
local notation "λ_" => Hom₂.left_unitor
local notation "ρ_" => Hom₂.right_unitor
local notation "α⁻¹_" => Hom₂.associator_inv
local notation "λ⁻¹_" => Hom₂.left_unitor_inv
local notation "ρ⁻¹_" => Hom₂.right_unitor_inv
/-- Relations between 2-morphisms in the free bicategory. -/
inductive Rel : ∀ {a b : FreeBicategory B} {f g : a ⟶ b}, Hom₂ f g → Hom₂ f g → Prop
| vcomp_right {a b} {f g h : Hom a b} (η : Hom₂ f g) (θ₁ θ₂ : Hom₂ g h) :
Rel θ₁ θ₂ → Rel (η ≫ θ₁) (η ≫ θ₂)
| vcomp_left {a b} {f g h : Hom a b} (η₁ η₂ : Hom₂ f g) (θ : Hom₂ g h) :
Rel η₁ η₂ → Rel (η₁ ≫ θ) (η₂ ≫ θ)
| id_comp {a b} {f g : Hom a b} (η : Hom₂ f g) : Rel (𝟙 f ≫ η) η
| comp_id {a b} {f g : Hom a b} (η : Hom₂ f g) : Rel (η ≫ 𝟙 g) η
| assoc {a b} {f g h i : Hom a b} (η : Hom₂ f g) (θ : Hom₂ g h) (ι : Hom₂ h i) :
Rel ((η ≫ θ) ≫ ι) (η ≫ θ ≫ ι)
| whisker_left {a b c} (f : Hom a b) (g h : Hom b c) (η η' : Hom₂ g h) :
Rel η η' → Rel (f ◁ η) (f ◁ η')
| whisker_left_id {a b c} (f : Hom a b) (g : Hom b c) : Rel (f ◁ 𝟙 g) (𝟙 (f.comp g))
| whisker_left_comp {a b c} (f : Hom a b) {g h i : Hom b c} (η : Hom₂ g h) (θ : Hom₂ h i) :
Rel (f ◁ η ≫ θ) ((f ◁ η) ≫ f ◁ θ)
| id_whisker_left {a b} {f g : Hom a b} (η : Hom₂ f g) : Rel (Hom.id a ◁ η) (λ_ f ≫ η ≫ λ⁻¹_ g)
| comp_whisker_left {a b c d} (f : Hom a b) (g : Hom b c) {h h' : Hom c d} (η : Hom₂ h h') :
Rel (f.comp g ◁ η) (α_ f g h ≫ (f ◁ g ◁ η) ≫ α⁻¹_ f g h')
| whisker_right {a b c} (f g : Hom a b) (h : Hom b c) (η η' : Hom₂ f g) :
Rel η η' → Rel (η ▷ h) (η' ▷ h)
| id_whisker_right {a b c} (f : Hom a b) (g : Hom b c) : Rel (𝟙 f ▷ g) (𝟙 (f.comp g))
| comp_whisker_right {a b c} {f g h : Hom a b} (i : Hom b c) (η : Hom₂ f g) (θ : Hom₂ g h) :
Rel ((η ≫ θ) ▷ i) ((η ▷ i) ≫ θ ▷ i)
| whisker_right_id {a b} {f g : Hom a b} (η : Hom₂ f g) : Rel (η ▷ Hom.id b) (ρ_ f ≫ η ≫ ρ⁻¹_ g)
| whisker_right_comp {a b c d} {f f' : Hom a b} (g : Hom b c) (h : Hom c d) (η : Hom₂ f f') :
Rel (η ▷ g.comp h) (α⁻¹_ f g h ≫ ((η ▷ g) ▷ h) ≫ α_ f' g h)
| whisker_assoc {a b c d} (f : Hom a b) {g g' : Hom b c} (η : Hom₂ g g') (h : Hom c d) :
Rel ((f ◁ η) ▷ h) (α_ f g h ≫ (f ◁ η ▷ h) ≫ α⁻¹_ f g' h)
| whisker_exchange {a b c} {f g : Hom a b} {h i : Hom b c} (η : Hom₂ f g) (θ : Hom₂ h i) :
Rel ((f ◁ θ) ≫ η ▷ i) ((η ▷ h) ≫ g ◁ θ)
| associator_hom_inv {a b c d} (f : Hom a b) (g : Hom b c) (h : Hom c d) :
Rel (α_ f g h ≫ α⁻¹_ f g h) (𝟙 ((f.comp g).comp h))
| associator_inv_hom {a b c d} (f : Hom a b) (g : Hom b c) (h : Hom c d) :
Rel (α⁻¹_ f g h ≫ α_ f g h) (𝟙 (f.comp (g.comp h)))
| left_unitor_hom_inv {a b} (f : Hom a b) : Rel (λ_ f ≫ λ⁻¹_ f) (𝟙 ((Hom.id a).comp f))
| left_unitor_inv_hom {a b} (f : Hom a b) : Rel (λ⁻¹_ f ≫ λ_ f) (𝟙 f)
| right_unitor_hom_inv {a b} (f : Hom a b) : Rel (ρ_ f ≫ ρ⁻¹_ f) (𝟙 (f.comp (Hom.id b)))
| right_unitor_inv_hom {a b} (f : Hom a b) : Rel (ρ⁻¹_ f ≫ ρ_ f) (𝟙 f)
| pentagon {a b c d e} (f : Hom a b) (g : Hom b c) (h : Hom c d) (i : Hom d e) :
Rel ((α_ f g h ▷ i) ≫ α_ f (g.comp h) i ≫ f ◁ α_ g h i)
(α_ (f.comp g) h i ≫ α_ f g (h.comp i))
| triangle {a b c} (f : Hom a b) (g : Hom b c) : Rel (α_ f (Hom.id b) g ≫ f ◁ λ_ g) (ρ_ f ▷ g)
end
instance homCategory (a b : FreeBicategory B) : Category (a ⟶ b) where
Hom f g := Quot (@Rel _ _ a b f g)
id f := Quot.mk Rel (Hom₂.id f)
comp := @fun f g h => Quot.map₂ Hom₂.vcomp Rel.vcomp_right Rel.vcomp_left
id_comp := by
rintro f g ⟨η⟩
exact Quot.sound (Rel.id_comp η)
comp_id := by
rintro f g ⟨η⟩
exact Quot.sound (Rel.comp_id η)
assoc := by
rintro f g h i ⟨η⟩ ⟨θ⟩ ⟨ι⟩
exact Quot.sound (Rel.assoc η θ ι)
/-- Bicategory structure on the free bicategory. -/
instance bicategory : Bicategory (FreeBicategory B) where
homCategory := @fun (a b : B) => FreeBicategory.homCategory a b
whiskerLeft := @fun a b c f g h η => Quot.map (Hom₂.whisker_left f) (Rel.whisker_left f g h) η
whiskerLeft_id := @fun a b c f g => Quot.sound (Rel.whisker_left_id f g)
associator := @fun a b c d f g h =>
{ hom := Quot.mk Rel (Hom₂.associator f g h)
inv := Quot.mk Rel (Hom₂.associator_inv f g h)
hom_inv_id := Quot.sound (Rel.associator_hom_inv f g h)
inv_hom_id := Quot.sound (Rel.associator_inv_hom f g h) }
leftUnitor := @fun a b f =>
{ hom := Quot.mk Rel (Hom₂.left_unitor f)
inv := Quot.mk Rel (Hom₂.left_unitor_inv f)
hom_inv_id := Quot.sound (Rel.left_unitor_hom_inv f)
inv_hom_id := Quot.sound (Rel.left_unitor_inv_hom f) }
rightUnitor := @fun a b f =>
{ hom := Quot.mk Rel (Hom₂.right_unitor f)
inv := Quot.mk Rel (Hom₂.right_unitor_inv f)
hom_inv_id := Quot.sound (Rel.right_unitor_hom_inv f)
inv_hom_id := Quot.sound (Rel.right_unitor_inv_hom f) }
whiskerLeft_comp := by
rintro a b c f g h i ⟨η⟩ ⟨θ⟩
exact Quot.sound (Rel.whisker_left_comp f η θ)
id_whiskerLeft := by
rintro a b f g ⟨η⟩
exact Quot.sound (Rel.id_whisker_left η)
comp_whiskerLeft := by
rintro a b c d f g h h' ⟨η⟩
exact Quot.sound (Rel.comp_whisker_left f g η)
whiskerRight := @fun a b c f g η h => Quot.map (Hom₂.whisker_right h) (Rel.whisker_right f g h) η
id_whiskerRight := @fun a b c f g => Quot.sound (Rel.id_whisker_right f g)
comp_whiskerRight := by
rintro a b c f g h ⟨η⟩ ⟨θ⟩ i
exact Quot.sound (Rel.comp_whisker_right i η θ)
whiskerRight_id := by
rintro a b f g ⟨η⟩
exact Quot.sound (Rel.whisker_right_id η)
whiskerRight_comp := by
rintro a b c d f f' ⟨η⟩ g h
exact Quot.sound (Rel.whisker_right_comp g h η)
whisker_assoc := by
rintro a b c d f g g' ⟨η⟩ h
exact Quot.sound (Rel.whisker_assoc f η h)
whisker_exchange := by
rintro a b c f g h i ⟨η⟩ ⟨θ⟩
exact Quot.sound (Rel.whisker_exchange η θ)
pentagon := @fun a b c d e f g h i => Quot.sound (Rel.pentagon f g h i)
triangle := @fun a b c f g => Quot.sound (Rel.triangle f g)
variable {a b c d : FreeBicategory B}
abbrev Hom₂.mk {f g : a ⟶ b} (η : Hom₂ f g) : f ⟶ g :=
Quot.mk Rel η
@[simp]
theorem mk_vcomp {f g h : a ⟶ b} (η : Hom₂ f g) (θ : Hom₂ g h) :
(η.vcomp θ).mk = (η.mk ≫ θ.mk : f ⟶ h) :=
rfl
@[simp]
theorem mk_whisker_left (f : a ⟶ b) {g h : b ⟶ c} (η : Hom₂ g h) :
(Hom₂.whisker_left f η).mk = (f ◁ η.mk : f ≫ g ⟶ f ≫ h) :=
rfl
@[simp]
theorem mk_whisker_right {f g : a ⟶ b} (η : Hom₂ f g) (h : b ⟶ c) :
(Hom₂.whisker_right h η).mk = (η.mk ▷ h : f ≫ h ⟶ g ≫ h) :=
rfl
variable (f : a ⟶ b) (g : b ⟶ c) (h : c ⟶ d)
-- Porting note: I can not get this to typecheck, and I don't understand why.
-- theorem id_def : Hom.id a = 𝟙 a :=
-- rfl
theorem comp_def : Hom.comp f g = f ≫ g :=
rfl
@[simp]
theorem mk_id : Quot.mk _ (Hom₂.id f) = 𝟙 f :=
rfl
@[simp]
theorem mk_associator_hom : Quot.mk _ (Hom₂.associator f g h) = (α_ f g h).hom :=
rfl
@[simp]
theorem mk_associator_inv : Quot.mk _ (Hom₂.associator_inv f g h) = (α_ f g h).inv :=
rfl
@[simp]
theorem mk_left_unitor_hom : Quot.mk _ (Hom₂.left_unitor f) = (λ_ f).hom :=
rfl
@[simp]
theorem mk_left_unitor_inv : Quot.mk _ (Hom₂.left_unitor_inv f) = (λ_ f).inv :=
rfl
@[simp]
theorem mk_right_unitor_hom : Quot.mk _ (Hom₂.right_unitor f) = (ρ_ f).hom :=
rfl
@[simp]
theorem mk_right_unitor_inv : Quot.mk _ (Hom₂.right_unitor_inv f) = (ρ_ f).inv :=
rfl
/-- Canonical prefunctor from `B` to `free_bicategory B`. -/
@[simps]
def of : Prefunctor B (FreeBicategory B) where
obj := id
map := @fun _ _ => Hom.of
end
section
variable {B : Type u₁} [Quiver.{v₁ + 1} B] {C : Type u₂} [CategoryStruct.{v₂} C]
variable (F : Prefunctor B C)
/-- Auxiliary definition for `lift`. -/
@[simp]
def liftHom : ∀ {a b : FreeBicategory B}, (a ⟶ b) → (F.obj a ⟶ F.obj b)
| _, _, Hom.of f => F.map f
| _, _, Hom.id a => 𝟙 (F.obj a)
| _, _, Hom.comp f g => liftHom f ≫ liftHom g
@[simp]
theorem liftHom_id (a : FreeBicategory B) : liftHom F (𝟙 a) = 𝟙 (F.obj a) :=
rfl
@[simp]
theorem liftHom_comp {a b c : FreeBicategory B} (f : a ⟶ b) (g : b ⟶ c) :
liftHom F (f ≫ g) = liftHom F f ≫ liftHom F g :=
rfl
end
section
variable {B : Type u₁} [Quiver.{v₁ + 1} B] {C : Type u₂} [Bicategory.{w₂, v₂} C]
variable (F : Prefunctor B C)
/-- Auxiliary definition for `lift`. -/
-- @[simp] -- Porting note: adding `@[simp]` causes a PANIC.
def liftHom₂ : ∀ {a b : FreeBicategory B} {f g : a ⟶ b}, Hom₂ f g → (liftHom F f ⟶ liftHom F g)
| _, _, _, _, Hom₂.id _ => 𝟙 _
| _, _, _, _, Hom₂.associator _ _ _ => (α_ _ _ _).hom
| _, _, _, _, Hom₂.associator_inv _ _ _ => (α_ _ _ _).inv
| _, _, _, _, Hom₂.left_unitor _ => (λ_ _).hom
| _, _, _, _, Hom₂.left_unitor_inv _ => (λ_ _).inv
| _, _, _, _, Hom₂.right_unitor _ => (ρ_ _).hom
| _, _, _, _, Hom₂.right_unitor_inv _ => (ρ_ _).inv
| _, _, _, _, Hom₂.vcomp η θ => liftHom₂ η ≫ liftHom₂ θ
| _, _, _, _, Hom₂.whisker_left f η => liftHom F f ◁ liftHom₂ η
| _, _, _, _, Hom₂.whisker_right h η => liftHom₂ η ▷ liftHom F h
attribute [local simp] whisker_exchange
theorem liftHom₂_congr {a b : FreeBicategory B} {f g : a ⟶ b} {η θ : Hom₂ f g} (H : Rel η θ) :
liftHom₂ F η = liftHom₂ F θ := by induction H <;> (dsimp [liftHom₂]; aesop_cat)
/-- A prefunctor from a quiver `B` to a bicategory `C` can be lifted to a pseudofunctor from
`free_bicategory B` to `C`.
-/
@[simps]
def lift : Pseudofunctor (FreeBicategory B) C where
obj := F.obj
map := liftHom F
mapId a := Iso.refl _
mapComp f g := Iso.refl _
map₂ := Quot.lift (liftHom₂ F) fun η θ H => liftHom₂_congr F H
-- Porting note: We'd really prefer not to be doing this by hand.
-- in mathlib3 `tidy` did these inductions for us.
map₂_comp := by
intros a b f g h η θ
apply Quot.rec _ _ η
· intro η
apply Quot.rec _ _ θ
· intro θ; rfl
· intros; rfl
· intros; rfl
-- Porting note: still borked from here. The infoview doesn't update properly for me.
map₂_whisker_left := by
intro a b c f g h η
apply Quot.rec _ _ η
· intros; aesop_cat
· intros; rfl
map₂_whisker_right := by intro _ _ _ _ _ η h; dsimp; apply Quot.rec _ _ η <;> aesop_cat
end
end FreeBicategory
end CategoryTheory
|
CategoryTheory\Bicategory\FunctorBicategory.lean | /-
Copyright (c) 2022 Yuma Mizuno. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yuma Mizuno
-/
import Mathlib.CategoryTheory.Bicategory.NaturalTransformation.Oplax
/-!
# The bicategory of oplax functors between two bicategories
Given bicategories `B` and `C`, we give a bicategory structure on `OplaxFunctor B C` whose
* objects are oplax functors,
* 1-morphisms are oplax natural transformations, and
* 2-morphisms are modifications.
-/
namespace CategoryTheory
open Category Bicategory
open scoped Bicategory
universe w₁ w₂ v₁ v₂ u₁ u₂
variable {B : Type u₁} [Bicategory.{w₁, v₁} B] {C : Type u₂} [Bicategory.{w₂, v₂} C]
variable {F G H I : OplaxFunctor B C}
namespace OplaxNatTrans
/-- Left whiskering of an oplax natural transformation and a modification. -/
@[simps]
def whiskerLeft (η : F ⟶ G) {θ ι : G ⟶ H} (Γ : θ ⟶ ι) : η ≫ θ ⟶ η ≫ ι where
app a := η.app a ◁ Γ.app a
naturality {a b} f := by
dsimp
rw [associator_inv_naturality_right_assoc, whisker_exchange_assoc]
simp
/-- Right whiskering of an oplax natural transformation and a modification. -/
@[simps]
def whiskerRight {η θ : F ⟶ G} (Γ : η ⟶ θ) (ι : G ⟶ H) : η ≫ ι ⟶ θ ≫ ι where
app a := Γ.app a ▷ ι.app a
naturality {a b} f := by
dsimp
simp_rw [assoc, ← associator_inv_naturality_left, whisker_exchange_assoc]
simp
/-- Associator for the vertical composition of oplax natural transformations. -/
-- Porting note: verified that projections are correct and changed @[simps] to @[simps!]
@[simps!]
def associator (η : F ⟶ G) (θ : G ⟶ H) (ι : H ⟶ I) : (η ≫ θ) ≫ ι ≅ η ≫ θ ≫ ι :=
ModificationIso.ofComponents (fun a => α_ (η.app a) (θ.app a) (ι.app a)) (by aesop_cat)
/-- Left unitor for the vertical composition of oplax natural transformations. -/
-- Porting note: verified that projections are correct and changed @[simps] to @[simps!]
@[simps!]
def leftUnitor (η : F ⟶ G) : 𝟙 F ≫ η ≅ η :=
ModificationIso.ofComponents (fun a => λ_ (η.app a)) (by aesop_cat)
/-- Right unitor for the vertical composition of oplax natural transformations. -/
-- Porting note: verified that projections are correct and changed @[simps] to @[simps!]
@[simps!]
def rightUnitor (η : F ⟶ G) : η ≫ 𝟙 G ≅ η :=
ModificationIso.ofComponents (fun a => ρ_ (η.app a)) (by aesop_cat)
end OplaxNatTrans
variable (B C)
/-- A bicategory structure on the oplax functors between bicategories. -/
-- Porting note: verified that projections are correct and changed @[simps] to @[simps!]
@[simps!]
instance OplaxFunctor.bicategory : Bicategory (OplaxFunctor B C) where
whiskerLeft {F G H} η _ _ Γ := OplaxNatTrans.whiskerLeft η Γ
whiskerRight {F G H} _ _ Γ η := OplaxNatTrans.whiskerRight Γ η
associator {F G H} I := OplaxNatTrans.associator
leftUnitor {F G} := OplaxNatTrans.leftUnitor
rightUnitor {F G} := OplaxNatTrans.rightUnitor
whisker_exchange {a b c f g h i} η θ := by
ext
exact whisker_exchange _ _
end CategoryTheory
|
CategoryTheory\Bicategory\LocallyDiscrete.lean | /-
Copyright (c) 2022 Yuma Mizuno. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yuma Mizuno, Calle Sönne
-/
import Mathlib.CategoryTheory.DiscreteCategory
import Mathlib.CategoryTheory.Bicategory.Functor.Pseudofunctor
import Mathlib.CategoryTheory.Bicategory.Strict
/-!
# Locally discrete bicategories
A category `C` can be promoted to a strict bicategory `LocallyDiscrete C`. The objects and the
1-morphisms in `LocallyDiscrete C` are the same as the objects and the morphisms, respectively,
in `C`, and the 2-morphisms in `LocallyDiscrete C` are the equalities between 1-morphisms. In
other words, the category consisting of the 1-morphisms between each pair of objects `X` and `Y`
in `LocallyDiscrete C` is defined as the discrete category associated with the type `X ⟶ Y`.
-/
namespace CategoryTheory
open Bicategory Discrete
open Bicategory
universe w₂ w₁ v₂ v₁ v u₂ u₁ u
section
variable {C : Type u}
/-- A wrapper for promoting any category to a bicategory,
with the only 2-morphisms being equalities.
-/
@[ext]
structure LocallyDiscrete (C : Type u) where
/-- A wrapper for promoting any category to a bicategory,
with the only 2-morphisms being equalities.
-/
as : C
namespace LocallyDiscrete
@[simp]
theorem mk_as (a : LocallyDiscrete C) : mk a.as = a := rfl
/-- `LocallyDiscrete C` is equivalent to the original type `C`. -/
@[simps]
def locallyDiscreteEquiv : LocallyDiscrete C ≃ C where
toFun := LocallyDiscrete.as
invFun := LocallyDiscrete.mk
left_inv := by aesop_cat
right_inv := by aesop_cat
instance [DecidableEq C] : DecidableEq (LocallyDiscrete C) :=
locallyDiscreteEquiv.decidableEq
instance [Inhabited C] : Inhabited (LocallyDiscrete C) :=
⟨⟨default⟩⟩
instance categoryStruct [CategoryStruct.{v} C] : CategoryStruct (LocallyDiscrete C) where
Hom a b := Discrete (a.as ⟶ b.as)
id a := ⟨𝟙 a.as⟩
comp f g := ⟨f.as ≫ g.as⟩
variable [CategoryStruct.{v} C]
@[simp]
lemma id_as (a : LocallyDiscrete C) : (𝟙 a : Discrete (a.as ⟶ a.as)).as = 𝟙 a.as :=
rfl
@[simp]
lemma comp_as {a b c : LocallyDiscrete C} (f : a ⟶ b) (g : b ⟶ c) : (f ≫ g).as = f.as ≫ g.as :=
rfl
instance (priority := 900) homSmallCategory (a b : LocallyDiscrete C) : SmallCategory (a ⟶ b) :=
CategoryTheory.discreteCategory (a.as ⟶ b.as)
-- Porting note: Manually adding this instance (inferInstance doesn't work)
instance subsingleton2Hom {a b : LocallyDiscrete C} (f g : a ⟶ b) : Subsingleton (f ⟶ g) :=
instSubsingletonDiscreteHom f g
/-- Extract the equation from a 2-morphism in a locally discrete 2-category. -/
theorem eq_of_hom {X Y : LocallyDiscrete C} {f g : X ⟶ Y} (η : f ⟶ g) : f = g :=
Discrete.ext η.1.1
end LocallyDiscrete
variable (C)
variable [Category.{v} C]
/-- The locally discrete bicategory on a category is a bicategory in which the objects and the
1-morphisms are the same as those in the underlying category, and the 2-morphisms are the
equalities between 1-morphisms.
-/
instance locallyDiscreteBicategory : Bicategory (LocallyDiscrete C) where
whiskerLeft f g h η := eqToHom (congr_arg₂ (· ≫ ·) rfl (LocallyDiscrete.eq_of_hom η))
whiskerRight η h := eqToHom (congr_arg₂ (· ≫ ·) (LocallyDiscrete.eq_of_hom η) rfl)
associator f g h := eqToIso <| by apply Discrete.ext; simp
leftUnitor f := eqToIso <| by apply Discrete.ext; simp
rightUnitor f := eqToIso <| by apply Discrete.ext; simp
/-- A locally discrete bicategory is strict. -/
instance locallyDiscreteBicategory.strict : Strict (LocallyDiscrete C) where
id_comp f := Discrete.ext (Category.id_comp _)
comp_id f := Discrete.ext (Category.comp_id _)
assoc f g h := Discrete.ext (Category.assoc _ _ _)
variable {I : Type u₁} [Category.{v₁} I] {B : Type u₂} [Bicategory.{w₂, v₂} B] [Strict B]
/--
If `B` is a strict bicategory and `I` is a (1-)category, any functor (of 1-categories) `I ⥤ B` can
be promoted to a pseudofunctor from `LocallyDiscrete I` to `B`.
-/
@[simps]
def Functor.toPseudoFunctor (F : I ⥤ B) : Pseudofunctor (LocallyDiscrete I) B where
obj i := F.obj i.as
map f := F.map f.as
map₂ η := eqToHom (congr_arg _ (LocallyDiscrete.eq_of_hom η))
mapId i := eqToIso (F.map_id i.as)
mapComp f g := eqToIso (F.map_comp f.as g.as)
/--
If `B` is a strict bicategory and `I` is a (1-)category, any functor (of 1-categories) `I ⥤ B` can
be promoted to an oplax functor from `LocallyDiscrete I` to `B`.
-/
@[simps]
def Functor.toOplaxFunctor (F : I ⥤ B) : OplaxFunctor (LocallyDiscrete I) B where
obj i := F.obj i.as
map f := F.map f.as
map₂ η := eqToHom (congr_arg _ (LocallyDiscrete.eq_of_hom η))
mapId i := eqToHom (F.map_id i.as)
mapComp f g := eqToHom (F.map_comp f.as g.as)
end
section
variable {B : Type u₁} [Bicategory.{w₁, v₁} B] {C : Type u₂} [Bicategory.{w₂, v₂} C]
@[simp]
lemma PrelaxFunctor.map₂_eqToHom (F : PrelaxFunctor B C) {a b : B} {f g : a ⟶ b} (h : f = g) :
F.map₂ (eqToHom h) = eqToHom (F.congr_map h) := by
subst h; simp only [eqToHom_refl, PrelaxFunctor.map₂_id]
end
end CategoryTheory
section
open CategoryTheory LocallyDiscrete
universe v u
namespace Quiver.Hom
variable {C : Type u} [CategoryStruct.{v} C]
/-- The 1-morphism in `LocallyDiscrete C` associated to a given morphism `f : a ⟶ b` in `C` -/
@[simps]
def toLoc {a b : C} (f : a ⟶ b) : LocallyDiscrete.mk a ⟶ LocallyDiscrete.mk b :=
⟨f⟩
@[simp]
lemma id_toLoc (a : C) : (𝟙 a).toLoc = 𝟙 (LocallyDiscrete.mk a) :=
rfl
@[simp]
lemma comp_toLoc {a b c : C} (f : a ⟶ b) (g : b ⟶ c) : (f ≫ g).toLoc = f.toLoc ≫ g.toLoc :=
rfl
end Quiver.Hom
@[simp]
lemma CategoryTheory.LocallyDiscrete.eqToHom_toLoc {C : Type u} [Category.{v} C] {a b : C}
(h : a = b) : (eqToHom h).toLoc = eqToHom (congrArg LocallyDiscrete.mk h) := by
subst h; rfl
end
|
CategoryTheory\Bicategory\SingleObj.lean | /-
Copyright (c) 2022 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Scott Morrison
-/
import Mathlib.CategoryTheory.Bicategory.End
import Mathlib.CategoryTheory.Monoidal.Functor
/-!
# Promoting a monoidal category to a single object bicategory.
A monoidal category can be thought of as a bicategory with a single object.
The objects of the monoidal category become the 1-morphisms,
with composition given by tensor product,
and the morphisms of the monoidal category become the 2-morphisms.
We verify that the endomorphisms of that single object recovers the original monoidal category.
One could go much further: the bicategory of monoidal categories
(equipped with monoidal functors and monoidal natural transformations)
is equivalent to the bicategory consisting of
* single object bicategories,
* pseudofunctors, and
* (oplax) natural transformations `η` such that `η.app PUnit.unit = 𝟙 _`.
-/
namespace CategoryTheory
variable (C : Type*) [Category C] [MonoidalCategory C]
/-- Promote a monoidal category to a bicategory with a single object.
(The objects of the monoidal category become the 1-morphisms,
with composition given by tensor product,
and the morphisms of the monoidal category become the 2-morphisms.)
-/
@[nolint unusedArguments]
def MonoidalSingleObj (C : Type*) [Category C] [MonoidalCategory C] :=
PUnit --deriving Inhabited
-- Porting note: `deriving` didn't work. Create this instance manually.
instance : Inhabited (MonoidalSingleObj C) := by
unfold MonoidalSingleObj
infer_instance
open MonoidalCategory
instance : Bicategory (MonoidalSingleObj C) where
Hom _ _ := C
id _ := 𝟙_ C
comp X Y := tensorObj X Y
whiskerLeft X Y Z f := X ◁ f
whiskerRight f Z := f ▷ Z
associator X Y Z := α_ X Y Z
leftUnitor X := λ_ X
rightUnitor X := ρ_ X
whisker_exchange := whisker_exchange
namespace MonoidalSingleObj
/-- The unique object in the bicategory obtained by "promoting" a monoidal category. -/
@[nolint unusedArguments]
protected def star : MonoidalSingleObj C :=
PUnit.unit
/-- The monoidal functor from the endomorphisms of the single object
when we promote a monoidal category to a single object bicategory,
to the original monoidal category.
We subsequently show this is an equivalence.
-/
@[simps]
def endMonoidalStarFunctor : MonoidalFunctor (EndMonoidal (MonoidalSingleObj.star C)) C where
obj X := X
map f := f
ε := 𝟙 _
μ X Y := 𝟙 _
/-- The equivalence between the endomorphisms of the single object
when we promote a monoidal category to a single object bicategory,
and the original monoidal category.
-/
@[simps functor inverse_obj inverse_map unitIso counitIso]
noncomputable def endMonoidalStarFunctorEquivalence :
EndMonoidal (MonoidalSingleObj.star C) ≌ C where
functor := (endMonoidalStarFunctor C).toFunctor
inverse :=
{ obj := fun X => X
map := fun f => f }
unitIso := Iso.refl _
counitIso := Iso.refl _
instance endMonoidalStarFunctor_isEquivalence : (endMonoidalStarFunctor C).IsEquivalence :=
(endMonoidalStarFunctorEquivalence C).isEquivalence_functor
end MonoidalSingleObj
end CategoryTheory
|
CategoryTheory\Bicategory\Strict.lean | /-
Copyright (c) 2022 Yuma Mizuno. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yuma Mizuno
-/
import Mathlib.CategoryTheory.EqToHom
import Mathlib.CategoryTheory.Bicategory.Basic
/-!
# Strict bicategories
A bicategory is called `Strict` if the left unitors, the right unitors, and the associators are
isomorphisms given by equalities.
## Implementation notes
In the literature of category theory, a strict bicategory (usually called a strict 2-category) is
often defined as a bicategory whose left unitors, right unitors, and associators are identities.
We cannot use this definition directly here since the types of 2-morphisms depend on 1-morphisms.
For this reason, we use `eqToIso`, which gives isomorphisms from equalities, instead of
identities.
-/
namespace CategoryTheory
open Bicategory
universe w v u
variable (B : Type u) [Bicategory.{w, v} B]
/-- A bicategory is called `Strict` if the left unitors, the right unitors, and the associators are
isomorphisms given by equalities.
-/
class Bicategory.Strict : Prop where
/-- Identity morphisms are left identities for composition. -/
id_comp : ∀ {a b : B} (f : a ⟶ b), 𝟙 a ≫ f = f := by aesop_cat
/-- Identity morphisms are right identities for composition. -/
comp_id : ∀ {a b : B} (f : a ⟶ b), f ≫ 𝟙 b = f := by aesop_cat
/-- Composition in a bicategory is associative. -/
assoc : ∀ {a b c d : B} (f : a ⟶ b) (g : b ⟶ c) (h : c ⟶ d), (f ≫ g) ≫ h = f ≫ g ≫ h := by
aesop_cat
/-- The left unitors are given by equalities -/
leftUnitor_eqToIso : ∀ {a b : B} (f : a ⟶ b), λ_ f = eqToIso (id_comp f) := by aesop_cat
/-- The right unitors are given by equalities -/
rightUnitor_eqToIso : ∀ {a b : B} (f : a ⟶ b), ρ_ f = eqToIso (comp_id f) := by aesop_cat
/-- The associators are given by equalities -/
associator_eqToIso :
∀ {a b c d : B} (f : a ⟶ b) (g : b ⟶ c) (h : c ⟶ d), α_ f g h = eqToIso (assoc f g h) := by
aesop_cat
-- Porting note: not adding simp to:
-- Bicategory.Strict.id_comp
-- Bicategory.Strict.comp_id
-- Bicategory.Strict.assoc
attribute [simp]
Bicategory.Strict.leftUnitor_eqToIso
Bicategory.Strict.rightUnitor_eqToIso
Bicategory.Strict.associator_eqToIso
-- see Note [lower instance priority]
/-- Category structure on a strict bicategory -/
instance (priority := 100) StrictBicategory.category [Bicategory.Strict B] : Category B where
id_comp := Bicategory.Strict.id_comp
comp_id := Bicategory.Strict.comp_id
assoc := Bicategory.Strict.assoc
namespace Bicategory
variable {B}
@[simp]
theorem whiskerLeft_eqToHom {a b c : B} (f : a ⟶ b) {g h : b ⟶ c} (η : g = h) :
f ◁ eqToHom η = eqToHom (congr_arg₂ (· ≫ ·) rfl η) := by
cases η
simp only [whiskerLeft_id, eqToHom_refl]
@[simp]
theorem eqToHom_whiskerRight {a b c : B} {f g : a ⟶ b} (η : f = g) (h : b ⟶ c) :
eqToHom η ▷ h = eqToHom (congr_arg₂ (· ≫ ·) η rfl) := by
cases η
simp only [id_whiskerRight, eqToHom_refl]
end Bicategory
end CategoryTheory
|
CategoryTheory\Bicategory\Functor\Lax.lean | /-
Copyright (c) 2024 Calle Sönne. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Calle Sönne
-/
import Mathlib.CategoryTheory.Bicategory.Functor.Prelax
import Mathlib.Tactic.CategoryTheory.Slice
/-!
# Lax functors
A lax functor `F` between bicategories `B` and `C` consists of
* a function between objects `F.obj : B ⟶ C`,
* a family of functions between 1-morphisms `F.map : (a ⟶ b) → (F.obj a ⟶ F.obj b)`,
* a family of functions between 2-morphisms `F.map₂ : (f ⟶ g) → (F.map f ⟶ F.map g)`,
* a family of 2-morphisms `F.mapId a : 𝟙 (F.obj a) ⟶ F.map (𝟙 a)`,
* a family of 2-morphisms `F.mapComp f g : F.map f ≫ F.map g ⟶ F.map (f ≫ g)`, and
* certain consistency conditions on them.
## Main definitions
* `CategoryTheory.LaxFunctor B C` : an lax functor between bicategories `B` and `C`
* `CategoryTheory.LaxFunctor.comp F G` : the composition of lax functors
* `CategoryTheory.LaxFunctor.Pseudocore` : a structure on an Lax functor that promotes a
Lax functor to a pseudofunctor
## Future work
Some constructions in the bicategory library have only been done in terms of oplax functors,
since lax functors had not yet been added (e.g `FunctorBicategory.lean`). A possible project would
be to mirror these constructions for lax functors.
-/
namespace CategoryTheory
open Category Bicategory
open Bicategory
universe w₁ w₂ w₃ v₁ v₂ v₃ u₁ u₂ u₃
/-- A lax functor `F` between bicategories `B` and `C` consists of a function between objects
`F.obj`, a function between 1-morphisms `F.map`, and a function between 2-morphisms `F.map₂`.
Unlike functors between categories, `F.map` do not need to strictly commute with the composition,
and do not need to strictly preserve the identity. Instead, there are specified 2-morphisms
`𝟙 (F.obj a) ⟶ F.map (𝟙 a)` and `F.map f ≫ F.map g ⟶ F.map (f ≫ g)`.
`F.map₂` strictly commute with compositions and preserve the identity. They also preserve the
associator, the left unitor, and the right unitor modulo some adjustments of domains and codomains
of 2-morphisms.
-/
structure LaxFunctor (B: Type u₁) [Bicategory.{w₁, v₁} B] (C : Type u₂) [Bicategory.{w₂, v₂} C]
extends PrelaxFunctor B C where
/-- The 2-morphism underlying the lax unity constraint. -/
mapId (a : B) : 𝟙 (obj a) ⟶ map (𝟙 a)
/-- The 2-morphism underlying the lax functoriality constraint. -/
mapComp {a b c : B} (f : a ⟶ b) (g : b ⟶ c) : map f ≫ map g ⟶ map (f ≫ g)
/-- Naturality of the lax functoriality constraight, on the left. -/
mapComp_naturality_left :
∀ {a b c : B} {f f' : a ⟶ b} (η : f ⟶ f') (g : b ⟶ c),
mapComp f g ≫ map₂ (η ▷ g) = map₂ η ▷ map g ≫ mapComp f' g:= by aesop_cat
/-- Naturality of the lax functoriality constraight, on the right. -/
mapComp_naturality_right :
∀ {a b c : B} (f : a ⟶ b) {g g' : b ⟶ c} (η : g ⟶ g'),
mapComp f g ≫ map₂ (f ◁ η) = map f ◁ map₂ η ≫ mapComp f g' := by aesop_cat
/-- Lax associativity -/
map₂_associator :
∀ {a b c d : B} (f : a ⟶ b) (g : b ⟶ c) (h : c ⟶ d),
mapComp f g ▷ map h ≫ mapComp (f ≫ g) h ≫ map₂ (α_ f g h).hom =
(α_ (map f) (map g) (map h)).hom ≫ map f ◁ mapComp g h ≫ mapComp f (g ≫ h) := by aesop_cat
/-- Lax left unity -/
map₂_leftUnitor :
∀ {a b : B} (f : a ⟶ b),
map₂ (λ_ f).inv = (λ_ (map f)).inv ≫ mapId a ▷ map f ≫ mapComp (𝟙 a) f := by aesop_cat
/-- Lax right unity -/
map₂_rightUnitor :
∀ {a b : B} (f : a ⟶ b),
map₂ (ρ_ f).inv = (ρ_ (map f)).inv ≫ map f ◁ mapId b ≫ mapComp f (𝟙 b) := by aesop_cat
initialize_simps_projections LaxFunctor (+toPrelaxFunctor, -obj, -map, -map₂)
namespace LaxFunctor
variable {B : Type u₁} [Bicategory.{w₁, v₁} B] {C : Type u₂} [Bicategory.{w₂, v₂} C]
attribute [reassoc (attr := simp)]
mapComp_naturality_left mapComp_naturality_right map₂_associator
attribute [simp, reassoc] map₂_leftUnitor map₂_rightUnitor
/-- The underlying prelax functor. -/
add_decl_doc LaxFunctor.toPrelaxFunctor
variable (F : LaxFunctor B C)
@[reassoc]
lemma mapComp_assoc_left {a b c d : B} (f : a ⟶ b) (g : b ⟶ c) (h : c ⟶ d) :
F.mapComp f g ▷ F.map h ≫ F.mapComp (f ≫ g) h = (α_ (F.map f) (F.map g) (F.map h)).hom ≫
F.map f ◁ F.mapComp g h ≫ F.mapComp f (g ≫ h) ≫ F.map₂ (α_ f g h).inv := by
rw [← F.map₂_associator_assoc, ← F.map₂_comp]
simp only [Iso.hom_inv_id, PrelaxFunctor.map₂_id, comp_id]
@[reassoc]
lemma mapComp_assoc_right {a b c d : B} (f : a ⟶ b) (g : b ⟶ c) (h : c ⟶ d) :
F.map f ◁ F.mapComp g h ≫ F.mapComp f (g ≫ h) =
(α_ (F.map f) (F.map g) (F.map h)).inv ≫ F.mapComp f g ▷ F.map h ≫
F.mapComp (f ≫ g) h ≫ F.map₂ (α_ f g h).hom := by
simp only [map₂_associator, Iso.inv_hom_id_assoc]
@[reassoc]
lemma map₂_leftUnitor_hom {a b : B} (f : a ⟶ b) :
(λ_ (F.map f)).hom = F.mapId a ▷ F.map f ≫ F.mapComp (𝟙 a) f ≫ F.map₂ (λ_ f).hom := by
rw [← PrelaxFunctor.map₂Iso_hom, ← assoc, ← Iso.comp_inv_eq, ← Iso.eq_inv_comp]
simp only [Functor.mapIso_inv, PrelaxFunctor.mapFunctor_map, map₂_leftUnitor]
@[reassoc]
lemma map₂_rightUnitor_hom {a b : B} (f : a ⟶ b) :
(ρ_ (F.map f)).hom = F.map f ◁ F.mapId b ≫ F.mapComp f (𝟙 b) ≫ F.map₂ (ρ_ f).hom := by
rw [← PrelaxFunctor.map₂Iso_hom, ← assoc, ← Iso.comp_inv_eq, ← Iso.eq_inv_comp]
simp only [Functor.mapIso_inv, PrelaxFunctor.mapFunctor_map, map₂_rightUnitor]
/-- The identity lax functor. -/
@[simps]
def id (B : Type u₁) [Bicategory.{w₁, v₁} B] : LaxFunctor B B where
toPrelaxFunctor := PrelaxFunctor.id B
mapId := fun a => 𝟙 (𝟙 a)
mapComp := fun f g => 𝟙 (f ≫ g)
instance : Inhabited (LaxFunctor B B) :=
⟨id B⟩
/-- Composition of lax functors. -/
@[simps]
def comp {D : Type u₃} [Bicategory.{w₃, v₃} D] (F : LaxFunctor B C) (G : LaxFunctor C D) :
LaxFunctor B D where
toPrelaxFunctor := PrelaxFunctor.comp F.toPrelaxFunctor G.toPrelaxFunctor
mapId := fun a => G.mapId (F.obj a) ≫ G.map₂ (F.mapId a)
mapComp := fun f g => G.mapComp (F.map f) (F.map g) ≫ G.map₂ (F.mapComp f g)
mapComp_naturality_left := fun η g => by
dsimp
rw [assoc, ← G.map₂_comp, mapComp_naturality_left, G.map₂_comp, mapComp_naturality_left_assoc]
mapComp_naturality_right := fun f _ _ η => by
dsimp
rw [assoc, ← G.map₂_comp, mapComp_naturality_right, G.map₂_comp, mapComp_naturality_right_assoc]
map₂_associator := fun f g h => by
dsimp
slice_rhs 1 3 =>
rw [whiskerLeft_comp, assoc, ← mapComp_naturality_right, ← map₂_associator_assoc]
slice_rhs 3 5 =>
rw [← G.map₂_comp, ← G.map₂_comp, ← F.map₂_associator, G.map₂_comp, G.map₂_comp]
slice_lhs 1 3 =>
rw [comp_whiskerRight, assoc, ← G.mapComp_naturality_left_assoc]
simp only [assoc]
map₂_leftUnitor := fun f => by
dsimp
simp only [map₂_leftUnitor, PrelaxFunctor.map₂_comp, assoc, mapComp_naturality_left_assoc,
comp_whiskerRight]
map₂_rightUnitor := fun f => by
dsimp
simp only [map₂_rightUnitor, PrelaxFunctor.map₂_comp, assoc, mapComp_naturality_right_assoc,
whiskerLeft_comp]
/-- A structure on an Lax functor that promotes an Lax functor to a pseudofunctor.
See `Pseudofunctor.mkOfLax`. -/
structure PseudoCore (F : LaxFunctor B C) where
mapIdIso (a : B) : F.map (𝟙 a) ≅ 𝟙 (F.obj a)
mapCompIso {a b c : B} (f : a ⟶ b) (g : b ⟶ c) : F.map (f ≫ g) ≅ F.map f ≫ F.map g
mapIdIso_inv {a : B} : (mapIdIso a).inv = F.mapId a := by aesop_cat
mapCompIso_inv {a b c : B} (f : a ⟶ b) (g : b ⟶ c) : (mapCompIso f g).inv = F.mapComp f g := by
aesop_cat
attribute [nolint docBlame] CategoryTheory.LaxFunctor.PseudoCore.mapIdIso
CategoryTheory.LaxFunctor.PseudoCore.mapCompIso
CategoryTheory.LaxFunctor.PseudoCore.mapIdIso_inv
CategoryTheory.LaxFunctor.PseudoCore.mapCompIso_inv
attribute [simp] PseudoCore.mapIdIso_inv PseudoCore.mapCompIso_inv
end LaxFunctor
end CategoryTheory
|
CategoryTheory\Bicategory\Functor\Oplax.lean | /-
Copyright (c) 2022 Yuma Mizuno. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yuma Mizuno
-/
import Mathlib.CategoryTheory.Bicategory.Functor.Prelax
/-!
# Oplax functors
An oplax functor `F` between bicategories `B` and `C` consists of
* a function between objects `F.obj : B ⟶ C`,
* a family of functions between 1-morphisms `F.map : (a ⟶ b) → (F.obj a ⟶ F.obj b)`,
* a family of functions between 2-morphisms `F.map₂ : (f ⟶ g) → (F.map f ⟶ F.map g)`,
* a family of 2-morphisms `F.mapId a : F.map (𝟙 a) ⟶ 𝟙 (F.obj a)`,
* a family of 2-morphisms `F.mapComp f g : F.map (f ≫ g) ⟶ F.map f ≫ F.map g`, and
* certain consistency conditions on them.
## Main definitions
* `CategoryTheory.OplaxFunctor B C` : an oplax functor between bicategories `B` and `C`
* `CategoryTheory.OplaxFunctor.comp F G` : the composition of oplax functors
-/
namespace CategoryTheory
open Category Bicategory
open Bicategory
universe w₁ w₂ w₃ v₁ v₂ v₃ u₁ u₂ u₃
section
variable {B : Type u₁} [Bicategory.{w₁, v₁} B] {C : Type u₂} [Bicategory.{w₂, v₂} C]
variable {D : Type u₃} [Bicategory.{w₃, v₃} D]
-- Porting note: in Lean 3 the below auxiliary definition was only used once, in the definition
-- of oplax functor, with a comment that it had to be used to fix a timeout. The timeout is
-- not present in Lean 4, however Lean 4 is not as good at seeing through the definition,
-- meaning that `simp` wasn't functioning as well as it should. I have hence removed
-- the auxiliary definition.
--@[simp]
--def OplaxFunctor.Map₂AssociatorAux (obj : B → C) (map : ∀ {X Y : B}, (X ⟶ Y) → (obj X ⟶ obj Y))
-- (map₂ : ∀ {a b : B} {f g : a ⟶ b}, (f ⟶ g) → (map f ⟶ map g))
-- (map_comp : ∀ {a b c : B} (f : a ⟶ b) (g : b ⟶ c), map (f ≫ g) ⟶ map f ≫ map g) {a b c d : B}
-- (f : a ⟶ b) (g : b ⟶ c) (h : c ⟶ d) : Prop := ...
/-- An oplax functor `F` between bicategories `B` and `C` consists of a function between objects
`F.obj`, a function between 1-morphisms `F.map`, and a function between 2-morphisms `F.map₂`.
Unlike functors between categories, `F.map` do not need to strictly commute with the composition,
and do not need to strictly preserve the identity. Instead, there are specified 2-morphisms
`F.map (𝟙 a) ⟶ 𝟙 (F.obj a)` and `F.map (f ≫ g) ⟶ F.map f ≫ F.map g`.
`F.map₂` strictly commute with compositions and preserve the identity. They also preserve the
associator, the left unitor, and the right unitor modulo some adjustments of domains and codomains
of 2-morphisms.
-/
structure OplaxFunctor (B : Type u₁) [Bicategory.{w₁, v₁} B] (C : Type u₂)
[Bicategory.{w₂, v₂} C] extends PrelaxFunctor B C where
mapId (a : B) : map (𝟙 a) ⟶ 𝟙 (obj a)
mapComp {a b c : B} (f : a ⟶ b) (g : b ⟶ c) : map (f ≫ g) ⟶ map f ≫ map g
mapComp_naturality_left :
∀ {a b c : B} {f f' : a ⟶ b} (η : f ⟶ f') (g : b ⟶ c),
map₂ (η ▷ g) ≫ mapComp f' g = mapComp f g ≫ map₂ η ▷ map g := by
aesop_cat
mapComp_naturality_right :
∀ {a b c : B} (f : a ⟶ b) {g g' : b ⟶ c} (η : g ⟶ g'),
map₂ (f ◁ η) ≫ mapComp f g' = mapComp f g ≫ map f ◁ map₂ η := by
aesop_cat
-- Porting note: `map₂_associator_aux` was used here in lean 3, but this was a hack
-- to avoid a timeout; we revert this hack here (because it was causing other problems
-- and was not necessary in lean 4)
map₂_associator :
∀ {a b c d : B} (f : a ⟶ b) (g : b ⟶ c) (h : c ⟶ d),
map₂ (α_ f g h).hom ≫ mapComp f (g ≫ h) ≫ map f ◁ mapComp g h =
mapComp (f ≫ g) h ≫ mapComp f g ▷ map h ≫ (α_ (map f) (map g) (map h)).hom := by
aesop_cat
map₂_leftUnitor :
∀ {a b : B} (f : a ⟶ b),
map₂ (λ_ f).hom = mapComp (𝟙 a) f ≫ mapId a ▷ map f ≫ (λ_ (map f)).hom := by
aesop_cat
map₂_rightUnitor :
∀ {a b : B} (f : a ⟶ b),
map₂ (ρ_ f).hom = mapComp f (𝟙 b) ≫ map f ◁ mapId b ≫ (ρ_ (map f)).hom := by
aesop_cat
initialize_simps_projections OplaxFunctor (+toPrelaxFunctor, -obj, -map, -map₂)
namespace OplaxFunctor
attribute [reassoc (attr := simp)]
mapComp_naturality_left mapComp_naturality_right map₂_associator
attribute [simp, reassoc] map₂_leftUnitor map₂_rightUnitor
section
/-- The underlying prelax functor. -/
add_decl_doc OplaxFunctor.toPrelaxFunctor
attribute [nolint docBlame] CategoryTheory.OplaxFunctor.mapId
CategoryTheory.OplaxFunctor.mapComp
CategoryTheory.OplaxFunctor.mapComp_naturality_left
CategoryTheory.OplaxFunctor.mapComp_naturality_right
CategoryTheory.OplaxFunctor.map₂_associator
CategoryTheory.OplaxFunctor.map₂_leftUnitor
CategoryTheory.OplaxFunctor.map₂_rightUnitor
variable (F : OplaxFunctor B C)
@[reassoc]
lemma mapComp_assoc_right {a b c d : B} (f : a ⟶ b) (g : b ⟶ c) (h : c ⟶ d) :
F.mapComp f (g ≫ h) ≫ F.map f ◁ F.mapComp g h = F.map₂ (α_ f g h).inv ≫
F.mapComp (f ≫ g) h ≫ F.mapComp f g ▷ F.map h ≫
(α_ (F.map f) (F.map g) (F.map h)).hom := by
rw [← @map₂_associator, ← F.map₂_comp_assoc]
simp
@[reassoc]
lemma mapComp_assoc_left {a b c d : B} (f : a ⟶ b) (g : b ⟶ c) (h : c ⟶ d) :
F.mapComp (f ≫ g) h ≫ F.mapComp f g ▷ F.map h =
F.map₂ (α_ f g h).hom ≫ F.mapComp f (g ≫ h) ≫ F.map f ◁ F.mapComp g h
≫ (α_ (F.map f) (F.map g) (F.map h)).inv := by
simp
-- Porting note: `to_prelax_eq_coe` and `to_prelaxFunctor_obj` are
-- syntactic tautologies in lean 4
-- Porting note: removed lemma `to_prelaxFunctor_map` relating the now
-- nonexistent `PrelaxFunctor.map` and `OplaxFunctor.map`
-- Porting note: removed lemma `to_prelaxFunctor_map₂` relating
-- `PrelaxFunctor.map₂` to nonexistent `OplaxFunctor.map₂`
/-- The identity oplax functor. -/
@[simps]
def id (B : Type u₁) [Bicategory.{w₁, v₁} B] : OplaxFunctor B B where
toPrelaxFunctor := PrelaxFunctor.id B
mapId := fun a => 𝟙 (𝟙 a)
mapComp := fun f g => 𝟙 (f ≫ g)
instance : Inhabited (OplaxFunctor B B) :=
⟨id B⟩
/-- Composition of oplax functors. -/
--@[simps]
def comp (F : OplaxFunctor B C) (G : OplaxFunctor C D) : OplaxFunctor B D where
toPrelaxFunctor := F.toPrelaxFunctor.comp G.toPrelaxFunctor
mapId := fun a => (G.mapFunctor _ _).map (F.mapId a) ≫ G.mapId (F.obj a)
mapComp := fun f g => (G.mapFunctor _ _).map (F.mapComp f g) ≫ G.mapComp (F.map f) (F.map g)
mapComp_naturality_left := fun η g => by
dsimp
rw [← G.map₂_comp_assoc, mapComp_naturality_left, G.map₂_comp_assoc, mapComp_naturality_left,
assoc]
mapComp_naturality_right := fun η => by
dsimp
intros
rw [← G.map₂_comp_assoc, mapComp_naturality_right, G.map₂_comp_assoc,
mapComp_naturality_right, assoc]
map₂_associator := fun f g h => by
dsimp
-- Porting note: if you use the `map₂_associator_aux` hack in the definition of
-- `map₂_associator` then the `simp only` call below does not seem to apply `map₂_associator`
simp only [map₂_associator, ← PrelaxFunctor.map₂_comp_assoc, ← mapComp_naturality_right_assoc,
whiskerLeft_comp, assoc]
simp only [map₂_associator, PrelaxFunctor.map₂_comp, mapComp_naturality_left_assoc,
comp_whiskerRight, assoc]
map₂_leftUnitor := fun f => by
dsimp
simp only [map₂_leftUnitor, PrelaxFunctor.map₂_comp, mapComp_naturality_left_assoc,
comp_whiskerRight, assoc]
map₂_rightUnitor := fun f => by
dsimp
simp only [map₂_rightUnitor, PrelaxFunctor.map₂_comp, mapComp_naturality_right_assoc,
whiskerLeft_comp, assoc]
/-- A structure on an oplax functor that promotes an oplax functor to a pseudofunctor.
See `Pseudofunctor.mkOfOplax`.
-/
-- Porting note(#5171): linter not ported yet
-- @[nolint has_nonempty_instance]
-- Porting note: removing primes in structure name because
-- my understanding is that they're no longer needed
structure PseudoCore (F : OplaxFunctor B C) where
mapIdIso (a : B) : F.map (𝟙 a) ≅ 𝟙 (F.obj a)
mapCompIso {a b c : B} (f : a ⟶ b) (g : b ⟶ c) : F.map (f ≫ g) ≅ F.map f ≫ F.map g
mapIdIso_hom : ∀ {a : B}, (mapIdIso a).hom = F.mapId a := by aesop_cat
mapCompIso_hom :
∀ {a b c : B} (f : a ⟶ b) (g : b ⟶ c), (mapCompIso f g).hom = F.mapComp f g := by aesop_cat
attribute [nolint docBlame] CategoryTheory.OplaxFunctor.PseudoCore.mapIdIso
CategoryTheory.OplaxFunctor.PseudoCore.mapCompIso
CategoryTheory.OplaxFunctor.PseudoCore.mapIdIso_hom
CategoryTheory.OplaxFunctor.PseudoCore.mapCompIso_hom
attribute [simp] PseudoCore.mapIdIso_hom PseudoCore.mapCompIso_hom
end
end OplaxFunctor
end
end CategoryTheory
|
CategoryTheory\Bicategory\Functor\Prelax.lean | /-
Copyright (c) 2024 Calle Sönne. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yuma Mizuno, Calle Sönne
-/
import Mathlib.CategoryTheory.Bicategory.Basic
/-!
# Prelax functors
This file defines lax prefunctors and prelax functors between bicategories. The point of these
definitions is to provide some common API that will be helpful in the development of both lax and
oplax functors.
## Main definitions
`PrelaxFunctorStruct B C`:
A PrelaxFunctorStruct `F` between quivers `B` and `C`, such that both have been equipped with quiver
structures on the hom-types, consists of
* a function between objects `F.obj : B ⟶ C`,
* a family of functions between 1-morphisms `F.map : (a ⟶ b) → (F.obj a ⟶ F.obj b)`,
* a family of functions between 2-morphisms `F.map₂ : (f ⟶ g) → (F.map f ⟶ F.map g)`,
`PrelaxFunctor B C`:
A prelax functor `F` between bicategories `B` and `C` is a `PrelaxFunctorStruct` such that the
associated prefunctors between the hom types are all functors. In other words, it is a
`PrelaxFunctorStruct` that satisfies
* `F.map₂ (𝟙 f) = 𝟙 (F.map f)`,
* `F.map₂ (η ≫ θ) = F.map₂ η ≫ F.map₂ θ`.
`mkOfHomFunctor`: constructs a `PrelaxFunctor` from a map on objects and functors between the
corresponding hom types.
-/
namespace CategoryTheory
open Category Bicategory
open Bicategory
universe w₁ w₂ w₃ v₁ v₂ v₃ u₁ u₂ u₃
section
variable (B : Type u₁) [Quiver.{v₁ + 1} B] [∀ a b : B, Quiver.{w₁ + 1} (a ⟶ b)]
variable (C : Type u₂) [Quiver.{v₂ + 1} C] [∀ a b : C, Quiver.{w₂ + 1} (a ⟶ b)]
variable {D : Type u₃} [Quiver.{v₃ + 1} D] [∀ a b : D, Quiver.{w₃ + 1} (a ⟶ b)]
/-- A `PrelaxFunctorStruct` between bicategories consists of functions between objects,
1-morphisms, and 2-morphisms. This structure will be extended to define `PrelaxFunctor`.
-/
structure PrelaxFunctorStruct extends Prefunctor B C where
/-- The action of a lax prefunctor on 2-morphisms. -/
map₂ {a b : B} {f g : a ⟶ b} : (f ⟶ g) → (map f ⟶ map g)
initialize_simps_projections PrelaxFunctorStruct (+toPrefunctor, -obj, -map)
/-- The prefunctor between the underlying quivers. -/
add_decl_doc PrelaxFunctorStruct.toPrefunctor
variable {B} {C}
namespace PrelaxFunctorStruct
/-- Construct a lax prefunctor from a map on objects, and prefunctors between the corresponding
hom types. -/
@[simps]
def mkOfHomPrefunctors (F : B → C) (F' : (a : B) → (b : B) → Prefunctor (a ⟶ b) (F a ⟶ F b)) :
PrelaxFunctorStruct B C where
obj := F
map {a b} := (F' a b).obj
map₂ {a b} := (F' a b).map
variable (F : PrelaxFunctorStruct B C)
-- Porting note: deleted syntactic tautologies `toPrefunctor_eq_coe : F.toPrefunctor = F`
-- and `to_prefunctor_obj : (F : Prefunctor B C).obj = F.obj`
-- and `to_prefunctor_map`
/-- The identity lax prefunctor. -/
@[simps]
def id (B : Type u₁) [Quiver.{v₁ + 1} B] [∀ a b : B, Quiver.{w₁ + 1} (a ⟶ b)] :
PrelaxFunctorStruct B B :=
{ Prefunctor.id B with map₂ := fun η => η }
instance : Inhabited (PrelaxFunctorStruct B B) :=
⟨PrelaxFunctorStruct.id B⟩
/-- Composition of lax prefunctors. -/
@[simps]
def comp (F : PrelaxFunctorStruct B C) (G : PrelaxFunctorStruct C D) : PrelaxFunctorStruct B D where
toPrefunctor := F.toPrefunctor.comp G.toPrefunctor
map₂ := fun η => G.map₂ (F.map₂ η)
end PrelaxFunctorStruct
end
/-- A prelax functor between bicategories is a lax prefunctor such that `map₂` is a functor.
This structure will be extended to define `LaxFunctor` and `OplaxFunctor`.
-/
structure PrelaxFunctor (B : Type u₁) [Bicategory.{w₁, v₁} B] (C : Type u₂) [Bicategory.{w₂, v₂} C]
extends PrelaxFunctorStruct B C where
/-- Prelax functors preserves identity 2-morphisms. -/
map₂_id : ∀ {a b : B} (f : a ⟶ b), map₂ (𝟙 f) = 𝟙 (map f) := by aesop -- TODO: why not aesop_cat?
/-- Prelax functors preserves compositions of 2-morphisms. -/
map₂_comp : ∀ {a b : B} {f g h : a ⟶ b} (η : f ⟶ g) (θ : g ⟶ h),
map₂ (η ≫ θ) = map₂ η ≫ map₂ θ := by aesop_cat
namespace PrelaxFunctor
initialize_simps_projections PrelaxFunctor (+toPrelaxFunctorStruct, -obj, -map, -map₂)
attribute [simp] map₂_id
attribute [reassoc] map₂_comp
attribute [simp] map₂_comp
/-- The underlying lax prefunctor. -/
add_decl_doc PrelaxFunctor.toPrelaxFunctorStruct
variable {B : Type u₁} [Bicategory.{w₁, v₁} B] {C : Type u₂} [Bicategory.{w₂, v₂} C]
variable {D : Type u₃} [Bicategory.{w₃, v₃} D]
/-- Construct a prelax functor from a map on objects, and functors between the corresponding
hom types. -/
@[simps]
def mkOfHomFunctors (F : B → C) (F' : (a : B) → (b : B) → (a ⟶ b) ⥤ (F a ⟶ F b)) :
PrelaxFunctor B C where
toPrelaxFunctorStruct := PrelaxFunctorStruct.mkOfHomPrefunctors F fun a b => (F' a b).toPrefunctor
map₂_id {a b} := (F' a b).map_id
map₂_comp {a b} := (F' a b).map_comp
/-- The identity prelax functor. -/
@[simps]
def id (B : Type u₁) [Bicategory.{w₁, v₁} B] : PrelaxFunctor B B where
toPrelaxFunctorStruct := PrelaxFunctorStruct.id B
instance : Inhabited (PrelaxFunctorStruct B B) :=
⟨PrelaxFunctorStruct.id B⟩
variable (F : PrelaxFunctor B C)
/-- Composition of prelax functors. -/
@[simps]
def comp (G : PrelaxFunctor C D) : PrelaxFunctor B D where
toPrelaxFunctorStruct := PrelaxFunctorStruct.comp F.toPrelaxFunctorStruct G.toPrelaxFunctorStruct
/-- Function between 1-morphisms as a functor. -/
@[simps]
def mapFunctor (a b : B) : (a ⟶ b) ⥤ (F.obj a ⟶ F.obj b) where
obj f := F.map f
map η := F.map₂ η
@[simp]
lemma mkOfHomFunctors_mapFunctor (F : B → C) (F' : (a : B) → (b : B) → (a ⟶ b) ⥤ (F a ⟶ F b))
(a b : B) : (mkOfHomFunctors F F').mapFunctor a b = F' a b :=
rfl
section
variable {a b : B}
/-- A prelaxfunctor `F` sends 2-isomorphisms `η : f ≅ f` to 2-isomorphisms `F.map f ≅ F.map g`. -/
@[simps!]
abbrev map₂Iso {f g : a ⟶ b} (η : f ≅ g) : F.map f ≅ F.map g :=
(F.mapFunctor a b).mapIso η
instance map₂_isIso {f g : a ⟶ b} (η : f ⟶ g) [IsIso η] : IsIso (F.map₂ η) :=
(F.map₂Iso (asIso η)).isIso_hom
@[simp]
lemma map₂_inv {f g : a ⟶ b} (η : f ⟶ g) [IsIso η] : F.map₂ (inv η) = inv (F.map₂ η) := by
apply IsIso.eq_inv_of_hom_inv_id
simp [← F.map₂_comp η (inv η)]
@[reassoc, simp]
lemma map₂_hom_inv {f g : a ⟶ b} (η : f ≅ g) :
F.map₂ η.hom ≫ F.map₂ η.inv = 𝟙 (F.map f) := by
rw [← F.map₂_comp, Iso.hom_inv_id, F.map₂_id]
@[reassoc]
lemma map₂_hom_inv_isIso {f g : a ⟶ b} (η : f ⟶ g) [IsIso η] :
F.map₂ η ≫ F.map₂ (inv η) = 𝟙 (F.map f) := by
simp
@[reassoc, simp]
lemma map₂_inv_hom {f g : a ⟶ b} (η : f ≅ g) :
F.map₂ η.inv ≫ F.map₂ η.hom = 𝟙 (F.map g) := by
rw [← F.map₂_comp, Iso.inv_hom_id, F.map₂_id]
@[reassoc]
lemma map₂_inv_hom_isIso {f g : a ⟶ b} (η : f ⟶ g) [IsIso η] :
F.map₂ (inv η) ≫ F.map₂ η = 𝟙 (F.map g) := by
simp
end
end PrelaxFunctor
end CategoryTheory
|
CategoryTheory\Bicategory\Functor\Pseudofunctor.lean | /-
Copyright (c) 2022 Yuma Mizuno. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yuma Mizuno, Calle Sönne
-/
import Mathlib.CategoryTheory.Bicategory.Functor.Oplax
import Mathlib.CategoryTheory.Bicategory.Functor.Lax
/-!
# Pseudofunctors
A pseudofunctor is an oplax (or lax) functor whose `mapId` and `mapComp` are isomorphisms.
We provide several constructors for pseudofunctors:
* `Pseudofunctor.mk` : the default constructor, which requires `map₂_whiskerLeft` and
`map₂_whiskerRight` instead of naturality of `mapComp`.
* `Pseudofunctor.mkOfOplax` : construct a pseudofunctor from an oplax functor whose
`mapId` and `mapComp` are isomorphisms. This constructor uses `Iso` to describe isomorphisms.
* `pseudofunctor.mkOfOplax'` : similar to `mkOfOplax`, but uses `IsIso` to describe isomorphisms.
* `Pseudofunctor.mkOfLax` : construct a pseudofunctor from a lax functor whose
`mapId` and `mapComp` are isomorphisms. This constructor uses `Iso` to describe isomorphisms.
* `pseudofunctor.mkOfLax'` : similar to `mkOfLax`, but uses `IsIso` to describe isomorphisms.
## Main definitions
* `CategoryTheory.Pseudofunctor B C` : a pseudofunctor between bicategories `B` and `C`
* `CategoryTheory.Pseudofunctor.comp F G` : the composition of pseudofunctors
-/
namespace CategoryTheory
open Category Bicategory
open Bicategory
universe w₁ w₂ w₃ v₁ v₂ v₃ u₁ u₂ u₃
variable {B : Type u₁} [Bicategory.{w₁, v₁} B] {C : Type u₂} [Bicategory.{w₂, v₂} C]
variable {D : Type u₃} [Bicategory.{w₃, v₃} D]
-- Porting note: this auxiliary def was introduced in Lean 3 and only used once, in this file,
-- to avoid a timeout. In Lean 4 the timeout isn't present and the definition causes other
-- things to break (simp proofs) so I removed it.
-- def Pseudofunctor.Map₂AssociatorAux (obj : B → C) (map : ∀ {X Y : B}, (X ⟶ Y) → (obj X ⟶ obj Y))
-- (map₂ : ∀ {a b : B} {f g : a ⟶ b}, (f ⟶ g) → (map f ⟶ map g))
-- (map_comp : ∀ {a b c : B} (f : a ⟶ b) (g : b ⟶ c), map (f ≫ g) ≅ map f ≫ map g) {a b c d : B}
-- (f : a ⟶ b) (g : b ⟶ c) (h : c ⟶ d) : Prop :=
-- map₂ (α_ f g h).hom =
-- (map_comp (f ≫ g) h).hom ≫
-- (map_comp f g).hom ▷ map h ≫
-- (α_ (map f) (map g) (map h)).hom ≫ map f ◁ (map_comp g h).inv ≫ (map_comp f (g ≫ h)).inv
/-- A pseudofunctor `F` between bicategories `B` and `C` consists of a function between objects
`F.obj`, a function between 1-morphisms `F.map`, and a function between 2-morphisms `F.map₂`.
Unlike functors between categories, `F.map` do not need to strictly commute with the compositions,
and do not need to strictly preserve the identity. Instead, there are specified 2-isomorphisms
`F.map (𝟙 a) ≅ 𝟙 (F.obj a)` and `F.map (f ≫ g) ≅ F.map f ≫ F.map g`.
`F.map₂` strictly commute with compositions and preserve the identity. They also preserve the
associator, the left unitor, and the right unitor modulo some adjustments of domains and codomains
of 2-morphisms.
-/
structure Pseudofunctor (B : Type u₁) [Bicategory.{w₁, v₁} B] (C : Type u₂)
[Bicategory.{w₂, v₂} C] extends PrelaxFunctor B C where
mapId (a : B) : map (𝟙 a) ≅ 𝟙 (obj a)
mapComp {a b c : B} (f : a ⟶ b) (g : b ⟶ c) : map (f ≫ g) ≅ map f ≫ map g
map₂_whisker_left :
∀ {a b c : B} (f : a ⟶ b) {g h : b ⟶ c} (η : g ⟶ h),
map₂ (f ◁ η) = (mapComp f g).hom ≫ map f ◁ map₂ η ≫ (mapComp f h).inv := by
aesop_cat
map₂_whisker_right :
∀ {a b c : B} {f g : a ⟶ b} (η : f ⟶ g) (h : b ⟶ c),
map₂ (η ▷ h) = (mapComp f h).hom ≫ map₂ η ▷ map h ≫ (mapComp g h).inv := by
aesop_cat
map₂_associator :
∀ {a b c d : B} (f : a ⟶ b) (g : b ⟶ c) (h : c ⟶ d),
map₂ (α_ f g h).hom = (mapComp (f ≫ g) h).hom ≫ (mapComp f g).hom ▷ map h ≫
(α_ (map f) (map g) (map h)).hom ≫ map f ◁ (mapComp g h).inv ≫
(mapComp f (g ≫ h)).inv := by
aesop_cat
map₂_left_unitor :
∀ {a b : B} (f : a ⟶ b),
map₂ (λ_ f).hom = (mapComp (𝟙 a) f).hom ≫ (mapId a).hom ▷ map f ≫ (λ_ (map f)).hom := by
aesop_cat
map₂_right_unitor :
∀ {a b : B} (f : a ⟶ b),
map₂ (ρ_ f).hom = (mapComp f (𝟙 b)).hom ≫ map f ◁ (mapId b).hom ≫ (ρ_ (map f)).hom := by
aesop_cat
initialize_simps_projections Pseudofunctor (+toPrelaxFunctor, -obj, -map, -map₂)
namespace Pseudofunctor
attribute [simp, reassoc]
map₂_whisker_left map₂_whisker_right map₂_associator map₂_left_unitor map₂_right_unitor
section
open Iso
/-- The underlying prelax functor. -/
add_decl_doc Pseudofunctor.toPrelaxFunctor
attribute [nolint docBlame] CategoryTheory.Pseudofunctor.mapId
CategoryTheory.Pseudofunctor.mapComp
CategoryTheory.Pseudofunctor.map₂_whisker_left
CategoryTheory.Pseudofunctor.map₂_whisker_right
CategoryTheory.Pseudofunctor.map₂_associator
CategoryTheory.Pseudofunctor.map₂_left_unitor
CategoryTheory.Pseudofunctor.map₂_right_unitor
variable (F : Pseudofunctor B C)
/-- The oplax functor associated with a pseudofunctor. -/
@[simps]
def toOplax : OplaxFunctor B C where
toPrelaxFunctor := F.toPrelaxFunctor
mapId := fun a => (F.mapId a).hom
mapComp := fun f g => (F.mapComp f g).hom
instance hasCoeToOplax : Coe (Pseudofunctor B C) (OplaxFunctor B C) :=
⟨toOplax⟩
/-- The Lax functor associated with a pseudofunctor. -/
@[simps]
def toLax : LaxFunctor B C where
toPrelaxFunctor := F.toPrelaxFunctor
mapId := fun a => (F.mapId a).inv
mapComp := fun f g => (F.mapComp f g).inv
map₂_leftUnitor f := by
rw [← F.map₂Iso_inv, eq_inv_comp, comp_inv_eq]
simp
map₂_rightUnitor f := by
rw [← F.map₂Iso_inv, eq_inv_comp, comp_inv_eq]
simp
instance hasCoeToLax : Coe (Pseudofunctor B C) (LaxFunctor B C) :=
⟨toLax⟩
/-- The identity pseudofunctor. -/
@[simps]
def id (B : Type u₁) [Bicategory.{w₁, v₁} B] : Pseudofunctor B B where
toPrelaxFunctor := PrelaxFunctor.id B
mapId := fun a => Iso.refl (𝟙 a)
mapComp := fun f g => Iso.refl (f ≫ g)
instance : Inhabited (Pseudofunctor B B) :=
⟨id B⟩
/-- Composition of pseudofunctors. -/
@[simps]
def comp (F : Pseudofunctor B C) (G : Pseudofunctor C D) : Pseudofunctor B D where
toPrelaxFunctor := F.toPrelaxFunctor.comp G.toPrelaxFunctor
mapId := fun a => G.map₂Iso (F.mapId a) ≪≫ G.mapId (F.obj a)
mapComp := fun f g => (G.map₂Iso (F.mapComp f g)) ≪≫ G.mapComp (F.map f) (F.map g)
-- Note: whilst these are all provable by `aesop_cat`, the proof is very slow
map₂_whisker_left f η := by dsimp; simp
map₂_whisker_right η h := by dsimp; simp
map₂_associator f g h := by dsimp; simp
map₂_left_unitor f := by dsimp; simp
map₂_right_unitor f := by dsimp; simp
section
variable (F : Pseudofunctor B C) {a b : B}
@[reassoc]
lemma mapComp_assoc_right_hom {c d : B} (f : a ⟶ b) (g : b ⟶ c) (h : c ⟶ d) :
(F.mapComp f (g ≫ h)).hom ≫ F.map f ◁ (F.mapComp g h).hom = F.map₂ (α_ f g h).inv ≫
(F.mapComp (f ≫ g) h).hom ≫ (F.mapComp f g).hom ▷ F.map h ≫
(α_ (F.map f) (F.map g) (F.map h)).hom :=
F.toOplax.mapComp_assoc_right _ _ _
@[reassoc]
lemma mapComp_assoc_left_hom {c d : B} (f : a ⟶ b) (g : b ⟶ c) (h : c ⟶ d) :
(F.mapComp (f ≫ g) h).hom ≫ (F.mapComp f g).hom ▷ F.map h =
F.map₂ (α_ f g h).hom ≫ (F.mapComp f (g ≫ h)).hom ≫ F.map f ◁ (F.mapComp g h).hom
≫ (α_ (F.map f) (F.map g) (F.map h)).inv :=
F.toOplax.mapComp_assoc_left _ _ _
@[reassoc]
lemma mapComp_assoc_right_inv {c d : B} (f : a ⟶ b) (g : b ⟶ c) (h : c ⟶ d) :
F.map f ◁ (F.mapComp g h).inv ≫ (F.mapComp f (g ≫ h)).inv =
(α_ (F.map f) (F.map g) (F.map h)).inv ≫ (F.mapComp f g).inv ▷ F.map h ≫
(F.mapComp (f ≫ g) h).inv ≫ F.map₂ (α_ f g h).hom :=
F.toLax.mapComp_assoc_right _ _ _
@[reassoc]
lemma mapComp_assoc_left_inv {c d : B} (f : a ⟶ b) (g : b ⟶ c) (h : c ⟶ d) :
(F.mapComp f g).inv ▷ F.map h ≫ (F.mapComp (f ≫ g) h).inv =
(α_ (F.map f) (F.map g) (F.map h)).hom ≫ F.map f ◁ (F.mapComp g h).inv ≫
(F.mapComp f (g ≫ h)).inv ≫ F.map₂ (α_ f g h).inv :=
F.toLax.mapComp_assoc_left _ _ _
@[reassoc]
lemma mapComp_id_left_hom (f : a ⟶ b) : (F.mapComp (𝟙 a) f).hom =
F.map₂ (λ_ f).hom ≫ (λ_ (F.map f)).inv ≫ (F.mapId a).inv ▷ F.map f := by
simp
lemma mapComp_id_left (f : a ⟶ b) : (F.mapComp (𝟙 a) f) = F.map₂Iso (λ_ f) ≪≫
(λ_ (F.map f)).symm ≪≫ (whiskerRightIso (F.mapId a) (F.map f)).symm :=
Iso.ext <| F.mapComp_id_left_hom f
@[reassoc]
lemma mapComp_id_left_inv (f : a ⟶ b) : (F.mapComp (𝟙 a) f).inv =
(F.mapId a).hom ▷ F.map f ≫ (λ_ (F.map f)).hom ≫ F.map₂ (λ_ f).inv := by
simp [mapComp_id_left]
lemma whiskerRightIso_mapId (f : a ⟶ b) : whiskerRightIso (F.mapId a) (F.map f) =
(F.mapComp (𝟙 a) f).symm ≪≫ F.map₂Iso (λ_ f) ≪≫ (λ_ (F.map f)).symm := by
simp [mapComp_id_left]
@[reassoc]
lemma whiskerRight_mapId_hom (f : a ⟶ b) : (F.mapId a).hom ▷ F.map f =
(F.mapComp (𝟙 a) f).inv ≫ F.map₂ (λ_ f).hom ≫ (λ_ (F.map f)).inv := by
simp [whiskerRightIso_mapId]
@[reassoc]
lemma whiskerRight_mapId_inv (f : a ⟶ b) : (F.mapId a).inv ▷ F.map f =
(λ_ (F.map f)).hom ≫ F.map₂ (λ_ f).inv ≫ (F.mapComp (𝟙 a) f).hom := by
simpa using congrArg (·.inv) (F.whiskerRightIso_mapId f)
@[reassoc]
lemma mapComp_id_right_hom (f : a ⟶ b) : (F.mapComp f (𝟙 b)).hom =
F.map₂ (ρ_ f).hom ≫ (ρ_ (F.map f)).inv ≫ F.map f ◁ (F.mapId b).inv := by
simp
lemma mapComp_id_right (f : a ⟶ b) : (F.mapComp f (𝟙 b)) = F.map₂Iso (ρ_ f) ≪≫
(ρ_ (F.map f)).symm ≪≫ (whiskerLeftIso (F.map f) (F.mapId b)).symm :=
Iso.ext <| F.mapComp_id_right_hom f
@[reassoc]
lemma mapComp_id_right_inv (f : a ⟶ b) : (F.mapComp f (𝟙 b)).inv =
F.map f ◁ (F.mapId b).hom ≫ (ρ_ (F.map f)).hom ≫ F.map₂ (ρ_ f).inv := by
simp [mapComp_id_right]
lemma whiskerLeftIso_mapId (f : a ⟶ b) : whiskerLeftIso (F.map f) (F.mapId b) =
(F.mapComp f (𝟙 b)).symm ≪≫ F.map₂Iso (ρ_ f) ≪≫ (ρ_ (F.map f)).symm := by
simp [mapComp_id_right]
@[reassoc]
lemma whiskerLeft_mapId_hom (f : a ⟶ b) : F.map f ◁ (F.mapId b).hom =
(F.mapComp f (𝟙 b)).inv ≫ F.map₂ (ρ_ f).hom ≫ (ρ_ (F.map f)).inv := by
simp [whiskerLeftIso_mapId]
@[reassoc]
lemma whiskerLeft_mapId_inv (f : a ⟶ b) : F.map f ◁ (F.mapId b).inv =
(ρ_ (F.map f)).hom ≫ F.map₂ (ρ_ f).inv ≫ (F.mapComp f (𝟙 b)).hom := by
simpa using congrArg (·.inv) (F.whiskerLeftIso_mapId f)
end
/-- Construct a pseudofunctor from an oplax functor whose `mapId` and `mapComp` are isomorphisms. -/
@[simps]
def mkOfOplax (F : OplaxFunctor B C) (F' : F.PseudoCore) : Pseudofunctor B C where
toPrelaxFunctor := F.toPrelaxFunctor
mapId := F'.mapIdIso
mapComp := F'.mapCompIso
map₂_whisker_left := fun f g h η => by
dsimp
rw [F'.mapCompIso_hom f g, ← F.mapComp_naturality_right_assoc, ← F'.mapCompIso_hom f h,
hom_inv_id, comp_id]
map₂_whisker_right := fun η h => by
dsimp
rw [F'.mapCompIso_hom _ h, ← F.mapComp_naturality_left_assoc, ← F'.mapCompIso_hom _ h,
hom_inv_id, comp_id]
map₂_associator := fun f g h => by
dsimp
rw [F'.mapCompIso_hom (f ≫ g) h, F'.mapCompIso_hom f g, ← F.map₂_associator_assoc, ←
F'.mapCompIso_hom f (g ≫ h), ← F'.mapCompIso_hom g h, whiskerLeft_hom_inv_assoc,
hom_inv_id, comp_id]
/-- Construct a pseudofunctor from an oplax functor whose `mapId` and `mapComp` are isomorphisms. -/
@[simps!]
noncomputable def mkOfOplax' (F : OplaxFunctor B C) [∀ a, IsIso (F.mapId a)]
[∀ {a b c} (f : a ⟶ b) (g : b ⟶ c), IsIso (F.mapComp f g)] : Pseudofunctor B C where
toPrelaxFunctor := F.toPrelaxFunctor
mapId := fun a => asIso (F.mapId a)
mapComp := fun f g => asIso (F.mapComp f g)
map₂_whisker_left := fun f g h η => by
dsimp
rw [← assoc, IsIso.eq_comp_inv, F.mapComp_naturality_right]
map₂_whisker_right := fun η h => by
dsimp
rw [← assoc, IsIso.eq_comp_inv, F.mapComp_naturality_left]
map₂_associator := fun f g h => by
dsimp
simp only [← assoc]
rw [IsIso.eq_comp_inv, ← inv_whiskerLeft, IsIso.eq_comp_inv]
simp only [assoc, F.map₂_associator]
/-- Construct a pseudofunctor from a lax functor whose `mapId` and `mapComp` are isomorphisms. -/
@[simps]
def mkOfLax (F : LaxFunctor B C) (F' : F.PseudoCore) : Pseudofunctor B C where
toPrelaxFunctor := F.toPrelaxFunctor
mapId := F'.mapIdIso
mapComp := F'.mapCompIso
map₂_whisker_left f g h η := by
rw [F'.mapCompIso_inv, ← LaxFunctor.mapComp_naturality_right, ← F'.mapCompIso_inv,
hom_inv_id_assoc]
map₂_whisker_right η h := by
rw [F'.mapCompIso_inv, ← LaxFunctor.mapComp_naturality_left, ← F'.mapCompIso_inv,
hom_inv_id_assoc]
map₂_associator {a b c d} f g h := by
rw [F'.mapCompIso_inv, F'.mapCompIso_inv, ← inv_comp_eq, ← IsIso.inv_comp_eq]
simp
map₂_left_unitor {a b} f := by rw [← IsIso.inv_eq_inv, ← F.map₂_inv]; simp
map₂_right_unitor {a b} f := by rw [← IsIso.inv_eq_inv, ← F.map₂_inv]; simp
/-- Construct a pseudofunctor from a lax functor whose `mapId` and `mapComp` are isomorphisms. -/
@[simps!]
noncomputable def mkOfLax' (F : LaxFunctor B C) [∀ a, IsIso (F.mapId a)]
[∀ {a b c} (f : a ⟶ b) (g : b ⟶ c), IsIso (F.mapComp f g)] : Pseudofunctor B C :=
mkOfLax F
{ mapIdIso := fun a => (asIso (F.mapId a)).symm
mapCompIso := fun f g => (asIso (F.mapComp f g)).symm }
end
end Pseudofunctor
end CategoryTheory
|
CategoryTheory\Bicategory\Kan\Adjunction.lean | /-
Copyright (c) 2024 Yuma Mizuno. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yuma Mizuno
-/
import Mathlib.CategoryTheory.Bicategory.Kan.HasKan
import Mathlib.CategoryTheory.Bicategory.Adjunction
import Mathlib.Tactic.TFAE
/-!
# Adjunctions as Kan extensions
We show that adjunctions are realized as Kan extensions or Kan lifts.
We also show that a left adjoint commutes with a left Kan extension. Under the assumption that
`IsLeftAdjoint h`, the isomorphism `f⁺ (g ≫ h) ≅ f⁺ g ≫ h` can be accessed by
`Lan.CommuteWith.lanCompIso f g h`.
## References
* [Riehl, *Category theory in context*, Proposition 6.5.2][riehl2017]
## TODO
At the moment, the results are stated for left Kan extensions and left Kan lifts. We can prove the
similar results for right Kan extensions and right Kan lifts.
-/
namespace CategoryTheory
open Mathlib.Tactic.BicategoryCoherence bicategoricalComp
namespace Bicategory
universe w v u
variable {B : Type u} [Bicategory.{w, v} B] {a b c : B}
section LeftExtension
open LeftExtension
/-- For an adjuntion `f ⊣ u`, `u` is an absolute left Kan extension of the identity along `f`.
The unit of this Kan extension is given by the unit of the adjunction. -/
def Adjunction.isAbsoluteLeftKan {f : a ⟶ b} {u : b ⟶ a} (adj : f ⊣ u) :
IsAbsKan (.mk u adj.unit) := fun {x} h ↦
.mk (fun s ↦ LeftExtension.homMk
(𝟙 _ ⊗≫ u ◁ s.unit ⊗≫ adj.counit ▷ s.extension ⊗≫ 𝟙 _ : u ≫ h ⟶ s.extension) <|
calc _
_ = 𝟙 _ ⊗≫ (adj.unit ▷ _ ≫ _ ◁ s.unit) ⊗≫ f ◁ adj.counit ▷ s.extension ⊗≫ 𝟙 _ := by
simp [bicategoricalComp]
_ = 𝟙 _ ⊗≫ s.unit ⊗≫ leftZigzag adj.unit adj.counit ▷ s.extension ⊗≫ 𝟙 _ := by
rw [← whisker_exchange, leftZigzag]; simp [bicategoricalComp]
_ = s.unit := by
rw [adj.left_triangle]; simp [bicategoricalComp]) <| by
intro s τ₀
ext
/- We need to specify the type of `τ` to use the notation `⊗≫`. -/
let τ : u ≫ h ⟶ s.extension := τ₀.right
have hτ : adj.unit ▷ h ⊗≫ f ◁ τ = s.unit := by
simpa [bicategoricalComp] using LeftExtension.w τ₀
calc τ
_ = 𝟙 _ ⊗≫ rightZigzag adj.unit adj.counit ▷ h ⊗≫ τ ⊗≫ 𝟙 _ := by
rw [adj.right_triangle]; simp [bicategoricalComp]
_ = 𝟙 _ ⊗≫ u ◁ adj.unit ▷ h ⊗≫ (adj.counit ▷ _ ≫ _ ◁ τ) ⊗≫ 𝟙 _ := by
rw [rightZigzag]; simp [bicategoricalComp]
_ = 𝟙 _ ⊗≫ u ◁ (adj.unit ▷ h ⊗≫ f ◁ τ) ⊗≫ adj.counit ▷ s.extension ⊗≫ 𝟙 _ := by
rw [← whisker_exchange]; simp [bicategoricalComp]
_ = _ := by
rw [hτ]; simp [bicategoricalComp]
/-- A left Kan extension of the identity along `f` such that `f` commutes with is a right adjoint
to `f`. The unit of this adjoint is given by the unit of the Kan extension. -/
def LeftExtension.IsKan.adjunction {f : a ⟶ b} {t : LeftExtension f (𝟙 a)}
(H : IsKan t) (H' : IsKan (t.whisker f)) :
f ⊣ t.extension :=
let ε : t.extension ≫ f ⟶ 𝟙 b := H'.desc <| .mk _ <| (λ_ f).hom ≫ (ρ_ f).inv
have Hε : leftZigzag t.unit ε = (λ_ f).hom ≫ (ρ_ f).inv := by
simpa [leftZigzag, bicategoricalComp] using H'.fac <| .mk _ <| (λ_ f).hom ≫ (ρ_ f).inv
{ unit := t.unit
counit := ε
left_triangle := Hε
right_triangle := by
apply (cancel_epi (ρ_ _).inv).mp
apply H.hom_ext
calc _
_ = 𝟙 _ ⊗≫ t.unit ⊗≫ f ◁ rightZigzag t.unit ε ⊗≫ 𝟙 _ := by
simp [bicategoricalComp]
_ = 𝟙 _ ⊗≫ (t.unit ▷ _ ≫ _ ◁ t.unit) ⊗≫ f ◁ ε ▷ t.extension ⊗≫ 𝟙 _ := by
rw [rightZigzag]; simp [bicategoricalComp]
_ = 𝟙 _ ⊗≫ t.unit ⊗≫ (t.unit ▷ f ⊗≫ f ◁ ε) ▷ t.extension ⊗≫ 𝟙 _ := by
rw [← whisker_exchange]; simp [bicategoricalComp]
_ = _ := by
rw [← leftZigzag, Hε]; simp [bicategoricalComp] }
/-- For an adjuntion `f ⊣ u`, `u` is a left Kan extension of the identity along `f`.
The unit of this Kan extension is given by the unit of the adjunction. -/
def LeftExtension.IsAbsKan.adjunction {f : a ⟶ b} (t : LeftExtension f (𝟙 a)) (H : IsAbsKan t) :
f ⊣ t.extension :=
H.isKan.adjunction (H f)
theorem isLeftAdjoint_TFAE (f : a ⟶ b) :
List.TFAE [
IsLeftAdjoint f,
HasAbsLeftKanExtension f (𝟙 a),
∃ _ : HasLeftKanExtension f (𝟙 a), Lan.CommuteWith f (𝟙 a) f] := by
tfae_have 1 → 2
· intro h
exact IsAbsKan.hasAbsLeftKanExtension (Adjunction.ofIsLeftAdjoint f).isAbsoluteLeftKan
tfae_have 2 → 3
· intro h
exact ⟨inferInstance, inferInstance⟩
tfae_have 3 → 1
· intro ⟨h, h'⟩
exact .mk <| (lanIsKan f (𝟙 a)).adjunction <| Lan.CommuteWith.isKan f (𝟙 a) f
tfae_finish
end LeftExtension
section LeftLift
open LeftLift
/-- For an adjuntion `f ⊣ u`, `f` is an absolute left Kan lift of the identity along `u`.
The unit of this Kan lift is given by the unit of the adjunction. -/
def Adjunction.isAbsoluteLeftKanLift {f : a ⟶ b} {u : b ⟶ a} (adj : f ⊣ u) :
IsAbsKan (.mk f adj.unit) := fun {x} h ↦
.mk (fun s ↦ LeftLift.homMk
(𝟙 _ ⊗≫ s.unit ▷ f ⊗≫ s.lift ◁ adj.counit ⊗≫ 𝟙 _ : h ≫ f ⟶ s.lift) <|
calc _
_ = 𝟙 _ ⊗≫ (_ ◁ adj.unit ≫ s.unit ▷ _) ⊗≫ s.lift ◁ adj.counit ▷ u ⊗≫ 𝟙 _ := by
simp [bicategoricalComp]
_ = s.unit ⊗≫ s.lift ◁ (rightZigzag adj.unit adj.counit) ⊗≫ 𝟙 _ := by
rw [whisker_exchange, rightZigzag]; simp [bicategoricalComp]
_ = s.unit := by
rw [adj.right_triangle]; simp [bicategoricalComp]) <| by
intro s τ₀
ext
/- We need to specify the type of `τ` to use the notation `⊗≫`. -/
let τ : h ≫ f ⟶ s.lift := τ₀.right
have hτ : h ◁ adj.unit ⊗≫ τ ▷ u = s.unit := by simpa [bicategoricalComp] using LeftLift.w τ₀
calc τ
_ = 𝟙 _ ⊗≫ h ◁ leftZigzag adj.unit adj.counit ⊗≫ τ ⊗≫ 𝟙 _ := by
rw [adj.left_triangle]; simp [bicategoricalComp]
_ = 𝟙 _ ⊗≫ h ◁ adj.unit ▷ f ⊗≫ (_ ◁ adj.counit ≫ τ ▷ _) ⊗≫ 𝟙 _ := by
rw [leftZigzag]; simp [bicategoricalComp]
_ = 𝟙 _ ⊗≫ (h ◁ adj.unit ⊗≫ τ ▷ u) ▷ f ⊗≫ s.lift ◁ adj.counit ⊗≫ 𝟙 _ := by
rw [whisker_exchange]; simp [bicategoricalComp]
_ = _ := by
rw [hτ]; simp [bicategoricalComp]
/-- A left Kan lift of the identity along `u` such that `u` commutes with is a left adjoint
to `u`. The unit of this adjoint is given by the unit of the Kan lift. -/
def LeftLift.IsKan.adjunction {u : b ⟶ a} {t : LeftLift u (𝟙 a)}
(H : IsKan t) (H' : IsKan (t.whisker u)) :
t.lift ⊣ u :=
let ε : u ≫ t.lift ⟶ 𝟙 b := H'.desc <| .mk _ <| (ρ_ u).hom ≫ (λ_ u).inv
have Hε : rightZigzag t.unit ε = (ρ_ u).hom ≫ (λ_ u).inv := by
simpa [rightZigzag, bicategoricalComp] using H'.fac <| .mk _ <| (ρ_ u).hom ≫ (λ_ u).inv
{ unit := t.unit
counit := ε
left_triangle := by
apply (cancel_epi (λ_ _).inv).mp
apply H.hom_ext
calc _
_ = 𝟙 _ ⊗≫ t.unit ⊗≫ leftZigzag t.unit ε ▷ u ⊗≫ 𝟙 _ := by
simp [bicategoricalComp]
_ = 𝟙 _ ⊗≫ (_ ◁ t.unit ≫ t.unit ▷ _) ⊗≫ t.lift ◁ ε ▷ u ⊗≫ 𝟙 _ := by
rw [leftZigzag]; simp [bicategoricalComp]
_ = 𝟙 _ ⊗≫ t.unit ⊗≫ t.lift ◁ (u ◁ t.unit ⊗≫ ε ▷ u) ⊗≫ 𝟙 _ := by
rw [whisker_exchange]; simp [bicategoricalComp]
_ = _ := by
rw [← rightZigzag, Hε]; simp [bicategoricalComp]
right_triangle := Hε }
/-- For an adjuntion `f ⊣ u`, `f` is a left Kan lift of the identity along `u`.
The unit of this Kan lift is given by the unit of the adjunction. -/
def LeftLift.IsAbsKan.adjunction {u : b ⟶ a} (t : LeftLift u (𝟙 a)) (H : IsAbsKan t) :
t.lift ⊣ u :=
H.isKan.adjunction (H u)
theorem isRightAdjoint_TFAE (u : b ⟶ a) :
List.TFAE [
IsRightAdjoint u,
HasAbsLeftKanLift u (𝟙 a),
∃ _ : HasLeftKanLift u (𝟙 a), LanLift.CommuteWith u (𝟙 a) u] := by
tfae_have 1 → 2
· intro h
exact IsAbsKan.hasAbsLeftKanLift (Adjunction.ofIsRightAdjoint u).isAbsoluteLeftKanLift
tfae_have 2 → 3
· intro h
exact ⟨inferInstance, inferInstance⟩
tfae_have 3 → 1
· intro ⟨h, h'⟩
exact .mk <| (lanLiftIsKan u (𝟙 a)).adjunction <| LanLift.CommuteWith.isKan u (𝟙 a) u
tfae_finish
end LeftLift
namespace LeftExtension
/-- A left adjoint commutes with a left Kan extension. -/
def isKanOfWhiskerLeftAdjoint
{f : a ⟶ b} {g : a ⟶ c} {t : LeftExtension f g} (H : LeftExtension.IsKan t)
{x : B} {h : c ⟶ x} {u : x ⟶ c} (adj : h ⊣ u) :
LeftExtension.IsKan (t.whisker h) :=
let η' := adj.unit
let H' : LeftLift.IsAbsKan (.mk _ η') := adj.isAbsoluteLeftKanLift
.mk (fun s ↦
let k := s.extension
let θ := s.unit
let τ : t.extension ⟶ k ≫ u := H.desc (.mk _ <| 𝟙 _ ⊗≫ g ◁ η' ⊗≫ θ ▷ u ⊗≫ 𝟙 _)
let σ : t.extension ≫ h ⟶ k := H'.desc <| (.mk _ <| (ρ_ _).hom ≫ τ)
LeftExtension.homMk σ <| (H' g).hom_ext <| by
have Hσ : t.extension ◁ η' ⊗≫ σ ▷ u = 𝟙 _ ⊗≫ τ := by
simpa [bicategoricalComp] using (H' _).fac (.mk _ <| (ρ_ _).hom ≫ τ)
calc _
_ = 𝟙 _ ⊗≫ (g ◁ η' ≫ t.unit ▷ (h ≫ u)) ⊗≫ f ◁ σ ▷ u ⊗≫ 𝟙 _ := by
simp [bicategoricalComp]
_ = 𝟙 _ ⊗≫ t.unit ▷ (𝟙 c) ⊗≫ f ◁ (t.extension ◁ η' ⊗≫ σ ▷ u) ⊗≫ 𝟙 _ := by
rw [whisker_exchange]; simp [bicategoricalComp]
_ = _ := by
rw [Hσ]; simp [τ, bicategoricalComp]) <| by
intro s' τ₀'
let τ' : t.extension ≫ h ⟶ s'.extension := τ₀'.right
have Hτ' : t.unit ▷ h ⊗≫ f ◁ τ' = s'.unit := by simpa [bicategoricalComp] using τ₀'.w.symm
ext
apply (H' _).hom_ext
dsimp only [StructuredArrow.homMk_right]
rw [(H' _).fac]
apply (cancel_epi (ρ_ _).inv).mp
apply H.hom_ext
calc _
_ = 𝟙 _ ⊗≫ (t.unit ▷ (𝟙 c) ≫ (f ≫ t.extension) ◁ η') ⊗≫ f ◁ τ' ▷ u := by
simp [bicategoricalComp]
_ = 𝟙 g ⊗≫ g ◁ η' ⊗≫ (t.unit ▷ h ⊗≫ f ◁ τ') ▷ u ⊗≫ 𝟙 _ := by
rw [← whisker_exchange]; simp [bicategoricalComp]
_ = _ := by
rw [Hτ']; simp [bicategoricalComp]
instance {f : a ⟶ b} {g : a ⟶ c} {x : B} {h : c ⟶ x} [IsLeftAdjoint h] [HasLeftKanExtension f g] :
Lan.CommuteWith f g h :=
⟨⟨isKanOfWhiskerLeftAdjoint (lanIsKan f g) (Adjunction.ofIsLeftAdjoint h)⟩⟩
end LeftExtension
end Bicategory
end CategoryTheory
|
CategoryTheory\Bicategory\Kan\HasKan.lean | /-
Copyright (c) 2024 Yuma Mizuno. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yuma Mizuno
-/
import Mathlib.CategoryTheory.Bicategory.Kan.IsKan
/-!
# Existence of Kan extensions and Kan lifts in bicategories
We provide the propositional typeclass `HasLeftKanExtension f g`, which asserts that there
exists a left Kan extension of `g` along `f`. See `CategoryTheory.Bicategory.Kan.IsKan` for
the definition of left Kan extensions. Under the assumption that `HasLeftKanExtension f g`,
we define the left Kan extension `lan f g` by using the axiom of choice.
## Main definitions
* `lan f g` is the left Kan extension of `g` along `f`, and is denoted by `f⁺ g`.
* `lanLift f g` is the left Kan lift of `g` along `f`, and is denoted by `f₊ g`.
These notations are inspired by
[M. Kashiwara, P. Schapira, *Categories and Sheaves*][Kashiwara2006].
## TODO
* `ran f g` is the right Kan extension of `g` along `f`, and is denoted by `f⁺⁺ g`.
* `ranLift f g` is the right Kan lift of `g` along `f`, and is denoted by `f₊₊ g`.
-/
noncomputable section
namespace CategoryTheory
namespace Bicategory
universe w v u
variable {B : Type u} [Bicategory.{w, v} B] {a b c : B}
open Limits
section LeftKan
open LeftExtension
variable {f : a ⟶ b} {g : a ⟶ c}
/-- The existence of a left Kan extension of `g` along `f`. -/
class HasLeftKanExtension (f : a ⟶ b) (g : a ⟶ c) : Prop where
hasInitial : HasInitial <| LeftExtension f g
theorem LeftExtension.IsKan.hasLeftKanExtension {t : LeftExtension f g} (H : IsKan t) :
HasLeftKanExtension f g :=
⟨IsInitial.hasInitial H⟩
instance [HasLeftKanExtension f g] : HasInitial <| LeftExtension f g :=
HasLeftKanExtension.hasInitial
/-- The left Kan extension of `g` along `f` at the level of structured arrows. -/
def lanLeftExtension (f : a ⟶ b) (g : a ⟶ c) [HasLeftKanExtension f g] : LeftExtension f g :=
⊥_ (LeftExtension f g)
/-- The left Kan extension of `g` along `f`. -/
def lan (f : a ⟶ b) (g : a ⟶ c) [HasLeftKanExtension f g] : b ⟶ c :=
(lanLeftExtension f g).extension
/-- `f⁺ g` is the left Kan extension of `g` along `f`.
```
b
△ \
| \ f⁺ g
f | \
| ◿
a - - - ▷ c
g
```
-/
scoped infixr:90 "⁺ " => lan
@[simp]
theorem lanLeftExtension_extension (f : a ⟶ b) (g : a ⟶ c) [HasLeftKanExtension f g] :
(lanLeftExtension f g).extension = f⁺ g := rfl
/-- The unit for the left Kan extension `f⁺ g`. -/
def lanUnit (f : a ⟶ b) (g : a ⟶ c) [HasLeftKanExtension f g] : g ⟶ f ≫ f⁺ g :=
(lanLeftExtension f g).unit
@[simp]
theorem lanLeftExtension_unit (f : a ⟶ b) (g : a ⟶ c) [HasLeftKanExtension f g] :
(lanLeftExtension f g).unit = lanUnit f g := rfl
/-- Evidence that the `Lan.extension f g` is a Kan extension. -/
def lanIsKan (f : a ⟶ b) (g : a ⟶ c) [HasLeftKanExtension f g] : (lanLeftExtension f g).IsKan :=
initialIsInitial
variable {f : a ⟶ b} {g : a ⟶ c}
/-- The family of 2-morphisms out of the left Kan extension `f⁺ g`. -/
def lanDesc [HasLeftKanExtension f g] (s : LeftExtension f g) :
f⁺ g ⟶ s.extension :=
(lanIsKan f g).desc s
@[reassoc (attr := simp)]
theorem lanUnit_desc [HasLeftKanExtension f g] (s : LeftExtension f g) :
lanUnit f g ≫ f ◁ lanDesc s = s.unit :=
(lanIsKan f g).fac s
@[simp]
theorem lanIsKan_desc [HasLeftKanExtension f g] (s : LeftExtension f g) :
(lanIsKan f g).desc s = lanDesc s :=
rfl
theorem Lan.existsUnique [HasLeftKanExtension f g] (s : LeftExtension f g) :
∃! τ, lanUnit f g ≫ f ◁ τ = s.unit :=
(lanIsKan f g).existsUnique _
/-- We say that a 1-morphism `h` commutes with the left Kan extension `f⁺ g` if the whiskered
left extension for `f⁺ g` by `h` is a Kan extension of `g ≫ h` along `f`. -/
class Lan.CommuteWith
(f : a ⟶ b) (g : a ⟶ c) [HasLeftKanExtension f g] {x : B} (h : c ⟶ x) : Prop where
commute : Nonempty <| IsKan <| (lanLeftExtension f g).whisker h
namespace Lan.CommuteWith
theorem of_isKan_whisker [HasLeftKanExtension f g] (t : LeftExtension f g) {x : B} (h : c ⟶ x)
(H : IsKan (t.whisker h)) (i : t.whisker h ≅ (lanLeftExtension f g).whisker h) :
Lan.CommuteWith f g h :=
⟨⟨IsKan.ofIsoKan H i⟩⟩
theorem of_lan_comp_iso [HasLeftKanExtension f g]
{x : B} {h : c ⟶ x} [HasLeftKanExtension f (g ≫ h)]
(i : f⁺ (g ≫ h) ≅ f⁺ g ≫ h)
(w : lanUnit f (g ≫ h) ≫ f ◁ i.hom = lanUnit f g ▷ h ≫ (α_ _ _ _).hom) :
Lan.CommuteWith f g h :=
⟨⟨(lanIsKan f (g ≫ h)).ofIsoKan <| StructuredArrow.isoMk i⟩⟩
variable (f : a ⟶ b) (g : a ⟶ c) [HasLeftKanExtension f g]
variable {x : B} (h : c ⟶ x) [Lan.CommuteWith f g h]
/-- Evidence that `h` commutes with the left Kan extension `f⁺ g`. -/
def isKan : IsKan <| (lanLeftExtension f g).whisker h := Classical.choice Lan.CommuteWith.commute
instance : HasLeftKanExtension f (g ≫ h) := (Lan.CommuteWith.isKan f g h).hasLeftKanExtension
/-- If `h` commutes with `f⁺ g` and `t` is another left Kan extension of `g` along `f`, then
`t.whisker h` is a left Kan extension of `g ≫ h` along `f`. -/
def isKanWhisker
(t : LeftExtension f g) (H : IsKan t) {x : B} (h : c ⟶ x) [Lan.CommuteWith f g h] :
IsKan (t.whisker h) :=
IsKan.whiskerOfCommute (lanLeftExtension f g) t (IsKan.uniqueUpToIso (lanIsKan f g) H) h
(isKan f g h)
/-- The isomorphism `f⁺ (g ≫ h) ≅ f⁺ g ≫ h` at the level of structured arrows. -/
def lanCompIsoWhisker : lanLeftExtension f (g ≫ h) ≅ (lanLeftExtension f g).whisker h :=
IsKan.uniqueUpToIso (lanIsKan f (g ≫ h)) (Lan.CommuteWith.isKan f g h)
@[simp]
theorem lanCompIsoWhisker_hom_right :
(lanCompIsoWhisker f g h).hom.right = lanDesc ((lanLeftExtension f g).whisker h) :=
rfl
@[simp]
theorem lanCompIsoWhisker_inv_right :
(lanCompIsoWhisker f g h).inv.right = (isKan f g h).desc (lanLeftExtension f (g ≫ h)) :=
rfl
/-- The 1-morphism `h` commutes with the left Kan extension `f⁺ g`. -/
@[simps!]
def lanCompIso : f⁺ (g ≫ h) ≅ f⁺ g ≫ h := Comma.rightIso <| lanCompIsoWhisker f g h
end Lan.CommuteWith
/-- We say that there exists an absolute left Kan extension of `g` along `f` if any 1-morphism `h`
commutes with the left Kan extension `f⁺ g`. -/
class HasAbsLeftKanExtension (f : a ⟶ b) (g : a ⟶ c) extends HasLeftKanExtension f g : Prop where
commute {x : B} (h : c ⟶ x) : Lan.CommuteWith f g h
instance [HasAbsLeftKanExtension f g] {x : B} (h : c ⟶ x) : Lan.CommuteWith f g h :=
HasAbsLeftKanExtension.commute h
theorem LeftExtension.IsAbsKan.hasAbsLeftKanExtension {t : LeftExtension f g} (H : IsAbsKan t) :
HasAbsLeftKanExtension f g :=
have : HasLeftKanExtension f g := H.isKan.hasLeftKanExtension
⟨fun h ↦ ⟨⟨H.ofIsoAbsKan (IsKan.uniqueUpToIso H.isKan (lanIsKan f g)) h⟩⟩⟩
end LeftKan
section LeftLift
open LeftLift
variable {f : b ⟶ a} {g : c ⟶ a}
/-- The existence of a left kan lift of `g` along `f`. -/
class HasLeftKanLift (f : b ⟶ a) (g : c ⟶ a) : Prop where mk' ::
hasInitial : HasInitial <| LeftLift f g
theorem LeftLift.IsKan.hasLeftKanLift {t : LeftLift f g} (H : IsKan t) : HasLeftKanLift f g :=
⟨IsInitial.hasInitial H⟩
instance [HasLeftKanLift f g] : HasInitial <| LeftLift f g := HasLeftKanLift.hasInitial
/-- The left Kan lift of `g` along `f` at the level of structured arrows. -/
def lanLiftLeftLift (f : b ⟶ a) (g : c ⟶ a) [HasLeftKanLift f g] : LeftLift f g :=
⊥_ (LeftLift f g)
/-- The left Kan lift of `g` along `f`. -/
def lanLift (f : b ⟶ a) (g : c ⟶ a) [HasLeftKanLift f g] : c ⟶ b :=
(lanLiftLeftLift f g).lift
/-- `f₊ g` is the left Kan lift of `g` along `f`.
```
b
◹ |
f₊ g / |
/ | f
/ ▽
c - - - ▷ a
g
```
-/
scoped infixr:90 "₊ " => lanLift
@[simp]
theorem lanLiftLeftLift_lift (f : b ⟶ a) (g : c ⟶ a) [HasLeftKanLift f g] :
(lanLiftLeftLift f g).lift = f₊ g := rfl
/-- The unit for the left Kan lift `f₊ g`. -/
def lanLiftUnit (f : b ⟶ a) (g : c ⟶ a) [HasLeftKanLift f g] : g ⟶ f₊ g ≫ f :=
(lanLiftLeftLift f g).unit
@[simp]
theorem lanLiftLeftLift_unit (f : b ⟶ a) (g : c ⟶ a) [HasLeftKanLift f g] :
(lanLiftLeftLift f g).unit = lanLiftUnit f g := rfl
/-- Evidence that the `LanLift.lift f g` is a Kan lift. -/
def lanLiftIsKan (f : b ⟶ a) (g : c ⟶ a) [HasLeftKanLift f g] : (lanLiftLeftLift f g).IsKan :=
initialIsInitial
variable {f : b ⟶ a} {g : c ⟶ a}
/-- The family of 2-morphisms out of the left Kan lift `f₊ g`. -/
def lanLiftDesc [HasLeftKanLift f g] (s : LeftLift f g) :
f ₊ g ⟶ s.lift :=
(lanLiftIsKan f g).desc s
@[reassoc (attr := simp)]
theorem lanLiftUnit_desc [HasLeftKanLift f g] (s : LeftLift f g) :
lanLiftUnit f g ≫ lanLiftDesc s ▷ f = s.unit :=
(lanLiftIsKan f g).fac s
@[simp]
theorem lanLiftIsKan_desc [HasLeftKanLift f g] (s : LeftLift f g) :
(lanLiftIsKan f g).desc s = lanLiftDesc s :=
rfl
theorem LanLift.existsUnique [HasLeftKanLift f g] (s : LeftLift f g) :
∃! τ, lanLiftUnit f g ≫ τ ▷ f = s.unit :=
(lanLiftIsKan f g).existsUnique _
/-- We say that a 1-morphism `h` commutes with the left Kan lift `f₊ g` if the whiskered left lift
for `f₊ g` by `h` is a Kan lift of `h ≫ g` along `f`. -/
class LanLift.CommuteWith
(f : b ⟶ a) (g : c ⟶ a) [HasLeftKanLift f g] {x : B} (h : x ⟶ c) : Prop where
commute : Nonempty <| IsKan <| (lanLiftLeftLift f g).whisker h
namespace LanLift.CommuteWith
theorem of_isKan_whisker [HasLeftKanLift f g] (t : LeftLift f g) {x : B} (h : x ⟶ c)
(H : IsKan (t.whisker h)) (i : t.whisker h ≅ (lanLiftLeftLift f g).whisker h) :
LanLift.CommuteWith f g h :=
⟨⟨IsKan.ofIsoKan H i⟩⟩
theorem of_lanLift_comp_iso [HasLeftKanLift f g]
{x : B} {h : x ⟶ c} [HasLeftKanLift f (h ≫ g)]
(i : f₊ (h ≫ g) ≅ h ≫ f₊ g)
(w : lanLiftUnit f (h ≫ g) ≫ i.hom ▷ f = h ◁ lanLiftUnit f g ≫ (α_ _ _ _).inv) :
LanLift.CommuteWith f g h :=
⟨⟨(lanLiftIsKan f (h ≫ g)).ofIsoKan <| StructuredArrow.isoMk i⟩⟩
variable (f : b ⟶ a) (g : c ⟶ a) [HasLeftKanLift f g]
variable {x : B} (h : x ⟶ c) [LanLift.CommuteWith f g h]
/-- Evidence that `h` commutes with the left Kan lift `f₊ g`. -/
def isKan : IsKan <| (lanLiftLeftLift f g).whisker h :=
Classical.choice LanLift.CommuteWith.commute
instance : HasLeftKanLift f (h ≫ g) := (LanLift.CommuteWith.isKan f g h).hasLeftKanLift
/-- If `h` commutes with `f₊ g` and `t` is another left Kan lift of `g` along `f`, then
`t.whisker h` is a left Kan lift of `h ≫ g` along `f`. -/
def isKanWhisker
(t : LeftLift f g) (H : IsKan t) {x : B} (h : x ⟶ c) [LanLift.CommuteWith f g h] :
IsKan (t.whisker h) :=
IsKan.whiskerOfCommute (lanLiftLeftLift f g) t (IsKan.uniqueUpToIso (lanLiftIsKan f g) H) h
(isKan f g h)
/-- The isomorphism `f₊ (h ≫ g) ≅ h ≫ f₊ g` at the level of structured arrows. -/
def lanLiftCompIsoWhisker :
lanLiftLeftLift f (h ≫ g) ≅ (lanLiftLeftLift f g).whisker h :=
IsKan.uniqueUpToIso (lanLiftIsKan f (h ≫ g)) (LanLift.CommuteWith.isKan f g h)
@[simp]
theorem lanLiftCompIsoWhisker_hom_right :
(lanLiftCompIsoWhisker f g h).hom.right = lanLiftDesc ((lanLiftLeftLift f g).whisker h) :=
rfl
@[simp]
theorem lanLiftCompIsoWhisker_inv_right :
(lanLiftCompIsoWhisker f g h).inv.right = (isKan f g h).desc (lanLiftLeftLift f (h ≫ g)) :=
rfl
/-- The 1-morphism `h` commutes with the left Kan lift `f₊ g`. -/
@[simps!]
def lanLiftCompIso : f₊ (h ≫ g) ≅ h ≫ f₊ g := Comma.rightIso <| lanLiftCompIsoWhisker f g h
end LanLift.CommuteWith
/-- We say that there exists an absolute left Kan lift of `g` along `f` if any 1-morphism `h`
commutes with the left Kan lift `f₊ g`. -/
class HasAbsLeftKanLift (f : b ⟶ a) (g : c ⟶ a) extends HasLeftKanLift f g : Prop where
commute : ∀ {x : B} (h : x ⟶ c), LanLift.CommuteWith f g h
instance [HasAbsLeftKanLift f g] {x : B} (h : x ⟶ c) : LanLift.CommuteWith f g h :=
HasAbsLeftKanLift.commute h
theorem LeftLift.IsAbsKan.hasAbsLeftKanLift {t : LeftLift f g} (H : IsAbsKan t) :
HasAbsLeftKanLift f g :=
have : HasLeftKanLift f g := H.isKan.hasLeftKanLift
⟨fun h ↦ ⟨⟨H.ofIsoAbsKan (IsKan.uniqueUpToIso H.isKan (lanLiftIsKan f g)) h⟩⟩⟩
end LeftLift
end Bicategory
end CategoryTheory
|
CategoryTheory\Bicategory\Kan\IsKan.lean | /-
Copyright (c) 2023 Yuma Mizuno. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yuma Mizuno
-/
import Mathlib.CategoryTheory.Bicategory.Extension
/-!
# Kan extensions and Kan lifts in bicategories
The left Kan extension of a 1-morphism `g : a ⟶ c` along a 1-morphism `f : a ⟶ b` is the initial
object in the category of left extensions `LeftExtension f g`. The universal property can be
accessed by the following definition and lemmas:
* `LeftExtension.IsKan.desc`: the family of 2-morphisms out of the left Kan extension.
* `LeftExtension.IsKan.fac`: the unit of any left extension factors through the left Kan extension.
* `LeftExtension.IsKan.hom_ext`: two 2-morphisms out of the left Kan extension are equal if their
compositions with each unit are equal.
We also define left Kan lifts, right Kan extensions, and right Kan lifts.
## Implementation Notes
We use the Is-Has design pattern, which is used for the implementation of limits and colimits in
the category theory library. This means that `IsKan t` is a structure containing the data of
2-morphisms which ensure that `t` is a Kan extension, while `HasKan f g` defined in
`CategoryTheory.Bicategory.Kan.HasKan` is a `Prop`-valued typeclass asserting that a Kan extension
of `g` along `f` exists.
We define `LeftExtension.IsKan t` for an extension `t : LeftExtension f g` (which is an
abbreviation of `t : StructuredArrow g (precomp _ f)`) to be an abbreviation for
`StructuredArrow.IsUniversal t`. This means that we can use the definitions and lemmas living
in the namespace `StructuredArrow.IsUniversal`.
## References
https://ncatlab.org/nlab/show/Kan+extension
-/
namespace CategoryTheory
namespace Bicategory
universe w v u
variable {B : Type u} [Bicategory.{w, v} B] {a b c : B}
namespace LeftExtension
variable {f : a ⟶ b} {g : a ⟶ c}
/-- A left Kan extension of `g` along `f` is an initial object in `LeftExtension f g`. -/
abbrev IsKan (t : LeftExtension f g) := t.IsUniversal
/-- An absolute left Kan extension is a Kan extension that commutes with any 1-morphism. -/
abbrev IsAbsKan (t : LeftExtension f g) :=
∀ {x : B} (h : c ⟶ x), IsKan (t.whisker h)
namespace IsKan
variable {s t : LeftExtension f g}
/-- To show that a left extension `t` is a Kan extension, we need to show that for every left
extension `s` there is a unique morphism `t ⟶ s`. -/
abbrev mk (desc : ∀ s, t ⟶ s) (w : ∀ s τ, τ = desc s) :
IsKan t :=
.ofUniqueHom desc w
/-- The family of 2-morphisms out of a left Kan extension. -/
abbrev desc (H : IsKan t) (s : LeftExtension f g) : t.extension ⟶ s.extension :=
StructuredArrow.IsUniversal.desc H s
@[reassoc (attr := simp)]
theorem fac (H : IsKan t) (s : LeftExtension f g) :
t.unit ≫ f ◁ H.desc s = s.unit :=
StructuredArrow.IsUniversal.fac H s
/-- Two 2-morphisms out of a left Kan extension are equal if their compositions with
each triangle 2-morphism are equal. -/
theorem hom_ext (H : IsKan t) {k : b ⟶ c} {τ τ' : t.extension ⟶ k}
(w : t.unit ≫ f ◁ τ = t.unit ≫ f ◁ τ') : τ = τ' :=
StructuredArrow.IsUniversal.hom_ext H w
/-- Kan extensions on `g` along `f` are unique up to isomorphism. -/
def uniqueUpToIso (P : IsKan s) (Q : IsKan t) : s ≅ t :=
Limits.IsInitial.uniqueUpToIso P Q
@[simp]
theorem uniqueUpToIso_hom_right (P : IsKan s) (Q : IsKan t) :
(uniqueUpToIso P Q).hom.right = P.desc t := rfl
@[simp]
theorem uniqueUpToIso_inv_right (P : IsKan s) (Q : IsKan t) :
(uniqueUpToIso P Q).inv.right = Q.desc s := rfl
/-- Transport evidence that a left extension is a Kan extension across an isomorphism
of extensions. -/
def ofIsoKan (P : IsKan s) (i : s ≅ t) : IsKan t :=
Limits.IsInitial.ofIso P i
/-- If `t : LeftExtension f (g ≫ 𝟙 c)` is a Kan extension, then `t.ofCompId : LeftExtension f g`
is also a Kan extension. -/
def ofCompId (t : LeftExtension f (g ≫ 𝟙 c)) (P : IsKan t) : IsKan t.ofCompId :=
.mk (fun s ↦ t.whiskerIdCancel <| P.to (s.whisker (𝟙 c))) <| by
intro s τ
ext
apply P.hom_ext
simp [← LeftExtension.w τ]
/-- If `s ≅ t` and `IsKan (s.whisker h)`, then `IsKan (t.whisker h)`. -/
def whiskerOfCommute (s t : LeftExtension f g) (i : s ≅ t) {x : B} (h : c ⟶ x)
(P : IsKan (s.whisker h)) :
IsKan (t.whisker h) :=
P.ofIsoKan <| whiskerIso i h
end IsKan
namespace IsAbsKan
variable {s t : LeftExtension f g}
/-- The family of 2-morphisms out of an absolute left Kan extension. -/
abbrev desc (H : IsAbsKan t) {x : B} {h : c ⟶ x} (s : LeftExtension f (g ≫ h)) :
t.extension ≫ h ⟶ s.extension :=
(H h).desc s
/-- An absolute left Kan extension is a left Kan extension. -/
def isKan (H : IsAbsKan t) : IsKan t :=
((H (𝟙 c)).ofCompId _).ofIsoKan <| whiskerOfCompIdIsoSelf t
/-- Transport evidence that a left extension is a Kan extension across an isomorphism
of extensions. -/
def ofIsoAbsKan (P : IsAbsKan s) (i : s ≅ t) : IsAbsKan t :=
fun h ↦ (P h).ofIsoKan (whiskerIso i h)
end IsAbsKan
end LeftExtension
namespace LeftLift
variable {f : b ⟶ a} {g : c ⟶ a}
/-- A left Kan lift of `g` along `f` is an initial object in `LeftLift f g`. -/
abbrev IsKan (t : LeftLift f g) := t.IsUniversal
/-- An absolute left Kan lift is a Kan lift such that every 1-morphism commutes with it. -/
abbrev IsAbsKan (t : LeftLift f g) :=
∀ {x : B} (h : x ⟶ c), IsKan (t.whisker h)
namespace IsKan
variable {s t : LeftLift f g}
/-- To show that a left lift `t` is a Kan lift, we need to show that for every left lift `s`
there is a unique morphism `t ⟶ s`. -/
abbrev mk (desc : ∀ s, t ⟶ s) (w : ∀ s τ, τ = desc s) :
IsKan t :=
.ofUniqueHom desc w
/-- The family of 2-morphisms out of a left Kan lift. -/
abbrev desc (H : IsKan t) (s : LeftLift f g) : t.lift ⟶ s.lift :=
StructuredArrow.IsUniversal.desc H s
@[reassoc (attr := simp)]
theorem fac (H : IsKan t) (s : LeftLift f g) :
t.unit ≫ H.desc s ▷ f = s.unit :=
StructuredArrow.IsUniversal.fac H s
/-- Two 2-morphisms out of a left Kan lift are equal if their compositions with
each triangle 2-morphism are equal. -/
theorem hom_ext (H : IsKan t) {k : c ⟶ b} {τ τ' : t.lift ⟶ k}
(w : t.unit ≫ τ ▷ f = t.unit ≫ τ' ▷ f) : τ = τ' :=
StructuredArrow.IsUniversal.hom_ext H w
/-- Kan lifts on `g` along `f` are unique up to isomorphism. -/
def uniqueUpToIso (P : IsKan s) (Q : IsKan t) : s ≅ t :=
Limits.IsInitial.uniqueUpToIso P Q
@[simp]
theorem uniqueUpToIso_hom_right (P : IsKan s) (Q : IsKan t) :
(uniqueUpToIso P Q).hom.right = P.desc t := rfl
@[simp]
theorem uniqueUpToIso_inv_right (P : IsKan s) (Q : IsKan t) :
(uniqueUpToIso P Q).inv.right = Q.desc s := rfl
/-- Transport evidence that a left lift is a Kan lift across an isomorphism of lifts. -/
def ofIsoKan (P : IsKan s) (i : s ≅ t) : IsKan t :=
Limits.IsInitial.ofIso P i
/-- If `t : LeftLift f (𝟙 c ≫ g)` is a Kan lift, then `t.ofIdComp : LeftLift f g` is also
a Kan lift. -/
def ofIdComp (t : LeftLift f (𝟙 c ≫ g)) (P : IsKan t) : IsKan t.ofIdComp :=
.mk (fun s ↦ t.whiskerIdCancel <| P.to (s.whisker (𝟙 c))) <| by
intro s τ
ext
apply P.hom_ext
simp [← LeftLift.w τ]
/-- If `s ≅ t` and `IsKan (s.whisker h)`, then `IsKan (t.whisker h)`. -/
def whiskerOfCommute (s t : LeftLift f g) (i : s ≅ t) {x : B} (h : x ⟶ c)
(P : IsKan (s.whisker h)) :
IsKan (t.whisker h) :=
P.ofIsoKan <| whiskerIso i h
end IsKan
namespace IsAbsKan
variable {s t : LeftLift f g}
/-- The family of 2-morphisms out of an absolute left Kan lift. -/
abbrev desc (H : IsAbsKan t) {x : B} {h : x ⟶ c} (s : LeftLift f (h ≫ g)) :
h ≫ t.lift ⟶ s.lift :=
(H h).desc s
/-- An absolute left Kan lift is a left Kan lift. -/
def isKan (H : IsAbsKan t) : IsKan t :=
((H (𝟙 c)).ofIdComp _).ofIsoKan <| whiskerOfIdCompIsoSelf t
/-- Transport evidence that a left lift is a Kan lift across an isomorphism of lifts. -/
def ofIsoAbsKan (P : IsAbsKan s) (i : s ≅ t) : IsAbsKan t :=
fun h ↦ (P h).ofIsoKan (whiskerIso i h)
end IsAbsKan
end LeftLift
namespace RightExtension
variable {f : a ⟶ b} {g : a ⟶ c}
/-- A right Kan extension of `g` along `f` is a terminal object in `RightExtension f g`. -/
abbrev IsKan (t : RightExtension f g) := t.IsUniversal
end RightExtension
namespace RightLift
variable {f : b ⟶ a} {g : c ⟶ a}
/-- A right Kan lift of `g` along `f` is a terminal object in `RightLift f g`. -/
abbrev IsKan (t : RightLift f g) := t.IsUniversal
end RightLift
end Bicategory
end CategoryTheory
|
CategoryTheory\Bicategory\NaturalTransformation\Oplax.lean | /-
Copyright (c) 2022 Yuma Mizuno. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yuma Mizuno
-/
import Mathlib.CategoryTheory.Bicategory.Functor.Oplax
/-!
# Oplax natural transformations
Just as there are natural transformations between functors, there are oplax natural transformations
between oplax functors. The equality in the naturality of natural transformations is replaced by a
specified 2-morphism `F.map f ≫ app b ⟶ app a ≫ G.map f` in the case of oplax natural
transformations.
## Main definitions
* `OplaxNatTrans F G` : oplax natural transformations between oplax functors `F` and `G`
* `OplaxNatTrans.vcomp η θ` : the vertical composition of oplax natural transformations `η`
and `θ`
* `OplaxNatTrans.category F G` : the category structure on the oplax natural transformations
between `F` and `G`
-/
namespace CategoryTheory
open Category Bicategory
open scoped Bicategory
universe w₁ w₂ v₁ v₂ u₁ u₂
variable {B : Type u₁} [Bicategory.{w₁, v₁} B] {C : Type u₂} [Bicategory.{w₂, v₂} C]
/-- If `η` is an oplax natural transformation between `F` and `G`, we have a 1-morphism
`η.app a : F.obj a ⟶ G.obj a` for each object `a : B`. We also have a 2-morphism
`η.naturality f : F.map f ≫ app b ⟶ app a ≫ G.map f` for each 1-morphism `f : a ⟶ b`.
These 2-morphisms satisfies the naturality condition, and preserve the identities and
the compositions modulo some adjustments of domains and codomains of 2-morphisms.
-/
structure OplaxNatTrans (F G : OplaxFunctor B C) where
app (a : B) : F.obj a ⟶ G.obj a
naturality {a b : B} (f : a ⟶ b) : F.map f ≫ app b ⟶ app a ≫ G.map f
naturality_naturality :
∀ {a b : B} {f g : a ⟶ b} (η : f ⟶ g),
F.map₂ η ▷ app b ≫ naturality g = naturality f ≫ app a ◁ G.map₂ η := by
aesop_cat
naturality_id :
∀ a : B,
naturality (𝟙 a) ≫ app a ◁ G.mapId a =
F.mapId a ▷ app a ≫ (λ_ (app a)).hom ≫ (ρ_ (app a)).inv := by
aesop_cat
naturality_comp :
∀ {a b c : B} (f : a ⟶ b) (g : b ⟶ c),
naturality (f ≫ g) ≫ app a ◁ G.mapComp f g =
F.mapComp f g ▷ app c ≫
(α_ _ _ _).hom ≫
F.map f ◁ naturality g ≫ (α_ _ _ _).inv ≫ naturality f ▷ G.map g ≫ (α_ _ _ _).hom := by
aesop_cat
attribute [nolint docBlame] CategoryTheory.OplaxNatTrans.app
CategoryTheory.OplaxNatTrans.naturality
CategoryTheory.OplaxNatTrans.naturality_naturality
CategoryTheory.OplaxNatTrans.naturality_id
CategoryTheory.OplaxNatTrans.naturality_comp
attribute [reassoc (attr := simp)] OplaxNatTrans.naturality_naturality OplaxNatTrans.naturality_id
OplaxNatTrans.naturality_comp
namespace OplaxNatTrans
section
variable (F : OplaxFunctor B C)
/-- The identity oplax natural transformation. -/
@[simps]
def id : OplaxNatTrans F F where
app a := 𝟙 (F.obj a)
naturality {a b} f := (ρ_ (F.map f)).hom ≫ (λ_ (F.map f)).inv
instance : Inhabited (OplaxNatTrans F F) :=
⟨id F⟩
variable {F} {G H : OplaxFunctor B C} (η : OplaxNatTrans F G) (θ : OplaxNatTrans G H)
section
variable {a b c : B} {a' : C}
@[reassoc (attr := simp)]
theorem whiskerLeft_naturality_naturality (f : a' ⟶ G.obj a) {g h : a ⟶ b} (β : g ⟶ h) :
f ◁ G.map₂ β ▷ θ.app b ≫ f ◁ θ.naturality h =
f ◁ θ.naturality g ≫ f ◁ θ.app a ◁ H.map₂ β := by
simp_rw [← whiskerLeft_comp, naturality_naturality]
@[reassoc (attr := simp)]
theorem whiskerRight_naturality_naturality {f g : a ⟶ b} (β : f ⟶ g) (h : G.obj b ⟶ a') :
F.map₂ β ▷ η.app b ▷ h ≫ η.naturality g ▷ h =
η.naturality f ▷ h ≫ (α_ _ _ _).hom ≫ η.app a ◁ G.map₂ β ▷ h ≫ (α_ _ _ _).inv := by
rw [← comp_whiskerRight, naturality_naturality, comp_whiskerRight, whisker_assoc]
@[reassoc (attr := simp)]
theorem whiskerLeft_naturality_comp (f : a' ⟶ G.obj a) (g : a ⟶ b) (h : b ⟶ c) :
f ◁ θ.naturality (g ≫ h) ≫ f ◁ θ.app a ◁ H.mapComp g h =
f ◁ G.mapComp g h ▷ θ.app c ≫
f ◁ (α_ _ _ _).hom ≫
f ◁ G.map g ◁ θ.naturality h ≫
f ◁ (α_ _ _ _).inv ≫ f ◁ θ.naturality g ▷ H.map h ≫ f ◁ (α_ _ _ _).hom := by
simp_rw [← whiskerLeft_comp, naturality_comp]
@[reassoc (attr := simp)]
theorem whiskerRight_naturality_comp (f : a ⟶ b) (g : b ⟶ c) (h : G.obj c ⟶ a') :
η.naturality (f ≫ g) ▷ h ≫ (α_ _ _ _).hom ≫ η.app a ◁ G.mapComp f g ▷ h =
F.mapComp f g ▷ η.app c ▷ h ≫
(α_ _ _ _).hom ▷ h ≫
(α_ _ _ _).hom ≫
F.map f ◁ η.naturality g ▷ h ≫
(α_ _ _ _).inv ≫
(α_ _ _ _).inv ▷ h ≫
η.naturality f ▷ G.map g ▷ h ≫ (α_ _ _ _).hom ▷ h ≫ (α_ _ _ _).hom := by
rw [← associator_naturality_middle, ← comp_whiskerRight_assoc, naturality_comp]; simp
@[reassoc (attr := simp)]
theorem whiskerLeft_naturality_id (f : a' ⟶ G.obj a) :
f ◁ θ.naturality (𝟙 a) ≫ f ◁ θ.app a ◁ H.mapId a =
f ◁ G.mapId a ▷ θ.app a ≫ f ◁ (λ_ (θ.app a)).hom ≫ f ◁ (ρ_ (θ.app a)).inv := by
simp_rw [← whiskerLeft_comp, naturality_id]
@[reassoc (attr := simp)]
theorem whiskerRight_naturality_id (f : G.obj a ⟶ a') :
η.naturality (𝟙 a) ▷ f ≫ (α_ _ _ _).hom ≫ η.app a ◁ G.mapId a ▷ f =
F.mapId a ▷ η.app a ▷ f ≫ (λ_ (η.app a)).hom ▷ f ≫ (ρ_ (η.app a)).inv ▷ f ≫ (α_ _ _ _).hom := by
rw [← associator_naturality_middle, ← comp_whiskerRight_assoc, naturality_id]; simp
end
/-- Vertical composition of oplax natural transformations. -/
@[simps]
def vcomp (η : OplaxNatTrans F G) (θ : OplaxNatTrans G H) : OplaxNatTrans F H where
app a := η.app a ≫ θ.app a
naturality {a b} f :=
(α_ _ _ _).inv ≫
η.naturality f ▷ θ.app b ≫ (α_ _ _ _).hom ≫ η.app a ◁ θ.naturality f ≫ (α_ _ _ _).inv
naturality_comp {a b c} f g := by
calc
_ =
?_ ≫
F.mapComp f g ▷ η.app c ▷ θ.app c ≫
?_ ≫
F.map f ◁ η.naturality g ▷ θ.app c ≫
?_ ≫
(F.map f ≫ η.app b) ◁ θ.naturality g ≫
η.naturality f ▷ (θ.app b ≫ H.map g) ≫
?_ ≫ η.app a ◁ θ.naturality f ▷ H.map g ≫ ?_ :=
?_
_ = _ := ?_
· exact (α_ _ _ _).inv
· exact (α_ _ _ _).hom ▷ _ ≫ (α_ _ _ _).hom
· exact _ ◁ (α_ _ _ _).hom ≫ (α_ _ _ _).inv
· exact (α_ _ _ _).hom ≫ _ ◁ (α_ _ _ _).inv
· exact _ ◁ (α_ _ _ _).hom ≫ (α_ _ _ _).inv
· rw [whisker_exchange_assoc]
simp
· simp
variable (B C)
@[simps id comp]
instance : CategoryStruct (OplaxFunctor B C) where
Hom := OplaxNatTrans
id := OplaxNatTrans.id
comp := OplaxNatTrans.vcomp
end
section
variable {F G : OplaxFunctor B C}
/-- A modification `Γ` between oplax natural transformations `η` and `θ` consists of a family of
2-morphisms `Γ.app a : η.app a ⟶ θ.app a`, which satisfies the equation
`(F.map f ◁ app b) ≫ θ.naturality f = η.naturality f ≫ (app a ▷ G.map f)`
for each 1-morphism `f : a ⟶ b`.
-/
@[ext]
structure Modification (η θ : F ⟶ G) where
app (a : B) : η.app a ⟶ θ.app a
naturality :
∀ {a b : B} (f : a ⟶ b),
F.map f ◁ app b ≫ θ.naturality f = η.naturality f ≫ app a ▷ G.map f := by
aesop_cat
attribute [nolint docBlame] CategoryTheory.OplaxNatTrans.Modification.app
CategoryTheory.OplaxNatTrans.Modification.naturality
/- Porting note: removed primes from field names and removed `restate_axiom` since that is no longer
needed in Lean 4 -/
attribute [reassoc (attr := simp)] Modification.naturality
variable {η θ ι : F ⟶ G}
namespace Modification
variable (η)
/-- The identity modification. -/
@[simps]
def id : Modification η η where app a := 𝟙 (η.app a)
instance : Inhabited (Modification η η) :=
⟨Modification.id η⟩
variable {η}
section
variable (Γ : Modification η θ) {a b c : B} {a' : C}
@[reassoc (attr := simp)]
theorem whiskerLeft_naturality (f : a' ⟶ F.obj b) (g : b ⟶ c) :
f ◁ F.map g ◁ Γ.app c ≫ f ◁ θ.naturality g = f ◁ η.naturality g ≫ f ◁ Γ.app b ▷ G.map g := by
simp_rw [← whiskerLeft_comp, naturality]
@[reassoc (attr := simp)]
theorem whiskerRight_naturality (f : a ⟶ b) (g : G.obj b ⟶ a') :
F.map f ◁ Γ.app b ▷ g ≫ (α_ _ _ _).inv ≫ θ.naturality f ▷ g =
(α_ _ _ _).inv ≫ η.naturality f ▷ g ≫ Γ.app a ▷ G.map f ▷ g := by
simp_rw [associator_inv_naturality_middle_assoc, ← comp_whiskerRight, naturality]
end
/-- Vertical composition of modifications. -/
@[simps]
def vcomp (Γ : Modification η θ) (Δ : Modification θ ι) : Modification η ι where
app a := Γ.app a ≫ Δ.app a
end Modification
/-- Category structure on the oplax natural transformations between OplaxFunctors. -/
@[simps]
instance category (F G : OplaxFunctor B C) : Category (F ⟶ G) where
Hom := Modification
id := Modification.id
comp := Modification.vcomp
-- Porting note: duplicating the `ext` lemma.
@[ext]
lemma ext {F G : OplaxFunctor B C} {α β : F ⟶ G} {m n : α ⟶ β} (w : ∀ b, m.app b = n.app b) :
m = n := by
apply Modification.ext
ext
apply w
@[simp]
lemma Modification.id_app' {X : B} {F G : OplaxFunctor B C} (α : F ⟶ G) :
Modification.app (𝟙 α) X = 𝟙 (α.app X) := rfl
@[simp]
lemma Modification.comp_app' {X : B} {F G : OplaxFunctor B C} {α β γ : F ⟶ G}
(m : α ⟶ β) (n : β ⟶ γ) : (m ≫ n).app X = m.app X ≫ n.app X :=
rfl
/-- Construct a modification isomorphism between oplax natural transformations
by giving object level isomorphisms, and checking naturality only in the forward direction.
-/
@[simps]
def ModificationIso.ofComponents (app : ∀ a, η.app a ≅ θ.app a)
(naturality :
∀ {a b} (f : a ⟶ b),
F.map f ◁ (app b).hom ≫ θ.naturality f = η.naturality f ≫ (app a).hom ▷ G.map f) :
η ≅ θ where
hom := { app := fun a => (app a).hom }
inv :=
{ app := fun a => (app a).inv
naturality := fun {a b} f => by
simpa using congr_arg (fun f => _ ◁ (app b).inv ≫ f ≫ (app a).inv ▷ _) (naturality f).symm }
end
/-- A structure on an Oplax natural transformation that promotes it to a strong natural
transformation.
See `StrongNatTrans.mkOfOplax`. -/
structure StrongCore {F G : OplaxFunctor B C} (η : OplaxNatTrans F G) where
naturality {a b : B} (f : a ⟶ b) : F.map f ≫ η.app b ≅ η.app a ≫ G.map f
naturality_hom {a b : B} (f : a ⟶ b) : (naturality f).hom = η.naturality f := by aesop_cat
attribute [nolint docBlame] CategoryTheory.OplaxNatTrans.StrongCore.naturality
CategoryTheory.OplaxNatTrans.StrongCore.naturality_hom
attribute [simp] StrongCore.naturality_hom
end OplaxNatTrans
end CategoryTheory
|
CategoryTheory\Bicategory\NaturalTransformation\Strong.lean | /-
Copyright (c) 2024 Calle Sönne. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Calle Sönne
-/
import Mathlib.CategoryTheory.Bicategory.Functor.Pseudofunctor
import Mathlib.CategoryTheory.Bicategory.NaturalTransformation.Oplax
/-!
# Strong natural transformations
A strong natural transformation is an oplax natural transformation such that each component 2-cell
is an isomorphism.
## Main definitions
* `StrongOplaxNatTrans F G` : strong natural transformations between oplax functors `F` and `G`.
* `mkOfOplax η η'` : given an oplax natural transformation `η` such that each component 2-cell
is an isomorphism, `mkOfOplax` gives the corresponding strong natural transformation.
* `StrongOplaxNatTrans.vcomp η θ` : the vertical composition of strong natural transformations `η`
and `θ`.
* `StrongOplaxNatTrans.category F G` : a category structure on pseudofunctors between `F` and `G`,
where the morphisms are strong natural transformations.
## TODO
After having defined lax functors, we should define 3 different types of strong natural
transformations:
* strong natural transformations between oplax functors (as defined here).
* strong natural transformations between lax functors.
* strong natural transformations between pseudofunctors. From these types of strong natural
transformations, we can define the underlying natural transformations between the underlying
oplax resp. lax functors. Many properties can then be inferred from these.
## References
* [Niles Johnson, Donald Yau, *2-Dimensional Categories*](https://arxiv.org/abs/2002.06055)
-/
namespace CategoryTheory
open Category Bicategory
open scoped Bicategory
universe w₁ w₂ v₁ v₂ u₁ u₂
variable {B : Type u₁} [Bicategory.{w₁, v₁} B] {C : Type u₂} [Bicategory.{w₂, v₂} C]
/-- A strong natural transformation between oplax functors `F` and `G` is a natural transformation
that is "natural up to 2-isomorphisms".
More precisely, it consists of the following:
* a 1-morphism `η.app a : F.obj a ⟶ G.obj a` for each object `a : B`.
* a 2-isomorphism `η.naturality f : F.map f ≫ app b ⟶ app a ≫ G.map f` for each 1-morphism
`f : a ⟶ b`.
* These 2-isomorphisms satisfy the naturality condition, and preserve the identities and the
compositions modulo some adjustments of domains and codomains of 2-morphisms.
-/
structure StrongOplaxNatTrans (F G : OplaxFunctor B C) where
app (a : B) : F.obj a ⟶ G.obj a
naturality {a b : B} (f : a ⟶ b) : F.map f ≫ app b ≅ app a ≫ G.map f
naturality_naturality :
∀ {a b : B} {f g : a ⟶ b} (η : f ⟶ g),
F.map₂ η ▷ app b ≫ (naturality g).hom = (naturality f).hom ≫ app a ◁ G.map₂ η := by
aesop_cat
naturality_id :
∀ a : B,
(naturality (𝟙 a)).hom ≫ app a ◁ G.mapId a =
F.mapId a ▷ app a ≫ (λ_ (app a)).hom ≫ (ρ_ (app a)).inv := by
aesop_cat
naturality_comp :
∀ {a b c : B} (f : a ⟶ b) (g : b ⟶ c),
(naturality (f ≫ g)).hom ≫ app a ◁ G.mapComp f g =
F.mapComp f g ▷ app c ≫ (α_ _ _ _).hom ≫ F.map f ◁ (naturality g).hom ≫
(α_ _ _ _).inv ≫ (naturality f).hom ▷ G.map g ≫ (α_ _ _ _).hom := by
aesop_cat
attribute [nolint docBlame] CategoryTheory.StrongOplaxNatTrans.app
CategoryTheory.StrongOplaxNatTrans.naturality
CategoryTheory.StrongOplaxNatTrans.naturality_naturality
CategoryTheory.StrongOplaxNatTrans.naturality_id
CategoryTheory.StrongOplaxNatTrans.naturality_comp
attribute [reassoc (attr := simp)] StrongOplaxNatTrans.naturality_naturality
StrongOplaxNatTrans.naturality_id StrongOplaxNatTrans.naturality_comp
namespace StrongOplaxNatTrans
section
/-- The underlying oplax natural transformation of a strong natural transformation. -/
@[simps]
def toOplax {F G : OplaxFunctor B C} (η : StrongOplaxNatTrans F G) : OplaxNatTrans F G where
app := η.app
naturality f := (η.naturality f).hom
/-- Construct a strong natural transformation from an oplax natural transformation whose
naturality 2-cell is an isomorphism. -/
def mkOfOplax {F G : OplaxFunctor B C} (η : OplaxNatTrans F G) (η' : OplaxNatTrans.StrongCore η) :
StrongOplaxNatTrans F G where
app := η.app
naturality := η'.naturality
/-- Construct a strong natural transformation from an oplax natural transformation whose
naturality 2-cell is an isomorphism. -/
noncomputable def mkOfOplax' {F G : OplaxFunctor B C} (η : OplaxNatTrans F G)
[∀ a b (f : a ⟶ b), IsIso (η.naturality f)] : StrongOplaxNatTrans F G where
app := η.app
naturality := fun f => asIso (η.naturality _)
variable (F : OplaxFunctor B C)
/-- The identity strong natural transformation. -/
@[simps!]
def id : StrongOplaxNatTrans F F :=
mkOfOplax (OplaxNatTrans.id F) { naturality := λ f ↦ (ρ_ (F.map f)) ≪≫ (λ_ (F.map f)).symm }
@[simp]
lemma id.toOplax : (id F).toOplax = OplaxNatTrans.id F :=
rfl
instance : Inhabited (StrongOplaxNatTrans F F) :=
⟨id F⟩
variable {F} {G H : OplaxFunctor B C} (η : StrongOplaxNatTrans F G) (θ : StrongOplaxNatTrans G H)
section
variable {a b c : B} {a' : C}
@[reassoc (attr := simp)]
theorem whiskerLeft_naturality_naturality (f : a' ⟶ G.obj a) {g h : a ⟶ b} (β : g ⟶ h) :
f ◁ G.map₂ β ▷ θ.app b ≫ f ◁ (θ.naturality h).hom =
f ◁ (θ.naturality g).hom ≫ f ◁ θ.app a ◁ H.map₂ β := by
apply θ.toOplax.whiskerLeft_naturality_naturality
@[reassoc (attr := simp)]
theorem whiskerRight_naturality_naturality {f g : a ⟶ b} (β : f ⟶ g) (h : G.obj b ⟶ a') :
F.map₂ β ▷ η.app b ▷ h ≫ (η.naturality g).hom ▷ h =
(η.naturality f).hom ▷ h ≫ (α_ _ _ _).hom ≫ η.app a ◁ G.map₂ β ▷ h ≫ (α_ _ _ _).inv := by
apply η.toOplax.whiskerRight_naturality_naturality
@[reassoc (attr := simp)]
theorem whiskerLeft_naturality_comp (f : a' ⟶ G.obj a) (g : a ⟶ b) (h : b ⟶ c) :
f ◁ (θ.naturality (g ≫ h)).hom ≫ f ◁ θ.app a ◁ H.mapComp g h =
f ◁ G.mapComp g h ▷ θ.app c ≫
f ◁ (α_ _ _ _).hom ≫
f ◁ G.map g ◁ (θ.naturality h).hom ≫
f ◁ (α_ _ _ _).inv ≫ f ◁ (θ.naturality g).hom ▷ H.map h ≫ f ◁ (α_ _ _ _).hom := by
apply θ.toOplax.whiskerLeft_naturality_comp
@[reassoc (attr := simp)]
theorem whiskerRight_naturality_comp (f : a ⟶ b) (g : b ⟶ c) (h : G.obj c ⟶ a') :
(η.naturality (f ≫ g)).hom ▷ h ≫ (α_ _ _ _).hom ≫ η.app a ◁ G.mapComp f g ▷ h =
F.mapComp f g ▷ η.app c ▷ h ≫
(α_ _ _ _).hom ▷ h ≫
(α_ _ _ _).hom ≫
F.map f ◁ (η.naturality g).hom ▷ h ≫
(α_ _ _ _).inv ≫
(α_ _ _ _).inv ▷ h ≫
(η.naturality f).hom ▷ G.map g ▷ h ≫ (α_ _ _ _).hom ▷ h ≫ (α_ _ _ _).hom := by
apply η.toOplax.whiskerRight_naturality_comp
@[reassoc (attr := simp)]
theorem whiskerLeft_naturality_id (f : a' ⟶ G.obj a) :
f ◁ (θ.naturality (𝟙 a)).hom ≫ f ◁ θ.app a ◁ H.mapId a =
f ◁ G.mapId a ▷ θ.app a ≫ f ◁ (λ_ (θ.app a)).hom ≫ f ◁ (ρ_ (θ.app a)).inv := by
apply θ.toOplax.whiskerLeft_naturality_id
@[reassoc (attr := simp)]
theorem whiskerRight_naturality_id (f : G.obj a ⟶ a') :
(η.naturality (𝟙 a)).hom ▷ f ≫ (α_ _ _ _).hom ≫ η.app a ◁ G.mapId a ▷ f =
F.mapId a ▷ η.app a ▷ f ≫ (λ_ (η.app a)).hom ▷ f ≫ (ρ_ (η.app a)).inv ▷ f ≫
(α_ _ _ _).hom := by
apply η.toOplax.whiskerRight_naturality_id
end
/-- Vertical composition of strong natural transformations. -/
@[simps!]
def vcomp (η : StrongOplaxNatTrans F G) (θ : StrongOplaxNatTrans G H) : StrongOplaxNatTrans F H :=
mkOfOplax (OplaxNatTrans.vcomp η.toOplax θ.toOplax)
{ naturality := λ {a b} f ↦
(α_ _ _ _).symm ≪≫ whiskerRightIso (η.naturality f) (θ.app b) ≪≫
(α_ _ _ _) ≪≫ whiskerLeftIso (η.app a) (θ.naturality f) ≪≫ (α_ _ _ _).symm }
end
end StrongOplaxNatTrans
variable (B C)
@[simps id comp]
instance Pseudofunctor.categoryStruct : CategoryStruct (Pseudofunctor B C) where
Hom F G := StrongOplaxNatTrans F.toOplax G.toOplax
id F := StrongOplaxNatTrans.id F.toOplax
comp := StrongOplaxNatTrans.vcomp
end CategoryTheory
|
CategoryTheory\Category\Basic.lean | /-
Copyright (c) 2017 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Stephen Morgan, Scott Morrison, Johannes Hölzl, Reid Barton
-/
import Mathlib.CategoryTheory.Category.Init
import Mathlib.Combinatorics.Quiver.Basic
import Mathlib.Tactic.PPWithUniv
import Mathlib.Tactic.Common
/-!
# Categories
Defines a category, as a type class parametrised by the type of objects.
## Notations
Introduces notations in the `CategoryTheory` scope
* `X ⟶ Y` for the morphism spaces (type as `\hom`),
* `𝟙 X` for the identity morphism on `X` (type as `\b1`),
* `f ≫ g` for composition in the 'arrows' convention (type as `\gg`).
Users may like to add `g ⊚ f` for composition in the standard convention, using
```lean
local notation g ` ⊚ `:80 f:80 := category.comp f g -- type as \oo
```
## Porting note
I am experimenting with using the `aesop` tactic as a replacement for `tidy`.
-/
library_note "CategoryTheory universes"
/--
The typeclass `Category C` describes morphisms associated to objects of type `C : Type u`.
The universe levels of the objects and morphisms are independent, and will often need to be
specified explicitly, as `Category.{v} C`.
Typically any concrete example will either be a `SmallCategory`, where `v = u`,
which can be introduced as
```
universe u
variable {C : Type u} [SmallCategory C]
```
or a `LargeCategory`, where `u = v+1`, which can be introduced as
```
universe u
variable {C : Type (u+1)} [LargeCategory C]
```
In order for the library to handle these cases uniformly,
we generally work with the unconstrained `Category.{v u}`,
for which objects live in `Type u` and morphisms live in `Type v`.
Because the universe parameter `u` for the objects can be inferred from `C`
when we write `Category C`, while the universe parameter `v` for the morphisms
can not be automatically inferred, through the category theory library
we introduce universe parameters with morphism levels listed first,
as in
```
universe v u
```
or
```
universe v₁ v₂ u₁ u₂
```
when multiple independent universes are needed.
This has the effect that we can simply write `Category.{v} C`
(that is, only specifying a single parameter) while `u` will be inferred.
Often, however, it's not even necessary to include the `.{v}`.
(Although it was in earlier versions of Lean.)
If it is omitted a "free" universe will be used.
-/
universe v u
namespace CategoryTheory
/-- A preliminary structure on the way to defining a category,
containing the data, but none of the axioms. -/
@[pp_with_univ]
class CategoryStruct (obj : Type u) extends Quiver.{v + 1} obj : Type max u (v + 1) where
/-- The identity morphism on an object. -/
id : ∀ X : obj, Hom X X
/-- Composition of morphisms in a category, written `f ≫ g`. -/
comp : ∀ {X Y Z : obj}, (X ⟶ Y) → (Y ⟶ Z) → (X ⟶ Z)
initialize_simps_projections CategoryStruct (-toQuiver_Hom)
/-- Notation for the identity morphism in a category. -/
scoped notation "𝟙" => CategoryStruct.id -- type as \b1
/-- Notation for composition of morphisms in a category. -/
scoped infixr:80 " ≫ " => CategoryStruct.comp -- type as \gg
/-- Close the main goal with `sorry` if its type contains `sorry`, and fail otherwise. -/
syntax (name := sorryIfSorry) "sorry_if_sorry" : tactic
open Lean Meta Elab.Tactic in
@[tactic sorryIfSorry, inherit_doc sorryIfSorry] def evalSorryIfSorry : Tactic := fun _ => do
let goalType ← getMainTarget
if goalType.hasSorry then
closeMainGoal `sorry_if_sorry (← mkSorry goalType true)
else
throwError "The goal does not contain `sorry`"
/--
A thin wrapper for `aesop` which adds the `CategoryTheory` rule set and
allows `aesop` to look through semireducible definitions when calling `intros`.
This tactic fails when it is unable to solve the goal, making it suitable for
use in auto-params.
-/
macro (name := aesop_cat) "aesop_cat" c:Aesop.tactic_clause* : tactic =>
`(tactic|
first | sorry_if_sorry |
aesop $c* (config := { introsTransparency? := some .default, terminal := true })
(rule_sets := [$(Lean.mkIdent `CategoryTheory):ident]))
/--
We also use `aesop_cat?` to pass along a `Try this` suggestion when using `aesop_cat`
-/
macro (name := aesop_cat?) "aesop_cat?" c:Aesop.tactic_clause* : tactic =>
`(tactic|
first | sorry_if_sorry |
aesop? $c* (config := { introsTransparency? := some .default, terminal := true })
(rule_sets := [$(Lean.mkIdent `CategoryTheory):ident]))
/--
A variant of `aesop_cat` which does not fail when it is unable to solve the
goal. Use this only for exploration! Nonterminal `aesop` is even worse than
nonterminal `simp`.
-/
macro (name := aesop_cat_nonterminal) "aesop_cat_nonterminal" c:Aesop.tactic_clause* : tactic =>
`(tactic|
aesop $c* (config := { introsTransparency? := some .default, warnOnNonterminal := false })
(rule_sets := [$(Lean.mkIdent `CategoryTheory):ident]))
attribute [aesop safe (rule_sets := [CategoryTheory])] Subsingleton.elim
/-- The typeclass `Category C` describes morphisms associated to objects of type `C`.
The universe levels of the objects and morphisms are unconstrained, and will often need to be
specified explicitly, as `Category.{v} C`. (See also `LargeCategory` and `SmallCategory`.)
See <https://stacks.math.columbia.edu/tag/0014>.
-/
@[pp_with_univ]
class Category (obj : Type u) extends CategoryStruct.{v} obj : Type max u (v + 1) where
/-- Identity morphisms are left identities for composition. -/
id_comp : ∀ {X Y : obj} (f : X ⟶ Y), 𝟙 X ≫ f = f := by aesop_cat
/-- Identity morphisms are right identities for composition. -/
comp_id : ∀ {X Y : obj} (f : X ⟶ Y), f ≫ 𝟙 Y = f := by aesop_cat
/-- Composition in a category is associative. -/
assoc : ∀ {W X Y Z : obj} (f : W ⟶ X) (g : X ⟶ Y) (h : Y ⟶ Z), (f ≫ g) ≫ h = f ≫ g ≫ h := by
aesop_cat
attribute [simp] Category.id_comp Category.comp_id Category.assoc
attribute [trans] CategoryStruct.comp
example {C} [Category C] {X Y : C} (f : X ⟶ Y) : 𝟙 X ≫ f = f := by simp
example {C} [Category C] {X Y : C} (f : X ⟶ Y) : f ≫ 𝟙 Y = f := by simp
/-- A `LargeCategory` has objects in one universe level higher than the universe level of
the morphisms. It is useful for examples such as the category of types, or the category
of groups, etc.
-/
abbrev LargeCategory (C : Type (u + 1)) : Type (u + 1) := Category.{u} C
/-- A `SmallCategory` has objects and morphisms in the same universe level.
-/
abbrev SmallCategory (C : Type u) : Type (u + 1) := Category.{u} C
section
variable {C : Type u} [Category.{v} C] {X Y Z : C}
initialize_simps_projections Category (-Hom)
/-- postcompose an equation between morphisms by another morphism -/
theorem eq_whisker {f g : X ⟶ Y} (w : f = g) (h : Y ⟶ Z) : f ≫ h = g ≫ h := by rw [w]
/-- precompose an equation between morphisms by another morphism -/
theorem whisker_eq (f : X ⟶ Y) {g h : Y ⟶ Z} (w : g = h) : f ≫ g = f ≫ h := by rw [w]
/--
Notation for whiskering an equation by a morphism (on the right).
If `f g : X ⟶ Y` and `w : f = g` and `h : Y ⟶ Z`, then `w =≫ h : f ≫ h = g ≫ h`.
-/
scoped infixr:80 " =≫ " => eq_whisker
/--
Notation for whiskering an equation by a morphism (on the left).
If `g h : Y ⟶ Z` and `w : g = h` and `h : X ⟶ Y`, then `f ≫= w : f ≫ g = f ≫ h`.
-/
scoped infixr:80 " ≫= " => whisker_eq
theorem eq_of_comp_left_eq {f g : X ⟶ Y} (w : ∀ {Z : C} (h : Y ⟶ Z), f ≫ h = g ≫ h) :
f = g := by
convert w (𝟙 Y) <;> simp
theorem eq_of_comp_right_eq {f g : Y ⟶ Z} (w : ∀ {X : C} (h : X ⟶ Y), h ≫ f = h ≫ g) :
f = g := by
convert w (𝟙 Y) <;> simp
theorem eq_of_comp_left_eq' (f g : X ⟶ Y)
(w : (fun {Z} (h : Y ⟶ Z) => f ≫ h) = fun {Z} (h : Y ⟶ Z) => g ≫ h) : f = g :=
eq_of_comp_left_eq @fun Z h => by convert congr_fun (congr_fun w Z) h
theorem eq_of_comp_right_eq' (f g : Y ⟶ Z)
(w : (fun {X} (h : X ⟶ Y) => h ≫ f) = fun {X} (h : X ⟶ Y) => h ≫ g) : f = g :=
eq_of_comp_right_eq @fun X h => by convert congr_fun (congr_fun w X) h
theorem id_of_comp_left_id (f : X ⟶ X) (w : ∀ {Y : C} (g : X ⟶ Y), f ≫ g = g) : f = 𝟙 X := by
convert w (𝟙 X)
simp
theorem id_of_comp_right_id (f : X ⟶ X) (w : ∀ {Y : C} (g : Y ⟶ X), g ≫ f = g) : f = 𝟙 X := by
convert w (𝟙 X)
simp
theorem comp_ite {P : Prop} [Decidable P] {X Y Z : C} (f : X ⟶ Y) (g g' : Y ⟶ Z) :
(f ≫ if P then g else g') = if P then f ≫ g else f ≫ g' := by aesop
theorem ite_comp {P : Prop} [Decidable P] {X Y Z : C} (f f' : X ⟶ Y) (g : Y ⟶ Z) :
(if P then f else f') ≫ g = if P then f ≫ g else f' ≫ g := by aesop
theorem comp_dite {P : Prop} [Decidable P]
{X Y Z : C} (f : X ⟶ Y) (g : P → (Y ⟶ Z)) (g' : ¬P → (Y ⟶ Z)) :
(f ≫ if h : P then g h else g' h) = if h : P then f ≫ g h else f ≫ g' h := by aesop
theorem dite_comp {P : Prop} [Decidable P]
{X Y Z : C} (f : P → (X ⟶ Y)) (f' : ¬P → (X ⟶ Y)) (g : Y ⟶ Z) :
(if h : P then f h else f' h) ≫ g = if h : P then f h ≫ g else f' h ≫ g := by aesop
/-- A morphism `f` is an epimorphism if it can be cancelled when precomposed:
`f ≫ g = f ≫ h` implies `g = h`.
See <https://stacks.math.columbia.edu/tag/003B>.
-/
class Epi (f : X ⟶ Y) : Prop where
/-- A morphism `f` is an epimorphism if it can be cancelled when precomposed. -/
left_cancellation : ∀ {Z : C} (g h : Y ⟶ Z), f ≫ g = f ≫ h → g = h
/-- A morphism `f` is a monomorphism if it can be cancelled when postcomposed:
`g ≫ f = h ≫ f` implies `g = h`.
See <https://stacks.math.columbia.edu/tag/003B>.
-/
class Mono (f : X ⟶ Y) : Prop where
/-- A morphism `f` is a monomorphism if it can be cancelled when postcomposed. -/
right_cancellation : ∀ {Z : C} (g h : Z ⟶ X), g ≫ f = h ≫ f → g = h
instance (X : C) : Epi (𝟙 X) :=
⟨fun g h w => by aesop⟩
instance (X : C) : Mono (𝟙 X) :=
⟨fun g h w => by aesop⟩
theorem cancel_epi (f : X ⟶ Y) [Epi f] {g h : Y ⟶ Z} : f ≫ g = f ≫ h ↔ g = h :=
⟨fun p => Epi.left_cancellation g h p, congr_arg _⟩
theorem cancel_mono (f : X ⟶ Y) [Mono f] {g h : Z ⟶ X} : g ≫ f = h ≫ f ↔ g = h :=
-- Porting note: in Lean 3 we could just write `congr_arg _` here.
⟨fun p => Mono.right_cancellation g h p, congr_arg (fun k => k ≫ f)⟩
theorem cancel_epi_id (f : X ⟶ Y) [Epi f] {h : Y ⟶ Y} : f ≫ h = f ↔ h = 𝟙 Y := by
convert cancel_epi f
simp
theorem cancel_mono_id (f : X ⟶ Y) [Mono f] {g : X ⟶ X} : g ≫ f = f ↔ g = 𝟙 X := by
convert cancel_mono f
simp
theorem epi_comp {X Y Z : C} (f : X ⟶ Y) [Epi f] (g : Y ⟶ Z) [Epi g] : Epi (f ≫ g) := by
constructor
intro Z a b w
apply (cancel_epi g).1
apply (cancel_epi f).1
simpa using w
theorem mono_comp {X Y Z : C} (f : X ⟶ Y) [Mono f] (g : Y ⟶ Z) [Mono g] : Mono (f ≫ g) := by
constructor
intro Z a b w
apply (cancel_mono f).1
apply (cancel_mono g).1
simpa using w
theorem mono_of_mono {X Y Z : C} (f : X ⟶ Y) (g : Y ⟶ Z) [Mono (f ≫ g)] : Mono f := by
constructor
intro Z a b w
replace w := congr_arg (fun k => k ≫ g) w
dsimp at w
rw [Category.assoc, Category.assoc] at w
exact (cancel_mono _).1 w
theorem mono_of_mono_fac {X Y Z : C} {f : X ⟶ Y} {g : Y ⟶ Z} {h : X ⟶ Z} [Mono h]
(w : f ≫ g = h) : Mono f := by
subst h
exact mono_of_mono f g
theorem epi_of_epi {X Y Z : C} (f : X ⟶ Y) (g : Y ⟶ Z) [Epi (f ≫ g)] : Epi g := by
constructor
intro Z a b w
replace w := congr_arg (fun k => f ≫ k) w
dsimp at w
rw [← Category.assoc, ← Category.assoc] at w
exact (cancel_epi _).1 w
theorem epi_of_epi_fac {X Y Z : C} {f : X ⟶ Y} {g : Y ⟶ Z} {h : X ⟶ Z} [Epi h]
(w : f ≫ g = h) : Epi g := by
subst h; exact epi_of_epi f g
section
variable [Quiver.IsThin C] (f : X ⟶ Y)
instance : Mono f where
right_cancellation _ _ _ := Subsingleton.elim _ _
instance : Epi f where
left_cancellation _ _ _ := Subsingleton.elim _ _
end
end
section
variable (C : Type u)
variable [Category.{v} C]
universe u'
instance uliftCategory : Category.{v} (ULift.{u'} C) where
Hom X Y := X.down ⟶ Y.down
id X := 𝟙 X.down
comp f g := f ≫ g
-- We verify that this previous instance can lift small categories to large categories.
example (D : Type u) [SmallCategory D] : LargeCategory (ULift.{u + 1} D) := by infer_instance
end
end CategoryTheory
-- Porting note: We hope that this will become less necessary,
-- as in Lean4 `simp` will automatically enter "`dsimp` mode" when needed with dependent arguments.
-- Optimistically, we will eventually remove this library note.
library_note "dsimp, simp"
/-- Many proofs in the category theory library use the `dsimp, simp` pattern,
which typically isn't necessary elsewhere.
One would usually hope that the same effect could be achieved simply with `simp`.
The essential issue is that composition of morphisms involves dependent types.
When you have a chain of morphisms being composed, say `f : X ⟶ Y` and `g : Y ⟶ Z`,
then `simp` can operate successfully on the morphisms
(e.g. if `f` is the identity it can strip that off).
However if we have an equality of objects, say `Y = Y'`,
then `simp` can't operate because it would break the typing of the composition operations.
We rarely have interesting equalities of objects
(because that would be "evil" --- anything interesting should be expressed as an isomorphism
and tracked explicitly),
except of course that we have plenty of definitional equalities of objects.
`dsimp` can apply these safely, even inside a composition.
After `dsimp` has cleared up the object level, `simp` can resume work on the morphism level ---
but without the `dsimp` step, because `simp` looks at expressions syntactically,
the relevant lemmas might not fire.
There's no bound on how many times you potentially could have to switch back and forth,
if the `simp` introduced new objects we again need to `dsimp`.
In practice this does occur, but only rarely, because `simp` tends to shorten chains of compositions
(i.e. not introduce new objects at all).
-/
|
CategoryTheory\Category\Bipointed.lean | /-
Copyright (c) 2022 Yaël Dillies. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yaël Dillies
-/
import Mathlib.CategoryTheory.Category.Pointed
/-!
# The category of bipointed types
This defines `Bipointed`, the category of bipointed types.
## TODO
Monoidal structure
-/
open CategoryTheory
universe u
variable {α β : Type*}
/-- The category of bipointed types. -/
structure Bipointed : Type (u + 1) where
/-- The underlying type of a bipointed type. -/
protected X : Type u
/-- The two points of a bipointed type, bundled together as a pair. -/
toProd : X × X
namespace Bipointed
instance : CoeSort Bipointed Type* := ⟨Bipointed.X⟩
/-- Turns a bipointing into a bipointed type. -/
def of {X : Type*} (to_prod : X × X) : Bipointed :=
⟨X, to_prod⟩
@[simp]
theorem coe_of {X : Type*} (to_prod : X × X) : ↥(of to_prod) = X :=
rfl
alias _root_.Prod.Bipointed := of
instance : Inhabited Bipointed :=
⟨of ((), ())⟩
/-- Morphisms in `Bipointed`. -/
@[ext]
protected structure Hom (X Y : Bipointed.{u}) : Type u where
/-- The underlying function of a morphism of bipointed types. -/
toFun : X → Y
map_fst : toFun X.toProd.1 = Y.toProd.1
map_snd : toFun X.toProd.2 = Y.toProd.2
namespace Hom
/-- The identity morphism of `X : Bipointed`. -/
@[simps]
nonrec def id (X : Bipointed) : Bipointed.Hom X X :=
⟨id, rfl, rfl⟩
instance (X : Bipointed) : Inhabited (Bipointed.Hom X X) :=
⟨id X⟩
/-- Composition of morphisms of `Bipointed`. -/
@[simps]
def comp {X Y Z : Bipointed.{u}} (f : Bipointed.Hom X Y) (g : Bipointed.Hom Y Z) :
Bipointed.Hom X Z :=
⟨g.toFun ∘ f.toFun, by rw [Function.comp_apply, f.map_fst, g.map_fst], by
rw [Function.comp_apply, f.map_snd, g.map_snd]⟩
end Hom
instance largeCategory : LargeCategory Bipointed where
Hom := Bipointed.Hom
id := Hom.id
comp := @Hom.comp
instance concreteCategory : ConcreteCategory Bipointed where
forget :=
{ obj := Bipointed.X
map := @Hom.toFun }
forget_faithful := ⟨@Hom.ext⟩
/-- Swaps the pointed elements of a bipointed type. `Prod.swap` as a functor. -/
@[simps]
def swap : Bipointed ⥤ Bipointed where
obj X := ⟨X, X.toProd.swap⟩
map f := ⟨f.toFun, f.map_snd, f.map_fst⟩
/-- The equivalence between `Bipointed` and itself induced by `Prod.swap` both ways. -/
@[simps!]
def swapEquiv : Bipointed ≌ Bipointed :=
CategoryTheory.Equivalence.mk swap swap
(NatIso.ofComponents fun X =>
{ hom := ⟨id, rfl, rfl⟩
inv := ⟨id, rfl, rfl⟩ })
(NatIso.ofComponents fun X =>
{ hom := ⟨id, rfl, rfl⟩
inv := ⟨id, rfl, rfl⟩ })
@[simp]
theorem swapEquiv_symm : swapEquiv.symm = swapEquiv :=
rfl
end Bipointed
/-- The forgetful functor from `Bipointed` to `Pointed` which forgets about the second point. -/
def bipointedToPointedFst : Bipointed ⥤ Pointed where
obj X := ⟨X, X.toProd.1⟩
map f := ⟨f.toFun, f.map_fst⟩
/-- The forgetful functor from `Bipointed` to `Pointed` which forgets about the first point. -/
def bipointedToPointedSnd : Bipointed ⥤ Pointed where
obj X := ⟨X, X.toProd.2⟩
map f := ⟨f.toFun, f.map_snd⟩
@[simp]
theorem bipointedToPointedFst_comp_forget :
bipointedToPointedFst ⋙ forget Pointed = forget Bipointed :=
rfl
@[simp]
theorem bipointedToPointedSnd_comp_forget :
bipointedToPointedSnd ⋙ forget Pointed = forget Bipointed :=
rfl
@[simp]
theorem swap_comp_bipointedToPointedFst :
Bipointed.swap ⋙ bipointedToPointedFst = bipointedToPointedSnd :=
rfl
@[simp]
theorem swap_comp_bipointedToPointedSnd :
Bipointed.swap ⋙ bipointedToPointedSnd = bipointedToPointedFst :=
rfl
/-- The functor from `Pointed` to `Bipointed` which bipoints the point. -/
def pointedToBipointed : Pointed.{u} ⥤ Bipointed where
obj X := ⟨X, X.point, X.point⟩
map f := ⟨f.toFun, f.map_point, f.map_point⟩
/-- The functor from `Pointed` to `Bipointed` which adds a second point. -/
def pointedToBipointedFst : Pointed.{u} ⥤ Bipointed where
obj X := ⟨Option X, X.point, none⟩
map f := ⟨Option.map f.toFun, congr_arg _ f.map_point, rfl⟩
map_id _ := Bipointed.Hom.ext Option.map_id
map_comp f g := Bipointed.Hom.ext (Option.map_comp_map f.1 g.1).symm
/-- The functor from `Pointed` to `Bipointed` which adds a first point. -/
def pointedToBipointedSnd : Pointed.{u} ⥤ Bipointed where
obj X := ⟨Option X, none, X.point⟩
map f := ⟨Option.map f.toFun, rfl, congr_arg _ f.map_point⟩
map_id _ := Bipointed.Hom.ext Option.map_id
map_comp f g := Bipointed.Hom.ext (Option.map_comp_map f.1 g.1).symm
@[simp]
theorem pointedToBipointedFst_comp_swap :
pointedToBipointedFst ⋙ Bipointed.swap = pointedToBipointedSnd :=
rfl
@[simp]
theorem pointedToBipointedSnd_comp_swap :
pointedToBipointedSnd ⋙ Bipointed.swap = pointedToBipointedFst :=
rfl
/-- `BipointedToPointed_fst` is inverse to `PointedToBipointed`. -/
@[simps!]
def pointedToBipointedCompBipointedToPointedFst :
pointedToBipointed ⋙ bipointedToPointedFst ≅ 𝟭 _ :=
NatIso.ofComponents fun X =>
{ hom := ⟨id, rfl⟩
inv := ⟨id, rfl⟩ }
/-- `BipointedToPointed_snd` is inverse to `PointedToBipointed`. -/
@[simps!]
def pointedToBipointedCompBipointedToPointedSnd :
pointedToBipointed ⋙ bipointedToPointedSnd ≅ 𝟭 _ :=
NatIso.ofComponents fun X =>
{ hom := ⟨id, rfl⟩
inv := ⟨id, rfl⟩ }
/-- The free/forgetful adjunction between `PointedToBipointed_fst` and `BipointedToPointed_fst`.
-/
def pointedToBipointedFstBipointedToPointedFstAdjunction :
pointedToBipointedFst ⊣ bipointedToPointedFst :=
Adjunction.mkOfHomEquiv
{ homEquiv := fun X Y =>
{ toFun := fun f => ⟨f.toFun ∘ Option.some, f.map_fst⟩
invFun := fun f => ⟨fun o => o.elim Y.toProd.2 f.toFun, f.map_point, rfl⟩
left_inv := fun f => by
apply Bipointed.Hom.ext
funext x
cases x
· exact f.map_snd.symm
· rfl
right_inv := fun f => Pointed.Hom.ext rfl }
homEquiv_naturality_left_symm := fun f g => by
apply Bipointed.Hom.ext
funext x
cases x <;> rfl }
/-- The free/forgetful adjunction between `PointedToBipointed_snd` and `BipointedToPointed_snd`.
-/
def pointedToBipointedSndBipointedToPointedSndAdjunction :
pointedToBipointedSnd ⊣ bipointedToPointedSnd :=
Adjunction.mkOfHomEquiv
{ homEquiv := fun X Y =>
{ toFun := fun f => ⟨f.toFun ∘ Option.some, f.map_snd⟩
invFun := fun f => ⟨fun o => o.elim Y.toProd.1 f.toFun, rfl, f.map_point⟩
left_inv := fun f => by
apply Bipointed.Hom.ext
funext x
cases x
· exact f.map_fst.symm
· rfl
right_inv := fun f => Pointed.Hom.ext rfl }
homEquiv_naturality_left_symm := fun f g => by
apply Bipointed.Hom.ext
funext x
cases x <;> rfl }
|
CategoryTheory\Category\Cat.lean | /-
Copyright (c) 2019 Yury Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudryashov
-/
import Mathlib.CategoryTheory.ConcreteCategory.Bundled
import Mathlib.CategoryTheory.DiscreteCategory
import Mathlib.CategoryTheory.Types
import Mathlib.CategoryTheory.Bicategory.Strict
/-!
# Category of categories
This file contains the definition of the category `Cat` of all categories.
In this category objects are categories and
morphisms are functors between these categories.
## Implementation notes
Though `Cat` is not a concrete category, we use `bundled` to define
its carrier type.
-/
universe v u
namespace CategoryTheory
open Bicategory
-- intended to be used with explicit universe parameters
/-- Category of categories. -/
@[nolint checkUnivs]
def Cat :=
Bundled Category.{v, u}
namespace Cat
instance : Inhabited Cat :=
⟨⟨Type u, CategoryTheory.types⟩⟩
-- Porting note: maybe this coercion should be defined to be `objects.obj`?
instance : CoeSort Cat (Type u) :=
⟨Bundled.α⟩
instance str (C : Cat.{v, u}) : Category.{v, u} C :=
Bundled.str C
/-- Construct a bundled `Cat` from the underlying type and the typeclass. -/
def of (C : Type u) [Category.{v} C] : Cat.{v, u} :=
Bundled.of C
/-- Bicategory structure on `Cat` -/
instance bicategory : Bicategory.{max v u, max v u} Cat.{v, u} where
Hom C D := C ⥤ D
id C := 𝟭 C
comp F G := F ⋙ G
homCategory := fun _ _ => Functor.category
whiskerLeft {C} {D} {E} F G H η := whiskerLeft F η
whiskerRight {C} {D} {E} F G η H := whiskerRight η H
associator {A} {B} {C} D := Functor.associator
leftUnitor {A} B := Functor.leftUnitor
rightUnitor {A} B := Functor.rightUnitor
pentagon := fun {A} {B} {C} {D} {E}=> Functor.pentagon
triangle {A} {B} {C} := Functor.triangle
/-- `Cat` is a strict bicategory. -/
instance bicategory.strict : Bicategory.Strict Cat.{v, u} where
id_comp {C} {D} F := by cases F; rfl
comp_id {C} {D} F := by cases F; rfl
assoc := by intros; rfl
/-- Category structure on `Cat` -/
instance category : LargeCategory.{max v u} Cat.{v, u} :=
StrictBicategory.category Cat.{v, u}
@[simp]
theorem id_map {C : Cat} {X Y : C} (f : X ⟶ Y) : (𝟙 C : C ⥤ C).map f = f :=
rfl
@[simp]
theorem comp_obj {C D E : Cat} (F : C ⟶ D) (G : D ⟶ E) (X : C) : (F ≫ G).obj X = G.obj (F.obj X) :=
rfl
@[simp]
theorem comp_map {C D E : Cat} (F : C ⟶ D) (G : D ⟶ E) {X Y : C} (f : X ⟶ Y) :
(F ≫ G).map f = G.map (F.map f) :=
rfl
@[simp]
lemma whiskerLeft_app {C D E : Cat} (F : C ⟶ D) {G H : D ⟶ E} (η : G ⟶ H) (X : C) :
(F ◁ η).app X = η.app (F.obj X) :=
rfl
@[simp]
lemma whiskerRight_app {C D E : Cat} {F G : C ⟶ D} (H : D ⟶ E) (η : F ⟶ G) (X : C) :
(η ▷ H).app X = H.map (η.app X) :=
rfl
lemma leftUnitor_hom_app {B C : Cat} (F : B ⟶ C) (X : B) : (λ_ F).hom.app X = eqToHom (by simp) :=
rfl
lemma leftUnitor_inv_app {B C : Cat} (F : B ⟶ C) (X : B) : (λ_ F).inv.app X = eqToHom (by simp) :=
rfl
lemma rightUnitor_hom_app {B C : Cat} (F : B ⟶ C) (X : B) : (ρ_ F).hom.app X = eqToHom (by simp) :=
rfl
lemma rightUnitor_inv_app {B C : Cat} (F : B ⟶ C) (X : B) : (ρ_ F).inv.app X = eqToHom (by simp) :=
rfl
lemma associator_hom_app {B C D E : Cat} (F : B ⟶ C) (G : C ⟶ D) (H : D ⟶ E) (X : B) :
(α_ F G H).hom.app X = eqToHom (by simp) :=
rfl
lemma associator_inv_app {B C D E : Cat} (F : B ⟶ C) (G : C ⟶ D) (H : D ⟶ E) (X : B) :
(α_ F G H).inv.app X = eqToHom (by simp) :=
rfl
/-- Functor that gets the set of objects of a category. It is not
called `forget`, because it is not a faithful functor. -/
def objects : Cat.{v, u} ⥤ Type u where
obj C := C
map F := F.obj
-- Porting note: this instance was needed for CategoryTheory.Category.Cat.Limit
instance (X : Cat.{v, u}) : Category (objects.obj X) := (inferInstance : Category X)
section
attribute [local simp] eqToHom_map
/-- Any isomorphism in `Cat` induces an equivalence of the underlying categories. -/
def equivOfIso {C D : Cat} (γ : C ≅ D) : C ≌ D where
functor := γ.hom
inverse := γ.inv
unitIso := eqToIso <| Eq.symm γ.hom_inv_id
counitIso := eqToIso γ.inv_hom_id
end
end Cat
/-- Embedding `Type` into `Cat` as discrete categories.
This ought to be modelled as a 2-functor!
-/
@[simps]
def typeToCat : Type u ⥤ Cat where
obj X := Cat.of (Discrete X)
map := fun {X} {Y} f => by
dsimp
exact Discrete.functor (Discrete.mk ∘ f)
map_id X := by
apply Functor.ext
· intro X Y f
cases f
simp only [id_eq, eqToHom_refl, Cat.id_map, Category.comp_id, Category.id_comp]
apply ULift.ext
aesop_cat
· aesop_cat
map_comp f g := by apply Functor.ext; aesop_cat
instance : Functor.Faithful typeToCat.{u} where
map_injective {_X} {_Y} _f _g h :=
funext fun x => congr_arg Discrete.as (Functor.congr_obj h ⟨x⟩)
instance : Functor.Full typeToCat.{u} where
map_surjective F := ⟨Discrete.as ∘ F.obj ∘ Discrete.mk, by
apply Functor.ext
· intro x y f
dsimp
apply ULift.ext
aesop_cat
· rintro ⟨x⟩
apply Discrete.ext
rfl⟩
end CategoryTheory
|
CategoryTheory\Category\Factorisation.lean | /-
Copyright (c) 2023 Jakob von Raumer. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jakob von Raumer
-/
import Mathlib.CategoryTheory.Category.Basic
import Mathlib.CategoryTheory.Comma.Arrow
import Mathlib.CategoryTheory.Limits.Shapes.Terminal
/-!
# The Factorisation Category of a Category
`Factorisation f` is the category containing as objects all factorisations of a morphism `f`.
We show that `Factorisation f` always has an initial and a terminal object.
TODO: Show that `Factorisation f` is isomorphic to a comma category in two ways.
TODO: Make `MonoFactorisation f` a special case of a `Factorisation f`.
-/
namespace CategoryTheory
universe v u
variable {C : Type u} [Category.{v} C]
/-- Factorisations of a morphism `f` as a structure, containing, one object, two morphisms,
and the condition that their composition equals `f`. -/
structure Factorisation {X Y : C} (f : X ⟶ Y) where
/-- The midpoint of the factorisation. -/
mid : C
/-- The morphism into the factorisation midpoint. -/
ι : X ⟶ mid
/-- The morphism out of the factorisation midpoint. -/
π : mid ⟶ Y
/-- The factorisation condition. -/
ι_π : ι ≫ π = f := by aesop_cat
attribute [simp] Factorisation.ι_π
namespace Factorisation
variable {X Y : C} {f : X ⟶ Y}
/-- Morphisms of `Factorisation f` consist of morphism between their midpoints and the obvious
commutativity conditions. -/
@[ext]
protected structure Hom (d e : Factorisation f) : Type (max u v) where
/-- The morphism between the midpoints of the factorizations. -/
h : d.mid ⟶ e.mid
/-- The left commuting triangle of the factorization morphism. -/
ι_h : d.ι ≫ h = e.ι := by aesop_cat
/-- The right commuting triangle of the factorization morphism. -/
h_π : h ≫ e.π = d.π := by aesop_cat
attribute [simp] Factorisation.Hom.ι_h Factorisation.Hom.h_π
/-- The identity morphism of `Factorisation f`. -/
@[simps]
protected def Hom.id (d : Factorisation f) : Factorisation.Hom d d where
h := 𝟙 _
/-- Composition of morphisms in `Factorisation f`. -/
@[simps]
protected def Hom.comp {d₁ d₂ d₃ : Factorisation f}
(f : Factorisation.Hom d₁ d₂) (g : Factorisation.Hom d₂ d₃) : Factorisation.Hom d₁ d₃ where
h := f.h ≫ g.h
ι_h := by rw [← Category.assoc, f.ι_h, g.ι_h]
h_π := by rw [Category.assoc, g.h_π, f.h_π]
instance : Category.{max u v} (Factorisation f) where
Hom d e := Factorisation.Hom d e
id d := Factorisation.Hom.id d
comp f g := Factorisation.Hom.comp f g
variable (d : Factorisation f)
/-- The initial object in `Factorisation f`, with the domain of `f` as its midpoint. -/
@[simps]
protected def initial : Factorisation f where
mid := X
ι := 𝟙 _
π := f
/-- The unique morphism out of `Factorisation.initial f`. -/
@[simps]
protected def initialHom (d : Factorisation f) :
Factorisation.Hom (Factorisation.initial : Factorisation f) d where
h := d.ι
instance : Unique ((Factorisation.initial : Factorisation f) ⟶ d) where
default := Factorisation.initialHom d
uniq f := by apply Factorisation.Hom.ext; simp [← f.ι_h]
/-- The terminal object in `Factorisation f`, with the codomain of `f` as its midpoint. -/
@[simps]
protected def terminal : Factorisation f where
mid := Y
ι := f
π := 𝟙 _
/-- The unique morphism into `Factorisation.terminal f`. -/
@[simps]
protected def terminalHom (d : Factorisation f) :
Factorisation.Hom d (Factorisation.terminal : Factorisation f) where
h := d.π
instance : Unique (d ⟶ (Factorisation.terminal : Factorisation f)) where
default := Factorisation.terminalHom d
uniq f := by apply Factorisation.Hom.ext; simp [← f.h_π]
open Limits
/-- The initial factorisation is an initial object -/
def IsInitial_initial : IsInitial (Factorisation.initial : Factorisation f) := IsInitial.ofUnique _
instance : HasInitial (Factorisation f) := Limits.hasInitial_of_unique Factorisation.initial
/-- The terminal factorisation is a terminal object -/
def IsTerminal_terminal : IsTerminal (Factorisation.terminal : Factorisation f) :=
IsTerminal.ofUnique _
instance : HasTerminal (Factorisation f) := Limits.hasTerminal_of_unique Factorisation.terminal
/-- The forgetful functor from `Factorisation f` to the underlying category `C`. -/
@[simps]
def forget : Factorisation f ⥤ C where
obj := Factorisation.mid
map f := f.h
end Factorisation
end CategoryTheory
|
CategoryTheory\Category\GaloisConnection.lean | /-
Copyright (c) 2017 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Stephen Morgan, Scott Morrison, Johannes Hölzl, Reid Barton
-/
import Mathlib.CategoryTheory.Category.Preorder
import Mathlib.CategoryTheory.Adjunction.Basic
import Mathlib.Order.GaloisConnection
/-!
# Galois connections between preorders are adjunctions.
* `GaloisConnection.adjunction` is the adjunction associated to a galois connection.
-/
universe u v
section
variable {X : Type u} {Y : Type v} [Preorder X] [Preorder Y]
/-- A galois connection between preorders induces an adjunction between the associated categories.
-/
def GaloisConnection.adjunction {l : X → Y} {u : Y → X} (gc : GaloisConnection l u) :
gc.monotone_l.functor ⊣ gc.monotone_u.functor :=
CategoryTheory.Adjunction.mkOfHomEquiv
{ homEquiv := fun X Y =>
{ toFun := fun f => CategoryTheory.homOfLE (gc.le_u f.le)
invFun := fun f => CategoryTheory.homOfLE (gc.l_le f.le)
left_inv := by aesop_cat
right_inv := by aesop_cat } }
end
namespace CategoryTheory
variable {X : Type u} {Y : Type v} [Preorder X] [Preorder Y]
/-- An adjunction between preorder categories induces a galois connection.
-/
theorem Adjunction.gc {L : X ⥤ Y} {R : Y ⥤ X} (adj : L ⊣ R) : GaloisConnection L.obj R.obj :=
fun x y =>
⟨fun h => ((adj.homEquiv x y).toFun h.hom).le, fun h => ((adj.homEquiv x y).invFun h.hom).le⟩
end CategoryTheory
|
CategoryTheory\Category\Grpd.lean | /-
Copyright (c) 2019 Yury Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudryashov
-/
import Mathlib.CategoryTheory.SingleObj
import Mathlib.CategoryTheory.Limits.Shapes.Products
/-!
# Category of groupoids
This file contains the definition of the category `Grpd` of all groupoids.
In this category objects are groupoids and morphisms are functors
between these groupoids.
We also provide two “forgetting” functors: `objects : Grpd ⥤ Type`
and `forgetToCat : Grpd ⥤ Cat`.
## Implementation notes
Though `Grpd` is not a concrete category, we use `Bundled` to define
its carrier type.
-/
universe v u
namespace CategoryTheory
-- intended to be used with explicit universe parameters
/-- Category of groupoids -/
@[nolint checkUnivs]
def Grpd :=
Bundled Groupoid.{v, u}
namespace Grpd
instance : Inhabited Grpd :=
⟨Bundled.of (SingleObj PUnit)⟩
instance str' (C : Grpd.{v, u}) : Groupoid.{v, u} C.α :=
C.str
instance : CoeSort Grpd Type* :=
Bundled.coeSort
/-- Construct a bundled `Grpd` from the underlying type and the typeclass `Groupoid`. -/
def of (C : Type u) [Groupoid.{v} C] : Grpd.{v, u} :=
Bundled.of C
@[simp]
theorem coe_of (C : Type u) [Groupoid C] : (of C : Type u) = C :=
rfl
/-- Category structure on `Grpd` -/
instance category : LargeCategory.{max v u} Grpd.{v, u} where
Hom C D := C ⥤ D
id C := 𝟭 C
comp F G := F ⋙ G
id_comp _ := rfl
comp_id _ := rfl
assoc := by intros; rfl
/-- Functor that gets the set of objects of a groupoid. It is not
called `forget`, because it is not a faithful functor. -/
def objects : Grpd.{v, u} ⥤ Type u where
obj := Bundled.α
map F := F.obj
/-- Forgetting functor to `Cat` -/
def forgetToCat : Grpd.{v, u} ⥤ Cat.{v, u} where
obj C := Cat.of C
map := id
instance forgetToCat_full : forgetToCat.Full where map_surjective f := ⟨f, rfl⟩
instance forgetToCat_faithful : forgetToCat.Faithful where
/-- Convert arrows in the category of groupoids to functors,
which sometimes helps in applying simp lemmas -/
theorem hom_to_functor {C D E : Grpd.{v, u}} (f : C ⟶ D) (g : D ⟶ E) : f ≫ g = f ⋙ g :=
rfl
/-- Converts identity in the category of groupoids to the functor identity -/
theorem id_to_functor {C : Grpd.{v, u}} : 𝟭 C = 𝟙 C :=
rfl
section Products
/-- Construct the product over an indexed family of groupoids, as a fan. -/
def piLimitFan ⦃J : Type u⦄ (F : J → Grpd.{u, u}) : Limits.Fan F :=
Limits.Fan.mk (@of (∀ j : J, F j) _) fun j => CategoryTheory.Pi.eval _ j
/-- The product fan over an indexed family of groupoids, is a limit cone. -/
def piLimitFanIsLimit ⦃J : Type u⦄ (F : J → Grpd.{u, u}) : Limits.IsLimit (piLimitFan F) :=
Limits.mkFanLimit (piLimitFan F) (fun s => Functor.pi' fun j => s.proj j)
(by
intros
dsimp only [piLimitFan]
simp [hom_to_functor])
(by
intro s m w
apply Functor.pi_ext
intro j; specialize w j
simpa)
instance has_pi : Limits.HasProducts.{u} Grpd.{u, u} :=
Limits.hasProducts_of_limit_fans (by apply piLimitFan) (by apply piLimitFanIsLimit)
/-- The product of a family of groupoids is isomorphic
to the product object in the category of Groupoids -/
noncomputable def piIsoPi (J : Type u) (f : J → Grpd.{u, u}) : @of (∀ j, f j) _ ≅ ∏ᶜ f :=
Limits.IsLimit.conePointUniqueUpToIso (piLimitFanIsLimit f)
(Limits.limit.isLimit (Discrete.functor f))
@[simp]
theorem piIsoPi_hom_π (J : Type u) (f : J → Grpd.{u, u}) (j : J) :
(piIsoPi J f).hom ≫ Limits.Pi.π f j = CategoryTheory.Pi.eval _ j := by
simp [piIsoPi]
rfl
end Products
end Grpd
end CategoryTheory
|
CategoryTheory\Category\Init.lean | /-
Copyright (c) 2023 Jannis Limperg. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jannis Limperg
-/
import Aesop
/-!
# Category Theory Rule Set
This module defines the `CategoryTheory` Aesop rule set which is used by the
`aesop_cat` tactic. Aesop rule sets only become visible once the file in which
they're declared is imported, so we must put this declaration into its own file.
-/
declare_aesop_rule_sets [CategoryTheory]
|
CategoryTheory\Category\KleisliCat.lean | /-
Copyright (c) 2018 Simon Hudon. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Simon Hudon
-/
import Mathlib.CategoryTheory.Category.Basic
/-!
# The Kleisli construction on the Type category
Define the Kleisli category for (control) monads.
`CategoryTheory/Monad/Kleisli` defines the general version for a monad on `C`, and demonstrates
the equivalence between the two.
## TODO
Generalise this to work with CategoryTheory.Monad
-/
universe u v
namespace CategoryTheory
-- This file is about Lean 3 declaration "Kleisli".
/-- The Kleisli category on the (type-)monad `m`. Note that the monad is not assumed to be lawful
yet. -/
@[nolint unusedArguments]
def KleisliCat (_ : Type u → Type v) :=
Type u
/-- Construct an object of the Kleisli category from a type. -/
def KleisliCat.mk (m) (α : Type u) : KleisliCat m :=
α
instance KleisliCat.categoryStruct {m} [Monad.{u, v} m] :
CategoryStruct (KleisliCat m) where
Hom α β := α → m β
id _ x := pure x
comp f g := f >=> g
instance KleisliCat.category {m} [Monad.{u, v} m] [LawfulMonad m] : Category (KleisliCat m) := by
-- Porting note: was
-- refine' { id_comp' := _, comp_id' := _, assoc' := _ } <;> intros <;> ext <;> unfold_projs <;>
-- simp only [(· >=> ·), functor_norm]
refine { id_comp := ?_, comp_id := ?_, assoc := ?_ } <;> intros <;>
refine funext (fun x => ?_) <;>
simp (config := { unfoldPartialApp := true }) [CategoryStruct.id, CategoryStruct.comp, (· >=> ·)]
@[simp]
theorem KleisliCat.id_def {m} [Monad m] (α : KleisliCat m) : 𝟙 α = @pure m _ α :=
rfl
theorem KleisliCat.comp_def {m} [Monad m] (α β γ : KleisliCat m) (xs : α ⟶ β) (ys : β ⟶ γ) (a : α) :
(xs ≫ ys) a = xs a >>= ys :=
rfl
instance : Inhabited (KleisliCat id) :=
⟨PUnit⟩
instance {α : Type u} [Inhabited α] : Inhabited (KleisliCat.mk id α) :=
⟨show α from default⟩
end CategoryTheory
|
CategoryTheory\Category\Pairwise.lean | /-
Copyright (c) 2020 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Scott Morrison
-/
import Mathlib.Order.CompleteLattice
import Mathlib.CategoryTheory.Category.Preorder
import Mathlib.CategoryTheory.Limits.IsLimit
/-!
# The category of "pairwise intersections".
Given `ι : Type v`, we build the diagram category `Pairwise ι`
with objects `single i` and `pair i j`, for `i j : ι`,
whose only non-identity morphisms are
`left : pair i j ⟶ single i` and `right : pair i j ⟶ single j`.
We use this later in describing (one formulation of) the sheaf condition.
Given any function `U : ι → α`, where `α` is some complete lattice (e.g. `(Opens X)ᵒᵖ`),
we produce a functor `Pairwise ι ⥤ α` in the obvious way,
and show that `iSup U` provides a colimit cocone over this functor.
-/
noncomputable section
universe v u
open CategoryTheory
open CategoryTheory.Limits
namespace CategoryTheory
/-- An inductive type representing either a single term of a type `ι`, or a pair of terms.
We use this as the objects of a category to describe the sheaf condition.
-/
inductive Pairwise (ι : Type v)
| single : ι → Pairwise ι
| pair : ι → ι → Pairwise ι
variable {ι : Type v}
namespace Pairwise
instance pairwiseInhabited [Inhabited ι] : Inhabited (Pairwise ι) :=
⟨single default⟩
/-- Morphisms in the category `Pairwise ι`. The only non-identity morphisms are
`left i j : single i ⟶ pair i j` and `right i j : single j ⟶ pair i j`.
-/
inductive Hom : Pairwise ι → Pairwise ι → Type v
| id_single : ∀ i, Hom (single i) (single i)
| id_pair : ∀ i j, Hom (pair i j) (pair i j)
| left : ∀ i j, Hom (pair i j) (single i)
| right : ∀ i j, Hom (pair i j) (single j)
open Hom
instance homInhabited [Inhabited ι] : Inhabited (Hom (single (default : ι)) (single default)) :=
⟨id_single default⟩
/-- The identity morphism in `Pairwise ι`.
-/
def id : ∀ o : Pairwise ι, Hom o o
| single i => id_single i
| pair i j => id_pair i j
/-- Composition of morphisms in `Pairwise ι`. -/
def comp : ∀ {o₁ o₂ o₃ : Pairwise ι} (_ : Hom o₁ o₂) (_ : Hom o₂ o₃), Hom o₁ o₃
| _, _, _, id_single _, g => g
| _, _, _, id_pair _ _, g => g
| _, _, _, left i j, id_single _ => left i j
| _, _, _, right i j, id_single _ => right i j
section
open Lean Elab Tactic in
/-- A helper tactic for `aesop_cat` and `Pairwise`. -/
def pairwiseCases : TacticM Unit := do
evalTactic (← `(tactic| casesm* (_ : Pairwise _) ⟶ (_ : Pairwise _)))
attribute [local aesop safe tactic (rule_sets := [CategoryTheory])] pairwiseCases in
instance : Category (Pairwise ι) where
Hom := Hom
id := id
comp f g := comp f g
end
variable {α : Type v} (U : ι → α)
section
variable [SemilatticeInf α]
/-- Auxiliary definition for `diagram`. -/
@[simp]
def diagramObj : Pairwise ι → α
| single i => U i
| pair i j => U i ⊓ U j
/-- Auxiliary definition for `diagram`. -/
@[simp]
def diagramMap : ∀ {o₁ o₂ : Pairwise ι} (_ : o₁ ⟶ o₂), diagramObj U o₁ ⟶ diagramObj U o₂
| _, _, id_single _ => 𝟙 _
| _, _, id_pair _ _ => 𝟙 _
| _, _, left _ _ => homOfLE inf_le_left
| _, _, right _ _ => homOfLE inf_le_right
-- Porting note: the fields map_id and map_comp were filled by hand, as generating them by `aesop`
-- causes a PANIC.
/-- Given a function `U : ι → α` for `[SemilatticeInf α]`, we obtain a functor `Pairwise ι ⥤ α`,
sending `single i` to `U i` and `pair i j` to `U i ⊓ U j`,
and the morphisms to the obvious inequalities.
-/
-- Porting note: We want `@[simps]` here, but this causes a PANIC in the linter.
-- (Which, worryingly, does not cause a linter failure!)
-- @[simps]
def diagram : Pairwise ι ⥤ α where
obj := diagramObj U
map := diagramMap U
end
section
-- `CompleteLattice` is not really needed, as we only ever use `inf`,
-- but the appropriate structure has not been defined.
variable [CompleteLattice α]
/-- Auxiliary definition for `cocone`. -/
def coconeιApp : ∀ o : Pairwise ι, diagramObj U o ⟶ iSup U
| single i => homOfLE (le_iSup U i)
| pair i _ => homOfLE inf_le_left ≫ homOfLE (le_iSup U i)
/-- Given a function `U : ι → α` for `[CompleteLattice α]`,
`iSup U` provides a cocone over `diagram U`.
-/
@[simps]
def cocone : Cocone (diagram U) where
pt := iSup U
ι := { app := coconeιApp U }
/-- Given a function `U : ι → α` for `[CompleteLattice α]`,
`iInf U` provides a limit cone over `diagram U`.
-/
def coconeIsColimit : IsColimit (cocone U) where
desc s := homOfLE
(by
apply CompleteSemilatticeSup.sSup_le
rintro _ ⟨j, rfl⟩
exact (s.ι.app (single j)).le)
end
end Pairwise
end CategoryTheory
|
CategoryTheory\Category\PartialFun.lean | /-
Copyright (c) 2022 Yaël Dillies. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yaël Dillies
-/
import Mathlib.CategoryTheory.Category.Pointed
import Mathlib.Data.PFun
/-!
# The category of types with partial functions
This defines `PartialFun`, the category of types equipped with partial functions.
This category is classically equivalent to the category of pointed types. The reason it doesn't hold
constructively stems from the difference between `Part` and `Option`. Both can model partial
functions, but the latter forces a decidable domain.
Precisely, `PartialFunToPointed` turns a partial function `α →. β` into a function
`Option α → Option β` by sending to `none` the undefined values (and `none` to `none`). But being
defined is (generally) undecidable while being sent to `none` is decidable. So it can't be
constructive.
## References
* [nLab, *The category of sets and partial functions*]
(https://ncatlab.org/nlab/show/partial+function)
-/
open CategoryTheory Option
universe u
variable {α β : Type*}
/-- The category of types equipped with partial functions. -/
def PartialFun : Type _ :=
Type*
namespace PartialFun
instance : CoeSort PartialFun Type* :=
⟨id⟩
-- Porting note(#5171): removed `@[nolint has_nonempty_instance]`; linter not ported yet
/-- Turns a type into a `PartialFun`. -/
def of : Type* → PartialFun :=
id
-- Porting note: removed this lemma which is useless because of the expansion of coercions
instance : Inhabited PartialFun :=
⟨Type*⟩
instance largeCategory : LargeCategory.{u} PartialFun where
Hom := PFun
id := PFun.id
comp f g := g.comp f
id_comp := @PFun.comp_id
comp_id := @PFun.id_comp
assoc _ _ _ := (PFun.comp_assoc _ _ _).symm
/-- Constructs a partial function isomorphism between types from an equivalence between them. -/
@[simps]
def Iso.mk {α β : PartialFun.{u}} (e : α ≃ β) : α ≅ β where
hom x := e x
inv x := e.symm x
hom_inv_id := (PFun.coe_comp _ _).symm.trans (by
simp only [Equiv.symm_comp_self, PFun.coe_id]
rfl)
inv_hom_id := (PFun.coe_comp _ _).symm.trans (by
simp only [Equiv.self_comp_symm, PFun.coe_id]
rfl)
end PartialFun
/-- The forgetful functor from `Type` to `PartialFun` which forgets that the maps are total. -/
def typeToPartialFun : Type u ⥤ PartialFun where
obj := id
map := @PFun.lift
map_comp _ _ := PFun.coe_comp _ _
instance : typeToPartialFun.Faithful where
map_injective {_ _} := PFun.lift_injective
/-- The functor which deletes the point of a pointed type. In return, this makes the maps partial.
This is the computable part of the equivalence `PartialFunEquivPointed`. -/
@[simps obj map]
def pointedToPartialFun : Pointed.{u} ⥤ PartialFun where
obj X := { x : X // x ≠ X.point }
map f := PFun.toSubtype _ f.toFun ∘ Subtype.val
map_id X :=
PFun.ext fun a b => PFun.mem_toSubtype_iff.trans (Subtype.coe_inj.trans Part.mem_some_iff.symm)
map_comp f g := by
-- Porting note: the proof was changed because the original mathlib3 proof no longer works
apply PFun.ext _
rintro ⟨a, ha⟩ ⟨c, hc⟩
constructor
· rintro ⟨h₁, h₂⟩
exact ⟨⟨fun h₀ => h₁ ((congr_arg g.toFun h₀).trans g.map_point), h₁⟩, h₂⟩
· rintro ⟨_, _, _⟩
exact ⟨_, rfl⟩
/-- The functor which maps undefined values to a new point. This makes the maps total and creates
pointed types. This is the noncomputable part of the equivalence `PartialFunEquivPointed`. It can't
be computable because `= Option.none` is decidable while the domain of a general `Part` isn't. -/
@[simps obj map]
noncomputable def partialFunToPointed : PartialFun ⥤ Pointed := by
classical
exact
{ obj := fun X => ⟨Option X, none⟩
map := fun f => ⟨Option.elim' none fun a => (f a).toOption, rfl⟩
map_id := fun X => Pointed.Hom.ext <| funext fun o => Option.recOn o rfl fun a => (by
dsimp [CategoryStruct.id]
convert Part.some_toOption a)
map_comp := fun f g => Pointed.Hom.ext <| funext fun o => Option.recOn o rfl fun a => by
dsimp [CategoryStruct.comp]
rw [Part.bind_toOption g (f a), Option.elim'_eq_elim] }
/-- The equivalence induced by `PartialFunToPointed` and `PointedToPartialFun`.
`Part.equivOption` made functorial. -/
@[simps!]
noncomputable def partialFunEquivPointed : PartialFun.{u} ≌ Pointed :=
CategoryTheory.Equivalence.mk partialFunToPointed pointedToPartialFun
(NatIso.ofComponents (fun X => PartialFun.Iso.mk
{ toFun := fun a => ⟨some a, some_ne_none a⟩
invFun := fun a => Option.get _ (Option.ne_none_iff_isSome.1 a.2)
left_inv := fun a => Option.get_some _ _
right_inv := fun a => by simp only [some_get, Subtype.coe_eta] })
fun f =>
PFun.ext fun a b => by
dsimp [PartialFun.Iso.mk, CategoryStruct.comp, pointedToPartialFun]
rw [Part.bind_some]
-- Porting note: the proof below has changed a lot because
-- `Part.mem_bind_iff` means that `b ∈ Part.bind f g` is equivalent
-- to `∃ (a : α), a ∈ f ∧ b ∈ g a`, while in mathlib3 it was equivalent
-- to `∃ (a : α) (H : a ∈ f), b ∈ g a`
refine (Part.mem_bind_iff.trans ?_).trans PFun.mem_toSubtype_iff.symm
obtain ⟨b | b, hb⟩ := b
· exact (hb rfl).elim
· dsimp [Part.toOption]
simp_rw [Part.mem_some_iff, Subtype.mk_eq_mk]
constructor
· rintro ⟨_, ⟨h₁, h₂⟩, h₃⟩
rw [h₃, ← h₂, dif_pos h₁]
· intro h
split_ifs at h with ha
rw [some_inj] at h
exact ⟨b, ⟨ha, h.symm⟩, rfl⟩) $
NatIso.ofComponents
(fun X ↦ Pointed.Iso.mk (by classical exact Equiv.optionSubtypeNe X.point) (by rfl))
fun {X Y} f ↦ Pointed.Hom.ext <| funext fun a ↦ by
obtain _ | ⟨a, ha⟩ := a
· exact f.map_point.symm
simp_all [Option.casesOn'_eq_elim, Part.elim_toOption]
/-- Forgetting that maps are total and making them total again by adding a point is the same as just
adding a point. -/
@[simps!]
noncomputable def typeToPartialFunIsoPartialFunToPointed :
typeToPartialFun ⋙ partialFunToPointed ≅ typeToPointed :=
NatIso.ofComponents
(fun X =>
{ hom := ⟨id, rfl⟩
inv := ⟨id, rfl⟩
hom_inv_id := rfl
inv_hom_id := rfl })
fun f =>
Pointed.Hom.ext <|
funext fun a => Option.recOn a rfl fun a => by
convert Part.some_toOption _
simpa using (Part.get_eq_iff_mem (by trivial)).mp rfl
|
CategoryTheory\Category\Pointed.lean | /-
Copyright (c) 2022 Yaël Dillies. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yaël Dillies
-/
import Mathlib.CategoryTheory.ConcreteCategory.Basic
import Mathlib.CategoryTheory.Adjunction.Basic
/-!
# The category of pointed types
This defines `Pointed`, the category of pointed types.
## TODO
* Monoidal structure
* Upgrade `typeToPointed` to an equivalence
-/
open CategoryTheory
universe u
variable {α β : Type*}
/-- The category of pointed types. -/
structure Pointed : Type (u + 1) where
/-- the underlying type -/
X : Type u
/-- the distinguished element -/
point : X
namespace Pointed
instance : CoeSort Pointed Type* :=
⟨X⟩
-- Porting note: protected attribute does not work
--attribute [protected] Pointed.X
/-- Turns a point into a pointed type. -/
def of {X : Type*} (point : X) : Pointed :=
⟨X, point⟩
@[simp]
theorem coe_of {X : Type*} (point : X) : ↥(of point) = X :=
rfl
alias _root_.Prod.Pointed := of
instance : Inhabited Pointed :=
⟨of ((), ())⟩
/-- Morphisms in `Pointed`. -/
@[ext]
protected structure Hom (X Y : Pointed.{u}) : Type u where
/-- the underlying map -/
toFun : X → Y
/-- compatibility with the distinguished points -/
map_point : toFun X.point = Y.point
namespace Hom
/-- The identity morphism of `X : Pointed`. -/
@[simps]
def id (X : Pointed) : Pointed.Hom X X :=
⟨_root_.id, rfl⟩
instance (X : Pointed) : Inhabited (Pointed.Hom X X) :=
⟨id X⟩
/-- Composition of morphisms of `Pointed`. -/
@[simps]
def comp {X Y Z : Pointed.{u}} (f : Pointed.Hom X Y) (g : Pointed.Hom Y Z) : Pointed.Hom X Z :=
⟨g.toFun ∘ f.toFun, by rw [Function.comp_apply, f.map_point, g.map_point]⟩
end Hom
instance largeCategory : LargeCategory Pointed where
Hom := Pointed.Hom
id := Hom.id
comp := @Hom.comp
@[simp] lemma Hom.id_toFun' (X : Pointed.{u}) : (𝟙 X : X ⟶ X).toFun = _root_.id := rfl
@[simp] lemma Hom.comp_toFun' {X Y Z : Pointed.{u}} (f : X ⟶ Y) (g : Y ⟶ Z) :
(f ≫ g).toFun = g.toFun ∘ f.toFun := rfl
instance concreteCategory : ConcreteCategory Pointed where
forget :=
{ obj := Pointed.X
map := @Hom.toFun }
forget_faithful := ⟨@Hom.ext⟩
/-- Constructs an isomorphism between pointed types from an equivalence that preserves the point
between them. -/
@[simps]
def Iso.mk {α β : Pointed} (e : α ≃ β) (he : e α.point = β.point) : α ≅ β where
hom := ⟨e, he⟩
inv := ⟨e.symm, e.symm_apply_eq.2 he.symm⟩
hom_inv_id := Pointed.Hom.ext e.symm_comp_self
inv_hom_id := Pointed.Hom.ext e.self_comp_symm
end Pointed
/-- `Option` as a functor from types to pointed types. This is the free functor. -/
@[simps]
def typeToPointed : Type u ⥤ Pointed.{u} where
obj X := ⟨Option X, none⟩
map f := ⟨Option.map f, rfl⟩
map_id _ := Pointed.Hom.ext Option.map_id
map_comp _ _ := Pointed.Hom.ext (Option.map_comp_map _ _).symm
/-- `typeToPointed` is the free functor. -/
def typeToPointedForgetAdjunction : typeToPointed ⊣ forget Pointed :=
Adjunction.mkOfHomEquiv
{ homEquiv := fun X Y =>
{ toFun := fun f => f.toFun ∘ Option.some
invFun := fun f => ⟨fun o => o.elim Y.point f, rfl⟩
left_inv := fun f => by
apply Pointed.Hom.ext
funext x
cases x
· exact f.map_point.symm
· rfl
right_inv := fun f => funext fun _ => rfl }
homEquiv_naturality_left_symm := fun f g => by
apply Pointed.Hom.ext
funext x
cases x <;> rfl }
|
CategoryTheory\Category\Preorder.lean | /-
Copyright (c) 2017 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Stephen Morgan, Scott Morrison, Johannes Hölzl, Reid Barton
-/
import Mathlib.CategoryTheory.Equivalence
import Mathlib.CategoryTheory.EqToHom
import Mathlib.Order.Hom.Basic
import Mathlib.Data.ULift
/-!
# Preorders as categories
We install a category instance on any preorder. This is not to be confused with the category _of_
preorders, defined in `Order.Category.Preorder`.
We show that monotone functions between preorders correspond to functors of the associated
categories.
## Main definitions
* `homOfLE` and `leOfHom` provide translations between inequalities in the preorder, and
morphisms in the associated category.
* `Monotone.functor` is the functor associated to a monotone function.
-/
universe u v
namespace Preorder
open CategoryTheory
-- see Note [lower instance priority]
/--
The category structure coming from a preorder. There is a morphism `X ⟶ Y` if and only if `X ≤ Y`.
Because we don't allow morphisms to live in `Prop`,
we have to define `X ⟶ Y` as `ULift (PLift (X ≤ Y))`.
See `CategoryTheory.homOfLE` and `CategoryTheory.leOfHom`.
See <https://stacks.math.columbia.edu/tag/00D3>.
-/
instance (priority := 100) smallCategory (α : Type u) [Preorder α] : SmallCategory α where
Hom U V := ULift (PLift (U ≤ V))
id X := ⟨⟨le_refl X⟩⟩
comp f g := ⟨⟨le_trans _ _ _ f.down.down g.down.down⟩⟩
-- Porting note: added to ease the port of `CategoryTheory.Subobject.Basic`
instance subsingleton_hom {α : Type u} [Preorder α] (U V : α) :
Subsingleton (U ⟶ V) := ⟨fun _ _ => ULift.ext _ _ (Subsingleton.elim _ _ )⟩
end Preorder
namespace CategoryTheory
open Opposite
variable {X : Type u} [Preorder X]
/-- Express an inequality as a morphism in the corresponding preorder category.
-/
def homOfLE {x y : X} (h : x ≤ y) : x ⟶ y :=
ULift.up (PLift.up h)
@[inherit_doc homOfLE]
abbrev _root_.LE.le.hom := @homOfLE
@[simp]
theorem homOfLE_refl {x : X} (h : x ≤ x) : h.hom = 𝟙 x :=
rfl
@[simp]
theorem homOfLE_comp {x y z : X} (h : x ≤ y) (k : y ≤ z) :
homOfLE h ≫ homOfLE k = homOfLE (h.trans k) :=
rfl
/-- Extract the underlying inequality from a morphism in a preorder category.
-/
theorem leOfHom {x y : X} (h : x ⟶ y) : x ≤ y :=
h.down.down
@[nolint defLemma, inherit_doc leOfHom]
abbrev _root_.Quiver.Hom.le := @leOfHom
-- Porting note: why does this lemma exist? With proof irrelevance, we don't need to simplify proofs
-- @[simp]
theorem leOfHom_homOfLE {x y : X} (h : x ≤ y) : h.hom.le = h :=
rfl
-- Porting note: linter gives: "Left-hand side does not simplify, when using the simp lemma on
-- itself. This usually means that it will never apply." removing simp? It doesn't fire
-- @[simp]
theorem homOfLE_leOfHom {x y : X} (h : x ⟶ y) : h.le.hom = h :=
rfl
lemma homOfLE_isIso_of_eq {x y : X} (h : x ≤ y) (heq : x = y) :
IsIso (homOfLE h) :=
⟨homOfLE (le_of_eq heq.symm), by simp⟩
@[simp, reassoc]
lemma homOfLE_comp_eqToHom {a b c : X} (hab : a ≤ b) (hbc : b = c) :
homOfLE hab ≫ eqToHom hbc = homOfLE (hab.trans (le_of_eq hbc)) :=
rfl
@[simp, reassoc]
lemma eqToHom_comp_homOfLE {a b c : X} (hab : a = b) (hbc : b ≤ c) :
eqToHom hab ≫ homOfLE hbc = homOfLE ((le_of_eq hab).trans hbc) :=
rfl
@[simp, reassoc]
lemma homOfLE_op_comp_eqToHom {a b c : X} (hab : b ≤ a) (hbc : op b = op c) :
(homOfLE hab).op ≫ eqToHom hbc = (homOfLE ((le_of_eq (op_injective hbc.symm)).trans hab)).op :=
rfl
@[simp, reassoc]
lemma eqToHom_comp_homOfLE_op {a b c : X} (hab : op a = op b) (hbc : c ≤ b) :
eqToHom hab ≫ (homOfLE hbc).op = (homOfLE (hbc.trans (le_of_eq (op_injective hab.symm)))).op :=
rfl
/-- Construct a morphism in the opposite of a preorder category from an inequality. -/
def opHomOfLE {x y : Xᵒᵖ} (h : unop x ≤ unop y) : y ⟶ x :=
(homOfLE h).op
theorem le_of_op_hom {x y : Xᵒᵖ} (h : x ⟶ y) : unop y ≤ unop x :=
h.unop.le
instance uniqueToTop [OrderTop X] {x : X} : Unique (x ⟶ ⊤) where
default := homOfLE le_top
uniq := fun a => by rfl
instance uniqueFromBot [OrderBot X] {x : X} : Unique (⊥ ⟶ x) where
default := homOfLE bot_le
uniq := fun a => by rfl
variable (X) in
/-- The equivalence of categories from the order dual of a preordered type `X`
to the opposite category of the preorder `X`. -/
@[simps]
def orderDualEquivalence : Xᵒᵈ ≌ Xᵒᵖ where
functor :=
{ obj := fun x => op (OrderDual.ofDual x)
map := fun f => (homOfLE (leOfHom f)).op }
inverse :=
{ obj := fun x => OrderDual.toDual x.unop
map := fun f => (homOfLE (leOfHom f.unop)) }
unitIso := Iso.refl _
counitIso := Iso.refl _
end CategoryTheory
section
open CategoryTheory
variable {X : Type u} {Y : Type v} [Preorder X] [Preorder Y]
/-- A monotone function between preorders induces a functor between the associated categories.
-/
def Monotone.functor {f : X → Y} (h : Monotone f) : X ⥤ Y where
obj := f
map g := CategoryTheory.homOfLE (h g.le)
@[simp]
theorem Monotone.functor_obj {f : X → Y} (h : Monotone f) : h.functor.obj = f :=
rfl
-- Faithfulness is automatic because preorder categories are thin
instance (f : X ↪o Y) : f.monotone.functor.Full where
map_surjective h := ⟨homOfLE (f.map_rel_iff.1 h.le), rfl⟩
/-- The equivalence of categories `X ≌ Y` induced by `e : X ≃o Y`. -/
@[simps]
def OrderIso.equivalence (e : X ≃o Y) : X ≌ Y where
functor := e.monotone.functor
inverse := e.symm.monotone.functor
unitIso := NatIso.ofComponents (fun _ ↦ eqToIso (by simp))
counitIso := NatIso.ofComponents (fun _ ↦ eqToIso (by simp))
end
namespace CategoryTheory
section Preorder
variable {X : Type u} {Y : Type v} [Preorder X] [Preorder Y]
/-- A functor between preorder categories is monotone.
-/
@[mono]
theorem Functor.monotone (f : X ⥤ Y) : Monotone f.obj := fun _ _ hxy => (f.map hxy.hom).le
end Preorder
section PartialOrder
variable {X : Type u} {Y : Type v} [PartialOrder X] [PartialOrder Y]
theorem Iso.to_eq {x y : X} (f : x ≅ y) : x = y :=
le_antisymm f.hom.le f.inv.le
/-- A categorical equivalence between partial orders is just an order isomorphism.
-/
def Equivalence.toOrderIso (e : X ≌ Y) : X ≃o Y where
toFun := e.functor.obj
invFun := e.inverse.obj
left_inv a := (e.unitIso.app a).to_eq.symm
right_inv b := (e.counitIso.app b).to_eq
map_rel_iff' {a a'} :=
⟨fun h =>
((Equivalence.unit e).app a ≫ e.inverse.map h.hom ≫ (Equivalence.unitInv e).app a').le,
fun h : a ≤ a' => (e.functor.map h.hom).le⟩
-- `@[simps]` on `Equivalence.toOrderIso` produces lemmas that fail the `simpNF` linter,
-- so we provide them by hand:
@[simp]
theorem Equivalence.toOrderIso_apply (e : X ≌ Y) (x : X) : e.toOrderIso x = e.functor.obj x :=
rfl
@[simp]
theorem Equivalence.toOrderIso_symm_apply (e : X ≌ Y) (y : Y) :
e.toOrderIso.symm y = e.inverse.obj y :=
rfl
end PartialOrder
end CategoryTheory
|
CategoryTheory\Category\Quiv.lean | /-
Copyright (c) 2021 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Scott Morrison
-/
import Mathlib.CategoryTheory.Adjunction.Basic
import Mathlib.CategoryTheory.Category.Cat
import Mathlib.CategoryTheory.PathCategory
/-!
# The category of quivers
The category of (bundled) quivers, and the free/forgetful adjunction between `Cat` and `Quiv`.
-/
universe v u
namespace CategoryTheory
-- intended to be used with explicit universe parameters
/-- Category of quivers. -/
@[nolint checkUnivs]
def Quiv :=
Bundled Quiver.{v + 1, u}
namespace Quiv
instance : CoeSort Quiv (Type u) where coe := Bundled.α
instance str' (C : Quiv.{v, u}) : Quiver.{v + 1, u} C :=
C.str
/-- Construct a bundled `Quiv` from the underlying type and the typeclass. -/
def of (C : Type u) [Quiver.{v + 1} C] : Quiv.{v, u} :=
Bundled.of C
instance : Inhabited Quiv :=
⟨Quiv.of (Quiver.Empty PEmpty)⟩
/-- Category structure on `Quiv` -/
instance category : LargeCategory.{max v u} Quiv.{v, u} where
Hom C D := Prefunctor C D
id C := Prefunctor.id C
comp F G := Prefunctor.comp F G
/-- The forgetful functor from categories to quivers. -/
@[simps]
def forget : Cat.{v, u} ⥤ Quiv.{v, u} where
obj C := Quiv.of C
map F := F.toPrefunctor
end Quiv
namespace Cat
/-- The functor sending each quiver to its path category. -/
@[simps]
def free : Quiv.{v, u} ⥤ Cat.{max u v, u} where
obj V := Cat.of (Paths V)
map F :=
{ obj := fun X => F.obj X
map := fun f => F.mapPath f
map_comp := fun f g => F.mapPath_comp f g }
map_id V := by
change (show Paths V ⥤ _ from _) = _
ext; swap
· apply eq_conj_eqToHom
· rfl
map_comp {U _ _} F G := by
change (show Paths U ⥤ _ from _) = _
ext; swap
· apply eq_conj_eqToHom
· rfl
end Cat
namespace Quiv
/-- Any prefunctor into a category lifts to a functor from the path category. -/
@[simps]
def lift {V : Type u} [Quiver.{v + 1} V] {C : Type*} [Category C] (F : Prefunctor V C) :
Paths V ⥤ C where
obj X := F.obj X
map f := composePath (F.mapPath f)
-- We might construct `of_lift_iso_self : Paths.of ⋙ lift F ≅ F`
-- (and then show that `lift F` is initial amongst such functors)
-- but it would require lifting quite a bit of machinery to quivers!
/--
The adjunction between forming the free category on a quiver, and forgetting a category to a quiver.
-/
def adj : Cat.free ⊣ Quiv.forget :=
Adjunction.mkOfHomEquiv
{ homEquiv := fun V C =>
{ toFun := fun F => Paths.of.comp F.toPrefunctor
invFun := fun F => @lift V _ C _ F
left_inv := fun F => Paths.ext_functor rfl (by simp)
right_inv := by
rintro ⟨obj, map⟩
dsimp only [Prefunctor.comp]
congr
funext X Y f
exact Category.id_comp _ }
homEquiv_naturality_left_symm := fun {V _ _} f g => by
change (show Paths V ⥤ _ from _) = _
ext; swap
· apply eq_conj_eqToHom
· rfl }
end Quiv
end CategoryTheory
|
CategoryTheory\Category\RelCat.lean | /-
Copyright (c) 2019 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Scott Morrison, Uni Marx
-/
import Mathlib.CategoryTheory.Iso
import Mathlib.CategoryTheory.EssentialImage
import Mathlib.CategoryTheory.Types
import Mathlib.CategoryTheory.Opposites
import Mathlib.Data.Rel
/-!
# Basics on the category of relations
We define the category of types `CategoryTheory.RelCat` with binary relations as morphisms.
Associating each function with the relation defined by its graph yields a faithful and
essentially surjective functor `graphFunctor` that also characterizes all isomorphisms
(see `rel_iso_iff`).
By flipping the arguments to a relation, we construct an equivalence `opEquivalence` between
`RelCat` and its opposite.
-/
namespace CategoryTheory
universe u
-- This file is about Lean 3 declaration "Rel".
/-- A type synonym for `Type`, which carries the category instance for which
morphisms are binary relations. -/
def RelCat :=
Type u
instance RelCat.inhabited : Inhabited RelCat := by unfold RelCat; infer_instance
/-- The category of types with binary relations as morphisms. -/
instance rel : LargeCategory RelCat where
Hom X Y := X → Y → Prop
id X x y := x = y
comp f g x z := ∃ y, f x y ∧ g y z
namespace RelCat
@[ext] theorem hom_ext {X Y : RelCat} (f g : X ⟶ Y) (h : ∀ a b, f a b ↔ g a b) : f = g :=
funext₂ (fun a b => propext (h a b))
namespace Hom
protected theorem rel_id (X : RelCat) : 𝟙 X = (· = ·) := rfl
protected theorem rel_comp {X Y Z : RelCat} (f : X ⟶ Y) (g : Y ⟶ Z) : f ≫ g = Rel.comp f g := rfl
theorem rel_id_apply₂ (X : RelCat) (x y : X) : (𝟙 X) x y ↔ x = y := by
rw [RelCat.Hom.rel_id]
theorem rel_comp_apply₂ {X Y Z : RelCat} (f : X ⟶ Y) (g : Y ⟶ Z) (x : X) (z : Z) :
(f ≫ g) x z ↔ ∃ y, f x y ∧ g y z := by rfl
end Hom
/-- The essentially surjective faithful embedding
from the category of types and functions into the category of types and relations. -/
def graphFunctor : Type u ⥤ RelCat.{u} where
obj X := X
map f := f.graph
map_id X := by
ext
simp [Hom.rel_id_apply₂]
map_comp f g := by
ext
simp [Hom.rel_comp_apply₂]
@[simp] theorem graphFunctor_map {X Y : Type u} (f : X ⟶ Y) (x : X) (y : Y) :
graphFunctor.map f x y ↔ f x = y := f.graph_def x y
instance graphFunctor_faithful : graphFunctor.Faithful where
map_injective h := Function.graph_injective h
instance graphFunctor_essSurj : graphFunctor.EssSurj :=
graphFunctor.essSurj_of_surj Function.surjective_id
/-- A relation is an isomorphism in `RelCat` iff it is the image of an isomorphism in
`Type`. -/
theorem rel_iso_iff {X Y : RelCat} (r : X ⟶ Y) :
IsIso (C := RelCat) r ↔ ∃ f : (Iso (C := Type) X Y), graphFunctor.map f.hom = r := by
constructor
· intro h
have h1 := congr_fun₂ h.hom_inv_id
have h2 := congr_fun₂ h.inv_hom_id
simp only [RelCat.Hom.rel_comp_apply₂, RelCat.Hom.rel_id_apply₂, eq_iff_iff] at h1 h2
obtain ⟨f, hf⟩ := Classical.axiomOfChoice (fun a => (h1 a a).mpr rfl)
obtain ⟨g, hg⟩ := Classical.axiomOfChoice (fun a => (h2 a a).mpr rfl)
suffices hif : IsIso (C := Type) f by
use asIso f
ext x y
simp only [asIso_hom, graphFunctor_map]
constructor
· rintro rfl
exact (hf x).1
· intro hr
specialize h2 (f x) y
rw [← h2]
use x, (hf x).2, hr
use g
constructor
· ext x
apply (h1 _ _).mp
use f x, (hg _).2, (hf _).2
· ext y
apply (h2 _ _).mp
use g y, (hf (g y)).2, (hg y).2
· rintro ⟨f, rfl⟩
apply graphFunctor.map_isIso
section Opposite
open Opposite
/-- The argument-swap isomorphism from `RelCat` to its opposite. -/
def opFunctor : RelCat ⥤ RelCatᵒᵖ where
obj X := op X
map {X Y} r := op (fun y x => r x y)
map_id X := by
congr
simp only [unop_op, RelCat.Hom.rel_id]
ext x y
exact Eq.comm
map_comp {X Y Z} f g := by
unfold Category.opposite
congr
ext x y
apply exists_congr
exact fun a => And.comm
/-- The other direction of `opFunctor`. -/
def unopFunctor : RelCatᵒᵖ ⥤ RelCat where
obj X := unop X
map {X Y} r x y := unop r y x
map_id X := by
dsimp
ext x y
exact Eq.comm
map_comp {X Y Z} f g := by
unfold Category.opposite
ext x y
apply exists_congr
exact fun a => And.comm
@[simp] theorem opFunctor_comp_unopFunctor_eq :
Functor.comp opFunctor unopFunctor = Functor.id _ := rfl
@[simp] theorem unopFunctor_comp_opFunctor_eq :
Functor.comp unopFunctor opFunctor = Functor.id _ := rfl
/-- `RelCat` is self-dual: The map that swaps the argument order of a
relation induces an equivalence between `RelCat` and its opposite. -/
@[simps]
def opEquivalence : Equivalence RelCat RelCatᵒᵖ where
functor := opFunctor
inverse := unopFunctor
unitIso := Iso.refl _
counitIso := Iso.refl _
instance : opFunctor.IsEquivalence := by
change opEquivalence.functor.IsEquivalence
infer_instance
instance : unopFunctor.IsEquivalence := by
change opEquivalence.inverse.IsEquivalence
infer_instance
end Opposite
end RelCat
end CategoryTheory
|
CategoryTheory\Category\TwoP.lean | /-
Copyright (c) 2022 Yaël Dillies. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yaël Dillies
-/
import Mathlib.CategoryTheory.Category.Bipointed
import Mathlib.Data.TwoPointing
/-!
# The category of two-pointed types
This defines `TwoP`, the category of two-pointed types.
## References
* [nLab, *coalgebra of the real interval*]
(https://ncatlab.org/nlab/show/coalgebra+of+the+real+interval)
-/
open CategoryTheory Option
universe u
variable {α β : Type*}
/-- The category of two-pointed types. -/
structure TwoP : Type (u + 1) where
/-- The underlying type of a two-pointed type. -/
protected X : Type u
/-- The two points of a bipointed type, bundled together as a pair of distinct elements. -/
toTwoPointing : TwoPointing X
namespace TwoP
instance : CoeSort TwoP Type* :=
⟨TwoP.X⟩
/-- Turns a two-pointing into a two-pointed type. -/
def of {X : Type*} (toTwoPointing : TwoPointing X) : TwoP :=
⟨X, toTwoPointing⟩
@[simp]
theorem coe_of {X : Type*} (toTwoPointing : TwoPointing X) : ↥(of toTwoPointing) = X :=
rfl
alias _root_.TwoPointing.TwoP := of
instance : Inhabited TwoP :=
⟨of TwoPointing.bool⟩
/-- Turns a two-pointed type into a bipointed type, by forgetting that the pointed elements are
distinct. -/
noncomputable def toBipointed (X : TwoP) : Bipointed :=
X.toTwoPointing.toProd.Bipointed
@[simp]
theorem coe_toBipointed (X : TwoP) : ↥X.toBipointed = ↥X :=
rfl
noncomputable instance largeCategory : LargeCategory TwoP :=
InducedCategory.category toBipointed
noncomputable instance concreteCategory : ConcreteCategory TwoP :=
InducedCategory.concreteCategory toBipointed
noncomputable instance hasForgetToBipointed : HasForget₂ TwoP Bipointed :=
InducedCategory.hasForget₂ toBipointed
/-- Swaps the pointed elements of a two-pointed type. `TwoPointing.swap` as a functor. -/
@[simps]
noncomputable def swap : TwoP ⥤ TwoP where
obj X := ⟨X, X.toTwoPointing.swap⟩
map f := ⟨f.toFun, f.map_snd, f.map_fst⟩
/-- The equivalence between `TwoP` and itself induced by `Prod.swap` both ways. -/
@[simps!]
noncomputable def swapEquiv : TwoP ≌ TwoP :=
CategoryTheory.Equivalence.mk swap swap
(NatIso.ofComponents fun X =>
{ hom := ⟨id, rfl, rfl⟩
inv := ⟨id, rfl, rfl⟩ })
(NatIso.ofComponents fun X =>
{ hom := ⟨id, rfl, rfl⟩
inv := ⟨id, rfl, rfl⟩ })
@[simp]
theorem swapEquiv_symm : swapEquiv.symm = swapEquiv :=
rfl
end TwoP
@[simp]
theorem TwoP_swap_comp_forget_to_Bipointed :
TwoP.swap ⋙ forget₂ TwoP Bipointed = forget₂ TwoP Bipointed ⋙ Bipointed.swap :=
rfl
/-- The functor from `Pointed` to `TwoP` which adds a second point. -/
@[simps]
noncomputable def pointedToTwoPFst : Pointed.{u} ⥤ TwoP where
obj X := ⟨Option X, ⟨X.point, none⟩, some_ne_none _⟩
map f := ⟨Option.map f.toFun, congr_arg _ f.map_point, rfl⟩
map_id _ := Bipointed.Hom.ext Option.map_id
map_comp f g := Bipointed.Hom.ext (Option.map_comp_map f.1 g.1).symm
/-- The functor from `Pointed` to `TwoP` which adds a first point. -/
@[simps]
noncomputable def pointedToTwoPSnd : Pointed.{u} ⥤ TwoP where
obj X := ⟨Option X, ⟨none, X.point⟩, (some_ne_none _).symm⟩
map f := ⟨Option.map f.toFun, rfl, congr_arg _ f.map_point⟩
map_id _ := Bipointed.Hom.ext Option.map_id
map_comp f g := Bipointed.Hom.ext (Option.map_comp_map f.1 g.1).symm
@[simp]
theorem pointedToTwoPFst_comp_swap : pointedToTwoPFst ⋙ TwoP.swap = pointedToTwoPSnd :=
rfl
@[simp]
theorem pointedToTwoPSnd_comp_swap : pointedToTwoPSnd ⋙ TwoP.swap = pointedToTwoPFst :=
rfl
@[simp]
theorem pointedToTwoPFst_comp_forget_to_bipointed :
pointedToTwoPFst ⋙ forget₂ TwoP Bipointed = pointedToBipointedFst :=
rfl
@[simp]
theorem pointedToTwoPSnd_comp_forget_to_bipointed :
pointedToTwoPSnd ⋙ forget₂ TwoP Bipointed = pointedToBipointedSnd :=
rfl
/-- Adding a second point is left adjoint to forgetting the second point. -/
noncomputable def pointedToTwoPFstForgetCompBipointedToPointedFstAdjunction :
pointedToTwoPFst ⊣ forget₂ TwoP Bipointed ⋙ bipointedToPointedFst :=
Adjunction.mkOfHomEquiv
{ homEquiv := fun X Y =>
{ toFun := fun f => ⟨f.toFun ∘ Option.some, f.map_fst⟩
invFun := fun f => ⟨fun o => o.elim Y.toTwoPointing.toProd.2 f.toFun, f.map_point, rfl⟩
left_inv := fun f => by
apply Bipointed.Hom.ext
funext x
cases x
· exact f.map_snd.symm
· rfl
right_inv := fun f => Pointed.Hom.ext rfl }
homEquiv_naturality_left_symm := fun f g => by
apply Bipointed.Hom.ext
funext x
cases x <;> rfl }
/-- Adding a first point is left adjoint to forgetting the first point. -/
noncomputable def pointedToTwoPSndForgetCompBipointedToPointedSndAdjunction :
pointedToTwoPSnd ⊣ forget₂ TwoP Bipointed ⋙ bipointedToPointedSnd :=
Adjunction.mkOfHomEquiv
{ homEquiv := fun X Y =>
{ toFun := fun f => ⟨f.toFun ∘ Option.some, f.map_snd⟩
invFun := fun f => ⟨fun o => o.elim Y.toTwoPointing.toProd.1 f.toFun, rfl, f.map_point⟩
left_inv := fun f => by
apply Bipointed.Hom.ext
funext x
cases x
· exact f.map_fst.symm
· rfl
right_inv := fun f => Pointed.Hom.ext rfl }
homEquiv_naturality_left_symm := fun f g => by
apply Bipointed.Hom.ext
funext x
cases x <;> rfl }
|
CategoryTheory\Category\ULift.lean | /-
Copyright (c) 2021 Adam Topaz. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Adam Topaz
-/
import Mathlib.CategoryTheory.Category.Basic
import Mathlib.CategoryTheory.Equivalence
import Mathlib.CategoryTheory.EqToHom
import Mathlib.Data.ULift
/-!
# Basic API for ULift
This file contains a very basic API for working with the categorical
instance on `ULift C` where `C` is a type with a category instance.
1. `CategoryTheory.ULift.upFunctor` is the functorial version of the usual `ULift.up`.
2. `CategoryTheory.ULift.downFunctor` is the functorial version of the usual `ULift.down`.
3. `CategoryTheory.ULift.equivalence` is the categorical equivalence between
`C` and `ULift C`.
# ULiftHom
Given a type `C : Type u`, `ULiftHom.{w} C` is just an alias for `C`.
If we have `category.{v} C`, then `ULiftHom.{w} C` is endowed with a category instance
whose morphisms are obtained by applying `ULift.{w}` to the morphisms from `C`.
This is a category equivalent to `C`. The forward direction of the equivalence is `ULiftHom.up`,
the backward direction is `ULiftHom.down` and the equivalence is `ULiftHom.equiv`.
# AsSmall
This file also contains a construction which takes a type `C : Type u` with a
category instance `Category.{v} C` and makes a small category
`AsSmall.{w} C : Type (max w v u)` equivalent to `C`.
The forward direction of the equivalence, `C ⥤ AsSmall C`, is denoted `AsSmall.up`
and the backward direction is `AsSmall.down`. The equivalence itself is `AsSmall.equiv`.
-/
universe w₁ v₁ v₂ u₁ u₂
namespace CategoryTheory
variable {C : Type u₁} [Category.{v₁} C]
/-- The functorial version of `ULift.up`. -/
@[simps]
def ULift.upFunctor : C ⥤ ULift.{u₂} C where
obj := ULift.up
map f := f
/-- The functorial version of `ULift.down`. -/
@[simps]
def ULift.downFunctor : ULift.{u₂} C ⥤ C where
obj := ULift.down
map f := f
/-- The categorical equivalence between `C` and `ULift C`. -/
@[simps]
def ULift.equivalence : C ≌ ULift.{u₂} C where
functor := ULift.upFunctor
inverse := ULift.downFunctor
unitIso :=
{ hom := 𝟙 _
inv := 𝟙 _ }
counitIso :=
{ hom :=
{ app := fun X => 𝟙 _
naturality := fun X Y f => by
change f ≫ 𝟙 _ = 𝟙 _ ≫ f
simp }
inv :=
{ app := fun X => 𝟙 _
naturality := fun X Y f => by
change f ≫ 𝟙 _ = 𝟙 _ ≫ f
simp }
hom_inv_id := by
ext
change 𝟙 _ ≫ 𝟙 _ = 𝟙 _
simp
inv_hom_id := by
ext
change 𝟙 _ ≫ 𝟙 _ = 𝟙 _
simp }
functor_unitIso_comp X := by
change 𝟙 X ≫ 𝟙 X = 𝟙 X
simp
section ULiftHom
/- Porting note: obviously we don't want code that looks like this long term
the ability to turn off unused universe parameter error is desirable -/
/-- `ULiftHom.{w} C` is an alias for `C`, which is endowed with a category instance
whose morphisms are obtained by applying `ULift.{w}` to the morphisms from `C`.
-/
def ULiftHom.{w,u} (C : Type u) : Type u :=
let _ := ULift.{w} C
C
instance {C} [Inhabited C] : Inhabited (ULiftHom C) :=
⟨(default : C)⟩
/-- The obvious function `ULiftHom C → C`. -/
def ULiftHom.objDown {C} (A : ULiftHom C) : C :=
A
/-- The obvious function `C → ULiftHom C`. -/
def ULiftHom.objUp {C} (A : C) : ULiftHom C :=
A
@[simp]
theorem objDown_objUp {C} (A : C) : (ULiftHom.objUp A).objDown = A :=
rfl
@[simp]
theorem objUp_objDown {C} (A : ULiftHom C) : ULiftHom.objUp A.objDown = A :=
rfl
instance ULiftHom.category : Category.{max v₂ v₁} (ULiftHom.{v₂} C) where
Hom A B := ULift.{v₂} <| A.objDown ⟶ B.objDown
id A := ⟨𝟙 _⟩
comp f g := ⟨f.down ≫ g.down⟩
/-- One half of the quivalence between `C` and `ULiftHom C`. -/
@[simps]
def ULiftHom.up : C ⥤ ULiftHom C where
obj := ULiftHom.objUp
map f := ⟨f⟩
/-- One half of the quivalence between `C` and `ULiftHom C`. -/
@[simps]
def ULiftHom.down : ULiftHom C ⥤ C where
obj := ULiftHom.objDown
map f := f.down
/-- The equivalence between `C` and `ULiftHom C`. -/
def ULiftHom.equiv : C ≌ ULiftHom C where
functor := ULiftHom.up
inverse := ULiftHom.down
unitIso := NatIso.ofComponents fun A => eqToIso rfl
counitIso := NatIso.ofComponents fun A => eqToIso rfl
end ULiftHom
/- Porting note: we want to keep around the category instance on `D`
so Lean can figure out things further down. So `AsSmall` has been
nolinted. -/
/-- `AsSmall C` is a small category equivalent to `C`.
More specifically, if `C : Type u` is endowed with `Category.{v} C`, then
`AsSmall.{w} C : Type (max w v u)` is endowed with an instance of a small category.
The objects and morphisms of `AsSmall C` are defined by applying `ULift` to the
objects and morphisms of `C`.
Note: We require a category instance for this definition in order to have direct
access to the universe level `v`.
-/
@[nolint unusedArguments]
def AsSmall.{w, v, u} (D : Type u) [Category.{v} D] := ULift.{max w v} D
instance : SmallCategory (AsSmall.{w₁} C) where
Hom X Y := ULift.{max w₁ u₁} <| X.down ⟶ Y.down
id X := ⟨𝟙 _⟩
comp f g := ⟨f.down ≫ g.down⟩
/-- One half of the equivalence between `C` and `AsSmall C`. -/
@[simps]
def AsSmall.up : C ⥤ AsSmall C where
obj X := ⟨X⟩
map f := ⟨f⟩
/-- One half of the equivalence between `C` and `AsSmall C`. -/
@[simps]
def AsSmall.down : AsSmall C ⥤ C where
obj X := ULift.down X
map f := f.down
/-- The equivalence between `C` and `AsSmall C`. -/
@[simps]
def AsSmall.equiv : C ≌ AsSmall C where
functor := AsSmall.up
inverse := AsSmall.down
unitIso := NatIso.ofComponents fun X => eqToIso rfl
counitIso := NatIso.ofComponents fun X => eqToIso <| ULift.ext _ _ rfl
instance [Inhabited C] : Inhabited (AsSmall C) :=
⟨⟨default⟩⟩
/-- The equivalence between `C` and `ULiftHom (ULift C)`. -/
def ULiftHomULiftCategory.equiv.{v', u', v, u} (C : Type u) [Category.{v} C] :
C ≌ ULiftHom.{v'} (ULift.{u'} C) :=
ULift.equivalence.trans ULiftHom.equiv
end CategoryTheory
|
CategoryTheory\Category\Cat\Adjunction.lean | /-
Copyright (c) 2024 Nicolas Rolland. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Nicolas Rolland
-/
import Mathlib.CategoryTheory.Category.Cat
import Mathlib.CategoryTheory.Adjunction.Basic
/-!
# Adjunctions related to Cat, the category of categories
The embedding `typeToCat: Type ⥤ Cat`, mapping a type to the corresponding discrete category, is
left adjoint to the functor `Cat.objects`, which maps a category to its set of objects.
## Notes
All this could be made with 2-functors
## TODO
Define the left adjoint `Cat.connectedComponents`, which map
a category to its set of connected components.
-/
universe u
namespace CategoryTheory.Cat
variable (X : Type u) (C : Cat)
private def typeToCatObjectsAdjHomEquiv : (typeToCat.obj X ⟶ C) ≃ (X ⟶ Cat.objects.obj C) where
toFun f x := f.obj ⟨x⟩
invFun := Discrete.functor
left_inv F := Functor.ext (fun _ ↦ rfl) (fun ⟨_⟩ ⟨_⟩ f => by
obtain rfl := Discrete.eq_of_hom f
simp)
right_inv _ := rfl
private def typeToCatObjectsAdjCounitApp : (Cat.objects ⋙ typeToCat).obj C ⥤ C where
obj := Discrete.as
map := eqToHom ∘ Discrete.eq_of_hom
/-- `typeToCat : Type ⥤ Cat` is left adjoint to `Cat.objects : Cat ⥤ Type` -/
def typeToCatObjectsAdj : typeToCat ⊣ Cat.objects where
homEquiv := typeToCatObjectsAdjHomEquiv
unit := { app:= fun _ ↦ Discrete.mk }
counit := {
app := typeToCatObjectsAdjCounitApp
naturality := fun _ _ _ ↦ Functor.hext (fun _ ↦ rfl)
(by intro ⟨_⟩ ⟨_⟩ f
obtain rfl := Discrete.eq_of_hom f
aesop_cat ) }
end CategoryTheory.Cat
|
CategoryTheory\Category\Cat\Limit.lean | /-
Copyright (c) 2020 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Scott Morrison
-/
import Mathlib.CategoryTheory.Category.Cat
import Mathlib.CategoryTheory.Limits.Types
import Mathlib.CategoryTheory.Limits.Preserves.Basic
/-!
# The category of small categories has all small limits.
An object in the limit consists of a family of objects,
which are carried to one another by the functors in the diagram.
A morphism between two such objects is a family of morphisms between the corresponding objects,
which are carried to one another by the action on morphisms of the functors in the diagram.
## Future work
Can the indexing category live in a lower universe?
-/
noncomputable section
universe v u
open CategoryTheory.Limits
namespace CategoryTheory
variable {J : Type v} [SmallCategory J]
namespace Cat
namespace HasLimits
instance categoryObjects {F : J ⥤ Cat.{u, u}} {j} :
SmallCategory ((F ⋙ Cat.objects.{u, u}).obj j) :=
(F.obj j).str
/-- Auxiliary definition:
the diagram whose limit gives the morphism space between two objects of the limit category. -/
@[simps]
def homDiagram {F : J ⥤ Cat.{v, v}} (X Y : limit (F ⋙ Cat.objects.{v, v})) : J ⥤ Type v where
obj j := limit.π (F ⋙ Cat.objects) j X ⟶ limit.π (F ⋙ Cat.objects) j Y
map f g := by
refine eqToHom ?_ ≫ (F.map f).map g ≫ eqToHom ?_
· exact (congr_fun (limit.w (F ⋙ Cat.objects) f) X).symm
· exact congr_fun (limit.w (F ⋙ Cat.objects) f) Y
map_id X := by
funext f
letI : Category (objects.obj (F.obj X)) := (inferInstance : Category (F.obj X))
simp [Functor.congr_hom (F.map_id X) f]
map_comp {_ _ Z} f g := by
funext h
letI : Category (objects.obj (F.obj Z)) := (inferInstance : Category (F.obj Z))
simp [Functor.congr_hom (F.map_comp f g) h, eqToHom_map]
@[simps]
instance (F : J ⥤ Cat.{v, v}) : Category (limit (F ⋙ Cat.objects)) where
Hom X Y := limit (homDiagram X Y)
id X := Types.Limit.mk.{v, v} (homDiagram X X) (fun j => 𝟙 _) fun j j' f => by simp
comp {X Y Z} f g :=
Types.Limit.mk.{v, v} (homDiagram X Z)
(fun j => limit.π (homDiagram X Y) j f ≫ limit.π (homDiagram Y Z) j g) fun j j' h => by
simp [← congr_fun (limit.w (homDiagram X Y) h) f,
← congr_fun (limit.w (homDiagram Y Z) h) g]
id_comp _ := by
apply Types.limit_ext.{v, v}
aesop_cat
comp_id _ := by
apply Types.limit_ext.{v, v}
aesop_cat
/-- Auxiliary definition: the limit category. -/
@[simps]
def limitConeX (F : J ⥤ Cat.{v, v}) : Cat.{v, v} where α := limit (F ⋙ Cat.objects)
/-- Auxiliary definition: the cone over the limit category. -/
@[simps]
def limitCone (F : J ⥤ Cat.{v, v}) : Cone F where
pt := limitConeX F
π :=
{ app := fun j =>
{ obj := limit.π (F ⋙ Cat.objects) j
map := fun f => limit.π (homDiagram _ _) j f }
naturality := fun j j' f =>
CategoryTheory.Functor.ext (fun X => (congr_fun (limit.w (F ⋙ Cat.objects) f) X).symm)
fun X Y h => (congr_fun (limit.w (homDiagram X Y) f) h).symm }
/-- Auxiliary definition: the universal morphism to the proposed limit cone. -/
@[simps]
def limitConeLift (F : J ⥤ Cat.{v, v}) (s : Cone F) : s.pt ⟶ limitConeX F where
obj :=
limit.lift (F ⋙ Cat.objects)
{ pt := s.pt
π :=
{ app := fun j => (s.π.app j).obj
naturality := fun _ _ f => objects.congr_map (s.π.naturality f) } }
map f := by
fapply Types.Limit.mk.{v, v}
· intro j
refine eqToHom ?_ ≫ (s.π.app j).map f ≫ eqToHom ?_ <;> simp
· intro j j' h
dsimp
simp only [Category.assoc, Functor.map_comp, eqToHom_map, eqToHom_trans,
eqToHom_trans_assoc, ← Functor.comp_map]
have := (s.π.naturality h).symm
dsimp at this
rw [Category.id_comp] at this
erw [Functor.congr_hom this f]
simp
@[simp]
theorem limit_π_homDiagram_eqToHom {F : J ⥤ Cat.{v, v}} (X Y : limit (F ⋙ Cat.objects.{v, v}))
(j : J) (h : X = Y) :
limit.π (homDiagram X Y) j (eqToHom h) =
eqToHom (congr_arg (limit.π (F ⋙ Cat.objects.{v, v}) j) h) := by
subst h
simp
/-- Auxiliary definition: the proposed cone is a limit cone. -/
def limitConeIsLimit (F : J ⥤ Cat.{v, v}) : IsLimit (limitCone F) where
lift := limitConeLift F
fac s j := CategoryTheory.Functor.ext (by simp) fun X Y f => by
dsimp [limitConeLift]
exact Types.Limit.π_mk.{v, v} _ _ _ _
uniq s m w := by
symm
refine CategoryTheory.Functor.ext ?_ ?_
· intro X
apply Types.limit_ext.{v, v}
intro j
simp [Types.Limit.lift_π_apply', ← w j]
· intro X Y f
dsimp
simp [fun j => Functor.congr_hom (w j).symm f]
end HasLimits
/-- The category of small categories has all small limits. -/
instance : HasLimits Cat.{v, v} where
has_limits_of_shape _ :=
{ has_limit := fun F => ⟨⟨⟨HasLimits.limitCone F, HasLimits.limitConeIsLimit F⟩⟩⟩ }
instance : PreservesLimits Cat.objects.{v, v} where
preservesLimitsOfShape :=
{ preservesLimit := fun {F} =>
preservesLimitOfPreservesLimitCone (HasLimits.limitConeIsLimit F)
(Limits.IsLimit.ofIsoLimit (limit.isLimit (F ⋙ Cat.objects))
(Cones.ext (by rfl) (by aesop_cat))) }
end Cat
end CategoryTheory
|
CategoryTheory\ChosenFiniteProducts\FunctorCategory.lean | /-
Copyright (c) 2024 Joël Riou. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Joël Riou
-/
import Mathlib.CategoryTheory.ChosenFiniteProducts
import Mathlib.CategoryTheory.Limits.FunctorCategory
/-!
# Functor categories have chosen finite products
If `C` is a category with chosen finite products, then so is `J ⥤ C`.
-/
namespace CategoryTheory
open Limits MonoidalCategory Category
variable (J C : Type*) [Category J] [Category C] [ChosenFiniteProducts C]
namespace Functor
/-- The chosen terminal object in `J ⥤ C`. -/
abbrev chosenTerminal : J ⥤ C := (Functor.const J).obj (𝟙_ C)
/-- The chosen terminal object in `J ⥤ C` is terminal. -/
def chosenTerminalIsTerminal : IsTerminal (chosenTerminal J C) :=
evaluationJointlyReflectsLimits _
(fun _ => isLimitChangeEmptyCone _ ChosenFiniteProducts.terminal.2 _ (Iso.refl _))
section
variable {J C}
variable (F₁ F₂ : J ⥤ C)
/-- The chosen binary product on `J ⥤ C`. -/
@[simps]
def chosenProd : J ⥤ C where
obj j := F₁.obj j ⊗ F₂.obj j
map φ := F₁.map φ ⊗ F₂.map φ
namespace chosenProd
/-- The first projection `chosenProd F₁ F₂ ⟶ F₁`. -/
@[simps]
def fst : chosenProd F₁ F₂ ⟶ F₁ where
app _ := ChosenFiniteProducts.fst _ _
/-- The second projection `chosenProd F₁ F₂ ⟶ F₂`. -/
@[simps]
def snd : chosenProd F₁ F₂ ⟶ F₂ where
app j := ChosenFiniteProducts.snd _ _
/-- `Functor.chosenProd F₁ F₂` is a binary product of `F₁` and `F₂`. -/
noncomputable def isLimit : IsLimit (BinaryFan.mk (fst F₁ F₂) (snd F₁ F₂)) :=
evaluationJointlyReflectsLimits _ (fun j =>
(IsLimit.postcomposeHomEquiv (mapPairIso (by exact Iso.refl _) (by exact Iso.refl _)) _).1
(IsLimit.ofIsoLimit (ChosenFiniteProducts.product (X := F₁.obj j) (Y := F₂.obj j)).2
(Cones.ext (Iso.refl _) (by rintro ⟨_|_⟩; all_goals aesop_cat))))
end chosenProd
end
noncomputable instance chosenFiniteProducts :
ChosenFiniteProducts (J ⥤ C) where
terminal := ⟨_, chosenTerminalIsTerminal J C⟩
product F₁ F₂ := ⟨_, chosenProd.isLimit F₁ F₂⟩
namespace Monoidal
open ChosenFiniteProducts
variable {J C}
@[simp]
lemma leftUnitor_hom_app (F : J ⥤ C) (j : J) :
(λ_ F).hom.app j = (λ_ (F.obj j)).hom := rfl
@[simp]
lemma leftUnitor_inv_app (F : J ⥤ C) (j : J) :
(λ_ F).inv.app j = (λ_ (F.obj j)).inv := by
rw [← cancel_mono ((λ_ (F.obj j)).hom), Iso.inv_hom_id, ← leftUnitor_hom_app,
Iso.inv_hom_id_app]
@[simp]
lemma rightUnitor_hom_app (F : J ⥤ C) (j : J) :
(ρ_ F).hom.app j = (ρ_ (F.obj j)).hom := rfl
@[simp]
lemma rightUnitor_inv_app (F : J ⥤ C) (j : J) :
(ρ_ F).inv.app j = (ρ_ (F.obj j)).inv := by
rw [← cancel_mono ((ρ_ (F.obj j)).hom), Iso.inv_hom_id, ← rightUnitor_hom_app,
Iso.inv_hom_id_app]
@[reassoc (attr := simp)]
lemma tensorHom_app_fst {F₁ F₁' F₂ F₂' : J ⥤ C} (f : F₁ ⟶ F₁') (g : F₂ ⟶ F₂') (j : J) :
(f ⊗ g).app j ≫ fst _ _ = fst _ _ ≫ f.app j := by
change (f ⊗ g).app j ≫ (fst F₁' F₂').app j = _
rw [← NatTrans.comp_app, tensorHom_fst, NatTrans.comp_app]
rfl
@[reassoc (attr := simp)]
lemma tensorHom_app_snd {F₁ F₁' F₂ F₂' : J ⥤ C} (f : F₁ ⟶ F₁') (g : F₂ ⟶ F₂') (j : J) :
(f ⊗ g).app j ≫ snd _ _ = snd _ _ ≫ g.app j := by
change (f ⊗ g).app j ≫ (snd F₁' F₂').app j = _
rw [← NatTrans.comp_app, tensorHom_snd, NatTrans.comp_app]
rfl
@[reassoc (attr := simp)]
lemma whiskerLeft_app_fst (F₁ : J ⥤ C) {F₂ F₂' : J ⥤ C} (g : F₂ ⟶ F₂') (j : J) :
(F₁ ◁ g).app j ≫ fst _ _ = fst _ _ :=
(tensorHom_app_fst (𝟙 F₁) g j).trans (by simp)
@[reassoc (attr := simp)]
lemma whiskerLeft_app_snd (F₁ : J ⥤ C) {F₂ F₂' : J ⥤ C} (g : F₂ ⟶ F₂') (j : J) :
(F₁ ◁ g).app j ≫ snd _ _ = snd _ _ ≫ g.app j :=
(tensorHom_app_snd (𝟙 F₁) g j)
@[reassoc (attr := simp)]
lemma whiskerRight_app_fst {F₁ F₁' : J ⥤ C} (f : F₁ ⟶ F₁') (F₂ : J ⥤ C) (j : J) :
(f ▷ F₂).app j ≫ fst _ _ = fst _ _ ≫ f.app j :=
(tensorHom_app_fst f (𝟙 F₂) j)
@[reassoc (attr := simp)]
lemma whiskerRight_app_snd {F₁ F₁' : J ⥤ C} (f : F₁ ⟶ F₁') (F₂ : J ⥤ C) (j : J) :
(f ▷ F₂).app j ≫ snd _ _ = snd _ _ :=
(tensorHom_app_snd f (𝟙 F₂) j).trans (by simp)
@[simp]
lemma associator_hom_app (F₁ F₂ F₃ : J ⥤ C) (j : J) :
(α_ F₁ F₂ F₃).hom.app j = (α_ _ _ _).hom := by
apply hom_ext
· change _ ≫ (fst F₁ (F₂ ⊗ F₃)).app j = _
rw [← NatTrans.comp_app, associator_hom_fst]
erw [associator_hom_fst]
rfl
· apply hom_ext
· change (_ ≫ (snd F₁ (F₂ ⊗ F₃)).app j) ≫ (fst F₂ F₃).app j = _
rw [← NatTrans.comp_app, ← NatTrans.comp_app, assoc, associator_hom_snd_fst, assoc]
erw [associator_hom_snd_fst]
rfl
· change (_ ≫ (snd F₁ (F₂ ⊗ F₃)).app j) ≫ (snd F₂ F₃).app j = _
rw [← NatTrans.comp_app, ← NatTrans.comp_app, assoc, associator_hom_snd_snd, assoc]
erw [associator_hom_snd_snd]
rfl
@[simp]
lemma associator_inv_app (F₁ F₂ F₃ : J ⥤ C) (j : J) :
(α_ F₁ F₂ F₃).inv.app j = (α_ _ _ _).inv := by
rw [← cancel_mono ((α_ _ _ _).hom), Iso.inv_hom_id, ← associator_hom_app, Iso.inv_hom_id_app]
end Monoidal
end Functor
end CategoryTheory
|
CategoryTheory\Closed\Cartesian.lean | /-
Copyright (c) 2020 Bhavik Mehta, Edward Ayers, Thomas Read. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Bhavik Mehta, Edward Ayers, Thomas Read
-/
import Mathlib.CategoryTheory.EpiMono
import Mathlib.CategoryTheory.Limits.Shapes.FiniteProducts
import Mathlib.CategoryTheory.Monoidal.OfHasFiniteProducts
import Mathlib.CategoryTheory.Limits.Preserves.Shapes.BinaryProducts
import Mathlib.CategoryTheory.Adjunction.Limits
import Mathlib.CategoryTheory.Adjunction.Mates
import Mathlib.CategoryTheory.Closed.Monoidal
/-!
# Cartesian closed categories
Given a category with finite products, the cartesian monoidal structure is provided by the local
instance `monoidalOfHasFiniteProducts`.
We define exponentiable objects to be closed objects with respect to this monoidal structure,
i.e. `(X × -)` is a left adjoint.
We say a category is cartesian closed if every object is exponentiable
(equivalently, that the category equipped with the cartesian monoidal structure is closed monoidal).
Show that exponential forms a difunctor and define the exponential comparison morphisms.
## TODO
Some of the results here are true more generally for closed objects and
for closed monoidal categories, and these could be generalised.
-/
universe v u u₂
noncomputable section
namespace CategoryTheory
open CategoryTheory CategoryTheory.Category CategoryTheory.Limits
attribute [local instance] monoidalOfHasFiniteProducts
/-- An object `X` is *exponentiable* if `(X × -)` is a left adjoint.
We define this as being `Closed` in the cartesian monoidal structure.
-/
abbrev Exponentiable {C : Type u} [Category.{v} C] [HasFiniteProducts C] (X : C) :=
Closed X
/-- Constructor for `Exponentiable X` which takes as an input an adjunction
`MonoidalCategory.tensorLeft X ⊣ exp` for some functor `exp : C ⥤ C`. -/
abbrev Exponentiable.mk {C : Type u} [Category.{v} C] [HasFiniteProducts C] (X : C)
(exp : C ⥤ C) (adj : MonoidalCategory.tensorLeft X ⊣ exp) :
Exponentiable X where
adj := adj
/-- If `X` and `Y` are exponentiable then `X ⨯ Y` is.
This isn't an instance because it's not usually how we want to construct exponentials, we'll usually
prove all objects are exponential uniformly.
-/
def binaryProductExponentiable {C : Type u} [Category.{v} C] [HasFiniteProducts C] {X Y : C}
(hX : Exponentiable X) (hY : Exponentiable Y) : Exponentiable (X ⨯ Y) :=
tensorClosed hX hY
/-- The terminal object is always exponentiable.
This isn't an instance because most of the time we'll prove cartesian closed for all objects
at once, rather than just for this one.
-/
def terminalExponentiable {C : Type u} [Category.{v} C] [HasFiniteProducts C] :
Exponentiable (⊤_ C) :=
unitClosed
/-- A category `C` is cartesian closed if it has finite products and every object is exponentiable.
We define this as `monoidal_closed` with respect to the cartesian monoidal structure.
-/
abbrev CartesianClosed (C : Type u) [Category.{v} C] [HasFiniteProducts C] :=
MonoidalClosed C
-- Porting note: added to ease the port of `CategoryTheory.Closed.Types`
/-- Constructor for `CartesianClosed C`. -/
def CartesianClosed.mk (C : Type u) [Category.{v} C] [HasFiniteProducts C]
(exp : ∀ (X : C), Exponentiable X) :
CartesianClosed C where
closed X := exp X
variable {C : Type u} [Category.{v} C] (A B : C) {X X' Y Y' Z : C}
variable [HasFiniteProducts C] [Exponentiable A]
/-- This is (-)^A. -/
abbrev exp : C ⥤ C :=
ihom A
namespace exp
/-- The adjunction between A ⨯ - and (-)^A. -/
abbrev adjunction : prod.functor.obj A ⊣ exp A :=
ihom.adjunction A
/-- The evaluation natural transformation. -/
abbrev ev : exp A ⋙ prod.functor.obj A ⟶ 𝟭 C :=
ihom.ev A
/-- The coevaluation natural transformation. -/
abbrev coev : 𝟭 C ⟶ prod.functor.obj A ⋙ exp A :=
ihom.coev A
-- Porting note: notation fails to elaborate with `quotPrecheck` on.
set_option quotPrecheck false in
/-- Morphisms obtained using an exponentiable object. -/
notation:20 A " ⟹ " B:19 => (exp A).obj B
open Lean PrettyPrinter.Delaborator SubExpr in
/-- Delaborator for `Prefunctor.obj` -/
@[delab app.Prefunctor.obj]
def delabPrefunctorObjExp : Delab := whenPPOption getPPNotation <| withOverApp 6 <| do
let e ← getExpr
guard <| e.isAppOfArity' ``Prefunctor.obj 6
let A ← withNaryArg 4 do
let e ← getExpr
guard <| e.isAppOfArity' ``Functor.toPrefunctor 5
withNaryArg 4 do
let e ← getExpr
guard <| e.isAppOfArity' ``exp 5
withNaryArg 2 delab
let B ← withNaryArg 5 delab
`($A ⟹ $B)
-- Porting note: notation fails to elaborate with `quotPrecheck` on.
set_option quotPrecheck false in
/-- Morphisms from an exponentiable object. -/
notation:30 B " ^^ " A:30 => (exp A).obj B
@[simp, reassoc]
theorem ev_coev : Limits.prod.map (𝟙 A) ((coev A).app B) ≫ (ev A).app (A ⨯ B) = 𝟙 (A ⨯ B) :=
ihom.ev_coev A B
@[reassoc]
theorem coev_ev : (coev A).app (A ⟹ B) ≫ (exp A).map ((ev A).app B) = 𝟙 (A ⟹ B) :=
ihom.coev_ev A B
end exp
instance : PreservesColimits (prod.functor.obj A) :=
(ihom.adjunction A).leftAdjointPreservesColimits
variable {A}
-- Wrap these in a namespace so we don't clash with the core versions.
namespace CartesianClosed
/-- Currying in a cartesian closed category. -/
def curry : (A ⨯ Y ⟶ X) → (Y ⟶ A ⟹ X) :=
(exp.adjunction A).homEquiv _ _
/-- Uncurrying in a cartesian closed category. -/
def uncurry : (Y ⟶ A ⟹ X) → (A ⨯ Y ⟶ X) :=
((exp.adjunction A).homEquiv _ _).symm
-- This lemma has always been bad, but the linter only noticed after lean4#2644.
@[simp, nolint simpNF]
theorem homEquiv_apply_eq (f : A ⨯ Y ⟶ X) : (exp.adjunction A).homEquiv _ _ f = curry f :=
rfl
-- This lemma has always been bad, but the linter only noticed after lean4#2644.
@[simp, nolint simpNF]
theorem homEquiv_symm_apply_eq (f : Y ⟶ A ⟹ X) :
((exp.adjunction A).homEquiv _ _).symm f = uncurry f :=
rfl
@[reassoc]
theorem curry_natural_left (f : X ⟶ X') (g : A ⨯ X' ⟶ Y) :
curry (Limits.prod.map (𝟙 _) f ≫ g) = f ≫ curry g :=
Adjunction.homEquiv_naturality_left _ _ _
@[reassoc]
theorem curry_natural_right (f : A ⨯ X ⟶ Y) (g : Y ⟶ Y') :
curry (f ≫ g) = curry f ≫ (exp _).map g :=
Adjunction.homEquiv_naturality_right _ _ _
@[reassoc]
theorem uncurry_natural_right (f : X ⟶ A ⟹ Y) (g : Y ⟶ Y') :
uncurry (f ≫ (exp _).map g) = uncurry f ≫ g :=
Adjunction.homEquiv_naturality_right_symm _ _ _
@[reassoc]
theorem uncurry_natural_left (f : X ⟶ X') (g : X' ⟶ A ⟹ Y) :
uncurry (f ≫ g) = Limits.prod.map (𝟙 _) f ≫ uncurry g :=
Adjunction.homEquiv_naturality_left_symm _ _ _
@[simp]
theorem uncurry_curry (f : A ⨯ X ⟶ Y) : uncurry (curry f) = f :=
(Closed.adj.homEquiv _ _).left_inv f
@[simp]
theorem curry_uncurry (f : X ⟶ A ⟹ Y) : curry (uncurry f) = f :=
(Closed.adj.homEquiv _ _).right_inv f
-- Porting note: extra `(exp.adjunction A)` argument was needed for elaboration to succeed.
theorem curry_eq_iff (f : A ⨯ Y ⟶ X) (g : Y ⟶ A ⟹ X) : curry f = g ↔ f = uncurry g :=
Adjunction.homEquiv_apply_eq (exp.adjunction A) f g
-- Porting note: extra `(exp.adjunction A)` argument was needed for elaboration to succeed.
theorem eq_curry_iff (f : A ⨯ Y ⟶ X) (g : Y ⟶ A ⟹ X) : g = curry f ↔ uncurry g = f :=
Adjunction.eq_homEquiv_apply (exp.adjunction A) f g
-- I don't think these two should be simp.
theorem uncurry_eq (g : Y ⟶ A ⟹ X) : uncurry g = Limits.prod.map (𝟙 A) g ≫ (exp.ev A).app X :=
Adjunction.homEquiv_counit _
theorem curry_eq (g : A ⨯ Y ⟶ X) : curry g = (exp.coev A).app Y ≫ (exp A).map g :=
Adjunction.homEquiv_unit _
theorem uncurry_id_eq_ev (A X : C) [Exponentiable A] : uncurry (𝟙 (A ⟹ X)) = (exp.ev A).app X := by
rw [uncurry_eq, prod.map_id_id, id_comp]
theorem curry_id_eq_coev (A X : C) [Exponentiable A] : curry (𝟙 _) = (exp.coev A).app X := by
rw [curry_eq, (exp A).map_id (A ⨯ _)]; apply comp_id
theorem curry_injective : Function.Injective (curry : (A ⨯ Y ⟶ X) → (Y ⟶ A ⟹ X)) :=
(Closed.adj.homEquiv _ _).injective
theorem uncurry_injective : Function.Injective (uncurry : (Y ⟶ A ⟹ X) → (A ⨯ Y ⟶ X)) :=
(Closed.adj.homEquiv _ _).symm.injective
end CartesianClosed
open CartesianClosed
/-- Show that the exponential of the terminal object is isomorphic to itself, i.e. `X^1 ≅ X`.
The typeclass argument is explicit: any instance can be used.
-/
def expTerminalIsoSelf [Exponentiable (⊤_ C)] : (⊤_ C) ⟹ X ≅ X :=
Yoneda.ext ((⊤_ C) ⟹ X) X
(fun {Y} f => (prod.leftUnitor Y).inv ≫ CartesianClosed.uncurry f)
(fun {Y} f => CartesianClosed.curry ((prod.leftUnitor Y).hom ≫ f))
(fun g => by
rw [curry_eq_iff, Iso.hom_inv_id_assoc])
(fun g => by simp)
(fun f g => by
-- Porting note: `rw` is a bit brittle here, requiring the `dsimp` rule cancellation.
dsimp [-prod.leftUnitor_inv]
rw [uncurry_natural_left, prod.leftUnitor_inv_naturality_assoc f])
/-- The internal element which points at the given morphism. -/
def internalizeHom (f : A ⟶ Y) : ⊤_ C ⟶ A ⟹ Y :=
CartesianClosed.curry (Limits.prod.fst ≫ f)
section Pre
variable {B}
/-- Pre-compose an internal hom with an external hom. -/
def pre (f : B ⟶ A) [Exponentiable B] : exp A ⟶ exp B :=
conjugateEquiv (exp.adjunction _) (exp.adjunction _) (prod.functor.map f)
theorem prod_map_pre_app_comp_ev (f : B ⟶ A) [Exponentiable B] (X : C) :
Limits.prod.map (𝟙 B) ((pre f).app X) ≫ (exp.ev B).app X =
Limits.prod.map f (𝟙 (A ⟹ X)) ≫ (exp.ev A).app X :=
conjugateEquiv_counit _ _ (prod.functor.map f) X
theorem uncurry_pre (f : B ⟶ A) [Exponentiable B] (X : C) :
CartesianClosed.uncurry ((pre f).app X) = Limits.prod.map f (𝟙 _) ≫ (exp.ev A).app X := by
rw [uncurry_eq, prod_map_pre_app_comp_ev]
theorem coev_app_comp_pre_app (f : B ⟶ A) [Exponentiable B] :
(exp.coev A).app X ≫ (pre f).app (A ⨯ X) =
(exp.coev B).app X ≫ (exp B).map (Limits.prod.map f (𝟙 _)) :=
unit_conjugateEquiv _ _ (prod.functor.map f) X
@[simp]
theorem pre_id (A : C) [Exponentiable A] : pre (𝟙 A) = 𝟙 _ := by simp [pre]
@[simp]
theorem pre_map {A₁ A₂ A₃ : C} [Exponentiable A₁] [Exponentiable A₂] [Exponentiable A₃]
(f : A₁ ⟶ A₂) (g : A₂ ⟶ A₃) : pre (f ≫ g) = pre g ≫ pre f := by
rw [pre, pre, pre, conjugateEquiv_comp, prod.functor.map_comp]
end Pre
/-- The internal hom functor given by the cartesian closed structure. -/
def internalHom [CartesianClosed C] : Cᵒᵖ ⥤ C ⥤ C where
obj X := exp X.unop
map f := pre f.unop
/-- If an initial object `I` exists in a CCC, then `A ⨯ I ≅ I`. -/
@[simps]
def zeroMul {I : C} (t : IsInitial I) : A ⨯ I ≅ I where
hom := Limits.prod.snd
inv := t.to _
hom_inv_id := by
have : (prod.snd : A ⨯ I ⟶ I) = CartesianClosed.uncurry (t.to _) := by
rw [← curry_eq_iff]
apply t.hom_ext
rw [this, ← uncurry_natural_right, ← eq_curry_iff]
apply t.hom_ext
inv_hom_id := t.hom_ext _ _
/-- If an initial object `0` exists in a CCC, then `0 ⨯ A ≅ 0`. -/
def mulZero {I : C} (t : IsInitial I) : I ⨯ A ≅ I :=
Limits.prod.braiding _ _ ≪≫ zeroMul t
/-- If an initial object `0` exists in a CCC then `0^B ≅ 1` for any `B`. -/
def powZero {I : C} (t : IsInitial I) [CartesianClosed C] : I ⟹ B ≅ ⊤_ C where
hom := default
inv := CartesianClosed.curry ((mulZero t).hom ≫ t.to _)
hom_inv_id := by
rw [← curry_natural_left, curry_eq_iff, ← cancel_epi (mulZero t).inv]
apply t.hom_ext
-- TODO: Generalise the below to its commutated variants.
-- TODO: Define a distributive category, so that zero_mul and friends can be derived from this.
/-- In a CCC with binary coproducts, the distribution morphism is an isomorphism. -/
def prodCoprodDistrib [HasBinaryCoproducts C] [CartesianClosed C] (X Y Z : C) :
(Z ⨯ X) ⨿ Z ⨯ Y ≅ Z ⨯ X ⨿ Y where
hom := coprod.desc (Limits.prod.map (𝟙 _) coprod.inl) (Limits.prod.map (𝟙 _) coprod.inr)
inv :=
CartesianClosed.uncurry
(coprod.desc (CartesianClosed.curry coprod.inl) (CartesianClosed.curry coprod.inr))
hom_inv_id := by
ext
· rw [coprod.inl_desc_assoc, comp_id, ← uncurry_natural_left, coprod.inl_desc, uncurry_curry]
rw [coprod.inr_desc_assoc, comp_id, ← uncurry_natural_left, coprod.inr_desc, uncurry_curry]
inv_hom_id := by
rw [← uncurry_natural_right, ← eq_curry_iff]
ext
· rw [coprod.inl_desc_assoc, ← curry_natural_right, coprod.inl_desc, ← curry_natural_left,
comp_id]
rw [coprod.inr_desc_assoc, ← curry_natural_right, coprod.inr_desc, ← curry_natural_left,
comp_id]
/-- If an initial object `I` exists in a CCC then it is a strict initial object,
i.e. any morphism to `I` is an iso.
This actually shows a slightly stronger version: any morphism to an initial object from an
exponentiable object is an isomorphism.
-/
theorem strict_initial {I : C} (t : IsInitial I) (f : A ⟶ I) : IsIso f := by
haveI : Mono (prod.lift (𝟙 A) f ≫ (zeroMul t).hom) := mono_comp _ _
rw [zeroMul_hom, prod.lift_snd] at this
haveI : IsSplitEpi f := IsSplitEpi.mk' ⟨t.to _, t.hom_ext _ _⟩
apply isIso_of_mono_of_isSplitEpi
instance to_initial_isIso [HasInitial C] (f : A ⟶ ⊥_ C) : IsIso f :=
strict_initial initialIsInitial _
/-- If an initial object `0` exists in a CCC then every morphism from it is monic. -/
theorem initial_mono {I : C} (B : C) (t : IsInitial I) [CartesianClosed C] : Mono (t.to B) :=
⟨fun g h _ => by
haveI := strict_initial t g
haveI := strict_initial t h
exact eq_of_inv_eq_inv (t.hom_ext _ _)⟩
instance Initial.mono_to [HasInitial C] (B : C) [CartesianClosed C] : Mono (initial.to B) :=
initial_mono B initialIsInitial
variable {D : Type u₂} [Category.{v} D]
section Functor
variable [HasFiniteProducts D]
/-- Transport the property of being cartesian closed across an equivalence of categories.
Note we didn't require any coherence between the choice of finite products here, since we transport
along the `prodComparison` isomorphism.
-/
def cartesianClosedOfEquiv (e : C ≌ D) [CartesianClosed C] : CartesianClosed D :=
MonoidalClosed.ofEquiv (e.inverse.toMonoidalFunctorOfHasFiniteProducts) e.symm.toAdjunction
end Functor
attribute [nolint simpNF] CategoryTheory.CartesianClosed.homEquiv_apply_eq
CategoryTheory.CartesianClosed.homEquiv_symm_apply_eq
end CategoryTheory
|
CategoryTheory\Closed\Functor.lean | /-
Copyright (c) 2020 Bhavik Mehta. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Bhavik Mehta
-/
import Mathlib.CategoryTheory.Closed.Cartesian
import Mathlib.CategoryTheory.Limits.Preserves.Shapes.BinaryProducts
import Mathlib.CategoryTheory.Adjunction.FullyFaithful
/-!
# Cartesian closed functors
Define the exponential comparison morphisms for a functor which preserves binary products, and use
them to define a cartesian closed functor: one which (naturally) preserves exponentials.
Define the Frobenius morphism, and show it is an isomorphism iff the exponential comparison is an
isomorphism.
## TODO
Some of the results here are true more generally for closed objects and for closed monoidal
categories, and these could be generalised.
## References
https://ncatlab.org/nlab/show/cartesian+closed+functor
https://ncatlab.org/nlab/show/Frobenius+reciprocity
## Tags
Frobenius reciprocity, cartesian closed functor
-/
noncomputable section
namespace CategoryTheory
open Category Limits CartesianClosed
universe v u u'
variable {C : Type u} [Category.{v} C]
variable {D : Type u'} [Category.{v} D]
variable [HasFiniteProducts C] [HasFiniteProducts D]
variable (F : C ⥤ D) {L : D ⥤ C}
/-- The Frobenius morphism for an adjunction `L ⊣ F` at `A` is given by the morphism
L(FA ⨯ B) ⟶ LFA ⨯ LB ⟶ A ⨯ LB
natural in `B`, where the first morphism is the product comparison and the latter uses the counit
of the adjunction.
We will show that if `C` and `D` are cartesian closed, then this morphism is an isomorphism for all
`A` iff `F` is a cartesian closed functor, i.e. it preserves exponentials.
-/
def frobeniusMorphism (h : L ⊣ F) (A : C) :
prod.functor.obj (F.obj A) ⋙ L ⟶ L ⋙ prod.functor.obj A :=
prodComparisonNatTrans L (F.obj A) ≫ whiskerLeft _ (prod.functor.map (h.counit.app _))
/-- If `F` is full and faithful and has a left adjoint `L` which preserves binary products, then the
Frobenius morphism is an isomorphism.
-/
instance frobeniusMorphism_iso_of_preserves_binary_products (h : L ⊣ F) (A : C)
[PreservesLimitsOfShape (Discrete WalkingPair) L] [F.Full] [F.Faithful] :
IsIso (frobeniusMorphism F h A) :=
suffices ∀ (X : D), IsIso ((frobeniusMorphism F h A).app X) from NatIso.isIso_of_isIso_app _
fun B ↦ by dsimp [frobeniusMorphism]; infer_instance
variable [CartesianClosed C] [CartesianClosed D]
variable [PreservesLimitsOfShape (Discrete WalkingPair) F]
/-- The exponential comparison map.
`F` is a cartesian closed functor if this is an iso for all `A`.
-/
def expComparison (A : C) : exp A ⋙ F ⟶ F ⋙ exp (F.obj A) :=
mateEquiv (exp.adjunction A) (exp.adjunction (F.obj A)) (prodComparisonNatIso F A).inv
theorem expComparison_ev (A B : C) :
Limits.prod.map (𝟙 (F.obj A)) ((expComparison F A).app B) ≫ (exp.ev (F.obj A)).app (F.obj B) =
inv (prodComparison F _ _) ≫ F.map ((exp.ev _).app _) := by
convert mateEquiv_counit _ _ (prodComparisonNatIso F A).inv B using 2
apply IsIso.inv_eq_of_hom_inv_id -- Porting note: was `ext`
simp only [Limits.prodComparisonNatIso_inv, asIso_inv, NatIso.isIso_inv_app, IsIso.hom_inv_id]
theorem coev_expComparison (A B : C) :
F.map ((exp.coev A).app B) ≫ (expComparison F A).app (A ⨯ B) =
(exp.coev _).app (F.obj B) ≫ (exp (F.obj A)).map (inv (prodComparison F A B)) := by
convert unit_mateEquiv _ _ (prodComparisonNatIso F A).inv B using 3
apply IsIso.inv_eq_of_hom_inv_id -- Porting note: was `ext`
dsimp
simp
theorem uncurry_expComparison (A B : C) :
CartesianClosed.uncurry ((expComparison F A).app B) =
inv (prodComparison F _ _) ≫ F.map ((exp.ev _).app _) := by
rw [uncurry_eq, expComparison_ev]
/-- The exponential comparison map is natural in `A`. -/
theorem expComparison_whiskerLeft {A A' : C} (f : A' ⟶ A) :
expComparison F A ≫ whiskerLeft _ (pre (F.map f)) =
whiskerRight (pre f) _ ≫ expComparison F A' := by
unfold expComparison pre
have vcomp1 := mateEquiv_conjugateEquiv_vcomp
(exp.adjunction A) (exp.adjunction (F.obj A)) (exp.adjunction (F.obj A'))
((prodComparisonNatIso F A).inv) ((prod.functor.map (F.map f)))
have vcomp2 := conjugateEquiv_mateEquiv_vcomp
(exp.adjunction A) (exp.adjunction A') (exp.adjunction (F.obj A'))
((prod.functor.map f)) ((prodComparisonNatIso F A').inv)
unfold leftAdjointSquareConjugate.vcomp rightAdjointSquareConjugate.vcomp at vcomp1
unfold leftAdjointConjugateSquare.vcomp rightAdjointConjugateSquare.vcomp at vcomp2
rw [← vcomp1, ← vcomp2]
apply congr_arg
ext B
simp only [Functor.comp_obj, prod.functor_obj_obj, prodComparisonNatIso_inv, asIso_inv,
NatTrans.comp_app, whiskerLeft_app, prod.functor_map_app, NatIso.isIso_inv_app,
whiskerRight_app]
rw [← F.map_id]
exact (prodComparison_inv_natural F f (𝟙 B)).symm
/-- The functor `F` is cartesian closed (ie preserves exponentials) if each natural transformation
`exp_comparison F A` is an isomorphism
-/
class CartesianClosedFunctor : Prop where
comparison_iso : ∀ A, IsIso (expComparison F A)
attribute [instance] CartesianClosedFunctor.comparison_iso
theorem frobeniusMorphism_mate (h : L ⊣ F) (A : C) :
conjugateEquiv (h.comp (exp.adjunction A)) ((exp.adjunction (F.obj A)).comp h)
(frobeniusMorphism F h A) =
expComparison F A := by
unfold expComparison frobeniusMorphism
have conjeq := iterated_mateEquiv_conjugateEquiv h h
(exp.adjunction (F.obj A)) (exp.adjunction A)
(prodComparisonNatTrans L (F.obj A) ≫ whiskerLeft L (prod.functor.map (h.counit.app A)))
rw [← conjeq]
apply congr_arg
ext B
unfold mateEquiv
simp only [Functor.comp_obj, prod.functor_obj_obj, Functor.id_obj, Equiv.coe_fn_mk,
whiskerLeft_comp, whiskerLeft_twice, whiskerRight_comp, assoc, NatTrans.comp_app,
whiskerLeft_app, whiskerRight_app, prodComparisonNatTrans_app, prod.functor_map_app,
Functor.comp_map, prod.functor_obj_map, prodComparisonNatIso_inv, asIso_inv,
NatIso.isIso_inv_app]
rw [← F.map_comp, ← F.map_comp]
simp only [prod.map_map, comp_id, id_comp]
apply IsIso.eq_inv_of_inv_hom_id
rw [F.map_comp, assoc, assoc, prodComparison_natural]
slice_lhs 2 3 =>
{
rw [← prodComparison_comp]
}
rw [← assoc]
unfold prodComparison
have ηlemma : (h.unit.app (F.obj A ⨯ F.obj B) ≫
prod.lift ((L ⋙ F).map prod.fst) ((L ⋙ F).map prod.snd)) =
prod.map (h.unit.app (F.obj A)) (h.unit.app (F.obj B)) := by
ext <;> simp
rw [ηlemma]
simp only [Functor.id_obj, Functor.comp_obj, prod.map_map, Adjunction.right_triangle_components,
prod.map_id_id]
/--
If the exponential comparison transformation (at `A`) is an isomorphism, then the Frobenius morphism
at `A` is an isomorphism.
-/
theorem frobeniusMorphism_iso_of_expComparison_iso (h : L ⊣ F) (A : C)
[i : IsIso (expComparison F A)] : IsIso (frobeniusMorphism F h A) := by
rw [← frobeniusMorphism_mate F h] at i
exact @conjugateEquiv_of_iso _ _ _ _ _ _ _ _ _ _ _ i
/--
If the Frobenius morphism at `A` is an isomorphism, then the exponential comparison transformation
(at `A`) is an isomorphism.
-/
theorem expComparison_iso_of_frobeniusMorphism_iso (h : L ⊣ F) (A : C)
[i : IsIso (frobeniusMorphism F h A)] : IsIso (expComparison F A) := by
rw [← frobeniusMorphism_mate F h]; infer_instance
/-- If `F` is full and faithful, and has a left adjoint which preserves binary products, then it is
cartesian closed.
TODO: Show the converse, that if `F` is cartesian closed and its left adjoint preserves binary
products, then it is full and faithful.
-/
theorem cartesianClosedFunctorOfLeftAdjointPreservesBinaryProducts (h : L ⊣ F) [F.Full] [F.Faithful]
[PreservesLimitsOfShape (Discrete WalkingPair) L] : CartesianClosedFunctor F where
comparison_iso _ := expComparison_iso_of_frobeniusMorphism_iso F h _
end CategoryTheory
|
CategoryTheory\Closed\FunctorCategory.lean | /-
Copyright (c) 2022 Antoine Labelle. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Antoine Labelle
-/
import Mathlib.CategoryTheory.Closed.Monoidal
import Mathlib.CategoryTheory.Functor.Currying
import Mathlib.CategoryTheory.Monoidal.FunctorCategory
/-!
# Functors from a groupoid into a monoidal closed category form a monoidal closed category.
(Using the pointwise monoidal structure on the functor category.)
-/
noncomputable section
open CategoryTheory CategoryTheory.MonoidalCategory CategoryTheory.MonoidalClosed
namespace CategoryTheory.Functor
variable {D C : Type*} [Groupoid D] [Category C] [MonoidalCategory C] [MonoidalClosed C]
/-- Auxiliary definition for `CategoryTheory.Functor.closed`.
The internal hom functor `F ⟶[C] -` -/
@[simps!]
def closedIhom (F : D ⥤ C) : (D ⥤ C) ⥤ D ⥤ C :=
((whiskeringRight₂ D Cᵒᵖ C C).obj internalHom).obj (Groupoid.invFunctor D ⋙ F.op)
/-- Auxiliary definition for `CategoryTheory.Functor.closed`.
The unit for the adjunction `(tensorLeft F) ⊣ (ihom F)`. -/
@[simps]
def closedUnit (F : D ⥤ C) : 𝟭 (D ⥤ C) ⟶ tensorLeft F ⋙ closedIhom F where
app G :=
{ app := fun X => (ihom.coev (F.obj X)).app (G.obj X)
naturality := by
intro X Y f
dsimp
simp only [ihom.coev_naturality, closedIhom_obj_map, Monoidal.tensorObj_map]
dsimp
rw [coev_app_comp_pre_app_assoc, ← Functor.map_comp, tensorHom_def]
simp }
/-- Auxiliary definition for `CategoryTheory.Functor.closed`.
The counit for the adjunction `(tensorLeft F) ⊣ (ihom F)`. -/
@[simps]
def closedCounit (F : D ⥤ C) : closedIhom F ⋙ tensorLeft F ⟶ 𝟭 (D ⥤ C) where
app G :=
{ app := fun X => (ihom.ev (F.obj X)).app (G.obj X)
naturality := by
intro X Y f
dsimp
simp only [closedIhom_obj_map, pre_comm_ihom_map]
rw [tensorHom_def]
simp }
/-- If `C` is a monoidal closed category and `D` is a groupoid, then every functor `F : D ⥤ C` is
closed in the functor category `F : D ⥤ C` with the pointwise monoidal structure. -/
-- Porting note: removed `@[simps]`, as some of the generated lemmas were failing the simpNF linter,
-- and none of the generated lemmas was actually used in mathlib3.
instance closed (F : D ⥤ C) : Closed F where
rightAdj := closedIhom F
adj :=
Adjunction.mkOfUnitCounit
{ unit := closedUnit F
counit := closedCounit F }
/-- If `C` is a monoidal closed category and `D` is groupoid, then the functor category `D ⥤ C`,
with the pointwise monoidal structure, is monoidal closed. -/
@[simps! closed_adj]
instance monoidalClosed : MonoidalClosed (D ⥤ C) where
theorem ihom_map (F : D ⥤ C) {G H : D ⥤ C} (f : G ⟶ H) : (ihom F).map f = (closedIhom F).map f :=
rfl
theorem ihom_ev_app (F G : D ⥤ C) : (ihom.ev F).app G = (closedCounit F).app G :=
rfl
theorem ihom_coev_app (F G : D ⥤ C) : (ihom.coev F).app G = (closedUnit F).app G :=
rfl
end CategoryTheory.Functor
|
CategoryTheory\Closed\Ideal.lean | /-
Copyright (c) 2021 Bhavik Mehta. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Bhavik Mehta
-/
import Mathlib.CategoryTheory.Limits.Preserves.Shapes.BinaryProducts
import Mathlib.CategoryTheory.Limits.Constructions.FiniteProductsOfBinaryProducts
import Mathlib.CategoryTheory.Monad.Limits
import Mathlib.CategoryTheory.Adjunction.FullyFaithful
import Mathlib.CategoryTheory.Adjunction.Limits
import Mathlib.CategoryTheory.Adjunction.Reflective
import Mathlib.CategoryTheory.Closed.Cartesian
import Mathlib.CategoryTheory.Subterminal
/-!
# Exponential ideals
An exponential ideal of a cartesian closed category `C` is a subcategory `D ⊆ C` such that for any
`B : D` and `A : C`, the exponential `A ⟹ B` is in `D`: resembling ring theoretic ideals. We
define the notion here for inclusion functors `i : D ⥤ C` rather than explicit subcategories to
preserve the principle of equivalence.
We additionally show that if `C` is cartesian closed and `i : D ⥤ C` is a reflective functor, the
following are equivalent.
* The left adjoint to `i` preserves binary (equivalently, finite) products.
* `i` is an exponential ideal.
-/
universe v₁ v₂ u₁ u₂
noncomputable section
namespace CategoryTheory
open Limits Category
section Ideal
variable {C : Type u₁} {D : Type u₂} [Category.{v₁} C] [Category.{v₁} D] {i : D ⥤ C}
variable (i) [HasFiniteProducts C] [CartesianClosed C]
/-- The subcategory `D` of `C` expressed as an inclusion functor is an *exponential ideal* if
`B ∈ D` implies `A ⟹ B ∈ D` for all `A`.
-/
class ExponentialIdeal : Prop where
exp_closed : ∀ {B}, B ∈ i.essImage → ∀ A, (A ⟹ B) ∈ i.essImage
attribute [nolint docBlame] ExponentialIdeal.exp_closed
/-- To show `i` is an exponential ideal it suffices to show that `A ⟹ iB` is "in" `D` for any `A` in
`C` and `B` in `D`.
-/
theorem ExponentialIdeal.mk' (h : ∀ (B : D) (A : C), (A ⟹ i.obj B) ∈ i.essImage) :
ExponentialIdeal i :=
⟨fun hB A => by
rcases hB with ⟨B', ⟨iB'⟩⟩
exact Functor.essImage.ofIso ((exp A).mapIso iB') (h B' A)⟩
/-- The entire category viewed as a subcategory is an exponential ideal. -/
instance : ExponentialIdeal (𝟭 C) :=
ExponentialIdeal.mk' _ fun _ _ => ⟨_, ⟨Iso.refl _⟩⟩
open CartesianClosed
/-- The subcategory of subterminal objects is an exponential ideal. -/
instance : ExponentialIdeal (subterminalInclusion C) := by
apply ExponentialIdeal.mk'
intro B A
refine ⟨⟨A ⟹ B.1, fun Z g h => ?_⟩, ⟨Iso.refl _⟩⟩
exact uncurry_injective (B.2 (CartesianClosed.uncurry g) (CartesianClosed.uncurry h))
/-- If `D` is a reflective subcategory, the property of being an exponential ideal is equivalent to
the presence of a natural isomorphism `i ⋙ exp A ⋙ leftAdjoint i ⋙ i ≅ i ⋙ exp A`, that is:
`(A ⟹ iB) ≅ i L (A ⟹ iB)`, naturally in `B`.
The converse is given in `ExponentialIdeal.mk_of_iso`.
-/
def exponentialIdealReflective (A : C) [Reflective i] [ExponentialIdeal i] :
i ⋙ exp A ⋙ reflector i ⋙ i ≅ i ⋙ exp A := by
symm
apply NatIso.ofComponents _ _
· intro X
haveI := Functor.essImage.unit_isIso (ExponentialIdeal.exp_closed (i.obj_mem_essImage X) A)
apply asIso ((reflectorAdjunction i).unit.app (A ⟹ i.obj X))
· simp [asIso]
/-- Given a natural isomorphism `i ⋙ exp A ⋙ leftAdjoint i ⋙ i ≅ i ⋙ exp A`, we can show `i`
is an exponential ideal.
-/
theorem ExponentialIdeal.mk_of_iso [Reflective i]
(h : ∀ A : C, i ⋙ exp A ⋙ reflector i ⋙ i ≅ i ⋙ exp A) : ExponentialIdeal i := by
apply ExponentialIdeal.mk'
intro B A
exact ⟨_, ⟨(h A).app B⟩⟩
end Ideal
section
variable {C : Type u₁} {D : Type u₂} [Category.{v₁} C] [Category.{v₁} D]
variable (i : D ⥤ C)
-- Porting note: this used to be used as a local instance,
-- now it can instead be used as a have when needed
-- we assume HasFiniteProducts D as a hypothesis below
theorem reflective_products [HasFiniteProducts C] [Reflective i] : HasFiniteProducts D :=
⟨fun _ => hasLimitsOfShape_of_reflective i⟩
open CartesianClosed
variable [HasFiniteProducts C] [Reflective i] [CartesianClosed C] [HasFiniteProducts D]
/-- If the reflector preserves binary products, the subcategory is an exponential ideal.
This is the converse of `preservesBinaryProductsOfExponentialIdeal`.
-/
instance (priority := 10) exponentialIdeal_of_preservesBinaryProducts
[PreservesLimitsOfShape (Discrete WalkingPair) (reflector i)] : ExponentialIdeal i := by
let ir := reflectorAdjunction i
let L : C ⥤ D := reflector i
let η : 𝟭 C ⟶ L ⋙ i := ir.unit
let ε : i ⋙ L ⟶ 𝟭 D := ir.counit
apply ExponentialIdeal.mk'
intro B A
let q : i.obj (L.obj (A ⟹ i.obj B)) ⟶ A ⟹ i.obj B := by
apply CartesianClosed.curry (ir.homEquiv _ _ _)
apply _ ≫ (ir.homEquiv _ _).symm ((exp.ev A).app (i.obj B))
exact prodComparison L A _ ≫ Limits.prod.map (𝟙 _) (ε.app _) ≫ inv (prodComparison _ _ _)
have : η.app (A ⟹ i.obj B) ≫ q = 𝟙 (A ⟹ i.obj B) := by
dsimp
rw [← curry_natural_left, curry_eq_iff, uncurry_id_eq_ev, ← ir.homEquiv_naturality_left,
ir.homEquiv_apply_eq, assoc, assoc, prodComparison_natural_assoc, L.map_id,
← prod.map_id_comp_assoc, ir.left_triangle_components, prod.map_id_id, id_comp]
apply IsIso.hom_inv_id_assoc
haveI : IsSplitMono (η.app (A ⟹ i.obj B)) := IsSplitMono.mk' ⟨_, this⟩
apply mem_essImage_of_unit_isSplitMono
variable [ExponentialIdeal i]
/-- If `i` witnesses that `D` is a reflective subcategory and an exponential ideal, then `D` is
itself cartesian closed.
-/
def cartesianClosedOfReflective : CartesianClosed D :=
{ __ := monoidalOfHasFiniteProducts D -- Porting note (#10754): added this instance
closed := fun B =>
{ rightAdj := i ⋙ exp (i.obj B) ⋙ reflector i
adj := by
apply (exp.adjunction (i.obj B)).restrictFullyFaithful i.fullyFaithfulOfReflective
i.fullyFaithfulOfReflective
· symm
refine NatIso.ofComponents (fun X => ?_) (fun f => ?_)
· haveI :=
Adjunction.rightAdjointPreservesLimits.{0, 0} (reflectorAdjunction i)
apply asIso (prodComparison i B X)
· dsimp [asIso]
rw [prodComparison_natural, Functor.map_id]
· apply (exponentialIdealReflective i _).symm } }
-- It's annoying that I need to do this.
attribute [-instance] CategoryTheory.preservesLimitOfCreatesLimitAndHasLimit
CategoryTheory.preservesLimitOfShapeOfCreatesLimitsOfShapeAndHasLimitsOfShape
/-- We construct a bijection between morphisms `L(A ⨯ B) ⟶ X` and morphisms `LA ⨯ LB ⟶ X`.
This bijection has two key properties:
* It is natural in `X`: See `bijection_natural`.
* When `X = LA ⨯ LB`, then the backwards direction sends the identity morphism to the product
comparison morphism: See `bijection_symm_apply_id`.
Together these help show that `L` preserves binary products. This should be considered
*internal implementation* towards `preservesBinaryProductsOfExponentialIdeal`.
-/
noncomputable def bijection (A B : C) (X : D) :
((reflector i).obj (A ⨯ B) ⟶ X) ≃ ((reflector i).obj A ⨯ (reflector i).obj B ⟶ X) :=
calc
_ ≃ (A ⨯ B ⟶ i.obj X) := (reflectorAdjunction i).homEquiv _ _
_ ≃ (B ⨯ A ⟶ i.obj X) := (Limits.prod.braiding _ _).homCongr (Iso.refl _)
_ ≃ (A ⟶ B ⟹ i.obj X) := (exp.adjunction _).homEquiv _ _
_ ≃ (i.obj ((reflector i).obj A) ⟶ B ⟹ i.obj X) :=
(unitCompPartialBijective _ (ExponentialIdeal.exp_closed (i.obj_mem_essImage _) _))
_ ≃ (B ⨯ i.obj ((reflector i).obj A) ⟶ i.obj X) := ((exp.adjunction _).homEquiv _ _).symm
_ ≃ (i.obj ((reflector i).obj A) ⨯ B ⟶ i.obj X) :=
((Limits.prod.braiding _ _).homCongr (Iso.refl _))
_ ≃ (B ⟶ i.obj ((reflector i).obj A) ⟹ i.obj X) := (exp.adjunction _).homEquiv _ _
_ ≃ (i.obj ((reflector i).obj B) ⟶ i.obj ((reflector i).obj A) ⟹ i.obj X) :=
(unitCompPartialBijective _ (ExponentialIdeal.exp_closed (i.obj_mem_essImage _) _))
_ ≃ (i.obj ((reflector i).obj A) ⨯ i.obj ((reflector i).obj B) ⟶ i.obj X) :=
((exp.adjunction _).homEquiv _ _).symm
_ ≃ (i.obj ((reflector i).obj A ⨯ (reflector i).obj B) ⟶ i.obj X) :=
haveI : PreservesLimits i := (reflectorAdjunction i).rightAdjointPreservesLimits
haveI := preservesSmallestLimitsOfPreservesLimits i
Iso.homCongr (PreservesLimitPair.iso _ _ _).symm (Iso.refl (i.obj X))
_ ≃ ((reflector i).obj A ⨯ (reflector i).obj B ⟶ X) :=
i.fullyFaithfulOfReflective.homEquiv.symm
theorem bijection_symm_apply_id (A B : C) :
(bijection i A B _).symm (𝟙 _) = prodComparison _ _ _ := by
dsimp [bijection]
-- Porting note: added
erw [homEquiv_symm_apply_eq, homEquiv_symm_apply_eq, homEquiv_apply_eq, homEquiv_apply_eq]
rw [comp_id, comp_id, comp_id, i.map_id, comp_id, unitCompPartialBijective_symm_apply,
unitCompPartialBijective_symm_apply, uncurry_natural_left, uncurry_curry,
uncurry_natural_left, uncurry_curry, prod.lift_map_assoc, comp_id, prod.lift_map_assoc, comp_id]
-- Porting note: added
dsimp only [Functor.comp_obj]
rw [prod.comp_lift_assoc, prod.lift_snd, prod.lift_fst_assoc, prod.lift_fst_comp_snd_comp,
← Adjunction.eq_homEquiv_apply, Adjunction.homEquiv_unit, Iso.comp_inv_eq, assoc]
rw [PreservesLimitPair.iso_hom i ((reflector i).obj A) ((reflector i).obj B)]
apply prod.hom_ext
· rw [Limits.prod.map_fst, assoc, assoc, prodComparison_fst, ← i.map_comp, prodComparison_fst]
apply (reflectorAdjunction i).unit.naturality
· rw [Limits.prod.map_snd, assoc, assoc, prodComparison_snd, ← i.map_comp, prodComparison_snd]
apply (reflectorAdjunction i).unit.naturality
theorem bijection_natural (A B : C) (X X' : D) (f : (reflector i).obj (A ⨯ B) ⟶ X) (g : X ⟶ X') :
bijection i _ _ _ (f ≫ g) = bijection i _ _ _ f ≫ g := by
dsimp [bijection]
-- Porting note: added
erw [homEquiv_symm_apply_eq, homEquiv_symm_apply_eq, homEquiv_apply_eq, homEquiv_apply_eq,
homEquiv_symm_apply_eq, homEquiv_symm_apply_eq, homEquiv_apply_eq, homEquiv_apply_eq]
apply i.map_injective
rw [Functor.FullyFaithful.map_preimage, i.map_comp, Functor.FullyFaithful.map_preimage,
comp_id, comp_id, comp_id, comp_id, comp_id,
comp_id, Adjunction.homEquiv_naturality_right, ← assoc, curry_natural_right _ (i.map g),
unitCompPartialBijective_natural, uncurry_natural_right, ← assoc, curry_natural_right,
unitCompPartialBijective_natural, uncurry_natural_right, assoc]
/--
The bijection allows us to show that `prodComparison L A B` is an isomorphism, where the inverse
is the forward map of the identity morphism.
-/
theorem prodComparison_iso (A B : C) : IsIso (prodComparison (reflector i) A B) :=
⟨⟨bijection i _ _ _ (𝟙 _), by
rw [← (bijection i _ _ _).injective.eq_iff, bijection_natural, ← bijection_symm_apply_id,
Equiv.apply_symm_apply, id_comp],
by rw [← bijection_natural, id_comp, ← bijection_symm_apply_id, Equiv.apply_symm_apply]⟩⟩
attribute [local instance] prodComparison_iso
/--
If a reflective subcategory is an exponential ideal, then the reflector preserves binary products.
This is the converse of `exponentialIdeal_of_preserves_binary_products`.
-/
noncomputable def preservesBinaryProductsOfExponentialIdeal :
PreservesLimitsOfShape (Discrete WalkingPair) (reflector i) where
preservesLimit {K} :=
letI := PreservesLimitPair.ofIsoProdComparison
(reflector i) (K.obj ⟨WalkingPair.left⟩) (K.obj ⟨WalkingPair.right⟩)
Limits.preservesLimitOfIsoDiagram _ (diagramIsoPair K).symm
/--
If a reflective subcategory is an exponential ideal, then the reflector preserves finite products.
-/
noncomputable def preservesFiniteProductsOfExponentialIdeal (J : Type) [Fintype J] :
PreservesLimitsOfShape (Discrete J) (reflector i) := by
letI := preservesBinaryProductsOfExponentialIdeal i
letI : PreservesLimitsOfShape _ (reflector i) := leftAdjointPreservesTerminalOfReflective.{0} i
apply preservesFiniteProductsOfPreservesBinaryAndTerminal (reflector i) J
end
end CategoryTheory
|
CategoryTheory\Closed\Monoidal.lean | /-
Copyright (c) 2020 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Scott Morrison, Bhavik Mehta
-/
import Mathlib.CategoryTheory.Monoidal.Functor
import Mathlib.CategoryTheory.Adjunction.Limits
import Mathlib.CategoryTheory.Adjunction.Mates
/-!
# Closed monoidal categories
Define (right) closed objects and (right) closed monoidal categories.
## TODO
Some of the theorems proved about cartesian closed categories
should be generalised and moved to this file.
-/
universe v u u₂ v₂
namespace CategoryTheory
open Category MonoidalCategory
-- Note that this class carries a particular choice of right adjoint,
-- (which is only unique up to isomorphism),
-- not merely the existence of such, and
-- so definitional properties of instances may be important.
/-- An object `X` is (right) closed if `(X ⊗ -)` is a left adjoint. -/
class Closed {C : Type u} [Category.{v} C] [MonoidalCategory.{v} C] (X : C) where
/-- a choice of a right adjoint for `tensorLeft X` -/
rightAdj : C ⥤ C
/-- `tensorLeft X` is a left adjoint -/
adj : tensorLeft X ⊣ rightAdj
/-- A monoidal category `C` is (right) monoidal closed if every object is (right) closed. -/
class MonoidalClosed (C : Type u) [Category.{v} C] [MonoidalCategory.{v} C] where
closed (X : C) : Closed X := by infer_instance
attribute [instance 100] MonoidalClosed.closed
variable {C : Type u} [Category.{v} C] [MonoidalCategory.{v} C]
/-- If `X` and `Y` are closed then `X ⊗ Y` is.
This isn't an instance because it's not usually how we want to construct internal homs,
we'll usually prove all objects are closed uniformly.
-/
def tensorClosed {X Y : C} (hX : Closed X) (hY : Closed Y) : Closed (X ⊗ Y) where
adj := (hY.adj.comp hX.adj).ofNatIsoLeft (MonoidalCategory.tensorLeftTensor X Y).symm
/-- The unit object is always closed.
This isn't an instance because most of the time we'll prove closedness for all objects at once,
rather than just for this one.
-/
def unitClosed : Closed (𝟙_ C) where
rightAdj := 𝟭 C
adj := Adjunction.id.ofNatIsoLeft (MonoidalCategory.leftUnitorNatIso C).symm
variable (A B : C) {X X' Y Y' Z : C}
variable [Closed A]
/-- This is the internal hom `A ⟶[C] -`.
-/
def ihom : C ⥤ C :=
Closed.rightAdj (X := A)
namespace ihom
/-- The adjunction between `A ⊗ -` and `A ⟹ -`. -/
def adjunction : tensorLeft A ⊣ ihom A :=
Closed.adj
/-- The evaluation natural transformation. -/
def ev : ihom A ⋙ tensorLeft A ⟶ 𝟭 C :=
(ihom.adjunction A).counit
/-- The coevaluation natural transformation. -/
def coev : 𝟭 C ⟶ tensorLeft A ⋙ ihom A :=
(ihom.adjunction A).unit
@[simp]
theorem ihom_adjunction_counit : (ihom.adjunction A).counit = ev A :=
rfl
@[simp]
theorem ihom_adjunction_unit : (ihom.adjunction A).unit = coev A :=
rfl
@[reassoc (attr := simp)]
theorem ev_naturality {X Y : C} (f : X ⟶ Y) :
A ◁ (ihom A).map f ≫ (ev A).app Y = (ev A).app X ≫ f :=
(ev A).naturality f
@[reassoc (attr := simp)]
theorem coev_naturality {X Y : C} (f : X ⟶ Y) :
f ≫ (coev A).app Y = (coev A).app X ≫ (ihom A).map (A ◁ f) :=
(coev A).naturality f
set_option quotPrecheck false in
/-- `A ⟶[C] B` denotes the internal hom from `A` to `B` -/
notation A " ⟶[" C "] " B:10 => (@ihom C _ _ A _).obj B
@[reassoc (attr := simp)]
theorem ev_coev : (A ◁ (coev A).app B) ≫ (ev A).app (A ⊗ B) = 𝟙 (A ⊗ B) :=
(ihom.adjunction A).left_triangle_components _
@[reassoc (attr := simp)]
theorem coev_ev : (coev A).app (A ⟶[C] B) ≫ (ihom A).map ((ev A).app B) = 𝟙 (A ⟶[C] B) :=
Adjunction.right_triangle_components (ihom.adjunction A) _
end ihom
open CategoryTheory.Limits
instance : PreservesColimits (tensorLeft A) :=
(ihom.adjunction A).leftAdjointPreservesColimits
variable {A}
-- Wrap these in a namespace so we don't clash with the core versions.
namespace MonoidalClosed
/-- Currying in a monoidal closed category. -/
def curry : (A ⊗ Y ⟶ X) → (Y ⟶ A ⟶[C] X) :=
(ihom.adjunction A).homEquiv _ _
/-- Uncurrying in a monoidal closed category. -/
def uncurry : (Y ⟶ A ⟶[C] X) → (A ⊗ Y ⟶ X) :=
((ihom.adjunction A).homEquiv _ _).symm
-- This lemma has always been bad, but the linter only noticed after lean4#2644.
@[simp, nolint simpNF]
theorem homEquiv_apply_eq (f : A ⊗ Y ⟶ X) : (ihom.adjunction A).homEquiv _ _ f = curry f :=
rfl
-- This lemma has always been bad, but the linter only noticed after lean4#2644.
@[simp, nolint simpNF]
theorem homEquiv_symm_apply_eq (f : Y ⟶ A ⟶[C] X) :
((ihom.adjunction A).homEquiv _ _).symm f = uncurry f :=
rfl
@[reassoc]
theorem curry_natural_left (f : X ⟶ X') (g : A ⊗ X' ⟶ Y) : curry (_ ◁ f ≫ g) = f ≫ curry g :=
Adjunction.homEquiv_naturality_left _ _ _
@[reassoc]
theorem curry_natural_right (f : A ⊗ X ⟶ Y) (g : Y ⟶ Y') :
curry (f ≫ g) = curry f ≫ (ihom _).map g :=
Adjunction.homEquiv_naturality_right _ _ _
@[reassoc]
theorem uncurry_natural_right (f : X ⟶ A ⟶[C] Y) (g : Y ⟶ Y') :
uncurry (f ≫ (ihom _).map g) = uncurry f ≫ g :=
Adjunction.homEquiv_naturality_right_symm _ _ _
@[reassoc]
theorem uncurry_natural_left (f : X ⟶ X') (g : X' ⟶ A ⟶[C] Y) :
uncurry (f ≫ g) = _ ◁ f ≫ uncurry g :=
Adjunction.homEquiv_naturality_left_symm _ _ _
@[simp]
theorem uncurry_curry (f : A ⊗ X ⟶ Y) : uncurry (curry f) = f :=
(Closed.adj.homEquiv _ _).left_inv f
@[simp]
theorem curry_uncurry (f : X ⟶ A ⟶[C] Y) : curry (uncurry f) = f :=
(Closed.adj.homEquiv _ _).right_inv f
theorem curry_eq_iff (f : A ⊗ Y ⟶ X) (g : Y ⟶ A ⟶[C] X) : curry f = g ↔ f = uncurry g :=
Adjunction.homEquiv_apply_eq (ihom.adjunction A) f g
theorem eq_curry_iff (f : A ⊗ Y ⟶ X) (g : Y ⟶ A ⟶[C] X) : g = curry f ↔ uncurry g = f :=
Adjunction.eq_homEquiv_apply (ihom.adjunction A) f g
-- I don't think these two should be simp.
theorem uncurry_eq (g : Y ⟶ A ⟶[C] X) : uncurry g = (A ◁ g) ≫ (ihom.ev A).app X :=
Adjunction.homEquiv_counit _
theorem curry_eq (g : A ⊗ Y ⟶ X) : curry g = (ihom.coev A).app Y ≫ (ihom A).map g :=
Adjunction.homEquiv_unit _
theorem curry_injective : Function.Injective (curry : (A ⊗ Y ⟶ X) → (Y ⟶ A ⟶[C] X)) :=
(Closed.adj.homEquiv _ _).injective
theorem uncurry_injective : Function.Injective (uncurry : (Y ⟶ A ⟶[C] X) → (A ⊗ Y ⟶ X)) :=
(Closed.adj.homEquiv _ _).symm.injective
variable (A X)
theorem uncurry_id_eq_ev : uncurry (𝟙 (A ⟶[C] X)) = (ihom.ev A).app X := by
simp [uncurry_eq]
theorem curry_id_eq_coev : curry (𝟙 _) = (ihom.coev A).app X := by
rw [curry_eq, (ihom A).map_id (A ⊗ _)]
apply comp_id
section Pre
variable {A B}
variable [Closed B]
/-- Pre-compose an internal hom with an external hom. -/
def pre (f : B ⟶ A) : ihom A ⟶ ihom B :=
conjugateEquiv (ihom.adjunction _) (ihom.adjunction _) ((tensoringLeft C).map f)
@[reassoc (attr := simp)]
theorem id_tensor_pre_app_comp_ev (f : B ⟶ A) (X : C) :
B ◁ (pre f).app X ≫ (ihom.ev B).app X = f ▷ (A ⟶[C] X) ≫ (ihom.ev A).app X :=
conjugateEquiv_counit _ _ ((tensoringLeft C).map f) X
@[simp]
theorem uncurry_pre (f : B ⟶ A) (X : C) :
MonoidalClosed.uncurry ((pre f).app X) = f ▷ _ ≫ (ihom.ev A).app X := by
simp [uncurry_eq]
@[reassoc (attr := simp)]
theorem coev_app_comp_pre_app (f : B ⟶ A) :
(ihom.coev A).app X ≫ (pre f).app (A ⊗ X) = (ihom.coev B).app X ≫ (ihom B).map (f ▷ _) :=
unit_conjugateEquiv _ _ ((tensoringLeft C).map f) X
@[simp]
theorem pre_id (A : C) [Closed A] : pre (𝟙 A) = 𝟙 _ := by
rw [pre, Functor.map_id]
apply conjugateEquiv_id
@[simp]
theorem pre_map {A₁ A₂ A₃ : C} [Closed A₁] [Closed A₂] [Closed A₃] (f : A₁ ⟶ A₂) (g : A₂ ⟶ A₃) :
pre (f ≫ g) = pre g ≫ pre f := by
rw [pre, pre, pre, conjugateEquiv_comp, (tensoringLeft C).map_comp]
theorem pre_comm_ihom_map {W X Y Z : C} [Closed W] [Closed X] (f : W ⟶ X) (g : Y ⟶ Z) :
(pre f).app Y ≫ (ihom W).map g = (ihom X).map g ≫ (pre f).app Z := by simp
end Pre
/-- The internal hom functor given by the monoidal closed structure. -/
@[simps]
def internalHom [MonoidalClosed C] : Cᵒᵖ ⥤ C ⥤ C where
obj X := ihom X.unop
map f := pre f.unop
section OfEquiv
variable {D : Type u₂} [Category.{v₂} D] [MonoidalCategory.{v₂} D]
variable (F : MonoidalFunctor C D) {G : D ⥤ C} (adj : F.toFunctor ⊣ G)
[F.IsEquivalence] [MonoidalClosed D]
/-- Transport the property of being monoidal closed across a monoidal equivalence of categories -/
noncomputable def ofEquiv : MonoidalClosed C where
closed X :=
{ rightAdj := F.toFunctor ⋙ ihom (F.obj X) ⋙ G
adj := (adj.comp ((ihom.adjunction (F.obj X)).comp
adj.toEquivalence.symm.toAdjunction)).ofNatIsoLeft
(Iso.compInverseIso (H := adj.toEquivalence) (MonoidalFunctor.commTensorLeft F X)) }
/-- Suppose we have a monoidal equivalence `F : C ≌ D`, with `D` monoidal closed. We can pull the
monoidal closed instance back along the equivalence. For `X, Y, Z : C`, this lemma describes the
resulting currying map `Hom(X ⊗ Y, Z) → Hom(Y, (X ⟶[C] Z))`. (`X ⟶[C] Z` is defined to be
`F⁻¹(F(X) ⟶[D] F(Z))`, so currying in `C` is given by essentially conjugating currying in
`D` by `F.`) -/
theorem ofEquiv_curry_def {X Y Z : C} (f : X ⊗ Y ⟶ Z) :
letI := ofEquiv F adj
MonoidalClosed.curry f =
adj.homEquiv Y ((ihom (F.obj X)).obj (F.obj Z))
(MonoidalClosed.curry (adj.toEquivalence.symm.toAdjunction.homEquiv (F.obj X ⊗ F.obj Y) Z
((Iso.compInverseIso (H := adj.toEquivalence)
(MonoidalFunctor.commTensorLeft F X)).hom.app Y ≫ f))) :=
rfl
/-- Suppose we have a monoidal equivalence `F : C ≌ D`, with `D` monoidal closed. We can pull the
monoidal closed instance back along the equivalence. For `X, Y, Z : C`, this lemma describes the
resulting uncurrying map `Hom(Y, (X ⟶[C] Z)) → Hom(X ⊗ Y ⟶ Z)`. (`X ⟶[C] Z` is
defined to be `F⁻¹(F(X) ⟶[D] F(Z))`, so uncurrying in `C` is given by essentially conjugating
uncurrying in `D` by `F.`) -/
theorem ofEquiv_uncurry_def {X Y Z : C} :
letI := ofEquiv F adj
∀ (f : Y ⟶ (ihom X).obj Z), MonoidalClosed.uncurry f =
((Iso.compInverseIso (H := adj.toEquivalence)
(MonoidalFunctor.commTensorLeft F X)).inv.app Y) ≫
(adj.toEquivalence.symm.toAdjunction.homEquiv _ _).symm
(MonoidalClosed.uncurry ((adj.homEquiv _ _).symm f)) :=
fun _ => rfl
end OfEquiv
end MonoidalClosed
attribute [nolint simpNF] CategoryTheory.MonoidalClosed.homEquiv_apply_eq
CategoryTheory.MonoidalClosed.homEquiv_symm_apply_eq
end CategoryTheory
|
CategoryTheory\Closed\Types.lean | /-
Copyright (c) 2020 Bhavik Mehta. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Bhavik Mehta
-/
import Mathlib.CategoryTheory.Limits.Presheaf
import Mathlib.CategoryTheory.Limits.Preserves.FunctorCategory
import Mathlib.CategoryTheory.Limits.Shapes.Types
import Mathlib.CategoryTheory.Closed.Cartesian
/-!
# Cartesian closure of Type
Show that `Type u₁` is cartesian closed, and `C ⥤ Type u₁` is cartesian closed for `C` a small
category in `Type u₁`.
Note this implies that the category of presheaves on a small category `C` is cartesian closed.
-/
namespace CategoryTheory
noncomputable section
open Category Limits
universe v₁ v₂ u₁ u₂
variable {C : Type v₂} [Category.{v₁} C]
section CartesianClosed
/-- The adjunction `Limits.Types.binaryProductFunctor.obj X ⊣ coyoneda.obj (Opposite.op X)`
for any `X : Type v₁`. -/
def Types.binaryProductAdjunction (X : Type v₁) :
Limits.Types.binaryProductFunctor.obj X ⊣ coyoneda.obj (Opposite.op X) :=
Adjunction.mkOfUnitCounit
{ unit := { app := fun Z (z : Z) x => ⟨x, z⟩ }
counit := { app := fun Z xf => xf.2 xf.1 } }
instance (X : Type v₁) : (Types.binaryProductFunctor.obj X).IsLeftAdjoint :=
⟨_, ⟨Types.binaryProductAdjunction X⟩⟩
-- Porting note: this instance should be moved to a higher file.
instance : HasFiniteProducts (Type v₁) :=
hasFiniteProducts_of_hasProducts.{v₁} _
instance : CartesianClosed (Type v₁) := CartesianClosed.mk _
(fun X => Exponentiable.mk _ _
((Types.binaryProductAdjunction X).ofNatIsoLeft (Types.binaryProductIsoProd.app X)))
-- Porting note: in mathlib3, the assertion was for `(C ⥤ Type u₁)`, but then Lean4 was
-- confused with universes. It makes no harm to relax the universe assumptions here.
instance {C : Type u₁} [Category.{v₁} C] : HasFiniteProducts (C ⥤ Type u₂) :=
hasFiniteProducts_of_hasProducts _
instance {C : Type v₁} [SmallCategory C] : CartesianClosed (C ⥤ Type v₁) :=
CartesianClosed.mk _
(fun F => by
letI := FunctorCategory.prodPreservesColimits F
have := Presheaf.isLeftAdjoint_of_preservesColimits (prod.functor.obj F)
exact Exponentiable.mk _ _ (Adjunction.ofIsLeftAdjoint (prod.functor.obj F)))
end CartesianClosed
end
end CategoryTheory
|
CategoryTheory\Closed\Zero.lean | /-
Copyright (c) 2020 Bhavik Mehta. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Bhavik Mehta
-/
import Mathlib.CategoryTheory.Closed.Cartesian
import Mathlib.CategoryTheory.PUnit
import Mathlib.CategoryTheory.Limits.Shapes.ZeroObjects
/-!
# A cartesian closed category with zero object is trivial
A cartesian closed category with zero object is trivial: it is equivalent to the category with one
object and one morphism.
## References
* https://mathoverflow.net/a/136480
-/
universe w v u
noncomputable section
namespace CategoryTheory
open Category Limits
variable {C : Type u} [Category.{v} C]
variable [HasFiniteProducts C] [CartesianClosed C]
/-- If a cartesian closed category has an initial object which is isomorphic to the terminal object,
then each homset has exactly one element.
-/
def uniqueHomsetOfInitialIsoTerminal [HasInitial C] (i : ⊥_ C ≅ ⊤_ C) (X Y : C) : Unique (X ⟶ Y) :=
Equiv.unique <|
calc
(X ⟶ Y) ≃ (X ⨯ ⊤_ C ⟶ Y) := Iso.homCongr (prod.rightUnitor _).symm (Iso.refl _)
_ ≃ (X ⨯ ⊥_ C ⟶ Y) := (Iso.homCongr (prod.mapIso (Iso.refl _) i.symm) (Iso.refl _))
_ ≃ (⊥_ C ⟶ Y ^^ X) := (exp.adjunction _).homEquiv _ _
open scoped ZeroObject
/-- If a cartesian closed category has a zero object, each homset has exactly one element. -/
def uniqueHomsetOfZero [HasZeroObject C] (X Y : C) : Unique (X ⟶ Y) := by
haveI : HasInitial C := HasZeroObject.hasInitial
apply uniqueHomsetOfInitialIsoTerminal _ X Y
refine ⟨default, (default : ⊤_ C ⟶ 0) ≫ default, ?_, ?_⟩ <;> simp [eq_iff_true_of_subsingleton]
attribute [local instance] uniqueHomsetOfZero
/-- A cartesian closed category with a zero object is equivalent to the category with one object and
one morphism.
-/
def equivPUnit [HasZeroObject C] : C ≌ Discrete PUnit.{w + 1} :=
Equivalence.mk (Functor.star C) (Functor.fromPUnit 0)
(NatIso.ofComponents
(fun X =>
{ hom := default
inv := default })
fun f => Subsingleton.elim _ _)
(Functor.punitExt _ _)
end CategoryTheory
|
CategoryTheory\Comma\Arrow.lean | /-
Copyright (c) 2020 Markus Himmel. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Markus Himmel
-/
import Mathlib.CategoryTheory.Comma.Basic
/-!
# The category of arrows
The category of arrows, with morphisms commutative squares.
We set this up as a specialization of the comma category `Comma L R`,
where `L` and `R` are both the identity functor.
## Tags
comma, arrow
-/
namespace CategoryTheory
universe v u
-- morphism levels before object levels. See note [CategoryTheory universes].
variable {T : Type u} [Category.{v} T]
section
variable (T)
/-- The arrow category of `T` has as objects all morphisms in `T` and as morphisms commutative
squares in `T`. -/
def Arrow :=
Comma.{v, v, v} (𝟭 T) (𝟭 T)
/- Porting note: could not derive `Category` above so this instance works in its place-/
instance : Category (Arrow T) := commaCategory
-- Satisfying the inhabited linter
instance Arrow.inhabited [Inhabited T] : Inhabited (Arrow T) where
default := show Comma (𝟭 T) (𝟭 T) from default
end
namespace Arrow
@[ext]
lemma hom_ext {X Y : Arrow T} (f g : X ⟶ Y) (h₁ : f.left = g.left) (h₂ : f.right = g.right) :
f = g :=
CommaMorphism.ext h₁ h₂
@[simp]
theorem id_left (f : Arrow T) : CommaMorphism.left (𝟙 f) = 𝟙 f.left :=
rfl
@[simp]
theorem id_right (f : Arrow T) : CommaMorphism.right (𝟙 f) = 𝟙 f.right :=
rfl
-- Porting note (#10688): added to ease automation
@[simp, reassoc]
theorem comp_left {X Y Z : Arrow T} (f : X ⟶ Y) (g : Y ⟶ Z) :
(f ≫ g).left = f.left ≫ g.left := rfl
-- Porting note (#10688): added to ease automation
@[simp, reassoc]
theorem comp_right {X Y Z : Arrow T} (f : X ⟶ Y) (g : Y ⟶ Z) :
(f ≫ g).right = f.right ≫ g.right := rfl
/-- An object in the arrow category is simply a morphism in `T`. -/
@[simps]
def mk {X Y : T} (f : X ⟶ Y) : Arrow T where
left := X
right := Y
hom := f
@[simp]
theorem mk_eq (f : Arrow T) : Arrow.mk f.hom = f := by
cases f
rfl
theorem mk_injective (A B : T) :
Function.Injective (Arrow.mk : (A ⟶ B) → Arrow T) := fun f g h => by
cases h
rfl
theorem mk_inj (A B : T) {f g : A ⟶ B} : Arrow.mk f = Arrow.mk g ↔ f = g :=
(mk_injective A B).eq_iff
/- Porting note: was marked as dangerous instance so changed from `Coe` to `CoeOut` -/
instance {X Y : T} : CoeOut (X ⟶ Y) (Arrow T) where
coe := mk
/-- A morphism in the arrow category is a commutative square connecting two objects of the arrow
category. -/
@[simps]
def homMk {f g : Arrow T} {u : f.left ⟶ g.left} {v : f.right ⟶ g.right}
(w : u ≫ g.hom = f.hom ≫ v) : f ⟶ g where
left := u
right := v
w := w
/-- We can also build a morphism in the arrow category out of any commutative square in `T`. -/
@[simps]
def homMk' {X Y : T} {f : X ⟶ Y} {P Q : T} {g : P ⟶ Q} {u : X ⟶ P} {v : Y ⟶ Q} (w : u ≫ g = f ≫ v) :
Arrow.mk f ⟶ Arrow.mk g where
left := u
right := v
w := w
/- Porting note: was warned simp could prove reassoc'd version. Found simp could not.
Added nolint. -/
@[reassoc (attr := simp, nolint simpNF)]
theorem w {f g : Arrow T} (sq : f ⟶ g) : sq.left ≫ g.hom = f.hom ≫ sq.right :=
sq.w
-- `w_mk_left` is not needed, as it is a consequence of `w` and `mk_hom`.
@[reassoc (attr := simp)]
theorem w_mk_right {f : Arrow T} {X Y : T} {g : X ⟶ Y} (sq : f ⟶ mk g) :
sq.left ≫ g = f.hom ≫ sq.right :=
sq.w
theorem isIso_of_isIso_left_of_isIso_right {f g : Arrow T} (ff : f ⟶ g) [IsIso ff.left]
[IsIso ff.right] : IsIso ff where
out := by
let inverse : g ⟶ f := ⟨inv ff.left, inv ff.right, (by simp)⟩
apply Exists.intro inverse
aesop_cat
/-- Create an isomorphism between arrows,
by providing isomorphisms between the domains and codomains,
and a proof that the square commutes. -/
@[simps!]
def isoMk {f g : Arrow T} (l : f.left ≅ g.left) (r : f.right ≅ g.right)
(h : l.hom ≫ g.hom = f.hom ≫ r.hom := by aesop_cat) : f ≅ g :=
Comma.isoMk l r h
/-- A variant of `Arrow.isoMk` that creates an iso between two `Arrow.mk`s with a better type
signature. -/
abbrev isoMk' {W X Y Z : T} (f : W ⟶ X) (g : Y ⟶ Z) (e₁ : W ≅ Y) (e₂ : X ≅ Z)
(h : e₁.hom ≫ g = f ≫ e₂.hom := by aesop_cat) : Arrow.mk f ≅ Arrow.mk g :=
Arrow.isoMk e₁ e₂ h
theorem hom.congr_left {f g : Arrow T} {φ₁ φ₂ : f ⟶ g} (h : φ₁ = φ₂) : φ₁.left = φ₂.left := by
rw [h]
@[simp]
theorem hom.congr_right {f g : Arrow T} {φ₁ φ₂ : f ⟶ g} (h : φ₁ = φ₂) : φ₁.right = φ₂.right := by
rw [h]
theorem iso_w {f g : Arrow T} (e : f ≅ g) : g.hom = e.inv.left ≫ f.hom ≫ e.hom.right := by
have eq := Arrow.hom.congr_right e.inv_hom_id
rw [Arrow.comp_right, Arrow.id_right] at eq
erw [Arrow.w_assoc, eq, Category.comp_id]
theorem iso_w' {W X Y Z : T} {f : W ⟶ X} {g : Y ⟶ Z} (e : Arrow.mk f ≅ Arrow.mk g) :
g = e.inv.left ≫ f ≫ e.hom.right :=
iso_w e
section
variable {f g : Arrow T} (sq : f ⟶ g)
instance isIso_left [IsIso sq] : IsIso sq.left where
out := by
apply Exists.intro (inv sq).left
simp only [← Comma.comp_left, IsIso.hom_inv_id, IsIso.inv_hom_id, Arrow.id_left,
eq_self_iff_true, and_self_iff]
simp
instance isIso_right [IsIso sq] : IsIso sq.right where
out := by
apply Exists.intro (inv sq).right
simp only [← Comma.comp_right, IsIso.hom_inv_id, IsIso.inv_hom_id, Arrow.id_right,
eq_self_iff_true, and_self_iff]
simp
@[simp]
theorem inv_left [IsIso sq] : (inv sq).left = inv sq.left :=
IsIso.eq_inv_of_hom_inv_id <| by rw [← Comma.comp_left, IsIso.hom_inv_id, id_left]
@[simp]
theorem inv_right [IsIso sq] : (inv sq).right = inv sq.right :=
IsIso.eq_inv_of_hom_inv_id <| by rw [← Comma.comp_right, IsIso.hom_inv_id, id_right]
/- Porting note (#10618): simp can prove this so removed @[simp] -/
theorem left_hom_inv_right [IsIso sq] : sq.left ≫ g.hom ≫ inv sq.right = f.hom := by
simp only [← Category.assoc, IsIso.comp_inv_eq, w]
-- simp proves this
theorem inv_left_hom_right [IsIso sq] : inv sq.left ≫ f.hom ≫ sq.right = g.hom := by
simp only [w, IsIso.inv_comp_eq]
instance mono_left [Mono sq] : Mono sq.left where
right_cancellation {Z} φ ψ h := by
let aux : (Z ⟶ f.left) → (Arrow.mk (𝟙 Z) ⟶ f) := fun φ =>
{ left := φ
right := φ ≫ f.hom }
have : ∀ g, (aux g).right = g ≫ f.hom := fun g => by dsimp
show (aux φ).left = (aux ψ).left
congr 1
rw [← cancel_mono sq]
apply CommaMorphism.ext
· exact h
· rw [Comma.comp_right, Comma.comp_right, this, this, Category.assoc, Category.assoc]
rw [← Arrow.w]
simp only [← Category.assoc, h]
instance epi_right [Epi sq] : Epi sq.right where
left_cancellation {Z} φ ψ h := by
let aux : (g.right ⟶ Z) → (g ⟶ Arrow.mk (𝟙 Z)) := fun φ =>
{ right := φ
left := g.hom ≫ φ }
show (aux φ).right = (aux ψ).right
congr 1
rw [← cancel_epi sq]
apply CommaMorphism.ext
· rw [Comma.comp_left, Comma.comp_left, Arrow.w_assoc, Arrow.w_assoc, h]
· exact h
@[reassoc (attr := simp)]
lemma hom_inv_id_left (e : f ≅ g) : e.hom.left ≫ e.inv.left = 𝟙 _ := by
rw [← comp_left, e.hom_inv_id, id_left]
@[reassoc (attr := simp)]
lemma inv_hom_id_left (e : f ≅ g) : e.inv.left ≫ e.hom.left = 𝟙 _ := by
rw [← comp_left, e.inv_hom_id, id_left]
@[reassoc (attr := simp)]
lemma hom_inv_id_right (e : f ≅ g) : e.hom.right ≫ e.inv.right = 𝟙 _ := by
rw [← comp_right, e.hom_inv_id, id_right]
@[reassoc (attr := simp)]
lemma inv_hom_id_right (e : f ≅ g) : e.inv.right ≫ e.hom.right = 𝟙 _ := by
rw [← comp_right, e.inv_hom_id, id_right]
end
/-- Given a square from an arrow `i` to an isomorphism `p`, express the source part of `sq`
in terms of the inverse of `p`. -/
@[simp]
theorem square_to_iso_invert (i : Arrow T) {X Y : T} (p : X ≅ Y) (sq : i ⟶ Arrow.mk p.hom) :
i.hom ≫ sq.right ≫ p.inv = sq.left := by
simpa only [Category.assoc] using (Iso.comp_inv_eq p).mpr (Arrow.w_mk_right sq).symm
/-- Given a square from an isomorphism `i` to an arrow `p`, express the target part of `sq`
in terms of the inverse of `i`. -/
theorem square_from_iso_invert {X Y : T} (i : X ≅ Y) (p : Arrow T) (sq : Arrow.mk i.hom ⟶ p) :
i.inv ≫ sq.left ≫ p.hom = sq.right := by simp only [Iso.inv_hom_id_assoc, Arrow.w, Arrow.mk_hom]
variable {C : Type u} [Category.{v} C]
/-- A helper construction: given a square between `i` and `f ≫ g`, produce a square between
`i` and `g`, whose top leg uses `f`:
A → X
↓f
↓i Y --> A → Y
↓g ↓i ↓g
B → Z B → Z
-/
@[simps]
def squareToSnd {X Y Z : C} {i : Arrow C} {f : X ⟶ Y} {g : Y ⟶ Z} (sq : i ⟶ Arrow.mk (f ≫ g)) :
i ⟶ Arrow.mk g where
left := sq.left ≫ f
right := sq.right
/-- The functor sending an arrow to its source. -/
@[simps!]
def leftFunc : Arrow C ⥤ C :=
Comma.fst _ _
/-- The functor sending an arrow to its target. -/
@[simps!]
def rightFunc : Arrow C ⥤ C :=
Comma.snd _ _
/-- The natural transformation from `leftFunc` to `rightFunc`, given by the arrow itself. -/
@[simps]
def leftToRight : (leftFunc : Arrow C ⥤ C) ⟶ rightFunc where app f := f.hom
end Arrow
namespace Functor
universe v₁ v₂ u₁ u₂
variable {C : Type u₁} [Category.{v₁} C] {D : Type u₂} [Category.{v₂} D]
/-- A functor `C ⥤ D` induces a functor between the corresponding arrow categories. -/
@[simps]
def mapArrow (F : C ⥤ D) : Arrow C ⥤ Arrow D where
obj a :=
{ left := F.obj a.left
right := F.obj a.right
hom := F.map a.hom }
map f :=
{ left := F.map f.left
right := F.map f.right
w := by
let w := f.w
simp only [id_map] at w
dsimp
simp only [← F.map_comp, w] }
variable (C D)
/-- The functor `(C ⥤ D) ⥤ (Arrow C ⥤ Arrow D)` which sends
a functor `F : C ⥤ D` to `F.mapArrow`. -/
@[simps]
def mapArrowFunctor : (C ⥤ D) ⥤ (Arrow C ⥤ Arrow D) where
obj F := F.mapArrow
map τ :=
{ app := fun f =>
{ left := τ.app _
right := τ.app _ } }
variable {C D}
/-- The equivalence of categories `Arrow C ≌ Arrow D` induced by an equivalence `C ≌ D`. -/
def mapArrowEquivalence (e : C ≌ D) : Arrow C ≌ Arrow D where
functor := e.functor.mapArrow
inverse := e.inverse.mapArrow
unitIso := Functor.mapIso (mapArrowFunctor C C) e.unitIso
counitIso := Functor.mapIso (mapArrowFunctor D D) e.counitIso
instance isEquivalence_mapArrow (F : C ⥤ D) [IsEquivalence F] :
IsEquivalence F.mapArrow :=
(mapArrowEquivalence (asEquivalence F)).isEquivalence_functor
end Functor
/-- The images of `f : Arrow C` by two isomorphic functors `F : C ⥤ D` are
isomorphic arrows in `D`. -/
def Arrow.isoOfNatIso {C D : Type*} [Category C] [Category D] {F G : C ⥤ D} (e : F ≅ G)
(f : Arrow C) : F.mapArrow.obj f ≅ G.mapArrow.obj f :=
Arrow.isoMk (e.app f.left) (e.app f.right)
end CategoryTheory
|
CategoryTheory\Comma\Basic.lean | /-
Copyright (c) 2018 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Scott Morrison, Johan Commelin, Bhavik Mehta
-/
import Mathlib.CategoryTheory.Iso
import Mathlib.CategoryTheory.Functor.Category
import Mathlib.CategoryTheory.EqToHom
/-!
# Comma categories
A comma category is a construction in category theory, which builds a category out of two functors
with a common codomain. Specifically, for functors `L : A ⥤ T` and `R : B ⥤ T`, an object in
`Comma L R` is a morphism `hom : L.obj left ⟶ R.obj right` for some objects `left : A` and
`right : B`, and a morphism in `Comma L R` between `hom : L.obj left ⟶ R.obj right` and
`hom' : L.obj left' ⟶ R.obj right'` is a commutative square
```
L.obj left ⟶ L.obj left'
| |
hom | | hom'
↓ ↓
R.obj right ⟶ R.obj right',
```
where the top and bottom morphism come from morphisms `left ⟶ left'` and `right ⟶ right'`,
respectively.
## Main definitions
* `Comma L R`: the comma category of the functors `L` and `R`.
* `Over X`: the over category of the object `X` (developed in `Over.lean`).
* `Under X`: the under category of the object `X` (also developed in `Over.lean`).
* `Arrow T`: the arrow category of the category `T` (developed in `Arrow.lean`).
## References
* <https://ncatlab.org/nlab/show/comma+category>
## Tags
comma, slice, coslice, over, under, arrow
-/
namespace CategoryTheory
open Category
-- declare the `v`'s first; see `CategoryTheory.Category` for an explanation
universe v₁ v₂ v₃ v₄ v₅ u₁ u₂ u₃ u₄ u₅
variable {A : Type u₁} [Category.{v₁} A]
variable {B : Type u₂} [Category.{v₂} B]
variable {T : Type u₃} [Category.{v₃} T]
variable {A' B' T' : Type*} [Category A'] [Category B'] [Category T']
/-- The objects of the comma category are triples of an object `left : A`, an object
`right : B` and a morphism `hom : L.obj left ⟶ R.obj right`. -/
structure Comma (L : A ⥤ T) (R : B ⥤ T) : Type max u₁ u₂ v₃ where
left : A
right : B
hom : L.obj left ⟶ R.obj right
-- Satisfying the inhabited linter
instance Comma.inhabited [Inhabited T] : Inhabited (Comma (𝟭 T) (𝟭 T)) where
default :=
{ left := default
right := default
hom := 𝟙 default }
variable {L : A ⥤ T} {R : B ⥤ T}
/-- A morphism between two objects in the comma category is a commutative square connecting the
morphisms coming from the two objects using morphisms in the image of the functors `L` and `R`.
-/
@[ext]
structure CommaMorphism (X Y : Comma L R) where
left : X.left ⟶ Y.left
right : X.right ⟶ Y.right
w : L.map left ≫ Y.hom = X.hom ≫ R.map right := by aesop_cat
-- Satisfying the inhabited linter
instance CommaMorphism.inhabited [Inhabited (Comma L R)] :
Inhabited (CommaMorphism (default : Comma L R) default) :=
⟨{ left := 𝟙 _, right := 𝟙 _}⟩
attribute [reassoc (attr := simp)] CommaMorphism.w
instance commaCategory : Category (Comma L R) where
Hom X Y := CommaMorphism X Y
id X :=
{ left := 𝟙 X.left
right := 𝟙 X.right }
comp f g :=
{ left := f.left ≫ g.left
right := f.right ≫ g.right }
namespace Comma
section
variable {X Y Z : Comma L R} {f : X ⟶ Y} {g : Y ⟶ Z}
-- Porting note: this lemma was added because `CommaMorphism.ext`
-- was not triggered automatically
@[ext]
lemma hom_ext (f g : X ⟶ Y) (h₁ : f.left = g.left) (h₂ : f.right = g.right) : f = g :=
CommaMorphism.ext h₁ h₂
@[simp]
theorem id_left : (𝟙 X : CommaMorphism X X).left = 𝟙 X.left :=
rfl
@[simp]
theorem id_right : (𝟙 X : CommaMorphism X X).right = 𝟙 X.right :=
rfl
@[simp]
theorem comp_left : (f ≫ g).left = f.left ≫ g.left :=
rfl
@[simp]
theorem comp_right : (f ≫ g).right = f.right ≫ g.right :=
rfl
end
variable (L) (R)
/-- The functor sending an object `X` in the comma category to `X.left`. -/
@[simps]
def fst : Comma L R ⥤ A where
obj X := X.left
map f := f.left
/-- The functor sending an object `X` in the comma category to `X.right`. -/
@[simps]
def snd : Comma L R ⥤ B where
obj X := X.right
map f := f.right
/-- We can interpret the commutative square constituting a morphism in the comma category as a
natural transformation between the functors `fst ⋙ L` and `snd ⋙ R` from the comma category
to `T`, where the components are given by the morphism that constitutes an object of the comma
category. -/
@[simps]
def natTrans : fst L R ⋙ L ⟶ snd L R ⋙ R where app X := X.hom
@[simp]
theorem eqToHom_left (X Y : Comma L R) (H : X = Y) :
CommaMorphism.left (eqToHom H) = eqToHom (by cases H; rfl) := by
cases H
rfl
@[simp]
theorem eqToHom_right (X Y : Comma L R) (H : X = Y) :
CommaMorphism.right (eqToHom H) = eqToHom (by cases H; rfl) := by
cases H
rfl
section
variable {L₁ L₂ L₃ : A ⥤ T} {R₁ R₂ R₃ : B ⥤ T}
/-- Extract the isomorphism between the left objects from an isomorphism in the comma category. -/
@[simps!]
def leftIso {X Y : Comma L₁ R₁} (α : X ≅ Y) : X.left ≅ Y.left := (fst L₁ R₁).mapIso α
/-- Extract the isomorphism between the right objects from an isomorphism in the comma category. -/
@[simps!]
def rightIso {X Y : Comma L₁ R₁} (α : X ≅ Y) : X.right ≅ Y.right := (snd L₁ R₁).mapIso α
/-- Construct an isomorphism in the comma category given isomorphisms of the objects whose forward
directions give a commutative square.
-/
@[simps]
def isoMk {X Y : Comma L₁ R₁} (l : X.left ≅ Y.left) (r : X.right ≅ Y.right)
(h : L₁.map l.hom ≫ Y.hom = X.hom ≫ R₁.map r.hom := by aesop_cat) : X ≅ Y where
hom :=
{ left := l.hom
right := r.hom
w := h }
inv :=
{ left := l.inv
right := r.inv
w := by
rw [← L₁.mapIso_inv l, Iso.inv_comp_eq, L₁.mapIso_hom, ← Category.assoc, h,
Category.assoc, ← R₁.map_comp]
simp }
section
variable {L R}
variable {L' : A' ⥤ T'} {R' : B' ⥤ T'}
{F₁ : A ⥤ A'} {F₂ : B ⥤ B'} {F : T ⥤ T'}
(α : F₁ ⋙ L' ⟶ L ⋙ F) (β : R ⋙ F ⟶ F₂ ⋙ R')
/-- The functor `Comma L R ⥤ Comma L' R'` induced by three functors `F₁`, `F₂`, `F`
and two natural transformations `F₁ ⋙ L' ⟶ L ⋙ F` and `R ⋙ F ⟶ F₂ ⋙ R'`. -/
@[simps]
def map : Comma L R ⥤ Comma L' R' where
obj X :=
{ left := F₁.obj X.left
right := F₂.obj X.right
hom := α.app X.left ≫ F.map X.hom ≫ β.app X.right }
map {X Y} φ :=
{ left := F₁.map φ.left
right := F₂.map φ.right
w := by
dsimp
rw [assoc, assoc]
erw [α.naturality_assoc, ← β.naturality]
dsimp
rw [← F.map_comp_assoc, ← F.map_comp_assoc, φ.w] }
instance faithful_map [F₁.Faithful] [F₂.Faithful] : (map α β).Faithful where
map_injective {X Y} f g h := by
ext
· exact F₁.map_injective (congr_arg CommaMorphism.left h)
· exact F₂.map_injective (congr_arg CommaMorphism.right h)
instance full_map [F.Faithful] [F₁.Full] [F₂.Full] [IsIso α] [IsIso β] : (map α β).Full where
map_surjective {X Y} φ :=
⟨{ left := F₁.preimage φ.left
right := F₂.preimage φ.right
w := F.map_injective (by
rw [← cancel_mono (β.app _), ← cancel_epi (α.app _), F.map_comp, F.map_comp,
assoc, assoc]
erw [← α.naturality_assoc, β.naturality]
dsimp
rw [F₁.map_preimage, F₂.map_preimage]
simpa using φ.w) }, by aesop_cat⟩
instance essSurj_map [F₁.EssSurj] [F₂.EssSurj] [F.Full] [IsIso α] [IsIso β] :
(map α β).EssSurj where
mem_essImage X :=
⟨{ left := F₁.objPreimage X.left
right := F₂.objPreimage X.right
hom := F.preimage ((inv α).app _ ≫ L'.map (F₁.objObjPreimageIso X.left).hom ≫
X.hom ≫ R'.map (F₂.objObjPreimageIso X.right).inv ≫ (inv β).app _) },
⟨isoMk (F₁.objObjPreimageIso X.left) (F₂.objObjPreimageIso X.right) (by
dsimp
simp only [NatIso.isIso_inv_app, Functor.comp_obj, Functor.map_preimage, assoc,
IsIso.inv_hom_id, comp_id, IsIso.hom_inv_id_assoc]
rw [← R'.map_comp, Iso.inv_hom_id, R'.map_id, comp_id])⟩⟩
noncomputable instance isEquivalenceMap
[F₁.IsEquivalence] [F₂.IsEquivalence] [F.Faithful] [F.Full] [IsIso α] [IsIso β] :
(map α β).IsEquivalence where
end
/-- A natural transformation `L₁ ⟶ L₂` induces a functor `Comma L₂ R ⥤ Comma L₁ R`. -/
@[simps]
def mapLeft (l : L₁ ⟶ L₂) : Comma L₂ R ⥤ Comma L₁ R where
obj X :=
{ left := X.left
right := X.right
hom := l.app X.left ≫ X.hom }
map f :=
{ left := f.left
right := f.right }
/-- The functor `Comma L R ⥤ Comma L R` induced by the identity natural transformation on `L` is
naturally isomorphic to the identity functor. -/
@[simps!]
def mapLeftId : mapLeft R (𝟙 L) ≅ 𝟭 _ :=
NatIso.ofComponents (fun X => isoMk (Iso.refl _) (Iso.refl _))
/-- The functor `Comma L₁ R ⥤ Comma L₃ R` induced by the composition of two natural transformations
`l : L₁ ⟶ L₂` and `l' : L₂ ⟶ L₃` is naturally isomorphic to the composition of the two functors
induced by these natural transformations. -/
@[simps!]
def mapLeftComp (l : L₁ ⟶ L₂) (l' : L₂ ⟶ L₃) :
mapLeft R (l ≫ l') ≅ mapLeft R l' ⋙ mapLeft R l :=
NatIso.ofComponents (fun X => isoMk (Iso.refl _) (Iso.refl _))
/-- Two equal natural transformations `L₁ ⟶ L₂` yield naturally isomorphic functors
`Comma L₁ R ⥤ Comma L₂ R`. -/
@[simps!]
def mapLeftEq (l l' : L₁ ⟶ L₂) (h : l = l') : mapLeft R l ≅ mapLeft R l' :=
NatIso.ofComponents (fun X => isoMk (Iso.refl _) (Iso.refl _))
/-- A natural isomorphism `L₁ ≅ L₂` induces an equivalence of categories
`Comma L₁ R ≌ Comma L₂ R`. -/
@[simps!]
def mapLeftIso (i : L₁ ≅ L₂) : Comma L₁ R ≌ Comma L₂ R :=
Equivalence.mk (mapLeft _ i.inv) (mapLeft _ i.hom)
((mapLeftId _ _).symm ≪≫ mapLeftEq _ _ _ i.hom_inv_id.symm ≪≫ mapLeftComp _ _ _)
((mapLeftComp _ _ _).symm ≪≫ mapLeftEq _ _ _ i.inv_hom_id ≪≫ mapLeftId _ _)
/-- A natural transformation `R₁ ⟶ R₂` induces a functor `Comma L R₁ ⥤ Comma L R₂`. -/
@[simps]
def mapRight (r : R₁ ⟶ R₂) : Comma L R₁ ⥤ Comma L R₂ where
obj X :=
{ left := X.left
right := X.right
hom := X.hom ≫ r.app X.right }
map f :=
{ left := f.left
right := f.right }
/-- The functor `Comma L R ⥤ Comma L R` induced by the identity natural transformation on `R` is
naturally isomorphic to the identity functor. -/
@[simps!]
def mapRightId : mapRight L (𝟙 R) ≅ 𝟭 _ :=
NatIso.ofComponents (fun X => isoMk (Iso.refl _) (Iso.refl _))
/-- The functor `Comma L R₁ ⥤ Comma L R₃` induced by the composition of the natural transformations
`r : R₁ ⟶ R₂` and `r' : R₂ ⟶ R₃` is naturally isomorphic to the composition of the functors
induced by these natural transformations. -/
@[simps!]
def mapRightComp (r : R₁ ⟶ R₂) (r' : R₂ ⟶ R₃) :
mapRight L (r ≫ r') ≅ mapRight L r ⋙ mapRight L r' :=
NatIso.ofComponents (fun X => isoMk (Iso.refl _) (Iso.refl _))
/-- Two equal natural transformations `R₁ ⟶ R₂` yield naturally isomorphic functors
`Comma L R₁ ⥤ Comma L R₂`. -/
@[simps!]
def mapRightEq (r r' : R₁ ⟶ R₂) (h : r = r') : mapRight L r ≅ mapRight L r' :=
NatIso.ofComponents (fun X => isoMk (Iso.refl _) (Iso.refl _))
/-- A natural isomorphism `R₁ ≅ R₂` induces an equivalence of categories
`Comma L R₁ ≌ Comma L R₂`. -/
@[simps!]
def mapRightIso (i : R₁ ≅ R₂) : Comma L R₁ ≌ Comma L R₂ :=
Equivalence.mk (mapRight _ i.hom) (mapRight _ i.inv)
((mapRightId _ _).symm ≪≫ mapRightEq _ _ _ i.hom_inv_id.symm ≪≫ mapRightComp _ _ _)
((mapRightComp _ _ _).symm ≪≫ mapRightEq _ _ _ i.inv_hom_id ≪≫ mapRightId _ _)
end
section
variable {C : Type u₄} [Category.{v₄} C] {D : Type u₅} [Category.{v₅} D]
/-- The functor `(F ⋙ L, R) ⥤ (L, R)` -/
@[simps]
def preLeft (F : C ⥤ A) (L : A ⥤ T) (R : B ⥤ T) : Comma (F ⋙ L) R ⥤ Comma L R where
obj X :=
{ left := F.obj X.left
right := X.right
hom := X.hom }
map f :=
{ left := F.map f.left
right := f.right
w := by simpa using f.w }
/-- `Comma.preLeft` is a particular case of `Comma.map`,
but with better definitional properties. -/
def preLeftIso (F : C ⥤ A) (L : A ⥤ T) (R : B ⥤ T) :
preLeft F L R ≅ map (F ⋙ L).rightUnitor.inv (R.rightUnitor.hom ≫ R.leftUnitor.inv) :=
NatIso.ofComponents (fun X => isoMk (Iso.refl _) (Iso.refl _))
instance (F : C ⥤ A) (L : A ⥤ T) (R : B ⥤ T) [F.Faithful] : (preLeft F L R).Faithful :=
Functor.Faithful.of_iso (preLeftIso F L R).symm
instance (F : C ⥤ A) (L : A ⥤ T) (R : B ⥤ T) [F.Full] : (preLeft F L R).Full :=
Functor.Full.of_iso (preLeftIso F L R).symm
instance (F : C ⥤ A) (L : A ⥤ T) (R : B ⥤ T) [F.EssSurj] : (preLeft F L R).EssSurj :=
Functor.essSurj_of_iso (preLeftIso F L R).symm
/-- If `F` is an equivalence, then so is `preLeft F L R`. -/
instance isEquivalence_preLeft (F : C ⥤ A) (L : A ⥤ T) (R : B ⥤ T) [F.IsEquivalence] :
(preLeft F L R).IsEquivalence where
/-- The functor `(F ⋙ L, R) ⥤ (L, R)` -/
@[simps]
def preRight (L : A ⥤ T) (F : C ⥤ B) (R : B ⥤ T) : Comma L (F ⋙ R) ⥤ Comma L R where
obj X :=
{ left := X.left
right := F.obj X.right
hom := X.hom }
map f :=
{ left := f.left
right := F.map f.right }
/-- `Comma.preRight` is a particular case of `Comma.map`,
but with better definitional properties. -/
def preRightIso (L : A ⥤ T) (F : C ⥤ B) (R : B ⥤ T) :
preRight L F R ≅ map (L.leftUnitor.hom ≫ L.rightUnitor.inv) (F ⋙ R).rightUnitor.hom :=
NatIso.ofComponents (fun X => isoMk (Iso.refl _) (Iso.refl _))
instance (L : A ⥤ T) (F : C ⥤ B) (R : B ⥤ T) [F.Faithful] : (preRight L F R).Faithful :=
Functor.Faithful.of_iso (preRightIso L F R).symm
instance (L : A ⥤ T) (F : C ⥤ B) (R : B ⥤ T) [F.Full] : (preRight L F R).Full :=
Functor.Full.of_iso (preRightIso L F R).symm
instance (L : A ⥤ T) (F : C ⥤ B) (R : B ⥤ T) [F.EssSurj] : (preRight L F R).EssSurj :=
Functor.essSurj_of_iso (preRightIso L F R).symm
/-- If `F` is an equivalence, then so is `preRight L F R`. -/
instance isEquivalence_preRight (L : A ⥤ T) (F : C ⥤ B) (R : B ⥤ T) [F.IsEquivalence] :
(preRight L F R).IsEquivalence where
/-- The functor `(L, R) ⥤ (L ⋙ F, R ⋙ F)` -/
@[simps]
def post (L : A ⥤ T) (R : B ⥤ T) (F : T ⥤ C) : Comma L R ⥤ Comma (L ⋙ F) (R ⋙ F) where
obj X :=
{ left := X.left
right := X.right
hom := F.map X.hom }
map f :=
{ left := f.left
right := f.right
w := by simp only [Functor.comp_map, ← F.map_comp, f.w] }
end
end Comma
end CategoryTheory
|
CategoryTheory\Comma\Over.lean | /-
Copyright (c) 2019 Johan Commelin. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johan Commelin, Bhavik Mehta
-/
import Mathlib.CategoryTheory.Comma.StructuredArrow
import Mathlib.CategoryTheory.PUnit
import Mathlib.CategoryTheory.Functor.ReflectsIso
import Mathlib.CategoryTheory.Functor.EpiMono
/-!
# Over and under categories
Over (and under) categories are special cases of comma categories.
* If `L` is the identity functor and `R` is a constant functor, then `Comma L R` is the "slice" or
"over" category over the object `R` maps to.
* Conversely, if `L` is a constant functor and `R` is the identity functor, then `Comma L R` is the
"coslice" or "under" category under the object `L` maps to.
## Tags
Comma, Slice, Coslice, Over, Under
-/
namespace CategoryTheory
universe v₁ v₂ u₁ u₂
-- morphism levels before object levels. See note [CategoryTheory universes].
variable {T : Type u₁} [Category.{v₁} T]
/-- The over category has as objects arrows in `T` with codomain `X` and as morphisms commutative
triangles.
See <https://stacks.math.columbia.edu/tag/001G>.
-/
def Over (X : T) :=
CostructuredArrow (𝟭 T) X
instance (X : T) : Category (Over X) := commaCategory
-- Satisfying the inhabited linter
instance Over.inhabited [Inhabited T] : Inhabited (Over (default : T)) where
default :=
{ left := default
right := default
hom := 𝟙 _ }
namespace Over
variable {X : T}
@[ext]
theorem OverMorphism.ext {X : T} {U V : Over X} {f g : U ⟶ V} (h : f.left = g.left) : f = g := by
let ⟨_,b,_⟩ := f
let ⟨_,e,_⟩ := g
congr
simp only [eq_iff_true_of_subsingleton]
-- @[simp] : Porting note (#10618): simp can prove this
theorem over_right (U : Over X) : U.right = ⟨⟨⟩⟩ := by simp only
@[simp]
theorem id_left (U : Over X) : CommaMorphism.left (𝟙 U) = 𝟙 U.left :=
rfl
@[simp]
theorem comp_left (a b c : Over X) (f : a ⟶ b) (g : b ⟶ c) : (f ≫ g).left = f.left ≫ g.left :=
rfl
@[reassoc (attr := simp)]
theorem w {A B : Over X} (f : A ⟶ B) : f.left ≫ B.hom = A.hom := by have := f.w; aesop_cat
/-- To give an object in the over category, it suffices to give a morphism with codomain `X`. -/
@[simps! left hom]
def mk {X Y : T} (f : Y ⟶ X) : Over X :=
CostructuredArrow.mk f
/-- We can set up a coercion from arrows with codomain `X` to `over X`. This most likely should not
be a global instance, but it is sometimes useful. -/
def coeFromHom {X Y : T} : CoeOut (Y ⟶ X) (Over X) where coe := mk
section
attribute [local instance] coeFromHom
@[simp]
theorem coe_hom {X Y : T} (f : Y ⟶ X) : (f : Over X).hom = f :=
rfl
end
/-- To give a morphism in the over category, it suffices to give an arrow fitting in a commutative
triangle. -/
@[simps!]
def homMk {U V : Over X} (f : U.left ⟶ V.left) (w : f ≫ V.hom = U.hom := by aesop_cat) : U ⟶ V :=
CostructuredArrow.homMk f w
-- Porting note: simp solves this; simpNF still sees them after `-simp` (?)
attribute [-simp, nolint simpNF] homMk_right_down_down
/-- Construct an isomorphism in the over category given isomorphisms of the objects whose forward
direction gives a commutative triangle.
-/
@[simps!]
def isoMk {f g : Over X} (hl : f.left ≅ g.left) (hw : hl.hom ≫ g.hom = f.hom := by aesop_cat) :
f ≅ g :=
CostructuredArrow.isoMk hl hw
-- Porting note: simp solves this; simpNF still sees them after `-simp` (?)
attribute [-simp, nolint simpNF] isoMk_hom_right_down_down isoMk_inv_right_down_down
section
variable (X)
/-- The forgetful functor mapping an arrow to its domain.
See <https://stacks.math.columbia.edu/tag/001G>.
-/
def forget : Over X ⥤ T :=
Comma.fst _ _
end
@[simp]
theorem forget_obj {U : Over X} : (forget X).obj U = U.left :=
rfl
@[simp]
theorem forget_map {U V : Over X} {f : U ⟶ V} : (forget X).map f = f.left :=
rfl
/-- The natural cocone over the forgetful functor `Over X ⥤ T` with cocone point `X`. -/
@[simps]
def forgetCocone (X : T) : Limits.Cocone (forget X) :=
{ pt := X
ι := { app := Comma.hom } }
/-- A morphism `f : X ⟶ Y` induces a functor `Over X ⥤ Over Y` in the obvious way.
See <https://stacks.math.columbia.edu/tag/001G>.
-/
def map {Y : T} (f : X ⟶ Y) : Over X ⥤ Over Y :=
Comma.mapRight _ <| Discrete.natTrans fun _ => f
section
variable {Y : T} {f : X ⟶ Y} {U V : Over X} {g : U ⟶ V}
@[simp]
theorem map_obj_left : ((map f).obj U).left = U.left :=
rfl
@[simp]
theorem map_obj_hom : ((map f).obj U).hom = U.hom ≫ f :=
rfl
@[simp]
theorem map_map_left : ((map f).map g).left = g.left :=
rfl
end
section coherences
/-!
This section proves various equalities between functors that
demonstrate, for instance, that over categories assemble into a
functor `mapFunctor : T ⥤ Cat`.
These equalities between functors are then converted to natural
isomorphisms using `eqToIso`. Such natural isomorphisms could be
obtained directly using `Iso.refl` but this method will have
better computational properties, when used, for instance, in
developing the theory of Beck-Chevalley transformations.
-/
/-- Mapping by the identity morphism is just the identity functor. -/
theorem mapId_eq (Y : T) : map (𝟙 Y) = 𝟭 _ := by
fapply Functor.ext
· intro x
dsimp [Over, Over.map, Comma.mapRight]
simp only [Category.comp_id]
exact rfl
· intros x y u
dsimp [Over, Over.map, Comma.mapRight]
simp
/-- The natural isomorphism arising from `mapForget_eq`. -/
def mapId (Y : T) : map (𝟙 Y) ≅ 𝟭 _ := eqToIso (mapId_eq Y)
-- NatIso.ofComponents fun X => isoMk (Iso.refl _)
/-- Mapping by `f` and then forgetting is the same as forgetting. -/
theorem mapForget_eq {X Y : T} (f : X ⟶ Y) :
(map f) ⋙ (forget Y) = (forget X) := by
fapply Functor.ext
· dsimp [Over, Over.map]; intro x; exact rfl
· intros x y u; simp
/-- The natural isomorphism arising from `mapForget_eq`. -/
def mapForget {X Y : T} (f : X ⟶ Y) :
(map f) ⋙ (forget Y) ≅ (forget X) := eqToIso (mapForget_eq f)
@[simp]
theorem eqToHom_left {X : T} {U V : Over X} (e : U = V) :
(eqToHom e).left = eqToHom (e ▸ rfl : U.left = V.left) := by
subst e; rfl
/-- Mapping by the composite morphism `f ≫ g` is the same as mapping by `f` then by `g`. -/
theorem mapComp_eq {X Y Z : T} (f : X ⟶ Y) (g : Y ⟶ Z) :
map (f ≫ g) = (map f) ⋙ (map g) := by
fapply Functor.ext
· simp [Over.map, Comma.mapRight]
· intro U V k
ext
simp
/-- The natural isomorphism arising from `mapComp_eq`. -/
def mapComp {X Y Z : T} (f : X ⟶ Y) (g : Y ⟶ Z) :
map (f ≫ g) ≅ (map f) ⋙ (map g) := eqToIso (mapComp_eq f g)
variable (T) in
/-- The functor defined by the over categories.-/
@[simps] def mapFunctor : T ⥤ Cat where
obj X := Cat.of (Over X)
map := map
map_id := mapId_eq
map_comp := mapComp_eq
end coherences
instance forget_reflects_iso : (forget X).ReflectsIsomorphisms where
reflects {Y Z} f t := by
let g : Z ⟶ Y := Over.homMk (inv ((forget X).map f))
((asIso ((forget X).map f)).inv_comp_eq.2 (Over.w f).symm)
dsimp [forget] at t
refine ⟨⟨g, ⟨?_,?_⟩⟩⟩
repeat (ext; simp [g])
/-- The identity over `X` is terminal. -/
noncomputable def mkIdTerminal : Limits.IsTerminal (mk (𝟙 X)) :=
CostructuredArrow.mkIdTerminal
instance forget_faithful : (forget X).Faithful where
-- TODO: Show the converse holds if `T` has binary products.
/--
If `k.left` is an epimorphism, then `k` is an epimorphism. In other words, `Over.forget X` reflects
epimorphisms.
The converse does not hold without additional assumptions on the underlying category, see
`CategoryTheory.Over.epi_left_of_epi`.
-/
theorem epi_of_epi_left {f g : Over X} (k : f ⟶ g) [hk : Epi k.left] : Epi k :=
(forget X).epi_of_epi_map hk
/--
If `k.left` is a monomorphism, then `k` is a monomorphism. In other words, `Over.forget X` reflects
monomorphisms.
The converse of `CategoryTheory.Over.mono_left_of_mono`.
This lemma is not an instance, to avoid loops in type class inference.
-/
theorem mono_of_mono_left {f g : Over X} (k : f ⟶ g) [hk : Mono k.left] : Mono k :=
(forget X).mono_of_mono_map hk
/--
If `k` is a monomorphism, then `k.left` is a monomorphism. In other words, `Over.forget X` preserves
monomorphisms.
The converse of `CategoryTheory.Over.mono_of_mono_left`.
-/
instance mono_left_of_mono {f g : Over X} (k : f ⟶ g) [Mono k] : Mono k.left := by
refine ⟨fun {Y : T} l m a => ?_⟩
let l' : mk (m ≫ f.hom) ⟶ f := homMk l (by
dsimp; rw [← Over.w k, ← Category.assoc, congrArg (· ≫ g.hom) a, Category.assoc])
suffices l' = (homMk m : mk (m ≫ f.hom) ⟶ f) by apply congrArg CommaMorphism.left this
rw [← cancel_mono k]
ext
apply a
section IteratedSlice
variable (f : Over X)
/-- Given f : Y ⟶ X, this is the obvious functor from (T/X)/f to T/Y -/
@[simps]
def iteratedSliceForward : Over f ⥤ Over f.left where
obj α := Over.mk α.hom.left
map κ := Over.homMk κ.left.left (by dsimp; rw [← Over.w κ]; rfl)
/-- Given f : Y ⟶ X, this is the obvious functor from T/Y to (T/X)/f -/
@[simps]
def iteratedSliceBackward : Over f.left ⥤ Over f where
obj g := mk (homMk g.hom : mk (g.hom ≫ f.hom) ⟶ f)
map α := homMk (homMk α.left (w_assoc α f.hom)) (OverMorphism.ext (w α))
/-- Given f : Y ⟶ X, we have an equivalence between (T/X)/f and T/Y -/
@[simps]
def iteratedSliceEquiv : Over f ≌ Over f.left where
functor := iteratedSliceForward f
inverse := iteratedSliceBackward f
unitIso := NatIso.ofComponents (fun g => Over.isoMk (Over.isoMk (Iso.refl _)))
counitIso := NatIso.ofComponents (fun g => Over.isoMk (Iso.refl _))
theorem iteratedSliceForward_forget :
iteratedSliceForward f ⋙ forget f.left = forget f ⋙ forget X :=
rfl
theorem iteratedSliceBackward_forget_forget :
iteratedSliceBackward f ⋙ forget f ⋙ forget X = forget f.left :=
rfl
end IteratedSlice
section
variable {D : Type u₂} [Category.{v₂} D]
/-- A functor `F : T ⥤ D` induces a functor `Over X ⥤ Over (F.obj X)` in the obvious way. -/
@[simps]
def post (F : T ⥤ D) : Over X ⥤ Over (F.obj X) where
obj Y := mk <| F.map Y.hom
map f := Over.homMk (F.map f.left)
(by simp only [Functor.id_obj, mk_left, Functor.const_obj_obj, mk_hom, ← F.map_comp, w])
end
end Over
namespace CostructuredArrow
variable {D : Type u₂} [Category.{v₂} D]
/-- Reinterpreting an `F`-costructured arrow `F.obj d ⟶ X` as an arrow over `X` induces a functor
`CostructuredArrow F X ⥤ Over X`. -/
@[simps!]
def toOver (F : D ⥤ T) (X : T) : CostructuredArrow F X ⥤ Over X :=
CostructuredArrow.pre F (𝟭 T) X
instance (F : D ⥤ T) (X : T) [F.Faithful] : (toOver F X).Faithful :=
show (CostructuredArrow.pre _ _ _).Faithful from inferInstance
instance (F : D ⥤ T) (X : T) [F.Full] : (toOver F X).Full :=
show (CostructuredArrow.pre _ _ _).Full from inferInstance
instance (F : D ⥤ T) (X : T) [F.EssSurj] : (toOver F X).EssSurj :=
show (CostructuredArrow.pre _ _ _).EssSurj from inferInstance
/-- An equivalence `F` induces an equivalence `CostructuredArrow F X ≌ Over X`. -/
instance isEquivalence_toOver (F : D ⥤ T) (X : T) [F.IsEquivalence] :
(toOver F X).IsEquivalence :=
CostructuredArrow.isEquivalence_pre _ _ _
end CostructuredArrow
/-- The under category has as objects arrows with domain `X` and as morphisms commutative
triangles. -/
def Under (X : T) :=
StructuredArrow X (𝟭 T)
instance (X : T) : Category (Under X) := commaCategory
-- Satisfying the inhabited linter
instance Under.inhabited [Inhabited T] : Inhabited (Under (default : T)) where
default :=
{ left := default
right := default
hom := 𝟙 _ }
namespace Under
variable {X : T}
@[ext]
theorem UnderMorphism.ext {X : T} {U V : Under X} {f g : U ⟶ V} (h : f.right = g.right) :
f = g := by
let ⟨_,b,_⟩ := f; let ⟨_,e,_⟩ := g
congr; simp only [eq_iff_true_of_subsingleton]
-- @[simp] Porting note (#10618): simp can prove this
theorem under_left (U : Under X) : U.left = ⟨⟨⟩⟩ := by simp only
@[simp]
theorem id_right (U : Under X) : CommaMorphism.right (𝟙 U) = 𝟙 U.right :=
rfl
@[simp]
theorem comp_right (a b c : Under X) (f : a ⟶ b) (g : b ⟶ c) : (f ≫ g).right = f.right ≫ g.right :=
rfl
@[reassoc (attr := simp)]
theorem w {A B : Under X} (f : A ⟶ B) : A.hom ≫ f.right = B.hom := by have := f.w; aesop_cat
/-- To give an object in the under category, it suffices to give an arrow with domain `X`. -/
@[simps! right hom]
def mk {X Y : T} (f : X ⟶ Y) : Under X :=
StructuredArrow.mk f
/-- To give a morphism in the under category, it suffices to give a morphism fitting in a
commutative triangle. -/
@[simps!]
def homMk {U V : Under X} (f : U.right ⟶ V.right) (w : U.hom ≫ f = V.hom := by aesop_cat) : U ⟶ V :=
StructuredArrow.homMk f w
-- Porting note: simp solves this; simpNF still sees them after `-simp` (?)
attribute [-simp, nolint simpNF] homMk_left_down_down
/-- Construct an isomorphism in the over category given isomorphisms of the objects whose forward
direction gives a commutative triangle.
-/
def isoMk {f g : Under X} (hr : f.right ≅ g.right)
(hw : f.hom ≫ hr.hom = g.hom := by aesop_cat) : f ≅ g :=
StructuredArrow.isoMk hr hw
@[simp]
theorem isoMk_hom_right {f g : Under X} (hr : f.right ≅ g.right) (hw : f.hom ≫ hr.hom = g.hom) :
(isoMk hr hw).hom.right = hr.hom :=
rfl
@[simp]
theorem isoMk_inv_right {f g : Under X} (hr : f.right ≅ g.right) (hw : f.hom ≫ hr.hom = g.hom) :
(isoMk hr hw).inv.right = hr.inv :=
rfl
section
variable (X)
/-- The forgetful functor mapping an arrow to its domain. -/
def forget : Under X ⥤ T :=
Comma.snd _ _
end
@[simp]
theorem forget_obj {U : Under X} : (forget X).obj U = U.right :=
rfl
@[simp]
theorem forget_map {U V : Under X} {f : U ⟶ V} : (forget X).map f = f.right :=
rfl
/-- The natural cone over the forgetful functor `Under X ⥤ T` with cone point `X`. -/
@[simps]
def forgetCone (X : T) : Limits.Cone (forget X) :=
{ pt := X
π := { app := Comma.hom } }
/-- A morphism `X ⟶ Y` induces a functor `Under Y ⥤ Under X` in the obvious way. -/
def map {Y : T} (f : X ⟶ Y) : Under Y ⥤ Under X :=
Comma.mapLeft _ <| Discrete.natTrans fun _ => f
section
variable {Y : T} {f : X ⟶ Y} {U V : Under Y} {g : U ⟶ V}
@[simp]
theorem map_obj_right : ((map f).obj U).right = U.right :=
rfl
@[simp]
theorem map_obj_hom : ((map f).obj U).hom = f ≫ U.hom :=
rfl
@[simp]
theorem map_map_right : ((map f).map g).right = g.right :=
rfl
end
section coherences
/-!
This section proves various equalities between functors that
demonstrate, for instance, that under categories assemble into a
functor `mapFunctor : Tᵒᵖ ⥤ Cat`.
-/
/-- Mapping by the identity morphism is just the identity functor. -/
theorem mapId_eq (Y : T) : map (𝟙 Y) = 𝟭 _ := by
fapply Functor.ext
· intro x
dsimp [Under, Under.map, Comma.mapLeft]
simp only [Category.id_comp]
exact rfl
· intros x y u
dsimp [Under, Under.map, Comma.mapLeft]
simp
/-- Mapping by the identity morphism is just the identity functor. -/
def mapId (Y : T) : map (𝟙 Y) ≅ 𝟭 _ := eqToIso (mapId_eq Y)
/-- Mapping by `f` and then forgetting is the same as forgetting. -/
theorem mapForget_eq {X Y : T} (f : X ⟶ Y) :
(map f) ⋙ (forget X) = (forget Y) := by
fapply Functor.ext
· dsimp [Under, Under.map]; intro x; exact rfl
· intros x y u; simp
/-- The natural isomorphism arising from `mapForget_eq`. -/
def mapForget {X Y : T} (f : X ⟶ Y) :
(map f) ⋙ (forget X) ≅ (forget Y) := eqToIso (mapForget_eq f)
@[simp]
theorem eqToHom_right {X : T} {U V : Under X} (e : U = V) :
(eqToHom e).right = eqToHom (e ▸ rfl : U.right = V.right) := by
subst e; rfl
/-- Mapping by the composite morphism `f ≫ g` is the same as mapping by `f` then by `g`. -/
theorem mapComp_eq {X Y Z : T} (f : X ⟶ Y) (g : Y ⟶ Z) :
map (f ≫ g) = (map g) ⋙ (map f) := by
fapply Functor.ext
· simp [Under.map, Comma.mapLeft]
· intro U V k
ext
simp
/-- The natural isomorphism arising from `mapComp_eq`. -/
def mapComp {Y Z : T} (f : X ⟶ Y) (g : Y ⟶ Z) : map (f ≫ g) ≅ map g ⋙ map f :=
eqToIso (mapComp_eq f g)
variable (T) in
/-- The functor defined by the under categories.-/
@[simps] def mapFunctor : Tᵒᵖ ⥤ Cat where
obj X := Cat.of (Under X.unop)
map f := map f.unop
map_id X := mapId_eq X.unop
map_comp f g := mapComp_eq (g.unop) (f.unop)
end coherences
instance forget_reflects_iso : (forget X).ReflectsIsomorphisms where
reflects {Y Z} f t := by
let g : Z ⟶ Y := Under.homMk (inv ((Under.forget X).map f))
((IsIso.comp_inv_eq _).2 (Under.w f).symm)
dsimp [forget] at t
refine ⟨⟨g, ⟨?_,?_⟩⟩⟩
repeat (ext; simp [g])
/-- The identity under `X` is initial. -/
noncomputable def mkIdInitial : Limits.IsInitial (mk (𝟙 X)) :=
StructuredArrow.mkIdInitial
instance forget_faithful : (forget X).Faithful where
-- TODO: Show the converse holds if `T` has binary coproducts.
/-- If `k.right` is a monomorphism, then `k` is a monomorphism. In other words, `Under.forget X`
reflects epimorphisms.
The converse does not hold without additional assumptions on the underlying category, see
`CategoryTheory.Under.mono_right_of_mono`.
-/
theorem mono_of_mono_right {f g : Under X} (k : f ⟶ g) [hk : Mono k.right] : Mono k :=
(forget X).mono_of_mono_map hk
/--
If `k.right` is an epimorphism, then `k` is an epimorphism. In other words, `Under.forget X`
reflects epimorphisms.
The converse of `CategoryTheory.Under.epi_right_of_epi`.
This lemma is not an instance, to avoid loops in type class inference.
-/
theorem epi_of_epi_right {f g : Under X} (k : f ⟶ g) [hk : Epi k.right] : Epi k :=
(forget X).epi_of_epi_map hk
/--
If `k` is an epimorphism, then `k.right` is an epimorphism. In other words, `Under.forget X`
preserves epimorphisms.
The converse of `CategoryTheory.under.epi_of_epi_right`.
-/
instance epi_right_of_epi {f g : Under X} (k : f ⟶ g) [Epi k] : Epi k.right := by
refine ⟨fun {Y : T} l m a => ?_⟩
let l' : g ⟶ mk (g.hom ≫ m) := homMk l (by
dsimp; rw [← Under.w k, Category.assoc, a, Category.assoc])
-- Porting note: add type ascription here to `homMk m`
suffices l' = (homMk m : g ⟶ mk (g.hom ≫ m)) by apply congrArg CommaMorphism.right this
rw [← cancel_epi k]; ext; apply a
section
variable {D : Type u₂} [Category.{v₂} D]
/-- A functor `F : T ⥤ D` induces a functor `Under X ⥤ Under (F.obj X)` in the obvious way. -/
@[simps]
def post {X : T} (F : T ⥤ D) : Under X ⥤ Under (F.obj X) where
obj Y := mk <| F.map Y.hom
map f := Under.homMk (F.map f.right)
(by simp only [Functor.id_obj, Functor.const_obj_obj, mk_right, mk_hom, ← F.map_comp, w])
end
end Under
namespace StructuredArrow
variable {D : Type u₂} [Category.{v₂} D]
/-- Reinterpreting an `F`-structured arrow `X ⟶ F.obj d` as an arrow under `X` induces a functor
`StructuredArrow X F ⥤ Under X`. -/
@[simps!]
def toUnder (X : T) (F : D ⥤ T) : StructuredArrow X F ⥤ Under X :=
StructuredArrow.pre X F (𝟭 T)
instance (X : T) (F : D ⥤ T) [F.Faithful] : (toUnder X F).Faithful :=
show (StructuredArrow.pre _ _ _).Faithful from inferInstance
instance (X : T) (F : D ⥤ T) [F.Full] : (toUnder X F).Full :=
show (StructuredArrow.pre _ _ _).Full from inferInstance
instance (X : T) (F : D ⥤ T) [F.EssSurj] : (toUnder X F).EssSurj :=
show (StructuredArrow.pre _ _ _).EssSurj from inferInstance
/-- An equivalence `F` induces an equivalence `StructuredArrow X F ≌ Under X`. -/
instance isEquivalence_toUnder (X : T) (F : D ⥤ T) [F.IsEquivalence] :
(toUnder X F).IsEquivalence :=
StructuredArrow.isEquivalence_pre _ _ _
end StructuredArrow
namespace Functor
variable {S : Type u₂} [Category.{v₂} S]
/-- Given `X : T`, to upgrade a functor `F : S ⥤ T` to a functor `S ⥤ Over X`, it suffices to
provide maps `F.obj Y ⟶ X` for all `Y` making the obvious triangles involving all `F.map g`
commute. -/
@[simps! obj_left map_left]
def toOver (F : S ⥤ T) (X : T) (f : (Y : S) → F.obj Y ⟶ X)
(h : ∀ {Y Z : S} (g : Y ⟶ Z), F.map g ≫ f Z = f Y) : S ⥤ Over X :=
F.toCostructuredArrow (𝟭 _) X f h
/-- Upgrading a functor `S ⥤ T` to a functor `S ⥤ Over X` and composing with the forgetful functor
`Over X ⥤ T` recovers the original functor. -/
def toOverCompForget (F : S ⥤ T) (X : T) (f : (Y : S) → F.obj Y ⟶ X)
(h : ∀ {Y Z : S} (g : Y ⟶ Z), F.map g ≫ f Z = f Y) : F.toOver X f h ⋙ Over.forget _ ≅ F :=
Iso.refl _
@[simp]
lemma toOver_comp_forget (F : S ⥤ T) (X : T) (f : (Y : S) → F.obj Y ⟶ X)
(h : ∀ {Y Z : S} (g : Y ⟶ Z), F.map g ≫ f Z = f Y) : F.toOver X f h ⋙ Over.forget _ = F :=
rfl
/-- Given `X : T`, to upgrade a functor `F : S ⥤ T` to a functor `S ⥤ Under X`, it suffices to
provide maps `X ⟶ F.obj Y` for all `Y` making the obvious triangles involving all `F.map g`
commute. -/
@[simps! obj_right map_right]
def toUnder (F : S ⥤ T) (X : T) (f : (Y : S) → X ⟶ F.obj Y)
(h : ∀ {Y Z : S} (g : Y ⟶ Z), f Y ≫ F.map g = f Z) : S ⥤ Under X :=
F.toStructuredArrow X (𝟭 _) f h
/-- Upgrading a functor `S ⥤ T` to a functor `S ⥤ Under X` and composing with the forgetful functor
`Under X ⥤ T` recovers the original functor. -/
def toUnderCompForget (F : S ⥤ T) (X : T) (f : (Y : S) → X ⟶ F.obj Y)
(h : ∀ {Y Z : S} (g : Y ⟶ Z), f Y ≫ F.map g = f Z) : F.toUnder X f h ⋙ Under.forget _ ≅ F :=
Iso.refl _
@[simp]
lemma toUnder_comp_forget (F : S ⥤ T) (X : T) (f : (Y : S) → X ⟶ F.obj Y)
(h : ∀ {Y Z : S} (g : Y ⟶ Z), f Y ≫ F.map g = f Z) : F.toUnder X f h ⋙ Under.forget _ = F :=
rfl
end Functor
end CategoryTheory
|
CategoryTheory\Comma\Presheaf.lean | /-
Copyright (c) 2024 Markus Himmel. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Markus Himmel
-/
import Mathlib.CategoryTheory.Comma.Over
import Mathlib.Tactic.CategoryTheory.Elementwise
/-!
# Computation of `Over A` for a presheaf `A`
Let `A : Cᵒᵖ ⥤ Type v` be a presheaf. In this file, we construct an equivalence
`e : Over A ≌ (CostructuredArrow yoneda A)ᵒᵖ ⥤ Type v` and show that there is a quasi-commutative
diagram
```
CostructuredArrow yoneda A ⥤ Over A
⇘ ⥥
PSh(CostructuredArrow yoneda A)
```
where the top arrow is the forgetful functor forgetting the yoneda-costructure, the right arrow is
the aforementioned equivalence and the diagonal arrow is the Yoneda embedding.
In the notation of Kashiwara-Schapira, the type of the equivalence is written `C^ₐ ≌ Cₐ^`, where
`·ₐ` is `CostructuredArrow` (with the functor `S` being either the identity or the Yoneda
embedding) and `^` is taking presheaves. The equivalence is a key ingredient in various results in
Kashiwara-Schapira.
The proof is somewhat long and technical, in part due to the construction inherently involving a
sigma type which comes with the usual DTT issues. However, a user of this result should not need
to interact with the actual construction, the mere existence of the equivalence and the commutative
triangle should generally be sufficient.
## Main results
* `overEquivPresheafCostructuredArrow`:
the equivalence `Over A ≌ (CostructuredArrow yoneda A)ᵒᵖ ⥤ Type v`
* `CostructuredArrow.toOverCompOverEquivPresheafCostructuredArrow`: the natural isomorphism
`CostructuredArrow.toOver yoneda A ⋙ (overEquivPresheafCostructuredArrow A).functor ≅ yoneda`
## Implementation details
The proof needs to introduce "correction terms" in various places in order to overcome DTT issues,
and these need to be canceled against each other when appropriate. It is important to deal with
these in a structured manner, otherwise you get large goals containing many correction terms which
are very tedious to manipulate. We avoid this blowup by carefully controlling which definitions
`(d)simp` is allowed to unfold and stating many lemmas explicitly before they are required. This
leads to manageable goals containing only a small number of correction terms. Generally, we use
the form `F.map (eqToHom _)` for these correction terms and try to push them as far outside as
possible.
## Future work
* If needed, it should be possible to show that the equivalence is natural in `A`.
## References
* [M. Kashiwara, P. Schapira, *Categories and Sheaves*][Kashiwara2006], Lemma 1.4.12
## Tags
presheaf, over category, coyoneda
-/
namespace CategoryTheory
open Category Opposite
universe w v u
variable {C : Type u} [Category.{v} C] {A : Cᵒᵖ ⥤ Type v}
namespace OverPresheafAux
attribute [local simp] FunctorToTypes.naturality
/-! ### Construction of the forward functor `Over A ⥤ (CostructuredArrow yoneda A)ᵒᵖ ⥤ Type v` -/
/-- Via the Yoneda lemma, `u : F.obj (op X)` defines a natural transformation `yoneda.obj X ⟶ F`
and via the element `η.app (op X) u` also a morphism `yoneda.obj X ⟶ A`. This structure
witnesses the fact that these morphisms from a commutative triangle with `η : F ⟶ A`, i.e.,
that `yoneda.obj X ⟶ F` lifts to a morphism in `Over A`. -/
structure MakesOverArrow {F : Cᵒᵖ ⥤ Type v} (η : F ⟶ A) {X : C} (s : yoneda.obj X ⟶ A)
(u : F.obj (op X)) : Prop where
app : η.app (op X) u = yonedaEquiv s
namespace MakesOverArrow
/-- "Functoriality" of `MakesOverArrow η s` in `η`. -/
lemma map₁ {F G : Cᵒᵖ ⥤ Type v} {η : F ⟶ A} {μ : G ⟶ A} {ε : F ⟶ G}
(hε : ε ≫ μ = η) {X : C} {s : yoneda.obj X ⟶ A} {u : F.obj (op X)}
(h : MakesOverArrow η s u) : MakesOverArrow μ s (ε.app _ u) :=
⟨by rw [← elementwise_of% NatTrans.comp_app ε μ, hε, h.app]⟩
/-- "Functoriality of `MakesOverArrow η s` in `s`. -/
lemma map₂ {F : Cᵒᵖ ⥤ Type v} {η : F ⟶ A} {X Y : C} (f : X ⟶ Y)
{s : yoneda.obj X ⟶ A} {t : yoneda.obj Y ⟶ A} (hst : yoneda.map f ≫ t = s)
{u : F.obj (op Y)} (h : MakesOverArrow η t u) : MakesOverArrow η s (F.map f.op u) :=
⟨by rw [elementwise_of% η.naturality, h.app, yonedaEquiv_naturality, hst]⟩
lemma of_arrow {F : Cᵒᵖ ⥤ Type v} {η : F ⟶ A} {X : C} {s : yoneda.obj X ⟶ A}
{f : yoneda.obj X ⟶ F} (hf : f ≫ η = s) : MakesOverArrow η s (yonedaEquiv f) :=
⟨hf ▸ rfl⟩
lemma of_yoneda_arrow {Y : C} {η : yoneda.obj Y ⟶ A} {X : C} {s : yoneda.obj X ⟶ A} {f : X ⟶ Y}
(hf : yoneda.map f ≫ η = s) : MakesOverArrow η s f := by
simpa only [yonedaEquiv_yoneda_map f] using of_arrow hf
end MakesOverArrow
/-- This is equivalent to the type `Over.mk s ⟶ Over.mk η`, but that lives in the wrong universe.
However, if `F = yoneda.obj Y` for some `Y`, then (using that the Yoneda embedding is fully
faithful) we get a good statement, see `OverArrow.costructuredArrowIso`. -/
def OverArrows {F : Cᵒᵖ ⥤ Type v} (η : F ⟶ A) {X : C} (s : yoneda.obj X ⟶ A) : Type v :=
Subtype (MakesOverArrow η s)
namespace OverArrows
/-- Since `OverArrows η s` can be thought of to contain certain morphisms `yoneda.obj X ⟶ F`, the
Yoneda lemma yields elements `F.obj (op X)`. -/
def val {F : Cᵒᵖ ⥤ Type v} {η : F ⟶ A} {X : C} {s : yoneda.obj X ⟶ A} :
OverArrows η s → F.obj (op X) :=
Subtype.val
@[simp]
lemma val_mk {F : Cᵒᵖ ⥤ Type v} (η : F ⟶ A) {X : C} (s : yoneda.obj X ⟶ A) (u : F.obj (op X))
(h : MakesOverArrow η s u) : val ⟨u, h⟩ = u :=
rfl
@[ext]
lemma ext {F : Cᵒᵖ ⥤ Type v} {η : F ⟶ A} {X : C} {s : yoneda.obj X ⟶ A}
{u v : OverArrows η s} : u.val = v.val → u = v :=
Subtype.ext
/-- The defining property of `OverArrows.val`. -/
lemma app_val {F : Cᵒᵖ ⥤ Type v} {η : F ⟶ A} {X : C} {s : yoneda.obj X ⟶ A}
(p : OverArrows η s) : η.app (op X) p.val = yonedaEquiv s :=
p.prop.app
/-- In the special case `F = yoneda.obj Y`, the element `p.val` for `p : OverArrows η s` is itself
a morphism `X ⟶ Y`. -/
@[simp]
lemma map_val {Y : C} {η : yoneda.obj Y ⟶ A} {X : C} {s : yoneda.obj X ⟶ A}
(p : OverArrows η s) : yoneda.map p.val ≫ η = s := by
rw [← yonedaEquiv.injective.eq_iff, yonedaEquiv_comp, yonedaEquiv_yoneda_map]
simp only [unop_op, p.app_val]
/-- Functoriality of `OverArrows η s` in `η`. -/
def map₁ {F G : Cᵒᵖ ⥤ Type v} {η : F ⟶ A} {μ : G ⟶ A} {X : C} {s : yoneda.obj X ⟶ A}
(u : OverArrows η s) (ε : F ⟶ G) (hε : ε ≫ μ = η) : OverArrows μ s :=
⟨ε.app _ u.val, MakesOverArrow.map₁ hε u.2⟩
@[simp]
lemma map₁_val {F G : Cᵒᵖ ⥤ Type v} {η : F ⟶ A} {μ : G ⟶ A} {X : C}
(s : yoneda.obj X ⟶ A) (u : OverArrows η s) (ε : F ⟶ G) (hε : ε ≫ μ = η) :
(u.map₁ ε hε).val = ε.app _ u.val :=
rfl
/-- Functoriality of `OverArrows η s` in `s`. -/
def map₂ {F : Cᵒᵖ ⥤ Type v} {η : F ⟶ A} {X Y : C} {s : yoneda.obj X ⟶ A}
{t : yoneda.obj Y ⟶ A} (u : OverArrows η t) (f : X ⟶ Y) (hst : yoneda.map f ≫ t = s) :
OverArrows η s :=
⟨F.map f.op u.val, MakesOverArrow.map₂ f hst u.2⟩
@[simp]
lemma map₂_val {F : Cᵒᵖ ⥤ Type v} {η : F ⟶ A} {X Y : C} (f : X ⟶ Y)
{s : yoneda.obj X ⟶ A} {t : yoneda.obj Y ⟶ A} (hst : yoneda.map f ≫ t = s)
(u : OverArrows η t) : (u.map₂ f hst).val = F.map f.op u.val :=
rfl
@[simp]
lemma map₁_map₂ {F G : Cᵒᵖ ⥤ Type v} {η : F ⟶ A} {μ : G ⟶ A} (ε : F ⟶ G)
(hε : ε ≫ μ = η) {X Y : C} {s : yoneda.obj X ⟶ A} {t : yoneda.obj Y ⟶ A} (f : X ⟶ Y)
(hf : yoneda.map f ≫ t = s) (u : OverArrows η t) :
(u.map₁ ε hε).map₂ f hf = (u.map₂ f hf).map₁ ε hε :=
OverArrows.ext <| (elementwise_of% (ε.naturality f.op).symm) u.val
/-- Construct an element of `OverArrows η s` with `F = yoneda.obj Y` from a suitable morphism
`f : X ⟶ Y`. -/
def yonedaArrow {Y : C} {η : yoneda.obj Y ⟶ A} {X : C} {s : yoneda.obj X ⟶ A} (f : X ⟶ Y)
(hf : yoneda.map f ≫ η = s) : OverArrows η s :=
⟨f, .of_yoneda_arrow hf⟩
@[simp]
lemma yonedaArrow_val {Y : C} {η : yoneda.obj Y ⟶ A} {X : C} {s : yoneda.obj X ⟶ A} {f : X ⟶ Y}
(hf : yoneda.map f ≫ η = s) : (yonedaArrow f hf).val = f :=
rfl
/-- If `η` is also `yoneda`-costructured, then `OverArrows η s` is just morphisms of costructured
arrows. -/
def costructuredArrowIso (s t : CostructuredArrow yoneda A) : OverArrows s.hom t.hom ≅ t ⟶ s where
hom p := CostructuredArrow.homMk p.val (by aesop_cat)
inv f := yonedaArrow f.left f.w
end OverArrows
/-- This is basically just `yoneda.obj η : (Over A)ᵒᵖ ⥤ Type (max u v)` restricted along the
forgetful functor `CostructuredArrow yoneda A ⥤ Over A`, but done in a way that we land in a
smaller universe. -/
@[simps]
def restrictedYonedaObj {F : Cᵒᵖ ⥤ Type v} (η : F ⟶ A) :
(CostructuredArrow yoneda A)ᵒᵖ ⥤ Type v where
obj s := OverArrows η s.unop.hom
map f u := u.map₂ f.unop.left f.unop.w
/-- Functoriality of `restrictedYonedaObj η` in `η`. -/
@[simps]
def restrictedYonedaObjMap₁ {F G : Cᵒᵖ ⥤ Type v} {η : F ⟶ A} {μ : G ⟶ A} (ε : F ⟶ G)
(hε : ε ≫ μ = η) : restrictedYonedaObj η ⟶ restrictedYonedaObj μ where
app s u := u.map₁ ε hε
/-- This is basically just `yoneda : Over A ⥤ (Over A)ᵒᵖ ⥤ Type (max u v)` restricted in the second
argument along the forgetful functor `CostructuredArrow yoneda A ⥤ Over A`, but done in a way
that we land in a smaller universe.
This is one direction of the equivalence we're constructing. -/
@[simps]
def restrictedYoneda (A : Cᵒᵖ ⥤ Type v) : Over A ⥤ (CostructuredArrow yoneda A)ᵒᵖ ⥤ Type v where
obj η := restrictedYonedaObj η.hom
map ε := restrictedYonedaObjMap₁ ε.left ε.w
/-- Further restricting the functor
`restrictedYoneda : Over A ⥤ (CostructuredArrow yoneda A)ᵒᵖ ⥤ Type v` along the forgetful
functor in the first argument recovers the Yoneda embedding
`CostructuredArrow yoneda A ⥤ (CostructuredArrow yoneda A)ᵒᵖ ⥤ Type v`. This basically follows
from the fact that the Yoneda embedding on `C` is fully faithful. -/
def toOverYonedaCompRestrictedYoneda (A : Cᵒᵖ ⥤ Type v) :
CostructuredArrow.toOver yoneda A ⋙ restrictedYoneda A ≅ yoneda :=
NatIso.ofComponents
(fun s => NatIso.ofComponents (fun t => OverArrows.costructuredArrowIso _ _) (by aesop_cat))
(by aesop_cat)
/-! ### Construction of the backward functor `((CostructuredArrow yoneda A)ᵒᵖ ⥤ Type v) ⥤ Over A` -/
/-- This lemma will be key to establishing good simp normal forms. -/
lemma map_mkPrecomp_eqToHom {F : (CostructuredArrow yoneda A)ᵒᵖ ⥤ Type v} {X Y : C} {f : X ⟶ Y}
{g g' : yoneda.obj Y ⟶ A} (h : g = g') {x : F.obj (op (CostructuredArrow.mk g'))} :
F.map (CostructuredArrow.mkPrecomp g f).op (F.map (eqToHom (by rw [h])) x) =
F.map (eqToHom (by rw [h])) (F.map (CostructuredArrow.mkPrecomp g' f).op x) := by
aesop_cat
attribute [local simp] map_mkPrecomp_eqToHom
/-- To give an object of `Over A`, we will in particular need a presheaf `Cᵒᵖ ⥤ Type v`. This is the
definition of that presheaf on objects.
We would prefer to think of this sigma type to be indexed by natural transformations
`yoneda.obj X ⟶ A` instead of `A.obj (op X)`. These are equivalent by the Yoneda lemma, but
we cannot use the former because that type lives in the wrong universe. Hence, we will provide
a lot of API that will enable us to pretend that we are really indexing over
`yoneda.obj X ⟶ A`. -/
def YonedaCollection (F : (CostructuredArrow yoneda A)ᵒᵖ ⥤ Type v) (X : C) : Type v :=
Σ s : A.obj (op X), F.obj (op (CostructuredArrow.mk (yonedaEquiv.symm s)))
namespace YonedaCollection
variable {F : (CostructuredArrow yoneda A)ᵒᵖ ⥤ Type v} {X : C}
/-- Given a costructured arrow `s : yoneda.obj X ⟶ A` and an element `x : F.obj s`, construct
an element of `YonedaCollection F X`. -/
def mk (s : yoneda.obj X ⟶ A) (x : F.obj (op (CostructuredArrow.mk s))) : YonedaCollection F X :=
⟨yonedaEquiv s, F.map (eqToHom <| by rw [Equiv.symm_apply_apply]) x⟩
/-- Access the first component of an element of `YonedaCollection F X`. -/
def fst (p : YonedaCollection F X) : yoneda.obj X ⟶ A :=
yonedaEquiv.symm p.1
/-- Access the second component of an element of `YonedaCollection F X`. -/
def snd (p : YonedaCollection F X) : F.obj (op (CostructuredArrow.mk p.fst)) :=
p.2
/-- This is a definition because it will be helpful to be able to control precisely when this
definition is unfolded. -/
def yonedaEquivFst (p : YonedaCollection F X) : A.obj (op X) :=
yonedaEquiv p.fst
lemma yonedaEquivFst_eq (p : YonedaCollection F X) : p.yonedaEquivFst = yonedaEquiv p.fst :=
rfl
@[simp]
lemma mk_fst (s : yoneda.obj X ⟶ A) (x : F.obj (op (CostructuredArrow.mk s))) : (mk s x).fst = s :=
Equiv.apply_symm_apply _ _
@[simp]
lemma mk_snd (s : yoneda.obj X ⟶ A) (x : F.obj (op (CostructuredArrow.mk s))) :
(mk s x).snd = F.map (eqToHom <| by rw [YonedaCollection.mk_fst]) x :=
rfl
@[ext (iff := false)]
lemma ext {p q : YonedaCollection F X} (h : p.fst = q.fst)
(h' : F.map (eqToHom <| by rw [h]) q.snd = p.snd) : p = q := by
rcases p with ⟨p, p'⟩
rcases q with ⟨q, q'⟩
obtain rfl : p = q := yonedaEquiv.symm.injective h
exact Sigma.ext rfl (by simpa [snd] using h'.symm)
/-- Functoriality of `YonedaCollection F X` in `F`. -/
def map₁ {G : (CostructuredArrow yoneda A)ᵒᵖ ⥤ Type v} (η : F ⟶ G) :
YonedaCollection F X → YonedaCollection G X :=
fun p => YonedaCollection.mk p.fst (η.app _ p.snd)
@[simp]
lemma map₁_fst {G : (CostructuredArrow yoneda A)ᵒᵖ ⥤ Type v} (η : F ⟶ G)
(p : YonedaCollection F X) : (YonedaCollection.map₁ η p).fst = p.fst := by
simp [map₁]
@[simp]
lemma map₁_yonedaEquivFst {G : (CostructuredArrow yoneda A)ᵒᵖ ⥤ Type v} (η : F ⟶ G)
(p : YonedaCollection F X) :
(YonedaCollection.map₁ η p).yonedaEquivFst = p.yonedaEquivFst := by
simp only [YonedaCollection.yonedaEquivFst_eq, map₁_fst]
@[simp]
lemma map₁_snd {G : (CostructuredArrow yoneda A)ᵒᵖ ⥤ Type v} (η : F ⟶ G)
(p : YonedaCollection F X) : (YonedaCollection.map₁ η p).snd =
G.map (eqToHom (by rw [YonedaCollection.map₁_fst])) (η.app _ p.snd) := by
simp [map₁]
/-- Functoriality of `YonedaCollection F X` in `X`. -/
def map₂ (F : (CostructuredArrow yoneda A)ᵒᵖ ⥤ Type v) {Y : C} (f : X ⟶ Y)
(p : YonedaCollection F Y) : YonedaCollection F X :=
YonedaCollection.mk (yoneda.map f ≫ p.fst) <| F.map (CostructuredArrow.mkPrecomp p.fst f).op p.snd
@[simp]
lemma map₂_fst {Y : C} (f : X ⟶ Y) (p : YonedaCollection F Y) :
(YonedaCollection.map₂ F f p).fst = yoneda.map f ≫ p.fst := by
simp [map₂]
@[simp]
lemma map₂_yonedaEquivFst {Y : C} (f : X ⟶ Y) (p : YonedaCollection F Y) :
(YonedaCollection.map₂ F f p).yonedaEquivFst = A.map f.op p.yonedaEquivFst := by
simp only [YonedaCollection.yonedaEquivFst_eq, map₂_fst, yonedaEquiv_naturality]
@[simp]
lemma map₂_snd {Y : C} (f : X ⟶ Y) (p : YonedaCollection F Y) :
(YonedaCollection.map₂ F f p).snd = F.map ((CostructuredArrow.mkPrecomp p.fst f).op ≫
eqToHom (by rw [YonedaCollection.map₂_fst f])) p.snd := by
simp [map₂]
attribute [local simp] CostructuredArrow.mkPrecomp_id CostructuredArrow.mkPrecomp_comp
@[simp]
lemma map₁_id : YonedaCollection.map₁ (𝟙 F) (X := X) = id := by
aesop_cat
@[simp]
lemma map₁_comp {G H : (CostructuredArrow yoneda A)ᵒᵖ ⥤ Type v} (η : F ⟶ G) (μ : G ⟶ H) :
YonedaCollection.map₁ (η ≫ μ) (X := X) =
YonedaCollection.map₁ μ (X := X) ∘ YonedaCollection.map₁ η (X := X) := by
ext; all_goals simp
@[simp]
lemma map₂_id : YonedaCollection.map₂ F (𝟙 X) = id := by
ext; all_goals simp
@[simp]
lemma map₂_comp {Y Z : C} (f : X ⟶ Y) (g : Y ⟶ Z) :
YonedaCollection.map₂ F (f ≫ g) = YonedaCollection.map₂ F f ∘ YonedaCollection.map₂ F g := by
ext; all_goals simp
@[simp]
lemma map₁_map₂ {G : (CostructuredArrow yoneda A)ᵒᵖ ⥤ Type v} (η : F ⟶ G) {Y : C} (f : X ⟶ Y)
(p : YonedaCollection F Y) :
YonedaCollection.map₂ G f (YonedaCollection.map₁ η p) =
YonedaCollection.map₁ η (YonedaCollection.map₂ F f p) := by
ext; all_goals simp
end YonedaCollection
/-- Given `F : (CostructuredArrow yoneda A)ᵒᵖ ⥤ Type v`, this is the presheaf that is given by
`YonedaCollection F X` on objects. -/
@[simps]
def yonedaCollectionPresheaf (A : Cᵒᵖ ⥤ Type v) (F : (CostructuredArrow yoneda A)ᵒᵖ ⥤ Type v) :
Cᵒᵖ ⥤ Type v where
obj X := YonedaCollection F X.unop
map f := YonedaCollection.map₂ F f.unop
/-- Functoriality of `yonedaCollectionPresheaf A F` in `F`. -/
@[simps]
def yonedaCollectionPresheafMap₁ {F G : (CostructuredArrow yoneda A)ᵒᵖ ⥤ Type v} (η : F ⟶ G) :
yonedaCollectionPresheaf A F ⟶ yonedaCollectionPresheaf A G where
app X := YonedaCollection.map₁ η
naturality := by
intros
ext
simp
/-- This is the functor `F ↦ X ↦ YonedaCollection F X`. -/
@[simps]
def yonedaCollectionFunctor (A : Cᵒᵖ ⥤ Type v) :
((CostructuredArrow yoneda A)ᵒᵖ ⥤ Type v) ⥤ Cᵒᵖ ⥤ Type v where
obj := yonedaCollectionPresheaf A
map η := yonedaCollectionPresheafMap₁ η
/-- The Yoneda lemma yields a natural transformation `yonedaCollectionPresheaf A F ⟶ A`. -/
@[simps]
def yonedaCollectionPresheafToA (F : (CostructuredArrow yoneda A)ᵒᵖ ⥤ Type v) :
yonedaCollectionPresheaf A F ⟶ A where
app X := YonedaCollection.yonedaEquivFst
/-- This is the reverse direction of the equivalence we're constructing. -/
@[simps! obj map]
def costructuredArrowPresheafToOver (A : Cᵒᵖ ⥤ Type v) :
((CostructuredArrow yoneda A)ᵒᵖ ⥤ Type v) ⥤ Over A :=
(yonedaCollectionFunctor A).toOver _ (yonedaCollectionPresheafToA) (by aesop_cat)
section unit
/-! ### Construction of the unit -/
/-- Forward direction of the unit. -/
def unitForward {F : Cᵒᵖ ⥤ Type v} (η : F ⟶ A) (X : C) :
YonedaCollection (restrictedYonedaObj η) X → F.obj (op X) :=
fun p => p.snd.val
@[simp]
lemma unitForward_naturality₁ {F G : Cᵒᵖ ⥤ Type v} {η : F ⟶ A} {μ : G ⟶ A} (ε : F ⟶ G)
(hε : ε ≫ μ = η) (X : C) (p : YonedaCollection (restrictedYonedaObj η) X) :
unitForward μ X (p.map₁ (restrictedYonedaObjMap₁ ε hε)) = ε.app _ (unitForward η X p) := by
simp [unitForward]
@[simp]
lemma unitForward_naturality₂ {F : Cᵒᵖ ⥤ Type v} (η : F ⟶ A) (X Y : C) (f : X ⟶ Y)
(p : YonedaCollection (restrictedYonedaObj η) Y) :
unitForward η X (YonedaCollection.map₂ (restrictedYonedaObj η) f p) =
F.map f.op (unitForward η Y p) := by
simp [unitForward]
@[simp]
lemma app_unitForward {F : Cᵒᵖ ⥤ Type v} (η : F ⟶ A) (X : Cᵒᵖ)
(p : YonedaCollection (restrictedYonedaObj η) X.unop) :
η.app X (unitForward η X.unop p) = p.yonedaEquivFst := by
simpa [unitForward] using p.snd.app_val
/-- Backward direction of the unit. -/
def unitBackward {F : Cᵒᵖ ⥤ Type v} (η : F ⟶ A) (X : C) :
F.obj (op X) → YonedaCollection (restrictedYonedaObj η) X :=
fun x => YonedaCollection.mk (yonedaEquiv.symm (η.app _ x)) ⟨x, ⟨by aesop_cat⟩⟩
lemma unitForward_unitBackward {F : Cᵒᵖ ⥤ Type v} (η : F ⟶ A) (X : C) :
unitForward η X ∘ unitBackward η X = id :=
funext fun x => by simp [unitForward, unitBackward]
lemma unitBackward_unitForward {F : Cᵒᵖ ⥤ Type v} (η : F ⟶ A) (X : C) :
unitBackward η X ∘ unitForward η X = id := by
refine funext fun p => YonedaCollection.ext ?_ (OverArrows.ext ?_)
· simpa [unitForward, unitBackward] using congrArg yonedaEquiv.symm p.snd.app_val
· simp [unitForward, unitBackward]
/-- Intermediate stage of assembling the unit. -/
@[simps]
def unitAuxAuxAux {F : Cᵒᵖ ⥤ Type v} (η : F ⟶ A) (X : C) :
YonedaCollection (restrictedYonedaObj η) X ≅ F.obj (op X) where
hom := unitForward η X
inv := unitBackward η X
hom_inv_id := unitBackward_unitForward η X
inv_hom_id := unitForward_unitBackward η X
/-- Intermediate stage of assembling the unit. -/
@[simps!]
def unitAuxAux {F : Cᵒᵖ ⥤ Type v} (η : F ⟶ A) :
yonedaCollectionPresheaf A (restrictedYonedaObj η) ≅ F :=
NatIso.ofComponents (fun X => unitAuxAuxAux η X.unop) (by aesop_cat)
/-- Intermediate stage of assembling the unit. -/
@[simps! hom]
def unitAux (η : Over A) : (restrictedYoneda A ⋙ costructuredArrowPresheafToOver A).obj η ≅ η :=
Over.isoMk (unitAuxAux η.hom) (by aesop_cat)
/-- The unit of the equivalence we're constructing. -/
def unit (A : Cᵒᵖ ⥤ Type v) : 𝟭 (Over A) ≅ restrictedYoneda A ⋙ costructuredArrowPresheafToOver A :=
Iso.symm <| NatIso.ofComponents unitAux (by aesop_cat)
end unit
/-! ### Construction of the counit -/
section counit
variable {F : (CostructuredArrow yoneda A)ᵒᵖ ⥤ Type v} {X : C}
@[simp]
lemma OverArrows.yonedaCollectionPresheafToA_val_fst (s : yoneda.obj X ⟶ A)
(p : OverArrows (yonedaCollectionPresheafToA F) s) : p.val.fst = s := by
simpa [YonedaCollection.yonedaEquivFst_eq] using p.app_val
/-- Forward direction of the counit. -/
def counitForward (F : (CostructuredArrow yoneda A)ᵒᵖ ⥤ Type v) (s : CostructuredArrow yoneda A) :
F.obj (op s) → OverArrows (yonedaCollectionPresheafToA F) s.hom :=
fun x => ⟨YonedaCollection.mk s.hom x, ⟨by simp [YonedaCollection.yonedaEquivFst_eq]⟩⟩
lemma counitForward_val_fst (s : CostructuredArrow yoneda A) (x : F.obj (op s)) :
(counitForward F s x).val.fst = s.hom := by
simp
@[simp]
lemma counitForward_val_snd (s : CostructuredArrow yoneda A) (x : F.obj (op s)) :
(counitForward F s x).val.snd = F.map (eqToHom (by simp [← CostructuredArrow.eq_mk])) x :=
YonedaCollection.mk_snd _ _
@[simp]
lemma counitForward_naturality₁ {G : (CostructuredArrow yoneda A)ᵒᵖ ⥤ Type v} (η : F ⟶ G)
(s : (CostructuredArrow yoneda A)ᵒᵖ) (x : F.obj s) : counitForward G s.unop (η.app s x) =
OverArrows.map₁ (counitForward F s.unop x) (yonedaCollectionPresheafMap₁ η) (by aesop_cat) :=
OverArrows.ext <| YonedaCollection.ext (by simp) (by simp)
@[simp]
lemma counitForward_naturality₂ (s t : (CostructuredArrow yoneda A)ᵒᵖ) (f : t ⟶ s) (x : F.obj t) :
counitForward F s.unop (F.map f x) =
OverArrows.map₂ (counitForward F t.unop x) f.unop.left (by simp) := by
refine OverArrows.ext <| YonedaCollection.ext (by simp) ?_
have : (CostructuredArrow.mkPrecomp t.unop.hom f.unop.left).op =
f ≫ eqToHom (by simp [← CostructuredArrow.eq_mk]) := by
apply Quiver.Hom.unop_inj
aesop_cat
aesop_cat
/-- Backward direction of the counit. -/
def counitBackward (F : (CostructuredArrow yoneda A)ᵒᵖ ⥤ Type v) (s : CostructuredArrow yoneda A) :
OverArrows (yonedaCollectionPresheafToA F) s.hom → F.obj (op s) :=
fun p => F.map (eqToHom (by simp [← CostructuredArrow.eq_mk])) p.val.snd
lemma counitForward_counitBackward (F : (CostructuredArrow yoneda A)ᵒᵖ ⥤ Type v)
(s : CostructuredArrow yoneda A) : counitForward F s ∘ counitBackward F s = id :=
funext fun p => OverArrows.ext <| YonedaCollection.ext (by simp) (by simp [counitBackward])
lemma counitBackward_counitForward (F : (CostructuredArrow yoneda A)ᵒᵖ ⥤ Type v)
(s : CostructuredArrow yoneda A) : counitBackward F s ∘ counitForward F s = id :=
funext fun x => by simp [counitBackward]
/-- Intermediate stage of assembling the counit. -/
@[simps]
def counitAuxAux (F : (CostructuredArrow yoneda A)ᵒᵖ ⥤ Type v) (s : CostructuredArrow yoneda A) :
F.obj (op s) ≅ OverArrows (yonedaCollectionPresheafToA F) s.hom where
hom := counitForward F s
inv := counitBackward F s
hom_inv_id := counitBackward_counitForward F s
inv_hom_id := counitForward_counitBackward F s
/-- Intermediate stage of assembling the counit. -/
@[simps! hom]
def counitAux (F : (CostructuredArrow yoneda A)ᵒᵖ ⥤ Type v) :
F ≅ restrictedYonedaObj (yonedaCollectionPresheafToA F) :=
NatIso.ofComponents (fun s => counitAuxAux F s.unop) (by aesop_cat)
/-- The counit of the equivalence we're constructing. -/
def counit (A : Cᵒᵖ ⥤ Type v) : (costructuredArrowPresheafToOver A ⋙ restrictedYoneda A) ≅ 𝟭 _ :=
Iso.symm <| NatIso.ofComponents counitAux (by aesop_cat)
end counit
end OverPresheafAux
open OverPresheafAux
/-- If `A : Cᵒᵖ ⥤ Type v` is a presheaf, then we have an equivalence between presheaves lying over
`A` and the category of presheaves on `CostructuredArrow yoneda A`. There is a quasicommutative
triangle involving this equivalence, see
`CostructuredArrow.toOverCompOverEquivPresheafCostructuredArrow`.
This is Lemma 1.4.12 in [Kashiwara2006]. -/
def overEquivPresheafCostructuredArrow (A : Cᵒᵖ ⥤ Type v) :
Over A ≌ ((CostructuredArrow yoneda A)ᵒᵖ ⥤ Type v) :=
.mk (restrictedYoneda A) (costructuredArrowPresheafToOver A) (unit A) (counit A)
/-- If `A : Cᵒᵖ ⥤ Type v` is a presheaf, then the Yoneda embedding for
`CostructuredArrow yoneda A` factors through `Over A` via a forgetful functor and an
equivalence.
This is Lemma 1.4.12 in [Kashiwara2006]. -/
def CostructuredArrow.toOverCompOverEquivPresheafCostructuredArrow (A : Cᵒᵖ ⥤ Type v) :
CostructuredArrow.toOver yoneda A ⋙ (overEquivPresheafCostructuredArrow A).functor ≅ yoneda :=
toOverYonedaCompRestrictedYoneda A
end CategoryTheory
|
CategoryTheory\Comma\StructuredArrow.lean | /-
Copyright (c) 2021 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Adam Topaz, Scott Morrison
-/
import Mathlib.CategoryTheory.Comma.Basic
import Mathlib.CategoryTheory.PUnit
import Mathlib.CategoryTheory.Limits.Shapes.Terminal
import Mathlib.CategoryTheory.EssentiallySmall
import Mathlib.Logic.Small.Set
/-!
# The category of "structured arrows"
For `T : C ⥤ D`, a `T`-structured arrow with source `S : D`
is just a morphism `S ⟶ T.obj Y`, for some `Y : C`.
These form a category with morphisms `g : Y ⟶ Y'` making the obvious diagram commute.
We prove that `𝟙 (T.obj Y)` is the initial object in `T`-structured objects with source `T.obj Y`.
-/
namespace CategoryTheory
-- morphism levels before object levels. See note [CategoryTheory universes].
universe v₁ v₂ v₃ v₄ u₁ u₂ u₃ u₄
variable {C : Type u₁} [Category.{v₁} C] {D : Type u₂} [Category.{v₂} D]
/-- The category of `T`-structured arrows with domain `S : D` (here `T : C ⥤ D`),
has as its objects `D`-morphisms of the form `S ⟶ T Y`, for some `Y : C`,
and morphisms `C`-morphisms `Y ⟶ Y'` making the obvious triangle commute.
-/
-- We explicitly come from `PUnit.{1}` here to obtain the correct universe for morphisms of
-- structured arrows.
-- Porting note(#5171): linter not ported yet
-- @[nolint has_nonempty_instance]
def StructuredArrow (S : D) (T : C ⥤ D) :=
Comma (Functor.fromPUnit.{0} S) T
-- Porting note: not found by inferInstance
instance (S : D) (T : C ⥤ D) : Category (StructuredArrow S T) := commaCategory
namespace StructuredArrow
/-- The obvious projection functor from structured arrows. -/
@[simps!]
def proj (S : D) (T : C ⥤ D) : StructuredArrow S T ⥤ C :=
Comma.snd _ _
variable {S S' S'' : D} {Y Y' Y'' : C} {T T' : C ⥤ D}
-- Porting note (#5229): this lemma was added because `Comma.hom_ext`
-- was not triggered automatically
@[ext]
lemma hom_ext {X Y : StructuredArrow S T} (f g : X ⟶ Y) (h : f.right = g.right) : f = g :=
CommaMorphism.ext (Subsingleton.elim _ _) h
@[simp]
theorem hom_eq_iff {X Y : StructuredArrow S T} (f g : X ⟶ Y) : f = g ↔ f.right = g.right :=
⟨fun h ↦ by rw [h], hom_ext _ _⟩
/-- Construct a structured arrow from a morphism. -/
def mk (f : S ⟶ T.obj Y) : StructuredArrow S T :=
⟨⟨⟨⟩⟩, Y, f⟩
@[simp]
theorem mk_left (f : S ⟶ T.obj Y) : (mk f).left = ⟨⟨⟩⟩ :=
rfl
@[simp]
theorem mk_right (f : S ⟶ T.obj Y) : (mk f).right = Y :=
rfl
@[simp]
theorem mk_hom_eq_self (f : S ⟶ T.obj Y) : (mk f).hom = f :=
rfl
@[reassoc (attr := simp)]
theorem w {A B : StructuredArrow S T} (f : A ⟶ B) : A.hom ≫ T.map f.right = B.hom := by
have := f.w; aesop_cat
@[simp]
theorem comp_right {X Y Z : StructuredArrow S T} (f : X ⟶ Y) (g : Y ⟶ Z) :
(f ≫ g).right = f.right ≫ g.right := rfl
@[simp]
theorem id_right (X : StructuredArrow S T) : (𝟙 X : X ⟶ X).right = 𝟙 X.right := rfl
@[simp]
theorem eqToHom_right {X Y : StructuredArrow S T} (h : X = Y) :
(eqToHom h).right = eqToHom (by rw [h]) := by
subst h
simp only [eqToHom_refl, id_right]
@[simp]
theorem left_eq_id {X Y : StructuredArrow S T} (f : X ⟶ Y) : f.left = 𝟙 _ := rfl
/-- To construct a morphism of structured arrows,
we need a morphism of the objects underlying the target,
and to check that the triangle commutes.
-/
@[simps]
def homMk {f f' : StructuredArrow S T} (g : f.right ⟶ f'.right)
(w : f.hom ≫ T.map g = f'.hom := by aesop_cat) : f ⟶ f' where
left := 𝟙 _
right := g
w := by
dsimp
simpa using w.symm
/- Porting note: it appears the simp lemma is not getting generated but the linter
picks up on it (seems like a bug). Either way simp solves it. -/
attribute [-simp, nolint simpNF] homMk_left
theorem homMk_surjective {f f' : StructuredArrow S T} (φ : f ⟶ f') :
∃ (ψ : f.right ⟶ f'.right) (hψ : f.hom ≫ T.map ψ = f'.hom),
φ = StructuredArrow.homMk ψ hψ :=
⟨φ.right, StructuredArrow.w φ, rfl⟩
/-- Given a structured arrow `X ⟶ T(Y)`, and an arrow `Y ⟶ Y'`, we can construct a morphism of
structured arrows given by `(X ⟶ T(Y)) ⟶ (X ⟶ T(Y) ⟶ T(Y'))`. -/
@[simps]
def homMk' (f : StructuredArrow S T) (g : f.right ⟶ Y') : f ⟶ mk (f.hom ≫ T.map g) where
left := 𝟙 _
right := g
lemma homMk'_id (f : StructuredArrow S T) : homMk' f (𝟙 f.right) = eqToHom (by aesop_cat) := by
ext
simp [eqToHom_right]
lemma homMk'_mk_id (f : S ⟶ T.obj Y) : homMk' (mk f) (𝟙 Y) = eqToHom (by aesop_cat) :=
homMk'_id _
lemma homMk'_comp (f : StructuredArrow S T) (g : f.right ⟶ Y') (g' : Y' ⟶ Y'') :
homMk' f (g ≫ g') = homMk' f g ≫ homMk' (mk (f.hom ≫ T.map g)) g' ≫ eqToHom (by simp) := by
ext
simp [eqToHom_right]
lemma homMk'_mk_comp (f : S ⟶ T.obj Y) (g : Y ⟶ Y') (g' : Y' ⟶ Y'') :
homMk' (mk f) (g ≫ g') = homMk' (mk f) g ≫ homMk' (mk (f ≫ T.map g)) g' ≫ eqToHom (by simp) :=
homMk'_comp _ _ _
/-- Variant of `homMk'` where both objects are applications of `mk`. -/
@[simps]
def mkPostcomp (f : S ⟶ T.obj Y) (g : Y ⟶ Y') : mk f ⟶ mk (f ≫ T.map g) where
left := 𝟙 _
right := g
lemma mkPostcomp_id (f : S ⟶ T.obj Y) : mkPostcomp f (𝟙 Y) = eqToHom (by aesop_cat) := by aesop_cat
lemma mkPostcomp_comp (f : S ⟶ T.obj Y) (g : Y ⟶ Y') (g' : Y' ⟶ Y'') :
mkPostcomp f (g ≫ g') = mkPostcomp f g ≫ mkPostcomp (f ≫ T.map g) g' ≫ eqToHom (by simp) := by
aesop_cat
/-- To construct an isomorphism of structured arrows,
we need an isomorphism of the objects underlying the target,
and to check that the triangle commutes.
-/
@[simps!]
def isoMk {f f' : StructuredArrow S T} (g : f.right ≅ f'.right)
(w : f.hom ≫ T.map g.hom = f'.hom := by aesop_cat) :
f ≅ f' :=
Comma.isoMk (eqToIso (by ext)) g (by simpa using w.symm)
/- Porting note: it appears the simp lemma is not getting generated but the linter
picks up on it. Either way simp solves these. -/
attribute [-simp, nolint simpNF] isoMk_hom_left_down_down isoMk_inv_left_down_down
theorem ext {A B : StructuredArrow S T} (f g : A ⟶ B) : f.right = g.right → f = g :=
CommaMorphism.ext (Subsingleton.elim _ _)
theorem ext_iff {A B : StructuredArrow S T} (f g : A ⟶ B) : f = g ↔ f.right = g.right :=
⟨fun h => h ▸ rfl, ext f g⟩
instance proj_faithful : (proj S T).Faithful where
map_injective {_ _} := ext
/-- The converse of this is true with additional assumptions, see `mono_iff_mono_right`. -/
theorem mono_of_mono_right {A B : StructuredArrow S T} (f : A ⟶ B) [h : Mono f.right] : Mono f :=
(proj S T).mono_of_mono_map h
theorem epi_of_epi_right {A B : StructuredArrow S T} (f : A ⟶ B) [h : Epi f.right] : Epi f :=
(proj S T).epi_of_epi_map h
instance mono_homMk {A B : StructuredArrow S T} (f : A.right ⟶ B.right) (w) [h : Mono f] :
Mono (homMk f w) :=
(proj S T).mono_of_mono_map h
instance epi_homMk {A B : StructuredArrow S T} (f : A.right ⟶ B.right) (w) [h : Epi f] :
Epi (homMk f w) :=
(proj S T).epi_of_epi_map h
/-- Eta rule for structured arrows. Prefer `StructuredArrow.eta` for rewriting, since equality of
objects tends to cause problems. -/
theorem eq_mk (f : StructuredArrow S T) : f = mk f.hom :=
rfl
/-- Eta rule for structured arrows. -/
@[simps!]
def eta (f : StructuredArrow S T) : f ≅ mk f.hom :=
isoMk (Iso.refl _)
/- Porting note: it appears the simp lemma is not getting generated but the linter
picks up on it. Either way simp solves these. -/
attribute [-simp, nolint simpNF] eta_hom_left_down_down eta_inv_left_down_down
lemma mk_surjective (f : StructuredArrow S T) :
∃ (Y : C) (g : S ⟶ T.obj Y), f = mk g :=
⟨_, _, eq_mk f⟩
/-- A morphism between source objects `S ⟶ S'`
contravariantly induces a functor between structured arrows,
`StructuredArrow S' T ⥤ StructuredArrow S T`.
Ideally this would be described as a 2-functor from `D`
(promoted to a 2-category with equations as 2-morphisms)
to `Cat`.
-/
@[simps!]
def map (f : S ⟶ S') : StructuredArrow S' T ⥤ StructuredArrow S T :=
Comma.mapLeft _ ((Functor.const _).map f)
@[simp]
theorem map_mk {f : S' ⟶ T.obj Y} (g : S ⟶ S') : (map g).obj (mk f) = mk (g ≫ f) :=
rfl
@[simp]
theorem map_id {f : StructuredArrow S T} : (map (𝟙 S)).obj f = f := by
rw [eq_mk f]
simp
@[simp]
theorem map_comp {f : S ⟶ S'} {f' : S' ⟶ S''} {h : StructuredArrow S'' T} :
(map (f ≫ f')).obj h = (map f).obj ((map f').obj h) := by
rw [eq_mk h]
simp
/-- An isomorphism `S ≅ S'` induces an equivalence `StructuredArrow S T ≌ StructuredArrow S' T`. -/
@[simp]
def mapIso (i : S ≅ S') : StructuredArrow S T ≌ StructuredArrow S' T :=
Comma.mapLeftIso _ ((Functor.const _).mapIso i)
/-- A natural isomorphism `T ≅ T'` induces an equivalence
`StructuredArrow S T ≌ StructuredArrow S T'`. -/
@[simp]
def mapNatIso (i : T ≅ T') : StructuredArrow S T ≌ StructuredArrow S T' :=
Comma.mapRightIso _ i
instance proj_reflectsIsomorphisms : (proj S T).ReflectsIsomorphisms where
reflects {Y Z} f t :=
⟨⟨StructuredArrow.homMk
(inv ((proj S T).map f))
(by rw [Functor.map_inv, IsIso.comp_inv_eq]; simp),
by constructor <;> apply CommaMorphism.ext <;> dsimp at t ⊢ <;> simp⟩⟩
open CategoryTheory.Limits
/-- The identity structured arrow is initial. -/
noncomputable def mkIdInitial [T.Full] [T.Faithful] : IsInitial (mk (𝟙 (T.obj Y))) where
desc c := homMk (T.preimage c.pt.hom)
uniq c m _ := by
apply CommaMorphism.ext
· aesop_cat
· apply T.map_injective
simpa only [homMk_right, T.map_preimage, ← w m] using (Category.id_comp _).symm
variable {A : Type u₃} [Category.{v₃} A] {B : Type u₄} [Category.{v₄} B]
/-- The functor `(S, F ⋙ G) ⥤ (S, G)`. -/
@[simps!]
def pre (S : D) (F : B ⥤ C) (G : C ⥤ D) : StructuredArrow S (F ⋙ G) ⥤ StructuredArrow S G :=
Comma.preRight _ F G
instance (S : D) (F : B ⥤ C) (G : C ⥤ D) [F.Faithful] : (pre S F G).Faithful :=
show (Comma.preRight _ _ _).Faithful from inferInstance
instance (S : D) (F : B ⥤ C) (G : C ⥤ D) [F.Full] : (pre S F G).Full :=
show (Comma.preRight _ _ _).Full from inferInstance
instance (S : D) (F : B ⥤ C) (G : C ⥤ D) [F.EssSurj] : (pre S F G).EssSurj :=
show (Comma.preRight _ _ _).EssSurj from inferInstance
/-- If `F` is an equivalence, then so is the functor `(S, F ⋙ G) ⥤ (S, G)`. -/
instance isEquivalence_pre (S : D) (F : B ⥤ C) (G : C ⥤ D) [F.IsEquivalence] :
(pre S F G).IsEquivalence :=
Comma.isEquivalence_preRight _ _ _
/-- The functor `(S, F) ⥤ (G(S), F ⋙ G)`. -/
@[simps]
def post (S : C) (F : B ⥤ C) (G : C ⥤ D) :
StructuredArrow S F ⥤ StructuredArrow (G.obj S) (F ⋙ G) where
obj X := StructuredArrow.mk (G.map X.hom)
map f := StructuredArrow.homMk f.right (by simp [Functor.comp_map, ← G.map_comp, ← f.w])
instance (S : C) (F : B ⥤ C) (G : C ⥤ D) : (post S F G).Faithful where
map_injective {_ _} _ _ h := by simpa [ext_iff] using h
instance (S : C) (F : B ⥤ C) (G : C ⥤ D) [G.Faithful] : (post S F G).Full where
map_surjective f := ⟨homMk f.right (G.map_injective (by simpa using f.w.symm)), by aesop_cat⟩
instance (S : C) (F : B ⥤ C) (G : C ⥤ D) [G.Full] : (post S F G).EssSurj where
mem_essImage h := ⟨mk (G.preimage h.hom), ⟨isoMk (Iso.refl _) (by simp)⟩⟩
/-- If `G` is fully faithful, then `post S F G : (S, F) ⥤ (G(S), F ⋙ G)` is an equivalence. -/
instance isEquivalence_post (S : C) (F : B ⥤ C) (G : C ⥤ D) [G.Full] [G.Faithful] :
(post S F G).IsEquivalence where
section
variable {L : D} {R : C ⥤ D} {L' : B} {R' : A ⥤ B} {F : C ⥤ A} {G : D ⥤ B}
(α : L' ⟶ G.obj L) (β : R ⋙ G ⟶ F ⋙ R')
/-- The functor `StructuredArrow L R ⥤ StructuredArrow L' R'` that is deduced from
a natural transformation `R ⋙ G ⟶ F ⋙ R'` and a morphism `L' ⟶ G.obj L.` -/
@[simps!]
def map₂ : StructuredArrow L R ⥤ StructuredArrow L' R' :=
Comma.map (F₁ := 𝟭 (Discrete PUnit)) (Discrete.natTrans (fun _ => α)) β
instance faithful_map₂ [F.Faithful] : (map₂ α β).Faithful := by
apply Comma.faithful_map
instance full_map₂ [G.Faithful] [F.Full] [IsIso α] [IsIso β] : (map₂ α β).Full := by
apply Comma.full_map
instance essSurj_map₂ [F.EssSurj] [G.Full] [IsIso α] [IsIso β] : (map₂ α β).EssSurj := by
apply Comma.essSurj_map
noncomputable instance isEquivalenceMap₂
[F.IsEquivalence] [G.Faithful] [G.Full] [IsIso α] [IsIso β] :
(map₂ α β).IsEquivalence := by
apply Comma.isEquivalenceMap
end
instance small_proj_preimage_of_locallySmall {𝒢 : Set C} [Small.{v₁} 𝒢] [LocallySmall.{v₁} D] :
Small.{v₁} ((proj S T).obj ⁻¹' 𝒢) := by
suffices (proj S T).obj ⁻¹' 𝒢 = Set.range fun f : ΣG : 𝒢, S ⟶ T.obj G => mk f.2 by
rw [this]
infer_instance
exact Set.ext fun X => ⟨fun h => ⟨⟨⟨_, h⟩, X.hom⟩, (eq_mk _).symm⟩, by aesop_cat⟩
/-- A structured arrow is called universal if it is initial. -/
abbrev IsUniversal (f : StructuredArrow S T) := IsInitial f
namespace IsUniversal
variable {f g : StructuredArrow S T}
theorem uniq (h : IsUniversal f) (η : f ⟶ g) : η = h.to g :=
h.hom_ext η (h.to g)
/-- The family of morphisms out of a universal arrow. -/
def desc (h : IsUniversal f) (g : StructuredArrow S T) : f.right ⟶ g.right :=
(h.to g).right
/-- Any structured arrow factors through a universal arrow. -/
@[reassoc (attr := simp)]
theorem fac (h : IsUniversal f) (g : StructuredArrow S T) :
f.hom ≫ T.map (h.desc g) = g.hom :=
Category.id_comp g.hom ▸ (h.to g).w.symm
theorem hom_desc (h : IsUniversal f) {c : C} (η : f.right ⟶ c) :
η = h.desc (mk <| f.hom ≫ T.map η) :=
let g := mk <| f.hom ≫ T.map η
congrArg CommaMorphism.right (h.hom_ext (homMk η rfl : f ⟶ g) (h.to g))
/-- Two morphisms out of a universal `T`-structured arrow are equal if their image under `T` are
equal after precomposing the universal arrow. -/
theorem hom_ext (h : IsUniversal f) {c : C} {η η' : f.right ⟶ c}
(w : f.hom ≫ T.map η = f.hom ≫ T.map η') : η = η' := by
rw [h.hom_desc η, h.hom_desc η', w]
theorem existsUnique (h : IsUniversal f) (g : StructuredArrow S T) :
∃! η : f.right ⟶ g.right, f.hom ≫ T.map η = g.hom :=
⟨h.desc g, h.fac g, fun f w ↦ h.hom_ext <| by simp [w]⟩
end IsUniversal
end StructuredArrow
/-- The category of `S`-costructured arrows with target `T : D` (here `S : C ⥤ D`),
has as its objects `D`-morphisms of the form `S Y ⟶ T`, for some `Y : C`,
and morphisms `C`-morphisms `Y ⟶ Y'` making the obvious triangle commute.
-/
-- We explicitly come from `PUnit.{1}` here to obtain the correct universe for morphisms of
-- costructured arrows.
-- @[nolint has_nonempty_instance] -- Porting note(#5171): linter not ported yet
def CostructuredArrow (S : C ⥤ D) (T : D) :=
Comma S (Functor.fromPUnit.{0} T)
instance (S : C ⥤ D) (T : D) : Category (CostructuredArrow S T) := commaCategory
namespace CostructuredArrow
/-- The obvious projection functor from costructured arrows. -/
@[simps!]
def proj (S : C ⥤ D) (T : D) : CostructuredArrow S T ⥤ C :=
Comma.fst _ _
variable {T T' T'' : D} {Y Y' Y'' : C} {S S' : C ⥤ D}
-- Porting note (#5229): this lemma was added because `Comma.hom_ext`
-- was not triggered automatically
@[ext]
lemma hom_ext {X Y : CostructuredArrow S T} (f g : X ⟶ Y) (h : f.left = g.left) : f = g :=
CommaMorphism.ext h (Subsingleton.elim _ _)
@[simp]
theorem hom_eq_iff {X Y : CostructuredArrow S T} (f g : X ⟶ Y) : f = g ↔ f.left = g.left :=
⟨fun h ↦ by rw [h], hom_ext _ _⟩
/-- Construct a costructured arrow from a morphism. -/
def mk (f : S.obj Y ⟶ T) : CostructuredArrow S T :=
⟨Y, ⟨⟨⟩⟩, f⟩
@[simp]
theorem mk_left (f : S.obj Y ⟶ T) : (mk f).left = Y :=
rfl
@[simp]
theorem mk_right (f : S.obj Y ⟶ T) : (mk f).right = ⟨⟨⟩⟩ :=
rfl
@[simp]
theorem mk_hom_eq_self (f : S.obj Y ⟶ T) : (mk f).hom = f :=
rfl
-- @[reassoc (attr := simp)] Porting note: simp can solve these
@[reassoc]
theorem w {A B : CostructuredArrow S T} (f : A ⟶ B) : S.map f.left ≫ B.hom = A.hom := by simp
@[simp]
theorem comp_left {X Y Z : CostructuredArrow S T} (f : X ⟶ Y) (g : Y ⟶ Z) :
(f ≫ g).left = f.left ≫ g.left := rfl
@[simp]
theorem id_left (X : CostructuredArrow S T) : (𝟙 X : X ⟶ X).left = 𝟙 X.left := rfl
@[simp]
theorem eqToHom_left {X Y : CostructuredArrow S T} (h : X = Y) :
(eqToHom h).left = eqToHom (by rw [h]) := by
subst h
simp only [eqToHom_refl, id_left]
@[simp]
theorem right_eq_id {X Y : CostructuredArrow S T} (f : X ⟶ Y) : f.right = 𝟙 _ := rfl
/-- To construct a morphism of costructured arrows,
we need a morphism of the objects underlying the source,
and to check that the triangle commutes.
-/
@[simps!]
def homMk {f f' : CostructuredArrow S T} (g : f.left ⟶ f'.left)
(w : S.map g ≫ f'.hom = f.hom := by aesop_cat) : f ⟶ f' where
left := g
right := 𝟙 _
/- Porting note: it appears the simp lemma is not getting generated but the linter
picks up on it. Either way simp can prove this -/
attribute [-simp, nolint simpNF] homMk_right_down_down
theorem homMk_surjective {f f' : CostructuredArrow S T} (φ : f ⟶ f') :
∃ (ψ : f.left ⟶ f'.left) (hψ : S.map ψ ≫ f'.hom = f.hom),
φ = CostructuredArrow.homMk ψ hψ :=
⟨φ.left, CostructuredArrow.w φ, rfl⟩
/-- Given a costructured arrow `S(Y) ⟶ X`, and an arrow `Y' ⟶ Y'`, we can construct a morphism of
costructured arrows given by `(S(Y) ⟶ X) ⟶ (S(Y') ⟶ S(Y) ⟶ X)`. -/
@[simps]
def homMk' (f : CostructuredArrow S T) (g : Y' ⟶ f.left) : mk (S.map g ≫ f.hom) ⟶ f where
left := g
right := 𝟙 _
lemma homMk'_id (f : CostructuredArrow S T) : homMk' f (𝟙 f.left) = eqToHom (by aesop_cat) := by
ext
simp [eqToHom_left]
lemma homMk'_mk_id (f : S.obj Y ⟶ T) : homMk' (mk f) (𝟙 Y) = eqToHom (by aesop_cat) :=
homMk'_id _
lemma homMk'_comp (f : CostructuredArrow S T) (g : Y' ⟶ f.left) (g' : Y'' ⟶ Y') :
homMk' f (g' ≫ g) = eqToHom (by simp) ≫ homMk' (mk (S.map g ≫ f.hom)) g' ≫ homMk' f g := by
ext
simp [eqToHom_left]
lemma homMk'_mk_comp (f : S.obj Y ⟶ T) (g : Y' ⟶ Y) (g' : Y'' ⟶ Y') :
homMk' (mk f) (g' ≫ g) = eqToHom (by simp) ≫ homMk' (mk (S.map g ≫ f)) g' ≫ homMk' (mk f) g :=
homMk'_comp _ _ _
/-- Variant of `homMk'` where both objects are applications of `mk`. -/
@[simps]
def mkPrecomp (f : S.obj Y ⟶ T) (g : Y' ⟶ Y) : mk (S.map g ≫ f) ⟶ mk f where
left := g
right := 𝟙 _
lemma mkPrecomp_id (f : S.obj Y ⟶ T) : mkPrecomp f (𝟙 Y) = eqToHom (by aesop_cat) := by aesop_cat
lemma mkPrecomp_comp (f : S.obj Y ⟶ T) (g : Y' ⟶ Y) (g' : Y'' ⟶ Y') :
mkPrecomp f (g' ≫ g) = eqToHom (by simp) ≫ mkPrecomp (S.map g ≫ f) g' ≫ mkPrecomp f g := by
aesop_cat
/-- To construct an isomorphism of costructured arrows,
we need an isomorphism of the objects underlying the source,
and to check that the triangle commutes.
-/
@[simps!]
def isoMk {f f' : CostructuredArrow S T} (g : f.left ≅ f'.left)
(w : S.map g.hom ≫ f'.hom = f.hom := by aesop_cat) : f ≅ f' :=
Comma.isoMk g (eqToIso (by ext)) (by simpa using w)
/- Porting note: it appears the simp lemma is not getting generated but the linter
picks up on it. Either way simp solves these. -/
attribute [-simp, nolint simpNF] isoMk_hom_right_down_down isoMk_inv_right_down_down
theorem ext {A B : CostructuredArrow S T} (f g : A ⟶ B) (h : f.left = g.left) : f = g :=
CommaMorphism.ext h (Subsingleton.elim _ _)
theorem ext_iff {A B : CostructuredArrow S T} (f g : A ⟶ B) : f = g ↔ f.left = g.left :=
⟨fun h => h ▸ rfl, ext f g⟩
instance proj_faithful : (proj S T).Faithful where map_injective {_ _} := ext
theorem mono_of_mono_left {A B : CostructuredArrow S T} (f : A ⟶ B) [h : Mono f.left] : Mono f :=
(proj S T).mono_of_mono_map h
/-- The converse of this is true with additional assumptions, see `epi_iff_epi_left`. -/
theorem epi_of_epi_left {A B : CostructuredArrow S T} (f : A ⟶ B) [h : Epi f.left] : Epi f :=
(proj S T).epi_of_epi_map h
instance mono_homMk {A B : CostructuredArrow S T} (f : A.left ⟶ B.left) (w) [h : Mono f] :
Mono (homMk f w) :=
(proj S T).mono_of_mono_map h
instance epi_homMk {A B : CostructuredArrow S T} (f : A.left ⟶ B.left) (w) [h : Epi f] :
Epi (homMk f w) :=
(proj S T).epi_of_epi_map h
/-- Eta rule for costructured arrows. Prefer `CostructuredArrow.eta` for rewriting, as equality of
objects tends to cause problems. -/
theorem eq_mk (f : CostructuredArrow S T) : f = mk f.hom :=
rfl
/-- Eta rule for costructured arrows. -/
@[simps!]
def eta (f : CostructuredArrow S T) : f ≅ mk f.hom :=
isoMk (Iso.refl _)
/- Porting note: it appears the simp lemma is not getting generated but the linter
picks up on it. Either way simp solves these. -/
attribute [-simp, nolint simpNF] eta_hom_right_down_down eta_inv_right_down_down
lemma mk_surjective (f : CostructuredArrow S T) :
∃ (Y : C) (g : S.obj Y ⟶ T), f = mk g :=
⟨_, _, eq_mk f⟩
/-- A morphism between target objects `T ⟶ T'`
covariantly induces a functor between costructured arrows,
`CostructuredArrow S T ⥤ CostructuredArrow S T'`.
Ideally this would be described as a 2-functor from `D`
(promoted to a 2-category with equations as 2-morphisms)
to `Cat`.
-/
@[simps!]
def map (f : T ⟶ T') : CostructuredArrow S T ⥤ CostructuredArrow S T' :=
Comma.mapRight _ ((Functor.const _).map f)
@[simp]
theorem map_mk {f : S.obj Y ⟶ T} (g : T ⟶ T') : (map g).obj (mk f) = mk (f ≫ g) :=
rfl
@[simp]
theorem map_id {f : CostructuredArrow S T} : (map (𝟙 T)).obj f = f := by
rw [eq_mk f]
simp
@[simp]
theorem map_comp {f : T ⟶ T'} {f' : T' ⟶ T''} {h : CostructuredArrow S T} :
(map (f ≫ f')).obj h = (map f').obj ((map f).obj h) := by
rw [eq_mk h]
simp
/-- An isomorphism `T ≅ T'` induces an equivalence
`CostructuredArrow S T ≌ CostructuredArrow S T'`. -/
@[simp]
def mapIso (i : T ≅ T') : CostructuredArrow S T ≌ CostructuredArrow S T' :=
Comma.mapRightIso _ ((Functor.const _).mapIso i)
/-- A natural isomorphism `S ≅ S'` induces an equivalence
`CostrucutredArrow S T ≌ CostructuredArrow S' T`. -/
@[simp]
def mapNatIso (i : S ≅ S') : CostructuredArrow S T ≌ CostructuredArrow S' T :=
Comma.mapLeftIso _ i
instance proj_reflectsIsomorphisms : (proj S T).ReflectsIsomorphisms where
reflects {Y Z} f t :=
⟨⟨CostructuredArrow.homMk
(inv ((proj S T).map f))
(by rw [Functor.map_inv, IsIso.inv_comp_eq]; simp),
by constructor <;> ext <;> dsimp at t ⊢ <;> simp⟩⟩
open CategoryTheory.Limits
/-- The identity costructured arrow is terminal. -/
noncomputable def mkIdTerminal [S.Full] [S.Faithful] : IsTerminal (mk (𝟙 (S.obj Y))) where
lift c := homMk (S.preimage c.pt.hom)
uniq := by
rintro c m -
ext
apply S.map_injective
simpa only [homMk_left, S.map_preimage, ← w m] using (Category.comp_id _).symm
variable {A : Type u₃} [Category.{v₃} A] {B : Type u₄} [Category.{v₄} B]
/-- The functor `(F ⋙ G, S) ⥤ (G, S)`. -/
@[simps!]
def pre (F : B ⥤ C) (G : C ⥤ D) (S : D) : CostructuredArrow (F ⋙ G) S ⥤ CostructuredArrow G S :=
Comma.preLeft F G _
instance (F : B ⥤ C) (G : C ⥤ D) (S : D) [F.Faithful] : (pre F G S).Faithful :=
show (Comma.preLeft _ _ _).Faithful from inferInstance
instance (F : B ⥤ C) (G : C ⥤ D) (S : D) [F.Full] : (pre F G S).Full :=
show (Comma.preLeft _ _ _).Full from inferInstance
instance (F : B ⥤ C) (G : C ⥤ D) (S : D) [F.EssSurj] : (pre F G S).EssSurj :=
show (Comma.preLeft _ _ _).EssSurj from inferInstance
/-- If `F` is an equivalence, then so is the functor `(F ⋙ G, S) ⥤ (G, S)`. -/
instance isEquivalence_pre (F : B ⥤ C) (G : C ⥤ D) (S : D) [F.IsEquivalence] :
(pre F G S).IsEquivalence :=
Comma.isEquivalence_preLeft _ _ _
/-- The functor `(F, S) ⥤ (F ⋙ G, G(S))`. -/
@[simps]
def post (F : B ⥤ C) (G : C ⥤ D) (S : C) :
CostructuredArrow F S ⥤ CostructuredArrow (F ⋙ G) (G.obj S) where
obj X := CostructuredArrow.mk (G.map X.hom)
map f := CostructuredArrow.homMk f.left (by simp [Functor.comp_map, ← G.map_comp, ← f.w])
instance (F : B ⥤ C) (G : C ⥤ D) (S : C) : (post F G S).Faithful where
map_injective {_ _} _ _ h := by simpa [ext_iff] using h
instance (F : B ⥤ C) (G : C ⥤ D) (S : C) [G.Faithful] : (post F G S).Full where
map_surjective f := ⟨homMk f.left (G.map_injective (by simpa using f.w)), by aesop_cat⟩
instance (F : B ⥤ C) (G : C ⥤ D) (S : C) [G.Full] : (post F G S).EssSurj where
mem_essImage h := ⟨mk (G.preimage h.hom), ⟨isoMk (Iso.refl _) (by simp)⟩⟩
/-- If `G` is fully faithful, then `post F G S : (F, S) ⥤ (F ⋙ G, G(S))` is an equivalence. -/
instance isEquivalence_post (S : C) (F : B ⥤ C) (G : C ⥤ D) [G.Full] [G.Faithful] :
(post F G S).IsEquivalence where
section
variable {U : A ⥤ B} {V : B} {F : C ⥤ A} {G : D ⥤ B}
(α : F ⋙ U ⟶ S ⋙ G) (β : G.obj T ⟶ V)
/-- The functor `CostructuredArrow S T ⥤ CostructuredArrow U V` that is deduced from
a natural transformation `F ⋙ U ⟶ S ⋙ G` and a morphism `G.obj T ⟶ V` -/
@[simps!]
def map₂ : CostructuredArrow S T ⥤ CostructuredArrow U V :=
Comma.map (F₂ := 𝟭 (Discrete PUnit)) α (Discrete.natTrans (fun _ => β))
instance faithful_map₂ [F.Faithful] : (map₂ α β).Faithful := by
apply Comma.faithful_map
instance full_map₂ [G.Faithful] [F.Full] [IsIso α] [IsIso β] : (map₂ α β).Full := by
apply Comma.full_map
instance essSurj_map₂ [F.EssSurj] [G.Full] [IsIso α] [IsIso β] : (map₂ α β).EssSurj := by
apply Comma.essSurj_map
noncomputable instance isEquivalenceMap₂
[F.IsEquivalence] [G.Faithful] [G.Full] [IsIso α] [IsIso β] :
(map₂ α β).IsEquivalence := by
apply Comma.isEquivalenceMap
end
instance small_proj_preimage_of_locallySmall {𝒢 : Set C} [Small.{v₁} 𝒢] [LocallySmall.{v₁} D] :
Small.{v₁} ((proj S T).obj ⁻¹' 𝒢) := by
suffices (proj S T).obj ⁻¹' 𝒢 = Set.range fun f : ΣG : 𝒢, S.obj G ⟶ T => mk f.2 by
rw [this]
infer_instance
exact Set.ext fun X => ⟨fun h => ⟨⟨⟨_, h⟩, X.hom⟩, (eq_mk _).symm⟩, by aesop_cat⟩
/-- A costructured arrow is called universal if it is terminal. -/
abbrev IsUniversal (f : CostructuredArrow S T) := IsTerminal f
namespace IsUniversal
variable {f g : CostructuredArrow S T}
theorem uniq (h : IsUniversal f) (η : g ⟶ f) : η = h.from g :=
h.hom_ext η (h.from g)
/-- The family of morphisms into a universal arrow. -/
def lift (h : IsUniversal f) (g : CostructuredArrow S T) : g.left ⟶ f.left :=
(h.from g).left
/-- Any costructured arrow factors through a universal arrow. -/
@[reassoc (attr := simp)]
theorem fac (h : IsUniversal f) (g : CostructuredArrow S T) :
S.map (h.lift g) ≫ f.hom = g.hom :=
Category.comp_id g.hom ▸ (h.from g).w
theorem hom_desc (h : IsUniversal f) {c : C} (η : c ⟶ f.left) :
η = h.lift (mk <| S.map η ≫ f.hom) :=
let g := mk <| S.map η ≫ f.hom
congrArg CommaMorphism.left (h.hom_ext (homMk η rfl : g ⟶ f) (h.from g))
/-- Two morphisms into a universal `S`-costructured arrow are equal if their image under `S` are
equal after postcomposing the universal arrow. -/
theorem hom_ext (h : IsUniversal f) {c : C} {η η' : c ⟶ f.left}
(w : S.map η ≫ f.hom = S.map η' ≫ f.hom) : η = η' := by
rw [h.hom_desc η, h.hom_desc η', w]
theorem existsUnique (h : IsUniversal f) (g : CostructuredArrow S T) :
∃! η : g.left ⟶ f.left, S.map η ≫ f.hom = g.hom :=
⟨h.lift g, h.fac g, fun f w ↦ h.hom_ext <| by simp [w]⟩
end IsUniversal
end CostructuredArrow
namespace Functor
variable {E : Type u₃} [Category.{v₃} E]
/-- Given `X : D` and `F : C ⥤ D`, to upgrade a functor `G : E ⥤ C` to a functor
`E ⥤ StructuredArrow X F`, it suffices to provide maps `X ⟶ F.obj (G.obj Y)` for all `Y` making
the obvious triangles involving all `F.map (G.map g)` commute.
This is of course the same as providing a cone over `F ⋙ G` with cone point `X`, see
`Functor.toStructuredArrowIsoToStructuredArrow`. -/
@[simps]
def toStructuredArrow (G : E ⥤ C) (X : D) (F : C ⥤ D) (f : (Y : E) → X ⟶ F.obj (G.obj Y))
(h : ∀ {Y Z : E} (g : Y ⟶ Z), f Y ≫ F.map (G.map g) = f Z) : E ⥤ StructuredArrow X F where
obj Y := StructuredArrow.mk (f Y)
map g := StructuredArrow.homMk (G.map g) (h g)
/-- Upgrading a functor `E ⥤ C` to a functor `E ⥤ StructuredArrow X F` and composing with the
forgetful functor `StructuredArrow X F ⥤ C` recovers the original functor. -/
def toStructuredArrowCompProj (G : E ⥤ C) (X : D) (F : C ⥤ D) (f : (Y : E) → X ⟶ F.obj (G.obj Y))
(h : ∀ {Y Z : E} (g : Y ⟶ Z), f Y ≫ F.map (G.map g) = f Z) :
G.toStructuredArrow X F f h ⋙ StructuredArrow.proj _ _ ≅ G :=
Iso.refl _
@[simp]
lemma toStructuredArrow_comp_proj (G : E ⥤ C) (X : D) (F : C ⥤ D)
(f : (Y : E) → X ⟶ F.obj (G.obj Y)) (h : ∀ {Y Z : E} (g : Y ⟶ Z), f Y ≫ F.map (G.map g) = f Z) :
G.toStructuredArrow X F f h ⋙ StructuredArrow.proj _ _ = G :=
rfl
/-- Given `F : C ⥤ D` and `X : D`, to upgrade a functor `G : E ⥤ C` to a functor
`E ⥤ CostructuredArrow F X`, it suffices to provide maps `F.obj (G.obj Y) ⟶ X` for all `Y`
making the obvious triangles involving all `F.map (G.map g)` commute.
This is of course the same as providing a cocone over `F ⋙ G` with cocone point `X`, see
`Functor.toCostructuredArrowIsoToCostructuredArrow`. -/
@[simps]
def toCostructuredArrow (G : E ⥤ C) (F : C ⥤ D) (X : D) (f : (Y : E) → F.obj (G.obj Y) ⟶ X)
(h : ∀ {Y Z : E} (g : Y ⟶ Z), F.map (G.map g) ≫ f Z = f Y) : E ⥤ CostructuredArrow F X where
obj Y := CostructuredArrow.mk (f Y)
map g := CostructuredArrow.homMk (G.map g) (h g)
/-- Upgrading a functor `E ⥤ C` to a functor `E ⥤ CostructuredArrow F X` and composing with the
forgetful functor `CostructuredArrow F X ⥤ C` recovers the original functor. -/
def toCostructuredArrowCompProj (G : E ⥤ C) (F : C ⥤ D) (X : D)
(f : (Y : E) → F.obj (G.obj Y) ⟶ X) (h : ∀ {Y Z : E} (g : Y ⟶ Z), F.map (G.map g) ≫ f Z = f Y) :
G.toCostructuredArrow F X f h ⋙ CostructuredArrow.proj _ _ ≅ G :=
Iso.refl _
@[simp]
lemma toCostructuredArrow_comp_proj (G : E ⥤ C) (F : C ⥤ D) (X : D)
(f : (Y : E) → F.obj (G.obj Y) ⟶ X) (h : ∀ {Y Z : E} (g : Y ⟶ Z), F.map (G.map g) ≫ f Z = f Y) :
G.toCostructuredArrow F X f h ⋙ CostructuredArrow.proj _ _ = G :=
rfl
end Functor
open Opposite
namespace StructuredArrow
/-- For a functor `F : C ⥤ D` and an object `d : D`, we obtain a contravariant functor from the
category of structured arrows `d ⟶ F.obj c` to the category of costructured arrows
`F.op.obj c ⟶ (op d)`.
-/
@[simps]
def toCostructuredArrow (F : C ⥤ D) (d : D) :
(StructuredArrow d F)ᵒᵖ ⥤ CostructuredArrow F.op (op d) where
obj X := @CostructuredArrow.mk _ _ _ _ _ (op X.unop.right) F.op X.unop.hom.op
map f :=
CostructuredArrow.homMk f.unop.right.op
(by
dsimp
rw [← op_comp, ← f.unop.w, Functor.const_obj_map]
erw [Category.id_comp])
/-- For a functor `F : C ⥤ D` and an object `d : D`, we obtain a contravariant functor from the
category of structured arrows `op d ⟶ F.op.obj c` to the category of costructured arrows
`F.obj c ⟶ d`.
-/
@[simps]
def toCostructuredArrow' (F : C ⥤ D) (d : D) :
(StructuredArrow (op d) F.op)ᵒᵖ ⥤ CostructuredArrow F d where
obj X := @CostructuredArrow.mk _ _ _ _ _ (unop X.unop.right) F X.unop.hom.unop
map f :=
CostructuredArrow.homMk f.unop.right.unop
(by
dsimp
rw [← Quiver.Hom.unop_op (F.map (Quiver.Hom.unop f.unop.right)), ← unop_comp, ← F.op_map, ←
f.unop.w, Functor.const_obj_map]
erw [Category.id_comp])
end StructuredArrow
namespace CostructuredArrow
/-- For a functor `F : C ⥤ D` and an object `d : D`, we obtain a contravariant functor from the
category of costructured arrows `F.obj c ⟶ d` to the category of structured arrows
`op d ⟶ F.op.obj c`.
-/
@[simps]
def toStructuredArrow (F : C ⥤ D) (d : D) :
(CostructuredArrow F d)ᵒᵖ ⥤ StructuredArrow (op d) F.op where
obj X := @StructuredArrow.mk _ _ _ _ _ (op X.unop.left) F.op X.unop.hom.op
map f :=
StructuredArrow.homMk f.unop.left.op
(by
dsimp
rw [← op_comp, f.unop.w, Functor.const_obj_map]
erw [Category.comp_id])
/-- For a functor `F : C ⥤ D` and an object `d : D`, we obtain a contravariant functor from the
category of costructured arrows `F.op.obj c ⟶ op d` to the category of structured arrows
`d ⟶ F.obj c`.
-/
@[simps]
def toStructuredArrow' (F : C ⥤ D) (d : D) :
(CostructuredArrow F.op (op d))ᵒᵖ ⥤ StructuredArrow d F where
obj X := @StructuredArrow.mk _ _ _ _ _ (unop X.unop.left) F X.unop.hom.unop
map f :=
StructuredArrow.homMk f.unop.left.unop
(by
dsimp
rw [← Quiver.Hom.unop_op (F.map f.unop.left.unop), ← unop_comp, ← F.op_map, f.unop.w,
Functor.const_obj_map]
erw [Category.comp_id])
end CostructuredArrow
/-- For a functor `F : C ⥤ D` and an object `d : D`, the category of structured arrows `d ⟶ F.obj c`
is contravariantly equivalent to the category of costructured arrows `F.op.obj c ⟶ op d`.
-/
def structuredArrowOpEquivalence (F : C ⥤ D) (d : D) :
(StructuredArrow d F)ᵒᵖ ≌ CostructuredArrow F.op (op d) :=
Equivalence.mk (StructuredArrow.toCostructuredArrow F d)
(CostructuredArrow.toStructuredArrow' F d).rightOp
(NatIso.ofComponents
(fun X => (StructuredArrow.isoMk (Iso.refl _)).op)
fun {X Y} f => Quiver.Hom.unop_inj <| by
apply CommaMorphism.ext <;>
dsimp [StructuredArrow.isoMk, Comma.isoMk,StructuredArrow.homMk]; simp)
(NatIso.ofComponents
(fun X => CostructuredArrow.isoMk (Iso.refl _))
fun {X Y} f => by
apply CommaMorphism.ext <;>
dsimp [CostructuredArrow.isoMk, Comma.isoMk, CostructuredArrow.homMk]; simp)
/-- For a functor `F : C ⥤ D` and an object `d : D`, the category of costructured arrows
`F.obj c ⟶ d` is contravariantly equivalent to the category of structured arrows
`op d ⟶ F.op.obj c`.
-/
def costructuredArrowOpEquivalence (F : C ⥤ D) (d : D) :
(CostructuredArrow F d)ᵒᵖ ≌ StructuredArrow (op d) F.op :=
Equivalence.mk (CostructuredArrow.toStructuredArrow F d)
(StructuredArrow.toCostructuredArrow' F d).rightOp
(NatIso.ofComponents
(fun X => (CostructuredArrow.isoMk (Iso.refl _)).op)
fun {X Y} f => Quiver.Hom.unop_inj <| by
apply CommaMorphism.ext <;>
dsimp [CostructuredArrow.isoMk, CostructuredArrow.homMk, Comma.isoMk]; simp)
(NatIso.ofComponents
(fun X => StructuredArrow.isoMk (Iso.refl _))
fun {X Y} f => by
apply CommaMorphism.ext <;>
dsimp [StructuredArrow.isoMk, StructuredArrow.homMk, Comma.isoMk]; simp)
end CategoryTheory
|
CategoryTheory\ConcreteCategory\Basic.lean | /-
Copyright (c) 2018 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Scott Morrison, Johannes Hölzl, Reid Barton, Sean Leather, Yury Kudryashov
-/
import Mathlib.CategoryTheory.Types
/-!
# Concrete categories
A concrete category is a category `C` with a fixed faithful functor
`forget : C ⥤ Type*`. We define concrete categories using `class ConcreteCategory`.
In particular, we impose no restrictions on the
carrier type `C`, so `Type` is a concrete category with the identity
forgetful functor.
Each concrete category `C` comes with a canonical faithful functor
`forget C : C ⥤ Type*`. We say that a concrete category `C` admits a
*forgetful functor* to a concrete category `D`, if it has a functor
`forget₂ C D : C ⥤ D` such that `(forget₂ C D) ⋙ (forget D) = forget C`,
see `class HasForget₂`. Due to `Faithful.div_comp`, it suffices
to verify that `forget₂.obj` and `forget₂.map` agree with the equality
above; then `forget₂` will satisfy the functor laws automatically, see
`HasForget₂.mk'`.
Two classes helping construct concrete categories in the two most
common cases are provided in the files `BundledHom` and
`UnbundledHom`, see their documentation for details.
## References
See [Ahrens and Lumsdaine, *Displayed Categories*][ahrens2017] for
related work.
-/
universe w w' v v' v'' u u' u''
assert_not_exists CategoryTheory.CommSq
assert_not_exists CategoryTheory.Adjunction
namespace CategoryTheory
/-- A concrete category is a category `C` with a fixed faithful functor `Forget : C ⥤ Type`.
Note that `ConcreteCategory` potentially depends on three independent universe levels,
* the universe level `w` appearing in `Forget : C ⥤ Type w`
* the universe level `v` of the morphisms (i.e. we have a `Category.{v} C`)
* the universe level `u` of the objects (i.e `C : Type u`)
They are specified that order, to avoid unnecessary universe annotations.
-/
class ConcreteCategory (C : Type u) [Category.{v} C] where
/-- We have a functor to Type -/
protected forget : C ⥤ Type w
/-- That functor is faithful -/
[forget_faithful : forget.Faithful]
attribute [reducible] ConcreteCategory.forget
attribute [instance] ConcreteCategory.forget_faithful
/-- The forgetful functor from a concrete category to `Type u`. -/
abbrev forget (C : Type u) [Category.{v} C] [ConcreteCategory.{w} C] : C ⥤ Type w :=
ConcreteCategory.forget
-- this is reducible because we want `forget (Type u)` to unfold to `𝟭 _`
@[instance] abbrev ConcreteCategory.types : ConcreteCategory.{u, u, u+1} (Type u) where
forget := 𝟭 _
/-- Provide a coercion to `Type u` for a concrete category. This is not marked as an instance
as it could potentially apply to every type, and so is too expensive in typeclass search.
You can use it on particular examples as:
```
instance : HasCoeToSort X := ConcreteCategory.hasCoeToSort X
```
-/
def ConcreteCategory.hasCoeToSort (C : Type u) [Category.{v} C] [ConcreteCategory.{w} C] :
CoeSort C (Type w) where
coe := fun X => (forget C).obj X
section
attribute [local instance] ConcreteCategory.hasCoeToSort
variable {C : Type u} [Category.{v} C] [ConcreteCategory.{w} C]
-- Porting note: forget_obj_eq_coe has become a syntactic tautology.
/-- In any concrete category, `(forget C).map` is injective. -/
abbrev ConcreteCategory.instFunLike {X Y : C} : FunLike (X ⟶ Y) X Y where
coe f := (forget C).map f
coe_injective' _ _ h := (forget C).map_injective h
attribute [local instance] ConcreteCategory.instFunLike
/-- In any concrete category, we can test equality of morphisms by pointwise evaluations. -/
@[ext low] -- Porting note: lowered priority
theorem ConcreteCategory.hom_ext {X Y : C} (f g : X ⟶ Y) (w : ∀ x : X, f x = g x) : f = g := by
apply (forget C).map_injective
dsimp [forget]
funext x
exact w x
theorem forget_map_eq_coe {X Y : C} (f : X ⟶ Y) : (forget C).map f = f := rfl
/-- Analogue of `congr_fun h x`,
when `h : f = g` is an equality between morphisms in a concrete category.
-/
theorem congr_hom {X Y : C} {f g : X ⟶ Y} (h : f = g) (x : X) : f x = g x :=
congrFun (congrArg (fun k : X ⟶ Y => (k : X → Y)) h) x
theorem coe_id {X : C} : (𝟙 X : X → X) = id :=
(forget _).map_id X
theorem coe_comp {X Y Z : C} (f : X ⟶ Y) (g : Y ⟶ Z) : (f ≫ g : X → Z) = g ∘ f :=
(forget _).map_comp f g
@[simp] theorem id_apply {X : C} (x : X) : (𝟙 X : X → X) x = x :=
congr_fun ((forget _).map_id X) x
@[simp] theorem comp_apply {X Y Z : C} (f : X ⟶ Y) (g : Y ⟶ Z) (x : X) : (f ≫ g) x = g (f x) :=
congr_fun ((forget _).map_comp _ _) x
theorem comp_apply' {X Y Z : C} (f : X ⟶ Y) (g : Y ⟶ Z) (x : X) :
(forget C).map (f ≫ g) x = (forget C).map g ((forget C).map f x) := comp_apply f g x
theorem ConcreteCategory.congr_hom {X Y : C} {f g : X ⟶ Y} (h : f = g) (x : X) : f x = g x :=
congr_fun (congr_arg (fun f : X ⟶ Y => (f : X → Y)) h) x
theorem ConcreteCategory.congr_arg {X Y : C} (f : X ⟶ Y) {x x' : X} (h : x = x') : f x = f x' :=
congrArg (f : X → Y) h
@[simp]
theorem ConcreteCategory.hasCoeToFun_Type {X Y : Type u} (f : X ⟶ Y) : CoeFun.coe f = f := rfl
end
/-- `HasForget₂ C D`, where `C` and `D` are both concrete categories, provides a functor
`forget₂ C D : C ⥤ D` and a proof that `forget₂ ⋙ (forget D) = forget C`.
-/
class HasForget₂ (C : Type u) (D : Type u') [Category.{v} C] [ConcreteCategory.{w} C]
[Category.{v'} D] [ConcreteCategory.{w} D] where
/-- A functor from `C` to `D` -/
forget₂ : C ⥤ D
/-- It covers the `ConcreteCategory.forget` for `C` and `D` -/
forget_comp : forget₂ ⋙ forget D = forget C := by aesop
/-- The forgetful functor `C ⥤ D` between concrete categories for which we have an instance
`HasForget₂ C`. -/
abbrev forget₂ (C : Type u) (D : Type u') [Category.{v} C] [ConcreteCategory.{w} C]
[Category.{v'} D] [ConcreteCategory.{w} D] [HasForget₂ C D] : C ⥤ D :=
HasForget₂.forget₂
attribute [local instance] ConcreteCategory.instFunLike ConcreteCategory.hasCoeToSort
lemma forget₂_comp_apply {C : Type u} {D : Type u'} [Category.{v} C] [ConcreteCategory.{w} C]
[Category.{v'} D] [ConcreteCategory.{w} D] [HasForget₂ C D] {X Y Z : C}
(f : X ⟶ Y) (g : Y ⟶ Z) (x : (forget₂ C D).obj X) :
((forget₂ C D).map (f ≫ g) x) =
(forget₂ C D).map g ((forget₂ C D).map f x) := by
rw [Functor.map_comp, comp_apply]
instance forget₂_faithful (C : Type u) (D : Type u') [Category.{v} C] [ConcreteCategory.{w} C]
[Category.{v'} D] [ConcreteCategory.{w} D] [HasForget₂ C D] : (forget₂ C D).Faithful :=
HasForget₂.forget_comp.faithful_of_comp
instance InducedCategory.concreteCategory {C : Type u} {D : Type u'}
[Category.{v'} D] [ConcreteCategory.{w} D] (f : C → D) :
ConcreteCategory (InducedCategory D f) where
forget := inducedFunctor f ⋙ forget D
instance InducedCategory.hasForget₂ {C : Type u} {D : Type u'} [Category.{v} D]
[ConcreteCategory.{w} D] (f : C → D) : HasForget₂ (InducedCategory D f) D where
forget₂ := inducedFunctor f
forget_comp := rfl
instance FullSubcategory.concreteCategory {C : Type u} [Category.{v} C] [ConcreteCategory.{w} C]
(Z : C → Prop) : ConcreteCategory (FullSubcategory Z) where
forget := fullSubcategoryInclusion Z ⋙ forget C
instance FullSubcategory.hasForget₂ {C : Type u} [Category.{v} C] [ConcreteCategory.{w} C]
(Z : C → Prop) : HasForget₂ (FullSubcategory Z) C where
forget₂ := fullSubcategoryInclusion Z
forget_comp := rfl
/-- In order to construct a “partially forgetting” functor, we do not need to verify functor laws;
it suffices to ensure that compositions agree with `forget₂ C D ⋙ forget D = forget C`.
-/
def HasForget₂.mk' {C : Type u} {D : Type u'} [Category.{v} C] [ConcreteCategory.{w} C]
[Category.{v'} D] [ConcreteCategory.{w} D]
(obj : C → D) (h_obj : ∀ X, (forget D).obj (obj X) = (forget C).obj X)
(map : ∀ {X Y}, (X ⟶ Y) → (obj X ⟶ obj Y))
(h_map : ∀ {X Y} {f : X ⟶ Y}, HEq ((forget D).map (map f)) ((forget C).map f)) :
HasForget₂ C D where
forget₂ := Functor.Faithful.div _ _ _ @h_obj _ @h_map
forget_comp := by apply Functor.Faithful.div_comp
/-- Composition of `HasForget₂` instances. -/
@[reducible]
def HasForget₂.trans (C : Type u) [Category.{v} C] [ConcreteCategory.{w} C]
(D : Type u') [Category.{v'} D] [ConcreteCategory.{w} D]
(E : Type u'') [Category.{v''} E] [ConcreteCategory.{w} E]
[HasForget₂ C D] [HasForget₂ D E] : HasForget₂ C E where
forget₂ := CategoryTheory.forget₂ C D ⋙ CategoryTheory.forget₂ D E
forget_comp := by
show (CategoryTheory.forget₂ _ D) ⋙ (CategoryTheory.forget₂ D E ⋙ CategoryTheory.forget E) = _
simp only [HasForget₂.forget_comp]
/-- Every forgetful functor factors through the identity functor. This is not a global instance as
it is prone to creating type class resolution loops. -/
def hasForgetToType (C : Type u) [Category.{v} C] [ConcreteCategory.{w} C] :
HasForget₂ C (Type w) where
forget₂ := forget C
forget_comp := Functor.comp_id _
@[simp]
lemma NatTrans.naturality_apply {C D : Type*} [Category C] [Category D] [ConcreteCategory D]
{F G : C ⥤ D} (φ : F ⟶ G) {X Y : C} (f : X ⟶ Y) (x : F.obj X) :
φ.app Y (F.map f x) = G.map f (φ.app X x) := by
simpa only [Functor.map_comp] using congr_fun ((forget D).congr_map (φ.naturality f)) x
end CategoryTheory
|
CategoryTheory\ConcreteCategory\Bundled.lean | /-
Copyright (c) 2018 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Scott Morrison, Johannes Hölzl, Reid Barton, Sean Leather
-/
import Batteries.Tactic.Lint.Misc
/-!
# Bundled types
`Bundled c` provides a uniform structure for bundling a type equipped with a type class.
We provide `Category` instances for these in
`Mathlib/CategoryTheory/ConcreteCategory/UnbundledHom.lean`
(for categories with unbundled homs, e.g. topological spaces)
and in `Mathlib/CategoryTheory/ConcreteCategory/BundledHom.lean`
(for categories with bundled homs, e.g. monoids).
-/
universe u v
namespace CategoryTheory
variable {c d : Type u → Type v} {α : Type u}
/-- `Bundled` is a type bundled with a type class instance for that type. Only
the type class is exposed as a parameter. -/
structure Bundled (c : Type u → Type v) : Type max (u + 1) v where
/-- The underlying type of the bundled type -/
α : Type u
/-- The corresponding instance of the bundled type class -/
str : c α := by infer_instance
namespace Bundled
attribute [coe] α
-- This is needed so that we can ask for an instance of `c α` below even though Lean doesn't know
-- that `c α` is a typeclass.
set_option checkBinderAnnotations false in
-- Usually explicit instances will provide their own version of this, e.g. `MonCat.of` and
-- `TopCat.of`.
/-- A generic function for lifting a type equipped with an instance to a bundled object. -/
def of {c : Type u → Type v} (α : Type u) [str : c α] : Bundled c :=
⟨α, str⟩
instance coeSort : CoeSort (Bundled c) (Type u) :=
⟨Bundled.α⟩
theorem coe_mk (α) (str) : (@Bundled.mk c α str : Type u) = α :=
rfl
/-
`Bundled.map` is reducible so that, if we define a category
def Ring : Type (u+1) := induced_category SemiRing (bundled.map @ring.to_semiring)
instance search is able to "see" that a morphism R ⟶ S in Ring is really
a (semi)ring homomorphism from R.α to S.α, and not merely from
`(Bundled.map @Ring.toSemiring R).α` to `(Bundled.map @Ring.toSemiring S).α`.
TODO: Once at least one use of this has been ported, check if this still needs to be reducible in
Lean 4.
-/
/-- Map over the bundled structure -/
def map (f : ∀ {α}, c α → d α) (b : Bundled c) : Bundled d :=
⟨b, f b.str⟩
end Bundled
end CategoryTheory
|
CategoryTheory\ConcreteCategory\BundledHom.lean | /-
Copyright (c) 2019 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Scott Morrison, Yury Kudryashov
-/
import Mathlib.CategoryTheory.ConcreteCategory.Basic
import Mathlib.CategoryTheory.ConcreteCategory.Bundled
/-!
# Category instances for algebraic structures that use bundled homs.
Many algebraic structures in Lean initially used unbundled homs (e.g. a bare function between types,
along with an `IsMonoidHom` typeclass), but the general trend is towards using bundled homs.
This file provides a basic infrastructure to define concrete categories using bundled homs, and
define forgetful functors between them.
-/
universe u
namespace CategoryTheory
variable {c : Type u → Type u} (hom : ∀ ⦃α β : Type u⦄ (_ : c α) (_ : c β), Type u)
/-- Class for bundled homs. Note that the arguments order follows that of lemmas for `MonoidHom`.
This way we can use `⟨@MonoidHom.toFun, @MonoidHom.id ...⟩` in an instance. -/
structure BundledHom where
/-- the underlying map of a bundled morphism -/
toFun : ∀ {α β : Type u} (Iα : c α) (Iβ : c β), hom Iα Iβ → α → β
/-- the identity as a bundled morphism -/
id : ∀ {α : Type u} (I : c α), hom I I
/-- composition of bundled morphisms -/
comp : ∀ {α β γ : Type u} (Iα : c α) (Iβ : c β) (Iγ : c γ), hom Iβ Iγ → hom Iα Iβ → hom Iα Iγ
/-- a bundled morphism is determined by the underlying map -/
hom_ext : ∀ {α β : Type u} (Iα : c α) (Iβ : c β), Function.Injective (toFun Iα Iβ) := by
aesop_cat
/-- compatibility with identities -/
id_toFun : ∀ {α : Type u} (I : c α), toFun I I (id I) = _root_.id := by aesop_cat
/-- compatibility with the composition -/
comp_toFun :
∀ {α β γ : Type u} (Iα : c α) (Iβ : c β) (Iγ : c γ) (f : hom Iα Iβ) (g : hom Iβ Iγ),
toFun Iα Iγ (comp Iα Iβ Iγ g f) = toFun Iβ Iγ g ∘ toFun Iα Iβ f := by
aesop_cat
attribute [class] BundledHom
attribute [simp] BundledHom.id_toFun BundledHom.comp_toFun
namespace BundledHom
variable [𝒞 : BundledHom hom]
set_option synthInstance.checkSynthOrder false in
/-- Every `@BundledHom c _` defines a category with objects in `Bundled c`.
This instance generates the type-class problem `BundledHom ?m`.
Currently that is not a problem, as there are almost no instances of `BundledHom`.
-/
instance category : Category (Bundled c) where
Hom := fun X Y => hom X.str Y.str
id := fun X => BundledHom.id 𝒞 (α := X) X.str
comp := fun {X Y Z} f g => BundledHom.comp 𝒞 (α := X) (β := Y) (γ := Z) X.str Y.str Z.str g f
comp_id _ := by apply 𝒞.hom_ext; simp
assoc _ _ _ := by apply 𝒞.hom_ext; aesop_cat
id_comp _ := by apply 𝒞.hom_ext; simp
/-- A category given by `BundledHom` is a concrete category. -/
instance concreteCategory : ConcreteCategory.{u} (Bundled c) where
forget :=
{ obj := fun X => X
map := @fun X Y f => 𝒞.toFun X.str Y.str f
map_id := fun X => 𝒞.id_toFun X.str
map_comp := fun f g => by dsimp; erw [𝒞.comp_toFun];rfl }
forget_faithful := { map_injective := by (intros; apply 𝒞.hom_ext) }
variable {hom}
attribute [local instance] ConcreteCategory.instFunLike
/-- A version of `HasForget₂.mk'` for categories defined using `@BundledHom`. -/
def mkHasForget₂ {d : Type u → Type u} {hom_d : ∀ ⦃α β : Type u⦄ (_ : d α) (_ : d β), Type u}
[BundledHom hom_d] (obj : ∀ ⦃α⦄, c α → d α)
(map : ∀ {X Y : Bundled c}, (X ⟶ Y) → (Bundled.map @obj X ⟶ (Bundled.map @obj Y)))
(h_map : ∀ {X Y : Bundled c} (f : X ⟶ Y), ⇑(map f) = ⇑f) :
HasForget₂ (Bundled c) (Bundled d) :=
HasForget₂.mk' (Bundled.map @obj) (fun _ => rfl) map (by
intros X Y f
rw [heq_eq_eq, forget_map_eq_coe, forget_map_eq_coe, h_map f])
variable {d : Type u → Type u}
variable (hom)
section
/-- The `hom` corresponding to first forgetting along `F`, then taking the `hom` associated to `c`.
For typical usage, see the construction of `CommMonCat` from `MonCat`.
-/
abbrev MapHom (F : ∀ {α}, d α → c α) : ∀ ⦃α β : Type u⦄ (_ : d α) (_ : d β), Type u :=
fun _ _ iα iβ => hom (F iα) (F iβ)
end
/-- Construct the `CategoryTheory.BundledHom` induced by a map between type classes.
This is useful for building categories such as `CommMonCat` from `MonCat`.
-/
def map (F : ∀ {α}, d α → c α) : BundledHom (MapHom hom @F) where
toFun α β {iα} {iβ} f := 𝒞.toFun (F iα) (F iβ) f
id α {iα} := 𝒞.id (F iα)
comp := @fun α β γ iα iβ iγ f g => 𝒞.comp (F iα) (F iβ) (F iγ) f g
hom_ext := @fun α β iα iβ f g h => 𝒞.hom_ext (F iα) (F iβ) h
section
/-- We use the empty `ParentProjection` class to label functions like `CommMonoid.toMonoid`,
which we would like to use to automatically construct `BundledHom` instances from.
Once we've set up `MonCat` as the category of bundled monoids,
this allows us to set up `CommMonCat` by defining an instance
```instance : ParentProjection (CommMonoid.toMonoid) := ⟨⟩```
-/
class ParentProjection (F : ∀ {α}, d α → c α) : Prop
end
-- The `ParentProjection` typeclass is just a marker, so won't be used.
@[nolint unusedArguments]
instance bundledHomOfParentProjection (F : ∀ {α}, d α → c α) [ParentProjection @F] :
BundledHom (MapHom hom @F) :=
map hom @F
instance forget₂ (F : ∀ {α}, d α → c α) [ParentProjection @F] :
HasForget₂ (Bundled d) (Bundled c) where
forget₂ :=
{ obj := fun X => ⟨X, F X.2⟩
map := @fun X Y f => f }
instance forget₂_full (F : ∀ {α}, d α → c α) [ParentProjection @F] :
Functor.Full (CategoryTheory.forget₂ (Bundled d) (Bundled c)) where
map_surjective f := ⟨f, rfl⟩
end BundledHom
end CategoryTheory
|
CategoryTheory\ConcreteCategory\Elementwise.lean | /-
Copyright (c) 2022 Andrew Yang. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Andrew Yang
-/
import Mathlib.Tactic.CategoryTheory.Elementwise
import Mathlib.CategoryTheory.Limits.HasLimits
import Mathlib.CategoryTheory.Limits.Shapes.Kernels
import Mathlib.CategoryTheory.ConcreteCategory.Basic
/-!
In this file we provide various simp lemmas in its elementwise form via `Tactic.Elementwise`.
-/
open CategoryTheory CategoryTheory.Limits
set_option linter.existingAttributeWarning false in
attribute [elementwise (attr := simp)] Cone.w limit.lift_π limit.w
colimit.ι_desc colimit.w kernel.lift_ι cokernel.π_desc kernel.condition cokernel.condition
attribute [elementwise] Cocone.w
|
CategoryTheory\ConcreteCategory\EpiMono.lean | /-
Copyright (c) 2024 Joël Riou. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Joël Riou
-/
import Mathlib.CategoryTheory.Limits.Shapes.Images
import Mathlib.CategoryTheory.MorphismProperty.Concrete
import Mathlib.CategoryTheory.Types
import Mathlib.CategoryTheory.Limits.Preserves.Basic
import Mathlib.CategoryTheory.Limits.Constructions.EpiMono
/-!
# Epi and mono in concrete categories
In this file, we relate epimorphisms and monomorphisms in a concrete category `C`
to surjective and injective morphisms, and we show that if `C` has
strong epi mono factorizations and is such that `forget C` preserves
both epi and mono, then any morphism in `C` can be factored in a
functorial manner as a composition of a surjective morphism followed
by an injective morphism.
-/
universe w v v' u u'
namespace CategoryTheory
variable {C : Type u} [Category.{v} C] [ConcreteCategory.{w} C]
open Limits MorphismProperty
namespace ConcreteCategory
section
attribute [local instance] ConcreteCategory.instFunLike in
/-- In any concrete category, injective morphisms are monomorphisms. -/
theorem mono_of_injective {X Y : C} (f : X ⟶ Y) (i : Function.Injective f) :
Mono f :=
(forget C).mono_of_mono_map ((mono_iff_injective f).2 i)
instance forget₂_preservesMonomorphisms (C : Type u) (D : Type u')
[Category.{v} C] [ConcreteCategory.{w} C] [Category.{v'} D] [ConcreteCategory.{w} D]
[HasForget₂ C D] [(forget C).PreservesMonomorphisms] :
(forget₂ C D).PreservesMonomorphisms :=
have : (forget₂ C D ⋙ forget D).PreservesMonomorphisms := by
simp only [HasForget₂.forget_comp]
infer_instance
Functor.preservesMonomorphisms_of_preserves_of_reflects _ (forget D)
instance forget₂_preservesEpimorphisms (C : Type u) (D : Type u')
[Category.{v} C] [ConcreteCategory.{w} C] [Category.{v'} D] [ConcreteCategory.{w} D]
[HasForget₂ C D] [(forget C).PreservesEpimorphisms] :
(forget₂ C D).PreservesEpimorphisms :=
have : (forget₂ C D ⋙ forget D).PreservesEpimorphisms := by
simp only [HasForget₂.forget_comp]
infer_instance
Functor.preservesEpimorphisms_of_preserves_of_reflects _ (forget D)
variable (C)
lemma surjective_le_epimorphisms :
MorphismProperty.surjective C ≤ epimorphisms C :=
fun _ _ _ hf => (forget C).epi_of_epi_map ((epi_iff_surjective _).2 hf)
lemma injective_le_monomorphisms :
MorphismProperty.injective C ≤ monomorphisms C :=
fun _ _ _ hf => (forget C).mono_of_mono_map ((mono_iff_injective _).2 hf)
lemma surjective_eq_epimorphisms_iff :
MorphismProperty.surjective C = epimorphisms C ↔ (forget C).PreservesEpimorphisms := by
constructor
· intro h
constructor
rintro _ _ f (hf : epimorphisms C f)
rw [epi_iff_surjective]
rw [← h] at hf
exact hf
· intro
apply le_antisymm (surjective_le_epimorphisms C)
intro _ _ f hf
have : Epi f := hf
change Function.Surjective ((forget C).map f)
rw [← epi_iff_surjective]
infer_instance
lemma injective_eq_monomorphisms_iff :
MorphismProperty.injective C = monomorphisms C ↔ (forget C).PreservesMonomorphisms := by
constructor
· intro h
constructor
rintro _ _ f (hf : monomorphisms C f)
rw [mono_iff_injective]
rw [← h] at hf
exact hf
· intro
apply le_antisymm (injective_le_monomorphisms C)
intro _ _ f hf
have : Mono f := hf
change Function.Injective ((forget C).map f)
rw [← mono_iff_injective]
infer_instance
lemma injective_eq_monomorphisms [(forget C).PreservesMonomorphisms] :
MorphismProperty.injective C = monomorphisms C := by
rw [injective_eq_monomorphisms_iff]
infer_instance
lemma surjective_eq_epimorphisms [(forget C).PreservesEpimorphisms] :
MorphismProperty.surjective C = epimorphisms C := by
rw [surjective_eq_epimorphisms_iff]
infer_instance
variable [HasStrongEpiMonoFactorisations C] [(forget C).PreservesMonomorphisms]
[(forget C).PreservesEpimorphisms]
/-- A concrete category with strong epi mono factorizations and such that
the forget functor preserves mono and epi admits functorial surjective/injective
factorizations. -/
noncomputable def functorialSurjectiveInjectiveFactorizationData :
FunctorialSurjectiveInjectiveFactorizationData C :=
(functorialEpiMonoFactorizationData C).ofLE
(by rw [surjective_eq_epimorphisms])
(by rw [injective_eq_monomorphisms])
instance (priority := 100) : HasFunctorialSurjectiveInjectiveFactorization C where
nonempty_functorialFactorizationData :=
⟨functorialSurjectiveInjectiveFactorizationData C⟩
end
section
open CategoryTheory.Limits
attribute [local instance] ConcreteCategory.hasCoeToSort
attribute [local instance] ConcreteCategory.instFunLike
theorem injective_of_mono_of_preservesPullback {X Y : C} (f : X ⟶ Y) [Mono f]
[PreservesLimitsOfShape WalkingCospan (forget C)] : Function.Injective f :=
(mono_iff_injective ((forget C).map f)).mp inferInstance
theorem mono_iff_injective_of_preservesPullback {X Y : C} (f : X ⟶ Y)
[PreservesLimitsOfShape WalkingCospan (forget C)] : Mono f ↔ Function.Injective f :=
((forget C).mono_map_iff_mono _).symm.trans (mono_iff_injective _)
/-- In any concrete category, surjective morphisms are epimorphisms. -/
theorem epi_of_surjective {X Y : C} (f : X ⟶ Y) (s : Function.Surjective f) :
Epi f :=
(forget C).epi_of_epi_map ((epi_iff_surjective f).2 s)
theorem surjective_of_epi_of_preservesPushout {X Y : C} (f : X ⟶ Y) [Epi f]
[PreservesColimitsOfShape WalkingSpan (forget C)] : Function.Surjective f :=
(epi_iff_surjective ((forget C).map f)).mp inferInstance
theorem epi_iff_surjective_of_preservesPushout {X Y : C} (f : X ⟶ Y)
[PreservesColimitsOfShape WalkingSpan (forget C)] : Epi f ↔ Function.Surjective f :=
((forget C).epi_map_iff_epi _).symm.trans (epi_iff_surjective _)
theorem bijective_of_isIso {X Y : C} (f : X ⟶ Y) [IsIso f] :
Function.Bijective ((forget C).map f) := by
rw [← isIso_iff_bijective]
infer_instance
/-- If the forgetful functor of a concrete category reflects isomorphisms, being an isomorphism
is equivalent to being bijective. -/
theorem isIso_iff_bijective [(forget C).ReflectsIsomorphisms]
{X Y : C} (f : X ⟶ Y) : IsIso f ↔ Function.Bijective ((forget C).map f) := by
rw [← CategoryTheory.isIso_iff_bijective]
exact ⟨fun _ ↦ inferInstance, fun _ ↦ isIso_of_reflects_iso f (forget C)⟩
end
end ConcreteCategory
end CategoryTheory
|
CategoryTheory\ConcreteCategory\ReflectsIso.lean | /-
Copyright (c) 2020 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Scott Morrison
-/
import Mathlib.CategoryTheory.ConcreteCategory.Basic
import Mathlib.CategoryTheory.Functor.ReflectsIso
/-!
A `forget₂ C D` forgetful functor between concrete categories `C` and `D`
whose forgetful functors both reflect isomorphisms, itself reflects isomorphisms.
-/
universe u
namespace CategoryTheory
instance : (forget (Type u)).ReflectsIsomorphisms where reflects _ _ _ {i} := i
variable (C : Type (u + 1)) [Category C] [ConcreteCategory.{u} C]
variable (D : Type (u + 1)) [Category D] [ConcreteCategory.{u} D]
-- This should not be an instance, as it causes a typeclass loop
-- with `CategoryTheory.hasForgetToType`.
/-- A `forget₂ C D` forgetful functor between concrete categories `C` and `D`
where `forget C` reflects isomorphisms, itself reflects isomorphisms.
-/
theorem reflectsIsomorphisms_forget₂ [HasForget₂ C D] [(forget C).ReflectsIsomorphisms] :
(forget₂ C D).ReflectsIsomorphisms :=
{ reflects := fun X Y f {i} => by
haveI i' : IsIso ((forget D).map ((forget₂ C D).map f)) := Functor.map_isIso (forget D) _
haveI : IsIso ((forget C).map f) := by
have := @HasForget₂.forget_comp C D
rwa [← this]
apply isIso_of_reflects_iso f (forget C) }
end CategoryTheory
|
CategoryTheory\ConcreteCategory\UnbundledHom.lean | /-
Copyright (c) 2019 Yury Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudryashov
-/
import Mathlib.CategoryTheory.ConcreteCategory.BundledHom
/-!
# Category instances for structures that use unbundled homs
This file provides basic infrastructure to define concrete
categories using unbundled homs (see `class UnbundledHom`), and
define forgetful functors between them (see
`UnbundledHom.mkHasForget₂`).
-/
universe v u
namespace CategoryTheory
/-- A class for unbundled homs used to define a category. `hom` must
take two types `α`, `β` and instances of the corresponding structures,
and return a predicate on `α → β`. -/
class UnbundledHom {c : Type u → Type u} (hom : ∀ ⦃α β⦄, c α → c β → (α → β) → Prop) : Prop where
hom_id : ∀ {α} (ia : c α), hom ia ia id
hom_comp : ∀ {α β γ} {Iα : c α} {Iβ : c β} {Iγ : c γ} {g : β → γ} {f : α → β} (_ : hom Iβ Iγ g)
(_ : hom Iα Iβ f), hom Iα Iγ (g ∘ f)
namespace UnbundledHom
variable (c : Type u → Type u) (hom : ∀ ⦃α β⦄, c α → c β → (α → β) → Prop) [𝒞 : UnbundledHom hom]
instance bundledHom : BundledHom fun α β (Iα : c α) (Iβ : c β) => Subtype (hom Iα Iβ) where
toFun _ _ := Subtype.val
id Iα := ⟨id, hom_id Iα⟩
id_toFun _ := rfl
comp _ _ _ g f := ⟨g.1 ∘ f.1, hom_comp g.2 f.2⟩
comp_toFun _ _ _ _ _ := rfl
hom_ext _ _ _ _ := Subtype.eq
section HasForget₂
variable {c hom} {c' : Type u → Type u} {hom' : ∀ ⦃α β⦄, c' α → c' β → (α → β) → Prop}
[𝒞' : UnbundledHom hom']
variable (obj : ∀ ⦃α⦄, c α → c' α)
(map : ∀ ⦃α β Iα Iβ f⦄, @hom α β Iα Iβ f → hom' (obj Iα) (obj Iβ) f)
/-- A custom constructor for forgetful functor
between concrete categories defined using `UnbundledHom`. -/
def mkHasForget₂ : HasForget₂ (Bundled c) (Bundled c') :=
BundledHom.mkHasForget₂ obj (fun f => ⟨f.val, map f.property⟩) fun _ => rfl
end HasForget₂
end UnbundledHom
end CategoryTheory
|
CategoryTheory\Dialectica\Basic.lean | /-
Copyright (c) 2024 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro
-/
import Mathlib.CategoryTheory.Subobject.Basic
import Mathlib.CategoryTheory.Limits.Shapes.FiniteProducts
/-!
# Dialectica category
We define the category `Dial` of the Dialectica interpretation, after [dialectica1989].
## Background
Dialectica categories are important models of linear type theory. They satisfy most of the
distinctions that linear logic was meant to introduce and many models do not satisfy, like the
independence of constants. Many linear type theories are being used at the
moment--[nLab] describes some of them: for quantum systems, for effects in programming, for linear
dependent types. In particular, dialectica categories are connected to polynomial functors, being a
slightly more sophisticated version of polynomial types, as discussed, for instance, in Moss and
von Glehn's [*Dialectica models of type theory*]. As such they are related to the polynomial
constructions being [developed][Poly] by Awodey, Riehl, and Hazratpour. For the non-dependent
version developed here several applications are known to Petri Nets, small cardinals
in Set Theory, state in imperative programming, and others, see [Dialectica Categories].
## References
* [Valeria de Paiva, The Dialectica Categories.][dialectica1989]
([pdf](https://www.cl.cam.ac.uk/techreports/UCAM-CL-TR-213.pdf))
[nLab]: https://ncatlab.org/nlab/show/linear+type+theory
[*Dialectica models of type theory*]: https://arxiv.org/abs/2105.00283
[Poly]: https://github.com/sinhp/Poly
[Dialectica Categories]: https://github.com/vcvpaiva/DialecticaCategories
-/
noncomputable section
namespace CategoryTheory
open Limits
universe v u
variable {C : Type u} [Category.{v} C] [HasFiniteProducts C] [HasPullbacks C]
variable (C) in
/-- The Dialectica category. An object of the category is a triple `⟨U, X, α ⊆ U × X⟩`,
and a morphism from `⟨U, X, α⟩` to `⟨V, Y, β⟩` is a pair `(f : U ⟶ V, F : U ⨯ Y ⟶ X)` such that
`{(u,y) | α(u, F(u, y))} ⊆ {(u,y) | β(f(u), y)}`. The subset `α` is actually encoded as an element
of `Subobject (U × X)`, and the above inequality is expressed using pullbacks. -/
structure Dial where
/-- The source object -/
src : C
/-- The target object -/
tgt : C
/-- A subobject of `src ⨯ tgt`, interpreted as a relation -/
rel : Subobject (src ⨯ tgt)
namespace Dial
local notation "π₁" => prod.fst
local notation "π₂" => prod.snd
local notation "π(" a ", " b ")" => prod.lift a b
/-- A morphism in the `Dial C` category from `⟨U, X, α⟩` to `⟨V, Y, β⟩` is a pair
`(f : U ⟶ V, F : U ⨯ Y ⟶ X)` such that `{(u,y) | α(u, F(u, y))} ≤ {(u,y) | β(f(u), y)}`. -/
@[ext] structure Hom (X Y : Dial C) where
/-- Maps the sources -/
f : X.src ⟶ Y.src
/-- Maps the targets (contravariantly) -/
F : X.src ⨯ Y.tgt ⟶ X.tgt
/-- This says `{(u, y) | α(u, F(u, y))} ⊆ {(u, y) | β(f(u), y)}` using subobject pullbacks -/
le :
(Subobject.pullback π(π₁, F)).obj X.rel ≤
(Subobject.pullback (prod.map f (𝟙 _))).obj Y.rel
theorem comp_le_lemma {X Y Z : Dial C} (F : Dial.Hom X Y) (G : Dial.Hom Y Z) :
(Subobject.pullback π(π₁, π(π₁, prod.map F.f (𝟙 _) ≫ G.F) ≫ F.F)).obj X.rel ≤
(Subobject.pullback (prod.map (F.f ≫ G.f) (𝟙 Z.tgt))).obj Z.rel := by
refine
le_trans ?_ <| ((Subobject.pullback (π(π₁, prod.map F.f (𝟙 _) ≫ G.F))).monotone F.le).trans <|
le_trans ?_ <| ((Subobject.pullback (prod.map F.f (𝟙 Z.tgt))).monotone G.le).trans ?_
<;> simp [← Subobject.pullback_comp]
@[simps]
instance : Category (Dial C) where
Hom := Dial.Hom
id X := {
f := 𝟙 _
F := π₂
le := by simp
}
comp {X Y Z} (F G : Dial.Hom ..) := {
f := F.f ≫ G.f
F := π(π₁, prod.map F.f (𝟙 _) ≫ G.F) ≫ F.F
le := comp_le_lemma F G
}
id_comp f := by simp; rfl
comp_id f := by simp; rfl
assoc f g h := by
simp only [Category.assoc, Hom.mk.injEq, true_and]
rw [← Category.assoc, ← Category.assoc]; congr 1
ext <;> simp
@[ext] theorem hom_ext {X Y : Dial C} {x y : X ⟶ Y} (hf : x.f = y.f) (hF : x.F = y.F) : x = y :=
Hom.ext hf hF
/--
An isomorphism in `Dial C` can be induced by isomorphisms on the source and target,
which respect the respective relations on `X` and `Y`.
-/
@[simps] def isoMk {X Y : Dial C} (e₁ : X.src ≅ Y.src) (e₂ : X.tgt ≅ Y.tgt)
(eq : X.rel = (Subobject.pullback (prod.map e₁.hom e₂.hom)).obj Y.rel) : X ≅ Y where
hom := {
f := e₁.hom
F := π₂ ≫ e₂.inv
le := by rw [eq, ← Subobject.pullback_comp]; apply le_of_eq; congr; ext <;> simp
}
inv := {
f := e₁.inv
F := π₂ ≫ e₂.hom
le := by rw [eq, ← Subobject.pullback_comp]; apply le_of_eq; congr; ext <;> simp
}
end Dial
end CategoryTheory
|
CategoryTheory\Dialectica\Monoidal.lean | /-
Copyright (c) 2024 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro
-/
import Mathlib.CategoryTheory.Subobject.Lattice
import Mathlib.CategoryTheory.Monoidal.Braided.Basic
import Mathlib.CategoryTheory.Dialectica.Basic
/-!
# The Dialectica category is symmetric monoidal
We show that the category `Dial` has a symmetric monoidal category structure.
-/
noncomputable section
namespace CategoryTheory
open MonoidalCategory Limits
universe v u
variable {C : Type u} [Category.{v} C] [HasFiniteProducts C] [HasPullbacks C]
namespace Dial
local notation "π₁" => prod.fst
local notation "π₂" => prod.snd
local notation "π(" a ", " b ")" => prod.lift a b
/-- The object `X ⊗ Y` in the `Dial C` category just tuples the left and right components. -/
@[simps] def tensorObj (X Y : Dial C) : Dial C where
src := X.src ⨯ Y.src
tgt := X.tgt ⨯ Y.tgt
rel :=
(Subobject.pullback (prod.map π₁ π₁)).obj X.rel ⊓
(Subobject.pullback (prod.map π₂ π₂)).obj Y.rel
/-- The functorial action of `X ⊗ Y` in `Dial C`. -/
@[simps] def tensorHom {X₁ X₂ Y₁ Y₂ : Dial C} (f : X₁ ⟶ X₂) (g : Y₁ ⟶ Y₂) :
tensorObj X₁ Y₁ ⟶ tensorObj X₂ Y₂ where
f := prod.map f.f g.f
F := π(prod.map π₁ π₁ ≫ f.F, prod.map π₂ π₂ ≫ g.F)
le := by
simp only [tensorObj, Subobject.inf_pullback]
apply inf_le_inf <;> rw [← Subobject.pullback_comp, ← Subobject.pullback_comp]
· have := (Subobject.pullback (prod.map π₁ π₁ :
(X₁.src ⨯ Y₁.src) ⨯ X₂.tgt ⨯ Y₂.tgt ⟶ _)).monotone (Hom.le f)
rw [← Subobject.pullback_comp, ← Subobject.pullback_comp] at this
convert this using 3 <;> simp
· have := (Subobject.pullback (prod.map π₂ π₂ :
(X₁.src ⨯ Y₁.src) ⨯ X₂.tgt ⨯ Y₂.tgt ⟶ _)).monotone (Hom.le g)
rw [← Subobject.pullback_comp, ← Subobject.pullback_comp] at this
convert this using 3 <;> simp
/-- The unit for the tensor `X ⊗ Y` in `Dial C`. -/
@[simps] def tensorUnit : Dial C := { src := ⊤_ _, tgt := ⊤_ _, rel := ⊤ }
/-- Left unit cancellation `1 ⊗ X ≅ X` in `Dial C`. -/
@[simps!] def leftUnitor (X : Dial C) : tensorObj tensorUnit X ≅ X :=
isoMk (prod.leftUnitor _) (prod.leftUnitor _) <| by simp [Subobject.pullback_top]
/-- Right unit cancellation `X ⊗ 1 ≅ X` in `Dial C`. -/
@[simps!] def rightUnitor (X : Dial C) : tensorObj X tensorUnit ≅ X :=
isoMk (prod.rightUnitor _) (prod.rightUnitor _) <| by simp [Subobject.pullback_top]
/-- The associator for tensor, `(X ⊗ Y) ⊗ Z ≅ X ⊗ (Y ⊗ Z)` in `Dial C`. -/
@[simps!]
def associator (X Y Z : Dial C) : tensorObj (tensorObj X Y) Z ≅ tensorObj X (tensorObj Y Z) :=
isoMk (prod.associator ..) (prod.associator ..) <| by
simp [Subobject.inf_pullback, ← Subobject.pullback_comp, inf_assoc]
@[simps!]
instance : MonoidalCategoryStruct (Dial C) where
tensorUnit := tensorUnit
tensorObj := tensorObj
whiskerLeft X _ _ f := tensorHom (𝟙 X) f
whiskerRight f Y := tensorHom f (𝟙 Y)
tensorHom := tensorHom
leftUnitor := leftUnitor
rightUnitor := rightUnitor
associator := associator
theorem tensor_id (X₁ X₂ : Dial C) : (𝟙 X₁ ⊗ 𝟙 X₂ : _ ⟶ _) = 𝟙 (X₁ ⊗ X₂ : Dial C) := by aesop_cat
theorem tensor_comp {X₁ Y₁ Z₁ X₂ Y₂ Z₂ : Dial C}
(f₁ : X₁ ⟶ Y₁) (f₂ : X₂ ⟶ Y₂) (g₁ : Y₁ ⟶ Z₁) (g₂ : Y₂ ⟶ Z₂) :
tensorHom (f₁ ≫ g₁) (f₂ ≫ g₂) = tensorHom f₁ f₂ ≫ tensorHom g₁ g₂ := by
ext <;> simp; ext <;> simp <;> (rw [← Category.assoc]; congr 1; simp)
theorem associator_naturality {X₁ X₂ X₃ Y₁ Y₂ Y₃ : Dial C}
(f₁ : X₁ ⟶ Y₁) (f₂ : X₂ ⟶ Y₂) (f₃ : X₃ ⟶ Y₃) :
tensorHom (tensorHom f₁ f₂) f₃ ≫ (associator Y₁ Y₂ Y₃).hom =
(associator X₁ X₂ X₃).hom ≫ tensorHom f₁ (tensorHom f₂ f₃) := by aesop_cat
theorem leftUnitor_naturality {X Y : Dial C} (f : X ⟶ Y) :
(𝟙 (𝟙_ (Dial C)) ⊗ f) ≫ (λ_ Y).hom = (λ_ X).hom ≫ f := by
ext <;> simp; ext; simp; congr 1; ext <;> simp
theorem rightUnitor_naturality {X Y : Dial C} (f : X ⟶ Y) :
(f ⊗ 𝟙 (𝟙_ (Dial C))) ≫ (ρ_ Y).hom = (ρ_ X).hom ≫ f := by
ext <;> simp; ext; simp; congr 1; ext <;> simp
theorem pentagon (W X Y Z : Dial C) :
(tensorHom (associator W X Y).hom (𝟙 Z)) ≫ (associator W (tensorObj X Y) Z).hom ≫
(tensorHom (𝟙 W) (associator X Y Z).hom) =
(associator (tensorObj W X) Y Z).hom ≫ (associator W X (tensorObj Y Z)).hom := by
ext <;> simp
theorem triangle (X Y : Dial C) :
(associator X (𝟙_ (Dial C)) Y).hom ≫ tensorHom (𝟙 X) (leftUnitor Y).hom =
tensorHom (rightUnitor X).hom (𝟙 Y) := by aesop_cat
instance : MonoidalCategory (Dial C) :=
.ofTensorHom
(tensor_id := tensor_id)
(tensor_comp := tensor_comp)
(associator_naturality := associator_naturality)
(leftUnitor_naturality := leftUnitor_naturality)
(rightUnitor_naturality := rightUnitor_naturality)
(pentagon := pentagon)
(triangle := triangle)
/-- The braiding isomorphism `X ⊗ Y ≅ Y ⊗ X` in `Dial C`. -/
@[simps!] def braiding (X Y : Dial C) : tensorObj X Y ≅ tensorObj Y X :=
isoMk (prod.braiding ..) (prod.braiding ..) <| by
simp [Subobject.inf_pullback, ← Subobject.pullback_comp, inf_comm]
theorem symmetry (X Y : Dial C) :
(braiding X Y).hom ≫ (braiding Y X).hom = 𝟙 (tensorObj X Y) := by aesop_cat
theorem braiding_naturality_right (X : Dial C) {Y Z : Dial C} (f : Y ⟶ Z) :
tensorHom (𝟙 X) f ≫ (braiding X Z).hom = (braiding X Y).hom ≫ tensorHom f (𝟙 X) := by aesop_cat
theorem braiding_naturality_left {X Y : Dial C} (f : X ⟶ Y) (Z : Dial C) :
tensorHom f (𝟙 Z) ≫ (braiding Y Z).hom = (braiding X Z).hom ≫ tensorHom (𝟙 Z) f := by aesop_cat
theorem hexagon_forward (X Y Z : Dial C) :
(associator X Y Z).hom ≫ (braiding X (Y ⊗ Z)).hom ≫ (associator Y Z X).hom =
tensorHom (braiding X Y).hom (𝟙 Z) ≫ (associator Y X Z).hom ≫
tensorHom (𝟙 Y) (braiding X Z).hom := by aesop_cat
theorem hexagon_reverse (X Y Z : Dial C) :
(associator X Y Z).inv ≫ (braiding (X ⊗ Y) Z).hom ≫ (associator Z X Y).inv =
tensorHom (𝟙 X) (braiding Y Z).hom ≫ (associator X Z Y).inv ≫
tensorHom (braiding X Z).hom (𝟙 Y) := by aesop_cat
instance : SymmetricCategory (Dial C) where
braiding := braiding
braiding_naturality_right := braiding_naturality_right
braiding_naturality_left := braiding_naturality_left
hexagon_forward := hexagon_forward
hexagon_reverse := hexagon_reverse
symmetry := symmetry
end Dial
end CategoryTheory
|
CategoryTheory\EffectiveEpi\Basic.lean | /-
Copyright (c) 2023 Adam Topaz. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Adam Topaz
-/
import Mathlib.CategoryTheory.Limits.Shapes.Products
/-!
# Effective epimorphisms
We define the notion of effective epimorphism and effective epimorphic family of morphisms.
A morphism is an *effective epi* if it is a joint coequalizer of all pairs of
morphisms which it coequalizes.
A family of morphisms with fixed target is *effective epimorphic* if it is initial among families
of morphisms with its sources and a general fixed target, coequalizing every pair of morphisms it
coequalizes (here, the pair of morphisms coequalized can have different targets among the sources
of the family).
We have defined the notion of effective epi for morphisms and families of morphisms in such a
way that avoids requiring the existence of pullbacks. However, if the relevant pullbacks exist
then these definitions are equivalent, see the file
`CategoryTheory/EffectiveEpi/RegularEpi.lean`
See [nlab: *Effective Epimorphism*](https://ncatlab.org/nlab/show/effective+epimorphism) and
[Stacks 00WP](https://stacks.math.columbia.edu/tag/00WP) for the standard definitions. Note that
our notion of `EffectiveEpi` is often called "strict epi" in the literature.
## References
- [Elephant]: *Sketches of an Elephant*, P. T. Johnstone: C2.1, Example 2.1.12.
- [nlab: *Effective Epimorphism*](https://ncatlab.org/nlab/show/effective+epimorphism) and
- [Stacks 00WP](https://stacks.math.columbia.edu/tag/00WP) for the standard definitions.
-/
namespace CategoryTheory
open Limits
variable {C : Type*} [Category C]
/--
This structure encodes the data required for a morphism to be an effective epimorphism.
-/
structure EffectiveEpiStruct {X Y : C} (f : Y ⟶ X) where
/--
For every `W` with a morphism `e : Y ⟶ W` that coequalizes every pair of morphisms
`g₁ g₂ : Z ⟶ Y` which `f` coequalizes, `desc e h` is a morphism `X ⟶ W`...
-/
desc : ∀ {W : C} (e : Y ⟶ W),
(∀ {Z : C} (g₁ g₂ : Z ⟶ Y), g₁ ≫ f = g₂ ≫ f → g₁ ≫ e = g₂ ≫ e) → (X ⟶ W)
/-- ...factorizing `e` through `f`... -/
fac : ∀ {W : C} (e : Y ⟶ W)
(h : ∀ {Z : C} (g₁ g₂ : Z ⟶ Y), g₁ ≫ f = g₂ ≫ f → g₁ ≫ e = g₂ ≫ e),
f ≫ desc e h = e
/-- ...and as such, unique. -/
uniq : ∀ {W : C} (e : Y ⟶ W)
(h : ∀ {Z : C} (g₁ g₂ : Z ⟶ Y), g₁ ≫ f = g₂ ≫ f → g₁ ≫ e = g₂ ≫ e)
(m : X ⟶ W), f ≫ m = e → m = desc e h
/--
A morphism `f : Y ⟶ X` is an effective epimorphism provided that `f` exhibits `X` as a colimit
of the diagram of all "relations" `R ⇉ Y`.
If `f` has a kernel pair, then this is equivalent to showing that the corresponding cofork is
a colimit.
-/
class EffectiveEpi {X Y : C} (f : Y ⟶ X) : Prop where
/-- `f` is an effective epimorphism if there exists an `EffectiveEpiStruct` for `f`. -/
effectiveEpi : Nonempty (EffectiveEpiStruct f)
/-- Some chosen `EffectiveEpiStruct` associated to an effective epi. -/
noncomputable
def EffectiveEpi.getStruct {X Y : C} (f : Y ⟶ X) [EffectiveEpi f] : EffectiveEpiStruct f :=
EffectiveEpi.effectiveEpi.some
/-- Descend along an effective epi. -/
noncomputable
def EffectiveEpi.desc {X Y W : C} (f : Y ⟶ X) [EffectiveEpi f]
(e : Y ⟶ W) (h : ∀ {Z : C} (g₁ g₂ : Z ⟶ Y), g₁ ≫ f = g₂ ≫ f → g₁ ≫ e = g₂ ≫ e) :
X ⟶ W := (EffectiveEpi.getStruct f).desc e h
@[reassoc (attr := simp)]
lemma EffectiveEpi.fac {X Y W : C} (f : Y ⟶ X) [EffectiveEpi f]
(e : Y ⟶ W) (h : ∀ {Z : C} (g₁ g₂ : Z ⟶ Y), g₁ ≫ f = g₂ ≫ f → g₁ ≫ e = g₂ ≫ e) :
f ≫ EffectiveEpi.desc f e h = e :=
(EffectiveEpi.getStruct f).fac e h
lemma EffectiveEpi.uniq {X Y W : C} (f : Y ⟶ X) [EffectiveEpi f]
(e : Y ⟶ W) (h : ∀ {Z : C} (g₁ g₂ : Z ⟶ Y), g₁ ≫ f = g₂ ≫ f → g₁ ≫ e = g₂ ≫ e)
(m : X ⟶ W) (hm : f ≫ m = e) :
m = EffectiveEpi.desc f e h :=
(EffectiveEpi.getStruct f).uniq e h _ hm
instance epiOfEffectiveEpi {X Y : C} (f : Y ⟶ X) [EffectiveEpi f] : Epi f := by
constructor
intro W m₁ m₂ h
have : m₂ = EffectiveEpi.desc f (f ≫ m₂)
(fun {Z} g₁ g₂ h => by simp only [← Category.assoc, h]) := EffectiveEpi.uniq _ _ _ _ rfl
rw [this]
exact EffectiveEpi.uniq _ _ _ _ h
/--
This structure encodes the data required for a family of morphisms to be effective epimorphic.
-/
structure EffectiveEpiFamilyStruct {B : C} {α : Type*}
(X : α → C) (π : (a : α) → (X a ⟶ B)) where
/--
For every `W` with a family of morphisms `e a : Y a ⟶ W` that coequalizes every pair of morphisms
`g₁ : Z ⟶ Y a₁`, `g₂ : Z ⟶ Y a₂` which the family `π` coequalizes, `desc e h` is a morphism
`X ⟶ W`...
-/
desc : ∀ {W} (e : (a : α) → (X a ⟶ W)),
(∀ {Z : C} (a₁ a₂ : α) (g₁ : Z ⟶ X a₁) (g₂ : Z ⟶ X a₂),
g₁ ≫ π _ = g₂ ≫ π _ → g₁ ≫ e _ = g₂ ≫ e _) → (B ⟶ W)
/-- ...factorizing the components of `e` through the components of `π`... -/
fac : ∀ {W} (e : (a : α) → (X a ⟶ W))
(h : ∀ {Z : C} (a₁ a₂ : α) (g₁ : Z ⟶ X a₁) (g₂ : Z ⟶ X a₂),
g₁ ≫ π _ = g₂ ≫ π _ → g₁ ≫ e _ = g₂ ≫ e _)
(a : α), π a ≫ desc e h = e a
/-- ...and as such, unique. -/
uniq : ∀ {W} (e : (a : α) → (X a ⟶ W))
(h : ∀ {Z : C} (a₁ a₂ : α) (g₁ : Z ⟶ X a₁) (g₂ : Z ⟶ X a₂),
g₁ ≫ π _ = g₂ ≫ π _ → g₁ ≫ e _ = g₂ ≫ e _)
(m : B ⟶ W), (∀ (a : α), π a ≫ m = e a) → m = desc e h
/--
A family of morphisms `π a : X a ⟶ B` indexed by `α` is effective epimorphic
provided that the `π a` exhibit `B` as a colimit of the diagram of all "relations"
`R → X a₁`, `R ⟶ X a₂` for all `a₁ a₂ : α`.
-/
class EffectiveEpiFamily {B : C} {α : Type*} (X : α → C) (π : (a : α) → (X a ⟶ B)) : Prop where
/-- `π` is an effective epimorphic family if there exists an `EffectiveEpiFamilyStruct` for `π` -/
effectiveEpiFamily : Nonempty (EffectiveEpiFamilyStruct X π)
/-- Some chosen `EffectiveEpiFamilyStruct` associated to an effective epi family. -/
noncomputable
def EffectiveEpiFamily.getStruct {B : C} {α : Type*} (X : α → C) (π : (a : α) → (X a ⟶ B))
[EffectiveEpiFamily X π] : EffectiveEpiFamilyStruct X π :=
EffectiveEpiFamily.effectiveEpiFamily.some
/-- Descend along an effective epi family. -/
noncomputable
def EffectiveEpiFamily.desc {B W : C} {α : Type*} (X : α → C) (π : (a : α) → (X a ⟶ B))
[EffectiveEpiFamily X π] (e : (a : α) → (X a ⟶ W))
(h : ∀ {Z : C} (a₁ a₂ : α) (g₁ : Z ⟶ X a₁) (g₂ : Z ⟶ X a₂),
g₁ ≫ π _ = g₂ ≫ π _ → g₁ ≫ e _ = g₂ ≫ e _) : B ⟶ W :=
(EffectiveEpiFamily.getStruct X π).desc e h
@[reassoc (attr := simp)]
lemma EffectiveEpiFamily.fac {B W : C} {α : Type*} (X : α → C) (π : (a : α) → (X a ⟶ B))
[EffectiveEpiFamily X π] (e : (a : α) → (X a ⟶ W))
(h : ∀ {Z : C} (a₁ a₂ : α) (g₁ : Z ⟶ X a₁) (g₂ : Z ⟶ X a₂),
g₁ ≫ π _ = g₂ ≫ π _ → g₁ ≫ e _ = g₂ ≫ e _) (a : α) :
π a ≫ EffectiveEpiFamily.desc X π e h = e a :=
(EffectiveEpiFamily.getStruct X π).fac e h a
lemma EffectiveEpiFamily.uniq {B W : C} {α : Type*} (X : α → C) (π : (a : α) → (X a ⟶ B))
[EffectiveEpiFamily X π] (e : (a : α) → (X a ⟶ W))
(h : ∀ {Z : C} (a₁ a₂ : α) (g₁ : Z ⟶ X a₁) (g₂ : Z ⟶ X a₂),
g₁ ≫ π _ = g₂ ≫ π _ → g₁ ≫ e _ = g₂ ≫ e _)
(m : B ⟶ W) (hm : ∀ a, π a ≫ m = e a) :
m = EffectiveEpiFamily.desc X π e h :=
(EffectiveEpiFamily.getStruct X π).uniq e h m hm
-- TODO: Once we have "jointly epimorphic families", we could rephrase this as such a property.
lemma EffectiveEpiFamily.hom_ext {B W : C} {α : Type*} (X : α → C) (π : (a : α) → (X a ⟶ B))
[EffectiveEpiFamily X π] (m₁ m₂ : B ⟶ W) (h : ∀ a, π a ≫ m₁ = π a ≫ m₂) :
m₁ = m₂ := by
have : m₂ = EffectiveEpiFamily.desc X π (fun a => π a ≫ m₂)
(fun a₁ a₂ g₁ g₂ h => by simp only [← Category.assoc, h]) := by
apply EffectiveEpiFamily.uniq; intro; rfl
rw [this]
exact EffectiveEpiFamily.uniq _ _ _ _ _ h
/--
An `EffectiveEpiFamily` consisting of a single `EffectiveEpi`
-/
noncomputable
def effectiveEpiFamilyStructSingletonOfEffectiveEpi {B X : C} (f : X ⟶ B) [EffectiveEpi f] :
EffectiveEpiFamilyStruct (fun () ↦ X) (fun () ↦ f) where
desc e h := EffectiveEpi.desc f (e ()) (fun g₁ g₂ hg ↦ h () () g₁ g₂ hg)
fac e h := fun _ ↦ EffectiveEpi.fac f (e ()) (fun g₁ g₂ hg ↦ h () () g₁ g₂ hg)
uniq e h m hm := by apply EffectiveEpi.uniq f (e ()) (h () ()); exact hm ()
instance {B X : C} (f : X ⟶ B) [EffectiveEpi f] : EffectiveEpiFamily (fun () ↦ X) (fun () ↦ f) :=
⟨⟨effectiveEpiFamilyStructSingletonOfEffectiveEpi f⟩⟩
/--
A single element `EffectiveEpiFamily` constists of an `EffectiveEpi`
-/
noncomputable
def effectiveEpiStructOfEffectiveEpiFamilySingleton {B X : C} (f : X ⟶ B)
[EffectiveEpiFamily (fun () ↦ X) (fun () ↦ f)] :
EffectiveEpiStruct f where
desc e h := EffectiveEpiFamily.desc
(fun () ↦ X) (fun () ↦ f) (fun () ↦ e) (fun _ _ g₁ g₂ hg ↦ h g₁ g₂ hg)
fac e h := EffectiveEpiFamily.fac
(fun () ↦ X) (fun () ↦ f) (fun () ↦ e) (fun _ _ g₁ g₂ hg ↦ h g₁ g₂ hg) ()
uniq e h m hm := EffectiveEpiFamily.uniq
(fun () ↦ X) (fun () ↦ f) (fun () ↦ e) (fun _ _ g₁ g₂ hg ↦ h g₁ g₂ hg) m (fun _ ↦ hm)
instance {B X : C} (f : X ⟶ B) [EffectiveEpiFamily (fun () ↦ X) (fun () ↦ f)] :
EffectiveEpi f :=
⟨⟨effectiveEpiStructOfEffectiveEpiFamilySingleton f⟩⟩
theorem effectiveEpi_iff_effectiveEpiFamily {B X : C} (f : X ⟶ B) :
EffectiveEpi f ↔ EffectiveEpiFamily (fun () ↦ X) (fun () ↦ f) :=
⟨fun _ ↦ inferInstance, fun _ ↦ inferInstance⟩
/--
A family of morphisms with the same target inducing an isomorphism from the coproduct to the target
is an `EffectiveEpiFamily`.
-/
noncomputable
def effectiveEpiFamilyStructOfIsIsoDesc {B : C} {α : Type*} (X : α → C)
(π : (a : α) → (X a ⟶ B)) [HasCoproduct X] [IsIso (Sigma.desc π)] :
EffectiveEpiFamilyStruct X π where
desc e _ := (asIso (Sigma.desc π)).inv ≫ (Sigma.desc e)
fac e h := by
intro a
have : π a = Sigma.ι X a ≫ (asIso (Sigma.desc π)).hom := by simp only [asIso_hom,
colimit.ι_desc, Cofan.mk_pt, Cofan.mk_ι_app]
rw [this, Category.assoc]
simp only [asIso_hom, asIso_inv, IsIso.hom_inv_id_assoc, colimit.ι_desc, Cofan.mk_pt,
Cofan.mk_ι_app]
uniq e h m hm := by
simp only [asIso_inv, IsIso.eq_inv_comp]
ext a
simp only [colimit.ι_desc_assoc, Discrete.functor_obj, Cofan.mk_pt, Cofan.mk_ι_app,
colimit.ι_desc]
exact hm a
instance {B : C} {α : Type*} (X : α → C) (π : (a : α) → (X a ⟶ B)) [HasCoproduct X]
[IsIso (Sigma.desc π)] : EffectiveEpiFamily X π :=
⟨⟨effectiveEpiFamilyStructOfIsIsoDesc X π⟩⟩
/-- Any isomorphism is an effective epi. -/
noncomputable
def effectiveEpiStructOfIsIso {X Y : C} (f : X ⟶ Y) [IsIso f] : EffectiveEpiStruct f where
desc e _ := inv f ≫ e
fac _ _ := by simp
uniq _ _ _ h := by simpa using h
instance {X Y : C} (f : X ⟶ Y) [IsIso f] : EffectiveEpi f := ⟨⟨effectiveEpiStructOfIsIso f⟩⟩
example {X : C} : EffectiveEpiFamily (fun _ => X : Unit → C) (fun _ => 𝟙 X) := inferInstance
/--
Reindex the indexing type of an effective epi family struct.
-/
def EffectiveEpiFamilyStruct.reindex
{B : C} {α α' : Type*}
(X : α → C)
(π : (a : α) → (X a ⟶ B))
(e : α' ≃ α)
(P : EffectiveEpiFamilyStruct (fun a => X (e a)) (fun a => π (e a))) :
EffectiveEpiFamilyStruct X π where
desc := fun f h => P.desc (fun a => f _) (fun a₁ a₂ => h _ _)
fac _ _ a := by
obtain ⟨a,rfl⟩ := e.surjective a
apply P.fac
uniq _ _ m hm := P.uniq _ _ _ fun a => hm _
/--
Reindex the indexing type of an effective epi family.
-/
lemma EffectiveEpiFamily.reindex
{B : C} {α α' : Type*}
(X : α → C)
(π : (a : α) → (X a ⟶ B))
(e : α' ≃ α)
(h : EffectiveEpiFamily (fun a => X (e a)) (fun a => π (e a))) :
EffectiveEpiFamily X π :=
.mk <| .intro <| @EffectiveEpiFamily.getStruct _ _ _ _ _ _ h |>.reindex _ _ e
end CategoryTheory
|
CategoryTheory\EffectiveEpi\Comp.lean | /-
Copyright (c) 2023 Dagur Asgeirsson. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Dagur Asgeirsson
-/
import Mathlib.CategoryTheory.EffectiveEpi.Basic
/-!
# Composition of effective epimorphisms
This file provides `EffectiveEpi` instances for certain compositions.
-/
namespace CategoryTheory
open Limits Category
variable {C : Type*} [Category C]
/--
An effective epi family precomposed by a family of split epis is effective epimorphic.
This version takes an explicit section to the split epis, and is mainly used to define
`effectiveEpiStructCompOfEffectiveEpiSplitEpi`,
which takes a `IsSplitEpi` instance instead.
-/
noncomputable
def effectiveEpiFamilyStructCompOfEffectiveEpiSplitEpi' {α : Type*} {B : C} {X Y : α → C}
(f : (a : α) → X a ⟶ B) (g : (a : α) → Y a ⟶ X a) (i : (a : α) → X a ⟶ Y a)
(hi : ∀ a, i a ≫ g a = 𝟙 _) [EffectiveEpiFamily _ f] :
EffectiveEpiFamilyStruct _ (fun a ↦ g a ≫ f a) where
desc e w := EffectiveEpiFamily.desc _ f (fun a ↦ i a ≫ e a) fun a₁ a₂ g₁ g₂ _ ↦ (by
simp only [← Category.assoc]
apply w _ _ (g₁ ≫ i a₁) (g₂ ≫ i a₂)
simpa [← Category.assoc, Category.assoc, hi])
fac e w a := by
simp only [Category.assoc, EffectiveEpiFamily.fac]
rw [← Category.id_comp (e a), ← Category.assoc, ← Category.assoc]
apply w
simp only [Category.comp_id, Category.id_comp, ← Category.assoc]
aesop
uniq _ _ _ hm := by
apply EffectiveEpiFamily.uniq _ f
intro a
rw [← hm a, ← Category.assoc, ← Category.assoc, hi, Category.id_comp]
/--
An effective epi family precomposed with a family of split epis is effective epimorphic.
-/
noncomputable
def effectiveEpiFamilyStructCompOfEffectiveEpiSplitEpi {α : Type*} {B : C} {X Y : α → C}
(f : (a : α) → X a ⟶ B) (g : (a : α) → Y a ⟶ X a) [∀ a, IsSplitEpi (g a)]
[EffectiveEpiFamily _ f] : EffectiveEpiFamilyStruct _ (fun a ↦ g a ≫ f a) :=
effectiveEpiFamilyStructCompOfEffectiveEpiSplitEpi' f g
(fun a ↦ section_ (g a))
(fun a ↦ IsSplitEpi.id (g a))
instance {α : Type*} {B : C} {X Y : α → C}
(f : (a : α) → X a ⟶ B) (g : (a : α) → Y a ⟶ X a) [∀ a, IsSplitEpi (g a)]
[EffectiveEpiFamily _ f] : EffectiveEpiFamily _ (fun a ↦ g a ≫ f a) :=
⟨⟨effectiveEpiFamilyStructCompOfEffectiveEpiSplitEpi f g⟩⟩
example {B X Y : C} (f : X ⟶ B) (g : Y ⟶ X) [IsSplitEpi g] [EffectiveEpi f] :
EffectiveEpi (g ≫ f) := inferInstance
instance IsSplitEpi.EffectiveEpi {B X : C} (f : X ⟶ B) [IsSplitEpi f] : EffectiveEpi f := by
rw [← Category.comp_id f]
infer_instance
/--
If a family of morphisms with fixed target, precomposed by a family of epis is
effective epimorphic, then the original family is as well.
-/
noncomputable def effectiveEpiFamilyStructOfComp {C : Type*} [Category C]
{I : Type*} {Z Y : I → C} {X : C} (g : ∀ i, Z i ⟶ Y i) (f : ∀ i, Y i ⟶ X)
[EffectiveEpiFamily _ (fun i => g i ≫ f i)] [∀ i, Epi (g i)] :
EffectiveEpiFamilyStruct _ f where
desc {W} φ h := EffectiveEpiFamily.desc _ (fun i => g i ≫ f i)
(fun i => g i ≫ φ i) (fun {T} i₁ i₂ g₁ g₂ eq =>
by simpa [assoc] using h i₁ i₂ (g₁ ≫ g i₁) (g₂ ≫ g i₂) (by simpa [assoc] using eq))
fac {W} φ h i := by
dsimp
rw [← cancel_epi (g i), ← assoc, EffectiveEpiFamily.fac _ (fun i => g i ≫ f i)]
uniq {W} φ h m hm := EffectiveEpiFamily.uniq _ (fun i => g i ≫ f i) _ _ _
(fun i => by rw [assoc, hm])
lemma effectiveEpiFamily_of_effectiveEpi_epi_comp {α : Type*} {B : C} {X Y : α → C}
(f : (a : α) → X a ⟶ B) (g : (a : α) → Y a ⟶ X a) [∀ a, Epi (g a)]
[EffectiveEpiFamily _ (fun a ↦ g a ≫ f a)] : EffectiveEpiFamily _ f :=
⟨⟨effectiveEpiFamilyStructOfComp g f⟩⟩
lemma effectiveEpi_of_effectiveEpi_epi_comp {B X Y : C} (f : X ⟶ B) (g : Y ⟶ X)
[Epi g] [EffectiveEpi (g ≫ f)] : EffectiveEpi f :=
have := (effectiveEpi_iff_effectiveEpiFamily (g ≫ f)).mp inferInstance
have := effectiveEpiFamily_of_effectiveEpi_epi_comp
(X := fun () ↦ X) (Y := fun () ↦ Y) (fun () ↦ f) (fun () ↦ g)
inferInstance
section CompIso
variable {B B' : C} {α : Type*} (X : α → C) (π : (a : α) → (X a ⟶ B))
(i : B ⟶ B')
theorem effectiveEpiFamilyStructCompIso_aux
{W : C} (e : (a : α) → X a ⟶ W)
(h : ∀ {Z : C} (a₁ a₂ : α) (g₁ : Z ⟶ X a₁) (g₂ : Z ⟶ X a₂),
g₁ ≫ π a₁ ≫ i = g₂ ≫ π a₂ ≫ i → g₁ ≫ e a₁ = g₂ ≫ e a₂)
{Z : C} (a₁ a₂ : α) (g₁ : Z ⟶ X a₁) (g₂ : Z ⟶ X a₂) (hg : g₁ ≫ π a₁ = g₂ ≫ π a₂) :
g₁ ≫ e a₁ = g₂ ≫ e a₂ := by
apply h
rw [← Category.assoc, hg]
simp
variable [EffectiveEpiFamily X π] [IsIso i]
/-- An effective epi family followed by an iso is an effective epi family. -/
noncomputable
def effectiveEpiFamilyStructCompIso : EffectiveEpiFamilyStruct X (fun a ↦ π a ≫ i) where
desc e h := inv i ≫ EffectiveEpiFamily.desc X π e (effectiveEpiFamilyStructCompIso_aux X π i e h)
fac _ _ _ := by simp
uniq e h m hm := by
simp only [Category.assoc] at hm
simp [← EffectiveEpiFamily.uniq X π e
(effectiveEpiFamilyStructCompIso_aux X π i e h) (i ≫ m) hm]
instance : EffectiveEpiFamily X (fun a ↦ π a ≫ i) := ⟨⟨effectiveEpiFamilyStructCompIso X π i⟩⟩
end CompIso
section IsoComp
variable {B : C} {α : Type*} (X Y : α → C) (π : (a : α) → (X a ⟶ B)) [EffectiveEpiFamily X π]
(i : (a : α) → Y a ⟶ X a) [∀ a, IsIso (i a)]
example : EffectiveEpiFamily Y (fun a ↦ i a ≫ π a) :=
inferInstance
end IsoComp
end CategoryTheory
|
CategoryTheory\EffectiveEpi\Coproduct.lean | /-
Copyright (c) 2023 Dagur Asgeirsson. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Dagur Asgeirsson
-/
import Mathlib.CategoryTheory.EffectiveEpi.Basic
import Mathlib.CategoryTheory.Limits.Shapes.Pullback.HasPullback
import Mathlib.Tactic.ApplyFun
/-!
# Effective epimorphic families and coproducts
This file proves that an effective epimorphic family induces an effective epi from the coproduct if
the coproduct exists, and the converse under some more conditions on the coproduct (that it
interacts well with pullbacks).
-/
namespace CategoryTheory
open Limits
variable {C : Type*} [Category C]
/--
Given an `EffectiveEpiFamily X π` and a corresponding coproduct cocone, the family descends to an
`EffectiveEpi` from the coproduct.
-/
noncomputable
def effectiveEpiStructIsColimitDescOfEffectiveEpiFamily {B : C} {α : Type*} (X : α → C)
(c : Cofan X) (hc : IsColimit c) (π : (a : α) → (X a ⟶ B)) [EffectiveEpiFamily X π] :
EffectiveEpiStruct (hc.desc (Cofan.mk B π)) where
desc e h := EffectiveEpiFamily.desc X π (fun a ↦ c.ι.app ⟨a⟩ ≫ e) (fun a₁ a₂ g₁ g₂ hg ↦ by
simp only [← Category.assoc]
exact h (g₁ ≫ c.ι.app ⟨a₁⟩) (g₂ ≫ c.ι.app ⟨a₂⟩) (by simpa))
fac e h := hc.hom_ext (fun ⟨j⟩ ↦ (by simp))
uniq e _ m hm := EffectiveEpiFamily.uniq X π (fun a ↦ c.ι.app ⟨a⟩ ≫ e)
(fun _ _ _ _ hg ↦ (by simp [← hm, reassoc_of% hg])) m (fun _ ↦ (by simp [← hm]))
/--
Given an `EffectiveEpiFamily X π` such that the coproduct of `X` exists, `Sigma.desc π` is an
`EffectiveEpi`.
-/
noncomputable
def effectiveEpiStructDescOfEffectiveEpiFamily {B : C} {α : Type*} (X : α → C)
(π : (a : α) → (X a ⟶ B)) [HasCoproduct X] [EffectiveEpiFamily X π] :
EffectiveEpiStruct (Sigma.desc π) := by
simpa [coproductIsCoproduct] using
effectiveEpiStructIsColimitDescOfEffectiveEpiFamily X _ (coproductIsCoproduct _) π
instance {B : C} {α : Type*} (X : α → C) (π : (a : α) → (X a ⟶ B)) [HasCoproduct X]
[EffectiveEpiFamily X π] : EffectiveEpi (Sigma.desc π) :=
⟨⟨effectiveEpiStructDescOfEffectiveEpiFamily X π⟩⟩
example {B : C} {α : Type*} (X : α → C) (π : (a : α) → (X a ⟶ B)) [EffectiveEpiFamily X π]
[HasCoproduct X] : Epi (Sigma.desc π) := inferInstance
/--
This is an auxiliary lemma used twice in the definition of `EffectiveEpiFamilyOfEffectiveEpiDesc`.
It is the `h` hypothesis of `EffectiveEpi.desc` and `EffectiveEpi.fac`.
-/
theorem effectiveEpiFamilyStructOfEffectiveEpiDesc_aux {B : C} {α : Type*} {X : α → C}
{π : (a : α) → X a ⟶ B} [HasCoproduct X]
[∀ {Z : C} (g : Z ⟶ ∐ X) (a : α), HasPullback g (Sigma.ι X a)]
[∀ {Z : C} (g : Z ⟶ ∐ X), HasCoproduct fun a ↦ pullback g (Sigma.ι X a)]
[∀ {Z : C} (g : Z ⟶ ∐ X), Epi (Sigma.desc fun a ↦ pullback.fst g (Sigma.ι X a))]
{W : C} {e : (a : α) → X a ⟶ W} (h : ∀ {Z : C} (a₁ a₂ : α) (g₁ : Z ⟶ X a₁) (g₂ : Z ⟶ X a₂),
g₁ ≫ π a₁ = g₂ ≫ π a₂ → g₁ ≫ e a₁ = g₂ ≫ e a₂) {Z : C}
{g₁ g₂ : Z ⟶ ∐ fun b ↦ X b} (hg : g₁ ≫ Sigma.desc π = g₂ ≫ Sigma.desc π) :
g₁ ≫ Sigma.desc e = g₂ ≫ Sigma.desc e := by
apply_fun ((Sigma.desc fun a ↦ pullback.fst g₁ (Sigma.ι X a)) ≫ ·) using
(fun a b ↦ (cancel_epi _).mp)
ext a
simp only [colimit.ι_desc_assoc, Discrete.functor_obj, Cofan.mk_pt, Cofan.mk_ι_app]
rw [← Category.assoc, pullback.condition]
simp only [Category.assoc, colimit.ι_desc, Cofan.mk_pt, Cofan.mk_ι_app]
apply_fun ((Sigma.desc fun a ↦ pullback.fst (pullback.fst _ _ ≫ g₂) (Sigma.ι X a)) ≫ ·)
using (fun a b ↦ (cancel_epi _).mp)
ext b
simp only [colimit.ι_desc_assoc, Discrete.functor_obj, Cofan.mk_pt, Cofan.mk_ι_app]
simp only [← Category.assoc]
rw [(Category.assoc _ _ g₂), pullback.condition]
simp only [Category.assoc, colimit.ι_desc, Cofan.mk_pt, Cofan.mk_ι_app]
rw [← Category.assoc]
apply h
apply_fun (pullback.fst g₁ (Sigma.ι X a) ≫ ·) at hg
rw [← Category.assoc, pullback.condition] at hg
simp only [Category.assoc, colimit.ι_desc, Cofan.mk_pt, Cofan.mk_ι_app] at hg
apply_fun ((Sigma.ι (fun a ↦ pullback _ _) b) ≫ (Sigma.desc fun a ↦
pullback.fst (pullback.fst _ _ ≫ g₂) (Sigma.ι X a)) ≫ ·) at hg
simp only [colimit.ι_desc_assoc, Discrete.functor_obj, Cofan.mk_pt, Cofan.mk_ι_app] at hg
simp only [← Category.assoc] at hg
rw [(Category.assoc _ _ g₂), pullback.condition] at hg
simpa using hg
/--
If a coproduct interacts well enough with pullbacks, then a family whose domains are the terms of
the coproduct is effective epimorphic whenever `Sigma.desc` induces an effective epimorphism from
the coproduct itself.
-/
noncomputable
def effectiveEpiFamilyStructOfEffectiveEpiDesc {B : C} {α : Type*} (X : α → C)
(π : (a : α) → (X a ⟶ B)) [HasCoproduct X] [EffectiveEpi (Sigma.desc π)]
[∀ {Z : C} (g : Z ⟶ ∐ X) (a : α), HasPullback g (Sigma.ι X a)]
[∀ {Z : C} (g : Z ⟶ ∐ X), HasCoproduct (fun a ↦ pullback g (Sigma.ι X a))]
[∀ {Z : C} (g : Z ⟶ ∐ X),
Epi (Sigma.desc (fun a ↦ pullback.fst g (Sigma.ι X a)))] :
EffectiveEpiFamilyStruct X π where
desc e h := EffectiveEpi.desc (Sigma.desc π) (Sigma.desc e) fun _ _ hg ↦
effectiveEpiFamilyStructOfEffectiveEpiDesc_aux h hg
fac e h a := by
rw [(by simp : π a = Sigma.ι X a ≫ Sigma.desc π), (by simp : e a = Sigma.ι X a ≫ Sigma.desc e),
Category.assoc, EffectiveEpi.fac (Sigma.desc π) (Sigma.desc e) (fun g₁ g₂ hg ↦
effectiveEpiFamilyStructOfEffectiveEpiDesc_aux h hg)]
uniq _ _ _ hm := by
apply EffectiveEpi.uniq (Sigma.desc π)
ext
simpa using hm _
end CategoryTheory
|
CategoryTheory\EffectiveEpi\Enough.lean | /-
Copyright (c) 2024 Dagur Asgeirsson. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Dagur Asgeirsson
-/
import Mathlib.CategoryTheory.EffectiveEpi.Basic
/-!
# Effectively enough objects in the image of a functor
We define the class `F.EffectivelyEnough` on a functor `F : C ⥤ D` which says that for every object
in `D`, there exists an effective epi to it from an object in the image of `F`.
-/
namespace CategoryTheory
open Limits
variable {C D : Type*} [Category C] [Category D] (F : C ⥤ D)
namespace Functor
/--
An effective presentation of an object `X` with respect to a functor `F` is the data of an effective
epimorphism of the form `F.obj p ⟶ X`.
-/
structure EffectivePresentation (X : D) where
/-- The object of `C` giving the source of the effective epi -/
p : C
/-- The morphism `F.obj p ⟶ X` -/
f : F.obj p ⟶ X
/-- `f` is an effective epi -/
effectiveEpi : EffectiveEpi f
/--
`D` has *effectively enough objects with respect to the functor `F` if every object has an
effective presentation.
-/
class EffectivelyEnough : Prop where
/-- For every `X : D`, there exists an object `p` of `C` with an effective epi `F.obj p ⟶ X`. -/
presentation : ∀ (X : D), Nonempty (F.EffectivePresentation X)
variable [F.EffectivelyEnough]
/--
`F.effectiveEpiOverObj X` provides an arbitrarily chosen object in the image of `F` equipped with an
effective epimorphism `F.effectiveEpiOver : F.effectiveEpiOverObj X ⟶ X`.
-/
noncomputable def effectiveEpiOverObj (X : D) : D :=
F.obj (EffectivelyEnough.presentation (F := F) X).some.p
/--
The epimorphism `F.effectiveEpiOver : F.effectiveEpiOverObj X ⟶ X` from the arbitrarily chosen
object in the image of `F` over `X`.
-/
noncomputable def effectiveEpiOver (X : D) : F.effectiveEpiOverObj X ⟶ X :=
(EffectivelyEnough.presentation X).some.f
instance (X : D) : EffectiveEpi (F.effectiveEpiOver X) :=
(EffectivelyEnough.presentation X).some.effectiveEpi
/-- An effective presentation of an object with respect to an equivalence of categories. -/
def equivalenceEffectivePresentation (e : C ≌ D) (X : D) :
EffectivePresentation e.functor X where
p := e.inverse.obj X
f := e.counit.app _
effectiveEpi := inferInstance
instance [IsEquivalence F] : EffectivelyEnough F where
presentation X := ⟨equivalenceEffectivePresentation F.asEquivalence X⟩
end Functor
end CategoryTheory
|
CategoryTheory\EffectiveEpi\Extensive.lean | /-
Copyright (c) 2024 Dagur Asgeirsson. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Dagur Asgeirsson
-/
import Mathlib.CategoryTheory.EffectiveEpi.Preserves
import Mathlib.CategoryTheory.EffectiveEpi.Coproduct
import Mathlib.CategoryTheory.Extensive
import Mathlib.CategoryTheory.Limits.Preserves.Finite
/-!
# Preserving and reflecting effective epis on extensive categories
We prove that a functor between `FinitaryPreExtensive` categories preserves (resp. reflects) finite
effective epi families if it preserves (resp. reflects) effective epis.
-/
namespace CategoryTheory
open Limits
variable {C : Type*} [Category C] [FinitaryPreExtensive C]
theorem effectiveEpi_desc_iff_effectiveEpiFamily {α : Type} [Finite α]
{B : C} (X : α → C) (π : (a : α) → X a ⟶ B) :
EffectiveEpi (Sigma.desc π) ↔ EffectiveEpiFamily X π := by
exact ⟨fun h ↦ ⟨⟨@effectiveEpiFamilyStructOfEffectiveEpiDesc _ _ _ _ X π _ h _ _ (fun g ↦
(FinitaryPreExtensive.sigma_desc_iso (fun a ↦ Sigma.ι X a) g inferInstance).epi_of_iso)⟩⟩,
fun _ ↦ inferInstance⟩
variable {D : Type*} [Category D] [FinitaryPreExtensive D]
variable (F : C ⥤ D) [PreservesFiniteCoproducts F]
instance [F.ReflectsEffectiveEpis] : F.ReflectsFiniteEffectiveEpiFamilies where
reflects {α _ B} X π h := by
simp only [← effectiveEpi_desc_iff_effectiveEpiFamily]
apply F.effectiveEpi_of_map
convert (inferInstance :
EffectiveEpi (inv (sigmaComparison F X) ≫ (Sigma.desc (fun a ↦ F.map (π a)))))
simp
instance [F.PreservesEffectiveEpis] : F.PreservesFiniteEffectiveEpiFamilies where
preserves {α _ B} X π h := by
simp only [← effectiveEpi_desc_iff_effectiveEpiFamily]
convert (inferInstance :
EffectiveEpi ((sigmaComparison F X) ≫ (F.map (Sigma.desc π))))
simp
end CategoryTheory
|
CategoryTheory\EffectiveEpi\Preserves.lean | /-
Copyright (c) 2023 Dagur Asgeirsson. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Dagur Asgeirsson
-/
import Mathlib.CategoryTheory.EffectiveEpi.Comp
import Mathlib.Data.Fintype.Card
/-!
# Functors preserving effective epimorphisms
This file concerns functors which preserve and/or reflect effective epimorphisms and effective
epimorphic families.
## TODO
- Find nice sufficient conditions in terms of preserving/reflecting (co)limits, to preserve/reflect
effective epis, similar to `CategoryTheory.preserves_epi_of_preservesColimit`.
-/
universe u
namespace CategoryTheory
open Limits
variable {C : Type*} [Category C]
noncomputable section Equivalence
variable {D : Type*} [Category D] (e : C ≌ D) {B : C}
variable {α : Type*} (X : α → C) (π : (a : α) → (X a ⟶ B))
theorem effectiveEpiFamilyStructOfEquivalence_aux {W : D} (ε : (a : α) → e.functor.obj (X a) ⟶ W)
(h : ∀ {Z : D} (a₁ a₂ : α) (g₁ : Z ⟶ e.functor.obj (X a₁)) (g₂ : Z ⟶ e.functor.obj (X a₂)),
g₁ ≫ e.functor.map (π a₁) = g₂ ≫ e.functor.map (π a₂) → g₁ ≫ ε a₁ = g₂ ≫ ε a₂)
{Z : C} (a₁ a₂ : α) (g₁ : Z ⟶ X a₁) (g₂ : Z ⟶ X a₂) (hg : g₁ ≫ π a₁ = g₂ ≫ π a₂) :
g₁ ≫ (fun a ↦ e.unit.app (X a) ≫ e.inverse.map (ε a)) a₁ =
g₂ ≫ (fun a ↦ e.unit.app (X a) ≫ e.inverse.map (ε a)) a₂ := by
have := h a₁ a₂ (e.functor.map g₁) (e.functor.map g₂)
simp only [← Functor.map_comp, hg] at this
simpa using congrArg e.inverse.map (this (by trivial))
variable [EffectiveEpiFamily X π]
/-- Equivalences preserve effective epimorphic families -/
def effectiveEpiFamilyStructOfEquivalence : EffectiveEpiFamilyStruct (fun a ↦ e.functor.obj (X a))
(fun a ↦ e.functor.map (π a)) where
desc ε h := (e.toAdjunction.homEquiv _ _).symm
(EffectiveEpiFamily.desc X π (fun a ↦ e.unit.app _ ≫ e.inverse.map (ε a))
(effectiveEpiFamilyStructOfEquivalence_aux e X π ε h))
fac ε h a := by
simp only [Functor.comp_obj, Adjunction.homEquiv_counit, Functor.id_obj,
Equivalence.toAdjunction_counit]
have := congrArg ((fun f ↦ f ≫ e.counit.app _) ∘ e.functor.map)
(EffectiveEpiFamily.fac X π (fun a ↦ e.unit.app _ ≫ e.inverse.map (ε a))
(effectiveEpiFamilyStructOfEquivalence_aux e X π ε h) a)
simp only [Functor.id_obj, Functor.comp_obj, Function.comp_apply, Functor.map_comp,
Category.assoc, Equivalence.fun_inv_map, Iso.inv_hom_id_app, Category.comp_id] at this
simp [this]
uniq ε h m hm := by
simp only [Functor.comp_obj, Adjunction.homEquiv_counit, Functor.id_obj,
Equivalence.toAdjunction_counit]
have := EffectiveEpiFamily.uniq X π (fun a ↦ e.unit.app _ ≫ e.inverse.map (ε a))
(effectiveEpiFamilyStructOfEquivalence_aux e X π ε h)
specialize this (e.unit.app _ ≫ e.inverse.map m) fun a ↦ ?_
· rw [← congrArg e.inverse.map (hm a)]
simp
· simp [← this]
instance (F : C ⥤ D) [F.IsEquivalence] :
EffectiveEpiFamily (fun a ↦ F.obj (X a)) (fun a ↦ F.map (π a)) :=
⟨⟨effectiveEpiFamilyStructOfEquivalence F.asEquivalence _ _⟩⟩
example {X B : C} (π : X ⟶ B) (F : C ⥤ D) [F.IsEquivalence] [EffectiveEpi π] :
EffectiveEpi <| F.map π := inferInstance
end Equivalence
namespace Functor
variable {D : Type*} [Category D]
section Preserves
/--
A class describing the property of preserving effective epimorphisms.
-/
class PreservesEffectiveEpis (F : C ⥤ D) : Prop where
/--
A functor preserves effective epimorphisms if it maps effective
epimorphisms to effective epimorphisms.
-/
preserves : ∀ {X Y : C} (f : X ⟶ Y) [EffectiveEpi f], EffectiveEpi (F.map f)
instance map_effectiveEpi (F : C ⥤ D) [F.PreservesEffectiveEpis] {X Y : C} (f : X ⟶ Y)
[EffectiveEpi f] : EffectiveEpi (F.map f) :=
PreservesEffectiveEpis.preserves f
/--
A class describing the property of preserving effective epimorphic families.
-/
class PreservesEffectiveEpiFamilies (F : C ⥤ D) : Prop where
/--
A functor preserves effective epimorphic families if it maps effective epimorphic families to
effective epimorphic families.
-/
preserves : ∀ {α : Type u} {B : C} (X : α → C) (π : (a : α) → (X a ⟶ B)) [EffectiveEpiFamily X π],
EffectiveEpiFamily (fun a ↦ F.obj (X a)) (fun a ↦ F.map (π a))
instance map_effectiveEpiFamily (F : C ⥤ D) [PreservesEffectiveEpiFamilies.{u} F]
{α : Type u} {B : C} (X : α → C) (π : (a : α) → (X a ⟶ B)) [EffectiveEpiFamily X π] :
EffectiveEpiFamily (fun a ↦ F.obj (X a)) (fun a ↦ F.map (π a)) :=
PreservesEffectiveEpiFamilies.preserves X π
/--
A class describing the property of preserving finite effective epimorphic families.
-/
class PreservesFiniteEffectiveEpiFamilies (F : C ⥤ D) : Prop where
/--
A functor preserves finite effective epimorphic families if it maps finite effective epimorphic
families to effective epimorphic families.
-/
preserves : ∀ {α : Type} [Finite α] {B : C} (X : α → C) (π : (a : α) → (X a ⟶ B))
[EffectiveEpiFamily X π],
EffectiveEpiFamily (fun a ↦ F.obj (X a)) (fun a ↦ F.map (π a))
instance map_finite_effectiveEpiFamily (F : C ⥤ D) [F.PreservesFiniteEffectiveEpiFamilies]
{α : Type} [Finite α] {B : C} (X : α → C) (π : (a : α) → (X a ⟶ B)) [EffectiveEpiFamily X π] :
EffectiveEpiFamily (fun a ↦ F.obj (X a)) (fun a ↦ F.map (π a)) :=
PreservesFiniteEffectiveEpiFamilies.preserves X π
instance (F : C ⥤ D) [PreservesEffectiveEpiFamilies.{0} F] :
PreservesFiniteEffectiveEpiFamilies F where
preserves _ _ := inferInstance
instance (F : C ⥤ D) [PreservesFiniteEffectiveEpiFamilies F] : PreservesEffectiveEpis F where
preserves _ := inferInstance
instance (F : C ⥤ D) [IsEquivalence F] : F.PreservesEffectiveEpiFamilies where
preserves _ _ := inferInstance
end Preserves
section Reflects
/--
A class describing the property of reflecting effective epimorphisms.
-/
class ReflectsEffectiveEpis (F : C ⥤ D) : Prop where
/--
A functor reflects effective epimorphisms if morphisms that are mapped to epimorphisms are
themselves effective epimorphisms.
-/
reflects : ∀ {X Y : C} (f : X ⟶ Y), EffectiveEpi (F.map f) → EffectiveEpi f
lemma effectiveEpi_of_map (F : C ⥤ D) [F.ReflectsEffectiveEpis] {X Y : C} (f : X ⟶ Y)
(h : EffectiveEpi (F.map f)) : EffectiveEpi f :=
ReflectsEffectiveEpis.reflects f h
/--
A class describing the property of reflecting effective epimorphic families.
-/
class ReflectsEffectiveEpiFamilies (F : C ⥤ D) : Prop where
/--
A functor reflects effective epimorphic families if families that are mapped to effective
epimorphic families are themselves effective epimorphic families.
-/
reflects : ∀ {α : Type u} {B : C} (X : α → C) (π : (a : α) → (X a ⟶ B)),
EffectiveEpiFamily (fun a ↦ F.obj (X a)) (fun a ↦ F.map (π a)) →
EffectiveEpiFamily X π
lemma effectiveEpiFamily_of_map (F : C ⥤ D) [ReflectsEffectiveEpiFamilies.{u} F]
{α : Type u} {B : C} (X : α → C) (π : (a : α) → (X a ⟶ B))
(h : EffectiveEpiFamily (fun a ↦ F.obj (X a)) (fun a ↦ F.map (π a))) :
EffectiveEpiFamily X π :=
ReflectsEffectiveEpiFamilies.reflects X π h
/--
A class describing the property of reflecting finite effective epimorphic families.
-/
class ReflectsFiniteEffectiveEpiFamilies (F : C ⥤ D) : Prop where
/--
A functor reflects finite effective epimorphic families if finite families that are
mapped to effective epimorphic families are themselves effective epimorphic families.
-/
reflects : ∀ {α : Type} [Finite α] {B : C} (X : α → C) (π : (a : α) → (X a ⟶ B)),
EffectiveEpiFamily (fun a ↦ F.obj (X a)) (fun a ↦ F.map (π a)) →
EffectiveEpiFamily X π
lemma finite_effectiveEpiFamily_of_map (F : C ⥤ D) [ReflectsFiniteEffectiveEpiFamilies F]
{α : Type} [Finite α] {B : C} (X : α → C) (π : (a : α) → (X a ⟶ B))
(h : EffectiveEpiFamily (fun a ↦ F.obj (X a)) (fun a ↦ F.map (π a))) :
EffectiveEpiFamily X π :=
ReflectsFiniteEffectiveEpiFamilies.reflects X π h
instance (F : C ⥤ D) [ReflectsEffectiveEpiFamilies.{0} F] :
ReflectsFiniteEffectiveEpiFamilies F where
reflects _ _ h := by
have := F.effectiveEpiFamily_of_map _ _ h
infer_instance
instance (F : C ⥤ D) [ReflectsFiniteEffectiveEpiFamilies F] : ReflectsEffectiveEpis F where
reflects _ h := by
rw [effectiveEpi_iff_effectiveEpiFamily] at h
have := F.finite_effectiveEpiFamily_of_map _ _ h
infer_instance
instance (F : C ⥤ D) [IsEquivalence F] : F.PreservesEffectiveEpiFamilies where
preserves _ _ := inferInstance
instance (F : C ⥤ D) [IsEquivalence F] : F.ReflectsEffectiveEpiFamilies where
reflects {α B} X π _ := by
let i : (a : α) → X a ⟶ (inv F).obj (F.obj (X a)) := fun a ↦ (asEquivalence F).unit.app _
have : EffectiveEpiFamily X (fun a ↦ (i a) ≫ (inv F).map (F.map (π a))) := inferInstance
simp only [inv_fun_map, Iso.hom_inv_id_app_assoc, i] at this
have : EffectiveEpiFamily X (fun a ↦ (π a ≫ (asEquivalence F).unit.app B) ≫
(asEquivalence F).unitInv.app _) := inferInstance
simpa
end Reflects
end Functor
end CategoryTheory
|
CategoryTheory\EffectiveEpi\RegularEpi.lean | /-
Copyright (c) 2023 Dagur Asgeirsson. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Dagur Asgeirsson
-/
import Mathlib.CategoryTheory.Limits.Shapes.RegularMono
import Mathlib.CategoryTheory.EffectiveEpi.Basic
/-!
# The relationship between effective and regular epimorphisms.
This file proves that the notions of regular epi and effective epi are equivalent for morphisms with
kernel pairs, and that regular epi implies effective epi in general.
-/
namespace CategoryTheory
open Limits RegularEpi
variable {C : Type*} [Category C]
/-- The data of an `EffectiveEpi` structure on a `RegularEpi`. -/
def effectiveEpiStructOfRegularEpi {B X : C} (f : X ⟶ B) [RegularEpi f] :
EffectiveEpiStruct f where
desc _ h := Cofork.IsColimit.desc isColimit _ (h _ _ w)
fac _ _ := Cofork.IsColimit.π_desc' isColimit _ _
uniq _ _ _ hg := Cofork.IsColimit.hom_ext isColimit (hg.trans
(Cofork.IsColimit.π_desc' _ _ _).symm)
instance {B X : C} (f : X ⟶ B) [RegularEpi f] : EffectiveEpi f :=
⟨⟨effectiveEpiStructOfRegularEpi f⟩⟩
/-- A morphism which is a coequalizer for its kernel pair is an effective epi. -/
theorem effectiveEpiOfKernelPair {B X : C} (f : X ⟶ B) [HasPullback f f]
(hc : IsColimit (Cofork.ofπ f pullback.condition)) : EffectiveEpi f :=
let _ := regularEpiOfKernelPair f hc
inferInstance
/-- An effective epi which has a kernel pair is a regular epi. -/
noncomputable instance regularEpiOfEffectiveEpi {B X : C} (f : X ⟶ B) [HasPullback f f]
[EffectiveEpi f] : RegularEpi f where
W := pullback f f
left := pullback.fst f f
right := pullback.snd f f
w := pullback.condition
isColimit := {
desc := fun s ↦ EffectiveEpi.desc f (s.ι.app WalkingParallelPair.one) fun g₁ g₂ hg ↦ (by
simp only [Cofork.app_one_eq_π]
rw [← pullback.lift_snd g₁ g₂ hg, Category.assoc, ← Cofork.app_zero_eq_comp_π_right]
simp)
fac := by
intro s j
have := EffectiveEpi.fac f (s.ι.app WalkingParallelPair.one) fun g₁ g₂ hg ↦ (by
simp only [Cofork.app_one_eq_π]
rw [← pullback.lift_snd g₁ g₂ hg, Category.assoc, ← Cofork.app_zero_eq_comp_π_right]
simp)
simp only [Functor.const_obj_obj, Cofork.app_one_eq_π] at this
cases j with
| zero => simp [this]
| one => simp [this]
uniq := fun _ _ h ↦ EffectiveEpi.uniq f _ _ _ (h WalkingParallelPair.one) }
end CategoryTheory
|
CategoryTheory\Endofunctor\Algebra.lean | /-
Copyright (c) 2022 Joseph Hua. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Scott Morrison, Bhavik Mehta, Johan Commelin, Reid Barton, Rob Lewis, Joseph Hua
-/
import Mathlib.CategoryTheory.Limits.Shapes.Terminal
/-!
# Algebras of endofunctors
This file defines (co)algebras of an endofunctor, and provides the category instance for them.
It also defines the forgetful functor from the category of (co)algebras. It is shown that the
structure map of the initial algebra of an endofunctor is an isomorphism. Furthermore, it is shown
that for an adjunction `F ⊣ G` the category of algebras over `F` is equivalent to the category of
coalgebras over `G`.
## TODO
* Prove the dual result about the structure map of the terminal coalgebra of an endofunctor.
* Prove that if the countable infinite product over the powers of the endofunctor exists, then
algebras over the endofunctor coincide with algebras over the free monad on the endofunctor.
-/
universe v u
namespace CategoryTheory
namespace Endofunctor
variable {C : Type u} [Category.{v} C]
/-- An algebra of an endofunctor; `str` stands for "structure morphism" -/
structure Algebra (F : C ⥤ C) where
/-- carrier of the algebra -/
a : C
/-- structure morphism of the algebra -/
str : F.obj a ⟶ a
instance [Inhabited C] : Inhabited (Algebra (𝟭 C)) :=
⟨⟨default, 𝟙 _⟩⟩
namespace Algebra
variable {F : C ⥤ C} (A : Algebra F) {A₀ A₁ A₂ : Algebra F}
/-
```
str
F A₀ -----> A₀
| |
F f | | f
V V
F A₁ -----> A₁
str
```
-/
/-- A morphism between algebras of endofunctor `F` -/
@[ext]
structure Hom (A₀ A₁ : Algebra F) where
/-- underlying morphism between the carriers -/
f : A₀.1 ⟶ A₁.1
/-- compatibility condition -/
h : F.map f ≫ A₁.str = A₀.str ≫ f := by aesop_cat
attribute [reassoc (attr := simp)] Hom.h
namespace Hom
/-- The identity morphism of an algebra of endofunctor `F` -/
def id : Hom A A where f := 𝟙 _
instance : Inhabited (Hom A A) :=
⟨{ f := 𝟙 _ }⟩
/-- The composition of morphisms between algebras of endofunctor `F` -/
def comp (f : Hom A₀ A₁) (g : Hom A₁ A₂) : Hom A₀ A₂ where f := f.1 ≫ g.1
end Hom
instance (F : C ⥤ C) : CategoryStruct (Algebra F) where
Hom := Hom
id := Hom.id
comp := @Hom.comp _ _ _
@[ext]
lemma ext {A B : Algebra F} {f g : A ⟶ B} (w : f.f = g.f := by aesop_cat) : f = g :=
Hom.ext w
@[simp]
theorem id_eq_id : Algebra.Hom.id A = 𝟙 A :=
rfl
@[simp]
theorem id_f : (𝟙 _ : A ⟶ A).1 = 𝟙 A.1 :=
rfl
variable (f : A₀ ⟶ A₁) (g : A₁ ⟶ A₂)
@[simp]
theorem comp_eq_comp : Algebra.Hom.comp f g = f ≫ g :=
rfl
@[simp]
theorem comp_f : (f ≫ g).1 = f.1 ≫ g.1 :=
rfl
/-- Algebras of an endofunctor `F` form a category -/
instance (F : C ⥤ C) : Category (Algebra F) := { }
/-- To construct an isomorphism of algebras, it suffices to give an isomorphism of the As which
commutes with the structure morphisms.
-/
@[simps!]
def isoMk (h : A₀.1 ≅ A₁.1) (w : F.map h.hom ≫ A₁.str = A₀.str ≫ h.hom := by aesop_cat) :
A₀ ≅ A₁ where
hom := { f := h.hom }
inv :=
{ f := h.inv
h := by
rw [h.eq_comp_inv, Category.assoc, ← w, ← Functor.map_comp_assoc]
simp }
/-- The forgetful functor from the category of algebras, forgetting the algebraic structure. -/
@[simps]
def forget (F : C ⥤ C) : Algebra F ⥤ C where
obj A := A.1
map := Hom.f
/-- An algebra morphism with an underlying isomorphism hom in `C` is an algebra isomorphism. -/
theorem iso_of_iso (f : A₀ ⟶ A₁) [IsIso f.1] : IsIso f :=
⟨⟨{ f := inv f.1
h := by
rw [IsIso.eq_comp_inv f.1, Category.assoc, ← f.h]
simp }, by aesop_cat, by aesop_cat⟩⟩
instance forget_reflects_iso : (forget F).ReflectsIsomorphisms where reflects := iso_of_iso
instance forget_faithful : (forget F).Faithful := { }
/-- An algebra morphism with an underlying epimorphism hom in `C` is an algebra epimorphism. -/
theorem epi_of_epi {X Y : Algebra F} (f : X ⟶ Y) [h : Epi f.1] : Epi f :=
(forget F).epi_of_epi_map h
/-- An algebra morphism with an underlying monomorphism hom in `C` is an algebra monomorphism. -/
theorem mono_of_mono {X Y : Algebra F} (f : X ⟶ Y) [h : Mono f.1] : Mono f :=
(forget F).mono_of_mono_map h
/-- From a natural transformation `α : G → F` we get a functor from
algebras of `F` to algebras of `G`.
-/
@[simps]
def functorOfNatTrans {F G : C ⥤ C} (α : G ⟶ F) : Algebra F ⥤ Algebra G where
obj A :=
{ a := A.1
str := α.app _ ≫ A.str }
map f := { f := f.1 }
/-- The identity transformation induces the identity endofunctor on the category of algebras. -/
-- Porting note: removed @[simps (config := { rhsMd := semireducible })] and replaced with
@[simps!]
def functorOfNatTransId : functorOfNatTrans (𝟙 F) ≅ 𝟭 _ :=
NatIso.ofComponents fun X => isoMk (Iso.refl _)
/-- A composition of natural transformations gives the composition of corresponding functors. -/
-- Porting note: removed @[simps (config := { rhsMd := semireducible })] and replaced with
@[simps!]
def functorOfNatTransComp {F₀ F₁ F₂ : C ⥤ C} (α : F₀ ⟶ F₁) (β : F₁ ⟶ F₂) :
functorOfNatTrans (α ≫ β) ≅ functorOfNatTrans β ⋙ functorOfNatTrans α :=
NatIso.ofComponents fun X => isoMk (Iso.refl _)
/--
If `α` and `β` are two equal natural transformations, then the functors of algebras induced by them
are isomorphic.
We define it like this as opposed to using `eq_to_iso` so that the components are nicer to prove
lemmas about.
-/
-- Porting note: removed @[simps (config := { rhsMd := semireducible })] and replaced with
@[simps!]
def functorOfNatTransEq {F G : C ⥤ C} {α β : F ⟶ G} (h : α = β) :
functorOfNatTrans α ≅ functorOfNatTrans β :=
NatIso.ofComponents fun X => isoMk (Iso.refl _)
/-- Naturally isomorphic endofunctors give equivalent categories of algebras.
Furthermore, they are equivalent as categories over `C`, that is,
we have `equiv_of_nat_iso h ⋙ forget = forget`.
-/
@[simps]
def equivOfNatIso {F G : C ⥤ C} (α : F ≅ G) : Algebra F ≌ Algebra G where
functor := functorOfNatTrans α.inv
inverse := functorOfNatTrans α.hom
unitIso := functorOfNatTransId.symm ≪≫ functorOfNatTransEq (by simp) ≪≫ functorOfNatTransComp _ _
counitIso :=
(functorOfNatTransComp _ _).symm ≪≫ functorOfNatTransEq (by simp) ≪≫ functorOfNatTransId
namespace Initial
variable {A} (h : @Limits.IsInitial (Algebra F) _ A)
/-- The inverse of the structure map of an initial algebra -/
@[simp]
def strInv : A.1 ⟶ F.obj A.1 :=
(h.to ⟨F.obj A.a, F.map A.str⟩).f
theorem left_inv' :
⟨strInv h ≫ A.str, by rw [← Category.assoc, F.map_comp, strInv, ← Hom.h]⟩ = 𝟙 A :=
Limits.IsInitial.hom_ext h _ (𝟙 A)
theorem left_inv : strInv h ≫ A.str = 𝟙 _ :=
congr_arg Hom.f (left_inv' h)
theorem right_inv : A.str ≫ strInv h = 𝟙 _ := by
rw [strInv, ← (h.to ⟨F.obj A.1, F.map A.str⟩).h, ← F.map_id, ← F.map_comp]
congr
exact left_inv h
/-- The structure map of the initial algebra is an isomorphism,
hence endofunctors preserve their initial algebras
-/
theorem str_isIso (h : Limits.IsInitial A) : IsIso A.str :=
{ out := ⟨strInv h, right_inv _, left_inv _⟩ }
end Initial
end Algebra
/-- A coalgebra of an endofunctor; `str` stands for "structure morphism" -/
structure Coalgebra (F : C ⥤ C) where
/-- carrier of the coalgebra -/
V : C
/-- structure morphism of the coalgebra -/
str : V ⟶ F.obj V
instance [Inhabited C] : Inhabited (Coalgebra (𝟭 C)) :=
⟨⟨default, 𝟙 _⟩⟩
namespace Coalgebra
variable {F : C ⥤ C} (V : Coalgebra F) {V₀ V₁ V₂ : Coalgebra F}
/-
```
str
V₀ -----> F V₀
| |
f | | F f
V V
V₁ -----> F V₁
str
```
-/
/-- A morphism between coalgebras of an endofunctor `F` -/
@[ext]
structure Hom (V₀ V₁ : Coalgebra F) where
/-- underlying morphism between two carriers -/
f : V₀.1 ⟶ V₁.1
/-- compatibility condition -/
h : V₀.str ≫ F.map f = f ≫ V₁.str := by aesop_cat
attribute [reassoc (attr := simp)] Hom.h
namespace Hom
/-- The identity morphism of an algebra of endofunctor `F` -/
def id : Hom V V where f := 𝟙 _
instance : Inhabited (Hom V V) :=
⟨{ f := 𝟙 _ }⟩
/-- The composition of morphisms between algebras of endofunctor `F` -/
def comp (f : Hom V₀ V₁) (g : Hom V₁ V₂) : Hom V₀ V₂ where f := f.1 ≫ g.1
end Hom
instance (F : C ⥤ C) : CategoryStruct (Coalgebra F) where
Hom := Hom
id := Hom.id
comp := @Hom.comp _ _ _
@[ext]
lemma ext {A B : Coalgebra F} {f g : A ⟶ B} (w : f.f = g.f := by aesop_cat) : f = g :=
Hom.ext w
@[simp]
theorem id_eq_id : Coalgebra.Hom.id V = 𝟙 V :=
rfl
@[simp]
theorem id_f : (𝟙 _ : V ⟶ V).1 = 𝟙 V.1 :=
rfl
variable (f : V₀ ⟶ V₁) (g : V₁ ⟶ V₂)
@[simp]
theorem comp_eq_comp : Coalgebra.Hom.comp f g = f ≫ g :=
rfl
@[simp]
theorem comp_f : (f ≫ g).1 = f.1 ≫ g.1 :=
rfl
/-- Coalgebras of an endofunctor `F` form a category -/
instance (F : C ⥤ C) : Category (Coalgebra F) := { }
/-- To construct an isomorphism of coalgebras, it suffices to give an isomorphism of the Vs which
commutes with the structure morphisms.
-/
@[simps]
def isoMk (h : V₀.1 ≅ V₁.1) (w : V₀.str ≫ F.map h.hom = h.hom ≫ V₁.str := by aesop_cat) :
V₀ ≅ V₁ where
hom := { f := h.hom }
inv :=
{ f := h.inv
h := by
rw [h.eq_inv_comp, ← Category.assoc, ← w, Category.assoc, ← F.map_comp]
simp only [Iso.hom_inv_id, Functor.map_id, Category.comp_id] }
/-- The forgetful functor from the category of coalgebras, forgetting the coalgebraic structure. -/
@[simps]
def forget (F : C ⥤ C) : Coalgebra F ⥤ C where
obj A := A.1
map f := f.1
/-- A coalgebra morphism with an underlying isomorphism hom in `C` is a coalgebra isomorphism. -/
theorem iso_of_iso (f : V₀ ⟶ V₁) [IsIso f.1] : IsIso f :=
⟨⟨{ f := inv f.1
h := by
rw [IsIso.eq_inv_comp f.1, ← Category.assoc, ← f.h, Category.assoc]
simp }, by aesop_cat, by aesop_cat⟩⟩
instance forget_reflects_iso : (forget F).ReflectsIsomorphisms where reflects := iso_of_iso
instance forget_faithful : (forget F).Faithful := { }
/-- An algebra morphism with an underlying epimorphism hom in `C` is an algebra epimorphism. -/
theorem epi_of_epi {X Y : Coalgebra F} (f : X ⟶ Y) [h : Epi f.1] : Epi f :=
(forget F).epi_of_epi_map h
/-- An algebra morphism with an underlying monomorphism hom in `C` is an algebra monomorphism. -/
theorem mono_of_mono {X Y : Coalgebra F} (f : X ⟶ Y) [h : Mono f.1] : Mono f :=
(forget F).mono_of_mono_map h
/-- From a natural transformation `α : F → G` we get a functor from
coalgebras of `F` to coalgebras of `G`.
-/
@[simps]
def functorOfNatTrans {F G : C ⥤ C} (α : F ⟶ G) : Coalgebra F ⥤ Coalgebra G where
obj V :=
{ V := V.1
str := V.str ≫ α.app V.1 }
map f :=
{ f := f.1
h := by rw [Category.assoc, ← α.naturality, ← Category.assoc, f.h, Category.assoc] }
/-- The identity transformation induces the identity endofunctor on the category of coalgebras. -/
-- Porting note: removed @[simps (config := { rhsMd := semireducible })] and replaced with
@[simps!]
def functorOfNatTransId : functorOfNatTrans (𝟙 F) ≅ 𝟭 _ :=
NatIso.ofComponents fun X => isoMk (Iso.refl _)
/-- A composition of natural transformations gives the composition of corresponding functors. -/
-- Porting note: removed @[simps (config := { rhsMd := semireducible })] and replaced with
@[simps!]
def functorOfNatTransComp {F₀ F₁ F₂ : C ⥤ C} (α : F₀ ⟶ F₁) (β : F₁ ⟶ F₂) :
functorOfNatTrans (α ≫ β) ≅ functorOfNatTrans α ⋙ functorOfNatTrans β :=
NatIso.ofComponents fun X => isoMk (Iso.refl _)
/-- If `α` and `β` are two equal natural transformations, then the functors of coalgebras induced by
them are isomorphic.
We define it like this as opposed to using `eq_to_iso` so that the components are nicer to prove
lemmas about.
-/
-- Porting note: removed @[simps (config := { rhsMd := semireducible })] and replaced with
@[simps!]
def functorOfNatTransEq {F G : C ⥤ C} {α β : F ⟶ G} (h : α = β) :
functorOfNatTrans α ≅ functorOfNatTrans β :=
NatIso.ofComponents fun X => isoMk (Iso.refl _)
/-- Naturally isomorphic endofunctors give equivalent categories of coalgebras.
Furthermore, they are equivalent as categories over `C`, that is,
we have `equiv_of_nat_iso h ⋙ forget = forget`.
-/
@[simps]
def equivOfNatIso {F G : C ⥤ C} (α : F ≅ G) : Coalgebra F ≌ Coalgebra G where
functor := functorOfNatTrans α.hom
inverse := functorOfNatTrans α.inv
unitIso := functorOfNatTransId.symm ≪≫ functorOfNatTransEq (by simp) ≪≫ functorOfNatTransComp _ _
counitIso :=
(functorOfNatTransComp _ _).symm ≪≫ functorOfNatTransEq (by simp) ≪≫ functorOfNatTransId
end Coalgebra
namespace Adjunction
variable {F : C ⥤ C} {G : C ⥤ C}
theorem Algebra.homEquiv_naturality_str (adj : F ⊣ G) (A₁ A₂ : Algebra F) (f : A₁ ⟶ A₂) :
(adj.homEquiv A₁.a A₁.a) A₁.str ≫ G.map f.f = f.f ≫ (adj.homEquiv A₂.a A₂.a) A₂.str := by
rw [← Adjunction.homEquiv_naturality_right, ← Adjunction.homEquiv_naturality_left, f.h]
theorem Coalgebra.homEquiv_naturality_str_symm (adj : F ⊣ G) (V₁ V₂ : Coalgebra G) (f : V₁ ⟶ V₂) :
F.map f.f ≫ (adj.homEquiv V₂.V V₂.V).symm V₂.str =
(adj.homEquiv V₁.V V₁.V).symm V₁.str ≫ f.f := by
rw [← Adjunction.homEquiv_naturality_left_symm, ← Adjunction.homEquiv_naturality_right_symm,
f.h]
/-- Given an adjunction `F ⊣ G`, the functor that associates to an algebra over `F` a
coalgebra over `G` defined via adjunction applied to the structure map. -/
def Algebra.toCoalgebraOf (adj : F ⊣ G) : Algebra F ⥤ Coalgebra G where
obj A :=
{ V := A.1
str := (adj.homEquiv A.1 A.1).toFun A.2 }
map f :=
{ f := f.1
h := Algebra.homEquiv_naturality_str adj _ _ f }
/-- Given an adjunction `F ⊣ G`, the functor that associates to a coalgebra over `G` an algebra over
`F` defined via adjunction applied to the structure map. -/
def Coalgebra.toAlgebraOf (adj : F ⊣ G) : Coalgebra G ⥤ Algebra F where
obj V :=
{ a := V.1
str := (adj.homEquiv V.1 V.1).invFun V.2 }
map f :=
{ f := f.1
h := Coalgebra.homEquiv_naturality_str_symm adj _ _ f }
/-- Given an adjunction, assigning to an algebra over the left adjoint a coalgebra over its right
adjoint and going back is isomorphic to the identity functor. -/
def AlgCoalgEquiv.unitIso (adj : F ⊣ G) :
𝟭 (Algebra F) ≅ Algebra.toCoalgebraOf adj ⋙ Coalgebra.toAlgebraOf adj where
hom :=
{ app := fun A =>
{ f := 𝟙 A.1
h := by
erw [F.map_id, Category.id_comp, Category.comp_id]
apply (adj.homEquiv _ _).left_inv A.str } }
inv :=
{ app := fun A =>
{ f := 𝟙 A.1
h := by
erw [F.map_id, Category.id_comp, Category.comp_id]
apply ((adj.homEquiv _ _).left_inv A.str).symm }
naturality := fun A₁ A₂ f => by
ext
dsimp
erw [Category.comp_id, Category.id_comp]
rfl }
/-- Given an adjunction, assigning to a coalgebra over the right adjoint an algebra over the left
adjoint and going back is isomorphic to the identity functor. -/
def AlgCoalgEquiv.counitIso (adj : F ⊣ G) :
Coalgebra.toAlgebraOf adj ⋙ Algebra.toCoalgebraOf adj ≅ 𝟭 (Coalgebra G) where
hom :=
{ app := fun V =>
{ f := 𝟙 V.1
h := by
dsimp
erw [G.map_id, Category.id_comp, Category.comp_id]
apply (adj.homEquiv _ _).right_inv V.str }
naturality := fun V₁ V₂ f => by
ext
dsimp
erw [Category.comp_id, Category.id_comp]
rfl }
inv :=
{ app := fun V =>
{ f := 𝟙 V.1
h := by
dsimp
rw [G.map_id, Category.comp_id, Category.id_comp]
apply ((adj.homEquiv _ _).right_inv V.str).symm } }
/-- If `F` is left adjoint to `G`, then the category of algebras over `F` is equivalent to the
category of coalgebras over `G`. -/
def algebraCoalgebraEquiv (adj : F ⊣ G) : Algebra F ≌ Coalgebra G where
functor := Algebra.toCoalgebraOf adj
inverse := Coalgebra.toAlgebraOf adj
unitIso := AlgCoalgEquiv.unitIso adj
counitIso := AlgCoalgEquiv.counitIso adj
functor_unitIso_comp A := by
ext
-- Porting note: why doesn't `simp` work here?
exact Category.comp_id _
end Adjunction
end Endofunctor
end CategoryTheory
|
CategoryTheory\Enriched\Basic.lean | /-
Copyright (c) 2021 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Scott Morrison
-/
import Mathlib.CategoryTheory.Monoidal.Types.Symmetric
import Mathlib.CategoryTheory.Monoidal.Types.Coyoneda
import Mathlib.CategoryTheory.Monoidal.Center
import Mathlib.Tactic.ApplyFun
/-!
# Enriched categories
We set up the basic theory of `V`-enriched categories,
for `V` an arbitrary monoidal category.
We do not assume here that `V` is a concrete category,
so there does not need to be an "honest" underlying category!
Use `X ⟶[V] Y` to obtain the `V` object of morphisms from `X` to `Y`.
This file contains the definitions of `V`-enriched categories and
`V`-functors.
We don't yet define the `V`-object of natural transformations
between a pair of `V`-functors (this requires limits in `V`),
but we do provide a presheaf isomorphic to the Yoneda embedding of this object.
We verify that when `V = Type v`, all these notion reduce to the usual ones.
-/
universe w v u₁ u₂ u₃
noncomputable section
namespace CategoryTheory
open Opposite
open MonoidalCategory
variable (V : Type v) [Category.{w} V] [MonoidalCategory V]
/-- A `V`-category is a category enriched in a monoidal category `V`.
Note that we do not assume that `V` is a concrete category,
so there may not be an "honest" underlying category at all!
-/
class EnrichedCategory (C : Type u₁) where
Hom : C → C → V
id (X : C) : 𝟙_ V ⟶ Hom X X
comp (X Y Z : C) : Hom X Y ⊗ Hom Y Z ⟶ Hom X Z
id_comp (X Y : C) : (λ_ (Hom X Y)).inv ≫ id X ▷ _ ≫ comp X X Y = 𝟙 _ := by aesop_cat
comp_id (X Y : C) : (ρ_ (Hom X Y)).inv ≫ _ ◁ id Y ≫ comp X Y Y = 𝟙 _ := by aesop_cat
assoc (W X Y Z : C) : (α_ _ _ _).inv ≫ comp W X Y ▷ _ ≫ comp W Y Z =
_ ◁ comp X Y Z ≫ comp W X Z := by aesop_cat
notation X " ⟶[" V "] " Y:10 => (EnrichedCategory.Hom X Y : V)
variable {C : Type u₁} [EnrichedCategory V C]
/-- The `𝟙_ V`-shaped generalized element giving the identity in a `V`-enriched category.
-/
def eId (X : C) : 𝟙_ V ⟶ X ⟶[V] X :=
EnrichedCategory.id X
/-- The composition `V`-morphism for a `V`-enriched category.
-/
def eComp (X Y Z : C) : ((X ⟶[V] Y) ⊗ Y ⟶[V] Z) ⟶ X ⟶[V] Z :=
EnrichedCategory.comp X Y Z
@[reassoc (attr := simp)]
theorem e_id_comp (X Y : C) :
(λ_ (X ⟶[V] Y)).inv ≫ eId V X ▷ _ ≫ eComp V X X Y = 𝟙 (X ⟶[V] Y) :=
EnrichedCategory.id_comp X Y
@[reassoc (attr := simp)]
theorem e_comp_id (X Y : C) :
(ρ_ (X ⟶[V] Y)).inv ≫ _ ◁ eId V Y ≫ eComp V X Y Y = 𝟙 (X ⟶[V] Y) :=
EnrichedCategory.comp_id X Y
@[reassoc (attr := simp)]
theorem e_assoc (W X Y Z : C) :
(α_ _ _ _).inv ≫ eComp V W X Y ▷ _ ≫ eComp V W Y Z =
_ ◁ eComp V X Y Z ≫ eComp V W X Z :=
EnrichedCategory.assoc W X Y Z
@[reassoc]
theorem e_assoc' (W X Y Z : C) :
(α_ _ _ _).hom ≫ _ ◁ eComp V X Y Z ≫ eComp V W X Z =
eComp V W X Y ▷ _ ≫ eComp V W Y Z := by
rw [← e_assoc V W X Y Z, Iso.hom_inv_id_assoc]
section
variable {V} {W : Type v} [Category.{w} W] [MonoidalCategory W]
-- Porting note: removed `@[nolint hasNonemptyInstance]`
/-- A type synonym for `C`, which should come equipped with a `V`-enriched category structure.
In a moment we will equip this with the `W`-enriched category structure
obtained by applying the functor `F : LaxMonoidalFunctor V W` to each hom object.
-/
@[nolint unusedArguments]
def TransportEnrichment (_ : LaxMonoidalFunctor V W) (C : Type u₁) :=
C
instance (F : LaxMonoidalFunctor V W) : EnrichedCategory W (TransportEnrichment F C) where
Hom := fun X Y : C => F.obj (X ⟶[V] Y)
id := fun X : C => F.ε ≫ F.map (eId V X)
comp := fun X Y Z : C => F.μ _ _ ≫ F.map (eComp V X Y Z)
id_comp X Y := by
simp only [comp_whiskerRight, Category.assoc, LaxMonoidalFunctor.μ_natural_left_assoc,
LaxMonoidalFunctor.left_unitality_inv_assoc]
simp_rw [← F.map_comp]
convert F.map_id _
simp
comp_id X Y := by
simp only [MonoidalCategory.whiskerLeft_comp, Category.assoc,
LaxMonoidalFunctor.μ_natural_right_assoc,
LaxMonoidalFunctor.right_unitality_inv_assoc]
simp_rw [← F.map_comp]
convert F.map_id _
simp
assoc P Q R S := by
rw [comp_whiskerRight, Category.assoc, F.μ_natural_left_assoc,
← F.associativity_inv_assoc, ← F.map_comp, ← F.map_comp, e_assoc,
F.map_comp, MonoidalCategory.whiskerLeft_comp, Category.assoc,
LaxMonoidalFunctor.μ_natural_right_assoc]
end
/-- Construct an honest category from a `Type v`-enriched category.
-/
def categoryOfEnrichedCategoryType (C : Type u₁) [𝒞 : EnrichedCategory (Type v) C] :
Category.{v} C where
Hom := 𝒞.Hom
id X := eId (Type v) X PUnit.unit
comp f g := eComp (Type v) _ _ _ ⟨f, g⟩
id_comp f := congr_fun (e_id_comp (Type v) _ _) f
comp_id f := congr_fun (e_comp_id (Type v) _ _) f
assoc f g h := (congr_fun (e_assoc (Type v) _ _ _ _) ⟨f, g, h⟩ : _)
/-- Construct a `Type v`-enriched category from an honest category.
-/
def enrichedCategoryTypeOfCategory (C : Type u₁) [𝒞 : Category.{v} C] :
EnrichedCategory (Type v) C where
Hom := 𝒞.Hom
id X _ := 𝟙 X
comp X Y Z p := p.1 ≫ p.2
id_comp X Y := by ext; simp
comp_id X Y := by ext; simp
assoc W X Y Z := by ext ⟨f, g, h⟩; simp
/-- We verify that an enriched category in `Type u` is just the same thing as an honest category.
-/
def enrichedCategoryTypeEquivCategory (C : Type u₁) :
EnrichedCategory (Type v) C ≃ Category.{v} C where
toFun _ := categoryOfEnrichedCategoryType C
invFun _ := enrichedCategoryTypeOfCategory C
left_inv _ := rfl
right_inv _ := rfl
section
variable {W : Type (v + 1)} [Category.{v} W] [MonoidalCategory W] [EnrichedCategory W C]
-- Porting note(#5171): removed `@[nolint has_nonempty_instance]`
/-- A type synonym for `C`, which should come equipped with a `V`-enriched category structure.
In a moment we will equip this with the (honest) category structure
so that `X ⟶ Y` is `(𝟙_ W) ⟶ (X ⟶[W] Y)`.
We obtain this category by
transporting the enrichment in `V` along the lax monoidal functor `coyonedaTensorUnit`,
then using the equivalence of `Type`-enriched categories with honest categories.
This is sometimes called the "underlying" category of an enriched category,
although some care is needed as the functor `coyonedaTensorUnit`,
which always exists, does not necessarily coincide with
"the forgetful functor" from `V` to `Type`, if such exists.
When `V` is any of `Type`, `Top`, `AddCommGroup`, or `Module R`,
`coyonedaTensorUnit` is just the usual forgetful functor, however.
For `V = Algebra R`, the usual forgetful functor is coyoneda of `R[X]`, not of `R`.
(Perhaps we should have a typeclass for this situation: `ConcreteMonoidal`?)
-/
@[nolint unusedArguments]
def ForgetEnrichment (W : Type (v + 1)) [Category.{v} W] [MonoidalCategory W] (C : Type u₁)
[EnrichedCategory W C] :=
C
variable (W)
/-- Typecheck an object of `C` as an object of `ForgetEnrichment W C`. -/
def ForgetEnrichment.of (X : C) : ForgetEnrichment W C :=
X
/-- Typecheck an object of `ForgetEnrichment W C` as an object of `C`. -/
def ForgetEnrichment.to (X : ForgetEnrichment W C) : C :=
X
@[simp]
theorem ForgetEnrichment.to_of (X : C) : ForgetEnrichment.to W (ForgetEnrichment.of W X) = X :=
rfl
@[simp]
theorem ForgetEnrichment.of_to (X : ForgetEnrichment W C) :
ForgetEnrichment.of W (ForgetEnrichment.to W X) = X :=
rfl
instance categoryForgetEnrichment : Category (ForgetEnrichment W C) := by
let I : EnrichedCategory (Type v) (TransportEnrichment (coyonedaTensorUnit W) C) :=
inferInstance
exact enrichedCategoryTypeEquivCategory C I
/-- We verify that the morphism types in `ForgetEnrichment W C` are `(𝟙_ W) ⟶ (X ⟶[W] Y)`.
-/
example (X Y : ForgetEnrichment W C) :
(X ⟶ Y) = (𝟙_ W ⟶ ForgetEnrichment.to W X ⟶[W] ForgetEnrichment.to W Y) :=
rfl
/-- Typecheck a `(𝟙_ W)`-shaped `W`-morphism as a morphism in `ForgetEnrichment W C`. -/
def ForgetEnrichment.homOf {X Y : C} (f : 𝟙_ W ⟶ X ⟶[W] Y) :
ForgetEnrichment.of W X ⟶ ForgetEnrichment.of W Y :=
f
/-- Typecheck a morphism in `ForgetEnrichment W C` as a `(𝟙_ W)`-shaped `W`-morphism. -/
def ForgetEnrichment.homTo {X Y : ForgetEnrichment W C} (f : X ⟶ Y) :
𝟙_ W ⟶ ForgetEnrichment.to W X ⟶[W] ForgetEnrichment.to W Y :=
f
@[simp]
theorem ForgetEnrichment.homTo_homOf {X Y : C} (f : 𝟙_ W ⟶ X ⟶[W] Y) :
ForgetEnrichment.homTo W (ForgetEnrichment.homOf W f) = f :=
rfl
@[simp]
theorem ForgetEnrichment.homOf_homTo {X Y : ForgetEnrichment W C} (f : X ⟶ Y) :
ForgetEnrichment.homOf W (ForgetEnrichment.homTo W f) = f :=
rfl
/-- The identity in the "underlying" category of an enriched category. -/
@[simp]
theorem forgetEnrichment_id (X : ForgetEnrichment W C) :
ForgetEnrichment.homTo W (𝟙 X) = eId W (ForgetEnrichment.to W X : C) :=
Category.id_comp _
@[simp]
theorem forgetEnrichment_id' (X : C) :
ForgetEnrichment.homOf W (eId W X) = 𝟙 (ForgetEnrichment.of W X : C) :=
(forgetEnrichment_id W (ForgetEnrichment.of W X)).symm
/-- Composition in the "underlying" category of an enriched category. -/
@[simp]
theorem forgetEnrichment_comp {X Y Z : ForgetEnrichment W C} (f : X ⟶ Y) (g : Y ⟶ Z) :
ForgetEnrichment.homTo W (f ≫ g) =
((λ_ (𝟙_ W)).inv ≫ (ForgetEnrichment.homTo W f ⊗ ForgetEnrichment.homTo W g)) ≫
eComp W _ _ _ :=
rfl
end
/-- A `V`-functor `F` between `V`-enriched categories
has a `V`-morphism from `X ⟶[V] Y` to `F.obj X ⟶[V] F.obj Y`,
satisfying the usual axioms.
-/
structure EnrichedFunctor (C : Type u₁) [EnrichedCategory V C] (D : Type u₂)
[EnrichedCategory V D] where
obj : C → D
map : ∀ X Y : C, (X ⟶[V] Y) ⟶ obj X ⟶[V] obj Y
map_id : ∀ X : C, eId V X ≫ map X X = eId V (obj X) := by aesop_cat
map_comp :
∀ X Y Z : C,
eComp V X Y Z ≫ map X Z = (map X Y ⊗ map Y Z) ≫ eComp V (obj X) (obj Y) (obj Z) := by
aesop_cat
attribute [reassoc (attr := simp)] EnrichedFunctor.map_id
attribute [reassoc (attr := simp)] EnrichedFunctor.map_comp
/-- The identity enriched functor. -/
@[simps]
def EnrichedFunctor.id (C : Type u₁) [EnrichedCategory V C] : EnrichedFunctor V C C where
obj X := X
map X Y := 𝟙 _
instance : Inhabited (EnrichedFunctor V C C) :=
⟨EnrichedFunctor.id V C⟩
/-- Composition of enriched functors. -/
@[simps]
def EnrichedFunctor.comp {C : Type u₁} {D : Type u₂} {E : Type u₃} [EnrichedCategory V C]
[EnrichedCategory V D] [EnrichedCategory V E] (F : EnrichedFunctor V C D)
(G : EnrichedFunctor V D E) : EnrichedFunctor V C E where
obj X := G.obj (F.obj X)
map X Y := F.map _ _ ≫ G.map _ _
section
variable {W : Type (v + 1)} [Category.{v} W] [MonoidalCategory W]
/-- An enriched functor induces an honest functor of the underlying categories,
by mapping the `(𝟙_ W)`-shaped morphisms.
-/
def EnrichedFunctor.forget {C : Type u₁} {D : Type u₂} [EnrichedCategory W C] [EnrichedCategory W D]
(F : EnrichedFunctor W C D) : ForgetEnrichment W C ⥤ ForgetEnrichment W D where
obj X := ForgetEnrichment.of W (F.obj (ForgetEnrichment.to W X))
map f :=
ForgetEnrichment.homOf W
(ForgetEnrichment.homTo W f ≫ F.map (ForgetEnrichment.to W _) (ForgetEnrichment.to W _))
map_comp f g := by
dsimp
apply_fun ForgetEnrichment.homTo W
· simp only [Iso.cancel_iso_inv_left, Category.assoc, tensor_comp,
ForgetEnrichment.homTo_homOf, EnrichedFunctor.map_comp, forgetEnrichment_comp]
rfl
· intro f g w; apply_fun ForgetEnrichment.homOf W at w; simpa using w
end
section
variable {V}
variable {D : Type u₂} [EnrichedCategory V D]
/-!
We now turn to natural transformations between `V`-functors.
The mostly commonly encountered definition of an enriched natural transformation
is a collection of morphisms
```
(𝟙_ W) ⟶ (F.obj X ⟶[V] G.obj X)
```
satisfying an appropriate analogue of the naturality square.
(c.f. https://ncatlab.org/nlab/show/enriched+natural+transformation)
This is the same thing as a natural transformation `F.forget ⟶ G.forget`.
We formalize this as `EnrichedNatTrans F G`, which is a `Type`.
However, there's also something much nicer: with appropriate additional hypotheses,
there is a `V`-object `EnrichedNatTransObj F G` which contains more information,
and from which one can recover `EnrichedNatTrans F G ≃ (𝟙_ V) ⟶ EnrichedNatTransObj F G`.
Using these as the hom-objects, we can build a `V`-enriched category
with objects the `V`-functors.
For `EnrichedNatTransObj` to exist, it suffices to have `V` braided and complete.
Before assuming `V` is complete, we assume it is braided and
define a presheaf `enrichedNatTransYoneda F G`
which is isomorphic to the Yoneda embedding of `EnrichedNatTransObj F G`
whether or not that object actually exists.
This presheaf has components `(enrichedNatTransYoneda F G).obj A`
what we call the `A`-graded enriched natural transformations,
which are collections of morphisms
```
A ⟶ (F.obj X ⟶[V] G.obj X)
```
satisfying a similar analogue of the naturality square,
this time incorporating a half-braiding on `A`.
(We actually define `EnrichedNatTrans F G`
as the special case `A := 𝟙_ V` with the trivial half-braiding,
and when defining `enrichedNatTransYoneda F G` we use the half-braidings
coming from the ambient braiding on `V`.)
-/
-- Porting note(#5171): removed `@[nolint has_nonempty_instance]`
/-- The type of `A`-graded natural transformations between `V`-functors `F` and `G`.
This is the type of morphisms in `V` from `A` to the `V`-object of natural transformations.
-/
@[ext]
structure GradedNatTrans (A : Center V) (F G : EnrichedFunctor V C D) where
app : ∀ X : C, A.1 ⟶ F.obj X ⟶[V] G.obj X
naturality :
∀ X Y : C,
(A.2.β (X ⟶[V] Y)).hom ≫ (F.map X Y ⊗ app Y) ≫ eComp V _ _ _ =
(app X ⊗ G.map X Y) ≫ eComp V _ _ _
variable [BraidedCategory V]
open BraidedCategory
/-- A presheaf isomorphic to the Yoneda embedding of
the `V`-object of natural transformations from `F` to `G`.
-/
@[simps]
def enrichedNatTransYoneda (F G : EnrichedFunctor V C D) : Vᵒᵖ ⥤ Type max u₁ w where
obj A := GradedNatTrans ((Center.ofBraided V).obj (unop A)) F G
map f σ :=
{ app := fun X => f.unop ≫ σ.app X
naturality := fun X Y => by
have p := σ.naturality X Y
dsimp at p ⊢
rw [← id_tensor_comp_tensor_id (f.unop ≫ σ.app Y) _, id_tensor_comp, Category.assoc,
Category.assoc, ← braiding_naturality_assoc, id_tensor_comp_tensor_id_assoc, p, ←
tensor_comp_assoc, Category.id_comp] }
-- TODO assuming `[HasLimits C]` construct the actual object of natural transformations
-- and show that the functor category is `V`-enriched.
end
section
attribute [local instance] categoryOfEnrichedCategoryType
/-- We verify that an enriched functor between `Type v` enriched categories
is just the same thing as an honest functor.
-/
@[simps]
def enrichedFunctorTypeEquivFunctor {C : Type u₁} [𝒞 : EnrichedCategory (Type v) C] {D : Type u₂}
[𝒟 : EnrichedCategory (Type v) D] : EnrichedFunctor (Type v) C D ≃ C ⥤ D where
toFun F :=
{ obj := fun X => F.obj X
map := fun f => F.map _ _ f
map_id := fun X => congr_fun (F.map_id X) PUnit.unit
map_comp := fun f g => congr_fun (F.map_comp _ _ _) ⟨f, g⟩ }
invFun F :=
{ obj := fun X => F.obj X
map := fun X Y f => F.map f
map_id := fun X => by ext ⟨⟩; exact F.map_id X
map_comp := fun X Y Z => by ext ⟨f, g⟩; exact F.map_comp f g }
left_inv _ := rfl
right_inv _ := rfl
/-- We verify that the presheaf representing natural transformations
between `Type v`-enriched functors is actually represented by
the usual type of natural transformations!
-/
def enrichedNatTransYonedaTypeIsoYonedaNatTrans {C : Type v} [EnrichedCategory (Type v) C]
{D : Type v} [EnrichedCategory (Type v) D] (F G : EnrichedFunctor (Type v) C D) :
enrichedNatTransYoneda F G ≅
yoneda.obj (enrichedFunctorTypeEquivFunctor F ⟶ enrichedFunctorTypeEquivFunctor G) :=
NatIso.ofComponents
(fun α =>
{ hom := fun σ x =>
{ app := fun X => σ.app X x
naturality := fun X Y f => congr_fun (σ.naturality X Y) ⟨x, f⟩ }
inv := fun σ =>
{ app := fun X x => (σ x).app X
naturality := fun X Y => by ext ⟨x, f⟩; exact (σ x).naturality f } })
(by aesop_cat)
end
end CategoryTheory
|
CategoryTheory\FiberedCategory\BasedCategory.lean | /-
Copyright (c) 2024 Calle Sönne. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Paul Lezeau, Calle Sönne
-/
import Mathlib.CategoryTheory.FiberedCategory.HomLift
import Mathlib.CategoryTheory.Bicategory.Strict
import Mathlib.CategoryTheory.Functor.Category
import Mathlib.CategoryTheory.Functor.ReflectsIso
/-!
# The bicategory of based categories
In this file we define the type `BasedCategory 𝒮`, and give it the structure of a strict
bicategory. Given a category `𝒮`, we define the type `BasedCategory 𝒮` as the type of categories
`𝒳` equiped with a functor `𝒳.p : 𝒳 ⥤ 𝒮`.
We also define a type of functors between based categories `𝒳` and `𝒴`, which we call
`BasedFunctor 𝒳 𝒴` and denote as `𝒳 ⥤ᵇ 𝒴`. These are defined as functors between the underlying
categories `𝒳.obj` and `𝒴.obj` which commute with the projections to `𝒮`.
Natural transformations between based functors `F G : 𝒳 ⥤ᵇ 𝒴 ` are given by the structure
`BasedNatTrans F G`. These are defined as natural transformations `α` between the functors
underlying `F` and `G` such that `α.app a` lifts `𝟙 S` whenever `𝒳.p.obj a = S`.
-/
universe v₅ u₅ v₄ u₄ v₃ u₃ v₂ u₂ v₁ u₁
namespace CategoryTheory
open CategoryTheory Functor Category NatTrans IsHomLift
variable {𝒮 : Type u₁} [Category.{v₁} 𝒮]
/-- A based category over `𝒮` is a category `𝒳` together with a functor `p : 𝒳 ⥤ 𝒮`. -/
@[nolint checkUnivs]
structure BasedCategory (𝒮 : Type u₁) [Category.{v₁} 𝒮] where
/-- The type of objects in a `BasedCategory`-/
obj : Type u₂
/-- The underlying category of a `BasedCategory`. -/
category : Category.{v₂} obj := by infer_instance
/-- The functor to the base. -/
p : obj ⥤ 𝒮
instance (𝒳 : BasedCategory.{v₂, u₂} 𝒮) : Category 𝒳.obj := 𝒳.category
/-- The based category associated to a functor `p : 𝒳 ⥤ 𝒮`. -/
def BasedCategory.ofFunctor {𝒳 : Type u₂} [Category.{v₂} 𝒳] (p : 𝒳 ⥤ 𝒮) : BasedCategory 𝒮 where
obj := 𝒳
p := p
/-- A functor between based categories is a functor between the underlying categories that commutes
with the projections. -/
structure BasedFunctor (𝒳 : BasedCategory.{v₂, u₂} 𝒮) (𝒴 : BasedCategory.{v₃, u₃} 𝒮) extends
𝒳.obj ⥤ 𝒴.obj where
w : toFunctor ⋙ 𝒴.p = 𝒳.p := by aesop_cat
/-- Notation for `BasedFunctor`. -/
scoped infixr:26 " ⥤ᵇ " => BasedFunctor
namespace BasedFunctor
initialize_simps_projections BasedFunctor (+toFunctor, -obj, -map)
/-- The identity based functor. -/
@[simps]
def id (𝒳 : BasedCategory.{v₂, u₂} 𝒮) : 𝒳 ⥤ᵇ 𝒳 where
toFunctor := 𝟭 𝒳.obj
variable {𝒳 : BasedCategory.{v₂, u₂} 𝒮} {𝒴 : BasedCategory.{v₃, u₃} 𝒮}
/-- Notation for the identity functor on a based category. -/
scoped notation "𝟭" => BasedFunctor.id
/-- The composition of two based functors. -/
@[simps]
def comp {𝒵 : BasedCategory.{v₄, u₄} 𝒮} (F : 𝒳 ⥤ᵇ 𝒴) (G : 𝒴 ⥤ᵇ 𝒵) : 𝒳 ⥤ᵇ 𝒵 where
toFunctor := F.toFunctor ⋙ G.toFunctor
w := by rw [Functor.assoc, G.w, F.w]
/-- Notation for composition of based functors. -/
scoped infixr:80 " ⋙ " => BasedFunctor.comp
@[simp]
lemma comp_id (F : 𝒳 ⥤ᵇ 𝒴) : F ⋙ 𝟭 𝒴 = F :=
rfl
@[simp]
lemma id_comp (F : 𝒳 ⥤ᵇ 𝒴) : 𝟭 𝒳 ⋙ F = F :=
rfl
@[simp]
lemma comp_assoc {𝒵 : BasedCategory.{v₄, u₄} 𝒮} {𝒜 : BasedCategory.{v₅, u₅} 𝒮} (F : 𝒳 ⥤ᵇ 𝒴)
(G : 𝒴 ⥤ᵇ 𝒵) (H : 𝒵 ⥤ᵇ 𝒜) : (F ⋙ G) ⋙ H = F ⋙ (G ⋙ H) :=
rfl
@[simp]
lemma w_obj (F : 𝒳 ⥤ᵇ 𝒴) (a : 𝒳.obj) : 𝒴.p.obj (F.obj a) = 𝒳.p.obj a := by
rw [← Functor.comp_obj, F.w]
instance (F : 𝒳 ⥤ᵇ 𝒴) (a : 𝒳.obj) : IsHomLift 𝒴.p (𝟙 (𝒳.p.obj a)) (𝟙 (F.obj a)) :=
IsHomLift.id (w_obj F a)
section
variable (F : 𝒳 ⥤ᵇ 𝒴) {R S : 𝒮} {a b : 𝒳.obj} (f : R ⟶ S) (φ : a ⟶ b)
/-- For a based functor `F : 𝒳 ⟶ 𝒴`, then whenever an arrow `φ` in `𝒳` lifts some `f` in `𝒮`,
then `F(φ)` also lifts `f`. -/
instance preserves_isHomLift [IsHomLift 𝒳.p f φ] : IsHomLift 𝒴.p f (F.map φ) := by
apply of_fac 𝒴.p f (F.map φ) (Eq.trans (F.w_obj a) (domain_eq 𝒳.p f φ))
(Eq.trans (F.w_obj b) (codomain_eq 𝒳.p f φ))
rw [← Functor.comp_map, congr_hom F.w]
simpa using (fac 𝒳.p f φ)
/-- For a based functor `F : 𝒳 ⟶ 𝒴`, and an arrow `φ` in `𝒳`, then `φ` lifts an arrow `f` in `𝒮`
if `F(φ)` does. -/
lemma isHomLift_map [IsHomLift 𝒴.p f (F.map φ)] : IsHomLift 𝒳.p f φ := by
apply of_fac 𝒳.p f φ (F.w_obj a ▸ domain_eq 𝒴.p f (F.map φ))
(F.w_obj b ▸ codomain_eq 𝒴.p f (F.map φ))
simp [congr_hom F.w.symm, fac 𝒴.p f (F.map φ)]
lemma isHomLift_iff : IsHomLift 𝒴.p f (F.map φ) ↔ IsHomLift 𝒳.p f φ :=
⟨fun _ ↦ isHomLift_map F f φ, fun _ ↦ preserves_isHomLift F f φ⟩
end
end BasedFunctor
/-- A `BasedNatTrans` between two `BasedFunctor`s is a natural transformation `α` between the
underlying functors, such that for all `a : 𝒳`, `α.app a` lifts `𝟙 S` whenever `𝒳.p.obj a = S`. -/
structure BasedNatTrans {𝒳 : BasedCategory.{v₂, u₂} 𝒮} {𝒴 : BasedCategory.{v₃, u₃} 𝒮}
(F G : 𝒳 ⥤ᵇ 𝒴) extends CategoryTheory.NatTrans F.toFunctor G.toFunctor where
isHomLift' : ∀ (a : 𝒳.obj), IsHomLift 𝒴.p (𝟙 (𝒳.p.obj a)) (toNatTrans.app a) := by aesop_cat
namespace BasedNatTrans
open BasedFunctor
variable {𝒳 : BasedCategory.{v₂, u₂} 𝒮} {𝒴 : BasedCategory.{v₃, u₃} 𝒮}
initialize_simps_projections BasedNatTrans (+toNatTrans, -app)
section
variable {F G : 𝒳 ⥤ᵇ 𝒴} (α : BasedNatTrans F G)
@[ext]
lemma ext (β : BasedNatTrans F G) (h : α.toNatTrans = β.toNatTrans) : α = β := by
cases α; subst h; rfl
instance app_isHomLift (a : 𝒳.obj) : IsHomLift 𝒴.p (𝟙 (𝒳.p.obj a)) (α.toNatTrans.app a) :=
α.isHomLift' a
lemma isHomLift {a : 𝒳.obj} {S : 𝒮} (ha : 𝒳.p.obj a = S) :
IsHomLift 𝒴.p (𝟙 S) (α.toNatTrans.app a) := by
subst ha; infer_instance
end
/-- The identity natural transformation is a `BasedNatTrans`. -/
@[simps]
def id (F : 𝒳 ⥤ᵇ 𝒴) : BasedNatTrans F F where
toNatTrans := CategoryTheory.NatTrans.id F.toFunctor
isHomLift' := fun a ↦ of_fac 𝒴.p _ _ (w_obj F a) (w_obj F a) (by simp)
/-- Composition of `BasedNatTrans`, given by composition of the underlying natural
transformations. -/
@[simps]
def comp {F G H : 𝒳 ⥤ᵇ 𝒴} (α : BasedNatTrans F G) (β : BasedNatTrans G H) : BasedNatTrans F H where
toNatTrans := CategoryTheory.NatTrans.vcomp α.toNatTrans β.toNatTrans
isHomLift' := by
intro a
rw [CategoryTheory.NatTrans.vcomp_app]
infer_instance
@[simps]
instance homCategory (𝒳 : BasedCategory.{v₂, u₂} 𝒮) (𝒴 : BasedCategory.{v₃, u₃} 𝒮) :
Category (𝒳 ⥤ᵇ 𝒴) where
Hom := BasedNatTrans
id := BasedNatTrans.id
comp := BasedNatTrans.comp
@[ext]
lemma homCategory.ext {F G : 𝒳 ⥤ᵇ 𝒴} (α β : F ⟶ G) (h : α.toNatTrans = β.toNatTrans) : α = β :=
BasedNatTrans.ext α β h
/-- The forgetful functor from the category of based functors `𝒳 ⥤ᵇ 𝒴` to the category of
functors of underlying categories, `𝒳.obj ⥤ 𝒴.obj`. -/
@[simps]
def forgetful (𝒳 : BasedCategory.{v₂, u₂} 𝒮) (𝒴 : BasedCategory.{v₃, u₃} 𝒮) :
(𝒳 ⥤ᵇ 𝒴) ⥤ (𝒳.obj ⥤ 𝒴.obj) where
obj := fun F ↦ F.toFunctor
map := fun α ↦ α.toNatTrans
instance : (forgetful 𝒳 𝒴).ReflectsIsomorphisms where
reflects {F G} α _ := by
constructor
use {
toNatTrans := inv ((forgetful 𝒳 𝒴).map α)
isHomLift' := fun a ↦ by simp [lift_id_inv_isIso] }
aesop
instance {F G : 𝒳 ⥤ᵇ 𝒴} (α : F ⟶ G) [IsIso α] : IsIso (X := F.toFunctor) α.toNatTrans := by
rw [← forgetful_map]; infer_instance
end BasedNatTrans
namespace BasedNatIso
open BasedNatTrans
variable {𝒳 : BasedCategory.{v₂, u₂} 𝒮} {𝒴 : BasedCategory.{v₃, u₃} 𝒮}
/-- The identity natural transformation is a based natural isomorphism. -/
@[simps]
def id (F : 𝒳 ⥤ᵇ 𝒴) : F ≅ F where
hom := 𝟙 F
inv := 𝟙 F
variable {F G : 𝒳 ⥤ᵇ 𝒴}
/-- The inverse of a based natural transformation whose underlying natural tranformation is an
isomorphism. -/
def mkNatIso (α : F.toFunctor ≅ G.toFunctor)
(isHomLift' : ∀ a : 𝒳.obj, IsHomLift 𝒴.p (𝟙 (𝒳.p.obj a)) (α.hom.app a)) : F ≅ G where
hom := { toNatTrans := α.hom }
inv := {
toNatTrans := α.inv
isHomLift' := fun a ↦ by
have : 𝒴.p.IsHomLift (𝟙 (𝒳.p.obj a)) (α.app a).hom := (NatIso.app_hom α a) ▸ isHomLift' a
rw [← NatIso.app_inv]
apply IsHomLift.lift_id_inv }
lemma isIso_of_toNatTrans_isIso (α : F ⟶ G) [IsIso (X := F.toFunctor) α.toNatTrans] : IsIso α :=
have : IsIso ((forgetful 𝒳 𝒴).map α) := by simp_all
Functor.ReflectsIsomorphisms.reflects (forgetful 𝒳 𝒴) α
end BasedNatIso
namespace BasedCategory
open BasedFunctor BasedNatTrans
section
variable {𝒳 : BasedCategory.{v₂, u₂} 𝒮} {𝒴 : BasedCategory.{v₃, u₃} 𝒮}
/-- Left-whiskering in the bicategory `BasedCategory` is given by whiskering the underlying functors
and natural transformations. -/
@[simps]
def whiskerLeft {𝒵 : BasedCategory.{v₄, u₄} 𝒮} (F : 𝒳 ⥤ᵇ 𝒴) {G H : 𝒴 ⥤ᵇ 𝒵} (α : G ⟶ H) :
F ⋙ G ⟶ F ⋙ H where
toNatTrans := CategoryTheory.whiskerLeft F.toFunctor α.toNatTrans
isHomLift' := fun a ↦ α.isHomLift (F.w_obj a)
/-- Right-whiskering in the bicategory `BasedCategory` is given by whiskering the underlying
functors and natural transformations. -/
@[simps]
def whiskerRight {𝒵 : BasedCategory.{v₄, u₄} 𝒮} {F G : 𝒳 ⥤ᵇ 𝒴} (α : F ⟶ G) (H : 𝒴 ⥤ᵇ 𝒵) :
F ⋙ H ⟶ G ⋙ H where
toNatTrans := CategoryTheory.whiskerRight α.toNatTrans H.toFunctor
isHomLift' := fun _ ↦ BasedFunctor.preserves_isHomLift _ _ _
end
/-- The category of based categories. -/
@[simps]
instance : Category (BasedCategory.{v₂, u₂} 𝒮) where
Hom := BasedFunctor
id := id
comp := comp
/-- The bicategory of based categories. -/
instance bicategory : Bicategory (BasedCategory.{v₂, u₂} 𝒮) where
Hom 𝒳 𝒴 := 𝒳 ⥤ᵇ 𝒴
id 𝒳 := 𝟭 𝒳
comp F G := F ⋙ G
homCategory 𝒳 𝒴 := homCategory 𝒳 𝒴
whiskerLeft {𝒳 𝒴 𝒵} F {G H} α := whiskerLeft F α
whiskerRight {𝒳 𝒴 𝒵} F G α H := whiskerRight α H
associator F G H := BasedNatIso.id _
leftUnitor {𝒳 𝒴} F := BasedNatIso.id F
rightUnitor {𝒳 𝒴} F := BasedNatIso.id F
/-- The bicategory structure on `BasedCategory.{v₂, u₂} 𝒮` is strict. -/
instance : Bicategory.Strict (BasedCategory.{v₂, u₂} 𝒮) where
end BasedCategory
end CategoryTheory
|
CategoryTheory\FiberedCategory\Cartesian.lean | /-
Copyright (c) 2024 Calle Sönne. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Paul Lezeau, Calle Sönne
-/
import Mathlib.CategoryTheory.FiberedCategory.HomLift
/-!
# Cartesian morphisms
This file defines cartesian resp. strongly cartesian morphisms with respect to a functor
`p : 𝒳 ⥤ 𝒮`.
## Main definitions
`IsCartesian p f φ` expresses that `φ` is a cartesian morphism lying over `f` with respect to `p` in
the sense of SGA 1 VI 5.1. This means that for any morphism `φ' : a' ⟶ b` lying over `f` there is
a unique morphism `τ : a' ⟶ a` lying over `𝟙 R`, such that `φ' = τ ≫ φ`.
`IsStronglyCartesian p f φ` expresses that `φ` is a strongly cartesian morphism lying over `f` with
respect to `p`, see <https://stacks.math.columbia.edu/tag/02XK>.
## Implementation
The constructor of `IsStronglyCartesian` has been named `universal_property'`, and is mainly
intended to be used for constructing instances of this class. To use the universal property, we
generally recommended to use the lemma `IsStronglyCartesian.universal_property` instead. The
difference between the two is that the latter is more flexible with respect to non-definitional
equalities.
## References
* [A. Grothendieck, M. Raynaud, *SGA 1*](https://arxiv.org/abs/math/0206203)
* [Stacks: Fibred Categories](https://stacks.math.columbia.edu/tag/02XJ)
-/
universe v₁ v₂ u₁ u₂
open CategoryTheory Functor Category IsHomLift
namespace CategoryTheory.Functor
variable {𝒮 : Type u₁} {𝒳 : Type u₂} [Category.{v₁} 𝒮] [Category.{v₂} 𝒳] (p : 𝒳 ⥤ 𝒮)
section
variable {R S : 𝒮} {a b : 𝒳} (f : R ⟶ S) (φ : a ⟶ b)
/-- The proposition that a morphism `φ : a ⟶ b` in `𝒳` lying over `f : R ⟶ S` in `𝒮` is a
cartesian morphism.
See SGA 1 VI 5.1. -/
class IsCartesian extends IsHomLift p f φ : Prop where
universal_property {a' : 𝒳} (φ' : a' ⟶ b) [IsHomLift p f φ'] :
∃! χ : a' ⟶ a, IsHomLift p (𝟙 R) χ ∧ χ ≫ φ = φ'
/-- The proposition that a morphism `φ : a ⟶ b` in `𝒳` lying over `f : R ⟶ S` in `𝒮` is a
strongly cartesian morphism.
See <https://stacks.math.columbia.edu/tag/02XK> -/
class IsStronglyCartesian extends IsHomLift p f φ : Prop where
universal_property' {a' : 𝒳} (g : p.obj a' ⟶ R) (φ' : a' ⟶ b) [IsHomLift p (g ≫ f) φ'] :
∃! χ : a' ⟶ a, IsHomLift p g χ ∧ χ ≫ φ = φ'
end
namespace IsCartesian
variable {R S : 𝒮} {a b : 𝒳} (f : R ⟶ S) (φ : a ⟶ b) [IsCartesian p f φ]
section
variable {a' : 𝒳} (φ' : a' ⟶ b) [IsHomLift p f φ']
/-- Given a cartesian morphism `φ : a ⟶ b` lying over `f : R ⟶ S` in `𝒳`, and another morphism
`φ' : a' ⟶ b` which also lifts `f`, then `IsCartesian.map f φ φ'` is the morphism `a' ⟶ a` lifting
`𝟙 R` obtained from the universal property of `φ`. -/
protected noncomputable def map : a' ⟶ a :=
Classical.choose <| IsCartesian.universal_property (p := p) (f := f) (φ := φ) φ'
instance map_isHomLift : IsHomLift p (𝟙 R) (IsCartesian.map p f φ φ') :=
(Classical.choose_spec <| IsCartesian.universal_property (p := p) (f := f) (φ := φ) φ').1.1
@[reassoc (attr := simp)]
lemma fac : IsCartesian.map p f φ φ' ≫ φ = φ' :=
(Classical.choose_spec <| IsCartesian.universal_property (p := p) (f := f) (φ := φ) φ').1.2
/-- Given a cartesian morphism `φ : a ⟶ b` lying over `f : R ⟶ S` in `𝒳`, and another morphism
`φ' : a' ⟶ b` which also lifts `f`. Then any morphism `ψ : a' ⟶ a` lifting `𝟙 R` such that
`g ≫ ψ = φ'` must equal the map induced from the universal property of `φ`. -/
lemma map_uniq (ψ : a' ⟶ a) [IsHomLift p (𝟙 R) ψ] (hψ : ψ ≫ φ = φ') :
ψ = IsCartesian.map p f φ φ' :=
(Classical.choose_spec <| IsCartesian.universal_property (p := p) (f := f) (φ := φ) φ').2
ψ ⟨inferInstance, hψ⟩
end
/-- Given a cartesian morphism `φ : a ⟶ b` lying over `f : R ⟶ S` in `𝒳`, and two morphisms
`ψ ψ' : a' ⟶ a` such that `ψ ≫ φ = ψ' ≫ φ`. Then we must have `ψ = ψ'`. -/
protected lemma ext (φ : a ⟶ b) [IsCartesian p f φ] {a' : 𝒳} (ψ ψ' : a' ⟶ a)
[IsHomLift p (𝟙 R) ψ] [IsHomLift p (𝟙 R) ψ'] (h : ψ ≫ φ = ψ' ≫ φ) : ψ = ψ' := by
rw [map_uniq p f φ (ψ ≫ φ) ψ rfl, map_uniq p f φ (ψ ≫ φ) ψ' h.symm]
@[simp]
lemma map_self : IsCartesian.map p f φ φ = 𝟙 a := by
subst_hom_lift p f φ; symm
apply map_uniq
simp only [id_comp]
/-- The canonical isomorphism between the domains of two cartesian morphisms
lying over the same object. -/
noncomputable def domainUniqueUpToIso {a' : 𝒳} (φ' : a' ⟶ b) [IsCartesian p f φ'] : a' ≅ a where
hom := IsCartesian.map p f φ φ'
inv := IsCartesian.map p f φ' φ
hom_inv_id := by
subst_hom_lift p f φ'
apply IsCartesian.ext p (p.map φ') φ'
simp only [assoc, fac, id_comp]
inv_hom_id := by
subst_hom_lift p f φ
apply IsCartesian.ext p (p.map φ) φ
simp only [assoc, fac, id_comp]
/-- Precomposing a cartesian morphism with an isomorphism lifting the identity is cartesian. -/
instance of_iso_comp {a' : 𝒳} (φ' : a' ≅ a) [IsHomLift p (𝟙 R) φ'.hom] :
IsCartesian p f (φ'.hom ≫ φ) where
universal_property := by
intro c ψ hψ
use IsCartesian.map p f φ ψ ≫ φ'.inv
refine ⟨⟨inferInstance, by simp⟩, ?_⟩
rintro τ ⟨hτ₁, hτ₂⟩
rw [Iso.eq_comp_inv]
apply map_uniq
simp only [assoc, hτ₂]
/-- Postcomposing a cartesian morphism with an isomorphism lifting the identity is cartesian. -/
instance of_comp_iso {b' : 𝒳} (φ' : b ≅ b') [IsHomLift p (𝟙 S) φ'.hom] :
IsCartesian p f (φ ≫ φ'.hom) where
universal_property := by
intro c ψ hψ
use IsCartesian.map p f φ (ψ ≫ φ'.inv)
refine ⟨⟨inferInstance, by simp⟩, ?_⟩
rintro τ ⟨hτ₁, hτ₂⟩
apply map_uniq
simp only [Iso.eq_comp_inv, assoc, hτ₂]
end IsCartesian
namespace IsStronglyCartesian
section
variable {R S : 𝒮} {a b : 𝒳} (f : R ⟶ S) (φ : a ⟶ b) [IsStronglyCartesian p f φ]
/-- The universal property of a strongly cartesian morphism.
This lemma is more flexible with respect to non-definitional equalities than the field
`universal_property'` of `IsStronglyCartesian`. -/
lemma universal_property {R' : 𝒮} {a' : 𝒳} (g : R' ⟶ R) (f' : R' ⟶ S) (hf' : f' = g ≫ f)
(φ' : a' ⟶ b) [IsHomLift p f' φ'] : ∃! χ : a' ⟶ a, IsHomLift p g χ ∧ χ ≫ φ = φ' := by
subst_hom_lift p f' φ'; clear a b R S
have : p.IsHomLift (g ≫ f) φ' := (hf' ▸ inferInstance)
apply IsStronglyCartesian.universal_property' f
instance isCartesian_of_isStronglyCartesian [p.IsStronglyCartesian f φ] : p.IsCartesian f φ where
universal_property := fun φ' => universal_property p f φ (𝟙 R) f (by simp) φ'
section
variable {R' : 𝒮} {a' : 𝒳} {g : R' ⟶ R} {f' : R' ⟶ S} (hf' : f' = g ≫ f) (φ' : a' ⟶ b)
[IsHomLift p f' φ']
/-- Given a diagram
```
a' a --φ--> b
| | |
v v v
R' --g--> R --f--> S
```
such that `φ` is strongly cartesian, and a morphism `φ' : a' ⟶ b`. Then `map` is the map `a' ⟶ a`
lying over `g` obtained from the universal property of `φ`. -/
noncomputable def map : a' ⟶ a :=
Classical.choose <| universal_property p f φ _ _ hf' φ'
instance map_isHomLift : IsHomLift p g (map p f φ hf' φ') :=
(Classical.choose_spec <| universal_property p f φ _ _ hf' φ').1.1
@[reassoc (attr := simp)]
lemma fac : (map p f φ hf' φ') ≫ φ = φ' :=
(Classical.choose_spec <| universal_property p f φ _ _ hf' φ').1.2
/-- Given a diagram
```
a' a --φ--> b
| | |
v v v
R' --g--> R --f--> S
```
such that `φ` is strongly cartesian, and morphisms `φ' : a' ⟶ b`, `ψ : a' ⟶ a` such that
`ψ ≫ φ = φ'`. Then `ψ` is the map induced by the universal property. -/
lemma map_uniq (ψ : a' ⟶ a) [IsHomLift p g ψ] (hψ : ψ ≫ φ = φ') : ψ = map p f φ hf' φ' :=
(Classical.choose_spec <| universal_property p f φ _ _ hf' φ').2 ψ ⟨inferInstance, hψ⟩
end
/-- Given a diagram
```
a' a --φ--> b
| | |
v v v
R' --g--> R --f--> S
```
such that `φ` is strongly cartesian, and morphisms `ψ ψ' : a' ⟶ a` such that
`g ≫ ψ = φ' = g ≫ ψ'`. Then we have that `ψ = ψ'`. -/
protected lemma ext (φ : a ⟶ b) [IsStronglyCartesian p f φ] {R' : 𝒮} {a' : 𝒳} (g : R' ⟶ R)
{ψ ψ' : a' ⟶ a} [IsHomLift p g ψ] [IsHomLift p g ψ'] (h : ψ ≫ φ = ψ' ≫ φ) : ψ = ψ' := by
rw [map_uniq p f φ (g := g) rfl (ψ ≫ φ) ψ rfl, map_uniq p f φ (g := g) rfl (ψ ≫ φ) ψ' h.symm]
@[simp]
lemma map_self : map p f φ (id_comp f).symm φ = 𝟙 a := by
subst_hom_lift p f φ; symm
apply map_uniq
simp only [id_comp]
/-- When its possible to compare the two, the composition of two `IsCocartesian.map` will also be
given by a `IsCocartesian.map`. In other words, given diagrams
```
a'' a' a --φ--> b a' --φ'--> b a'' --φ''--> b
| | | | and | | and | |
v v v v v v v v
R'' --g'--> R' --g--> R --f--> S R' --f'--> S R'' --f''--> S
```
such that `φ` and `φ'` are strongly cartesian morphisms. Then composing the induced map from
`a'' ⟶ a'` with the induced map from `a' ⟶ a` gives the induced map from `a'' ⟶ a`. -/
@[reassoc (attr := simp)]
lemma map_comp_map {R' R'' : 𝒮} {a' a'' : 𝒳} {f' : R' ⟶ S} {f'' : R'' ⟶ S} {g : R' ⟶ R}
{g' : R'' ⟶ R'} (H : f' = g ≫ f) (H' : f'' = g' ≫ f') (φ' : a' ⟶ b) (φ'' : a'' ⟶ b)
[IsStronglyCartesian p f' φ'] [IsHomLift p f'' φ''] :
map p f' φ' H' φ'' ≫ map p f φ H φ' =
map p f φ (show f'' = (g' ≫ g) ≫ f by rwa [assoc, ← H]) φ'' := by
apply map_uniq p f φ
simp only [assoc, fac]
end
section
variable {R S T : 𝒮} {a b c : 𝒳} {f : R ⟶ S} {g : S ⟶ T} {φ : a ⟶ b} {ψ : b ⟶ c}
/-- Given two strongly cartesian morphisms `φ`, `ψ` as follows
```
a --φ--> b --ψ--> c
| | |
v v v
R --f--> S --g--> T
```
Then the composite `φ ≫ ψ` is also strongly cartesian. -/
instance comp [IsStronglyCartesian p f φ] [IsStronglyCartesian p g ψ] :
IsStronglyCartesian p (f ≫ g) (φ ≫ ψ) where
universal_property' := by
intro a' h τ hτ
use map p f φ (f' := h ≫ f) rfl (map p g ψ (assoc h f g).symm τ)
refine ⟨⟨inferInstance, ?_⟩, ?_⟩
· rw [← assoc, fac, fac]
· intro π' ⟨hπ'₁, hπ'₂⟩
apply map_uniq
apply map_uniq
simp only [assoc, hπ'₂]
/-- Given two commutative squares
```
a --φ--> b --ψ--> c
| | |
v v v
R --f--> S --g--> T
```
such that `φ ≫ ψ` and `ψ` are strongly cartesian, then so is `φ`. -/
protected lemma of_comp [IsStronglyCartesian p g ψ] [IsStronglyCartesian p (f ≫ g) (φ ≫ ψ)]
[IsHomLift p f φ] : IsStronglyCartesian p f φ where
universal_property' := by
intro a' h τ hτ
have h₁ : IsHomLift p (h ≫ f ≫ g) (τ ≫ ψ) := by simpa using IsHomLift.comp p (h ≫ f) _ τ ψ
/- We get a morphism `π : a' ⟶ a` such that `π ≫ φ ≫ ψ = τ ≫ ψ` from the universal property
of `φ ≫ ψ`. This will be the morphism induced by `φ`. -/
use map p (f ≫ g) (φ ≫ ψ) (f' := h ≫ f ≫ g) rfl (τ ≫ ψ)
refine ⟨⟨inferInstance, ?_⟩, ?_⟩
/- The fact that `π ≫ φ = τ` follows from `π ≫ φ ≫ ψ = τ ≫ ψ` and the universal property of
`ψ`. -/
· apply IsStronglyCartesian.ext p g ψ (h ≫ f) (by simp)
-- Finally, the uniqueness of `π` comes from the universal property of `φ ≫ ψ`.
· intro π' ⟨hπ'₁, hπ'₂⟩
apply map_uniq
simp [hπ'₂.symm]
end
section
variable {R S : 𝒮} {a b : 𝒳} (f : R ⟶ S)
instance of_iso (φ : a ≅ b) [IsHomLift p f φ.hom] : IsStronglyCartesian p f φ.hom where
universal_property' := by
intro a' g τ hτ
use τ ≫ φ.inv
refine ⟨?_, by aesop_cat⟩
simpa using (IsHomLift.comp p (g ≫ f) (isoOfIsoLift p f φ).inv τ φ.inv)
instance of_isIso (φ : a ⟶ b) [IsHomLift p f φ] [IsIso φ] : IsStronglyCartesian p f φ :=
@IsStronglyCartesian.of_iso _ _ _ _ p _ _ _ _ f (asIso φ) (by aesop)
/-- A strongly cartesian morphism lying over an isomorphism is an isomorphism. -/
lemma isIso_of_base_isIso (φ : a ⟶ b) [IsStronglyCartesian p f φ] [IsIso f] : IsIso φ := by
subst_hom_lift p f φ; clear a b R S
-- Let `φ` be the morphism induced by applying universal property to `𝟙 b` lying over `f⁻¹ ≫ f`.
let φ' := map p (p.map φ) φ (IsIso.inv_hom_id (p.map φ)).symm (𝟙 b)
use φ'
-- `φ' ≫ φ = 𝟙 b` follows immediately from the universal property.
have inv_hom : φ' ≫ φ = 𝟙 b := fac p (p.map φ) φ _ (𝟙 b)
refine ⟨?_, inv_hom⟩
-- We will now show that `φ ≫ φ' = 𝟙 a` by showing that `(φ ≫ φ') ≫ φ = 𝟙 a ≫ φ`.
have h₁ : IsHomLift p (𝟙 (p.obj a)) (φ ≫ φ') := by
rw [← IsIso.hom_inv_id (p.map φ)]
apply IsHomLift.comp
apply IsStronglyCartesian.ext p (p.map φ) φ (𝟙 (p.obj a))
simp only [assoc, inv_hom, comp_id, id_comp]
end
/-- The canonical isomorphism between the domains of two strongly cartesian morphisms lying over
isomorphic objects. -/
noncomputable def domainIsoOfBaseIso {R R' S : 𝒮} {a a' b : 𝒳} {f : R ⟶ S} {f' : R' ⟶ S}
{g : R' ≅ R} (h : f' = g.hom ≫ f) (φ : a ⟶ b) (φ' : a' ⟶ b) [IsStronglyCartesian p f φ]
[IsStronglyCartesian p f' φ'] : a' ≅ a where
hom := map p f φ h φ'
inv := by
convert map p f' φ' (congrArg (g.inv ≫ ·) h.symm) φ
simpa using IsCartesian.toIsHomLift
end IsStronglyCartesian
end CategoryTheory.Functor
|
CategoryTheory\FiberedCategory\HomLift.lean | /-
Copyright (c) 2024 Calle Sönne. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Paul Lezeau, Calle Sönne
-/
import Mathlib.CategoryTheory.Functor.Category
import Mathlib.CategoryTheory.CommSq
/-!
# HomLift
Given a functor `p : 𝒳 ⥤ 𝒮`, this file provides API for expressing the fact that `p(φ) = f`
for given morphisms `φ` and `f`. The reason this API is needed is because, in general, `p.map φ = f`
does not make sense when the domain and/or codomain of `φ` and `f` are not definitionally equal.
## Main definition
Given morphism `φ : a ⟶ b` in `𝒳` and `f : R ⟶ S` in `𝒮`, `p.IsHomLift f φ` is a class, defined
using the auxillary inductive type `IsHomLiftAux` which expresses the fact that `f = p(φ)`.
We also define a macro `subst_hom_lift p f φ` which can be used to substitute `f` with `p(φ)` in a
goal, this tactic is just short for `obtain ⟨⟩ := Functor.IsHomLift.cond (p:=p) (f:=f) (φ:=φ)`, and
it is used to make the code more readable.
-/
universe u₁ v₁ u₂ v₂
open CategoryTheory Category
variable {𝒮 : Type u₁} {𝒳 : Type u₂} [Category.{v₁} 𝒳] [Category.{v₂} 𝒮] (p : 𝒳 ⥤ 𝒮)
namespace CategoryTheory
/-- Helper-type for defining `IsHomLift`. -/
inductive IsHomLiftAux : ∀ {R S : 𝒮} {a b : 𝒳} (_ : R ⟶ S) (_ : a ⟶ b), Prop
| map {a b : 𝒳} (φ : a ⟶ b) : IsHomLiftAux (p.map φ) φ
/-- Given a functor `p : 𝒳 ⥤ 𝒮`, an arrow `φ : a ⟶ b` in `𝒳` and an arrow `f : R ⟶ S` in `𝒮`,
`p.IsHomLift f φ` expresses the fact that `φ` lifts `f` through `p`.
This is often drawn as:
```
a --φ--> b
- -
| |
v v
R --f--> S
``` -/
class Functor.IsHomLift {R S : 𝒮} {a b : 𝒳} (f : R ⟶ S) (φ : a ⟶ b) : Prop where
cond : IsHomLiftAux p f φ
/-- `subst_hom_lift p f φ` tries to substitute `f` with `p(φ)` by using `p.IsHomLift f φ` -/
macro "subst_hom_lift" p:ident f:ident φ:ident : tactic =>
`(tactic| obtain ⟨⟩ := Functor.IsHomLift.cond (p := $p) (f := $f) (φ := $φ))
/-- For any arrow `φ : a ⟶ b` in `𝒳`, `φ` lifts the arrow `p.map φ` in the base `𝒮`-/
@[simp]
instance {a b : 𝒳} (φ : a ⟶ b) : p.IsHomLift (p.map φ) φ where
cond := by constructor
@[simp]
instance (a : 𝒳) : p.IsHomLift (𝟙 (p.obj a)) (𝟙 a) := by
rw [← p.map_id]; infer_instance
namespace IsHomLift
protected lemma id {p : 𝒳 ⥤ 𝒮} {R : 𝒮} {a : 𝒳} (ha : p.obj a = R) : p.IsHomLift (𝟙 R) (𝟙 a) := by
cases ha; infer_instance
section
variable {R S : 𝒮} {a b : 𝒳}
lemma domain_eq (f : R ⟶ S) (φ : a ⟶ b) [p.IsHomLift f φ] : p.obj a = R := by
subst_hom_lift p f φ; rfl
lemma codomain_eq (f : R ⟶ S) (φ : a ⟶ b) [p.IsHomLift f φ] : p.obj b = S := by
subst_hom_lift p f φ; rfl
variable (f : R ⟶ S) (φ : a ⟶ b) [p.IsHomLift f φ]
lemma fac : f = eqToHom (domain_eq p f φ).symm ≫ p.map φ ≫ eqToHom (codomain_eq p f φ) := by
subst_hom_lift p f φ; simp
lemma fac' : p.map φ = eqToHom (domain_eq p f φ) ≫ f ≫ eqToHom (codomain_eq p f φ).symm := by
subst_hom_lift p f φ; simp
lemma commSq : CommSq (p.map φ) (eqToHom (domain_eq p f φ)) (eqToHom (codomain_eq p f φ)) f where
w := by simp only [fac p f φ, eqToHom_trans_assoc, eqToHom_refl, id_comp]
end
lemma eq_of_isHomLift {a b : 𝒳} (f : p.obj a ⟶ p.obj b) (φ : a ⟶ b) [p.IsHomLift f φ] :
f = p.map φ := by
simp only [fac p f φ, eqToHom_refl, comp_id, id_comp]
lemma of_fac {R S : 𝒮} {a b : 𝒳} (f : R ⟶ S) (φ : a ⟶ b) (ha : p.obj a = R) (hb : p.obj b = S)
(h : f = eqToHom ha.symm ≫ p.map φ ≫ eqToHom hb) : p.IsHomLift f φ := by
subst ha hb h; simp
lemma of_fac' {R S : 𝒮} {a b : 𝒳} (f : R ⟶ S) (φ : a ⟶ b) (ha : p.obj a = R) (hb : p.obj b = S)
(h : p.map φ = eqToHom ha ≫ f ≫ eqToHom hb.symm) : p.IsHomLift f φ := by
subst ha hb
obtain rfl : f = p.map φ := by simpa using h.symm
infer_instance
lemma of_commSq {R S : 𝒮} {a b : 𝒳} (f : R ⟶ S) (φ : a ⟶ b) (ha : p.obj a = R) (hb : p.obj b = S)
(h : CommSq (p.map φ) (eqToHom ha) (eqToHom hb) f) : p.IsHomLift f φ := by
subst ha hb
obtain rfl : f = p.map φ := by simpa using h.1.symm
infer_instance
instance comp {R S T : 𝒮} {a b c : 𝒳} (f : R ⟶ S) (g : S ⟶ T) (φ : a ⟶ b)
(ψ : b ⟶ c) [p.IsHomLift f φ] [p.IsHomLift g ψ] : p.IsHomLift (f ≫ g) (φ ≫ ψ) := by
apply of_commSq
-- This line transforms the first goal in suitable form; the last line closes all three goals.
on_goal 1 => rw [p.map_comp]
apply CommSq.horiz_comp (commSq p f φ) (commSq p g ψ)
/-- If `φ : a ⟶ b` and `ψ : b ⟶ c` lift `𝟙 R`, then so does `φ ≫ ψ` -/
instance lift_id_comp (R : 𝒮) {a b c : 𝒳} (φ : a ⟶ b) (ψ : b ⟶ c)
[p.IsHomLift (𝟙 R) φ] [p.IsHomLift (𝟙 R) ψ] : p.IsHomLift (𝟙 R) (φ ≫ ψ) :=
comp_id (𝟙 R) ▸ comp p (𝟙 R) (𝟙 R) φ ψ
instance comp_lift_id_right {a b c : 𝒳} {S T : 𝒮} (f : S ⟶ T) (φ : a ⟶ b) [p.IsHomLift f φ]
(ψ : b ⟶ c) [p.IsHomLift (𝟙 T) ψ] : p.IsHomLift f (φ ≫ ψ) := by
simpa using inferInstanceAs (p.IsHomLift (f ≫ 𝟙 T) (φ ≫ ψ))
/-- If `φ : a ⟶ b` lifts `f` and `ψ : b ⟶ c` lifts `𝟙 T`, then `φ ≫ ψ` lifts `f` -/
lemma comp_lift_id_right' {R S : 𝒮} {a b c : 𝒳} (f : R ⟶ S) (φ : a ⟶ b) [p.IsHomLift f φ]
(T : 𝒮) (ψ : b ⟶ c) [p.IsHomLift (𝟙 T) ψ] : p.IsHomLift f (φ ≫ ψ) := by
obtain rfl : S = T := by rw [← codomain_eq p f φ, domain_eq p (𝟙 T) ψ]
infer_instance
instance comp_lift_id_left {a b c : 𝒳} {S T : 𝒮} (f : S ⟶ T) (ψ : b ⟶ c) [p.IsHomLift f ψ]
(φ : a ⟶ b) [p.IsHomLift (𝟙 S) φ] : p.IsHomLift f (φ ≫ ψ) := by
simpa using inferInstanceAs (p.IsHomLift (𝟙 S ≫ f) (φ ≫ ψ))
/-- If `φ : a ⟶ b` lifts `𝟙 T` and `ψ : b ⟶ c` lifts `f`, then `φ ≫ ψ` lifts `f` -/
lemma comp_lift_id_left' {a b c : 𝒳} (R : 𝒮) (φ : a ⟶ b) [p.IsHomLift (𝟙 R) φ]
{S T : 𝒮} (f : S ⟶ T) (ψ : b ⟶ c) [p.IsHomLift f ψ] : p.IsHomLift f (φ ≫ ψ) := by
obtain rfl : R = S := by rw [← codomain_eq p (𝟙 R) φ, domain_eq p f ψ]
simpa using inferInstanceAs (p.IsHomLift (𝟙 R ≫ f) (φ ≫ ψ))
lemma eqToHom_domain_lift_id {p : 𝒳 ⥤ 𝒮} {a b : 𝒳} (hab : a = b) {R : 𝒮} (hR : p.obj a = R) :
p.IsHomLift (𝟙 R) (eqToHom hab) := by
subst hR hab; simp
lemma eqToHom_codomain_lift_id {p : 𝒳 ⥤ 𝒮} {a b : 𝒳} (hab : a = b) {S : 𝒮} (hS : p.obj b = S) :
p.IsHomLift (𝟙 S) (eqToHom hab) := by
subst hS hab; simp
lemma id_lift_eqToHom_domain {p : 𝒳 ⥤ 𝒮} {R S : 𝒮} (hRS : R = S) {a : 𝒳} (ha : p.obj a = R) :
p.IsHomLift (eqToHom hRS) (𝟙 a) := by
subst hRS ha; simp
lemma id_lift_eqToHom_codomain {p : 𝒳 ⥤ 𝒮} {R S : 𝒮} (hRS : R = S) {b : 𝒳} (hb : p.obj b = S) :
p.IsHomLift (eqToHom hRS) (𝟙 b) := by
subst hRS hb; simp
instance comp_eqToHom_lift {R S : 𝒮} {a' a b : 𝒳} (f : R ⟶ S) (φ : a ⟶ b) (h : a' = a)
[p.IsHomLift f φ] : p.IsHomLift f (eqToHom h ≫ φ) := by
subst h; simp_all
instance eqToHom_comp_lift {R S : 𝒮} {a b b' : 𝒳} (f : R ⟶ S) (φ : a ⟶ b) (h : b = b')
[p.IsHomLift f φ] : p.IsHomLift f (φ ≫ eqToHom h) := by
subst h; simp_all
instance lift_eqToHom_comp {R' R S : 𝒮} {a b : 𝒳} (f : R ⟶ S) (φ : a ⟶ b) (h : R' = R)
[p.IsHomLift f φ] : p.IsHomLift (eqToHom h ≫ f) φ := by
subst h; simp_all
instance lift_comp_eqToHom {R S S' : 𝒮} {a b : 𝒳} (f : R ⟶ S) (φ : a ⟶ b) (h : S = S')
[p.IsHomLift f φ] : p.IsHomLift (f ≫ eqToHom h) φ := by
subst h; simp_all
@[simp]
lemma comp_eqToHom_lift_iff {R S : 𝒮} {a' a b : 𝒳} (f : R ⟶ S) (φ : a ⟶ b) (h : a' = a) :
p.IsHomLift f (eqToHom h ≫ φ) ↔ p.IsHomLift f φ where
mp hφ' := by subst h; simpa using hφ'
mpr hφ := inferInstance
@[simp]
lemma eqToHom_comp_lift_iff {R S : 𝒮} {a b b' : 𝒳} (f : R ⟶ S) (φ : a ⟶ b) (h : b = b') :
p.IsHomLift f (φ ≫ eqToHom h) ↔ p.IsHomLift f φ where
mp hφ' := by subst h; simpa using hφ'
mpr hφ := inferInstance
@[simp]
lemma lift_eqToHom_comp_iff {R' R S : 𝒮} {a b : 𝒳} (f : R ⟶ S) (φ : a ⟶ b) (h : R' = R) :
p.IsHomLift (eqToHom h ≫ f) φ ↔ p.IsHomLift f φ where
mp hφ' := by subst h; simpa using hφ'
mpr hφ := inferInstance
@[simp]
lemma lift_comp_eqToHom_iff {R S S' : 𝒮} {a b : 𝒳} (f : R ⟶ S) (φ : a ⟶ b) (h : S = S') :
p.IsHomLift (f ≫ eqToHom h) φ ↔ p.IsHomLift f φ where
mp := fun hφ' => by subst h; simpa using hφ'
mpr := fun hφ => inferInstance
section
variable {R S : 𝒮} {a b : 𝒳}
/-- Given a morphism `f : R ⟶ S`, and an isomorphism `φ : a ≅ b` lifting `f`, `isoOfIsoLift f φ` is
the isomorphism `Φ : R ≅ S` with `Φ.hom = f` induced from `φ` -/
@[simps hom]
def isoOfIsoLift (f : R ⟶ S) (φ : a ≅ b) [p.IsHomLift f φ.hom] :
R ≅ S where
hom := f
inv := eqToHom (codomain_eq p f φ.hom).symm ≫ (p.mapIso φ).inv ≫ eqToHom (domain_eq p f φ.hom)
hom_inv_id := by subst_hom_lift p f φ.hom; simp [← p.map_comp]
inv_hom_id := by subst_hom_lift p f φ.hom; simp [← p.map_comp]
@[simp]
lemma isoOfIsoLift_inv_hom_id (f : R ⟶ S) (φ : a ≅ b) [p.IsHomLift f φ.hom] :
(isoOfIsoLift p f φ).inv ≫ f = 𝟙 S :=
(isoOfIsoLift p f φ).inv_hom_id
@[simp]
lemma isoOfIsoLift_hom_inv_id (f : R ⟶ S) (φ : a ≅ b) [p.IsHomLift f φ.hom] :
f ≫ (isoOfIsoLift p f φ).inv = 𝟙 R :=
(isoOfIsoLift p f φ).hom_inv_id
/-- If `φ : a ⟶ b` lifts `f : R ⟶ S` and `φ` is an isomorphism, then so is `f`. -/
lemma isIso_of_lift_isIso (f : R ⟶ S) (φ : a ⟶ b) [p.IsHomLift f φ] [IsIso φ] : IsIso f :=
(fac p f φ) ▸ inferInstance
/-- Given `φ : a ≅ b` and `f : R ≅ S`, such that `φ.hom` lifts `f.hom`, then `φ.inv` lifts
`f.inv`. -/
instance inv_lift_inv (f : R ≅ S) (φ : a ≅ b) [p.IsHomLift f.hom φ.hom] :
p.IsHomLift f.inv φ.inv := by
apply of_commSq
apply CommSq.horiz_inv (f := p.mapIso φ) (commSq p f.hom φ.hom)
/-- Given `φ : a ≅ b` and `f : R ⟶ S`, such that `φ.hom` lifts `f`, then `φ.inv` lifts the
inverse of `f` given by `isoOfIsoLift`. -/
instance inv_lift (f : R ⟶ S) (φ : a ≅ b) [p.IsHomLift f φ.hom] :
p.IsHomLift (isoOfIsoLift p f φ).inv φ.inv := by
apply of_commSq
apply CommSq.horiz_inv (f := p.mapIso φ) (by apply commSq p f φ.hom)
/-- If `φ : a ⟶ b` lifts `f : R ⟶ S` and both are isomorphisms, then `φ⁻¹` lifts `f⁻¹`. -/
protected instance inv (f : R ⟶ S) (φ : a ⟶ b) [IsIso f] [IsIso φ] [p.IsHomLift f φ] :
p.IsHomLift (inv f) (inv φ) :=
have : p.IsHomLift (asIso f).hom (asIso φ).hom := by simp_all
IsHomLift.inv_lift_inv p (asIso f) (asIso φ)
end
/-- If `φ : a ≅ b` is an isomorphism lifting `𝟙 S` for some `S : 𝒮`, then `φ⁻¹` also
lifts `𝟙 S`. -/
instance lift_id_inv (S : 𝒮) {a b : 𝒳} (φ : a ≅ b) [p.IsHomLift (𝟙 S) φ.hom] :
p.IsHomLift (𝟙 S) φ.inv :=
have : p.IsHomLift (asIso (𝟙 S)).hom φ.hom := by simp_all
(IsIso.inv_id (X := S)) ▸ (IsHomLift.inv_lift_inv p (asIso (𝟙 S)) φ)
instance lift_id_inv_isIso (S : 𝒮) {a b : 𝒳} (φ : a ⟶ b) [IsIso φ] [p.IsHomLift (𝟙 S) φ] :
p.IsHomLift (𝟙 S) (inv φ) :=
(IsIso.inv_id (X := S)) ▸ (IsHomLift.inv p _ φ)
end IsHomLift
end CategoryTheory
|
CategoryTheory\Filtered\Basic.lean | /-
Copyright (c) 2019 Reid Barton. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Reid Barton, Scott Morrison
-/
import Mathlib.CategoryTheory.FinCategory.Basic
import Mathlib.CategoryTheory.Limits.Cones
import Mathlib.CategoryTheory.Limits.Shapes.FiniteLimits
import Mathlib.CategoryTheory.Adjunction.Basic
import Mathlib.CategoryTheory.Category.Preorder
import Mathlib.CategoryTheory.Category.ULift
import Mathlib.CategoryTheory.PEmpty
/-!
# Filtered categories
A category is filtered if every finite diagram admits a cocone.
We give a simple characterisation of this condition as
1. for every pair of objects there exists another object "to the right",
2. for every pair of parallel morphisms there exists a morphism to the right so the compositions
are equal, and
3. there exists some object.
Filtered colimits are often better behaved than arbitrary colimits.
See `CategoryTheory/Limits/Types` for some details.
Filtered categories are nice because colimits indexed by filtered categories tend to be
easier to describe than general colimits (and more often preserved by functors).
In this file we show that any functor from a finite category to a filtered category admits a cocone:
* `cocone_nonempty [FinCategory J] [IsFiltered C] (F : J ⥤ C) : Nonempty (Cocone F)`
More generally,
for any finite collection of objects and morphisms between them in a filtered category
(even if not closed under composition) there exists some object `Z` receiving maps from all of them,
so that all the triangles (one edge from the finite set, two from morphisms to `Z`) commute.
This formulation is often more useful in practice and is available via `sup_exists`,
which takes a finset of objects, and an indexed family (indexed by source and target)
of finsets of morphisms.
We also prove the converse of `cocone_nonempty` as `of_cocone_nonempty`.
Furthermore, we give special support for two diagram categories: The `bowtie` and the `tulip`.
This is because these shapes show up in the proofs that forgetful functors of algebraic categories
(e.g. `MonCat`, `CommRingCat`, ...) preserve filtered colimits.
All of the above API, except for the `bowtie` and the `tulip`, is also provided for cofiltered
categories.
## See also
In `CategoryTheory.Limits.FilteredColimitCommutesFiniteLimit` we show that filtered colimits
commute with finite limits.
There is another characterization of filtered categories, namely that whenever `F : J ⥤ C` is a
functor from a finite category, there is `X : C` such that `Nonempty (limit (F.op ⋙ yoneda.obj X))`.
This is shown in `CategoryTheory.Limits.Filtered`.
-/
open Function
-- declare the `v`'s first; see `CategoryTheory.Category` for an explanation
universe w v v₁ u u₁ u₂
namespace CategoryTheory
variable (C : Type u) [Category.{v} C]
/-- A category `IsFilteredOrEmpty` if
1. for every pair of objects there exists another object "to the right", and
2. for every pair of parallel morphisms there exists a morphism to the right so the compositions
are equal.
-/
class IsFilteredOrEmpty : Prop where
/-- for every pair of objects there exists another object "to the right" -/
cocone_objs : ∀ X Y : C, ∃ (Z : _) (_ : X ⟶ Z) (_ : Y ⟶ Z), True
/-- for every pair of parallel morphisms there exists a morphism to the right
so the compositions are equal -/
cocone_maps : ∀ ⦃X Y : C⦄ (f g : X ⟶ Y), ∃ (Z : _) (h : Y ⟶ Z), f ≫ h = g ≫ h
/-- A category `IsFiltered` if
1. for every pair of objects there exists another object "to the right",
2. for every pair of parallel morphisms there exists a morphism to the right so the compositions
are equal, and
3. there exists some object.
See <https://stacks.math.columbia.edu/tag/002V>. (They also define a diagram being filtered.)
-/
class IsFiltered extends IsFilteredOrEmpty C : Prop where
/-- a filtered category must be non empty -/
[nonempty : Nonempty C]
instance (priority := 100) isFilteredOrEmpty_of_semilatticeSup (α : Type u) [SemilatticeSup α] :
IsFilteredOrEmpty α where
cocone_objs X Y := ⟨X ⊔ Y, homOfLE le_sup_left, homOfLE le_sup_right, trivial⟩
cocone_maps X Y f g := ⟨Y, 𝟙 _, by subsingleton⟩
instance (priority := 100) isFiltered_of_semilatticeSup_nonempty (α : Type u) [SemilatticeSup α]
[Nonempty α] : IsFiltered α where
instance (priority := 100) isFilteredOrEmpty_of_directed_le (α : Type u) [Preorder α]
[IsDirected α (· ≤ ·)] : IsFilteredOrEmpty α where
cocone_objs X Y :=
let ⟨Z, h1, h2⟩ := exists_ge_ge X Y
⟨Z, homOfLE h1, homOfLE h2, trivial⟩
cocone_maps X Y f g := ⟨Y, 𝟙 _, by subsingleton⟩
instance (priority := 100) isFiltered_of_directed_le_nonempty (α : Type u) [Preorder α]
[IsDirected α (· ≤ ·)] [Nonempty α] : IsFiltered α where
-- Sanity checks
example (α : Type u) [SemilatticeSup α] [OrderBot α] : IsFiltered α := by infer_instance
example (α : Type u) [SemilatticeSup α] [OrderTop α] : IsFiltered α := by infer_instance
instance : IsFiltered (Discrete PUnit) where
cocone_objs X Y := ⟨⟨PUnit.unit⟩, ⟨⟨by trivial⟩⟩, ⟨⟨by subsingleton⟩⟩, trivial⟩
cocone_maps X Y f g := ⟨⟨PUnit.unit⟩, ⟨⟨by trivial⟩⟩, by subsingleton⟩
namespace IsFiltered
section AllowEmpty
variable {C}
variable [IsFilteredOrEmpty C]
-- Porting note: the following definitions were removed because the names are invalid,
-- direct references to `IsFilteredOrEmpty` have been added instead
--
-- theorem cocone_objs : ∀ X Y : C, ∃ (Z : _) (f : X ⟶ Z) (g : Y ⟶ Z), True :=
-- IsFilteredOrEmpty.cocone_objs
--
--theorem cocone_maps : ∀ ⦃X Y : C⦄ (f g : X ⟶ Y), ∃ (Z : _) (h : Y ⟶ Z), f ≫ h = g ≫ h :=
-- IsFilteredOrEmpty.cocone_maps
/-- `max j j'` is an arbitrary choice of object to the right of both `j` and `j'`,
whose existence is ensured by `IsFiltered`.
-/
noncomputable def max (j j' : C) : C :=
(IsFilteredOrEmpty.cocone_objs j j').choose
/-- `leftToMax j j'` is an arbitrary choice of morphism from `j` to `max j j'`,
whose existence is ensured by `IsFiltered`.
-/
noncomputable def leftToMax (j j' : C) : j ⟶ max j j' :=
(IsFilteredOrEmpty.cocone_objs j j').choose_spec.choose
/-- `rightToMax j j'` is an arbitrary choice of morphism from `j'` to `max j j'`,
whose existence is ensured by `IsFiltered`.
-/
noncomputable def rightToMax (j j' : C) : j' ⟶ max j j' :=
(IsFilteredOrEmpty.cocone_objs j j').choose_spec.choose_spec.choose
/-- `coeq f f'`, for morphisms `f f' : j ⟶ j'`, is an arbitrary choice of object
which admits a morphism `coeqHom f f' : j' ⟶ coeq f f'` such that
`coeq_condition : f ≫ coeqHom f f' = f' ≫ coeqHom f f'`.
Its existence is ensured by `IsFiltered`.
-/
noncomputable def coeq {j j' : C} (f f' : j ⟶ j') : C :=
(IsFilteredOrEmpty.cocone_maps f f').choose
/-- `coeqHom f f'`, for morphisms `f f' : j ⟶ j'`, is an arbitrary choice of morphism
`coeqHom f f' : j' ⟶ coeq f f'` such that
`coeq_condition : f ≫ coeqHom f f' = f' ≫ coeqHom f f'`.
Its existence is ensured by `IsFiltered`.
-/
noncomputable def coeqHom {j j' : C} (f f' : j ⟶ j') : j' ⟶ coeq f f' :=
(IsFilteredOrEmpty.cocone_maps f f').choose_spec.choose
-- Porting note: the simp tag has been removed as the linter complained
/-- `coeq_condition f f'`, for morphisms `f f' : j ⟶ j'`, is the proof that
`f ≫ coeqHom f f' = f' ≫ coeqHom f f'`.
-/
@[reassoc]
theorem coeq_condition {j j' : C} (f f' : j ⟶ j') : f ≫ coeqHom f f' = f' ≫ coeqHom f f' :=
(IsFilteredOrEmpty.cocone_maps f f').choose_spec.choose_spec
end AllowEmpty
end IsFiltered
namespace IsFilteredOrEmpty
open IsFiltered
variable {C}
variable [IsFilteredOrEmpty C]
variable {D : Type u₁} [Category.{v₁} D]
/-- If `C` is filtered or empty, and we have a functor `R : C ⥤ D` with a left adjoint, then `D` is
filtered or empty.
-/
theorem of_right_adjoint {L : D ⥤ C} {R : C ⥤ D} (h : L ⊣ R) : IsFilteredOrEmpty D :=
{ cocone_objs := fun X Y =>
⟨R.obj (max (L.obj X) (L.obj Y)),
h.homEquiv _ _ (leftToMax _ _), h.homEquiv _ _ (rightToMax _ _), ⟨⟩⟩
cocone_maps := fun X Y f g =>
⟨R.obj (coeq (L.map f) (L.map g)), h.homEquiv _ _ (coeqHom _ _), by
rw [← h.homEquiv_naturality_left, ← h.homEquiv_naturality_left, coeq_condition]⟩ }
/-- If `C` is filtered or empty, and we have a right adjoint functor `R : C ⥤ D`, then `D` is
filtered or empty. -/
theorem of_isRightAdjoint (R : C ⥤ D) [R.IsRightAdjoint] : IsFilteredOrEmpty D :=
of_right_adjoint (Adjunction.ofIsRightAdjoint R)
/-- Being filtered or empty is preserved by equivalence of categories. -/
theorem of_equivalence (h : C ≌ D) : IsFilteredOrEmpty D :=
of_right_adjoint h.symm.toAdjunction
end IsFilteredOrEmpty
namespace IsFiltered
section Nonempty
open CategoryTheory.Limits
variable {C}
variable [IsFiltered C]
/-- Any finite collection of objects in a filtered category has an object "to the right".
-/
theorem sup_objs_exists (O : Finset C) : ∃ S : C, ∀ {X}, X ∈ O → Nonempty (X ⟶ S) := by
classical
induction' O using Finset.induction with X O' nm h
· exact ⟨Classical.choice IsFiltered.nonempty, by intro; simp⟩
· obtain ⟨S', w'⟩ := h
use max X S'
rintro Y mY
obtain rfl | h := eq_or_ne Y X
· exact ⟨leftToMax _ _⟩
· exact ⟨(w' (Finset.mem_of_mem_insert_of_ne mY h)).some ≫ rightToMax _ _⟩
variable (O : Finset C) (H : Finset (Σ' (X Y : C) (_ : X ∈ O) (_ : Y ∈ O), X ⟶ Y))
/-- Given any `Finset` of objects `{X, ...}` and
indexed collection of `Finset`s of morphisms `{f, ...}` in `C`,
there exists an object `S`, with a morphism `T X : X ⟶ S` from each `X`,
such that the triangles commute: `f ≫ T Y = T X`, for `f : X ⟶ Y` in the `Finset`.
-/
theorem sup_exists :
∃ (S : C) (T : ∀ {X : C}, X ∈ O → (X ⟶ S)),
∀ {X Y : C} (mX : X ∈ O) (mY : Y ∈ O) {f : X ⟶ Y},
(⟨X, Y, mX, mY, f⟩ : Σ' (X Y : C) (_ : X ∈ O) (_ : Y ∈ O), X ⟶ Y) ∈ H →
f ≫ T mY = T mX := by
classical
induction' H using Finset.induction with h' H' nmf h''
· obtain ⟨S, f⟩ := sup_objs_exists O
exact ⟨S, fun mX => (f mX).some, by rintro - - - - - ⟨⟩⟩
· obtain ⟨X, Y, mX, mY, f⟩ := h'
obtain ⟨S', T', w'⟩ := h''
refine ⟨coeq (f ≫ T' mY) (T' mX), fun mZ => T' mZ ≫ coeqHom (f ≫ T' mY) (T' mX), ?_⟩
intro X' Y' mX' mY' f' mf'
rw [← Category.assoc]
by_cases h : X = X' ∧ Y = Y'
· rcases h with ⟨rfl, rfl⟩
by_cases hf : f = f'
· subst hf
apply coeq_condition
· rw [@w' _ _ mX mY f']
simp only [Finset.mem_insert, PSigma.mk.injEq, heq_eq_eq, true_and] at mf'
rcases mf' with mf' | mf'
· exfalso
exact hf mf'.symm
· exact mf'
· rw [@w' _ _ mX' mY' f' _]
apply Finset.mem_of_mem_insert_of_ne mf'
contrapose! h
obtain ⟨rfl, h⟩ := h
trivial
/-- An arbitrary choice of object "to the right"
of a finite collection of objects `O` and morphisms `H`,
making all the triangles commute.
-/
noncomputable def sup : C :=
(sup_exists O H).choose
/-- The morphisms to `sup O H`.
-/
noncomputable def toSup {X : C} (m : X ∈ O) : X ⟶ sup O H :=
(sup_exists O H).choose_spec.choose m
/-- The triangles of consisting of a morphism in `H` and the maps to `sup O H` commute.
-/
theorem toSup_commutes {X Y : C} (mX : X ∈ O) (mY : Y ∈ O) {f : X ⟶ Y}
(mf : (⟨X, Y, mX, mY, f⟩ : Σ' (X Y : C) (_ : X ∈ O) (_ : Y ∈ O), X ⟶ Y) ∈ H) :
f ≫ toSup O H mY = toSup O H mX :=
(sup_exists O H).choose_spec.choose_spec mX mY mf
variable {J : Type w} [SmallCategory J] [FinCategory J]
/-- If we have `IsFiltered C`, then for any functor `F : J ⥤ C` with `FinCategory J`,
there exists a cocone over `F`.
-/
theorem cocone_nonempty (F : J ⥤ C) : Nonempty (Cocone F) := by
classical
let O := Finset.univ.image F.obj
let H : Finset (Σ' (X Y : C) (_ : X ∈ O) (_ : Y ∈ O), X ⟶ Y) :=
Finset.univ.biUnion fun X : J =>
Finset.univ.biUnion fun Y : J =>
Finset.univ.image fun f : X ⟶ Y => ⟨F.obj X, F.obj Y, by simp [O], by simp [O], F.map f⟩
obtain ⟨Z, f, w⟩ := sup_exists O H
refine ⟨⟨Z, ⟨fun X => f (by simp [O]), ?_⟩⟩⟩
intro j j' g
dsimp
simp only [Category.comp_id]
apply w
simp only [O, H, Finset.mem_biUnion, Finset.mem_univ, Finset.mem_image, PSigma.mk.injEq,
true_and, exists_and_left]
exact ⟨j, rfl, j', g, by simp⟩
/-- An arbitrary choice of cocone over `F : J ⥤ C`, for `FinCategory J` and `IsFiltered C`.
-/
noncomputable def cocone (F : J ⥤ C) : Cocone F :=
(cocone_nonempty F).some
variable {D : Type u₁} [Category.{v₁} D]
/-- If `C` is filtered, and we have a functor `R : C ⥤ D` with a left adjoint, then `D` is filtered.
-/
theorem of_right_adjoint {L : D ⥤ C} {R : C ⥤ D} (h : L ⊣ R) : IsFiltered D :=
{ IsFilteredOrEmpty.of_right_adjoint h with
nonempty := IsFiltered.nonempty.map R.obj }
/-- If `C` is filtered, and we have a right adjoint functor `R : C ⥤ D`, then `D` is filtered. -/
theorem of_isRightAdjoint (R : C ⥤ D) [R.IsRightAdjoint] : IsFiltered D :=
of_right_adjoint (Adjunction.ofIsRightAdjoint R)
/-- Being filtered is preserved by equivalence of categories. -/
theorem of_equivalence (h : C ≌ D) : IsFiltered D :=
of_right_adjoint h.symm.toAdjunction
end Nonempty
section OfCocone
open CategoryTheory.Limits
/-- If every finite diagram in `C` admits a cocone, then `C` is filtered. It is sufficient to verify
this for diagrams whose shape lives in any one fixed universe. -/
theorem of_cocone_nonempty (h : ∀ {J : Type w} [SmallCategory J] [FinCategory J] (F : J ⥤ C),
Nonempty (Cocone F)) : IsFiltered C := by
have : Nonempty C := by
obtain ⟨c⟩ := h (Functor.empty _)
exact ⟨c.pt⟩
have : IsFilteredOrEmpty C := by
refine ⟨?_, ?_⟩
· intros X Y
obtain ⟨c⟩ := h (ULiftHom.down ⋙ ULift.downFunctor ⋙ pair X Y)
exact ⟨c.pt, c.ι.app ⟨⟨WalkingPair.left⟩⟩, c.ι.app ⟨⟨WalkingPair.right⟩⟩, trivial⟩
· intros X Y f g
obtain ⟨c⟩ := h (ULiftHom.down ⋙ ULift.downFunctor ⋙ parallelPair f g)
refine ⟨c.pt, c.ι.app ⟨WalkingParallelPair.one⟩, ?_⟩
have h₁ := c.ι.naturality ⟨WalkingParallelPairHom.left⟩
have h₂ := c.ι.naturality ⟨WalkingParallelPairHom.right⟩
simp_all
apply IsFiltered.mk
theorem of_hasFiniteColimits [HasFiniteColimits C] : IsFiltered C :=
of_cocone_nonempty.{v} C fun F => ⟨colimit.cocone F⟩
theorem of_isTerminal {X : C} (h : IsTerminal X) : IsFiltered C :=
of_cocone_nonempty.{v} _ fun {_} _ _ _ => ⟨⟨X, ⟨fun _ => h.from _, fun _ _ _ => h.hom_ext _ _⟩⟩⟩
instance (priority := 100) of_hasTerminal [HasTerminal C] : IsFiltered C :=
of_isTerminal _ terminalIsTerminal
/-- For every universe `w`, `C` is filtered if and only if every finite diagram in `C` with shape
in `w` admits a cocone. -/
theorem iff_cocone_nonempty : IsFiltered C ↔
∀ {J : Type w} [SmallCategory J] [FinCategory J] (F : J ⥤ C), Nonempty (Cocone F) :=
⟨fun _ _ _ _ F => cocone_nonempty F, of_cocone_nonempty C⟩
end OfCocone
section SpecialShapes
variable {C}
variable [IsFilteredOrEmpty C]
/-- `max₃ j₁ j₂ j₃` is an arbitrary choice of object to the right of `j₁`, `j₂` and `j₃`,
whose existence is ensured by `IsFiltered`.
-/
noncomputable def max₃ (j₁ j₂ j₃ : C) : C :=
max (max j₁ j₂) j₃
/-- `firstToMax₃ j₁ j₂ j₃` is an arbitrary choice of morphism from `j₁` to `max₃ j₁ j₂ j₃`,
whose existence is ensured by `IsFiltered`.
-/
noncomputable def firstToMax₃ (j₁ j₂ j₃ : C) : j₁ ⟶ max₃ j₁ j₂ j₃ :=
leftToMax j₁ j₂ ≫ leftToMax (max j₁ j₂) j₃
/-- `secondToMax₃ j₁ j₂ j₃` is an arbitrary choice of morphism from `j₂` to `max₃ j₁ j₂ j₃`,
whose existence is ensured by `IsFiltered`.
-/
noncomputable def secondToMax₃ (j₁ j₂ j₃ : C) : j₂ ⟶ max₃ j₁ j₂ j₃ :=
rightToMax j₁ j₂ ≫ leftToMax (max j₁ j₂) j₃
/-- `thirdToMax₃ j₁ j₂ j₃` is an arbitrary choice of morphism from `j₃` to `max₃ j₁ j₂ j₃`,
whose existence is ensured by `IsFiltered`.
-/
noncomputable def thirdToMax₃ (j₁ j₂ j₃ : C) : j₃ ⟶ max₃ j₁ j₂ j₃ :=
rightToMax (max j₁ j₂) j₃
/-- `coeq₃ f g h`, for morphisms `f g h : j₁ ⟶ j₂`, is an arbitrary choice of object
which admits a morphism `coeq₃Hom f g h : j₂ ⟶ coeq₃ f g h` such that
`coeq₃_condition₁`, `coeq₃_condition₂` and `coeq₃_condition₃` are satisfied.
Its existence is ensured by `IsFiltered`.
-/
noncomputable def coeq₃ {j₁ j₂ : C} (f g h : j₁ ⟶ j₂) : C :=
coeq (coeqHom f g ≫ leftToMax (coeq f g) (coeq g h))
(coeqHom g h ≫ rightToMax (coeq f g) (coeq g h))
/-- `coeq₃Hom f g h`, for morphisms `f g h : j₁ ⟶ j₂`, is an arbitrary choice of morphism
`j₂ ⟶ coeq₃ f g h` such that `coeq₃_condition₁`, `coeq₃_condition₂` and `coeq₃_condition₃`
are satisfied. Its existence is ensured by `IsFiltered`.
-/
noncomputable def coeq₃Hom {j₁ j₂ : C} (f g h : j₁ ⟶ j₂) : j₂ ⟶ coeq₃ f g h :=
coeqHom f g ≫
leftToMax (coeq f g) (coeq g h) ≫
coeqHom (coeqHom f g ≫ leftToMax (coeq f g) (coeq g h))
(coeqHom g h ≫ rightToMax (coeq f g) (coeq g h))
theorem coeq₃_condition₁ {j₁ j₂ : C} (f g h : j₁ ⟶ j₂) :
f ≫ coeq₃Hom f g h = g ≫ coeq₃Hom f g h := by
simp only [coeq₃Hom, ← Category.assoc, coeq_condition f g]
theorem coeq₃_condition₂ {j₁ j₂ : C} (f g h : j₁ ⟶ j₂) :
g ≫ coeq₃Hom f g h = h ≫ coeq₃Hom f g h := by
dsimp [coeq₃Hom]
slice_lhs 2 4 => rw [← Category.assoc, coeq_condition _ _]
slice_rhs 2 4 => rw [← Category.assoc, coeq_condition _ _]
slice_lhs 1 3 => rw [← Category.assoc, coeq_condition _ _]
simp only [Category.assoc]
theorem coeq₃_condition₃ {j₁ j₂ : C} (f g h : j₁ ⟶ j₂) : f ≫ coeq₃Hom f g h = h ≫ coeq₃Hom f g h :=
Eq.trans (coeq₃_condition₁ f g h) (coeq₃_condition₂ f g h)
/-- For every span `j ⟵ i ⟶ j'`, there
exists a cocone `j ⟶ k ⟵ j'` such that the square commutes. -/
theorem span {i j j' : C} (f : i ⟶ j) (f' : i ⟶ j') :
∃ (k : C) (g : j ⟶ k) (g' : j' ⟶ k), f ≫ g = f' ≫ g' :=
let ⟨K, G, G', _⟩ := IsFilteredOrEmpty.cocone_objs j j'
let ⟨k, e, he⟩ := IsFilteredOrEmpty.cocone_maps (f ≫ G) (f' ≫ G')
⟨k, G ≫ e, G' ≫ e, by simpa only [← Category.assoc] ⟩
/-- Given a "bowtie" of morphisms
```
j₁ j₂
|\ /|
| \/ |
| /\ |
|/ \∣
vv vv
k₁ k₂
```
in a filtered category, we can construct an object `s` and two morphisms from `k₁` and `k₂` to `s`,
making the resulting squares commute.
-/
theorem bowtie {j₁ j₂ k₁ k₂ : C} (f₁ : j₁ ⟶ k₁) (g₁ : j₁ ⟶ k₂) (f₂ : j₂ ⟶ k₁) (g₂ : j₂ ⟶ k₂) :
∃ (s : C) (α : k₁ ⟶ s) (β : k₂ ⟶ s), f₁ ≫ α = g₁ ≫ β ∧ f₂ ≫ α = g₂ ≫ β := by
obtain ⟨t, k₁t, k₂t, ht⟩ := span f₁ g₁
obtain ⟨s, ts, hs⟩ := IsFilteredOrEmpty.cocone_maps (f₂ ≫ k₁t) (g₂ ≫ k₂t)
simp_rw [Category.assoc] at hs
exact ⟨s, k₁t ≫ ts, k₂t ≫ ts, by simp only [← Category.assoc, ht], hs⟩
/-- Given a "tulip" of morphisms
```
j₁ j₂ j₃
|\ / \ / |
| \ / \ / |
| vv vv |
\ k₁ k₂ /
\ /
\ /
\ /
\ /
v v
l
```
in a filtered category, we can construct an object `s` and three morphisms from `k₁`, `k₂` and `l`
to `s`, making the resulting squares commute.
-/
theorem tulip {j₁ j₂ j₃ k₁ k₂ l : C} (f₁ : j₁ ⟶ k₁) (f₂ : j₂ ⟶ k₁) (f₃ : j₂ ⟶ k₂) (f₄ : j₃ ⟶ k₂)
(g₁ : j₁ ⟶ l) (g₂ : j₃ ⟶ l) :
∃ (s : C) (α : k₁ ⟶ s) (β : l ⟶ s) (γ : k₂ ⟶ s),
f₁ ≫ α = g₁ ≫ β ∧ f₂ ≫ α = f₃ ≫ γ ∧ f₄ ≫ γ = g₂ ≫ β := by
obtain ⟨l', k₁l, k₂l, hl⟩ := span f₂ f₃
obtain ⟨s, ls, l's, hs₁, hs₂⟩ := bowtie g₁ (f₁ ≫ k₁l) g₂ (f₄ ≫ k₂l)
refine ⟨s, k₁l ≫ l's, ls, k₂l ≫ l's, ?_, by simp only [← Category.assoc, hl], ?_⟩ <;>
simp only [hs₁, hs₂, Category.assoc]
end SpecialShapes
end IsFiltered
/-- A category `IsCofilteredOrEmpty` if
1. for every pair of objects there exists another object "to the left", and
2. for every pair of parallel morphisms there exists a morphism to the left so the compositions
are equal.
-/
class IsCofilteredOrEmpty : Prop where
/-- for every pair of objects there exists another object "to the left" -/
cone_objs : ∀ X Y : C, ∃ (W : _) (_ : W ⟶ X) (_ : W ⟶ Y), True
/-- for every pair of parallel morphisms there exists a morphism to the left
so the compositions are equal -/
cone_maps : ∀ ⦃X Y : C⦄ (f g : X ⟶ Y), ∃ (W : _) (h : W ⟶ X), h ≫ f = h ≫ g
/-- A category `IsCofiltered` if
1. for every pair of objects there exists another object "to the left",
2. for every pair of parallel morphisms there exists a morphism to the left so the compositions
are equal, and
3. there exists some object.
See <https://stacks.math.columbia.edu/tag/04AZ>.
-/
class IsCofiltered extends IsCofilteredOrEmpty C : Prop where
/-- a cofiltered category must be non empty -/
[nonempty : Nonempty C]
instance (priority := 100) isCofilteredOrEmpty_of_semilatticeInf (α : Type u) [SemilatticeInf α] :
IsCofilteredOrEmpty α where
cone_objs X Y := ⟨X ⊓ Y, homOfLE inf_le_left, homOfLE inf_le_right, trivial⟩
cone_maps X Y f g := ⟨X, 𝟙 _, by
apply ULift.ext
subsingleton⟩
instance (priority := 100) isCofiltered_of_semilatticeInf_nonempty (α : Type u) [SemilatticeInf α]
[Nonempty α] : IsCofiltered α where
instance (priority := 100) isCofilteredOrEmpty_of_directed_ge (α : Type u) [Preorder α]
[IsDirected α (· ≥ ·)] : IsCofilteredOrEmpty α where
cone_objs X Y :=
let ⟨Z, hX, hY⟩ := exists_le_le X Y
⟨Z, homOfLE hX, homOfLE hY, trivial⟩
cone_maps X Y f g := ⟨X, 𝟙 _, by
apply ULift.ext
subsingleton⟩
instance (priority := 100) isCofiltered_of_directed_ge_nonempty (α : Type u) [Preorder α]
[IsDirected α (· ≥ ·)] [Nonempty α] : IsCofiltered α where
-- Sanity checks
example (α : Type u) [SemilatticeInf α] [OrderBot α] : IsCofiltered α := by infer_instance
example (α : Type u) [SemilatticeInf α] [OrderTop α] : IsCofiltered α := by infer_instance
instance : IsCofiltered (Discrete PUnit) where
cone_objs X Y := ⟨⟨PUnit.unit⟩, ⟨⟨by trivial⟩⟩, ⟨⟨by subsingleton⟩⟩, trivial⟩
cone_maps X Y f g := ⟨⟨PUnit.unit⟩, ⟨⟨by trivial⟩⟩, by
apply ULift.ext
subsingleton⟩
namespace IsCofiltered
section AllowEmpty
variable {C}
variable [IsCofilteredOrEmpty C]
-- Porting note: the following definitions were removed because the names are invalid,
-- direct references to `IsCofilteredOrEmpty` have been added instead
--
--theorem cone_objs : ∀ X Y : C, ∃ (W : _) (f : W ⟶ X) (g : W ⟶ Y), True :=
-- IsCofilteredOrEmpty.cone_objs
--
--theorem cone_maps : ∀ ⦃X Y : C⦄ (f g : X ⟶ Y), ∃ (W : _) (h : W ⟶ X), h ≫ f = h ≫ g :=
-- IsCofilteredOrEmpty.cone_maps
/-- `min j j'` is an arbitrary choice of object to the left of both `j` and `j'`,
whose existence is ensured by `IsCofiltered`.
-/
noncomputable def min (j j' : C) : C :=
(IsCofilteredOrEmpty.cone_objs j j').choose
/-- `minToLeft j j'` is an arbitrary choice of morphism from `min j j'` to `j`,
whose existence is ensured by `IsCofiltered`.
-/
noncomputable def minToLeft (j j' : C) : min j j' ⟶ j :=
(IsCofilteredOrEmpty.cone_objs j j').choose_spec.choose
/-- `minToRight j j'` is an arbitrary choice of morphism from `min j j'` to `j'`,
whose existence is ensured by `IsCofiltered`.
-/
noncomputable def minToRight (j j' : C) : min j j' ⟶ j' :=
(IsCofilteredOrEmpty.cone_objs j j').choose_spec.choose_spec.choose
/-- `eq f f'`, for morphisms `f f' : j ⟶ j'`, is an arbitrary choice of object
which admits a morphism `eqHom f f' : eq f f' ⟶ j` such that
`eq_condition : eqHom f f' ≫ f = eqHom f f' ≫ f'`.
Its existence is ensured by `IsCofiltered`.
-/
noncomputable def eq {j j' : C} (f f' : j ⟶ j') : C :=
(IsCofilteredOrEmpty.cone_maps f f').choose
/-- `eqHom f f'`, for morphisms `f f' : j ⟶ j'`, is an arbitrary choice of morphism
`eqHom f f' : eq f f' ⟶ j` such that
`eq_condition : eqHom f f' ≫ f = eqHom f f' ≫ f'`.
Its existence is ensured by `IsCofiltered`.
-/
noncomputable def eqHom {j j' : C} (f f' : j ⟶ j') : eq f f' ⟶ j :=
(IsCofilteredOrEmpty.cone_maps f f').choose_spec.choose
-- Porting note: the simp tag has been removed as the linter complained
/-- `eq_condition f f'`, for morphisms `f f' : j ⟶ j'`, is the proof that
`eqHom f f' ≫ f = eqHom f f' ≫ f'`.
-/
@[reassoc]
theorem eq_condition {j j' : C} (f f' : j ⟶ j') : eqHom f f' ≫ f = eqHom f f' ≫ f' :=
(IsCofilteredOrEmpty.cone_maps f f').choose_spec.choose_spec
/-- For every cospan `j ⟶ i ⟵ j'`,
there exists a cone `j ⟵ k ⟶ j'` such that the square commutes. -/
theorem cospan {i j j' : C} (f : j ⟶ i) (f' : j' ⟶ i) :
∃ (k : C) (g : k ⟶ j) (g' : k ⟶ j'), g ≫ f = g' ≫ f' :=
let ⟨K, G, G', _⟩ := IsCofilteredOrEmpty.cone_objs j j'
let ⟨k, e, he⟩ := IsCofilteredOrEmpty.cone_maps (G ≫ f) (G' ≫ f')
⟨k, e ≫ G, e ≫ G', by simpa only [Category.assoc] using he⟩
theorem _root_.CategoryTheory.Functor.ranges_directed (F : C ⥤ Type*) (j : C) :
Directed (· ⊇ ·) fun f : Σ'i, i ⟶ j => Set.range (F.map f.2) := fun ⟨i, ij⟩ ⟨k, kj⟩ => by
let ⟨l, li, lk, e⟩ := cospan ij kj
refine ⟨⟨l, lk ≫ kj⟩, e ▸ ?_, ?_⟩ <;> simp_rw [F.map_comp] <;> apply Set.range_comp_subset_range
end AllowEmpty
end IsCofiltered
namespace IsCofilteredOrEmpty
open IsCofiltered
variable {C}
variable [IsCofilteredOrEmpty C]
variable {D : Type u₁} [Category.{v₁} D]
/-- If `C` is cofiltered or empty, and we have a functor `L : C ⥤ D` with a right adjoint,
then `D` is cofiltered or empty.
-/
theorem of_left_adjoint {L : C ⥤ D} {R : D ⥤ C} (h : L ⊣ R) : IsCofilteredOrEmpty D :=
{ cone_objs := fun X Y =>
⟨L.obj (min (R.obj X) (R.obj Y)), (h.homEquiv _ X).symm (minToLeft _ _),
(h.homEquiv _ Y).symm (minToRight _ _), ⟨⟩⟩
cone_maps := fun X Y f g =>
⟨L.obj (eq (R.map f) (R.map g)), (h.homEquiv _ _).symm (eqHom _ _), by
rw [← h.homEquiv_naturality_right_symm, ← h.homEquiv_naturality_right_symm, eq_condition]⟩ }
/-- If `C` is cofiltered or empty, and we have a left adjoint functor `L : C ⥤ D`, then `D` is
cofiltered or empty. -/
theorem of_isLeftAdjoint (L : C ⥤ D) [L.IsLeftAdjoint] : IsCofilteredOrEmpty D :=
of_left_adjoint (Adjunction.ofIsLeftAdjoint L)
/-- Being cofiltered or empty is preserved by equivalence of categories. -/
theorem of_equivalence (h : C ≌ D) : IsCofilteredOrEmpty D :=
of_left_adjoint h.toAdjunction
end IsCofilteredOrEmpty
namespace IsCofiltered
section Nonempty
open CategoryTheory.Limits
variable {C}
variable [IsCofiltered C]
/-- Any finite collection of objects in a cofiltered category has an object "to the left".
-/
theorem inf_objs_exists (O : Finset C) : ∃ S : C, ∀ {X}, X ∈ O → Nonempty (S ⟶ X) := by
classical
induction' O using Finset.induction with X O' nm h
· exact ⟨Classical.choice IsCofiltered.nonempty, by intro; simp⟩
· obtain ⟨S', w'⟩ := h
use min X S'
rintro Y mY
obtain rfl | h := eq_or_ne Y X
· exact ⟨minToLeft _ _⟩
· exact ⟨minToRight _ _ ≫ (w' (Finset.mem_of_mem_insert_of_ne mY h)).some⟩
variable (O : Finset C) (H : Finset (Σ' (X Y : C) (_ : X ∈ O) (_ : Y ∈ O), X ⟶ Y))
/-- Given any `Finset` of objects `{X, ...}` and
indexed collection of `Finset`s of morphisms `{f, ...}` in `C`,
there exists an object `S`, with a morphism `T X : S ⟶ X` from each `X`,
such that the triangles commute: `T X ≫ f = T Y`, for `f : X ⟶ Y` in the `Finset`.
-/
theorem inf_exists :
∃ (S : C) (T : ∀ {X : C}, X ∈ O → (S ⟶ X)),
∀ {X Y : C} (mX : X ∈ O) (mY : Y ∈ O) {f : X ⟶ Y},
(⟨X, Y, mX, mY, f⟩ : Σ' (X Y : C) (_ : X ∈ O) (_ : Y ∈ O), X ⟶ Y) ∈ H →
T mX ≫ f = T mY := by
classical
induction' H using Finset.induction with h' H' nmf h''
· obtain ⟨S, f⟩ := inf_objs_exists O
exact ⟨S, fun mX => (f mX).some, by rintro - - - - - ⟨⟩⟩
· obtain ⟨X, Y, mX, mY, f⟩ := h'
obtain ⟨S', T', w'⟩ := h''
refine ⟨eq (T' mX ≫ f) (T' mY), fun mZ => eqHom (T' mX ≫ f) (T' mY) ≫ T' mZ, ?_⟩
intro X' Y' mX' mY' f' mf'
rw [Category.assoc]
by_cases h : X = X' ∧ Y = Y'
· rcases h with ⟨rfl, rfl⟩
by_cases hf : f = f'
· subst hf
apply eq_condition
· rw [@w' _ _ mX mY f']
simp only [Finset.mem_insert, PSigma.mk.injEq, heq_eq_eq, true_and] at mf'
rcases mf' with mf' | mf'
· exfalso
exact hf mf'.symm
· exact mf'
· rw [@w' _ _ mX' mY' f' _]
apply Finset.mem_of_mem_insert_of_ne mf'
contrapose! h
obtain ⟨rfl, h⟩ := h
trivial
/-- An arbitrary choice of object "to the left"
of a finite collection of objects `O` and morphisms `H`,
making all the triangles commute.
-/
noncomputable def inf : C :=
(inf_exists O H).choose
/-- The morphisms from `inf O H`.
-/
noncomputable def infTo {X : C} (m : X ∈ O) : inf O H ⟶ X :=
(inf_exists O H).choose_spec.choose m
/-- The triangles consisting of a morphism in `H` and the maps from `inf O H` commute.
-/
theorem infTo_commutes {X Y : C} (mX : X ∈ O) (mY : Y ∈ O) {f : X ⟶ Y}
(mf : (⟨X, Y, mX, mY, f⟩ : Σ' (X Y : C) (_ : X ∈ O) (_ : Y ∈ O), X ⟶ Y) ∈ H) :
infTo O H mX ≫ f = infTo O H mY :=
(inf_exists O H).choose_spec.choose_spec mX mY mf
variable {J : Type w} [SmallCategory J] [FinCategory J]
/-- If we have `IsCofiltered C`, then for any functor `F : J ⥤ C` with `FinCategory J`,
there exists a cone over `F`.
-/
theorem cone_nonempty (F : J ⥤ C) : Nonempty (Cone F) := by
classical
let O := Finset.univ.image F.obj
let H : Finset (Σ' (X Y : C) (_ : X ∈ O) (_ : Y ∈ O), X ⟶ Y) :=
Finset.univ.biUnion fun X : J =>
Finset.univ.biUnion fun Y : J =>
Finset.univ.image fun f : X ⟶ Y => ⟨F.obj X, F.obj Y, by simp [O], by simp [O], F.map f⟩
obtain ⟨Z, f, w⟩ := inf_exists O H
refine ⟨⟨Z, ⟨fun X => f (by simp [O]), ?_⟩⟩⟩
intro j j' g
dsimp
simp only [Category.id_comp]
symm
apply w
simp only [O, H, Finset.mem_biUnion, Finset.mem_univ, Finset.mem_image,
PSigma.mk.injEq, true_and, exists_and_left]
exact ⟨j, rfl, j', g, by simp⟩
/-- An arbitrary choice of cone over `F : J ⥤ C`, for `FinCategory J` and `IsCofiltered C`.
-/
noncomputable def cone (F : J ⥤ C) : Cone F :=
(cone_nonempty F).some
variable {D : Type u₁} [Category.{v₁} D]
/-- If `C` is cofiltered, and we have a functor `L : C ⥤ D` with a right adjoint,
then `D` is cofiltered.
-/
theorem of_left_adjoint {L : C ⥤ D} {R : D ⥤ C} (h : L ⊣ R) : IsCofiltered D :=
{ IsCofilteredOrEmpty.of_left_adjoint h with
nonempty := IsCofiltered.nonempty.map L.obj }
/-- If `C` is cofiltered, and we have a left adjoint functor `L : C ⥤ D`, then `D` is cofiltered. -/
theorem of_isLeftAdjoint (L : C ⥤ D) [L.IsLeftAdjoint] : IsCofiltered D :=
of_left_adjoint (Adjunction.ofIsLeftAdjoint L)
/-- Being cofiltered is preserved by equivalence of categories. -/
theorem of_equivalence (h : C ≌ D) : IsCofiltered D :=
of_left_adjoint h.toAdjunction
end Nonempty
section OfCone
open CategoryTheory.Limits
/-- If every finite diagram in `C` admits a cone, then `C` is cofiltered. It is sufficient to
verify this for diagrams whose shape lives in any one fixed universe. -/
theorem of_cone_nonempty (h : ∀ {J : Type w} [SmallCategory J] [FinCategory J] (F : J ⥤ C),
Nonempty (Cone F)) : IsCofiltered C := by
have : Nonempty C := by
obtain ⟨c⟩ := h (Functor.empty _)
exact ⟨c.pt⟩
have : IsCofilteredOrEmpty C := by
refine ⟨?_, ?_⟩
· intros X Y
obtain ⟨c⟩ := h (ULiftHom.down ⋙ ULift.downFunctor ⋙ pair X Y)
exact ⟨c.pt, c.π.app ⟨⟨WalkingPair.left⟩⟩, c.π.app ⟨⟨WalkingPair.right⟩⟩, trivial⟩
· intros X Y f g
obtain ⟨c⟩ := h (ULiftHom.down ⋙ ULift.downFunctor ⋙ parallelPair f g)
refine ⟨c.pt, c.π.app ⟨WalkingParallelPair.zero⟩, ?_⟩
have h₁ := c.π.naturality ⟨WalkingParallelPairHom.left⟩
have h₂ := c.π.naturality ⟨WalkingParallelPairHom.right⟩
simp_all
apply IsCofiltered.mk
theorem of_hasFiniteLimits [HasFiniteLimits C] : IsCofiltered C :=
of_cone_nonempty.{v} C fun F => ⟨limit.cone F⟩
theorem of_isInitial {X : C} (h : IsInitial X) : IsCofiltered C :=
of_cone_nonempty.{v} _ fun {_} _ _ _ => ⟨⟨X, ⟨fun _ => h.to _, fun _ _ _ => h.hom_ext _ _⟩⟩⟩
instance (priority := 100) of_hasInitial [HasInitial C] : IsCofiltered C :=
of_isInitial _ initialIsInitial
@[deprecated (since := "2024-03-11")]
alias _root_.CategoryTheory.cofiltered_of_hasFiniteLimits := of_hasFiniteLimits
/-- For every universe `w`, `C` is filtered if and only if every finite diagram in `C` with shape
in `w` admits a cocone. -/
theorem iff_cone_nonempty : IsCofiltered C ↔
∀ {J : Type w} [SmallCategory J] [FinCategory J] (F : J ⥤ C), Nonempty (Cone F) :=
⟨fun _ _ _ _ F => cone_nonempty F, of_cone_nonempty C⟩
end OfCone
end IsCofiltered
section Opposite
open Opposite
instance isCofilteredOrEmpty_op_of_isFilteredOrEmpty [IsFilteredOrEmpty C] :
IsCofilteredOrEmpty Cᵒᵖ where
cone_objs X Y :=
⟨op (IsFiltered.max X.unop Y.unop), (IsFiltered.leftToMax _ _).op,
(IsFiltered.rightToMax _ _).op, trivial⟩
cone_maps X Y f g :=
⟨op (IsFiltered.coeq f.unop g.unop), (IsFiltered.coeqHom _ _).op, by
rw [show f = f.unop.op by simp, show g = g.unop.op by simp, ← op_comp, ← op_comp]
congr 1
exact IsFiltered.coeq_condition f.unop g.unop⟩
instance isCofiltered_op_of_isFiltered [IsFiltered C] : IsCofiltered Cᵒᵖ where
nonempty := letI : Nonempty C := IsFiltered.nonempty; inferInstance
instance isFilteredOrEmpty_op_of_isCofilteredOrEmpty [IsCofilteredOrEmpty C] :
IsFilteredOrEmpty Cᵒᵖ where
cocone_objs X Y :=
⟨op (IsCofiltered.min X.unop Y.unop), (IsCofiltered.minToLeft X.unop Y.unop).op,
(IsCofiltered.minToRight X.unop Y.unop).op, trivial⟩
cocone_maps X Y f g :=
⟨op (IsCofiltered.eq f.unop g.unop), (IsCofiltered.eqHom f.unop g.unop).op, by
rw [show f = f.unop.op by simp, show g = g.unop.op by simp, ← op_comp, ← op_comp]
congr 1
exact IsCofiltered.eq_condition f.unop g.unop⟩
instance isFiltered_op_of_isCofiltered [IsCofiltered C] : IsFiltered Cᵒᵖ where
nonempty := letI : Nonempty C := IsCofiltered.nonempty; inferInstance
/-- If Cᵒᵖ is filtered or empty, then C is cofiltered or empty. -/
lemma isCofilteredOrEmpty_of_isFilteredOrEmpty_op [IsFilteredOrEmpty Cᵒᵖ] : IsCofilteredOrEmpty C :=
IsCofilteredOrEmpty.of_equivalence (opOpEquivalence _)
/-- If Cᵒᵖ is cofiltered or empty, then C is filtered or empty. -/
lemma isFilteredOrEmpty_of_isCofilteredOrEmpty_op [IsCofilteredOrEmpty Cᵒᵖ] : IsFilteredOrEmpty C :=
IsFilteredOrEmpty.of_equivalence (opOpEquivalence _)
/-- If Cᵒᵖ is filtered, then C is cofiltered. -/
lemma isCofiltered_of_isFiltered_op [IsFiltered Cᵒᵖ] : IsCofiltered C :=
IsCofiltered.of_equivalence (opOpEquivalence _)
/-- If Cᵒᵖ is cofiltered, then C is filtered. -/
lemma isFiltered_of_isCofiltered_op [IsCofiltered Cᵒᵖ] : IsFiltered C :=
IsFiltered.of_equivalence (opOpEquivalence _)
end Opposite
section ULift
instance [IsFiltered C] : IsFiltered (ULift.{u₂} C) :=
IsFiltered.of_equivalence ULift.equivalence
instance [IsCofiltered C] : IsCofiltered (ULift.{u₂} C) :=
IsCofiltered.of_equivalence ULift.equivalence
instance [IsFiltered C] : IsFiltered (ULiftHom C) :=
IsFiltered.of_equivalence ULiftHom.equiv
instance [IsCofiltered C] : IsCofiltered (ULiftHom C) :=
IsCofiltered.of_equivalence ULiftHom.equiv
instance [IsFiltered C] : IsFiltered (AsSmall C) :=
IsFiltered.of_equivalence AsSmall.equiv
instance [IsCofiltered C] : IsCofiltered (AsSmall C) :=
IsCofiltered.of_equivalence AsSmall.equiv
end ULift
end CategoryTheory
|
CategoryTheory\Filtered\Connected.lean | /-
Copyright (c) 2024 Markus Himmel. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Markus Himmel
-/
import Mathlib.CategoryTheory.Filtered.Basic
import Mathlib.CategoryTheory.IsConnected
/-!
# Filtered categories are connected
-/
universe v u
namespace CategoryTheory
variable (C : Type u) [Category.{v} C]
theorem IsFilteredOrEmpty.isPreconnected [IsFilteredOrEmpty C] : IsPreconnected C :=
zigzag_isPreconnected fun j j' => .trans
(.single <| .inl <| .intro <| IsFiltered.leftToMax j j')
(.single <| .inr <| .intro <| IsFiltered.rightToMax j j')
theorem IsCofilteredOrEmpty.isPreconnected [IsCofilteredOrEmpty C] : IsPreconnected C :=
zigzag_isPreconnected fun j j' => .trans
(.single <| .inr <| .intro <| IsCofiltered.minToLeft j j')
(.single <| .inl <| .intro <| IsCofiltered.minToRight j j')
attribute [local instance] IsFiltered.nonempty in
theorem IsFiltered.isConnected [IsFiltered C] : IsConnected C :=
{ IsFilteredOrEmpty.isPreconnected C with }
attribute [local instance] IsCofiltered.nonempty in
theorem IsCofiltered.isConnected [IsCofiltered C] : IsConnected C :=
{ IsCofilteredOrEmpty.isPreconnected C with }
end CategoryTheory
|
CategoryTheory\Filtered\Final.lean | /-
Copyright (c) 2024 Markus Himmel. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Markus Himmel
-/
import Mathlib.CategoryTheory.Filtered.Connected
import Mathlib.CategoryTheory.Limits.TypesFiltered
import Mathlib.CategoryTheory.Limits.Final
/-!
# Final functors with filtered (co)domain
If `C` is a filtered category, then the usual equivalent conditions for a functor `F : C ⥤ D` to be
final can be restated. We show:
* `final_iff_of_isFiltered`: a concrete description of finality which is sometimes a convenient way
to show that a functor is final.
* `final_iff_isFiltered_structuredArrow`: `F` is final if and only if `StructuredArrow d F` is
filtered for all `d : D`, which strengthens the usual statement that `F` is final if and only
if `StructuredArrow d F` is connected for all `d : D`.
Additionally, we show that if `D` is a filtered category and `F : C ⥤ D` is fully faithful and
satisfies the additional condition that for every `d : D` there is an object `c : D` and a morphism
`d ⟶ F.obj c`, then `C` is filtered and `F` is final.
## References
* [M. Kashiwara, P. Schapira, *Categories and Sheaves*][Kashiwara2006], Section 3.2
-/
universe v₁ v₂ u₁ u₂
namespace CategoryTheory
open CategoryTheory.Limits CategoryTheory.Functor Opposite
section ArbitraryUniverses
variable {C : Type u₁} [Category.{v₁} C] {D : Type u₂} [Category.{v₂} D] (F : C ⥤ D)
/-- If `StructuredArrow d F` is filtered for any `d : D`, then `F : C ⥤ D` is final. This is
simply because filtered categories are connected. More profoundly, the converse is also true if
`C` is filtered, see `final_iff_isFiltered_structuredArrow`. -/
theorem Functor.final_of_isFiltered_structuredArrow [∀ d, IsFiltered (StructuredArrow d F)] :
Final F where
out _ := IsFiltered.isConnected _
/-- If `CostructuredArrow F d` is filtered for any `d : D`, then `F : C ⥤ D` is initial. This is
simply because cofiltered categories are connectged. More profoundly, the converse is also true
if `C` is cofiltered, see `initial_iff_isCofiltered_costructuredArrow`. -/
theorem Functor.initial_of_isCofiltered_costructuredArrow
[∀ d, IsCofiltered (CostructuredArrow F d)] : Initial F where
out _ := IsCofiltered.isConnected _
theorem isFiltered_structuredArrow_of_isFiltered_of_exists [IsFilteredOrEmpty C]
(h₁ : ∀ d, ∃ c, Nonempty (d ⟶ F.obj c)) (h₂ : ∀ {d : D} {c : C} (s s' : d ⟶ F.obj c),
∃ (c' : C) (t : c ⟶ c'), s ≫ F.map t = s' ≫ F.map t) (d : D) :
IsFiltered (StructuredArrow d F) := by
have : Nonempty (StructuredArrow d F) := by
obtain ⟨c, ⟨f⟩⟩ := h₁ d
exact ⟨.mk f⟩
suffices IsFilteredOrEmpty (StructuredArrow d F) from IsFiltered.mk
refine ⟨fun f g => ?_, fun f g η μ => ?_⟩
· obtain ⟨c, ⟨t, ht⟩⟩ := h₂ (f.hom ≫ F.map (IsFiltered.leftToMax f.right g.right))
(g.hom ≫ F.map (IsFiltered.rightToMax f.right g.right))
refine ⟨.mk (f.hom ≫ F.map (IsFiltered.leftToMax f.right g.right ≫ t)), ?_, ?_, trivial⟩
· exact StructuredArrow.homMk (IsFiltered.leftToMax _ _ ≫ t) rfl
· exact StructuredArrow.homMk (IsFiltered.rightToMax _ _ ≫ t) (by simpa using ht.symm)
· refine ⟨.mk (f.hom ≫ F.map (η.right ≫ IsFiltered.coeqHom η.right μ.right)),
StructuredArrow.homMk (IsFiltered.coeqHom η.right μ.right) (by simp), ?_⟩
simpa using IsFiltered.coeq_condition _ _
theorem isCofiltered_costructuredArrow_of_isCofiltered_of_exists [IsCofilteredOrEmpty C]
(h₁ : ∀ d, ∃ c, Nonempty (F.obj c ⟶ d)) (h₂ : ∀ {d : D} {c : C} (s s' : F.obj c ⟶ d),
∃ (c' : C) (t : c' ⟶ c), F.map t ≫ s = F.map t ≫ s') (d : D) :
IsCofiltered (CostructuredArrow F d) := by
suffices IsFiltered (CostructuredArrow F d)ᵒᵖ from isCofiltered_of_isFiltered_op _
suffices IsFiltered (StructuredArrow (op d) F.op) from
IsFiltered.of_equivalence (costructuredArrowOpEquivalence _ _).symm
apply isFiltered_structuredArrow_of_isFiltered_of_exists
· intro d
obtain ⟨c, ⟨t⟩⟩ := h₁ d.unop
exact ⟨op c, ⟨Quiver.Hom.op t⟩⟩
· intro d c s s'
obtain ⟨c', t, ht⟩ := h₂ s.unop s'.unop
exact ⟨op c', Quiver.Hom.op t, Quiver.Hom.unop_inj ht⟩
/-- If `C` is filtered, then we can give an explicit condition for a functor `F : C ⥤ D` to
be final. The converse is also true, see `final_iff_of_isFiltered`. -/
theorem Functor.final_of_exists_of_isFiltered [IsFilteredOrEmpty C]
(h₁ : ∀ d, ∃ c, Nonempty (d ⟶ F.obj c)) (h₂ : ∀ {d : D} {c : C} (s s' : d ⟶ F.obj c),
∃ (c' : C) (t : c ⟶ c'), s ≫ F.map t = s' ≫ F.map t) : Functor.Final F := by
suffices ∀ d, IsFiltered (StructuredArrow d F) from final_of_isFiltered_structuredArrow F
exact isFiltered_structuredArrow_of_isFiltered_of_exists F h₁ h₂
/-- If `C` is cofiltered, then we can give an explicit condition for a functor `F : C ⥤ D` to
be final. The converse is also true, see `initial_iff_of_isCofiltered`. -/
theorem Functor.initial_of_exists_of_isCofiltered [IsCofilteredOrEmpty C]
(h₁ : ∀ d, ∃ c, Nonempty (F.obj c ⟶ d)) (h₂ : ∀ {d : D} {c : C} (s s' : F.obj c ⟶ d),
∃ (c' : C) (t : c' ⟶ c), F.map t ≫ s = F.map t ≫ s') : Functor.Initial F := by
suffices ∀ d, IsCofiltered (CostructuredArrow F d) from
initial_of_isCofiltered_costructuredArrow F
exact isCofiltered_costructuredArrow_of_isCofiltered_of_exists F h₁ h₂
/-- In this situation, `F` is also final, see
`Functor.final_of_exists_of_isFiltered_of_fullyFaithful`. -/
theorem IsFilteredOrEmpty.of_exists_of_isFiltered_of_fullyFaithful [IsFilteredOrEmpty D] [F.Full]
[F.Faithful] (h : ∀ d, ∃ c, Nonempty (d ⟶ F.obj c)) : IsFilteredOrEmpty C where
cocone_objs c c' := by
obtain ⟨c₀, ⟨f⟩⟩ := h (IsFiltered.max (F.obj c) (F.obj c'))
exact ⟨c₀, F.preimage (IsFiltered.leftToMax _ _ ≫ f),
F.preimage (IsFiltered.rightToMax _ _ ≫ f), trivial⟩
cocone_maps {c c'} f g := by
obtain ⟨c₀, ⟨f₀⟩⟩ := h (IsFiltered.coeq (F.map f) (F.map g))
refine ⟨_, F.preimage (IsFiltered.coeqHom (F.map f) (F.map g) ≫ f₀), F.map_injective ?_⟩
simp [reassoc_of% (IsFiltered.coeq_condition (F.map f) (F.map g))]
/-- In this situation, `F` is also initial, see
`Functor.initial_of_exists_of_isCofiltered_of_fullyFaithful`. -/
theorem IsCofilteredOrEmpty.of_exists_of_isCofiltered_of_fullyFaithful [IsCofilteredOrEmpty D]
[F.Full] [F.Faithful] (h : ∀ d, ∃ c, Nonempty (F.obj c ⟶ d)) : IsCofilteredOrEmpty C := by
suffices IsFilteredOrEmpty Cᵒᵖ from isCofilteredOrEmpty_of_isFilteredOrEmpty_op _
refine IsFilteredOrEmpty.of_exists_of_isFiltered_of_fullyFaithful F.op (fun d => ?_)
obtain ⟨c, ⟨f⟩⟩ := h d.unop
exact ⟨op c, ⟨f.op⟩⟩
/-- In this situation, `F` is also final, see
`Functor.final_of_exists_of_isFiltered_of_fullyFaithful`. -/
theorem IsFiltered.of_exists_of_isFiltered_of_fullyFaithful [IsFiltered D] [F.Full] [F.Faithful]
(h : ∀ d, ∃ c, Nonempty (d ⟶ F.obj c)) : IsFiltered C :=
{ IsFilteredOrEmpty.of_exists_of_isFiltered_of_fullyFaithful F h with
nonempty := by
have : Nonempty D := IsFiltered.nonempty
obtain ⟨c, -⟩ := h (Classical.arbitrary D)
exact ⟨c⟩ }
/-- In this situation, `F` is also initial, see
`Functor.initial_of_exists_of_isCofiltered_of_fullyFaithful`. -/
theorem IsCofiltered.of_exists_of_isCofiltered_of_fullyFaithful [IsCofiltered D] [F.Full]
[F.Faithful] (h : ∀ d, ∃ c, Nonempty (F.obj c ⟶ d)) : IsCofiltered C :=
{ IsCofilteredOrEmpty.of_exists_of_isCofiltered_of_fullyFaithful F h with
nonempty := by
have : Nonempty D := IsCofiltered.nonempty
obtain ⟨c, -⟩ := h (Classical.arbitrary D)
exact ⟨c⟩ }
/-- In this situation, `C` is also filtered, see
`IsFilteredOrEmpty.of_exists_of_isFiltered_of_fullyFaithful`. -/
theorem Functor.final_of_exists_of_isFiltered_of_fullyFaithful [IsFilteredOrEmpty D] [F.Full]
[F.Faithful] (h : ∀ d, ∃ c, Nonempty (d ⟶ F.obj c)) : Final F := by
have := IsFilteredOrEmpty.of_exists_of_isFiltered_of_fullyFaithful F h
refine Functor.final_of_exists_of_isFiltered F h (fun {d c} s s' => ?_)
obtain ⟨c₀, ⟨f⟩⟩ := h (IsFiltered.coeq s s')
refine ⟨c₀, F.preimage (IsFiltered.coeqHom s s' ≫ f), ?_⟩
simp [reassoc_of% (IsFiltered.coeq_condition s s')]
/-- In this situation, `C` is also cofiltered, see
`IsCofilteredOrEmpty.of_exists_of_isCofiltered_of_fullyFaithful`. -/
theorem Functor.initial_of_exists_of_isCofiltered_of_fullyFaithful [IsCofilteredOrEmpty D] [F.Full]
[Faithful F] (h : ∀ d, ∃ c, Nonempty (F.obj c ⟶ d)) : Initial F := by
suffices Final F.op from initial_of_final_op _
refine Functor.final_of_exists_of_isFiltered_of_fullyFaithful F.op (fun d => ?_)
obtain ⟨c, ⟨f⟩⟩ := h d.unop
exact ⟨op c, ⟨f.op⟩⟩
end ArbitraryUniverses
section LocallySmall
variable {C : Type v₁} [Category.{v₁} C] {D : Type u₂} [Category.{v₁} D] (F : C ⥤ D)
/-- If `C` is filtered, then we can give an explicit condition for a functor `F : C ⥤ D` to
be final. -/
theorem Functor.final_iff_of_isFiltered [IsFilteredOrEmpty C] :
Final F ↔ (∀ d, ∃ c, Nonempty (d ⟶ F.obj c)) ∧ (∀ {d : D} {c : C} (s s' : d ⟶ F.obj c),
∃ (c' : C) (t : c ⟶ c'), s ≫ F.map t = s' ≫ F.map t) := by
refine ⟨fun hF => ⟨?_, ?_⟩, fun h => final_of_exists_of_isFiltered F h.1 h.2⟩
· intro d
obtain ⟨f⟩ : Nonempty (StructuredArrow d F) := IsConnected.is_nonempty
exact ⟨_, ⟨f.hom⟩⟩
· intro d c s s'
have : colimit.ι (F ⋙ coyoneda.obj (op d)) c s = colimit.ι (F ⋙ coyoneda.obj (op d)) c s' := by
apply (Final.colimitCompCoyonedaIso F d).toEquiv.injective
subsingleton
obtain ⟨c', t₁, t₂, h⟩ := (Types.FilteredColimit.colimit_eq_iff.{v₁, v₁, v₁} _).mp this
refine ⟨IsFiltered.coeq t₁ t₂, t₁ ≫ IsFiltered.coeqHom t₁ t₂, ?_⟩
conv_rhs => rw [IsFiltered.coeq_condition t₁ t₂]
dsimp only [comp_obj, coyoneda_obj_obj, unop_op, Functor.comp_map, coyoneda_obj_map] at h
simp [reassoc_of% h]
/-- If `C` is cofiltered, then we can give an explicit condition for a functor `F : C ⥤ D` to
be initial. -/
theorem Functor.initial_iff_of_isCofiltered [IsCofilteredOrEmpty C] :
Initial F ↔ (∀ d, ∃ c, Nonempty (F.obj c ⟶ d)) ∧ (∀ {d : D} {c : C} (s s' : F.obj c ⟶ d),
∃ (c' : C) (t : c' ⟶ c), F.map t ≫ s = F.map t ≫ s') := by
refine ⟨fun hF => ?_, fun h => initial_of_exists_of_isCofiltered F h.1 h.2⟩
obtain ⟨h₁, h₂⟩ := F.op.final_iff_of_isFiltered.mp inferInstance
refine ⟨?_, ?_⟩
· intro d
obtain ⟨c, ⟨t⟩⟩ := h₁ (op d)
exact ⟨c.unop, ⟨t.unop⟩⟩
· intro d c s s'
obtain ⟨c', t, ht⟩ := h₂ (Quiver.Hom.op s) (Quiver.Hom.op s')
exact ⟨c'.unop, t.unop, Quiver.Hom.op_inj ht⟩
theorem Functor.Final.exists_coeq [IsFilteredOrEmpty C] [Final F] {d : D} {c : C}
(s s' : d ⟶ F.obj c) : ∃ (c' : C) (t : c ⟶ c'), s ≫ F.map t = s' ≫ F.map t :=
((final_iff_of_isFiltered F).1 inferInstance).2 s s'
theorem Functor.Initial.exists_eq [IsCofilteredOrEmpty C] [Initial F] {d : D} {c : C}
(s s' : F.obj c ⟶ d) : ∃ (c' : C) (t : c' ⟶ c), F.map t ≫ s = F.map t ≫ s' :=
((initial_iff_of_isCofiltered F).1 inferInstance).2 s s'
/-- If `C` is filtered, then `F : C ⥤ D` is final if and only if `StructuredArrow d F` is filtered
for all `d : D`. -/
theorem Functor.final_iff_isFiltered_structuredArrow [IsFilteredOrEmpty C] :
Final F ↔ ∀ d, IsFiltered (StructuredArrow d F) := by
refine ⟨?_, fun h => final_of_isFiltered_structuredArrow F⟩
rw [final_iff_of_isFiltered]
exact fun h => isFiltered_structuredArrow_of_isFiltered_of_exists F h.1 h.2
/-- If `C` is cofiltered, then `F : C ⥤ D` is initial if and only if `CostructuredArrow F d` is
cofiltered for all `d : D`. -/
theorem Functor.initial_iff_isCofiltered_costructuredArrow [IsCofilteredOrEmpty C] :
Initial F ↔ ∀ d, IsCofiltered (CostructuredArrow F d) := by
refine ⟨?_, fun h => initial_of_isCofiltered_costructuredArrow F⟩
rw [initial_iff_of_isCofiltered]
exact fun h => isCofiltered_costructuredArrow_of_isCofiltered_of_exists F h.1 h.2
end LocallySmall
end CategoryTheory
|
CategoryTheory\Filtered\Small.lean | /-
Copyright (c) 2023 Markus Himmel. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Markus Himmel
-/
import Mathlib.CategoryTheory.EssentiallySmall
import Mathlib.CategoryTheory.Filtered.Basic
/-!
# A functor from a small category to a filtered category factors through a small filtered category
A consequence of this is that if `C` is filtered and finally small, then `C` is also
"finally filtered-small", i.e., there is a final functor from a small filtered category to `C`.
This is occasionally useful, for example in the proof of the recognition theorem for ind-objects
(Proposition 6.1.5 in [Kashiwara2006]).
-/
universe w v v₁ u u₁
namespace CategoryTheory
variable {C : Type u} [Category.{v} C]
namespace IsFiltered
section FilteredClosure
variable [IsFilteredOrEmpty C] {α : Type w} (f : α → C)
/-- The "filtered closure" of an `α`-indexed family of objects in `C` is the set of objects in `C`
obtained by starting with the family and successively adding maxima and coequalizers. -/
inductive FilteredClosure : C → Prop
| base : (x : α) → FilteredClosure (f x)
| max : {j j' : C} → FilteredClosure j → FilteredClosure j' → FilteredClosure (max j j')
| coeq : {j j' : C} → FilteredClosure j → FilteredClosure j' → (f f' : j ⟶ j') →
FilteredClosure (coeq f f')
/-- The full subcategory induced by the filtered closure of a family of objects is filtered. -/
instance : IsFilteredOrEmpty (FullSubcategory (FilteredClosure f)) where
cocone_objs j j' :=
⟨⟨max j.1 j'.1, FilteredClosure.max j.2 j'.2⟩, leftToMax _ _, rightToMax _ _, trivial⟩
cocone_maps {j j'} f f' :=
⟨⟨coeq f f', FilteredClosure.coeq j.2 j'.2 f f'⟩, coeqHom (C := C) f f', coeq_condition _ _⟩
namespace FilteredClosureSmall
/-! Our goal for this section is to show that the size of the filtered closure of an `α`-indexed
family of objects in `C` only depends on the size of `α` and the morphism types of `C`, not on
the size of the objects of `C`. More precisely, if `α` lives in `Type w`, the objects of `C`
live in `Type u` and the morphisms of `C` live in `Type v`, then we want
`Small.{max v w} (FullSubcategory (FilteredClosure f))`.
The strategy is to define a type `AbstractFilteredClosure` which should be an inductive type
similar to `FilteredClosure`, which lives in the correct universe and surjects onto the full
subcategory. The difficulty with this is that we need to define it at the same time as the map
`AbstractFilteredClosure → C`, as the coequalizer constructor depends on the actual morphisms
in `C`. This would require some kind of inductive-recursive definition, which Lean does not
allow. Our solution is to define a function `ℕ → Σ t : Type (max v w), t → C` by (strong)
induction and then take the union over all natural numbers, mimicking what one would do in a
set-theoretic setting. -/
/-- One step of the inductive procedure consists of adjoining all maxima and coequalizers of all
objects and morphisms obtained so far. This is quite redundant, picking up many objects which we
already hit in earlier iterations, but this is easier to work with later. -/
private inductive InductiveStep (n : ℕ) (X : ∀ (k : ℕ), k < n → Σ t : Type (max v w), t → C) :
Type (max v w)
| max : {k k' : ℕ} → (hk : k < n) → (hk' : k' < n) → (X _ hk).1 → (X _ hk').1 → InductiveStep n X
| coeq : {k k' : ℕ} → (hk : k < n) → (hk' : k' < n) → (j : (X _ hk).1) → (j' : (X _ hk').1) →
((X _ hk).2 j ⟶ (X _ hk').2 j') → ((X _ hk).2 j ⟶ (X _ hk').2 j') → InductiveStep n X
/-- The realization function sends the abstract maxima and weak coequalizers to the corresponding
objects in `C`. -/
private noncomputable def inductiveStepRealization (n : ℕ)
(X : ∀ (k : ℕ), k < n → Σ t : Type (max v w), t → C) : InductiveStep.{w} n X → C
| (InductiveStep.max hk hk' x y) => max ((X _ hk).2 x) ((X _ hk').2 y)
| (InductiveStep.coeq _ _ _ _ f g) => coeq f g
/-- All steps of building the abstract filtered closure together with the realization function,
as a function of `ℕ`.
The function is defined by well-founded recursion, but we really want to use its
definitional equalities in the proofs below, so lets make it semireducible. -/
@[semireducible] private noncomputable def bundledAbstractFilteredClosure :
ℕ → Σ t : Type (max v w), t → C
| 0 => ⟨ULift.{v} α, f ∘ ULift.down⟩
| (n + 1) => ⟨_, inductiveStepRealization (n + 1) (fun m _ => bundledAbstractFilteredClosure m)⟩
/-- The small type modelling the filtered closure. -/
private noncomputable def AbstractFilteredClosure : Type (max v w) :=
Σ n, (bundledAbstractFilteredClosure f n).1
/-- The surjection from the abstract filtered closure to the actual filtered closure in `C`. -/
private noncomputable def abstractFilteredClosureRealization : AbstractFilteredClosure f → C :=
fun x => (bundledAbstractFilteredClosure f x.1).2 x.2
end FilteredClosureSmall
theorem small_fullSubcategory_filteredClosure :
Small.{max v w} (FullSubcategory (FilteredClosure f)) := by
refine small_of_injective_of_exists (FilteredClosureSmall.abstractFilteredClosureRealization f)
(fun _ _ => FullSubcategory.ext) ?_
rintro ⟨j, h⟩
induction h with
| base x => exact ⟨⟨0, ⟨x⟩⟩, rfl⟩
| max hj₁ hj₂ ih ih' =>
rcases ih with ⟨⟨n, x⟩, rfl⟩
rcases ih' with ⟨⟨m, y⟩, rfl⟩
refine ⟨⟨(Max.max n m).succ, FilteredClosureSmall.InductiveStep.max ?_ ?_ x y⟩, rfl⟩
all_goals apply Nat.lt_succ_of_le
exacts [Nat.le_max_left _ _, Nat.le_max_right _ _]
| coeq hj₁ hj₂ g g' ih ih' =>
rcases ih with ⟨⟨n, x⟩, rfl⟩
rcases ih' with ⟨⟨m, y⟩, rfl⟩
refine ⟨⟨(Max.max n m).succ, FilteredClosureSmall.InductiveStep.coeq ?_ ?_ x y g g'⟩, rfl⟩
all_goals apply Nat.lt_succ_of_le
exacts [Nat.le_max_left _ _, Nat.le_max_right _ _]
instance : EssentiallySmall.{max v w} (FullSubcategory (FilteredClosure f)) :=
have : LocallySmall.{max v w} (FullSubcategory (FilteredClosure f)) := locallySmall_max.{w, v, u}
have := small_fullSubcategory_filteredClosure f
essentiallySmall_of_small_of_locallySmall _
end FilteredClosure
section
variable [IsFilteredOrEmpty C] {D : Type u₁} [Category.{v₁} D] (F : D ⥤ C)
/-- Every functor from a small category to a filtered category factors fully faithfully through a
small filtered category. This is that category. -/
def SmallFilteredIntermediate : Type (max u₁ v) :=
SmallModel.{max u₁ v} (FullSubcategory (FilteredClosure F.obj))
noncomputable instance : SmallCategory (SmallFilteredIntermediate F) :=
show SmallCategory (SmallModel (FullSubcategory (FilteredClosure F.obj))) from inferInstance
namespace SmallFilteredIntermediate
/-- The first part of a factoring of a functor from a small category to a filtered category through
a small filtered category. -/
noncomputable def factoring : D ⥤ SmallFilteredIntermediate F :=
FullSubcategory.lift _ F FilteredClosure.base ⋙ (equivSmallModel _).functor
/-- The second, fully faithful part of a factoring of a functor from a small category to a filtered
category through a small filtered category. -/
noncomputable def inclusion : SmallFilteredIntermediate F ⥤ C :=
(equivSmallModel _).inverse ⋙ fullSubcategoryInclusion _
instance : (inclusion F).Faithful :=
show ((equivSmallModel _).inverse ⋙ fullSubcategoryInclusion _).Faithful from inferInstance
noncomputable instance : (inclusion F).Full :=
show ((equivSmallModel _).inverse ⋙ fullSubcategoryInclusion _).Full from inferInstance
/-- The factorization through a small filtered category is in fact a factorization, up to natural
isomorphism. -/
noncomputable def factoringCompInclusion : factoring F ⋙ inclusion F ≅ F :=
isoWhiskerLeft _ (isoWhiskerRight (Equivalence.unitIso _).symm _)
instance : IsFilteredOrEmpty (SmallFilteredIntermediate F) :=
IsFilteredOrEmpty.of_equivalence (equivSmallModel _)
instance [Nonempty D] : IsFiltered (SmallFilteredIntermediate F) :=
{ (inferInstance : IsFilteredOrEmpty _) with
nonempty := Nonempty.map (factoring F).obj inferInstance }
end SmallFilteredIntermediate
end
end IsFiltered
namespace IsCofiltered
section CofilteredClosure
variable [IsCofilteredOrEmpty C] {α : Type w} (f : α → C)
/-- The "cofiltered closure" of an `α`-indexed family of objects in `C` is the set of objects in `C`
obtained by starting with the family and successively adding minima and equalizers. -/
inductive CofilteredClosure : C → Prop
| base : (x : α) → CofilteredClosure (f x)
| min : {j j' : C} → CofilteredClosure j → CofilteredClosure j' → CofilteredClosure (min j j')
| eq : {j j' : C} → CofilteredClosure j → CofilteredClosure j' → (f f' : j ⟶ j') →
CofilteredClosure (eq f f')
/-- The full subcategory induced by the cofiltered closure of a family is cofiltered. -/
instance : IsCofilteredOrEmpty (FullSubcategory (CofilteredClosure f)) where
cone_objs j j' :=
⟨⟨min j.1 j'.1, CofilteredClosure.min j.2 j'.2⟩, minToLeft _ _, minToRight _ _, trivial⟩
cone_maps {j j'} f f' :=
⟨⟨eq f f', CofilteredClosure.eq j.2 j'.2 f f'⟩, eqHom (C := C) f f', eq_condition _ _⟩
namespace CofilteredClosureSmall
/-- Implementation detail for the instance
`EssentiallySmall.{max v w} (FullSubcategory (CofilteredClosure f))`. -/
private inductive InductiveStep (n : ℕ) (X : ∀ (k : ℕ), k < n → Σ t : Type (max v w), t → C) :
Type (max v w)
| min : {k k' : ℕ} → (hk : k < n) → (hk' : k' < n) → (X _ hk).1 → (X _ hk').1 → InductiveStep n X
| eq : {k k' : ℕ} → (hk : k < n) → (hk' : k' < n) → (j : (X _ hk).1) → (j' : (X _ hk').1) →
((X _ hk).2 j ⟶ (X _ hk').2 j') → ((X _ hk).2 j ⟶ (X _ hk').2 j') → InductiveStep n X
/-- Implementation detail for the instance
`EssentiallySmall.{max v w} (FullSubcategory (CofilteredClosure f))`. -/
private noncomputable def inductiveStepRealization (n : ℕ)
(X : ∀ (k : ℕ), k < n → Σ t : Type (max v w), t → C) : InductiveStep.{w} n X → C
| (InductiveStep.min hk hk' x y) => min ((X _ hk).2 x) ((X _ hk').2 y)
| (InductiveStep.eq _ _ _ _ f g) => eq f g
/-- Implementation detail for the instance
`EssentiallySmall.{max v w} (FullSubcategory (CofilteredClosure f))`.
The function is defined by well-founded recursion, but we really want to use its
definitional equalities in the proofs below, so lets make it semireducible. -/
@[semireducible] private noncomputable def bundledAbstractCofilteredClosure :
ℕ → Σ t : Type (max v w), t → C
| 0 => ⟨ULift.{v} α, f ∘ ULift.down⟩
| (n + 1) => ⟨_, inductiveStepRealization (n + 1) (fun m _ => bundledAbstractCofilteredClosure m)⟩
/-- Implementation detail for the instance
`EssentiallySmall.{max v w} (FullSubcategory (CofilteredClosure f))`. -/
private noncomputable def AbstractCofilteredClosure : Type (max v w) :=
Σ n, (bundledAbstractCofilteredClosure f n).1
/-- Implementation detail for the instance
`EssentiallySmall.{max v w} (FullSubcategory (CofilteredClosure f))`. -/
private noncomputable def abstractCofilteredClosureRealization : AbstractCofilteredClosure f → C :=
fun x => (bundledAbstractCofilteredClosure f x.1).2 x.2
end CofilteredClosureSmall
theorem small_fullSubcategory_cofilteredClosure :
Small.{max v w} (FullSubcategory (CofilteredClosure f)) := by
refine small_of_injective_of_exists
(CofilteredClosureSmall.abstractCofilteredClosureRealization f)
(fun _ _ => FullSubcategory.ext) ?_
rintro ⟨j, h⟩
induction h with
| base x => exact ⟨⟨0, ⟨x⟩⟩, rfl⟩
| min hj₁ hj₂ ih ih' =>
rcases ih with ⟨⟨n, x⟩, rfl⟩
rcases ih' with ⟨⟨m, y⟩, rfl⟩
refine ⟨⟨(Max.max n m).succ, CofilteredClosureSmall.InductiveStep.min ?_ ?_ x y⟩, rfl⟩
all_goals apply Nat.lt_succ_of_le
exacts [Nat.le_max_left _ _, Nat.le_max_right _ _]
| eq hj₁ hj₂ g g' ih ih' =>
rcases ih with ⟨⟨n, x⟩, rfl⟩
rcases ih' with ⟨⟨m, y⟩, rfl⟩
refine ⟨⟨(Max.max n m).succ, CofilteredClosureSmall.InductiveStep.eq ?_ ?_ x y g g'⟩, rfl⟩
all_goals apply Nat.lt_succ_of_le
exacts [Nat.le_max_left _ _, Nat.le_max_right _ _]
instance : EssentiallySmall.{max v w} (FullSubcategory (CofilteredClosure f)) :=
have : LocallySmall.{max v w} (FullSubcategory (CofilteredClosure f)) :=
locallySmall_max.{w, v, u}
have := small_fullSubcategory_cofilteredClosure f
essentiallySmall_of_small_of_locallySmall _
end CofilteredClosure
section
variable [IsCofilteredOrEmpty C] {D : Type u₁} [Category.{v₁} D] (F : D ⥤ C)
/-- Every functor from a small category to a cofiltered category factors fully faithfully through a
small cofiltered category. This is that category. -/
def SmallCofilteredIntermediate : Type (max u₁ v) :=
SmallModel.{max u₁ v} (FullSubcategory (CofilteredClosure F.obj))
noncomputable instance : SmallCategory (SmallCofilteredIntermediate F) :=
show SmallCategory (SmallModel (FullSubcategory (CofilteredClosure F.obj))) from inferInstance
namespace SmallCofilteredIntermediate
/-- The first part of a factoring of a functor from a small category to a cofiltered category
through a small filtered category. -/
noncomputable def factoring : D ⥤ SmallCofilteredIntermediate F :=
FullSubcategory.lift _ F CofilteredClosure.base ⋙ (equivSmallModel _).functor
/-- The second, fully faithful part of a factoring of a functor from a small category to a filtered
category through a small filtered category. -/
noncomputable def inclusion : SmallCofilteredIntermediate F ⥤ C :=
(equivSmallModel _).inverse ⋙ fullSubcategoryInclusion _
instance : (inclusion F).Faithful :=
show ((equivSmallModel _).inverse ⋙ fullSubcategoryInclusion _).Faithful from inferInstance
noncomputable instance : (inclusion F).Full :=
show ((equivSmallModel _).inverse ⋙ fullSubcategoryInclusion _).Full from inferInstance
/-- The factorization through a small filtered category is in fact a factorization, up to natural
isomorphism. -/
noncomputable def factoringCompInclusion : factoring F ⋙ inclusion F ≅ F :=
isoWhiskerLeft _ (isoWhiskerRight (Equivalence.unitIso _).symm _)
instance : IsCofilteredOrEmpty (SmallCofilteredIntermediate F) :=
IsCofilteredOrEmpty.of_equivalence (equivSmallModel _)
instance [Nonempty D] : IsCofiltered (SmallCofilteredIntermediate F) :=
{ (inferInstance : IsCofilteredOrEmpty _) with
nonempty := Nonempty.map (factoring F).obj inferInstance }
end SmallCofilteredIntermediate
end
end IsCofiltered
end CategoryTheory
|
CategoryTheory\FinCategory\AsType.lean | /-
Copyright (c) 2019 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Scott Morrison
-/
import Mathlib.Data.Fintype.Card
import Mathlib.CategoryTheory.FinCategory.Basic
/-!
# Finite categories are equivalent to category in `Type 0`.
-/
universe w v u
open scoped Classical
noncomputable section
namespace CategoryTheory
namespace FinCategory
variable (α : Type*) [Fintype α] [SmallCategory α] [FinCategory α]
/-- A FinCategory `α` is equivalent to a category with objects in `Type`. -/
--@[nolint unused_arguments]
abbrev ObjAsType : Type :=
InducedCategory α (Fintype.equivFin α).symm
instance {i j : ObjAsType α} : Fintype (i ⟶ j) :=
FinCategory.fintypeHom ((Fintype.equivFin α).symm i) _
/-- The constructed category is indeed equivalent to `α`. -/
noncomputable def objAsTypeEquiv : ObjAsType α ≌ α :=
(inducedFunctor (Fintype.equivFin α).symm).asEquivalence
/-- A FinCategory `α` is equivalent to a fin_category with in `Type`. -/
--@[nolint unused_arguments]
abbrev AsType : Type :=
Fin (Fintype.card α)
@[simps (config := .lemmasOnly) id comp]
noncomputable instance categoryAsType : SmallCategory (AsType α) where
Hom i j := Fin (Fintype.card (@Quiver.Hom (ObjAsType α) _ i j))
id i := Fintype.equivFin _ (𝟙 _)
comp f g := Fintype.equivFin _ ((Fintype.equivFin _).symm f ≫ (Fintype.equivFin _).symm g)
attribute [local simp] categoryAsType_id categoryAsType_comp
/-- The "identity" functor from `AsType α` to `ObjAsType α`. -/
@[simps]
noncomputable def asTypeToObjAsType : AsType α ⥤ ObjAsType α where
obj := id
map {X Y} := (Fintype.equivFin _).symm
/-- The "identity" functor from `ObjAsType α` to `AsType α`. -/
@[simps]
noncomputable def objAsTypeToAsType : ObjAsType α ⥤ AsType α where
obj := id
map {X Y} := Fintype.equivFin _
/-- The constructed category (`AsType α`) is equivalent to `ObjAsType α`. -/
noncomputable def asTypeEquivObjAsType : AsType α ≌ ObjAsType α :=
Equivalence.mk (asTypeToObjAsType α) (objAsTypeToAsType α)
(NatIso.ofComponents Iso.refl)
(NatIso.ofComponents Iso.refl)
noncomputable instance asTypeFinCategory : FinCategory (AsType α) where
fintypeHom := fun _ _ => show Fintype (Fin _) from inferInstance
/-- The constructed category (`ObjAsType α`) is indeed equivalent to `α`. -/
noncomputable def equivAsType : AsType α ≌ α :=
(asTypeEquivObjAsType α).trans (objAsTypeEquiv α)
end FinCategory
end CategoryTheory
|
CategoryTheory\FinCategory\Basic.lean | /-
Copyright (c) 2019 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Scott Morrison
-/
import Mathlib.Data.Fintype.Basic
import Mathlib.CategoryTheory.DiscreteCategory
import Mathlib.CategoryTheory.Opposites
import Mathlib.CategoryTheory.Category.ULift
/-!
# Finite categories
A category is finite in this sense if it has finitely many objects, and finitely many morphisms.
## Implementation
Prior to #14046, `FinCategory` required a `DecidableEq` instance on the object and morphism types.
This does not seem to have had any practical payoff (i.e. making some definition constructive)
so we have removed these requirements to avoid
having to supply instances or delay with non-defeq conflicts between instances.
-/
universe w v u
open scoped Classical
noncomputable section
namespace CategoryTheory
instance discreteFintype {α : Type*} [Fintype α] : Fintype (Discrete α) :=
Fintype.ofEquiv α discreteEquiv.symm
instance discreteHomFintype {α : Type*} (X Y : Discrete α) : Fintype (X ⟶ Y) := by
apply ULift.fintype
/-- A category with a `Fintype` of objects, and a `Fintype` for each morphism space. -/
class FinCategory (J : Type v) [SmallCategory J] where
fintypeObj : Fintype J := by infer_instance
fintypeHom : ∀ j j' : J, Fintype (j ⟶ j') := by infer_instance
attribute [instance] FinCategory.fintypeObj FinCategory.fintypeHom
instance finCategoryDiscreteOfFintype (J : Type v) [Fintype J] : FinCategory (Discrete J) where
open Opposite
/-- The opposite of a finite category is finite.
-/
instance finCategoryOpposite {J : Type v} [SmallCategory J] [FinCategory J] : FinCategory Jᵒᵖ where
fintypeObj := Fintype.ofEquiv _ equivToOpposite
fintypeHom j j' := Fintype.ofEquiv _ (opEquiv j j').symm
/-- Applying `ULift` to morphisms and objects of a category preserves finiteness. -/
instance finCategoryUlift {J : Type v} [SmallCategory J] [FinCategory J] :
FinCategory.{max w v} (ULiftHom.{w, max w v} (ULift.{w, v} J)) where
fintypeObj := ULift.fintype J
fintypeHom := fun _ _ => ULift.fintype _
end CategoryTheory
|
CategoryTheory\Functor\Basic.lean | /-
Copyright (c) 2017 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Tim Baumann, Stephen Morgan, Scott Morrison
-/
import Mathlib.CategoryTheory.Category.Basic
/-!
# 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.
-/
namespace CategoryTheory
-- declare the `v`'s first; see note [CategoryTheory 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.
See <https://stacks.math.columbia.edu/tag/001B>.
-/
structure Functor (C : Type u₁) [Category.{v₁} C] (D : Type u₂) [Category.{v₂} D]
extends Prefunctor C D : Type max v₁ v₂ u₁ u₂ where
/-- A functor preserves identity morphisms. -/
map_id : ∀ X : C, map (𝟙 X) = 𝟙 (obj X) := by aesop_cat
/-- A functor preserves composition. -/
map_comp : ∀ {X Y Z : C} (f : X ⟶ Y) (g : Y ⟶ Z), map (f ≫ g) = map f ≫ map g := by aesop_cat
/-- The prefunctor between the underlying quivers. -/
add_decl_doc Functor.toPrefunctor
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
-- 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
rw [F.map_comp, Category.assoc]
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]
theorem id_obj (X : C) : (𝟭 C).obj X = X := rfl
@[simp]
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]
/-- `F ⋙ G` is the composition of a functor `F` and a functor `G` (`F` first, then `G`).
-/
@[simps 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)
map_comp := by intros; dsimp; rw [F.map_comp, G.map_comp]
/-- Notation for composition of functors. -/
scoped [CategoryTheory] infixr:80 " ⋙ " => Functor.comp
@[simp]
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
aesop_cat
@[simp]
theorem toPrefunctor_comp (F : C ⥤ D) (G : D ⥤ E) :
F.toPrefunctor.comp G.toPrefunctor = (F ⋙ G).toPrefunctor := rfl
end
end Functor
end CategoryTheory
|
CategoryTheory\Functor\Category.lean | /-
Copyright (c) 2017 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Tim Baumann, Stephen Morgan, Scott Morrison, Floris van Doorn
-/
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.
## 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.
-/
namespace CategoryTheory
-- declare the `v`'s first; see note [CategoryTheory universes].
universe v₁ v₂ v₃ 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 {F G H I : C ⥤ D}
/-- `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
-- Porting note: the behaviour of `ext` has changed here.
-- We need to provide a copy of the `NatTrans.ext` lemma,
-- written in terms of `F ⟶ G` rather than `NatTrans F G`,
-- or `ext` will not retrieve it from the cache.
@[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]
theorem id_app (F : C ⥤ D) (X : C) : (𝟙 F : F ⟶ F).app X = 𝟙 (F.obj X) := rfl
@[simp]
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]
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
/-- 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]
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)
naturality X Y f := by
rw [Functor.comp_map, Functor.comp_map, ← assoc, naturality, assoc, ← map_comp I, naturality,
map_comp, assoc]
/-- 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
aesop_cat
end NatTrans
open NatTrans
namespace Functor
/-- Flip the arguments of a bifunctor. See also `Currying.lean`. -/
@[simps]
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 }
end Functor
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
simp [← NatTrans.comp_app, ← Functor.map_comp]
@[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
simp [← NatTrans.comp_app, ← Functor.map_comp]
end Iso
@[deprecated (since := "2024-06-09")] alias map_hom_inv_app := Iso.map_hom_inv_id_app
@[deprecated (since := "2024-06-09")] alias map_inv_hom_app := Iso.map_inv_hom_id_app
@[deprecated (since := "2024-06-09")] alias map_hom_inv_app_assoc := Iso.map_hom_inv_id_app_assoc
@[deprecated (since := "2024-06-09")] alias map_inv_hom_app_assoc := Iso.map_inv_hom_id_app_assoc
end CategoryTheory
|
CategoryTheory\Functor\Const.lean | /-
Copyright (c) 2018 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Scott Morrison, Bhavik Mehta
-/
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 j => 𝟙 _ }
inv := { app := fun j => 𝟙 _ }
/-- 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 j => 𝟙 _ }
inv := { app := fun j => 𝟙 _ }
-- 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 j => Iso.refl _) (by aesop_cat))
(by aesop_cat)
end
end CategoryTheory.Functor
|
CategoryTheory\Functor\Currying.lean | /-
Copyright (c) 2017 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Scott Morrison
-/
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)`.
-/
namespace CategoryTheory
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 [prod_comp_fst, prod_comp_snd, Category.comp_id, Category.assoc, Functor.map_id,
Functor.map_comp, NatTrans.id_app, NatTrans.comp_app]
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 [F.map_id]; 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; dsimp; 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 :=
Equivalence.mk uncurry curry
(NatIso.ofComponents fun F =>
NatIso.ofComponents fun X => NatIso.ofComponents fun Y => Iso.refl _)
(NatIso.ofComponents fun F => NatIso.ofComponents (fun X => eqToIso (by simp))
(by intros X Y f; cases X; cases Y; cases f; dsimp at *; rw [← F.map_comp]; simp))
/-- `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 c => 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 p => 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
namespace Functor
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 aesop_cat)
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])
end Functor
end CategoryTheory
|
CategoryTheory\Functor\EpiMono.lean | /-
Copyright (c) 2022 Markus Himmel. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Markus Himmel
-/
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⟩
theorem preservesMonomorphisms.of_iso {F G : C ⥤ D} [PreservesMonomorphisms F] (α : F ≅ G) :
PreservesMonomorphisms G :=
{ preserves := fun {X} {Y} f h => by
haveI : Mono (F.map f ≫ (α.app Y).hom) := mono_comp _ _
convert (mono_comp _ _ : Mono ((α.app X).inv ≫ F.map f ≫ (α.app Y).hom))
rw [Iso.eq_inv_comp, Iso.app_hom, Iso.app_hom, NatTrans.naturality] }
theorem preservesMonomorphisms.iso_iff {F G : C ⥤ D} (α : F ≅ G) :
PreservesMonomorphisms F ↔ PreservesMonomorphisms G :=
⟨fun _ => preservesMonomorphisms.of_iso α, fun _ => preservesMonomorphisms.of_iso α.symm⟩
theorem preservesEpimorphisms.of_iso {F G : C ⥤ D} [PreservesEpimorphisms F] (α : F ≅ G) :
PreservesEpimorphisms G :=
{ preserves := fun {X} {Y} f h => by
haveI : Epi (F.map f ≫ (α.app Y).hom) := epi_comp _ _
convert (epi_comp _ _ : Epi ((α.app X).inv ≫ F.map f ≫ (α.app Y).hom))
rw [Iso.eq_inv_comp, Iso.app_hom, Iso.app_hom, NatTrans.naturality] }
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
haveI : Mono (G.map f ≫ (α.app Y).inv) := mono_comp _ _
convert (mono_comp _ _ : Mono ((α.app X).hom ≫ G.map f ≫ (α.app Y).inv))
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
haveI : Epi (G.map f ≫ (α.app Y).inv) := epi_comp _ _
convert (epi_comp _ _ : Epi ((α.app X).hom ≫ G.map f ≫ (α.app Y).inv))
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 preservesEpimorphsisms_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⟩ }
instance (priority := 100) preservesEpimorphisms_of_isLeftAdjoint (F : C ⥤ D) [IsLeftAdjoint F] :
PreservesEpimorphisms F :=
preservesEpimorphsisms_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 hf :=
⟨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 hf :=
⟨fun {Z} g h hgh =>
F.map_injective ((cancel_epi (F.map f)).1 (by rw [← F.map_comp, hgh, F.map_comp]))⟩
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 aesop_cat
right_inv x := by aesop_cat
@[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 aesop_cat
right_inv x := by aesop_cat
@[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) [h₁ : F'.PreservesMonomorphisms]
[h₂ : 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
|
CategoryTheory\Functor\Flat.lean | /-
Copyright (c) 2021 Andrew Yang. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Andrew Yang
-/
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.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.
* `preservesFiniteLimitsOfFlat`: If `F : C ⥤ D` is flat, then it preserves all finite limits.
* `preservesFiniteLimitsIffFlat`: If `C` has all finite limits,
then `F` is flat iff `F` is left_exact.
* `lanPreservesFiniteLimitsOfFlat`: 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.
* `preservesFiniteLimitsIffLanPreservesFiniteLimits`: 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 functor if the comma category `(X/F)`
is cofiltered for each `X : C`.
-/
class RepresentablyFlat (F : C ⥤ D) : Prop where
cofiltered : ∀ X : D, IsCofiltered (StructuredArrow X F)
attribute [instance] RepresentablyFlat.cofiltered
instance RepresentablyFlat.of_isRightAdjoint (F : C ⥤ D) [F.IsRightAdjoint] :
RepresentablyFlat F where
cofiltered _ := IsCofiltered.of_isInitial _ (mkInitialOfLeftAdjoint _ (.ofIsRightAdjoint F) _)
theorem RepresentablyFlat.id : RepresentablyFlat (𝟭 C) := inferInstance
instance RepresentablyFlat.comp (F : C ⥤ D) (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₂
exact ⟨⟨StructuredArrow.mk (c₁.pt.hom ≫ G.map c₂.pt.hom),
⟨fun j => StructuredArrow.homMk (c₂.π.app j).right (by simp [← G.map_comp, (c₂.π.app j).w]),
fun j j' f => by simpa using (c₂.w f).symm⟩⟩⟩
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)
intro J sJ fJ
constructor
-- Porting note: instance was inferred automatically in Lean 3
infer_instance
IsCofiltered.of_hasFiniteLimits _⟩
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 X => 𝟙 _ } :
(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 (whiskerRight α₁ (pre s.pt K F) : _)).obj (c.toStructuredArrowCone F f₁)
let c₂ : Cone (s.toStructuredArrow ⋙ pre s.pt K F) :=
(Cones.postcompose (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 _)
-- Porting note: was `by tidy`, but `aesop` only works if max heartbeats
-- is increased, so we replace it by the output of `tidy?`
intro j; rfl
_ = hc.lift (c.extend g₂.right) := by
congr
_ = g₂.right := by
symm
apply hc.uniq (c.extend _)
-- Porting note: was `by tidy`, but `aesop` only works if max heartbeats
-- is increased, so we replace it by the output of `tidy?`
intro _; rfl
-- 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. -/
noncomputable def preservesFiniteLimitsOfFlat (F : C ⥤ D) [RepresentablyFlat F] :
PreservesFiniteLimits F := by
apply preservesFiniteLimitsOfPreservesFiniteLimitsOfSize
intro J _ _; constructor
intro K; constructor
intro c hc
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 }
/-- If `C` is finitely cocomplete, then `F : C ⥤ D` is representably flat iff it preserves
finite limits.
-/
noncomputable def preservesFiniteLimitsIffFlat [HasFiniteLimits C] (F : C ⥤ D) :
RepresentablyFlat F ≃ PreservesFiniteLimits F where
toFun _ := preservesFiniteLimitsOfFlat F
invFun _ := flat_of_preservesFiniteLimits F
left_inv _ := proof_irrel _ _
right_inv x := by
cases x
unfold preservesFiniteLimitsOfFlat
dsimp only [preservesFiniteLimitsOfPreservesFiniteLimitsOfSize]
congr
-- Porting note: this next line wasn't needed in lean 3
subsingleton
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 ≅
(whiskeringLeft _ _ E).obj (CostructuredArrow.proj F X) ⋙ colim :=
NatIso.ofComponents (fun G =>
IsColimit.coconePointUniqueUpToIso (Functor.isPointwiseLeftKanExtensionLanUnit F G X)
(colimit.isColimit _)) (fun {G₁ G₂} φ => by
apply (Functor.isPointwiseLeftKanExtensionLanUnit F G₁ X).hom_ext
intro T
have h₁ := fun (G : C ⥤ E) => IsColimit.comp_coconePointUniqueUpToIso_hom
(Functor.isPointwiseLeftKanExtensionLanUnit 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₁ ⊢
rw [reassoc_of% h₁, NatTrans.naturality_assoc, ← reassoc_of% h₂, h₁,
ι_colimMap, whiskerLeft_app]
rfl)
variable [ConcreteCategory.{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 lanPreservesFiniteLimitsOfFlat (F : C ⥤ D) [RepresentablyFlat F] :
PreservesFiniteLimits (F.op.lan : _ ⥤ Dᵒᵖ ⥤ E) := by
apply preservesFiniteLimitsOfPreservesFiniteLimitsOfSize.{u₁}
intro J _ _
apply preservesLimitsOfShapeOfEvaluation (F.op.lan : (Cᵒᵖ ⥤ E) ⥤ Dᵒᵖ ⥤ E) J
intro K
haveI : IsFiltered (CostructuredArrow F.op K) :=
IsFiltered.of_equivalence (structuredArrowOpEquivalence F (unop K))
exact preservesLimitsOfShapeOfNatIso (lanEvaluationIsoColim _ _ _).symm
instance lan_flat_of_flat (F : C ⥤ D) [RepresentablyFlat F] :
RepresentablyFlat (F.op.lan : _ ⥤ Dᵒᵖ ⥤ E) :=
flat_of_preservesFiniteLimits _
variable [HasFiniteLimits C]
noncomputable instance lanPreservesFiniteLimitsOfPreservesFiniteLimits (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 H => inferInstance, fun H => by
haveI := preservesFiniteLimitsOfFlat (F.op.lan : _ ⥤ Dᵒᵖ ⥤ Type u₁)
haveI : PreservesFiniteLimits F := by
apply preservesFiniteLimitsOfPreservesFiniteLimitsOfSize.{u₁}
intros; apply preservesLimitOfLanPreservesLimit
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.
-/
noncomputable def preservesFiniteLimitsIffLanPreservesFiniteLimits (F : C ⥤ D) :
PreservesFiniteLimits F ≃ PreservesFiniteLimits (F.op.lan : _ ⥤ Dᵒᵖ ⥤ Type u₁) where
toFun _ := inferInstance
invFun _ := by
apply preservesFiniteLimitsOfPreservesFiniteLimitsOfSize.{u₁}
intros; apply preservesLimitOfLanPreservesLimit
left_inv x := by
-- Porting note: `cases x` and an `unfold` not necessary in lean 4.
-- Remark : in mathlib3 we had `unfold preservesFiniteLimitsOfFlat`
-- but there was no `preservesFiniteLimitsOfFlat` in the goal! Experimentation
-- indicates that it was doing the same as `dsimp only`
dsimp only [preservesFiniteLimitsOfPreservesFiniteLimitsOfSize]; congr
-- Porting note: next line wasn't necessary in lean 3
subsingleton
right_inv x := by
-- cases x; -- Porting note: not necessary in lean 4
dsimp only [lanPreservesFiniteLimitsOfPreservesFiniteLimits,
lanPreservesFiniteLimitsOfFlat,
preservesFiniteLimitsOfPreservesFiniteLimitsOfSize]
congr
-- Porting note: next line wasn't necessary in lean 3
subsingleton
end SmallCategory
end CategoryTheory
|
CategoryTheory\Functor\FullyFaithful.lean | /-
Copyright (c) 2018 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Scott Morrison
-/
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.
See <https://stacks.math.columbia.edu/tag/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.
See <https://stacks.math.columbia.edu/tag/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
aesop_cat
variable {X Y : C}
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 aesop_cat
preimage_map {X Y : C} (f : X ⟶ Y) : preimage (F.map f) = f := by aesop_cat
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)
/-- 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
lemma full : F.Full where
map_surjective := hF.map_surjective
lemma faithful : F.Faithful where
map_injective := hF.map_injective
/-- 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 (hF : F.FullyFaithful) {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 aesop_cat
right_inv := by aesop_cat
/-- 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}, HEq (G.map (map f)) (F.map f)) : C ⥤ D :=
{ obj, map := @map,
map_id := by
intros X
apply G.map_injective
apply eq_of_heq
trans F.map (𝟙 X)
· exact h_map
· rw [F.map_id, G.map_id, h_obj X]
map_comp := by
intros X Y Z f g
refine G.map_injective <| eq_of_heq <| h_map.trans ?_
simp only [Functor.map_comp]
convert HEq.refl (F.map f ≫ F.map g)
all_goals { first | apply h_obj | apply h_map } }
-- 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}, HEq (G.map (map f)) (F.map f)) :
Faithful.div F G obj @h_obj @map @h_map ⋙ G = F := by
-- Porting note: Have to unfold the structure twice because the first one recovers only the
-- prefunctor `F_pre`
cases' F with F_pre _ _; cases' G with G_pre _ _
cases' F_pre with F_obj _; cases' G_pre with G_obj _
unfold Faithful.div Functor.comp
-- Porting note: unable to find the lean4 analogue to `unfold_projs`, works without it
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}, HEq (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
@[deprecated (since := "2024-04-06")] alias Full := Functor.Full
@[deprecated (since := "2024-04-06")] alias Faithful := Functor.Faithful
@[deprecated (since := "2024-04-06")] alias preimage_id := Functor.preimage_id
@[deprecated (since := "2024-04-06")] alias preimage_comp := Functor.preimage_comp
@[deprecated (since := "2024-04-06")] alias preimage_map := Functor.preimage_map
@[deprecated (since := "2024-04-06")] alias Faithful.of_comp := Functor.Faithful.of_comp
@[deprecated (since := "2024-04-06")] alias Full.ofIso := Functor.Full.of_iso
@[deprecated (since := "2024-04-06")] alias Faithful.of_iso := Functor.Faithful.of_iso
@[deprecated (since := "2024-04-06")] alias Faithful.of_comp_iso := Functor.Faithful.of_comp_iso
@[deprecated (since := "2024-04-06")] alias Faithful.of_comp_eq := Functor.Faithful.of_comp_eq
@[deprecated (since := "2024-04-06")] alias Faithful.div := Functor.Faithful.div
@[deprecated (since := "2024-04-06")] alias Faithful.div_comp := Functor.Faithful.div_comp
@[deprecated (since := "2024-04-06")] alias Faithful.div_faithful := Functor.Faithful.div_faithful
@[deprecated (since := "2024-04-06")] alias Full.ofCompFaithful := Functor.Full.of_comp_faithful
@[deprecated (since := "2024-04-06")]
alias Full.ofCompFaithfulIso := Functor.Full.of_comp_faithful_iso
@[deprecated (since := "2024-04-06")]
alias fullyFaithfulCancelRight := Functor.fullyFaithfulCancelRight
@[deprecated (since := "2024-04-06")]
alias fullyFaithfulCancelRight_hom_app := Functor.fullyFaithfulCancelRight_hom_app
@[deprecated (since := "2024-04-06")]
alias fullyFaithfulCancelRight_inv_app := Functor.fullyFaithfulCancelRight_inv_app
@[deprecated (since := "2024-04-26")] alias Functor.image_preimage := Functor.map_preimage
end CategoryTheory
|
CategoryTheory\Functor\Functorial.lean | /-
Copyright (c) 2019 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Scott Morrison
-/
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
/-- A functorial map extends to an action on morphisms. -/
map' : ∀ {X Y : C}, (X ⟶ Y) → (F X ⟶ F Y)
/-- A functorial map preserves identities. -/
map_id' : ∀ X : C, map' (𝟙 X) = 𝟙 (F X) := by aesop_cat
/-- 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
aesop_cat
/-- 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`.
-/
def map (F : C → D) [Functorial.{v₁, v₂} F] {X Y : C} (f : X ⟶ Y) : F X ⟶ F Y :=
Functorial.map'.{v₁, v₂} f
@[simp]
theorem map'_as_map {F : C → D} [Functorial.{v₁, v₂} F] {X Y : C} {f : X ⟶ Y} :
Functorial.map'.{v₁, v₂} f = map F f :=
rfl
@[simp]
theorem Functorial.map_id {F : C → D} [Functorial.{v₁, v₂} F] {X : C} : map F (𝟙 X) = 𝟙 (F X) :=
Functorial.map_id' X
@[simp]
theorem Functorial.map_comp {F : C → D} [Functorial.{v₁, v₂} F] {X Y Z : C} {f : X ⟶ Y}
{g : Y ⟶ Z} : map F (f ≫ g) = map F f ≫ map F g :=
Functorial.map_comp' f g
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 := map F }
end Functor
instance (F : C ⥤ D) : Functorial.{v₁, v₂} F.obj :=
{ F with map' := F.map }
@[simp]
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
|
CategoryTheory\Functor\Hom.lean | /-
Copyright (c) 2018 Reid Barton. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Reid Barton, Scott Morrison
-/
import Mathlib.CategoryTheory.Products.Basic
import Mathlib.CategoryTheory.Types
/-!
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
|
CategoryTheory\Functor\OfSequence.lean | /-
Copyright (c) 2024 Joël Riou. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Joël Riou
-/
import Mathlib.Algebra.Order.Group.Nat
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`.
-/
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)
| _, _, k + 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 omega) = 𝟙 _ := 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 omega) = 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
revert X f j k
induction i with
| zero =>
intros X f j
revert X f
induction j with
| zero =>
intros X f k hij hjk
rw [map_id, id_comp]
| succ j hj =>
rintro X f (_|_|k) hij hjk
· omega
· obtain rfl : j = 0 := by omega
rw [map_id, comp_id]
· dsimp [map]
rw [hj (fun n ↦ f (n + 1)) (k + 1) (by omega) (by omega)]
obtain _|j := j
all_goals simp [map]
| succ i hi =>
rintro X f (_|j) (_|k)
· omega
· omega
· omega
· intros
exact hi _ j k (by omega) (by omega)
-- `map` has good definitional properties when applied to explicit natural numbers
example : map f 5 5 (by omega) = 𝟙 _ := rfl
example : map f 0 3 (by omega) = f 0 ≫ f 1 ≫ f 2 := rfl
example : map f 3 7 (by omega) = 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
end CategoryTheory
|
CategoryTheory\Functor\ReflectsIso.lean | /-
Copyright (c) 2020 Bhavik Mehta. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Bhavik Mehta
-/
import Mathlib.CategoryTheory.Balanced
import Mathlib.CategoryTheory.Functor.EpiMono
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.
-/
open CategoryTheory CategoryTheory.Functor
namespace CategoryTheory
universe v₁ v₂ v₃ u₁ u₂ u₃
variable {C : Type u₁} [Category.{v₁} C]
section ReflectsIso
variable {D : Type u₂} [Category.{v₂} D]
variable {E : Type u₃} [Category.{v₃} E]
/-- 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
@[deprecated (since := "2024-04-06")] alias ReflectsIsomorphisms := Functor.ReflectsIsomorphisms
/-- 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 (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
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
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 ReflectsIso
end CategoryTheory
|
CategoryTheory\Functor\Trifunctor.lean | /-
Copyright (c) 2023 Joël Riou. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Joël Riou
-/
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
variable (F₁₂ : C₁ ⥤ C₂ ⥤ C₁₂) (G : C₁₂ ⥤ C₃ ⥤ C₄)
/-- Auxiliary definition for `bifunctorComp₁₂`. -/
@[simps]
def bifunctorComp₁₂Obj (X₁ : C₁) : C₂ ⥤ C₃ ⥤ C₄ where
obj X₂ :=
{ obj := fun X₃ => (G.obj ((F₁₂.obj X₁).obj X₂)).obj X₃
map := fun {X₃ Y₃} φ => (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₁₂ : 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] }
end
section
variable (F : C₁ ⥤ C₂₃ ⥤ C₄) (G₂₃ : C₂ ⥤ C₃ ⥤ C₂₃)
/-- Auxiliary definition for `bifunctorComp₂₃`. -/
@[simps]
def bifunctorComp₂₃Obj (X₁ : C₁) : C₂ ⥤ C₃ ⥤ C₄ where
obj X₂ :=
{ obj := fun X₃ => (F.obj X₁).obj ((G₂₃.obj X₂).obj X₃)
map := fun {X₃ Y₃} φ => (F.obj X₁).map ((G₂₃.obj X₂).map φ) }
map {X₂ Y₂} φ :=
{ app := fun X₃ => (F.obj X₁).map ((G₂₃.map φ).app X₃)
naturality := fun {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₂₃ : 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₃) } }
end
end CategoryTheory
|
CategoryTheory\Functor\Derived\RightDerived.lean | /-
Copyright (c) 2024 Joël Riou. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Joël Riou
-/
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 [L.IsLocalization W] : Prop where
isLeftKanExtension' : RF.IsLeftKanExtension α
lemma IsRightDerivedFunctor.isLeftKanExtension
[L.IsLocalization W] [RF.IsRightDerivedFunctor α W] :
RF.IsLeftKanExtension α :=
IsRightDerivedFunctor.isLeftKanExtension' W
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]
[RF'.IsRightDerivedFunctor α' 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
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 aesop_cat)
@[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 aesop_cat)
/-- 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}
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.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
|
CategoryTheory\Functor\KanExtension\Adjunction.lean | /-
Copyright (c) 2024 Joël Riou. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Joël Riou
-/
import Mathlib.CategoryTheory.Functor.KanExtension.Pointwise
/-! # 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
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
/-- 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 isPointwiseLeftKanExtensionLanUnit
(F : C ⥤ H) [HasPointwiseLeftKanExtension L F] :
(LeftExtension.mk _ (L.lanUnit.app F)).IsPointwiseLeftKanExtension :=
isPointwiseLeftKanExtensionOfIsLeftKanExtension (F := F) _ (L.lanUnit.app 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
end
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) :=
(isPointwiseLeftKanExtensionLanUnit 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)
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
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
|
CategoryTheory\Functor\KanExtension\Basic.lean | /-
Copyright (c) 2024 Joël Riou. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Joël Riou
-/
import Mathlib.CategoryTheory.Comma.StructuredArrow
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
namespace Functor
variable {C C' H H' D D' : Type*} [Category C] [Category C'] [Category H] [Category H']
[Category D] [Category D']
/-- Given two functors `L : C ⥤ D` and `F : C ⥤ H`, this is the category of functors
`F' : H ⥤ D` 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' : H ⥤ D` 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`. -/
noncomputable def homEquivOfIsRightKanExtension (G : D ⥤ H) :
(G ⟶ F') ≃ (L ⋙ G ⟶ F) where
toFun β := whiskerLeft _ β ≫ α
invFun β := liftOfIsRightKanExtension _ α _ β
left_inv β := Functor.hom_ext_of_isRightKanExtension _ α _ _ (by aesop_cat)
right_inv := by aesop_cat
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`. -/
noncomputable def homEquivOfIsLeftKanExtension (G : D ⥤ H) :
(F' ⟶ G) ≃ (F ⟶ L ⋙ G) where
toFun β := α ≫ whiskerLeft _ β
invFun β := descOfIsLeftKanExtension _ α _ β
left_inv β := Functor.hom_ext_of_isLeftKanExtension _ α _ _ (by aesop_cat)
right_inv := by aesop_cat
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 (e : L ⋙ G ≅ L') (F : C ⥤ H)
variable {G} in
lemma hasLeftExtension_iff_postcomp₁ :
HasLeftKanExtension L' F ↔ HasLeftKanExtension L F :=
(LeftExtension.postcomp₁ G e.inv F).asEquivalence.hasInitial_iff
variable {G} in
lemma hasRightExtension_iff_postcomp₁ :
HasRightKanExtension L' F ↔ HasRightKanExtension L F :=
(RightExtension.postcomp₁ G e.hom F).asEquivalence.hasTerminal_iff
/-- 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 _ ≫ (Functor.associator _ _ _).hom) := by
let eq : (LeftExtension.mk _ α).IsUniversal ≃
(LeftExtension.mk _
(α ≫ whiskerRight e.inv _ ≫ (Functor.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
((Functor.associator _ _ _).inv ≫ whiskerRight e.hom F' ≫ α) := by
let eq : (RightExtension.mk _ α).IsUniversal ≃
(RightExtension.mk _
((Functor.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) (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 α ≫ (Functor.associator _ _ _).inv) := by
let eq : (LeftExtension.mk _ α).IsUniversal ≃ (LeftExtension.mk _
(whiskerLeft G α ≫ (Functor.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 ((Functor.associator _ _ _).hom ≫ whiskerLeft G α) := by
let eq : (RightExtension.mk _ α).IsUniversal ≃ (RightExtension.mk _
((Functor.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₁)
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'`. -/
def leftExtensionEquivalenceOfIso₁ : LeftExtension L F ≌ LeftExtension L' F :=
StructuredArrow.mapNatIso ((whiskeringLeft C D H).mapIso iso₁)
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₂
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₂
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
end Functor
end CategoryTheory
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.