path
stringlengths
11
71
content
stringlengths
75
124k
CategoryTheory\Monoidal\Subcategory.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.Monoidal.Braided.Basic import Mathlib.CategoryTheory.Monoidal.Linear import Mathlib.CategoryTheory.Monoidal.Transport import Mathlib.CategoryTheory.Preadditive.AdditiveFunctor import Mathlib.CategoryTheory.Linear.LinearFunctor import Mathlib.CategoryTheory.Closed.Monoidal /-! # Full monoidal subcategories Given a monoidal category `C` and a monoidal predicate on `C`, that is a function `P : C → Prop` closed under `𝟙_` and `⊗`, we can put a monoidal structure on `{X : C // P X}` (the category structure is defined in `Mathlib.CategoryTheory.FullSubcategory`). When `C` is also braided/symmetric, the full monoidal subcategory also inherits the braided/symmetric structure. ## TODO * Add monoidal/braided versions of `CategoryTheory.FullSubcategory.Lift` -/ universe u v namespace CategoryTheory namespace MonoidalCategory open Iso variable {C : Type u} [Category.{v} C] [MonoidalCategory C] (P : C → Prop) /-- A property `C → Prop` is a monoidal predicate if it is closed under `𝟙_` and `⊗`. -/ class MonoidalPredicate : Prop where prop_id : P (𝟙_ C) := by aesop_cat prop_tensor : ∀ {X Y}, P X → P Y → P (X ⊗ Y) := by aesop_cat open MonoidalPredicate variable [MonoidalPredicate P] @[simps] instance : MonoidalCategoryStruct (FullSubcategory P) where tensorObj X Y := ⟨X.1 ⊗ Y.1, prop_tensor X.2 Y.2⟩ whiskerLeft X _ _ f := X.1 ◁ f whiskerRight {X₁ X₂} (f : X₁.1 ⟶ X₂.1) Y := (f ▷ Y.1 :) tensorHom f g := f ⊗ g tensorUnit := ⟨𝟙_ C, prop_id⟩ associator X Y Z := ⟨(α_ X.1 Y.1 Z.1).hom, (α_ X.1 Y.1 Z.1).inv, hom_inv_id (α_ X.1 Y.1 Z.1), inv_hom_id (α_ X.1 Y.1 Z.1)⟩ leftUnitor X := ⟨(λ_ X.1).hom, (λ_ X.1).inv, hom_inv_id (λ_ X.1), inv_hom_id (λ_ X.1)⟩ rightUnitor X := ⟨(ρ_ X.1).hom, (ρ_ X.1).inv, hom_inv_id (ρ_ X.1), inv_hom_id (ρ_ X.1)⟩ /-- When `P` is a monoidal predicate, the full subcategory for `P` inherits the monoidal structure of `C`. -/ instance fullMonoidalSubcategory : MonoidalCategory (FullSubcategory P) := Monoidal.induced (fullSubcategoryInclusion P) { μIso := fun X Y => eqToIso rfl εIso := eqToIso rfl } /-- The forgetful monoidal functor from a full monoidal subcategory into the original category ("forgetting" the condition). -/ @[simps] def fullMonoidalSubcategoryInclusion : MonoidalFunctor (FullSubcategory P) C where toFunctor := fullSubcategoryInclusion P ε := 𝟙 _ μ X Y := 𝟙 _ instance fullMonoidalSubcategory.full : (fullMonoidalSubcategoryInclusion P).Full := FullSubcategory.full P instance fullMonoidalSubcategory.faithful : (fullMonoidalSubcategoryInclusion P).Faithful := FullSubcategory.faithful P section variable [Preadditive C] instance fullMonoidalSubcategoryInclusion_additive : (fullMonoidalSubcategoryInclusion P).toFunctor.Additive := Functor.fullSubcategoryInclusion_additive _ instance [MonoidalPreadditive C] : MonoidalPreadditive (FullSubcategory P) := monoidalPreadditive_of_faithful (fullMonoidalSubcategoryInclusion P) variable (R : Type*) [Ring R] [Linear R C] instance fullMonoidalSubcategoryInclusion_linear : (fullMonoidalSubcategoryInclusion P).toFunctor.Linear R := Functor.fullSubcategoryInclusionLinear R _ instance [MonoidalPreadditive C] [MonoidalLinear R C] : MonoidalLinear R (FullSubcategory P) := monoidalLinearOfFaithful R (fullMonoidalSubcategoryInclusion P) end variable {P} {P' : C → Prop} [MonoidalPredicate P'] -- needed for `aesop_cat` attribute [local simp] FullSubcategory.comp_def FullSubcategory.id_def in /-- An implication of predicates `P → P'` induces a monoidal functor between full monoidal subcategories. -/ @[simps] def fullMonoidalSubcategory.map (h : ∀ ⦃X⦄, P X → P' X) : MonoidalFunctor (FullSubcategory P) (FullSubcategory P') where toFunctor := FullSubcategory.map h ε := 𝟙 _ μ X Y := 𝟙 _ instance fullMonoidalSubcategory.map_full (h : ∀ ⦃X⦄, P X → P' X) : (fullMonoidalSubcategory.map h).Full where map_surjective f := ⟨f, rfl⟩ instance fullMonoidalSubcategory.map_faithful (h : ∀ ⦃X⦄, P X → P' X) : (fullMonoidalSubcategory.map h).Faithful where section Braided variable (P) [BraidedCategory C] /-- The braided structure on a full subcategory inherited by the braided structure on `C`. -/ instance fullBraidedSubcategory : BraidedCategory (FullSubcategory P) := braidedCategoryOfFaithful (fullMonoidalSubcategoryInclusion P) (fun X Y => ⟨(β_ X.1 Y.1).hom, (β_ X.1 Y.1).inv, (β_ X.1 Y.1).hom_inv_id, (β_ X.1 Y.1).inv_hom_id⟩) fun X Y => by aesop_cat /-- The forgetful braided functor from a full braided subcategory into the original category ("forgetting" the condition). -/ @[simps!] def fullBraidedSubcategoryInclusion : BraidedFunctor (FullSubcategory P) C where toMonoidalFunctor := fullMonoidalSubcategoryInclusion P braided X Y := by rw [IsIso.eq_inv_comp]; aesop_cat instance fullBraidedSubcategory.full : (fullBraidedSubcategoryInclusion P).Full := fullMonoidalSubcategory.full P instance fullBraidedSubcategory.faithful : (fullBraidedSubcategoryInclusion P).Faithful := fullMonoidalSubcategory.faithful P variable {P} /-- An implication of predicates `P → P'` induces a braided functor between full braided subcategories. -/ @[simps!] def fullBraidedSubcategory.map (h : ∀ ⦃X⦄, P X → P' X) : BraidedFunctor (FullSubcategory P) (FullSubcategory P') where toMonoidalFunctor := fullMonoidalSubcategory.map h braided X Y := by rw [IsIso.eq_inv_comp]; aesop_cat instance fullBraidedSubcategory.mapFull (h : ∀ ⦃X⦄, P X → P' X) : (fullBraidedSubcategory.map h).Full := fullMonoidalSubcategory.map_full h instance fullBraidedSubcategory.map_faithful (h : ∀ ⦃X⦄, P X → P' X) : (fullBraidedSubcategory.map h).Faithful := fullMonoidalSubcategory.map_faithful h end Braided section Symmetric variable (P) [SymmetricCategory C] instance fullSymmetricSubcategory : SymmetricCategory (FullSubcategory P) := symmetricCategoryOfFaithful (fullBraidedSubcategoryInclusion P) end Symmetric section Closed variable (P) [MonoidalClosed C] /-- A property `C → Prop` is a closed predicate if it is closed under taking internal homs -/ class ClosedPredicate : Prop where prop_ihom : ∀ {X Y}, P X → P Y → P ((ihom X).obj Y) := by aesop_cat open ClosedPredicate variable [ClosedPredicate P] instance fullMonoidalClosedSubcategory : MonoidalClosed (FullSubcategory P) where closed X := { rightAdj := FullSubcategory.lift P (fullSubcategoryInclusion P ⋙ ihom X.1) fun Y => prop_ihom X.2 Y.2 adj := Adjunction.mkOfUnitCounit { unit := { app := fun Y => (ihom.coev X.1).app Y.1 naturality := fun Y Z f => ihom.coev_naturality X.1 f } counit := { app := fun Y => (ihom.ev X.1).app Y.1 naturality := fun Y Z f => ihom.ev_naturality X.1 f } left_triangle := by ext Y; simp [FullSubcategory.comp_def, FullSubcategory.id_def] right_triangle := by ext Y; simp [FullSubcategory.comp_def, FullSubcategory.id_def] } } @[simp] theorem fullMonoidalClosedSubcategory_ihom_obj (X Y : FullSubcategory P) : ((ihom X).obj Y).obj = (ihom X.obj).obj Y.obj := rfl @[simp] theorem fullMonoidalClosedSubcategory_ihom_map (X : FullSubcategory P) {Y Z : FullSubcategory P} (f : Y ⟶ Z) : (ihom X).map f = (ihom X.obj).map f := rfl end Closed end MonoidalCategory end CategoryTheory
CategoryTheory\Monoidal\Tor.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.Abelian.LeftDerived import Mathlib.CategoryTheory.Monoidal.Preadditive /-! # Tor, the left-derived functor of tensor product We define `Tor C n : C ⥤ C ⥤ C`, by left-deriving in the second factor of `(X, Y) ↦ X ⊗ Y`. For now we have almost nothing to say about it! It would be good to show that this is naturally isomorphic to the functor obtained by left-deriving in the first factor, instead. For now we define `Tor'` by left-deriving in the first factor, but showing `Tor C n ≅ Tor' C n` will require a bit more theory! Possibly it's best to axiomatize delta functors, and obtain a unique characterisation? -/ noncomputable section open CategoryTheory.Limits open CategoryTheory.MonoidalCategory namespace CategoryTheory variable (C : Type*) [Category C] [MonoidalCategory C] [Abelian C] [MonoidalPreadditive C] [HasProjectiveResolutions C] /-- We define `Tor C n : C ⥤ C ⥤ C` by left-deriving in the second factor of `(X, Y) ↦ X ⊗ Y`. -/ @[simps] def Tor (n : ℕ) : C ⥤ C ⥤ C where obj X := Functor.leftDerived ((tensoringLeft C).obj X) n map f := NatTrans.leftDerived ((tensoringLeft C).map f) n /-- An alternative definition of `Tor`, where we left-derive in the first factor instead. -/ @[simps! obj_obj] def Tor' (n : ℕ) : C ⥤ C ⥤ C := Functor.flip { obj := fun X => Functor.leftDerived ((tensoringRight C).obj X) n map := fun f => NatTrans.leftDerived ((tensoringRight C).map f) n } -- Porting note: the `checkType` linter complains about the automatically generated -- lemma `Tor'_map_app`, but not about this one @[simp] lemma Tor'_map_app' (n : ℕ) {X Y : C} (f : X ⟶ Y) (Z : C) : ((Tor' C n).map f).app Z = (Functor.leftDerived ((tensoringRight C).obj Z) n).map f := by rfl -- Porting note: this specific lemma was added because otherwise the internals of -- `NatTrans.leftDerived` leaks into the RHS (it was already so in mathlib) @[simp] lemma Tor'_obj_map (n : ℕ) {X Y : C} (Z : C) (f : X ⟶ Y) : ((Tor' C n).obj Z).map f = (NatTrans.leftDerived ((tensoringRight C).map f) n).app Z := rfl /-- The higher `Tor` groups for `X` and `Y` are zero if `Y` is projective. -/ lemma isZero_Tor_succ_of_projective (X Y : C) [Projective Y] (n : ℕ) : IsZero (((Tor C (n + 1)).obj X).obj Y) := by apply Functor.isZero_leftDerived_obj_projective_succ /-- The higher `Tor'` groups for `X` and `Y` are zero if `X` is projective. -/ lemma isZero_Tor'_succ_of_projective (X Y : C) [Projective X] (n : ℕ) : IsZero (((Tor' C (n + 1)).obj X).obj Y) := by apply Functor.isZero_leftDerived_obj_projective_succ end CategoryTheory assert_not_exists Module.abelian
CategoryTheory\Monoidal\Transport.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.Monoidal.NaturalTransformation /-! # Transport a monoidal structure along an equivalence. When `C` and `D` are equivalent as categories, we can transport a monoidal structure on `C` along the equivalence as `CategoryTheory.Monoidal.transport`, obtaining a monoidal structure on `D`. More generally, we can transport the lawfulness of a monoidal structure along a suitable faithful functor, as `CategoryTheory.Monoidal.induced`. The comparison is analogous to the difference between `Equiv.monoid` and `Function.Injective.monoid`. We then upgrade the original functor and its inverse to monoidal functors with respect to the new monoidal structure on `D`. -/ universe v₁ v₂ u₁ u₂ noncomputable section open CategoryTheory open CategoryTheory.Category open CategoryTheory.MonoidalCategory namespace CategoryTheory.Monoidal variable {C : Type u₁} [Category.{v₁} C] [MonoidalCategory.{v₁} C] variable {D : Type u₂} [Category.{v₂} D] /-- The data needed to induce a `MonoidalCategory` via the functor `F`; namely, pre-existing definitions of `⊗`, `𝟙_`, `▷`, `◁` that are preserved by `F`. -/ structure InducingFunctorData [MonoidalCategoryStruct D] (F : D ⥤ C) where /-- Analogous to `CategoryTheory.LaxMonoidalFunctor.μIso` -/ μIso : ∀ X Y, F.obj X ⊗ F.obj Y ≅ F.obj (X ⊗ Y) whiskerLeft_eq : ∀ (X : D) {Y₁ Y₂ : D} (f : Y₁ ⟶ Y₂), F.map (X ◁ f) = (μIso _ _).inv ≫ (F.obj X ◁ F.map f) ≫ (μIso _ _).hom := by aesop_cat whiskerRight_eq : ∀ {X₁ X₂ : D} (f : X₁ ⟶ X₂) (Y : D), F.map (f ▷ Y) = (μIso _ _).inv ≫ (F.map f ▷ F.obj Y) ≫ (μIso _ _).hom := by aesop_cat tensorHom_eq : ∀ {X₁ Y₁ X₂ Y₂ : D} (f : X₁ ⟶ Y₁) (g : X₂ ⟶ Y₂), F.map (f ⊗ g) = (μIso _ _).inv ≫ (F.map f ⊗ F.map g) ≫ (μIso _ _).hom := by aesop_cat /-- Analogous to `CategoryTheory.LaxMonoidalFunctor.εIso` -/ εIso : 𝟙_ _ ≅ F.obj (𝟙_ _) associator_eq : ∀ X Y Z : D, F.map (α_ X Y Z).hom = (((μIso _ _).symm ≪≫ ((μIso _ _).symm ⊗ .refl _)) ≪≫ α_ (F.obj X) (F.obj Y) (F.obj Z) ≪≫ ((.refl _ ⊗ μIso _ _) ≪≫ μIso _ _)).hom := by aesop_cat leftUnitor_eq : ∀ X : D, F.map (λ_ X).hom = (((μIso _ _).symm ≪≫ (εIso.symm ⊗ .refl _)) ≪≫ λ_ (F.obj X)).hom := by aesop_cat rightUnitor_eq : ∀ X : D, F.map (ρ_ X).hom = (((μIso _ _).symm ≪≫ (.refl _ ⊗ εIso.symm)) ≪≫ ρ_ (F.obj X)).hom := by aesop_cat -- these are theorems so don't need docstrings (std4#217) attribute [nolint docBlame] InducingFunctorData.whiskerLeft_eq InducingFunctorData.whiskerRight_eq InducingFunctorData.tensorHom_eq InducingFunctorData.associator_eq InducingFunctorData.leftUnitor_eq InducingFunctorData.rightUnitor_eq /-- Induce the lawfulness of the monoidal structure along an faithful functor of (plain) categories, where the operations are already defined on the destination type `D`. The functor `F` must preserve all the data parts of the monoidal structure between the two categories. -/ abbrev induced [MonoidalCategoryStruct D] (F : D ⥤ C) [F.Faithful] (fData : InducingFunctorData F) : MonoidalCategory.{v₂} D where tensorHom_def {X₁ Y₁ X₂ Y₂} f g := F.map_injective <| by rw [fData.tensorHom_eq, Functor.map_comp, fData.whiskerRight_eq, fData.whiskerLeft_eq] simp only [tensorHom_def, assoc, Iso.hom_inv_id_assoc] tensor_id X₁ X₂ := F.map_injective <| by cases fData; aesop_cat tensor_comp {X₁ Y₁ Z₁ X₂ Y₂ Z₂} f₁ f₂ g₁ g₂ := F.map_injective <| by cases fData; aesop_cat whiskerLeft_id X Y := F.map_injective <| by simp [fData.whiskerLeft_eq] id_whiskerRight X Y := F.map_injective <| by simp [fData.whiskerRight_eq] triangle X Y := F.map_injective <| by cases fData; aesop_cat pentagon W X Y Z := F.map_injective <| by simp only [Functor.map_comp, fData.whiskerRight_eq, fData.associator_eq, Iso.trans_assoc, Iso.trans_hom, Iso.symm_hom, tensorIso_hom, Iso.refl_hom, tensorHom_id, id_tensorHom, comp_whiskerRight, whisker_assoc, assoc, fData.whiskerLeft_eq, MonoidalCategory.whiskerLeft_comp, Iso.hom_inv_id_assoc, whiskerLeft_hom_inv_assoc, hom_inv_whiskerRight_assoc, Iso.inv_hom_id_assoc, Iso.cancel_iso_inv_left] slice_lhs 5 6 => rw [← MonoidalCategory.whiskerLeft_comp, hom_inv_whiskerRight] rw [whisker_exchange_assoc] simp leftUnitor_naturality {X Y : D} f := F.map_injective <| by simp [fData.leftUnitor_eq, fData.whiskerLeft_eq, whisker_exchange_assoc] rightUnitor_naturality {X Y : D} f := F.map_injective <| by simp [fData.rightUnitor_eq, fData.whiskerRight_eq, ← whisker_exchange_assoc] associator_naturality {X₁ X₂ X₃ Y₁ Y₂ Y₃} f₁ f₂ f₃ := F.map_injective <| by simp [fData.tensorHom_eq, fData.associator_eq, tensorHom_def, whisker_exchange_assoc] /-- We can upgrade `F` to a monoidal functor from `D` to `E` with the induced structure. -/ @[simps] def fromInduced [MonoidalCategoryStruct D] (F : D ⥤ C) [F.Faithful] (fData : InducingFunctorData F) : letI := induced F fData MonoidalFunctor D C := letI := induced F fData { toFunctor := F ε := fData.εIso.hom μ := fun X Y => (fData.μIso X Y).hom μ_natural_left := by cases fData; aesop_cat μ_natural_right := by cases fData; aesop_cat associativity := by cases fData; aesop_cat left_unitality := by cases fData; aesop_cat right_unitality := by cases fData; aesop_cat } /-- Transport a monoidal structure along an equivalence of (plain) categories. -/ @[simps] def transportStruct (e : C ≌ D) : MonoidalCategoryStruct.{v₂} D where tensorObj X Y := e.functor.obj (e.inverse.obj X ⊗ e.inverse.obj Y) whiskerLeft X _ _ f := e.functor.map (e.inverse.obj X ◁ e.inverse.map f) whiskerRight f X := e.functor.map (e.inverse.map f ▷ e.inverse.obj X) tensorHom f g := e.functor.map (e.inverse.map f ⊗ e.inverse.map g) tensorUnit := e.functor.obj (𝟙_ C) associator X Y Z := e.functor.mapIso (((e.unitIso.app _).symm ⊗ Iso.refl _) ≪≫ α_ (e.inverse.obj X) (e.inverse.obj Y) (e.inverse.obj Z) ≪≫ (Iso.refl _ ⊗ e.unitIso.app _)) leftUnitor X := e.functor.mapIso (((e.unitIso.app _).symm ⊗ Iso.refl _) ≪≫ λ_ (e.inverse.obj X)) ≪≫ e.counitIso.app _ rightUnitor X := e.functor.mapIso ((Iso.refl _ ⊗ (e.unitIso.app _).symm) ≪≫ ρ_ (e.inverse.obj X)) ≪≫ e.counitIso.app _ /-- Transport a monoidal structure along an equivalence of (plain) categories. -/ def transport (e : C ≌ D) : MonoidalCategory.{v₂} D := letI : MonoidalCategoryStruct.{v₂} D := transportStruct e induced e.inverse { μIso := fun X Y => e.unitIso.app _ εIso := e.unitIso.app _ } /-- A type synonym for `D`, which will carry the transported monoidal structure. -/ @[nolint unusedArguments] def Transported (_ : C ≌ D) := D instance (e : C ≌ D) : Category (Transported e) := (inferInstance : Category D) instance Transported.instMonoidalCategoryStruct (e : C ≌ D) : MonoidalCategoryStruct (Transported e) := transportStruct e instance Transported.instMonoidalCategory (e : C ≌ D) : MonoidalCategory (Transported e) := transport e instance (e : C ≌ D) : Inhabited (Transported e) := ⟨𝟙_ _⟩ /-- We can upgrade `e.inverse` to a monoidal functor from `D` with the transported structure to `C`. -/ @[simps!] def fromTransported (e : C ≌ D) : MonoidalFunctor (Transported e) C := by dsimp only [transport, Transported.instMonoidalCategory] exact fromInduced (D := Transported e) e.inverse _ instance instIsEquivalence_fromTransported (e : C ≌ D) : (fromTransported e).IsEquivalence := by dsimp [fromTransported] infer_instance /-- We can upgrade `e.functor` to a monoidal functor from `C` to `D` with the transported structure. -/ @[simps!] def toTransported (e : C ≌ D) : MonoidalFunctor C (Transported e) := monoidalInverse (fromTransported e) e.symm.toAdjunction instance (e : C ≌ D) : (toTransported e).IsEquivalence := e.isEquivalence_functor /-- The unit isomorphism upgrades to a monoidal isomorphism. -/ @[simps! hom inv] def transportedMonoidalUnitIso (e : C ≌ D) : LaxMonoidalFunctor.id C ≅ (toTransported e).toLaxMonoidalFunctor ⊗⋙ (fromTransported e).toLaxMonoidalFunctor := asIso (monoidalCounit (fromTransported e) e.symm.toAdjunction) |>.symm /-- The counit isomorphism upgrades to a monoidal isomorphism. -/ @[simps! hom inv] def transportedMonoidalCounitIso (e : C ≌ D) : (fromTransported e).toLaxMonoidalFunctor ⊗⋙ (toTransported e).toLaxMonoidalFunctor ≅ LaxMonoidalFunctor.id (Transported e) := asIso (monoidalUnit (fromTransported e) e.symm.toAdjunction) |>.symm end CategoryTheory.Monoidal
CategoryTheory\Monoidal\Braided\Basic.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.Monoidal.Discrete import Mathlib.CategoryTheory.Monoidal.NaturalTransformation import Mathlib.CategoryTheory.Monoidal.Opposite import Mathlib.Tactic.CategoryTheory.Coherence import Mathlib.CategoryTheory.CommSq /-! # Braided and symmetric monoidal categories The basic definitions of braided monoidal categories, and symmetric monoidal categories, as well as braided functors. ## Implementation note We make `BraidedCategory` another typeclass, but then have `SymmetricCategory` extend this. The rationale is that we are not carrying any additional data, just requiring a property. ## Future work * Construct the Drinfeld center of a monoidal category as a braided monoidal category. * Say something about pseudo-natural transformations. ## References * [Pavel Etingof, Shlomo Gelaki, Dmitri Nikshych, Victor Ostrik, *Tensor categories*][egno15] -/ open CategoryTheory MonoidalCategory universe v v₁ v₂ v₃ u u₁ u₂ u₃ namespace CategoryTheory /-- A braided monoidal category is a monoidal category equipped with a braiding isomorphism `β_ X Y : X ⊗ Y ≅ Y ⊗ X` which is natural in both arguments, and also satisfies the two hexagon identities. -/ class BraidedCategory (C : Type u) [Category.{v} C] [MonoidalCategory.{v} C] where /-- The braiding natural isomorphism. -/ braiding : ∀ X Y : C, X ⊗ Y ≅ Y ⊗ X braiding_naturality_right : ∀ (X : C) {Y Z : C} (f : Y ⟶ Z), X ◁ f ≫ (braiding X Z).hom = (braiding X Y).hom ≫ f ▷ X := by aesop_cat braiding_naturality_left : ∀ {X Y : C} (f : X ⟶ Y) (Z : C), f ▷ Z ≫ (braiding Y Z).hom = (braiding X Z).hom ≫ Z ◁ f := by aesop_cat /-- The first hexagon identity. -/ hexagon_forward : ∀ X Y Z : C, (α_ X Y Z).hom ≫ (braiding X (Y ⊗ Z)).hom ≫ (α_ Y Z X).hom = ((braiding X Y).hom ▷ Z) ≫ (α_ Y X Z).hom ≫ (Y ◁ (braiding X Z).hom) := by aesop_cat /-- The second hexagon identity. -/ hexagon_reverse : ∀ X Y Z : C, (α_ X Y Z).inv ≫ (braiding (X ⊗ Y) Z).hom ≫ (α_ Z X Y).inv = (X ◁ (braiding Y Z).hom) ≫ (α_ X Z Y).inv ≫ ((braiding X Z).hom ▷ Y) := by aesop_cat attribute [reassoc (attr := simp)] BraidedCategory.braiding_naturality_left BraidedCategory.braiding_naturality_right attribute [reassoc] BraidedCategory.hexagon_forward BraidedCategory.hexagon_reverse open Category open MonoidalCategory open BraidedCategory @[inherit_doc] notation "β_" => BraidedCategory.braiding namespace BraidedCategory variable {C : Type u} [Category.{v} C] [MonoidalCategory.{v} C] [BraidedCategory.{v} C] @[simp, reassoc] theorem braiding_tensor_left (X Y Z : C) : (β_ (X ⊗ Y) Z).hom = (α_ X Y Z).hom ≫ X ◁ (β_ Y Z).hom ≫ (α_ X Z Y).inv ≫ (β_ X Z).hom ▷ Y ≫ (α_ Z X Y).hom := by apply (cancel_epi (α_ X Y Z).inv).1 apply (cancel_mono (α_ Z X Y).inv).1 simp [hexagon_reverse] @[simp, reassoc] theorem braiding_tensor_right (X Y Z : C) : (β_ X (Y ⊗ Z)).hom = (α_ X Y Z).inv ≫ (β_ X Y).hom ▷ Z ≫ (α_ Y X Z).hom ≫ Y ◁ (β_ X Z).hom ≫ (α_ Y Z X).inv := by apply (cancel_epi (α_ X Y Z).hom).1 apply (cancel_mono (α_ Y Z X).hom).1 simp [hexagon_forward] @[simp, reassoc] theorem braiding_inv_tensor_left (X Y Z : C) : (β_ (X ⊗ Y) Z).inv = (α_ Z X Y).inv ≫ (β_ X Z).inv ▷ Y ≫ (α_ X Z Y).hom ≫ X ◁ (β_ Y Z).inv ≫ (α_ X Y Z).inv := eq_of_inv_eq_inv (by simp) @[simp, reassoc] theorem braiding_inv_tensor_right (X Y Z : C) : (β_ X (Y ⊗ Z)).inv = (α_ Y Z X).hom ≫ Y ◁ (β_ X Z).inv ≫ (α_ Y X Z).inv ≫ (β_ X Y).inv ▷ Z ≫ (α_ X Y Z).hom := eq_of_inv_eq_inv (by simp) @[reassoc (attr := simp)] theorem braiding_naturality {X X' Y Y' : C} (f : X ⟶ Y) (g : X' ⟶ Y') : (f ⊗ g) ≫ (braiding Y Y').hom = (braiding X X').hom ≫ (g ⊗ f) := by rw [tensorHom_def' f g, tensorHom_def g f] simp_rw [Category.assoc, braiding_naturality_left, braiding_naturality_right_assoc] @[reassoc (attr := simp)] theorem braiding_inv_naturality_right (X : C) {Y Z : C} (f : Y ⟶ Z) : X ◁ f ≫ (β_ Z X).inv = (β_ Y X).inv ≫ f ▷ X := CommSq.w <| .vert_inv <| .mk <| braiding_naturality_left f X @[reassoc (attr := simp)] theorem braiding_inv_naturality_left {X Y : C} (f : X ⟶ Y) (Z : C) : f ▷ Z ≫ (β_ Z Y).inv = (β_ Z X).inv ≫ Z ◁ f := CommSq.w <| .vert_inv <| .mk <| braiding_naturality_right Z f @[reassoc (attr := simp)] theorem braiding_inv_naturality {X X' Y Y' : C} (f : X ⟶ Y) (g : X' ⟶ Y') : (f ⊗ g) ≫ (β_ Y' Y).inv = (β_ X' X).inv ≫ (g ⊗ f) := CommSq.w <| .vert_inv <| .mk <| braiding_naturality g f @[reassoc] theorem yang_baxter (X Y Z : C) : (α_ X Y Z).inv ≫ (β_ X Y).hom ▷ Z ≫ (α_ Y X Z).hom ≫ Y ◁ (β_ X Z).hom ≫ (α_ Y Z X).inv ≫ (β_ Y Z).hom ▷ X ≫ (α_ Z Y X).hom = X ◁ (β_ Y Z).hom ≫ (α_ X Z Y).inv ≫ (β_ X Z).hom ▷ Y ≫ (α_ Z X Y).hom ≫ Z ◁ (β_ X Y).hom := by rw [← braiding_tensor_right_assoc X Y Z, ← cancel_mono (α_ Z Y X).inv] repeat rw [assoc] rw [Iso.hom_inv_id, comp_id, ← braiding_naturality_right, braiding_tensor_right] theorem yang_baxter' (X Y Z : C) : (β_ X Y).hom ▷ Z ⊗≫ Y ◁ (β_ X Z).hom ⊗≫ (β_ Y Z).hom ▷ X = 𝟙 _ ⊗≫ (X ◁ (β_ Y Z).hom ⊗≫ (β_ X Z).hom ▷ Y ⊗≫ Z ◁ (β_ X Y).hom) ⊗≫ 𝟙 _ := by rw [← cancel_epi (α_ X Y Z).inv, ← cancel_mono (α_ Z Y X).hom] convert yang_baxter X Y Z using 1 all_goals coherence theorem yang_baxter_iso (X Y Z : C) : (α_ X Y Z).symm ≪≫ whiskerRightIso (β_ X Y) Z ≪≫ α_ Y X Z ≪≫ whiskerLeftIso Y (β_ X Z) ≪≫ (α_ Y Z X).symm ≪≫ whiskerRightIso (β_ Y Z) X ≪≫ (α_ Z Y X) = whiskerLeftIso X (β_ Y Z) ≪≫ (α_ X Z Y).symm ≪≫ whiskerRightIso (β_ X Z) Y ≪≫ α_ Z X Y ≪≫ whiskerLeftIso Z (β_ X Y) := Iso.ext (yang_baxter X Y Z) theorem hexagon_forward_iso (X Y Z : C) : α_ X Y Z ≪≫ β_ X (Y ⊗ Z) ≪≫ α_ Y Z X = whiskerRightIso (β_ X Y) Z ≪≫ α_ Y X Z ≪≫ whiskerLeftIso Y (β_ X Z) := Iso.ext (hexagon_forward X Y Z) theorem hexagon_reverse_iso (X Y Z : C) : (α_ X Y Z).symm ≪≫ β_ (X ⊗ Y) Z ≪≫ (α_ Z X Y).symm = whiskerLeftIso X (β_ Y Z) ≪≫ (α_ X Z Y).symm ≪≫ whiskerRightIso (β_ X Z) Y := Iso.ext (hexagon_reverse X Y Z) @[reassoc] theorem hexagon_forward_inv (X Y Z : C) : (α_ Y Z X).inv ≫ (β_ X (Y ⊗ Z)).inv ≫ (α_ X Y Z).inv = Y ◁ (β_ X Z).inv ≫ (α_ Y X Z).inv ≫ (β_ X Y).inv ▷ Z := by simp @[reassoc] theorem hexagon_reverse_inv (X Y Z : C) : (α_ Z X Y).hom ≫ (β_ (X ⊗ Y) Z).inv ≫ (α_ X Y Z).hom = (β_ X Z).inv ▷ Y ≫ (α_ X Z Y).hom ≫ X ◁ (β_ Y Z).inv := by simp end BraidedCategory /-- Verifying the axioms for a braiding by checking that the candidate braiding is sent to a braiding by a faithful monoidal functor. -/ def braidedCategoryOfFaithful {C D : Type*} [Category C] [Category D] [MonoidalCategory C] [MonoidalCategory D] (F : MonoidalFunctor C D) [F.Faithful] [BraidedCategory D] (β : ∀ X Y : C, X ⊗ Y ≅ Y ⊗ X) (w : ∀ X Y, F.μ _ _ ≫ F.map (β X Y).hom = (β_ _ _).hom ≫ F.μ _ _) : BraidedCategory C where braiding := β braiding_naturality_left := by intros apply F.map_injective refine (cancel_epi (F.μ ?_ ?_)).1 ?_ rw [Functor.map_comp, ← LaxMonoidalFunctor.μ_natural_left_assoc, w, Functor.map_comp, reassoc_of% w, braiding_naturality_left_assoc, LaxMonoidalFunctor.μ_natural_right] braiding_naturality_right := by intros apply F.map_injective refine (cancel_epi (F.μ ?_ ?_)).1 ?_ rw [Functor.map_comp, ← LaxMonoidalFunctor.μ_natural_right_assoc, w, Functor.map_comp, reassoc_of% w, braiding_naturality_right_assoc, LaxMonoidalFunctor.μ_natural_left] hexagon_forward := by intros apply F.map_injective refine (cancel_epi (F.μ _ _)).1 ?_ refine (cancel_epi (F.μ _ _ ▷ _)).1 ?_ rw [Functor.map_comp, Functor.map_comp, Functor.map_comp, Functor.map_comp, ← LaxMonoidalFunctor.μ_natural_left_assoc, ← comp_whiskerRight_assoc, w, comp_whiskerRight_assoc, LaxMonoidalFunctor.associativity_assoc, LaxMonoidalFunctor.associativity_assoc, ← LaxMonoidalFunctor.μ_natural_right, ← MonoidalCategory.whiskerLeft_comp_assoc, w, MonoidalCategory.whiskerLeft_comp_assoc, reassoc_of% w, braiding_naturality_right_assoc, LaxMonoidalFunctor.associativity, hexagon_forward_assoc] hexagon_reverse := by intros apply F.toFunctor.map_injective refine (cancel_epi (F.μ _ _)).1 ?_ refine (cancel_epi (_ ◁ F.μ _ _)).1 ?_ rw [Functor.map_comp, Functor.map_comp, Functor.map_comp, Functor.map_comp, ← LaxMonoidalFunctor.μ_natural_right_assoc, ← MonoidalCategory.whiskerLeft_comp_assoc, w, MonoidalCategory.whiskerLeft_comp_assoc, LaxMonoidalFunctor.associativity_inv_assoc, LaxMonoidalFunctor.associativity_inv_assoc, ← LaxMonoidalFunctor.μ_natural_left, ← comp_whiskerRight_assoc, w, comp_whiskerRight_assoc, reassoc_of% w, braiding_naturality_left_assoc, LaxMonoidalFunctor.associativity_inv, hexagon_reverse_assoc] /-- Pull back a braiding along a fully faithful monoidal functor. -/ noncomputable def braidedCategoryOfFullyFaithful {C D : Type*} [Category C] [Category D] [MonoidalCategory C] [MonoidalCategory D] (F : MonoidalFunctor C D) [F.Full] [F.Faithful] [BraidedCategory D] : BraidedCategory C := braidedCategoryOfFaithful F (fun X Y => F.toFunctor.preimageIso ((asIso (F.μ _ _)).symm ≪≫ β_ (F.obj X) (F.obj Y) ≪≫ asIso (F.μ _ _))) (by aesop_cat) section /-! We now establish how the braiding interacts with the unitors. I couldn't find a detailed proof in print, but this is discussed in: * Proposition 1 of André Joyal and Ross Street, "Braided monoidal categories", Macquarie Math Reports 860081 (1986). * Proposition 2.1 of André Joyal and Ross Street, "Braided tensor categories" , Adv. Math. 102 (1993), 20–78. * Exercise 8.1.6 of Etingof, Gelaki, Nikshych, Ostrik, "Tensor categories", vol 25, Mathematical Surveys and Monographs (2015), AMS. -/ variable (C : Type u₁) [Category.{v₁} C] [MonoidalCategory C] [BraidedCategory C] theorem braiding_leftUnitor_aux₁ (X : C) : (α_ (𝟙_ C) (𝟙_ C) X).hom ≫ (𝟙_ C ◁ (β_ X (𝟙_ C)).inv) ≫ (α_ _ X _).inv ≫ ((λ_ X).hom ▷ _) = ((λ_ _).hom ▷ X) ≫ (β_ X (𝟙_ C)).inv := by coherence theorem braiding_leftUnitor_aux₂ (X : C) : ((β_ X (𝟙_ C)).hom ▷ 𝟙_ C) ≫ ((λ_ X).hom ▷ 𝟙_ C) = (ρ_ X).hom ▷ 𝟙_ C := calc ((β_ X (𝟙_ C)).hom ▷ 𝟙_ C) ≫ ((λ_ X).hom ▷ 𝟙_ C) = ((β_ X (𝟙_ C)).hom ▷ 𝟙_ C) ≫ (α_ _ _ _).hom ≫ (α_ _ _ _).inv ≫ ((λ_ X).hom ▷ 𝟙_ C) := by coherence _ = ((β_ X (𝟙_ C)).hom ▷ 𝟙_ C) ≫ (α_ _ _ _).hom ≫ (_ ◁ (β_ X _).hom) ≫ (_ ◁ (β_ X _).inv) ≫ (α_ _ _ _).inv ≫ ((λ_ X).hom ▷ 𝟙_ C) := by simp _ = (α_ _ _ _).hom ≫ (β_ _ _).hom ≫ (α_ _ _ _).hom ≫ (_ ◁ (β_ X _).inv) ≫ (α_ _ _ _).inv ≫ ((λ_ X).hom ▷ 𝟙_ C) := by (slice_lhs 1 3 => rw [← hexagon_forward]); simp only [assoc] _ = (α_ _ _ _).hom ≫ (β_ _ _).hom ≫ ((λ_ _).hom ▷ X) ≫ (β_ X _).inv := by rw [braiding_leftUnitor_aux₁] _ = (α_ _ _ _).hom ≫ (_ ◁ (λ_ _).hom) ≫ (β_ _ _).hom ≫ (β_ X _).inv := by (slice_lhs 2 3 => rw [← braiding_naturality_right]); simp only [assoc] _ = (α_ _ _ _).hom ≫ (_ ◁ (λ_ _).hom) := by rw [Iso.hom_inv_id, comp_id] _ = (ρ_ X).hom ▷ 𝟙_ C := by rw [triangle] @[reassoc] theorem braiding_leftUnitor (X : C) : (β_ X (𝟙_ C)).hom ≫ (λ_ X).hom = (ρ_ X).hom := by rw [← whiskerRight_iff, comp_whiskerRight, braiding_leftUnitor_aux₂] theorem braiding_rightUnitor_aux₁ (X : C) : (α_ X (𝟙_ C) (𝟙_ C)).inv ≫ ((β_ (𝟙_ C) X).inv ▷ 𝟙_ C) ≫ (α_ _ X _).hom ≫ (_ ◁ (ρ_ X).hom) = (X ◁ (ρ_ _).hom) ≫ (β_ (𝟙_ C) X).inv := by coherence theorem braiding_rightUnitor_aux₂ (X : C) : (𝟙_ C ◁ (β_ (𝟙_ C) X).hom) ≫ (𝟙_ C ◁ (ρ_ X).hom) = 𝟙_ C ◁ (λ_ X).hom := calc (𝟙_ C ◁ (β_ (𝟙_ C) X).hom) ≫ (𝟙_ C ◁ (ρ_ X).hom) = (𝟙_ C ◁ (β_ (𝟙_ C) X).hom) ≫ (α_ _ _ _).inv ≫ (α_ _ _ _).hom ≫ (𝟙_ C ◁ (ρ_ X).hom) := by coherence _ = (𝟙_ C ◁ (β_ (𝟙_ C) X).hom) ≫ (α_ _ _ _).inv ≫ ((β_ _ X).hom ▷ _) ≫ ((β_ _ X).inv ▷ _) ≫ (α_ _ _ _).hom ≫ (𝟙_ C ◁ (ρ_ X).hom) := by simp _ = (α_ _ _ _).inv ≫ (β_ _ _).hom ≫ (α_ _ _ _).inv ≫ ((β_ _ X).inv ▷ _) ≫ (α_ _ _ _).hom ≫ (𝟙_ C ◁ (ρ_ X).hom) := by (slice_lhs 1 3 => rw [← hexagon_reverse]); simp only [assoc] _ = (α_ _ _ _).inv ≫ (β_ _ _).hom ≫ (X ◁ (ρ_ _).hom) ≫ (β_ _ X).inv := by rw [braiding_rightUnitor_aux₁] _ = (α_ _ _ _).inv ≫ ((ρ_ _).hom ▷ _) ≫ (β_ _ X).hom ≫ (β_ _ _).inv := by (slice_lhs 2 3 => rw [← braiding_naturality_left]); simp only [assoc] _ = (α_ _ _ _).inv ≫ ((ρ_ _).hom ▷ _) := by rw [Iso.hom_inv_id, comp_id] _ = 𝟙_ C ◁ (λ_ X).hom := by rw [triangle_assoc_comp_right] @[reassoc] theorem braiding_rightUnitor (X : C) : (β_ (𝟙_ C) X).hom ≫ (ρ_ X).hom = (λ_ X).hom := by rw [← whiskerLeft_iff, MonoidalCategory.whiskerLeft_comp, braiding_rightUnitor_aux₂] @[reassoc, simp] theorem braiding_tensorUnit_left (X : C) : (β_ (𝟙_ C) X).hom = (λ_ X).hom ≫ (ρ_ X).inv := by simp [← braiding_rightUnitor] @[reassoc, simp] theorem braiding_inv_tensorUnit_left (X : C) : (β_ (𝟙_ C) X).inv = (ρ_ X).hom ≫ (λ_ X).inv := by rw [Iso.inv_ext] rw [braiding_tensorUnit_left] coherence @[reassoc] theorem leftUnitor_inv_braiding (X : C) : (λ_ X).inv ≫ (β_ (𝟙_ C) X).hom = (ρ_ X).inv := by simp @[reassoc] theorem rightUnitor_inv_braiding (X : C) : (ρ_ X).inv ≫ (β_ X (𝟙_ C)).hom = (λ_ X).inv := by apply (cancel_mono (λ_ X).hom).1 simp only [assoc, braiding_leftUnitor, Iso.inv_hom_id] @[reassoc, simp] theorem braiding_tensorUnit_right (X : C) : (β_ X (𝟙_ C)).hom = (ρ_ X).hom ≫ (λ_ X).inv := by simp [← rightUnitor_inv_braiding] @[reassoc, simp] theorem braiding_inv_tensorUnit_right (X : C) : (β_ X (𝟙_ C)).inv = (λ_ X).hom ≫ (ρ_ X).inv := by rw [Iso.inv_ext] rw [braiding_tensorUnit_right] coherence end /-- A symmetric monoidal category is a braided monoidal category for which the braiding is symmetric. See <https://stacks.math.columbia.edu/tag/0FFW>. -/ class SymmetricCategory (C : Type u) [Category.{v} C] [MonoidalCategory.{v} C] extends BraidedCategory.{v} C where -- braiding symmetric: symmetry : ∀ X Y : C, (β_ X Y).hom ≫ (β_ Y X).hom = 𝟙 (X ⊗ Y) := by aesop_cat attribute [reassoc (attr := simp)] SymmetricCategory.symmetry lemma SymmetricCategory.braiding_swap_eq_inv_braiding {C : Type u₁} [Category.{v₁} C] [MonoidalCategory C] [SymmetricCategory C] (X Y : C) : (β_ Y X).hom = (β_ X Y).inv := Iso.inv_ext' (symmetry X Y) variable (C : Type u₁) [Category.{v₁} C] [MonoidalCategory C] [BraidedCategory C] variable (D : Type u₂) [Category.{v₂} D] [MonoidalCategory D] [BraidedCategory D] variable (E : Type u₃) [Category.{v₃} E] [MonoidalCategory E] [BraidedCategory E] /-- A lax braided functor between braided monoidal categories is a lax monoidal functor which preserves the braiding. -/ structure LaxBraidedFunctor extends LaxMonoidalFunctor C D where braided : ∀ X Y : C, μ X Y ≫ map (β_ X Y).hom = (β_ (obj X) (obj Y)).hom ≫ μ Y X := by aesop_cat namespace LaxBraidedFunctor /-- The identity lax braided monoidal functor. -/ @[simps!] def id : LaxBraidedFunctor C C := { MonoidalFunctor.id C with } instance : Inhabited (LaxBraidedFunctor C C) := ⟨id C⟩ variable {C D E} /-- The composition of lax braided monoidal functors. -/ @[simps!] def comp (F : LaxBraidedFunctor C D) (G : LaxBraidedFunctor D E) : LaxBraidedFunctor C E := { LaxMonoidalFunctor.comp F.toLaxMonoidalFunctor G.toLaxMonoidalFunctor with braided := fun X Y => by dsimp slice_lhs 2 3 => rw [← CategoryTheory.Functor.map_comp, F.braided, CategoryTheory.Functor.map_comp] slice_lhs 1 2 => rw [G.braided] simp only [Category.assoc] } instance categoryLaxBraidedFunctor : Category (LaxBraidedFunctor C D) := InducedCategory.category LaxBraidedFunctor.toLaxMonoidalFunctor -- Porting note: added, as `MonoidalNatTrans.ext` does not apply to morphisms. @[ext] lemma ext' {F G : LaxBraidedFunctor C D} {α β : F ⟶ G} (w : ∀ X : C, α.app X = β.app X) : α = β := MonoidalNatTrans.ext (funext w) @[simp] theorem comp_toNatTrans {F G H : LaxBraidedFunctor C D} {α : F ⟶ G} {β : G ⟶ H} : (α ≫ β).toNatTrans = @CategoryStruct.comp (C ⥤ D) _ _ _ _ α.toNatTrans β.toNatTrans := rfl /-- Interpret a natural isomorphism of the underlying lax monoidal functors as an isomorphism of the lax braided monoidal functors. -/ @[simps] def mkIso {F G : LaxBraidedFunctor C D} (i : F.toLaxMonoidalFunctor ≅ G.toLaxMonoidalFunctor) : F ≅ G := { i with } end LaxBraidedFunctor /-- A braided functor between braided monoidal categories is a monoidal functor which preserves the braiding. -/ structure BraidedFunctor extends MonoidalFunctor C D where -- Note this is stated differently than for `LaxBraidedFunctor`. -- We move the `μ X Y` to the right hand side, -- so that this makes a good `@[simp]` lemma. braided : ∀ X Y : C, map (β_ X Y).hom = inv (μ X Y) ≫ (β_ (obj X) (obj Y)).hom ≫ μ Y X := by aesop_cat attribute [simp] BraidedFunctor.braided /-- A braided category with a faithful braided functor to a symmetric category is itself symmetric. -/ def symmetricCategoryOfFaithful {C D : Type*} [Category C] [Category D] [MonoidalCategory C] [MonoidalCategory D] [BraidedCategory C] [SymmetricCategory D] (F : BraidedFunctor C D) [F.Faithful] : SymmetricCategory C where symmetry X Y := F.map_injective (by simp) namespace BraidedFunctor /-- Turn a braided functor into a lax braided functor. -/ @[simps toLaxMonoidalFunctor] def toLaxBraidedFunctor (F : BraidedFunctor C D) : LaxBraidedFunctor C D := { toLaxMonoidalFunctor := F.toLaxMonoidalFunctor braided := fun X Y => by rw [F.braided]; simp } /-- The identity braided monoidal functor. -/ @[simps!] def id : BraidedFunctor C C := { MonoidalFunctor.id C with } instance : Inhabited (BraidedFunctor C C) := ⟨id C⟩ variable {C D E} /-- The composition of braided monoidal functors. -/ @[simps!] def comp (F : BraidedFunctor C D) (G : BraidedFunctor D E) : BraidedFunctor C E := { MonoidalFunctor.comp F.toMonoidalFunctor G.toMonoidalFunctor with } instance categoryBraidedFunctor : Category (BraidedFunctor C D) := InducedCategory.category BraidedFunctor.toMonoidalFunctor -- Porting note: added, as `MonoidalNatTrans.ext` does not apply to morphisms. @[ext] lemma ext' {F G : BraidedFunctor C D} {α β : F ⟶ G} (w : ∀ X : C, α.app X = β.app X) : α = β := MonoidalNatTrans.ext (funext w) @[simp] theorem comp_toNatTrans {F G H : BraidedFunctor C D} {α : F ⟶ G} {β : G ⟶ H} : (α ≫ β).toNatTrans = @CategoryStruct.comp (C ⥤ D) _ _ _ _ α.toNatTrans β.toNatTrans := rfl /-- Interpret a natural isomorphism of the underlying monoidal functors as an isomorphism of the braided monoidal functors. -/ @[simps] def mkIso {F G : BraidedFunctor C D} (i : F.toMonoidalFunctor ≅ G.toMonoidalFunctor) : F ≅ G := { i with } end BraidedFunctor section CommMonoid variable (M : Type u) [CommMonoid M] instance : BraidedCategory (Discrete M) where braiding X Y := Discrete.eqToIso (mul_comm X.as Y.as) variable {M} {N : Type u} [CommMonoid N] /-- A multiplicative morphism between commutative monoids gives a braided functor between the corresponding discrete braided monoidal categories. -/ @[simps!] def Discrete.braidedFunctor (F : M →* N) : BraidedFunctor (Discrete M) (Discrete N) := { Discrete.monoidalFunctor F with } end CommMonoid section Tensor /-- The strength of the tensor product functor from `C × C` to `C`. -/ def tensor_μ (X Y : C × C) : (X.1 ⊗ X.2) ⊗ Y.1 ⊗ Y.2 ⟶ (X.1 ⊗ Y.1) ⊗ X.2 ⊗ Y.2 := (α_ X.1 X.2 (Y.1 ⊗ Y.2)).hom ≫ (X.1 ◁ (α_ X.2 Y.1 Y.2).inv) ≫ (X.1 ◁ (β_ X.2 Y.1).hom ▷ Y.2) ≫ (X.1 ◁ (α_ Y.1 X.2 Y.2).hom) ≫ (α_ X.1 Y.1 (X.2 ⊗ Y.2)).inv @[reassoc] theorem tensor_μ_natural {X₁ X₂ Y₁ Y₂ U₁ U₂ V₁ V₂ : C} (f₁ : X₁ ⟶ Y₁) (f₂ : X₂ ⟶ Y₂) (g₁ : U₁ ⟶ V₁) (g₂ : U₂ ⟶ V₂) : ((f₁ ⊗ f₂) ⊗ g₁ ⊗ g₂) ≫ tensor_μ C (Y₁, Y₂) (V₁, V₂) = tensor_μ C (X₁, X₂) (U₁, U₂) ≫ ((f₁ ⊗ g₁) ⊗ f₂ ⊗ g₂) := by dsimp only [tensor_μ] simp_rw [← id_tensorHom, ← tensorHom_id] slice_lhs 1 2 => rw [associator_naturality] slice_lhs 2 3 => rw [← tensor_comp, comp_id f₁, ← id_comp f₁, associator_inv_naturality, tensor_comp] slice_lhs 3 4 => rw [← tensor_comp, ← tensor_comp, comp_id f₁, ← id_comp f₁, comp_id g₂, ← id_comp g₂, braiding_naturality, tensor_comp, tensor_comp] slice_lhs 4 5 => rw [← tensor_comp, comp_id f₁, ← id_comp f₁, associator_naturality, tensor_comp] slice_lhs 5 6 => rw [associator_inv_naturality] simp only [assoc] @[reassoc] theorem tensor_μ_natural_left {X₁ X₂ Y₁ Y₂ : C} (f₁ : X₁ ⟶ Y₁) (f₂ : X₂ ⟶ Y₂) (Z₁ Z₂ : C) : (f₁ ⊗ f₂) ▷ (Z₁ ⊗ Z₂) ≫ tensor_μ C (Y₁, Y₂) (Z₁, Z₂) = tensor_μ C (X₁, X₂) (Z₁, Z₂) ≫ (f₁ ▷ Z₁ ⊗ f₂ ▷ Z₂) := by convert tensor_μ_natural C f₁ f₂ (𝟙 Z₁) (𝟙 Z₂) using 1 <;> simp @[reassoc] theorem tensor_μ_natural_right (Z₁ Z₂ : C) {X₁ X₂ Y₁ Y₂ : C} (f₁ : X₁ ⟶ Y₁) (f₂ : X₂ ⟶ Y₂) : (Z₁ ⊗ Z₂) ◁ (f₁ ⊗ f₂) ≫ tensor_μ C (Z₁, Z₂) (Y₁, Y₂) = tensor_μ C (Z₁, Z₂) (X₁, X₂) ≫ (Z₁ ◁ f₁ ⊗ Z₂ ◁ f₂) := by convert tensor_μ_natural C (𝟙 Z₁) (𝟙 Z₂) f₁ f₂ using 1 <;> simp @[reassoc] theorem tensor_left_unitality (X₁ X₂ : C) : (λ_ (X₁ ⊗ X₂)).hom = ((λ_ (𝟙_ C)).inv ▷ (X₁ ⊗ X₂)) ≫ tensor_μ C (𝟙_ C, 𝟙_ C) (X₁, X₂) ≫ ((λ_ X₁).hom ⊗ (λ_ X₂).hom) := by dsimp only [tensor_μ] have : ((λ_ (𝟙_ C)).inv ▷ (X₁ ⊗ X₂)) ≫ (α_ (𝟙_ C) (𝟙_ C) (X₁ ⊗ X₂)).hom ≫ (𝟙_ C ◁ (α_ (𝟙_ C) X₁ X₂).inv) = 𝟙_ C ◁ (λ_ X₁).inv ▷ X₂ := by coherence slice_rhs 1 3 => rw [this] clear this slice_rhs 1 2 => rw [← MonoidalCategory.whiskerLeft_comp, ← comp_whiskerRight, leftUnitor_inv_braiding] simp [tensorHom_id, id_tensorHom, tensorHom_def] @[reassoc] theorem tensor_right_unitality (X₁ X₂ : C) : (ρ_ (X₁ ⊗ X₂)).hom = ((X₁ ⊗ X₂) ◁ (λ_ (𝟙_ C)).inv) ≫ tensor_μ C (X₁, X₂) (𝟙_ C, 𝟙_ C) ≫ ((ρ_ X₁).hom ⊗ (ρ_ X₂).hom) := by dsimp only [tensor_μ] have : ((X₁ ⊗ X₂) ◁ (λ_ (𝟙_ C)).inv) ≫ (α_ X₁ X₂ (𝟙_ C ⊗ 𝟙_ C)).hom ≫ (X₁ ◁ (α_ X₂ (𝟙_ C) (𝟙_ C)).inv) = (α_ X₁ X₂ (𝟙_ C)).hom ≫ (X₁ ◁ (ρ_ X₂).inv ▷ 𝟙_ C) := by coherence slice_rhs 1 3 => rw [this] clear this slice_rhs 2 3 => rw [← MonoidalCategory.whiskerLeft_comp, ← comp_whiskerRight, rightUnitor_inv_braiding] simp [tensorHom_id, id_tensorHom, tensorHom_def] theorem tensor_associativity (X₁ X₂ Y₁ Y₂ Z₁ Z₂ : C) : (tensor_μ C (X₁, X₂) (Y₁, Y₂) ▷ (Z₁ ⊗ Z₂)) ≫ tensor_μ C (X₁ ⊗ Y₁, X₂ ⊗ Y₂) (Z₁, Z₂) ≫ ((α_ X₁ Y₁ Z₁).hom ⊗ (α_ X₂ Y₂ Z₂).hom) = (α_ (X₁ ⊗ X₂) (Y₁ ⊗ Y₂) (Z₁ ⊗ Z₂)).hom ≫ ((X₁ ⊗ X₂) ◁ tensor_μ C (Y₁, Y₂) (Z₁, Z₂)) ≫ tensor_μ C (X₁, X₂) (Y₁ ⊗ Z₁, Y₂ ⊗ Z₂) := by dsimp only [tensor_obj, prodMonoidal_tensorObj, tensor_μ] simp only [whiskerRight_tensor, comp_whiskerRight, whisker_assoc, assoc, Iso.inv_hom_id_assoc, tensor_whiskerLeft, braiding_tensor_left, MonoidalCategory.whiskerLeft_comp, braiding_tensor_right] calc _ = 𝟙 _ ⊗≫ X₁ ◁ ((β_ X₂ Y₁).hom ▷ (Y₂ ⊗ Z₁) ≫ (Y₁ ⊗ X₂) ◁ (β_ Y₂ Z₁).hom) ▷ Z₂ ⊗≫ X₁ ◁ Y₁ ◁ (β_ X₂ Z₁).hom ▷ Y₂ ▷ Z₂ ⊗≫ 𝟙 _ := by coherence _ = _ := by rw [← whisker_exchange]; coherence -- We got a timeout if `reassoc` was at the declaration, so we put it here instead. attribute [reassoc] tensor_associativity /-- The tensor product functor from `C × C` to `C` as a monoidal functor. -/ @[simps!] def tensorMonoidal : MonoidalFunctor (C × C) C := { tensor C with ε := (λ_ (𝟙_ C)).inv μ := tensor_μ C μ_natural_left := fun f Z => by -- `simpa` will be not needed when we define `μ_natural_left` in terms of the whiskerings. simpa using tensor_μ_natural_left C f.1 f.2 Z.1 Z.2 μ_natural_right := fun Z f => by simpa using tensor_μ_natural_right C Z.1 Z.2 f.1 f.2 associativity := fun X Y Z => by simpa using tensor_associativity C X.1 X.2 Y.1 Y.2 Z.1 Z.2 left_unitality := fun ⟨X₁, X₂⟩ => by simpa using tensor_left_unitality C X₁ X₂ right_unitality := fun ⟨X₁, X₂⟩ => by simpa using tensor_right_unitality C X₁ X₂ μ_isIso := by dsimp [tensor_μ]; infer_instance } @[reassoc] theorem leftUnitor_monoidal (X₁ X₂ : C) : (λ_ X₁).hom ⊗ (λ_ X₂).hom = tensor_μ C (𝟙_ C, X₁) (𝟙_ C, X₂) ≫ ((λ_ (𝟙_ C)).hom ▷ (X₁ ⊗ X₂)) ≫ (λ_ (X₁ ⊗ X₂)).hom := by dsimp only [tensor_μ] have : (λ_ X₁).hom ⊗ (λ_ X₂).hom = (α_ (𝟙_ C) X₁ (𝟙_ C ⊗ X₂)).hom ≫ (𝟙_ C ◁ (α_ X₁ (𝟙_ C) X₂).inv) ≫ (λ_ ((X₁ ⊗ 𝟙_ C) ⊗ X₂)).hom ≫ ((ρ_ X₁).hom ▷ X₂) := by coherence rw [this]; clear this rw [← braiding_leftUnitor] dsimp only [tensor_obj, prodMonoidal_tensorObj] coherence @[reassoc] theorem rightUnitor_monoidal (X₁ X₂ : C) : (ρ_ X₁).hom ⊗ (ρ_ X₂).hom = tensor_μ C (X₁, 𝟙_ C) (X₂, 𝟙_ C) ≫ ((X₁ ⊗ X₂) ◁ (λ_ (𝟙_ C)).hom) ≫ (ρ_ (X₁ ⊗ X₂)).hom := by dsimp only [tensor_μ] have : (ρ_ X₁).hom ⊗ (ρ_ X₂).hom = (α_ X₁ (𝟙_ C) (X₂ ⊗ 𝟙_ C)).hom ≫ (X₁ ◁ (α_ (𝟙_ C) X₂ (𝟙_ C)).inv) ≫ (X₁ ◁ (ρ_ (𝟙_ C ⊗ X₂)).hom) ≫ (X₁ ◁ (λ_ X₂).hom) := by coherence rw [this]; clear this rw [← braiding_rightUnitor] dsimp only [tensor_obj, prodMonoidal_tensorObj] coherence theorem associator_monoidal (X₁ X₂ X₃ Y₁ Y₂ Y₃ : C) : tensor_μ C (X₁ ⊗ X₂, X₃) (Y₁ ⊗ Y₂, Y₃) ≫ (tensor_μ C (X₁, X₂) (Y₁, Y₂) ▷ (X₃ ⊗ Y₃)) ≫ (α_ (X₁ ⊗ Y₁) (X₂ ⊗ Y₂) (X₃ ⊗ Y₃)).hom = ((α_ X₁ X₂ X₃).hom ⊗ (α_ Y₁ Y₂ Y₃).hom) ≫ tensor_μ C (X₁, X₂ ⊗ X₃) (Y₁, Y₂ ⊗ Y₃) ≫ ((X₁ ⊗ Y₁) ◁ tensor_μ C (X₂, X₃) (Y₂, Y₃)) := by dsimp only [tensor_μ] calc _ = 𝟙 _ ⊗≫ X₁ ◁ X₂ ◁ (β_ X₃ Y₁).hom ▷ Y₂ ▷ Y₃ ⊗≫ X₁ ◁ ((X₂ ⊗ Y₁) ◁ (β_ X₃ Y₂).hom ≫ (β_ X₂ Y₁).hom ▷ (Y₂ ⊗ X₃)) ▷ Y₃ ⊗≫ 𝟙 _ := by simp; coherence _ = _ := by rw [whisker_exchange]; simp; coherence -- We got a timeout if `reassoc` was at the declaration, so we put it here instead. attribute [reassoc] associator_monoidal end Tensor instance : BraidedCategory Cᵒᵖ where braiding X Y := (β_ Y.unop X.unop).op braiding_naturality_right X {_ _} f := Quiver.Hom.unop_inj <| by simp braiding_naturality_left {_ _} f Z := Quiver.Hom.unop_inj <| by simp section OppositeLemmas open Opposite @[simp] lemma op_braiding (X Y : C) : (β_ X Y).op = β_ (op Y) (op X) := rfl @[simp] lemma unop_braiding (X Y : Cᵒᵖ) : (β_ X Y).unop = β_ (unop Y) (unop X) := rfl @[simp] lemma op_hom_braiding (X Y : C) : (β_ X Y).hom.op = (β_ (op Y) (op X)).hom := rfl @[simp] lemma unop_hom_braiding (X Y : Cᵒᵖ) : (β_ X Y).hom.unop = (β_ (unop Y) (unop X)).hom := rfl @[simp] lemma op_inv_braiding (X Y : C) : (β_ X Y).inv.op = (β_ (op Y) (op X)).inv := rfl @[simp] lemma unop_inv_braiding (X Y : Cᵒᵖ) : (β_ X Y).inv.unop = (β_ (unop Y) (unop X)).inv := rfl end OppositeLemmas namespace MonoidalOpposite instance instBraiding : BraidedCategory Cᴹᵒᵖ where braiding X Y := (β_ Y.unmop X.unmop).mop braiding_naturality_right X {_ _} f := Quiver.Hom.unmop_inj <| by simp braiding_naturality_left {_ _} f Z := Quiver.Hom.unmop_inj <| by simp section MonoidalOppositeLemmas @[simp] lemma mop_braiding (X Y : C) : (β_ X Y).mop = β_ (mop Y) (mop X) := rfl @[simp] lemma unmop_braiding (X Y : Cᴹᵒᵖ) : (β_ X Y).unmop = β_ (unmop Y) (unmop X) := rfl @[simp] lemma mop_hom_braiding (X Y : C) : (β_ X Y).hom.mop = (β_ (mop Y) (mop X)).hom := rfl @[simp] lemma unmop_hom_braiding (X Y : Cᴹᵒᵖ) : (β_ X Y).hom.unmop = (β_ (unmop Y) (unmop X)).hom := rfl @[simp] lemma mop_inv_braiding (X Y : C) : (β_ X Y).inv.mop = (β_ (mop Y) (mop X)).inv := rfl @[simp] lemma unmop_inv_braiding (X Y : Cᴹᵒᵖ) : (β_ X Y).inv.unmop = (β_ (unmop Y) (unmop X)).inv := rfl end MonoidalOppositeLemmas /-- The identity functor on `C`, viewed as a functor from `C` to its monoidal opposite, upgraded to a braided functor. -/ @[simps!] def mopBraidedFunctor : BraidedFunctor C Cᴹᵒᵖ where μ X Y := (β_ (mop X) (mop Y)).hom ε := 𝟙 (𝟙_ Cᴹᵒᵖ) -- we could make this fully automated if we mark `← yang_baxter_assoc` as simp -- should it be marked as such? associativity X Y Z := by simp [← yang_baxter_assoc] __ := mopFunctor C /-- The identity functor on `C`, viewed as a functor from the monoidal opposite of `C` to `C`, upgraded to a braided functor. -/ @[simps!] def unmopBraidedFunctor : BraidedFunctor Cᴹᵒᵖ C where μ X Y := (β_ (unmop X) (unmop Y)).hom ε := 𝟙 (𝟙_ C) associativity X Y Z := by simp [← yang_baxter_assoc] __ := unmopFunctor C end MonoidalOpposite /-- The braided monoidal category obtained from `C` by replacing its braiding `β_ X Y : X ⊗ Y ≅ Y ⊗ X` with the inverse `(β_ Y X)⁻¹ : X ⊗ Y ≅ Y ⊗ X`. This corresponds to the automorphism of the braid group swapping over-crossings and under-crossings. -/ abbrev reverseBraiding : BraidedCategory C where braiding X Y := (β_ Y X).symm braiding_naturality_right X {_ _} f := by simp braiding_naturality_left {_ _} f Z := by simp lemma SymmetricCategory.reverseBraiding_eq (C : Type u₁) [Category.{v₁} C] [MonoidalCategory C] [i : SymmetricCategory C] : reverseBraiding C = i.toBraidedCategory := by dsimp only [reverseBraiding] congr funext X Y exact Iso.ext (braiding_swap_eq_inv_braiding Y X).symm /-- The identity functor from `C` to `C`, where the codomain is given the reversed braiding, upgraded to a braided functor. -/ def SymmetricCategory.equivReverseBraiding (C : Type u₁) [Category.{v₁} C] [MonoidalCategory C] [SymmetricCategory C] := @BraidedFunctor.mk C _ _ _ C _ _ (reverseBraiding C) (.id C) <| by intros; simp [reverseBraiding, braiding_swap_eq_inv_braiding] end CategoryTheory
CategoryTheory\Monoidal\Braided\Opposite.lean
/- Copyright (c) 2024 Lean FRO LLC. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison -/ import Mathlib.CategoryTheory.Monoidal.Braided.Basic import Mathlib.CategoryTheory.Monoidal.Opposite /-! # If `C` is braided, so is `Cᵒᵖ`. Todo: we should also do `Cᵐᵒᵖ`. -/ open CategoryTheory MonoidalCategory BraidedCategory Opposite variable {C : Type*} [Category C] [MonoidalCategory C] [BraidedCategory C] instance : BraidedCategory Cᵒᵖ where braiding X Y := (β_ (unop Y) (unop X)).op namespace CategoryTheory.BraidedCategory @[simp] lemma unop_tensor_μ {C : Type*} [Category C] [MonoidalCategory C] [BraidedCategory C] (X Y W Z : Cᵒᵖ) : (tensor_μ Cᵒᵖ (X, W) (Y, Z)).unop = tensor_μ C (X.unop, Y.unop) (W.unop, Z.unop) := by simp only [unop_tensorObj, tensor_μ, unop_comp, unop_inv_associator, unop_whiskerLeft, unop_hom_associator, unop_whiskerRight, unop_hom_braiding, Category.assoc] @[simp] lemma op_tensor_μ {C : Type*} [Category C] [MonoidalCategory C] [BraidedCategory C] (X Y W Z : C) : (tensor_μ C (X, W) (Y, Z)).op = tensor_μ Cᵒᵖ (op X, op Y) (op W, op Z) := by simp only [op_tensorObj, tensor_μ, op_comp, op_inv_associator, op_whiskerLeft, op_hom_associator, op_whiskerRight, op_hom_braiding, Category.assoc] end CategoryTheory.BraidedCategory
CategoryTheory\Monoidal\Cartesian\Comon_.lean
/- Copyright (c) 2023 Lean FRO LLC. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Kim Morrison -/ import Mathlib.CategoryTheory.Monoidal.Comon_ import Mathlib.CategoryTheory.Monoidal.OfHasFiniteProducts /-! # Comonoid objects in a cartesian monoidal category. The category of comonoid objects in a cartesian monoidal category is equivalent to the category itself, via the forgetful functor. -/ open CategoryTheory MonoidalCategory Limits universe v u noncomputable section variable (C : Type u) [Category.{v} C] [HasTerminal C] [HasBinaryProducts C] attribute [local instance] monoidalOfHasFiniteProducts open monoidalOfHasFiniteProducts attribute [local simp] associator_hom associator_inv /-- The functor from a cartesian monoidal category to comonoids in that category, equipping every object with the diagonal map as a comultiplication. -/ def cartesianComon_ : C ⥤ Comon_ C where obj := fun X => { X := X comul := diag X counit := terminal.from X } map := fun f => { hom := f } variable {C} @[simp] theorem counit_eq_from (A : Comon_ C) : A.counit = terminal.from A.X := by ext @[simp] theorem comul_eq_diag (A : Comon_ C) : A.comul = diag A.X := by ext · simpa using A.comul_counit =≫ prod.fst · simpa using A.counit_comul =≫ prod.snd /-- Every comonoid object in a cartesian monoidal category is equivalent to the canonical comonoid structure on the underlying object. -/ @[simps] def iso_cartesianComon_ (A : Comon_ C) : A ≅ (cartesianComon_ C).obj A.X := { hom := { hom := 𝟙 _ } inv := { hom := 𝟙 _ } } /-- The category of comonoid objects in a cartesian monoidal category is equivalent to the category itself, via the forgetful functor. -/ @[simps] def comonEquiv : Comon_ C ≌ C where functor := Comon_.forget C inverse := cartesianComon_ C unitIso := NatIso.ofComponents (fun A => iso_cartesianComon_ A) counitIso := NatIso.ofComponents (fun X => Iso.refl _)
CategoryTheory\Monoidal\Free\Basic.lean
/- Copyright (c) 2021 Markus Himmel. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Markus Himmel -/ import Mathlib.CategoryTheory.Monoidal.Functor /-! # The free monoidal category over a type Given a type `C`, the free monoidal category over `C` has as objects formal expressions built from (formal) tensor products of terms of `C` and a formal unit. Its morphisms are compositions and tensor products of identities, unitors and associators. In this file, we construct the free monoidal category and prove that it is a monoidal category. If `D` is a monoidal category, we construct the functor `FreeMonoidalCategory C ⥤ D` associated to a function `C → D`. The free monoidal category has two important properties: it is a groupoid and it is thin. The former is obvious from the construction, and the latter is what is commonly known as the monoidal coherence theorem. Both of these properties are proved in the file `Coherence.lean`. -/ universe v' u u' namespace CategoryTheory open MonoidalCategory variable {C : Type u} section variable (C) /-- Given a type `C`, the free monoidal category over `C` has as objects formal expressions built from (formal) tensor products of terms of `C` and a formal unit. Its morphisms are compositions and tensor products of identities, unitors and associators. -/ inductive FreeMonoidalCategory : Type u | of : C → FreeMonoidalCategory | unit : FreeMonoidalCategory | tensor : FreeMonoidalCategory → FreeMonoidalCategory → FreeMonoidalCategory deriving Inhabited end local notation "F" => FreeMonoidalCategory namespace FreeMonoidalCategory attribute [nolint simpNF] unit.sizeOf_spec tensor.injEq tensor.sizeOf_spec /-- Formal compositions and tensor products of identities, unitors and associators. The morphisms of the free monoidal category are obtained as a quotient of these formal morphisms by the relations defining a monoidal category. -/ -- Porting note(#5171): linter not ported yet -- @[nolint has_nonempty_instance] inductive Hom : F C → F C → Type u | id (X) : Hom X X | α_hom (X Y Z : F C) : Hom ((X.tensor Y).tensor Z) (X.tensor (Y.tensor Z)) | α_inv (X Y Z : F C) : Hom (X.tensor (Y.tensor Z)) ((X.tensor Y).tensor Z) | l_hom (X) : Hom (unit.tensor X) X | l_inv (X) : Hom X (unit.tensor X) | ρ_hom (X : F C) : Hom (X.tensor unit) X | ρ_inv (X : F C) : Hom X (X.tensor unit) | comp {X Y Z} (f : Hom X Y) (g : Hom Y Z) : Hom X Z | whiskerLeft (X : F C) {Y₁ Y₂} (f : Hom Y₁ Y₂) : Hom (X.tensor Y₁) (X.tensor Y₂) | whiskerRight {X₁ X₂} (f : Hom X₁ X₂) (Y : F C) : Hom (X₁.tensor Y) (X₂.tensor Y) | tensor {W X Y Z} (f : Hom W Y) (g : Hom X Z) : Hom (W.tensor X) (Y.tensor Z) local infixr:10 " ⟶ᵐ " => Hom /-- The morphisms of the free monoidal category satisfy 21 relations ensuring that the resulting category is in fact a category and that it is monoidal. -/ inductive HomEquiv : ∀ {X Y : F C}, (X ⟶ᵐ Y) → (X ⟶ᵐ Y) → Prop | refl {X Y} (f : X ⟶ᵐ Y) : HomEquiv f f | symm {X Y} (f g : X ⟶ᵐ Y) : HomEquiv f g → HomEquiv g f | trans {X Y} {f g h : X ⟶ᵐ Y} : HomEquiv f g → HomEquiv g h → HomEquiv f h | comp {X Y Z} {f f' : X ⟶ᵐ Y} {g g' : Y ⟶ᵐ Z} : HomEquiv f f' → HomEquiv g g' → HomEquiv (f.comp g) (f'.comp g') | whiskerLeft (X) {Y Z} (f f' : Y ⟶ᵐ Z) : HomEquiv f f' → HomEquiv (f.whiskerLeft X) (f'.whiskerLeft X) | whiskerRight {Y Z} (f f' : Y ⟶ᵐ Z) (X) : HomEquiv f f' → HomEquiv (f.whiskerRight X) (f'.whiskerRight X) | tensor {W X Y Z} {f f' : W ⟶ᵐ X} {g g' : Y ⟶ᵐ Z} : HomEquiv f f' → HomEquiv g g' → HomEquiv (f.tensor g) (f'.tensor g') | tensorHom_def {X₁ Y₁ X₂ Y₂} (f : X₁ ⟶ᵐ Y₁) (g : X₂ ⟶ᵐ Y₂) : HomEquiv (f.tensor g) ((f.whiskerRight X₂).comp (g.whiskerLeft Y₁)) | comp_id {X Y} (f : X ⟶ᵐ Y) : HomEquiv (f.comp (Hom.id _)) f | id_comp {X Y} (f : X ⟶ᵐ Y) : HomEquiv ((Hom.id _).comp f) f | assoc {X Y U V : F C} (f : X ⟶ᵐ U) (g : U ⟶ᵐ V) (h : V ⟶ᵐ Y) : HomEquiv ((f.comp g).comp h) (f.comp (g.comp h)) | tensor_id {X Y} : HomEquiv ((Hom.id X).tensor (Hom.id Y)) (Hom.id _) | tensor_comp {X₁ Y₁ Z₁ X₂ Y₂ Z₂ : F C} (f₁ : X₁ ⟶ᵐ Y₁) (f₂ : X₂ ⟶ᵐ Y₂) (g₁ : Y₁ ⟶ᵐ Z₁) (g₂ : Y₂ ⟶ᵐ Z₂) : HomEquiv ((f₁.comp g₁).tensor (f₂.comp g₂)) ((f₁.tensor f₂).comp (g₁.tensor g₂)) | whiskerLeft_id (X Y) : HomEquiv ((Hom.id Y).whiskerLeft X) (Hom.id (X.tensor Y)) | id_whiskerRight (X Y) : HomEquiv ((Hom.id X).whiskerRight Y) (Hom.id (X.tensor Y)) | α_hom_inv {X Y Z} : HomEquiv ((Hom.α_hom X Y Z).comp (Hom.α_inv X Y Z)) (Hom.id _) | α_inv_hom {X Y Z} : HomEquiv ((Hom.α_inv X Y Z).comp (Hom.α_hom X Y Z)) (Hom.id _) | associator_naturality {X₁ X₂ X₃ Y₁ Y₂ Y₃} (f₁ : X₁ ⟶ᵐ Y₁) (f₂ : X₂ ⟶ᵐ Y₂) (f₃ : X₃ ⟶ᵐ Y₃) : HomEquiv (((f₁.tensor f₂).tensor f₃).comp (Hom.α_hom Y₁ Y₂ Y₃)) ((Hom.α_hom X₁ X₂ X₃).comp (f₁.tensor (f₂.tensor f₃))) | ρ_hom_inv {X} : HomEquiv ((Hom.ρ_hom X).comp (Hom.ρ_inv X)) (Hom.id _) | ρ_inv_hom {X} : HomEquiv ((Hom.ρ_inv X).comp (Hom.ρ_hom X)) (Hom.id _) | ρ_naturality {X Y} (f : X ⟶ᵐ Y) : HomEquiv ((f.whiskerRight unit).comp (Hom.ρ_hom Y)) ((Hom.ρ_hom X).comp f) | l_hom_inv {X} : HomEquiv ((Hom.l_hom X).comp (Hom.l_inv X)) (Hom.id _) | l_inv_hom {X} : HomEquiv ((Hom.l_inv X).comp (Hom.l_hom X)) (Hom.id _) | l_naturality {X Y} (f : X ⟶ᵐ Y) : HomEquiv ((f.whiskerLeft unit).comp (Hom.l_hom Y)) ((Hom.l_hom X).comp f) | pentagon {W X Y Z} : HomEquiv (((Hom.α_hom W X Y).whiskerRight Z).comp ((Hom.α_hom W (X.tensor Y) Z).comp ((Hom.α_hom X Y Z).whiskerLeft W))) ((Hom.α_hom (W.tensor X) Y Z).comp (Hom.α_hom W X (Y.tensor Z))) | triangle {X Y} : HomEquiv ((Hom.α_hom X unit Y).comp ((Hom.l_hom Y).whiskerLeft X)) ((Hom.ρ_hom X).whiskerRight Y) /-- We say that two formal morphisms in the free monoidal category are equivalent if they become equal if we apply the relations that are true in a monoidal category. Note that we will prove that there is only one equivalence class -- this is the monoidal coherence theorem. -/ def setoidHom (X Y : F C) : Setoid (X ⟶ᵐ Y) := ⟨HomEquiv, ⟨fun f => HomEquiv.refl f, @fun f g => HomEquiv.symm f g, @fun _ _ _ hfg hgh => HomEquiv.trans hfg hgh⟩⟩ attribute [instance] setoidHom section open FreeMonoidalCategory.HomEquiv instance categoryFreeMonoidalCategory : Category.{u} (F C) where Hom X Y := Quotient (FreeMonoidalCategory.setoidHom X Y) id X := ⟦Hom.id X⟧ comp := Quotient.map₂ Hom.comp (fun _ _ hf _ _ hg ↦ HomEquiv.comp hf hg) id_comp := by rintro X Y ⟨f⟩ exact Quotient.sound (id_comp f) comp_id := by rintro X Y ⟨f⟩ exact Quotient.sound (comp_id f) assoc := by rintro W X Y Z ⟨f⟩ ⟨g⟩ ⟨h⟩ exact Quotient.sound (assoc f g h) instance : MonoidalCategory (F C) where tensorObj X Y := FreeMonoidalCategory.tensor X Y tensorHom := Quotient.map₂ Hom.tensor (fun _ _ hf _ _ hg ↦ HomEquiv.tensor hf hg) whiskerLeft X _ _ f := Quot.map (fun f ↦ Hom.whiskerLeft X f) (fun f f' ↦ .whiskerLeft X f f') f whiskerRight f Y := Quot.map (fun f ↦ Hom.whiskerRight f Y) (fun f f' ↦ .whiskerRight f f' Y) f tensorHom_def := by rintro W X Y Z ⟨f⟩ ⟨g⟩ exact Quotient.sound (tensorHom_def _ _) tensor_id X Y := Quot.sound tensor_id tensor_comp := @fun X₁ Y₁ Z₁ X₂ Y₂ Z₂ => by rintro ⟨f₁⟩ ⟨f₂⟩ ⟨g₁⟩ ⟨g₂⟩ exact Quotient.sound (tensor_comp _ _ _ _) whiskerLeft_id X Y := Quot.sound (HomEquiv.whiskerLeft_id X Y) id_whiskerRight X Y := Quot.sound (HomEquiv.id_whiskerRight X Y) tensorUnit := FreeMonoidalCategory.unit associator X Y Z := ⟨⟦Hom.α_hom X Y Z⟧, ⟦Hom.α_inv X Y Z⟧, Quotient.sound α_hom_inv, Quotient.sound α_inv_hom⟩ associator_naturality := @fun X₁ X₂ X₃ Y₁ Y₂ Y₃ => by rintro ⟨f₁⟩ ⟨f₂⟩ ⟨f₃⟩ exact Quotient.sound (associator_naturality _ _ _) leftUnitor X := ⟨⟦Hom.l_hom X⟧, ⟦Hom.l_inv X⟧, Quotient.sound l_hom_inv, Quotient.sound l_inv_hom⟩ leftUnitor_naturality := @fun X Y => by rintro ⟨f⟩ exact Quotient.sound (l_naturality _) rightUnitor X := ⟨⟦Hom.ρ_hom X⟧, ⟦Hom.ρ_inv X⟧, Quotient.sound ρ_hom_inv, Quotient.sound ρ_inv_hom⟩ rightUnitor_naturality := @fun X Y => by rintro ⟨f⟩ exact Quotient.sound (ρ_naturality _) pentagon W X Y Z := Quotient.sound pentagon triangle X Y := Quotient.sound triangle @[simp] theorem mk_comp {X Y Z : F C} (f : X ⟶ᵐ Y) (g : Y ⟶ᵐ Z) : ⟦f.comp g⟧ = @CategoryStruct.comp (F C) _ _ _ _ ⟦f⟧ ⟦g⟧ := rfl @[simp] theorem mk_tensor {X₁ Y₁ X₂ Y₂ : F C} (f : X₁ ⟶ᵐ Y₁) (g : X₂ ⟶ᵐ Y₂) : ⟦f.tensor g⟧ = @MonoidalCategory.tensorHom (F C) _ _ _ _ _ _ ⟦f⟧ ⟦g⟧ := rfl @[simp] theorem mk_whiskerLeft (X : F C) {Y₁ Y₂ : F C} (f : Y₁ ⟶ᵐ Y₂) : ⟦f.whiskerLeft X⟧ = MonoidalCategory.whiskerLeft (C := F C) (X := X) (f := ⟦f⟧) := rfl @[simp] theorem mk_whiskerRight {X₁ X₂ : F C} (f : X₁ ⟶ᵐ X₂) (Y : F C) : ⟦f.whiskerRight Y⟧ = MonoidalCategory.whiskerRight (C := F C) (f := ⟦f⟧) (Y := Y) := rfl @[simp] theorem mk_id {X : F C} : ⟦Hom.id X⟧ = 𝟙 X := rfl @[simp] theorem mk_α_hom {X Y Z : F C} : ⟦Hom.α_hom X Y Z⟧ = (α_ X Y Z).hom := rfl @[simp] theorem mk_α_inv {X Y Z : F C} : ⟦Hom.α_inv X Y Z⟧ = (α_ X Y Z).inv := rfl @[simp] theorem mk_ρ_hom {X : F C} : ⟦Hom.ρ_hom X⟧ = (ρ_ X).hom := rfl @[simp] theorem mk_ρ_inv {X : F C} : ⟦Hom.ρ_inv X⟧ = (ρ_ X).inv := rfl @[simp] theorem mk_l_hom {X : F C} : ⟦Hom.l_hom X⟧ = (λ_ X).hom := rfl @[simp] theorem mk_l_inv {X : F C} : ⟦Hom.l_inv X⟧ = (λ_ X).inv := rfl @[simp] theorem tensor_eq_tensor {X Y : F C} : X.tensor Y = X ⊗ Y := rfl @[simp] theorem unit_eq_unit : FreeMonoidalCategory.unit = 𝟙_ (F C) := rfl /-- The abbreviation for `⟦f⟧`. -/ /- This is useful since the notation `⟦f⟧` often behaves like an element of the quotient set, but not like a morphism. This is why we need weird `@CategoryStruct.comp (F C) ...` in the statement in `mk_comp` above. -/ abbrev homMk {X Y : F C} (f : X ⟶ᵐ Y) : X ⟶ Y := ⟦f⟧ theorem Hom.inductionOn {motive : {X Y : F C} → (X ⟶ Y) → Prop} {X Y : F C} (t : X ⟶ Y) (id : (X : F C) → motive (𝟙 X)) (α_hom : (X Y Z : F C) → motive (α_ X Y Z).hom) (α_inv : (X Y Z : F C) → motive (α_ X Y Z).inv) (l_hom : (X : F C) → motive (λ_ X).hom) (l_inv : (X : F C) → motive (λ_ X).inv) (ρ_hom : (X : F C) → motive (ρ_ X).hom) (ρ_inv : (X : F C) → motive (ρ_ X).inv) (comp : {X Y Z : F C} → (f : X ⟶ Y) → (g : Y ⟶ Z) → motive f → motive g → motive (f ≫ g)) (whiskerLeft : (X : F C) → {Y Z : F C} → (f : Y ⟶ Z) → motive f → motive (X ◁ f)) (whiskerRight : {X Y : F C} → (f : X ⟶ Y) → (Z : F C) → motive f → motive (f ▷ Z)) : motive t := by apply Quotient.inductionOn intro f induction f with | id X => exact id X | α_hom X Y Z => exact α_hom X Y Z | α_inv X Y Z => exact α_inv X Y Z | l_hom X => exact l_hom X | l_inv X => exact l_inv X | ρ_hom X => exact ρ_hom X | ρ_inv X => exact ρ_inv X | comp f g hf hg => exact comp _ _ (hf ⟦f⟧) (hg ⟦g⟧) | whiskerLeft X f hf => exact whiskerLeft X _ (hf ⟦f⟧) | whiskerRight f X hf => exact whiskerRight _ X (hf ⟦f⟧) | @tensor W X Y Z f g hf hg => have : homMk f ⊗ homMk g = homMk f ▷ X ≫ Y ◁ homMk g := Quotient.sound (HomEquiv.tensorHom_def f g) change motive (homMk f ⊗ homMk g) rw [this] exact comp _ _ (whiskerRight _ _ (hf ⟦f⟧)) (whiskerLeft _ _ (hg ⟦g⟧)) section Functor variable {D : Type u'} [Category.{v'} D] [MonoidalCategory D] (f : C → D) /-- Auxiliary definition for `free_monoidal_category.project`. -/ def projectObj : F C → D | FreeMonoidalCategory.of X => f X | FreeMonoidalCategory.unit => 𝟙_ D | FreeMonoidalCategory.tensor X Y => projectObj X ⊗ projectObj Y section open Hom /-- Auxiliary definition for `FreeMonoidalCategory.project`. -/ -- Porting note: here `@[simp]` generates a panic in -- _private.Lean.Meta.Match.MatchEqs.0.Lean.Meta.Match.SimpH.substRHS def projectMapAux : ∀ {X Y : F C}, (X ⟶ᵐ Y) → (projectObj f X ⟶ projectObj f Y) | _, _, Hom.id _ => 𝟙 _ | _, _, α_hom _ _ _ => (α_ _ _ _).hom | _, _, α_inv _ _ _ => (α_ _ _ _).inv | _, _, l_hom _ => (λ_ _).hom | _, _, l_inv _ => (λ_ _).inv | _, _, ρ_hom _ => (ρ_ _).hom | _, _, ρ_inv _ => (ρ_ _).inv | _, _, Hom.comp f g => projectMapAux f ≫ projectMapAux g | _, _, Hom.whiskerLeft X p => projectObj f X ◁ projectMapAux p | _, _, Hom.whiskerRight p X => projectMapAux p ▷ projectObj f X | _, _, Hom.tensor f g => projectMapAux f ⊗ projectMapAux g -- Porting note: this declaration generates the same panic. /-- Auxiliary definition for `FreeMonoidalCategory.project`. -/ def projectMap (X Y : F C) : (X ⟶ Y) → (projectObj f X ⟶ projectObj f Y) := Quotient.lift (projectMapAux f) <| by intro f g h induction h with | refl => rfl | symm _ _ _ hfg' => exact hfg'.symm | trans _ _ hfg hgh => exact hfg.trans hgh | comp _ _ hf hg => dsimp only [projectMapAux]; rw [hf, hg] | whiskerLeft _ _ _ _ hf => dsimp only [projectMapAux, projectObj]; rw [hf] | whiskerRight _ _ _ _ hf => dsimp only [projectMapAux, projectObj]; rw [hf] | tensor _ _ hfg hfg' => dsimp only [projectMapAux]; rw [hfg, hfg'] | tensorHom_def _ _ => dsimp only [projectMapAux, projectObj]; rw [MonoidalCategory.tensorHom_def] | comp_id => dsimp only [projectMapAux]; rw [Category.comp_id] | id_comp => dsimp only [projectMapAux]; rw [Category.id_comp] | assoc => dsimp only [projectMapAux]; rw [Category.assoc] | tensor_id => dsimp only [projectMapAux]; rw [MonoidalCategory.tensor_id]; rfl | tensor_comp => dsimp only [projectMapAux]; rw [MonoidalCategory.tensor_comp] | whiskerLeft_id => dsimp only [projectMapAux, projectObj] rw [MonoidalCategory.whiskerLeft_id] | id_whiskerRight => dsimp only [projectMapAux, projectObj] rw [MonoidalCategory.id_whiskerRight] | α_hom_inv => dsimp only [projectMapAux]; rw [Iso.hom_inv_id] | α_inv_hom => dsimp only [projectMapAux]; rw [Iso.inv_hom_id] | associator_naturality => dsimp only [projectMapAux]; rw [MonoidalCategory.associator_naturality] | ρ_hom_inv => dsimp only [projectMapAux]; rw [Iso.hom_inv_id] | ρ_inv_hom => dsimp only [projectMapAux]; rw [Iso.inv_hom_id] | ρ_naturality => dsimp only [projectMapAux, projectObj] rw [MonoidalCategory.rightUnitor_naturality] | l_hom_inv => dsimp only [projectMapAux]; rw [Iso.hom_inv_id] | l_inv_hom => dsimp only [projectMapAux]; rw [Iso.inv_hom_id] | l_naturality => dsimp only [projectMapAux, projectObj] rw [MonoidalCategory.leftUnitor_naturality] | pentagon => dsimp only [projectMapAux, projectObj] rw [MonoidalCategory.pentagon] | triangle => dsimp only [projectMapAux, projectObj] rw [MonoidalCategory.triangle] end /-- If `D` is a monoidal category and we have a function `C → D`, then we have a functor from the free monoidal category over `C` to the category `D`. -/ def project : MonoidalFunctor (F C) D where obj := projectObj f map := projectMap f _ _ -- Porting note: `map_comp` and `μ_natural` were proved in mathlib3 by tidy, using induction. -- We probably don't expect `aesop_cat` to handle this yet, see https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/Aesop.20and.20cases -- In any case I don't understand why we need to specify `using Quotient.recOn`. map_comp := by rintro _ _ _ ⟨_⟩ ⟨_⟩; rfl ε := 𝟙 _ μ X Y := 𝟙 _ μ_natural_left := fun f _ => by induction' f using Quotient.recOn · dsimp simp only [Category.comp_id, Category.id_comp] rw [← tensorHom_id, ← tensorHom_id] rfl · rfl μ_natural_right := fun _ f => by induction' f using Quotient.recOn · dsimp simp only [Category.comp_id, Category.id_comp] rw [← id_tensorHom, ← id_tensorHom] rfl · rfl end Functor end end FreeMonoidalCategory end CategoryTheory
CategoryTheory\Monoidal\Free\Coherence.lean
/- Copyright (c) 2021 Markus Himmel. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Markus Himmel -/ import Mathlib.CategoryTheory.Monoidal.Free.Basic import Mathlib.CategoryTheory.DiscreteCategory /-! # The monoidal coherence theorem In this file, we prove the monoidal coherence theorem, stated in the following form: the free monoidal category over any type `C` is thin. We follow a proof described by Ilya Beylin and Peter Dybjer, which has been previously formalized in the proof assistant ALF. The idea is to declare a normal form (with regard to association and adding units) on objects of the free monoidal category and consider the discrete subcategory of objects that are in normal form. A normalization procedure is then just a functor `fullNormalize : FreeMonoidalCategory C ⥤ Discrete (NormalMonoidalObject C)`, where functoriality says that two objects which are related by associators and unitors have the same normal form. Another desirable property of a normalization procedure is that an object is isomorphic (i.e., related via associators and unitors) to its normal form. In the case of the specific normalization procedure we use we not only get these isomorphisms, but also that they assemble into a natural isomorphism `𝟭 (FreeMonoidalCategory C) ≅ fullNormalize ⋙ inclusion`. But this means that any two parallel morphisms in the free monoidal category factor through a discrete category in the same way, so they must be equal, and hence the free monoidal category is thin. ## References * [Ilya Beylin and Peter Dybjer, Extracting a proof of coherence for monoidal categories from a proof of normalization for monoids][beylin1996] -/ universe u namespace CategoryTheory open MonoidalCategory namespace FreeMonoidalCategory variable {C : Type u} section variable (C) /-- We say an object in the free monoidal category is in normal form if it is of the form `(((𝟙_ C) ⊗ X₁) ⊗ X₂) ⊗ ⋯`. -/ -- porting note (#5171): removed @[nolint has_nonempty_instance] inductive NormalMonoidalObject : Type u | unit : NormalMonoidalObject | tensor : NormalMonoidalObject → C → NormalMonoidalObject end local notation "F" => FreeMonoidalCategory local notation "N" => Discrete ∘ NormalMonoidalObject local infixr:10 " ⟶ᵐ " => Hom -- Porting note: this was automatic in mathlib 3 instance (x y : N C) : Subsingleton (x ⟶ y) := Discrete.instSubsingletonDiscreteHom _ _ /-- Auxiliary definition for `inclusion`. -/ @[simp] def inclusionObj : NormalMonoidalObject C → F C | NormalMonoidalObject.unit => unit | NormalMonoidalObject.tensor n a => tensor (inclusionObj n) (of a) /-- The discrete subcategory of objects in normal form includes into the free monoidal category. -/ def inclusion : N C ⥤ F C := Discrete.functor inclusionObj @[simp] theorem inclusion_obj (X : N C) : inclusion.obj X = inclusionObj X.as := rfl @[simp] theorem inclusion_map {X Y : N C} (f : X ⟶ Y) : inclusion.map f = eqToHom (congr_arg _ (Discrete.ext (Discrete.eq_of_hom f))) := by rcases f with ⟨⟨⟩⟩ cases Discrete.ext (by assumption) apply inclusion.map_id /-- Auxiliary definition for `normalize`. -/ def normalizeObj : F C → NormalMonoidalObject C → NormalMonoidalObject C | unit, n => n | of X, n => NormalMonoidalObject.tensor n X | tensor X Y, n => normalizeObj Y (normalizeObj X n) @[simp] theorem normalizeObj_unitor (n : NormalMonoidalObject C) : normalizeObj (𝟙_ (F C)) n = n := rfl @[simp] theorem normalizeObj_tensor (X Y : F C) (n : NormalMonoidalObject C) : normalizeObj (X ⊗ Y) n = normalizeObj Y (normalizeObj X n) := rfl /-- Auxiliary definition for `normalize`. -/ def normalizeObj' (X : F C) : N C ⥤ N C := Discrete.functor fun n ↦ ⟨normalizeObj X n⟩ section open Hom /-- Auxiliary definition for `normalize`. Here we prove that objects that are related by associators and unitors map to the same normal form. -/ @[simp] def normalizeMapAux : ∀ {X Y : F C}, (X ⟶ᵐ Y) → (normalizeObj' X ⟶ normalizeObj' Y) | _, _, Hom.id _ => 𝟙 _ | _, _, α_hom X Y Z => by dsimp; exact Discrete.natTrans (fun _ => 𝟙 _) | _, _, α_inv _ _ _ => by dsimp; exact Discrete.natTrans (fun _ => 𝟙 _) | _, _, l_hom _ => by dsimp; exact Discrete.natTrans (fun _ => 𝟙 _) | _, _, l_inv _ => by dsimp; exact Discrete.natTrans (fun _ => 𝟙 _) | _, _, ρ_hom _ => by dsimp; exact Discrete.natTrans (fun _ => 𝟙 _) | _, _, ρ_inv _ => by dsimp; exact Discrete.natTrans (fun _ => 𝟙 _) | _, _, (@comp _ _ _ _ f g) => normalizeMapAux f ≫ normalizeMapAux g | _, _, (@Hom.tensor _ T _ _ W f g) => Discrete.natTrans <| fun ⟨X⟩ => (normalizeMapAux g).app ⟨normalizeObj T X⟩ ≫ (normalizeObj' W).map ((normalizeMapAux f).app ⟨X⟩) | _, _, (@Hom.whiskerLeft _ T _ W f) => Discrete.natTrans <| fun ⟨X⟩ => (normalizeMapAux f).app ⟨normalizeObj T X⟩ | _, _, (@Hom.whiskerRight _ T _ f W) => Discrete.natTrans <| fun X => (normalizeObj' W).map <| (normalizeMapAux f).app X end section variable (C) /-- Our normalization procedure works by first defining a functor `F C ⥤ (N C ⥤ N C)` (which turns out to be very easy), and then obtain a functor `F C ⥤ N C` by plugging in the normal object `𝟙_ C`. -/ @[simp] def normalize : F C ⥤ N C ⥤ N C where obj X := normalizeObj' X map {X Y} := Quotient.lift normalizeMapAux (by aesop_cat) /-- A variant of the normalization functor where we consider the result as an object in the free monoidal category (rather than an object of the discrete subcategory of objects in normal form). -/ @[simp] def normalize' : F C ⥤ N C ⥤ F C := normalize C ⋙ (whiskeringRight _ _ _).obj inclusion /-- The normalization functor for the free monoidal category over `C`. -/ def fullNormalize : F C ⥤ N C where obj X := ((normalize C).obj X).obj ⟨NormalMonoidalObject.unit⟩ map f := ((normalize C).map f).app ⟨NormalMonoidalObject.unit⟩ /-- Given an object `X` of the free monoidal category and an object `n` in normal form, taking the tensor product `n ⊗ X` in the free monoidal category is functorial in both `X` and `n`. -/ @[simp] def tensorFunc : F C ⥤ N C ⥤ F C where obj X := Discrete.functor fun n => inclusion.obj ⟨n⟩ ⊗ X map f := Discrete.natTrans (fun n => _ ◁ f) theorem tensorFunc_map_app {X Y : F C} (f : X ⟶ Y) (n) : ((tensorFunc C).map f).app n = _ ◁ f := rfl theorem tensorFunc_obj_map (Z : F C) {n n' : N C} (f : n ⟶ n') : ((tensorFunc C).obj Z).map f = inclusion.map f ▷ Z := by cases n cases n' rcases f with ⟨⟨h⟩⟩ dsimp at h subst h simp /-- Auxiliary definition for `normalizeIso`. Here we construct the isomorphism between `n ⊗ X` and `normalize X n`. -/ @[simp] def normalizeIsoApp : ∀ (X : F C) (n : N C), ((tensorFunc C).obj X).obj n ≅ ((normalize' C).obj X).obj n | of _, _ => Iso.refl _ | unit, _ => ρ_ _ | tensor X a, n => (α_ _ _ _).symm ≪≫ whiskerRightIso (normalizeIsoApp X n) a ≪≫ normalizeIsoApp _ _ /-- Almost non-definitionally equall to `normalizeIsoApp`, but has a better definitional property in the proof of `normalize_naturality`. -/ @[simp] def normalizeIsoApp' : ∀ (X : F C) (n : NormalMonoidalObject C), inclusionObj n ⊗ X ≅ inclusionObj (normalizeObj X n) | of _, _ => Iso.refl _ | unit, _ => ρ_ _ | tensor X Y, n => (α_ _ _ _).symm ≪≫ whiskerRightIso (normalizeIsoApp' X n) Y ≪≫ normalizeIsoApp' _ _ theorem normalizeIsoApp_eq : ∀ (X : F C) (n : N C), normalizeIsoApp C X n = normalizeIsoApp' C X n.as | of X, _ => rfl | unit, _ => rfl | tensor X Y, n => by rw [normalizeIsoApp, normalizeIsoApp'] rw [normalizeIsoApp_eq X n] rw [normalizeIsoApp_eq Y ⟨normalizeObj X n.as⟩] rfl @[simp] theorem normalizeIsoApp_tensor (X Y : F C) (n : N C) : normalizeIsoApp C (X ⊗ Y) n = (α_ _ _ _).symm ≪≫ whiskerRightIso (normalizeIsoApp C X n) Y ≪≫ normalizeIsoApp _ _ _ := rfl @[simp] theorem normalizeIsoApp_unitor (n : N C) : normalizeIsoApp C (𝟙_ (F C)) n = ρ_ _ := rfl /-- Auxiliary definition for `normalizeIso`. -/ @[simp] def normalizeIsoAux (X : F C) : (tensorFunc C).obj X ≅ (normalize' C).obj X := NatIso.ofComponents (normalizeIsoApp C X) (by rintro ⟨X⟩ ⟨Y⟩ ⟨⟨f⟩⟩ dsimp at f subst f dsimp simp) section variable {C} theorem normalizeObj_congr (n : NormalMonoidalObject C) {X Y : F C} (f : X ⟶ Y) : normalizeObj X n = normalizeObj Y n := by rcases f with ⟨f'⟩ apply @congr_fun _ _ fun n => normalizeObj X n clear n f induction f' with | comp _ _ _ _ => apply Eq.trans <;> assumption | whiskerLeft _ _ ih => funext; apply congr_fun ih | whiskerRight _ _ ih => funext; apply congr_arg₂ _ rfl (congr_fun ih _) | @tensor W X Y Z _ _ ih₁ ih₂ => funext n simp [congr_fun ih₁ n, congr_fun ih₂ (normalizeObj Y n)] | _ => funext; rfl theorem normalize_naturality (n : NormalMonoidalObject C) {X Y : F C} (f : X ⟶ Y) : inclusionObj n ◁ f ≫ (normalizeIsoApp' C Y n).hom = (normalizeIsoApp' C X n).hom ≫ inclusion.map (eqToHom (Discrete.ext (normalizeObj_congr n f))) := by revert n induction f using Hom.inductionOn case comp f g ihf ihg => simp [ihg, reassoc_of% (ihf _)] case whiskerLeft X' X Y f ih => intro n dsimp only [normalizeObj_tensor, normalizeIsoApp', tensor_eq_tensor, Iso.trans_hom, Iso.symm_hom, whiskerRightIso_hom, Function.comp_apply, inclusion_obj] rw [associator_inv_naturality_right_assoc, whisker_exchange_assoc, ih] simp case whiskerRight X Y h η' ih => intro n dsimp only [normalizeObj_tensor, normalizeIsoApp', tensor_eq_tensor, Iso.trans_hom, Iso.symm_hom, whiskerRightIso_hom, Function.comp_apply, inclusion_obj] rw [associator_inv_naturality_middle_assoc, ← comp_whiskerRight_assoc, ih] have := dcongr_arg (fun x => (normalizeIsoApp' C η' x).hom) (normalizeObj_congr n h) simp [this] all_goals simp end set_option tactic.skipAssignedInstances false in /-- The isomorphism between `n ⊗ X` and `normalize X n` is natural (in both `X` and `n`, but naturality in `n` is trivial and was "proved" in `normalizeIsoAux`). This is the real heart of our proof of the coherence theorem. -/ def normalizeIso : tensorFunc C ≅ normalize' C := NatIso.ofComponents (normalizeIsoAux C) <| by intro X Y f ext ⟨n⟩ convert normalize_naturality n f using 1 any_goals dsimp [NatIso.ofComponents]; congr; apply normalizeIsoApp_eq /-- The isomorphism between an object and its normal form is natural. -/ def fullNormalizeIso : 𝟭 (F C) ≅ fullNormalize C ⋙ inclusion := NatIso.ofComponents (fun X => (λ_ X).symm ≪≫ ((normalizeIso C).app X).app ⟨NormalMonoidalObject.unit⟩) (by intro X Y f dsimp rw [leftUnitor_inv_naturality_assoc, Category.assoc, Iso.cancel_iso_inv_left] exact congr_arg (fun f => NatTrans.app f (Discrete.mk NormalMonoidalObject.unit)) ((normalizeIso.{u} C).hom.naturality f)) end /-- The monoidal coherence theorem. -/ instance subsingleton_hom : Quiver.IsThin (F C) := fun X Y => ⟨fun f g => by have hfg : (fullNormalize C).map f = (fullNormalize C).map g := Subsingleton.elim _ _ have hf := NatIso.naturality_2 (fullNormalizeIso.{u} C) f have hg := NatIso.naturality_2 (fullNormalizeIso.{u} C) g exact hf.symm.trans (Eq.trans (by simp only [Functor.comp_map, hfg]) hg)⟩ section Groupoid section open Hom /-- Auxiliary construction for showing that the free monoidal category is a groupoid. Do not use this, use `IsIso.inv` instead. -/ def inverseAux : ∀ {X Y : F C}, (X ⟶ᵐ Y) → (Y ⟶ᵐ X) | _, _, Hom.id X => id X | _, _, α_hom _ _ _ => α_inv _ _ _ | _, _, α_inv _ _ _ => α_hom _ _ _ | _, _, ρ_hom _ => ρ_inv _ | _, _, ρ_inv _ => ρ_hom _ | _, _, l_hom _ => l_inv _ | _, _, l_inv _ => l_hom _ | _, _, comp f g => (inverseAux g).comp (inverseAux f) | _, _, Hom.whiskerLeft X f => (inverseAux f).whiskerLeft X | _, _, Hom.whiskerRight f X => (inverseAux f).whiskerRight X | _, _, Hom.tensor f g => (inverseAux f).tensor (inverseAux g) end instance : Groupoid.{u} (F C) := { (inferInstance : Category (F C)) with inv := Quotient.lift (fun f => ⟦inverseAux f⟧) (by aesop_cat) } end Groupoid end FreeMonoidalCategory end CategoryTheory
CategoryTheory\Monoidal\Internal\FunctorCategory.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.Monoidal.CommMon_ import Mathlib.CategoryTheory.Monoidal.Comon_ import Mathlib.CategoryTheory.Monoidal.FunctorCategory /-! # `Mon_ (C ⥤ D) ≌ C ⥤ Mon_ D` When `D` is a monoidal category, monoid objects in `C ⥤ D` are the same thing as functors from `C` into the monoid objects of `D`. This is formalised as: * `monFunctorCategoryEquivalence : Mon_ (C ⥤ D) ≌ C ⥤ Mon_ D` The intended application is that as `Ring ≌ Mon_ Ab` (not yet constructed!), we have `presheaf Ring X ≌ presheaf (Mon_ Ab) X ≌ Mon_ (presheaf Ab X)`, and we can model a module over a presheaf of rings as a module object in `presheaf Ab X`. ## Future work Presumably this statement is not specific to monoids, and could be generalised to any internal algebraic objects, if the appropriate framework was available. -/ universe v₁ v₂ u₁ u₂ open CategoryTheory MonoidalCategory namespace CategoryTheory.Monoidal variable (C : Type u₁) [Category.{v₁} C] variable (D : Type u₂) [Category.{v₂} D] [MonoidalCategory.{v₂} D] namespace MonFunctorCategoryEquivalence variable {C D} /-- A monoid object in a functor category induces a functor to the category of monoid objects. -/ @[simps] def functorObj (A : Mon_ (C ⥤ D)) : C ⥤ Mon_ D where obj X := { X := A.X.obj X one := A.one.app X mul := A.mul.app X one_mul := congr_app A.one_mul X mul_one := congr_app A.mul_one X mul_assoc := congr_app A.mul_assoc X } map f := { hom := A.X.map f one_hom := by rw [← A.one.naturality, tensorUnit_map]; dsimp; rw [Category.id_comp] mul_hom := by dsimp; rw [← A.mul.naturality, tensorObj_map] } map_id X := by ext; dsimp; rw [CategoryTheory.Functor.map_id] map_comp f g := by ext; dsimp; rw [Functor.map_comp] /-- Functor translating a monoid object in a functor category to a functor into the category of monoid objects. -/ @[simps] def functor : Mon_ (C ⥤ D) ⥤ C ⥤ Mon_ D where obj := functorObj map f := { app := fun X => { hom := f.hom.app X one_hom := congr_app f.one_hom X mul_hom := congr_app f.mul_hom X } } /-- A functor to the category of monoid objects can be translated as a monoid object in the functor category. -/ @[simps] def inverseObj (F : C ⥤ Mon_ D) : Mon_ (C ⥤ D) where X := F ⋙ Mon_.forget D one := { app := fun X => (F.obj X).one } mul := { app := fun X => (F.obj X).mul } /-- Functor translating a functor into the category of monoid objects to a monoid object in the functor category -/ @[simps] def inverse : (C ⥤ Mon_ D) ⥤ Mon_ (C ⥤ D) where obj := inverseObj map α := { hom := { app := fun X => (α.app X).hom naturality := fun X Y f => congr_arg Mon_.Hom.hom (α.naturality f) } } /-- The unit for the equivalence `Mon_ (C ⥤ D) ≌ C ⥤ Mon_ D`. -/ @[simps!] def unitIso : 𝟭 (Mon_ (C ⥤ D)) ≅ functor ⋙ inverse := NatIso.ofComponents (fun A => { hom := { hom := { app := fun _ => 𝟙 _ } } inv := { hom := { app := fun _ => 𝟙 _ } } }) /-- The counit for the equivalence `Mon_ (C ⥤ D) ≌ C ⥤ Mon_ D`. -/ @[simps!] def counitIso : inverse ⋙ functor ≅ 𝟭 (C ⥤ Mon_ D) := NatIso.ofComponents (fun A => NatIso.ofComponents (fun X => { hom := { hom := 𝟙 _ }, inv := { hom := 𝟙 _ } })) end MonFunctorCategoryEquivalence open MonFunctorCategoryEquivalence /-- When `D` is a monoidal category, monoid objects in `C ⥤ D` are the same thing as functors from `C` into the monoid objects of `D`. -/ @[simps] def monFunctorCategoryEquivalence : Mon_ (C ⥤ D) ≌ C ⥤ Mon_ D where functor := functor inverse := inverse unitIso := unitIso counitIso := counitIso namespace ComonFunctorCategoryEquivalence variable {C D} /-- A comonoid object in a functor category induces a functor to the category of comonoid objects. -/ @[simps] def functorObj (A : Comon_ (C ⥤ D)) : C ⥤ Comon_ D where obj X := { X := A.X.obj X counit := A.counit.app X comul := A.comul.app X counit_comul := congr_app A.counit_comul X comul_counit := congr_app A.comul_counit X comul_assoc := congr_app A.comul_assoc X } map f := { hom := A.X.map f hom_counit := by dsimp; rw [A.counit.naturality, tensorUnit_map]; dsimp; rw [Category.comp_id] hom_comul := by dsimp; rw [A.comul.naturality, tensorObj_map] } map_id X := by ext; dsimp; rw [CategoryTheory.Functor.map_id] map_comp f g := by ext; dsimp; rw [Functor.map_comp] /-- Functor translating a comonoid object in a functor category to a functor into the category of comonoid objects. -/ @[simps] def functor : Comon_ (C ⥤ D) ⥤ C ⥤ Comon_ D where obj := functorObj map f := { app := fun X => { hom := f.hom.app X hom_counit := congr_app f.hom_counit X hom_comul := congr_app f.hom_comul X } } /-- A functor to the category of comonoid objects can be translated as a comonoid object in the functor category. -/ @[simps] def inverseObj (F : C ⥤ Comon_ D) : Comon_ (C ⥤ D) where X := F ⋙ Comon_.forget D counit := { app := fun X => (F.obj X).counit } comul := { app := fun X => (F.obj X).comul } /-- Functor translating a functor into the category of comonoid objects to a comonoid object in the functor category -/ @[simps] private def inverse : (C ⥤ Comon_ D) ⥤ Comon_ (C ⥤ D) where obj := inverseObj map α := { hom := { app := fun X => (α.app X).hom naturality := fun X Y f => congr_arg Comon_.Hom.hom (α.naturality f) } hom_counit := by ext x; dsimp; rw [(α.app x).hom_counit] hom_comul := by ext x; dsimp; rw [(α.app x).hom_comul] } /-- The unit for the equivalence `Comon_ (C ⥤ D) ≌ C ⥤ Comon_ D`. -/ @[simps!] private def unitIso : 𝟭 (Comon_ (C ⥤ D)) ≅ functor ⋙ inverse := NatIso.ofComponents (fun A => { hom := { hom := { app := fun _ => 𝟙 _ } } inv := { hom := { app := fun _ => 𝟙 _ } } }) /-- The counit for the equivalence `Mon_ (C ⥤ D) ≌ C ⥤ Mon_ D`. -/ @[simps!] def counitIso : inverse ⋙ functor ≅ 𝟭 (C ⥤ Comon_ D) := NatIso.ofComponents (fun A => NatIso.ofComponents (fun X => { hom := { hom := 𝟙 _ }, inv := { hom := 𝟙 _ } }) ) end ComonFunctorCategoryEquivalence open ComonFunctorCategoryEquivalence /-- When `D` is a monoidal category, comonoid objects in `C ⥤ D` are the same thing as functors from `C` into the comonoid objects of `D`. -/ @[simps] def comonFunctorCategoryEquivalence : Comon_ (C ⥤ D) ≌ C ⥤ Comon_ D where functor := functor inverse := inverse unitIso := unitIso counitIso := counitIso variable [BraidedCategory.{v₂} D] namespace CommMonFunctorCategoryEquivalence variable {C D} /-- Functor translating a commutative monoid object in a functor category to a functor into the category of commutative monoid objects. -/ @[simps!] def functor : CommMon_ (C ⥤ D) ⥤ C ⥤ CommMon_ D where obj A := { (monFunctorCategoryEquivalence C D).functor.obj A.toMon_ with obj := fun X => { ((monFunctorCategoryEquivalence C D).functor.obj A.toMon_).obj X with mul_comm := congr_app A.mul_comm X } } map f := { app := fun X => ((monFunctorCategoryEquivalence C D).functor.map f).app X } /-- Functor translating a functor into the category of commutative monoid objects to a commutative monoid object in the functor category -/ @[simps!] def inverse : (C ⥤ CommMon_ D) ⥤ CommMon_ (C ⥤ D) where obj F := { (monFunctorCategoryEquivalence C D).inverse.obj (F ⋙ CommMon_.forget₂Mon_ D) with mul_comm := by ext X; exact (F.obj X).mul_comm } map α := (monFunctorCategoryEquivalence C D).inverse.map (whiskerRight α _) /-- The unit for the equivalence `CommMon_ (C ⥤ D) ≌ C ⥤ CommMon_ D`. -/ @[simps!] def unitIso : 𝟭 (CommMon_ (C ⥤ D)) ≅ functor ⋙ inverse := NatIso.ofComponents (fun A => { hom := { hom := { app := fun _ => 𝟙 _ } } inv := { hom := { app := fun _ => 𝟙 _ } } }) /-- The counit for the equivalence `CommMon_ (C ⥤ D) ≌ C ⥤ CommMon_ D`. -/ @[simps!] def counitIso : inverse ⋙ functor ≅ 𝟭 (C ⥤ CommMon_ D) := NatIso.ofComponents (fun A => NatIso.ofComponents (fun X => { hom := { hom := 𝟙 _ }, inv := { hom := 𝟙 _ } }) ) end CommMonFunctorCategoryEquivalence open CommMonFunctorCategoryEquivalence /-- When `D` is a braided monoidal category, commutative monoid objects in `C ⥤ D` are the same thing as functors from `C` into the commutative monoid objects of `D`. -/ @[simps] def commMonFunctorCategoryEquivalence : CommMon_ (C ⥤ D) ≌ C ⥤ CommMon_ D where functor := functor inverse := inverse unitIso := unitIso counitIso := counitIso end CategoryTheory.Monoidal
CategoryTheory\Monoidal\Internal\Limits.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.Monoidal.Internal.FunctorCategory import Mathlib.CategoryTheory.Monoidal.Limits import Mathlib.CategoryTheory.Limits.Preserves.Basic /-! # Limits of monoid objects. If `C` has limits (of a given shape), so does `Mon_ C`, and the forgetful functor preserves these limits. (This could potentially replace many individual constructions for concrete categories, in particular `MonCat`, `SemiRingCat`, `RingCat`, and `AlgebraCat R`.) -/ open CategoryTheory Limits Monoidal universe v u w noncomputable section namespace Mon_ variable {J : Type w} [SmallCategory J] variable {C : Type u} [Category.{v} C] [HasLimitsOfShape J C] [MonoidalCategory.{v} C] /-- We construct the (candidate) limit of a functor `F : J ⥤ Mon_ C` by interpreting it as a functor `Mon_ (J ⥤ C)`, and noting that taking limits is a lax monoidal functor, and hence sends monoid objects to monoid objects. -/ @[simps!] def limit (F : J ⥤ Mon_ C) : Mon_ C := limLax.mapMon.obj ((monFunctorCategoryEquivalence J C).inverse.obj F) /-- Implementation of `Mon_.hasLimits`: a limiting cone over a functor `F : J ⥤ Mon_ C`. -/ @[simps] def limitCone (F : J ⥤ Mon_ C) : Cone F where pt := limit F π := { app := fun j => { hom := limit.π (F ⋙ Mon_.forget C) j } naturality := fun j j' f => by ext; exact (limit.cone (F ⋙ Mon_.forget C)).π.naturality f } /-- The image of the proposed limit cone for `F : J ⥤ Mon_ C` under the forgetful functor `forget C : Mon_ C ⥤ C` is isomorphic to the limit cone of `F ⋙ forget C`. -/ def forgetMapConeLimitConeIso (F : J ⥤ Mon_ C) : (forget C).mapCone (limitCone F) ≅ limit.cone (F ⋙ forget C) := Cones.ext (Iso.refl _) (by aesop_cat) /-- Implementation of `Mon_.hasLimits`: the proposed cone over a functor `F : J ⥤ Mon_ C` is a limit cone. -/ @[simps] def limitConeIsLimit (F : J ⥤ Mon_ C) : IsLimit (limitCone F) where lift s := { hom := limit.lift (F ⋙ Mon_.forget C) ((Mon_.forget C).mapCone s) mul_hom := by dsimp ext simp only [Functor.comp_obj, forget_obj, Category.assoc, limit.lift_π, Functor.mapCone_pt, Functor.mapCone_π_app, forget_map, Hom.mul_hom, limit_mul, Cones.postcompose_obj_pt, Cones.postcompose_obj_π, NatTrans.comp_app, Functor.const_obj_obj, tensorObj_obj] slice_rhs 1 2 => rw [← MonoidalCategory.tensor_comp, limit.lift_π] rfl } fac s h := by ext; simp uniq s m w := by ext1 refine limit.hom_ext (fun j => ?_) dsimp; simp only [Mon_.forget_map, limit.lift_π, Functor.mapCone_π_app] exact congr_arg Mon_.Hom.hom (w j) instance hasLimitsOfShape [HasLimitsOfShape J C] : HasLimitsOfShape J (Mon_ C) where has_limit := fun F => HasLimit.mk { cone := limitCone F isLimit := limitConeIsLimit F } instance forgetPreservesLimitsOfShape : PreservesLimitsOfShape J (Mon_.forget C) where preservesLimit := fun {F} => preservesLimitOfPreservesLimitCone (limitConeIsLimit F) (IsLimit.ofIsoLimit (limit.isLimit (F ⋙ Mon_.forget C)) (forgetMapConeLimitConeIso F).symm) end Mon_
CategoryTheory\Monoidal\Internal\Module.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.Algebra.Category.ModuleCat.Monoidal.Basic import Mathlib.Algebra.Category.AlgebraCat.Basic import Mathlib.CategoryTheory.Monoidal.Mon_ /-! # `Mon_ (ModuleCat R) ≌ AlgebraCat R` The category of internal monoid objects in `ModuleCat R` is equivalent to the category of "native" bundled `R`-algebras. Moreover, this equivalence is compatible with the forgetful functors to `ModuleCat R`. -/ suppress_compilation universe v u open CategoryTheory open LinearMap open scoped TensorProduct attribute [local ext] TensorProduct.ext namespace ModuleCat variable {R : Type u} [CommRing R] namespace MonModuleEquivalenceAlgebra -- Porting note: in the following proof `have := ...; convert this` is to help Lean infer what the -- underlying rings are. -- Porting note: `simps(!)` doesn't work, I guess we will see what `simp` lemmas are needed and -- add them manually -- @[simps!] instance Ring_of_Mon_ (A : Mon_ (ModuleCat.{u} R)) : Ring A.X := { (inferInstance : AddCommGroup A.X) with one := A.one (1 : R) mul := fun x y => A.mul (x ⊗ₜ y) one_mul := fun x => by have := LinearMap.congr_fun A.one_mul ((1 : R) ⊗ₜ x) convert this rw [MonoidalCategory.leftUnitor_hom_apply, one_smul] mul_one := fun x => by have := LinearMap.congr_fun A.mul_one (x ⊗ₜ (1 : R)) convert this erw [MonoidalCategory.leftUnitor_hom_apply, one_smul] mul_assoc := fun x y z => by have := LinearMap.congr_fun A.mul_assoc (x ⊗ₜ y ⊗ₜ z) convert this left_distrib := fun x y z => by have := A.mul.map_add (x ⊗ₜ y) (x ⊗ₜ z) convert this rw [← TensorProduct.tmul_add] rfl right_distrib := fun x y z => by have := A.mul.map_add (x ⊗ₜ z) (y ⊗ₜ z) convert this rw [← TensorProduct.add_tmul] rfl zero_mul := fun x => show A.mul _ = 0 by rw [TensorProduct.zero_tmul, map_zero] mul_zero := fun x => show A.mul _ = 0 by rw [TensorProduct.tmul_zero, map_zero] } instance Algebra_of_Mon_ (A : Mon_ (ModuleCat.{u} R)) : Algebra R A.X := { A.one with map_zero' := A.one.map_zero map_one' := rfl map_mul' := fun x y => by have h := LinearMap.congr_fun A.one_mul.symm (x ⊗ₜ A.one y) rwa [MonoidalCategory.leftUnitor_hom_apply, ← A.one.map_smul] at h commutes' := fun r a => by dsimp have h₁ := LinearMap.congr_fun A.one_mul (r ⊗ₜ a) have h₂ := LinearMap.congr_fun A.mul_one (a ⊗ₜ r) exact h₁.trans h₂.symm smul_def' := fun r a => (LinearMap.congr_fun A.one_mul (r ⊗ₜ a)).symm } @[simp] theorem algebraMap (A : Mon_ (ModuleCat.{u} R)) (r : R) : algebraMap R A.X r = A.one r := rfl /-- Converting a monoid object in `ModuleCat R` to a bundled algebra. -/ @[simps!] def functor : Mon_ (ModuleCat.{u} R) ⥤ AlgebraCat R where obj A := AlgebraCat.of R A.X map {A B} f := { f.hom.toAddMonoidHom with toFun := f.hom map_one' := LinearMap.congr_fun f.one_hom (1 : R) map_mul' := fun x y => LinearMap.congr_fun f.mul_hom (x ⊗ₜ y) commutes' := fun r => LinearMap.congr_fun f.one_hom r } /-- Converting a bundled algebra to a monoid object in `ModuleCat R`. -/ @[simps] def inverseObj (A : AlgebraCat.{u} R) : Mon_ (ModuleCat.{u} R) where X := ModuleCat.of R A one := Algebra.linearMap R A mul := LinearMap.mul' R A one_mul := by -- Porting note: `ext` did not pick up `TensorProduct.ext` refine TensorProduct.ext <| LinearMap.ext_ring <| LinearMap.ext fun x => ?_ -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644 erw [compr₂_apply, compr₂_apply, CategoryTheory.comp_apply] -- Porting note: this `dsimp` does nothing -- dsimp [AlgebraCat.id_apply, TensorProduct.mk_apply, Algebra.linearMap_apply, -- LinearMap.compr₂_apply, Function.comp_apply, RingHom.map_one, -- ModuleCat.MonoidalCategory.hom_apply, AlgebraCat.coe_comp, -- ModuleCat.MonoidalCategory.leftUnitor_hom_apply] -- Porting note: because `dsimp` is not effective, `rw` needs to be changed to `erw` erw [LinearMap.mul'_apply, MonoidalCategory.leftUnitor_hom_apply, ← Algebra.smul_def] erw [id_apply] mul_one := by -- Porting note: `ext` did not pick up `TensorProduct.ext` refine TensorProduct.ext <| LinearMap.ext fun x => LinearMap.ext_ring ?_ -- Porting note: this `dsimp` does nothing -- dsimp only [AlgebraCat.id_apply, TensorProduct.mk_apply, Algebra.linearMap_apply, -- LinearMap.compr₂_apply, Function.comp_apply, ModuleCat.MonoidalCategory.hom_apply, -- AlgebraCat.coe_comp] -- Porting note: because `dsimp` is not effective, `rw` needs to be changed to `erw` erw [compr₂_apply, compr₂_apply] -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644 erw [CategoryTheory.comp_apply] erw [LinearMap.mul'_apply, ModuleCat.MonoidalCategory.rightUnitor_hom_apply, ← Algebra.commutes, ← Algebra.smul_def] erw [id_apply] mul_assoc := by set_option tactic.skipAssignedInstances false in -- Porting note: `ext` did not pick up `TensorProduct.ext` refine TensorProduct.ext <| TensorProduct.ext <| LinearMap.ext fun x => LinearMap.ext fun y => LinearMap.ext fun z => ?_ dsimp only [AlgebraCat.id_apply, TensorProduct.mk_apply, LinearMap.compr₂_apply, Function.comp_apply, ModuleCat.MonoidalCategory.hom_apply, AlgebraCat.coe_comp, MonoidalCategory.associator_hom_apply] rw [compr₂_apply, compr₂_apply] -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644 erw [CategoryTheory.comp_apply, CategoryTheory.comp_apply, CategoryTheory.comp_apply] erw [LinearMap.mul'_apply, LinearMap.mul'_apply] erw [id_apply] erw [TensorProduct.mk_apply, TensorProduct.mk_apply, mul'_apply, LinearMap.id_apply, mul'_apply] simp only [LinearMap.mul'_apply, mul_assoc] /-- Converting a bundled algebra to a monoid object in `ModuleCat R`. -/ @[simps] def inverse : AlgebraCat.{u} R ⥤ Mon_ (ModuleCat.{u} R) where obj := inverseObj map f := { hom := f.toLinearMap one_hom := LinearMap.ext f.commutes mul_hom := TensorProduct.ext <| LinearMap.ext₂ <| map_mul f } end MonModuleEquivalenceAlgebra open MonModuleEquivalenceAlgebra set_option maxHeartbeats 400000 in /-- The category of internal monoid objects in `ModuleCat R` is equivalent to the category of "native" bundled `R`-algebras. -/ def monModuleEquivalenceAlgebra : Mon_ (ModuleCat.{u} R) ≌ AlgebraCat R where functor := functor inverse := inverse unitIso := NatIso.ofComponents (fun A => { hom := { hom := { toFun := _root_.id map_add' := fun x y => rfl map_smul' := fun r a => rfl } mul_hom := by -- Porting note: `ext` did not pick up `TensorProduct.ext` refine TensorProduct.ext ?_ dsimp at * rfl } inv := { hom := { toFun := _root_.id map_add' := fun x y => rfl map_smul' := fun r a => rfl } mul_hom := by -- Porting note: `ext` did not pick up `TensorProduct.ext` refine TensorProduct.ext ?_ dsimp at * rfl } }) counitIso := NatIso.ofComponents (fun A => { hom := { toFun := _root_.id map_zero' := rfl map_add' := fun x y => rfl map_one' := (algebraMap R A).map_one map_mul' := fun x y => @LinearMap.mul'_apply R _ _ _ _ _ _ x y commutes' := fun r => rfl } inv := { toFun := _root_.id map_zero' := rfl map_add' := fun x y => rfl map_one' := (algebraMap R A).map_one.symm map_mul' := fun x y => (@LinearMap.mul'_apply R _ _ _ _ _ _ x y).symm commutes' := fun r => rfl } }) -- These lemmas have always been bad (#7657), but leanprover/lean4#2644 made `simp` start noticing attribute [nolint simpNF] ModuleCat.MonModuleEquivalenceAlgebra.functor_map_apply /-- The equivalence `Mon_ (ModuleCat R) ≌ AlgebraCat R` is naturally compatible with the forgetful functors to `ModuleCat R`. -/ def monModuleEquivalenceAlgebraForget : MonModuleEquivalenceAlgebra.functor ⋙ forget₂ (AlgebraCat.{u} R) (ModuleCat.{u} R) ≅ Mon_.forget (ModuleCat.{u} R) := NatIso.ofComponents (fun A => { hom := { toFun := _root_.id map_add' := fun x y => rfl map_smul' := fun c x => rfl } inv := { toFun := _root_.id map_add' := fun x y => rfl map_smul' := fun c x => rfl } }) end ModuleCat
CategoryTheory\Monoidal\Internal\Types.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.Algebra.Category.MonCat.Basic import Mathlib.CategoryTheory.Monoidal.CommMon_ import Mathlib.CategoryTheory.Monoidal.Types.Symmetric /-! # `Mon_ (Type u) ≌ MonCat.{u}` The category of internal monoid objects in `Type` is equivalent to the category of "native" bundled monoids. Moreover, this equivalence is compatible with the forgetful functors to `Type`. -/ universe v u open CategoryTheory namespace MonTypeEquivalenceMon instance monMonoid (A : Mon_ (Type u)) : Monoid A.X where one := A.one PUnit.unit mul x y := A.mul (x, y) one_mul x := by convert congr_fun A.one_mul (PUnit.unit, x) mul_one x := by convert congr_fun A.mul_one (x, PUnit.unit) mul_assoc x y z := by convert congr_fun A.mul_assoc ((x, y), z) /-- Converting a monoid object in `Type` to a bundled monoid. -/ noncomputable def functor : Mon_ (Type u) ⥤ MonCat.{u} where obj A := MonCat.of A.X map f := { toFun := f.hom map_one' := congr_fun f.one_hom PUnit.unit map_mul' := fun x y => congr_fun f.mul_hom (x, y) } /-- Converting a bundled monoid to a monoid object in `Type`. -/ noncomputable def inverse : MonCat.{u} ⥤ Mon_ (Type u) where obj A := { X := A one := fun _ => 1 mul := fun p => p.1 * p.2 one_mul := by ext ⟨_, _⟩; dsimp; simp mul_one := by ext ⟨_, _⟩; dsimp; simp mul_assoc := by ext ⟨⟨x, y⟩, z⟩; simp [mul_assoc] } map f := { hom := f } end MonTypeEquivalenceMon open MonTypeEquivalenceMon /-- The category of internal monoid objects in `Type` is equivalent to the category of "native" bundled monoids. -/ noncomputable def monTypeEquivalenceMon : Mon_ (Type u) ≌ MonCat.{u} where functor := functor inverse := inverse unitIso := NatIso.ofComponents (fun A => { hom := { hom := 𝟙 _ } inv := { hom := 𝟙 _ } }) (by aesop_cat) counitIso := NatIso.ofComponents (fun A => { hom := { toFun := id map_one' := rfl map_mul' := fun x y => rfl } inv := { toFun := id map_one' := rfl map_mul' := fun x y => rfl } }) (by aesop_cat) /-- The equivalence `Mon_ (Type u) ≌ MonCat.{u}` is naturally compatible with the forgetful functors to `Type u`. -/ noncomputable def monTypeEquivalenceMonForget : MonTypeEquivalenceMon.functor ⋙ forget MonCat ≅ Mon_.forget (Type u) := NatIso.ofComponents (fun A => Iso.refl _) (by aesop_cat) noncomputable instance monTypeInhabited : Inhabited (Mon_ (Type u)) := ⟨MonTypeEquivalenceMon.inverse.obj (MonCat.of PUnit)⟩ namespace CommMonTypeEquivalenceCommMon instance commMonCommMonoid (A : CommMon_ (Type u)) : CommMonoid A.X := { MonTypeEquivalenceMon.monMonoid A.toMon_ with mul_comm := fun x y => by convert congr_fun A.mul_comm (y, x) } /-- Converting a commutative monoid object in `Type` to a bundled commutative monoid. -/ noncomputable def functor : CommMon_ (Type u) ⥤ CommMonCat.{u} where obj A := CommMonCat.of A.X map f := MonTypeEquivalenceMon.functor.map f /-- Converting a bundled commutative monoid to a commutative monoid object in `Type`. -/ noncomputable def inverse : CommMonCat.{u} ⥤ CommMon_ (Type u) where obj A := { MonTypeEquivalenceMon.inverse.obj ((forget₂ CommMonCat MonCat).obj A) with mul_comm := by ext ⟨x : A, y : A⟩ exact CommMonoid.mul_comm y x } map f := MonTypeEquivalenceMon.inverse.map ((forget₂ CommMonCat MonCat).map f) end CommMonTypeEquivalenceCommMon open CommMonTypeEquivalenceCommMon /-- The category of internal commutative monoid objects in `Type` is equivalent to the category of "native" bundled commutative monoids. -/ noncomputable def commMonTypeEquivalenceCommMon : CommMon_ (Type u) ≌ CommMonCat.{u} where functor := functor inverse := inverse unitIso := NatIso.ofComponents (fun A => { hom := { hom := 𝟙 _ } inv := { hom := 𝟙 _ } }) (by aesop_cat) counitIso := NatIso.ofComponents (fun A => { hom := { toFun := id map_one' := rfl map_mul' := fun x y => rfl } inv := { toFun := id map_one' := rfl map_mul' := fun x y => rfl } }) (by aesop_cat) /-- The equivalences `Mon_ (Type u) ≌ MonCat.{u}` and `CommMon_ (Type u) ≌ CommMonCat.{u}` are naturally compatible with the forgetful functors to `MonCat` and `Mon_ (Type u)`. -/ noncomputable def commMonTypeEquivalenceCommMonForget : CommMonTypeEquivalenceCommMon.functor ⋙ forget₂ CommMonCat MonCat ≅ CommMon_.forget₂Mon_ (Type u) ⋙ MonTypeEquivalenceMon.functor := NatIso.ofComponents (fun A => Iso.refl _) (by aesop_cat) noncomputable instance commMonTypeInhabited : Inhabited (CommMon_ (Type u)) := ⟨CommMonTypeEquivalenceCommMon.inverse.obj (CommMonCat.of PUnit)⟩
CategoryTheory\Monoidal\OfChosenFiniteProducts\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, Simon Hudon -/ import Mathlib.CategoryTheory.Monoidal.Category import Mathlib.CategoryTheory.Limits.Shapes.BinaryProducts import Mathlib.CategoryTheory.PEmpty /-! # The monoidal structure on a category with chosen finite products. This is a variant of the development in `CategoryTheory.Monoidal.OfHasFiniteProducts`, which uses specified choices of the terminal object and binary product, enabling the construction of a cartesian category with specific definitions of the tensor unit and tensor product. (Because the construction in `CategoryTheory.Monoidal.OfHasFiniteProducts` uses `HasLimit` classes, the actual definitions there are opaque behind `Classical.choice`.) We use this in `CategoryTheory.Monoidal.TypeCat` to construct the monoidal category of types so that the tensor product is the usual cartesian product of types. For now we only do the construction from products, and not from coproducts, which seems less often useful. -/ universe v u namespace CategoryTheory variable (C : Type u) [Category.{v} C] {X Y : C} namespace Limits section variable {C} /-- Swap the two sides of a `BinaryFan`. -/ def BinaryFan.swap {P Q : C} (t : BinaryFan P Q) : BinaryFan Q P := BinaryFan.mk t.snd t.fst @[simp] theorem BinaryFan.swap_fst {P Q : C} (t : BinaryFan P Q) : t.swap.fst = t.snd := rfl @[simp] theorem BinaryFan.swap_snd {P Q : C} (t : BinaryFan P Q) : t.swap.snd = t.fst := rfl /-- If a binary fan `t` over `P Q` is a limit cone, then `t.swap` is a limit cone over `Q P`. -/ @[simps] def IsLimit.swapBinaryFan {P Q : C} {t : BinaryFan P Q} (I : IsLimit t) : IsLimit t.swap where lift s := I.lift (BinaryFan.swap s) fac s := by rintro ⟨⟨⟩⟩ <;> simp uniq s m w := by have h := I.uniq (BinaryFan.swap s) m rw [h] rintro ⟨j⟩ specialize w ⟨WalkingPair.swap j⟩ cases j <;> exact w /-- Construct `HasBinaryProduct Q P` from `HasBinaryProduct P Q`. This can't be an instance, as it would cause a loop in typeclass search. -/ theorem HasBinaryProduct.swap (P Q : C) [HasBinaryProduct P Q] : HasBinaryProduct Q P := HasLimit.mk ⟨BinaryFan.swap (limit.cone (pair P Q)), (limit.isLimit (pair P Q)).swapBinaryFan⟩ /-- Given a limit cone over `X` and `Y`, and another limit cone over `Y` and `X`, we can construct an isomorphism between the cone points. Relative to some fixed choice of limits cones for every pair, these isomorphisms constitute a braiding. -/ def BinaryFan.braiding {X Y : C} {s : BinaryFan X Y} (P : IsLimit s) {t : BinaryFan Y X} (Q : IsLimit t) : s.pt ≅ t.pt := IsLimit.conePointUniqueUpToIso P Q.swapBinaryFan /-- Given binary fans `sXY` over `X Y`, and `sYZ` over `Y Z`, and `s` over `sXY.X Z`, if `sYZ` is a limit cone we can construct a binary fan over `X sYZ.X`. This is an ingredient of building the associator for a cartesian category. -/ def BinaryFan.assoc {X Y Z : C} {sXY : BinaryFan X Y} {sYZ : BinaryFan Y Z} (Q : IsLimit sYZ) (s : BinaryFan sXY.pt Z) : BinaryFan X sYZ.pt := BinaryFan.mk (s.fst ≫ sXY.fst) (Q.lift (BinaryFan.mk (s.fst ≫ sXY.snd) s.snd)) @[simp] theorem BinaryFan.assoc_fst {X Y Z : C} {sXY : BinaryFan X Y} {sYZ : BinaryFan Y Z} (Q : IsLimit sYZ) (s : BinaryFan sXY.pt Z) : (BinaryFan.assoc Q s).fst = s.fst ≫ sXY.fst := rfl @[simp] theorem BinaryFan.assoc_snd {X Y Z : C} {sXY : BinaryFan X Y} {sYZ : BinaryFan Y Z} (Q : IsLimit sYZ) (s : BinaryFan sXY.pt Z) : (BinaryFan.assoc Q s).snd = Q.lift (BinaryFan.mk (s.fst ≫ sXY.snd) s.snd) := rfl /-- Given binary fans `sXY` over `X Y`, and `sYZ` over `Y Z`, and `s` over `X sYZ.X`, if `sYZ` is a limit cone we can construct a binary fan over `sXY.X Z`. This is an ingredient of building the associator for a cartesian category. -/ def BinaryFan.assocInv {X Y Z : C} {sXY : BinaryFan X Y} (P : IsLimit sXY) {sYZ : BinaryFan Y Z} (s : BinaryFan X sYZ.pt) : BinaryFan sXY.pt Z := BinaryFan.mk (P.lift (BinaryFan.mk s.fst (s.snd ≫ sYZ.fst))) (s.snd ≫ sYZ.snd) @[simp] theorem BinaryFan.assocInv_fst {X Y Z : C} {sXY : BinaryFan X Y} (P : IsLimit sXY) {sYZ : BinaryFan Y Z} (s : BinaryFan X sYZ.pt) : (BinaryFan.assocInv P s).fst = P.lift (BinaryFan.mk s.fst (s.snd ≫ sYZ.fst)) := rfl @[simp] theorem BinaryFan.assocInv_snd {X Y Z : C} {sXY : BinaryFan X Y} (P : IsLimit sXY) {sYZ : BinaryFan Y Z} (s : BinaryFan X sYZ.pt) : (BinaryFan.assocInv P s).snd = s.snd ≫ sYZ.snd := rfl /-- If all the binary fans involved a limit cones, `BinaryFan.assoc` produces another limit cone. -/ @[simps] def IsLimit.assoc {X Y Z : C} {sXY : BinaryFan X Y} (P : IsLimit sXY) {sYZ : BinaryFan Y Z} (Q : IsLimit sYZ) {s : BinaryFan sXY.pt Z} (R : IsLimit s) : IsLimit (BinaryFan.assoc Q s) where lift t := R.lift (BinaryFan.assocInv P t) fac t := by rintro ⟨⟨⟩⟩ <;> simp apply Q.hom_ext rintro ⟨⟨⟩⟩ <;> simp uniq t m w := by have h := R.uniq (BinaryFan.assocInv P t) m rw [h] rintro ⟨⟨⟩⟩ <;> simp · apply P.hom_ext rintro ⟨⟨⟩⟩ <;> simp · exact w ⟨WalkingPair.left⟩ · specialize w ⟨WalkingPair.right⟩ simp? at w says simp only [pair_obj_right, BinaryFan.π_app_right, BinaryFan.assoc_snd, Functor.const_obj_obj, pair_obj_left] at w rw [← w] simp · specialize w ⟨WalkingPair.right⟩ simp? at w says simp only [pair_obj_right, BinaryFan.π_app_right, BinaryFan.assoc_snd, Functor.const_obj_obj, pair_obj_left] at w rw [← w] simp /-- Given two pairs of limit cones corresponding to the parenthesisations of `X × Y × Z`, we obtain an isomorphism between the cone points. -/ abbrev BinaryFan.associator {X Y Z : C} {sXY : BinaryFan X Y} (P : IsLimit sXY) {sYZ : BinaryFan Y Z} (Q : IsLimit sYZ) {s : BinaryFan sXY.pt Z} (R : IsLimit s) {t : BinaryFan X sYZ.pt} (S : IsLimit t) : s.pt ≅ t.pt := IsLimit.conePointUniqueUpToIso (IsLimit.assoc P Q R) S /-- Given a fixed family of limit data for every pair `X Y`, we obtain an associator. -/ abbrev BinaryFan.associatorOfLimitCone (L : ∀ X Y : C, LimitCone (pair X Y)) (X Y Z : C) : (L (L X Y).cone.pt Z).cone.pt ≅ (L X (L Y Z).cone.pt).cone.pt := BinaryFan.associator (L X Y).isLimit (L Y Z).isLimit (L (L X Y).cone.pt Z).isLimit (L X (L Y Z).cone.pt).isLimit /-- Construct a left unitor from specified limit cones. -/ @[simps] def BinaryFan.leftUnitor {X : C} {s : Cone (Functor.empty.{0} C)} (P : IsLimit s) {t : BinaryFan s.pt X} (Q : IsLimit t) : t.pt ≅ X where hom := t.snd inv := Q.lift <| BinaryFan.mk (P.lift ⟨_, fun x => x.as.elim, fun {x} => x.as.elim⟩) (𝟙 _) hom_inv_id := by apply Q.hom_ext rintro ⟨⟨⟩⟩ · apply P.hom_ext rintro ⟨⟨⟩⟩ · simp /-- Construct a right unitor from specified limit cones. -/ @[simps] def BinaryFan.rightUnitor {X : C} {s : Cone (Functor.empty.{0} C)} (P : IsLimit s) {t : BinaryFan X s.pt} (Q : IsLimit t) : t.pt ≅ X where hom := t.fst inv := Q.lift <| BinaryFan.mk (𝟙 _) <| P.lift ⟨_, fun x => x.as.elim, fun {x} => x.as.elim⟩ hom_inv_id := by apply Q.hom_ext rintro ⟨⟨⟩⟩ · simp · apply P.hom_ext rintro ⟨⟨⟩⟩ end end Limits open CategoryTheory.Limits section -- Porting note: no tidy -- attribute [local tidy] tactic.case_bash variable {C} variable (𝒯 : LimitCone (Functor.empty.{0} C)) variable (ℬ : ∀ X Y : C, LimitCone (pair X Y)) namespace MonoidalOfChosenFiniteProducts /-- Implementation of the tensor product for `MonoidalOfChosenFiniteProducts`. -/ abbrev tensorObj (X Y : C) : C := (ℬ X Y).cone.pt /-- Implementation of the tensor product of morphisms for `MonoidalOfChosenFiniteProducts`. -/ abbrev tensorHom {W X Y Z : C} (f : W ⟶ X) (g : Y ⟶ Z) : tensorObj ℬ W Y ⟶ tensorObj ℬ X Z := (BinaryFan.IsLimit.lift' (ℬ X Z).isLimit ((ℬ W Y).cone.π.app ⟨WalkingPair.left⟩ ≫ f) (((ℬ W Y).cone.π.app ⟨WalkingPair.right⟩ : (ℬ W Y).cone.pt ⟶ Y) ≫ g)).val theorem tensor_id (X₁ X₂ : C) : tensorHom ℬ (𝟙 X₁) (𝟙 X₂) = 𝟙 (tensorObj ℬ X₁ X₂) := by apply IsLimit.hom_ext (ℬ _ _).isLimit rintro ⟨⟨⟩⟩ <;> · dsimp [tensorHom] simp theorem tensor_comp {X₁ Y₁ Z₁ X₂ Y₂ Z₂ : 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 apply IsLimit.hom_ext (ℬ _ _).isLimit rintro ⟨⟨⟩⟩ <;> · dsimp [tensorHom] simp theorem pentagon (W X Y Z : C) : tensorHom ℬ (BinaryFan.associatorOfLimitCone ℬ W X Y).hom (𝟙 Z) ≫ (BinaryFan.associatorOfLimitCone ℬ W (tensorObj ℬ X Y) Z).hom ≫ tensorHom ℬ (𝟙 W) (BinaryFan.associatorOfLimitCone ℬ X Y Z).hom = (BinaryFan.associatorOfLimitCone ℬ (tensorObj ℬ W X) Y Z).hom ≫ (BinaryFan.associatorOfLimitCone ℬ W X (tensorObj ℬ Y Z)).hom := by dsimp [tensorHom] apply IsLimit.hom_ext (ℬ _ _).isLimit; rintro ⟨⟨⟩⟩ · simp · apply IsLimit.hom_ext (ℬ _ _).isLimit rintro ⟨⟨⟩⟩ · simp apply IsLimit.hom_ext (ℬ _ _).isLimit rintro ⟨⟨⟩⟩ · simp · simp theorem triangle (X Y : C) : (BinaryFan.associatorOfLimitCone ℬ X 𝒯.cone.pt Y).hom ≫ tensorHom ℬ (𝟙 X) (BinaryFan.leftUnitor 𝒯.isLimit (ℬ 𝒯.cone.pt Y).isLimit).hom = tensorHom ℬ (BinaryFan.rightUnitor 𝒯.isLimit (ℬ X 𝒯.cone.pt).isLimit).hom (𝟙 Y) := by dsimp [tensorHom] apply IsLimit.hom_ext (ℬ _ _).isLimit; rintro ⟨⟨⟩⟩ <;> simp theorem leftUnitor_naturality {X₁ X₂ : C} (f : X₁ ⟶ X₂) : tensorHom ℬ (𝟙 𝒯.cone.pt) f ≫ (BinaryFan.leftUnitor 𝒯.isLimit (ℬ 𝒯.cone.pt X₂).isLimit).hom = (BinaryFan.leftUnitor 𝒯.isLimit (ℬ 𝒯.cone.pt X₁).isLimit).hom ≫ f := by dsimp [tensorHom] simp theorem rightUnitor_naturality {X₁ X₂ : C} (f : X₁ ⟶ X₂) : tensorHom ℬ f (𝟙 𝒯.cone.pt) ≫ (BinaryFan.rightUnitor 𝒯.isLimit (ℬ X₂ 𝒯.cone.pt).isLimit).hom = (BinaryFan.rightUnitor 𝒯.isLimit (ℬ X₁ 𝒯.cone.pt).isLimit).hom ≫ f := by dsimp [tensorHom] simp theorem associator_naturality {X₁ X₂ X₃ Y₁ Y₂ Y₃ : C} (f₁ : X₁ ⟶ Y₁) (f₂ : X₂ ⟶ Y₂) (f₃ : X₃ ⟶ Y₃) : tensorHom ℬ (tensorHom ℬ f₁ f₂) f₃ ≫ (BinaryFan.associatorOfLimitCone ℬ Y₁ Y₂ Y₃).hom = (BinaryFan.associatorOfLimitCone ℬ X₁ X₂ X₃).hom ≫ tensorHom ℬ f₁ (tensorHom ℬ f₂ f₃) := by dsimp [tensorHom] apply IsLimit.hom_ext (ℬ _ _).isLimit; rintro ⟨⟨⟩⟩ · simp · apply IsLimit.hom_ext (ℬ _ _).isLimit rintro ⟨⟨⟩⟩ · simp · simp end MonoidalOfChosenFiniteProducts open MonoidalOfChosenFiniteProducts /-- A category with a terminal object and binary products has a natural monoidal structure. -/ def monoidalOfChosenFiniteProducts : MonoidalCategory C := letI : MonoidalCategoryStruct C := { tensorUnit := 𝒯.cone.pt tensorObj := tensorObj ℬ tensorHom := tensorHom ℬ whiskerLeft := @fun X {_ _} g ↦ tensorHom ℬ (𝟙 X) g whiskerRight := @fun{_ _} f Y ↦ tensorHom ℬ f (𝟙 Y) associator := BinaryFan.associatorOfLimitCone ℬ leftUnitor := fun X ↦ BinaryFan.leftUnitor 𝒯.isLimit (ℬ 𝒯.cone.pt X).isLimit rightUnitor := fun X ↦ BinaryFan.rightUnitor 𝒯.isLimit (ℬ X 𝒯.cone.pt).isLimit} .ofTensorHom (tensor_id := tensor_id ℬ) (tensor_comp := tensor_comp ℬ) (pentagon := pentagon ℬ) (triangle := triangle 𝒯 ℬ) (leftUnitor_naturality := leftUnitor_naturality 𝒯 ℬ) (rightUnitor_naturality := rightUnitor_naturality 𝒯 ℬ) (associator_naturality := associator_naturality ℬ) namespace MonoidalOfChosenFiniteProducts open MonoidalCategory /-- A type synonym for `C` carrying a monoidal category structure corresponding to a fixed choice of limit data for the empty functor, and for `pair X Y` for every `X Y : C`. This is an implementation detail for `SymmetricOfChosenFiniteProducts`. -/ -- Porting note(#5171): linter `has_nonempty_instance` not ported yet -- @[nolint has_nonempty_instance] @[nolint unusedArguments] def MonoidalOfChosenFiniteProductsSynonym (_𝒯 : LimitCone (Functor.empty.{0} C)) (_ℬ : ∀ X Y : C, LimitCone (pair X Y)) := C instance : Category (MonoidalOfChosenFiniteProductsSynonym 𝒯 ℬ) := by dsimp [MonoidalOfChosenFiniteProductsSynonym] infer_instance instance : MonoidalCategory (MonoidalOfChosenFiniteProductsSynonym 𝒯 ℬ) := monoidalOfChosenFiniteProducts 𝒯 ℬ end MonoidalOfChosenFiniteProducts end end CategoryTheory
CategoryTheory\Monoidal\OfChosenFiniteProducts\Symmetric.lean
/- Copyright (c) 2019 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison, Simon Hudon -/ import Mathlib.CategoryTheory.Monoidal.Braided.Basic import Mathlib.CategoryTheory.Monoidal.OfChosenFiniteProducts.Basic /-! # The symmetric monoidal structure on a category with chosen finite products. -/ universe v u namespace CategoryTheory variable {C : Type u} [Category.{v} C] {X Y : C} open CategoryTheory.Limits variable (𝒯 : LimitCone (Functor.empty.{0} C)) variable (ℬ : ∀ X Y : C, LimitCone (pair X Y)) open MonoidalOfChosenFiniteProducts namespace MonoidalOfChosenFiniteProducts open MonoidalCategory theorem braiding_naturality {X X' Y Y' : C} (f : X ⟶ Y) (g : X' ⟶ Y') : tensorHom ℬ f g ≫ (Limits.BinaryFan.braiding (ℬ Y Y').isLimit (ℬ Y' Y).isLimit).hom = (Limits.BinaryFan.braiding (ℬ X X').isLimit (ℬ X' X).isLimit).hom ≫ tensorHom ℬ g f := by dsimp [tensorHom, Limits.BinaryFan.braiding] apply (ℬ _ _).isLimit.hom_ext rintro ⟨⟨⟩⟩ <;> · dsimp [Limits.IsLimit.conePointUniqueUpToIso]; simp theorem hexagon_forward (X Y Z : C) : (BinaryFan.associatorOfLimitCone ℬ X Y Z).hom ≫ (Limits.BinaryFan.braiding (ℬ X (tensorObj ℬ Y Z)).isLimit (ℬ (tensorObj ℬ Y Z) X).isLimit).hom ≫ (BinaryFan.associatorOfLimitCone ℬ Y Z X).hom = tensorHom ℬ (Limits.BinaryFan.braiding (ℬ X Y).isLimit (ℬ Y X).isLimit).hom (𝟙 Z) ≫ (BinaryFan.associatorOfLimitCone ℬ Y X Z).hom ≫ tensorHom ℬ (𝟙 Y) (Limits.BinaryFan.braiding (ℬ X Z).isLimit (ℬ Z X).isLimit).hom := by dsimp [tensorHom, Limits.BinaryFan.braiding] apply (ℬ _ _).isLimit.hom_ext; rintro ⟨⟨⟩⟩ · dsimp [Limits.IsLimit.conePointUniqueUpToIso]; simp · apply (ℬ _ _).isLimit.hom_ext rintro ⟨⟨⟩⟩ <;> · dsimp [Limits.IsLimit.conePointUniqueUpToIso]; simp theorem hexagon_reverse (X Y Z : C) : (BinaryFan.associatorOfLimitCone ℬ X Y Z).inv ≫ (Limits.BinaryFan.braiding (ℬ (tensorObj ℬ X Y) Z).isLimit (ℬ Z (tensorObj ℬ X Y)).isLimit).hom ≫ (BinaryFan.associatorOfLimitCone ℬ Z X Y).inv = tensorHom ℬ (𝟙 X) (Limits.BinaryFan.braiding (ℬ Y Z).isLimit (ℬ Z Y).isLimit).hom ≫ (BinaryFan.associatorOfLimitCone ℬ X Z Y).inv ≫ tensorHom ℬ (Limits.BinaryFan.braiding (ℬ X Z).isLimit (ℬ Z X).isLimit).hom (𝟙 Y) := by dsimp [tensorHom, Limits.BinaryFan.braiding] apply (ℬ _ _).isLimit.hom_ext; rintro ⟨⟨⟩⟩ · apply (ℬ _ _).isLimit.hom_ext rintro ⟨⟨⟩⟩ <;> · dsimp [BinaryFan.associatorOfLimitCone, BinaryFan.associator, Limits.IsLimit.conePointUniqueUpToIso] simp · dsimp [BinaryFan.associatorOfLimitCone, BinaryFan.associator, Limits.IsLimit.conePointUniqueUpToIso] simp theorem symmetry (X Y : C) : (Limits.BinaryFan.braiding (ℬ X Y).isLimit (ℬ Y X).isLimit).hom ≫ (Limits.BinaryFan.braiding (ℬ Y X).isLimit (ℬ X Y).isLimit).hom = 𝟙 (tensorObj ℬ X Y) := by dsimp [tensorHom, Limits.BinaryFan.braiding] apply (ℬ _ _).isLimit.hom_ext rintro ⟨⟨⟩⟩ <;> · dsimp [Limits.IsLimit.conePointUniqueUpToIso]; simp end MonoidalOfChosenFiniteProducts open MonoidalOfChosenFiniteProducts /-- The monoidal structure coming from finite products is symmetric. -/ def symmetricOfChosenFiniteProducts : SymmetricCategory (MonoidalOfChosenFiniteProductsSynonym 𝒯 ℬ) where braiding _ _ := Limits.BinaryFan.braiding (ℬ _ _).isLimit (ℬ _ _).isLimit braiding_naturality_left f X := braiding_naturality ℬ f (𝟙 X) braiding_naturality_right X _ _ f := braiding_naturality ℬ (𝟙 X) f hexagon_forward X Y Z := hexagon_forward ℬ X Y Z hexagon_reverse X Y Z := hexagon_reverse ℬ X Y Z symmetry X Y := symmetry ℬ X Y end CategoryTheory
CategoryTheory\Monoidal\Rigid\Basic.lean
/- Copyright (c) 2021 Jakob von Raumer. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jakob von Raumer -/ import Mathlib.Tactic.CategoryTheory.Coherence import Mathlib.CategoryTheory.Closed.Monoidal import Mathlib.Tactic.ApplyFun /-! # Rigid (autonomous) monoidal categories This file defines rigid (autonomous) monoidal categories and the necessary theory about exact pairings and duals. ## Main definitions * `ExactPairing` of two objects of a monoidal category * Type classes `HasLeftDual` and `HasRightDual` that capture that a pairing exists * The `rightAdjointMate f` as a morphism `fᘁ : Yᘁ ⟶ Xᘁ` for a morphism `f : X ⟶ Y` * The classes of `RightRigidCategory`, `LeftRigidCategory` and `RigidCategory` ## Main statements * `comp_rightAdjointMate`: The adjoint mates of the composition is the composition of adjoint mates. ## Notations * `η_` and `ε_` denote the coevaluation and evaluation morphism of an exact pairing. * `Xᘁ` and `ᘁX` denote the right and left dual of an object, as well as the adjoint mate of a morphism. ## Future work * Show that `X ⊗ Y` and `Yᘁ ⊗ Xᘁ` form an exact pairing. * Show that the left adjoint mate of the right adjoint mate of a morphism is the morphism itself. * Simplify constructions in the case where a symmetry or braiding is present. * Show that `ᘁ` gives an equivalence of categories `C ≅ (Cᵒᵖ)ᴹᵒᵖ`. * Define pivotal categories (rigid categories equipped with a natural isomorphism `ᘁᘁ ≅ 𝟙 C`). ## Notes Although we construct the adjunction `tensorLeft Y ⊣ tensorLeft X` from `ExactPairing X Y`, this is not a bijective correspondence. I think the correct statement is that `tensorLeft Y` and `tensorLeft X` are module endofunctors of `C` as a right `C` module category, and `ExactPairing X Y` is in bijection with adjunctions compatible with this right `C` action. ## References * <https://ncatlab.org/nlab/show/rigid+monoidal+category> ## Tags rigid category, monoidal category -/ open CategoryTheory MonoidalCategory universe v v₁ v₂ v₃ u u₁ u₂ u₃ noncomputable section namespace CategoryTheory variable {C : Type u₁} [Category.{v₁} C] [MonoidalCategory C] /-- An exact pairing is a pair of objects `X Y : C` which admit a coevaluation and evaluation morphism which fulfill two triangle equalities. -/ class ExactPairing (X Y : C) where /-- Coevaluation of an exact pairing. Do not use directly. Use `ExactPairing.coevaluation` instead. -/ coevaluation' : 𝟙_ C ⟶ X ⊗ Y /-- Evaluation of an exact pairing. Do not use directly. Use `ExactPairing.evaluation` instead. -/ evaluation' : Y ⊗ X ⟶ 𝟙_ C coevaluation_evaluation' : Y ◁ coevaluation' ≫ (α_ _ _ _).inv ≫ evaluation' ▷ Y = (ρ_ Y).hom ≫ (λ_ Y).inv := by aesop_cat evaluation_coevaluation' : coevaluation' ▷ X ≫ (α_ _ _ _).hom ≫ X ◁ evaluation' = (λ_ X).hom ≫ (ρ_ X).inv := by aesop_cat namespace ExactPairing -- Porting note: as there is no mechanism equivalent to `[]` in Lean 3 to make -- arguments for class fields explicit, -- we now repeat all the fields without primes. -- See https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/Making.20variable.20in.20class.20field.20explicit variable (X Y : C) variable [ExactPairing X Y] /-- Coevaluation of an exact pairing. -/ def coevaluation : 𝟙_ C ⟶ X ⊗ Y := @coevaluation' _ _ _ X Y _ /-- Evaluation of an exact pairing. -/ def evaluation : Y ⊗ X ⟶ 𝟙_ C := @evaluation' _ _ _ X Y _ @[inherit_doc] notation "η_" => ExactPairing.coevaluation @[inherit_doc] notation "ε_" => ExactPairing.evaluation lemma coevaluation_evaluation : Y ◁ η_ _ _ ≫ (α_ _ _ _).inv ≫ ε_ X _ ▷ Y = (ρ_ Y).hom ≫ (λ_ Y).inv := coevaluation_evaluation' lemma evaluation_coevaluation : η_ _ _ ▷ X ≫ (α_ _ _ _).hom ≫ X ◁ ε_ _ Y = (λ_ X).hom ≫ (ρ_ X).inv := evaluation_coevaluation' lemma coevaluation_evaluation'' : Y ◁ η_ X Y ⊗≫ ε_ X Y ▷ Y = ⊗𝟙 := by convert coevaluation_evaluation X Y <;> simp [monoidalComp] lemma evaluation_coevaluation'' : η_ X Y ▷ X ⊗≫ X ◁ ε_ X Y = ⊗𝟙 := by convert evaluation_coevaluation X Y <;> simp [monoidalComp] end ExactPairing attribute [reassoc (attr := simp)] ExactPairing.coevaluation_evaluation attribute [reassoc (attr := simp)] ExactPairing.evaluation_coevaluation instance exactPairingUnit : ExactPairing (𝟙_ C) (𝟙_ C) where coevaluation' := (ρ_ _).inv evaluation' := (ρ_ _).hom coevaluation_evaluation' := by rw [← id_tensorHom, ← tensorHom_id]; coherence evaluation_coevaluation' := by rw [← id_tensorHom, ← tensorHom_id]; coherence /-- A class of objects which have a right dual. -/ class HasRightDual (X : C) where /-- The right dual of the object `X`. -/ rightDual : C [exact : ExactPairing X rightDual] /-- A class of objects which have a left dual. -/ class HasLeftDual (Y : C) where /-- The left dual of the object `X`. -/ leftDual : C [exact : ExactPairing leftDual Y] attribute [instance] HasRightDual.exact attribute [instance] HasLeftDual.exact open ExactPairing HasRightDual HasLeftDual MonoidalCategory #adaptation_note /-- The overlapping notation for `leftDual` and `leftAdjointMate` become more problematic in after https://github.com/leanprover/lean4/pull/4596, and we sometimes have to disambiguate with e.g. `(ᘁX : C)` where previously just `ᘁX` was enough. -/ @[inherit_doc] prefix:1024 "ᘁ" => leftDual @[inherit_doc] postfix:1024 "ᘁ" => rightDual instance hasRightDualUnit : HasRightDual (𝟙_ C) where rightDual := 𝟙_ C instance hasLeftDualUnit : HasLeftDual (𝟙_ C) where leftDual := 𝟙_ C instance hasRightDualLeftDual {X : C} [HasLeftDual X] : HasRightDual ᘁX where rightDual := X instance hasLeftDualRightDual {X : C} [HasRightDual X] : HasLeftDual Xᘁ where leftDual := X @[simp] theorem leftDual_rightDual {X : C} [HasRightDual X] : ᘁXᘁ = X := rfl @[simp] theorem rightDual_leftDual {X : C} [HasLeftDual X] : (ᘁX)ᘁ = X := rfl /-- The right adjoint mate `fᘁ : Xᘁ ⟶ Yᘁ` of a morphism `f : X ⟶ Y`. -/ def rightAdjointMate {X Y : C} [HasRightDual X] [HasRightDual Y] (f : X ⟶ Y) : Yᘁ ⟶ Xᘁ := (ρ_ _).inv ≫ _ ◁ η_ _ _ ≫ _ ◁ f ▷ _ ≫ (α_ _ _ _).inv ≫ ε_ _ _ ▷ _ ≫ (λ_ _).hom /-- The left adjoint mate `ᘁf : ᘁY ⟶ ᘁX` of a morphism `f : X ⟶ Y`. -/ def leftAdjointMate {X Y : C} [HasLeftDual X] [HasLeftDual Y] (f : X ⟶ Y) : ᘁY ⟶ ᘁX := (λ_ _).inv ≫ η_ (ᘁX) X ▷ _ ≫ (_ ◁ f) ▷ _ ≫ (α_ _ _ _).hom ≫ _ ◁ ε_ _ _ ≫ (ρ_ _).hom @[inherit_doc] notation f "ᘁ" => rightAdjointMate f @[inherit_doc] notation "ᘁ" f => leftAdjointMate f @[simp] theorem rightAdjointMate_id {X : C} [HasRightDual X] : (𝟙 X)ᘁ = 𝟙 (Xᘁ) := by simp [rightAdjointMate] @[simp] theorem leftAdjointMate_id {X : C} [HasLeftDual X] : (ᘁ(𝟙 X)) = 𝟙 (ᘁX) := by simp [leftAdjointMate] theorem rightAdjointMate_comp {X Y Z : C} [HasRightDual X] [HasRightDual Y] {f : X ⟶ Y} {g : Xᘁ ⟶ Z} : fᘁ ≫ g = (ρ_ (Yᘁ)).inv ≫ _ ◁ η_ X (Xᘁ) ≫ _ ◁ (f ⊗ g) ≫ (α_ (Yᘁ) Y Z).inv ≫ ε_ Y (Yᘁ) ▷ _ ≫ (λ_ Z).hom := calc _ = 𝟙 _ ⊗≫ (Yᘁ : C) ◁ η_ X Xᘁ ≫ Yᘁ ◁ f ▷ Xᘁ ⊗≫ (ε_ Y Yᘁ ▷ Xᘁ ≫ 𝟙_ C ◁ g) ⊗≫ 𝟙 _ := by dsimp only [rightAdjointMate]; coherence _ = _ := by rw [← whisker_exchange, tensorHom_def]; coherence theorem leftAdjointMate_comp {X Y Z : C} [HasLeftDual X] [HasLeftDual Y] {f : X ⟶ Y} {g : (ᘁX) ⟶ Z} : (ᘁf) ≫ g = (λ_ _).inv ≫ η_ (ᘁX : C) X ▷ _ ≫ (g ⊗ f) ▷ _ ≫ (α_ _ _ _).hom ≫ _ ◁ ε_ _ _ ≫ (ρ_ _).hom := calc _ = 𝟙 _ ⊗≫ η_ (ᘁX : C) X ▷ (ᘁY) ⊗≫ (ᘁX) ◁ f ▷ (ᘁY) ⊗≫ ((ᘁX) ◁ ε_ (ᘁY) Y ≫ g ▷ 𝟙_ C) ⊗≫ 𝟙 _ := by dsimp only [leftAdjointMate]; coherence _ = _ := by rw [whisker_exchange, tensorHom_def']; coherence /-- The composition of right adjoint mates is the adjoint mate of the composition. -/ @[reassoc] theorem comp_rightAdjointMate {X Y Z : C} [HasRightDual X] [HasRightDual Y] [HasRightDual Z] {f : X ⟶ Y} {g : Y ⟶ Z} : (f ≫ g)ᘁ = gᘁ ≫ fᘁ := by rw [rightAdjointMate_comp] simp only [rightAdjointMate, comp_whiskerRight] simp only [← Category.assoc]; congr 3; simp only [Category.assoc] simp only [← MonoidalCategory.whiskerLeft_comp]; congr 2 symm calc _ = 𝟙 _ ⊗≫ (η_ Y Yᘁ ▷ 𝟙_ C ≫ (Y ⊗ Yᘁ) ◁ η_ X Xᘁ) ⊗≫ Y ◁ Yᘁ ◁ f ▷ Xᘁ ⊗≫ Y ◁ ε_ Y Yᘁ ▷ Xᘁ ⊗≫ g ▷ Xᘁ ⊗≫ 𝟙 _ := by rw [tensorHom_def']; coherence _ = η_ X Xᘁ ⊗≫ (η_ Y Yᘁ ▷ (X ⊗ Xᘁ) ≫ (Y ⊗ Yᘁ) ◁ f ▷ Xᘁ) ⊗≫ Y ◁ ε_ Y Yᘁ ▷ Xᘁ ⊗≫ g ▷ Xᘁ ⊗≫ 𝟙 _ := by rw [← whisker_exchange]; coherence _ = η_ X Xᘁ ⊗≫ f ▷ Xᘁ ⊗≫ (η_ Y Yᘁ ▷ Y ⊗≫ Y ◁ ε_ Y Yᘁ) ▷ Xᘁ ⊗≫ g ▷ Xᘁ ⊗≫ 𝟙 _ := by rw [← whisker_exchange]; coherence _ = η_ X Xᘁ ≫ f ▷ Xᘁ ≫ g ▷ Xᘁ := by rw [evaluation_coevaluation'']; coherence /-- The composition of left adjoint mates is the adjoint mate of the composition. -/ @[reassoc] theorem comp_leftAdjointMate {X Y Z : C} [HasLeftDual X] [HasLeftDual Y] [HasLeftDual Z] {f : X ⟶ Y} {g : Y ⟶ Z} : (ᘁf ≫ g) = (ᘁg) ≫ ᘁf := by rw [leftAdjointMate_comp] simp only [leftAdjointMate, MonoidalCategory.whiskerLeft_comp] simp only [← Category.assoc]; congr 3; simp only [Category.assoc] simp only [← comp_whiskerRight]; congr 2 symm calc _ = 𝟙 _ ⊗≫ ((𝟙_ C) ◁ η_ (ᘁY) Y ≫ η_ (ᘁX) X ▷ ((ᘁY) ⊗ Y)) ⊗≫ (ᘁX) ◁ f ▷ (ᘁY) ▷ Y ⊗≫ (ᘁX) ◁ ε_ (ᘁY) Y ▷ Y ⊗≫ (ᘁX) ◁ g := by rw [tensorHom_def]; coherence _ = η_ (ᘁX) X ⊗≫ (((ᘁX) ⊗ X) ◁ η_ (ᘁY) Y ≫ ((ᘁX) ◁ f) ▷ ((ᘁY) ⊗ Y)) ⊗≫ (ᘁX) ◁ ε_ (ᘁY) Y ▷ Y ⊗≫ (ᘁX) ◁ g := by rw [whisker_exchange]; coherence _ = η_ (ᘁX) X ⊗≫ ((ᘁX) ◁ f) ⊗≫ (ᘁX) ◁ (Y ◁ η_ (ᘁY) Y ⊗≫ ε_ (ᘁY) Y ▷ Y) ⊗≫ (ᘁX) ◁ g := by rw [whisker_exchange]; coherence _ = η_ (ᘁX) X ≫ (ᘁX) ◁ f ≫ (ᘁX) ◁ g := by rw [coevaluation_evaluation'']; coherence /-- Given an exact pairing on `Y Y'`, we get a bijection on hom-sets `(Y' ⊗ X ⟶ Z) ≃ (X ⟶ Y ⊗ Z)` by "pulling the string on the left" up or down. This gives the adjunction `tensorLeftAdjunction Y Y' : tensorLeft Y' ⊣ tensorLeft Y`. This adjunction is often referred to as "Frobenius reciprocity" in the fusion categories / planar algebras / subfactors literature. -/ def tensorLeftHomEquiv (X Y Y' Z : C) [ExactPairing Y Y'] : (Y' ⊗ X ⟶ Z) ≃ (X ⟶ Y ⊗ Z) where toFun f := (λ_ _).inv ≫ η_ _ _ ▷ _ ≫ (α_ _ _ _).hom ≫ _ ◁ f invFun f := Y' ◁ f ≫ (α_ _ _ _).inv ≫ ε_ _ _ ▷ _ ≫ (λ_ _).hom left_inv f := by calc _ = 𝟙 _ ⊗≫ Y' ◁ η_ Y Y' ▷ X ⊗≫ ((Y' ⊗ Y) ◁ f ≫ ε_ Y Y' ▷ Z) ⊗≫ 𝟙 _ := by coherence _ = 𝟙 _ ⊗≫ (Y' ◁ η_ Y Y' ⊗≫ ε_ Y Y' ▷ Y') ▷ X ⊗≫ f := by rw [whisker_exchange]; coherence _ = f := by rw [coevaluation_evaluation'']; coherence right_inv f := by calc _ = 𝟙 _ ⊗≫ (η_ Y Y' ▷ X ≫ (Y ⊗ Y') ◁ f) ⊗≫ Y ◁ ε_ Y Y' ▷ Z ⊗≫ 𝟙 _ := by coherence _ = f ⊗≫ (η_ Y Y' ▷ Y ⊗≫ Y ◁ ε_ Y Y') ▷ Z ⊗≫ 𝟙 _ := by rw [← whisker_exchange]; coherence _ = f := by rw [evaluation_coevaluation'']; coherence /-- Given an exact pairing on `Y Y'`, we get a bijection on hom-sets `(X ⊗ Y ⟶ Z) ≃ (X ⟶ Z ⊗ Y')` by "pulling the string on the right" up or down. -/ def tensorRightHomEquiv (X Y Y' Z : C) [ExactPairing Y Y'] : (X ⊗ Y ⟶ Z) ≃ (X ⟶ Z ⊗ Y') where toFun f := (ρ_ _).inv ≫ _ ◁ η_ _ _ ≫ (α_ _ _ _).inv ≫ f ▷ _ invFun f := f ▷ _ ≫ (α_ _ _ _).hom ≫ _ ◁ ε_ _ _ ≫ (ρ_ _).hom left_inv f := by calc _ = 𝟙 _ ⊗≫ X ◁ η_ Y Y' ▷ Y ⊗≫ (f ▷ (Y' ⊗ Y) ≫ Z ◁ ε_ Y Y') ⊗≫ 𝟙 _ := by coherence _ = 𝟙 _ ⊗≫ X ◁ (η_ Y Y' ▷ Y ⊗≫ Y ◁ ε_ Y Y') ⊗≫ f := by rw [← whisker_exchange]; coherence _ = f := by rw [evaluation_coevaluation'']; coherence right_inv f := by calc _ = 𝟙 _ ⊗≫ (X ◁ η_ Y Y' ≫ f ▷ (Y ⊗ Y')) ⊗≫ Z ◁ ε_ Y Y' ▷ Y' ⊗≫ 𝟙 _ := by coherence _ = f ⊗≫ Z ◁ (Y' ◁ η_ Y Y' ⊗≫ ε_ Y Y' ▷ Y') ⊗≫ 𝟙 _ := by rw [whisker_exchange]; coherence _ = f := by rw [coevaluation_evaluation'']; coherence theorem tensorLeftHomEquiv_naturality {X Y Y' Z Z' : C} [ExactPairing Y Y'] (f : Y' ⊗ X ⟶ Z) (g : Z ⟶ Z') : (tensorLeftHomEquiv X Y Y' Z') (f ≫ g) = (tensorLeftHomEquiv X Y Y' Z) f ≫ Y ◁ g := by simp [tensorLeftHomEquiv] theorem tensorLeftHomEquiv_symm_naturality {X X' Y Y' Z : C} [ExactPairing Y Y'] (f : X ⟶ X') (g : X' ⟶ Y ⊗ Z) : (tensorLeftHomEquiv X Y Y' Z).symm (f ≫ g) = _ ◁ f ≫ (tensorLeftHomEquiv X' Y Y' Z).symm g := by simp [tensorLeftHomEquiv] theorem tensorRightHomEquiv_naturality {X Y Y' Z Z' : C} [ExactPairing Y Y'] (f : X ⊗ Y ⟶ Z) (g : Z ⟶ Z') : (tensorRightHomEquiv X Y Y' Z') (f ≫ g) = (tensorRightHomEquiv X Y Y' Z) f ≫ g ▷ Y' := by simp [tensorRightHomEquiv] theorem tensorRightHomEquiv_symm_naturality {X X' Y Y' Z : C} [ExactPairing Y Y'] (f : X ⟶ X') (g : X' ⟶ Z ⊗ Y') : (tensorRightHomEquiv X Y Y' Z).symm (f ≫ g) = f ▷ Y ≫ (tensorRightHomEquiv X' Y Y' Z).symm g := by simp [tensorRightHomEquiv] /-- If `Y Y'` have an exact pairing, then the functor `tensorLeft Y'` is left adjoint to `tensorLeft Y`. -/ def tensorLeftAdjunction (Y Y' : C) [ExactPairing Y Y'] : tensorLeft Y' ⊣ tensorLeft Y := Adjunction.mkOfHomEquiv { homEquiv := fun X Z => tensorLeftHomEquiv X Y Y' Z homEquiv_naturality_left_symm := fun f g => tensorLeftHomEquiv_symm_naturality f g homEquiv_naturality_right := fun f g => tensorLeftHomEquiv_naturality f g } /-- If `Y Y'` have an exact pairing, then the functor `tensor_right Y` is left adjoint to `tensor_right Y'`. -/ def tensorRightAdjunction (Y Y' : C) [ExactPairing Y Y'] : tensorRight Y ⊣ tensorRight Y' := Adjunction.mkOfHomEquiv { homEquiv := fun X Z => tensorRightHomEquiv X Y Y' Z homEquiv_naturality_left_symm := fun f g => tensorRightHomEquiv_symm_naturality f g homEquiv_naturality_right := fun f g => tensorRightHomEquiv_naturality f g } /-- If `Y` has a left dual `ᘁY`, then it is a closed object, with the internal hom functor `Y ⟶[C] -` given by left tensoring by `ᘁY`. This has to be a definition rather than an instance to avoid diamonds, for example between `category_theory.monoidal_closed.functor_closed` and `CategoryTheory.Monoidal.functorHasLeftDual`. Moreover, in concrete applications there is often a more useful definition of the internal hom object than `ᘁY ⊗ X`, in which case the closed structure shouldn't come from `has_left_dual` (e.g. in the category `FinVect k`, it is more convenient to define the internal hom as `Y →ₗ[k] X` rather than `ᘁY ⊗ X` even though these are naturally isomorphic). -/ def closedOfHasLeftDual (Y : C) [HasLeftDual Y] : Closed Y where adj := tensorLeftAdjunction (ᘁY) Y /-- `tensorLeftHomEquiv` commutes with tensoring on the right -/ theorem tensorLeftHomEquiv_tensor {X X' Y Y' Z Z' : C} [ExactPairing Y Y'] (f : X ⟶ Y ⊗ Z) (g : X' ⟶ Z') : (tensorLeftHomEquiv (X ⊗ X') Y Y' (Z ⊗ Z')).symm ((f ⊗ g) ≫ (α_ _ _ _).hom) = (α_ _ _ _).inv ≫ ((tensorLeftHomEquiv X Y Y' Z).symm f ⊗ g) := by simp [tensorLeftHomEquiv, tensorHom_def'] /-- `tensorRightHomEquiv` commutes with tensoring on the left -/ theorem tensorRightHomEquiv_tensor {X X' Y Y' Z Z' : C} [ExactPairing Y Y'] (f : X ⟶ Z ⊗ Y') (g : X' ⟶ Z') : (tensorRightHomEquiv (X' ⊗ X) Y Y' (Z' ⊗ Z)).symm ((g ⊗ f) ≫ (α_ _ _ _).inv) = (α_ _ _ _).hom ≫ (g ⊗ (tensorRightHomEquiv X Y Y' Z).symm f) := by simp [tensorRightHomEquiv, tensorHom_def] @[simp] theorem tensorLeftHomEquiv_symm_coevaluation_comp_whiskerLeft {Y Y' Z : C} [ExactPairing Y Y'] (f : Y' ⟶ Z) : (tensorLeftHomEquiv _ _ _ _).symm (η_ _ _ ≫ Y ◁ f) = (ρ_ _).hom ≫ f := by calc _ = Y' ◁ η_ Y Y' ⊗≫ ((Y' ⊗ Y) ◁ f ≫ ε_ Y Y' ▷ Z) ⊗≫ 𝟙 _ := by dsimp [tensorLeftHomEquiv]; coherence _ = (Y' ◁ η_ Y Y' ⊗≫ ε_ Y Y' ▷ Y') ⊗≫ f := by rw [whisker_exchange]; coherence _ = _ := by rw [coevaluation_evaluation'']; coherence @[simp] theorem tensorLeftHomEquiv_symm_coevaluation_comp_whiskerRight {X Y : C} [HasRightDual X] [HasRightDual Y] (f : X ⟶ Y) : (tensorLeftHomEquiv _ _ _ _).symm (η_ _ _ ≫ f ▷ (Xᘁ)) = (ρ_ _).hom ≫ fᘁ := by dsimp [tensorLeftHomEquiv, rightAdjointMate] simp @[simp] theorem tensorRightHomEquiv_symm_coevaluation_comp_whiskerLeft {X Y : C} [HasLeftDual X] [HasLeftDual Y] (f : X ⟶ Y) : (tensorRightHomEquiv _ (ᘁY) _ _).symm (η_ (ᘁX : C) X ≫ (ᘁX : C) ◁ f) = (λ_ _).hom ≫ ᘁf := by dsimp [tensorRightHomEquiv, leftAdjointMate] simp @[simp] theorem tensorRightHomEquiv_symm_coevaluation_comp_whiskerRight {Y Y' Z : C} [ExactPairing Y Y'] (f : Y ⟶ Z) : (tensorRightHomEquiv _ Y _ _).symm (η_ Y Y' ≫ f ▷ Y') = (λ_ _).hom ≫ f := calc _ = η_ Y Y' ▷ Y ⊗≫ (f ▷ (Y' ⊗ Y) ≫ Z ◁ ε_ Y Y') ⊗≫ 𝟙 _ := by dsimp [tensorRightHomEquiv]; coherence _ = (η_ Y Y' ▷ Y ⊗≫ Y ◁ ε_ Y Y') ⊗≫ f := by rw [← whisker_exchange]; coherence _ = _ := by rw [evaluation_coevaluation'']; coherence @[simp] theorem tensorLeftHomEquiv_whiskerLeft_comp_evaluation {Y Z : C} [HasLeftDual Z] (f : Y ⟶ ᘁZ) : (tensorLeftHomEquiv _ _ _ _) (Z ◁ f ≫ ε_ _ _) = f ≫ (ρ_ _).inv := calc _ = 𝟙 _ ⊗≫ (η_ (ᘁZ : C) Z ▷ Y ≫ ((ᘁZ) ⊗ Z) ◁ f) ⊗≫ (ᘁZ) ◁ ε_ (ᘁZ) Z := by dsimp [tensorLeftHomEquiv]; coherence _ = f ⊗≫ (η_ (ᘁZ) Z ▷ (ᘁZ) ⊗≫ (ᘁZ) ◁ ε_ (ᘁZ) Z) := by rw [← whisker_exchange]; coherence _ = _ := by rw [evaluation_coevaluation'']; coherence @[simp] theorem tensorLeftHomEquiv_whiskerRight_comp_evaluation {X Y : C} [HasLeftDual X] [HasLeftDual Y] (f : X ⟶ Y) : (tensorLeftHomEquiv _ _ _ _) (f ▷ _ ≫ ε_ _ _) = (ᘁf) ≫ (ρ_ _).inv := by dsimp [tensorLeftHomEquiv, leftAdjointMate] simp @[simp] theorem tensorRightHomEquiv_whiskerLeft_comp_evaluation {X Y : C} [HasRightDual X] [HasRightDual Y] (f : X ⟶ Y) : (tensorRightHomEquiv _ _ _ _) ((Yᘁ : C) ◁ f ≫ ε_ _ _) = fᘁ ≫ (λ_ _).inv := by dsimp [tensorRightHomEquiv, rightAdjointMate] simp @[simp] theorem tensorRightHomEquiv_whiskerRight_comp_evaluation {X Y : C} [HasRightDual X] (f : Y ⟶ Xᘁ) : (tensorRightHomEquiv _ _ _ _) (f ▷ X ≫ ε_ X (Xᘁ)) = f ≫ (λ_ _).inv := calc _ = 𝟙 _ ⊗≫ (Y ◁ η_ X Xᘁ ≫ f ▷ (X ⊗ Xᘁ)) ⊗≫ ε_ X Xᘁ ▷ Xᘁ := by dsimp [tensorRightHomEquiv]; coherence _ = f ⊗≫ (Xᘁ ◁ η_ X Xᘁ ⊗≫ ε_ X Xᘁ ▷ Xᘁ) := by rw [whisker_exchange]; coherence _ = _ := by rw [coevaluation_evaluation'']; coherence -- Next four lemmas passing `fᘁ` or `ᘁf` through (co)evaluations. @[reassoc] theorem coevaluation_comp_rightAdjointMate {X Y : C} [HasRightDual X] [HasRightDual Y] (f : X ⟶ Y) : η_ Y (Yᘁ) ≫ _ ◁ (fᘁ) = η_ _ _ ≫ f ▷ _ := by apply_fun (tensorLeftHomEquiv _ Y (Yᘁ) _).symm simp @[reassoc] theorem leftAdjointMate_comp_evaluation {X Y : C} [HasLeftDual X] [HasLeftDual Y] (f : X ⟶ Y) : X ◁ (ᘁf) ≫ ε_ _ _ = f ▷ _ ≫ ε_ _ _ := by apply_fun tensorLeftHomEquiv _ (ᘁX) X _ simp @[reassoc] theorem coevaluation_comp_leftAdjointMate {X Y : C} [HasLeftDual X] [HasLeftDual Y] (f : X ⟶ Y) : η_ (ᘁY) Y ≫ (ᘁf) ▷ Y = η_ (ᘁX) X ≫ (ᘁX) ◁ f := by apply_fun (tensorRightHomEquiv _ (ᘁY) Y _).symm simp @[reassoc] theorem rightAdjointMate_comp_evaluation {X Y : C} [HasRightDual X] [HasRightDual Y] (f : X ⟶ Y) : (fᘁ ▷ X) ≫ ε_ X (Xᘁ) = ((Yᘁ) ◁ f) ≫ ε_ Y (Yᘁ) := by apply_fun tensorRightHomEquiv _ X (Xᘁ) _ simp /-- Transport an exact pairing across an isomorphism in the first argument. -/ def exactPairingCongrLeft {X X' Y : C} [ExactPairing X' Y] (i : X ≅ X') : ExactPairing X Y where evaluation' := Y ◁ i.hom ≫ ε_ _ _ coevaluation' := η_ _ _ ≫ i.inv ▷ Y evaluation_coevaluation' := calc _ = η_ X' Y ▷ X ⊗≫ (i.inv ▷ (Y ⊗ X) ≫ X ◁ (Y ◁ i.hom)) ⊗≫ X ◁ ε_ X' Y := by coherence _ = 𝟙 _ ⊗≫ (η_ X' Y ▷ X ≫ (X' ⊗ Y) ◁ i.hom) ⊗≫ (i.inv ▷ (Y ⊗ X') ≫ X ◁ ε_ X' Y) ⊗≫ 𝟙 _ := by rw [← whisker_exchange]; coherence _ = 𝟙 _ ⊗≫ i.hom ⊗≫ (η_ X' Y ▷ X' ⊗≫ X' ◁ ε_ X' Y) ⊗≫ i.inv ⊗≫ 𝟙 _ := by rw [← whisker_exchange, ← whisker_exchange]; coherence _ = 𝟙 _ ⊗≫ (i.hom ≫ i.inv) ⊗≫ 𝟙 _ := by rw [evaluation_coevaluation'']; coherence _ = (λ_ X).hom ≫ (ρ_ X).inv := by rw [Iso.hom_inv_id] -- coherence failed simp [monoidalComp] coevaluation_evaluation' := by calc _ = Y ◁ η_ X' Y ≫ Y ◁ (i.inv ≫ i.hom) ▷ Y ⊗≫ ε_ X' Y ▷ Y := by coherence _ = Y ◁ η_ X' Y ⊗≫ ε_ X' Y ▷ Y := by rw [Iso.inv_hom_id]; coherence _ = _ := by rw [coevaluation_evaluation''] -- coherence failed simp [monoidalComp] /-- Transport an exact pairing across an isomorphism in the second argument. -/ def exactPairingCongrRight {X Y Y' : C} [ExactPairing X Y'] (i : Y ≅ Y') : ExactPairing X Y where evaluation' := i.hom ▷ X ≫ ε_ _ _ coevaluation' := η_ _ _ ≫ X ◁ i.inv evaluation_coevaluation' := by calc _ = η_ X Y' ▷ X ⊗≫ X ◁ (i.inv ≫ i.hom) ▷ X ≫ X ◁ ε_ X Y' := by coherence _ = η_ X Y' ▷ X ⊗≫ X ◁ ε_ X Y' := by rw [Iso.inv_hom_id]; coherence _ = _ := by rw [evaluation_coevaluation''] -- coherence failed simp [monoidalComp] coevaluation_evaluation' := calc _ = Y ◁ η_ X Y' ⊗≫ (Y ◁ (X ◁ i.inv) ≫ i.hom ▷ (X ⊗ Y)) ⊗≫ ε_ X Y' ▷ Y := by coherence _ = 𝟙 _ ⊗≫ (Y ◁ η_ X Y' ≫ i.hom ▷ (X ⊗ Y')) ⊗≫ ((Y' ⊗ X) ◁ i.inv ≫ ε_ X Y' ▷ Y) ⊗≫ 𝟙 _ := by rw [whisker_exchange]; coherence _ = 𝟙 _ ⊗≫ i.hom ⊗≫ (Y' ◁ η_ X Y' ⊗≫ ε_ X Y' ▷ Y') ⊗≫ i.inv ⊗≫ 𝟙 _ := by rw [whisker_exchange, whisker_exchange]; coherence _ = 𝟙 _ ⊗≫ (i.hom ≫ i.inv) ⊗≫ 𝟙 _ := by rw [coevaluation_evaluation'']; coherence _ = (ρ_ Y).hom ≫ (λ_ Y).inv := by rw [Iso.hom_inv_id] -- coherence failed simp [monoidalComp] /-- Transport an exact pairing across isomorphisms. -/ def exactPairingCongr {X X' Y Y' : C} [ExactPairing X' Y'] (i : X ≅ X') (j : Y ≅ Y') : ExactPairing X Y := haveI : ExactPairing X' Y := exactPairingCongrRight j exactPairingCongrLeft i /-- Right duals are isomorphic. -/ def rightDualIso {X Y₁ Y₂ : C} (p₁ : ExactPairing X Y₁) (p₂ : ExactPairing X Y₂) : Y₁ ≅ Y₂ where hom := @rightAdjointMate C _ _ X X ⟨Y₂⟩ ⟨Y₁⟩ (𝟙 X) inv := @rightAdjointMate C _ _ X X ⟨Y₁⟩ ⟨Y₂⟩ (𝟙 X) -- Porting note: no implicit arguments were required below: hom_inv_id := by rw [← @comp_rightAdjointMate C _ _ X X X ⟨Y₁⟩ ⟨Y₂⟩ ⟨Y₁⟩, Category.comp_id, @rightAdjointMate_id _ _ _ _ ⟨Y₁⟩] rfl inv_hom_id := by rw [← @comp_rightAdjointMate C _ _ X X X ⟨Y₂⟩ ⟨Y₁⟩ ⟨Y₂⟩, Category.comp_id, @rightAdjointMate_id _ _ _ _ ⟨Y₂⟩] rfl /-- Left duals are isomorphic. -/ def leftDualIso {X₁ X₂ Y : C} (p₁ : ExactPairing X₁ Y) (p₂ : ExactPairing X₂ Y) : X₁ ≅ X₂ where hom := @leftAdjointMate C _ _ Y Y ⟨X₂⟩ ⟨X₁⟩ (𝟙 Y) inv := @leftAdjointMate C _ _ Y Y ⟨X₁⟩ ⟨X₂⟩ (𝟙 Y) -- Porting note: no implicit arguments were required below: hom_inv_id := by rw [← @comp_leftAdjointMate C _ _ Y Y Y ⟨X₁⟩ ⟨X₂⟩ ⟨X₁⟩, Category.comp_id, @leftAdjointMate_id _ _ _ _ ⟨X₁⟩] rfl inv_hom_id := by rw [← @comp_leftAdjointMate C _ _ Y Y Y ⟨X₂⟩ ⟨X₁⟩ ⟨X₂⟩, Category.comp_id, @leftAdjointMate_id _ _ _ _ ⟨X₂⟩] rfl @[simp] theorem rightDualIso_id {X Y : C} (p : ExactPairing X Y) : rightDualIso p p = Iso.refl Y := by ext simp only [rightDualIso, Iso.refl_hom, @rightAdjointMate_id _ _ _ _ ⟨Y⟩] @[simp] theorem leftDualIso_id {X Y : C} (p : ExactPairing X Y) : leftDualIso p p = Iso.refl X := by ext simp only [leftDualIso, Iso.refl_hom, @leftAdjointMate_id _ _ _ _ ⟨X⟩] /-- A right rigid monoidal category is one in which every object has a right dual. -/ class RightRigidCategory (C : Type u) [Category.{v} C] [MonoidalCategory.{v} C] where [rightDual : ∀ X : C, HasRightDual X] /-- A left rigid monoidal category is one in which every object has a right dual. -/ class LeftRigidCategory (C : Type u) [Category.{v} C] [MonoidalCategory.{v} C] where [leftDual : ∀ X : C, HasLeftDual X] attribute [instance 100] RightRigidCategory.rightDual attribute [instance 100] LeftRigidCategory.leftDual /-- Any left rigid category is monoidal closed, with the internal hom `X ⟶[C] Y = ᘁX ⊗ Y`. This has to be a definition rather than an instance to avoid diamonds, for example between `category_theory.monoidal_closed.functor_category` and `CategoryTheory.Monoidal.leftRigidFunctorCategory`. Moreover, in concrete applications there is often a more useful definition of the internal hom object than `ᘁY ⊗ X`, in which case the monoidal closed structure shouldn't come the rigid structure (e.g. in the category `FinVect k`, it is more convenient to define the internal hom as `Y →ₗ[k] X` rather than `ᘁY ⊗ X` even though these are naturally isomorphic). -/ def monoidalClosedOfLeftRigidCategory (C : Type u) [Category.{v} C] [MonoidalCategory.{v} C] [LeftRigidCategory C] : MonoidalClosed C where closed X := closedOfHasLeftDual X /-- A rigid monoidal category is a monoidal category which is left rigid and right rigid. -/ class RigidCategory (C : Type u) [Category.{v} C] [MonoidalCategory.{v} C] extends RightRigidCategory C, LeftRigidCategory C end CategoryTheory
CategoryTheory\Monoidal\Rigid\FunctorCategory.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.Monoidal.Rigid.Basic import Mathlib.CategoryTheory.Monoidal.FunctorCategory /-! # Functors from a groupoid into a right/left rigid category form a right/left rigid category. (Using the pointwise monoidal structure on the functor category.) -/ noncomputable section open CategoryTheory open CategoryTheory.MonoidalCategory namespace CategoryTheory.Monoidal variable {C D : Type*} [Groupoid C] [Category D] [MonoidalCategory D] instance functorHasRightDual [RightRigidCategory D] (F : C ⥤ D) : HasRightDual F where rightDual := { obj := fun X => (F.obj X)ᘁ map := fun f => (F.map (inv f))ᘁ map_comp := fun f g => by simp [comp_rightAdjointMate] } exact := { evaluation' := { app := fun X => ε_ _ _ naturality := fun X Y f => by dsimp rw [Category.comp_id, Functor.map_inv, ← id_tensor_comp_tensor_id, Category.assoc, id_tensorHom, tensorHom_id, rightAdjointMate_comp_evaluation, ← MonoidalCategory.whiskerLeft_comp_assoc, IsIso.hom_inv_id, MonoidalCategory.whiskerLeft_id, Category.id_comp] } coevaluation' := { app := fun X => η_ _ _ naturality := fun X Y f => by dsimp rw [Functor.map_inv, Category.id_comp, ← id_tensor_comp_tensor_id, id_tensorHom, tensorHom_id, ← Category.assoc, coevaluation_comp_rightAdjointMate, Category.assoc, ← comp_whiskerRight, IsIso.inv_hom_id, id_whiskerRight, Category.comp_id] } } instance rightRigidFunctorCategory [RightRigidCategory D] : RightRigidCategory (C ⥤ D) where instance functorHasLeftDual [LeftRigidCategory D] (F : C ⥤ D) : HasLeftDual F where leftDual := { obj := fun X => ᘁ(F.obj X) map := fun f => ᘁ(F.map (inv f)) map_comp := fun f g => by simp [comp_leftAdjointMate] } exact := { evaluation' := { app := fun X => ε_ _ _ naturality := fun X Y f => by dsimp simp [tensorHom_def, leftAdjointMate_comp_evaluation] } coevaluation' := { app := fun X => η_ _ _ naturality := fun X Y f => by dsimp simp [tensorHom_def, coevaluation_comp_leftAdjointMate_assoc] } } instance leftRigidFunctorCategory [LeftRigidCategory D] : LeftRigidCategory (C ⥤ D) where instance rigidFunctorCategory [RigidCategory D] : RigidCategory (C ⥤ D) where end CategoryTheory.Monoidal
CategoryTheory\Monoidal\Rigid\OfEquivalence.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.Monoidal.Rigid.Basic /-! # Transport rigid structures over a monoidal equivalence. -/ noncomputable section namespace CategoryTheory open MonoidalCategory variable {C D : Type*} [Category C] [Category D] [MonoidalCategory C] [MonoidalCategory D] variable (F : MonoidalFunctor C D) /-- Given candidate data for an exact pairing, which is sent by a faithful monoidal functor to an exact pairing, the equations holds automatically. -/ def exactPairingOfFaithful [F.Faithful] {X Y : C} (eval : Y ⊗ X ⟶ 𝟙_ C) (coeval : 𝟙_ C ⟶ X ⊗ Y) [ExactPairing (F.obj X) (F.obj Y)] (map_eval : F.map eval = inv (F.μ _ _) ≫ ε_ _ _ ≫ F.ε) (map_coeval : F.map coeval = inv F.ε ≫ η_ _ _ ≫ F.μ _ _) : ExactPairing X Y where evaluation' := eval coevaluation' := coeval evaluation_coevaluation' := F.toFunctor.map_injective <| by simp [map_eval, map_coeval, MonoidalFunctor.map_whiskerLeft, MonoidalFunctor.map_whiskerRight] coevaluation_evaluation' := F.toFunctor.map_injective <| by simp [map_eval, map_coeval, MonoidalFunctor.map_whiskerLeft, MonoidalFunctor.map_whiskerRight] /-- Given a pair of objects which are sent by a fully faithful functor to a pair of objects with an exact pairing, we get an exact pairing. -/ def exactPairingOfFullyFaithful [F.Full] [F.Faithful] (X Y : C) [ExactPairing (F.obj X) (F.obj Y)] : ExactPairing X Y := exactPairingOfFaithful F (F.toFunctor.preimage (inv (F.μ _ _) ≫ ε_ _ _ ≫ F.ε)) (F.toFunctor.preimage (inv F.ε ≫ η_ _ _ ≫ F.μ _ _)) (by simp) (by simp) variable {F} variable {G : D ⥤ C} (adj : F.toFunctor ⊣ G) [F.IsEquivalence] /-- Pull back a left dual along an equivalence. -/ def hasLeftDualOfEquivalence (X : C) [HasLeftDual (F.obj X)] : HasLeftDual X where leftDual := G.obj (ᘁ(F.obj X)) exact := by -- Porting note: in Lean3, `apply exactPairingOfFullyFaithful F _ _` automatically -- created the goals for `ExactPairing` type class refine @exactPairingOfFullyFaithful _ _ _ _ _ _ F _ _ _ _ ?_ refine @exactPairingCongrLeft _ _ _ _ _ _ ?_ (adj.toEquivalence.counitIso.app _) dsimp infer_instance /-- Pull back a right dual along an equivalence. -/ def hasRightDualOfEquivalence (X : C) [HasRightDual (F.obj X)] : HasRightDual X where rightDual := G.obj ((F.obj X)ᘁ) exact := by refine @exactPairingOfFullyFaithful _ _ _ _ _ _ F _ _ _ _ ?_ refine @exactPairingCongrRight _ _ _ _ _ _ ?_ (adj.toEquivalence.counitIso.app _) dsimp infer_instance /-- Pull back a left rigid structure along an equivalence. -/ def leftRigidCategoryOfEquivalence [LeftRigidCategory D] : LeftRigidCategory C where leftDual X := hasLeftDualOfEquivalence adj X /-- Pull back a right rigid structure along an equivalence. -/ def rightRigidCategoryOfEquivalence [RightRigidCategory D] : RightRigidCategory C where rightDual X := hasRightDualOfEquivalence adj X /-- Pull back a rigid structure along an equivalence. -/ def rigidCategoryOfEquivalence [RigidCategory D] : RigidCategory C where leftDual X := hasLeftDualOfEquivalence adj X rightDual X := hasRightDualOfEquivalence adj X end CategoryTheory
CategoryTheory\Monoidal\Types\Basic.lean
/- Copyright (c) 2018 Michael Jendrusch. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Michael Jendrusch, Scott Morrison -/ import Mathlib.CategoryTheory.Monoidal.Functor import Mathlib.CategoryTheory.ChosenFiniteProducts import Mathlib.CategoryTheory.Limits.Shapes.Types import Mathlib.Logic.Equiv.Fin /-! # The category of types is a monoidal category -/ open CategoryTheory Limits MonoidalCategory open Tactic universe v u namespace CategoryTheory instance typesChosenFiniteProducts : ChosenFiniteProducts (Type u) where product := Types.binaryProductLimitCone terminal := Types.terminalLimitCone @[simp] theorem tensor_apply {W X Y Z : Type u} (f : W ⟶ X) (g : Y ⟶ Z) (p : W ⊗ Y) : (f ⊗ g) p = (f p.1, g p.2) := rfl @[simp] theorem whiskerLeft_apply (X : Type u) {Y Z : Type u} (f : Y ⟶ Z) (p : X ⊗ Y) : (X ◁ f) p = (p.1, f p.2) := rfl @[simp] theorem whiskerRight_apply {Y Z : Type u} (f : Y ⟶ Z) (X : Type u) (p : Y ⊗ X) : (f ▷ X) p = (f p.1, p.2) := rfl @[simp] theorem leftUnitor_hom_apply {X : Type u} {x : X} {p : PUnit} : ((λ_ X).hom : 𝟙_ (Type u) ⊗ X → X) (p, x) = x := rfl @[simp] theorem leftUnitor_inv_apply {X : Type u} {x : X} : ((λ_ X).inv : X ⟶ 𝟙_ (Type u) ⊗ X) x = (PUnit.unit, x) := rfl @[simp] theorem rightUnitor_hom_apply {X : Type u} {x : X} {p : PUnit} : ((ρ_ X).hom : X ⊗ 𝟙_ (Type u) → X) (x, p) = x := rfl @[simp] theorem rightUnitor_inv_apply {X : Type u} {x : X} : ((ρ_ X).inv : X ⟶ X ⊗ 𝟙_ (Type u)) x = (x, PUnit.unit) := rfl @[simp] theorem associator_hom_apply {X Y Z : Type u} {x : X} {y : Y} {z : Z} : ((α_ X Y Z).hom : (X ⊗ Y) ⊗ Z → X ⊗ Y ⊗ Z) ((x, y), z) = (x, (y, z)) := rfl @[simp] theorem associator_inv_apply {X Y Z : Type u} {x : X} {y : Y} {z : Z} : ((α_ X Y Z).inv : X ⊗ Y ⊗ Z → (X ⊗ Y) ⊗ Z) (x, (y, z)) = ((x, y), z) := rfl @[simp] theorem associator_hom_apply_1 {X Y Z : Type u} {x} : (((α_ X Y Z).hom : (X ⊗ Y) ⊗ Z → X ⊗ Y ⊗ Z) x).1 = x.1.1 := rfl @[simp] theorem associator_hom_apply_2_1 {X Y Z : Type u} {x} : (((α_ X Y Z).hom : (X ⊗ Y) ⊗ Z → X ⊗ Y ⊗ Z) x).2.1 = x.1.2 := rfl @[simp] theorem associator_hom_apply_2_2 {X Y Z : Type u} {x} : (((α_ X Y Z).hom : (X ⊗ Y) ⊗ Z → X ⊗ Y ⊗ Z) x).2.2 = x.2 := rfl @[simp] theorem associator_inv_apply_1_1 {X Y Z : Type u} {x} : (((α_ X Y Z).inv : X ⊗ Y ⊗ Z → (X ⊗ Y) ⊗ Z) x).1.1 = x.1 := rfl @[simp] theorem associator_inv_apply_1_2 {X Y Z : Type u} {x} : (((α_ X Y Z).inv : X ⊗ Y ⊗ Z → (X ⊗ Y) ⊗ Z) x).1.2 = x.2.1 := rfl @[simp] theorem associator_inv_apply_2 {X Y Z : Type u} {x} : (((α_ X Y Z).inv : X ⊗ Y ⊗ Z → (X ⊗ Y) ⊗ Z) x).2 = x.2.2 := rfl -- We don't yet have an API for tensor products indexed by finite ordered types, -- but it would be nice to state how monoidal functors preserve these. /-- If `F` is a monoidal functor out of `Type`, it takes the (n+1)st cartesian power of a type to the image of that type, tensored with the image of the nth cartesian power. -/ noncomputable def MonoidalFunctor.mapPi {C : Type*} [Category C] [MonoidalCategory C] (F : MonoidalFunctor (Type _) C) (n : ℕ) (β : Type*) : F.obj (Fin (n + 1) → β) ≅ F.obj β ⊗ F.obj (Fin n → β) := Functor.mapIso _ (Equiv.piFinSucc n β).toIso ≪≫ (asIso (F.μ β (Fin n → β))).symm end CategoryTheory
CategoryTheory\Monoidal\Types\Coyoneda.lean
/- Copyright (c) 2018 Michael Jendrusch. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Michael Jendrusch, Scott Morrison -/ import Mathlib.CategoryTheory.Monoidal.Types.Basic import Mathlib.CategoryTheory.Monoidal.CoherenceLemmas /-! # `(𝟙_ C ⟶ -)` is a lax monoidal functor to `Type` -/ open CategoryTheory open CategoryTheory.Limits open Tactic universe v u namespace CategoryTheory open Opposite open MonoidalCategory /-- `(𝟙_ C ⟶ -)` is a lax monoidal functor to `Type`. -/ def coyonedaTensorUnit (C : Type u) [Category.{v} C] [MonoidalCategory C] : LaxMonoidalFunctor C (Type v) := .ofTensorHom (F := coyoneda.obj (op (𝟙_ C))) (ε := fun _p => 𝟙 _) (μ := fun X Y p => (λ_ (𝟙_ C)).inv ≫ (p.1 ⊗ p.2)) (μ_natural := by aesop_cat) (associativity := fun X Y Z => by ext ⟨⟨f, g⟩, h⟩; dsimp at f g h dsimp; simp only [Iso.cancel_iso_inv_left, Category.assoc] conv_lhs => rw [← Category.id_comp h, tensor_comp, Category.assoc, associator_naturality, ← Category.assoc, unitors_inv_equal, tensorHom_id, triangle_assoc_comp_right_inv] conv_rhs => rw [← Category.id_comp f, tensor_comp] simp) (left_unitality := by intros ext ⟨⟨⟩, f⟩; dsimp at f dsimp simp) (right_unitality := fun X => by ext ⟨f, ⟨⟩⟩; dsimp at f dsimp simp [unitors_inv_equal]) end CategoryTheory
CategoryTheory\Monoidal\Types\Symmetric.lean
/- Copyright (c) 2018 Michael Jendrusch. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Michael Jendrusch, Scott Morrison -/ import Mathlib.CategoryTheory.Monoidal.OfChosenFiniteProducts.Symmetric import Mathlib.CategoryTheory.Monoidal.Types.Basic /-! # The category of types is a symmetric monoidal category -/ open CategoryTheory Limits universe v u namespace CategoryTheory open MonoidalCategory instance typesSymmetric : SymmetricCategory.{u} (Type u) := symmetricOfChosenFiniteProducts Types.terminalLimitCone Types.binaryProductLimitCone @[simp] theorem braiding_hom_apply {X Y : Type u} {x : X} {y : Y} : ((β_ X Y).hom : X ⊗ Y → Y ⊗ X) (x, y) = (y, x) := rfl @[simp] theorem braiding_inv_apply {X Y : Type u} {x : X} {y : Y} : ((β_ X Y).inv : Y ⊗ X → X ⊗ Y) (y, x) = (x, y) := rfl end CategoryTheory
CategoryTheory\MorphismProperty\Basic.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.CategoryTheory.Comma.Arrow import Mathlib.CategoryTheory.Pi.Basic import Mathlib.Order.CompleteBooleanAlgebra /-! # Properties of morphisms We provide the basic framework for talking about properties of morphisms. The following meta-property is defined * `RespectsIso`: `P` respects isomorphisms if `P f → P (e ≫ f)` and `P f → P (f ≫ e)`, where `e` is an isomorphism. -/ universe w v v' u u' open CategoryTheory Opposite noncomputable section namespace CategoryTheory variable (C : Type u) [Category.{v} C] {D : Type*} [Category D] /-- A `MorphismProperty C` is a class of morphisms between objects in `C`. -/ def MorphismProperty := ∀ ⦃X Y : C⦄ (_ : X ⟶ Y), Prop instance : CompleteBooleanAlgebra (MorphismProperty C) where le P₁ P₂ := ∀ ⦃X Y : C⦄ (f : X ⟶ Y), P₁ f → P₂ f __ := inferInstanceAs (CompleteBooleanAlgebra (∀ ⦃X Y : C⦄ (_ : X ⟶ Y), Prop)) lemma MorphismProperty.le_def {P Q : MorphismProperty C} : P ≤ Q ↔ ∀ {X Y : C} (f : X ⟶ Y), P f → Q f := Iff.rfl instance : Inhabited (MorphismProperty C) := ⟨⊤⟩ lemma MorphismProperty.top_eq : (⊤ : MorphismProperty C) = fun _ _ _ => True := rfl variable {C} namespace MorphismProperty @[ext] lemma ext (W W' : MorphismProperty C) (h : ∀ ⦃X Y : C⦄ (f : X ⟶ Y), W f ↔ W' f) : W = W' := by funext X Y f rw [h] @[simp] lemma top_apply {X Y : C} (f : X ⟶ Y) : (⊤ : MorphismProperty C) f := by simp only [top_eq] /-- The morphism property in `Cᵒᵖ` associated to a morphism property in `C` -/ @[simp] def op (P : MorphismProperty C) : MorphismProperty Cᵒᵖ := fun _ _ f => P f.unop /-- The morphism property in `C` associated to a morphism property in `Cᵒᵖ` -/ @[simp] def unop (P : MorphismProperty Cᵒᵖ) : MorphismProperty C := fun _ _ f => P f.op theorem unop_op (P : MorphismProperty C) : P.op.unop = P := rfl theorem op_unop (P : MorphismProperty Cᵒᵖ) : P.unop.op = P := rfl /-- The inverse image of a `MorphismProperty D` by a functor `C ⥤ D` -/ def inverseImage (P : MorphismProperty D) (F : C ⥤ D) : MorphismProperty C := fun _ _ f => P (F.map f) @[simp] lemma inverseImage_iff (P : MorphismProperty D) (F : C ⥤ D) {X Y : C} (f : X ⟶ Y) : P.inverseImage F f ↔ P (F.map f) := by rfl /-- The image (up to isomorphisms) of a `MorphismProperty C` by a functor `C ⥤ D` -/ def map (P : MorphismProperty C) (F : C ⥤ D) : MorphismProperty D := fun _ _ f => ∃ (X' Y' : C) (f' : X' ⟶ Y') (_ : P f'), Nonempty (Arrow.mk (F.map f') ≅ Arrow.mk f) lemma map_mem_map (P : MorphismProperty C) (F : C ⥤ D) {X Y : C} (f : X ⟶ Y) (hf : P f) : (P.map F) (F.map f) := ⟨X, Y, f, hf, ⟨Iso.refl _⟩⟩ lemma monotone_map (F : C ⥤ D) : Monotone (map · F) := by intro P Q h X Y f ⟨X', Y', f', hf', ⟨e⟩⟩ exact ⟨X', Y', f', h _ hf', ⟨e⟩⟩ /-- A morphism property `RespectsIso` if it still holds when composed with an isomorphism -/ class RespectsIso (P : MorphismProperty C) : Prop where precomp {X Y Z} (e : X ≅ Y) (f : Y ⟶ Z) (hf : P f) : P (e.hom ≫ f) postcomp {X Y Z} (e : Y ≅ Z) (f : X ⟶ Y) (hf : P f) : P (f ≫ e.hom) instance RespectsIso.op (P : MorphismProperty C) [h : RespectsIso P] : RespectsIso P.op := ⟨fun e f hf => h.2 e.unop f.unop hf, fun e f hf => h.1 e.unop f.unop hf⟩ instance RespectsIso.unop (P : MorphismProperty Cᵒᵖ) [h : RespectsIso P] : RespectsIso P.unop := ⟨fun e f hf => h.2 e.op f.op hf, fun e f hf => h.1 e.op f.op hf⟩ /-- The intersection of two isomorphism respecting morphism properties respects isomorphisms. -/ instance RespectsIso.inf (P Q : MorphismProperty C) [RespectsIso P] [RespectsIso Q] : RespectsIso (P ⊓ Q) where precomp e f hf := ⟨RespectsIso.precomp e f hf.left, RespectsIso.precomp e f hf.right⟩ postcomp e f hf := ⟨RespectsIso.postcomp e f hf.left, RespectsIso.postcomp e f hf.right⟩ /-- The closure by isomorphisms of a `MorphismProperty` -/ def isoClosure (P : MorphismProperty C) : MorphismProperty C := fun _ _ f => ∃ (Y₁ Y₂ : C) (f' : Y₁ ⟶ Y₂) (_ : P f'), Nonempty (Arrow.mk f' ≅ Arrow.mk f) lemma le_isoClosure (P : MorphismProperty C) : P ≤ P.isoClosure := fun _ _ f hf => ⟨_, _, f, hf, ⟨Iso.refl _⟩⟩ instance isoClosure_respectsIso (P : MorphismProperty C) : RespectsIso P.isoClosure where precomp := fun e f ⟨_, _, f', hf', ⟨iso⟩⟩ => ⟨_, _, f', hf', ⟨Arrow.isoMk (asIso iso.hom.left ≪≫ e.symm) (asIso iso.hom.right) (by simp)⟩⟩ postcomp := fun e f ⟨_, _, f', hf', ⟨iso⟩⟩ => ⟨_, _, f', hf', ⟨Arrow.isoMk (asIso iso.hom.left) (asIso iso.hom.right ≪≫ e) (by simp)⟩⟩ lemma monotone_isoClosure : Monotone (isoClosure (C := C)) := by intro P Q h X Y f ⟨X', Y', f', hf', ⟨e⟩⟩ exact ⟨X', Y', f', h _ hf', ⟨e⟩⟩ theorem cancel_left_of_respectsIso (P : MorphismProperty C) [hP : RespectsIso P] {X Y Z : C} (f : X ⟶ Y) (g : Y ⟶ Z) [IsIso f] : P (f ≫ g) ↔ P g := ⟨fun h => by simpa using hP.1 (asIso f).symm (f ≫ g) h, hP.1 (asIso f) g⟩ theorem cancel_right_of_respectsIso (P : MorphismProperty C) [hP : RespectsIso P] {X Y Z : C} (f : X ⟶ Y) (g : Y ⟶ Z) [IsIso g] : P (f ≫ g) ↔ P f := ⟨fun h => by simpa using hP.2 (asIso g).symm (f ≫ g) h, hP.2 (asIso g) f⟩ theorem arrow_iso_iff (P : MorphismProperty C) [RespectsIso P] {f g : Arrow C} (e : f ≅ g) : P f.hom ↔ P g.hom := by simp [← Arrow.inv_left_hom_right e.hom, cancel_left_of_respectsIso, cancel_right_of_respectsIso] theorem arrow_mk_iso_iff (P : MorphismProperty C) [RespectsIso P] {W X Y Z : C} {f : W ⟶ X} {g : Y ⟶ Z} (e : Arrow.mk f ≅ Arrow.mk g) : P f ↔ P g := P.arrow_iso_iff e theorem RespectsIso.of_respects_arrow_iso (P : MorphismProperty C) (hP : ∀ (f g : Arrow C) (_ : f ≅ g) (_ : P f.hom), P g.hom) : RespectsIso P := by constructor · intro X Y Z e f hf refine hP (Arrow.mk f) (Arrow.mk (e.hom ≫ f)) (Arrow.isoMk e.symm (Iso.refl _) ?_) hf dsimp simp only [Iso.inv_hom_id_assoc, Category.comp_id] · intro X Y Z e f hf refine hP (Arrow.mk f) (Arrow.mk (f ≫ e.hom)) (Arrow.isoMk (Iso.refl _) e ?_) hf dsimp simp only [Category.id_comp] lemma isoClosure_eq_iff (P : MorphismProperty C) : P.isoClosure = P ↔ P.RespectsIso := by refine ⟨(· ▸ P.isoClosure_respectsIso), fun hP ↦ le_antisymm ?_ (P.le_isoClosure)⟩ intro X Y f ⟨X', Y', f', hf', ⟨e⟩⟩ exact (P.arrow_mk_iso_iff e).1 hf' lemma isoClosure_eq_self (P : MorphismProperty C) [P.RespectsIso] : P.isoClosure = P := by rwa [isoClosure_eq_iff] @[simp] lemma isoClosure_isoClosure (P : MorphismProperty C) : P.isoClosure.isoClosure = P.isoClosure := P.isoClosure.isoClosure_eq_self lemma isoClosure_le_iff (P Q : MorphismProperty C) [Q.RespectsIso] : P.isoClosure ≤ Q ↔ P ≤ Q := by constructor · exact P.le_isoClosure.trans · intro h exact (monotone_isoClosure h).trans (by rw [Q.isoClosure_eq_self]) instance map_respectsIso (P : MorphismProperty C) (F : C ⥤ D) : (P.map F).RespectsIso := by apply RespectsIso.of_respects_arrow_iso intro f g e ⟨X', Y', f', hf', ⟨e'⟩⟩ exact ⟨X', Y', f', hf', ⟨e' ≪≫ e⟩⟩ lemma map_le_iff (P : MorphismProperty C) {F : C ⥤ D} (Q : MorphismProperty D) [RespectsIso Q] : P.map F ≤ Q ↔ P ≤ Q.inverseImage F := by constructor · intro h X Y f hf exact h (F.map f) (map_mem_map P F f hf) · intro h X Y f ⟨X', Y', f', hf', ⟨e⟩⟩ exact (Q.arrow_mk_iso_iff e).1 (h _ hf') @[simp] lemma map_isoClosure (P : MorphismProperty C) (F : C ⥤ D) : P.isoClosure.map F = P.map F := by apply le_antisymm · rw [map_le_iff] intro X Y f ⟨X', Y', f', hf', ⟨e⟩⟩ exact ⟨_, _, f', hf', ⟨F.mapArrow.mapIso e⟩⟩ · exact monotone_map _ (le_isoClosure P) lemma map_id_eq_isoClosure (P : MorphismProperty C) : P.map (𝟭 _) = P.isoClosure := by apply le_antisymm · rw [map_le_iff] intro X Y f hf exact P.le_isoClosure _ hf · intro X Y f hf exact hf lemma map_id (P : MorphismProperty C) [RespectsIso P] : P.map (𝟭 _) = P := by rw [map_id_eq_isoClosure, P.isoClosure_eq_self] @[simp] lemma map_map (P : MorphismProperty C) (F : C ⥤ D) {E : Type*} [Category E] (G : D ⥤ E) : (P.map F).map G = P.map (F ⋙ G) := by apply le_antisymm · rw [map_le_iff] intro X Y f ⟨X', Y', f', hf', ⟨e⟩⟩ exact ⟨X', Y', f', hf', ⟨G.mapArrow.mapIso e⟩⟩ · rw [map_le_iff] intro X Y f hf exact map_mem_map _ _ _ (map_mem_map _ _ _ hf) instance RespectsIso.inverseImage (P : MorphismProperty D) [RespectsIso P] (F : C ⥤ D) : RespectsIso (P.inverseImage F) := by constructor all_goals intro X Y Z e f hf simpa [MorphismProperty.inverseImage, cancel_left_of_respectsIso, cancel_right_of_respectsIso] using hf lemma map_eq_of_iso (P : MorphismProperty C) {F G : C ⥤ D} (e : F ≅ G) : P.map F = P.map G := by revert F G e suffices ∀ {F G : C ⥤ D} (_ : F ≅ G), P.map F ≤ P.map G from fun F G e => le_antisymm (this e) (this e.symm) intro F G e X Y f ⟨X', Y', f', hf', ⟨e'⟩⟩ exact ⟨X', Y', f', hf', ⟨((Functor.mapArrowFunctor _ _).mapIso e.symm).app (Arrow.mk f') ≪≫ e'⟩⟩ lemma map_inverseImage_le (P : MorphismProperty D) (F : C ⥤ D) : (P.inverseImage F).map F ≤ P.isoClosure := fun _ _ _ ⟨_, _, f, hf, ⟨e⟩⟩ => ⟨_, _, F.map f, hf, ⟨e⟩⟩ lemma inverseImage_equivalence_inverse_eq_map_functor (P : MorphismProperty D) [RespectsIso P] (E : C ≌ D) : P.inverseImage E.functor = P.map E.inverse := by apply le_antisymm · intro X Y f hf refine ⟨_, _, _, hf, ⟨?_⟩⟩ exact ((Functor.mapArrowFunctor _ _).mapIso E.unitIso.symm).app (Arrow.mk f) · rw [map_le_iff] intro X Y f hf exact (P.arrow_mk_iso_iff (((Functor.mapArrowFunctor _ _).mapIso E.counitIso).app (Arrow.mk f))).2 hf lemma inverseImage_equivalence_functor_eq_map_inverse (Q : MorphismProperty C) [RespectsIso Q] (E : C ≌ D) : Q.inverseImage E.inverse = Q.map E.functor := inverseImage_equivalence_inverse_eq_map_functor Q E.symm lemma map_inverseImage_eq_of_isEquivalence (P : MorphismProperty D) [P.RespectsIso] (F : C ⥤ D) [F.IsEquivalence] : (P.inverseImage F).map F = P := by erw [P.inverseImage_equivalence_inverse_eq_map_functor F.asEquivalence, map_map, P.map_eq_of_iso F.asEquivalence.counitIso, map_id] lemma inverseImage_map_eq_of_isEquivalence (P : MorphismProperty C) [P.RespectsIso] (F : C ⥤ D) [F.IsEquivalence] : (P.map F).inverseImage F = P := by erw [((P.map F).inverseImage_equivalence_inverse_eq_map_functor (F.asEquivalence)), map_map, P.map_eq_of_iso F.asEquivalence.unitIso.symm, map_id] variable (C) /-- The `MorphismProperty C` satisfied by isomorphisms in `C`. -/ def isomorphisms : MorphismProperty C := fun _ _ f => IsIso f /-- The `MorphismProperty C` satisfied by monomorphisms in `C`. -/ def monomorphisms : MorphismProperty C := fun _ _ f => Mono f /-- The `MorphismProperty C` satisfied by epimorphisms in `C`. -/ def epimorphisms : MorphismProperty C := fun _ _ f => Epi f section variable {C} variable {X Y : C} (f : X ⟶ Y) @[simp] theorem isomorphisms.iff : (isomorphisms C) f ↔ IsIso f := by rfl @[simp] theorem monomorphisms.iff : (monomorphisms C) f ↔ Mono f := by rfl @[simp] theorem epimorphisms.iff : (epimorphisms C) f ↔ Epi f := by rfl theorem isomorphisms.infer_property [hf : IsIso f] : (isomorphisms C) f := hf theorem monomorphisms.infer_property [hf : Mono f] : (monomorphisms C) f := hf theorem epimorphisms.infer_property [hf : Epi f] : (epimorphisms C) f := hf end instance RespectsIso.monomorphisms : RespectsIso (monomorphisms C) := by constructor <;> · intro X Y Z e f simp only [monomorphisms.iff] intro apply mono_comp instance RespectsIso.epimorphisms : RespectsIso (epimorphisms C) := by constructor <;> · intro X Y Z e f simp only [epimorphisms.iff] intro apply epi_comp instance RespectsIso.isomorphisms : RespectsIso (isomorphisms C) := by constructor <;> · intro X Y Z e f simp only [isomorphisms.iff] intro infer_instance @[deprecated (since := "2024-07-02")] alias RespectsIso.cancel_left_isIso := cancel_left_of_respectsIso @[deprecated (since := "2024-07-02")] alias RespectsIso.cancel_right_isIso := cancel_right_of_respectsIso @[deprecated (since := "2024-07-02")] alias RespectsIso.arrow_iso_iff := arrow_iso_iff @[deprecated (since := "2024-07-02")] alias RespectsIso.arrow_mk_iso_iff := arrow_mk_iso_iff @[deprecated (since := "2024-07-02")] alias RespectsIso.isoClosure_eq := isoClosure_eq_self /-- If `W₁` and `W₂` are morphism properties on two categories `C₁` and `C₂`, this is the induced morphism property on `C₁ × C₂`. -/ def prod {C₁ C₂ : Type*} [Category C₁] [Category C₂] (W₁ : MorphismProperty C₁) (W₂ : MorphismProperty C₂) : MorphismProperty (C₁ × C₂) := fun _ _ f => W₁ f.1 ∧ W₂ f.2 /-- If `W j` are morphism properties on categories `C j` for all `j`, this is the induced morphism property on the category `∀ j, C j`. -/ def pi {J : Type w} {C : J → Type u} [∀ j, Category.{v} (C j)] (W : ∀ j, MorphismProperty (C j)) : MorphismProperty (∀ j, C j) := fun _ _ f => ∀ j, (W j) (f j) variable {C} /-- The morphism property on `J ⥤ C` which is defined objectwise from `W : MorphismProperty C`. -/ def functorCategory (W : MorphismProperty C) (J : Type*) [Category J] : MorphismProperty (J ⥤ C) := fun _ _ f => ∀ (j : J), W (f.app j) /-- Given `W : MorphismProperty C`, this is the morphism property on `Arrow C` of morphisms whose left and right parts are in `W`. -/ def arrow (W : MorphismProperty C) : MorphismProperty (Arrow C) := fun _ _ f => W f.left ∧ W f.right end MorphismProperty namespace NatTrans lemma isIso_app_iff_of_iso {F G : C ⥤ D} (α : F ⟶ G) {X Y : C} (e : X ≅ Y) : IsIso (α.app X) ↔ IsIso (α.app Y) := (MorphismProperty.isomorphisms D).arrow_mk_iso_iff (Arrow.isoMk (F.mapIso e) (G.mapIso e) (by simp)) end NatTrans end CategoryTheory
CategoryTheory\MorphismProperty\Composition.lean
/- Copyright (c) 2022 Andrew Yang. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Andrew Yang, Joël Riou -/ import Mathlib.CategoryTheory.MorphismProperty.Basic /-! # Compatibilities of properties of morphisms with respect to composition Given `P : MorphismProperty C`, we define the predicate `P.IsStableUnderComposition` which means that `P f → P g → P (f ≫ g)`. We also introduce the type classes `W.ContainsIdentities`, `W.IsMultiplicative`, and `W.HasTwoOutOfThreeProperty`. -/ universe w v v' u u' namespace CategoryTheory namespace MorphismProperty variable {C : Type u} [Category.{v} C] {D : Type u'} [Category.{v'} D] /-- Typeclass expressing that a morphism property contain identities. -/ class ContainsIdentities (W : MorphismProperty C) : Prop := /-- for all `X : C`, the identity of `X` satisfies the morphism property -/ id_mem : ∀ (X : C), W (𝟙 X) lemma id_mem (W : MorphismProperty C) [W.ContainsIdentities] (X : C) : W (𝟙 X) := ContainsIdentities.id_mem X namespace ContainsIdentities instance op (W : MorphismProperty C) [W.ContainsIdentities] : W.op.ContainsIdentities := ⟨fun X => W.id_mem X.unop⟩ instance unop (W : MorphismProperty Cᵒᵖ) [W.ContainsIdentities] : W.unop.ContainsIdentities := ⟨fun X => W.id_mem (Opposite.op X)⟩ lemma of_op (W : MorphismProperty C) [W.op.ContainsIdentities] : W.ContainsIdentities := (inferInstance : W.op.unop.ContainsIdentities) lemma of_unop (W : MorphismProperty Cᵒᵖ) [W.unop.ContainsIdentities] : W.ContainsIdentities := (inferInstance : W.unop.op.ContainsIdentities) instance inverseImage {P : MorphismProperty D} [P.ContainsIdentities] (F : C ⥤ D) : (P.inverseImage F).ContainsIdentities where id_mem X := by simpa only [← F.map_id] using P.id_mem (F.obj X) end ContainsIdentities instance Prod.containsIdentities {C₁ C₂ : Type*} [Category C₁] [Category C₂] (W₁ : MorphismProperty C₁) (W₂ : MorphismProperty C₂) [W₁.ContainsIdentities] [W₂.ContainsIdentities] : (prod W₁ W₂).ContainsIdentities := ⟨fun _ => ⟨W₁.id_mem _, W₂.id_mem _⟩⟩ instance Pi.containsIdentities {J : Type w} {C : J → Type u} [∀ j, Category.{v} (C j)] (W : ∀ j, MorphismProperty (C j)) [∀ j, (W j).ContainsIdentities] : (pi W).ContainsIdentities := ⟨fun _ _ => MorphismProperty.id_mem _ _⟩ /-- A morphism property satisfies `IsStableUnderComposition` if the composition of two such morphisms still falls in the class. -/ class IsStableUnderComposition (P : MorphismProperty C) : Prop := comp_mem {X Y Z} (f : X ⟶ Y) (g : Y ⟶ Z) : P f → P g → P (f ≫ g) lemma comp_mem (W : MorphismProperty C) [W.IsStableUnderComposition] {X Y Z : C} (f : X ⟶ Y) (g : Y ⟶ Z) (hf : W f) (hg : W g) : W (f ≫ g) := IsStableUnderComposition.comp_mem f g hf hg instance IsStableUnderComposition.op {P : MorphismProperty C} [P.IsStableUnderComposition] : P.op.IsStableUnderComposition where comp_mem f g hf hg := P.comp_mem g.unop f.unop hg hf instance IsStableUnderComposition.unop {P : MorphismProperty Cᵒᵖ} [P.IsStableUnderComposition] : P.unop.IsStableUnderComposition where comp_mem f g hf hg := P.comp_mem g.op f.op hg hf /-- A morphism property is `StableUnderInverse` if the inverse of a morphism satisfying the property still falls in the class. -/ def StableUnderInverse (P : MorphismProperty C) : Prop := ∀ ⦃X Y⦄ (e : X ≅ Y), P e.hom → P e.inv theorem StableUnderInverse.op {P : MorphismProperty C} (h : StableUnderInverse P) : StableUnderInverse P.op := fun _ _ e he => h e.unop he theorem StableUnderInverse.unop {P : MorphismProperty Cᵒᵖ} (h : StableUnderInverse P) : StableUnderInverse P.unop := fun _ _ e he => h e.op he theorem respectsIso_of_isStableUnderComposition {P : MorphismProperty C} [P.IsStableUnderComposition] (hP : isomorphisms C ≤ P) : RespectsIso P := ⟨fun _ _ hf => P.comp_mem _ _ (hP _ (isomorphisms.infer_property _)) hf, fun _ _ hf => P.comp_mem _ _ hf (hP _ (isomorphisms.infer_property _))⟩ instance IsStableUnderComposition.inverseImage {P : MorphismProperty D} [P.IsStableUnderComposition] (F : C ⥤ D) : (P.inverseImage F).IsStableUnderComposition where comp_mem f g hf hg := by simpa only [← F.map_comp] using P.comp_mem _ _ hf hg /-- Given `app : Π X, F₁.obj X ⟶ F₂.obj X` where `F₁` and `F₂` are two functors, this is the `morphism_property C` satisfied by the morphisms in `C` with respect to whom `app` is natural. -/ @[simp] def naturalityProperty {F₁ F₂ : C ⥤ D} (app : ∀ X, F₁.obj X ⟶ F₂.obj X) : MorphismProperty C := fun X Y f => F₁.map f ≫ app Y = app X ≫ F₂.map f namespace naturalityProperty instance isStableUnderComposition {F₁ F₂ : C ⥤ D} (app : ∀ X, F₁.obj X ⟶ F₂.obj X) : (naturalityProperty app).IsStableUnderComposition where comp_mem f g hf hg := by simp only [naturalityProperty] at hf hg ⊢ simp only [Functor.map_comp, Category.assoc, hg] slice_lhs 1 2 => rw [hf] rw [Category.assoc] theorem stableUnderInverse {F₁ F₂ : C ⥤ D} (app : ∀ X, F₁.obj X ⟶ F₂.obj X) : (naturalityProperty app).StableUnderInverse := fun X Y e he => by simp only [naturalityProperty] at he ⊢ rw [← cancel_epi (F₁.map e.hom)] slice_rhs 1 2 => rw [he] simp only [Category.assoc, ← F₁.map_comp_assoc, ← F₂.map_comp, e.hom_inv_id, Functor.map_id, Category.id_comp, Category.comp_id] end naturalityProperty /-- A morphism property is multiplicative if it contains identities and is stable by composition. -/ class IsMultiplicative (W : MorphismProperty C) extends W.ContainsIdentities, W.IsStableUnderComposition : Prop := namespace IsMultiplicative instance op (W : MorphismProperty C) [IsMultiplicative W] : IsMultiplicative W.op where comp_mem f g hf hg := W.comp_mem g.unop f.unop hg hf instance unop (W : MorphismProperty Cᵒᵖ) [IsMultiplicative W] : IsMultiplicative W.unop where id_mem _ := W.id_mem _ comp_mem f g hf hg := W.comp_mem g.op f.op hg hf lemma of_op (W : MorphismProperty C) [IsMultiplicative W.op] : IsMultiplicative W := (inferInstance : IsMultiplicative W.op.unop) lemma of_unop (W : MorphismProperty Cᵒᵖ) [IsMultiplicative W.unop] : IsMultiplicative W := (inferInstance : IsMultiplicative W.unop.op) instance : (isomorphisms C).IsMultiplicative where id_mem _ := isomorphisms.infer_property _ comp_mem f g hf hg := by rw [isomorphisms.iff] at hf hg ⊢ infer_instance instance : (monomorphisms C).IsMultiplicative where id_mem _ := monomorphisms.infer_property _ comp_mem f g hf hg := by rw [monomorphisms.iff] at hf hg ⊢ apply mono_comp instance : (epimorphisms C).IsMultiplicative where id_mem _ := epimorphisms.infer_property _ comp_mem f g hf hg := by rw [epimorphisms.iff] at hf hg ⊢ apply epi_comp instance {P : MorphismProperty D} [P.IsMultiplicative] (F : C ⥤ D) : (P.inverseImage F).IsMultiplicative where end IsMultiplicative /-- A class of morphisms `W` has the two-out-of-three property if whenever two out of three maps in `f`, `g`, `f ≫ g` are in `W`, then the third map is also in `W`. -/ class HasTwoOutOfThreeProperty (W : MorphismProperty C) extends W.IsStableUnderComposition : Prop where of_postcomp {X Y Z : C} (f : X ⟶ Y) (g : Y ⟶ Z) : W g → W (f ≫ g) → W f of_precomp {X Y Z : C} (f : X ⟶ Y) (g : Y ⟶ Z) : W f → W (f ≫ g) → W g section variable (W : MorphismProperty C) [W.HasTwoOutOfThreeProperty] lemma of_postcomp {X Y Z : C} (f : X ⟶ Y) (g : Y ⟶ Z) (hg : W g) (hfg : W (f ≫ g)) : W f := HasTwoOutOfThreeProperty.of_postcomp f g hg hfg lemma of_precomp {X Y Z : C} (f : X ⟶ Y) (g : Y ⟶ Z) (hf : W f) (hfg : W (f ≫ g)) : W g := HasTwoOutOfThreeProperty.of_precomp f g hf hfg lemma postcomp_iff {X Y Z : C} (f : X ⟶ Y) (g : Y ⟶ Z) (hg : W g) : W (f ≫ g) ↔ W f := ⟨W.of_postcomp f g hg, fun hf => W.comp_mem _ _ hf hg⟩ lemma precomp_iff {X Y Z : C} (f : X ⟶ Y) (g : Y ⟶ Z) (hf : W f) : W (f ≫ g) ↔ W g := ⟨W.of_precomp f g hf, fun hg => W.comp_mem _ _ hf hg⟩ end instance : (isomorphisms C).HasTwoOutOfThreeProperty where of_postcomp f g := fun (hg : IsIso g) (hfg : IsIso (f ≫ g)) => by simpa using (inferInstance : IsIso ((f ≫ g) ≫ inv g)) of_precomp f g := fun (hf : IsIso f) (hfg : IsIso (f ≫ g)) => by simpa using (inferInstance : IsIso (inv f ≫ (f ≫ g))) instance (F : C ⥤ D) (W : MorphismProperty D) [W.HasTwoOutOfThreeProperty] : (W.inverseImage F).HasTwoOutOfThreeProperty where of_postcomp f g hg hfg := W.of_postcomp (F.map f) (F.map g) hg (by simpa using hfg) of_precomp f g hf hfg := W.of_precomp (F.map f) (F.map g) hf (by simpa using hfg) end MorphismProperty end CategoryTheory
CategoryTheory\MorphismProperty\Concrete.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.CategoryTheory.ConcreteCategory.Basic import Mathlib.CategoryTheory.MorphismProperty.Composition import Mathlib.CategoryTheory.MorphismProperty.Factorization /-! # Morphism properties defined in concrete categories In this file, we define the class of morphisms `MorphismProperty.injective`, `MorphismProperty.surjective`, `MorphismProperty.bijective` in concrete categories, and show that it is stable under composition and respect isomorphisms. We introduce type-classes `HasSurjectiveInjectiveFactorization` and `HasFunctorialSurjectiveInjectiveFactorization` expressing that in a concrete category `C`, all morphisms can be factored (resp. factored functorially) as a surjective map followed by an injective map. -/ universe v u namespace CategoryTheory variable (C : Type u) [Category.{v} C] [ConcreteCategory C] namespace MorphismProperty open Function attribute [local instance] ConcreteCategory.instFunLike ConcreteCategory.hasCoeToSort /-- Injectiveness (in a concrete category) as a `MorphismProperty` -/ protected def injective : MorphismProperty C := fun _ _ f => Injective f /-- Surjectiveness (in a concrete category) as a `MorphismProperty` -/ protected def surjective : MorphismProperty C := fun _ _ f => Surjective f /-- Bijectiveness (in a concrete category) as a `MorphismProperty` -/ protected def bijective : MorphismProperty C := fun _ _ f => Bijective f theorem bijective_eq_sup : MorphismProperty.bijective C = MorphismProperty.injective C ⊓ MorphismProperty.surjective C := rfl instance : (MorphismProperty.injective C).IsMultiplicative where id_mem X := by delta MorphismProperty.injective convert injective_id aesop comp_mem f g hf hg := by delta MorphismProperty.injective rw [coe_comp] exact hg.comp hf instance : (MorphismProperty.surjective C).IsMultiplicative where id_mem X := by delta MorphismProperty.surjective convert surjective_id aesop comp_mem f g hf hg := by delta MorphismProperty.surjective rw [coe_comp] exact hg.comp hf instance : (MorphismProperty.bijective C).IsMultiplicative where id_mem X := by delta MorphismProperty.bijective convert bijective_id aesop comp_mem f g hf hg := by delta MorphismProperty.bijective rw [coe_comp] exact hg.comp hf instance injective_respectsIso : (MorphismProperty.injective C).RespectsIso := respectsIso_of_isStableUnderComposition (fun _ _ f (_ : IsIso f) => ((forget C).mapIso (asIso f)).toEquiv.injective) instance surjective_respectsIso : (MorphismProperty.surjective C).RespectsIso := respectsIso_of_isStableUnderComposition (fun _ _ f (_ : IsIso f) => ((forget C).mapIso (asIso f)).toEquiv.surjective) instance bijective_respectsIso : (MorphismProperty.bijective C).RespectsIso := respectsIso_of_isStableUnderComposition (fun _ _ f (_ : IsIso f) => ((forget C).mapIso (asIso f)).toEquiv.bijective) end MorphismProperty namespace ConcreteCategory /-- The property that any morphism in a concrete category can be factored as a surjective map followed by an injective map. -/ abbrev HasSurjectiveInjectiveFactorization := (MorphismProperty.surjective C).HasFactorization (MorphismProperty.injective C) /-- The property that any morphism in a concrete category can be functorially factored as a surjective map followed by an injective map. -/ abbrev HasFunctorialSurjectiveInjectiveFactorization := (MorphismProperty.surjective C).HasFunctorialFactorization (MorphismProperty.injective C) /-- The structure containing the data of a functorial factorization of morphisms as a surjective map followed by an injective map in a concrete category. -/ abbrev FunctorialSurjectiveInjectiveFactorizationData := (MorphismProperty.surjective C).FunctorialFactorizationData (MorphismProperty.injective C) end ConcreteCategory open ConcreteCategory /-- In the category of types, any map can be functorially factored as a surjective map followed by an injective map. -/ def functorialSurjectiveInjectiveFactorizationData : FunctorialSurjectiveInjectiveFactorizationData (Type u) where Z := { obj := fun f => Subtype (Set.range f.hom) map := fun φ y => ⟨φ.right y.1, by obtain ⟨_, x, rfl⟩ := y exact ⟨φ.left x, congr_fun φ.w x⟩ ⟩ } i := { app := fun f x => ⟨f.hom x, ⟨x, rfl⟩⟩ naturality := fun f g φ => by ext x exact congr_fun φ.w x } p := { app := fun f y => y.1 naturality := by intros; rfl; } fac := rfl hi := by rintro f ⟨_, x, rfl⟩ exact ⟨x, rfl⟩ hp f x₁ x₂ h := by rw [Subtype.ext_iff] exact h instance : HasFunctorialSurjectiveInjectiveFactorization (Type u) where nonempty_functorialFactorizationData := ⟨functorialSurjectiveInjectiveFactorizationData⟩ end CategoryTheory
CategoryTheory\MorphismProperty\Factorization.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.MorphismProperty.Basic /-! # The factorization axiom In this file, we introduce a type-class `HasFactorization W₁ W₂`, which, given two classes of morphisms `W₁` and `W₂` in a category `C`, asserts that any morphism in `C` can be factored as a morphism in `W₁` followed by a morphism in `W₂`. The data of such factorizations can be packaged in the type `FactorizationData W₁ W₂`. This shall be used in the formalization of model categories for which the CM5 axiom asserts that any morphism can be factored as a cofibration followed by a trivial fibration (or a trivial cofibration followed by a fibration). We also provide a structure `FunctorialFactorizationData W₁ W₂` which contains the data of a functorial factorization as above. With this design, when we formalize certain constructions (e.g. cylinder objects in model categories), we may first construct them using using `data : FactorizationData W₁ W₂`. Without duplication of code, it shall be possible to show these cylinders are functorial when a term `data : FunctorialFactorizationData W₁ W₂` is available, the existence of which is asserted in the type-class `HasFunctorialFactorization W₁ W₂`. We also introduce the class `W₁.comp W₂` of morphisms of the form `i ≫ p` with `W₁ i` and `W₂ p` and show that `W₁.comp W₂ = ⊤` iff `HasFactorization W₁ W₂` holds (this is `MorphismProperty.comp_eq_top_iff`). -/ namespace CategoryTheory namespace MorphismProperty variable {C : Type*} [Category C] (W₁ W₂ : MorphismProperty C) /-- Given two classes of morphisms `W₁` and `W₂` on a category `C`, this is the data of the factorization of a morphism `f : X ⟶ Y` as `i ≫ p` with `W₁ i` and `W₂ p`. -/ structure MapFactorizationData {X Y : C} (f : X ⟶ Y) where /-- the intermediate object in the factorization -/ Z : C /-- the first morphism in the factorization -/ i : X ⟶ Z /-- the second morphism in the factorization -/ p : Z ⟶ Y fac : i ≫ p = f := by aesop_cat hi : W₁ i hp : W₂ p attribute [reassoc (attr := simp)] MapFactorizationData.fac /-- The data of a term in `MapFactorizationData W₁ W₂ f` for any morphism `f`. -/ abbrev FactorizationData := ∀ {X Y : C} (f : X ⟶ Y), MapFactorizationData W₁ W₂ f /-- The factorization axiom for two classes of morphisms `W₁` and `W₂` in a category `C`. It asserts that any morphism can be factored as a morphism in `W₁` followed by a morphism in `W₂`. -/ class HasFactorization : Prop where nonempty_mapFactorizationData {X Y : C} (f : X ⟶ Y) : Nonempty (MapFactorizationData W₁ W₂ f) /-- A chosen term in `FactorizationData W₁ W₂` when `HasFactorization W₁ W₂` holds. -/ noncomputable def factorizationData [HasFactorization W₁ W₂] : FactorizationData W₁ W₂ := fun _ => Nonempty.some (HasFactorization.nonempty_mapFactorizationData _) /-- The class of morphisms that are of the form `i ≫ p` with `W₁ i` and `W₂ p`. -/ def comp : MorphismProperty C := fun _ _ f => Nonempty (MapFactorizationData W₁ W₂ f) lemma comp_eq_top_iff : W₁.comp W₂ = ⊤ ↔ HasFactorization W₁ W₂ := by constructor · intro h refine ⟨fun f => ?_⟩ have : W₁.comp W₂ f := by simp only [h, top_apply] exact ⟨this.some⟩ · intro ext X Y f simp only [top_apply, iff_true] exact ⟨factorizationData W₁ W₂ f⟩ /-- The data of a functorial factorization of any morphism in `C` as a morphism in `W₁` followed by a morphism in `W₂`. -/ structure FunctorialFactorizationData where /-- the intermediate objects in the factorizations -/ Z : Arrow C ⥤ C /-- the first morphism in the factorizations -/ i : Arrow.leftFunc ⟶ Z /-- the second morphism in the factorizations -/ p : Z ⟶ Arrow.rightFunc fac : i ≫ p = Arrow.leftToRight := by aesop_cat hi (f : Arrow C) : W₁ (i.app f) hp (f : Arrow C) : W₂ (p.app f) namespace FunctorialFactorizationData variable {W₁ W₂} variable (data : FunctorialFactorizationData W₁ W₂) attribute [reassoc (attr := simp)] fac @[reassoc (attr := simp)] lemma fac_app {f : Arrow C} : data.i.app f ≫ data.p.app f = f.hom := by rw [← NatTrans.comp_app, fac,Arrow.leftToRight_app] /-- If `W₁ ≤ W₁'` and `W₂ ≤ W₂'`, then a functorial factorization for `W₁` and `W₂` induces a functorial factorization for `W₁'` and `W₂'`. -/ def ofLE {W₁' W₂' : MorphismProperty C} (le₁ : W₁ ≤ W₁') (le₂ : W₂ ≤ W₂') : FunctorialFactorizationData W₁' W₂' where Z := data.Z i := data.i p := data.p hi f := le₁ _ (data.hi f) hp f := le₂ _ (data.hp f) /-- The term in `FactorizationData W₁ W₂` that is deduced from a functorial factorization. -/ def factorizationData : FactorizationData W₁ W₂ := fun f => { i := data.i.app (Arrow.mk f) p := data.p.app (Arrow.mk f) hi := data.hi _ hp := data.hp _ } section variable {X Y X' Y' : C} {f : X ⟶ Y} {g : X' ⟶ Y'} (φ : Arrow.mk f ⟶ Arrow.mk g) /-- When `data : FunctorialFactorizationData W₁ W₂`, this is the morphism `(data.factorizationData f).Z ⟶ (data.factorizationData g).Z` expressing the functoriality of the intermediate objects of the factorizations for `φ : Arrow.mk f ⟶ Arrow.mk g`. -/ def mapZ : (data.factorizationData f).Z ⟶ (data.factorizationData g).Z := data.Z.map φ @[reassoc (attr := simp)] lemma i_mapZ : (data.factorizationData f).i ≫ data.mapZ φ = φ.left ≫ (data.factorizationData g).i := (data.i.naturality φ).symm @[reassoc (attr := simp)] lemma mapZ_p : data.mapZ φ ≫ (data.factorizationData g).p = (data.factorizationData f).p ≫ φ.right := data.p.naturality φ variable (f) in @[simp] lemma mapZ_id : data.mapZ (𝟙 (Arrow.mk f)) = 𝟙 _ := data.Z.map_id _ @[reassoc, simp] lemma mapZ_comp {X'' Y'' : C} {h : X'' ⟶ Y''} (ψ : Arrow.mk g ⟶ Arrow.mk h) : data.mapZ (φ ≫ ψ) = data.mapZ φ ≫ data.mapZ ψ := data.Z.map_comp _ _ end section variable (J : Type*) [Category J] /-- Auxiliary definition for `FunctorialFactorizationData.functorCategory`. -/ @[simps] def functorCategory.Z : Arrow (J ⥤ C) ⥤ J ⥤ C where obj f := { obj := fun j => (data.factorizationData (f.hom.app j)).Z map := fun φ => data.mapZ { left := f.left.map φ right := f.right.map φ } map_id := fun j => by dsimp rw [← data.mapZ_id (f.hom.app j)] congr <;> simp map_comp := fun _ _ => by dsimp rw [← data.mapZ_comp] congr <;> simp } map τ := { app := fun j => data.mapZ { left := τ.left.app j right := τ.right.app j w := congr_app τ.w j } naturality := fun _ _ α => by dsimp rw [← data.mapZ_comp, ← data.mapZ_comp] congr 1 ext <;> simp } map_id f := by ext j dsimp rw [← data.mapZ_id] congr 1 map_comp f g := by ext j dsimp rw [← data.mapZ_comp] congr 1 /-- A functorial factorization in the category `C` extends to the functor category `J ⥤ C`. -/ def functorCategory : FunctorialFactorizationData (W₁.functorCategory J) (W₂.functorCategory J) where Z := functorCategory.Z data J i := { app := fun f => { app := fun j => (data.factorizationData (f.hom.app j)).i } } p := { app := fun f => { app := fun j => (data.factorizationData (f.hom.app j)).p } } hi _ _ := data.hi _ hp _ _ := data.hp _ end end FunctorialFactorizationData /-- The functorial factorization axiom for two classes of morphisms `W₁` and `W₂` in a category `C`. It asserts that any morphism can be factored in a functorial manner as a morphism in `W₁` followed by a morphism in `W₂`. -/ class HasFunctorialFactorization : Prop where nonempty_functorialFactorizationData : Nonempty (FunctorialFactorizationData W₁ W₂) /-- A chosen term in `FunctorialFactorizationData W₁ W₂` when the functorial factorization axiom `HasFunctorialFactorization W₁ W₂` holds. -/ noncomputable def functorialFactorizationData [HasFunctorialFactorization W₁ W₂] : FunctorialFactorizationData W₁ W₂ := Nonempty.some (HasFunctorialFactorization.nonempty_functorialFactorizationData) instance [HasFunctorialFactorization W₁ W₂] : HasFactorization W₁ W₂ where nonempty_mapFactorizationData f := ⟨(functorialFactorizationData W₁ W₂).factorizationData f⟩ instance [HasFunctorialFactorization W₁ W₂] (J : Type*) [Category J] : HasFunctorialFactorization (W₁.functorCategory J) (W₂.functorCategory J) := ⟨⟨(functorialFactorizationData W₁ W₂).functorCategory J⟩⟩ end MorphismProperty end CategoryTheory
CategoryTheory\MorphismProperty\IsInvertedBy.lean
/- Copyright (c) 2022 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.ReflectsIso import Mathlib.CategoryTheory.MorphismProperty.Basic /-! # Morphism properties that are inverted by a functor In this file, we introduce the predicate `P.IsInvertedBy F` which expresses that the morphisms satisfying `P : MorphismProperty C` are mapped to isomorphisms by a functor `F : C ⥤ D`. This is used in the localization of categories API (folder `CategoryTheory.Localization`). -/ universe w v v' u u' namespace CategoryTheory namespace MorphismProperty variable {C : Type u} [Category.{v} C] {D : Type u'} [Category.{v'} D] /-- If `P : MorphismProperty C` and `F : C ⥤ D`, then `P.IsInvertedBy F` means that all morphisms in `P` are mapped by `F` to isomorphisms in `D`. -/ def IsInvertedBy (P : MorphismProperty C) (F : C ⥤ D) : Prop := ∀ ⦃X Y : C⦄ (f : X ⟶ Y) (_ : P f), IsIso (F.map f) namespace IsInvertedBy lemma of_le (P Q : MorphismProperty C) (F : C ⥤ D) (hQ : Q.IsInvertedBy F) (h : P ≤ Q) : P.IsInvertedBy F := fun _ _ _ hf => hQ _ (h _ hf) theorem of_comp {C₁ C₂ C₃ : Type*} [Category C₁] [Category C₂] [Category C₃] (W : MorphismProperty C₁) (F : C₁ ⥤ C₂) (hF : W.IsInvertedBy F) (G : C₂ ⥤ C₃) : W.IsInvertedBy (F ⋙ G) := fun X Y f hf => by haveI := hF f hf dsimp infer_instance theorem op {W : MorphismProperty C} {L : C ⥤ D} (h : W.IsInvertedBy L) : W.op.IsInvertedBy L.op := fun X Y f hf => by haveI := h f.unop hf dsimp infer_instance theorem rightOp {W : MorphismProperty C} {L : Cᵒᵖ ⥤ D} (h : W.op.IsInvertedBy L) : W.IsInvertedBy L.rightOp := fun X Y f hf => by haveI := h f.op hf dsimp infer_instance theorem leftOp {W : MorphismProperty C} {L : C ⥤ Dᵒᵖ} (h : W.IsInvertedBy L) : W.op.IsInvertedBy L.leftOp := fun X Y f hf => by haveI := h f.unop hf dsimp infer_instance theorem unop {W : MorphismProperty C} {L : Cᵒᵖ ⥤ Dᵒᵖ} (h : W.op.IsInvertedBy L) : W.IsInvertedBy L.unop := fun X Y f hf => by haveI := h f.op hf dsimp infer_instance lemma prod {C₁ C₂ : Type*} [Category C₁] [Category C₂] {W₁ : MorphismProperty C₁} {W₂ : MorphismProperty C₂} {E₁ E₂ : Type*} [Category E₁] [Category E₂] {F₁ : C₁ ⥤ E₁} {F₂ : C₂ ⥤ E₂} (h₁ : W₁.IsInvertedBy F₁) (h₂ : W₂.IsInvertedBy F₂) : (W₁.prod W₂).IsInvertedBy (F₁.prod F₂) := fun _ _ f hf => by rw [isIso_prod_iff] exact ⟨h₁ _ hf.1, h₂ _ hf.2⟩ lemma pi {J : Type w} {C : J → Type u} {D : J → Type u'} [∀ j, Category.{v} (C j)] [∀ j, Category.{v'} (D j)] (W : ∀ j, MorphismProperty (C j)) (F : ∀ j, C j ⥤ D j) (hF : ∀ j, (W j).IsInvertedBy (F j)) : (MorphismProperty.pi W).IsInvertedBy (Functor.pi F) := by intro _ _ f hf rw [isIso_pi_iff] intro j exact hF j _ (hf j) end IsInvertedBy -- porting note (#5171): removed @[nolint has_nonempty_instance] /-- The full subcategory of `C ⥤ D` consisting of functors inverting morphisms in `W` -/ def FunctorsInverting (W : MorphismProperty C) (D : Type*) [Category D] := FullSubcategory fun F : C ⥤ D => W.IsInvertedBy F @[ext] lemma FunctorsInverting.ext {W : MorphismProperty C} {F₁ F₂ : FunctorsInverting W D} (h : F₁.obj = F₂.obj) : F₁ = F₂ := by cases F₁ cases F₂ subst h rfl instance (W : MorphismProperty C) (D : Type*) [Category D] : Category (FunctorsInverting W D) := FullSubcategory.category _ -- Porting note (#5229): add another `@[ext]` lemma -- since `ext` can't see through the definition to use `NatTrans.ext`. @[ext] lemma FunctorsInverting.hom_ext {W : MorphismProperty C} {F₁ F₂ : FunctorsInverting W D} {α β : F₁ ⟶ F₂} (h : α.app = β.app) : α = β := NatTrans.ext h /-- A constructor for `W.FunctorsInverting D` -/ def FunctorsInverting.mk {W : MorphismProperty C} {D : Type*} [Category D] (F : C ⥤ D) (hF : W.IsInvertedBy F) : W.FunctorsInverting D := ⟨F, hF⟩ theorem IsInvertedBy.iff_of_iso (W : MorphismProperty C) {F₁ F₂ : C ⥤ D} (e : F₁ ≅ F₂) : W.IsInvertedBy F₁ ↔ W.IsInvertedBy F₂ := by dsimp [IsInvertedBy] simp only [NatIso.isIso_map_iff e] @[simp] lemma IsInvertedBy.isoClosure_iff (W : MorphismProperty C) (F : C ⥤ D) : W.isoClosure.IsInvertedBy F ↔ W.IsInvertedBy F := by constructor · intro h X Y f hf exact h _ (W.le_isoClosure _ hf) · intro h X Y f ⟨X', Y', f', hf', ⟨e⟩⟩ have : f = e.inv.left ≫ f' ≫ e.hom.right := by erw [← e.hom.w, ← Arrow.comp_left_assoc, e.inv_hom_id, Category.id_comp] rfl simp only [this, F.map_comp] have := h _ hf' infer_instance @[simp] lemma IsInvertedBy.iff_comp {C₁ C₂ C₃ : Type*} [Category C₁] [Category C₂] [Category C₃] (W : MorphismProperty C₁) (F : C₁ ⥤ C₂) (G : C₂ ⥤ C₃) [G.ReflectsIsomorphisms] : W.IsInvertedBy (F ⋙ G) ↔ W.IsInvertedBy F := by constructor · intro h X Y f hf have : IsIso (G.map (F.map f)) := h _ hf exact isIso_of_reflects_iso (F.map f) G · intro hF exact IsInvertedBy.of_comp W F hF G lemma IsInvertedBy.iff_le_inverseImage_isomorphisms (W : MorphismProperty C) (F : C ⥤ D) : W.IsInvertedBy F ↔ W ≤ (isomorphisms D).inverseImage F := Iff.rfl lemma IsInvertedBy.iff_map_le_isomorphisms (W : MorphismProperty C) (F : C ⥤ D) : W.IsInvertedBy F ↔ W.map F ≤ isomorphisms D := by rw [iff_le_inverseImage_isomorphisms, map_le_iff] lemma IsInvertedBy.map_iff {C₁ C₂ C₃ : Type*} [Category C₁] [Category C₂] [Category C₃] (W : MorphismProperty C₁) (F : C₁ ⥤ C₂) (G : C₂ ⥤ C₃) : (W.map F).IsInvertedBy G ↔ W.IsInvertedBy (F ⋙ G) := by simp only [IsInvertedBy.iff_map_le_isomorphisms, map_map] end MorphismProperty end CategoryTheory
CategoryTheory\MorphismProperty\Limits.lean
/- Copyright (c) 2022 Andrew Yang. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Andrew Yang, Joël Riou -/ import Mathlib.CategoryTheory.Limits.Shapes.Pullback.CommSq import Mathlib.CategoryTheory.Limits.Shapes.Diagonal import Mathlib.CategoryTheory.MorphismProperty.Composition /-! # Relation of morphism properties with limits The following predicates are introduces for morphism properties `P`: * `StableUnderBaseChange`: `P` is stable under base change if in all pullback squares, the left map satisfies `P` if the right map satisfies it. * `StableUnderCobaseChange`: `P` is stable under cobase change if in all pushout squares, the right map satisfies `P` if the left map satisfies it. We define `P.universally` for the class of morphisms which satisfy `P` after any base change. We also introduce properties `IsStableUnderProductsOfShape`, `IsStableUnderLimitsOfShape`, `IsStableUnderFiniteProducts`. -/ universe v u namespace CategoryTheory open Limits namespace MorphismProperty variable {C : Type u} [Category.{v} C] /-- A morphism property is `StableUnderBaseChange` if the base change of such a morphism still falls in the class. -/ def StableUnderBaseChange (P : MorphismProperty C) : Prop := ∀ ⦃X Y Y' S : C⦄ ⦃f : X ⟶ S⦄ ⦃g : Y ⟶ S⦄ ⦃f' : Y' ⟶ Y⦄ ⦃g' : Y' ⟶ X⦄ (_ : IsPullback f' g' g f) (_ : P g), P g' /-- A morphism property is `StableUnderCobaseChange` if the cobase change of such a morphism still falls in the class. -/ def StableUnderCobaseChange (P : MorphismProperty C) : Prop := ∀ ⦃A A' B B' : C⦄ ⦃f : A ⟶ A'⦄ ⦃g : A ⟶ B⦄ ⦃f' : B ⟶ B'⦄ ⦃g' : A' ⟶ B'⦄ (_ : IsPushout g f f' g') (_ : P f), P f' theorem StableUnderBaseChange.mk {P : MorphismProperty C} [HasPullbacks C] [RespectsIso P] (hP₂ : ∀ (X Y S : C) (f : X ⟶ S) (g : Y ⟶ S) (_ : P g), P (pullback.fst f g)) : StableUnderBaseChange P := fun X Y Y' S f g f' g' sq hg => by let e := sq.flip.isoPullback rw [← P.cancel_left_of_respectsIso e.inv, sq.flip.isoPullback_inv_fst] exact hP₂ _ _ _ f g hg theorem StableUnderBaseChange.respectsIso {P : MorphismProperty C} (hP : StableUnderBaseChange P) : RespectsIso P := by apply RespectsIso.of_respects_arrow_iso intro f g e exact hP (IsPullback.of_horiz_isIso (CommSq.mk e.inv.w)) theorem StableUnderBaseChange.fst {P : MorphismProperty C} (hP : StableUnderBaseChange P) {X Y S : C} (f : X ⟶ S) (g : Y ⟶ S) [HasPullback f g] (H : P g) : P (pullback.fst f g) := hP (IsPullback.of_hasPullback f g).flip H theorem StableUnderBaseChange.snd {P : MorphismProperty C} (hP : StableUnderBaseChange P) {X Y S : C} (f : X ⟶ S) (g : Y ⟶ S) [HasPullback f g] (H : P f) : P (pullback.snd f g) := hP (IsPullback.of_hasPullback f g) H theorem StableUnderBaseChange.baseChange_obj [HasPullbacks C] {P : MorphismProperty C} (hP : StableUnderBaseChange P) {S S' : C} (f : S' ⟶ S) (X : Over S) (H : P X.hom) : P ((Over.pullback f).obj X).hom := hP.snd X.hom f H theorem StableUnderBaseChange.baseChange_map [HasPullbacks C] {P : MorphismProperty C} (hP : StableUnderBaseChange P) {S S' : C} (f : S' ⟶ S) {X Y : Over S} (g : X ⟶ Y) (H : P g.left) : P ((Over.pullback f).map g).left := by have := hP.respectsIso let e := pullbackRightPullbackFstIso Y.hom f g.left ≪≫ pullback.congrHom (g.w.trans (Category.comp_id _)) rfl have : e.inv ≫ (pullback.snd _ _) = ((Over.pullback f).map g).left := by ext <;> dsimp [e] <;> simp rw [← this, P.cancel_left_of_respectsIso] exact hP.snd _ _ H theorem StableUnderBaseChange.pullback_map [HasPullbacks C] {P : MorphismProperty C} (hP : StableUnderBaseChange P) [P.IsStableUnderComposition] {S X X' Y Y' : C} {f : X ⟶ S} {g : Y ⟶ S} {f' : X' ⟶ S} {g' : Y' ⟶ S} {i₁ : X ⟶ X'} {i₂ : Y ⟶ Y'} (h₁ : P i₁) (h₂ : P i₂) (e₁ : f = i₁ ≫ f') (e₂ : g = i₂ ≫ g') : P (pullback.map f g f' g' i₁ i₂ (𝟙 _) ((Category.comp_id _).trans e₁) ((Category.comp_id _).trans e₂)) := by have := hP.respectsIso have : pullback.map f g f' g' i₁ i₂ (𝟙 _) ((Category.comp_id _).trans e₁) ((Category.comp_id _).trans e₂) = ((pullbackSymmetry _ _).hom ≫ ((Over.pullback _).map (Over.homMk _ e₂.symm : Over.mk g ⟶ Over.mk g')).left) ≫ (pullbackSymmetry _ _).hom ≫ ((Over.pullback g').map (Over.homMk _ e₁.symm : Over.mk f ⟶ Over.mk f')).left := by ext <;> dsimp <;> simp rw [this] apply P.comp_mem <;> rw [P.cancel_left_of_respectsIso] exacts [hP.baseChange_map _ (Over.homMk _ e₂.symm : Over.mk g ⟶ Over.mk g') h₂, hP.baseChange_map _ (Over.homMk _ e₁.symm : Over.mk f ⟶ Over.mk f') h₁] theorem StableUnderCobaseChange.mk {P : MorphismProperty C} [HasPushouts C] [RespectsIso P] (hP₂ : ∀ (A B A' : C) (f : A ⟶ A') (g : A ⟶ B) (_ : P f), P (pushout.inr f g)) : StableUnderCobaseChange P := fun A A' B B' f g f' g' sq hf => by let e := sq.flip.isoPushout rw [← P.cancel_right_of_respectsIso _ e.hom, sq.flip.inr_isoPushout_hom] exact hP₂ _ _ _ f g hf theorem StableUnderCobaseChange.respectsIso {P : MorphismProperty C} (hP : StableUnderCobaseChange P) : RespectsIso P := RespectsIso.of_respects_arrow_iso _ fun _ _ e => hP (IsPushout.of_horiz_isIso (CommSq.mk e.hom.w)) theorem StableUnderCobaseChange.inl {P : MorphismProperty C} (hP : StableUnderCobaseChange P) {A B A' : C} (f : A ⟶ A') (g : A ⟶ B) [HasPushout f g] (H : P g) : P (pushout.inl f g) := hP (IsPushout.of_hasPushout f g) H theorem StableUnderCobaseChange.inr {P : MorphismProperty C} (hP : StableUnderCobaseChange P) {A B A' : C} (f : A ⟶ A') (g : A ⟶ B) [HasPushout f g] (H : P f) : P (pushout.inr f g) := hP (IsPushout.of_hasPushout f g).flip H theorem StableUnderCobaseChange.op {P : MorphismProperty C} (hP : StableUnderCobaseChange P) : StableUnderBaseChange P.op := fun _ _ _ _ _ _ _ _ sq hg => hP sq.unop hg theorem StableUnderCobaseChange.unop {P : MorphismProperty Cᵒᵖ} (hP : StableUnderCobaseChange P) : StableUnderBaseChange P.unop := fun _ _ _ _ _ _ _ _ sq hg => hP sq.op hg theorem StableUnderBaseChange.op {P : MorphismProperty C} (hP : StableUnderBaseChange P) : StableUnderCobaseChange P.op := fun _ _ _ _ _ _ _ _ sq hf => hP sq.unop hf theorem StableUnderBaseChange.unop {P : MorphismProperty Cᵒᵖ} (hP : StableUnderBaseChange P) : StableUnderCobaseChange P.unop := fun _ _ _ _ _ _ _ _ sq hf => hP sq.op hf section variable (W : MorphismProperty C) /-- The property that a morphism property `W` is stable under limits indexed by a category `J`. -/ def IsStableUnderLimitsOfShape (J : Type*) [Category J] : Prop := ∀ (X₁ X₂ : J ⥤ C) (c₁ : Cone X₁) (c₂ : Cone X₂) (_ : IsLimit c₁) (h₂ : IsLimit c₂) (f : X₁ ⟶ X₂) (_ : W.functorCategory J f), W (h₂.lift (Cone.mk _ (c₁.π ≫ f))) variable {W} lemma IsStableUnderLimitsOfShape.lim_map {J : Type*} [Category J] (hW : W.IsStableUnderLimitsOfShape J) {X Y : J ⥤ C} (f : X ⟶ Y) [HasLimitsOfShape J C] (hf : W.functorCategory _ f) : W (lim.map f) := hW X Y _ _ (limit.isLimit X) (limit.isLimit Y) f hf variable (W) /-- The property that a morphism property `W` is stable under products indexed by a type `J`. -/ abbrev IsStableUnderProductsOfShape (J : Type*) := W.IsStableUnderLimitsOfShape (Discrete J) lemma IsStableUnderProductsOfShape.mk (J : Type*) [W.RespectsIso] [HasProductsOfShape J C] (hW : ∀ (X₁ X₂ : J → C) (f : ∀ j, X₁ j ⟶ X₂ j) (_ : ∀ (j : J), W (f j)), W (Pi.map f)) : W.IsStableUnderProductsOfShape J := by intro X₁ X₂ c₁ c₂ hc₁ hc₂ f hf let φ := fun j => f.app (Discrete.mk j) have hf' := hW _ _ φ (fun j => hf (Discrete.mk j)) refine (W.arrow_mk_iso_iff ?_).2 hf' refine Arrow.isoMk (IsLimit.conePointUniqueUpToIso hc₁ (limit.isLimit X₁) ≪≫ (Pi.isoLimit _).symm) (IsLimit.conePointUniqueUpToIso hc₂ (limit.isLimit X₂) ≪≫ (Pi.isoLimit _).symm) ?_ apply limit.hom_ext rintro ⟨j⟩ simp /-- The condition that a property of morphisms is stable by finite products. -/ class IsStableUnderFiniteProducts : Prop := isStableUnderProductsOfShape (J : Type) [Finite J] : W.IsStableUnderProductsOfShape J lemma isStableUnderProductsOfShape_of_isStableUnderFiniteProducts (J : Type) [Finite J] [W.IsStableUnderFiniteProducts] : W.IsStableUnderProductsOfShape J := IsStableUnderFiniteProducts.isStableUnderProductsOfShape J end section Diagonal variable [HasPullbacks C] {P : MorphismProperty C} /-- For `P : MorphismProperty C`, `P.diagonal` is a morphism property that holds for `f : X ⟶ Y` whenever `P` holds for `X ⟶ Y xₓ Y`. -/ def diagonal (P : MorphismProperty C) : MorphismProperty C := fun _ _ f => P (pullback.diagonal f) theorem diagonal_iff {X Y : C} {f : X ⟶ Y} : P.diagonal f ↔ P (pullback.diagonal f) := Iff.rfl instance RespectsIso.diagonal [P.RespectsIso] : P.diagonal.RespectsIso := by constructor · introv H rwa [diagonal_iff, pullback.diagonal_comp, P.cancel_left_of_respectsIso, P.cancel_left_of_respectsIso, ← P.cancel_right_of_respectsIso _ (pullback.map (e.hom ≫ f) (e.hom ≫ f) f f e.hom e.hom (𝟙 Z) (by simp) (by simp)), ← pullback.condition, P.cancel_left_of_respectsIso] · introv H delta diagonal rwa [pullback.diagonal_comp, P.cancel_right_of_respectsIso] theorem diagonal_isStableUnderComposition [P.IsStableUnderComposition] [RespectsIso P] (hP'' : StableUnderBaseChange P) : P.diagonal.IsStableUnderComposition where comp_mem _ _ h₁ h₂ := by rw [diagonal_iff, pullback.diagonal_comp] exact P.comp_mem _ _ h₁ (by simpa only [cancel_left_of_respectsIso] using hP''.snd _ _ h₂) theorem StableUnderBaseChange.diagonal (hP : StableUnderBaseChange P) [P.RespectsIso] : P.diagonal.StableUnderBaseChange := StableUnderBaseChange.mk (by introv h rw [diagonal_iff, diagonal_pullback_fst, P.cancel_left_of_respectsIso, P.cancel_right_of_respectsIso] exact hP.baseChange_map f _ (by simpa)) end Diagonal section Universally /-- `P.universally` holds for a morphism `f : X ⟶ Y` iff `P` holds for all `X ×[Y] Y' ⟶ Y'`. -/ def universally (P : MorphismProperty C) : MorphismProperty C := fun X Y f => ∀ ⦃X' Y' : C⦄ (i₁ : X' ⟶ X) (i₂ : Y' ⟶ Y) (f' : X' ⟶ Y') (_ : IsPullback f' i₁ i₂ f), P f' instance universally_respectsIso (P : MorphismProperty C) : P.universally.RespectsIso := by constructor · intro X Y Z e f hf X' Z' i₁ i₂ f' H have : IsPullback (𝟙 _) (i₁ ≫ e.hom) i₁ e.inv := IsPullback.of_horiz_isIso ⟨by rw [Category.id_comp, Category.assoc, e.hom_inv_id, Category.comp_id]⟩ exact hf _ _ _ (by simpa only [Iso.inv_hom_id_assoc, Category.id_comp] using this.paste_horiz H) · intro X Y Z e f hf X' Z' i₁ i₂ f' H have : IsPullback (𝟙 _) i₂ (i₂ ≫ e.inv) e.inv := IsPullback.of_horiz_isIso ⟨Category.id_comp _⟩ exact hf _ _ _ (by simpa only [Category.assoc, Iso.hom_inv_id, Category.comp_id, Category.comp_id] using H.paste_horiz this) theorem universally_stableUnderBaseChange (P : MorphismProperty C) : P.universally.StableUnderBaseChange := fun _ _ _ _ _ _ _ _ H h₁ _ _ _ _ _ H' => h₁ _ _ _ (H'.paste_vert H.flip) instance IsStableUnderComposition.universally [HasPullbacks C] (P : MorphismProperty C) [hP : P.IsStableUnderComposition] : P.universally.IsStableUnderComposition where comp_mem {X Y Z} f g hf hg X' Z' i₁ i₂ f' H := by have := pullback.lift_fst _ _ (H.w.trans (Category.assoc _ _ _).symm) rw [← this] at H ⊢ apply P.comp_mem _ _ _ (hg _ _ _ <| IsPullback.of_hasPullback _ _) exact hf _ _ _ (H.of_right (pullback.lift_snd _ _ _) (IsPullback.of_hasPullback i₂ g)) theorem universally_le (P : MorphismProperty C) : P.universally ≤ P := by intro X Y f hf exact hf (𝟙 _) (𝟙 _) _ (IsPullback.of_vert_isIso ⟨by rw [Category.comp_id, Category.id_comp]⟩) theorem universally_eq_iff {P : MorphismProperty C} : P.universally = P ↔ P.StableUnderBaseChange := ⟨(· ▸ P.universally_stableUnderBaseChange), fun hP ↦ P.universally_le.antisymm fun _ _ _ hf _ _ _ _ _ H => hP H.flip hf⟩ theorem StableUnderBaseChange.universally_eq {P : MorphismProperty C} (hP : P.StableUnderBaseChange) : P.universally = P := universally_eq_iff.mpr hP theorem universally_mono : Monotone (universally : MorphismProperty C → MorphismProperty C) := fun _ _ h _ _ _ h₁ _ _ _ _ _ H => h _ (h₁ _ _ _ H) end Universally end MorphismProperty end CategoryTheory
CategoryTheory\Pi\Basic.lean
/- Copyright (c) 2020 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Simon Hudon, Scott Morrison -/ import Mathlib.CategoryTheory.EqToHom import Mathlib.CategoryTheory.NatIso import Mathlib.CategoryTheory.Products.Basic import Batteries.Data.Sum.Basic /-! # Categories of indexed families of objects. We define the pointwise category structure on indexed families of objects in a category (and also the dependent generalization). -/ namespace CategoryTheory universe w₀ w₁ w₂ v₁ v₂ v₃ u₁ u₂ u₃ variable {I : Type w₀} {J : Type w₁} (C : I → Type u₁) [∀ i, Category.{v₁} (C i)] /-- `pi C` gives the cartesian product of an indexed family of categories. -/ instance pi : Category.{max w₀ v₁} (∀ i, C i) where Hom X Y := ∀ i, X i ⟶ Y i id X i := 𝟙 (X i) comp f g i := f i ≫ g i /-- This provides some assistance to typeclass search in a common situation, which otherwise fails. (Without this `CategoryTheory.Pi.has_limit_of_has_limit_comp_eval` fails.) -/ abbrev pi' {I : Type v₁} (C : I → Type u₁) [∀ i, Category.{v₁} (C i)] : Category.{v₁} (∀ i, C i) := CategoryTheory.pi C attribute [instance] pi' namespace Pi @[simp] theorem id_apply (X : ∀ i, C i) (i) : (𝟙 X : ∀ i, X i ⟶ X i) i = 𝟙 (X i) := rfl @[simp] theorem comp_apply {X Y Z : ∀ i, C i} (f : X ⟶ Y) (g : Y ⟶ Z) (i) : (f ≫ g : ∀ i, X i ⟶ Z i) i = f i ≫ g i := rfl -- Porting note: need to add an additional `ext` lemma. @[ext] lemma ext {X Y : ∀ i, C i} {f g : X ⟶ Y} (w : ∀ i, f i = g i) : f = g := funext (w ·) /-- The evaluation functor at `i : I`, sending an `I`-indexed family of objects to the object over `i`. -/ @[simps] def eval (i : I) : (∀ i, C i) ⥤ C i where obj f := f i map α := α i section variable {J : Type w₁} /- Porting note: add this because Lean cannot see directly through the `∘` for `Function.comp` -/ instance (f : J → I) : (j : J) → Category ((C ∘ f) j) := by dsimp infer_instance /-- Pull back an `I`-indexed family of objects to a `J`-indexed family, along a function `J → I`. -/ @[simps] def comap (h : J → I) : (∀ i, C i) ⥤ (∀ j, C (h j)) where obj f i := f (h i) map α i := α (h i) variable (I) /-- The natural isomorphism between pulling back a grading along the identity function, and the identity functor. -/ @[simps] def comapId : comap C (id : I → I) ≅ 𝟭 (∀ i, C i) where hom := { app := fun X => 𝟙 X } inv := { app := fun X => 𝟙 X } example (g : J → I) : (j : J) → Category (C (g j)) := by infer_instance variable {I} variable {K : Type w₂} /-- The natural isomorphism comparing between pulling back along two successive functions, and pulling back along their composition -/ @[simps!] def comapComp (f : K → J) (g : J → I) : comap C g ⋙ comap (C ∘ g) f ≅ comap C (g ∘ f) where hom := { app := fun X b => 𝟙 (X (g (f b))) naturality := fun X Y f' => by simp only [comap, Function.comp]; funext; simp } inv := { app := fun X b => 𝟙 (X (g (f b))) naturality := fun X Y f' => by simp only [comap, Function.comp]; funext; simp } /-- The natural isomorphism between pulling back then evaluating, and just evaluating. -/ @[simps!] def comapEvalIsoEval (h : J → I) (j : J) : comap C h ⋙ eval (C ∘ h) j ≅ eval C (h j) := NatIso.ofComponents (fun f => Iso.refl _) (by simp only [Iso.refl]; aesop_cat) end section variable {J : Type w₀} {D : J → Type u₁} [∀ j, Category.{v₁} (D j)] /- Porting note: maybe mixing up universes -/ instance sumElimCategory : ∀ s : I ⊕ J, Category.{v₁} (Sum.elim C D s) | Sum.inl i => by dsimp infer_instance | Sum.inr j => by dsimp infer_instance /- Porting note: replaced `Sum.rec` with `match`'s per the error about current state of code generation -/ /-- The bifunctor combining an `I`-indexed family of objects with a `J`-indexed family of objects to obtain an `I ⊕ J`-indexed family of objects. -/ @[simps] def sum : (∀ i, C i) ⥤ (∀ j, D j) ⥤ ∀ s : I ⊕ J, Sum.elim C D s where obj X := { obj := fun Y s => match s with | .inl i => X i | .inr j => Y j map := fun {Y} {Y'} f s => match s with | .inl i => 𝟙 (X i) | .inr j => f j } map {X} {X'} f := { app := fun Y s => match s with | .inl i => f i | .inr j => 𝟙 (Y j) } end variable {C} /-- An isomorphism between `I`-indexed objects gives an isomorphism between each pair of corresponding components. -/ @[simps] def isoApp {X Y : ∀ i, C i} (f : X ≅ Y) (i : I) : X i ≅ Y i := ⟨f.hom i, f.inv i, by rw [← comp_apply, Iso.hom_inv_id, id_apply], by rw [← comp_apply, Iso.inv_hom_id, id_apply]⟩ @[simp] theorem isoApp_refl (X : ∀ i, C i) (i : I) : isoApp (Iso.refl X) i = Iso.refl (X i) := rfl @[simp] theorem isoApp_symm {X Y : ∀ i, C i} (f : X ≅ Y) (i : I) : isoApp f.symm i = (isoApp f i).symm := rfl @[simp] theorem isoApp_trans {X Y Z : ∀ i, C i} (f : X ≅ Y) (g : Y ≅ Z) (i : I) : isoApp (f ≪≫ g) i = isoApp f i ≪≫ isoApp g i := rfl end Pi namespace Functor variable {C} variable {D : I → Type u₂} [∀ i, Category.{v₂} (D i)] {A : Type u₃} [Category.{v₃} A] /-- Assemble an `I`-indexed family of functors into a functor between the pi types. -/ @[simps] def pi (F : ∀ i, C i ⥤ D i) : (∀ i, C i) ⥤ ∀ i, D i where obj f i := (F i).obj (f i) map α i := (F i).map (α i) /-- Similar to `pi`, but all functors come from the same category `A` -/ @[simps] def pi' (f : ∀ i, A ⥤ C i) : A ⥤ ∀ i, C i where obj a i := (f i).obj a map h i := (f i).map h /-- The projections of `Functor.pi' F` are isomorphic to the functors of the family `F` -/ @[simps!] def pi'CompEval {A : Type*} [Category A] (F : ∀ i, A ⥤ C i) (i : I) : pi' F ⋙ Pi.eval C i ≅ F i := Iso.refl _ section EqToHom @[simp] theorem eqToHom_proj {x x' : ∀ i, C i} (h : x = x') (i : I) : (eqToHom h : x ⟶ x') i = eqToHom (Function.funext_iff.mp h i) := by subst h rfl end EqToHom -- One could add some natural isomorphisms showing -- how `Functor.pi` commutes with `Pi.eval` and `Pi.comap`. @[simp] theorem pi'_eval (f : ∀ i, A ⥤ C i) (i : I) : pi' f ⋙ Pi.eval C i = f i := by apply Functor.ext · intro _ _ _ simp · intro _ rfl /-- Two functors to a product category are equal iff they agree on every coordinate. -/ theorem pi_ext (f f' : A ⥤ ∀ i, C i) (h : ∀ i, f ⋙ (Pi.eval C i) = f' ⋙ (Pi.eval C i)) : f = f' := by apply Functor.ext; rotate_left · intro X ext i specialize h i have := congr_obj h X simpa · intro X Y g dsimp funext i specialize h i have := congr_hom h g simpa end Functor namespace NatTrans variable {C} variable {D : I → Type u₂} [∀ i, Category.{v₂} (D i)] variable {F G : ∀ i, C i ⥤ D i} /-- Assemble an `I`-indexed family of natural transformations into a single natural transformation. -/ @[simps!] def pi (α : ∀ i, F i ⟶ G i) : Functor.pi F ⟶ Functor.pi G where app f i := (α i).app (f i) /-- Assemble an `I`-indexed family of natural transformations into a single natural transformation. -/ @[simps] def pi' {E : Type*} [Category E] {F G : E ⥤ ∀ i, C i} (τ : ∀ i, F ⋙ Pi.eval C i ⟶ G ⋙ Pi.eval C i) : F ⟶ G where app := fun X i => (τ i).app X naturality _ _ f := by ext i exact (τ i).naturality f end NatTrans namespace NatIso variable {C} variable {D : I → Type u₂} [∀ i, Category.{v₂} (D i)] variable {F G : ∀ i, C i ⥤ D i} /-- Assemble an `I`-indexed family of natural isomorphisms into a single natural isomorphism. -/ @[simps] def pi (e : ∀ i, F i ≅ G i) : Functor.pi F ≅ Functor.pi G where hom := NatTrans.pi (fun i => (e i).hom) inv := NatTrans.pi (fun i => (e i).inv) /-- Assemble an `I`-indexed family of natural isomorphisms into a single natural isomorphism. -/ @[simps] def pi' {E : Type*} [Category E] {F G : E ⥤ ∀ i, C i} (e : ∀ i, F ⋙ Pi.eval C i ≅ G ⋙ Pi.eval C i) : F ≅ G where hom := NatTrans.pi' (fun i => (e i).hom) inv := NatTrans.pi' (fun i => (e i).inv) end NatIso variable {C} lemma isIso_pi_iff {X Y : ∀ i, C i} (f : X ⟶ Y) : IsIso f ↔ ∀ i, IsIso (f i) := by constructor · intro _ i exact (Pi.isoApp (asIso f) i).isIso_hom · intro exact ⟨fun i => inv (f i), by aesop_cat, by aesop_cat⟩ variable (C) /-- For a family of categories `C i` indexed by `I`, an equality `i = j` in `I` induces an equivalence `C i ≌ C j`. -/ def Pi.eqToEquivalence {i j : I} (h : i = j) : C i ≌ C j := by subst h; rfl /-- When `i = j`, projections `Pi.eval C i` and `Pi.eval C j` are related by the equivalence `Pi.eqToEquivalence C h : C i ≌ C j`. -/ @[simps!] def Pi.evalCompEqToEquivalenceFunctor {i j : I} (h : i = j) : Pi.eval C i ⋙ (Pi.eqToEquivalence C h).functor ≅ Pi.eval C j := eqToIso (by subst h; rfl) /-- The equivalences given by `Pi.eqToEquivalence` are compatible with reindexing. -/ @[simps!] def Pi.eqToEquivalenceFunctorIso (f : J → I) {i' j' : J} (h : i' = j') : (Pi.eqToEquivalence C (congr_arg f h)).functor ≅ (Pi.eqToEquivalence (fun i' => C (f i')) h).functor := eqToIso (by subst h; rfl) attribute [local simp] eqToHom_map /-- Reindexing a family of categories gives equivalent `Pi` categories. -/ @[simps] noncomputable def Pi.equivalenceOfEquiv (e : J ≃ I) : (∀ j, C (e j)) ≌ (∀ i, C i) where functor := Functor.pi' (fun i => Pi.eval _ (e.symm i) ⋙ (Pi.eqToEquivalence C (by simp)).functor) inverse := Functor.pi' (fun i' => Pi.eval _ (e i')) unitIso := NatIso.pi' (fun i' => Functor.leftUnitor _ ≪≫ (Pi.evalCompEqToEquivalenceFunctor (fun j => C (e j)) (e.symm_apply_apply i')).symm ≪≫ isoWhiskerLeft _ ((Pi.eqToEquivalenceFunctorIso C e (e.symm_apply_apply i')).symm) ≪≫ (Functor.pi'CompEval _ _).symm ≪≫ isoWhiskerLeft _ (Functor.pi'CompEval _ _).symm ≪≫ (Functor.associator _ _ _).symm) counitIso := NatIso.pi' (fun i => (Functor.associator _ _ _).symm ≪≫ isoWhiskerRight (Functor.pi'CompEval _ _) _ ≪≫ Pi.evalCompEqToEquivalenceFunctor C (e.apply_symm_apply i) ≪≫ (Functor.leftUnitor _).symm) /-- A product of categories indexed by `Option J` identifies to a binary product. -/ @[simps] def Pi.optionEquivalence (C' : Option J → Type u₁) [∀ i, Category.{v₁} (C' i)] : (∀ i, C' i) ≌ C' none × (∀ (j : J), C' (some j)) where functor := Functor.prod' (Pi.eval C' none) (Functor.pi' (fun i => (Pi.eval _ (some i)))) inverse := Functor.pi' (fun i => match i with | none => Prod.fst _ _ | some i => Prod.snd _ _ ⋙ (Pi.eval _ i)) unitIso := NatIso.pi' (fun i => match i with | none => Iso.refl _ | some i => Iso.refl _) counitIso := by exact Iso.refl _ namespace Equivalence variable {C} variable {D : I → Type u₂} [∀ i, Category.{v₂} (D i)] /-- Assemble an `I`-indexed family of equivalences of categories into a single equivalence. -/ @[simps] def pi (E : ∀ i, C i ≌ D i) : (∀ i, C i) ≌ (∀ i, D i) where functor := Functor.pi (fun i => (E i).functor) inverse := Functor.pi (fun i => (E i).inverse) unitIso := NatIso.pi (fun i => (E i).unitIso) counitIso := NatIso.pi (fun i => (E i).counitIso) instance (F : ∀ i, C i ⥤ D i) [∀ i, (F i).IsEquivalence] : (Functor.pi F).IsEquivalence := (pi (fun i => (F i).asEquivalence)).isEquivalence_functor end Equivalence end CategoryTheory
CategoryTheory\Preadditive\AdditiveFunctor.lean
/- Copyright (c) 2021 Adam Topaz. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Adam Topaz, Scott Morrison -/ import Mathlib.CategoryTheory.Limits.ExactFunctor import Mathlib.CategoryTheory.Limits.Preserves.Finite import Mathlib.CategoryTheory.Preadditive.Biproducts import Mathlib.CategoryTheory.Preadditive.FunctorCategory /-! # Additive Functors A functor between two preadditive categories is called *additive* provided that the induced map on hom types is a morphism of abelian groups. An additive functor between preadditive categories creates and preserves biproducts. Conversely, if `F : C ⥤ D` is a functor between preadditive categories, where `C` has binary biproducts, and if `F` preserves binary biproducts, then `F` is additive. We also define the category of bundled additive functors. # Implementation details `Functor.Additive` is a `Prop`-valued class, defined by saying that for every two objects `X` and `Y`, the map `F.map : (X ⟶ Y) → (F.obj X ⟶ F.obj Y)` is a morphism of abelian groups. -/ universe v₁ v₂ u₁ u₂ namespace CategoryTheory /-- A functor `F` is additive provided `F.map` is an additive homomorphism. -/ class Functor.Additive {C D : Type*} [Category C] [Category D] [Preadditive C] [Preadditive D] (F : C ⥤ D) : Prop where /-- the addition of two morphisms is mapped to the sum of their images -/ map_add : ∀ {X Y : C} {f g : X ⟶ Y}, F.map (f + g) = F.map f + F.map g := by aesop_cat section Preadditive namespace Functor section variable {C D E : Type*} [Category C] [Category D] [Category E] [Preadditive C] [Preadditive D] [Preadditive E] (F : C ⥤ D) [Functor.Additive F] @[simp] theorem map_add {X Y : C} {f g : X ⟶ Y} : F.map (f + g) = F.map f + F.map g := Functor.Additive.map_add -- Porting note: it was originally @[simps (config := .asFn)] /-- `F.mapAddHom` is an additive homomorphism whose underlying function is `F.map`. -/ @[simps!] def mapAddHom {X Y : C} : (X ⟶ Y) →+ (F.obj X ⟶ F.obj Y) := AddMonoidHom.mk' (fun f => F.map f) fun _ _ => F.map_add theorem coe_mapAddHom {X Y : C} : ⇑(F.mapAddHom : (X ⟶ Y) →+ _) = F.map := rfl instance (priority := 100) preservesZeroMorphisms_of_additive : PreservesZeroMorphisms F where map_zero _ _ := F.mapAddHom.map_zero instance : Additive (𝟭 C) where instance {E : Type*} [Category E] [Preadditive E] (G : D ⥤ E) [Functor.Additive G] : Additive (F ⋙ G) where @[simp] theorem map_neg {X Y : C} {f : X ⟶ Y} : F.map (-f) = -F.map f := (F.mapAddHom : (X ⟶ Y) →+ (F.obj X ⟶ F.obj Y)).map_neg _ @[simp] theorem map_sub {X Y : C} {f g : X ⟶ Y} : F.map (f - g) = F.map f - F.map g := (F.mapAddHom : (X ⟶ Y) →+ (F.obj X ⟶ F.obj Y)).map_sub _ _ theorem map_nsmul {X Y : C} {f : X ⟶ Y} {n : ℕ} : F.map (n • f) = n • F.map f := (F.mapAddHom : (X ⟶ Y) →+ (F.obj X ⟶ F.obj Y)).map_nsmul _ _ -- You can alternatively just use `Functor.map_smul` here, with an explicit `(r : ℤ)` argument. theorem map_zsmul {X Y : C} {f : X ⟶ Y} {r : ℤ} : F.map (r • f) = r • F.map f := (F.mapAddHom : (X ⟶ Y) →+ (F.obj X ⟶ F.obj Y)).map_zsmul _ _ @[simp] nonrec theorem map_sum {X Y : C} {α : Type*} (f : α → (X ⟶ Y)) (s : Finset α) : F.map (∑ a ∈ s, f a) = ∑ a ∈ s, F.map (f a) := map_sum F.mapAddHom f s variable {F} lemma additive_of_iso {G : C ⥤ D} (e : F ≅ G) : G.Additive := by constructor intro X Y f g simp only [← NatIso.naturality_1 e (f + g), map_add, Preadditive.add_comp, NatTrans.naturality, Preadditive.comp_add, Iso.inv_hom_id_app_assoc] variable (F) lemma additive_of_full_essSurj_comp [Full F] [EssSurj F] (G : D ⥤ E) [(F ⋙ G).Additive] : G.Additive where map_add {X Y f g} := by obtain ⟨f', hf'⟩ := F.map_surjective ((F.objObjPreimageIso X).hom ≫ f ≫ (F.objObjPreimageIso Y).inv) obtain ⟨g', hg'⟩ := F.map_surjective ((F.objObjPreimageIso X).hom ≫ g ≫ (F.objObjPreimageIso Y).inv) simp only [← cancel_mono (G.map (F.objObjPreimageIso Y).inv), ← cancel_epi (G.map (F.objObjPreimageIso X).hom), Preadditive.add_comp, Preadditive.comp_add, ← Functor.map_comp] erw [← hf', ← hg', ← (F ⋙ G).map_add] dsimp rw [F.map_add] lemma additive_of_comp_faithful (F : C ⥤ D) (G : D ⥤ E) [G.Additive] [(F ⋙ G).Additive] [Faithful G] : F.Additive where map_add {_ _ f₁ f₂} := G.map_injective (by rw [← Functor.comp_map, G.map_add, (F ⋙ G).map_add, Functor.comp_map, Functor.comp_map]) open ZeroObject Limits in lemma hasZeroObject_of_additive [HasZeroObject C] : HasZeroObject D where zero := ⟨F.obj 0, by rw [IsZero.iff_id_eq_zero, ← F.map_id, id_zero, F.map_zero]⟩ end section InducedCategory variable {C : Type*} {D : Type*} [Category D] [Preadditive D] (F : C → D) instance inducedFunctor_additive : Functor.Additive (inducedFunctor F) where end InducedCategory instance fullSubcategoryInclusion_additive {C : Type*} [Category C] [Preadditive C] (Z : C → Prop) : (fullSubcategoryInclusion Z).Additive where section -- To talk about preservation of biproducts we need to specify universes explicitly. noncomputable section variable {C : Type u₁} {D : Type u₂} [Category.{v₁} C] [Category.{v₂} D] [Preadditive C] [Preadditive D] (F : C ⥤ D) open CategoryTheory.Limits open CategoryTheory.Preadditive instance (priority := 100) preservesFiniteBiproductsOfAdditive [Additive F] : PreservesFiniteBiproducts F where preserves := { preserves := { preserves := fun hb => isBilimitOfTotal _ (by simp_rw [F.mapBicone_π, F.mapBicone_ι, ← F.map_comp] erw [← F.map_sum, ← F.map_id, IsBilimit.total hb])} } theorem additive_of_preservesBinaryBiproducts [HasBinaryBiproducts C] [PreservesZeroMorphisms F] [PreservesBinaryBiproducts F] : Additive F where map_add {X Y f g} := by rw [biprod.add_eq_lift_id_desc, F.map_comp, ← biprod.lift_mapBiprod, ← biprod.mapBiprod_hom_desc, Category.assoc, Iso.inv_hom_id_assoc, F.map_id, biprod.add_eq_lift_id_desc] lemma additive_of_preserves_binary_products [HasBinaryProducts C] [PreservesLimitsOfShape (Discrete WalkingPair) F] [F.PreservesZeroMorphisms] : F.Additive := by have : HasBinaryBiproducts C := HasBinaryBiproducts.of_hasBinaryProducts have := preservesBinaryBiproductsOfPreservesBinaryProducts F exact Functor.additive_of_preservesBinaryBiproducts F end end end Functor namespace Equivalence variable {C D : Type*} [Category C] [Category D] [Preadditive C] [Preadditive D] instance inverse_additive (e : C ≌ D) [e.functor.Additive] : e.inverse.Additive where map_add {f g} := e.functor.map_injective (by simp) end Equivalence section variable (C D : Type*) [Category C] [Category D] [Preadditive C] [Preadditive D] -- porting note (#5171): removed @[nolint has_nonempty_instance] /-- Bundled additive functors. -/ def AdditiveFunctor := FullSubcategory fun F : C ⥤ D => F.Additive instance : Category (AdditiveFunctor C D) := FullSubcategory.category _ /-- the category of additive functors is denoted `C ⥤+ D` -/ infixr:26 " ⥤+ " => AdditiveFunctor instance : Preadditive (C ⥤+ D) := Preadditive.inducedCategory _ /-- An additive functor is in particular a functor. -/ def AdditiveFunctor.forget : (C ⥤+ D) ⥤ C ⥤ D := fullSubcategoryInclusion _ instance : (AdditiveFunctor.forget C D).Full := FullSubcategory.full _ variable {C D} /-- Turn an additive functor into an object of the category `AdditiveFunctor C D`. -/ def AdditiveFunctor.of (F : C ⥤ D) [F.Additive] : C ⥤+ D := ⟨F, inferInstance⟩ @[simp] theorem AdditiveFunctor.of_fst (F : C ⥤ D) [F.Additive] : (AdditiveFunctor.of F).1 = F := rfl @[simp] theorem AdditiveFunctor.forget_obj (F : C ⥤+ D) : (AdditiveFunctor.forget C D).obj F = F.1 := rfl theorem AdditiveFunctor.forget_obj_of (F : C ⥤ D) [F.Additive] : (AdditiveFunctor.forget C D).obj (AdditiveFunctor.of F) = F := rfl @[simp] theorem AdditiveFunctor.forget_map (F G : C ⥤+ D) (α : F ⟶ G) : (AdditiveFunctor.forget C D).map α = α := rfl instance : Functor.Additive (AdditiveFunctor.forget C D) where map_add := rfl instance (F : C ⥤+ D) : Functor.Additive F.1 := F.2 end section Exact open CategoryTheory.Limits variable (C : Type u₁) (D : Type u₂) [Category.{v₁} C] [Category.{v₂} D] [Preadditive C] variable [Preadditive D] [HasZeroObject C] [HasZeroObject D] [HasBinaryBiproducts C] section attribute [local instance] preservesBinaryBiproductsOfPreservesBinaryProducts attribute [local instance] preservesBinaryBiproductsOfPreservesBinaryCoproducts /-- Turn a left exact functor into an additive functor. -/ def AdditiveFunctor.ofLeftExact : (C ⥤ₗ D) ⥤ C ⥤+ D := FullSubcategory.map fun F ⟨_⟩ => Functor.additive_of_preservesBinaryBiproducts F instance : (AdditiveFunctor.ofLeftExact C D).Full := FullSubcategory.full_map _ instance : (AdditiveFunctor.ofLeftExact C D).Faithful := FullSubcategory.faithful_map _ /-- Turn a right exact functor into an additive functor. -/ def AdditiveFunctor.ofRightExact : (C ⥤ᵣ D) ⥤ C ⥤+ D := FullSubcategory.map fun F ⟨_⟩ => Functor.additive_of_preservesBinaryBiproducts F instance : (AdditiveFunctor.ofRightExact C D).Full := FullSubcategory.full_map _ instance : (AdditiveFunctor.ofRightExact C D).Faithful := FullSubcategory.faithful_map _ /-- Turn an exact functor into an additive functor. -/ def AdditiveFunctor.ofExact : (C ⥤ₑ D) ⥤ C ⥤+ D := FullSubcategory.map fun F ⟨⟨_⟩, _⟩ => Functor.additive_of_preservesBinaryBiproducts F instance : (AdditiveFunctor.ofExact C D).Full := FullSubcategory.full_map _ instance : (AdditiveFunctor.ofExact C D).Faithful := FullSubcategory.faithful_map _ end variable {C D} @[simp] theorem AdditiveFunctor.ofLeftExact_obj_fst (F : C ⥤ₗ D) : ((AdditiveFunctor.ofLeftExact C D).obj F).obj = F.obj := rfl @[simp] theorem AdditiveFunctor.ofRightExact_obj_fst (F : C ⥤ᵣ D) : ((AdditiveFunctor.ofRightExact C D).obj F).obj = F.obj := rfl @[simp] theorem AdditiveFunctor.ofExact_obj_fst (F : C ⥤ₑ D) : ((AdditiveFunctor.ofExact C D).obj F).obj = F.obj := rfl @[simp] theorem AdditiveFunctor.ofLeftExact_map {F G : C ⥤ₗ D} (α : F ⟶ G) : (AdditiveFunctor.ofLeftExact C D).map α = α := rfl @[simp] theorem AdditiveFunctor.ofRightExact_map {F G : C ⥤ᵣ D} (α : F ⟶ G) : (AdditiveFunctor.ofRightExact C D).map α = α := rfl @[simp] theorem AdditiveFunctor.ofExact_map {F G : C ⥤ₑ D} (α : F ⟶ G) : (AdditiveFunctor.ofExact C D).map α = α := rfl end Exact end Preadditive end CategoryTheory
CategoryTheory\Preadditive\Basic.lean
/- Copyright (c) 2020 Markus Himmel. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Markus Himmel, Jakob von Raumer -/ import Mathlib.Algebra.BigOperators.Group.Finset import Mathlib.Algebra.Group.Hom.Defs import Mathlib.Algebra.Module.Defs import Mathlib.CategoryTheory.Endomorphism import Mathlib.CategoryTheory.Limits.Shapes.Kernels /-! # Preadditive categories A preadditive category is a category in which `X ⟶ Y` is an abelian group in such a way that composition of morphisms is linear in both variables. This file contains a definition of preadditive category that directly encodes the definition given above. The definition could also be phrased as follows: A preadditive category is a category enriched over the category of Abelian groups. Once the general framework to state this in Lean is available, the contents of this file should become obsolete. ## Main results * Definition of preadditive categories and basic properties * In a preadditive category, `f : Q ⟶ R` is mono if and only if `g ≫ f = 0 → g = 0` for all composable `g`. * A preadditive category with kernels has equalizers. ## Implementation notes The simp normal form for negation and composition is to push negations as far as possible to the outside. For example, `f ≫ (-g)` and `(-f) ≫ g` both become `-(f ≫ g)`, and `(-f) ≫ (-g)` is simplified to `f ≫ g`. ## References * [F. Borceux, *Handbook of Categorical Algebra 2*][borceux-vol2] ## Tags additive, preadditive, Hom group, Ab-category, Ab-enriched -/ universe v u open CategoryTheory.Limits namespace CategoryTheory variable (C : Type u) [Category.{v} C] /-- A category is called preadditive if `P ⟶ Q` is an abelian group such that composition is linear in both variables. -/ class Preadditive where homGroup : ∀ P Q : C, AddCommGroup (P ⟶ Q) := by infer_instance add_comp : ∀ (P Q R : C) (f f' : P ⟶ Q) (g : Q ⟶ R), (f + f') ≫ g = f ≫ g + f' ≫ g := by aesop_cat comp_add : ∀ (P Q R : C) (f : P ⟶ Q) (g g' : Q ⟶ R), f ≫ (g + g') = f ≫ g + f ≫ g' := by aesop_cat attribute [inherit_doc Preadditive] Preadditive.homGroup Preadditive.add_comp Preadditive.comp_add attribute [instance] Preadditive.homGroup -- Porting note: simp can prove reassoc version attribute [reassoc, simp] Preadditive.add_comp attribute [reassoc] Preadditive.comp_add -- (the linter doesn't like `simp` on this lemma) attribute [simp] Preadditive.comp_add end CategoryTheory open CategoryTheory namespace CategoryTheory namespace Preadditive section Preadditive open AddMonoidHom variable {C : Type u} [Category.{v} C] [Preadditive C] section InducedCategory universe u' variable {D : Type u'} (F : D → C) instance inducedCategory : Preadditive.{v} (InducedCategory C F) where homGroup P Q := @Preadditive.homGroup C _ _ (F P) (F Q) add_comp _ _ _ _ _ _ := add_comp _ _ _ _ _ _ comp_add _ _ _ _ _ _ := comp_add _ _ _ _ _ _ end InducedCategory instance fullSubcategory (Z : C → Prop) : Preadditive.{v} (FullSubcategory Z) where homGroup P Q := @Preadditive.homGroup C _ _ P.obj Q.obj add_comp _ _ _ _ _ _ := add_comp _ _ _ _ _ _ comp_add _ _ _ _ _ _ := comp_add _ _ _ _ _ _ instance (X : C) : AddCommGroup (End X) := by dsimp [End] infer_instance /-- Composition by a fixed left argument as a group homomorphism -/ def leftComp {P Q : C} (R : C) (f : P ⟶ Q) : (Q ⟶ R) →+ (P ⟶ R) := mk' (fun g => f ≫ g) fun g g' => by simp /-- Composition by a fixed right argument as a group homomorphism -/ def rightComp (P : C) {Q R : C} (g : Q ⟶ R) : (P ⟶ Q) →+ (P ⟶ R) := mk' (fun f => f ≫ g) fun f f' => by simp variable {P Q R : C} (f f' : P ⟶ Q) (g g' : Q ⟶ R) /-- Composition as a bilinear group homomorphism -/ def compHom : (P ⟶ Q) →+ (Q ⟶ R) →+ (P ⟶ R) := AddMonoidHom.mk' (fun f => leftComp _ f) fun f₁ f₂ => AddMonoidHom.ext fun g => (rightComp _ g).map_add f₁ f₂ -- Porting note: simp can prove the reassoc version @[reassoc, simp] theorem sub_comp : (f - f') ≫ g = f ≫ g - f' ≫ g := map_sub (rightComp P g) f f' -- The redundant simp lemma linter says that simp can prove the reassoc version of this lemma. @[reassoc, simp] theorem comp_sub : f ≫ (g - g') = f ≫ g - f ≫ g' := map_sub (leftComp R f) g g' -- Porting note: simp can prove the reassoc version @[reassoc, simp] theorem neg_comp : (-f) ≫ g = -f ≫ g := map_neg (rightComp P g) f -- The redundant simp lemma linter says that simp can prove the reassoc version of this lemma. @[reassoc, simp] theorem comp_neg : f ≫ (-g) = -f ≫ g := map_neg (leftComp R f) g @[reassoc] theorem neg_comp_neg : (-f) ≫ (-g) = f ≫ g := by simp theorem nsmul_comp (n : ℕ) : (n • f) ≫ g = n • f ≫ g := map_nsmul (rightComp P g) n f theorem comp_nsmul (n : ℕ) : f ≫ (n • g) = n • f ≫ g := map_nsmul (leftComp R f) n g theorem zsmul_comp (n : ℤ) : (n • f) ≫ g = n • f ≫ g := map_zsmul (rightComp P g) n f theorem comp_zsmul (n : ℤ) : f ≫ (n • g) = n • f ≫ g := map_zsmul (leftComp R f) n g @[reassoc] theorem comp_sum {P Q R : C} {J : Type*} (s : Finset J) (f : P ⟶ Q) (g : J → (Q ⟶ R)) : (f ≫ ∑ j ∈ s, g j) = ∑ j ∈ s, f ≫ g j := map_sum (leftComp R f) _ _ @[reassoc] theorem sum_comp {P Q R : C} {J : Type*} (s : Finset J) (f : J → (P ⟶ Q)) (g : Q ⟶ R) : (∑ j ∈ s, f j) ≫ g = ∑ j ∈ s, f j ≫ g := map_sum (rightComp P g) _ _ instance {P Q : C} {f : P ⟶ Q} [Epi f] : Epi (-f) := ⟨fun g g' H => by rwa [neg_comp, neg_comp, ← comp_neg, ← comp_neg, cancel_epi, neg_inj] at H⟩ instance {P Q : C} {f : P ⟶ Q} [Mono f] : Mono (-f) := ⟨fun g g' H => by rwa [comp_neg, comp_neg, ← neg_comp, ← neg_comp, cancel_mono, neg_inj] at H⟩ instance (priority := 100) preadditiveHasZeroMorphisms : HasZeroMorphisms C where zero := inferInstance comp_zero f R := show leftComp R f 0 = 0 from map_zero _ zero_comp P _ _ f := show rightComp P f 0 = 0 from map_zero _ /-- Porting note: adding this before the ring instance allowed moduleEndRight to find the correct Monoid structure on End. Moved both down after preadditiveHasZeroMorphisms to make use of them -/ instance {X : C} : Semiring (End X) := { End.monoid with zero_mul := fun f => by dsimp [mul]; exact HasZeroMorphisms.comp_zero f _ mul_zero := fun f => by dsimp [mul]; exact HasZeroMorphisms.zero_comp _ f left_distrib := fun f g h => Preadditive.add_comp X X X g h f right_distrib := fun f g h => Preadditive.comp_add X X X h f g } /-- Porting note: It looks like Ring's parent classes changed in Lean 4 so the previous instance needed modification. Was following my nose here. -/ instance {X : C} : Ring (End X) := { (inferInstance : Semiring (End X)), (inferInstance : AddCommGroup (End X)) with add_left_neg := add_left_neg } instance moduleEndRight {X Y : C} : Module (End Y) (X ⟶ Y) where smul_add _ _ _ := add_comp _ _ _ _ _ _ smul_zero _ := zero_comp add_smul _ _ _ := comp_add _ _ _ _ _ _ zero_smul _ := comp_zero theorem mono_of_cancel_zero {Q R : C} (f : Q ⟶ R) (h : ∀ {P : C} (g : P ⟶ Q), g ≫ f = 0 → g = 0) : Mono f where right_cancellation := fun {Z} g₁ g₂ hg => sub_eq_zero.1 <| h _ <| (map_sub (rightComp Z f) g₁ g₂).trans <| sub_eq_zero.2 hg theorem mono_iff_cancel_zero {Q R : C} (f : Q ⟶ R) : Mono f ↔ ∀ (P : C) (g : P ⟶ Q), g ≫ f = 0 → g = 0 := ⟨fun _ _ _ => zero_of_comp_mono _, mono_of_cancel_zero f⟩ theorem mono_of_kernel_zero {X Y : C} {f : X ⟶ Y} [HasLimit (parallelPair f 0)] (w : kernel.ι f = 0) : Mono f := mono_of_cancel_zero f fun g h => by rw [← kernel.lift_ι f g h, w, Limits.comp_zero] lemma mono_of_isZero_kernel' {X Y : C} {f : X ⟶ Y} (c : KernelFork f) (hc : IsLimit c) (h : IsZero c.pt) : Mono f := mono_of_cancel_zero _ (fun g hg => by obtain ⟨a, ha⟩ := KernelFork.IsLimit.lift' hc _ hg rw [← ha, h.eq_of_tgt a 0, Limits.zero_comp]) lemma mono_of_isZero_kernel {X Y : C} (f : X ⟶ Y) [HasKernel f] (h : IsZero (kernel f)) : Mono f := mono_of_isZero_kernel' _ (kernelIsKernel _) h theorem epi_of_cancel_zero {P Q : C} (f : P ⟶ Q) (h : ∀ {R : C} (g : Q ⟶ R), f ≫ g = 0 → g = 0) : Epi f := ⟨fun {Z} g g' hg => sub_eq_zero.1 <| h _ <| (map_sub (leftComp Z f) g g').trans <| sub_eq_zero.2 hg⟩ theorem epi_iff_cancel_zero {P Q : C} (f : P ⟶ Q) : Epi f ↔ ∀ (R : C) (g : Q ⟶ R), f ≫ g = 0 → g = 0 := ⟨fun _ _ _ => zero_of_epi_comp _, epi_of_cancel_zero f⟩ theorem epi_of_cokernel_zero {X Y : C} {f : X ⟶ Y} [HasColimit (parallelPair f 0)] (w : cokernel.π f = 0) : Epi f := epi_of_cancel_zero f fun g h => by rw [← cokernel.π_desc f g h, w, Limits.zero_comp] lemma epi_of_isZero_cokernel' {X Y : C} {f : X ⟶ Y} (c : CokernelCofork f) (hc : IsColimit c) (h : IsZero c.pt) : Epi f := epi_of_cancel_zero _ (fun g hg => by obtain ⟨a, ha⟩ := CokernelCofork.IsColimit.desc' hc _ hg rw [← ha, h.eq_of_src a 0, Limits.comp_zero]) lemma epi_of_isZero_cokernel {X Y : C} (f : X ⟶ Y) [HasCokernel f] (h : IsZero (cokernel f)) : Epi f := epi_of_isZero_cokernel' _ (cokernelIsCokernel _) h namespace IsIso @[simp] theorem comp_left_eq_zero [IsIso f] : f ≫ g = 0 ↔ g = 0 := by rw [← IsIso.eq_inv_comp, Limits.comp_zero] @[simp] theorem comp_right_eq_zero [IsIso g] : f ≫ g = 0 ↔ f = 0 := by rw [← IsIso.eq_comp_inv, Limits.zero_comp] end IsIso open ZeroObject variable [HasZeroObject C] theorem mono_of_kernel_iso_zero {X Y : C} {f : X ⟶ Y} [HasLimit (parallelPair f 0)] (w : kernel f ≅ 0) : Mono f := mono_of_kernel_zero (zero_of_source_iso_zero _ w) theorem epi_of_cokernel_iso_zero {X Y : C} {f : X ⟶ Y} [HasColimit (parallelPair f 0)] (w : cokernel f ≅ 0) : Epi f := epi_of_cokernel_zero (zero_of_target_iso_zero _ w) end Preadditive section Equalizers variable {C : Type u} [Category.{v} C] [Preadditive C] section variable {X Y : C} {f : X ⟶ Y} {g : X ⟶ Y} /-- Map a kernel cone on the difference of two morphisms to the equalizer fork. -/ @[simps! pt] def forkOfKernelFork (c : KernelFork (f - g)) : Fork f g := Fork.ofι c.ι <| by rw [← sub_eq_zero, ← comp_sub, c.condition] @[simp] theorem forkOfKernelFork_ι (c : KernelFork (f - g)) : (forkOfKernelFork c).ι = c.ι := rfl /-- Map any equalizer fork to a cone on the difference of the two morphisms. -/ def kernelForkOfFork (c : Fork f g) : KernelFork (f - g) := Fork.ofι c.ι <| by rw [comp_sub, comp_zero, sub_eq_zero, c.condition] @[simp] theorem kernelForkOfFork_ι (c : Fork f g) : (kernelForkOfFork c).ι = c.ι := rfl @[simp] theorem kernelForkOfFork_ofι {P : C} (ι : P ⟶ X) (w : ι ≫ f = ι ≫ g) : kernelForkOfFork (Fork.ofι ι w) = KernelFork.ofι ι (by simp [w]) := rfl /-- A kernel of `f - g` is an equalizer of `f` and `g`. -/ def isLimitForkOfKernelFork {c : KernelFork (f - g)} (i : IsLimit c) : IsLimit (forkOfKernelFork c) := Fork.IsLimit.mk' _ fun s => ⟨i.lift (kernelForkOfFork s), i.fac _ _, fun h => by apply Fork.IsLimit.hom_ext i; aesop_cat⟩ @[simp] theorem isLimitForkOfKernelFork_lift {c : KernelFork (f - g)} (i : IsLimit c) (s : Fork f g) : (isLimitForkOfKernelFork i).lift s = i.lift (kernelForkOfFork s) := rfl /-- An equalizer of `f` and `g` is a kernel of `f - g`. -/ def isLimitKernelForkOfFork {c : Fork f g} (i : IsLimit c) : IsLimit (kernelForkOfFork c) := Fork.IsLimit.mk' _ fun s => ⟨i.lift (forkOfKernelFork s), i.fac _ _, fun h => by apply Fork.IsLimit.hom_ext i; aesop_cat⟩ variable (f g) /-- A preadditive category has an equalizer for `f` and `g` if it has a kernel for `f - g`. -/ theorem hasEqualizer_of_hasKernel [HasKernel (f - g)] : HasEqualizer f g := HasLimit.mk { cone := forkOfKernelFork _ isLimit := isLimitForkOfKernelFork (equalizerIsEqualizer (f - g) 0) } /-- A preadditive category has a kernel for `f - g` if it has an equalizer for `f` and `g`. -/ theorem hasKernel_of_hasEqualizer [HasEqualizer f g] : HasKernel (f - g) := HasLimit.mk { cone := kernelForkOfFork (equalizer.fork f g) isLimit := isLimitKernelForkOfFork (limit.isLimit (parallelPair f g)) } variable {f g} /-- Map a cokernel cocone on the difference of two morphisms to the coequalizer cofork. -/ @[simps! pt] def coforkOfCokernelCofork (c : CokernelCofork (f - g)) : Cofork f g := Cofork.ofπ c.π <| by rw [← sub_eq_zero, ← sub_comp, c.condition] @[simp] theorem coforkOfCokernelCofork_π (c : CokernelCofork (f - g)) : (coforkOfCokernelCofork c).π = c.π := rfl /-- Map any coequalizer cofork to a cocone on the difference of the two morphisms. -/ def cokernelCoforkOfCofork (c : Cofork f g) : CokernelCofork (f - g) := Cofork.ofπ c.π <| by rw [sub_comp, zero_comp, sub_eq_zero, c.condition] @[simp] theorem cokernelCoforkOfCofork_π (c : Cofork f g) : (cokernelCoforkOfCofork c).π = c.π := rfl @[simp] theorem cokernelCoforkOfCofork_ofπ {P : C} (π : Y ⟶ P) (w : f ≫ π = g ≫ π) : cokernelCoforkOfCofork (Cofork.ofπ π w) = CokernelCofork.ofπ π (by simp [w]) := rfl /-- A cokernel of `f - g` is a coequalizer of `f` and `g`. -/ def isColimitCoforkOfCokernelCofork {c : CokernelCofork (f - g)} (i : IsColimit c) : IsColimit (coforkOfCokernelCofork c) := Cofork.IsColimit.mk' _ fun s => ⟨i.desc (cokernelCoforkOfCofork s), i.fac _ _, fun h => by apply Cofork.IsColimit.hom_ext i; aesop_cat⟩ @[simp] theorem isColimitCoforkOfCokernelCofork_desc {c : CokernelCofork (f - g)} (i : IsColimit c) (s : Cofork f g) : (isColimitCoforkOfCokernelCofork i).desc s = i.desc (cokernelCoforkOfCofork s) := rfl /-- A coequalizer of `f` and `g` is a cokernel of `f - g`. -/ def isColimitCokernelCoforkOfCofork {c : Cofork f g} (i : IsColimit c) : IsColimit (cokernelCoforkOfCofork c) := Cofork.IsColimit.mk' _ fun s => ⟨i.desc (coforkOfCokernelCofork s), i.fac _ _, fun h => by apply Cofork.IsColimit.hom_ext i; aesop_cat⟩ variable (f g) /-- A preadditive category has a coequalizer for `f` and `g` if it has a cokernel for `f - g`. -/ theorem hasCoequalizer_of_hasCokernel [HasCokernel (f - g)] : HasCoequalizer f g := HasColimit.mk { cocone := coforkOfCokernelCofork _ isColimit := isColimitCoforkOfCokernelCofork (coequalizerIsCoequalizer (f - g) 0) } /-- A preadditive category has a cokernel for `f - g` if it has a coequalizer for `f` and `g`. -/ theorem hasCokernel_of_hasCoequalizer [HasCoequalizer f g] : HasCokernel (f - g) := HasColimit.mk { cocone := cokernelCoforkOfCofork (coequalizer.cofork f g) isColimit := isColimitCokernelCoforkOfCofork (colimit.isColimit (parallelPair f g)) } end /-- If a preadditive category has all kernels, then it also has all equalizers. -/ theorem hasEqualizers_of_hasKernels [HasKernels C] : HasEqualizers C := @hasEqualizers_of_hasLimit_parallelPair _ _ fun {_} {_} f g => hasEqualizer_of_hasKernel f g /-- If a preadditive category has all cokernels, then it also has all coequalizers. -/ theorem hasCoequalizers_of_hasCokernels [HasCokernels C] : HasCoequalizers C := @hasCoequalizers_of_hasColimit_parallelPair _ _ fun {_} {_} f g => hasCoequalizer_of_hasCokernel f g end Equalizers section variable {C : Type*} [Category C] [Preadditive C] {X Y : C} instance : SMul (Units ℤ) (X ≅ Y) where smul a e := { hom := (a : ℤ) • e.hom inv := ((a⁻¹ : Units ℤ) : ℤ) • e.inv hom_inv_id := by simp only [comp_zsmul, zsmul_comp, smul_smul, Units.inv_mul, one_smul, e.hom_inv_id] inv_hom_id := by simp only [comp_zsmul, zsmul_comp, smul_smul, Units.mul_inv, one_smul, e.inv_hom_id] } @[simp] lemma smul_iso_hom (a : Units ℤ) (e : X ≅ Y) : (a • e).hom = a • e.hom := rfl @[simp] lemma smul_iso_inv (a : Units ℤ) (e : X ≅ Y) : (a • e).inv = a⁻¹ • e.inv := rfl instance : Neg (X ≅ Y) where neg e := { hom := -e.hom inv := -e.inv } @[simp] lemma neg_iso_hom (e : X ≅ Y) : (-e).hom = -e.hom := rfl @[simp] lemma neg_iso_inv (e : X ≅ Y) : (-e).inv = -e.inv := rfl end end Preadditive end CategoryTheory
CategoryTheory\Preadditive\Biproducts.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.Algebra.Group.Ext import Mathlib.CategoryTheory.Limits.Shapes.Biproducts import Mathlib.CategoryTheory.Limits.Preserves.Shapes.BinaryProducts import Mathlib.CategoryTheory.Limits.Preserves.Shapes.Biproducts import Mathlib.CategoryTheory.Limits.Preserves.Shapes.Products import Mathlib.CategoryTheory.Preadditive.Basic import Mathlib.Tactic.Abel /-! # Basic facts about biproducts in preadditive categories. In (or between) preadditive categories, * Any biproduct satisfies the equality `total : ∑ j : J, biproduct.π f j ≫ biproduct.ι f j = 𝟙 (⨁ f)`, or, in the binary case, `total : fst ≫ inl + snd ≫ inr = 𝟙 X`. * Any (binary) `product` or (binary) `coproduct` is a (binary) `biproduct`. * In any category (with zero morphisms), if `biprod.map f g` is an isomorphism, then both `f` and `g` are isomorphisms. * If `f` is a morphism `X₁ ⊞ X₂ ⟶ Y₁ ⊞ Y₂` whose `X₁ ⟶ Y₁` entry is an isomorphism, then we can construct isomorphisms `L : X₁ ⊞ X₂ ≅ X₁ ⊞ X₂` and `R : Y₁ ⊞ Y₂ ≅ Y₁ ⊞ Y₂` so that `L.hom ≫ g ≫ R.hom` is diagonal (with `X₁ ⟶ Y₁` component still `f`), via Gaussian elimination. * As a corollary of the previous two facts, if we have an isomorphism `X₁ ⊞ X₂ ≅ Y₁ ⊞ Y₂` whose `X₁ ⟶ Y₁` entry is an isomorphism, we can construct an isomorphism `X₂ ≅ Y₂`. * If `f : W ⊞ X ⟶ Y ⊞ Z` is an isomorphism, either `𝟙 W = 0`, or at least one of the component maps `W ⟶ Y` and `W ⟶ Z` is nonzero. * If `f : ⨁ S ⟶ ⨁ T` is an isomorphism, then every column (corresponding to a nonzero summand in the domain) has some nonzero matrix entry. * A functor preserves a biproduct if and only if it preserves the corresponding product if and only if it preserves the corresponding coproduct. There are connections between this material and the special case of the category whose morphisms are matrices over a ring, in particular the Schur complement (see `Mathlib.LinearAlgebra.Matrix.SchurComplement`). In particular, the declarations `CategoryTheory.Biprod.isoElim`, `CategoryTheory.Biprod.gaussian` and `Matrix.invertibleOfFromBlocks₁₁Invertible` are all closely related. -/ open CategoryTheory open CategoryTheory.Preadditive open CategoryTheory.Limits open CategoryTheory.Functor open CategoryTheory.Preadditive open scoped Classical universe v v' u u' noncomputable section namespace CategoryTheory variable {C : Type u} [Category.{v} C] [Preadditive C] namespace Limits section Fintype variable {J : Type} [Fintype J] /-- In a preadditive category, we can construct a biproduct for `f : J → C` from any bicone `b` for `f` satisfying `total : ∑ j : J, b.π j ≫ b.ι j = 𝟙 b.X`. (That is, such a bicone is a limit cone and a colimit cocone.) -/ def isBilimitOfTotal {f : J → C} (b : Bicone f) (total : ∑ j : J, b.π j ≫ b.ι j = 𝟙 b.pt) : b.IsBilimit where isLimit := { lift := fun s => ∑ j : J, s.π.app ⟨j⟩ ≫ b.ι j uniq := fun s m h => by erw [← Category.comp_id m, ← total, comp_sum] apply Finset.sum_congr rfl intro j _ have reassoced : m ≫ Bicone.π b j ≫ Bicone.ι b j = s.π.app ⟨j⟩ ≫ Bicone.ι b j := by erw [← Category.assoc, eq_whisker (h ⟨j⟩)] rw [reassoced] fac := fun s j => by cases j simp only [sum_comp, Category.assoc, Bicone.toCone_π_app, b.ι_π, comp_dite] -- See note [dsimp, simp]. dsimp simp } isColimit := { desc := fun s => ∑ j : J, b.π j ≫ s.ι.app ⟨j⟩ uniq := fun s m h => by erw [← Category.id_comp m, ← total, sum_comp] apply Finset.sum_congr rfl intro j _ erw [Category.assoc, h ⟨j⟩] fac := fun s j => by cases j simp only [comp_sum, ← Category.assoc, Bicone.toCocone_ι_app, b.ι_π, dite_comp] dsimp; simp } theorem IsBilimit.total {f : J → C} {b : Bicone f} (i : b.IsBilimit) : ∑ j : J, b.π j ≫ b.ι j = 𝟙 b.pt := i.isLimit.hom_ext fun j => by cases j simp [sum_comp, b.ι_π, comp_dite] /-- In a preadditive category, we can construct a biproduct for `f : J → C` from any bicone `b` for `f` satisfying `total : ∑ j : J, b.π j ≫ b.ι j = 𝟙 b.X`. (That is, such a bicone is a limit cone and a colimit cocone.) -/ theorem hasBiproduct_of_total {f : J → C} (b : Bicone f) (total : ∑ j : J, b.π j ≫ b.ι j = 𝟙 b.pt) : HasBiproduct f := HasBiproduct.mk { bicone := b isBilimit := isBilimitOfTotal b total } /-- In a preadditive category, any finite bicone which is a limit cone is in fact a bilimit bicone. -/ def isBilimitOfIsLimit {f : J → C} (t : Bicone f) (ht : IsLimit t.toCone) : t.IsBilimit := isBilimitOfTotal _ <| ht.hom_ext fun j => by cases j simp [sum_comp, t.ι_π, dite_comp, comp_dite] /-- We can turn any limit cone over a pair into a bilimit bicone. -/ def biconeIsBilimitOfLimitConeOfIsLimit {f : J → C} {t : Cone (Discrete.functor f)} (ht : IsLimit t) : (Bicone.ofLimitCone ht).IsBilimit := isBilimitOfIsLimit _ <| IsLimit.ofIsoLimit ht <| Cones.ext (Iso.refl _) (by aesop_cat) /-- In a preadditive category, any finite bicone which is a colimit cocone is in fact a bilimit bicone. -/ def isBilimitOfIsColimit {f : J → C} (t : Bicone f) (ht : IsColimit t.toCocone) : t.IsBilimit := isBilimitOfTotal _ <| ht.hom_ext fun j => by cases j simp_rw [Bicone.toCocone_ι_app, comp_sum, ← Category.assoc, t.ι_π, dite_comp] simp /-- We can turn any limit cone over a pair into a bilimit bicone. -/ def biconeIsBilimitOfColimitCoconeOfIsColimit {f : J → C} {t : Cocone (Discrete.functor f)} (ht : IsColimit t) : (Bicone.ofColimitCocone ht).IsBilimit := isBilimitOfIsColimit _ <| IsColimit.ofIsoColimit ht <| Cocones.ext (Iso.refl _) <| by rintro ⟨j⟩; simp end Fintype section Finite variable {J : Type} [Finite J] /-- In a preadditive category, if the product over `f : J → C` exists, then the biproduct over `f` exists. -/ theorem HasBiproduct.of_hasProduct (f : J → C) [HasProduct f] : HasBiproduct f := by cases nonempty_fintype J exact HasBiproduct.mk { bicone := _ isBilimit := biconeIsBilimitOfLimitConeOfIsLimit (limit.isLimit _) } /-- In a preadditive category, if the coproduct over `f : J → C` exists, then the biproduct over `f` exists. -/ theorem HasBiproduct.of_hasCoproduct (f : J → C) [HasCoproduct f] : HasBiproduct f := by cases nonempty_fintype J exact HasBiproduct.mk { bicone := _ isBilimit := biconeIsBilimitOfColimitCoconeOfIsColimit (colimit.isColimit _) } end Finite /-- A preadditive category with finite products has finite biproducts. -/ theorem HasFiniteBiproducts.of_hasFiniteProducts [HasFiniteProducts C] : HasFiniteBiproducts C := ⟨fun _ => { has_biproduct := fun _ => HasBiproduct.of_hasProduct _ }⟩ /-- A preadditive category with finite coproducts has finite biproducts. -/ theorem HasFiniteBiproducts.of_hasFiniteCoproducts [HasFiniteCoproducts C] : HasFiniteBiproducts C := ⟨fun _ => { has_biproduct := fun _ => HasBiproduct.of_hasCoproduct _ }⟩ section HasBiproduct variable {J : Type} [Fintype J] {f : J → C} [HasBiproduct f] /-- In any preadditive category, any biproduct satsifies `∑ j : J, biproduct.π f j ≫ biproduct.ι f j = 𝟙 (⨁ f)` -/ @[simp] theorem biproduct.total : ∑ j : J, biproduct.π f j ≫ biproduct.ι f j = 𝟙 (⨁ f) := IsBilimit.total (biproduct.isBilimit _) theorem biproduct.lift_eq {T : C} {g : ∀ j, T ⟶ f j} : biproduct.lift g = ∑ j, g j ≫ biproduct.ι f j := by ext j simp only [sum_comp, biproduct.ι_π, comp_dite, biproduct.lift_π, Category.assoc, comp_zero, Finset.sum_dite_eq', Finset.mem_univ, eqToHom_refl, Category.comp_id, if_true] theorem biproduct.desc_eq {T : C} {g : ∀ j, f j ⟶ T} : biproduct.desc g = ∑ j, biproduct.π f j ≫ g j := by ext j simp [comp_sum, biproduct.ι_π_assoc, dite_comp] @[reassoc] theorem biproduct.lift_desc {T U : C} {g : ∀ j, T ⟶ f j} {h : ∀ j, f j ⟶ U} : biproduct.lift g ≫ biproduct.desc h = ∑ j : J, g j ≫ h j := by simp [biproduct.lift_eq, biproduct.desc_eq, comp_sum, sum_comp, biproduct.ι_π_assoc, comp_dite, dite_comp] theorem biproduct.map_eq [HasFiniteBiproducts C] {f g : J → C} {h : ∀ j, f j ⟶ g j} : biproduct.map h = ∑ j : J, biproduct.π f j ≫ h j ≫ biproduct.ι g j := by ext simp [biproduct.ι_π, biproduct.ι_π_assoc, comp_sum, sum_comp, comp_dite, dite_comp] @[reassoc] theorem biproduct.lift_matrix {K : Type} [Finite K] [HasFiniteBiproducts C] {f : J → C} {g : K → C} {P} (x : ∀ j, P ⟶ f j) (m : ∀ j k, f j ⟶ g k) : biproduct.lift x ≫ biproduct.matrix m = biproduct.lift fun k => ∑ j, x j ≫ m j k := by ext simp [biproduct.lift_desc] end HasBiproduct section HasFiniteBiproducts variable {J K : Type} [Finite J] {f : J → C} [HasFiniteBiproducts C] @[reassoc] theorem biproduct.matrix_desc [Fintype K] {f : J → C} {g : K → C} (m : ∀ j k, f j ⟶ g k) {P} (x : ∀ k, g k ⟶ P) : biproduct.matrix m ≫ biproduct.desc x = biproduct.desc fun j => ∑ k, m j k ≫ x k := by ext simp [lift_desc] variable [Finite K] @[reassoc] theorem biproduct.matrix_map {f : J → C} {g : K → C} {h : K → C} (m : ∀ j k, f j ⟶ g k) (n : ∀ k, g k ⟶ h k) : biproduct.matrix m ≫ biproduct.map n = biproduct.matrix fun j k => m j k ≫ n k := by ext simp @[reassoc] theorem biproduct.map_matrix {f : J → C} {g : J → C} {h : K → C} (m : ∀ k, f k ⟶ g k) (n : ∀ j k, g j ⟶ h k) : biproduct.map m ≫ biproduct.matrix n = biproduct.matrix fun j k => m j ≫ n j k := by ext simp end HasFiniteBiproducts /-- Reindex a categorical biproduct via an equivalence of the index types. -/ @[simps] def biproduct.reindex {β γ : Type} [Finite β] (ε : β ≃ γ) (f : γ → C) [HasBiproduct f] [HasBiproduct (f ∘ ε)] : ⨁ f ∘ ε ≅ ⨁ f where hom := biproduct.desc fun b => biproduct.ι f (ε b) inv := biproduct.lift fun b => biproduct.π f (ε b) hom_inv_id := by ext b b' by_cases h : b' = b · subst h; simp · have : ε b' ≠ ε b := by simp [h] simp [biproduct.ι_π_ne _ h, biproduct.ι_π_ne _ this] inv_hom_id := by cases nonempty_fintype β ext g g' by_cases h : g' = g <;> simp [Preadditive.sum_comp, Preadditive.comp_sum, biproduct.lift_desc, biproduct.ι_π, biproduct.ι_π_assoc, comp_dite, Equiv.apply_eq_iff_eq_symm_apply, Finset.sum_dite_eq' Finset.univ (ε.symm g') _, h] /-- In a preadditive category, we can construct a binary biproduct for `X Y : C` from any binary bicone `b` satisfying `total : b.fst ≫ b.inl + b.snd ≫ b.inr = 𝟙 b.X`. (That is, such a bicone is a limit cone and a colimit cocone.) -/ def isBinaryBilimitOfTotal {X Y : C} (b : BinaryBicone X Y) (total : b.fst ≫ b.inl + b.snd ≫ b.inr = 𝟙 b.pt) : b.IsBilimit where isLimit := { lift := fun s => (BinaryFan.fst s ≫ b.inl : s.pt ⟶ b.pt) + (BinaryFan.snd s ≫ b.inr : s.pt ⟶ b.pt) uniq := fun s m h => by have reassoced (j : WalkingPair) {W : C} (h' : _ ⟶ W) : m ≫ b.toCone.π.app ⟨j⟩ ≫ h' = s.π.app ⟨j⟩ ≫ h' := by rw [← Category.assoc, eq_whisker (h ⟨j⟩)] erw [← Category.comp_id m, ← total, comp_add, reassoced WalkingPair.left, reassoced WalkingPair.right] fac := fun s j => by rcases j with ⟨⟨⟩⟩ <;> simp } isColimit := { desc := fun s => (b.fst ≫ BinaryCofan.inl s : b.pt ⟶ s.pt) + (b.snd ≫ BinaryCofan.inr s : b.pt ⟶ s.pt) uniq := fun s m h => by erw [← Category.id_comp m, ← total, add_comp, Category.assoc, Category.assoc, h ⟨WalkingPair.left⟩, h ⟨WalkingPair.right⟩] fac := fun s j => by rcases j with ⟨⟨⟩⟩ <;> simp } theorem IsBilimit.binary_total {X Y : C} {b : BinaryBicone X Y} (i : b.IsBilimit) : b.fst ≫ b.inl + b.snd ≫ b.inr = 𝟙 b.pt := i.isLimit.hom_ext fun j => by rcases j with ⟨⟨⟩⟩ <;> simp /-- In a preadditive category, we can construct a binary biproduct for `X Y : C` from any binary bicone `b` satisfying `total : b.fst ≫ b.inl + b.snd ≫ b.inr = 𝟙 b.X`. (That is, such a bicone is a limit cone and a colimit cocone.) -/ theorem hasBinaryBiproduct_of_total {X Y : C} (b : BinaryBicone X Y) (total : b.fst ≫ b.inl + b.snd ≫ b.inr = 𝟙 b.pt) : HasBinaryBiproduct X Y := HasBinaryBiproduct.mk { bicone := b isBilimit := isBinaryBilimitOfTotal b total } /-- We can turn any limit cone over a pair into a bicone. -/ @[simps] def BinaryBicone.ofLimitCone {X Y : C} {t : Cone (pair X Y)} (ht : IsLimit t) : BinaryBicone X Y where pt := t.pt fst := t.π.app ⟨WalkingPair.left⟩ snd := t.π.app ⟨WalkingPair.right⟩ inl := ht.lift (BinaryFan.mk (𝟙 X) 0) inr := ht.lift (BinaryFan.mk 0 (𝟙 Y)) theorem inl_of_isLimit {X Y : C} {t : BinaryBicone X Y} (ht : IsLimit t.toCone) : t.inl = ht.lift (BinaryFan.mk (𝟙 X) 0) := by apply ht.uniq (BinaryFan.mk (𝟙 X) 0); rintro ⟨⟨⟩⟩ <;> dsimp <;> simp theorem inr_of_isLimit {X Y : C} {t : BinaryBicone X Y} (ht : IsLimit t.toCone) : t.inr = ht.lift (BinaryFan.mk 0 (𝟙 Y)) := by apply ht.uniq (BinaryFan.mk 0 (𝟙 Y)); rintro ⟨⟨⟩⟩ <;> dsimp <;> simp /-- In a preadditive category, any binary bicone which is a limit cone is in fact a bilimit bicone. -/ def isBinaryBilimitOfIsLimit {X Y : C} (t : BinaryBicone X Y) (ht : IsLimit t.toCone) : t.IsBilimit := isBinaryBilimitOfTotal _ (by refine BinaryFan.IsLimit.hom_ext ht ?_ ?_ <;> simp) /-- We can turn any limit cone over a pair into a bilimit bicone. -/ def binaryBiconeIsBilimitOfLimitConeOfIsLimit {X Y : C} {t : Cone (pair X Y)} (ht : IsLimit t) : (BinaryBicone.ofLimitCone ht).IsBilimit := isBinaryBilimitOfTotal _ <| BinaryFan.IsLimit.hom_ext ht (by simp) (by simp) /-- In a preadditive category, if the product of `X` and `Y` exists, then the binary biproduct of `X` and `Y` exists. -/ theorem HasBinaryBiproduct.of_hasBinaryProduct (X Y : C) [HasBinaryProduct X Y] : HasBinaryBiproduct X Y := HasBinaryBiproduct.mk { bicone := _ isBilimit := binaryBiconeIsBilimitOfLimitConeOfIsLimit (limit.isLimit _) } /-- In a preadditive category, if all binary products exist, then all binary biproducts exist. -/ theorem HasBinaryBiproducts.of_hasBinaryProducts [HasBinaryProducts C] : HasBinaryBiproducts C := { has_binary_biproduct := fun X Y => HasBinaryBiproduct.of_hasBinaryProduct X Y } /-- We can turn any colimit cocone over a pair into a bicone. -/ @[simps] def BinaryBicone.ofColimitCocone {X Y : C} {t : Cocone (pair X Y)} (ht : IsColimit t) : BinaryBicone X Y where pt := t.pt fst := ht.desc (BinaryCofan.mk (𝟙 X) 0) snd := ht.desc (BinaryCofan.mk 0 (𝟙 Y)) inl := t.ι.app ⟨WalkingPair.left⟩ inr := t.ι.app ⟨WalkingPair.right⟩ theorem fst_of_isColimit {X Y : C} {t : BinaryBicone X Y} (ht : IsColimit t.toCocone) : t.fst = ht.desc (BinaryCofan.mk (𝟙 X) 0) := by apply ht.uniq (BinaryCofan.mk (𝟙 X) 0) rintro ⟨⟨⟩⟩ <;> dsimp <;> simp theorem snd_of_isColimit {X Y : C} {t : BinaryBicone X Y} (ht : IsColimit t.toCocone) : t.snd = ht.desc (BinaryCofan.mk 0 (𝟙 Y)) := by apply ht.uniq (BinaryCofan.mk 0 (𝟙 Y)) rintro ⟨⟨⟩⟩ <;> dsimp <;> simp /-- In a preadditive category, any binary bicone which is a colimit cocone is in fact a bilimit bicone. -/ def isBinaryBilimitOfIsColimit {X Y : C} (t : BinaryBicone X Y) (ht : IsColimit t.toCocone) : t.IsBilimit := isBinaryBilimitOfTotal _ <| by refine BinaryCofan.IsColimit.hom_ext ht ?_ ?_ <;> simp /-- We can turn any colimit cocone over a pair into a bilimit bicone. -/ def binaryBiconeIsBilimitOfColimitCoconeOfIsColimit {X Y : C} {t : Cocone (pair X Y)} (ht : IsColimit t) : (BinaryBicone.ofColimitCocone ht).IsBilimit := isBinaryBilimitOfIsColimit (BinaryBicone.ofColimitCocone ht) <| IsColimit.ofIsoColimit ht <| Cocones.ext (Iso.refl _) fun j => by rcases j with ⟨⟨⟩⟩ <;> simp /-- In a preadditive category, if the coproduct of `X` and `Y` exists, then the binary biproduct of `X` and `Y` exists. -/ theorem HasBinaryBiproduct.of_hasBinaryCoproduct (X Y : C) [HasBinaryCoproduct X Y] : HasBinaryBiproduct X Y := HasBinaryBiproduct.mk { bicone := _ isBilimit := binaryBiconeIsBilimitOfColimitCoconeOfIsColimit (colimit.isColimit _) } /-- In a preadditive category, if all binary coproducts exist, then all binary biproducts exist. -/ theorem HasBinaryBiproducts.of_hasBinaryCoproducts [HasBinaryCoproducts C] : HasBinaryBiproducts C := { has_binary_biproduct := fun X Y => HasBinaryBiproduct.of_hasBinaryCoproduct X Y } section variable {X Y : C} [HasBinaryBiproduct X Y] /-- In any preadditive category, any binary biproduct satsifies `biprod.fst ≫ biprod.inl + biprod.snd ≫ biprod.inr = 𝟙 (X ⊞ Y)`. -/ @[simp] theorem biprod.total : biprod.fst ≫ biprod.inl + biprod.snd ≫ biprod.inr = 𝟙 (X ⊞ Y) := by ext <;> simp [add_comp] theorem biprod.lift_eq {T : C} {f : T ⟶ X} {g : T ⟶ Y} : biprod.lift f g = f ≫ biprod.inl + g ≫ biprod.inr := by ext <;> simp [add_comp] theorem biprod.desc_eq {T : C} {f : X ⟶ T} {g : Y ⟶ T} : biprod.desc f g = biprod.fst ≫ f + biprod.snd ≫ g := by ext <;> simp [add_comp] @[reassoc (attr := simp)] theorem biprod.lift_desc {T U : C} {f : T ⟶ X} {g : T ⟶ Y} {h : X ⟶ U} {i : Y ⟶ U} : biprod.lift f g ≫ biprod.desc h i = f ≫ h + g ≫ i := by simp [biprod.lift_eq, biprod.desc_eq] theorem biprod.map_eq [HasBinaryBiproducts C] {W X Y Z : C} {f : W ⟶ Y} {g : X ⟶ Z} : biprod.map f g = biprod.fst ≫ f ≫ biprod.inl + biprod.snd ≫ g ≫ biprod.inr := by ext <;> simp /-- Every split mono `f` with a cokernel induces a binary bicone with `f` as its `inl` and the cokernel map as its `snd`. We will show in `is_bilimit_binary_bicone_of_split_mono_of_cokernel` that this binary bicone is in fact already a biproduct. -/ @[simps] def binaryBiconeOfIsSplitMonoOfCokernel {X Y : C} {f : X ⟶ Y} [IsSplitMono f] {c : CokernelCofork f} (i : IsColimit c) : BinaryBicone X c.pt where pt := Y fst := retraction f snd := c.π inl := f inr := let c' : CokernelCofork (𝟙 Y - (𝟙 Y - retraction f ≫ f)) := CokernelCofork.ofπ (Cofork.π c) (by simp) let i' : IsColimit c' := isCokernelEpiComp i (retraction f) (by simp) let i'' := isColimitCoforkOfCokernelCofork i' (splitEpiOfIdempotentOfIsColimitCofork C (by simp) i'').section_ inl_fst := by simp inl_snd := by simp inr_fst := by dsimp only rw [splitEpiOfIdempotentOfIsColimitCofork_section_, isColimitCoforkOfCokernelCofork_desc, isCokernelEpiComp_desc] dsimp only [cokernelCoforkOfCofork_ofπ] letI := epi_of_isColimit_cofork i apply zero_of_epi_comp c.π simp only [sub_comp, comp_sub, Category.comp_id, Category.assoc, IsSplitMono.id, sub_self, Cofork.IsColimit.π_desc_assoc, CokernelCofork.π_ofπ, IsSplitMono.id_assoc] apply sub_eq_zero_of_eq apply Category.id_comp inr_snd := by apply SplitEpi.id /-- The bicone constructed in `binaryBiconeOfSplitMonoOfCokernel` is a bilimit. This is a version of the splitting lemma that holds in all preadditive categories. -/ def isBilimitBinaryBiconeOfIsSplitMonoOfCokernel {X Y : C} {f : X ⟶ Y} [IsSplitMono f] {c : CokernelCofork f} (i : IsColimit c) : (binaryBiconeOfIsSplitMonoOfCokernel i).IsBilimit := isBinaryBilimitOfTotal _ (by simp only [binaryBiconeOfIsSplitMonoOfCokernel_fst, binaryBiconeOfIsSplitMonoOfCokernel_inr, binaryBiconeOfIsSplitMonoOfCokernel_snd, splitEpiOfIdempotentOfIsColimitCofork_section_] dsimp only [binaryBiconeOfIsSplitMonoOfCokernel_pt] rw [isColimitCoforkOfCokernelCofork_desc, isCokernelEpiComp_desc] simp only [binaryBiconeOfIsSplitMonoOfCokernel_inl, Cofork.IsColimit.π_desc, cokernelCoforkOfCofork_π, Cofork.π_ofπ, add_sub_cancel]) /-- If `b` is a binary bicone such that `b.inl` is a kernel of `b.snd`, then `b` is a bilimit bicone. -/ def BinaryBicone.isBilimitOfKernelInl {X Y : C} (b : BinaryBicone X Y) (hb : IsLimit b.sndKernelFork) : b.IsBilimit := isBinaryBilimitOfIsLimit _ <| BinaryFan.IsLimit.mk _ (fun f g => f ≫ b.inl + g ≫ b.inr) (fun f g => by simp) (fun f g => by simp) fun {T} f g m h₁ h₂ => by dsimp at m have h₁' : ((m : T ⟶ b.pt) - (f ≫ b.inl + g ≫ b.inr)) ≫ b.fst = 0 := by simpa using sub_eq_zero.2 h₁ have h₂' : (m - (f ≫ b.inl + g ≫ b.inr)) ≫ b.snd = 0 := by simpa using sub_eq_zero.2 h₂ obtain ⟨q : T ⟶ X, hq : q ≫ b.inl = m - (f ≫ b.inl + g ≫ b.inr)⟩ := KernelFork.IsLimit.lift' hb _ h₂' rw [← sub_eq_zero, ← hq, ← Category.comp_id q, ← b.inl_fst, ← Category.assoc, hq, h₁', zero_comp] /-- If `b` is a binary bicone such that `b.inr` is a kernel of `b.fst`, then `b` is a bilimit bicone. -/ def BinaryBicone.isBilimitOfKernelInr {X Y : C} (b : BinaryBicone X Y) (hb : IsLimit b.fstKernelFork) : b.IsBilimit := isBinaryBilimitOfIsLimit _ <| BinaryFan.IsLimit.mk _ (fun f g => f ≫ b.inl + g ≫ b.inr) (fun f g => by simp) (fun f g => by simp) fun {T} f g m h₁ h₂ => by dsimp at m have h₁' : (m - (f ≫ b.inl + g ≫ b.inr)) ≫ b.fst = 0 := by simpa using sub_eq_zero.2 h₁ have h₂' : (m - (f ≫ b.inl + g ≫ b.inr)) ≫ b.snd = 0 := by simpa using sub_eq_zero.2 h₂ obtain ⟨q : T ⟶ Y, hq : q ≫ b.inr = m - (f ≫ b.inl + g ≫ b.inr)⟩ := KernelFork.IsLimit.lift' hb _ h₁' rw [← sub_eq_zero, ← hq, ← Category.comp_id q, ← b.inr_snd, ← Category.assoc, hq, h₂', zero_comp] /-- If `b` is a binary bicone such that `b.fst` is a cokernel of `b.inr`, then `b` is a bilimit bicone. -/ def BinaryBicone.isBilimitOfCokernelFst {X Y : C} (b : BinaryBicone X Y) (hb : IsColimit b.inrCokernelCofork) : b.IsBilimit := isBinaryBilimitOfIsColimit _ <| BinaryCofan.IsColimit.mk _ (fun f g => b.fst ≫ f + b.snd ≫ g) (fun f g => by simp) (fun f g => by simp) fun {T} f g m h₁ h₂ => by dsimp at m have h₁' : b.inl ≫ (m - (b.fst ≫ f + b.snd ≫ g)) = 0 := by simpa using sub_eq_zero.2 h₁ have h₂' : b.inr ≫ (m - (b.fst ≫ f + b.snd ≫ g)) = 0 := by simpa using sub_eq_zero.2 h₂ obtain ⟨q : X ⟶ T, hq : b.fst ≫ q = m - (b.fst ≫ f + b.snd ≫ g)⟩ := CokernelCofork.IsColimit.desc' hb _ h₂' rw [← sub_eq_zero, ← hq, ← Category.id_comp q, ← b.inl_fst, Category.assoc, hq, h₁', comp_zero] /-- If `b` is a binary bicone such that `b.snd` is a cokernel of `b.inl`, then `b` is a bilimit bicone. -/ def BinaryBicone.isBilimitOfCokernelSnd {X Y : C} (b : BinaryBicone X Y) (hb : IsColimit b.inlCokernelCofork) : b.IsBilimit := isBinaryBilimitOfIsColimit _ <| BinaryCofan.IsColimit.mk _ (fun f g => b.fst ≫ f + b.snd ≫ g) (fun f g => by simp) (fun f g => by simp) fun {T} f g m h₁ h₂ => by dsimp at m have h₁' : b.inl ≫ (m - (b.fst ≫ f + b.snd ≫ g)) = 0 := by simpa using sub_eq_zero.2 h₁ have h₂' : b.inr ≫ (m - (b.fst ≫ f + b.snd ≫ g)) = 0 := by simpa using sub_eq_zero.2 h₂ obtain ⟨q : Y ⟶ T, hq : b.snd ≫ q = m - (b.fst ≫ f + b.snd ≫ g)⟩ := CokernelCofork.IsColimit.desc' hb _ h₁' rw [← sub_eq_zero, ← hq, ← Category.id_comp q, ← b.inr_snd, Category.assoc, hq, h₂', comp_zero] /-- Every split epi `f` with a kernel induces a binary bicone with `f` as its `snd` and the kernel map as its `inl`. We will show in `binary_bicone_of_is_split_mono_of_cokernel` that this binary bicone is in fact already a biproduct. -/ @[simps] def binaryBiconeOfIsSplitEpiOfKernel {X Y : C} {f : X ⟶ Y} [IsSplitEpi f] {c : KernelFork f} (i : IsLimit c) : BinaryBicone c.pt Y := { pt := X fst := let c' : KernelFork (𝟙 X - (𝟙 X - f ≫ section_ f)) := KernelFork.ofι (Fork.ι c) (by simp) let i' : IsLimit c' := isKernelCompMono i (section_ f) (by simp) let i'' := isLimitForkOfKernelFork i' (splitMonoOfIdempotentOfIsLimitFork C (by simp) i'').retraction snd := f inl := c.ι inr := section_ f inl_fst := by apply SplitMono.id inl_snd := by simp inr_fst := by dsimp only rw [splitMonoOfIdempotentOfIsLimitFork_retraction, isLimitForkOfKernelFork_lift, isKernelCompMono_lift] dsimp only [kernelForkOfFork_ι] letI := mono_of_isLimit_fork i apply zero_of_comp_mono c.ι simp only [comp_sub, Category.comp_id, Category.assoc, sub_self, Fork.IsLimit.lift_ι, Fork.ι_ofι, IsSplitEpi.id_assoc] inr_snd := by simp } /-- The bicone constructed in `binaryBiconeOfIsSplitEpiOfKernel` is a bilimit. This is a version of the splitting lemma that holds in all preadditive categories. -/ def isBilimitBinaryBiconeOfIsSplitEpiOfKernel {X Y : C} {f : X ⟶ Y} [IsSplitEpi f] {c : KernelFork f} (i : IsLimit c) : (binaryBiconeOfIsSplitEpiOfKernel i).IsBilimit := BinaryBicone.isBilimitOfKernelInl _ <| i.ofIsoLimit <| Fork.ext (Iso.refl _) (by simp) end section variable {X Y : C} (f g : X ⟶ Y) /-- The existence of binary biproducts implies that there is at most one preadditive structure. -/ theorem biprod.add_eq_lift_id_desc [HasBinaryBiproduct X X] : f + g = biprod.lift (𝟙 X) (𝟙 X) ≫ biprod.desc f g := by simp /-- The existence of binary biproducts implies that there is at most one preadditive structure. -/ theorem biprod.add_eq_lift_desc_id [HasBinaryBiproduct Y Y] : f + g = biprod.lift f g ≫ biprod.desc (𝟙 Y) (𝟙 Y) := by simp end end Limits open CategoryTheory.Limits section attribute [local ext] Preadditive /-- The existence of binary biproducts implies that there is at most one preadditive structure. -/ instance subsingleton_preadditive_of_hasBinaryBiproducts {C : Type u} [Category.{v} C] [HasZeroMorphisms C] [HasBinaryBiproducts C] : Subsingleton (Preadditive C) where allEq := fun a b => by apply Preadditive.ext; funext X Y; apply AddCommGroup.ext; funext f g have h₁ := @biprod.add_eq_lift_id_desc _ _ a _ _ f g (by convert (inferInstance : HasBinaryBiproduct X X); subsingleton) have h₂ := @biprod.add_eq_lift_id_desc _ _ b _ _ f g (by convert (inferInstance : HasBinaryBiproduct X X); subsingleton) refine h₁.trans (Eq.trans ?_ h₂.symm) congr! 2 <;> subsingleton end section variable [HasBinaryBiproducts.{v} C] variable {X₁ X₂ Y₁ Y₂ : C} variable (f₁₁ : X₁ ⟶ Y₁) (f₁₂ : X₁ ⟶ Y₂) (f₂₁ : X₂ ⟶ Y₁) (f₂₂ : X₂ ⟶ Y₂) /-- The "matrix" morphism `X₁ ⊞ X₂ ⟶ Y₁ ⊞ Y₂` with specified components. -/ def Biprod.ofComponents : X₁ ⊞ X₂ ⟶ Y₁ ⊞ Y₂ := biprod.fst ≫ f₁₁ ≫ biprod.inl + biprod.fst ≫ f₁₂ ≫ biprod.inr + biprod.snd ≫ f₂₁ ≫ biprod.inl + biprod.snd ≫ f₂₂ ≫ biprod.inr @[simp] theorem Biprod.inl_ofComponents : biprod.inl ≫ Biprod.ofComponents f₁₁ f₁₂ f₂₁ f₂₂ = f₁₁ ≫ biprod.inl + f₁₂ ≫ biprod.inr := by simp [Biprod.ofComponents] @[simp] theorem Biprod.inr_ofComponents : biprod.inr ≫ Biprod.ofComponents f₁₁ f₁₂ f₂₁ f₂₂ = f₂₁ ≫ biprod.inl + f₂₂ ≫ biprod.inr := by simp [Biprod.ofComponents] @[simp] theorem Biprod.ofComponents_fst : Biprod.ofComponents f₁₁ f₁₂ f₂₁ f₂₂ ≫ biprod.fst = biprod.fst ≫ f₁₁ + biprod.snd ≫ f₂₁ := by simp [Biprod.ofComponents] @[simp] theorem Biprod.ofComponents_snd : Biprod.ofComponents f₁₁ f₁₂ f₂₁ f₂₂ ≫ biprod.snd = biprod.fst ≫ f₁₂ + biprod.snd ≫ f₂₂ := by simp [Biprod.ofComponents] @[simp] theorem Biprod.ofComponents_eq (f : X₁ ⊞ X₂ ⟶ Y₁ ⊞ Y₂) : Biprod.ofComponents (biprod.inl ≫ f ≫ biprod.fst) (biprod.inl ≫ f ≫ biprod.snd) (biprod.inr ≫ f ≫ biprod.fst) (biprod.inr ≫ f ≫ biprod.snd) = f := by ext <;> simp only [Category.comp_id, biprod.inr_fst, biprod.inr_snd, biprod.inl_snd, add_zero, zero_add, Biprod.inl_ofComponents, Biprod.inr_ofComponents, eq_self_iff_true, Category.assoc, comp_zero, biprod.inl_fst, Preadditive.add_comp] @[simp] theorem Biprod.ofComponents_comp {X₁ X₂ Y₁ Y₂ Z₁ Z₂ : C} (f₁₁ : X₁ ⟶ Y₁) (f₁₂ : X₁ ⟶ Y₂) (f₂₁ : X₂ ⟶ Y₁) (f₂₂ : X₂ ⟶ Y₂) (g₁₁ : Y₁ ⟶ Z₁) (g₁₂ : Y₁ ⟶ Z₂) (g₂₁ : Y₂ ⟶ Z₁) (g₂₂ : Y₂ ⟶ Z₂) : Biprod.ofComponents f₁₁ f₁₂ f₂₁ f₂₂ ≫ Biprod.ofComponents g₁₁ g₁₂ g₂₁ g₂₂ = Biprod.ofComponents (f₁₁ ≫ g₁₁ + f₁₂ ≫ g₂₁) (f₁₁ ≫ g₁₂ + f₁₂ ≫ g₂₂) (f₂₁ ≫ g₁₁ + f₂₂ ≫ g₂₁) (f₂₁ ≫ g₁₂ + f₂₂ ≫ g₂₂) := by dsimp [Biprod.ofComponents] ext <;> simp only [add_comp, comp_add, add_comp_assoc, add_zero, zero_add, biprod.inl_fst, biprod.inl_snd, biprod.inr_fst, biprod.inr_snd, biprod.inl_fst_assoc, biprod.inl_snd_assoc, biprod.inr_fst_assoc, biprod.inr_snd_assoc, comp_zero, zero_comp, Category.assoc] /-- The unipotent upper triangular matrix ``` (1 r) (0 1) ``` as an isomorphism. -/ @[simps] def Biprod.unipotentUpper {X₁ X₂ : C} (r : X₁ ⟶ X₂) : X₁ ⊞ X₂ ≅ X₁ ⊞ X₂ where hom := Biprod.ofComponents (𝟙 _) r 0 (𝟙 _) inv := Biprod.ofComponents (𝟙 _) (-r) 0 (𝟙 _) /-- The unipotent lower triangular matrix ``` (1 0) (r 1) ``` as an isomorphism. -/ @[simps] def Biprod.unipotentLower {X₁ X₂ : C} (r : X₂ ⟶ X₁) : X₁ ⊞ X₂ ≅ X₁ ⊞ X₂ where hom := Biprod.ofComponents (𝟙 _) 0 r (𝟙 _) inv := Biprod.ofComponents (𝟙 _) 0 (-r) (𝟙 _) /-- If `f` is a morphism `X₁ ⊞ X₂ ⟶ Y₁ ⊞ Y₂` whose `X₁ ⟶ Y₁` entry is an isomorphism, then we can construct isomorphisms `L : X₁ ⊞ X₂ ≅ X₁ ⊞ X₂` and `R : Y₁ ⊞ Y₂ ≅ Y₁ ⊞ Y₂` so that `L.hom ≫ g ≫ R.hom` is diagonal (with `X₁ ⟶ Y₁` component still `f`), via Gaussian elimination. (This is the version of `Biprod.gaussian` written in terms of components.) -/ def Biprod.gaussian' [IsIso f₁₁] : Σ' (L : X₁ ⊞ X₂ ≅ X₁ ⊞ X₂) (R : Y₁ ⊞ Y₂ ≅ Y₁ ⊞ Y₂) (g₂₂ : X₂ ⟶ Y₂), L.hom ≫ Biprod.ofComponents f₁₁ f₁₂ f₂₁ f₂₂ ≫ R.hom = biprod.map f₁₁ g₂₂ := ⟨Biprod.unipotentLower (-f₂₁ ≫ inv f₁₁), Biprod.unipotentUpper (-inv f₁₁ ≫ f₁₂), f₂₂ - f₂₁ ≫ inv f₁₁ ≫ f₁₂, by ext <;> simp; abel⟩ /-- If `f` is a morphism `X₁ ⊞ X₂ ⟶ Y₁ ⊞ Y₂` whose `X₁ ⟶ Y₁` entry is an isomorphism, then we can construct isomorphisms `L : X₁ ⊞ X₂ ≅ X₁ ⊞ X₂` and `R : Y₁ ⊞ Y₂ ≅ Y₁ ⊞ Y₂` so that `L.hom ≫ g ≫ R.hom` is diagonal (with `X₁ ⟶ Y₁` component still `f`), via Gaussian elimination. -/ def Biprod.gaussian (f : X₁ ⊞ X₂ ⟶ Y₁ ⊞ Y₂) [IsIso (biprod.inl ≫ f ≫ biprod.fst)] : Σ' (L : X₁ ⊞ X₂ ≅ X₁ ⊞ X₂) (R : Y₁ ⊞ Y₂ ≅ Y₁ ⊞ Y₂) (g₂₂ : X₂ ⟶ Y₂), L.hom ≫ f ≫ R.hom = biprod.map (biprod.inl ≫ f ≫ biprod.fst) g₂₂ := by let this := Biprod.gaussian' (biprod.inl ≫ f ≫ biprod.fst) (biprod.inl ≫ f ≫ biprod.snd) (biprod.inr ≫ f ≫ biprod.fst) (biprod.inr ≫ f ≫ biprod.snd) rwa [Biprod.ofComponents_eq] at this /-- If `X₁ ⊞ X₂ ≅ Y₁ ⊞ Y₂` via a two-by-two matrix whose `X₁ ⟶ Y₁` entry is an isomorphism, then we can construct an isomorphism `X₂ ≅ Y₂`, via Gaussian elimination. -/ def Biprod.isoElim' [IsIso f₁₁] [IsIso (Biprod.ofComponents f₁₁ f₁₂ f₂₁ f₂₂)] : X₂ ≅ Y₂ := by obtain ⟨L, R, g, w⟩ := Biprod.gaussian' f₁₁ f₁₂ f₂₁ f₂₂ letI : IsIso (biprod.map f₁₁ g) := by rw [← w] infer_instance letI : IsIso g := isIso_right_of_isIso_biprod_map f₁₁ g exact asIso g /-- If `f` is an isomorphism `X₁ ⊞ X₂ ≅ Y₁ ⊞ Y₂` whose `X₁ ⟶ Y₁` entry is an isomorphism, then we can construct an isomorphism `X₂ ≅ Y₂`, via Gaussian elimination. -/ def Biprod.isoElim (f : X₁ ⊞ X₂ ≅ Y₁ ⊞ Y₂) [IsIso (biprod.inl ≫ f.hom ≫ biprod.fst)] : X₂ ≅ Y₂ := letI : IsIso (Biprod.ofComponents (biprod.inl ≫ f.hom ≫ biprod.fst) (biprod.inl ≫ f.hom ≫ biprod.snd) (biprod.inr ≫ f.hom ≫ biprod.fst) (biprod.inr ≫ f.hom ≫ biprod.snd)) := by simp only [Biprod.ofComponents_eq] infer_instance Biprod.isoElim' (biprod.inl ≫ f.hom ≫ biprod.fst) (biprod.inl ≫ f.hom ≫ biprod.snd) (biprod.inr ≫ f.hom ≫ biprod.fst) (biprod.inr ≫ f.hom ≫ biprod.snd) theorem Biprod.column_nonzero_of_iso {W X Y Z : C} (f : W ⊞ X ⟶ Y ⊞ Z) [IsIso f] : 𝟙 W = 0 ∨ biprod.inl ≫ f ≫ biprod.fst ≠ 0 ∨ biprod.inl ≫ f ≫ biprod.snd ≠ 0 := by by_contra! h rcases h with ⟨nz, a₁, a₂⟩ set x := biprod.inl ≫ f ≫ inv f ≫ biprod.fst have h₁ : x = 𝟙 W := by simp [x] have h₀ : x = 0 := by dsimp [x] rw [← Category.id_comp (inv f), Category.assoc, ← biprod.total] conv_lhs => slice 2 3 rw [comp_add] simp only [Category.assoc] rw [comp_add_assoc, add_comp] conv_lhs => congr next => skip slice 1 3 rw [a₂] simp only [zero_comp, add_zero] conv_lhs => slice 1 3 rw [a₁] simp only [zero_comp] exact nz (h₁.symm.trans h₀) end theorem Biproduct.column_nonzero_of_iso' {σ τ : Type} [Finite τ] {S : σ → C} [HasBiproduct S] {T : τ → C} [HasBiproduct T] (s : σ) (f : ⨁ S ⟶ ⨁ T) [IsIso f] : (∀ t : τ, biproduct.ι S s ≫ f ≫ biproduct.π T t = 0) → 𝟙 (S s) = 0 := by cases nonempty_fintype τ intro z have reassoced {t : τ} {W : C} (h : _ ⟶ W) : biproduct.ι S s ≫ f ≫ biproduct.π T t ≫ h = 0 ≫ h := by simp only [← Category.assoc] apply eq_whisker simp only [Category.assoc] apply z set x := biproduct.ι S s ≫ f ≫ inv f ≫ biproduct.π S s have h₁ : x = 𝟙 (S s) := by simp [x] have h₀ : x = 0 := by dsimp [x] rw [← Category.id_comp (inv f), Category.assoc, ← biproduct.total] simp only [comp_sum_assoc] conv_lhs => congr congr next => skip intro j; simp only [reassoced] simp exact h₁.symm.trans h₀ /-- If `f : ⨁ S ⟶ ⨁ T` is an isomorphism, and `s` is a non-trivial summand of the source, then there is some `t` in the target so that the `s, t` matrix entry of `f` is nonzero. -/ def Biproduct.columnNonzeroOfIso {σ τ : Type} [Fintype τ] {S : σ → C} [HasBiproduct S] {T : τ → C} [HasBiproduct T] (s : σ) (nz : 𝟙 (S s) ≠ 0) (f : ⨁ S ⟶ ⨁ T) [IsIso f] : Trunc (Σ't : τ, biproduct.ι S s ≫ f ≫ biproduct.π T t ≠ 0) := by classical apply truncSigmaOfExists have t := Biproduct.column_nonzero_of_iso'.{v} s f by_contra h simp only [not_exists_not] at h exact nz (t h) section Preadditive variable {D : Type u'} [Category.{v'} D] [Preadditive.{v'} D] variable (F : C ⥤ D) [PreservesZeroMorphisms F] namespace Limits section Fintype variable {J : Type} [Fintype J] /-- A functor between preadditive categories that preserves (zero morphisms and) finite biproducts preserves finite products. -/ def preservesProductOfPreservesBiproduct {f : J → C} [PreservesBiproduct f F] : PreservesLimit (Discrete.functor f) F where preserves hc := IsLimit.ofIsoLimit ((IsLimit.postcomposeInvEquiv (Discrete.compNatIsoDiscrete _ _) _).symm (isBilimitOfPreserves F (biconeIsBilimitOfLimitConeOfIsLimit hc)).isLimit) <| Cones.ext (Iso.refl _) (by rintro ⟨⟩; simp) section attribute [local instance] preservesProductOfPreservesBiproduct /-- A functor between preadditive categories that preserves (zero morphisms and) finite biproducts preserves finite products. -/ def preservesProductsOfShapeOfPreservesBiproductsOfShape [PreservesBiproductsOfShape J F] : PreservesLimitsOfShape (Discrete J) F where preservesLimit {_} := preservesLimitOfIsoDiagram _ Discrete.natIsoFunctor.symm end /-- A functor between preadditive categories that preserves (zero morphisms and) finite products preserves finite biproducts. -/ def preservesBiproductOfPreservesProduct {f : J → C} [PreservesLimit (Discrete.functor f) F] : PreservesBiproduct f F where preserves {b} hb := isBilimitOfIsLimit _ <| IsLimit.ofIsoLimit ((IsLimit.postcomposeHomEquiv (Discrete.compNatIsoDiscrete _ _) (F.mapCone b.toCone)).symm (isLimitOfPreserves F hb.isLimit)) <| Cones.ext (Iso.refl _) (by rintro ⟨⟩; simp) /-- If the (product-like) biproduct comparison for `F` and `f` is a monomorphism, then `F` preserves the biproduct of `f`. For the converse, see `mapBiproduct`. -/ def preservesBiproductOfMonoBiproductComparison {f : J → C} [HasBiproduct f] [HasBiproduct (F.obj ∘ f)] [Mono (biproductComparison F f)] : PreservesBiproduct f F := by haveI : HasProduct fun b => F.obj (f b) := by change HasProduct (F.obj ∘ f) infer_instance have that : piComparison F f = (F.mapIso (biproduct.isoProduct f)).inv ≫ biproductComparison F f ≫ (biproduct.isoProduct _).hom := by ext j convert piComparison_comp_π F f j; simp [← Function.comp_def, ← Functor.map_comp] haveI : IsIso (biproductComparison F f) := isIso_of_mono_of_isSplitEpi _ haveI : IsIso (piComparison F f) := by rw [that] infer_instance haveI := PreservesProduct.ofIsoComparison F f apply preservesBiproductOfPreservesProduct /-- If the (coproduct-like) biproduct comparison for `F` and `f` is an epimorphism, then `F` preserves the biproduct of `F` and `f`. For the converse, see `mapBiproduct`. -/ def preservesBiproductOfEpiBiproductComparison' {f : J → C} [HasBiproduct f] [HasBiproduct (F.obj ∘ f)] [Epi (biproductComparison' F f)] : PreservesBiproduct f F := by haveI : Epi (splitEpiBiproductComparison F f).section_ := by simpa haveI : IsIso (biproductComparison F f) := IsIso.of_epi_section' (splitEpiBiproductComparison F f) apply preservesBiproductOfMonoBiproductComparison /-- A functor between preadditive categories that preserves (zero morphisms and) finite products preserves finite biproducts. -/ def preservesBiproductsOfShapeOfPreservesProductsOfShape [PreservesLimitsOfShape (Discrete J) F] : PreservesBiproductsOfShape J F where preserves {_} := preservesBiproductOfPreservesProduct F /-- A functor between preadditive categories that preserves (zero morphisms and) finite biproducts preserves finite coproducts. -/ def preservesCoproductOfPreservesBiproduct {f : J → C} [PreservesBiproduct f F] : PreservesColimit (Discrete.functor f) F where preserves {c} hc := IsColimit.ofIsoColimit ((IsColimit.precomposeHomEquiv (Discrete.compNatIsoDiscrete _ _) _).symm (isBilimitOfPreserves F (biconeIsBilimitOfColimitCoconeOfIsColimit hc)).isColimit) <| Cocones.ext (Iso.refl _) (by rintro ⟨⟩; simp) section attribute [local instance] preservesCoproductOfPreservesBiproduct /-- A functor between preadditive categories that preserves (zero morphisms and) finite biproducts preserves finite coproducts. -/ def preservesCoproductsOfShapeOfPreservesBiproductsOfShape [PreservesBiproductsOfShape J F] : PreservesColimitsOfShape (Discrete J) F where preservesColimit {_} := preservesColimitOfIsoDiagram _ Discrete.natIsoFunctor.symm end /-- A functor between preadditive categories that preserves (zero morphisms and) finite coproducts preserves finite biproducts. -/ def preservesBiproductOfPreservesCoproduct {f : J → C} [PreservesColimit (Discrete.functor f) F] : PreservesBiproduct f F where preserves {b} hb := isBilimitOfIsColimit _ <| IsColimit.ofIsoColimit ((IsColimit.precomposeInvEquiv (Discrete.compNatIsoDiscrete _ _) (F.mapCocone b.toCocone)).symm (isColimitOfPreserves F hb.isColimit)) <| Cocones.ext (Iso.refl _) (by rintro ⟨⟩; simp) /-- A functor between preadditive categories that preserves (zero morphisms and) finite coproducts preserves finite biproducts. -/ def preservesBiproductsOfShapeOfPreservesCoproductsOfShape [PreservesColimitsOfShape (Discrete J) F] : PreservesBiproductsOfShape J F where preserves {_} := preservesBiproductOfPreservesCoproduct F end Fintype /-- A functor between preadditive categories that preserves (zero morphisms and) binary biproducts preserves binary products. -/ def preservesBinaryProductOfPreservesBinaryBiproduct {X Y : C} [PreservesBinaryBiproduct X Y F] : PreservesLimit (pair X Y) F where preserves {c} hc := IsLimit.ofIsoLimit ((IsLimit.postcomposeInvEquiv (diagramIsoPair _) _).symm (isBinaryBilimitOfPreserves F (binaryBiconeIsBilimitOfLimitConeOfIsLimit hc)).isLimit) <| Cones.ext (by dsimp; rfl) fun j => by rcases j with ⟨⟨⟩⟩ <;> simp section attribute [local instance] preservesBinaryProductOfPreservesBinaryBiproduct /-- A functor between preadditive categories that preserves (zero morphisms and) binary biproducts preserves binary products. -/ def preservesBinaryProductsOfPreservesBinaryBiproducts [PreservesBinaryBiproducts F] : PreservesLimitsOfShape (Discrete WalkingPair) F where preservesLimit {_} := preservesLimitOfIsoDiagram _ (diagramIsoPair _).symm end /-- A functor between preadditive categories that preserves (zero morphisms and) binary products preserves binary biproducts. -/ def preservesBinaryBiproductOfPreservesBinaryProduct {X Y : C} [PreservesLimit (pair X Y) F] : PreservesBinaryBiproduct X Y F where preserves {b} hb := isBinaryBilimitOfIsLimit _ <| IsLimit.ofIsoLimit ((IsLimit.postcomposeHomEquiv (diagramIsoPair _) (F.mapCone b.toCone)).symm (isLimitOfPreserves F hb.isLimit)) <| Cones.ext (by dsimp; rfl) fun j => by rcases j with ⟨⟨⟩⟩ <;> simp /-- If the (product-like) biproduct comparison for `F`, `X` and `Y` is a monomorphism, then `F` preserves the biproduct of `X` and `Y`. For the converse, see `map_biprod`. -/ def preservesBinaryBiproductOfMonoBiprodComparison {X Y : C} [HasBinaryBiproduct X Y] [HasBinaryBiproduct (F.obj X) (F.obj Y)] [Mono (biprodComparison F X Y)] : PreservesBinaryBiproduct X Y F := by have that : prodComparison F X Y = (F.mapIso (biprod.isoProd X Y)).inv ≫ biprodComparison F X Y ≫ (biprod.isoProd _ _).hom := by ext <;> simp [← Functor.map_comp] haveI : IsIso (biprodComparison F X Y) := isIso_of_mono_of_isSplitEpi _ haveI : IsIso (prodComparison F X Y) := by rw [that] infer_instance haveI := PreservesLimitPair.ofIsoProdComparison F X Y apply preservesBinaryBiproductOfPreservesBinaryProduct /-- If the (coproduct-like) biproduct comparison for `F`, `X` and `Y` is an epimorphism, then `F` preserves the biproduct of `X` and `Y`. For the converse, see `mapBiprod`. -/ def preservesBinaryBiproductOfEpiBiprodComparison' {X Y : C} [HasBinaryBiproduct X Y] [HasBinaryBiproduct (F.obj X) (F.obj Y)] [Epi (biprodComparison' F X Y)] : PreservesBinaryBiproduct X Y F := by haveI : Epi (splitEpiBiprodComparison F X Y).section_ := by simpa haveI : IsIso (biprodComparison F X Y) := IsIso.of_epi_section' (splitEpiBiprodComparison F X Y) apply preservesBinaryBiproductOfMonoBiprodComparison /-- A functor between preadditive categories that preserves (zero morphisms and) binary products preserves binary biproducts. -/ def preservesBinaryBiproductsOfPreservesBinaryProducts [PreservesLimitsOfShape (Discrete WalkingPair) F] : PreservesBinaryBiproducts F where preserves {_} {_} := preservesBinaryBiproductOfPreservesBinaryProduct F /-- A functor between preadditive categories that preserves (zero morphisms and) binary biproducts preserves binary coproducts. -/ def preservesBinaryCoproductOfPreservesBinaryBiproduct {X Y : C} [PreservesBinaryBiproduct X Y F] : PreservesColimit (pair X Y) F where preserves {c} hc := IsColimit.ofIsoColimit ((IsColimit.precomposeHomEquiv (diagramIsoPair _) _).symm (isBinaryBilimitOfPreserves F (binaryBiconeIsBilimitOfColimitCoconeOfIsColimit hc)).isColimit) <| Cocones.ext (by dsimp; rfl) fun j => by rcases j with ⟨⟨⟩⟩ <;> simp section attribute [local instance] preservesBinaryCoproductOfPreservesBinaryBiproduct /-- A functor between preadditive categories that preserves (zero morphisms and) binary biproducts preserves binary coproducts. -/ def preservesBinaryCoproductsOfPreservesBinaryBiproducts [PreservesBinaryBiproducts F] : PreservesColimitsOfShape (Discrete WalkingPair) F where preservesColimit {_} := preservesColimitOfIsoDiagram _ (diagramIsoPair _).symm end /-- A functor between preadditive categories that preserves (zero morphisms and) binary coproducts preserves binary biproducts. -/ def preservesBinaryBiproductOfPreservesBinaryCoproduct {X Y : C} [PreservesColimit (pair X Y) F] : PreservesBinaryBiproduct X Y F where preserves {b} hb := isBinaryBilimitOfIsColimit _ <| IsColimit.ofIsoColimit ((IsColimit.precomposeInvEquiv (diagramIsoPair _) (F.mapCocone b.toCocone)).symm (isColimitOfPreserves F hb.isColimit)) <| Cocones.ext (Iso.refl _) fun j => by rcases j with ⟨⟨⟩⟩ <;> simp /-- A functor between preadditive categories that preserves (zero morphisms and) binary coproducts preserves binary biproducts. -/ def preservesBinaryBiproductsOfPreservesBinaryCoproducts [PreservesColimitsOfShape (Discrete WalkingPair) F] : PreservesBinaryBiproducts F where preserves {_} {_} := preservesBinaryBiproductOfPreservesBinaryCoproduct F end Limits end Preadditive end CategoryTheory
CategoryTheory\Preadditive\EilenbergMoore.lean
/- Copyright (c) 2022 Julian Kuelshammer. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Julian Kuelshammer -/ import Mathlib.CategoryTheory.Preadditive.Basic import Mathlib.CategoryTheory.Monad.Algebra import Mathlib.CategoryTheory.Preadditive.AdditiveFunctor /-! # Preadditive structure on algebras over a monad If `C` is a preadditive category and `T` is an additive monad on `C` then `Algebra T` is also preadditive. Dually, if `U` is an additive comonad on `C` then `Coalgebra U` is preadditive as well. -/ universe v₁ u₁ namespace CategoryTheory variable (C : Type u₁) [Category.{v₁} C] [Preadditive C] (T : Monad C) [Functor.Additive (T : C ⥤ C)] open CategoryTheory.Limits Preadditive /-- The category of algebras over an additive monad on a preadditive category is preadditive. -/ @[simps] instance Monad.algebraPreadditive : Preadditive (Monad.Algebra T) where homGroup F G := { add := fun α β => { f := α.f + β.f h := by simp only [Functor.map_add, add_comp, Monad.Algebra.Hom.h, comp_add] } zero := { f := 0 h := by simp only [Functor.map_zero, zero_comp, comp_zero] } nsmul := fun n α => { f := n • α.f h := by rw [Functor.map_nsmul, nsmul_comp, Monad.Algebra.Hom.h, comp_nsmul] } neg := fun α => { f := -α.f h := by simp only [Functor.map_neg, neg_comp, Monad.Algebra.Hom.h, comp_neg] } sub := fun α β => { f := α.f - β.f h := by simp only [Functor.map_sub, sub_comp, Monad.Algebra.Hom.h, comp_sub] } zsmul := fun r α => { f := r • α.f h := by rw [Functor.map_zsmul, zsmul_comp, Monad.Algebra.Hom.h, comp_zsmul] } add_assoc := by intros ext apply add_assoc zero_add := by intros ext apply zero_add add_zero := by intros ext apply add_zero nsmul_zero := by intros ext apply zero_smul nsmul_succ := by intros ext apply succ_nsmul sub_eq_add_neg := by intros ext apply sub_eq_add_neg zsmul_zero' := by intros ext apply zero_smul zsmul_succ' := by intros ext dsimp simp only [natCast_zsmul, succ_nsmul] rfl zsmul_neg' := by intros ext simp only [negSucc_zsmul, neg_inj, ← Nat.cast_smul_eq_nsmul ℤ] add_left_neg := by intros ext apply add_left_neg add_comm := by intros ext apply add_comm } add_comp := by intros ext apply add_comp comp_add := by intros ext apply comp_add instance Monad.forget_additive : (Monad.forget T).Additive where variable (U : Comonad C) [Functor.Additive (U : C ⥤ C)] /-- The category of coalgebras over an additive comonad on a preadditive category is preadditive. -/ @[simps] instance Comonad.coalgebraPreadditive : Preadditive (Comonad.Coalgebra U) where homGroup F G := { add := fun α β => { f := α.f + β.f h := by simp only [Functor.map_add, comp_add, Comonad.Coalgebra.Hom.h, add_comp] } zero := { f := 0 h := by simp only [Functor.map_zero, comp_zero, zero_comp] } nsmul := fun n α => { f := n • α.f h := by rw [Functor.map_nsmul, comp_nsmul, Comonad.Coalgebra.Hom.h, nsmul_comp] } neg := fun α => { f := -α.f h := by simp only [Functor.map_neg, comp_neg, Comonad.Coalgebra.Hom.h, neg_comp] } sub := fun α β => { f := α.f - β.f h := by simp only [Functor.map_sub, comp_sub, Comonad.Coalgebra.Hom.h, sub_comp] } zsmul := fun r α => { f := r • α.f h := by rw [Functor.map_zsmul, comp_zsmul, Comonad.Coalgebra.Hom.h, zsmul_comp] } add_assoc := by intros ext apply add_assoc zero_add := by intros ext apply zero_add add_zero := by intros ext apply add_zero nsmul_zero := by intros ext apply zero_smul nsmul_succ := by intros ext apply succ_nsmul sub_eq_add_neg := by intros ext apply sub_eq_add_neg zsmul_zero' := by intros ext apply zero_smul zsmul_succ' := by intros ext dsimp simp only [natCast_zsmul, succ_nsmul] rfl zsmul_neg' := by intros ext simp only [negSucc_zsmul, neg_inj, ← Nat.cast_smul_eq_nsmul ℤ] add_left_neg := by intros ext apply add_left_neg add_comm := by intros ext apply add_comm } add_comp := by intros ext apply add_comp comp_add := by intros ext apply comp_add instance Comonad.forget_additive : (Comonad.forget U).Additive where end CategoryTheory
CategoryTheory\Preadditive\EndoFunctor.lean
/- Copyright (c) 2022 Julian Kuelshammer. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Julian Kuelshammer -/ import Mathlib.CategoryTheory.Preadditive.Basic import Mathlib.CategoryTheory.Endofunctor.Algebra import Mathlib.CategoryTheory.Preadditive.AdditiveFunctor /-! # Preadditive structure on algebras over a monad If `C` is a preadditive category and `F` is an additive endofunctor on `C` then `Algebra F` is also preadditive. Dually, the category `Coalgebra F` is also preadditive. -/ universe v₁ u₁ -- morphism levels before object levels. See note [category_theory universes]. namespace CategoryTheory variable (C : Type u₁) [Category.{v₁} C] [Preadditive C] (F : C ⥤ C) [Functor.Additive (F : C ⥤ C)] open CategoryTheory.Limits Preadditive /-- The category of algebras over an additive endofunctor on a preadditive category is preadditive. -/ @[simps] instance Endofunctor.algebraPreadditive : Preadditive (Endofunctor.Algebra F) where homGroup A₁ A₂ := { add := fun α β => { f := α.f + β.f h := by simp only [Functor.map_add, add_comp, Endofunctor.Algebra.Hom.h, comp_add] } zero := { f := 0 h := by simp only [Functor.map_zero, zero_comp, comp_zero] } nsmul := fun n α => { f := n • α.f h := by rw [comp_nsmul, Functor.map_nsmul, nsmul_comp, Endofunctor.Algebra.Hom.h] } neg := fun α => { f := -α.f h := by simp only [Functor.map_neg, neg_comp, Endofunctor.Algebra.Hom.h, comp_neg] } sub := fun α β => { f := α.f - β.f h := by simp only [Functor.map_sub, sub_comp, Endofunctor.Algebra.Hom.h, comp_sub] } zsmul := fun r α => { f := r • α.f h := by rw [comp_zsmul, Functor.map_zsmul, zsmul_comp, Endofunctor.Algebra.Hom.h] } add_assoc := by intros apply Algebra.Hom.ext apply add_assoc zero_add := by intros apply Algebra.Hom.ext apply zero_add add_zero := by intros apply Algebra.Hom.ext apply add_zero nsmul_zero := by intros apply Algebra.Hom.ext apply zero_smul nsmul_succ := by intros apply Algebra.Hom.ext apply succ_nsmul sub_eq_add_neg := by intros apply Algebra.Hom.ext apply sub_eq_add_neg zsmul_zero' := by intros apply Algebra.Hom.ext apply zero_smul zsmul_succ' := by intros apply Algebra.Hom.ext dsimp simp only [natCast_zsmul, succ_nsmul] rfl zsmul_neg' := by intros apply Algebra.Hom.ext simp only [negSucc_zsmul, neg_inj, ← Nat.cast_smul_eq_nsmul ℤ] add_left_neg := by intros apply Algebra.Hom.ext apply add_left_neg add_comm := by intros apply Algebra.Hom.ext apply add_comm } add_comp := by intros apply Algebra.Hom.ext apply add_comp comp_add := by intros apply Algebra.Hom.ext apply comp_add instance Algebra.forget_additive : (Endofunctor.Algebra.forget F).Additive where @[simps] instance Endofunctor.coalgebraPreadditive : Preadditive (Endofunctor.Coalgebra F) where homGroup A₁ A₂ := { add := fun α β => { f := α.f + β.f h := by simp only [Functor.map_add, comp_add, Endofunctor.Coalgebra.Hom.h, add_comp] } zero := { f := 0 h := by simp only [Functor.map_zero, zero_comp, comp_zero] } nsmul := fun n α => { f := n • α.f h := by rw [Functor.map_nsmul, comp_nsmul, Endofunctor.Coalgebra.Hom.h, nsmul_comp] } neg := fun α => { f := -α.f h := by simp only [Functor.map_neg, comp_neg, Endofunctor.Coalgebra.Hom.h, neg_comp] } sub := fun α β => { f := α.f - β.f h := by simp only [Functor.map_sub, comp_sub, Endofunctor.Coalgebra.Hom.h, sub_comp] } zsmul := fun r α => { f := r • α.f h := by rw [Functor.map_zsmul, comp_zsmul, Endofunctor.Coalgebra.Hom.h, zsmul_comp] } add_assoc := by intros apply Coalgebra.Hom.ext apply add_assoc zero_add := by intros apply Coalgebra.Hom.ext apply zero_add add_zero := by intros apply Coalgebra.Hom.ext apply add_zero nsmul_zero := by intros apply Coalgebra.Hom.ext apply zero_smul nsmul_succ := by intros apply Coalgebra.Hom.ext apply succ_nsmul sub_eq_add_neg := by intros apply Coalgebra.Hom.ext apply sub_eq_add_neg zsmul_zero' := by intros apply Coalgebra.Hom.ext apply zero_smul zsmul_succ' := by intros apply Coalgebra.Hom.ext dsimp simp only [natCast_zsmul, succ_nsmul] rfl zsmul_neg' := by intros apply Coalgebra.Hom.ext simp only [negSucc_zsmul, neg_inj, ← Nat.cast_smul_eq_nsmul ℤ] add_left_neg := by intros apply Coalgebra.Hom.ext apply add_left_neg add_comm := by intros apply Coalgebra.Hom.ext apply add_comm } add_comp := by intros apply Coalgebra.Hom.ext apply add_comp comp_add := by intros apply Coalgebra.Hom.ext apply comp_add instance Coalgebra.forget_additive : (Endofunctor.Coalgebra.forget F).Additive where end CategoryTheory
CategoryTheory\Preadditive\FunctorCategory.lean
/- Copyright (c) 2021 Johan Commelin. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johan Commelin -/ import Mathlib.CategoryTheory.Preadditive.Basic /-! # Preadditive structure on functor categories If `C` and `D` are categories and `D` is preadditive, then `C ⥤ D` is also preadditive. -/ namespace CategoryTheory open CategoryTheory.Limits Preadditive variable {C D : Type*} [Category C] [Category D] [Preadditive D] instance {F G : C ⥤ D} : Zero (F ⟶ G) where zero := { app := fun X => 0 } instance {F G : C ⥤ D} : Add (F ⟶ G) where add α β := { app := fun X => α.app X + β.app X } instance {F G : C ⥤ D} : Neg (F ⟶ G) where neg α := { app := fun X => -α.app X } instance functorCategoryPreadditive : Preadditive (C ⥤ D) where homGroup F G := { nsmul := nsmulRec zsmul := zsmulRec sub := fun α β => { app := fun X => α.app X - β.app X } add_assoc := by intros ext apply add_assoc zero_add := by intros dsimp ext apply zero_add add_zero := by intros dsimp ext apply add_zero add_comm := by intros dsimp ext apply add_comm sub_eq_add_neg := by intros dsimp ext apply sub_eq_add_neg add_left_neg := by intros dsimp ext apply add_left_neg } add_comp := by intros dsimp ext apply add_comp comp_add := by intros dsimp ext apply comp_add namespace NatTrans variable {F G : C ⥤ D} /-- Application of a natural transformation at a fixed object, as group homomorphism -/ @[simps] def appHom (X : C) : (F ⟶ G) →+ (F.obj X ⟶ G.obj X) where toFun α := α.app X map_zero' := rfl map_add' _ _ := rfl @[simp] theorem app_zero (X : C) : (0 : F ⟶ G).app X = 0 := rfl @[simp] theorem app_add (X : C) (α β : F ⟶ G) : (α + β).app X = α.app X + β.app X := rfl @[simp] theorem app_sub (X : C) (α β : F ⟶ G) : (α - β).app X = α.app X - β.app X := rfl @[simp] theorem app_neg (X : C) (α : F ⟶ G) : (-α).app X = -α.app X := rfl @[simp] theorem app_nsmul (X : C) (α : F ⟶ G) (n : ℕ) : (n • α).app X = n • α.app X := (appHom X).map_nsmul α n @[simp] theorem app_zsmul (X : C) (α : F ⟶ G) (n : ℤ) : (n • α).app X = n • α.app X := (appHom X : (F ⟶ G) →+ (F.obj X ⟶ G.obj X)).map_zsmul α n @[simp] theorem app_units_zsmul (X : C) (α : F ⟶ G) (n : ℤˣ) : (n • α).app X = n • α.app X := by apply app_zsmul @[simp] theorem app_sum {ι : Type*} (s : Finset ι) (X : C) (α : ι → (F ⟶ G)) : (∑ i ∈ s, α i).app X = ∑ i ∈ s, (α i).app X := by simp only [← appHom_apply, map_sum] end NatTrans end CategoryTheory
CategoryTheory\Preadditive\Generator.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.Generator import Mathlib.CategoryTheory.Preadditive.Yoneda.Basic /-! # Separators in preadditive categories This file contains characterizations of separating sets and objects that are valid in all preadditive categories. -/ universe v u open CategoryTheory Opposite namespace CategoryTheory variable {C : Type u} [Category.{v} C] [Preadditive C] theorem Preadditive.isSeparating_iff (𝒢 : Set C) : IsSeparating 𝒢 ↔ ∀ ⦃X Y : C⦄ (f : X ⟶ Y), (∀ G ∈ 𝒢, ∀ (h : G ⟶ X), h ≫ f = 0) → f = 0 := ⟨fun h𝒢 X Y f hf => h𝒢 _ _ (by simpa only [Limits.comp_zero] using hf), fun h𝒢 X Y f g hfg => sub_eq_zero.1 <| h𝒢 _ (by simpa only [Preadditive.comp_sub, sub_eq_zero] using hfg)⟩ theorem Preadditive.isCoseparating_iff (𝒢 : Set C) : IsCoseparating 𝒢 ↔ ∀ ⦃X Y : C⦄ (f : X ⟶ Y), (∀ G ∈ 𝒢, ∀ (h : Y ⟶ G), f ≫ h = 0) → f = 0 := ⟨fun h𝒢 X Y f hf => h𝒢 _ _ (by simpa only [Limits.zero_comp] using hf), fun h𝒢 X Y f g hfg => sub_eq_zero.1 <| h𝒢 _ (by simpa only [Preadditive.sub_comp, sub_eq_zero] using hfg)⟩ theorem Preadditive.isSeparator_iff (G : C) : IsSeparator G ↔ ∀ ⦃X Y : C⦄ (f : X ⟶ Y), (∀ h : G ⟶ X, h ≫ f = 0) → f = 0 := ⟨fun hG X Y f hf => hG.def _ _ (by simpa only [Limits.comp_zero] using hf), fun hG => (isSeparator_def _).2 fun X Y f g hfg => sub_eq_zero.1 <| hG _ (by simpa only [Preadditive.comp_sub, sub_eq_zero] using hfg)⟩ theorem Preadditive.isCoseparator_iff (G : C) : IsCoseparator G ↔ ∀ ⦃X Y : C⦄ (f : X ⟶ Y), (∀ h : Y ⟶ G, f ≫ h = 0) → f = 0 := ⟨fun hG X Y f hf => hG.def _ _ (by simpa only [Limits.zero_comp] using hf), fun hG => (isCoseparator_def _).2 fun X Y f g hfg => sub_eq_zero.1 <| hG _ (by simpa only [Preadditive.sub_comp, sub_eq_zero] using hfg)⟩ theorem isSeparator_iff_faithful_preadditiveCoyoneda (G : C) : IsSeparator G ↔ (preadditiveCoyoneda.obj (op G)).Faithful := by rw [isSeparator_iff_faithful_coyoneda_obj, ← whiskering_preadditiveCoyoneda, Functor.comp_obj, whiskeringRight_obj_obj] exact ⟨fun h => Functor.Faithful.of_comp _ (forget AddCommGrp), fun h => Functor.Faithful.comp _ _⟩ theorem isSeparator_iff_faithful_preadditiveCoyonedaObj (G : C) : IsSeparator G ↔ (preadditiveCoyonedaObj (op G)).Faithful := by rw [isSeparator_iff_faithful_preadditiveCoyoneda, preadditiveCoyoneda_obj] exact ⟨fun h => Functor.Faithful.of_comp _ (forget₂ _ AddCommGrp.{v}), fun h => Functor.Faithful.comp _ _⟩ theorem isCoseparator_iff_faithful_preadditiveYoneda (G : C) : IsCoseparator G ↔ (preadditiveYoneda.obj G).Faithful := by rw [isCoseparator_iff_faithful_yoneda_obj, ← whiskering_preadditiveYoneda, Functor.comp_obj, whiskeringRight_obj_obj] exact ⟨fun h => Functor.Faithful.of_comp _ (forget AddCommGrp), fun h => Functor.Faithful.comp _ _⟩ theorem isCoseparator_iff_faithful_preadditiveYonedaObj (G : C) : IsCoseparator G ↔ (preadditiveYonedaObj G).Faithful := by rw [isCoseparator_iff_faithful_preadditiveYoneda, preadditiveYoneda_obj] exact ⟨fun h => Functor.Faithful.of_comp _ (forget₂ _ AddCommGrp.{v}), fun h => Functor.Faithful.comp _ _⟩ end CategoryTheory
CategoryTheory\Preadditive\HomOrthogonal.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.Linear.Basic import Mathlib.CategoryTheory.Preadditive.Biproducts import Mathlib.LinearAlgebra.Matrix.InvariantBasisNumber import Mathlib.Data.Set.Subsingleton /-! # Hom orthogonal families. A family of objects in a category with zero morphisms is "hom orthogonal" if the only morphism between distinct objects is the zero morphism. We show that in any category with zero morphisms and finite biproducts, a morphism between biproducts drawn from a hom orthogonal family `s : ι → C` can be decomposed into a block diagonal matrix with entries in the endomorphism rings of the `s i`. When the category is preadditive, this decomposition is an additive equivalence, and intertwines composition and matrix multiplication. When the category is `R`-linear, the decomposition is an `R`-linear equivalence. If every object in the hom orthogonal family has an endomorphism ring with invariant basis number (e.g. if each object in the family is simple, so its endomorphism ring is a division ring, or otherwise if each endomorphism ring is commutative), then decompositions of an object as a biproduct of the family have uniquely defined multiplicities. We state this as: ``` theorem HomOrthogonal.equiv_of_iso (o : HomOrthogonal s) {f : α → ι} {g : β → ι} (i : (⨁ fun a => s (f a)) ≅ ⨁ fun b => s (g b)) : ∃ e : α ≃ β, ∀ a, g (e a) = f a ``` This is preliminary to defining semisimple categories. -/ open scoped Classical open Matrix CategoryTheory.Limits universe v u namespace CategoryTheory variable {C : Type u} [Category.{v} C] /-- A family of objects is "hom orthogonal" if there is at most one morphism between distinct objects. (In a category with zero morphisms, that must be the zero morphism.) -/ def HomOrthogonal {ι : Type*} (s : ι → C) : Prop := Pairwise fun i j => Subsingleton (s i ⟶ s j) namespace HomOrthogonal variable {ι : Type*} {s : ι → C} theorem eq_zero [HasZeroMorphisms C] (o : HomOrthogonal s) {i j : ι} (w : i ≠ j) (f : s i ⟶ s j) : f = 0 := (o w).elim _ _ section variable [HasZeroMorphisms C] [HasFiniteBiproducts C] /-- Morphisms between two direct sums over a hom orthogonal family `s : ι → C` are equivalent to block diagonal matrices, with blocks indexed by `ι`, and matrix entries in `i`-th block living in the endomorphisms of `s i`. -/ @[simps] noncomputable def matrixDecomposition (o : HomOrthogonal s) {α β : Type} [Finite α] [Finite β] {f : α → ι} {g : β → ι} : ((⨁ fun a => s (f a)) ⟶ ⨁ fun b => s (g b)) ≃ ∀ i : ι, Matrix (g ⁻¹' {i}) (f ⁻¹' {i}) (End (s i)) where toFun z i j k := eqToHom (by rcases k with ⟨k, ⟨⟩⟩ simp) ≫ biproduct.components z k j ≫ eqToHom (by rcases j with ⟨j, ⟨⟩⟩ simp) invFun z := biproduct.matrix fun j k => if h : f j = g k then z (f j) ⟨k, by simp [h]⟩ ⟨j, by simp⟩ ≫ eqToHom (by simp [h]) else 0 left_inv z := by ext j k simp only [biproduct.matrix_π, biproduct.ι_desc] split_ifs with h · simp rfl · symm apply o.eq_zero h right_inv z := by ext i ⟨j, w⟩ ⟨k, ⟨⟩⟩ simp only [eqToHom_refl, biproduct.matrix_components, Category.id_comp] split_ifs with h · simp · exfalso exact h w.symm end section variable [Preadditive C] [HasFiniteBiproducts C] /-- `HomOrthogonal.matrixDecomposition` as an additive equivalence. -/ @[simps!] noncomputable def matrixDecompositionAddEquiv (o : HomOrthogonal s) {α β : Type} [Finite α] [Finite β] {f : α → ι} {g : β → ι} : ((⨁ fun a => s (f a)) ⟶ ⨁ fun b => s (g b)) ≃+ ∀ i : ι, Matrix (g ⁻¹' {i}) (f ⁻¹' {i}) (End (s i)) := { o.matrixDecomposition with map_add' := fun w z => by ext dsimp [biproduct.components] simp } @[simp] theorem matrixDecomposition_id (o : HomOrthogonal s) {α : Type} [Finite α] {f : α → ι} (i : ι) : o.matrixDecomposition (𝟙 (⨁ fun a => s (f a))) i = 1 := by ext ⟨b, ⟨⟩⟩ ⟨a, j_property⟩ simp only [Set.mem_preimage, Set.mem_singleton_iff] at j_property simp only [Category.comp_id, Category.id_comp, Category.assoc, End.one_def, eqToHom_refl, Matrix.one_apply, HomOrthogonal.matrixDecomposition_apply, biproduct.components] split_ifs with h · cases h simp · simp only [Subtype.mk.injEq] at h -- Porting note: used to be `convert comp_zero`, but that does not work anymore have : biproduct.ι (fun a ↦ s (f a)) a ≫ biproduct.π (fun b ↦ s (f b)) b = 0 := by simpa using biproduct.ι_π_ne _ (Ne.symm h) rw [this, comp_zero] theorem matrixDecomposition_comp (o : HomOrthogonal s) {α β γ : Type} [Finite α] [Fintype β] [Finite γ] {f : α → ι} {g : β → ι} {h : γ → ι} (z : (⨁ fun a => s (f a)) ⟶ ⨁ fun b => s (g b)) (w : (⨁ fun b => s (g b)) ⟶ ⨁ fun c => s (h c)) (i : ι) : o.matrixDecomposition (z ≫ w) i = o.matrixDecomposition w i * o.matrixDecomposition z i := by ext ⟨c, ⟨⟩⟩ ⟨a, j_property⟩ simp only [Set.mem_preimage, Set.mem_singleton_iff] at j_property simp only [Matrix.mul_apply, Limits.biproduct.components, HomOrthogonal.matrixDecomposition_apply, Category.comp_id, Category.id_comp, Category.assoc, End.mul_def, eqToHom_refl, eqToHom_trans_assoc, Finset.sum_congr] conv_lhs => rw [← Category.id_comp w, ← biproduct.total] simp only [Preadditive.sum_comp, Preadditive.comp_sum] apply Finset.sum_congr_set · simp · intro b nm simp only [Set.mem_preimage, Set.mem_singleton_iff] at nm simp only [Category.assoc] -- Porting note: this used to be 4 times `convert comp_zero` have : biproduct.ι (fun b ↦ s (g b)) b ≫ w ≫ biproduct.π (fun b ↦ s (h b)) c = 0 := by apply o.eq_zero nm simp only [this, comp_zero] section variable {R : Type*} [Semiring R] [Linear R C] /-- `HomOrthogonal.MatrixDecomposition` as an `R`-linear equivalence. -/ @[simps] noncomputable def matrixDecompositionLinearEquiv (o : HomOrthogonal s) {α β : Type} [Finite α] [Finite β] {f : α → ι} {g : β → ι} : ((⨁ fun a => s (f a)) ⟶ ⨁ fun b => s (g b)) ≃ₗ[R] ∀ i : ι, Matrix (g ⁻¹' {i}) (f ⁻¹' {i}) (End (s i)) := { o.matrixDecompositionAddEquiv with map_smul' := fun w z => by ext dsimp [biproduct.components] simp } end /-! The hypothesis that `End (s i)` has invariant basis number is automatically satisfied if `s i` is simple (as then `End (s i)` is a division ring). -/ variable [∀ i, InvariantBasisNumber (End (s i))] /-- Given a hom orthogonal family `s : ι → C` for which each `End (s i)` is a ring with invariant basis number (e.g. if each `s i` is simple), if two direct sums over `s` are isomorphic, then they have the same multiplicities. -/ theorem equiv_of_iso (o : HomOrthogonal s) {α β : Type} [Finite α] [Finite β] {f : α → ι} {g : β → ι} (i : (⨁ fun a => s (f a)) ≅ ⨁ fun b => s (g b)) : ∃ e : α ≃ β, ∀ a, g (e a) = f a := by refine ⟨Equiv.ofPreimageEquiv ?_, fun a => Equiv.ofPreimageEquiv_map _ _⟩ intro c apply Nonempty.some apply Cardinal.eq.1 cases nonempty_fintype α; cases nonempty_fintype β simp only [Cardinal.mk_fintype, Nat.cast_inj] exact Matrix.square_of_invertible (o.matrixDecomposition i.inv c) (o.matrixDecomposition i.hom c) (by rw [← o.matrixDecomposition_comp] simp) (by rw [← o.matrixDecomposition_comp] simp) end end HomOrthogonal end CategoryTheory
CategoryTheory\Preadditive\Injective.lean
/- Copyright (c) 2022 Jujian Zhang. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jujian Zhang, Kevin Buzzard -/ import Mathlib.CategoryTheory.Preadditive.Projective /-! # Injective objects and categories with enough injectives An object `J` is injective iff every morphism into `J` can be obtained by extending a monomorphism. -/ noncomputable section open CategoryTheory open CategoryTheory.Limits open Opposite universe v v₁ v₂ u₁ u₂ namespace CategoryTheory variable {C : Type u₁} [Category.{v₁} C] /-- An object `J` is injective iff every morphism into `J` can be obtained by extending a monomorphism. -/ class Injective (J : C) : Prop where factors : ∀ {X Y : C} (g : X ⟶ J) (f : X ⟶ Y) [Mono f], ∃ h : Y ⟶ J, f ≫ h = g attribute [inherit_doc Injective] Injective.factors lemma Limits.IsZero.injective {X : C} (h : IsZero X) : Injective X where factors _ _ _ := ⟨h.from_ _, h.eq_of_tgt _ _⟩ section /-- An injective presentation of an object `X` consists of a monomorphism `f : X ⟶ J` to some injective object `J`. -/ structure InjectivePresentation (X : C) where J : C injective : Injective J := by infer_instance f : X ⟶ J mono : Mono f := by infer_instance open InjectivePresentation in attribute [inherit_doc InjectivePresentation] J injective f mono attribute [instance] InjectivePresentation.injective InjectivePresentation.mono variable (C) /-- A category "has enough injectives" if every object has an injective presentation, i.e. if for every object `X` there is an injective object `J` and a monomorphism `X ↪ J`. -/ class EnoughInjectives : Prop where presentation : ∀ X : C, Nonempty (InjectivePresentation X) attribute [inherit_doc EnoughInjectives] EnoughInjectives.presentation end namespace Injective /-- Let `J` be injective and `g` a morphism into `J`, then `g` can be factored through any monomorphism. -/ def factorThru {J X Y : C} [Injective J] (g : X ⟶ J) (f : X ⟶ Y) [Mono f] : Y ⟶ J := (Injective.factors g f).choose @[simp] theorem comp_factorThru {J X Y : C} [Injective J] (g : X ⟶ J) (f : X ⟶ Y) [Mono f] : f ≫ factorThru g f = g := (Injective.factors g f).choose_spec section open ZeroObject instance zero_injective [HasZeroObject C] : Injective (0 : C) := (isZero_zero C).injective end theorem of_iso {P Q : C} (i : P ≅ Q) (hP : Injective P) : Injective Q := { factors := fun g f mono => by obtain ⟨h, h_eq⟩ := @Injective.factors C _ P _ _ _ (g ≫ i.inv) f mono refine ⟨h ≫ i.hom, ?_⟩ rw [← Category.assoc, h_eq, Category.assoc, Iso.inv_hom_id, Category.comp_id] } theorem iso_iff {P Q : C} (i : P ≅ Q) : Injective P ↔ Injective Q := ⟨of_iso i, of_iso i.symm⟩ /-- The axiom of choice says that every nonempty type is an injective object in `Type`. -/ instance (X : Type u₁) [Nonempty X] : Injective X where factors g f mono := ⟨fun z => by classical exact if h : z ∈ Set.range f then g (Classical.choose h) else Nonempty.some inferInstance, by ext y classical change dite (f y ∈ Set.range f) (fun h => g (Classical.choose h)) _ = _ split_ifs <;> rename_i h · rw [mono_iff_injective] at mono erw [mono (Classical.choose_spec h)] · exact False.elim (h ⟨y, rfl⟩)⟩ instance Type.enoughInjectives : EnoughInjectives (Type u₁) where presentation X := Nonempty.intro { J := WithBot X injective := inferInstance f := Option.some mono := by rw [mono_iff_injective] exact Option.some_injective X } instance {P Q : C} [HasBinaryProduct P Q] [Injective P] [Injective Q] : Injective (P ⨯ Q) where factors g f mono := by use Limits.prod.lift (factorThru (g ≫ Limits.prod.fst) f) (factorThru (g ≫ Limits.prod.snd) f) simp only [prod.comp_lift, comp_factorThru] ext · simp only [prod.lift_fst] · simp only [prod.lift_snd] instance {β : Type v} (c : β → C) [HasProduct c] [∀ b, Injective (c b)] : Injective (∏ᶜ c) where factors g f mono := by refine ⟨Pi.lift fun b => factorThru (g ≫ Pi.π c _) f, ?_⟩ ext b simp only [Category.assoc, limit.lift_π, Fan.mk_π_app, comp_factorThru] instance {P Q : C} [HasZeroMorphisms C] [HasBinaryBiproduct P Q] [Injective P] [Injective Q] : Injective (P ⊞ Q) where factors g f mono := by refine ⟨biprod.lift (factorThru (g ≫ biprod.fst) f) (factorThru (g ≫ biprod.snd) f), ?_⟩ ext · simp only [Category.assoc, biprod.lift_fst, comp_factorThru] · simp only [Category.assoc, biprod.lift_snd, comp_factorThru] instance {β : Type v} (c : β → C) [HasZeroMorphisms C] [HasBiproduct c] [∀ b, Injective (c b)] : Injective (⨁ c) where factors g f mono := by refine ⟨biproduct.lift fun b => factorThru (g ≫ biproduct.π _ _) f, ?_⟩ ext simp only [Category.assoc, biproduct.lift_π, comp_factorThru] instance {P : Cᵒᵖ} [Projective P] : Injective no_index (unop P) where factors g f mono := ⟨(@Projective.factorThru Cᵒᵖ _ P _ _ _ g.op f.op _).unop, Quiver.Hom.op_inj (by simp)⟩ instance {J : Cᵒᵖ} [Injective J] : Projective no_index (unop J) where factors f e he := ⟨(@factorThru Cᵒᵖ _ J _ _ _ f.op e.op _).unop, Quiver.Hom.op_inj (by simp)⟩ instance {J : C} [Injective J] : Projective (op J) where factors f e epi := ⟨(@factorThru C _ J _ _ _ f.unop e.unop _).op, Quiver.Hom.unop_inj (by simp)⟩ instance {P : C} [Projective P] : Injective (op P) where factors g f mono := ⟨(@Projective.factorThru C _ P _ _ _ g.unop f.unop _).op, Quiver.Hom.unop_inj (by simp)⟩ theorem injective_iff_projective_op {J : C} : Injective J ↔ Projective (op J) := ⟨fun _ => inferInstance, fun _ => show Injective (unop (op J)) from inferInstance⟩ theorem projective_iff_injective_op {P : C} : Projective P ↔ Injective (op P) := ⟨fun _ => inferInstance, fun _ => show Projective (unop (op P)) from inferInstance⟩ theorem injective_iff_preservesEpimorphisms_yoneda_obj (J : C) : Injective J ↔ (yoneda.obj J).PreservesEpimorphisms := by rw [injective_iff_projective_op, Projective.projective_iff_preservesEpimorphisms_coyoneda_obj] exact Functor.preservesEpimorphisms.iso_iff (Coyoneda.objOpOp _) section Adjunction open CategoryTheory.Functor variable {D : Type u₂} [Category.{v₂} D] variable {L : C ⥤ D} {R : D ⥤ C} [PreservesMonomorphisms L] theorem injective_of_adjoint (adj : L ⊣ R) (J : D) [Injective J] : Injective <| R.obj J := ⟨fun {A} {_} g f im => ⟨adj.homEquiv _ _ (factorThru ((adj.homEquiv A J).symm g) (L.map f)), (adj.homEquiv _ _).symm.injective (by simp)⟩⟩ end Adjunction section EnoughInjectives variable [EnoughInjectives C] /-- `Injective.under X` provides an arbitrarily chosen injective object equipped with a monomorphism `Injective.ι : X ⟶ Injective.under X`. -/ def under (X : C) : C := (EnoughInjectives.presentation X).some.J instance injective_under (X : C) : Injective (under X) := (EnoughInjectives.presentation X).some.injective /-- The monomorphism `Injective.ι : X ⟶ Injective.under X` from the arbitrarily chosen injective object under `X`. -/ def ι (X : C) : X ⟶ under X := (EnoughInjectives.presentation X).some.f instance ι_mono (X : C) : Mono (ι X) := (EnoughInjectives.presentation X).some.mono section variable [HasZeroMorphisms C] {X Y : C} (f : X ⟶ Y) [HasCokernel f] /-- When `C` has enough injectives, the object `Injective.syzygies f` is an arbitrarily chosen injective object under `cokernel f`. -/ def syzygies : C := under (cokernel f) -- Porting note: no deriving Injective instance : Injective <| syzygies f := injective_under (cokernel f) /-- When `C` has enough injective, `Injective.d f : Y ⟶ syzygies f` is the composition `cokernel.π f ≫ ι (cokernel f)`. (When `C` is abelian, we have `exact f (injective.d f)`.) -/ abbrev d : Y ⟶ syzygies f := cokernel.π f ≫ ι (cokernel f) end end EnoughInjectives instance [EnoughInjectives C] : EnoughProjectives Cᵒᵖ := ⟨fun X => ⟨{ p := _, f := (Injective.ι (unop X)).op}⟩⟩ instance [EnoughProjectives C] : EnoughInjectives Cᵒᵖ := ⟨fun X => ⟨⟨_, inferInstance, (Projective.π (unop X)).op, inferInstance⟩⟩⟩ theorem enoughProjectives_of_enoughInjectives_op [EnoughInjectives Cᵒᵖ] : EnoughProjectives C := ⟨fun X => ⟨{ p := _, f := (Injective.ι (op X)).unop} ⟩⟩ theorem enoughInjectives_of_enoughProjectives_op [EnoughProjectives Cᵒᵖ] : EnoughInjectives C := ⟨fun X => ⟨⟨_, inferInstance, (Projective.π (op X)).unop, inferInstance⟩⟩⟩ end Injective namespace Adjunction variable {D : Type*} [Category D] {F : C ⥤ D} {G : D ⥤ C} theorem map_injective (adj : F ⊣ G) [F.PreservesMonomorphisms] (I : D) (hI : Injective I) : Injective (G.obj I) := ⟨fun {X} {Y} f g => by intro rcases hI.factors (F.map f ≫ adj.counit.app _) (F.map g) with ⟨w,h⟩ use adj.unit.app Y ≫ G.map w rw [← unit_naturality_assoc, ← G.map_comp, h] simp⟩ theorem injective_of_map_injective (adj : F ⊣ G) [G.Full] [G.Faithful] (I : D) (hI : Injective (G.obj I)) : Injective I := ⟨fun {X} {Y} f g => by intro haveI : PreservesLimitsOfSize.{0, 0} G := adj.rightAdjointPreservesLimits rcases hI.factors (G.map f) (G.map g) with ⟨w,h⟩ use inv (adj.counit.app _) ≫ F.map w ≫ adj.counit.app _ exact G.map_injective (by simpa)⟩ /-- Given an adjunction `F ⊣ G` such that `F` preserves monos, `G` maps an injective presentation of `X` to an injective presentation of `G(X)`. -/ def mapInjectivePresentation (adj : F ⊣ G) [F.PreservesMonomorphisms] (X : D) (I : InjectivePresentation X) : InjectivePresentation (G.obj X) where J := G.obj I.J injective := adj.map_injective _ I.injective f := G.map I.f mono := by haveI : PreservesLimitsOfSize.{0, 0} G := adj.rightAdjointPreservesLimits; infer_instance /-- Given an adjunction `F ⊣ G` such that `F` preserves monomorphisms and is faithful, then any injective presentation of `F(X)` can be pulled back to an injective presentation of `X`. This is similar to `mapInjectivePresentation`. -/ def injectivePresentationOfMap (adj : F ⊣ G) [F.PreservesMonomorphisms] [F.ReflectsMonomorphisms] (X : C) (I : InjectivePresentation <| F.obj X) : InjectivePresentation X where J := G.obj I.J injective := Injective.injective_of_adjoint adj _ f := adj.homEquiv _ _ I.f end Adjunction /-- [Lemma 3.8](https://ncatlab.org/nlab/show/injective+object#preservation_of_injective_objects) -/ lemma EnoughInjectives.of_adjunction {C : Type u₁} {D : Type u₂} [Category.{v₁} C] [Category.{v₂} D] {L : C ⥤ D} {R : D ⥤ C} (adj : L ⊣ R) [L.PreservesMonomorphisms] [L.ReflectsMonomorphisms] [EnoughInjectives D] : EnoughInjectives C where presentation _ := ⟨adj.injectivePresentationOfMap _ (EnoughInjectives.presentation _).some⟩ /-- An equivalence of categories transfers enough injectives. -/ lemma EnoughInjectives.of_equivalence {C : Type u₁} {D : Type u₂} [Category.{v₁} C] [Category.{v₂} D] (e : C ⥤ D) [e.IsEquivalence] [EnoughInjectives D] : EnoughInjectives C := EnoughInjectives.of_adjunction (adj := e.asEquivalence.toAdjunction) namespace Equivalence variable {D : Type*} [Category D] (F : C ≌ D) theorem map_injective_iff (P : C) : Injective (F.functor.obj P) ↔ Injective P := ⟨F.symm.toAdjunction.injective_of_map_injective P, F.symm.toAdjunction.map_injective P⟩ /-- Given an equivalence of categories `F`, an injective presentation of `F(X)` induces an injective presentation of `X.` -/ def injectivePresentationOfMapInjectivePresentation (X : C) (I : InjectivePresentation (F.functor.obj X)) : InjectivePresentation X := F.toAdjunction.injectivePresentationOfMap _ I theorem enoughInjectives_iff (F : C ≌ D) : EnoughInjectives C ↔ EnoughInjectives D := ⟨fun h => h.of_adjunction F.symm.toAdjunction, fun h => h.of_adjunction F.toAdjunction⟩ end Equivalence end CategoryTheory
CategoryTheory\Preadditive\InjectiveResolution.lean
/- Copyright (c) 2022 Jujian Zhang. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jujian Zhang, Scott Morrison, Joël Riou -/ import Mathlib.Algebra.Homology.QuasiIso import Mathlib.Algebra.Homology.ShortComplex.HomologicalComplex import Mathlib.Algebra.Homology.SingleHomology import Mathlib.CategoryTheory.Preadditive.Injective /-! # Injective resolutions An injective resolution `I : InjectiveResolution Z` of an object `Z : C` consists of an `ℕ`-indexed cochain complex `I.cocomplex` of injective objects, along with a quasi-isomorphism `I.ι` from the cochain complex consisting just of `Z` in degree zero to `I.cocomplex`. ``` Z ----> 0 ----> ... ----> 0 ----> ... | | | | | | v v v I⁰ ---> I¹ ---> ... ----> Iⁿ ---> ... ``` -/ noncomputable section universe v u namespace CategoryTheory open Limits HomologicalComplex CochainComplex variable {C : Type u} [Category.{v} C] [HasZeroObject C] [HasZeroMorphisms C] /-- An `InjectiveResolution Z` consists of a bundled `ℕ`-indexed cochain complex of injective objects, along with a quasi-isomorphism from the complex consisting of just `Z` supported in degree `0`. -/ -- Porting note(#5171): this linter isn't ported yet. -- @[nolint has_nonempty_instance] structure InjectiveResolution (Z : C) where /-- the cochain complex involved in the resolution -/ cocomplex : CochainComplex C ℕ /-- the cochain complex must be degreewise injective -/ injective : ∀ n, Injective (cocomplex.X n) := by infer_instance /-- the cochain complex must have homology -/ [hasHomology : ∀ i, cocomplex.HasHomology i] /-- the morphism from the single cochain complex with `Z` in degree `0` -/ ι : (single₀ C).obj Z ⟶ cocomplex /-- the morphism from the single cochain complex with `Z` in degree `0` is a quasi-isomorphism -/ quasiIso : QuasiIso ι := by infer_instance open InjectiveResolution in attribute [instance] injective hasHomology InjectiveResolution.quasiIso /-- An object admits an injective resolution. -/ class HasInjectiveResolution (Z : C) : Prop where out : Nonempty (InjectiveResolution Z) attribute [inherit_doc HasInjectiveResolution] HasInjectiveResolution.out section variable (C) /-- You will rarely use this typeclass directly: it is implied by the combination `[EnoughInjectives C]` and `[Abelian C]`. -/ class HasInjectiveResolutions : Prop where out : ∀ Z : C, HasInjectiveResolution Z attribute [instance 100] HasInjectiveResolutions.out end namespace InjectiveResolution variable {Z : C} (I : InjectiveResolution Z) lemma cocomplex_exactAt_succ (n : ℕ) : I.cocomplex.ExactAt (n + 1) := by rw [← quasiIsoAt_iff_exactAt I.ι (n + 1) (exactAt_succ_single_obj _ _)] infer_instance lemma exact_succ (n : ℕ) : (ShortComplex.mk _ _ (I.cocomplex.d_comp_d n (n + 1) (n + 2))).Exact := (HomologicalComplex.exactAt_iff' _ n (n + 1) (n + 2) (by simp) (by simp only [CochainComplex.next]; rfl)).1 (I.cocomplex_exactAt_succ n) @[simp] theorem ι_f_succ (n : ℕ) : I.ι.f (n + 1) = 0 := (isZero_single_obj_X _ _ _ _ (by simp)).eq_of_src _ _ -- Porting note (#10618): removed @[simp] simp can prove this @[reassoc] theorem ι_f_zero_comp_complex_d : I.ι.f 0 ≫ I.cocomplex.d 0 1 = 0 := by simp -- Porting note (#10618): removed @[simp] simp can prove this theorem complex_d_comp (n : ℕ) : I.cocomplex.d n (n + 1) ≫ I.cocomplex.d (n + 1) (n + 2) = 0 := by simp /-- The (limit) kernel fork given by the composition `Z ⟶ I.cocomplex.X 0 ⟶ I.cocomplex.X 1` when `I : InjectiveResolution Z`. -/ @[simp] def kernelFork : KernelFork (I.cocomplex.d 0 1) := KernelFork.ofι _ I.ι_f_zero_comp_complex_d /-- `Z` is the kernel of `I.cocomplex.X 0 ⟶ I.cocomplex.X 1` when `I : InjectiveResolution Z`. -/ def isLimitKernelFork : IsLimit (I.kernelFork) := by refine IsLimit.ofIsoLimit (I.cocomplex.cyclesIsKernel 0 1 (by simp)) (Iso.symm ?_) refine Fork.ext ((singleObjHomologySelfIso _ _ _).symm ≪≫ isoOfQuasiIsoAt I.ι 0 ≪≫ I.cocomplex.isoHomologyπ₀.symm) ?_ rw [← cancel_epi (singleObjHomologySelfIso (ComplexShape.up ℕ) _ _).hom, ← cancel_epi (isoHomologyπ₀ _).hom, ← cancel_epi (singleObjCyclesSelfIso (ComplexShape.up ℕ) _ _).inv] simp instance (n : ℕ) : Mono (I.ι.f n) := by cases n · exact mono_of_isLimit_fork I.isLimitKernelFork · rw [ι_f_succ]; infer_instance variable (Z) /-- An injective object admits a trivial injective resolution: itself in degree 0. -/ @[simps] def self [Injective Z] : InjectiveResolution Z where cocomplex := (CochainComplex.single₀ C).obj Z ι := 𝟙 ((CochainComplex.single₀ C).obj Z) injective n := by cases n · simpa · apply IsZero.injective apply HomologicalComplex.isZero_single_obj_X simp end InjectiveResolution end CategoryTheory
CategoryTheory\Preadditive\LeftExact.lean
/- Copyright (c) 2022 Jakob von Raumer. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Markus Himmel, Jakob von Raumer -/ import Mathlib.CategoryTheory.Limits.Constructions.FiniteProductsOfBinaryProducts import Mathlib.CategoryTheory.Limits.Preserves.Shapes.Kernels import Mathlib.CategoryTheory.Limits.Constructions.LimitsOfProductsAndEqualizers import Mathlib.CategoryTheory.Preadditive.AdditiveFunctor /-! # Left exactness of functors between preadditive categories We show that a functor is left exact in the sense that it preserves finite limits, if it preserves kernels. The dual result holds for right exact functors and cokernels. ## Main results * We first derive preservation of binary product in the lemma `preservesBinaryProductsOfPreservesKernels`, * then show the preservation of equalizers in `preservesEqualizerOfPreservesKernels`, * and then derive the preservation of all finite limits with the usual construction. -/ universe v₁ v₂ u₁ u₂ noncomputable section open CategoryTheory open CategoryTheory.Limits open CategoryTheory.Preadditive namespace CategoryTheory namespace Functor variable {C : Type u₁} [Category.{v₁} C] [Preadditive C] {D : Type u₂} [Category.{v₂} D] [Preadditive D] (F : C ⥤ D) [PreservesZeroMorphisms F] section FiniteLimits /-- A functor between preadditive categories which preserves kernels preserves that an arbitrary binary fan is a limit. -/ def isLimitMapConeBinaryFanOfPreservesKernels {X Y Z : C} (π₁ : Z ⟶ X) (π₂ : Z ⟶ Y) [PreservesLimit (parallelPair π₂ 0) F] (i : IsLimit (BinaryFan.mk π₁ π₂)) : IsLimit (F.mapCone (BinaryFan.mk π₁ π₂)) := by let bc := BinaryBicone.ofLimitCone i let presf : PreservesLimit (parallelPair bc.snd 0) F := by simpa let hf : IsLimit bc.sndKernelFork := BinaryBicone.isLimitSndKernelFork i exact (isLimitMapConeBinaryFanEquiv F π₁ π₂).invFun (BinaryBicone.isBilimitOfKernelInl (F.mapBinaryBicone bc) (isLimitMapConeForkEquiv' F bc.inl_snd (isLimitOfPreserves F hf))).isLimit /-- A kernel preserving functor between preadditive categories preserves any pair being a limit. -/ def preservesBinaryProductOfPreservesKernels [∀ {X Y} (f : X ⟶ Y), PreservesLimit (parallelPair f 0) F] {X Y : C} : PreservesLimit (pair X Y) F where preserves {c} hc := IsLimit.ofIsoLimit (isLimitMapConeBinaryFanOfPreservesKernels F _ _ (IsLimit.ofIsoLimit hc (isoBinaryFanMk c))) ((Cones.functoriality _ F).mapIso (isoBinaryFanMk c).symm) attribute [local instance] preservesBinaryProductOfPreservesKernels /-- A kernel preserving functor between preadditive categories preserves binary products. -/ def preservesBinaryProductsOfPreservesKernels [∀ {X Y} (f : X ⟶ Y), PreservesLimit (parallelPair f 0) F] : PreservesLimitsOfShape (Discrete WalkingPair) F where preservesLimit := preservesLimitOfIsoDiagram F (diagramIsoPair _).symm attribute [local instance] preservesBinaryProductsOfPreservesKernels variable [HasBinaryBiproducts C] /-- A functor between preadditive categories preserves the equalizer of two morphisms if it preserves all kernels. -/ def preservesEqualizerOfPreservesKernels [∀ {X Y} (f : X ⟶ Y), PreservesLimit (parallelPair f 0) F] {X Y : C} (f g : X ⟶ Y) : PreservesLimit (parallelPair f g) F := by letI := preservesBinaryBiproductsOfPreservesBinaryProducts F haveI := additive_of_preservesBinaryBiproducts F constructor; intro c i let c' := isLimitKernelForkOfFork (i.ofIsoLimit (Fork.isoForkOfι c)) dsimp only [kernelForkOfFork_ofι] at c' let iFc := isLimitForkMapOfIsLimit' F _ c' apply IsLimit.ofIsoLimit _ ((Cones.functoriality _ F).mapIso (Fork.isoForkOfι c).symm) apply (isLimitMapConeForkEquiv F (Fork.condition c)).invFun let p : parallelPair (F.map (f - g)) 0 ≅ parallelPair (F.map f - F.map g) 0 := parallelPair.eqOfHomEq F.map_sub rfl exact IsLimit.ofIsoLimit (isLimitForkOfKernelFork ((IsLimit.postcomposeHomEquiv p _).symm iFc)) (Fork.ext (Iso.refl _) (by simp [p])) /-- A functor between preadditive categories preserves all equalizers if it preserves all kernels. -/ def preservesEqualizersOfPreservesKernels [∀ {X Y} (f : X ⟶ Y), PreservesLimit (parallelPair f 0) F] : PreservesLimitsOfShape WalkingParallelPair F where preservesLimit {K} := by letI := preservesEqualizerOfPreservesKernels F (K.map WalkingParallelPairHom.left) (K.map WalkingParallelPairHom.right) apply preservesLimitOfIsoDiagram F (diagramIsoParallelPair K).symm /-- A functor between preadditive categories which preserves kernels preserves all finite limits. -/ def preservesFiniteLimitsOfPreservesKernels [HasFiniteProducts C] [HasEqualizers C] [HasZeroObject C] [HasZeroObject D] [∀ {X Y} (f : X ⟶ Y), PreservesLimit (parallelPair f 0) F] : PreservesFiniteLimits F := by letI := preservesEqualizersOfPreservesKernels F letI := preservesTerminalObjectOfPreservesZeroMorphisms F letI := preservesLimitsOfShapePemptyOfPreservesTerminal F letI : PreservesFiniteProducts F := ⟨preservesFiniteProductsOfPreservesBinaryAndTerminal F⟩ exact preservesFiniteLimitsOfPreservesEqualizersAndFiniteProducts F end FiniteLimits section FiniteColimits /-- A functor between preadditive categories which preserves cokernels preserves finite coproducts. -/ def isColimitMapCoconeBinaryCofanOfPreservesCokernels {X Y Z : C} (ι₁ : X ⟶ Z) (ι₂ : Y ⟶ Z) [PreservesColimit (parallelPair ι₂ 0) F] (i : IsColimit (BinaryCofan.mk ι₁ ι₂)) : IsColimit (F.mapCocone (BinaryCofan.mk ι₁ ι₂)) := by let bc := BinaryBicone.ofColimitCocone i let presf : PreservesColimit (parallelPair bc.inr 0) F := by simpa let hf : IsColimit bc.inrCokernelCofork := BinaryBicone.isColimitInrCokernelCofork i exact (isColimitMapCoconeBinaryCofanEquiv F ι₁ ι₂).invFun (BinaryBicone.isBilimitOfCokernelFst (F.mapBinaryBicone bc) (isColimitMapCoconeCoforkEquiv' F bc.inr_fst (isColimitOfPreserves F hf))).isColimit /-- A cokernel preserving functor between preadditive categories preserves any pair being a colimit. -/ def preservesCoproductOfPreservesCokernels [∀ {X Y} (f : X ⟶ Y), PreservesColimit (parallelPair f 0) F] {X Y : C} : PreservesColimit (pair X Y) F where preserves {c} hc := IsColimit.ofIsoColimit (isColimitMapCoconeBinaryCofanOfPreservesCokernels F _ _ (IsColimit.ofIsoColimit hc (isoBinaryCofanMk c))) ((Cocones.functoriality _ F).mapIso (isoBinaryCofanMk c).symm) attribute [local instance] preservesCoproductOfPreservesCokernels /-- A cokernel preserving functor between preadditive categories preserves binary coproducts. -/ def preservesBinaryCoproductsOfPreservesCokernels [∀ {X Y} (f : X ⟶ Y), PreservesColimit (parallelPair f 0) F] : PreservesColimitsOfShape (Discrete WalkingPair) F where preservesColimit := preservesColimitOfIsoDiagram F (diagramIsoPair _).symm attribute [local instance] preservesBinaryCoproductsOfPreservesCokernels variable [HasBinaryBiproducts C] /-- A functor between preadditive categories preserves the coequalizer of two morphisms if it preserves all cokernels. -/ def preservesCoequalizerOfPreservesCokernels [∀ {X Y} (f : X ⟶ Y), PreservesColimit (parallelPair f 0) F] {X Y : C} (f g : X ⟶ Y) : PreservesColimit (parallelPair f g) F := by letI := preservesBinaryBiproductsOfPreservesBinaryCoproducts F haveI := additive_of_preservesBinaryBiproducts F constructor intro c i let c' := isColimitCokernelCoforkOfCofork (i.ofIsoColimit (Cofork.isoCoforkOfπ c)) dsimp only [cokernelCoforkOfCofork_ofπ] at c' let iFc := isColimitCoforkMapOfIsColimit' F _ c' apply IsColimit.ofIsoColimit _ ((Cocones.functoriality _ F).mapIso (Cofork.isoCoforkOfπ c).symm) apply (isColimitMapCoconeCoforkEquiv F (Cofork.condition c)).invFun let p : parallelPair (F.map (f - g)) 0 ≅ parallelPair (F.map f - F.map g) 0 := parallelPair.ext (Iso.refl _) (Iso.refl _) (by simp) (by simp) exact IsColimit.ofIsoColimit (isColimitCoforkOfCokernelCofork ((IsColimit.precomposeHomEquiv p.symm _).symm iFc)) (Cofork.ext (Iso.refl _) (by simp [p])) /-- A functor between preadditive categories preserves all coequalizers if it preserves all kernels. -/ def preservesCoequalizersOfPreservesCokernels [∀ {X Y} (f : X ⟶ Y), PreservesColimit (parallelPair f 0) F] : PreservesColimitsOfShape WalkingParallelPair F where preservesColimit {K} := by letI := preservesCoequalizerOfPreservesCokernels F (K.map Limits.WalkingParallelPairHom.left) (K.map Limits.WalkingParallelPairHom.right) apply preservesColimitOfIsoDiagram F (diagramIsoParallelPair K).symm /-- A functor between preadditive categories which preserves kernels preserves all finite limits. -/ def preservesFiniteColimitsOfPreservesCokernels [HasFiniteCoproducts C] [HasCoequalizers C] [HasZeroObject C] [HasZeroObject D] [∀ {X Y} (f : X ⟶ Y), PreservesColimit (parallelPair f 0) F] : PreservesFiniteColimits F := by letI := preservesCoequalizersOfPreservesCokernels F letI := preservesInitialObjectOfPreservesZeroMorphisms F letI := preservesColimitsOfShapePemptyOfPreservesInitial F letI : PreservesFiniteCoproducts F := ⟨preservesFiniteCoproductsOfPreservesBinaryAndInitial F⟩ exact preservesFiniteColimitsOfPreservesCoequalizersAndFiniteCoproducts F end FiniteColimits end Functor end CategoryTheory
CategoryTheory\Preadditive\Mat.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.Algebra.BigOperators.Group.Finset import Mathlib.Algebra.BigOperators.Pi import Mathlib.CategoryTheory.Limits.Shapes.Biproducts import Mathlib.CategoryTheory.Preadditive.Basic import Mathlib.CategoryTheory.Preadditive.AdditiveFunctor import Mathlib.Data.Matrix.DMatrix import Mathlib.Data.Matrix.Basic import Mathlib.CategoryTheory.FintypeCat import Mathlib.CategoryTheory.Preadditive.SingleObj import Mathlib.Algebra.Opposites /-! # Matrices over a category. When `C` is a preadditive category, `Mat_ C` is the preadditive category whose objects are finite tuples of objects in `C`, and whose morphisms are matrices of morphisms from `C`. There is a functor `Mat_.embedding : C ⥤ Mat_ C` sending morphisms to one-by-one matrices. `Mat_ C` has finite biproducts. ## The additive envelope We show that this construction is the "additive envelope" of `C`, in the sense that any additive functor `F : C ⥤ D` to a category `D` with biproducts lifts to a functor `Mat_.lift F : Mat_ C ⥤ D`, Moreover, this functor is unique (up to natural isomorphisms) amongst functors `L : Mat_ C ⥤ D` such that `embedding C ⋙ L ≅ F`. (As we don't have 2-category theory, we can't explicitly state that `Mat_ C` is the initial object in the 2-category of categories under `C` which have biproducts.) As a consequence, when `C` already has finite biproducts we have `Mat_ C ≌ C`. ## Future work We should provide a more convenient `Mat R`, when `R` is a ring, as a category with objects `n : FinType`, and whose morphisms are matrices with components in `R`. Ideally this would conveniently interact with both `Mat_` and `Matrix`. -/ open CategoryTheory CategoryTheory.Preadditive open scoped Classical noncomputable section namespace CategoryTheory universe w v₁ v₂ u₁ u₂ variable (C : Type u₁) [Category.{v₁} C] [Preadditive C] /-- An object in `Mat_ C` is a finite tuple of objects in `C`. -/ structure Mat_ where ι : Type [fintype : Fintype ι] X : ι → C attribute [instance] Mat_.fintype namespace Mat_ variable {C} -- porting note (#5171): removed @[nolint has_nonempty_instance] /-- A morphism in `Mat_ C` is a dependently typed matrix of morphisms. -/ def Hom (M N : Mat_ C) : Type v₁ := DMatrix M.ι N.ι fun i j => M.X i ⟶ N.X j namespace Hom /-- The identity matrix consists of identity morphisms on the diagonal, and zeros elsewhere. -/ def id (M : Mat_ C) : Hom M M := fun i j => if h : i = j then eqToHom (congr_arg M.X h) else 0 /-- Composition of matrices using matrix multiplication. -/ def comp {M N K : Mat_ C} (f : Hom M N) (g : Hom N K) : Hom M K := fun i k => ∑ j : N.ι, f i j ≫ g j k end Hom section attribute [local simp] Hom.id Hom.comp instance : Category.{v₁} (Mat_ C) where Hom := Hom id := Hom.id comp f g := f.comp g id_comp f := by simp (config := { unfoldPartialApp := true }) [dite_comp] comp_id f := by simp (config := { unfoldPartialApp := true }) [comp_dite] assoc f g h := by apply DMatrix.ext intros simp_rw [Hom.comp, sum_comp, comp_sum, Category.assoc] rw [Finset.sum_comm] -- Porting note (#5229): added because `DMatrix.ext` is not triggered automatically @[ext] theorem hom_ext {M N : Mat_ C} (f g : M ⟶ N) (H : ∀ i j, f i j = g i j) : f = g := DMatrix.ext_iff.mp H theorem id_def (M : Mat_ C) : (𝟙 M : Hom M M) = fun i j => if h : i = j then eqToHom (congr_arg M.X h) else 0 := rfl theorem id_apply (M : Mat_ C) (i j : M.ι) : (𝟙 M : Hom M M) i j = if h : i = j then eqToHom (congr_arg M.X h) else 0 := rfl @[simp] theorem id_apply_self (M : Mat_ C) (i : M.ι) : (𝟙 M : Hom M M) i i = 𝟙 _ := by simp [id_apply] @[simp] theorem id_apply_of_ne (M : Mat_ C) (i j : M.ι) (h : i ≠ j) : (𝟙 M : Hom M M) i j = 0 := by simp [id_apply, h] theorem comp_def {M N K : Mat_ C} (f : M ⟶ N) (g : N ⟶ K) : f ≫ g = fun i k => ∑ j : N.ι, f i j ≫ g j k := rfl @[simp] theorem comp_apply {M N K : Mat_ C} (f : M ⟶ N) (g : N ⟶ K) (i k) : (f ≫ g) i k = ∑ j : N.ι, f i j ≫ g j k := rfl instance (M N : Mat_ C) : Inhabited (M ⟶ N) := ⟨fun i j => (0 : M.X i ⟶ N.X j)⟩ end -- Porting note: to ease the construction of the preadditive structure, the `AddCommGroup` -- was introduced separately and the lemma `add_apply` was moved upwards instance (M N : Mat_ C) : AddCommGroup (M ⟶ N) := by change AddCommGroup (DMatrix M.ι N.ι _) infer_instance @[simp] theorem add_apply {M N : Mat_ C} (f g : M ⟶ N) (i j) : (f + g) i j = f i j + g i j := rfl instance : Preadditive (Mat_ C) where add_comp M N K f f' g := by ext; simp [Finset.sum_add_distrib] comp_add M N K f g g' := by ext; simp [Finset.sum_add_distrib] open CategoryTheory.Limits /-- We now prove that `Mat_ C` has finite biproducts. Be warned, however, that `Mat_ C` is not necessarily Krull-Schmidt, and so the internal indexing of a biproduct may have nothing to do with the external indexing, even though the construction we give uses a sigma type. See however `isoBiproductEmbedding`. -/ instance hasFiniteBiproducts : HasFiniteBiproducts (Mat_ C) where out n := { has_biproduct := fun f => hasBiproduct_of_total { pt := ⟨Σ j, (f j).ι, fun p => (f p.1).X p.2⟩ π := fun j x y => by refine if h : x.1 = j then ?_ else 0 refine if h' : @Eq.ndrec (Fin n) x.1 (fun j => (f j).ι) x.2 _ h = y then ?_ else 0 apply eqToHom substs h h' rfl -- Notice we were careful not to use `subst` until we had a goal in `Prop`. ι := fun j x y => by refine if h : y.1 = j then ?_ else 0 refine if h' : @Eq.ndrec _ y.1 (fun j => (f j).ι) y.2 _ h = x then ?_ else 0 apply eqToHom substs h h' rfl ι_π := fun j j' => by ext x y dsimp simp_rw [dite_comp, comp_dite] simp only [ite_self, dite_eq_ite, dif_ctx_congr, Limits.comp_zero, Limits.zero_comp, eqToHom_trans, Finset.sum_congr] erw [Finset.sum_sigma] dsimp simp only [if_congr, if_true, dif_ctx_congr, Finset.sum_dite_irrel, Finset.mem_univ, Finset.sum_const_zero, Finset.sum_congr, Finset.sum_dite_eq'] split_ifs with h h' · substs h h' simp only [CategoryTheory.eqToHom_refl, CategoryTheory.Mat_.id_apply_self] · subst h rw [eqToHom_refl, id_apply_of_ne _ _ _ h'] · rfl } (by dsimp ext1 ⟨i, j⟩ rintro ⟨i', j'⟩ rw [Finset.sum_apply, Finset.sum_apply] dsimp rw [Finset.sum_eq_single i]; rotate_left · intro b _ hb apply Finset.sum_eq_zero intro x _ rw [dif_neg hb.symm, zero_comp] · intro hi simp at hi rw [Finset.sum_eq_single j]; rotate_left · intro b _ hb rw [dif_pos rfl, dif_neg, zero_comp] simp only tauto · intro hj simp at hj simp only [eqToHom_refl, dite_eq_ite, ite_true, Category.id_comp, ne_eq, Sigma.mk.inj_iff, not_and, id_def] by_cases h : i' = i · subst h rw [dif_pos rfl] simp only [heq_eq_eq, true_and] by_cases h : j' = j · subst h simp · rw [dif_neg h, dif_neg (Ne.symm h)] · rw [dif_neg h, dif_neg] tauto) } end Mat_ namespace Functor variable {C} {D : Type*} [Category.{v₁} D] [Preadditive D] attribute [local simp] Mat_.id_apply eqToHom_map /-- A functor induces a functor of matrix categories. -/ @[simps] def mapMat_ (F : C ⥤ D) [Functor.Additive F] : Mat_ C ⥤ Mat_ D where obj M := ⟨M.ι, fun i => F.obj (M.X i)⟩ map f i j := F.map (f i j) /-- The identity functor induces the identity functor on matrix categories. -/ @[simps!] def mapMatId : (𝟭 C).mapMat_ ≅ 𝟭 (Mat_ C) := NatIso.ofComponents (fun M => eqToIso (by cases M; rfl)) fun {M N} f => by ext cases M; cases N simp [comp_dite, dite_comp] /-- Composite functors induce composite functors on matrix categories. -/ @[simps!] def mapMatComp {E : Type*} [Category.{v₁} E] [Preadditive E] (F : C ⥤ D) [Functor.Additive F] (G : D ⥤ E) [Functor.Additive G] : (F ⋙ G).mapMat_ ≅ F.mapMat_ ⋙ G.mapMat_ := NatIso.ofComponents (fun M => eqToIso (by cases M; rfl)) fun {M N} f => by ext cases M; cases N simp [comp_dite, dite_comp] end Functor namespace Mat_ /-- The embedding of `C` into `Mat_ C` as one-by-one matrices. (We index the summands by `PUnit`.) -/ @[simps] def embedding : C ⥤ Mat_ C where obj X := ⟨PUnit, fun _ => X⟩ map f _ _ := f map_id _ := by ext ⟨⟩; simp map_comp _ _ := by ext ⟨⟩; simp namespace Embedding instance : (embedding C).Faithful where map_injective h := congr_fun (congr_fun h PUnit.unit) PUnit.unit instance : (embedding C).Full where map_surjective f := ⟨f PUnit.unit PUnit.unit, rfl⟩ instance : Functor.Additive (embedding C) where end Embedding instance [Inhabited C] : Inhabited (Mat_ C) := ⟨(embedding C).obj default⟩ open CategoryTheory.Limits variable {C} /-- Every object in `Mat_ C` is isomorphic to the biproduct of its summands. -/ @[simps] def isoBiproductEmbedding (M : Mat_ C) : M ≅ ⨁ fun i => (embedding C).obj (M.X i) where hom := biproduct.lift fun i j k => if h : j = i then eqToHom (congr_arg M.X h) else 0 inv := biproduct.desc fun i j k => if h : i = k then eqToHom (congr_arg M.X h) else 0 hom_inv_id := by simp only [biproduct.lift_desc] funext i j dsimp [id_def] rw [Finset.sum_apply, Finset.sum_apply, Finset.sum_eq_single i]; rotate_left · intro b _ hb dsimp rw [Fintype.univ_ofSubsingleton, Finset.sum_singleton, dif_neg hb.symm, zero_comp] · intro h simp at h simp inv_hom_id := by apply biproduct.hom_ext intro i apply biproduct.hom_ext' intro j simp only [Category.id_comp, Category.assoc, biproduct.lift_π, biproduct.ι_desc_assoc, biproduct.ι_π] ext ⟨⟩ ⟨⟩ simp only [embedding, comp_apply, comp_dite, dite_comp, comp_zero, zero_comp, Finset.sum_dite_eq', Finset.mem_univ, ite_true, eqToHom_refl, Category.comp_id] split_ifs with h · subst h simp · rfl variable {D : Type u₁} [Category.{v₁} D] [Preadditive D] -- Porting note: added because it was not found automatically instance (F : Mat_ C ⥤ D) [Functor.Additive F] (M : Mat_ C) : HasBiproduct (fun i => F.obj ((embedding C).obj (M.X i))) := F.hasBiproduct_of_preserves _ -- Porting note: removed the @[simps] attribute as the automatically generated lemmas -- are not very useful; two more useful lemmas have been added just after this -- definition in order to ease the proof of `additiveObjIsoBiproduct_naturality` /-- Every `M` is a direct sum of objects from `C`, and `F` preserves biproducts. -/ def additiveObjIsoBiproduct (F : Mat_ C ⥤ D) [Functor.Additive F] (M : Mat_ C) : F.obj M ≅ ⨁ fun i => F.obj ((embedding C).obj (M.X i)) := F.mapIso (isoBiproductEmbedding M) ≪≫ F.mapBiproduct _ @[reassoc (attr := simp)] lemma additiveObjIsoBiproduct_hom_π (F : Mat_ C ⥤ D) [Functor.Additive F] (M : Mat_ C) (i : M.ι) : (additiveObjIsoBiproduct F M).hom ≫ biproduct.π _ i = F.map (M.isoBiproductEmbedding.hom ≫ biproduct.π _ i) := by dsimp [additiveObjIsoBiproduct] rw [biproduct.lift_π, Category.assoc] erw [biproduct.lift_π, ← F.map_comp] simp @[reassoc (attr := simp)] lemma ι_additiveObjIsoBiproduct_inv (F : Mat_ C ⥤ D) [Functor.Additive F] (M : Mat_ C) (i : M.ι) : biproduct.ι _ i ≫ (additiveObjIsoBiproduct F M).inv = F.map (biproduct.ι _ i ≫ M.isoBiproductEmbedding.inv) := by dsimp [additiveObjIsoBiproduct, Functor.mapBiproduct, Functor.mapBicone] simp only [biproduct.ι_desc, biproduct.ι_desc_assoc, ← F.map_comp] variable [HasFiniteBiproducts D] @[reassoc] theorem additiveObjIsoBiproduct_naturality (F : Mat_ C ⥤ D) [Functor.Additive F] {M N : Mat_ C} (f : M ⟶ N) : F.map f ≫ (additiveObjIsoBiproduct F N).hom = (additiveObjIsoBiproduct F M).hom ≫ biproduct.matrix fun i j => F.map ((embedding C).map (f i j)) := by ext i : 1 simp only [Category.assoc, additiveObjIsoBiproduct_hom_π, isoBiproductEmbedding_hom, embedding_obj_ι, embedding_obj_X, biproduct.lift_π, biproduct.matrix_π, ← cancel_epi (additiveObjIsoBiproduct F M).inv, Iso.inv_hom_id_assoc] ext j : 1 simp only [ι_additiveObjIsoBiproduct_inv_assoc, isoBiproductEmbedding_inv, biproduct.ι_desc, ← F.map_comp] congr 1 funext ⟨⟩ ⟨⟩ simp [comp_apply, dite_comp, comp_dite] @[reassoc] theorem additiveObjIsoBiproduct_naturality' (F : Mat_ C ⥤ D) [Functor.Additive F] {M N : Mat_ C} (f : M ⟶ N) : (additiveObjIsoBiproduct F M).inv ≫ F.map f = biproduct.matrix (fun i j => F.map ((embedding C).map (f i j)) : _) ≫ (additiveObjIsoBiproduct F N).inv := by rw [Iso.inv_comp_eq, ← Category.assoc, Iso.eq_comp_inv, additiveObjIsoBiproduct_naturality] attribute [local simp] biproduct.lift_desc /-- Any additive functor `C ⥤ D` to a category `D` with finite biproducts extends to a functor `Mat_ C ⥤ D`. -/ @[simps] def lift (F : C ⥤ D) [Functor.Additive F] : Mat_ C ⥤ D where obj X := ⨁ fun i => F.obj (X.X i) map f := biproduct.matrix fun i j => F.map (f i j) map_id X := by dsimp ext i j by_cases h : j = i · subst h; simp · simp [h] instance lift_additive (F : C ⥤ D) [Functor.Additive F] : Functor.Additive (lift F) where /-- An additive functor `C ⥤ D` factors through its lift to `Mat_ C ⥤ D`. -/ @[simps!] def embeddingLiftIso (F : C ⥤ D) [Functor.Additive F] : embedding C ⋙ lift F ≅ F := NatIso.ofComponents (fun X => { hom := biproduct.desc fun _ => 𝟙 (F.obj X) inv := biproduct.lift fun _ => 𝟙 (F.obj X) }) /-- `Mat_.lift F` is the unique additive functor `L : Mat_ C ⥤ D` such that `F ≅ embedding C ⋙ L`. -/ def liftUnique (F : C ⥤ D) [Functor.Additive F] (L : Mat_ C ⥤ D) [Functor.Additive L] (α : embedding C ⋙ L ≅ F) : L ≅ lift F := NatIso.ofComponents (fun M => additiveObjIsoBiproduct L M ≪≫ (biproduct.mapIso fun i => α.app (M.X i)) ≪≫ (biproduct.mapIso fun i => (embeddingLiftIso F).symm.app (M.X i)) ≪≫ (additiveObjIsoBiproduct (lift F) M).symm) fun f => by dsimp only [Iso.trans_hom, Iso.symm_hom, biproduct.mapIso_hom] simp only [additiveObjIsoBiproduct_naturality_assoc] simp only [biproduct.matrix_map_assoc, Category.assoc] simp only [additiveObjIsoBiproduct_naturality'] simp only [biproduct.map_matrix_assoc, Category.assoc] congr 3 ext j k apply biproduct.hom_ext rintro ⟨⟩ dsimp simpa using α.hom.naturality (f j k) -- Porting note (#11182): removed @[ext] as the statement is not an equality -- TODO is there some uniqueness statement for the natural isomorphism in `liftUnique`? /-- Two additive functors `Mat_ C ⥤ D` are naturally isomorphic if their precompositions with `embedding C` are naturally isomorphic as functors `C ⥤ D`. -/ def ext {F G : Mat_ C ⥤ D} [Functor.Additive F] [Functor.Additive G] (α : embedding C ⋙ F ≅ embedding C ⋙ G) : F ≅ G := liftUnique (embedding C ⋙ G) _ α ≪≫ (liftUnique _ _ (Iso.refl _)).symm /-- Natural isomorphism needed in the construction of `equivalenceSelfOfHasFiniteBiproducts`. -/ def equivalenceSelfOfHasFiniteBiproductsAux [HasFiniteBiproducts C] : embedding C ⋙ 𝟭 (Mat_ C) ≅ embedding C ⋙ lift (𝟭 C) ⋙ embedding C := Functor.rightUnitor _ ≪≫ (Functor.leftUnitor _).symm ≪≫ isoWhiskerRight (embeddingLiftIso _).symm _ ≪≫ Functor.associator _ _ _ /-- A preadditive category that already has finite biproducts is equivalent to its additive envelope. Note that we only prove this for a large category; otherwise there are universe issues that I haven't attempted to sort out. -/ def equivalenceSelfOfHasFiniteBiproducts (C : Type (u₁ + 1)) [LargeCategory C] [Preadditive C] [HasFiniteBiproducts C] : Mat_ C ≌ C := Equivalence.mk (-- I suspect this is already an adjoint equivalence, but it seems painful to verify. lift (𝟭 C)) (embedding C) (ext equivalenceSelfOfHasFiniteBiproductsAux) (embeddingLiftIso (𝟭 C)) @[simp] theorem equivalenceSelfOfHasFiniteBiproducts_functor {C : Type (u₁ + 1)} [LargeCategory C] [Preadditive C] [HasFiniteBiproducts C] : (equivalenceSelfOfHasFiniteBiproducts C).functor = lift (𝟭 C) := rfl @[simp] theorem equivalenceSelfOfHasFiniteBiproducts_inverse {C : Type (u₁ + 1)} [LargeCategory C] [Preadditive C] [HasFiniteBiproducts C] : (equivalenceSelfOfHasFiniteBiproducts C).inverse = embedding C := rfl end Mat_ universe u /-- A type synonym for `Fintype`, which we will equip with a category structure where the morphisms are matrices with components in `R`. -/ @[nolint unusedArguments] def Mat (_ : Type u) := FintypeCat.{u} instance (R : Type u) : Inhabited (Mat R) := by dsimp [Mat] infer_instance instance (R : Type u) : CoeSort (Mat R) (Type u) := Bundled.coeSort open Matrix instance (R : Type u) [Semiring R] : Category (Mat R) where Hom X Y := Matrix X Y R id X := (1 : Matrix X X R) comp {X Y Z} f g := (show Matrix X Y R from f) * (show Matrix Y Z R from g) assoc := by intros; simp [Matrix.mul_assoc] namespace Mat section variable {R : Type u} [Semiring R] -- Porting note (#5229): added because `Matrix.ext` is not triggered automatically @[ext] theorem hom_ext {X Y : Mat R} (f g : X ⟶ Y) (h : ∀ i j, f i j = g i j) : f = g := Matrix.ext_iff.mp h variable (R) theorem id_def (M : Mat R) : 𝟙 M = fun i j => if i = j then 1 else 0 := rfl theorem id_apply (M : Mat R) (i j : M) : (𝟙 M : Matrix M M R) i j = if i = j then 1 else 0 := rfl @[simp] theorem id_apply_self (M : Mat R) (i : M) : (𝟙 M : Matrix M M R) i i = 1 := by simp [id_apply] @[simp] theorem id_apply_of_ne (M : Mat R) (i j : M) (h : i ≠ j) : (𝟙 M : Matrix M M R) i j = 0 := by simp [id_apply, h] theorem comp_def {M N K : Mat R} (f : M ⟶ N) (g : N ⟶ K) : f ≫ g = fun i k => ∑ j : N, f i j * g j k := rfl @[simp] theorem comp_apply {M N K : Mat R} (f : M ⟶ N) (g : N ⟶ K) (i k) : (f ≫ g) i k = ∑ j : N, f i j * g j k := rfl instance (M N : Mat R) : Inhabited (M ⟶ N) := ⟨fun (_ : M) (_ : N) => (0 : R)⟩ end variable (R : Type) [Ring R] open Opposite /-- Auxiliary definition for `CategoryTheory.Mat.equivalenceSingleObj`. -/ @[simps] def equivalenceSingleObjInverse : Mat_ (SingleObj Rᵐᵒᵖ) ⥤ Mat R where obj X := FintypeCat.of X.ι map f i j := MulOpposite.unop (f i j) map_id X := by ext simp only [Mat_.id_def, id_def] split_ifs <;> rfl map_comp f g := by -- Porting note: this proof was automatic in mathlib3 ext simp only [Mat_.comp_apply, comp_apply] apply Finset.unop_sum instance : (equivalenceSingleObjInverse R).Faithful where map_injective w := by ext apply_fun MulOpposite.unop using MulOpposite.unop_injective exact congr_fun (congr_fun w _) _ instance : (equivalenceSingleObjInverse R).Full where map_surjective f := ⟨fun i j => MulOpposite.op (f i j), rfl⟩ instance : (equivalenceSingleObjInverse R).EssSurj where mem_essImage X := ⟨{ ι := X X := fun _ => PUnit.unit }, ⟨eqToIso (by dsimp; cases X; congr)⟩⟩ instance : (equivalenceSingleObjInverse R).IsEquivalence where /-- The categorical equivalence between the category of matrices over a ring, and the category of matrices over that ring considered as a single-object category. -/ def equivalenceSingleObj : Mat R ≌ Mat_ (SingleObj Rᵐᵒᵖ) := (equivalenceSingleObjInverse R).asEquivalence.symm -- Porting note: added as this was not found automatically instance (X Y : Mat R) : AddCommGroup (X ⟶ Y) := by change AddCommGroup (Matrix X Y R) infer_instance variable {R} -- Porting note (#10688): added to ease automation @[simp] theorem add_apply {M N : Mat R} (f g : M ⟶ N) (i j) : (f + g) i j = f i j + g i j := rfl attribute [local simp] add_mul mul_add Finset.sum_add_distrib instance : Preadditive (Mat R) where -- TODO show `Mat R` has biproducts, and that `biprod.map` "is" forming a block diagonal matrix. end Mat end CategoryTheory
CategoryTheory\Preadditive\OfBiproducts.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.Limits.Shapes.Biproducts import Mathlib.GroupTheory.EckmannHilton import Mathlib.Tactic.CategoryTheory.Reassoc /-! # Constructing a semiadditive structure from binary biproducts We show that any category with zero morphisms and binary biproducts is enriched over the category of commutative monoids. -/ noncomputable section universe v u open CategoryTheory open CategoryTheory.Limits namespace CategoryTheory.SemiadditiveOfBinaryBiproducts variable {C : Type u} [Category.{v} C] [HasZeroMorphisms C] [HasBinaryBiproducts C] section variable (X Y : C) /-- `f +ₗ g` is the composite `X ⟶ Y ⊞ Y ⟶ Y`, where the first map is `(f, g)` and the second map is `(𝟙 𝟙)`. -/ @[simp] def leftAdd (f g : X ⟶ Y) : X ⟶ Y := biprod.lift f g ≫ biprod.desc (𝟙 Y) (𝟙 Y) /-- `f +ᵣ g` is the composite `X ⟶ X ⊞ X ⟶ Y`, where the first map is `(𝟙, 𝟙)` and the second map is `(f g)`. -/ @[simp] def rightAdd (f g : X ⟶ Y) : X ⟶ Y := biprod.lift (𝟙 X) (𝟙 X) ≫ biprod.desc f g local infixr:65 " +ₗ " => leftAdd X Y local infixr:65 " +ᵣ " => rightAdd X Y theorem isUnital_leftAdd : EckmannHilton.IsUnital (· +ₗ ·) 0 := by have hr : ∀ f : X ⟶ Y, biprod.lift (0 : X ⟶ Y) f = f ≫ biprod.inr := by intro f ext · aesop_cat · simp [biprod.lift_fst, Category.assoc, biprod.inr_fst, comp_zero] have hl : ∀ f : X ⟶ Y, biprod.lift f (0 : X ⟶ Y) = f ≫ biprod.inl := by intro f ext · aesop_cat · simp [biprod.lift_snd, Category.assoc, biprod.inl_snd, comp_zero] exact { left_id := fun f => by simp [hr f, leftAdd, Category.assoc, Category.comp_id, biprod.inr_desc], right_id := fun f => by simp [hl f, leftAdd, Category.assoc, Category.comp_id, biprod.inl_desc] } theorem isUnital_rightAdd : EckmannHilton.IsUnital (· +ᵣ ·) 0 := by have h₂ : ∀ f : X ⟶ Y, biprod.desc (0 : X ⟶ Y) f = biprod.snd ≫ f := by intro f ext · aesop_cat · simp only [biprod.inr_desc, BinaryBicone.inr_snd_assoc] have h₁ : ∀ f : X ⟶ Y, biprod.desc f (0 : X ⟶ Y) = biprod.fst ≫ f := by intro f ext · aesop_cat · simp only [biprod.inr_desc, BinaryBicone.inr_fst_assoc, zero_comp] exact { left_id := fun f => by simp [h₂ f, rightAdd, biprod.lift_snd_assoc, Category.id_comp], right_id := fun f => by simp [h₁ f, rightAdd, biprod.lift_fst_assoc, Category.id_comp] } theorem distrib (f g h k : X ⟶ Y) : (f +ᵣ g) +ₗ h +ᵣ k = (f +ₗ h) +ᵣ g +ₗ k := by let diag : X ⊞ X ⟶ Y ⊞ Y := biprod.lift (biprod.desc f g) (biprod.desc h k) have hd₁ : biprod.inl ≫ diag = biprod.lift f h := by ext <;> simp [diag] have hd₂ : biprod.inr ≫ diag = biprod.lift g k := by ext <;> simp [diag] have h₁ : biprod.lift (f +ᵣ g) (h +ᵣ k) = biprod.lift (𝟙 X) (𝟙 X) ≫ diag := by ext <;> aesop_cat have h₂ : diag ≫ biprod.desc (𝟙 Y) (𝟙 Y) = biprod.desc (f +ₗ h) (g +ₗ k) := by ext <;> simp [reassoc_of% hd₁, reassoc_of% hd₂] rw [leftAdd, h₁, Category.assoc, h₂, rightAdd] /-- In a category with binary biproducts, the morphisms form a commutative monoid. -/ def addCommMonoidHomOfHasBinaryBiproducts : AddCommMonoid (X ⟶ Y) where add := (· +ᵣ ·) add_assoc := (EckmannHilton.mul_assoc (isUnital_leftAdd X Y) (isUnital_rightAdd X Y) (distrib X Y)).assoc zero := 0 zero_add := (isUnital_rightAdd X Y).left_id add_zero := (isUnital_rightAdd X Y).right_id add_comm := (EckmannHilton.mul_comm (isUnital_leftAdd X Y) (isUnital_rightAdd X Y) (distrib X Y)).comm nsmul := letI : Add (X ⟶ Y) := ⟨(· +ᵣ ·)⟩; nsmulRec end section variable {X Y Z : C} attribute [local instance] addCommMonoidHomOfHasBinaryBiproducts theorem add_eq_right_addition (f g : X ⟶ Y) : f + g = biprod.lift (𝟙 X) (𝟙 X) ≫ biprod.desc f g := rfl theorem add_eq_left_addition (f g : X ⟶ Y) : f + g = biprod.lift f g ≫ biprod.desc (𝟙 Y) (𝟙 Y) := congr_fun₂ (EckmannHilton.mul (isUnital_leftAdd X Y) (isUnital_rightAdd X Y) (distrib X Y)).symm f g theorem add_comp (f g : X ⟶ Y) (h : Y ⟶ Z) : (f + g) ≫ h = f ≫ h + g ≫ h := by simp only [add_eq_right_addition, Category.assoc] congr ext <;> simp theorem comp_add (f : X ⟶ Y) (g h : Y ⟶ Z) : f ≫ (g + h) = f ≫ g + f ≫ h := by simp only [add_eq_left_addition, ← Category.assoc] congr ext <;> simp end end CategoryTheory.SemiadditiveOfBinaryBiproducts
CategoryTheory\Preadditive\Opposite.lean
/- Copyright (c) 2021 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison, Adam Topaz, Johan Commelin, Joël Riou -/ import Mathlib.CategoryTheory.Preadditive.AdditiveFunctor import Mathlib.Logic.Equiv.TransferInstance /-! # If `C` is preadditive, `Cᵒᵖ` has a natural preadditive structure. -/ open Opposite namespace CategoryTheory variable (C : Type*) [Category C] [Preadditive C] instance : Preadditive Cᵒᵖ where homGroup X Y := Equiv.addCommGroup (opEquiv X Y) add_comp _ _ _ f f' g := Quiver.Hom.unop_inj (Preadditive.comp_add _ _ _ g.unop f.unop f'.unop) comp_add _ _ _ f g g' := Quiver.Hom.unop_inj (Preadditive.add_comp _ _ _ g.unop g'.unop f.unop) instance moduleEndLeft {X : Cᵒᵖ} {Y : C} : Module (End X) (unop X ⟶ Y) where smul_add _ _ _ := Preadditive.comp_add _ _ _ _ _ _ smul_zero _ := Limits.comp_zero add_smul _ _ _ := Preadditive.add_comp _ _ _ _ _ _ zero_smul _ := Limits.zero_comp @[simp] theorem unop_add {X Y : Cᵒᵖ} (f g : X ⟶ Y) : (f + g).unop = f.unop + g.unop := rfl @[simp] theorem unop_zsmul {X Y : Cᵒᵖ} (k : ℤ) (f : X ⟶ Y) : (k • f).unop = k • f.unop := rfl @[simp] theorem unop_neg {X Y : Cᵒᵖ} (f : X ⟶ Y) : (-f).unop = -f.unop := rfl @[simp] theorem op_add {X Y : C} (f g : X ⟶ Y) : (f + g).op = f.op + g.op := rfl @[simp] theorem op_zsmul {X Y : C} (k : ℤ) (f : X ⟶ Y) : (k • f).op = k • f.op := rfl @[simp] theorem op_neg {X Y : C} (f : X ⟶ Y) : (-f).op = -f.op := rfl variable {C} /-- `unop` induces morphisms of monoids on hom groups of a preadditive category -/ @[simps!] def unopHom (X Y : Cᵒᵖ) : (X ⟶ Y) →+ (Opposite.unop Y ⟶ Opposite.unop X) := AddMonoidHom.mk' (fun f => f.unop) fun f g => unop_add _ f g @[simp] theorem unop_sum (X Y : Cᵒᵖ) {ι : Type*} (s : Finset ι) (f : ι → (X ⟶ Y)) : (s.sum f).unop = s.sum fun i => (f i).unop := map_sum (unopHom X Y) _ _ /-- `op` induces morphisms of monoids on hom groups of a preadditive category -/ @[simps!] def opHom (X Y : C) : (X ⟶ Y) →+ (Opposite.op Y ⟶ Opposite.op X) := AddMonoidHom.mk' (fun f => f.op) fun f g => op_add _ f g @[simp] theorem op_sum (X Y : C) {ι : Type*} (s : Finset ι) (f : ι → (X ⟶ Y)) : (s.sum f).op = s.sum fun i => (f i).op := map_sum (opHom X Y) _ _ variable {D : Type*} [Category D] [Preadditive D] instance Functor.op_additive (F : C ⥤ D) [F.Additive] : F.op.Additive where instance Functor.rightOp_additive (F : Cᵒᵖ ⥤ D) [F.Additive] : F.rightOp.Additive where instance Functor.leftOp_additive (F : C ⥤ Dᵒᵖ) [F.Additive] : F.leftOp.Additive where instance Functor.unop_additive (F : Cᵒᵖ ⥤ Dᵒᵖ) [F.Additive] : F.unop.Additive where end CategoryTheory
CategoryTheory\Preadditive\Projective.lean
/- Copyright (c) 2020 Markus Himmel. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Markus Himmel, Scott Morrison -/ import Mathlib.CategoryTheory.Adjunction.FullyFaithful import Mathlib.CategoryTheory.Adjunction.Limits import Mathlib.CategoryTheory.Limits.Constructions.EpiMono import Mathlib.CategoryTheory.Limits.Shapes.Biproducts import Mathlib.CategoryTheory.Limits.Preserves.Finite import Mathlib.CategoryTheory.Limits.Constructions.EpiMono /-! # Projective objects and categories with enough projectives An object `P` is called *projective* if every morphism out of `P` factors through every epimorphism. A category `C` *has enough projectives* if every object admits an epimorphism from some projective object. `CategoryTheory.Projective.over X` picks an arbitrary such projective object, and `CategoryTheory.Projective.π X : CategoryTheory.Projective.over X ⟶ X` is the corresponding epimorphism. Given a morphism `f : X ⟶ Y`, `CategoryTheory.Projective.left f` is a projective object over `CategoryTheory.Limits.kernel f`, and `Projective.d f : Projective.left f ⟶ X` is the morphism `π (kernel f) ≫ kernel.ι f`. -/ noncomputable section open CategoryTheory Limits Opposite universe v u v' u' namespace CategoryTheory variable {C : Type u} [Category.{v} C] /-- An object `P` is called *projective* if every morphism out of `P` factors through every epimorphism. -/ class Projective (P : C) : Prop where factors : ∀ {E X : C} (f : P ⟶ X) (e : E ⟶ X) [Epi e], ∃ f', f' ≫ e = f lemma Limits.IsZero.projective {X : C} (h : IsZero X) : Projective X where factors _ _ _ := ⟨h.to_ _, h.eq_of_src _ _⟩ section /-- A projective presentation of an object `X` consists of an epimorphism `f : P ⟶ X` from some projective object `P`. -/ -- Porting note(#5171): was @[nolint has_nonempty_instance] structure ProjectivePresentation (X : C) where p : C [projective : Projective p] f : p ⟶ X [epi : Epi f] attribute [instance] ProjectivePresentation.projective ProjectivePresentation.epi variable (C) /-- A category "has enough projectives" if for every object `X` there is a projective object `P` and an epimorphism `P ↠ X`. -/ class EnoughProjectives : Prop where presentation : ∀ X : C, Nonempty (ProjectivePresentation X) end namespace Projective /-- An arbitrarily chosen factorisation of a morphism out of a projective object through an epimorphism. -/ def factorThru {P X E : C} [Projective P] (f : P ⟶ X) (e : E ⟶ X) [Epi e] : P ⟶ E := (Projective.factors f e).choose @[reassoc (attr := simp)] theorem factorThru_comp {P X E : C} [Projective P] (f : P ⟶ X) (e : E ⟶ X) [Epi e] : factorThru f e ≫ e = f := (Projective.factors f e).choose_spec section open ZeroObject instance zero_projective [HasZeroObject C] : Projective (0 : C) := (isZero_zero C).projective end theorem of_iso {P Q : C} (i : P ≅ Q) (hP : Projective P) : Projective Q where factors f e e_epi := let ⟨f', hf'⟩ := Projective.factors (i.hom ≫ f) e ⟨i.inv ≫ f', by simp [hf']⟩ theorem iso_iff {P Q : C} (i : P ≅ Q) : Projective P ↔ Projective Q := ⟨of_iso i, of_iso i.symm⟩ /-- The axiom of choice says that every type is a projective object in `Type`. -/ instance (X : Type u) : Projective X where factors f e _ := have he : Function.Surjective e := surjective_of_epi e ⟨fun x => (he (f x)).choose, funext fun x ↦ (he (f x)).choose_spec⟩ instance Type.enoughProjectives : EnoughProjectives (Type u) where presentation X := ⟨⟨X, 𝟙 X⟩⟩ instance {P Q : C} [HasBinaryCoproduct P Q] [Projective P] [Projective Q] : Projective (P ⨿ Q) where factors f e epi := ⟨coprod.desc (factorThru (coprod.inl ≫ f) e) (factorThru (coprod.inr ≫ f) e), by aesop_cat⟩ instance {β : Type v} (g : β → C) [HasCoproduct g] [∀ b, Projective (g b)] : Projective (∐ g) where factors f e epi := ⟨Sigma.desc fun b => factorThru (Sigma.ι g b ≫ f) e, by aesop_cat⟩ instance {P Q : C} [HasZeroMorphisms C] [HasBinaryBiproduct P Q] [Projective P] [Projective Q] : Projective (P ⊞ Q) where factors f e epi := ⟨biprod.desc (factorThru (biprod.inl ≫ f) e) (factorThru (biprod.inr ≫ f) e), by aesop_cat⟩ instance {β : Type v} (g : β → C) [HasZeroMorphisms C] [HasBiproduct g] [∀ b, Projective (g b)] : Projective (⨁ g) where factors f e epi := ⟨biproduct.desc fun b => factorThru (biproduct.ι g b ≫ f) e, by aesop_cat⟩ theorem projective_iff_preservesEpimorphisms_coyoneda_obj (P : C) : Projective P ↔ (coyoneda.obj (op P)).PreservesEpimorphisms := ⟨fun hP => ⟨fun f _ => (epi_iff_surjective _).2 fun g => have : Projective (unop (op P)) := hP ⟨factorThru g f, factorThru_comp _ _⟩⟩, fun _ => ⟨fun f e _ => (epi_iff_surjective _).1 (inferInstance : Epi ((coyoneda.obj (op P)).map e)) f⟩⟩ section EnoughProjectives variable [EnoughProjectives C] /-- `Projective.over X` provides an arbitrarily chosen projective object equipped with an epimorphism `Projective.π : Projective.over X ⟶ X`. -/ def over (X : C) : C := (EnoughProjectives.presentation X).some.p instance projective_over (X : C) : Projective (over X) := (EnoughProjectives.presentation X).some.projective /-- The epimorphism `projective.π : projective.over X ⟶ X` from the arbitrarily chosen projective object over `X`. -/ def π (X : C) : over X ⟶ X := (EnoughProjectives.presentation X).some.f instance π_epi (X : C) : Epi (π X) := (EnoughProjectives.presentation X).some.epi section variable [HasZeroMorphisms C] {X Y : C} (f : X ⟶ Y) [HasKernel f] /-- When `C` has enough projectives, the object `Projective.syzygies f` is an arbitrarily chosen projective object over `kernel f`. -/ def syzygies : C := over (kernel f) instance : Projective (syzygies f) := inferInstanceAs (Projective (over _)) /-- When `C` has enough projectives, `Projective.d f : Projective.syzygies f ⟶ X` is the composition `π (kernel f) ≫ kernel.ι f`. (When `C` is abelian, we have `exact (projective.d f) f`.) -/ abbrev d : syzygies f ⟶ X := π (kernel f) ≫ kernel.ι f end end EnoughProjectives end Projective namespace Adjunction variable {D : Type u'} [Category.{v'} D] {F : C ⥤ D} {G : D ⥤ C} theorem map_projective (adj : F ⊣ G) [G.PreservesEpimorphisms] (P : C) (hP : Projective P) : Projective (F.obj P) where factors f g _ := by rcases hP.factors (adj.unit.app P ≫ G.map f) (G.map g) with ⟨f', hf'⟩ use F.map f' ≫ adj.counit.app _ rw [Category.assoc, ← Adjunction.counit_naturality, ← Category.assoc, ← F.map_comp, hf'] simp theorem projective_of_map_projective (adj : F ⊣ G) [F.Full] [F.Faithful] (P : C) (hP : Projective (F.obj P)) : Projective P where factors f g _ := by haveI := Adjunction.leftAdjointPreservesColimits.{0, 0} adj rcases (@hP).1 (F.map f) (F.map g) with ⟨f', hf'⟩ use adj.unit.app _ ≫ G.map f' ≫ (inv <| adj.unit.app _) exact F.map_injective (by simpa) /-- Given an adjunction `F ⊣ G` such that `G` preserves epis, `F` maps a projective presentation of `X` to a projective presentation of `F(X)`. -/ def mapProjectivePresentation (adj : F ⊣ G) [G.PreservesEpimorphisms] (X : C) (Y : ProjectivePresentation X) : ProjectivePresentation (F.obj X) where p := F.obj Y.p projective := adj.map_projective _ Y.projective f := F.map Y.f epi := have := Adjunction.leftAdjointPreservesColimits.{0, 0} adj; inferInstance end Adjunction namespace Equivalence variable {D : Type u'} [Category.{v'} D] (F : C ≌ D) theorem map_projective_iff (P : C) : Projective (F.functor.obj P) ↔ Projective P := ⟨F.toAdjunction.projective_of_map_projective P, F.toAdjunction.map_projective P⟩ /-- Given an equivalence of categories `F`, a projective presentation of `F(X)` induces a projective presentation of `X.` -/ def projectivePresentationOfMapProjectivePresentation (X : C) (Y : ProjectivePresentation (F.functor.obj X)) : ProjectivePresentation X where p := F.inverse.obj Y.p projective := Adjunction.map_projective F.symm.toAdjunction Y.p Y.projective f := F.inverse.map Y.f ≫ F.unitInv.app _ epi := epi_comp _ _ theorem enoughProjectives_iff (F : C ≌ D) : EnoughProjectives C ↔ EnoughProjectives D := by constructor all_goals intro H; constructor; intro X; constructor · exact F.symm.projectivePresentationOfMapProjectivePresentation _ (Nonempty.some (H.presentation (F.inverse.obj X))) · exact F.projectivePresentationOfMapProjectivePresentation X (Nonempty.some (H.presentation (F.functor.obj X))) end Equivalence end CategoryTheory
CategoryTheory\Preadditive\ProjectiveResolution.lean
/- Copyright (c) 2021 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison, Joël Riou -/ import Mathlib.Algebra.Homology.QuasiIso import Mathlib.Algebra.Homology.SingleHomology /-! # Projective resolutions A projective resolution `P : ProjectiveResolution Z` of an object `Z : C` consists of an `ℕ`-indexed chain complex `P.complex` of projective objects, along with a quasi-isomorphism `P.π` from `C` to the chain complex consisting just of `Z` in degree zero. -/ universe v u namespace CategoryTheory open Category Limits ChainComplex HomologicalComplex variable {C : Type u} [Category.{v} C] open Projective variable [HasZeroObject C] [HasZeroMorphisms C] -- porting note (#5171): removed @[nolint has_nonempty_instance] /-- A `ProjectiveResolution Z` consists of a bundled `ℕ`-indexed chain complex of projective objects, along with a quasi-isomorphism to the complex consisting of just `Z` supported in degree `0`. -/ structure ProjectiveResolution (Z : C) where /-- the chain complex involved in the resolution -/ complex : ChainComplex C ℕ /-- the chain complex must be degreewise projective -/ projective : ∀ n, Projective (complex.X n) := by infer_instance /-- the chain complex must have homology -/ [hasHomology : ∀ i, complex.HasHomology i] /-- the morphism to the single chain complex with `Z` in degree `0` -/ π : complex ⟶ (ChainComplex.single₀ C).obj Z /-- the morphism to the single chain complex with `Z` in degree `0` is a quasi-isomorphism -/ quasiIso : QuasiIso π := by infer_instance open ProjectiveResolution in attribute [instance] projective hasHomology ProjectiveResolution.quasiIso /-- An object admits a projective resolution. -/ class HasProjectiveResolution (Z : C) : Prop where out : Nonempty (ProjectiveResolution Z) variable (C) /-- You will rarely use this typeclass directly: it is implied by the combination `[EnoughProjectives C]` and `[Abelian C]`. By itself it's enough to set up the basic theory of derived functors. -/ class HasProjectiveResolutions : Prop where out : ∀ Z : C, HasProjectiveResolution Z attribute [instance 100] HasProjectiveResolutions.out namespace ProjectiveResolution variable {C} variable {Z : C} (P : ProjectiveResolution Z) lemma complex_exactAt_succ (n : ℕ) : P.complex.ExactAt (n + 1) := by rw [← quasiIsoAt_iff_exactAt' P.π (n + 1) (exactAt_succ_single_obj _ _)] infer_instance lemma exact_succ (n : ℕ) : (ShortComplex.mk _ _ (P.complex.d_comp_d (n + 2) (n + 1) n)).Exact := ((HomologicalComplex.exactAt_iff' _ (n + 2) (n + 1) n) (by simp only [prev]; rfl) (by simp)).1 (P.complex_exactAt_succ n) @[simp] theorem π_f_succ (n : ℕ) : P.π.f (n + 1) = 0 := (isZero_single_obj_X _ _ _ _ (by simp)).eq_of_tgt _ _ @[reassoc (attr := simp)] theorem complex_d_comp_π_f_zero : P.complex.d 1 0 ≫ P.π.f 0 = 0 := by rw [← P.π.comm 1 0, single_obj_d, comp_zero] -- Porting note (#10618): removed @[simp] simp can prove this theorem complex_d_succ_comp (n : ℕ) : P.complex.d n (n + 1) ≫ P.complex.d (n + 1) (n + 2) = 0 := by simp /-- The (limit) cokernel cofork given by the composition `P.complex.X 1 ⟶ P.complex.X 0 ⟶ Z` when `P : ProjectiveResolution Z`. -/ @[simp] noncomputable def cokernelCofork : CokernelCofork (P.complex.d 1 0) := CokernelCofork.ofπ _ P.complex_d_comp_π_f_zero /-- `Z` is the cokernel of `P.complex.X 1 ⟶ P.complex.X 0` when `P : ProjectiveResolution Z`. -/ noncomputable def isColimitCokernelCofork : IsColimit (P.cokernelCofork) := by refine IsColimit.ofIsoColimit (P.complex.opcyclesIsCokernel 1 0 (by simp)) ?_ refine Cofork.ext (P.complex.isoHomologyι₀.symm ≪≫ isoOfQuasiIsoAt P.π 0 ≪≫ singleObjHomologySelfIso _ _ _) ?_ rw [← cancel_mono (singleObjHomologySelfIso (ComplexShape.down ℕ) 0 _).inv, ← cancel_mono (isoHomologyι₀ _).hom] dsimp simp only [isoHomologyι₀_inv_naturality_assoc, p_opcyclesMap_assoc, single₀_obj_zero, assoc, Iso.hom_inv_id, comp_id, isoHomologyι_inv_hom_id, singleObjHomologySelfIso_inv_homologyι, singleObjOpcyclesSelfIso_hom, single₀ObjXSelf, Iso.refl_inv, id_comp] instance (n : ℕ) : Epi (P.π.f n) := by cases n · exact epi_of_isColimit_cofork P.isColimitCokernelCofork · rw [π_f_succ]; infer_instance variable (Z) /-- A projective object admits a trivial projective resolution: itself in degree 0. -/ @[simps] noncomputable def self [Projective Z] : ProjectiveResolution Z where complex := (ChainComplex.single₀ C).obj Z π := 𝟙 ((ChainComplex.single₀ C).obj Z) projective n := by cases n · simpa · apply IsZero.projective apply HomologicalComplex.isZero_single_obj_X simp end ProjectiveResolution end CategoryTheory
CategoryTheory\Preadditive\Schur.lean
/- Copyright (c) 2020 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Markus Himmel, Scott Morrison -/ import Mathlib.Algebra.Group.Ext import Mathlib.CategoryTheory.Simple import Mathlib.CategoryTheory.Linear.Basic import Mathlib.CategoryTheory.Endomorphism import Mathlib.FieldTheory.IsAlgClosed.Spectrum /-! # Schur's lemma We first prove the part of Schur's Lemma that holds in any preadditive category with kernels, that any nonzero morphism between simple objects is an isomorphism. Second, we prove Schur's lemma for `𝕜`-linear categories with finite dimensional hom spaces, over an algebraically closed field `𝕜`: the hom space `X ⟶ Y` between simple objects `X` and `Y` is at most one dimensional, and is 1-dimensional iff `X` and `Y` are isomorphic. -/ namespace CategoryTheory open CategoryTheory.Limits variable {C : Type*} [Category C] variable [Preadditive C] -- See also `epi_of_nonzero_to_simple`, which does not require `Preadditive C`. theorem mono_of_nonzero_from_simple [HasKernels C] {X Y : C} [Simple X] {f : X ⟶ Y} (w : f ≠ 0) : Mono f := Preadditive.mono_of_kernel_zero (kernel_zero_of_nonzero_from_simple w) /-- The part of **Schur's lemma** that holds in any preadditive category with kernels: that a nonzero morphism between simple objects is an isomorphism. -/ theorem isIso_of_hom_simple [HasKernels C] {X Y : C} [Simple X] [Simple Y] {f : X ⟶ Y} (w : f ≠ 0) : IsIso f := haveI := mono_of_nonzero_from_simple w isIso_of_mono_of_nonzero w /-- As a corollary of Schur's lemma for preadditive categories, any morphism between simple objects is (exclusively) either an isomorphism or zero. -/ theorem isIso_iff_nonzero [HasKernels C] {X Y : C} [Simple X] [Simple Y] (f : X ⟶ Y) : IsIso f ↔ f ≠ 0 := ⟨fun I => by intro h apply id_nonzero X simp only [← IsIso.hom_inv_id f, h, zero_comp], fun w => isIso_of_hom_simple w⟩ open scoped Classical in /-- In any preadditive category with kernels, the endomorphisms of a simple object form a division ring. -/ noncomputable instance [HasKernels C] {X : C} [Simple X] : DivisionRing (End X) where inv f := if h : f = 0 then 0 else haveI := isIso_of_hom_simple h; inv f exists_pair_ne := ⟨𝟙 X, 0, id_nonzero _⟩ inv_zero := dif_pos rfl mul_inv_cancel f hf := by dsimp rw [dif_neg hf] haveI := isIso_of_hom_simple hf exact IsIso.inv_hom_id f nnqsmul := _ qsmul := _ open FiniteDimensional section variable (𝕜 : Type*) [DivisionRing 𝕜] /-- Part of **Schur's lemma** for `𝕜`-linear categories: the hom space between two non-isomorphic simple objects is 0-dimensional. -/ theorem finrank_hom_simple_simple_eq_zero_of_not_iso [HasKernels C] [Linear 𝕜 C] {X Y : C} [Simple X] [Simple Y] (h : (X ≅ Y) → False) : finrank 𝕜 (X ⟶ Y) = 0 := haveI := subsingleton_of_forall_eq (0 : X ⟶ Y) fun f => by have p := not_congr (isIso_iff_nonzero f) simp only [Classical.not_not, Ne] at p exact p.mp fun _ => h (asIso f) finrank_zero_of_subsingleton end variable (𝕜 : Type*) [Field 𝕜] variable [IsAlgClosed 𝕜] [Linear 𝕜 C] -- Porting note: the defeq issue in lean3 described below is no longer a problem in Lean4. -- In the proof below we have some difficulty using `I : FiniteDimensional 𝕜 (X ⟶ X)` -- where we need a `FiniteDimensional 𝕜 (End X)`. -- These are definitionally equal, but without eta reduction Lean can't see this. -- To get around this, we use `convert I`, -- then check the various instances agree field-by-field, -- We prove this with the explicit `isIso_iff_nonzero` assumption, -- rather than just `[Simple X]`, as this form is useful for -- Müger's formulation of semisimplicity. /-- An auxiliary lemma for Schur's lemma. If `X ⟶ X` is finite dimensional, and every nonzero endomorphism is invertible, then `X ⟶ X` is 1-dimensional. -/ theorem finrank_endomorphism_eq_one {X : C} (isIso_iff_nonzero : ∀ f : X ⟶ X, IsIso f ↔ f ≠ 0) [I : FiniteDimensional 𝕜 (X ⟶ X)] : finrank 𝕜 (X ⟶ X) = 1 := by have id_nonzero := (isIso_iff_nonzero (𝟙 X)).mp (by infer_instance) refine finrank_eq_one (𝟙 X) id_nonzero ?_ intro f have : Nontrivial (End X) := nontrivial_of_ne _ _ id_nonzero have : FiniteDimensional 𝕜 (End X) := I obtain ⟨c, nu⟩ := spectrum.nonempty_of_isAlgClosed_of_finiteDimensional 𝕜 (End.of f) use c rw [spectrum.mem_iff, IsUnit.sub_iff, isUnit_iff_isIso, isIso_iff_nonzero, Ne, Classical.not_not, sub_eq_zero, Algebra.algebraMap_eq_smul_one] at nu exact nu.symm variable [HasKernels C] /-- **Schur's lemma** for endomorphisms in `𝕜`-linear categories. -/ theorem finrank_endomorphism_simple_eq_one (X : C) [Simple X] [FiniteDimensional 𝕜 (X ⟶ X)] : finrank 𝕜 (X ⟶ X) = 1 := finrank_endomorphism_eq_one 𝕜 isIso_iff_nonzero theorem endomorphism_simple_eq_smul_id {X : C} [Simple X] [FiniteDimensional 𝕜 (X ⟶ X)] (f : X ⟶ X) : ∃ c : 𝕜, c • 𝟙 X = f := (finrank_eq_one_iff_of_nonzero' (𝟙 X) (id_nonzero X)).mp (finrank_endomorphism_simple_eq_one 𝕜 X) f /-- Endomorphisms of a simple object form a field if they are finite dimensional. This can't be an instance as `𝕜` would be undetermined. -/ noncomputable def fieldEndOfFiniteDimensional (X : C) [Simple X] [I : FiniteDimensional 𝕜 (X ⟶ X)] : Field (End X) := by classical exact { (inferInstance : DivisionRing (End X)) with mul_comm := fun f g => by obtain ⟨c, rfl⟩ := endomorphism_simple_eq_smul_id 𝕜 f obtain ⟨d, rfl⟩ := endomorphism_simple_eq_smul_id 𝕜 g simp [← mul_smul, mul_comm c d] } -- There is a symmetric argument that uses `[FiniteDimensional 𝕜 (Y ⟶ Y)]` instead, -- but we don't bother proving that here. /-- **Schur's lemma** for `𝕜`-linear categories: if hom spaces are finite dimensional, then the hom space between simples is at most 1-dimensional. See `finrank_hom_simple_simple_eq_one_iff` and `finrank_hom_simple_simple_eq_zero_iff` below for the refinements when we know whether or not the simples are isomorphic. -/ theorem finrank_hom_simple_simple_le_one (X Y : C) [FiniteDimensional 𝕜 (X ⟶ X)] [Simple X] [Simple Y] : finrank 𝕜 (X ⟶ Y) ≤ 1 := by obtain (h|h) := subsingleton_or_nontrivial (X ⟶ Y) · rw [finrank_zero_of_subsingleton] exact zero_le_one · obtain ⟨f, nz⟩ := (nontrivial_iff_exists_ne 0).mp h haveI fi := (isIso_iff_nonzero f).mpr nz refine finrank_le_one f ?_ intro g obtain ⟨c, w⟩ := endomorphism_simple_eq_smul_id 𝕜 (g ≫ inv f) exact ⟨c, by simpa using w =≫ f⟩ theorem finrank_hom_simple_simple_eq_one_iff (X Y : C) [FiniteDimensional 𝕜 (X ⟶ X)] [FiniteDimensional 𝕜 (X ⟶ Y)] [Simple X] [Simple Y] : finrank 𝕜 (X ⟶ Y) = 1 ↔ Nonempty (X ≅ Y) := by fconstructor · intro h rw [finrank_eq_one_iff'] at h obtain ⟨f, nz, -⟩ := h rw [← isIso_iff_nonzero] at nz exact ⟨asIso f⟩ · rintro ⟨f⟩ have le_one := finrank_hom_simple_simple_le_one 𝕜 X Y have zero_lt : 0 < finrank 𝕜 (X ⟶ Y) := finrank_pos_iff_exists_ne_zero.mpr ⟨f.hom, (isIso_iff_nonzero f.hom).mp inferInstance⟩ omega theorem finrank_hom_simple_simple_eq_zero_iff (X Y : C) [FiniteDimensional 𝕜 (X ⟶ X)] [FiniteDimensional 𝕜 (X ⟶ Y)] [Simple X] [Simple Y] : finrank 𝕜 (X ⟶ Y) = 0 ↔ IsEmpty (X ≅ Y) := by rw [← not_nonempty_iff, ← not_congr (finrank_hom_simple_simple_eq_one_iff 𝕜 X Y)] refine ⟨fun h => by rw [h]; simp, fun h => ?_⟩ have := finrank_hom_simple_simple_le_one 𝕜 X Y interval_cases finrank 𝕜 (X ⟶ Y) · rfl · exact False.elim (h rfl) open scoped Classical theorem finrank_hom_simple_simple (X Y : C) [∀ X Y : C, FiniteDimensional 𝕜 (X ⟶ Y)] [Simple X] [Simple Y] : finrank 𝕜 (X ⟶ Y) = if Nonempty (X ≅ Y) then 1 else 0 := by split_ifs with h · exact (finrank_hom_simple_simple_eq_one_iff 𝕜 X Y).2 h · exact (finrank_hom_simple_simple_eq_zero_iff 𝕜 X Y).2 (not_nonempty_iff.mp h) end CategoryTheory
CategoryTheory\Preadditive\SingleObj.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.Preadditive.Basic import Mathlib.CategoryTheory.SingleObj /-! # `SingleObj α` is preadditive when `α` is a ring. -/ namespace CategoryTheory variable {α : Type*} [Ring α] instance : Preadditive (SingleObj α) where add_comp _ _ _ f f' g := mul_add g f f' comp_add _ _ _ f g g' := add_mul g g' f -- TODO define `PreAddCat` (with additive functors as morphisms), and `Ring ⥤ PreAddCat`. end CategoryTheory
CategoryTheory\Preadditive\Yoneda\Basic.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.Preadditive.Opposite import Mathlib.Algebra.Category.ModuleCat.Basic import Mathlib.Algebra.Category.Grp.Preadditive /-! # The Yoneda embedding for preadditive categories The Yoneda embedding for preadditive categories sends an object `Y` to the presheaf sending an object `X` to the group of morphisms `X ⟶ Y`. At each point, we get an additional `End Y`-module structure. We also show that this presheaf is additive and that it is compatible with the normal Yoneda embedding in the expected way and deduce that the preadditive Yoneda embedding is fully faithful. ## TODO * The Yoneda embedding is additive itself -/ universe v u open CategoryTheory.Preadditive Opposite CategoryTheory.Limits noncomputable section namespace CategoryTheory variable {C : Type u} [Category.{v} C] [Preadditive C] /-- The Yoneda embedding for preadditive categories sends an object `Y` to the presheaf sending an object `X` to the `End Y`-module of morphisms `X ⟶ Y`. -/ @[simps] def preadditiveYonedaObj (Y : C) : Cᵒᵖ ⥤ ModuleCat.{v} (End Y) where obj X := ModuleCat.of _ (X.unop ⟶ Y) map f := ModuleCat.ofHom { toFun := fun g => f.unop ≫ g map_add' := fun g g' => comp_add _ _ _ _ _ _ map_smul' := fun r g => Eq.symm <| Category.assoc _ _ _ } /-- The Yoneda embedding for preadditive categories sends an object `Y` to the presheaf sending an object `X` to the group of morphisms `X ⟶ Y`. At each point, we get an additional `End Y`-module structure, see `preadditiveYonedaObj`. -/ @[simps] def preadditiveYoneda : C ⥤ Cᵒᵖ ⥤ AddCommGrp.{v} where obj Y := preadditiveYonedaObj Y ⋙ forget₂ _ _ map f := { app := fun X => { toFun := fun g => g ≫ f map_zero' := Limits.zero_comp map_add' := fun g g' => add_comp _ _ _ _ _ _ } naturality := fun X X' g => AddCommGrp.ext fun x => Category.assoc _ _ _ } map_id _ := by ext; dsimp; simp map_comp f g := by ext; dsimp; simp /-- The Yoneda embedding for preadditive categories sends an object `X` to the copresheaf sending an object `Y` to the `End X`-module of morphisms `X ⟶ Y`. -/ @[simps] def preadditiveCoyonedaObj (X : Cᵒᵖ) : C ⥤ ModuleCat.{v} (End X) where obj Y := ModuleCat.of _ (unop X ⟶ Y) map f := ModuleCat.ofHom { toFun := fun g => g ≫ f map_add' := fun g g' => add_comp _ _ _ _ _ _ map_smul' := fun r g => Category.assoc _ _ _ } /-- The Yoneda embedding for preadditive categories sends an object `X` to the copresheaf sending an object `Y` to the group of morphisms `X ⟶ Y`. At each point, we get an additional `End X`-module structure, see `preadditiveCoyonedaObj`. -/ @[simps] def preadditiveCoyoneda : Cᵒᵖ ⥤ C ⥤ AddCommGrp.{v} where obj X := preadditiveCoyonedaObj X ⋙ forget₂ _ _ map f := { app := fun Y => { toFun := fun g => f.unop ≫ g map_zero' := Limits.comp_zero map_add' := fun g g' => comp_add _ _ _ _ _ _ } naturality := fun Y Y' g => AddCommGrp.ext fun x => Eq.symm <| Category.assoc _ _ _ } map_id _ := by ext; dsimp; simp map_comp f g := by ext; dsimp; simp -- These lemmas have always been bad (#7657), but leanprover/lean4#2644 made `simp` start noticing attribute [nolint simpNF] CategoryTheory.preadditiveYoneda_map_app_apply CategoryTheory.preadditiveCoyoneda_map_app_apply instance additive_yonedaObj (X : C) : Functor.Additive (preadditiveYonedaObj X) where instance additive_yonedaObj' (X : C) : Functor.Additive (preadditiveYoneda.obj X) where instance additive_coyonedaObj (X : Cᵒᵖ) : Functor.Additive (preadditiveCoyonedaObj X) where instance additive_coyonedaObj' (X : Cᵒᵖ) : Functor.Additive (preadditiveCoyoneda.obj X) where /-- Composing the preadditive yoneda embedding with the forgetful functor yields the regular Yoneda embedding. -/ @[simp] theorem whiskering_preadditiveYoneda : preadditiveYoneda ⋙ (whiskeringRight Cᵒᵖ AddCommGrp (Type v)).obj (forget AddCommGrp) = yoneda := rfl /-- Composing the preadditive yoneda embedding with the forgetful functor yields the regular Yoneda embedding. -/ @[simp] theorem whiskering_preadditiveCoyoneda : preadditiveCoyoneda ⋙ (whiskeringRight C AddCommGrp (Type v)).obj (forget AddCommGrp) = coyoneda := rfl instance full_preadditiveYoneda : (preadditiveYoneda : C ⥤ Cᵒᵖ ⥤ AddCommGrp).Full := let _ : Functor.Full (preadditiveYoneda ⋙ (whiskeringRight Cᵒᵖ AddCommGrp (Type v)).obj (forget AddCommGrp)) := Yoneda.yoneda_full Functor.Full.of_comp_faithful preadditiveYoneda ((whiskeringRight Cᵒᵖ AddCommGrp (Type v)).obj (forget AddCommGrp)) instance full_preadditiveCoyoneda : (preadditiveCoyoneda : Cᵒᵖ ⥤ C ⥤ AddCommGrp).Full := let _ : Functor.Full (preadditiveCoyoneda ⋙ (whiskeringRight C AddCommGrp (Type v)).obj (forget AddCommGrp)) := Coyoneda.coyoneda_full Functor.Full.of_comp_faithful preadditiveCoyoneda ((whiskeringRight C AddCommGrp (Type v)).obj (forget AddCommGrp)) instance faithful_preadditiveYoneda : (preadditiveYoneda : C ⥤ Cᵒᵖ ⥤ AddCommGrp).Faithful := Functor.Faithful.of_comp_eq whiskering_preadditiveYoneda instance faithful_preadditiveCoyoneda : (preadditiveCoyoneda : Cᵒᵖ ⥤ C ⥤ AddCommGrp).Faithful := Functor.Faithful.of_comp_eq whiskering_preadditiveCoyoneda end CategoryTheory
CategoryTheory\Preadditive\Yoneda\Injective.lean
/- Copyright (c) 2020 Markus Himmel. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Markus Himmel, Scott Morrison -/ import Mathlib.CategoryTheory.Preadditive.Yoneda.Basic import Mathlib.CategoryTheory.Preadditive.Injective import Mathlib.Algebra.Category.Grp.EpiMono import Mathlib.Algebra.Category.ModuleCat.EpiMono /-! An object is injective iff the preadditive yoneda functor on it preserves epimorphisms. -/ universe v u open Opposite namespace CategoryTheory variable {C : Type u} [Category.{v} C] section Preadditive variable [Preadditive C] namespace Injective theorem injective_iff_preservesEpimorphisms_preadditiveYoneda_obj (J : C) : Injective J ↔ (preadditiveYoneda.obj J).PreservesEpimorphisms := by rw [injective_iff_preservesEpimorphisms_yoneda_obj] refine ⟨fun h : (preadditiveYoneda.obj J ⋙ (forget AddCommGrp)).PreservesEpimorphisms => ?_, ?_⟩ · exact Functor.preservesEpimorphisms_of_preserves_of_reflects (preadditiveYoneda.obj J) (forget _) · intro exact (inferInstance : (preadditiveYoneda.obj J ⋙ forget _).PreservesEpimorphisms) theorem injective_iff_preservesEpimorphisms_preadditive_yoneda_obj' (J : C) : Injective J ↔ (preadditiveYonedaObj J).PreservesEpimorphisms := by rw [injective_iff_preservesEpimorphisms_yoneda_obj] refine ⟨fun h : (preadditiveYonedaObj J ⋙ (forget <| ModuleCat (End J))).PreservesEpimorphisms => ?_, ?_⟩ · exact Functor.preservesEpimorphisms_of_preserves_of_reflects (preadditiveYonedaObj J) (forget _) · intro exact (inferInstance : (preadditiveYonedaObj J ⋙ forget _).PreservesEpimorphisms) end Injective end Preadditive end CategoryTheory
CategoryTheory\Preadditive\Yoneda\Limits.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.Preadditive.Yoneda.Basic import Mathlib.Algebra.Category.ModuleCat.Abelian import Mathlib.CategoryTheory.Limits.Yoneda /-! # The Yoneda embedding for preadditive categories preserves limits The Yoneda embedding for preadditive categories preserves limits. ## Implementation notes This is in a separate file to avoid having to import the development of the abelian structure on `ModuleCat` in the main file about the preadditive Yoneda embedding. -/ universe v u open CategoryTheory.Preadditive Opposite CategoryTheory.Limits noncomputable section namespace CategoryTheory variable {C : Type u} [Category.{v} C] [Preadditive C] instance preservesLimitsPreadditiveYonedaObj (X : C) : PreservesLimits (preadditiveYonedaObj X) := have : PreservesLimits (preadditiveYonedaObj X ⋙ forget _) := (inferInstance : PreservesLimits (yoneda.obj X)) preservesLimitsOfReflectsOfPreserves _ (forget _) instance preservesLimitsPreadditiveCoyonedaObj (X : Cᵒᵖ) : PreservesLimits (preadditiveCoyonedaObj X) := have : PreservesLimits (preadditiveCoyonedaObj X ⋙ forget _) := (inferInstance : PreservesLimits (coyoneda.obj X)) preservesLimitsOfReflectsOfPreserves _ (forget _) instance PreservesLimitsPreadditiveYoneda.obj (X : C) : PreservesLimits (preadditiveYoneda.obj X) := show PreservesLimits (preadditiveYonedaObj X ⋙ forget₂ _ _) from inferInstance instance PreservesLimitsPreadditiveCoyoneda.obj (X : Cᵒᵖ) : PreservesLimits (preadditiveCoyoneda.obj X) := show PreservesLimits (preadditiveCoyonedaObj X ⋙ forget₂ _ _) from inferInstance end CategoryTheory
CategoryTheory\Preadditive\Yoneda\Projective.lean
/- Copyright (c) 2020 Markus Himmel. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Markus Himmel, Scott Morrison -/ import Mathlib.CategoryTheory.Preadditive.Yoneda.Basic import Mathlib.CategoryTheory.Preadditive.Projective import Mathlib.Algebra.Category.Grp.EpiMono /-! An object is projective iff the preadditive coyoneda functor on it preserves epimorphisms. -/ universe v u open Opposite namespace CategoryTheory variable {C : Type u} [Category.{v} C] section Preadditive variable [Preadditive C] namespace Projective theorem projective_iff_preservesEpimorphisms_preadditiveCoyoneda_obj (P : C) : Projective P ↔ (preadditiveCoyoneda.obj (op P)).PreservesEpimorphisms := by rw [projective_iff_preservesEpimorphisms_coyoneda_obj] refine ⟨fun h : (preadditiveCoyoneda.obj (op P) ⋙ forget AddCommGrp).PreservesEpimorphisms => ?_, ?_⟩ · exact Functor.preservesEpimorphisms_of_preserves_of_reflects (preadditiveCoyoneda.obj (op P)) (forget _) · intro exact (inferInstance : (preadditiveCoyoneda.obj (op P) ⋙ forget _).PreservesEpimorphisms) theorem projective_iff_preservesEpimorphisms_preadditiveCoyoneda_obj' (P : C) : Projective P ↔ (preadditiveCoyoneda.obj (op P)).PreservesEpimorphisms := by rw [projective_iff_preservesEpimorphisms_coyoneda_obj] refine ⟨fun h : (preadditiveCoyoneda.obj (op P) ⋙ forget AddCommGrp).PreservesEpimorphisms => ?_, ?_⟩ · exact Functor.preservesEpimorphisms_of_preserves_of_reflects (preadditiveCoyoneda.obj (op P)) (forget _) · intro exact (inferInstance : (preadditiveCoyoneda.obj (op P) ⋙ forget _).PreservesEpimorphisms) end Projective end Preadditive end CategoryTheory
CategoryTheory\Products\Associator.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 -/ import Mathlib.CategoryTheory.Products.Basic /-! The associator functor `((C × D) × E) ⥤ (C × (D × E))` and its inverse form an equivalence. -/ universe v₁ v₂ v₃ u₁ u₂ u₃ open CategoryTheory namespace CategoryTheory.prod variable (C : Type u₁) [Category.{v₁} C] (D : Type u₂) [Category.{v₂} D] (E : Type u₃) [Category.{v₃} E] /-- The associator functor `(C × D) × E ⥤ C × (D × E)`. -/ @[simps] def associator : (C × D) × E ⥤ C × D × E where obj X := (X.1.1, (X.1.2, X.2)) map := @fun _ _ f => (f.1.1, (f.1.2, f.2)) /-- The inverse associator functor `C × (D × E) ⥤ (C × D) × E `. -/ @[simps] def inverseAssociator : C × D × E ⥤ (C × D) × E where obj X := ((X.1, X.2.1), X.2.2) map := @fun _ _ f => ((f.1, f.2.1), f.2.2) /-- The equivalence of categories expressing associativity of products of categories. -/ def associativity : (C × D) × E ≌ C × D × E := Equivalence.mk (associator C D E) (inverseAssociator C D E) (NatIso.ofComponents fun X => eqToIso (by simp)) (NatIso.ofComponents fun X => eqToIso (by simp)) instance associatorIsEquivalence : (associator C D E).IsEquivalence := (by infer_instance : (associativity C D E).functor.IsEquivalence) instance inverseAssociatorIsEquivalence : (inverseAssociator C D E).IsEquivalence := (by infer_instance : (associativity C D E).inverse.IsEquivalence) -- TODO pentagon natural transformation? ...satisfying? end CategoryTheory.prod
CategoryTheory\Products\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 -/ import Mathlib.CategoryTheory.EqToHom import Mathlib.CategoryTheory.Functor.Const import Mathlib.CategoryTheory.Opposites import Mathlib.Data.Prod.Basic /-! # Cartesian products of categories We define the category instance on `C × D` when `C` and `D` are categories. We define: * `sectl C Z` : the functor `C ⥤ C × D` given by `X ↦ ⟨X, Z⟩` * `sectr Z D` : the functor `D ⥤ C × D` given by `Y ↦ ⟨Z, Y⟩` * `fst` : the functor `⟨X, Y⟩ ↦ X` * `snd` : the functor `⟨X, Y⟩ ↦ Y` * `swap` : the functor `C × D ⥤ D × C` given by `⟨X, Y⟩ ↦ ⟨Y, X⟩` (and the fact this is an equivalence) We further define `evaluation : C ⥤ (C ⥤ D) ⥤ D` and `evaluationUncurried : C × (C ⥤ D) ⥤ D`, and products of functors and natural transformations, written `F.prod G` and `α.prod β`. -/ namespace CategoryTheory -- declare the `v`'s first; see `CategoryTheory.Category` for an explanation universe v₁ v₂ v₃ v₄ u₁ u₂ u₃ u₄ section variable (C : Type u₁) [Category.{v₁} C] (D : Type u₂) [Category.{v₂} D] -- the generates simp lemmas like `id_fst` and `comp_snd` /-- `prod C D` gives the cartesian product of two categories. See <https://stacks.math.columbia.edu/tag/001K>. -/ @[simps (config := { notRecursive := [] }) Hom id_fst id_snd comp_fst comp_snd] instance prod : Category.{max v₁ v₂} (C × D) where Hom X Y := (X.1 ⟶ Y.1) × (X.2 ⟶ Y.2) id X := ⟨𝟙 X.1, 𝟙 X.2⟩ comp f g := (f.1 ≫ g.1, f.2 ≫ g.2) /-- Two rfl lemmas that cannot be generated by `@[simps]`. -/ @[simp] theorem prod_id (X : C) (Y : D) : 𝟙 (X, Y) = (𝟙 X, 𝟙 Y) := rfl @[simp] theorem prod_comp {P Q R : C} {S T U : D} (f : (P, S) ⟶ (Q, T)) (g : (Q, T) ⟶ (R, U)) : f ≫ g = (f.1 ≫ g.1, f.2 ≫ g.2) := rfl theorem isIso_prod_iff {P Q : C} {S T : D} {f : (P, S) ⟶ (Q, T)} : IsIso f ↔ IsIso f.1 ∧ IsIso f.2 := by constructor · rintro ⟨g, hfg, hgf⟩ simp? at hfg hgf says simp only [prod_Hom, prod_comp, prod_id, Prod.mk.injEq] at hfg hgf rcases hfg with ⟨hfg₁, hfg₂⟩ rcases hgf with ⟨hgf₁, hgf₂⟩ exact ⟨⟨⟨g.1, hfg₁, hgf₁⟩⟩, ⟨⟨g.2, hfg₂, hgf₂⟩⟩⟩ · rintro ⟨⟨g₁, hfg₁, hgf₁⟩, ⟨g₂, hfg₂, hgf₂⟩⟩ dsimp at hfg₁ hgf₁ hfg₂ hgf₂ refine ⟨⟨(g₁, g₂), ?_, ?_⟩⟩ repeat { simp; constructor; assumption; assumption } section variable {C D} /-- The isomorphism between `(X.1, X.2)` and `X`. -/ @[simps] def prod.etaIso (X : C × D) : (X.1, X.2) ≅ X where hom := (𝟙 _, 𝟙 _) inv := (𝟙 _, 𝟙 _) /-- Construct an isomorphism in `C × D` out of two isomorphisms in `C` and `D`. -/ @[simps] def Iso.prod {P Q : C} {S T : D} (f : P ≅ Q) (g : S ≅ T) : (P, S) ≅ (Q, T) where hom := (f.hom, g.hom) inv := (f.inv, g.inv) end end section variable (C : Type u₁) [Category.{v₁} C] (D : Type u₁) [Category.{v₁} D] /-- `Category.uniformProd C D` is an additional instance specialised so both factors have the same universe levels. This helps typeclass resolution. -/ instance uniformProd : Category (C × D) := CategoryTheory.prod C D end -- Next we define the natural functors into and out of product categories. For now this doesn't -- address the universal properties. namespace Prod /-- `sectl C Z` is the functor `C ⥤ C × D` given by `X ↦ (X, Z)`. -/ @[simps] def sectl (C : Type u₁) [Category.{v₁} C] {D : Type u₂} [Category.{v₂} D] (Z : D) : C ⥤ C × D where obj X := (X, Z) map f := (f, 𝟙 Z) /-- `sectr Z D` is the functor `D ⥤ C × D` given by `Y ↦ (Z, Y)` . -/ @[simps] def sectr {C : Type u₁} [Category.{v₁} C] (Z : C) (D : Type u₂) [Category.{v₂} D] : D ⥤ C × D where obj X := (Z, X) map f := (𝟙 Z, f) variable (C : Type u₁) [Category.{v₁} C] (D : Type u₂) [Category.{v₂} D] /-- `fst` is the functor `(X, Y) ↦ X`. -/ @[simps] def fst : C × D ⥤ C where obj X := X.1 map f := f.1 /-- `snd` is the functor `(X, Y) ↦ Y`. -/ @[simps] def snd : C × D ⥤ D where obj X := X.2 map f := f.2 /-- The functor swapping the factors of a cartesian product of categories, `C × D ⥤ D × C`. -/ @[simps] def swap : C × D ⥤ D × C where obj X := (X.2, X.1) map f := (f.2, f.1) /-- Swapping the factors of a cartesian product of categories twice is naturally isomorphic to the identity functor. -/ @[simps] def symmetry : swap C D ⋙ swap D C ≅ 𝟭 (C × D) where hom := { app := fun X => 𝟙 X } inv := { app := fun X => 𝟙 X } /-- The equivalence, given by swapping factors, between `C × D` and `D × C`. -/ @[simps!] def braiding : C × D ≌ D × C := Equivalence.mk (swap C D) (swap D C) (NatIso.ofComponents fun X => eqToIso (by simp)) (NatIso.ofComponents fun X => eqToIso (by simp)) instance swapIsEquivalence : (swap C D).IsEquivalence := (by infer_instance : (braiding C D).functor.IsEquivalence) end Prod section variable (C : Type u₁) [Category.{v₁} C] (D : Type u₂) [Category.{v₂} D] /-- The "evaluation at `X`" functor, such that `(evaluation.obj X).obj F = F.obj X`, which is functorial in both `X` and `F`. -/ @[simps] def evaluation : C ⥤ (C ⥤ D) ⥤ D where obj X := { obj := fun F => F.obj X map := fun α => α.app X } map {X} {Y} f := { app := fun F => F.map f naturality := fun {F} {G} α => Eq.symm (α.naturality f) } /-- The "evaluation of `F` at `X`" functor, as a functor `C × (C ⥤ D) ⥤ D`. -/ @[simps] def evaluationUncurried : C × (C ⥤ D) ⥤ D where obj p := p.2.obj p.1 map := fun {x} {y} f => x.2.map f.1 ≫ f.2.app y.1 map_comp := fun {X} {Y} {Z} f g => by cases g; cases f; cases Z; cases Y; cases X simp only [prod_comp, NatTrans.comp_app, Functor.map_comp, Category.assoc] rw [← NatTrans.comp_app, NatTrans.naturality, NatTrans.comp_app, Category.assoc, NatTrans.naturality] variable {C} /-- The constant functor followed by the evaluation functor is just the identity. -/ @[simps!] def Functor.constCompEvaluationObj (X : C) : Functor.const C ⋙ (evaluation C D).obj X ≅ 𝟭 D := NatIso.ofComponents fun Y => Iso.refl _ end variable {A : Type u₁} [Category.{v₁} A] {B : Type u₂} [Category.{v₂} B] {C : Type u₃} [Category.{v₃} C] {D : Type u₄} [Category.{v₄} D] namespace Functor /-- The cartesian product of two functors. -/ @[simps] def prod (F : A ⥤ B) (G : C ⥤ D) : A × C ⥤ B × D where obj X := (F.obj X.1, G.obj X.2) map f := (F.map f.1, G.map f.2) /- Because of limitations in Lean 3's handling of notations, we do not setup a notation `F × G`. You can use `F.prod G` as a "poor man's infix", or just write `functor.prod F G`. -/ /-- Similar to `prod`, but both functors start from the same category `A` -/ @[simps] def prod' (F : A ⥤ B) (G : A ⥤ C) : A ⥤ B × C where obj a := (F.obj a, G.obj a) map f := (F.map f, G.map f) /-- The product `F.prod' G` followed by projection on the first component is isomorphic to `F` -/ @[simps!] def prod'CompFst (F : A ⥤ B) (G : A ⥤ C) : F.prod' G ⋙ CategoryTheory.Prod.fst B C ≅ F := NatIso.ofComponents fun X => Iso.refl _ /-- The product `F.prod' G` followed by projection on the second component is isomorphic to `G` -/ @[simps!] def prod'CompSnd (F : A ⥤ B) (G : A ⥤ C) : F.prod' G ⋙ CategoryTheory.Prod.snd B C ≅ G := NatIso.ofComponents fun X => Iso.refl _ section variable (C) /-- The diagonal functor. -/ def diag : C ⥤ C × C := (𝟭 C).prod' (𝟭 C) @[simp] theorem diag_obj (X : C) : (diag C).obj X = (X, X) := rfl @[simp] theorem diag_map {X Y : C} (f : X ⟶ Y) : (diag C).map f = (f, f) := rfl end end Functor namespace NatTrans /-- The cartesian product of two natural transformations. -/ @[simps] def prod {F G : A ⥤ B} {H I : C ⥤ D} (α : F ⟶ G) (β : H ⟶ I) : F.prod H ⟶ G.prod I where app X := (α.app X.1, β.app X.2) naturality {X} {Y} f := by cases X; cases Y simp only [Functor.prod_map, prod_comp] rw [Prod.mk.inj_iff] constructor repeat {rw [naturality]} /- Again, it is inadvisable in Lean 3 to setup a notation `α × β`; use instead `α.prod β` or `NatTrans.prod α β`. -/ end NatTrans namespace NatIso /-- The cartesian product of two natural isomorphisms. -/ @[simps] def prod {F F' : A ⥤ B} {G G' : C ⥤ D} (e₁ : F ≅ F') (e₂ : G ≅ G') : F.prod G ≅ F'.prod G' where hom := NatTrans.prod e₁.hom e₂.hom inv := NatTrans.prod e₁.inv e₂.inv end NatIso namespace Equivalence /-- The cartesian product of two equivalences of categories. -/ @[simps] def prod (E₁ : A ≌ B) (E₂ : C ≌ D) : A × C ≌ B × D where functor := E₁.functor.prod E₂.functor inverse := E₁.inverse.prod E₂.inverse unitIso := NatIso.prod E₁.unitIso E₂.unitIso counitIso := NatIso.prod E₁.counitIso E₂.counitIso end Equivalence /-- `F.flip` composed with evaluation is the same as evaluating `F`. -/ @[simps!] def flipCompEvaluation (F : A ⥤ B ⥤ C) (a) : F.flip ⋙ (evaluation _ _).obj a ≅ F.obj a := NatIso.ofComponents fun b => eqToIso rfl variable (A B C) /-- The forward direction for `functorProdFunctorEquiv` -/ @[simps] def prodFunctorToFunctorProd : (A ⥤ B) × (A ⥤ C) ⥤ A ⥤ B × C where obj F := F.1.prod' F.2 map f := { app := fun X => (f.1.app X, f.2.app X) } /-- The backward direction for `functorProdFunctorEquiv` -/ @[simps] def functorProdToProdFunctor : (A ⥤ B × C) ⥤ (A ⥤ B) × (A ⥤ C) where obj F := ⟨F ⋙ CategoryTheory.Prod.fst B C, F ⋙ CategoryTheory.Prod.snd B C⟩ map α := ⟨{ app := fun X => (α.app X).1 naturality := fun X Y f => by simp only [Functor.comp_map, Prod.fst_map, ← prod_comp_fst, α.naturality] }, { app := fun X => (α.app X).2 naturality := fun X Y f => by simp only [Functor.comp_map, Prod.snd_map, ← prod_comp_snd, α.naturality] }⟩ /-- The unit isomorphism for `functorProdFunctorEquiv` -/ @[simps!] def functorProdFunctorEquivUnitIso : 𝟭 _ ≅ prodFunctorToFunctorProd A B C ⋙ functorProdToProdFunctor A B C := NatIso.ofComponents fun F => (((Functor.prod'CompFst F.fst F.snd).prod (Functor.prod'CompSnd F.fst F.snd)).trans (prod.etaIso F)).symm /-- The counit isomorphism for `functorProdFunctorEquiv` -/ @[simps!] def functorProdFunctorEquivCounitIso : functorProdToProdFunctor A B C ⋙ prodFunctorToFunctorProd A B C ≅ 𝟭 _ := NatIso.ofComponents fun F => NatIso.ofComponents fun X => prod.etaIso (F.obj X) /-- The equivalence of categories between `(A ⥤ B) × (A ⥤ C)` and `A ⥤ (B × C)` -/ @[simps] def functorProdFunctorEquiv : (A ⥤ B) × (A ⥤ C) ≌ A ⥤ B × C := { functor := prodFunctorToFunctorProd A B C, inverse := functorProdToProdFunctor A B C, unitIso := functorProdFunctorEquivUnitIso A B C, counitIso := functorProdFunctorEquivCounitIso A B C, } section Opposite open Opposite /-- The equivalence between the opposite of a product and the product of the opposites. -/ @[simps] def prodOpEquiv : (C × D)ᵒᵖ ≌ Cᵒᵖ × Dᵒᵖ where functor := { obj := fun X ↦ ⟨op X.unop.1, op X.unop.2⟩, map := fun f ↦ ⟨f.unop.1.op, f.unop.2.op⟩ } inverse := { obj := fun ⟨X,Y⟩ ↦ op ⟨X.unop, Y.unop⟩, map := fun ⟨f,g⟩ ↦ op ⟨f.unop, g.unop⟩ } unitIso := Iso.refl _ counitIso := Iso.refl _ functor_unitIso_comp := fun ⟨X, Y⟩ => by dsimp ext <;> apply Category.id_comp end Opposite end CategoryTheory
CategoryTheory\Products\Bifunctor.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 -/ import Mathlib.CategoryTheory.Products.Basic /-! # Lemmas about functors out of product categories. -/ open CategoryTheory namespace CategoryTheory.Bifunctor universe v₁ v₂ v₃ u₁ u₂ u₃ variable {C : Type u₁} {D : Type u₂} {E : Type u₃} variable [Category.{v₁} C] [Category.{v₂} D] [Category.{v₃} E] @[simp] theorem map_id (F : C × D ⥤ E) (X : C) (Y : D) : F.map ((𝟙 X, 𝟙 Y) : (X, Y) ⟶ (X, Y)) = 𝟙 (F.obj (X, Y)) := F.map_id (X, Y) @[simp] theorem map_id_comp (F : C × D ⥤ E) (W : C) {X Y Z : D} (f : X ⟶ Y) (g : Y ⟶ Z) : F.map ((𝟙 W, f ≫ g) : (W, X) ⟶ (W, Z)) = F.map ((𝟙 W, f) : (W, X) ⟶ (W, Y)) ≫ F.map ((𝟙 W, g) : (W, Y) ⟶ (W, Z)) := by rw [← Functor.map_comp, prod_comp, Category.comp_id] @[simp] theorem map_comp_id (F : C × D ⥤ E) (X Y Z : C) (W : D) (f : X ⟶ Y) (g : Y ⟶ Z) : F.map ((f ≫ g, 𝟙 W) : (X, W) ⟶ (Z, W)) = F.map ((f, 𝟙 W) : (X, W) ⟶ (Y, W)) ≫ F.map ((g, 𝟙 W) : (Y, W) ⟶ (Z, W)) := by rw [← Functor.map_comp, prod_comp, Category.comp_id] @[simp] theorem diagonal (F : C × D ⥤ E) (X X' : C) (f : X ⟶ X') (Y Y' : D) (g : Y ⟶ Y') : F.map ((𝟙 X, g) : (X, Y) ⟶ (X, Y')) ≫ F.map ((f, 𝟙 Y') : (X, Y') ⟶ (X', Y')) = F.map ((f, g) : (X, Y) ⟶ (X', Y')) := by rw [← Functor.map_comp, prod_comp, Category.id_comp, Category.comp_id] @[simp] theorem diagonal' (F : C × D ⥤ E) (X X' : C) (f : X ⟶ X') (Y Y' : D) (g : Y ⟶ Y') : F.map ((f, 𝟙 Y) : (X, Y) ⟶ (X', Y)) ≫ F.map ((𝟙 X', g) : (X', Y) ⟶ (X', Y')) = F.map ((f, g) : (X, Y) ⟶ (X', Y')) := by rw [← Functor.map_comp, prod_comp, Category.id_comp, Category.comp_id] end CategoryTheory.Bifunctor
CategoryTheory\Products\Unitor.lean
/- Copyright (c) 2024 Shanghe Chen. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Shanghe Chen -/ import Mathlib.CategoryTheory.Products.Basic import Mathlib.CategoryTheory.DiscreteCategory /-! # The left/right unitor equivalences `1 × C ≌ C` and `C × 1 ≌ C`. -/ universe w v u open CategoryTheory namespace CategoryTheory.prod variable (C : Type u) [Category.{v} C] /-- The left unitor functor `1 × C ⥤ C` -/ @[simps] def leftUnitor : Discrete (PUnit : Type w) × C ⥤ C where obj X := X.2 map f := f.2 /-- The right unitor functor `C × 1 ⥤ C` -/ @[simps] def rightUnitor : C × Discrete (PUnit : Type w) ⥤ C where obj X := X.1 map f := f.1 /-- The left inverse unitor `C ⥤ 1 × C` -/ @[simps] def leftInverseUnitor : C ⥤ Discrete (PUnit : Type w) × C where obj X := ⟨⟨PUnit.unit⟩, X⟩ map f := ⟨𝟙 _, f⟩ /-- The right inverse unitor `C ⥤ C × 1` -/ @[simps] def rightInverseUnitor : C ⥤ C × Discrete (PUnit : Type w) where obj X := ⟨X, ⟨PUnit.unit⟩⟩ map f := ⟨f, 𝟙 _⟩ /-- The equivalence of categories expressing left unity of products of categories. -/ @[simps] def leftUnitorEquivalence : Discrete (PUnit : Type w) × C ≌ C where functor := leftUnitor C inverse := leftInverseUnitor C unitIso := Iso.refl _ counitIso := Iso.refl _ /-- The equivalence of categories expressing right unity of products of categories. -/ @[simps] def rightUnitorEquivalence : C × Discrete (PUnit : Type w) ≌ C where functor := rightUnitor C inverse := rightInverseUnitor C unitIso := Iso.refl _ counitIso := Iso.refl _ instance leftUnitor_isEquivalence : (leftUnitor C).IsEquivalence := (leftUnitorEquivalence C).isEquivalence_functor instance rightUnitor_isEquivalence : (rightUnitor C).IsEquivalence := (rightUnitorEquivalence C).isEquivalence_functor end CategoryTheory.prod
CategoryTheory\Quotient\Linear.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.Quotient import Mathlib.CategoryTheory.Linear.LinearFunctor /-! # The quotient category is linear If `r : HomRel C` is a congruence on a preadditive category `C` which satisfies certain compatibilities, we have already defined a preadditive structure on `Quotient r` in the file `CategoryTheory.Quotient.Preadditive` such that `functor r : C ⥤ Quotient r` is an additive functor. In this file, assuming moreover that `C` is a `R`-linear category and that the relation `r` is compatible with the scalar multiplication by any `a : R`, we show that `Quotient r` is a `R`-linear category and that `functor r : C ⥤ Quotient r` is a `R`-linear functor. -/ namespace CategoryTheory namespace Quotient variable {R C : Type*} [Semiring R] [Category C] [Preadditive C] [Linear R C] (r : HomRel C) [Congruence r] namespace Linear /-- The scalar multiplications on morphisms in `Quotient R`. -/ def smul (hr : ∀ (a : R) ⦃X Y : C⦄ (f₁ f₂ : X ⟶ Y) (_ : r f₁ f₂), r (a • f₁) (a • f₂)) (X Y : Quotient r) : SMul R (X ⟶ Y) where smul a := Quot.lift (fun g => Quot.mk _ (a • g)) (fun f₁ f₂ h₁₂ => by dsimp simp only [compClosure_eq_self] at h₁₂ apply Quot.sound rw [compClosure_eq_self] exact hr _ _ _ h₁₂) @[simp] lemma smul_eq (hr : ∀ (a : R) ⦃X Y : C⦄ (f₁ f₂ : X ⟶ Y) (_ : r f₁ f₂), r (a • f₁) (a • f₂)) (a : R) {X Y : C} (f : X ⟶ Y) : letI := smul r hr a • (functor r).map f = (functor r).map (a • f) := rfl /-- Auxiliary definition for `Quotient.Linear.module`. -/ def module' (hr : ∀ (a : R) ⦃X Y : C⦄ (f₁ f₂ : X ⟶ Y) (_ : r f₁ f₂), r (a • f₁) (a • f₂)) [Preadditive (Quotient r)] [(functor r).Additive] (X Y : C) : Module R ((functor r).obj X ⟶ (functor r).obj Y) := letI := smul r hr ((functor r).obj X) ((functor r).obj Y) { smul_zero := fun a => by dsimp rw [← (functor r).map_zero X Y, smul_eq, smul_zero] zero_smul := fun f => by obtain ⟨f, rfl⟩ := (functor r).map_surjective f dsimp rw [zero_smul, Functor.map_zero] one_smul := fun f => by obtain ⟨f, rfl⟩ := (functor r).map_surjective f dsimp rw [one_smul] mul_smul := fun a b f => by obtain ⟨f, rfl⟩ := (functor r).map_surjective f dsimp rw [mul_smul] smul_add := fun a f g => by obtain ⟨f, rfl⟩ := (functor r).map_surjective f obtain ⟨g, rfl⟩ := (functor r).map_surjective g dsimp rw [← (functor r).map_add, smul_eq, ← (functor r).map_add, smul_add] add_smul := fun a b f => by obtain ⟨f, rfl⟩ := (functor r).map_surjective f dsimp rw [add_smul, Functor.map_add] } /-- Auxiliary definition for `Quotient.linear`. -/ def module (hr : ∀ (a : R) ⦃X Y : C⦄ (f₁ f₂ : X ⟶ Y) (_ : r f₁ f₂), r (a • f₁) (a • f₂)) [Preadditive (Quotient r)] [(functor r).Additive] (X Y : Quotient r) : Module R (X ⟶ Y) := module' r hr X.as Y.as end Linear variable (R) /-- Assuming `Quotient r` has already been endowed with a preadditive category structure such that `functor r : C ⥤ Quotient r` is additive, and that `C` has a `R`-linear category structure compatible with `r`, this is the induced `R`-linear category structure on `Quotient r`. -/ def linear (hr : ∀ (a : R) ⦃X Y : C⦄ (f₁ f₂ : X ⟶ Y) (_ : r f₁ f₂), r (a • f₁) (a • f₂)) [Preadditive (Quotient r)] [(functor r).Additive] : Linear R (Quotient r) := by letI := Linear.module r hr exact { smul_comp := by rintro ⟨X⟩ ⟨Y⟩ ⟨Z⟩ a f g obtain ⟨f, rfl⟩ := (functor r).map_surjective f obtain ⟨g, rfl⟩ := (functor r).map_surjective g rw [Linear.smul_eq, ← Functor.map_comp, ← Functor.map_comp, Linear.smul_eq, Linear.smul_comp] comp_smul := by rintro ⟨X⟩ ⟨Y⟩ ⟨Z⟩ f a g obtain ⟨f, rfl⟩ := (functor r).map_surjective f obtain ⟨g, rfl⟩ := (functor r).map_surjective g rw [Linear.smul_eq, ← Functor.map_comp, ← Functor.map_comp, Linear.smul_eq, Linear.comp_smul] } instance linear_functor (hr : ∀ (a : R) ⦃X Y : C⦄ (f₁ f₂ : X ⟶ Y) (_ : r f₁ f₂), r (a • f₁) (a • f₂)) [Preadditive (Quotient r)] [(functor r).Additive] : letI := linear R r hr; Functor.Linear R (functor r) := by letI := linear R r hr; exact { } end Quotient end CategoryTheory
CategoryTheory\Quotient\Preadditive.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.Quotient import Mathlib.CategoryTheory.Preadditive.AdditiveFunctor /-! # The quotient category is preadditive If an equivalence relation `r : HomRel C` on the morphisms of a preadditive category is compatible with the addition, then the quotient category `Quotient r` is also preadditive. -/ namespace CategoryTheory namespace Quotient variable {C : Type _} [Category C] [Preadditive C] (r : HomRel C) [Congruence r] namespace Preadditive /-- The addition on the morphisms in the category `Quotient r` when `r` is compatible with the addition. -/ def add (hr : ∀ ⦃X Y : C⦄ (f₁ f₂ g₁ g₂ : X ⟶ Y) (_ : r f₁ f₂) (_ : r g₁ g₂), r (f₁ + g₁) (f₂ + g₂)) {X Y : Quotient r} (f g : X ⟶ Y) : X ⟶ Y := Quot.liftOn₂ f g (fun a b => Quot.mk _ (a + b)) (fun f g₁ g₂ h₁₂ => by simp only [compClosure_iff_self] at h₁₂ erw [functor_map_eq_iff] exact hr _ _ _ _ (Congruence.equivalence.refl f) h₁₂) (fun f₁ f₂ g h₁₂ => by simp only [compClosure_iff_self] at h₁₂ erw [functor_map_eq_iff] exact hr _ _ _ _ h₁₂ (Congruence.equivalence.refl g)) /-- The negation on the morphisms in the category `Quotient r` when `r` is compatible with the addition. -/ def neg (hr : ∀ ⦃X Y : C⦄ (f₁ f₂ g₁ g₂ : X ⟶ Y) (_ : r f₁ f₂) (_ : r g₁ g₂), r (f₁ + g₁) (f₂ + g₂)) {X Y : Quotient r} (f : X ⟶ Y) : X ⟶ Y := Quot.liftOn f (fun a => Quot.mk _ (-a)) (fun f g => by intro hfg simp only [compClosure_iff_self] at hfg erw [functor_map_eq_iff] apply Congruence.equivalence.symm convert hr f g _ _ hfg (Congruence.equivalence.refl (-f-g)) using 1 <;> abel) end Preadditive /-- The preadditive structure on the category `Quotient r` when `r` is compatible with the addition. -/ def preadditive (hr : ∀ ⦃X Y : C⦄ (f₁ f₂ g₁ g₂ : X ⟶ Y) (_ : r f₁ f₂) (_ : r g₁ g₂), r (f₁ + g₁) (f₂ + g₂)) : Preadditive (Quotient r) where homGroup P Q := let iZ : Zero (P ⟶ Q) := { zero := Quot.mk _ 0 } let iA : Add (P ⟶ Q) := { add := Preadditive.add r hr } let iN : Neg (P ⟶ Q) := { neg := Preadditive.neg r hr } { add_assoc := by rintro ⟨_⟩ ⟨_⟩ ⟨_⟩; exact congr_arg (functor r).map (add_assoc _ _ _) zero_add := by rintro ⟨_⟩; exact congr_arg (functor r).map (zero_add _) add_zero := by rintro ⟨_⟩; exact congr_arg (functor r).map (add_zero _) add_comm := by rintro ⟨_⟩ ⟨_⟩; exact congr_arg (functor r).map (add_comm _ _) add_left_neg := by rintro ⟨_⟩; exact congr_arg (functor r).map (add_left_neg _) -- todo: use a better defeq nsmul := nsmulRec zsmul := zsmulRec } add_comp := by rintro _ _ _ ⟨_⟩ ⟨_⟩ ⟨_⟩ exact congr_arg (functor r).map (by apply Preadditive.add_comp) comp_add := by rintro _ _ _ ⟨_⟩ ⟨_⟩ ⟨_⟩ exact congr_arg (functor r).map (by apply Preadditive.comp_add) lemma functor_additive (hr : ∀ ⦃X Y : C⦄ (f₁ f₂ g₁ g₂ : X ⟶ Y) (_ : r f₁ f₂) (_ : r g₁ g₂), r (f₁ + g₁) (f₂ + g₂)) : letI := preadditive r hr (functor r).Additive := letI := preadditive r hr { map_add := rfl } end Quotient end CategoryTheory
CategoryTheory\Shift\Basic.lean
/- Copyright (c) 2020 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison, Johan Commelin, Andrew Yang -/ import Mathlib.Algebra.Group.Basic import Mathlib.CategoryTheory.Limits.Preserves.Shapes.Zero import Mathlib.CategoryTheory.Monoidal.End import Mathlib.CategoryTheory.Monoidal.Discrete /-! # Shift A `Shift` on a category `C` indexed by a monoid `A` is nothing more than a monoidal functor from `A` to `C ⥤ C`. A typical example to keep in mind might be the category of complexes `⋯ → C_{n-1} → C_n → C_{n+1} → ⋯`. It has a shift indexed by `ℤ`, where we assign to each `n : ℤ` the functor `C ⥤ C` that re-indexes the terms, so the degree `i` term of `Shift n C` would be the degree `i+n`-th term of `C`. ## Main definitions * `HasShift`: A typeclass asserting the existence of a shift functor. * `shiftEquiv`: When the indexing monoid is a group, then the functor indexed by `n` and `-n` forms a self-equivalence of `C`. * `shiftComm`: When the indexing monoid is commutative, then shifts commute as well. ## Implementation Notes `[HasShift C A]` is implemented using `MonoidalFunctor (Discrete A) (C ⥤ C)`. However, the API of monoidal functors is used only internally: one should use the API of shifts functors which includes `shiftFunctor C a : C ⥤ C` for `a : A`, `shiftFunctorZero C A : shiftFunctor C (0 : A) ≅ 𝟭 C` and `shiftFunctorAdd C i j : shiftFunctor C (i + j) ≅ shiftFunctor C i ⋙ shiftFunctor C j` (and its variant `shiftFunctorAdd'`). These isomorphisms satisfy some coherence properties which are stated in lemmas like `shiftFunctorAdd'_assoc`, `shiftFunctorAdd'_zero_add` and `shiftFunctorAdd'_add_zero`. -/ namespace CategoryTheory noncomputable section universe v u variable (C : Type u) (A : Type*) [Category.{v} C] attribute [local instance] endofunctorMonoidalCategory variable {A C} section Defs variable (A C) [AddMonoid A] /-- A category has a shift indexed by an additive monoid `A` if there is a monoidal functor from `A` to `C ⥤ C`. -/ class HasShift (C : Type u) (A : Type*) [Category.{v} C] [AddMonoid A] where /-- a shift is a monoidal functor from `A` to `C ⥤ C` -/ shift : MonoidalFunctor (Discrete A) (C ⥤ C) -- porting note (#5171): removed @[nolint has_nonempty_instance] /-- A helper structure to construct the shift functor `(Discrete A) ⥤ (C ⥤ C)`. -/ structure ShiftMkCore where /-- the family of shift functors -/ F : A → C ⥤ C /-- the shift by 0 identifies to the identity functor -/ zero : F 0 ≅ 𝟭 C /-- the composition of shift functors identifies to the shift by the sum -/ add : ∀ n m : A, F (n + m) ≅ F n ⋙ F m /-- compatibility with the associativity -/ assoc_hom_app : ∀ (m₁ m₂ m₃ : A) (X : C), (add (m₁ + m₂) m₃).hom.app X ≫ (F m₃).map ((add m₁ m₂).hom.app X) = eqToHom (by rw [add_assoc]) ≫ (add m₁ (m₂ + m₃)).hom.app X ≫ (add m₂ m₃).hom.app ((F m₁).obj X) := by aesop_cat /-- compatibility with the left addition with 0 -/ zero_add_hom_app : ∀ (n : A) (X : C), (add 0 n).hom.app X = eqToHom (by dsimp; rw [zero_add]) ≫ (F n).map (zero.inv.app X) := by aesop_cat /-- compatibility with the right addition with 0 -/ add_zero_hom_app : ∀ (n : A) (X : C), (add n 0).hom.app X = eqToHom (by dsimp; rw [add_zero]) ≫ zero.inv.app ((F n).obj X) := by aesop_cat namespace ShiftMkCore variable {C A} attribute [reassoc] assoc_hom_app @[reassoc] lemma assoc_inv_app (h : ShiftMkCore C A) (m₁ m₂ m₃ : A) (X : C) : (h.F m₃).map ((h.add m₁ m₂).inv.app X) ≫ (h.add (m₁ + m₂) m₃).inv.app X = (h.add m₂ m₃).inv.app ((h.F m₁).obj X) ≫ (h.add m₁ (m₂ + m₃)).inv.app X ≫ eqToHom (by rw [add_assoc]) := by rw [← cancel_mono ((h.add (m₁ + m₂) m₃).hom.app X ≫ (h.F m₃).map ((h.add m₁ m₂).hom.app X)), Category.assoc, Category.assoc, Category.assoc, Iso.inv_hom_id_app_assoc, ← Functor.map_comp, Iso.inv_hom_id_app, Functor.map_id, h.assoc_hom_app, eqToHom_trans_assoc, eqToHom_refl, Category.id_comp, Iso.inv_hom_id_app_assoc, Iso.inv_hom_id_app] rfl lemma zero_add_inv_app (h : ShiftMkCore C A) (n : A) (X : C) : (h.add 0 n).inv.app X = (h.F n).map (h.zero.hom.app X) ≫ eqToHom (by dsimp; rw [zero_add]) := by rw [← cancel_epi ((h.add 0 n).hom.app X), Iso.hom_inv_id_app, h.zero_add_hom_app, Category.assoc, ← Functor.map_comp_assoc, Iso.inv_hom_id_app, Functor.map_id, Category.id_comp, eqToHom_trans, eqToHom_refl] lemma add_zero_inv_app (h : ShiftMkCore C A) (n : A) (X : C) : (h.add n 0).inv.app X = h.zero.hom.app ((h.F n).obj X) ≫ eqToHom (by dsimp; rw [add_zero]) := by rw [← cancel_epi ((h.add n 0).hom.app X), Iso.hom_inv_id_app, h.add_zero_hom_app, Category.assoc, Iso.inv_hom_id_app_assoc, eqToHom_trans, eqToHom_refl] end ShiftMkCore section attribute [local simp] eqToHom_map /-- Constructs a `HasShift C A` instance from `ShiftMkCore`. -/ @[simps] def hasShiftMk (h : ShiftMkCore C A) : HasShift C A := ⟨{ Discrete.functor h.F with ε := h.zero.inv μ := fun m n => (h.add m.as n.as).inv μ_natural_left := by rintro ⟨X⟩ ⟨Y⟩ ⟨⟨⟨rfl⟩⟩⟩ ⟨X'⟩ ext dsimp simp μ_natural_right := by rintro ⟨X⟩ ⟨Y⟩ ⟨X'⟩ ⟨⟨⟨rfl⟩⟩⟩ ext dsimp simp associativity := by rintro ⟨m₁⟩ ⟨m₂⟩ ⟨m₃⟩ ext X simp [endofunctorMonoidalCategory, h.assoc_inv_app_assoc] left_unitality := by rintro ⟨n⟩ ext X simp [endofunctorMonoidalCategory, h.zero_add_inv_app, ← Functor.map_comp] right_unitality := by rintro ⟨n⟩ ext X simp [endofunctorMonoidalCategory, h.add_zero_inv_app]}⟩ end section variable [HasShift C A] /-- The monoidal functor from `A` to `C ⥤ C` given a `HasShift` instance. -/ def shiftMonoidalFunctor : MonoidalFunctor (Discrete A) (C ⥤ C) := HasShift.shift variable {A} /-- The shift autoequivalence, moving objects and morphisms 'up'. -/ def shiftFunctor (i : A) : C ⥤ C := (shiftMonoidalFunctor C A).obj ⟨i⟩ /-- Shifting by `i + j` is the same as shifting by `i` and then shifting by `j`. -/ def shiftFunctorAdd (i j : A) : shiftFunctor C (i + j) ≅ shiftFunctor C i ⋙ shiftFunctor C j := ((shiftMonoidalFunctor C A).μIso ⟨i⟩ ⟨j⟩).symm /-- When `k = i + j`, shifting by `k` is the same as shifting by `i` and then shifting by `j`. -/ def shiftFunctorAdd' (i j k : A) (h : i + j = k) : shiftFunctor C k ≅ shiftFunctor C i ⋙ shiftFunctor C j := eqToIso (by rw [h]) ≪≫ shiftFunctorAdd C i j lemma shiftFunctorAdd'_eq_shiftFunctorAdd (i j : A) : shiftFunctorAdd' C i j (i+j) rfl = shiftFunctorAdd C i j := by ext1 apply Category.id_comp variable (A) in /-- Shifting by zero is the identity functor. -/ def shiftFunctorZero : shiftFunctor C (0 : A) ≅ 𝟭 C := (shiftMonoidalFunctor C A).εIso.symm /-- Shifting by `a` such that `a = 0` identifies to the identity functor. -/ def shiftFunctorZero' (a : A) (ha : a = 0) : shiftFunctor C a ≅ 𝟭 C := eqToIso (by rw [ha]) ≪≫ shiftFunctorZero C A end variable {C A} lemma ShiftMkCore.shiftFunctor_eq (h : ShiftMkCore C A) (a : A) : letI := hasShiftMk C A h shiftFunctor C a = h.F a := by rfl lemma ShiftMkCore.shiftFunctorZero_eq (h : ShiftMkCore C A) : letI := hasShiftMk C A h shiftFunctorZero C A = h.zero := by letI := hasShiftMk C A h dsimp [shiftFunctorZero] change (shiftFunctorZero C A).symm.symm = h.zero.symm.symm congr 1 ext rfl lemma ShiftMkCore.shiftFunctorAdd_eq (h : ShiftMkCore C A) (a b : A) : letI := hasShiftMk C A h shiftFunctorAdd C a b = h.add a b := by letI := hasShiftMk C A h change (shiftFunctorAdd C a b).symm.symm = (h.add a b).symm.symm congr 1 ext rfl set_option quotPrecheck false in /-- shifting an object `X` by `n` is obtained by the notation `X⟦n⟧` -/ notation -- Any better notational suggestions? X "⟦" n "⟧" => (shiftFunctor _ n).obj X set_option quotPrecheck false in /-- shifting a morphism `f` by `n` is obtained by the notation `f⟦n⟧'` -/ notation f "⟦" n "⟧'" => (shiftFunctor _ n).map f variable (C) variable [HasShift C A] lemma shiftFunctorAdd'_zero_add (a : A) : shiftFunctorAdd' C 0 a a (zero_add a) = (Functor.leftUnitor _).symm ≪≫ isoWhiskerRight (shiftFunctorZero C A).symm (shiftFunctor C a) := by ext X dsimp [shiftFunctorAdd', shiftFunctorZero, shiftFunctor] simp only [eqToHom_app, obj_ε_app, Discrete.addMonoidal_leftUnitor, eqToIso.inv, eqToHom_map, Category.id_comp] rfl lemma shiftFunctorAdd'_add_zero (a : A) : shiftFunctorAdd' C a 0 a (add_zero a) = (Functor.rightUnitor _).symm ≪≫ isoWhiskerLeft (shiftFunctor C a) (shiftFunctorZero C A).symm := by ext dsimp [shiftFunctorAdd', shiftFunctorZero, shiftFunctor] simp only [eqToHom_app, ε_app_obj, Discrete.addMonoidal_rightUnitor, eqToIso.inv, eqToHom_map, Category.id_comp] rfl lemma shiftFunctorAdd'_assoc (a₁ a₂ a₃ a₁₂ a₂₃ a₁₂₃ : A) (h₁₂ : a₁ + a₂ = a₁₂) (h₂₃ : a₂ + a₃ = a₂₃) (h₁₂₃ : a₁ + a₂ + a₃ = a₁₂₃) : shiftFunctorAdd' C a₁₂ a₃ a₁₂₃ (by rw [← h₁₂, h₁₂₃]) ≪≫ isoWhiskerRight (shiftFunctorAdd' C a₁ a₂ a₁₂ h₁₂) _ ≪≫ Functor.associator _ _ _ = shiftFunctorAdd' C a₁ a₂₃ a₁₂₃ (by rw [← h₂₃, ← add_assoc, h₁₂₃]) ≪≫ isoWhiskerLeft _ (shiftFunctorAdd' C a₂ a₃ a₂₃ h₂₃) := by subst h₁₂ h₂₃ h₁₂₃ ext X dsimp simp only [shiftFunctorAdd'_eq_shiftFunctorAdd, Category.comp_id] dsimp [shiftFunctorAdd'] simp only [eqToHom_app] dsimp [shiftFunctorAdd, shiftFunctor] simp only [obj_μ_inv_app, Discrete.addMonoidal_associator, eqToIso.hom, eqToHom_map, eqToHom_app] erw [Iso.inv_hom_id_app_assoc, Category.assoc] rfl lemma shiftFunctorAdd_assoc (a₁ a₂ a₃ : A) : shiftFunctorAdd C (a₁ + a₂) a₃ ≪≫ isoWhiskerRight (shiftFunctorAdd C a₁ a₂) _ ≪≫ Functor.associator _ _ _ = shiftFunctorAdd' C a₁ (a₂ + a₃) _ (add_assoc a₁ a₂ a₃).symm ≪≫ isoWhiskerLeft _ (shiftFunctorAdd C a₂ a₃) := by ext X simpa [shiftFunctorAdd'_eq_shiftFunctorAdd] using NatTrans.congr_app (congr_arg Iso.hom (shiftFunctorAdd'_assoc C a₁ a₂ a₃ _ _ _ rfl rfl rfl)) X variable {C} lemma shiftFunctorAdd'_zero_add_hom_app (a : A) (X : C) : (shiftFunctorAdd' C 0 a a (zero_add a)).hom.app X = ((shiftFunctorZero C A).inv.app X)⟦a⟧' := by simpa using NatTrans.congr_app (congr_arg Iso.hom (shiftFunctorAdd'_zero_add C a)) X lemma shiftFunctorAdd_zero_add_hom_app (a : A) (X : C) : (shiftFunctorAdd C 0 a).hom.app X = eqToHom (by dsimp; rw [zero_add]) ≫ ((shiftFunctorZero C A).inv.app X)⟦a⟧' := by simp [← shiftFunctorAdd'_zero_add_hom_app, shiftFunctorAdd'] lemma shiftFunctorAdd'_zero_add_inv_app (a : A) (X : C) : (shiftFunctorAdd' C 0 a a (zero_add a)).inv.app X = ((shiftFunctorZero C A).hom.app X)⟦a⟧' := by simpa using NatTrans.congr_app (congr_arg Iso.inv (shiftFunctorAdd'_zero_add C a)) X lemma shiftFunctorAdd_zero_add_inv_app (a : A) (X : C) : (shiftFunctorAdd C 0 a).inv.app X = ((shiftFunctorZero C A).hom.app X)⟦a⟧' ≫ eqToHom (by dsimp; rw [zero_add]) := by simp [← shiftFunctorAdd'_zero_add_inv_app, shiftFunctorAdd'] lemma shiftFunctorAdd'_add_zero_hom_app (a : A) (X : C) : (shiftFunctorAdd' C a 0 a (add_zero a)).hom.app X = (shiftFunctorZero C A).inv.app (X⟦a⟧) := by simpa using NatTrans.congr_app (congr_arg Iso.hom (shiftFunctorAdd'_add_zero C a)) X lemma shiftFunctorAdd_add_zero_hom_app (a : A) (X : C) : (shiftFunctorAdd C a 0).hom.app X = eqToHom (by dsimp; rw [add_zero]) ≫ (shiftFunctorZero C A).inv.app (X⟦a⟧) := by simp [← shiftFunctorAdd'_add_zero_hom_app, shiftFunctorAdd'] lemma shiftFunctorAdd'_add_zero_inv_app (a : A) (X : C) : (shiftFunctorAdd' C a 0 a (add_zero a)).inv.app X = (shiftFunctorZero C A).hom.app (X⟦a⟧) := by simpa using NatTrans.congr_app (congr_arg Iso.inv (shiftFunctorAdd'_add_zero C a)) X lemma shiftFunctorAdd_add_zero_inv_app (a : A) (X : C) : (shiftFunctorAdd C a 0).inv.app X = (shiftFunctorZero C A).hom.app (X⟦a⟧) ≫ eqToHom (by dsimp; rw [add_zero]) := by simp [← shiftFunctorAdd'_add_zero_inv_app, shiftFunctorAdd'] @[reassoc] lemma shiftFunctorAdd'_assoc_hom_app (a₁ a₂ a₃ a₁₂ a₂₃ a₁₂₃ : A) (h₁₂ : a₁ + a₂ = a₁₂) (h₂₃ : a₂ + a₃ = a₂₃) (h₁₂₃ : a₁ + a₂ + a₃ = a₁₂₃) (X : C) : (shiftFunctorAdd' C a₁₂ a₃ a₁₂₃ (by rw [← h₁₂, h₁₂₃])).hom.app X ≫ ((shiftFunctorAdd' C a₁ a₂ a₁₂ h₁₂).hom.app X)⟦a₃⟧' = (shiftFunctorAdd' C a₁ a₂₃ a₁₂₃ (by rw [← h₂₃, ← add_assoc, h₁₂₃])).hom.app X ≫ (shiftFunctorAdd' C a₂ a₃ a₂₃ h₂₃).hom.app (X⟦a₁⟧) := by simpa using NatTrans.congr_app (congr_arg Iso.hom (shiftFunctorAdd'_assoc C _ _ _ _ _ _ h₁₂ h₂₃ h₁₂₃)) X @[reassoc] lemma shiftFunctorAdd'_assoc_inv_app (a₁ a₂ a₃ a₁₂ a₂₃ a₁₂₃ : A) (h₁₂ : a₁ + a₂ = a₁₂) (h₂₃ : a₂ + a₃ = a₂₃) (h₁₂₃ : a₁ + a₂ + a₃ = a₁₂₃) (X : C) : ((shiftFunctorAdd' C a₁ a₂ a₁₂ h₁₂).inv.app X)⟦a₃⟧' ≫ (shiftFunctorAdd' C a₁₂ a₃ a₁₂₃ (by rw [← h₁₂, h₁₂₃])).inv.app X = (shiftFunctorAdd' C a₂ a₃ a₂₃ h₂₃).inv.app (X⟦a₁⟧) ≫ (shiftFunctorAdd' C a₁ a₂₃ a₁₂₃ (by rw [← h₂₃, ← add_assoc, h₁₂₃])).inv.app X := by simpa using NatTrans.congr_app (congr_arg Iso.inv (shiftFunctorAdd'_assoc C _ _ _ _ _ _ h₁₂ h₂₃ h₁₂₃)) X @[reassoc] lemma shiftFunctorAdd_assoc_hom_app (a₁ a₂ a₃ : A) (X : C) : (shiftFunctorAdd C (a₁ + a₂) a₃).hom.app X ≫ ((shiftFunctorAdd C a₁ a₂).hom.app X)⟦a₃⟧' = (shiftFunctorAdd' C a₁ (a₂ + a₃) (a₁ + a₂ + a₃) (add_assoc _ _ _).symm).hom.app X ≫ (shiftFunctorAdd C a₂ a₃).hom.app (X⟦a₁⟧) := by simpa using NatTrans.congr_app (congr_arg Iso.hom (shiftFunctorAdd_assoc C a₁ a₂ a₃)) X @[reassoc] lemma shiftFunctorAdd_assoc_inv_app (a₁ a₂ a₃ : A) (X : C) : ((shiftFunctorAdd C a₁ a₂).inv.app X)⟦a₃⟧' ≫ (shiftFunctorAdd C (a₁ + a₂) a₃).inv.app X = (shiftFunctorAdd C a₂ a₃).inv.app (X⟦a₁⟧) ≫ (shiftFunctorAdd' C a₁ (a₂ + a₃) (a₁ + a₂ + a₃) (add_assoc _ _ _).symm).inv.app X := by simpa using NatTrans.congr_app (congr_arg Iso.inv (shiftFunctorAdd_assoc C a₁ a₂ a₃)) X end Defs section AddMonoid variable [AddMonoid A] [HasShift C A] (X Y : C) (f : X ⟶ Y) @[simp] theorem HasShift.shift_obj_obj (n : A) (X : C) : (HasShift.shift.obj ⟨n⟩).obj X = X⟦n⟧ := rfl /-- Shifting by `i + j` is the same as shifting by `i` and then shifting by `j`. -/ abbrev shiftAdd (i j : A) : X⟦i + j⟧ ≅ X⟦i⟧⟦j⟧ := (shiftFunctorAdd C i j).app _ theorem shift_shift' (i j : A) : f⟦i⟧'⟦j⟧' = (shiftAdd X i j).inv ≫ f⟦i + j⟧' ≫ (shiftAdd Y i j).hom := by symm rw [← Functor.comp_map, NatIso.app_inv] apply NatIso.naturality_1 variable (A) /-- Shifting by zero is the identity functor. -/ abbrev shiftZero : X⟦(0 : A)⟧ ≅ X := (shiftFunctorZero C A).app _ theorem shiftZero' : f⟦(0 : A)⟧' = (shiftZero A X).hom ≫ f ≫ (shiftZero A Y).inv := by symm rw [NatIso.app_inv, NatIso.app_hom] apply NatIso.naturality_2 variable (C) {A} /-- When `i + j = 0`, shifting by `i` and by `j` gives the identity functor -/ def shiftFunctorCompIsoId (i j : A) (h : i + j = 0) : shiftFunctor C i ⋙ shiftFunctor C j ≅ 𝟭 C := (shiftFunctorAdd' C i j 0 h).symm ≪≫ shiftFunctorZero C A end AddMonoid section AddGroup variable (C) variable [AddGroup A] [HasShift C A] /-- Shifting by `i` and shifting by `j` forms an equivalence when `i + j = 0`. -/ @[simps] def shiftEquiv' (i j : A) (h : i + j = 0) : C ≌ C where functor := shiftFunctor C i inverse := shiftFunctor C j unitIso := (shiftFunctorCompIsoId C i j h).symm counitIso := shiftFunctorCompIsoId C j i (by rw [← add_left_inj j, add_assoc, h, zero_add, add_zero]) functor_unitIso_comp X := by convert (equivOfTensorIsoUnit (shiftMonoidalFunctor C A) ⟨i⟩ ⟨j⟩ (Discrete.eqToIso h) (Discrete.eqToIso (by dsimp; rw [← add_left_inj j, add_assoc, h, zero_add, add_zero])) (Subsingleton.elim _ _)).functor_unitIso_comp X all_goals ext X dsimp [shiftFunctorCompIsoId, unitOfTensorIsoUnit, shiftFunctorAdd'] simp only [Category.assoc, eqToHom_map] rfl /-- Shifting by `n` and shifting by `-n` forms an equivalence. -/ abbrev shiftEquiv (n : A) : C ≌ C := shiftEquiv' C n (-n) (add_neg_self n) variable (X Y : C) (f : X ⟶ Y) /-- Shifting by `i` is an equivalence. -/ instance (i : A) : (shiftFunctor C i).IsEquivalence := by change (shiftEquiv C i).functor.IsEquivalence infer_instance variable {C} /-- Shifting by `i` and then shifting by `-i` is the identity. -/ abbrev shiftShiftNeg (i : A) : X⟦i⟧⟦-i⟧ ≅ X := (shiftEquiv C i).unitIso.symm.app X /-- Shifting by `-i` and then shifting by `i` is the identity. -/ abbrev shiftNegShift (i : A) : X⟦-i⟧⟦i⟧ ≅ X := (shiftEquiv C i).counitIso.app X variable {X Y} theorem shift_shift_neg' (i : A) : f⟦i⟧'⟦-i⟧' = (shiftFunctorCompIsoId C i (-i) (add_neg_self i)).hom.app X ≫ f ≫ (shiftFunctorCompIsoId C i (-i) (add_neg_self i)).inv.app Y := (NatIso.naturality_2 (shiftFunctorCompIsoId C i (-i) (add_neg_self i)) f).symm theorem shift_neg_shift' (i : A) : f⟦-i⟧'⟦i⟧' = (shiftFunctorCompIsoId C (-i) i (neg_add_self i)).hom.app X ≫ f ≫ (shiftFunctorCompIsoId C (-i) i (neg_add_self i)).inv.app Y := (NatIso.naturality_2 (shiftFunctorCompIsoId C (-i) i (neg_add_self i)) f).symm theorem shift_equiv_triangle (n : A) (X : C) : (shiftShiftNeg X n).inv⟦n⟧' ≫ (shiftNegShift (X⟦n⟧) n).hom = 𝟙 (X⟦n⟧) := (shiftEquiv C n).functor_unitIso_comp X section theorem shift_shiftFunctorCompIsoId_hom_app (n m : A) (h : n + m = 0) (X : C) : ((shiftFunctorCompIsoId C n m h).hom.app X)⟦n⟧' = (shiftFunctorCompIsoId C m n (by rw [← neg_eq_of_add_eq_zero_left h, add_right_neg])).hom.app (X⟦n⟧) := by dsimp [shiftFunctorCompIsoId] simpa only [Functor.map_comp, ← shiftFunctorAdd'_zero_add_inv_app n X, ← shiftFunctorAdd'_add_zero_inv_app n X] using shiftFunctorAdd'_assoc_inv_app n m n 0 0 n h (by rw [← neg_eq_of_add_eq_zero_left h, add_right_neg]) (by rw [h, zero_add]) X theorem shift_shiftFunctorCompIsoId_inv_app (n m : A) (h : n + m = 0) (X : C) : ((shiftFunctorCompIsoId C n m h).inv.app X)⟦n⟧' = ((shiftFunctorCompIsoId C m n (by rw [← neg_eq_of_add_eq_zero_left h, add_right_neg])).inv.app (X⟦n⟧)) := by rw [← cancel_mono (((shiftFunctorCompIsoId C n m h).hom.app X)⟦n⟧'), ← Functor.map_comp, Iso.inv_hom_id_app, Functor.map_id, shift_shiftFunctorCompIsoId_hom_app, Iso.inv_hom_id_app] rfl theorem shift_shiftFunctorCompIsoId_add_neg_self_hom_app (n : A) (X : C) : ((shiftFunctorCompIsoId C n (-n) (add_neg_self n)).hom.app X)⟦n⟧' = (shiftFunctorCompIsoId C (-n) n (neg_add_self n)).hom.app (X⟦n⟧) := by apply shift_shiftFunctorCompIsoId_hom_app theorem shift_shiftFunctorCompIsoId_add_neg_self_inv_app (n : A) (X : C) : ((shiftFunctorCompIsoId C n (-n) (add_neg_self n)).inv.app X)⟦n⟧' = (shiftFunctorCompIsoId C (-n) n (neg_add_self n)).inv.app (X⟦n⟧) := by apply shift_shiftFunctorCompIsoId_inv_app theorem shift_shiftFunctorCompIsoId_neg_add_self_hom_app (n : A) (X : C) : ((shiftFunctorCompIsoId C (-n) n (neg_add_self n)).hom.app X)⟦-n⟧' = (shiftFunctorCompIsoId C n (-n) (add_neg_self n)).hom.app (X⟦-n⟧) := by apply shift_shiftFunctorCompIsoId_hom_app theorem shift_shiftFunctorCompIsoId_neg_add_self_inv_app (n : A) (X : C) : ((shiftFunctorCompIsoId C (-n) n (neg_add_self n)).inv.app X)⟦-n⟧' = (shiftFunctorCompIsoId C n (-n) (add_neg_self n)).inv.app (X⟦-n⟧) := by apply shift_shiftFunctorCompIsoId_inv_app end open CategoryTheory.Limits variable [HasZeroMorphisms C] theorem shift_zero_eq_zero (X Y : C) (n : A) : (0 : X ⟶ Y)⟦n⟧' = (0 : X⟦n⟧ ⟶ Y⟦n⟧) := CategoryTheory.Functor.map_zero _ _ _ end AddGroup section AddCommMonoid variable [AddCommMonoid A] [HasShift C A] variable (C) /-- When shifts are indexed by an additive commutative monoid, then shifts commute. -/ def shiftFunctorComm (i j : A) : shiftFunctor C i ⋙ shiftFunctor C j ≅ shiftFunctor C j ⋙ shiftFunctor C i := (shiftFunctorAdd C i j).symm ≪≫ shiftFunctorAdd' C j i (i + j) (add_comm j i) lemma shiftFunctorComm_eq (i j k : A) (h : i + j = k) : shiftFunctorComm C i j = (shiftFunctorAdd' C i j k h).symm ≪≫ shiftFunctorAdd' C j i k (by rw [add_comm j i, h]) := by subst h rw [shiftFunctorAdd'_eq_shiftFunctorAdd] rfl @[simp] lemma shiftFunctorComm_eq_refl (i : A) : shiftFunctorComm C i i = Iso.refl _ := by rw [shiftFunctorComm_eq C i i (i + i) rfl, Iso.symm_self_id] lemma shiftFunctorComm_symm (i j : A) : (shiftFunctorComm C i j).symm = shiftFunctorComm C j i := by ext1 dsimp rw [shiftFunctorComm_eq C i j (i+j) rfl, shiftFunctorComm_eq C j i (i+j) (add_comm j i)] rfl variable {C} variable (X Y : C) (f : X ⟶ Y) /-- When shifts are indexed by an additive commutative monoid, then shifts commute. -/ abbrev shiftComm (i j : A) : X⟦i⟧⟦j⟧ ≅ X⟦j⟧⟦i⟧ := (shiftFunctorComm C i j).app X @[simp] theorem shiftComm_symm (i j : A) : (shiftComm X i j).symm = shiftComm X j i := by ext exact NatTrans.congr_app (congr_arg Iso.hom (shiftFunctorComm_symm C i j)) X variable {X Y} /-- When shifts are indexed by an additive commutative monoid, then shifts commute. -/ theorem shiftComm' (i j : A) : f⟦i⟧'⟦j⟧' = (shiftComm _ _ _).hom ≫ f⟦j⟧'⟦i⟧' ≫ (shiftComm _ _ _).hom := by erw [← shiftComm_symm Y i j, ← ((shiftFunctorComm C i j).hom.naturality_assoc f)] dsimp simp only [Iso.hom_inv_id_app, Functor.comp_obj, Category.comp_id] @[reassoc] theorem shiftComm_hom_comp (i j : A) : (shiftComm X i j).hom ≫ f⟦j⟧'⟦i⟧' = f⟦i⟧'⟦j⟧' ≫ (shiftComm Y i j).hom := by rw [shiftComm', ← shiftComm_symm, Iso.symm_hom, Iso.inv_hom_id_assoc] lemma shiftFunctorZero_hom_app_shift (n : A) : (shiftFunctorZero C A).hom.app (X⟦n⟧) = (shiftFunctorComm C n 0).hom.app X ≫ ((shiftFunctorZero C A).hom.app X)⟦n⟧' := by rw [← shiftFunctorAdd'_zero_add_inv_app n X, shiftFunctorComm_eq C n 0 n (add_zero n)] dsimp rw [Category.assoc, Iso.hom_inv_id_app, Category.comp_id, shiftFunctorAdd'_add_zero_inv_app] lemma shiftFunctorZero_inv_app_shift (n : A) : (shiftFunctorZero C A).inv.app (X⟦n⟧) = ((shiftFunctorZero C A).inv.app X)⟦n⟧' ≫ (shiftFunctorComm C n 0).inv.app X := by rw [← cancel_mono ((shiftFunctorZero C A).hom.app (X⟦n⟧)), Category.assoc, Iso.inv_hom_id_app, shiftFunctorZero_hom_app_shift, Iso.inv_hom_id_app_assoc, ← Functor.map_comp, Iso.inv_hom_id_app] dsimp rw [Functor.map_id] lemma shiftFunctorComm_zero_hom_app (a : A) : (shiftFunctorComm C a 0).hom.app X = (shiftFunctorZero C A).hom.app (X⟦a⟧) ≫ ((shiftFunctorZero C A).inv.app X)⟦a⟧' := by simp only [shiftFunctorZero_hom_app_shift, Category.assoc, ← Functor.map_comp, Iso.hom_inv_id_app, Functor.map_id, Functor.comp_obj, Category.comp_id] @[reassoc] lemma shiftFunctorComm_hom_app_comp_shift_shiftFunctorAdd_hom_app (m₁ m₂ m₃ : A) (X : C) : (shiftFunctorComm C m₁ (m₂ + m₃)).hom.app X ≫ ((shiftFunctorAdd C m₂ m₃).hom.app X)⟦m₁⟧' = (shiftFunctorAdd C m₂ m₃).hom.app (X⟦m₁⟧) ≫ ((shiftFunctorComm C m₁ m₂).hom.app X)⟦m₃⟧' ≫ (shiftFunctorComm C m₁ m₃).hom.app (X⟦m₂⟧) := by rw [← cancel_mono ((shiftFunctorComm C m₁ m₃).inv.app (X⟦m₂⟧)), ← cancel_mono (((shiftFunctorComm C m₁ m₂).inv.app X)⟦m₃⟧')] simp only [Category.assoc, Iso.hom_inv_id_app] dsimp simp only [Category.id_comp, ← Functor.map_comp, Iso.hom_inv_id_app] dsimp simp only [Functor.map_id, Category.comp_id, shiftFunctorComm_eq C _ _ _ rfl, ← shiftFunctorAdd'_eq_shiftFunctorAdd] dsimp simp only [Category.assoc, Iso.hom_inv_id_app_assoc, Iso.inv_hom_id_app_assoc, ← Functor.map_comp, shiftFunctorAdd'_assoc_hom_app_assoc m₂ m₃ m₁ (m₂ + m₃) (m₁ + m₃) (m₁ + (m₂ + m₃)) rfl (add_comm m₃ m₁) (add_comm _ m₁) X, ← shiftFunctorAdd'_assoc_hom_app_assoc m₂ m₁ m₃ (m₁ + m₂) (m₁ + m₃) (m₁ + (m₂ + m₃)) (add_comm _ _) rfl (by rw [add_comm m₂ m₁, add_assoc]) X, shiftFunctorAdd'_assoc_hom_app m₁ m₂ m₃ (m₁ + m₂) (m₂ + m₃) (m₁ + (m₂ + m₃)) rfl rfl (add_assoc _ _ _) X] end AddCommMonoid namespace Functor.FullyFaithful variable {D : Type*} [Category D] [AddMonoid A] [HasShift D A] variable {F : C ⥤ D} (hF : F.FullyFaithful) variable (s : A → C ⥤ C) (i : ∀ i, s i ⋙ F ≅ F ⋙ shiftFunctor D i) namespace hasShift /-- auxiliary definition for `FullyFaithful.hasShift` -/ def zero : s 0 ≅ 𝟭 C := (hF.whiskeringRight C).preimageIso ((i 0) ≪≫ isoWhiskerLeft F (shiftFunctorZero D A) ≪≫ Functor.rightUnitor _ ≪≫ (Functor.leftUnitor _).symm) @[simp] lemma map_zero_hom_app (X : C) : F.map ((zero hF s i).hom.app X) = (i 0).hom.app X ≫ (shiftFunctorZero D A).hom.app (F.obj X) := by simp [zero] @[simp] lemma map_zero_inv_app (X : C) : F.map ((zero hF s i).inv.app X) = (shiftFunctorZero D A).inv.app (F.obj X) ≫ (i 0).inv.app X := by simp [zero] /-- auxiliary definition for `FullyFaithful.hasShift` -/ def add (a b : A) : s (a + b) ≅ s a ⋙ s b := (hF.whiskeringRight C).preimageIso (i (a + b) ≪≫ isoWhiskerLeft _ (shiftFunctorAdd D a b) ≪≫ (Functor.associator _ _ _).symm ≪≫ (isoWhiskerRight (i a).symm _) ≪≫ Functor.associator _ _ _ ≪≫ (isoWhiskerLeft _ (i b).symm) ≪≫ (Functor.associator _ _ _).symm) @[simp] lemma map_add_hom_app (a b : A) (X : C) : F.map ((add hF s i a b).hom.app X) = (i (a + b)).hom.app X ≫ (shiftFunctorAdd D a b).hom.app (F.obj X) ≫ ((i a).inv.app X)⟦b⟧' ≫ (i b).inv.app ((s a).obj X) := by dsimp [add] simp @[simp] lemma map_add_inv_app (a b : A) (X : C) : F.map ((add hF s i a b).inv.app X) = (i b).hom.app ((s a).obj X) ≫ ((i a).hom.app X)⟦b⟧' ≫ (shiftFunctorAdd D a b).inv.app (F.obj X) ≫ (i (a + b)).inv.app X := by dsimp [add] simp end hasShift open hasShift in /-- Given a family of endomorphisms of `C` which are intertwined by a fully faithful `F : C ⥤ D` with shift functors on `D`, we can promote that family to shift functors on `C`. -/ def hasShift : HasShift C A := hasShiftMk C A { F := s zero := zero hF s i add := add hF s i assoc_hom_app := fun m₁ m₂ m₃ X => hF.map_injective (by have h := shiftFunctorAdd'_assoc_hom_app m₁ m₂ m₃ _ _ (m₁+m₂+m₃) rfl rfl rfl (F.obj X) simp only [shiftFunctorAdd'_eq_shiftFunctorAdd] at h rw [← cancel_mono ((i m₃).hom.app ((s m₂).obj ((s m₁).obj X)))] simp only [Functor.comp_obj, Functor.map_comp, map_add_hom_app, Category.assoc, Iso.inv_hom_id_app_assoc, NatTrans.naturality_assoc, Functor.comp_map, Iso.inv_hom_id_app, Category.comp_id] erw [(i m₃).hom.naturality] rw [Functor.comp_map, map_add_hom_app, Functor.map_comp, Functor.map_comp, Iso.inv_hom_id_app_assoc, ← Functor.map_comp_assoc _ ((i (m₁ + m₂)).inv.app X), Iso.inv_hom_id_app, Functor.map_id, Category.id_comp, reassoc_of% h, dcongr_arg (fun a => (i a).hom.app X) (add_assoc m₁ m₂ m₃)] simp [shiftFunctorAdd', eqToHom_map]) zero_add_hom_app := fun n X => hF.map_injective (by have this := dcongr_arg (fun a => (i a).hom.app X) (zero_add n) rw [← cancel_mono ((i n).hom.app ((s 0).obj X)) ] simp [this, map_add_hom_app, shiftFunctorAdd_zero_add_hom_app, eqToHom_map] congr 1 erw [(i n).hom.naturality] dsimp simp) add_zero_hom_app := fun n X => hF.map_injective (by have := dcongr_arg (fun a => (i a).hom.app X) (add_zero n) simp [this, ← NatTrans.naturality_assoc, eqToHom_map, shiftFunctorAdd_add_zero_hom_app]) } end Functor.FullyFaithful end end CategoryTheory
CategoryTheory\Shift\CommShift.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.Shift.Basic /-! # Functors which commute with shifts Let `C` and `D` be two categories equipped with shifts by an additive monoid `A`. In this file, we define the notion of functor `F : C ⥤ D` which "commutes" with these shifts. The associated type class is `[F.CommShift A]`. The data consists of commutation isomorphisms `F.commShiftIso a : shiftFunctor C a ⋙ F ≅ F ⋙ shiftFunctor D a` for all `a : A` which satisfy a compatibility with the addition and the zero. After this was formalised in Lean, it was found that this definition is exactly the definition which appears in Jean-Louis Verdier's thesis (I 1.2.3/1.2.4), although the language is different. (In Verdier's thesis, the shift is not given by a monoidal functor `Discrete A ⥤ C ⥤ C`, but by a fibred category `C ⥤ BA`, where `BA` is the category with one object, the endomorphisms of which identify to `A`. The choice of a cleavage for this fibered category gives the individual shift functors.) ## References * [Jean-Louis Verdier, *Des catégories dérivées des catégories abéliennes*][verdier1996] -/ namespace CategoryTheory open Category namespace Functor variable {C D E : Type*} [Category C] [Category D] [Category E] (F : C ⥤ D) (G : D ⥤ E) (A B : Type*) [AddMonoid A] [AddCommMonoid B] [HasShift C A] [HasShift D A] [HasShift E A] [HasShift C B] [HasShift D B] namespace CommShift /-- For any functor `F : C ⥤ D`, this is the obvious isomorphism `shiftFunctor C (0 : A) ⋙ F ≅ F ⋙ shiftFunctor D (0 : A)` deduced from the isomorphisms `shiftFunctorZero` on both categories `C` and `D`. -/ @[simps!] noncomputable def isoZero : shiftFunctor C (0 : A) ⋙ F ≅ F ⋙ shiftFunctor D (0 : A) := isoWhiskerRight (shiftFunctorZero C A) F ≪≫ F.leftUnitor ≪≫ F.rightUnitor.symm ≪≫ isoWhiskerLeft F (shiftFunctorZero D A).symm variable {F A} /-- If a functor `F : C ⥤ D` is equipped with "commutation isomorphisms" with the shifts by `a` and `b`, then there is a commutation isomorphism with the shift by `c` when `a + b = c`. -/ @[simps!] noncomputable def isoAdd' {a b c : A} (h : a + b = c) (e₁ : shiftFunctor C a ⋙ F ≅ F ⋙ shiftFunctor D a) (e₂ : shiftFunctor C b ⋙ F ≅ F ⋙ shiftFunctor D b) : shiftFunctor C c ⋙ F ≅ F ⋙ shiftFunctor D c := isoWhiskerRight (shiftFunctorAdd' C _ _ _ h) F ≪≫ Functor.associator _ _ _ ≪≫ isoWhiskerLeft _ e₂ ≪≫ (Functor.associator _ _ _).symm ≪≫ isoWhiskerRight e₁ _ ≪≫ Functor.associator _ _ _ ≪≫ isoWhiskerLeft _ (shiftFunctorAdd' D _ _ _ h).symm /-- If a functor `F : C ⥤ D` is equipped with "commutation isomorphisms" with the shifts by `a` and `b`, then there is a commutation isomorphism with the shift by `a + b`. -/ noncomputable def isoAdd {a b : A} (e₁ : shiftFunctor C a ⋙ F ≅ F ⋙ shiftFunctor D a) (e₂ : shiftFunctor C b ⋙ F ≅ F ⋙ shiftFunctor D b) : shiftFunctor C (a + b) ⋙ F ≅ F ⋙ shiftFunctor D (a + b) := CommShift.isoAdd' rfl e₁ e₂ @[simp] lemma isoAdd_hom_app {a b : A} (e₁ : shiftFunctor C a ⋙ F ≅ F ⋙ shiftFunctor D a) (e₂ : shiftFunctor C b ⋙ F ≅ F ⋙ shiftFunctor D b) (X : C) : (CommShift.isoAdd e₁ e₂).hom.app X = F.map ((shiftFunctorAdd C a b).hom.app X) ≫ e₂.hom.app ((shiftFunctor C a).obj X) ≫ (shiftFunctor D b).map (e₁.hom.app X) ≫ (shiftFunctorAdd D a b).inv.app (F.obj X) := by simp only [isoAdd, isoAdd'_hom_app, shiftFunctorAdd'_eq_shiftFunctorAdd] @[simp] lemma isoAdd_inv_app {a b : A} (e₁ : shiftFunctor C a ⋙ F ≅ F ⋙ shiftFunctor D a) (e₂ : shiftFunctor C b ⋙ F ≅ F ⋙ shiftFunctor D b) (X : C) : (CommShift.isoAdd e₁ e₂).inv.app X = (shiftFunctorAdd D a b).hom.app (F.obj X) ≫ (shiftFunctor D b).map (e₁.inv.app X) ≫ e₂.inv.app ((shiftFunctor C a).obj X) ≫ F.map ((shiftFunctorAdd C a b).inv.app X) := by simp only [isoAdd, isoAdd'_inv_app, shiftFunctorAdd'_eq_shiftFunctorAdd] end CommShift /-- A functor `F` commutes with the shift by a monoid `A` if it is equipped with commutation isomorphisms with the shifts by all `a : A`, and these isomorphisms satisfy coherence properties with respect to `0 : A` and the addition in `A`. -/ class CommShift where iso (a : A) : shiftFunctor C a ⋙ F ≅ F ⋙ shiftFunctor D a zero : iso 0 = CommShift.isoZero F A := by aesop_cat add (a b : A) : iso (a + b) = CommShift.isoAdd (iso a) (iso b) := by aesop_cat variable {A} section variable [F.CommShift A] /-- If a functor `F` commutes with the shift by `A` (i.e. `[F.CommShift A]`), then `F.commShiftIso a` is the given isomorphism `shiftFunctor C a ⋙ F ≅ F ⋙ shiftFunctor D a`. -/ def commShiftIso (a : A) : shiftFunctor C a ⋙ F ≅ F ⋙ shiftFunctor D a := CommShift.iso a -- Note: The following two lemmas are introduced in order to have more proofs work `by simp`. -- Indeed, `simp only [(F.commShiftIso a).hom.naturality f]` would almost never work because -- of the compositions of functors which appear in both the source and target of -- `F.commShiftIso a`. Otherwise, we would be forced to use `erw [NatTrans.naturality]`. @[reassoc (attr := simp)] lemma commShiftIso_hom_naturality {X Y : C} (f : X ⟶ Y) (a : A) : F.map (f⟦a⟧') ≫ (F.commShiftIso a).hom.app Y = (F.commShiftIso a).hom.app X ≫ (F.map f)⟦a⟧' := (F.commShiftIso a).hom.naturality f @[reassoc (attr := simp)] lemma commShiftIso_inv_naturality {X Y : C} (f : X ⟶ Y) (a : A) : (F.map f)⟦a⟧' ≫ (F.commShiftIso a).inv.app Y = (F.commShiftIso a).inv.app X ≫ F.map (f⟦a⟧') := (F.commShiftIso a).inv.naturality f variable (A) lemma commShiftIso_zero : F.commShiftIso (0 : A) = CommShift.isoZero F A := CommShift.zero variable {A} lemma commShiftIso_add (a b : A) : F.commShiftIso (a + b) = CommShift.isoAdd (F.commShiftIso a) (F.commShiftIso b) := CommShift.add a b lemma commShiftIso_add' {a b c : A} (h : a + b = c) : F.commShiftIso c = CommShift.isoAdd' h (F.commShiftIso a) (F.commShiftIso b) := by subst h simp only [commShiftIso_add, CommShift.isoAdd] end namespace CommShift variable (C) in instance id : CommShift (𝟭 C) A where iso := fun a => rightUnitor _ ≪≫ (leftUnitor _).symm instance comp [F.CommShift A] [G.CommShift A] : (F ⋙ G).CommShift A where iso a := (Functor.associator _ _ _).symm ≪≫ isoWhiskerRight (F.commShiftIso a) _ ≪≫ Functor.associator _ _ _ ≪≫ isoWhiskerLeft _ (G.commShiftIso a) ≪≫ (Functor.associator _ _ _).symm zero := by ext X dsimp simp only [id_comp, comp_id, commShiftIso_zero, isoZero_hom_app, ← Functor.map_comp_assoc, assoc, Iso.inv_hom_id_app, id_obj, comp_map, comp_obj] add := fun a b => by ext X dsimp simp only [commShiftIso_add, isoAdd_hom_app] dsimp simp only [comp_id, id_comp, assoc, ← Functor.map_comp_assoc, Iso.inv_hom_id_app, comp_obj] simp only [map_comp, assoc, commShiftIso_hom_naturality_assoc] end CommShift @[simp] lemma commShiftIso_id_hom_app (a : A) (X : C) : (commShiftIso (𝟭 C) a).hom.app X = 𝟙 _ := comp_id _ @[simp] lemma commShiftIso_id_inv_app (a : A) (X : C) : (commShiftIso (𝟭 C) a).inv.app X = 𝟙 _ := comp_id _ lemma commShiftIso_comp_hom_app [F.CommShift A] [G.CommShift A] (a : A) (X : C) : (commShiftIso (F ⋙ G) a).hom.app X = G.map ((commShiftIso F a).hom.app X) ≫ (commShiftIso G a).hom.app (F.obj X) := by simp [commShiftIso, CommShift.iso] lemma commShiftIso_comp_inv_app [F.CommShift A] [G.CommShift A] (a : A) (X : C) : (commShiftIso (F ⋙ G) a).inv.app X = (commShiftIso G a).inv.app (F.obj X) ≫ G.map ((commShiftIso F a).inv.app X) := by simp [commShiftIso, CommShift.iso] variable {B} lemma map_shiftFunctorComm_hom_app [F.CommShift B] (X : C) (a b : B) : F.map ((shiftFunctorComm C a b).hom.app X) = (F.commShiftIso b).hom.app (X⟦a⟧) ≫ ((F.commShiftIso a).hom.app X)⟦b⟧' ≫ (shiftFunctorComm D a b).hom.app (F.obj X) ≫ ((F.commShiftIso b).inv.app X)⟦a⟧' ≫ (F.commShiftIso a).inv.app (X⟦b⟧) := by have eq := NatTrans.congr_app (congr_arg Iso.hom (F.commShiftIso_add a b)) X simp only [comp_obj, CommShift.isoAdd_hom_app, ← cancel_epi (F.map ((shiftFunctorAdd C a b).inv.app X)), Category.assoc, ← F.map_comp_assoc, Iso.inv_hom_id_app, F.map_id, Category.id_comp, F.map_comp] at eq simp only [shiftFunctorComm_eq D a b _ rfl] dsimp simp only [Functor.map_comp, shiftFunctorAdd'_eq_shiftFunctorAdd, Category.assoc, ← reassoc_of% eq, shiftFunctorComm_eq C a b _ rfl] dsimp rw [Functor.map_comp] simp only [NatTrans.congr_app (congr_arg Iso.hom (F.commShiftIso_add' (add_comm b a))) X, CommShift.isoAdd'_hom_app, Category.assoc, Iso.inv_hom_id_app_assoc, ← Functor.map_comp_assoc, Iso.hom_inv_id_app, Functor.map_id, Category.id_comp, comp_obj, Category.comp_id] @[simp, reassoc] lemma map_shiftFunctorCompIsoId_hom_app [F.CommShift A] (X : C) (a b : A) (h : a + b = 0) : F.map ((shiftFunctorCompIsoId C a b h).hom.app X) = (F.commShiftIso b).hom.app (X⟦a⟧) ≫ ((F.commShiftIso a).hom.app X)⟦b⟧' ≫ (shiftFunctorCompIsoId D a b h).hom.app (F.obj X) := by dsimp [shiftFunctorCompIsoId] have eq := NatTrans.congr_app (congr_arg Iso.hom (F.commShiftIso_add' h)) X simp only [commShiftIso_zero, comp_obj, CommShift.isoZero_hom_app, CommShift.isoAdd'_hom_app] at eq rw [← cancel_epi (F.map ((shiftFunctorAdd' C a b 0 h).hom.app X)), ← reassoc_of% eq, F.map_comp] simp only [Iso.inv_hom_id_app, id_obj, Category.comp_id, ← F.map_comp_assoc, Iso.hom_inv_id_app, F.map_id, Category.id_comp] @[simp, reassoc] lemma map_shiftFunctorCompIsoId_inv_app [F.CommShift A] (X : C) (a b : A) (h : a + b = 0) : F.map ((shiftFunctorCompIsoId C a b h).inv.app X) = (shiftFunctorCompIsoId D a b h).inv.app (F.obj X) ≫ ((F.commShiftIso a).inv.app X)⟦b⟧' ≫ (F.commShiftIso b).inv.app (X⟦a⟧) := by rw [← cancel_epi (F.map ((shiftFunctorCompIsoId C a b h).hom.app X)), ← F.map_comp, Iso.hom_inv_id_app, F.map_id, map_shiftFunctorCompIsoId_hom_app] simp only [comp_obj, id_obj, Category.assoc, Iso.hom_inv_id_app_assoc, ← Functor.map_comp_assoc, Iso.hom_inv_id_app, Functor.map_id, Category.id_comp] end Functor namespace NatTrans variable {C D E J : Type*} [Category C] [Category D] [Category E] [Category J] {F₁ F₂ F₃ : C ⥤ D} (τ : F₁ ⟶ F₂) (τ' : F₂ ⟶ F₃) (e : F₁ ≅ F₂) (G G' : D ⥤ E) (τ'' : G ⟶ G') (H : E ⥤ J) (A : Type*) [AddMonoid A] [HasShift C A] [HasShift D A] [HasShift E A] [HasShift J A] [F₁.CommShift A] [F₂.CommShift A] [F₃.CommShift A] [G.CommShift A] [G'.CommShift A] [H.CommShift A] /-- If `τ : F₁ ⟶ F₂` is a natural transformation between two functors which commute with a shift by an additive monoid `A`, this typeclass asserts a compatibility of `τ` with these shifts. -/ class CommShift : Prop := comm' (a : A) : (F₁.commShiftIso a).hom ≫ whiskerRight τ _ = whiskerLeft _ τ ≫ (F₂.commShiftIso a).hom namespace CommShift section variable {A} variable [NatTrans.CommShift τ A] lemma comm (a : A) : (F₁.commShiftIso a).hom ≫ whiskerRight τ _ = whiskerLeft _ τ ≫ (F₂.commShiftIso a).hom := by apply comm' @[reassoc] lemma comm_app (a : A) (X : C) : (F₁.commShiftIso a).hom.app X ≫ (τ.app X)⟦a⟧' = τ.app (X⟦a⟧) ≫ (F₂.commShiftIso a).hom.app X := NatTrans.congr_app (comm τ a) X @[reassoc] lemma shift_app (a : A) (X : C) : (τ.app X)⟦a⟧' = (F₁.commShiftIso a).inv.app X ≫ τ.app (X⟦a⟧) ≫ (F₂.commShiftIso a).hom.app X := by rw [← comm_app, Iso.inv_hom_id_app_assoc] @[reassoc] lemma app_shift (a : A) (X : C) : τ.app (X⟦a⟧) = (F₁.commShiftIso a).hom.app X ≫ (τ.app X)⟦a⟧' ≫ (F₂.commShiftIso a).inv.app X := by erw [comm_app_assoc, Iso.hom_inv_id_app, Category.comp_id] end instance of_iso_inv [NatTrans.CommShift e.hom A] : NatTrans.CommShift e.inv A := ⟨fun a => by ext X dsimp rw [← cancel_epi (e.hom.app (X⟦a⟧)), e.hom_inv_id_app_assoc, ← comm_app_assoc, ← Functor.map_comp, e.hom_inv_id_app, Functor.map_id] rw [Category.comp_id]⟩ lemma of_isIso [IsIso τ] [NatTrans.CommShift τ A] : NatTrans.CommShift (inv τ) A := by haveI : NatTrans.CommShift (asIso τ).hom A := by dsimp infer_instance change NatTrans.CommShift (asIso τ).inv A infer_instance variable (F₁) in instance id : NatTrans.CommShift (𝟙 F₁) A := ⟨by aesop_cat⟩ instance comp [NatTrans.CommShift τ A] [NatTrans.CommShift τ' A] : NatTrans.CommShift (τ ≫ τ') A := ⟨fun a => by ext X simp [comm_app_assoc, comm_app]⟩ instance whiskerRight [NatTrans.CommShift τ A] : NatTrans.CommShift (whiskerRight τ G) A := ⟨fun a => by ext X simp only [Functor.comp_obj, whiskerRight_twice, comp_app, whiskerRight_app, Functor.comp_map, whiskerLeft_app, Functor.commShiftIso_comp_hom_app, Category.assoc] erw [← NatTrans.naturality] dsimp simp only [← G.map_comp_assoc, comm_app]⟩ variable {G G'} (F₁) instance whiskerLeft [NatTrans.CommShift τ'' A] : NatTrans.CommShift (whiskerLeft F₁ τ'') A := ⟨fun a => by ext X simp only [Functor.comp_obj, comp_app, whiskerRight_app, whiskerLeft_app, whiskerLeft_twice, Functor.commShiftIso_comp_hom_app, Category.assoc, ← NatTrans.naturality_assoc, comm_app]⟩ instance associator : CommShift (Functor.associator F₁ G H).hom A where comm' a := by ext X; simp [Functor.commShiftIso_comp_hom_app] instance leftUnitor : CommShift F₁.leftUnitor.hom A where comm' a := by ext X; simp [Functor.commShiftIso_comp_hom_app] instance rightUnitor : CommShift F₁.rightUnitor.hom A where comm' a := by ext X; simp [Functor.commShiftIso_comp_hom_app] end CommShift end NatTrans namespace Functor namespace CommShift variable {C D E : Type*} [Category C] [Category D] {F : C ⥤ D} {G : C ⥤ D} (e : F ≅ G) (A : Type*) [AddMonoid A] [HasShift C A] [HasShift D A] [F.CommShift A] /-- If `e : F ≅ G` is an isomorphism of functors and if `F` commutes with the shift, then `G` also commutes with the shift. -/ def ofIso : G.CommShift A where iso a := isoWhiskerLeft _ e.symm ≪≫ F.commShiftIso a ≪≫ isoWhiskerRight e _ zero := by ext X simp only [comp_obj, F.commShiftIso_zero A, Iso.trans_hom, isoWhiskerLeft_hom, Iso.symm_hom, isoWhiskerRight_hom, NatTrans.comp_app, whiskerLeft_app, isoZero_hom_app, whiskerRight_app, assoc] erw [← e.inv.naturality_assoc, ← NatTrans.naturality, e.inv_hom_id_app_assoc] add a b := by ext X simp only [comp_obj, F.commShiftIso_add, Iso.trans_hom, isoWhiskerLeft_hom, Iso.symm_hom, isoWhiskerRight_hom, NatTrans.comp_app, whiskerLeft_app, isoAdd_hom_app, whiskerRight_app, assoc, map_comp, NatTrans.naturality_assoc, NatIso.cancel_natIso_inv_left] simp only [← Functor.map_comp_assoc, e.hom_inv_id_app_assoc] simp only [← NatTrans.naturality, comp_obj, comp_map, map_comp, assoc] lemma ofIso_compatibility : letI := ofIso e A NatTrans.CommShift e.hom A := by letI := ofIso e A refine ⟨fun a => ?_⟩ dsimp [commShiftIso, ofIso] rw [← whiskerLeft_comp_assoc, e.hom_inv_id, whiskerLeft_id', id_comp] end CommShift end Functor /-- Assume that we have a diagram of categories ``` C₁ ⥤ D₁ ‖ ‖ v v C₂ ⥤ D₂ ‖ ‖ v v C₃ ⥤ D₃ ``` with functors `F₁₂ : C₁ ⥤ C₂`, `F₂₃ : C₂ ⥤ C₃` and `F₁₃ : C₁ ⥤ C₃` on the first column that are related by a natural transformation `α : F₁₃ ⟶ F₁₂ ⋙ F₂₃` and similarly `β : G₁₂ ⋙ G₂₃ ⟶ G₁₃` on the second column. Assume that we have natural transformations `e₁₂ : F₁₂ ⋙ L₂ ⟶ L₁ ⋙ G₁₂` (top square), `e₂₃ : F₂₃ ⋙ L₃ ⟶ L₂ ⋙ G₂₃` (bottom square), and `e₁₃ : F₁₃ ⋙ L₃ ⟶ L₁ ⋙ G₁₃` (outer square), where the horizontal functors are denoted `L₁`, `L₂` and `L₃`. Assume that `e₁₃` is determined by the other natural transformations `α`, `e₂₃`, `e₁₂` and `β`. Then, if all these categories are equipped with a shift by an additive monoid `A`, and all these functors commute with these shifts, then the natural transformation `e₁₃` of the outer square commutes with the shift if all `α`, `e₂₃`, `e₁₂` and `β` do. -/ lemma NatTrans.CommShift.verticalComposition {C₁ C₂ C₃ D₁ D₂ D₃ : Type*} [Category C₁] [Category C₂] [Category C₃] [Category D₁] [Category D₂] [Category D₃] {F₁₂ : C₁ ⥤ C₂} {F₂₃ : C₂ ⥤ C₃} {F₁₃ : C₁ ⥤ C₃} (α : F₁₃ ⟶ F₁₂ ⋙ F₂₃) {G₁₂ : D₁ ⥤ D₂} {G₂₃ : D₂ ⥤ D₃} {G₁₃ : D₁ ⥤ D₃} (β : G₁₂ ⋙ G₂₃ ⟶ G₁₃) {L₁ : C₁ ⥤ D₁} {L₂ : C₂ ⥤ D₂} {L₃ : C₃ ⥤ D₃} (e₁₂ : F₁₂ ⋙ L₂ ⟶ L₁ ⋙ G₁₂) (e₂₃ : F₂₃ ⋙ L₃ ⟶ L₂ ⋙ G₂₃) (e₁₃ : F₁₃ ⋙ L₃ ⟶ L₁ ⋙ G₁₃) (A : Type*) [AddMonoid A] [HasShift C₁ A] [HasShift C₂ A] [HasShift C₃ A] [HasShift D₁ A] [HasShift D₂ A] [HasShift D₃ A] [F₁₂.CommShift A] [F₂₃.CommShift A] [F₁₃.CommShift A] [CommShift α A] [G₁₂.CommShift A] [G₂₃.CommShift A] [G₁₃.CommShift A] [CommShift β A] [L₁.CommShift A] [L₂.CommShift A] [L₃.CommShift A] [CommShift e₁₂ A] [CommShift e₂₃ A] (h₁₃ : e₁₃ = CategoryTheory.whiskerRight α L₃ ≫ (Functor.associator _ _ _).hom ≫ CategoryTheory.whiskerLeft F₁₂ e₂₃ ≫ (Functor.associator _ _ _).inv ≫ CategoryTheory.whiskerRight e₁₂ G₂₃ ≫ (Functor.associator _ _ _).hom ≫ CategoryTheory.whiskerLeft L₁ β) : CommShift e₁₃ A := by subst h₁₃ infer_instance end CategoryTheory
CategoryTheory\Shift\Induced.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.Shift.CommShift /-! # Shift induced from a category to another In this file, we introduce a sufficient condition on a functor `F : C ⥤ D` so that a shift on `C` by a monoid `A` induces a shift on `D`. More precisely, when the functor `(D ⥤ D) ⥤ C ⥤ D` given by the precomposition with `F` is fully faithful, and that all the shift functors on `C` can be lifted to functors `D ⥤ D` (i.e. we have functors `s a : D ⥤ D` for all `a : A`, and isomorphisms `F ⋙ s a ≅ shiftFunctor C a ⋙ F`), then these functors `s a` are the shift functors of a term of type `HasShift D A`. As this condition on the functor `F` is satisfied for quotient and localization functors, the main construction `HasShift.induced` in this file shall be used for both quotient and localized shifts. -/ namespace CategoryTheory variable {C D : Type _} [Category C] [Category D] (F : C ⥤ D) {A : Type _} [AddMonoid A] [HasShift C A] (s : A → D ⥤ D) (i : ∀ a, F ⋙ s a ≅ shiftFunctor C a ⋙ F) [((whiskeringLeft C D D).obj F).Full] [((whiskeringLeft C D D).obj F).Faithful] namespace HasShift namespace Induced /-- The `zero` field of the `ShiftMkCore` structure for the induced shift. -/ noncomputable def zero : s 0 ≅ 𝟭 D := ((whiskeringLeft C D D).obj F).preimageIso ((i 0) ≪≫ isoWhiskerRight (shiftFunctorZero C A) F ≪≫ F.leftUnitor ≪≫ F.rightUnitor.symm) /-- The `add` field of the `ShiftMkCore` structure for the induced shift. -/ noncomputable def add (a b : A) : s (a + b) ≅ s a ⋙ s b := ((whiskeringLeft C D D).obj F).preimageIso (i (a + b) ≪≫ isoWhiskerRight (shiftFunctorAdd C a b) F ≪≫ Functor.associator _ _ _ ≪≫ isoWhiskerLeft _ (i b).symm ≪≫ (Functor.associator _ _ _).symm ≪≫ isoWhiskerRight (i a).symm _ ≪≫ Functor.associator _ _ _) @[simp] lemma zero_hom_app_obj (X : C) : (zero F s i).hom.app (F.obj X) = (i 0).hom.app X ≫ F.map ((shiftFunctorZero C A).hom.app X) := by have h : whiskerLeft F (zero F s i).hom = _ := ((whiskeringLeft C D D).obj F).map_preimage _ exact (NatTrans.congr_app h X).trans (by simp) @[simp] lemma zero_inv_app_obj (X : C) : (zero F s i).inv.app (F.obj X) = F.map ((shiftFunctorZero C A).inv.app X) ≫ (i 0).inv.app X := by have h : whiskerLeft F (zero F s i).inv = _ := ((whiskeringLeft C D D).obj F).map_preimage _ exact (NatTrans.congr_app h X).trans (by simp) @[simp] lemma add_hom_app_obj (a b : A) (X : C) : (add F s i a b).hom.app (F.obj X) = (i (a + b)).hom.app X ≫ F.map ((shiftFunctorAdd C a b).hom.app X) ≫ (i b).inv.app ((shiftFunctor C a).obj X) ≫ (s b).map ((i a).inv.app X) := by have h : whiskerLeft F (add F s i a b).hom = _ := ((whiskeringLeft C D D).obj F).map_preimage _ exact (NatTrans.congr_app h X).trans (by simp) @[simp] lemma add_inv_app_obj (a b : A) (X : C) : (add F s i a b).inv.app (F.obj X) = (s b).map ((i a).hom.app X) ≫ (i b).hom.app ((shiftFunctor C a).obj X) ≫ F.map ((shiftFunctorAdd C a b).inv.app X) ≫ (i (a + b)).inv.app X := by have h : whiskerLeft F (add F s i a b).inv = _ := ((whiskeringLeft C D D).obj F).map_preimage _ exact (NatTrans.congr_app h X).trans (by simp) end Induced variable (A) /-- When `F : C ⥤ D` is a functor satisfying suitable technical assumptions, this is the induced term of type `HasShift D A` deduced from `[HasShift C A]`. -/ noncomputable def induced : HasShift D A := hasShiftMk D A { F := s zero := Induced.zero F s i add := Induced.add F s i zero_add_hom_app := fun n => by suffices (Induced.add F s i 0 n).hom = eqToHom (by rw [zero_add]; rfl) ≫ whiskerRight (Induced.zero F s i ).inv (s n) by intro X simpa using NatTrans.congr_app this X apply ((whiskeringLeft C D D).obj F).map_injective ext X have eq := dcongr_arg (fun a => (i a).hom.app X) (zero_add n) dsimp simp only [Induced.add_hom_app_obj, eq, shiftFunctorAdd_zero_add_hom_app, Functor.map_comp, eqToHom_map, Category.assoc, eqToHom_trans_assoc, eqToHom_refl, Category.id_comp, eqToHom_app, Induced.zero_inv_app_obj] erw [← NatTrans.naturality_assoc, Iso.hom_inv_id_app_assoc] rfl add_zero_hom_app := fun n => by suffices (Induced.add F s i n 0).hom = eqToHom (by rw [add_zero]; rfl) ≫ whiskerLeft (s n) (Induced.zero F s i).inv by intro X simpa using NatTrans.congr_app this X apply ((whiskeringLeft C D D).obj F).map_injective ext X dsimp erw [Induced.add_hom_app_obj, dcongr_arg (fun a => (i a).hom.app X) (add_zero n), ← cancel_mono ((s 0).map ((i n).hom.app X)), Category.assoc, Category.assoc, Category.assoc, Category.assoc, Category.assoc, Category.assoc, ← (s 0).map_comp, Iso.inv_hom_id_app, Functor.map_id, Category.comp_id, ← NatTrans.naturality, Induced.zero_inv_app_obj, shiftFunctorAdd_add_zero_hom_app] simp [eqToHom_map, eqToHom_app] assoc_hom_app := fun m₁ m₂ m₃ => by suffices (Induced.add F s i (m₁ + m₂) m₃).hom ≫ whiskerRight (Induced.add F s i m₁ m₂).hom (s m₃) = eqToHom (by rw [add_assoc]) ≫ (Induced.add F s i m₁ (m₂ + m₃)).hom ≫ whiskerLeft (s m₁) (Induced.add F s i m₂ m₃).hom by intro X simpa using NatTrans.congr_app this X apply ((whiskeringLeft C D D).obj F).map_injective ext X dsimp have eq := F.congr_map (shiftFunctorAdd'_assoc_hom_app m₁ m₂ m₃ _ _ (m₁+m₂+m₃) rfl rfl rfl X) simp only [shiftFunctorAdd'_eq_shiftFunctorAdd] at eq simp only [Functor.comp_obj, Functor.map_comp, shiftFunctorAdd', Iso.trans_hom, eqToIso.hom, NatTrans.comp_app, eqToHom_app, Category.assoc] at eq rw [← cancel_mono ((s m₃).map ((s m₂).map ((i m₁).hom.app X)))] simp only [Induced.add_hom_app_obj, Category.assoc, Functor.map_comp] slice_lhs 4 5 => erw [← Functor.map_comp, Iso.inv_hom_id_app, Functor.map_id] erw [Category.id_comp] slice_lhs 6 7 => erw [← Functor.map_comp, ← Functor.map_comp, Iso.inv_hom_id_app, (s m₂).map_id, (s m₃).map_id] erw [Category.comp_id, ← NatTrans.naturality_assoc, reassoc_of% eq, dcongr_arg (fun a => (i a).hom.app X) (add_assoc m₁ m₂ m₃).symm] simp only [Functor.comp_obj, eqToHom_map, eqToHom_app, NatTrans.naturality_assoc, Induced.add_hom_app_obj, Functor.comp_map, Category.assoc, Iso.inv_hom_id_app_assoc, eqToHom_trans_assoc, eqToHom_refl, Category.id_comp, Category.comp_id, ← Functor.map_comp, Iso.inv_hom_id_app, Functor.map_id] } end HasShift @[simp] lemma shiftFunctor_of_induced (a : A) : letI := HasShift.induced F A s i shiftFunctor D a = s a := by rfl variable (A) @[simp] lemma shiftFunctorZero_hom_app_obj_of_induced (X : C) : letI := HasShift.induced F A s i (shiftFunctorZero D A).hom.app (F.obj X) = (i 0).hom.app X ≫ F.map ((shiftFunctorZero C A).hom.app X) := by letI := HasShift.induced F A s i simp only [ShiftMkCore.shiftFunctorZero_eq, HasShift.Induced.zero_hom_app_obj] @[simp] lemma shiftFunctorZero_inv_app_obj_of_induced (X : C) : letI := HasShift.induced F A s i (shiftFunctorZero D A).inv.app (F.obj X) = F.map ((shiftFunctorZero C A).inv.app X) ≫ (i 0).inv.app X := by letI := HasShift.induced F A s i simp only [ShiftMkCore.shiftFunctorZero_eq, HasShift.Induced.zero_inv_app_obj] variable {A} @[simp] lemma shiftFunctorAdd_hom_app_obj_of_induced (a b : A) (X : C) : letI := HasShift.induced F A s i (shiftFunctorAdd D a b).hom.app (F.obj X) = (i (a + b)).hom.app X ≫ F.map ((shiftFunctorAdd C a b).hom.app X) ≫ (i b).inv.app ((shiftFunctor C a).obj X) ≫ (s b).map ((i a).inv.app X) := by letI := HasShift.induced F A s i simp only [ShiftMkCore.shiftFunctorAdd_eq, HasShift.Induced.add_hom_app_obj] @[simp] lemma shiftFunctorAdd_inv_app_obj_of_induced (a b : A) (X : C) : letI := HasShift.induced F A s i (shiftFunctorAdd D a b).inv.app (F.obj X) = (s b).map ((i a).hom.app X) ≫ (i b).hom.app ((shiftFunctor C a).obj X) ≫ F.map ((shiftFunctorAdd C a b).inv.app X) ≫ (i (a + b)).inv.app X := by letI := HasShift.induced F A s i simp only [ShiftMkCore.shiftFunctorAdd_eq, HasShift.Induced.add_inv_app_obj] variable (A) /-- When the target category of a functor `F : C ⥤ D` is equipped with the induced shift, this is the compatibility of `F` with the shifts on the categories `C` and `D`. -/ def Functor.CommShift.ofInduced : letI := HasShift.induced F A s i F.CommShift A := by letI := HasShift.induced F A s i exact { iso := fun a => (i a).symm zero := by ext X dsimp simp only [isoZero_hom_app, shiftFunctorZero_inv_app_obj_of_induced, ← F.map_comp_assoc, Iso.hom_inv_id_app, F.map_id, Category.id_comp] add := fun a b => by ext X dsimp simp only [isoAdd_hom_app, Iso.symm_hom, shiftFunctorAdd_inv_app_obj_of_induced, shiftFunctor_of_induced] erw [← Functor.map_comp_assoc, Iso.inv_hom_id_app, Functor.map_id, Category.id_comp, Iso.inv_hom_id_app_assoc, ← F.map_comp_assoc, Iso.hom_inv_id_app, F.map_id, Category.id_comp] } lemma Functor.commShiftIso_eq_ofInduced (a : A) : letI := HasShift.induced F A s i letI := Functor.CommShift.ofInduced F A s i F.commShiftIso a = (i a).symm := rfl end CategoryTheory
CategoryTheory\Shift\InducedShiftSequence.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.Shift.CommShift import Mathlib.CategoryTheory.Shift.ShiftSequence /-! # Induced shift sequences When `G : C ⥤ A` is a functor from a category equipped with a shift by a monoid `M`, we have defined in the file `CategoryTheory.Shift.ShiftSequence` a type class `G.ShiftSequence M` which provides functors `G.shift a : C ⥤ A` for all `a : M`, isomorphisms `shiftFunctor C n ⋙ G.shift a ≅ G.shift a'` when `n + a = a'`, and isomorphisms `G.isoShift a : shiftFunctor C a ⋙ G ≅ G.shift a` for all `a`, all of which satisfy good coherence properties. The idea is that it allows to use functors `G.shift a` which may have better definitional properties than `shiftFunctor C a ⋙ G`. The typical example shall be `[(homologyFunctor C (ComplexShape.up ℤ) 0).ShiftSequence ℤ]` for any abelian category `C` (TODO). Similarly as a shift on a category may induce a shift on a quotient or a localized category (see the file `CategoryTheory.Shift.Induced`), this file shows that under certain assumptions, there is an induced "shift sequence". The main application will be the construction of a shift sequence for the homology functor on the homotopy category of cochain complexes (TODO), and also on the derived category (TODO). -/ open CategoryTheory Category namespace CategoryTheory variable {C D A : Type*} [Category C] [Category D] [Category A] {L : C ⥤ D} {F : D ⥤ A} {G : C ⥤ A} (e : L ⋙ F ≅ G) (M : Type*) [AddMonoid M] [HasShift C M] [G.ShiftSequence M] (F' : M → D ⥤ A) (e' : ∀ m, L ⋙ F' m ≅ G.shift m) [((whiskeringLeft C D A).obj L).Full] [((whiskeringLeft C D A).obj L).Faithful] namespace Functor namespace ShiftSequence namespace induced /-- The `isoZero` field of the induced shift sequence. -/ noncomputable def isoZero : F' 0 ≅ F := ((whiskeringLeft C D A).obj L).preimageIso (e' 0 ≪≫ G.isoShiftZero M ≪≫ e.symm) lemma isoZero_hom_app_obj (X : C) : (isoZero e M F' e').hom.app (L.obj X) = (e' 0).hom.app X ≫ (isoShiftZero G M).hom.app X ≫ e.inv.app X := NatTrans.congr_app (((whiskeringLeft C D A).obj L).map_preimage _) X variable (L G) variable [HasShift D M] [L.CommShift M] /-- The `shiftIso` field of the induced shift sequence. -/ noncomputable def shiftIso (n a a' : M) (ha' : n + a = a') : shiftFunctor D n ⋙ F' a ≅ F' a' := by exact ((whiskeringLeft C D A).obj L).preimageIso ((Functor.associator _ _ _).symm ≪≫ isoWhiskerRight (L.commShiftIso n).symm _ ≪≫ Functor.associator _ _ _ ≪≫ isoWhiskerLeft _ (e' a) ≪≫ G.shiftIso n a a' ha' ≪≫ (e' a').symm) lemma shiftIso_hom_app_obj (n a a' : M) (ha' : n + a = a') (X : C) : (shiftIso L G M F' e' n a a' ha').hom.app (L.obj X) = (F' a).map ((L.commShiftIso n).inv.app X) ≫ (e' a).hom.app (X⟦n⟧) ≫ (G.shiftIso n a a' ha').hom.app X ≫ (e' a').inv.app X := (NatTrans.congr_app (((whiskeringLeft C D A).obj L).map_preimage _) X).trans (by simp) attribute [irreducible] isoZero shiftIso end induced variable [HasShift D M] [L.CommShift M] /-- Given an isomorphism of functors `e : L ⋙ F ≅ G` relating functors `L : C ⥤ D`, `F : D ⥤ A` and `G : C ⥤ A`, an additive monoid `M`, a family of functors `F' : M → D ⥤ A` equipped with isomorphisms `e' : ∀ m, L ⋙ F' m ≅ G.shift m`, this is the shift sequence induced on `F` induced by a shift sequence for the functor `G`, provided that the functor `(whiskeringLeft C D A).obj L` of precomposition by `L` is fully faithful. -/ noncomputable def induced : F.ShiftSequence M where sequence := F' isoZero := induced.isoZero e M F' e' shiftIso := induced.shiftIso L G M F' e' shiftIso_zero a := by ext1 apply ((whiskeringLeft C D A).obj L).map_injective ext K dsimp simp only [induced.shiftIso_hom_app_obj, shiftIso_zero_hom_app, id_obj, NatTrans.naturality, comp_map, Iso.hom_inv_id_app_assoc, comp_id, ← Functor.map_comp, L.commShiftIso_zero, CommShift.isoZero_inv_app, assoc, Iso.inv_hom_id_app, Functor.map_id] shiftIso_add n m a a' a'' ha' ha'' := by ext1 apply ((whiskeringLeft C D A).obj L).map_injective ext K dsimp simp only [id_comp, induced.shiftIso_hom_app_obj, G.shiftIso_add_hom_app n m a a' a'' ha' ha'', L.commShiftIso_add, comp_obj, CommShift.isoAdd_inv_app, (F' a).map_comp, assoc, ← (e' a).hom.naturality_assoc, comp_map] simp only [← NatTrans.naturality_assoc, induced.shiftIso_hom_app_obj, ← Functor.map_comp_assoc, ← Functor.map_comp, Iso.inv_hom_id_app, comp_obj, Functor.map_id, id_comp] dsimp simp only [Functor.map_comp, assoc, Iso.inv_hom_id_app_assoc] @[simp, reassoc] lemma induced_isoShiftZero_hom_app_obj (X : C) : letI := (induced e M F' e') (F.isoShiftZero M).hom.app (L.obj X) = (e' 0).hom.app X ≫ (isoShiftZero G M).hom.app X ≫ e.inv.app X := by apply induced.isoZero_hom_app_obj @[simp, reassoc] lemma induced_shiftIso_hom_app_obj (n a a' : M) (ha' : n + a = a') (X : C) : letI := (induced e M F' e') (F.shiftIso n a a' ha').hom.app (L.obj X) = (F.shift a).map ((L.commShiftIso n).inv.app X) ≫ (e' a).hom.app (X⟦n⟧) ≫ (G.shiftIso n a a' ha').hom.app X ≫ (e' a').inv.app X := by apply induced.shiftIso_hom_app_obj @[reassoc] lemma induced_shiftMap {n : M} {X Y : C} (f : X ⟶ Y⟦n⟧) (a a' : M) (h : n + a = a') : letI := induced e M F' e' F.shiftMap (L.map f ≫ (L.commShiftIso n).hom.app _) a a' h = (e' a).hom.app X ≫ G.shiftMap f a a' h ≫ (e' a').inv.app Y := by dsimp [shiftMap] rw [Functor.map_comp, induced_shiftIso_hom_app_obj, assoc, assoc] nth_rw 2 [← Functor.map_comp_assoc] simp only [comp_obj, Iso.hom_inv_id_app, map_id, id_comp] rw [← NatTrans.naturality_assoc] rfl end ShiftSequence end Functor end CategoryTheory
CategoryTheory\Shift\Localization.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.Shift.Induced import Mathlib.CategoryTheory.Localization.HasLocalization import Mathlib.CategoryTheory.Localization.LocalizerMorphism /-! # The shift induced on a localized category Let `C` be a category equipped with a shift by a monoid `A`. A morphism property `W` on `C` satisfies `W.IsCompatibleWithShift A` when for all `a : A`, a morphism `f` is in `W` iff `f⟦a⟧'` is. When this compatibility is satisfied, then the corresponding localized category can be equipped with a shift by `A`, and the localization functor is compatible with the shift. --/ universe v₁ v₂ v₃ u₁ u₂ u₃ w namespace CategoryTheory variable {C : Type u₁} {D : Type u₂} [Category.{v₁} C] [Category.{v₂} D] {E : Type u₃} [Category.{v₃} E] (L : C ⥤ D) (W : MorphismProperty C) [L.IsLocalization W] (A : Type w) [AddMonoid A] [HasShift C A] namespace MorphismProperty /-- A morphism property `W` on a category `C` is compatible with the shift by a monoid `A` when for all `a : A`, a morphism `f` belongs to `W` if and only if `f⟦a⟧'` does. -/ class IsCompatibleWithShift : Prop := /-- the condition that for all `a : A`, the morphism property `W` is not changed when we take its inverse image by the shift functor by `a` -/ condition : ∀ (a : A), W.inverseImage (shiftFunctor C a) = W variable [W.IsCompatibleWithShift A] namespace IsCompatibleWithShift variable {A} lemma iff {X Y : C} (f : X ⟶ Y) (a : A) : W (f⟦a⟧') ↔ W f := by conv_rhs => rw [← @IsCompatibleWithShift.condition _ _ W A _ _ _ a] rfl lemma shiftFunctor_comp_inverts (a : A) : W.IsInvertedBy (shiftFunctor C a ⋙ L) := fun _ _ f hf => Localization.inverts L W _ (by simpa only [iff] using hf) end IsCompatibleWithShift variable {A} in /-- The morphism of localizer from `W` to `W` given by the functor `shiftFunctor C a` when `a : A` and `W` is compatible with the shift by `A`. -/ abbrev shiftLocalizerMorphism (a : A) : LocalizerMorphism W W where functor := shiftFunctor C a map := by rw [MorphismProperty.IsCompatibleWithShift.condition] end MorphismProperty section variable [W.IsCompatibleWithShift A] /-- When `L : C ⥤ D` is a localization functor with respect to a morphism property `W` that is compatible with the shift by a monoid `A` on `C`, this is the induced shift on the category `D`. -/ noncomputable def HasShift.localized : HasShift D A := have := Localization.full_whiskeringLeft L W D have := Localization.faithful_whiskeringLeft L W D HasShift.induced L A (fun a => Localization.lift (shiftFunctor C a ⋙ L) (MorphismProperty.IsCompatibleWithShift.shiftFunctor_comp_inverts L W a) L) (fun _ => Localization.fac _ _ _) /-- The localization functor `L : C ⥤ D` is compatible with the shift. -/ @[nolint unusedHavesSuffices] noncomputable def Functor.CommShift.localized : @Functor.CommShift _ _ _ _ L A _ _ (HasShift.localized L W A) := have := Localization.full_whiskeringLeft L W D have := Localization.faithful_whiskeringLeft L W D Functor.CommShift.ofInduced _ _ _ _ attribute [irreducible] HasShift.localized Functor.CommShift.localized /-- The localized category `W.Localization` is endowed with the induced shift. -/ noncomputable instance HasShift.localization : HasShift W.Localization A := HasShift.localized W.Q W A /-- The localization functor `W.Q : C ⥤ W.Localization` is compatible with the shift. -/ noncomputable instance MorphismProperty.commShift_Q : W.Q.CommShift A := Functor.CommShift.localized W.Q W A attribute [irreducible] HasShift.localization MorphismProperty.commShift_Q variable [W.HasLocalization] /-- The localized category `W.Localization'` is endowed with the induced shift. -/ noncomputable instance HasShift.localization' : HasShift W.Localization' A := HasShift.localized W.Q' W A /-- The localization functor `W.Q' : C ⥤ W.Localization'` is compatible with the shift. -/ noncomputable instance MorphismProperty.commShift_Q' : W.Q'.CommShift A := Functor.CommShift.localized W.Q' W A attribute [irreducible] HasShift.localization' MorphismProperty.commShift_Q' end section open Localization variable (F : C ⥤ E) (F' : D ⥤ E) [Lifting L W F F'] [HasShift D A] [HasShift E A] [L.CommShift A] [F.CommShift A] namespace Functor namespace commShiftOfLocalization variable {A} /-- Auxiliary definition for `Functor.commShiftOfLocalization`. -/ noncomputable def iso (a : A) : shiftFunctor D a ⋙ F' ≅ F' ⋙ shiftFunctor E a := Localization.liftNatIso L W (L ⋙ shiftFunctor D a ⋙ F') (L ⋙ F' ⋙ shiftFunctor E a) _ _ ((Functor.associator _ _ _).symm ≪≫ isoWhiskerRight (L.commShiftIso a).symm F' ≪≫ Functor.associator _ _ _ ≪≫ isoWhiskerLeft _ (Lifting.iso L W F F') ≪≫ F.commShiftIso a ≪≫ isoWhiskerRight (Lifting.iso L W F F').symm _ ≪≫ Functor.associator _ _ _) @[simp, reassoc] lemma iso_hom_app (a : A) (X : C) : (commShiftOfLocalization.iso L W F F' a).hom.app (L.obj X) = F'.map ((L.commShiftIso a).inv.app X) ≫ (Lifting.iso L W F F').hom.app (X⟦a⟧) ≫ (F.commShiftIso a).hom.app X ≫ (shiftFunctor E a).map ((Lifting.iso L W F F').inv.app X) := by simp [commShiftOfLocalization.iso] @[simp, reassoc] lemma iso_inv_app (a : A) (X : C) : (commShiftOfLocalization.iso L W F F' a).inv.app (L.obj X) = (shiftFunctor E a).map ((Lifting.iso L W F F').hom.app X) ≫ (F.commShiftIso a).inv.app X ≫ (Lifting.iso L W F F').inv.app (X⟦a⟧) ≫ F'.map ((L.commShiftIso a).hom.app X) := by simp [commShiftOfLocalization.iso] end commShiftOfLocalization /-- In the context of localization of categories, if a functor is induced by a functor which commutes with the shift, then this functor commutes with the shift. -/ noncomputable def commShiftOfLocalization : F'.CommShift A where iso := commShiftOfLocalization.iso L W F F' zero := by ext1 apply natTrans_ext L W intro X dsimp simp only [commShiftOfLocalization.iso_hom_app, comp_obj, commShiftIso_zero, CommShift.isoZero_inv_app, map_comp, CommShift.isoZero_hom_app, Category.assoc, ← NatTrans.naturality_assoc, ← NatTrans.naturality] dsimp simp only [← Functor.map_comp_assoc, ← Functor.map_comp, Iso.inv_hom_id_app, id_obj, map_id, Category.id_comp, Iso.hom_inv_id_app_assoc] add a b := by ext1 apply natTrans_ext L W intro X dsimp simp only [commShiftOfLocalization.iso_hom_app, comp_obj, commShiftIso_add, CommShift.isoAdd_inv_app, map_comp, CommShift.isoAdd_hom_app, Category.assoc] congr 1 rw [← cancel_epi (F'.map ((shiftFunctor D b).map ((L.commShiftIso a).hom.app X))), ← F'.map_comp_assoc, ← map_comp, Iso.hom_inv_id_app, map_id, map_id, Category.id_comp] conv_lhs => erw [← NatTrans.naturality_assoc] dsimp rw [← Functor.map_comp_assoc, ← map_comp_assoc, Category.assoc, ← map_comp, Iso.inv_hom_id_app] dsimp rw [map_id, Category.comp_id, ← NatTrans.naturality] dsimp conv_rhs => erw [← NatTrans.naturality_assoc] dsimp rw [← Functor.map_comp_assoc, ← map_comp, Iso.hom_inv_id_app] dsimp rw [map_id, map_id, Category.id_comp, commShiftOfLocalization.iso_hom_app, Category.assoc, Category.assoc, Category.assoc, ← map_comp_assoc, Iso.inv_hom_id_app, map_id, Category.id_comp] variable {A} lemma commShiftOfLocalization_iso_hom_app (a : A) (X : C) : letI := Functor.commShiftOfLocalization L W A F F' (F'.commShiftIso a).hom.app (L.obj X) = F'.map ((L.commShiftIso a).inv.app X) ≫ (Lifting.iso L W F F').hom.app (X⟦a⟧) ≫ (F.commShiftIso a).hom.app X ≫ (shiftFunctor E a).map ((Lifting.iso L W F F').inv.app X) := by apply commShiftOfLocalization.iso_hom_app lemma commShiftOfLocalization_iso_inv_app (a : A) (X : C) : letI := Functor.commShiftOfLocalization L W A F F' (F'.commShiftIso a).inv.app (L.obj X) = (shiftFunctor E a).map ((Lifting.iso L W F F').hom.app X) ≫ (F.commShiftIso a).inv.app X ≫ (Lifting.iso L W F F').inv.app (X⟦a⟧) ≫ F'.map ((L.commShiftIso a).hom.app X) := by apply commShiftOfLocalization.iso_inv_app end Functor instance NatTrans.commShift_iso_hom_of_localization : letI := Functor.commShiftOfLocalization L W A F F' NatTrans.CommShift (Lifting.iso L W F F').hom A := by letI := Functor.commShiftOfLocalization L W A F F' constructor intro a ext X simp only [comp_app, whiskerRight_app, whiskerLeft_app, Functor.commShiftIso_comp_hom_app, Functor.commShiftOfLocalization_iso_hom_app, Category.assoc, ← Functor.map_comp, ← Functor.map_comp_assoc, Iso.hom_inv_id_app, Functor.map_id, Iso.inv_hom_id_app, Category.comp_id, Category.id_comp, Functor.comp_obj] end end CategoryTheory
CategoryTheory\Shift\Opposite.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.Shift.Basic import Mathlib.CategoryTheory.Preadditive.Opposite /-! # The (naive) shift on the opposite category If `C` is a category equipped with a shift by a monoid `A`, the opposite category can be equipped with a shift such that the shift functor by `n` is `(shiftFunctor C n).op`. This is the "naive" opposite shift, which we shall set on a category `OppositeShift C A`, which is a type synonym for `Cᵒᵖ`. However, for the application to (pre)triangulated categories, we would like to define the shift on `Cᵒᵖ` so that `shiftFunctor Cᵒᵖ n` for `n : ℤ` identifies to `(shiftFunctor C (-n)).op` rather than `(shiftFunctor C n).op`. Then, the construction of the shift on `Cᵒᵖ` shall combine the shift on `OppositeShift C A` and another construction of the "pullback" of a shift by a monoid morphism like `n ↦ -n`. -/ namespace CategoryTheory open Limits variable (C : Type*) [Category C] (A : Type*) [AddMonoid A] [HasShift C A] namespace HasShift /-- Construction of the naive shift on the opposite category of a category `C`: the shiftfunctor by `n` is `(shiftFunctor C n).op`. -/ noncomputable def mkShiftCoreOp : ShiftMkCore Cᵒᵖ A where F n := (shiftFunctor C n).op zero := (NatIso.op (shiftFunctorZero C A)).symm add a b := (NatIso.op (shiftFunctorAdd C a b)).symm assoc_hom_app m₁ m₂ m₃ X := Quiver.Hom.unop_inj ((shiftFunctorAdd_assoc_inv_app m₁ m₂ m₃ X.unop).trans (by simp [shiftFunctorAdd'])) zero_add_hom_app n X := Quiver.Hom.unop_inj ((shiftFunctorAdd_zero_add_inv_app n X.unop).trans (by simp)) add_zero_hom_app n X := Quiver.Hom.unop_inj ((shiftFunctorAdd_add_zero_inv_app n X.unop).trans (by simp)) end HasShift /-- The category `OppositeShift C A` is the opposite category `Cᵒᵖ` equipped with the naive shift: `shiftFunctor (OppositeShift C A) n` is `(shiftFunctor C n).op`. -/ @[nolint unusedArguments] def OppositeShift (A : Type*) [AddMonoid A] [HasShift C A] := Cᵒᵖ instance : Category (OppositeShift C A) := by dsimp only [OppositeShift] infer_instance noncomputable instance : HasShift (OppositeShift C A) A := hasShiftMk Cᵒᵖ A (HasShift.mkShiftCoreOp C A) instance [HasZeroObject C] : HasZeroObject (OppositeShift C A) := by dsimp only [OppositeShift] infer_instance instance [Preadditive C] : Preadditive (OppositeShift C A) := by dsimp only [OppositeShift] infer_instance instance [Preadditive C] (n : A) [(shiftFunctor C n).Additive] : (shiftFunctor (OppositeShift C A) n).Additive := by change (shiftFunctor C n).op.Additive infer_instance lemma oppositeShiftFunctorZero_inv_app (X : OppositeShift C A) : (shiftFunctorZero (OppositeShift C A) A).inv.app X = ((shiftFunctorZero C A).hom.app X.unop).op := rfl lemma oppositeShiftFunctorZero_hom_app (X : OppositeShift C A) : (shiftFunctorZero (OppositeShift C A) A).hom.app X = ((shiftFunctorZero C A).inv.app X.unop).op := by rw [← cancel_mono ((shiftFunctorZero (OppositeShift C A) A).inv.app X), Iso.hom_inv_id_app, oppositeShiftFunctorZero_inv_app, ← op_comp, Iso.hom_inv_id_app, op_id] rfl variable {C A} variable (X : OppositeShift C A) (a b c : A) (h : a + b = c) lemma oppositeShiftFunctorAdd_inv_app : (shiftFunctorAdd (OppositeShift C A) a b).inv.app X = ((shiftFunctorAdd C a b).hom.app X.unop).op := rfl lemma oppositeShiftFunctorAdd_hom_app : (shiftFunctorAdd (OppositeShift C A) a b).hom.app X = ((shiftFunctorAdd C a b).inv.app X.unop).op := by rw [← cancel_mono ((shiftFunctorAdd (OppositeShift C A) a b).inv.app X), Iso.hom_inv_id_app, oppositeShiftFunctorAdd_inv_app, ← op_comp, Iso.hom_inv_id_app, op_id] rfl lemma oppositeShiftFunctorAdd'_inv_app : (shiftFunctorAdd' (OppositeShift C A) a b c h).inv.app X = ((shiftFunctorAdd' C a b c h).hom.app X.unop).op := by subst h simp only [shiftFunctorAdd'_eq_shiftFunctorAdd, oppositeShiftFunctorAdd_inv_app] lemma oppositeShiftFunctorAdd'_hom_app : (shiftFunctorAdd' (OppositeShift C A) a b c h).hom.app X = ((shiftFunctorAdd' C a b c h).inv.app X.unop).op := by subst h simp only [shiftFunctorAdd'_eq_shiftFunctorAdd, oppositeShiftFunctorAdd_hom_app] end CategoryTheory
CategoryTheory\Shift\Predicate.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.ClosedUnderIsomorphisms import Mathlib.CategoryTheory.Shift.Basic /-! # Predicates on categories equipped with shift Given a predicate `P : C → Prop` on objects of a category equipped with a shift by `A`, we define shifted predicates `PredicateShift P a` for all `a : A`. -/ open CategoryTheory Category namespace CategoryTheory variable {C : Type*} [Category C] (P : C → Prop) {A : Type*} [AddMonoid A] [HasShift C A] /-- Given a predicate `P : C → Prop` on objects of a category equipped with a shift by `A`, this is the predicate which is satisfied by `X` if `P (X⟦a⟧)`. -/ def PredicateShift (a : A) : C → Prop := fun X => P (X⟦a⟧) lemma predicateShift_iff (a : A) (X : C) : PredicateShift P a X ↔ P (X⟦a⟧) := Iff.rfl instance predicateShift_closedUnderIsomorphisms (a : A) [ClosedUnderIsomorphisms P] : ClosedUnderIsomorphisms (PredicateShift P a) where of_iso e hX := mem_of_iso P ((shiftFunctor C a).mapIso e) hX variable (A) @[simp] lemma predicateShift_zero [ClosedUnderIsomorphisms P] : PredicateShift P (0 : A) = P := by ext X exact mem_iff_of_iso P ((shiftFunctorZero C A).app X) variable {A} lemma predicateShift_predicateShift (a b c : A) (h : a + b = c) [ClosedUnderIsomorphisms P] : PredicateShift (PredicateShift P b) a = PredicateShift P c := by ext X exact mem_iff_of_iso _ ((shiftFunctorAdd' C a b c h).symm.app X) end CategoryTheory
CategoryTheory\Shift\Pullback.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.Shift.Basic import Mathlib.CategoryTheory.Preadditive.AdditiveFunctor /-! # The pullback of a shift by a monoid morphism Given a shift by a monoid `B` on a category `C` and a monoid morphism `φ : A →+ B`, we define a shift by `A` on a category `PullbackShift C φ` which is a type synonym for `C`. -/ namespace CategoryTheory open Limits Category variable (C : Type*) [Category C] {A B : Type*} [AddMonoid A] [AddMonoid B] (φ : A →+ B) [HasShift C B] /-- The category `PullbackShift C φ` is equipped with a shift such that for all `a`, the shift functor by `a` is `shiftFunctor C (φ a)`. -/ @[nolint unusedArguments] def PullbackShift (_ : A →+ B) [HasShift C B] := C instance : Category (PullbackShift C φ) := by dsimp only [PullbackShift] infer_instance attribute [local instance] endofunctorMonoidalCategory /-- The shift on `PullbackShift C φ` is obtained by precomposing the shift on `C` with the monoidal functor `Discrete.addMonoidalFunctor φ : Discrete A ⥤ Discrete B`. -/ noncomputable instance : HasShift (PullbackShift C φ) A where shift := (Discrete.addMonoidalFunctor φ).comp (@HasShift.shift C B _ _ _) instance [HasZeroObject C] : HasZeroObject (PullbackShift C φ) := by dsimp [PullbackShift] infer_instance instance [Preadditive C] : Preadditive (PullbackShift C φ) := by dsimp [PullbackShift] infer_instance instance [Preadditive C] (a : A) [(shiftFunctor C (φ a)).Additive] : (shiftFunctor (PullbackShift C φ) a).Additive := by change (shiftFunctor C (φ a)).Additive infer_instance /-- When `b = φ a`, this is the canonical isomorphism `shiftFunctor (PullbackShift C φ) a ≅ shiftFunctor C b`. -/ noncomputable def pullbackShiftIso (a : A) (b : B) (h : b = φ a) : shiftFunctor (PullbackShift C φ) a ≅ shiftFunctor C b := eqToIso (by subst h; rfl) variable {C} variable (X : PullbackShift C φ) (a₁ a₂ a₃ : A) (h : a₁ + a₂ = a₃) (b₁ b₂ b₃ : B) (h₁ : b₁ = φ a₁) (h₂ : b₂ = φ a₂) (h₃ : b₃ = φ a₃) lemma pullbackShiftFunctorZero_inv_app : (shiftFunctorZero _ A).inv.app X = (shiftFunctorZero C B).inv.app X ≫ (pullbackShiftIso C φ 0 0 (by simp)).inv.app X := by change (shiftFunctorZero C B).inv.app X ≫ _ = _ dsimp [Discrete.eqToHom] congr 2 apply eqToHom_map lemma pullbackShiftFunctorZero_hom_app : (shiftFunctorZero _ A).hom.app X = (pullbackShiftIso C φ 0 0 (by simp)).hom.app X ≫ (shiftFunctorZero C B).hom.app X := by rw [← cancel_epi ((shiftFunctorZero _ A).inv.app X), Iso.inv_hom_id_app, pullbackShiftFunctorZero_inv_app, assoc, Iso.inv_hom_id_app_assoc, Iso.inv_hom_id_app] rfl lemma pullbackShiftFunctorAdd'_inv_app : (shiftFunctorAdd' _ a₁ a₂ a₃ h).inv.app X = (shiftFunctor (PullbackShift C φ) a₂).map ((pullbackShiftIso C φ a₁ b₁ h₁).hom.app X) ≫ (pullbackShiftIso C φ a₂ b₂ h₂).hom.app _ ≫ (shiftFunctorAdd' C b₁ b₂ b₃ (by rw [h₁, h₂, h₃, ← h, φ.map_add])).inv.app X ≫ (pullbackShiftIso C φ a₃ b₃ h₃).inv.app X := by subst h₁ h₂ h obtain rfl : b₃ = φ a₁ + φ a₂ := by rw [h₃, φ.map_add] erw [Functor.map_id, id_comp, id_comp, shiftFunctorAdd'_eq_shiftFunctorAdd, shiftFunctorAdd'_eq_shiftFunctorAdd] change _ ≫ _ = _ congr 1 dsimp [Discrete.eqToHom] congr 2 apply eqToHom_map lemma pullbackShiftFunctorAdd'_hom_app : (shiftFunctorAdd' _ a₁ a₂ a₃ h).hom.app X = (pullbackShiftIso C φ a₃ b₃ h₃).hom.app X ≫ (shiftFunctorAdd' C b₁ b₂ b₃ (by rw [h₁, h₂, h₃, ← h, φ.map_add])).hom.app X ≫ (pullbackShiftIso C φ a₂ b₂ h₂).inv.app _ ≫ (shiftFunctor (PullbackShift C φ) a₂).map ((pullbackShiftIso C φ a₁ b₁ h₁).inv.app X) := by rw [← cancel_epi ((shiftFunctorAdd' _ a₁ a₂ a₃ h).inv.app X), Iso.inv_hom_id_app, pullbackShiftFunctorAdd'_inv_app φ X a₁ a₂ a₃ h b₁ b₂ b₃ h₁ h₂ h₃, assoc, assoc, assoc, Iso.inv_hom_id_app_assoc, Iso.inv_hom_id_app_assoc, Iso.hom_inv_id_app_assoc, ← Functor.map_comp, Iso.hom_inv_id_app, Functor.map_id] rfl end CategoryTheory
CategoryTheory\Shift\Quotient.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.Shift.CommShift import Mathlib.CategoryTheory.Shift.Induced import Mathlib.CategoryTheory.Quotient /-! # The shift on a quotient category Let `C` be a category equipped a shift by a monoid `A`. If we have a relation on morphisms `r : HomRel C` that is compatible with the shift (i.e. if two morphisms `f` and `g` are related, then `f⟦a⟧'` and `g⟦a⟧'` are also related for all `a : A`), then the quotient category `Quotient r` is equipped with a shift. The condition `r.IsCompatibleWithShift A` on the relation `r` is a class so that the shift can be automatically infered on the quotient category. -/ universe v v' u u' w open CategoryTheory Category variable {C : Type u} [Category.{v} C] {D : Type u'} [Category.{v'} D] (F : C ⥤ D) (r : HomRel C) (A : Type w) [AddMonoid A] [HasShift C A] [HasShift D A] namespace HomRel /-- A relation on morphisms is compatible with the shift by a monoid `A` when the relation if preserved by the shift. -/ class IsCompatibleWithShift : Prop := /-- the condition that the relation is preserved by the shift -/ condition : ∀ (a : A) ⦃X Y : C⦄ (f g : X ⟶ Y), r f g → r (f⟦a⟧') (g⟦a⟧') end HomRel namespace CategoryTheory /-- The shift by a monoid `A` induced on a quotient category `Quotient r` when the relation `r` is compatible with the shift. -/ noncomputable instance HasShift.quotient [r.IsCompatibleWithShift A] : HasShift (Quotient r) A := HasShift.induced (Quotient.functor r) A (fun a => Quotient.lift r (shiftFunctor C a ⋙ Quotient.functor r) (fun _ _ _ _ hfg => Quotient.sound r (HomRel.IsCompatibleWithShift.condition _ _ _ hfg))) (fun _ => Quotient.lift.isLift _ _ _) /-- The functor `Quotient.functor r : C ⥤ Quotient r` commutes with the shift. -/ noncomputable instance Quotient.functor_commShift [r.IsCompatibleWithShift A] : (Quotient.functor r).CommShift A := Functor.CommShift.ofInduced _ _ _ _ -- the construction is made irreducible in order to prevent timeouts and abuse of defeq attribute [irreducible] HasShift.quotient Quotient.functor_commShift namespace Quotient variable [r.IsCompatibleWithShift A] [F.CommShift A] (hF : ∀ (x y : C) (f₁ f₂ : x ⟶ y), r f₁ f₂ → F.map f₁ = F.map f₂) namespace LiftCommShift variable {A} /-- Auxiliary definition for `Quotient.liftCommShift`. -/ noncomputable def iso (a : A) : shiftFunctor (Quotient r) a ⋙ lift r F hF ≅ lift r F hF ⋙ shiftFunctor D a := natIsoLift r ((Functor.associator _ _ _).symm ≪≫ isoWhiskerRight ((functor r).commShiftIso a).symm _ ≪≫ Functor.associator _ _ _ ≪≫ isoWhiskerLeft _ (lift.isLift r F hF) ≪≫ F.commShiftIso a ≪≫ isoWhiskerRight (lift.isLift r F hF).symm _ ≪≫ Functor.associator _ _ _) @[simp] lemma iso_hom_app (a : A) (X : C) : (iso F r hF a).hom.app ((functor r).obj X) = (lift r F hF).map (((functor r).commShiftIso a).inv.app X) ≫ (F.commShiftIso a).hom.app X := by dsimp only [iso, natIsoLift] rw [natTransLift_app] dsimp erw [comp_id, id_comp, id_comp, id_comp, Functor.map_id, comp_id] @[simp] lemma iso_inv_app (a : A) (X : C) : (iso F r hF a).inv.app ((functor r).obj X) = (F.commShiftIso a).inv.app X ≫ (lift r F hF).map (((functor r).commShiftIso a).hom.app X) := by dsimp only [iso, natIsoLift] rw [natTransLift_app] dsimp erw [id_comp, comp_id, comp_id, comp_id, Functor.map_id, id_comp] attribute [irreducible] iso end LiftCommShift /-- When `r : HomRel C` is compatible with the shift by an additive monoid, and `F : C ⥤ D` is a functor which commutes with the shift and is compatible with `r`, then the induced functor `Quotient.lift r F _ : Quotient r ⥤ D` also commutes with the shift. -/ noncomputable instance liftCommShift : (Quotient.lift r F hF).CommShift A where iso := LiftCommShift.iso F r hF zero := by ext1 apply natTrans_ext ext X dsimp rw [LiftCommShift.iso_hom_app, (functor r).commShiftIso_zero, Functor.CommShift.isoZero_hom_app, Functor.CommShift.isoZero_inv_app, Functor.map_comp, assoc, F.commShiftIso_zero, Functor.CommShift.isoZero_hom_app, lift_map_functor_map, ← F.map_comp_assoc, Iso.inv_hom_id_app] dsimp [lift_obj_functor_obj] rw [F.map_id, id_comp] add a b := by ext1 apply natTrans_ext ext X dsimp rw [LiftCommShift.iso_hom_app, (functor r).commShiftIso_add, F.commShiftIso_add, Functor.CommShift.isoAdd_hom_app, Functor.CommShift.isoAdd_hom_app, Functor.CommShift.isoAdd_inv_app, Functor.map_comp, Functor.map_comp, Functor.map_comp, assoc, assoc, assoc, LiftCommShift.iso_hom_app, lift_map_functor_map] congr 1 rw [← cancel_epi ((shiftFunctor (Quotient r) b ⋙ lift r F hF).map (NatTrans.app (Functor.commShiftIso (functor r) a).hom X))] erw [(LiftCommShift.iso F r hF b).hom.naturality_assoc (((functor r).commShiftIso a).hom.app X), LiftCommShift.iso_hom_app, ← Functor.map_comp_assoc, Iso.hom_inv_id_app] dsimp simp only [Functor.comp_obj, assoc, ← Functor.map_comp_assoc, Iso.inv_hom_id_app, Functor.map_id, id_comp, Iso.hom_inv_id_app, lift_obj_functor_obj] instance liftCommShift_compatibility : NatTrans.CommShift (Quotient.lift.isLift r F hF).hom A where comm' a := by ext X dsimp erw [Functor.map_id, id_comp, comp_id] rw [Functor.commShiftIso_comp_hom_app] erw [LiftCommShift.iso_hom_app] rw [← Functor.map_comp_assoc, Iso.hom_inv_id_app, Functor.map_id, id_comp] end Quotient end CategoryTheory
CategoryTheory\Shift\ShiftedHom.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.Shift.CommShift import Mathlib.CategoryTheory.Preadditive.AdditiveFunctor /-! Shifted morphisms Given a category `C` endowed with a shift by an additive monoid `M` and two objects `X` and `Y` in `C`, we consider the types `ShiftedHom X Y m` defined as `X ⟶ (Y⟦m⟧)` for all `m : M`, and the composition on these shifted hom. ## TODO * redefine Ext-groups in abelian categories using `ShiftedHom` in the derived category. * study the `R`-module structures on `ShiftedHom` when `C` is `R`-linear -/ namespace CategoryTheory open Category variable {C : Type*} [Category C] {D : Type*} [Category D] {E : Type*} [Category E] {M : Type*} [AddMonoid M] [HasShift C M] [HasShift D M] [HasShift E M] /-- In a category `C` equipped with a shift by an additive monoid, this is the type of morphisms `X ⟶ (Y⟦n⟧)` for `m : M`. -/ def ShiftedHom (X Y : C) (m : M) : Type _ := X ⟶ (Y⟦m⟧) instance [Preadditive C] (X Y : C) (n : M) : AddCommGroup (ShiftedHom X Y n) := by dsimp only [ShiftedHom] infer_instance namespace ShiftedHom variable {X Y Z T : C} /-- The composition of `f : X ⟶ Y⟦a⟧` and `g : Y ⟶ Z⟦b⟧`, as a morphism `X ⟶ Z⟦c⟧` when `b + a = c`. -/ noncomputable def comp {a b c : M} (f : ShiftedHom X Y a) (g : ShiftedHom Y Z b) (h : b + a = c) : ShiftedHom X Z c := f ≫ g⟦a⟧' ≫ (shiftFunctorAdd' C b a c h).inv.app _ lemma comp_assoc {a₁ a₂ a₃ a₁₂ a₂₃ a : M} (α : ShiftedHom X Y a₁) (β : ShiftedHom Y Z a₂) (γ : ShiftedHom Z T a₃) (h₁₂ : a₂ + a₁ = a₁₂) (h₂₃ : a₃ + a₂ = a₂₃) (h : a₃ + a₂ + a₁ = a) : (α.comp β h₁₂).comp γ (show a₃ + a₁₂ = a by rw [← h₁₂, ← add_assoc, h]) = α.comp (β.comp γ h₂₃) (by rw [← h₂₃, h]) := by simp only [comp, assoc, Functor.map_comp, shiftFunctorAdd'_assoc_inv_app a₃ a₂ a₁ a₂₃ a₁₂ a h₂₃ h₁₂ h, ← NatTrans.naturality_assoc, Functor.comp_map] /-! In degree `0 : M`, shifted hom `ShiftedHom X Y 0` identify to morphisms `X ⟶ Y`. We generalize this to `m₀ : M` such that `m₀ : 0` as it shall be convenient when we apply this with `M := ℤ` and `m₀` the coercion of `0 : ℕ`. -/ /-- The element of `ShiftedHom X Y m₀` (when `m₀ = 0`) attached to a morphism `X ⟶ Y`. -/ noncomputable def mk₀ (m₀ : M) (hm₀ : m₀ = 0) (f : X ⟶ Y) : ShiftedHom X Y m₀ := f ≫ (shiftFunctorZero' C m₀ hm₀).inv.app Y /-- The bijection `(X ⟶ Y) ≃ ShiftedHom X Y m₀` when `m₀ = 0`. -/ @[simps apply] noncomputable def homEquiv (m₀ : M) (hm₀ : m₀ = 0) : (X ⟶ Y) ≃ ShiftedHom X Y m₀ where toFun f := mk₀ m₀ hm₀ f invFun g := g ≫ (shiftFunctorZero' C m₀ hm₀).hom.app Y left_inv f := by simp [mk₀] right_inv g := by simp [mk₀] lemma mk₀_comp (m₀ : M) (hm₀ : m₀ = 0) (f : X ⟶ Y) {a : M} (g : ShiftedHom Y Z a) : (mk₀ m₀ hm₀ f).comp g (by rw [hm₀, add_zero]) = f ≫ g := by subst hm₀ simp [comp, mk₀, shiftFunctorAdd'_add_zero_inv_app, shiftFunctorZero'] @[simp] lemma mk₀_id_comp (m₀ : M) (hm₀ : m₀ = 0) {a : M} (f : ShiftedHom X Y a) : (mk₀ m₀ hm₀ (𝟙 X)).comp f (by rw [hm₀, add_zero]) = f := by simp [mk₀_comp] lemma comp_mk₀ {a : M} (f : ShiftedHom X Y a) (m₀ : M) (hm₀ : m₀ = 0) (g : Y ⟶ Z) : f.comp (mk₀ m₀ hm₀ g) (by rw [hm₀, zero_add]) = f ≫ g⟦a⟧' := by subst hm₀ simp only [comp, shiftFunctorAdd'_zero_add_inv_app, mk₀, shiftFunctorZero', eqToIso_refl, Iso.refl_trans, ← Functor.map_comp, assoc, Iso.inv_hom_id_app, Functor.id_obj, comp_id] @[simp] lemma comp_mk₀_id {a : M} (f : ShiftedHom X Y a) (m₀ : M) (hm₀ : m₀ = 0) : f.comp (mk₀ m₀ hm₀ (𝟙 Y)) (by rw [hm₀, zero_add]) = f := by simp [comp_mk₀] @[simp 1100] lemma mk₀_comp_mk₀ (f : X ⟶ Y) (g : Y ⟶ Z) {a b c : M} (h : b + a = c) (ha : a = 0) (hb : b = 0) : (mk₀ a ha f).comp (mk₀ b hb g) h = mk₀ c (by rw [← h, ha, hb, add_zero]) (f ≫ g) := by subst ha hb obtain rfl : c = 0 := by rw [← h, zero_add] rw [mk₀_comp, mk₀, mk₀, assoc] @[simp] lemma mk₀_comp_mk₀_assoc (f : X ⟶ Y) (g : Y ⟶ Z) {a : M} (ha : a = 0) {d : M} (h : ShiftedHom Z T d) : (mk₀ a ha f).comp ((mk₀ a ha g).comp h (show _ = d by rw [ha, add_zero])) (show _ = d by rw [ha, add_zero]) = (mk₀ a ha (f ≫ g)).comp h (by rw [ha, add_zero]) := by subst ha rw [← comp_assoc, mk₀_comp_mk₀] all_goals simp section Preadditive variable [Preadditive C] variable (X Y) in @[simp] lemma mk₀_zero (m₀ : M) (hm₀ : m₀ = 0) : mk₀ m₀ hm₀ (0 : X ⟶ Y) = 0 := by simp [mk₀] @[simp] lemma comp_add [∀ (a : M), (shiftFunctor C a).Additive] {a b c : M} (α : ShiftedHom X Y a) (β₁ β₂ : ShiftedHom Y Z b) (h : b + a = c) : α.comp (β₁ + β₂) h = α.comp β₁ h + α.comp β₂ h := by rw [comp, comp, comp, Functor.map_add, Preadditive.add_comp, Preadditive.comp_add] @[simp] lemma add_comp {a b c : M} (α₁ α₂ : ShiftedHom X Y a) (β : ShiftedHom Y Z b) (h : b + a = c) : (α₁ + α₂).comp β h = α₁.comp β h + α₂.comp β h := by rw [comp, comp, comp, Preadditive.add_comp] @[simp] lemma comp_neg [∀ (a : M), (shiftFunctor C a).Additive] {a b c : M} (α : ShiftedHom X Y a) (β : ShiftedHom Y Z b) (h : b + a = c) : α.comp (-β) h = -α.comp β h := by rw [comp, comp, Functor.map_neg, Preadditive.neg_comp, Preadditive.comp_neg] @[simp] lemma neg_comp {a b c : M} (α : ShiftedHom X Y a) (β : ShiftedHom Y Z b) (h : b + a = c) : (-α).comp β h = -α.comp β h := by rw [comp, comp, Preadditive.neg_comp] variable (Z) in @[simp] lemma comp_zero [∀ (a : M), (shiftFunctor C a).PreservesZeroMorphisms] {a : M} (β : ShiftedHom X Y a) {b c : M} (h : b + a = c) : β.comp (0 : ShiftedHom Y Z b) h = 0 := by rw [comp, Functor.map_zero, Limits.zero_comp, Limits.comp_zero] variable (X) in @[simp] lemma zero_comp (a : M) {b c : M} (β : ShiftedHom Y Z b) (h : b + a = c) : (0 : ShiftedHom X Y a).comp β h = 0 := by rw [comp, Limits.zero_comp] end Preadditive /-- The action on `ShiftedHom` of a functor which commutes with the shift. -/ def map {a : M} (f : ShiftedHom X Y a) (F : C ⥤ D) [F.CommShift M] : ShiftedHom (F.obj X) (F.obj Y) a := F.map f ≫ (F.commShiftIso a).hom.app Y @[simp] lemma id_map {a : M} (f : ShiftedHom X Y a) : f.map (𝟭 C) = f := by simp [map, Functor.commShiftIso, Functor.CommShift.iso] lemma comp_map {a : M} (f : ShiftedHom X Y a) (F : C ⥤ D) [F.CommShift M] (G : D ⥤ E) [G.CommShift M] : f.map (F ⋙ G) = (f.map F).map G := by simp [map, Functor.commShiftIso_comp_hom_app] lemma map_comp {a b c : M} (f : ShiftedHom X Y a) (g : ShiftedHom Y Z b) (h : b + a = c) (F : C ⥤ D) [F.CommShift M] : (f.comp g h).map F = (f.map F).comp (g.map F) h := by dsimp [comp, map] simp only [Functor.map_comp, assoc] erw [← NatTrans.naturality_assoc] simp only [Functor.comp_map, F.commShiftIso_add' h, Functor.CommShift.isoAdd'_hom_app, ← Functor.map_comp_assoc, Iso.inv_hom_id_app, Functor.comp_obj, comp_id, assoc] end ShiftedHom end CategoryTheory
CategoryTheory\Shift\ShiftSequence.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.Shift.Basic import Mathlib.CategoryTheory.Preadditive.AdditiveFunctor /-! Sequences of functors from a category equipped with a shift Let `F : C ⥤ A` be a functor from a category `C` that is equipped with a shift by an additive monoid `M`. In this file, we define a typeclass `F.ShiftSequence M` which includes the data of a sequence of functors `F.shift a : C ⥤ A` for all `a : A`. For each `a : A`, we have an isomorphism `F.isoShift a : shiftFunctor C a ⋙ F ≅ F.shift a` which satisfies some coherence relations. This allows to state results (e.g. the long exact sequence of an homology functor (TODO)) using functors `F.shift a` rather than `shiftFunctor C a ⋙ F`. The reason for this design is that we can often choose functors `F.shift a` that have better definitional properties than `shiftFunctor C a ⋙ F`. For example, if `C` is the derived category (TODO) of an abelian category `A` and `F` is the homology functor in degree `0`, then for any `n : ℤ`, we may choose `F.shift n` to be the homology functor in degree `n`. -/ open CategoryTheory Category ZeroObject Limits variable {C A : Type*} [Category C] [Category A] (F : C ⥤ A) (M : Type*) [AddMonoid M] [HasShift C M] {G : Type*} [AddGroup G] [HasShift C G] namespace CategoryTheory namespace Functor /-- A shift sequence for a functor `F : C ⥤ A` when `C` is equipped with a shift by a monoid `M` involves a sequence of functor `sequence n : C ⥤ A` for all `n : M` which behave like `shiftFunctor C n ⋙ F`. -/ class ShiftSequence where /-- a sequence of functors -/ sequence : M → C ⥤ A /-- `sequence 0` identifies to the given functor -/ isoZero : sequence 0 ≅ F /-- compatibility isomorphism with the shift -/ shiftIso (n a a' : M) (ha' : n + a = a') : shiftFunctor C n ⋙ sequence a ≅ sequence a' shiftIso_zero (a : M) : shiftIso 0 a a (zero_add a) = isoWhiskerRight (shiftFunctorZero C M) _ ≪≫ leftUnitor _ shiftIso_add : ∀ (n m a a' a'' : M) (ha' : n + a = a') (ha'' : m + a' = a''), shiftIso (m + n) a a'' (by rw [add_assoc, ha', ha'']) = isoWhiskerRight (shiftFunctorAdd C m n) _ ≪≫ Functor.associator _ _ _ ≪≫ isoWhiskerLeft _ (shiftIso n a a' ha') ≪≫ shiftIso m a' a'' ha'' /-- The tautological shift sequence on a functor. -/ noncomputable def ShiftSequence.tautological : ShiftSequence F M where sequence n := shiftFunctor C n ⋙ F isoZero := isoWhiskerRight (shiftFunctorZero C M) F ≪≫ F.rightUnitor shiftIso n a a' ha' := (Functor.associator _ _ _).symm ≪≫ isoWhiskerRight (shiftFunctorAdd' C n a a' ha').symm _ shiftIso_zero a := by dsimp rw [shiftFunctorAdd'_zero_add] aesop_cat shiftIso_add n m a a' a'' ha' ha'' := by ext X dsimp simp only [id_comp, ← Functor.map_comp] congr simpa only [← cancel_epi ((shiftFunctor C a).map ((shiftFunctorAdd C m n).hom.app X)), shiftFunctorAdd'_eq_shiftFunctorAdd, ← Functor.map_comp_assoc, Iso.hom_inv_id_app, Functor.map_id, id_comp] using shiftFunctorAdd'_assoc_inv_app m n a (m+n) a' a'' rfl ha' (by rw [← ha'', ← ha', add_assoc]) X section variable {M} variable [F.ShiftSequence M] /-- The shifted functors given by the shift sequence. -/ def shift (n : M) : C ⥤ A := ShiftSequence.sequence F n /-- Compatibility isomorphism `shiftFunctor C n ⋙ F.shift a ≅ F.shift a'` when `n + a = a'`. -/ def shiftIso (n a a' : M) (ha' : n + a = a') : shiftFunctor C n ⋙ F.shift a ≅ F.shift a' := ShiftSequence.shiftIso n a a' ha' @[reassoc (attr := simp 1100)] lemma shiftIso_hom_naturality {X Y : C} (n a a' : M) (ha' : n + a = a') (f : X ⟶ Y) : (shift F a).map (f⟦n⟧') ≫ (shiftIso F n a a' ha').hom.app Y = (shiftIso F n a a' ha').hom.app X ≫ (shift F a').map f := (F.shiftIso n a a' ha').hom.naturality f @[reassoc (attr := simp 1100)] lemma shiftIso_inv_naturality {X Y : C} (n a a' : M) (ha' : n + a = a') (f : X ⟶ Y) : (shift F a').map f ≫ (shiftIso F n a a' ha').inv.app Y = (shiftIso F n a a' ha').inv.app X ≫ (shift F a).map (f⟦n⟧') := (F.shiftIso n a a' ha').inv.naturality f variable (M) /-- The canonical isomorphism `F.shift 0 ≅ F`. -/ def isoShiftZero : F.shift (0 : M) ≅ F := ShiftSequence.isoZero variable {M} /-- The canonical isomorphism `shiftFunctor C n ⋙ F ≅ F.shift n`. -/ def isoShift (n : M) : shiftFunctor C n ⋙ F ≅ F.shift n := isoWhiskerLeft _ (F.isoShiftZero M).symm ≪≫ F.shiftIso _ _ _ (add_zero n) @[reassoc] lemma isoShift_hom_naturality (n : M) {X Y : C} (f : X ⟶ Y) : F.map (f⟦n⟧') ≫ (F.isoShift n).hom.app Y = (F.isoShift n).hom.app X ≫ (F.shift n).map f := (F.isoShift n).hom.naturality f attribute [simp] isoShift_hom_naturality @[reassoc] lemma isoShift_inv_naturality (n : M) {X Y : C} (f : X ⟶ Y) : (F.shift n).map f ≫ (F.isoShift n).inv.app Y = (F.isoShift n).inv.app X ≫ F.map (f⟦n⟧') := (F.isoShift n).inv.naturality f lemma shiftIso_zero (a : M) : F.shiftIso 0 a a (zero_add a) = isoWhiskerRight (shiftFunctorZero C M) _ ≪≫ leftUnitor _ := ShiftSequence.shiftIso_zero a @[simp] lemma shiftIso_zero_hom_app (a : M) (X : C) : (F.shiftIso 0 a a (zero_add a)).hom.app X = (shift F a).map ((shiftFunctorZero C M).hom.app X) := by simp [F.shiftIso_zero a] @[simp] lemma shiftIso_zero_inv_app (a : M) (X : C) : (F.shiftIso 0 a a (zero_add a)).inv.app X = (shift F a).map ((shiftFunctorZero C M).inv.app X) := by simp [F.shiftIso_zero a] lemma shiftIso_add (n m a a' a'' : M) (ha' : n + a = a') (ha'' : m + a' = a'') : F.shiftIso (m + n) a a'' (by rw [add_assoc, ha', ha'']) = isoWhiskerRight (shiftFunctorAdd C m n) _ ≪≫ Functor.associator _ _ _ ≪≫ isoWhiskerLeft _ (F.shiftIso n a a' ha') ≪≫ F.shiftIso m a' a'' ha'' := ShiftSequence.shiftIso_add _ _ _ _ _ _ _ lemma shiftIso_add_hom_app (n m a a' a'' : M) (ha' : n + a = a') (ha'' : m + a' = a'') (X : C) : (F.shiftIso (m + n) a a'' (by rw [add_assoc, ha', ha''])).hom.app X = (shift F a).map ((shiftFunctorAdd C m n).hom.app X) ≫ (shiftIso F n a a' ha').hom.app ((shiftFunctor C m).obj X) ≫ (shiftIso F m a' a'' ha'').hom.app X := by simp [F.shiftIso_add n m a a' a'' ha' ha''] lemma shiftIso_add_inv_app (n m a a' a'' : M) (ha' : n + a = a') (ha'' : m + a' = a'') (X : C) : (F.shiftIso (m + n) a a'' (by rw [add_assoc, ha', ha''])).inv.app X = (shiftIso F m a' a'' ha'').inv.app X ≫ (shiftIso F n a a' ha').inv.app ((shiftFunctor C m).obj X) ≫ (shift F a).map ((shiftFunctorAdd C m n).inv.app X) := by simp [F.shiftIso_add n m a a' a'' ha' ha''] lemma shiftIso_add' (n m mn : M) (hnm : m + n = mn) (a a' a'' : M) (ha' : n + a = a') (ha'' : m + a' = a'') : F.shiftIso mn a a'' (by rw [← hnm, ← ha'', ← ha', add_assoc]) = isoWhiskerRight (shiftFunctorAdd' C m n _ hnm) _ ≪≫ Functor.associator _ _ _ ≪≫ isoWhiskerLeft _ (F.shiftIso n a a' ha') ≪≫ F.shiftIso m a' a'' ha'' := by subst hnm rw [shiftFunctorAdd'_eq_shiftFunctorAdd, shiftIso_add] lemma shiftIso_add'_hom_app (n m mn : M) (hnm : m + n = mn) (a a' a'' : M) (ha' : n + a = a') (ha'' : m + a' = a'') (X : C) : (F.shiftIso mn a a'' (by rw [← hnm, ← ha'', ← ha', add_assoc])).hom.app X = (shift F a).map ((shiftFunctorAdd' C m n mn hnm).hom.app X) ≫ (shiftIso F n a a' ha').hom.app ((shiftFunctor C m).obj X) ≫ (shiftIso F m a' a'' ha'').hom.app X := by simp [F.shiftIso_add' n m mn hnm a a' a'' ha' ha''] lemma shiftIso_add'_inv_app (n m mn : M) (hnm : m + n = mn) (a a' a'' : M) (ha' : n + a = a') (ha'' : m + a' = a'') (X : C) : (F.shiftIso mn a a'' (by rw [← hnm, ← ha'', ← ha', add_assoc])).inv.app X = (shiftIso F m a' a'' ha'').inv.app X ≫ (shiftIso F n a a' ha').inv.app ((shiftFunctor C m).obj X) ≫ (shift F a).map ((shiftFunctorAdd' C m n mn hnm).inv.app X) := by simp [F.shiftIso_add' n m mn hnm a a' a'' ha' ha''] @[reassoc] lemma shiftIso_hom_app_comp (n m mn : M) (hnm : m + n = mn) (a a' a'' : M) (ha' : n + a = a') (ha'' : m + a' = a'') (X : C) : (shiftIso F n a a' ha').hom.app ((shiftFunctor C m).obj X) ≫ (shiftIso F m a' a'' ha'').hom.app X = (shift F a).map ((shiftFunctorAdd' C m n mn hnm).inv.app X) ≫ (F.shiftIso mn a a'' (by rw [← hnm, ← ha'', ← ha', add_assoc])).hom.app X := by rw [F.shiftIso_add'_hom_app n m mn hnm a a' a'' ha' ha'', ← Functor.map_comp_assoc, Iso.inv_hom_id_app, Functor.map_id, id_comp] /-- The morphism `(F.shift a).obj X ⟶ (F.shift a').obj Y` induced by a morphism `f : X ⟶ Y⟦n⟧` when `n + a = a'`. -/ def shiftMap {X Y : C} {n : M} (f : X ⟶ Y⟦n⟧) (a a' : M) (ha' : n + a = a') : (F.shift a).obj X ⟶ (F.shift a').obj Y := (F.shift a).map f ≫ (F.shiftIso _ _ _ ha').hom.app Y @[reassoc] lemma shiftMap_comp {X Y Z : C} {n : M} (f : X ⟶ Y⟦n⟧) (g : Y ⟶ Z) (a a' : M) (ha' : n + a = a') : F.shiftMap (f ≫ g⟦n⟧') a a' ha' = F.shiftMap f a a' ha' ≫ (F.shift a').map g := by simp [shiftMap] @[reassoc] lemma shiftMap_comp' {X Y Z : C} {n : M} (f : X ⟶ Y) (g : Y ⟶ Z⟦n⟧) (a a' : M) (ha' : n + a = a') : F.shiftMap (f ≫ g) a a' ha' = (F.shift a).map f ≫ F.shiftMap g a a' ha' := by simp [shiftMap] /-- When `f : X ⟶ Y⟦m⟧`, `m + n = mn`, `n + a = a'` and `ha'' : m + a' = a''`, this lemma relates the two morphisms `F.shiftMap f a' a'' ha''` and `(F.shift a).map (f⟦n⟧')`. Indeed, via canonical isomorphisms, they both identity to morphisms `(F.shift a').obj X ⟶ (F.shift a'').obj Y`. -/ lemma shiftIso_hom_app_comp_shiftMap {X Y : C} {m : M} (f : X ⟶ Y⟦m⟧) (n mn : M) (hnm : m + n = mn) (a a' a'' : M) (ha' : n + a = a') (ha'' : m + a' = a'') : (F.shiftIso n a a' ha').hom.app X ≫ F.shiftMap f a' a'' ha'' = (F.shift a).map (f⟦n⟧') ≫ (F.shift a).map ((shiftFunctorAdd' C m n mn hnm).inv.app Y) ≫ (F.shiftIso mn a a'' (by rw [← ha'', ← ha', ← hnm, add_assoc])).hom.app Y := by simp only [F.shiftIso_add'_hom_app n m mn hnm a a' a'' ha' ha'' Y, ← Functor.map_comp_assoc, Iso.inv_hom_id_app, Functor.map_id, id_comp, comp_obj, shiftIso_hom_naturality_assoc, shiftMap] /-- If `f : X ⟶ Y⟦m⟧`, `n + m = 0` and `ha' : m + a = a'`, this lemma relates the two morphisms `F.shiftMap f a a' ha'` and `(F.shift a').map (f⟦n⟧')`. Indeed, via canonical isomorphisms, they both identify to morphisms `(F.shift a).obj X ⟶ (F.shift a').obj Y`. -/ lemma shiftIso_hom_app_comp_shiftMap_of_add_eq_zero [F.ShiftSequence G] {X Y : C} {m : G} (f : X ⟶ Y⟦m⟧) (n : G) (hnm : n + m = 0) (a a' : G) (ha' : m + a = a') : (F.shiftIso n a' a (by rw [← ha', ← add_assoc, hnm, zero_add])).hom.app X ≫ F.shiftMap f a a' ha' = (F.shift a').map (f⟦n⟧' ≫ (shiftFunctorCompIsoId C m n (by rw [← add_left_inj m, add_assoc, hnm, zero_add, add_zero])).hom.app Y) := by have hnm' : m + n = 0 := by rw [← add_left_inj m, add_assoc, hnm, zero_add, add_zero] dsimp simp [F.shiftIso_hom_app_comp_shiftMap f n 0 hnm' a' a, shiftIso_zero_hom_app, shiftFunctorCompIsoId] section variable [HasZeroMorphisms C] [HasZeroMorphisms A] [F.PreservesZeroMorphisms] [∀ (n : M), (shiftFunctor C n).PreservesZeroMorphisms] instance (n : M) : (F.shift n).PreservesZeroMorphisms := preservesZeroMorphisms_of_iso (F.isoShift n) @[simp] lemma shiftMap_zero (X Y : C) (n a a' : M) (ha' : n + a = a') : F.shiftMap (0 : X ⟶ Y⟦n⟧) a a' ha' = 0 := by simp [shiftMap] end section variable [Preadditive C] [Preadditive A] [F.Additive] [∀ (n : M), (shiftFunctor C n).Additive] instance (n : M) : (F.shift n).Additive := additive_of_iso (F.isoShift n) end end end Functor end CategoryTheory
CategoryTheory\Shift\SingleFunctors.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.Shift.CommShift /-! # Functors from a category to a category with a shift Given a category `C`, and a category `D` equipped with a shift by a monoid `A`, we define a structure `SingleFunctors C D A` which contains the data of functors `functor a : C ⥤ D` for all `a : A` and isomorphisms `shiftIso n a a' h : functor a' ⋙ shiftFunctor D n ≅ functor a` whenever `n + a = a'`. These isomorphisms should satisfy certain compatibilities with respect to the shift on `D`. This notion is similar to `Functor.ShiftSequence` which can be used in order to attach shifted versions of a homological functor `D ⥤ C` with `D` a triangulated category and `C` an abelian category. However, the definition `SingleFunctors` is for functors in the other direction: it is meant to ease the formalization of the compatibilities with shifts of the functors `C ⥤ CochainComplex C ℤ` (or `C ⥤ DerivedCategory C` (TODO)) which sends an object `X : C` to a complex where `X` sits in a single degree. -/ open CategoryTheory Category ZeroObject Limits variable (C D E E' : Type*) [Category C] [Category D] [Category E] [Category E'] (A : Type*) [AddMonoid A] [HasShift D A] [HasShift E A] [HasShift E' A] namespace CategoryTheory /-- The type of families of functors `A → C ⥤ D` which are compatible with the shift by `A` on the category `D`. -/ structure SingleFunctors where /-- a family of functors `C ⥤ D` indexed by the elements of the additive monoid `A` -/ functor (a : A) : C ⥤ D /-- the isomorphism `functor a' ⋙ shiftFunctor D n ≅ functor a` when `n + a = a'` -/ shiftIso (n a a' : A) (ha' : n + a = a') : functor a' ⋙ shiftFunctor D n ≅ functor a /-- `shiftIso 0` is the obvious isomorphism. -/ shiftIso_zero (a : A) : shiftIso 0 a a (zero_add a) = isoWhiskerLeft _ (shiftFunctorZero D A) /-- `shiftIso (m + n)` is determined by `shiftIso m` and `shiftIso n`. -/ shiftIso_add (n m a a' a'' : A) (ha' : n + a = a') (ha'' : m + a' = a'') : shiftIso (m + n) a a'' (by rw [add_assoc, ha', ha'']) = isoWhiskerLeft _ (shiftFunctorAdd D m n) ≪≫ (Functor.associator _ _ _).symm ≪≫ isoWhiskerRight (shiftIso m a' a'' ha'') _ ≪≫ shiftIso n a a' ha' variable {C D E A} variable (F G H : SingleFunctors C D A) namespace SingleFunctors lemma shiftIso_add_hom_app (n m a a' a'' : A) (ha' : n + a = a') (ha'' : m + a' = a'') (X : C) : (F.shiftIso (m + n) a a'' (by rw [add_assoc, ha', ha''])).hom.app X = (shiftFunctorAdd D m n).hom.app ((F.functor a'').obj X) ≫ ((F.shiftIso m a' a'' ha'').hom.app X)⟦n⟧' ≫ (F.shiftIso n a a' ha').hom.app X := by simp [F.shiftIso_add n m a a' a'' ha' ha''] lemma shiftIso_add_inv_app (n m a a' a'' : A) (ha' : n + a = a') (ha'' : m + a' = a'') (X : C) : (F.shiftIso (m + n) a a'' (by rw [add_assoc, ha', ha''])).inv.app X = (F.shiftIso n a a' ha').inv.app X ≫ ((F.shiftIso m a' a'' ha'').inv.app X)⟦n⟧' ≫ (shiftFunctorAdd D m n).inv.app ((F.functor a'').obj X) := by simp [F.shiftIso_add n m a a' a'' ha' ha''] lemma shiftIso_add' (n m mn : A) (hnm : m + n = mn) (a a' a'' : A) (ha' : n + a = a') (ha'' : m + a' = a'') : F.shiftIso mn a a'' (by rw [← hnm, ← ha'', ← ha', add_assoc]) = isoWhiskerLeft _ (shiftFunctorAdd' D m n mn hnm) ≪≫ (Functor.associator _ _ _).symm ≪≫ isoWhiskerRight (F.shiftIso m a' a'' ha'') _ ≪≫ F.shiftIso n a a' ha' := by subst hnm rw [shiftFunctorAdd'_eq_shiftFunctorAdd, shiftIso_add] lemma shiftIso_add'_hom_app (n m mn : A) (hnm : m + n = mn) (a a' a'' : A) (ha' : n + a = a') (ha'' : m + a' = a'') (X : C) : (F.shiftIso mn a a'' (by rw [← hnm, ← ha'', ← ha', add_assoc])).hom.app X = (shiftFunctorAdd' D m n mn hnm).hom.app ((F.functor a'').obj X) ≫ ((F.shiftIso m a' a'' ha'').hom.app X)⟦n⟧' ≫ (F.shiftIso n a a' ha').hom.app X := by simp [F.shiftIso_add' n m mn hnm a a' a'' ha' ha''] lemma shiftIso_add'_inv_app (n m mn : A) (hnm : m + n = mn) (a a' a'' : A) (ha' : n + a = a') (ha'' : m + a' = a'') (X : C) : (F.shiftIso mn a a'' (by rw [← hnm, ← ha'', ← ha', add_assoc])).inv.app X = (F.shiftIso n a a' ha').inv.app X ≫ ((F.shiftIso m a' a'' ha'').inv.app X)⟦n⟧' ≫ (shiftFunctorAdd' D m n mn hnm).inv.app ((F.functor a'').obj X) := by simp [F.shiftIso_add' n m mn hnm a a' a'' ha' ha''] @[simp] lemma shiftIso_zero_hom_app (a : A) (X : C) : (F.shiftIso 0 a a (zero_add a)).hom.app X = (shiftFunctorZero D A).hom.app _ := by rw [shiftIso_zero] rfl @[simp] lemma shiftIso_zero_inv_app (a : A) (X : C) : (F.shiftIso 0 a a (zero_add a)).inv.app X = (shiftFunctorZero D A).inv.app _ := by rw [shiftIso_zero] rfl /-- The morphisms in the category `SingleFunctors C D A` -/ @[ext] structure Hom where /-- a family of natural transformations `F.functor a ⟶ G.functor a` -/ hom (a : A) : F.functor a ⟶ G.functor a comm (n a a' : A) (ha' : n + a = a') : (F.shiftIso n a a' ha').hom ≫ hom a = whiskerRight (hom a') (shiftFunctor D n) ≫ (G.shiftIso n a a' ha').hom := by aesop_cat namespace Hom attribute [reassoc] comm attribute [local simp] comm comm_assoc /-- The identity morphism in `SingleFunctors C D A`. -/ @[simps] def id : Hom F F where hom a := 𝟙 _ variable {F G H} /-- The composition of morphisms in `SingleFunctors C D A`. -/ @[simps] def comp (α : Hom F G) (β : Hom G H) : Hom F H where hom a := α.hom a ≫ β.hom a end Hom instance : Category (SingleFunctors C D A) where Hom := Hom id := Hom.id comp := Hom.comp @[simp] lemma id_hom (a : A) : Hom.hom (𝟙 F) a = 𝟙 _ := rfl variable {F G H} @[simp, reassoc] lemma comp_hom (f : F ⟶ G) (g : G ⟶ H) (a : A) : (f ≫ g).hom a = f.hom a ≫ g.hom a := rfl @[ext] lemma hom_ext (f g : F ⟶ G) (h : f.hom = g.hom) : f = g := Hom.ext h /-- Construct an isomorphism in `SingleFunctors C D A` by giving level-wise isomorphisms and checking compatibility only in the forward direction. -/ @[simps] def isoMk (iso : ∀ a, (F.functor a ≅ G.functor a)) (comm : ∀ (n a a' : A) (ha' : n + a = a'), (F.shiftIso n a a' ha').hom ≫ (iso a).hom = whiskerRight (iso a').hom (shiftFunctor D n) ≫ (G.shiftIso n a a' ha').hom) : F ≅ G where hom := { hom := fun a => (iso a).hom comm := comm } inv := { hom := fun a => (iso a).inv comm := fun n a a' ha' => by dsimp only rw [← cancel_mono (iso a).hom, assoc, assoc, Iso.inv_hom_id, comp_id, comm, ← whiskerRight_comp_assoc, Iso.inv_hom_id, whiskerRight_id', id_comp] } variable (C D) /-- The evaluation `SingleFunctors C D A ⥤ C ⥤ D` for some `a : A`. -/ @[simps] def evaluation (a : A) : SingleFunctors C D A ⥤ C ⥤ D where obj F := F.functor a map {F G} φ := φ.hom a variable {C D} @[reassoc (attr := simp)] lemma hom_inv_id_hom (e : F ≅ G) (n : A) : e.hom.hom n ≫ e.inv.hom n = 𝟙 _ := by rw [← comp_hom, e.hom_inv_id, id_hom] @[reassoc (attr := simp)] lemma inv_hom_id_hom (e : F ≅ G) (n : A) : e.inv.hom n ≫ e.hom.hom n = 𝟙 _ := by rw [← comp_hom, e.inv_hom_id, id_hom] @[reassoc (attr := simp)] lemma hom_inv_id_hom_app (e : F ≅ G) (n : A) (X : C) : (e.hom.hom n).app X ≫ (e.inv.hom n).app X = 𝟙 _ := by rw [← NatTrans.comp_app, hom_inv_id_hom, NatTrans.id_app] @[reassoc (attr := simp)] lemma inv_hom_id_hom_app (e : F ≅ G) (n : A) (X : C) : (e.inv.hom n).app X ≫ (e.hom.hom n).app X = 𝟙 _ := by rw [← NatTrans.comp_app, inv_hom_id_hom, NatTrans.id_app] instance (f : F ⟶ G) [IsIso f] (n : A) : IsIso (f.hom n) := (inferInstance : IsIso ((evaluation C D n).map f)) variable (F) /-- Given `F : SingleFunctors C D A`, and a functor `G : D ⥤ E` which commutes with the shift by `A`, this is the "composition" of `F` and `G` in `SingleFunctors C E A`. -/ @[simps! functor shiftIso_hom_app shiftIso_inv_app] def postcomp (G : D ⥤ E) [G.CommShift A] : SingleFunctors C E A where functor a := F.functor a ⋙ G shiftIso n a a' ha' := Functor.associator _ _ _ ≪≫ isoWhiskerLeft _ (G.commShiftIso n).symm ≪≫ (Functor.associator _ _ _).symm ≪≫ isoWhiskerRight (F.shiftIso n a a' ha') G shiftIso_zero a := by ext X dsimp simp only [Functor.commShiftIso_zero, Functor.CommShift.isoZero_inv_app, SingleFunctors.shiftIso_zero_hom_app,id_comp, assoc, ← G.map_comp, Iso.inv_hom_id_app, Functor.map_id, Functor.id_obj, comp_id] shiftIso_add n m a a' a'' ha' ha'' := by ext X dsimp simp only [F.shiftIso_add_hom_app n m a a' a'' ha' ha'', Functor.commShiftIso_add, Functor.CommShift.isoAdd_inv_app, Functor.map_comp, id_comp, assoc, Functor.commShiftIso_inv_naturality_assoc] simp only [← G.map_comp, Iso.inv_hom_id_app_assoc] variable (C A) /-- The functor `SingleFunctors C D A ⥤ SingleFunctors C E A` given by the postcomposition by a functor `G : D ⥤ E` which commutes with the shift. -/ def postcompFunctor (G : D ⥤ E) [G.CommShift A] : SingleFunctors C D A ⥤ SingleFunctors C E A where obj F := F.postcomp G map {F₁ F₂} φ := { hom := fun a => whiskerRight (φ.hom a) G comm := fun n a a' ha' => by ext X simpa using G.congr_map (congr_app (φ.comm n a a' ha') X) } variable {C E' A} /-- The canonical isomorphism `(F.postcomp G).postcomp G' ≅ F.postcomp (G ⋙ G')`. -/ @[simps!] def postcompPostcompIso (G : D ⥤ E) (G' : E ⥤ E') [G.CommShift A] [G'.CommShift A] : (F.postcomp G).postcomp G' ≅ F.postcomp (G ⋙ G') := isoMk (fun a => Functor.associator _ _ _) (fun n a a' ha' => by ext X simp [Functor.commShiftIso_comp_inv_app]) /-- The isomorphism `F.postcomp G ≅ F.postcomp G'` induced by an isomorphism `e : G ≅ G'` which commutes with the shift. -/ @[simps!] def postcompIsoOfIso {G G' : D ⥤ E} (e : G ≅ G') [G.CommShift A] [G'.CommShift A] [NatTrans.CommShift e.hom A] : F.postcomp G ≅ F.postcomp G' := isoMk (fun a => isoWhiskerLeft (F.functor a) e) (fun n a a' ha' => by ext X dsimp simp [NatTrans.CommShift.shift_app e.hom n]) end SingleFunctors end CategoryTheory
CategoryTheory\Sigma\Basic.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.Whiskering import Mathlib.CategoryTheory.Functor.FullyFaithful import Mathlib.CategoryTheory.NatIso /-! # Disjoint union of categories We define the category structure on a sigma-type (disjoint union) of categories. -/ namespace CategoryTheory namespace Sigma universe w₁ w₂ w₃ v₁ v₂ u₁ u₂ variable {I : Type w₁} {C : I → Type u₁} [∀ i, Category.{v₁} (C i)] /-- The type of morphisms of a disjoint union of categories: for `X : C i` and `Y : C j`, a morphism `(i, X) ⟶ (j, Y)` if `i = j` is just a morphism `X ⟶ Y`, and if `i ≠ j` there are no such morphisms. -/ inductive SigmaHom : (Σi, C i) → (Σi, C i) → Type max w₁ v₁ u₁ | mk : ∀ {i : I} {X Y : C i}, (X ⟶ Y) → SigmaHom ⟨i, X⟩ ⟨i, Y⟩ namespace SigmaHom /-- The identity morphism on an object. -/ def id : ∀ X : Σi, C i, SigmaHom X X | ⟨_, _⟩ => mk (𝟙 _) -- Porting note: reordered universes instance (X : Σi, C i) : Inhabited (SigmaHom X X) := ⟨id X⟩ /-- Composition of sigma homomorphisms. -/ def comp : ∀ {X Y Z : Σi, C i}, SigmaHom X Y → SigmaHom Y Z → SigmaHom X Z | _, _, _, mk f, mk g => mk (f ≫ g) -- Porting note: reordered universes instance : CategoryStruct (Σi, C i) where Hom := SigmaHom id := id comp f g := comp f g @[simp] lemma comp_def (i : I) (X Y Z : C i) (f : X ⟶ Y) (g : Y ⟶ Z) : comp (mk f) (mk g) = mk (f ≫ g) := rfl lemma assoc : ∀ {X Y Z W : Σi, C i} (f : X ⟶ Y) (g : Y ⟶ Z) (h : Z ⟶ W), (f ≫ g) ≫ h = f ≫ g ≫ h | _, _, _, _, mk _, mk _, mk _ => congr_arg mk (Category.assoc _ _ _) lemma id_comp : ∀ {X Y : Σi, C i} (f : X ⟶ Y), 𝟙 X ≫ f = f | _, _, mk _ => congr_arg mk (Category.id_comp _) lemma comp_id : ∀ {X Y : Σi, C i} (f : X ⟶ Y), f ≫ 𝟙 Y = f | _, _, mk _ => congr_arg mk (Category.comp_id _) end SigmaHom instance sigma : Category (Σi, C i) where id_comp := SigmaHom.id_comp comp_id := SigmaHom.comp_id assoc := SigmaHom.assoc /-- The inclusion functor into the disjoint union of categories. -/ @[simps map] def incl (i : I) : C i ⥤ Σi, C i where obj X := ⟨i, X⟩ map := SigmaHom.mk @[simp] lemma incl_obj {i : I} (X : C i) : (incl i).obj X = ⟨i, X⟩ := rfl instance (i : I) : Functor.Full (incl i : C i ⥤ Σi, C i) where map_surjective := fun ⟨f⟩ => ⟨f, rfl⟩ instance (i : I) : Functor.Faithful (incl i : C i ⥤ Σi, C i) where map_injective {_ _ _ _} h := by injection h section variable {D : Type u₂} [Category.{v₂} D] (F : ∀ i, C i ⥤ D) /-- To build a natural transformation over the sigma category, it suffices to specify it restricted to each subcategory. -/ def natTrans {F G : (Σi, C i) ⥤ D} (h : ∀ i : I, incl i ⋙ F ⟶ incl i ⋙ G) : F ⟶ G where app := fun ⟨j, X⟩ => (h j).app X naturality := by rintro ⟨j, X⟩ ⟨_, _⟩ ⟨f⟩ apply (h j).naturality @[simp] lemma natTrans_app {F G : (Σi, C i) ⥤ D} (h : ∀ i : I, incl i ⋙ F ⟶ incl i ⋙ G) (i : I) (X : C i) : (natTrans h).app ⟨i, X⟩ = (h i).app X := rfl /-- (Implementation). An auxiliary definition to build the functor `desc`. -/ def descMap : ∀ X Y : Σi, C i, (X ⟶ Y) → ((F X.1).obj X.2 ⟶ (F Y.1).obj Y.2) | _, _, SigmaHom.mk g => (F _).map g -- Porting note: reordered universes /-- Given a collection of functors `F i : C i ⥤ D`, we can produce a functor `(Σ i, C i) ⥤ D`. The produced functor `desc F` satisfies: `incl i ⋙ desc F ≅ F i`, i.e. restricted to just the subcategory `C i`, `desc F` agrees with `F i`, and it is unique (up to natural isomorphism) with this property. This witnesses that the sigma-type is the coproduct in Cat. -/ @[simps obj] def desc : (Σi, C i) ⥤ D where obj X := (F X.1).obj X.2 map g := descMap F _ _ g map_id := by rintro ⟨i, X⟩ apply (F i).map_id map_comp := by rintro ⟨i, X⟩ ⟨_, Y⟩ ⟨_, Z⟩ ⟨f⟩ ⟨g⟩ apply (F i).map_comp @[simp] lemma desc_map_mk {i : I} (X Y : C i) (f : X ⟶ Y) : (desc F).map (SigmaHom.mk f) = (F i).map f := rfl -- We hand-generate the simp lemmas about this since they come out cleaner. /-- This shows that when `desc F` is restricted to just the subcategory `C i`, `desc F` agrees with `F i`. -/ def inclDesc (i : I) : incl i ⋙ desc F ≅ F i := NatIso.ofComponents fun X => Iso.refl _ @[simp] lemma inclDesc_hom_app (i : I) (X : C i) : (inclDesc F i).hom.app X = 𝟙 ((F i).obj X) := rfl @[simp] lemma inclDesc_inv_app (i : I) (X : C i) : (inclDesc F i).inv.app X = 𝟙 ((F i).obj X) := rfl /-- If `q` when restricted to each subcategory `C i` agrees with `F i`, then `q` is isomorphic to `desc F`. -/ def descUniq (q : (Σi, C i) ⥤ D) (h : ∀ i, incl i ⋙ q ≅ F i) : q ≅ desc F := NatIso.ofComponents (fun ⟨i, X⟩ => (h i).app X) <| by rintro ⟨i, X⟩ ⟨_, _⟩ ⟨f⟩ apply (h i).hom.naturality f @[simp] lemma descUniq_hom_app (q : (Σi, C i) ⥤ D) (h : ∀ i, incl i ⋙ q ≅ F i) (i : I) (X : C i) : (descUniq F q h).hom.app ⟨i, X⟩ = (h i).hom.app X := rfl @[simp] lemma descUniq_inv_app (q : (Σi, C i) ⥤ D) (h : ∀ i, incl i ⋙ q ≅ F i) (i : I) (X : C i) : (descUniq F q h).inv.app ⟨i, X⟩ = (h i).inv.app X := rfl /-- If `q₁` and `q₂` when restricted to each subcategory `C i` agree, then `q₁` and `q₂` are isomorphic. -/ @[simps] def natIso {q₁ q₂ : (Σi, C i) ⥤ D} (h : ∀ i, incl i ⋙ q₁ ≅ incl i ⋙ q₂) : q₁ ≅ q₂ where hom := natTrans fun i => (h i).hom inv := natTrans fun i => (h i).inv end section variable (C) {J : Type w₂} (g : J → I) /-- A function `J → I` induces a functor `Σ j, C (g j) ⥤ Σ i, C i`. -/ def map : (Σj : J, C (g j)) ⥤ Σi : I, C i := desc fun j => incl (g j) @[simp] lemma map_obj (j : J) (X : C (g j)) : (Sigma.map C g).obj ⟨j, X⟩ = ⟨g j, X⟩ := rfl @[simp] lemma map_map {j : J} {X Y : C (g j)} (f : X ⟶ Y) : (Sigma.map C g).map (SigmaHom.mk f) = SigmaHom.mk f := rfl /-- The functor `Sigma.map C g` restricted to the subcategory `C j` acts as the inclusion of `g j`. -/ @[simps!] def inclCompMap (j : J) : incl j ⋙ map C g ≅ incl (g j) := Iso.refl _ variable (I) /-- The functor `Sigma.map` applied to the identity function is just the identity functor. -/ @[simps!] def mapId : map C (id : I → I) ≅ 𝟭 (Σi, C i) := natIso fun i => NatIso.ofComponents fun X => Iso.refl _ variable {I} {K : Type w₃} -- Porting note: Had to expand (C ∘ g) to (fun x => C (g x)) in lemma statement -- so that the suitable category instances could be found /-- The functor `Sigma.map` applied to a composition is a composition of functors. -/ @[simps!] def mapComp (f : K → J) (g : J → I) : map (fun x ↦ C (g x)) f ⋙ (map C g : _) ≅ map C (g ∘ f) := (descUniq _ _) fun k => (isoWhiskerRight (inclCompMap (fun i => C (g i)) f k) (map C g : _) : _) ≪≫ inclCompMap _ _ _ end namespace Functor -- variable {C} variable {D : I → Type u₁} [∀ i, Category.{v₁} (D i)] /-- Assemble an `I`-indexed family of functors into a functor between the sigma types. -/ def sigma (F : ∀ i, C i ⥤ D i) : (Σi, C i) ⥤ Σi, D i := desc fun i => F i ⋙ incl i end Functor namespace natTrans variable {D : I → Type u₁} [∀ i, Category.{v₁} (D i)] variable {F G : ∀ i, C i ⥤ D i} /-- Assemble an `I`-indexed family of natural transformations into a single natural transformation. -/ def sigma (α : ∀ i, F i ⟶ G i) : Functor.sigma F ⟶ Functor.sigma G where app f := SigmaHom.mk ((α f.1).app _) naturality := by rintro ⟨i, X⟩ ⟨_, _⟩ ⟨f⟩ change SigmaHom.mk _ = SigmaHom.mk _ rw [(α i).naturality] end natTrans end Sigma end CategoryTheory
CategoryTheory\Sites\Abelian.lean
/- Copyright (c) 2022 Jujian Zhang. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Adam Topaz, Jujian Zhang -/ import Mathlib.CategoryTheory.Abelian.FunctorCategory import Mathlib.CategoryTheory.Preadditive.AdditiveFunctor import Mathlib.CategoryTheory.Abelian.Transfer import Mathlib.CategoryTheory.Sites.Limits /-! # Category of sheaves is abelian Let `C, D` be categories and `J` be a grothendieck topology on `C`, when `D` is abelian and sheafification is possible in `C`, `Sheaf J D` is abelian as well (`sheafIsAbelian`). Hence, `presheafToSheaf` is an additive functor (`presheafToSheaf_additive`). -/ noncomputable section namespace CategoryTheory open CategoryTheory.Limits section Abelian universe w' w v u variable {C : Type u} [Category.{v} C] variable {D : Type w} [Category.{w'} D] [Abelian D] variable {J : GrothendieckTopology C} variable [HasSheafify J D] instance sheafIsAbelian : Abelian (Sheaf J D) := let adj := sheafificationAdjunction J D abelianOfAdjunction _ _ (asIso adj.counit) adj attribute [local instance] preservesBinaryBiproductsOfPreservesBinaryProducts instance presheafToSheaf_additive : (presheafToSheaf J D).Additive := (presheafToSheaf J D).additive_of_preservesBinaryBiproducts end Abelian end CategoryTheory
CategoryTheory\Sites\Adjunction.lean
/- Copyright (c) 2021 Adam Topaz. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Adam Topaz, Joël Riou -/ import Mathlib.CategoryTheory.Adjunction.Whiskering import Mathlib.CategoryTheory.Sites.PreservesSheafification /-! In this file, we show that an adjunction `G ⊣ F` induces an adjunction between categories of sheaves. We also show that `G` preserves sheafification. -/ namespace CategoryTheory open GrothendieckTopology CategoryTheory Limits Opposite universe v₁ v₂ u₁ u₂ variable {C : Type u₁} [Category.{v₁} C] (J : GrothendieckTopology C) variable {D : Type u₂} [Category.{v₂} D] variable {E : Type*} [Category E] variable {F : D ⥤ E} {G : E ⥤ D} /-- The forgetful functor from `Sheaf J D` to sheaves of types, for a concrete category `D` whose forgetful functor preserves the correct limits. -/ abbrev sheafForget [ConcreteCategory D] [HasSheafCompose J (forget D)] : Sheaf J D ⥤ SheafOfTypes J := sheafCompose J (forget D) ⋙ (sheafEquivSheafOfTypes J).functor namespace Sheaf noncomputable section /-- An auxiliary definition to be used in defining `CategoryTheory.Sheaf.adjunction` below. -/ @[simps] def composeEquiv [HasWeakSheafify J D] [HasSheafCompose J F] (adj : G ⊣ F) (X : Sheaf J E) (Y : Sheaf J D) : ((composeAndSheafify J G).obj X ⟶ Y) ≃ (X ⟶ (sheafCompose J F).obj Y) := let A := adj.whiskerRight Cᵒᵖ { toFun := fun η => ⟨A.homEquiv _ _ (toSheafify J _ ≫ η.val)⟩ invFun := fun γ => ⟨sheafifyLift J ((A.homEquiv _ _).symm ((sheafToPresheaf _ _).map γ)) Y.2⟩ left_inv := by intro η ext1 dsimp symm apply sheafifyLift_unique rw [Equiv.symm_apply_apply] right_inv := by intro γ ext1 dsimp -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644 erw [toSheafify_sheafifyLift, Equiv.apply_symm_apply] } -- These lemmas have always been bad (#7657), but leanprover/lean4#2644 made `simp` start noticing attribute [nolint simpNF] CategoryTheory.Sheaf.composeEquiv_apply_val CategoryTheory.Sheaf.composeEquiv_symm_apply_val /-- An adjunction `adj : G ⊣ F` with `F : D ⥤ E` and `G : E ⥤ D` induces an adjunction between `Sheaf J D` and `Sheaf J E`, in contexts where one can sheafify `D`-valued presheaves, and `F` preserves the correct limits. -/ @[simps! unit_app_val counit_app_val] def adjunction [HasWeakSheafify J D] [HasSheafCompose J F] (adj : G ⊣ F) : composeAndSheafify J G ⊣ sheafCompose J F := Adjunction.mkOfHomEquiv { homEquiv := composeEquiv J adj homEquiv_naturality_left_symm := fun f g => by ext1 dsimp [composeEquiv] rw [sheafifyMap_sheafifyLift] erw [Adjunction.homEquiv_naturality_left_symm] rw [whiskeringRight_obj_map] rfl homEquiv_naturality_right := fun f g => by ext dsimp [composeEquiv] erw [Adjunction.homEquiv_unit, Adjunction.homEquiv_unit] dsimp simp } instance [HasWeakSheafify J D] [F.IsRightAdjoint] : (sheafCompose J F).IsRightAdjoint := (adjunction J (Adjunction.ofIsRightAdjoint F)).isRightAdjoint instance [HasWeakSheafify J D] [G.IsLeftAdjoint] : (composeAndSheafify J G).IsLeftAdjoint := (adjunction J (Adjunction.ofIsLeftAdjoint G)).isLeftAdjoint lemma preservesSheafification_of_adjunction (adj : G ⊣ F) : J.PreservesSheafification G where le P Q f hf := by have := adj.isRightAdjoint rw [MorphismProperty.inverseImage_iff] dsimp intro R hR rw [← ((adj.whiskerRight Cᵒᵖ).homEquiv P R).comp_bijective] convert (((adj.whiskerRight Cᵒᵖ).homEquiv Q R).trans (hf.homEquiv (R ⋙ F) ((sheafCompose J F).obj ⟨R, hR⟩).cond)).bijective ext g X dsimp [Adjunction.whiskerRight, Adjunction.mkOfUnitCounit] simp instance [G.IsLeftAdjoint] : J.PreservesSheafification G := preservesSheafification_of_adjunction J (Adjunction.ofIsLeftAdjoint G) section ForgetToType variable [HasWeakSheafify J D] [ConcreteCategory D] [HasSheafCompose J (forget D)] /-- This is the functor sending a sheaf of types `X` to the sheafification of `X ⋙ G`. -/ abbrev composeAndSheafifyFromTypes (G : Type max v₁ u₁ ⥤ D) : SheafOfTypes J ⥤ Sheaf J D := (sheafEquivSheafOfTypes J).inverse ⋙ composeAndSheafify _ G /-- A variant of the adjunction between sheaf categories, in the case where the right adjoint is the forgetful functor to sheaves of types. -/ def adjunctionToTypes {G : Type max v₁ u₁ ⥤ D} (adj : G ⊣ forget D) : composeAndSheafifyFromTypes J G ⊣ sheafForget J := (sheafEquivSheafOfTypes J).symm.toAdjunction.comp (adjunction J adj) @[simp] theorem adjunctionToTypes_unit_app_val {G : Type max v₁ u₁ ⥤ D} (adj : G ⊣ forget D) (Y : SheafOfTypes J) : ((adjunctionToTypes J adj).unit.app Y).val = (adj.whiskerRight _).unit.app ((sheafOfTypesToPresheaf J).obj Y) ≫ whiskerRight (toSheafify J _) (forget D) := by dsimp [adjunctionToTypes, Adjunction.comp] simp rfl @[simp] theorem adjunctionToTypes_counit_app_val {G : Type max v₁ u₁ ⥤ D} (adj : G ⊣ forget D) (X : Sheaf J D) : ((adjunctionToTypes J adj).counit.app X).val = sheafifyLift J ((Functor.associator _ _ _).hom ≫ (adj.whiskerRight _).counit.app _) X.2 := by apply sheafifyLift_unique dsimp only [adjunctionToTypes, Adjunction.comp, NatTrans.comp_app, instCategorySheaf_comp_val, instCategorySheaf_id_val] rw [adjunction_counit_app_val] erw [Category.id_comp, sheafifyMap_sheafifyLift, toSheafify_sheafifyLift] ext dsimp [sheafEquivSheafOfTypes, Equivalence.symm, Equivalence.toAdjunction, NatIso.ofComponents, Adjunction.whiskerRight, Adjunction.mkOfUnitCounit] simp instance [(forget D).IsRightAdjoint] : (sheafForget.{_, _, _, _, max u₁ v₁} (D := D) J).IsRightAdjoint := (adjunctionToTypes J (Adjunction.ofIsRightAdjoint (forget D))).isRightAdjoint end ForgetToType end end Sheaf end CategoryTheory
CategoryTheory\Sites\Canonical.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.Sites.Sheaf /-! # The canonical topology on a category We define the finest (largest) Grothendieck topology for which a given presheaf `P` is a sheaf. This is well defined since if `P` is a sheaf for a topology `J`, then it is a sheaf for any coarser (smaller) topology. Nonetheless we define the topology explicitly by specifying its sieves: A sieve `S` on `X` is covering for `finestTopologySingle P` iff for any `f : Y ⟶ X`, `P` satisfies the sheaf axiom for `S.pullback f`. Showing that this is a genuine Grothendieck topology (namely that it satisfies the transitivity axiom) forms the bulk of this file. This generalises to a set of presheaves, giving the topology `finestTopology Ps` which is the finest topology for which every presheaf in `Ps` is a sheaf. Using `Ps` as the set of representable presheaves defines the `canonicalTopology`: the finest topology for which every representable is a sheaf. A Grothendieck topology is called `Subcanonical` if it is smaller than the canonical topology, equivalently it is subcanonical iff every representable presheaf is a sheaf. ## References * https://ncatlab.org/nlab/show/canonical+topology * https://ncatlab.org/nlab/show/subcanonical+coverage * https://stacks.math.columbia.edu/tag/00Z9 * https://math.stackexchange.com/a/358709/ -/ universe v u namespace CategoryTheory open scoped Classical open CategoryTheory Category Limits Sieve variable {C : Type u} [Category.{v} C] namespace Sheaf variable {P : Cᵒᵖ ⥤ Type v} variable {X Y : C} {S : Sieve X} {R : Presieve X} variable (J J₂ : GrothendieckTopology C) /-- To show `P` is a sheaf for the binding of `U` with `B`, it suffices to show that `P` is a sheaf for `U`, that `P` is a sheaf for each sieve in `B`, and that it is separated for any pullback of any sieve in `B`. This is mostly an auxiliary lemma to show `isSheafFor_trans`. Adapted from [Elephant], Lemma C2.1.7(i) with suggestions as mentioned in https://math.stackexchange.com/a/358709/ -/ theorem isSheafFor_bind (P : Cᵒᵖ ⥤ Type v) (U : Sieve X) (B : ∀ ⦃Y⦄ ⦃f : Y ⟶ X⦄, U f → Sieve Y) (hU : Presieve.IsSheafFor P (U : Presieve X)) (hB : ∀ ⦃Y⦄ ⦃f : Y ⟶ X⦄ (hf : U f), Presieve.IsSheafFor P (B hf : Presieve Y)) (hB' : ∀ ⦃Y⦄ ⦃f : Y ⟶ X⦄ (h : U f) ⦃Z⦄ (g : Z ⟶ Y), Presieve.IsSeparatedFor P (((B h).pullback g) : Presieve Z)) : Presieve.IsSheafFor P (Sieve.bind (U : Presieve X) B : Presieve X) := by intro s hs let y : ∀ ⦃Y⦄ ⦃f : Y ⟶ X⦄ (hf : U f), Presieve.FamilyOfElements P (B hf : Presieve Y) := fun Y f hf Z g hg => s _ (Presieve.bind_comp _ _ hg) have hy : ∀ ⦃Y⦄ ⦃f : Y ⟶ X⦄ (hf : U f), (y hf).Compatible := by intro Y f H Y₁ Y₂ Z g₁ g₂ f₁ f₂ hf₁ hf₂ comm apply hs apply reassoc_of% comm let t : Presieve.FamilyOfElements P (U : Presieve X) := fun Y f hf => (hB hf).amalgamate (y hf) (hy hf) have ht : ∀ ⦃Y⦄ ⦃f : Y ⟶ X⦄ (hf : U f), (y hf).IsAmalgamation (t f hf) := fun Y f hf => (hB hf).isAmalgamation _ have hT : t.Compatible := by rw [Presieve.compatible_iff_sieveCompatible] intro Z W f h hf apply (hB (U.downward_closed hf h)).isSeparatedFor.ext intro Y l hl apply (hB' hf (l ≫ h)).ext intro M m hm have : bind U B (m ≫ l ≫ h ≫ f) := by -- Porting note: had to make explicit the parameter `((m ≫ l ≫ h) ≫ f)` and -- using `by exact` have : bind U B ((m ≫ l ≫ h) ≫ f) := by exact Presieve.bind_comp f hf hm simpa using this trans s (m ≫ l ≫ h ≫ f) this · have := ht (U.downward_closed hf h) _ ((B _).downward_closed hl m) rw [op_comp, FunctorToTypes.map_comp_apply] at this rw [this] change s _ _ = s _ _ -- Porting note: the proof was `by simp` congr 1 simp only [assoc] · have h : s _ _ = _ := (ht hf _ hm).symm -- Porting note: this was done by `simp only [assoc] at` conv_lhs at h => congr; rw [assoc, assoc] rw [h] simp only [op_comp, assoc, FunctorToTypes.map_comp_apply] refine ⟨hU.amalgamate t hT, ?_, ?_⟩ · rintro Z _ ⟨Y, f, g, hg, hf, rfl⟩ rw [op_comp, FunctorToTypes.map_comp_apply, Presieve.IsSheafFor.valid_glue _ _ _ hg] apply ht hg _ hf · intro y hy apply hU.isSeparatedFor.ext intro Y f hf apply (hB hf).isSeparatedFor.ext intro Z g hg rw [← FunctorToTypes.map_comp_apply, ← op_comp, hy _ (Presieve.bind_comp _ _ hg), hU.valid_glue _ _ hf, ht hf _ hg] /-- Given two sieves `R` and `S`, to show that `P` is a sheaf for `S`, we can show: * `P` is a sheaf for `R` * `P` is a sheaf for the pullback of `S` along any arrow in `R` * `P` is separated for the pullback of `R` along any arrow in `S`. This is mostly an auxiliary lemma to construct `finestTopology`. Adapted from [Elephant], Lemma C2.1.7(ii) with suggestions as mentioned in https://math.stackexchange.com/a/358709 -/ theorem isSheafFor_trans (P : Cᵒᵖ ⥤ Type v) (R S : Sieve X) (hR : Presieve.IsSheafFor P (R : Presieve X)) (hR' : ∀ ⦃Y⦄ ⦃f : Y ⟶ X⦄ (_ : S f), Presieve.IsSeparatedFor P (R.pullback f : Presieve Y)) (hS : ∀ ⦃Y⦄ ⦃f : Y ⟶ X⦄ (_ : R f), Presieve.IsSheafFor P (S.pullback f : Presieve Y)) : Presieve.IsSheafFor P (S : Presieve X) := by have : (bind R fun Y f _ => S.pullback f : Presieve X) ≤ S := by rintro Z f ⟨W, f, g, hg, hf : S _, rfl⟩ apply hf apply Presieve.isSheafFor_subsieve_aux P this · apply isSheafFor_bind _ _ _ hR hS intro Y f hf Z g rw [← pullback_comp] apply (hS (R.downward_closed hf _)).isSeparatedFor · intro Y f hf have : Sieve.pullback f (bind R fun T (k : T ⟶ X) (_ : R k) => pullback k S) = R.pullback f := by ext Z g constructor · rintro ⟨W, k, l, hl, _, comm⟩ rw [pullback_apply, ← comm] simp [hl] · intro a refine ⟨Z, 𝟙 Z, _, a, ?_⟩ simp [hf] rw [this] apply hR' hf /-- Construct the finest (largest) Grothendieck topology for which the given presheaf is a sheaf. This is a special case of https://stacks.math.columbia.edu/tag/00Z9, but following a different proof (see the comments there). -/ def finestTopologySingle (P : Cᵒᵖ ⥤ Type v) : GrothendieckTopology C where sieves X S := ∀ (Y) (f : Y ⟶ X), Presieve.IsSheafFor P (S.pullback f : Presieve Y) top_mem' X Y f := by rw [Sieve.pullback_top] exact Presieve.isSheafFor_top_sieve P pullback_stable' X Y S f hS Z g := by rw [← pullback_comp] apply hS transitive' X S hS R hR Z g := by -- This is the hard part of the construction, showing that the given set of sieves satisfies -- the transitivity axiom. refine isSheafFor_trans P (pullback g S) _ (hS Z g) ?_ ?_ · intro Y f _ rw [← pullback_comp] apply (hS _ _).isSeparatedFor · intro Y f hf have := hR hf _ (𝟙 _) rw [pullback_id, pullback_comp] at this apply this /-- Construct the finest (largest) Grothendieck topology for which all the given presheaves are sheaves. This is equal to the construction of <https://stacks.math.columbia.edu/tag/00Z9>. -/ def finestTopology (Ps : Set (Cᵒᵖ ⥤ Type v)) : GrothendieckTopology C := sInf (finestTopologySingle '' Ps) /-- Check that if `P ∈ Ps`, then `P` is indeed a sheaf for the finest topology on `Ps`. -/ theorem sheaf_for_finestTopology (Ps : Set (Cᵒᵖ ⥤ Type v)) (h : P ∈ Ps) : Presieve.IsSheaf (finestTopology Ps) P := fun X S hS => by simpa using hS _ ⟨⟨_, _, ⟨_, h, rfl⟩, rfl⟩, rfl⟩ _ (𝟙 _) /-- Check that if each `P ∈ Ps` is a sheaf for `J`, then `J` is a subtopology of `finestTopology Ps`. -/ theorem le_finestTopology (Ps : Set (Cᵒᵖ ⥤ Type v)) (J : GrothendieckTopology C) (hJ : ∀ P ∈ Ps, Presieve.IsSheaf J P) : J ≤ finestTopology Ps := by rintro X S hS _ ⟨⟨_, _, ⟨P, hP, rfl⟩, rfl⟩, rfl⟩ intro Y f -- this can't be combined with the previous because the `subst` is applied at the end exact hJ P hP (S.pullback f) (J.pullback_stable f hS) /-- The `canonicalTopology` on a category is the finest (largest) topology for which every representable presheaf is a sheaf. See <https://stacks.math.columbia.edu/tag/00ZA> -/ def canonicalTopology (C : Type u) [Category.{v} C] : GrothendieckTopology C := finestTopology (Set.range yoneda.obj) /-- `yoneda.obj X` is a sheaf for the canonical topology. -/ theorem isSheaf_yoneda_obj (X : C) : Presieve.IsSheaf (canonicalTopology C) (yoneda.obj X) := fun _ _ hS => sheaf_for_finestTopology _ (Set.mem_range_self _) _ hS /-- A representable functor is a sheaf for the canonical topology. -/ theorem isSheaf_of_representable (P : Cᵒᵖ ⥤ Type v) [P.Representable] : Presieve.IsSheaf (canonicalTopology C) P := Presieve.isSheaf_iso (canonicalTopology C) P.reprW (isSheaf_yoneda_obj _) /-- A subcanonical topology is a topology which is smaller than the canonical topology. Equivalently, a topology is subcanonical iff every representable is a sheaf. -/ def Subcanonical (J : GrothendieckTopology C) : Prop := J ≤ canonicalTopology C namespace Subcanonical /-- If every functor `yoneda.obj X` is a `J`-sheaf, then `J` is subcanonical. -/ theorem of_yoneda_isSheaf (J : GrothendieckTopology C) (h : ∀ X, Presieve.IsSheaf J (yoneda.obj X)) : Subcanonical J := le_finestTopology _ _ (by rintro P ⟨X, rfl⟩ apply h) /-- If `J` is subcanonical, then any representable is a `J`-sheaf. -/ theorem isSheaf_of_representable {J : GrothendieckTopology C} (hJ : Subcanonical J) (P : Cᵒᵖ ⥤ Type v) [P.Representable] : Presieve.IsSheaf J P := Presieve.isSheaf_of_le _ hJ (Sheaf.isSheaf_of_representable P) variable {J} /-- If `J` is subcanonical, we obtain a "Yoneda" functor from the defining site into the sheaf category. -/ @[simps] def yoneda (hJ : Subcanonical J) : C ⥤ Sheaf J (Type v) where obj X := ⟨CategoryTheory.yoneda.obj X, by rw [isSheaf_iff_isSheaf_of_type] apply hJ.isSheaf_of_representable⟩ map f := ⟨CategoryTheory.yoneda.map f⟩ variable (hJ : Subcanonical J) /-- The yoneda embedding into the presheaf category factors through the one to the sheaf category. -/ def yonedaCompSheafToPresheaf : hJ.yoneda ⋙ sheafToPresheaf J (Type v) ≅ CategoryTheory.yoneda := Iso.refl _ /-- The yoneda functor into the sheaf category is fully faithful -/ def yonedaFullyFaithful : hJ.yoneda.FullyFaithful := Functor.FullyFaithful.ofCompFaithful (G := sheafToPresheaf J (Type v)) Yoneda.fullyFaithful instance : hJ.yoneda.Full := hJ.yonedaFullyFaithful.full instance : hJ.yoneda.Faithful := hJ.yonedaFullyFaithful.faithful end Subcanonical end Sheaf end CategoryTheory
CategoryTheory\Sites\Closed.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.Sites.SheafOfTypes import Mathlib.Order.Closure /-! # Closed sieves A natural closure operator on sieves is a closure operator on `Sieve X` for each `X` which commutes with pullback. We show that a Grothendieck topology `J` induces a natural closure operator, and define what the closed sieves are. The collection of `J`-closed sieves forms a presheaf which is a sheaf for `J`, and further this presheaf can be used to determine the Grothendieck topology from the sheaf predicate. Finally we show that a natural closure operator on sieves induces a Grothendieck topology, and hence that natural closure operators are in bijection with Grothendieck topologies. ## Main definitions * `CategoryTheory.GrothendieckTopology.close`: Sends a sieve `S` on `X` to the set of arrows which it covers. This has all the usual properties of a closure operator, as well as commuting with pullback. * `CategoryTheory.GrothendieckTopology.closureOperator`: The bundled `ClosureOperator` given by `CategoryTheory.GrothendieckTopology.close`. * `CategoryTheory.GrothendieckTopology.IsClosed`: A sieve `S` on `X` is closed for the topology `J` if it contains every arrow it covers. * `CategoryTheory.Functor.closedSieves`: The presheaf sending `X` to the collection of `J`-closed sieves on `X`. This is additionally shown to be a sheaf for `J`, and if this is a sheaf for a different topology `J'`, then `J' ≤ J`. * `CategoryTheory.topologyOfClosureOperator`: A closure operator on the set of sieves on every object which commutes with pullback additionally induces a Grothendieck topology, giving a bijection with `CategoryTheory.GrothendieckTopology.closureOperator`. ## Tags closed sieve, closure, Grothendieck topology ## References * [S. MacLane, I. Moerdijk, *Sheaves in Geometry and Logic*][MM92] -/ universe v u namespace CategoryTheory variable {C : Type u} [Category.{v} C] variable (J₁ J₂ : GrothendieckTopology C) namespace GrothendieckTopology /-- The `J`-closure of a sieve is the collection of arrows which it covers. -/ @[simps] def close {X : C} (S : Sieve X) : Sieve X where arrows _ f := J₁.Covers S f downward_closed hS := J₁.arrow_stable _ _ hS /-- Any sieve is smaller than its closure. -/ theorem le_close {X : C} (S : Sieve X) : S ≤ J₁.close S := fun _ _ hg => J₁.covering_of_eq_top (S.pullback_eq_top_of_mem hg) /-- A sieve is closed for the Grothendieck topology if it contains every arrow it covers. In the case of the usual topology on a topological space, this means that the open cover contains every open set which it covers. Note this has no relation to a closed subset of a topological space. -/ def IsClosed {X : C} (S : Sieve X) : Prop := ∀ ⦃Y : C⦄ (f : Y ⟶ X), J₁.Covers S f → S f /-- If `S` is `J₁`-closed, then `S` covers exactly the arrows it contains. -/ theorem covers_iff_mem_of_isClosed {X : C} {S : Sieve X} (h : J₁.IsClosed S) {Y : C} (f : Y ⟶ X) : J₁.Covers S f ↔ S f := ⟨h _, J₁.arrow_max _ _⟩ /-- Being `J`-closed is stable under pullback. -/ theorem isClosed_pullback {X Y : C} (f : Y ⟶ X) (S : Sieve X) : J₁.IsClosed S → J₁.IsClosed (S.pullback f) := fun hS Z g hg => hS (g ≫ f) (by rwa [J₁.covers_iff, Sieve.pullback_comp]) /-- The closure of a sieve `S` is the largest closed sieve which contains `S` (justifying the name "closure"). -/ theorem le_close_of_isClosed {X : C} {S T : Sieve X} (h : S ≤ T) (hT : J₁.IsClosed T) : J₁.close S ≤ T := fun _ f hf => hT _ (J₁.superset_covering (Sieve.pullback_monotone f h) hf) /-- The closure of a sieve is closed. -/ theorem close_isClosed {X : C} (S : Sieve X) : J₁.IsClosed (J₁.close S) := fun _ g hg => J₁.arrow_trans g _ S hg fun _ hS => hS /-- A Grothendieck topology induces a natural family of closure operators on sieves. -/ @[simps! isClosed] def closureOperator (X : C) : ClosureOperator (Sieve X) := .ofPred J₁.close J₁.IsClosed J₁.le_close J₁.close_isClosed fun _ _ ↦ J₁.le_close_of_isClosed /-- The sieve `S` is closed iff its closure is equal to itself. -/ theorem isClosed_iff_close_eq_self {X : C} (S : Sieve X) : J₁.IsClosed S ↔ J₁.close S = S := (J₁.closureOperator _).isClosed_iff theorem close_eq_self_of_isClosed {X : C} {S : Sieve X} (hS : J₁.IsClosed S) : J₁.close S = S := (J₁.isClosed_iff_close_eq_self S).1 hS /-- Closing under `J` is stable under pullback. -/ theorem pullback_close {X Y : C} (f : Y ⟶ X) (S : Sieve X) : J₁.close (S.pullback f) = (J₁.close S).pullback f := by apply le_antisymm · refine J₁.le_close_of_isClosed (Sieve.pullback_monotone _ (J₁.le_close S)) ?_ apply J₁.isClosed_pullback _ _ (J₁.close_isClosed _) · intro Z g hg change _ ∈ J₁ _ rw [← Sieve.pullback_comp] apply hg @[mono] theorem monotone_close {X : C} : Monotone (J₁.close : Sieve X → Sieve X) := (J₁.closureOperator _).monotone @[simp] theorem close_close {X : C} (S : Sieve X) : J₁.close (J₁.close S) = J₁.close S := (J₁.closureOperator _).idempotent _ /-- The sieve `S` is in the topology iff its closure is the maximal sieve. This shows that the closure operator determines the topology. -/ theorem close_eq_top_iff_mem {X : C} (S : Sieve X) : J₁.close S = ⊤ ↔ S ∈ J₁ X := by constructor · intro h apply J₁.transitive (J₁.top_mem X) intro Y f hf change J₁.close S f rwa [h] · intro hS rw [eq_top_iff] intro Y f _ apply J₁.pullback_stable _ hS end GrothendieckTopology /-- The presheaf sending each object to the set of `J`-closed sieves on it. This presheaf is a `J`-sheaf (and will turn out to be a subobject classifier for the category of `J`-sheaves). -/ @[simps] def Functor.closedSieves : Cᵒᵖ ⥤ Type max v u where obj X := { S : Sieve X.unop // J₁.IsClosed S } map f S := ⟨S.1.pullback f.unop, J₁.isClosed_pullback f.unop _ S.2⟩ /-- The presheaf of `J`-closed sieves is a `J`-sheaf. The proof of this is adapted from [MM92], Chapter III, Section 7, Lemma 1. -/ theorem classifier_isSheaf : Presieve.IsSheaf J₁ (Functor.closedSieves J₁) := by intro X S hS rw [← Presieve.isSeparatedFor_and_exists_isAmalgamation_iff_isSheafFor] refine ⟨?_, ?_⟩ · rintro x ⟨M, hM⟩ ⟨N, hN⟩ hM₂ hN₂ simp only [Functor.closedSieves_obj] ext Y f dsimp only [Subtype.coe_mk] rw [← J₁.covers_iff_mem_of_isClosed hM, ← J₁.covers_iff_mem_of_isClosed hN] have q : ∀ ⦃Z : C⦄ (g : Z ⟶ X) (_ : S g), M.pullback g = N.pullback g := fun Z g hg => congr_arg Subtype.val ((hM₂ g hg).trans (hN₂ g hg).symm) have MSNS : M ⊓ S = N ⊓ S := by ext Z g rw [Sieve.inter_apply, Sieve.inter_apply] simp only [and_comm] apply and_congr_right intro hg rw [Sieve.pullback_eq_top_iff_mem, Sieve.pullback_eq_top_iff_mem, q g hg] constructor · intro hf rw [J₁.covers_iff] apply J₁.superset_covering (Sieve.pullback_monotone f inf_le_left) rw [← MSNS] apply J₁.arrow_intersect f M S hf (J₁.pullback_stable _ hS) · intro hf rw [J₁.covers_iff] apply J₁.superset_covering (Sieve.pullback_monotone f inf_le_left) rw [MSNS] apply J₁.arrow_intersect f N S hf (J₁.pullback_stable _ hS) · intro x hx rw [Presieve.compatible_iff_sieveCompatible] at hx let M := Sieve.bind S fun Y f hf => (x f hf).1 have : ∀ ⦃Y⦄ (f : Y ⟶ X) (hf : S f), M.pullback f = (x f hf).1 := by intro Y f hf apply le_antisymm · rintro Z u ⟨W, g, f', hf', hg : (x f' hf').1 _, c⟩ rw [Sieve.pullback_eq_top_iff_mem, ← show (x (u ≫ f) _).1 = (x f hf).1.pullback u from congr_arg Subtype.val (hx f u hf)] conv_lhs => congr; congr; rw [← c] -- Porting note: Originally `simp_rw [← c]` rw [show (x (g ≫ f') _).1 = _ from congr_arg Subtype.val (hx f' g hf')] apply Sieve.pullback_eq_top_of_mem _ hg · apply Sieve.le_pullback_bind S fun Y f hf => (x f hf).1 refine ⟨⟨_, J₁.close_isClosed M⟩, ?_⟩ intro Y f hf simp only [Functor.closedSieves_obj] ext1 dsimp rw [← J₁.pullback_close, this _ hf] apply le_antisymm (J₁.le_close_of_isClosed le_rfl (x f hf).2) (J₁.le_close _) /-- If presheaf of `J₁`-closed sieves is a `J₂`-sheaf then `J₁ ≤ J₂`. Note the converse is true by `classifier_isSheaf` and `isSheaf_of_le`. -/ theorem le_topology_of_closedSieves_isSheaf {J₁ J₂ : GrothendieckTopology C} (h : Presieve.IsSheaf J₁ (Functor.closedSieves J₂)) : J₁ ≤ J₂ := by intro X S hS rw [← J₂.close_eq_top_iff_mem] have : J₂.IsClosed (⊤ : Sieve X) := by intro Y f _ trivial suffices (⟨J₂.close S, J₂.close_isClosed S⟩ : Subtype _) = ⟨⊤, this⟩ by rw [Subtype.ext_iff] at this exact this apply (h S hS).isSeparatedFor.ext intro Y f hf simp only [Functor.closedSieves_obj] ext1 dsimp rw [Sieve.pullback_top, ← J₂.pullback_close, S.pullback_eq_top_of_mem hf, J₂.close_eq_top_iff_mem] apply J₂.top_mem /-- If being a sheaf for `J₁` is equivalent to being a sheaf for `J₂`, then `J₁ = J₂`. -/ theorem topology_eq_iff_same_sheaves {J₁ J₂ : GrothendieckTopology C} : J₁ = J₂ ↔ ∀ P : Cᵒᵖ ⥤ Type max v u, Presieve.IsSheaf J₁ P ↔ Presieve.IsSheaf J₂ P := by constructor · rintro rfl intro P rfl · intro h apply le_antisymm · apply le_topology_of_closedSieves_isSheaf rw [h] apply classifier_isSheaf · apply le_topology_of_closedSieves_isSheaf rw [← h] apply classifier_isSheaf /-- A closure (increasing, inflationary and idempotent) operation on sieves that commutes with pullback induces a Grothendieck topology. In fact, such operations are in bijection with Grothendieck topologies. -/ @[simps] def topologyOfClosureOperator (c : ∀ X : C, ClosureOperator (Sieve X)) (hc : ∀ ⦃X Y : C⦄ (f : Y ⟶ X) (S : Sieve X), c _ (S.pullback f) = (c _ S).pullback f) : GrothendieckTopology C where sieves X := { S | c X S = ⊤ } top_mem' X := top_unique ((c X).le_closure _) pullback_stable' X Y S f hS := by rw [Set.mem_setOf_eq] at hS rw [Set.mem_setOf_eq, hc, hS, Sieve.pullback_top] transitive' X S hS R hR := by rw [Set.mem_setOf_eq] at hS rw [Set.mem_setOf_eq, ← (c X).idempotent, eq_top_iff, ← hS] apply (c X).monotone fun Y f hf => _ intros Y f hf rw [Sieve.pullback_eq_top_iff_mem, ← hc] apply hR hf /-- The topology given by the closure operator `J.close` on a Grothendieck topology is the same as `J`. -/ theorem topologyOfClosureOperator_self : (topologyOfClosureOperator J₁.closureOperator fun X Y => J₁.pullback_close) = J₁ := by ext X S apply GrothendieckTopology.close_eq_top_iff_mem theorem topologyOfClosureOperator_close (c : ∀ X : C, ClosureOperator (Sieve X)) (pb : ∀ ⦃X Y : C⦄ (f : Y ⟶ X) (S : Sieve X), c Y (S.pullback f) = (c X S).pullback f) (X : C) (S : Sieve X) : (topologyOfClosureOperator c pb).close S = c X S := by ext Y f change c _ (Sieve.pullback f S) = ⊤ ↔ c _ S f rw [pb, Sieve.pullback_eq_top_iff_mem] end CategoryTheory
CategoryTheory\Sites\CompatiblePlus.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.Sites.Whiskering import Mathlib.CategoryTheory.Sites.Plus /-! In this file, we prove that the plus functor is compatible with functors which preserve the correct limits and colimits. See `CategoryTheory/Sites/CompatibleSheafification` for the compatibility of sheafification, which follows easily from the content in this file. -/ noncomputable section namespace CategoryTheory.GrothendieckTopology open CategoryTheory Limits Opposite universe w₁ w₂ v u variable {C : Type u} [Category.{v} C] (J : GrothendieckTopology C) variable {D : Type w₁} [Category.{max v u} D] variable {E : Type w₂} [Category.{max v u} E] variable (F : D ⥤ E) variable [∀ (α β : Type max v u) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D] variable [∀ (α β : Type max v u) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E] variable [∀ (X : C) (W : J.Cover X) (P : Cᵒᵖ ⥤ D), PreservesLimit (W.index P).multicospan F] variable (P : Cᵒᵖ ⥤ D) /-- The diagram used to define `P⁺`, composed with `F`, is isomorphic to the diagram used to define `P ⋙ F`. -/ def diagramCompIso (X : C) : J.diagram P X ⋙ F ≅ J.diagram (P ⋙ F) X := NatIso.ofComponents (fun W => by refine ?_ ≪≫ HasLimit.isoOfNatIso (W.unop.multicospanComp _ _).symm refine (isLimitOfPreserves F (limit.isLimit _)).conePointUniqueUpToIso (limit.isLimit _)) (by intro A B f dsimp ext g simp [← F.map_comp]) @[reassoc (attr := simp)] theorem diagramCompIso_hom_ι (X : C) (W : (J.Cover X)ᵒᵖ) (i : W.unop.Arrow) : (J.diagramCompIso F P X).hom.app W ≫ Multiequalizer.ι ((unop W).index (P ⋙ F)) i = F.map (Multiequalizer.ι _ _) := by delta diagramCompIso dsimp simp variable [∀ X : C, HasColimitsOfShape (J.Cover X)ᵒᵖ D] variable [∀ X : C, HasColimitsOfShape (J.Cover X)ᵒᵖ E] variable [∀ X : C, PreservesColimitsOfShape (J.Cover X)ᵒᵖ F] /-- The isomorphism between `P⁺ ⋙ F` and `(P ⋙ F)⁺`. -/ def plusCompIso : J.plusObj P ⋙ F ≅ J.plusObj (P ⋙ F) := NatIso.ofComponents (fun X => by refine ?_ ≪≫ HasColimit.isoOfNatIso (J.diagramCompIso F P X.unop) refine (isColimitOfPreserves F (colimit.isColimit (J.diagram P (unop X)))).coconePointUniqueUpToIso (colimit.isColimit _)) (by intro X Y f apply (isColimitOfPreserves F (colimit.isColimit (J.diagram P X.unop))).hom_ext intro W dsimp [plusObj, plusMap] simp only [Functor.map_comp, Category.assoc] slice_rhs 1 2 => erw [(isColimitOfPreserves F (colimit.isColimit (J.diagram P X.unop))).fac] slice_lhs 1 3 => simp only [← F.map_comp] dsimp [colimMap, IsColimit.map, colimit.pre] simp only [colimit.ι_desc_assoc, colimit.ι_desc] dsimp [Cocones.precompose] simp only [Category.assoc, colimit.ι_desc] dsimp [Cocone.whisker] rw [F.map_comp] simp only [Category.assoc] slice_lhs 2 3 => erw [(isColimitOfPreserves F (colimit.isColimit (J.diagram P Y.unop))).fac] dsimp simp only [HasColimit.isoOfNatIso_ι_hom_assoc, GrothendieckTopology.diagramPullback_app, colimit.ι_pre, HasColimit.isoOfNatIso_ι_hom, ι_colimMap_assoc] simp only [← Category.assoc] dsimp congr 1 ext dsimp simp only [Category.assoc] erw [Multiequalizer.lift_ι, diagramCompIso_hom_ι, diagramCompIso_hom_ι, ← F.map_comp, Multiequalizer.lift_ι]) @[reassoc (attr := simp)] theorem ι_plusCompIso_hom (X) (W) : F.map (colimit.ι _ W) ≫ (J.plusCompIso F P).hom.app X = (J.diagramCompIso F P X.unop).hom.app W ≫ colimit.ι _ W := by delta diagramCompIso plusCompIso simp only [IsColimit.descCoconeMorphism_hom, IsColimit.uniqueUpToIso_hom, Cocones.forget_map, Iso.trans_hom, NatIso.ofComponents_hom_app, Functor.mapIso_hom, ← Category.assoc] erw [(isColimitOfPreserves F (colimit.isColimit (J.diagram P (unop X)))).fac] simp @[reassoc (attr := simp)] theorem plusCompIso_whiskerLeft {F G : D ⥤ E} (η : F ⟶ G) (P : Cᵒᵖ ⥤ D) [∀ X : C, PreservesColimitsOfShape (J.Cover X)ᵒᵖ F] [∀ (X : C) (W : J.Cover X) (P : Cᵒᵖ ⥤ D), PreservesLimit (W.index P).multicospan F] [∀ X : C, PreservesColimitsOfShape (J.Cover X)ᵒᵖ G] [∀ (X : C) (W : J.Cover X) (P : Cᵒᵖ ⥤ D), PreservesLimit (W.index P).multicospan G] : whiskerLeft _ η ≫ (J.plusCompIso G P).hom = (J.plusCompIso F P).hom ≫ J.plusMap (whiskerLeft _ η) := by ext X apply (isColimitOfPreserves F (colimit.isColimit (J.diagram P X.unop))).hom_ext intro W dsimp [plusObj, plusMap] simp only [ι_plusCompIso_hom, ι_colimMap, whiskerLeft_app, ι_plusCompIso_hom_assoc, NatTrans.naturality_assoc, GrothendieckTopology.diagramNatTrans_app] simp only [← Category.assoc] congr 1 aesop_cat /-- The isomorphism between `P⁺ ⋙ F` and `(P ⋙ F)⁺`, functorially in `F`. -/ @[simps! hom_app inv_app] def plusFunctorWhiskerLeftIso (P : Cᵒᵖ ⥤ D) [∀ (F : D ⥤ E) (X : C), PreservesColimitsOfShape (J.Cover X)ᵒᵖ F] [∀ (F : D ⥤ E) (X : C) (W : J.Cover X) (P : Cᵒᵖ ⥤ D), PreservesLimit (W.index P).multicospan F] : (whiskeringLeft _ _ E).obj (J.plusObj P) ≅ (whiskeringLeft _ _ _).obj P ⋙ J.plusFunctor E := NatIso.ofComponents (fun _ => plusCompIso _ _ _) @fun _ _ _ => plusCompIso_whiskerLeft _ _ _ @[reassoc (attr := simp)] theorem plusCompIso_whiskerRight {P Q : Cᵒᵖ ⥤ D} (η : P ⟶ Q) : whiskerRight (J.plusMap η) F ≫ (J.plusCompIso F Q).hom = (J.plusCompIso F P).hom ≫ J.plusMap (whiskerRight η F) := by ext X apply (isColimitOfPreserves F (colimit.isColimit (J.diagram P X.unop))).hom_ext intro W dsimp [plusObj, plusMap] simp only [ι_colimMap, whiskerRight_app, ι_plusCompIso_hom_assoc, GrothendieckTopology.diagramNatTrans_app] simp only [← Category.assoc, ← F.map_comp] dsimp [colimMap, IsColimit.map] simp only [colimit.ι_desc] dsimp [Cocones.precompose] simp only [Functor.map_comp, Category.assoc, ι_plusCompIso_hom] simp only [← Category.assoc] congr 1 -- Porting note (#11041): this used to work with `ext` apply Multiequalizer.hom_ext intro a dsimp simp only [diagramCompIso_hom_ι_assoc, Multiequalizer.lift_ι, diagramCompIso_hom_ι, Category.assoc] simp only [← F.map_comp, Multiequalizer.lift_ι] /-- The isomorphism between `P⁺ ⋙ F` and `(P ⋙ F)⁺`, functorially in `P`. -/ @[simps! hom_app inv_app] def plusFunctorWhiskerRightIso : J.plusFunctor D ⋙ (whiskeringRight _ _ _).obj F ≅ (whiskeringRight _ _ _).obj F ⋙ J.plusFunctor E := NatIso.ofComponents (fun _ => J.plusCompIso _ _) @fun _ _ _ => plusCompIso_whiskerRight _ _ _ @[reassoc (attr := simp)] theorem whiskerRight_toPlus_comp_plusCompIso_hom : whiskerRight (J.toPlus _) _ ≫ (J.plusCompIso F P).hom = J.toPlus _ := by ext dsimp [toPlus] simp only [ι_plusCompIso_hom, Functor.map_comp, Category.assoc] simp only [← Category.assoc] congr 1 -- Porting note (#11041): was ext apply Multiequalizer.hom_ext; intro a rw [Category.assoc, diagramCompIso_hom_ι, ← F.map_comp] simp only [unop_op, limit.lift_π, Multifork.ofι_π_app, Functor.comp_obj, Functor.comp_map] @[simp] theorem toPlus_comp_plusCompIso_inv : J.toPlus _ ≫ (J.plusCompIso F P).inv = whiskerRight (J.toPlus _) _ := by simp [Iso.comp_inv_eq] theorem plusCompIso_inv_eq_plusLift (hP : Presheaf.IsSheaf J (J.plusObj P ⋙ F)) : (J.plusCompIso F P).inv = J.plusLift (whiskerRight (J.toPlus _) _) hP := by apply J.plusLift_unique simp [Iso.comp_inv_eq] end CategoryTheory.GrothendieckTopology
CategoryTheory\Sites\CompatibleSheafification.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.Sites.CompatiblePlus import Mathlib.CategoryTheory.Sites.ConcreteSheafification /-! In this file, we prove that sheafification is compatible with functors which preserve the correct limits and colimits. -/ namespace CategoryTheory.GrothendieckTopology open CategoryTheory open CategoryTheory.Limits open Opposite universe w₁ w₂ v u variable {C : Type u} [Category.{v} C] (J : GrothendieckTopology C) variable {D : Type w₁} [Category.{max v u} D] variable {E : Type w₂} [Category.{max v u} E] variable (F : D ⥤ E) -- Porting note: Removed this and made whatever necessary noncomputable -- noncomputable section variable [∀ (α β : Type max v u) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D] variable [∀ (α β : Type max v u) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E] variable [∀ X : C, HasColimitsOfShape (J.Cover X)ᵒᵖ D] variable [∀ X : C, HasColimitsOfShape (J.Cover X)ᵒᵖ E] variable [∀ X : C, PreservesColimitsOfShape (J.Cover X)ᵒᵖ F] variable [∀ (X : C) (W : J.Cover X) (P : Cᵒᵖ ⥤ D), PreservesLimit (W.index P).multicospan F] variable (P : Cᵒᵖ ⥤ D) /-- The isomorphism between the sheafification of `P` composed with `F` and the sheafification of `P ⋙ F`. Use the lemmas `whisker_right_to_sheafify_sheafify_comp_iso_hom`, `to_sheafify_comp_sheafify_comp_iso_inv` and `sheafify_comp_iso_inv_eq_sheafify_lift` to reduce the components of this isomorphisms to a state that can be handled using the universal property of sheafification. -/ noncomputable def sheafifyCompIso : J.sheafify P ⋙ F ≅ J.sheafify (P ⋙ F) := J.plusCompIso _ _ ≪≫ (J.plusFunctor _).mapIso (J.plusCompIso _ _) /-- The isomorphism between the sheafification of `P` composed with `F` and the sheafification of `P ⋙ F`, functorially in `F`. -/ noncomputable def sheafificationWhiskerLeftIso (P : Cᵒᵖ ⥤ D) [∀ (F : D ⥤ E) (X : C), PreservesColimitsOfShape (J.Cover X)ᵒᵖ F] [∀ (F : D ⥤ E) (X : C) (W : J.Cover X) (P : Cᵒᵖ ⥤ D), PreservesLimit (W.index P).multicospan F] : (whiskeringLeft _ _ E).obj (J.sheafify P) ≅ (whiskeringLeft _ _ _).obj P ⋙ J.sheafification E := by refine J.plusFunctorWhiskerLeftIso _ ≪≫ ?_ ≪≫ Functor.associator _ _ _ refine isoWhiskerRight ?_ _ exact J.plusFunctorWhiskerLeftIso _ @[simp] theorem sheafificationWhiskerLeftIso_hom_app (P : Cᵒᵖ ⥤ D) (F : D ⥤ E) [∀ (F : D ⥤ E) (X : C), PreservesColimitsOfShape (J.Cover X)ᵒᵖ F] [∀ (F : D ⥤ E) (X : C) (W : J.Cover X) (P : Cᵒᵖ ⥤ D), PreservesLimit (W.index P).multicospan F] : (sheafificationWhiskerLeftIso J P).hom.app F = (J.sheafifyCompIso F P).hom := by dsimp [sheafificationWhiskerLeftIso, sheafifyCompIso] rw [Category.comp_id] @[simp] theorem sheafificationWhiskerLeftIso_inv_app (P : Cᵒᵖ ⥤ D) (F : D ⥤ E) [∀ (F : D ⥤ E) (X : C), PreservesColimitsOfShape (J.Cover X)ᵒᵖ F] [∀ (F : D ⥤ E) (X : C) (W : J.Cover X) (P : Cᵒᵖ ⥤ D), PreservesLimit (W.index P).multicospan F] : (sheafificationWhiskerLeftIso J P).inv.app F = (J.sheafifyCompIso F P).inv := by dsimp [sheafificationWhiskerLeftIso, sheafifyCompIso] erw [Category.id_comp] /-- The isomorphism between the sheafification of `P` composed with `F` and the sheafification of `P ⋙ F`, functorially in `P`. -/ noncomputable def sheafificationWhiskerRightIso : J.sheafification D ⋙ (whiskeringRight _ _ _).obj F ≅ (whiskeringRight _ _ _).obj F ⋙ J.sheafification E := by refine Functor.associator _ _ _ ≪≫ ?_ refine isoWhiskerLeft (J.plusFunctor D) (J.plusFunctorWhiskerRightIso _) ≪≫ ?_ refine ?_ ≪≫ Functor.associator _ _ _ refine (Functor.associator _ _ _).symm ≪≫ ?_ exact isoWhiskerRight (J.plusFunctorWhiskerRightIso _) (J.plusFunctor E) @[simp] theorem sheafificationWhiskerRightIso_hom_app : (J.sheafificationWhiskerRightIso F).hom.app P = (J.sheafifyCompIso F P).hom := by dsimp [sheafificationWhiskerRightIso, sheafifyCompIso] simp only [Category.id_comp, Category.comp_id] erw [Category.id_comp] @[simp] theorem sheafificationWhiskerRightIso_inv_app : (J.sheafificationWhiskerRightIso F).inv.app P = (J.sheafifyCompIso F P).inv := by dsimp [sheafificationWhiskerRightIso, sheafifyCompIso] simp only [Category.id_comp, Category.comp_id] erw [Category.id_comp] @[simp, reassoc] theorem whiskerRight_toSheafify_sheafifyCompIso_hom : whiskerRight (J.toSheafify _) _ ≫ (J.sheafifyCompIso F P).hom = J.toSheafify _ := by dsimp [sheafifyCompIso] erw [whiskerRight_comp, Category.assoc] slice_lhs 2 3 => rw [plusCompIso_whiskerRight] rw [Category.assoc, ← J.plusMap_comp, whiskerRight_toPlus_comp_plusCompIso_hom, ← Category.assoc, whiskerRight_toPlus_comp_plusCompIso_hom] rfl @[simp, reassoc] theorem toSheafify_comp_sheafifyCompIso_inv : J.toSheafify _ ≫ (J.sheafifyCompIso F P).inv = whiskerRight (J.toSheafify _) _ := by rw [Iso.comp_inv_eq]; simp section -- We will sheafify `D`-valued presheaves in this section. variable [ConcreteCategory.{max v u} D] [PreservesLimits (forget D)] [∀ X : C, PreservesColimitsOfShape (J.Cover X)ᵒᵖ (forget D)] [(forget D).ReflectsIsomorphisms] @[simp] theorem sheafifyCompIso_inv_eq_sheafifyLift : (J.sheafifyCompIso F P).inv = J.sheafifyLift (whiskerRight (J.toSheafify P) F) (HasSheafCompose.isSheaf _ ((J.sheafify_isSheaf _))) := by apply J.sheafifyLift_unique rw [Iso.comp_inv_eq] simp end end CategoryTheory.GrothendieckTopology
CategoryTheory\Sites\ConcreteSheafification.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.Sites.Plus import Mathlib.CategoryTheory.Limits.Shapes.ConcreteCategory /-! # Sheafification We construct the sheafification of a presheaf over a site `C` with values in `D` whenever `D` is a concrete category for which the forgetful functor preserves the appropriate (co)limits and reflects isomorphisms. We generally follow the approach of https://stacks.math.columbia.edu/tag/00W1 -/ namespace CategoryTheory open CategoryTheory.Limits Opposite universe w v u variable {C : Type u} [Category.{v} C] {J : GrothendieckTopology C} variable {D : Type w} [Category.{max v u} D] section variable [ConcreteCategory.{max v u} D] attribute [local instance] ConcreteCategory.hasCoeToSort ConcreteCategory.instFunLike -- porting note (#5171): removed @[nolint has_nonempty_instance] /-- A concrete version of the multiequalizer, to be used below. -/ def Meq {X : C} (P : Cᵒᵖ ⥤ D) (S : J.Cover X) := { x : ∀ I : S.Arrow, P.obj (op I.Y) // ∀ I : S.Relation, P.map I.r.g₁.op (x I.fst) = P.map I.r.g₂.op (x I.snd) } end namespace Meq variable [ConcreteCategory.{max v u} D] attribute [local instance] ConcreteCategory.hasCoeToSort ConcreteCategory.instFunLike instance {X} (P : Cᵒᵖ ⥤ D) (S : J.Cover X) : CoeFun (Meq P S) fun _ => ∀ I : S.Arrow, P.obj (op I.Y) := ⟨fun x => x.1⟩ lemma congr_apply {X} {P : Cᵒᵖ ⥤ D} {S : J.Cover X} (x : Meq P S) {Y} {f g : Y ⟶ X} (h : f = g) (hf : S f) : x ⟨_, _, hf⟩ = x ⟨_, g, by simpa only [← h] using hf⟩ := by subst h rfl @[ext] theorem ext {X} {P : Cᵒᵖ ⥤ D} {S : J.Cover X} (x y : Meq P S) (h : ∀ I : S.Arrow, x I = y I) : x = y := Subtype.ext <| funext <| h theorem condition {X} {P : Cᵒᵖ ⥤ D} {S : J.Cover X} (x : Meq P S) (I : S.Relation) : P.map I.r.g₁.op (x ((S.index P).fstTo I)) = P.map I.r.g₂.op (x ((S.index P).sndTo I)) := x.2 _ /-- Refine a term of `Meq P T` with respect to a refinement `S ⟶ T` of covers. -/ def refine {X : C} {P : Cᵒᵖ ⥤ D} {S T : J.Cover X} (x : Meq P T) (e : S ⟶ T) : Meq P S := ⟨fun I => x ⟨I.Y, I.f, (leOfHom e) _ I.hf⟩, fun I => x.condition (GrothendieckTopology.Cover.Relation.mk' (I.r.map e))⟩ @[simp] theorem refine_apply {X : C} {P : Cᵒᵖ ⥤ D} {S T : J.Cover X} (x : Meq P T) (e : S ⟶ T) (I : S.Arrow) : x.refine e I = x ⟨I.Y, I.f, (leOfHom e) _ I.hf⟩ := rfl /-- Pull back a term of `Meq P S` with respect to a morphism `f : Y ⟶ X` in `C`. -/ def pullback {Y X : C} {P : Cᵒᵖ ⥤ D} {S : J.Cover X} (x : Meq P S) (f : Y ⟶ X) : Meq P ((J.pullback f).obj S) := ⟨fun I => x ⟨_, I.f ≫ f, I.hf⟩, fun I => x.condition (GrothendieckTopology.Cover.Relation.mk' I.r.base)⟩ @[simp] theorem pullback_apply {Y X : C} {P : Cᵒᵖ ⥤ D} {S : J.Cover X} (x : Meq P S) (f : Y ⟶ X) (I : ((J.pullback f).obj S).Arrow) : x.pullback f I = x ⟨_, I.f ≫ f, I.hf⟩ := rfl @[simp] theorem pullback_refine {Y X : C} {P : Cᵒᵖ ⥤ D} {S T : J.Cover X} (h : S ⟶ T) (f : Y ⟶ X) (x : Meq P T) : (x.pullback f).refine ((J.pullback f).map h) = (refine x h).pullback _ := rfl /-- Make a term of `Meq P S`. -/ def mk {X : C} {P : Cᵒᵖ ⥤ D} (S : J.Cover X) (x : P.obj (op X)) : Meq P S := ⟨fun I => P.map I.f.op x, fun I => by dsimp simp only [← comp_apply, ← P.map_comp, ← op_comp, I.r.w]⟩ theorem mk_apply {X : C} {P : Cᵒᵖ ⥤ D} (S : J.Cover X) (x : P.obj (op X)) (I : S.Arrow) : mk S x I = P.map I.f.op x := rfl variable [PreservesLimits (forget D)] /-- The equivalence between the type associated to `multiequalizer (S.index P)` and `Meq P S`. -/ noncomputable def equiv {X : C} (P : Cᵒᵖ ⥤ D) (S : J.Cover X) [HasMultiequalizer (S.index P)] : (multiequalizer (S.index P) : D) ≃ Meq P S := Limits.Concrete.multiequalizerEquiv _ @[simp] theorem equiv_apply {X : C} {P : Cᵒᵖ ⥤ D} {S : J.Cover X} [HasMultiequalizer (S.index P)] (x : (multiequalizer (S.index P) : D)) (I : S.Arrow) : equiv P S x I = Multiequalizer.ι (S.index P) I x := rfl theorem equiv_symm_eq_apply {X : C} {P : Cᵒᵖ ⥤ D} {S : J.Cover X} [HasMultiequalizer (S.index P)] (x : Meq P S) (I : S.Arrow) : Multiequalizer.ι (S.index P) I ((Meq.equiv P S).symm x) = x I := by rw [← equiv_apply] simp end Meq namespace GrothendieckTopology namespace Plus variable [ConcreteCategory.{max v u} D] attribute [local instance] ConcreteCategory.hasCoeToSort ConcreteCategory.instFunLike variable [PreservesLimits (forget D)] variable [∀ X : C, HasColimitsOfShape (J.Cover X)ᵒᵖ D] variable [∀ (P : Cᵒᵖ ⥤ D) (X : C) (S : J.Cover X), HasMultiequalizer (S.index P)] noncomputable section /-- Make a term of `(J.plusObj P).obj (op X)` from `x : Meq P S`. -/ def mk {X : C} {P : Cᵒᵖ ⥤ D} {S : J.Cover X} (x : Meq P S) : (J.plusObj P).obj (op X) := colimit.ι (J.diagram P X) (op S) ((Meq.equiv P S).symm x) theorem res_mk_eq_mk_pullback {Y X : C} {P : Cᵒᵖ ⥤ D} {S : J.Cover X} (x : Meq P S) (f : Y ⟶ X) : (J.plusObj P).map f.op (mk x) = mk (x.pullback f) := by dsimp [mk, plusObj] rw [← comp_apply (x := (Meq.equiv P S).symm x), ι_colimMap_assoc, colimit.ι_pre, comp_apply (x := (Meq.equiv P S).symm x)] apply congr_arg apply (Meq.equiv P _).injective erw [Equiv.apply_symm_apply] ext i simp only [Functor.op_obj, unop_op, pullback_obj, diagram_obj, Functor.comp_obj, diagramPullback_app, Meq.equiv_apply, Meq.pullback_apply] erw [← comp_apply, Multiequalizer.lift_ι, Meq.equiv_symm_eq_apply] cases i; rfl theorem toPlus_mk {X : C} {P : Cᵒᵖ ⥤ D} (S : J.Cover X) (x : P.obj (op X)) : (J.toPlus P).app _ x = mk (Meq.mk S x) := by dsimp [mk, toPlus] let e : S ⟶ ⊤ := homOfLE (OrderTop.le_top _) rw [← colimit.w _ e.op] delta Cover.toMultiequalizer erw [comp_apply, comp_apply] apply congr_arg dsimp [diagram] apply Concrete.multiequalizer_ext intro i simp only [← comp_apply, Category.assoc, Multiequalizer.lift_ι, Category.comp_id, Meq.equiv_symm_eq_apply] rfl theorem toPlus_apply {X : C} {P : Cᵒᵖ ⥤ D} (S : J.Cover X) (x : Meq P S) (I : S.Arrow) : (J.toPlus P).app _ (x I) = (J.plusObj P).map I.f.op (mk x) := by dsimp only [toPlus, plusObj] delta Cover.toMultiequalizer dsimp [mk] erw [← comp_apply] rw [ι_colimMap_assoc, colimit.ι_pre, comp_apply, comp_apply] dsimp only [Functor.op] let e : (J.pullback I.f).obj (unop (op S)) ⟶ ⊤ := homOfLE (OrderTop.le_top _) rw [← colimit.w _ e.op] erw [comp_apply] apply congr_arg apply Concrete.multiequalizer_ext intro i dsimp erw [← comp_apply, ← comp_apply, ← comp_apply] rw [Multiequalizer.lift_ι, Multiequalizer.lift_ι, Multiequalizer.lift_ι] erw [Meq.equiv_symm_eq_apply] simpa using (x.condition (Cover.Relation.mk' (I.precompRelation i.f))).symm theorem toPlus_eq_mk {X : C} {P : Cᵒᵖ ⥤ D} (x : P.obj (op X)) : (J.toPlus P).app _ x = mk (Meq.mk ⊤ x) := by dsimp [mk, toPlus] delta Cover.toMultiequalizer simp only [comp_apply] apply congr_arg apply (Meq.equiv P ⊤).injective ext i rw [Meq.equiv_apply, Equiv.apply_symm_apply, ← comp_apply, Multiequalizer.lift_ι] rfl variable [∀ X : C, PreservesColimitsOfShape (J.Cover X)ᵒᵖ (forget D)] theorem exists_rep {X : C} {P : Cᵒᵖ ⥤ D} (x : (J.plusObj P).obj (op X)) : ∃ (S : J.Cover X) (y : Meq P S), x = mk y := by obtain ⟨S, y, h⟩ := Concrete.colimit_exists_rep (J.diagram P X) x use S.unop, Meq.equiv _ _ y rw [← h] dsimp [mk] simp theorem eq_mk_iff_exists {X : C} {P : Cᵒᵖ ⥤ D} {S T : J.Cover X} (x : Meq P S) (y : Meq P T) : mk x = mk y ↔ ∃ (W : J.Cover X) (h1 : W ⟶ S) (h2 : W ⟶ T), x.refine h1 = y.refine h2 := by constructor · intro h obtain ⟨W, h1, h2, hh⟩ := Concrete.colimit_exists_of_rep_eq.{u} _ _ _ h use W.unop, h1.unop, h2.unop ext I apply_fun Multiequalizer.ι (W.unop.index P) I at hh convert hh all_goals dsimp [diagram] erw [← comp_apply, Multiequalizer.lift_ι, Meq.equiv_symm_eq_apply] cases I; rfl · rintro ⟨S, h1, h2, e⟩ apply Concrete.colimit_rep_eq_of_exists use op S, h1.op, h2.op apply Concrete.multiequalizer_ext intro i apply_fun fun ee => ee i at e convert e all_goals dsimp erw [← comp_apply, Multiequalizer.lift_ι] erw [Meq.equiv_symm_eq_apply] cases i; rfl /-- `P⁺` is always separated. -/ theorem sep {X : C} (P : Cᵒᵖ ⥤ D) (S : J.Cover X) (x y : (J.plusObj P).obj (op X)) (h : ∀ I : S.Arrow, (J.plusObj P).map I.f.op x = (J.plusObj P).map I.f.op y) : x = y := by -- First, we choose representatives for x and y. obtain ⟨Sx, x, rfl⟩ := exists_rep x obtain ⟨Sy, y, rfl⟩ := exists_rep y simp only [res_mk_eq_mk_pullback] at h -- Next, using our assumption, -- choose covers over which the pullbacks of these representatives become equal. choose W h1 h2 hh using fun I : S.Arrow => (eq_mk_iff_exists _ _).mp (h I) -- To prove equality, it suffices to prove that there exists a cover over which -- the representatives become equal. rw [eq_mk_iff_exists] -- Construct the cover over which the representatives become equal by combining the various -- covers chosen above. let B : J.Cover X := S.bind W use B -- Prove that this cover refines the two covers over which our representatives are defined -- and use these proofs. let ex : B ⟶ Sx := homOfLE (by rintro Y f ⟨Z, e1, e2, he2, he1, hee⟩ rw [← hee] apply leOfHom (h1 ⟨_, _, he2⟩) exact he1) let ey : B ⟶ Sy := homOfLE (by rintro Y f ⟨Z, e1, e2, he2, he1, hee⟩ rw [← hee] apply leOfHom (h2 ⟨_, _, he2⟩) exact he1) use ex, ey -- Now prove that indeed the representatives become equal over `B`. -- This will follow by using the fact that our representatives become -- equal over the chosen covers. ext1 I let IS : S.Arrow := I.fromMiddle specialize hh IS let IW : (W IS).Arrow := I.toMiddle apply_fun fun e => e IW at hh convert hh using 1 · exact x.congr_apply I.middle_spec.symm _ · exact y.congr_apply I.middle_spec.symm _ theorem inj_of_sep (P : Cᵒᵖ ⥤ D) (hsep : ∀ (X : C) (S : J.Cover X) (x y : P.obj (op X)), (∀ I : S.Arrow, P.map I.f.op x = P.map I.f.op y) → x = y) (X : C) : Function.Injective ((J.toPlus P).app (op X)) := by intro x y h simp only [toPlus_eq_mk] at h rw [eq_mk_iff_exists] at h obtain ⟨W, h1, h2, hh⟩ := h apply hsep X W intro I apply_fun fun e => e I at hh exact hh /-- An auxiliary definition to be used in the proof of `exists_of_sep` below. Given a compatible family of local sections for `P⁺`, and representatives of said sections, construct a compatible family of local sections of `P` over the combination of the covers associated to the representatives. The separatedness condition is used to prove compatibility among these local sections of `P`. -/ def meqOfSep (P : Cᵒᵖ ⥤ D) (hsep : ∀ (X : C) (S : J.Cover X) (x y : P.obj (op X)), (∀ I : S.Arrow, P.map I.f.op x = P.map I.f.op y) → x = y) (X : C) (S : J.Cover X) (s : Meq (J.plusObj P) S) (T : ∀ I : S.Arrow, J.Cover I.Y) (t : ∀ I : S.Arrow, Meq P (T I)) (ht : ∀ I : S.Arrow, s I = mk (t I)) : Meq P (S.bind T) where val I := t I.fromMiddle I.toMiddle property := by intro II apply inj_of_sep P hsep rw [← comp_apply, ← comp_apply, (J.toPlus P).naturality, (J.toPlus P).naturality, comp_apply, comp_apply] erw [toPlus_apply (T II.fst.fromMiddle) (t II.fst.fromMiddle) II.fst.toMiddle, toPlus_apply (T II.snd.fromMiddle) (t II.snd.fromMiddle) II.snd.toMiddle, ← ht, ← ht, ← comp_apply, ← comp_apply, ← (J.plusObj P).map_comp, ← (J.plusObj P).map_comp] rw [← op_comp, ← op_comp] exact s.condition (Cover.Relation.mk { hf := II.fst.from_middle_condition } { hf := II.snd.from_middle_condition } { g₁ := II.r.g₁ ≫ II.fst.toMiddleHom g₂ := II.r.g₂ ≫ II.snd.toMiddleHom w := by simpa only [Category.assoc, Cover.Arrow.middle_spec] using II.r.w }) theorem exists_of_sep (P : Cᵒᵖ ⥤ D) (hsep : ∀ (X : C) (S : J.Cover X) (x y : P.obj (op X)), (∀ I : S.Arrow, P.map I.f.op x = P.map I.f.op y) → x = y) (X : C) (S : J.Cover X) (s : Meq (J.plusObj P) S) : ∃ t : (J.plusObj P).obj (op X), Meq.mk S t = s := by have inj : ∀ X : C, Function.Injective ((J.toPlus P).app (op X)) := inj_of_sep _ hsep -- Choose representatives for the given local sections. choose T t ht using fun I => exists_rep (s I) -- Construct a large cover over which we will define a representative that will -- provide the gluing of the given local sections. let B : J.Cover X := S.bind T choose Z e1 e2 he2 _ _ using fun I : B.Arrow => I.hf -- Construct a compatible system of local sections over this large cover, using the chosen -- representatives of our local sections. -- The compatibility here follows from the separatedness assumption. let w : Meq P B := meqOfSep P hsep X S s T t ht -- The associated gluing will be the candidate section. use mk w ext I dsimp [Meq.mk] erw [ht, res_mk_eq_mk_pullback] -- Use the separatedness of `P⁺` to prove that this is indeed a gluing of our -- original local sections. apply sep P (T I) intro II simp only [res_mk_eq_mk_pullback, eq_mk_iff_exists] -- It suffices to prove equality for representatives over a -- convenient sufficiently large cover... use (J.pullback II.f).obj (T I) let e0 : (J.pullback II.f).obj (T I) ⟶ (J.pullback II.f).obj ((J.pullback I.f).obj B) := homOfLE (by intro Y f hf apply Sieve.le_pullback_bind _ _ _ I.hf · cases I exact hf) use e0, 𝟙 _ ext IV let IA : B.Arrow := ⟨_, (IV.f ≫ II.f) ≫ I.f, ⟨I.Y, _, _, I.hf, Sieve.downward_closed _ II.hf _, rfl⟩⟩ let IB : S.Arrow := IA.fromMiddle let IC : (T IB).Arrow := IA.toMiddle let ID : (T I).Arrow := ⟨IV.Y, IV.f ≫ II.f, Sieve.downward_closed (T I).sieve II.hf IV.f⟩ change t IB IC = t I ID apply inj IV.Y erw [toPlus_apply (T I) (t I) ID, toPlus_apply (T IB) (t IB) IC, ← ht, ← ht] -- Conclude by constructing the relation showing equality... let IR : S.Relation := Cover.Relation.mk { hf := IB.hf } { hf := I.hf } { w := IA.middle_spec } exact s.condition IR variable [(forget D).ReflectsIsomorphisms] /-- If `P` is separated, then `P⁺` is a sheaf. -/ theorem isSheaf_of_sep (P : Cᵒᵖ ⥤ D) (hsep : ∀ (X : C) (S : J.Cover X) (x y : P.obj (op X)), (∀ I : S.Arrow, P.map I.f.op x = P.map I.f.op y) → x = y) : Presheaf.IsSheaf J (J.plusObj P) := by rw [Presheaf.isSheaf_iff_multiequalizer] intro X S apply @isIso_of_reflects_iso _ _ _ _ _ _ _ (forget D) ?_ rw [isIso_iff_bijective] constructor · intro x y h apply sep P S _ _ intro I apply_fun Meq.equiv _ _ at h apply_fun fun e => e I at h convert h <;> erw [Meq.equiv_apply, ← comp_apply, Multiequalizer.lift_ι] <;> rfl · rintro (x : (multiequalizer (S.index _) : D)) obtain ⟨t, ht⟩ := exists_of_sep P hsep X S (Meq.equiv _ _ x) use t apply (Meq.equiv _ _).injective rw [← ht] ext i dsimp erw [← comp_apply] rw [Multiequalizer.lift_ι] rfl variable (J) /-- `P⁺⁺` is always a sheaf. -/ theorem isSheaf_plus_plus (P : Cᵒᵖ ⥤ D) : Presheaf.IsSheaf J (J.plusObj (J.plusObj P)) := by apply isSheaf_of_sep intro X S x y apply sep end end Plus variable (J) variable [∀ (P : Cᵒᵖ ⥤ D) (X : C) (S : J.Cover X), HasMultiequalizer (S.index P)] [∀ X : C, HasColimitsOfShape (J.Cover X)ᵒᵖ D] /-- The sheafification of a presheaf `P`. *NOTE:* Additional hypotheses are needed to obtain a proof that this is a sheaf! -/ noncomputable def sheafify (P : Cᵒᵖ ⥤ D) : Cᵒᵖ ⥤ D := J.plusObj (J.plusObj P) /-- The canonical map from `P` to its sheafification. -/ noncomputable def toSheafify (P : Cᵒᵖ ⥤ D) : P ⟶ J.sheafify P := J.toPlus P ≫ J.plusMap (J.toPlus P) /-- The canonical map on sheafifications induced by a morphism. -/ noncomputable def sheafifyMap {P Q : Cᵒᵖ ⥤ D} (η : P ⟶ Q) : J.sheafify P ⟶ J.sheafify Q := J.plusMap <| J.plusMap η @[simp] theorem sheafifyMap_id (P : Cᵒᵖ ⥤ D) : J.sheafifyMap (𝟙 P) = 𝟙 (J.sheafify P) := by dsimp [sheafifyMap, sheafify] simp @[simp] theorem sheafifyMap_comp {P Q R : Cᵒᵖ ⥤ D} (η : P ⟶ Q) (γ : Q ⟶ R) : J.sheafifyMap (η ≫ γ) = J.sheafifyMap η ≫ J.sheafifyMap γ := by dsimp [sheafifyMap, sheafify] simp @[reassoc (attr := simp)] theorem toSheafify_naturality {P Q : Cᵒᵖ ⥤ D} (η : P ⟶ Q) : η ≫ J.toSheafify _ = J.toSheafify _ ≫ J.sheafifyMap η := by dsimp [sheafifyMap, sheafify, toSheafify] simp variable (D) /-- The sheafification of a presheaf `P`, as a functor. *NOTE:* Additional hypotheses are needed to obtain a proof that this is a sheaf! -/ noncomputable def sheafification : (Cᵒᵖ ⥤ D) ⥤ Cᵒᵖ ⥤ D := J.plusFunctor D ⋙ J.plusFunctor D @[simp] theorem sheafification_obj (P : Cᵒᵖ ⥤ D) : (J.sheafification D).obj P = J.sheafify P := rfl @[simp] theorem sheafification_map {P Q : Cᵒᵖ ⥤ D} (η : P ⟶ Q) : (J.sheafification D).map η = J.sheafifyMap η := rfl /-- The canonical map from `P` to its sheafification, as a natural transformation. *Note:* We only show this is a sheaf under additional hypotheses on `D`. -/ noncomputable def toSheafification : 𝟭 _ ⟶ sheafification J D := J.toPlusNatTrans D ≫ whiskerRight (J.toPlusNatTrans D) (J.plusFunctor D) @[simp] theorem toSheafification_app (P : Cᵒᵖ ⥤ D) : (J.toSheafification D).app P = J.toSheafify P := rfl variable {D} theorem isIso_toSheafify {P : Cᵒᵖ ⥤ D} (hP : Presheaf.IsSheaf J P) : IsIso (J.toSheafify P) := by dsimp [toSheafify] haveI := isIso_toPlus_of_isSheaf J P hP change (IsIso (toPlus J P ≫ (J.plusFunctor D).map (toPlus J P))) infer_instance /-- If `P` is a sheaf, then `P` is isomorphic to `J.sheafify P`. -/ noncomputable def isoSheafify {P : Cᵒᵖ ⥤ D} (hP : Presheaf.IsSheaf J P) : P ≅ J.sheafify P := letI := isIso_toSheafify J hP asIso (J.toSheafify P) @[simp] theorem isoSheafify_hom {P : Cᵒᵖ ⥤ D} (hP : Presheaf.IsSheaf J P) : (J.isoSheafify hP).hom = J.toSheafify P := rfl /-- Given a sheaf `Q` and a morphism `P ⟶ Q`, construct a morphism from `J.sheafify P` to `Q`. -/ noncomputable def sheafifyLift {P Q : Cᵒᵖ ⥤ D} (η : P ⟶ Q) (hQ : Presheaf.IsSheaf J Q) : J.sheafify P ⟶ Q := J.plusLift (J.plusLift η hQ) hQ @[reassoc (attr := simp)] theorem toSheafify_sheafifyLift {P Q : Cᵒᵖ ⥤ D} (η : P ⟶ Q) (hQ : Presheaf.IsSheaf J Q) : J.toSheafify P ≫ sheafifyLift J η hQ = η := by dsimp only [sheafifyLift, toSheafify] simp theorem sheafifyLift_unique {P Q : Cᵒᵖ ⥤ D} (η : P ⟶ Q) (hQ : Presheaf.IsSheaf J Q) (γ : J.sheafify P ⟶ Q) : J.toSheafify P ≫ γ = η → γ = sheafifyLift J η hQ := by intro h apply plusLift_unique apply plusLift_unique rw [← Category.assoc, ← plusMap_toPlus] exact h @[simp] theorem isoSheafify_inv {P : Cᵒᵖ ⥤ D} (hP : Presheaf.IsSheaf J P) : (J.isoSheafify hP).inv = J.sheafifyLift (𝟙 _) hP := by apply J.sheafifyLift_unique simp [Iso.comp_inv_eq] theorem sheafify_hom_ext {P Q : Cᵒᵖ ⥤ D} (η γ : J.sheafify P ⟶ Q) (hQ : Presheaf.IsSheaf J Q) (h : J.toSheafify P ≫ η = J.toSheafify P ≫ γ) : η = γ := by apply J.plus_hom_ext _ _ hQ apply J.plus_hom_ext _ _ hQ rw [← Category.assoc, ← Category.assoc, ← plusMap_toPlus] exact h @[reassoc (attr := simp)] theorem sheafifyMap_sheafifyLift {P Q R : Cᵒᵖ ⥤ D} (η : P ⟶ Q) (γ : Q ⟶ R) (hR : Presheaf.IsSheaf J R) : J.sheafifyMap η ≫ J.sheafifyLift γ hR = J.sheafifyLift (η ≫ γ) hR := by apply J.sheafifyLift_unique rw [← Category.assoc, ← J.toSheafify_naturality, Category.assoc, toSheafify_sheafifyLift] end GrothendieckTopology variable (J) variable [ConcreteCategory.{max v u} D] [PreservesLimits (forget D)] [∀ (P : Cᵒᵖ ⥤ D) (X : C) (S : J.Cover X), HasMultiequalizer (S.index P)] [∀ X : C, HasColimitsOfShape (J.Cover X)ᵒᵖ D] [∀ X : C, PreservesColimitsOfShape (J.Cover X)ᵒᵖ (forget D)] [(forget D).ReflectsIsomorphisms] theorem GrothendieckTopology.sheafify_isSheaf (P : Cᵒᵖ ⥤ D) : Presheaf.IsSheaf J (J.sheafify P) := GrothendieckTopology.Plus.isSheaf_plus_plus _ _ variable (D) /-- The sheafification functor, as a functor taking values in `Sheaf`. -/ @[simps] noncomputable def plusPlusSheaf : (Cᵒᵖ ⥤ D) ⥤ Sheaf J D where obj P := ⟨J.sheafify P, J.sheafify_isSheaf P⟩ map η := ⟨J.sheafifyMap η⟩ map_id _ := Sheaf.Hom.ext <| J.sheafifyMap_id _ map_comp _ _ := Sheaf.Hom.ext <| J.sheafifyMap_comp _ _ instance plusPlusSheaf_preservesZeroMorphisms [Preadditive D] : (plusPlusSheaf J D).PreservesZeroMorphisms where map_zero F G := by ext : 3 refine colimit.hom_ext (fun j => ?_) erw [colimit.ι_map, comp_zero, J.plusMap_zero, J.diagramNatTrans_zero, zero_comp] /-- The sheafification functor is left adjoint to the forgetful functor. -/ @[simps! unit_app counit_app_val] noncomputable def plusPlusAdjunction : plusPlusSheaf J D ⊣ sheafToPresheaf J D := Adjunction.mkOfHomEquiv { homEquiv := fun P Q => { toFun := fun e => J.toSheafify P ≫ e.val invFun := fun e => ⟨J.sheafifyLift e Q.2⟩ left_inv := fun e => Sheaf.Hom.ext <| (J.sheafifyLift_unique _ _ _ rfl).symm right_inv := fun e => J.toSheafify_sheafifyLift _ _ } homEquiv_naturality_left_symm := by intro P Q R η γ; ext1; dsimp; symm apply J.sheafifyMap_sheafifyLift homEquiv_naturality_right := fun η γ => by dsimp rw [Category.assoc] } instance sheafToPresheaf_isRightAdjoint : (sheafToPresheaf J D).IsRightAdjoint := (plusPlusAdjunction J D).isRightAdjoint instance presheaf_mono_of_mono {F G : Sheaf J D} (f : F ⟶ G) [Mono f] : Mono f.1 := (sheafToPresheaf J D).map_mono _ theorem Sheaf.Hom.mono_iff_presheaf_mono {F G : Sheaf J D} (f : F ⟶ G) : Mono f ↔ Mono f.1 := ⟨fun m => by infer_instance, fun m => by exact Sheaf.Hom.mono_of_presheaf_mono J D f⟩ -- Porting note: added to ease the port of CategoryTheory.Sites.LeftExact -- in mathlib, this was `by refl`, but here it would timeout @[simps! hom_app inv_app] noncomputable def GrothendieckTopology.sheafificationIsoPresheafToSheafCompSheafToPreasheaf : J.sheafification D ≅ plusPlusSheaf J D ⋙ sheafToPresheaf J D := NatIso.ofComponents fun P => Iso.refl _ end CategoryTheory
CategoryTheory\Sites\ConstantSheaf.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.Sites.Sheafification /-! # The constant sheaf We define the constant sheaf functor (the sheafification of the constant presheaf) `constantSheaf : D ⥤ Sheaf J D` and prove that it is left adjoint to evaluation at a terminal object (see `constantSheafAdj`). -/ namespace CategoryTheory open Limits Opposite Category Functor Sheaf variable {C : Type*} [Category C] (J : GrothendieckTopology C) variable (D : Type*) [Category D] /-- The constant presheaf functor is left adjoint to evaluation at a terminal object. -/ noncomputable def constantPresheafAdj {T : C} (hT : IsTerminal T) : Functor.const Cᵒᵖ ⊣ (evaluation Cᵒᵖ D).obj (op T) := Adjunction.mkOfUnitCounit { unit := (Functor.constCompEvaluationObj D (op T)).hom counit := { app := fun F => { app := fun ⟨X⟩ => F.map (IsTerminal.from hT X).op naturality := fun _ _ _ => by simp only [Functor.comp_obj, Functor.const_obj_obj, Functor.id_obj, Functor.const_obj_map, Category.id_comp, ← Functor.map_comp] congr simp } naturality := by intros; ext; simp /- Note: `aesop` works but is kind of slow -/ } } variable [HasWeakSheafify J D] /-- The functor which maps an object of `D` to the constant sheaf at that object, i.e. the sheafification of the constant presheaf. -/ noncomputable def constantSheaf : D ⥤ Sheaf J D := Functor.const Cᵒᵖ ⋙ (presheafToSheaf J D) /-- The constant sheaf functor is left adjoint to evaluation at a terminal object. -/ noncomputable def constantSheafAdj {T : C} (hT : IsTerminal T) : constantSheaf J D ⊣ (sheafSections J D).obj (op T) := (constantPresheafAdj D hT).comp (sheafificationAdjunction J D) lemma constantSheafAdj_counit_app {T : C} (hT : IsTerminal T) (F : Sheaf J D) : (constantSheafAdj J D hT).counit.app F = (presheafToSheaf J D).map ((constantPresheafAdj D hT).counit.app F.val) ≫ (sheafificationAdjunction J D).counit.app F := by apply Sheaf.hom_ext apply sheafify_hom_ext _ _ _ F.cond simp only [flip_obj_obj, sheafToPresheaf_obj, comp_obj, id_obj, constantSheafAdj, Adjunction.comp, evaluation_obj_obj, constantPresheafAdj, Opposite.op_unop, Adjunction.mkOfUnitCounit_unit, Adjunction.mkOfUnitCounit_counit, NatTrans.comp_app, associator_hom_app, whiskerLeft_app, whiskerRight_app, instCategorySheaf_comp_val, instCategorySheaf_id_val, sheafificationAdjunction_counit_app_val, sheafifyMap_sheafifyLift, comp_id, toSheafify_sheafifyLift] erw [id_comp, toSheafify_sheafifyLift] end CategoryTheory
CategoryTheory\Sites\Continuous.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, Andrew Yang -/ import Mathlib.CategoryTheory.Sites.IsSheafOneHypercover /-! # Continuous functors between sites. We define the notion of continuous functor between sites: these are functors `F` such that the precomposition with `F.op` preserves sheaves of types (and actually sheaves in any category). ## Main definitions * `Functor.IsContinuous`: a functor between sites is continuous if the precomposition with this functor preserves sheaves with values in the category `Type t` for a certain auxiliary universe `t`. * `Functor.sheafPushforwardContinuous`: the induced functor `Sheaf K A ⥤ Sheaf J A` for a continuous functor `G : (C, J) ⥤ (D, K)`. In case this is part of a morphism of sites, this would be understood as the pushforward functor even though it goes in the opposite direction as the functor `G`. (Here, the auxiliary universe `t` in the assumption that `G` is continuous is the one such that morphisms in the category `A` are in `Type t`.) * `Functor.PreservesOneHypercovers`: a type-class expressing that a functor preserves 1-hypercovers of a certain size ## Main result - `Functor.isContinuous_of_preservesOneHypercovers`: if the topology on `C` is generated by 1-hypercovers of size `w` and that `F : C ⥤ D` preserves 1-hypercovers of size `w`, then `F` is continuous (for any auxiliary universe parameter `t`). This is an instance for `w = max u₁ v₁` when `C : Type u₁` and `[Category.{v₁} C]` ## References * https://stacks.math.columbia.edu/tag/00WU -/ universe w t v₁ v₂ v₃ u₁ u₂ u₃ u namespace CategoryTheory open Limits variable {C : Type u₁} [Category.{v₁} C] {D : Type u₂} [Category.{v₂} D] {E : Type u₃} [Category.{v₃} E] namespace PreOneHypercover variable {X : C} (E : PreOneHypercover X) (F : C ⥤ D) /-- The image of a 1-pre-hypercover by a functor. -/ @[simps] def map : PreOneHypercover (F.obj X) where I₀ := E.I₀ X i := F.obj (E.X i) f i := F.map (E.f i) I₁ := E.I₁ Y _ _ j := F.obj (E.Y j) p₁ _ _ j := F.map (E.p₁ j) p₂ _ _ j := F.map (E.p₂ j) w _ _ j := by simpa using F.congr_map (E.w j) /-- If `F : C ⥤ D`, `P : Dᵒᵖ ⥤ A` and `E` is a 1-pre-hypercover of an object of `X`, then `(E.map F).multifork P` is a limit iff `E.multifork (F.op ⋙ P)` is a limit. -/ def isLimitMapMultiforkEquiv {A : Type u} [Category.{t} A] (P : Dᵒᵖ ⥤ A) : IsLimit ((E.map F).multifork P) ≃ IsLimit (E.multifork (F.op ⋙ P)) := by rfl end PreOneHypercover namespace GrothendieckTopology namespace OneHypercover variable {J : GrothendieckTopology C} {X : C} (E : J.OneHypercover X) /-- A 1-hypercover in `C` is preserved by a functor `F : C ⥤ D` if the mapped 1-pre-hypercover in `D` is a 1-hypercover for the given topology on `D`. -/ class IsPreservedBy (F : C ⥤ D) (K : GrothendieckTopology D) : Prop where mem₀ : (E.toPreOneHypercover.map F).sieve₀ ∈ K (F.obj X) mem₁ (i₁ i₂ : E.I₀) ⦃W : D⦄ (p₁ : W ⟶ F.obj (E.X i₁)) (p₂ : W ⟶ F.obj (E.X i₂)) (w : p₁ ≫ F.map (E.f i₁) = p₂ ≫ F.map (E.f i₂)) : (E.toPreOneHypercover.map F).sieve₁ p₁ p₂ ∈ K W /-- Given a 1-hypercover `E : J.OneHypercover X` of an object of `C`, a functor `F : C ⥤ D` such that `E.IsPreversedBy F K` for a Grothendieck topology `K` on `D`, this is the image of `E` by `F`, as a 1-hypercover of `F.obj X` for `K`. -/ @[simps toPreOneHypercover] def map (F : C ⥤ D) (K : GrothendieckTopology D) [E.IsPreservedBy F K] : K.OneHypercover (F.obj X) where toPreOneHypercover := E.toPreOneHypercover.map F mem₀ := IsPreservedBy.mem₀ mem₁ := IsPreservedBy.mem₁ instance : E.IsPreservedBy (𝟭 C) J where mem₀ := E.mem₀ mem₁ := E.mem₁ end OneHypercover end GrothendieckTopology namespace Functor variable (F : C ⥤ D) {A : Type u} [Category.{t} A] (J : GrothendieckTopology C) (K : GrothendieckTopology D) /-- The condition that a functor `F : C ⥤ D` sends 1-hypercovers for `J : GrothendieckTopology C` to 1-hypercovers for `K : GrothendieckTopology D`. -/ abbrev PreservesOneHypercovers := ∀ {X : C} (E : GrothendieckTopology.OneHypercover.{w} J X), E.IsPreservedBy F K /-- A functor `F` is continuous if the precomposition with `F.op` sends sheaves of `Type t` to sheaves. -/ class IsContinuous : Prop where op_comp_isSheafOfTypes (G : SheafOfTypes.{t} K) : Presieve.IsSheaf J (F.op ⋙ G.val) lemma op_comp_isSheafOfTypes [Functor.IsContinuous.{t} F J K] (G : SheafOfTypes.{t} K) : Presieve.IsSheaf J (F.op ⋙ G.val) := Functor.IsContinuous.op_comp_isSheafOfTypes _ lemma op_comp_isSheaf [Functor.IsContinuous.{t} F J K] (G : Sheaf K A) : Presheaf.IsSheaf J (F.op ⋙ G.val) := fun T => F.op_comp_isSheafOfTypes J K ⟨_, G.cond T⟩ lemma isContinuous_of_iso {F₁ F₂ : C ⥤ D} (e : F₁ ≅ F₂) (J : GrothendieckTopology C) (K : GrothendieckTopology D) [Functor.IsContinuous.{t} F₁ J K] : Functor.IsContinuous.{t} F₂ J K where op_comp_isSheafOfTypes G := Presieve.isSheaf_iso J (isoWhiskerRight (NatIso.op e.symm) _) (F₁.op_comp_isSheafOfTypes J K G) instance isContinuous_id : Functor.IsContinuous.{w} (𝟭 C) J J where op_comp_isSheafOfTypes G := G.2 lemma isContinuous_comp (F₁ : C ⥤ D) (F₂ : D ⥤ E) (J : GrothendieckTopology C) (K : GrothendieckTopology D) (L : GrothendieckTopology E) [Functor.IsContinuous.{t} F₁ J K] [Functor.IsContinuous.{t} F₂ K L] : Functor.IsContinuous.{t} (F₁ ⋙ F₂) J L where op_comp_isSheafOfTypes G := F₁.op_comp_isSheafOfTypes J K ⟨_, F₂.op_comp_isSheafOfTypes K L G⟩ lemma isContinuous_comp' {F₁ : C ⥤ D} {F₂ : D ⥤ E} {F₁₂ : C ⥤ E} (e : F₁ ⋙ F₂ ≅ F₁₂) (J : GrothendieckTopology C) (K : GrothendieckTopology D) (L : GrothendieckTopology E) [Functor.IsContinuous.{t} F₁ J K] [Functor.IsContinuous.{t} F₂ K L] : Functor.IsContinuous.{t} F₁₂ J L := by have := Functor.isContinuous_comp F₁ F₂ J K L apply Functor.isContinuous_of_iso e section lemma op_comp_isSheaf_of_preservesOneHypercovers [PreservesOneHypercovers.{w} F J K] [GrothendieckTopology.IsGeneratedByOneHypercovers.{w} J] (P : Dᵒᵖ ⥤ A) (hP : Presheaf.IsSheaf K P) : Presheaf.IsSheaf J (F.op ⋙ P) := by rw [Presheaf.isSheaf_iff_of_isGeneratedByOneHypercovers.{w}] intro X E exact ⟨(E.toPreOneHypercover.isLimitMapMultiforkEquiv F P) ((E.map F K).isLimitMultifork ⟨P, hP⟩)⟩ lemma isContinuous_of_preservesOneHypercovers [PreservesOneHypercovers.{w} F J K] [GrothendieckTopology.IsGeneratedByOneHypercovers.{w} J] : IsContinuous.{t} F J K where op_comp_isSheafOfTypes := by rintro ⟨P, hP⟩ rw [← isSheaf_iff_isSheaf_of_type] at hP ⊢ exact F.op_comp_isSheaf_of_preservesOneHypercovers J K P hP end instance [PreservesOneHypercovers.{max u₁ v₁} F J K] : IsContinuous.{t} F J K := isContinuous_of_preservesOneHypercovers.{max u₁ v₁} F J K variable (A) variable [Functor.IsContinuous.{t} F J K] /-- The induced functor `Sheaf K A ⥤ Sheaf J A` given by `F.op ⋙ _` if `F` is a continuous functor. -/ @[simps!] def sheafPushforwardContinuous : Sheaf K A ⥤ Sheaf J A where obj ℱ := ⟨F.op ⋙ ℱ.val, F.op_comp_isSheaf J K ℱ⟩ map f := ⟨((whiskeringLeft _ _ _).obj F.op).map f.val⟩ /-- The functor `F.sheafPushforwardContinuous A J K : Sheaf K A ⥤ Sheaf J A` is induced by the precomposition with `F.op`. -/ @[simps!] def sheafPushforwardContinuousCompSheafToPresheafIso : F.sheafPushforwardContinuous A J K ⋙ sheafToPresheaf J A ≅ sheafToPresheaf K A ⋙ (whiskeringLeft _ _ _).obj F.op := Iso.refl _ end Functor end CategoryTheory
CategoryTheory\Sites\Coverage.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.Sites.Sheaf /-! # Coverages A coverage `K` on a category `C` is a set of presieves associated to every object `X : C`, called "covering presieves". This collection must satisfy a certain "pullback compatibility" condition, saying that whenever `S` is a covering presieve on `X` and `f : Y ⟶ X` is a morphism, then there exists some covering sieve `T` on `Y` such that `T` factors through `S` along `f`. The main difference between a coverage and a Grothendieck pretopology is that we *do not* require `C` to have pullbacks. This is useful, for example, when we want to consider the Grothendieck topology on the category of extremally disconnected sets in the context of condensed mathematics. A more concrete example: If `ℬ` is a basis for a topology on a type `X` (in the sense of `TopologicalSpace.IsTopologicalBasis`) then it naturally induces a coverage on `Opens X` whose associated Grothendieck topology is the one induced by the topology on `X` generated by `ℬ`. (Project: Formalize this!) ## Main Definitions and Results: All definitions are in the `CategoryTheory` namespace. - `Coverage C`: The type of coverages on `C`. - `Coverage.ofGrothendieck C`: A function which associates a coverage to any Grothendieck topology. - `Coverage.toGrothendieck C`: A function which associates a Grothendieck topology to any coverage. - `Coverage.gi`: The two functions above form a Galois insertion. - `Presieve.isSheaf_coverage`: Given `K : Coverage C` with associated Grothendieck topology `J`, a `Type*`-valued presheaf on `C` is a sheaf for `K` if and only if it is a sheaf for `J`. # References We don't follow any particular reference, but the arguments can probably be distilled from the following sources: - [Elephant]: *Sketches of an Elephant*, P. T. Johnstone: C2.1. - [nLab, *Coverage*](https://ncatlab.org/nlab/show/coverage) -/ namespace CategoryTheory variable {C D : Type _} [Category C] [Category D] open Limits namespace Presieve /-- Given a morphism `f : Y ⟶ X`, a presieve `S` on `Y` and presieve `T` on `X`, we say that *`S` factors through `T` along `f`*, written `S.FactorsThruAlong T f`, provided that for any morphism `g : Z ⟶ Y` in `S`, there exists some morphism `e : W ⟶ X` in `T` and some morphism `i : Z ⟶ W` such that the obvious square commutes: `i ≫ e = g ≫ f`. This is used in the definition of a coverage. -/ def FactorsThruAlong {X Y : C} (S : Presieve Y) (T : Presieve X) (f : Y ⟶ X) : Prop := ∀ ⦃Z : C⦄ ⦃g : Z ⟶ Y⦄, S g → ∃ (W : C) (i : Z ⟶ W) (e : W ⟶ X), T e ∧ i ≫ e = g ≫ f /-- Given `S T : Presieve X`, we say that `S` factors through `T` if any morphism in `S` factors through some morphism in `T`. The lemma `Presieve.isSheafFor_of_factorsThru` gives a *sufficient* condition for a presheaf to be a sheaf for a presieve `T`, in terms of `S.FactorsThru T`, provided that the presheaf is a sheaf for `S`. -/ def FactorsThru {X : C} (S T : Presieve X) : Prop := ∀ ⦃Z : C⦄ ⦃g : Z ⟶ X⦄, S g → ∃ (W : C) (i : Z ⟶ W) (e : W ⟶ X), T e ∧ i ≫ e = g @[simp] lemma factorsThruAlong_id {X : C} (S T : Presieve X) : S.FactorsThruAlong T (𝟙 X) ↔ S.FactorsThru T := by simp [FactorsThruAlong, FactorsThru] lemma factorsThru_of_le {X : C} (S T : Presieve X) (h : S ≤ T) : S.FactorsThru T := fun Y g hg => ⟨Y, 𝟙 _, g, h _ hg, by simp⟩ lemma le_of_factorsThru_sieve {X : C} (S : Presieve X) (T : Sieve X) (h : S.FactorsThru T) : S ≤ T := by rintro Y f hf obtain ⟨W, i, e, h1, rfl⟩ := h hf exact T.downward_closed h1 _ lemma factorsThru_top {X : C} (S : Presieve X) : S.FactorsThru ⊤ := factorsThru_of_le _ _ le_top lemma isSheafFor_of_factorsThru {X : C} {S T : Presieve X} (P : Cᵒᵖ ⥤ Type*) (H : S.FactorsThru T) (hS : S.IsSheafFor P) (h : ∀ ⦃Y : C⦄ ⦃f : Y ⟶ X⦄, T f → ∃ (R : Presieve Y), R.IsSeparatedFor P ∧ R.FactorsThruAlong S f) : T.IsSheafFor P := by simp only [← Presieve.isSeparatedFor_and_exists_isAmalgamation_iff_isSheafFor] at * choose W i e h1 h2 using H refine ⟨?_, fun x hx => ?_⟩ · intro x y₁ y₂ h₁ h₂ refine hS.1.ext (fun Y g hg => ?_) simp only [← h2 hg, op_comp, P.map_comp, types_comp_apply, h₁ _ (h1 _ ), h₂ _ (h1 _)] let y : S.FamilyOfElements P := fun Y g hg => P.map (i _).op (x (e hg) (h1 _)) have hy : y.Compatible := by intro Y₁ Y₂ Z g₁ g₂ f₁ f₂ h₁ h₂ h rw [← types_comp_apply (P.map (i h₁).op) (P.map g₁.op), ← types_comp_apply (P.map (i h₂).op) (P.map g₂.op), ← P.map_comp, ← op_comp, ← P.map_comp, ← op_comp] apply hx simp only [h2, h, Category.assoc] let ⟨_, h2'⟩ := hS obtain ⟨z, hz⟩ := h2' y hy refine ⟨z, fun Y g hg => ?_⟩ obtain ⟨R, hR1, hR2⟩ := h hg choose WW ii ee hh1 hh2 using hR2 refine hR1.ext (fun Q t ht => ?_) rw [← types_comp_apply (P.map g.op) (P.map t.op), ← P.map_comp, ← op_comp, ← hh2 ht, op_comp, P.map_comp, types_comp_apply, hz _ (hh1 _), ← types_comp_apply _ (P.map (ii ht).op), ← P.map_comp, ← op_comp] apply hx simp only [Category.assoc, h2, hh2] end Presieve variable (C) in /-- The type `Coverage C` of coverages on `C`. A coverage is a collection of *covering* presieves on every object `X : C`, which satisfies a *pullback compatibility* condition. Explicitly, this condition says that whenever `S` is a covering presieve for `X` and `f : Y ⟶ X` is a morphism, then there exists some covering presieve `T` for `Y` such that `T` factors through `S` along `f`. -/ @[ext] structure Coverage where /-- The collection of covering presieves for an object `X`. -/ covering : ∀ (X : C), Set (Presieve X) /-- Given any covering sieve `S` on `X` and a morphism `f : Y ⟶ X`, there exists some covering sieve `T` on `Y` such that `T` factors through `S` along `f`. -/ pullback : ∀ ⦃X Y : C⦄ (f : Y ⟶ X) (S : Presieve X) (_ : S ∈ covering X), ∃ (T : Presieve Y), T ∈ covering Y ∧ T.FactorsThruAlong S f namespace Coverage instance : CoeFun (Coverage C) (fun _ => (X : C) → Set (Presieve X)) where coe := covering variable (C) in /-- Associate a coverage to any Grothendieck topology. If `J` is a Grothendieck topology, and `K` is the associated coverage, then a presieve `S` is a covering presieve for `K` if and only if the sieve that it generates is a covering sieve for `J`. -/ def ofGrothendieck (J : GrothendieckTopology C) : Coverage C where covering X := { S | Sieve.generate S ∈ J X } pullback := by intro X Y f S (hS : Sieve.generate S ∈ J X) refine ⟨(Sieve.generate S).pullback f, ?_, fun Z g h => h⟩ dsimp rw [Sieve.generate_sieve] exact J.pullback_stable _ hS lemma ofGrothendieck_iff {X : C} {S : Presieve X} (J : GrothendieckTopology C) : S ∈ ofGrothendieck _ J X ↔ Sieve.generate S ∈ J X := Iff.rfl /-- An auxiliary definition used to define the Grothendieck topology associated to a coverage. See `Coverage.toGrothendieck`. -/ inductive Saturate (K : Coverage C) : (X : C) → Sieve X → Prop where | of (X : C) (S : Presieve X) (hS : S ∈ K X) : Saturate K X (Sieve.generate S) | top (X : C) : Saturate K X ⊤ | transitive (X : C) (R S : Sieve X) : Saturate K X R → (∀ ⦃Y : C⦄ ⦃f : Y ⟶ X⦄, R f → Saturate K Y (S.pullback f)) → Saturate K X S lemma eq_top_pullback {X Y : C} {S T : Sieve X} (h : S ≤ T) (f : Y ⟶ X) (hf : S f) : T.pullback f = ⊤ := by ext Z g simp only [Sieve.pullback_apply, Sieve.top_apply, iff_true] apply h apply S.downward_closed exact hf lemma saturate_of_superset (K : Coverage C) {X : C} {S T : Sieve X} (h : S ≤ T) (hS : Saturate K X S) : Saturate K X T := by apply Saturate.transitive _ _ _ hS intro Y g hg rw [eq_top_pullback (h := h)] · apply Saturate.top · assumption variable (C) in /-- The Grothendieck topology associated to a coverage `K`. It is defined *inductively* as follows: 1. If `S` is a covering presieve for `K`, then the sieve generated by `S` is a covering sieve for the associated Grothendieck topology. 2. The top sieves are in the associated Grothendieck topology. 3. Add all sieves required by the *local character* axiom of a Grothendieck topology. The pullback compatibility condition for a coverage ensures that the associated Grothendieck topology is pullback stable, and so an additional constructor in the inductive construction is not needed. -/ def toGrothendieck (K : Coverage C) : GrothendieckTopology C where sieves := Saturate K top_mem' := .top pullback_stable' := by intro X Y S f hS induction hS generalizing Y with | of X S hS => obtain ⟨R,hR1,hR2⟩ := K.pullback f S hS suffices Sieve.generate R ≤ (Sieve.generate S).pullback f from saturate_of_superset _ this (Saturate.of _ _ hR1) rintro Z g ⟨W, i, e, h1, h2⟩ obtain ⟨WW, ii, ee, hh1, hh2⟩ := hR2 h1 refine ⟨WW, i ≫ ii, ee, hh1, ?_⟩ simp only [hh2, reassoc_of% h2, Category.assoc] | top X => apply Saturate.top | transitive X R S _ hS H1 _ => apply Saturate.transitive · apply H1 f intro Z g hg rw [← Sieve.pullback_comp] exact hS hg transitive' X S hS R hR := .transitive _ _ _ hS hR instance : PartialOrder (Coverage C) where le A B := A.covering ≤ B.covering le_refl A X := le_refl _ le_trans A B C h1 h2 X := le_trans (h1 X) (h2 X) le_antisymm A B h1 h2 := Coverage.ext <| funext <| fun X => le_antisymm (h1 X) (h2 X) variable (C) in /-- The two constructions `Coverage.toGrothendieck` and `Coverage.ofGrothendieck` form a Galois insertion. -/ def gi : GaloisInsertion (toGrothendieck C) (ofGrothendieck C) where choice K _ := toGrothendieck _ K choice_eq := fun _ _ => rfl le_l_u J X S hS := by rw [← Sieve.generate_sieve S] apply Saturate.of dsimp [ofGrothendieck] rwa [Sieve.generate_sieve S] gc K J := by constructor · intro H X S hS exact H _ <| Saturate.of _ _ hS · intro H X S hS induction hS with | of X S hS => exact H _ hS | top => apply J.top_mem | transitive X R S _ _ H1 H2 => exact J.transitive H1 _ H2 /-- An alternative characterization of the Grothendieck topology associated to a coverage `K`: it is the infimum of all Grothendieck topologies whose associated coverage contains `K`. -/ theorem toGrothendieck_eq_sInf (K : Coverage C) : toGrothendieck _ K = sInf {J | K ≤ ofGrothendieck _ J } := by apply le_antisymm · apply le_sInf; intro J hJ intro X S hS induction hS with | of X S hS => apply hJ; assumption | top => apply J.top_mem | transitive X R S _ _ H1 H2 => exact J.transitive H1 _ H2 · apply sInf_le intro X S hS apply Saturate.of _ _ hS instance : SemilatticeSup (Coverage C) where sup x y := { covering := fun B ↦ x.covering B ∪ y.covering B pullback := by rintro X Y f S (hx | hy) · obtain ⟨T, hT⟩ := x.pullback f S hx exact ⟨T, Or.inl hT.1, hT.2⟩ · obtain ⟨T, hT⟩ := y.pullback f S hy exact ⟨T, Or.inr hT.1, hT.2⟩ } toPartialOrder := inferInstance le_sup_left _ _ _ := Set.subset_union_left le_sup_right _ _ _ := Set.subset_union_right sup_le _ _ _ hx hy X := Set.union_subset_iff.mpr ⟨hx X, hy X⟩ @[simp] lemma sup_covering (x y : Coverage C) (B : C) : (x ⊔ y).covering B = x.covering B ∪ y.covering B := rfl /-- Any sieve that contains a covering presieve for a coverage is a covering sieve for the associated Grothendieck topology. -/ theorem mem_toGrothendieck_sieves_of_superset (K : Coverage C) {X : C} {S : Sieve X} {R : Presieve X} (h : R ≤ S) (hR : R ∈ K.covering X) : S ∈ (K.toGrothendieck C).sieves X := K.saturate_of_superset ((Sieve.generate_le_iff _ _).mpr h) (Coverage.Saturate.of X _ hR) end Coverage open Coverage namespace Presieve /-- The main theorem of this file: Given a coverage `K` on `C`, a `Type*`-valued presheaf on `C` is a sheaf for `K` if and only if it is a sheaf for the associated Grothendieck topology. -/ theorem isSheaf_coverage (K : Coverage C) (P : Cᵒᵖ ⥤ Type*) : Presieve.IsSheaf (toGrothendieck _ K) P ↔ (∀ {X : C} (R : Presieve X), R ∈ K X → Presieve.IsSheafFor P R) := by constructor · intro H X R hR rw [Presieve.isSheafFor_iff_generate] apply H _ <| Saturate.of _ _ hR · intro H X S hS -- This is the key point of the proof: -- We must generalize the induction in the correct way. suffices ∀ ⦃Y : C⦄ (f : Y ⟶ X), Presieve.IsSheafFor P (S.pullback f).arrows by simpa using this (f := 𝟙 _) induction hS with | of X S hS => intro Y f obtain ⟨T, hT1, hT2⟩ := K.pullback f S hS apply Presieve.isSheafFor_of_factorsThru (S := T) · intro Z g hg obtain ⟨W, i, e, h1, h2⟩ := hT2 hg exact ⟨Z, 𝟙 _, g, ⟨W, i, e, h1, h2⟩, by simp⟩ · apply H; assumption · intro Z g _ obtain ⟨R, hR1, hR2⟩ := K.pullback g _ hT1 exact ⟨R, (H _ hR1).isSeparatedFor, hR2⟩ | top => intros; simpa using Presieve.isSheafFor_top_sieve _ | transitive X R S _ _ H1 H2 => intro Y f simp only [← Presieve.isSeparatedFor_and_exists_isAmalgamation_iff_isSheafFor] at * choose H1 H1' using H1 choose H2 H2' using H2 refine ⟨?_, fun x hx => ?_⟩ · intro x t₁ t₂ h₁ h₂ refine (H1 f).ext (fun Z g hg => ?_) refine (H2 hg (𝟙 _)).ext (fun ZZ gg hgg => ?_) simp only [Sieve.pullback_id, Sieve.pullback_apply] at hgg simp only [← types_comp_apply] rw [← P.map_comp, ← op_comp, h₁, h₂] simpa only [Sieve.pullback_apply, Category.assoc] using hgg let y : ∀ ⦃Z : C⦄ (g : Z ⟶ Y), ((S.pullback (g ≫ f)).pullback (𝟙 _)).arrows.FamilyOfElements P := fun Z g ZZ gg hgg => x (gg ≫ g) (by simpa using hgg) have hy : ∀ ⦃Z : C⦄ (g : Z ⟶ Y), (y g).Compatible := by intro Z g Y₁ Y₂ ZZ g₁ g₂ f₁ f₂ h₁ h₂ h rw [hx] rw [reassoc_of% h] choose z hz using fun ⦃Z : C⦄ ⦃g : Z ⟶ Y⦄ (hg : R.pullback f g) => H2' hg (𝟙 _) (y g) (hy g) let q : (R.pullback f).arrows.FamilyOfElements P := fun Z g hg => z hg have hq : q.Compatible := by intro Y₁ Y₂ Z g₁ g₂ f₁ f₂ h₁ h₂ h apply (H2 h₁ g₁).ext intro ZZ gg hgg simp only [← types_comp_apply] rw [← P.map_comp, ← P.map_comp, ← op_comp, ← op_comp, hz, hz] · dsimp [y]; congr 1; simp only [Category.assoc, h] · simpa [reassoc_of% h] using hgg · simpa using hgg obtain ⟨t, ht⟩ := H1' f q hq refine ⟨t, fun Z g hg => ?_⟩ refine (H1 (g ≫ f)).ext (fun ZZ gg hgg => ?_) rw [← types_comp_apply _ (P.map gg.op), ← P.map_comp, ← op_comp, ht] on_goal 2 => simpa using hgg refine (H2 hgg (𝟙 _)).ext (fun ZZZ ggg hggg => ?_) rw [← types_comp_apply _ (P.map ggg.op), ← P.map_comp, ← op_comp, hz] on_goal 2 => simpa using hggg refine (H2 hgg ggg).ext (fun ZZZZ gggg _ => ?_) rw [← types_comp_apply _ (P.map gggg.op), ← P.map_comp, ← op_comp] apply hx simp /-- A presheaf is a sheaf for the Grothendieck topology generated by a union of coverages iff it is a sheaf for the Grothendieck topology generated by each coverage separately. -/ theorem isSheaf_sup (K L : Coverage C) (P : Cᵒᵖ ⥤ Type*) : (Presieve.IsSheaf ((K ⊔ L).toGrothendieck C)) P ↔ (Presieve.IsSheaf (K.toGrothendieck C)) P ∧ (Presieve.IsSheaf (L.toGrothendieck C)) P := by refine ⟨fun h ↦ ⟨Presieve.isSheaf_of_le _ ((gi C).gc.monotone_l le_sup_left) h, Presieve.isSheaf_of_le _ ((gi C).gc.monotone_l le_sup_right) h⟩, fun h ↦ ?_⟩ rw [isSheaf_coverage, isSheaf_coverage] at h rw [isSheaf_coverage] intro X R hR cases' hR with hR hR · exact h.1 R hR · exact h.2 R hR end Presieve namespace Presheaf theorem isSheaf_iff_isLimit_coverage (K : Coverage C) (P : Cᵒᵖ ⥤ D) : Presheaf.IsSheaf (toGrothendieck _ K) P ↔ ∀ ⦃X : C⦄ (R : Presieve X), R ∈ K.covering X → Nonempty (IsLimit (P.mapCone (Sieve.generate R).arrows.cocone.op)) := by simp only [Presheaf.IsSheaf, Presieve.isSheaf_coverage, isLimit_iff_isSheafFor, ← Presieve.isSheafFor_iff_generate] aesop theorem isSheaf_sup (K L : Coverage C) (P : Cᵒᵖ ⥤ D) : (IsSheaf ((K ⊔ L).toGrothendieck C)) P ↔ (IsSheaf (K.toGrothendieck C)) P ∧ (IsSheaf (L.toGrothendieck C)) P := ⟨fun h ↦ ⟨fun E ↦ ((Presieve.isSheaf_sup K L _).mp (h E)).1, fun E ↦ ((Presieve.isSheaf_sup K L _).mp (h E)).2⟩, fun ⟨h₁, h₂⟩ E ↦ (Presieve.isSheaf_sup K L _).mpr ⟨h₁ E, h₂ E⟩⟩ end Presheaf end CategoryTheory
CategoryTheory\Sites\CoverLifting.lean
/- Copyright (c) 2021 Andrew Yang. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Andrew Yang, Joël Riou -/ import Mathlib.CategoryTheory.Adjunction.Restrict import Mathlib.CategoryTheory.Functor.KanExtension.Adjunction import Mathlib.CategoryTheory.Sites.Continuous import Mathlib.CategoryTheory.Sites.Sheafification /-! # Cocontinuous functors between sites. We define cocontinuous functors between sites as functors that pull covering sieves back to covering sieves. This concept is also known as *cover-lifting* or *cover-reflecting functors*. We use the original terminology and definition of SGA 4 III 2.1. However, the notion of cocontinuous functor should not be confused with the general definition of cocontinuous functors between categories as functors preserving small colimits. ## Main definitions * `CategoryTheory.Functor.IsCocontinuous`: a functor between sites is cocontinuous if it pulls back covering sieves to covering sieves * `CategoryTheory.Functor.sheafPushforwardCocontinuous`: A cocontinuous functor `G : (C, J) ⥤ (D, K)` induces a functor `Sheaf J A ⥤ Sheaf K A`. ## Main results * `CategoryTheory.ran_isSheaf_of_isCocontinuous`: If `G : C ⥤ D` is cocontinuous, then `G.op.ran` (`ₚu`) as a functor `(Cᵒᵖ ⥤ A) ⥤ (Dᵒᵖ ⥤ A)` of presheaves maps sheaves to sheaves. * `CategoryTheory.Functor.sheafAdjunctionCocontinuous`: If `G : (C, J) ⥤ (D, K)` is cocontinuous and continuous, then `G.sheafPushforwardContinuous A J K` and `G.sheafPushforwardCocontinuous A J K` are adjoint. ## References * [Elephant]: *Sketches of an Elephant*, P. T. Johnstone: C2.3. * [S. MacLane, I. Moerdijk, *Sheaves in Geometry and Logic*][MM92] * https://stacks.math.columbia.edu/tag/00XI -/ universe w' w v v₁ v₂ v₃ u u₁ u₂ u₃ noncomputable section open CategoryTheory open Opposite open CategoryTheory.Presieve.FamilyOfElements open CategoryTheory.Presieve open CategoryTheory.Limits namespace CategoryTheory section IsCocontinuous variable {C : Type*} [Category C] {D : Type*} [Category D] {E : Type*} [Category E] (G : C ⥤ D) (G' : D ⥤ E) variable (J : GrothendieckTopology C) (K : GrothendieckTopology D) variable {L : GrothendieckTopology E} /-- A functor `G : (C, J) ⥤ (D, K)` between sites is called cocontinuous (SGA 4 III 2.1) if for all covering sieves `R` in `D`, `R.pullback G` is a covering sieve in `C`. -/ -- Porting note(#5171): removed `@[nolint has_nonempty_instance]` class Functor.IsCocontinuous : Prop where cover_lift : ∀ {U : C} {S : Sieve (G.obj U)} (_ : S ∈ K (G.obj U)), S.functorPullback G ∈ J U lemma Functor.cover_lift [G.IsCocontinuous J K] {U : C} {S : Sieve (G.obj U)} (hS : S ∈ K (G.obj U)) : S.functorPullback G ∈ J U := IsCocontinuous.cover_lift hS /-- The identity functor on a site is cocontinuous. -/ instance isCocontinuous_id : Functor.IsCocontinuous (𝟭 C) J J := ⟨fun h => by simpa using h⟩ /-- The composition of two cocontinuous functors is cocontinuous. -/ theorem isCocontinuous_comp [G.IsCocontinuous J K] [G'.IsCocontinuous K L] : (G ⋙ G').IsCocontinuous J L where cover_lift h := G.cover_lift J K (G'.cover_lift K L h) end IsCocontinuous /-! We will now prove that `G.op.ran : (Cᵒᵖ ⥤ A) ⥤ (Dᵒᵖ ⥤ A)` maps sheaves to sheaves when `G : C ⥤ D` is a cocontinuous functor. We do not follow the proofs in SGA 4 III 2.2 or <https://stacks.math.columbia.edu/tag/00XK>. Instead, we verify as directly as possible that if `F : Cᵒᵖ ⥤ A` is a sheaf, then `G.op.ran.obj F` is a sheaf. in order to do this, we use the "multifork" characterization of sheaves which involves limits in the category `A`. As `G.op.ran.obj F` is the chosen right Kan extension of `F` along `G.op : Cᵒᵖ ⥤ Dᵒᵖ`, we actually verify that any pointwise right Kan extension of `F` along `G.op` is a sheaf. -/ variable {C D : Type*} [Category C] [Category D] (G : C ⥤ D) variable {A : Type w} [Category.{w'} A] variable {J : GrothendieckTopology C} {K : GrothendieckTopology D} [G.IsCocontinuous J K] namespace RanIsSheafOfIsCocontinuous variable {G} variable {F : Cᵒᵖ ⥤ A} (hF : Presheaf.IsSheaf J F) variable {R : Dᵒᵖ ⥤ A} (α : G.op ⋙ R ⟶ F) variable (hR : (Functor.RightExtension.mk _ α).IsPointwiseRightKanExtension) variable {X : D} {S : K.Cover X} (s : Multifork (S.index R)) /-- Auxiliary definition for `lift`. -/ def liftAux {Y : C} (f : G.obj Y ⟶ X) : s.pt ⟶ F.obj (op Y) := Multifork.IsLimit.lift (hF.isLimitMultifork ⟨_, G.cover_lift J K (K.pullback_stable f S.2)⟩) (fun k ↦ s.ι (⟨_, G.map k.f ≫ f, k.hf⟩) ≫ α.app (op k.Y)) (by rintro ⟨⟨Y₁, p₁, hp₁⟩, ⟨Y₂, p₂, hp₂⟩, W, g₁, g₂, w⟩ dsimp at g₁ g₂ w ⊢ simp only [Category.assoc, ← α.naturality, Functor.comp_map, Functor.op_map, Quiver.Hom.unop_op] apply s.condition_assoc (GrothendieckTopology.Cover.Relation.mk { hf := hp₁ } { hf := hp₂ } { g₁ := G.map g₁ g₂ := G.map g₂ w := by simpa using G.congr_map w =≫ f })) lemma liftAux_map {Y : C} (f : G.obj Y ⟶ X) {W : C} (g : W ⟶ Y) (i : S.Arrow) (h : G.obj W ⟶ i.Y) (w : h ≫ i.f = G.map g ≫ f) : liftAux hF α s f ≫ F.map g.op = s.ι i ≫ R.map h.op ≫ α.app _ := (Multifork.IsLimit.fac (hF.isLimitMultifork ⟨_, G.cover_lift J K (K.pullback_stable f S.2)⟩) _ _ ⟨W, g, by simpa only [GrothendieckTopology.Cover.sieve, Sieve.functorPullback_apply, functorPullback_mem, Sieve.pullback_apply, ← w] using S.1.downward_closed i.hf h⟩).trans (by dsimp simp only [← Category.assoc] congr 1 let r : S.Relation := GrothendieckTopology.Cover.Relation.mk { f := G.map g ≫ f hf := by simpa only [← w] using S.1.downward_closed i.hf h } i { g₁ := 𝟙 _ g₂ := h w := by simpa using w.symm } simpa using s.condition r ) lemma liftAux_map' {Y Y' : C} (f : G.obj Y ⟶ X) (f' : G.obj Y' ⟶ X) {W : C} (a : W ⟶ Y) (b : W ⟶ Y') (w : G.map a ≫ f = G.map b ≫ f') : liftAux hF α s f ≫ F.map a.op = liftAux hF α s f' ≫ F.map b.op := by apply hF.hom_ext ⟨_, G.cover_lift J K (K.pullback_stable (G.map a ≫ f) S.2)⟩ rintro ⟨T, g, hg⟩ dsimp have eq₁ := liftAux_map hF α s f (g ≫ a) ⟨_, _, hg⟩ (𝟙 _) (by simp) have eq₂ := liftAux_map hF α s f' (g ≫ b) ⟨_, _, hg⟩ (𝟙 _) (by simp [w]) dsimp at eq₁ eq₂ simp only [Functor.map_comp, Functor.map_id, Category.id_comp] at eq₁ eq₂ simp only [Category.assoc, eq₁, eq₂] variable {α} /-- Auxiliary definition for `isLimitMultifork` -/ def lift : s.pt ⟶ R.obj (op X) := (hR (op X)).lift (Cone.mk _ { app := fun j ↦ liftAux hF α s j.hom.unop naturality := fun j j' φ ↦ by simpa using liftAux_map' hF α s j'.hom.unop j.hom.unop (𝟙 _) φ.right.unop (Quiver.Hom.op_inj (by simpa using (StructuredArrow.w φ).symm)) }) lemma fac' (j : StructuredArrow (op X) G.op) : lift hF hR s ≫ R.map j.hom ≫ α.app j.right = liftAux hF α s j.hom.unop := by apply IsLimit.fac @[reassoc (attr := simp)] lemma fac (i : S.Arrow) : lift hF hR s ≫ R.map i.f.op = s.ι i := by apply (hR (op i.Y)).hom_ext intro j have eq := fac' hF hR s (StructuredArrow.mk (i.f.op ≫ j.hom)) dsimp at eq ⊢ simp only [Functor.map_comp, Category.assoc] at eq rw [Category.assoc, eq] simpa using liftAux_map hF α s (j.hom.unop ≫ i.f) (𝟙 _) i j.hom.unop (by simp) variable (K) in lemma hom_ext {W : A} {f g : W ⟶ R.obj (op X)} (h : ∀ (i : S.Arrow), f ≫ R.map i.f.op = g ≫ R.map i.f.op) : f = g := by apply (hR (op X)).hom_ext intro j apply hF.hom_ext ⟨_, G.cover_lift J K (K.pullback_stable j.hom.unop S.2)⟩ intro ⟨W, i, hi⟩ have eq := h (GrothendieckTopology.Cover.Arrow.mk _ (G.map i ≫ j.hom.unop) hi) dsimp at eq ⊢ simp only [Category.assoc, ← NatTrans.naturality, Functor.comp_map, ← Functor.map_comp_assoc, Functor.op_map, Quiver.Hom.unop_op] rw [reassoc_of% eq] variable (S) /-- Auxiliary definition for `ran_isSheaf_of_isCocontinuous`: if `G : C ⥤ D` is a cocontinuous functor, -/ def isLimitMultifork : IsLimit (S.multifork R) := Multifork.IsLimit.mk _ (lift hF hR) (fac hF hR) (fun s _ hm ↦ hom_ext K hF hR (fun i ↦ (hm i).trans (fac hF hR s i).symm)) end RanIsSheafOfIsCocontinuous variable (K) variable [∀ (F : Cᵒᵖ ⥤ A), G.op.HasPointwiseRightKanExtension F] /-- If `G` is cocontinuous, then `G.op.ran` pushes sheaves to sheaves. This is SGA 4 III 2.2. An alternative reference is https://stacks.math.columbia.edu/tag/00XK (where results are obtained under the additional assumption that `C` and `D` have pullbacks). -/ theorem ran_isSheaf_of_isCocontinuous (ℱ : Sheaf J A) : Presheaf.IsSheaf K (G.op.ran.obj ℱ.val) := by rw [Presheaf.isSheaf_iff_multifork] intros X S exact ⟨RanIsSheafOfIsCocontinuous.isLimitMultifork ℱ.2 (G.op.isPointwiseRightKanExtensionRanCounit ℱ.val) S⟩ variable (A J) /-- A cocontinuous functor induces a pushforward functor on categories of sheaves. -/ def Functor.sheafPushforwardCocontinuous : Sheaf J A ⥤ Sheaf K A where obj ℱ := ⟨G.op.ran.obj ℱ.val, ran_isSheaf_of_isCocontinuous _ K ℱ⟩ map f := ⟨G.op.ran.map f.val⟩ map_id ℱ := Sheaf.Hom.ext <| (ran G.op).map_id ℱ.val map_comp f g := Sheaf.Hom.ext <| (ran G.op).map_comp f.val g.val /-- `G.sheafPushforwardCocontinuous A J K : Sheaf J A ⥤ Sheaf K A` is induced by the right Kan extension functor `G.op.ran` on presheaves. -/ @[simps! hom inv] def Functor.sheafPushforwardCocontinuousCompSheafToPresheafIso : G.sheafPushforwardCocontinuous A J K ⋙ sheafToPresheaf K A ≅ sheafToPresheaf J A ⋙ G.op.ran := Iso.refl _ /- Given a cocontinuous functor `G`, the precomposition with `G.op` induces a functor on presheaves with leads to a "pullback" functor `Sheaf K A ⥤ Sheaf J A` (TODO: formalize this as `G.sheafPullbackCocontinuous A J K`) using the associated sheaf functor. It is shown in SGA 4 III 2.3 that this pullback functor is left adjoint to `G.sheafPushforwardCocontinuous A J K`. This adjunction may replace `Functor.sheafAdjunctionCocontinuous` below, and then, it could be shown that if `G` is also continuous, then we have an isomorphism `G.sheafPullbackCocontinuous A J K ≅ G.sheafPushforwardContinuous A J K` (TODO). -/ namespace Functor variable [G.IsContinuous J K] /-- Given a functor between sites that is continuous and cocontinuous, the pushforward for the continuous functor `G` is left adjoint to the pushforward for the cocontinuous functor `G`. -/ noncomputable def sheafAdjunctionCocontinuous : G.sheafPushforwardContinuous A J K ⊣ G.sheafPushforwardCocontinuous A J K := (G.op.ranAdjunction A).restrictFullyFaithful (fullyFaithfulSheafToPresheaf K A) (fullyFaithfulSheafToPresheaf J A) (G.sheafPushforwardContinuousCompSheafToPresheafIso A J K).symm (G.sheafPushforwardCocontinuousCompSheafToPresheafIso A J K).symm lemma sheafAdjunctionCocontinuous_unit_app_val (F : Sheaf K A) : ((G.sheafAdjunctionCocontinuous A J K).unit.app F).val = (G.op.ranAdjunction A).unit.app F.val := by apply ((G.op.ranAdjunction A).map_restrictFullyFaithful_unit_app (fullyFaithfulSheafToPresheaf K A) (fullyFaithfulSheafToPresheaf J A) (G.sheafPushforwardContinuousCompSheafToPresheafIso A J K).symm (G.sheafPushforwardCocontinuousCompSheafToPresheafIso A J K).symm F).trans dsimp erw [Functor.map_id] change _ ≫ 𝟙 _ ≫ 𝟙 _ = _ simp only [Category.comp_id] lemma sheafAdjunctionCocontinuous_counit_app_val (F : Sheaf J A) : ((G.sheafAdjunctionCocontinuous A J K).counit.app F).val = (G.op.ranAdjunction A).counit.app F.val := ((G.op.ranAdjunction A).map_restrictFullyFaithful_counit_app (fullyFaithfulSheafToPresheaf K A) (fullyFaithfulSheafToPresheaf J A) (G.sheafPushforwardContinuousCompSheafToPresheafIso A J K).symm (G.sheafPushforwardCocontinuousCompSheafToPresheafIso A J K).symm F).trans (by aesop_cat) lemma sheafAdjunctionCocontinuous_homEquiv_apply_val {F : Sheaf K A} {H : Sheaf J A} (f : (G.sheafPushforwardContinuous A J K).obj F ⟶ H) : ((G.sheafAdjunctionCocontinuous A J K).homEquiv F H f).val = (G.op.ranAdjunction A).homEquiv F.val H.val f.val := ((sheafToPresheaf K A).congr_map (((G.op.ranAdjunction A).restrictFullyFaithful_homEquiv_apply (fullyFaithfulSheafToPresheaf K A) (fullyFaithfulSheafToPresheaf J A) (G.sheafPushforwardContinuousCompSheafToPresheafIso A J K).symm (G.sheafPushforwardCocontinuousCompSheafToPresheafIso A J K).symm f))).trans (by dsimp erw [Functor.map_id, Category.comp_id, Category.id_comp, Adjunction.homEquiv_unit]) variable [HasWeakSheafify J A] [HasWeakSheafify K A] /-- The natural isomorphism exhibiting compatibility between pushforward and sheafification. -/ def pushforwardContinuousSheafificationCompatibility [G.IsContinuous J K] : (whiskeringLeft _ _ A).obj G.op ⋙ presheafToSheaf J A ≅ presheafToSheaf K A ⋙ G.sheafPushforwardContinuous A J K := ((G.op.ranAdjunction A).comp (sheafificationAdjunction J A)).leftAdjointUniq ((sheafificationAdjunction K A).comp (G.sheafAdjunctionCocontinuous A J K)) /- Implementation: This is primarily used to prove the lemma `pullbackSheafificationCompatibility_hom_app_val`. -/ lemma toSheafify_pullbackSheafificationCompatibility (F : Dᵒᵖ ⥤ A) : toSheafify J (G.op ⋙ F) ≫ ((G.pushforwardContinuousSheafificationCompatibility A J K).hom.app F).val = whiskerLeft _ (toSheafify K _) := by let adj₁ := G.op.ranAdjunction A let adj₂ := sheafificationAdjunction J A let adj₃ := sheafificationAdjunction K A let adj₄ := G.sheafAdjunctionCocontinuous A J K change adj₂.unit.app (((whiskeringLeft Cᵒᵖ Dᵒᵖ A).obj G.op).obj F) ≫ (sheafToPresheaf J A).map (((adj₁.comp adj₂).leftAdjointUniq (adj₃.comp adj₄)).hom.app F) = ((whiskeringLeft Cᵒᵖ Dᵒᵖ A).obj G.op).map (adj₃.unit.app F) apply (adj₁.homEquiv _ _).injective have eq := (adj₁.comp adj₂).unit_leftAdjointUniq_hom_app (adj₃.comp adj₄) F rw [Adjunction.comp_unit_app, Adjunction.comp_unit_app, comp_map, Category.assoc] at eq rw [adj₁.homEquiv_unit, Functor.map_comp, eq] apply (adj₁.homEquiv _ _).symm.injective simp only [Adjunction.homEquiv_counit, map_comp, Category.assoc, Adjunction.homEquiv_unit, Adjunction.unit_naturality] congr 3 exact G.sheafAdjunctionCocontinuous_unit_app_val A J K ((presheafToSheaf K A).obj F) @[simp] lemma pushforwardContinuousSheafificationCompatibility_hom_app_val (F : Dᵒᵖ ⥤ A) : ((G.pushforwardContinuousSheafificationCompatibility A J K).hom.app F).val = sheafifyLift J (whiskerLeft G.op <| toSheafify K F) ((presheafToSheaf K A ⋙ G.sheafPushforwardContinuous A J K).obj F).cond := by apply sheafifyLift_unique apply toSheafify_pullbackSheafificationCompatibility end Functor end CategoryTheory
CategoryTheory\Sites\CoverPreserving.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.Functor.Flat import Mathlib.CategoryTheory.Sites.Continuous import Mathlib.Tactic.ApplyFun /-! # Cover-preserving functors between sites. In order to show that a functor is continuous, we define cover-preserving functors between sites as functors that push covering sieves to covering sieves. Then, a cover-preserving and compatible-preserving functor is continuous. ## Main definitions * `CategoryTheory.CoverPreserving`: a functor between sites is cover-preserving if it pushes covering sieves to covering sieves * `CategoryTheory.CompatiblePreserving`: a functor between sites is compatible-preserving if it pushes compatible families of elements to compatible families. ## Main results - `CategoryTheory.isContinuous_of_coverPreserving`: If `G : C ⥤ D` is cover-preserving and compatible-preserving, then `G` is a continuous functor, i.e. `G.op ⋙ -` as a functor `(Dᵒᵖ ⥤ A) ⥤ (Cᵒᵖ ⥤ A)` of presheaves maps sheaves to sheaves. ## References * [Elephant]: *Sketches of an Elephant*, P. T. Johnstone: C2.3. * https://stacks.math.columbia.edu/tag/00WU -/ universe w v₁ v₂ v₃ u₁ u₂ u₃ noncomputable section open CategoryTheory Opposite CategoryTheory.Presieve.FamilyOfElements CategoryTheory.Presieve CategoryTheory.Limits namespace CategoryTheory variable {C : Type u₁} [Category.{v₁} C] {D : Type u₂} [Category.{v₂} D] (F : C ⥤ D) variable {A : Type u₃} [Category.{v₃} A] variable (J : GrothendieckTopology C) (K : GrothendieckTopology D) variable {L : GrothendieckTopology A} /-- A functor `G : (C, J) ⥤ (D, K)` between sites is *cover-preserving* if for all covering sieves `R` in `C`, `R.functorPushforward G` is a covering sieve in `D`. -/ -- Porting note(#5171): removed `@[nolint has_nonempty_instance]` structure CoverPreserving (G : C ⥤ D) : Prop where cover_preserve : ∀ {U : C} {S : Sieve U} (_ : S ∈ J U), S.functorPushforward G ∈ K (G.obj U) /-- The identity functor on a site is cover-preserving. -/ theorem idCoverPreserving : CoverPreserving J J (𝟭 _) := ⟨fun hS => by simpa using hS⟩ /-- The composition of two cover-preserving functors is cover-preserving. -/ theorem CoverPreserving.comp {F} (hF : CoverPreserving J K F) {G} (hG : CoverPreserving K L G) : CoverPreserving J L (F ⋙ G) := ⟨fun hS => by rw [Sieve.functorPushforward_comp] exact hG.cover_preserve (hF.cover_preserve hS)⟩ /-- A functor `G : (C, J) ⥤ (D, K)` between sites is called compatible preserving if for each compatible family of elements at `C` and valued in `G.op ⋙ ℱ`, and each commuting diagram `f₁ ≫ G.map g₁ = f₂ ≫ G.map g₂`, `x g₁` and `x g₂` coincide when restricted via `fᵢ`. This is actually stronger than merely preserving compatible families because of the definition of `functorPushforward` used. -/ -- Porting note(#5171): linter not ported yet @[nolint has_nonempty_instance] structure CompatiblePreserving (K : GrothendieckTopology D) (G : C ⥤ D) : Prop where compatible : ∀ (ℱ : SheafOfTypes.{w} K) {Z} {T : Presieve Z} {x : FamilyOfElements (G.op ⋙ ℱ.val) T} (_ : x.Compatible) {Y₁ Y₂} {X} (f₁ : X ⟶ G.obj Y₁) (f₂ : X ⟶ G.obj Y₂) {g₁ : Y₁ ⟶ Z} {g₂ : Y₂ ⟶ Z} (hg₁ : T g₁) (hg₂ : T g₂) (_ : f₁ ≫ G.map g₁ = f₂ ≫ G.map g₂), ℱ.val.map f₁.op (x g₁ hg₁) = ℱ.val.map f₂.op (x g₂ hg₂) variable {J K} {G : C ⥤ D} (hG : CompatiblePreserving.{w} K G) (ℱ : SheafOfTypes.{w} K) {Z : C} variable {T : Presieve Z} {x : FamilyOfElements (G.op ⋙ ℱ.val) T} (h : x.Compatible) /-- `CompatiblePreserving` functors indeed preserve compatible families. -/ theorem Presieve.FamilyOfElements.Compatible.functorPushforward : (x.functorPushforward G).Compatible := by rintro Z₁ Z₂ W g₁ g₂ f₁' f₂' H₁ H₂ eq unfold FamilyOfElements.functorPushforward rcases getFunctorPushforwardStructure H₁ with ⟨X₁, f₁, h₁, hf₁, rfl⟩ rcases getFunctorPushforwardStructure H₂ with ⟨X₂, f₂, h₂, hf₂, rfl⟩ suffices ℱ.val.map (g₁ ≫ h₁).op (x f₁ hf₁) = ℱ.val.map (g₂ ≫ h₂).op (x f₂ hf₂) by simpa using this apply hG.compatible ℱ h _ _ hf₁ hf₂ simpa using eq @[simp] theorem CompatiblePreserving.apply_map {Y : C} {f : Y ⟶ Z} (hf : T f) : x.functorPushforward G (G.map f) (image_mem_functorPushforward G T hf) = x f hf := by unfold FamilyOfElements.functorPushforward rcases getFunctorPushforwardStructure (image_mem_functorPushforward G T hf) with ⟨X, g, f', hg, eq⟩ simpa using hG.compatible ℱ h f' (𝟙 _) hg hf (by simp [eq]) open Limits.WalkingCospan theorem compatiblePreservingOfFlat {C : Type u₁} [Category.{v₁} C] {D : Type u₁} [Category.{v₁} D] (K : GrothendieckTopology D) (G : C ⥤ D) [RepresentablyFlat G] : CompatiblePreserving K G := by constructor intro ℱ Z T x hx Y₁ Y₂ X f₁ f₂ g₁ g₂ hg₁ hg₂ e -- First, `f₁` and `f₂` form a cone over `cospan g₁ g₂ ⋙ u`. let c : Cone (cospan g₁ g₂ ⋙ G) := (Cones.postcompose (diagramIsoCospan (cospan g₁ g₂ ⋙ G)).inv).obj (PullbackCone.mk f₁ f₂ e) /- This can then be viewed as a cospan of structured arrows, and we may obtain an arbitrary cone over it since `StructuredArrow W u` is cofiltered. Then, it suffices to prove that it is compatible when restricted onto `u(c'.X.right)`. -/ let c' := IsCofiltered.cone (c.toStructuredArrow ⋙ StructuredArrow.pre _ _ _) have eq₁ : f₁ = (c'.pt.hom ≫ G.map (c'.π.app left).right) ≫ eqToHom (by simp) := by erw [← (c'.π.app left).w] dsimp [c] simp have eq₂ : f₂ = (c'.pt.hom ≫ G.map (c'.π.app right).right) ≫ eqToHom (by simp) := by erw [← (c'.π.app right).w] dsimp [c] simp conv_lhs => rw [eq₁] conv_rhs => rw [eq₂] simp only [op_comp, Functor.map_comp, types_comp_apply, eqToHom_op, eqToHom_map] apply congr_arg -- Porting note: was `congr 1` which for some reason doesn't do anything here -- despite goal being of the form f a = f b, with f=`ℱ.val.map (Quiver.Hom.op c'.pt.hom)` /- Since everything now falls in the image of `u`, the result follows from the compatibility of `x` in the image of `u`. -/ injection c'.π.naturality WalkingCospan.Hom.inl with _ e₁ injection c'.π.naturality WalkingCospan.Hom.inr with _ e₂ exact hx (c'.π.app left).right (c'.π.app right).right hg₁ hg₂ (e₁.symm.trans e₂) theorem compatiblePreservingOfDownwardsClosed (F : C ⥤ D) [F.Full] [F.Faithful] (hF : ∀ {c : C} {d : D} (_ : d ⟶ F.obj c), Σc', F.obj c' ≅ d) : CompatiblePreserving K F := by constructor introv hx he obtain ⟨X', e⟩ := hF f₁ apply (ℱ.1.mapIso e.op).toEquiv.injective simp only [Iso.op_hom, Iso.toEquiv_fun, ℱ.1.mapIso_hom, ← FunctorToTypes.map_comp_apply] simpa using hx (F.preimage <| e.hom ≫ f₁) (F.preimage <| e.hom ≫ f₂) hg₁ hg₂ (F.map_injective <| by simpa using he) variable (J K) variable {F J K} /-- If `F` is cover-preserving and compatible-preserving, then `F` is a continuous functor. This result is basically <https://stacks.math.columbia.edu/tag/00WW>. -/ lemma Functor.isContinuous_of_coverPreserving (hF₁ : CompatiblePreserving.{w} K F) (hF₂ : CoverPreserving J K F) : Functor.IsContinuous.{w} F J K where op_comp_isSheafOfTypes G X S hS x hx := by apply exists_unique_of_exists_of_unique · have H := G.2 _ (hF₂.cover_preserve hS) exact ⟨H.amalgamate (x.functorPushforward F) (hx.functorPushforward hF₁), fun V f hf => (H.isAmalgamation (hx.functorPushforward hF₁) (F.map f) _).trans (hF₁.apply_map _ hx hf)⟩ · intro y₁ y₂ hy₁ hy₂ apply (Presieve.isSeparated_of_isSheaf _ _ G.cond _ (hF₂.cover_preserve hS)).ext rintro Y _ ⟨Z, g, h, hg, rfl⟩ dsimp simp only [Functor.map_comp, types_comp_apply] have H := (hy₁ g hg).trans (hy₂ g hg).symm dsimp at H rw [H] end CategoryTheory
CategoryTheory\Sites\CoversTop.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.Sites.Sheaf /-! Objects which cover the terminal object In this file, given a site `(C, J)`, we introduce the notion of a family of objects `Y : I → C` which "cover the final object": this means that for all `X : C`, the sieve `Sieve.ofObjects Y X` is covering for `J`. When there is a terminal object `X : C`, then `J.CoversTop Y` holds iff `Sieve.ofObjects Y X` is covering for `J`. We introduce a notion of compatible family of elements on objects `Y` and obtain `Presheaf.FamilyOfElementsOnObjects.IsCompatible.exists_unique_section` which asserts that if a presheaf of types is a sheaf, then any compatible family of elements on objects `Y` which cover the final object extends as a section of this presheaf. -/ universe w v' v u' u namespace CategoryTheory open Limits variable {C : Type u} [Category.{v} C] (J : GrothendieckTopology C) {A : Type u'} [Category.{v'} A] namespace GrothendieckTopology /-- A family of objects `Y : I → C` "covers the final object" if for all `X : C`, the sieve `ofObjects Y X` is a covering sieve. -/ def CoversTop {I : Type*} (Y : I → C) : Prop := ∀ (X : C), Sieve.ofObjects Y X ∈ J X lemma coversTop_iff_of_isTerminal (X : C) (hX : IsTerminal X) {I : Type*} (Y : I → C) : J.CoversTop Y ↔ Sieve.ofObjects Y X ∈ J X := by constructor · tauto · intro h W apply J.superset_covering _ (J.pullback_stable (hX.from W) h) rintro T a ⟨i, ⟨b⟩⟩ exact ⟨i, ⟨b⟩⟩ namespace CoversTop variable {J} variable {I : Type*} {Y : I → C} (hY : J.CoversTop Y) /-- The cover of any object `W : C` attached to a family of objects `Y` that satisfy `J.CoversTop Y` -/ abbrev cover (W : C) : Cover J W := ⟨Sieve.ofObjects Y W, hY W⟩ lemma ext (F : Sheaf J A) {c : Cone F.1} (hc : IsLimit c) {X : A} {f g : X ⟶ c.pt} (h : ∀ (i : I), f ≫ c.π.app (Opposite.op (Y i)) = g ≫ c.π.app (Opposite.op (Y i))) : f = g := by refine hc.hom_ext (fun Z => F.2.hom_ext (hY.cover Z.unop) _ _ ?_) rintro ⟨W, a, ⟨i, ⟨b⟩⟩⟩ simpa using h i =≫ F.1.map b.op lemma sections_ext (F : Sheaf J (Type _)) {x y : F.1.sections} (h : ∀ (i : I), x.1 (Opposite.op (Y i)) = y.1 (Opposite.op (Y i))) : x = y := by ext W apply (Presieve.isSeparated_of_isSheaf J F.1 ((isSheaf_iff_isSheaf_of_type _ _).1 F.2) _ (hY W.unop)).ext rintro T a ⟨i, ⟨b⟩⟩ simpa using congr_arg (F.1.map b.op) (h i) end CoversTop end GrothendieckTopology namespace Presheaf variable (F : Cᵒᵖ ⥤ Type w) {I : Type*} (Y : I → C) /-- A family of elements of a presheaf of types `F` indexed by a family of objects `Y : I → C` consists of the data of an element in `F.obj (Opposite.op (Y i))` for all `i`. -/ def FamilyOfElementsOnObjects := ∀ (i : I), F.obj (Opposite.op (Y i)) namespace FamilyOfElementsOnObjects variable {F Y} variable (x : FamilyOfElementsOnObjects F Y) /-- `x : FamilyOfElementsOnObjects F Y` is compatible if for any object `Z` such that there exists a morphism `f : Z → Y i`, then the pullback of `x i` by `f` is independent of `f` and `i`. -/ def IsCompatible (x : FamilyOfElementsOnObjects F Y) : Prop := ∀ (Z : C) (i j : I) (f : Z ⟶ Y i) (g : Z ⟶ Y j), F.map f.op (x i) = F.map g.op (x j) /-- A family of elements indexed by `Sieve.ofObjects Y X` that is induced by `x : FamilyOfElementsOnObjects F Y`. See the equational lemma `IsCompatible.familyOfElements_apply` which holds under the assumption `x.IsCompatible`. -/ noncomputable def familyOfElements (X : C) : Presieve.FamilyOfElements F (Sieve.ofObjects Y X).arrows := fun _ _ hf => F.map hf.choose_spec.some.op (x _) namespace IsCompatible variable {x} lemma familyOfElements_apply (hx : x.IsCompatible) {X Z : C} (f : Z ⟶ X) (i : I) (φ : Z ⟶ Y i) : familyOfElements x X f ⟨i, ⟨φ⟩⟩ = F.map φ.op (x i) := by apply hx lemma familyOfElements_isCompatible (hx : x.IsCompatible) (X : C) : (familyOfElements x X).Compatible := by intro Y₁ Y₂ Z g₁ g₂ f₁ f₂ ⟨i₁, ⟨φ₁⟩⟩ ⟨i₂, ⟨φ₂⟩⟩ _ simpa [hx.familyOfElements_apply f₁ i₁ φ₁, hx.familyOfElements_apply f₂ i₂ φ₂] using hx Z i₁ i₂ (g₁ ≫ φ₁) (g₂ ≫ φ₂) variable {J} lemma exists_unique_section (hx : x.IsCompatible) (hY : J.CoversTop Y) (hF : IsSheaf J F) : ∃! (s : F.sections), ∀ (i : I), s.1 (Opposite.op (Y i)) = x i := by have H := (isSheaf_iff_isSheaf_of_type _ _).1 hF apply exists_unique_of_exists_of_unique · let s := fun (X : C) => (H _ (hY X)).amalgamate _ (hx.familyOfElements_isCompatible X) have hs : ∀ {X : C} (i : I) (f : X ⟶ Y i), s X = F.map f.op (x i) := fun {X} i f => by have h := Presieve.IsSheafFor.valid_glue (H _ (hY X)) (hx.familyOfElements_isCompatible _) (𝟙 _) ⟨i, ⟨f⟩⟩ simp only [op_id, F.map_id, types_id_apply] at h exact h.trans (hx.familyOfElements_apply _ _ _) have hs' : ∀ {W X : C} (a : W ⟶ X) (i : I) (_ : W ⟶ Y i), F.map a.op (s X) = s W := by intro W X a i b rw [hs i b] exact (Presieve.IsSheafFor.valid_glue (H _ (hY X)) (hx.familyOfElements_isCompatible _) a ⟨i, ⟨b⟩⟩).trans (familyOfElements_apply hx _ _ _) refine ⟨⟨fun X => s X.unop, ?_⟩, fun i => (hs i (𝟙 (Y i))).trans (by simp)⟩ rintro ⟨Y₁⟩ ⟨Y₂⟩ ⟨f : Y₂ ⟶ Y₁⟩ change F.map f.op (s Y₁) = s Y₂ apply (Presieve.isSeparated_of_isSheaf J F H _ (hY Y₂)).ext rintro Z φ ⟨i, ⟨g⟩⟩ rw [hs' φ i g, ← hs' (φ ≫ f) i g, op_comp, F.map_comp] rfl · intro y₁ y₂ hy₁ hy₂ exact hY.sections_ext ⟨F, hF⟩ (fun i => by rw [hy₁, hy₂]) variable (hx : x.IsCompatible) (hY : J.CoversTop Y) (hF : IsSheaf J F) /-- The section of a sheaf of types which lifts a compatible family of elements indexed by objects which cover the terminal object. -/ noncomputable def section_ : F.sections := (hx.exists_unique_section hY hF).choose @[simp] lemma section_apply (i : I) : (hx.section_ hY hF).1 (Opposite.op (Y i)) = x i := (hx.exists_unique_section hY hF).choose_spec.1 i end IsCompatible end FamilyOfElementsOnObjects end Presheaf end CategoryTheory
CategoryTheory\Sites\DenseSubsite.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.Sites.Sheaf import Mathlib.CategoryTheory.Sites.CoverLifting import Mathlib.CategoryTheory.Sites.CoverPreserving import Mathlib.CategoryTheory.Adjunction.FullyFaithful import Mathlib.CategoryTheory.Sites.LocallyFullyFaithful /-! # Dense subsites We define `IsCoverDense` functors into sites as functors such that there exists a covering sieve that factors through images of the functor for each object in `D`. ## Main results - `CategoryTheory.Functor.IsCoverDense.Types.presheafHom`: If `G : C ⥤ (D, K)` is locally-full and cover-dense, then given any presheaf `ℱ` and sheaf `ℱ'` on `D`, and a morphism `α : G ⋙ ℱ ⟶ G ⋙ ℱ'`, we may glue them together to obtain a morphism of presheaves `ℱ ⟶ ℱ'`. - `CategoryTheory.Functor.IsCoverDense.sheafIso`: If `ℱ` above is a sheaf and `α` is an iso, then the result is also an iso. - `CategoryTheory.Functor.IsCoverDense.iso_of_restrict_iso`: If `G : C ⥤ (D, K)` is locally-full and cover-dense, then given any sheaves `ℱ, ℱ'` on `D`, and a morphism `α : ℱ ⟶ ℱ'`, then `α` is an iso if `G ⋙ ℱ ⟶ G ⋙ ℱ'` is iso. - `CategoryTheory.Functor.IsDenseSubsite`: The functor `G : C ⥤ D` exhibits `(C, J)` as a dense subsite of `(D, K)` if `G` is cover-dense, locally fully-faithful, and `S` is a cover of `C` iff the image of `S` in `D` is a cover. - `CategoryTheory.Functor.IsDenseSubsite.sheafEquiv`: If `G : C ⥤ D` exhibits `(C, J)` as a dense subsite of `(D, K)`, it induces an equivalence of category of sheaves valued in a category with suitable limits. ## References * [Elephant]: *Sketches of an Elephant*, ℱ. T. Johnstone: C2.2. * https://ncatlab.org/nlab/show/dense+sub-site * https://ncatlab.org/nlab/show/comparison+lemma -/ universe w v u namespace CategoryTheory variable {C : Type*} [Category C] {D : Type*} [Category D] {E : Type*} [Category E] variable (J : GrothendieckTopology C) (K : GrothendieckTopology D) variable {L : GrothendieckTopology E} /-- An auxiliary structure that witnesses the fact that `f` factors through an image object of `G`. -/ -- Porting note(#5171): removed `@[nolint has_nonempty_instance]` structure Presieve.CoverByImageStructure (G : C ⥤ D) {V U : D} (f : V ⟶ U) where obj : C lift : V ⟶ G.obj obj map : G.obj obj ⟶ U fac : lift ≫ map = f := by aesop_cat attribute [nolint docBlame] Presieve.CoverByImageStructure.obj Presieve.CoverByImageStructure.lift Presieve.CoverByImageStructure.map Presieve.CoverByImageStructure.fac attribute [reassoc (attr := simp)] Presieve.CoverByImageStructure.fac /-- For a functor `G : C ⥤ D`, and an object `U : D`, `Presieve.coverByImage G U` is the presieve of `U` consisting of those arrows that factor through images of `G`. -/ def Presieve.coverByImage (G : C ⥤ D) (U : D) : Presieve U := fun _ f => Nonempty (Presieve.CoverByImageStructure G f) /-- For a functor `G : C ⥤ D`, and an object `U : D`, `Sieve.coverByImage G U` is the sieve of `U` consisting of those arrows that factor through images of `G`. -/ def Sieve.coverByImage (G : C ⥤ D) (U : D) : Sieve U := ⟨Presieve.coverByImage G U, fun ⟨⟨Z, f₁, f₂, (e : _ = _)⟩⟩ g => ⟨⟨Z, g ≫ f₁, f₂, show (g ≫ f₁) ≫ f₂ = g ≫ _ by rw [Category.assoc, ← e]⟩⟩⟩ theorem Presieve.in_coverByImage (G : C ⥤ D) {X : D} {Y : C} (f : G.obj Y ⟶ X) : Presieve.coverByImage G X f := ⟨⟨Y, 𝟙 _, f, by simp⟩⟩ /-- A functor `G : (C, J) ⥤ (D, K)` is cover dense if for each object in `D`, there exists a covering sieve in `D` that factors through images of `G`. This definition can be found in https://ncatlab.org/nlab/show/dense+sub-site Definition 2.2. -/ class Functor.IsCoverDense (G : C ⥤ D) (K : GrothendieckTopology D) : Prop where is_cover : ∀ U : D, Sieve.coverByImage G U ∈ K U lemma Functor.is_cover_of_isCoverDense (G : C ⥤ D) (K : GrothendieckTopology D) [G.IsCoverDense K] (U : D) : Sieve.coverByImage G U ∈ K U := by apply Functor.IsCoverDense.is_cover lemma Functor.isCoverDense_of_generate_singleton_functor_π_mem (G : C ⥤ D) (K : GrothendieckTopology D) (h : ∀ B, ∃ (X : C) (f : G.obj X ⟶ B), Sieve.generate (Presieve.singleton f) ∈ K B) : G.IsCoverDense K where is_cover B := by obtain ⟨X, f, h⟩ := h B refine K.superset_covering ?_ h intro Y f ⟨Z, g, _, h, w⟩ cases h exact ⟨⟨_, g, _, w⟩⟩ attribute [nolint docBlame] CategoryTheory.Functor.IsCoverDense.is_cover open Presieve Opposite namespace Functor namespace IsCoverDense variable {K} variable {A : Type*} [Category A] (G : C ⥤ D) [G.IsCoverDense K] -- this is not marked with `@[ext]` because `H` can not be inferred from the type theorem ext (ℱ : SheafOfTypes K) (X : D) {s t : ℱ.val.obj (op X)} (h : ∀ ⦃Y : C⦄ (f : G.obj Y ⟶ X), ℱ.val.map f.op s = ℱ.val.map f.op t) : s = t := by apply (ℱ.cond (Sieve.coverByImage G X) (G.is_cover_of_isCoverDense K X)).isSeparatedFor.ext rintro Y _ ⟨Z, f₁, f₂, ⟨rfl⟩⟩ simp [h f₂] variable {G} theorem functorPullback_pushforward_covering [G.IsLocallyFull K] {X : C} (T : K (G.obj X)) : (T.val.functorPullback G).functorPushforward G ∈ K (G.obj X) := by refine K.transitive T.2 _ fun Y iYX hiYX ↦ ?_ apply K.transitive (G.is_cover_of_isCoverDense _ _) _ rintro W _ ⟨Z, iWZ, iZY, rfl⟩ rw [Sieve.pullback_comp]; apply K.pullback_stable; clear W iWZ apply K.superset_covering ?_ (G.functorPushforward_imageSieve_mem _ (iZY ≫ iYX)) rintro W _ ⟨V, iVZ, iWV, ⟨iVX, e⟩, rfl⟩ exact ⟨_, iVX, iWV, by simpa [e] using T.1.downward_closed hiYX (G.map iVZ ≫ iZY), by simp [e]⟩ /-- (Implementation). Given a hom between the pullbacks of two sheaves, we can whisker it with `coyoneda` to obtain a hom between the pullbacks of the sheaves of maps from `X`. -/ @[simps!] def homOver {ℱ : Dᵒᵖ ⥤ A} {ℱ' : Sheaf K A} (α : G.op ⋙ ℱ ⟶ G.op ⋙ ℱ'.val) (X : A) : G.op ⋙ ℱ ⋙ coyoneda.obj (op X) ⟶ G.op ⋙ (sheafOver ℱ' X).val := whiskerRight α (coyoneda.obj (op X)) /-- (Implementation). Given an iso between the pullbacks of two sheaves, we can whisker it with `coyoneda` to obtain an iso between the pullbacks of the sheaves of maps from `X`. -/ @[simps!] def isoOver {ℱ ℱ' : Sheaf K A} (α : G.op ⋙ ℱ.val ≅ G.op ⋙ ℱ'.val) (X : A) : G.op ⋙ (sheafOver ℱ X).val ≅ G.op ⋙ (sheafOver ℱ' X).val := isoWhiskerRight α (coyoneda.obj (op X)) theorem sheaf_eq_amalgamation (ℱ : Sheaf K A) {X : A} {U : D} {T : Sieve U} (hT) (x : FamilyOfElements _ T) (hx) (t) (h : x.IsAmalgamation t) : t = (ℱ.cond X T hT).amalgamate x hx := (ℱ.cond X T hT).isSeparatedFor x t _ h ((ℱ.cond X T hT).isAmalgamation hx) variable [G.IsLocallyFull K] namespace Types variable {ℱ : Dᵒᵖ ⥤ Type v} {ℱ' : SheafOfTypes.{v} K} (α : G.op ⋙ ℱ ⟶ G.op ⋙ ℱ'.val) theorem naturality_apply {X Y : C} (i : G.obj X ⟶ G.obj Y) (x) : ℱ'.1.map i.op (α.app _ x) = α.app _ (ℱ.map i.op x) := by have {X Y} (i : X ⟶ Y) (x) : ℱ'.1.map (G.map i).op (α.app _ x) = α.app _ (ℱ.map (G.map i).op x) := by exact congr_fun (α.naturality i.op).symm x refine IsLocallyFull.ext G _ i fun V iVX iVY e ↦ ?_ simp only [comp_obj, types_comp_apply, ← FunctorToTypes.map_comp_apply, ← op_comp, ← e, this] @[reassoc] theorem naturality {X Y : C} (i : G.obj X ⟶ G.obj Y) : α.app _ ≫ ℱ'.1.map i.op = ℱ.map i.op ≫ α.app _ := types_ext _ _ (naturality_apply α i) /-- (Implementation). Given a section of `ℱ` on `X`, we can obtain a family of elements valued in `ℱ'` that is defined on a cover generated by the images of `G`. -/ -- Porting note: removed `@[simp, nolint unused_arguments]` noncomputable def pushforwardFamily {X} (x : ℱ.obj (op X)) : FamilyOfElements ℱ'.val (coverByImage G X) := fun _ _ hf => ℱ'.val.map hf.some.lift.op <| α.app (op _) (ℱ.map hf.some.map.op x : _) -- Porting note: there are various `include` and `omit`s in this file (e.g. one is removed here), -- none of which are needed in Lean 4. -- Porting note: `pushforward_family` was tagged `@[simp]` in Lean 3 so we add the -- equation lemma @[simp] theorem pushforwardFamily_def {X} (x : ℱ.obj (op X)) : pushforwardFamily α x = fun _ _ hf => ℱ'.val.map hf.some.lift.op <| α.app (op _) (ℱ.map hf.some.map.op x : _) := rfl /-- (Implementation). The `pushforwardFamily` defined is compatible. -/ theorem pushforwardFamily_compatible {X} (x : ℱ.obj (op X)) : (pushforwardFamily α x).Compatible := by suffices ∀ {Z W₁ W₂} (iWX₁ : G.obj W₁ ⟶ X) (iWX₂ : G.obj W₂ ⟶ X) (iZW₁ : Z ⟶ G.obj W₁) (iZW₂ : Z ⟶ G.obj W₂), iZW₁ ≫ iWX₁ = iZW₂ ≫ iWX₂ → ℱ'.1.map iZW₁.op (α.app _ (ℱ.map iWX₁.op x)) = ℱ'.1.map iZW₂.op (α.app _ (ℱ.map iWX₂.op x)) by rintro Y₁ Y₂ Z iZY₁ iZY₂ f₁ f₂ h₁ h₂ e simp only [pushforwardFamily, ← FunctorToTypes.map_comp_apply, ← op_comp] generalize Nonempty.some h₁ = l₁ generalize Nonempty.some h₂ = l₂ obtain ⟨W₁, iYW₁, iWX₁, rfl⟩ := l₁ obtain ⟨W₂, iYW₂, iWX₂, rfl⟩ := l₂ exact this _ _ _ _ (by simpa only [Category.assoc] using e) introv e refine ext G _ _ fun V iVZ ↦ ?_ simp only [← op_comp, ← FunctorToTypes.map_comp_apply, ← Functor.map_comp, naturality_apply, Category.assoc, e] /-- (Implementation). The morphism `ℱ(X) ⟶ ℱ'(X)` given by gluing the `pushforwardFamily`. -/ noncomputable def appHom (X : D) : ℱ.obj (op X) ⟶ ℱ'.val.obj (op X) := fun x => (ℱ'.cond _ (G.is_cover_of_isCoverDense _ X)).amalgamate (pushforwardFamily α x) (pushforwardFamily_compatible α x) @[simp] theorem pushforwardFamily_apply {X} (x : ℱ.obj (op X)) {Y : C} (f : G.obj Y ⟶ X) : pushforwardFamily α x f (Presieve.in_coverByImage G f) = α.app (op Y) (ℱ.map f.op x) := by simp only [pushforwardFamily_def, op_obj] generalize Nonempty.some (Presieve.in_coverByImage G f) = l obtain ⟨W, iYW, iWX, rfl⟩ := l simp only [← op_comp, ← FunctorToTypes.map_comp_apply, naturality_apply] @[simp] theorem appHom_restrict {X : D} {Y : C} (f : op X ⟶ op (G.obj Y)) (x) : ℱ'.val.map f (appHom α X x) = α.app (op Y) (ℱ.map f x) := ((ℱ'.cond _ (G.is_cover_of_isCoverDense _ X)).valid_glue (pushforwardFamily_compatible α x) f.unop (Presieve.in_coverByImage G f.unop)).trans (pushforwardFamily_apply _ _ _) @[simp] theorem appHom_valid_glue {X : D} {Y : C} (f : op X ⟶ op (G.obj Y)) : appHom α X ≫ ℱ'.val.map f = ℱ.map f ≫ α.app (op Y) := by ext apply appHom_restrict /-- (Implementation). The maps given in `appIso` is inverse to each other and gives a `ℱ(X) ≅ ℱ'(X)`. -/ @[simps] noncomputable def appIso {ℱ ℱ' : SheafOfTypes.{v} K} (i : G.op ⋙ ℱ.val ≅ G.op ⋙ ℱ'.val) (X : D) : ℱ.val.obj (op X) ≅ ℱ'.val.obj (op X) where hom := appHom i.hom X inv := appHom i.inv X hom_inv_id := by ext x apply Functor.IsCoverDense.ext G intro Y f simp inv_hom_id := by ext x apply Functor.IsCoverDense.ext G intro Y f simp /-- Given a natural transformation `G ⋙ ℱ ⟶ G ⋙ ℱ'` between presheaves of types, where `G` is locally-full and cover-dense, and `ℱ'` is a sheaf, we may obtain a natural transformation between sheaves. -/ @[simps] noncomputable def presheafHom (α : G.op ⋙ ℱ ⟶ G.op ⋙ ℱ'.val) : ℱ ⟶ ℱ'.val where app X := appHom α (unop X) naturality X Y f := by ext x apply Functor.IsCoverDense.ext G intro Y' f' simp only [appHom_restrict, types_comp_apply, ← FunctorToTypes.map_comp_apply] -- Porting note: Lean 3 proof continued with a rewrite but we're done here /-- Given a natural isomorphism `G ⋙ ℱ ≅ G ⋙ ℱ'` between presheaves of types, where `G` is locally-full and cover-dense, and `ℱ, ℱ'` are sheaves, we may obtain a natural isomorphism between presheaves. -/ @[simps!] noncomputable def presheafIso {ℱ ℱ' : SheafOfTypes.{v} K} (i : G.op ⋙ ℱ.val ≅ G.op ⋙ ℱ'.val) : ℱ.val ≅ ℱ'.val := NatIso.ofComponents (fun X => appIso i (unop X)) @(presheafHom i.hom).naturality /-- Given a natural isomorphism `G ⋙ ℱ ≅ G ⋙ ℱ'` between presheaves of types, where `G` is locally-full and cover-dense, and `ℱ, ℱ'` are sheaves, we may obtain a natural isomorphism between sheaves. -/ @[simps] noncomputable def sheafIso {ℱ ℱ' : SheafOfTypes.{v} K} (i : G.op ⋙ ℱ.val ≅ G.op ⋙ ℱ'.val) : ℱ ≅ ℱ' where hom := ⟨(presheafIso i).hom⟩ inv := ⟨(presheafIso i).inv⟩ hom_inv_id := by ext1 apply (presheafIso i).hom_inv_id inv_hom_id := by ext1 apply (presheafIso i).inv_hom_id end Types open Types variable {ℱ : Dᵒᵖ ⥤ A} {ℱ' : Sheaf K A} /-- (Implementation). The sheaf map given in `types.sheaf_hom` is natural in terms of `X`. -/ @[simps] noncomputable def sheafCoyonedaHom (α : G.op ⋙ ℱ ⟶ G.op ⋙ ℱ'.val) : coyoneda ⋙ (whiskeringLeft Dᵒᵖ A (Type _)).obj ℱ ⟶ coyoneda ⋙ (whiskeringLeft Dᵒᵖ A (Type _)).obj ℱ'.val where app X := presheafHom (homOver α (unop X)) naturality X Y f := by ext U x change appHom (homOver α (unop Y)) (unop U) (f.unop ≫ x) = f.unop ≫ appHom (homOver α (unop X)) (unop U) x symm apply sheaf_eq_amalgamation · apply G.is_cover_of_isCoverDense -- Porting note: the following line closes a goal which didn't exist before reenableeta · exact pushforwardFamily_compatible (homOver α Y.unop) (f.unop ≫ x) intro Y' f' hf' change unop X ⟶ ℱ.obj (op (unop _)) at x dsimp simp only [pushforwardFamily, Functor.comp_map, coyoneda_obj_map, homOver_app, Category.assoc] congr 1 conv_lhs => rw [← hf'.some.fac] simp only [← Category.assoc, op_comp, Functor.map_comp] congr 1 exact (appHom_restrict (homOver α (unop X)) hf'.some.map.op x).trans (by simp) /-- (Implementation). `sheafCoyonedaHom` but the order of the arguments of the functor are swapped. -/ noncomputable def sheafYonedaHom (α : G.op ⋙ ℱ ⟶ G.op ⋙ ℱ'.val) : ℱ ⋙ yoneda ⟶ ℱ'.val ⋙ yoneda where app U := let α := (sheafCoyonedaHom α) { app := fun X => (α.app X).app U naturality := fun X Y f => by simpa using congr_app (α.naturality f) U } naturality U V i := by ext X x exact congr_fun (((sheafCoyonedaHom α).app X).naturality i) x /-- Given a natural transformation `G ⋙ ℱ ⟶ G ⋙ ℱ'` between presheaves of arbitrary category, where `G` is locally-full and cover-dense, and `ℱ'` is a sheaf, we may obtain a natural transformation between presheaves. -/ noncomputable def sheafHom (α : G.op ⋙ ℱ ⟶ G.op ⋙ ℱ'.val) : ℱ ⟶ ℱ'.val := let α' := sheafYonedaHom α { app := fun X => yoneda.preimage (α'.app X) naturality := fun X Y f => yoneda.map_injective (by simpa using α'.naturality f) } /-- Given a natural isomorphism `G ⋙ ℱ ≅ G ⋙ ℱ'` between presheaves of arbitrary category, where `G` is locally-full and cover-dense, and `ℱ', ℱ` are sheaves, we may obtain a natural isomorphism between presheaves. -/ @[simps!] noncomputable def presheafIso {ℱ ℱ' : Sheaf K A} (i : G.op ⋙ ℱ.val ≅ G.op ⋙ ℱ'.val) : ℱ.val ≅ ℱ'.val := by have : ∀ X : Dᵒᵖ, IsIso ((sheafHom i.hom).app X) := by intro X -- Porting note: somehow `apply` in Lean 3 is leaving a typeclass goal, -- perhaps due to elaboration order. The corresponding `apply` in Lean 4 fails -- because the instance can't yet be synthesized. I hence reorder the proof. suffices IsIso (yoneda.map ((sheafHom i.hom).app X)) by apply isIso_of_reflects_iso _ yoneda use (sheafYonedaHom i.inv).app X constructor <;> ext x : 2 <;> simp only [sheafHom, NatTrans.comp_app, NatTrans.id_app, Functor.map_preimage] · exact ((Types.presheafIso (isoOver i (unop x))).app X).hom_inv_id · exact ((Types.presheafIso (isoOver i (unop x))).app X).inv_hom_id -- Porting note: Lean 4 proof is finished, Lean 3 needed `inferInstance` haveI : IsIso (sheafHom i.hom) := by apply NatIso.isIso_of_isIso_app apply asIso (sheafHom i.hom) /-- Given a natural isomorphism `G ⋙ ℱ ≅ G ⋙ ℱ'` between presheaves of arbitrary category, where `G` is locally-full and cover-dense, and `ℱ', ℱ` are sheaves, we may obtain a natural isomorphism between presheaves. -/ @[simps] noncomputable def sheafIso {ℱ ℱ' : Sheaf K A} (i : G.op ⋙ ℱ.val ≅ G.op ⋙ ℱ'.val) : ℱ ≅ ℱ' where hom := ⟨(presheafIso i).hom⟩ inv := ⟨(presheafIso i).inv⟩ hom_inv_id := by ext1 apply (presheafIso i).hom_inv_id inv_hom_id := by ext1 apply (presheafIso i).inv_hom_id /-- The constructed `sheafHom α` is equal to `α` when restricted onto `C`. -/ theorem sheafHom_restrict_eq (α : G.op ⋙ ℱ ⟶ G.op ⋙ ℱ'.val) : whiskerLeft G.op (sheafHom α) = α := by ext X apply yoneda.map_injective ext U -- Porting note: didn't need to provide the input to `map_preimage` in Lean 3 erw [yoneda.map_preimage ((sheafYonedaHom α).app (G.op.obj X))] symm change (show (ℱ'.val ⋙ coyoneda.obj (op (unop U))).obj (op (G.obj (unop X))) from _) = _ apply sheaf_eq_amalgamation ℱ' (G.is_cover_of_isCoverDense _ _) -- Porting note: next line was not needed in mathlib3 · exact (pushforwardFamily_compatible _ _) intro Y f hf conv_lhs => rw [← hf.some.fac] simp only [pushforwardFamily, Functor.comp_map, yoneda_map_app, coyoneda_obj_map, op_comp, FunctorToTypes.map_comp_apply, homOver_app, ← Category.assoc] congr 1 simp only [Category.assoc] congr 1 have := naturality_apply (G := G) (ℱ := ℱ ⋙ coyoneda.obj (op <| (G.op ⋙ ℱ).obj X)) (ℱ' := ⟨_, ℱ'.2 ((G.op ⋙ ℱ).obj X)⟩) (whiskerRight α (coyoneda.obj _)) hf.some.map (𝟙 _) simpa using this variable (G) /-- If the pullback map is obtained via whiskering, then the result `sheaf_hom (whisker_left G.op α)` is equal to `α`. -/ theorem sheafHom_eq (α : ℱ ⟶ ℱ'.val) : sheafHom (whiskerLeft G.op α) = α := by ext X apply yoneda.map_injective -- Porting note: deleted next line as it's not needed in Lean 4 ext U -- Porting note: Lean 3 didn't need to be told the explicit input to map_preimage erw [yoneda.map_preimage ((sheafYonedaHom (whiskerLeft G.op α)).app X)] symm change (show (ℱ'.val ⋙ coyoneda.obj (op (unop U))).obj (op (unop X)) from _) = _ apply sheaf_eq_amalgamation ℱ' (G.is_cover_of_isCoverDense _ _) -- Porting note: next line was not needed in mathlib3 · exact (pushforwardFamily_compatible _ _) intro Y f hf conv_lhs => rw [← hf.some.fac] dsimp simp variable {G} /-- A locally-full and cover-dense functor `G` induces an equivalence between morphisms into a sheaf and morphisms over the restrictions via `G`. -/ noncomputable def restrictHomEquivHom : (G.op ⋙ ℱ ⟶ G.op ⋙ ℱ'.val) ≃ (ℱ ⟶ ℱ'.val) where toFun := sheafHom invFun := whiskerLeft G.op left_inv := sheafHom_restrict_eq right_inv := sheafHom_eq _ /-- Given a locally-full and cover-dense functor `G` and a natural transformation of sheaves `α : ℱ ⟶ ℱ'`, if the pullback of `α` along `G` is iso, then `α` is also iso. -/ theorem iso_of_restrict_iso {ℱ ℱ' : Sheaf K A} (α : ℱ ⟶ ℱ') (i : IsIso (whiskerLeft G.op α.val)) : IsIso α := by convert (sheafIso (asIso (whiskerLeft G.op α.val))).isIso_hom using 1 ext1 apply (sheafHom_eq _ _).symm variable (G K) /-- A locally-fully-faithful and cover-dense functor preserves compatible families. -/ lemma compatiblePreserving [G.IsLocallyFaithful K] : CompatiblePreserving K G := by constructor intro ℱ Z T x hx Y₁ Y₂ X f₁ f₂ g₁ g₂ hg₁ hg₂ eq apply Functor.IsCoverDense.ext G intro W i refine IsLocallyFull.ext G _ (i ≫ f₁) fun V₁ iVW iV₁Y₁ e₁ ↦ ?_ refine IsLocallyFull.ext G _ (G.map iVW ≫ i ≫ f₂) fun V₂ iV₂V₁ iV₂Y₂ e₂ ↦ ?_ refine IsLocallyFaithful.ext G _ (iV₂V₁ ≫ iV₁Y₁ ≫ g₁) (iV₂Y₂ ≫ g₂) (by simp [e₁, e₂, eq]) ?_ intro V₃ iV₃ e₄ simp only [← op_comp, ← FunctorToTypes.map_comp_apply, ← e₁, ← e₂, ← Functor.map_comp] apply hx simpa using e₄ lemma isContinuous [G.IsLocallyFaithful K] (Hp : CoverPreserving J K G) : G.IsContinuous J K := isContinuous_of_coverPreserving (compatiblePreserving K G) Hp instance full_sheafPushforwardContinuous [G.IsContinuous J K] : Full (G.sheafPushforwardContinuous A J K) where map_surjective α := ⟨⟨sheafHom α.val⟩, Sheaf.Hom.ext <| sheafHom_restrict_eq α.val⟩ instance faithful_sheafPushforwardContinuous [G.IsContinuous J K] : Faithful (G.sheafPushforwardContinuous A J K) where map_injective := by intro ℱ ℱ' α β e ext1 apply_fun fun e => e.val at e dsimp [sheafPushforwardContinuous] at e rw [← sheafHom_eq G α.val, ← sheafHom_eq G β.val, e] end IsCoverDense /-- If `G : C ⥤ D` is cover dense and full, then the map `(P ⟶ Q) → (G.op ⋙ P ⟶ G.op ⋙ Q)` is bijective when `Q` is a sheaf`. -/ lemma whiskerLeft_obj_map_bijective_of_isCoverDense (G : C ⥤ D) [G.IsCoverDense K] [G.IsLocallyFull K] {A : Type*} [Category A] (P Q : Dᵒᵖ ⥤ A) (hQ : Presheaf.IsSheaf K Q) : Function.Bijective (((whiskeringLeft Cᵒᵖ Dᵒᵖ A).obj G.op).map : (P ⟶ Q) → _) := (IsCoverDense.restrictHomEquivHom (ℱ' := ⟨Q, hQ⟩)).symm.bijective variable {A : Type*} [Category A] variable (J : GrothendieckTopology C) (K : GrothendieckTopology D) (G : C ⥤ D) /-- The functor `G : C ⥤ D` exhibits `(C, J)` as a dense subsite of `(D, K)` if `G` is cover-dense, locally fully-faithful, and `S` is a cover of `C` if and only if the image of `S` in `D` is a cover. -/ class IsDenseSubsite : Prop where isCoverDense' : G.IsCoverDense K := by infer_instance isLocallyFull' : G.IsLocallyFull K := by infer_instance isLocallyFaithful' : G.IsLocallyFaithful K := by infer_instance functorPushforward_mem_iff : ∀ {X : C} {S : Sieve X}, S.functorPushforward G ∈ K _ ↔ S ∈ J _ lemma functorPushforward_mem_iff {X : C} {S : Sieve X} [G.IsDenseSubsite J K]: S.functorPushforward G ∈ K _ ↔ S ∈ J _ := IsDenseSubsite.functorPushforward_mem_iff namespace IsDenseSubsite variable [G.IsDenseSubsite J K] lemma isCoverDense : G.IsCoverDense K := isCoverDense' J lemma isLocallyFull : G.IsLocallyFull K := isLocallyFull' J lemma isLocallyFaithful : G.IsLocallyFaithful K := isLocallyFaithful' J lemma coverPreserving [G.IsDenseSubsite J K] : CoverPreserving J K G := ⟨functorPushforward_mem_iff.mpr⟩ instance (priority := 900) [G.IsDenseSubsite J K] : G.IsContinuous J K := letI := IsDenseSubsite.isCoverDense J K G letI := IsDenseSubsite.isLocallyFull J K G letI := IsDenseSubsite.isLocallyFaithful J K G IsCoverDense.isContinuous J K G (IsDenseSubsite.coverPreserving J K G) instance (priority := 900) [G.IsDenseSubsite J K] : G.IsCocontinuous J K where cover_lift hS := letI := IsDenseSubsite.isCoverDense J K G letI := IsDenseSubsite.isLocallyFull J K G IsDenseSubsite.functorPushforward_mem_iff.mp (IsCoverDense.functorPullback_pushforward_covering ⟨_, hS⟩) instance full_sheafPushforwardContinuous [G.IsDenseSubsite J K] : Full (G.sheafPushforwardContinuous A J K) := letI := IsDenseSubsite.isCoverDense J K G letI := IsDenseSubsite.isLocallyFull J K G inferInstance instance faithful_sheafPushforwardContinuous [G.IsDenseSubsite J K] : Faithful (G.sheafPushforwardContinuous A J K) := letI := IsDenseSubsite.isCoverDense J K G letI := IsDenseSubsite.isLocallyFull J K G inferInstance lemma imageSieve_mem [G.IsDenseSubsite J K] {U V} (f : G.obj U ⟶ G.obj V) : G.imageSieve f ∈ J _ := letI := IsDenseSubsite.isLocallyFull J K G IsDenseSubsite.functorPushforward_mem_iff.mp (G.functorPushforward_imageSieve_mem K f) lemma equalizer_mem [G.IsDenseSubsite J K] {U V} (f₁ f₂ : U ⟶ V) (e : G.map f₁ = G.map f₂) : Sieve.equalizer f₁ f₂ ∈ J _ := letI := IsDenseSubsite.isLocallyFaithful J K G IsDenseSubsite.functorPushforward_mem_iff.mp (G.functorPushforward_equalizer_mem K f₁ f₂ e) end IsDenseSubsite end Functor end CategoryTheory namespace CategoryTheory.Functor.IsDenseSubsite open CategoryTheory Opposite universe w' variable {C D : Type*} [Category C] [Category D] variable (G : C ⥤ D) variable (J : GrothendieckTopology C) (K : GrothendieckTopology D) variable {A : Type w} [Category.{w'} A] [∀ X, Limits.HasLimitsOfShape (StructuredArrow X G.op) A] variable [G.IsDenseSubsite J K] lemma isIso_ranCounit_app_of_isDenseSubsite (Y : Sheaf J A) (U X) : IsIso ((yoneda.map ((G.op.ranCounit.app Y.val).app (op U))).app (op X)) := by rw [isIso_iff_bijective] constructor · intro f₁ f₂ e apply (isPointwiseRightKanExtensionRanCounit G.op Y.1 (.op (G.obj U))).hom_ext rintro ⟨⟨⟨⟩⟩, ⟨W⟩, g⟩ obtain ⟨g, rfl⟩ : ∃ g' : G.obj W ⟶ G.obj U, g = g'.op := ⟨g.unop, rfl⟩ simp only [id_obj, comp_obj, StructuredArrow.proj_obj, RightExtension.coneAt_pt, RightExtension.mk_left, RightExtension.coneAt_π_app, const_obj_obj, op_obj, whiskeringLeft_obj_obj, RightExtension.mk_hom] apply (Y.2 X _ (IsDenseSubsite.imageSieve_mem J K G g)).isSeparatedFor.ext rintro V iVW ⟨iVU, e'⟩ have := congr($e ≫ Y.1.map iVU.op) simp only [comp_obj, yoneda_map_app, Category.assoc, coyoneda_obj_obj, comp_map, coyoneda_obj_map, ← NatTrans.naturality, op_obj, op_map, Quiver.Hom.unop_op, ← map_comp_assoc, ← op_comp, ← e'] at this ⊢ erw [← NatTrans.naturality] at this exact this · intro f have (X Y Z) (f : X ⟶ Y) (g : G.obj Y ⟶ G.obj Z) (hf : G.imageSieve g f) : Exists _ := hf choose l hl using this let c : Limits.Cone (StructuredArrow.proj (op (G.obj U)) G.op ⋙ Y.val) := by refine ⟨X, ⟨fun g ↦ ?_, ?_⟩⟩ · refine Y.2.amalgamate ⟨_, IsDenseSubsite.imageSieve_mem J K G g.hom.unop⟩ (fun I ↦ f ≫ Y.1.map (l _ _ _ _ _ I.hf).op) fun I₁ I₂ r ↦ ?_ apply (Y.2 X _ (IsDenseSubsite.equalizer_mem J K G (r.g₁ ≫ l _ _ _ _ _ I₁.hf) (r.g₂ ≫ l _ _ _ _ _ I₂.hf) ?_)).isSeparatedFor.ext fun V iUV (hiUV : _ = _) ↦ ?_ · simp only [const_obj_obj, op_obj, map_comp, hl] simp only [← map_comp_assoc, r.w] · simp [← map_comp, ← op_comp, hiUV] · rintro ⟨⟨⟨⟩⟩, ⟨W₁⟩, g₁⟩ ⟨⟨⟨⟩⟩, ⟨W₂⟩, g₂⟩ ⟨⟨⟨⟨⟩⟩⟩, i, hi⟩ dsimp at g₁ g₂ i hi obtain rfl : g₂ = g₁ ≫ (G.map i.unop).op := by simpa only [Category.id_comp] using hi obtain ⟨g, rfl⟩ : ∃ g' : G.obj W₁ ⟶ G.obj U, g₁ = g'.op := ⟨g₁.unop, rfl⟩ obtain ⟨i, rfl⟩ : ∃ i' : W₂ ⟶ W₁, i = i'.op := ⟨i.unop, rfl⟩ simp only [const_obj_obj, id_obj, comp_obj, StructuredArrow.proj_obj, const_obj_map, op_obj, unop_comp, Quiver.Hom.unop_op, Category.id_comp, comp_map, StructuredArrow.proj_map] apply Y.2.hom_ext ⟨_, IsDenseSubsite.imageSieve_mem J K G (G.map i ≫ g)⟩ intro I simp only [Presheaf.IsSheaf.amalgamate_map, Category.assoc, ← Functor.map_comp, ← op_comp] let I' : GrothendieckTopology.Cover.Arrow ⟨_, IsDenseSubsite.imageSieve_mem J K G g⟩ := ⟨_, I.f ≫ i, ⟨l _ _ _ _ _ I.hf, by simp [hl]⟩⟩ refine Eq.trans ?_ (Y.2.amalgamate_map _ _ _ I').symm apply (Y.2 X _ (IsDenseSubsite.equalizer_mem J K G (l _ _ _ _ _ I.hf) (l _ _ _ _ _ I'.hf) (by simp [hl]))).isSeparatedFor.ext fun V iUV (hiUV : _ = _) ↦ ?_ simp [← Functor.map_comp, ← op_comp, hiUV] refine ⟨(isPointwiseRightKanExtensionRanCounit G.op Y.1 (.op (G.obj U))).lift c, ?_⟩ · have := (isPointwiseRightKanExtensionRanCounit G.op Y.1 (.op (G.obj U))).fac c (.mk (𝟙 _)) simp only [id_obj, comp_obj, StructuredArrow.proj_obj, StructuredArrow.mk_right, RightExtension.coneAt_pt, RightExtension.mk_left, RightExtension.coneAt_π_app, const_obj_obj, op_obj, StructuredArrow.mk_hom_eq_self, map_id, whiskeringLeft_obj_obj, RightExtension.mk_hom, Category.id_comp, StructuredArrow.mk_left, unop_id] at this simp only [id_obj, yoneda_map_app, this] apply Y.2.hom_ext ⟨_, IsDenseSubsite.imageSieve_mem J K G (𝟙 (G.obj U))⟩ _ _ fun I ↦ ?_ apply (Y.2 X _ (IsDenseSubsite.equalizer_mem J K G (l _ _ _ _ _ I.hf) I.f (by simp [hl]))).isSeparatedFor.ext fun V iUV (hiUV : _ = _) ↦ ?_ simp [← Functor.map_comp, ← op_comp, hiUV] instance (Y : Sheaf J A) : IsIso ((G.sheafAdjunctionCocontinuous A J K).counit.app Y) := by apply (config := { allowSynthFailures := true }) ReflectsIsomorphisms.reflects (sheafToPresheaf J A) rw [NatTrans.isIso_iff_isIso_app] intro ⟨U⟩ apply (config := { allowSynthFailures := true }) ReflectsIsomorphisms.reflects yoneda rw [NatTrans.isIso_iff_isIso_app] intro ⟨X⟩ simp only [comp_obj, sheafToPresheaf_obj, sheafPushforwardContinuous_obj_val_obj, yoneda_obj_obj, id_obj, sheafToPresheaf_map, sheafAdjunctionCocontinuous_counit_app_val, ranAdjunction_counit] exact isIso_ranCounit_app_of_isDenseSubsite G J K Y U X variable (A) /-- If `G : C ⥤ D` exhibits `(C, J)` as a dense subsite of `(D, K)`, it induces an equivalence of category of sheaves valued in a category with suitable limits. -/ @[simps! functor inverse] noncomputable def sheafEquiv : Sheaf J A ≌ Sheaf K A := (G.sheafAdjunctionCocontinuous A J K).toEquivalence.symm instance : (G.sheafPushforwardContinuous A J K).IsEquivalence := inferInstanceAs (IsDenseSubsite.sheafEquiv G _ _ _).inverse.IsEquivalence variable [HasWeakSheafify J A] [HasWeakSheafify K A] /-- The natural isomorphism exhibiting the compatibility of `IsDenseSubsite.sheafEquiv` with sheafification. -/ noncomputable abbrev sheafEquivSheafificationCompatibility : (whiskeringLeft _ _ A).obj G.op ⋙ presheafToSheaf _ _ ≅ presheafToSheaf _ _ ⋙ (sheafEquiv G J K A).inverse := by apply Functor.pushforwardContinuousSheafificationCompatibility end IsDenseSubsite @[deprecated (since := "2024-07-23")] alias IsCoverDense.sheafEquivOfCoverPreservingCoverLifting := IsDenseSubsite.sheafEquiv @[deprecated (since := "2024-07-23")] alias IsCoverDense.sheafEquivOfCoverPreservingCoverLiftingSheafificationCompatibility := IsDenseSubsite.sheafEquivSheafificationCompatibility end CategoryTheory.Functor
CategoryTheory\Sites\Discrete.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.Adjunction.FullyFaithful import Mathlib.CategoryTheory.Sites.ConstantSheaf import Mathlib.CategoryTheory.Sites.DenseSubsite import Mathlib.CategoryTheory.Sites.PreservesSheafification /-! # Discrete objects in sheaf categories. This file defines the notion of a discrete object in a sheaf category. A discrete sheaf in this context is a sheaf `F` such that the counit `(F(*))^cst ⟶ F` is an isomorphism. Here `*` denotes a particular chosen terminal object of the defining site, and `cst` denotes the constant sheaf. It is convenient to take an arbitrary terminal object; one might want to use this construction to talk about discrete sheaves on a site which has a particularly convenient terminal object, such as the one element space in `CompHaus`. ## Main results * `isDiscrete_iff_mem_essImage` : A sheaf is discrete if and only if it is in the essential image of the constant sheaf functor. * `isDiscrete_iff_of_equivalence` : The property of a sheaf of being discrete is invariant under equivalence of sheaf categories. * `isDiscrete_iff_forget` : Given a "forgetful" functor `U : A ⥤ B` a sheaf `F : Sheaf J A` is discrete if and only if the sheaf given by postcomposition with `U` is discrete. ## Future work * Use `isDiscrete_iff_forget` to prove that a condensed module is discrete if and only if its underlying condensed set is discrete. -/ open CategoryTheory Limits Functor Adjunction Opposite Category Functor namespace CategoryTheory.Sheaf variable {C : Type*} [Category C] (J : GrothendieckTopology C) {A : Type*} [Category A] [HasWeakSheafify J A] {t : C} (ht : IsTerminal t) section variable [(constantSheaf J A).Faithful] [(constantSheaf J A).Full] /-- A sheaf is discrete if it is a discrete object of the "underlying object" functor from the sheaf category to the target category. -/ abbrev IsDiscrete (F : Sheaf J A) : Prop := IsIso ((constantSheafAdj J A ht).counit.app F) lemma isDiscrete_of_iso {F : Sheaf J A} {X : A} (i : F ≅ (constantSheaf J A).obj X) : IsDiscrete J ht F := isIso_counit_app_of_iso _ i lemma isDiscrete_iff_mem_essImage (F : Sheaf J A) : F.IsDiscrete J ht ↔ F ∈ (constantSheaf J A).essImage := (constantSheafAdj J A ht).isIso_counit_app_iff_mem_essImage lemma isDiscrete_iff_mem_essImage' {L : A ⥤ Sheaf J A} (adj : L ⊣ (sheafSections J A).obj ⟨t⟩) (F : Sheaf J A) : IsDiscrete J ht F ↔ F ∈ L.essImage := by let e : L ≅ constantSheaf J A := adj.leftAdjointUniq (constantSheafAdj _ _ ht) refine ⟨fun h ↦ ⟨F.val.obj ⟨t⟩, ⟨?_⟩⟩, fun ⟨Y, ⟨i⟩⟩ ↦ ?_⟩ · exact e.app _ ≪≫ asIso ((constantSheafAdj _ _ ht).counit.app _) · rw [isDiscrete_iff_mem_essImage] exact ⟨Y, ⟨e.symm.app _ ≪≫ i⟩⟩ lemma isDiscrete_iff_isIso_counit_app {L : A ⥤ Sheaf J A} (adj : L ⊣ (sheafSections J A).obj ⟨t⟩) (F : Sheaf J A) : IsDiscrete J ht F ↔ IsIso (adj.counit.app F) := by have : L.Faithful := Functor.Faithful.of_iso (adj.leftAdjointUniq (constantSheafAdj _ _ ht)).symm have : L.Full := Functor.Full.of_iso (adj.leftAdjointUniq (constantSheafAdj _ _ ht)).symm rw [isIso_counit_app_iff_mem_essImage] exact isDiscrete_iff_mem_essImage' _ _ adj _ section Equivalence variable {D : Type*} [Category D] (K : GrothendieckTopology D) [HasWeakSheafify K A] variable (G : C ⥤ D) [∀ (X : Dᵒᵖ), HasLimitsOfShape (StructuredArrow X G.op) A] [G.IsDenseSubsite J K] (ht' : IsTerminal (G.obj t)) open Functor.IsDenseSubsite noncomputable example : let e : Sheaf J A ≌ Sheaf K A := sheafEquiv G J K A e.inverse ⋙ (sheafSections J A).obj (op t) ≅ (sheafSections K A).obj (op (G.obj t)) := Iso.refl _ variable (A) in /-- The constant sheaf functor commutes up to isomorphism with any equivalence of sheaf categories. This is an auxiliary definition used to prove `Sheaf.isDiscrete_iff` below, which says that the property of a sheaf of being a discrete object is invariant under equivalence of sheaf categories. -/ noncomputable def equivCommuteConstant : let e : Sheaf J A ≌ Sheaf K A := sheafEquiv G J K A constantSheaf J A ⋙ e.functor ≅ constantSheaf K A := let e : Sheaf J A ≌ Sheaf K A := sheafEquiv G J K A (Adjunction.leftAdjointUniq ((constantSheafAdj J A ht).comp e.toAdjunction) (constantSheafAdj K A ht')) variable (A) in /-- The constant sheaf functor commutes up to isomorphism with any equivalence of sheaf categories. This is an auxiliary definition used to prove `Sheaf.isDiscrete_iff` below, which says that the property of a sheaf of being a discrete object is invariant under equivalence of sheaf categories. -/ noncomputable def equivCommuteConstant' : let e : Sheaf J A ≌ Sheaf K A := sheafEquiv G J K A constantSheaf J A ≅ constantSheaf K A ⋙ e.inverse := let e : Sheaf J A ≌ Sheaf K A := sheafEquiv G J K A isoWhiskerLeft (constantSheaf J A) e.unitIso ≪≫ isoWhiskerRight (equivCommuteConstant J A ht K G ht') e.inverse /-- The property of a sheaf of being a discrete object is invariant under equivalence of sheaf categories. -/ lemma isDiscrete_iff_of_equivalence (F : Sheaf K A) : let e : Sheaf J A ≌ Sheaf K A := sheafEquiv G J K A haveI : (constantSheaf K A).Faithful := Functor.Faithful.of_iso (equivCommuteConstant J A ht K G ht') haveI : (constantSheaf K A).Full := Functor.Full.of_iso (equivCommuteConstant J A ht K G ht') (e.inverse.obj F).IsDiscrete J ht ↔ IsDiscrete K ht' F := by intro e have : (constantSheaf K A).Faithful := Functor.Faithful.of_iso (equivCommuteConstant J A ht K G ht') have : (constantSheaf K A).Full := Functor.Full.of_iso (equivCommuteConstant J A ht K G ht') simp only [isDiscrete_iff_mem_essImage] constructor · intro ⟨Y, ⟨i⟩⟩ let j : (constantSheaf K A).obj Y ≅ F := (equivCommuteConstant J A ht K G ht').symm.app _ ≪≫ e.functor.mapIso i ≪≫ e.counitIso.app _ exact ⟨_, ⟨j⟩⟩ · intro ⟨Y, ⟨i⟩⟩ let j : (constantSheaf J A).obj Y ≅ e.inverse.obj F := (equivCommuteConstant' J A ht K G ht').app _ ≪≫ e.inverse.mapIso i exact ⟨_, ⟨j⟩⟩ end Equivalence end section Forget variable {B : Type*} [Category B] (U : A ⥤ B) [HasWeakSheafify J B] [J.PreservesSheafification U] [J.HasSheafCompose U] (F : Sheaf J A) open Limits /-- The constant sheaf functor commutes with `sheafCompose` up to isomorphism. -/ @[simps!] noncomputable def constantCommuteCompose : constantSheaf J A ⋙ sheafCompose J U ≅ U ⋙ constantSheaf J B := (isoWhiskerLeft (const Cᵒᵖ) (sheafComposeNatIso J U (sheafificationAdjunction J A) (sheafificationAdjunction J B)).symm) ≪≫ isoWhiskerRight (compConstIso _ _).symm _ lemma sheafComposeNatIso_app_counit (P : Sheaf J A) : (sheafComposeNatIso J U (sheafificationAdjunction J A) (sheafificationAdjunction J B)).hom.app _ ≫ (sheafCompose J U).map ((sheafificationAdjunction J A).counit.app P) = (sheafificationAdjunction J B).counit.app ((sheafCompose J U).obj P) := by simp only [sheafToPresheaf_obj, Functor.comp_obj, whiskeringRight_obj_obj, Functor.id_obj, sheafComposeNatIso, sheafComposeNatTrans, sheafCompose_obj_val, sheafificationAdjunction_unit_app, asIso_hom] erw [Adjunction.homEquiv_counit] apply Sheaf.hom_ext apply sheafify_hom_ext _ _ _ ((sheafCompose J U).obj P).cond simp [← whiskerRight_comp] lemma constantCommuteComposeApp_comp_counit (F : Sheaf J A) : ((constantCommuteCompose J U).app _).hom ≫ (constantSheafAdj J B ht).counit.app ((sheafCompose J U).obj F) = (sheafCompose J U).map ((constantSheafAdj J A ht).counit.app F) := by simp only [← Iso.eq_inv_comp, constantSheafAdj_counit_app, constantCommuteCompose, flip_obj_obj, sheafToPresheaf_obj, id_obj, NatIso.trans_app, comp_obj, whiskeringRight_obj_obj, Iso.trans_inv, Iso.app_inv, isoWhiskerRight_inv, Iso.symm_inv, whiskerRight_app, isoWhiskerLeft_inv, whiskerLeft_app, evaluation_obj_obj, Functor.map_comp, assoc, sheafCompose_obj_val, ← sheafComposeNatIso_app_counit] simp only [← assoc] congr 1 have : (compConstIso Cᵒᵖ U).hom.app (F.val.obj ⟨t⟩) ≫ { app := fun Y ↦ (F.val ⋙ U).map (ht.from _).op naturality := by intros; simp; rw [← Functor.map_comp, ← Functor.map_comp]; congr; simp } = ((constantPresheafAdj B ht).counit.app (F.val ⋙ U)) := by ext; simp [constantPresheafAdj] simp only [← this, assoc, Functor.map_comp] congr 1 apply Sheaf.hom_ext apply sheafify_hom_ext _ _ _ ((sheafCompose J U).obj ((presheafToSheaf J A).obj F.val)).cond simp only [sheafCompose_obj_val, instCategorySheaf_comp_val, sheafCompose_map_val, comp_obj, whiskeringRight_obj_obj, Functor.comp_map] erw [← toSheafify_naturality_assoc, sheafComposeIso_hom_fac, sheafComposeIso_hom_fac_assoc] ext simp only [comp_obj, const_obj_obj, NatTrans.comp_app, whiskerRight_app, ← Functor.map_comp] congr 1 simp only [constantPresheafAdj, comp_obj, evaluation_obj_obj, id_obj, Opposite.op_unop, Adjunction.mkOfUnitCounit_counit, NatTrans.naturality] erw [← NatTrans.comp_app, ← toSheafify_naturality] simp only [NatTrans.comp_app, const_obj_obj, NatTrans.naturality] /-- Auxiliary lemma for `sheafCompose_reflects_discrete`. -/ private lemma sheafifyComposeIso_comp_sheafCompose_map_constantSheafAdj_counit : (sheafifyComposeIso J U ((const Cᵒᵖ).obj (F.val.obj { unop := t }))).hom ≫ ((sheafCompose J U).map ((constantSheafAdj J A ht).counit.app F)).val = ((presheafToSheaf J B ⋙ sheafToPresheaf J B).mapIso (constComp Cᵒᵖ _ U)).hom ≫ ((constantSheafAdj J B ht).counit.app ((sheafCompose J U).obj F)).val := by apply sheafify_hom_ext _ _ _ ((sheafCompose J U).obj F).cond simp only [sheafCompose_obj_val, id_obj, comp_obj, flip_obj_obj, sheafToPresheaf_obj, sheafComposeIso_hom_fac_assoc, mapIso_hom, Functor.comp_map, sheafToPresheaf_map] erw [Adjunction.unit_naturality_assoc] simp only [const_obj_obj, const_obj_map, id_obj, constComp, comp_obj, sheafToPresheaf_obj, sheafificationAdjunction_unit_app] ext simp only [comp_obj, const_obj_obj, NatTrans.comp_app, whiskerRight_app, Category.id_comp, comp_obj, flip_obj_obj, sheafToPresheaf_obj, id_obj, constantSheafAdj, Adjunction.comp, evaluation_obj_obj, NatTrans.comp_app, associator_hom_app, whiskerLeft_app, whiskerRight_app, map_comp, instCategorySheaf_comp_val, sheafCompose_obj_val, sheafCompose_map_val, instCategorySheaf_id_val, sheafificationAdjunction_counit_app_val, NatTrans.id_app, sheafifyMap_sheafifyLift, Category.comp_id, Category.id_comp] erw [Functor.map_id, Category.id_comp, ← NatTrans.comp_app] simp only [toSheafify_sheafifyLift, ← Functor.map_comp, ← NatTrans.comp_app, sheafifyMap_sheafifyLift, Category.comp_id, constantPresheafAdj, comp_obj, evaluation_obj_obj, id_obj, op_unop, mkOfUnitCounit_counit, Functor.comp_map] /-- Auxiliary lemma for `sheafCompose_reflects_discrete`. -/ private lemma constantSheafAdj_counit_w : ((sheafifyComposeIso J U ((const Cᵒᵖ).obj (F.val.obj ⟨t⟩))).symm ≪≫ (presheafToSheaf J B ⋙ sheafToPresheaf J B).mapIso (constComp Cᵒᵖ (F.val.obj ⟨t⟩) U)).hom ≫ ((constantSheafAdj J B ht).counit.app ((sheafCompose J U).obj F)).val = ((sheafCompose J U).map ((constantSheafAdj J A ht).counit.app F)).val := by rw [← Iso.eq_inv_comp] simp only [comp_obj, flip_obj_obj, sheafToPresheaf_obj, sheafCompose_obj_val, id_obj, Iso.trans_inv, mapIso_inv, Functor.comp_map, sheafToPresheaf_map, Iso.symm_inv, Category.assoc, sheafifyComposeIso_comp_sheafCompose_map_constantSheafAdj_counit, mapIso_hom, ← instCategorySheaf_comp_val, Iso.map_inv_hom_id_assoc] lemma sheafCompose_reflects_discrete [(sheafCompose J U).ReflectsIsomorphisms] [((sheafCompose J U).obj F).IsDiscrete J ht] : F.IsDiscrete J ht := by let f := (sheafCompose J U).map ((constantSheafAdj J A ht).counit.app F) have : IsIso ((sheafToPresheaf J B).map f) := by simp only [comp_obj, flip_obj_obj, sheafToPresheaf_obj, sheafCompose_obj_val, id_obj, sheafToPresheaf_map, f, ← constantSheafAdj_counit_w] exact inferInstanceAs (IsIso (_ ≫ ((sheafToPresheaf J B).map ((constantSheafAdj J B ht).counit.app ((sheafCompose J U).obj F))))) have : IsIso f := by apply ReflectsIsomorphisms.reflects (sheafToPresheaf J B) _ apply ReflectsIsomorphisms.reflects (sheafCompose J U) _ variable [(constantSheaf J A).Full] [(constantSheaf J A).Faithful] [(constantSheaf J B).Full] [(constantSheaf J B).Faithful] instance [h : F.IsDiscrete J ht] : ((sheafCompose J U).obj F).IsDiscrete J ht := by rw [isDiscrete_iff_mem_essImage] at h ⊢ obtain ⟨Y, ⟨i⟩⟩ := h exact ⟨U.obj Y, ⟨(fullyFaithfulSheafToPresheaf _ _).preimageIso (((sheafifyComposeIso J U ((const Cᵒᵖ).obj Y)).symm ≪≫ (presheafToSheaf J B ⋙ sheafToPresheaf J B).mapIso (constComp Cᵒᵖ Y U)).symm ≪≫ (sheafToPresheaf _ _).mapIso ((sheafCompose J U).mapIso i))⟩⟩ lemma isDiscrete_iff_forget [(sheafCompose J U).ReflectsIsomorphisms] : F.IsDiscrete J ht ↔ ((sheafCompose J U).obj F).IsDiscrete J ht := ⟨fun _ ↦ inferInstance, fun _ ↦ sheafCompose_reflects_discrete _ _ U F⟩ end Forget end CategoryTheory.Sheaf
CategoryTheory\Sites\EffectiveEpimorphic.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.Sites.Sieves import Mathlib.CategoryTheory.EffectiveEpi.Basic /-! # Effective epimorphic sieves We define the notion of effective epimorphic (pre)sieves and provide some API for relating the notion with the notions of effective epimorphism and effective epimorphic family. More precisely, if `f` is a morphism, then `f` is an effective epi if and only if the sieve it generates is effective epimorphic; see `CategoryTheory.Sieve.effectiveEpimorphic_singleton`. The analogous statement for a family of morphisms is in the theorem `CategoryTheory.Sieve.effectiveEpimorphic_family`. -/ namespace CategoryTheory open Limits variable {C : Type*} [Category C] /-- A sieve is effective epimorphic if the associated cocone is a colimit cocone. -/ def Sieve.EffectiveEpimorphic {X : C} (S : Sieve X) : Prop := Nonempty (IsColimit (S : Presieve X).cocone) /-- A presieve is effective epimorphic if the cocone associated to the sieve it generates is a colimit cocone. -/ abbrev Presieve.EffectiveEpimorphic {X : C} (S : Presieve X) : Prop := (Sieve.generate S).EffectiveEpimorphic /-- The sieve of morphisms which factor through a given morphism `f`. This is equal to `Sieve.generate (Presieve.singleton f)`, but has more convenient definitional properties. -/ def Sieve.generateSingleton {X Y : C} (f : Y ⟶ X) : Sieve X where arrows Z := { g | ∃ (e : Z ⟶ Y), e ≫ f = g } downward_closed := by rintro W Z g ⟨e,rfl⟩ q exact ⟨q ≫ e, by simp⟩ lemma Sieve.generateSingleton_eq {X Y : C} (f : Y ⟶ X) : Sieve.generate (Presieve.singleton f) = Sieve.generateSingleton f := by ext Z g constructor · rintro ⟨W,i,p,⟨⟩,rfl⟩ exact ⟨i,rfl⟩ · rintro ⟨g,h⟩ exact ⟨Y,g,f,⟨⟩,h⟩ /-- Implementation: This is a construction which will be used in the proof that the sieve generated by a single arrow is effective epimorphic if and only if the arrow is an effective epi. -/ def isColimitOfEffectiveEpiStruct {X Y : C} (f : Y ⟶ X) (Hf : EffectiveEpiStruct f) : IsColimit (Sieve.generateSingleton f : Presieve X).cocone := letI D := FullSubcategory fun T : Over X => Sieve.generateSingleton f T.hom letI F : D ⥤ _ := (Sieve.generateSingleton f).arrows.diagram { desc := fun S => Hf.desc (S.ι.app ⟨Over.mk f, ⟨𝟙 _, by simp⟩⟩) <| by intro Z g₁ g₂ h let Y' : D := ⟨Over.mk f, 𝟙 _, by simp⟩ let Z' : D := ⟨Over.mk (g₁ ≫ f), g₁, rfl⟩ let g₁' : Z' ⟶ Y' := Over.homMk g₁ let g₂' : Z' ⟶ Y' := Over.homMk g₂ (by simp [h]) change F.map g₁' ≫ _ = F.map g₂' ≫ _ simp only [S.w] fac := by rintro S ⟨T,g,hT⟩ dsimp nth_rewrite 1 [← hT, Category.assoc, Hf.fac] let y : D := ⟨Over.mk f, 𝟙 _, by simp⟩ let x : D := ⟨Over.mk T.hom, g, hT⟩ let g' : x ⟶ y := Over.homMk g change F.map g' ≫ _ = _ rw [S.w] rfl uniq := by intro S m hm dsimp generalize_proofs h1 h2 apply Hf.uniq _ h2 exact hm ⟨Over.mk f, 𝟙 _, by simp⟩ } /-- Implementation: This is a construction which will be used in the proof that the sieve generated by a single arrow is effective epimorphic if and only if the arrow is an effective epi. -/ noncomputable def effectiveEpiStructOfIsColimit {X Y : C} (f : Y ⟶ X) (Hf : IsColimit (Sieve.generateSingleton f : Presieve X).cocone) : EffectiveEpiStruct f := let aux {W : C} (e : Y ⟶ W) (h : ∀ {Z : C} (g₁ g₂ : Z ⟶ Y), g₁ ≫ f = g₂ ≫ f → g₁ ≫ e = g₂ ≫ e) : Cocone (Sieve.generateSingleton f).arrows.diagram := { pt := W ι := { app := fun ⟨T,hT⟩ => hT.choose ≫ e naturality := by rintro ⟨A,hA⟩ ⟨B,hB⟩ (q : A ⟶ B) dsimp; simp only [← Category.assoc, Category.comp_id] apply h rw [Category.assoc, hB.choose_spec, hA.choose_spec, Over.w] } } { desc := fun {W} e h => Hf.desc (aux e h) fac := by intro W e h dsimp have := Hf.fac (aux e h) ⟨Over.mk f, 𝟙 _, by simp⟩ dsimp at this; rw [this]; clear this nth_rewrite 2 [← Category.id_comp e] apply h generalize_proofs hh rw [hh.choose_spec, Category.id_comp] uniq := by intro W e h m hm dsimp apply Hf.uniq (aux e h) rintro ⟨A,g,hA⟩ dsimp nth_rewrite 1 [← hA, Category.assoc, hm] apply h generalize_proofs hh rwa [hh.choose_spec] } theorem Sieve.effectiveEpimorphic_singleton {X Y : C} (f : Y ⟶ X) : (Presieve.singleton f).EffectiveEpimorphic ↔ (EffectiveEpi f) := by constructor · intro (h : Nonempty _) rw [Sieve.generateSingleton_eq] at h constructor apply Nonempty.map (effectiveEpiStructOfIsColimit _) h · rintro ⟨h⟩ show Nonempty _ rw [Sieve.generateSingleton_eq] apply Nonempty.map (isColimitOfEffectiveEpiStruct _) h /-- The sieve of morphisms which factor through a morphism in a given family. This is equal to `Sieve.generate (Presieve.ofArrows X π)`, but has more convenient definitional properties. -/ def Sieve.generateFamily {B : C} {α : Type*} (X : α → C) (π : (a : α) → (X a ⟶ B)) : Sieve B where arrows Y := { f | ∃ (a : α) (g : Y ⟶ X a), g ≫ π a = f } downward_closed := by rintro Y₁ Y₂ g₁ ⟨a,q,rfl⟩ e exact ⟨a, e ≫ q, by simp⟩ lemma Sieve.generateFamily_eq {B : C} {α : Type*} (X : α → C) (π : (a : α) → (X a ⟶ B)) : Sieve.generate (Presieve.ofArrows X π) = Sieve.generateFamily X π := by ext Y g constructor · rintro ⟨W, g, f, ⟨a⟩, rfl⟩ exact ⟨a, g, rfl⟩ · rintro ⟨a, g, rfl⟩ exact ⟨_, g, π a, ⟨a⟩, rfl⟩ /-- Implementation: This is a construction which will be used in the proof that the sieve generated by a family of arrows is effective epimorphic if and only if the family is an effective epi. -/ def isColimitOfEffectiveEpiFamilyStruct {B : C} {α : Type*} (X : α → C) (π : (a : α) → (X a ⟶ B)) (H : EffectiveEpiFamilyStruct X π) : IsColimit (Sieve.generateFamily X π : Presieve B).cocone := letI D := FullSubcategory fun T : Over B => Sieve.generateFamily X π T.hom letI F : D ⥤ _ := (Sieve.generateFamily X π).arrows.diagram { desc := fun S => H.desc (fun a => S.ι.app ⟨Over.mk (π a), ⟨a,𝟙 _, by simp⟩⟩) <| by intro Z a₁ a₂ g₁ g₂ h dsimp let A₁ : D := ⟨Over.mk (π a₁), a₁, 𝟙 _, by simp⟩ let A₂ : D := ⟨Over.mk (π a₂), a₂, 𝟙 _, by simp⟩ let Z' : D := ⟨Over.mk (g₁ ≫ π a₁), a₁, g₁, rfl⟩ let i₁ : Z' ⟶ A₁ := Over.homMk g₁ let i₂ : Z' ⟶ A₂ := Over.homMk g₂ change F.map i₁ ≫ _ = F.map i₂ ≫ _ simp only [S.w] fac := by intro S ⟨T, a, (g : T.left ⟶ X a), hT⟩ dsimp nth_rewrite 1 [← hT, Category.assoc, H.fac] let A : D := ⟨Over.mk (π a), a, 𝟙 _, by simp⟩ let B : D := ⟨Over.mk T.hom, a, g, hT⟩ let i : B ⟶ A := Over.homMk g change F.map i ≫ _ = _ rw [S.w] rfl uniq := by intro S m hm; dsimp apply H.uniq intro a exact hm ⟨Over.mk (π a), a, 𝟙 _, by simp⟩ } /-- Implementation: This is a construction which will be used in the proof that the sieve generated by a family of arrows is effective epimorphic if and only if the family is an effective epi. -/ noncomputable def effectiveEpiFamilyStructOfIsColimit {B : C} {α : Type*} (X : α → C) (π : (a : α) → (X a ⟶ B)) (H : IsColimit (Sieve.generateFamily X π : Presieve B).cocone) : EffectiveEpiFamilyStruct X π := let aux {W : C} (e : (a : α) → (X a ⟶ W)) (h : ∀ {Z : C} (a₁ a₂ : α) (g₁ : Z ⟶ X a₁) (g₂ : Z ⟶ X a₂), g₁ ≫ π _ = g₂ ≫ π _ → g₁ ≫ e _ = g₂ ≫ e _) : Cocone (Sieve.generateFamily X π).arrows.diagram := { pt := W ι := { app := fun ⟨T,hT⟩ => hT.choose_spec.choose ≫ e hT.choose naturality := by intro ⟨A,a,(g₁ : A.left ⟶ _),ha⟩ ⟨B,b,(g₂ : B.left ⟶ _),hb⟩ (q : A ⟶ B) dsimp; rw [Category.comp_id, ← Category.assoc] apply h; rw [Category.assoc] generalize_proofs h1 h2 h3 h4 rw [h2.choose_spec, h4.choose_spec, Over.w] } } { desc := fun {W} e h => H.desc (aux e h) fac := by intro W e h a dsimp have := H.fac (aux e h) ⟨Over.mk (π a), a, 𝟙 _, by simp⟩ dsimp at this; rw [this]; clear this conv_rhs => rw [← Category.id_comp (e a)] apply h generalize_proofs h1 h2 rw [h2.choose_spec, Category.id_comp] uniq := by intro W e h m hm apply H.uniq (aux e h) rintro ⟨T, a, (g : T.left ⟶ _), ha⟩ dsimp nth_rewrite 1 [← ha, Category.assoc, hm] apply h generalize_proofs h1 h2 rwa [h2.choose_spec] } theorem Sieve.effectiveEpimorphic_family {B : C} {α : Type*} (X : α → C) (π : (a : α) → (X a ⟶ B)) : (Presieve.ofArrows X π).EffectiveEpimorphic ↔ EffectiveEpiFamily X π := by constructor · intro (h : Nonempty _) rw [Sieve.generateFamily_eq] at h constructor apply Nonempty.map (effectiveEpiFamilyStructOfIsColimit _ _) h · rintro ⟨h⟩ show Nonempty _ rw [Sieve.generateFamily_eq] apply Nonempty.map (isColimitOfEffectiveEpiFamilyStruct _ _) h end CategoryTheory
CategoryTheory\Sites\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.MorphismProperty.Concrete import Mathlib.CategoryTheory.Sites.LocallyBijective /-! # Morphisms of sheaves factor as a locally surjective followed by a locally injective morphism When morphisms in a concrete category `A` factor in a functorial manner as a surjective map followed by an injective map, we obtain that any morphism of sheaves in `Sheaf J A` factors in a functorial manner as a locally surjective morphism (which is epi) followed by a locally injective morphism (which is mono). Moreover, if we assume that the category of sheaves `Sheaf J A` is balanced (see `Sites.LeftExact`), then epimorphisms are exactly locally surjective morphisms. -/ universe w v' u' v u namespace CategoryTheory open Category ConcreteCategory variable {C : Type u} [Category.{v} C] (J : GrothendieckTopology C) (A : Type u') [Category.{v'} A] [ConcreteCategory.{w} A] [HasFunctorialSurjectiveInjectiveFactorization A] [J.WEqualsLocallyBijective A] namespace Presheaf end Presheaf namespace Sheaf /-- The class of locally injective morphisms of sheaves, see `Sheaf.IsLocallyInjective`. -/ def locallyInjective : MorphismProperty (Sheaf J A) := fun _ _ f => IsLocallyInjective f /-- The class of locally surjective morphisms of sheaves, see `Sheaf.IsLocallySurjective`. -/ def locallySurjective : MorphismProperty (Sheaf J A) := fun _ _ f => IsLocallySurjective f section variable {A} variable (data : FunctorialSurjectiveInjectiveFactorizationData A) [HasWeakSheafify J A] /-- Given a functorial surjective/injective factorizations of morphisms in a concrete category `A`, this is the induced functorial locally surjective/locally injective factorization of morphisms in the category `Sheaf J A`. -/ noncomputable def functorialLocallySurjectiveInjectiveFactorization : (locallySurjective J A).FunctorialFactorizationData (locallyInjective J A) where Z := (sheafToPresheaf J A).mapArrow ⋙ (data.functorCategory Cᵒᵖ).Z ⋙ presheafToSheaf J A i := whiskerLeft Arrow.leftFunc (inv (sheafificationAdjunction J A).counit) ≫ whiskerLeft (sheafToPresheaf J A).mapArrow (whiskerRight (data.functorCategory Cᵒᵖ).i (presheafToSheaf J A)) p := whiskerLeft (sheafToPresheaf J A).mapArrow (whiskerRight (data.functorCategory Cᵒᵖ).p (presheafToSheaf J A)) ≫ whiskerLeft Arrow.rightFunc (sheafificationAdjunction J A).counit fac := by ext f : 2 dsimp simp only [assoc, ← Functor.map_comp_assoc, MorphismProperty.FunctorialFactorizationData.fac_app, NatIso.isIso_inv_app, IsIso.inv_comp_eq] exact (sheafificationAdjunction J A).counit.naturality f.hom hi _ := by dsimp [locallySurjective] rw [← isLocallySurjective_sheafToPresheaf_map_iff, Functor.map_comp, Presheaf.comp_isLocallySurjective_iff, isLocallySurjective_sheafToPresheaf_map_iff, Presheaf.isLocallySurjective_presheafToSheaf_map_iff] apply Presheaf.isLocallySurjective_of_surjective apply (data.functorCategory Cᵒᵖ).hi hp _ := by dsimp [locallyInjective] rw [← isLocallyInjective_sheafToPresheaf_map_iff, Functor.map_comp, Presheaf.isLocallyInjective_comp_iff, isLocallyInjective_sheafToPresheaf_map_iff, Presheaf.isLocallyInjective_presheafToSheaf_map_iff] apply Presheaf.isLocallyInjective_of_injective apply (data.functorCategory Cᵒᵖ).hp section variable (f : Arrow (Sheaf J A)) instance : IsLocallySurjective ((functorialLocallySurjectiveInjectiveFactorization J data).i.app f) := by apply (functorialLocallySurjectiveInjectiveFactorization J data).hi instance : IsLocallyInjective ((functorialLocallySurjectiveInjectiveFactorization J data).p.app f) := by apply (functorialLocallySurjectiveInjectiveFactorization J data).hp variable [J.HasSheafCompose (forget A)] instance : Epi ((functorialLocallySurjectiveInjectiveFactorization J data).i.app f) := by apply epi_of_isLocallySurjective instance : Mono ((functorialLocallySurjectiveInjectiveFactorization J data).p.app f) := by apply mono_of_isLocallyInjective end instance : (locallySurjective J A).HasFunctorialFactorization (locallyInjective J A) where nonempty_functorialFactorizationData := ⟨functorialLocallySurjectiveInjectiveFactorization J (MorphismProperty.functorialFactorizationData _ _)⟩ end section variable {J} variable [HasSheafify J A] [J.HasSheafCompose (forget A)] [Balanced (Sheaf J A)] variable {F G : Sheaf J A} (φ : F ⟶ G) lemma isLocallySurjective_iff_epi' : IsLocallySurjective φ ↔ Epi φ := by constructor · intro infer_instance · intro let data := (locallySurjective J A).factorizationData (locallyInjective J A) φ have : IsLocallySurjective data.i := data.hi have : IsLocallyInjective data.p := data.hp have : Epi data.p := epi_of_epi_fac data.fac have := mono_of_isLocallyInjective data.p have := isIso_of_mono_of_epi data.p rw [← data.fac] infer_instance end end Sheaf end CategoryTheory
CategoryTheory\Sites\EqualizerSheafCondition.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.Sites.IsSheafFor import Mathlib.CategoryTheory.Limits.Shapes.Types import Mathlib.Tactic.ApplyFun /-! # The equalizer diagram sheaf condition for a presieve In `Mathlib/CategoryTheory/Sites/IsSheafFor.lean` it is defined what it means for a presheaf to be a sheaf *for* a particular presieve. In this file we provide equivalent conditions in terms of equalizer diagrams. * In `Equalizer.Presieve.sheaf_condition`, the sheaf condition at a presieve is shown to be equivalent to that of https://stacks.math.columbia.edu/tag/00VM (and combined with `isSheaf_pretopology`, this shows the notions of `IsSheaf` are exactly equivalent.) * In `Equalizer.Sieve.equalizer_sheaf_condition`, the sheaf condition at a sieve is shown to be equivalent to that of Equation (3) p. 122 in Maclane-Moerdijk [MM92]. ## References * [MM92]: *Sheaves in geometry and logic*, Saunders MacLane, and Ieke Moerdijk: Chapter III, Section 4. * https://stacks.math.columbia.edu/tag/00VL (sheaves on a pretopology or site) -/ universe w v u namespace CategoryTheory open Opposite CategoryTheory Category Limits Sieve namespace Equalizer variable {C : Type u} [Category.{v} C] (P : Cᵒᵖ ⥤ Type max v u) {X : C} (R : Presieve X) (S : Sieve X) noncomputable section /-- The middle object of the fork diagram given in Equation (3) of [MM92], as well as the fork diagram of <https://stacks.math.columbia.edu/tag/00VM>. -/ def FirstObj : Type max v u := ∏ᶜ fun f : ΣY, { f : Y ⟶ X // R f } => P.obj (op f.1) variable {P R} -- Porting note (#10688): added to ease automation @[ext] lemma FirstObj.ext (z₁ z₂ : FirstObj P R) (h : ∀ (Y : C) (f : Y ⟶ X) (hf : R f), (Pi.π _ ⟨Y, f, hf⟩ : FirstObj P R ⟶ _) z₁ = (Pi.π _ ⟨Y, f, hf⟩ : FirstObj P R ⟶ _) z₂) : z₁ = z₂ := by apply Limits.Types.limit_ext rintro ⟨⟨Y, f, hf⟩⟩ exact h Y f hf variable (P R) /-- Show that `FirstObj` is isomorphic to `FamilyOfElements`. -/ @[simps] def firstObjEqFamily : FirstObj P R ≅ R.FamilyOfElements P where hom t Y f hf := Pi.π (fun f : ΣY, { f : Y ⟶ X // R f } => P.obj (op f.1)) ⟨_, _, hf⟩ t inv := Pi.lift fun f x => x _ f.2.2 instance : Inhabited (FirstObj P (⊥ : Presieve X)) := (firstObjEqFamily P _).toEquiv.inhabited -- Porting note: was not needed in mathlib instance : Inhabited (FirstObj P ((⊥ : Sieve X) : Presieve X)) := (inferInstance : Inhabited (FirstObj P (⊥ : Presieve X))) /-- The left morphism of the fork diagram given in Equation (3) of [MM92], as well as the fork diagram of <https://stacks.math.columbia.edu/tag/00VM>. -/ def forkMap : P.obj (op X) ⟶ FirstObj P R := Pi.lift fun f => P.map f.2.1.op /-! This section establishes the equivalence between the sheaf condition of Equation (3) [MM92] and the definition of `IsSheafFor`. -/ namespace Sieve /-- The rightmost object of the fork diagram of Equation (3) [MM92], which contains the data used to check a family is compatible. -/ def SecondObj : Type max v u := ∏ᶜ fun f : Σ(Y Z : _) (_ : Z ⟶ Y), { f' : Y ⟶ X // S f' } => P.obj (op f.2.1) variable {P S} -- Porting note (#10688): added to ease automation @[ext] lemma SecondObj.ext (z₁ z₂ : SecondObj P S) (h : ∀ (Y Z : C) (g : Z ⟶ Y) (f : Y ⟶ X) (hf : S.arrows f), (Pi.π _ ⟨Y, Z, g, f, hf⟩ : SecondObj P S ⟶ _) z₁ = (Pi.π _ ⟨Y, Z, g, f, hf⟩ : SecondObj P S ⟶ _) z₂) : z₁ = z₂ := by apply Limits.Types.limit_ext rintro ⟨⟨Y, Z, g, f, hf⟩⟩ apply h variable (P S) /-- The map `p` of Equations (3,4) [MM92]. -/ def firstMap : FirstObj P (S : Presieve X) ⟶ SecondObj P S := Pi.lift fun fg => Pi.π _ (⟨_, _, S.downward_closed fg.2.2.2.2 fg.2.2.1⟩ : ΣY, { f : Y ⟶ X // S f }) instance : Inhabited (SecondObj P (⊥ : Sieve X)) := ⟨firstMap _ _ default⟩ /-- The map `a` of Equations (3,4) [MM92]. -/ def secondMap : FirstObj P (S : Presieve X) ⟶ SecondObj P S := Pi.lift fun fg => Pi.π _ ⟨_, fg.2.2.2⟩ ≫ P.map fg.2.2.1.op theorem w : forkMap P (S : Presieve X) ≫ firstMap P S = forkMap P S ≫ secondMap P S := by ext simp [firstMap, secondMap, forkMap] /-- The family of elements given by `x : FirstObj P S` is compatible iff `firstMap` and `secondMap` map it to the same point. -/ theorem compatible_iff (x : FirstObj P S) : ((firstObjEqFamily P S).hom x).Compatible ↔ firstMap P S x = secondMap P S x := by rw [Presieve.compatible_iff_sieveCompatible] constructor · intro t apply SecondObj.ext intros Y Z g f hf simpa [firstMap, secondMap] using t _ g hf · intro t Y Z f g hf rw [Types.limit_ext_iff'] at t simpa [firstMap, secondMap] using t ⟨⟨Y, Z, g, f, hf⟩⟩ /-- `P` is a sheaf for `S`, iff the fork given by `w` is an equalizer. -/ theorem equalizer_sheaf_condition : Presieve.IsSheafFor P (S : Presieve X) ↔ Nonempty (IsLimit (Fork.ofι _ (w P S))) := by rw [Types.type_equalizer_iff_unique, ← Equiv.forall_congr_right (firstObjEqFamily P (S : Presieve X)).toEquiv.symm] simp_rw [← compatible_iff] simp only [inv_hom_id_apply, Iso.toEquiv_symm_fun] apply forall₂_congr intro x _ apply existsUnique_congr intro t rw [← Iso.toEquiv_symm_fun] rw [Equiv.eq_symm_apply] constructor · intro q funext Y f hf simpa [firstObjEqFamily, forkMap] using q _ _ · intro q Y f hf rw [← q] simp [firstObjEqFamily, forkMap] end Sieve /-! This section establishes the equivalence between the sheaf condition of https://stacks.math.columbia.edu/tag/00VM and the definition of `isSheafFor`. -/ namespace Presieve variable [R.hasPullbacks] /-- The rightmost object of the fork diagram of https://stacks.math.columbia.edu/tag/00VM, which contains the data used to check a family of elements for a presieve is compatible. -/ @[simp] def SecondObj : Type max v u := ∏ᶜ fun fg : (ΣY, { f : Y ⟶ X // R f }) × ΣZ, { g : Z ⟶ X // R g } => haveI := Presieve.hasPullbacks.has_pullbacks fg.1.2.2 fg.2.2.2 P.obj (op (pullback fg.1.2.1 fg.2.2.1)) /-- The map `pr₀*` of <https://stacks.math.columbia.edu/tag/00VL>. -/ def firstMap : FirstObj P R ⟶ SecondObj P R := Pi.lift fun fg => haveI := Presieve.hasPullbacks.has_pullbacks fg.1.2.2 fg.2.2.2 Pi.π _ _ ≫ P.map (pullback.fst _ _).op instance [HasPullbacks C] : Inhabited (SecondObj P (⊥ : Presieve X)) := ⟨firstMap _ _ default⟩ /-- The map `pr₁*` of <https://stacks.math.columbia.edu/tag/00VL>. -/ def secondMap : FirstObj P R ⟶ SecondObj P R := Pi.lift fun fg => haveI := Presieve.hasPullbacks.has_pullbacks fg.1.2.2 fg.2.2.2 Pi.π _ _ ≫ P.map (pullback.snd _ _).op theorem w : forkMap P R ≫ firstMap P R = forkMap P R ≫ secondMap P R := by dsimp ext fg simp only [firstMap, secondMap, forkMap] simp only [limit.lift_π, limit.lift_π_assoc, assoc, Fan.mk_π_app] haveI := Presieve.hasPullbacks.has_pullbacks fg.1.2.2 fg.2.2.2 rw [← P.map_comp, ← op_comp, pullback.condition] simp /-- The family of elements given by `x : FirstObj P S` is compatible iff `firstMap` and `secondMap` map it to the same point. -/ theorem compatible_iff (x : FirstObj P R) : ((firstObjEqFamily P R).hom x).Compatible ↔ firstMap P R x = secondMap P R x := by rw [Presieve.pullbackCompatible_iff] constructor · intro t apply Limits.Types.limit_ext rintro ⟨⟨Y, f, hf⟩, Z, g, hg⟩ simpa [firstMap, secondMap] using t hf hg · intro t Y Z f g hf hg rw [Types.limit_ext_iff'] at t simpa [firstMap, secondMap] using t ⟨⟨⟨Y, f, hf⟩, Z, g, hg⟩⟩ /-- `P` is a sheaf for `R`, iff the fork given by `w` is an equalizer. See <https://stacks.math.columbia.edu/tag/00VM>. -/ theorem sheaf_condition : R.IsSheafFor P ↔ Nonempty (IsLimit (Fork.ofι _ (w P R))) := by rw [Types.type_equalizer_iff_unique] erw [← Equiv.forall_congr_right (firstObjEqFamily P R).toEquiv.symm] simp_rw [← compatible_iff, ← Iso.toEquiv_fun, Equiv.apply_symm_apply] apply forall₂_congr intro x _ apply existsUnique_congr intro t rw [Equiv.eq_symm_apply] constructor · intro q funext Y f hf simpa [forkMap] using q _ _ · intro q Y f hf rw [← q] simp [forkMap] namespace Arrows variable (P : Cᵒᵖ ⥤ Type w) {X : C} (R : Presieve X) (S : Sieve X) open Presieve variable {B : C} {I : Type} (X : I → C) (π : (i : I) → X i ⟶ B) [(Presieve.ofArrows X π).hasPullbacks] -- TODO: allow `I : Type w`  /-- The middle object of the fork diagram of <https://stacks.math.columbia.edu/tag/00VM>. The difference between this and `Equalizer.FirstObj P (ofArrows X π)` arrises if the family of arrows `π` contains duplicates. The `Presieve.ofArrows` doesn't see those. -/ def FirstObj : Type w := ∏ᶜ (fun i ↦ P.obj (op (X i))) @[ext] lemma FirstObj.ext (z₁ z₂ : FirstObj P X) (h : ∀ i, (Pi.π _ i : FirstObj P X ⟶ _) z₁ = (Pi.π _ i : FirstObj P X ⟶ _) z₂) : z₁ = z₂ := by apply Limits.Types.limit_ext rintro ⟨i⟩ exact h i /-- The rightmost object of the fork diagram of https://stacks.math.columbia.edu/tag/00VM. The difference between this and `Equalizer.Presieve.SecondObj P (ofArrows X π)` arrises if the family of arrows `π` contains duplicates. The `Presieve.ofArrows` doesn't see those. -/ def SecondObj : Type w := ∏ᶜ (fun (ij : I × I) ↦ P.obj (op (pullback (π ij.1) (π ij.2)))) @[ext] lemma SecondObj.ext (z₁ z₂ : SecondObj P X π) (h : ∀ ij, (Pi.π _ ij : SecondObj P X π ⟶ _) z₁ = (Pi.π _ ij : SecondObj P X π ⟶ _) z₂) : z₁ = z₂ := by apply Limits.Types.limit_ext rintro ⟨i⟩ exact h i /-- The left morphism of the fork diagram. -/ def forkMap : P.obj (op B) ⟶ FirstObj P X := Pi.lift (fun i ↦ P.map (π i).op) /-- The first of the two parallel morphisms of the fork diagram, induced by the first projection in each pullback. -/ def firstMap : FirstObj P X ⟶ SecondObj P X π := Pi.lift fun _ => Pi.π _ _ ≫ P.map (pullback.fst _ _).op /-- The second of the two parallel morphisms of the fork diagram, induced by the second projection in each pullback. -/ def secondMap : FirstObj P X ⟶ SecondObj P X π := Pi.lift fun _ => Pi.π _ _ ≫ P.map (pullback.snd _ _).op theorem w : forkMap P X π ≫ firstMap P X π = forkMap P X π ≫ secondMap P X π := by ext x ij simp only [firstMap, secondMap, forkMap, types_comp_apply, Types.pi_lift_π_apply, ← FunctorToTypes.map_comp_apply, ← op_comp, pullback.condition] /-- The family of elements given by `x : FirstObj P S` is compatible iff `firstMap` and `secondMap` map it to the same point. -/ theorem compatible_iff (x : FirstObj P X) : (Arrows.Compatible P π ((Types.productIso _).hom x)) ↔ firstMap P X π x = secondMap P X π x := by rw [Arrows.pullbackCompatible_iff] constructor · intro t ext ij simpa [firstMap, secondMap] using t ij.1 ij.2 · intro t i j apply_fun Pi.π (fun (ij : I × I) ↦ P.obj (op (pullback (π ij.1) (π ij.2)))) ⟨i, j⟩ at t simpa [firstMap, secondMap] using t /-- `P` is a sheaf for `Presieve.ofArrows X π`, iff the fork given by `w` is an equalizer. See <https://stacks.math.columbia.edu/tag/00VM>. -/ theorem sheaf_condition : (Presieve.ofArrows X π).IsSheafFor P ↔ Nonempty (IsLimit (Fork.ofι (forkMap P X π) (w P X π))) := by rw [Types.type_equalizer_iff_unique, isSheafFor_arrows_iff] erw [← Equiv.forall_congr_right (Types.productIso _).toEquiv.symm] simp_rw [← compatible_iff, ← Iso.toEquiv_fun, Equiv.apply_symm_apply] apply forall₂_congr intro x _ apply existsUnique_congr intro t erw [Equiv.eq_symm_apply] constructor · intro q funext i simpa [forkMap] using q i · intro q i rw [← q] simp [forkMap] end Arrows end Presieve end end Equalizer end CategoryTheory
CategoryTheory\Sites\Equivalence.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.Sites.InducedTopology import Mathlib.CategoryTheory.Sites.LocallyBijective import Mathlib.CategoryTheory.Sites.PreservesLocallyBijective import Mathlib.CategoryTheory.Sites.Whiskering /-! # Equivalences of sheaf categories Given a site `(C, J)` and a category `D` which is equivalent to `C`, with `C` and `D` possibly large and possibly in different universes, we transport the Grothendieck topology `J` on `C` to `D` and prove that the sheaf categories are equivalent. We also prove that sheafification and the property `HasSheafCompose` transport nicely over this equivalence, and apply it to essentially small sites. We also provide instances for existence of sufficiently small limits in the sheaf category on the essentially small site. ## Main definitions * `CategoryTheory.Equivalence.sheafCongr` is the equivalence of sheaf categories. * `CategoryTheory.Equivalence.transportAndSheafify` is the functor which takes a presheaf on `C`, transports it over the equivalence to `D`, sheafifies there and then transports back to `C`. * `CategoryTheory.Equivalence.transportSheafificationAdjunction`: `transportAndSheafify` is left adjoint to the functor taking a sheaf to its underlying presheaf. * `CategoryTheory.smallSheafify` is the functor which takes a presheaf on an essentially small site `(C, J)`, transports to a small model, sheafifies there and then transports back to `C`. * `CategoryTheory.smallSheafificationAdjunction`: `smallSheafify` is left adjoint to the functor taking a sheaf to its underlying presheaf. -/ universe v₁ v₂ v₃ v₄ u₁ u₂ u₃ u₄ w namespace CategoryTheory open Functor Limits GrothendieckTopology variable {C : Type u₁} [Category.{v₁} C] (J : GrothendieckTopology C) variable {D : Type u₂} [Category.{v₂} D] (K : GrothendieckTopology D) (e : C ≌ D) (G : D ⥤ C) variable (A : Type u₃) [Category.{v₃} A] namespace Equivalence instance (priority := 900) [G.IsEquivalence] : IsCoverDense G J where is_cover U := by let e := (asEquivalence G).symm convert J.top_mem U ext Y f simp only [Sieve.functorPushforward_apply, Presieve.functorPushforward, exists_and_left, Sieve.top_apply, iff_true] let g : e.inverse.obj _ ⟶ U := (e.unitInv.app Y) ≫ f have : (Sieve.coverByImage e.inverse U).arrows g := Presieve.in_coverByImage _ g replace := Sieve.downward_closed _ this (e.unit.app Y) simpa [g] using this instance : e.functor.IsDenseSubsite J (e.inverse.inducedTopology J) := by have : J = e.functor.inducedTopology (e.inverse.inducedTopology J) := by ext X S erw [← GrothendieckTopology.pullback_mem_iff_of_isIso (i := e.unit.app X)] congr!; ext Y f; simp nth_rw 1 [this] infer_instance lemma eq_inducedTopology_of_isDenseSubsite [e.inverse.IsDenseSubsite K J] : K = e.inverse.inducedTopology J := by ext simp [e.inverse.functorPushforward_mem_iff K J] variable [e.inverse.IsDenseSubsite K J] instance : e.functor.IsDenseSubsite J K := by rw [e.eq_inducedTopology_of_isDenseSubsite J K] infer_instance /-- The functor in the equivalence of sheaf categories. -/ @[simps!] def sheafCongr.functor : Sheaf J A ⥤ Sheaf K A where obj F := ⟨e.inverse.op ⋙ F.val, e.inverse.op_comp_isSheaf _ _ _⟩ map f := ⟨whiskerLeft e.inverse.op f.val⟩ /-- The inverse in the equivalence of sheaf categories. -/ @[simps!] def sheafCongr.inverse : Sheaf K A ⥤ Sheaf J A where obj F := ⟨e.functor.op ⋙ F.val, e.functor.op_comp_isSheaf _ _ _⟩ map f := ⟨whiskerLeft e.functor.op f.val⟩ /-- The unit iso in the equivalence of sheaf categories. -/ @[simps!] def sheafCongr.unitIso : 𝟭 (Sheaf J A) ≅ functor J K e A ⋙ inverse J K e A := NatIso.ofComponents (fun F ↦ ⟨⟨(isoWhiskerRight e.op.unitIso F.val).hom⟩, ⟨(isoWhiskerRight e.op.unitIso F.val).inv⟩, Sheaf.hom_ext _ _ (isoWhiskerRight e.op.unitIso F.val).hom_inv_id, Sheaf.hom_ext _ _ (isoWhiskerRight e.op.unitIso F.val).inv_hom_id⟩ ) (by aesop) /-- The counit iso in the equivalence of sheaf categories. -/ @[simps!] def sheafCongr.counitIso : inverse J K e A ⋙ functor J K e A ≅ 𝟭 (Sheaf _ A) := NatIso.ofComponents (fun F ↦ ⟨⟨(isoWhiskerRight e.op.counitIso F.val).hom⟩, ⟨(isoWhiskerRight e.op.counitIso F.val).inv⟩, Sheaf.hom_ext _ _ (isoWhiskerRight e.op.counitIso F.val).hom_inv_id, Sheaf.hom_ext _ _ (isoWhiskerRight e.op.counitIso F.val).inv_hom_id⟩ ) (by aesop) /-- The equivalence of sheaf categories. -/ def sheafCongr : Sheaf J A ≌ Sheaf K A where functor := sheafCongr.functor J K e A inverse := sheafCongr.inverse J K e A unitIso := sheafCongr.unitIso J K e A counitIso := sheafCongr.counitIso J K e A functor_unitIso_comp X := by ext simp only [id_obj, sheafCongr.functor_obj_val_obj, comp_obj, Sheaf.instCategorySheaf_comp_val, NatTrans.comp_app, sheafCongr.inverse_obj_val_obj, Opposite.unop_op, sheafCongr.functor_map_val_app, sheafCongr.unitIso_hom_app_val_app, sheafCongr.counitIso_hom_app_val_app, sheafCongr.functor_obj_val_map, Quiver.Hom.unop_op, Sheaf.instCategorySheaf_id_val, NatTrans.id_app] simp [← Functor.map_comp, ← op_comp] variable [HasSheafify K A] /-- Transport a presheaf to the equivalent category and sheafify there. -/ noncomputable def transportAndSheafify : (Cᵒᵖ ⥤ A) ⥤ Sheaf J A := e.op.congrLeft.functor ⋙ presheafToSheaf _ _ ⋙ (e.sheafCongr J K A).inverse /-- An auxiliary definition for the sheafification adjunction. -/ noncomputable def transportIsoSheafToPresheaf : (e.sheafCongr J K A).functor ⋙ sheafToPresheaf K A ⋙ e.op.congrLeft.inverse ≅ sheafToPresheaf J A := NatIso.ofComponents (fun F ↦ isoWhiskerRight e.op.unitIso.symm F.val) (by intros; ext; simp [Equivalence.sheafCongr]) /-- Transporting and sheafifying is left adjoint to taking the underlying presheaf. -/ noncomputable def transportSheafificationAdjunction : transportAndSheafify J K e A ⊣ sheafToPresheaf J A := ((e.op.congrLeft.toAdjunction.comp (sheafificationAdjunction _ _)).comp (e.sheafCongr J K A).symm.toAdjunction).ofNatIsoRight (transportIsoSheafToPresheaf _ _ _ _) noncomputable instance : PreservesFiniteLimits <| transportAndSheafify J K e A where preservesFiniteLimits _ := compPreservesLimitsOfShape _ _ /-- Transport `HasSheafify` along an equivalence of sites. -/ theorem hasSheafify : HasSheafify J A := HasSheafify.mk' J A (transportSheafificationAdjunction J K e A) variable {A : Type*} [Category A] {B : Type*} [Category B] (F : A ⥤ B) [K.HasSheafCompose F] theorem hasSheafCompose : J.HasSheafCompose F where isSheaf P hP := by have hP' : Presheaf.IsSheaf K (e.inverse.op ⋙ P ⋙ F) := by change Presheaf.IsSheaf K ((_ ⋙ _) ⋙ _) apply HasSheafCompose.isSheaf exact e.inverse.op_comp_isSheaf K J ⟨P, hP⟩ replace hP' : Presheaf.IsSheaf J (e.functor.op ⋙ e.inverse.op ⋙ P ⋙ F) := e.functor.op_comp_isSheaf _ _ ⟨_, hP'⟩ exact (Presheaf.isSheaf_of_iso_iff ((isoWhiskerRight e.op.unitIso.symm (P ⋙ F)))).mp hP' variable [ConcreteCategory.{w} A] variable {F G : Cᵒᵖ ⥤ A} (f : F ⟶ G) end Equivalence variable [EssentiallySmall.{w} C] variable (B : Type u₄) [Category.{v₄} B] (F : A ⥤ B) variable [HasSheafify ((equivSmallModel C).inverse.inducedTopology J) A] variable [((equivSmallModel C).inverse.inducedTopology J).HasSheafCompose F] /-- Transport to a small model and sheafify there. -/ noncomputable def smallSheafify : (Cᵒᵖ ⥤ A) ⥤ Sheaf J A := (equivSmallModel C).transportAndSheafify J ((equivSmallModel C).inverse.inducedTopology J) A /-- Transporting to a small model and sheafifying there is left adjoint to the underlying presheaf functor -/ noncomputable def smallSheafificationAdjunction : smallSheafify J A ⊣ sheafToPresheaf J A := (equivSmallModel C).transportSheafificationAdjunction J _ A noncomputable instance hasSheafifyEssentiallySmallSite : HasSheafify J A := (equivSmallModel C).hasSheafify J ((equivSmallModel C).inverse.inducedTopology J) A instance hasSheafComposeEssentiallySmallSite : HasSheafCompose J F := (equivSmallModel C).hasSheafCompose J ((equivSmallModel C).inverse.inducedTopology J) F instance hasLimitsEssentiallySmallSite [HasLimits <| Sheaf ((equivSmallModel C).inverse.inducedTopology J) A] : HasLimitsOfSize.{max v₃ w, max v₃ w} <| Sheaf J A := Adjunction.has_limits_of_equivalence ((equivSmallModel C).sheafCongr J ((equivSmallModel C).inverse.inducedTopology J) A).functor instance hasColimitsEssentiallySmallSite [HasColimits <| Sheaf ((equivSmallModel C).inverse.inducedTopology J) A] : HasColimitsOfSize.{max v₃ w, max v₃ w} <| Sheaf J A := Adjunction.has_colimits_of_equivalence ((equivSmallModel C).sheafCongr J ((equivSmallModel C).inverse.inducedTopology J) A).functor namespace GrothendieckTopology variable {A} variable [G.IsCoverDense J] [Functor.IsContinuous.{v₃} G K J] [G.Full] [(G.sheafPushforwardContinuous A K J).EssSurj] open Localization lemma W_inverseImage_whiskeringLeft : K.W.inverseImage ((whiskeringLeft Dᵒᵖ Cᵒᵖ A).obj G.op) = J.W := by ext P Q f have h₁ : K.W (A := A) = Localization.LeftBousfield.W (· ∈ Set.range (sheafToPresheaf J A ⋙ ((whiskeringLeft Dᵒᵖ Cᵒᵖ A).obj G.op)).obj) := by rw [W_eq_W_range_sheafToPresheaf_obj, ← LeftBousfield.W_isoClosure] conv_rhs => rw [← LeftBousfield.W_isoClosure] apply congr_arg ext P constructor · rintro ⟨_, ⟨R, rfl⟩, ⟨e⟩⟩ exact ⟨_, ⟨_, rfl⟩, ⟨e.trans ((sheafToPresheaf _ _).mapIso ((G.sheafPushforwardContinuous A K J).objObjPreimageIso R).symm)⟩⟩ · rintro ⟨_, ⟨R, rfl⟩, ⟨e⟩⟩ exact ⟨G.op ⋙ R.val, ⟨(G.sheafPushforwardContinuous A K J).obj R, rfl⟩, ⟨e⟩⟩ have h₂ : ∀ (R : Sheaf J A), Function.Bijective (fun (g : G.op ⋙ Q ⟶ G.op ⋙ R.val) ↦ whiskerLeft G.op f ≫ g) ↔ Function.Bijective (fun (g : Q ⟶ R.val) ↦ f ≫ g) := fun R ↦ by rw [← Function.Bijective.of_comp_iff _ (Functor.whiskerLeft_obj_map_bijective_of_isCoverDense J G Q R.val R.cond)] exact Function.Bijective.of_comp_iff' (Functor.whiskerLeft_obj_map_bijective_of_isCoverDense J G P R.val R.cond) (fun g ↦ f ≫ g) rw [h₁, J.W_eq_W_range_sheafToPresheaf_obj, MorphismProperty.inverseImage_iff] constructor · rintro h _ ⟨R, rfl⟩ exact (h₂ R).1 (h _ ⟨R, rfl⟩) · rintro h _ ⟨R, rfl⟩ exact (h₂ R).2 (h _ ⟨R, rfl⟩) lemma W_whiskerLeft_iff {P Q : Cᵒᵖ ⥤ A} (f : P ⟶ Q) : K.W (whiskerLeft G.op f) ↔ J.W f := by rw [← W_inverseImage_whiskeringLeft J K G] rfl variable [Functor.IsContinuous.{v₄} G K J] [Functor.IsContinuous.{v₃} G K J] lemma PreservesSheafification.transport [(G.sheafPushforwardContinuous B K J).EssSurj] [K.PreservesSheafification F] : J.PreservesSheafification F where le P Q f hf := by rw [← J.W_whiskerLeft_iff (G := G) (K := K)] at hf have := K.W_of_preservesSheafification F (whiskerLeft G.op f) hf rwa [whiskerRight_left, K.W_whiskerLeft_iff (G := G) (J := J) (f := whiskerRight f F)] at this variable [G.IsCocontinuous K J] (hG : CoverPreserving K J G) [ConcreteCategory A] [K.WEqualsLocallyBijective A] lemma WEqualsLocallyBijective.transport : J.WEqualsLocallyBijective A where iff f := by rw [← W_whiskerLeft_iff J K G f, ← Presheaf.isLocallyInjective_whisker_iff K J G f hG, ← Presheaf.isLocallySurjective_whisker_iff K J G f hG, W_iff_isLocallyBijective] variable [∀ (X : Cᵒᵖ), HasLimitsOfShape (StructuredArrow X (equivSmallModel C).inverse.op) A] instance [((equivSmallModel C).inverse.inducedTopology J).WEqualsLocallyBijective A] : J.WEqualsLocallyBijective A := WEqualsLocallyBijective.transport J ((equivSmallModel C).inverse.inducedTopology J) (equivSmallModel C).inverse (IsDenseSubsite.coverPreserving _ _ _) variable [∀ (X : Cᵒᵖ), HasLimitsOfShape (StructuredArrow X (equivSmallModel C).inverse.op) B] variable [PreservesSheafification ((equivSmallModel C).inverse.inducedTopology J) F] instance : PreservesSheafification J F := PreservesSheafification.transport (A := A) J ((equivSmallModel C).inverse.inducedTopology J) (equivSmallModel C).inverse B F end GrothendieckTopology end CategoryTheory
CategoryTheory\Sites\Grothendieck.lean
/- Copyright (c) 2020 Bhavik Mehta, E. W. Ayers. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Bhavik Mehta, E. W. Ayers -/ import Mathlib.CategoryTheory.Sites.Sieves import Mathlib.CategoryTheory.Limits.Shapes.Multiequalizer import Mathlib.CategoryTheory.Category.Preorder import Mathlib.Order.Copy import Mathlib.Data.Set.Subsingleton /-! # Grothendieck topologies Definition and lemmas about Grothendieck topologies. A Grothendieck topology for a category `C` is a set of sieves on each object `X` satisfying certain closure conditions. Alternate versions of the axioms (in arrow form) are also described. Two explicit examples of Grothendieck topologies are given: * The dense topology * The atomic topology as well as the complete lattice structure on Grothendieck topologies (which gives two additional explicit topologies: the discrete and trivial topologies.) A pretopology, or a basis for a topology is defined in `Mathlib/CategoryTheory/Sites/Pretopology.lean`. The topology associated to a topological space is defined in `Mathlib/CategoryTheory/Sites/Spaces.lean`. ## Tags Grothendieck topology, coverage, pretopology, site ## References * [nLab, *Grothendieck topology*](https://ncatlab.org/nlab/show/Grothendieck+topology) * [S. MacLane, I. Moerdijk, *Sheaves in Geometry and Logic*][MM92] ## Implementation notes We use the definition of [nlab] and [MM92][] (Chapter III, Section 2), where Grothendieck topologies are saturated collections of morphisms, rather than the notions of the Stacks project (00VG) and the Elephant, in which topologies are allowed to be unsaturated, and are then completed. TODO (BM): Add the definition from Stacks, as a pretopology, and complete to a topology. This is so that we can produce a bijective correspondence between Grothendieck topologies on a small category and Lawvere-Tierney topologies on its presheaf topos, as well as the equivalence between Grothendieck topoi and left exact reflective subcategories of presheaf toposes. -/ universe v₁ u₁ v u namespace CategoryTheory open CategoryTheory Category variable (C : Type u) [Category.{v} C] /-- The definition of a Grothendieck topology: a set of sieves `J X` on each object `X` satisfying three axioms: 1. For every object `X`, the maximal sieve is in `J X`. 2. If `S ∈ J X` then its pullback along any `h : Y ⟶ X` is in `J Y`. 3. If `S ∈ J X` and `R` is a sieve on `X`, then provided that the pullback of `R` along any arrow `f : Y ⟶ X` in `S` is in `J Y`, we have that `R` itself is in `J X`. A sieve `S` on `X` is referred to as `J`-covering, (or just covering), if `S ∈ J X`. See <https://stacks.math.columbia.edu/tag/00Z4>, or [nlab], or [MM92][] Chapter III, Section 2, Definition 1. -/ structure GrothendieckTopology where /-- A Grothendieck topology on `C` consists of a set of sieves for each object `X`, which satisfy some axioms. -/ sieves : ∀ X : C, Set (Sieve X) /-- The sieves associated to each object must contain the top sieve. Use `GrothendieckTopology.top_mem`. -/ top_mem' : ∀ X, ⊤ ∈ sieves X /-- Stability under pullback. Use `GrothendieckTopology.pullback_stable`. -/ pullback_stable' : ∀ ⦃X Y : C⦄ ⦃S : Sieve X⦄ (f : Y ⟶ X), S ∈ sieves X → S.pullback f ∈ sieves Y /-- Transitivity of sieves in a Grothendieck topology. Use `GrothendieckTopology.transitive`. -/ transitive' : ∀ ⦃X⦄ ⦃S : Sieve X⦄ (_ : S ∈ sieves X) (R : Sieve X), (∀ ⦃Y⦄ ⦃f : Y ⟶ X⦄, S f → R.pullback f ∈ sieves Y) → R ∈ sieves X namespace GrothendieckTopology instance : CoeFun (GrothendieckTopology C) fun _ => ∀ X : C, Set (Sieve X) := ⟨sieves⟩ variable {C} variable {X Y : C} {S R : Sieve X} variable (J : GrothendieckTopology C) /-- An extensionality lemma in terms of the coercion to a pi-type. We prove this explicitly rather than deriving it so that it is in terms of the coercion rather than the projection `.sieves`. -/ @[ext] theorem ext {J₁ J₂ : GrothendieckTopology C} (h : (J₁ : ∀ X : C, Set (Sieve X)) = J₂) : J₁ = J₂ := by cases J₁ cases J₂ congr /- Porting note: This is now a syntactic tautology. @[simp] theorem mem_sieves_iff_coe : S ∈ J.sieves X ↔ S ∈ J X := Iff.rfl -/ /-- Also known as the maximality axiom. -/ @[simp] theorem top_mem (X : C) : ⊤ ∈ J X := J.top_mem' X /-- Also known as the stability axiom. -/ @[simp] theorem pullback_stable (f : Y ⟶ X) (hS : S ∈ J X) : S.pullback f ∈ J Y := J.pullback_stable' f hS variable {J} in @[simp] lemma pullback_mem_iff_of_isIso {i : X ⟶ Y} [IsIso i] {S : Sieve Y} : S.pullback i ∈ J _ ↔ S ∈ J _ := by refine ⟨fun H ↦ ?_, J.pullback_stable i⟩ convert J.pullback_stable (inv i) H rw [← Sieve.pullback_comp, IsIso.inv_hom_id, Sieve.pullback_id] theorem transitive (hS : S ∈ J X) (R : Sieve X) (h : ∀ ⦃Y⦄ ⦃f : Y ⟶ X⦄, S f → R.pullback f ∈ J Y) : R ∈ J X := J.transitive' hS R h theorem covering_of_eq_top : S = ⊤ → S ∈ J X := fun h => h.symm ▸ J.top_mem X /-- If `S` is a subset of `R`, and `S` is covering, then `R` is covering as well. See <https://stacks.math.columbia.edu/tag/00Z5> (2), or discussion after [MM92] Chapter III, Section 2, Definition 1. -/ theorem superset_covering (Hss : S ≤ R) (sjx : S ∈ J X) : R ∈ J X := by apply J.transitive sjx R fun Y f hf => _ intros Y f hf apply covering_of_eq_top rw [← top_le_iff, ← S.pullback_eq_top_of_mem hf] apply Sieve.pullback_monotone _ Hss /-- The intersection of two covering sieves is covering. See <https://stacks.math.columbia.edu/tag/00Z5> (1), or [MM92] Chapter III, Section 2, Definition 1 (iv). -/ theorem intersection_covering (rj : R ∈ J X) (sj : S ∈ J X) : R ⊓ S ∈ J X := by apply J.transitive rj _ fun Y f Hf => _ intros Y f hf rw [Sieve.pullback_inter, R.pullback_eq_top_of_mem hf] simp [sj] @[simp] theorem intersection_covering_iff : R ⊓ S ∈ J X ↔ R ∈ J X ∧ S ∈ J X := ⟨fun h => ⟨J.superset_covering inf_le_left h, J.superset_covering inf_le_right h⟩, fun t => intersection_covering _ t.1 t.2⟩ theorem bind_covering {S : Sieve X} {R : ∀ ⦃Y : C⦄ ⦃f : Y ⟶ X⦄, S f → Sieve Y} (hS : S ∈ J X) (hR : ∀ ⦃Y⦄ ⦃f : Y ⟶ X⦄ (H : S f), R H ∈ J Y) : Sieve.bind S R ∈ J X := J.transitive hS _ fun _ f hf => superset_covering J (Sieve.le_pullback_bind S R f hf) (hR hf) /-- The sieve `S` on `X` `J`-covers an arrow `f` to `X` if `S.pullback f ∈ J Y`. This definition is an alternate way of presenting a Grothendieck topology. -/ def Covers (S : Sieve X) (f : Y ⟶ X) : Prop := S.pullback f ∈ J Y theorem covers_iff (S : Sieve X) (f : Y ⟶ X) : J.Covers S f ↔ S.pullback f ∈ J Y := Iff.rfl theorem covering_iff_covers_id (S : Sieve X) : S ∈ J X ↔ J.Covers S (𝟙 X) := by simp [covers_iff] /-- The maximality axiom in 'arrow' form: Any arrow `f` in `S` is covered by `S`. -/ theorem arrow_max (f : Y ⟶ X) (S : Sieve X) (hf : S f) : J.Covers S f := by rw [Covers, (Sieve.pullback_eq_top_iff_mem f).1 hf] apply J.top_mem /-- The stability axiom in 'arrow' form: If `S` covers `f` then `S` covers `g ≫ f` for any `g`. -/ theorem arrow_stable (f : Y ⟶ X) (S : Sieve X) (h : J.Covers S f) {Z : C} (g : Z ⟶ Y) : J.Covers S (g ≫ f) := by rw [covers_iff] at h ⊢ simp [h, Sieve.pullback_comp] /-- The transitivity axiom in 'arrow' form: If `S` covers `f` and every arrow in `S` is covered by `R`, then `R` covers `f`. -/ theorem arrow_trans (f : Y ⟶ X) (S R : Sieve X) (h : J.Covers S f) : (∀ {Z : C} (g : Z ⟶ X), S g → J.Covers R g) → J.Covers R f := by intro k apply J.transitive h intro Z g hg rw [← Sieve.pullback_comp] apply k (g ≫ f) hg theorem arrow_intersect (f : Y ⟶ X) (S R : Sieve X) (hS : J.Covers S f) (hR : J.Covers R f) : J.Covers (S ⊓ R) f := by simpa [covers_iff] using And.intro hS hR variable (C) /-- The trivial Grothendieck topology, in which only the maximal sieve is covering. This topology is also known as the indiscrete, coarse, or chaotic topology. See [MM92] Chapter III, Section 2, example (a), or https://en.wikipedia.org/wiki/Grothendieck_topology#The_discrete_and_indiscrete_topologies -/ def trivial : GrothendieckTopology C where sieves X := {⊤} top_mem' X := rfl pullback_stable' X Y S f hf := by rw [Set.mem_singleton_iff] at hf ⊢ simp [hf] transitive' X S hS R hR := by rw [Set.mem_singleton_iff, ← Sieve.id_mem_iff_eq_top] at hS simpa using hR hS /-- The discrete Grothendieck topology, in which every sieve is covering. See https://en.wikipedia.org/wiki/Grothendieck_topology#The_discrete_and_indiscrete_topologies. -/ def discrete : GrothendieckTopology C where sieves X := Set.univ top_mem' := by simp pullback_stable' X Y f := by simp transitive' := by simp variable {C} theorem trivial_covering : S ∈ trivial C X ↔ S = ⊤ := Set.mem_singleton_iff /-- See <https://stacks.math.columbia.edu/tag/00Z6> -/ instance instLEGrothendieckTopology : LE (GrothendieckTopology C) where le J₁ J₂ := (J₁ : ∀ X : C, Set (Sieve X)) ≤ (J₂ : ∀ X : C, Set (Sieve X)) theorem le_def {J₁ J₂ : GrothendieckTopology C} : J₁ ≤ J₂ ↔ (J₁ : ∀ X : C, Set (Sieve X)) ≤ J₂ := Iff.rfl /-- See <https://stacks.math.columbia.edu/tag/00Z6> -/ instance : PartialOrder (GrothendieckTopology C) := { instLEGrothendieckTopology with le_refl := fun J₁ => le_def.mpr le_rfl le_trans := fun J₁ J₂ J₃ h₁₂ h₂₃ => le_def.mpr (le_trans h₁₂ h₂₃) le_antisymm := fun J₁ J₂ h₁₂ h₂₁ => GrothendieckTopology.ext (le_antisymm h₁₂ h₂₁) } /-- See <https://stacks.math.columbia.edu/tag/00Z7> -/ instance : InfSet (GrothendieckTopology C) where sInf T := { sieves := sInf (sieves '' T) top_mem' := by rintro X S ⟨⟨_, J, hJ, rfl⟩, rfl⟩ simp pullback_stable' := by rintro X Y S hS f _ ⟨⟨_, J, hJ, rfl⟩, rfl⟩ apply J.pullback_stable _ (f _ ⟨⟨_, _, hJ, rfl⟩, rfl⟩) transitive' := by rintro X S hS R h _ ⟨⟨_, J, hJ, rfl⟩, rfl⟩ apply J.transitive (hS _ ⟨⟨_, _, hJ, rfl⟩, rfl⟩) _ fun Y f hf => h hf _ ⟨⟨_, _, hJ, rfl⟩, rfl⟩ } /-- See <https://stacks.math.columbia.edu/tag/00Z7> -/ theorem isGLB_sInf (s : Set (GrothendieckTopology C)) : IsGLB s (sInf s) := by refine @IsGLB.of_image _ _ _ _ sieves ?_ _ _ ?_ · rfl · exact _root_.isGLB_sInf _ /-- Construct a complete lattice from the `Inf`, but make the trivial and discrete topologies definitionally equal to the bottom and top respectively. -/ instance : CompleteLattice (GrothendieckTopology C) := CompleteLattice.copy (completeLatticeOfInf _ isGLB_sInf) _ rfl (discrete C) (by apply le_antisymm · exact @CompleteLattice.le_top _ (completeLatticeOfInf _ isGLB_sInf) (discrete C) · intro X S _ apply Set.mem_univ) (trivial C) (by apply le_antisymm · intro X S hS rw [trivial_covering] at hS apply covering_of_eq_top _ hS · exact @CompleteLattice.bot_le _ (completeLatticeOfInf _ isGLB_sInf) (trivial C)) _ rfl _ rfl _ rfl sInf rfl instance : Inhabited (GrothendieckTopology C) := ⟨⊤⟩ @[simp] theorem trivial_eq_bot : trivial C = ⊥ := rfl @[simp] theorem discrete_eq_top : discrete C = ⊤ := rfl @[simp] theorem bot_covering : S ∈ (⊥ : GrothendieckTopology C) X ↔ S = ⊤ := trivial_covering @[simp] theorem top_covering : S ∈ (⊤ : GrothendieckTopology C) X := ⟨⟩ theorem bot_covers (S : Sieve X) (f : Y ⟶ X) : (⊥ : GrothendieckTopology C).Covers S f ↔ S f := by rw [covers_iff, bot_covering, ← Sieve.pullback_eq_top_iff_mem] @[simp] theorem top_covers (S : Sieve X) (f : Y ⟶ X) : (⊤ : GrothendieckTopology C).Covers S f := by simp [covers_iff] /-- The dense Grothendieck topology. See https://ncatlab.org/nlab/show/dense+topology, or [MM92] Chapter III, Section 2, example (e). -/ def dense : GrothendieckTopology C where sieves X S := ∀ {Y : C} (f : Y ⟶ X), ∃ (Z : _) (g : Z ⟶ Y), S (g ≫ f) top_mem' X Y f := ⟨Y, 𝟙 Y, ⟨⟩⟩ pullback_stable' := by intro X Y S h H Z f rcases H (f ≫ h) with ⟨W, g, H'⟩ exact ⟨W, g, by simpa⟩ transitive' := by intro X S H₁ R H₂ Y f rcases H₁ f with ⟨Z, g, H₃⟩ rcases H₂ H₃ (𝟙 Z) with ⟨W, h, H₄⟩ exact ⟨W, h ≫ g, by simpa using H₄⟩ theorem dense_covering : S ∈ dense X ↔ ∀ {Y} (f : Y ⟶ X), ∃ (Z : _) (g : Z ⟶ Y), S (g ≫ f) := Iff.rfl /-- A category satisfies the right Ore condition if any span can be completed to a commutative square. NB. Any category with pullbacks obviously satisfies the right Ore condition, see `right_ore_of_pullbacks`. -/ def RightOreCondition (C : Type u) [Category.{v} C] : Prop := ∀ {X Y Z : C} (yx : Y ⟶ X) (zx : Z ⟶ X), ∃ (W : _) (wy : W ⟶ Y) (wz : W ⟶ Z), wy ≫ yx = wz ≫ zx theorem right_ore_of_pullbacks [Limits.HasPullbacks C] : RightOreCondition C := fun _ _ => ⟨_, _, _, Limits.pullback.condition⟩ /-- The atomic Grothendieck topology: a sieve is covering iff it is nonempty. For the pullback stability condition, we need the right Ore condition to hold. See https://ncatlab.org/nlab/show/atomic+site, or [MM92] Chapter III, Section 2, example (f). -/ def atomic (hro : RightOreCondition C) : GrothendieckTopology C where sieves X S := ∃ (Y : _) (f : Y ⟶ X), S f top_mem' X := ⟨_, 𝟙 _, ⟨⟩⟩ pullback_stable' := by rintro X Y S h ⟨Z, f, hf⟩ rcases hro h f with ⟨W, g, k, comm⟩ refine ⟨_, g, ?_⟩ simp [comm, hf] transitive' := by rintro X S ⟨Y, f, hf⟩ R h rcases h hf with ⟨Z, g, hg⟩ exact ⟨_, _, hg⟩ /-- `J.Cover X` denotes the poset of covers of `X` with respect to the Grothendieck topology `J`. -/ -- Porting note: Lean 3 inferred `Type max u v`, Lean 4 by default gives `Type (max 0 u v)` def Cover (X : C) : Type max u v := { S : Sieve X // S ∈ J X } -- deriving Preorder -- Porting note: `deriving` didn't work above, so we add the preorder instance manually. instance (X : C) : Preorder (J.Cover X) := show Preorder {S : Sieve X // S ∈ J X} from inferInstance namespace Cover variable {J} /- Porting note: Lean complains that this is a dangerous instance. I'm commenting this out since the `CoeFun` instance below is what we use 99% of the time anyway. instance : Coe (J.Cover X) (Sieve X) := ⟨fun S => S.1⟩ -/ /- Porting note (#11445): Added this def as a replacement for the "dangerous" `Coe` above. -/ /-- The sieve associated to a term of `J.Cover X`. -/ def sieve (S : J.Cover X) : Sieve X := S.1 /- Porting note: This somehow yields different behavior than the better instance below. Why?! With this instance, we have to write `S _ f` but with the uncommented one, we can write `S f` as expected. instance : CoeFun (J.Cover X) fun _ => ∀ ⦃Y⦄ (_ : Y ⟶ X), Prop := ⟨fun S _ f => (S : Sieve X) f⟩ -/ instance : CoeFun (J.Cover X) fun _ => ∀ ⦃Y⦄ (_ : Y ⟶ X), Prop := ⟨fun S => S.sieve⟩ /- Porting note: This is now a syntactic tautology. @[simp] theorem coe_fun_coe (S : J.Cover X) (f : Y ⟶ X) : S.sieve f = S f := rfl -/ theorem condition (S : J.Cover X) : S.sieve ∈ J X := S.2 @[ext] theorem ext (S T : J.Cover X) (h : ∀ ⦃Y⦄ (f : Y ⟶ X), S f ↔ T f) : S = T := Subtype.ext <| Sieve.ext h instance : OrderTop (J.Cover X) := { (inferInstance : Preorder (J.Cover X)) with top := ⟨⊤, J.top_mem _⟩ le_top := fun S Y f _ => by tauto } instance : SemilatticeInf (J.Cover X) := { (inferInstance : Preorder _) with inf := fun S T => ⟨S.sieve ⊓ T.sieve, J.intersection_covering S.condition T.condition⟩ le_antisymm := fun S T h1 h2 => ext _ _ fun {Y} f => ⟨by apply h1, by apply h2⟩ inf_le_left := fun S T Y f hf => hf.1 inf_le_right := fun S T Y f hf => hf.2 le_inf := fun S T W h1 h2 Y f h => ⟨h1 _ h, h2 _ h⟩ } instance : Inhabited (J.Cover X) := ⟨⊤⟩ /-- An auxiliary structure, used to define `S.index`. -/ -- Porting note(#5171): this linter isn't ported yet. -- @[nolint has_nonempty_instance] @[ext] structure Arrow (S : J.Cover X) where /-- The source of the arrow. -/ Y : C /-- The arrow itself. -/ f : Y ⟶ X /-- The given arrow is contained in the given sieve. -/ hf : S f /-- Relation between two elements in `S.arrow`, the data of which involves a commutative square. -/ @[ext] structure Arrow.Relation {S : J.Cover X} (I₁ I₂ : S.Arrow) where /-- The source of the arrows defining the relation. -/ Z : C /-- The first arrow defining the relation. -/ g₁ : Z ⟶ I₁.Y /-- The second arrow defining the relation. -/ g₂ : Z ⟶ I₂.Y /-- The relation itself. -/ w : g₁ ≫ I₁.f = g₂ ≫ I₂.f := by aesop_cat attribute [reassoc] Arrow.Relation.w /-- Given `I : S.Arrow` and a morphism `g : Z ⟶ I.Y`, this is the arrow in `S.Arrow` corresponding to `g ≫ I.f`. -/ @[simps] def Arrow.precomp {S : J.Cover X} (I : S.Arrow) {Z : C} (g : Z ⟶ I.Y) : S.Arrow := ⟨Z, g ≫ I.f, S.1.downward_closed I.hf g⟩ /-- Given `I : S.Arrow` and a morphism `g : Z ⟶ I.Y`, this is the obvious relation from `I.precomp g` to `I`. -/ @[simps] def Arrow.precompRelation {S : J.Cover X} (I : S.Arrow) {Z : C} (g : Z ⟶ I.Y) : (I.precomp g).Relation I where g₁ := 𝟙 _ g₂ := g /-- Map an `Arrow` along a refinement `S ⟶ T`. -/ @[simps] def Arrow.map {S T : J.Cover X} (I : S.Arrow) (f : S ⟶ T) : T.Arrow := ⟨I.Y, I.f, f.le _ I.hf⟩ /-- Map an `Arrow.Relation` along a refinement `S ⟶ T`. -/ @[simps] def Arrow.Relation.map {S T : J.Cover X} {I₁ I₂ : S.Arrow} (r : I₁.Relation I₂) (f : S ⟶ T) : (I₁.map f).Relation (I₂.map f) where w := r.w /-- Pull back a cover along a morphism. -/ def pullback (S : J.Cover X) (f : Y ⟶ X) : J.Cover Y := ⟨Sieve.pullback f S.sieve, J.pullback_stable _ S.condition⟩ /-- An arrow of `S.pullback f` gives rise to an arrow of `S`. -/ @[simps] def Arrow.base {f : Y ⟶ X} {S : J.Cover X} (I : (S.pullback f).Arrow) : S.Arrow := ⟨I.Y, I.f ≫ f, I.hf⟩ /-- A relation of `S.pullback f` gives rise to a relation of `S`. -/ def Arrow.Relation.base {f : Y ⟶ X} {S : J.Cover X} {I₁ I₂ : (S.pullback f).Arrow} (r : I₁.Relation I₂) : I₁.base.Relation I₂.base where g₁ := r.g₁ g₂ := r.g₂ w := by simp [r.w_assoc] @[simp] theorem coe_pullback {Z : C} (f : Y ⟶ X) (g : Z ⟶ Y) (S : J.Cover X) : (S.pullback f) g ↔ S (g ≫ f) := Iff.rfl /-- The isomorphism between `S` and the pullback of `S` w.r.t. the identity. -/ def pullbackId (S : J.Cover X) : S.pullback (𝟙 X) ≅ S := eqToIso <| Cover.ext _ _ fun Y f => by simp /-- Pulling back with respect to a composition is the composition of the pullbacks. -/ def pullbackComp {X Y Z : C} (S : J.Cover X) (f : Z ⟶ Y) (g : Y ⟶ X) : S.pullback (f ≫ g) ≅ (S.pullback g).pullback f := eqToIso <| Cover.ext _ _ fun Y f => by simp /-- Combine a family of covers over a cover. -/ def bind {X : C} (S : J.Cover X) (T : ∀ I : S.Arrow, J.Cover I.Y) : J.Cover X := ⟨Sieve.bind S.sieve fun Y f hf => (T ⟨Y, f, hf⟩).sieve, J.bind_covering S.condition fun _ _ _ => (T _).condition⟩ /-- The canonical morphism from `S.bind T` to `T`. -/ def bindToBase {X : C} (S : J.Cover X) (T : ∀ I : S.Arrow, J.Cover I.Y) : S.bind T ⟶ S := homOfLE <| by rintro Y f ⟨Z, e1, e2, h1, _, h3⟩ rw [← h3] apply Sieve.downward_closed exact h1 /-- An arrow in bind has the form `A ⟶ B ⟶ X` where `A ⟶ B` is an arrow in `T I` for some `I`. and `B ⟶ X` is an arrow of `S`. This is the object `B`. -/ noncomputable def Arrow.middle {X : C} {S : J.Cover X} {T : ∀ I : S.Arrow, J.Cover I.Y} (I : (S.bind T).Arrow) : C := I.hf.choose /-- An arrow in bind has the form `A ⟶ B ⟶ X` where `A ⟶ B` is an arrow in `T I` for some `I`. and `B ⟶ X` is an arrow of `S`. This is the hom `A ⟶ B`. -/ noncomputable def Arrow.toMiddleHom {X : C} {S : J.Cover X} {T : ∀ I : S.Arrow, J.Cover I.Y} (I : (S.bind T).Arrow) : I.Y ⟶ I.middle := I.hf.choose_spec.choose /-- An arrow in bind has the form `A ⟶ B ⟶ X` where `A ⟶ B` is an arrow in `T I` for some `I`. and `B ⟶ X` is an arrow of `S`. This is the hom `B ⟶ X`. -/ noncomputable def Arrow.fromMiddleHom {X : C} {S : J.Cover X} {T : ∀ I : S.Arrow, J.Cover I.Y} (I : (S.bind T).Arrow) : I.middle ⟶ X := I.hf.choose_spec.choose_spec.choose theorem Arrow.from_middle_condition {X : C} {S : J.Cover X} {T : ∀ I : S.Arrow, J.Cover I.Y} (I : (S.bind T).Arrow) : S I.fromMiddleHom := I.hf.choose_spec.choose_spec.choose_spec.choose /-- An arrow in bind has the form `A ⟶ B ⟶ X` where `A ⟶ B` is an arrow in `T I` for some `I`. and `B ⟶ X` is an arrow of `S`. This is the hom `B ⟶ X`, as an arrow. -/ noncomputable def Arrow.fromMiddle {X : C} {S : J.Cover X} {T : ∀ I : S.Arrow, J.Cover I.Y} (I : (S.bind T).Arrow) : S.Arrow := ⟨_, I.fromMiddleHom, I.from_middle_condition⟩ theorem Arrow.to_middle_condition {X : C} {S : J.Cover X} {T : ∀ I : S.Arrow, J.Cover I.Y} (I : (S.bind T).Arrow) : (T I.fromMiddle) I.toMiddleHom := I.hf.choose_spec.choose_spec.choose_spec.choose_spec.1 /-- An arrow in bind has the form `A ⟶ B ⟶ X` where `A ⟶ B` is an arrow in `T I` for some `I`. and `B ⟶ X` is an arrow of `S`. This is the hom `A ⟶ B`, as an arrow. -/ noncomputable def Arrow.toMiddle {X : C} {S : J.Cover X} {T : ∀ I : S.Arrow, J.Cover I.Y} (I : (S.bind T).Arrow) : (T I.fromMiddle).Arrow := ⟨_, I.toMiddleHom, I.to_middle_condition⟩ theorem Arrow.middle_spec {X : C} {S : J.Cover X} {T : ∀ I : S.Arrow, J.Cover I.Y} (I : (S.bind T).Arrow) : I.toMiddleHom ≫ I.fromMiddleHom = I.f := I.hf.choose_spec.choose_spec.choose_spec.choose_spec.2 /-- An auxiliary structure, used to define `S.index`. -/ -- Porting note(#5171): this linter isn't ported yet. -- @[nolint has_nonempty_instance, ext] @[ext] structure Relation (S : J.Cover X) where /-- The first arrow. -/ fst : S.Arrow /-- The second arrow. -/ snd : S.Arrow /-- The relation between the two arrows. -/ r : fst.Relation snd /-- Constructor for `Cover.Relation` which takes as an input `r : I₁.Relation I₂` with `I₁ I₂ : S.Arrow`. -/ @[simps] def Relation.mk' {S : J.Cover X} {fst snd : S.Arrow} (r : fst.Relation snd) : S.Relation where r := r -- This is used extensively in `Plus.lean`, etc. -- We place this definition here as it will be used in `Sheaf.lean` as well. /-- To every `S : J.Cover X` and presheaf `P`, associate a `MulticospanIndex`. -/ @[simps] def index {D : Type u₁} [Category.{v₁} D] (S : J.Cover X) (P : Cᵒᵖ ⥤ D) : Limits.MulticospanIndex D where L := S.Arrow R := S.Relation fstTo I := I.fst sndTo I := I.snd left I := P.obj (Opposite.op I.Y) right I := P.obj (Opposite.op I.r.Z) fst I := P.map I.r.g₁.op snd I := P.map I.r.g₂.op /-- The natural multifork associated to `S : J.Cover X` for a presheaf `P`. Saying that this multifork is a limit is essentially equivalent to the sheaf condition at the given object for the given covering sieve. See `Sheaf.lean` for an equivalent sheaf condition using this. -/ abbrev multifork {D : Type u₁} [Category.{v₁} D] (S : J.Cover X) (P : Cᵒᵖ ⥤ D) : Limits.Multifork (S.index P) := Limits.Multifork.ofι _ (P.obj (Opposite.op X)) (fun I => P.map I.f.op) (by intro I dsimp simp only [← P.map_comp, ← op_comp, I.r.w]) /-- The canonical map from `P.obj (op X)` to the multiequalizer associated to a covering sieve, assuming such a multiequalizer exists. This will be used in `Sheaf.lean` to provide an equivalent sheaf condition in terms of multiequalizers. -/ noncomputable abbrev toMultiequalizer {D : Type u₁} [Category.{v₁} D] (S : J.Cover X) (P : Cᵒᵖ ⥤ D) [Limits.HasMultiequalizer (S.index P)] : P.obj (Opposite.op X) ⟶ Limits.multiequalizer (S.index P) := Limits.Multiequalizer.lift _ _ (fun I => P.map I.f.op) (by intro I dsimp only [index, Relation.fst, Relation.snd] simp only [← P.map_comp, ← op_comp, I.r.w]) end Cover /-- Pull back a cover along a morphism. -/ @[simps obj] def pullback (f : Y ⟶ X) : J.Cover X ⥤ J.Cover Y where obj S := S.pullback f map f := (Sieve.pullback_monotone _ f.le).hom /-- Pulling back along the identity is naturally isomorphic to the identity functor. -/ def pullbackId (X : C) : J.pullback (𝟙 X) ≅ 𝟭 _ := NatIso.ofComponents fun S => S.pullbackId /-- Pulling back along a composition is naturally isomorphic to the composition of the pullbacks. -/ def pullbackComp {X Y Z : C} (f : X ⟶ Y) (g : Y ⟶ Z) : J.pullback (f ≫ g) ≅ J.pullback g ⋙ J.pullback f := NatIso.ofComponents fun S => S.pullbackComp f g end GrothendieckTopology end CategoryTheory
CategoryTheory\Sites\InducedTopology.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.Sites.DenseSubsite /-! # Induced Topology We say that a functor `G : C ⥤ (D, K)` is locally dense if for each covering sieve `T` in `D` of some `X : C`, `T ∩ mor(C)` generates a covering sieve of `X` in `D`. A locally dense fully faithful functor then induces a topology on `C` via `{ T ∩ mor(C) | T ∈ K }`. Note that this is equal to the collection of sieves on `C` whose image generates a covering sieve. This construction would make `C` both cover-lifting and cover-preserving. Some typical examples are full and cover-dense functors (for example the functor from a basis of a topological space `X` into `Opens X`). The functor `Over X ⥤ C` is also locally dense, and the induced topology can then be used to construct the big sites associated to a scheme. Given a fully faithful cover-dense functor `G : C ⥤ (D, K)` between small sites, we then have `Sheaf (H.inducedTopology) A ≌ Sheaf K A`. This is known as the comparison lemma. ## References * [Elephant]: *Sketches of an Elephant*, P. T. Johnstone: C2.2. * https://ncatlab.org/nlab/show/dense+sub-site * https://ncatlab.org/nlab/show/comparison+lemma -/ namespace CategoryTheory universe v u open Limits Opposite Presieve CategoryTheory variable {C : Type*} [Category C] {D : Type*} [Category D] (G : C ⥤ D) variable {J : GrothendieckTopology C} (K : GrothendieckTopology D) variable (A : Type v) [Category.{u} A] namespace Functor -- variables (A) [full G] [faithful G] /-- We say that a functor `C ⥤ D` into a site is "locally dense" if for each covering sieve `T` in `D`, `T ∩ mor(C)` generates a covering sieve in `D`. -/ class LocallyCoverDense : Prop where functorPushforward_functorPullback_mem : ∀ ⦃X : C⦄ (T : K (G.obj X)), (T.val.functorPullback G).functorPushforward G ∈ K (G.obj X) variable [G.LocallyCoverDense K] theorem pushforward_cover_iff_cover_pullback [G.Full] [G.Faithful] {X : C} (S : Sieve X) : K _ (S.functorPushforward G) ↔ ∃ T : K (G.obj X), T.val.functorPullback G = S := by constructor · intro hS exact ⟨⟨_, hS⟩, (Sieve.fullyFaithfulFunctorGaloisCoinsertion G X).u_l_eq S⟩ · rintro ⟨T, rfl⟩ exact LocallyCoverDense.functorPushforward_functorPullback_mem T variable [G.IsLocallyFull K] [G.IsLocallyFaithful K] /-- If a functor `G : C ⥤ (D, K)` is fully faithful and locally dense, then the set `{ T ∩ mor(C) | T ∈ K }` is a grothendieck topology of `C`. -/ @[simps] def inducedTopology : GrothendieckTopology C where sieves X S := K _ (S.functorPushforward G) top_mem' X := by change K _ _ rw [Sieve.functorPushforward_top] exact K.top_mem _ pullback_stable' X Y S iYX hS := by apply K.transitive (LocallyCoverDense.functorPushforward_functorPullback_mem ⟨_, K.pullback_stable (G.map iYX) hS⟩) rintro Z _ ⟨U, iUY, iZU, ⟨W, iWX, iUW, hiWX, e₁⟩, rfl⟩ rw [Sieve.pullback_comp] apply K.pullback_stable clear iZU Z apply K.transitive (G.functorPushforward_imageSieve_mem _ iUW) rintro Z _ ⟨U₁, iU₁U, iZU₁, ⟨iU₁W, e₂⟩, rfl⟩ rw [Sieve.pullback_comp] apply K.pullback_stable clear iZU₁ Z apply K.superset_covering ?_ (G.functorPushforward_equalizer_mem _ (iU₁U ≫ iUY ≫ iYX) (iU₁W ≫ iWX) (by simp [e₁, e₂])) rintro Z _ ⟨U₂, iU₂U₁, iZU₂, e₃ : _ = _, rfl⟩ refine ⟨_, iU₂U₁ ≫ iU₁U ≫ iUY, iZU₂, ?_, by simp⟩ simpa [e₃] using S.downward_closed hiWX (iU₂U₁ ≫ iU₁W) transitive' X S hS S' H' := by apply K.transitive hS rintro Y _ ⟨Z, g, i, hg, rfl⟩ rw [Sieve.pullback_comp] apply K.pullback_stable i refine K.superset_covering ?_ (H' hg) rintro W _ ⟨Z', g', i', hg, rfl⟩ refine ⟨Z', g' ≫ g , i', hg, ?_⟩ simp @[simp] lemma mem_inducedTopology_sieves_iff {X : C} (S : Sieve X) : S ∈ (G.inducedTopology K).sieves X ↔ (S.functorPushforward G) ∈ K.sieves (G.obj X) := Iff.rfl /-- `G` is cover-lifting wrt the induced topology. -/ instance inducedTopology_isCocontinuous : G.IsCocontinuous (G.inducedTopology K) K := ⟨@fun _ S hS => LocallyCoverDense.functorPushforward_functorPullback_mem ⟨S, hS⟩⟩ /-- `G` is cover-preserving wrt the induced topology. -/ theorem inducedTopology_coverPreserving : CoverPreserving (G.inducedTopology K) K G := ⟨@fun _ _ hS => hS⟩ instance (priority := 900) locallyCoverDense_of_isCoverDense [G.IsCoverDense K] : G.LocallyCoverDense K where functorPushforward_functorPullback_mem _ _ := IsCoverDense.functorPullback_pushforward_covering _ instance (priority := 900) [G.IsCoverDense K] : G.IsDenseSubsite (G.inducedTopology K) K where functorPushforward_mem_iff := Iff.rfl @[deprecated (since := "2024-07-23")] alias inducedTopologyOfIsCoverDense := inducedTopology variable (J) instance over_forget_locallyCoverDense (X : C) : (Over.forget X).LocallyCoverDense J where functorPushforward_functorPullback_mem Y T := by convert T.property ext Z f constructor · rintro ⟨_, _, g', hg, rfl⟩ exact T.val.downward_closed hg g' · intro hf exact ⟨Over.mk (f ≫ Y.hom), Over.homMk f, 𝟙 _, hf, (Category.id_comp _).symm⟩ /-- Cover-dense functors induces an equivalence of categories of sheaves. This is known as the comparison lemma. It requires that the sites are small and the value category is complete. -/ noncomputable def sheafInducedTopologyEquivOfIsCoverDense [G.IsCoverDense K] [∀ (X : Dᵒᵖ), HasLimitsOfShape (StructuredArrow X G.op) A] : Sheaf (G.inducedTopology K) A ≌ Sheaf K A := Functor.IsDenseSubsite.sheafEquiv G (G.inducedTopology K) K A end Functor end CategoryTheory
CategoryTheory\Sites\IsSheafFor.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.Sites.Sieves import Mathlib.CategoryTheory.Limits.Shapes.Pullback.Mono /-! # The sheaf condition for a presieve We define what it means for a presheaf `P : Cᵒᵖ ⥤ Type v` to be a sheaf *for* a particular presieve `R` on `X`: * A *family of elements* `x` for `P` at `R` is an element `x_f` of `P Y` for every `f : Y ⟶ X` in `R`. See `FamilyOfElements`. * The family `x` is *compatible* if, for any `f₁ : Y₁ ⟶ X` and `f₂ : Y₂ ⟶ X` both in `R`, and any `g₁ : Z ⟶ Y₁` and `g₂ : Z ⟶ Y₂` such that `g₁ ≫ f₁ = g₂ ≫ f₂`, the restriction of `x_f₁` along `g₁` agrees with the restriction of `x_f₂` along `g₂`. See `FamilyOfElements.Compatible`. * An *amalgamation* `t` for the family is an element of `P X` such that for every `f : Y ⟶ X` in `R`, the restriction of `t` on `f` is `x_f`. See `FamilyOfElements.IsAmalgamation`. We then say `P` is *separated* for `R` if every compatible family has at most one amalgamation, and it is a *sheaf* for `R` if every compatible family has a unique amalgamation. See `IsSeparatedFor` and `IsSheafFor`. In the special case where `R` is a sieve, the compatibility condition can be simplified: * The family `x` is *compatible* if, for any `f : Y ⟶ X` in `R` and `g : Z ⟶ Y`, the restriction of `x_f` along `g` agrees with `x_(g ≫ f)` (which is well defined since `g ≫ f` is in `R`). See `FamilyOfElements.SieveCompatible` and `compatible_iff_sieveCompatible`. In the special case where `C` has pullbacks, the compatibility condition can be simplified: * The family `x` is *compatible* if, for any `f : Y ⟶ X` and `g : Z ⟶ X` both in `R`, the restriction of `x_f` along `π₁ : pullback f g ⟶ Y` agrees with the restriction of `x_g` along `π₂ : pullback f g ⟶ Z`. See `FamilyOfElements.PullbackCompatible` and `pullbackCompatible_iff`. We also provide equivalent conditions to satisfy alternate definitions given in the literature. * Stacks: The condition of https://stacks.math.columbia.edu/tag/00Z8 is virtually identical to the statement of `isSheafFor_iff_yonedaSheafCondition` (since the bijection described there carries the same information as the unique existence.) * Maclane-Moerdijk [MM92]: Using `compatible_iff_sieveCompatible`, the definitions of `IsSheaf` are equivalent. There are also alternate definitions given: - Yoneda condition: Defined in `yonedaSheafCondition` and equivalence in `isSheafFor_iff_yonedaSheafCondition`. - Matching family for presieves with pullback: `pullbackCompatible_iff`. ## Implementation The sheaf condition is given as a proposition, rather than a subsingleton in `Type (max u₁ v)`. This doesn't seem to make a big difference, other than making a couple of definitions noncomputable, but it means that equivalent conditions can be given as `↔` statements rather than `≃` statements, which can be convenient. ## References * [MM92]: *Sheaves in geometry and logic*, Saunders MacLane, and Ieke Moerdijk: Chapter III, Section 4. * [Elephant]: *Sketches of an Elephant*, P. T. Johnstone: C2.1. * https://stacks.math.columbia.edu/tag/00VL (sheaves on a pretopology or site) * https://stacks.math.columbia.edu/tag/00ZB (sheaves on a topology) -/ universe w v₁ v₂ u₁ u₂ namespace CategoryTheory open Opposite CategoryTheory Category Limits Sieve namespace Presieve variable {C : Type u₁} [Category.{v₁} C] variable {P Q U : Cᵒᵖ ⥤ Type w} variable {X Y : C} {S : Sieve X} {R : Presieve X} /-- A family of elements for a presheaf `P` given a collection of arrows `R` with fixed codomain `X` consists of an element of `P Y` for every `f : Y ⟶ X` in `R`. A presheaf is a sheaf (resp, separated) if every *compatible* family of elements has exactly one (resp, at most one) amalgamation. This data is referred to as a `family` in [MM92], Chapter III, Section 4. It is also a concrete version of the elements of the middle object in https://stacks.math.columbia.edu/tag/00VM which is more useful for direct calculations. It is also used implicitly in Definition C2.1.2 in [Elephant]. -/ def FamilyOfElements (P : Cᵒᵖ ⥤ Type w) (R : Presieve X) := ∀ ⦃Y : C⦄ (f : Y ⟶ X), R f → P.obj (op Y) instance : Inhabited (FamilyOfElements P (⊥ : Presieve X)) := ⟨fun _ _ => False.elim⟩ /-- A family of elements for a presheaf on the presieve `R₂` can be restricted to a smaller presieve `R₁`. -/ def FamilyOfElements.restrict {R₁ R₂ : Presieve X} (h : R₁ ≤ R₂) : FamilyOfElements P R₂ → FamilyOfElements P R₁ := fun x _ f hf => x f (h _ hf) /-- The image of a family of elements by a morphism of presheaves. -/ def FamilyOfElements.map (p : FamilyOfElements P R) (φ : P ⟶ Q) : FamilyOfElements Q R := fun _ f hf => φ.app _ (p f hf) @[simp] lemma FamilyOfElements.map_apply (p : FamilyOfElements P R) (φ : P ⟶ Q) {Y : C} (f : Y ⟶ X) (hf : R f) : p.map φ f hf = φ.app _ (p f hf) := rfl lemma FamilyOfElements.restrict_map (p : FamilyOfElements P R) (φ : P ⟶ Q) {R' : Presieve X} (h : R' ≤ R) : (p.restrict h).map φ = (p.map φ).restrict h := rfl /-- A family of elements for the arrow set `R` is *compatible* if for any `f₁ : Y₁ ⟶ X` and `f₂ : Y₂ ⟶ X` in `R`, and any `g₁ : Z ⟶ Y₁` and `g₂ : Z ⟶ Y₂`, if the square `g₁ ≫ f₁ = g₂ ≫ f₂` commutes then the elements of `P Z` obtained by restricting the element of `P Y₁` along `g₁` and restricting the element of `P Y₂` along `g₂` are the same. In special cases, this condition can be simplified, see `pullbackCompatible_iff` and `compatible_iff_sieveCompatible`. This is referred to as a "compatible family" in Definition C2.1.2 of [Elephant], and on nlab: https://ncatlab.org/nlab/show/sheaf#GeneralDefinitionInComponents For a more explicit version in the case where `R` is of the form `Presieve.ofArrows`, see `CategoryTheory.Presieve.Arrows.Compatible`. -/ def FamilyOfElements.Compatible (x : FamilyOfElements P R) : Prop := ∀ ⦃Y₁ Y₂ Z⦄ (g₁ : Z ⟶ Y₁) (g₂ : Z ⟶ Y₂) ⦃f₁ : Y₁ ⟶ X⦄ ⦃f₂ : Y₂ ⟶ X⦄ (h₁ : R f₁) (h₂ : R f₂), g₁ ≫ f₁ = g₂ ≫ f₂ → P.map g₁.op (x f₁ h₁) = P.map g₂.op (x f₂ h₂) /-- If the category `C` has pullbacks, this is an alternative condition for a family of elements to be compatible: For any `f : Y ⟶ X` and `g : Z ⟶ X` in the presieve `R`, the restriction of the given elements for `f` and `g` to the pullback agree. This is equivalent to being compatible (provided `C` has pullbacks), shown in `pullbackCompatible_iff`. This is the definition for a "matching" family given in [MM92], Chapter III, Section 4, Equation (5). Viewing the type `FamilyOfElements` as the middle object of the fork in https://stacks.math.columbia.edu/tag/00VM, this condition expresses that `pr₀* (x) = pr₁* (x)`, using the notation defined there. For a more explicit version in the case where `R` is of the form `Presieve.ofArrows`, see `CategoryTheory.Presieve.Arrows.PullbackCompatible`. -/ def FamilyOfElements.PullbackCompatible (x : FamilyOfElements P R) [R.hasPullbacks] : Prop := ∀ ⦃Y₁ Y₂⦄ ⦃f₁ : Y₁ ⟶ X⦄ ⦃f₂ : Y₂ ⟶ X⦄ (h₁ : R f₁) (h₂ : R f₂), haveI := hasPullbacks.has_pullbacks h₁ h₂ P.map (pullback.fst f₁ f₂).op (x f₁ h₁) = P.map (pullback.snd f₁ f₂).op (x f₂ h₂) theorem pullbackCompatible_iff (x : FamilyOfElements P R) [R.hasPullbacks] : x.Compatible ↔ x.PullbackCompatible := by constructor · intro t Y₁ Y₂ f₁ f₂ hf₁ hf₂ apply t haveI := hasPullbacks.has_pullbacks hf₁ hf₂ apply pullback.condition · intro t Y₁ Y₂ Z g₁ g₂ f₁ f₂ hf₁ hf₂ comm haveI := hasPullbacks.has_pullbacks hf₁ hf₂ rw [← pullback.lift_fst _ _ comm, op_comp, FunctorToTypes.map_comp_apply, t hf₁ hf₂, ← FunctorToTypes.map_comp_apply, ← op_comp, pullback.lift_snd] /-- The restriction of a compatible family is compatible. -/ theorem FamilyOfElements.Compatible.restrict {R₁ R₂ : Presieve X} (h : R₁ ≤ R₂) {x : FamilyOfElements P R₂} : x.Compatible → (x.restrict h).Compatible := fun q _ _ _ g₁ g₂ _ _ h₁ h₂ comm => q g₁ g₂ (h _ h₁) (h _ h₂) comm /-- Extend a family of elements to the sieve generated by an arrow set. This is the construction described as "easy" in Lemma C2.1.3 of [Elephant]. -/ noncomputable def FamilyOfElements.sieveExtend (x : FamilyOfElements P R) : FamilyOfElements P (generate R : Presieve X) := fun _ _ hf => P.map hf.choose_spec.choose.op (x _ hf.choose_spec.choose_spec.choose_spec.1) /-- The extension of a compatible family to the generated sieve is compatible. -/ theorem FamilyOfElements.Compatible.sieveExtend {x : FamilyOfElements P R} (hx : x.Compatible) : x.sieveExtend.Compatible := by intro _ _ _ _ _ _ _ h₁ h₂ comm iterate 2 erw [← FunctorToTypes.map_comp_apply]; rw [← op_comp] apply hx simp [comm, h₁.choose_spec.choose_spec.choose_spec.2, h₂.choose_spec.choose_spec.choose_spec.2] /-- The extension of a family agrees with the original family. -/ theorem extend_agrees {x : FamilyOfElements P R} (t : x.Compatible) {f : Y ⟶ X} (hf : R f) : x.sieveExtend f (le_generate R Y hf) = x f hf := by have h := (le_generate R Y hf).choose_spec unfold FamilyOfElements.sieveExtend rw [t h.choose (𝟙 _) _ hf _] · simp · rw [id_comp] exact h.choose_spec.choose_spec.2 /-- The restriction of an extension is the original. -/ @[simp] theorem restrict_extend {x : FamilyOfElements P R} (t : x.Compatible) : x.sieveExtend.restrict (le_generate R) = x := by funext Y f hf exact extend_agrees t hf /-- If the arrow set for a family of elements is actually a sieve (i.e. it is downward closed) then the consistency condition can be simplified. This is an equivalent condition, see `compatible_iff_sieveCompatible`. This is the notion of "matching" given for families on sieves given in [MM92], Chapter III, Section 4, Equation 1, and nlab: https://ncatlab.org/nlab/show/matching+family. See also the discussion before Lemma C2.1.4 of [Elephant]. -/ def FamilyOfElements.SieveCompatible (x : FamilyOfElements P (S : Presieve X)) : Prop := ∀ ⦃Y Z⦄ (f : Y ⟶ X) (g : Z ⟶ Y) (hf), x (g ≫ f) (S.downward_closed hf g) = P.map g.op (x f hf) theorem compatible_iff_sieveCompatible (x : FamilyOfElements P (S : Presieve X)) : x.Compatible ↔ x.SieveCompatible := by constructor · intro h Y Z f g hf simpa using h (𝟙 _) g (S.downward_closed hf g) hf (id_comp _) · intro h Y₁ Y₂ Z g₁ g₂ f₁ f₂ h₁ h₂ k simp_rw [← h f₁ g₁ h₁, ← h f₂ g₂ h₂] congr theorem FamilyOfElements.Compatible.to_sieveCompatible {x : FamilyOfElements P (S : Presieve X)} (t : x.Compatible) : x.SieveCompatible := (compatible_iff_sieveCompatible x).1 t /-- Given a family of elements `x` for the sieve `S` generated by a presieve `R`, if `x` is restricted to `R` and then extended back up to `S`, the resulting extension equals `x`. -/ @[simp] theorem extend_restrict {x : FamilyOfElements P (generate R)} (t : x.Compatible) : (x.restrict (le_generate R)).sieveExtend = x := by rw [compatible_iff_sieveCompatible] at t funext _ _ h apply (t _ _ _).symm.trans congr exact h.choose_spec.choose_spec.choose_spec.2 /-- Two compatible families on the sieve generated by a presieve `R` are equal if and only if they are equal when restricted to `R`. -/ theorem restrict_inj {x₁ x₂ : FamilyOfElements P (generate R)} (t₁ : x₁.Compatible) (t₂ : x₂.Compatible) : x₁.restrict (le_generate R) = x₂.restrict (le_generate R) → x₁ = x₂ := fun h => by rw [← extend_restrict t₁, ← extend_restrict t₂] -- Porting note: congr fails to make progress apply congr_arg exact h /-- Compatible families of elements for a presheaf of types `P` and a presieve `R` are in 1-1 correspondence with compatible families for the same presheaf and the sieve generated by `R`, through extension and restriction. -/ @[simps] noncomputable def compatibleEquivGenerateSieveCompatible : { x : FamilyOfElements P R // x.Compatible } ≃ { x : FamilyOfElements P (generate R : Presieve X) // x.Compatible } where toFun x := ⟨x.1.sieveExtend, x.2.sieveExtend⟩ invFun x := ⟨x.1.restrict (le_generate R), x.2.restrict _⟩ left_inv x := Subtype.ext (restrict_extend x.2) right_inv x := Subtype.ext (extend_restrict x.2) theorem FamilyOfElements.comp_of_compatible (S : Sieve X) {x : FamilyOfElements P S} (t : x.Compatible) {f : Y ⟶ X} (hf : S f) {Z} (g : Z ⟶ Y) : x (g ≫ f) (S.downward_closed hf g) = P.map g.op (x f hf) := by simpa using t (𝟙 _) g (S.downward_closed hf g) hf (id_comp _) section FunctorPullback variable {D : Type u₂} [Category.{v₂} D] (F : D ⥤ C) {Z : D} variable {T : Presieve (F.obj Z)} {x : FamilyOfElements P T} /-- Given a family of elements of a sieve `S` on `F(X)`, we can realize it as a family of elements of `S.functorPullback F`. -/ def FamilyOfElements.functorPullback (x : FamilyOfElements P T) : FamilyOfElements (F.op ⋙ P) (T.functorPullback F) := fun _ f hf => x (F.map f) hf theorem FamilyOfElements.Compatible.functorPullback (h : x.Compatible) : (x.functorPullback F).Compatible := by intro Z₁ Z₂ W g₁ g₂ f₁ f₂ h₁ h₂ eq exact h (F.map g₁) (F.map g₂) h₁ h₂ (by simp only [← F.map_comp, eq]) end FunctorPullback /-- Given a family of elements of a sieve `S` on `X` whose values factors through `F`, we can realize it as a family of elements of `S.functorPushforward F`. Since the preimage is obtained by choice, this is not well-defined generally. -/ noncomputable def FamilyOfElements.functorPushforward {D : Type u₂} [Category.{v₂} D] (F : D ⥤ C) {X : D} {T : Presieve X} (x : FamilyOfElements (F.op ⋙ P) T) : FamilyOfElements P (T.functorPushforward F) := fun Y f h => by obtain ⟨Z, g, h, h₁, _⟩ := getFunctorPushforwardStructure h exact P.map h.op (x g h₁) section Pullback /-- Given a family of elements of a sieve `S` on `X`, and a map `Y ⟶ X`, we can obtain a family of elements of `S.pullback f` by taking the same elements. -/ def FamilyOfElements.pullback (f : Y ⟶ X) (x : FamilyOfElements P (S : Presieve X)) : FamilyOfElements P (S.pullback f : Presieve Y) := fun _ g hg => x (g ≫ f) hg theorem FamilyOfElements.Compatible.pullback (f : Y ⟶ X) {x : FamilyOfElements P S} (h : x.Compatible) : (x.pullback f).Compatible := by simp only [compatible_iff_sieveCompatible] at h ⊢ intro W Z f₁ f₂ hf unfold FamilyOfElements.pullback rw [← h (f₁ ≫ f) f₂ hf] congr 1 simp only [assoc] end Pullback /-- Given a morphism of presheaves `f : P ⟶ Q`, we can take a family of elements valued in `P` to a family of elements valued in `Q` by composing with `f`. -/ def FamilyOfElements.compPresheafMap (f : P ⟶ Q) (x : FamilyOfElements P R) : FamilyOfElements Q R := fun Y g hg => f.app (op Y) (x g hg) @[simp] theorem FamilyOfElements.compPresheafMap_id (x : FamilyOfElements P R) : x.compPresheafMap (𝟙 P) = x := rfl @[simp] theorem FamilyOfElements.compPresheafMap_comp (x : FamilyOfElements P R) (f : P ⟶ Q) (g : Q ⟶ U) : (x.compPresheafMap f).compPresheafMap g = x.compPresheafMap (f ≫ g) := rfl theorem FamilyOfElements.Compatible.compPresheafMap (f : P ⟶ Q) {x : FamilyOfElements P R} (h : x.Compatible) : (x.compPresheafMap f).Compatible := by intro Z₁ Z₂ W g₁ g₂ f₁ f₂ h₁ h₂ eq unfold FamilyOfElements.compPresheafMap rwa [← FunctorToTypes.naturality, ← FunctorToTypes.naturality, h] /-- The given element `t` of `P.obj (op X)` is an *amalgamation* for the family of elements `x` if every restriction `P.map f.op t = x_f` for every arrow `f` in the presieve `R`. This is the definition given in https://ncatlab.org/nlab/show/sheaf#GeneralDefinitionInComponents, and https://ncatlab.org/nlab/show/matching+family, as well as [MM92], Chapter III, Section 4, equation (2). -/ def FamilyOfElements.IsAmalgamation (x : FamilyOfElements P R) (t : P.obj (op X)) : Prop := ∀ ⦃Y : C⦄ (f : Y ⟶ X) (h : R f), P.map f.op t = x f h theorem FamilyOfElements.IsAmalgamation.compPresheafMap {x : FamilyOfElements P R} {t} (f : P ⟶ Q) (h : x.IsAmalgamation t) : (x.compPresheafMap f).IsAmalgamation (f.app (op X) t) := by intro Y g hg dsimp [FamilyOfElements.compPresheafMap] change (f.app _ ≫ Q.map _) _ = _ rw [← f.naturality, types_comp_apply, h g hg] theorem is_compatible_of_exists_amalgamation (x : FamilyOfElements P R) (h : ∃ t, x.IsAmalgamation t) : x.Compatible := by cases' h with t ht intro Y₁ Y₂ Z g₁ g₂ f₁ f₂ h₁ h₂ comm rw [← ht _ h₁, ← ht _ h₂, ← FunctorToTypes.map_comp_apply, ← op_comp, comm] simp theorem isAmalgamation_restrict {R₁ R₂ : Presieve X} (h : R₁ ≤ R₂) (x : FamilyOfElements P R₂) (t : P.obj (op X)) (ht : x.IsAmalgamation t) : (x.restrict h).IsAmalgamation t := fun Y f hf => ht f (h Y hf) theorem isAmalgamation_sieveExtend {R : Presieve X} (x : FamilyOfElements P R) (t : P.obj (op X)) (ht : x.IsAmalgamation t) : x.sieveExtend.IsAmalgamation t := by intro Y f hf dsimp [FamilyOfElements.sieveExtend] rw [← ht _, ← FunctorToTypes.map_comp_apply, ← op_comp, hf.choose_spec.choose_spec.choose_spec.2] /-- A presheaf is separated for a presieve if there is at most one amalgamation. -/ def IsSeparatedFor (P : Cᵒᵖ ⥤ Type w) (R : Presieve X) : Prop := ∀ (x : FamilyOfElements P R) (t₁ t₂), x.IsAmalgamation t₁ → x.IsAmalgamation t₂ → t₁ = t₂ theorem IsSeparatedFor.ext {R : Presieve X} (hR : IsSeparatedFor P R) {t₁ t₂ : P.obj (op X)} (h : ∀ ⦃Y⦄ ⦃f : Y ⟶ X⦄ (_ : R f), P.map f.op t₁ = P.map f.op t₂) : t₁ = t₂ := hR (fun _ f _ => P.map f.op t₂) t₁ t₂ (fun _ _ hf => h hf) fun _ _ _ => rfl theorem isSeparatedFor_iff_generate : IsSeparatedFor P R ↔ IsSeparatedFor P (generate R : Presieve X) := by constructor · intro h x t₁ t₂ ht₁ ht₂ apply h (x.restrict (le_generate R)) t₁ t₂ _ _ · exact isAmalgamation_restrict _ x t₁ ht₁ · exact isAmalgamation_restrict _ x t₂ ht₂ · intro h x t₁ t₂ ht₁ ht₂ apply h x.sieveExtend · exact isAmalgamation_sieveExtend x t₁ ht₁ · exact isAmalgamation_sieveExtend x t₂ ht₂ theorem isSeparatedFor_top (P : Cᵒᵖ ⥤ Type w) : IsSeparatedFor P (⊤ : Presieve X) := fun x t₁ t₂ h₁ h₂ => by have q₁ := h₁ (𝟙 X) (by tauto) have q₂ := h₂ (𝟙 X) (by tauto) simp only [op_id, FunctorToTypes.map_id_apply] at q₁ q₂ rw [q₁, q₂] /-- We define `P` to be a sheaf for the presieve `R` if every compatible family has a unique amalgamation. This is the definition of a sheaf for the given presieve given in C2.1.2 of [Elephant], and https://ncatlab.org/nlab/show/sheaf#GeneralDefinitionInComponents. Using `compatible_iff_sieveCompatible`, this is equivalent to the definition of a sheaf in [MM92], Chapter III, Section 4. -/ def IsSheafFor (P : Cᵒᵖ ⥤ Type w) (R : Presieve X) : Prop := ∀ x : FamilyOfElements P R, x.Compatible → ∃! t, x.IsAmalgamation t /-- This is an equivalent condition to be a sheaf, which is useful for the abstraction to local operators on elementary toposes. However this definition is defined only for sieves, not presieves. The equivalence between this and `IsSheafFor` is given in `isSheafFor_iff_yonedaSheafCondition`. This version is also useful to establish that being a sheaf is preserved under isomorphism of presheaves. See the discussion before Equation (3) of [MM92], Chapter III, Section 4. See also C2.1.4 of [Elephant]. This is also a direct reformulation of <https://stacks.math.columbia.edu/tag/00Z8>. -/ def YonedaSheafCondition (P : Cᵒᵖ ⥤ Type v₁) (S : Sieve X) : Prop := ∀ f : S.functor ⟶ P, ∃! g, S.functorInclusion ≫ g = f -- TODO: We can generalize the universe parameter v₁ above by composing with -- appropriate `ulift_functor`s. /-- (Implementation). This is a (primarily internal) equivalence between natural transformations and compatible families. Cf the discussion after Lemma 7.47.10 in <https://stacks.math.columbia.edu/tag/00YW>. See also the proof of C2.1.4 of [Elephant], and the discussion in [MM92], Chapter III, Section 4. -/ def natTransEquivCompatibleFamily {P : Cᵒᵖ ⥤ Type v₁} : (S.functor ⟶ P) ≃ { x : FamilyOfElements P (S : Presieve X) // x.Compatible } where toFun α := by refine ⟨fun Y f hf => ?_, ?_⟩ · apply α.app (op Y) ⟨_, hf⟩ · rw [compatible_iff_sieveCompatible] intro Y Z f g hf dsimp rw [← FunctorToTypes.naturality _ _ α g.op] rfl invFun t := { app := fun Y f => t.1 _ f.2 naturality := fun Y Z g => by ext ⟨f, hf⟩ apply t.2.to_sieveCompatible _ } left_inv α := by ext X ⟨_, _⟩ rfl right_inv := by rintro ⟨x, hx⟩ rfl /-- (Implementation). A lemma useful to prove `isSheafFor_iff_yonedaSheafCondition`. -/ theorem extension_iff_amalgamation {P : Cᵒᵖ ⥤ Type v₁} (x : S.functor ⟶ P) (g : yoneda.obj X ⟶ P) : S.functorInclusion ≫ g = x ↔ (natTransEquivCompatibleFamily x).1.IsAmalgamation (yonedaEquiv g) := by change _ ↔ ∀ ⦃Y : C⦄ (f : Y ⟶ X) (h : S f), P.map f.op (yonedaEquiv g) = x.app (op Y) ⟨f, h⟩ constructor · rintro rfl Y f hf rw [yonedaEquiv_naturality] dsimp simp [yonedaEquiv_apply] -- See note [dsimp, simp]. · intro h ext Y ⟨f, hf⟩ convert h f hf rw [yonedaEquiv_naturality] dsimp [yonedaEquiv] simp /-- The yoneda version of the sheaf condition is equivalent to the sheaf condition. C2.1.4 of [Elephant]. -/ theorem isSheafFor_iff_yonedaSheafCondition {P : Cᵒᵖ ⥤ Type v₁} : IsSheafFor P (S : Presieve X) ↔ YonedaSheafCondition P S := by rw [IsSheafFor, YonedaSheafCondition] simp_rw [extension_iff_amalgamation] rw [Equiv.forall_congr_left natTransEquivCompatibleFamily] rw [Subtype.forall] exact forall₂_congr fun x hx ↦ by simp [Equiv.existsUnique_congr_right] /-- If `P` is a sheaf for the sieve `S` on `X`, a natural transformation from `S` (viewed as a functor) to `P` can be (uniquely) extended to all of `yoneda.obj X`. f S → P ↓ ↗ yX -/ noncomputable def IsSheafFor.extend {P : Cᵒᵖ ⥤ Type v₁} (h : IsSheafFor P (S : Presieve X)) (f : S.functor ⟶ P) : yoneda.obj X ⟶ P := (isSheafFor_iff_yonedaSheafCondition.1 h f).exists.choose /-- Show that the extension of `f : S.functor ⟶ P` to all of `yoneda.obj X` is in fact an extension, ie that the triangle below commutes, provided `P` is a sheaf for `S` f S → P ↓ ↗ yX -/ @[reassoc (attr := simp)] theorem IsSheafFor.functorInclusion_comp_extend {P : Cᵒᵖ ⥤ Type v₁} (h : IsSheafFor P S) (f : S.functor ⟶ P) : S.functorInclusion ≫ h.extend f = f := (isSheafFor_iff_yonedaSheafCondition.1 h f).exists.choose_spec /-- The extension of `f` to `yoneda.obj X` is unique. -/ theorem IsSheafFor.unique_extend {P : Cᵒᵖ ⥤ Type v₁} (h : IsSheafFor P S) {f : S.functor ⟶ P} (t : yoneda.obj X ⟶ P) (ht : S.functorInclusion ≫ t = f) : t = h.extend f := (isSheafFor_iff_yonedaSheafCondition.1 h f).unique ht (h.functorInclusion_comp_extend f) /-- If `P` is a sheaf for the sieve `S` on `X`, then if two natural transformations from `yoneda.obj X` to `P` agree when restricted to the subfunctor given by `S`, they are equal. -/ theorem IsSheafFor.hom_ext {P : Cᵒᵖ ⥤ Type v₁} (h : IsSheafFor P (S : Presieve X)) (t₁ t₂ : yoneda.obj X ⟶ P) (ht : S.functorInclusion ≫ t₁ = S.functorInclusion ≫ t₂) : t₁ = t₂ := (h.unique_extend t₁ ht).trans (h.unique_extend t₂ rfl).symm /-- `P` is a sheaf for `R` iff it is separated for `R` and there exists an amalgamation. -/ theorem isSeparatedFor_and_exists_isAmalgamation_iff_isSheafFor : (IsSeparatedFor P R ∧ ∀ x : FamilyOfElements P R, x.Compatible → ∃ t, x.IsAmalgamation t) ↔ IsSheafFor P R := by rw [IsSeparatedFor, ← forall_and] apply forall_congr' intro x constructor · intro z hx exact exists_unique_of_exists_of_unique (z.2 hx) z.1 · intro h refine ⟨?_, ExistsUnique.exists ∘ h⟩ intro t₁ t₂ ht₁ ht₂ apply (h _).unique ht₁ ht₂ exact is_compatible_of_exists_amalgamation x ⟨_, ht₂⟩ /-- If `P` is separated for `R` and every family has an amalgamation, then `P` is a sheaf for `R`. -/ theorem IsSeparatedFor.isSheafFor (t : IsSeparatedFor P R) : (∀ x : FamilyOfElements P R, x.Compatible → ∃ t, x.IsAmalgamation t) → IsSheafFor P R := by rw [← isSeparatedFor_and_exists_isAmalgamation_iff_isSheafFor] exact And.intro t /-- If `P` is a sheaf for `R`, it is separated for `R`. -/ theorem IsSheafFor.isSeparatedFor : IsSheafFor P R → IsSeparatedFor P R := fun q => (isSeparatedFor_and_exists_isAmalgamation_iff_isSheafFor.2 q).1 /-- Get the amalgamation of the given compatible family, provided we have a sheaf. -/ noncomputable def IsSheafFor.amalgamate (t : IsSheafFor P R) (x : FamilyOfElements P R) (hx : x.Compatible) : P.obj (op X) := (t x hx).exists.choose theorem IsSheafFor.isAmalgamation (t : IsSheafFor P R) {x : FamilyOfElements P R} (hx : x.Compatible) : x.IsAmalgamation (t.amalgamate x hx) := (t x hx).exists.choose_spec @[simp] theorem IsSheafFor.valid_glue (t : IsSheafFor P R) {x : FamilyOfElements P R} (hx : x.Compatible) (f : Y ⟶ X) (Hf : R f) : P.map f.op (t.amalgamate x hx) = x f Hf := t.isAmalgamation hx f Hf /-- C2.1.3 in [Elephant] -/ theorem isSheafFor_iff_generate (R : Presieve X) : IsSheafFor P R ↔ IsSheafFor P (generate R : Presieve X) := by rw [← isSeparatedFor_and_exists_isAmalgamation_iff_isSheafFor] rw [← isSeparatedFor_and_exists_isAmalgamation_iff_isSheafFor] rw [← isSeparatedFor_iff_generate] apply and_congr (Iff.refl _) constructor · intro q x hx apply Exists.imp _ (q _ (hx.restrict (le_generate R))) intro t ht simpa [hx] using isAmalgamation_sieveExtend _ _ ht · intro q x hx apply Exists.imp _ (q _ hx.sieveExtend) intro t ht simpa [hx] using isAmalgamation_restrict (le_generate R) _ _ ht /-- Every presheaf is a sheaf for the family {𝟙 X}. [Elephant] C2.1.5(i) -/ theorem isSheafFor_singleton_iso (P : Cᵒᵖ ⥤ Type w) : IsSheafFor P (Presieve.singleton (𝟙 X)) := by intro x _ refine ⟨x _ (Presieve.singleton_self _), ?_, ?_⟩ · rintro _ _ ⟨rfl, rfl⟩ simp · intro t ht simpa using ht _ (Presieve.singleton_self _) /-- Every presheaf is a sheaf for the maximal sieve. [Elephant] C2.1.5(ii) -/ theorem isSheafFor_top_sieve (P : Cᵒᵖ ⥤ Type w) : IsSheafFor P ((⊤ : Sieve X) : Presieve X) := by rw [← generate_of_singleton_isSplitEpi (𝟙 X)] rw [← isSheafFor_iff_generate] apply isSheafFor_singleton_iso /-- If `P` is a sheaf for `S`, and it is iso to `P'`, then `P'` is a sheaf for `S`. This shows that "being a sheaf for a presieve" is a mathematical or hygienic property. -/ theorem isSheafFor_iso {P' : Cᵒᵖ ⥤ Type w} (i : P ≅ P') : IsSheafFor P R → IsSheafFor P' R := by intro h x hx let x' := x.compPresheafMap i.inv have : x'.Compatible := FamilyOfElements.Compatible.compPresheafMap i.inv hx obtain ⟨t, ht1, ht2⟩ := h x' this use i.hom.app _ t fconstructor · convert FamilyOfElements.IsAmalgamation.compPresheafMap i.hom ht1 simp [x'] · intro y hy rw [show y = (i.inv.app (op X) ≫ i.hom.app (op X)) y by simp] simp [ht2 (i.inv.app _ y) (FamilyOfElements.IsAmalgamation.compPresheafMap i.inv hy)] /-- If a presieve `R` on `X` has a subsieve `S` such that: * `P` is a sheaf for `S`. * For every `f` in `R`, `P` is separated for the pullback of `S` along `f`, then `P` is a sheaf for `R`. This is closely related to [Elephant] C2.1.6(i). -/ theorem isSheafFor_subsieve_aux (P : Cᵒᵖ ⥤ Type w) {S : Sieve X} {R : Presieve X} (h : (S : Presieve X) ≤ R) (hS : IsSheafFor P (S : Presieve X)) (trans : ∀ ⦃Y⦄ ⦃f : Y ⟶ X⦄, R f → IsSeparatedFor P (S.pullback f : Presieve Y)) : IsSheafFor P R := by rw [← isSeparatedFor_and_exists_isAmalgamation_iff_isSheafFor] constructor · intro x t₁ t₂ ht₁ ht₂ exact hS.isSeparatedFor _ _ _ (isAmalgamation_restrict h x t₁ ht₁) (isAmalgamation_restrict h x t₂ ht₂) · intro x hx use hS.amalgamate _ (hx.restrict h) intro W j hj apply (trans hj).ext intro Y f hf rw [← FunctorToTypes.map_comp_apply, ← op_comp, hS.valid_glue (hx.restrict h) _ hf, FamilyOfElements.restrict, ← hx (𝟙 _) f (h _ hf) _ (id_comp _)] simp /-- If `P` is a sheaf for every pullback of the sieve `S`, then `P` is a sheaf for any presieve which contains `S`. This is closely related to [Elephant] C2.1.6. -/ theorem isSheafFor_subsieve (P : Cᵒᵖ ⥤ Type w) {S : Sieve X} {R : Presieve X} (h : (S : Presieve X) ≤ R) (trans : ∀ ⦃Y⦄ (f : Y ⟶ X), IsSheafFor P (S.pullback f : Presieve Y)) : IsSheafFor P R := isSheafFor_subsieve_aux P h (by simpa using trans (𝟙 _)) fun Y f _ => (trans f).isSeparatedFor section Arrows variable {B : C} {I : Type*} {X : I → C} (π : (i : I) → X i ⟶ B) (P) /-- A more explicit version of `FamilyOfElements.Compatible` for a `Presieve.ofArrows`. -/ def Arrows.Compatible (x : (i : I) → P.obj (op (X i))) : Prop := ∀ i j Z (gi : Z ⟶ X i) (gj : Z ⟶ X j), gi ≫ π i = gj ≫ π j → P.map gi.op (x i) = P.map gj.op (x j) lemma FamilyOfElements.isAmalgamation_iff_ofArrows (x : FamilyOfElements P (ofArrows X π)) (t : P.obj (op B)) : x.IsAmalgamation t ↔ ∀ (i : I), P.map (π i).op t = x _ (ofArrows.mk i) := ⟨fun h i ↦ h _ (ofArrows.mk i), fun h _ f ⟨i⟩ ↦ h i⟩ namespace Arrows.Compatible variable {x : (i : I) → P.obj (op (X i))} variable {P π} theorem exists_familyOfElements (hx : Compatible P π x) : ∃ (x' : FamilyOfElements P (ofArrows X π)), ∀ (i : I), x' _ (ofArrows.mk i) = x i := by choose i h h' using @ofArrows_surj _ _ _ _ _ π exact ⟨fun Y f hf ↦ P.map (eqToHom (h f hf).symm).op (x _), fun j ↦ (hx _ j (X j) _ (𝟙 _) <| by rw [← h', id_comp]).trans <| by simp⟩ variable (hx : Compatible P π x) /-- A `FamilyOfElements` associated to an explicit family of elements. -/ noncomputable def familyOfElements : FamilyOfElements P (ofArrows X π) := (exists_familyOfElements hx).choose @[simp] theorem familyOfElements_ofArrows_mk (i : I) : hx.familyOfElements _ (ofArrows.mk i) = x i := (exists_familyOfElements hx).choose_spec _ theorem familyOfElements_compatible : hx.familyOfElements.Compatible := by rintro Y₁ Y₂ Z g₁ g₂ f₁ f₂ ⟨i⟩ ⟨j⟩ hgf simp [hx i j Z g₁ g₂ hgf] end Arrows.Compatible theorem isSheafFor_arrows_iff : (ofArrows X π).IsSheafFor P ↔ (∀ (x : (i : I) → P.obj (op (X i))), Arrows.Compatible P π x → ∃! t, ∀ i, P.map (π i).op t = x i) := by refine ⟨fun h x hx ↦ ?_, fun h x hx ↦ ?_⟩ · obtain ⟨t, ht₁, ht₂⟩ := h _ hx.familyOfElements_compatible refine ⟨t, fun i ↦ ?_, fun t' ht' ↦ ht₂ _ fun _ _ ⟨i⟩ ↦ ?_⟩ · rw [ht₁ _ (ofArrows.mk i), hx.familyOfElements_ofArrows_mk] · rw [ht', hx.familyOfElements_ofArrows_mk] · obtain ⟨t, hA, ht⟩ := h (fun i ↦ x (π i) (ofArrows.mk _)) (fun i j Z gi gj ↦ hx gi gj (ofArrows.mk _) (ofArrows.mk _)) exact ⟨t, fun Y f ⟨i⟩ ↦ hA i, fun y hy ↦ ht y (fun i ↦ hy (π i) (ofArrows.mk _))⟩ variable [(ofArrows X π).hasPullbacks] /-- A more explicit version of `FamilyOfElements.PullbackCompatible` for a `Presieve.ofArrows`. -/ def Arrows.PullbackCompatible (x : (i : I) → P.obj (op (X i))) : Prop := ∀ i j, P.map (pullback.fst (π i) (π j)).op (x i) = P.map (pullback.snd (π i) (π j)).op (x j) theorem Arrows.pullbackCompatible_iff (x : (i : I) → P.obj (op (X i))) : Compatible P π x ↔ PullbackCompatible P π x := by refine ⟨fun t i j ↦ ?_, fun t i j Z gi gj comm ↦ ?_⟩ · apply t exact pullback.condition · rw [← pullback.lift_fst _ _ comm, op_comp, FunctorToTypes.map_comp_apply, t i j, ← FunctorToTypes.map_comp_apply, ← op_comp, pullback.lift_snd] theorem isSheafFor_arrows_iff_pullbacks : (ofArrows X π).IsSheafFor P ↔ (∀ (x : (i : I) → P.obj (op (X i))), Arrows.PullbackCompatible P π x → ∃! t, ∀ i, P.map (π i).op t = x i) := by simp_rw [← Arrows.pullbackCompatible_iff, isSheafFor_arrows_iff] end Arrows end Presieve end CategoryTheory
CategoryTheory\Sites\IsSheafOneHypercover.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.Sites.OneHypercover /-! # Characterization of sheaves using 1-hypercovers In this file, given a Grothendieck topology `J` on a category `C`, we define a type `J.OneHypercoverFamily` of families of 1-hypercovers. When `H : J.OneHypercoverFamily`, we define a predicate `H.IsGenerating` which means that any covering sieve contains the sieve generated by the underlying covering of one of the 1-hypercovers in the family. If this holds, we show in `OneHypercoverFamily.isSheaf_iff` that a presheaf `P : Cᵒᵖ ⥤ A` is a sheaf iff for any 1-hypercover `E` in the family, the multifork `E.multifork P` is limit. There is a universe parameter `w` attached to `OneHypercoverFamily` and `OneHypercover`. This universe controls the "size" of the 1-hypercovers: the index types involved in the 1-hypercovers have to be in `Type w`. Then, we introduce a type class `GrothendieckTopology.IsGeneratedByOneHypercovers.{w} J` as an abbreviation for `OneHypercoverFamily.IsGenerating.{w} (J := J) ⊤`. We show that if `C : Type u` and `Category.{v} C`, then `GrothendieckTopology.IsGeneratedByOneHypercovers.{max u v} J` holds. ## TODO * Show that functors which preserve 1-hypercovers are continuous. * Refactor `DenseSubsite` using `1`-hypercovers. -/ universe w v v' u u' namespace CategoryTheory open Category Limits variable {C : Type u} [Category.{v} C] (J : GrothendieckTopology C) {A : Type u'} [Category.{v'} A] namespace GrothendieckTopology /-- A family of 1-hypercovers consists of the data of a predicate on `OneHypercover.{w} J X` for all `X`. -/ abbrev OneHypercoverFamily := ∀ ⦃X : C⦄, OneHypercover.{w} J X → Prop namespace OneHypercoverFamily variable {J} variable (H : OneHypercoverFamily.{w} J) /-- A family of 1-hypercovers generates the topology if any covering sieve contains the sieve generated by the underlying covering of one of these 1-hypercovers. See `OneHypercoverFamily.isSheaf_iff` for the characterization of sheaves. -/ class IsGenerating : Prop where le {X : C} (S : Sieve X) (hS : S ∈ J X) : ∃ (E : J.OneHypercover X) (_ : H E), E.sieve₀ ≤ S variable [H.IsGenerating] lemma exists_oneHypercover {X : C} (S : Sieve X) (hS : S ∈ J X) : ∃ (E : J.OneHypercover X) (_ : H E), E.sieve₀ ≤ S := IsGenerating.le _ hS variable (P : Cᵒᵖ ⥤ A) namespace IsSheafIff variable (hP : ∀ ⦃X : C⦄ (E : J.OneHypercover X) (_ : H E), Nonempty (IsLimit (E.multifork P))) lemma hom_ext {X : C} (S : Sieve X) (hS : S ∈ J X) {T : A} {x y : T ⟶ P.obj (Opposite.op X)} (h : ∀ ⦃Y : C⦄ (f : Y ⟶ X) (_ : S f), x ≫ P.map f.op = y ≫ P.map f.op) : x = y := by obtain ⟨E, hE, le⟩ := H.exists_oneHypercover S hS exact Multifork.IsLimit.hom_ext (hP E hE).some (fun j => h _ (le _ (Sieve.ofArrows_mk _ _ _))) variable {P H} variable {X : C} {S : Sieve X} {E : J.OneHypercover X} (hE : H E) (le : E.sieve₀ ≤ S) section variable (F : Multifork (Cover.index ⟨S, J.superset_covering le E.mem₀⟩ P)) /-- Auxiliary definition for `isLimit`. -/ noncomputable def lift : F.pt ⟶ P.obj (Opposite.op X) := Multifork.IsLimit.lift (hP E hE).some (fun i => F.ι ⟨_, E.f i, le _ (Sieve.ofArrows_mk _ _ _)⟩) (fun ⟨⟨i₁, i₂⟩, j⟩ => F.condition (Cover.Relation.mk { hf := le _ (Sieve.ofArrows_mk _ _ i₁) } { hf := le _ (Sieve.ofArrows_mk _ _ i₂) } { w := E.w j} )) @[reassoc] lemma fac' (i : E.I₀) : lift hP hE le F ≫ P.map (E.f i).op = F.ι ⟨_, E.f i, le _ (Sieve.ofArrows_mk _ _ _)⟩ := Multifork.IsLimit.fac (hP E hE).some _ _ i lemma fac {Y : C} (f : Y ⟶ X) (hf : S f) : lift hP hE le F ≫ P.map f.op = F.ι ⟨Y, f, hf⟩ := by apply hom_ext H P hP _ (J.pullback_stable f E.mem₀) intro Z g rintro ⟨T, a, b, hb, fac⟩ cases' hb with i rw [assoc, ← P.map_comp, ← op_comp, ← fac, op_comp, P.map_comp, fac'_assoc] exact F.condition (Cover.Relation.mk { hf := le _ (Sieve.ofArrows_mk _ _ _) } { hf := hf } { w := fac }) end /-- Auxiliary definition for `OneHypercoverFamily.isSheaf_iff`. -/ noncomputable def isLimit : IsLimit (Cover.multifork ⟨S, J.superset_covering le E.mem₀⟩ P) := Multifork.IsLimit.mk _ (fun F => lift hP hE le F) (fun F => by rintro ⟨Y, f, hf⟩ apply fac) (fun F m hm => by apply hom_ext H P hP S (J.superset_covering le E.mem₀) intro Y f hf rw [fac _ _ _ _ _ hf] exact hm ⟨_, _, hf⟩) end IsSheafIff lemma isSheaf_iff : Presheaf.IsSheaf J P ↔ ∀ ⦃X : C⦄ (E : J.OneHypercover X) (_ : H E), Nonempty (IsLimit (E.multifork P)) := by constructor · intro hP X E _ exact ⟨E.isLimitMultifork ⟨_, hP⟩⟩ · intro hP rw [Presheaf.isSheaf_iff_multifork] rintro X ⟨S, hS⟩ obtain ⟨E, hE, le⟩ := H.exists_oneHypercover S hS exact ⟨IsSheafIff.isLimit hP hE le⟩ end OneHypercoverFamily /-- Condition that a topology is generated by 1-hypercovers of size `w`. -/ abbrev IsGeneratedByOneHypercovers : Prop := OneHypercoverFamily.IsGenerating.{w} (J := J) ⊤ instance : IsGeneratedByOneHypercovers.{max u v} J where le S hS := ⟨Cover.oneHypercover ⟨S, hS⟩, by simp, by simp⟩ end GrothendieckTopology namespace Presheaf lemma isSheaf_iff_of_isGeneratedByOneHypercovers [GrothendieckTopology.IsGeneratedByOneHypercovers.{w} J] (P : Cᵒᵖ ⥤ A) : IsSheaf J P ↔ ∀ ⦃X : C⦄ (E : GrothendieckTopology.OneHypercover.{w} J X), Nonempty (IsLimit (E.multifork P)) := by simpa using GrothendieckTopology.OneHypercoverFamily.isSheaf_iff.{w} ⊤ P end Presheaf end CategoryTheory
CategoryTheory\Sites\LeftExact.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.Sites.Limits import Mathlib.CategoryTheory.Limits.FilteredColimitCommutesFiniteLimit import Mathlib.CategoryTheory.Adhesive import Mathlib.CategoryTheory.Sites.ConcreteSheafification /-! # Left exactness of sheafification In this file we show that sheafification commutes with finite limits. -/ open CategoryTheory Limits Opposite universe w' w v u variable {C : Type u} [Category.{v} C] {J : GrothendieckTopology C} noncomputable section namespace CategoryTheory.GrothendieckTopology variable {D : Type w} [Category.{max v u} D] variable [∀ (P : Cᵒᵖ ⥤ D) (X : C) (S : J.Cover X), HasMultiequalizer (S.index P)] /-- An auxiliary definition to be used in the proof of the fact that `J.diagramFunctor D X` preserves limits. -/ @[simps] def coneCompEvaluationOfConeCompDiagramFunctorCompEvaluation {X : C} {K : Type max v u} [SmallCategory K] {F : K ⥤ Cᵒᵖ ⥤ D} {W : J.Cover X} (i : W.Arrow) (E : Cone (F ⋙ J.diagramFunctor D X ⋙ (evaluation (J.Cover X)ᵒᵖ D).obj (op W))) : Cone (F ⋙ (evaluation _ _).obj (op i.Y)) where pt := E.pt π := { app := fun k => E.π.app k ≫ Multiequalizer.ι (W.index (F.obj k)) i naturality := by intro a b f dsimp rw [Category.id_comp, Category.assoc, ← E.w f] dsimp [diagramNatTrans] simp only [Multiequalizer.lift_ι, Category.assoc] } /-- An auxiliary definition to be used in the proof of the fact that `J.diagramFunctor D X` preserves limits. -/ abbrev liftToDiagramLimitObj {X : C} {K : Type max v u} [SmallCategory K] [HasLimitsOfShape K D] {W : (J.Cover X)ᵒᵖ} (F : K ⥤ Cᵒᵖ ⥤ D) (E : Cone (F ⋙ J.diagramFunctor D X ⋙ (evaluation (J.Cover X)ᵒᵖ D).obj W)) : E.pt ⟶ (J.diagram (limit F) X).obj W := Multiequalizer.lift ((unop W).index (limit F)) E.pt (fun i => (isLimitOfPreserves ((evaluation Cᵒᵖ D).obj (op i.Y)) (limit.isLimit F)).lift (coneCompEvaluationOfConeCompDiagramFunctorCompEvaluation.{w, v, u} i E)) (by intro i change (_ ≫ _) ≫ _ = (_ ≫ _) ≫ _ dsimp [evaluateCombinedCones] erw [Category.comp_id, Category.comp_id, Category.assoc, Category.assoc, ← (limit.lift F _).naturality, ← (limit.lift F _).naturality, ← Category.assoc, ← Category.assoc] congr 1 refine limit.hom_ext (fun j => ?_) erw [Category.assoc, Category.assoc, limit.lift_π, limit.lift_π, limit.lift_π_assoc, limit.lift_π_assoc, Category.assoc, Category.assoc, Multiequalizer.condition] rfl) instance preservesLimit_diagramFunctor (X : C) (K : Type max v u) [SmallCategory K] [HasLimitsOfShape K D] (F : K ⥤ Cᵒᵖ ⥤ D) : PreservesLimit F (J.diagramFunctor D X) := preservesLimitOfEvaluation _ _ fun W => preservesLimitOfPreservesLimitCone (limit.isLimit _) { lift := fun E => liftToDiagramLimitObj.{w, v, u} F E fac := by intro E k dsimp [diagramNatTrans] refine Multiequalizer.hom_ext _ _ _ (fun a => ?_) simp only [Multiequalizer.lift_ι, Multiequalizer.lift_ι_assoc, Category.assoc] change (_ ≫ _) ≫ _ = _ dsimp [evaluateCombinedCones] erw [Category.comp_id, Category.assoc, ← NatTrans.comp_app, limit.lift_π, limit.lift_π] rfl uniq := by intro E m hm refine Multiequalizer.hom_ext _ _ _ (fun a => limit_obj_ext (fun j => ?_)) delta liftToDiagramLimitObj erw [Multiequalizer.lift_ι, Category.assoc] change _ = (_ ≫ _) ≫ _ dsimp [evaluateCombinedCones] erw [Category.comp_id, Category.assoc, ← NatTrans.comp_app, limit.lift_π, limit.lift_π] dsimp rw [← hm] dsimp [diagramNatTrans] simp } instance preservesLimitsOfShape_diagramFunctor (X : C) (K : Type max v u) [SmallCategory K] [HasLimitsOfShape K D] : PreservesLimitsOfShape K (J.diagramFunctor D X) := ⟨by apply preservesLimit_diagramFunctor.{w, v, u}⟩ instance preservesLimits_diagramFunctor (X : C) [HasLimits D] : PreservesLimits (J.diagramFunctor D X) := by constructor intro _ _ apply preservesLimitsOfShape_diagramFunctor.{w, v, u} variable [∀ X : C, HasColimitsOfShape (J.Cover X)ᵒᵖ D] variable [ConcreteCategory.{max v u} D] variable [∀ X : C, PreservesColimitsOfShape (J.Cover X)ᵒᵖ (forget D)] /-- An auxiliary definition to be used in the proof that `J.plusFunctor D` commutes with finite limits. -/ def liftToPlusObjLimitObj {K : Type max v u} [SmallCategory K] [FinCategory K] [HasLimitsOfShape K D] [PreservesLimitsOfShape K (forget D)] [ReflectsLimitsOfShape K (forget D)] (F : K ⥤ Cᵒᵖ ⥤ D) (X : C) (S : Cone (F ⋙ J.plusFunctor D ⋙ (evaluation Cᵒᵖ D).obj (op X))) : S.pt ⟶ (J.plusObj (limit F)).obj (op X) := let e := colimitLimitIso (F ⋙ J.diagramFunctor D X) let t : J.diagram (limit F) X ≅ limit (F ⋙ J.diagramFunctor D X) := (isLimitOfPreserves (J.diagramFunctor D X) (limit.isLimit F)).conePointUniqueUpToIso (limit.isLimit _) let p : (J.plusObj (limit F)).obj (op X) ≅ colimit (limit (F ⋙ J.diagramFunctor D X)) := HasColimit.isoOfNatIso t let s : colimit (F ⋙ J.diagramFunctor D X).flip ≅ F ⋙ J.plusFunctor D ⋙ (evaluation Cᵒᵖ D).obj (op X) := NatIso.ofComponents (fun k => colimitObjIsoColimitCompEvaluation _ k) (by intro i j f rw [← Iso.eq_comp_inv, Category.assoc, ← Iso.inv_comp_eq] refine colimit.hom_ext (fun w => ?_) dsimp [plusMap] erw [colimit.ι_map_assoc, colimitObjIsoColimitCompEvaluation_ι_inv (F ⋙ J.diagramFunctor D X).flip w j, colimitObjIsoColimitCompEvaluation_ι_inv_assoc (F ⋙ J.diagramFunctor D X).flip w i] rw [← (colimit.ι (F ⋙ J.diagramFunctor D X).flip w).naturality] rfl) limit.lift _ S ≫ (HasLimit.isoOfNatIso s.symm).hom ≫ e.inv ≫ p.inv -- This lemma should not be used directly. Instead, one should use the fact that -- `J.plusFunctor D` preserves finite limits, along with the fact that -- evaluation preserves limits. theorem liftToPlusObjLimitObj_fac {K : Type max v u} [SmallCategory K] [FinCategory K] [HasLimitsOfShape K D] [PreservesLimitsOfShape K (forget D)] [ReflectsLimitsOfShape K (forget D)] (F : K ⥤ Cᵒᵖ ⥤ D) (X : C) (S : Cone (F ⋙ J.plusFunctor D ⋙ (evaluation Cᵒᵖ D).obj (op X))) (k) : liftToPlusObjLimitObj.{w, v, u} F X S ≫ (J.plusMap (limit.π F k)).app (op X) = S.π.app k := by dsimp only [liftToPlusObjLimitObj] rw [← (limit.isLimit (F ⋙ J.plusFunctor D ⋙ (evaluation Cᵒᵖ D).obj (op X))).fac S k, Category.assoc] congr 1 dsimp rw [Category.assoc, Category.assoc, ← Iso.eq_inv_comp, Iso.inv_comp_eq, Iso.inv_comp_eq] refine colimit.hom_ext (fun j => ?_) dsimp [plusMap] simp only [HasColimit.isoOfNatIso_ι_hom_assoc, ι_colimMap] dsimp [IsLimit.conePointUniqueUpToIso, HasLimit.isoOfNatIso, IsLimit.map] rw [limit.lift_π] dsimp rw [ι_colimitLimitIso_limit_π_assoc] simp_rw [← Category.assoc, ← NatTrans.comp_app] rw [limit.lift_π, Category.assoc] congr 1 rw [← Iso.comp_inv_eq] erw [colimit.ι_desc] rfl instance preservesLimitsOfShape_plusFunctor (K : Type max v u) [SmallCategory K] [FinCategory K] [HasLimitsOfShape K D] [PreservesLimitsOfShape K (forget D)] [ReflectsLimitsOfShape K (forget D)] : PreservesLimitsOfShape K (J.plusFunctor D) := by constructor; intro F; apply preservesLimitOfEvaluation; intro X apply preservesLimitOfPreservesLimitCone (limit.isLimit F) refine ⟨fun S => liftToPlusObjLimitObj.{w, v, u} F X.unop S, ?_, ?_⟩ · intro S k apply liftToPlusObjLimitObj_fac · intro S m hm dsimp [liftToPlusObjLimitObj] simp_rw [← Category.assoc, Iso.eq_comp_inv, ← Iso.comp_inv_eq] refine limit.hom_ext (fun k => ?_) simp only [limit.lift_π, Category.assoc, ← hm] congr 1 refine colimit.hom_ext (fun k => ?_) dsimp [plusMap, plusObj] erw [colimit.ι_map, colimit.ι_desc_assoc, limit.lift_π] conv_lhs => dsimp simp only [Category.assoc] rw [ι_colimitLimitIso_limit_π_assoc] simp only [NatIso.ofComponents_inv_app, colimitObjIsoColimitCompEvaluation_ι_app_hom, Iso.symm_inv] conv_lhs => dsimp [IsLimit.conePointUniqueUpToIso] rw [← Category.assoc, ← NatTrans.comp_app, limit.lift_π] rfl instance preserveFiniteLimits_plusFunctor [HasFiniteLimits D] [PreservesFiniteLimits (forget D)] [(forget D).ReflectsIsomorphisms] : PreservesFiniteLimits (J.plusFunctor D) := by apply preservesFiniteLimitsOfPreservesFiniteLimitsOfSize.{max v u} intro K _ _ have : ReflectsLimitsOfShape K (forget D) := reflectsLimitsOfShapeOfReflectsIsomorphisms apply preservesLimitsOfShape_plusFunctor.{w, v, u} instance preservesLimitsOfShape_sheafification (K : Type max v u) [SmallCategory K] [FinCategory K] [HasLimitsOfShape K D] [PreservesLimitsOfShape K (forget D)] [ReflectsLimitsOfShape K (forget D)] : PreservesLimitsOfShape K (J.sheafification D) := Limits.compPreservesLimitsOfShape _ _ instance preservesFiniteLimits_sheafification [HasFiniteLimits D] [PreservesFiniteLimits (forget D)] [(forget D).ReflectsIsomorphisms] : PreservesFiniteLimits (J.sheafification D) := Limits.compPreservesFiniteLimits _ _ end CategoryTheory.GrothendieckTopology namespace CategoryTheory section variable {D : Type w} [Category.{max v u} D] variable [∀ (P : Cᵒᵖ ⥤ D) (X : C) (S : J.Cover X), HasMultiequalizer (S.index P)] variable [∀ X : C, HasColimitsOfShape (J.Cover X)ᵒᵖ D] variable [ConcreteCategory.{max v u} D] variable [∀ X : C, PreservesColimitsOfShape (J.Cover X)ᵒᵖ (forget D)] variable [PreservesLimits (forget D)] variable [(forget D).ReflectsIsomorphisms] variable (K : Type w') variable [SmallCategory K] [FinCategory K] [HasLimitsOfShape K D] instance preservesLimitsOfShape_presheafToSheaf : PreservesLimitsOfShape K (plusPlusSheaf J D) := by let e := (FinCategory.equivAsType K).symm.trans (AsSmall.equiv.{0, 0, max v u}) haveI : HasLimitsOfShape (AsSmall.{max v u} (FinCategory.AsType K)) D := Limits.hasLimitsOfShape_of_equivalence e haveI : FinCategory (AsSmall.{max v u} (FinCategory.AsType K)) := by constructor · show Fintype (ULift _) infer_instance · intro j j' show Fintype (ULift _) infer_instance refine @preservesLimitsOfShapeOfEquiv _ _ _ _ _ _ _ _ e.symm _ (show _ from ?_) constructor; intro F; constructor; intro S hS apply isLimitOfReflects (sheafToPresheaf J D) have : ReflectsLimitsOfShape (AsSmall.{max v u} (FinCategory.AsType K)) (forget D) := reflectsLimitsOfShapeOfReflectsIsomorphisms -- Porting note: the mathlib proof was by `apply is_limit_of_preserves (J.sheafification D) hS` have : PreservesLimitsOfShape (AsSmall.{max v u} (FinCategory.AsType K)) (plusPlusSheaf J D ⋙ sheafToPresheaf J D) := preservesLimitsOfShapeOfNatIso (J.sheafificationIsoPresheafToSheafCompSheafToPreasheaf D) exact isLimitOfPreserves (plusPlusSheaf J D ⋙ sheafToPresheaf J D) hS instance preservesfiniteLimits_presheafToSheaf [HasFiniteLimits D] : PreservesFiniteLimits (plusPlusSheaf J D) := by apply preservesFiniteLimitsOfPreservesFiniteLimitsOfSize.{max v u} intros infer_instance variable (J D) /-- `plusPlusSheaf` is isomorphic to an arbitrary choice of left adjoint. -/ def plusPlusSheafIsoPresheafToSheaf : plusPlusSheaf J D ≅ presheafToSheaf J D := (plusPlusAdjunction J D).leftAdjointUniq (sheafificationAdjunction J D) /-- `plusPlusFunctor` is isomorphic to `sheafification`. -/ def plusPlusFunctorIsoSheafification : J.sheafification D ≅ sheafification J D := isoWhiskerRight (plusPlusSheafIsoPresheafToSheaf J D) (sheafToPresheaf J D) /-- `plusPlus` is isomorphic to `sheafify`. -/ def plusPlusIsoSheafify (P : Cᵒᵖ ⥤ D) : J.sheafify P ≅ sheafify J P := (sheafToPresheaf J D).mapIso ((plusPlusSheafIsoPresheafToSheaf J D).app P) @[reassoc (attr := simp)] lemma toSheafify_plusPlusIsoSheafify_hom (P : Cᵒᵖ ⥤ D) : J.toSheafify P ≫ (plusPlusIsoSheafify J D P).hom = toSheafify J P := by convert Adjunction.unit_leftAdjointUniq_hom_app (plusPlusAdjunction J D) (sheafificationAdjunction J D) P ext1 P dsimp [GrothendieckTopology.toSheafify, plusPlusAdjunction] rw [Category.comp_id] instance [HasFiniteLimits D] : HasSheafify J D := HasSheafify.mk' J D (plusPlusAdjunction J D) end variable {D : Type w} [Category.{w'} D] instance [FinitaryExtensive D] [HasPullbacks D] [HasSheafify J D] : FinitaryExtensive (Sheaf J D) := finitaryExtensive_of_reflective (sheafificationAdjunction _ _) instance [Adhesive D] [HasPullbacks D] [HasPushouts D] [HasSheafify J D] : Adhesive (Sheaf J D) := adhesive_of_reflective (sheafificationAdjunction _ _) instance SheafOfTypes.finitary_extensive [HasSheafify J (Type w)] : FinitaryExtensive (Sheaf J (Type w)) := inferInstance instance SheafOfTypes.adhesive [HasSheafify J (Type w)] : Adhesive (Sheaf J (Type w)) := inferInstance instance SheafOfTypes.balanced [HasSheafify J (Type w)] : Balanced (Sheaf J (Type w)) := inferInstance end CategoryTheory
CategoryTheory\Sites\Limits.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.Limits.Creates import Mathlib.CategoryTheory.Sites.Sheafification import Mathlib.CategoryTheory.Limits.Shapes.FiniteProducts /-! # Limits and colimits of sheaves ## Limits We prove that the forgetful functor from `Sheaf J D` to presheaves creates limits. If the target category `D` has limits (of a certain shape), this then implies that `Sheaf J D` has limits of the same shape and that the forgetful functor preserves these limits. ## Colimits Given a diagram `F : K ⥤ Sheaf J D` of sheaves, and a colimit cocone on the level of presheaves, we show that the cocone obtained by sheafifying the cocone point is a colimit cocone of sheaves. This allows us to show that `Sheaf J D` has colimits (of a certain shape) as soon as `D` does. -/ namespace CategoryTheory namespace Sheaf open CategoryTheory.Limits open Opposite universe w w' v u z z' u₁ u₂ variable {C : Type u} [Category.{v} C] {J : GrothendieckTopology C} variable {D : Type w} [Category.{w'} D] variable {K : Type z} [Category.{z'} K] section Limits noncomputable section section /-- An auxiliary definition to be used below. Whenever `E` is a cone of shape `K` of sheaves, and `S` is the multifork associated to a covering `W` of an object `X`, with respect to the cone point `E.X`, this provides a cone of shape `K` of objects in `D`, with cone point `S.X`. See `isLimitMultiforkOfIsLimit` for more on how this definition is used. -/ def multiforkEvaluationCone (F : K ⥤ Sheaf J D) (E : Cone (F ⋙ sheafToPresheaf J D)) (X : C) (W : J.Cover X) (S : Multifork (W.index E.pt)) : Cone (F ⋙ sheafToPresheaf J D ⋙ (evaluation Cᵒᵖ D).obj (op X)) where pt := S.pt π := { app := fun k => (Presheaf.isLimitOfIsSheaf J (F.obj k).1 W (F.obj k).2).lift <| Multifork.ofι _ S.pt (fun i => S.ι i ≫ (E.π.app k).app (op i.Y)) (by intro i simp only [Category.assoc] erw [← (E.π.app k).naturality, ← (E.π.app k).naturality] dsimp simp only [← Category.assoc] congr 1 apply S.condition) naturality := by intro i j f dsimp [Presheaf.isLimitOfIsSheaf] rw [Category.id_comp] apply Presheaf.IsSheaf.hom_ext (F.obj j).2 W intro ii rw [Presheaf.IsSheaf.amalgamate_map, Category.assoc, ← (F.map f).val.naturality, ← Category.assoc, Presheaf.IsSheaf.amalgamate_map] dsimp [Multifork.ofι] erw [Category.assoc, ← E.w f] aesop_cat } variable [HasLimitsOfShape K D] /-- If `E` is a cone of shape `K` of sheaves, which is a limit on the level of presheaves, this definition shows that the limit presheaf satisfies the multifork variant of the sheaf condition, at a given covering `W`. This is used below in `isSheaf_of_isLimit` to show that the limit presheaf is indeed a sheaf. -/ def isLimitMultiforkOfIsLimit (F : K ⥤ Sheaf J D) (E : Cone (F ⋙ sheafToPresheaf J D)) (hE : IsLimit E) (X : C) (W : J.Cover X) : IsLimit (W.multifork E.pt) := Multifork.IsLimit.mk _ (fun S => (isLimitOfPreserves ((evaluation Cᵒᵖ D).obj (op X)) hE).lift <| multiforkEvaluationCone F E X W S) (by intro S i apply (isLimitOfPreserves ((evaluation Cᵒᵖ D).obj (op i.Y)) hE).hom_ext intro k dsimp [Multifork.ofι] erw [Category.assoc, (E.π.app k).naturality] dsimp rw [← Category.assoc] erw [(isLimitOfPreserves ((evaluation Cᵒᵖ D).obj (op X)) hE).fac (multiforkEvaluationCone F E X W S)] dsimp [multiforkEvaluationCone, Presheaf.isLimitOfIsSheaf] erw [Presheaf.IsSheaf.amalgamate_map] rfl) (by intro S m hm apply (isLimitOfPreserves ((evaluation Cᵒᵖ D).obj (op X)) hE).hom_ext intro k dsimp erw [(isLimitOfPreserves ((evaluation Cᵒᵖ D).obj (op X)) hE).fac] apply Presheaf.IsSheaf.hom_ext (F.obj k).2 W intro i dsimp only [multiforkEvaluationCone, Presheaf.isLimitOfIsSheaf] rw [(F.obj k).cond.amalgamate_map] dsimp [Multifork.ofι] change _ = S.ι i ≫ _ erw [← hm, Category.assoc, ← (E.π.app k).naturality, Category.assoc] rfl) /-- If `E` is a cone which is a limit on the level of presheaves, then the limit presheaf is again a sheaf. This is used to show that the forgetful functor from sheaves to presheaves creates limits. -/ theorem isSheaf_of_isLimit (F : K ⥤ Sheaf J D) (E : Cone (F ⋙ sheafToPresheaf J D)) (hE : IsLimit E) : Presheaf.IsSheaf J E.pt := by rw [Presheaf.isSheaf_iff_multifork] intro X S exact ⟨isLimitMultiforkOfIsLimit _ _ hE _ _⟩ instance (F : K ⥤ Sheaf J D) : CreatesLimit F (sheafToPresheaf J D) := createsLimitOfReflectsIso fun E hE => { liftedCone := ⟨⟨E.pt, isSheaf_of_isLimit _ _ hE⟩, ⟨fun t => ⟨E.π.app _⟩, fun u v e => Sheaf.Hom.ext <| E.π.naturality _⟩⟩ validLift := Cones.ext (eqToIso rfl) fun j => by dsimp simp makesLimit := { lift := fun S => ⟨hE.lift ((sheafToPresheaf J D).mapCone S)⟩ fac := fun S j => by ext1 apply hE.fac ((sheafToPresheaf J D).mapCone S) j uniq := fun S m hm => by ext1 exact hE.uniq ((sheafToPresheaf J D).mapCone S) m.val fun j => congr_arg Hom.val (hm j) } } instance createsLimitsOfShape : CreatesLimitsOfShape K (sheafToPresheaf J D) where instance : HasLimitsOfShape K (Sheaf J D) := hasLimitsOfShape_of_hasLimitsOfShape_createsLimitsOfShape (sheafToPresheaf J D) instance [HasFiniteProducts D] : HasFiniteProducts (Sheaf J D) := ⟨inferInstance⟩ instance [HasFiniteLimits D] : HasFiniteLimits (Sheaf J D) := ⟨fun _ ↦ inferInstance⟩ end instance createsLimits [HasLimitsOfSize.{u₁, u₂} D] : CreatesLimitsOfSize.{u₁, u₂} (sheafToPresheaf J D) := ⟨createsLimitsOfShape⟩ instance hasLimitsOfSize [HasLimitsOfSize.{u₁, u₂} D] : HasLimitsOfSize.{u₁, u₂} (Sheaf J D) := hasLimits_of_hasLimits_createsLimits (sheafToPresheaf J D) variable {D : Type w} [Category.{max v u} D] example [HasLimits D] : HasLimits (Sheaf J D) := inferInstance end end Limits section Colimits variable [HasWeakSheafify J D] /-- Construct a cocone by sheafifying a cocone point of a cocone `E` of presheaves over a functor which factors through sheaves. In `isColimitSheafifyCocone`, we show that this is a colimit cocone when `E` is a colimit. -/ noncomputable def sheafifyCocone {F : K ⥤ Sheaf J D} (E : Cocone (F ⋙ sheafToPresheaf J D)) : Cocone F := (Cocones.precompose (isoWhiskerLeft F (asIso (sheafificationAdjunction J D).counit).symm).hom).obj ((presheafToSheaf J D).mapCocone E) /-- If `E` is a colimit cocone of presheaves, over a diagram factoring through sheaves, then `sheafifyCocone E` is a colimit cocone. -/ noncomputable def isColimitSheafifyCocone {F : K ⥤ Sheaf J D} (E : Cocone (F ⋙ sheafToPresheaf J D)) (hE : IsColimit E) : IsColimit (sheafifyCocone E) := (IsColimit.precomposeHomEquiv _ ((presheafToSheaf J D).mapCocone E)).symm (isColimitOfPreserves _ hE) instance [HasColimitsOfShape K D] : HasColimitsOfShape K (Sheaf J D) := ⟨fun _ => HasColimit.mk ⟨sheafifyCocone (colimit.cocone _), isColimitSheafifyCocone _ (colimit.isColimit _)⟩⟩ instance [HasFiniteCoproducts D] : HasFiniteCoproducts (Sheaf J D) := ⟨inferInstance⟩ instance [HasFiniteColimits D] : HasFiniteColimits (Sheaf J D) := ⟨fun _ ↦ inferInstance⟩ instance [HasColimitsOfSize.{u₁, u₂} D] : HasColimitsOfSize.{u₁, u₂} (Sheaf J D) := ⟨inferInstance⟩ variable {D : Type w} [Category.{max v u} D] example [HasLimits D] : HasLimits (Sheaf J D) := inferInstance end Colimits end Sheaf end CategoryTheory
CategoryTheory\Sites\Localization.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.Localization.Bousfield import Mathlib.CategoryTheory.Sites.Sheafification /-! # The sheaf category as a localized category In this file, it is shown that the category of sheaves `Sheaf J A` is a localization of the category `Presheaf J A` with respect to the class `J.W` of morphisms of presheaves which become isomorphisms after applying the sheafification functor. -/ namespace CategoryTheory open Localization variable {C : Type*} [Category C] (J : GrothendieckTopology C) {A : Type*} [Category A] namespace GrothendieckTopology /-- The class of morphisms of presheaves which become isomorphisms after sheafification. (See `GrothendieckTopology.W_iff`.) -/ abbrev W : MorphismProperty (Cᵒᵖ ⥤ A) := LeftBousfield.W (Presheaf.IsSheaf J) variable (A) in lemma W_eq_W_range_sheafToPresheaf_obj : J.W = LeftBousfield.W (· ∈ Set.range (sheafToPresheaf J A).obj) := by apply congr_arg ext P constructor · intro hP exact ⟨⟨P, hP⟩, rfl⟩ · rintro ⟨F, rfl⟩ exact F.cond lemma W_sheafToPreheaf_map_iff_isIso {F₁ F₂ : Sheaf J A} (φ : F₁ ⟶ F₂) : J.W ((sheafToPresheaf J A).map φ) ↔ IsIso φ := by rw [W_eq_W_range_sheafToPresheaf_obj, LeftBousfield.W_iff_isIso _ _ ⟨_, rfl⟩ ⟨_, rfl⟩, isIso_iff_of_reflects_iso] section Adjunction variable {G : (Cᵒᵖ ⥤ A) ⥤ Sheaf J A} lemma W_adj_unit_app (adj : G ⊣ sheafToPresheaf J A) (P : Cᵒᵖ ⥤ A) : J.W (adj.unit.app P) := by rw [W_eq_W_range_sheafToPresheaf_obj] exact LeftBousfield.W_adj_unit_app adj P lemma W_iff_isIso_map_of_adjunction (adj : G ⊣ sheafToPresheaf J A) {P₁ P₂ : Cᵒᵖ ⥤ A} (f : P₁ ⟶ P₂) : J.W f ↔ IsIso (G.map f) := by rw [W_eq_W_range_sheafToPresheaf_obj] exact LeftBousfield.W_iff_isIso_map adj f lemma W_eq_inverseImage_isomorphisms_of_adjunction (adj : G ⊣ sheafToPresheaf J A) : J.W = (MorphismProperty.isomorphisms _).inverseImage G := by rw [W_eq_W_range_sheafToPresheaf_obj, LeftBousfield.W_eq_inverseImage_isomorphisms adj] end Adjunction section HasWeakSheafify variable [HasWeakSheafify J A] lemma W_toSheafify (P : Cᵒᵖ ⥤ A) : J.W (toSheafify J P) := J.W_adj_unit_app (sheafificationAdjunction J A) P lemma W_iff {P₁ P₂ : Cᵒᵖ ⥤ A} (f : P₁ ⟶ P₂) : J.W f ↔ IsIso ((presheafToSheaf J A).map f) := J.W_iff_isIso_map_of_adjunction (sheafificationAdjunction J A) f variable (A) in lemma W_eq_inverseImage_isomorphisms : J.W = (MorphismProperty.isomorphisms _).inverseImage (presheafToSheaf J A) := J.W_eq_inverseImage_isomorphisms_of_adjunction (sheafificationAdjunction J A) instance : (presheafToSheaf J A).IsLocalization J.W := by rw [W_eq_inverseImage_isomorphisms] exact (sheafificationAdjunction J A).isLocalization end HasWeakSheafify end GrothendieckTopology end CategoryTheory
CategoryTheory\Sites\LocallyBijective.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.Sites.LocallySurjective import Mathlib.CategoryTheory.Sites.Localization /-! # Locally bijective morphisms of presheaves Let `C` a be category equipped with a Grothendieck topology `J`. Let `A` be a concrete category. In this file, we introduce a type-class `J.WEqualsLocallyBijective A` which says that the class `J.W` (of morphisms of presheaves which become isomorphisms after sheafification) is the class of morphisms that are both locally injective and locally surjective (i.e. locally bijective). We prove that this holds iff for any presheaf `P : Cᵒᵖ ⥤ A`, the sheafification map `toSheafify J P` is locally bijective. We show that this holds under certain universe assumptions. -/ universe w' w v' v u' u namespace CategoryTheory variable {C : Type u} [Category.{v} C] {J : GrothendieckTopology C} {A : Type u'} [Category.{v'} A] [ConcreteCategory.{w} A] namespace Sheaf section variable {F G : Sheaf J (Type w)} (f : F ⟶ G) /-- A morphism of sheaves of types is locally bijective iff it is an isomorphism. (This is generalized below as `isLocallyBijective_iff_isIso`.) -/ private lemma isLocallyBijective_iff_isIso' : IsLocallyInjective f ∧ IsLocallySurjective f ↔ IsIso f := by constructor · rintro ⟨h₁, _⟩ rw [isLocallyInjective_iff_injective] at h₁ suffices ∀ (X : Cᵒᵖ), Function.Surjective (f.val.app X) by rw [← isIso_iff_of_reflects_iso _ (sheafToPresheaf _ _), NatTrans.isIso_iff_isIso_app] intro X rw [isIso_iff_bijective] exact ⟨h₁ X, this X⟩ intro X s have H := (isSheaf_iff_isSheaf_of_type J F.val).1 F.cond _ (Presheaf.imageSieve_mem J f.val s) let t : Presieve.FamilyOfElements F.val (Presheaf.imageSieve f.val s).arrows := fun Y g hg => Presheaf.localPreimage f.val s g hg have ht : t.Compatible := by intro Y₁ Y₂ W g₁ g₂ f₁ f₂ hf₁ hf₂ w apply h₁ have eq₁ := FunctorToTypes.naturality _ _ f.val g₁.op (t f₁ hf₁) have eq₂ := FunctorToTypes.naturality _ _ f.val g₂.op (t f₂ hf₂) have eq₃ := congr_arg (G.val.map g₁.op) (Presheaf.app_localPreimage f.val s _ hf₁) have eq₄ := congr_arg (G.val.map g₂.op) (Presheaf.app_localPreimage f.val s _ hf₂) refine eq₁.trans (eq₃.trans (Eq.trans ?_ (eq₄.symm.trans eq₂.symm))) erw [← FunctorToTypes.map_comp_apply, ← FunctorToTypes.map_comp_apply] simp only [← op_comp, w] refine ⟨H.amalgamate t ht, ?_⟩ · apply (Presieve.isSeparated_of_isSheaf _ _ ((isSheaf_iff_isSheaf_of_type J G.val).1 G.cond) _ (Presheaf.imageSieve_mem J f.val s)).ext intro Y g hg rw [← FunctorToTypes.naturality, H.valid_glue ht] exact Presheaf.app_localPreimage f.val s g hg · intro constructor <;> infer_instance end section variable {F G : Sheaf J A} (f : F ⟶ G) [(forget A).ReflectsIsomorphisms] [J.HasSheafCompose (forget A)] lemma isLocallyBijective_iff_isIso : IsLocallyInjective f ∧ IsLocallySurjective f ↔ IsIso f := by constructor · rintro ⟨_, _⟩ rw [← isIso_iff_of_reflects_iso f (sheafCompose J (forget A)), ← isLocallyBijective_iff_isIso'] constructor <;> infer_instance · intro constructor <;> infer_instance end end Sheaf variable (J A) namespace GrothendieckTopology /-- Given a category `C` equipped with a Grothendieck topology `J` and a concrete category `A`, this property holds if a morphism in `Cᵒᵖ ⥤ A` satisfies `J.W` (i.e. becomes an iso after sheafification) iff it is both locally injective and locally surjective. -/ class WEqualsLocallyBijective : Prop where iff {X Y : Cᵒᵖ ⥤ A} (f : X ⟶ Y) : J.W f ↔ Presheaf.IsLocallyInjective J f ∧ Presheaf.IsLocallySurjective J f section variable {A} variable [J.WEqualsLocallyBijective A] {X Y : Cᵒᵖ ⥤ A} (f : X ⟶ Y) lemma W_iff_isLocallyBijective : J.W f ↔ Presheaf.IsLocallyInjective J f ∧ Presheaf.IsLocallySurjective J f := by apply WEqualsLocallyBijective.iff lemma W_of_isLocallyBijective [Presheaf.IsLocallyInjective J f] [Presheaf.IsLocallySurjective J f] : J.W f := by rw [W_iff_isLocallyBijective] constructor <;> infer_instance variable {J f} lemma W.isLocallyInjective (hf : J.W f) : Presheaf.IsLocallyInjective J f := ((J.W_iff_isLocallyBijective f).1 hf).1 lemma W.isLocallySurjective (hf : J.W f) : Presheaf.IsLocallySurjective J f := ((J.W_iff_isLocallyBijective f).1 hf).2 variable [HasWeakSheafify J A] (P : Cᵒᵖ ⥤ A) instance : Presheaf.IsLocallyInjective J (CategoryTheory.toSheafify J P) := (J.W_toSheafify P).isLocallyInjective instance : Presheaf.IsLocallySurjective J (CategoryTheory.toSheafify J P) := (J.W_toSheafify P).isLocallySurjective end lemma WEqualsLocallyBijective.mk' [HasWeakSheafify J A] [(forget A).ReflectsIsomorphisms] [J.HasSheafCompose (forget A)] [∀ (P : Cᵒᵖ ⥤ A), Presheaf.IsLocallyInjective J (CategoryTheory.toSheafify J P)] [∀ (P : Cᵒᵖ ⥤ A), Presheaf.IsLocallySurjective J (CategoryTheory.toSheafify J P)] : J.WEqualsLocallyBijective A where iff {P Q} f := by rw [W_iff, ← Sheaf.isLocallyBijective_iff_isIso, ← Presheaf.isLocallyInjective_comp_iff J f (CategoryTheory.toSheafify J Q), ← Presheaf.isLocallySurjective_comp_iff J f (CategoryTheory.toSheafify J Q), CategoryTheory.toSheafify_naturality, Presheaf.comp_isLocallyInjective_iff, Presheaf.comp_isLocallySurjective_iff] instance {D : Type w} [Category.{w'} D] [ConcreteCategory.{max u v} D] [HasWeakSheafify J D] [J.HasSheafCompose (forget D)] [J.PreservesSheafification (forget D)] [(forget D).ReflectsIsomorphisms] : J.WEqualsLocallyBijective D := by apply WEqualsLocallyBijective.mk' instance : J.WEqualsLocallyBijective (Type (max u v)) := inferInstance end GrothendieckTopology namespace Presheaf variable {A} variable [HasWeakSheafify J A] [J.WEqualsLocallyBijective A] {P Q : Cᵒᵖ ⥤ A} (φ : P ⟶ Q) lemma isLocallyInjective_presheafToSheaf_map_iff : Sheaf.IsLocallyInjective ((presheafToSheaf J A).map φ) ↔ IsLocallyInjective J φ := by rw [← Sheaf.isLocallyInjective_sheafToPresheaf_map_iff, ← isLocallyInjective_comp_iff J _ (toSheafify J Q), ← comp_isLocallyInjective_iff J (toSheafify J P), toSheafify_naturality, sheafToPresheaf_map] lemma isLocallySurjective_presheafToSheaf_map_iff : Sheaf.IsLocallySurjective ((presheafToSheaf J A).map φ) ↔ IsLocallySurjective J φ := by rw [← Sheaf.isLocallySurjective_sheafToPresheaf_map_iff, ← isLocallySurjective_comp_iff J _ (toSheafify J Q), ← comp_isLocallySurjective_iff J (toSheafify J P), toSheafify_naturality, sheafToPresheaf_map] end Presheaf end CategoryTheory
CategoryTheory\Sites\LocallyFullyFaithful.lean
/- Copyright (c) 2024 Andrew Yang. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Andrew Yang -/ import Mathlib.CategoryTheory.Sites.LocallySurjective /-! # Locally fully faithful functors into sites ## Main results - `CategoryTheory.Functor.IsLocallyFull`: A functor `G : C ⥤ D` is locally full wrt a topology on `D` if for every `f : G.obj U ⟶ G.obj V`, the set of `G.map fᵢ : G.obj Wᵢ ⟶ G.obj U` such that `G.map fᵢ ≫ f` is in the image of `G` is a coverage of the topology on `D`. - `CategoryTheory.Functor.IsLocallyFaithful`: A functor `G : C ⥤ D` is locally faithful wrt a topology on `D` if for every `f₁ f₂ : U ⟶ V` whose image in `D` are equal, the set of `G.map gᵢ : G.obj Wᵢ ⟶ G.obj U` such that `gᵢ ≫ f₁ = gᵢ ≫ f₂` is a coverage of the topology on `D`. ## References * [caramello2020]: Olivia Caramello, *Denseness conditions, morphisms and equivalences of toposes* -/ universe w vC vD uC uD namespace CategoryTheory variable {C : Type uC} [Category.{vC} C] {D : Type uD} [Category.{vD} D] (G : C ⥤ D) variable (J : GrothendieckTopology C) (K : GrothendieckTopology D) /-- For a functor `G : C ⥤ D`, and a morphism `f : G.obj U ⟶ G.obj V`, `Functor.imageSieve G f` is the sieve of `U` consisting of those arrows whose composition with `f` has a lift in `G`. This is the image sieve of `f` under `yonedaMap G V` and hence the name. See `Functor.imageSieve_eq_imageSieve`. -/ def Functor.imageSieve {U V : C} (f : G.obj U ⟶ G.obj V) : Sieve U where arrows Y i := ∃ l, G.map l = G.map i ≫ f downward_closed := by rintro Y₁ Y₂ i₁ ⟨l, hl⟩ i₂ exact ⟨i₂ ≫ l, by simp [hl]⟩ @[simp] lemma Functor.imageSieve_map {U V : C} (f : U ⟶ V) : G.imageSieve (G.map f) = ⊤ := by ext W g; simpa using ⟨g ≫ f, by simp⟩ /-- For two arrows `f₁ f₂ : U ⟶ V`, the arrows `i` such that `i ≫ f₁ = i ≫ f₂` forms a sieve. -/ @[simps] def Sieve.equalizer {U V : C} (f₁ f₂ : U ⟶ V) : Sieve U where arrows Y i := i ≫ f₁ = i ≫ f₂ downward_closed := by aesop @[simp] lemma Sieve.equalizer_self {U V : C} (f : U ⟶ V) : equalizer f f = ⊤ := by ext; simp lemma Sieve.equalizer_eq_equalizerSieve {U V : C} (f₁ f₂ : U ⟶ V) : Sieve.equalizer f₁ f₂ = Presheaf.equalizerSieve (F := yoneda.obj _) f₁ f₂ := rfl lemma Functor.imageSieve_eq_imageSieve {D : Type uD} [Category.{vC} D] (G : C ⥤ D) {U V : C} (f : G.obj U ⟶ G.obj V) : G.imageSieve f = Presheaf.imageSieve (yonedaMap G V) f := rfl open Presieve Opposite namespace Functor /-- A functor `G : C ⥤ D` is locally full wrt a topology on `D` if for every `f : G.obj U ⟶ G.obj V`, the set of `G.map fᵢ : G.obj Wᵢ ⟶ G.obj U` such that `G.map fᵢ ≫ f` is in the image of `G` is a coverage of the topology on `D`. -/ class IsLocallyFull : Prop where functorPushforward_imageSieve_mem : ∀ {U V} (f : G.obj U ⟶ G.obj V), (G.imageSieve f).functorPushforward G ∈ K _ /-- A functor `G : C ⥤ D` is locally faithful wrt a topology on `D` if for every `f₁ f₂ : U ⟶ V` whose image in `D` are equal, the set of `G.map gᵢ : G.obj Wᵢ ⟶ G.obj U` such that `gᵢ ≫ f₁ = gᵢ ≫ f₂` is a coverage of the topology on `D`. -/ class IsLocallyFaithful : Prop where functorPushforward_equalizer_mem : ∀ {U V : C} (f₁ f₂ : U ⟶ V), G.map f₁ = G.map f₂ → (Sieve.equalizer f₁ f₂).functorPushforward G ∈ K _ lemma functorPushforward_imageSieve_mem [G.IsLocallyFull K] {U V} (f : G.obj U ⟶ G.obj V) : (G.imageSieve f).functorPushforward G ∈ K _ := Functor.IsLocallyFull.functorPushforward_imageSieve_mem _ lemma functorPushforward_equalizer_mem [G.IsLocallyFaithful K] {U V} (f₁ f₂ : U ⟶ V) (e : G.map f₁ = G.map f₂) : (Sieve.equalizer f₁ f₂).functorPushforward G ∈ K _ := Functor.IsLocallyFaithful.functorPushforward_equalizer_mem _ _ e variable {K} variable {A : Type*} [Category A] (G : C ⥤ D) theorem IsLocallyFull.ext [G.IsLocallyFull K] (ℱ : SheafOfTypes K) {X Y : C} (i : G.obj X ⟶ G.obj Y) {s t : ℱ.val.obj (op (G.obj X))} (h : ∀ ⦃Z : C⦄ (j : Z ⟶ X) (f : Z ⟶ Y), G.map f = G.map j ≫ i → ℱ.1.map (G.map j).op s = ℱ.1.map (G.map j).op t) : s = t := by apply (ℱ.cond _ (G.functorPushforward_imageSieve_mem K i)).isSeparatedFor.ext rintro Z _ ⟨W, iWX, iZW, ⟨iWY, e⟩, rfl⟩ simp [h iWX iWY e] theorem IsLocallyFaithful.ext [G.IsLocallyFaithful K] (ℱ : SheafOfTypes K) {X Y : C} (i₁ i₂ : X ⟶ Y) (e : G.map i₁ = G.map i₂) {s t : ℱ.val.obj (op (G.obj X))} (h : ∀ ⦃Z : C⦄ (j : Z ⟶ X), j ≫ i₁ = j ≫ i₂ → ℱ.1.map (G.map j).op s = ℱ.1.map (G.map j).op t) : s = t := by apply (ℱ.cond _ (G.functorPushforward_equalizer_mem K i₁ i₂ e)).isSeparatedFor.ext rintro Z _ ⟨W, iWX, iZW, hiWX, rfl⟩ simp [h iWX hiWX] instance (priority := 900) IsLocallyFull.of_full [G.Full] : G.IsLocallyFull K where functorPushforward_imageSieve_mem f := by rw [← G.map_preimage f] simp only [Functor.imageSieve_map, Sieve.functorPushforward_top, GrothendieckTopology.top_mem] instance (priority := 900) IsLocallyFaithful.of_faithful [G.Faithful] : G.IsLocallyFaithful K where functorPushforward_equalizer_mem f₁ f₂ e := by obtain rfl := G.map_injective e; simp end CategoryTheory.Functor
CategoryTheory\Sites\LocallyInjective.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.Sites.LeftExact import Mathlib.CategoryTheory.Sites.PreservesSheafification import Mathlib.CategoryTheory.Sites.Subsheaf import Mathlib.CategoryTheory.Sites.Whiskering /-! # Locally injective morphisms of (pre)sheaves Let `C` be a category equipped with a Grothendieck topology `J`, and let `D` be a concrete category. In this file, we introduce the typeclass `Presheaf.IsLocallyInjective J φ` for a morphism `φ : F₁ ⟶ F₂` in the category `Cᵒᵖ ⥤ D`. This means that `φ` is locally injective. More precisely, if `x` and `y` are two elements of some `F₁.obj U` such the images of `x` and `y` in `F₂.obj U` coincide, then the equality `x = y` must hold locally, i.e. after restriction by the maps of a covering sieve. -/ universe w v' v u' u namespace CategoryTheory open Opposite Limits variable {C : Type u} [Category.{v} C] {D : Type u'} [Category.{v'} D] [ConcreteCategory.{w} D] (J : GrothendieckTopology C) attribute [local instance] ConcreteCategory.hasCoeToSort ConcreteCategory.instFunLike namespace Presheaf /-- If `F : Cᵒᵖ ⥤ D` is a presheaf with values in a concrete category, if `x` and `y` are elements in `F.obj X`, this is the sieve of `X.unop` consisting of morphisms `f` such that `F.map f.op x = F.map f.op y`. -/ @[simps] def equalizerSieve {F : Cᵒᵖ ⥤ D} {X : Cᵒᵖ} (x y : F.obj X) : Sieve X.unop where arrows _ f := F.map f.op x = F.map f.op y downward_closed {X Y} f hf g := by dsimp at hf ⊢ simp [hf] @[simp] lemma equalizerSieve_self_eq_top {F : Cᵒᵖ ⥤ D} {X : Cᵒᵖ} (x : F.obj X) : equalizerSieve x x = ⊤ := by aesop @[simp] lemma equalizerSieve_eq_top_iff {F : Cᵒᵖ ⥤ D} {X : Cᵒᵖ} (x y : F.obj X) : equalizerSieve x y = ⊤ ↔ x = y := by constructor · intro h simpa using (show equalizerSieve x y (𝟙 _) by simp [h]) · rintro rfl apply equalizerSieve_self_eq_top variable {F₁ F₂ F₃ : Cᵒᵖ ⥤ D} (φ : F₁ ⟶ F₂) (ψ : F₂ ⟶ F₃) /-- A morphism `φ : F₁ ⟶ F₂` of presheaves `Cᵒᵖ ⥤ D` (with `D` a concrete category) is locally injective for a Grothendieck topology `J` on `C` if whenever two sections of `F₁` are sent to the same section of `F₂`, then these two sections coincide locally. -/ class IsLocallyInjective : Prop where equalizerSieve_mem {X : Cᵒᵖ} (x y : F₁.obj X) (h : φ.app X x = φ.app X y) : equalizerSieve x y ∈ J X.unop lemma equalizerSieve_mem [IsLocallyInjective J φ] {X : Cᵒᵖ} (x y : F₁.obj X) (h : φ.app X x = φ.app X y) : equalizerSieve x y ∈ J X.unop := IsLocallyInjective.equalizerSieve_mem x y h lemma isLocallyInjective_of_injective (hφ : ∀ (X : Cᵒᵖ), Function.Injective (φ.app X)) : IsLocallyInjective J φ where equalizerSieve_mem {X} x y h := by convert J.top_mem X.unop ext Y f simp only [equalizerSieve_apply, op_unop, Sieve.top_apply, iff_true] apply hφ simp [h] instance [IsIso φ] : IsLocallyInjective J φ := isLocallyInjective_of_injective J φ (fun X => Function.Bijective.injective (by rw [← isIso_iff_bijective] change IsIso ((forget D).map (φ.app X)) infer_instance)) instance isLocallyInjective_forget [IsLocallyInjective J φ] : IsLocallyInjective J (whiskerRight φ (forget D)) where equalizerSieve_mem x y h := equalizerSieve_mem J φ x y h lemma isLocallyInjective_forget_iff : IsLocallyInjective J (whiskerRight φ (forget D)) ↔ IsLocallyInjective J φ := by constructor · intro exact ⟨fun x y h => equalizerSieve_mem J (whiskerRight φ (forget D)) x y h⟩ · intro infer_instance lemma isLocallyInjective_iff_equalizerSieve_mem_imp : IsLocallyInjective J φ ↔ ∀ ⦃X : Cᵒᵖ⦄ (x y : F₁.obj X), equalizerSieve (φ.app _ x) (φ.app _ y) ∈ J X.unop → equalizerSieve x y ∈ J X.unop := by constructor · intro _ X x y h let S := equalizerSieve (φ.app _ x) (φ.app _ y) let T : ∀ ⦃Y : C⦄ ⦃f : Y ⟶ X.unop⦄ (_ : S f), Sieve Y := fun Y f _ => equalizerSieve (F₁.map f.op x) ((F₁.map f.op y)) refine J.superset_covering ?_ (J.transitive h (Sieve.bind S.1 T) ?_) · rintro Y f ⟨Z, a, g, hg, ha, rfl⟩ simpa using ha · intro Y f hf refine J.superset_covering (Sieve.le_pullback_bind S.1 T _ hf) (equalizerSieve_mem J φ _ _ ?_) erw [NatTrans.naturality_apply, NatTrans.naturality_apply] exact hf · intro hφ exact ⟨fun {X} x y h => hφ x y (by simp [h])⟩ lemma equalizerSieve_mem_of_equalizerSieve_app_mem {X : Cᵒᵖ} (x y : F₁.obj X) (h : equalizerSieve (φ.app _ x) (φ.app _ y) ∈ J X.unop) [IsLocallyInjective J φ] : equalizerSieve x y ∈ J X.unop := (isLocallyInjective_iff_equalizerSieve_mem_imp J φ).1 inferInstance x y h instance isLocallyInjective_comp [IsLocallyInjective J φ] [IsLocallyInjective J ψ] : IsLocallyInjective J (φ ≫ ψ) where equalizerSieve_mem {X} x y h := by apply equalizerSieve_mem_of_equalizerSieve_app_mem J φ exact equalizerSieve_mem J ψ _ _ (by simpa using h) lemma isLocallyInjective_of_isLocallyInjective [IsLocallyInjective J (φ ≫ ψ)] : IsLocallyInjective J φ where equalizerSieve_mem {X} x y h := equalizerSieve_mem J (φ ≫ ψ) x y (by simp [h]) variable {φ ψ} lemma isLocallyInjective_of_isLocallyInjective_fac {φψ : F₁ ⟶ F₃} (fac : φ ≫ ψ = φψ) [IsLocallyInjective J φψ] : IsLocallyInjective J φ := by subst fac exact isLocallyInjective_of_isLocallyInjective J φ ψ lemma isLocallyInjective_iff_of_fac {φψ : F₁ ⟶ F₃} (fac : φ ≫ ψ = φψ) [IsLocallyInjective J ψ] : IsLocallyInjective J φψ ↔ IsLocallyInjective J φ := by constructor · intro exact isLocallyInjective_of_isLocallyInjective_fac J fac · intro rw [← fac] infer_instance variable (φ ψ) lemma isLocallyInjective_comp_iff [IsLocallyInjective J ψ] : IsLocallyInjective J (φ ≫ ψ) ↔ IsLocallyInjective J φ := isLocallyInjective_iff_of_fac J rfl lemma isLocallyInjective_iff_injective_of_separated (hsep : Presieve.IsSeparated J (F₁ ⋙ forget D)) : IsLocallyInjective J φ ↔ ∀ (X : Cᵒᵖ), Function.Injective (φ.app X) := by constructor · intro _ X x y h exact (hsep _ (equalizerSieve_mem J φ x y h)).ext (fun _ _ hf => hf) · apply isLocallyInjective_of_injective instance (F : Cᵒᵖ ⥤ Type w) (G : GrothendieckTopology.Subpresheaf F) : IsLocallyInjective J G.ι := isLocallyInjective_of_injective _ _ (fun X => by intro ⟨x, _⟩ ⟨y, _⟩ h exact Subtype.ext h) section open GrothendieckTopology.Plus instance isLocallyInjective_toPlus (P : Cᵒᵖ ⥤ Type max u v) : IsLocallyInjective J (J.toPlus P) where equalizerSieve_mem {X} x y h := by erw [toPlus_eq_mk, toPlus_eq_mk, eq_mk_iff_exists] at h obtain ⟨W, h₁, h₂, eq⟩ := h exact J.superset_covering (fun Y f hf => congr_fun (congr_arg Subtype.val eq) ⟨Y, f, hf⟩) W.2 instance isLocallyInjective_toSheafify (P : Cᵒᵖ ⥤ Type max u v) : IsLocallyInjective J (J.toSheafify P) := by dsimp [GrothendieckTopology.toSheafify] rw [GrothendieckTopology.plusMap_toPlus] infer_instance instance isLocallyInjective_toSheafify' [ConcreteCategory.{max u v} D] (P : Cᵒᵖ ⥤ D) [HasWeakSheafify J D] [J.HasSheafCompose (forget D)] [J.PreservesSheafification (forget D)] : IsLocallyInjective J (toSheafify J P) := by rw [← isLocallyInjective_forget_iff, ← sheafComposeIso_hom_fac, ← toSheafify_plusPlusIsoSheafify_hom] infer_instance end end Presheaf namespace Sheaf variable {J} variable {F₁ F₂ : Sheaf J D} (φ : F₁ ⟶ F₂) /-- If `φ : F₁ ⟶ F₂` is a morphism of sheaves, this is an abbreviation for `Presheaf.IsLocallyInjective J φ.val`. Under suitable assumptions, it is equivalent to the injectivity of all maps `φ.val.app X`, see `isLocallyInjective_iff_injective`. -/ abbrev IsLocallyInjective := Presheaf.IsLocallyInjective J φ.val lemma isLocallyInjective_sheafToPresheaf_map_iff : Presheaf.IsLocallyInjective J ((sheafToPresheaf J D).map φ) ↔ IsLocallyInjective φ := by rfl instance isLocallyInjective_of_iso [IsIso φ] : IsLocallyInjective φ := by change Presheaf.IsLocallyInjective J ((sheafToPresheaf _ _).map φ) infer_instance variable [J.HasSheafCompose (forget D)] instance isLocallyInjective_forget [IsLocallyInjective φ] : IsLocallyInjective ((sheafCompose J (forget D)).map φ) := Presheaf.isLocallyInjective_forget J φ.1 lemma isLocallyInjective_iff_injective : IsLocallyInjective φ ↔ ∀ (X : Cᵒᵖ), Function.Injective (φ.val.app X) := Presheaf.isLocallyInjective_iff_injective_of_separated _ _ (by apply Presieve.isSeparated_of_isSheaf rw [← isSheaf_iff_isSheaf_of_type] exact ((sheafCompose J (forget D)).obj F₁).2) lemma mono_of_injective (hφ : ∀ (X : Cᵒᵖ), Function.Injective (φ.val.app X)) : Mono φ := have := fun X ↦ ConcreteCategory.mono_of_injective _ (hφ X) (sheafToPresheaf _ _).mono_of_mono_map (NatTrans.mono_of_mono_app φ.1) lemma mono_of_isLocallyInjective [IsLocallyInjective φ] : Mono φ := by apply mono_of_injective rw [← isLocallyInjective_iff_injective] infer_instance instance {F G : Sheaf J (Type w)} (f : F ⟶ G) : IsLocallyInjective (GrothendieckTopology.imageSheafι f) := by dsimp [GrothendieckTopology.imageSheafι] infer_instance end Sheaf end CategoryTheory
CategoryTheory\Sites\LocallySurjective.lean
/- Copyright (c) 2022 Andrew Yang. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Andrew Yang, Joël Riou -/ import Mathlib.CategoryTheory.Sites.Subsheaf import Mathlib.CategoryTheory.Sites.CompatibleSheafification import Mathlib.CategoryTheory.Sites.LocallyInjective /-! # Locally surjective morphisms ## Main definitions - `IsLocallySurjective` : A morphism of presheaves valued in a concrete category is locally surjective with respect to a Grothendieck topology if every section in the target is locally in the set-theoretic image, i.e. the image sheaf coincides with the target. ## Main results - `Presheaf.isLocallySurjective_toSheafify`: `toSheafify` is locally surjective. - `Sheaf.isLocallySurjective_iff_epi`: a morphism of sheaves of types is locally surjective iff it is epi -/ universe v u w v' u' w' open Opposite CategoryTheory CategoryTheory.GrothendieckTopology namespace CategoryTheory variable {C : Type u} [Category.{v} C] (J : GrothendieckTopology C) attribute [local instance] ConcreteCategory.hasCoeToSort ConcreteCategory.instFunLike variable {A : Type u'} [Category.{v'} A] [ConcreteCategory.{w'} A] namespace Presheaf /-- Given `f : F ⟶ G`, a morphism between presieves, and `s : G.obj (op U)`, this is the sieve of `U` consisting of the `i : V ⟶ U` such that `s` restricted along `i` is in the image of `f`. -/ @[simps (config := .lemmasOnly)] def imageSieve {F G : Cᵒᵖ ⥤ A} (f : F ⟶ G) {U : C} (s : G.obj (op U)) : Sieve U where arrows V i := ∃ t : F.obj (op V), f.app _ t = G.map i.op s downward_closed := by rintro V W i ⟨t, ht⟩ j refine ⟨F.map j.op t, ?_⟩ rw [op_comp, G.map_comp, comp_apply, ← ht, elementwise_of% f.naturality] theorem imageSieve_eq_sieveOfSection {F G : Cᵒᵖ ⥤ A} (f : F ⟶ G) {U : C} (s : G.obj (op U)) : imageSieve f s = (imagePresheaf (whiskerRight f (forget A))).sieveOfSection s := rfl theorem imageSieve_whisker_forget {F G : Cᵒᵖ ⥤ A} (f : F ⟶ G) {U : C} (s : G.obj (op U)) : imageSieve (whiskerRight f (forget A)) s = imageSieve f s := rfl theorem imageSieve_app {F G : Cᵒᵖ ⥤ A} (f : F ⟶ G) {U : C} (s : F.obj (op U)) : imageSieve f (f.app _ s) = ⊤ := by ext V i simp only [Sieve.top_apply, iff_true_iff, imageSieve_apply] have := elementwise_of% (f.naturality i.op) exact ⟨F.map i.op s, this s⟩ /-- If a morphism `g : V ⟶ U.unop` belongs to the sieve `imageSieve f s g`, then this is choice of a preimage of `G.map g.op s` in `F.obj (op V)`, see `app_localPreimage`.-/ noncomputable def localPreimage {F G : Cᵒᵖ ⥤ A} (f : F ⟶ G) {U : Cᵒᵖ} (s : G.obj U) {V : C} (g : V ⟶ U.unop) (hg : imageSieve f s g) : F.obj (op V) := hg.choose @[simp] lemma app_localPreimage {F G : Cᵒᵖ ⥤ A} (f : F ⟶ G) {U : Cᵒᵖ} (s : G.obj U) {V : C} (g : V ⟶ U.unop) (hg : imageSieve f s g) : f.app _ (localPreimage f s g hg) = G.map g.op s := hg.choose_spec /-- A morphism of presheaves `f : F ⟶ G` is locally surjective with respect to a grothendieck topology if every section of `G` is locally in the image of `f`. -/ class IsLocallySurjective {F G : Cᵒᵖ ⥤ A} (f : F ⟶ G) : Prop where imageSieve_mem {U : C} (s : G.obj (op U)) : imageSieve f s ∈ J U lemma imageSieve_mem {F G : Cᵒᵖ ⥤ A} (f : F ⟶ G) [IsLocallySurjective J f] {U : Cᵒᵖ} (s : G.obj U) : imageSieve f s ∈ J U.unop := IsLocallySurjective.imageSieve_mem _ instance {F G : Cᵒᵖ ⥤ A} (f : F ⟶ G) [IsLocallySurjective J f] : IsLocallySurjective J (whiskerRight f (forget A)) where imageSieve_mem s := imageSieve_mem J f s theorem isLocallySurjective_iff_imagePresheaf_sheafify_eq_top {F G : Cᵒᵖ ⥤ A} (f : F ⟶ G) : IsLocallySurjective J f ↔ (imagePresheaf (whiskerRight f (forget A))).sheafify J = ⊤ := by simp only [Subpresheaf.ext_iff, Function.funext_iff, Set.ext_iff, top_subpresheaf_obj, Set.top_eq_univ, Set.mem_univ, iff_true_iff] exact ⟨fun H _ => H.imageSieve_mem, fun H => ⟨H _⟩⟩ theorem isLocallySurjective_iff_imagePresheaf_sheafify_eq_top' {F G : Cᵒᵖ ⥤ Type w} (f : F ⟶ G) : IsLocallySurjective J f ↔ (imagePresheaf f).sheafify J = ⊤ := by apply isLocallySurjective_iff_imagePresheaf_sheafify_eq_top theorem isLocallySurjective_iff_whisker_forget {F G : Cᵒᵖ ⥤ A} (f : F ⟶ G) : IsLocallySurjective J f ↔ IsLocallySurjective J (whiskerRight f (forget A)) := by simp only [isLocallySurjective_iff_imagePresheaf_sheafify_eq_top] rfl theorem isLocallySurjective_of_surjective {F G : Cᵒᵖ ⥤ A} (f : F ⟶ G) (H : ∀ U, Function.Surjective (f.app U)) : IsLocallySurjective J f where imageSieve_mem {U} s := by obtain ⟨t, rfl⟩ := H _ s rw [imageSieve_app] exact J.top_mem _ instance isLocallySurjective_of_iso {F G : Cᵒᵖ ⥤ A} (f : F ⟶ G) [IsIso f] : IsLocallySurjective J f := by apply isLocallySurjective_of_surjective intro U apply Function.Bijective.surjective rw [← isIso_iff_bijective, ← forget_map_eq_coe] infer_instance instance isLocallySurjective_comp {F₁ F₂ F₃ : Cᵒᵖ ⥤ A} (f₁ : F₁ ⟶ F₂) (f₂ : F₂ ⟶ F₃) [IsLocallySurjective J f₁] [IsLocallySurjective J f₂] : IsLocallySurjective J (f₁ ≫ f₂) where imageSieve_mem s := by have : (Sieve.bind (imageSieve f₂ s) fun _ _ h => imageSieve f₁ h.choose) ≤ imageSieve (f₁ ≫ f₂) s := by rintro V i ⟨W, i, j, H, ⟨t', ht'⟩, rfl⟩ refine ⟨t', ?_⟩ rw [op_comp, F₃.map_comp, NatTrans.comp_app, comp_apply, comp_apply, ht', elementwise_of% f₂.naturality, H.choose_spec] apply J.superset_covering this apply J.bind_covering · apply imageSieve_mem · intros; apply imageSieve_mem lemma isLocallySurjective_of_isLocallySurjective {F₁ F₂ F₃ : Cᵒᵖ ⥤ A} (f₁ : F₁ ⟶ F₂) (f₂ : F₂ ⟶ F₃) [IsLocallySurjective J (f₁ ≫ f₂)] : IsLocallySurjective J f₂ where imageSieve_mem {X} x := by refine J.superset_covering ?_ (imageSieve_mem J (f₁ ≫ f₂) x) intro Y g hg exact ⟨f₁.app _ (localPreimage (f₁ ≫ f₂) x g hg), by simpa using app_localPreimage (f₁ ≫ f₂) x g hg⟩ lemma isLocallySurjective_of_isLocallySurjective_fac {F₁ F₂ F₃ : Cᵒᵖ ⥤ A} {f₁ : F₁ ⟶ F₂} {f₂ : F₂ ⟶ F₃} {f₃ : F₁ ⟶ F₃} (fac : f₁ ≫ f₂ = f₃) [IsLocallySurjective J f₃] : IsLocallySurjective J f₂ := by subst fac exact isLocallySurjective_of_isLocallySurjective J f₁ f₂ lemma isLocallySurjective_iff_of_fac {F₁ F₂ F₃ : Cᵒᵖ ⥤ A} {f₁ : F₁ ⟶ F₂} {f₂ : F₂ ⟶ F₃} {f₃ : F₁ ⟶ F₃} (fac : f₁ ≫ f₂ = f₃) [IsLocallySurjective J f₁] : IsLocallySurjective J f₃ ↔ IsLocallySurjective J f₂ := by constructor · intro exact isLocallySurjective_of_isLocallySurjective_fac J fac · intro rw [← fac] infer_instance lemma comp_isLocallySurjective_iff {F₁ F₂ F₃ : Cᵒᵖ ⥤ A} (f₁ : F₁ ⟶ F₂) (f₂ : F₂ ⟶ F₃) [IsLocallySurjective J f₁] : IsLocallySurjective J (f₁ ≫ f₂) ↔ IsLocallySurjective J f₂ := isLocallySurjective_iff_of_fac J rfl variable {J} in lemma isLocallySurjective_of_le {K : GrothendieckTopology C} (hJK : J ≤ K) {F G : Cᵒᵖ ⥤ A} (f : F ⟶ G) (h : IsLocallySurjective J f) : IsLocallySurjective K f where imageSieve_mem s := by apply hJK; exact h.1 _ lemma isLocallyInjective_of_isLocallyInjective_of_isLocallySurjective {F₁ F₂ F₃ : Cᵒᵖ ⥤ A} (f₁ : F₁ ⟶ F₂) (f₂ : F₂ ⟶ F₃) [IsLocallyInjective J (f₁ ≫ f₂)] [IsLocallySurjective J f₁] : IsLocallyInjective J f₂ where equalizerSieve_mem {X} x₁ x₂ h := by let S := imageSieve f₁ x₁ ⊓ imageSieve f₁ x₂ have hS : S ∈ J X.unop := by apply J.intersection_covering all_goals apply imageSieve_mem let T : ∀ ⦃Y : C⦄ (f : Y ⟶ X.unop) (_ : S f), Sieve Y := fun Y f hf => equalizerSieve (localPreimage f₁ x₁ f hf.1) (localPreimage f₁ x₂ f hf.2) refine J.superset_covering ?_ (J.transitive hS (Sieve.bind S.1 T) ?_) · rintro Y f ⟨Z, a, g, hg, ha, rfl⟩ simpa using congr_arg (f₁.app _) ha · intro Y f hf apply J.superset_covering (Sieve.le_pullback_bind _ _ _ hf) apply equalizerSieve_mem J (f₁ ≫ f₂) dsimp rw [comp_apply, comp_apply, app_localPreimage, app_localPreimage, NatTrans.naturality_apply, NatTrans.naturality_apply, h] lemma isLocallyInjective_of_isLocallyInjective_of_isLocallySurjective_fac {F₁ F₂ F₃ : Cᵒᵖ ⥤ A} {f₁ : F₁ ⟶ F₂} {f₂ : F₂ ⟶ F₃} (f₃ : F₁ ⟶ F₃) (fac : f₁ ≫ f₂ = f₃) [IsLocallyInjective J f₃] [IsLocallySurjective J f₁] : IsLocallyInjective J f₂ := by subst fac exact isLocallyInjective_of_isLocallyInjective_of_isLocallySurjective J f₁ f₂ lemma isLocallySurjective_of_isLocallySurjective_of_isLocallyInjective {F₁ F₂ F₃ : Cᵒᵖ ⥤ A} (f₁ : F₁ ⟶ F₂) (f₂ : F₂ ⟶ F₃) [IsLocallySurjective J (f₁ ≫ f₂)] [IsLocallyInjective J f₂] : IsLocallySurjective J f₁ where imageSieve_mem {X} x := by let S := imageSieve (f₁ ≫ f₂) (f₂.app _ x) let T : ∀ ⦃Y : C⦄ (f : Y ⟶ X) (_ : S f), Sieve Y := fun Y f hf => equalizerSieve (f₁.app _ (localPreimage (f₁ ≫ f₂) (f₂.app _ x) f hf)) (F₂.map f.op x) refine J.superset_covering ?_ (J.transitive (imageSieve_mem J (f₁ ≫ f₂) (f₂.app _ x)) (Sieve.bind S.1 T) ?_) · rintro Y _ ⟨Z, a, g, hg, ha, rfl⟩ exact ⟨F₁.map a.op (localPreimage (f₁ ≫ f₂) _ _ hg), by simpa using ha⟩ · intro Y f hf apply J.superset_covering (Sieve.le_pullback_bind _ _ _ hf) apply equalizerSieve_mem J f₂ rw [NatTrans.naturality_apply, ← app_localPreimage (f₁ ≫ f₂) _ _ hf, NatTrans.comp_app, comp_apply] lemma isLocallySurjective_of_isLocallySurjective_of_isLocallyInjective_fac {F₁ F₂ F₃ : Cᵒᵖ ⥤ A} {f₁ : F₁ ⟶ F₂} {f₂ : F₂ ⟶ F₃} (f₃ : F₁ ⟶ F₃) (fac : f₁ ≫ f₂ = f₃) [IsLocallySurjective J f₃] [IsLocallyInjective J f₂] : IsLocallySurjective J f₁ := by subst fac exact isLocallySurjective_of_isLocallySurjective_of_isLocallyInjective J f₁ f₂ lemma comp_isLocallyInjective_iff {F₁ F₂ F₃ : Cᵒᵖ ⥤ A} (f₁ : F₁ ⟶ F₂) (f₂ : F₂ ⟶ F₃) [IsLocallyInjective J f₁] [IsLocallySurjective J f₁] : IsLocallyInjective J (f₁ ≫ f₂) ↔ IsLocallyInjective J f₂ := by constructor · intro exact isLocallyInjective_of_isLocallyInjective_of_isLocallySurjective J f₁ f₂ · intro infer_instance lemma isLocallySurjective_comp_iff {F₁ F₂ F₃ : Cᵒᵖ ⥤ A} (f₁ : F₁ ⟶ F₂) (f₂ : F₂ ⟶ F₃) [IsLocallyInjective J f₂] [IsLocallySurjective J f₂] : IsLocallySurjective J (f₁ ≫ f₂) ↔ IsLocallySurjective J f₁ := by constructor · intro exact isLocallySurjective_of_isLocallySurjective_of_isLocallyInjective J f₁ f₂ · intro infer_instance instance {F₁ F₂ : Cᵒᵖ ⥤ Type w} (f : F₁ ⟶ F₂) : IsLocallySurjective J (toImagePresheafSheafify J f) where imageSieve_mem {X} := by rintro ⟨s, hs⟩ refine J.superset_covering ?_ hs rintro Y g ⟨t, ht⟩ exact ⟨t, Subtype.ext ht⟩ /-- The image of `F` in `J.sheafify F` is isomorphic to the sheafification. -/ noncomputable def sheafificationIsoImagePresheaf (F : Cᵒᵖ ⥤ Type max u v) : J.sheafify F ≅ ((imagePresheaf (J.toSheafify F)).sheafify J).toPresheaf where hom := J.sheafifyLift (toImagePresheafSheafify J _) ((isSheaf_iff_isSheaf_of_type J _).mpr <| Subpresheaf.sheafify_isSheaf _ <| (isSheaf_iff_isSheaf_of_type J _).mp <| GrothendieckTopology.sheafify_isSheaf J _) inv := Subpresheaf.ι _ hom_inv_id := J.sheafify_hom_ext _ _ (J.sheafify_isSheaf _) (by simp [toImagePresheafSheafify]) inv_hom_id := by rw [← cancel_mono (Subpresheaf.ι _), Category.id_comp, Category.assoc] refine Eq.trans ?_ (Category.comp_id _) congr 1 exact J.sheafify_hom_ext _ _ (J.sheafify_isSheaf _) (by simp [toImagePresheafSheafify]) section open GrothendieckTopology.Plus instance isLocallySurjective_toPlus (P : Cᵒᵖ ⥤ Type max u v) : IsLocallySurjective J (J.toPlus P) where imageSieve_mem x := by obtain ⟨S, x, rfl⟩ := exists_rep x refine J.superset_covering (fun Y f hf => ⟨x.1 ⟨Y, f, hf⟩, ?_⟩) S.2 dsimp rw [toPlus_eq_mk, res_mk_eq_mk_pullback, eq_mk_iff_exists] refine ⟨S.pullback f, homOfLE le_top, 𝟙 _, ?_⟩ ext ⟨Z, g, hg⟩ simpa using x.2 (Cover.Relation.mk { hf := hf } { hf := S.1.downward_closed hf g } { g₁ := g, g₂ := 𝟙 Z }) instance isLocallySurjective_toSheafify (P : Cᵒᵖ ⥤ Type max u v) : IsLocallySurjective J (J.toSheafify P) := by dsimp [GrothendieckTopology.toSheafify] rw [GrothendieckTopology.plusMap_toPlus] infer_instance instance isLocallySurjective_toSheafify' {D : Type*} [Category D] [ConcreteCategory.{max u v} D] (P : Cᵒᵖ ⥤ D) [HasWeakSheafify J D] [J.HasSheafCompose (forget D)] [J.PreservesSheafification (forget D)] : IsLocallySurjective J (toSheafify J P) := by rw [isLocallySurjective_iff_whisker_forget, ← sheafComposeIso_hom_fac, ← toSheafify_plusPlusIsoSheafify_hom] infer_instance end end Presheaf namespace Sheaf variable {J} variable {F₁ F₂ F₃ : Sheaf J A} (φ : F₁ ⟶ F₂) (ψ : F₂ ⟶ F₃) /-- If `φ : F₁ ⟶ F₂` is a morphism of sheaves, this is an abbreviation for `Presheaf.IsLocallySurjective J φ.val`. -/ abbrev IsLocallySurjective := Presheaf.IsLocallySurjective J φ.val lemma isLocallySurjective_sheafToPresheaf_map_iff : Presheaf.IsLocallySurjective J ((sheafToPresheaf J A).map φ) ↔ IsLocallySurjective φ := by rfl instance isLocallySurjective_comp [IsLocallySurjective φ] [IsLocallySurjective ψ] : IsLocallySurjective (φ ≫ ψ) := Presheaf.isLocallySurjective_comp J φ.val ψ.val instance isLocallySurjective_of_iso [IsIso φ] : IsLocallySurjective φ := by have : IsIso φ.val := (inferInstance : IsIso ((sheafToPresheaf J A).map φ)) infer_instance instance {F G : Sheaf J (Type w)} (f : F ⟶ G) : IsLocallySurjective (toImageSheaf f) := by dsimp [toImageSheaf] infer_instance variable [J.HasSheafCompose (forget A)] instance [IsLocallySurjective φ] : IsLocallySurjective ((sheafCompose J (forget A)).map φ) := (Presheaf.isLocallySurjective_iff_whisker_forget J φ.val).1 inferInstance theorem isLocallySurjective_iff_isIso {F G : Sheaf J (Type w)} (f : F ⟶ G) : IsLocallySurjective f ↔ IsIso (imageSheafι f) := by dsimp only [IsLocallySurjective] rw [imageSheafι, Presheaf.isLocallySurjective_iff_imagePresheaf_sheafify_eq_top', Subpresheaf.eq_top_iff_isIso] exact isIso_iff_of_reflects_iso (f := imageSheafι f) (F := sheafToPresheaf J (Type w)) instance epi_of_isLocallySurjective' {F₁ F₂ : Sheaf J (Type w)} (φ : F₁ ⟶ F₂) [IsLocallySurjective φ] : Epi φ where left_cancellation {Z} f₁ f₂ h := by ext X x apply (Presieve.isSeparated_of_isSheaf J Z.1 ((isSheaf_iff_isSheaf_of_type _ _).1 Z.2) _ (Presheaf.imageSieve_mem J φ.val x)).ext rintro Y f ⟨s : F₁.val.obj (op Y), hs : φ.val.app _ s = F₂.val.map f.op x⟩ dsimp have h₁ := congr_fun (f₁.val.naturality f.op) x have h₂ := congr_fun (f₂.val.naturality f.op) x dsimp at h₁ h₂ rw [← h₁, ← h₂, ← hs] exact congr_fun (congr_app ((sheafToPresheaf J _).congr_map h) (op Y)) s instance epi_of_isLocallySurjective [IsLocallySurjective φ] : Epi φ := (sheafCompose J (forget A)).epi_of_epi_map inferInstance lemma isLocallySurjective_iff_epi {F G : Sheaf J (Type w)} (φ : F ⟶ G) [HasSheafify J (Type w)] : IsLocallySurjective φ ↔ Epi φ := by constructor · intro infer_instance · intro have := epi_of_epi_fac (toImageSheaf_ι φ) rw [isLocallySurjective_iff_isIso φ] apply isIso_of_mono_of_epi end Sheaf namespace Presieve.FamilyOfElements variable {R R' : Cᵒᵖ ⥤ Type w} (φ : R ⟶ R') {X : Cᵒᵖ} (r' : R'.obj X) /-- Given a morphism `φ : R ⟶ R'` of presheaves of types and `r' : R'.obj X`, this is the family of elements of `R` defined over the sieve `Presheaf.imageSieve φ r'` which sends a map in this sieve to an arbitrary choice of a preimage of the restriction of `r'`. -/ noncomputable def localPreimage : FamilyOfElements R (Presheaf.imageSieve φ r').arrows := fun _ f hf => Presheaf.localPreimage φ r' f hf lemma isAmalgamation_map_localPreimage : ((localPreimage φ r').map φ).IsAmalgamation r' := fun _ f hf => (Presheaf.app_localPreimage φ r' f hf).symm end Presieve.FamilyOfElements end CategoryTheory
CategoryTheory\Sites\MayerVietorisSquare.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.Pullback.Square import Mathlib.CategoryTheory.Limits.Shapes.Types import Mathlib.CategoryTheory.Sites.Sheafification /-! # Mayer-Vietoris squares The purpose of this file is to allow the formalization of long exact Mayer-Vietoris sequences in sheaf cohomology. If `X₄` is an open subset of a topological space that is covered by two open subsets `X₂` and `X₃`, it is known that there is a long exact sequence `... ⟶ H^q(X₄) ⟶ H^q(X₂) ⊞ H^q(X₃) ⟶ H^q(X₁) ⟶ H^{q+1}(X₄) ⟶ ...` where `X₁` is the intersection of `X₂` and `X₃`, and `H^q` are the cohomology groups with values in an abelian sheaf. In this file, we introduce a structure `GrothendieckTopology.MayerVietorisSquare` which extends `Square C`, and asserts properties which shall imply the existence of long exact Mayer-Vietoris sequences in sheaf cohomology (TODO). We require that the map `X₁ ⟶ X₃` is a monomorphism and that the square in `C` becomes a pushout square in the category of sheaves after the application of the functor `yoneda ⋙ presheafToSheaf J _`. Note that in the standard case of a covering by two open subsets, all the morphisms in the square would be monomorphisms, but this dissymetry allows the example of Nisnevich distinguished squares in the case of the Nisnevich topology on schemes (in which case `f₂₄ : X₂ ⟶ X₄` shall be an open immersion and `f₃₄ : X₃ ⟶ X₄` an étale map that is an isomorphism over the closed (reduced) subscheme `X₄ - X₂`, and `X₁` shall be the pullback of `f₂₄` and `f₃₄`.). ## TODO * show that when "evaluating" a sheaf on a Mayer-Vietoris square, one obtains a pullback square * provide constructors for `MayerVietorisSquare` ## References * https://stacks.math.columbia.edu/tag/08GL -/ universe v u namespace CategoryTheory namespace GrothendieckTopology variable {C : Type u} [Category.{v} C] (J : GrothendieckTopology C) [HasWeakSheafify J (Type v)] /-- A Mayer-Vietoris square in a category `C` equipped with a Grothendieck topology consists of a commutative square `f₁₂ ≫ f₂₄ = f₁₃ ≫ f₃₄` in `C` such that `f₁₃` is a monomorphism and that the square becomes a pushout square in the category of sheaves of sets. -/ structure MayerVietorisSquare extends Square C where mono_f₁₃ : Mono toSquare.f₁₃ := by infer_instance /-- the square becomes a pushout square in the category of sheaves of types -/ isPushout : (toSquare.map (yoneda ⋙ presheafToSheaf J _)).IsPushout end GrothendieckTopology end CategoryTheory
CategoryTheory\Sites\OneHypercover.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.Sites.Sheaf /-! # 1-hypercovers Given a Grothendieck topology `J` on a category `C`, we define the type of `1`-hypercovers of an object `S : C`. They consists of a covering family of morphisms `X i ⟶ S` indexed by a type `I₀` and, for each tuple `(i₁, i₂)` of elements of `I₀`, a "covering `Y j` of the fibre product of `X i₁` and `X i₂` over `S`", a condition which is phrased here without assuming that the fibre product actually exist. The definition `OneHypercover.isLimitMultifork` shows that if `E` is a `1`-hypercover of `S`, and `F` is a sheaf, then `F.obj (op S)` identifies to the multiequalizer of suitable maps `F.obj (op (E.X i)) ⟶ F.obj (op (E.Y j))`. -/ universe w v u namespace CategoryTheory open Category Limits variable {C : Type u} [Category.{v} C] {A : Type*} [Category A] /-- The categorical data that is involved in a `1`-hypercover of an object `S`. This consists of a family of morphisms `f i : X i ⟶ S` for `i : I₀`, and for each tuple `(i₁, i₂)` of elements in `I₀`, a family of objects `Y j` indexed by a type `I₁ i₁ i₂`, which are equipped with a map to the fibre product of `X i₁` and `X i₂`, which is phrased here as the data of the two projections `p₁ : Y j ⟶ X i₁`, `p₂ : Y j ⟶ X i₂` and the relation `p₁ j ≫ f i₁ = p₂ j ≫ f i₂`. (See `GrothendieckTopology.OneHypercover` for the topological conditions.) -/ structure PreOneHypercover (S : C) where /-- the index type of the covering of `S` -/ I₀ : Type w /-- the objects in the covering of `S` -/ X (i : I₀) : C /-- the morphisms in the covering of `S` -/ f (i : I₀) : X i ⟶ S /-- the index type of the coverings of the fibre products -/ I₁ (i₁ i₂ : I₀) : Type w /-- the objects in the coverings of the fibre products -/ Y ⦃i₁ i₂ : I₀⦄ (j : I₁ i₁ i₂) : C /-- the first projection `Y j ⟶ X i₁` -/ p₁ ⦃i₁ i₂ : I₀⦄ (j : I₁ i₁ i₂) : Y j ⟶ X i₁ /-- the second projection `Y j ⟶ X i₂` -/ p₂ ⦃i₁ i₂ : I₀⦄ (j : I₁ i₁ i₂) : Y j ⟶ X i₂ w ⦃i₁ i₂ : I₀⦄ (j : I₁ i₁ i₂) : p₁ j ≫ f i₁ = p₂ j ≫ f i₂ namespace PreOneHypercover variable {S : C} (E : PreOneHypercover.{w} S) /-- The assumption that the pullback of `X i₁` and `X i₂` over `S` exists for any `i₁` and `i₂`. -/ abbrev HasPullbacks := ∀ (i₁ i₂ : E.I₀), HasPullback (E.f i₁) (E.f i₂) /-- The sieve of `S` that is generated by the morphisms `f i : X i ⟶ S`. -/ abbrev sieve₀ : Sieve S := Sieve.ofArrows _ E.f /-- Given an object `W` equipped with morphisms `p₁ : W ⟶ E.X i₁`, `p₂ : W ⟶ E.X i₂`, this is the sieve of `W` which consists of morphisms `g : Z ⟶ W` such that there exists `j` and `h : Z ⟶ E.Y j` such that `g ≫ p₁ = h ≫ E.p₁ j` and `g ≫ p₂ = h ≫ E.p₂ j`. See lemmas `sieve₁_eq_pullback_sieve₁'` and `sieve₁'_eq_sieve₁` for equational lemmas regarding this sieve. -/ @[simps] def sieve₁ {i₁ i₂ : E.I₀} {W : C} (p₁ : W ⟶ E.X i₁) (p₂ : W ⟶ E.X i₂) : Sieve W where arrows Z g := ∃ (j : E.I₁ i₁ i₂) (h : Z ⟶ E.Y j), g ≫ p₁ = h ≫ E.p₁ j ∧ g ≫ p₂ = h ≫ E.p₂ j downward_closed := by rintro Z Z' g ⟨j, h, fac₁, fac₂⟩ φ exact ⟨j, φ ≫ h, by simpa using φ ≫= fac₁, by simpa using φ ≫= fac₂⟩ section variable {i₁ i₂ : E.I₀} [HasPullback (E.f i₁) (E.f i₂)] /-- The obvious morphism `E.Y j ⟶ pullback (E.f i₁) (E.f i₂)` given by `E : PreOneHypercover S`. -/ noncomputable abbrev toPullback (j : E.I₁ i₁ i₂) [HasPullback (E.f i₁) (E.f i₂)] : E.Y j ⟶ pullback (E.f i₁) (E.f i₂) := pullback.lift (E.p₁ j) (E.p₂ j) (E.w j) variable (i₁ i₂) in /-- The sieve of `pullback (E.f i₁) (E.f i₂)` given by `E : PreOneHypercover S`. -/ def sieve₁' : Sieve (pullback (E.f i₁) (E.f i₂)) := Sieve.ofArrows _ (fun (j : E.I₁ i₁ i₂) => E.toPullback j) lemma sieve₁_eq_pullback_sieve₁' {W : C} (p₁ : W ⟶ E.X i₁) (p₂ : W ⟶ E.X i₂) (w : p₁ ≫ E.f i₁ = p₂ ≫ E.f i₂) : E.sieve₁ p₁ p₂ = (E.sieve₁' i₁ i₂).pullback (pullback.lift _ _ w) := by ext Z g constructor · rintro ⟨j, h, fac₁, fac₂⟩ exact ⟨_, h, _, ⟨j⟩, by aesop_cat⟩ · rintro ⟨_, h, w, ⟨j⟩, fac⟩ exact ⟨j, h, by simpa using fac.symm =≫ pullback.fst _ _, by simpa using fac.symm =≫ pullback.snd _ _⟩ variable (i₁ i₂) in lemma sieve₁'_eq_sieve₁ : E.sieve₁' i₁ i₂ = E.sieve₁ (pullback.fst _ _) (pullback.snd _ _) := by rw [← Sieve.pullback_id (S := E.sieve₁' i₁ i₂), sieve₁_eq_pullback_sieve₁' _ _ _ pullback.condition] congr aesop_cat end /-- The sigma type of all `E.I₁ i₁ i₂` for `⟨i₁, i₂⟩ : E.I₀ × E.I₀`. -/ abbrev I₁' : Type w := Sigma (fun (i : E.I₀ × E.I₀) => E.I₁ i.1 i.2) /-- The diagram of the multifork attached to a presheaf `F : Cᵒᵖ ⥤ A`, `S : C` and `E : PreOneHypercover S`. -/ @[simps] def multicospanIndex (F : Cᵒᵖ ⥤ A) : MulticospanIndex A where L := E.I₀ R := E.I₁' fstTo j := j.1.1 sndTo j := j.1.2 left i := F.obj (Opposite.op (E.X i)) right j := F.obj (Opposite.op (E.Y j.2)) fst j := F.map ((E.p₁ j.2).op) snd j := F.map ((E.p₂ j.2).op) /-- The multifork attached to a presheaf `F : Cᵒᵖ ⥤ A`, `S : C` and `E : PreOneHypercover S`. -/ def multifork (F : Cᵒᵖ ⥤ A) : Multifork (E.multicospanIndex F) := Multifork.ofι _ (F.obj (Opposite.op S)) (fun i₀ => F.map (E.f i₀).op) (by rintro ⟨⟨i₁, i₂⟩, (j : E.I₁ i₁ i₂)⟩ dsimp simp only [← F.map_comp, ← op_comp, E.w]) end PreOneHypercover namespace GrothendieckTopology variable (J : GrothendieckTopology C) /-- The type of `1`-hypercovers of an object `S : C` in a category equipped with a Grothendieck topology `J`. This can be constructed from a covering of `S` and a covering of the fibre products of the objects in this covering (see `OneHypercover.mk'`). -/ structure OneHypercover (S : C) extends PreOneHypercover.{w} S where mem₀ : toPreOneHypercover.sieve₀ ∈ J S mem₁ (i₁ i₂ : I₀) ⦃W : C⦄ (p₁ : W ⟶ X i₁) (p₂ : W ⟶ X i₂) (w : p₁ ≫ f i₁ = p₂ ≫ f i₂) : toPreOneHypercover.sieve₁ p₁ p₂ ∈ J W variable {J} lemma OneHypercover.mem_sieve₁' {S : C} (E : J.OneHypercover S) (i₁ i₂ : E.I₀) [HasPullback (E.f i₁) (E.f i₂)] : E.sieve₁' i₁ i₂ ∈ J _ := by rw [E.sieve₁'_eq_sieve₁] exact mem₁ _ _ _ _ _ pullback.condition namespace OneHypercover /-- In order to check that a certain data is a `1`-hypercover of `S`, it suffices to check that the data provides a covering of `S` and of the fibre products. -/ @[simps toPreOneHypercover] def mk' {S : C} (E : PreOneHypercover S) [E.HasPullbacks] (mem₀ : E.sieve₀ ∈ J S) (mem₁' : ∀ (i₁ i₂ : E.I₀), E.sieve₁' i₁ i₂ ∈ J _) : J.OneHypercover S where toPreOneHypercover := E mem₀ := mem₀ mem₁ i₁ i₂ W p₁ p₂ w := by rw [E.sieve₁_eq_pullback_sieve₁' _ _ w] exact J.pullback_stable' _ (mem₁' i₁ i₂) section variable {S : C} (E : J.OneHypercover S) (F : Sheaf J A) section variable {E F} variable (c : Multifork (E.multicospanIndex F.val)) /-- Auxiliary definition of `isLimitMultifork`. -/ noncomputable def multiforkLift : c.pt ⟶ F.val.obj (Opposite.op S) := F.cond.amalgamateOfArrows _ E.mem₀ c.ι (fun W i₁ i₂ p₁ p₂ w => by apply F.cond.hom_ext ⟨_, E.mem₁ _ _ _ _ w⟩ rintro ⟨T, g, j, h, fac₁, fac₂⟩ dsimp simp only [assoc, ← Functor.map_comp, ← op_comp, fac₁, fac₂] simp only [op_comp, Functor.map_comp] simpa using c.condition ⟨⟨i₁, i₂⟩, j⟩ =≫ F.val.map h.op) @[reassoc] lemma multiforkLift_map (i₀ : E.I₀) : multiforkLift c ≫ F.val.map (E.f i₀).op = c.ι i₀ := by simp [multiforkLift] end /-- If `E : J.OneHypercover S` and `F : Sheaf J A`, then `F.obj (op S)` is a multiequalizer of suitable maps `F.obj (op (E.X i)) ⟶ F.obj (op (E.Y j))` induced by `E.p₁ j` and `E.p₂ j`. -/ noncomputable def isLimitMultifork : IsLimit (E.multifork F.1) := Multifork.IsLimit.mk _ (fun c => multiforkLift c) (fun c => multiforkLift_map c) (by intro c m hm apply F.cond.hom_ext_ofArrows _ E.mem₀ intro i₀ dsimp only rw [multiforkLift_map] exact hm i₀) end end OneHypercover namespace Cover variable {X : C} (S : J.Cover X) /-- The tautological 1-pre-hypercover induced by `S : J.Cover X`. Its index type `I₀` is given by `S.Arrow` (i.e. all the morphisms in the sieve `S`), while `I₁` is given by all possible pullback cones. -/ @[simps] def preOneHypercover : PreOneHypercover.{max u v} X where I₀ := S.Arrow X f := f.Y f f := f.f I₁ f₁ f₂ := f₁.Relation f₂ Y _ _ r := r.Z p₁ _ _ r := r.g₁ p₂ _ _ r := r.g₂ w _ _ r := r.w @[simp] lemma preOneHypercover_sieve₀ : S.preOneHypercover.sieve₀ = S.1 := by ext Y f constructor · rintro ⟨_, _, _, ⟨g⟩, rfl⟩ exact S.1.downward_closed g.hf _ · intro hf exact Sieve.ofArrows_mk _ _ ({ hf := hf } : S.Arrow) lemma preOneHypercover_sieve₁ (f₁ f₂ : S.Arrow) {W : C} (p₁ : W ⟶ f₁.Y) (p₂ : W ⟶ f₂.Y) (w : p₁ ≫ f₁.f = p₂ ≫ f₂.f) : S.preOneHypercover.sieve₁ p₁ p₂ = ⊤ := by ext Y f simp only [Sieve.top_apply, iff_true] exact ⟨{ w := w}, f, rfl, rfl⟩ /-- The tautological 1-hypercover induced by `S : J.Cover X`. Its index type `I₀` is given by `S.Arrow` (i.e. all the morphisms in the sieve `S`), while `I₁` is given by all possible pullback cones. -/ @[simps toPreOneHypercover] def oneHypercover : J.OneHypercover X where toPreOneHypercover := S.preOneHypercover mem₀ := by simp mem₁ f₁ f₂ _ p₁ p₂ w := by simp [S.preOneHypercover_sieve₁ f₁ f₂ p₁ p₂ w] end Cover end GrothendieckTopology end CategoryTheory