source stringlengths 17 118 | lean4 stringlengths 0 335k |
|---|---|
.lake/packages/mathlib/Mathlib/CategoryTheory/Triangulated/TriangleShift.lean | import Mathlib.CategoryTheory.Linear.LinearFunctor
import Mathlib.CategoryTheory.Triangulated.Rotate
import Mathlib.Algebra.Ring.NegOnePow
/-!
# The shift on the category of triangles
In this file, it is shown that if `C` is a preadditive category with
a shift by `ℤ`, then the category of triangles `Triangle C` is also
endowed with a shift. We also show that rotating triangles three times
identifies with the shift by `1`.
The shift on the category of triangles was also obtained by Adam Topaz,
Johan Commelin and Andrew Yang during the Liquid Tensor Experiment.
-/
assert_not_exists TwoSidedIdeal
universe v u
namespace CategoryTheory
open Category Preadditive
variable (C : Type u) [Category.{v} C] [Preadditive C] [HasShift C ℤ]
[∀ (n : ℤ), (CategoryTheory.shiftFunctor C n).Additive]
namespace Pretriangulated
attribute [local simp] Triangle.eqToHom_hom₁ Triangle.eqToHom_hom₂ Triangle.eqToHom_hom₃
shiftFunctorAdd_zero_add_hom_app shiftFunctorAdd_add_zero_hom_app
shiftFunctorAdd'_eq_shiftFunctorAdd shift_shiftFunctorCompIsoId_inv_app
/-- The shift functor `Triangle C ⥤ Triangle C` by `n : ℤ` sends a triangle
to the triangle obtained by shifting the objects by `n` in `C` and by
multiplying the three morphisms by `(-1)^n`. -/
@[simps]
noncomputable def Triangle.shiftFunctor (n : ℤ) : Triangle C ⥤ Triangle C where
obj T := Triangle.mk (n.negOnePow • T.mor₁⟦n⟧') (n.negOnePow • T.mor₂⟦n⟧')
(n.negOnePow • T.mor₃⟦n⟧' ≫ (shiftFunctorComm C 1 n).hom.app T.obj₁)
map f :=
{ hom₁ := f.hom₁⟦n⟧'
hom₂ := f.hom₂⟦n⟧'
hom₃ := f.hom₃⟦n⟧'
comm₁ := by
dsimp
simp only [Linear.units_smul_comp, Linear.comp_units_smul, ← Functor.map_comp, f.comm₁]
comm₂ := by
dsimp
simp only [Linear.units_smul_comp, Linear.comp_units_smul, ← Functor.map_comp, f.comm₂]
comm₃ := by
dsimp
rw [Linear.units_smul_comp, Linear.comp_units_smul, ← Functor.map_comp_assoc, ← f.comm₃,
Functor.map_comp, assoc, assoc]
erw [(shiftFunctorComm C 1 n).hom.naturality]
rfl }
/-- The canonical isomorphism `Triangle.shiftFunctor C 0 ≅ 𝟭 (Triangle C)`. -/
@[simps!]
noncomputable def Triangle.shiftFunctorZero : Triangle.shiftFunctor C 0 ≅ 𝟭 _ :=
NatIso.ofComponents
(fun T => Triangle.isoMk _ _ ((CategoryTheory.shiftFunctorZero C ℤ).app _)
((CategoryTheory.shiftFunctorZero C ℤ).app _) ((CategoryTheory.shiftFunctorZero C ℤ).app _)
(by simp) (by simp) (by
dsimp
simp only [one_smul, assoc, shiftFunctorComm_zero_hom_app,
← Functor.map_comp, Iso.inv_hom_id_app, Functor.id_obj, Functor.map_id,
comp_id, NatTrans.naturality, Functor.id_map]))
(by cat_disch)
/-- The canonical isomorphism
`Triangle.shiftFunctor C n ≅ Triangle.shiftFunctor C a ⋙ Triangle.shiftFunctor C b`
when `a + b = n`. -/
@[simps!]
noncomputable def Triangle.shiftFunctorAdd' (a b n : ℤ) (h : a + b = n) :
Triangle.shiftFunctor C n ≅ Triangle.shiftFunctor C a ⋙ Triangle.shiftFunctor C b :=
NatIso.ofComponents
(fun T => Triangle.isoMk _ _
((CategoryTheory.shiftFunctorAdd' C a b n h).app _)
((CategoryTheory.shiftFunctorAdd' C a b n h).app _)
((CategoryTheory.shiftFunctorAdd' C a b n h).app _)
(by
subst h
dsimp
rw [Linear.units_smul_comp, NatTrans.naturality, Linear.comp_units_smul, Functor.comp_map,
Functor.map_units_smul, Linear.comp_units_smul, smul_smul, Int.negOnePow_add, mul_comm])
(by
subst h
dsimp
rw [Linear.units_smul_comp, NatTrans.naturality, Linear.comp_units_smul, Functor.comp_map,
Functor.map_units_smul, Linear.comp_units_smul, smul_smul, Int.negOnePow_add, mul_comm])
(by
subst h
dsimp
rw [Linear.units_smul_comp, Linear.comp_units_smul, Functor.map_units_smul,
Linear.units_smul_comp, Linear.comp_units_smul, smul_smul, assoc,
Functor.map_comp, assoc]
erw [← NatTrans.naturality_assoc]
simp only [shiftFunctorAdd'_eq_shiftFunctorAdd, Int.negOnePow_add,
shiftFunctorComm_hom_app_comp_shift_shiftFunctorAdd_hom_app, add_comm a]))
(by cat_disch)
/-- Rotating triangles three times identifies with the shift by `1`. -/
noncomputable def rotateRotateRotateIso :
rotate C ⋙ rotate C ⋙ rotate C ≅ Triangle.shiftFunctor C 1 :=
NatIso.ofComponents
(fun T => Triangle.isoMk _ _ (Iso.refl _) (Iso.refl _) (Iso.refl _)
(by simp) (by simp) (by simp))
(by cat_disch)
/-- Rotating triangles three times backwards identifies with the shift by `-1`. -/
noncomputable def invRotateInvRotateInvRotateIso :
invRotate C ⋙ invRotate C ⋙ invRotate C ≅ Triangle.shiftFunctor C (-1) :=
NatIso.ofComponents
(fun T => Triangle.isoMk _ _ (Iso.refl _) (Iso.refl _) (Iso.refl _)
(by simp)
(by simp)
(by
dsimp [shiftFunctorCompIsoId]
simp [shiftFunctorComm_eq C _ _ _ (add_neg_cancel (1 : ℤ))]))
(by cat_disch)
/-- The inverse of the rotation of triangles can be expressed using a double
rotation and the shift by `-1`. -/
noncomputable def invRotateIsoRotateRotateShiftFunctorNegOne :
invRotate C ≅ rotate C ⋙ rotate C ⋙ Triangle.shiftFunctor C (-1) :=
calc
invRotate C ≅ invRotate C ⋙ 𝟭 _ := (Functor.rightUnitor _).symm
_ ≅ invRotate C ⋙ Triangle.shiftFunctor C 0 :=
Functor.isoWhiskerLeft _ (Triangle.shiftFunctorZero C).symm
_ ≅ invRotate C ⋙ Triangle.shiftFunctor C 1 ⋙ Triangle.shiftFunctor C (-1) :=
Functor.isoWhiskerLeft _ (Triangle.shiftFunctorAdd' C 1 (-1) 0 (add_neg_cancel 1))
_ ≅ invRotate C ⋙ (rotate C ⋙ rotate C ⋙ rotate C) ⋙ Triangle.shiftFunctor C (-1) :=
Functor.isoWhiskerLeft _ (Functor.isoWhiskerRight (rotateRotateRotateIso C).symm _)
_ ≅ (invRotate C ⋙ rotate C) ⋙ rotate C ⋙ rotate C ⋙ Triangle.shiftFunctor C (-1) :=
Functor.isoWhiskerLeft _ (Functor.associator _ _ _ ≪≫
Functor.isoWhiskerLeft _ (Functor.associator _ _ _)) ≪≫ (Functor.associator _ _ _).symm
_ ≅ 𝟭 _ ⋙ rotate C ⋙ rotate C ⋙ Triangle.shiftFunctor C (-1) :=
Functor.isoWhiskerRight (triangleRotation C).counitIso _
_ ≅ _ := Functor.leftUnitor _
namespace Triangle
noncomputable instance : HasShift (Triangle C) ℤ :=
hasShiftMk (Triangle C) ℤ
{ F := Triangle.shiftFunctor C
zero := Triangle.shiftFunctorZero C
add := fun a b => Triangle.shiftFunctorAdd' C a b _ rfl
assoc_hom_app := fun a b c T => by
ext
all_goals
dsimp
rw [← shiftFunctorAdd'_assoc_hom_app a b c _ _ _ rfl rfl (add_assoc a b c)]
dsimp only [CategoryTheory.shiftFunctorAdd']
simp }
@[simp]
lemma shiftFunctor_eq (n : ℤ) :
CategoryTheory.shiftFunctor (Triangle C) n = Triangle.shiftFunctor C n := rfl
@[simp]
lemma shiftFunctorZero_eq :
CategoryTheory.shiftFunctorZero (Triangle C) ℤ = Triangle.shiftFunctorZero C :=
ShiftMkCore.shiftFunctorZero_eq _
@[simp]
lemma shiftFunctorAdd_eq (a b : ℤ) :
CategoryTheory.shiftFunctorAdd (Triangle C) a b =
Triangle.shiftFunctorAdd' C a b _ rfl :=
ShiftMkCore.shiftFunctorAdd_eq _ _ _
@[simp]
lemma shiftFunctorAdd'_eq (a b c : ℤ) (h : a + b = c) :
CategoryTheory.shiftFunctorAdd' (Triangle C) a b c h =
Triangle.shiftFunctorAdd' C a b c h := by
subst h
rw [shiftFunctorAdd'_eq_shiftFunctorAdd]
apply shiftFunctorAdd_eq
end Triangle
end Pretriangulated
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Triangulated/Subcategory.lean | import Mathlib.CategoryTheory.Localization.CalculusOfFractions
import Mathlib.CategoryTheory.Localization.Triangulated
import Mathlib.CategoryTheory.ObjectProperty.ContainsZero
import Mathlib.CategoryTheory.ObjectProperty.Shift
import Mathlib.CategoryTheory.Shift.Localization
/-! # Triangulated subcategories
In this file, given a pretriangulated category `C` and `P : ObjectProperty C`,
we introduce a typeclass `P.IsTriangulated` to express that `P`
is a triangulated subcategory of `C`. When `P` is a triangulated
subcategory, we introduce a class of morphisms `P.trW : MorphismProperty C`
consisting of the morphisms whose "cone" belongs to `P` (up to isomorphisms),
and we show that it has both calculus of left and right fractions.
## TODO
* show that the fullsubcategory attached to `P` (such that `P.IsTriangulated`)
is a pretriangulated category.
## Implementation notes
In the definition of `P.IsTriangulated`, we do not assume that the predicate
on objects is closed under isomorphisms (i.e. that the subcategory is "strictly full").
Part of the theory would be more convenient under this stronger assumption
(e.g. the subtype of `ObjectProperty C` consisting of triangulated subcategories
would be a lattice), but some applications require this:
for example, the subcategory of bounded below complexes in the homotopy category
of an additive category is not closed under isomorphisms.
## References
* [Jean-Louis Verdier, *Des catégories dérivées des catégories abéliennes*][verdier1996]
-/
assert_not_exists TwoSidedIdeal
namespace CategoryTheory
open Category Limits Preadditive ZeroObject Pretriangulated Triangulated
variable {C : Type*} [Category C] [HasZeroObject C] [HasShift C ℤ]
[Preadditive C] [∀ (n : ℤ), (shiftFunctor C n).Additive] [Pretriangulated C]
namespace ObjectProperty
variable (P : ObjectProperty C)
/-- Given `P : ObjectProperty C` with `C` a pretriangulated category, this
is the property that whenever `X₁ ⟶ X₂ ⟶ X₃ ⟶ X₁⟦1⟧` is a distinguished triangle
such that `P X₂` and `P X₃` hold, then `P.isoClosure X₁` holds. -/
class IsTriangulatedClosed₁ : Prop where
ext₁' (T : Triangle C) (_ : T ∈ distTriang C) : P T.obj₂ → P T.obj₃ → P.isoClosure T.obj₁
/-- Given `P : ObjectProperty C` with `C` a pretriangulated category, this
is the property that whenever `X₁ ⟶ X₂ ⟶ X₃ ⟶ X₁⟦1⟧` is a distinguished triangle
such that `P X₁` and `P X₃` hold, then `P.isoClosure X₂` holds. -/
class IsTriangulatedClosed₂ : Prop where
ext₂' (T : Triangle C) (_ : T ∈ distTriang C) : P T.obj₁ → P T.obj₃ → P.isoClosure T.obj₂
/-- Given `P : ObjectProperty C` with `C` a pretriangulated category, this
is the property that whenever `X₁ ⟶ X₂ ⟶ X₃ ⟶ X₁⟦1⟧` is a distinguished triangle
such that `P X₁` and `P X₂` hold, then `P.isoClosure X₃` holds. -/
class IsTriangulatedClosed₃ : Prop where
ext₃' (T : Triangle C) (_ : T ∈ distTriang C) : P T.obj₁ → P T.obj₂ → P.isoClosure T.obj₃
lemma ext_of_isTriangulatedClosed₁'
[P.IsTriangulatedClosed₁] (T : Triangle C) (hT : T ∈ distTriang C)
(h₂ : P T.obj₂) (h₃ : P T.obj₃) : P.isoClosure T.obj₁ :=
IsTriangulatedClosed₁.ext₁' T hT h₂ h₃
lemma ext_of_isTriangulatedClosed₂'
[P.IsTriangulatedClosed₂] (T : Triangle C) (hT : T ∈ distTriang C)
(h₁ : P T.obj₁) (h₃ : P T.obj₃) : P.isoClosure T.obj₂ :=
IsTriangulatedClosed₂.ext₂' T hT h₁ h₃
lemma ext_of_isTriangulatedClosed₃'
[P.IsTriangulatedClosed₃] (T : Triangle C) (hT : T ∈ distTriang C)
(h₁ : P T.obj₁) (h₂ : P T.obj₂) : P.isoClosure T.obj₃ :=
IsTriangulatedClosed₃.ext₃' T hT h₁ h₂
lemma ext_of_isTriangulatedClosed₁
[P.IsTriangulatedClosed₁] [P.IsClosedUnderIsomorphisms]
(T : Triangle C) (hT : T ∈ distTriang C)
(h₂ : P T.obj₂) (h₃ : P T.obj₃) : P T.obj₁ := by
simpa only [isoClosure_eq_self] using P.ext_of_isTriangulatedClosed₁' T hT h₂ h₃
lemma ext_of_isTriangulatedClosed₂
[P.IsTriangulatedClosed₂] [P.IsClosedUnderIsomorphisms]
(T : Triangle C) (hT : T ∈ distTriang C)
(h₁ : P T.obj₁) (h₃ : P T.obj₃) : P T.obj₂ := by
simpa only [isoClosure_eq_self] using P.ext_of_isTriangulatedClosed₂' T hT h₁ h₃
lemma ext_of_isTriangulatedClosed₃
[P.IsTriangulatedClosed₃] [P.IsClosedUnderIsomorphisms]
(T : Triangle C) (hT : T ∈ distTriang C)
(h₁ : P T.obj₁) (h₂ : P T.obj₂) : P T.obj₃ := by
simpa only [isoClosure_eq_self] using P.ext_of_isTriangulatedClosed₃' T hT h₁ h₂
variable {P}
lemma IsTriangulatedClosed₁.mk' [P.IsClosedUnderIsomorphisms]
(hP : ∀ (T : Triangle C) (_ : T ∈ distTriang C)
(_ : P T.obj₂) (_ : P T.obj₃), P T.obj₁) : P.IsTriangulatedClosed₁ where
ext₁' := by simpa only [isoClosure_eq_self] using hP
lemma IsTriangulatedClosed₂.mk' [P.IsClosedUnderIsomorphisms]
(hP : ∀ (T : Triangle C) (_ : T ∈ distTriang C)
(_ : P T.obj₁) (_ : P T.obj₃), P T.obj₂) : P.IsTriangulatedClosed₂ where
ext₂' := by simpa only [isoClosure_eq_self] using hP
lemma IsTriangulatedClosed₃.mk' [P.IsClosedUnderIsomorphisms]
(hP : ∀ (T : Triangle C) (_ : T ∈ distTriang C)
(_ : P T.obj₁) (_ : P T.obj₂), P T.obj₃) : P.IsTriangulatedClosed₃ where
ext₃' := by simpa only [isoClosure_eq_self] using hP
variable (P)
instance [P.IsTriangulatedClosed₂] : P.isoClosure.IsTriangulatedClosed₂ where
ext₂' := by
rintro T hT ⟨X₁, h₁, ⟨e₁⟩⟩ ⟨X₃, h₃, ⟨e₃⟩⟩
exact ObjectProperty.le_isoClosure _ _
(P.ext_of_isTriangulatedClosed₂'
(Triangle.mk (e₁.inv ≫ T.mor₁) (T.mor₂ ≫ e₃.hom) (e₃.inv ≫ T.mor₃ ≫ e₁.hom⟦1⟧'))
(isomorphic_distinguished _ hT _
(Triangle.isoMk _ _ e₁.symm (Iso.refl _) e₃.symm (by simp) (by simp) (by
dsimp
simp only [assoc, ← Functor.map_comp, e₁.hom_inv_id,
Functor.map_id, comp_id]))) h₁ h₃)
/-- The property that `P : ObjectProperty C` is a triangulated subcategory
(of a pretriangulated category `C`). -/
protected class IsTriangulated : Prop extends P.ContainsZero, P.IsStableUnderShift ℤ,
P.IsTriangulatedClosed₂ where
instance [P.IsTriangulated] : P.IsTriangulatedClosed₁ where
ext₁' _ hT h₂ h₃ :=
P.ext_of_isTriangulatedClosed₂' _ (inv_rot_of_distTriang _ hT) (P.le_shift _ _ h₃) h₂
instance [P.IsTriangulated] : P.IsTriangulatedClosed₃ where
ext₃' _ hT h₁ h₂ :=
P.ext_of_isTriangulatedClosed₂' _ (rot_of_distTriang _ hT) h₂ (P.le_shift _ _ h₁)
instance [P.IsTriangulated] : P.isoClosure.IsTriangulated where
/-- Given `P : ObjectProperty C` with `C` a pretriangulated category, this is the class
of morphisms whose cone satisfies `P`. (The name `trW` contains the prefix `tr`
for "triangulated", and `W` is a letter that is often used to refer to classes of
morphisms with respect to which we may consider the localized category.) -/
def trW : MorphismProperty C :=
fun X Y f => ∃ (Z : C) (g : Y ⟶ Z) (h : Z ⟶ X⟦(1 : ℤ)⟧)
(_ : Triangle.mk f g h ∈ distTriang C), P Z
lemma trW_iff {X Y : C} (f : X ⟶ Y) :
P.trW f ↔ ∃ (Z : C) (g : Y ⟶ Z) (h : Z ⟶ X⟦(1 : ℤ)⟧)
(_ : Triangle.mk f g h ∈ distTriang C), P Z := by rfl
lemma trW_iff' [P.IsStableUnderShift ℤ] {Y Z : C} (g : Y ⟶ Z) :
P.trW g ↔ ∃ (X : C) (f : X ⟶ Y) (h : Z ⟶ X⟦(1 : ℤ)⟧)
(_ : Triangle.mk f g h ∈ distTriang C), P X := by
rw [P.trW_iff]
constructor
· rintro ⟨Z, g, h, H, mem⟩
exact ⟨_, _, _, inv_rot_of_distTriang _ H, P.le_shift (-1) _ mem⟩
· rintro ⟨Z, g, h, H, mem⟩
exact ⟨_, _, _, rot_of_distTriang _ H, P.le_shift 1 _ mem⟩
lemma trW.mk {T : Triangle C} (hT : T ∈ distTriang C) (h : P T.obj₃) : P.trW T.mor₁ :=
⟨_, _, _, hT, h⟩
lemma trW.mk' [P.IsStableUnderShift ℤ] {T : Triangle C} (hT : T ∈ distTriang C)
(h : P T.obj₁) : P.trW T.mor₂ := by
rw [trW_iff']
exact ⟨_, _, _, hT, h⟩
lemma trW_isoClosure : P.isoClosure.trW = P.trW := by
ext X Y f
constructor
· rintro ⟨Z, g, h, mem, ⟨Z', hZ', ⟨e⟩⟩⟩
refine ⟨Z', g ≫ e.hom, e.inv ≫ h, isomorphic_distinguished _ mem _ ?_, hZ'⟩
exact Triangle.isoMk _ _ (Iso.refl _) (Iso.refl _) e.symm
· rintro ⟨Z, g, h, mem, hZ⟩
exact ⟨Z, g, h, mem, ObjectProperty.le_isoClosure _ _ hZ⟩
instance : P.trW.RespectsIso where
precomp {X' X Y} e (he : IsIso e) := by
rintro f ⟨Z, g, h, mem, mem'⟩
refine ⟨Z, g, h ≫ inv e⟦(1 : ℤ)⟧', isomorphic_distinguished _ mem _ ?_, mem'⟩
refine Triangle.isoMk _ _ (asIso e) (Iso.refl _) (Iso.refl _) (by simp) (by simp) ?_
dsimp
simp only [Functor.map_inv, assoc, IsIso.inv_hom_id, comp_id, id_comp]
postcomp {X Y Y'} e (he : IsIso e) := by
rintro f ⟨Z, g, h, mem, mem'⟩
refine ⟨Z, inv e ≫ g, h, isomorphic_distinguished _ mem _ ?_, mem'⟩
exact Triangle.isoMk _ _ (Iso.refl _) (asIso e).symm (Iso.refl _)
instance [P.ContainsZero] : P.trW.ContainsIdentities := by
rw [← trW_isoClosure]
exact ⟨fun X => ⟨_, _, _, contractible_distinguished X, prop_zero _⟩⟩
lemma trW_of_isIso [P.ContainsZero] {X Y : C} (f : X ⟶ Y) [IsIso f] : P.trW f := by
refine (P.trW.arrow_mk_iso_iff ?_).1 (MorphismProperty.id_mem _ X)
exact Arrow.isoMk (Iso.refl _) (asIso f)
lemma smul_mem_trW_iff {X Y : C} (f : X ⟶ Y) (n : ℤˣ) :
P.trW (n • f) ↔ P.trW f :=
P.trW.arrow_mk_iso_iff (Arrow.isoMk (n • (Iso.refl _)) (Iso.refl _))
variable {P} in
lemma trW.shift [P.IsStableUnderShift ℤ]
{X₁ X₂ : C} {f : X₁ ⟶ X₂} (hf : P.trW f) (n : ℤ) : P.trW (f⟦n⟧') := by
rw [← smul_mem_trW_iff _ _ (n.negOnePow)]
obtain ⟨X₃, g, h, hT, mem⟩ := hf
exact ⟨_, _, _, Pretriangulated.Triangle.shift_distinguished _ hT n, P.le_shift _ _ mem⟩
lemma trW.unshift [P.IsStableUnderShift ℤ]
{X₁ X₂ : C} {f : X₁ ⟶ X₂} {n : ℤ} (hf : P.trW (f⟦n⟧')) : P.trW f :=
(P.trW.arrow_mk_iso_iff
(Arrow.isoOfNatIso (shiftEquiv C n).unitIso (Arrow.mk f))).2 (hf.shift (-n))
instance [P.IsStableUnderShift ℤ] : P.trW.IsCompatibleWithShift ℤ where
condition n := by
ext K L f
exact ⟨fun hf => hf.unshift, fun hf => hf.shift n⟩
instance [IsTriangulated C] [P.IsTriangulated] : P.trW.IsMultiplicative where
comp_mem := by
rw [← trW_isoClosure]
rintro X₁ X₂ X₃ u₁₂ u₂₃ ⟨Z₁₂, v₁₂, w₁₂, H₁₂, mem₁₂⟩ ⟨Z₂₃, v₂₃, w₂₃, H₂₃, mem₂₃⟩
obtain ⟨Z₁₃, v₁₃, w₁₂, H₁₃⟩ := distinguished_cocone_triangle (u₁₂ ≫ u₂₃)
exact ⟨_, _, _, H₁₃, P.isoClosure.ext_of_isTriangulatedClosed₂
_ (someOctahedron rfl H₁₂ H₂₃ H₁₃).mem mem₁₂ mem₂₃⟩
lemma trW_iff_of_distinguished
[P.IsClosedUnderIsomorphisms] (T : Triangle C) (hT : T ∈ distTriang C) :
P.trW T.mor₁ ↔ P T.obj₃ := by
constructor
· rintro ⟨Z, g, h, hT', mem⟩
obtain ⟨e, _⟩ := exists_iso_of_arrow_iso _ _ hT' hT (Iso.refl _)
exact P.prop_of_iso (Triangle.π₃.mapIso e) mem
· intro h
exact ⟨_, _, _, hT, h⟩
instance [IsTriangulated C] [P.IsTriangulated] : P.trW.HasLeftCalculusOfFractions where
exists_leftFraction X Y φ := by
obtain ⟨Z, f, g, H, mem⟩ := φ.hs
obtain ⟨Y', s', f', mem'⟩ := distinguished_cocone_triangle₂ (g ≫ φ.f⟦1⟧')
obtain ⟨b, ⟨hb₁, _⟩⟩ :=
complete_distinguished_triangle_morphism₂ _ _ H mem' φ.f (𝟙 Z) (by simp)
exact ⟨MorphismProperty.LeftFraction.mk b s' ⟨_, _, _, mem', mem⟩, hb₁.symm⟩
ext := by
rintro X' X Y f₁ f₂ s ⟨Z, g, h, H, mem⟩ hf₁
have hf₂ : s ≫ (f₁ - f₂) = 0 := by rw [comp_sub, hf₁, sub_self]
obtain ⟨q, hq⟩ := Triangle.yoneda_exact₂ _ H _ hf₂
obtain ⟨Y', r, t, mem'⟩ := distinguished_cocone_triangle q
refine ⟨Y', r, ?_, ?_⟩
· exact ⟨_, _, _, rot_of_distTriang _ mem', P.le_shift _ _ mem⟩
· have eq := comp_distTriang_mor_zero₁₂ _ mem'
dsimp at eq
rw [← sub_eq_zero, ← sub_comp, hq, assoc, eq, comp_zero]
instance [IsTriangulated C] [P.IsTriangulated] : P.trW.HasRightCalculusOfFractions where
exists_rightFraction X Y φ := by
obtain ⟨Z, f, g, H, mem⟩ := φ.hs
obtain ⟨X', f', h', mem'⟩ := distinguished_cocone_triangle₁ (φ.f ≫ f)
obtain ⟨a, ⟨ha₁, _⟩⟩ := complete_distinguished_triangle_morphism₁ _ _
mem' H φ.f (𝟙 Z) (by simp)
exact ⟨MorphismProperty.RightFraction.mk f' ⟨_, _, _, mem', mem⟩ a, ha₁⟩
ext Y Z Z' f₁ f₂ s hs hf₁ := by
rw [P.trW_iff'] at hs
obtain ⟨Z, g, h, H, mem⟩ := hs
have hf₂ : (f₁ - f₂) ≫ s = 0 := by rw [sub_comp, hf₁, sub_self]
obtain ⟨q, hq⟩ := Triangle.coyoneda_exact₂ _ H _ hf₂
obtain ⟨Y', r, t, mem'⟩ := distinguished_cocone_triangle₁ q
refine ⟨Y', r, ?_, ?_⟩
· exact ⟨_, _, _, mem', mem⟩
· have eq := comp_distTriang_mor_zero₁₂ _ mem'
dsimp at eq
rw [← sub_eq_zero, ← comp_sub, hq, reassoc_of% eq, zero_comp]
instance [IsTriangulated C] [P.IsTriangulated] : P.trW.IsCompatibleWithTriangulation := ⟨by
rintro T₁ T₃ mem₁ mem₃ a b ⟨Z₅, g₅, h₅, mem₅, mem₅'⟩ ⟨Z₄, g₄, h₄, mem₄, mem₄'⟩ comm
obtain ⟨Z₂, g₂, h₂, mem₂⟩ := distinguished_cocone_triangle (T₁.mor₁ ≫ b)
have H := someOctahedron rfl mem₁ mem₄ mem₂
have H' := someOctahedron comm.symm mem₅ mem₃ mem₂
let φ : T₁ ⟶ T₃ := H.triangleMorphism₁ ≫ H'.triangleMorphism₂
exact ⟨φ.hom₃, P.trW.comp_mem _ _ (trW.mk P H.mem mem₄') (trW.mk' P H'.mem mem₅'),
by simpa [φ] using φ.comm₂, by simpa [φ] using φ.comm₃⟩⟩
end ObjectProperty
namespace Triangulated
@[deprecated (since := "2025-07-21")]
alias Subcategory := ObjectProperty.IsTriangulated
namespace Subcategory
open ObjectProperty
@[deprecated (since := "2025-07-21")] alias mk' := IsTriangulatedClosed₂.mk'
@[deprecated (since := "2025-07-21")] alias ext₁ := ext_of_isTriangulatedClosed₁
@[deprecated (since := "2025-07-21")] alias ext₁' := ext_of_isTriangulatedClosed₁'
@[deprecated (since := "2025-07-21")] alias ext₂ := ext_of_isTriangulatedClosed₂
@[deprecated (since := "2025-07-21")] alias ext₂' := ext_of_isTriangulatedClosed₂'
@[deprecated (since := "2025-07-21")] alias ext₃ := ext_of_isTriangulatedClosed₃
@[deprecated (since := "2025-07-21")] alias ext₃' := ext_of_isTriangulatedClosed₃'
@[deprecated (since := "2025-07-21")] alias W := trW
@[deprecated (since := "2025-07-21")] alias W_iff := trW_iff
@[deprecated (since := "2025-07-21")] alias W_iff' := trW_iff'
@[deprecated (since := "2025-07-21")] alias W.mk := trW.mk
@[deprecated (since := "2025-07-21")] alias W.mk' := trW.mk'
@[deprecated (since := "2025-07-21")] alias isoClosure_W := trW_isoClosure
@[deprecated (since := "2025-07-21")] alias W_of_isIso := trW_of_isIso
@[deprecated (since := "2025-07-21")] alias smul_mem_W_iff := smul_mem_trW_iff
@[deprecated (since := "2025-07-21")] alias W.shift := trW.shift
@[deprecated (since := "2025-07-21")] alias W.unshift := trW.unshift
@[deprecated (since := "2025-07-21")]
alias mem_W_iff_of_distinguished := trW_iff_of_distinguished
end Subcategory
end Triangulated
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Triangulated/Triangulated.lean | import Mathlib.CategoryTheory.Triangulated.Pretriangulated
/-!
# Triangulated Categories
This file contains the definition of triangulated categories, which are
pretriangulated categories which satisfy the octahedron axiom.
-/
assert_not_exists TwoSidedIdeal
noncomputable section
namespace CategoryTheory
open Limits Category Preadditive Pretriangulated
open ZeroObject
variable (C : Type*) [Category C] [Preadditive C] [HasZeroObject C] [HasShift C ℤ]
[∀ n : ℤ, Functor.Additive (shiftFunctor C n)] [Pretriangulated C]
namespace Triangulated
variable {C}
/-- An octahedron is a type of datum whose existence is asserted by the octahedron axiom (TR 4). -/
@[stacks 05QK]
structure Octahedron
{X₁ X₂ X₃ Z₁₂ Z₂₃ Z₁₃ : C}
{u₁₂ : X₁ ⟶ X₂} {u₂₃ : X₂ ⟶ X₃} {u₁₃ : X₁ ⟶ X₃} (comm : u₁₂ ≫ u₂₃ = u₁₃)
{v₁₂ : X₂ ⟶ Z₁₂} {w₁₂ : Z₁₂ ⟶ X₁⟦(1 : ℤ)⟧} (h₁₂ : Triangle.mk u₁₂ v₁₂ w₁₂ ∈ distTriang C)
{v₂₃ : X₃ ⟶ Z₂₃} {w₂₃ : Z₂₃ ⟶ X₂⟦(1 : ℤ)⟧} (h₂₃ : Triangle.mk u₂₃ v₂₃ w₂₃ ∈ distTriang C)
{v₁₃ : X₃ ⟶ Z₁₃} {w₁₃ : Z₁₃ ⟶ X₁⟦(1 : ℤ)⟧} (h₁₃ : Triangle.mk u₁₃ v₁₃ w₁₃ ∈ distTriang C) where
/-- `m₁` is the morphism `a` of (TR 4) as presented in Stacks. -/
m₁ : Z₁₂ ⟶ Z₁₃
/-- `m₃` is the morphism `b` of (TR 4) as presented in Stacks. -/
m₃ : Z₁₃ ⟶ Z₂₃
comm₁ : v₁₂ ≫ m₁ = u₂₃ ≫ v₁₃
comm₂ : m₁ ≫ w₁₃ = w₁₂
comm₃ : v₁₃ ≫ m₃ = v₂₃
comm₄ : w₁₃ ≫ u₁₂⟦1⟧' = m₃ ≫ w₂₃
mem : Triangle.mk m₁ m₃ (w₂₃ ≫ v₁₂⟦1⟧') ∈ distTriang C
instance (X : C) :
Nonempty (Octahedron (comp_id (𝟙 X)) (contractible_distinguished X)
(contractible_distinguished X) (contractible_distinguished X)) := by
refine ⟨⟨0, 0, ?_, ?_, ?_, ?_, isomorphic_distinguished _ (contractible_distinguished (0 : C)) _
(Triangle.isoMk _ _ (by rfl) (by rfl) (by rfl))⟩⟩
all_goals apply Subsingleton.elim
namespace Octahedron
attribute [reassoc] comm₁ comm₂ comm₃ comm₄
variable {X₁ X₂ X₃ Z₁₂ Z₂₃ Z₁₃ : C}
{u₁₂ : X₁ ⟶ X₂} {u₂₃ : X₂ ⟶ X₃} {u₁₃ : X₁ ⟶ X₃} {comm : u₁₂ ≫ u₂₃ = u₁₃}
{v₁₂ : X₂ ⟶ Z₁₂} {w₁₂ : Z₁₂ ⟶ X₁⟦(1 : ℤ)⟧} {h₁₂ : Triangle.mk u₁₂ v₁₂ w₁₂ ∈ distTriang C}
{v₂₃ : X₃ ⟶ Z₂₃} {w₂₃ : Z₂₃ ⟶ X₂⟦(1 : ℤ)⟧} {h₂₃ : Triangle.mk u₂₃ v₂₃ w₂₃ ∈ distTriang C}
{v₁₃ : X₃ ⟶ Z₁₃} {w₁₃ : Z₁₃ ⟶ X₁⟦(1 : ℤ)⟧} {h₁₃ : Triangle.mk u₁₃ v₁₃ w₁₃ ∈ distTriang C}
(h : Octahedron comm h₁₂ h₂₃ h₁₃)
/-- The triangle `Z₁₂ ⟶ Z₁₃ ⟶ Z₂₃ ⟶ Z₁₂⟦1⟧` given by an octahedron. -/
@[simps!]
def triangle : Triangle C :=
Triangle.mk h.m₁ h.m₃ (w₂₃ ≫ v₁₂⟦1⟧')
/-- The first morphism of triangles given by an octahedron. -/
@[simps]
def triangleMorphism₁ : Triangle.mk u₁₂ v₁₂ w₁₂ ⟶ Triangle.mk u₁₃ v₁₃ w₁₃ where
hom₁ := 𝟙 X₁
hom₂ := u₂₃
hom₃ := h.m₁
comm₁ := by
dsimp
rw [id_comp, comm]
comm₂ := h.comm₁
comm₃ := by
dsimp
simpa only [Functor.map_id, comp_id] using h.comm₂.symm
/-- The second morphism of triangles given an octahedron. -/
@[simps]
def triangleMorphism₂ : Triangle.mk u₁₃ v₁₃ w₁₃ ⟶ Triangle.mk u₂₃ v₂₃ w₂₃ where
hom₁ := u₁₂
hom₂ := 𝟙 X₃
hom₃ := h.m₃
comm₁ := by
dsimp
rw [comp_id, comm]
comm₂ := by
dsimp
rw [id_comp, h.comm₃]
comm₃ := h.comm₄
variable (u₁₂ u₁₃ u₂₃ comm h₁₂ h₁₃ h₂₃)
/-- When two diagrams are isomorphic, an octahedron for one gives an octahedron for the other. -/
def ofIso {X₁' X₂' X₃' Z₁₂' Z₂₃' Z₁₃' : C} (u₁₂' : X₁' ⟶ X₂') (u₂₃' : X₂' ⟶ X₃') (u₁₃' : X₁' ⟶ X₃')
(comm' : u₁₂' ≫ u₂₃' = u₁₃')
(e₁ : X₁ ≅ X₁') (e₂ : X₂ ≅ X₂') (e₃ : X₃ ≅ X₃')
(comm₁₂ : u₁₂ ≫ e₂.hom = e₁.hom ≫ u₁₂') (comm₂₃ : u₂₃ ≫ e₃.hom = e₂.hom ≫ u₂₃')
(v₁₂' : X₂' ⟶ Z₁₂') (w₁₂' : Z₁₂' ⟶ X₁'⟦(1 : ℤ)⟧)
(h₁₂' : Triangle.mk u₁₂' v₁₂' w₁₂' ∈ distTriang C)
(v₂₃' : X₃' ⟶ Z₂₃') (w₂₃' : Z₂₃' ⟶ X₂'⟦(1 : ℤ)⟧)
(h₂₃' : Triangle.mk u₂₃' v₂₃' w₂₃' ∈ distTriang C)
(v₁₃' : X₃' ⟶ Z₁₃') (w₁₃' : Z₁₃' ⟶ X₁'⟦(1 : ℤ)⟧)
(h₁₃' : Triangle.mk (u₁₃') v₁₃' w₁₃' ∈ distTriang C)
(H : Octahedron comm' h₁₂' h₂₃' h₁₃') : Octahedron comm h₁₂ h₂₃ h₁₃ := by
let iso₁₂ := isoTriangleOfIso₁₂ _ _ h₁₂ h₁₂' e₁ e₂ comm₁₂
let iso₂₃ := isoTriangleOfIso₁₂ _ _ h₂₃ h₂₃' e₂ e₃ comm₂₃
let iso₁₃ := isoTriangleOfIso₁₂ _ _ h₁₃ h₁₃' e₁ e₃ (by
dsimp; rw [← comm, assoc, ← comm', ← reassoc_of% comm₁₂, comm₂₃])
have eq₁₂ := iso₁₂.hom.comm₂
have eq₁₂' := iso₁₂.hom.comm₃
have eq₁₃ := iso₁₃.hom.comm₂
have eq₁₃' := iso₁₃.hom.comm₃
have eq₂₃ := iso₂₃.hom.comm₂
have eq₂₃' := iso₂₃.hom.comm₃
have rel₁₂ := H.triangleMorphism₁.comm₂
have rel₁₃ := H.triangleMorphism₁.comm₃
have rel₂₂ := H.triangleMorphism₂.comm₂
have rel₂₃ := H.triangleMorphism₂.comm₃
dsimp [iso₁₂, iso₂₃, iso₁₃] at eq₁₂ eq₁₂' eq₁₃ eq₁₃' eq₂₃ eq₂₃' rel₁₂ rel₁₃ rel₂₂ rel₂₃
rw [Functor.map_id, comp_id] at rel₁₃
rw [id_comp] at rel₂₂
refine ⟨iso₁₂.hom.hom₃ ≫ H.m₁ ≫ iso₁₃.inv.hom₃,
iso₁₃.hom.hom₃ ≫ H.m₃ ≫ iso₂₃.inv.hom₃, ?_, ?_, ?_, ?_, ?_⟩
· rw [reassoc_of% eq₁₂, ← cancel_mono iso₁₃.hom.hom₃, assoc, assoc, assoc, assoc,
iso₁₃.inv_hom_id_triangle_hom₃, eq₁₃, reassoc_of% comm₂₃, ← rel₁₂]
dsimp
rw [comp_id]
· rw [← cancel_mono (e₁.hom⟦(1 : ℤ)⟧'), eq₁₂', assoc, assoc, assoc, eq₁₃',
iso₁₃.inv_hom_id_triangle_hom₃_assoc, ← rel₁₃]
· rw [reassoc_of% eq₁₃, reassoc_of% rel₂₂, ← cancel_mono iso₂₃.hom.hom₃, assoc, assoc,
iso₂₃.inv_hom_id_triangle_hom₃, eq₂₃]
dsimp
rw [comp_id]
· rw [← cancel_mono (e₂.hom⟦(1 : ℤ)⟧'), assoc, assoc, assoc,assoc, eq₂₃',
iso₂₃.inv_hom_id_triangle_hom₃_assoc, ← rel₂₃, ← Functor.map_comp, comm₁₂,
Functor.map_comp, reassoc_of% eq₁₃']
· refine isomorphic_distinguished _ H.mem _ ?_
refine Triangle.isoMk _ _ (Triangle.π₃.mapIso iso₁₂) (Triangle.π₃.mapIso iso₁₃)
(Triangle.π₃.mapIso iso₂₃) (by simp) (by simp) ?_
dsimp
rw [assoc, ← Functor.map_comp, eq₁₂, Functor.map_comp, reassoc_of% eq₂₃']
end Octahedron
end Triangulated
open Triangulated
/-- A triangulated category is a pretriangulated category which satisfies
the octahedron axiom (TR 4). -/
@[stacks 05QK]
class IsTriangulated : Prop where
/-- the octahedron axiom (TR 4) -/
octahedron_axiom :
∀ {X₁ X₂ X₃ Z₁₂ Z₂₃ Z₁₃ : C}
{u₁₂ : X₁ ⟶ X₂} {u₂₃ : X₂ ⟶ X₃} {u₁₃ : X₁ ⟶ X₃} (comm : u₁₂ ≫ u₂₃ = u₁₃)
{v₁₂ : X₂ ⟶ Z₁₂} {w₁₂ : Z₁₂ ⟶ X₁⟦(1 : ℤ)⟧} (h₁₂ : Triangle.mk u₁₂ v₁₂ w₁₂ ∈ distTriang C)
{v₂₃ : X₃ ⟶ Z₂₃} {w₂₃ : Z₂₃ ⟶ X₂⟦(1 : ℤ)⟧} (h₂₃ : Triangle.mk u₂₃ v₂₃ w₂₃ ∈ distTriang C)
{v₁₃ : X₃ ⟶ Z₁₃} {w₁₃ : Z₁₃ ⟶ X₁⟦(1 : ℤ)⟧} (h₁₃ : Triangle.mk u₁₃ v₁₃ w₁₃ ∈ distTriang C),
Nonempty (Octahedron comm h₁₂ h₂₃ h₁₃)
namespace Triangulated
variable {C}
variable {X₁ X₂ X₃ Z₁₂ Z₂₃ Z₁₃ : C}
{u₁₂ : X₁ ⟶ X₂} {u₂₃ : X₂ ⟶ X₃} {u₁₃ : X₁ ⟶ X₃} (comm : u₁₂ ≫ u₂₃ = u₁₃)
{v₁₂ : X₂ ⟶ Z₁₂} {w₁₂ : Z₁₂ ⟶ X₁⟦(1 : ℤ)⟧} {h₁₂ : Triangle.mk u₁₂ v₁₂ w₁₂ ∈ distTriang C}
{v₂₃ : X₃ ⟶ Z₂₃} {w₂₃ : Z₂₃ ⟶ X₂⟦(1 : ℤ)⟧} {h₂₃ : Triangle.mk u₂₃ v₂₃ w₂₃ ∈ distTriang C}
{v₁₃ : X₃ ⟶ Z₁₃} {w₁₃ : Z₁₃ ⟶ X₁⟦(1 : ℤ)⟧} {h₁₃ : Triangle.mk u₁₃ v₁₃ w₁₃ ∈ distTriang C}
(h : Octahedron comm h₁₂ h₂₃ h₁₃)
/-- A choice of octahedron given by the octahedron axiom. -/
def someOctahedron' [IsTriangulated C] : Octahedron comm h₁₂ h₂₃ h₁₃ :=
(IsTriangulated.octahedron_axiom comm h₁₂ h₂₃ h₁₃).some
/-- A choice of octahedron given by the octahedron axiom. -/
def someOctahedron [IsTriangulated C]
{X₁ X₂ X₃ Z₁₂ Z₂₃ Z₁₃ : C}
{u₁₂ : X₁ ⟶ X₂} {u₂₃ : X₂ ⟶ X₃} {u₁₃ : X₁ ⟶ X₃} (comm : u₁₂ ≫ u₂₃ = u₁₃)
{v₁₂ : X₂ ⟶ Z₁₂} {w₁₂ : Z₁₂ ⟶ X₁⟦(1 : ℤ)⟧} (h₁₂ : Triangle.mk u₁₂ v₁₂ w₁₂ ∈ distTriang C)
{v₂₃ : X₃ ⟶ Z₂₃} {w₂₃ : Z₂₃ ⟶ X₂⟦(1 : ℤ)⟧} (h₂₃ : Triangle.mk u₂₃ v₂₃ w₂₃ ∈ distTriang C)
{v₁₃ : X₃ ⟶ Z₁₃} {w₁₃ : Z₁₃ ⟶ X₁⟦(1 : ℤ)⟧} (h₁₃ : Triangle.mk u₁₃ v₁₃ w₁₃ ∈ distTriang C) :
Octahedron comm h₁₂ h₂₃ h₁₃ :=
someOctahedron' _
end Triangulated
variable {C}
/-- Constructor for `IsTriangulated C` which shows that it suffices to obtain an octahedron
for a suitable isomorphic diagram instead of the given diagram. -/
lemma IsTriangulated.mk' (h : ∀ ⦃X₁' X₂' X₃' : C⦄ (u₁₂' : X₁' ⟶ X₂') (u₂₃' : X₂' ⟶ X₃'),
∃ (X₁ X₂ X₃ Z₁₂ Z₂₃ Z₁₃ : C) (u₁₂ : X₁ ⟶ X₂) (u₂₃ : X₂ ⟶ X₃) (e₁ : X₁' ≅ X₁) (e₂ : X₂' ≅ X₂)
(e₃ : X₃' ≅ X₃) (_ : u₁₂' ≫ e₂.hom = e₁.hom ≫ u₁₂)
(_ : u₂₃' ≫ e₃.hom = e₂.hom ≫ u₂₃)
(v₁₂ : X₂ ⟶ Z₁₂) (w₁₂ : Z₁₂ ⟶ X₁⟦1⟧) (h₁₂ : Triangle.mk u₁₂ v₁₂ w₁₂ ∈ distTriang C)
(v₂₃ : X₃ ⟶ Z₂₃) (w₂₃ : Z₂₃ ⟶ X₂⟦1⟧) (h₂₃ : Triangle.mk u₂₃ v₂₃ w₂₃ ∈ distTriang C)
(v₁₃ : X₃ ⟶ Z₁₃) (w₁₃ : Z₁₃ ⟶ X₁⟦1⟧)
(h₁₃ : Triangle.mk (u₁₂ ≫ u₂₃) v₁₃ w₁₃ ∈ distTriang C),
Nonempty (Octahedron rfl h₁₂ h₂₃ h₁₃)) :
IsTriangulated C where
octahedron_axiom {X₁' X₂' X₃' Z₁₂' Z₂₃' Z₁₃' u₁₂' u₂₃' u₁₃'} comm'
{v₁₂' w₁₂'} h₁₂' {v₂₃' w₂₃'} h₂₃' {v₁₃' w₁₃'} h₁₃' := by
obtain ⟨X₁, X₂, X₃, Z₁₂, Z₂₃, Z₁₃, u₁₂, u₂₃, e₁, e₂, e₃, comm₁₂, comm₂₃,
v₁₂, w₁₂, h₁₂, v₂₃, w₂₃, h₂₃, v₁₃, w₁₃, h₁₃, H⟩ := h u₁₂' u₂₃'
exact ⟨Octahedron.ofIso u₁₂' u₂₃' u₁₃' comm' h₁₂' h₂₃' h₁₃'
u₁₂ u₂₃ _ rfl e₁ e₂ e₃ comm₁₂ comm₂₃ v₁₂ w₁₂ h₁₂ v₂₃ w₂₃ h₂₃ v₁₃ w₁₃ h₁₃ H.some⟩
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Triangulated/Basic.lean | import Mathlib.CategoryTheory.Adjunction.Limits
import Mathlib.CategoryTheory.Limits.Preserves.Shapes.Products
import Mathlib.CategoryTheory.Limits.Shapes.BinaryBiproducts
import Mathlib.CategoryTheory.Linear.LinearFunctor
import Mathlib.CategoryTheory.Shift.Basic
/-!
# Triangles
This file contains the definition of triangles in an additive category with an additive shift.
It also defines morphisms between these triangles.
TODO: generalise this to n-angles in n-angulated categories as in https://arxiv.org/abs/1006.4592
-/
noncomputable section
open CategoryTheory Limits
universe v v₀ v₁ v₂ u u₀ u₁ u₂
namespace CategoryTheory.Pretriangulated
open CategoryTheory.Category
/-
We work in a category `C` equipped with a shift.
-/
variable (C : Type u) [Category.{v} C] [HasShift C ℤ]
/-- A triangle in `C` is a sextuple `(X,Y,Z,f,g,h)` where `X,Y,Z` are objects of `C`,
and `f : X ⟶ Y`, `g : Y ⟶ Z`, `h : Z ⟶ X⟦1⟧` are morphisms in `C`. -/
@[stacks 0144]
structure Triangle where mk' ::
/-- the first object of a triangle -/
obj₁ : C
/-- the second object of a triangle -/
obj₂ : C
/-- the third object of a triangle -/
obj₃ : C
/-- the first morphism of a triangle -/
mor₁ : obj₁ ⟶ obj₂
/-- the second morphism of a triangle -/
mor₂ : obj₂ ⟶ obj₃
/-- the third morphism of a triangle -/
mor₃ : obj₃ ⟶ obj₁⟦(1 : ℤ)⟧
variable {C}
/-- A triangle `(X,Y,Z,f,g,h)` in `C` is defined by the morphisms `f : X ⟶ Y`, `g : Y ⟶ Z`
and `h : Z ⟶ X⟦1⟧`.
-/
@[simps]
def Triangle.mk {X Y Z : C} (f : X ⟶ Y) (g : Y ⟶ Z) (h : Z ⟶ X⟦(1 : ℤ)⟧) : Triangle C where
obj₁ := X
obj₂ := Y
obj₃ := Z
mor₁ := f
mor₂ := g
mor₃ := h
section
variable [HasZeroObject C] [HasZeroMorphisms C]
open ZeroObject
instance : Inhabited (Triangle C) :=
⟨⟨0, 0, 0, 0, 0, 0⟩⟩
/-- For each object in `C`, there is a triangle of the form `(X,X,0,𝟙 X,0,0)`
-/
@[simps!]
def contractibleTriangle (X : C) : Triangle C :=
Triangle.mk (𝟙 X) (0 : X ⟶ 0) 0
end
/-- A morphism of triangles `(X,Y,Z,f,g,h) ⟶ (X',Y',Z',f',g',h')` in `C` is a triple of morphisms
`a : X ⟶ X'`, `b : Y ⟶ Y'`, `c : Z ⟶ Z'` such that
`a ≫ f' = f ≫ b`, `b ≫ g' = g ≫ c`, and `a⟦1⟧' ≫ h = h' ≫ c`.
In other words, we have a commutative diagram:
```
f g h
X ───> Y ───> Z ───> X⟦1⟧
│ │ │ │
│a │b │c │a⟦1⟧'
V V V V
X' ───> Y' ───> Z' ───> X'⟦1⟧
f' g' h'
```
-/
@[ext, stacks 0144]
structure TriangleMorphism (T₁ : Triangle C) (T₂ : Triangle C) where
/-- the first morphism in a triangle morphism -/
hom₁ : T₁.obj₁ ⟶ T₂.obj₁
/-- the second morphism in a triangle morphism -/
hom₂ : T₁.obj₂ ⟶ T₂.obj₂
/-- the third morphism in a triangle morphism -/
hom₃ : T₁.obj₃ ⟶ T₂.obj₃
/-- the first commutative square of a triangle morphism -/
comm₁ : T₁.mor₁ ≫ hom₂ = hom₁ ≫ T₂.mor₁ := by cat_disch
/-- the second commutative square of a triangle morphism -/
comm₂ : T₁.mor₂ ≫ hom₃ = hom₂ ≫ T₂.mor₂ := by cat_disch
/-- the third commutative square of a triangle morphism -/
comm₃ : T₁.mor₃ ≫ hom₁⟦1⟧' = hom₃ ≫ T₂.mor₃ := by cat_disch
attribute [reassoc (attr := simp)] TriangleMorphism.comm₁ TriangleMorphism.comm₂
TriangleMorphism.comm₃
/-- The identity triangle morphism.
-/
@[simps]
def triangleMorphismId (T : Triangle C) : TriangleMorphism T T where
hom₁ := 𝟙 T.obj₁
hom₂ := 𝟙 T.obj₂
hom₃ := 𝟙 T.obj₃
instance (T : Triangle C) : Inhabited (TriangleMorphism T T) :=
⟨triangleMorphismId T⟩
variable {T₁ T₂ T₃ : Triangle C}
/-- Composition of triangle morphisms gives a triangle morphism.
-/
@[simps]
def TriangleMorphism.comp (f : TriangleMorphism T₁ T₂) (g : TriangleMorphism T₂ T₃) :
TriangleMorphism T₁ T₃ where
hom₁ := f.hom₁ ≫ g.hom₁
hom₂ := f.hom₂ ≫ g.hom₂
hom₃ := f.hom₃ ≫ g.hom₃
/-- Triangles with triangle morphisms form a category.
-/
@[simps]
instance triangleCategory : Category (Triangle C) where
Hom A B := TriangleMorphism A B
id A := triangleMorphismId A
comp f g := f.comp g
@[ext]
lemma Triangle.hom_ext {A B : Triangle C} (f g : A ⟶ B)
(h₁ : f.hom₁ = g.hom₁) (h₂ : f.hom₂ = g.hom₂) (h₃ : f.hom₃ = g.hom₃) : f = g :=
TriangleMorphism.ext h₁ h₂ h₃
@[simp]
lemma id_hom₁ (A : Triangle C) : TriangleMorphism.hom₁ (𝟙 A) = 𝟙 _ := rfl
@[simp]
lemma id_hom₂ (A : Triangle C) : TriangleMorphism.hom₂ (𝟙 A) = 𝟙 _ := rfl
@[simp]
lemma id_hom₃ (A : Triangle C) : TriangleMorphism.hom₃ (𝟙 A) = 𝟙 _ := rfl
@[simp, reassoc]
lemma comp_hom₁ {X Y Z : Triangle C} (f : X ⟶ Y) (g : Y ⟶ Z) :
(f ≫ g).hom₁ = f.hom₁ ≫ g.hom₁ := rfl
@[simp, reassoc]
lemma comp_hom₂ {X Y Z : Triangle C} (f : X ⟶ Y) (g : Y ⟶ Z) :
(f ≫ g).hom₂ = f.hom₂ ≫ g.hom₂ := rfl
@[simp, reassoc]
lemma comp_hom₃ {X Y Z : Triangle C} (f : X ⟶ Y) (g : Y ⟶ Z) :
(f ≫ g).hom₃ = f.hom₃ ≫ g.hom₃ := rfl
/-- Make a morphism between triangles from the required data. -/
@[simps]
def Triangle.homMk (A B : Triangle C)
(hom₁ : A.obj₁ ⟶ B.obj₁) (hom₂ : A.obj₂ ⟶ B.obj₂) (hom₃ : A.obj₃ ⟶ B.obj₃)
(comm₁ : A.mor₁ ≫ hom₂ = hom₁ ≫ B.mor₁ := by cat_disch)
(comm₂ : A.mor₂ ≫ hom₃ = hom₂ ≫ B.mor₂ := by cat_disch)
(comm₃ : A.mor₃ ≫ hom₁⟦1⟧' = hom₃ ≫ B.mor₃ := by cat_disch) :
A ⟶ B where
hom₁ := hom₁
hom₂ := hom₂
hom₃ := hom₃
comm₁ := comm₁
comm₂ := comm₂
comm₃ := comm₃
/-- Make an isomorphism between triangles from the required data. -/
@[simps]
def Triangle.isoMk (A B : Triangle C)
(iso₁ : A.obj₁ ≅ B.obj₁) (iso₂ : A.obj₂ ≅ B.obj₂) (iso₃ : A.obj₃ ≅ B.obj₃)
(comm₁ : A.mor₁ ≫ iso₂.hom = iso₁.hom ≫ B.mor₁ := by cat_disch)
(comm₂ : A.mor₂ ≫ iso₃.hom = iso₂.hom ≫ B.mor₂ := by cat_disch)
(comm₃ : A.mor₃ ≫ iso₁.hom⟦1⟧' = iso₃.hom ≫ B.mor₃ := by cat_disch) : A ≅ B where
hom := Triangle.homMk _ _ iso₁.hom iso₂.hom iso₃.hom comm₁ comm₂ comm₃
inv := Triangle.homMk _ _ iso₁.inv iso₂.inv iso₃.inv
(by simp only [← cancel_mono iso₂.hom, assoc, Iso.inv_hom_id, comp_id,
comm₁, Iso.inv_hom_id_assoc])
(by simp only [← cancel_mono iso₃.hom, assoc, Iso.inv_hom_id, comp_id,
comm₂, Iso.inv_hom_id_assoc])
(by simp only [← cancel_mono (iso₁.hom⟦(1 : ℤ)⟧'), Category.assoc, comm₃,
Iso.inv_hom_id_assoc, ← Functor.map_comp, Iso.inv_hom_id,
Functor.map_id, Category.comp_id])
lemma Triangle.isIso_of_isIsos {A B : Triangle C} (f : A ⟶ B)
(h₁ : IsIso f.hom₁) (h₂ : IsIso f.hom₂) (h₃ : IsIso f.hom₃) : IsIso f := by
let e := Triangle.isoMk A B (asIso f.hom₁) (asIso f.hom₂) (asIso f.hom₃)
(by simp) (by simp) (by simp)
exact (inferInstance : IsIso e.hom)
@[reassoc (attr := simp)]
lemma _root_.CategoryTheory.Iso.hom_inv_id_triangle_hom₁ {A B : Triangle C} (e : A ≅ B) :
e.hom.hom₁ ≫ e.inv.hom₁ = 𝟙 _ := by rw [← comp_hom₁, e.hom_inv_id, id_hom₁]
@[reassoc (attr := simp)]
lemma _root_.CategoryTheory.Iso.hom_inv_id_triangle_hom₂ {A B : Triangle C} (e : A ≅ B) :
e.hom.hom₂ ≫ e.inv.hom₂ = 𝟙 _ := by rw [← comp_hom₂, e.hom_inv_id, id_hom₂]
@[reassoc (attr := simp)]
lemma _root_.CategoryTheory.Iso.hom_inv_id_triangle_hom₃ {A B : Triangle C} (e : A ≅ B) :
e.hom.hom₃ ≫ e.inv.hom₃ = 𝟙 _ := by rw [← comp_hom₃, e.hom_inv_id, id_hom₃]
@[reassoc (attr := simp)]
lemma _root_.CategoryTheory.Iso.inv_hom_id_triangle_hom₁ {A B : Triangle C} (e : A ≅ B) :
e.inv.hom₁ ≫ e.hom.hom₁ = 𝟙 _ := by rw [← comp_hom₁, e.inv_hom_id, id_hom₁]
@[reassoc (attr := simp)]
lemma _root_.CategoryTheory.Iso.inv_hom_id_triangle_hom₂ {A B : Triangle C} (e : A ≅ B) :
e.inv.hom₂ ≫ e.hom.hom₂ = 𝟙 _ := by rw [← comp_hom₂, e.inv_hom_id, id_hom₂]
@[reassoc (attr := simp)]
lemma _root_.CategoryTheory.Iso.inv_hom_id_triangle_hom₃ {A B : Triangle C} (e : A ≅ B) :
e.inv.hom₃ ≫ e.hom.hom₃ = 𝟙 _ := by rw [← comp_hom₃, e.inv_hom_id, id_hom₃]
lemma Triangle.eqToHom_hom₁ {A B : Triangle C} (h : A = B) :
(eqToHom h).hom₁ = eqToHom (by subst h; rfl) := by subst h; rfl
lemma Triangle.eqToHom_hom₂ {A B : Triangle C} (h : A = B) :
(eqToHom h).hom₂ = eqToHom (by subst h; rfl) := by subst h; rfl
lemma Triangle.eqToHom_hom₃ {A B : Triangle C} (h : A = B) :
(eqToHom h).hom₃ = eqToHom (by subst h; rfl) := by subst h; rfl
namespace Triangle
section Preadditive
variable [Preadditive C] [∀ (n : ℤ), (shiftFunctor C n).Additive]
@[simps (attr := grind =)]
instance : Zero (T₁ ⟶ T₂) where
zero :=
{ hom₁ := 0
hom₂ := 0
hom₃ := 0 }
@[simps (attr := grind =)]
instance : Add (T₁ ⟶ T₂) where
add f g :=
{ hom₁ := f.hom₁ + g.hom₁
hom₂ := f.hom₂ + g.hom₂
hom₃ := f.hom₃ + g.hom₃ }
@[simps (attr := grind =)]
instance : Neg (T₁ ⟶ T₂) where
neg f :=
{ hom₁ := -f.hom₁
hom₂ := -f.hom₂
hom₃ := -f.hom₃ }
@[simps (attr := grind =)]
instance : Sub (T₁ ⟶ T₂) where
sub f g :=
{ hom₁ := f.hom₁ - g.hom₁
hom₂ := f.hom₂ - g.hom₂
hom₃ := f.hom₃ - g.hom₃ }
section
variable {R : Type*} [Semiring R] [Linear R C]
[∀ (n : ℤ), Functor.Linear R (shiftFunctor C n)]
@[simps (attr := grind =)]
instance : SMul R (T₁ ⟶ T₂) where
smul n f :=
{ hom₁ := n • f.hom₁
hom₂ := n • f.hom₂
hom₃ := n • f.hom₃ }
omit [∀ (n : ℤ), (shiftFunctor C n).Additive]
end
instance : AddCommGroup (T₁ ⟶ T₂) where
zero_add f := by ext <;> apply zero_add
add_assoc f g h := by ext <;> apply add_assoc
add_zero f := by ext <;> apply add_zero
add_comm f g := by ext <;> apply add_comm
neg_add_cancel f := by ext <;> apply neg_add_cancel
sub_eq_add_neg f g := by ext <;> apply sub_eq_add_neg
nsmul n f := n • f
nsmul_zero f := by cat_disch
nsmul_succ n f := by ext <;> apply AddMonoid.nsmul_succ
zsmul n f := n • f
zsmul_zero' := by cat_disch
zsmul_succ' n f := by ext <;> apply SubNegMonoid.zsmul_succ'
zsmul_neg' n f := by ext <;> apply SubNegMonoid.zsmul_neg'
instance : Preadditive (Triangle C) where
end Preadditive
section Linear
variable [Preadditive C] {R : Type*} [Semiring R] [Linear R C]
[∀ (n : ℤ), (shiftFunctor C n).Additive]
[∀ (n : ℤ), Functor.Linear R (shiftFunctor C n)]
attribute [local simp] mul_smul add_smul in
instance : Module R (T₁ ⟶ T₂) where
one_smul := by aesop
mul_smul := by aesop
smul_zero := by aesop
smul_add := by aesop
add_smul := by aesop
zero_smul := by aesop
instance : Linear R (Triangle C) where
end Linear
end Triangle
/-- The obvious triangle `X₁ ⟶ X₁ ⊞ X₂ ⟶ X₂ ⟶ X₁⟦1⟧`. -/
@[simps!]
def binaryBiproductTriangle (X₁ X₂ : C) [HasZeroMorphisms C] [HasBinaryBiproduct X₁ X₂] :
Triangle C :=
Triangle.mk biprod.inl (Limits.biprod.snd : X₁ ⊞ X₂ ⟶ _) 0
/-- The obvious triangle `X₁ ⟶ X₁ ⨯ X₂ ⟶ X₂ ⟶ X₁⟦1⟧`. -/
@[simps!]
def binaryProductTriangle (X₁ X₂ : C) [HasZeroMorphisms C] [HasBinaryProduct X₁ X₂] :
Triangle C :=
Triangle.mk ((Limits.prod.lift (𝟙 X₁) 0)) (Limits.prod.snd : X₁ ⨯ X₂ ⟶ _) 0
/-- The canonical isomorphism of triangles
`binaryProductTriangle X₁ X₂ ≅ binaryBiproductTriangle X₁ X₂`. -/
@[simps!]
def binaryProductTriangleIsoBinaryBiproductTriangle
(X₁ X₂ : C) [HasZeroMorphisms C] [HasBinaryBiproduct X₁ X₂] :
binaryProductTriangle X₁ X₂ ≅ binaryBiproductTriangle X₁ X₂ :=
Triangle.isoMk _ _ (Iso.refl _) (biprod.isoProd X₁ X₂).symm (Iso.refl _)
(by cat_disch) (by simp) (by simp)
section
variable {J : Type*} (T : J → Triangle C)
[HasProduct (fun j => (T j).obj₁)] [HasProduct (fun j => (T j).obj₂)]
[HasProduct (fun j => (T j).obj₃)] [HasProduct (fun j => (T j).obj₁⟦(1 : ℤ)⟧)]
/-- The product of a family of triangles. -/
@[simps!]
def productTriangle : Triangle C :=
Triangle.mk (Limits.Pi.map (fun j => (T j).mor₁))
(Limits.Pi.map (fun j => (T j).mor₂))
(Limits.Pi.map (fun j => (T j).mor₃) ≫ inv (piComparison _ _))
/-- A projection from the product of a family of triangles. -/
@[simps]
def productTriangle.π (j : J) :
productTriangle T ⟶ T j where
hom₁ := Pi.π _ j
hom₂ := Pi.π _ j
hom₃ := Pi.π _ j
comm₃ := by
dsimp
rw [← piComparison_comp_π, assoc, IsIso.inv_hom_id_assoc]
simp only [limMap_π, Discrete.natTrans_app]
/-- The fan given by `productTriangle T`. -/
@[simp]
def productTriangle.fan : Fan T := Fan.mk (productTriangle T) (productTriangle.π T)
/-- A family of morphisms `T' ⟶ T j` lifts to a morphism `T' ⟶ productTriangle T`. -/
@[simps]
def productTriangle.lift {T' : Triangle C} (φ : ∀ j, T' ⟶ T j) :
T' ⟶ productTriangle T where
hom₁ := Pi.lift (fun j => (φ j).hom₁)
hom₂ := Pi.lift (fun j => (φ j).hom₂)
hom₃ := Pi.lift (fun j => (φ j).hom₃)
comm₃ := by
dsimp
rw [← cancel_mono (piComparison _ _), assoc, assoc, assoc, IsIso.inv_hom_id, comp_id]
cat_disch
/-- The triangle `productTriangle T` satisfies the universal property of the categorical
product of the triangles `T`. -/
def productTriangle.isLimitFan : IsLimit (productTriangle.fan T) :=
mkFanLimit _ (fun s => productTriangle.lift T s.proj) (fun s j => by cat_disch) (by
intro s m hm
ext1
all_goals
exact Pi.hom_ext _ _ (fun j => (by simp [← hm])))
lemma productTriangle.zero₃₁ [HasZeroMorphisms C]
(h : ∀ j, (T j).mor₃ ≫ (T j).mor₁⟦(1 : ℤ)⟧' = 0) :
(productTriangle T).mor₃ ≫ (productTriangle T).mor₁⟦1⟧' = 0 := by
have : HasProduct (fun j => (T j).obj₂⟦(1 : ℤ)⟧) :=
⟨_, isLimitFanMkObjOfIsLimit (shiftFunctor C (1 : ℤ)) _ _
(productIsProduct (fun j => (T j).obj₂))⟩
dsimp
change _ ≫ (Pi.lift (fun j => Pi.π _ j ≫ (T j).mor₁))⟦(1 : ℤ)⟧' = 0
rw [assoc, ← cancel_mono (piComparison _ _), zero_comp, assoc, assoc]
ext j
simp only [map_lift_piComparison, assoc, limit.lift_π, Fan.mk_π_app, zero_comp,
Functor.map_comp, ← piComparison_comp_π_assoc, IsIso.inv_hom_id_assoc,
limMap_π_assoc, Discrete.natTrans_app, h j, comp_zero]
end
variable (C) in
/-- The functor `C ⥤ Triangle C` which sends `X` to `contractibleTriangle X`. -/
@[simps]
def contractibleTriangleFunctor [HasZeroObject C] [HasZeroMorphisms C] : C ⥤ Triangle C where
obj X := contractibleTriangle X
map f :=
{ hom₁ := f
hom₂ := f
hom₃ := 0 }
namespace Triangle
/-- The first projection `Triangle C ⥤ C`. -/
@[simps]
def π₁ : Triangle C ⥤ C where
obj T := T.obj₁
map f := f.hom₁
/-- The second projection `Triangle C ⥤ C`. -/
@[simps]
def π₂ : Triangle C ⥤ C where
obj T := T.obj₂
map f := f.hom₂
/-- The third projection `Triangle C ⥤ C`. -/
@[simps]
def π₃ : Triangle C ⥤ C where
obj T := T.obj₃
map f := f.hom₃
section
variable {A B : Triangle C} (φ : A ⟶ B) [IsIso φ]
instance : IsIso φ.hom₁ := (inferInstance : IsIso (π₁.map φ))
instance : IsIso φ.hom₂ := (inferInstance : IsIso (π₂.map φ))
instance : IsIso φ.hom₃ := (inferInstance : IsIso (π₃.map φ))
end
end Triangle
end CategoryTheory.Pretriangulated |
.lake/packages/mathlib/Mathlib/CategoryTheory/Triangulated/Functor.lean | import Mathlib.CategoryTheory.Triangulated.Triangulated
import Mathlib.CategoryTheory.ComposableArrows.Basic
import Mathlib.CategoryTheory.Shift.CommShift
/-!
# Triangulated functors
In this file, when `C` and `D` are categories equipped with a shift by `ℤ` and
`F : C ⥤ D` is a functor which commutes with the shift, we define the induced
functor `F.mapTriangle : Triangle C ⥤ Triangle D` on the categories of
triangles. When `C` and `D` are pretriangulated, a triangulated functor
is such a functor `F` which also sends distinguished triangles to
distinguished triangles: this defines the typeclass `Functor.IsTriangulated`.
-/
assert_not_exists TwoSidedIdeal
namespace CategoryTheory
open Category Limits Pretriangulated Preadditive
namespace Functor
variable {C D E : Type*} [Category C] [Category D] [Category E]
[HasShift C ℤ] [HasShift D ℤ] [HasShift E ℤ]
(F : C ⥤ D) [F.CommShift ℤ] (G : D ⥤ E) [G.CommShift ℤ]
/-- The functor `Triangle C ⥤ Triangle D` that is induced by a functor `F : C ⥤ D`
which commutes with shift by `ℤ`. -/
@[simps]
def mapTriangle : Triangle C ⥤ Triangle D where
obj T := Triangle.mk (F.map T.mor₁) (F.map T.mor₂)
(F.map T.mor₃ ≫ (F.commShiftIso (1 : ℤ)).hom.app T.obj₁)
map f :=
{ hom₁ := F.map f.hom₁
hom₂ := F.map f.hom₂
hom₃ := F.map f.hom₃
comm₁ := by dsimp; simp only [← F.map_comp, f.comm₁]
comm₂ := by dsimp; simp only [← F.map_comp, f.comm₂]
comm₃ := by
dsimp [Functor.comp]
simp only [Category.assoc, ← NatTrans.naturality,
← F.map_comp_assoc, f.comm₃] }
instance [Faithful F] : Faithful F.mapTriangle where
map_injective {X Y} f g h := by
ext <;> apply F.map_injective
· exact congr_arg TriangleMorphism.hom₁ h
· exact congr_arg TriangleMorphism.hom₂ h
· exact congr_arg TriangleMorphism.hom₃ h
instance [Full F] [Faithful F] : Full F.mapTriangle where
map_surjective {X Y} f :=
⟨{hom₁ := F.preimage f.hom₁
hom₂ := F.preimage f.hom₂
hom₃ := F.preimage f.hom₃
comm₁ := F.map_injective
(by simpa only [mapTriangle_obj, map_comp, map_preimage] using f.comm₁)
comm₂ := F.map_injective
(by simpa only [mapTriangle_obj, map_comp, map_preimage] using f.comm₂)
comm₃ := F.map_injective (by
rw [← cancel_mono ((F.commShiftIso (1 : ℤ)).hom.app Y.obj₁)]
simpa only [mapTriangle_obj, map_comp, assoc, commShiftIso_hom_naturality,
map_preimage, Triangle.mk_mor₃] using f.comm₃) }, by cat_disch⟩
section Additive
variable [Preadditive C] [Preadditive D] [F.Additive]
/-- The functor `F.mapTriangle` commutes with the shift. -/
noncomputable def mapTriangleCommShiftIso (n : ℤ) :
Triangle.shiftFunctor C n ⋙ F.mapTriangle ≅ F.mapTriangle ⋙ Triangle.shiftFunctor D n :=
NatIso.ofComponents (fun T => Triangle.isoMk _ _
((F.commShiftIso n).app _) ((F.commShiftIso n).app _) ((F.commShiftIso n).app _)
(by simp) (by simp) (by
dsimp
simp only [map_units_smul, map_comp, Linear.units_smul_comp, assoc,
Linear.comp_units_smul, ← F.commShiftIso_hom_naturality_assoc]
rw [F.map_shiftFunctorComm_hom_app T.obj₁ 1 n]
simp only [comp_obj, assoc, Iso.inv_hom_id_app_assoc,
← Functor.map_comp, Iso.inv_hom_id_app, map_id, comp_id])) (by cat_disch)
attribute [simps!] mapTriangleCommShiftIso
attribute [local simp] map_zsmul comp_zsmul zsmul_comp
commShiftIso_zero commShiftIso_add commShiftIso_comp_hom_app
shiftFunctorAdd'_eq_shiftFunctorAdd
-- Split out from the following instance for faster elaboration.
private theorem mapTriangleCommShiftIso_add
[∀ (n : ℤ), (shiftFunctor C n).Additive]
[∀ (n : ℤ), (shiftFunctor D n).Additive] (n m : ℤ) :
F.mapTriangleCommShiftIso (n + m) =
CommShift.isoAdd (a := n) (b := m)
(F.mapTriangleCommShiftIso n) (F.mapTriangleCommShiftIso m) := by
ext <;> simp
noncomputable instance [∀ (n : ℤ), (shiftFunctor C n).Additive]
[∀ (n : ℤ), (shiftFunctor D n).Additive] : (F.mapTriangle).CommShift ℤ where
commShiftIso := F.mapTriangleCommShiftIso
commShiftIso_add _ _ := mapTriangleCommShiftIso_add ..
/-- `F.mapTriangle` commutes with the rotation of triangles. -/
@[simps!]
def mapTriangleRotateIso :
F.mapTriangle ⋙ Pretriangulated.rotate D ≅
Pretriangulated.rotate C ⋙ F.mapTriangle :=
NatIso.ofComponents
(fun T => Triangle.isoMk _ _ (Iso.refl _) (Iso.refl _)
((F.commShiftIso (1 : ℤ)).symm.app _)
(by simp) (by simp) (by simp)) (by cat_disch)
/-- `F.mapTriangle` commutes with the inverse of the rotation of triangles. -/
@[simps!]
noncomputable def mapTriangleInvRotateIso [F.Additive] :
F.mapTriangle ⋙ Pretriangulated.invRotate D ≅
Pretriangulated.invRotate C ⋙ F.mapTriangle :=
NatIso.ofComponents
(fun T => Triangle.isoMk _ _ ((F.commShiftIso (-1 : ℤ)).symm.app _) (Iso.refl _) (Iso.refl _)
(by simp) (by simp) (by simp)) (by cat_disch)
variable (C) in
/-- The canonical isomorphism `(𝟭 C).mapTriangle ≅ 𝟭 (Triangle C)`. -/
@[simps!]
def mapTriangleIdIso : (𝟭 C).mapTriangle ≅ 𝟭 _ :=
NatIso.ofComponents (fun T ↦ Triangle.isoMk _ _ (Iso.refl _) (Iso.refl _) (Iso.refl _))
/-- The canonical isomorphism `(F ⋙ G).mapTriangle ≅ F.mapTriangle ⋙ G.mapTriangle`. -/
@[simps!]
def mapTriangleCompIso : (F ⋙ G).mapTriangle ≅ F.mapTriangle ⋙ G.mapTriangle :=
NatIso.ofComponents (fun T => Triangle.isoMk _ _ (Iso.refl _) (Iso.refl _) (Iso.refl _))
/-- Two isomorphic functors `F₁` and `F₂` induce isomorphic functors
`F₁.mapTriangle` and `F₂.mapTriangle` if the isomorphism `F₁ ≅ F₂` is compatible
with the shifts. -/
@[simps!]
def mapTriangleIso {F₁ F₂ : C ⥤ D} (e : F₁ ≅ F₂) [F₁.CommShift ℤ] [F₂.CommShift ℤ]
[NatTrans.CommShift e.hom ℤ] : F₁.mapTriangle ≅ F₂.mapTriangle :=
NatIso.ofComponents (fun T =>
Triangle.isoMk _ _ (e.app _) (e.app _) (e.app _) (by simp) (by simp) (by
dsimp
simp only [assoc, NatTrans.shift_app_comm e.hom (1 : ℤ) T.obj₁,
NatTrans.naturality_assoc])) (by cat_disch)
end Additive
variable [HasZeroObject C] [HasZeroObject D] [HasZeroObject E]
[Preadditive C] [Preadditive D] [Preadditive E]
[∀ (n : ℤ), (shiftFunctor C n).Additive] [∀ (n : ℤ), (shiftFunctor D n).Additive]
[∀ (n : ℤ), (shiftFunctor E n).Additive]
[Pretriangulated C] [Pretriangulated D] [Pretriangulated E]
/-- A functor which commutes with the shift by `ℤ` is triangulated if
it sends distinguished triangles to distinguished triangles. -/
class IsTriangulated : Prop where
map_distinguished (T : Triangle C) : (T ∈ distTriang C) → F.mapTriangle.obj T ∈ distTriang D
lemma map_distinguished [F.IsTriangulated] (T : Triangle C) (hT : T ∈ distTriang C) :
F.mapTriangle.obj T ∈ distTriang D :=
IsTriangulated.map_distinguished _ hT
namespace IsTriangulated
open ZeroObject
instance (priority := 100) [F.IsTriangulated] : PreservesZeroMorphisms F where
map_zero X Y := by
have h₁ : (0 : X ⟶ Y) = 0 ≫ 𝟙 0 ≫ 0 := by simp
have h₂ : 𝟙 (F.obj 0) = 0 := by
rw [← IsZero.iff_id_eq_zero]
apply Triangle.isZero₃_of_isIso₁ _
(F.map_distinguished _ (contractible_distinguished (0 : C)))
dsimp
infer_instance
rw [h₁, F.map_comp, F.map_comp, F.map_id, h₂, zero_comp, comp_zero]
noncomputable instance [F.IsTriangulated] :
PreservesLimitsOfShape (Discrete WalkingPair) F := by
suffices ∀ (X₁ X₃ : C), IsIso (prodComparison F X₁ X₃) by
have := fun (X₁ X₃ : C) ↦ PreservesLimitPair.of_iso_prod_comparison F X₁ X₃
exact ⟨fun {K} ↦ preservesLimit_of_iso_diagram F (diagramIsoPair K).symm⟩
intro X₁ X₃
let φ : F.mapTriangle.obj (binaryProductTriangle X₁ X₃) ⟶
binaryProductTriangle (F.obj X₁) (F.obj X₃) :=
{ hom₁ := 𝟙 _
hom₂ := prodComparison F X₁ X₃
hom₃ := 𝟙 _
comm₁ := by
dsimp
ext
· simp only [assoc, prodComparison_fst, prod.comp_lift, comp_id, comp_zero,
limit.lift_π, BinaryFan.mk_pt, BinaryFan.π_app_left, BinaryFan.mk_fst,
← F.map_comp, F.map_id]
· simp only [assoc, prodComparison_snd, prod.comp_lift, comp_id, comp_zero,
limit.lift_π, BinaryFan.mk_pt, BinaryFan.π_app_right, BinaryFan.mk_snd,
← F.map_comp, F.map_zero]
comm₂ := by simp
comm₃ := by simp }
exact isIso₂_of_isIso₁₃ φ (F.map_distinguished _ (binaryProductTriangle_distinguished X₁ X₃))
(binaryProductTriangle_distinguished _ _)
(by dsimp [φ]; infer_instance) (by dsimp [φ]; infer_instance)
instance (priority := 100) [F.IsTriangulated] : F.Additive :=
F.additive_of_preserves_binary_products
instance : (𝟭 C).IsTriangulated where
map_distinguished T hT :=
isomorphic_distinguished _ hT _ ((mapTriangleIdIso C).app T)
instance [F.IsTriangulated] [G.IsTriangulated] : (F ⋙ G).IsTriangulated where
map_distinguished T hT :=
isomorphic_distinguished _ (G.map_distinguished _ (F.map_distinguished T hT)) _
((mapTriangleCompIso F G).app T)
end IsTriangulated
lemma isTriangulated_of_iso {F₁ F₂ : C ⥤ D} (e : F₁ ≅ F₂) [F₁.CommShift ℤ] [F₂.CommShift ℤ]
[NatTrans.CommShift e.hom ℤ] [F₁.IsTriangulated] : F₂.IsTriangulated where
map_distinguished T hT :=
isomorphic_distinguished _ (F₁.map_distinguished T hT) _ ((mapTriangleIso e).app T).symm
lemma isTriangulated_iff_of_iso {F₁ F₂ : C ⥤ D} (e : F₁ ≅ F₂) [F₁.CommShift ℤ] [F₂.CommShift ℤ]
[NatTrans.CommShift e.hom ℤ] : F₁.IsTriangulated ↔ F₂.IsTriangulated := by
constructor
· intro
exact isTriangulated_of_iso e
· intro
have : NatTrans.CommShift e.symm.hom ℤ := inferInstanceAs (NatTrans.CommShift e.inv ℤ)
exact isTriangulated_of_iso e.symm
lemma mem_mapTriangle_essImage_of_distinguished
[F.IsTriangulated] [F.mapArrow.EssSurj] (T : Triangle D) (hT : T ∈ distTriang D) :
∃ (T' : Triangle C) (_ : T' ∈ distTriang C), Nonempty (F.mapTriangle.obj T' ≅ T) := by
obtain ⟨X, Y, f, e₁, e₂, w⟩ : ∃ (X Y : C) (f : X ⟶ Y) (e₁ : F.obj X ≅ T.obj₁)
(e₂ : F.obj Y ≅ T.obj₂), F.map f ≫ e₂.hom = e₁.hom ≫ T.mor₁ := by
let e := F.mapArrow.objObjPreimageIso (Arrow.mk T.mor₁)
exact ⟨_, _, _, Arrow.leftFunc.mapIso e, Arrow.rightFunc.mapIso e, e.hom.w.symm⟩
obtain ⟨W, g, h, H⟩ := distinguished_cocone_triangle f
exact ⟨_, H, ⟨isoTriangleOfIso₁₂ _ _ (F.map_distinguished _ H) hT e₁ e₂ w⟩⟩
lemma isTriangulated_of_precomp
[(F ⋙ G).IsTriangulated] [F.IsTriangulated] [F.mapArrow.EssSurj] :
G.IsTriangulated where
map_distinguished T hT := by
obtain ⟨T', hT', ⟨e⟩⟩ := F.mem_mapTriangle_essImage_of_distinguished T hT
exact isomorphic_distinguished _ ((F ⋙ G).map_distinguished T' hT') _
(G.mapTriangle.mapIso e.symm ≪≫ (mapTriangleCompIso F G).symm.app _)
variable {F G} in
lemma isTriangulated_of_precomp_iso {H : C ⥤ E} (e : F ⋙ G ≅ H) [H.CommShift ℤ]
[H.IsTriangulated] [F.IsTriangulated] [F.mapArrow.EssSurj] [NatTrans.CommShift e.hom ℤ] :
G.IsTriangulated := by
have := (isTriangulated_iff_of_iso e).2 inferInstance
exact isTriangulated_of_precomp F G
end Functor
variable {C D : Type*} [Category C] [Category D] [HasShift C ℤ] [HasShift D ℤ]
[HasZeroObject C] [HasZeroObject D] [Preadditive C] [Preadditive D]
[∀ (n : ℤ), (shiftFunctor C n).Additive] [∀ (n : ℤ), (shiftFunctor D n).Additive]
[Pretriangulated C] [Pretriangulated D]
namespace Triangulated
namespace Octahedron
variable {X₁ X₂ X₃ Z₁₂ Z₂₃ Z₁₃ : C}
{u₁₂ : X₁ ⟶ X₂} {u₂₃ : X₂ ⟶ X₃} {u₁₃ : X₁ ⟶ X₃} {comm : u₁₂ ≫ u₂₃ = u₁₃}
{v₁₂ : X₂ ⟶ Z₁₂} {w₁₂ : Z₁₂ ⟶ X₁⟦(1 : ℤ)⟧} {h₁₂ : Triangle.mk u₁₂ v₁₂ w₁₂ ∈ distTriang C}
{v₂₃ : X₃ ⟶ Z₂₃} {w₂₃ : Z₂₃ ⟶ X₂⟦(1 : ℤ)⟧} {h₂₃ : Triangle.mk u₂₃ v₂₃ w₂₃ ∈ distTriang C}
{v₁₃ : X₃ ⟶ Z₁₃} {w₁₃ : Z₁₃ ⟶ X₁⟦(1 : ℤ)⟧} {h₁₃ : Triangle.mk u₁₃ v₁₃ w₁₃ ∈ distTriang C}
(h : Octahedron comm h₁₂ h₂₃ h₁₃)
(F : C ⥤ D) [F.CommShift ℤ] [F.IsTriangulated]
/-- The image of an octahedron by a triangulated functor. -/
@[simps]
def map : Octahedron (by dsimp; rw [← F.map_comp, comm])
(F.map_distinguished _ h₁₂) (F.map_distinguished _ h₂₃) (F.map_distinguished _ h₁₃) where
m₁ := F.map h.m₁
m₃ := F.map h.m₃
comm₁ := by simpa using F.congr_map h.comm₁
comm₂ := by simpa using F.congr_map h.comm₂ =≫ (F.commShiftIso 1).hom.app X₁
comm₃ := by simpa using F.congr_map h.comm₃
comm₄ := by simpa using F.congr_map h.comm₄ =≫ (F.commShiftIso 1).hom.app X₂
mem := isomorphic_distinguished _ (F.map_distinguished _ h.mem) _
(Triangle.isoMk _ _ (Iso.refl _) (Iso.refl _) (Iso.refl _))
end Octahedron
end Triangulated
open Triangulated
/-- If `F : C ⥤ D` is a triangulated functor from a triangulated category, then `D`
is also triangulated if tuples of composables arrows in `D` can be lifted to `C`. -/
lemma isTriangulated_of_essSurj_mapComposableArrows_two
(F : C ⥤ D) [F.CommShift ℤ] [F.IsTriangulated]
[(F.mapComposableArrows 2).EssSurj] [IsTriangulated C] :
IsTriangulated D := by
apply IsTriangulated.mk
intro Y₁ Y₂ Y₃ Z₁₂ Z₂₃ Z₁₃ u₁₂ u₂₃ u₁₃ comm v₁₂ w₁₂ h₁₂ v₂₃ w₂₃ h₂₃ v₁₃ w₁₃ h₁₃
obtain ⟨α, ⟨e⟩⟩ : ∃ (α : ComposableArrows C 2),
Nonempty ((F.mapComposableArrows 2).obj α ≅ ComposableArrows.mk₂ u₁₂ u₂₃) :=
⟨_, ⟨Functor.objObjPreimageIso _ _⟩⟩
obtain ⟨X₁, X₂, X₃, f, g, rfl⟩ := ComposableArrows.mk₂_surjective α
obtain ⟨_, _, _, h₁₂'⟩ := distinguished_cocone_triangle f
obtain ⟨_, _, _, h₂₃'⟩ := distinguished_cocone_triangle g
obtain ⟨_, _, _, h₁₃'⟩ := distinguished_cocone_triangle (f ≫ g)
exact ⟨Octahedron.ofIso (e₁ := (e.app 0).symm) (e₂ := (e.app 1).symm) (e₃ := (e.app 2).symm)
(comm₁₂ := ComposableArrows.naturality' e.inv 0 1)
(comm₂₃ := ComposableArrows.naturality' e.inv 1 2)
(H := (someOctahedron rfl h₁₂' h₂₃' h₁₃').map F) ..⟩
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Triangulated/Adjunction.lean | import Mathlib.CategoryTheory.Triangulated.Functor
import Mathlib.CategoryTheory.Shift.Adjunction
import Mathlib.CategoryTheory.Adjunction.Additive
import Mathlib.CategoryTheory.Adjunction.Opposites
import Mathlib.CategoryTheory.Triangulated.Opposite.Functor
/-!
# The adjoint functor is triangulated
If a functor `F : C ⥤ D` between pretriangulated categories is triangulated, and if we
have an adjunction `F ⊣ G`, then `G` is also a triangulated functor. We deduce the
symmetric statement (if `G` is a triangulated functor, then so is `F`) using opposite
categories.
We then introduce a class `IsTriangulated` for adjunctions: an adjunction `F ⊣ G`
is called triangulated if both `F` and `G` are triangulated, and if the adjunction
is compatible with the shifts by `ℤ` on `F` and `G` (in the sense of `Adjunction.CommShift`);
we prove that this is compatible with composition and that the identity adjunction is
triangulated.
Thanks to the results above, an adjunction carrying an `Adjunction.CommShift` instance
is triangulated as soon as one of the adjoint functors is triangulated.
We finally specialize these structures to equivalences of categories, and prove that,
if `E : C ≌ D` is an equivalence of pretriangulated categories, then
`E.functor` is triangulated if and only if `E.inverse` is triangulated.
-/
assert_not_exists TwoSidedIdeal
namespace CategoryTheory
open Category Limits Preadditive Pretriangulated Adjunction
variable {C D : Type*} [Category C] [Category D] [HasZeroObject C] [HasZeroObject D]
[Preadditive C] [Preadditive D] [HasShift C ℤ] [HasShift D ℤ]
[∀ (n : ℤ), (shiftFunctor C n).Additive] [∀ (n : ℤ), (shiftFunctor D n).Additive]
[Pretriangulated C] [Pretriangulated D]
namespace Adjunction
variable {F : C ⥤ D} {G : D ⥤ C} (adj : F ⊣ G) [F.CommShift ℤ] [G.CommShift ℤ]
[adj.CommShift ℤ]
include adj in
/--
The right adjoint of a triangulated functor is triangulated.
-/
lemma isTriangulated_rightAdjoint [F.IsTriangulated] : G.IsTriangulated where
map_distinguished T hT := by
have : G.Additive := adj.right_adjoint_additive
obtain ⟨Z, f, g, mem⟩ := distinguished_cocone_triangle (G.map T.mor₁)
obtain ⟨h, ⟨h₁, h₂⟩⟩ := complete_distinguished_triangle_morphism _ _
(F.map_distinguished _ mem) hT (adj.counit.app T.obj₁) (adj.counit.app T.obj₂) (by simp)
dsimp at h h₁ h₂ ⊢
have h₁' : f ≫ adj.unit.app Z ≫ G.map h = G.map T.mor₂ := by
simpa [homEquiv_apply] using DFunLike.congr_arg (adj.homEquiv _ _) h₁
have h₂' : g ≫ (G.commShiftIso (1 : ℤ)).inv.app T.obj₁ =
adj.homEquiv _ _ h ≫ G.map T.mor₃ := by
apply (adj.homEquiv _ _).symm.injective
simp only [Functor.comp_obj, homEquiv_counit, Functor.id_obj, Functor.map_comp, assoc,
homEquiv_unit, counit_naturality, counit_naturality_assoc, left_triangle_components_assoc,
← h₂, adj.shift_counit_app, Iso.hom_inv_id_app_assoc]
rw [assoc] at h₂
have : Mono (adj.homEquiv _ _ h) := by
rw [mono_iff_cancel_zero]
intro _ φ hφ
obtain ⟨ψ, rfl⟩ := Triangle.coyoneda_exact₃ _ mem φ (by
dsimp
simp only [homEquiv_unit, Functor.comp_obj] at hφ
rw [← cancel_mono ((G.commShiftIso (1 : ℤ)).inv.app T.obj₁), assoc, h₂', zero_comp,
homEquiv_unit, assoc, reassoc_of% hφ, zero_comp])
dsimp at ψ hφ ⊢
obtain ⟨α, hα⟩ := T.coyoneda_exact₂ hT ((adj.homEquiv _ _).symm ψ)
((adj.homEquiv _ _).injective (by simpa [homEquiv_counit, homEquiv_unit, ← h₁'] using hφ))
have eq := DFunLike.congr_arg (adj.homEquiv _ _ ) hα
simp only [homEquiv_counit, homEquiv_unit, comp_id,
Functor.map_comp, unit_naturality_assoc, right_triangle_components] at eq
have eq' := comp_distTriang_mor_zero₁₂ _ mem
dsimp at eq eq'
rw [eq, assoc, assoc, eq', comp_zero, comp_zero]
have := isIso_of_yoneda_map_bijective (adj.homEquiv _ _ h) (fun Y => by
constructor
· intro φ₁ φ₂ hφ
rw [← cancel_mono (adj.homEquiv _ _ h)]
exact hφ
· intro φ
obtain ⟨ψ, hψ⟩ := Triangle.coyoneda_exact₁ _ mem (φ ≫ G.map T.mor₃ ≫
(G.commShiftIso (1 : ℤ)).hom.app T.obj₁) (by
dsimp
rw [assoc, assoc, ← G.commShiftIso_hom_naturality, ← G.map_comp_assoc,
comp_distTriang_mor_zero₃₁ _ hT, G.map_zero, zero_comp, comp_zero])
dsimp at ψ hψ
obtain ⟨α, hα⟩ : ∃ α, α = φ - ψ ≫ adj.homEquiv _ _ h := ⟨_, rfl⟩
have hα₀ : α ≫ G.map T.mor₃ = 0 := by
rw [hα, sub_comp, ← cancel_mono ((Functor.commShiftIso G (1 : ℤ)).hom.app T.obj₁),
assoc, sub_comp, assoc, assoc, hψ, zero_comp, sub_eq_zero,
← cancel_mono ((Functor.commShiftIso G (1 : ℤ)).inv.app T.obj₁), assoc,
assoc, assoc, assoc, h₂', Iso.hom_inv_id_app, comp_id]
suffices ∃ (β : Y ⟶ Z), β ≫ adj.homEquiv _ _ h = α by
obtain ⟨β, hβ⟩ := this
refine ⟨ψ + β, ?_⟩
dsimp
rw [add_comp, hβ, hα, add_sub_cancel]
obtain ⟨β, hβ⟩ := T.coyoneda_exact₃ hT ((adj.homEquiv _ _).symm α)
((adj.homEquiv _ _).injective (by simpa [homEquiv_unit, homEquiv_counit] using hα₀))
refine ⟨adj.homEquiv _ _ β ≫ f, ?_⟩
simpa [homEquiv_unit, h₁'] using congr_arg (adj.homEquiv _ _).toFun hβ.symm)
refine isomorphic_distinguished _ mem _ (Iso.symm ?_)
refine Triangle.isoMk _ _ (Iso.refl _) (Iso.refl _) (asIso (adj.homEquiv Z T.obj₃ h)) ?_ ?_ ?_
· simp
· apply (adj.homEquiv _ _).symm.injective
dsimp
simp only [homEquiv_unit, homEquiv_counit, Functor.map_comp, assoc,
counit_naturality, left_triangle_components_assoc, h₁, id_comp]
· dsimp
rw [Functor.map_id, comp_id, homEquiv_unit, assoc, ← G.map_comp_assoc, ← h₂,
Functor.map_comp, Functor.map_comp, assoc, unit_naturality_assoc, assoc,
Functor.commShiftIso_hom_naturality, ← adj.shift_unit_app_assoc,
← Functor.map_comp, right_triangle_components, Functor.map_id, comp_id]
include adj in
open Pretriangulated.Opposite Functor in
/--
The left adjoint of a triangulated functor is triangulated.
-/
lemma isTriangulated_leftAdjoint [G.IsTriangulated] : F.IsTriangulated := by
have := isTriangulated_rightAdjoint adj.op
exact F.isTriangulated_of_op
/--
We say that an adjunction `F ⊣ G` is triangulated if it is compatible with the `CommShift`
structures on `F` and `G` (in the sense of `Adjunction.CommShift`) and if both `F` and `G`
are triangulated functors.
-/
class IsTriangulated : Prop where
commShift : adj.CommShift ℤ := by infer_instance
leftAdjoint_isTriangulated : F.IsTriangulated := by infer_instance
rightAdjoint_isTriangulated : G.IsTriangulated := by infer_instance
namespace IsTriangulated
attribute [instance] commShift leftAdjoint_isTriangulated rightAdjoint_isTriangulated
/-- Constructor for `Adjunction.IsTriangulated`.
-/
lemma mk' [F.IsTriangulated] : adj.IsTriangulated where
rightAdjoint_isTriangulated := adj.isTriangulated_rightAdjoint
/-- Constructor for `Adjunction.IsTriangulated`.
-/
lemma mk'' [G.IsTriangulated] : adj.IsTriangulated where
leftAdjoint_isTriangulated := adj.isTriangulated_leftAdjoint
/-- The identity adjunction is triangulated.
-/
instance id : (Adjunction.id (C := C)).IsTriangulated where
variable {E : Type*} [Category E] {F' : D ⥤ E} {G' : E ⥤ D} (adj' : F' ⊣ G') [HasZeroObject E]
[Preadditive E] [HasShift E ℤ] [∀ (n : ℤ), (shiftFunctor E n).Additive] [Pretriangulated E]
[F'.CommShift ℤ] [G'.CommShift ℤ] [adj'.CommShift ℤ]
/-- A composition of triangulated adjunctions is triangulated.
-/
instance comp [adj.IsTriangulated] [adj'.IsTriangulated] : (adj.comp adj').IsTriangulated where
end IsTriangulated
end Adjunction
namespace Equivalence
variable (E : C ≌ D) [E.functor.CommShift ℤ] [E.inverse.CommShift ℤ] [E.CommShift ℤ]
/--
We say that an equivalence of categories `E` is triangulated if both `E.functor` and
`E.inverse` are triangulated functors.
-/
abbrev IsTriangulated : Prop := E.toAdjunction.IsTriangulated
namespace IsTriangulated
instance [E.IsTriangulated] : E.functor.IsTriangulated := inferInstance
instance [E.IsTriangulated] : E.inverse.IsTriangulated := inferInstance
instance [h : E.functor.IsTriangulated] : E.symm.inverse.IsTriangulated := h
instance [h : E.inverse.IsTriangulated] : E.symm.functor.IsTriangulated := h
/-- Constructor for `Equivalence.IsTriangulated`. -/
lemma mk' (h : E.functor.IsTriangulated) : E.IsTriangulated where
rightAdjoint_isTriangulated := E.toAdjunction.isTriangulated_rightAdjoint
/-- Constructor for `Equivalence.IsTriangulated`. -/
lemma mk'' (h : E.inverse.IsTriangulated) : E.IsTriangulated where
leftAdjoint_isTriangulated := (mk' E.symm h).rightAdjoint_isTriangulated
/--
The identity equivalence is triangulated.
-/
instance refl : (Equivalence.refl (C := C)).IsTriangulated := by
dsimp [Equivalence.IsTriangulated]
rw [refl_toAdjunction]
infer_instance
/-- If the equivalence `E` is triangulated, so is the equivalence `E.symm`.
-/
instance symm [E.IsTriangulated] : E.symm.IsTriangulated where
variable {D' : Type*} [Category D'] [HasZeroObject D'] [Preadditive D'] [HasShift D' ℤ]
[∀ (n : ℤ), (shiftFunctor D' n).Additive] [Pretriangulated D'] {E' : D ≌ D'}
[E'.functor.CommShift ℤ] [E'.inverse.CommShift ℤ] [E'.CommShift ℤ]
/--
If equivalences `E : C ≌ D` and `E' : D ≌ F` are triangulated, so is `E.trans E'`.
-/
instance trans [E.IsTriangulated] [E'.IsTriangulated] : (E.trans E').IsTriangulated := by
dsimp [Equivalence.IsTriangulated]
rw [trans_toAdjunction]
infer_instance
end IsTriangulated
end Equivalence
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Triangulated/Pretriangulated.lean | import Mathlib.Algebra.Homology.ShortComplex.Basic
import Mathlib.CategoryTheory.Limits.Constructions.FiniteProductsOfBinaryProducts
import Mathlib.CategoryTheory.Triangulated.TriangleShift
/-!
# Pretriangulated Categories
This file contains the definition of pretriangulated categories and triangulated functors
between them.
## Implementation Notes
We work under the assumption that pretriangulated categories are preadditive categories,
but not necessarily additive categories, as is assumed in some sources.
TODO: generalise this to n-angulated categories as in https://arxiv.org/abs/1006.4592
-/
assert_not_exists TwoSidedIdeal
noncomputable section
open CategoryTheory Preadditive Limits
universe v v₀ v₁ v₂ u u₀ u₁ u₂
namespace CategoryTheory
open Category Pretriangulated ZeroObject
/-
We work in a preadditive category `C` equipped with an additive shift.
-/
variable (C : Type u) [Category.{v} C] [HasZeroObject C] [HasShift C ℤ] [Preadditive C]
/-- A preadditive category `C` with an additive shift, and a class of "distinguished triangles"
relative to that shift is called pretriangulated if the following hold:
* Any triangle that is isomorphic to a distinguished triangle is also distinguished.
* Any triangle of the form `(X,X,0,id,0,0)` is distinguished.
* For any morphism `f : X ⟶ Y` there exists a distinguished triangle of the form `(X,Y,Z,f,g,h)`.
* The triangle `(X,Y,Z,f,g,h)` is distinguished if and only if `(Y,Z,X⟦1⟧,g,h,-f⟦1⟧)` is.
* Given a diagram:
```
f g h
X ───> Y ───> Z ───> X⟦1⟧
│ │ │
│a │b │a⟦1⟧'
V V V
X' ───> Y' ───> Z' ───> X'⟦1⟧
f' g' h'
```
where the left square commutes, and whose rows are distinguished triangles,
there exists a morphism `c : Z ⟶ Z'` such that `(a,b,c)` is a triangle morphism.
-/
@[stacks 0145]
class Pretriangulated [∀ n : ℤ, Functor.Additive (shiftFunctor C n)] where
/-- a class of triangle which are called `distinguished` -/
distinguishedTriangles : Set (Triangle C)
/-- a triangle that is isomorphic to a distinguished triangle is distinguished -/
isomorphic_distinguished :
∀ T₁ ∈ distinguishedTriangles, ∀ (T₂) (_ : T₂ ≅ T₁), T₂ ∈ distinguishedTriangles
/-- obvious triangles `X ⟶ X ⟶ 0 ⟶ X⟦1⟧` are distinguished -/
contractible_distinguished : ∀ X : C, contractibleTriangle X ∈ distinguishedTriangles
/-- any morphism `X ⟶ Y` is part of a distinguished triangle `X ⟶ Y ⟶ Z ⟶ X⟦1⟧` -/
distinguished_cocone_triangle :
∀ {X Y : C} (f : X ⟶ Y),
∃ (Z : C) (g : Y ⟶ Z) (h : Z ⟶ X⟦(1 : ℤ)⟧), Triangle.mk f g h ∈ distinguishedTriangles
/-- a triangle is distinguished iff it is so after rotating it -/
rotate_distinguished_triangle :
∀ T : Triangle C, T ∈ distinguishedTriangles ↔ T.rotate ∈ distinguishedTriangles
/-- given two distinguished triangle, a commutative square
can be extended as morphism of triangles -/
complete_distinguished_triangle_morphism :
∀ (T₁ T₂ : Triangle C) (_ : T₁ ∈ distinguishedTriangles) (_ : T₂ ∈ distinguishedTriangles)
(a : T₁.obj₁ ⟶ T₂.obj₁) (b : T₁.obj₂ ⟶ T₂.obj₂) (_ : T₁.mor₁ ≫ b = a ≫ T₂.mor₁),
∃ c : T₁.obj₃ ⟶ T₂.obj₃, T₁.mor₂ ≫ c = b ≫ T₂.mor₂ ∧ T₁.mor₃ ≫ a⟦1⟧' = c ≫ T₂.mor₃
namespace Pretriangulated
variable [∀ n : ℤ, Functor.Additive (CategoryTheory.shiftFunctor C n)] [hC : Pretriangulated C]
/-- distinguished triangles in a pretriangulated category -/
notation:60 "distTriang " C:60 => @distinguishedTriangles C _ _ _ _ _ _
variable {C}
lemma distinguished_iff_of_iso {T₁ T₂ : Triangle C} (e : T₁ ≅ T₂) :
T₁ ∈ distTriang C ↔ T₂ ∈ distTriang C :=
⟨fun hT₁ => isomorphic_distinguished _ hT₁ _ e.symm,
fun hT₂ => isomorphic_distinguished _ hT₂ _ e⟩
/-- Given any distinguished triangle `T`, then we know `T.rotate` is also distinguished.
-/
theorem rot_of_distTriang (T : Triangle C) (H : T ∈ distTriang C) : T.rotate ∈ distTriang C :=
(rotate_distinguished_triangle T).mp H
/-- Given any distinguished triangle `T`, then we know `T.inv_rotate` is also distinguished.
-/
theorem inv_rot_of_distTriang (T : Triangle C) (H : T ∈ distTriang C) :
T.invRotate ∈ distTriang C :=
(rotate_distinguished_triangle T.invRotate).mpr
(isomorphic_distinguished T H T.invRotate.rotate (invRotCompRot.app T))
/-- Given any distinguished triangle
```
f g h
X ───> Y ───> Z ───> X⟦1⟧
```
the composition `f ≫ g = 0`. -/
@[reassoc, stacks 0146]
theorem comp_distTriang_mor_zero₁₂ (T) (H : T ∈ distTriang C) : T.mor₁ ≫ T.mor₂ = 0 := by
obtain ⟨c, hc⟩ :=
complete_distinguished_triangle_morphism _ _ (contractible_distinguished T.obj₁) H (𝟙 T.obj₁)
T.mor₁ rfl
simpa only [contractibleTriangle_mor₂, zero_comp] using hc.left.symm
/-- Given any distinguished triangle
```
f g h
X ───> Y ───> Z ───> X⟦1⟧
```
the composition `g ≫ h = 0`. -/
@[reassoc, stacks 0146]
theorem comp_distTriang_mor_zero₂₃ (T : Triangle C) (H : T ∈ distTriang C) :
T.mor₂ ≫ T.mor₃ = 0 :=
comp_distTriang_mor_zero₁₂ T.rotate (rot_of_distTriang T H)
/-- Given any distinguished triangle
```
f g h
X ───> Y ───> Z ───> X⟦1⟧
```
the composition `h ≫ f⟦1⟧ = 0`. -/
@[reassoc, stacks 0146]
theorem comp_distTriang_mor_zero₃₁ (T : Triangle C) (H : T ∈ distTriang C) :
T.mor₃ ≫ T.mor₁⟦1⟧' = 0 := by
have H₂ := rot_of_distTriang T.rotate (rot_of_distTriang T H)
simpa using comp_distTriang_mor_zero₁₂ T.rotate.rotate H₂
/-- The short complex `T.obj₁ ⟶ T.obj₂ ⟶ T.obj₃` attached to a distinguished triangle. -/
@[simps]
def shortComplexOfDistTriangle (T : Triangle C) (hT : T ∈ distTriang C) : ShortComplex C :=
ShortComplex.mk T.mor₁ T.mor₂ (comp_distTriang_mor_zero₁₂ _ hT)
/-- The isomorphism between the short complex attached to
two isomorphic distinguished triangles. -/
@[simps!]
def shortComplexOfDistTriangleIsoOfIso {T T' : Triangle C} (e : T ≅ T') (hT : T ∈ distTriang C) :
shortComplexOfDistTriangle T hT ≅ shortComplexOfDistTriangle T'
(isomorphic_distinguished _ hT _ e.symm) :=
ShortComplex.isoMk (Triangle.π₁.mapIso e) (Triangle.π₂.mapIso e) (Triangle.π₃.mapIso e)
/-- Any morphism `Y ⟶ Z` is part of a distinguished triangle `X ⟶ Y ⟶ Z ⟶ X⟦1⟧` -/
lemma distinguished_cocone_triangle₁ {Y Z : C} (g : Y ⟶ Z) :
∃ (X : C) (f : X ⟶ Y) (h : Z ⟶ X⟦(1 : ℤ)⟧), Triangle.mk f g h ∈ distTriang C := by
obtain ⟨X', f', g', mem⟩ := distinguished_cocone_triangle g
exact ⟨_, _, _, inv_rot_of_distTriang _ mem⟩
/-- Any morphism `Z ⟶ X⟦1⟧` is part of a distinguished triangle `X ⟶ Y ⟶ Z ⟶ X⟦1⟧` -/
lemma distinguished_cocone_triangle₂ {Z X : C} (h : Z ⟶ X⟦(1 : ℤ)⟧) :
∃ (Y : C) (f : X ⟶ Y) (g : Y ⟶ Z), Triangle.mk f g h ∈ distTriang C := by
obtain ⟨Y', f', g', mem⟩ := distinguished_cocone_triangle h
let T' := (Triangle.mk h f' g').invRotate.invRotate
refine ⟨T'.obj₂, ((shiftEquiv C (1 : ℤ)).unitIso.app X).hom ≫ T'.mor₁, T'.mor₂,
isomorphic_distinguished _ (inv_rot_of_distTriang _ (inv_rot_of_distTriang _ mem)) _ ?_⟩
exact Triangle.isoMk _ _ ((shiftEquiv C (1 : ℤ)).unitIso.app X) (Iso.refl _) (Iso.refl _)
(by cat_disch) (by cat_disch)
(by dsimp; simp only [shift_shiftFunctorCompIsoId_inv_app, id_comp])
/-- A commutative square involving the morphisms `mor₂` of two distinguished triangles
can be extended as morphism of triangles -/
lemma complete_distinguished_triangle_morphism₁ (T₁ T₂ : Triangle C)
(hT₁ : T₁ ∈ distTriang C) (hT₂ : T₂ ∈ distTriang C) (b : T₁.obj₂ ⟶ T₂.obj₂)
(c : T₁.obj₃ ⟶ T₂.obj₃) (comm : T₁.mor₂ ≫ c = b ≫ T₂.mor₂) :
∃ (a : T₁.obj₁ ⟶ T₂.obj₁), T₁.mor₁ ≫ b = a ≫ T₂.mor₁ ∧
T₁.mor₃ ≫ a⟦(1 : ℤ)⟧' = c ≫ T₂.mor₃ := by
obtain ⟨a, ⟨ha₁, ha₂⟩⟩ := complete_distinguished_triangle_morphism _ _
(rot_of_distTriang _ hT₁) (rot_of_distTriang _ hT₂) b c comm
refine ⟨(shiftFunctor C (1 : ℤ)).preimage a, ⟨?_, ?_⟩⟩
· apply (shiftFunctor C (1 : ℤ)).map_injective
dsimp at ha₂
rw [neg_comp, comp_neg, neg_inj] at ha₂
simpa only [Functor.map_comp, Functor.map_preimage] using ha₂
· simpa only [Functor.map_preimage] using ha₁
/-- A commutative square involving the morphisms `mor₃` of two distinguished triangles
can be extended as morphism of triangles -/
lemma complete_distinguished_triangle_morphism₂ (T₁ T₂ : Triangle C)
(hT₁ : T₁ ∈ distTriang C) (hT₂ : T₂ ∈ distTriang C) (a : T₁.obj₁ ⟶ T₂.obj₁)
(c : T₁.obj₃ ⟶ T₂.obj₃) (comm : T₁.mor₃ ≫ a⟦(1 : ℤ)⟧' = c ≫ T₂.mor₃) :
∃ (b : T₁.obj₂ ⟶ T₂.obj₂), T₁.mor₁ ≫ b = a ≫ T₂.mor₁ ∧ T₁.mor₂ ≫ c = b ≫ T₂.mor₂ := by
obtain ⟨a, ⟨ha₁, ha₂⟩⟩ := complete_distinguished_triangle_morphism _ _
(inv_rot_of_distTriang _ hT₁) (inv_rot_of_distTriang _ hT₂) (c⟦(-1 : ℤ)⟧') a (by
dsimp
simp only [neg_comp, comp_neg, ← Functor.map_comp_assoc, ← comm,
Functor.map_comp, shift_shift_neg', Functor.id_obj, assoc, Iso.inv_hom_id_app, comp_id])
refine ⟨a, ⟨ha₁, ?_⟩⟩
dsimp only [Triangle.invRotate, Triangle.mk] at ha₂
rw [← cancel_mono ((shiftEquiv C (1 : ℤ)).counitIso.inv.app T₂.obj₃), assoc, assoc, ← ha₂]
simp only [shiftEquiv'_counitIso, shift_neg_shift', assoc, Iso.inv_hom_id_app_assoc]
/-- Obvious triangles `0 ⟶ X ⟶ X ⟶ 0⟦1⟧` are distinguished -/
lemma contractible_distinguished₁ (X : C) :
Triangle.mk (0 : 0 ⟶ X) (𝟙 X) 0 ∈ distTriang C := by
refine isomorphic_distinguished _
(inv_rot_of_distTriang _ (contractible_distinguished X)) _ ?_
exact Triangle.isoMk _ _ (Functor.mapZeroObject _).symm (Iso.refl _) (Iso.refl _)
(by simp) (by simp) (by simp)
/-- Obvious triangles `X ⟶ 0 ⟶ X⟦1⟧ ⟶ X⟦1⟧` are distinguished -/
lemma contractible_distinguished₂ (X : C) :
Triangle.mk (0 : X ⟶ 0) 0 (𝟙 (X⟦1⟧)) ∈ distTriang C := by
refine isomorphic_distinguished _
(inv_rot_of_distTriang _ (contractible_distinguished₁ (X⟦(1 : ℤ)⟧))) _ ?_
exact Triangle.isoMk _ _ ((shiftEquiv C (1 : ℤ)).unitIso.app X) (Iso.refl _) (Iso.refl _)
(by simp) (by simp)
(by dsimp; simp only [shift_shiftFunctorCompIsoId_inv_app, id_comp])
namespace Triangle
variable (T : Triangle C) (hT : T ∈ distTriang C)
include hT
lemma yoneda_exact₂ {X : C} (f : T.obj₂ ⟶ X) (hf : T.mor₁ ≫ f = 0) :
∃ (g : T.obj₃ ⟶ X), f = T.mor₂ ≫ g := by
obtain ⟨g, ⟨hg₁, _⟩⟩ := complete_distinguished_triangle_morphism T _ hT
(contractible_distinguished₁ X) 0 f (by cat_disch)
exact ⟨g, by simpa using hg₁.symm⟩
lemma yoneda_exact₃ {X : C} (f : T.obj₃ ⟶ X) (hf : T.mor₂ ≫ f = 0) :
∃ (g : T.obj₁⟦(1 : ℤ)⟧ ⟶ X), f = T.mor₃ ≫ g :=
yoneda_exact₂ _ (rot_of_distTriang _ hT) f hf
lemma coyoneda_exact₂ {X : C} (f : X ⟶ T.obj₂) (hf : f ≫ T.mor₂ = 0) :
∃ (g : X ⟶ T.obj₁), f = g ≫ T.mor₁ := by
obtain ⟨a, ⟨ha₁, _⟩⟩ := complete_distinguished_triangle_morphism₁ _ T
(contractible_distinguished X) hT f 0 (by cat_disch)
exact ⟨a, by simpa using ha₁⟩
lemma coyoneda_exact₁ {X : C} (f : X ⟶ T.obj₁⟦(1 : ℤ)⟧) (hf : f ≫ T.mor₁⟦1⟧' = 0) :
∃ (g : X ⟶ T.obj₃), f = g ≫ T.mor₃ :=
coyoneda_exact₂ _ (rot_of_distTriang _ (rot_of_distTriang _ hT)) f (by cat_disch)
lemma coyoneda_exact₃ {X : C} (f : X ⟶ T.obj₃) (hf : f ≫ T.mor₃ = 0) :
∃ (g : X ⟶ T.obj₂), f = g ≫ T.mor₂ :=
coyoneda_exact₂ _ (rot_of_distTriang _ hT) f hf
lemma mor₃_eq_zero_iff_epi₂ : T.mor₃ = 0 ↔ Epi T.mor₂ := by
constructor
· intro h
rw [epi_iff_cancel_zero]
intro X g hg
obtain ⟨f, rfl⟩ := yoneda_exact₃ T hT g hg
rw [h, zero_comp]
· intro
rw [← cancel_epi T.mor₂, comp_distTriang_mor_zero₂₃ _ hT, comp_zero]
lemma mor₂_eq_zero_iff_epi₁ : T.mor₂ = 0 ↔ Epi T.mor₁ := by
have h := mor₃_eq_zero_iff_epi₂ _ (inv_rot_of_distTriang _ hT)
dsimp at h
rw [← h, IsIso.comp_right_eq_zero]
lemma mor₁_eq_zero_iff_epi₃ : T.mor₁ = 0 ↔ Epi T.mor₃ := by
have h := mor₃_eq_zero_iff_epi₂ _ (rot_of_distTriang _ hT)
dsimp at h
rw [← h, neg_eq_zero]
constructor
· intro h
simp only [h, Functor.map_zero]
· intro h
rw [← (CategoryTheory.shiftFunctor C (1 : ℤ)).map_eq_zero_iff, h]
lemma mor₃_eq_zero_of_epi₂ (h : Epi T.mor₂) : T.mor₃ = 0 := (T.mor₃_eq_zero_iff_epi₂ hT).2 h
lemma mor₂_eq_zero_of_epi₁ (h : Epi T.mor₁) : T.mor₂ = 0 := (T.mor₂_eq_zero_iff_epi₁ hT).2 h
lemma mor₁_eq_zero_of_epi₃ (h : Epi T.mor₃) : T.mor₁ = 0 := (T.mor₁_eq_zero_iff_epi₃ hT).2 h
lemma epi₂ (h : T.mor₃ = 0) : Epi T.mor₂ := (T.mor₃_eq_zero_iff_epi₂ hT).1 h
lemma epi₁ (h : T.mor₂ = 0) : Epi T.mor₁ := (T.mor₂_eq_zero_iff_epi₁ hT).1 h
lemma epi₃ (h : T.mor₁ = 0) : Epi T.mor₃ := (T.mor₁_eq_zero_iff_epi₃ hT).1 h
lemma mor₁_eq_zero_iff_mono₂ : T.mor₁ = 0 ↔ Mono T.mor₂ := by
constructor
· intro h
rw [mono_iff_cancel_zero]
intro X g hg
obtain ⟨f, rfl⟩ := coyoneda_exact₂ T hT g hg
rw [h, comp_zero]
· intro
rw [← cancel_mono T.mor₂, comp_distTriang_mor_zero₁₂ _ hT, zero_comp]
lemma mor₂_eq_zero_iff_mono₃ : T.mor₂ = 0 ↔ Mono T.mor₃ :=
mor₁_eq_zero_iff_mono₂ _ (rot_of_distTriang _ hT)
lemma mor₃_eq_zero_iff_mono₁ : T.mor₃ = 0 ↔ Mono T.mor₁ := by
have h := mor₁_eq_zero_iff_mono₂ _ (inv_rot_of_distTriang _ hT)
dsimp at h
rw [← h, neg_eq_zero, IsIso.comp_right_eq_zero]
constructor
· intro h
simp only [h, Functor.map_zero]
· intro h
rw [← (CategoryTheory.shiftFunctor C (-1 : ℤ)).map_eq_zero_iff, h]
lemma mor₁_eq_zero_of_mono₂ (h : Mono T.mor₂) : T.mor₁ = 0 := (T.mor₁_eq_zero_iff_mono₂ hT).2 h
lemma mor₂_eq_zero_of_mono₃ (h : Mono T.mor₃) : T.mor₂ = 0 := (T.mor₂_eq_zero_iff_mono₃ hT).2 h
lemma mor₃_eq_zero_of_mono₁ (h : Mono T.mor₁) : T.mor₃ = 0 := (T.mor₃_eq_zero_iff_mono₁ hT).2 h
lemma mono₂ (h : T.mor₁ = 0) : Mono T.mor₂ := (T.mor₁_eq_zero_iff_mono₂ hT).1 h
lemma mono₃ (h : T.mor₂ = 0) : Mono T.mor₃ := (T.mor₂_eq_zero_iff_mono₃ hT).1 h
lemma mono₁ (h : T.mor₃ = 0) : Mono T.mor₁ := (T.mor₃_eq_zero_iff_mono₁ hT).1 h
lemma isZero₂_iff : IsZero T.obj₂ ↔ (T.mor₁ = 0 ∧ T.mor₂ = 0) := by
constructor
· intro h
exact ⟨h.eq_of_tgt _ _, h.eq_of_src _ _⟩
· intro ⟨h₁, h₂⟩
obtain ⟨f, hf⟩ := coyoneda_exact₂ T hT (𝟙 _) (by rw [h₂, comp_zero])
rw [IsZero.iff_id_eq_zero, hf, h₁, comp_zero]
lemma isZero₁_iff : IsZero T.obj₁ ↔ (T.mor₁ = 0 ∧ T.mor₃ = 0) := by
refine (isZero₂_iff _ (inv_rot_of_distTriang _ hT)).trans ?_
dsimp
simp only [neg_eq_zero, IsIso.comp_right_eq_zero, Functor.map_eq_zero_iff]
tauto
lemma isZero₃_iff : IsZero T.obj₃ ↔ (T.mor₂ = 0 ∧ T.mor₃ = 0) := by
refine (isZero₂_iff _ (rot_of_distTriang _ hT)).trans ?_
dsimp
tauto
lemma isZero₁_of_isZero₂₃ (h₂ : IsZero T.obj₂) (h₃ : IsZero T.obj₃) : IsZero T.obj₁ := by
rw [T.isZero₁_iff hT]
exact ⟨h₂.eq_of_tgt _ _, h₃.eq_of_src _ _⟩
lemma isZero₂_of_isZero₁₃ (h₁ : IsZero T.obj₁) (h₃ : IsZero T.obj₃) : IsZero T.obj₂ := by
rw [T.isZero₂_iff hT]
exact ⟨h₁.eq_of_src _ _, h₃.eq_of_tgt _ _⟩
lemma isZero₃_of_isZero₁₂ (h₁ : IsZero T.obj₁) (h₂ : IsZero T.obj₂) : IsZero T.obj₃ :=
isZero₂_of_isZero₁₃ _ (rot_of_distTriang _ hT) h₂ (by
dsimp
simp only [IsZero.iff_id_eq_zero] at h₁ ⊢
rw [← Functor.map_id, h₁, Functor.map_zero])
lemma isZero₁_iff_isIso₂ :
IsZero T.obj₁ ↔ IsIso T.mor₂ := by
rw [T.isZero₁_iff hT]
constructor
· intro ⟨h₁, h₃⟩
have := T.epi₂ hT h₃
obtain ⟨f, hf⟩ := yoneda_exact₂ T hT (𝟙 _) (by rw [h₁, zero_comp])
exact ⟨f, hf.symm, by rw [← cancel_epi T.mor₂, comp_id, ← reassoc_of% hf]⟩
· intro
rw [T.mor₁_eq_zero_iff_mono₂ hT, T.mor₃_eq_zero_iff_epi₂ hT]
constructor <;> infer_instance
lemma isZero₂_iff_isIso₃ : IsZero T.obj₂ ↔ IsIso T.mor₃ :=
isZero₁_iff_isIso₂ _ (rot_of_distTriang _ hT)
lemma isZero₃_iff_isIso₁ : IsZero T.obj₃ ↔ IsIso T.mor₁ := by
refine Iff.trans ?_ (Triangle.isZero₁_iff_isIso₂ _ (inv_rot_of_distTriang _ hT))
dsimp
simp only [IsZero.iff_id_eq_zero, ← Functor.map_id, Functor.map_eq_zero_iff]
lemma isZero₁_of_isIso₂ (h : IsIso T.mor₂) : IsZero T.obj₁ := (T.isZero₁_iff_isIso₂ hT).2 h
lemma isZero₂_of_isIso₃ (h : IsIso T.mor₃) : IsZero T.obj₂ := (T.isZero₂_iff_isIso₃ hT).2 h
lemma isZero₃_of_isIso₁ (h : IsIso T.mor₁) : IsZero T.obj₃ := (T.isZero₃_iff_isIso₁ hT).2 h
lemma shift_distinguished (n : ℤ) :
(CategoryTheory.shiftFunctor (Triangle C) n).obj T ∈ distTriang C := by
revert T hT
let H : ℤ → Prop := fun n => ∀ (T : Triangle C) (_ : T ∈ distTriang C),
(Triangle.shiftFunctor C n).obj T ∈ distTriang C
change H n
have H_zero : H 0 := fun T hT =>
isomorphic_distinguished _ hT _ ((Triangle.shiftFunctorZero C).app T)
have H_one : H 1 := fun T hT =>
isomorphic_distinguished _ (rot_of_distTriang _
(rot_of_distTriang _ (rot_of_distTriang _ hT))) _
((rotateRotateRotateIso C).symm.app T)
have H_neg_one : H (-1) := fun T hT =>
isomorphic_distinguished _ (inv_rot_of_distTriang _
(inv_rot_of_distTriang _ (inv_rot_of_distTriang _ hT))) _
((invRotateInvRotateInvRotateIso C).symm.app T)
have H_add : ∀ {a b c : ℤ}, H a → H b → a + b = c → H c := fun {a b c} ha hb hc T hT =>
isomorphic_distinguished _ (hb _ (ha _ hT)) _
((Triangle.shiftFunctorAdd' C _ _ _ hc).app T)
obtain (n|n) := n
· induction n with
| zero => exact H_zero
| succ n hn => exact H_add hn H_one rfl
· induction n with
| zero => exact H_neg_one
| succ n hn => exact H_add hn H_neg_one rfl
end Triangle
instance : SplitEpiCategory C where
isSplitEpi_of_epi f hf := by
obtain ⟨Z, g, h, hT⟩ := distinguished_cocone_triangle f
obtain ⟨r, hr⟩ := Triangle.coyoneda_exact₂ _ hT (𝟙 _)
(by rw [Triangle.mor₂_eq_zero_of_epi₁ _ hT hf, comp_zero])
exact ⟨r, hr.symm⟩
instance : SplitMonoCategory C where
isSplitMono_of_mono f hf := by
obtain ⟨X, g, h, hT⟩ := distinguished_cocone_triangle₁ f
obtain ⟨r, hr⟩ := Triangle.yoneda_exact₂ _ hT (𝟙 _) (by
rw [Triangle.mor₁_eq_zero_of_mono₂ _ hT hf, zero_comp])
exact ⟨r, hr.symm⟩
lemma isIso₂_of_isIso₁₃ {T T' : Triangle C} (φ : T ⟶ T') (hT : T ∈ distTriang C)
(hT' : T' ∈ distTriang C) (h₁ : IsIso φ.hom₁) (h₃ : IsIso φ.hom₃) : IsIso φ.hom₂ := by
have : Mono φ.hom₂ := by
rw [mono_iff_cancel_zero]
intro A f hf
obtain ⟨g, rfl⟩ := Triangle.coyoneda_exact₂ _ hT f
(by rw [← cancel_mono φ.hom₃, assoc, φ.comm₂, reassoc_of% hf, zero_comp, zero_comp])
rw [assoc] at hf
obtain ⟨h, hh⟩ := Triangle.coyoneda_exact₂ T'.invRotate (inv_rot_of_distTriang _ hT')
(g ≫ φ.hom₁) (by dsimp; rw [assoc, ← φ.comm₁, hf])
obtain ⟨k, rfl⟩ : ∃ (k : A ⟶ T.invRotate.obj₁), k ≫ T.invRotate.mor₁ = g := by
refine ⟨h ≫ inv (φ.hom₃⟦(-1 : ℤ)⟧'), ?_⟩
have eq := ((invRotate C).map φ).comm₁
dsimp only [invRotate] at eq
rw [← cancel_mono φ.hom₁, assoc, assoc, eq, IsIso.inv_hom_id_assoc, hh]
erw [assoc, comp_distTriang_mor_zero₁₂ _ (inv_rot_of_distTriang _ hT), comp_zero]
refine isIso_of_yoneda_map_bijective _ (fun A => ⟨?_, ?_⟩)
· intro f₁ f₂ h
simpa only [← cancel_mono φ.hom₂] using h
· intro y₂
obtain ⟨x₃, hx₃⟩ : ∃ (x₃ : A ⟶ T.obj₃), x₃ ≫ φ.hom₃ = y₂ ≫ T'.mor₂ :=
⟨y₂ ≫ T'.mor₂ ≫ inv φ.hom₃, by simp⟩
obtain ⟨x₂, hx₂⟩ := Triangle.coyoneda_exact₃ _ hT x₃
(by rw [← cancel_mono (φ.hom₁⟦(1 : ℤ)⟧'), assoc, zero_comp, φ.comm₃, reassoc_of% hx₃,
comp_distTriang_mor_zero₂₃ _ hT', comp_zero])
obtain ⟨y₁, hy₁⟩ := Triangle.coyoneda_exact₂ _ hT' (y₂ - x₂ ≫ φ.hom₂)
(by rw [sub_comp, assoc, ← φ.comm₂, ← reassoc_of% hx₂, hx₃, sub_self])
obtain ⟨x₁, hx₁⟩ : ∃ (x₁ : A ⟶ T.obj₁), x₁ ≫ φ.hom₁ = y₁ := ⟨y₁ ≫ inv φ.hom₁, by simp⟩
refine ⟨x₂ + x₁ ≫ T.mor₁, ?_⟩
dsimp
rw [add_comp, assoc, φ.comm₁, reassoc_of% hx₁, ← hy₁, add_sub_cancel]
lemma isIso₃_of_isIso₁₂ {T T' : Triangle C} (φ : T ⟶ T') (hT : T ∈ distTriang C)
(hT' : T' ∈ distTriang C) (h₁ : IsIso φ.hom₁) (h₂ : IsIso φ.hom₂) : IsIso φ.hom₃ :=
isIso₂_of_isIso₁₃ ((rotate C).map φ) (rot_of_distTriang _ hT)
(rot_of_distTriang _ hT') h₂ (by dsimp; infer_instance)
lemma isIso₁_of_isIso₂₃ {T T' : Triangle C} (φ : T ⟶ T') (hT : T ∈ distTriang C)
(hT' : T' ∈ distTriang C) (h₂ : IsIso φ.hom₂) (h₃ : IsIso φ.hom₃) : IsIso φ.hom₁ :=
isIso₂_of_isIso₁₃ ((invRotate C).map φ) (inv_rot_of_distTriang _ hT)
(inv_rot_of_distTriang _ hT') (by dsimp; infer_instance) (by dsimp; infer_instance)
/-- Given a distinguished triangle `T` such that `T.mor₃ = 0` and the datum of morphisms
`inr : T.obj₃ ⟶ T.obj₂` and `fst : T.obj₂ ⟶ T.obj₁` satisfying suitable relations, this
is the binary biproduct data expressing that `T.obj₂` identifies to the binary
biproduct of `T.obj₁` and `T.obj₃`.
See also `exists_iso_binaryBiproduct_of_distTriang`. -/
@[simps]
def binaryBiproductData (T : Triangle C) (hT : T ∈ distTriang C) (hT₀ : T.mor₃ = 0)
(inr : T.obj₃ ⟶ T.obj₂) (inr_snd : inr ≫ T.mor₂ = 𝟙 _) (fst : T.obj₂ ⟶ T.obj₁)
(total : fst ≫ T.mor₁ + T.mor₂ ≫ inr = 𝟙 T.obj₂) :
BinaryBiproductData T.obj₁ T.obj₃ := by
have : Mono T.mor₁ := T.mono₁ hT hT₀
have eq : fst ≫ T.mor₁ = 𝟙 T.obj₂ - T.mor₂ ≫ inr := by rw [← total, add_sub_cancel_right]
exact
{ bicone :=
{ pt := T.obj₂
fst := fst
snd := T.mor₂
inl := T.mor₁
inr := inr
inl_fst := by
simp only [← cancel_mono T.mor₁, assoc, id_comp, eq, comp_sub, comp_id,
comp_distTriang_mor_zero₁₂_assoc _ hT, zero_comp, sub_zero]
inl_snd := comp_distTriang_mor_zero₁₂ _ hT
inr_fst := by
simp only [← cancel_mono T.mor₁, assoc, eq, comp_sub, reassoc_of% inr_snd,
comp_id, sub_self, zero_comp]
inr_snd := inr_snd }
isBilimit := isBinaryBilimitOfTotal _ total }
instance : HasBinaryBiproducts C := ⟨fun X₁ X₃ => by
obtain ⟨X₂, inl, snd, mem⟩ := distinguished_cocone_triangle₂ (0 : X₃ ⟶ X₁⟦(1 : ℤ)⟧)
obtain ⟨inr : X₃ ⟶ X₂, inr_snd : 𝟙 _ = inr ≫ snd⟩ :=
Triangle.coyoneda_exact₃ _ mem (𝟙 X₃) (by simp)
obtain ⟨fst : X₂ ⟶ X₁, hfst : 𝟙 X₂ - snd ≫ inr = fst ≫ inl⟩ :=
Triangle.coyoneda_exact₂ _ mem (𝟙 X₂ - snd ≫ inr) (by
dsimp
simp only [sub_comp, assoc, id_comp, ← inr_snd, comp_id, sub_self])
refine ⟨⟨binaryBiproductData _ mem rfl inr inr_snd.symm fst ?_⟩⟩
dsimp
simp only [← hfst, sub_add_cancel]⟩
instance : HasFiniteProducts C := hasFiniteProducts_of_has_binary_and_terminal
instance : HasFiniteCoproducts C := hasFiniteCoproducts_of_has_binary_and_initial
instance : HasFiniteBiproducts C := HasFiniteBiproducts.of_hasFiniteProducts
lemma exists_iso_binaryBiproduct_of_distTriang (T : Triangle C) (hT : T ∈ distTriang C)
(zero : T.mor₃ = 0) :
∃ (e : T.obj₂ ≅ T.obj₁ ⊞ T.obj₃), T.mor₁ ≫ e.hom = biprod.inl ∧
T.mor₂ = e.hom ≫ biprod.snd := by
have := T.epi₂ hT zero
have := isSplitEpi_of_epi T.mor₂
obtain ⟨fst, hfst⟩ := T.coyoneda_exact₂ hT (𝟙 T.obj₂ - T.mor₂ ≫ section_ T.mor₂) (by simp)
let d := binaryBiproductData _ hT zero (section_ T.mor₂) (by simp) fst
(by simp only [← hfst, sub_add_cancel])
refine ⟨biprod.uniqueUpToIso _ _ d.isBilimit, ⟨?_, by simp [d]⟩⟩
ext
· simpa [d] using d.bicone.inl_fst
· simpa [d] using d.bicone.inl_snd
lemma binaryBiproductTriangle_distinguished (X₁ X₂ : C) :
binaryBiproductTriangle X₁ X₂ ∈ distTriang C := by
obtain ⟨Y, g, h, mem⟩ := distinguished_cocone_triangle₂ (0 : X₂ ⟶ X₁⟦(1 : ℤ)⟧)
obtain ⟨e, ⟨he₁, he₂⟩⟩ := exists_iso_binaryBiproduct_of_distTriang _ mem rfl
dsimp at he₁ he₂
refine isomorphic_distinguished _ mem _ (Iso.symm ?_)
refine Triangle.isoMk _ _ (Iso.refl _) e (Iso.refl _)
(by cat_disch) (by cat_disch) (by simp)
lemma binaryProductTriangle_distinguished (X₁ X₂ : C) :
binaryProductTriangle X₁ X₂ ∈ distTriang C :=
isomorphic_distinguished _ (binaryBiproductTriangle_distinguished X₁ X₂) _
(binaryProductTriangleIsoBinaryBiproductTriangle X₁ X₂)
/-- A chosen extension of a commutative square into a morphism of distinguished triangles. -/
@[simps hom₁ hom₂]
def completeDistinguishedTriangleMorphism (T₁ T₂ : Triangle C)
(hT₁ : T₁ ∈ distTriang C) (hT₂ : T₂ ∈ distTriang C)
(a : T₁.obj₁ ⟶ T₂.obj₁) (b : T₁.obj₂ ⟶ T₂.obj₂) (comm : T₁.mor₁ ≫ b = a ≫ T₂.mor₁) :
T₁ ⟶ T₂ :=
have h := complete_distinguished_triangle_morphism _ _ hT₁ hT₂ a b comm
{ hom₁ := a
hom₂ := b
hom₃ := h.choose
comm₁ := comm
comm₂ := h.choose_spec.1
comm₃ := h.choose_spec.2 }
/-- A product of distinguished triangles is distinguished -/
lemma productTriangle_distinguished {J : Type*} (T : J → Triangle C)
(hT : ∀ j, T j ∈ distTriang C)
[HasProduct (fun j => (T j).obj₁)] [HasProduct (fun j => (T j).obj₂)]
[HasProduct (fun j => (T j).obj₃)] [HasProduct (fun j => (T j).obj₁⟦(1 : ℤ)⟧)] :
productTriangle T ∈ distTriang C := by
/- The proof proceeds by constructing a morphism of triangles
`φ' : T' ⟶ productTriangle T` with `T'` distinguished, and such that
`φ'.hom₁` and `φ'.hom₂` are identities. Then, it suffices to show that
`φ'.hom₃` is an isomorphism, which is achieved by using Yoneda's lemma
and diagram chases. -/
let f₁ := Limits.Pi.map (fun j => (T j).mor₁)
obtain ⟨Z, f₂, f₃, hT'⟩ := distinguished_cocone_triangle f₁
let T' := Triangle.mk f₁ f₂ f₃
change T' ∈ distTriang C at hT'
let φ : ∀ j, T' ⟶ T j := fun j => completeDistinguishedTriangleMorphism _ _
hT' (hT j) (Pi.π _ j) (Pi.π _ j) (by simp [f₁, T'])
let φ' := productTriangle.lift _ φ
have h₁ : φ'.hom₁ = 𝟙 _ := by cat_disch
have h₂ : φ'.hom₂ = 𝟙 _ := by cat_disch
have : IsIso φ'.hom₁ := by rw [h₁]; infer_instance
have : IsIso φ'.hom₂ := by rw [h₂]; infer_instance
suffices IsIso φ'.hom₃ by
have : IsIso φ' := by
apply Triangle.isIso_of_isIsos
all_goals infer_instance
exact isomorphic_distinguished _ hT' _ (asIso φ').symm
refine isIso_of_yoneda_map_bijective _ (fun A => ⟨?_, ?_⟩)
/- the proofs by diagram chase start here -/
· suffices Mono φ'.hom₃ by
intro a₁ a₂ ha
simpa only [← cancel_mono φ'.hom₃] using ha
rw [mono_iff_cancel_zero]
intro A f hf
have hf' : f ≫ T'.mor₃ = 0 := by
rw [← cancel_mono (φ'.hom₁⟦1⟧'), zero_comp, assoc, φ'.comm₃, reassoc_of% hf, zero_comp]
obtain ⟨g, hg⟩ := T'.coyoneda_exact₃ hT' f hf'
have hg' : ∀ j, (g ≫ Pi.π _ j) ≫ (T j).mor₂ = 0 := fun j => by
have : g ≫ T'.mor₂ ≫ φ'.hom₃ ≫ Pi.π _ j = 0 := by
rw [← reassoc_of% hg, reassoc_of% hf, zero_comp]
rw [φ'.comm₂_assoc, h₂, id_comp] at this
simpa using this
have hg'' := fun j => (T j).coyoneda_exact₂ (hT j) _ (hg' j)
let α := fun j => (hg'' j).choose
have hα : ∀ j, _ = α j ≫ _ := fun j => (hg'' j).choose_spec
have hg''' : g = Pi.lift α ≫ T'.mor₁ := by dsimp [f₁, T']; ext j; rw [hα]; simp
rw [hg, hg''', assoc, comp_distTriang_mor_zero₁₂ _ hT', comp_zero]
· intro a
obtain ⟨a', ha'⟩ : ∃ (a' : A ⟶ Z), a' ≫ T'.mor₃ = a ≫ (productTriangle T).mor₃ := by
have zero : ((productTriangle T).mor₃) ≫ (shiftFunctor C 1).map T'.mor₁ = 0 := by
rw [← cancel_mono (φ'.hom₂⟦1⟧'), zero_comp, assoc, ← Functor.map_comp, φ'.comm₁, h₁,
id_comp, productTriangle.zero₃₁]
intro j
exact comp_distTriang_mor_zero₃₁ _ (hT j)
have ⟨g, hg⟩ := T'.coyoneda_exact₁ hT' (a ≫ (productTriangle T).mor₃) (by
rw [assoc, zero, comp_zero])
exact ⟨g, hg.symm⟩
have ha'' := fun (j : J) => (T j).coyoneda_exact₃ (hT j) ((a - a' ≫ φ'.hom₃) ≫ Pi.π _ j) (by
simp only [sub_comp, assoc]
erw [← (productTriangle.π T j).comm₃]
rw [← φ'.comm₃_assoc]
rw [reassoc_of% ha', sub_eq_zero, h₁, Functor.map_id, id_comp])
let b := fun j => (ha'' j).choose
have hb : ∀ j, _ = b j ≫ _ := fun j => (ha'' j).choose_spec
have hb' : a - a' ≫ φ'.hom₃ = Pi.lift b ≫ (productTriangle T).mor₂ :=
Limits.Pi.hom_ext _ _ (fun j => by rw [hb]; simp)
have : (a' + (by exact Pi.lift b) ≫ T'.mor₂) ≫ φ'.hom₃ = a := by
rw [add_comp, assoc, φ'.comm₂, h₂, id_comp, ← hb', add_sub_cancel]
exact ⟨_, this⟩
lemma exists_iso_of_arrow_iso (T₁ T₂ : Triangle C) (hT₁ : T₁ ∈ distTriang C)
(hT₂ : T₂ ∈ distTriang C) (e : Arrow.mk T₁.mor₁ ≅ Arrow.mk T₂.mor₁) :
∃ (e' : T₁ ≅ T₂), e'.hom.hom₁ = e.hom.left ∧ e'.hom.hom₂ = e.hom.right := by
let φ := completeDistinguishedTriangleMorphism T₁ T₂ hT₁ hT₂ e.hom.left e.hom.right e.hom.w.symm
have : IsIso φ.hom₁ := by dsimp [φ]; infer_instance
have : IsIso φ.hom₂ := by dsimp [φ]; infer_instance
have : IsIso φ.hom₃ := isIso₃_of_isIso₁₂ φ hT₁ hT₂ inferInstance inferInstance
have : IsIso φ := by
apply Triangle.isIso_of_isIsos
all_goals infer_instance
exact ⟨asIso φ, by simp [φ], by simp [φ]⟩
/-- A choice of isomorphism `T₁ ≅ T₂` between two distinguished triangles
when we are given two isomorphisms `e₁ : T₁.obj₁ ≅ T₂.obj₁` and `e₂ : T₁.obj₂ ≅ T₂.obj₂`. -/
@[simps! hom_hom₁ hom_hom₂ inv_hom₁ inv_hom₂]
def isoTriangleOfIso₁₂ (T₁ T₂ : Triangle C) (hT₁ : T₁ ∈ distTriang C)
(hT₂ : T₂ ∈ distTriang C) (e₁ : T₁.obj₁ ≅ T₂.obj₁) (e₂ : T₁.obj₂ ≅ T₂.obj₂)
(comm : T₁.mor₁ ≫ e₂.hom = e₁.hom ≫ T₂.mor₁) : T₁ ≅ T₂ := by
have h := exists_iso_of_arrow_iso T₁ T₂ hT₁ hT₂ (Arrow.isoMk e₁ e₂ comm.symm)
exact Triangle.isoMk _ _ e₁ e₂ (Triangle.π₃.mapIso h.choose) comm (by
have eq := h.choose_spec.2
dsimp at eq ⊢
conv_rhs => rw [← eq, ← TriangleMorphism.comm₂]) (by
have eq := h.choose_spec.1
dsimp at eq ⊢
conv_lhs => rw [← eq, TriangleMorphism.comm₃])
end Pretriangulated
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Triangulated/Rotate.lean | import Mathlib.CategoryTheory.Preadditive.AdditiveFunctor
import Mathlib.CategoryTheory.Triangulated.Basic
/-!
# Rotate
This file adds the ability to rotate triangles and triangle morphisms.
It also shows that rotation gives an equivalence on the category of triangles.
-/
noncomputable section
open CategoryTheory
open CategoryTheory.Preadditive
open CategoryTheory.Limits
universe v v₀ v₁ v₂ u u₀ u₁ u₂
namespace CategoryTheory.Pretriangulated
open CategoryTheory.Category
variable {C : Type u} [Category.{v} C] [Preadditive C]
variable [HasShift C ℤ]
variable (X : C)
/-- If you rotate a triangle, you get another triangle.
Given a triangle of the form:
```
f g h
X ───> Y ───> Z ───> X⟦1⟧
```
applying `rotate` gives a triangle of the form:
```
g h -f⟦1⟧'
Y ───> Z ───> X⟦1⟧ ───> Y⟦1⟧
```
-/
@[simps!]
def Triangle.rotate (T : Triangle C) : Triangle C :=
Triangle.mk T.mor₂ T.mor₃ (-T.mor₁⟦1⟧')
section
/-- Given a triangle of the form:
```
f g h
X ───> Y ───> Z ───> X⟦1⟧
```
applying `invRotate` gives a triangle that can be thought of as:
```
-h⟦-1⟧' f g
Z⟦-1⟧ ───> X ───> Y ───> Z
```
(note that this diagram doesn't technically fit the definition of triangle, as `Z⟦-1⟧⟦1⟧` is
not necessarily equal to `Z`, but it is isomorphic, by the `counitIso` of `shiftEquiv C 1`)
-/
@[simps!]
def Triangle.invRotate (T : Triangle C) : Triangle C :=
Triangle.mk (-T.mor₃⟦(-1 : ℤ)⟧' ≫ (shiftEquiv C (1 : ℤ)).unitIso.inv.app _) (T.mor₁)
(T.mor₂ ≫ (shiftEquiv C (1 : ℤ)).counitIso.inv.app _ )
end
attribute [local simp] shift_shift_neg' shift_neg_shift'
shift_shiftFunctorCompIsoId_add_neg_cancel_inv_app
shift_shiftFunctorCompIsoId_add_neg_cancel_hom_app
variable (C)
/-- Rotating triangles gives an endofunctor on the category of triangles in `C`.
-/
@[simps]
def rotate : Triangle C ⥤ Triangle C where
obj := Triangle.rotate
map f :=
{ hom₁ := f.hom₂
hom₂ := f.hom₃
hom₃ := f.hom₁⟦1⟧'
comm₃ := by
dsimp
simp only [comp_neg, neg_comp, ← Functor.map_comp, f.comm₁] }
/-- The inverse rotation of triangles gives an endofunctor on the category of triangles in `C`.
-/
@[simps]
def invRotate : Triangle C ⥤ Triangle C where
obj := Triangle.invRotate
map f :=
{ hom₁ := f.hom₃⟦-1⟧'
hom₂ := f.hom₁
hom₃ := f.hom₂
comm₁ := by
dsimp
simp only [comp_neg, ← Functor.map_comp_assoc, ← f.comm₃]
rw [Functor.map_comp]
simp }
variable {C}
variable [∀ n : ℤ, Functor.Additive (shiftFunctor C n)]
/-- The unit isomorphism of the auto-equivalence of categories `triangleRotation C` of
`Triangle C` given by the rotation of triangles. -/
@[simps!]
def rotCompInvRot : 𝟭 (Triangle C) ≅ rotate C ⋙ invRotate C :=
NatIso.ofComponents fun T => Triangle.isoMk _ _
((shiftEquiv C (1 : ℤ)).unitIso.app T.obj₁) (Iso.refl _) (Iso.refl _)
/-- The counit isomorphism of the auto-equivalence of categories `triangleRotation C` of
`Triangle C` given by the rotation of triangles. -/
@[simps!]
def invRotCompRot : invRotate C ⋙ rotate C ≅ 𝟭 (Triangle C) :=
NatIso.ofComponents fun T => Triangle.isoMk _ _ (Iso.refl _) (Iso.refl _)
((shiftEquiv C (1 : ℤ)).counitIso.app T.obj₃)
variable (C) in
/-- Rotating triangles gives an auto-equivalence on the category of triangles in `C`.
-/
@[simps]
def triangleRotation : Equivalence (Triangle C) (Triangle C) where
functor := rotate C
inverse := invRotate C
unitIso := rotCompInvRot
counitIso := invRotCompRot
instance : (rotate C).IsEquivalence := by
change (triangleRotation C).functor.IsEquivalence
infer_instance
instance : (invRotate C).IsEquivalence := by
change (triangleRotation C).inverse.IsEquivalence
infer_instance
end CategoryTheory.Pretriangulated |
.lake/packages/mathlib/Mathlib/CategoryTheory/Triangulated/Opposite/Triangle.lean | import Mathlib.CategoryTheory.Triangulated.Basic
import Mathlib.CategoryTheory.Triangulated.Opposite.Basic
/-!
# Triangles in the opposite category of a (pre)triangulated category
Let `C` be a (pre)triangulated category.
In `CategoryTheory.Triangulated.Opposite.Basic`, we have constructed
a shift on `Cᵒᵖ` that will be part of a structure of (pre)triangulated
category. In this file, we construct an equivalence of categories
between `(Triangle C)ᵒᵖ` and `Triangle Cᵒᵖ`, called
`CategoryTheory.Pretriangulated.triangleOpEquivalence`. It sends a triangle
`X ⟶ Y ⟶ Z ⟶ X⟦1⟧` in `C` to the triangle `op Z ⟶ op Y ⟶ op X ⟶ (op Z)⟦1⟧` in `Cᵒᵖ`
(without introducing signs).
## References
* [Jean-Louis Verdier, *Des catégories dérivées des catégories abéliennes*][verdier1996]
-/
namespace CategoryTheory.Pretriangulated
open Category Limits Preadditive ZeroObject Opposite
variable (C : Type*) [Category C] [HasShift C ℤ]
namespace TriangleOpEquivalence
/-- The functor which sends a triangle `X ⟶ Y ⟶ Z ⟶ X⟦1⟧` in `C` to the triangle
`op Z ⟶ op Y ⟶ op X ⟶ (op Z)⟦1⟧` in `Cᵒᵖ` (without introducing signs). -/
@[simps]
noncomputable def functor : (Triangle C)ᵒᵖ ⥤ Triangle Cᵒᵖ where
obj T := Triangle.mk T.unop.mor₂.op T.unop.mor₁.op
((opShiftFunctorEquivalence C 1).counitIso.inv.app (Opposite.op T.unop.obj₁) ≫
T.unop.mor₃.op⟦(1 : ℤ)⟧')
map {T₁ T₂} φ :=
{ hom₁ := φ.unop.hom₃.op
hom₂ := φ.unop.hom₂.op
hom₃ := φ.unop.hom₁.op
comm₁ := Quiver.Hom.unop_inj φ.unop.comm₂.symm
comm₂ := Quiver.Hom.unop_inj φ.unop.comm₁.symm
comm₃ := by
dsimp
rw [assoc, ← Functor.map_comp, ← op_comp, ← φ.unop.comm₃, op_comp, Functor.map_comp,
opShiftFunctorEquivalence_counitIso_inv_naturality_assoc]
rfl }
/-- The functor which sends a triangle `X ⟶ Y ⟶ Z ⟶ X⟦1⟧` in `Cᵒᵖ` to the triangle
`Z.unop ⟶ Y.unop ⟶ X.unop ⟶ Z.unop⟦1⟧` in `C` (without introducing signs). -/
@[simps]
noncomputable def inverse : Triangle Cᵒᵖ ⥤ (Triangle C)ᵒᵖ where
obj T := Opposite.op (Triangle.mk T.mor₂.unop T.mor₁.unop
(((opShiftFunctorEquivalence C 1).unitIso.inv.app T.obj₁).unop ≫ T.mor₃.unop⟦(1 : ℤ)⟧'))
map {T₁ T₂} φ := Quiver.Hom.op
{ hom₁ := φ.hom₃.unop
hom₂ := φ.hom₂.unop
hom₃ := φ.hom₁.unop
comm₁ := Quiver.Hom.op_inj φ.comm₂.symm
comm₂ := Quiver.Hom.op_inj φ.comm₁.symm
comm₃ := Quiver.Hom.op_inj (by
dsimp
rw [assoc, ← opShiftFunctorEquivalence_unitIso_inv_naturality,
← op_comp_assoc, ← Functor.map_comp, ← unop_comp, ← φ.comm₃,
unop_comp, Functor.map_comp, op_comp, assoc]) }
/-- The unit isomorphism of the
equivalence `triangleOpEquivalence C : (Triangle C)ᵒᵖ ≌ Triangle Cᵒᵖ` . -/
@[simps!]
noncomputable def unitIso : 𝟭 _ ≅ functor C ⋙ inverse C :=
NatIso.ofComponents (fun T => Iso.op
(Triangle.isoMk _ _ (Iso.refl _) (Iso.refl _) (Iso.refl _) (by simp) (by simp)
(Quiver.Hom.op_inj
(by simp [shift_unop_opShiftFunctorEquivalence_counitIso_inv_app]))))
(fun {T₁ T₂} f => Quiver.Hom.unop_inj (by cat_disch))
/-- The counit isomorphism of the
equivalence `triangleOpEquivalence C : (Triangle C)ᵒᵖ ≌ Triangle Cᵒᵖ` . -/
@[simps!]
noncomputable def counitIso : inverse C ⋙ functor C ≅ 𝟭 _ :=
NatIso.ofComponents (fun T => by
refine Triangle.isoMk _ _ (Iso.refl _) (Iso.refl _) (Iso.refl _) ?_ ?_ ?_
· simp
· simp
· dsimp
rw [Functor.map_id, comp_id, id_comp, Functor.map_comp,
← opShiftFunctorEquivalence_counitIso_inv_naturality_assoc,
opShiftFunctorEquivalence_counitIso_inv_app_shift, ← Functor.map_comp,
Iso.hom_inv_id_app, Functor.map_id]
simp only [Functor.id_obj, comp_id])
(by cat_disch)
end TriangleOpEquivalence
/-- An anti-equivalence between the categories of triangles in `C` and in `Cᵒᵖ`.
A triangle in `Cᵒᵖ` shall be distinguished iff it correspond to a distinguished
triangle in `C` via this equivalence. -/
@[simps]
noncomputable def triangleOpEquivalence :
(Triangle C)ᵒᵖ ≌ Triangle Cᵒᵖ where
functor := TriangleOpEquivalence.functor C
inverse := TriangleOpEquivalence.inverse C
unitIso := TriangleOpEquivalence.unitIso C
counitIso := TriangleOpEquivalence.counitIso C
end CategoryTheory.Pretriangulated |
.lake/packages/mathlib/Mathlib/CategoryTheory/Triangulated/Opposite/Basic.lean | import Mathlib.CategoryTheory.Limits.Shapes.RegularMono
import Mathlib.CategoryTheory.Shift.Opposite
import Mathlib.CategoryTheory.Shift.Pullback
/-!
# The shift on the opposite category of a pretriangulated category
Let `C` be a (pre)triangulated category. We already have a shift on `Cᵒᵖ` given
by `CategoryTheory.Shift.Opposite`, but this is not the shift that we want to
make `Cᵒᵖ` into a (pre)triangulated category.
The correct shift on `Cᵒᵖ` is obtained by combining the constructions in the files
`CategoryTheory.Shift.Opposite` and `CategoryTheory.Shift.Pullback`.
When the user opens `CategoryTheory.Pretriangulated.Opposite`, the
category `Cᵒᵖ` is equipped with the shift by `ℤ` such that
shifting by `n : ℤ` on `Cᵒᵖ` corresponds to the shift by
`-n` on `C`. This is actually a definitional equality, but the user
should not rely on this, and instead use the isomorphism
`shiftFunctorOpIso C n m hnm : shiftFunctor Cᵒᵖ n ≅ (shiftFunctor C m).op`
where `hnm : n + m = 0`.
Some compatibilities between the shifts on `C` and `Cᵒᵖ` are also expressed through
the equivalence of categories `opShiftFunctorEquivalence C n : Cᵒᵖ ≌ Cᵒᵖ` whose
functor is `shiftFunctor Cᵒᵖ n` and whose inverse functor is `(shiftFunctor C n).op`.
## References
* [Jean-Louis Verdier, *Des catégories dérivées des catégories abéliennes*][verdier1996]
-/
namespace CategoryTheory
open Category Limits Preadditive ZeroObject
variable (C : Type*) [Category C]
namespace Pretriangulated
variable [HasShift C ℤ]
namespace Opposite
/-- As it is unclear whether the opposite category `Cᵒᵖ` should always be equipped
with the shift by `ℤ` such that shifting by `n` on `Cᵒᵖ` corresponds to shifting
by `-n` on `C`, the user shall have to do `open CategoryTheory.Pretriangulated.Opposite`
in order to get this shift and the (pre)triangulated structure on `Cᵒᵖ`. -/
private abbrev OppositeShiftAux :=
PullbackShift (OppositeShift C ℤ)
(AddMonoidHom.mk' (fun (n : ℤ) => -n) (by intros; dsimp; cutsat))
/-- The category `Cᵒᵖ` is equipped with the shift such that the shift by `n` on `Cᵒᵖ`
corresponds to the shift by `-n` on `C`. -/
noncomputable scoped instance : HasShift Cᵒᵖ ℤ :=
(inferInstance : HasShift (OppositeShiftAux C) ℤ)
instance [Preadditive C] [∀ (n : ℤ), (shiftFunctor C n).Additive] (n : ℤ) :
(shiftFunctor Cᵒᵖ n).Additive :=
(inferInstance : (shiftFunctor (OppositeShiftAux C) n).Additive)
end Opposite
open Opposite
/-- The shift functor on the opposite category identifies to the opposite functor
of a shift functor on the original category. -/
noncomputable def shiftFunctorOpIso (n m : ℤ) (hnm : n + m = 0) :
shiftFunctor Cᵒᵖ n ≅ (shiftFunctor C m).op := eqToIso (by
obtain rfl : m = -n := by cutsat
rfl)
variable {C}
lemma shiftFunctorZero_op_hom_app (X : Cᵒᵖ) :
(shiftFunctorZero Cᵒᵖ ℤ).hom.app X = (shiftFunctorOpIso C 0 0 (zero_add 0)).hom.app X ≫
((shiftFunctorZero C ℤ).inv.app X.unop).op := rfl
lemma shiftFunctorZero_op_inv_app (X : Cᵒᵖ) :
(shiftFunctorZero Cᵒᵖ ℤ).inv.app X =
((shiftFunctorZero C ℤ).hom.app X.unop).op ≫
(shiftFunctorOpIso C 0 0 (zero_add 0)).inv.app X := by
rw [← cancel_epi ((shiftFunctorZero Cᵒᵖ ℤ).hom.app X), Iso.hom_inv_id_app,
shiftFunctorZero_op_hom_app, assoc, ← op_comp_assoc, Iso.hom_inv_id_app, op_id,
id_comp, Iso.hom_inv_id_app]
lemma shiftFunctorAdd'_op_hom_app (X : Cᵒᵖ) (a₁ a₂ a₃ : ℤ) (h : a₁ + a₂ = a₃)
(b₁ b₂ b₃ : ℤ) (h₁ : a₁ + b₁ = 0) (h₂ : a₂ + b₂ = 0) (h₃ : a₃ + b₃ = 0) :
(shiftFunctorAdd' Cᵒᵖ a₁ a₂ a₃ h).hom.app X =
(shiftFunctorOpIso C _ _ h₃).hom.app X ≫
((shiftFunctorAdd' C b₁ b₂ b₃ (by cutsat)).inv.app X.unop).op ≫
(shiftFunctorOpIso C _ _ h₂).inv.app _ ≫
(shiftFunctor Cᵒᵖ a₂).map ((shiftFunctorOpIso C _ _ h₁).inv.app X) := by
erw [@pullbackShiftFunctorAdd'_hom_app (OppositeShift C ℤ) _ _ _ _ _ _ _ X
a₁ a₂ a₃ h b₁ b₂ b₃ (by dsimp; cutsat) (by dsimp; cutsat) (by dsimp; cutsat)]
rw [oppositeShiftFunctorAdd'_hom_app]
rfl
lemma shiftFunctorAdd'_op_inv_app (X : Cᵒᵖ) (a₁ a₂ a₃ : ℤ) (h : a₁ + a₂ = a₃)
(b₁ b₂ b₃ : ℤ) (h₁ : a₁ + b₁ = 0) (h₂ : a₂ + b₂ = 0) (h₃ : a₃ + b₃ = 0) :
(shiftFunctorAdd' Cᵒᵖ a₁ a₂ a₃ h).inv.app X =
(shiftFunctor Cᵒᵖ a₂).map ((shiftFunctorOpIso C _ _ h₁).hom.app X) ≫
(shiftFunctorOpIso C _ _ h₂).hom.app _ ≫
((shiftFunctorAdd' C b₁ b₂ b₃ (by cutsat)).hom.app X.unop).op ≫
(shiftFunctorOpIso C _ _ h₃).inv.app X := by
rw [← cancel_epi ((shiftFunctorAdd' Cᵒᵖ a₁ a₂ a₃ h).hom.app X), Iso.hom_inv_id_app,
shiftFunctorAdd'_op_hom_app X a₁ a₂ a₃ h b₁ b₂ b₃ h₁ h₂ h₃,
assoc, assoc, assoc, ← Functor.map_comp_assoc, Iso.inv_hom_id_app]
erw [Functor.map_id, id_comp, Iso.inv_hom_id_app_assoc]
rw [← op_comp_assoc, Iso.hom_inv_id_app, op_id, id_comp, Iso.hom_inv_id_app]
lemma shiftFunctor_op_map (n m : ℤ) (hnm : n + m = 0) {K L : Cᵒᵖ} (φ : K ⟶ L) :
(shiftFunctor Cᵒᵖ n).map φ =
(shiftFunctorOpIso C n m hnm).hom.app K ≫ ((shiftFunctor C m).map φ.unop).op ≫
(shiftFunctorOpIso C n m hnm).inv.app L :=
(NatIso.naturality_2 (shiftFunctorOpIso C n m hnm) φ).symm
variable (C) in
/-- The autoequivalence `Cᵒᵖ ≌ Cᵒᵖ` whose functor is `shiftFunctor Cᵒᵖ n` and whose inverse
functor is `(shiftFunctor C n).op`. Do not unfold the definitions of the unit and counit
isomorphisms: the compatibilities they satisfy are stated as separate lemmas. -/
@[simps functor inverse]
noncomputable def opShiftFunctorEquivalence (n : ℤ) : Cᵒᵖ ≌ Cᵒᵖ where
functor := shiftFunctor Cᵒᵖ n
inverse := (shiftFunctor C n).op
unitIso := NatIso.op (shiftFunctorCompIsoId C (-n) n n.add_left_neg) ≪≫
Functor.isoWhiskerRight (shiftFunctorOpIso C n (-n) n.add_right_neg).symm (shiftFunctor C n).op
counitIso := Functor.isoWhiskerLeft _ (shiftFunctorOpIso C n (-n) n.add_right_neg) ≪≫
NatIso.op (shiftFunctorCompIsoId C n (-n) n.add_right_neg).symm
functor_unitIso_comp X := Quiver.Hom.unop_inj (by
dsimp [shiftFunctorOpIso]
erw [comp_id, Functor.map_id, comp_id]
change (shiftFunctorCompIsoId C n (-n) (add_neg_cancel n)).inv.app (X.unop⟦-n⟧) ≫
((shiftFunctorCompIsoId C (-n) n (neg_add_cancel n)).hom.app X.unop)⟦-n⟧' = 𝟙 _
rw [shift_shiftFunctorCompIsoId_neg_add_cancel_hom_app n X.unop, Iso.inv_hom_id_app])
/-! The naturality of the unit and counit isomorphisms are restated in the following
lemmas so as to mitigate the need for `erw`. -/
@[reassoc (attr := simp)]
lemma opShiftFunctorEquivalence_unitIso_hom_naturality (n : ℤ) {X Y : Cᵒᵖ} (f : X ⟶ Y) :
f ≫ (opShiftFunctorEquivalence C n).unitIso.hom.app Y =
(opShiftFunctorEquivalence C n).unitIso.hom.app X ≫ (f⟦n⟧').unop⟦n⟧'.op :=
(opShiftFunctorEquivalence C n).unitIso.hom.naturality f
@[reassoc (attr := simp)]
lemma opShiftFunctorEquivalence_unitIso_inv_naturality (n : ℤ) {X Y : Cᵒᵖ} (f : X ⟶ Y) :
(f⟦n⟧').unop⟦n⟧'.op ≫ (opShiftFunctorEquivalence C n).unitIso.inv.app Y =
(opShiftFunctorEquivalence C n).unitIso.inv.app X ≫ f :=
(opShiftFunctorEquivalence C n).unitIso.inv.naturality f
@[reassoc (attr := simp)]
lemma opShiftFunctorEquivalence_counitIso_hom_naturality (n : ℤ) {X Y : Cᵒᵖ} (f : X ⟶ Y) :
f.unop⟦n⟧'.op⟦n⟧' ≫ (opShiftFunctorEquivalence C n).counitIso.hom.app Y =
(opShiftFunctorEquivalence C n).counitIso.hom.app X ≫ f :=
(opShiftFunctorEquivalence C n).counitIso.hom.naturality f
@[reassoc (attr := simp)]
lemma opShiftFunctorEquivalence_counitIso_inv_naturality (n : ℤ) {X Y : Cᵒᵖ} (f : X ⟶ Y) :
f ≫ (opShiftFunctorEquivalence C n).counitIso.inv.app Y =
(opShiftFunctorEquivalence C n).counitIso.inv.app X ≫ f.unop⟦n⟧'.op⟦n⟧' :=
(opShiftFunctorEquivalence C n).counitIso.inv.naturality f
lemma opShiftFunctorEquivalence_zero_unitIso_hom_app (X : Cᵒᵖ) :
(opShiftFunctorEquivalence C 0).unitIso.hom.app X =
((shiftFunctorZero C ℤ).hom.app X.unop).op ≫
(((shiftFunctorZero Cᵒᵖ ℤ).inv.app X).unop⟦(0 : ℤ)⟧').op := by
apply Quiver.Hom.unop_inj
dsimp [opShiftFunctorEquivalence]
rw [shiftFunctorZero_op_inv_app, unop_comp, Quiver.Hom.unop_op, Functor.map_comp,
shiftFunctorCompIsoId_zero_zero_hom_app, assoc]
lemma opShiftFunctorEquivalence_zero_unitIso_inv_app (X : Cᵒᵖ) :
(opShiftFunctorEquivalence C 0).unitIso.inv.app X =
(((shiftFunctorZero Cᵒᵖ ℤ).hom.app X).unop⟦(0 : ℤ)⟧').op ≫
((shiftFunctorZero C ℤ).inv.app X.unop).op := by
apply Quiver.Hom.unop_inj
dsimp [opShiftFunctorEquivalence]
rw [shiftFunctorZero_op_hom_app, unop_comp, Quiver.Hom.unop_op, Functor.map_comp,
shiftFunctorCompIsoId_zero_zero_inv_app, assoc]
lemma opShiftFunctorEquivalence_unitIso_hom_app_eq (X : Cᵒᵖ) (m n p : ℤ) (h : m + n = p) :
(opShiftFunctorEquivalence C p).unitIso.hom.app X =
(opShiftFunctorEquivalence C n).unitIso.hom.app X ≫
(((opShiftFunctorEquivalence C m).unitIso.hom.app (X⟦n⟧)).unop⟦n⟧').op ≫
((shiftFunctorAdd' C m n p h).hom.app _).op ≫
(((shiftFunctorAdd' Cᵒᵖ n m p (by cutsat)).inv.app X).unop⟦p⟧').op := by
dsimp [opShiftFunctorEquivalence]
simp only [shiftFunctorAdd'_op_inv_app _ n m p (by cutsat) _ _ _ (add_neg_cancel n)
(add_neg_cancel m) (add_neg_cancel p), shiftFunctor_op_map _ _ (add_neg_cancel m),
Category.assoc, Iso.inv_hom_id_app_assoc]
erw [Functor.map_id, Functor.map_id, Functor.map_id, Functor.map_id,
id_comp, id_comp, id_comp, comp_id, comp_id]
dsimp
rw [comp_id, shiftFunctorCompIsoId_add'_hom_app _ _ _ _ _ _
(neg_add_cancel m) (neg_add_cancel n) (neg_add_cancel p) h]
dsimp
rw [Category.assoc, Category.assoc]
rfl
lemma opShiftFunctorEquivalence_unitIso_inv_app_eq (X : Cᵒᵖ) (m n p : ℤ) (h : m + n = p) :
(opShiftFunctorEquivalence C p).unitIso.inv.app X =
(((shiftFunctorAdd' Cᵒᵖ n m p (by cutsat)).hom.app X).unop⟦p⟧').op ≫
((shiftFunctorAdd' C m n p h).inv.app _).op ≫
(((opShiftFunctorEquivalence C m).unitIso.inv.app (X⟦n⟧)).unop⟦n⟧').op ≫
(opShiftFunctorEquivalence C n).unitIso.inv.app X := by
rw [← cancel_mono ((opShiftFunctorEquivalence C p).unitIso.hom.app X), Iso.inv_hom_id_app,
opShiftFunctorEquivalence_unitIso_hom_app_eq _ _ _ _ h,
Category.assoc, Category.assoc, Category.assoc, Iso.inv_hom_id_app_assoc]
apply Quiver.Hom.unop_inj
dsimp
simp only [Category.assoc,
← unop_comp, Iso.inv_hom_id_app, Functor.comp_obj, Functor.op_obj, unop_id,
Functor.map_id, id_comp, ← Functor.map_comp, Iso.hom_inv_id_app]
lemma shift_unop_opShiftFunctorEquivalence_counitIso_inv_app (X : Cᵒᵖ) (n : ℤ) :
((opShiftFunctorEquivalence C n).counitIso.inv.app X).unop⟦n⟧' =
((opShiftFunctorEquivalence C n).unitIso.hom.app ((Opposite.op ((X.unop)⟦n⟧)))).unop :=
Quiver.Hom.op_inj ((opShiftFunctorEquivalence C n).unit_app_inverse X).symm
lemma shift_unop_opShiftFunctorEquivalence_counitIso_hom_app (X : Cᵒᵖ) (n : ℤ) :
((opShiftFunctorEquivalence C n).counitIso.hom.app X).unop⟦n⟧' =
((opShiftFunctorEquivalence C n).unitIso.inv.app ((Opposite.op (X.unop⟦n⟧)))).unop :=
Quiver.Hom.op_inj ((opShiftFunctorEquivalence C n).unitInv_app_inverse X).symm
lemma opShiftFunctorEquivalence_counitIso_inv_app_shift (X : Cᵒᵖ) (n : ℤ) :
(opShiftFunctorEquivalence C n).counitIso.inv.app (X⟦n⟧) =
((opShiftFunctorEquivalence C n).unitIso.hom.app X)⟦n⟧' :=
(opShiftFunctorEquivalence C n).counitInv_app_functor X
lemma opShiftFunctorEquivalence_counitIso_hom_app_shift (X : Cᵒᵖ) (n : ℤ) :
(opShiftFunctorEquivalence C n).counitIso.hom.app (X⟦n⟧) =
((opShiftFunctorEquivalence C n).unitIso.inv.app X)⟦n⟧' :=
(opShiftFunctorEquivalence C n).counit_app_functor X
end Pretriangulated
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Triangulated/Opposite/Functor.lean | import Mathlib.CategoryTheory.Triangulated.Opposite.Pretriangulated
import Mathlib.CategoryTheory.Adjunction.Opposites
/-!
# Opposites of functors between pretriangulated categories,
If `F : C ⥤ D` is a functor between pretriangulated categories, we prove that
`F` is a triangulated functor if and only if `F.op` is a triangulated functor.
In order to do this, we first show that a `CommShift` structure on `F` naturally
gives one on `F.op` (for the shifts on `Cᵒᵖ` and `Dᵒᵖ` defined in
`CategoryTheory.Triangulated.Opposite.Basic`), and we then prove
that `F.mapTriangle.op` and `F.op.mapTriangle` correspond to each other via the
equivalences `(Triangle C)ᵒᵖ ≌ Triangle Cᵒᵖ` and `(Triangle D)ᵒᵖ ≌ Triangle Dᵒᵖ`
given by `CategoryTheory.Pretriangulated.triangleOpEquivalence`.
-/
assert_not_exists TwoSidedIdeal
namespace CategoryTheory
variable {C D : Type*} [Category C] [Category D] [HasShift C ℤ] [HasShift D ℤ] (F : C ⥤ D)
[F.CommShift ℤ]
open Category Limits Pretriangulated Opposite
namespace Pretriangulated.Opposite
/-- If `F` commutes with shifts, so does `F.op`, for the shifts chosen on `Cᵒᵖ` in
`CategoryTheory.Triangulated.Opposite.Basic`.
-/
noncomputable scoped instance commShiftFunctorOpInt : F.op.CommShift ℤ :=
inferInstanceAs ((PullbackShift.functor
(AddMonoidHom.mk' (fun (n : ℤ) => -n) (by intros; dsimp; cutsat))
(OppositeShift.functor ℤ F)).CommShift ℤ)
variable {F}
noncomputable scoped instance commShift_natTrans_op_int {G : C ⥤ D} [G.CommShift ℤ] (τ : F ⟶ G)
[NatTrans.CommShift τ ℤ] : NatTrans.CommShift (NatTrans.op τ) ℤ :=
inferInstanceAs (NatTrans.CommShift (PullbackShift.natTrans
(AddMonoidHom.mk' (fun (n : ℤ) => -n) (by intros; dsimp; cutsat))
(OppositeShift.natTrans ℤ τ)) ℤ)
noncomputable scoped instance commShift_adjunction_op_int {G : D ⥤ C} [G.CommShift ℤ] (adj : F ⊣ G)
[Adjunction.CommShift adj ℤ] : Adjunction.CommShift adj.op ℤ := by
have eq : adj.op = PullbackShift.adjunction
(AddMonoidHom.mk' (fun (n : ℤ) => -n) (by intros; dsimp; cutsat))
(OppositeShift.adjunction ℤ adj) := by
ext
dsimp [PullbackShift.adjunction, NatTrans.PullbackShift.natIsoId,
NatTrans.PullbackShift.natIsoComp, PullbackShift.functor, PullbackShift.natTrans,
OppositeShift.adjunction, OppositeShift.natTrans, NatTrans.OppositeShift.natIsoId,
NatTrans.OppositeShift.natIsoComp, OppositeShift.functor]
simp only [Category.comp_id, Category.id_comp]
rw [eq]
exact inferInstanceAs (Adjunction.CommShift (PullbackShift.adjunction
(AddMonoidHom.mk' (fun (n : ℤ) => -n) (by intros; dsimp; cutsat))
(OppositeShift.adjunction ℤ adj)) ℤ)
end Pretriangulated.Opposite
namespace Functor
@[reassoc]
lemma op_commShiftIso_hom_app (X : Cᵒᵖ) (n m : ℤ) (h : n + m = 0) :
(F.op.commShiftIso n).hom.app X =
(F.map ((shiftFunctorOpIso C n m h).hom.app X).unop).op ≫
((F.commShiftIso m).inv.app X.unop).op ≫
(shiftFunctorOpIso D n m h).inv.app (op (F.obj X.unop)) := by
obtain rfl : m = -n := by cutsat
rfl
@[reassoc]
lemma op_commShiftIso_inv_app (X : Cᵒᵖ) (n m : ℤ) (h : n + m = 0) :
(F.op.commShiftIso n).inv.app X =
(shiftFunctorOpIso D n m h).hom.app (op (F.obj X.unop)) ≫
((F.commShiftIso m).hom.app X.unop).op ≫
(F.map ((shiftFunctorOpIso C n m h).inv.app X).unop).op := by
rw [← cancel_epi ((F.op.commShiftIso n).hom.app X), Iso.hom_inv_id_app,
op_commShiftIso_hom_app _ X n m h, assoc, assoc]
simp [← op_comp, ← F.map_comp]
@[reassoc]
lemma shift_map_op {X Y : C} (f : X ⟶ Y) (n : ℤ) :
(F.map f).op⟦n⟧' = (F.op.commShiftIso n).inv.app _ ≫
(F.map (f.op⟦n⟧').unop).op ≫ (F.op.commShiftIso n).hom.app _ :=
(NatIso.naturality_1 (F.op.commShiftIso n) f.op).symm
@[reassoc]
lemma map_shift_unop {X Y : Cᵒᵖ} (f : X ⟶ Y) (n : ℤ) :
F.map ((f⟦n⟧').unop) = ((F.op.commShiftIso n).inv.app Y).unop ≫
((F.map f.unop).op⟦n⟧').unop ≫ ((F.op.commShiftIso n).hom.app X).unop := by
simp [shift_map_op]
@[reassoc]
lemma map_opShiftFunctorEquivalence_unitIso_hom_app_unop (X : Cᵒᵖ) (n : ℤ) :
F.map ((opShiftFunctorEquivalence C n).unitIso.hom.app X).unop =
(F.commShiftIso n).hom.app _ ≫
(((F.op).commShiftIso n).inv.app X).unop⟦n⟧' ≫
((opShiftFunctorEquivalence D n).unitIso.hom.app (op _)).unop := by
dsimp [opShiftFunctorEquivalence]
simp only [map_comp, unop_comp, Quiver.Hom.unop_op, assoc,
map_shiftFunctorCompIsoId_hom_app, commShiftIso_hom_naturality_assoc,
op_commShiftIso_inv_app _ _ _ _ (add_neg_cancel n)]
congr 3
rw [← Functor.map_comp_assoc, ← unop_comp,
Iso.inv_hom_id_app]
dsimp
rw [map_id, id_comp]
@[reassoc]
lemma map_opShiftFunctorEquivalence_unitIso_inv_app_unop (X : Cᵒᵖ) (n : ℤ) :
F.map ((opShiftFunctorEquivalence C n).unitIso.inv.app X).unop =
((opShiftFunctorEquivalence D n).unitIso.inv.app (op (F.obj X.unop))).unop ≫
(((F.op).commShiftIso n).hom.app X).unop⟦n⟧' ≫
((F.commShiftIso n).inv.app _) := by
rw [← cancel_mono (F.map ((opShiftFunctorEquivalence C n).unitIso.hom.app X).unop),
← F.map_comp, ← unop_comp, Iso.hom_inv_id_app,
map_opShiftFunctorEquivalence_unitIso_hom_app_unop, assoc, assoc,
Iso.inv_hom_id_app_assoc, ← Functor.map_comp_assoc, ← unop_comp]
simp
@[reassoc]
lemma map_opShiftFunctorEquivalence_counitIso_hom_app_unop (X : Cᵒᵖ) (n : ℤ) :
F.map ((opShiftFunctorEquivalence C n).counitIso.hom.app X).unop =
((opShiftFunctorEquivalence D n).counitIso.hom.app (op (F.obj X.unop))).unop ≫
(((F.commShiftIso n).inv.app X.unop).op⟦n⟧').unop ≫
((F.op.commShiftIso n).hom.app (op (X.unop⟦n⟧))).unop := by
apply Quiver.Hom.op_inj
dsimp [opShiftFunctorEquivalence]
rw [assoc, F.op_commShiftIso_hom_app_assoc _ _ _ (add_neg_cancel n), map_comp,
map_shiftFunctorCompIsoId_inv_app_assoc, op_comp, op_comp_assoc, op_comp_assoc,
NatTrans.naturality_assoc, op_map, Iso.inv_hom_id_app_assoc, Quiver.Hom.unop_op]
@[reassoc]
lemma map_opShiftFunctorEquivalence_counitIso_inv_app_unop (X : Cᵒᵖ) (n : ℤ) :
F.map ((opShiftFunctorEquivalence C n).counitIso.inv.app X).unop =
((F.op.commShiftIso n).inv.app (op (X.unop⟦n⟧))).unop ≫
(((F.commShiftIso n).hom.app X.unop).op⟦n⟧').unop ≫
((opShiftFunctorEquivalence D n).counitIso.inv.app (op (F.obj X.unop))).unop := by
rw [← cancel_epi (F.map ((opShiftFunctorEquivalence C n).counitIso.hom.app X).unop),
← F.map_comp, ← unop_comp, Iso.inv_hom_id_app,
map_opShiftFunctorEquivalence_counitIso_hom_app_unop]
dsimp
simp only [map_id, assoc, ← Functor.map_comp_assoc,
← unop_comp, Iso.inv_hom_id_app_assoc, ← op_comp,
Iso.inv_hom_id_app]
simp
end Functor
variable [HasZeroObject C] [Preadditive C] [∀ (n : ℤ), (shiftFunctor C n).Additive]
[Pretriangulated C] [HasZeroObject D] [Preadditive D]
[∀ (n : ℤ), (shiftFunctor D n).Additive] [Pretriangulated D]
namespace Functor
/--
If `F : C ⥤ D` commutes with shifts, this expresses the compatibility of `F.mapTriangle`
with the equivalences `Pretriangulated.triangleOpEquivalence` on `C` and `D`.
-/
@[simps!]
noncomputable def mapTriangleOpCompTriangleOpEquivalenceFunctorApp (T : Triangle C) :
(triangleOpEquivalence D).functor.obj (op (F.mapTriangle.obj T)) ≅
F.op.mapTriangle.obj ((triangleOpEquivalence C).functor.obj (op T)) :=
Triangle.isoMk _ _ (Iso.refl _) (Iso.refl _) (Iso.refl _) (by simp) (by simp)
(by simp [shift_map_op, map_opShiftFunctorEquivalence_counitIso_inv_app_unop])
/--
If `F : C ⥤ D` commutes with shifts, this expresses the compatibility of `F.mapTriangle`
with the equivalences `Pretriangulated.triangleOpEquivalence` on `C` and `D`.
-/
noncomputable def mapTriangleOpCompTriangleOpEquivalenceFunctor :
F.mapTriangle.op ⋙ (triangleOpEquivalence D).functor ≅
(triangleOpEquivalence C).functor ⋙ F.op.mapTriangle :=
NatIso.ofComponents
(fun T ↦ F.mapTriangleOpCompTriangleOpEquivalenceFunctorApp T.unop)
(by intros; ext <;> dsimp <;> simp only [id_comp, comp_id])
/--
If `F : C ⥤ D` commutes with shifts, this is the 2-commutative square of categories
`CategoryTheory.Functor.mapTriangleOpCompTriangleOpEquivalenceFunctor`.
-/
noncomputable instance :
CatCommSq (F.mapTriangle.op) (triangleOpEquivalence C).functor
(triangleOpEquivalence D).functor F.op.mapTriangle :=
⟨F.mapTriangleOpCompTriangleOpEquivalenceFunctor⟩
/--
Vertical inverse of the 2-commutative square of
`CategoryTheory.Functor.mapTriangleOpCompTriangleOpEquivalenceFunctor`.
-/
noncomputable instance :
CatCommSq (F.op.mapTriangle) (triangleOpEquivalence C).inverse
(triangleOpEquivalence D).inverse F.mapTriangle.op :=
CatCommSq.vInv (F.mapTriangle.op) (triangleOpEquivalence C)
(triangleOpEquivalence D) F.op.mapTriangle inferInstance
/--
If `F : C ⥤ D` commutes with shifts, this expresses the compatibility of `F.mapTriangle`
with the equivalences `Pretriangulated.triangleOpEquivalence` on `C` and `D`.
-/
noncomputable def opMapTriangleCompTriangleOpEquivalenceInverse :
F.op.mapTriangle ⋙ (triangleOpEquivalence D).inverse ≅
(triangleOpEquivalence C).inverse ⋙ F.mapTriangle.op :=
CatCommSq.iso (F.op.mapTriangle) (triangleOpEquivalence C).inverse
(triangleOpEquivalence D).inverse F.mapTriangle.op
end Functor
namespace Pretriangulated.Opposite
open Functor in
/-- If `F` is triangulated, so is `F.op`.
-/
scoped instance functor_isTriangulated_op [F.IsTriangulated] : F.op.IsTriangulated where
map_distinguished T dT := by
rw [mem_distTriang_op_iff]
exact Pretriangulated.isomorphic_distinguished _
((F.map_distinguished _ (unop_distinguished _ dT))) _
(((opMapTriangleCompTriangleOpEquivalenceInverse F).symm.app T).unop)
end Pretriangulated.Opposite
namespace Functor
/-- If `F.op` is triangulated, so is `F`.
-/
lemma isTriangulated_of_op [F.op.IsTriangulated] : F.IsTriangulated where
map_distinguished T dT := by
have := distinguished_iff_of_iso ((triangleOpEquivalence D).unitIso.app
(Opposite.op (F.mapTriangle.obj T))).unop
rw [Functor.id_obj, Opposite.unop_op (F.mapTriangle.obj T)] at this
rw [← this, Functor.comp_obj, ← mem_distTriang_op_iff, ← Functor.op_obj, ← Functor.comp_obj,
distinguished_iff_of_iso ((mapTriangleOpCompTriangleOpEquivalenceFunctor F).app
(Opposite.op T))]
apply F.op.map_distinguished
have := distinguished_iff_of_iso ((triangleOpEquivalence C).unitIso.app (Opposite.op T)).unop
rw [Functor.id_obj, Opposite.unop_op T] at this
rw [← this, Functor.comp_obj, ← mem_distTriang_op_iff] at dT
exact dT
open Pretriangulated.Opposite in
/-- `F` is triangulated if and only if `F.op` is triangulated.
-/
lemma op_isTriangulated_iff : F.op.IsTriangulated ↔ F.IsTriangulated :=
⟨fun _ ↦ F.isTriangulated_of_op, fun _ ↦ inferInstance⟩
end Functor
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Triangulated/Opposite/Pretriangulated.lean | import Mathlib.CategoryTheory.Triangulated.Opposite.Triangle
import Mathlib.CategoryTheory.Triangulated.HomologicalFunctor
/-!
# The (pre)triangulated structure on the opposite category
In this file, we shall construct the (pre)triangulated structure
on the opposite category `Cᵒᵖ` of a (pre)triangulated category `C`.
The shift on `Cᵒᵖ` was constructed in `CategoryTheory.Triangulated.Opposite.Basic`,
and is such that shifting by `n : ℤ` on `Cᵒᵖ` corresponds to the shift by
`-n` on `C`. In `CategoryTheory.Triangulated.Opposite.Triangle`, we constructed
an equivalence `(Triangle C)ᵒᵖ ≌ Triangle Cᵒᵖ`, called
`CategoryTheory.Pretriangulated.triangleOpEquivalence`.
Here, we defined the notion of distinguished triangles in `Cᵒᵖ`, such that
`triangleOpEquivalence` sends distinguished triangles in `C` to distinguished triangles
in `Cᵒᵖ`. In other words, if `X ⟶ Y ⟶ Z ⟶ X⟦1⟧` is a distinguished triangle in `C`,
then the triangle `op Z ⟶ op Y ⟶ op X ⟶ (op Z)⟦1⟧` that is deduced *without introducing signs*
shall be a distinguished triangle in `Cᵒᵖ`. This is equivalent to the definition
in [Verdiers's thesis, p. 96][verdier1996] which would require that the triangle
`(op X)⟦-1⟧ ⟶ op Z ⟶ op Y ⟶ op X` (without signs) is *antidistinguished*.
## References
* [Jean-Louis Verdier, *Des catégories dérivées des catégories abéliennes*][verdier1996]
-/
assert_not_exists TwoSidedIdeal
namespace CategoryTheory
open Category Limits Preadditive ZeroObject
variable (C : Type*) [Category C] [HasShift C ℤ] [HasZeroObject C] [Preadditive C]
[∀ (n : ℤ), (shiftFunctor C n).Additive] [Pretriangulated C]
namespace Pretriangulated
open Opposite
namespace Opposite
/-- A triangle in `Cᵒᵖ` shall be distinguished iff it corresponds to a distinguished
triangle in `C` via the equivalence `triangleOpEquivalence C : (Triangle C)ᵒᵖ ≌ Triangle Cᵒᵖ`. -/
def distinguishedTriangles : Set (Triangle Cᵒᵖ) :=
fun T => ((triangleOpEquivalence C).inverse.obj T).unop ∈ distTriang C
variable {C}
lemma mem_distinguishedTriangles_iff (T : Triangle Cᵒᵖ) :
T ∈ distinguishedTriangles C ↔
((triangleOpEquivalence C).inverse.obj T).unop ∈ distTriang C := by
rfl
lemma mem_distinguishedTriangles_iff' (T : Triangle Cᵒᵖ) :
T ∈ distinguishedTriangles C ↔
∃ (T' : Triangle C) (_ : T' ∈ distTriang C),
Nonempty (T ≅ (triangleOpEquivalence C).functor.obj (Opposite.op T')) := by
rw [mem_distinguishedTriangles_iff]
constructor
· intro hT
exact ⟨_, hT, ⟨(triangleOpEquivalence C).counitIso.symm.app T⟩⟩
· rintro ⟨T', hT', ⟨e⟩⟩
refine isomorphic_distinguished _ hT' _ ?_
exact Iso.unop ((triangleOpEquivalence C).unitIso.app (Opposite.op T') ≪≫
(triangleOpEquivalence C).inverse.mapIso e.symm)
lemma isomorphic_distinguished (T₁ : Triangle Cᵒᵖ)
(hT₁ : T₁ ∈ distinguishedTriangles C) (T₂ : Triangle Cᵒᵖ) (e : T₂ ≅ T₁) :
T₂ ∈ distinguishedTriangles C := by
simp only [mem_distinguishedTriangles_iff] at hT₁ ⊢
exact Pretriangulated.isomorphic_distinguished _ hT₁ _
((triangleOpEquivalence C).inverse.mapIso e).unop.symm
/-- Up to rotation, the contractible triangle `X ⟶ X ⟶ 0 ⟶ X⟦1⟧` for `X : Cᵒᵖ` corresponds
to the contractible triangle for `X.unop` in `C`. -/
@[simps!]
noncomputable def contractibleTriangleIso (X : Cᵒᵖ) :
contractibleTriangle X ≅ (triangleOpEquivalence C).functor.obj
(Opposite.op (contractibleTriangle X.unop).invRotate) :=
Triangle.isoMk _ _ (Iso.refl _) (Iso.refl _)
(IsZero.iso (isZero_zero _) (by
dsimp
rw [IsZero.iff_id_eq_zero]
change (𝟙 ((0 : C)⟦(-1 : ℤ)⟧)).op = 0
rw [← Functor.map_id, id_zero, Functor.map_zero, op_zero]))
(by simp) (by simp) (by simp)
lemma contractible_distinguished (X : Cᵒᵖ) :
contractibleTriangle X ∈ distinguishedTriangles C := by
rw [mem_distinguishedTriangles_iff']
exact ⟨_, inv_rot_of_distTriang _ (Pretriangulated.contractible_distinguished X.unop),
⟨contractibleTriangleIso X⟩⟩
/-- Isomorphism expressing a compatibility of the equivalence `triangleOpEquivalence C`
with the rotation of triangles. -/
noncomputable def rotateTriangleOpEquivalenceInverseObjRotateUnopIso (T : Triangle Cᵒᵖ) :
((triangleOpEquivalence C).inverse.obj T.rotate).unop.rotate ≅
((triangleOpEquivalence C).inverse.obj T).unop :=
Triangle.isoMk _ _ (Iso.refl _) (Iso.refl _)
(-((opShiftFunctorEquivalence C 1).unitIso.app T.obj₁).unop) (by simp)
(Quiver.Hom.op_inj (by simp)) (by simp)
lemma rotate_distinguished_triangle (T : Triangle Cᵒᵖ) :
T ∈ distinguishedTriangles C ↔ T.rotate ∈ distinguishedTriangles C := by
simp only [mem_distinguishedTriangles_iff, Pretriangulated.rotate_distinguished_triangle
((triangleOpEquivalence C).inverse.obj (T.rotate)).unop]
exact distinguished_iff_of_iso (rotateTriangleOpEquivalenceInverseObjRotateUnopIso T).symm
lemma distinguished_cocone_triangle {X Y : Cᵒᵖ} (f : X ⟶ Y) :
∃ (Z : Cᵒᵖ) (g : Y ⟶ Z) (h : Z ⟶ X⟦(1 : ℤ)⟧),
Triangle.mk f g h ∈ distinguishedTriangles C := by
obtain ⟨Z, g, h, H⟩ := Pretriangulated.distinguished_cocone_triangle₁ f.unop
refine ⟨_, g.op, (opShiftFunctorEquivalence C 1).counitIso.inv.app (Opposite.op Z) ≫
(shiftFunctor Cᵒᵖ (1 : ℤ)).map h.op, ?_⟩
simp only [mem_distinguishedTriangles_iff]
refine Pretriangulated.isomorphic_distinguished _ H _ ?_
exact Triangle.isoMk _ _ (Iso.refl _) (Iso.refl _) (Iso.refl _) (by simp) (by simp)
(Quiver.Hom.op_inj (by simp [shift_unop_opShiftFunctorEquivalence_counitIso_inv_app]))
lemma complete_distinguished_triangle_morphism (T₁ T₂ : Triangle Cᵒᵖ)
(hT₁ : T₁ ∈ distinguishedTriangles C) (hT₂ : T₂ ∈ distinguishedTriangles C)
(a : T₁.obj₁ ⟶ T₂.obj₁) (b : T₁.obj₂ ⟶ T₂.obj₂) (comm : T₁.mor₁ ≫ b = a ≫ T₂.mor₁) :
∃ (c : T₁.obj₃ ⟶ T₂.obj₃), T₁.mor₂ ≫ c = b ≫ T₂.mor₂ ∧
T₁.mor₃ ≫ a⟦1⟧' = c ≫ T₂.mor₃ := by
rw [mem_distinguishedTriangles_iff] at hT₁ hT₂
obtain ⟨c, hc₁, hc₂⟩ :=
Pretriangulated.complete_distinguished_triangle_morphism₁ _ _ hT₂ hT₁
b.unop a.unop (Quiver.Hom.op_inj comm.symm)
dsimp at c hc₁ hc₂
replace hc₂ := ((opShiftFunctorEquivalence C 1).unitIso.hom.app T₂.obj₁).unop ≫= hc₂
dsimp at hc₂
simp only [assoc, Iso.unop_hom_inv_id_app_assoc] at hc₂
refine ⟨c.op, Quiver.Hom.unop_inj hc₁.symm, Quiver.Hom.unop_inj ?_⟩
apply (shiftFunctor C (1 : ℤ)).map_injective
rw [unop_comp, unop_comp, Functor.map_comp, Functor.map_comp,
Quiver.Hom.unop_op, hc₂, ← unop_comp_assoc, ← unop_comp_assoc,
← opShiftFunctorEquivalence_unitIso_inv_naturality]
simp
/-- The pretriangulated structure on the opposite category of
a pretriangulated category. It is a scoped instance, so that we need to
`open CategoryTheory.Pretriangulated.Opposite` in order to be able
to use it: the reason is that it relies on the definition of the shift
on the opposite category `Cᵒᵖ`, for which it is unclear whether it should
be a global instance or not. -/
noncomputable scoped instance : Pretriangulated Cᵒᵖ where
distinguishedTriangles := distinguishedTriangles C
isomorphic_distinguished := isomorphic_distinguished
contractible_distinguished := contractible_distinguished
distinguished_cocone_triangle := distinguished_cocone_triangle
rotate_distinguished_triangle := rotate_distinguished_triangle
complete_distinguished_triangle_morphism := complete_distinguished_triangle_morphism
end Opposite
variable {C}
lemma mem_distTriang_op_iff (T : Triangle Cᵒᵖ) :
(T ∈ distTriang Cᵒᵖ) ↔ ((triangleOpEquivalence C).inverse.obj T).unop ∈ distTriang C := by
rfl
lemma mem_distTriang_op_iff' (T : Triangle Cᵒᵖ) :
(T ∈ distTriang Cᵒᵖ) ↔ ∃ (T' : Triangle C) (_ : T' ∈ distTriang C),
Nonempty (T ≅ (triangleOpEquivalence C).functor.obj (Opposite.op T')) :=
Opposite.mem_distinguishedTriangles_iff' T
lemma op_distinguished (T : Triangle C) (hT : T ∈ distTriang C) :
((triangleOpEquivalence C).functor.obj (Opposite.op T)) ∈ distTriang Cᵒᵖ := by
rw [mem_distTriang_op_iff']
exact ⟨T, hT, ⟨Iso.refl _⟩⟩
lemma unop_distinguished (T : Triangle Cᵒᵖ) (hT : T ∈ distTriang Cᵒᵖ) :
((triangleOpEquivalence C).inverse.obj T).unop ∈ distTriang C := hT
end Pretriangulated
namespace Functor
open Pretriangulated.Opposite Pretriangulated
variable {C}
lemma map_distinguished_op_exact {A : Type*} [Category A] [Abelian A] (F : Cᵒᵖ ⥤ A)
[F.IsHomological] (T : Triangle C) (hT : T ∈ distTriang C) :
((shortComplexOfDistTriangle T hT).op.map F).Exact :=
F.map_distinguished_exact _ (op_distinguished T hT)
end Functor
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Triangulated/TStructure/Basic.lean | import Mathlib.CategoryTheory.ObjectProperty.Shift
import Mathlib.CategoryTheory.Triangulated.Pretriangulated
/-!
# t-structures on triangulated categories
This file introduces the notion of t-structure on (pre)triangulated categories.
The first example of t-structure shall be the canonical t-structure on the
derived category of an abelian category (TODO).
Given a t-structure `t : TStructure C`, we define type classes `t.IsLE X n`
and `t.IsGE X n` in order to say that an object `X : C` is `≤ n` or `≥ n` for `t`.
## Implementation notes
We introduce the type of t-structures rather than a type class saying that we
have fixed a t-structure on a certain category. The reason is that certain
triangulated categories have several t-structures which one may want to
use depending on the context.
## TODO
* define functors `t.truncLE n : C ⥤ C`, `t.truncGE n : C ⥤ C` and the
associated distinguished triangles
* promote these truncations to a (functorial) spectral object
* define the heart of `t` and show it is an abelian category
* define triangulated subcategories `t.plus`, `t.minus`, `t.bounded` and show
that there are induced t-structures on these full subcategories
## References
* [Beilinson, Bernstein, Deligne, Gabber, *Faisceaux pervers*][bbd-1982]
-/
assert_not_exists TwoSidedIdeal
namespace CategoryTheory
open Limits
namespace Triangulated
variable (C : Type _) [Category C] [Preadditive C] [HasZeroObject C] [HasShift C ℤ]
[∀ (n : ℤ), (shiftFunctor C n).Additive] [Pretriangulated C]
open Pretriangulated
/-- `TStructure C` is the type of t-structures on the (pre)triangulated category `C`. -/
structure TStructure where
/-- the predicate of objects that are `≤ n` for `n : ℤ`. -/
le (n : ℤ) : ObjectProperty C
/-- the predicate of objects that are `≥ n` for `n : ℤ`. -/
ge (n : ℤ) : ObjectProperty C
le_isClosedUnderIsomorphisms (n : ℤ) : (le n).IsClosedUnderIsomorphisms := by infer_instance
ge_isClosedUnderIsomorphisms (n : ℤ) : (ge n).IsClosedUnderIsomorphisms := by infer_instance
le_shift (n a n' : ℤ) (h : a + n' = n) (X : C) (hX : le n X) : le n' (X⟦a⟧)
ge_shift (n a n' : ℤ) (h : a + n' = n) (X : C) (hX : ge n X) : ge n' (X⟦a⟧)
zero' ⦃X Y : C⦄ (f : X ⟶ Y) (hX : le 0 X) (hY : ge 1 Y) : f = 0
le_zero_le : le 0 ≤ le 1
ge_one_le : ge 1 ≤ ge 0
exists_triangle_zero_one (A : C) : ∃ (X Y : C) (_ : le 0 X) (_ : ge 1 Y)
(f : X ⟶ A) (g : A ⟶ Y) (h : Y ⟶ X⟦(1 : ℤ)⟧), Triangle.mk f g h ∈ distTriang C
namespace TStructure
attribute [instance] le_isClosedUnderIsomorphisms ge_isClosedUnderIsomorphisms
variable {C}
variable (t : TStructure C)
lemma exists_triangle (A : C) (n₀ n₁ : ℤ) (h : n₀ + 1 = n₁) :
∃ (X Y : C) (_ : t.le n₀ X) (_ : t.ge n₁ Y) (f : X ⟶ A) (g : A ⟶ Y)
(h : Y ⟶ X⟦(1 : ℤ)⟧), Triangle.mk f g h ∈ distTriang C := by
obtain ⟨X, Y, hX, hY, f, g, h, mem⟩ := t.exists_triangle_zero_one (A⟦n₀⟧)
let T := (Triangle.shiftFunctor C (-n₀)).obj (Triangle.mk f g h)
let e := (shiftEquiv C n₀).unitIso.symm.app A
have hT' : Triangle.mk (T.mor₁ ≫ e.hom) (e.inv ≫ T.mor₂) T.mor₃ ∈ distTriang C := by
refine isomorphic_distinguished _ (Triangle.shift_distinguished _ mem (-n₀)) _ ?_
refine Triangle.isoMk _ _ (Iso.refl _) e.symm (Iso.refl _) ?_ ?_ ?_
all_goals simp [T]
exact ⟨_, _, t.le_shift _ _ _ (neg_add_cancel n₀) _ hX,
t.ge_shift _ _ _ (by cutsat) _ hY, _, _, _, hT'⟩
lemma shift_le (a n n' : ℤ) (hn' : a + n = n') :
(t.le n).shift a = t.le n' := by
ext X
constructor
· intro hX
exact ((t.le n').prop_iff_of_iso ((shiftEquiv C a).unitIso.symm.app X)).1
(t.le_shift n (-a) n' (by cutsat) _ hX)
· intro hX
exact t.le_shift _ _ _ hn' X hX
lemma shift_ge (a n n' : ℤ) (hn' : a + n = n') :
(t.ge n).shift a = t.ge n' := by
ext X
constructor
· intro hX
exact ((t.ge n').prop_iff_of_iso ((shiftEquiv C a).unitIso.symm.app X)).1
(t.ge_shift n (-a) n' (by cutsat) _ hX)
· intro hX
exact t.ge_shift _ _ _ hn' X hX
lemma le_monotone : Monotone t.le := by
let H := fun (a : ℕ) => ∀ (n : ℤ), t.le n ≤ t.le (n + a)
suffices ∀ (a : ℕ), H a by
intro n₀ n₁ h
obtain ⟨a, ha⟩ := Int.nonneg_def.1 h
obtain rfl : n₁ = n₀ + a := by cutsat
apply this
have H_zero : H 0 := fun n => by
simp only [Nat.cast_zero, add_zero]
rfl
have H_one : H 1 := fun n X hX => by
rw [← t.shift_le n 1 (n + (1 : ℕ)) rfl, ObjectProperty.prop_shift_iff]
rw [← t.shift_le n 0 n (add_zero n), ObjectProperty.prop_shift_iff] at hX
exact t.le_zero_le _ hX
have H_add : ∀ (a b c : ℕ) (_ : a + b = c) (_ : H a) (_ : H b), H c := by
intro a b c h ha hb n
rw [← h, Nat.cast_add, ← add_assoc]
exact (ha n).trans (hb (n+a))
intro a
induction a with
| zero => exact H_zero
| succ a ha => exact H_add a 1 _ rfl ha H_one
lemma ge_antitone : Antitone t.ge := by
let H := fun (a : ℕ) => ∀ (n : ℤ), t.ge (n + a) ≤ t.ge n
suffices ∀ (a : ℕ), H a by
intro n₀ n₁ h
obtain ⟨a, ha⟩ := Int.nonneg_def.1 h
obtain rfl : n₁ = n₀ + a := by cutsat
apply this
have H_zero : H 0 := fun n => by
simp only [Nat.cast_zero, add_zero]
rfl
have H_one : H 1 := fun n X hX => by
rw [← t.shift_ge n 1 (n + (1 : ℕ)) (by simp), ObjectProperty.prop_shift_iff] at hX
rw [← t.shift_ge n 0 n (add_zero n)]
exact t.ge_one_le _ hX
have H_add : ∀ (a b c : ℕ) (_ : a + b = c) (_ : H a) (_ : H b), H c := by
intro a b c h ha hb n
rw [← h, Nat.cast_add, ← add_assoc ]
exact (hb (n + a)).trans (ha n)
intro a
induction a with
| zero => exact H_zero
| succ a ha => exact H_add a 1 _ rfl ha H_one
/-- Given a t-structure `t` on a pretriangulated category `C`, the property `t.IsLE X n`
holds if `X : C` is `≤ n` for the t-structure. -/
class IsLE (X : C) (n : ℤ) : Prop where
le : t.le n X
/-- Given a t-structure `t` on a pretriangulated category `C`, the property `t.IsGE X n`
holds if `X : C` is `≥ n` for the t-structure. -/
class IsGE (X : C) (n : ℤ) : Prop where
ge : t.ge n X
lemma le_of_isLE (X : C) (n : ℤ) [t.IsLE X n] : t.le n X := IsLE.le
lemma ge_of_isGE (X : C) (n : ℤ) [t.IsGE X n] : t.ge n X := IsGE.ge
lemma isLE_of_iso {X Y : C} (e : X ≅ Y) (n : ℤ) [t.IsLE X n] : t.IsLE Y n where
le := (t.le n).prop_of_iso e (t.le_of_isLE X n)
lemma isGE_of_iso {X Y : C} (e : X ≅ Y) (n : ℤ) [t.IsGE X n] : t.IsGE Y n where
ge := (t.ge n).prop_of_iso e (t.ge_of_isGE X n)
lemma isLE_of_LE (X : C) (p q : ℤ) (hpq : p ≤ q := by cutsat) [t.IsLE X p] : t.IsLE X q where
le := le_monotone t hpq _ (t.le_of_isLE X p)
lemma isGE_of_GE (X : C) (p q : ℤ) (hpq : p ≤ q := by cutsat) [t.IsGE X q] : t.IsGE X p where
ge := ge_antitone t hpq _ (t.ge_of_isGE X q)
lemma isLE_shift (X : C) (n a n' : ℤ) (hn' : a + n' = n := by cutsat) [t.IsLE X n] :
t.IsLE (X⟦a⟧) n' :=
⟨t.le_shift n a n' hn' X (t.le_of_isLE X n)⟩
lemma isGE_shift (X : C) (n a n' : ℤ) (hn' : a + n' = n := by cutsat) [t.IsGE X n] :
t.IsGE (X⟦a⟧) n' :=
⟨t.ge_shift n a n' hn' X (t.ge_of_isGE X n)⟩
lemma isLE_of_shift (X : C) (n a n' : ℤ) (hn' : a + n' = n := by cutsat) [t.IsLE (X⟦a⟧) n'] :
t.IsLE X n := by
have h := t.isLE_shift (X⟦a⟧) n' (-a) n
exact t.isLE_of_iso (show X⟦a⟧⟦-a⟧ ≅ X from (shiftEquiv C a).unitIso.symm.app X) n
lemma isGE_of_shift (X : C) (n a n' : ℤ) (hn' : a + n' = n := by cutsat) [t.IsGE (X⟦a⟧) n'] :
t.IsGE X n := by
have h := t.isGE_shift (X⟦a⟧) n' (-a) n
exact t.isGE_of_iso (show X⟦a⟧⟦-a⟧ ≅ X from (shiftEquiv C a).unitIso.symm.app X) n
lemma isLE_shift_iff (X : C) (n a n' : ℤ) (hn' : a + n' = n := by cutsat) :
t.IsLE (X⟦a⟧) n' ↔ t.IsLE X n := by
constructor
· intro
exact t.isLE_of_shift X n a n' hn'
· intro
exact t.isLE_shift X n a n' hn'
lemma isGE_shift_iff (X : C) (n a n' : ℤ) (hn' : a + n' = n := by cutsat) :
t.IsGE (X⟦a⟧) n' ↔ t.IsGE X n := by
constructor
· intro
exact t.isGE_of_shift X n a n' hn'
· intro
exact t.isGE_shift X n a n' hn'
lemma zero {X Y : C} (f : X ⟶ Y) (n₀ n₁ : ℤ) (h : n₀ < n₁ := by cutsat)
[t.IsLE X n₀] [t.IsGE Y n₁] : f = 0 := by
have := t.isLE_shift X n₀ n₀ 0 (add_zero n₀)
have := t.isGE_shift Y n₁ n₀ (n₁-n₀)
have := t.isGE_of_GE (Y⟦n₀⟧) 1 (n₁-n₀)
apply (shiftFunctor C n₀).map_injective
simp only [Functor.map_zero]
apply t.zero'
· apply t.le_of_isLE
· apply t.ge_of_isGE
lemma zero_of_isLE_of_isGE {X Y : C} (f : X ⟶ Y) (n₀ n₁ : ℤ) (h : n₀ < n₁)
(_ : t.IsLE X n₀) (_ : t.IsGE Y n₁) : f = 0 :=
t.zero f n₀ n₁ h
lemma isZero (X : C) (n₀ n₁ : ℤ) (h : n₀ < n₁ := by cutsat)
[t.IsLE X n₀] [t.IsGE X n₁] : IsZero X := by
rw [IsZero.iff_id_eq_zero]
exact t.zero _ n₀ n₁ h
end TStructure
end Triangulated
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Subobject/ArtinianObject.lean | import Mathlib.CategoryTheory.Subobject.Lattice
import Mathlib.CategoryTheory.ObjectProperty.ContainsZero
import Mathlib.CategoryTheory.ObjectProperty.EpiMono
import Mathlib.CategoryTheory.Limits.Constructions.EventuallyConstant
import Mathlib.Order.OrderIsoNat
import Mathlib.CategoryTheory.Simple
/-!
# Artinian objects
We shall say that an object `X` in a category `C` is Artinian
(type class `IsArtinianObject X`) if the ordered type `Subobject X`
satisfies the descending chain condition. The corresponding property of
objects `isArtinianObject : ObjectProperty C` is always
closed under subobjects.
## Future works
* when `C` is an abelian category, relate `IsArtinianObject` in `C`
with `IsNoetherianObject` in `Cᵒᵖ`.
-/
universe v u
namespace CategoryTheory
open Limits ZeroObject
variable {C : Type u} [Category.{v} C]
/-- An object `X` in a category `C` is Artinian if `Subobject X`
satisfies the descending chain condition. This definition is a
term in `ObjectProperty C` which allows to study the stability
properties of Artinian objects. For statements regarding
specific objects, it is advisable to use the type class
`IsArtinianObject` instead. -/
@[stacks 0FCF]
def isArtinianObject : ObjectProperty C :=
fun X ↦ WellFoundedLT (Subobject X)
variable (X Y : C)
/-- An object `X` in a category `C` is Artinian if `Subobject X`
satisfies the descending chain condition. -/
@[stacks 0FCF]
abbrev IsArtinianObject : Prop := isArtinianObject.Is X
instance [IsArtinianObject X] : WellFoundedLT (Subobject X) :=
isArtinianObject.prop_of_is X
lemma isArtinianObject_iff_antitone_chain_condition :
IsArtinianObject X ↔ ∀ (f : ℕ →o (Subobject X)ᵒᵈ),
∃ (n : ℕ), ∀ (m : ℕ), n ≤ m → f n = f m := by
dsimp only [IsArtinianObject]
rw [ObjectProperty.is_iff, isArtinianObject,
← wellFoundedGT_dual_iff,
wellFoundedGT_iff_monotone_chain_condition]
variable {X} in
lemma antitone_chain_condition_of_isArtinianObject
[IsArtinianObject X] (f : ℕ →o (Subobject X)ᵒᵈ) :
∃ (n : ℕ), ∀ (m : ℕ), n ≤ m → f n = f m :=
(isArtinianObject_iff_antitone_chain_condition X).1 inferInstance f
lemma isArtinianObject_iff_not_strictAnti :
IsArtinianObject X ↔ ∀ (f : ℕ → Subobject X), ¬ StrictAnti f := by
refine ⟨fun _ ↦ not_strictAnti_of_wellFoundedLT, fun h ↦ ?_⟩
dsimp only [IsArtinianObject]
rw [ObjectProperty.is_iff, isArtinianObject, WellFoundedLT,
isWellFounded_iff, RelEmbedding.wellFounded_iff_isEmpty]
exact ⟨fun f ↦ h f.toFun (fun a b h ↦ f.map_rel_iff.2 h)⟩
variable {X} in
lemma not_strictAnti_of_isArtinianObject
[IsArtinianObject X] (f : ℕ → Subobject X) :
¬ StrictAnti f :=
(isArtinianObject_iff_not_strictAnti X).1 inferInstance f
lemma isArtinianObject_iff_isEventuallyConstant :
IsArtinianObject X ↔ ∀ (F : ℕ ⥤ (MonoOver X)ᵒᵖ),
IsFiltered.IsEventuallyConstant F := by
rw [isArtinianObject_iff_antitone_chain_condition]
refine ⟨fun h G ↦ ?_, fun h F ↦ ?_⟩
· obtain ⟨n, hn⟩ := h ⟨_, (G ⋙ (Subobject.equivMonoOver X).inverse.op ⋙
(orderDualEquivalence _).inverse).monotone⟩
refine ⟨n, fun m hm ↦ ?_⟩
rw [← isIso_unop_iff, MonoOver.isIso_iff_subobjectMk_eq]
exact (hn m (leOfHom hm)).symm
· obtain ⟨n, hn⟩ := h (F.monotone.functor ⋙ (orderDualEquivalence _).functor ⋙
Subobject.representative.op)
refine ⟨n, fun m hm ↦ Eq.symm ?_⟩
simpa [isIso_op_iff, isIso_iff_of_reflects_iso, PartialOrder.isIso_iff_eq]
using hn (homOfLE hm)
variable {X} in
lemma isEventuallyConstant_of_isArtinianObject [IsArtinianObject X]
(F : ℕ ⥤ (MonoOver X)ᵒᵖ) : IsFiltered.IsEventuallyConstant F :=
(isArtinianObject_iff_isEventuallyConstant X).1 inferInstance F
variable {X Y}
lemma isArtinianObject_of_isZero (hX : IsZero X) : IsArtinianObject X := by
rw [isArtinianObject_iff_antitone_chain_condition]
have := Subobject.subsingleton_of_isZero hX
intro f
exact ⟨0, fun m hm ↦ Subsingleton.elim _ _⟩
instance [HasZeroObject C] : (isArtinianObject (C := C)).ContainsZero where
exists_zero := ⟨0, isZero_zero _, by
rw [← isArtinianObject.is_iff]
exact isArtinianObject_of_isZero (isZero_zero C)⟩
lemma isArtinianObject_of_mono (i : X ⟶ Y) [Mono i] [IsArtinianObject Y] :
IsArtinianObject X := by
rw [isArtinianObject_iff_antitone_chain_condition]
intro f
obtain ⟨n, hn⟩ := antitone_chain_condition_of_isArtinianObject
⟨fun n ↦ (Subobject.map i).obj (f n),
fun _ _ h ↦ (Subobject.map i).monotone (f.2 h)⟩
exact ⟨n, fun m hm ↦ Subobject.map_obj_injective i (hn m hm)⟩
instance : (isArtinianObject (C := C)).IsClosedUnderSubobjects where
prop_of_mono f _ hY := by
rw [← isArtinianObject.is_iff] at hY ⊢
exact isArtinianObject_of_mono f
open Subobject
variable [HasZeroMorphisms C] [HasZeroObject C]
theorem exists_simple_subobject {X : C} [IsArtinianObject X] (h : ¬IsZero X) :
∃ Y : Subobject X, Simple (Y : C) := by
have : Nontrivial (Subobject X) := nontrivial_of_not_isZero h
obtain ⟨Y, s⟩ := (IsAtomic.eq_bot_or_exists_atom_le (⊤ : Subobject X)).resolve_left top_ne_bot
exact ⟨Y, (subobject_simple_iff_isAtom _).mpr s.1⟩
/-- Choose an arbitrary simple subobject of a non-zero Artinian object. -/
noncomputable def simpleSubobject {X : C} [IsArtinianObject X] (h : ¬IsZero X) : C :=
(exists_simple_subobject h).choose
/-- The monomorphism from the arbitrary simple subobject of a non-zero Artinian object. -/
noncomputable def simpleSubobjectArrow {X : C} [IsArtinianObject X] (h : ¬IsZero X) :
simpleSubobject h ⟶ X :=
(exists_simple_subobject h).choose.arrow
instance mono_simpleSubobjectArrow {X : C} [IsArtinianObject X] (h : ¬IsZero X) :
Mono (simpleSubobjectArrow h) := by
dsimp only [simpleSubobjectArrow]
infer_instance
instance {X : C} [IsArtinianObject X] (h : ¬IsZero X) : Simple (simpleSubobject h) :=
(exists_simple_subobject h).choose_spec
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Subobject/NoetherianObject.lean | import Mathlib.CategoryTheory.Subobject.Lattice
import Mathlib.CategoryTheory.ObjectProperty.ContainsZero
import Mathlib.CategoryTheory.ObjectProperty.EpiMono
import Mathlib.CategoryTheory.Limits.Constructions.EventuallyConstant
import Mathlib.Order.OrderIsoNat
/-!
# Noetherian objects
We shall say that an object `X` in a category `C` is Noetherian
(type class `IsNoetherianObject X`) if the ordered type `Subobject X`
satisfies the ascending chain condition. The corresponding property of
objects `isNoetherianObject : ObjectProperty C` is always
closed under subobjects.
## Future works
* show that `isNoetherian` is a Serre class when `C` is an abelian category
(TODO @joelriou)
-/
universe v u
namespace CategoryTheory
open Limits ZeroObject
variable {C : Type u} [Category.{v} C]
/-- An object `X` in a category `C` is Noetherian if `Subobject X`
satisfies the ascending chain condition. This definition is a
term in `ObjectProperty C` which allows to study the stability
properties of Noetherian objects. For statements regarding
specific objects, it is advisable to use the type class
`IsNoetherianObject` instead. -/
@[stacks 0FCG]
def isNoetherianObject : ObjectProperty C :=
fun X ↦ WellFoundedGT (Subobject X)
variable (X Y : C)
/-- An object `X` in a category `C` is Noetherian if `Subobject X`
satisfies the ascending chain condition. -/
@[stacks 0FCG]
abbrev IsNoetherianObject : Prop := isNoetherianObject.Is X
instance [IsNoetherianObject X] : WellFoundedGT (Subobject X) :=
isNoetherianObject.prop_of_is X
lemma isNoetherianObject_iff_monotone_chain_condition :
IsNoetherianObject X ↔ ∀ (f : ℕ →o Subobject X),
∃ (n : ℕ), ∀ (m : ℕ), n ≤ m → f n = f m := by
dsimp only [IsNoetherianObject]
rw [ObjectProperty.is_iff, isNoetherianObject,
wellFoundedGT_iff_monotone_chain_condition]
variable {X} in
lemma monotone_chain_condition_of_isNoetherianObject
[IsNoetherianObject X] (f : ℕ →o Subobject X) :
∃ (n : ℕ), ∀ (m : ℕ), n ≤ m → f n = f m :=
(isNoetherianObject_iff_monotone_chain_condition X).1 inferInstance f
lemma isNoetherianObject_iff_not_strictMono :
IsNoetherianObject X ↔ ∀ (f : ℕ → Subobject X), ¬ StrictMono f := by
refine ⟨fun _ ↦ not_strictMono_of_wellFoundedGT, fun h ↦ ?_⟩
dsimp only [IsNoetherianObject]
rw [ObjectProperty.is_iff, isNoetherianObject, WellFoundedGT,
isWellFounded_iff, RelEmbedding.wellFounded_iff_isEmpty]
exact ⟨fun f ↦ h f.toFun (fun a b h ↦ f.map_rel_iff.2 h)⟩
variable {X} in
lemma not_strictMono_of_isNoetherianObject
[IsNoetherianObject X] (f : ℕ → Subobject X) :
¬ StrictMono f :=
(isNoetherianObject_iff_not_strictMono X).1 inferInstance f
lemma isNoetherianObject_iff_isEventuallyConstant :
IsNoetherianObject X ↔ ∀ (F : ℕ ⥤ MonoOver X),
IsFiltered.IsEventuallyConstant F := by
rw [isNoetherianObject_iff_monotone_chain_condition]
refine ⟨fun h G ↦ ?_, fun h F ↦ ?_⟩
· obtain ⟨n, hn⟩ := h (G ⋙ (Subobject.equivMonoOver _).inverse).toOrderHom
refine ⟨n, fun m hm ↦ ?_⟩
rw [MonoOver.isIso_iff_subobjectMk_eq]
exact hn m (leOfHom hm)
· obtain ⟨n, hn⟩ := h (F.monotone.functor ⋙ Subobject.representative)
refine ⟨n, fun m hm ↦ ?_⟩
simpa [← MonoOver.isIso_iff_isIso_left, isIso_iff_of_reflects_iso,
PartialOrder.isIso_iff_eq] using hn (homOfLE hm)
variable {X} in
lemma isEventuallyConstant_of_isNoetherianObject [IsNoetherianObject X]
(F : ℕ ⥤ MonoOver X) : IsFiltered.IsEventuallyConstant F :=
(isNoetherianObject_iff_isEventuallyConstant X).1 inferInstance F
variable {X Y}
lemma isNoetherianObject_of_isZero (hX : IsZero X) : IsNoetherianObject X := by
rw [isNoetherianObject_iff_monotone_chain_condition]
have := Subobject.subsingleton_of_isZero hX
intro f
exact ⟨0, fun m hm ↦ Subsingleton.elim _ _⟩
instance [HasZeroObject C] : (isNoetherianObject (C := C)).ContainsZero where
exists_zero := ⟨0, isZero_zero _, by
rw [← isNoetherianObject.is_iff]
exact isNoetherianObject_of_isZero (isZero_zero C)⟩
lemma isNoetherianObject_of_mono (i : X ⟶ Y) [Mono i] [IsNoetherianObject Y] :
IsNoetherianObject X := by
rw [isNoetherianObject_iff_monotone_chain_condition]
intro f
obtain ⟨n, hn⟩ := monotone_chain_condition_of_isNoetherianObject
⟨_, (Subobject.map i).monotone.comp f.2⟩
exact ⟨n, fun m hm ↦ Subobject.map_obj_injective i (hn m hm)⟩
instance : (isNoetherianObject (C := C)).IsClosedUnderSubobjects where
prop_of_mono f _ hY := by
rw [← isNoetherianObject.is_iff] at hY ⊢
exact isNoetherianObject_of_mono f
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Subobject/Presheaf.lean | import Mathlib.CategoryTheory.Subobject.Basic
import Mathlib.CategoryTheory.Limits.Shapes.Pullback.HasPullback
/-!
# Subobjects presheaf
Following Section I.3 of [Sheaves in Geometry and Logic][MM92], we define the subobjects presheaf
`Subobject.presheaf C` mapping any object `X` to its type of subobjects `Subobject X`.
## Main definitions
Let `C` refer to a category with pullbacks.
* `CategoryTheory.Subobject.presheaf C` is the presheaf that sends every object `X : C` to its type
of subobjects `Subobject X`, and every morphism `f : X ⟶ Y` to the function `Subobject Y →
Subobject X` that maps every subobject of `Y` to its pullback along `f`.
## References
* [S. MacLane and I. Moerdijk, *Sheaves in geometry and logic: A first introduction to topos
theory*][MM92]
## Tags
subobject, representable functor, presheaf, topos theory
-/
open CategoryTheory Subobject
namespace Subobject
universe u v
variable (C : Type u) [Category.{v} C] [Limits.HasPullbacks C]
/-- This is the presheaf that sends every object `X : C` to its type of subobjects `Subobject X`,
and every morphism `f : X ⟶ Y` to the function `Subobject Y → Subobject X` that maps every
subobject of `Y` to its pullback along `f`. -/
@[simps]
noncomputable def presheaf : Cᵒᵖ ⥤ Type max u v where
obj X := Subobject X.unop
map f := (pullback f.unop).obj
map_id _ := by ext : 1; simp [pullback_id]
map_comp _ _ := by ext : 1; simp [pullback_comp]
end Subobject |
.lake/packages/mathlib/Mathlib/CategoryTheory/Subobject/WellPowered.lean | import Mathlib.CategoryTheory.Subobject.Basic
import Mathlib.CategoryTheory.EssentiallySmall
/-!
# Well-powered categories
A category `(C : Type u) [Category.{v} C]` is `[WellPowered.{w} C]`
if `C` is locally small relative to `w` and for every `X : C`,
we have `Small.{w} (Subobject X)`. The most common cases if when `w = v`,
in which case, it only involves the condition `Small.{v} (Subobject X)`
(Note that in this situation `Subobject X : Type (max u v)`,
so this is a nontrivial condition for large categories,
but automatic for small categories.)
This is equivalent to the category `MonoOver X` being `EssentiallySmall.{w}` for all `X : C`.
When a category is well-powered, you can obtain nonconstructive witnesses as
`Shrink (Subobject X) : Type w`
and
`equivShrink (Subobject X) : Subobject X ≃ Shrink (subobject X)`.
-/
universe w v v₂ u₁ u₂
namespace CategoryTheory
variable (C : Type u₁) [Category.{v} C]
/--
A category (with morphisms in `Type v`) is well-powered relative to a universe `w`
if it is locally small and `Subobject X` is `w`-small for every `X`.
We show in `wellPowered_of_essentiallySmall_monoOver` and `essentiallySmall_monoOver`
that this is the case if and only if `MonoOver X` is `w`-essentially small for every `X`.
-/
@[pp_with_univ]
class WellPowered [LocallySmall.{w} C] : Prop where
subobject_small : ∀ X : C, Small.{w} (Subobject X) := by infer_instance
instance small_subobject [LocallySmall.{w} C] [WellPowered C] (X : C) :
Small.{w} (Subobject X) :=
WellPowered.subobject_small X
instance (priority := 100) wellPowered_of_smallCategory (C : Type u₁) [SmallCategory C] :
WellPowered.{u₁} C where
variable {C}
theorem essentiallySmall_monoOver_iff_small_subobject (X : C) :
EssentiallySmall.{w} (MonoOver X) ↔ Small.{w} (Subobject X) :=
essentiallySmall_iff_of_thin
theorem wellPowered_of_essentiallySmall_monoOver [LocallySmall.{w} C]
(h : ∀ X : C, EssentiallySmall.{w} (MonoOver X)) :
WellPowered.{w} C :=
{ subobject_small := fun X => (essentiallySmall_monoOver_iff_small_subobject X).mp (h X) }
section
variable [LocallySmall.{w} C] [WellPowered.{w} C]
instance essentiallySmall_monoOver (X : C) : EssentiallySmall.{w} (MonoOver X) :=
(essentiallySmall_monoOver_iff_small_subobject X).mpr (WellPowered.subobject_small X)
end
section Equivalence
variable {D : Type u₂} [Category.{v₂} D]
theorem wellPowered_of_equiv (e : C ≌ D) [LocallySmall.{w} C] [LocallySmall.{w} D]
[WellPowered.{w} C] : WellPowered.{w} D :=
wellPowered_of_essentiallySmall_monoOver fun X =>
(essentiallySmall_congr (MonoOver.congr X e.symm)).2 <| by infer_instance
/-- Being well-powered is preserved by equivalences. -/
theorem wellPowered_congr (e : C ≌ D) [LocallySmall.{w} C] [LocallySmall.{w} D] :
WellPowered.{w} C ↔ WellPowered.{w} D :=
⟨fun _ => wellPowered_of_equiv e, fun _ => wellPowered_of_equiv e.symm⟩
instance [LocallySmall.{w} C] [WellPowered.{w} C] :
WellPowered.{w, w} (ShrinkHoms C) :=
wellPowered_of_equiv.{w} (ShrinkHoms.equivalence.{w} C)
end Equivalence
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Subobject/Comma.lean | import Mathlib.CategoryTheory.Subobject.WellPowered
import Mathlib.CategoryTheory.Comma.LocallySmall
import Mathlib.CategoryTheory.Limits.Preserves.Finite
import Mathlib.CategoryTheory.Limits.Shapes.FiniteLimits
import Mathlib.CategoryTheory.Limits.Comma
/-!
# Subobjects in the category of structured arrows
We compute the subobjects of an object `A` in the category `StructuredArrow S T` for `T : C ⥤ D`
and `S : D` as a subtype of the subobjects of `A.right`. We deduce that `StructuredArrow S T` is
well-powered if `C` is.
## Main declarations
* `StructuredArrow.subobjectEquiv`: the order-equivalence between `Subobject A` and a subtype of
`Subobject A.right`.
## Implementation notes
Our computation requires that `C` has all limits and `T` preserves all limits. Furthermore, we
require that the morphisms of `C` and `D` are in the same universe. It is possible that both of
these requirements can be relaxed by refining the results about limits in comma categories.
We also provide the dual results. As usual, we use `Subobject (op A)` for the quotient objects of
`A`.
-/
noncomputable section
open CategoryTheory.Limits Opposite
universe w v₁ v₂ u₁ u₂
namespace CategoryTheory
variable {C : Type u₁} [Category.{v₁} C] {D : Type u₂} [Category.{v₂} D]
namespace StructuredArrow
variable {S : D} {T : C ⥤ D}
/-- Every subobject of a structured arrow can be projected to a subobject of the underlying
object. -/
def projectSubobject [HasFiniteLimits C] [PreservesFiniteLimits T] {A : StructuredArrow S T} :
Subobject A → Subobject A.right := by
refine Subobject.lift (fun P f hf => Subobject.mk f.right) ?_
intro P Q f g hf hg i hi
refine Subobject.mk_eq_mk_of_comm _ _ ((proj S T).mapIso i) ?_
exact congr_arg CommaMorphism.right hi
@[simp]
theorem projectSubobject_mk [HasFiniteLimits C] [PreservesFiniteLimits T]
{A P : StructuredArrow S T}
(f : P ⟶ A) [Mono f] : projectSubobject (Subobject.mk f) = Subobject.mk f.right :=
rfl
theorem projectSubobject_factors [HasFiniteLimits C] [PreservesFiniteLimits T]
{A : StructuredArrow S T} :
∀ P : Subobject A, ∃ q, q ≫ T.map (projectSubobject P).arrow = A.hom :=
Subobject.ind _ fun P f hf =>
⟨P.hom ≫ T.map (Subobject.underlyingIso _).inv, by simp [← T.map_comp]⟩
/-- A subobject of the underlying object of a structured arrow can be lifted to a subobject of
the structured arrow, provided that there is a morphism making the subobject into a structured
arrow. -/
@[simp]
def liftSubobject {A : StructuredArrow S T} (P : Subobject A.right) {q}
(hq : q ≫ T.map P.arrow = A.hom) : Subobject A :=
Subobject.mk (homMk P.arrow hq : mk q ⟶ A)
/-- Projecting and then lifting a subobject recovers the original subobject, because there is at
most one morphism making the projected subobject into a structured arrow. -/
theorem lift_projectSubobject [HasFiniteLimits C] [PreservesFiniteLimits T]
{A : StructuredArrow S T} :
∀ (P : Subobject A) {q} (hq : q ≫ T.map (projectSubobject P).arrow = A.hom),
liftSubobject (projectSubobject P) hq = P :=
Subobject.ind _
(by
intro P f hf q hq
fapply Subobject.mk_eq_mk_of_comm
· fapply isoMk
· exact Subobject.underlyingIso _
· exact (cancel_mono (T.map f.right)).1 (by dsimp; simpa [← T.map_comp] using hq)
· exact ext _ _ (by simp))
/-- If `A : S → T.obj B` is a structured arrow for `S : D` and `T : C ⥤ D`, then we can explicitly
describe the subobjects of `A` as the subobjects `P` of `B` in `C` for which `A.hom` factors
through the image of `P` under `T`. -/
def subobjectEquiv [HasFiniteLimits C] [PreservesFiniteLimits T] (A : StructuredArrow S T) :
Subobject A ≃o { P : Subobject A.right // ∃ q, q ≫ T.map P.arrow = A.hom } where
toFun P := ⟨projectSubobject P, projectSubobject_factors P⟩
invFun P := liftSubobject P.val P.prop.choose_spec
left_inv _ := lift_projectSubobject _ _
right_inv P := Subtype.ext (by simp only [liftSubobject, homMk_right, projectSubobject_mk,
Subobject.mk_arrow])
map_rel_iff' := by
apply Subobject.ind₂
intro P Q f g hf hg
refine ⟨fun h => Subobject.mk_le_mk_of_comm ?_ ?_, fun h => ?_⟩
· exact homMk (Subobject.ofMkLEMk _ _ h)
((cancel_mono (T.map g.right)).1 (by simp [← T.map_comp]))
· simp
· refine Subobject.mk_le_mk_of_comm (Subobject.ofMkLEMk _ _ h).right ?_
exact congr_arg CommaMorphism.right (Subobject.ofMkLEMk_comp h)
/-- If `C` is well-powered and complete and `T` preserves limits, then `StructuredArrow S T` is
well-powered. -/
instance wellPowered_structuredArrow [LocallySmall.{w} C]
[WellPowered.{w} C] [HasFiniteLimits C] [PreservesFiniteLimits T] :
WellPowered.{w} (StructuredArrow S T) where
subobject_small X := small_map (subobjectEquiv X).toEquiv
end StructuredArrow
namespace CostructuredArrow
variable {S : C ⥤ D} {T : D}
/-- Every quotient of a costructured arrow can be projected to a quotient of the underlying
object. -/
def projectQuotient [HasFiniteColimits C] [PreservesFiniteColimits S] {A : CostructuredArrow S T} :
Subobject (op A) → Subobject (op A.left) := by
refine Subobject.lift (fun P f hf => Subobject.mk f.unop.left.op) ?_
intro P Q f g hf hg i hi
refine Subobject.mk_eq_mk_of_comm _ _ ((proj S T).mapIso i.unop).op (Quiver.Hom.unop_inj ?_)
have := congr_arg Quiver.Hom.unop hi
simpa using congr_arg CommaMorphism.left this
@[simp]
theorem projectQuotient_mk [HasFiniteColimits C] [PreservesFiniteColimits S]
{A : CostructuredArrow S T}
{P : (CostructuredArrow S T)ᵒᵖ} (f : P ⟶ op A) [Mono f] :
projectQuotient (Subobject.mk f) = Subobject.mk f.unop.left.op :=
rfl
theorem projectQuotient_factors [HasFiniteColimits C] [PreservesFiniteColimits S]
{A : CostructuredArrow S T} :
∀ P : Subobject (op A), ∃ q, S.map (projectQuotient P).arrow.unop ≫ q = A.hom :=
Subobject.ind _ fun P f hf =>
⟨S.map (Subobject.underlyingIso _).unop.inv ≫ P.unop.hom, by
dsimp
rw [← Category.assoc, ← S.map_comp, ← unop_comp]
simp⟩
/-- A quotient of the underlying object of a costructured arrow can be lifted to a quotient of
the costructured arrow, provided that there is a morphism making the quotient into a
costructured arrow. -/
@[simp]
def liftQuotient {A : CostructuredArrow S T} (P : Subobject (op A.left)) {q}
(hq : S.map P.arrow.unop ≫ q = A.hom) : Subobject (op A) :=
Subobject.mk (homMk P.arrow.unop hq : A ⟶ mk q).op
/-- Technical lemma for `lift_projectQuotient`. -/
@[simp]
theorem unop_left_comp_underlyingIso_hom_unop {A : CostructuredArrow S T}
{P : (CostructuredArrow S T)ᵒᵖ} (f : P ⟶ op A) [Mono f.unop.left.op] :
f.unop.left ≫ (Subobject.underlyingIso f.unop.left.op).hom.unop =
(Subobject.mk f.unop.left.op).arrow.unop := by
conv_lhs =>
congr
rw [← Quiver.Hom.unop_op f.unop.left]
rw [← unop_comp, Subobject.underlyingIso_hom_comp_eq_mk]
/-- Projecting and then lifting a quotient recovers the original quotient, because there is at most
one morphism making the projected quotient into a costructured arrow. -/
theorem lift_projectQuotient [HasFiniteColimits C] [PreservesFiniteColimits S]
{A : CostructuredArrow S T} :
∀ (P : Subobject (op A)) {q} (hq : S.map (projectQuotient P).arrow.unop ≫ q = A.hom),
liftQuotient (projectQuotient P) hq = P :=
Subobject.ind _
(by
intro P f hf q hq
fapply Subobject.mk_eq_mk_of_comm
· refine (Iso.op (isoMk ?_ ?_) : _ ≅ op (unop P))
· exact (Subobject.underlyingIso f.unop.left.op).unop
· refine (cancel_epi (S.map f.unop.left)).1 ?_
simpa [← Category.assoc, ← S.map_comp] using hq
· exact Quiver.Hom.unop_inj (by simp))
/-- Technical lemma for `quotientEquiv`. -/
theorem unop_left_comp_ofMkLEMk_unop {A : CostructuredArrow S T} {P Q : (CostructuredArrow S T)ᵒᵖ}
{f : P ⟶ op A} {g : Q ⟶ op A} [Mono f.unop.left.op] [Mono g.unop.left.op]
(h : Subobject.mk f.unop.left.op ≤ Subobject.mk g.unop.left.op) :
g.unop.left ≫ (Subobject.ofMkLEMk f.unop.left.op g.unop.left.op h).unop = f.unop.left := by
conv_lhs =>
congr
rw [← Quiver.Hom.unop_op g.unop.left]
rw [← unop_comp]
simp only [Subobject.ofMkLEMk_comp, Quiver.Hom.unop_op]
/-- If `A : S.obj B ⟶ T` is a costructured arrow for `S : C ⥤ D` and `T : D`, then we can
explicitly describe the quotients of `A` as the quotients `P` of `B` in `C` for which `A.hom`
factors through the image of `P` under `S`. -/
def quotientEquiv [HasFiniteColimits C] [PreservesFiniteColimits S] (A : CostructuredArrow S T) :
Subobject (op A) ≃o { P : Subobject (op A.left) // ∃ q, S.map P.arrow.unop ≫ q = A.hom } where
toFun P := ⟨projectQuotient P, projectQuotient_factors P⟩
invFun P := liftQuotient P.val P.prop.choose_spec
left_inv _ := lift_projectQuotient _ _
right_inv P := Subtype.ext (by simp only [liftQuotient, Quiver.Hom.unop_op, homMk_left,
Quiver.Hom.op_unop, projectQuotient_mk, Subobject.mk_arrow])
map_rel_iff' := by
apply Subobject.ind₂
intro P Q f g hf hg
refine ⟨fun h => Subobject.mk_le_mk_of_comm ?_ ?_, fun h => ?_⟩
· refine (homMk (Subobject.ofMkLEMk _ _ h).unop ((cancel_epi (S.map g.unop.left)).1 ?_)).op
dsimp
simp only [← S.map_comp_assoc, unop_left_comp_ofMkLEMk_unop, unop_op, CommaMorphism.w,
Functor.const_obj_obj, right_eq_id, Functor.const_obj_map, Category.comp_id]
· apply Quiver.Hom.unop_inj
ext
exact unop_left_comp_ofMkLEMk_unop _
· refine Subobject.mk_le_mk_of_comm (Subobject.ofMkLEMk _ _ h).unop.left.op ?_
refine Quiver.Hom.unop_inj ?_
have := congr_arg Quiver.Hom.unop (Subobject.ofMkLEMk_comp h)
simpa only [unop_op, Functor.id_obj, Functor.const_obj_obj, MonoOver.mk'_obj, Over.mk_left,
MonoOver.mk'_arrow, unop_comp, Quiver.Hom.unop_op, comp_left]
using congr_arg CommaMorphism.left this
/-- If `C` is well-copowered and cocomplete and `S` preserves colimits, then
`CostructuredArrow S T` is well-copowered. -/
instance well_copowered_costructuredArrow [LocallySmall.{w} C] [WellPowered.{w} Cᵒᵖ]
[HasFiniteColimits C] [PreservesFiniteColimits S] :
WellPowered.{w} (CostructuredArrow S T)ᵒᵖ where
subobject_small X := small_map (quotientEquiv (unop X)).toEquiv
end CostructuredArrow
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Subobject/Basic.lean | import Mathlib.CategoryTheory.Limits.Skeleton
import Mathlib.CategoryTheory.Subobject.MonoOver
import Mathlib.CategoryTheory.Skeletal
import Mathlib.CategoryTheory.ConcreteCategory.Basic
import Mathlib.Tactic.ApplyFun
import Mathlib.Tactic.CategoryTheory.Elementwise
/-!
# Subobjects
We define `Subobject X` as the quotient (by isomorphisms) of
`MonoOver X := {f : Over X // Mono f.hom}`.
Here `MonoOver X` is a thin category (a pair of objects has at most one morphism between them),
so we can think of it as a preorder. However as it is not skeletal, it is not a partial order.
There is a coercion from `Subobject X` back to the ambient category `C`
(using choice to pick a representative), and for `P : Subobject X`,
`P.arrow : (P : C) ⟶ X` is the inclusion morphism.
We provide
* `def pullback [HasPullbacks C] (f : X ⟶ Y) : Subobject Y ⥤ Subobject X`
* `def map (f : X ⟶ Y) [Mono f] : Subobject X ⥤ Subobject Y`
* `def «exists_» [HasImages C] (f : X ⟶ Y) : Subobject X ⥤ Subobject Y`
and prove their basic properties and relationships.
These are all easy consequences of the earlier development
of the corresponding functors for `MonoOver`.
The subobjects of `X` form a preorder making them into a category. We have `X ≤ Y` if and only if
`X.arrow` factors through `Y.arrow`: see `ofLE`/`ofLEMk`/`ofMkLE`/`ofMkLEMk` and
`le_of_comm`. Similarly, to show that two subobjects are equal, we can supply an isomorphism between
the underlying objects that commutes with the arrows (`eq_of_comm`).
See also
* `CategoryTheory.Subobject.factorThru` :
an API describing factorization of morphisms through subobjects.
* `CategoryTheory.Subobject.lattice` :
the lattice structures on subobjects.
## Notes
This development originally appeared in Bhavik Mehta's "Topos theory for Lean" repository,
and was ported to mathlib by Kim Morrison.
### Implementation note
Currently we describe `pullback`, `map`, etc., as functors.
It may be better to just say that they are monotone functions,
and even avoid using categorical language entirely when describing `Subobject X`.
(It's worth keeping this in mind in future use; it should be a relatively easy change here
if it looks preferable.)
### Relation to pseudoelements
There is a separate development of pseudoelements in `CategoryTheory.Abelian.Pseudoelements`,
as a quotient (but not by isomorphism) of `Over X`.
When a morphism `f` has an image, the image represents the same pseudoelement.
In a category with images `Pseudoelements X` could be constructed as a quotient of `MonoOver X`.
In fact, in an abelian category (I'm not sure in what generality beyond that),
`Pseudoelements X` agrees with `Subobject X`, but we haven't developed this in mathlib yet.
-/
universe w' w v₁ v₂ v₃ u₁ u₂ u₃
noncomputable section
namespace CategoryTheory
open CategoryTheory CategoryTheory.Category CategoryTheory.Limits
variable {C : Type u₁} [Category.{v₁} C] {X Y Z : C}
variable {D : Type u₂} [Category.{v₂} D]
/-!
We now construct the subobject lattice for `X : C`,
as the quotient by isomorphisms of `MonoOver X`.
Since `MonoOver X` is a thin category, we use `ThinSkeleton` to take the quotient.
Essentially all the structure defined above on `MonoOver X` descends to `Subobject X`,
with morphisms becoming inequalities, and isomorphisms becoming equations.
-/
/-- The category of subobjects of `X : C`, defined as isomorphism classes of monomorphisms into `X`.
-/
def Subobject (X : C) :=
ThinSkeleton (MonoOver X)
instance (X : C) : PartialOrder (Subobject X) :=
inferInstanceAs <| PartialOrder (ThinSkeleton (MonoOver X))
namespace Subobject
/-- Convenience constructor for a subobject. -/
def mk {X A : C} (f : A ⟶ X) [Mono f] : Subobject X :=
(toThinSkeleton _).obj (MonoOver.mk' f)
section
attribute [local ext] CategoryTheory.Comma
protected theorem ind {X : C} (p : Subobject X → Prop)
(h : ∀ ⦃A : C⦄ (f : A ⟶ X) [Mono f], p (Subobject.mk f)) (P : Subobject X) : p P := by
apply Quotient.inductionOn'
intro a
exact h a.arrow
protected theorem ind₂ {X : C} (p : Subobject X → Subobject X → Prop)
(h : ∀ ⦃A B : C⦄ (f : A ⟶ X) (g : B ⟶ X) [Mono f] [Mono g],
p (Subobject.mk f) (Subobject.mk g))
(P Q : Subobject X) : p P Q := by
apply Quotient.inductionOn₂'
intro a b
exact h a.arrow b.arrow
end
/-- Declare a function on subobjects of `X` by specifying a function on monomorphisms with
codomain `X`. -/
protected def lift {α : Sort*} {X : C} (F : ∀ ⦃A : C⦄ (f : A ⟶ X) [Mono f], α)
(h :
∀ ⦃A B : C⦄ (f : A ⟶ X) (g : B ⟶ X) [Mono f] [Mono g] (i : A ≅ B),
i.hom ≫ g = f → F f = F g) :
Subobject X → α := fun P =>
Quotient.liftOn' P (fun m => F m.arrow) fun m n ⟨i⟩ =>
h m.arrow n.arrow ((MonoOver.forget X ⋙ Over.forget X).mapIso i) (Over.w i.hom)
@[simp]
protected theorem lift_mk {α : Sort*} {X : C} (F : ∀ ⦃A : C⦄ (f : A ⟶ X) [Mono f], α) {h A}
(f : A ⟶ X) [Mono f] : Subobject.lift F h (Subobject.mk f) = F f :=
rfl
/-- The category of subobjects is equivalent to the `MonoOver` category. It is more convenient to
use the former due to the partial order instance, but oftentimes it is easier to define structures
on the latter. -/
noncomputable def equivMonoOver (X : C) : Subobject X ≌ MonoOver X :=
ThinSkeleton.equivalence _
/-- Use choice to pick a representative `MonoOver X` for each `Subobject X`.
-/
noncomputable def representative {X : C} : Subobject X ⥤ MonoOver X :=
(equivMonoOver X).functor
instance : (representative (X := X)).IsEquivalence :=
(equivMonoOver X).isEquivalence_functor
/-- Starting with `A : MonoOver X`, we can take its equivalence class in `Subobject X`
then pick an arbitrary representative using `representative.obj`.
This is isomorphic (in `MonoOver X`) to the original `A`.
-/
noncomputable def representativeIso {X : C} (A : MonoOver X) :
representative.obj ((toThinSkeleton _).obj A) ≅ A :=
(equivMonoOver X).counitIso.app A
/-- Use choice to pick a representative underlying object in `C` for any `Subobject X`.
Prefer to use the coercion `P : C` rather than explicitly writing `underlying.obj P`.
-/
noncomputable def underlying {X : C} : Subobject X ⥤ C :=
representative ⋙ MonoOver.forget _ ⋙ Over.forget _
instance : CoeOut (Subobject X) C where coe Y := underlying.obj Y
/-- If we construct a `Subobject Y` from an explicit `f : X ⟶ Y` with `[Mono f]`,
then pick an arbitrary choice of underlying object `(Subobject.mk f : C)` back in `C`,
it is isomorphic (in `C`) to the original `X`.
-/
noncomputable def underlyingIso {X Y : C} (f : X ⟶ Y) [Mono f] : (Subobject.mk f : C) ≅ X :=
(MonoOver.forget _ ⋙ Over.forget _).mapIso (representativeIso (MonoOver.mk' f))
/-- The morphism in `C` from the arbitrarily chosen underlying object to the ambient object.
-/
noncomputable def arrow {X : C} (Y : Subobject X) : (Y : C) ⟶ X :=
(representative.obj Y).obj.hom
instance arrow_mono {X : C} (Y : Subobject X) : Mono Y.arrow :=
(representative.obj Y).property
@[simp]
theorem arrow_congr {A : C} (X Y : Subobject A) (h : X = Y) :
eqToHom (congr_arg (fun X : Subobject A => (X : C)) h) ≫ Y.arrow = X.arrow := by
induction h
simp
@[simp]
theorem representative_coe (Y : Subobject X) : (representative.obj Y : C) = (Y : C) :=
rfl
@[simp]
theorem representative_arrow (Y : Subobject X) : (representative.obj Y).arrow = Y.arrow :=
rfl
@[reassoc (attr := simp)]
theorem underlying_arrow {X : C} {Y Z : Subobject X} (f : Y ⟶ Z) :
underlying.map f ≫ arrow Z = arrow Y :=
Over.w (representative.map f)
@[reassoc (attr := simp), elementwise (attr := simp)]
theorem underlyingIso_arrow {X Y : C} (f : X ⟶ Y) [Mono f] :
(underlyingIso f).inv ≫ (Subobject.mk f).arrow = f :=
Over.w _
@[reassoc (attr := simp)]
theorem underlyingIso_hom_comp_eq_mk {X Y : C} (f : X ⟶ Y) [Mono f] :
(underlyingIso f).hom ≫ f = (mk f).arrow :=
(Iso.eq_inv_comp _).1 (underlyingIso_arrow f).symm
/-- Two morphisms into a subobject are equal exactly if
the morphisms into the ambient object are equal -/
@[ext]
theorem eq_of_comp_arrow_eq {X Y : C} {P : Subobject Y} {f g : X ⟶ P}
(h : f ≫ P.arrow = g ≫ P.arrow) : f = g :=
(cancel_mono P.arrow).mp h
theorem mk_le_mk_of_comm {B A₁ A₂ : C} {f₁ : A₁ ⟶ B} {f₂ : A₂ ⟶ B} [Mono f₁] [Mono f₂] (g : A₁ ⟶ A₂)
(w : g ≫ f₂ = f₁) : mk f₁ ≤ mk f₂ :=
⟨MonoOver.homMk _ w⟩
@[simp]
theorem mk_arrow (P : Subobject X) : mk P.arrow = P :=
Quotient.inductionOn' P fun Q => by
obtain ⟨e⟩ := @Quotient.mk_out' _ (isIsomorphicSetoid _) Q
exact Quotient.sound' ⟨MonoOver.isoMk (Iso.refl _) ≪≫ e⟩
theorem le_of_comm {B : C} {X Y : Subobject B} (f : (X : C) ⟶ (Y : C)) (w : f ≫ Y.arrow = X.arrow) :
X ≤ Y := by
convert mk_le_mk_of_comm _ w <;> simp
theorem le_mk_of_comm {B A : C} {X : Subobject B} {f : A ⟶ B} [Mono f] (g : (X : C) ⟶ A)
(w : g ≫ f = X.arrow) : X ≤ mk f :=
le_of_comm (g ≫ (underlyingIso f).inv) <| by simp [w]
theorem mk_le_of_comm {B A : C} {X : Subobject B} {f : A ⟶ B} [Mono f] (g : A ⟶ (X : C))
(w : g ≫ X.arrow = f) : mk f ≤ X :=
le_of_comm ((underlyingIso f).hom ≫ g) <| by simp [w]
/-- To show that two subobjects are equal, it suffices to exhibit an isomorphism commuting with
the arrows. -/
@[ext (iff := false)]
theorem eq_of_comm {B : C} {X Y : Subobject B} (f : (X : C) ≅ (Y : C))
(w : f.hom ≫ Y.arrow = X.arrow) : X = Y :=
le_antisymm (le_of_comm f.hom w) <| le_of_comm f.inv <| f.inv_comp_eq.2 w.symm
/-- To show that two subobjects are equal, it suffices to exhibit an isomorphism commuting with
the arrows. -/
theorem eq_mk_of_comm {B A : C} {X : Subobject B} (f : A ⟶ B) [Mono f] (i : (X : C) ≅ A)
(w : i.hom ≫ f = X.arrow) : X = mk f :=
eq_of_comm (i.trans (underlyingIso f).symm) <| by simp [w]
/-- To show that two subobjects are equal, it suffices to exhibit an isomorphism commuting with
the arrows. -/
theorem mk_eq_of_comm {B A : C} {X : Subobject B} (f : A ⟶ B) [Mono f] (i : A ≅ (X : C))
(w : i.hom ≫ X.arrow = f) : mk f = X :=
Eq.symm <| eq_mk_of_comm _ i.symm <| by rw [Iso.symm_hom, Iso.inv_comp_eq, w]
/-- To show that two subobjects are equal, it suffices to exhibit an isomorphism commuting with
the arrows. -/
theorem mk_eq_mk_of_comm {B A₁ A₂ : C} (f : A₁ ⟶ B) (g : A₂ ⟶ B) [Mono f] [Mono g] (i : A₁ ≅ A₂)
(w : i.hom ≫ g = f) : mk f = mk g :=
eq_mk_of_comm _ ((underlyingIso f).trans i) <| by simp [w]
lemma mk_surjective {X : C} (S : Subobject X) :
∃ (A : C) (i : A ⟶ X) (_ : Mono i), S = Subobject.mk i :=
⟨_, S.arrow, inferInstance, by simp⟩
-- We make `X` and `Y` explicit arguments here so that when `ofLE` appears in goal statements
-- it is possible to see its source and target
-- (`h` will just display as `_`, because it is in `Prop`).
/-- An inequality of subobjects is witnessed by some morphism between the corresponding objects. -/
def ofLE {B : C} (X Y : Subobject B) (h : X ≤ Y) : (X : C) ⟶ (Y : C) :=
underlying.map <| h.hom
@[reassoc (attr := simp)]
theorem ofLE_arrow {B : C} {X Y : Subobject B} (h : X ≤ Y) : ofLE X Y h ≫ Y.arrow = X.arrow :=
underlying_arrow _
instance {B : C} (X Y : Subobject B) (h : X ≤ Y) : Mono (ofLE X Y h) := by
fconstructor
intro Z f g w
replace w := w =≫ Y.arrow
ext
simpa using w
theorem ofLE_mk_le_mk_of_comm {B A₁ A₂ : C} {f₁ : A₁ ⟶ B} {f₂ : A₂ ⟶ B} [Mono f₁] [Mono f₂]
(g : A₁ ⟶ A₂) (w : g ≫ f₂ = f₁) :
ofLE _ _ (mk_le_mk_of_comm g w) = (underlyingIso _).hom ≫ g ≫ (underlyingIso _).inv := by
ext
simp [w]
/-- An inequality of subobjects is witnessed by some morphism between the corresponding objects. -/
def ofLEMk {B A : C} (X : Subobject B) (f : A ⟶ B) [Mono f] (h : X ≤ mk f) : (X : C) ⟶ A :=
ofLE X (mk f) h ≫ (underlyingIso f).hom
instance {B A : C} (X : Subobject B) (f : A ⟶ B) [Mono f] (h : X ≤ mk f) :
Mono (ofLEMk X f h) := by
dsimp only [ofLEMk]
infer_instance
@[simp]
theorem ofLEMk_comp {B A : C} {X : Subobject B} {f : A ⟶ B} [Mono f] (h : X ≤ mk f) :
ofLEMk X f h ≫ f = X.arrow := by simp [ofLEMk]
/-- An inequality of subobjects is witnessed by some morphism between the corresponding objects. -/
def ofMkLE {B A : C} (f : A ⟶ B) [Mono f] (X : Subobject B) (h : mk f ≤ X) : A ⟶ (X : C) :=
(underlyingIso f).inv ≫ ofLE (mk f) X h
instance {B A : C} (f : A ⟶ B) [Mono f] (X : Subobject B) (h : mk f ≤ X) :
Mono (ofMkLE f X h) := by
dsimp only [ofMkLE]
infer_instance
@[simp]
theorem ofMkLE_arrow {B A : C} {f : A ⟶ B} [Mono f] {X : Subobject B} (h : mk f ≤ X) :
ofMkLE f X h ≫ X.arrow = f := by simp [ofMkLE]
/-- An inequality of subobjects is witnessed by some morphism between the corresponding objects. -/
def ofMkLEMk {B A₁ A₂ : C} (f : A₁ ⟶ B) (g : A₂ ⟶ B) [Mono f] [Mono g] (h : mk f ≤ mk g) :
A₁ ⟶ A₂ :=
(underlyingIso f).inv ≫ ofLE (mk f) (mk g) h ≫ (underlyingIso g).hom
instance {B A₁ A₂ : C} (f : A₁ ⟶ B) (g : A₂ ⟶ B) [Mono f] [Mono g] (h : mk f ≤ mk g) :
Mono (ofMkLEMk f g h) := by
dsimp only [ofMkLEMk]
infer_instance
@[simp]
theorem ofMkLEMk_comp {B A₁ A₂ : C} {f : A₁ ⟶ B} {g : A₂ ⟶ B} [Mono f] [Mono g] (h : mk f ≤ mk g) :
ofMkLEMk f g h ≫ g = f := by simp [ofMkLEMk]
@[reassoc (attr := simp)]
theorem ofLE_comp_ofLE {B : C} (X Y Z : Subobject B) (h₁ : X ≤ Y) (h₂ : Y ≤ Z) :
ofLE X Y h₁ ≫ ofLE Y Z h₂ = ofLE X Z (h₁.trans h₂) := by
simp only [ofLE, ← Functor.map_comp underlying]
congr 1
@[reassoc (attr := simp)]
theorem ofLE_comp_ofLEMk {B A : C} (X Y : Subobject B) (f : A ⟶ B) [Mono f] (h₁ : X ≤ Y)
(h₂ : Y ≤ mk f) : ofLE X Y h₁ ≫ ofLEMk Y f h₂ = ofLEMk X f (h₁.trans h₂) := by
simp only [ofLEMk, ofLE, ← Functor.map_comp_assoc underlying]
congr 1
@[reassoc (attr := simp)]
theorem ofLEMk_comp_ofMkLE {B A : C} (X : Subobject B) (f : A ⟶ B) [Mono f] (Y : Subobject B)
(h₁ : X ≤ mk f) (h₂ : mk f ≤ Y) : ofLEMk X f h₁ ≫ ofMkLE f Y h₂ = ofLE X Y (h₁.trans h₂) := by
simp only [ofMkLE, ofLEMk, ofLE, ← Functor.map_comp underlying, assoc, Iso.hom_inv_id_assoc]
congr 1
@[reassoc (attr := simp)]
theorem ofLEMk_comp_ofMkLEMk {B A₁ A₂ : C} (X : Subobject B) (f : A₁ ⟶ B) [Mono f] (g : A₂ ⟶ B)
[Mono g] (h₁ : X ≤ mk f) (h₂ : mk f ≤ mk g) :
ofLEMk X f h₁ ≫ ofMkLEMk f g h₂ = ofLEMk X g (h₁.trans h₂) := by
simp only [ofLEMk, ofLE, ofMkLEMk, ← Functor.map_comp_assoc underlying,
assoc, Iso.hom_inv_id_assoc]
congr 1
@[reassoc (attr := simp)]
theorem ofMkLE_comp_ofLE {B A₁ : C} (f : A₁ ⟶ B) [Mono f] (X Y : Subobject B) (h₁ : mk f ≤ X)
(h₂ : X ≤ Y) : ofMkLE f X h₁ ≫ ofLE X Y h₂ = ofMkLE f Y (h₁.trans h₂) := by
simp only [ofMkLE, ofLE, ← Functor.map_comp underlying,
assoc]
congr 1
@[reassoc (attr := simp)]
theorem ofMkLE_comp_ofLEMk {B A₁ A₂ : C} (f : A₁ ⟶ B) [Mono f] (X : Subobject B) (g : A₂ ⟶ B)
[Mono g] (h₁ : mk f ≤ X) (h₂ : X ≤ mk g) :
ofMkLE f X h₁ ≫ ofLEMk X g h₂ = ofMkLEMk f g (h₁.trans h₂) := by
simp only [ofMkLE, ofLEMk, ofLE, ofMkLEMk, ← Functor.map_comp_assoc underlying, assoc]
congr 1
@[reassoc (attr := simp)]
theorem ofMkLEMk_comp_ofMkLE {B A₁ A₂ : C} (f : A₁ ⟶ B) [Mono f] (g : A₂ ⟶ B) [Mono g]
(X : Subobject B) (h₁ : mk f ≤ mk g) (h₂ : mk g ≤ X) :
ofMkLEMk f g h₁ ≫ ofMkLE g X h₂ = ofMkLE f X (h₁.trans h₂) := by
simp only [ofMkLE, ofLE, ofMkLEMk, ← Functor.map_comp underlying,
assoc, Iso.hom_inv_id_assoc]
congr 1
@[reassoc (attr := simp)]
theorem ofMkLEMk_comp_ofMkLEMk {B A₁ A₂ A₃ : C} (f : A₁ ⟶ B) [Mono f] (g : A₂ ⟶ B) [Mono g]
(h : A₃ ⟶ B) [Mono h] (h₁ : mk f ≤ mk g) (h₂ : mk g ≤ mk h) :
ofMkLEMk f g h₁ ≫ ofMkLEMk g h h₂ = ofMkLEMk f h (h₁.trans h₂) := by
simp only [ofLE, ofMkLEMk, ← Functor.map_comp_assoc underlying, assoc,
Iso.hom_inv_id_assoc]
congr 1
@[simp]
theorem ofLE_refl {B : C} (X : Subobject B) : ofLE X X le_rfl = 𝟙 _ := by
apply (cancel_mono X.arrow).mp
simp
@[simp]
theorem ofMkLEMk_refl {B A₁ : C} (f : A₁ ⟶ B) [Mono f] : ofMkLEMk f f le_rfl = 𝟙 _ := by
apply (cancel_mono f).mp
simp
-- As with `ofLE`, we have `X` and `Y` as explicit arguments for readability.
/-- An equality of subobjects gives an isomorphism of the corresponding objects.
(One could use `underlying.mapIso (eqToIso h))` here, but this is more readable.) -/
@[simps]
def isoOfEq {B : C} (X Y : Subobject B) (h : X = Y) : (X : C) ≅ (Y : C) where
hom := ofLE _ _ h.le
inv := ofLE _ _ h.ge
/-- An equality of subobjects gives an isomorphism of the corresponding objects. -/
@[simps]
def isoOfEqMk {B A : C} (X : Subobject B) (f : A ⟶ B) [Mono f] (h : X = mk f) : (X : C) ≅ A where
hom := ofLEMk X f h.le
inv := ofMkLE f X h.ge
/-- An equality of subobjects gives an isomorphism of the corresponding objects. -/
@[simps]
def isoOfMkEq {B A : C} (f : A ⟶ B) [Mono f] (X : Subobject B) (h : mk f = X) : A ≅ (X : C) where
hom := ofMkLE f X h.le
inv := ofLEMk X f h.ge
/-- An equality of subobjects gives an isomorphism of the corresponding objects. -/
@[simps]
def isoOfMkEqMk {B A₁ A₂ : C} (f : A₁ ⟶ B) (g : A₂ ⟶ B) [Mono f] [Mono g] (h : mk f = mk g) :
A₁ ≅ A₂ where
hom := ofMkLEMk f g h.le
inv := ofMkLEMk g f h.ge
lemma mk_lt_mk_of_comm {X A₁ A₂ : C} {i₁ : A₁ ⟶ X} {i₂ : A₂ ⟶ X} [Mono i₁] [Mono i₂]
(f : A₁ ⟶ A₂) (fac : f ≫ i₂ = i₁) (hf : ¬ IsIso f) :
Subobject.mk i₁ < Subobject.mk i₂ := by
obtain _ | h := (mk_le_mk_of_comm _ fac).lt_or_eq
· assumption
· exfalso
apply hf
convert (isoOfMkEqMk i₁ i₂ h).isIso_hom
rw [← cancel_mono i₂, isoOfMkEqMk_hom, ofMkLEMk_comp, fac]
lemma mk_lt_mk_iff_of_comm {X A₁ A₂ : C} {i₁ : A₁ ⟶ X} {i₂ : A₂ ⟶ X} [Mono i₁] [Mono i₂]
(f : A₁ ⟶ A₂) (fac : f ≫ i₂ = i₁) :
Subobject.mk i₁ < Subobject.mk i₂ ↔ ¬ IsIso f :=
⟨fun h hf ↦ by simp only [mk_eq_mk_of_comm i₁ i₂ (asIso f) fac, lt_self_iff_false] at h,
mk_lt_mk_of_comm f fac⟩
end Subobject
namespace MonoOver
variable {P Q : MonoOver X} (f : P ⟶ Q)
include f in
lemma subobjectMk_le_mk_of_hom :
Subobject.mk P.obj.hom ≤ Subobject.mk Q.obj.hom :=
Subobject.mk_le_mk_of_comm f.left (by simp)
lemma isIso_left_iff_subobjectMk_eq :
IsIso f.left ↔ Subobject.mk P.1.hom = Subobject.mk Q.1.hom :=
⟨fun _ ↦ Subobject.mk_eq_mk_of_comm _ _ (asIso f.left) (by simp),
fun h ↦ ⟨Subobject.ofMkLEMk _ _ h.symm.le, by simp [← cancel_mono P.1.hom],
by simp [← cancel_mono Q.1.hom]⟩⟩
lemma isIso_iff_subobjectMk_eq :
IsIso f ↔ Subobject.mk P.1.hom = Subobject.mk Q.1.hom := by
rw [isIso_iff_isIso_left, isIso_left_iff_subobjectMk_eq]
end MonoOver
open CategoryTheory.Limits
namespace Subobject
/-- Any functor `MonoOver X ⥤ MonoOver Y` descends to a functor
`Subobject X ⥤ Subobject Y`, because `MonoOver Y` is thin. -/
def lower {Y : D} (F : MonoOver X ⥤ MonoOver Y) : Subobject X ⥤ Subobject Y :=
ThinSkeleton.map F
/-- Isomorphic functors become equal when lowered to `Subobject`.
(It's not as evil as usual to talk about equality between functors
because the categories are thin and skeletal.) -/
theorem lower_iso (F₁ F₂ : MonoOver X ⥤ MonoOver Y) (h : F₁ ≅ F₂) : lower F₁ = lower F₂ :=
ThinSkeleton.map_iso_eq h
/-- A ternary version of `Subobject.lower`. -/
def lower₂ (F : MonoOver X ⥤ MonoOver Y ⥤ MonoOver Z) : Subobject X ⥤ Subobject Y ⥤ Subobject Z :=
ThinSkeleton.map₂ F
@[simp]
theorem lower_comm (F : MonoOver Y ⥤ MonoOver X) :
toThinSkeleton _ ⋙ lower F = F ⋙ toThinSkeleton _ :=
rfl
/--
Applying `lower F` and then `representative` is isomorphic to first applying `representative`
and then applying `F`.
-/
def lowerCompRepresentativeIso (F : MonoOver Y ⥤ MonoOver X) :
lower F ⋙ representative ≅ representative ⋙ F :=
ThinSkeleton.mapCompFromThinSkeletonIso _
/-- An adjunction between `MonoOver A` and `MonoOver B` gives an adjunction
between `Subobject A` and `Subobject B`. -/
def lowerAdjunction {A : C} {B : D} {L : MonoOver A ⥤ MonoOver B} {R : MonoOver B ⥤ MonoOver A}
(h : L ⊣ R) : lower L ⊣ lower R :=
ThinSkeleton.lowerAdjunction _ _ h
/-- An equivalence between `MonoOver A` and `MonoOver B` gives an equivalence
between `Subobject A` and `Subobject B`. -/
@[simps]
def lowerEquivalence {A : C} {B : D} (e : MonoOver A ≌ MonoOver B) : Subobject A ≌ Subobject B where
functor := lower e.functor
inverse := lower e.inverse
unitIso := by
apply eqToIso
convert ThinSkeleton.map_iso_eq e.unitIso
· exact ThinSkeleton.map_id_eq.symm
· exact (ThinSkeleton.map_comp_eq _ _).symm
counitIso := by
apply eqToIso
convert ThinSkeleton.map_iso_eq e.counitIso
· exact (ThinSkeleton.map_comp_eq _ _).symm
· exact ThinSkeleton.map_id_eq.symm
section Limits
variable {J : Type u₃} [Category.{v₃} J]
instance hasLimitsOfShape [HasLimitsOfShape J (Over X)] :
HasLimitsOfShape J (Subobject X) := by
apply hasLimitsOfShape_thinSkeleton
instance hasFiniteLimits [HasFiniteLimits (Over X)] : HasFiniteLimits (Subobject X) where
out _ _ _ := by infer_instance
instance hasLimitsOfSize [HasLimitsOfSize.{w, w'} (Over X)] :
HasLimitsOfSize.{w, w'} (Subobject X) where
has_limits_of_shape _ _ := by infer_instance
end Limits
section Colimits
variable [HasCoproducts C] [HasStrongEpiMonoFactorisations C]
instance hasColimitsOfSize : HasColimitsOfSize.{w, w'} (Subobject X) := by
apply hasColimitsOfSize_thinSkeleton
end Colimits
section Pullback
variable [HasPullbacks C]
/-- When `C` has pullbacks, a morphism `f : X ⟶ Y` induces a functor `Subobject Y ⥤ Subobject X`,
by pulling back a monomorphism along `f`. -/
def pullback (f : X ⟶ Y) : Subobject Y ⥤ Subobject X :=
lower (MonoOver.pullback f)
theorem pullback_id (x : Subobject X) : (pullback (𝟙 X)).obj x = x := by
induction x using Quotient.inductionOn' with | _ f
exact Quotient.sound ⟨MonoOver.pullbackId.app f⟩
theorem pullback_comp (f : X ⟶ Y) (g : Y ⟶ Z) (x : Subobject Z) :
(pullback (f ≫ g)).obj x = (pullback f).obj ((pullback g).obj x) := by
induction x using Quotient.inductionOn' with | _ t
exact Quotient.sound ⟨(MonoOver.pullbackComp _ _).app t⟩
theorem pullback_obj_mk {A B X Y : C} {f : Y ⟶ X} {i : A ⟶ X} [Mono i]
{j : B ⟶ Y} [Mono j] {f' : B ⟶ A}
(h : IsPullback f' j i f) :
(pullback f).obj (mk i) = mk j :=
((equivMonoOver Y).inverse.mapIso
(MonoOver.pullbackObjIsoOfIsPullback _ _ _ _ h)).to_eq
theorem pullback_obj {X Y : C} (f : Y ⟶ X) (x : Subobject X) :
(pullback f).obj x = mk (pullback.snd x.arrow f) := by
obtain ⟨Z, i, _, rfl⟩ := mk_surjective x
rw [pullback_obj_mk (IsPullback.of_hasPullback i f)]
exact mk_eq_mk_of_comm _ _ (asIso (pullback.map i f (mk i).arrow f
(underlyingIso i).inv (𝟙 _) (𝟙 _) (by simp) (by simp))) (by simp)
instance (f : X ⟶ Y) : (pullback f).Faithful where
lemma isPullback_aux (f : X ⟶ Y) (y : Subobject Y) :
∃ φ, IsPullback φ ((pullback f).obj y).arrow y.arrow f := by
obtain ⟨A, i, ⟨_, rfl⟩⟩ := mk_surjective y
rw [pullback_obj]
exists (underlyingIso (pullback.snd (mk i).arrow f)).hom ≫ pullback.fst (mk i).arrow f
exact IsPullback.of_iso (IsPullback.of_hasPullback (mk i).arrow f)
(underlyingIso (pullback.snd (mk i).arrow f)).symm (Iso.refl _) (Iso.refl _) (Iso.refl _)
(by simp) (by simp) (by simp) (by simp)
/-- For any morphism `f : X ⟶ Y` and subobject `y` of `Y`, `Subobject.pullbackπ f y` is the first
projection in the following pullback square:
```
(Subobject.pullback f).obj y ----pullbackπ f y---> (y : C)
| |
((Subobject.pullback f).obj y).arrow y.arrow
| |
v v
X ---------------------f-------------------> Y
```
For instance in the category of sets, `Subobject.pullbackπ f y` is the restriction of `f` to
elements of `X` that are in the preimage of `y ⊆ Y`.
-/
noncomputable def pullbackπ (f : X ⟶ Y) (y : Subobject Y) :
((Subobject.pullback f).obj y : C) ⟶ (y : C) :=
(isPullback_aux f y).choose
/-- This states that `pullbackπ f y` indeed forms a pullback square (see `Subobject.pullbackπ`). -/
theorem isPullback (f : X ⟶ Y) (y : Subobject Y) :
IsPullback (pullbackπ f y) ((pullback f).obj y).arrow y.arrow f :=
(isPullback_aux f y).choose_spec
end Pullback
section Map
/-- We can map subobjects of `X` to subobjects of `Y`
by post-composition with a monomorphism `f : X ⟶ Y`.
-/
def map (f : X ⟶ Y) [Mono f] : Subobject X ⥤ Subobject Y :=
lower (MonoOver.map f)
lemma map_mk {A X Y : C} (i : A ⟶ X) [Mono i] (f : X ⟶ Y) [Mono f] :
(map f).obj (mk i) = mk (i ≫ f) :=
rfl
theorem map_id (x : Subobject X) : (map (𝟙 X)).obj x = x := by
induction x using Quotient.inductionOn' with | _ f
exact Quotient.sound ⟨(MonoOver.mapId _).app f⟩
theorem map_comp (f : X ⟶ Y) (g : Y ⟶ Z) [Mono f] [Mono g] (x : Subobject X) :
(map (f ≫ g)).obj x = (map g).obj ((map f).obj x) := by
induction x using Quotient.inductionOn' with | _ t
exact Quotient.sound ⟨(MonoOver.mapComp _ _).app t⟩
lemma map_obj_injective {X Y : C} (f : X ⟶ Y) [Mono f] :
Function.Injective (Subobject.map f).obj := fun X₁ X₂ h ↦ by
induction X₁ using Subobject.ind
induction X₂ using Subobject.ind
simp only [map_mk] at h
exact mk_eq_mk_of_comm _ _ (isoOfMkEqMk _ _ h) (by simp [← cancel_mono f])
/-- Isomorphic objects have equivalent subobject lattices. -/
def mapIso {A B : C} (e : A ≅ B) : Subobject A ≌ Subobject B :=
lowerEquivalence (MonoOver.mapIso e)
/-- In fact, there's a type level bijection between the subobjects of isomorphic objects,
which preserves the order. -/
@[simps]
def mapIsoToOrderIso (e : X ≅ Y) : Subobject X ≃o Subobject Y where
toFun := (map e.hom).obj
invFun := (map e.inv).obj
left_inv g := by simp_rw [← map_comp, e.hom_inv_id, map_id]
right_inv g := by simp_rw [← map_comp, e.inv_hom_id, map_id]
map_rel_iff' {A B} := by
dsimp
constructor
· intro h
apply_fun (map e.inv).obj at h
· simpa only [← map_comp, e.hom_inv_id, map_id] using h
· apply Functor.monotone
· intro h
apply_fun (map e.hom).obj at h
· exact h
· apply Functor.monotone
/-- `map f : Subobject X ⥤ Subobject Y` is
the left adjoint of `pullback f : Subobject Y ⥤ Subobject X`. -/
def mapPullbackAdj [HasPullbacks C] (f : X ⟶ Y) [Mono f] : map f ⊣ pullback f :=
lowerAdjunction (MonoOver.mapPullbackAdj f)
@[simp]
theorem pullback_map_self [HasPullbacks C] (f : X ⟶ Y) [Mono f] (g : Subobject X) :
(pullback f).obj ((map f).obj g) = g := by
revert g
exact Quotient.ind (fun g' => Quotient.sound ⟨(MonoOver.pullbackMapSelf f).app _⟩)
theorem map_pullback [HasPullbacks C] {X Y Z W : C} {f : X ⟶ Y} {g : X ⟶ Z} {h : Y ⟶ W} {k : Z ⟶ W}
[Mono h] [Mono g] (comm : f ≫ h = g ≫ k) (t : IsLimit (PullbackCone.mk f g comm))
(p : Subobject Y) : (map g).obj ((pullback f).obj p) = (pullback k).obj ((map h).obj p) := by
revert p
apply Quotient.ind'
intro a
apply Quotient.sound
apply ThinSkeleton.equiv_of_both_ways
· refine MonoOver.homMk (pullback.lift (pullback.fst _ _) _ ?_) (pullback.lift_snd _ _ _)
change _ ≫ a.arrow ≫ h = (pullback.snd _ _ ≫ g) ≫ _
rw [assoc, ← comm, pullback.condition_assoc]
· refine MonoOver.homMk (pullback.lift (pullback.fst _ _)
(PullbackCone.IsLimit.lift t (pullback.fst _ _ ≫ a.arrow) (pullback.snd _ _) _)
(PullbackCone.IsLimit.lift_fst _ _ _ ?_).symm) ?_
· rw [← pullback.condition, assoc]
rfl
· dsimp
rw [pullback.lift_snd_assoc]
apply PullbackCone.IsLimit.lift_snd
end Map
section Exists
variable [HasImages C]
/-- The functor from subobjects of `X` to subobjects of `Y` given by
sending the subobject `S` to its "image" under `f`, usually denoted $\exists_f$.
For instance, when `C` is the category of types,
viewing `Subobject X` as `Set X` this is just `Set.image f`.
This functor is left adjoint to the `pullback f` functor (shown in `existsPullbackAdj`)
provided both are defined, and generalises the `map f` functor, again provided it is defined.
-/
def «exists» (f : X ⟶ Y) : Subobject X ⥤ Subobject Y :=
lower (MonoOver.exists f)
/-- When `f : X ⟶ Y` is a monomorphism, `exists f` agrees with `map f`.
-/
theorem exists_iso_map (f : X ⟶ Y) [Mono f] : «exists» f = map f :=
lower_iso _ _ (MonoOver.existsIsoMap f)
/-- `exists f : Subobject X ⥤ Subobject Y` is
left adjoint to `pullback f : Subobject Y ⥤ Subobject X`.
-/
def existsPullbackAdj (f : X ⟶ Y) [HasPullbacks C] : «exists» f ⊣ pullback f :=
lowerAdjunction (MonoOver.existsPullbackAdj f)
/--
Taking representatives and then `MonoOver.exists` is isomorphic to taking `Subobject.exists`
and then taking representatives.
-/
def existsCompRepresentativeIso (f : X ⟶ Y) :
«exists» f ⋙ representative ≅ representative ⋙ MonoOver.exists f :=
lowerCompRepresentativeIso _
/-- `exists f` applied to a subobject `x` is isomorphic to the image of `x.arrow ≫ f`. -/
def existsIsoImage (f : X ⟶ Y) (x : Subobject X) :
((«exists» f).obj x : C) ≅ Limits.image (x.arrow ≫ f) :=
(MonoOver.forget Y ⋙ Over.forget Y).mapIso <| (existsCompRepresentativeIso f).app x
/-- Given a subobject `x`, the `ImageFactorisation` of `x.arrow ≫ f` through `(exists f).obj x`. -/
@[simps! F_I F_m]
def imageFactorisation (f : X ⟶ Y) (x : Subobject X) :
ImageFactorisation (x.arrow ≫ f) :=
let :=
ImageFactorisation.ofIsoI
(Image.imageFactorisation (x.arrow ≫ f))
(existsIsoImage f x).symm
ImageFactorisation.copy this
((«exists» f).obj x).arrow
this.F.e
(by simpa [this, -Over.w] using (Over.w ((existsCompRepresentativeIso f).app x).hom).symm)
end Exists
end Subobject
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Subobject/FactorThru.lean | import Mathlib.CategoryTheory.Subobject.Basic
import Mathlib.CategoryTheory.Preadditive.Basic
/-!
# Factoring through subobjects
The predicate `h : P.Factors f`, for `P : Subobject Y` and `f : X ⟶ Y`
asserts the existence of some `P.factorThru f : X ⟶ (P : C)` making the obvious diagram commute.
-/
universe v₁ v₂ u₁ u₂
noncomputable section
open CategoryTheory CategoryTheory.Category CategoryTheory.Limits
variable {C : Type u₁} [Category.{v₁} C] {X Y Z : C}
variable {D : Type u₂} [Category.{v₂} D]
namespace CategoryTheory
namespace MonoOver
/-- When `f : X ⟶ Y` and `P : MonoOver Y`,
`P.Factors f` expresses that there exists a factorisation of `f` through `P`.
Given `h : P.Factors f`, you can recover the morphism as `P.factorThru f h`.
-/
def Factors {X Y : C} (P : MonoOver Y) (f : X ⟶ Y) : Prop :=
∃ g : X ⟶ (P : C), g ≫ P.arrow = f
theorem factors_congr {X : C} {f g : MonoOver X} {Y : C} (h : Y ⟶ X) (e : f ≅ g) :
f.Factors h ↔ g.Factors h :=
⟨fun ⟨u, hu⟩ => ⟨u ≫ ((MonoOver.forget _).map e.hom).left, by simp [hu]⟩, fun ⟨u, hu⟩ =>
⟨u ≫ ((MonoOver.forget _).map e.inv).left, by simp [hu]⟩⟩
/-- `P.factorThru f h` provides a factorisation of `f : X ⟶ Y` through some `P : MonoOver Y`,
given the evidence `h : P.Factors f` that such a factorisation exists. -/
def factorThru {X Y : C} (P : MonoOver Y) (f : X ⟶ Y) (h : Factors P f) : X ⟶ (P : C) :=
Classical.choose h
end MonoOver
namespace Subobject
/-- When `f : X ⟶ Y` and `P : Subobject Y`,
`P.Factors f` expresses that there exists a factorisation of `f` through `P`.
Given `h : P.Factors f`, you can recover the morphism as `P.factorThru f h`.
-/
def Factors {X Y : C} (P : Subobject Y) (f : X ⟶ Y) : Prop :=
Quotient.liftOn' P (fun P => P.Factors f)
(by
rintro P Q ⟨h⟩
apply propext
constructor
· rintro ⟨i, w⟩
exact ⟨i ≫ h.hom.left, by erw [Category.assoc, Over.w h.hom, w]⟩
· rintro ⟨i, w⟩
exact ⟨i ≫ h.inv.left, by erw [Category.assoc, Over.w h.inv, w]⟩)
@[simp]
theorem mk_factors_iff {X Y Z : C} (f : Y ⟶ X) [Mono f] (g : Z ⟶ X) :
(Subobject.mk f).Factors g ↔ (MonoOver.mk' f).Factors g :=
Iff.rfl
theorem mk_factors_self (f : X ⟶ Y) [Mono f] : (mk f).Factors f :=
⟨𝟙 _, by simp⟩
theorem factors_iff {X Y : C} (P : Subobject Y) (f : X ⟶ Y) :
P.Factors f ↔ (representative.obj P).Factors f :=
Quot.inductionOn P fun _ => MonoOver.factors_congr _ (representativeIso _).symm
theorem factors_self {X : C} (P : Subobject X) : P.Factors P.arrow :=
(factors_iff _ _).mpr ⟨𝟙 (P : C), by simp⟩
theorem factors_comp_arrow {X Y : C} {P : Subobject Y} (f : X ⟶ P) : P.Factors (f ≫ P.arrow) :=
(factors_iff _ _).mpr ⟨f, rfl⟩
theorem factors_of_factors_right {X Y Z : C} {P : Subobject Z} (f : X ⟶ Y) {g : Y ⟶ Z}
(h : P.Factors g) : P.Factors (f ≫ g) := by
induction P using Quotient.ind'
obtain ⟨g, rfl⟩ := h
exact ⟨f ≫ g, by simp⟩
theorem factors_zero [HasZeroMorphisms C] {X Y : C} {P : Subobject Y} : P.Factors (0 : X ⟶ Y) :=
(factors_iff _ _).mpr ⟨0, by simp⟩
theorem factors_of_le {Y Z : C} {P Q : Subobject Y} (f : Z ⟶ Y) (h : P ≤ Q) :
P.Factors f → Q.Factors f := by
simp only [factors_iff]
exact fun ⟨u, hu⟩ => ⟨u ≫ ofLE _ _ h, by simp [← hu]⟩
/-- `P.factorThru f h` provides a factorisation of `f : X ⟶ Y` through some `P : Subobject Y`,
given the evidence `h : P.Factors f` that such a factorisation exists. -/
def factorThru {X Y : C} (P : Subobject Y) (f : X ⟶ Y) (h : Factors P f) : X ⟶ P :=
Classical.choose ((factors_iff _ _).mp h)
@[reassoc (attr := simp)]
theorem factorThru_arrow {X Y : C} (P : Subobject Y) (f : X ⟶ Y) (h : Factors P f) :
P.factorThru f h ≫ P.arrow = f :=
Classical.choose_spec ((factors_iff _ _).mp h)
@[simp]
theorem factorThru_self {X : C} (P : Subobject X) (h) : P.factorThru P.arrow h = 𝟙 (P : C) := by
ext
simp
@[simp]
theorem factorThru_mk_self (f : X ⟶ Y) [Mono f] :
(mk f).factorThru f (mk_factors_self f) = (underlyingIso f).inv := by
ext
simp
@[simp]
theorem factorThru_comp_arrow {X Y : C} {P : Subobject Y} (f : X ⟶ P) (h) :
P.factorThru (f ≫ P.arrow) h = f := by
ext
simp
@[simp]
theorem factorThru_eq_zero [HasZeroMorphisms C] {X Y : C} {P : Subobject Y} {f : X ⟶ Y}
{h : Factors P f} : P.factorThru f h = 0 ↔ f = 0 := by
fconstructor
· intro w
replace w := w =≫ P.arrow
simpa using w
· rintro rfl
ext
simp
theorem factorThru_right {X Y Z : C} {P : Subobject Z} (f : X ⟶ Y) (g : Y ⟶ Z) (h : P.Factors g) :
f ≫ P.factorThru g h = P.factorThru (f ≫ g) (factors_of_factors_right f h) := by
apply (cancel_mono P.arrow).mp
simp
@[simp]
theorem factorThru_zero [HasZeroMorphisms C] {X Y : C} {P : Subobject Y}
(h : P.Factors (0 : X ⟶ Y)) : P.factorThru 0 h = 0 := by simp
-- `h` is an explicit argument here so we can use
-- `rw factorThru_ofLE h`, obtaining a subgoal `P.Factors f`.
-- (While the reverse direction looks plausible as a simp lemma, it seems to be unproductive.)
theorem factorThru_ofLE {Y Z : C} {P Q : Subobject Y} {f : Z ⟶ Y} (h : P ≤ Q) (w : P.Factors f) :
Q.factorThru f (factors_of_le f h w) = P.factorThru f w ≫ ofLE P Q h := by
ext
simp
section Preadditive
variable [Preadditive C]
theorem factors_add {X Y : C} {P : Subobject Y} (f g : X ⟶ Y) (wf : P.Factors f)
(wg : P.Factors g) : P.Factors (f + g) :=
(factors_iff _ _).mpr ⟨P.factorThru f wf + P.factorThru g wg, by simp⟩
-- This can't be a `simp` lemma as `wf` and `wg` may not exist.
-- However you can `rw` by it to assert that `f` and `g` factor through `P` separately.
theorem factorThru_add {X Y : C} {P : Subobject Y} (f g : X ⟶ Y) (w : P.Factors (f + g))
(wf : P.Factors f) (wg : P.Factors g) :
P.factorThru (f + g) w = P.factorThru f wf + P.factorThru g wg := by
ext
simp
theorem factors_left_of_factors_add {X Y : C} {P : Subobject Y} (f g : X ⟶ Y)
(w : P.Factors (f + g)) (wg : P.Factors g) : P.Factors f :=
(factors_iff _ _).mpr ⟨P.factorThru (f + g) w - P.factorThru g wg, by simp⟩
@[simp]
theorem factorThru_add_sub_factorThru_right {X Y : C} {P : Subobject Y} (f g : X ⟶ Y)
(w : P.Factors (f + g)) (wg : P.Factors g) :
P.factorThru (f + g) w - P.factorThru g wg =
P.factorThru f (factors_left_of_factors_add f g w wg) := by
ext
simp
theorem factors_right_of_factors_add {X Y : C} {P : Subobject Y} (f g : X ⟶ Y)
(w : P.Factors (f + g)) (wf : P.Factors f) : P.Factors g :=
(factors_iff _ _).mpr ⟨P.factorThru (f + g) w - P.factorThru f wf, by simp⟩
@[simp]
theorem factorThru_add_sub_factorThru_left {X Y : C} {P : Subobject Y} (f g : X ⟶ Y)
(w : P.Factors (f + g)) (wf : P.Factors f) :
P.factorThru (f + g) w - P.factorThru f wf =
P.factorThru g (factors_right_of_factors_add f g w wf) := by
ext
simp
end Preadditive
end Subobject
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Subobject/MonoOver.lean | import Mathlib.CategoryTheory.Comma.Over.Pullback
import Mathlib.CategoryTheory.Adjunction.Reflective
import Mathlib.CategoryTheory.Adjunction.Restrict
import Mathlib.CategoryTheory.Limits.FullSubcategory
import Mathlib.CategoryTheory.Limits.Shapes.Images
import Mathlib.CategoryTheory.Limits.Shapes.Pullback.CommSq
import Mathlib.CategoryTheory.Functor.ReflectsIso.Basic
import Mathlib.CategoryTheory.WithTerminal.Cone
/-!
# Monomorphisms over a fixed object
As preparation for defining `Subobject X`, we set up the theory for
`MonoOver X := { f : Over X // Mono f.hom}`.
Here `MonoOver X` is a thin category (a pair of objects has at most one morphism between them),
so we can think of it as a preorder. However as it is not skeletal, it is not yet a partial order.
`Subobject X` will be defined as the skeletalization of `MonoOver X`.
We provide
* `def pullback [HasPullbacks C] (f : X ⟶ Y) : MonoOver Y ⥤ MonoOver X`
* `def map (f : X ⟶ Y) [Mono f] : MonoOver X ⥤ MonoOver Y`
* `def «exists» [HasImages C] (f : X ⟶ Y) : MonoOver X ⥤ MonoOver Y`
and prove their basic properties and relationships.
## Notes
This development originally appeared in Bhavik Mehta's "Topos theory for Lean" repository,
and was ported to mathlib by Kim Morrison.
-/
universe w' w v₁ v₂ v₃ u₁ u₂ u₃
noncomputable section
namespace CategoryTheory
open CategoryTheory CategoryTheory.Category CategoryTheory.Limits CategoryTheory.Functor
variable {C : Type u₁} [Category.{v₁} C] {X Y Z : C}
variable {D : Type u₂} [Category.{v₂} D]
/-- The object property in `Over X` of the structure morphism being a monomorphism. -/
abbrev Over.isMono (X : C) : ObjectProperty (Over X) :=
fun f : Over X => Mono f.hom
/-- The category of monomorphisms into `X` as a full subcategory of the over category.
This isn't skeletal, so it's not a partial order.
Later we define `Subobject X` as the quotient of this by isomorphisms.
-/
def MonoOver (X : C) :=
ObjectProperty.FullSubcategory (Over.isMono X)
instance (X : C) : Category (MonoOver X) :=
ObjectProperty.FullSubcategory.category _
namespace MonoOver
instance mono_obj_hom (S : MonoOver X) : Mono S.obj.hom := S.2
/-- Construct a `MonoOver X`. -/
@[simps]
def mk' {X A : C} (f : A ⟶ X) [hf : Mono f] : MonoOver X where
obj := Over.mk f
property := hf
/-- The inclusion from monomorphisms over X to morphisms over X. -/
def forget (X : C) : MonoOver X ⥤ Over X :=
ObjectProperty.ι _
instance : CoeOut (MonoOver X) C where coe Y := Y.obj.left
@[simp]
theorem forget_obj_left {f} : ((forget X).obj f).left = (f : C) :=
rfl
@[simp]
theorem mk'_coe' {X A : C} (f : A ⟶ X) [Mono f] : (mk' f : C) = A :=
rfl
/-- Convenience notation for the underlying arrow of a monomorphism over X. -/
abbrev arrow (f : MonoOver X) : (f : C) ⟶ X :=
((forget X).obj f).hom
@[simp]
theorem mk'_arrow {X A : C} (f : A ⟶ X) [Mono f] : (mk' f).arrow = f :=
rfl
@[simp]
theorem forget_obj_hom {f} : ((forget X).obj f).hom = f.arrow :=
rfl
/-- The forget functor `MonoOver X ⥤ Over X` is fully faithful. -/
def fullyFaithfulForget (X : C) : (forget X).FullyFaithful :=
ObjectProperty.fullyFaithfulι _
instance : (forget X).Full :=
ObjectProperty.full_ι _
instance : (forget X).Faithful :=
ObjectProperty.faithful_ι _
instance mono (f : MonoOver X) : Mono f.arrow :=
f.property
instance {X : C} {f : MonoOver X} : Mono ((MonoOver.forget X).obj f).hom := f.mono
/-- The category of monomorphisms over X is a thin category,s
which makes defining its skeleton easy. -/
instance isThin {X : C} : Quiver.IsThin (MonoOver X) := fun f g =>
⟨by
intro h₁ h₂
apply Over.OverMorphism.ext
rw [← cancel_mono g.arrow]
erw [Over.w h₁]
erw [Over.w h₂]⟩
@[reassoc]
theorem w {f g : MonoOver X} (k : f ⟶ g) : k.left ≫ g.arrow = f.arrow :=
Over.w _
/-- Convenience constructor for a morphism in monomorphisms over `X`. -/
abbrev homMk {f g : MonoOver X} (h : f.obj.left ⟶ g.obj.left)
(w : h ≫ g.arrow = f.arrow := by cat_disch) : f ⟶ g :=
Over.homMk h w
/-- Convenience constructor for an isomorphism in monomorphisms over `X`. -/
@[simps]
def isoMk {f g : MonoOver X} (h : f.obj.left ≅ g.obj.left)
(w : h.hom ≫ g.arrow = f.arrow := by cat_disch) : f ≅ g where
hom := homMk h.hom w
inv := homMk h.inv (by rw [h.inv_comp_eq, w])
/-- If `f : MonoOver X`, then `mk' f.arrow` is of course just `f`, but not definitionally, so we
package it as an isomorphism. -/
@[simps!]
def mk'ArrowIso {X : C} (f : MonoOver X) : mk' f.arrow ≅ f :=
isoMk (Iso.refl _)
instance {A B : MonoOver X} (f : A ⟶ B) [IsIso f] : IsIso f.left :=
inferInstanceAs (IsIso ((MonoOver.forget _ ⋙ Over.forget _).map f))
lemma isIso_iff_isIso_left {A B : MonoOver X} (f : A ⟶ B) :
IsIso f ↔ IsIso f.left :=
(isIso_iff_of_reflects_iso _ (MonoOver.forget X ⋙ Over.forget _)).symm
/-- Lift a functor between over categories to a functor between `MonoOver` categories,
given suitable evidence that morphisms are taken to monomorphisms.
-/
@[simps]
def lift {Y : D} (F : Over Y ⥤ Over X)
(h : ∀ f : MonoOver Y, Mono (F.obj ((MonoOver.forget Y).obj f)).hom) :
MonoOver Y ⥤ MonoOver X where
obj f := ⟨_, h f⟩
map k := (MonoOver.forget Y ⋙ F).map k
/-- Isomorphic functors `Over Y ⥤ Over X` lift to isomorphic functors `MonoOver Y ⥤ MonoOver X`.
-/
def liftIso {Y : D} {F₁ F₂ : Over Y ⥤ Over X} (h₁ h₂) (i : F₁ ≅ F₂) : lift F₁ h₁ ≅ lift F₂ h₂ :=
Functor.fullyFaithfulCancelRight (MonoOver.forget X) (isoWhiskerLeft (MonoOver.forget Y) i)
/-- `MonoOver.lift` commutes with composition of functors. -/
def liftComp {X Z : C} {Y : D} (F : Over X ⥤ Over Y) (G : Over Y ⥤ Over Z) (h₁ h₂) :
lift F h₁ ⋙ lift G h₂ ≅ lift (F ⋙ G) fun f => h₂ ⟨_, h₁ f⟩ :=
Functor.fullyFaithfulCancelRight (MonoOver.forget _) (Iso.refl _)
/-- `MonoOver.lift` preserves the identity functor. -/
def liftId : (lift (𝟭 (Over X)) fun f => f.2) ≅ 𝟭 _ :=
Functor.fullyFaithfulCancelRight (MonoOver.forget _) (Iso.refl _)
@[simp]
theorem lift_comm (F : Over Y ⥤ Over X)
(h : ∀ f : MonoOver Y, Mono (F.obj ((MonoOver.forget Y).obj f)).hom) :
lift F h ⋙ MonoOver.forget X = MonoOver.forget Y ⋙ F :=
rfl
@[simp]
theorem lift_obj_arrow {Y : D} (F : Over Y ⥤ Over X)
(h : ∀ f : MonoOver Y, Mono (F.obj ((MonoOver.forget Y).obj f)).hom) (f : MonoOver Y) :
((lift F h).obj f).arrow = (F.obj ((forget Y).obj f)).hom :=
rfl
/-- Monomorphisms over an object `f : Over A` in an over category
are equivalent to monomorphisms over the source of `f`.
-/
def slice {A : C} {f : Over A}
(h₁ : ∀ (g : MonoOver f),
Mono ((Over.iteratedSliceEquiv f).functor.obj ((forget f).obj g)).hom)
(h₂ : ∀ (g : MonoOver f.left),
Mono ((Over.iteratedSliceEquiv f).inverse.obj ((forget f.left).obj g)).hom) :
MonoOver f ≌ MonoOver f.left where
functor := MonoOver.lift f.iteratedSliceEquiv.functor h₁
inverse := MonoOver.lift f.iteratedSliceEquiv.inverse h₂
unitIso :=
MonoOver.liftId.symm ≪≫
MonoOver.liftIso _ _ f.iteratedSliceEquiv.unitIso ≪≫ (MonoOver.liftComp _ _ _ _).symm
counitIso :=
MonoOver.liftComp _ _ _ _ ≪≫
MonoOver.liftIso _ _ f.iteratedSliceEquiv.counitIso ≪≫ MonoOver.liftId
section Limits
variable {J : Type u₃} [Category.{v₃} J] (X : C)
instance : (Over.isMono X).IsClosedUnderLimitsOfShape J where
limitsOfShape_le := fun F ⟨p, hp⟩ ↦ ⟨fun g h e ↦ by
refine (WithTerminal.isLimitEquiv.invFun p.isLimit).hom_ext (fun j ↦ ?_)
cases j with
| of j => have := hp j; rw [← cancel_mono ((p.diag.obj j).hom)]; simpa
| star => exact e⟩
instance hasLimit (F : J ⥤ MonoOver X) [HasLimit (F ⋙ (Over.isMono X).ι)] :
HasLimit F :=
hasLimit_of_closedUnderLimits _ _ _
instance hasLimitsOfShape [HasLimitsOfShape J (Over X)] :
HasLimitsOfShape J (MonoOver X) where
instance hasFiniteLimits [HasFiniteLimits (Over X)] : HasFiniteLimits (MonoOver X) where
out _ _ _ := inferInstance
instance hasLimitsOfSize [HasLimitsOfSize.{w, w'} (Over X)] :
HasLimitsOfSize.{w, w'} (MonoOver X) where
end Limits
section Colimits
variable [HasCoproducts C] [HasStrongEpiMonoFactorisations C] {J : Type u₂} [Category.{v₂} J]
/-- A helper function, providing the strong epi-mono factorization used construct to colimits. -/
def strongEpiMonoFactorisationSigmaDesc (F : J ⥤ MonoOver Y) :
StrongEpiMonoFactorisation (Sigma.desc fun i ↦ (F.obj i).arrow) :=
Classical.choice <| HasStrongEpiMonoFactorisations.has_fac (Sigma.desc fun i ↦ (F.obj i).arrow)
/-- If a category `C` has strong epi-mono factorization, for any `Y : C` and functor
`F : J ⥤ MonoOver Y`, there is a cocone under F. -/
def coconeOfHasStrongEpiMonoFactorisation (F : J ⥤ MonoOver Y) :
Cocone F where
pt := {
obj := .mk <| (strongEpiMonoFactorisationSigmaDesc F).m
property := (strongEpiMonoFactorisationSigmaDesc F).m_mono
}
ι := {
app j := {
left := Sigma.ι (fun i ↦ (F.obj i : C)) j ≫ (strongEpiMonoFactorisationSigmaDesc F).e
right := 𝟙 _
}
}
lemma commSqOfHasStrongEpiMonoFactorisation (F : J ⥤ MonoOver Y) (c : Cocone F) :
CommSq (Sigma.desc fun i ↦ (c.ι.app i).left) (strongEpiMonoFactorisationSigmaDesc F).e
c.pt.arrow (strongEpiMonoFactorisationSigmaDesc F).m where
w := by
apply Sigma.hom_ext
intro j
simp only [colimit.ι_desc_assoc, Discrete.functor_obj_eq_as, Cofan.mk_pt, Cofan.mk_ι_app,
MonoFactorisation.fac, colimit.ι_desc]
convert (c.ι.app j).w
simp only [const_obj_obj, CostructuredArrow.right_eq_id, const_obj_map, comp_id]
exact rfl
/-- A helper function, providing the lift structure used to construct colimits. -/
def liftStructOfHasStrongEpiMonoFactorisation (F : J ⥤ MonoOver Y) (c : Cocone F) :
(commSqOfHasStrongEpiMonoFactorisation F c).LiftStruct :=
Classical.choice
(((strongEpiMonoFactorisationSigmaDesc F).e_strong_epi.llp _).sq_hasLift
(commSqOfHasStrongEpiMonoFactorisation F c)).exists_lift
/-- The cocone `coconeOfHasStrongEpiMonoFactorisation F` is a colimit -/
def isColimitCoconeOfHasStrongEpiMonoFactorisation (F : J ⥤ MonoOver Y) :
IsColimit (coconeOfHasStrongEpiMonoFactorisation F) where
desc c := {
left := (liftStructOfHasStrongEpiMonoFactorisation F c).l
right := 𝟙 _
w := by
simp only [id_obj, const_obj_obj, Functor.id_map, Discrete.functor_map_id, comp_id];
exact (liftStructOfHasStrongEpiMonoFactorisation F c).fac_right
}
instance hasColimitsOfSize_of_hasStrongEpiMonoFactorisations :
HasColimitsOfSize.{w, w'} (MonoOver Y) where
has_colimits_of_shape _ _ :=
⟨fun F ↦
⟨coconeOfHasStrongEpiMonoFactorisation F, isColimitCoconeOfHasStrongEpiMonoFactorisation F⟩⟩
end Colimits
section Pullback
variable [HasPullbacks C]
/-- When `C` has pullbacks, a morphism `f : X ⟶ Y` induces a functor `MonoOver Y ⥤ MonoOver X`,
by pulling back a monomorphism along `f`. -/
def pullback (f : X ⟶ Y) : MonoOver Y ⥤ MonoOver X :=
MonoOver.lift (Over.pullback f) (fun g => by
haveI : Mono ((forget Y).obj g).hom := (inferInstance : Mono g.arrow)
apply pullback.snd_of_mono)
/-- pullback commutes with composition (up to a natural isomorphism) -/
def pullbackComp (f : X ⟶ Y) (g : Y ⟶ Z) : pullback (f ≫ g) ≅ pullback g ⋙ pullback f :=
liftIso _ _ (Over.pullbackComp _ _) ≪≫ (liftComp _ _ _ _).symm
/-- pullback preserves the identity (up to a natural isomorphism) -/
def pullbackId : pullback (𝟙 X) ≅ 𝟭 _ :=
liftIso _ _ Over.pullbackId ≪≫ liftId
@[simp]
theorem pullback_obj_left (f : X ⟶ Y) (g : MonoOver Y) :
((pullback f).obj g : C) = Limits.pullback g.arrow f :=
rfl
@[simp]
theorem pullback_obj_arrow (f : X ⟶ Y) (g : MonoOver Y) :
((pullback f).obj g).arrow = pullback.snd _ _ :=
rfl
end Pullback
section IsPullback
/--
Given two monomorphisms `S` and `T` over `X` and `Y` and two morphisms `f` and `f'` between them
forming the following pullback square:
```
(T : C) -f'-> (S : C)
| |
T.arrow S.arrow
| |
v v
Y -----f----> X
```
we get an isomorphism between `T` and the pullback of `S` along `f` through the `pullback` functor.
-/
def pullbackObjIsoOfIsPullback [HasPullbacks C] {X Y : C} (f : Y ⟶ X) (S : MonoOver X)
(T : MonoOver Y) (f' : (T : C) ⟶ (S : C))
(h : IsPullback f' T.arrow S.arrow f) :
(pullback f).obj S ≅ T :=
isoMk ((IsPullback.isoPullback h).symm) (by simp)
end IsPullback
section Map
/-- We can map monomorphisms over `X` to monomorphisms over `Y`
by post-composition with a monomorphism `f : X ⟶ Y`.
-/
def map (f : X ⟶ Y) [Mono f] : MonoOver X ⥤ MonoOver Y :=
lift (Over.map f) fun g => mono_comp g.arrow f
/-- `MonoOver.map` commutes with composition (up to a natural isomorphism). -/
def mapComp (f : X ⟶ Y) (g : Y ⟶ Z) [Mono f] [Mono g] : map (f ≫ g) ≅ map f ⋙ map g :=
liftIso _ _ (Over.mapComp _ _) ≪≫ (liftComp _ _ _ _).symm
variable (X) in
/-- `MonoOver.map` preserves the identity (up to a natural isomorphism). -/
def mapId : map (𝟙 X) ≅ 𝟭 _ :=
liftIso _ _ (Over.mapId X) ≪≫ liftId
@[simp]
theorem map_obj_left (f : X ⟶ Y) [Mono f] (g : MonoOver X) : ((map f).obj g : C) = g.obj.left :=
rfl
@[simp]
theorem map_obj_arrow (f : X ⟶ Y) [Mono f] (g : MonoOver X) : ((map f).obj g).arrow = g.arrow ≫ f :=
rfl
instance full_map (f : X ⟶ Y) [Mono f] : Functor.Full (map f) where
map_surjective {g h} e := by
refine ⟨homMk e.left ?_, rfl⟩
· rw [← cancel_mono f, assoc]
apply w e
instance faithful_map (f : X ⟶ Y) [Mono f] : Functor.Faithful (map f) where
/-- Isomorphic objects have equivalent `MonoOver` categories.
-/
@[simps]
def mapIso {A B : C} (e : A ≅ B) : MonoOver A ≌ MonoOver B where
functor := map e.hom
inverse := map e.inv
unitIso := ((mapComp _ _).symm ≪≫ eqToIso (by simp) ≪≫ (mapId _)).symm
counitIso := (mapComp _ _).symm ≪≫ eqToIso (by simp) ≪≫ (mapId _)
section
variable (X)
/-- An equivalence of categories `e` between `C` and `D` induces an equivalence between
`MonoOver X` and `MonoOver (e.functor.obj X)` whenever `X` is an object of `C`. -/
@[simps]
def congr (e : C ≌ D) : MonoOver X ≌ MonoOver (e.functor.obj X) where
functor :=
lift (Over.post e.functor) fun f => by
dsimp
infer_instance
inverse :=
(lift (Over.post e.inverse) fun f => by
dsimp
infer_instance) ⋙
(mapIso (e.unitIso.symm.app X)).functor
unitIso := NatIso.ofComponents fun Y => isoMk (e.unitIso.app Y)
counitIso := NatIso.ofComponents fun Y => isoMk (e.counitIso.app Y)
end
section
variable [HasPullbacks C]
/-- `map f` is left adjoint to `pullback f` when `f` is a monomorphism -/
def mapPullbackAdj (f : X ⟶ Y) [Mono f] : map f ⊣ pullback f :=
(Over.mapPullbackAdj f).restrictFullyFaithful (fullyFaithfulForget X) (fullyFaithfulForget Y)
(Iso.refl _) (Iso.refl _)
/-- `MonoOver.map f` followed by `MonoOver.pullback f` is the identity. -/
def pullbackMapSelf (f : X ⟶ Y) [Mono f] : map f ⋙ pullback f ≅ 𝟭 _ :=
(asIso (MonoOver.mapPullbackAdj f).unit).symm
end
end Map
section Image
variable (f : X ⟶ Y) [HasImage f]
/-- The `MonoOver Y` for the image inclusion for a morphism `f : X ⟶ Y`.
-/
def imageMonoOver (f : X ⟶ Y) [HasImage f] : MonoOver Y :=
MonoOver.mk' (image.ι f)
@[simp]
theorem imageMonoOver_arrow (f : X ⟶ Y) [HasImage f] : (imageMonoOver f).arrow = image.ι f :=
rfl
end Image
section Image
variable [HasImages C]
/-- Taking the image of a morphism gives a functor `Over X ⥤ MonoOver X`.
-/
@[simps]
def image : Over X ⥤ MonoOver X where
obj f := imageMonoOver f.hom
map {f g} k := by
apply (forget X).preimage _
apply Over.homMk _ _
· exact
image.lift
{ I := Limits.image _
m := image.ι g.hom
e := k.left ≫ factorThruImage g.hom }
· apply image.lift_fac
/-- `MonoOver.image : Over X ⥤ MonoOver X` is left adjoint to
`MonoOver.forget : MonoOver X ⥤ Over X`
-/
def imageForgetAdj : image ⊣ forget X :=
Adjunction.mkOfHomEquiv
{ homEquiv := fun f g =>
{ toFun := fun k => by
apply Over.homMk (factorThruImage f.hom ≫ k.left) _
change (factorThruImage f.hom ≫ k.left) ≫ _ = f.hom
rw [assoc, Over.w k]
apply image.fac
invFun := fun k => by
refine Over.homMk ?_ ?_
· exact
image.lift
{ I := g.obj.left
m := g.arrow
e := k.left
fac := Over.w k }
· apply image.lift_fac
left_inv := fun _ => Subsingleton.elim _ _
right_inv := fun k => by simp } }
instance : (forget X).IsRightAdjoint :=
⟨_, ⟨imageForgetAdj⟩⟩
instance reflective : Reflective (forget X) where
L := image
adj := imageForgetAdj
/-- Forgetting that a monomorphism over `X` is a monomorphism, then taking its image,
is the identity functor.
-/
def forgetImage : forget X ⋙ image ≅ 𝟭 (MonoOver X) :=
asIso (Adjunction.counit imageForgetAdj)
end Image
section Exists
variable [HasImages C]
/-- In the case where `f` is not a monomorphism but `C` has images,
we can still take the "forward map" under it, which agrees with `MonoOver.map f`.
-/
def «exists» (f : X ⟶ Y) : MonoOver X ⥤ MonoOver Y :=
forget _ ⋙ Over.map f ⋙ image
instance faithful_exists (f : X ⟶ Y) : Functor.Faithful («exists» f) where
/-- When `f : X ⟶ Y` is a monomorphism, `exists f` agrees with `map f`.
-/
def existsIsoMap (f : X ⟶ Y) [Mono f] : «exists» f ≅ map f :=
NatIso.ofComponents (by
intro Z
suffices (forget _).obj ((«exists» f).obj Z) ≅ (forget _).obj ((map f).obj Z) by
apply (forget _).preimageIso this
apply Over.isoMk _ _
· apply imageMonoIsoSource (Z.arrow ≫ f)
· apply imageMonoIsoSource_hom_self)
/-- `exists` is adjoint to `pullback` when images exist -/
def existsPullbackAdj (f : X ⟶ Y) [HasPullbacks C] : «exists» f ⊣ pullback f :=
((Over.mapPullbackAdj f).comp imageForgetAdj).restrictFullyFaithful
(fullyFaithfulForget X) (Functor.FullyFaithful.id _) (Iso.refl _) (Iso.refl _)
end Exists
end MonoOver
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Subobject/HasCardinalLT.lean | import Mathlib.CategoryTheory.Subobject.Basic
import Mathlib.SetTheory.Cardinal.HasCardinalLT
/-!
# Cardinality of Subobject
If `X ⟶ Y` is a monomorphism, and the cardinality of `Subobject Y`
is `< κ`, then the cardinality of `Subobject X` is also `< κ`.
-/
universe w v u
namespace CategoryTheory.Subobject
variable {C : Type u} [Category.{v} C]
lemma hasCardinalLT_of_mono {Y : C} {κ : Cardinal.{w}}
(h : HasCardinalLT (Subobject Y) κ) {X : C} (f : X ⟶ Y) [Mono f] :
HasCardinalLT (Subobject X) κ :=
h.of_injective _ (map_obj_injective f)
end CategoryTheory.Subobject |
.lake/packages/mathlib/Mathlib/CategoryTheory/Subobject/Types.lean | import Mathlib.CategoryTheory.Subobject.WellPowered
import Mathlib.CategoryTheory.Types.Basic
import Mathlib.Data.Set.Subsingleton
/-!
# `Type u` is well-powered
By building a categorical equivalence `MonoOver α ≌ Set α` for any `α : Type u`,
we deduce that `Subobject α ≃o Set α` and that `Type u` is well-powered.
One would hope that for a particular concrete category `C` (`AddCommGroup`, etc)
it's viable to prove `[WellPowered C]` without explicitly aligning `Subobject X`
with the "hand-rolled" definition of subobjects.
This may be possible using Lawvere theories,
but it remains to be seen whether this just pushes lumps around in the carpet.
-/
universe u
open CategoryTheory
open CategoryTheory.Subobject
theorem subtype_val_mono {α : Type u} (s : Set α) : Mono (↾(Subtype.val : s → α)) :=
(mono_iff_injective _).mpr Subtype.val_injective
attribute [local instance] subtype_val_mono
/-- The category of `MonoOver α`, for `α : Type u`, is equivalent to the partial order `Set α`.
-/
@[simps]
noncomputable def Types.monoOverEquivalenceSet (α : Type u) : MonoOver α ≌ Set α where
functor :=
{ obj := fun f => Set.range f.1.hom
map := fun {f g} t =>
homOfLE
(by
rintro a ⟨x, rfl⟩
exact ⟨t.1 x, congr_fun t.w x⟩) }
inverse :=
{ obj := fun s => MonoOver.mk' (Subtype.val : s → α)
map := fun {s t} b => MonoOver.homMk (fun w => ⟨w.1, Set.mem_of_mem_of_subset w.2 b.le⟩) }
unitIso :=
NatIso.ofComponents fun f =>
MonoOver.isoMk (Equiv.ofInjective f.1.hom ((mono_iff_injective _).mp f.2)).toIso
counitIso := NatIso.ofComponents fun _ => eqToIso Subtype.range_val
instance : WellPowered.{u} (Type u) :=
wellPowered_of_essentiallySmall_monoOver fun α =>
EssentiallySmall.mk' (Types.monoOverEquivalenceSet α)
/-- For `α : Type u`, `Subobject α` is order isomorphic to `Set α`.
-/
noncomputable def Types.subobjectEquivSet (α : Type u) : Subobject α ≃o Set α :=
(Types.monoOverEquivalenceSet α).thinSkeletonOrderIso |
.lake/packages/mathlib/Mathlib/CategoryTheory/Subobject/Limits.lean | import Mathlib.CategoryTheory.Subobject.Lattice
/-!
# Specific subobjects
We define `equalizerSubobject`, `kernelSubobject` and `imageSubobject`, which are the subobjects
represented by the equalizer, kernel and image of (a pair of) morphism(s) and provide conditions
for `P.factors f`, where `P` is one of these special subobjects.
TODO: Add conditions for when `P` is a pullback subobject.
TODO: an iff characterisation of `(imageSubobject f).Factors h`
-/
universe v u
noncomputable section
open CategoryTheory CategoryTheory.Category CategoryTheory.Limits CategoryTheory.Subobject Opposite
variable {C : Type u} [Category.{v} C] {X Y Z : C}
namespace CategoryTheory
namespace Limits
section Equalizer
variable (f g : X ⟶ Y) [HasEqualizer f g]
/-- The equalizer of morphisms `f g : X ⟶ Y` as a `Subobject X`. -/
abbrev equalizerSubobject : Subobject X :=
Subobject.mk (equalizer.ι f g)
/-- The underlying object of `equalizerSubobject f g` is (up to isomorphism!)
the same as the chosen object `equalizer f g`. -/
def equalizerSubobjectIso : (equalizerSubobject f g : C) ≅ equalizer f g :=
Subobject.underlyingIso (equalizer.ι f g)
@[reassoc (attr := simp)]
theorem equalizerSubobject_arrow :
(equalizerSubobjectIso f g).hom ≫ equalizer.ι f g = (equalizerSubobject f g).arrow := by
simp [equalizerSubobjectIso]
@[reassoc (attr := simp)]
theorem equalizerSubobject_arrow' :
(equalizerSubobjectIso f g).inv ≫ (equalizerSubobject f g).arrow = equalizer.ι f g := by
simp [equalizerSubobjectIso]
@[reassoc]
theorem equalizerSubobject_arrow_comp :
(equalizerSubobject f g).arrow ≫ f = (equalizerSubobject f g).arrow ≫ g := by
rw [← equalizerSubobject_arrow, Category.assoc, Category.assoc, equalizer.condition]
theorem equalizerSubobject_factors {W : C} (h : W ⟶ X) (w : h ≫ f = h ≫ g) :
(equalizerSubobject f g).Factors h :=
⟨equalizer.lift h w, by simp⟩
theorem equalizerSubobject_factors_iff {W : C} (h : W ⟶ X) :
(equalizerSubobject f g).Factors h ↔ h ≫ f = h ≫ g :=
⟨fun w => by
rw [← Subobject.factorThru_arrow _ _ w, Category.assoc, equalizerSubobject_arrow_comp,
Category.assoc],
equalizerSubobject_factors f g h⟩
end Equalizer
section Kernel
variable [HasZeroMorphisms C] (f : X ⟶ Y) [HasKernel f]
/-- The kernel of a morphism `f : X ⟶ Y` as a `Subobject X`. -/
abbrev kernelSubobject : Subobject X :=
Subobject.mk (kernel.ι f)
/-- The underlying object of `kernelSubobject f` is (up to isomorphism!)
the same as the chosen object `kernel f`. -/
def kernelSubobjectIso : (kernelSubobject f : C) ≅ kernel f :=
Subobject.underlyingIso (kernel.ι f)
@[reassoc (attr := simp), elementwise (attr := simp)]
theorem kernelSubobject_arrow :
(kernelSubobjectIso f).hom ≫ kernel.ι f = (kernelSubobject f).arrow := by
simp [kernelSubobjectIso]
@[reassoc (attr := simp), elementwise (attr := simp)]
theorem kernelSubobject_arrow' :
(kernelSubobjectIso f).inv ≫ (kernelSubobject f).arrow = kernel.ι f := by
simp [kernelSubobjectIso]
@[reassoc (attr := simp), elementwise (attr := simp)]
theorem kernelSubobject_arrow_comp : (kernelSubobject f).arrow ≫ f = 0 := by
rw [← kernelSubobject_arrow]
simp only [Category.assoc, kernel.condition, comp_zero]
theorem kernelSubobject_factors {W : C} (h : W ⟶ X) (w : h ≫ f = 0) :
(kernelSubobject f).Factors h :=
⟨kernel.lift _ h w, by simp⟩
theorem kernelSubobject_factors_iff {W : C} (h : W ⟶ X) :
(kernelSubobject f).Factors h ↔ h ≫ f = 0 :=
⟨fun w => by
rw [← Subobject.factorThru_arrow _ _ w, Category.assoc, kernelSubobject_arrow_comp,
comp_zero],
kernelSubobject_factors f h⟩
/-- A factorisation of `h : W ⟶ X` through `kernelSubobject f`, assuming `h ≫ f = 0`. -/
def factorThruKernelSubobject {W : C} (h : W ⟶ X) (w : h ≫ f = 0) : W ⟶ kernelSubobject f :=
(kernelSubobject f).factorThru h (kernelSubobject_factors f h w)
@[simp]
theorem factorThruKernelSubobject_comp_arrow {W : C} (h : W ⟶ X) (w : h ≫ f = 0) :
factorThruKernelSubobject f h w ≫ (kernelSubobject f).arrow = h := by
dsimp [factorThruKernelSubobject]
simp
@[simp]
theorem factorThruKernelSubobject_comp_kernelSubobjectIso {W : C} (h : W ⟶ X) (w : h ≫ f = 0) :
factorThruKernelSubobject f h w ≫ (kernelSubobjectIso f).hom = kernel.lift f h w :=
(cancel_mono (kernel.ι f)).1 <| by simp
section
variable {f} {X' Y' : C} {f' : X' ⟶ Y'} [HasKernel f']
/-- A commuting square induces a morphism between the kernel subobjects. -/
def kernelSubobjectMap (sq : Arrow.mk f ⟶ Arrow.mk f') :
(kernelSubobject f : C) ⟶ (kernelSubobject f' : C) :=
Subobject.factorThru _ ((kernelSubobject f).arrow ≫ sq.left)
(kernelSubobject_factors _ _ (by simp))
@[reassoc (attr := simp), elementwise (attr := simp)]
theorem kernelSubobjectMap_arrow (sq : Arrow.mk f ⟶ Arrow.mk f') :
kernelSubobjectMap sq ≫ (kernelSubobject f').arrow = (kernelSubobject f).arrow ≫ sq.left := by
simp [kernelSubobjectMap]
@[simp]
theorem kernelSubobjectMap_id : kernelSubobjectMap (𝟙 (Arrow.mk f)) = 𝟙 _ := by cat_disch
@[simp]
theorem kernelSubobjectMap_comp {X'' Y'' : C} {f'' : X'' ⟶ Y''} [HasKernel f'']
(sq : Arrow.mk f ⟶ Arrow.mk f') (sq' : Arrow.mk f' ⟶ Arrow.mk f'') :
kernelSubobjectMap (sq ≫ sq') = kernelSubobjectMap sq ≫ kernelSubobjectMap sq' := by
cat_disch
@[reassoc]
theorem kernel_map_comp_kernelSubobjectIso_inv (sq : Arrow.mk f ⟶ Arrow.mk f') :
kernel.map f f' sq.1 sq.2 sq.3.symm ≫ (kernelSubobjectIso _).inv =
(kernelSubobjectIso _).inv ≫ kernelSubobjectMap sq := by cat_disch
@[reassoc]
theorem kernelSubobjectIso_comp_kernel_map (sq : Arrow.mk f ⟶ Arrow.mk f') :
(kernelSubobjectIso _).hom ≫ kernel.map f f' sq.1 sq.2 sq.3.symm =
kernelSubobjectMap sq ≫ (kernelSubobjectIso _).hom := by
simp [← Iso.comp_inv_eq, kernel_map_comp_kernelSubobjectIso_inv]
end
@[simp]
theorem kernelSubobject_zero {A B : C} : kernelSubobject (0 : A ⟶ B) = ⊤ :=
(isIso_iff_mk_eq_top _).mp (by infer_instance)
instance isIso_kernelSubobject_zero_arrow : IsIso (kernelSubobject (0 : X ⟶ Y)).arrow :=
(isIso_arrow_iff_eq_top _).mpr kernelSubobject_zero
theorem le_kernelSubobject (A : Subobject X) (h : A.arrow ≫ f = 0) : A ≤ kernelSubobject f :=
Subobject.le_mk_of_comm (kernel.lift f A.arrow h) (by simp)
/-- The isomorphism between the kernel of `f ≫ g` and the kernel of `g`,
when `f` is an isomorphism.
-/
def kernelSubobjectIsoComp {X' : C} (f : X' ⟶ X) [IsIso f] (g : X ⟶ Y) [HasKernel g] :
(kernelSubobject (f ≫ g) : C) ≅ (kernelSubobject g : C) :=
kernelSubobjectIso _ ≪≫ kernelIsIsoComp f g ≪≫ (kernelSubobjectIso _).symm
@[simp]
theorem kernelSubobjectIsoComp_hom_arrow {X' : C} (f : X' ⟶ X) [IsIso f] (g : X ⟶ Y) [HasKernel g] :
(kernelSubobjectIsoComp f g).hom ≫ (kernelSubobject g).arrow =
(kernelSubobject (f ≫ g)).arrow ≫ f := by
simp [kernelSubobjectIsoComp]
@[simp]
theorem kernelSubobjectIsoComp_inv_arrow {X' : C} (f : X' ⟶ X) [IsIso f] (g : X ⟶ Y) [HasKernel g] :
(kernelSubobjectIsoComp f g).inv ≫ (kernelSubobject (f ≫ g)).arrow =
(kernelSubobject g).arrow ≫ inv f := by
simp [kernelSubobjectIsoComp]
/-- The kernel of `f` is always a smaller subobject than the kernel of `f ≫ h`. -/
theorem kernelSubobject_comp_le (f : X ⟶ Y) [HasKernel f] {Z : C} (h : Y ⟶ Z) [HasKernel (f ≫ h)] :
kernelSubobject f ≤ kernelSubobject (f ≫ h) :=
le_kernelSubobject _ _ (by simp)
/-- Postcomposing by a monomorphism does not change the kernel subobject. -/
@[simp]
theorem kernelSubobject_comp_mono (f : X ⟶ Y) [HasKernel f] {Z : C} (h : Y ⟶ Z) [Mono h] :
kernelSubobject (f ≫ h) = kernelSubobject f :=
le_antisymm (le_kernelSubobject _ _ ((cancel_mono h).mp (by simp))) (kernelSubobject_comp_le f h)
instance kernelSubobject_comp_mono_isIso (f : X ⟶ Y) [HasKernel f] {Z : C} (h : Y ⟶ Z) [Mono h] :
IsIso (Subobject.ofLE _ _ (kernelSubobject_comp_le f h)) := by
rw [ofLE_mk_le_mk_of_comm (kernelCompMono f h).inv]
· infer_instance
· simp
/-- Taking cokernels is an order-reversing map from the subobjects of `X` to the quotient objects
of `X`. -/
@[simps]
def cokernelOrderHom [HasCokernels C] (X : C) : Subobject X →o (Subobject (op X))ᵒᵈ where
toFun :=
Subobject.lift (fun _ f _ => Subobject.mk (cokernel.π f).op)
(by
rintro A B f g hf hg i rfl
refine Subobject.mk_eq_mk_of_comm _ _ (Iso.op ?_) (Quiver.Hom.unop_inj ?_)
· exact (IsColimit.coconePointUniqueUpToIso (colimit.isColimit _)
(isCokernelEpiComp (colimit.isColimit _) i.hom rfl)).symm
· simp only [Iso.comp_inv_eq, Iso.op_hom, Iso.symm_hom, unop_comp, Quiver.Hom.unop_op,
colimit.comp_coconePointUniqueUpToIso_hom, Cofork.ofπ_ι_app,
coequalizer.cofork_π])
monotone' :=
Subobject.ind₂ _ <| by
intro A B f g hf hg h
dsimp only [Subobject.lift_mk]
refine Subobject.mk_le_mk_of_comm (cokernel.desc f (cokernel.π g) ?_).op ?_
· rw [← Subobject.ofMkLEMk_comp h, Category.assoc, cokernel.condition, comp_zero]
· exact Quiver.Hom.unop_inj (cokernel.π_desc _ _ _)
/-- Taking kernels is an order-reversing map from the quotient objects of `X` to the subobjects of
`X`. -/
@[simps]
def kernelOrderHom [HasKernels C] (X : C) : (Subobject (op X))ᵒᵈ →o Subobject X where
toFun :=
Subobject.lift (fun _ f _ => Subobject.mk (kernel.ι f.unop))
(by
rintro A B f g hf hg i rfl
refine Subobject.mk_eq_mk_of_comm _ _ ?_ ?_
· exact
IsLimit.conePointUniqueUpToIso (limit.isLimit _)
(isKernelCompMono (limit.isLimit (parallelPair g.unop 0)) i.unop.hom rfl)
· dsimp
simp only [← Iso.eq_inv_comp, limit.conePointUniqueUpToIso_inv_comp,
Fork.ofι_π_app])
monotone' :=
Subobject.ind₂ _ <| by
intro A B f g hf hg h
dsimp only [Subobject.lift_mk]
refine Subobject.mk_le_mk_of_comm (kernel.lift g.unop (kernel.ι f.unop) ?_) ?_
· rw [← Subobject.ofMkLEMk_comp h, unop_comp, kernel.condition_assoc, zero_comp]
· exact Quiver.Hom.op_inj (by simp)
end Kernel
section Image
variable (f : X ⟶ Y) [HasImage f]
/-- The image of a morphism `f g : X ⟶ Y` as a `Subobject Y`. -/
abbrev imageSubobject : Subobject Y :=
Subobject.mk (image.ι f)
/-- The underlying object of `imageSubobject f` is (up to isomorphism!)
the same as the chosen object `image f`. -/
def imageSubobjectIso : (imageSubobject f : C) ≅ image f :=
Subobject.underlyingIso (image.ι f)
@[reassoc (attr := simp)]
theorem imageSubobject_arrow :
(imageSubobjectIso f).hom ≫ image.ι f = (imageSubobject f).arrow := by simp [imageSubobjectIso]
@[reassoc (attr := simp)]
theorem imageSubobject_arrow' :
(imageSubobjectIso f).inv ≫ (imageSubobject f).arrow = image.ι f := by simp [imageSubobjectIso]
/-- A factorisation of `f : X ⟶ Y` through `imageSubobject f`. -/
def factorThruImageSubobject : X ⟶ imageSubobject f :=
factorThruImage f ≫ (imageSubobjectIso f).inv
instance [HasEqualizers C] : Epi (factorThruImageSubobject f) := by
dsimp [factorThruImageSubobject]
apply epi_comp
@[reassoc (attr := simp), elementwise (attr := simp)]
theorem imageSubobject_arrow_comp : factorThruImageSubobject f ≫ (imageSubobject f).arrow = f := by
simp [factorThruImageSubobject]
theorem imageSubobject_arrow_comp_eq_zero [HasZeroMorphisms C] {X Y Z : C} {f : X ⟶ Y} {g : Y ⟶ Z}
[HasImage f] [Epi (factorThruImageSubobject f)] (h : f ≫ g = 0) :
(imageSubobject f).arrow ≫ g = 0 :=
zero_of_epi_comp (factorThruImageSubobject f) <| by simp [h]
theorem imageSubobject_factors_comp_self {W : C} (k : W ⟶ X) : (imageSubobject f).Factors (k ≫ f) :=
⟨k ≫ factorThruImage f, by simp⟩
@[simp]
theorem factorThruImageSubobject_comp_self {W : C} (k : W ⟶ X) (h) :
(imageSubobject f).factorThru (k ≫ f) h = k ≫ factorThruImageSubobject f := by
ext
simp
@[simp]
theorem factorThruImageSubobject_comp_self_assoc {W W' : C} (k : W ⟶ W') (k' : W' ⟶ X) (h) :
(imageSubobject f).factorThru (k ≫ k' ≫ f) h = k ≫ k' ≫ factorThruImageSubobject f := by
ext
simp
/-- The image of `h ≫ f` is always a smaller subobject than the image of `f`. -/
theorem imageSubobject_comp_le {X' : C} (h : X' ⟶ X) (f : X ⟶ Y) [HasImage f] [HasImage (h ≫ f)] :
imageSubobject (h ≫ f) ≤ imageSubobject f :=
Subobject.mk_le_mk_of_comm (image.preComp h f) (by simp)
section
open ZeroObject
variable [HasZeroMorphisms C] [HasZeroObject C]
@[simp]
theorem imageSubobject_zero_arrow : (imageSubobject (0 : X ⟶ Y)).arrow = 0 := by
rw [← imageSubobject_arrow]
simp
@[simp]
theorem imageSubobject_zero {A B : C} : imageSubobject (0 : A ⟶ B) = ⊥ :=
Subobject.eq_of_comm (imageSubobjectIso _ ≪≫ imageZero ≪≫ Subobject.botCoeIsoZero.symm) (by simp)
end
section
variable [HasEqualizers C]
/-- The morphism `imageSubobject (h ≫ f) ⟶ imageSubobject f`
is an epimorphism when `h` is an epimorphism.
In general this does not imply that `imageSubobject (h ≫ f) = imageSubobject f`,
although it will when the ambient category is abelian.
-/
instance imageSubobject_comp_le_epi_of_epi {X' : C} (h : X' ⟶ X) [Epi h] (f : X ⟶ Y) [HasImage f]
[HasImage (h ≫ f)] : Epi (Subobject.ofLE _ _ (imageSubobject_comp_le h f)) := by
rw [ofLE_mk_le_mk_of_comm (image.preComp h f)]
· infer_instance
· simp
end
section
variable [HasEqualizers C]
/-- Postcomposing by an isomorphism gives an isomorphism between image subobjects. -/
def imageSubobjectCompIso (f : X ⟶ Y) [HasImage f] {Y' : C} (h : Y ⟶ Y') [IsIso h] :
(imageSubobject (f ≫ h) : C) ≅ (imageSubobject f : C) :=
imageSubobjectIso _ ≪≫ (image.compIso _ _).symm ≪≫ (imageSubobjectIso _).symm
@[reassoc (attr := simp)]
theorem imageSubobjectCompIso_hom_arrow (f : X ⟶ Y) [HasImage f] {Y' : C} (h : Y ⟶ Y') [IsIso h] :
(imageSubobjectCompIso f h).hom ≫ (imageSubobject f).arrow =
(imageSubobject (f ≫ h)).arrow ≫ inv h := by
simp [imageSubobjectCompIso]
@[reassoc (attr := simp)]
theorem imageSubobjectCompIso_inv_arrow (f : X ⟶ Y) [HasImage f] {Y' : C} (h : Y ⟶ Y') [IsIso h] :
(imageSubobjectCompIso f h).inv ≫ (imageSubobject (f ≫ h)).arrow =
(imageSubobject f).arrow ≫ h := by
simp [imageSubobjectCompIso]
end
theorem imageSubobject_mono (f : X ⟶ Y) [Mono f] : imageSubobject f = Subobject.mk f :=
eq_of_comm (imageSubobjectIso f ≪≫ imageMonoIsoSource f ≪≫ (underlyingIso f).symm) (by simp)
/-- Precomposing by an isomorphism does not change the image subobject. -/
theorem imageSubobject_iso_comp [HasEqualizers C] {X' : C} (h : X' ⟶ X) [IsIso h] (f : X ⟶ Y)
[HasImage f] : imageSubobject (h ≫ f) = imageSubobject f :=
le_antisymm (imageSubobject_comp_le h f)
(Subobject.mk_le_mk_of_comm (inv (image.preComp h f)) (by simp))
theorem imageSubobject_le {A B : C} {X : Subobject B} (f : A ⟶ B) [HasImage f] (h : A ⟶ X)
(w : h ≫ X.arrow = f) : imageSubobject f ≤ X :=
Subobject.le_of_comm
((imageSubobjectIso f).hom ≫
image.lift
{ I := (X : C)
e := h
m := X.arrow })
(by rw [assoc, image.lift_fac, imageSubobject_arrow])
theorem imageSubobject_le_mk {A B : C} {X : C} (g : X ⟶ B) [Mono g] (f : A ⟶ B) [HasImage f]
(h : A ⟶ X) (w : h ≫ g = f) : imageSubobject f ≤ Subobject.mk g :=
imageSubobject_le f (h ≫ (Subobject.underlyingIso g).inv) (by simp [w])
/-- Given a commutative square between morphisms `f` and `g`,
we have a morphism in the category from `imageSubobject f` to `imageSubobject g`. -/
def imageSubobjectMap {W X Y Z : C} {f : W ⟶ X} [HasImage f] {g : Y ⟶ Z} [HasImage g]
(sq : Arrow.mk f ⟶ Arrow.mk g) [HasImageMap sq] :
(imageSubobject f : C) ⟶ (imageSubobject g : C) :=
(imageSubobjectIso f).hom ≫ image.map sq ≫ (imageSubobjectIso g).inv
@[reassoc (attr := simp)]
theorem imageSubobjectMap_arrow {W X Y Z : C} {f : W ⟶ X} [HasImage f] {g : Y ⟶ Z} [HasImage g]
(sq : Arrow.mk f ⟶ Arrow.mk g) [HasImageMap sq] :
imageSubobjectMap sq ≫ (imageSubobject g).arrow = (imageSubobject f).arrow ≫ sq.right := by
simp only [imageSubobjectMap, Category.assoc, imageSubobject_arrow']
erw [image.map_ι, ← Category.assoc, imageSubobject_arrow]
theorem image_map_comp_imageSubobjectIso_inv {W X Y Z : C} {f : W ⟶ X} [HasImage f] {g : Y ⟶ Z}
[HasImage g] (sq : Arrow.mk f ⟶ Arrow.mk g) [HasImageMap sq] :
image.map sq ≫ (imageSubobjectIso _).inv =
(imageSubobjectIso _).inv ≫ imageSubobjectMap sq := by
ext
simpa using image.map_ι sq
theorem imageSubobjectIso_comp_image_map {W X Y Z : C} {f : W ⟶ X} [HasImage f] {g : Y ⟶ Z}
[HasImage g] (sq : Arrow.mk f ⟶ Arrow.mk g) [HasImageMap sq] :
(imageSubobjectIso _).hom ≫ image.map sq =
imageSubobjectMap sq ≫ (imageSubobjectIso _).hom := by
erw [← Iso.comp_inv_eq, Category.assoc, ← (imageSubobjectIso f).eq_inv_comp,
image_map_comp_imageSubobjectIso_inv sq]
end Image
end Limits
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Subobject/Lattice.lean | import Mathlib.CategoryTheory.Functor.Currying
import Mathlib.CategoryTheory.Subobject.FactorThru
import Mathlib.CategoryTheory.Subobject.WellPowered
import Mathlib.Data.Finset.Lattice.Fold
/-!
# The lattice of subobjects
We provide the `SemilatticeInf` with `OrderTop (Subobject X)` instance when `[HasPullback C]`,
and the `SemilatticeSup (Subobject X)` instance when `[HasImages C] [HasBinaryCoproducts C]`.
-/
universe w v₁ v₂ u₁ u₂
noncomputable section
open CategoryTheory CategoryTheory.Category CategoryTheory.Limits
variable {C : Type u₁} [Category.{v₁} C] {X Y Z : C}
variable {D : Type u₂} [Category.{v₂} D]
namespace CategoryTheory
namespace MonoOver
section Top
instance {X : C} : Top (MonoOver X) where top := mk' (𝟙 _)
instance {X : C} : Inhabited (MonoOver X) :=
⟨⊤⟩
/-- The morphism to the top object in `MonoOver X`. -/
def leTop (f : MonoOver X) : f ⟶ ⊤ :=
homMk f.arrow (comp_id _)
@[simp]
theorem top_left (X : C) : ((⊤ : MonoOver X) : C) = X :=
rfl
@[simp]
theorem top_arrow (X : C) : (⊤ : MonoOver X).arrow = 𝟙 X :=
rfl
/-- `map f` sends `⊤ : MonoOver X` to `⟨X, f⟩ : MonoOver Y`. -/
def mapTop (f : X ⟶ Y) [Mono f] : (map f).obj ⊤ ≅ mk' f :=
iso_of_both_ways (homMk (𝟙 _) rfl) (homMk (𝟙 _) (by simp [id_comp f]))
section
variable [HasPullbacks C]
/-- The pullback of the top object in `MonoOver Y`
is (isomorphic to) the top object in `MonoOver X`. -/
def pullbackTop (f : X ⟶ Y) : (pullback f).obj ⊤ ≅ ⊤ :=
iso_of_both_ways (leTop _)
(homMk (pullback.lift f (𝟙 _) (by simp)) (pullback.lift_snd _ _ _))
/-- There is a morphism from `⊤ : MonoOver A` to the pullback of a monomorphism along itself;
as the category is thin this is an isomorphism. -/
def topLEPullbackSelf {A B : C} (f : A ⟶ B) [Mono f] :
(⊤ : MonoOver A) ⟶ (pullback f).obj (mk' f) :=
homMk _ (pullback.lift_snd _ _ rfl)
/-- The pullback of a monomorphism along itself is isomorphic to the top object. -/
def pullbackSelf {A B : C} (f : A ⟶ B) [Mono f] : (pullback f).obj (mk' f) ≅ ⊤ :=
iso_of_both_ways (leTop _) (topLEPullbackSelf _)
end
end Top
section Bot
variable [HasInitial C] [InitialMonoClass C]
instance {X : C} : Bot (MonoOver X) where bot := mk' (initial.to X)
@[simp]
theorem bot_left (X : C) : ((⊥ : MonoOver X) : C) = ⊥_ C :=
rfl
@[simp]
theorem bot_arrow {X : C} : (⊥ : MonoOver X).arrow = initial.to X :=
rfl
/-- The (unique) morphism from `⊥ : MonoOver X` to any other `f : MonoOver X`. -/
def botLE {X : C} (f : MonoOver X) : ⊥ ⟶ f :=
homMk (initial.to _)
/-- `map f` sends `⊥ : MonoOver X` to `⊥ : MonoOver Y`. -/
def mapBot (f : X ⟶ Y) [Mono f] : (map f).obj ⊥ ≅ ⊥ :=
iso_of_both_ways (homMk (initial.to _)) (homMk (𝟙 _))
end Bot
section ZeroOrderBot
variable [HasZeroObject C]
open ZeroObject
/-- The object underlying `⊥ : Subobject B` is (up to isomorphism) the zero object. -/
def botCoeIsoZero {B : C} : ((⊥ : MonoOver B) : C) ≅ 0 :=
initialIsInitial.uniqueUpToIso HasZeroObject.zeroIsInitial
theorem bot_arrow_eq_zero [HasZeroMorphisms C] {B : C} : (⊥ : MonoOver B).arrow = 0 :=
zero_of_source_iso_zero _ botCoeIsoZero
/-- `simp`-normal form of `bot_arrow_eq_zero`. -/
@[simp]
theorem initialTo_b_eq_zero [HasZeroMorphisms C] {B : C} : initial.to B = 0 := by
rw [← bot_arrow, bot_arrow_eq_zero]
end ZeroOrderBot
section Inf
variable [HasPullbacks C]
/-- When `[HasPullbacks C]`, `MonoOver A` has "intersections", functorial in both arguments.
As `MonoOver A` is only a preorder, this doesn't satisfy the axioms of `SemilatticeInf`,
but we reuse all the names from `SemilatticeInf` because they will be used to construct
`SemilatticeInf (subobject A)` shortly.
-/
@[simps]
def inf {A : C} : MonoOver A ⥤ MonoOver A ⥤ MonoOver A where
obj f := pullback f.arrow ⋙ map f.arrow
map k :=
{ app := fun g => by
apply homMk _ _
· apply pullback.lift (pullback.fst _ _) (pullback.snd _ _ ≫ k.left) _
rw [pullback.condition, assoc, w k]
dsimp
rw [pullback.lift_snd_assoc, assoc, w k] }
/-- A morphism from the "infimum" of two objects in `MonoOver A` to the first object. -/
def infLELeft {A : C} (f g : MonoOver A) : (inf.obj f).obj g ⟶ f :=
homMk _ rfl
/-- A morphism from the "infimum" of two objects in `MonoOver A` to the second object. -/
def infLERight {A : C} (f g : MonoOver A) : (inf.obj f).obj g ⟶ g :=
homMk _ pullback.condition
/-- A morphism version of the `le_inf` axiom. -/
def leInf {A : C} (f g h : MonoOver A) : (h ⟶ f) → (h ⟶ g) → (h ⟶ (inf.obj f).obj g) := by
intro k₁ k₂
refine homMk (pullback.lift k₂.left k₁.left ?_) ?_
· rw [w k₁, w k₂]
· erw [pullback.lift_snd_assoc, w k₁]
end Inf
section Sup
variable [HasImages C] [HasBinaryCoproducts C]
/-- When `[HasImages C] [HasBinaryCoproducts C]`, `MonoOver A` has a `sup` construction,
which is functorial in both arguments,
and which on `Subobject A` will induce a `SemilatticeSup`. -/
def sup {A : C} : MonoOver A ⥤ MonoOver A ⥤ MonoOver A :=
Functor.curryObj ((forget A).prod (forget A) ⋙ Functor.uncurry.obj Over.coprod ⋙ image)
/-- A morphism version of `le_sup_left`. -/
def leSupLeft {A : C} (f g : MonoOver A) : f ⟶ (sup.obj f).obj g := by
refine homMk (coprod.inl ≫ factorThruImage _) ?_
erw [Category.assoc, image.fac, coprod.inl_desc]
rfl
/-- A morphism version of `le_sup_right`. -/
def leSupRight {A : C} (f g : MonoOver A) : g ⟶ (sup.obj f).obj g := by
refine homMk (coprod.inr ≫ factorThruImage _) ?_
erw [Category.assoc, image.fac, coprod.inr_desc]
rfl
/-- A morphism version of `sup_le`. -/
def supLe {A : C} (f g h : MonoOver A) : (f ⟶ h) → (g ⟶ h) → ((sup.obj f).obj g ⟶ h) := by
intro k₁ k₂
refine homMk ?_ ?_
· apply image.lift ⟨_, h.arrow, coprod.desc k₁.left k₂.left, _⟩
ext
· simp [w k₁]
· simp [w k₂]
· apply image.lift_fac
end Sup
end MonoOver
namespace Subobject
section OrderTop
instance orderTop {X : C} : OrderTop (Subobject X) where
top := Quotient.mk'' ⊤
le_top := by
refine Quotient.ind' fun f => ?_
exact ⟨MonoOver.leTop f⟩
instance {X : C} : Inhabited (Subobject X) :=
⟨⊤⟩
theorem top_eq_id (B : C) : (⊤ : Subobject B) = Subobject.mk (𝟙 B) :=
rfl
theorem underlyingIso_top_hom {B : C} : (underlyingIso (𝟙 B)).hom = (⊤ : Subobject B).arrow := by
convert underlyingIso_hom_comp_eq_mk (𝟙 B)
simp only [comp_id]
instance top_arrow_isIso {B : C} : IsIso (⊤ : Subobject B).arrow := by
rw [← underlyingIso_top_hom]
infer_instance
@[reassoc (attr := simp)]
theorem underlyingIso_inv_top_arrow {B : C} :
(underlyingIso _).inv ≫ (⊤ : Subobject B).arrow = 𝟙 B :=
underlyingIso_arrow _
@[simp]
theorem map_top (f : X ⟶ Y) [Mono f] : (map f).obj ⊤ = Subobject.mk f :=
Quotient.sound' ⟨MonoOver.mapTop f⟩
theorem top_factors {A B : C} (f : A ⟶ B) : (⊤ : Subobject B).Factors f :=
⟨f, comp_id _⟩
theorem isIso_iff_mk_eq_top {X Y : C} (f : X ⟶ Y) [Mono f] : IsIso f ↔ mk f = ⊤ :=
⟨fun _ => mk_eq_mk_of_comm _ _ (asIso f) (Category.comp_id _), fun h => by
rw [← ofMkLEMk_comp h.le, Category.comp_id]
exact (isoOfMkEqMk _ _ h).isIso_hom⟩
theorem isIso_arrow_iff_eq_top {Y : C} (P : Subobject Y) : IsIso P.arrow ↔ P = ⊤ := by
rw [isIso_iff_mk_eq_top, mk_arrow]
instance isIso_top_arrow {Y : C} : IsIso (⊤ : Subobject Y).arrow := by rw [isIso_arrow_iff_eq_top]
theorem mk_eq_top_of_isIso {X Y : C} (f : X ⟶ Y) [IsIso f] : mk f = ⊤ :=
(isIso_iff_mk_eq_top f).mp inferInstance
theorem eq_top_of_isIso_arrow {Y : C} (P : Subobject Y) [IsIso P.arrow] : P = ⊤ :=
(isIso_arrow_iff_eq_top P).mp inferInstance
lemma epi_iff_mk_eq_top [Balanced C] (f : X ⟶ Y) [Mono f] :
Epi f ↔ Subobject.mk f = ⊤ := by
rw [← isIso_iff_mk_eq_top]
exact ⟨fun _ ↦ isIso_of_mono_of_epi f, fun _ ↦ inferInstance⟩
section
variable [HasPullbacks C]
theorem pullback_top (f : X ⟶ Y) : (pullback f).obj ⊤ = ⊤ :=
Quotient.sound' ⟨MonoOver.pullbackTop f⟩
theorem pullback_self {A B : C} (f : A ⟶ B) [Mono f] : (pullback f).obj (mk f) = ⊤ :=
Quotient.sound' ⟨MonoOver.pullbackSelf f⟩
end
end OrderTop
section OrderBot
variable [HasInitial C] [InitialMonoClass C]
instance orderBot {X : C} : OrderBot (Subobject X) where
bot := Quotient.mk'' ⊥
bot_le := by
refine Quotient.ind' fun f => ?_
exact ⟨MonoOver.botLE f⟩
theorem bot_eq_initial_to {B : C} : (⊥ : Subobject B) = Subobject.mk (initial.to B) :=
rfl
/-- The object underlying `⊥ : Subobject B` is (up to isomorphism) the initial object. -/
def botCoeIsoInitial {B : C} : ((⊥ : Subobject B) : C) ≅ ⊥_ C :=
underlyingIso _
theorem map_bot (f : X ⟶ Y) [Mono f] : (map f).obj ⊥ = ⊥ :=
Quotient.sound' ⟨MonoOver.mapBot f⟩
end OrderBot
section ZeroOrderBot
variable [HasZeroObject C]
open ZeroObject
/-- The object underlying `⊥ : Subobject B` is (up to isomorphism) the zero object. -/
def botCoeIsoZero {B : C} : ((⊥ : Subobject B) : C) ≅ 0 :=
botCoeIsoInitial ≪≫ initialIsInitial.uniqueUpToIso HasZeroObject.zeroIsInitial
variable [HasZeroMorphisms C]
theorem bot_eq_zero {B : C} : (⊥ : Subobject B) = Subobject.mk (0 : 0 ⟶ B) :=
mk_eq_mk_of_comm _ _ (initialIsInitial.uniqueUpToIso HasZeroObject.zeroIsInitial)
(by simp)
@[simp]
theorem bot_arrow {B : C} : (⊥ : Subobject B).arrow = 0 :=
zero_of_source_iso_zero _ botCoeIsoZero
theorem bot_factors_iff_zero {A B : C} (f : A ⟶ B) : (⊥ : Subobject B).Factors f ↔ f = 0 :=
⟨by
rintro ⟨h, rfl⟩
simp only [MonoOver.bot_arrow_eq_zero, MonoOver.bot_left, comp_zero],
by
rintro rfl
exact ⟨0, by simp⟩⟩
theorem mk_eq_bot_iff_zero {f : X ⟶ Y} [Mono f] : Subobject.mk f = ⊥ ↔ f = 0 :=
⟨fun h => by simpa [h, bot_factors_iff_zero] using mk_factors_self f, fun h =>
mk_eq_mk_of_comm _ _ ((isoZeroOfMonoEqZero h).trans HasZeroObject.zeroIsoInitial) (by simp [h])⟩
end ZeroOrderBot
section Functor
variable (C)
/-- Sending `X : C` to `Subobject X` is a contravariant functor `Cᵒᵖ ⥤ Type`. -/
@[simps]
def functor [HasPullbacks C] : Cᵒᵖ ⥤ Type max u₁ v₁ where
obj X := Subobject X.unop
map f := (pullback f.unop).obj
map_id _ := funext pullback_id
map_comp _ _ := funext (pullback_comp _ _)
end Functor
section SemilatticeInfTop
variable [HasPullbacks C]
/-- The functorial infimum on `MonoOver A` descends to an infimum on `Subobject A`. -/
def inf {A : C} : Subobject A ⥤ Subobject A ⥤ Subobject A :=
ThinSkeleton.map₂ MonoOver.inf
theorem inf_le_left {A : C} (f g : Subobject A) : (inf.obj f).obj g ≤ f :=
Quotient.inductionOn₂' f g fun _ _ => ⟨MonoOver.infLELeft _ _⟩
theorem inf_le_right {A : C} (f g : Subobject A) : (inf.obj f).obj g ≤ g :=
Quotient.inductionOn₂' f g fun _ _ => ⟨MonoOver.infLERight _ _⟩
theorem le_inf {A : C} (h f g : Subobject A) : h ≤ f → h ≤ g → h ≤ (inf.obj f).obj g :=
Quotient.inductionOn₃' h f g
(by
rintro f g h ⟨k⟩ ⟨l⟩
exact ⟨MonoOver.leInf _ _ _ k l⟩)
instance semilatticeInf {B : C} : SemilatticeInf (Subobject B) where
inf := fun m n => (inf.obj m).obj n
inf_le_left := inf_le_left
inf_le_right := inf_le_right
le_inf := le_inf
theorem factors_left_of_inf_factors {A B : C} {X Y : Subobject B} {f : A ⟶ B}
(h : (X ⊓ Y).Factors f) : X.Factors f :=
factors_of_le _ (inf_le_left _ _) h
theorem factors_right_of_inf_factors {A B : C} {X Y : Subobject B} {f : A ⟶ B}
(h : (X ⊓ Y).Factors f) : Y.Factors f :=
factors_of_le _ (inf_le_right _ _) h
@[simp]
theorem inf_factors {A B : C} {X Y : Subobject B} (f : A ⟶ B) :
(X ⊓ Y).Factors f ↔ X.Factors f ∧ Y.Factors f :=
⟨fun h => ⟨factors_left_of_inf_factors h, factors_right_of_inf_factors h⟩, by
revert X Y
apply Quotient.ind₂'
rintro X Y ⟨⟨g₁, rfl⟩, ⟨g₂, hg₂⟩⟩
exact ⟨_, pullback.lift_snd_assoc _ _ hg₂ _⟩⟩
theorem inf_arrow_factors_left {B : C} (X Y : Subobject B) : X.Factors (X ⊓ Y).arrow :=
(factors_iff _ _).mpr ⟨ofLE (X ⊓ Y) X (inf_le_left X Y), by simp⟩
theorem inf_arrow_factors_right {B : C} (X Y : Subobject B) : Y.Factors (X ⊓ Y).arrow :=
(factors_iff _ _).mpr ⟨ofLE (X ⊓ Y) Y (inf_le_right X Y), by simp⟩
@[simp]
theorem finset_inf_factors {I : Type*} {A B : C} {s : Finset I} {P : I → Subobject B} (f : A ⟶ B) :
(s.inf P).Factors f ↔ ∀ i ∈ s, (P i).Factors f := by
classical
induction s using Finset.induction_on with
| empty => simp [top_factors]
| insert _ _ _ ih => simp [ih]
-- `i` is explicit here because often we'd like to defer a proof of `m`
theorem finset_inf_arrow_factors {I : Type*} {B : C} (s : Finset I) (P : I → Subobject B) (i : I)
(m : i ∈ s) : (P i).Factors (s.inf P).arrow := by
classical
revert i m
induction s using Finset.induction_on with
| empty => rintro _ ⟨⟩
| insert _ _ _ ih =>
intro _ m
rw [Finset.inf_insert]
simp only [Finset.mem_insert] at m
rcases m with (rfl | m)
· rw [← factorThru_arrow _ _ (inf_arrow_factors_left _ _)]
exact factors_comp_arrow _
· rw [← factorThru_arrow _ _ (inf_arrow_factors_right _ _)]
apply factors_of_factors_right
exact ih _ m
theorem inf_eq_map_pullback' {A : C} (f₁ : MonoOver A) (f₂ : Subobject A) :
(Subobject.inf.obj (Quotient.mk'' f₁)).obj f₂ =
(Subobject.map f₁.arrow).obj ((Subobject.pullback f₁.arrow).obj f₂) := by
induction f₂ using Quotient.inductionOn'
rfl
theorem inf_eq_map_pullback {A : C} (f₁ : MonoOver A) (f₂ : Subobject A) :
(Quotient.mk'' f₁ ⊓ f₂ : Subobject A) = (map f₁.arrow).obj ((pullback f₁.arrow).obj f₂) :=
inf_eq_map_pullback' f₁ f₂
theorem prod_eq_inf {A : C} {f₁ f₂ : Subobject A} [HasBinaryProduct f₁ f₂] :
(f₁ ⨯ f₂) = f₁ ⊓ f₂ := by
apply le_antisymm
· refine le_inf _ _ _ (Limits.prod.fst.le) (Limits.prod.snd.le)
· apply leOfHom
exact prod.lift (inf_le_left _ _).hom (inf_le_right _ _).hom
theorem inf_def {B : C} (m m' : Subobject B) : m ⊓ m' = (inf.obj m).obj m' :=
rfl
/-- `⊓` commutes with pullback. -/
theorem inf_pullback {X Y : C} (g : X ⟶ Y) (f₁ f₂) :
(pullback g).obj (f₁ ⊓ f₂) = (pullback g).obj f₁ ⊓ (pullback g).obj f₂ := by
revert f₁
apply Quotient.ind'
intro f₁
erw [inf_def, inf_def, inf_eq_map_pullback', inf_eq_map_pullback', ← pullback_comp, ←
map_pullback pullback.condition (pullbackIsPullback f₁.arrow g), ← pullback_comp,
pullback.condition]
rfl
/-- `⊓` commutes with map. -/
theorem inf_map {X Y : C} (g : Y ⟶ X) [Mono g] (f₁ f₂) :
(map g).obj (f₁ ⊓ f₂) = (map g).obj f₁ ⊓ (map g).obj f₂ := by
revert f₁
apply Quotient.ind'
intro f₁
erw [inf_def, inf_def, inf_eq_map_pullback', inf_eq_map_pullback', ← map_comp]
dsimp
rw [pullback_comp, pullback_map_self]
end SemilatticeInfTop
section SemilatticeSup
variable [HasImages C] [HasBinaryCoproducts C]
/-- The functorial supremum on `MonoOver A` descends to a supremum on `Subobject A`. -/
def sup {A : C} : Subobject A ⥤ Subobject A ⥤ Subobject A :=
ThinSkeleton.map₂ MonoOver.sup
instance semilatticeSup {B : C} : SemilatticeSup (Subobject B) where
sup := fun m n => (sup.obj m).obj n
le_sup_left := fun m n => Quotient.inductionOn₂' m n fun _ _ => ⟨MonoOver.leSupLeft _ _⟩
le_sup_right := fun m n => Quotient.inductionOn₂' m n fun _ _ => ⟨MonoOver.leSupRight _ _⟩
sup_le := fun m n k =>
Quotient.inductionOn₃' m n k fun _ _ _ ⟨i⟩ ⟨j⟩ => ⟨MonoOver.supLe _ _ _ i j⟩
theorem sup_factors_of_factors_left {A B : C} {X Y : Subobject B} {f : A ⟶ B} (P : X.Factors f) :
(X ⊔ Y).Factors f :=
factors_of_le f le_sup_left P
theorem sup_factors_of_factors_right {A B : C} {X Y : Subobject B} {f : A ⟶ B} (P : Y.Factors f) :
(X ⊔ Y).Factors f :=
factors_of_le f le_sup_right P
variable [HasInitial C] [InitialMonoClass C]
theorem finset_sup_factors {I : Type*} {A B : C} {s : Finset I} {P : I → Subobject B} {f : A ⟶ B}
(h : ∃ i ∈ s, (P i).Factors f) : (s.sup P).Factors f := by
classical
revert h
induction s using Finset.induction_on with
| empty => rintro ⟨_, ⟨⟨⟩, _⟩⟩
| insert _ _ _ ih =>
rintro ⟨j, ⟨m, h⟩⟩
simp only [Finset.sup_insert]
simp only [Finset.mem_insert] at m
rcases m with (rfl | m)
· exact sup_factors_of_factors_left h
· exact sup_factors_of_factors_right (ih ⟨j, ⟨m, h⟩⟩)
end SemilatticeSup
section Lattice
instance boundedOrder [HasInitial C] [InitialMonoClass C] {B : C} : BoundedOrder (Subobject B) :=
{ Subobject.orderTop, Subobject.orderBot with }
variable [HasPullbacks C] [HasImages C] [HasBinaryCoproducts C]
instance {B : C} : Lattice (Subobject B) :=
{ Subobject.semilatticeInf, Subobject.semilatticeSup with }
end Lattice
section Inf
variable [LocallySmall.{w} C] [WellPowered.{w} C]
/-- The "wide cospan" diagram, with a small indexing type, constructed from a set of subobjects.
(This is just the diagram of all the subobjects pasted together, but using `WellPowered C`
to make the diagram small.)
-/
def wideCospan {A : C} (s : Set (Subobject A)) : WidePullbackShape (equivShrink _ '' s) ⥤ C :=
WidePullbackShape.wideCospan A
(fun j : equivShrink _ '' s => ((equivShrink (Subobject A)).symm j : C)) fun j =>
((equivShrink (Subobject A)).symm j).arrow
@[simp]
theorem wideCospan_map_term {A : C} (s : Set (Subobject A)) (j) :
(wideCospan s).map (WidePullbackShape.Hom.term j) =
((equivShrink (Subobject A)).symm j).arrow :=
rfl
/-- Auxiliary construction of a cone for `le_inf`. -/
def leInfCone {A : C} (s : Set (Subobject A)) (f : Subobject A) (k : ∀ g ∈ s, f ≤ g) :
Cone (wideCospan s) :=
WidePullbackShape.mkCone f.arrow
(fun j =>
underlying.map
(homOfLE
(k _
(by
rcases j with ⟨-, ⟨g, ⟨m, rfl⟩⟩⟩
simpa using m))))
(by simp)
@[simp]
theorem leInfCone_π_app_none {A : C} (s : Set (Subobject A)) (f : Subobject A)
(k : ∀ g ∈ s, f ≤ g) : (leInfCone s f k).π.app none = f.arrow :=
rfl
variable [HasWidePullbacks.{w} C]
/-- The limit of `wideCospan s`. (This will be the supremum of the set of subobjects.)
-/
def widePullback {A : C} (s : Set (Subobject A)) : C :=
Limits.limit (wideCospan s)
/-- The inclusion map from `widePullback s` to `A`
-/
def widePullbackι {A : C} (s : Set (Subobject A)) : widePullback s ⟶ A :=
Limits.limit.π (wideCospan s) none
instance widePullbackι_mono {A : C} (s : Set (Subobject A)) : Mono (widePullbackι s) :=
⟨fun u v h =>
limit.hom_ext fun j => by
cases j
· exact h
· apply (cancel_mono ((equivShrink (Subobject A)).symm _).arrow).1
rw [assoc, assoc]
erw [limit.w (wideCospan s) (WidePullbackShape.Hom.term _)]
exact h⟩
/-- When `[WellPowered C]` and `[HasWidePullbacks C]`, `Subobject A` has arbitrary infimums.
-/
def sInf {A : C} (s : Set (Subobject A)) : Subobject A :=
Subobject.mk (widePullbackι s)
theorem sInf_le {A : C} (s : Set (Subobject A)) (f) (hf : f ∈ s) : sInf s ≤ f := by
fapply le_of_comm
· exact (underlyingIso _).hom ≫
Limits.limit.π (wideCospan s)
(some ⟨equivShrink (Subobject A) f,
Set.mem_image_of_mem (equivShrink (Subobject A)) hf⟩) ≫
eqToHom (congr_arg (fun X : Subobject A => (X : C)) (Equiv.symm_apply_apply _ _))
· dsimp [sInf]
simp only [Category.assoc, ← underlyingIso_hom_comp_eq_mk,
Iso.cancel_iso_hom_left]
convert limit.w (wideCospan s) (WidePullbackShape.Hom.term _)
simp
theorem le_sInf {A : C} (s : Set (Subobject A)) (f : Subobject A) (k : ∀ g ∈ s, f ≤ g) :
f ≤ sInf s := by
fapply le_of_comm
· exact Limits.limit.lift _ (leInfCone s f k) ≫ (underlyingIso _).inv
· dsimp [sInf]
rw [assoc, underlyingIso_arrow, widePullbackι, limit.lift_π, leInfCone_π_app_none]
instance completeSemilatticeInf {B : C} : CompleteSemilatticeInf (Subobject B) where
sInf := sInf
sInf_le := sInf_le
le_sInf := le_sInf
end Inf
section Sup
variable [LocallySmall.{w} C] [WellPowered.{w} C] [HasCoproducts.{w} C]
/-- The universal morphism out of the coproduct of a set of subobjects,
after using `[WellPowered C]` to reindex by a small type.
-/
def smallCoproductDesc {A : C} (s : Set (Subobject A)) :=
Limits.Sigma.desc fun j : equivShrink _ '' s => ((equivShrink (Subobject A)).symm j).arrow
variable [HasImages C]
/-- When `[WellPowered C] [HasImages C] [HasCoproducts C]`,
`Subobject A` has arbitrary supremums. -/
def sSup {A : C} (s : Set (Subobject A)) : Subobject A :=
Subobject.mk (image.ι (smallCoproductDesc s))
theorem le_sSup {A : C} (s : Set (Subobject A)) (f) (hf : f ∈ s) : f ≤ sSup s := by
fapply le_of_comm
· refine eqToHom ?_ ≫ Sigma.ι _ ⟨equivShrink (Subobject A) f, by simpa [Set.mem_image] using hf⟩
≫ factorThruImage _ ≫ (underlyingIso _).inv
exact (congr_arg (fun X : Subobject A => (X : C)) (Equiv.symm_apply_apply _ _).symm)
· simp [sSup, smallCoproductDesc]
theorem symm_apply_mem_iff_mem_image {α β : Type*} (e : α ≃ β) (s : Set α) (x : β) :
e.symm x ∈ s ↔ x ∈ e '' s :=
⟨fun h => ⟨e.symm x, h, by simp⟩, by
rintro ⟨a, m, rfl⟩
simpa using m⟩
theorem sSup_le {A : C} (s : Set (Subobject A)) (f : Subobject A) (k : ∀ g ∈ s, g ≤ f) :
sSup s ≤ f := by
fapply le_of_comm
· refine(underlyingIso _).hom ≫ image.lift ⟨_, f.arrow, ?_, ?_⟩
· refine Sigma.desc ?_
rintro ⟨g, m⟩
refine underlying.map (homOfLE (k _ ?_))
simpa using m
· ext
dsimp [smallCoproductDesc]
simp
· dsimp [sSup]
rw [assoc, image.lift_fac, underlyingIso_hom_comp_eq_mk]
instance completeSemilatticeSup {B : C} : CompleteSemilatticeSup (Subobject B) where
sSup := sSup
le_sSup := le_sSup
sSup_le := sSup_le
end Sup
section CompleteLattice
variable [LocallySmall.{w} C] [WellPowered.{w} C] [HasWidePullbacks.{w} C]
[HasImages C] [HasCoproducts.{w} C] [InitialMonoClass C]
attribute [local instance] has_smallest_coproducts_of_hasCoproducts
instance {B : C} : CompleteLattice (Subobject B) :=
{ Subobject.semilatticeInf, Subobject.semilatticeSup, Subobject.boundedOrder,
Subobject.completeSemilatticeInf, Subobject.completeSemilatticeSup with }
end CompleteLattice
lemma subsingleton_of_isInitial {X : C} (hX : IsInitial X) : Subsingleton (Subobject X) := by
suffices ∀ (S : Subobject X), S = .mk (𝟙 _) from ⟨by simp [this]⟩
intro S
obtain ⟨A, i, _, rfl⟩ := S.mk_surjective
have fac : hX.to A ≫ i = 𝟙 X := hX.hom_ext _ _
let e : A ≅ X :=
{ hom := i
inv := hX.to A
hom_inv_id := by rw [← cancel_mono i, assoc, fac, id_comp, comp_id]
inv_hom_id := fac }
exact mk_eq_mk_of_comm i (𝟙 X) e (by simp [e])
lemma subsingleton_of_isZero {X : C} (hX : IsZero X) : Subsingleton (Subobject X) :=
subsingleton_of_isInitial hX.isInitial
section ZeroObject
variable [HasZeroMorphisms C] [HasZeroObject C]
open ZeroObject
/-- A nonzero object has nontrivial subobject lattice. -/
theorem nontrivial_of_not_isZero {X : C} (h : ¬IsZero X) : Nontrivial (Subobject X) :=
⟨⟨mk (0 : 0 ⟶ X), mk (𝟙 X), fun w => h (IsZero.of_iso (isZero_zero C) (isoOfMkEqMk _ _ w).symm)⟩⟩
end ZeroObject
section SubobjectSubobject
/-- The subobject lattice of a subobject `Y` is order isomorphic to the interval `Set.Iic Y`. -/
def subobjectOrderIso {X : C} (Y : Subobject X) : Subobject (Y : C) ≃o Set.Iic Y where
toFun Z :=
⟨Subobject.mk (Z.arrow ≫ Y.arrow),
Set.mem_Iic.mpr (le_of_comm ((underlyingIso _).hom ≫ Z.arrow) (by simp))⟩
invFun Z := Subobject.mk (ofLE _ _ Z.2)
left_inv Z := mk_eq_of_comm _ (underlyingIso _) (by cat_disch)
right_inv Z := Subtype.ext (mk_eq_of_comm _ (underlyingIso _) (by simp [← Iso.eq_inv_comp]))
map_rel_iff' {W Z} := by
dsimp
constructor
· intro h
exact le_of_comm (((underlyingIso _).inv ≫ ofLE _ _ (Subtype.mk_le_mk.mp h) ≫
(underlyingIso _).hom)) (by cat_disch)
· intro h
exact Subtype.mk_le_mk.mpr (le_of_comm
((underlyingIso _).hom ≫ ofLE _ _ h ≫ (underlyingIso _).inv) (by simp))
end SubobjectSubobject
end Subobject
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/FinCategory/AsType.lean | import Mathlib.CategoryTheory.FinCategory.Basic
import Mathlib.Data.Fintype.EquivFin
/-!
# Finite categories are equivalent to category in `Type 0`.
-/
universe w v u
noncomputable section
namespace CategoryTheory
namespace FinCategory
variable (α : Type*) [Fintype α] [SmallCategory α] [FinCategory α]
/-- A FinCategory `α` is equivalent to a category with objects in `Type`. -/
--@[nolint unused_arguments]
abbrev ObjAsType : Type :=
InducedCategory α (Fintype.equivFin α).symm
instance {i j : ObjAsType α} : Fintype (i ⟶ j) :=
FinCategory.fintypeHom ((Fintype.equivFin α).symm i) _
/-- The constructed category is indeed equivalent to `α`. -/
noncomputable def objAsTypeEquiv : ObjAsType α ≌ α :=
(inducedFunctor (Fintype.equivFin α).symm).asEquivalence
/-- A FinCategory `α` is equivalent to a fin_category with in `Type`. -/
--@[nolint unused_arguments]
abbrev AsType : Type :=
Fin (Fintype.card α)
@[simps -isSimp id comp]
noncomputable instance categoryAsType : SmallCategory (AsType α) where
Hom i j := Fin (Fintype.card (@Quiver.Hom (ObjAsType α) _ i j))
id _ := Fintype.equivFin _ (𝟙 _)
comp f g := Fintype.equivFin _ ((Fintype.equivFin _).symm f ≫ (Fintype.equivFin _).symm g)
attribute [local simp] categoryAsType_id categoryAsType_comp
/-- The "identity" functor from `AsType α` to `ObjAsType α`. -/
@[simps]
noncomputable def asTypeToObjAsType : AsType α ⥤ ObjAsType α where
obj := id
map {_ _} := (Fintype.equivFin _).symm
/-- The "identity" functor from `ObjAsType α` to `AsType α`. -/
@[simps]
noncomputable def objAsTypeToAsType : ObjAsType α ⥤ AsType α where
obj := id
map {_ _} := Fintype.equivFin _
/-- The constructed category (`AsType α`) is equivalent to `ObjAsType α`. -/
noncomputable def asTypeEquivObjAsType : AsType α ≌ ObjAsType α where
functor := asTypeToObjAsType α
inverse := objAsTypeToAsType α
unitIso := NatIso.ofComponents Iso.refl
counitIso := NatIso.ofComponents Iso.refl
noncomputable instance asTypeFinCategory : FinCategory (AsType α) where
fintypeHom := fun _ _ => show Fintype (Fin _) from inferInstance
/-- The constructed category (`ObjAsType α`) is indeed equivalent to `α`. -/
noncomputable def equivAsType : AsType α ≌ α :=
(asTypeEquivObjAsType α).trans (objAsTypeEquiv α)
end FinCategory
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/FinCategory/Basic.lean | import Mathlib.Data.Fintype.Basic
import Mathlib.CategoryTheory.Discrete.Basic
import Mathlib.CategoryTheory.Opposites
import Mathlib.CategoryTheory.Category.ULift
/-!
# Finite categories
A category is finite in this sense if it has finitely many objects, and finitely many morphisms.
## Implementation
Prior to https://github.com/leanprover-community/mathlib4/pull/14046, `FinCategory` required a `DecidableEq` instance on the object and morphism types.
This does not seem to have had any practical payoff (i.e. making some definition constructive)
so we have removed these requirements to avoid
having to supply instances or delay with non-defeq conflicts between instances.
-/
universe w v u
noncomputable section
namespace CategoryTheory
instance discreteFintype {α : Type*} [Fintype α] : Fintype (Discrete α) :=
Fintype.ofEquiv α discreteEquiv.symm
instance discreteHomFintype {α : Type*} (X Y : Discrete α) : Fintype (X ⟶ Y) := by
classical
apply ULift.fintype
/-- A category with a `Fintype` of objects, and a `Fintype` for each morphism space. -/
class FinCategory (J : Type v) [SmallCategory J] where
fintypeObj : Fintype J := by infer_instance
fintypeHom : ∀ j j' : J, Fintype (j ⟶ j') := by infer_instance
attribute [instance] FinCategory.fintypeObj FinCategory.fintypeHom
instance finCategoryDiscreteOfFintype (J : Type v) [Fintype J] : FinCategory (Discrete J) where
open Opposite
/-- The opposite of a finite category is finite.
-/
instance finCategoryOpposite {J : Type v} [SmallCategory J] [FinCategory J] : FinCategory Jᵒᵖ where
fintypeObj := Fintype.ofEquiv _ equivToOpposite
fintypeHom j j' := Fintype.ofEquiv _ (opEquiv j j').symm
attribute [local instance] uliftCategory in
/-- Applying `ULift` to morphisms and objects of a category preserves finiteness. -/
instance finCategoryUlift {J : Type v} [SmallCategory J] [FinCategory J] :
FinCategory.{max w v} (ULiftHom.{w, max w v} (ULift.{w, v} J)) where
fintypeObj := ULift.fintype J
fintypeHom := fun _ _ => ULift.fintype _
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Adjunction/Parametrized.lean | import Mathlib.CategoryTheory.Adjunction.Basic
/-!
# Adjunctions with a parameter
Given bifunctors `F : C₁ ⥤ C₂ ⥤ C₃` and `G : C₁ᵒᵖ ⥤ C₃ ⥤ C₂`,
this file introduces the notation `F ⊣₂ G` for the adjunctions
with a parameter (in `C₁`) between `F` and `G`.
(See `MonoidalClosed.internalHomAdjunction₂` in the file
`CategoryTheory.Closed.Monoidal` for an example of such an adjunction.)
Note: this notion is weaker than the notion of
"adjunction of two variables" which appears in the mathematical literature.
In order to have an adjunction of two variables, we need
a third functor `H : C₂ᵒᵖ ⥤ C₃ ⥤ C₁` and two adjunctions with
a parameter `F ⊣₂ G` and `F.flip ⊣₂ H`.
## TODO
Show that given `F : C₁ ⥤ C₂ ⥤ C₃`, if `F.obj X₁` has a right adjoint
`G X₁ : C₃ ⥤ C₂` for any `X₁ : C₁`, then `G` extends as a
bifunctor `G' : C₁ᵒᵖ ⥤ C₃ ⥤ C₂` with `F ⊣₂ G'` (and similarly for
left adjoints).
## References
* https://ncatlab.org/nlab/show/two-variable+adjunction
-/
universe v₁ v₂ v₃ u₁ u₂ u₃
namespace CategoryTheory
open Opposite Functor
variable {C₁ : Type u₁} {C₂ : Type u₂} {C₃ : Type u₃}
[Category.{v₁} C₁] [Category.{v₂} C₂] [Category.{v₃} C₃]
(F : C₁ ⥤ C₂ ⥤ C₃) (G : C₁ᵒᵖ ⥤ C₃ ⥤ C₂)
/-- Given bifunctors `F : C₁ ⥤ C₂ ⥤ C₃` and `G : C₁ᵒᵖ ⥤ C₃ ⥤ C₂`,
an adjunction with parameter `F ⊣₂ G` consists of the data of
adjunctions `F.obj X₁ ⊣ G.obj (op X₁)` for all `X₁ : C₁` which
satisfy a naturality condition with respect to `X₁`. -/
structure ParametrizedAdjunction where
/-- a family of adjunctions -/
adj (X₁ : C₁) : F.obj X₁ ⊣ G.obj (op X₁)
unit_whiskerRight_map {X₁ Y₁ : C₁} (f : X₁ ⟶ Y₁) :
(adj X₁).unit ≫ whiskerRight (F.map f) _ = (adj Y₁).unit ≫ whiskerLeft _ (G.map f.op) :=
by cat_disch
/-- The notation `F ⊣₂ G` stands for `ParametrizedAdjunction F G`
representing that the bifunctor `F` is the left adjoint to `G`
in an adjunction with a parameter. -/
infixl:15 " ⊣₂ " => ParametrizedAdjunction
namespace ParametrizedAdjunction
attribute [reassoc] unit_whiskerRight_map
variable {F G}
/-- Alternative constructor for parametrized adjunctions, for which
the compatibility is stated in terms of `Adjunction.homEquiv`. -/
@[simps]
def mk' (adj : ∀ (X₁ : C₁), F.obj X₁ ⊣ G.obj (op X₁))
(h : ∀ {X₁ Y₁ : C₁} (f : X₁ ⟶ Y₁) {X₂ : C₂} {X₃ : C₃} (g : (F.obj Y₁).obj X₂ ⟶ X₃),
(adj X₁).homEquiv X₂ X₃ ((F.map f).app X₂ ≫ g) =
(adj Y₁).homEquiv X₂ X₃ g ≫ (G.map f.op).app X₃ := by cat_disch) :
F ⊣₂ G where
adj := adj
unit_whiskerRight_map {X₁ Y₁} f := by
ext X₂
simpa [Adjunction.homEquiv_unit] using h f (X₂ := X₂) (𝟙 _)
variable (adj₂ : F ⊣₂ G)
{X₁ Y₁ : C₁} {X₂ Y₂ : C₂} {X₃ Y₃ : C₃}
/-- The bijection `((F.obj X₁).obj X₂ ⟶ X₃) ≃ (X₂ ⟶ (G.obj (op X₁)).obj X₃)`
given by an adjunction with a parameter `adj₂ : F ⊣₂ G`. -/
def homEquiv : ((F.obj X₁).obj X₂ ⟶ X₃) ≃ (X₂ ⟶ (G.obj (op X₁)).obj X₃) :=
(adj₂.adj X₁).homEquiv _ _
lemma homEquiv_eq : adj₂.homEquiv = (adj₂.adj X₁).homEquiv X₂ X₃ := rfl
@[reassoc]
lemma homEquiv_naturality_one (f₁ : X₁ ⟶ Y₁) (g : (F.obj Y₁).obj X₂ ⟶ X₃) :
adj₂.homEquiv ((F.map f₁).app X₂ ≫ g) =
adj₂.homEquiv g ≫ (G.map f₁.op).app X₃ := by
have := NatTrans.congr_app (adj₂.unit_whiskerRight_map f₁) X₂
dsimp at this
simp only [homEquiv_eq, Adjunction.homEquiv_unit, Functor.comp_obj, Functor.map_comp,
Category.assoc, NatTrans.naturality, reassoc_of% this]
@[reassoc]
lemma homEquiv_naturality_two (f₂ : X₂ ⟶ Y₂) (g : (F.obj X₁).obj Y₂ ⟶ X₃) :
adj₂.homEquiv ((F.obj X₁).map f₂ ≫ g) = f₂ ≫ adj₂.homEquiv g :=
(adj₂.adj X₁).homEquiv_naturality_left _ _
@[reassoc]
lemma homEquiv_naturality_three (f₃ : X₃ ⟶ Y₃) (g : (F.obj X₁).obj X₂ ⟶ X₃) :
adj₂.homEquiv (g ≫ f₃) = adj₂.homEquiv g ≫ (G.obj (op X₁)).map f₃ :=
(adj₂.adj X₁).homEquiv_naturality_right _ _
@[reassoc]
lemma homEquiv_symm_naturality_one
(f₁ : X₁ ⟶ Y₁) (g : X₂ ⟶ (G.obj (op Y₁)).obj X₃) :
adj₂.homEquiv.symm (g ≫ (G.map f₁.op).app X₃) =
(F.map f₁).app X₂ ≫ adj₂.homEquiv.symm g :=
adj₂.homEquiv.injective (by simp [homEquiv_naturality_one])
@[reassoc]
lemma homEquiv_symm_naturality_two
(f₂ : X₂ ⟶ Y₂) (g : Y₂ ⟶ (G.obj (op X₁)).obj X₃) :
adj₂.homEquiv.symm (f₂ ≫ g) =
(F.obj X₁).map f₂ ≫ adj₂.homEquiv.symm g :=
adj₂.homEquiv.injective (by simp [homEquiv_naturality_two])
@[reassoc]
lemma homEquiv_symm_naturality_three
(f₃ : X₃ ⟶ Y₃) (g : X₂ ⟶ (G.obj (op X₁)).obj X₃) :
adj₂.homEquiv.symm (g ≫ (G.obj (op X₁)).map f₃) =
adj₂.homEquiv.symm g ≫ f₃ :=
adj₂.homEquiv.injective (by simp [homEquiv_naturality_three])
@[reassoc]
lemma whiskerLeft_map_counit {X₁ Y₁ : C₁} (f : X₁ ⟶ Y₁) :
whiskerLeft _ (F.map f) ≫ (adj₂.adj Y₁).counit =
whiskerRight (G.map f.op) _ ≫ (adj₂.adj X₁).counit := by
ext X₃
dsimp
apply adj₂.homEquiv.injective
rw [homEquiv_naturality_one, homEquiv_naturality_two]
simp [homEquiv_eq, Adjunction.homEquiv_unit]
end ParametrizedAdjunction
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Adjunction/Mates.lean | import Mathlib.CategoryTheory.Adjunction.Basic
import Mathlib.CategoryTheory.Functor.TwoSquare
import Mathlib.CategoryTheory.HomCongr
import Mathlib.Tactic.ApplyFun
/-!
# Mate of natural transformations
This file establishes the bijection between the 2-cells
```
L₁ R₁
C --→ D C ←-- D
G ↓ ↗ ↓ H G ↓ ↘ ↓ H
E --→ F E ←-- F
L₂ R₂
```
where `L₁ ⊣ R₁` and `L₂ ⊣ R₂`. The corresponding natural transformations are called mates.
This bijection includes a number of interesting cases as specializations. For instance, in the
special case where `G,H` are identity functors then the bijection preserves and reflects
isomorphisms (i.e. we have bijections`(L₂ ⟶ L₁) ≃ (R₁ ⟶ R₂)`, and if either side is an iso then the
other side is as well). This demonstrates that adjoints to a given functor are unique up to
isomorphism (since if `L₁ ≅ L₂` then we deduce `R₁ ≅ R₂`).
Another example arises from considering the square representing that a functor `H` preserves
products, in particular the morphism `HA ⨯ H- ⟶ H(A ⨯ -)`. Then provided `(A ⨯ -)` and `HA ⨯ -`
have left adjoints (for instance if the relevant categories are Cartesian closed), the transferred
natural transformation is the exponential comparison morphism: `H(A ^ -) ⟶ HA ^ H-`.
Furthermore if `H` has a left adjoint `L`, this morphism is an isomorphism iff its mate
`L(HA ⨯ -) ⟶ A ⨯ L-` is an isomorphism, see
https://ncatlab.org/nlab/show/Frobenius+reciprocity#InCategoryTheory.
This also relates to Grothendieck's yoga of six operations, though this is not spelled out in
mathlib: https://ncatlab.org/nlab/show/six+operations.
-/
universe v₁ v₂ v₃ v₄ v₅ v₆ v₇ v₈ v₉ u₁ u₂ u₃ u₄ u₅ u₆ u₇ u₈ u₉
namespace CategoryTheory
open Category Functor Adjunction NatTrans TwoSquare
section mateEquiv
variable {C : Type u₁} {D : Type u₂} {E : Type u₃} {F : Type u₄}
variable [Category.{v₁} C] [Category.{v₂} D] [Category.{v₃} E] [Category.{v₄} F]
variable {G : C ⥤ E} {H : D ⥤ F} {L₁ : C ⥤ D} {R₁ : D ⥤ C} {L₂ : E ⥤ F} {R₂ : F ⥤ E}
variable (adj₁ : L₁ ⊣ R₁) (adj₂ : L₂ ⊣ R₂)
/-- Suppose we have a square of functors (where the top and bottom are adjunctions `L₁ ⊣ R₁`
and `L₂ ⊣ R₂` respectively).
```
C ↔ D
G ↓ ↓ H
E ↔ F
```
Then we have a bijection between natural transformations `G ⋙ L₂ ⟶ L₁ ⋙ H` and
`R₁ ⋙ G ⟶ H ⋙ R₂`. This can be seen as a bijection of the 2-cells:
```
L₁ R₁
C --→ D C ←-- D
G ↓ ↗ ↓ H G ↓ ↘ ↓ H
E --→ F E ←-- F
L₂ R₂
```
Note that if one of the transformations is an iso, it does not imply the other is an iso.
-/
@[simps]
def mateEquiv : TwoSquare G L₁ L₂ H ≃ TwoSquare R₁ H G R₂ where
toFun α := .mk _ _ _ _ <|
(rightUnitor _).inv ≫
whiskerLeft (R₁ ⋙ G) adj₂.unit ≫
(associator _ _ _).hom ≫ whiskerLeft _ (associator _ _ _).inv ≫
whiskerLeft R₁ (whiskerRight α.natTrans R₂) ≫
whiskerLeft _ (associator _ _ _).hom ≫ (associator _ _ _).inv ≫
whiskerRight adj₁.counit (H ⋙ R₂) ≫
(leftUnitor _).hom
invFun β := .mk _ _ _ _ <|
(leftUnitor _).inv ≫
whiskerRight adj₁.unit (G ⋙ L₂) ≫
(associator _ _ _).inv ≫ whiskerRight (associator _ _ _).hom _ ≫
whiskerRight (whiskerLeft L₁ β.natTrans) L₂ ≫
whiskerRight (associator _ _ _).inv _ ≫ (associator _ _ _).hom ≫
whiskerLeft (L₁ ⋙ H) adj₂.counit ≫
(rightUnitor _).hom
left_inv α := by
ext
simp only [comp_obj, whiskerLeft_comp, whiskerLeft_twice, assoc, Iso.hom_inv_id_assoc,
whiskerRight_comp, comp_app, id_obj, leftUnitor_inv_app, Functor.whiskerRight_app,
Functor.comp_map, associator_inv_app, associator_hom_app, map_id, Functor.whiskerLeft_app,
rightUnitor_inv_app, leftUnitor_hom_app, rightUnitor_hom_app, comp_id, id_comp,
counit_naturality, counit_naturality_assoc, left_triangle_components_assoc]
rw [← assoc, ← Functor.comp_map, α.natTrans.naturality, Functor.comp_map, assoc, ← H.map_comp,
left_triangle_components, map_id]
simp only [comp_obj, comp_id]
right_inv β := by
ext
simp only [comp_obj, whiskerRight_comp, whiskerRight_twice, assoc, Iso.inv_hom_id_assoc,
whiskerLeft_comp, comp_app, id_obj, rightUnitor_inv_app, Functor.whiskerLeft_app,
associator_hom_app, associator_inv_app, Functor.whiskerRight_app, leftUnitor_inv_app, map_id,
Functor.comp_map, rightUnitor_hom_app, leftUnitor_hom_app, comp_id, id_comp,
unit_naturality_assoc, right_triangle_components_assoc]
rw [← assoc, ← Functor.comp_map, assoc, ← β.natTrans.naturality, ← assoc, Functor.comp_map,
← G.map_comp, right_triangle_components, map_id, id_comp]
/-- A component of a transposed version of the mates correspondence. -/
theorem mateEquiv_counit (α : TwoSquare G L₁ L₂ H) (d : D) :
L₂.map ((mateEquiv adj₁ adj₂ α).app _) ≫ adj₂.counit.app _ =
α.app _ ≫ H.map (adj₁.counit.app d) := by simp
/-- A component of a transposed version of the inverse mates correspondence. -/
theorem mateEquiv_counit_symm (α : TwoSquare R₁ H G R₂) (d : D) :
L₂.map (α.app _) ≫ adj₂.counit.app _ =
((mateEquiv adj₁ adj₂).symm α).app _ ≫ H.map (adj₁.counit.app d) := by
conv_lhs => rw [← (mateEquiv adj₁ adj₂).right_inv α]
exact (mateEquiv_counit adj₁ adj₂ ((mateEquiv adj₁ adj₂).symm α) d)
/- A component of a transposed version of the mates correspondence. -/
theorem unit_mateEquiv (α : TwoSquare G L₁ L₂ H) (c : C) :
G.map (adj₁.unit.app c) ≫ (mateEquiv adj₁ adj₂ α).app _ =
adj₂.unit.app _ ≫ R₂.map (α.app _) := by
simp only [id_obj, comp_obj, mateEquiv, Equiv.coe_fn_mk, comp_app, rightUnitor_inv_app,
Functor.whiskerLeft_app, associator_hom_app, associator_inv_app, Functor.whiskerRight_app,
Functor.comp_map, leftUnitor_hom_app, comp_id, id_comp]
rw [← adj₂.unit_naturality_assoc]
slice_lhs 2 3 =>
rw [← R₂.map_comp, ← Functor.comp_map G L₂, α.naturality]
rw [R₂.map_comp]
slice_lhs 3 4 =>
rw [← R₂.map_comp, Functor.comp_map L₁ H, ← H.map_comp, left_triangle_components]
simp only [comp_obj, map_id, comp_id]
/-- A component of a transposed version of the inverse mates correspondence. -/
theorem unit_mateEquiv_symm (α : TwoSquare R₁ H G R₂) (c : C) :
G.map (adj₁.unit.app c) ≫ α.app _ =
adj₂.unit.app _ ≫ R₂.map (((mateEquiv adj₁ adj₂).symm α).app _) := by
conv_lhs => rw [← (mateEquiv adj₁ adj₂).right_inv α]
exact (unit_mateEquiv adj₁ adj₂ ((mateEquiv adj₁ adj₂).symm α) c)
end mateEquiv
section mateEquivVComp
variable {A : Type u₁} {B : Type u₂} {C : Type u₃} {D : Type u₄} {E : Type u₅} {F : Type u₆}
variable [Category.{v₁} A] [Category.{v₂} B] [Category.{v₃} C]
variable [Category.{v₄} D] [Category.{v₅} E] [Category.{v₆} F]
variable {G₁ : A ⥤ C} {G₂ : C ⥤ E} {H₁ : B ⥤ D} {H₂ : D ⥤ F}
variable {L₁ : A ⥤ B} {R₁ : B ⥤ A} {L₂ : C ⥤ D} {R₂ : D ⥤ C} {L₃ : E ⥤ F} {R₃ : F ⥤ E}
variable (adj₁ : L₁ ⊣ R₁) (adj₂ : L₂ ⊣ R₂) (adj₃ : L₃ ⊣ R₃)
/-- The mates equivalence commutes with vertical composition. -/
theorem mateEquiv_vcomp (α : TwoSquare G₁ L₁ L₂ H₁) (β : TwoSquare G₂ L₂ L₃ H₂) :
(mateEquiv adj₁ adj₃) (α ≫ₕ β) = (mateEquiv adj₁ adj₂ α) ≫ᵥ (mateEquiv adj₂ adj₃ β) := by
unfold hComp vComp mateEquiv
ext b
simp only [comp_obj, Equiv.coe_fn_mk, whiskerRight_comp, whiskerRight_twice, assoc,
whiskerLeft_comp, comp_app, id_obj, rightUnitor_inv_app, Functor.whiskerLeft_app,
associator_hom_app, associator_inv_app, Functor.whiskerRight_app, map_id, Functor.comp_map,
leftUnitor_hom_app, comp_id, id_comp, whiskerLeft_twice, Iso.hom_inv_id_assoc]
slice_rhs 1 4 => rw [← assoc, ← assoc, ← unit_naturality (adj₃)]
rw [L₃.map_comp, R₃.map_comp]
slice_rhs 2 4 =>
rw [← R₃.map_comp, ← R₃.map_comp, ← assoc, ← L₃.map_comp, ← G₂.map_comp, ← G₂.map_comp]
rw [← Functor.comp_map G₂ L₃, β.naturality]
rw [(L₂ ⋙ H₂).map_comp, R₃.map_comp, R₃.map_comp]
slice_rhs 4 5 =>
rw [← R₃.map_comp, Functor.comp_map L₂ _, ← Functor.comp_map _ L₂, ← H₂.map_comp]
rw [adj₂.counit.naturality]
simp only [comp_obj, Functor.comp_map, map_comp, id_obj, Functor.id_map, assoc]
slice_rhs 4 5 =>
rw [← R₃.map_comp, ← H₂.map_comp, ← Functor.comp_map _ L₂, adj₂.counit.naturality]
simp only [comp_obj, id_obj, Functor.id_map, map_comp, assoc]
slice_rhs 3 4 =>
rw [← R₃.map_comp, ← H₂.map_comp, left_triangle_components]
simp only [map_id, id_comp]
end mateEquivVComp
section mateEquivHComp
variable {A : Type u₁} {B : Type u₂} {C : Type u₃} {D : Type u₄} {E : Type u₅} {F : Type u₆}
variable [Category.{v₁} A] [Category.{v₂} B] [Category.{v₃} C]
variable [Category.{v₄} D] [Category.{v₅} E] [Category.{v₆} F]
variable {G : A ⥤ D} {H : B ⥤ E} {K : C ⥤ F}
variable {L₁ : A ⥤ B} {R₁ : B ⥤ A} {L₂ : D ⥤ E} {R₂ : E ⥤ D}
variable {L₃ : B ⥤ C} {R₃ : C ⥤ B} {L₄ : E ⥤ F} {R₄ : F ⥤ E}
variable (adj₁ : L₁ ⊣ R₁) (adj₂ : L₂ ⊣ R₂) (adj₃ : L₃ ⊣ R₃) (adj₄ : L₄ ⊣ R₄)
/-- The mates equivalence commutes with horizontal composition of squares. -/
theorem mateEquiv_hcomp (α : TwoSquare G L₁ L₂ H) (β : TwoSquare H L₃ L₄ K) :
(mateEquiv (adj₁.comp adj₃) (adj₂.comp adj₄)) (α ≫ᵥ β) =
(mateEquiv adj₃ adj₄ β) ≫ₕ (mateEquiv adj₁ adj₂ α) := by
unfold vComp hComp mateEquiv Adjunction.comp
ext c
simp only [comp_obj, whiskerRight_comp, assoc, mk'_unit, whiskerLeft_comp, mk'_counit,
whiskerRight_twice, Iso.inv_hom_id_assoc, Equiv.coe_fn_mk, comp_app, id_obj,
rightUnitor_inv_app, Functor.whiskerLeft_app, Functor.whiskerRight_app, map_id,
associator_inv_app, associator_hom_app, Functor.comp_map, rightUnitor_hom_app,
leftUnitor_hom_app, comp_id, id_comp, whiskerLeft_twice, Iso.hom_inv_id_assoc]
slice_rhs 2 4 =>
rw [← R₂.map_comp, ← R₂.map_comp, ← assoc, ← unit_naturality (adj₄)]
rw [R₂.map_comp, L₄.map_comp, R₄.map_comp, R₂.map_comp]
slice_rhs 4 5 =>
rw [← R₂.map_comp, ← R₄.map_comp, ← Functor.comp_map _ L₄, β.naturality]
simp only [comp_obj, Functor.comp_map, map_comp, assoc]
end mateEquivHComp
section mateEquivSquareComp
variable {A : Type u₁} {B : Type u₂} {C : Type u₃}
variable {D : Type u₄} {E : Type u₅} {F : Type u₆}
variable {X : Type u₇} {Y : Type u₈} {Z : Type u₉}
variable [Category.{v₁} A] [Category.{v₂} B] [Category.{v₃} C]
variable [Category.{v₄} D] [Category.{v₅} E] [Category.{v₆} F]
variable [Category.{v₇} X] [Category.{v₈} Y] [Category.{v₉} Z]
variable {G₁ : A ⥤ D} {H₁ : B ⥤ E} {K₁ : C ⥤ F} {G₂ : D ⥤ X} {H₂ : E ⥤ Y} {K₂ : F ⥤ Z}
variable {L₁ : A ⥤ B} {R₁ : B ⥤ A} {L₂ : B ⥤ C} {R₂ : C ⥤ B} {L₃ : D ⥤ E} {R₃ : E ⥤ D}
variable {L₄ : E ⥤ F} {R₄ : F ⥤ E} {L₅ : X ⥤ Y} {R₅ : Y ⥤ X} {L₆ : Y ⥤ Z} {R₆ : Z ⥤ Y}
variable (adj₁ : L₁ ⊣ R₁) (adj₂ : L₂ ⊣ R₂) (adj₃ : L₃ ⊣ R₃)
variable (adj₄ : L₄ ⊣ R₄) (adj₅ : L₅ ⊣ R₅) (adj₆ : L₆ ⊣ R₆)
/-- The mates equivalence commutes with composition of squares of squares. These results form the
basis for an isomorphism of double categories to be proven later.
-/
theorem mateEquiv_square (α : TwoSquare G₁ L₁ L₃ H₁) (β : TwoSquare H₁ L₂ L₄ K₁)
(γ : TwoSquare G₂ L₃ L₅ H₂) (δ : TwoSquare H₂ L₄ L₆ K₂) :
(mateEquiv (adj₁.comp adj₂) (adj₅.comp adj₆)) ((α ≫ᵥ β) ≫ₕ (γ ≫ᵥ δ)) =
((mateEquiv adj₂ adj₄ β) ≫ₕ (mateEquiv adj₁ adj₃ α))
≫ᵥ ((mateEquiv adj₄ adj₆ δ) ≫ₕ (mateEquiv adj₃ adj₅ γ)) := by
have vcomp :=
mateEquiv_vcomp (adj₁.comp adj₂) (adj₃.comp adj₄) (adj₅.comp adj₆) (α ≫ᵥ β) (γ ≫ᵥ δ)
simp only [mateEquiv_hcomp] at vcomp
assumption
end mateEquivSquareComp
section conjugateEquiv
variable {C : Type u₁} {D : Type u₂}
variable [Category.{v₁} C] [Category.{v₂} D]
variable {L₁ L₂ : C ⥤ D} {R₁ R₂ : D ⥤ C}
variable (adj₁ : L₁ ⊣ R₁) (adj₂ : L₂ ⊣ R₂)
/-- Given two adjunctions `L₁ ⊣ R₁` and `L₂ ⊣ R₂` both between categories `C`, `D`, there is a
bijection between natural transformations `L₂ ⟶ L₁` and natural transformations `R₁ ⟶ R₂`. This is
defined as a special case of `mateEquiv`, where the two "vertical" functors are identity, modulo
composition with the unitors. Corresponding natural transformations are called `conjugateEquiv`.
TODO: Generalise to when the two vertical functors are equivalences rather than being exactly `𝟭`.
Furthermore, this bijection preserves (and reflects) isomorphisms, i.e. a transformation is an iso
iff its image under the bijection is an iso, see e.g. `CategoryTheory.conjugateIsoEquiv`.
This is in contrast to the general case `mateEquiv` which does not in general have this property.
-/
@[simps!]
def conjugateEquiv : (L₂ ⟶ L₁) ≃ (R₁ ⟶ R₂) :=
calc
(L₂ ⟶ L₁) ≃ (𝟭 C ⋙ L₂ ⟶ L₁ ⋙ 𝟭 D) := (Iso.homCongr L₂.leftUnitor L₁.rightUnitor).symm
_ ≃ TwoSquare _ _ _ _ := (TwoSquare.equivNatTrans _ _ _ _).symm
_ ≃ _ := mateEquiv adj₁ adj₂
_ ≃ (R₁ ⋙ 𝟭 C ⟶ 𝟭 D ⋙ R₂) := TwoSquare.equivNatTrans _ _ _ _
_ ≃ (R₁ ⟶ R₂) := R₁.rightUnitor.homCongr R₂.leftUnitor
/-- A component of a transposed form of the conjugation definition. -/
theorem conjugateEquiv_counit (α : L₂ ⟶ L₁) (d : D) :
L₂.map ((conjugateEquiv adj₁ adj₂ α).app _) ≫ adj₂.counit.app d =
α.app _ ≫ adj₁.counit.app d := by
simp
/-- A component of a transposed form of the inverse conjugation definition. -/
theorem conjugateEquiv_counit_symm (α : R₁ ⟶ R₂) (d : D) :
L₂.map (α.app _) ≫ adj₂.counit.app d =
((conjugateEquiv adj₁ adj₂).symm α).app _ ≫ adj₁.counit.app d := by
conv_lhs => rw [← (conjugateEquiv adj₁ adj₂).right_inv α]
exact (conjugateEquiv_counit adj₁ adj₂ ((conjugateEquiv adj₁ adj₂).symm α) d)
/-- A component of a transposed form of the conjugation definition. -/
theorem unit_conjugateEquiv (α : L₂ ⟶ L₁) (c : C) :
adj₁.unit.app _ ≫ (conjugateEquiv adj₁ adj₂ α).app _ =
adj₂.unit.app c ≫ R₂.map (α.app _) := by
dsimp [conjugateEquiv]
rw [id_comp, comp_id]
have := unit_mateEquiv adj₁ adj₂ (L₂.leftUnitor.hom ≫ α ≫ L₁.rightUnitor.inv) c
dsimp at this
rw [this]
simp
/-- A component of a transposed form of the inverse conjugation definition. -/
theorem unit_conjugateEquiv_symm (α : R₁ ⟶ R₂) (c : C) :
adj₁.unit.app _ ≫ α.app _ =
adj₂.unit.app c ≫ R₂.map (((conjugateEquiv adj₁ adj₂).symm α).app _) := by
conv_lhs => rw [← (conjugateEquiv adj₁ adj₂).right_inv α]
exact (unit_conjugateEquiv adj₁ adj₂ ((conjugateEquiv adj₁ adj₂).symm α) c)
@[simp]
theorem conjugateEquiv_id : conjugateEquiv adj₁ adj₁ (𝟙 _) = 𝟙 _ := by
ext
simp
@[simp]
theorem conjugateEquiv_symm_id : (conjugateEquiv adj₁ adj₁).symm (𝟙 _) = 𝟙 _ := by
rw [Equiv.symm_apply_eq]
simp only [conjugateEquiv_id]
theorem conjugateEquiv_adjunction_id {L R : C ⥤ C} (adj : L ⊣ R) (α : 𝟭 C ⟶ L) (c : C) :
(conjugateEquiv adj Adjunction.id α).app c = α.app (R.obj c) ≫ adj.counit.app c := by
simp [conjugateEquiv, mateEquiv, Adjunction.id]
theorem conjugateEquiv_adjunction_id_symm {L R : C ⥤ C} (adj : L ⊣ R) (α : R ⟶ 𝟭 C) (c : C) :
((conjugateEquiv adj Adjunction.id).symm α).app c = adj.unit.app c ≫ α.app (L.obj c) := by
simp [conjugateEquiv, mateEquiv, Adjunction.id]
end conjugateEquiv
section ConjugateComposition
variable {C : Type u₁} {D : Type u₂}
variable [Category.{v₁} C] [Category.{v₂} D]
variable {L₁ L₂ L₃ : C ⥤ D} {R₁ R₂ R₃ : D ⥤ C}
variable (adj₁ : L₁ ⊣ R₁) (adj₂ : L₂ ⊣ R₂) (adj₃ : L₃ ⊣ R₃)
@[reassoc (attr := simp)]
theorem conjugateEquiv_comp (α : L₂ ⟶ L₁) (β : L₃ ⟶ L₂) :
conjugateEquiv adj₁ adj₂ α ≫ conjugateEquiv adj₂ adj₃ β =
conjugateEquiv adj₁ adj₃ (β ≫ α) := by
ext d
dsimp [conjugateEquiv, mateEquiv]
have vcomp := mateEquiv_vcomp adj₁ adj₂ adj₃
(L₂.leftUnitor.hom ≫ α ≫ L₁.rightUnitor.inv)
(L₃.leftUnitor.hom ≫ β ≫ L₂.rightUnitor.inv)
have vcompd := congr_app vcomp d
simp only [comp_obj, id_obj, mateEquiv_apply, comp_app, rightUnitor_inv_app,
Functor.whiskerLeft_app, associator_hom_app, associator_inv_app, Functor.whiskerRight_app,
hComp_app, leftUnitor_hom_app, comp_id, id_comp, Functor.id_map, map_comp, Functor.comp_map,
assoc, whiskerRight_comp, whiskerLeft_comp, vComp_app, map_id] at vcompd ⊢
rw [vcompd]
@[reassoc (attr := simp)]
theorem conjugateEquiv_symm_comp (α : R₁ ⟶ R₂) (β : R₂ ⟶ R₃) :
(conjugateEquiv adj₂ adj₃).symm β ≫ (conjugateEquiv adj₁ adj₂).symm α =
(conjugateEquiv adj₁ adj₃).symm (α ≫ β) := by
rw [Equiv.eq_symm_apply, ← conjugateEquiv_comp _ adj₂]
simp only [Equiv.apply_symm_apply]
theorem conjugateEquiv_comm {α : L₂ ⟶ L₁} {β : L₁ ⟶ L₂} (βα : β ≫ α = 𝟙 _) :
conjugateEquiv adj₁ adj₂ α ≫ conjugateEquiv adj₂ adj₁ β = 𝟙 _ := by
rw [conjugateEquiv_comp, βα, conjugateEquiv_id]
theorem conjugateEquiv_symm_comm {α : R₁ ⟶ R₂} {β : R₂ ⟶ R₁} (αβ : α ≫ β = 𝟙 _) :
(conjugateEquiv adj₂ adj₁).symm β ≫ (conjugateEquiv adj₁ adj₂).symm α = 𝟙 _ := by
rw [conjugateEquiv_symm_comp, αβ, conjugateEquiv_symm_id]
end ConjugateComposition
section ConjugateIsomorphism
variable {C : Type u₁} {D : Type u₂}
variable [Category.{v₁} C] [Category.{v₂} D]
variable {L₁ L₂ : C ⥤ D} {R₁ R₂ : D ⥤ C}
variable (adj₁ : L₁ ⊣ R₁) (adj₂ : L₂ ⊣ R₂)
/-- If `α` is an isomorphism between left adjoints, then its conjugate transformation is an
isomorphism. The converse is given in `conjugateEquiv_of_iso`.
-/
instance conjugateEquiv_iso (α : L₂ ⟶ L₁) [IsIso α] :
IsIso (conjugateEquiv adj₁ adj₂ α) :=
⟨⟨conjugateEquiv adj₂ adj₁ (inv α),
⟨conjugateEquiv_comm _ _ (by simp), conjugateEquiv_comm _ _ (by simp)⟩⟩⟩
/-- If `α` is an isomorphism between right adjoints, then its conjugate transformation is an
isomorphism. The converse is given in `conjugateEquiv_symm_of_iso`.
-/
instance conjugateEquiv_symm_iso (α : R₁ ⟶ R₂) [IsIso α] :
IsIso ((conjugateEquiv adj₁ adj₂).symm α) :=
⟨⟨(conjugateEquiv adj₂ adj₁).symm (inv α),
⟨conjugateEquiv_symm_comm _ _ (by simp), conjugateEquiv_symm_comm _ _ (by simp)⟩⟩⟩
/-- If `α` is a natural transformation between left adjoints whose conjugate natural transformation
is an isomorphism, then `α` is an isomorphism. The converse is given in `Conjugate_iso`.
-/
theorem conjugateEquiv_of_iso (α : L₂ ⟶ L₁) [IsIso (conjugateEquiv adj₁ adj₂ α)] :
IsIso α := by
suffices IsIso ((conjugateEquiv adj₁ adj₂).symm (conjugateEquiv adj₁ adj₂ α))
by simpa using this
infer_instance
/--
If `α` is a natural transformation between right adjoints whose conjugate natural transformation is
an isomorphism, then `α` is an isomorphism. The converse is given in `conjugateEquiv_symm_iso`.
-/
theorem conjugateEquiv_symm_of_iso (α : R₁ ⟶ R₂)
[IsIso ((conjugateEquiv adj₁ adj₂).symm α)] : IsIso α := by
suffices IsIso ((conjugateEquiv adj₁ adj₂) ((conjugateEquiv adj₁ adj₂).symm α))
by simpa using this
infer_instance
/-- Thus conjugation defines an equivalence between natural isomorphisms. -/
@[simps]
def conjugateIsoEquiv : (L₂ ≅ L₁) ≃ (R₁ ≅ R₂) where
toFun α := {
hom := conjugateEquiv adj₁ adj₂ α.hom
inv := conjugateEquiv adj₂ adj₁ α.inv
}
invFun β := {
hom := (conjugateEquiv adj₁ adj₂).symm β.hom
inv := (conjugateEquiv adj₂ adj₁).symm β.inv
}
left_inv := by cat_disch
right_inv := by cat_disch
end ConjugateIsomorphism
variable {A : Type u₁} {B : Type u₂} {C : Type u₃} {D : Type u₄}
variable [Category.{v₁} A] [Category.{v₂} B] [Category.{v₃} C] [Category.{v₄} D]
section IteratedmateEquiv
variable {F₁ : A ⥤ C} {U₁ : C ⥤ A} {F₂ : B ⥤ D} {U₂ : D ⥤ B}
variable {L₁ : A ⥤ B} {R₁ : B ⥤ A} {L₂ : C ⥤ D} {R₂ : D ⥤ C}
variable (adj₁ : L₁ ⊣ R₁) (adj₂ : L₂ ⊣ R₂) (adj₃ : F₁ ⊣ U₁) (adj₄ : F₂ ⊣ U₂)
/-- When all four functors in a square are left adjoints, the mates operation can be iterated:
```
L₁ R₁ R₁
C --→ D C ←-- D C ←-- D
F₁ ↓ ↗ ↓ F₂ F₁ ↓ ↘ ↓ F₂ U₁ ↑ ↙ ↑ U₂
E --→ F E ←-- F E ←-- F
L₂ R₂ R₂
```
In this case the iterated mate equals the conjugate of the original transformation and is thus an
isomorphism if and only if the original transformation is. This explains why some Beck-Chevalley
natural transformations are natural isomorphisms.
-/
theorem iterated_mateEquiv_conjugateEquiv (α : TwoSquare F₁ L₁ L₂ F₂) :
(mateEquiv adj₄ adj₃ (mateEquiv adj₁ adj₂ α)).natTrans =
conjugateEquiv (adj₁.comp adj₄) (adj₃.comp adj₂) α := by
ext d
unfold conjugateEquiv mateEquiv Adjunction.comp
simp
theorem iterated_mateEquiv_conjugateEquiv_symm (α : TwoSquare U₂ R₂ R₁ U₁) :
(mateEquiv adj₁ adj₂).symm ((mateEquiv adj₄ adj₃).symm α) =
(conjugateEquiv (adj₁.comp adj₄) (adj₃.comp adj₂)).symm.trans
(equivNatTrans _ _ _ _).symm α := by
ext
simp
end IteratedmateEquiv
variable {G : A ⥤ C} {H : B ⥤ D}
/-- The mates equivalence commutes with this composition, essentially by `mateEquiv_vcomp`. -/
theorem mateEquiv_conjugateEquiv_vcomp {L₁ : A ⥤ B} {R₁ : B ⥤ A} {L₂ : C ⥤ D} {R₂ : D ⥤ C}
{L₃ : C ⥤ D} {R₃ : D ⥤ C}
(adj₁ : L₁ ⊣ R₁) (adj₂ : L₂ ⊣ R₂) (adj₃ : L₃ ⊣ R₃) (α : TwoSquare G L₁ L₂ H) (β : L₃ ⟶ L₂) :
(mateEquiv adj₁ adj₃) (α.whiskerRight β) =
(mateEquiv adj₁ adj₂ α).whiskerBottom (conjugateEquiv adj₂ adj₃ β) := by
ext b
have vcomp := mateEquiv_vcomp adj₁ adj₂ adj₃ α (L₃.leftUnitor.hom ≫ β ≫ L₂.rightUnitor.inv)
unfold vComp hComp at vcomp
unfold TwoSquare.whiskerRight TwoSquare.whiskerBottom conjugateEquiv
have vcompb := congr_app vcomp b
simp only [comp_obj, id_obj, whiskerLeft_comp, assoc, mateEquiv_apply, whiskerLeft_twice,
Iso.hom_inv_id_assoc, whiskerRight_comp, comp_app, Functor.whiskerLeft_app,
Functor.whiskerRight_app, associator_hom_app, map_id, associator_inv_app, leftUnitor_hom_app,
rightUnitor_inv_app, Functor.id_map, Functor.comp_map, id_comp, whiskerRight_twice,
comp_id] at vcompb
simpa [mateEquiv]
/-- The mates equivalence commutes with this composition, essentially by `mateEquiv_vcomp`. -/
theorem conjugateEquiv_mateEquiv_vcomp {L₁ : A ⥤ B} {R₁ : B ⥤ A} {L₂ : A ⥤ B} {R₂ : B ⥤ A}
{L₃ : C ⥤ D} {R₃ : D ⥤ C}
(adj₁ : L₁ ⊣ R₁) (adj₂ : L₂ ⊣ R₂) (adj₃ : L₃ ⊣ R₃) (α : L₂ ⟶ L₁) (β : TwoSquare G L₂ L₃ H) :
(mateEquiv adj₁ adj₃) (β.whiskerLeft α) =
(mateEquiv adj₂ adj₃ β).whiskerTop (conjugateEquiv adj₁ adj₂ α) := by
ext b
have vcomp := mateEquiv_vcomp adj₁ adj₂ adj₃ (L₂.leftUnitor.hom ≫ α ≫ L₁.rightUnitor.inv) β
unfold vComp hComp at vcomp
unfold TwoSquare.whiskerLeft TwoSquare.whiskerTop conjugateEquiv
have vcompb := congr_app vcomp b
simp only [comp_obj, id_obj, whiskerRight_comp, assoc, mateEquiv_apply, whiskerLeft_comp,
whiskerLeft_twice, comp_app, Functor.whiskerLeft_app, Functor.whiskerRight_app,
associator_hom_app, map_id, associator_inv_app, leftUnitor_hom_app, rightUnitor_inv_app,
Functor.comp_map, Functor.id_map, id_comp, whiskerRight_twice, Iso.inv_hom_id_assoc,
comp_id] at vcompb
simpa [mateEquiv]
lemma conjugateEquiv_associator_hom
{L₀₁ : A ⥤ B} {R₁₀ : B ⥤ A} {L₁₂ : B ⥤ C} {R₂₁ : C ⥤ B}
{L₂₃ : C ⥤ D} {R₃₂ : D ⥤ C} (adj₀₁ : L₀₁ ⊣ R₁₀) (adj₁₂ : L₁₂ ⊣ R₂₁)
(adj₂₃ : L₂₃ ⊣ R₃₂) :
conjugateEquiv (adj₀₁.comp (adj₁₂.comp adj₂₃)) ((adj₀₁.comp adj₁₂).comp adj₂₃)
(associator _ _ _).hom = (associator _ _ _).hom := by
ext X
simp only [comp_obj, conjugateEquiv_apply_app, Adjunction.comp_unit_app, id_obj,
Functor.comp_map, Category.assoc, ← map_comp, associator_hom_app, map_id,
Adjunction.comp_counit_app, Category.id_comp]
simp
lemma conjugateEquiv_leftUnitor_hom
{L : A ⥤ B} {R : B ⥤ A} (adj : L ⊣ R) :
conjugateEquiv adj (id.comp adj) (leftUnitor L).hom =
(rightUnitor R).inv := by
cat_disch
lemma conjugateEquiv_rightUnitor_hom
{L : A ⥤ B} {R : B ⥤ A} (adj : L ⊣ R) :
conjugateEquiv adj (adj.comp id) (rightUnitor L).hom =
(leftUnitor R).inv := by
cat_disch
lemma conjugateEquiv_whiskerLeft
{L₁ L₂ : B ⥤ C} {R₁ R₂ : C ⥤ B} {L : A ⥤ B} {R : B ⥤ A}
(adj₁ : L₁ ⊣ R₁) (adj₂ : L₂ ⊣ R₂) (adj : L ⊣ R) (τ : L₂ ⟶ L₁) :
conjugateEquiv (adj.comp adj₁) (adj.comp adj₂) (whiskerLeft L τ) =
whiskerRight (conjugateEquiv adj₁ adj₂ τ) R := by
ext X
have h₁ := congr_map (R₂ ⋙ R) (τ.naturality (adj.counit.app (R₁.obj X)))
have h₂ := congr_map R (adj₂.unit_naturality (adj.counit.app (R₁.obj X)))
simp only [comp_obj, id_obj, Functor.map_comp] at h₁ h₂
simp [← reassoc_of% h₁, reassoc_of% h₂]
lemma conjugateEquiv_whiskerRight
{L₁ L₂ : A ⥤ B} {R₁ R₂ : B ⥤ A} {L : B ⥤ C} {R : C ⥤ B}
(adj₁ : L₁ ⊣ R₁) (adj₂ : L₂ ⊣ R₂) (adj : L ⊣ R) (τ : L₂ ⟶ L₁) :
conjugateEquiv (adj₁.comp adj) (adj₂.comp adj) (whiskerRight τ L) =
whiskerLeft R (conjugateEquiv adj₁ adj₂ τ) := by
ext X
simp only [comp_obj, conjugateEquiv_apply_app, comp_unit_app, id_obj, Functor.whiskerRight_app,
Functor.comp_map, comp_counit_app, ← map_comp, assoc, Functor.whiskerLeft_app]
simp
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Adjunction/CompositionIso.lean | import Mathlib.CategoryTheory.Adjunction.Mates
/-!
# Compatibilities for left adjoints from compatibilities satisfied by right adjoints
In this file, given isomorphisms between compositions of right adjoint functors,
we obtain isomorphisms between the corresponding compositions of the left adjoint functors,
and show that the left adjoint functors satisfy properties similar to the left/right
unitality and the associativity of pseudofunctors if the right adjoint functors
satisfy the corresponding properties.
This is used in `Mathlib.Algebra.Category.ModuleCat.Presheaf.Pullback` to study
the behaviour with respect to composition of the pullback functors on presheaves
of modules, by reducing these definitions and properties to the (obvious) case of the
pushforward functors. Similar results shall be obtained for sheaves of modules (TODO).
-/
namespace CategoryTheory
variable {C₀ C₁ C₂ C₃ : Type*} [Category C₀] [Category C₁] [Category C₂] [Category C₃]
open Functor
namespace Adjunction
/-- If a right adjoint functor is isomorphic to the identity functor,
so is the left adjoint. -/
@[simps! -isSimp]
def leftAdjointIdIso {F : C₀ ⥤ C₀} {G : C₀ ⥤ C₀} (adj : F ⊣ G) (e : G ≅ 𝟭 C₀) :
F ≅ 𝟭 C₀ := (conjugateIsoEquiv .id adj).symm e.symm
section
variable {F₀₁ : C₀ ⥤ C₁} {F₁₂ : C₁ ⥤ C₂} {F₀₂ : C₀ ⥤ C₂}
{G₁₀ : C₁ ⥤ C₀} {G₂₁ : C₂ ⥤ C₁} {G₂₀ : C₂ ⥤ C₀}
(adj₀₁ : F₀₁ ⊣ G₁₀) (adj₁₂ : F₁₂ ⊣ G₂₁) (adj₀₂ : F₀₂ ⊣ G₂₀)
/-- A natural transformation `G₂₀ ⟶ G₂₁ ⋙ G₁₀` involving right adjoint functors
induces a natural transformation `F₀₁ ⋙ F₁₂ ⟶ F₀₂` between the corresponding
left adjoint functors. -/
@[simps! -isSimp]
def leftAdjointCompNatTrans (τ₀₁₂ : G₂₀ ⟶ G₂₁ ⋙ G₁₀) :
F₀₁ ⋙ F₁₂ ⟶ F₀₂ :=
(conjugateEquiv adj₀₂ (adj₀₁.comp adj₁₂)).symm τ₀₁₂
/-- A natural isomorphism `G₂₁ ⋙ G₁₀ ≅ G₂₀` involving right adjoint functors
induces a natural isomorphism `F₀₁ ⋙ F₁₂ ≅ F₀₂` between the corresponding
left adjoint functors. -/
@[simps! -isSimp]
def leftAdjointCompIso (e₀₁₂ : G₂₁ ⋙ G₁₀ ≅ G₂₀) :
F₀₁ ⋙ F₁₂ ≅ F₀₂ :=
(conjugateIsoEquiv adj₀₂ (adj₀₁.comp adj₁₂)).symm e₀₁₂.symm
lemma leftAdjointCompIso_hom (e₀₁₂ : G₂₁ ⋙ G₁₀ ≅ G₂₀) :
(leftAdjointCompIso adj₀₁ adj₁₂ adj₀₂ e₀₁₂).hom =
leftAdjointCompNatTrans adj₀₁ adj₁₂ adj₀₂ e₀₁₂.inv :=
rfl
end
lemma leftAdjointCompIso_comp_id
{F₀₁ : C₀ ⥤ C₁} {F₁₁' : C₁ ⥤ C₁} {G₁₀ : C₁ ⥤ C₀} {G₁'₁ : C₁ ⥤ C₁}
(adj₀₁ : F₀₁ ⊣ G₁₀) (adj₁₁' : F₁₁' ⊣ G₁'₁)
(e₀₁₁' : G₁'₁ ⋙ G₁₀ ≅ G₁₀) (e₁'₁ : G₁'₁ ≅ 𝟭 _)
(h : e₀₁₁' = isoWhiskerRight e₁'₁ G₁₀ ≪≫ leftUnitor G₁₀) :
leftAdjointCompIso adj₀₁ adj₁₁' adj₀₁ e₀₁₁' =
isoWhiskerLeft _ (leftAdjointIdIso adj₁₁' e₁'₁) ≪≫ rightUnitor F₀₁ := by
subst h
ext X₀
simp [leftAdjointCompIso_hom_app, leftAdjointIdIso_hom_app,
← Functor.map_comp_assoc, -Functor.map_comp]
lemma leftAdjointCompIso_id_comp
{F₀₀' : C₀ ⥤ C₀} {F₀'₁ : C₀ ⥤ C₁} {G₀'₀ : C₀ ⥤ C₀} {G₁₀' : C₁ ⥤ C₀}
(adj₀₀' : F₀₀' ⊣ G₀'₀) (adj₀'₁ : F₀'₁ ⊣ G₁₀')
(e₀₀'₁ : G₁₀' ⋙ G₀'₀ ≅ G₁₀') (e₀'₀ : G₀'₀ ≅ 𝟭 _)
(h : e₀₀'₁ = isoWhiskerLeft G₁₀' e₀'₀ ≪≫ rightUnitor G₁₀') :
leftAdjointCompIso adj₀₀' adj₀'₁ adj₀'₁ e₀₀'₁ =
isoWhiskerRight (leftAdjointIdIso adj₀₀' e₀'₀) F₀'₁ ≪≫ leftUnitor F₀'₁ := by
subst h
ext X₀
have h₁ := congr_map F₀'₁ (adj₀₀'.counit.naturality (adj₀'₁.unit.app X₀))
have h₂ := congr_map (F₀₀' ⋙ F₀'₁) (e₀'₀.inv.naturality (adj₀'₁.unit.app X₀))
simp only [id_obj, comp_obj, Functor.id_map, Functor.comp_map, Functor.map_comp] at h₁ h₂
simp [leftAdjointCompIso_hom_app, leftAdjointIdIso_hom_app,
reassoc_of% h₂, reassoc_of% h₁]
section
variable
{F₀₁ : C₀ ⥤ C₁} {F₁₂ : C₁ ⥤ C₂} {F₂₃ : C₂ ⥤ C₃} {F₀₂ : C₀ ⥤ C₂} {F₁₃ : C₁ ⥤ C₃} {F₀₃ : C₀ ⥤ C₃}
{G₁₀ : C₁ ⥤ C₀} {G₂₁ : C₂ ⥤ C₁} {G₃₂ : C₃ ⥤ C₂} {G₂₀ : C₂ ⥤ C₀} {G₃₁ : C₃ ⥤ C₁} {G₃₀ : C₃ ⥤ C₀}
(adj₀₁ : F₀₁ ⊣ G₁₀) (adj₁₂ : F₁₂ ⊣ G₂₁) (adj₂₃ : F₂₃ ⊣ G₃₂) (adj₀₂ : F₀₂ ⊣ G₂₀)
(adj₁₃ : F₁₃ ⊣ G₃₁) (adj₀₃ : F₀₃ ⊣ G₃₀)
section
variable (τ₀₁₂ : G₂₀ ⟶ G₂₁ ⋙ G₁₀) (τ₁₂₃ : G₃₁ ⟶ G₃₂ ⋙ G₂₁)
(τ₀₁₃ : G₃₀ ⟶ G₃₁ ⋙ G₁₀) (τ₀₂₃ : G₃₀ ⟶ G₃₂ ⋙ G₂₀)
lemma leftAdjointCompNatTrans₀₁₃_eq_conjugateEquiv_symm :
whiskerLeft _ (leftAdjointCompNatTrans adj₁₂ adj₂₃ adj₁₃ τ₁₂₃) ≫
leftAdjointCompNatTrans adj₀₁ adj₁₃ adj₀₃ τ₀₁₃ =
(conjugateEquiv adj₀₃ (adj₀₁.comp (adj₁₂.comp adj₂₃))).symm
(τ₀₁₃ ≫ whiskerRight τ₁₂₃ G₁₀) := by
obtain ⟨τ₁₂₃, rfl⟩ := (conjugateEquiv adj₁₃ (adj₁₂.comp adj₂₃)).surjective τ₁₂₃
obtain ⟨τ₀₁₃, rfl⟩ := (conjugateEquiv adj₀₃ (adj₀₁.comp adj₁₃)).surjective τ₀₁₃
apply (conjugateEquiv adj₀₃ (adj₀₁.comp (adj₁₂.comp adj₂₃))).injective
simp [leftAdjointCompNatTrans, ← conjugateEquiv_whiskerLeft _ _ adj₀₁]
lemma leftAdjointCompNatTrans₀₂₃_eq_conjugateEquiv_symm :
(associator _ _ _).inv ≫
whiskerRight (leftAdjointCompNatTrans adj₀₁ adj₁₂ adj₀₂ τ₀₁₂) F₂₃ ≫
leftAdjointCompNatTrans adj₀₂ adj₂₃ adj₀₃ τ₀₂₃ =
(conjugateEquiv adj₀₃ (adj₀₁.comp (adj₁₂.comp adj₂₃))).symm
(τ₀₂₃ ≫ whiskerLeft G₃₂ τ₀₁₂ ≫ (associator _ _ _).inv) := by
obtain ⟨τ₀₁₂, rfl⟩ := (conjugateEquiv adj₀₂ (adj₀₁.comp adj₁₂)).surjective τ₀₁₂
obtain ⟨τ₀₂₃, rfl⟩ := (conjugateEquiv adj₀₃ (adj₀₂.comp adj₂₃)).surjective τ₀₂₃
apply (conjugateEquiv adj₀₃ (adj₀₁.comp (adj₁₂.comp adj₂₃))).injective
simp only [Equiv.apply_symm_apply, Equiv.symm_apply_apply, leftAdjointCompNatTrans]
rw [← cancel_mono (associator G₃₂ G₂₁ G₁₀).hom, Category.assoc, Category.assoc,
Iso.inv_hom_id, Category.comp_id, ← conjugateEquiv_associator_hom adj₀₁ adj₁₂ adj₂₃,
← conjugateEquiv_whiskerRight _ _ adj₂₃, conjugateEquiv_comp, Iso.hom_inv_id_assoc,
conjugateEquiv_comp]
lemma leftAdjointCompNatTrans_assoc
(h : τ₀₂₃ ≫ whiskerLeft G₃₂ τ₀₁₂ =
τ₀₁₃ ≫ whiskerRight τ₁₂₃ G₁₀ ≫ (associator _ _ _).hom) :
whiskerLeft _ (leftAdjointCompNatTrans adj₁₂ adj₂₃ adj₁₃ τ₁₂₃) ≫
leftAdjointCompNatTrans adj₀₁ adj₁₃ adj₀₃ τ₀₁₃ =
(associator _ _ _).inv ≫
whiskerRight (leftAdjointCompNatTrans adj₀₁ adj₁₂ adj₀₂ τ₀₁₂) F₂₃ ≫
leftAdjointCompNatTrans adj₀₂ adj₂₃ adj₀₃ τ₀₂₃ := by
simp [leftAdjointCompNatTrans₀₁₃_eq_conjugateEquiv_symm,
leftAdjointCompNatTrans₀₂₃_eq_conjugateEquiv_symm, reassoc_of% h]
end
lemma leftAdjointCompIso_assoc
(e₀₁₂ : G₂₁ ⋙ G₁₀ ≅ G₂₀) (e₁₂₃ : G₃₂ ⋙ G₂₁ ≅ G₃₁)
(e₀₁₃ : G₃₁ ⋙ G₁₀ ≅ G₃₀) (e₀₂₃ : G₃₂ ⋙ G₂₀ ≅ G₃₀)
(h : isoWhiskerLeft G₃₂ e₀₁₂ ≪≫ e₀₂₃ =
(associator _ _ _).symm ≪≫ isoWhiskerRight e₁₂₃ _ ≪≫ e₀₁₃) :
isoWhiskerLeft _ (leftAdjointCompIso adj₁₂ adj₂₃ adj₁₃ e₁₂₃) ≪≫
leftAdjointCompIso adj₀₁ adj₁₃ adj₀₃ e₀₁₃ =
(associator _ _ _).symm ≪≫
isoWhiskerRight (leftAdjointCompIso adj₀₁ adj₁₂ adj₀₂ e₀₁₂) F₂₃ ≪≫
leftAdjointCompIso adj₀₂ adj₂₃ adj₀₃ e₀₂₃ := by
ext : 1
dsimp [leftAdjointCompIso_hom]
exact leftAdjointCompNatTrans_assoc _ _ _ _ _ _ _ _ _ _
(by simpa using congr_arg Iso.inv h)
end
end Adjunction
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Adjunction/Reflective.lean | import Mathlib.CategoryTheory.Adjunction.FullyFaithful
import Mathlib.CategoryTheory.Functor.EpiMono
import Mathlib.CategoryTheory.HomCongr
/-!
# Reflective functors
Basic properties of reflective functors, especially those relating to their essential image.
Note properties of reflective functors relating to limits and colimits are included in
`Mathlib/CategoryTheory/Monad/Limits.lean`.
-/
universe v₁ v₂ v₃ u₁ u₂ u₃
noncomputable section
namespace CategoryTheory
open Category Adjunction
variable {C : Type u₁} {D : Type u₂} {E : Type u₃}
variable [Category.{v₁} C] [Category.{v₂} D] [Category.{v₃} E]
/--
A functor is *reflective*, or *a reflective inclusion*, if it is fully faithful and right adjoint.
-/
class Reflective (R : D ⥤ C) extends R.Full, R.Faithful where
/-- a choice of a left adjoint to `R` -/
L : C ⥤ D
/-- `R` is a right adjoint -/
adj : L ⊣ R
variable (i : D ⥤ C)
/-- The reflector `C ⥤ D` when `R : D ⥤ C` is reflective. -/
def reflector [Reflective i] : C ⥤ D := Reflective.L (R := i)
/-- The adjunction `reflector i ⊣ i` when `i` is reflective. -/
def reflectorAdjunction [Reflective i] : reflector i ⊣ i := Reflective.adj
instance [Reflective i] : i.IsRightAdjoint := ⟨_, ⟨reflectorAdjunction i⟩⟩
instance [Reflective i] : (reflector i).IsLeftAdjoint := ⟨_, ⟨reflectorAdjunction i⟩⟩
/-- A reflective functor is fully faithful. -/
def Functor.fullyFaithfulOfReflective [Reflective i] : i.FullyFaithful :=
(reflectorAdjunction i).fullyFaithfulROfIsIsoCounit
-- TODO: This holds more generally for idempotent adjunctions, not just reflective adjunctions.
/-- For a reflective functor `i` (with left adjoint `L`), with unit `η`, we have `η_iL = iL η`.
-/
theorem unit_obj_eq_map_unit [Reflective i] (X : C) :
(reflectorAdjunction i).unit.app (i.obj ((reflector i).obj X)) =
i.map ((reflector i).map ((reflectorAdjunction i).unit.app X)) := by
rw [← cancel_mono (i.map ((reflectorAdjunction i).counit.app ((reflector i).obj X))),
← i.map_comp]
simp
/--
When restricted to objects in `D` given by `i : D ⥤ C`, the unit is an isomorphism. In other words,
`η_iX` is an isomorphism for any `X` in `D`.
More generally this applies to objects essentially in the reflective subcategory, see
`Functor.essImage.unit_isIso`.
-/
example [Reflective i] {B : D} : IsIso ((reflectorAdjunction i).unit.app (i.obj B)) :=
inferInstance
variable {i}
/-- If `A` is essentially in the image of a reflective functor `i`, then `η_A` is an isomorphism.
This gives that the "witness" for `A` being in the essential image can instead be given as the
reflection of `A`, with the isomorphism as `η_A`.
(For any `B` in the reflective subcategory, we automatically have that `ε_B` is an iso.)
-/
theorem Functor.essImage.unit_isIso [Reflective i] {A : C} (h : i.essImage A) :
IsIso ((reflectorAdjunction i).unit.app A) := by
rwa [isIso_unit_app_iff_mem_essImage]
/-- If `η_A` is a split monomorphism, then `A` is in the reflective subcategory. -/
theorem mem_essImage_of_unit_isSplitMono [Reflective i] {A : C}
[IsSplitMono ((reflectorAdjunction i).unit.app A)] : i.essImage A := by
let η : 𝟭 C ⟶ reflector i ⋙ i := (reflectorAdjunction i).unit
haveI : IsIso (η.app (i.obj ((reflector i).obj A))) :=
Functor.essImage.unit_isIso ((i.obj_mem_essImage _))
have : Epi (η.app A) := by
refine @epi_of_epi _ _ _ _ _ (retraction (η.app A)) (η.app A) ?_
rw [show retraction _ ≫ η.app A = _ from η.naturality (retraction (η.app A))]
apply epi_comp (η.app (i.obj ((reflector i).obj A)))
haveI := isIso_of_epi_of_isSplitMono (η.app A)
exact (reflectorAdjunction i).mem_essImage_of_unit_isIso A
/-- Composition of reflective functors. -/
instance Reflective.comp (F : C ⥤ D) (G : D ⥤ E) [Reflective F] [Reflective G] :
Reflective (F ⋙ G) where
L := reflector G ⋙ reflector F
adj := (reflectorAdjunction G).comp (reflectorAdjunction F)
/-- (Implementation) Auxiliary definition for `unitCompPartialBijective`. -/
def unitCompPartialBijectiveAux [Reflective i] (A : C) (B : D) :
(A ⟶ i.obj B) ≃ (i.obj ((reflector i).obj A) ⟶ i.obj B) :=
((reflectorAdjunction i).homEquiv _ _).symm.trans
(Functor.FullyFaithful.ofFullyFaithful i).homEquiv
/-- The description of the inverse of the bijection `unitCompPartialBijectiveAux`. -/
theorem unitCompPartialBijectiveAux_symm_apply [Reflective i] {A : C} {B : D}
(f : i.obj ((reflector i).obj A) ⟶ i.obj B) :
(unitCompPartialBijectiveAux _ _).symm f = (reflectorAdjunction i).unit.app A ≫ f := by
simp [unitCompPartialBijectiveAux, Adjunction.homEquiv_unit]
/-- If `i` has a reflector `L`, then the function `(i.obj (L.obj A) ⟶ B) → (A ⟶ B)` given by
precomposing with `η.app A` is a bijection provided `B` is in the essential image of `i`.
That is, the function `fun (f : i.obj (L.obj A) ⟶ B) ↦ η.app A ≫ f` is bijective,
as long as `B` is in the essential image of `i`.
This definition gives an equivalence: the key property that the inverse can be described
nicely is shown in `unitCompPartialBijective_symm_apply`.
This establishes there is a natural bijection `(A ⟶ B) ≃ (i.obj (L.obj A) ⟶ B)`. In other words,
from the point of view of objects in `D`, `A` and `i.obj (L.obj A)` look the same: specifically
that `η.app A` is an isomorphism.
-/
def unitCompPartialBijective [Reflective i] (A : C) {B : C} (hB : i.essImage B) :
(A ⟶ B) ≃ (i.obj ((reflector i).obj A) ⟶ B) :=
calc
(A ⟶ B) ≃ (A ⟶ i.obj (Functor.essImage.witness hB)) := Iso.homCongr (Iso.refl _) hB.getIso.symm
_ ≃ (i.obj _ ⟶ i.obj (Functor.essImage.witness hB)) := unitCompPartialBijectiveAux _ _
_ ≃ (i.obj ((reflector i).obj A) ⟶ B) :=
Iso.homCongr (Iso.refl _) (Functor.essImage.getIso hB)
@[simp]
theorem unitCompPartialBijective_symm_apply [Reflective i] (A : C) {B : C} (hB : i.essImage B)
(f) : (unitCompPartialBijective A hB).symm f = (reflectorAdjunction i).unit.app A ≫ f := by
simp [unitCompPartialBijective, unitCompPartialBijectiveAux_symm_apply]
theorem unitCompPartialBijective_symm_natural [Reflective i] (A : C) {B B' : C} (h : B ⟶ B')
(hB : i.essImage B) (hB' : i.essImage B') (f : i.obj ((reflector i).obj A) ⟶ B) :
(unitCompPartialBijective A hB').symm (f ≫ h) = (unitCompPartialBijective A hB).symm f ≫ h := by
simp
theorem unitCompPartialBijective_natural [Reflective i] (A : C) {B B' : C} (h : B ⟶ B')
(hB : i.essImage B) (hB' : i.essImage B') (f : A ⟶ B) :
(unitCompPartialBijective A hB') (f ≫ h) = unitCompPartialBijective A hB f ≫ h := by
rw [← Equiv.eq_symm_apply, unitCompPartialBijective_symm_natural A h hB, Equiv.symm_apply_apply]
instance [Reflective i] (X : Functor.EssImageSubcategory i) :
IsIso (NatTrans.app (reflectorAdjunction i).unit X.obj) :=
Functor.essImage.unit_isIso X.property
-- These attributes are necessary to make automation work in `equivEssImageOfReflective`.
-- Making them global doesn't break anything elsewhere, but this is enough for now.
-- TODO: investigate further.
attribute [local simp 900] ObjectProperty.ι_map in
attribute [local ext] Functor.essImage_ext in
/-- If `i : D ⥤ C` is reflective, the inverse functor of `i ≌ F.essImage` can be explicitly
defined by the reflector. -/
@[simps]
def equivEssImageOfReflective [Reflective i] : D ≌ i.EssImageSubcategory where
functor := i.toEssImage
inverse := i.essImage.ι ⋙ reflector i
unitIso := (asIso <| (reflectorAdjunction i).counit).symm
counitIso := Functor.fullyFaithfulCancelRight i.essImage.ι <|
NatIso.ofComponents (fun X ↦ (asIso ((reflectorAdjunction i).unit.app X.obj)).symm)
/--
A functor is *coreflective*, or *a coreflective inclusion*, if it is fully faithful and left
adjoint.
-/
class Coreflective (L : C ⥤ D) extends L.Full, L.Faithful where
/-- a choice of a right adjoint to `L` -/
R : D ⥤ C
/-- `L` is a left adjoint -/
adj : L ⊣ R
variable (j : C ⥤ D)
/-- The coreflector `D ⥤ C` when `L : C ⥤ D` is coreflective. -/
def coreflector [Coreflective j] : D ⥤ C := Coreflective.R (L := j)
/-- The adjunction `j ⊣ coreflector j` when `j` is coreflective. -/
def coreflectorAdjunction [Coreflective j] : j ⊣ coreflector j := Coreflective.adj
instance [Coreflective j] : j.IsLeftAdjoint := ⟨_, ⟨coreflectorAdjunction j⟩⟩
instance [Coreflective j] : (coreflector j).IsRightAdjoint := ⟨_, ⟨coreflectorAdjunction j⟩⟩
/-- A coreflective functor is fully faithful. -/
def Functor.fullyFaithfulOfCoreflective [Coreflective j] : j.FullyFaithful :=
(coreflectorAdjunction j).fullyFaithfulLOfIsIsoUnit
lemma counit_obj_eq_map_counit [Coreflective j] (X : D) :
(coreflectorAdjunction j).counit.app (j.obj ((coreflector j).obj X)) =
j.map ((coreflector j).map ((coreflectorAdjunction j).counit.app X)) := by
rw [← cancel_epi (j.map ((coreflectorAdjunction j).unit.app ((coreflector j).obj X))),
← j.map_comp]
simp
example [Coreflective j] {B : C} : IsIso ((coreflectorAdjunction j).counit.app (j.obj B)) :=
inferInstance
variable {j}
lemma Functor.essImage.counit_isIso [Coreflective j] {A : D} (h : j.essImage A) :
IsIso ((coreflectorAdjunction j).counit.app A) := by
rwa [isIso_counit_app_iff_mem_essImage]
lemma mem_essImage_of_counit_isSplitEpi [Coreflective j] {A : D}
[IsSplitEpi ((coreflectorAdjunction j).counit.app A)] : j.essImage A := by
let ε : coreflector j ⋙ j ⟶ 𝟭 D := (coreflectorAdjunction j).counit
haveI : IsIso (ε.app (j.obj ((coreflector j).obj A))) :=
Functor.essImage.counit_isIso ((j.obj_mem_essImage _))
have : Mono (ε.app A) := by
refine @mono_of_mono _ _ _ _ _ (ε.app A) (section_ (ε.app A)) ?_
rw [show ε.app A ≫ section_ _ = _ from (ε.naturality (section_ (ε.app A))).symm]
apply mono_comp _ (ε.app (j.obj ((coreflector j).obj A)))
haveI := isIso_of_mono_of_isSplitEpi (ε.app A)
exact (coreflectorAdjunction j).mem_essImage_of_counit_isIso A
instance Coreflective.comp (F : C ⥤ D) (G : D ⥤ E) [Coreflective F] [Coreflective G] :
Coreflective (F ⋙ G) where
R := coreflector G ⋙ coreflector F
adj := (coreflectorAdjunction F).comp (coreflectorAdjunction G)
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Adjunction/Additive.lean | import Mathlib.CategoryTheory.Preadditive.Yoneda.Basic
/-!
# Adjunctions between additive functors.
This provides some results and constructions for adjunctions between functors on
preadditive categories:
* If one of the adjoint functors is additive, so is the other.
* If one of the adjoint functors is additive, the equivalence `Adjunction.homEquiv` lifts to
an additive equivalence `Adjunction.homAddEquiv`.
* We also give a version of this additive equivalence as an isomorphism of `preadditiveYoneda`
functors (analogous to `Adjunction.compYonedaIso`), in `Adjunction.compPreadditiveYonedaIso`.
-/
universe u₁ u₂ v₁ v₂
namespace CategoryTheory
namespace Adjunction
open CategoryTheory Category Functor
variable {C : Type u₁} {D : Type u₂} [Category.{v₁} C] [Category.{v₂} D] [Preadditive C]
[Preadditive D] {F : C ⥤ D} {G : D ⥤ C} (adj : F ⊣ G)
include adj
lemma right_adjoint_additive [F.Additive] : G.Additive where
map_add {X Y} f g := (adj.homEquiv _ _).symm.injective (by simp [homEquiv_counit])
lemma left_adjoint_additive [G.Additive] : F.Additive where
map_add {X Y} f g := (adj.homEquiv _ _).injective (by simp [homEquiv_unit])
variable [F.Additive]
/-- If we have an adjunction `adj : F ⊣ G` of functors between preadditive categories,
and if `F` is additive, then the hom set equivalence upgrades to an `AddEquiv`.
Note that `F` is additive if and only if `G` is, by `Adjunction.right_adjoint_additive` and
`Adjunction.left_adjoint_additive`.
-/
def homAddEquiv (X : C) (Y : D) : AddEquiv (F.obj X ⟶ Y) (X ⟶ G.obj Y) :=
{ adj.homEquiv _ _ with
map_add' _ _ := by
have := adj.right_adjoint_additive
simp [homEquiv_apply] }
@[simp]
lemma homAddEquiv_apply (X : C) (Y : D) (f : F.obj X ⟶ Y) :
adj.homAddEquiv X Y f = adj.homEquiv X Y f := rfl
@[simp]
lemma homAddEquiv_symm_apply (X : C) (Y : D) (f : X ⟶ G.obj Y) :
(adj.homAddEquiv X Y).symm f = (adj.homEquiv X Y).symm f := rfl
@[simp]
lemma homAddEquiv_zero (X : C) (Y : D) : adj.homEquiv X Y 0 = 0 := map_zero (adj.homAddEquiv X Y)
@[simp]
lemma homAddEquiv_add (X : C) (Y : D) (f f' : F.obj X ⟶ Y) :
adj.homEquiv X Y (f + f') = adj.homEquiv X Y f + adj.homEquiv X Y f' :=
map_add (adj.homAddEquiv X Y) _ _
@[simp]
lemma homAddEquiv_sub (X : C) (Y : D) (f f' : F.obj X ⟶ Y) :
adj.homEquiv X Y (f - f') = adj.homEquiv X Y f - adj.homEquiv X Y f' :=
map_sub (adj.homAddEquiv X Y) _ _
@[simp]
lemma homAddEquiv_neg (X : C) (Y : D) (f : F.obj X ⟶ Y) :
adj.homEquiv X Y (- f) = - adj.homEquiv X Y f := map_neg (adj.homAddEquiv X Y) _
@[simp]
lemma homAddEquiv_symm_zero (X : C) (Y : D) :
(adj.homEquiv X Y).symm 0 = 0 := map_zero (adj.homAddEquiv X Y).symm
@[simp]
lemma homAddEquiv_symm_add (X : C) (Y : D) (f f' : X ⟶ G.obj Y) :
(adj.homEquiv X Y).symm (f + f') = (adj.homEquiv X Y).symm f + (adj.homEquiv X Y).symm f' :=
map_add (adj.homAddEquiv X Y).symm _ _
@[simp]
lemma homAddEquiv_symm_sub (X : C) (Y : D) (f f' : X ⟶ G.obj Y) :
(adj.homEquiv X Y).symm (f - f') = (adj.homEquiv X Y).symm f - (adj.homEquiv X Y).symm f' :=
map_sub (adj.homAddEquiv X Y).symm _ _
@[simp]
lemma homAddEquiv_symm_neg (X : C) (Y : D) (f : X ⟶ G.obj Y) :
(adj.homEquiv X Y).symm (- f) = - (adj.homEquiv X Y).symm f :=
map_neg (adj.homAddEquiv X Y).symm _
open Opposite in
/-- If we have an adjunction `adj : F ⊣ G` of functors between preadditive categories,
and if `F` is additive, then the hom set equivalence upgrades to an isomorphism between
`G ⋙ preadditiveYoneda` and `preadditiveYoneda ⋙ F`, once we throw in the necessary
universe lifting functors.
Note that `F` is additive if and only if `G` is, by `Adjunction.right_adjoint_additive` and
`Adjunction.left_adjoint_additive`.
-/
def compPreadditiveYonedaIso :
G ⋙ preadditiveYoneda ⋙ (whiskeringRight _ _ _).obj AddCommGrpCat.uliftFunctor.{max v₁ v₂} ≅
preadditiveYoneda ⋙ (whiskeringLeft _ _ _).obj F.op ⋙
(whiskeringRight _ _ _).obj AddCommGrpCat.uliftFunctor.{max v₁ v₂} :=
NatIso.ofComponents
(fun Y ↦ NatIso.ofComponents
(fun X ↦ (AddEquiv.ulift.trans ((adj.homAddEquiv (unop X) Y).symm.trans
AddEquiv.ulift.symm)).toAddCommGrpIso)
(fun g ↦ by
ext ⟨y⟩
exact AddEquiv.ulift.injective (adj.homEquiv_naturality_left_symm g.unop y)))
(fun f ↦ by
ext _ ⟨x⟩
exact AddEquiv.ulift.injective ((adj.homEquiv_naturality_right_symm x f)))
lemma compPreadditiveYonedaIso_hom_app_app_apply (X : Cᵒᵖ) (Y : D)
(a : ULift.{max v₁ v₂, v₁} (Opposite.unop X ⟶ G.obj Y)) :
((adj.compPreadditiveYonedaIso.hom.app Y).app X) a =
ULift.up ((adj.homEquiv (Opposite.unop X) Y).symm (AddEquiv.ulift a)) := rfl
lemma compPreadditiveYonedaIso_inv_app_app_apply (X : Cᵒᵖ) (Y : D)
(a : ULift.{max v₁ v₂, v₂} (F.obj (Opposite.unop X) ⟶ Y)) :
((adj.compPreadditiveYonedaIso.inv.app Y).app X) a =
ULift.up ((adj.homEquiv (Opposite.unop X) Y) (AddEquiv.ulift a)) := rfl
end Adjunction
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Adjunction/AdjointFunctorTheorems.lean | import Mathlib.CategoryTheory.Comma.StructuredArrow.Small
import Mathlib.CategoryTheory.Generator.Basic
import Mathlib.CategoryTheory.Limits.ConeCategory
import Mathlib.CategoryTheory.Limits.Constructions.WeaklyInitial
import Mathlib.CategoryTheory.Limits.FunctorCategory.Basic
import Mathlib.CategoryTheory.Subobject.Comma
/-!
# Adjoint functor theorem
This file proves the (general) adjoint functor theorem, in the form:
* If `G : D ⥤ C` preserves limits and `D` has limits, and satisfies the solution set condition,
then it has a left adjoint: `isRightAdjointOfPreservesLimitsOfIsCoseparating`.
We show that the converse holds, i.e. that if `G` has a left adjoint then it satisfies the solution
set condition, see `solutionSetCondition_of_isRightAdjoint`
(the file `CategoryTheory/Adjunction/Limits` already shows it preserves limits).
We define the *solution set condition* for the functor `G : D ⥤ C` to mean, for every object
`A : C`, there is a set-indexed family ${f_i : A ⟶ G (B_i)}$ such that any morphism `A ⟶ G X`
factors through one of the `f_i`.
This file also proves the special adjoint functor theorem, in the form:
* If `G : D ⥤ C` preserves limits and `D` is complete, well-powered and has a small coseparating
set, then `G` has a left adjoint: `isRightAdjointOfPreservesLimitsOfIsCoseparating`
Finally, we prove the following corollaries of the special adjoint functor theorem:
* If `C` is complete, well-powered and has a small coseparating set, then it is cocomplete:
`hasColimits_of_hasLimits_of_isCoseparating`, `hasColimits_of_hasLimits_of_hasCoseparator`
* If `C` is cocomplete, co-well-powered and has a small separating set, then it is complete:
`hasLimits_of_hasColimits_of_isSeparating`, `hasLimits_of_hasColimits_of_hasSeparator`
-/
universe v u u'
namespace CategoryTheory
open Limits
variable {J : Type v}
variable {C : Type u} [Category.{v} C]
/-- The functor `G : D ⥤ C` satisfies the *solution set condition* if for every `A : C`, there is a
family of morphisms `{f_i : A ⟶ G (B_i) // i ∈ ι}` such that given any morphism `h : A ⟶ G X`,
there is some `i ∈ ι` such that `h` factors through `f_i`.
The key part of this definition is that the indexing set `ι` lives in `Type v`, where `v` is the
universe of morphisms of the category: this is the "smallness" condition which allows the general
adjoint functor theorem to go through.
-/
def SolutionSetCondition {D : Type u} [Category.{v} D] (G : D ⥤ C) : Prop :=
∀ A : C,
∃ (ι : Type v) (B : ι → D) (f : ∀ i : ι, A ⟶ G.obj (B i)),
∀ (X) (h : A ⟶ G.obj X), ∃ (i : ι) (g : B i ⟶ X), f i ≫ G.map g = h
section GeneralAdjointFunctorTheorem
variable {D : Type u} [Category.{v} D]
variable (G : D ⥤ C)
/-- If `G : D ⥤ C` is a right adjoint it satisfies the solution set condition. -/
theorem solutionSetCondition_of_isRightAdjoint [G.IsRightAdjoint] : SolutionSetCondition G := by
intro A
refine
⟨PUnit, fun _ => G.leftAdjoint.obj A, fun _ => (Adjunction.ofIsRightAdjoint G).unit.app A, ?_⟩
intro B h
refine ⟨PUnit.unit, ((Adjunction.ofIsRightAdjoint G).homEquiv _ _).symm h, ?_⟩
rw [← Adjunction.homEquiv_unit, Equiv.apply_symm_apply]
/-- The general adjoint functor theorem says that if `G : D ⥤ C` preserves limits and `D` has them,
if `G` satisfies the solution set condition then `G` is a right adjoint.
-/
lemma isRightAdjoint_of_preservesLimits_of_solutionSetCondition [HasLimits D]
[PreservesLimits G] (hG : SolutionSetCondition G) : G.IsRightAdjoint := by
refine @isRightAdjointOfStructuredArrowInitials _ _ _ _ G ?_
intro A
specialize hG A
choose ι B f g using hG
let B' : ι → StructuredArrow A G := fun i => StructuredArrow.mk (f i)
have hB' : ∀ A' : StructuredArrow A G, ∃ i, Nonempty (B' i ⟶ A') := by
intro A'
obtain ⟨i, _, t⟩ := g _ A'.hom
exact ⟨i, ⟨StructuredArrow.homMk _ t⟩⟩
obtain ⟨T, hT⟩ := has_weakly_initial_of_weakly_initial_set_and_hasProducts hB'
apply hasInitial_of_weakly_initial_and_hasWideEqualizers hT
end GeneralAdjointFunctorTheorem
section SpecialAdjointFunctorTheorem
variable {D : Type u'} [Category.{v} D]
/-- The special adjoint functor theorem: if `G : D ⥤ C` preserves limits and `D` is complete,
well-powered and has a small coseparating set, then `G` has a left adjoint.
-/
lemma isRightAdjoint_of_preservesLimits_of_isCoseparating [HasLimits D] [WellPowered.{v} D]
{P : ObjectProperty D} [ObjectProperty.Small.{v} P]
(hP : P.IsCoseparating) (G : D ⥤ C) [PreservesLimits G] :
G.IsRightAdjoint := by
have : ∀ A, HasInitial (StructuredArrow A G) := fun A ↦
hasInitial_of_isCoseparating.{v} (StructuredArrow.isCoseparating_inverseImage_proj A G hP)
exact isRightAdjointOfStructuredArrowInitials _
/-- The special adjoint functor theorem: if `F : C ⥤ D` preserves colimits and `C` is cocomplete,
well-copowered and has a small separating set, then `F` has a right adjoint.
-/
lemma isLeftAdjoint_of_preservesColimits_of_isSeparating [HasColimits C] [WellPowered.{v} Cᵒᵖ]
{P : ObjectProperty C} [ObjectProperty.Small.{v} P]
(h𝒢 : P.IsSeparating) (F : C ⥤ D) [PreservesColimits F] :
F.IsLeftAdjoint :=
have : ∀ A, HasTerminal (CostructuredArrow F A) := fun A =>
hasTerminal_of_isSeparating.{v} (CostructuredArrow.isSeparating_inverseImage_proj F A h𝒢)
isLeftAdjoint_of_costructuredArrowTerminals _
end SpecialAdjointFunctorTheorem
namespace Limits
/-- A consequence of the special adjoint functor theorem: if `C` is complete, well-powered and
has a small coseparating set, then it is cocomplete. -/
theorem hasColimits_of_hasLimits_of_isCoseparating [HasLimits C] [WellPowered.{v} C]
{P : ObjectProperty C} [ObjectProperty.Small.{v} P] (hP : P.IsCoseparating) : HasColimits C :=
{ has_colimits_of_shape := fun _ _ =>
hasColimitsOfShape_iff_isRightAdjoint_const.2
(isRightAdjoint_of_preservesLimits_of_isCoseparating hP _) }
/-- A consequence of the special adjoint functor theorem: if `C` is cocomplete, well-copowered and
has a small separating set, then it is complete. -/
theorem hasLimits_of_hasColimits_of_isSeparating [HasColimits C] [WellPowered.{v} Cᵒᵖ]
{P : ObjectProperty C} [ObjectProperty.Small.{v} P] (hP : P.IsSeparating) : HasLimits C :=
{ has_limits_of_shape := fun _ _ =>
hasLimitsOfShape_iff_isLeftAdjoint_const.2
(isLeftAdjoint_of_preservesColimits_of_isSeparating hP _) }
/-- A consequence of the special adjoint functor theorem: if `C` is complete, well-powered and
has a separator, then it is complete. -/
theorem hasLimits_of_hasColimits_of_hasSeparator [HasColimits C] [HasSeparator C]
[WellPowered.{v} Cᵒᵖ] : HasLimits C :=
hasLimits_of_hasColimits_of_isSeparating <| isSeparator_separator C
/-- A consequence of the special adjoint functor theorem: if `C` is complete, well-powered and
has a coseparator, then it is cocomplete. -/
theorem hasColimits_of_hasLimits_of_hasCoseparator [HasLimits C] [HasCoseparator C]
[WellPowered.{v} C] : HasColimits C :=
hasColimits_of_hasLimits_of_isCoseparating <| isCoseparator_coseparator C
end Limits
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Adjunction/Comma.lean | import Mathlib.CategoryTheory.Limits.Shapes.Terminal
import Mathlib.CategoryTheory.Adjunction.Basic
import Mathlib.CategoryTheory.Comma.StructuredArrow.Basic
import Mathlib.CategoryTheory.PUnit
/-!
# Properties of comma categories relating to adjunctions
This file shows that for a functor `G : D ⥤ C` the data of an initial object in each
`StructuredArrow` category on `G` is equivalent to a left adjoint to `G`, as well as the dual.
Specifically, `adjunctionOfStructuredArrowInitials` gives the left adjoint assuming the
appropriate initial objects exist, and `mkInitialOfLeftAdjoint` constructs the initial objects
provided a left adjoint.
The duals are also shown.
-/
universe v₁ v₂ u₁ u₂
noncomputable section
namespace CategoryTheory
open Limits
variable {C : Type u₁} {D : Type u₂} [Category.{v₁} C] [Category.{v₂} D] (G : D ⥤ C)
section OfInitials
variable [∀ A, HasInitial (StructuredArrow A G)]
attribute [local simp] eq_iff_true_of_subsingleton in
/-- Implementation: If each structured arrow category on `G` has an initial object, an equivalence
which is helpful for constructing a left adjoint to `G`.
-/
@[simps]
def leftAdjointOfStructuredArrowInitialsAux (A : C) (B : D) :
((⊥_ StructuredArrow A G).right ⟶ B) ≃ (A ⟶ G.obj B) where
toFun g := (⊥_ StructuredArrow A G).hom ≫ G.map g
invFun f := CommaMorphism.right (initial.to (StructuredArrow.mk f))
left_inv g := by
let B' : StructuredArrow A G := StructuredArrow.mk ((⊥_ StructuredArrow A G).hom ≫ G.map g)
let g' : ⊥_ StructuredArrow A G ⟶ B' := StructuredArrow.homMk g rfl
have : initial.to _ = g' := by cat_disch
change CommaMorphism.right (initial.to B') = _
rw [this]
rfl
right_inv f := by
let B' : StructuredArrow A G := StructuredArrow.mk f
apply (CommaMorphism.w (initial.to B')).symm.trans (Category.id_comp _)
/--
If each structured arrow category on `G` has an initial object, construct a left adjoint to `G`. It
is shown that it is a left adjoint in `adjunctionOfStructuredArrowInitials`.
-/
def leftAdjointOfStructuredArrowInitials : C ⥤ D :=
Adjunction.leftAdjointOfEquiv (leftAdjointOfStructuredArrowInitialsAux G) fun _ _ => by simp
/--
If each structured arrow category on `G` has an initial object, we have a constructed left adjoint
to `G`.
-/
def adjunctionOfStructuredArrowInitials : leftAdjointOfStructuredArrowInitials G ⊣ G :=
Adjunction.adjunctionOfEquivLeft _ _
/-- If each structured arrow category on `G` has an initial object, `G` is a right adjoint. -/
lemma isRightAdjointOfStructuredArrowInitials : G.IsRightAdjoint where
exists_leftAdjoint := ⟨_, ⟨adjunctionOfStructuredArrowInitials G⟩⟩
end OfInitials
section OfTerminals
variable [∀ A, HasTerminal (CostructuredArrow G A)]
attribute [local simp] eq_iff_true_of_subsingleton in
/-- Implementation: If each costructured arrow category on `G` has a terminal object, an equivalence
which is helpful for constructing a right adjoint to `G`.
-/
@[simps]
def rightAdjointOfCostructuredArrowTerminalsAux (B : D) (A : C) :
(G.obj B ⟶ A) ≃ (B ⟶ (⊤_ CostructuredArrow G A).left) where
toFun g := CommaMorphism.left (terminal.from (CostructuredArrow.mk g))
invFun g := G.map g ≫ (⊤_ CostructuredArrow G A).hom
left_inv := by cat_disch
right_inv g := by
let B' : CostructuredArrow G A :=
CostructuredArrow.mk (G.map g ≫ (⊤_ CostructuredArrow G A).hom)
let g' : B' ⟶ ⊤_ CostructuredArrow G A := CostructuredArrow.homMk g rfl
have : terminal.from _ = g' := by cat_disch
change CommaMorphism.left (terminal.from B') = _
rw [this]
rfl
/--
If each costructured arrow category on `G` has a terminal object, construct a right adjoint to `G`.
It is shown that it is a right adjoint in `adjunctionOfStructuredArrowInitials`.
-/
def rightAdjointOfCostructuredArrowTerminals : C ⥤ D :=
Adjunction.rightAdjointOfEquiv (rightAdjointOfCostructuredArrowTerminalsAux G)
fun B₁ B₂ A f g => by
rw [← Equiv.eq_symm_apply]
simp
/-- If each costructured arrow category on `G` has a terminal object, we have a constructed right
adjoint to `G`.
-/
def adjunctionOfCostructuredArrowTerminals : G ⊣ rightAdjointOfCostructuredArrowTerminals G :=
Adjunction.adjunctionOfEquivRight _ _
/-- If each costructured arrow category on `G` has a terminal object, `G` is a left adjoint. -/
lemma isLeftAdjoint_of_costructuredArrowTerminals : G.IsLeftAdjoint where
exists_rightAdjoint :=
⟨rightAdjointOfCostructuredArrowTerminals G, ⟨Adjunction.adjunctionOfEquivRight _ _⟩⟩
end OfTerminals
section
variable {F : C ⥤ D}
attribute [local simp] Adjunction.homEquiv_unit Adjunction.homEquiv_counit
/-- Given a left adjoint to `G`, we can construct an initial object in each structured arrow
category on `G`. -/
def mkInitialOfLeftAdjoint (h : F ⊣ G) (A : C) :
IsInitial (StructuredArrow.mk (h.unit.app A) : StructuredArrow A G) where
desc B := StructuredArrow.homMk ((h.homEquiv _ _).symm B.pt.hom)
uniq s m _ := by
apply StructuredArrow.ext
simp [← StructuredArrow.w m]
/-- Given a right adjoint to `F`, we can construct a terminal object in each costructured arrow
category on `F`. -/
def mkTerminalOfRightAdjoint (h : F ⊣ G) (A : D) :
IsTerminal (CostructuredArrow.mk (h.counit.app A) : CostructuredArrow F A) where
lift B := CostructuredArrow.homMk (h.homEquiv _ _ B.pt.hom)
uniq s m _ := by
apply CostructuredArrow.ext
simp [← CostructuredArrow.w m]
end
theorem isRightAdjoint_iff_hasInitial_structuredArrow {G : D ⥤ C} :
G.IsRightAdjoint ↔ ∀ A, HasInitial (StructuredArrow A G) :=
⟨fun _ A => (mkInitialOfLeftAdjoint _ (Adjunction.ofIsRightAdjoint G) A).hasInitial,
fun _ => isRightAdjointOfStructuredArrowInitials _⟩
theorem isLeftAdjoint_iff_hasTerminal_costructuredArrow {F : C ⥤ D} :
F.IsLeftAdjoint ↔ ∀ A, HasTerminal (CostructuredArrow F A) :=
⟨fun _ A => (mkTerminalOfRightAdjoint _ (Adjunction.ofIsLeftAdjoint F) A).hasTerminal,
fun _ => isLeftAdjoint_of_costructuredArrowTerminals _⟩
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Adjunction/Evaluation.lean | import Mathlib.CategoryTheory.Limits.Shapes.Products
import Mathlib.CategoryTheory.Functor.EpiMono
/-!
# Adjunctions involving evaluation
We show that evaluation of functors have adjoints, given the existence of (co)products.
-/
namespace CategoryTheory
open CategoryTheory.Limits
universe v₁ v₂ v₃ u₁ u₂ u₃
variable {C : Type u₁} [Category.{v₁} C] (D : Type u₂) [Category.{v₂} D]
noncomputable section
section
variable [∀ a b : C, HasCoproductsOfShape (a ⟶ b) D]
/-- The left adjoint of evaluation. -/
@[simps]
def evaluationLeftAdjoint (c : C) : D ⥤ C ⥤ D where
obj d :=
{ obj := fun t => ∐ fun _ : c ⟶ t => d
map := fun f => Sigma.desc fun g => (Sigma.ι fun _ => d) <| g ≫ f}
map {_ d₂} f :=
{ app := fun _ => Sigma.desc fun h => f ≫ Sigma.ι (fun _ => d₂) h
naturality := by
intros
dsimp
ext
simp }
/-- The adjunction showing that evaluation is a right adjoint. -/
@[simps! unit_app counit_app_app]
def evaluationAdjunctionRight (c : C) : evaluationLeftAdjoint D c ⊣ (evaluation _ _).obj c :=
Adjunction.mkOfHomEquiv
{ homEquiv := fun d F =>
{ toFun := fun f => Sigma.ι (fun _ => d) (𝟙 _) ≫ f.app c
invFun := fun f => { app := fun _ => Sigma.desc fun h => f ≫ F.map h }
left_inv := by
intro f
ext x
dsimp
ext g
simp only [colimit.ι_desc, Cofan.mk_ι_app, Category.assoc, ← f.naturality,
evaluationLeftAdjoint_obj_map, colimit.ι_desc_assoc,
Discrete.functor_obj, Cofan.mk_pt, Category.id_comp]
right_inv := fun f => by simp } }
instance evaluationIsRightAdjoint (c : C) : ((evaluation _ D).obj c).IsRightAdjoint :=
⟨_, ⟨evaluationAdjunctionRight _ _⟩⟩
/-- See also the file `CategoryTheory.Limits.FunctorCategory.EpiMono`
for a similar result under a `HasPullbacks` assumption. -/
theorem NatTrans.mono_iff_mono_app' {F G : C ⥤ D} (η : F ⟶ G) : Mono η ↔ ∀ c, Mono (η.app c) := by
constructor
· intro h c
exact (inferInstance : Mono (((evaluation _ _).obj c).map η))
· intro _
apply NatTrans.mono_of_mono_app
end
section
variable [∀ a b : C, HasProductsOfShape (a ⟶ b) D]
/-- The right adjoint of evaluation. -/
@[simps]
def evaluationRightAdjoint (c : C) : D ⥤ C ⥤ D where
obj d :=
{ obj := fun t => ∏ᶜ fun _ : t ⟶ c => d
map := fun f => Pi.lift fun g => Pi.π _ <| f ≫ g }
map f := { app := fun _ => Pi.lift fun g => Pi.π _ g ≫ f }
/-- The adjunction showing that evaluation is a left adjoint. -/
@[simps! unit_app_app counit_app]
def evaluationAdjunctionLeft (c : C) : (evaluation _ _).obj c ⊣ evaluationRightAdjoint D c :=
Adjunction.mkOfHomEquiv
{ homEquiv := fun F d =>
{ toFun := fun f => { app := fun _ => Pi.lift fun g => F.map g ≫ f }
invFun := fun f => f.app _ ≫ Pi.π _ (𝟙 _)
left_inv := fun f => by simp
right_inv := by
intro f
ext x
dsimp
ext g
simp only [NatTrans.naturality_assoc,
evaluationRightAdjoint_obj_obj, evaluationRightAdjoint_obj_map, limit.lift_π,
Fan.mk_pt, Fan.mk_π_app, Category.comp_id] } }
instance evaluationIsLeftAdjoint (c : C) : ((evaluation _ D).obj c).IsLeftAdjoint :=
⟨_, ⟨evaluationAdjunctionLeft _ _⟩⟩
/-- See also the file `Mathlib/CategoryTheory/Limits/FunctorCategory/EpiMono.lean`
for a similar result under a `HasPushouts` assumption. -/
theorem NatTrans.epi_iff_epi_app' {F G : C ⥤ D} (η : F ⟶ G) : Epi η ↔ ∀ c, Epi (η.app c) := by
constructor
· intro h c
exact (inferInstance : Epi (((evaluation _ _).obj c).map η))
· intros
apply NatTrans.epi_of_epi_app
end
end
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Adjunction/Restrict.lean | import Mathlib.CategoryTheory.Adjunction.Basic
import Mathlib.CategoryTheory.HomCongr
/-!
# Restricting adjunctions
`Adjunction.restrictFullyFaithful` shows that an adjunction can be restricted along fully faithful
inclusions.
-/
namespace CategoryTheory.Adjunction
universe v₁ v₂ u₁ u₂ v₃ v₄ u₃ u₄
open Category Opposite
variable {C : Type u₁} [Category.{v₁} C]
variable {D : Type u₂} [Category.{v₂} D]
variable {C' : Type u₃} [Category.{v₃} C']
variable {D' : Type u₄} [Category.{v₄} D']
variable {iC : C ⥤ C'} {iD : D ⥤ D'}
{L' : C' ⥤ D'} {R' : D' ⥤ C'} (adj : L' ⊣ R') (hiC : iC.FullyFaithful) (hiD : iD.FullyFaithful)
{L : C ⥤ D} {R : D ⥤ C} (comm1 : iC ⋙ L' ≅ L ⋙ iD) (comm2 : iD ⋙ R' ≅ R ⋙ iC)
attribute [local simp] homEquiv_unit homEquiv_counit
/-- If `C` is a full subcategory of `C'` and `D` is a full subcategory of `D'`, then we can restrict
an adjunction `L' ⊣ R'` where `L' : C' ⥤ D'` and `R' : D' ⥤ C'` to `C` and `D`.
The construction here is slightly more general, in that `C` is required only to have a full and
faithful "inclusion" functor `iC : C ⥤ C'` (and similarly `iD : D ⥤ D'`) which commute (up to
natural isomorphism) with the proposed restrictions.
-/
noncomputable def restrictFullyFaithful : L ⊣ R :=
Adjunction.mkOfHomEquiv
{ homEquiv := fun X Y =>
calc
(L.obj X ⟶ Y) ≃ (iD.obj (L.obj X) ⟶ iD.obj Y) := hiD.homEquiv
_ ≃ (L'.obj (iC.obj X) ⟶ iD.obj Y) := Iso.homCongr (comm1.symm.app X) (Iso.refl _)
_ ≃ (iC.obj X ⟶ R'.obj (iD.obj Y)) := adj.homEquiv _ _
_ ≃ (iC.obj X ⟶ iC.obj (R.obj Y)) := Iso.homCongr (Iso.refl _) (comm2.app Y)
_ ≃ (X ⟶ R.obj Y) := hiC.homEquiv.symm
homEquiv_naturality_left_symm := fun {X' X Y} f g => by
apply hiD.map_injective
simpa [Trans.trans] using (comm1.inv.naturality_assoc f _).symm
homEquiv_naturality_right := fun {X Y' Y} f g => by
apply hiC.map_injective
suffices R'.map (iD.map g) ≫ comm2.hom.app Y = comm2.hom.app Y' ≫ iC.map (R.map g) by
simp [Trans.trans, this]
apply comm2.hom.naturality g }
@[simp, reassoc]
lemma map_restrictFullyFaithful_unit_app (X : C) :
iC.map ((adj.restrictFullyFaithful hiC hiD comm1 comm2).unit.app X) =
adj.unit.app (iC.obj X) ≫ R'.map (comm1.hom.app X) ≫ comm2.hom.app (L.obj X) := by
simp [restrictFullyFaithful]
@[simp, reassoc]
lemma map_restrictFullyFaithful_counit_app (X : D) :
iD.map ((adj.restrictFullyFaithful hiC hiD comm1 comm2).counit.app X) =
comm1.inv.app (R.obj X) ≫ L'.map (comm2.inv.app X) ≫ adj.counit.app (iD.obj X) := by
dsimp [restrictFullyFaithful]
simp
lemma restrictFullyFaithful_homEquiv_apply {X : C} {Y : D} (f : L.obj X ⟶ Y) :
(adj.restrictFullyFaithful hiC hiD comm1 comm2).homEquiv X Y f =
hiC.preimage (adj.unit.app (iC.obj X) ≫ R'.map (comm1.hom.app X) ≫
R'.map (iD.map f) ≫ comm2.hom.app Y) := by
-- This proof was just `simp [restrictFullyFaithful]` before https://github.com/leanprover-community/mathlib4/pull/16317
apply hiC.map_injective
simp only [homEquiv_apply, Functor.comp_obj, Functor.map_comp, map_restrictFullyFaithful_unit_app,
Functor.id_obj, assoc, Functor.FullyFaithful.map_preimage]
congr 2
exact (comm2.hom.naturality _).symm
end CategoryTheory.Adjunction |
.lake/packages/mathlib/Mathlib/CategoryTheory/Adjunction/Basic.lean | import Mathlib.CategoryTheory.Equivalence
import Mathlib.CategoryTheory.Yoneda
/-!
# Adjunctions between functors
`F ⊣ G` represents the data of an adjunction between two functors
`F : C ⥤ D` and `G : D ⥤ C`. `F` is the left adjoint and `G` is the right adjoint.
We provide various useful constructors:
* `mkOfHomEquiv`
* `mk'`: construct an adjunction from the data of a hom set equivalence, unit and counit natural
transformations together with proofs of the equalities `homEquiv_unit` and `homEquiv_counit`
relating them to each other.
* `leftAdjointOfEquiv` / `rightAdjointOfEquiv`
construct a left/right adjoint of a given functor given the action on objects and
the relevant equivalence of morphism spaces.
* `adjunctionOfEquivLeft` / `adjunctionOfEquivRight` witness that these constructions
give adjunctions.
There are also typeclasses `IsLeftAdjoint` / `IsRightAdjoint`, which asserts the
existence of a adjoint functor. Given `[F.IsLeftAdjoint]`, a chosen right
adjoint can be obtained as `F.rightAdjoint`.
`Adjunction.comp` composes adjunctions.
`toEquivalence` upgrades an adjunction to an equivalence,
given witnesses that the unit and counit are pointwise isomorphisms.
Conversely `Equivalence.toAdjunction` recovers the underlying adjunction from an equivalence.
## Overview of the directory `CategoryTheory.Adjunction`
* Adjoint lifting theorems are in the directory `Lifting`.
* The file `AdjointFunctorTheorems` proves the adjoint functor theorems.
* The file `Comma` shows that for a functor `G : D ⥤ C` the data of an initial object in each
`StructuredArrow` category on `G` is equivalent to a left adjoint to `G`, as well as the dual.
* The file `Evaluation` shows that products and coproducts are adjoint to evaluation of functors.
* The file `FullyFaithful` characterizes when adjoints are full or faithful in terms of the unit
and counit.
* The file `Limits` proves that left adjoints preserve colimits and right adjoints preserve limits.
* The file `Mates` establishes the bijection between the 2-cells
```
L₁ R₁
C --→ D C ←-- D
G ↓ ↗ ↓ H G ↓ ↘ ↓ H
E --→ F E ←-- F
L₂ R₂
```
where `L₁ ⊣ R₁` and `L₂ ⊣ R₂`. Specializing to a pair of adjoints `L₁ L₂ : C ⥤ D`,
`R₁ R₂ : D ⥤ C`, it provides equivalences `(L₂ ⟶ L₁) ≃ (R₁ ⟶ R₂)` and `(L₂ ≅ L₁) ≃ (R₁ ≅ R₂)`.
* The file `Opposites` contains constructions to relate adjunctions of functors to adjunctions of
their opposites.
* The file `Reflective` defines reflective functors, i.e. fully faithful right adjoints. Note that
many facts about reflective functors are proved in the earlier file `FullyFaithful`.
* The file `Restrict` defines the restriction of an adjunction along fully faithful functors.
* The file `Triple` proves that in an adjoint triple, the left adjoint is fully faithful if and
only if the right adjoint is.
* The file `Unique` proves uniqueness of adjoints.
* The file `Whiskering` proves that functors `F : D ⥤ E` and `G : E ⥤ D` with an adjunction
`F ⊣ G`, induce adjunctions between the functor categories `C ⥤ D` and `C ⥤ E`,
and the functor categories `E ⥤ C` and `D ⥤ C`.
## Other files related to adjunctions
* The file `CategoryTheory.Monad.Adjunction` develops the basic relationship between adjunctions
and (co)monads. There it is also shown that given an adjunction `L ⊣ R` and an isomorphism
`L ⋙ R ≅ 𝟭 C`, the unit is an isomorphism, and similarly for the counit.
-/
namespace CategoryTheory
open Category Functor
-- declare the `v`'s first; see `CategoryTheory.Category` for an explanation
universe v₁ v₂ v₃ u₁ u₂ u₃
variable {C : Type u₁} [Category.{v₁} C] {D : Type u₂} [Category.{v₂} D]
/-- `F ⊣ G` represents the data of an adjunction between two functors
`F : C ⥤ D` and `G : D ⥤ C`. `F` is the left adjoint and `G` is the right adjoint.
We use the unit-counit definition of an adjunction. There is a constructor `Adjunction.mk'`
which constructs an adjunction from the data of a hom set equivalence, a unit, and a counit,
together with proofs of the equalities `homEquiv_unit` and `homEquiv_counit` relating them to each
other.
There is also a constructor `Adjunction.mkOfHomEquiv` which constructs an adjunction from a natural
hom set equivalence.
To construct adjoints to a given functor, there are constructors `leftAdjointOfEquiv` and
`adjunctionOfEquivLeft` (as well as their duals). -/
@[stacks 0037]
structure Adjunction (F : C ⥤ D) (G : D ⥤ C) where
/-- The unit of an adjunction -/
unit : 𝟭 C ⟶ F.comp G
/-- The counit of an adjunction -/
counit : G.comp F ⟶ 𝟭 D
/-- Equality of the composition of the unit and counit with the identity `F ⟶ FGF ⟶ F = 𝟙` -/
left_triangle_components (X : C) :
F.map (unit.app X) ≫ counit.app (F.obj X) = 𝟙 (F.obj X) := by cat_disch
/-- Equality of the composition of the unit and counit with the identity `G ⟶ GFG ⟶ G = 𝟙` -/
right_triangle_components (Y : D) :
unit.app (G.obj Y) ≫ G.map (counit.app Y) = 𝟙 (G.obj Y) := by cat_disch
/-- The notation `F ⊣ G` stands for `Adjunction F G` representing that `F` is left adjoint to `G` -/
infixl:15 " ⊣ " => Adjunction
namespace Functor
/-- A class asserting the existence of a right adjoint. -/
class IsLeftAdjoint (left : C ⥤ D) : Prop where
exists_rightAdjoint : ∃ (right : D ⥤ C), Nonempty (left ⊣ right)
/-- A class asserting the existence of a left adjoint. -/
class IsRightAdjoint (right : D ⥤ C) : Prop where
exists_leftAdjoint : ∃ (left : C ⥤ D), Nonempty (left ⊣ right)
/-- A chosen left adjoint to a functor that is a right adjoint. -/
noncomputable def leftAdjoint (R : D ⥤ C) [IsRightAdjoint R] : C ⥤ D :=
(IsRightAdjoint.exists_leftAdjoint (right := R)).choose
/-- A chosen right adjoint to a functor that is a left adjoint. -/
noncomputable def rightAdjoint (L : C ⥤ D) [IsLeftAdjoint L] : D ⥤ C :=
(IsLeftAdjoint.exists_rightAdjoint (left := L)).choose
end Functor
/-- The adjunction associated to a functor known to be a left adjoint. -/
noncomputable def Adjunction.ofIsLeftAdjoint (left : C ⥤ D) [left.IsLeftAdjoint] :
left ⊣ left.rightAdjoint :=
IsLeftAdjoint.exists_rightAdjoint.choose_spec.some
/-- The adjunction associated to a functor known to be a right adjoint. -/
noncomputable def Adjunction.ofIsRightAdjoint (right : C ⥤ D) [right.IsRightAdjoint] :
right.leftAdjoint ⊣ right :=
IsRightAdjoint.exists_leftAdjoint.choose_spec.some
namespace Adjunction
attribute [reassoc (attr := simp)] left_triangle_components right_triangle_components
/-- The hom set equivalence associated to an adjunction. -/
@[simps -isSimp]
def homEquiv {F : C ⥤ D} {G : D ⥤ C} (adj : F ⊣ G) (X : C) (Y : D) :
(F.obj X ⟶ Y) ≃ (X ⟶ G.obj Y) where
toFun := fun f => adj.unit.app X ≫ G.map f
invFun := fun g => F.map g ≫ adj.counit.app Y
left_inv := fun f => by
dsimp
rw [F.map_comp, assoc, ← Functor.comp_map, adj.counit.naturality, ← assoc]
simp
right_inv := fun g => by
simp only [Functor.comp_obj, Functor.map_comp]
rw [← assoc, ← Functor.comp_map, ← adj.unit.naturality]
simp
alias homEquiv_unit := homEquiv_apply
alias homEquiv_counit := homEquiv_symm_apply
end Adjunction
-- These lemmas are not global simp lemmas because certain adjunctions
-- are constructed using `Adjunction.mkOfHomEquiv`, and we certainly
-- do not want `dsimp` to apply `homEquiv_unit` or `homEquiv_counit`
-- in that case. However, when proving general API results about adjunctions,
-- it may be advisable to add a local simp attribute to these lemmas.
attribute [local simp] Adjunction.homEquiv_unit Adjunction.homEquiv_counit
namespace Adjunction
@[ext]
lemma ext {F : C ⥤ D} {G : D ⥤ C} {adj adj' : F ⊣ G}
(h : adj.unit = adj'.unit) : adj = adj' := by
suffices h' : adj.counit = adj'.counit by cases adj; cases adj'; aesop
ext X
apply (adj.homEquiv _ _).injective
rw [Adjunction.homEquiv_unit, Adjunction.homEquiv_unit,
Adjunction.right_triangle_components, h, Adjunction.right_triangle_components]
section
variable {F : C ⥤ D} {G : D ⥤ C} (adj : F ⊣ G)
lemma isLeftAdjoint (adj : F ⊣ G) : F.IsLeftAdjoint := ⟨_, ⟨adj⟩⟩
lemma isRightAdjoint (adj : F ⊣ G) : G.IsRightAdjoint := ⟨_, ⟨adj⟩⟩
instance (R : D ⥤ C) [R.IsRightAdjoint] : R.leftAdjoint.IsLeftAdjoint :=
(ofIsRightAdjoint R).isLeftAdjoint
instance (L : C ⥤ D) [L.IsLeftAdjoint] : L.rightAdjoint.IsRightAdjoint :=
(ofIsLeftAdjoint L).isRightAdjoint
variable {X' X : C} {Y Y' : D}
theorem homEquiv_id (X : C) : adj.homEquiv X _ (𝟙 _) = adj.unit.app X := by simp
theorem homEquiv_symm_id (X : D) : (adj.homEquiv _ X).symm (𝟙 _) = adj.counit.app X := by simp
theorem homEquiv_naturality_left_symm (f : X' ⟶ X) (g : X ⟶ G.obj Y) :
(adj.homEquiv X' Y).symm (f ≫ g) = F.map f ≫ (adj.homEquiv X Y).symm g := by
simp
theorem homEquiv_naturality_left (f : X' ⟶ X) (g : F.obj X ⟶ Y) :
(adj.homEquiv X' Y) (F.map f ≫ g) = f ≫ (adj.homEquiv X Y) g := by
rw [← Equiv.eq_symm_apply]
simp only [Equiv.symm_apply_apply, homEquiv_naturality_left_symm]
theorem homEquiv_naturality_right (f : F.obj X ⟶ Y) (g : Y ⟶ Y') :
(adj.homEquiv X Y') (f ≫ g) = (adj.homEquiv X Y) f ≫ G.map g := by
simp
theorem homEquiv_naturality_right_symm (f : X ⟶ G.obj Y) (g : Y ⟶ Y') :
(adj.homEquiv X Y').symm (f ≫ G.map g) = (adj.homEquiv X Y).symm f ≫ g := by
rw [Equiv.symm_apply_eq]
simp only [homEquiv_naturality_right, Equiv.apply_symm_apply]
@[reassoc]
theorem homEquiv_naturality_left_square (f : X' ⟶ X) (g : F.obj X ⟶ Y')
(h : F.obj X' ⟶ Y) (k : Y ⟶ Y') (w : F.map f ≫ g = h ≫ k) :
f ≫ (adj.homEquiv X Y') g = (adj.homEquiv X' Y) h ≫ G.map k := by
rw [← homEquiv_naturality_left, ← homEquiv_naturality_right, w]
@[reassoc]
theorem homEquiv_naturality_right_square (f : X' ⟶ X) (g : X ⟶ G.obj Y')
(h : X' ⟶ G.obj Y) (k : Y ⟶ Y') (w : f ≫ g = h ≫ G.map k) :
F.map f ≫ (adj.homEquiv X Y').symm g = (adj.homEquiv X' Y).symm h ≫ k := by
rw [← homEquiv_naturality_left_symm, ← homEquiv_naturality_right_symm, w]
theorem homEquiv_naturality_left_square_iff (f : X' ⟶ X) (g : F.obj X ⟶ Y')
(h : F.obj X' ⟶ Y) (k : Y ⟶ Y') :
(f ≫ (adj.homEquiv X Y') g = (adj.homEquiv X' Y) h ≫ G.map k) ↔
(F.map f ≫ g = h ≫ k) :=
⟨fun w ↦ by simpa only [Equiv.symm_apply_apply]
using homEquiv_naturality_right_square adj _ _ _ _ w,
homEquiv_naturality_left_square adj f g h k⟩
theorem homEquiv_naturality_right_square_iff (f : X' ⟶ X) (g : X ⟶ G.obj Y')
(h : X' ⟶ G.obj Y) (k : Y ⟶ Y') :
(F.map f ≫ (adj.homEquiv X Y').symm g = (adj.homEquiv X' Y).symm h ≫ k) ↔
(f ≫ g = h ≫ G.map k) :=
⟨fun w ↦ by simpa only [Equiv.apply_symm_apply]
using homEquiv_naturality_left_square adj _ _ _ _ w,
homEquiv_naturality_right_square adj f g h k⟩
@[simp]
theorem left_triangle : whiskerRight adj.unit F ≫ whiskerLeft F adj.counit = 𝟙 _ := by
ext; simp
@[simp]
theorem right_triangle : whiskerLeft G adj.unit ≫ whiskerRight adj.counit G = 𝟙 _ := by
ext; simp
@[reassoc (attr := simp)]
theorem counit_naturality {X Y : D} (f : X ⟶ Y) :
F.map (G.map f) ≫ adj.counit.app Y = adj.counit.app X ≫ f :=
adj.counit.naturality f
@[reassoc (attr := simp)]
theorem unit_naturality {X Y : C} (f : X ⟶ Y) :
adj.unit.app X ≫ G.map (F.map f) = f ≫ adj.unit.app Y :=
(adj.unit.naturality f).symm
lemma unit_comp_map_eq_iff {A : C} {B : D} (f : F.obj A ⟶ B) (g : A ⟶ G.obj B) :
adj.unit.app A ≫ G.map f = g ↔ f = F.map g ≫ adj.counit.app B :=
⟨fun h => by simp [← h], fun h => by simp [h]⟩
lemma eq_unit_comp_map_iff {A : C} {B : D} (f : F.obj A ⟶ B) (g : A ⟶ G.obj B) :
g = adj.unit.app A ≫ G.map f ↔ F.map g ≫ adj.counit.app B = f :=
⟨fun h => by simp [h], fun h => by simp [← h]⟩
theorem homEquiv_apply_eq {A : C} {B : D} (f : F.obj A ⟶ B) (g : A ⟶ G.obj B) :
adj.homEquiv A B f = g ↔ f = (adj.homEquiv A B).symm g :=
unit_comp_map_eq_iff adj f g
theorem eq_homEquiv_apply {A : C} {B : D} (f : F.obj A ⟶ B) (g : A ⟶ G.obj B) :
g = adj.homEquiv A B f ↔ (adj.homEquiv A B).symm g = f :=
eq_unit_comp_map_iff adj f g
/-- If `adj : F ⊣ G`, and `X : C`, then `F.obj X` corepresents `Y ↦ (X ⟶ G.obj Y)`. -/
@[simps]
def corepresentableBy (X : C) :
(G ⋙ coyoneda.obj (Opposite.op X)).CorepresentableBy (F.obj X) where
homEquiv := adj.homEquiv _ _
homEquiv_comp := by simp
/-- If `adj : F ⊣ G`, and `Y : D`, then `G.obj Y` represents `X ↦ (F.obj X ⟶ Y)`. -/
@[simps]
def representableBy (Y : D) :
(F.op ⋙ yoneda.obj Y).RepresentableBy (G.obj Y) where
homEquiv := (adj.homEquiv _ _).symm
homEquiv_comp := by simp
end
end Adjunction
namespace Adjunction
/--
This is an auxiliary data structure useful for constructing adjunctions.
See `Adjunction.mk'`. This structure won't typically be used anywhere else.
-/
structure CoreHomEquivUnitCounit (F : C ⥤ D) (G : D ⥤ C) where
/-- The equivalence between `Hom (F X) Y` and `Hom X (G Y)` coming from an adjunction -/
homEquiv : ∀ X Y, (F.obj X ⟶ Y) ≃ (X ⟶ G.obj Y)
/-- The unit of an adjunction -/
unit : 𝟭 C ⟶ F ⋙ G
/-- The counit of an adjunction -/
counit : G ⋙ F ⟶ 𝟭 D
/-- The relationship between the unit and hom set equivalence of an adjunction -/
homEquiv_unit : ∀ {X Y f}, (homEquiv X Y) f = unit.app X ≫ G.map f := by cat_disch
/-- The relationship between the counit and hom set equivalence of an adjunction -/
homEquiv_counit : ∀ {X Y g}, (homEquiv X Y).symm g = F.map g ≫ counit.app Y := by cat_disch
/-- This is an auxiliary data structure useful for constructing adjunctions.
See `Adjunction.mkOfHomEquiv`.
This structure won't typically be used anywhere else.
-/
structure CoreHomEquiv (F : C ⥤ D) (G : D ⥤ C) where
/-- The equivalence between `Hom (F X) Y` and `Hom X (G Y)` -/
homEquiv : ∀ X Y, (F.obj X ⟶ Y) ≃ (X ⟶ G.obj Y)
/-- The property that describes how `homEquiv.symm` transforms compositions `X' ⟶ X ⟶ G Y` -/
homEquiv_naturality_left_symm :
∀ {X' X Y} (f : X' ⟶ X) (g : X ⟶ G.obj Y),
(homEquiv X' Y).symm (f ≫ g) = F.map f ≫ (homEquiv X Y).symm g := by
cat_disch
/-- The property that describes how `homEquiv` transforms compositions `F X ⟶ Y ⟶ Y'` -/
homEquiv_naturality_right :
∀ {X Y Y'} (f : F.obj X ⟶ Y) (g : Y ⟶ Y'),
(homEquiv X Y') (f ≫ g) = (homEquiv X Y) f ≫ G.map g := by
cat_disch
namespace CoreHomEquiv
attribute [simp] homEquiv_naturality_left_symm homEquiv_naturality_right
variable {F : C ⥤ D} {G : D ⥤ C} (adj : CoreHomEquiv F G) {X' X : C} {Y Y' : D}
theorem homEquiv_naturality_left (f : X' ⟶ X) (g : F.obj X ⟶ Y) :
(adj.homEquiv X' Y) (F.map f ≫ g) = f ≫ (adj.homEquiv X Y) g := by
rw [← Equiv.eq_symm_apply]; simp
theorem homEquiv_naturality_right_symm (f : X ⟶ G.obj Y) (g : Y ⟶ Y') :
(adj.homEquiv X Y').symm (f ≫ G.map g) = (adj.homEquiv X Y).symm f ≫ g := by
rw [Equiv.symm_apply_eq]; simp
end CoreHomEquiv
/-- This is an auxiliary data structure useful for constructing adjunctions.
See `Adjunction.mkOfUnitCounit`.
This structure won't typically be used anywhere else.
-/
structure CoreUnitCounit (F : C ⥤ D) (G : D ⥤ C) where
/-- The unit of an adjunction between `F` and `G` -/
unit : 𝟭 C ⟶ F.comp G
/-- The counit of an adjunction between `F` and `G`s -/
counit : G.comp F ⟶ 𝟭 D
/-- Equality of the composition of the unit, associator, and counit with the identity
`F ⟶ (F G) F ⟶ F (G F) ⟶ F = NatTrans.id F` -/
left_triangle :
whiskerRight unit F ≫ (associator F G F).hom ≫ whiskerLeft F counit =
NatTrans.id (𝟭 C ⋙ F) := by
cat_disch
/-- Equality of the composition of the unit, associator, and counit with the identity
`G ⟶ G (F G) ⟶ (F G) F ⟶ G = NatTrans.id G` -/
right_triangle :
whiskerLeft G unit ≫ (associator G F G).inv ≫ whiskerRight counit G =
NatTrans.id (G ⋙ 𝟭 C) := by
cat_disch
namespace CoreUnitCounit
attribute [simp] left_triangle right_triangle
end CoreUnitCounit
variable {F : C ⥤ D} {G : D ⥤ C}
attribute [local simp] CoreHomEquivUnitCounit.homEquiv_unit CoreHomEquivUnitCounit.homEquiv_counit
/--
Construct an adjunction from the data of a `CoreHomEquivUnitCounit`, i.e. a hom set
equivalence, unit and counit natural transformations together with proofs of the equalities
`homEquiv_unit` and `homEquiv_counit` relating them to each other.
-/
@[simps]
def mk' (adj : CoreHomEquivUnitCounit F G) : F ⊣ G where
unit := adj.unit
counit := adj.counit
left_triangle_components X := by
rw [← adj.homEquiv_counit, (adj.homEquiv _ _).symm_apply_eq, adj.homEquiv_unit]
simp
right_triangle_components Y := by
rw [← adj.homEquiv_unit, ← (adj.homEquiv _ _).eq_symm_apply, adj.homEquiv_counit]
simp
lemma mk'_homEquiv (adj : CoreHomEquivUnitCounit F G) : (mk' adj).homEquiv = adj.homEquiv := by
ext
rw [homEquiv_unit, adj.homEquiv_unit, mk'_unit]
/-- Construct an adjunction between `F` and `G` out of a natural bijection between each
`F.obj X ⟶ Y` and `X ⟶ G.obj Y`. -/
@[simps!]
def mkOfHomEquiv (adj : CoreHomEquiv F G) : F ⊣ G :=
mk' {
unit :=
{ app := fun X => (adj.homEquiv X (F.obj X)) (𝟙 (F.obj X))
naturality := by
intros
simp [← adj.homEquiv_naturality_left, ← adj.homEquiv_naturality_right] }
counit :=
{ app := fun Y => (adj.homEquiv _ _).invFun (𝟙 (G.obj Y))
naturality := by
intros
simp [← adj.homEquiv_naturality_left_symm, ← adj.homEquiv_naturality_right_symm] }
homEquiv := adj.homEquiv
homEquiv_unit := fun {X Y f} => by simp [← adj.homEquiv_naturality_right]
homEquiv_counit := fun {X Y f} => by simp [← adj.homEquiv_naturality_left_symm] }
@[simp]
lemma mkOfHomEquiv_homEquiv (adj : CoreHomEquiv F G) :
(mkOfHomEquiv adj).homEquiv = adj.homEquiv := by
ext X Y g
simp [mkOfHomEquiv, ← adj.homEquiv_naturality_right (𝟙 _) g]
/-- Construct an adjunction between functors `F` and `G` given a unit and counit for the adjunction
satisfying the triangle identities. -/
@[simps!]
def mkOfUnitCounit (adj : CoreUnitCounit F G) : F ⊣ G where
unit := adj.unit
counit := adj.counit
left_triangle_components X := by
have := adj.left_triangle
rw [NatTrans.ext_iff, funext_iff] at this
simpa [-CoreUnitCounit.left_triangle] using this X
right_triangle_components Y := by
have := adj.right_triangle
rw [NatTrans.ext_iff, funext_iff] at this
simpa [-CoreUnitCounit.right_triangle] using this Y
/-- The adjunction between the identity functor on a category and itself. -/
@[simps]
def id : 𝟭 C ⊣ 𝟭 C where
unit := 𝟙 _
counit := 𝟙 _
-- Satisfy the inhabited linter.
instance : Inhabited (Adjunction (𝟭 C) (𝟭 C)) :=
⟨id⟩
/-- If F and G are naturally isomorphic functors, establish an equivalence of hom-sets. -/
@[simps]
def equivHomsetLeftOfNatIso {F F' : C ⥤ D} (iso : F ≅ F') {X : C} {Y : D} :
(F.obj X ⟶ Y) ≃ (F'.obj X ⟶ Y) where
toFun f := iso.inv.app _ ≫ f
invFun g := iso.hom.app _ ≫ g
left_inv f := by simp
right_inv g := by simp
/-- If G and H are naturally isomorphic functors, establish an equivalence of hom-sets. -/
@[simps]
def equivHomsetRightOfNatIso {G G' : D ⥤ C} (iso : G ≅ G') {X : C} {Y : D} :
(X ⟶ G.obj Y) ≃ (X ⟶ G'.obj Y) where
toFun f := f ≫ iso.hom.app _
invFun g := g ≫ iso.inv.app _
left_inv f := by simp
right_inv g := by simp
/-- Transport an adjunction along a natural isomorphism on the left. -/
def ofNatIsoLeft {F G : C ⥤ D} {H : D ⥤ C} (adj : F ⊣ H) (iso : F ≅ G) : G ⊣ H :=
Adjunction.mkOfHomEquiv
{ homEquiv := fun X Y => (equivHomsetLeftOfNatIso iso.symm).trans (adj.homEquiv X Y) }
/-- Transport an adjunction along a natural isomorphism on the right. -/
def ofNatIsoRight {F : C ⥤ D} {G H : D ⥤ C} (adj : F ⊣ G) (iso : G ≅ H) : F ⊣ H :=
Adjunction.mkOfHomEquiv
{ homEquiv := fun X Y => (adj.homEquiv X Y).trans (equivHomsetRightOfNatIso iso) }
/-- The isomorphism which an adjunction `F ⊣ G` induces on `G ⋙ yoneda`. This states that
`Adjunction.homEquiv` is natural in both arguments. -/
@[simps!]
def compYonedaIso {C : Type u₁} [Category.{v₁} C] {D : Type u₂} [Category.{v₁} D]
{F : C ⥤ D} {G : D ⥤ C} (adj : F ⊣ G) :
G ⋙ yoneda ≅ yoneda ⋙ (whiskeringLeft _ _ _).obj F.op :=
NatIso.ofComponents fun X => NatIso.ofComponents fun Y => (adj.homEquiv Y.unop X).toIso.symm
/-- The isomorphism which an adjunction `F ⊣ G` induces on `F.op ⋙ coyoneda`. This states that
`Adjunction.homEquiv` is natural in both arguments. -/
@[simps!]
def compCoyonedaIso {C : Type u₁} [Category.{v₁} C] {D : Type u₂} [Category.{v₁} D]
{F : C ⥤ D} {G : D ⥤ C} (adj : F ⊣ G) :
F.op ⋙ coyoneda ≅ coyoneda ⋙ (whiskeringLeft _ _ _).obj G :=
NatIso.ofComponents fun X => NatIso.ofComponents fun Y => (adj.homEquiv X.unop Y).toIso
section
variable {E : Type u₃} [ℰ : Category.{v₃} E] {H : D ⥤ E} {I : E ⥤ D}
(adj₁ : F ⊣ G) (adj₂ : H ⊣ I)
/-- Composition of adjunctions. -/
@[simps! -isSimp unit counit, stacks 0DV0]
def comp : F ⋙ H ⊣ I ⋙ G :=
mk' {
homEquiv := fun _ _ ↦ Equiv.trans (adj₂.homEquiv _ _) (adj₁.homEquiv _ _)
unit := adj₁.unit ≫ whiskerRight (F.rightUnitor.inv ≫ whiskerLeft F adj₂.unit ≫
(associator _ _ _ ).inv) G ≫ (associator _ _ _).hom
counit := (associator _ _ _ ).inv ≫ whiskerRight ((associator _ _ _ ).hom ≫
whiskerLeft _ adj₁.counit ≫ I.rightUnitor.hom) _ ≫ adj₂.counit }
@[simp, reassoc]
lemma comp_unit_app (X : C) :
(adj₁.comp adj₂).unit.app X = adj₁.unit.app X ≫ G.map (adj₂.unit.app (F.obj X)) := by
simp [Adjunction.comp]
@[simp, reassoc]
lemma comp_counit_app (X : E) :
(adj₁.comp adj₂).counit.app X = H.map (adj₁.counit.app (I.obj X)) ≫ adj₂.counit.app X := by
simp [Adjunction.comp]
lemma comp_homEquiv : (adj₁.comp adj₂).homEquiv =
fun _ _ ↦ Equiv.trans (adj₂.homEquiv _ _) (adj₁.homEquiv _ _) :=
mk'_homEquiv _
end
section ConstructLeft
-- Construction of a left adjoint. In order to construct a left
-- adjoint to a functor G : D → C, it suffices to give the object part
-- of a functor F : C → D together with isomorphisms Hom(FX, Y) ≃
-- Hom(X, GY) natural in Y. The action of F on morphisms can be
-- constructed from this data.
variable {F_obj : C → D}
variable (e : ∀ X Y, (F_obj X ⟶ Y) ≃ (X ⟶ G.obj Y))
/-- Construct a left adjoint functor to `G`, given the functor's value on objects `F_obj` and
a bijection `e` between `F_obj X ⟶ Y` and `X ⟶ G.obj Y` satisfying a naturality law
`he : ∀ X Y Y' g h, e X Y' (h ≫ g) = e X Y h ≫ G.map g`.
Dual to `rightAdjointOfEquiv`. -/
@[simps!]
def leftAdjointOfEquiv (he : ∀ X Y Y' g h, e X Y' (h ≫ g) = e X Y h ≫ G.map g) : C ⥤ D where
obj := F_obj
map {X} {X'} f := (e X (F_obj X')).symm (f ≫ e X' (F_obj X') (𝟙 _))
map_comp := fun f f' => by
rw [Equiv.symm_apply_eq, he, Equiv.apply_symm_apply]
conv =>
rhs
rw [assoc, ← he, id_comp, Equiv.apply_symm_apply]
simp
variable (he : ∀ X Y Y' g h, e X Y' (h ≫ g) = e X Y h ≫ G.map g)
/-- Show that the functor given by `leftAdjointOfEquiv` is indeed left adjoint to `G`. Dual
to `adjunctionOfRightEquiv`. -/
@[simps!]
def adjunctionOfEquivLeft : leftAdjointOfEquiv e he ⊣ G :=
mkOfHomEquiv
{ homEquiv := e
homEquiv_naturality_left_symm := fun {X'} {X} {Y} f g => by
have {X : C} {Y Y' : D} (f : X ⟶ G.obj Y) (g : Y ⟶ Y') :
(e X Y').symm (f ≫ G.map g) = (e X Y).symm f ≫ g := by
rw [Equiv.symm_apply_eq, he]; simp
simp [← this, ← he] }
end ConstructLeft
section ConstructRight
-- Construction of a right adjoint, analogous to the above.
variable {G_obj : D → C}
variable (e : ∀ X Y, (F.obj X ⟶ Y) ≃ (X ⟶ G_obj Y))
private theorem he'' (he : ∀ X' X Y f g, e X' Y (F.map f ≫ g) = f ≫ e X Y g)
{X' X Y} (f g) : F.map f ≫ (e X Y).symm g = (e X' Y).symm (f ≫ g) := by
rw [Equiv.eq_symm_apply, he]; simp
/-- Construct a right adjoint functor to `F`, given the functor's value on objects `G_obj` and
a bijection `e` between `F.obj X ⟶ Y` and `X ⟶ G_obj Y` satisfying a naturality law
`he : ∀ X Y Y' g h, e X' Y (F.map f ≫ g) = f ≫ e X Y g`.
Dual to `leftAdjointOfEquiv`. -/
@[simps!]
def rightAdjointOfEquiv (he : ∀ X' X Y f g, e X' Y (F.map f ≫ g) = f ≫ e X Y g) : D ⥤ C where
obj := G_obj
map {Y} {Y'} g := (e (G_obj Y) Y') ((e (G_obj Y) Y).symm (𝟙 _) ≫ g)
map_comp := fun {Y} {Y'} {Y''} g g' => by
rw [← Equiv.eq_symm_apply, ← he'' e he, Equiv.symm_apply_apply]
conv =>
rhs
rw [← assoc, he'' e he, comp_id, Equiv.symm_apply_apply]
simp
/-- Show that the functor given by `rightAdjointOfEquiv` is indeed right adjoint to `F`. Dual
to `adjunctionOfEquivRight`. -/
@[simps!]
def adjunctionOfEquivRight (he : ∀ X' X Y f g, e X' Y (F.map f ≫ g) = f ≫ e X Y g) :
F ⊣ (rightAdjointOfEquiv e he) :=
mkOfHomEquiv
{ homEquiv := e
homEquiv_naturality_left_symm := by
intro X X' Y f g; rw [Equiv.symm_apply_eq]; simp [he]
homEquiv_naturality_right := by
intro X Y Y' g h
simp [← he, reassoc_of% (he'' e)] }
end ConstructRight
/--
If the unit and counit of a given adjunction are (pointwise) isomorphisms, then we can upgrade the
adjunction to an equivalence.
-/
@[simps!]
noncomputable def toEquivalence (adj : F ⊣ G) [∀ X, IsIso (adj.unit.app X)]
[∀ Y, IsIso (adj.counit.app Y)] : C ≌ D where
functor := F
inverse := G
unitIso := NatIso.ofComponents fun X => asIso (adj.unit.app X)
counitIso := NatIso.ofComponents fun Y => asIso (adj.counit.app Y)
end Adjunction
open Adjunction
/--
If the unit and counit for the adjunction corresponding to a right adjoint functor are (pointwise)
isomorphisms, then the functor is an equivalence of categories.
-/
lemma Functor.isEquivalence_of_isRightAdjoint (G : C ⥤ D) [IsRightAdjoint G]
[∀ X, IsIso ((Adjunction.ofIsRightAdjoint G).unit.app X)]
[∀ Y, IsIso ((Adjunction.ofIsRightAdjoint G).counit.app Y)] : G.IsEquivalence :=
(Adjunction.ofIsRightAdjoint G).toEquivalence.isEquivalence_inverse
namespace Equivalence
variable (e : C ≌ D)
/-- The adjunction given by an equivalence of categories. (To obtain the opposite adjunction,
simply use `e.symm.toAdjunction`. -/
@[simps]
def toAdjunction : e.functor ⊣ e.inverse where
unit := e.unit
counit := e.counit
lemma isLeftAdjoint_functor : e.functor.IsLeftAdjoint where
exists_rightAdjoint := ⟨_, ⟨e.toAdjunction⟩⟩
lemma isRightAdjoint_inverse : e.inverse.IsRightAdjoint where
exists_leftAdjoint := ⟨_, ⟨e.toAdjunction⟩⟩
lemma isLeftAdjoint_inverse : e.inverse.IsLeftAdjoint :=
e.symm.isLeftAdjoint_functor
lemma isRightAdjoint_functor : e.functor.IsRightAdjoint :=
e.symm.isRightAdjoint_inverse
lemma refl_toAdjunction : (refl (C := C)).toAdjunction = Adjunction.id := rfl
lemma trans_toAdjunction {E : Type*} [Category E] (e' : D ≌ E) :
(e.trans e').toAdjunction = e.toAdjunction.comp e'.toAdjunction := rfl
end Equivalence
namespace Functor
/-- If `F` and `G` are left adjoints then `F ⋙ G` is a left adjoint too. -/
instance isLeftAdjoint_comp {E : Type u₃} [Category.{v₃} E] (F : C ⥤ D) (G : D ⥤ E)
[F.IsLeftAdjoint] [G.IsLeftAdjoint] : (F ⋙ G).IsLeftAdjoint where
exists_rightAdjoint :=
⟨_, ⟨(Adjunction.ofIsLeftAdjoint F).comp (Adjunction.ofIsLeftAdjoint G)⟩⟩
/-- If `F` and `G` are right adjoints then `F ⋙ G` is a right adjoint too. -/
instance isRightAdjoint_comp {E : Type u₃} [Category.{v₃} E] {F : C ⥤ D} {G : D ⥤ E}
[IsRightAdjoint F] [IsRightAdjoint G] : IsRightAdjoint (F ⋙ G) where
exists_leftAdjoint :=
⟨_, ⟨(Adjunction.ofIsRightAdjoint G).comp (Adjunction.ofIsRightAdjoint F)⟩⟩
/-- Transport being a right adjoint along a natural isomorphism. -/
lemma isRightAdjoint_of_iso {F G : C ⥤ D} (h : F ≅ G) [F.IsRightAdjoint] :
IsRightAdjoint G where
exists_leftAdjoint := ⟨_, ⟨(Adjunction.ofIsRightAdjoint F).ofNatIsoRight h⟩⟩
/-- Transport being a left adjoint along a natural isomorphism. -/
lemma isLeftAdjoint_of_iso {F G : C ⥤ D} (h : F ≅ G) [IsLeftAdjoint F] :
IsLeftAdjoint G where
exists_rightAdjoint := ⟨_, ⟨(Adjunction.ofIsLeftAdjoint F).ofNatIsoLeft h⟩⟩
/-- An equivalence `E` is left adjoint to its inverse. -/
noncomputable def adjunction (E : C ⥤ D) [IsEquivalence E] : E ⊣ E.inv :=
E.asEquivalence.toAdjunction
/-- If `F` is an equivalence, it's a left adjoint. -/
instance (priority := 10) isLeftAdjoint_of_isEquivalence {F : C ⥤ D} [F.IsEquivalence] :
IsLeftAdjoint F :=
F.asEquivalence.isLeftAdjoint_functor
/-- If `F` is an equivalence, it's a right adjoint. -/
instance (priority := 10) isRightAdjoint_of_isEquivalence {F : C ⥤ D} [F.IsEquivalence] :
IsRightAdjoint F :=
F.asEquivalence.isRightAdjoint_functor
end Functor
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Adjunction/PartialAdjoint.lean | import Mathlib.CategoryTheory.Adjunction.Basic
import Mathlib.CategoryTheory.Limits.HasLimits
import Mathlib.CategoryTheory.Yoneda
/-!
# Domain of definition of the partial left adjoint
Given a functor `F : D ⥤ C`, we define a functor
`F.partialLeftAdjoint : F.PartialLeftAdjointSource ⥤ D` which is
defined on the full subcategory of `C` consisting of those objects `X : C`
such that `F ⋙ coyoneda.obj (op X) : D ⥤ Type _` is corepresentable.
We have a natural bijection
`(F.partialLeftAdjoint.obj X ⟶ Y) ≃ (X.obj ⟶ F.obj Y)`
that is similar to what we would expect for the image of the object `X`
by the left adjoint of `F`, if such an adjoint existed.
Indeed, if the predicate `F.LeftAdjointObjIsDefined` which defines
the `F.PartialLeftAdjointSource` holds for all
objects `X : C`, then `F` has a left adjoint.
When colimits indexed by a category `J` exist in `D`, we show that
the predicate `F.LeftAdjointObjIsDefined` is stable under colimits indexed by `J`.
## TODO
* consider dualizing the results to right adjoints
-/
universe v₁ v₂ u₁ u₂
namespace CategoryTheory
namespace Functor
open Category Opposite Limits
section partialLeftAdjoint
variable {C : Type u₁} [Category.{v₁} C] {D : Type u₂} [Category.{v₂} D] (F : D ⥤ C)
/-- Given a functor `F : D ⥤ C`, this is a predicate on objects `X : C` corresponding
to the domain of definition of the (partial) left adjoint of `F`. -/
def leftAdjointObjIsDefined : ObjectProperty C :=
fun X ↦ IsCorepresentable (F ⋙ coyoneda.obj (op X))
lemma leftAdjointObjIsDefined_iff (X : C) :
F.leftAdjointObjIsDefined X ↔ IsCorepresentable (F ⋙ coyoneda.obj (op X)) := by rfl
variable {F} in
lemma leftAdjointObjIsDefined_of_adjunction {G : C ⥤ D} (adj : G ⊣ F) (X : C) :
F.leftAdjointObjIsDefined X :=
(adj.corepresentableBy X).isCorepresentable
/-- The full subcategory where `F.partialLeftAdjoint` shall be defined. -/
abbrev PartialLeftAdjointSource := F.leftAdjointObjIsDefined.FullSubcategory
instance (X : F.PartialLeftAdjointSource) :
IsCorepresentable (F ⋙ coyoneda.obj (op X.obj)) := X.property
/-- Given `F : D ⥤ C`, this is `F.partialLeftAdjoint` on objects: it sends
`X : C` such that `F.leftAdjointObjIsDefined X` holds to an object of `D`
which represents the functor `F ⋙ coyoneda.obj (op X.obj)`. -/
noncomputable def partialLeftAdjointObj (X : F.PartialLeftAdjointSource) : D :=
(F ⋙ coyoneda.obj (op X.obj)).coreprX
/-- Given `F : D ⥤ C`, this is the canonical bijection
`(F.partialLeftAdjointObj X ⟶ Y) ≃ (X.obj ⟶ F.obj Y)`
for all `X : F.PartialLeftAdjointSource` and `Y : D`. -/
noncomputable def partialLeftAdjointHomEquiv {X : F.PartialLeftAdjointSource} {Y : D} :
(F.partialLeftAdjointObj X ⟶ Y) ≃ (X.obj ⟶ F.obj Y) :=
(F ⋙ coyoneda.obj (op X.obj)).corepresentableBy.homEquiv
lemma partialLeftAdjointHomEquiv_comp {X : F.PartialLeftAdjointSource} {Y Y' : D}
(f : F.partialLeftAdjointObj X ⟶ Y) (g : Y ⟶ Y') :
F.partialLeftAdjointHomEquiv (f ≫ g) =
F.partialLeftAdjointHomEquiv f ≫ F.map g := by
apply CorepresentableBy.homEquiv_comp
/-- Given `F : D ⥤ C`, this is `F.partialLeftAdjoint` on morphisms. -/
noncomputable def partialLeftAdjointMap {X Y : F.PartialLeftAdjointSource}
(f : X ⟶ Y) : F.partialLeftAdjointObj X ⟶ F.partialLeftAdjointObj Y :=
F.partialLeftAdjointHomEquiv.symm (f ≫ F.partialLeftAdjointHomEquiv (𝟙 _))
@[simp]
lemma partialLeftAdjointHomEquiv_map {X Y : F.PartialLeftAdjointSource}
(f : X ⟶ Y) :
F.partialLeftAdjointHomEquiv (F.partialLeftAdjointMap f) =
by exact f ≫ F.partialLeftAdjointHomEquiv (𝟙 _) := by
simp [partialLeftAdjointMap]
lemma partialLeftAdjointHomEquiv_map_comp {X X' : F.PartialLeftAdjointSource} {Y : D}
(f : X ⟶ X') (g : F.partialLeftAdjointObj X' ⟶ Y) :
F.partialLeftAdjointHomEquiv (F.partialLeftAdjointMap f ≫ g) =
by exact f ≫ F.partialLeftAdjointHomEquiv g := by
rw [partialLeftAdjointHomEquiv_comp, partialLeftAdjointHomEquiv_map, assoc,
← partialLeftAdjointHomEquiv_comp, id_comp]
@[reassoc]
lemma partialLeftAdjointHomEquiv_symm_comp {X : F.PartialLeftAdjointSource} {Y Y' : D}
(f : X.obj ⟶ F.obj Y) (g : Y ⟶ Y') :
F.partialLeftAdjointHomEquiv.symm f ≫ g = F.partialLeftAdjointHomEquiv.symm (f ≫ F.map g) :=
CorepresentableBy.homEquiv_symm_comp ..
@[reassoc]
lemma partialLeftAdjointHomEquiv_comp_symm {X X' : F.PartialLeftAdjointSource} {Y : D}
(f : X'.obj ⟶ F.obj Y) (g : X ⟶ X') :
F.partialLeftAdjointMap g ≫ F.partialLeftAdjointHomEquiv.symm f =
F.partialLeftAdjointHomEquiv.symm (g ≫ f) := by
rw [Equiv.eq_symm_apply, partialLeftAdjointHomEquiv_comp, partialLeftAdjointHomEquiv_map,
assoc, ← partialLeftAdjointHomEquiv_comp, id_comp, Equiv.apply_symm_apply]
/-- Given `F : D ⥤ C`, this is the partial adjoint functor `F.PartialLeftAdjointSource ⥤ D`. -/
@[simps]
noncomputable def partialLeftAdjoint : F.PartialLeftAdjointSource ⥤ D where
obj := F.partialLeftAdjointObj
map := F.partialLeftAdjointMap
map_id X := by
apply F.partialLeftAdjointHomEquiv.injective
dsimp
rw [partialLeftAdjointHomEquiv_map]
erw [id_comp]
map_comp {X Y Z} f g := by
apply F.partialLeftAdjointHomEquiv.injective
dsimp
rw [partialLeftAdjointHomEquiv_map, partialLeftAdjointHomEquiv_comp,
partialLeftAdjointHomEquiv_map, assoc]
erw [assoc]
rw [← F.partialLeftAdjointHomEquiv_comp, id_comp,
partialLeftAdjointHomEquiv_map]
variable {F}
lemma isRightAdjoint_of_leftAdjointObjIsDefined_eq_top
(h : F.leftAdjointObjIsDefined = ⊤) : F.IsRightAdjoint := by
replace h : ∀ X, IsCorepresentable (F ⋙ coyoneda.obj (op X)) := fun X ↦ by
simp only [← leftAdjointObjIsDefined_iff, h, Pi.top_apply, Prop.top_eq_true]
exact (Adjunction.adjunctionOfEquivLeft
(fun X Y ↦ (F ⋙ coyoneda.obj (op X)).corepresentableBy.homEquiv)
(fun X Y Y' g f ↦ by apply CorepresentableBy.homEquiv_comp)).isRightAdjoint
variable (F) in
lemma isRightAdjoint_iff_leftAdjointObjIsDefined_eq_top :
F.IsRightAdjoint ↔ F.leftAdjointObjIsDefined = ⊤ := by
refine ⟨fun h ↦ ?_, isRightAdjoint_of_leftAdjointObjIsDefined_eq_top⟩
ext X
simpa only [Pi.top_apply, Prop.top_eq_true, iff_true]
using leftAdjointObjIsDefined_of_adjunction (Adjunction.ofIsRightAdjoint F) X
/-- Auxiliary definition for `leftAdjointObjIsDefined_of_isColimit`. -/
noncomputable def corepresentableByCompCoyonedaObjOfIsColimit {J : Type*} [Category J]
{R : J ⥤ F.PartialLeftAdjointSource}
{c : Cocone (R ⋙ ObjectProperty.ι _)} (hc : IsColimit c)
{c' : Cocone (R ⋙ F.partialLeftAdjoint)} (hc' : IsColimit c') :
(F ⋙ coyoneda.obj (op c.pt)).CorepresentableBy c'.pt where
homEquiv {Y} :=
{ toFun := fun f ↦ hc.desc (Cocone.mk _
{ app := fun j ↦ F.partialLeftAdjointHomEquiv (c'.ι.app j ≫ f)
naturality := fun j j' φ ↦ by
dsimp
rw [comp_id, ← c'.w φ, ← partialLeftAdjointHomEquiv_map_comp, assoc]
dsimp })
invFun := fun g ↦ hc'.desc (Cocone.mk _
{ app := fun j ↦ F.partialLeftAdjointHomEquiv.symm (c.ι.app j ≫ g)
naturality := fun j j' φ ↦ by
apply F.partialLeftAdjointHomEquiv.injective
have := c.w φ
dsimp at this ⊢
rw [comp_id, Equiv.apply_symm_apply, partialLeftAdjointHomEquiv_map_comp,
Equiv.apply_symm_apply, reassoc_of% this] })
left_inv := fun f ↦ hc'.hom_ext (fun j ↦ by simp)
right_inv := fun g ↦ hc.hom_ext (fun j ↦ by simp) }
homEquiv_comp {Y Y'} g f := hc.hom_ext (fun j ↦ by
dsimp
simp only [IsColimit.fac, IsColimit.fac_assoc, partialLeftAdjointHomEquiv_comp,
F.map_comp, assoc] )
lemma leftAdjointObjIsDefined_of_isColimit {J : Type*} [Category J] {R : J ⥤ C} {c : Cocone R}
(hc : IsColimit c) [HasColimitsOfShape J D]
(h : ∀ (j : J), F.leftAdjointObjIsDefined (R.obj j)) :
F.leftAdjointObjIsDefined c.pt :=
(corepresentableByCompCoyonedaObjOfIsColimit
(R := ObjectProperty.lift _ R h) hc (colimit.isColimit _)).isCorepresentable
lemma leftAdjointObjIsDefined_colimit {J : Type*} [Category J] (R : J ⥤ C)
[HasColimit R] [HasColimitsOfShape J D]
(h : ∀ (j : J), F.leftAdjointObjIsDefined (R.obj j)) :
F.leftAdjointObjIsDefined (colimit R) :=
leftAdjointObjIsDefined_of_isColimit (colimit.isColimit R) h
end partialLeftAdjoint
section partialRightAdjoint
variable {C : Type u₁} [Category.{v₁} C] {D : Type u₂} [Category.{v₂} D] (F : C ⥤ D)
/-- Given a functor `F : C ⥤ D`, this is a predicate on objects `X : D` corresponding
to the domain of definition of the (partial) right adjoint of `F`. -/
def rightAdjointObjIsDefined : ObjectProperty D :=
fun Y ↦ IsRepresentable (F.op ⋙ yoneda.obj Y)
lemma rightAdjointObjIsDefined_iff (Y : D) :
F.rightAdjointObjIsDefined Y ↔ IsRepresentable (F.op ⋙ yoneda.obj Y) := by rfl
variable {F} in
lemma rightAdjointObjIsDefined_of_adjunction {G : D ⥤ C} (adj : F ⊣ G) (Y : D) :
F.rightAdjointObjIsDefined Y :=
(adj.representableBy Y).isRepresentable
/-- The full subcategory where `F.partialRightAdjoint` shall be defined. -/
abbrev PartialRightAdjointSource := F.rightAdjointObjIsDefined.FullSubcategory
instance (Y : F.PartialRightAdjointSource) :
IsRepresentable (F.op ⋙ yoneda.obj Y.obj) := Y.property
/-- Given `F : C ⥤ D`, this is `F.partialRightAdjoint` on objects: it sends
`X : D` such that `F.rightAdjointObjIsDefined X` holds to an object of `C`
which represents the functor `F ⋙ coyoneda.obj (op X.obj)`. -/
noncomputable def partialRightAdjointObj (Y : F.PartialRightAdjointSource) : C :=
(F.op ⋙ yoneda.obj Y.obj).reprX
/-- Given `F : C ⥤ D`, this is the canonical bijection
`(X ⟶ F.partialRightAdjointObj Y) ≃ (F.obj X ⟶ Y.obj)`
for all `X : C` and `Y : F.PartialRightAdjointSource`. -/
noncomputable def partialRightAdjointHomEquiv {X : C} {Y : F.PartialRightAdjointSource} :
(X ⟶ F.partialRightAdjointObj Y) ≃ (F.obj X ⟶ Y.obj) :=
(F.op ⋙ yoneda.obj Y.obj).representableBy.homEquiv
lemma partialRightAdjointHomEquiv_comp {X X' : C} {Y : F.PartialRightAdjointSource}
(f : X' ⟶ F.partialRightAdjointObj Y) (g : X ⟶ X') :
F.partialRightAdjointHomEquiv (g ≫ f) =
F.map g ≫ F.partialRightAdjointHomEquiv f :=
RepresentableBy.homEquiv_comp ..
/-- Given `F : C ⥤ D`, this is `F.partialRightAdjoint` on morphisms. -/
noncomputable def partialRightAdjointMap {X Y : F.PartialRightAdjointSource}
(f : X ⟶ Y) : F.partialRightAdjointObj X ⟶ F.partialRightAdjointObj Y :=
F.partialRightAdjointHomEquiv.symm (F.partialRightAdjointHomEquiv (𝟙 _) ≫ f)
@[simp]
lemma partialRightAdjointHomEquiv_map {X Y : F.PartialRightAdjointSource}
(f : X ⟶ Y) :
F.partialRightAdjointHomEquiv (F.partialRightAdjointMap f) =
F.partialRightAdjointHomEquiv (𝟙 _) ≫ f := by
simp [partialRightAdjointMap]
lemma partialRightAdjointHomEquiv_map_comp {X : C} {Y Y' : F.PartialRightAdjointSource}
(f : X ⟶ F.partialRightAdjointObj Y) (g : Y ⟶ Y') :
F.partialRightAdjointHomEquiv (f ≫ F.partialRightAdjointMap g) =
F.partialRightAdjointHomEquiv f ≫ g := by
rw [partialRightAdjointHomEquiv_comp, partialRightAdjointHomEquiv_map,
← assoc, ← partialRightAdjointHomEquiv_comp, comp_id]
@[reassoc]
lemma partialRightAdjointHomEquiv_comp_symm {X X' : C} {Y : F.PartialRightAdjointSource}
(f : F.obj X' ⟶ Y.obj) (g : X ⟶ X') :
g ≫ F.partialRightAdjointHomEquiv.symm f =
F.partialRightAdjointHomEquiv.symm (F.map g ≫ f) :=
RepresentableBy.comp_homEquiv_symm ..
@[reassoc]
lemma partialRightAdjointHomEquiv_symm_comp {X : C} {Y Y' : F.PartialRightAdjointSource}
(f : F.obj X ⟶ Y.obj) (g : Y ⟶ Y') :
F.partialRightAdjointHomEquiv.symm f ≫ F.partialRightAdjointMap g =
F.partialRightAdjointHomEquiv.symm (f ≫ g) := by
simp [Equiv.eq_symm_apply, partialRightAdjointHomEquiv_map_comp]
/-- Given `F : C ⥤ D`, this is the partial adjoint functor `F.PartialLeftAdjointSource ⥤ C`. -/
@[simps]
noncomputable def partialRightAdjoint : F.PartialRightAdjointSource ⥤ C where
obj := F.partialRightAdjointObj
map := F.partialRightAdjointMap
map_id X := by
apply F.partialRightAdjointHomEquiv.injective
dsimp
rw [partialRightAdjointHomEquiv_map]
erw [comp_id]
map_comp {X Y Z} f g := by
apply F.partialRightAdjointHomEquiv.injective
dsimp
rw [partialRightAdjointHomEquiv_map, partialRightAdjointHomEquiv_comp,
partialRightAdjointHomEquiv_map, ← assoc]
erw [← assoc]
rw [← F.partialRightAdjointHomEquiv_comp, comp_id,
partialRightAdjointHomEquiv_map]
variable {F}
lemma isLeftAdjoint_of_rightAdjointObjIsDefined_eq_top
(h : F.rightAdjointObjIsDefined = ⊤) : F.IsLeftAdjoint := by
replace h : ∀ X, IsRepresentable (F.op ⋙ yoneda.obj X) := fun X ↦ by
simp only [← rightAdjointObjIsDefined_iff, h, Pi.top_apply, Prop.top_eq_true]
exact (Adjunction.adjunctionOfEquivRight
(fun X Y ↦ (F.op ⋙ yoneda.obj Y).representableBy.homEquiv.symm)
(fun X Y Y' g f ↦ (RepresentableBy.comp_homEquiv_symm ..).symm)).isLeftAdjoint
variable (F) in
lemma isLeftAdjoint_iff_rightAdjointObjIsDefined_eq_top :
F.IsLeftAdjoint ↔ F.rightAdjointObjIsDefined = ⊤ := by
refine ⟨fun h ↦ ?_, isLeftAdjoint_of_rightAdjointObjIsDefined_eq_top⟩
ext X
simpa only [Pi.top_apply, Prop.top_eq_true, iff_true]
using rightAdjointObjIsDefined_of_adjunction (Adjunction.ofIsLeftAdjoint F) X
/-- Auxiliary definition for `rightAdjointObjIsDefined_of_isLimit`. -/
noncomputable def representableByCompYonedaObjOfIsLimit {J : Type*} [Category J]
{R : J ⥤ F.PartialRightAdjointSource}
{c : Cone (R ⋙ ObjectProperty.ι _)} (hc : IsLimit c)
{c' : Cone (R ⋙ F.partialRightAdjoint)} (hc' : IsLimit c') :
(F.op ⋙ yoneda.obj c.pt).RepresentableBy c'.pt where
homEquiv {Y} :=
{ toFun := fun f ↦ hc.lift (Cone.mk _
{ app := fun j ↦ F.partialRightAdjointHomEquiv (f ≫ c'.π.app j)
naturality := fun j j' φ ↦ by
dsimp
rw [id_comp, ← c'.w φ, ← partialRightAdjointHomEquiv_map_comp,
← assoc]
dsimp })
invFun := fun g ↦ hc'.lift (Cone.mk _
{ app := fun j ↦ F.partialRightAdjointHomEquiv.symm (g ≫ c.π.app j)
naturality := fun j j' φ ↦ by
apply F.partialRightAdjointHomEquiv.injective
have := c.w φ
dsimp at this ⊢
rw [id_comp, Equiv.apply_symm_apply, partialRightAdjointHomEquiv_map_comp,
Equiv.apply_symm_apply, assoc, this] })
left_inv := fun f ↦ hc'.hom_ext (fun j ↦ by simp)
right_inv := fun g ↦ hc.hom_ext (fun j ↦ by simp) }
homEquiv_comp {Y Y'} g f := hc.hom_ext (fun j ↦ by
dsimp
simp only [IsLimit.fac, partialRightAdjointHomEquiv_comp, assoc] )
lemma rightAdjointObjIsDefined_of_isLimit {J : Type*} [Category J] {R : J ⥤ D} {c : Cone R}
(hc : IsLimit c) [HasLimitsOfShape J C]
(h : ∀ (j : J), F.rightAdjointObjIsDefined (R.obj j)) :
F.rightAdjointObjIsDefined c.pt :=
(representableByCompYonedaObjOfIsLimit
(R := ObjectProperty.lift _ R h) hc (limit.isLimit _)).isRepresentable
lemma rightAdjointObjIsDefined_limit {J : Type*} [Category J] (R : J ⥤ D)
[HasLimit R] [HasLimitsOfShape J C]
(h : ∀ (j : J), F.rightAdjointObjIsDefined (R.obj j)) :
F.rightAdjointObjIsDefined (limit R) :=
rightAdjointObjIsDefined_of_isLimit (limit.isLimit R) h
end partialRightAdjoint
end Functor
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Adjunction/Unique.lean | import Mathlib.CategoryTheory.Adjunction.Mates
/-!
# Uniqueness of adjoints
This file shows that adjoints are unique up to natural isomorphism.
## Main results
* `Adjunction.leftAdjointUniq` : If `F` and `F'` are both left adjoint to `G`, then they are
naturally isomorphic.
* `Adjunction.rightAdjointUniq` : If `G` and `G'` are both right adjoint to `F`, then they are
naturally isomorphic.
-/
open CategoryTheory Functor
variable {C D : Type*} [Category C] [Category D]
namespace CategoryTheory.Adjunction
attribute [local simp] homEquiv_unit homEquiv_counit
/-- If `F` and `F'` are both left adjoint to `G`, then they are naturally isomorphic. -/
def leftAdjointUniq {F F' : C ⥤ D} {G : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F' ⊣ G) : F ≅ F' :=
((conjugateIsoEquiv adj1 adj2).symm (Iso.refl G)).symm
theorem homEquiv_leftAdjointUniq_hom_app {F F' : C ⥤ D} {G : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F' ⊣ G)
(x : C) : adj1.homEquiv _ _ ((leftAdjointUniq adj1 adj2).hom.app x) = adj2.unit.app x := by
simp [leftAdjointUniq]
@[reassoc (attr := simp)]
theorem unit_leftAdjointUniq_hom {F F' : C ⥤ D} {G : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F' ⊣ G) :
adj1.unit ≫ whiskerRight (leftAdjointUniq adj1 adj2).hom G = adj2.unit := by
ext x
rw [NatTrans.comp_app, ← homEquiv_leftAdjointUniq_hom_app adj1 adj2]
simp
@[reassoc (attr := simp)]
theorem unit_leftAdjointUniq_hom_app
{F F' : C ⥤ D} {G : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F' ⊣ G) (x : C) :
adj1.unit.app x ≫ G.map ((leftAdjointUniq adj1 adj2).hom.app x) = adj2.unit.app x := by
rw [← unit_leftAdjointUniq_hom adj1 adj2]; rfl
@[reassoc (attr := simp)]
theorem leftAdjointUniq_hom_counit {F F' : C ⥤ D} {G : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F' ⊣ G) :
whiskerLeft G (leftAdjointUniq adj1 adj2).hom ≫ adj2.counit = adj1.counit := by
ext x
simp only [Functor.comp_obj, Functor.id_obj, leftAdjointUniq, Iso.symm_hom,
conjugateIsoEquiv_symm_apply_inv, Iso.refl_inv, NatTrans.comp_app, whiskerLeft_app,
conjugateEquiv_symm_apply_app, NatTrans.id_app, Functor.map_id, Category.id_comp,
Category.assoc]
rw [← adj1.counit_naturality, ← Category.assoc, ← F.map_comp]
simp
@[reassoc (attr := simp)]
theorem leftAdjointUniq_hom_app_counit {F F' : C ⥤ D} {G : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F' ⊣ G)
(x : D) :
(leftAdjointUniq adj1 adj2).hom.app (G.obj x) ≫ adj2.counit.app x = adj1.counit.app x := by
rw [← leftAdjointUniq_hom_counit adj1 adj2]
rfl
theorem leftAdjointUniq_inv_app {F F' : C ⥤ D} {G : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F' ⊣ G) (x : C) :
(leftAdjointUniq adj1 adj2).inv.app x = (leftAdjointUniq adj2 adj1).hom.app x :=
rfl
@[reassoc (attr := simp)]
theorem leftAdjointUniq_trans {F F' F'' : C ⥤ D} {G : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F' ⊣ G)
(adj3 : F'' ⊣ G) :
(leftAdjointUniq adj1 adj2).hom ≫ (leftAdjointUniq adj2 adj3).hom =
(leftAdjointUniq adj1 adj3).hom := by
simp [leftAdjointUniq]
@[reassoc (attr := simp)]
theorem leftAdjointUniq_trans_app {F F' F'' : C ⥤ D} {G : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F' ⊣ G)
(adj3 : F'' ⊣ G) (x : C) :
(leftAdjointUniq adj1 adj2).hom.app x ≫ (leftAdjointUniq adj2 adj3).hom.app x =
(leftAdjointUniq adj1 adj3).hom.app x := by
rw [← leftAdjointUniq_trans adj1 adj2 adj3]
rfl
@[simp]
theorem leftAdjointUniq_refl {F : C ⥤ D} {G : D ⥤ C} (adj1 : F ⊣ G) :
(leftAdjointUniq adj1 adj1).hom = 𝟙 _ := by
simp [leftAdjointUniq]
/-- If `G` and `G'` are both right adjoint to `F`, then they are naturally isomorphic. -/
def rightAdjointUniq {F : C ⥤ D} {G G' : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F ⊣ G') : G ≅ G' :=
conjugateIsoEquiv adj1 adj2 (Iso.refl _)
theorem homEquiv_symm_rightAdjointUniq_hom_app {F : C ⥤ D} {G G' : D ⥤ C} (adj1 : F ⊣ G)
(adj2 : F ⊣ G') (x : D) :
(adj2.homEquiv _ _).symm ((rightAdjointUniq adj1 adj2).hom.app x) = adj1.counit.app x := by
simp [rightAdjointUniq]
@[reassoc (attr := simp)]
theorem unit_rightAdjointUniq_hom_app {F : C ⥤ D} {G G' : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F ⊣ G')
(x : C) : adj1.unit.app x ≫ (rightAdjointUniq adj1 adj2).hom.app (F.obj x) =
adj2.unit.app x := by
simp only [Functor.id_obj, Functor.comp_obj, rightAdjointUniq, conjugateIsoEquiv_apply_hom,
Iso.refl_hom, conjugateEquiv_apply_app, NatTrans.id_app, Functor.map_id, Category.id_comp]
rw [← adj2.unit_naturality_assoc, ← G'.map_comp]
simp
@[reassoc (attr := simp)]
theorem unit_rightAdjointUniq_hom {F : C ⥤ D} {G G' : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F ⊣ G') :
adj1.unit ≫ whiskerLeft F (rightAdjointUniq adj1 adj2).hom = adj2.unit := by
ext x
simp
@[reassoc (attr := simp)]
theorem rightAdjointUniq_hom_app_counit {F : C ⥤ D} {G G' : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F ⊣ G')
(x : D) :
F.map ((rightAdjointUniq adj1 adj2).hom.app x) ≫ adj2.counit.app x = adj1.counit.app x := by
simp [rightAdjointUniq]
@[reassoc (attr := simp)]
theorem rightAdjointUniq_hom_counit {F : C ⥤ D} {G G' : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F ⊣ G') :
whiskerRight (rightAdjointUniq adj1 adj2).hom F ≫ adj2.counit = adj1.counit := by
ext
simp
theorem rightAdjointUniq_inv_app {F : C ⥤ D} {G G' : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F ⊣ G')
(x : D) : (rightAdjointUniq adj1 adj2).inv.app x = (rightAdjointUniq adj2 adj1).hom.app x :=
rfl
@[reassoc (attr := simp)]
theorem rightAdjointUniq_trans {F : C ⥤ D} {G G' G'' : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F ⊣ G')
(adj3 : F ⊣ G'') :
(rightAdjointUniq adj1 adj2).hom ≫ (rightAdjointUniq adj2 adj3).hom =
(rightAdjointUniq adj1 adj3).hom := by
simp [rightAdjointUniq]
@[reassoc (attr := simp)]
theorem rightAdjointUniq_trans_app {F : C ⥤ D} {G G' G'' : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F ⊣ G')
(adj3 : F ⊣ G'') (x : D) :
(rightAdjointUniq adj1 adj2).hom.app x ≫ (rightAdjointUniq adj2 adj3).hom.app x =
(rightAdjointUniq adj1 adj3).hom.app x := by
rw [← rightAdjointUniq_trans adj1 adj2 adj3]
rfl
@[simp]
theorem rightAdjointUniq_refl {F : C ⥤ D} {G : D ⥤ C} (adj1 : F ⊣ G) :
(rightAdjointUniq adj1 adj1).hom = 𝟙 _ := by
delta rightAdjointUniq
simp
end Adjunction
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Adjunction/Quadruple.lean | import Mathlib.CategoryTheory.Adjunction.Triple
import Mathlib.CategoryTheory.Limits.FunctorCategory.EpiMono
/-!
# Adjoint quadruples
This file concerns adjoint quadruples `L ⊣ F ⊣ G ⊣ R` of functors `L G : C ⥤ D`, `F R : D ⥤ C`.
We bundle the adjunctions in a structure `Quadruple L F G R` and make the two triples `Triple L F G`
and `Triple F G R` accessible as `Quadruple.leftTriple` and `Quadruple.rightTriple`.
Currently the only two results are the following:
* When `F` and `R` are fully faithful, the components of the induced natural transformation `G ⟶ L`
are epimorphisms iff the components of the natural transformation `F ⟶ R` are monomorphisms.
* When `L` and `G` are fully faithful, the components of the induced natural transformation `L ⟶ G`
are epimorphisms iff the components of the natural transformation `R ⟶ F` are monomorphisms.
This is in particular relevant for the adjoint quadruples `π₀ ⊣ disc ⊣ Γ ⊣ codisc` that appear in
cohesive topoi, and can be found e.g. as proposition 2.7
[here](https://ncatlab.org/nlab/show/cohesive+topos).
Note that by `Triple.fullyFaithfulEquiv`, in an adjoint quadruple `L ⊣ F ⊣ G ⊣ R` `L` is fully
faithful iff `G` is and `F` is fully faithful iff `R` is; these lemmas thus cover all cases in which
some of the functors are fully faithful. We opt to include only those typeclass assumptions that are
needed for the theorem statements, so some lemmas require only e.g. `F` to be fully faithful when
really this means `F` and `R` both must be.
-/
open CategoryTheory Limits Functor Adjunction Triple
universe v₁ v₂ u₁ u₂
variable {C : Type u₁} {D : Type u₂} [Category.{v₁} C] [Category.{v₂} D]
variable (L : C ⥤ D) (F : D ⥤ C) (G : C ⥤ D) (R : D ⥤ C)
/-- Structure containing the three adjunctions of an adjoint quadruple `L ⊣ F ⊣ G ⊣ R`. -/
structure CategoryTheory.Adjunction.Quadruple where
/-- Adjunction `L ⊣ F` of the adjoint quadruple `L ⊣ F ⊣ G ⊣ R`. -/
adj₁ : L ⊣ F
/-- Adjunction `F ⊣ G` of the adjoint quadruple `L ⊣ F ⊣ G ⊣ R`. -/
adj₂ : F ⊣ G
/-- Adjunction `G ⊣ R` of the adjoint quadruple `L ⊣ F ⊣ G ⊣ R`. -/
adj₃ : G ⊣ R
namespace CategoryTheory.Adjunction.Quadruple
variable {L F G R} (q : Quadruple L F G R)
/-- The left part of an adjoint quadruple `L ⊣ F ⊣ G ⊣ R`. -/
@[simps]
def leftTriple : Triple L F G where
adj₁ := q.adj₁
adj₂ := q.adj₂
/-- The right part of an adjoint quadruple `L ⊣ F ⊣ G ⊣ R`. -/
@[simps]
def rightTriple : Triple F G R where
adj₁ := q.adj₂
adj₂ := q.adj₃
/-- The adjoint quadruple `R.op ⊣ G.op ⊣ F.op ⊣ L.op` dual to an
adjoint quadruple `L ⊣ F ⊣ G ⊣ R`. -/
@[simps]
protected def op : Quadruple R.op G.op F.op L.op where
adj₁ := q.adj₃.op
adj₂ := q.adj₂.op
adj₃ := q.adj₁.op
@[simp]
lemma op_leftTriple : q.op.leftTriple = q.rightTriple.op := rfl
@[simp]
lemma op_rightTriple : q.op.rightTriple = q.leftTriple.op := rfl
section RightFullyFaithful
variable [F.Full] [F.Faithful]
/-- For an adjoint quadruple `L ⊣ F ⊣ G ⊣ R` where `F` (and hence also `R`) is fully faithful, all
components of the natural transformation `G ⟶ L` are epimorphisms iff all components of the natural
transformation `F ⟶ R` are monomorphisms. -/
lemma epi_leftTriple_rightToLeft_app_iff_mono_rightTriple_leftToRight_app :
(∀ X, Epi (q.leftTriple.rightToLeft.app X)) ↔ ∀ X, Mono (q.rightTriple.leftToRight.app X) := by
simp_rw [mono_leftToRight_app_iff_mono_adj₂_unit_app, rightToLeft_eq_counits]
dsimp
simp only [NatIso.isIso_inv_app, Functor.comp_obj, Functor.id_obj,
whiskerLeft_app, Category.comp_id, Category.id_comp]
simp_rw [epi_comp_iff_of_epi, epi_iff_forall_injective, mono_iff_forall_injective]
rw [forall_comm]
refine forall_congr' fun X ↦ forall_congr' fun Y ↦ ?_
rw [← (q.adj₁.homEquiv _ _).comp_injective _]
simp_rw [Function.comp_def, q.adj₁.homEquiv_naturality_left]
refine ((q.adj₁.homEquiv _ _).injective_comp fun f ↦ _).trans ?_
rw [← ((q.adj₂.homEquiv _ _).trans (q.adj₃.homEquiv _ _)).comp_injective _]
simp [Function.comp_def, ← q.adj₂.homEquiv_symm_id, ← q.adj₂.homEquiv_naturality_right_symm,
← q.adj₃.homEquiv_id, ← q.adj₃.homEquiv_naturality_left]
/-- For an adjoint quadruple `L ⊣ F ⊣ G ⊣ R` where `F` (and hence also `R`) is fully faithful and
its domain / codomain has all pushouts resp. pullbacks, the natural transformation `G ⟶ L` is an
epimorphism iff the natural transformation `F ⟶ R` is a monomorphism. -/
lemma epi_leftTriple_rightToLeft_iff_mono_rightTriple_leftToRight [HasPullbacks C] [HasPushouts D] :
Epi q.leftTriple.rightToLeft ↔ Mono q.rightTriple.leftToRight := by
rw [NatTrans.epi_iff_epi_app, NatTrans.mono_iff_mono_app]
exact q.epi_leftTriple_rightToLeft_app_iff_mono_rightTriple_leftToRight_app
end RightFullyFaithful
section LeftFullyFaithful
variable [L.Full] [L.Faithful] [G.Full] [G.Faithful]
/-- For an adjoint quadruple `L ⊣ F ⊣ G ⊣ R` where `L` and `G` are fully faithful, all components
of the natural transformation `L ⟶ G` are epimorphisms iff all components of the natural
transformation `R ⟶ F` are monomorphisms. -/
lemma epi_leftTriple_leftToRight_app_iff_mono_rightTriple_rightToLeft_app :
(∀ X, Epi (q.leftTriple.leftToRight.app X)) ↔ ∀ X, Mono (q.rightTriple.rightToLeft.app X) := by
have h := q.op.epi_leftTriple_rightToLeft_app_iff_mono_rightTriple_leftToRight_app
rw [← (Opposite.equivToOpposite (α := C)).forall_congr_right] at h
rw [← (Opposite.equivToOpposite (α := D)).forall_congr_right] at h
simpa using h.symm
/-- For an adjoint quadruple `L ⊣ F ⊣ G ⊣ R` where `L` and `G` are fully faithful and their domain
and codomain have all pullbacks resp. pushouts, the natural transformation `L ⟶ G` is an
epimorphism iff the natural transformation `R ⟶ F` is a monomorphism. -/
lemma epi_leftTriple_leftToRight_iff_mono_rightTriple_rightToLeft [HasPullbacks C] [HasPushouts D] :
Epi q.leftTriple.leftToRight ↔ Mono q.rightTriple.rightToLeft := by
rw [NatTrans.epi_iff_epi_app, NatTrans.mono_iff_mono_app]
exact q.epi_leftTriple_leftToRight_app_iff_mono_rightTriple_rightToLeft_app
end LeftFullyFaithful
end CategoryTheory.Adjunction.Quadruple |
.lake/packages/mathlib/Mathlib/CategoryTheory/Adjunction/Opposites.lean | import Mathlib.CategoryTheory.Adjunction.Basic
import Mathlib.CategoryTheory.Yoneda
import Mathlib.CategoryTheory.Opposites
/-!
# Opposite adjunctions
This file contains constructions to relate adjunctions of functors to adjunctions of their
opposites.
## Tags
adjunction, opposite, uniqueness
-/
open CategoryTheory
universe v₁ v₂ u₁ u₂
-- morphism levels before object levels. See note [category theory universes].
variable {C : Type u₁} [Category.{v₁} C] {D : Type u₂} [Category.{v₂} D]
namespace CategoryTheory.Adjunction
attribute [local simp] homEquiv_unit homEquiv_counit
/-- If `G` is adjoint to `F` then `F.unop` is adjoint to `G.unop`. -/
@[simps]
def unop {F : Cᵒᵖ ⥤ Dᵒᵖ} {G : Dᵒᵖ ⥤ Cᵒᵖ} (h : G ⊣ F) : F.unop ⊣ G.unop where
unit := NatTrans.unop h.counit
counit := NatTrans.unop h.unit
left_triangle_components _ := Quiver.Hom.op_inj (h.right_triangle_components _)
right_triangle_components _ := Quiver.Hom.op_inj (h.left_triangle_components _)
/-- If `G` is adjoint to `F` then `F.op` is adjoint to `G.op`. -/
@[simps]
def op {F : C ⥤ D} {G : D ⥤ C} (h : G ⊣ F) : F.op ⊣ G.op where
unit := NatTrans.op h.counit
counit := NatTrans.op h.unit
left_triangle_components _ := Quiver.Hom.unop_inj (by simp)
right_triangle_components _ := Quiver.Hom.unop_inj (by simp)
/-- If `F` is adjoint to `G.leftOp` then `G` is adjoint to `F.leftOp`. -/
@[simps]
def leftOp {F : C ⥤ Dᵒᵖ} {G : D ⥤ Cᵒᵖ} (a : F ⊣ G.leftOp) : G ⊣ F.leftOp where
unit := NatTrans.unop a.counit
counit := NatTrans.op a.unit
left_triangle_components X := congr($(a.right_triangle_components (.op X)).op)
right_triangle_components X := congr($(a.left_triangle_components X.unop).unop)
/-- If `F.rightOp` is adjoint to `G` then `G.rightOp` is adjoint to `F`. -/
@[simps]
def rightOp {F : Cᵒᵖ ⥤ D} {G : Dᵒᵖ ⥤ C} (a : F.rightOp ⊣ G) : G.rightOp ⊣ F where
unit := NatTrans.unop a.counit
counit := NatTrans.op a.unit
left_triangle_components X := congr($(a.right_triangle_components (.op X)).op)
right_triangle_components X := congr($(a.left_triangle_components X.unop).unop)
lemma leftOp_eq {F : C ⥤ Dᵒᵖ} {G : D ⥤ Cᵒᵖ} (a : F ⊣ G.leftOp) :
a.leftOp = (opOpEquivalence D).symm.toAdjunction.comp a.op := by
ext X; simp [Equivalence.unit]
lemma rightOp_eq {F : Cᵒᵖ ⥤ D} {G : Dᵒᵖ ⥤ C} (a : F.rightOp ⊣ G) :
a.rightOp = (opOpEquivalence D).symm.toAdjunction.comp a.op := by
ext X; simp [Equivalence.unit]
/-- If `F` and `F'` are both adjoint to `G`, there is a natural isomorphism
`F.op ⋙ coyoneda ≅ F'.op ⋙ coyoneda`.
We use this in combination with `fullyFaithfulCancelRight` to show left adjoints are unique.
-/
def leftAdjointsCoyonedaEquiv {F F' : C ⥤ D} {G : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F' ⊣ G) :
F.op ⋙ coyoneda ≅ F'.op ⋙ coyoneda :=
NatIso.ofComponents fun X =>
NatIso.ofComponents fun Y =>
((adj1.homEquiv X.unop Y).trans (adj2.homEquiv X.unop Y).symm).toIso
/-- Given two adjunctions, if the right adjoints are naturally isomorphic, then so are the left
adjoints.
Note: it is generally better to use `Adjunction.natIsoEquiv`, see the file `Adjunction.Unique`.
The reason this definition still exists is that apparently `CategoryTheory.extendAlongYonedaYoneda`
uses its definitional properties (TODO: figure out a way to avoid this).
-/
def natIsoOfRightAdjointNatIso {F F' : C ⥤ D} {G G' : D ⥤ C}
(adj1 : F ⊣ G) (adj2 : F' ⊣ G') (r : G ≅ G') : F ≅ F' :=
NatIso.removeOp ((Coyoneda.fullyFaithful.whiskeringRight _).isoEquiv.symm
(leftAdjointsCoyonedaEquiv adj2 (adj1.ofNatIsoRight r)))
/-- Given two adjunctions, if the left adjoints are naturally isomorphic, then so are the right
adjoints.
Note: it is generally better to use `Adjunction.natIsoEquiv`, see the file `Adjunction.Unique`.
-/
def natIsoOfLeftAdjointNatIso {F F' : C ⥤ D} {G G' : D ⥤ C}
(adj1 : F ⊣ G) (adj2 : F' ⊣ G') (l : F ≅ F') : G ≅ G' :=
NatIso.removeOp (natIsoOfRightAdjointNatIso (op adj2) (op adj1) (NatIso.op l))
end Adjunction
namespace Functor
instance IsLeftAdjoint.op {F : C ⥤ D} [F.IsLeftAdjoint] : F.op.IsRightAdjoint :=
⟨F.rightAdjoint.op, ⟨.op <| .ofIsLeftAdjoint _⟩⟩
instance IsRightAdjoint.op {F : C ⥤ D} [F.IsRightAdjoint] : F.op.IsLeftAdjoint :=
⟨F.leftAdjoint.op, ⟨.op <| .ofIsRightAdjoint _⟩⟩
instance IsLeftAdjoint.leftOp {F : C ⥤ Dᵒᵖ} [F.IsLeftAdjoint] : F.leftOp.IsRightAdjoint :=
⟨F.rightAdjoint.rightOp, ⟨.leftOp <| .ofIsLeftAdjoint _⟩⟩
-- TODO: Do we need to introduce `Adjunction.leftUnop`?
instance IsRightAdjoint.leftOp {F : C ⥤ Dᵒᵖ} [F.IsRightAdjoint] : F.leftOp.IsLeftAdjoint :=
inferInstanceAs (F.op ⋙ (opOpEquivalence D).functor).IsLeftAdjoint
-- TODO: Do we need to introduce `Adjunction.rightUnop`?
instance IsLeftAdjoint.rightOp {F : Cᵒᵖ ⥤ D} [F.IsLeftAdjoint] : F.rightOp.IsRightAdjoint :=
inferInstanceAs ((opOpEquivalence C).inverse ⋙ F.op).IsRightAdjoint
instance IsRightAdjoint.rightOp {F : Cᵒᵖ ⥤ D} [F.IsRightAdjoint] : F.rightOp.IsLeftAdjoint :=
⟨F.leftAdjoint.leftOp, ⟨.rightOp <| .ofIsRightAdjoint _⟩⟩
end Functor
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Adjunction/FullyFaithful.lean | import Mathlib.CategoryTheory.Adjunction.Basic
import Mathlib.CategoryTheory.MorphismProperty.Basic
import Mathlib.CategoryTheory.EpiMono
/-!
# Adjoints of fully faithful functors
A left adjoint is
* faithful, if and only if the unit is a monomorphism
* full, if and only if the unit is a split epimorphism
* fully faithful, if and only if the unit is an isomorphism
A right adjoint is
* faithful, if and only if the counit is an epimorphism
* full, if and only if the counit is a split monomorphism
* fully faithful, if and only if the counit is an isomorphism
This is Lemma 4.5.13 in Riehl's *Category Theory in Context* [riehl2017].
See also https://stacks.math.columbia.edu/tag/07RB for the statements about fully faithful functors.
In the file `Mathlib/CategoryTheory/Monad/Adjunction.lean`, we prove that in fact, if there exists
an isomorphism `L ⋙ R ≅ 𝟭 C`, then the unit is an isomorphism, and similarly for the counit.
See `CategoryTheory.Adjunction.isIso_unit_of_iso` and
`CategoryTheory.Adjunction.isIso_counit_of_iso`.
-/
open CategoryTheory
namespace CategoryTheory.Adjunction
universe v₁ v₂ u₁ u₂
open Category Functor
open Opposite
attribute [local simp] Adjunction.homEquiv_unit Adjunction.homEquiv_counit
variable {C : Type u₁} [Category.{v₁} C]
variable {D : Type u₂} [Category.{v₂} D]
variable {L : C ⥤ D} {R : D ⥤ C} (h : L ⊣ R)
attribute [local simp] homEquiv_unit homEquiv_counit
/-- If the left adjoint is faithful, then each component of the unit is an monomorphism. -/
instance unit_mono_of_L_faithful [L.Faithful] (X : C) : Mono (h.unit.app X) where
right_cancellation {Y} f g hfg :=
L.map_injective <| (h.homEquiv Y (L.obj X)).injective <| by simpa using hfg
/-- If the left adjoint is full, then each component of the unit is a split epimorphism. -/
noncomputable def unitSplitEpiOfLFull [L.Full] (X : C) : SplitEpi (h.unit.app X) where
section_ := L.preimage (h.counit.app (L.obj X))
id := by simp [← h.unit_naturality (L.preimage (h.counit.app (L.obj X)))]
/-- If the right adjoint is full, then each component of the counit is a split monomorphism. -/
instance unit_isSplitEpi_of_L_full [L.Full] (X : C) : IsSplitEpi (h.unit.app X) :=
⟨⟨h.unitSplitEpiOfLFull X⟩⟩
instance [L.Full] [L.Faithful] (X : C) : IsIso (h.unit.app X) :=
isIso_of_mono_of_isSplitEpi _
/-- If the left adjoint is fully faithful, then the unit is an isomorphism. -/
instance unit_isIso_of_L_fully_faithful [L.Full] [L.Faithful] : IsIso (Adjunction.unit h) :=
NatIso.isIso_of_isIso_app _
/-- If the right adjoint is faithful, then each component of the counit is an epimorphism. -/
instance counit_epi_of_R_faithful [R.Faithful] (X : D) : Epi (h.counit.app X) where
left_cancellation {Y} f g hfg :=
R.map_injective <| (h.homEquiv (R.obj X) Y).symm.injective <| by simpa using hfg
/-- If the right adjoint is full, then each component of the counit is a split monomorphism. -/
noncomputable def counitSplitMonoOfRFull [R.Full] (X : D) : SplitMono (h.counit.app X) where
retraction := R.preimage (h.unit.app (R.obj X))
id := by simp [← h.counit_naturality (R.preimage (h.unit.app (R.obj X)))]
/-- If the right adjoint is full, then each component of the counit is a split monomorphism. -/
instance counit_isSplitMono_of_R_full [R.Full] (X : D) : IsSplitMono (h.counit.app X) :=
⟨⟨h.counitSplitMonoOfRFull X⟩⟩
instance [R.Full] [R.Faithful] (X : D) : IsIso (h.counit.app X) :=
isIso_of_epi_of_isSplitMono _
/-- If the right adjoint is fully faithful, then the counit is an isomorphism. -/
instance counit_isIso_of_R_fully_faithful [R.Full] [R.Faithful] : IsIso (Adjunction.counit h) :=
NatIso.isIso_of_isIso_app _
/-- If the unit of an adjunction is an isomorphism, then its inverse on the image of L is given
by L whiskered with the counit. -/
@[simp]
theorem inv_map_unit {X : C} [IsIso (h.unit.app X)] :
inv (L.map (h.unit.app X)) = h.counit.app (L.obj X) :=
IsIso.inv_eq_of_hom_inv_id (h.left_triangle_components X)
/-- If the unit is an isomorphism, bundle one has an isomorphism `L ⋙ R ⋙ L ≅ L`. -/
@[simps!]
noncomputable def whiskerLeftLCounitIsoOfIsIsoUnit [IsIso h.unit] : L ⋙ R ⋙ L ≅ L :=
(L.associator R L).symm ≪≫ isoWhiskerRight (asIso h.unit).symm L ≪≫ Functor.leftUnitor _
/-- If the counit of an adjunction is an isomorphism, then its inverse on the image of R is given
by R whiskered with the unit. -/
@[simp]
theorem inv_counit_map {X : D} [IsIso (h.counit.app X)] :
inv (R.map (h.counit.app X)) = h.unit.app (R.obj X) :=
IsIso.inv_eq_of_inv_hom_id (h.right_triangle_components X)
/-- If the counit of an is an isomorphism, one has an isomorphism `(R ⋙ L ⋙ R) ≅ R`. -/
@[simps!]
noncomputable def whiskerLeftRUnitIsoOfIsIsoCounit [IsIso h.counit] : R ⋙ L ⋙ R ≅ R :=
(R.associator L R).symm ≪≫ isoWhiskerRight (asIso h.counit) R ≪≫ Functor.leftUnitor _
/-- If each component of the unit is a monomorphism, then the left adjoint is faithful. -/
lemma faithful_L_of_mono_unit_app [∀ X, Mono (h.unit.app X)] : L.Faithful where
map_injective {X Y f g} hfg := by
apply Mono.right_cancellation (f := h.unit.app Y)
apply (h.homEquiv X (L.obj Y)).symm.injective
simpa using hfg
/-- If each component of the unit is a split epimorphism, then the left adjoint is full. -/
lemma full_L_of_isSplitEpi_unit_app [∀ X, IsSplitEpi (h.unit.app X)] : L.Full where
map_surjective {X Y} f := by
use ((h.homEquiv X (L.obj Y)) f ≫ section_ (h.unit.app Y))
suffices L.map (section_ (h.unit.app Y)) = h.counit.app (L.obj Y) by simp [this]
rw [← comp_id (L.map (section_ (h.unit.app Y)))]
simp only [Functor.comp_obj, Functor.id_obj, ← h.left_triangle_components Y,
← assoc, ← Functor.map_comp, IsSplitEpi.id, Functor.map_id, id_comp]
/-- If the unit is an isomorphism, then the left adjoint is fully faithful. -/
noncomputable def fullyFaithfulLOfIsIsoUnit [IsIso h.unit] : L.FullyFaithful where
preimage {_ Y} f := h.homEquiv _ (L.obj Y) f ≫ inv (h.unit.app Y)
/-- If each component of the counit is an epimorphism, then the right adjoint is faithful. -/
lemma faithful_R_of_epi_counit_app [∀ X, Epi (h.counit.app X)] : R.Faithful where
map_injective {X Y f g} hfg := by
apply Epi.left_cancellation (f := h.counit.app X)
apply (h.homEquiv (R.obj X) Y).injective
simpa using hfg
/-- If each component of the counit is a split monomorphism, then the right adjoint is full. -/
lemma full_R_of_isSplitMono_counit_app [∀ X, IsSplitMono (h.counit.app X)] : R.Full where
map_surjective {X Y} f := by
use (retraction (h.counit.app X) ≫ (h.homEquiv (R.obj X) Y).symm f)
suffices R.map (retraction (h.counit.app X)) = h.unit.app (R.obj X) by simp [this]
rw [← id_comp (R.map (retraction (h.counit.app X)))]
simp only [Functor.id_obj, Functor.comp_obj, ← h.right_triangle_components X,
assoc, ← Functor.map_comp, IsSplitMono.id, Functor.map_id, comp_id]
/-- If the counit is an isomorphism, then the right adjoint is fully faithful. -/
noncomputable def fullyFaithfulROfIsIsoCounit [IsIso h.counit] : R.FullyFaithful where
preimage {X Y} f := inv (h.counit.app X) ≫ (h.homEquiv (R.obj X) Y).symm f
instance whiskerLeft_counit_iso_of_L_fully_faithful [L.Full] [L.Faithful] :
IsIso (whiskerLeft L h.counit) := by
have := h.left_triangle
rw [← IsIso.eq_inv_comp] at this
rw [this]
infer_instance
instance whiskerRight_counit_iso_of_L_fully_faithful [L.Full] [L.Faithful] :
IsIso (whiskerRight h.counit R) := by
have := h.right_triangle
rw [← IsIso.eq_inv_comp] at this
rw [this]
infer_instance
instance whiskerLeft_unit_iso_of_R_fully_faithful [R.Full] [R.Faithful] :
IsIso (whiskerLeft R h.unit) := by
have := h.right_triangle
rw [← IsIso.eq_comp_inv] at this
rw [this]
infer_instance
instance whiskerRight_unit_iso_of_R_fully_faithful [R.Full] [R.Faithful] :
IsIso (whiskerRight h.unit L) := by
have := h.left_triangle
rw [← IsIso.eq_comp_inv] at this
rw [this]
infer_instance
instance [L.Faithful] [L.Full] {Y : C} : IsIso (h.counit.app (L.obj Y)) :=
isIso_of_hom_comp_eq_id _ (h.left_triangle_components Y)
instance [L.Faithful] [L.Full] {Y : D} : IsIso (R.map (h.counit.app Y)) :=
isIso_of_hom_comp_eq_id _ (h.right_triangle_components Y)
lemma isIso_counit_app_iff_mem_essImage [L.Faithful] [L.Full] {X : D} :
IsIso (h.counit.app X) ↔ L.essImage X := by
constructor
· intro
exact ⟨R.obj X, ⟨asIso (h.counit.app X)⟩⟩
· rintro ⟨_, ⟨i⟩⟩
rw [NatTrans.isIso_app_iff_of_iso _ i.symm]
infer_instance
lemma mem_essImage_of_counit_isIso (A : D)
[IsIso (h.counit.app A)] : L.essImage A :=
⟨R.obj A, ⟨asIso (h.counit.app A)⟩⟩
lemma isIso_counit_app_of_iso [L.Faithful] [L.Full] {X : D} {Y : C} (e : X ≅ L.obj Y) :
IsIso (h.counit.app X) :=
(isIso_counit_app_iff_mem_essImage h).mpr ⟨Y, ⟨e.symm⟩⟩
instance [R.Faithful] [R.Full] {Y : D} : IsIso (h.unit.app (R.obj Y)) :=
isIso_of_comp_hom_eq_id _ (h.right_triangle_components Y)
instance [R.Faithful] [R.Full] {X : C} : IsIso (L.map (h.unit.app X)) :=
isIso_of_comp_hom_eq_id _ (h.left_triangle_components X)
lemma isIso_unit_app_iff_mem_essImage [R.Faithful] [R.Full] {Y : C} :
IsIso (h.unit.app Y) ↔ R.essImage Y := by
constructor
· intro
exact ⟨L.obj Y, ⟨(asIso (h.unit.app Y)).symm⟩⟩
· rintro ⟨_, ⟨i⟩⟩
rw [NatTrans.isIso_app_iff_of_iso _ i.symm]
infer_instance
/-- If `η_A` is an isomorphism, then `A` is in the essential image of `i`. -/
theorem mem_essImage_of_unit_isIso (A : C)
[IsIso (h.unit.app A)] : R.essImage A :=
⟨L.obj A, ⟨(asIso (h.unit.app A)).symm⟩⟩
lemma isIso_unit_app_of_iso [R.Faithful] [R.Full] {X : D} {Y : C} (e : Y ≅ R.obj X) :
IsIso (h.unit.app Y) :=
(isIso_unit_app_iff_mem_essImage h).mpr ⟨X, ⟨e.symm⟩⟩
instance [R.IsEquivalence] : IsIso h.unit := by
have := fun Y => isIso_unit_app_of_iso h (R.objObjPreimageIso Y).symm
apply NatIso.isIso_of_isIso_app
instance [L.IsEquivalence] : IsIso h.counit := by
have := fun X => isIso_counit_app_of_iso h (L.objObjPreimageIso X).symm
apply NatIso.isIso_of_isIso_app
lemma isEquivalence_left_of_isEquivalence_right (h : L ⊣ R) [R.IsEquivalence] : L.IsEquivalence :=
h.toEquivalence.isEquivalence_functor
lemma isEquivalence_right_of_isEquivalence_left (h : L ⊣ R) [L.IsEquivalence] : R.IsEquivalence :=
h.toEquivalence.isEquivalence_inverse
instance [L.IsEquivalence] : IsIso h.unit := by
have := h.isEquivalence_right_of_isEquivalence_left
infer_instance
instance [R.IsEquivalence] : IsIso h.counit := by
have := h.isEquivalence_left_of_isEquivalence_right
infer_instance
end CategoryTheory.Adjunction |
.lake/packages/mathlib/Mathlib/CategoryTheory/Adjunction/Triple.lean | import Mathlib.CategoryTheory.Adjunction.Opposites
import Mathlib.CategoryTheory.Adjunction.Unique
import Mathlib.CategoryTheory.Monad.Adjunction
/-!
# Adjoint triples
This file concerns adjoint triples `F ⊣ G ⊣ H` of functors `F H : C ⥤ D`, `G : D ⥤ C`. We first
prove that `F` is fully faithful iff `H` is, and then prove results about the two special cases
where `G` is fully faithful or `F` and `H` are.
## Main results
All results are about an adjoint triple `F ⊣ G ⊣ H` where `adj₁ : F ⊣ G` and `adj₂ : G ⊣ H`. We
bundle the adjunctions in a structure `Triple F G H`.
* `fullyFaithfulEquiv`: `F` is fully faithful iff `H` is.
* `rightToLeft`: the canonical natural transformation `H ⟶ F` that exists whenever `G` is fully
faithful. This is defined as the preimage of `adj₂.counit ≫ adj₁.unit` under whiskering with `G`,
but formulas in terms of the units resp. counits of the adjunctions are also given.
* `whiskerRight_rightToLeft`: whiskering `rightToLeft : H ⟶ F` with `G` yields
`adj₂.counit ≫ adj₁.unit : H ⋙ G ⟶ F ⋙ G`.
* `epi_rightToLeft_app_iff_epi_map_adj₁_unit_app`: `rightToLeft : H ⟶ F` is epic at `X` iff the
image of `adj₁.unit.app X` under `H` is.
* `epi_rightToLeft_app_iff_epi_map_adj₂_counit_app`: `rightToLeft : H ⟶ F` is epic at `X` iff the
image of `adj₂.counit.app X` under `F` is.
* `epi_rightToLeft_app_iff`: when `H` preserves epimorphisms, `rightToLeft : H ⟶ F` is epic at `X`
iff `adj₂.counit ≫ adj₁.unit : H ⋙ G ⟶ F ⋙ G` is.
* `leftToRight`: the canonical natural transformation `F ⟶ H` that exists whenever `F` and `H` are
fully faithful. This is defined in terms of the units of the adjunctions, but a formula in terms
of the counits is also given.
* `whiskerLeft_leftToRight`: whiskering `G` with `leftToRight : F ⟶ H` yields
`adj₁.counit ≫ adj₂.unit : G ⋙ F ⟶ G ⋙ H`.
* `mono_leftToRight_app_iff_mono_adj₂_unit_app`: `leftToRight : F ⟶ H` is monic at `X` iff
`adj₂.unit` is monic at `F.obj X`.
* `mono_leftToRight_app_iff_mono_adj₁_counit_app`: `leftToRight : F ⟶ H` is monic at `X` iff
`adj₁.unit` is monic at `H.obj X`.
* `mono_leftToRight_app_iff`: `leftToRight : H ⟶ F` is componentwise monic iff
`adj₁.counit ≫ adj₂.unit : G ⋙ F ⟶ G ⋙ H` is.
-/
open CategoryTheory Functor
variable {C D : Type*} [Category C] [Category D]
variable (F : C ⥤ D) (G : D ⥤ C) (H : C ⥤ D)
/-- Structure containing the two adjunctions of an adjoint triple `F ⊣ G ⊣ H`. -/
structure CategoryTheory.Adjunction.Triple where
/-- Adjunction `F ⊣ G` of the adjoint triple `F ⊣ G ⊣ H`. -/
adj₁ : F ⊣ G
/-- Adjunction `G ⊣ H` of the adjoint triple `F ⊣ G ⊣ H`. -/
adj₂ : G ⊣ H
namespace CategoryTheory.Adjunction.Triple
variable {F G H} (t : Triple F G H)
lemma isIso_unit_iff_isIso_counit : IsIso t.adj₁.unit ↔ IsIso t.adj₂.counit := by
let adj : F ⋙ G ⊣ H ⋙ G := t.adj₁.comp t.adj₂
constructor
· intro h
let idAdj : 𝟭 C ⊣ H ⋙ G := adj.ofNatIsoLeft (asIso t.adj₁.unit).symm
exact t.adj₂.isIso_counit_of_iso (idAdj.rightAdjointUniq id)
· intro h
let adjId : F ⋙ G ⊣ 𝟭 C := adj.ofNatIsoRight (asIso t.adj₂.counit)
exact t.adj₁.isIso_unit_of_iso (adjId.leftAdjointUniq id)
/--
Given an adjoint triple `F ⊣ G ⊣ H`, the left adjoint `F` is fully faithful if and only if the
right adjoint `H` is fully faithful.
-/
noncomputable def fullyFaithfulEquiv : F.FullyFaithful ≃ H.FullyFaithful where
toFun h :=
haveI := h.full
haveI := h.faithful
haveI : IsIso t.adj₂.counit := by
rw [← t.isIso_unit_iff_isIso_counit]
infer_instance
t.adj₂.fullyFaithfulROfIsIsoCounit
invFun h :=
haveI := h.full
haveI := h.faithful
haveI : IsIso t.adj₁.unit := by
rw [t.isIso_unit_iff_isIso_counit]
infer_instance
t.adj₁.fullyFaithfulLOfIsIsoUnit
left_inv _ := Subsingleton.elim _ _
right_inv _ := Subsingleton.elim _ _
/-- The adjoint triple `H.op ⊣ G.op ⊣ F.op` dual to an adjoint triple `F ⊣ G ⊣ H`. -/
@[simps]
protected def op : Triple H.op G.op F.op where
adj₁ := t.adj₂.op
adj₂ := t.adj₁.op
section InnerFullyFaithful
variable [G.Full] [G.Faithful]
/-- The natural transformation `H ⟶ F` that exists for every adjoint triple `F ⊣ G ⊣ H` where `G`
is fully faithful, given here as the preimage of `adj₂.counit ≫ adj₁.unit : H ⋙ G ⟶ F ⋙ G`
under whiskering with `G`. -/
noncomputable def rightToLeft : H ⟶ F :=
((FullyFaithful.ofFullyFaithful G).whiskeringRight _).preimage (t.adj₂.counit ≫ t.adj₁.unit)
/-- For an adjoint triple `F ⊣ G ⊣ H` where `G` is fully faithful, whiskering the natural
transformation `H ⟶ F` with `G` yields the composition of the counit of the second adjunction with
the unit of the first adjunction. -/
@[simp, reassoc]
lemma whiskerRight_rightToLeft : whiskerRight t.rightToLeft G = t.adj₂.counit ≫ t.adj₁.unit :=
((FullyFaithful.ofFullyFaithful G).whiskeringRight _).map_preimage _
/-- For an adjoint triple `F ⊣ G ⊣ H` where `G` is fully faithful, the images of the components of
the natural transformation `H ⟶ F` under `G` are the components of the composition of counit of the
second adjunction with the unit of the first adjunction. -/
@[simp, reassoc]
lemma map_rightToLeft_app (X : C) :
G.map (t.rightToLeft.app X) = t.adj₂.counit.app X ≫ t.adj₁.unit.app X :=
congr_app t.whiskerRight_rightToLeft X
/-- The natural transformation `H ⟶ F` for an adjoint triple `F ⊣ G ⊣ H` with `G` fully faithful
is also equal to the whiskered unit `H ⟶ F ⋙ G ⋙ H` of the first adjunction followed by the
inverse of the whiskered unit `F ⟶ F ⋙ G ⋙ H` of the second. -/
lemma rightToLeft_eq_units :
t.rightToLeft = H.leftUnitor.inv ≫ whiskerRight t.adj₁.unit H ≫ (Functor.associator _ _ _).hom ≫
inv (whiskerLeft F t.adj₂.unit) ≫ F.rightUnitor.hom := by
ext X; apply G.map_injective; simp [rightToLeft]
/-- The natural transformation `H ⟶ F` for an adjoint triple `F ⊣ G ⊣ H` with `G` fully faithful
is also equal to the inverse of the whiskered counit `H ⋙ G ⋙ F ⟶ H` of the first adjunction
followed by the whiskered counit `H ⋙ G ⋙ F ⟶ F` of the second. -/
lemma rightToLeft_eq_counits :
t.rightToLeft = H.rightUnitor.inv ≫ inv (whiskerLeft H t.adj₁.counit) ≫
(Functor.associator _ _ _).inv ≫ whiskerRight t.adj₂.counit F ≫ F.leftUnitor.hom := by
ext X; apply G.map_injective; simp [rightToLeft]
@[reassoc (attr := simp)]
lemma adj₁_counit_app_rightToLeft_app (X : C) :
t.adj₁.counit.app (H.obj X) ≫ t.rightToLeft.app X = F.map (t.adj₂.counit.app X) :=
G.map_injective (by simp [← cancel_epi (t.adj₁.unit.app _)])
@[reassoc (attr := simp)]
lemma rightToLeft_app_adj₂_unit_app (X : C) :
t.rightToLeft.app X ≫ t.adj₂.unit.app (F.obj X) = H.map (t.adj₁.unit.app X) :=
G.map_injective (by simp [← cancel_mono (t.adj₂.counit.app _)])
/-- For an adjoint triple `F ⊣ G ⊣ H` where `G` is fully faithful, the natural transformation
`F.op ⟶ H.op` obtained from the dual adjoint triple `H.op ⊣ G.op ⊣ F.op` is dual to the natural
transformation `H ⟶ F`. -/
@[simp]
lemma op_rightToLeft : t.op.rightToLeft = NatTrans.op t.rightToLeft := by
ext
rw [rightToLeft_eq_units, rightToLeft_eq_counits]
simp
/-- For an adjoint triple `F ⊣ G ⊣ H` where `G` is fully faithful, the natural transformation
`H ⟶ F` is epic at `X` iff the image of the unit of the adjunction `F ⊣ G` under `H` is. -/
lemma epi_rightToLeft_app_iff_epi_map_adj₁_unit_app {X : C} :
Epi (t.rightToLeft.app X) ↔ Epi (H.map (t.adj₁.unit.app X)) := by
rw [← epi_comp_iff_of_isIso _ (t.adj₂.unit.app (F.obj X)), rightToLeft_app_adj₂_unit_app]
/-- For an adjoint triple `F ⊣ G ⊣ H` where `G` is fully faithful, the natural transformation
`H ⟶ F` is epic at `X` iff the image of the counit of the adjunction `G ⊣ H` under `F` is. -/
lemma epi_rightToLeft_app_iff_epi_map_adj₂_counit_app {X : C} :
Epi (t.rightToLeft.app X) ↔ Epi (F.map (t.adj₂.counit.app X)) := by
rw [← epi_comp_iff_of_epi (t.adj₁.counit.app (H.obj X)), adj₁_counit_app_rightToLeft_app]
/-- For an adjoint triple `F ⊣ G ⊣ H` where `G` is fully faithful and `H` preserves epimorphisms
(which is for example the case if `H` has a further right adjoint), the components of the natural
transformation `H ⟶ F` are epic iff the respective components of the natural transformation
`H ⋙ G ⟶ F ⋙ G` obtained from the units and counits of the adjunctions are. -/
lemma epi_rightToLeft_app_iff [H.PreservesEpimorphisms] {X : C} :
Epi (t.rightToLeft.app X) ↔ Epi (t.adj₂.counit.app X ≫ t.adj₁.unit.app X) := by
have _ := t.adj₂.isLeftAdjoint
refine ⟨fun h ↦ by rw [← map_rightToLeft_app]; exact G.map_epi _, fun h ↦ ?_⟩
rw [epi_rightToLeft_app_iff_epi_map_adj₁_unit_app]
simpa using epi_comp (t.adj₂.unit.app (H.obj X)) (H.map (t.adj₂.counit.app X ≫ t.adj₁.unit.app X))
end InnerFullyFaithful
section OuterFullyFaithful
variable [F.Full] [F.Faithful] [H.Full] [H.Faithful]
/-- The natural transformation `F ⟶ H` that exists for every adjoint triple `F ⊣ G ⊣ H` where `F`
and `H` are fully faithful, given here as the whiskered unit `F ⟶ F ⋙ G ⋙ H` of the second
adjunction followed by the inverse of the whiskered unit `F ⋙ G ⋙ H ⟶ H` of the first. -/
noncomputable def leftToRight : F ⟶ H :=
F.rightUnitor.inv ≫ whiskerLeft F t.adj₂.unit ≫ (Functor.associator _ _ _).inv ≫
inv (whiskerRight t.adj₁.unit H) ≫ H.leftUnitor.hom
omit [H.Full] [H.Faithful] in
lemma leftToRight_app {X : C} :
t.leftToRight.app X = t.adj₂.unit.app (F.obj X) ≫ inv (H.map (t.adj₁.unit.app X)) := by
simp [leftToRight]
/-- The natural transformation `F ⟶ H` for an adjoint triple `F ⊣ G ⊣ H` with `F` and `H`
fully faithful is also equal to the inverse of the whiskered counit `H ⋙ G ⋙ F ⟶ F` of the second
adjunction followed by the whiskered counit `H ⋙ G ⋙ F ⟶ H` of the first. -/
lemma leftToRight_eq_counits :
t.leftToRight = F.leftUnitor.inv ≫ inv (whiskerRight t.adj₂.counit F) ≫
(Functor.associator _ _ _).hom ≫ whiskerLeft H t.adj₁.counit ≫ H.rightUnitor.hom := by
ext X; dsimp [leftToRight]; simp only [Category.id_comp, Category.comp_id, NatIso.isIso_inv_app]
rw [IsIso.comp_inv_eq, Category.assoc, IsIso.eq_inv_comp]
refine Eq.trans ?_ (t.adj₁.counit_naturality <| (whiskerRight t.adj₁.unit H).app X)
rw [whiskerRight_app _ H, (asIso (t.adj₂.counit.app (G.obj _))).eq_comp_inv.2
(t.adj₂.counit_naturality (t.adj₁.unit.app X)),
← (asIso _).comp_hom_eq_id.1 <| t.adj₂.left_triangle_components (F.obj X)]
simp
omit [H.Full] [H.Faithful] in
/-- For an adjoint triple `F ⊣ G ⊣ H` where `F` and `H` are fully faithful, the components of the
natural transformation `F ⟶ H` at `G` are precisely the components of the natural transformation
`G ⋙ F ⟶ G ⋙ H` obtained from the units and counits of the adjunctions. -/
@[simp, reassoc]
lemma leftToRight_app_obj {X : D} :
t.leftToRight.app (G.obj X) = t.adj₁.counit.app X ≫ t.adj₂.unit.app X := by
refine (((t.adj₂.homEquiv _ _).apply_symm_apply _).symm.trans ?_).symm
rw [homEquiv_symm_apply, map_comp, Category.assoc, left_triangle_components,
homEquiv_apply, leftToRight_app, ← H.map_inv]
congr
simpa using IsIso.eq_inv_of_hom_inv_id (t.adj₁.right_triangle_components _)
omit [H.Full] [H.Faithful] in
/-- For an adjoint triple `F ⊣ G ⊣ H` where `F` and `H` are fully faithful, whiskering `G` with the
natural transformation `F ⟶ H` yields the composition of the counit of the first adjunction with
the unit of the second adjunction. -/
@[simp, reassoc]
lemma whiskerLeft_leftToRight : whiskerLeft G t.leftToRight = t.adj₁.counit ≫ t.adj₂.unit := by
ext X; exact t.leftToRight_app_obj
omit [H.Full] [H.Faithful] in
lemma map_adj₂_counit_app_leftToRight_app (X : C) :
F.map (t.adj₂.counit.app X) ≫ t.leftToRight.app X = t.adj₁.counit.app (H.obj X) := by
simp
omit [H.Full] [H.Faithful] in
@[reassoc (attr := simp)]
lemma leftToRight_app_map_adj₁_unit_app (X : C) :
t.leftToRight.app X ≫ H.map (t.adj₁.unit.app X) = t.adj₂.unit.app (F.obj X) := by
simp [leftToRight_app]
/-- For an adjoint triple `F ⊣ G ⊣ H` where `F` and `H` are fully faithful, the natural
transformation `H.op ⟶ F.op` obtained from the dual adjoint triple `H.op ⊣ G.op ⊣ F.op` is
dual to the natural transformation `F ⟶ H`. -/
@[simp]
lemma leftToRight_op : t.op.leftToRight = NatTrans.op t.leftToRight := by
ext
rw [leftToRight, leftToRight_eq_counits]
simp
omit [H.Full] [H.Faithful] in
/-- For an adjoint triple `F ⊣ G ⊣ H` where `F` and `H` are fully faithful, the natural
transformation `F ⟶ H` is monic at `X` iff the unit of the adjunction `G ⊣ H` is monic
at `F.obj X`. -/
lemma mono_leftToRight_app_iff_mono_adj₂_unit_app {X : C} :
Mono (t.leftToRight.app X) ↔ Mono (t.adj₂.unit.app (F.obj X)) := by
rw [← leftToRight_app_map_adj₁_unit_app, mono_comp_iff_of_mono]
/-- For an adjoint triple `F ⊣ G ⊣ H` where `F` and `H` are fully faithful, the natural
transformation `F ⟶ H` is monic at `X` iff the counit of the adjunction `F ⊣ G` is monic
at `H.obj X`. -/
lemma mono_leftToRight_app_iff_mono_adj₁_counit_app {X : C} :
Mono (t.leftToRight.app X) ↔ Mono (t.adj₁.counit.app (H.obj X)) := by
rw [← map_adj₂_counit_app_leftToRight_app, mono_comp_iff_of_isIso]
omit [H.Full] [H.Faithful] in
/-- For an adjoint triple `F ⊣ G ⊣ H` where `F` and `H` are fully faithful, the natural
transformation `F ⟶ H` is componentwise monic iff the natural transformation `G ⋙ F ⟶ G ⋙ H`
obtained from the units and counits of the adjunctions is.
Note that unlike `epi_rightToLeft_app_iff`, this equivalence does not make sense
on a per-object basis because the components of the two natural transformations are indexed by
different categories. -/
lemma mono_leftToRight_app_iff :
(∀ X, Mono (t.leftToRight.app X)) ↔ ∀ X, Mono (t.adj₁.counit.app X ≫ t.adj₂.unit.app X) := by
refine ⟨fun h X ↦ by rw [← leftToRight_app_obj]; exact h _, fun h X ↦ ?_⟩
rw [mono_leftToRight_app_iff_mono_adj₂_unit_app]
simpa using h (F.obj X)
end OuterFullyFaithful
end CategoryTheory.Adjunction.Triple |
.lake/packages/mathlib/Mathlib/CategoryTheory/Adjunction/Whiskering.lean | import Mathlib.CategoryTheory.Whiskering
import Mathlib.CategoryTheory.Adjunction.Basic
/-!
Given categories `C D E`, functors `F : D ⥤ E` and `G : E ⥤ D` with an adjunction
`F ⊣ G`, we provide the induced adjunction between the functor categories `C ⥤ D` and `C ⥤ E`,
and the functor categories `E ⥤ C` and `D ⥤ C`.
-/
namespace CategoryTheory.Adjunction
open CategoryTheory Functor
variable (C : Type*) {D E : Type*} [Category C] [Category D] [Category E] {F : D ⥤ E} {G : E ⥤ D}
/-- Given an adjunction `F ⊣ G`, this provides the natural adjunction
`(whiskeringRight C _ _).obj F ⊣ (whiskeringRight C _ _).obj G`. -/
@[simps! unit_app_app counit_app_app]
protected def whiskerRight (adj : F ⊣ G) :
(whiskeringRight C D E).obj F ⊣ (whiskeringRight C E D).obj G where
unit :=
{ app := fun X =>
(rightUnitor _).inv ≫ whiskerLeft X adj.unit ≫ (associator _ _ _).inv
naturality := by intros; ext; simp }
counit :=
{ app := fun X =>
(associator _ _ _).hom ≫ whiskerLeft X adj.counit ≫ (rightUnitor _).hom
naturality := by intros; ext; simp }
/-- Given an adjunction `F ⊣ G`, this provides the natural adjunction
`(whiskeringLeft _ _ C).obj G ⊣ (whiskeringLeft _ _ C).obj F`. -/
@[simps! unit_app_app counit_app_app]
protected def whiskerLeft (adj : F ⊣ G) :
(whiskeringLeft E D C).obj G ⊣ (whiskeringLeft D E C).obj F where
unit :=
{ app := fun X =>
(leftUnitor _).inv ≫ whiskerRight adj.unit X ≫ (associator _ _ _).hom }
counit :=
{ app := fun X =>
(associator _ _ _).inv ≫ whiskerRight adj.counit X ≫ (leftUnitor _).hom }
left_triangle_components X := by ext; simp [← X.map_comp]
right_triangle_components X := by ext; simp [← X.map_comp]
end CategoryTheory.Adjunction |
.lake/packages/mathlib/Mathlib/CategoryTheory/Adjunction/Limits.lean | import Mathlib.CategoryTheory.Adjunction.Basic
import Mathlib.CategoryTheory.Limits.Creates
/-!
# Adjunctions and limits
A left adjoint preserves colimits (`CategoryTheory.Adjunction.leftAdjoint_preservesColimits`),
and a right adjoint preserves limits (`CategoryTheory.Adjunction.rightAdjoint_preservesLimits`).
Equivalences create and reflect (co)limits.
(`CategoryTheory.Functor.createsLimitsOfIsEquivalence`,
`CategoryTheory.Functor.createsColimitsOfIsEquivalence`,
`CategoryTheory.Functor.reflectsLimits_of_isEquivalence`,
`CategoryTheory.Functor.reflectsColimits_of_isEquivalence`.)
In `CategoryTheory.Adjunction.coconesIso` we show that
when `F ⊣ G`,
the functor associating to each `Y` the cocones over `K ⋙ F` with cone point `Y`
is naturally isomorphic to
the functor associating to each `Y` the cocones over `K` with cone point `G.obj Y`.
-/
open Opposite
namespace CategoryTheory
open Functor Limits
universe v u v₁ v₂ v₀ u₁ u₂
namespace Adjunction
section ArbitraryUniverse
variable {C : Type u₁} [Category.{v₁} C] {D : Type u₂} [Category.{v₂} D]
variable {F : C ⥤ D} {G : D ⥤ C} (adj : F ⊣ G)
section PreservationColimits
variable {J : Type u} [Category.{v} J] (K : J ⥤ C)
/-- The right adjoint of `Cocones.functoriality K F : Cocone K ⥤ Cocone (K ⋙ F)`.
Auxiliary definition for `functorialityIsLeftAdjoint`.
-/
def functorialityRightAdjoint : Cocone (K ⋙ F) ⥤ Cocone K :=
Cocones.functoriality _ G ⋙
Cocones.precompose (K.rightUnitor.inv ≫ whiskerLeft K adj.unit ≫ (associator _ _ _).inv)
attribute [local simp] functorialityRightAdjoint
/-- The unit for the adjunction for `Cocones.functoriality K F : Cocone K ⥤ Cocone (K ⋙ F)`.
Auxiliary definition for `functorialityIsLeftAdjoint`.
-/
@[simps]
def functorialityUnit :
𝟭 (Cocone K) ⟶ Cocones.functoriality _ F ⋙ functorialityRightAdjoint adj K where
app c := { hom := adj.unit.app c.pt }
/-- The counit for the adjunction for `Cocones.functoriality K F : Cocone K ⥤ Cocone (K ⋙ F)`.
Auxiliary definition for `functorialityIsLeftAdjoint`.
-/
@[simps]
def functorialityCounit :
functorialityRightAdjoint adj K ⋙ Cocones.functoriality _ F ⟶ 𝟭 (Cocone (K ⋙ F)) where
app c := { hom := adj.counit.app c.pt }
/-- The functor `Cocones.functoriality K F : Cocone K ⥤ Cocone (K ⋙ F)` is a left adjoint. -/
def functorialityAdjunction : Cocones.functoriality K F ⊣ functorialityRightAdjoint adj K where
unit := functorialityUnit adj K
counit := functorialityCounit adj K
include adj in
/-- A left adjoint preserves colimits. -/
@[stacks 0038]
lemma leftAdjoint_preservesColimits : PreservesColimitsOfSize.{v, u} F where
preservesColimitsOfShape :=
{ preservesColimit :=
{ preserves := fun hc =>
⟨IsColimit.isoUniqueCoconeMorphism.inv fun _ =>
@Equiv.unique _ _ (IsColimit.isoUniqueCoconeMorphism.hom hc _)
((adj.functorialityAdjunction _).homEquiv _ _)⟩ } }
noncomputable
instance colim_preservesColimits [HasColimitsOfShape J C] :
PreservesColimits (colim (J := J) (C := C)) :=
colimConstAdj.leftAdjoint_preservesColimits
-- see Note [lower instance priority]
noncomputable instance (priority := 100) isEquivalence_preservesColimits
(E : C ⥤ D) [E.IsEquivalence] :
PreservesColimitsOfSize.{v, u} E :=
leftAdjoint_preservesColimits E.adjunction
-- see Note [lower instance priority]
noncomputable instance (priority := 100)
_root_.CategoryTheory.Functor.reflectsColimits_of_isEquivalence
(E : D ⥤ C) [E.IsEquivalence] :
ReflectsColimitsOfSize.{v, u} E where
reflectsColimitsOfShape :=
{ reflectsColimit :=
{ reflects := fun t =>
⟨(isColimitOfPreserves E.inv t).mapCoconeEquiv E.asEquivalence.unitIso.symm⟩ } }
-- see Note [lower instance priority]
noncomputable instance (priority := 100)
_root_.CategoryTheory.Functor.createsColimitsOfIsEquivalence (H : D ⥤ C)
[H.IsEquivalence] :
CreatesColimitsOfSize.{v, u} H where
CreatesColimitsOfShape :=
{ CreatesColimit :=
{ lifts := fun c _ =>
{ liftedCocone := mapCoconeInv H c
validLift := mapCoconeMapCoconeInv H c } } }
-- verify the preserve_colimits instance works as expected:
noncomputable example (E : C ⥤ D) [E.IsEquivalence] (c : Cocone K) (h : IsColimit c) :
IsColimit (E.mapCocone c) :=
isColimitOfPreserves E h
theorem hasColimit_comp_equivalence (E : C ⥤ D) [E.IsEquivalence] [HasColimit K] :
HasColimit (K ⋙ E) :=
HasColimit.mk
{ cocone := E.mapCocone (colimit.cocone K)
isColimit := isColimitOfPreserves _ (colimit.isColimit K) }
theorem hasColimit_of_comp_equivalence (E : C ⥤ D) [E.IsEquivalence] [HasColimit (K ⋙ E)] :
HasColimit K := by
rw [hasColimit_iff_of_iso
((Functor.rightUnitor _).symm ≪≫ isoWhiskerLeft K E.asEquivalence.unitIso)]
exact hasColimit_comp_equivalence (K ⋙ E) E.inv
/-- Transport a `HasColimitsOfShape` instance across an equivalence. -/
theorem hasColimitsOfShape_of_equivalence (E : C ⥤ D) [E.IsEquivalence] [HasColimitsOfShape J D] :
HasColimitsOfShape J C :=
⟨fun F => hasColimit_of_comp_equivalence F E⟩
/-- Transport a `HasColimitsOfSize` instance across an equivalence. -/
theorem has_colimits_of_equivalence (E : C ⥤ D) [E.IsEquivalence] [HasColimitsOfSize.{v, u} D] :
HasColimitsOfSize.{v, u} C :=
⟨fun _ _ => hasColimitsOfShape_of_equivalence E⟩
end PreservationColimits
section PreservationLimits
variable {J : Type u} [Category.{v} J] (K : J ⥤ D)
/-- The left adjoint of `Cones.functoriality K G : Cone K ⥤ Cone (K ⋙ G)`.
Auxiliary definition for `functorialityIsRightAdjoint`.
-/
def functorialityLeftAdjoint : Cone (K ⋙ G) ⥤ Cone K :=
Cones.functoriality _ F ⋙
Cones.postcompose ((associator _ _ _).hom ≫ whiskerLeft K adj.counit ≫ K.rightUnitor.hom)
attribute [local simp] functorialityLeftAdjoint
/-- The unit for the adjunction for `Cones.functoriality K G : Cone K ⥤ Cone (K ⋙ G)`.
Auxiliary definition for `functorialityIsRightAdjoint`.
-/
@[simps]
def functorialityUnit' :
𝟭 (Cone (K ⋙ G)) ⟶ functorialityLeftAdjoint adj K ⋙ Cones.functoriality _ G where
app c := { hom := adj.unit.app c.pt }
/-- The counit for the adjunction for `Cones.functoriality K G : Cone K ⥤ Cone (K ⋙ G)`.
Auxiliary definition for `functorialityIsRightAdjoint`.
-/
@[simps]
def functorialityCounit' :
Cones.functoriality _ G ⋙ functorialityLeftAdjoint adj K ⟶ 𝟭 (Cone K) where
app c := { hom := adj.counit.app c.pt }
/-- The functor `Cones.functoriality K G : Cone K ⥤ Cone (K ⋙ G)` is a right adjoint. -/
def functorialityAdjunction' : functorialityLeftAdjoint adj K ⊣ Cones.functoriality K G where
unit := functorialityUnit' adj K
counit := functorialityCounit' adj K
include adj in
/-- A right adjoint preserves limits. -/
@[stacks 0038]
lemma rightAdjoint_preservesLimits : PreservesLimitsOfSize.{v, u} G where
preservesLimitsOfShape :=
{ preservesLimit :=
{ preserves := fun hc =>
⟨IsLimit.isoUniqueConeMorphism.inv fun _ =>
@Equiv.unique _ _ (IsLimit.isoUniqueConeMorphism.hom hc _)
((adj.functorialityAdjunction' _).homEquiv _ _).symm⟩ } }
instance lim_preservesLimits [HasLimitsOfShape J C] :
PreservesLimits (lim (J := J) (C := C)) :=
constLimAdj.rightAdjoint_preservesLimits
-- see Note [lower instance priority]
instance (priority := 100) isEquivalencePreservesLimits
(E : D ⥤ C) [E.IsEquivalence] :
PreservesLimitsOfSize.{v, u} E :=
rightAdjoint_preservesLimits E.asEquivalence.symm.toAdjunction
-- see Note [lower instance priority]
noncomputable instance (priority := 100)
_root_.CategoryTheory.Functor.reflectsLimits_of_isEquivalence
(E : D ⥤ C) [E.IsEquivalence] :
ReflectsLimitsOfSize.{v, u} E where
reflectsLimitsOfShape :=
{ reflectsLimit :=
{ reflects := fun t =>
⟨(isLimitOfPreserves E.inv t).mapConeEquiv E.asEquivalence.unitIso.symm⟩ } }
-- see Note [lower instance priority]
noncomputable instance (priority := 100)
_root_.CategoryTheory.Functor.createsLimitsOfIsEquivalence (H : D ⥤ C) [H.IsEquivalence] :
CreatesLimitsOfSize.{v, u} H where
CreatesLimitsOfShape :=
{ CreatesLimit :=
{ lifts := fun c _ =>
{ liftedCone := mapConeInv H c
validLift := mapConeMapConeInv H c } } }
-- verify the preserve_limits instance works as expected:
noncomputable example (E : D ⥤ C) [E.IsEquivalence] (c : Cone K) (h : IsLimit c) :
IsLimit (E.mapCone c) :=
isLimitOfPreserves E h
theorem hasLimit_comp_equivalence (E : D ⥤ C) [E.IsEquivalence] [HasLimit K] : HasLimit (K ⋙ E) :=
HasLimit.mk
{ cone := E.mapCone (limit.cone K)
isLimit := isLimitOfPreserves _ (limit.isLimit K) }
theorem hasLimit_of_comp_equivalence (E : D ⥤ C) [E.IsEquivalence] [HasLimit (K ⋙ E)] :
HasLimit K := by
rw [← hasLimit_iff_of_iso
(isoWhiskerLeft K E.asEquivalence.unitIso.symm ≪≫ Functor.rightUnitor _)]
exact hasLimit_comp_equivalence (K ⋙ E) E.inv
/-- Transport a `HasLimitsOfShape` instance across an equivalence. -/
theorem hasLimitsOfShape_of_equivalence (E : D ⥤ C) [E.IsEquivalence] [HasLimitsOfShape J C] :
HasLimitsOfShape J D :=
⟨fun F => hasLimit_of_comp_equivalence F E⟩
/-- Transport a `HasLimitsOfSize` instance across an equivalence. -/
theorem has_limits_of_equivalence (E : D ⥤ C) [E.IsEquivalence] [HasLimitsOfSize.{v, u} C] :
HasLimitsOfSize.{v, u} D :=
⟨fun _ _ => hasLimitsOfShape_of_equivalence E⟩
end PreservationLimits
/-- auxiliary construction for `coconesIso` -/
@[simp]
def coconesIsoComponentHom {J : Type u} [Category.{v} J] {K : J ⥤ C} (Y : D)
(t : ((cocones J D).obj (op (K ⋙ F))).obj Y) : (G ⋙ (cocones J C).obj (op K)).obj Y where
app j := (adj.homEquiv (K.obj j) Y) (t.app j)
naturality j j' f := by
rw [← adj.homEquiv_naturality_left, ← Functor.comp_map, t.naturality]
simp
/-- auxiliary construction for `coconesIso` -/
@[simp]
def coconesIsoComponentInv {J : Type u} [Category.{v} J] {K : J ⥤ C} (Y : D)
(t : (G ⋙ (cocones J C).obj (op K)).obj Y) : ((cocones J D).obj (op (K ⋙ F))).obj Y where
app j := (adj.homEquiv (K.obj j) Y).symm (t.app j)
naturality j j' f := by
erw [← adj.homEquiv_naturality_left_symm, ← adj.homEquiv_naturality_right_symm, t.naturality]
simp
/-- auxiliary construction for `conesIso` -/
@[simp]
def conesIsoComponentHom {J : Type u} [Category.{v} J] {K : J ⥤ D} (X : Cᵒᵖ)
(t : (Functor.op F ⋙ (cones J D).obj K).obj X) : ((cones J C).obj (K ⋙ G)).obj X where
app j := (adj.homEquiv (unop X) (K.obj j)) (t.app j)
naturality j j' f := by
erw [← adj.homEquiv_naturality_right, ← t.naturality, Category.id_comp, Category.id_comp]
rfl
/-- auxiliary construction for `conesIso` -/
@[simp]
def conesIsoComponentInv {J : Type u} [Category.{v} J] {K : J ⥤ D} (X : Cᵒᵖ)
(t : ((cones J C).obj (K ⋙ G)).obj X) : (Functor.op F ⋙ (cones J D).obj K).obj X where
app j := (adj.homEquiv (unop X) (K.obj j)).symm (t.app j)
naturality j j' f := by
erw [← adj.homEquiv_naturality_right_symm, ← t.naturality, Category.id_comp, Category.id_comp]
end ArbitraryUniverse
variable {C : Type u₁} [Category.{v₀} C] {D : Type u₂} [Category.{v₀} D] {F : C ⥤ D} {G : D ⥤ C}
(adj : F ⊣ G)
attribute [local simp] homEquiv_unit homEquiv_counit
-- Note: this is natural in K, but we do not yet have the tools to formulate that.
/-- When `F ⊣ G`,
the functor associating to each `Y` the cocones over `K ⋙ F` with cone point `Y`
is naturally isomorphic to
the functor associating to each `Y` the cocones over `K` with cone point `G.obj Y`.
-/
def coconesIso {J : Type u} [Category.{v} J] {K : J ⥤ C} :
(cocones J D).obj (op (K ⋙ F)) ≅ G ⋙ (cocones J C).obj (op K) :=
NatIso.ofComponents fun Y =>
{ hom := coconesIsoComponentHom adj Y
inv := coconesIsoComponentInv adj Y }
-- Note: this is natural in K, but we do not yet have the tools to formulate that.
/-- When `F ⊣ G`,
the functor associating to each `X` the cones over `K` with cone point `F.op.obj X`
is naturally isomorphic to
the functor associating to each `X` the cones over `K ⋙ G` with cone point `X`.
-/
def conesIso {J : Type u} [Category.{v} J] {K : J ⥤ D} :
F.op ⋙ (cones J D).obj K ≅ (cones J C).obj (K ⋙ G) :=
NatIso.ofComponents fun X =>
{ hom := conesIsoComponentHom adj X
inv := conesIsoComponentInv adj X }
end Adjunction
namespace Functor
variable {J C D : Type*} [Category J] [Category C] [Category D]
(F : C ⥤ D)
noncomputable instance [IsLeftAdjoint F] : PreservesColimitsOfShape J F :=
(Adjunction.ofIsLeftAdjoint F).leftAdjoint_preservesColimits.preservesColimitsOfShape
noncomputable instance [IsLeftAdjoint F] : PreservesColimitsOfSize.{v, u} F where
noncomputable instance [IsRightAdjoint F] : PreservesLimitsOfShape J F :=
(Adjunction.ofIsRightAdjoint F).rightAdjoint_preservesLimits.preservesLimitsOfShape
noncomputable instance [IsRightAdjoint F] : PreservesLimitsOfSize.{v, u} F where
end Functor
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Adjunction/Lifting/Right.lean | import Mathlib.CategoryTheory.Monad.Adjunction
import Mathlib.CategoryTheory.Monad.Equalizer
/-!
# Adjoint lifting
This file gives two constructions for building right adjoints: the adjoint triangle theorem and the
adjoint lifting theorem.
The adjoint triangle theorem concerns a functor `F : B ⥤ A` with a right adjoint `U` such
that `η_X : X ⟶ UFX` is a regular mono. Then for any category `C` with equalizers of coreflexive
pairs, a functor `L : C ⥤ B` has a right adjoint if (and only if) the composite `L ⋙ F` does.
Note that the condition on `F` regarding `η_X` is automatically satisfied in the case when `F` is
a comonadic functor, giving the corollary: `isLeftAdjoint_triangle_lift_comonadic`, i.e. if `F` is
comonadic, `C` has coreflexive equalizers then `L : C ⥤ B` has a right adjoint provided `L ⋙ F`
does.
The adjoint lifting theorem says that given a commutative square of functors (up to isomorphism):
```
Q
A → B
U ↓ ↓ V
C → D
L
```
where `V` is comonadic, `U` has a right adjoint, and `A` has coreflexive equalizers, then if `L` has
a right adjoint then `Q` has a right adjoint.
## Implementation
It is more convenient to prove this theorem by assuming we are given the explicit adjunction rather
than just a functor known to be a right adjoint. In docstrings, we write `(η, ε)` for the unit
and counit of the adjunction `adj₁ : F ⊣ U` and `(ι, δ)` for the unit and counit of the adjunction
`adj₂ : L ⋙ F ⊣ U'`.
This file has been adapted from `Mathlib/CategoryTheory/Adjunction/Lifting/Left.lean`.
Please try to keep them in sync.
## TODO
- Dualise to lift left adjoints through comonads (by reversing 2-cells).
- Investigate whether it is possible to give a more explicit description of the lifted adjoint,
especially in the case when the isomorphism `comm` is `Iso.refl _`
## References
* https://ncatlab.org/nlab/show/adjoint+triangle+theorem
* https://ncatlab.org/nlab/show/adjoint+lifting+theorem
* Adjoint Lifting Theorems for Categories of Algebras (PT Johnstone, 1975)
* A unified approach to the lifting of adjoints (AJ Power, 1988)
-/
namespace CategoryTheory
open Category Limits
universe v₁ v₂ v₃ v₄ u₁ u₂ u₃ u₄
variable {A : Type u₁} {B : Type u₂} {C : Type u₃}
variable [Category.{v₁} A] [Category.{v₂} B] [Category.{v₃} C]
-- Hide implementation details in this namespace
namespace LiftRightAdjoint
variable {U : A ⥤ B} {F : B ⥤ A} (L : C ⥤ B) (U' : A ⥤ C)
variable (adj₁ : F ⊣ U) (adj₂ : L ⋙ F ⊣ U')
/-- To show that `η_X` is an equalizer for `(UFη_X, η_UFX)`, it suffices to assume it's always an
equalizer of something (i.e. a regular mono).
-/
def unitEqualises [∀ X : B, RegularMono (adj₁.unit.app X)] (X : B) :
IsLimit (Fork.ofι (adj₁.unit.app X) (adj₁.unit_naturality _)) :=
Fork.IsLimit.mk' _ fun s => by
refine ⟨(RegularMono.lift' (adj₁.unit.app X) s.ι ?_).1, ?_, ?_⟩
· rw [← cancel_mono (adj₁.unit.app (RegularMono.Z (adj₁.unit.app X)))]
rw [assoc, ← adj₁.unit_naturality RegularMono.left]
dsimp only [Functor.comp_obj]
erw [← assoc, ← s.condition, assoc, ← U.map_comp, ← F.map_comp, RegularMono.w, F.map_comp,
U.map_comp, s.condition_assoc, assoc, ← adj₁.unit_naturality RegularMono.right]
rfl
· apply (RegularMono.lift' (adj₁.unit.app X) s.ι _).2
· intro m hm
rw [← cancel_mono (adj₁.unit.app X)]
apply hm.trans (RegularMono.lift' (adj₁.unit.app X) s.ι _).2.symm
/-- (Implementation)
To construct the right adjoint, we use the equalizer of `U' F η_X` with the composite
`U' F X ⟶ U' F L U' F X ⟶ U' F U F L U' F X ⟶ U' F U F X`
where the first morphism is `ι_U'FX`, the second is `U' F η_LU'FX` and the third is `U' F U δ_FX`.
We will show that this equalizer exists and that it forms the object map for a right adjoint to `L`.
-/
def otherMap (X : B) : U'.obj (F.obj X) ⟶ U'.obj (F.obj (U.obj (F.obj X))) :=
adj₂.unit.app _ ≫ U'.map (F.map (adj₁.unit.app _ ≫ (U.map (adj₂.counit.app _))))
/-- `(U'Fη_X, otherMap X)` is a coreflexive pair: in particular if `C` has coreflexive equalizers
then this pair has an equalizer.
-/
instance (X : B) :
IsCoreflexivePair (U'.map (F.map (adj₁.unit.app X))) (otherMap _ _ adj₁ adj₂ X) :=
IsCoreflexivePair.mk' (U'.map (adj₁.counit.app (F.obj X)))
(by simp [← Functor.map_comp])
(by simp only [otherMap, assoc, ← Functor.map_comp]; simp)
variable [HasCoreflexiveEqualizers C]
/-- Construct the object part of the desired right adjoint as the equalizer of `U'Fη_Y` with
`otherMap`.
-/
noncomputable def constructRightAdjointObj (Y : B) : C :=
equalizer (U'.map (F.map (adj₁.unit.app Y))) (otherMap _ _ adj₁ adj₂ Y)
/-- The homset equivalence which helps show that `L` is a left adjoint. -/
@[simps!]
noncomputable def constructRightAdjointEquiv [∀ X : B, RegularMono (adj₁.unit.app X)] (Y : C)
(X : B) : (Y ⟶ constructRightAdjointObj _ _ adj₁ adj₂ X) ≃ (L.obj Y ⟶ X) :=
calc
(Y ⟶ constructRightAdjointObj _ _ adj₁ adj₂ X) ≃
{ f : Y ⟶ U'.obj (F.obj X) //
f ≫ U'.map (F.map (adj₁.unit.app X)) = f ≫ (otherMap _ _ adj₁ adj₂ X) } :=
Fork.IsLimit.homIso (limit.isLimit _) _
_ ≃ { g : F.obj (L.obj Y) ⟶ F.obj X // F.map (adj₁.unit.app _≫ U.map g) =
g ≫ F.map (adj₁.unit.app _) } := by
apply (adj₂.homEquiv _ _).symm.subtypeEquiv _
intro f
rw [← (adj₂.homEquiv _ _).injective.eq_iff, eq_comm, otherMap,
← adj₂.homEquiv_naturality_right_symm, adj₂.homEquiv_unit, ← adj₂.unit_naturality_assoc,
adj₂.homEquiv_counit]
simp
_ ≃ { z : L.obj Y ⟶ U.obj (F.obj X) //
z ≫ U.map (F.map (adj₁.unit.app X)) = z ≫ adj₁.unit.app (U.obj (F.obj X)) } := by
apply (adj₁.homEquiv _ _).subtypeEquiv
intro g
rw [← (adj₁.homEquiv _ _).injective.eq_iff, adj₁.homEquiv_unit,
adj₁.homEquiv_unit, adj₁.homEquiv_unit, eq_comm]
simp
_ ≃ (L.obj Y ⟶ X) := (Fork.IsLimit.homIso (unitEqualises adj₁ X) _).symm
/-- Construct the right adjoint to `L`, with object map `constructRightAdjointObj`. -/
noncomputable def constructRightAdjoint [∀ X : B, RegularMono (adj₁.unit.app X)] : B ⥤ C := by
refine Adjunction.rightAdjointOfEquiv
(fun X Y => (constructRightAdjointEquiv L _ adj₁ adj₂ X Y).symm) ?_
intro X Y Y' g h
rw [constructRightAdjointEquiv_symm_apply, constructRightAdjointEquiv_symm_apply,
Equiv.symm_apply_eq, Subtype.ext_iff]
dsimp
simp only [Adjunction.homEquiv_counit]
erw [Fork.IsLimit.homIso_natural, Fork.IsLimit.homIso_natural]
simp only [Fork.ofι_pt, Functor.map_comp, assoc, limit.cone_x]
erw [adj₂.homEquiv_naturality_left, Equiv.rightInverse_symm]
simp
end LiftRightAdjoint
/-- The adjoint triangle theorem: Suppose `U : A ⥤ B` has a left adjoint `F` such that each unit
`η_X : X ⟶ UFX` is a regular monomorphism. Then if a category `C` has equalizers of coreflexive
pairs, then a functor `L : C ⥤ B` has a right adjoint if the composite `L ⋙ F` does.
Note the converse is true (with weaker assumptions), by `Adjunction.comp`.
See https://ncatlab.org/nlab/show/adjoint+triangle+theorem
-/
lemma isLeftAdjoint_triangle_lift {U : A ⥤ B} {F : B ⥤ A} (L : C ⥤ B) (adj₁ : F ⊣ U)
[∀ X, RegularMono (adj₁.unit.app X)] [HasCoreflexiveEqualizers C]
[(L ⋙ F).IsLeftAdjoint] : L.IsLeftAdjoint where
exists_rightAdjoint :=
⟨LiftRightAdjoint.constructRightAdjoint L _ adj₁ (Adjunction.ofIsLeftAdjoint _),
⟨Adjunction.adjunctionOfEquivRight _ _⟩⟩
/-- If `L ⋙ F` has a right adjoint, the domain of `L` has coreflexive equalizers and `F` is a
comonadic functor, then `L` has a right adjoint.
This is a special case of `isLeftAdjoint_triangle_lift` which is often more useful in practice.
-/
lemma isLeftAdjoint_triangle_lift_comonadic (F : B ⥤ A) [ComonadicLeftAdjoint F] {L : C ⥤ B}
[HasCoreflexiveEqualizers C] [(L ⋙ F).IsLeftAdjoint] : L.IsLeftAdjoint := by
let L' : _ ⥤ _ := L ⋙ Comonad.comparison (comonadicAdjunction F)
rsuffices : L'.IsLeftAdjoint
· let this : (L' ⋙ (Comonad.comparison (comonadicAdjunction F)).inv).IsLeftAdjoint := by
infer_instance
refine ((Adjunction.ofIsLeftAdjoint
(L' ⋙ (Comonad.comparison (comonadicAdjunction F)).inv)).ofNatIsoLeft ?_).isLeftAdjoint
exact Functor.isoWhiskerLeft L (Comonad.comparison _).asEquivalence.unitIso.symm ≪≫ L.leftUnitor
let this : (L' ⋙ Comonad.forget (comonadicAdjunction F).toComonad).IsLeftAdjoint := by
refine ((Adjunction.ofIsLeftAdjoint (L ⋙ F)).ofNatIsoLeft ?_).isLeftAdjoint
exact Functor.isoWhiskerLeft L (Comonad.comparisonForget (comonadicAdjunction F)).symm
let this : ∀ X, RegularMono ((Comonad.adj (comonadicAdjunction F).toComonad).unit.app X) := by
intro X
simp only [Comonad.adj_unit]
exact ⟨_, _, _, _, Comonad.beckCoalgebraEqualizer X⟩
exact isLeftAdjoint_triangle_lift L' (Comonad.adj _)
variable {D : Type u₄}
variable [Category.{v₄} D]
/-- Suppose we have a commutative square of functors
```
Q
A → B
U ↓ ↓ V
C → D
R
```
where `U` has a right adjoint, `A` has coreflexive equalizers and `V` has a right adjoint such that
each component of the counit is a regular mono.
Then `Q` has a right adjoint if `L` has a right adjoint.
See https://ncatlab.org/nlab/show/adjoint+lifting+theorem
-/
lemma isLeftAdjoint_square_lift (Q : A ⥤ B) (V : B ⥤ D) (U : A ⥤ C) (L : C ⥤ D)
(comm : U ⋙ L ≅ Q ⋙ V) [U.IsLeftAdjoint] [V.IsLeftAdjoint] [L.IsLeftAdjoint]
[∀ X, RegularMono ((Adjunction.ofIsLeftAdjoint V).unit.app X)] [HasCoreflexiveEqualizers A] :
Q.IsLeftAdjoint :=
have := ((Adjunction.ofIsLeftAdjoint (U ⋙ L)).ofNatIsoLeft comm).isLeftAdjoint
isLeftAdjoint_triangle_lift Q (Adjunction.ofIsLeftAdjoint V)
/-- Suppose we have a commutative square of functors
```
Q
A → B
U ↓ ↓ V
C → D
R
```
where `U` has a right adjoint, `A` has reflexive equalizers and `V` is comonadic.
Then `Q` has a right adjoint if `L` has a right adjoint.
See https://ncatlab.org/nlab/show/adjoint+lifting+theorem
-/
lemma isLeftAdjoint_square_lift_comonadic (Q : A ⥤ B) (V : B ⥤ D) (U : A ⥤ C) (L : C ⥤ D)
(comm : U ⋙ L ≅ Q ⋙ V) [U.IsLeftAdjoint] [ComonadicLeftAdjoint V] [L.IsLeftAdjoint]
[HasCoreflexiveEqualizers A] : Q.IsLeftAdjoint :=
have := ((Adjunction.ofIsLeftAdjoint (U ⋙ L)).ofNatIsoLeft comm).isLeftAdjoint
isLeftAdjoint_triangle_lift_comonadic V
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Adjunction/Lifting/Left.lean | import Mathlib.CategoryTheory.Monad.Adjunction
import Mathlib.CategoryTheory.Monad.Coequalizer
/-!
# Adjoint lifting
This file gives two constructions for building left adjoints: the adjoint triangle theorem and the
adjoint lifting theorem.
The adjoint triangle theorem concerns a functor `U : B ⥤ C` with a left adjoint `F` such
that `ε_X : FUX ⟶ X` is a regular epi. Then for any category `A` with coequalizers of reflexive
pairs, a functor `R : A ⥤ B` has a left adjoint if (and only if) the composite `R ⋙ U` does.
Note that the condition on `U` regarding `ε_X` is automatically satisfied in the case when `U` is
a monadic functor, giving the corollary: `isRightAdjoint_triangle_lift_monadic`, i.e. if `U` is
monadic, `A` has reflexive coequalizers then `R : A ⥤ B` has a left adjoint provided `R ⋙ U` does.
The adjoint lifting theorem says that given a commutative square of functors (up to isomorphism):
```
Q
A → B
U ↓ ↓ V
C → D
R
```
where `V` is monadic, `U` has a left adjoint, and `A` has reflexive coequalizers, then if `R` has a
left adjoint then `Q` has a left adjoint.
## Implementation
It is more convenient to prove this theorem by assuming we are given the explicit adjunction rather
than just a functor known to be a right adjoint. In docstrings, we write `(η, ε)` for the unit
and counit of the adjunction `adj₁ : F ⊣ U` and `(ι, δ)` for the unit and counit of the adjunction
`adj₂ : F' ⊣ R ⋙ U`.
This file has been adapted to `Mathlib/CategoryTheory/Adjunction/Lifting/Right.lean`.
Please try to keep them in sync.
## TODO
- Dualise to lift right adjoints through monads (by reversing 2-cells).
- Investigate whether it is possible to give a more explicit description of the lifted adjoint,
especially in the case when the isomorphism `comm` is `Iso.refl _`
## References
* https://ncatlab.org/nlab/show/adjoint+triangle+theorem
* https://ncatlab.org/nlab/show/adjoint+lifting+theorem
* Adjoint Lifting Theorems for Categories of Algebras (PT Johnstone, 1975)
* A unified approach to the lifting of adjoints (AJ Power, 1988)
-/
namespace CategoryTheory
open Category Limits
universe v₁ v₂ v₃ v₄ u₁ u₂ u₃ u₄
variable {A : Type u₁} {B : Type u₂} {C : Type u₃}
variable [Category.{v₁} A] [Category.{v₂} B] [Category.{v₃} C]
-- Hide implementation details in this namespace
namespace LiftLeftAdjoint
variable {U : B ⥤ C} {F : C ⥤ B} (R : A ⥤ B) (F' : C ⥤ A)
variable (adj₁ : F ⊣ U) (adj₂ : F' ⊣ R ⋙ U)
/-- To show that `ε_X` is a coequalizer for `(FUε_X, ε_FUX)`, it suffices to assume it's always a
coequalizer of something (i.e. a regular epi).
-/
def counitCoequalises [∀ X : B, RegularEpi (adj₁.counit.app X)] (X : B) :
IsColimit (Cofork.ofπ (adj₁.counit.app X) (adj₁.counit_naturality _)) :=
Cofork.IsColimit.mk' _ fun s => by
refine ⟨(RegularEpi.desc' (adj₁.counit.app X) s.π ?_).1, ?_, ?_⟩
· rw [← cancel_epi (adj₁.counit.app (RegularEpi.W (adj₁.counit.app X)))]
rw [← adj₁.counit_naturality_assoc RegularEpi.left]
dsimp only [Functor.comp_obj]
rw [← s.condition, ← F.map_comp_assoc, ← U.map_comp, RegularEpi.w, U.map_comp,
F.map_comp_assoc, s.condition, ← adj₁.counit_naturality_assoc RegularEpi.right]
· apply (RegularEpi.desc' (adj₁.counit.app X) s.π _).2
· intro m hm
rw [← cancel_epi (adj₁.counit.app X)]
apply hm.trans (RegularEpi.desc' (adj₁.counit.app X) s.π _).2.symm
/-- (Implementation)
To construct the left adjoint, we use the coequalizer of `F' U ε_Y` with the composite
`F' U F U X ⟶ F' U F U R F U' X ⟶ F' U R F' U X ⟶ F' U X`
where the first morphism is `F' U F ι_UX`, the second is `F' U ε_RF'UX`, and the third is `δ_F'UX`.
We will show that this coequalizer exists and that it forms the object map for a left adjoint to
`R`.
-/
def otherMap (X) : F'.obj (U.obj (F.obj (U.obj X))) ⟶ F'.obj (U.obj X) :=
F'.map (U.map (F.map (adj₂.unit.app _) ≫ adj₁.counit.app _)) ≫ adj₂.counit.app _
/-- `(F'Uε_X, otherMap X)` is a reflexive pair: in particular if `A` has reflexive coequalizers then
this pair has a coequalizer.
-/
instance (X : B) :
IsReflexivePair (F'.map (U.map (adj₁.counit.app X))) (otherMap _ _ adj₁ adj₂ X) :=
IsReflexivePair.mk' (F'.map (adj₁.unit.app (U.obj X)))
(by
rw [← F'.map_comp, adj₁.right_triangle_components]
apply F'.map_id)
(by
dsimp [otherMap]
rw [← F'.map_comp_assoc, U.map_comp, adj₁.unit_naturality_assoc,
adj₁.right_triangle_components, comp_id, adj₂.left_triangle_components])
variable [HasReflexiveCoequalizers A]
/-- Construct the object part of the desired left adjoint as the coequalizer of `F'Uε_Y` with
`otherMap`.
-/
noncomputable def constructLeftAdjointObj (Y : B) : A :=
coequalizer (F'.map (U.map (adj₁.counit.app Y))) (otherMap _ _ adj₁ adj₂ Y)
/-- The homset equivalence which helps show that `R` is a right adjoint. -/
@[simps!]
noncomputable def constructLeftAdjointEquiv [∀ X : B, RegularEpi (adj₁.counit.app X)] (Y : A)
(X : B) : (constructLeftAdjointObj _ _ adj₁ adj₂ X ⟶ Y) ≃ (X ⟶ R.obj Y) :=
calc
(constructLeftAdjointObj _ _ adj₁ adj₂ X ⟶ Y) ≃
{ f : F'.obj (U.obj X) ⟶ Y //
F'.map (U.map (adj₁.counit.app X)) ≫ f = otherMap _ _ adj₁ adj₂ _ ≫ f } :=
Cofork.IsColimit.homIso (colimit.isColimit _) _
_ ≃ { g : U.obj X ⟶ U.obj (R.obj Y) //
U.map (F.map g ≫ adj₁.counit.app _) = U.map (adj₁.counit.app _) ≫ g } := by
apply (adj₂.homEquiv _ _).subtypeEquiv _
intro f
rw [← (adj₂.homEquiv _ _).injective.eq_iff, eq_comm, adj₂.homEquiv_naturality_left,
otherMap, assoc, adj₂.homEquiv_naturality_left, ← adj₂.counit_naturality,
adj₂.homEquiv_naturality_left, adj₂.homEquiv_unit, adj₂.right_triangle_components,
comp_id, Functor.comp_map, ← U.map_comp, assoc, ← adj₁.counit_naturality,
adj₂.homEquiv_unit, adj₂.homEquiv_unit, F.map_comp, assoc]
rfl
_ ≃ { z : F.obj (U.obj X) ⟶ R.obj Y // _ } := by
apply (adj₁.homEquiv _ _).symm.subtypeEquiv
intro g
rw [← (adj₁.homEquiv _ _).symm.injective.eq_iff, adj₁.homEquiv_counit,
adj₁.homEquiv_counit, adj₁.homEquiv_counit, F.map_comp, assoc, U.map_comp, F.map_comp,
assoc, adj₁.counit_naturality, adj₁.counit_naturality_assoc]
apply eq_comm
_ ≃ (X ⟶ R.obj Y) := (Cofork.IsColimit.homIso (counitCoequalises adj₁ X) _).symm
attribute [local simp] Adjunction.homEquiv_counit
/-- Construct the left adjoint to `R`, with object map `constructLeftAdjointObj`. -/
noncomputable def constructLeftAdjoint [∀ X : B, RegularEpi (adj₁.counit.app X)] : B ⥤ A := by
refine Adjunction.leftAdjointOfEquiv (fun X Y => constructLeftAdjointEquiv R _ adj₁ adj₂ Y X) ?_
intro X Y Y' g h
rw [constructLeftAdjointEquiv_apply, constructLeftAdjointEquiv_apply,
Equiv.symm_apply_eq, Subtype.ext_iff]
dsimp
-- This used to be `rw`, but we need `erw` after https://github.com/leanprover/lean4/pull/2644
erw [Cofork.IsColimit.homIso_natural, Cofork.IsColimit.homIso_natural]
erw [adj₂.homEquiv_naturality_right]
simp_rw [Functor.comp_map]
-- This used to be `simp`, but we need `cat_disch` after https://github.com/leanprover/lean4/pull/2644
cat_disch
end LiftLeftAdjoint
/-- The adjoint triangle theorem: Suppose `U : B ⥤ C` has a left adjoint `F` such that each counit
`ε_X : FUX ⟶ X` is a regular epimorphism. Then if a category `A` has coequalizers of reflexive
pairs, then a functor `R : A ⥤ B` has a left adjoint if the composite `R ⋙ U` does.
Note the converse is true (with weaker assumptions), by `Adjunction.comp`.
See https://ncatlab.org/nlab/show/adjoint+triangle+theorem
-/
lemma isRightAdjoint_triangle_lift {U : B ⥤ C} {F : C ⥤ B} (R : A ⥤ B) (adj₁ : F ⊣ U)
[∀ X : B, RegularEpi (adj₁.counit.app X)] [HasReflexiveCoequalizers A]
[(R ⋙ U).IsRightAdjoint ] : R.IsRightAdjoint where
exists_leftAdjoint :=
⟨LiftLeftAdjoint.constructLeftAdjoint R _ adj₁ (Adjunction.ofIsRightAdjoint _),
⟨Adjunction.adjunctionOfEquivLeft _ _⟩⟩
/-- If `R ⋙ U` has a left adjoint, the domain of `R` has reflexive coequalizers and `U` is a monadic
functor, then `R` has a left adjoint.
This is a special case of `isRightAdjoint_triangle_lift` which is often more useful in practice.
-/
lemma isRightAdjoint_triangle_lift_monadic (U : B ⥤ C) [MonadicRightAdjoint U] {R : A ⥤ B}
[HasReflexiveCoequalizers A] [(R ⋙ U).IsRightAdjoint] : R.IsRightAdjoint := by
let R' : A ⥤ _ := R ⋙ Monad.comparison (monadicAdjunction U)
rsuffices : R'.IsRightAdjoint
· let this : (R' ⋙ (Monad.comparison (monadicAdjunction U)).inv).IsRightAdjoint := by
infer_instance
refine ((Adjunction.ofIsRightAdjoint
(R' ⋙ (Monad.comparison (monadicAdjunction U)).inv)).ofNatIsoRight ?_).isRightAdjoint
exact Functor.isoWhiskerLeft R (Monad.comparison _).asEquivalence.unitIso.symm ≪≫ R.rightUnitor
let this : (R' ⋙ Monad.forget (monadicAdjunction U).toMonad).IsRightAdjoint := by
refine ((Adjunction.ofIsRightAdjoint (R ⋙ U)).ofNatIsoRight ?_).isRightAdjoint
exact Functor.isoWhiskerLeft R (Monad.comparisonForget (monadicAdjunction U)).symm
let this : ∀ X, RegularEpi ((Monad.adj (monadicAdjunction U).toMonad).counit.app X) := by
intro X
simp only [Monad.adj_counit]
exact ⟨_, _, _, _, Monad.beckAlgebraCoequalizer X⟩
exact isRightAdjoint_triangle_lift R' (Monad.adj _)
variable {D : Type u₄}
variable [Category.{v₄} D]
/-- Suppose we have a commutative square of functors
```
Q
A → B
U ↓ ↓ V
C → D
R
```
where `U` has a left adjoint, `A` has reflexive coequalizers and `V` has a left adjoint such that
each component of the counit is a regular epi.
Then `Q` has a left adjoint if `R` has a left adjoint.
See https://ncatlab.org/nlab/show/adjoint+lifting+theorem
-/
lemma isRightAdjoint_square_lift (Q : A ⥤ B) (V : B ⥤ D) (U : A ⥤ C) (R : C ⥤ D)
(comm : U ⋙ R ≅ Q ⋙ V) [U.IsRightAdjoint] [V.IsRightAdjoint] [R.IsRightAdjoint]
[∀ X, RegularEpi ((Adjunction.ofIsRightAdjoint V).counit.app X)] [HasReflexiveCoequalizers A] :
Q.IsRightAdjoint :=
have := ((Adjunction.ofIsRightAdjoint (U ⋙ R)).ofNatIsoRight comm).isRightAdjoint
isRightAdjoint_triangle_lift Q (Adjunction.ofIsRightAdjoint V)
/-- Suppose we have a commutative square of functors
```
Q
A → B
U ↓ ↓ V
C → D
R
```
where `U` has a left adjoint, `A` has reflexive coequalizers and `V` is monadic.
Then `Q` has a left adjoint if `R` has a left adjoint.
See https://ncatlab.org/nlab/show/adjoint+lifting+theorem
-/
lemma isRightAdjoint_square_lift_monadic (Q : A ⥤ B) (V : B ⥤ D) (U : A ⥤ C) (R : C ⥤ D)
(comm : U ⋙ R ≅ Q ⋙ V) [U.IsRightAdjoint] [MonadicRightAdjoint V] [R.IsRightAdjoint]
[HasReflexiveCoequalizers A] : Q.IsRightAdjoint :=
have := ((Adjunction.ofIsRightAdjoint (U ⋙ R)).ofNatIsoRight comm).isRightAdjoint
isRightAdjoint_triangle_lift_monadic V
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/MarkovCategory/Basic.lean | import Mathlib.CategoryTheory.CopyDiscardCategory.Basic
import Mathlib.CategoryTheory.Limits.Shapes.IsTerminal
/-!
# Markov Categories
Copy-discard categories where deletion is natural for all morphisms.
## Main definitions
* `MarkovCategory` - Copy-discard category with natural deletion
## Main results
* `eq_discard` - Any morphism to the unit equals discard
* `isTerminalUnit` - The monoidal unit is terminal
## Implementation notes
Natural discard forces probabilistic interpretation: morphisms preserve normalization. The unit
being terminal follows from naturality of discard.
The key property `discard_natural : f ≫ ε[Y] = ε[X]` means discard "erases" any preceding
morphism, a distinguishing feature of Markov categories in categorical probability.
## References
* [Cho and Jacobs, *Disintegration and Bayesian inversion via string diagrams*][cho_jacobs_2019]
* [Fritz, *A synthetic approach to Markov kernels, conditional independence
and theorems on sufficient statistics*][fritz2020]
## Tags
Markov category, probability, categorical probability
-/
universe v u
namespace CategoryTheory
open MonoidalCategory CopyDiscardCategory ComonObj Limits
variable {C : Type u} [Category.{v} C] [MonoidalCategory.{v} C]
/-- Copy-discard category where discard is natural. -/
class MarkovCategory (C : Type u) [Category.{v} C] [MonoidalCategory.{v} C]
extends CopyDiscardCategory C where
/-- Process then discard equals discard directly. -/
discard_natural {X Y : C} (f : X ⟶ Y) : f ≫ ε[Y] = ε[X]
namespace MarkovCategory
variable [MarkovCategory C]
attribute [reassoc (attr := simp)] discard_natural
/-- Any morphism to the unit equals discard. -/
theorem eq_discard (X : C) (f : X ⟶ 𝟙_ C) : f = ε[X] := by
rw [← Category.comp_id f, ← discard_unit, discard_natural]
/-- The monoidal unit is a terminal object. -/
def isTerminalUnit : IsTerminal (𝟙_ C) :=
IsTerminal.ofUniqueHom _ eq_discard
/-- There is a unique morphism to the unit (it is terminal). -/
instance (X : C) : Subsingleton (X ⟶ 𝟙_ C) where
allEq := isTerminalUnit.hom_ext
end MarkovCategory
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/LiftingProperties/Basic.lean | import Mathlib.CategoryTheory.CommSq
import Mathlib.CategoryTheory.Retract
/-!
# Lifting properties
This file defines the lifting property of two morphisms in a category and
shows basic properties of this notion.
## Main results
- `HasLiftingProperty`: the definition of the lifting property
## Tags
lifting property
@TODO :
1) direct/inverse images, adjunctions
-/
universe v
namespace CategoryTheory
open Category
variable {C : Type*} [Category C] {A B B' X Y Y' : C} (i : A ⟶ B) (i' : B ⟶ B') (p : X ⟶ Y)
(p' : Y ⟶ Y')
/-- `HasLiftingProperty i p` means that `i` has the left lifting
property with respect to `p`, or equivalently that `p` has
the right lifting property with respect to `i`. -/
class HasLiftingProperty : Prop where
/-- Unique field expressing that any commutative square built from `f` and `g` has a lift -/
sq_hasLift : ∀ {f : A ⟶ X} {g : B ⟶ Y} (sq : CommSq f i p g), sq.HasLift
instance (priority := 100) sq_hasLift_of_hasLiftingProperty {f : A ⟶ X} {g : B ⟶ Y}
(sq : CommSq f i p g) [hip : HasLiftingProperty i p] : sq.HasLift := hip.sq_hasLift _
namespace HasLiftingProperty
variable {i p}
theorem op (h : HasLiftingProperty i p) : HasLiftingProperty p.op i.op :=
⟨fun {f} {g} sq => by
simp only [CommSq.HasLift.iff_unop, Quiver.Hom.unop_op]
infer_instance⟩
theorem unop {A B X Y : Cᵒᵖ} {i : A ⟶ B} {p : X ⟶ Y} (h : HasLiftingProperty i p) :
HasLiftingProperty p.unop i.unop :=
⟨fun {f} {g} sq => by
rw [CommSq.HasLift.iff_op]
simp only [Quiver.Hom.op_unop]
infer_instance⟩
theorem iff_op : HasLiftingProperty i p ↔ HasLiftingProperty p.op i.op :=
⟨op, unop⟩
theorem iff_unop {A B X Y : Cᵒᵖ} (i : A ⟶ B) (p : X ⟶ Y) :
HasLiftingProperty i p ↔ HasLiftingProperty p.unop i.unop :=
⟨unop, op⟩
variable (i p)
instance (priority := 100) of_left_iso [IsIso i] : HasLiftingProperty i p :=
⟨fun {f} {g} sq =>
CommSq.HasLift.mk'
{ l := inv i ≫ f
fac_left := by simp only [IsIso.hom_inv_id_assoc]
fac_right := by simp only [sq.w, assoc, IsIso.inv_hom_id_assoc] }⟩
instance (priority := 100) of_right_iso [IsIso p] : HasLiftingProperty i p :=
⟨fun {f} {g} sq =>
CommSq.HasLift.mk'
{ l := g ≫ inv p
fac_left := by simp only [← sq.w_assoc, IsIso.hom_inv_id, comp_id]
fac_right := by simp only [assoc, IsIso.inv_hom_id, comp_id] }⟩
instance of_comp_left [HasLiftingProperty i p] [HasLiftingProperty i' p] :
HasLiftingProperty (i ≫ i') p :=
⟨fun {f} {g} sq => by
have fac := sq.w
rw [assoc] at fac
exact
CommSq.HasLift.mk'
{ l := (CommSq.mk (CommSq.mk fac).fac_right).lift
fac_left := by simp only [assoc, CommSq.fac_left]
fac_right := by simp only [CommSq.fac_right] }⟩
instance of_comp_right [HasLiftingProperty i p] [HasLiftingProperty i p'] :
HasLiftingProperty i (p ≫ p') :=
⟨fun {f} {g} sq => by
have fac := sq.w
rw [← assoc] at fac
let _ := (CommSq.mk (CommSq.mk fac).fac_left.symm).lift
exact
CommSq.HasLift.mk'
{ l := (CommSq.mk (CommSq.mk fac).fac_left.symm).lift
fac_left := by simp only [CommSq.fac_left]
fac_right := by simp only [CommSq.fac_right_assoc, CommSq.fac_right] }⟩
theorem of_arrow_iso_left {A B A' B' X Y : C} {i : A ⟶ B} {i' : A' ⟶ B'}
(e : Arrow.mk i ≅ Arrow.mk i') (p : X ⟶ Y) [hip : HasLiftingProperty i p] :
HasLiftingProperty i' p := by
rw [Arrow.iso_w' e]
infer_instance
theorem of_arrow_iso_right {A B X Y X' Y' : C} (i : A ⟶ B) {p : X ⟶ Y} {p' : X' ⟶ Y'}
(e : Arrow.mk p ≅ Arrow.mk p') [hip : HasLiftingProperty i p] : HasLiftingProperty i p' := by
rw [Arrow.iso_w' e]
infer_instance
theorem iff_of_arrow_iso_left {A B A' B' X Y : C} {i : A ⟶ B} {i' : A' ⟶ B'}
(e : Arrow.mk i ≅ Arrow.mk i') (p : X ⟶ Y) :
HasLiftingProperty i p ↔ HasLiftingProperty i' p := by
constructor <;> intro
exacts [of_arrow_iso_left e p, of_arrow_iso_left e.symm p]
theorem iff_of_arrow_iso_right {A B X Y X' Y' : C} (i : A ⟶ B) {p : X ⟶ Y} {p' : X' ⟶ Y'}
(e : Arrow.mk p ≅ Arrow.mk p') : HasLiftingProperty i p ↔ HasLiftingProperty i p' := by
constructor <;> intro
exacts [of_arrow_iso_right i e, of_arrow_iso_right i e.symm]
end HasLiftingProperty
lemma RetractArrow.leftLiftingProperty
{X Y Z W Z' W' : C} {g : Z ⟶ W} {g' : Z' ⟶ W'}
(h : RetractArrow g' g) (f : X ⟶ Y) [HasLiftingProperty g f] : HasLiftingProperty g' f where
sq_hasLift := fun {u v} sq ↦ by
have sq' : CommSq (h.r.left ≫ u) g f (h.r.right ≫ v) := by simp only [Arrow.mk_left,
Arrow.mk_right, Category.assoc, sq.w, Arrow.w_mk_right_assoc, Arrow.mk_hom, CommSq.mk]
exact
⟨⟨{ l := h.i.right ≫ sq'.lift
fac_left := by
simp only [← h.i_w_assoc, sq'.fac_left, h.retract_left_assoc,
Arrow.mk_left, Category.id_comp]}⟩⟩
lemma RetractArrow.rightLiftingProperty
{X Y Z W X' Y' : C} {f : X ⟶ Y} {f' : X' ⟶ Y'}
(h : RetractArrow f' f) (g : Z ⟶ W) [HasLiftingProperty g f] : HasLiftingProperty g f' where
sq_hasLift := fun {u v} sq ↦
have sq' : CommSq (u ≫ h.i.left) g f (v ≫ h.i.right) :=
⟨by rw [← Category.assoc, ← sq.w, Category.assoc, RetractArrow.i_w, Category.assoc]⟩
⟨⟨{ l := sq'.lift ≫ h.r.left}⟩⟩
namespace Arrow
/-- Given a morphism `φ : f ⟶ g` in the category `Arrow C`, this is an
abbreviation for the `CommSq.LiftStruct` structure for
the square corresponding to `φ`. -/
abbrev LiftStruct {f g : Arrow C} (φ : f ⟶ g) := (CommSq.mk φ.w).LiftStruct
lemma hasLiftingProperty_iff {A B X Y : C} (i : A ⟶ B) (p : X ⟶ Y) :
HasLiftingProperty i p ↔
∀ (φ : Arrow.mk i ⟶ Arrow.mk p), Nonempty (LiftStruct φ) := by
constructor
· intro _ φ
have sq : CommSq φ.left i p φ.right := CommSq.mk φ.w
exact ⟨{ l := sq.lift }⟩
· intro h
exact ⟨fun {f g} sq ↦ ⟨h (Arrow.homMk f g sq.w)⟩⟩
end Arrow
/-- Given morphisms `i : A ⟶ B`, `p : X ⟶ Y`, `t : A ⟶ X`,
this is the property that a lifting exists for all squares
with `i` on left, `p` on the right and `t` on the top. -/
def HasLiftingPropertyFixedTop (t : A ⟶ X) : Prop :=
∀ (b : B ⟶ Y) (sq : CommSq t i p b), sq.HasLift
/-- Given morphisms `i : A ⟶ B`, `p : X ⟶ Y`, `b : B ⟶ Y`,
this is the property that a lifting exists for all squares
with `i` on left, `p` on the right and `b` on the bottom. -/
def HasLiftingPropertyFixedBot (b : B ⟶ Y) : Prop :=
∀ (t : A ⟶ X) (sq : CommSq t i p b), sq.HasLift
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/LiftingProperties/ParametrizedAdjunction.lean | import Mathlib.CategoryTheory.LiftingProperties.Basic
import Mathlib.CategoryTheory.Limits.Shapes.Pullback.CommSq
import Mathlib.CategoryTheory.Adjunction.Parametrized
/-!
# Lifting properties and parametrized adjunctions
Let `F : C₁ ⥤ C₂ ⥤ C₃`. Given morphisms `f₁ : X₁ ⟶ Y₁` in `C₁`
and `f₂ : X₂ ⟶ Y₂` in `C₂`, we introduce a structure
`F.PushoutObjObj f₁ f₂` which contains the data of a
pushout of `(F.obj Y₁).obj X₂` and `(F.obj X₁).obj Y₂`
along `(F.obj X₁).obj X₂`. If `sq₁₂ : F.PushoutObjObj f₁ f₂`,
we have a canonical "inclusion" `sq₁₂.ι : sq₁₂.pt ⟶ (F.obj Y₁).obj Y₂`.
Similarly, if we have a bifunctor `G : C₁ᵒᵖ ⥤ C₃ ⥤ C₂`, and
morphisms `f₁ : X₁ ⟶ Y₁` in `C₁` and `f₃ : X₃ ⟶ Y₃` in `C₃`,
we introduce a structure `F.PullbackObjObj f₁ f₃` which
contains the data of a pullback of `(G.obj (op X₁)).obj X₃`
and `(G.obj (op Y₁)).obj Y₃` over `(G.obj (op X₁)).obj Y₃`.
If `sq₁₃ : F.PullbackObjObj f₁ f₃`, we have a canonical
projection `sq₁₃.π : (G.obj Y₁).obj X₃ ⟶ sq₁₃.pt`.
Now, if we have a parametrized adjunction `adj₂ : F ⊣₂ G`,
`sq₁₂ : F.PushoutObjObj f₁ f₂` and `sq₁₃ : G.PullbackObjObj f₁ f₃`,
we show that `sq₁₂.ι` has the left lifting property with respect to
`f₃` if and only if `f₂` has the left lifting property with respect
to `sq₁₃.π`: this is the lemma `ParametrizedAdjunction.hasLiftingProperty_iff`.
-/
universe v₁ v₂ v₃ u₁ u₂ u₃
namespace CategoryTheory
open Opposite Limits
variable {C₁ : Type u₁} {C₂ : Type u₂} {C₃ : Type u₃}
[Category.{v₁} C₁] [Category.{v₂} C₂] [Category.{v₃} C₃]
(F : C₁ ⥤ C₂ ⥤ C₃) (G : C₁ᵒᵖ ⥤ C₃ ⥤ C₂)
namespace Functor
section
variable {X₁ Y₁ : C₁} (f₁ : X₁ ⟶ Y₁) {X₂ Y₂ : C₂} (f₂ : X₂ ⟶ Y₂)
/-- Given a bifunctor `F : C₁ ⥤ C₂ ⥤ C₃`, and morphisms `f₁ : X₁ ⟶ Y₁` in `C₁`
and `f₂ : X₂ ⟶ Y₂` in `C₂`, this structure contains the data of
a pushout of `(F.obj Y₁).obj X₂` and `(F.obj X₁).obj Y₂`
along `(F.obj X₁).obj X₂`. -/
structure PushoutObjObj where
/-- the pushout -/
pt : C₃
/-- the first inclusion -/
inl : (F.obj Y₁).obj X₂ ⟶ pt
/-- the second inclusion -/
inr : (F.obj X₁).obj Y₂ ⟶ pt
isPushout : IsPushout ((F.map f₁).app X₂) ((F.obj X₁).map f₂) inl inr
namespace PushoutObjObj
/-- The `PushoutObjObj` structure given by the pushout of the colimits API. -/
@[simps]
noncomputable def ofHasPushout
[HasPushout ((F.map f₁).app X₂) ((F.obj X₁).map f₂)] :
F.PushoutObjObj f₁ f₂ :=
{ isPushout := IsPushout.of_hasPushout _ _, .. }
variable {F f₁ f₂} (sq : F.PushoutObjObj f₁ f₂)
/-- The "inclusion" `sq.pt ⟶ (F.obj Y₁).obj Y₂` when
`sq : F.PushoutObjObj f₁ f₂`. -/
noncomputable def ι : sq.pt ⟶ (F.obj Y₁).obj Y₂ :=
sq.isPushout.desc ((F.obj Y₁).map f₂) ((F.map f₁).app Y₂) (by simp)
@[reassoc (attr := simp)]
lemma inl_ι : sq.inl ≫ sq.ι = (F.obj Y₁).map f₂ := by simp [ι]
@[reassoc (attr := simp)]
lemma inr_ι : sq.inr ≫ sq.ι = (F.map f₁).app Y₂ := by simp [ι]
/-- Given `sq : F.PushoutObjObj f₁ f₂`, flipping the pushout square gives
`sq.flip : F.flip.PushoutObjObj f₂ f₁`. -/
@[simps]
def flip : F.flip.PushoutObjObj f₂ f₁ where
pt := sq.pt
inl := sq.inr
inr := sq.inl
isPushout := sq.isPushout.flip
@[simp]
lemma ι_flip : sq.flip.ι = sq.ι := by
apply sq.flip.isPushout.hom_ext
· rw [inl_ι, flip_inl, inr_ι, flip_obj_map]
· rw [inr_ι, flip_inr, inl_ι, flip_map_app]
end PushoutObjObj
end
section
variable {X₁ Y₁ : C₁} (f₁ : X₁ ⟶ Y₁) {X₃ Y₃ : C₃} (f₃ : X₃ ⟶ Y₃)
/-- Given a bifunctor `G : C₁ᵒᵖ ⥤ C₃ ⥤ C₂`, and morphisms `f₁ : X₁ ⟶ Y₁` in `C₁`
and `f₃ : X₃ ⟶ Y₃` in `C₃`, this structure contains the data of
a pullback of `(G.obj (op X₁)).obj X₃`
and `(G.obj (op Y₁)).obj Y₃` over `(G.obj (op X₁)).obj Y₃`. -/
structure PullbackObjObj where
/-- the pullback -/
pt : C₂
/-- the first projection -/
fst : pt ⟶ (G.obj (op X₁)).obj X₃
/-- the second projection -/
snd : pt ⟶ (G.obj (op Y₁)).obj Y₃
isPullback : IsPullback fst snd ((G.obj (op X₁)).map f₃)
((G.map f₁.op).app Y₃)
namespace PullbackObjObj
/-- The `PullbackObjObj` structure given by the pullback of the limits API. -/
@[simps]
noncomputable def ofHasPullback
[HasPullback ((G.obj (op X₁)).map f₃) ((G.map f₁.op).app Y₃)] :
G.PullbackObjObj f₁ f₃ :=
{ isPullback := IsPullback.of_hasPullback _ _, ..}
variable {G f₁ f₃} (sq : G.PullbackObjObj f₁ f₃)
/-- The projection `(G.obj (op Y₁)).obj X₃ ⟶ sq.pt` when
`sq : G.PullbackObjObj f₁ f₃`. -/
noncomputable def π : (G.obj (op Y₁)).obj X₃ ⟶ sq.pt :=
sq.isPullback.lift ((G.map f₁.op).app X₃) ((G.obj (op Y₁)).map f₃) (by simp)
@[reassoc (attr := simp)]
lemma π_fst : sq.π ≫ sq.fst = (G.map f₁.op).app X₃ := by simp [π]
@[reassoc (attr := simp)]
lemma π_snd : sq.π ≫ sq.snd = (G.obj (op Y₁)).map f₃ := by simp [π]
end PullbackObjObj
end
end Functor
namespace ParametrizedAdjunction
variable {F G} (adj₂ : F ⊣₂ G)
{X₁ Y₁ : C₁} {f₁ : X₁ ⟶ Y₁} {X₂ Y₂ : C₂} {f₂ : X₂ ⟶ Y₂}
{X₃ Y₃ : C₃} {f₃ : X₃ ⟶ Y₃}
(sq₁₂ : F.PushoutObjObj f₁ f₂) (sq₁₃ : G.PullbackObjObj f₁ f₃)
/-- Given a parametrized adjunction `F ⊣₂ G` between bifunctors, and structures
`sq₁₂ : F.PushoutObjObj f₁ f₂` and `sq₁₃ : G.PullbackObjObj f₁ f₃`, there are
as many commutative squares with left map `sq₁₂.ι` and right map `f₃`
as commutative squares with left map `f₂` and right map `sq₁₃.π`. -/
@[simps! apply_left symm_apply_right]
noncomputable def arrowHomEquiv :
(Arrow.mk sq₁₂.ι ⟶ Arrow.mk f₃) ≃
(Arrow.mk f₂ ⟶ Arrow.mk sq₁₃.π) where
toFun α :=
Arrow.homMk (adj₂.homEquiv (sq₁₂.inl ≫ α.left))
(sq₁₃.isPullback.lift
(adj₂.homEquiv (sq₁₂.inr ≫ α.left)) (adj₂.homEquiv α.right)
(by simp [← adj₂.homEquiv_naturality_one,
← adj₂.homEquiv_naturality_three])) (by
apply sq₁₃.isPullback.hom_ext
· simp [← adj₂.homEquiv_naturality_two,
← adj₂.homEquiv_naturality_one,
sq₁₂.isPushout.w_assoc]
· simp [← adj₂.homEquiv_naturality_two,
← adj₂.homEquiv_naturality_three])
invFun β :=
Arrow.homMk
(sq₁₂.isPushout.desc
(adj₂.homEquiv.symm β.left)
(adj₂.homEquiv.symm (β.right ≫ sq₁₃.fst)) (by
have := Arrow.w β =≫ sq₁₃.fst
dsimp at this
simp only [Category.assoc, sq₁₃.π_fst] at this
simp only [← adj₂.homEquiv_symm_naturality_one,
← adj₂.homEquiv_symm_naturality_two,
Arrow.mk_left, Arrow.mk_right, this]))
(adj₂.homEquiv.symm (β.right ≫ sq₁₃.snd)) (by
apply sq₁₂.isPushout.hom_ext
· have := Arrow.w β =≫ sq₁₃.snd
dsimp at this
simp only [Category.assoc, sq₁₃.π_snd] at this
simp [← adj₂.homEquiv_symm_naturality_two,
← adj₂.homEquiv_symm_naturality_three, this]
· simp [← adj₂.homEquiv_symm_naturality_one,
← adj₂.homEquiv_symm_naturality_three, sq₁₃.isPullback.w])
left_inv α := by
ext
· apply sq₁₂.isPushout.hom_ext <;> simp
· simp
right_inv β := by
ext
· simp
· apply sq₁₃.isPullback.hom_ext <;> simp
@[reassoc (attr := simp)]
lemma arrowHomEquiv_apply_right_fst (α : Arrow.mk sq₁₂.ι ⟶ Arrow.mk f₃) :
((adj₂.arrowHomEquiv sq₁₂ sq₁₃) α).right ≫ sq₁₃.fst = adj₂.homEquiv (sq₁₂.inr ≫ α.left) :=
IsPullback.lift_fst _ _ _ _
@[reassoc (attr := simp)]
lemma arrowHomEquiv_apply_right_snd (α : Arrow.mk sq₁₂.ι ⟶ Arrow.mk f₃) :
((adj₂.arrowHomEquiv sq₁₂ sq₁₃) α).right ≫ sq₁₃.snd = adj₂.homEquiv α.right :=
IsPullback.lift_snd _ _ _ _
@[reassoc (attr := simp)]
lemma inl_arrowHomEquiv_symm_apply_left (β : Arrow.mk f₂ ⟶ Arrow.mk sq₁₃.π) :
sq₁₂.inl ≫ ((adj₂.arrowHomEquiv sq₁₂ sq₁₃).symm β).left = adj₂.homEquiv.symm β.left :=
IsPushout.inl_desc _ _ _ _
@[reassoc (attr := simp)]
lemma inr_arrowHomEquiv_symm_apply_left (β : Arrow.mk f₂ ⟶ Arrow.mk sq₁₃.π) :
sq₁₂.inr ≫ ((adj₂.arrowHomEquiv sq₁₂ sq₁₃).symm β).left =
adj₂.homEquiv.symm (β.right ≫ sq₁₃.fst) :=
IsPushout.inr_desc _ _ _ _
/-- Given a parametrized adjunction `F ⊣₂ G` between bifunctors, structures
`sq₁₂ : F.PushoutObjObj f₁ f₂` and `sq₁₃ : G.PullbackObjObj f₁ f₃`,
there are as many liftings for the commutative square given by a
map `α : Arrow.mk sq₁₂.ι ⟶ Arrow.mk f₃` as there are liftings
for the square given by the corresponding map `Arrow.mk f₂ ⟶ Arrow.mk sq₁₃.π`. -/
noncomputable def liftStructEquiv (α : Arrow.mk sq₁₂.ι ⟶ Arrow.mk f₃) :
Arrow.LiftStruct α ≃ Arrow.LiftStruct (adj₂.arrowHomEquiv sq₁₂ sq₁₃ α) where
toFun l :=
{ l := adj₂.homEquiv l.l
fac_left := by
have := l.fac_left
dsimp at this ⊢
simp only [← adj₂.homEquiv_naturality_two, ← this,
sq₁₂.inl_ι_assoc]
fac_right := by
apply sq₁₃.isPullback.hom_ext
· have := l.fac_left
dsimp at this ⊢
simp only [Category.assoc, sq₁₃.π_fst, ← adj₂.homEquiv_naturality_one,
arrowHomEquiv_apply_right_fst, Arrow.mk_left, ← this, sq₁₂.inr_ι_assoc]
· have := l.fac_right
dsimp at this ⊢
simp only [Category.assoc, sq₁₃.π_snd, ← this, adj₂.homEquiv_naturality_three,
arrowHomEquiv_apply_right_snd, Arrow.mk_right] }
invFun l :=
{ l := adj₂.homEquiv.symm l.l
fac_left := by
apply sq₁₂.isPushout.hom_ext
· have := l.fac_left
dsimp at this ⊢
simp only [sq₁₂.inl_ι_assoc, ← adj₂.homEquiv_symm_naturality_two,
this, Equiv.symm_apply_apply]
· have := l.fac_right =≫ sq₁₃.fst
dsimp at this ⊢
simp only [Category.assoc, sq₁₃.π_fst] at this
simp only [sq₁₂.inr_ι_assoc, ← adj₂.homEquiv_symm_naturality_one,
this, Equiv.symm_apply_apply, arrowHomEquiv_apply_right_fst, Arrow.mk_left]
fac_right := by
have := l.fac_right =≫ sq₁₃.snd
dsimp at this ⊢
simp only [Category.assoc, sq₁₃.π_snd, arrowHomEquiv_apply_right_snd,
Arrow.mk_right] at this
rw [← adj₂.homEquiv_symm_naturality_three, this,
Equiv.symm_apply_apply] }
left_inv _ := by aesop
right_inv _ := by aesop
include adj₂ in
lemma hasLiftingProperty_iff :
HasLiftingProperty sq₁₂.ι f₃ ↔ HasLiftingProperty f₂ sq₁₃.π := by
simp only [Arrow.hasLiftingProperty_iff]
constructor
· intro h β
obtain ⟨α, rfl⟩ := (adj₂.arrowHomEquiv sq₁₂ sq₁₃).surjective β
exact ⟨adj₂.liftStructEquiv sq₁₂ sq₁₃ α (h α).some⟩
· intro h α
exact ⟨(adj₂.liftStructEquiv sq₁₂ sq₁₃ α).symm (h _).some⟩
end ParametrizedAdjunction
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/LiftingProperties/Adjunction.lean | import Mathlib.CategoryTheory.LiftingProperties.Basic
import Mathlib.CategoryTheory.Adjunction.Basic
/-!
# Lifting properties and adjunction
In this file, we obtain `Adjunction.HasLiftingProperty_iff`, which states
that when we have an adjunction `adj : G ⊣ F` between two functors `G : C ⥤ D`
and `F : D ⥤ C`, then a morphism of the form `G.map i` has the left lifting
property in `D` with respect to a morphism `p` if and only the morphism `i`
has the left lifting property in `C` with respect to `F.map p`.
-/
namespace CategoryTheory
open Category
variable {C D : Type*} [Category C] [Category D] {G : C ⥤ D} {F : D ⥤ C}
namespace CommSq
section
variable {A B : C} {X Y : D} {i : A ⟶ B} {p : X ⟶ Y} {u : G.obj A ⟶ X} {v : G.obj B ⟶ Y}
/-- When we have an adjunction `G ⊣ F`, any commutative square where the left
map is of the form `G.map i` and the right map is `p` has an "adjoint" commutative
square whose left map is `i` and whose right map is `F.map p`. -/
theorem right_adjoint (sq : CommSq u (G.map i) p v) (adj : G ⊣ F) :
CommSq (adj.homEquiv _ _ u) i (F.map p) (adj.homEquiv _ _ v) :=
⟨by
simp only [Adjunction.homEquiv_unit, assoc, ← F.map_comp, sq.w]
rw [F.map_comp, Adjunction.unit_naturality_assoc]⟩
variable (sq : CommSq u (G.map i) p v) (adj : G ⊣ F)
/-- The liftings of a commutative are in bijection with the liftings of its (right)
adjoint square. -/
def rightAdjointLiftStructEquiv : sq.LiftStruct ≃ (sq.right_adjoint adj).LiftStruct where
toFun l :=
{ l := adj.homEquiv _ _ l.l
fac_left := by rw [← adj.homEquiv_naturality_left, l.fac_left]
fac_right := by rw [← Adjunction.homEquiv_naturality_right, l.fac_right] }
invFun l :=
{ l := (adj.homEquiv _ _).symm l.l
fac_left := by
rw [← Adjunction.homEquiv_naturality_left_symm, l.fac_left]
apply (adj.homEquiv _ _).left_inv
fac_right := by
rw [← Adjunction.homEquiv_naturality_right_symm, l.fac_right]
apply (adj.homEquiv _ _).left_inv }
left_inv := by cat_disch
right_inv := by cat_disch
/-- A square has a lifting if and only if its (right) adjoint square has a lifting. -/
theorem right_adjoint_hasLift_iff : HasLift (sq.right_adjoint adj) ↔ HasLift sq := by
simp only [HasLift.iff]
exact Equiv.nonempty_congr (sq.rightAdjointLiftStructEquiv adj).symm
instance [HasLift sq] : HasLift (sq.right_adjoint adj) := by
rw [right_adjoint_hasLift_iff]
infer_instance
end
section
variable {A B : C} {X Y : D} {i : A ⟶ B} {p : X ⟶ Y} {u : A ⟶ F.obj X} {v : B ⟶ F.obj Y}
/-- When we have an adjunction `G ⊣ F`, any commutative square where the left
map is of the form `i` and the right map is `F.map p` has an "adjoint" commutative
square whose left map is `G.map i` and whose right map is `p`. -/
theorem left_adjoint (sq : CommSq u i (F.map p) v) (adj : G ⊣ F) :
CommSq ((adj.homEquiv _ _).symm u) (G.map i) p ((adj.homEquiv _ _).symm v) :=
⟨by
simp only [Adjunction.homEquiv_counit, assoc, ← G.map_comp_assoc, ← sq.w]
rw [G.map_comp, assoc, Adjunction.counit_naturality]⟩
variable (sq : CommSq u i (F.map p) v) (adj : G ⊣ F)
/-- The liftings of a commutative are in bijection with the liftings of its (left)
adjoint square. -/
def leftAdjointLiftStructEquiv :
sq.LiftStruct ≃ (sq.left_adjoint adj).LiftStruct where
toFun l :=
{ l := (adj.homEquiv _ _).symm l.l
fac_left := by rw [← adj.homEquiv_naturality_left_symm, l.fac_left]
fac_right := by rw [← adj.homEquiv_naturality_right_symm, l.fac_right] }
invFun l :=
{ l := (adj.homEquiv _ _) l.l
fac_left := by
rw [← adj.homEquiv_naturality_left, l.fac_left]
apply (adj.homEquiv _ _).right_inv
fac_right := by
rw [← adj.homEquiv_naturality_right, l.fac_right]
apply (adj.homEquiv _ _).right_inv }
left_inv := by cat_disch
right_inv := by cat_disch
/-- A (left) adjoint square has a lifting if and only if the original square has a lifting. -/
theorem left_adjoint_hasLift_iff : HasLift (sq.left_adjoint adj) ↔ HasLift sq := by
simp only [HasLift.iff]
exact Equiv.nonempty_congr (sq.leftAdjointLiftStructEquiv adj).symm
instance [HasLift sq] : HasLift (sq.left_adjoint adj) := by
rw [left_adjoint_hasLift_iff]
infer_instance
end
end CommSq
namespace Adjunction
theorem hasLiftingProperty_iff (adj : G ⊣ F) {A B : C} {X Y : D} (i : A ⟶ B) (p : X ⟶ Y) :
HasLiftingProperty (G.map i) p ↔ HasLiftingProperty i (F.map p) := by
constructor <;> intro <;> constructor <;> intro f g sq
· rw [← sq.left_adjoint_hasLift_iff adj]
infer_instance
· rw [← sq.right_adjoint_hasLift_iff adj]
infer_instance
end Adjunction
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/LiftingProperties/Limits.lean | import Mathlib.CategoryTheory.Limits.Shapes.Pullback.CommSq
/-!
# Lifting properties and (co)limits
In this file, we show some consequences of lifting properties in the presence of
certain (co)limits.
-/
universe v
namespace CategoryTheory
open Category Limits
variable {C : Type*} [Category C] {X Y Z W : C}
{f : X ⟶ Y} {s : X ⟶ Z} {g : Z ⟶ W} {t : Y ⟶ W}
lemma IsPushout.hasLiftingProperty (h : IsPushout s f g t)
{Z' W' : C} (g' : Z' ⟶ W') [HasLiftingProperty f g'] : HasLiftingProperty g g' where
sq_hasLift := fun {u v} sq ↦ by
have w : (s ≫ u) ≫ g' = f ≫ (t ≫ v) := by
rw [← Category.assoc, ← h.w, Category.assoc, Category.assoc, sq.w]
exact ⟨h.desc u (CommSq.mk w).lift (by rw [CommSq.fac_left]), h.inl_desc ..,
h.hom_ext (by rw [h.inl_desc_assoc, sq.w]) (by rw [h.inr_desc_assoc, CommSq.fac_right])⟩
lemma IsPullback.hasLiftingProperty (h : IsPullback s f g t)
{X' Y' : C} (f' : X' ⟶ Y') [HasLiftingProperty f' g] : HasLiftingProperty f' f where
sq_hasLift := fun {u v} sq ↦ by
have w : (u ≫ s) ≫ g = f' ≫ v ≫ t := by
rw [Category.assoc, h.toCommSq.w, ← Category.assoc, ← Category.assoc, sq.w]
exact ⟨h.lift (CommSq.mk w).lift v (by rw [CommSq.fac_right]),
h.hom_ext (by rw [Category.assoc, h.lift_fst, CommSq.fac_left])
(by rw [Category.assoc, h.lift_snd, sq.w]), h.lift_snd _ _ _⟩
instance [HasPushout s f] {T₁ T₂ : C} (p : T₁ ⟶ T₂) [HasLiftingProperty f p] :
HasLiftingProperty (pushout.inl s f) p :=
(IsPushout.of_hasPushout s f).hasLiftingProperty p
instance [HasPushout s f] {T₁ T₂ : C} (p : T₁ ⟶ T₂) [HasLiftingProperty s p] :
HasLiftingProperty (pushout.inr s f) p :=
(IsPushout.of_hasPushout s f).flip.hasLiftingProperty p
instance [HasPullback g t] {T₁ T₂ : C} (p : T₁ ⟶ T₂) [HasLiftingProperty p g] :
HasLiftingProperty p (pullback.snd g t) :=
(IsPullback.of_hasPullback g t).hasLiftingProperty p
instance [HasPullback g t] {T₁ T₂ : C} (p : T₁ ⟶ T₂) [HasLiftingProperty p t] :
HasLiftingProperty p (pullback.fst g t) :=
(IsPullback.of_hasPullback g t).flip.hasLiftingProperty p
instance {J : Type*} {A B : J → C} [HasProduct A] [HasProduct B]
(f : (j : J) → A j ⟶ B j) {X Y : C} (p : X ⟶ Y)
[∀ j, HasLiftingProperty p (f j)] :
HasLiftingProperty p (Limits.Pi.map f) where
sq_hasLift {t b} sq := by
have sq' (j : J) :
CommSq (t ≫ Pi.π _ j) p (f j) (b ≫ Pi.π _ j) :=
⟨by rw [← Category.assoc, ← sq.w]; simp⟩
exact ⟨⟨{ l := Pi.lift (fun j ↦ (sq' j).lift) }⟩⟩
instance {J : Type*} {A B : J → C} [HasCoproduct A] [HasCoproduct B]
(f : (j : J) → A j ⟶ B j) {X Y : C} (p : X ⟶ Y)
[∀ j, HasLiftingProperty (f j) p] :
HasLiftingProperty (Limits.Sigma.map f) p where
sq_hasLift {t b} sq := by
have sq' (j : J) :
CommSq (Sigma.ι _ j ≫ t) (f j) p (Sigma.ι _ j ≫ b) :=
⟨by simp [sq.w]⟩
exact ⟨⟨{ l := Sigma.desc (fun j ↦ (sq' j).lift) }⟩⟩
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Endofunctor/Algebra.lean | import Mathlib.CategoryTheory.Limits.Shapes.IsTerminal
import Mathlib.CategoryTheory.Functor.EpiMono
/-!
# Algebras of endofunctors
This file defines (co)algebras of an endofunctor, and provides the category instance for them.
It also defines the forgetful functor from the category of (co)algebras. It is shown that the
structure map of the initial algebra of an endofunctor is an isomorphism. Furthermore, it is shown
that for an adjunction `F ⊣ G` the category of algebras over `F` is equivalent to the category of
coalgebras over `G`.
## TODO
* Prove that if the countable infinite product over the powers of the endofunctor exists, then
algebras over the endofunctor coincide with algebras over the free monad on the endofunctor.
-/
universe v u
namespace CategoryTheory
namespace Endofunctor
variable {C : Type u} [Category.{v} C]
/-- An algebra of an endofunctor; `str` stands for "structure morphism" -/
structure Algebra (F : C ⥤ C) where
/-- carrier of the algebra -/
a : C
/-- structure morphism of the algebra -/
str : F.obj a ⟶ a
instance [Inhabited C] : Inhabited (Algebra (𝟭 C)) :=
⟨⟨default, 𝟙 _⟩⟩
namespace Algebra
variable {F : C ⥤ C} (A : Algebra F) {A₀ A₁ A₂ : Algebra F}
/-
```
str
F A₀ -----> A₀
| |
F f | | f
V V
F A₁ -----> A₁
str
```
-/
/-- A morphism between algebras of endofunctor `F` -/
@[ext]
structure Hom (A₀ A₁ : Algebra F) where
/-- underlying morphism between the carriers -/
f : A₀.1 ⟶ A₁.1
/-- compatibility condition -/
h : F.map f ≫ A₁.str = A₀.str ≫ f := by cat_disch
attribute [reassoc (attr := simp)] Hom.h
namespace Hom
/-- The identity morphism of an algebra of endofunctor `F` -/
def id : Hom A A where f := 𝟙 _
instance : Inhabited (Hom A A) :=
⟨{ f := 𝟙 _ }⟩
/-- The composition of morphisms between algebras of endofunctor `F` -/
def comp (f : Hom A₀ A₁) (g : Hom A₁ A₂) : Hom A₀ A₂ where f := f.1 ≫ g.1
end Hom
instance (F : C ⥤ C) : CategoryStruct (Algebra F) where
Hom := Hom
id := Hom.id
comp := @Hom.comp _ _ _
@[ext]
lemma ext {A B : Algebra F} {f g : A ⟶ B} (w : f.f = g.f := by cat_disch) : f = g :=
Hom.ext w
@[simp]
theorem id_eq_id : Algebra.Hom.id A = 𝟙 A :=
rfl
@[simp]
theorem id_f : (𝟙 _ : A ⟶ A).1 = 𝟙 A.1 :=
rfl
variable (f : A₀ ⟶ A₁) (g : A₁ ⟶ A₂)
@[simp]
theorem comp_eq_comp : Algebra.Hom.comp f g = f ≫ g :=
rfl
@[simp]
theorem comp_f : (f ≫ g).1 = f.1 ≫ g.1 :=
rfl
/-- Algebras of an endofunctor `F` form a category -/
instance (F : C ⥤ C) : Category (Algebra F) := { }
/-- To construct an isomorphism of algebras, it suffices to give an isomorphism of the As which
commutes with the structure morphisms.
-/
@[simps!]
def isoMk (h : A₀.1 ≅ A₁.1) (w : F.map h.hom ≫ A₁.str = A₀.str ≫ h.hom := by cat_disch) :
A₀ ≅ A₁ where
hom := { f := h.hom }
inv :=
{ f := h.inv
h := by
rw [h.eq_comp_inv, Category.assoc, ← w, ← Functor.map_comp_assoc]
simp }
/-- The forgetful functor from the category of algebras, forgetting the algebraic structure. -/
@[simps]
def forget (F : C ⥤ C) : Algebra F ⥤ C where
obj A := A.1
map := Hom.f
/-- An algebra morphism with an underlying isomorphism hom in `C` is an algebra isomorphism. -/
theorem iso_of_iso (f : A₀ ⟶ A₁) [IsIso f.1] : IsIso f :=
⟨⟨{ f := inv f.1
h := by simp }, by cat_disch, by cat_disch⟩⟩
instance forget_reflects_iso : (forget F).ReflectsIsomorphisms where reflects := iso_of_iso
instance forget_faithful : (forget F).Faithful := { }
/-- An algebra morphism with an underlying epimorphism hom in `C` is an algebra epimorphism. -/
theorem epi_of_epi {X Y : Algebra F} (f : X ⟶ Y) [h : Epi f.1] : Epi f :=
(forget F).epi_of_epi_map h
/-- An algebra morphism with an underlying monomorphism hom in `C` is an algebra monomorphism. -/
theorem mono_of_mono {X Y : Algebra F} (f : X ⟶ Y) [h : Mono f.1] : Mono f :=
(forget F).mono_of_mono_map h
/-- From a natural transformation `α : G → F` we get a functor from
algebras of `F` to algebras of `G`.
-/
@[simps]
def functorOfNatTrans {F G : C ⥤ C} (α : G ⟶ F) : Algebra F ⥤ Algebra G where
obj A :=
{ a := A.1
str := α.app _ ≫ A.str }
map f := { f := f.1 }
/-- The identity transformation induces the identity endofunctor on the category of algebras. -/
@[simps!]
def functorOfNatTransId : functorOfNatTrans (𝟙 F) ≅ 𝟭 _ :=
NatIso.ofComponents fun X => isoMk (Iso.refl _)
/-- A composition of natural transformations gives the composition of corresponding functors. -/
@[simps!]
def functorOfNatTransComp {F₀ F₁ F₂ : C ⥤ C} (α : F₀ ⟶ F₁) (β : F₁ ⟶ F₂) :
functorOfNatTrans (α ≫ β) ≅ functorOfNatTrans β ⋙ functorOfNatTrans α :=
NatIso.ofComponents fun X => isoMk (Iso.refl _)
/--
If `α` and `β` are two equal natural transformations, then the functors of algebras induced by them
are isomorphic.
We define it like this as opposed to using `eq_to_iso` so that the components are nicer to prove
lemmas about.
-/
@[simps!]
def functorOfNatTransEq {F G : C ⥤ C} {α β : F ⟶ G} (h : α = β) :
functorOfNatTrans α ≅ functorOfNatTrans β :=
NatIso.ofComponents fun X => isoMk (Iso.refl _)
/-- Naturally isomorphic endofunctors give equivalent categories of algebras.
Furthermore, they are equivalent as categories over `C`, that is,
we have `equiv_of_nat_iso h ⋙ forget = forget`.
-/
@[simps]
def equivOfNatIso {F G : C ⥤ C} (α : F ≅ G) : Algebra F ≌ Algebra G where
functor := functorOfNatTrans α.inv
inverse := functorOfNatTrans α.hom
unitIso := functorOfNatTransId.symm ≪≫ functorOfNatTransEq (by simp) ≪≫ functorOfNatTransComp _ _
counitIso :=
(functorOfNatTransComp _ _).symm ≪≫ functorOfNatTransEq (by simp) ≪≫ functorOfNatTransId
namespace Initial
variable {A : Algebra F} (h : Limits.IsInitial A)
/-- The inverse of the structure map of an initial algebra -/
@[simp]
def strInv : A.1 ⟶ F.obj A.1 :=
(h.to ⟨F.obj A.a, F.map A.str⟩).f
theorem left_inv' :
⟨strInv h ≫ A.str, by rw [← Category.assoc, F.map_comp, strInv, ← Hom.h]⟩ = 𝟙 A :=
Limits.IsInitial.hom_ext h _ (𝟙 A)
theorem left_inv : strInv h ≫ A.str = 𝟙 _ :=
congr_arg Hom.f (left_inv' h)
theorem right_inv : A.str ≫ strInv h = 𝟙 _ := by
rw [strInv, ← (h.to ⟨F.obj A.1, F.map A.str⟩).h, ← F.map_id, ← F.map_comp]
congr
exact left_inv h
/-- The structure map of the initial algebra is an isomorphism,
hence endofunctors preserve their initial algebras
-/
theorem str_isIso (h : Limits.IsInitial A) : IsIso A.str :=
{ out := ⟨strInv h, right_inv _, left_inv _⟩ }
end Initial
end Algebra
/-- A coalgebra of an endofunctor; `str` stands for "structure morphism" -/
structure Coalgebra (F : C ⥤ C) where
/-- carrier of the coalgebra -/
V : C
/-- structure morphism of the coalgebra -/
str : V ⟶ F.obj V
instance [Inhabited C] : Inhabited (Coalgebra (𝟭 C)) :=
⟨⟨default, 𝟙 _⟩⟩
namespace Coalgebra
variable {F : C ⥤ C} (V : Coalgebra F) {V₀ V₁ V₂ : Coalgebra F}
/-
```
str
V₀ -----> F V₀
| |
f | | F f
V V
V₁ -----> F V₁
str
```
-/
/-- A morphism between coalgebras of an endofunctor `F` -/
@[ext]
structure Hom (V₀ V₁ : Coalgebra F) where
/-- underlying morphism between two carriers -/
f : V₀.1 ⟶ V₁.1
/-- compatibility condition -/
h : V₀.str ≫ F.map f = f ≫ V₁.str := by cat_disch
attribute [reassoc (attr := simp)] Hom.h
namespace Hom
/-- The identity morphism of an algebra of endofunctor `F` -/
def id : Hom V V where f := 𝟙 _
instance : Inhabited (Hom V V) :=
⟨{ f := 𝟙 _ }⟩
/-- The composition of morphisms between algebras of endofunctor `F` -/
def comp (f : Hom V₀ V₁) (g : Hom V₁ V₂) : Hom V₀ V₂ where f := f.1 ≫ g.1
end Hom
instance (F : C ⥤ C) : CategoryStruct (Coalgebra F) where
Hom := Hom
id := Hom.id
comp := @Hom.comp _ _ _
@[ext]
lemma ext {A B : Coalgebra F} {f g : A ⟶ B} (w : f.f = g.f := by cat_disch) : f = g :=
Hom.ext w
@[simp]
theorem id_eq_id : Coalgebra.Hom.id V = 𝟙 V :=
rfl
@[simp]
theorem id_f : (𝟙 _ : V ⟶ V).1 = 𝟙 V.1 :=
rfl
variable (f : V₀ ⟶ V₁) (g : V₁ ⟶ V₂)
@[simp]
theorem comp_eq_comp : Coalgebra.Hom.comp f g = f ≫ g :=
rfl
@[simp]
theorem comp_f : (f ≫ g).1 = f.1 ≫ g.1 :=
rfl
/-- Coalgebras of an endofunctor `F` form a category -/
instance (F : C ⥤ C) : Category (Coalgebra F) := { }
/-- To construct an isomorphism of coalgebras, it suffices to give an isomorphism of the Vs which
commutes with the structure morphisms.
-/
@[simps]
def isoMk (h : V₀.1 ≅ V₁.1) (w : V₀.str ≫ F.map h.hom = h.hom ≫ V₁.str := by cat_disch) :
V₀ ≅ V₁ where
hom := { f := h.hom }
inv :=
{ f := h.inv
h := by
rw [h.eq_inv_comp, ← Category.assoc, ← w, Category.assoc, ← F.map_comp]
simp only [Iso.hom_inv_id, Functor.map_id, Category.comp_id] }
/-- The forgetful functor from the category of coalgebras, forgetting the coalgebraic structure. -/
@[simps]
def forget (F : C ⥤ C) : Coalgebra F ⥤ C where
obj A := A.1
map f := f.1
/-- A coalgebra morphism with an underlying isomorphism hom in `C` is a coalgebra isomorphism. -/
theorem iso_of_iso (f : V₀ ⟶ V₁) [IsIso f.1] : IsIso f :=
⟨⟨{ f := inv f.1
h := by
rw [IsIso.eq_inv_comp f.1, ← Category.assoc, ← f.h, Category.assoc]
simp }, by cat_disch, by cat_disch⟩⟩
instance forget_reflects_iso : (forget F).ReflectsIsomorphisms where reflects := iso_of_iso
instance forget_faithful : (forget F).Faithful := { }
/-- An algebra morphism with an underlying epimorphism hom in `C` is an algebra epimorphism. -/
theorem epi_of_epi {X Y : Coalgebra F} (f : X ⟶ Y) [h : Epi f.1] : Epi f :=
(forget F).epi_of_epi_map h
/-- An algebra morphism with an underlying monomorphism hom in `C` is an algebra monomorphism. -/
theorem mono_of_mono {X Y : Coalgebra F} (f : X ⟶ Y) [h : Mono f.1] : Mono f :=
(forget F).mono_of_mono_map h
/-- From a natural transformation `α : F → G` we get a functor from
coalgebras of `F` to coalgebras of `G`.
-/
@[simps]
def functorOfNatTrans {F G : C ⥤ C} (α : F ⟶ G) : Coalgebra F ⥤ Coalgebra G where
obj V :=
{ V := V.1
str := V.str ≫ α.app V.1 }
map f :=
{ f := f.1
h := by rw [Category.assoc, ← α.naturality, ← Category.assoc, f.h, Category.assoc] }
/-- The identity transformation induces the identity endofunctor on the category of coalgebras. -/
@[simps!]
def functorOfNatTransId : functorOfNatTrans (𝟙 F) ≅ 𝟭 _ :=
NatIso.ofComponents fun X => isoMk (Iso.refl _)
/-- A composition of natural transformations gives the composition of corresponding functors. -/
@[simps!]
def functorOfNatTransComp {F₀ F₁ F₂ : C ⥤ C} (α : F₀ ⟶ F₁) (β : F₁ ⟶ F₂) :
functorOfNatTrans (α ≫ β) ≅ functorOfNatTrans α ⋙ functorOfNatTrans β :=
NatIso.ofComponents fun X => isoMk (Iso.refl _)
/-- If `α` and `β` are two equal natural transformations, then the functors of coalgebras induced by
them are isomorphic.
We define it like this as opposed to using `eq_to_iso` so that the components are nicer to prove
lemmas about.
-/
@[simps!]
def functorOfNatTransEq {F G : C ⥤ C} {α β : F ⟶ G} (h : α = β) :
functorOfNatTrans α ≅ functorOfNatTrans β :=
NatIso.ofComponents fun X => isoMk (Iso.refl _)
/-- Naturally isomorphic endofunctors give equivalent categories of coalgebras.
Furthermore, they are equivalent as categories over `C`, that is,
we have `equiv_of_nat_iso h ⋙ forget = forget`.
-/
@[simps]
def equivOfNatIso {F G : C ⥤ C} (α : F ≅ G) : Coalgebra F ≌ Coalgebra G where
functor := functorOfNatTrans α.hom
inverse := functorOfNatTrans α.inv
unitIso := functorOfNatTransId.symm ≪≫ functorOfNatTransEq (by simp) ≪≫ functorOfNatTransComp _ _
counitIso :=
(functorOfNatTransComp _ _).symm ≪≫ functorOfNatTransEq (by simp) ≪≫ functorOfNatTransId
namespace Terminal
variable {A : Coalgebra F} (h : Limits.IsTerminal A)
/-- The inverse of the structure map of an terminal coalgebra -/
@[simp]
def strInv : F.obj A.1 ⟶ A.1 :=
(h.from ⟨F.obj A.V, F.map A.str⟩).f
theorem right_inv' :
⟨A.str ≫ strInv h, by rw [Category.assoc, F.map_comp, strInv, ← Hom.h] ⟩ = 𝟙 A :=
Limits.IsTerminal.hom_ext h _ (𝟙 A)
theorem right_inv : A.str ≫ strInv h = 𝟙 _ :=
congr_arg Hom.f (right_inv' h)
theorem left_inv : strInv h ≫ A.str = 𝟙 _ := by
rw [strInv, ← (h.from ⟨F.obj A.V, F.map A.str⟩).h, ← F.map_id, ← F.map_comp]
congr
exact right_inv h
/-- The structure map of the terminal coalgebra is an isomorphism,
hence endofunctors preserve their terminal coalgebras
-/
theorem str_isIso (h : Limits.IsTerminal A) : IsIso A.str :=
{ out := ⟨strInv h, right_inv _, left_inv _⟩ }
end Terminal
end Coalgebra
namespace Adjunction
variable {F : C ⥤ C} {G : C ⥤ C}
theorem Algebra.homEquiv_naturality_str (adj : F ⊣ G) (A₁ A₂ : Algebra F) (f : A₁ ⟶ A₂) :
(adj.homEquiv A₁.a A₁.a) A₁.str ≫ G.map f.f = f.f ≫ (adj.homEquiv A₂.a A₂.a) A₂.str := by
rw [← Adjunction.homEquiv_naturality_right, ← Adjunction.homEquiv_naturality_left, f.h]
theorem Coalgebra.homEquiv_naturality_str_symm (adj : F ⊣ G) (V₁ V₂ : Coalgebra G) (f : V₁ ⟶ V₂) :
F.map f.f ≫ (adj.homEquiv V₂.V V₂.V).symm V₂.str =
(adj.homEquiv V₁.V V₁.V).symm V₁.str ≫ f.f := by
rw [← Adjunction.homEquiv_naturality_left_symm, ← Adjunction.homEquiv_naturality_right_symm,
f.h]
/-- Given an adjunction `F ⊣ G`, the functor that associates to an algebra over `F` a
coalgebra over `G` defined via adjunction applied to the structure map. -/
@[simps!]
def Algebra.toCoalgebraOf (adj : F ⊣ G) : Algebra F ⥤ Coalgebra G where
obj A :=
{ V := A.1
str := (adj.homEquiv A.1 A.1).toFun A.2 }
map f :=
{ f := f.1
h := Algebra.homEquiv_naturality_str adj _ _ f }
/-- Given an adjunction `F ⊣ G`, the functor that associates to a coalgebra over `G` an algebra over
`F` defined via adjunction applied to the structure map. -/
@[simps!]
def Coalgebra.toAlgebraOf (adj : F ⊣ G) : Coalgebra G ⥤ Algebra F where
obj V :=
{ a := V.1
str := (adj.homEquiv V.1 V.1).invFun V.2 }
map f :=
{ f := f.1
h := Coalgebra.homEquiv_naturality_str_symm adj _ _ f }
/-- Given an adjunction, assigning to an algebra over the left adjoint a coalgebra over its right
adjoint and going back is isomorphic to the identity functor. -/
@[simps!]
def AlgCoalgEquiv.unitIso (adj : F ⊣ G) :
𝟭 (Algebra F) ≅ Algebra.toCoalgebraOf adj ⋙ Coalgebra.toAlgebraOf adj :=
NatIso.ofComponents (fun _ ↦ Algebra.isoMk <| Iso.refl _)
/-- Given an adjunction, assigning to a coalgebra over the right adjoint an algebra over the left
adjoint and going back is isomorphic to the identity functor. -/
@[simps!]
def AlgCoalgEquiv.counitIso (adj : F ⊣ G) :
Coalgebra.toAlgebraOf adj ⋙ Algebra.toCoalgebraOf adj ≅ 𝟭 (Coalgebra G) :=
NatIso.ofComponents (fun _ ↦ Coalgebra.isoMk <| Iso.refl _)
/-- If `F` is left adjoint to `G`, then the category of algebras over `F` is equivalent to the
category of coalgebras over `G`. -/
@[simps!]
def algebraCoalgebraEquiv (adj : F ⊣ G) : Algebra F ≌ Coalgebra G where
functor := Algebra.toCoalgebraOf adj
inverse := Coalgebra.toAlgebraOf adj
unitIso := AlgCoalgEquiv.unitIso adj
counitIso := AlgCoalgEquiv.counitIso adj
functor_unitIso_comp A := by
ext
simp
end Adjunction
end Endofunctor
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Localization/CalculusOfFractions.lean | import Mathlib.CategoryTheory.Localization.Opposite
/-!
# Calculus of fractions
Following the definitions by [Gabriel and Zisman][gabriel-zisman-1967],
given a morphism property `W : MorphismProperty C` on a category `C`,
we introduce the class `W.HasLeftCalculusOfFractions`. The main
result `Localization.exists_leftFraction` is that if `L : C ⥤ D`
is a localization functor for `W`, then for any morphism `L.obj X ⟶ L.obj Y` in `D`,
there exists an auxiliary object `Y' : C` and morphisms `g : X ⟶ Y'` and `s : Y ⟶ Y'`,
with `W s`, such that the given morphism is a sort of fraction `g / s`,
or more precisely of the form `L.map g ≫ (Localization.isoOfHom L W s hs).inv`.
We also show that the functor `L.mapArrow : Arrow C ⥤ Arrow D` is essentially surjective.
Similar results are obtained when `W` has a right calculus of fractions.
## References
* [P. Gabriel, M. Zisman, *Calculus of fractions and homotopy theory*][gabriel-zisman-1967]
-/
namespace CategoryTheory
variable {C D : Type*} [Category C] [Category D]
open Category
namespace MorphismProperty
/-- A left fraction from `X : C` to `Y : C` for `W : MorphismProperty C` consists of the
datum of an object `Y' : C` and maps `f : X ⟶ Y'` and `s : Y ⟶ Y'` such that `W s`. -/
structure LeftFraction (W : MorphismProperty C) (X Y : C) where
/-- the auxiliary object of a left fraction -/
{Y' : C}
/-- the numerator of a left fraction -/
f : X ⟶ Y'
/-- the denominator of a left fraction -/
s : Y ⟶ Y'
/-- the condition that the denominator belongs to the given morphism property -/
hs : W s
namespace LeftFraction
variable (W : MorphismProperty C) {X Y : C}
/-- The left fraction from `X` to `Y` given by a morphism `f : X ⟶ Y`. -/
@[simps]
def ofHom (f : X ⟶ Y) [W.ContainsIdentities] :
W.LeftFraction X Y := mk f (𝟙 Y) (W.id_mem Y)
variable {W}
/-- The left fraction from `X` to `Y` given by a morphism `s : Y ⟶ X` such that `W s`. -/
@[simps]
def ofInv (s : Y ⟶ X) (hs : W s) :
W.LeftFraction X Y := mk (𝟙 X) s hs
/-- If `φ : W.LeftFraction X Y` and `L` is a functor which inverts `W`, this is the
induced morphism `L.obj X ⟶ L.obj Y` -/
noncomputable def map (φ : W.LeftFraction X Y) (L : C ⥤ D) (hL : W.IsInvertedBy L) :
L.obj X ⟶ L.obj Y :=
have := hL _ φ.hs
L.map φ.f ≫ inv (L.map φ.s)
@[reassoc (attr := simp)]
lemma map_comp_map_s (φ : W.LeftFraction X Y) (L : C ⥤ D) (hL : W.IsInvertedBy L) :
φ.map L hL ≫ L.map φ.s = L.map φ.f := by
letI := hL _ φ.hs
simp [map]
variable (W)
lemma map_ofHom (f : X ⟶ Y) (L : C ⥤ D) (hL : W.IsInvertedBy L) [W.ContainsIdentities] :
(ofHom W f).map L hL = L.map f := by
simp [map]
@[reassoc (attr := simp)]
lemma map_ofInv_hom_id (s : Y ⟶ X) (hs : W s) (L : C ⥤ D) (hL : W.IsInvertedBy L) :
(ofInv s hs).map L hL ≫ L.map s = 𝟙 _ := by
letI := hL _ hs
simp [map]
@[reassoc (attr := simp)]
lemma map_hom_ofInv_id (s : Y ⟶ X) (hs : W s) (L : C ⥤ D) (hL : W.IsInvertedBy L) :
L.map s ≫ (ofInv s hs).map L hL = 𝟙 _ := by
letI := hL _ hs
simp [map]
variable {W}
lemma cases (α : W.LeftFraction X Y) :
∃ (Y' : C) (f : X ⟶ Y') (s : Y ⟶ Y') (hs : W s), α = LeftFraction.mk f s hs :=
⟨_, _, _, _, rfl⟩
end LeftFraction
/-- A right fraction from `X : C` to `Y : C` for `W : MorphismProperty C` consists of the
datum of an object `X' : C` and maps `s : X' ⟶ X` and `f : X' ⟶ Y` such that `W s`. -/
structure RightFraction (W : MorphismProperty C) (X Y : C) where
/-- the auxiliary object of a right fraction -/
{X' : C}
/-- the denominator of a right fraction -/
s : X' ⟶ X
/-- the condition that the denominator belongs to the given morphism property -/
hs : W s
/-- the numerator of a right fraction -/
f : X' ⟶ Y
namespace RightFraction
variable (W : MorphismProperty C)
variable {X Y : C}
/-- The right fraction from `X` to `Y` given by a morphism `f : X ⟶ Y`. -/
@[simps]
def ofHom (f : X ⟶ Y) [W.ContainsIdentities] :
W.RightFraction X Y := mk (𝟙 X) (W.id_mem X) f
variable {W}
/-- The right fraction from `X` to `Y` given by a morphism `s : Y ⟶ X` such that `W s`. -/
@[simps]
def ofInv (s : Y ⟶ X) (hs : W s) :
W.RightFraction X Y := mk s hs (𝟙 Y)
/-- If `φ : W.RightFraction X Y` and `L` is a functor which inverts `W`, this is the
induced morphism `L.obj X ⟶ L.obj Y` -/
noncomputable def map (φ : W.RightFraction X Y) (L : C ⥤ D) (hL : W.IsInvertedBy L) :
L.obj X ⟶ L.obj Y :=
have := hL _ φ.hs
inv (L.map φ.s) ≫ L.map φ.f
@[reassoc (attr := simp)]
lemma map_s_comp_map (φ : W.RightFraction X Y) (L : C ⥤ D) (hL : W.IsInvertedBy L) :
L.map φ.s ≫ φ.map L hL = L.map φ.f := by
letI := hL _ φ.hs
simp [map]
variable (W)
@[simp]
lemma map_ofHom (f : X ⟶ Y) (L : C ⥤ D) (hL : W.IsInvertedBy L) [W.ContainsIdentities] :
(ofHom W f).map L hL = L.map f := by
simp [map]
@[reassoc (attr := simp)]
lemma map_ofInv_hom_id (s : Y ⟶ X) (hs : W s) (L : C ⥤ D) (hL : W.IsInvertedBy L) :
(ofInv s hs).map L hL ≫ L.map s = 𝟙 _ := by
letI := hL _ hs
simp [map]
@[reassoc (attr := simp)]
lemma map_hom_ofInv_id (s : Y ⟶ X) (hs : W s) (L : C ⥤ D) (hL : W.IsInvertedBy L) :
L.map s ≫ (ofInv s hs).map L hL = 𝟙 _ := by
letI := hL _ hs
simp [map]
variable {W}
lemma cases (α : W.RightFraction X Y) :
∃ (X' : C) (s : X' ⟶ X) (hs : W s) (f : X' ⟶ Y), α = RightFraction.mk s hs f :=
⟨_, _, _, _, rfl⟩
end RightFraction
variable (W : MorphismProperty C)
/-- A multiplicative morphism property `W` has left calculus of fractions if
any right fraction can be turned into a left fraction and that two morphisms
that can be equalized by precomposition with a morphism in `W` can also
be equalized by postcomposition with a morphism in `W`. -/
class HasLeftCalculusOfFractions : Prop extends W.IsMultiplicative where
exists_leftFraction ⦃X Y : C⦄ (φ : W.RightFraction X Y) :
∃ (ψ : W.LeftFraction X Y), φ.f ≫ ψ.s = φ.s ≫ ψ.f
ext : ∀ ⦃X' X Y : C⦄ (f₁ f₂ : X ⟶ Y) (s : X' ⟶ X) (_ : W s)
(_ : s ≫ f₁ = s ≫ f₂), ∃ (Y' : C) (t : Y ⟶ Y') (_ : W t), f₁ ≫ t = f₂ ≫ t
/-- A multiplicative morphism property `W` has right calculus of fractions if
any left fraction can be turned into a right fraction and that two morphisms
that can be equalized by postcomposition with a morphism in `W` can also
be equalized by precomposition with a morphism in `W`. -/
class HasRightCalculusOfFractions : Prop extends W.IsMultiplicative where
exists_rightFraction ⦃X Y : C⦄ (φ : W.LeftFraction X Y) :
∃ (ψ : W.RightFraction X Y), ψ.s ≫ φ.f = ψ.f ≫ φ.s
ext : ∀ ⦃X Y Y' : C⦄ (f₁ f₂ : X ⟶ Y) (s : Y ⟶ Y') (_ : W s)
(_ : f₁ ≫ s = f₂ ≫ s), ∃ (X' : C) (t : X' ⟶ X) (_ : W t), t ≫ f₁ = t ≫ f₂
variable {W}
lemma RightFraction.exists_leftFraction [W.HasLeftCalculusOfFractions] {X Y : C}
(φ : W.RightFraction X Y) : ∃ (ψ : W.LeftFraction X Y), φ.f ≫ ψ.s = φ.s ≫ ψ.f :=
HasLeftCalculusOfFractions.exists_leftFraction φ
/-- A choice of a left fraction deduced from a right fraction for a morphism property `W`
when `W` has left calculus of fractions. -/
noncomputable def RightFraction.leftFraction [W.HasLeftCalculusOfFractions] {X Y : C}
(φ : W.RightFraction X Y) : W.LeftFraction X Y :=
φ.exists_leftFraction.choose
@[reassoc]
lemma RightFraction.leftFraction_fac [W.HasLeftCalculusOfFractions] {X Y : C}
(φ : W.RightFraction X Y) : φ.f ≫ φ.leftFraction.s = φ.s ≫ φ.leftFraction.f :=
φ.exists_leftFraction.choose_spec
lemma LeftFraction.exists_rightFraction [W.HasRightCalculusOfFractions] {X Y : C}
(φ : W.LeftFraction X Y) : ∃ (ψ : W.RightFraction X Y), ψ.s ≫ φ.f = ψ.f ≫ φ.s :=
HasRightCalculusOfFractions.exists_rightFraction φ
/-- A choice of a right fraction deduced from a left fraction for a morphism property `W`
when `W` has right calculus of fractions. -/
noncomputable def LeftFraction.rightFraction [W.HasRightCalculusOfFractions] {X Y : C}
(φ : W.LeftFraction X Y) : W.RightFraction X Y :=
φ.exists_rightFraction.choose
@[reassoc]
lemma LeftFraction.rightFraction_fac [W.HasRightCalculusOfFractions] {X Y : C}
(φ : W.LeftFraction X Y) : φ.rightFraction.s ≫ φ.f = φ.rightFraction.f ≫ φ.s :=
φ.exists_rightFraction.choose_spec
/-- The equivalence relation on left fractions for a morphism property `W`. -/
def LeftFractionRel {X Y : C} (z₁ z₂ : W.LeftFraction X Y) : Prop :=
∃ (Z : C) (t₁ : z₁.Y' ⟶ Z) (t₂ : z₂.Y' ⟶ Z) (_ : z₁.s ≫ t₁ = z₂.s ≫ t₂)
(_ : z₁.f ≫ t₁ = z₂.f ≫ t₂), W (z₁.s ≫ t₁)
namespace LeftFractionRel
lemma refl {X Y : C} (z : W.LeftFraction X Y) : LeftFractionRel z z :=
⟨z.Y', 𝟙 _, 𝟙 _, rfl, rfl, by simpa only [Category.comp_id] using z.hs⟩
lemma symm {X Y : C} {z₁ z₂ : W.LeftFraction X Y} (h : LeftFractionRel z₁ z₂) :
LeftFractionRel z₂ z₁ := by
obtain ⟨Z, t₁, t₂, hst, hft, ht⟩ := h
exact ⟨Z, t₂, t₁, hst.symm, hft.symm, by simpa only [← hst] using ht⟩
lemma trans {X Y : C} {z₁ z₂ z₃ : W.LeftFraction X Y}
[HasLeftCalculusOfFractions W]
(h₁₂ : LeftFractionRel z₁ z₂) (h₂₃ : LeftFractionRel z₂ z₃) :
LeftFractionRel z₁ z₃ := by
obtain ⟨Z₄, t₁, t₂, hst, hft, ht⟩ := h₁₂
obtain ⟨Z₅, u₂, u₃, hsu, hfu, hu⟩ := h₂₃
obtain ⟨⟨v₄, v₅, hv₅⟩, fac⟩ := HasLeftCalculusOfFractions.exists_leftFraction
(RightFraction.mk (z₁.s ≫ t₁) ht (z₃.s ≫ u₃))
simp only [Category.assoc] at fac
have eq : z₂.s ≫ u₂ ≫ v₅ = z₂.s ≫ t₂ ≫ v₄ := by
simpa only [← reassoc_of% hsu, reassoc_of% hst] using fac
obtain ⟨Z₇, w, hw, fac'⟩ := HasLeftCalculusOfFractions.ext _ _ _ z₂.hs eq
simp only [Category.assoc] at fac'
refine ⟨Z₇, t₁ ≫ v₄ ≫ w, u₃ ≫ v₅ ≫ w, ?_, ?_, ?_⟩
· rw [reassoc_of% fac]
· rw [reassoc_of% hft, ← fac', reassoc_of% hfu]
· rw [← reassoc_of% fac, ← reassoc_of% hsu, ← Category.assoc]
exact W.comp_mem _ _ hu (W.comp_mem _ _ hv₅ hw)
end LeftFractionRel
section
variable (W)
lemma equivalenceLeftFractionRel [W.HasLeftCalculusOfFractions] (X Y : C) :
@_root_.Equivalence (W.LeftFraction X Y) LeftFractionRel where
refl := LeftFractionRel.refl
symm := LeftFractionRel.symm
trans := LeftFractionRel.trans
variable {W}
namespace LeftFraction
open HasLeftCalculusOfFractions
/-- Auxiliary definition for the composition of left fractions. -/
@[simp]
def comp₀ [W.HasLeftCalculusOfFractions] {X Y Z : C}
(z₁ : W.LeftFraction X Y) (z₂ : W.LeftFraction Y Z) (z₃ : W.LeftFraction z₁.Y' z₂.Y') :
W.LeftFraction X Z :=
mk (z₁.f ≫ z₃.f) (z₂.s ≫ z₃.s) (W.comp_mem _ _ z₂.hs z₃.hs)
/-- The equivalence class of `z₁.comp₀ z₂ z₃` does not depend on the choice of `z₃` provided
they satisfy the compatibility `z₂.f ≫ z₃.s = z₁.s ≫ z₃.f`. -/
lemma comp₀_rel [W.HasLeftCalculusOfFractions]
{X Y Z : C} (z₁ : W.LeftFraction X Y) (z₂ : W.LeftFraction Y Z)
(z₃ z₃' : W.LeftFraction z₁.Y' z₂.Y') (h₃ : z₂.f ≫ z₃.s = z₁.s ≫ z₃.f)
(h₃' : z₂.f ≫ z₃'.s = z₁.s ≫ z₃'.f) :
LeftFractionRel (z₁.comp₀ z₂ z₃) (z₁.comp₀ z₂ z₃') := by
obtain ⟨z₄, fac⟩ := exists_leftFraction (RightFraction.mk z₃.s z₃.hs z₃'.s)
dsimp at fac
have eq : z₁.s ≫ z₃.f ≫ z₄.f = z₁.s ≫ z₃'.f ≫ z₄.s := by
rw [← reassoc_of% h₃, ← reassoc_of% h₃', fac]
obtain ⟨Y, t, ht, fac'⟩ := HasLeftCalculusOfFractions.ext _ _ _ z₁.hs eq
simp only [assoc] at fac'
refine ⟨Y, z₄.f ≫ t, z₄.s ≫ t, ?_, ?_, ?_⟩
· simp only [comp₀, assoc, reassoc_of% fac]
· simp only [comp₀, assoc, fac']
· simp only [comp₀, assoc, ← reassoc_of% fac]
exact W.comp_mem _ _ z₂.hs (W.comp_mem _ _ z₃'.hs (W.comp_mem _ _ z₄.hs ht))
variable (W) in
/-- The morphisms in the constructed localized category for a morphism property `W`
that has left calculus of fractions are equivalence classes of left fractions. -/
def Localization.Hom (X Y : C) :=
Quot (LeftFractionRel : W.LeftFraction X Y → W.LeftFraction X Y → Prop)
/-- The morphism in the constructed localized category that is induced by a left fraction. -/
def Localization.Hom.mk {X Y : C} (z : W.LeftFraction X Y) : Localization.Hom W X Y :=
Quot.mk _ z
lemma Localization.Hom.mk_surjective {X Y : C} (f : Localization.Hom W X Y) :
∃ (z : W.LeftFraction X Y), f = mk z := by
obtain ⟨z⟩ := f
exact ⟨z, rfl⟩
variable [W.HasLeftCalculusOfFractions]
/-- Auxiliary definition towards the definition of the composition of morphisms
in the constructed localized category for a morphism property that has
left calculus of fractions. -/
noncomputable def comp
{X Y Z : C} (z₁ : W.LeftFraction X Y) (z₂ : W.LeftFraction Y Z) :
Localization.Hom W X Z :=
Localization.Hom.mk (z₁.comp₀ z₂ (RightFraction.mk z₁.s z₁.hs z₂.f).leftFraction)
lemma comp_eq {X Y Z : C} (z₁ : W.LeftFraction X Y) (z₂ : W.LeftFraction Y Z)
(z₃ : W.LeftFraction z₁.Y' z₂.Y') (h₃ : z₂.f ≫ z₃.s = z₁.s ≫ z₃.f) :
z₁.comp z₂ = Localization.Hom.mk (z₁.comp₀ z₂ z₃) :=
Quot.sound (LeftFraction.comp₀_rel _ _ _ _
(RightFraction.leftFraction_fac (RightFraction.mk z₁.s z₁.hs z₂.f)) h₃)
namespace Localization
/-- Composition of morphisms in the constructed localized category
for a morphism property that has left calculus of fractions. -/
noncomputable def Hom.comp {X Y Z : C} (z₁ : Hom W X Y) (z₂ : Hom W Y Z) : Hom W X Z := by
refine Quot.lift₂ (fun a b => a.comp b) ?_ ?_ z₁ z₂
· rintro a b₁ b₂ ⟨U, t₁, t₂, hst, hft, ht⟩
obtain ⟨z₁, fac₁⟩ := exists_leftFraction (RightFraction.mk a.s a.hs b₁.f)
obtain ⟨z₂, fac₂⟩ := exists_leftFraction (RightFraction.mk a.s a.hs b₂.f)
obtain ⟨w₁, fac₁'⟩ := exists_leftFraction (RightFraction.mk z₁.s z₁.hs t₁)
obtain ⟨w₂, fac₂'⟩ := exists_leftFraction (RightFraction.mk z₂.s z₂.hs t₂)
obtain ⟨u, fac₃⟩ := exists_leftFraction (RightFraction.mk w₁.s w₁.hs w₂.s)
dsimp at fac₁ fac₂ fac₁' fac₂' fac₃ ⊢
have eq : a.s ≫ z₁.f ≫ w₁.f ≫ u.f = a.s ≫ z₂.f ≫ w₂.f ≫ u.s := by
rw [← reassoc_of% fac₁, ← reassoc_of% fac₂, ← reassoc_of% fac₁', ← reassoc_of% fac₂',
reassoc_of% hft, fac₃]
obtain ⟨Z, p, hp, fac₄⟩ := HasLeftCalculusOfFractions.ext _ _ _ a.hs eq
simp only [assoc] at fac₄
rw [comp_eq _ _ z₁ fac₁, comp_eq _ _ z₂ fac₂]
apply Quot.sound
refine ⟨Z, w₁.f ≫ u.f ≫ p, w₂.f ≫ u.s ≫ p, ?_, ?_, ?_⟩
· dsimp
simp only [assoc, ← reassoc_of% fac₁', ← reassoc_of% fac₂',
reassoc_of% hst, reassoc_of% fac₃]
· dsimp
simp only [assoc, fac₄]
· dsimp
simp only [assoc]
rw [← reassoc_of% fac₁', ← reassoc_of% fac₃, ← assoc]
exact W.comp_mem _ _ ht (W.comp_mem _ _ w₂.hs (W.comp_mem _ _ u.hs hp))
· rintro a₁ a₂ b ⟨U, t₁, t₂, hst, hft, ht⟩
obtain ⟨z₁, fac₁⟩ := exists_leftFraction (RightFraction.mk a₁.s a₁.hs b.f)
obtain ⟨z₂, fac₂⟩ := exists_leftFraction (RightFraction.mk a₂.s a₂.hs b.f)
obtain ⟨w₁, fac₁'⟩ := exists_leftFraction (RightFraction.mk (a₁.s ≫ t₁) ht (b.f ≫ z₁.s))
obtain ⟨w₂, fac₂'⟩ := exists_leftFraction (RightFraction.mk (a₂.s ≫ t₂)
(show W _ by rw [← hst]; exact ht) (b.f ≫ z₂.s))
let p₁ : W.LeftFraction X Z := LeftFraction.mk (a₁.f ≫ t₁ ≫ w₁.f) (b.s ≫ z₁.s ≫ w₁.s)
(W.comp_mem _ _ b.hs (W.comp_mem _ _ z₁.hs w₁.hs))
let p₂ : W.LeftFraction X Z := LeftFraction.mk (a₂.f ≫ t₂ ≫ w₂.f) (b.s ≫ z₂.s ≫ w₂.s)
(W.comp_mem _ _ b.hs (W.comp_mem _ _ z₂.hs w₂.hs))
dsimp at fac₁ fac₂ fac₁' fac₂' ⊢
simp only [assoc] at fac₁' fac₂'
rw [comp_eq _ _ z₁ fac₁, comp_eq _ _ z₂ fac₂]
apply Quot.sound
refine LeftFractionRel.trans ?_ ((?_ : LeftFractionRel p₁ p₂).trans ?_)
· have eq : a₁.s ≫ z₁.f ≫ w₁.s = a₁.s ≫ t₁ ≫ w₁.f := by rw [← fac₁', reassoc_of% fac₁]
obtain ⟨Z, u, hu, fac₃⟩ := HasLeftCalculusOfFractions.ext _ _ _ a₁.hs eq
simp only [assoc] at fac₃
refine ⟨Z, w₁.s ≫ u, u, ?_, ?_, ?_⟩
· dsimp [p₁]
simp only [assoc]
· dsimp [p₁]
simp only [assoc, fac₃]
· dsimp
simp only [assoc]
exact W.comp_mem _ _ b.hs (W.comp_mem _ _ z₁.hs (W.comp_mem _ _ w₁.hs hu))
· obtain ⟨q, fac₃⟩ := exists_leftFraction (RightFraction.mk (z₁.s ≫ w₁.s)
(W.comp_mem _ _ z₁.hs w₁.hs) (z₂.s ≫ w₂.s))
dsimp at fac₃
simp only [assoc] at fac₃
have eq : a₁.s ≫ t₁ ≫ w₁.f ≫ q.f = a₁.s ≫ t₁ ≫ w₂.f ≫ q.s := by
rw [← reassoc_of% fac₁', ← fac₃, reassoc_of% hst, reassoc_of% fac₂']
obtain ⟨Z, u, hu, fac₄⟩ := HasLeftCalculusOfFractions.ext _ _ _ a₁.hs eq
simp only [assoc] at fac₄
refine ⟨Z, q.f ≫ u, q.s ≫ u, ?_, ?_, ?_⟩
· simp only [p₁, p₂, assoc, reassoc_of% fac₃]
· rw [assoc, assoc, assoc, assoc, fac₄, reassoc_of% hft]
· simp only [p₁, assoc, ← reassoc_of% fac₃]
exact W.comp_mem _ _ b.hs (W.comp_mem _ _ z₂.hs
(W.comp_mem _ _ w₂.hs (W.comp_mem _ _ q.hs hu)))
· have eq : a₂.s ≫ z₂.f ≫ w₂.s = a₂.s ≫ t₂ ≫ w₂.f := by
rw [← fac₂', reassoc_of% fac₂]
obtain ⟨Z, u, hu, fac₄⟩ := HasLeftCalculusOfFractions.ext _ _ _ a₂.hs eq
simp only [assoc] at fac₄
refine ⟨Z, u, w₂.s ≫ u, ?_, ?_, ?_⟩
· dsimp [p₁, p₂]
simp only [assoc]
· dsimp [p₁, p₂]
simp only [assoc, fac₄]
· dsimp [p₁, p₂]
simp only [assoc]
exact W.comp_mem _ _ b.hs (W.comp_mem _ _ z₂.hs (W.comp_mem _ _ w₂.hs hu))
lemma Hom.comp_eq {X Y Z : C} (z₁ : W.LeftFraction X Y) (z₂ : W.LeftFraction Y Z) :
Hom.comp (mk z₁) (mk z₂) = z₁.comp z₂ := rfl
end Localization
/-- The constructed localized category for a morphism property
that has left calculus of fractions. -/
@[nolint unusedArguments]
def Localization (_ : MorphismProperty C) := C
namespace Localization
noncomputable instance : Category (Localization W) where
Hom X Y := Localization.Hom W X Y
id _ := Localization.Hom.mk (ofHom W (𝟙 _))
comp f g := f.comp g
comp_id := by
rintro (X Y : C) f
obtain ⟨z, rfl⟩ := Hom.mk_surjective f
change (Hom.mk z).comp (Hom.mk (ofHom W (𝟙 Y))) = Hom.mk z
rw [Hom.comp_eq, comp_eq z (ofHom W (𝟙 Y)) (ofInv z.s z.hs) (by simp)]
dsimp [comp₀]
simp only [comp_id, id_comp]
id_comp := by
rintro (X Y : C) f
obtain ⟨z, rfl⟩ := Hom.mk_surjective f
change (Hom.mk (ofHom W (𝟙 X))).comp (Hom.mk z) = Hom.mk z
rw [Hom.comp_eq, comp_eq (ofHom W (𝟙 X)) z (ofHom W z.f) (by simp)]
dsimp
simp only [id_comp, comp_id]
assoc := by
rintro (X₁ X₂ X₃ X₄ : C) f₁ f₂ f₃
obtain ⟨z₁, rfl⟩ := Hom.mk_surjective f₁
obtain ⟨z₂, rfl⟩ := Hom.mk_surjective f₂
obtain ⟨z₃, rfl⟩ := Hom.mk_surjective f₃
change ((Hom.mk z₁).comp (Hom.mk z₂)).comp (Hom.mk z₃) =
(Hom.mk z₁).comp ((Hom.mk z₂).comp (Hom.mk z₃))
rw [Hom.comp_eq z₁ z₂, Hom.comp_eq z₂ z₃]
obtain ⟨z₁₂, fac₁₂⟩ := exists_leftFraction (RightFraction.mk z₁.s z₁.hs z₂.f)
obtain ⟨z₂₃, fac₂₃⟩ := exists_leftFraction (RightFraction.mk z₂.s z₂.hs z₃.f)
obtain ⟨z', fac⟩ := exists_leftFraction (RightFraction.mk z₁₂.s z₁₂.hs z₂₃.f)
dsimp at fac₁₂ fac₂₃ fac
rw [comp_eq z₁ z₂ z₁₂ fac₁₂, comp_eq z₂ z₃ z₂₃ fac₂₃, comp₀, comp₀,
Hom.comp_eq, Hom.comp_eq,
comp_eq _ z₃ (mk z'.f (z₂₃.s ≫ z'.s) (W.comp_mem _ _ z₂₃.hs z'.hs))
(by dsimp; rw [assoc, reassoc_of% fac₂₃, fac]),
comp_eq z₁ _ (mk (z₁₂.f ≫ z'.f) z'.s z'.hs)
(by dsimp; rw [assoc, ← reassoc_of% fac₁₂, fac])]
simp
variable (W) in
/-- The localization functor to the constructed localized category for a morphism property
that has left calculus of fractions. -/
@[simps obj]
noncomputable def Q : C ⥤ Localization W where
obj X := X
map f := Hom.mk (ofHom W f)
map_id _ := rfl
map_comp {X Y Z} f g := by
change _ = Hom.comp _ _
rw [Hom.comp_eq, comp_eq (ofHom W f) (ofHom W g) (ofHom W g) (by simp)]
simp only [ofHom, comp₀, comp_id]
/-- The morphism on `Localization W` that is induced by a left fraction. -/
noncomputable abbrev homMk {X Y : C} (f : W.LeftFraction X Y) : (Q W).obj X ⟶ (Q W).obj Y :=
Hom.mk f
lemma homMk_eq_hom_mk {X Y : C} (f : W.LeftFraction X Y) : homMk f = Hom.mk f := rfl
variable (W)
lemma Q_map {X Y : C} (f : X ⟶ Y) : (Q W).map f = homMk (ofHom W f) := rfl
variable {W}
lemma homMk_comp_homMk {X Y Z : C} (z₁ : W.LeftFraction X Y) (z₂ : W.LeftFraction Y Z)
(z₃ : W.LeftFraction z₁.Y' z₂.Y') (h₃ : z₂.f ≫ z₃.s = z₁.s ≫ z₃.f) :
homMk z₁ ≫ homMk z₂ = homMk (z₁.comp₀ z₂ z₃) := by
change Hom.comp _ _ = _
rw [Hom.comp_eq, comp_eq z₁ z₂ z₃ h₃]
lemma homMk_eq_of_leftFractionRel {X Y : C} (z₁ z₂ : W.LeftFraction X Y)
(h : LeftFractionRel z₁ z₂) :
homMk z₁ = homMk z₂ :=
Quot.sound h
lemma homMk_eq_iff_leftFractionRel {X Y : C} (z₁ z₂ : W.LeftFraction X Y) :
homMk z₁ = homMk z₂ ↔ LeftFractionRel z₁ z₂ :=
@Equivalence.quot_mk_eq_iff _ _ (equivalenceLeftFractionRel W X Y) _ _
/-- The morphism in `Localization W` that is the formal inverse of a morphism
which belongs to `W`. -/
noncomputable def Qinv {X Y : C} (s : X ⟶ Y) (hs : W s) : (Q W).obj Y ⟶ (Q W).obj X :=
homMk (ofInv s hs)
lemma Q_map_comp_Qinv {X Y Y' : C} (f : X ⟶ Y') (s : Y ⟶ Y') (hs : W s) :
(Q W).map f ≫ Qinv s hs = homMk (mk f s hs) := by
dsimp only [Q_map, Qinv]
rw [homMk_comp_homMk (ofHom W f) (ofInv s hs) (ofHom W (𝟙 _)) (by simp)]
simp
/-- The isomorphism in `Localization W` that is induced by a morphism in `W`. -/
@[simps]
noncomputable def Qiso {X Y : C} (s : X ⟶ Y) (hs : W s) : (Q W).obj X ≅ (Q W).obj Y where
hom := (Q W).map s
inv := Qinv s hs
hom_inv_id := by
rw [Q_map_comp_Qinv]
apply homMk_eq_of_leftFractionRel
exact ⟨_, 𝟙 Y, s, by simp, by simp, by simpa using hs⟩
inv_hom_id := by
dsimp only [Qinv, Q_map]
rw [homMk_comp_homMk (ofInv s hs) (ofHom W s) (ofHom W (𝟙 Y)) (by simp)]
apply homMk_eq_of_leftFractionRel
exact ⟨_, 𝟙 Y, 𝟙 Y, by simp, by simp, by simpa using W.id_mem Y⟩
@[reassoc (attr := simp)]
lemma Qiso_hom_inv_id {X Y : C} (s : X ⟶ Y) (hs : W s) :
(Q W).map s ≫ Qinv s hs = 𝟙 _ := (Qiso s hs).hom_inv_id
@[reassoc (attr := simp)]
lemma Qiso_inv_hom_id {X Y : C} (s : X ⟶ Y) (hs : W s) :
Qinv s hs ≫ (Q W).map s = 𝟙 _ := (Qiso s hs).inv_hom_id
instance {X Y : C} (s : X ⟶ Y) (hs : W s) : IsIso (Qinv s hs) :=
(inferInstance : IsIso (Qiso s hs).inv)
section
variable {E : Type*} [Category E]
/-- The image by a functor which inverts `W` of an equivalence class of left fractions. -/
noncomputable def Hom.map {X Y : C} (f : Hom W X Y) (F : C ⥤ E) (hF : W.IsInvertedBy F) :
F.obj X ⟶ F.obj Y :=
Quot.lift (fun f => f.map F hF) (by
intro a₁ a₂ ⟨Z, t₁, t₂, hst, hft, h⟩
dsimp
have := hF _ h
rw [← cancel_mono (F.map (a₁.s ≫ t₁)), F.map_comp, map_comp_map_s_assoc,
← F.map_comp, ← F.map_comp, hst, hft, F.map_comp,
F.map_comp, map_comp_map_s_assoc]) f
@[simp]
lemma Hom.map_mk {W} {X Y : C} (f : LeftFraction W X Y) (F : C ⥤ E) (hF : W.IsInvertedBy F) :
Hom.map (Hom.mk f) F hF = f.map F hF := rfl
namespace StrictUniversalPropertyFixedTarget
variable (W)
lemma inverts : W.IsInvertedBy (Q W) := fun _ _ s hs =>
(inferInstance : IsIso (Qiso s hs).hom)
variable {W}
/-- The functor `Localization W ⥤ E` that is induced by a functor `C ⥤ E` which inverts `W`,
when `W` has a left calculus of fractions. -/
noncomputable def lift (F : C ⥤ E) (hF : W.IsInvertedBy F) :
Localization W ⥤ E where
obj X := F.obj X
map {_ _ : C} f := f.map F hF
map_id := by
intro (X : C)
change (Hom.mk (ofHom W (𝟙 X))).map F hF = _
rw [Hom.map_mk, map_ofHom, F.map_id]
map_comp := by
rintro (X Y Z : C) f g
obtain ⟨f, rfl⟩ := Hom.mk_surjective f
obtain ⟨g, rfl⟩ := Hom.mk_surjective g
dsimp
obtain ⟨z, fac⟩ := HasLeftCalculusOfFractions.exists_leftFraction
(RightFraction.mk f.s f.hs g.f)
rw [homMk_comp_homMk f g z fac, Hom.map_mk]
dsimp at fac ⊢
have := hF _ g.hs
have := hF _ z.hs
rw [← cancel_mono (F.map g.s), assoc, map_comp_map_s,
← cancel_mono (F.map z.s), assoc, assoc, ← F.map_comp,
← F.map_comp, map_comp_map_s, fac]
dsimp
rw [F.map_comp, F.map_comp, map_comp_map_s_assoc]
lemma fac (F : C ⥤ E) (hF : W.IsInvertedBy F) : Q W ⋙ lift F hF = F :=
Functor.ext (fun _ => rfl) (fun X Y f => by
dsimp [lift]
rw [Q_map, Hom.map_mk, id_comp, comp_id, map_ofHom])
lemma uniq (F₁ F₂ : Localization W ⥤ E) (h : Q W ⋙ F₁ = Q W ⋙ F₂) : F₁ = F₂ :=
Functor.ext (fun X => Functor.congr_obj h X) (by
rintro (X Y : C) f
obtain ⟨f, rfl⟩ := Hom.mk_surjective f
rw [show Hom.mk f = homMk (mk f.f f.s f.hs) by rfl,
← Q_map_comp_Qinv f.f f.s f.hs, F₁.map_comp, F₂.map_comp, assoc]
erw [Functor.congr_hom h f.f]
rw [assoc, assoc]
congr 2
have := inverts W _ f.hs
rw [← cancel_epi (F₂.map ((Q W).map f.s)), ← F₂.map_comp_assoc,
Qiso_hom_inv_id, Functor.map_id, id_comp]
erw [Functor.congr_hom h.symm f.s]
dsimp
rw [assoc, assoc, eqToHom_trans_assoc, eqToHom_refl, id_comp, ← F₁.map_comp,
Qiso_hom_inv_id]
dsimp
rw [F₁.map_id, comp_id])
end StrictUniversalPropertyFixedTarget
variable (W)
open StrictUniversalPropertyFixedTarget in
/-- The universal property of the localization for the constructed localized category
when there is a left calculus of fractions. -/
noncomputable def strictUniversalPropertyFixedTarget (E : Type*) [Category E] :
Localization.StrictUniversalPropertyFixedTarget (Q W) W E where
inverts := inverts W
lift := lift
fac := fac
uniq := uniq
instance : (Q W).IsLocalization W :=
Functor.IsLocalization.mk' _ _
(strictUniversalPropertyFixedTarget W _)
(strictUniversalPropertyFixedTarget W _)
end
lemma homMk_eq {X Y : C} (f : LeftFraction W X Y) :
homMk f = f.map (Q W) (Localization.inverts _ W) := by
have := Localization.inverts (Q W) W f.s f.hs
rw [← Q_map_comp_Qinv f.f f.s f.hs, ← cancel_mono ((Q W).map f.s),
assoc, Qiso_inv_hom_id, comp_id, map_comp_map_s]
lemma map_eq_iff {X Y : C} (f g : LeftFraction W X Y) :
f.map (LeftFraction.Localization.Q W) (Localization.inverts _ _) =
g.map (LeftFraction.Localization.Q W) (Localization.inverts _ _) ↔
LeftFractionRel f g := by
simp only [← Hom.map_mk _ (Q W)]
constructor
· intro h
rw [← homMk_eq_iff_leftFractionRel, homMk_eq, homMk_eq]
exact h
· intro h
congr 1
exact Quot.sound h
end Localization
section
lemma map_eq {W} {X Y : C} (φ : W.LeftFraction X Y) (L : C ⥤ D) [L.IsLocalization W] :
φ.map L (Localization.inverts L W) =
L.map φ.f ≫ (Localization.isoOfHom L W φ.s φ.hs).inv := rfl
lemma map_compatibility {W} {X Y : C}
(φ : W.LeftFraction X Y) {E : Type*} [Category E]
(L₁ : C ⥤ D) (L₂ : C ⥤ E) [L₁.IsLocalization W] [L₂.IsLocalization W] :
(Localization.uniq L₁ L₂ W).functor.map (φ.map L₁ (Localization.inverts L₁ W)) =
(Localization.compUniqFunctor L₁ L₂ W).hom.app X ≫
φ.map L₂ (Localization.inverts L₂ W) ≫
(Localization.compUniqFunctor L₁ L₂ W).inv.app Y := by
let e := Localization.compUniqFunctor L₁ L₂ W
have := Localization.inverts L₂ W φ.s φ.hs
rw [← cancel_mono (e.hom.app Y), assoc, assoc, e.inv_hom_id_app, comp_id,
← cancel_mono (L₂.map φ.s), assoc, assoc, map_comp_map_s, ← e.hom.naturality]
simpa [← Functor.map_comp_assoc, map_comp_map_s] using e.hom.naturality φ.f
lemma map_eq_of_map_eq {W} {X Y : C}
(φ₁ φ₂ : W.LeftFraction X Y) {E : Type*} [Category E]
(L₁ : C ⥤ D) (L₂ : C ⥤ E) [L₁.IsLocalization W] [L₂.IsLocalization W]
(h : φ₁.map L₁ (Localization.inverts L₁ W) = φ₂.map L₁ (Localization.inverts L₁ W)) :
φ₁.map L₂ (Localization.inverts L₂ W) = φ₂.map L₂ (Localization.inverts L₂ W) := by
apply (Localization.uniq L₂ L₁ W).functor.map_injective
rw [map_compatibility φ₁ L₂ L₁, map_compatibility φ₂ L₂ L₁, h]
lemma map_comp_map_eq_map {X Y Z : C} (z₁ : W.LeftFraction X Y) (z₂ : W.LeftFraction Y Z)
(z₃ : W.LeftFraction z₁.Y' z₂.Y') (h₃ : z₂.f ≫ z₃.s = z₁.s ≫ z₃.f)
(L : C ⥤ D) [L.IsLocalization W] :
z₁.map L (Localization.inverts L W) ≫ z₂.map L (Localization.inverts L W) =
(z₁.comp₀ z₂ z₃).map L (Localization.inverts L W) := by
have := Localization.inverts L W _ z₂.hs
have := Localization.inverts L W _ z₃.hs
have : IsIso (L.map (z₂.s ≫ z₃.s)) := by
rw [L.map_comp]
infer_instance
dsimp [LeftFraction.comp₀]
rw [← cancel_mono (L.map (z₂.s ≫ z₃.s)), map_comp_map_s,
L.map_comp, assoc, map_comp_map_s_assoc, ← L.map_comp, h₃,
L.map_comp, map_comp_map_s_assoc, L.map_comp]
end
end LeftFraction
end
end MorphismProperty
variable (L : C ⥤ D) (W : MorphismProperty C) [L.IsLocalization W]
section
variable [W.HasLeftCalculusOfFractions]
lemma Localization.exists_leftFraction {X Y : C} (f : L.obj X ⟶ L.obj Y) :
∃ (φ : W.LeftFraction X Y), f = φ.map L (Localization.inverts L W) := by
let E := Localization.uniq (MorphismProperty.LeftFraction.Localization.Q W) L W
let e : _ ⋙ E.functor ≅ L := Localization.compUniqFunctor _ _ _
obtain ⟨f', rfl⟩ : ∃ (f' : E.functor.obj X ⟶ E.functor.obj Y),
f = e.inv.app _ ≫ f' ≫ e.hom.app _ := ⟨e.hom.app _ ≫ f ≫ e.inv.app _, by simp⟩
obtain ⟨g, rfl⟩ := E.functor.map_surjective f'
obtain ⟨g, rfl⟩ := MorphismProperty.LeftFraction.Localization.Hom.mk_surjective g
refine ⟨g, ?_⟩
rw [← MorphismProperty.LeftFraction.Localization.homMk_eq_hom_mk,
MorphismProperty.LeftFraction.Localization.homMk_eq g,
g.map_compatibility (MorphismProperty.LeftFraction.Localization.Q W) L,
assoc, assoc, Iso.inv_hom_id_app, comp_id, Iso.inv_hom_id_app_assoc]
lemma MorphismProperty.LeftFraction.map_eq_iff
{X Y : C} (φ ψ : W.LeftFraction X Y) :
φ.map L (Localization.inverts _ _) = ψ.map L (Localization.inverts _ _) ↔
LeftFractionRel φ ψ := by
constructor
· intro h
rw [← MorphismProperty.LeftFraction.Localization.map_eq_iff]
apply map_eq_of_map_eq _ _ _ _ h
· intro h
simp only [← Localization.Hom.map_mk _ L (Localization.inverts _ _)]
congr 1
exact Quot.sound h
lemma MorphismProperty.map_eq_iff_postcomp {X Y : C} (f₁ f₂ : X ⟶ Y) :
L.map f₁ = L.map f₂ ↔ ∃ (Z : C) (s : Y ⟶ Z) (_ : W s), f₁ ≫ s = f₂ ≫ s := by
constructor
· intro h
rw [← LeftFraction.map_ofHom W _ L (Localization.inverts _ _),
← LeftFraction.map_ofHom W _ L (Localization.inverts _ _),
LeftFraction.map_eq_iff] at h
obtain ⟨Z, t₁, t₂, hst, hft, ht⟩ := h
dsimp at t₁ t₂ hst hft ht
grind
· rintro ⟨Z, s, hs, fac⟩
simp only [← cancel_mono (Localization.isoOfHom L W s hs).hom,
Localization.isoOfHom_hom, ← L.map_comp, fac]
include W in
lemma Localization.essSurj_mapArrow :
L.mapArrow.EssSurj where
mem_essImage f := by
have := Localization.essSurj L W
obtain ⟨X, ⟨eX⟩⟩ : ∃ (X : C), Nonempty (L.obj X ≅ f.left) :=
⟨_, ⟨L.objObjPreimageIso f.left⟩⟩
obtain ⟨Y, ⟨eY⟩⟩ : ∃ (Y : C), Nonempty (L.obj Y ≅ f.right) :=
⟨_, ⟨L.objObjPreimageIso f.right⟩⟩
obtain ⟨φ, hφ⟩ := Localization.exists_leftFraction L W (eX.hom ≫ f.hom ≫ eY.inv)
refine ⟨Arrow.mk φ.f, ⟨Iso.symm ?_⟩⟩
refine Arrow.isoMk eX.symm (eY.symm ≪≫ Localization.isoOfHom L W φ.s φ.hs) ?_
dsimp
simp only [← cancel_epi eX.hom, Iso.hom_inv_id_assoc, reassoc_of% hφ,
MorphismProperty.LeftFraction.map_comp_map_s]
end
namespace MorphismProperty
variable {W}
/-- The right fraction in the opposite category corresponding to a left fraction. -/
@[simps]
def LeftFraction.op {X Y : C} (φ : W.LeftFraction X Y) :
W.op.RightFraction (Opposite.op Y) (Opposite.op X) where
X' := Opposite.op φ.Y'
s := φ.s.op
hs := φ.hs
f := φ.f.op
/-- The left fraction in the opposite category corresponding to a right fraction. -/
@[simps]
def RightFraction.op {X Y : C} (φ : W.RightFraction X Y) :
W.op.LeftFraction (Opposite.op Y) (Opposite.op X) where
Y' := Opposite.op φ.X'
s := φ.s.op
hs := φ.hs
f := φ.f.op
/-- The right fraction corresponding to a left fraction in the opposite category. -/
@[simps]
def LeftFraction.unop {W : MorphismProperty Cᵒᵖ}
{X Y : Cᵒᵖ} (φ : W.LeftFraction X Y) :
W.unop.RightFraction (Opposite.unop Y) (Opposite.unop X) where
X' := Opposite.unop φ.Y'
s := φ.s.unop
hs := φ.hs
f := φ.f.unop
/-- The left fraction corresponding to a right fraction in the opposite category. -/
@[simps]
def RightFraction.unop {W : MorphismProperty Cᵒᵖ}
{X Y : Cᵒᵖ} (φ : W.RightFraction X Y) :
W.unop.LeftFraction (Opposite.unop Y) (Opposite.unop X) where
Y' := Opposite.unop φ.X'
s := φ.s.unop
hs := φ.hs
f := φ.f.unop
lemma RightFraction.op_map
{X Y : C} (φ : W.RightFraction X Y) (L : C ⥤ D) (hL : W.IsInvertedBy L) :
(φ.map L hL).op = φ.op.map L.op hL.op := by
dsimp [map, LeftFraction.map]
rw [op_inv]
lemma LeftFraction.op_map
{X Y : C} (φ : W.LeftFraction X Y) (L : C ⥤ D) (hL : W.IsInvertedBy L) :
(φ.map L hL).op = φ.op.map L.op hL.op := by
dsimp [map, RightFraction.map]
rw [op_inv]
instance [h : W.HasLeftCalculusOfFractions] : W.op.HasRightCalculusOfFractions where
exists_rightFraction X Y φ := by
obtain ⟨ψ, eq⟩ := h.exists_leftFraction φ.unop
exact ⟨ψ.op, Quiver.Hom.unop_inj eq⟩
ext X Y Y' f₁ f₂ s hs eq := by
obtain ⟨X', t, ht, fac⟩ := h.ext f₁.unop f₂.unop s.unop hs (Quiver.Hom.op_inj eq)
exact ⟨Opposite.op X', t.op, ht, Quiver.Hom.unop_inj fac⟩
instance [h : W.HasRightCalculusOfFractions] : W.op.HasLeftCalculusOfFractions where
exists_leftFraction X Y φ := by
obtain ⟨ψ, eq⟩ := h.exists_rightFraction φ.unop
exact ⟨ψ.op, Quiver.Hom.unop_inj eq⟩
ext X' X Y f₁ f₂ s hs eq := by
obtain ⟨Y', t, ht, fac⟩ := h.ext f₁.unop f₂.unop s.unop hs (Quiver.Hom.op_inj eq)
exact ⟨Opposite.op Y', t.op, ht, Quiver.Hom.unop_inj fac⟩
instance (W : MorphismProperty Cᵒᵖ) [h : W.HasLeftCalculusOfFractions] :
W.unop.HasRightCalculusOfFractions where
exists_rightFraction X Y φ := by
obtain ⟨ψ, eq⟩ := h.exists_leftFraction φ.op
exact ⟨ψ.unop, Quiver.Hom.op_inj eq⟩
ext X Y Y' f₁ f₂ s hs eq := by
obtain ⟨X', t, ht, fac⟩ := h.ext f₁.op f₂.op s.op hs (Quiver.Hom.unop_inj eq)
exact ⟨Opposite.unop X', t.unop, ht, Quiver.Hom.op_inj fac⟩
instance (W : MorphismProperty Cᵒᵖ) [h : W.HasRightCalculusOfFractions] :
W.unop.HasLeftCalculusOfFractions where
exists_leftFraction X Y φ := by
obtain ⟨ψ, eq⟩ := h.exists_rightFraction φ.op
exact ⟨ψ.unop, Quiver.Hom.op_inj eq⟩
ext X' X Y f₁ f₂ s hs eq := by
obtain ⟨Y', t, ht, fac⟩ := h.ext f₁.op f₂.op s.op hs (Quiver.Hom.unop_inj eq)
exact ⟨Opposite.unop Y', t.unop, ht, Quiver.Hom.op_inj fac⟩
/-- The equivalence relation on right fractions for a morphism property `W`. -/
def RightFractionRel {X Y : C} (z₁ z₂ : W.RightFraction X Y) : Prop :=
∃ (Z : C) (t₁ : Z ⟶ z₁.X') (t₂ : Z ⟶ z₂.X') (_ : t₁ ≫ z₁.s = t₂ ≫ z₂.s)
(_ : t₁ ≫ z₁.f = t₂ ≫ z₂.f), W (t₁ ≫ z₁.s)
lemma RightFractionRel.op {X Y : C} {z₁ z₂ : W.RightFraction X Y}
(h : RightFractionRel z₁ z₂) : LeftFractionRel z₁.op z₂.op := by
obtain ⟨Z, t₁, t₂, hs, hf, ht⟩ := h
exact ⟨Opposite.op Z, t₁.op, t₂.op, Quiver.Hom.unop_inj hs,
Quiver.Hom.unop_inj hf, ht⟩
lemma RightFractionRel.unop {W : MorphismProperty Cᵒᵖ} {X Y : Cᵒᵖ}
{z₁ z₂ : W.RightFraction X Y}
(h : RightFractionRel z₁ z₂) : LeftFractionRel z₁.unop z₂.unop := by
obtain ⟨Z, t₁, t₂, hs, hf, ht⟩ := h
exact ⟨Opposite.unop Z, t₁.unop, t₂.unop, Quiver.Hom.op_inj hs,
Quiver.Hom.op_inj hf, ht⟩
lemma LeftFractionRel.op {X Y : C} {z₁ z₂ : W.LeftFraction X Y}
(h : LeftFractionRel z₁ z₂) : RightFractionRel z₁.op z₂.op := by
obtain ⟨Z, t₁, t₂, hs, hf, ht⟩ := h
exact ⟨Opposite.op Z, t₁.op, t₂.op, Quiver.Hom.unop_inj hs,
Quiver.Hom.unop_inj hf, ht⟩
lemma LeftFractionRel.unop {W : MorphismProperty Cᵒᵖ} {X Y : Cᵒᵖ}
{z₁ z₂ : W.LeftFraction X Y}
(h : LeftFractionRel z₁ z₂) : RightFractionRel z₁.unop z₂.unop := by
obtain ⟨Z, t₁, t₂, hs, hf, ht⟩ := h
exact ⟨Opposite.unop Z, t₁.unop, t₂.unop, Quiver.Hom.op_inj hs,
Quiver.Hom.op_inj hf, ht⟩
lemma leftFractionRel_op_iff
{X Y : C} (z₁ z₂ : W.RightFraction X Y) :
LeftFractionRel z₁.op z₂.op ↔ RightFractionRel z₁ z₂ :=
⟨fun h => h.unop, fun h => h.op⟩
lemma rightFractionRel_op_iff
{X Y : C} (z₁ z₂ : W.LeftFraction X Y) :
RightFractionRel z₁.op z₂.op ↔ LeftFractionRel z₁ z₂ :=
⟨fun h => h.unop, fun h => h.op⟩
namespace RightFractionRel
lemma refl {X Y : C} (z : W.RightFraction X Y) : RightFractionRel z z :=
(LeftFractionRel.refl z.op).unop
lemma symm {X Y : C} {z₁ z₂ : W.RightFraction X Y} (h : RightFractionRel z₁ z₂) :
RightFractionRel z₂ z₁ :=
h.op.symm.unop
lemma trans {X Y : C} {z₁ z₂ z₃ : W.RightFraction X Y}
[HasRightCalculusOfFractions W]
(h₁₂ : RightFractionRel z₁ z₂) (h₂₃ : RightFractionRel z₂ z₃) :
RightFractionRel z₁ z₃ :=
(h₁₂.op.trans h₂₃.op).unop
end RightFractionRel
lemma equivalenceRightFractionRel (X Y : C) [HasRightCalculusOfFractions W] :
@_root_.Equivalence (W.RightFraction X Y) RightFractionRel where
refl := RightFractionRel.refl
symm := RightFractionRel.symm
trans := RightFractionRel.trans
end MorphismProperty
section
variable [W.HasRightCalculusOfFractions]
lemma Localization.exists_rightFraction {X Y : C} (f : L.obj X ⟶ L.obj Y) :
∃ (φ : W.RightFraction X Y), f = φ.map L (Localization.inverts L W) := by
obtain ⟨φ, eq⟩ := Localization.exists_leftFraction L.op W.op f.op
refine ⟨φ.unop, Quiver.Hom.op_inj ?_⟩
rw [eq, MorphismProperty.RightFraction.op_map]
rfl
lemma MorphismProperty.RightFraction.map_eq_iff
{X Y : C} (φ ψ : W.RightFraction X Y) :
φ.map L (Localization.inverts _ _) = ψ.map L (Localization.inverts _ _) ↔
RightFractionRel φ ψ := by
rw [← leftFractionRel_op_iff, ← LeftFraction.map_eq_iff L.op W.op φ.op ψ.op,
← φ.op_map L (Localization.inverts _ _), ← ψ.op_map L (Localization.inverts _ _)]
constructor
· apply Quiver.Hom.unop_inj
· apply Quiver.Hom.op_inj
lemma MorphismProperty.map_eq_iff_precomp {Y Z : C} (f₁ f₂ : Y ⟶ Z) :
L.map f₁ = L.map f₂ ↔ ∃ (X : C) (s : X ⟶ Y) (_ : W s), s ≫ f₁ = s ≫ f₂ := by
constructor
· intro h
rw [← RightFraction.map_ofHom W _ L (Localization.inverts _ _),
← RightFraction.map_ofHom W _ L (Localization.inverts _ _),
RightFraction.map_eq_iff] at h
obtain ⟨Z, t₁, t₂, hst, hft, ht⟩ := h
dsimp at t₁ t₂ hst hft ht
grind
· rintro ⟨Z, s, hs, fac⟩
simp only [← cancel_epi (Localization.isoOfHom L W s hs).hom,
Localization.isoOfHom_hom, ← L.map_comp, fac]
include W in
lemma Localization.essSurj_mapArrow_of_hasRightCalculusOfFractions :
L.mapArrow.EssSurj where
mem_essImage f := by
have := Localization.essSurj_mapArrow L.op W.op
obtain ⟨g, ⟨e⟩⟩ : ∃ (g : _), Nonempty (L.op.mapArrow.obj g ≅ Arrow.mk f.hom.op) :=
⟨_, ⟨Functor.objObjPreimageIso _ _⟩⟩
exact ⟨Arrow.mk g.hom.unop, ⟨Arrow.isoMk (Arrow.rightFunc.mapIso e.symm).unop
(Arrow.leftFunc.mapIso e.symm).unop (Quiver.Hom.op_inj e.inv.w.symm)⟩⟩
end
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Localization/Opposite.lean | import Mathlib.CategoryTheory.Localization.Equivalence
/-!
# Localization of the opposite category
If a functor `L : C ⥤ D` is a localization functor for `W : MorphismProperty C`, it
is shown in this file that `L.op : Cᵒᵖ ⥤ Dᵒᵖ` is also a localization functor.
-/
noncomputable section
open CategoryTheory CategoryTheory.Category
namespace CategoryTheory
variable {C D : Type*} [Category C] [Category D] {L : C ⥤ D} {W : MorphismProperty C}
namespace Localization
/-- If `L : C ⥤ D` satisfies the universal property of the localisation
for `W : MorphismProperty C`, then `L.op` also does. -/
def StrictUniversalPropertyFixedTarget.op {E : Type*} [Category E]
(h : StrictUniversalPropertyFixedTarget L W Eᵒᵖ) :
StrictUniversalPropertyFixedTarget L.op W.op E where
inverts := h.inverts.op
lift F hF := (h.lift F.rightOp hF.rightOp).leftOp
fac F hF := by
convert congr_arg Functor.leftOp (h.fac F.rightOp hF.rightOp)
uniq F₁ F₂ eq := by
suffices F₁.rightOp = F₂.rightOp by
rw [← F₁.rightOp_leftOp_eq, ← F₂.rightOp_leftOp_eq, this]
have eq' := congr_arg Functor.rightOp eq
exact h.uniq _ _ eq'
instance isLocalization_op : W.Q.op.IsLocalization W.op :=
Functor.IsLocalization.mk' W.Q.op W.op (strictUniversalPropertyFixedTargetQ W _).op
(strictUniversalPropertyFixedTargetQ W _).op
end Localization
variable (L W)
variable [L.IsLocalization W]
namespace Functor
instance IsLocalization.op : L.op.IsLocalization W.op :=
IsLocalization.of_equivalence_target W.Q.op W.op L.op (Localization.equivalenceFromModel L W).op
(NatIso.op (Localization.qCompEquivalenceFromModelFunctorIso L W).symm)
instance IsLocalization.unop (L : Cᵒᵖ ⥤ Dᵒᵖ) (W : MorphismProperty Cᵒᵖ)
[L.IsLocalization W] : L.unop.IsLocalization W.unop :=
have : CatCommSq (opOpEquivalence C).functor L.op L.unop
(opOpEquivalence D).functor := ⟨Iso.refl _⟩
of_equivalences L.op W.op L.unop W.unop
(opOpEquivalence C) (opOpEquivalence D)
(fun _ _ _ hf ↦ MorphismProperty.le_isoClosure _ _ hf)
(fun _ _ _ hf ↦ by
have := Localization.inverts L W _ hf
dsimp
infer_instance)
@[simp]
lemma op_iff (L : C ⥤ D) (W : MorphismProperty C) :
L.op.IsLocalization W.op ↔ L.IsLocalization W :=
⟨fun _ ↦ inferInstanceAs (L.op.unop.IsLocalization W.op.unop),
fun _ ↦ inferInstance⟩
end Functor
namespace Localization
lemma isoOfHom_unop {X Y : Cᵒᵖ} (w : X ⟶ Y) (hw : W.op w) :
(isoOfHom L.op W.op w hw).unop = (isoOfHom L W w.unop hw) := by ext; rfl
lemma isoOfHom_op_inv {X Y : Cᵒᵖ} (w : X ⟶ Y) (hw : W.op w) :
(isoOfHom L.op W.op w hw).inv = (isoOfHom L W w.unop hw).inv.op :=
congr_arg Quiver.Hom.op (congr_arg Iso.inv (isoOfHom_unop L W w hw))
end Localization
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Localization/LocallySmall.lean | import Mathlib.CategoryTheory.Localization.HasLocalization
import Mathlib.CategoryTheory.EssentiallySmall
/-!
# Locally small localizations
In this file, given `W : MorphismProperty C` and a universe `w`, we show
that there exists a term in `HasLocalization.{w} W` if and only if
there exists (or for all) localization functors `L : C ⥤ D` for `W`,
the category `D` is locally `w`-small.
-/
universe w v₁ v₂ u₁ u₂
open CategoryTheory.Functor
namespace CategoryTheory.MorphismProperty
variable {C : Type u₁} [Category.{v₁} C] (W : MorphismProperty C)
/-- If `L : C ⥤ D` is a localization functor for a class of morphisms
`W : MorphismProperty C`, and `D` is locally `w`-small, we may obtain
a `HasLocalization.{w} W` instance by shrinking the morphisms in `D`.
(This version assumes that the types of objects of the categories
`C` and `D` are in the same universe.) -/
noncomputable def hasLocalizationOfLocallySmall
{D : Type u₁} [Category.{v₂} D] [LocallySmall.{w} D]
(L : C ⥤ D) [L.IsLocalization W] :
HasLocalization.{w} W where
D := ShrinkHoms D
L := L ⋙ (ShrinkHoms.equivalence D).functor
/-- If `L : C ⥤ D` is a localization functor for a class of morphisms
`W : MorphismProperty C`, and `D` is locally `w`-small, we may obtain
a `HasLocalization.{w} W` instance. This should be used only in the
unlikely situation where the types of objects of `C` and `D` are in
different universes. Otherwise, use `hasLocalizationOfLocallySmall`. -/
noncomputable irreducible_def hasLocalizationOfLocallySmall'
{D : Type u₂} [Category.{v₂} D] [LocallySmall.{w} D]
(L : C ⥤ D) [L.IsLocalization W] :
HasLocalization.{w} W := by
have : LocallySmall.{w} (InducedCategory _ L.obj) :=
⟨fun X Y ↦ inferInstanceAs (Small.{w} (L.obj X ⟶ L.obj Y))⟩
let L' : C ⥤ (InducedCategory _ L.obj) :=
{ obj X := X
map f := L.map f }
have := Localization.essSurj L W
have : (inducedFunctor L.obj).EssSurj := ⟨fun Y ↦ ⟨_, ⟨L.objObjPreimageIso Y⟩⟩⟩
have : (inducedFunctor L.obj).IsEquivalence := { }
let e := (inducedFunctor L.obj).asEquivalence
let e' : (L' ⋙ e.functor) ⋙ e.inverse ≅ L' :=
associator _ _ _ ≪≫ isoWhiskerLeft L' e.unitIso.symm ≪≫ L'.rightUnitor
have : L'.IsLocalization W :=
Functor.IsLocalization.of_iso W (L₁ := L ⋙ e.inverse) e'
exact hasLocalizationOfLocallySmall.{w} W L'
/-- If a class of morphisms `W : MorphismProperty C` satisfies `HasLocalization.{w} W`,
then any localized category for `W` (i.e. any target of a localization functor
`L : C ⥤ D` for `W`) is locally `w`-small. -/
lemma locallySmall_of_hasLocalization {D : Type u₂} [Category.{v₂} D]
(L : C ⥤ D) [L.IsLocalization W] [HasLocalization.{w} W] :
LocallySmall.{w} D where
hom_small _ _ := small_of_injective (fun _ _ h ↦
(Localization.uniq L W.Q' W).functor.map_injective h)
end CategoryTheory.MorphismProperty |
.lake/packages/mathlib/Mathlib/CategoryTheory/Localization/Monoidal.lean | import Mathlib.CategoryTheory.Localization.Monoidal.Basic
deprecated_module (since := "2025-10-20") |
.lake/packages/mathlib/Mathlib/CategoryTheory/Localization/BousfieldTransfiniteComposition.lean | import Mathlib.CategoryTheory.Localization.Bousfield
import Mathlib.CategoryTheory.MorphismProperty.TransfiniteComposition
import Mathlib.CategoryTheory.SmallObject.WellOrderInductionData
/-!
# LeftBousfield.W is stable under transfinite compositions
If `P : ObjectProperty C`, then `Localization.LeftBousfield.W P : MorphismProperty C`
is stable under transfinite compositions.
-/
universe w v u
namespace CategoryTheory
open Limits Opposite
variable {C : Type u} [Category.{v} C]
namespace Localization.LeftBousfield
variable (P : ObjectProperty C)
instance (J : Type w) [LinearOrder J] [SuccOrder J] [OrderBot J] [WellFoundedLT J] :
(W P).IsStableUnderTransfiniteCompositionOfShape J where
le := fun X Y f ⟨hf⟩ Z hZ ↦ by
refine ⟨fun g₁ g₂ h ↦ hf.isColimit.hom_ext (fun j ↦ ?_), fun g ↦ ?_⟩
· dsimp at h ⊢
induction j using SuccOrder.limitRecOn with
| isMin j hj =>
obtain rfl := hj.eq_bot
simpa [← cancel_epi hf.isoBot.inv]
| succ j hj hj' => exact (hf.map_mem j hj _ hZ).1 (by simpa)
| isSuccLimit j hj hj' =>
exact (hf.F.isColimitOfIsWellOrderContinuous j hj).hom_ext
(fun ⟨k, hk⟩ ↦ by simpa using hj' _ hk)
· let d : (hf.F.op ⋙ yoneda.obj Z).WellOrderInductionData :=
.ofExists (fun j hj ↦ (hf.map_mem j hj _ hZ).2) (fun j hj s ↦ by
let c : Cocone ((Set.principalSegIio j).monotone.functor ⋙ hf.F) :=
{ pt := Z
ι.app k := s.1 (op k)
ι.naturality _ _ g := by
dsimp
simpa only [Category.comp_id] using s.2 g.op }
exact ⟨(hf.F.isColimitOfIsWellOrderContinuous j hj).desc c, fun k hk ↦
by simpa using (hf.F.isColimitOfIsWellOrderContinuous j hj).fac c ⟨k, hk⟩⟩)
let σ := d.sectionsMk (hf.isoBot.hom ≫ g)
let c : Cocone hf.F :=
{ pt := Z
ι.app j := σ.1 (op j)
ι.naturality _ _ f := by
dsimp
simpa only [Category.comp_id] using σ.2 f.op }
exact ⟨hf.isColimit.desc c, by
simp only [← hf.fac, Category.assoc, hf.isColimit.fac c ⊥, c, σ,
d.sectionsMk_val_op_bot, Iso.inv_hom_id_assoc]⟩
instance : MorphismProperty.IsStableUnderTransfiniteComposition.{w} (W P) where
end Localization.LeftBousfield
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Localization/Construction.lean | import Mathlib.CategoryTheory.MorphismProperty.Composition
import Mathlib.CategoryTheory.MorphismProperty.IsInvertedBy
import Mathlib.CategoryTheory.Category.Quiv
/-!
# Construction of the localized category
This file constructs the localized category, obtained by formally inverting
a class of maps `W : MorphismProperty C` in a category `C`.
We first construct a quiver `LocQuiver W` whose objects are the same as those
of `C` and whose maps are the maps in `C` and placeholders for the formal
inverses of the maps in `W`.
The localized category `W.Localization` is obtained by taking the quotient
of the path category of `LocQuiver W` by the congruence generated by four
types of relations.
The obvious functor `Q W : C ⥤ W.Localization` satisfies the universal property
of the localization. Indeed, if `G : C ⥤ D` sends morphisms in `W` to isomorphisms
in `D` (i.e. we have `hG : W.IsInvertedBy G`), then there exists a unique functor
`G' : W.Localization ⥤ D` such that `Q W ≫ G' = G`. This `G'` is `lift G hG`.
The expected property of `lift G hG` if expressed by the lemma `fac` and the
uniqueness is expressed by `uniq`.
## References
* [P. Gabriel, M. Zisman, *Calculus of fractions and homotopy theory*][gabriel-zisman-1967]
-/
noncomputable section
open CategoryTheory.Category CategoryTheory.Functor
namespace CategoryTheory
-- category universes first for convenience
universe uC' uD' uC uD
variable {C : Type uC} [Category.{uC'} C] (W : MorphismProperty C) {D : Type uD} [Category.{uD'} D]
namespace Localization
namespace Construction
/-- If `W : MorphismProperty C`, `LocQuiver W` is a quiver with the same objects
as `C`, and whose morphisms are those in `C` and placeholders for formal
inverses of the morphisms in `W`. -/
structure LocQuiver (W : MorphismProperty C) where
/-- underlying object -/
obj : C
instance : Quiver (LocQuiver W) where Hom A B := (A.obj ⟶ B.obj) ⊕ { f : B.obj ⟶ A.obj // W f }
/-- The object in the path category of `LocQuiver W` attached to an object in
the category `C` -/
def ιPaths (X : C) : Paths (LocQuiver W) :=
⟨X⟩
/-- The morphism in the path category associated to a morphism in the original category. -/
@[simp]
def ψ₁ {X Y : C} (f : X ⟶ Y) : ιPaths W X ⟶ ιPaths W Y := (Paths.of _).map (Sum.inl f)
/-- The morphism in the path category corresponding to a formal inverse. -/
@[simp]
def ψ₂ {X Y : C} (w : X ⟶ Y) (hw : W w) : ιPaths W Y ⟶ ιPaths W X :=
(Paths.of _).map (Sum.inr ⟨w, hw⟩)
/-- The relations by which we take the quotient in order to get the localized category. -/
inductive relations : HomRel (Paths (LocQuiver W))
| id (X : C) : relations (ψ₁ W (𝟙 X)) (𝟙 _)
| comp {X Y Z : C} (f : X ⟶ Y) (g : Y ⟶ Z) : relations (ψ₁ W (f ≫ g)) (ψ₁ W f ≫ ψ₁ W g)
| Winv₁ {X Y : C} (w : X ⟶ Y) (hw : W w) : relations (ψ₁ W w ≫ ψ₂ W w hw) (𝟙 _)
| Winv₂ {X Y : C} (w : X ⟶ Y) (hw : W w) : relations (ψ₂ W w hw ≫ ψ₁ W w) (𝟙 _)
end Construction
end Localization
namespace MorphismProperty
open Localization.Construction
/-- The localized category obtained by formally inverting the morphisms
in `W : MorphismProperty C` -/
def Localization :=
CategoryTheory.Quotient (Localization.Construction.relations W)
instance : Category (Localization W) := by
dsimp only [Localization]
infer_instance
/-- The obvious functor `C ⥤ W.Localization` -/
def Q : C ⥤ W.Localization where
obj X := (Quotient.functor _).obj ((Paths.of _).obj ⟨X⟩)
map f := (Quotient.functor _).map (ψ₁ W f)
map_id X := Quotient.sound _ (relations.id X)
map_comp f g := Quotient.sound _ (relations.comp f g)
end MorphismProperty
namespace Localization
namespace Construction
variable {W}
/-- The isomorphism in `W.Localization` associated to a morphism `w` in W -/
def wIso {X Y : C} (w : X ⟶ Y) (hw : W w) : Iso (W.Q.obj X) (W.Q.obj Y) where
hom := W.Q.map w
inv := (Quotient.functor _).map (by dsimp; exact (Paths.of _).map (Sum.inr ⟨w, hw⟩))
hom_inv_id := Quotient.sound _ (relations.Winv₁ w hw)
inv_hom_id := Quotient.sound _ (relations.Winv₂ w hw)
/-- The formal inverse in `W.Localization` of a morphism `w` in `W`. -/
abbrev wInv {X Y : C} (w : X ⟶ Y) (hw : W w) :=
(wIso w hw).inv
variable (W) in
theorem _root_.CategoryTheory.MorphismProperty.Q_inverts : W.IsInvertedBy W.Q := fun _ _ w hw =>
(Localization.Construction.wIso w hw).isIso_hom
variable (G : C ⥤ D) (hG : W.IsInvertedBy G)
/-- The lifting of a functor to the path category of `LocQuiver W` -/
@[simps!]
def liftToPathCategory : Paths (LocQuiver W) ⥤ D :=
Quiv.lift
{ obj := fun X => G.obj X.obj
map := by
intro X Y
rintro (f | ⟨g, hg⟩)
· exact G.map f
· haveI := hG g hg
exact inv (G.map g) }
/-- The lifting of a functor `C ⥤ D` inverting `W` as a functor `W.Localization ⥤ D` -/
@[simps!]
def lift : W.Localization ⥤ D :=
Quotient.lift (relations W) (liftToPathCategory G hG)
(by
rintro ⟨X⟩ ⟨Y⟩ f₁ f₂ r
rcases r with ⟨⟩ <;> all_goals aesop)
@[simp]
theorem fac : W.Q ⋙ lift G hG = G :=
Functor.ext (fun _ => rfl)
(by
intro X Y f
simp only [Functor.comp_map, eqToHom_refl, comp_id, id_comp]
dsimp [MorphismProperty.Q, Quot.liftOn, Quotient.functor]
rw [composePath_toPath])
theorem uniq (G₁ G₂ : W.Localization ⥤ D) (h : W.Q ⋙ G₁ = W.Q ⋙ G₂) : G₁ = G₂ := by
suffices h' : Quotient.functor _ ⋙ G₁ = Quotient.functor _ ⋙ G₂ by
refine Functor.ext ?_ ?_
· rintro ⟨⟨X⟩⟩
apply Functor.congr_obj h
· rintro ⟨⟨X⟩⟩ ⟨⟨Y⟩⟩ ⟨f⟩
apply Functor.congr_hom h'
refine Paths.ext_functor ?_ ?_
· ext X
cases X
apply Functor.congr_obj h
· rintro ⟨X⟩ ⟨Y⟩ (f | ⟨w, hw⟩)
· simpa only using Functor.congr_hom h f
· have hw : W.Q.map w = (wIso w hw).hom := rfl
have hw' := Functor.congr_hom h w
simp only [Functor.comp_map, hw] at hw'
refine Functor.congr_inv_of_congr_hom _ _ _ ?_ ?_ hw'
all_goals apply Functor.congr_obj h
variable (W) in
/-- The canonical bijection between objects in a category and its
localization with respect to a morphism_property `W` -/
@[simps]
def objEquiv : C ≃ W.Localization where
toFun := W.Q.obj
invFun X := X.as.obj
right_inv := by
rintro ⟨⟨X⟩⟩
rfl
/-- A `MorphismProperty` in `W.Localization` is satisfied by all
morphisms in the localized category if it contains the image of the
morphisms in the original category, the inverses of the morphisms
in `W` and if it is stable under composition -/
theorem morphismProperty_eq_top (P : MorphismProperty W.Localization)
[P.IsStableUnderComposition] (hP₁ : ∀ ⦃X Y : C⦄ (f : X ⟶ Y), P (W.Q.map f))
(hP₂ : ∀ ⦃X Y : C⦄ (w : X ⟶ Y) (hw : W w), P (wInv w hw)) :
P = ⊤ := by
funext X Y f
ext
constructor
· intro
apply MorphismProperty.top_apply
· intro
let G : _ ⥤ W.Localization := Quotient.functor _
haveI : G.Full := Quotient.full_functor _
suffices ∀ (X₁ X₂ : Paths (LocQuiver W)) (f : X₁ ⟶ X₂), P (G.map f) by
rcases X with ⟨⟨X⟩⟩
rcases Y with ⟨⟨Y⟩⟩
simpa only [Functor.map_preimage] using this _ _ (G.preimage f)
intro X₁ X₂ p
induction p with
| nil => simpa only [Functor.map_id] using hP₁ (𝟙 X₁.obj)
| @cons X₂ X₃ p g hp =>
let p' : X₁ ⟶X₂ := p
rw [show p'.cons g = p' ≫ Quiver.Hom.toPath g by rfl, G.map_comp]
refine P.comp_mem _ _ hp ?_
rcases g with (g | ⟨g, hg⟩)
· apply hP₁
· apply hP₂
@[deprecated (since := "2025-10-21")] alias morphismProperty_is_top := morphismProperty_eq_top
/-- A `MorphismProperty` in `W.Localization` is satisfied by all
morphisms in the localized category if it contains the image of the
morphisms in the original category, if is stable under composition
and if the property is stable by passing to inverses. -/
theorem morphismProperty_eq_top' (P : MorphismProperty W.Localization)
[P.IsStableUnderComposition] (hP₁ : ∀ ⦃X Y : C⦄ (f : X ⟶ Y), P (W.Q.map f))
(hP₂ : ∀ ⦃X Y : W.Localization⦄ (e : X ≅ Y) (_ : P e.hom), P e.inv) : P = ⊤ :=
morphismProperty_eq_top P hP₁ (fun _ _ w _ => hP₂ _ (hP₁ w))
@[deprecated (since := "2025-10-21")] alias morphismProperty_is_top' := morphismProperty_eq_top'
namespace NatTransExtension
variable {F₁ F₂ : W.Localization ⥤ D} (τ : W.Q ⋙ F₁ ⟶ W.Q ⋙ F₂)
/-- If `F₁` and `F₂` are functors `W.Localization ⥤ D` and if we have
`τ : W.Q ⋙ F₁ ⟶ W.Q ⋙ F₂`, we shall define a natural transformation `F₁ ⟶ F₂`.
This is the `app` field of this natural transformation. -/
def app (X : W.Localization) : F₁.obj X ⟶ F₂.obj X :=
eqToHom (congr_arg F₁.obj ((objEquiv W).right_inv X).symm) ≫
τ.app ((objEquiv W).invFun X) ≫ eqToHom (congr_arg F₂.obj ((objEquiv W).right_inv X))
@[simp]
theorem app_eq (X : C) : (app τ) (W.Q.obj X) = τ.app X := by
simp only [app, eqToHom_refl, comp_id, id_comp]
rfl
end NatTransExtension
/-- If `F₁` and `F₂` are functors `W.Localization ⥤ D`, a natural transformation `F₁ ⟶ F₂`
can be obtained from a natural transformation `W.Q ⋙ F₁ ⟶ W.Q ⋙ F₂`. -/
@[simps]
def natTransExtension {F₁ F₂ : W.Localization ⥤ D} (τ : W.Q ⋙ F₁ ⟶ W.Q ⋙ F₂) : F₁ ⟶ F₂ where
app := NatTransExtension.app τ
naturality := by
suffices MorphismProperty.naturalityProperty (NatTransExtension.app τ) = ⊤ by
intro X Y f
simpa only [← this] using MorphismProperty.top_apply f
refine morphismProperty_eq_top'
(MorphismProperty.naturalityProperty (NatTransExtension.app τ))
?_ (MorphismProperty.naturalityProperty.stableUnderInverse _)
intro X Y f
dsimp
simpa only [NatTransExtension.app_eq] using τ.naturality f
@[simp]
theorem whiskerLeft_natTransExtension {F G : W.Localization ⥤ D} (τ : W.Q ⋙ F ⟶ W.Q ⋙ G) :
whiskerLeft W.Q (natTransExtension τ) = τ := by cat_disch
-- This is not a simp lemma, because the simp norm form of the left-hand side uses `whiskerLeft`.
theorem natTransExtension_hcomp {F G : W.Localization ⥤ D} (τ : W.Q ⋙ F ⟶ W.Q ⋙ G) :
𝟙 W.Q ◫ natTransExtension τ = τ := by simp
theorem natTrans_hcomp_injective {F G : W.Localization ⥤ D} {τ₁ τ₂ : F ⟶ G}
(h : 𝟙 W.Q ◫ τ₁ = 𝟙 W.Q ◫ τ₂) : τ₁ = τ₂ := by
ext X
have eq := (objEquiv W).right_inv X
simp only [objEquiv] at eq
rw [← eq, ← NatTrans.id_hcomp_app, ← NatTrans.id_hcomp_app, h]
variable (W D)
namespace WhiskeringLeftEquivalence
/-- The functor `(W.Localization ⥤ D) ⥤ (W.FunctorsInverting D)` induced by the
composition with `W.Q : C ⥤ W.Localization`. -/
@[simps!]
def functor : (W.Localization ⥤ D) ⥤ W.FunctorsInverting D :=
ObjectProperty.lift _ ((whiskeringLeft _ _ D).obj W.Q) fun _ =>
MorphismProperty.IsInvertedBy.of_comp W W.Q W.Q_inverts _
/-- The function `(W.FunctorsInverting D) ⥤ (W.Localization ⥤ D)` induced by
`Construction.lift`. -/
@[simps!]
def inverse : W.FunctorsInverting D ⥤ W.Localization ⥤ D where
obj G := lift G.obj G.property
map τ := natTransExtension (eqToHom (by rw [fac]) ≫ τ ≫ eqToHom (by rw [fac]))
map_id G :=
natTrans_hcomp_injective
(by
rw [natTransExtension_hcomp]
ext X
simp only [NatTrans.comp_app, eqToHom_app, eqToHom_refl, comp_id, id_comp,
NatTrans.hcomp_id_app, NatTrans.id_app, Functor.map_id]
rfl)
map_comp τ₁ τ₂ :=
natTrans_hcomp_injective
(by
ext X
simp only [natTransExtension_hcomp, NatTrans.comp_app, eqToHom_app, eqToHom_refl,
id_comp, comp_id, NatTrans.hcomp_app, NatTrans.id_app, Functor.map_id,
natTransExtension_app, NatTransExtension.app_eq]
rfl)
/-- The unit isomorphism of the equivalence of categories `whiskeringLeftEquivalence W D`. -/
@[simps!]
def unitIso : 𝟭 (W.Localization ⥤ D) ≅ functor W D ⋙ inverse W D :=
eqToIso
(by
refine Functor.ext (fun G => ?_) fun G₁ G₂ τ => ?_
· apply uniq
dsimp [Functor]
erw [fac]
rfl
· apply natTrans_hcomp_injective
ext X
simp)
/-- The counit isomorphism of the equivalence of categories `WhiskeringLeftEquivalence W D`. -/
@[simps!]
def counitIso : inverse W D ⋙ functor W D ≅ 𝟭 (W.FunctorsInverting D) :=
eqToIso
(by
refine Functor.ext ?_ ?_
· rintro ⟨G, hG⟩
ext
exact fac G hG
· rintro ⟨G₁, hG₁⟩ ⟨G₂, hG₂⟩ f
ext
apply NatTransExtension.app_eq)
end WhiskeringLeftEquivalence
/-- The equivalence of categories `(W.localization ⥤ D) ≌ (W.FunctorsInverting D)`
induced by the composition with `W.Q : C ⥤ W.localization`. -/
def whiskeringLeftEquivalence : W.Localization ⥤ D ≌ W.FunctorsInverting D where
functor := WhiskeringLeftEquivalence.functor W D
inverse := WhiskeringLeftEquivalence.inverse W D
unitIso := WhiskeringLeftEquivalence.unitIso W D
counitIso := WhiskeringLeftEquivalence.counitIso W D
functor_unitIso_comp F := by
ext
simp only [WhiskeringLeftEquivalence.unitIso_hom, eqToHom_app, eqToHom_refl,
WhiskeringLeftEquivalence.counitIso_hom, eqToHom_map, eqToHom_trans]
rfl
end Construction
end Localization
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Localization/Triangulated.lean | import Mathlib.CategoryTheory.Localization.CalculusOfFractions.ComposableArrows
import Mathlib.CategoryTheory.Localization.CalculusOfFractions.Preadditive
import Mathlib.CategoryTheory.Triangulated.Functor
import Mathlib.CategoryTheory.Shift.Localization
/-! # Localization of triangulated categories
If `L : C ⥤ D` is a localization functor for a class of morphisms `W` that is compatible
with the triangulation on the category `C` and admits a left calculus of fractions,
it is shown in this file that `D` can be equipped with a pretriangulated category structure,
and that it is triangulated.
## References
* [Jean-Louis Verdier, *Des catégories dérivées des catégories abéliennes*][verdier1996]
-/
assert_not_exists TwoSidedIdeal
namespace CategoryTheory
open Category Limits Pretriangulated Localization
variable {C D : Type*} [Category C] [Category D] (L : C ⥤ D)
[HasShift C ℤ] [Preadditive C] [HasZeroObject C]
[∀ (n : ℤ), (shiftFunctor C n).Additive] [Pretriangulated C]
[HasShift D ℤ] [L.CommShift ℤ]
namespace MorphismProperty
/-- Given `W` is a class of morphisms in a pretriangulated category `C`, this is the condition
that `W` is compatible with the triangulation on `C`. -/
class IsCompatibleWithTriangulation (W : MorphismProperty C) : Prop
extends W.IsCompatibleWithShift ℤ where
compatible_with_triangulation (T₁ T₂ : Triangle C)
(_ : T₁ ∈ distTriang C) (_ : T₂ ∈ distTriang C)
(a : T₁.obj₁ ⟶ T₂.obj₁) (b : T₁.obj₂ ⟶ T₂.obj₂) (_ : W a) (_ : W b)
(_ : T₁.mor₁ ≫ b = a ≫ T₂.mor₁) :
∃ (c : T₁.obj₃ ⟶ T₂.obj₃) (_ : W c),
(T₁.mor₂ ≫ c = b ≫ T₂.mor₂) ∧ (T₁.mor₃ ≫ a⟦1⟧' = c ≫ T₂.mor₃)
export IsCompatibleWithTriangulation (compatible_with_triangulation)
end MorphismProperty
namespace Functor
/-- Given a functor `C ⥤ D` from a pretriangulated category, this is the set of
triangles in `D` that are in the essential image of distinguished triangles of `C`. -/
def essImageDistTriang : Set (Triangle D) :=
fun T => ∃ (T' : Triangle C) (_ : T ≅ L.mapTriangle.obj T'), T' ∈ distTriang C
lemma essImageDistTriang_mem_of_iso {T₁ T₂ : Triangle D} (e : T₂ ≅ T₁)
(h : T₁ ∈ L.essImageDistTriang) : T₂ ∈ L.essImageDistTriang := by
obtain ⟨T', e', hT'⟩ := h
exact ⟨T', e ≪≫ e', hT'⟩
lemma contractible_mem_essImageDistTriang [EssSurj L] [HasZeroObject D]
[HasZeroMorphisms D] [L.PreservesZeroMorphisms] (X : D) :
contractibleTriangle X ∈ L.essImageDistTriang := by
refine ⟨contractibleTriangle (L.objPreimage X), ?_, contractible_distinguished _⟩
exact ((contractibleTriangleFunctor D).mapIso (L.objObjPreimageIso X)).symm ≪≫
Triangle.isoMk _ _ (Iso.refl _) (Iso.refl _) L.mapZeroObject.symm (by simp) (by simp) (by simp)
lemma rotate_essImageDistTriang [Preadditive D] [L.Additive]
[∀ (n : ℤ), (shiftFunctor D n).Additive] (T : Triangle D) :
T ∈ L.essImageDistTriang ↔ T.rotate ∈ L.essImageDistTriang := by
constructor
· rintro ⟨T', e', hT'⟩
exact ⟨T'.rotate, (rotate D).mapIso e' ≪≫ L.mapTriangleRotateIso.app T',
rot_of_distTriang T' hT'⟩
· rintro ⟨T', e', hT'⟩
exact ⟨T'.invRotate, (triangleRotation D).unitIso.app T ≪≫ (invRotate D).mapIso e' ≪≫
L.mapTriangleInvRotateIso.app T', inv_rot_of_distTriang T' hT'⟩
lemma complete_distinguished_essImageDistTriang_morphism
(H : ∀ (T₁' T₂' : Triangle C) (_ : T₁' ∈ distTriang C) (_ : T₂' ∈ distTriang C)
(a : L.obj (T₁'.obj₁) ⟶ L.obj (T₂'.obj₁)) (b : L.obj (T₁'.obj₂) ⟶ L.obj (T₂'.obj₂))
(_ : L.map T₁'.mor₁ ≫ b = a ≫ L.map T₂'.mor₁),
∃ (φ : L.mapTriangle.obj T₁' ⟶ L.mapTriangle.obj T₂'), φ.hom₁ = a ∧ φ.hom₂ = b)
(T₁ T₂ : Triangle D)
(hT₁ : T₁ ∈ Functor.essImageDistTriang L) (hT₂ : T₂ ∈ L.essImageDistTriang)
(a : T₁.obj₁ ⟶ T₂.obj₁) (b : T₁.obj₂ ⟶ T₂.obj₂) (fac : T₁.mor₁ ≫ b = a ≫ T₂.mor₁) :
∃ c, T₁.mor₂ ≫ c = b ≫ T₂.mor₂ ∧ T₁.mor₃ ≫ a⟦1⟧' = c ≫ T₂.mor₃ := by
obtain ⟨T₁', e₁, hT₁'⟩ := hT₁
obtain ⟨T₂', e₂, hT₂'⟩ := hT₂
have comm₁ := e₁.inv.comm₁
have comm₁' := e₂.hom.comm₁
have comm₂ := e₁.hom.comm₂
have comm₂' := e₂.hom.comm₂
have comm₃ := e₁.inv.comm₃
have comm₃' := e₂.hom.comm₃
dsimp at comm₁ comm₁' comm₂ comm₂' comm₃ comm₃'
simp only [assoc] at comm₃
obtain ⟨φ, hφ₁, hφ₂⟩ := H T₁' T₂' hT₁' hT₂' (e₁.inv.hom₁ ≫ a ≫ e₂.hom.hom₁)
(e₁.inv.hom₂ ≫ b ≫ e₂.hom.hom₂)
(by simp only [assoc, ← comm₁', ← reassoc_of% fac, ← reassoc_of% comm₁])
have h₂ := φ.comm₂
have h₃ := φ.comm₃
dsimp at h₂ h₃
simp only [assoc] at h₃
refine ⟨e₁.hom.hom₃ ≫ φ.hom₃ ≫ e₂.inv.hom₃, ?_, ?_⟩
· rw [reassoc_of% comm₂, reassoc_of% h₂, hφ₂, assoc, assoc,
Iso.hom_inv_id_triangle_hom₂_assoc, ← reassoc_of% comm₂',
Iso.hom_inv_id_triangle_hom₃, comp_id]
· rw [assoc, assoc, ← cancel_epi e₁.inv.hom₃, ← reassoc_of% comm₃,
Iso.inv_hom_id_triangle_hom₃_assoc, ← cancel_mono (e₂.hom.hom₁⟦(1 : ℤ)⟧'),
assoc, assoc, assoc, assoc, assoc, ← Functor.map_comp, ← Functor.map_comp, ← hφ₁,
h₃, comm₃', Iso.inv_hom_id_triangle_hom₃_assoc]
end Functor
namespace Triangulated
namespace Localization
variable (W : MorphismProperty C) [L.IsLocalization W]
[W.HasLeftCalculusOfFractions]
include W in
lemma distinguished_cocone_triangle {X Y : D} (f : X ⟶ Y) :
∃ (Z : D) (g : Y ⟶ Z) (h : Z ⟶ X⟦(1 : ℤ)⟧),
Triangle.mk f g h ∈ L.essImageDistTriang := by
have := essSurj_mapArrow L W
obtain ⟨φ, ⟨e⟩⟩ : ∃ (φ : Arrow C), Nonempty (L.mapArrow.obj φ ≅ Arrow.mk f) :=
⟨_, ⟨Functor.objObjPreimageIso _ _⟩⟩
obtain ⟨Z, g, h, H⟩ := Pretriangulated.distinguished_cocone_triangle φ.hom
refine ⟨L.obj Z, e.inv.right ≫ L.map g,
L.map h ≫ (L.commShiftIso (1 : ℤ)).hom.app _ ≫ e.hom.left⟦(1 : ℤ)⟧', _, ?_, H⟩
refine Triangle.isoMk _ _ (Arrow.leftFunc.mapIso e.symm) (Arrow.rightFunc.mapIso e.symm)
(Iso.refl _) e.inv.w.symm (by simp) ?_
dsimp
simp only [assoc, id_comp, ← Functor.map_comp, ← Arrow.comp_left, e.hom_inv_id, Arrow.id_left,
Functor.mapArrow_obj, Arrow.mk_left, Functor.map_id, comp_id]
section
variable [W.IsCompatibleWithTriangulation]
include W in
lemma complete_distinguished_triangle_morphism (T₁ T₂ : Triangle D)
(hT₁ : T₁ ∈ L.essImageDistTriang) (hT₂ : T₂ ∈ L.essImageDistTriang)
(a : T₁.obj₁ ⟶ T₂.obj₁) (b : T₁.obj₂ ⟶ T₂.obj₂) (fac : T₁.mor₁ ≫ b = a ≫ T₂.mor₁) :
∃ c, T₁.mor₂ ≫ c = b ≫ T₂.mor₂ ∧ T₁.mor₃ ≫ a⟦1⟧' = c ≫ T₂.mor₃ := by
refine L.complete_distinguished_essImageDistTriang_morphism ?_ T₁ T₂ hT₁ hT₂ a b fac
clear a b fac hT₁ hT₂ T₁ T₂
intro T₁ T₂ hT₁ hT₂ a b fac
obtain ⟨α, hα⟩ := exists_leftFraction L W a
obtain ⟨β, hβ⟩ := (MorphismProperty.RightFraction.mk α.s α.hs T₂.mor₁).exists_leftFraction
obtain ⟨γ, hγ⟩ := exists_leftFraction L W (b ≫ L.map β.s)
have := inverts L W β.s β.hs
have := inverts L W γ.s γ.hs
dsimp at hβ
obtain ⟨Z₂, σ, hσ, fac⟩ := (MorphismProperty.map_eq_iff_postcomp L W
(α.f ≫ β.f ≫ γ.s) (T₁.mor₁ ≫ γ.f)).1 (by
rw [← cancel_mono (L.map β.s), assoc, assoc, hγ, ← cancel_mono (L.map γ.s),
assoc, assoc, assoc, hα, MorphismProperty.LeftFraction.map_comp_map_s,
← Functor.map_comp] at fac
rw [fac, ← Functor.map_comp_assoc, hβ, Functor.map_comp, Functor.map_comp,
Functor.map_comp, assoc, MorphismProperty.LeftFraction.map_comp_map_s_assoc])
simp only [assoc] at fac
obtain ⟨Y₃, g, h, hT₃⟩ := Pretriangulated.distinguished_cocone_triangle (β.f ≫ γ.s ≫ σ)
let T₃ := Triangle.mk (β.f ≫ γ.s ≫ σ) g h
change T₃ ∈ distTriang C at hT₃
have hβγσ : W (β.s ≫ γ.s ≫ σ) := W.comp_mem _ _ β.hs (W.comp_mem _ _ γ.hs hσ)
obtain ⟨ψ₃, hψ₃, hψ₁, hψ₂⟩ := MorphismProperty.compatible_with_triangulation
T₂ T₃ hT₂ hT₃ α.s (β.s ≫ γ.s ≫ σ) α.hs hβγσ (by dsimp [T₃]; rw [reassoc_of% hβ])
let ψ : T₂ ⟶ T₃ := Triangle.homMk _ _ α.s (β.s ≫ γ.s ≫ σ) ψ₃
(by dsimp [T₃]; rw [reassoc_of% hβ]) hψ₁ hψ₂
have : IsIso (L.mapTriangle.map ψ) := Triangle.isIso_of_isIsos _
(inverts L W α.s α.hs) (inverts L W _ hβγσ) (inverts L W ψ₃ hψ₃)
refine ⟨L.mapTriangle.map (completeDistinguishedTriangleMorphism T₁ T₃ hT₁ hT₃ α.f
(γ.f ≫ σ) fac.symm) ≫ inv (L.mapTriangle.map ψ), ?_, ?_⟩
· rw [← cancel_mono (L.mapTriangle.map ψ).hom₁, ← comp_hom₁, assoc, IsIso.inv_hom_id, comp_id]
dsimp [ψ]
rw [hα, MorphismProperty.LeftFraction.map_comp_map_s]
· rw [← cancel_mono (L.mapTriangle.map ψ).hom₂, ← comp_hom₂, assoc, IsIso.inv_hom_id, comp_id]
dsimp [ψ]
simp only [Functor.map_comp, reassoc_of% hγ,
MorphismProperty.LeftFraction.map_comp_map_s_assoc]
variable [HasZeroObject D] [Preadditive D] [∀ (n : ℤ), (shiftFunctor D n).Additive] [L.Additive]
/-- The pretriangulated structure on the localized category. -/
def pretriangulated : Pretriangulated D where
distinguishedTriangles := L.essImageDistTriang
isomorphic_distinguished _ hT₁ _ e := L.essImageDistTriang_mem_of_iso e hT₁
contractible_distinguished :=
have := essSurj L W; L.contractible_mem_essImageDistTriang
distinguished_cocone_triangle f := distinguished_cocone_triangle L W f
rotate_distinguished_triangle := L.rotate_essImageDistTriang
complete_distinguished_triangle_morphism := complete_distinguished_triangle_morphism L W
instance isTriangulated_functor :
letI : Pretriangulated D := pretriangulated L W; L.IsTriangulated :=
letI : Pretriangulated D := pretriangulated L W
⟨fun T hT => ⟨T, Iso.refl _, hT⟩⟩
end
variable [HasZeroObject D] [Preadditive D] [∀ (n : ℤ), (shiftFunctor D n).Additive]
include W in
lemma isTriangulated [Pretriangulated D] [L.IsTriangulated] [IsTriangulated C] :
IsTriangulated D := by
have := essSurj_mapComposableArrows L W 2
exact isTriangulated_of_essSurj_mapComposableArrows_two L
variable [W.IsCompatibleWithTriangulation]
instance (n : ℤ) : (shiftFunctor (W.Localization) n).Additive := by
rw [Localization.functor_additive_iff W.Q W]
exact Functor.additive_of_iso (W.Q.commShiftIso n)
noncomputable instance : Pretriangulated W.Localization := pretriangulated W.Q W
instance [IsTriangulated C] : IsTriangulated W.Localization := isTriangulated W.Q W
section
variable [W.HasLocalization]
instance (n : ℤ) : (shiftFunctor (W.Localization') n).Additive := by
rw [Localization.functor_additive_iff W.Q' W]
exact Functor.additive_of_iso (W.Q'.commShiftIso n)
noncomputable instance : Pretriangulated W.Localization' := pretriangulated W.Q' W
instance [IsTriangulated C] : IsTriangulated W.Localization' := isTriangulated W.Q' W
end
end Localization
end Triangulated
namespace Functor
variable [HasZeroObject D] [Preadditive D] [∀ (n : ℤ), (shiftFunctor D n).Additive]
[Pretriangulated D] [L.mapArrow.EssSurj] [L.IsTriangulated]
lemma distTriang_iff (T : Triangle D) :
(T ∈ distTriang D) ↔ T ∈ L.essImageDistTriang := by
constructor
· intro hT
let f := L.mapArrow.objPreimage T.mor₁
obtain ⟨Z, g : f.right ⟶ Z, h : Z ⟶ f.left⟦(1 : ℤ)⟧, mem⟩ :=
Pretriangulated.distinguished_cocone_triangle f.hom
exact ⟨_, (exists_iso_of_arrow_iso T _ hT (L.map_distinguished _ mem)
(L.mapArrow.objObjPreimageIso T.mor₁).symm).choose, mem⟩
· rintro ⟨T₀, e, hT₀⟩
exact isomorphic_distinguished _ (L.map_distinguished _ hT₀) _ e
end Functor
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Localization/Prod.lean | import Mathlib.CategoryTheory.Functor.Currying
import Mathlib.CategoryTheory.Localization.Predicate
import Mathlib.CategoryTheory.MorphismProperty.Composition
/-!
# Localization of product categories
In this file, it is shown that if functors `L₁ : C₁ ⥤ D₁` and `L₂ : C₂ ⥤ D₂`
are localization functors for morphisms properties `W₁` and `W₂`, then
the product functor `C₁ × C₂ ⥤ D₁ × D₂` is a localization functor for
`W₁.prod W₂ : MorphismProperty (C₁ × C₂)`, at least if both `W₁` and `W₂`
contain identities. This main result is the instance `Functor.IsLocalization.prod`.
The proof proceeds by showing first `Localization.Construction.prodIsLocalization`,
which asserts that this holds for the localization functors `W₁.Q` and `W₂.Q` to
the constructed localized categories: this is done by showing that the product
functor `W₁.Q.prod W₂.Q : C₁ × C₂ ⥤ W₁.Localization × W₂.Localization` satisfies
the strict universal property of the localization for `W₁.prod W₂`. The general
case follows by transporting this result through equivalences of categories.
-/
universe v₁ v₂ v₃ v₄ v₅ u₁ u₂ u₃ u₄ u₅
namespace CategoryTheory
open Functor
variable {C₁ : Type u₁} {C₂ : Type u₂} {D₁ : Type u₃} {D₂ : Type u₄}
[Category.{v₁} C₁] [Category.{v₂} C₂] [Category.{v₃} D₁] [Category.{v₄} D₂]
(L₁ : C₁ ⥤ D₁) {W₁ : MorphismProperty C₁}
(L₂ : C₂ ⥤ D₂) {W₂ : MorphismProperty C₂}
namespace Localization
namespace StrictUniversalPropertyFixedTarget
variable {E : Type u₅} [Category.{v₅} E] (F : C₁ × C₂ ⥤ E)
lemma prod_uniq (F₁ F₂ : (W₁.Localization × W₂.Localization ⥤ E))
(h : (W₁.Q.prod W₂.Q) ⋙ F₁ = (W₁.Q.prod W₂.Q) ⋙ F₂) :
F₁ = F₂ := by
apply Functor.curry_obj_injective
apply Construction.uniq
apply Functor.flip_injective
apply Construction.uniq
apply Functor.flip_injective
apply Functor.uncurry_obj_injective
simpa only [Functor.uncurry_obj_curry_obj_flip_flip] using h
/-- Auxiliary definition for `prodLift`. -/
noncomputable def prodLift₁ [W₂.ContainsIdentities]
(hF : (W₁.prod W₂).IsInvertedBy F) :
W₁.Localization ⥤ C₂ ⥤ E :=
Construction.lift (curry.obj F) (fun _ _ f₁ hf₁ => by
haveI : ∀ (X₂ : C₂), IsIso (((curry.obj F).map f₁).app X₂) :=
fun X₂ => hF _ ⟨hf₁, MorphismProperty.id_mem _ _⟩
apply NatIso.isIso_of_isIso_app)
variable (hF : (W₁.prod W₂).IsInvertedBy F)
lemma prod_fac₁ [W₂.ContainsIdentities] :
W₁.Q ⋙ prodLift₁ F hF = curry.obj F :=
Construction.fac _ _
variable [W₁.ContainsIdentities] [W₂.ContainsIdentities]
/-- The lifting of a functor `F : C₁ × C₂ ⥤ E` inverting `W₁.prod W₂` to a functor
`W₁.Localization × W₂.Localization ⥤ E` -/
noncomputable def prodLift :
W₁.Localization × W₂.Localization ⥤ E := by
refine uncurry.obj (Construction.lift (prodLift₁ F hF).flip ?_).flip
intro _ _ f₂ hf₂
haveI : ∀ (X₁ : W₁.Localization),
IsIso (((Functor.flip (prodLift₁ F hF)).map f₂).app X₁) := fun X₁ => by
obtain ⟨X₁, rfl⟩ := (Construction.objEquiv W₁).surjective X₁
exact ((MorphismProperty.isomorphisms E).arrow_mk_iso_iff
(((Functor.mapArrowFunctor _ _).mapIso
(eqToIso (Functor.congr_obj (prod_fac₁ F hF) X₁))).app (Arrow.mk f₂))).2
(hF _ ⟨MorphismProperty.id_mem _ _, hf₂⟩)
apply NatIso.isIso_of_isIso_app
lemma prod_fac₂ :
W₂.Q ⋙ (curry.obj (prodLift F hF)).flip = (prodLift₁ F hF).flip := by
simp only [prodLift, Functor.curry_obj_uncurry_obj, Functor.flip_flip]
apply Construction.fac
lemma prod_fac :
(W₁.Q.prod W₂.Q) ⋙ prodLift F hF = F := by
rw [← Functor.uncurry_obj_curry_obj_flip_flip', prod_fac₂, Functor.flip_flip, prod_fac₁,
Functor.uncurry_obj_curry_obj]
variable (W₁ W₂)
/-- The product of two (constructed) localized categories satisfies the universal
property of the localized category of the product. -/
noncomputable def prod :
StrictUniversalPropertyFixedTarget (W₁.Q.prod W₂.Q) (W₁.prod W₂) E where
inverts := (Localization.inverts W₁.Q W₁).prod (Localization.inverts W₂.Q W₂)
lift := fun F hF => prodLift F hF
fac := fun F hF => prod_fac F hF
uniq := prod_uniq
end StrictUniversalPropertyFixedTarget
variable (W₁ W₂)
variable [W₁.ContainsIdentities] [W₂.ContainsIdentities]
lemma Construction.prodIsLocalization :
(W₁.Q.prod W₂.Q).IsLocalization (W₁.prod W₂) :=
Functor.IsLocalization.mk' _ _
(StrictUniversalPropertyFixedTarget.prod W₁ W₂)
(StrictUniversalPropertyFixedTarget.prod W₁ W₂)
end Localization
open Localization
namespace Functor
namespace IsLocalization
variable (W₁ W₂)
variable [W₁.ContainsIdentities] [W₂.ContainsIdentities]
/-- If `L₁ : C₁ ⥤ D₁` and `L₂ : C₂ ⥤ D₂` are localization functors
for `W₁ : MorphismProperty C₁` and `W₂ : MorphismProperty C₂` respectively,
and if both `W₁` and `W₂` contain identities, then the product
functor `L₁.prod L₂ : C₁ × C₂ ⥤ D₁ × D₂` is a localization functor for `W₁.prod W₂`. -/
instance prod [L₁.IsLocalization W₁] [L₂.IsLocalization W₂] :
(L₁.prod L₂).IsLocalization (W₁.prod W₂) := by
haveI := Construction.prodIsLocalization W₁ W₂
exact of_equivalence_target (W₁.Q.prod W₂.Q) (W₁.prod W₂) (L₁.prod L₂)
((uniq W₁.Q L₁ W₁).prod (uniq W₂.Q L₂ W₂))
(NatIso.prod (compUniqFunctor W₁.Q L₁ W₁) (compUniqFunctor W₂.Q L₂ W₂))
end IsLocalization
end Functor
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Localization/Composition.lean | import Mathlib.CategoryTheory.Localization.LocalizerMorphism
import Mathlib.CategoryTheory.Functor.ReflectsIso.Basic
/-!
# Composition of localization functors
Given two composable functors `L₁ : C₁ ⥤ C₂` and `L₂ : C₂ ⥤ C₃`, it is shown
in this file that under some suitable conditions on `W₁ : MorphismProperty C₁`
`W₂ : MorphismProperty C₂` and `W₃ : MorphismProperty C₁`, then
if `L₁ : C₁ ⥤ C₂` is a localization functor for `W₁`,
then the composition `L₁ ⋙ L₂ : C₁ ⥤ C₃` is a localization functor for `W₃`
if and only if `L₂ : C₂ ⥤ C₃` is a localization functor for `W₂`.
The two implications are the lemmas `Functor.IsLocalization.comp` and
`Functor.IsLocalization.of_comp`.
-/
universe v₁ v₂ v₃ v₄ u₁ u₂ u₃ u₄
namespace CategoryTheory
variable {C₁ : Type u₁} {C₂ : Type u₂} {C₃ : Type u₃} {E : Type u₄}
[Category.{v₁} C₁] [Category.{v₂} C₂] [Category.{v₃} C₃] [Category.{v₄} E]
{L₁ : C₁ ⥤ C₂} {L₂ : C₂ ⥤ C₃} {W₁ : MorphismProperty C₁} {W₂ : MorphismProperty C₂}
namespace Localization
/-- Under some conditions on the `MorphismProperty`, functors satisfying the strict
universal property of the localization are stable under composition -/
def StrictUniversalPropertyFixedTarget.comp
(h₁ : StrictUniversalPropertyFixedTarget L₁ W₁ E)
(h₂ : StrictUniversalPropertyFixedTarget L₂ W₂ E)
(W₃ : MorphismProperty C₁) (hW₃ : W₃.IsInvertedBy (L₁ ⋙ L₂))
(hW₁₃ : W₁ ≤ W₃) (hW₂₃ : W₂ ≤ W₃.map L₁) :
StrictUniversalPropertyFixedTarget (L₁ ⋙ L₂) W₃ E where
inverts := hW₃
lift F hF := h₂.lift (h₁.lift F (MorphismProperty.IsInvertedBy.of_le _ _ F hF hW₁₃)) (by
refine MorphismProperty.IsInvertedBy.of_le _ _ _ ?_ hW₂₃
simpa only [MorphismProperty.IsInvertedBy.map_iff, h₁.fac F] using hF)
fac F hF := by rw [Functor.assoc, h₂.fac, h₁.fac]
uniq _ _ h := h₂.uniq _ _ (h₁.uniq _ _ (by simpa only [Functor.assoc] using h))
end Localization
open Localization
namespace Functor
namespace IsLocalization
variable (L₁ W₁ L₂ W₂)
lemma comp [L₁.IsLocalization W₁] [L₂.IsLocalization W₂]
(W₃ : MorphismProperty C₁) (hW₃ : W₃.IsInvertedBy (L₁ ⋙ L₂))
(hW₁₃ : W₁ ≤ W₃) (hW₂₃ : W₂ ≤ W₃.map L₁) :
(L₁ ⋙ L₂).IsLocalization W₃ := by
-- The proof proceeds by reducing to the case of the constructed
-- localized categories, which satisfy the strict universal property
-- of the localization. In order to do this, we introduce
-- an equivalence of categories `E₂ : C₂ ≅ W₁.Localization`. Via
-- this equivalence, we introduce `W₂' : MorphismProperty W₁.Localization`
-- which corresponds to `W₂` via the equivalence `E₂`.
-- Then, we have a localizer morphism `Φ : LocalizerMorphism W₂ W₂'` which
-- is a localized equivalence (because `E₂` is an equivalence).
let E₂ := Localization.uniq L₁ W₁.Q W₁
let W₂' := W₂.map E₂.functor
let Φ : LocalizerMorphism W₂ W₂' :=
{ functor := E₂.functor
map := by
have eq := W₂.isoClosure.inverseImage_map_eq_of_isEquivalence E₂.functor
rw [MorphismProperty.map_isoClosure] at eq
rw [eq]
apply W₂.le_isoClosure }
have := LocalizerMorphism.IsLocalizedEquivalence.of_equivalence Φ (by rfl)
-- The fact that `Φ` is a localized equivalence allows to consider
-- the induced equivalence of categories `E₃ : C₃ ≅ W₂'.Localization`, and
-- the isomorphism `iso : (W₁.Q ⋙ W₂'.Q) ⋙ E₃.inverse ≅ L₁ ⋙ L₂`
let E₃ := (Φ.localizedFunctor L₂ W₂'.Q).asEquivalence
let iso : (W₁.Q ⋙ W₂'.Q) ⋙ E₃.inverse ≅ L₁ ⋙ L₂ := by
calc
_ ≅ L₁ ⋙ E₂.functor ⋙ W₂'.Q ⋙ E₃.inverse :=
Functor.associator _ _ _ ≪≫ isoWhiskerRight (compUniqFunctor L₁ W₁.Q W₁).symm _ ≪≫
Functor.associator _ _ _
_ ≅ L₁ ⋙ L₂ ⋙ E₃.functor ⋙ E₃.inverse :=
isoWhiskerLeft _ ((Functor.associator _ _ _).symm ≪≫
isoWhiskerRight (Φ.catCommSq L₂ W₂'.Q).iso E₃.inverse ≪≫ Functor.associator _ _ _)
_ ≅ L₁ ⋙ L₂ := isoWhiskerLeft _ (isoWhiskerLeft _ E₃.unitIso.symm ≪≫ L₂.rightUnitor)
-- In order to show `(W₁.Q ⋙ W₂'.Q).IsLocalization W₃`, we need
-- to check the assumptions of `StrictUniversalPropertyFixedTarget.comp`
have hW₃' : W₃.IsInvertedBy (W₁.Q ⋙ W₂'.Q) := by
simpa only [← MorphismProperty.IsInvertedBy.iff_comp _ _ E₃.inverse,
MorphismProperty.IsInvertedBy.iff_of_iso W₃ iso] using hW₃
have hW₂₃' : W₂' ≤ W₃.map W₁.Q := (MorphismProperty.monotone_map E₂.functor hW₂₃).trans
(by simpa only [W₃.map_map]
using le_of_eq (W₃.map_eq_of_iso (compUniqFunctor L₁ W₁.Q W₁)))
have : (W₁.Q ⋙ W₂'.Q).IsLocalization W₃ := by
refine IsLocalization.mk' _ _ ?_ ?_
all_goals
exact (StrictUniversalPropertyFixedTarget.comp
(strictUniversalPropertyFixedTargetQ W₁ _)
(strictUniversalPropertyFixedTargetQ W₂' _) W₃ hW₃' hW₁₃ hW₂₃')
-- Finally, the previous result can be transported via the equivalence `E₃`
exact IsLocalization.of_equivalence_target _ W₃ _ E₃.symm iso
lemma of_comp (W₃ : MorphismProperty C₁)
[L₁.IsLocalization W₁] [(L₁ ⋙ L₂).IsLocalization W₃]
(hW₁₃ : W₁ ≤ W₃) (hW₂₃ : W₂ = W₃.map L₁) :
L₂.IsLocalization W₂ := by
have : (L₁ ⋙ W₂.Q).IsLocalization W₃ :=
comp L₁ W₂.Q W₁ W₂ W₃ (fun X Y f hf => Localization.inverts W₂.Q W₂ _
(by simpa only [hW₂₃] using W₃.map_mem_map _ _ hf)) hW₁₃
(by rw [hW₂₃])
exact IsLocalization.of_equivalence_target W₂.Q W₂ L₂
(Localization.uniq (L₁ ⋙ W₂.Q) (L₁ ⋙ L₂) W₃)
(liftNatIso L₁ W₁ _ _ _ _
((Functor.associator _ _ _).symm ≪≫
Localization.compUniqFunctor (L₁ ⋙ W₂.Q) (L₁ ⋙ L₂) W₃))
end IsLocalization
end Functor
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Localization/Linear.lean | import Mathlib.CategoryTheory.Localization.HasLocalization
import Mathlib.CategoryTheory.Center.Localization
import Mathlib.CategoryTheory.Center.Linear
import Mathlib.CategoryTheory.Linear.LinearFunctor
/-!
# Localization of linear categories
If `L : C ⥤ D` is an additive localization functor between preadditive categories,
and `C` is `R`-linear, we show that `D` can also be equipped with a `R`-linear
structure such that `L` is a `R`-linear functor.
-/
universe w v₁ v₂ u₁ u₂
namespace CategoryTheory
namespace Localization
variable (R : Type w) [Ring R] {C : Type u₁} [Category.{v₁} C] {D : Type u₂} [Category.{v₂} D]
[Preadditive C] [Preadditive D]
(L : C ⥤ D) (W : MorphismProperty C) [L.IsLocalization W]
[L.Additive] [Linear R C]
/-- If `L : C ⥤ D` is a localization functor and `C` is `R`-linear, then `D` is
`R`-linear if we already know that `D` is preadditive and `L` is additive. -/
noncomputable def linear : Linear R D := Linear.ofRingMorphism
((CatCenter.localizationRingHom L W).comp (Linear.toCatCenter R C))
lemma functor_linear :
letI := linear R L W
Functor.Linear R L := by
letI := linear R L W
constructor
intro X Y f r
change L.map (r • f) = ((Linear.toCatCenter R C r).localization L W).app (L.obj X) ≫ L.map f
simp only [CatCenter.localization_app, ← L.map_comp,
Functor.id_obj, Linear.toCatCenter_apply_app, Linear.smul_comp, Category.id_comp]
section
variable [Preadditive W.Localization] [W.Q.Additive]
noncomputable instance : Linear R W.Localization := Localization.linear R W.Q W
noncomputable instance : Functor.Linear R W.Q := Localization.functor_linear R W.Q W
end
section
variable [W.HasLocalization] [Preadditive W.Localization'] [W.Q'.Additive]
noncomputable instance : Linear R W.Localization' := Localization.linear R W.Q' W
noncomputable instance : Functor.Linear R W.Q' := Localization.functor_linear R W.Q' W
end
section
variable {E : Type*} [Category E]
(L : C ⥤ D) (W : MorphismProperty C) [L.IsLocalization W] [Preadditive E]
(R : Type*) [Ring R]
[Linear R C] [Linear R D] [Linear R E] [L.Linear R]
lemma functor_linear_iff (F : C ⥤ E) (G : D ⥤ E) [Lifting L W F G] :
F.Linear R ↔ G.Linear R := by
constructor
· intro
have : (L ⋙ G).Linear R := Functor.linear_of_iso _ (Lifting.iso L W F G).symm
have := Localization.essSurj L W
rw [Functor.linear_iff]
intro X r
have e := L.objObjPreimageIso X
have : r • 𝟙 X = e.inv ≫ (r • 𝟙 _) ≫ e.hom := by simp
rw [this, G.map_comp, G.map_comp, ← L.map_id, ← L.map_smul, ← Functor.comp_map,
(L ⋙ G).map_smul, Functor.map_id, Linear.smul_comp, Linear.comp_smul]
dsimp
rw [Category.id_comp, ← G.map_comp, e.inv_hom_id, G.map_id]
· intro
exact Functor.linear_of_iso _ (Lifting.iso L W F G)
end
end Localization
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Localization/Preadditive.lean | import Mathlib.CategoryTheory.Localization.Predicate
import Mathlib.CategoryTheory.Preadditive.FunctorCategory
/-!
# Localization of natural transformations to preadditive categories
-/
namespace CategoryTheory
open Limits
variable {C D E : Type*} [Category C] [Category D] [Category E]
namespace Localization
variable (L : C ⥤ D) (W : MorphismProperty C) [L.IsLocalization W]
lemma liftNatTrans_zero (F₁ F₂ : C ⥤ E) (F₁' F₂' : D ⥤ E)
[Lifting L W F₁ F₁'] [Lifting L W F₂ F₂']
[HasZeroMorphisms E] :
liftNatTrans L W F₁ F₂ F₁' F₂' 0 = 0 :=
natTrans_ext L W (by simp)
variable [Preadditive E]
lemma liftNatTrans_add (F₁ F₂ : C ⥤ E) (F₁' F₂' : D ⥤ E)
[Lifting L W F₁ F₁'] [Lifting L W F₂ F₂']
(τ τ' : F₁ ⟶ F₂) :
liftNatTrans L W F₁ F₂ F₁' F₂' (τ + τ') =
liftNatTrans L W F₁ F₂ F₁' F₂' τ + liftNatTrans L W F₁ F₂ F₁' F₂' τ' :=
natTrans_ext L W (by simp)
end Localization
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Localization/Pi.lean | import Mathlib.CategoryTheory.Localization.Prod
import Mathlib.CategoryTheory.Localization.Equivalence
import Mathlib.Data.Fintype.Option
/-!
# Localization of product categories
In this file, it is shown that if for all `j : J` (with `J` finite),
functors `L j : C j ⥤ D j` are localization functors with respect
to a class of morphisms `W j : MorphismProperty (C j)`, then the product
functor `Functor.pi L : (∀ j, C j) ⥤ ∀ j, D j` is a localization
functor for the product class of morphisms `MorphismProperty.pi W`.
The proof proceeds by induction on the cardinal of `J` using the
main result of the file `Mathlib/CategoryTheory/Localization/Prod.lean`.
-/
universe w v₁ v₂ u₁ u₂
namespace CategoryTheory.Functor.IsLocalization
instance pi {J : Type w} [Finite J] {C : J → Type u₁} {D : J → Type u₂}
[∀ j, Category.{v₁} (C j)] [∀ j, Category.{v₂} (D j)]
(L : ∀ j, C j ⥤ D j) (W : ∀ j, MorphismProperty (C j))
[∀ j, (W j).ContainsIdentities] [∀ j, (L j).IsLocalization (W j)] :
(Functor.pi L).IsLocalization (MorphismProperty.pi W) := by
revert J
apply Finite.induction_empty_option
· intro J₁ J₂ e hJ₁ C₂ D₂ _ _ L₂ W₂ _ _
let L₁ := fun j => (L₂ (e j))
let E := Pi.equivalenceOfEquiv C₂ e
let E' := Pi.equivalenceOfEquiv D₂ e
haveI : CatCommSq E.functor (Functor.pi L₁) (Functor.pi L₂) E'.functor :=
(CatCommSq.hInvEquiv E (Functor.pi L₁) (Functor.pi L₂) E').symm ⟨Iso.refl _⟩
refine IsLocalization.of_equivalences (Functor.pi L₁)
(MorphismProperty.pi (fun j => (W₂ (e j)))) (Functor.pi L₂)
(MorphismProperty.pi W₂) E E' ?_
(MorphismProperty.IsInvertedBy.pi _ _ (fun _ => Localization.inverts _ _))
intro _ _ f hf
refine ⟨_, _, E.functor.map f, fun i => ?_, ⟨Iso.refl _⟩⟩
have H : ∀ {j j' : J₂} (h : j = j') {X Y : C₂ j} (g : X ⟶ Y) (_ : W₂ j g),
W₂ j' ((Pi.eqToEquivalence C₂ h).functor.map g) := by
rintro j _ rfl _ _ g hg
exact hg
exact H (e.apply_symm_apply i) _ (hf (e.symm i))
· intro C D _ _ L W _ _
haveI : ∀ j, IsEquivalence (L j) := by rintro ⟨⟩
refine IsLocalization.of_isEquivalence _ _ (fun _ _ _ _ => ?_)
rw [MorphismProperty.isomorphisms.iff, isIso_pi_iff]
rintro ⟨⟩
· intro J _ hJ C D _ _ L W _ _
let L₁ := (L none).prod (Functor.pi (fun j => L (some j)))
haveI : CatCommSq (Pi.optionEquivalence C).symm.functor L₁ (Functor.pi L)
(Pi.optionEquivalence D).symm.functor :=
⟨NatIso.pi' (by rintro (_ | i) <;> apply Iso.refl)⟩
refine IsLocalization.of_equivalences L₁
((W none).prod (MorphismProperty.pi (fun j => W (some j)))) (Functor.pi L) _
(Pi.optionEquivalence C).symm (Pi.optionEquivalence D).symm ?_ ?_
· intro ⟨X₁, X₂⟩ ⟨Y₁, Y₂⟩ f ⟨hf₁, hf₂⟩
refine ⟨_, _, (Pi.optionEquivalence C).inverse.map f, ?_, ⟨Iso.refl _⟩⟩
rintro (_ | i)
· exact hf₁
· apply hf₂
· apply MorphismProperty.IsInvertedBy.pi
rintro (_ | i) <;> apply Localization.inverts
/-- If `L : C ⥤ D` is a localization functor for `W : MorphismProperty C`, then
the induced functor `(Discrete J ⥤ C) ⥤ (Discrete J ⥤ D)` is also a localization
for `W.functorCategory (Discrete J)` if `W` contains identities. -/
instance {J : Type} [Finite J] {C : Type u₁} {D : Type u₂} [Category.{v₁} C] [Category.{v₂} D]
(L : C ⥤ D) (W : MorphismProperty C) [W.ContainsIdentities] [L.IsLocalization W] :
((whiskeringRight (Discrete J) C D).obj L).IsLocalization
(W.functorCategory (Discrete J)) := by
let E := piEquivalenceFunctorDiscrete J C
let E' := piEquivalenceFunctorDiscrete J D
let L₂ := (whiskeringRight (Discrete J) C D).obj L
let L₁ := Functor.pi (fun (_ : J) => L)
have : CatCommSq E.functor L₁ L₂ E'.functor :=
⟨(Functor.rightUnitor _).symm ≪≫ isoWhiskerLeft _ E'.counitIso.symm ≪≫
Functor.associator _ _ _≪≫ isoWhiskerLeft _ ((Functor.associator _ _ _).symm ≪≫
isoWhiskerRight (by exact Iso.refl _) _) ≪≫ (Functor.associator _ _ _).symm ≪≫
isoWhiskerRight ((Functor.associator _ _ _).symm ≪≫
isoWhiskerRight E.unitIso.symm L₁) _ ≪≫ isoWhiskerRight L₁.leftUnitor _⟩
refine Functor.IsLocalization.of_equivalences L₁
(MorphismProperty.pi (fun _ => W)) L₂ _ E E' ?_ ?_
· intro X Y f hf
exact MorphismProperty.le_isoClosure _ _ (fun ⟨j⟩ => hf j)
· intro X Y f hf
have : ∀ (j : Discrete J), IsIso ((L₂.map f).app j) :=
fun j => Localization.inverts L W _ (hf j)
apply NatIso.isIso_of_isIso_app
end CategoryTheory.Functor.IsLocalization |
.lake/packages/mathlib/Mathlib/CategoryTheory/Localization/Bifunctor.lean | import Mathlib.CategoryTheory.Localization.Prod
import Mathlib.CategoryTheory.Functor.Currying
/-!
# Lifting of bifunctors
In this file, in the context of the localization of categories, we extend the notion
of lifting of functors to the case of bifunctors. As the localization of categories
behaves well with respect to finite products of categories (when the classes of
morphisms contain identities), all the definitions for bifunctors `C₁ ⥤ C₂ ⥤ E`
are obtained by reducing to the case of functors `(C₁ × C₂) ⥤ E` by using
currying and uncurrying.
Given morphism properties `W₁ : MorphismProperty C₁` and `W₂ : MorphismProperty C₂`,
and a functor `F : C₁ ⥤ C₂ ⥤ E`, we define `MorphismProperty.IsInvertedBy₂ W₁ W₂ F`
as the condition that the functor `uncurry.obj F : C₁ × C₂ ⥤ E` inverts `W₁.prod W₂`.
If `L₁ : C₁ ⥤ D₁` and `L₂ : C₂ ⥤ D₂` are localization functors for `W₁` and `W₂`
respectively, and `F : C₁ ⥤ C₂ ⥤ E` satisfies `MorphismProperty.IsInvertedBy₂ W₁ W₂ F`,
we introduce `Localization.lift₂ F hF L₁ L₂ : D₁ ⥤ D₂ ⥤ E` which is a bifunctor
which lifts `F`.
-/
namespace CategoryTheory
open Category Functor
variable {C₁ C₂ D₁ D₂ E E' : Type*} [Category C₁] [Category C₂]
[Category D₁] [Category D₂] [Category E] [Category E']
namespace MorphismProperty
/-- Classes of morphisms `W₁ : MorphismProperty C₁` and `W₂ : MorphismProperty C₂` are said
to be inverted by `F : C₁ ⥤ C₂ ⥤ E` if `W₁.prod W₂` is inverted by
the functor `uncurry.obj F : C₁ × C₂ ⥤ E`. -/
def IsInvertedBy₂ (W₁ : MorphismProperty C₁) (W₂ : MorphismProperty C₂)
(F : C₁ ⥤ C₂ ⥤ E) : Prop :=
(W₁.prod W₂).IsInvertedBy (uncurry.obj F)
end MorphismProperty
namespace Localization
section
variable (L₁ : C₁ ⥤ D₁) (L₂ : C₂ ⥤ D₂)
/-- Given functors `L₁ : C₁ ⥤ D₁`, `L₂ : C₂ ⥤ D₂`, morphisms properties `W₁` on `C₁`
and `W₂` on `C₂`, and functors `F : C₁ ⥤ C₂ ⥤ E` and `F' : D₁ ⥤ D₂ ⥤ E`, we say
`Lifting₂ L₁ L₂ W₁ W₂ F F'` holds if `F` is induced by `F'`, up to an isomorphism. -/
class Lifting₂ (L₁ : C₁ ⥤ D₁) (L₂ : C₂ ⥤ D₂) (W₁ : MorphismProperty C₁) (W₂ : MorphismProperty C₂)
(F : C₁ ⥤ C₂ ⥤ E) (F' : D₁ ⥤ D₂ ⥤ E) where
/-- the isomorphism `(((whiskeringLeft₂ E).obj L₁).obj L₂).obj F' ≅ F` expressing
that `F` is induced by `F'` up to an isomorphism -/
iso (L₁ L₂ W₁ W₂ F F') : (((whiskeringLeft₂ E).obj L₁).obj L₂).obj F' ≅ F
variable (W₁ : MorphismProperty C₁) (W₂ : MorphismProperty C₂)
(F : C₁ ⥤ C₂ ⥤ E) (F' : D₁ ⥤ D₂ ⥤ E) [Lifting₂ L₁ L₂ W₁ W₂ F F']
@[deprecated (since := "2025-08-22")] alias Lifting₂.iso' := Lifting.iso
/-- If `Lifting₂ L₁ L₂ W₁ W₂ F F'` holds, then `Lifting L₂ W₂ (F.obj X₁) (F'.obj (L₁.obj X₁))`
holds for any `X₁ : C₁`. -/
noncomputable def Lifting₂.fst (X₁ : C₁) :
Lifting L₂ W₂ (F.obj X₁) (F'.obj (L₁.obj X₁)) where
iso := ((evaluation _ _).obj X₁).mapIso (Lifting₂.iso L₁ L₂ W₁ W₂ F F')
noncomputable instance Lifting₂.flip : Lifting₂ L₂ L₁ W₂ W₁ F.flip F'.flip where
iso := (flipFunctor _ _ _).mapIso (Lifting₂.iso L₁ L₂ W₁ W₂ F F')
/-- If `Lifting₂ L₁ L₂ W₁ W₂ F F'` holds, then
`Lifting L₁ W₁ (F.flip.obj X₂) (F'.flip.obj (L₂.obj X₂))` holds for any `X₂ : C₂`. -/
noncomputable def Lifting₂.snd (X₂ : C₂) :
Lifting L₁ W₁ (F.flip.obj X₂) (F'.flip.obj (L₂.obj X₂)) :=
Lifting₂.fst L₂ L₁ W₂ W₁ F.flip F'.flip X₂
noncomputable instance Lifting₂.uncurry [Lifting₂ L₁ L₂ W₁ W₂ F F'] :
Lifting (L₁.prod L₂) (W₁.prod W₂) (uncurry.obj F) (uncurry.obj F') where
iso := Functor.uncurry.mapIso (Lifting₂.iso L₁ L₂ W₁ W₂ F F')
end
section
variable (F : C₁ ⥤ C₂ ⥤ E) {W₁ : MorphismProperty C₁} {W₂ : MorphismProperty C₂}
(hF : MorphismProperty.IsInvertedBy₂ W₁ W₂ F)
(L₁ : C₁ ⥤ D₁) (L₂ : C₂ ⥤ D₂)
[L₁.IsLocalization W₁] [L₂.IsLocalization W₂]
[W₁.ContainsIdentities] [W₂.ContainsIdentities]
/-- Given localization functor `L₁ : C₁ ⥤ D₁` and `L₂ : C₂ ⥤ D₂` with respect
to `W₁ : MorphismProperty C₁` and `W₂ : MorphismProperty C₂` respectively,
and a bifunctor `F : C₁ ⥤ C₂ ⥤ E` which inverts `W₁` and `W₂`, this is
the induced localized bifunctor `D₁ ⥤ D₂ ⥤ E`. -/
noncomputable def lift₂ : D₁ ⥤ D₂ ⥤ E :=
curry.obj (lift (uncurry.obj F) hF (L₁.prod L₂))
noncomputable instance : Lifting₂ L₁ L₂ W₁ W₂ F (lift₂ F hF L₁ L₂) where
iso := (curryObjProdComp _ _ _).symm ≪≫
curry.mapIso (fac (uncurry.obj F) hF (L₁.prod L₂)) ≪≫
currying.unitIso.symm.app F
noncomputable instance Lifting₂.liftingLift₂ (X₁ : C₁) :
Lifting L₂ W₂ (F.obj X₁) ((lift₂ F hF L₁ L₂).obj (L₁.obj X₁)) :=
Lifting₂.fst _ _ W₁ _ _ _ _
noncomputable instance Lifting₂.liftingLift₂Flip (X₂ : C₂) :
Lifting L₁ W₁ (F.flip.obj X₂) ((lift₂ F hF L₁ L₂).flip.obj (L₂.obj X₂)) :=
Lifting₂.snd _ _ _ W₂ _ _ _
lemma lift₂_iso_hom_app_app₁ (X₁ : C₁) (X₂ : C₂) :
((Lifting₂.iso L₁ L₂ W₁ W₂ F (lift₂ F hF L₁ L₂)).hom.app X₁).app X₂ =
(Lifting.iso L₂ W₂ (F.obj X₁) ((lift₂ F hF L₁ L₂).obj (L₁.obj X₁))).hom.app X₂ :=
rfl
lemma lift₂_iso_hom_app_app₂ (X₁ : C₁) (X₂ : C₂) :
((Lifting₂.iso L₁ L₂ W₁ W₂ F (lift₂ F hF L₁ L₂)).hom.app X₁).app X₂ =
(Lifting.iso L₁ W₁ (F.flip.obj X₂) ((lift₂ F hF L₁ L₂).flip.obj (L₂.obj X₂))).hom.app X₁ :=
rfl
end
section
variable (L₁ : C₁ ⥤ D₁) (L₂ : C₂ ⥤ D₂)
(W₁ : MorphismProperty C₁) (W₂ : MorphismProperty C₂)
[L₁.IsLocalization W₁] [L₂.IsLocalization W₂]
[W₁.ContainsIdentities] [W₂.ContainsIdentities]
(F₁ F₂ : C₁ ⥤ C₂ ⥤ E) (F₁' F₂' : D₁ ⥤ D₂ ⥤ E)
[Lifting₂ L₁ L₂ W₁ W₂ F₁ F₁'] [Lifting₂ L₁ L₂ W₁ W₂ F₂ F₂']
/-- The natural transformation `F₁' ⟶ F₂'` of bifunctors induced by a
natural transformation `τ : F₁ ⟶ F₂` when `Lifting₂ L₁ L₂ W₁ W₂ F₁ F₁'`
and `Lifting₂ L₁ L₂ W₁ W₂ F₂ F₂'` hold. -/
noncomputable def lift₂NatTrans (τ : F₁ ⟶ F₂) : F₁' ⟶ F₂' :=
fullyFaithfulUncurry.preimage
(liftNatTrans (L₁.prod L₂) (W₁.prod W₂) (uncurry.obj F₁)
(uncurry.obj F₂) (uncurry.obj F₁') (uncurry.obj F₂') (uncurry.map τ))
@[simp]
theorem lift₂NatTrans_app_app (τ : F₁ ⟶ F₂) (X₁ : C₁) (X₂ : C₂) :
((lift₂NatTrans L₁ L₂ W₁ W₂ F₁ F₂ F₁' F₂' τ).app (L₁.obj X₁)).app (L₂.obj X₂) =
((Lifting₂.iso L₁ L₂ W₁ W₂ F₁ F₁').hom.app X₁).app X₂ ≫ (τ.app X₁).app X₂ ≫
((Lifting₂.iso L₁ L₂ W₁ W₂ F₂ F₂').inv.app X₁).app X₂ := by
dsimp [lift₂NatTrans, fullyFaithfulUncurry, Equivalence.fullyFaithfulFunctor]
simp only [comp_id, id_comp]
exact liftNatTrans_app _ _ _ _ (uncurry.obj F₁') (uncurry.obj F₂') (uncurry.map τ) ⟨X₁, X₂⟩
variable {F₁' F₂'} in
include W₁ W₂ in
theorem natTrans₂_ext {τ τ' : F₁' ⟶ F₂'}
(h : ∀ (X₁ : C₁) (X₂ : C₂), (τ.app (L₁.obj X₁)).app (L₂.obj X₂) =
(τ'.app (L₁.obj X₁)).app (L₂.obj X₂)) : τ = τ' :=
uncurry.map_injective (natTrans_ext (L₁.prod L₂) (W₁.prod W₂) (fun _ ↦ h _ _))
/-- The natural isomorphism `F₁' ≅ F₂'` of bifunctors induced by a
natural isomorphism `e : F₁ ≅ F₂` when `Lifting₂ L₁ L₂ W₁ W₂ F₁ F₁'`
and `Lifting₂ L₁ L₂ W₁ W₂ F₂ F₂'` hold. -/
noncomputable def lift₂NatIso (e : F₁ ≅ F₂) : F₁' ≅ F₂' where
hom := lift₂NatTrans L₁ L₂ W₁ W₂ F₁ F₂ F₁' F₂' e.hom
inv := lift₂NatTrans L₁ L₂ W₁ W₂ F₂ F₁ F₂' F₁' e.inv
hom_inv_id := natTrans₂_ext L₁ L₂ W₁ W₂ (by simp)
inv_hom_id := natTrans₂_ext L₁ L₂ W₁ W₂ (by simp)
end
end Localization
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Localization/Quotient.lean | import Mathlib.CategoryTheory.Localization.LocalizerMorphism
import Mathlib.CategoryTheory.Quotient
/-!
# Localization of quotient categories
Given a relation `homRel : HomRel C` on morphisms in a category `C`
and `W : MorphismProperty C`, we introduce a property
`homRel.FactorsThroughLocalization W` expressing that related
morphisms are mapped to the same morphism in the localized
category with respect to `W`. When `W` is compatible with `homRel`
(i.e. there is a class of morphisms `W'` such that
`hW : W = W'.inverseImage (Quotient.functor homRel)`),
we show that `LocalizerMorphism.ofEq hW : LocalizerMorphism W W'`
induces an equivalence on localized categories.
-/
namespace HomRel
open CategoryTheory
variable {C D : Type*} [Category C] [Category D] (homRel : HomRel C)
/-- Given `homRel : HomRel C` and `W : MorphismProperty C`, this is the property
that whenever `homRel f g`, then the morphisms `f` and `g` are sent to the
same morphism in the localization category with respect to `W`. -/
def FactorsThroughLocalization (W : MorphismProperty C) : Prop :=
∀ ⦃X Y : C⦄ ⦃f g : X ⟶ Y⦄, homRel f g → AreEqualizedByLocalization W f g
variable {homRel} {W : MorphismProperty C}
(h : homRel.FactorsThroughLocalization W)
{W' : MorphismProperty (Quotient homRel)}
(hW : W = W'.inverseImage (Quotient.functor homRel))
namespace FactorsThroughLocalization
open Localization
section
variable {E : Type*} [Category E]
/-- If `L' : Quotient homRel ⥤ D` satisfies the strict universal property of the
localization, then `Quotient.functor homRel ⋙ L'` also satisfies it. -/
def strictUniversalPropertyFixedTarget (L' : Quotient homRel ⥤ D)
(univ : StrictUniversalPropertyFixedTarget L' W' E) :
StrictUniversalPropertyFixedTarget
(Quotient.functor homRel ⋙ L') W E where
inverts _ _ _ hf := univ.inverts _ (by rwa [hW] at hf)
lift F hF :=
univ.lift (CategoryTheory.Quotient.lift _ F
(fun _ _ f g hfg ↦ (h hfg).map_eq_of_isInvertedBy _ hF)) (by
rintro K L ⟨f⟩ hf
exact hF _ (by simpa [hW] using hf))
fac F hF := by rw [Functor.assoc, univ.fac, Quotient.lift_spec]
uniq F₁ F₂ h := univ.uniq _ _ (Quotient.lift_unique' _ _ _ h)
variable (E) in
/-- If `homRel : HomRel C` satisfies `homRel.FactorsThroughLocalization W` and
that the class of morphisms `W` induces a class of morphism `W'` on the quotient category,
then `Quotient.functor homRel ⋙ W'.Q` satisfies the universal property of the
localization. This is used in `HomRel.FactorsThroughLocalization.isLocalizedEquivalence`
in order to show that as a localizer morphism, the quotient functor induces an
equivalence on localized categories. -/
noncomputable def strictUniversalPropertyFixedTarget' :
StrictUniversalPropertyFixedTarget
(Quotient.functor homRel ⋙ W'.Q) W E :=
strictUniversalPropertyFixedTarget h hW _ (strictUniversalPropertyFixedTargetQ W' E)
end
include h in
/-- If `homRel : HomRel C` satisfies `homRel.FactorsThroughLocalization W` and
that the class of morphisms `W` induces a class of morphism `W'` on the quotient category,
then the localizer morphism given by the functor `Quotient.functor HomRel : C ⥤ Quotient homRel`
induces equivalences on localized categories. -/
lemma isLocalizedEquivalence :
(LocalizerMorphism.ofEq hW).IsLocalizedEquivalence :=
have : ((LocalizerMorphism.ofEq hW).functor ⋙ W'.Q).IsLocalization W :=
Functor.IsLocalization.mk' _ _
(h.strictUniversalPropertyFixedTarget' hW _)
(h.strictUniversalPropertyFixedTarget' hW _)
LocalizerMorphism.IsLocalizedEquivalence.of_isLocalization_of_isLocalization _ W'.Q
end FactorsThroughLocalization
end HomRel |
.lake/packages/mathlib/Mathlib/CategoryTheory/Localization/Trifunctor.lean | import Mathlib.CategoryTheory.Localization.Bifunctor
import Mathlib.CategoryTheory.Functor.CurryingThree
import Mathlib.CategoryTheory.Products.Associator
/-!
# Lifting of trifunctors
In this file, in the context of the localization of categories, we extend the notion
of lifting of functors to the case of trifunctors
(see also the file `Localization.Bifunctor` for the case of bifunctors).
The main result in this file is that we can localize "associator" isomorphisms
(see the definition `Localization.associator`).
-/
namespace CategoryTheory
open Functor
variable {C₁ C₂ C₃ C₁₂ C₂₃ D₁ D₂ D₃ D₁₂ D₂₃ C D E : Type*}
[Category C₁] [Category C₂] [Category C₃] [Category D₁] [Category D₂] [Category D₃]
[Category C₁₂] [Category C₂₃] [Category D₁₂] [Category D₂₃]
[Category C] [Category D] [Category E]
namespace MorphismProperty
/-- Classes of morphisms `W₁ : MorphismProperty C₁`, `W₂ : MorphismProperty C₂` and
`W₃ : MorphismProperty C₃` are said to be inverted by `F : C₁ ⥤ C₂ ⥤ C₃ ⥤ E` if
`W₁.prod (W₂.prod W₃)` is inverted by the
functor `currying₃.functor.obj F : C₁ × C₂ × C₃ ⥤ E`. -/
def IsInvertedBy₃ (W₁ : MorphismProperty C₁) (W₂ : MorphismProperty C₂)
(W₃ : MorphismProperty C₃) (F : C₁ ⥤ C₂ ⥤ C₃ ⥤ E) : Prop :=
(W₁.prod (W₂.prod W₃)).IsInvertedBy (currying₃.functor.obj F)
end MorphismProperty
namespace Localization
section
variable (L₁ : C₁ ⥤ D₁) (L₂ : C₂ ⥤ D₂) (L₃ : C₃ ⥤ D₃)
/-- Given functors `L₁ : C₁ ⥤ D₁`, `L₂ : C₂ ⥤ D₂`, `L₃ : C₃ ⥤ D₃`,
morphisms properties `W₁` on `C₁`, `W₂` on `C₂`, `W₃` on `C₃`, and
functors `F : C₁ ⥤ C₂ ⥤ C₃ ⥤ E` and `F' : D₁ ⥤ D₂ ⥤ D₃ ⥤ E`, we say
`Lifting₃ L₁ L₂ L₃ W₁ W₂ W₃ F F'` holds if `F` is induced by `F'`, up to an isomorphism. -/
class Lifting₃ (L₁ : C₁ ⥤ D₁) (L₂ : C₂ ⥤ D₂) (L₃ : C₃ ⥤ D₃)
(W₁ : MorphismProperty C₁) (W₂ : MorphismProperty C₂) (W₃ : MorphismProperty C₃)
(F : C₁ ⥤ C₂ ⥤ C₃ ⥤ E) (F' : D₁ ⥤ D₂ ⥤ D₃ ⥤ E) where
/-- the isomorphism `((((whiskeringLeft₃ E).obj L₁).obj L₂).obj L₃).obj F' ≅ F` expressing
that `F` is induced by `F'` up to an isomorphism -/
iso (L₁ L₂ L₃ W₁ W₂ W₃ F F') : ((((whiskeringLeft₃ E).obj L₁).obj L₂).obj L₃).obj F' ≅ F
variable (W₁ : MorphismProperty C₁) (W₂ : MorphismProperty C₂) (W₃ : MorphismProperty C₃)
(F : C₁ ⥤ C₂ ⥤ C₃ ⥤ E) (F' : D₁ ⥤ D₂ ⥤ D₃ ⥤ E) [Lifting₃ L₁ L₂ L₃ W₁ W₂ W₃ F F']
@[deprecated (since := "2025-08-22")] alias Lifting₃.iso' := Lifting₃.iso
variable (F : C₁ ⥤ C₂ ⥤ C₃ ⥤ E) (F' : D₁ ⥤ D₂ ⥤ D₃ ⥤ E)
noncomputable instance Lifting₃.uncurry [Lifting₃ L₁ L₂ L₃ W₁ W₂ W₃ F F'] :
Lifting (L₁.prod (L₂.prod L₃)) (W₁.prod (W₂.prod W₃))
(uncurry₃.obj F) (uncurry₃.obj F') where
iso := uncurry₃.mapIso (Lifting₃.iso L₁ L₂ L₃ W₁ W₂ W₃ F F')
end
section
variable (F : C₁ ⥤ C₂ ⥤ C₃ ⥤ E) {W₁ : MorphismProperty C₁} {W₂ : MorphismProperty C₂}
{W₃ : MorphismProperty C₃}
(hF : MorphismProperty.IsInvertedBy₃ W₁ W₂ W₃ F)
(L₁ : C₁ ⥤ D₁) (L₂ : C₂ ⥤ D₂) (L₃ : C₃ ⥤ D₃)
[L₁.IsLocalization W₁] [L₂.IsLocalization W₂] [L₃.IsLocalization W₃]
[W₁.ContainsIdentities] [W₂.ContainsIdentities] [W₃.ContainsIdentities]
/-- Given localization functor `L₁ : C₁ ⥤ D₁`, `L₂ : C₂ ⥤ D₂` and `L₃ : C₃ ⥤ D₃`
with respect to `W₁ : MorphismProperty C₁`, `W₂ : MorphismProperty C₂` and
`W₃ : MorphismProperty C₃` respectively, and a trifunctor `F : C₁ ⥤ C₂ ⥤ C₃ ⥤ E`
which inverts `W₁`, `W₂` and `W₃`, this is the induced localized
trifunctor `D₁ ⥤ D₂ ⥤ D₃ ⥤ E`. -/
noncomputable def lift₃ : D₁ ⥤ D₂ ⥤ D₃ ⥤ E :=
curry₃.obj (lift (uncurry₃.obj F) hF (L₁.prod (L₂.prod L₃)))
noncomputable instance : Lifting₃ L₁ L₂ L₃ W₁ W₂ W₃ F (lift₃ F hF L₁ L₂ L₃) where
iso :=
(curry₃ObjProdComp L₁ L₂ L₃ _).symm ≪≫
curry₃.mapIso (fac (uncurry₃.obj F) hF (L₁.prod (L₂.prod L₃))) ≪≫
currying₃.unitIso.symm.app F
end
section
variable (L₁ : C₁ ⥤ D₁) (L₂ : C₂ ⥤ D₂) (L₃ : C₃ ⥤ D₃)
(W₁ : MorphismProperty C₁) (W₂ : MorphismProperty C₂) (W₃ : MorphismProperty C₃)
[L₁.IsLocalization W₁] [L₂.IsLocalization W₂] [L₃.IsLocalization W₃]
[W₁.ContainsIdentities] [W₂.ContainsIdentities] [W₃.ContainsIdentities]
(F₁ F₂ : C₁ ⥤ C₂ ⥤ C₃ ⥤ E) (F₁' F₂' : D₁ ⥤ D₂ ⥤ D₃ ⥤ E)
[Lifting₃ L₁ L₂ L₃ W₁ W₂ W₃ F₁ F₁'] [Lifting₃ L₁ L₂ L₃ W₁ W₂ W₃ F₂ F₂'] (τ : F₁ ⟶ F₂)
(e : F₁ ≅ F₂)
/-- The natural transformation `F₁' ⟶ F₂'` of trifunctors induced by a
natural transformation `τ : F₁ ⟶ F₂` when `Lifting₃ L₁ L₂ L₃ W₁ W₂ W₃ F₁ F₁'`
and `Lifting₃ L₁ L₂ L₃ W₁ W₂ W₃ F₂ F₂'` hold. -/
noncomputable def lift₃NatTrans : F₁' ⟶ F₂' :=
fullyFaithfulUncurry₃.preimage
(liftNatTrans (L₁.prod (L₂.prod L₃)) (W₁.prod (W₂.prod W₃)) (uncurry₃.obj F₁)
(uncurry₃.obj F₂) (uncurry₃.obj F₁') (uncurry₃.obj F₂') (uncurry₃.map τ))
@[simp]
theorem lift₃NatTrans_app_app_app (X₁ : C₁) (X₂ : C₂) (X₃ : C₃) :
(((lift₃NatTrans L₁ L₂ L₃ W₁ W₂ W₃ F₁ F₂ F₁' F₂' τ).app
(L₁.obj X₁)).app (L₂.obj X₂)).app (L₃.obj X₃) =
(((Lifting₃.iso L₁ L₂ L₃ W₁ W₂ W₃ F₁ F₁').hom.app X₁).app X₂).app X₃ ≫
((τ.app X₁).app X₂).app X₃ ≫
(((Lifting₃.iso L₁ L₂ L₃ W₁ W₂ W₃ F₂ F₂').inv.app X₁).app X₂).app X₃ := by
dsimp [lift₃NatTrans, fullyFaithfulUncurry₃, Equivalence.fullyFaithfulFunctor]
simp only [currying₃_unitIso_hom_app_app_app_app, Functor.id_obj,
currying₃_unitIso_inv_app_app_app_app, Functor.comp_obj,
Category.comp_id, Category.id_comp]
exact liftNatTrans_app _ _ _ _ (uncurry₃.obj F₁') (uncurry₃.obj F₂') (uncurry₃.map τ) ⟨X₁, X₂, X₃⟩
variable {F₁' F₂'} in
include W₁ W₂ W₃ in
theorem natTrans₃_ext {τ τ' : F₁' ⟶ F₂'}
(h : ∀ (X₁ : C₁) (X₂ : C₂) (X₃ : C₃), ((τ.app (L₁.obj X₁)).app (L₂.obj X₂)).app (L₃.obj X₃) =
((τ'.app (L₁.obj X₁)).app (L₂.obj X₂)).app (L₃.obj X₃)) : τ = τ' :=
uncurry₃.map_injective (natTrans_ext (L₁.prod (L₂.prod L₃)) (W₁.prod (W₂.prod W₃))
(fun _ ↦ h _ _ _))
/-- The natural isomorphism `F₁' ≅ F₂'` of trifunctors induced by a
natural isomorphism `e : F₁ ≅ F₂` when `Lifting₃ L₁ L₂ L₃ W₁ W₂ W₃ F₁ F₁'`
and `Lifting₃ L₁ L₂ L₃ W₁ W₂ W₃ F₂ F₂'` hold. -/
@[simps]
noncomputable def lift₃NatIso : F₁' ≅ F₂' where
hom := lift₃NatTrans L₁ L₂ L₃ W₁ W₂ W₃ F₁ F₂ F₁' F₂' e.hom
inv := lift₃NatTrans L₁ L₂ L₃ W₁ W₂ W₃ F₂ F₁ F₂' F₁' e.inv
hom_inv_id := natTrans₃_ext L₁ L₂ L₃ W₁ W₂ W₃ (by cat_disch)
inv_hom_id := natTrans₃_ext L₁ L₂ L₃ W₁ W₂ W₃ (by cat_disch)
end
section
variable
(L₁ : C₁ ⥤ D₁) (L₂ : C₂ ⥤ D₂) (L₃ : C₃ ⥤ D₃) (L₁₂ : C₁₂ ⥤ D₁₂) (L₂₃ : C₂₃ ⥤ D₂₃) (L : C ⥤ D)
(W₁ : MorphismProperty C₁) (W₂ : MorphismProperty C₂) (W₃ : MorphismProperty C₃)
(W₁₂ : MorphismProperty C₁₂) (W₂₃ : MorphismProperty C₂₃) (W : MorphismProperty C)
[W₁.ContainsIdentities] [W₂.ContainsIdentities] [W₃.ContainsIdentities]
[L₁.IsLocalization W₁] [L₂.IsLocalization W₂] [L₃.IsLocalization W₃] [L.IsLocalization W]
(F₁₂ : C₁ ⥤ C₂ ⥤ C₁₂) (G : C₁₂ ⥤ C₃ ⥤ C)
(F : C₁ ⥤ C₂₃ ⥤ C) (G₂₃ : C₂ ⥤ C₃ ⥤ C₂₃)
(iso : bifunctorComp₁₂ F₁₂ G ≅ bifunctorComp₂₃ F G₂₃)
(F₁₂' : D₁ ⥤ D₂ ⥤ D₁₂) (G' : D₁₂ ⥤ D₃ ⥤ D)
(F' : D₁ ⥤ D₂₃ ⥤ D) (G₂₃' : D₂ ⥤ D₃ ⥤ D₂₃)
[Lifting₂ L₁ L₂ W₁ W₂ (F₁₂ ⋙ (whiskeringRight _ _ _).obj L₁₂) F₁₂']
[Lifting₂ L₁₂ L₃ W₁₂ W₃ (G ⋙ (whiskeringRight _ _ _).obj L) G']
[Lifting₂ L₁ L₂₃ W₁ W₂₃ (F ⋙ (whiskeringRight _ _ _).obj L) F']
[Lifting₂ L₂ L₃ W₂ W₃ (G₂₃ ⋙ (whiskeringRight _ _ _).obj L₂₃) G₂₃']
/-- The construction `bifunctorComp₁₂` of a trifunctor by composition of bifunctors
is compatible with localization. -/
noncomputable def Lifting₃.bifunctorComp₁₂ :
Lifting₃ L₁ L₂ L₃ W₁ W₂ W₃
((Functor.postcompose₃.obj L).obj (bifunctorComp₁₂ F₁₂ G))
(bifunctorComp₁₂ F₁₂' G') where
iso :=
((whiskeringRight C₁ _ _).obj
((whiskeringRight C₂ _ _).obj ((whiskeringLeft _ _ D).obj L₃))).mapIso
((bifunctorComp₁₂Functor.mapIso
(Lifting₂.iso L₁ L₂ W₁ W₂ (F₁₂ ⋙ (whiskeringRight _ _ _).obj L₁₂) F₁₂')).app G') ≪≫
(bifunctorComp₁₂Functor.obj F₁₂).mapIso
(Lifting₂.iso L₁₂ L₃ W₁₂ W₃ (G ⋙ (whiskeringRight _ _ _).obj L) G')
/-- The construction `bifunctorComp₂₃` of a trifunctor by composition of bifunctors
is compatible with localization. -/
noncomputable def Lifting₃.bifunctorComp₂₃ :
Lifting₃ L₁ L₂ L₃ W₁ W₂ W₃
((Functor.postcompose₃.obj L).obj (bifunctorComp₂₃ F G₂₃))
(bifunctorComp₂₃ F' G₂₃') where
iso :=
((whiskeringLeft _ _ _).obj L₁).mapIso ((bifunctorComp₂₃Functor.obj F').mapIso
(Lifting₂.iso L₂ L₃ W₂ W₃ (G₂₃ ⋙ (whiskeringRight _ _ _).obj L₂₃) G₂₃')) ≪≫
(bifunctorComp₂₃Functor.mapIso
(Lifting₂.iso L₁ L₂₃ W₁ W₂₃ (F ⋙ (whiskeringRight _ _ _).obj L) F')).app G₂₃
variable {F₁₂ G F G₂₃}
/-- The associator isomorphism obtained by localization. -/
noncomputable def associator : bifunctorComp₁₂ F₁₂' G' ≅ bifunctorComp₂₃ F' G₂₃' :=
letI := Lifting₃.bifunctorComp₁₂ L₁ L₂ L₃ L₁₂ L W₁ W₂ W₃ W₁₂ F₁₂ G F₁₂' G'
letI := Lifting₃.bifunctorComp₂₃ L₁ L₂ L₃ L₂₃ L W₁ W₂ W₃ W₂₃ F G₂₃ F' G₂₃'
lift₃NatIso L₁ L₂ L₃ W₁ W₂ W₃ _ _ _ _ ((Functor.postcompose₃.obj L).mapIso iso)
lemma associator_hom_app_app_app (X₁ : C₁) (X₂ : C₂) (X₃ : C₃) :
(((associator L₁ L₂ L₃ L₁₂ L₂₃ L W₁ W₂ W₃ W₁₂ W₂₃ iso F₁₂' G' F' G₂₃').hom.app (L₁.obj X₁)).app
(L₂.obj X₂)).app (L₃.obj X₃) =
(G'.map (((Lifting₂.iso L₁ L₂ W₁ W₂
(F₁₂ ⋙ (whiskeringRight C₂ C₁₂ D₁₂).obj L₁₂) F₁₂').hom.app X₁).app X₂)).app (L₃.obj X₃) ≫
((Lifting₂.iso L₁₂ L₃ W₁₂ W₃ (G ⋙ (whiskeringRight C₃ C D).obj L) G').hom.app
((F₁₂.obj X₁).obj X₂)).app X₃ ≫
L.map (((iso.hom.app X₁).app X₂).app X₃) ≫
((Lifting₂.iso L₁ L₂₃ W₁ W₂₃
(F ⋙ (whiskeringRight _ _ _).obj L) F').inv.app X₁).app ((G₂₃.obj X₂).obj X₃) ≫
(F'.obj (L₁.obj X₁)).map
(((Lifting₂.iso L₂ L₃ W₂ W₃
(G₂₃ ⋙ (whiskeringRight _ _ _).obj L₂₃) G₂₃').inv.app X₂).app X₃) := by
dsimp [associator]
rw [lift₃NatTrans_app_app_app]
dsimp [Lifting₃.iso, Lifting₃.bifunctorComp₁₂, Lifting₃.bifunctorComp₂₃]
simp only [Category.assoc]
end
end Localization
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Localization/LocalizerMorphism.lean | import Mathlib.CategoryTheory.Localization.Equivalence
/-!
# Morphisms of localizers
A morphism of localizers consists of a functor `F : C₁ ⥤ C₂` between
two categories equipped with morphism properties `W₁` and `W₂` such
that `F` sends morphisms in `W₁` to morphisms in `W₂`.
If `Φ : LocalizerMorphism W₁ W₂`, and that `L₁ : C₁ ⥤ D₁` and `L₂ : C₂ ⥤ D₂`
are localization functors for `W₁` and `W₂`, the induced functor `D₁ ⥤ D₂`
is denoted `Φ.localizedFunctor L₁ L₂`; we introduce the condition
`Φ.IsLocalizedEquivalence` which expresses that this functor is an equivalence
of categories. This condition is independent of the choice of the
localized categories.
## References
* [Bruno Kahn and Georges Maltsiniotis, *Structures de dérivabilité*][KahnMaltsiniotis2008]
-/
universe v₁ v₂ v₃ v₄ v₄' v₅ v₅' v₆ u₁ u₂ u₃ u₄ u₄' u₅ u₅' u₆
namespace CategoryTheory
open Localization Functor
variable {C₁ : Type u₁} {C₂ : Type u₂} {C₃ : Type u₃} {D₁ : Type u₄} {D₂ : Type u₅}
[Category.{v₁} C₁] [Category.{v₂} C₂] [Category.{v₃} C₃] [Category.{v₄} D₁] [Category.{v₅} D₂]
(W₁ : MorphismProperty C₁) (W₂ : MorphismProperty C₂) (W₃ : MorphismProperty C₃)
/-- If `W₁ : MorphismProperty C₁` and `W₂ : MorphismProperty C₂`, a `LocalizerMorphism W₁ W₂`
is the datum of a functor `C₁ ⥤ C₂` which sends morphisms in `W₁` to morphisms in `W₂` -/
structure LocalizerMorphism where
/-- a functor between the two categories -/
functor : C₁ ⥤ C₂
/-- the functor is compatible with the `MorphismProperty` -/
map : W₁ ≤ W₂.inverseImage functor
namespace LocalizerMorphism
variable {W₁ W₂} in
/-- Constructor for localizer morphisms given by a functor `F : C₁ ⥤ C₂`
under the stronger assumption that the classes of morphisms `W₁` and `W₂`
satisfy `W₁ = W₂.inverseImage F`. -/
@[simps]
def ofEq {F : C₁ ⥤ C₂} (hW : W₁ = W₂.inverseImage F) : LocalizerMorphism W₁ W₂ where
functor := F
map := by rw [hW]
/-- The identity functor as a morphism of localizers. -/
@[simps]
def id : LocalizerMorphism W₁ W₁ where
functor := 𝟭 C₁
map _ _ _ hf := hf
variable {W₁ W₂ W₃}
/-- The composition of two localizers morphisms. -/
@[simps]
def comp (Φ : LocalizerMorphism W₁ W₂) (Ψ : LocalizerMorphism W₂ W₃) :
LocalizerMorphism W₁ W₃ where
functor := Φ.functor ⋙ Ψ.functor
map _ _ _ hf := Ψ.map _ (Φ.map _ hf)
variable (Φ : LocalizerMorphism W₁ W₂)
/-- The opposite localizer morphism `LocalizerMorphism W₁.op W₂.op` deduced
from `Φ : LocalizerMorphism W₁ W₂`. -/
@[simps]
def op : LocalizerMorphism W₁.op W₂.op where
functor := Φ.functor.op
map _ _ _ hf := Φ.map _ hf
variable (L₁ : C₁ ⥤ D₁) [L₁.IsLocalization W₁] (L₂ : C₂ ⥤ D₂) [L₂.IsLocalization W₂]
lemma inverts : W₁.IsInvertedBy (Φ.functor ⋙ L₂) :=
fun _ _ _ hf => Localization.inverts L₂ W₂ _ (Φ.map _ hf)
/-- When `Φ : LocalizerMorphism W₁ W₂` and that `L₁` and `L₂` are localization functors
for `W₁` and `W₂`, then `Φ.localizedFunctor L₁ L₂` is the induced functor on the
localized categories. -/
noncomputable def localizedFunctor : D₁ ⥤ D₂ :=
lift (Φ.functor ⋙ L₂) (Φ.inverts _) L₁
noncomputable instance liftingLocalizedFunctor :
Lifting L₁ W₁ (Φ.functor ⋙ L₂) (Φ.localizedFunctor L₁ L₂) := by
dsimp [localizedFunctor]
infer_instance
/-- The 2-commutative square expressing that `Φ.localizedFunctor L₁ L₂` lifts the
functor `Φ.functor` -/
noncomputable instance catCommSq : CatCommSq Φ.functor L₁ L₂ (Φ.localizedFunctor L₁ L₂) :=
CatCommSq.mk (Lifting.iso _ W₁ _ _).symm
variable (G : D₁ ⥤ D₂)
section
variable [CatCommSq Φ.functor L₁ L₂ G]
{D₁' : Type u₄'} {D₂' : Type u₅'}
[Category.{v₄'} D₁'] [Category.{v₅'} D₂']
(L₁' : C₁ ⥤ D₁') (L₂' : C₂ ⥤ D₂') [L₁'.IsLocalization W₁] [L₂'.IsLocalization W₂]
(G' : D₁' ⥤ D₂') [CatCommSq Φ.functor L₁' L₂' G']
include W₁ W₂ Φ L₁ L₂ L₁' L₂'
/-- If a localizer morphism induces an equivalence on some choice of localized categories,
it will be so for any choice of localized categories. -/
lemma isEquivalence_imp [G.IsEquivalence] : G'.IsEquivalence :=
let E₁ := Localization.uniq L₁ L₁' W₁
let E₂ := Localization.uniq L₂ L₂' W₂
let e : L₁ ⋙ G ⋙ E₂.functor ≅ L₁ ⋙ E₁.functor ⋙ G' :=
calc
L₁ ⋙ G ⋙ E₂.functor ≅ Φ.functor ⋙ L₂ ⋙ E₂.functor :=
(associator _ _ _).symm ≪≫
isoWhiskerRight (CatCommSq.iso Φ.functor L₁ L₂ G).symm E₂.functor ≪≫
associator _ _ _
_ ≅ Φ.functor ⋙ L₂' := isoWhiskerLeft Φ.functor (compUniqFunctor L₂ L₂' W₂)
_ ≅ L₁' ⋙ G' := CatCommSq.iso Φ.functor L₁' L₂' G'
_ ≅ L₁ ⋙ E₁.functor ⋙ G' :=
isoWhiskerRight (compUniqFunctor L₁ L₁' W₁).symm G' ≪≫ associator _ _ _
have := Functor.isEquivalence_of_iso
(liftNatIso L₁ W₁ _ _ (G ⋙ E₂.functor) (E₁.functor ⋙ G') e)
Functor.isEquivalence_of_comp_left E₁.functor G'
lemma isEquivalence_iff : G.IsEquivalence ↔ G'.IsEquivalence :=
⟨fun _ => Φ.isEquivalence_imp L₁ L₂ G L₁' L₂' G',
fun _ => Φ.isEquivalence_imp L₁' L₂' G' L₁ L₂ G⟩
end
/-- Condition that a `LocalizerMorphism` induces an equivalence on the localized categories -/
class IsLocalizedEquivalence : Prop where
/-- the induced functor on the constructed localized categories is an equivalence -/
isEquivalence : (Φ.localizedFunctor W₁.Q W₂.Q).IsEquivalence
lemma IsLocalizedEquivalence.mk' [CatCommSq Φ.functor L₁ L₂ G] [G.IsEquivalence] :
Φ.IsLocalizedEquivalence where
isEquivalence := by
rw [Φ.isEquivalence_iff W₁.Q W₂.Q (Φ.localizedFunctor W₁.Q W₂.Q) L₁ L₂ G]
exact inferInstance
/-- If a `LocalizerMorphism` is a localized equivalence, then any compatible functor
between the localized categories is an equivalence. -/
lemma isEquivalence [h : Φ.IsLocalizedEquivalence] [CatCommSq Φ.functor L₁ L₂ G] :
G.IsEquivalence := (by
rw [Φ.isEquivalence_iff L₁ L₂ G W₁.Q W₂.Q (Φ.localizedFunctor W₁.Q W₂.Q)]
exact h.isEquivalence)
/-- If a `LocalizerMorphism` is a localized equivalence, then the induced functor on
the localized categories is an equivalence -/
instance localizedFunctor_isEquivalence [Φ.IsLocalizedEquivalence] :
(Φ.localizedFunctor L₁ L₂).IsEquivalence :=
Φ.isEquivalence L₁ L₂ _
/-- When `Φ : LocalizerMorphism W₁ W₂`, if the composition `Φ.functor ⋙ L₂` is a
localization functor for `W₁`, then `Φ` is a localized equivalence. -/
lemma IsLocalizedEquivalence.of_isLocalization_of_isLocalization
[(Φ.functor ⋙ L₂).IsLocalization W₁] :
IsLocalizedEquivalence Φ := by
have : CatCommSq Φ.functor (Φ.functor ⋙ L₂) L₂ (𝟭 D₂) :=
CatCommSq.mk (rightUnitor _).symm
exact IsLocalizedEquivalence.mk' Φ (Φ.functor ⋙ L₂) L₂ (𝟭 D₂)
/-- When the underlying functor `Φ.functor` of `Φ : LocalizerMorphism W₁ W₂` is
an equivalence of categories and that `W₁` and `W₂` essentially correspond to each
other via this equivalence, then `Φ` is a localized equivalence. -/
lemma IsLocalizedEquivalence.of_equivalence [Φ.functor.IsEquivalence]
(h : W₂ ≤ W₁.map Φ.functor) : IsLocalizedEquivalence Φ := by
haveI : Functor.IsLocalization (Φ.functor ⋙ MorphismProperty.Q W₂) W₁ := by
refine Functor.IsLocalization.of_equivalence_source W₂.Q W₂ (Φ.functor ⋙ W₂.Q) W₁
(asEquivalence Φ.functor).symm ?_ (Φ.inverts W₂.Q)
((associator _ _ _).symm ≪≫ isoWhiskerRight ((Equivalence.unitIso _).symm) _ ≪≫
leftUnitor _)
erw [W₁.isoClosure.inverseImage_equivalence_functor_eq_map_inverse]
rw [MorphismProperty.map_isoClosure]
exact h
exact IsLocalizedEquivalence.of_isLocalization_of_isLocalization Φ W₂.Q
instance IsLocalizedEquivalence.isLocalization [Φ.IsLocalizedEquivalence] :
(Φ.functor ⋙ L₂).IsLocalization W₁ :=
Functor.IsLocalization.of_iso _ ((Φ.catCommSq W₁.Q L₂).iso).symm
lemma isLocalizedEquivalence_of_unit_of_unit (Ψ : LocalizerMorphism W₂ W₁)
(ε₁ : 𝟭 C₁ ⟶ Φ.functor ⋙ Ψ.functor) (ε₂ : 𝟭 C₂ ⟶ Ψ.functor ⋙ Φ.functor)
(hε₁ : ∀ X₁, W₁ (ε₁.app X₁)) (hε₂ : ∀ X₂, W₂ (ε₂.app X₂)) :
Φ.IsLocalizedEquivalence where
isEquivalence := by
have : IsIso (whiskerRight ε₁ W₁.Q) := by
rw [NatTrans.isIso_iff_isIso_app]
exact fun _ ↦ Localization.inverts W₁.Q W₁ _ (hε₁ _)
have : IsIso (whiskerRight ε₂ W₂.Q) := by
rw [NatTrans.isIso_iff_isIso_app]
exact fun _ ↦ Localization.inverts W₂.Q W₂ _ (hε₂ _)
refine (Localization.equivalence W₁.Q W₁ W₂.Q W₂ (Φ.functor ⋙ W₂.Q)
(Φ.localizedFunctor W₁.Q W₂.Q)
(Ψ.functor ⋙ W₁.Q) (Ψ.localizedFunctor W₂.Q W₁.Q) ?_ ?_).isEquivalence_functor
· exact Functor.associator _ _ _ ≪≫
isoWhiskerLeft _ (CatCommSq.iso Ψ.functor W₂.Q W₁.Q _).symm ≪≫
(Functor.associator _ _ _).symm ≪≫
(asIso (whiskerRight ε₁ W₁.Q)).symm ≪≫ Functor.leftUnitor _
· exact Functor.associator _ _ _ ≪≫
isoWhiskerLeft _ (CatCommSq.iso Φ.functor W₁.Q W₂.Q _).symm ≪≫
(Functor.associator _ _ _).symm ≪≫
(asIso (whiskerRight ε₂ W₂.Q)).symm ≪≫ Functor.leftUnitor _
/-- The localizer morphism from `W₁.arrow` to `W₂.arrow` that is induced by
`Φ : LocalizerMorphism W₁ W₂`. -/
@[simps]
def arrow : LocalizerMorphism W₁.arrow W₂.arrow where
functor := Φ.functor.mapArrow
map _ _ _ hf := ⟨Φ.map _ hf.1, Φ.map _ hf.2⟩
end LocalizerMorphism
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Localization/Bousfield.lean | import Mathlib.CategoryTheory.ObjectProperty.Local
import Mathlib.CategoryTheory.MorphismProperty.Composition
import Mathlib.CategoryTheory.Localization.Adjunction
/-!
# Bousfield localization
Given a predicate `P : ObjectProperty C` on the objects of a category `C`,
we define `Localization.LeftBousfield.W P : MorphismProperty C`
as the class of morphisms `f : X ⟶ Y` such that for any `Z : C`
such that `P Z`, the precomposition with `f` induces a bijection
`(Y ⟶ Z) ≃ (X ⟶ Z)`.
(This construction is part of left Bousfield localization
in the context of model categories.)
When `G ⊣ F` is an adjunction with `F : C ⥤ D` fully faithful, then
`G : D ⥤ C` is a localization functor for the class `W (· ∈ Set.range F.obj)`,
which then identifies to the inverse image by `G` of the class of
isomorphisms in `C`.
## References
* https://ncatlab.org/nlab/show/left+Bousfield+localization+of+model+categories
-/
namespace CategoryTheory
open Category
variable {C D : Type*} [Category C] [Category D]
namespace Localization
namespace LeftBousfield
section
variable (P : ObjectProperty C)
/-- Given `P : ObjectProperty C`, this is the class of morphisms `f : X ⟶ Y`
such that for all `Z : C` such that `P Z`, the precomposition with `f` induces
a bijection `(Y ⟶ Z) ≃ (X ⟶ Z)`. -/
def W : MorphismProperty C := fun _ _ f =>
∀ Z, P Z → Function.Bijective (fun (g : _ ⟶ Z) => f ≫ g)
variable {P} in
/-- The bijection `(Y ⟶ Z) ≃ (X ⟶ Z)` induced by `f : X ⟶ Y` when `LeftBousfield.W P f`
and `P Z`. -/
@[simps! apply]
noncomputable def W.homEquiv {X Y : C} {f : X ⟶ Y} (hf : W P f) (Z : C) (hZ : P Z) :
(Y ⟶ Z) ≃ (X ⟶ Z) :=
Equiv.ofBijective _ (hf Z hZ)
lemma W_isoClosure : W P.isoClosure = W P := by
ext X Y f
constructor
· intro hf Z hZ
exact hf _ (P.le_isoClosure _ hZ)
· rintro hf Z ⟨Z', hZ', ⟨e⟩⟩
constructor
· intro g₁ g₂ eq
rw [← cancel_mono e.hom]
apply (hf _ hZ').1
simp only [reassoc_of% eq]
· intro g
obtain ⟨a, h⟩ := (hf _ hZ').2 (g ≫ e.hom)
exact ⟨a ≫ e.inv, by simp only [reassoc_of% h, e.hom_inv_id, comp_id]⟩
instance : (W P).IsMultiplicative where
id_mem X Z _ := by simpa [id_comp] using Function.bijective_id
comp_mem f g hf hg Z hZ := by
simpa using Function.Bijective.comp (hf Z hZ) (hg Z hZ)
instance : (W P).HasTwoOutOfThreeProperty where
of_postcomp f g hg hfg Z hZ := by
rw [← Function.Bijective.of_comp_iff _ (hg Z hZ)]
simpa using hfg Z hZ
of_precomp f g hf hfg Z hZ := by
rw [← Function.Bijective.of_comp_iff' (hf Z hZ)]
simpa using hfg Z hZ
lemma W_of_isIso {X Y : C} (f : X ⟶ Y) [IsIso f] : W P f := fun Z _ => by
constructor
· intro g₁ g₂ _
simpa only [← cancel_epi f]
· intro g
exact ⟨inv f ≫ g, by simp⟩
lemma W_iff_isIso {X Y : C} (f : X ⟶ Y) (hX : P X) (hY : P Y) :
W P f ↔ IsIso f := by
constructor
· intro hf
obtain ⟨g, hg⟩ := (hf _ hX).2 (𝟙 X)
exact ⟨g, hg, (hf _ hY).1 (by simp only [reassoc_of% hg, comp_id])⟩
· apply W_of_isIso
instance : (W P).RespectsIso where
precomp f (_ : IsIso f) g hg := (W P).comp_mem f g (W_of_isIso _ f) hg
postcomp f (_ : IsIso f) g hg := (W P).comp_mem g f hg (W_of_isIso _ f)
lemma le_W_iff (P : ObjectProperty C) (W : MorphismProperty C) :
W ≤ LeftBousfield.W P ↔ P ≤ W.isLocal :=
⟨fun h _ hZ _ _ _ hf ↦ h _ hf _ hZ,
fun h _ _ _ hf _ hZ ↦ h _ hZ _ hf⟩
lemma galoisConnection :
GaloisConnection (OrderDual.toDual ∘ W (C := C))
(MorphismProperty.isLocal ∘ OrderDual.ofDual) :=
le_W_iff
end
section
variable {F : C ⥤ D} {G : D ⥤ C} (adj : G ⊣ F) [F.Full] [F.Faithful]
include adj
lemma W_adj_unit_app (X : D) : W (· ∈ Set.range F.obj) (adj.unit.app X) := by
rintro _ ⟨Y, rfl⟩
convert ((Functor.FullyFaithful.ofFullyFaithful F).homEquiv.symm.trans
(adj.homEquiv X Y)).bijective using 1
dsimp [Adjunction.homEquiv]
aesop
lemma W_iff_isIso_map {X Y : D} (f : X ⟶ Y) :
W (· ∈ Set.range F.obj) f ↔ IsIso (G.map f) := by
rw [← (W (· ∈ Set.range F.obj)).postcomp_iff _ _ (W_adj_unit_app adj Y)]
erw [adj.unit.naturality f]
rw [(W (· ∈ Set.range F.obj)).precomp_iff _ _ (W_adj_unit_app adj X),
W_iff_isIso _ _ ⟨_, rfl⟩ ⟨_, rfl⟩]
constructor
· intro h
dsimp at h
exact isIso_of_fully_faithful F (G.map f)
· intro
rw [Functor.comp_map]
infer_instance
lemma W_eq_inverseImage_isomorphisms :
W (· ∈ Set.range F.obj) = (MorphismProperty.isomorphisms _).inverseImage G := by
ext P₁ P₂ f
rw [W_iff_isIso_map adj]
rfl
lemma isLocalization : G.IsLocalization (W (· ∈ Set.range F.obj)) := by
rw [W_eq_inverseImage_isomorphisms adj]
exact adj.isLocalization
end
end LeftBousfield
end Localization
open Localization
lemma ObjectProperty.le_isLocal_W (P : ObjectProperty C) :
P ≤ (LeftBousfield.W P).isLocal := by
rw [← LeftBousfield.le_W_iff]
lemma MorphismProperty.le_leftBousfieldW_isLocal (W : MorphismProperty C) :
W ≤ LeftBousfield.W W.isLocal := by
rw [LeftBousfield.le_W_iff]
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Localization/HasLocalization.lean | import Mathlib.CategoryTheory.Localization.Predicate
/-! Morphism properties equipped with a localized category
If `C : Type u` is a category (with `[Category.{v} C]`), and
`W : MorphismProperty C`, then the constructed localized
category `W.Localization` is in `Type u` (the objects are
essentially the same as that of `C`), but the morphisms
are in `Type (max u v)`. In particular situations, it
may happen that there is a localized category for `W`
whose morphisms are in a lower universe like `v`: it shall
be so for the homotopy categories of model categories (TODO),
and it should also be so for the derived categories of
Grothendieck abelian categories (TODO: but this shall be
very technical).
Then, in order to allow the user to provide a localized
category with specific universe parameters when it exists,
we introduce a typeclass `MorphismProperty.HasLocalization.{w} W`
which contains the data of a localized category `D` for `W`
with `D : Type u` and `[Category.{w} D]`. Then, all
definitions which involve "the" localized category
for `W` should contain a `[MorphismProperty.HasLocalization.{w} W]`
assumption for a suitable `w`. The functor `W.Q' : C ⥤ W.Localization'`
shall be the localization functor for this fixed choice of the
localized category. If the statement of a theorem does not
involve the localized category, but the proof does,
it is no longer necessary to use a `HasLocalization`
assumption, but one may use
`HasLocalization.standard` in the proof instead.
-/
universe w v u
namespace CategoryTheory
variable {C : Type u} [Category.{v} C]
variable (W : MorphismProperty C)
namespace MorphismProperty
/-- The data of a localized category with a given universe
for the morphisms. -/
class HasLocalization where
/-- the objects of the localized category. -/
{D : Type u}
/-- the category structure. -/
[hD : Category.{w} D]
/-- the localization functor. -/
L : C ⥤ D
[hL : L.IsLocalization W]
variable [HasLocalization.{w} W]
/-- The localized category for `W : MorphismProperty C`
that is fixed by the `[HasLocalization W]` instance. -/
def Localization' := HasLocalization.D W
instance : Category W.Localization' := HasLocalization.hD
/-- The localization functor `C ⥤ W.Localization'`
that is fixed by the `[HasLocalization W]` instance. -/
def Q' : C ⥤ W.Localization' := HasLocalization.L
instance : W.Q'.IsLocalization W := HasLocalization.hL
/-- The constructed localized category. -/
def HasLocalization.standard : HasLocalization.{max u v} W where
L := W.Q
end MorphismProperty
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Localization/Adjunction.lean | import Mathlib.CategoryTheory.CatCommSq
import Mathlib.CategoryTheory.Localization.Predicate
import Mathlib.CategoryTheory.Adjunction.FullyFaithful
/-!
# Localization of adjunctions
In this file, we show that if we have an adjunction `adj : G ⊣ F` such that both
functors `G : C₁ ⥤ C₂` and `F : C₂ ⥤ C₁` induce functors
`G' : D₁ ⥤ D₂` and `F' : D₂ ⥤ D₁` on localized categories, i.e. that we
have localization functors `L₁ : C₁ ⥤ D₁` and `L₂ : C₂ ⥤ D₂` with respect
to morphism properties `W₁` and `W₂` respectively, and 2-commutative diagrams
`[CatCommSq G L₁ L₂ G']` and `[CatCommSq F L₂ L₁ F']`, then we have an
induced adjunction `Adjunction.localization L₁ W₁ L₂ W₂ G' F' : G' ⊣ F'`.
-/
namespace CategoryTheory
open Localization Category Functor
namespace Adjunction
variable {C₁ C₂ D₁ D₂ : Type*} [Category C₁] [Category C₂] [Category D₁] [Category D₂]
{G : C₁ ⥤ C₂} {F : C₂ ⥤ C₁} (adj : G ⊣ F)
section
variable (L₁ : C₁ ⥤ D₁) (W₁ : MorphismProperty C₁) [L₁.IsLocalization W₁]
(L₂ : C₂ ⥤ D₂) (W₂ : MorphismProperty C₂) [L₂.IsLocalization W₂]
(G' : D₁ ⥤ D₂) (F' : D₂ ⥤ D₁)
[CatCommSq G L₁ L₂ G'] [CatCommSq F L₂ L₁ F']
namespace Localization
/-- Auxiliary definition of the unit morphism for the adjunction `Adjunction.localization` -/
noncomputable def ε : 𝟭 D₁ ⟶ G' ⋙ F' := by
letI : Lifting L₁ W₁ ((G ⋙ F) ⋙ L₁) (G' ⋙ F') :=
Lifting.mk (CatCommSq.hComp G F L₁ L₂ L₁ G' F').iso.symm
exact Localization.liftNatTrans L₁ W₁ L₁ ((G ⋙ F) ⋙ L₁) (𝟭 D₁) (G' ⋙ F')
(whiskerRight adj.unit L₁)
lemma ε_app (X₁ : C₁) :
(ε adj L₁ W₁ L₂ G' F').app (L₁.obj X₁) =
L₁.map (adj.unit.app X₁) ≫ (CatCommSq.iso F L₂ L₁ F').hom.app (G.obj X₁) ≫
F'.map ((CatCommSq.iso G L₁ L₂ G').hom.app X₁) := by
letI : Lifting L₁ W₁ ((G ⋙ F) ⋙ L₁) (G' ⋙ F') :=
Lifting.mk (CatCommSq.hComp G F L₁ L₂ L₁ G' F').iso.symm
simp only [ε, liftNatTrans_app, Lifting.iso, Iso.symm,
Functor.id_obj, Functor.comp_obj, Functor.rightUnitor_hom_app,
whiskerRight_app, CatCommSq.hComp_iso_hom_app, id_comp]
/-- Auxiliary definition of the counit morphism for the adjunction `Adjunction.localization` -/
noncomputable def η : F' ⋙ G' ⟶ 𝟭 D₂ := by
letI : Lifting L₂ W₂ ((F ⋙ G) ⋙ L₂) (F' ⋙ G') :=
Lifting.mk (CatCommSq.hComp F G L₂ L₁ L₂ F' G').iso.symm
exact liftNatTrans L₂ W₂ ((F ⋙ G) ⋙ L₂) L₂ (F' ⋙ G') (𝟭 D₂) (whiskerRight adj.counit L₂)
lemma η_app (X₂ : C₂) :
(η adj L₁ L₂ W₂ G' F').app (L₂.obj X₂) =
G'.map ((CatCommSq.iso F L₂ L₁ F').inv.app X₂) ≫
(CatCommSq.iso G L₁ L₂ G').inv.app (F.obj X₂) ≫
L₂.map (adj.counit.app X₂) := by
letI : Lifting L₂ W₂ ((F ⋙ G) ⋙ L₂) (F' ⋙ G') :=
Lifting.mk (CatCommSq.hComp F G L₂ L₁ L₂ F' G').iso.symm
simp only [η, liftNatTrans_app, Lifting.iso, Iso.symm, CatCommSq.hComp_iso_inv_app,
whiskerRight_app, Functor.rightUnitor_inv_app, comp_id, assoc]
end Localization
/-- If `adj : G ⊣ F` is an adjunction between two categories `C₁` and `C₂` that
are equipped with localization functors `L₁ : C₁ ⥤ D₁` and `L₂ : C₂ ⥤ D₂` with
respect to `W₁ : MorphismProperty C₁` and `W₂ : MorphismProperty C₂`, and that
the functors `F : C₂ ⥤ C₁` and `G : C₁ ⥤ C₂` induce functors `F' : D₂ ⥤ D₁`
and `G' : D₁ ⥤ D₂` on the localized categories, then the adjunction `adj`
induces an adjunction `G' ⊣ F'`. -/
noncomputable def localization : G' ⊣ F' :=
Adjunction.mkOfUnitCounit
{ unit := Localization.ε adj L₁ W₁ L₂ G' F'
counit := Localization.η adj L₁ L₂ W₂ G' F'
left_triangle := by
apply natTrans_ext L₁ W₁
intro X₁
have eq := congr_app adj.left_triangle X₁
dsimp at eq
rw [NatTrans.comp_app, NatTrans.comp_app, whiskerRight_app, Localization.ε_app,
Functor.associator_hom_app, id_comp, whiskerLeft_app, G'.map_comp, G'.map_comp,
assoc, assoc]
erw [(Localization.η adj L₁ L₂ W₂ G' F').naturality, Localization.η_app,
assoc, assoc, ← G'.map_comp_assoc, ← G'.map_comp_assoc, assoc, Iso.hom_inv_id_app,
comp_id, (CatCommSq.iso G L₁ L₂ G').inv.naturality_assoc, ← L₂.map_comp_assoc, eq,
L₂.map_id, id_comp, Iso.inv_hom_id_app]
rfl
right_triangle := by
apply natTrans_ext L₂ W₂
intro X₂
have eq := congr_app adj.right_triangle X₂
dsimp at eq
rw [NatTrans.comp_app, NatTrans.comp_app, whiskerLeft_app, whiskerRight_app,
Localization.η_app, Functor.associator_inv_app, id_comp, F'.map_comp, F'.map_comp]
erw [← (Localization.ε _ _ _ _ _ _).naturality_assoc, Localization.ε_app,
assoc, assoc, ← F'.map_comp_assoc, Iso.hom_inv_id_app, F'.map_id, id_comp,
← NatTrans.naturality, ← L₁.map_comp_assoc, eq, L₁.map_id, id_comp,
Iso.inv_hom_id_app]
rfl }
@[simp]
lemma localization_unit_app (X₁ : C₁) :
(adj.localization L₁ W₁ L₂ W₂ G' F').unit.app (L₁.obj X₁) =
L₁.map (adj.unit.app X₁) ≫ (CatCommSq.iso F L₂ L₁ F').hom.app (G.obj X₁) ≫
F'.map ((CatCommSq.iso G L₁ L₂ G').hom.app X₁) := by
apply Localization.ε_app
@[simp]
lemma localization_counit_app (X₂ : C₂) :
(adj.localization L₁ W₁ L₂ W₂ G' F').counit.app (L₂.obj X₂) =
G'.map ((CatCommSq.iso F L₂ L₁ F').inv.app X₂) ≫
(CatCommSq.iso G L₁ L₂ G').inv.app (F.obj X₂) ≫
L₂.map (adj.counit.app X₂) := by
apply Localization.η_app
end
include adj in
lemma isLocalization [F.Full] [F.Faithful] :
G.IsLocalization ((MorphismProperty.isomorphisms C₂).inverseImage G) := by
let W := ((MorphismProperty.isomorphisms C₂).inverseImage G)
have hG : W.IsInvertedBy G := fun _ _ _ hf => hf
have : ∀ (X : C₁), IsIso ((whiskerRight adj.unit W.Q).app X) := fun X =>
Localization.inverts W.Q W _ (by
change IsIso _
infer_instance)
have : IsIso (whiskerRight adj.unit W.Q) := NatIso.isIso_of_isIso_app _
let e : W.Localization ≌ C₂ := Equivalence.mk (Localization.lift G hG W.Q) (F ⋙ W.Q)
(liftNatIso W.Q W W.Q (G ⋙ F ⋙ W.Q) _ _
(W.Q.leftUnitor.symm ≪≫ asIso (whiskerRight adj.unit W.Q)))
(Functor.associator _ _ _ ≪≫ isoWhiskerLeft _ (Localization.fac G hG W.Q) ≪≫
asIso adj.counit)
apply Functor.IsLocalization.of_equivalence_target W.Q W G e
(Localization.fac G hG W.Q)
end Adjunction
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Localization/SmallHom.lean | import Mathlib.CategoryTheory.Localization.HomEquiv
import Mathlib.Logic.Small.Defs
/-!
# Shrinking morphisms in localized categories
Given a class of morphisms `W : MorphismProperty C`, and two objects `X` and `Y`,
we introduce a type-class `HasSmallLocalizedHom.{w} W X Y` which expresses
that in the localized category with respect to `W`, the type of morphisms from `X`
to `Y` is `w`-small for a certain universe `w`. Under this assumption,
we define `SmallHom.{w} W X Y : Type w` as the shrunk type. For any localization
functor `L : C ⥤ D` for `W`, we provide a bijection
`SmallHom.equiv.{w} W L : SmallHom.{w} W X Y ≃ (L.obj X ⟶ L.obj Y)` that is compatible
with the composition of morphisms.
-/
universe w'' w w' v₁ v₂ v₃ v₄ v₅ u₁ u₂ u₃ u₄ u₅
namespace CategoryTheory
open Category
namespace Localization
variable {C : Type u₁} [Category.{v₁} C] (W : MorphismProperty C)
{D : Type u₂} [Category.{v₂} D]
{D' : Type u₃} [Category.{v₃} D']
section
variable (L : C ⥤ D) [L.IsLocalization W] (X Y Z : C)
/-- This property holds if the type of morphisms between `X` and `Y`
in the localized category with respect to `W : MorphismProperty C`
is small. -/
class HasSmallLocalizedHom : Prop where
small : Small.{w} (W.Q.obj X ⟶ W.Q.obj Y)
attribute [instance] HasSmallLocalizedHom.small
variable {X Y Z}
lemma hasSmallLocalizedHom_iff :
HasSmallLocalizedHom.{w} W X Y ↔ Small.{w} (L.obj X ⟶ L.obj Y) := by
constructor
· intro h
exact small_map (homEquiv W W.Q L).symm
· intro h
exact ⟨small_map (homEquiv W W.Q L)⟩
include L in
lemma hasSmallLocalizedHom_of_isLocalization :
HasSmallLocalizedHom.{v₂} W X Y := by
rw [hasSmallLocalizedHom_iff W L]
infer_instance
variable (X Y) in
lemma small_of_hasSmallLocalizedHom [HasSmallLocalizedHom.{w} W X Y] :
Small.{w} (L.obj X ⟶ L.obj Y) := by
rwa [← hasSmallLocalizedHom_iff W]
lemma hasSmallLocalizedHom_iff_of_isos {X' Y' : C} (e : X ≅ X') (e' : Y ≅ Y') :
HasSmallLocalizedHom.{w} W X Y ↔ HasSmallLocalizedHom.{w} W X' Y' := by
simp only [hasSmallLocalizedHom_iff W W.Q]
exact small_congr (Iso.homCongr (W.Q.mapIso e) (W.Q.mapIso e'))
lemma hasSmallLocalizedHom_of_isos {X' Y' : C} (e : X ≅ X') (e' : Y ≅ Y')
[HasSmallLocalizedHom.{w} W X Y] :
HasSmallLocalizedHom.{w} W X' Y' := by
rwa [← hasSmallLocalizedHom_iff_of_isos _ e e']
variable (X) in
lemma hasSmallLocalizedHom_iff_target {Y Y' : C} (f : Y ⟶ Y') (hf : W f) :
HasSmallLocalizedHom.{w} W X Y ↔ HasSmallLocalizedHom.{w} W X Y' := by
simp only [hasSmallLocalizedHom_iff W W.Q]
exact small_congr (Iso.homCongr (Iso.refl _) (Localization.isoOfHom W.Q W f hf))
lemma hasSmallLocalizedHom_iff_source {X' : C} (f : X ⟶ X') (hf : W f) (Y : C) :
HasSmallLocalizedHom.{w} W X Y ↔ HasSmallLocalizedHom.{w} W X' Y := by
simp only [hasSmallLocalizedHom_iff W W.Q]
exact small_congr (Iso.homCongr (Localization.isoOfHom W.Q W f hf) (Iso.refl _))
end
/-- The type of morphisms from `X` to `Y` in the localized category
with respect to `W : MorphismProperty C` that is shrunk to `Type w`
when `HasSmallLocalizedHom.{w} W X Y` holds. -/
def SmallHom (X Y : C) [HasSmallLocalizedHom.{w} W X Y] : Type w :=
Shrink.{w} (W.Q.obj X ⟶ W.Q.obj Y)
namespace SmallHom
/-- The canonical bijection `SmallHom.{w} W X Y ≃ (L.obj X ⟶ L.obj Y)`
when `L` is a localization functor for `W : MorphismProperty C` and
that `HasSmallLocalizedHom.{w} W X Y` holds. -/
noncomputable def equiv (L : C ⥤ D) [L.IsLocalization W] {X Y : C}
[HasSmallLocalizedHom.{w} W X Y] :
SmallHom.{w} W X Y ≃ (L.obj X ⟶ L.obj Y) :=
letI := small_of_hasSmallLocalizedHom.{w} W W.Q X Y
(equivShrink _).symm.trans (homEquiv W W.Q L)
lemma equiv_equiv_symm (L : C ⥤ D) [L.IsLocalization W]
(L' : C ⥤ D') [L'.IsLocalization W] (G : D ⥤ D')
(e : L ⋙ G ≅ L') {X Y : C} [HasSmallLocalizedHom.{w} W X Y]
(f : L.obj X ⟶ L.obj Y) :
equiv W L' ((equiv W L).symm f) =
e.inv.app X ≫ G.map f ≫ e.hom.app Y := by
dsimp [equiv]
rw [Equiv.symm_apply_apply, homEquiv_trans]
apply homEquiv_eq
/-- The element in `SmallHom W X Y` induced by `f : X ⟶ Y`. -/
noncomputable def mk {X Y : C} [HasSmallLocalizedHom.{w} W X Y] (f : X ⟶ Y) :
SmallHom.{w} W X Y :=
(equiv.{w} W W.Q).symm (W.Q.map f)
@[simp]
lemma equiv_mk (L : C ⥤ D) [L.IsLocalization W] {X Y : C}
[HasSmallLocalizedHom.{w} W X Y] (f : X ⟶ Y) :
equiv.{w} W L (mk W f) = L.map f := by
simp [equiv, mk]
variable {W}
/-- The formal inverse in `SmallHom W X Y` of a morphism `f : Y ⟶ X` such that `W f`. -/
noncomputable def mkInv {X Y : C} (f : Y ⟶ X) (hf : W f) [HasSmallLocalizedHom.{w} W X Y] :
SmallHom.{w} W X Y :=
(equiv.{w} W W.Q).symm (Localization.isoOfHom W.Q W f hf).inv
@[simp]
lemma equiv_mkInv (L : C ⥤ D) [L.IsLocalization W] {X Y : C} (f : Y ⟶ X) (hf : W f)
[HasSmallLocalizedHom.{w} W X Y] :
equiv.{w} W L (mkInv f hf) = (Localization.isoOfHom L W f hf).inv := by
simp only [equiv, mkInv, Equiv.symm_trans_apply, Equiv.symm_symm, homEquiv_symm_apply,
Equiv.trans_apply, Equiv.symm_apply_apply, homEquiv_isoOfHom_inv]
/-- The composition on `SmallHom W`. -/
noncomputable def comp {X Y Z : C} [HasSmallLocalizedHom.{w} W X Y]
[HasSmallLocalizedHom.{w} W Y Z] [HasSmallLocalizedHom.{w} W X Z]
(α : SmallHom.{w} W X Y) (β : SmallHom.{w} W Y Z) :
SmallHom.{w} W X Z :=
(equiv W W.Q).symm (equiv W W.Q α ≫ equiv W W.Q β)
lemma equiv_comp (L : C ⥤ D) [L.IsLocalization W] {X Y Z : C} [HasSmallLocalizedHom.{w} W X Y]
[HasSmallLocalizedHom.{w} W Y Z] [HasSmallLocalizedHom.{w} W X Z]
(α : SmallHom.{w} W X Y) (β : SmallHom.{w} W Y Z) :
equiv W L (α.comp β) = equiv W L α ≫ equiv W L β := by
letI := small_of_hasSmallLocalizedHom.{w} W W.Q X Y
letI := small_of_hasSmallLocalizedHom.{w} W W.Q Y Z
obtain ⟨α, rfl⟩ := (equivShrink _).surjective α
obtain ⟨β, rfl⟩ := (equivShrink _).surjective β
dsimp [equiv, comp]
rw [Equiv.symm_apply_apply]
simp only [homEquiv_refl, homEquiv_comp]
section
variable {X Y Z T : C}
lemma mk_comp_mk [HasSmallLocalizedHom.{w} W X Y] [HasSmallLocalizedHom.{w} W Y Z]
[HasSmallLocalizedHom.{w} W X Z] (f : X ⟶ Y) (g : Y ⟶ Z) :
(mk W f).comp (mk W g) = mk W (f ≫ g) :=
(equiv W W.Q).injective (by simp [equiv_comp])
@[simp]
lemma comp_mk_id [HasSmallLocalizedHom.{w} W X Y] [HasSmallLocalizedHom.{w} W Y Y]
(α : SmallHom.{w} W X Y) :
α.comp (mk W (𝟙 Y)) = α :=
(equiv W W.Q).injective (by simp [equiv_comp])
@[simp]
lemma mk_id_comp [HasSmallLocalizedHom.{w} W X Y] [HasSmallLocalizedHom.{w} W X X]
(α : SmallHom.{w} W X Y) :
(mk W (𝟙 X)).comp α = α :=
(equiv W W.Q).injective (by simp [equiv_comp])
@[simp]
lemma comp_assoc [HasSmallLocalizedHom.{w} W X Y] [HasSmallLocalizedHom.{w} W X Z]
[HasSmallLocalizedHom.{w} W X T] [HasSmallLocalizedHom.{w} W Y Z]
[HasSmallLocalizedHom.{w} W Y T] [HasSmallLocalizedHom.{w} W Z T]
(α : SmallHom.{w} W X Y) (β : SmallHom.{w} W Y Z) (γ : SmallHom.{w} W Z T) :
(α.comp β).comp γ = α.comp (β.comp γ) := by
apply (equiv W W.Q).injective
simp only [equiv_comp, assoc]
@[simp]
lemma mk_comp_mkInv [HasSmallLocalizedHom.{w} W X Y] [HasSmallLocalizedHom.{w} W Y X]
[HasSmallLocalizedHom.{w} W Y Y] (f : Y ⟶ X) (hf : W f) :
(mk W f).comp (mkInv f hf) = mk W (𝟙 Y) :=
(equiv W W.Q).injective (by simp [equiv_comp])
@[simp]
lemma mkInv_comp_mk [HasSmallLocalizedHom.{w} W X X] [HasSmallLocalizedHom.{w} W X Y]
[HasSmallLocalizedHom.{w} W Y X] (f : Y ⟶ X) (hf : W f) :
(mkInv f hf).comp (mk W f) = mk W (𝟙 X) :=
(equiv W W.Q).injective (by simp [equiv_comp])
end
section ChangeOfUniverse
/-- Up to an equivalence, the type `SmallHom.{w} W X Y n` does not depend on the universe `w`. -/
noncomputable def chgUniv {X Y : C}
[HasSmallLocalizedHom.{w} W X Y] [HasSmallLocalizedHom.{w''} W X Y] :
SmallHom.{w} W X Y ≃ SmallHom.{w''} W X Y :=
(equiv.{w} W W.Q).trans (equiv.{w''} W W.Q).symm
lemma equiv_chgUniv (L : C ⥤ D) [L.IsLocalization W] {X Y : C}
[HasSmallLocalizedHom.{w} W X Y] [HasSmallLocalizedHom.{w''} W X Y]
(e : SmallHom.{w} W X Y) :
equiv W L (chgUniv.{w''} e) = equiv W L e := by
obtain ⟨f, rfl⟩ := (equiv W W.Q).symm.surjective e
dsimp [chgUniv]
simp only [Equiv.apply_symm_apply,
equiv_equiv_symm W _ _ _ (Localization.compUniqFunctor W.Q L W)]
end ChangeOfUniverse
end SmallHom
end Localization
namespace LocalizerMorphism
open Localization
variable {C₁ : Type u₁} [Category.{v₁} C₁] {W₁ : MorphismProperty C₁}
{C₂ : Type u₂} [Category.{v₂} C₂] {W₂ : MorphismProperty C₂}
{D₁ : Type u₃} [Category.{v₃} D₁] {D₂ : Type u₄} [Category.{v₄} D₂]
(Φ : LocalizerMorphism W₁ W₂) (L₁ : C₁ ⥤ D₁) [L₁.IsLocalization W₁]
(L₂ : C₂ ⥤ D₂) [L₂.IsLocalization W₂]
section
variable {X Y : C₁}
variable [HasSmallLocalizedHom.{w} W₁ X Y]
[HasSmallLocalizedHom.{w'} W₂ (Φ.functor.obj X) (Φ.functor.obj Y)]
/-- The action of a localizer morphism on `SmallHom`. -/
noncomputable def smallHomMap (f : SmallHom.{w} W₁ X Y) :
SmallHom.{w'} W₂ (Φ.functor.obj X) (Φ.functor.obj Y) :=
(SmallHom.equiv W₂ W₂.Q).symm
(Iso.homCongr ((CatCommSq.iso Φ.functor W₁.Q W₂.Q _).symm.app _)
((CatCommSq.iso Φ.functor W₁.Q W₂.Q _).symm.app _)
((Φ.localizedFunctor W₁.Q W₂.Q).map ((SmallHom.equiv W₁ W₁.Q) f)))
lemma equiv_smallHomMap (G : D₁ ⥤ D₂) (e : Φ.functor ⋙ L₂ ≅ L₁ ⋙ G)
(f : SmallHom.{w} W₁ X Y) :
(SmallHom.equiv W₂ L₂) (Φ.smallHomMap f) =
e.hom.app X ≫ G.map (SmallHom.equiv W₁ L₁ f) ≫ e.inv.app Y := by
obtain ⟨g, rfl⟩ := (SmallHom.equiv W₁ W₁.Q).symm.surjective f
simp only [smallHomMap, Equiv.apply_symm_apply]
let G' := Φ.localizedFunctor W₁.Q W₂.Q
let β := CatCommSq.iso Φ.functor W₁.Q W₂.Q G'
let E₁ := (uniq W₁.Q L₁ W₁).functor
let α₁ : W₁.Q ⋙ E₁ ≅ L₁ := compUniqFunctor W₁.Q L₁ W₁
let E₂ := (uniq W₂.Q L₂ W₂).functor
let α₂ : W₂.Q ⋙ E₂ ≅ L₂ := compUniqFunctor W₂.Q L₂ W₂
rw [SmallHom.equiv_equiv_symm W₁ W₁.Q L₁ E₁ α₁,
SmallHom.equiv_equiv_symm W₂ W₂.Q L₂ E₂ α₂]
change α₂.inv.app _ ≫ E₂.map (β.hom.app X ≫ G'.map g ≫ β.inv.app Y) ≫ _ = _
let γ : G' ⋙ E₂ ≅ E₁ ⋙ G := liftNatIso W₁.Q W₁ (W₁.Q ⋙ G' ⋙ E₂) (W₁.Q ⋙ E₁ ⋙ G) _ _
((Functor.associator _ _ _).symm ≪≫ Functor.isoWhiskerRight β.symm E₂ ≪≫
Functor.associator _ _ _ ≪≫ Functor.isoWhiskerLeft _ α₂ ≪≫ e ≪≫
Functor.isoWhiskerRight α₁.symm G ≪≫ Functor.associator _ _ _)
have hγ : ∀ (X : C₁), γ.hom.app (W₁.Q.obj X) =
E₂.map (β.inv.app X) ≫ α₂.hom.app (Φ.functor.obj X) ≫
e.hom.app X ≫ G.map (α₁.inv.app X) := fun X ↦ by
simp [γ, id_comp, comp_id]
simp only [Functor.map_comp, assoc]
erw [← NatIso.naturality_1 γ]
simp only [Functor.comp_map, ← cancel_epi (e.inv.app X), ← cancel_epi (G.map (α₁.hom.app X)),
← cancel_epi (γ.hom.app (W₁.Q.obj X)), assoc, Iso.inv_hom_id_app_assoc,
← Functor.map_comp_assoc, Iso.hom_inv_id_app, Functor.map_id, id_comp,
Iso.hom_inv_id_app_assoc]
simp only [hγ, assoc, ← Functor.map_comp_assoc, Iso.inv_hom_id_app,
Functor.map_id, id_comp, Iso.hom_inv_id_app_assoc,
Iso.inv_hom_id_app_assoc, Iso.hom_inv_id_app, Functor.comp_obj, comp_id]
@[simp]
lemma smallHomMap_mk (f : X ⟶ Y) :
Φ.smallHomMap (SmallHom.mk _ f) =
SmallHom.mk _ (Φ.functor.map f) := by
apply (SmallHom.equiv W₂ W₂.Q).injective
simp [Φ.equiv_smallHomMap W₁.Q W₂.Q (Φ.localizedFunctor W₁.Q W₂.Q) (CatCommSq.iso _ _ _ _)]
end
section
variable {X Y Z : C₁}
variable [HasSmallLocalizedHom.{w} W₁ X Y] [HasSmallLocalizedHom.{w} W₁ Y Z]
[HasSmallLocalizedHom.{w} W₁ X Z]
[HasSmallLocalizedHom.{w'} W₂ (Φ.functor.obj X) (Φ.functor.obj Y)]
[HasSmallLocalizedHom.{w'} W₂ (Φ.functor.obj Y) (Φ.functor.obj Z)]
[HasSmallLocalizedHom.{w'} W₂ (Φ.functor.obj X) (Φ.functor.obj Z)]
lemma smallHomMap_comp (f : SmallHom.{w} W₁ X Y) (g : SmallHom.{w} W₁ Y Z) :
Φ.smallHomMap (f.comp g) = (Φ.smallHomMap f).comp (Φ.smallHomMap g) := by
apply (SmallHom.equiv W₂ W₂.Q).injective
simp [Φ.equiv_smallHomMap W₁.Q W₂.Q (Φ.localizedFunctor W₁.Q W₂.Q) (CatCommSq.iso _ _ _ _),
SmallHom.equiv_comp]
end
section
variable {X Y : C₁} [HasSmallLocalizedHom.{w} W₁ X Y] {X' Y' : C₂}
[HasSmallLocalizedHom.{w'} W₂ X' X']
[HasSmallLocalizedHom.{w'} W₂ X' Y']
[HasSmallLocalizedHom.{w'} W₂ Y' Y']
(eX : Φ.functor.obj X ≅ X') (eY : Φ.functor.obj Y ≅ Y')
/-- The action of a localizer morphism `Φ` on `SmallHom`. In this version, we allow
the replacement of objects `Φ.functor.obj` by isomorphic objects. -/
noncomputable def smallHomMap' (f : SmallHom.{w} W₁ X Y) :
SmallHom.{w'} W₂ X' Y' :=
have := hasSmallLocalizedHom_of_isos.{w'} W₂ eX.symm eY.symm
have := hasSmallLocalizedHom_of_isos.{w'} W₂ eX.symm (Iso.refl Y')
have := hasSmallLocalizedHom_of_isos.{w'} W₂ eY.symm (Iso.refl Y')
have := hasSmallLocalizedHom_of_isos.{w'} W₂ (Iso.refl X') eX.symm
(SmallHom.mk _ eX.inv).comp ((Φ.smallHomMap f).comp (SmallHom.mk _ eY.hom))
lemma equiv_smallHomMap' (G : D₁ ⥤ D₂) (e : Φ.functor ⋙ L₂ ≅ L₁ ⋙ G)
(f : SmallHom.{w} W₁ X Y) :
SmallHom.equiv W₂ L₂ (Φ.smallHomMap' eX eY f) =
L₂.map eX.inv ≫ e.hom.app X ≫ G.map (SmallHom.equiv W₁ L₁ f) ≫
e.inv.app Y ≫ L₂.map eY.hom := by
have := hasSmallLocalizedHom_of_isos.{w'} W₂ eY.symm (Iso.refl Y')
simp [smallHomMap', SmallHom.equiv_comp, Φ.equiv_smallHomMap L₁ L₂ G e]
@[simp]
lemma smallHomMap'_mk (f : X ⟶ Y) :
Φ.smallHomMap' eX eY (SmallHom.mk _ f) =
SmallHom.mk _ (eX.inv ≫ Φ.functor.map f ≫ eY.hom) := by
simp [smallHomMap', SmallHom.mk_comp_mk]
end
section
variable {X Y Z : C₁} [HasSmallLocalizedHom.{w} W₁ X Y] [HasSmallLocalizedHom.{w} W₁ Y Z]
[HasSmallLocalizedHom.{w} W₁ X Z] {X' Y' Z' : C₂}
[HasSmallLocalizedHom.{w'} W₂ X' X'] [HasSmallLocalizedHom.{w'} W₂ Y' Y']
[HasSmallLocalizedHom.{w'} W₂ Z' Z'] [HasSmallLocalizedHom.{w'} W₂ X' Y']
[HasSmallLocalizedHom.{w'} W₂ Y' Z'] [HasSmallLocalizedHom.{w'} W₂ X' Z']
(eX : Φ.functor.obj X ≅ X') (eY : Φ.functor.obj Y ≅ Y') (eZ : Φ.functor.obj Z ≅ Z')
lemma smallHomMap'_comp (f : SmallHom.{w} W₁ X Y) (g : SmallHom.{w} W₁ Y Z) :
Φ.smallHomMap' eX eZ (f.comp g) =
(Φ.smallHomMap' eX eY f).comp (Φ.smallHomMap' eY eZ g) := by
have := hasSmallLocalizedHom_of_isos.{w'} W₂ eX.symm eY.symm
have := hasSmallLocalizedHom_of_isos.{w'} W₂ eY.symm (Iso.refl Y')
have := hasSmallLocalizedHom_of_isos.{w'} W₂ eX.symm (Iso.refl Z')
have := hasSmallLocalizedHom_of_isos.{w'} W₂ eY.symm eZ.symm
have := hasSmallLocalizedHom_of_isos.{w'} W₂ eY.symm (Iso.refl Z')
have := hasSmallLocalizedHom_of_isos.{w'} W₂ (Iso.refl Y') eY.symm
have := hasSmallLocalizedHom_of_isos.{w'} W₂ eY.symm eY.symm
simp only [smallHomMap', smallHomMap_comp, SmallHom.comp_assoc]
congr 2
rw [← SmallHom.comp_assoc, SmallHom.mk_comp_mk, eY.hom_inv_id, SmallHom.mk_id_comp]
end
end LocalizerMorphism
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Localization/HomEquiv.lean | import Mathlib.CategoryTheory.Localization.LocalizerMorphism
import Mathlib.CategoryTheory.HomCongr
/-!
# Bijections between morphisms in two localized categories
Given two localization functors `L₁ : C ⥤ D₁` and `L₂ : C ⥤ D₂` for the same
class of morphisms `W : MorphismProperty C`, we define a bijection
`Localization.homEquiv W L₁ L₂ : (L₁.obj X ⟶ L₁.obj Y) ≃ (L₂.obj X ⟶ L₂.obj Y)`
between the types of morphisms in the two localized categories.
More generally, given a localizer morphism `Φ : LocalizerMorphism W₁ W₂`, we define a map
`Φ.homMap L₁ L₂ : (L₁.obj X ⟶ L₁.obj Y) ⟶ (L₂.obj (Φ.functor.obj X) ⟶ L₂.obj (Φ.functor.obj Y))`.
The definition `Localization.homEquiv` is obtained by applying the construction
to the identity localizer morphism.
-/
namespace CategoryTheory
open Category
variable {C C₁ C₂ C₃ D₁ D₂ D₃ : Type*} [Category C]
[Category C₁] [Category C₂] [Category C₃]
[Category D₁] [Category D₂] [Category D₃]
namespace LocalizerMorphism
variable {W₁ : MorphismProperty C₁} {W₂ : MorphismProperty C₂} {W₃ : MorphismProperty C₃}
(Φ : LocalizerMorphism W₁ W₂) (Ψ : LocalizerMorphism W₂ W₃)
(L₁ : C₁ ⥤ D₁) [L₁.IsLocalization W₁]
(L₂ : C₂ ⥤ D₂) [L₂.IsLocalization W₂]
(L₃ : C₃ ⥤ D₃) [L₃.IsLocalization W₃]
{X Y Z : C₁}
/-- If `Φ : LocalizerMorphism W₁ W₂` is a morphism of localizers, `L₁` and `L₂`
are localization functors for `W₁` and `W₂`, then this is the induced map
`(L₁.obj X ⟶ L₁.obj Y) ⟶ (L₂.obj (Φ.functor.obj X) ⟶ L₂.obj (Φ.functor.obj Y))`
for all objects `X` and `Y`. -/
noncomputable def homMap (f : L₁.obj X ⟶ L₁.obj Y) :
L₂.obj (Φ.functor.obj X) ⟶ L₂.obj (Φ.functor.obj Y) :=
Iso.homCongr ((CatCommSq.iso _ _ _ _).symm.app _) ((CatCommSq.iso _ _ _ _).symm.app _)
((Φ.localizedFunctor L₁ L₂).map f)
@[simp]
lemma homMap_map (f : X ⟶ Y) :
Φ.homMap L₁ L₂ (L₁.map f) = L₂.map (Φ.functor.map f) := by
dsimp [homMap]
simp
variable (X) in
@[simp]
lemma homMap_id :
Φ.homMap L₁ L₂ (𝟙 (L₁.obj X)) = 𝟙 (L₂.obj (Φ.functor.obj X)) := by
simpa using Φ.homMap_map L₁ L₂ (𝟙 X)
@[reassoc]
lemma homMap_comp (f : L₁.obj X ⟶ L₁.obj Y) (g : L₁.obj Y ⟶ L₁.obj Z) :
Φ.homMap L₁ L₂ (f ≫ g) = Φ.homMap L₁ L₂ f ≫ Φ.homMap L₁ L₂ g := by
simp [homMap]
@[reassoc]
lemma homMap_apply (G : D₁ ⥤ D₂) (e : Φ.functor ⋙ L₂ ≅ L₁ ⋙ G) (f : L₁.obj X ⟶ L₁.obj Y) :
Φ.homMap L₁ L₂ f = e.hom.app X ≫ G.map f ≫ e.inv.app Y := by
let G' := Φ.localizedFunctor L₁ L₂
let e' := CatCommSq.iso Φ.functor L₁ L₂ G'
change e'.hom.app X ≫ G'.map f ≫ e'.inv.app Y = _
letI : Localization.Lifting L₁ W₁ (Φ.functor ⋙ L₂) G := ⟨e.symm⟩
let α : G' ≅ G := Localization.liftNatIso L₁ W₁ (L₁ ⋙ G') (Φ.functor ⋙ L₂) _ _ e'.symm
have : e = e' ≪≫ Functor.isoWhiskerLeft _ α := by
ext X
dsimp [α]
rw [Localization.liftNatTrans_app]
erw [id_comp]
rw [Iso.hom_inv_id_app_assoc]
rfl
simp [this]
@[simp]
lemma id_homMap (f : L₁.obj X ⟶ L₁.obj Y) :
(id W₁).homMap L₁ L₁ f = f := by
simpa using (id W₁).homMap_apply L₁ L₁ (𝟭 D₁) (Iso.refl _) f
@[simp]
lemma homMap_homMap (f : L₁.obj X ⟶ L₁.obj Y) :
Ψ.homMap L₂ L₃ (Φ.homMap L₁ L₂ f) = (Φ.comp Ψ).homMap L₁ L₃ f := by
let G := Φ.localizedFunctor L₁ L₂
let G' := Ψ.localizedFunctor L₂ L₃
let e : Φ.functor ⋙ L₂ ≅ L₁ ⋙ G := CatCommSq.iso _ _ _ _
let e' : Ψ.functor ⋙ L₃ ≅ L₂ ⋙ G' := CatCommSq.iso _ _ _ _
rw [Φ.homMap_apply L₁ L₂ G e, Ψ.homMap_apply L₂ L₃ G' e',
(Φ.comp Ψ).homMap_apply L₁ L₃ (G ⋙ G')
(Functor.associator _ _ _ ≪≫ Functor.isoWhiskerLeft _ e' ≪≫
(Functor.associator _ _ _).symm ≪≫ Functor.isoWhiskerRight e _ ≪≫
Functor.associator _ _ _)]
dsimp
simp only [Functor.map_comp, assoc, comp_id, id_comp]
end LocalizerMorphism
namespace Localization
variable (W : MorphismProperty C) (L₁ : C ⥤ D₁) [L₁.IsLocalization W]
(L₂ : C ⥤ D₂) [L₂.IsLocalization W] (L₃ : C ⥤ D₃) [L₃.IsLocalization W]
{X Y Z : C}
/-- Bijection between types of morphisms in two localized categories
for the same class of morphisms `W`. -/
@[simps -isSimp apply]
noncomputable def homEquiv :
(L₁.obj X ⟶ L₁.obj Y) ≃ (L₂.obj X ⟶ L₂.obj Y) where
toFun := (LocalizerMorphism.id W).homMap L₁ L₂
invFun := (LocalizerMorphism.id W).homMap L₂ L₁
left_inv f := by
rw [LocalizerMorphism.homMap_homMap]
apply LocalizerMorphism.id_homMap
right_inv g := by
rw [LocalizerMorphism.homMap_homMap]
apply LocalizerMorphism.id_homMap
@[simp]
lemma homEquiv_symm_apply (g : L₂.obj X ⟶ L₂.obj Y) :
(homEquiv W L₁ L₂).symm g = homEquiv W L₂ L₁ g := rfl
lemma homEquiv_eq (G : D₁ ⥤ D₂) (e : L₁ ⋙ G ≅ L₂) (f : L₁.obj X ⟶ L₁.obj Y) :
homEquiv W L₁ L₂ f = e.inv.app X ≫ G.map f ≫ e.hom.app Y := by
rw [homEquiv_apply, LocalizerMorphism.homMap_apply (LocalizerMorphism.id W) L₁ L₂ G e.symm,
Iso.symm_hom, Iso.symm_inv]
@[simp]
lemma homEquiv_refl (f : L₁.obj X ⟶ L₁.obj Y) :
homEquiv W L₁ L₁ f = f := by
apply LocalizerMorphism.id_homMap
lemma homEquiv_trans (f : L₁.obj X ⟶ L₁.obj Y) :
homEquiv W L₂ L₃ (homEquiv W L₁ L₂ f) = homEquiv W L₁ L₃ f := by
dsimp only [homEquiv_apply]
apply LocalizerMorphism.homMap_homMap
lemma homEquiv_comp (f : L₁.obj X ⟶ L₁.obj Y) (g : L₁.obj Y ⟶ L₁.obj Z) :
homEquiv W L₁ L₂ (f ≫ g) = homEquiv W L₁ L₂ f ≫ homEquiv W L₁ L₂ g := by
apply LocalizerMorphism.homMap_comp
@[simp]
lemma homEquiv_map (f : X ⟶ Y) : homEquiv W L₁ L₂ (L₁.map f) = L₂.map f := by
simp [homEquiv_apply]
variable (X) in
@[simp]
lemma homEquiv_id : homEquiv W L₁ L₂ (𝟙 (L₁.obj X)) = 𝟙 (L₂.obj X) := by
simp [homEquiv_apply]
lemma homEquiv_isoOfHom_inv (f : Y ⟶ X) (hf : W f) :
homEquiv W L₁ L₂ (isoOfHom L₁ W f hf).inv = (isoOfHom L₂ W f hf).inv := by
rw [← cancel_mono (isoOfHom L₂ W f hf).hom, Iso.inv_hom_id, isoOfHom_hom,
← homEquiv_map W L₁ L₂ f, ← homEquiv_comp, isoOfHom_inv_hom_id, homEquiv_id]
end Localization
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Localization/FiniteProducts.lean | import Mathlib.CategoryTheory.Limits.ConeCategory
import Mathlib.CategoryTheory.Limits.Preserves.Finite
import Mathlib.CategoryTheory.Localization.Adjunction
import Mathlib.CategoryTheory.Localization.HasLocalization
import Mathlib.CategoryTheory.Localization.Pi
import Mathlib.CategoryTheory.MorphismProperty.Limits
/-! The localized category has finite products
In this file, it is shown that if `L : C ⥤ D` is
a localization functor for `W : MorphismProperty C` and that
`W` is stable under finite products, then `D` has finite
products, and `L` preserves finite products.
-/
universe v₁ v₂ u₁ u₂
namespace CategoryTheory
open Limits Functor
namespace Localization
variable {C : Type u₁} {D : Type u₂} [Category.{v₁} C] [Category.{v₂} D] (L : C ⥤ D)
(W : MorphismProperty C) [L.IsLocalization W]
namespace HasProductsOfShapeAux
variable (J : Type) [HasProductsOfShape J C] [W.IsStableUnderProductsOfShape J]
lemma inverts :
(W.functorCategory (Discrete J)).IsInvertedBy (lim ⋙ L) :=
fun _ _ f hf => Localization.inverts L W _ (MorphismProperty.limMap f hf)
variable [W.ContainsIdentities] [Finite J]
/-- The (candidate) limit functor for the localized category.
It is induced by `lim ⋙ L : (Discrete J ⥤ C) ⥤ D`. -/
noncomputable abbrev limitFunctor :
(Discrete J ⥤ D) ⥤ D :=
Localization.lift _ (inverts L W J)
((whiskeringRight (Discrete J) C D).obj L)
/-- The functor `limitFunctor L W J` is induced by `lim ⋙ L`. -/
noncomputable def compLimitFunctorIso :
((whiskeringRight (Discrete J) C D).obj L) ⋙ limitFunctor L W J ≅
lim ⋙ L := by
apply Localization.fac
instance :
CatCommSq (Functor.const (Discrete J)) L
((whiskeringRight (Discrete J) C D).obj L) (Functor.const (Discrete J)) where
iso := (Functor.compConstIso _ _).symm
noncomputable instance :
CatCommSq lim ((whiskeringRight (Discrete J) C D).obj L) L (limitFunctor L W J) where
iso := (compLimitFunctorIso L W J).symm
/-- The adjunction between the constant functor `D ⥤ (Discrete J ⥤ D)`
and `limitFunctor L W J`. -/
noncomputable def adj :
Functor.const _ ⊣ limitFunctor L W J :=
constLimAdj.localization L W ((whiskeringRight (Discrete J) C D).obj L)
(W.functorCategory (Discrete J)) (Functor.const _) (limitFunctor L W J)
lemma adj_counit_app (F : Discrete J ⥤ C) :
(adj L W J).counit.app (F ⋙ L) =
(Functor.const (Discrete J)).map ((compLimitFunctorIso L W J).hom.app F) ≫
(Functor.compConstIso (Discrete J) L).hom.app (lim.obj F) ≫
whiskerRight (constLimAdj.counit.app F) L := by
apply constLimAdj.localization_counit_app
/-- Auxiliary definition for `Localization.preservesProductsOfShape`. -/
noncomputable def isLimitMapCone (F : Discrete J ⥤ C) :
IsLimit (L.mapCone (limit.cone F)) :=
IsLimit.ofIsoLimit (isLimitConeOfAdj (adj L W J) (F ⋙ L))
(Cones.ext ((compLimitFunctorIso L W J).app F) (by simp [adj_counit_app, constLimAdj]))
end HasProductsOfShapeAux
variable [W.ContainsIdentities]
include L
lemma hasProductsOfShape (J : Type) [Finite J] [HasProductsOfShape J C]
[W.IsStableUnderProductsOfShape J] :
HasProductsOfShape J D :=
hasLimitsOfShape_iff_isLeftAdjoint_const.2
(HasProductsOfShapeAux.adj L W J).isLeftAdjoint
/-- When `C` has finite products indexed by `J`, `W : MorphismProperty C` contains
identities and is stable by products indexed by `J`,
then any localization functor for `W` preserves finite products indexed by `J`. -/
lemma preservesProductsOfShape (J : Type) [Finite J]
[HasProductsOfShape J C] [W.IsStableUnderProductsOfShape J] :
PreservesLimitsOfShape (Discrete J) L where
preservesLimit {F} := preservesLimit_of_preserves_limit_cone (limit.isLimit F)
(HasProductsOfShapeAux.isLimitMapCone L W J F)
variable [HasFiniteProducts C] [W.IsStableUnderFiniteProducts]
include W in
lemma hasFiniteProducts : HasFiniteProducts D :=
⟨fun _ => hasProductsOfShape L W _⟩
include W in
/-- When `C` has finite products and `W : MorphismProperty C` contains
identities and is stable by finite products,
then any localization functor for `W` preserves finite products. -/
lemma preservesFiniteProducts :
PreservesFiniteProducts L where
preserves _ := preservesProductsOfShape L W _
instance : HasFiniteProducts (W.Localization) := hasFiniteProducts W.Q W
noncomputable instance : PreservesFiniteProducts W.Q := preservesFiniteProducts W.Q W
instance [W.HasLocalization] :
HasFiniteProducts (W.Localization') :=
hasFiniteProducts W.Q' W
noncomputable instance [W.HasLocalization] :
PreservesFiniteProducts W.Q' :=
preservesFiniteProducts W.Q' W
end Localization
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Localization/Equivalence.lean | import Mathlib.CategoryTheory.Localization.Predicate
import Mathlib.CategoryTheory.CatCommSq
/-!
# Localization functors are preserved through equivalences
In `Localization/Predicate.lean`, the lemma `Localization.of_equivalence_target` already
showed that the predicate of localized categories is unchanged when we replace the
target category (i.e. the candidate localized category) by an equivalent category.
In this file, we show the same for the source category (`Localization.of_equivalence_source`).
More generally, `Localization.of_equivalences` shows that we may replace both the
source and target categories by equivalent categories. This is obtained using
`Localization.isEquivalence` which provide a sufficient condition in order to show
that a functor between localized categories is an equivalence.
-/
namespace CategoryTheory
open Category Localization
variable {C₁ C₂ D D₁ D₂ : Type*} [Category C₁] [Category C₂] [Category D]
[Category D₁] [Category D₂]
namespace Localization
variable
(L₁ : C₁ ⥤ D₁) (W₁ : MorphismProperty C₁) [L₁.IsLocalization W₁]
(L₂ : C₂ ⥤ D₂) (W₂ : MorphismProperty C₂) [L₂.IsLocalization W₂]
(G : C₁ ⥤ D₂) (G' : D₁ ⥤ D₂) [Lifting L₁ W₁ G G']
(F : C₂ ⥤ D₁) (F' : D₂ ⥤ D₁) [Lifting L₂ W₂ F F']
(α : G ⋙ F' ≅ L₁) (β : F ⋙ G' ≅ L₂)
/-- Basic constructor of an equivalence between localized categories -/
noncomputable def equivalence : D₁ ≌ D₂ :=
Equivalence.mk G' F' (liftNatIso L₁ W₁ L₁ (G ⋙ F') (𝟭 D₁) (G' ⋙ F') α.symm)
(liftNatIso L₂ W₂ (F ⋙ G') L₂ (F' ⋙ G') (𝟭 D₂) β)
@[simp]
lemma equivalence_counitIso_app (X : C₂) :
(equivalence L₁ W₁ L₂ W₂ G G' F F' α β).counitIso.app (L₂.obj X) =
(Lifting.iso L₂ W₂ (F ⋙ G') (F' ⋙ G')).app X ≪≫ β.app X := by
ext
dsimp [equivalence, Equivalence.mk]
rw [liftNatTrans_app]
dsimp [Lifting.iso]
rw [comp_id]
include L₁ W₁ L₂ W₂ G F F' α β in
/-- Basic constructor of an equivalence between localized categories -/
lemma isEquivalence : G'.IsEquivalence :=
(equivalence L₁ W₁ L₂ W₂ G G' F F' α β).isEquivalence_functor
end Localization
namespace Functor
namespace IsLocalization
/-- If `L₁ : C₁ ⥤ D` is a localization functor for `W₁ : MorphismProperty C₁`, then it is also
the case of a functor `L₂ : C₂ ⥤ D` for a suitable `W₂ : MorphismProperty C₂` when
we have an equivalence of category `E : C₁ ≌ C₂` and an isomorphism `E.functor ⋙ L₂ ≅ L₁`. -/
lemma of_equivalence_source (L₁ : C₁ ⥤ D) (W₁ : MorphismProperty C₁)
(L₂ : C₂ ⥤ D) (W₂ : MorphismProperty C₂)
(E : C₁ ≌ C₂) (hW₁ : W₁ ≤ W₂.isoClosure.inverseImage E.functor) (hW₂ : W₂.IsInvertedBy L₂)
[L₁.IsLocalization W₁] (iso : E.functor ⋙ L₂ ≅ L₁) : L₂.IsLocalization W₂ := by
have h : W₁.IsInvertedBy (E.functor ⋙ W₂.Q) := fun _ _ f hf => by
obtain ⟨_, _, f', hf', ⟨e⟩⟩ := hW₁ f hf
exact ((MorphismProperty.isomorphisms _).arrow_mk_iso_iff
(W₂.Q.mapArrow.mapIso e)).1 (Localization.inverts W₂.Q W₂ _ hf')
exact
{ inverts := hW₂
isEquivalence :=
Localization.isEquivalence W₂.Q W₂ L₁ W₁ L₂ (Construction.lift L₂ hW₂)
(E.functor ⋙ W₂.Q) (Localization.lift (E.functor ⋙ W₂.Q) h L₁) (by
calc
L₂ ⋙ lift (E.functor ⋙ W₂.Q) h L₁ ≅ _ := (leftUnitor _).symm
_ ≅ _ := isoWhiskerRight E.counitIso.symm _
_ ≅ E.inverse ⋙ E.functor ⋙ L₂ ⋙ lift (E.functor ⋙ W₂.Q) h L₁ :=
Functor.associator _ _ _
_ ≅ E.inverse ⋙ L₁ ⋙ lift (E.functor ⋙ W₂.Q) h L₁ :=
isoWhiskerLeft E.inverse ((Functor.associator _ _ _).symm ≪≫
isoWhiskerRight iso _)
_ ≅ E.inverse ⋙ E.functor ⋙ W₂.Q :=
isoWhiskerLeft _ (Localization.fac (E.functor ⋙ W₂.Q) h L₁)
_ ≅ (E.inverse ⋙ E.functor) ⋙ W₂.Q := (Functor.associator _ _ _).symm
_ ≅ 𝟭 C₂ ⋙ W₂.Q := isoWhiskerRight E.counitIso _
_ ≅ W₂.Q := leftUnitor _)
(Functor.associator _ _ _ ≪≫ isoWhiskerLeft _ (Lifting.iso W₂.Q W₂ _ _) ≪≫ iso) }
/-- If `L₁ : C₁ ⥤ D₁` is a localization functor for `W₁ : MorphismProperty C₁`, then if we
transport this functor `L₁` via equivalences `C₁ ≌ C₂` and `D₁ ≌ D₂` to get a functor
`L₂ : C₂ ⥤ D₂`, then `L₂` is also a localization functor for
a suitable `W₂ : MorphismProperty C₂`. -/
lemma of_equivalences (L₁ : C₁ ⥤ D₁) (W₁ : MorphismProperty C₁) [L₁.IsLocalization W₁]
(L₂ : C₂ ⥤ D₂) (W₂ : MorphismProperty C₂)
(E : C₁ ≌ C₂) (E' : D₁ ≌ D₂) [CatCommSq E.functor L₁ L₂ E'.functor]
(hW₁ : W₁ ≤ W₂.isoClosure.inverseImage E.functor) (hW₂ : W₂.IsInvertedBy L₂) :
L₂.IsLocalization W₂ := by
haveI : (E.functor ⋙ L₂).IsLocalization W₁ :=
of_equivalence_target L₁ W₁ _ E' ((CatCommSq.iso _ _ _ _).symm)
exact of_equivalence_source (E.functor ⋙ L₂) W₁ L₂ W₂ E hW₁ hW₂ (Iso.refl _)
end IsLocalization
end Functor
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Localization/SmallShiftedHom.lean | import Mathlib.CategoryTheory.Localization.SmallHom
import Mathlib.CategoryTheory.Shift.ShiftedHom
import Mathlib.CategoryTheory.Shift.Localization
/-!
# Shrinking morphisms in localized categories equipped with shifts
If `C` is a category equipped with a shift by an additive monoid `M`,
and `W : MorphismProperty C` is compatible with the shift,
we define a type-class `HasSmallLocalizedShiftedHom.{w} W X Y` which
says that all the types of morphisms from `X⟦a⟧` to `Y⟦b⟧` in the
localized category are `w`-small for a certain universe. Then,
we define types `SmallShiftedHom.{w} W X Y m : Type w` for all `m : M`,
and endow these with a composition which transports the composition
on the types `ShiftedHom (L.obj X) (L.obj Y) m` when `L : C ⥤ D` is
any localization functor for `W`.
-/
universe w'' w w' v₁ v₂ v₁' v₂' u₁ u₂ u₁' u₂'
namespace CategoryTheory
open Category
variable {C : Type u₁} [Category.{v₁} C] {D : Type u₂} [Category.{v₂} D]
(W : MorphismProperty C) {M : Type w'} [AddMonoid M] [HasShift C M] [HasShift D M]
namespace Localization
section
variable (X Y : C)
variable (M)
/-- Given objects `X` and `Y` in a category `C`, this is the property that
all the types of morphisms from `X⟦a⟧` to `Y⟦b⟧` are `w`-small
in the localized category with respect to a class of morphisms `W`. -/
abbrev HasSmallLocalizedShiftedHom : Prop :=
∀ (a b : M), HasSmallLocalizedHom.{w} W (X⟦a⟧) (Y⟦b⟧)
lemma hasSmallLocalizedShiftedHom_iff
(L : C ⥤ D) [L.IsLocalization W] [L.CommShift M] (X Y : C) :
HasSmallLocalizedShiftedHom.{w} W M X Y ↔
∀ (a b : M), Small.{w} ((L.obj X)⟦a⟧ ⟶ (L.obj Y)⟦b⟧) := by
dsimp [HasSmallLocalizedShiftedHom]
have eq := fun (a b : M) ↦ small_congr.{w}
(Iso.homCongr ((L.commShiftIso a).app X) ((L.commShiftIso b).app Y))
dsimp at eq
simp only [hasSmallLocalizedHom_iff _ L, eq]
variable {Y} in
lemma hasSmallLocalizedShiftedHom_iff_target [W.IsCompatibleWithShift M]
{Y' : C} (f : Y ⟶ Y') (hf : W f) :
HasSmallLocalizedShiftedHom.{w} W M X Y ↔ HasSmallLocalizedShiftedHom.{w} W M X Y' :=
forall_congr' (fun a ↦ forall_congr' (fun b ↦
hasSmallLocalizedHom_iff_target W (X⟦a⟧) (f⟦b⟧') (W.shift hf b)))
variable {X} in
lemma hasSmallLocalizedShiftedHom_iff_source [W.IsCompatibleWithShift M]
{X' : C} (f : X ⟶ X') (hf : W f) (Y : C) :
HasSmallLocalizedShiftedHom.{w} W M X Y ↔ HasSmallLocalizedShiftedHom.{w} W M X' Y :=
forall_congr' (fun a ↦ forall_congr' (fun b ↦
hasSmallLocalizedHom_iff_source W (f⟦a⟧') (W.shift hf a) (Y⟦b⟧)))
variable [HasSmallLocalizedShiftedHom.{w} W M X Y]
include M in
lemma hasSmallLocalizedHom_of_hasSmallLocalizedShiftedHom₀ :
HasSmallLocalizedHom.{w} W X Y :=
(hasSmallLocalizedHom_iff_of_isos W
((shiftFunctorZero C M).app X) ((shiftFunctorZero C M).app Y)).1 inferInstance
variable {M}
instance (m : M) : HasSmallLocalizedHom.{w} W X (Y⟦m⟧) :=
(hasSmallLocalizedHom_iff_of_isos W
((shiftFunctorZero C M).app X) (Iso.refl (Y⟦m⟧))).1 inferInstance
instance (m : M) : HasSmallLocalizedHom.{w} W (X⟦m⟧) Y :=
(hasSmallLocalizedHom_iff_of_isos W
(Iso.refl (X⟦m⟧)) ((shiftFunctorZero C M).app Y)).1 inferInstance
instance (m m' n : M) : HasSmallLocalizedHom.{w} W (X⟦m⟧⟦m'⟧) (Y⟦n⟧) :=
(hasSmallLocalizedHom_iff_of_isos W
((shiftFunctorAdd C m m').app X) (Iso.refl (Y⟦n⟧))).1 inferInstance
instance (m n n' : M) : HasSmallLocalizedHom.{w} W (X⟦m⟧) (Y⟦n⟧⟦n'⟧) :=
(hasSmallLocalizedHom_iff_of_isos W
(Iso.refl (X⟦m⟧)) ((shiftFunctorAdd C n n').app Y)).1 inferInstance
end
namespace SmallHom
variable {W}
variable [W.IsCompatibleWithShift M] (L : C ⥤ D) [L.IsLocalization W] [L.CommShift M]
{X Y : C} [HasSmallLocalizedHom.{w} W X Y]
(f : SmallHom.{w} W X Y) (a : M) [HasSmallLocalizedHom.{w} W (X⟦a⟧) (Y⟦a⟧)]
/-- Given `f : SmallHom W X Y` and `a : M`, this is the element
in `SmallHom W (X⟦a⟧) (Y⟦a⟧)` obtained by shifting by `a`. -/
noncomputable def shift : SmallHom.{w} W (X⟦a⟧) (Y⟦a⟧) :=
(W.shiftLocalizerMorphism a).smallHomMap f
lemma equiv_shift : equiv W L (f.shift a) =
(L.commShiftIso a).hom.app X ≫ (equiv W L f)⟦a⟧' ≫ (L.commShiftIso a).inv.app Y :=
(W.shiftLocalizerMorphism a).equiv_smallHomMap _ _ _ (L.commShiftIso a) f
end SmallHom
/-- The type of morphisms from `X` to `Y⟦m⟧` in the localized category
with respect to `W : MorphismProperty C` that is shrunk to `Type w`
when `HasSmallLocalizedShiftedHom.{w} W X Y` holds. -/
def SmallShiftedHom (X Y : C) [HasSmallLocalizedShiftedHom.{w} W M X Y] (m : M) : Type w :=
SmallHom W X (Y⟦m⟧)
namespace SmallShiftedHom
section
variable [W.IsCompatibleWithShift M] {X Y Z : C}
/-- Constructor for `SmallShiftedHom`. -/
noncomputable def mk {m : M} [HasSmallLocalizedShiftedHom.{w} W M X Y] (f : ShiftedHom X Y m) :
SmallShiftedHom.{w} W X Y m :=
SmallHom.mk _ f
variable {W}
/-- Given `f : SmallShiftedHom.{w} W X Y a`, this is the element in
`SmallHom.{w} W (X⟦n⟧) (Y⟦a'⟧)` that is obtained by shifting by `n`
when `a + n = a'`. -/
noncomputable def shift {a : M} [HasSmallLocalizedShiftedHom.{w} W M X Y]
[HasSmallLocalizedShiftedHom.{w} W M Y Y]
(f : SmallShiftedHom.{w} W X Y a) (n a' : M) (h : a + n = a') :
SmallHom.{w} W (X⟦n⟧) (Y⟦a'⟧) :=
(SmallHom.shift f n).comp (SmallHom.mk W ((shiftFunctorAdd' C a n a' h).inv.app Y))
/-- The composition on `SmallShiftedHom W`. -/
noncomputable def comp {a b c : M} [HasSmallLocalizedShiftedHom.{w} W M X Y]
[HasSmallLocalizedShiftedHom.{w} W M Y Z] [HasSmallLocalizedShiftedHom.{w} W M X Z]
[HasSmallLocalizedShiftedHom.{w} W M Z Z]
(f : SmallShiftedHom.{w} W X Y a) (g : SmallShiftedHom.{w} W Y Z b) (h : b + a = c) :
SmallShiftedHom.{w} W X Z c :=
SmallHom.comp f (g.shift a c h)
variable (W) in
/-- The canonical map `(X ⟶ Y) → SmallShiftedHom.{w} W X Y m₀` when `m₀ = 0` and
`[HasSmallLocalizedShiftedHom.{w} W M X Y]` holds. -/
noncomputable def mk₀ [HasSmallLocalizedShiftedHom.{w} W M X Y]
(m₀ : M) (hm₀ : m₀ = 0) (f : X ⟶ Y) :
SmallShiftedHom.{w} W X Y m₀ :=
SmallShiftedHom.mk _ (ShiftedHom.mk₀ _ hm₀ f)
end
section
variable (L : C ⥤ D) [L.IsLocalization W] [L.CommShift M]
{X Y Z T : C}
/-- The bijection `SmallShiftedHom.{w} W X Y m ≃ ShiftedHom (L.obj X) (L.obj Y) m`
for all `m : M`, and `X` and `Y` in `C` when `L : C ⥤ D` is a localization functor for
`W : MorphismProperty C` such that the category `D` is equipped with a shift by `M`
and `L` commutes with the shifts. -/
noncomputable def equiv [HasSmallLocalizedShiftedHom.{w} W M X Y] {m : M} :
SmallShiftedHom.{w} W X Y m ≃ ShiftedHom (L.obj X) (L.obj Y) m :=
(SmallHom.equiv W L).trans ((L.commShiftIso m).app Y).homToEquiv
lemma equiv_apply [HasSmallLocalizedShiftedHom.{w} W M X Y] {m : M}
(f : SmallShiftedHom.{w} W X Y m) :
equiv W L f = (SmallHom.equiv W L) f ≫ ((L.commShiftIso m).app Y).hom :=
rfl
section
variable [W.IsCompatibleWithShift M]
lemma equiv_shift' {a : M} [HasSmallLocalizedShiftedHom.{w} W M X Y]
[HasSmallLocalizedShiftedHom.{w} W M Y Y]
(f : SmallShiftedHom.{w} W X Y a) (n a' : M) (h : a + n = a') :
SmallHom.equiv W L (f.shift n a' h) = (L.commShiftIso n).hom.app X ≫
(SmallHom.equiv W L f)⟦n⟧' ≫ ((L.commShiftIso a).hom.app Y)⟦n⟧' ≫
(shiftFunctorAdd' D a n a' h).inv.app (L.obj Y) ≫ (L.commShiftIso a').inv.app Y := by
simp only [shift, SmallHom.equiv_comp, SmallHom.equiv_shift, SmallHom.equiv_mk, assoc,
L.commShiftIso_add' h, Functor.CommShift.isoAdd'_inv_app, Iso.inv_hom_id_app_assoc,
← Functor.map_comp_assoc, Iso.hom_inv_id_app, Functor.comp_obj, comp_id]
lemma equiv_shift {a : M} [HasSmallLocalizedShiftedHom.{w} W M X Y]
[HasSmallLocalizedShiftedHom.{w} W M Y Y]
(f : SmallShiftedHom.{w} W X Y a) (n a' : M) (h : a + n = a') :
equiv W L (f.shift n a' h) = (L.commShiftIso n).hom.app X ≫ (equiv W L f)⟦n⟧' ≫
(shiftFunctorAdd' D a n a' h).inv.app (L.obj Y) := by
dsimp [equiv]
erw [Iso.homToEquiv_apply, Iso.homToEquiv_apply, equiv_shift']
simp only [Functor.comp_obj, Iso.app_hom, assoc, Iso.inv_hom_id_app, comp_id, Functor.map_comp]
rfl
lemma equiv_comp [HasSmallLocalizedShiftedHom.{w} W M X Y]
[HasSmallLocalizedShiftedHom.{w} W M Y Z] [HasSmallLocalizedShiftedHom.{w} W M X Z]
[HasSmallLocalizedShiftedHom.{w} W M Z Z] {a b c : M}
(f : SmallShiftedHom.{w} W X Y a) (g : SmallShiftedHom.{w} W Y Z b) (h : b + a = c) :
equiv W L (f.comp g h) = (equiv W L f).comp (equiv W L g) h := by
dsimp [comp, equiv, ShiftedHom.comp]
erw [Iso.homToEquiv_apply, Iso.homToEquiv_apply, Iso.homToEquiv_apply, SmallHom.equiv_comp]
simp only [equiv_shift', Functor.comp_obj, Iso.app_hom, assoc, Iso.inv_hom_id_app,
comp_id, Functor.map_comp]
rfl
end
@[simp]
lemma equiv_mk [HasSmallLocalizedShiftedHom.{w} W M X Y] {m : M} (f : ShiftedHom X Y m) :
equiv W L (.mk _ f) = f.map L :=
((L.commShiftIso m).app Y).homToEquiv.symm.injective
((Equiv.symm_apply_apply ..).trans (by simp [ShiftedHom.map, mk]))
@[simp]
lemma equiv_mk₀ [HasSmallLocalizedShiftedHom.{w} W M X Y]
(m₀ : M) (hm₀ : m₀ = 0) (f : X ⟶ Y) :
equiv W L (SmallShiftedHom.mk₀ W m₀ hm₀ f) =
ShiftedHom.mk₀ m₀ hm₀ (L.map f) := by
subst hm₀
dsimp [equiv, mk₀]
erw [SmallHom.equiv_mk, Iso.homToEquiv_apply, Functor.map_comp]
dsimp [equiv, mk₀, ShiftedHom.mk₀, shiftFunctorZero']
simp only [comp_id, L.commShiftIso_zero, Functor.CommShift.isoZero_hom_app, assoc,
← Functor.map_comp_assoc, Iso.inv_hom_id_app, Functor.id_obj, Functor.map_id, id_comp]
end
section
variable [W.IsCompatibleWithShift M]
lemma comp_assoc {X Y Z T : C} {a₁ a₂ a₃ a₁₂ a₂₃ a : M}
[HasSmallLocalizedShiftedHom.{w} W M X Y] [HasSmallLocalizedShiftedHom.{w} W M X Z]
[HasSmallLocalizedShiftedHom.{w} W M X T] [HasSmallLocalizedShiftedHom.{w} W M Y Z]
[HasSmallLocalizedShiftedHom.{w} W M Y T] [HasSmallLocalizedShiftedHom.{w} W M Z T]
[HasSmallLocalizedShiftedHom.{w} W M Z Z] [HasSmallLocalizedShiftedHom.{w} W M T T]
(α : SmallShiftedHom.{w} W X Y a₁) (β : SmallShiftedHom.{w} W Y Z a₂)
(γ : SmallShiftedHom.{w} W 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
apply (equiv W W.Q).injective
simp only [equiv_comp, ShiftedHom.comp_assoc _ _ _ h₁₂ h₂₃ h]
end
section ChangeOfUniverse
variable {W}
/-- Up to an equivalence, the type `SmallShiftedHom.{w} W X Y m` does
not depend on the universe `w`. -/
noncomputable def chgUniv {X Y : C} {m : M}
[HasSmallLocalizedShiftedHom.{w} W M X Y]
[HasSmallLocalizedShiftedHom.{w''} W M X Y] :
SmallShiftedHom.{w} W X Y m ≃ SmallShiftedHom.{w''} W X Y m :=
SmallHom.chgUniv
lemma equiv_chgUniv (L : C ⥤ D) [L.IsLocalization W] [L.CommShift M] {X Y : C} {m : M}
[HasSmallLocalizedShiftedHom.{w} W M X Y]
[HasSmallLocalizedShiftedHom.{w''} W M X Y]
(e : SmallShiftedHom.{w} W X Y m) :
equiv W L (chgUniv.{w''} e) = equiv W L e := by
dsimp [equiv]
congr
apply SmallHom.equiv_chgUniv
end ChangeOfUniverse
end SmallShiftedHom
end Localization
namespace LocalizerMorphism
open Localization
variable {C₁ : Type u₁} [Category.{v₁} C₁] {C₂ : Type u₂} [Category.{v₂} C₂]
{D₁ : Type u₁'} [Category.{v₁'} D₁] {D₂ : Type u₂'} [Category.{v₂'} D₂]
{W₁ : MorphismProperty C₁} {W₂ : MorphismProperty C₂}
(Φ : LocalizerMorphism W₁ W₂)
(L₁ : C₁ ⥤ D₁) (L₂ : C₂ ⥤ D₂) [L₁.IsLocalization W₁] [L₂.IsLocalization W₂]
{M : Type w'} [AddMonoid M] [HasShift C₁ M] [HasShift C₂ M]
[HasShift D₁ M] [HasShift D₂ M] [L₁.CommShift M] [L₂.CommShift M]
[Φ.functor.CommShift M]
{X₁ Y₁ Z₁ : C₁} {X₂ Y₂ Z₂ : C₂}
[HasSmallLocalizedShiftedHom.{w} W₁ M X₁ Y₁] [HasSmallLocalizedShiftedHom.{w''} W₂ M X₂ X₂]
[HasSmallLocalizedShiftedHom.{w''} W₂ M X₂ Y₂] [HasSmallLocalizedShiftedHom.{w''} W₂ M Y₂ Y₂]
(eX : Φ.functor.obj X₁ ≅ X₂) (eY : Φ.functor.obj Y₁ ≅ Y₂)
(eZ : Φ.functor.obj Z₁ ≅ Z₂)
/-- The action of a localizer morphism `Φ` on `SmallShiftedHom`. -/
noncomputable def smallShiftedHomMap {m : M} (f : SmallShiftedHom.{w} W₁ X₁ Y₁ m) :
SmallShiftedHom.{w''} W₂ X₂ Y₂ m :=
have := hasSmallLocalizedHom_of_hasSmallLocalizedShiftedHom₀.{w''} W₂ M X₂ X₂
Φ.smallHomMap' eX ((Φ.functor.commShiftIso m).app Y₁ ≪≫ (shiftFunctor _ _).mapIso eY) f
lemma equiv_smallShiftedHomMap (G : D₁ ⥤ D₂) [G.CommShift M]
(e : Φ.functor ⋙ L₂ ≅ L₁ ⋙ G) [NatTrans.CommShift e.hom M]
{m : M} (f : SmallShiftedHom.{w} W₁ X₁ Y₁ m) :
SmallShiftedHom.equiv W₂ L₂ (Φ.smallShiftedHomMap eX eY f) =
(ShiftedHom.mk₀ 0 rfl (L₂.map eX.inv ≫ e.hom.app _)).comp
(((SmallShiftedHom.equiv W₁ L₁ f).map G).comp
((ShiftedHom.mk₀ 0 rfl (e.inv.app _ ≫ L₂.map eY.hom)))
(zero_add m)) (add_zero m) := by
have := hasSmallLocalizedHom_of_hasSmallLocalizedShiftedHom₀.{w''} W₂ M X₂ X₂
apply ((L₂.commShiftIso m).app Y₂).homToEquiv.symm.injective
simp only [Functor.comp_obj, SmallShiftedHom.equiv_apply, Iso.app_hom,
Iso.homToEquiv_symm_apply, Iso.app_inv, assoc, Iso.hom_inv_id_app, comp_id]
refine (Φ.equiv_smallHomMap' L₁ L₂ _ _ G e f).trans ?_
simp only [Functor.comp_obj, NatTrans.app_shift,
Functor.commShiftIso_comp_hom_app, Functor.commShiftIso_comp_inv_app, assoc,
Iso.trans_hom, Iso.app_hom, Functor.mapIso_hom, Functor.map_comp, ShiftedHom.map,
ShiftedHom.comp_mk₀, ShiftedHom.mk₀_comp,
Functor.commShiftIso_inv_naturality]
nth_rw 2 [← Functor.map_comp_assoc]
simp
variable [W₁.IsCompatibleWithShift M] [W₂.IsCompatibleWithShift M]
@[simp]
lemma smallShiftedHomMap_mk {m : M} (f : ShiftedHom X₁ Y₁ m) :
Φ.smallShiftedHomMap eX eY (.mk _ f) =
.mk _ ((ShiftedHom.mk₀ _ rfl eX.inv).comp
((f.map Φ.functor).comp (.mk₀ _ rfl eY.hom) (zero_add m)) (add_zero _)) := by
apply (SmallShiftedHom.equiv W₂ W₂.Q).injective
let e := CatCommSq.iso Φ.functor W₁.Q W₂.Q (Φ.localizedFunctor W₁.Q W₂.Q)
simp only [Φ.equiv_smallShiftedHomMap W₁.Q W₂.Q _ _ (Φ.localizedFunctor W₁.Q W₂.Q) e,
Functor.comp_obj, ShiftedHom.map, SmallShiftedHom.equiv_mk, Functor.map_comp, assoc,
ShiftedHom.comp_mk₀, NatTrans.shift_app, Functor.commShiftIso_comp_inv_app,
Functor.commShiftIso_comp_hom_app, Iso.hom_inv_id_app_assoc, ShiftedHom.mk₀_comp,
Functor.commShiftIso_hom_naturality]
nth_rw 2 [← Functor.map_comp_assoc]
simp [reassoc_of% (NatIso.naturality_2 e f)]
lemma smallShiftedHomMap_mk₀ (m₀ : M) (hm₀ : m₀ = 0) (f : X₁ ⟶ Y₁) :
Φ.smallShiftedHomMap eX eY (.mk₀ _ _ hm₀ f) =
.mk₀ _ _ hm₀ (eX.inv ≫ Φ.functor.map f ≫ eY.hom) := by
simp [SmallShiftedHom.mk₀]
lemma smallShiftedHomMap_comp
[HasSmallLocalizedShiftedHom.{w} W₁ M Y₁ Z₁] [HasSmallLocalizedShiftedHom.{w''} W₂ M Z₂ Z₂]
[HasSmallLocalizedShiftedHom.{w''} W₂ M Y₂ Z₂] [HasSmallLocalizedShiftedHom.{w} W₁ M X₁ Z₁]
[HasSmallLocalizedShiftedHom.{w} W₁ M Z₁ Z₁] [HasSmallLocalizedShiftedHom.{w''} W₂ M X₂ Z₂]
{a b c : M} (f : SmallShiftedHom.{w} W₁ X₁ Y₁ a) (g : SmallShiftedHom.{w} W₁ Y₁ Z₁ b)
(h : b + a = c) :
Φ.smallShiftedHomMap eX eZ (f.comp g h) =
(Φ.smallShiftedHomMap eX eY f).comp (Φ.smallShiftedHomMap eY eZ g) h := by
apply (SmallShiftedHom.equiv W₂ W₂.Q).injective
let e := CatCommSq.iso Φ.functor W₁.Q W₂.Q (Φ.localizedFunctor W₁.Q W₂.Q)
simp only [Φ.equiv_smallShiftedHomMap W₁.Q W₂.Q _ _ (Φ.localizedFunctor W₁.Q W₂.Q) e,
SmallShiftedHom.equiv_comp, ShiftedHom.map_comp]
rw [ShiftedHom.comp_assoc _ _ _ _ (zero_add b) (by simpa),
ShiftedHom.comp_assoc _ _ _ _ h (by simpa),
ShiftedHom.comp_assoc _ _ _ _ (add_zero b) (by simpa),
← ShiftedHom.comp_assoc _ _ _ (add_zero 0) (add_zero b) (by simp),
ShiftedHom.mk₀_comp_mk₀]
simp
end LocalizerMorphism
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Localization/StructuredArrow.lean | import Mathlib.CategoryTheory.Localization.HomEquiv
import Mathlib.CategoryTheory.Localization.Opposite
import Mathlib.CategoryTheory.Comma.StructuredArrow.Basic
/-!
# Induction principles for structured and costructured arrows
Assume that `L : C ⥤ D` is a localization functor for `W : MorphismProperty C`.
Given `X : C` and a predicate `P` on `StructuredArrow (L.obj X) L`, we obtain
the lemma `Localization.induction_structuredArrow` which shows that `P` holds for
all structured arrows if `P` holds for the identity map `𝟙 (L.obj X)`,
if `P` is stable by post-composition with `L.map f` for any `f`
and if `P` is stable by post-composition with the inverse of `L.map w` when `W w`.
We obtain a similar lemma `Localization.induction_costructuredArrow` for
costructured arrows.
-/
namespace CategoryTheory
open Opposite
variable {C D D' : Type*} [Category C] [Category D] [Category D']
namespace Localization
section
variable (W : MorphismProperty C) (L : C ⥤ D) (L' : C ⥤ D')
[L.IsLocalization W] [L'.IsLocalization W] {X : C}
/-- The bijection `StructuredArrow (L.obj X) L ≃ StructuredArrow (L'.obj X) L'`
when `L` and `L'` are two localization functors for the same class of morphisms. -/
@[simps]
noncomputable def structuredArrowEquiv :
StructuredArrow (L.obj X) L ≃ StructuredArrow (L'.obj X) L' where
toFun f := StructuredArrow.mk (homEquiv W L L' f.hom)
invFun f := StructuredArrow.mk (homEquiv W L' L f.hom)
left_inv f := by
obtain ⟨Y, f, rfl⟩ := f.mk_surjective
dsimp
rw [← homEquiv_symm_apply, Equiv.symm_apply_apply]
right_inv f := by
obtain ⟨Y, f, rfl⟩ := f.mk_surjective
dsimp
rw [← homEquiv_symm_apply, Equiv.symm_apply_apply]
end
section
variable (W : MorphismProperty C) {X : C}
(P : StructuredArrow (W.Q.obj X) W.Q → Prop)
open Construction in
private lemma induction_structuredArrow'
(hP₀ : P (StructuredArrow.mk (𝟙 (W.Q.obj X))))
(hP₁ : ∀ ⦃Y₁ Y₂ : C⦄ (f : Y₁ ⟶ Y₂) (φ : W.Q.obj X ⟶ W.Q.obj Y₁),
P (StructuredArrow.mk φ) → P (StructuredArrow.mk (φ ≫ W.Q.map f)))
(hP₂ : ∀ ⦃Y₁ Y₂ : C⦄ (w : Y₁ ⟶ Y₂) (hw : W w) (φ : W.Q.obj X ⟶ W.Q.obj Y₂),
P (StructuredArrow.mk φ) → P (StructuredArrow.mk (φ ≫ (isoOfHom W.Q W w hw).inv)))
(g : StructuredArrow (W.Q.obj X) W.Q) : P g := by
let X₀ : Paths (LocQuiver W) := ⟨X⟩
suffices ∀ ⦃Y₀ : Paths (LocQuiver W)⦄ (f : X₀ ⟶ Y₀),
P (StructuredArrow.mk ((Quotient.functor (relations W)).map f)) by
obtain ⟨Y, g, rfl⟩ := g.mk_surjective
obtain ⟨g, rfl⟩ := (Quotient.functor (relations W)).map_surjective g
exact this g
intro Y₀ f
induction f with
| nil => exact hP₀
| cons f g hf =>
obtain (g|⟨w, hw⟩) := g
· exact hP₁ g _ hf
· simpa only [← Construction.wInv_eq_isoOfHom_inv w hw] using hP₂ w hw _ hf
end
section
variable (L : C ⥤ D) (W : MorphismProperty C) [L.IsLocalization W] {X : C}
(P : StructuredArrow (L.obj X) L → Prop)
@[elab_as_elim]
lemma induction_structuredArrow
(hP₀ : P (StructuredArrow.mk (𝟙 (L.obj X))))
(hP₁ : ∀ ⦃Y₁ Y₂ : C⦄ (f : Y₁ ⟶ Y₂) (φ : L.obj X ⟶ L.obj Y₁),
P (StructuredArrow.mk φ) → P (StructuredArrow.mk (φ ≫ L.map f)))
(hP₂ : ∀ ⦃Y₁ Y₂ : C⦄ (w : Y₁ ⟶ Y₂) (hw : W w) (φ : L.obj X ⟶ L.obj Y₂),
P (StructuredArrow.mk φ) → P (StructuredArrow.mk (φ ≫ (isoOfHom L W w hw).inv)))
(g : StructuredArrow (L.obj X) L) : P g := by
let P' : StructuredArrow (W.Q.obj X) W.Q → Prop :=
fun g ↦ P (structuredArrowEquiv W W.Q L g)
rw [← (structuredArrowEquiv W W.Q L).apply_symm_apply g]
apply induction_structuredArrow' W P'
· convert hP₀
simp
· intro Y₁ Y₂ f φ hφ
convert hP₁ f (homEquiv W W.Q L φ) hφ
simp [homEquiv_comp]
· intro Y₁ Y₂ w hw φ hφ
convert hP₂ w hw (homEquiv W W.Q L φ) hφ
simp [homEquiv_comp, homEquiv_isoOfHom_inv]
end
section
variable (L : C ⥤ D) (W : MorphismProperty C) [L.IsLocalization W] {Y : C}
(P : CostructuredArrow L (L.obj Y) → Prop)
@[elab_as_elim]
lemma induction_costructuredArrow
(hP₀ : P (CostructuredArrow.mk (𝟙 (L.obj Y))))
(hP₁ : ∀ ⦃X₁ X₂ : C⦄ (f : X₁ ⟶ X₂) (φ : L.obj X₂ ⟶ L.obj Y),
P (CostructuredArrow.mk φ) → P (CostructuredArrow.mk (L.map f ≫ φ)))
(hP₂ : ∀ ⦃X₁ X₂ : C⦄ (w : X₁ ⟶ X₂) (hw : W w) (φ : L.obj X₁ ⟶ L.obj Y),
P (CostructuredArrow.mk φ) → P (CostructuredArrow.mk ((isoOfHom L W w hw).inv ≫ φ)))
(g : CostructuredArrow L (L.obj Y)) : P g := by
let g' := StructuredArrow.mk (T := L.op) (Y := op g.left) g.hom.op
change P (CostructuredArrow.mk g'.hom.unop)
induction g' using induction_structuredArrow L.op W.op with
| hP₀ => exact hP₀
| hP₁ f φ hφ => exact hP₁ f.unop φ.unop hφ
| hP₂ w hw φ hφ => simpa [isoOfHom_op_inv L W w hw] using hP₂ w.unop hw φ.unop hφ
end
end Localization
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Localization/Resolution.lean | import Mathlib.CategoryTheory.Localization.LocalizerMorphism
/-!
# Resolutions for a morphism of localizers
Given a morphism of localizers `Φ : LocalizerMorphism W₁ W₂` (i.e. `W₁` and `W₂` are
morphism properties on categories `C₁` and `C₂`, and we have a functor
`Φ.functor : C₁ ⥤ C₂` which sends morphisms in `W₁` to morphisms in `W₂`), we introduce
the notion of right resolutions of objects in `C₂`: if `X₂ : C₂`.
A right resolution consists of an object `X₁ : C₁` and a morphism
`w : X₂ ⟶ Φ.functor.obj X₁` that is in `W₂`. Then, the typeclass
`Φ.HasRightResolutions` holds when any `X₂ : C₂` has a right resolution.
The type of right resolutions `Φ.RightResolution X₂` is endowed with a category
structure.
Similar definitions are done for left resolutions.
## Future works
* show that if `C` is an abelian category with enough injectives, there is a derivability
structure associated to the inclusion of the full subcategory of complexes of injective
objects into the bounded below homotopy category of `C` (TODO @joelriou)
* formalize dual results
## References
* [Bruno Kahn and Georges Maltsiniotis, *Structures de dérivabilité*][KahnMaltsiniotis2008]
-/
universe v₁ v₂ v₂' u₁ u₂ u₂'
namespace CategoryTheory
open Category Localization
variable {C₁ C₂ D₂ H : Type*} [Category C₁] [Category C₂] [Category D₂] [Category H]
{W₁ : MorphismProperty C₁} {W₂ : MorphismProperty C₂}
namespace LocalizerMorphism
variable (Φ : LocalizerMorphism W₁ W₂)
/-- The category of right resolutions of an object in the target category
of a localizer morphism. -/
structure RightResolution (X₂ : C₂) where
/-- an object in the source category -/
{X₁ : C₁}
/-- a morphism to an object of the form `Φ.functor.obj X₁` -/
w : X₂ ⟶ Φ.functor.obj X₁
hw : W₂ w
/-- The category of left resolutions of an object in the target category
of a localizer morphism. -/
structure LeftResolution (X₂ : C₂) where
/-- an object in the source category -/
{X₁ : C₁}
/-- a morphism from an object of the form `Φ.functor.obj X₁` -/
w : Φ.functor.obj X₁ ⟶ X₂
hw : W₂ w
variable {Φ X₂} in
lemma RightResolution.mk_surjective (R : Φ.RightResolution X₂) :
∃ (X₁ : C₁) (w : X₂ ⟶ Φ.functor.obj X₁) (hw : W₂ w), R = RightResolution.mk w hw :=
⟨_, R.w, R.hw, rfl⟩
variable {Φ X₂} in
lemma LeftResolution.mk_surjective (L : Φ.LeftResolution X₂) :
∃ (X₁ : C₁) (w : Φ.functor.obj X₁ ⟶ X₂) (hw : W₂ w), L = LeftResolution.mk w hw :=
⟨_, L.w, L.hw, rfl⟩
/-- A localizer morphism has right resolutions when any object has a right resolution. -/
abbrev HasRightResolutions := ∀ (X₂ : C₂), Nonempty (Φ.RightResolution X₂)
/-- A localizer morphism has right resolutions when any object has a right resolution. -/
abbrev HasLeftResolutions := ∀ (X₂ : C₂), Nonempty (Φ.LeftResolution X₂)
namespace RightResolution
variable {Φ} {X₂ : C₂}
/-- The type of morphisms in the category `Φ.RightResolution X₂`. -/
@[ext]
structure Hom (R R' : Φ.RightResolution X₂) where
/-- a morphism in the source category -/
f : R.X₁ ⟶ R'.X₁
comm : R.w ≫ Φ.functor.map f = R'.w := by cat_disch
attribute [reassoc (attr := simp)] Hom.comm
/-- The identity of an object in `Φ.RightResolution X₂`. -/
@[simps]
def Hom.id (R : Φ.RightResolution X₂) : Hom R R where
f := 𝟙 _
/-- The composition of morphisms in `Φ.RightResolution X₂`. -/
@[simps]
def Hom.comp {R R' R'' : Φ.RightResolution X₂}
(φ : Hom R R') (ψ : Hom R' R'') :
Hom R R'' where
f := φ.f ≫ ψ.f
instance : Category (Φ.RightResolution X₂) where
Hom := Hom
id := Hom.id
comp := Hom.comp
@[simp]
lemma id_f (R : Φ.RightResolution X₂) : Hom.f (𝟙 R) = 𝟙 R.X₁ := rfl
@[simp, reassoc]
lemma comp_f {R R' R'' : Φ.RightResolution X₂} (φ : R ⟶ R') (ψ : R' ⟶ R'') :
(φ ≫ ψ).f = φ.f ≫ ψ.f := rfl
@[ext]
lemma hom_ext {R R' : Φ.RightResolution X₂} {φ₁ φ₂ : R ⟶ R'} (h : φ₁.f = φ₂.f) :
φ₁ = φ₂ :=
Hom.ext h
end RightResolution
namespace LeftResolution
variable {Φ} {X₂ : C₂}
/-- The type of morphisms in the category `Φ.LeftResolution X₂`. -/
@[ext]
structure Hom (L L' : Φ.LeftResolution X₂) where
/-- a morphism in the source category -/
f : L.X₁ ⟶ L'.X₁
comm : Φ.functor.map f ≫ L'.w = L.w := by cat_disch
attribute [reassoc (attr := simp)] Hom.comm
/-- The identity of an object in `Φ.LeftResolution X₂`. -/
@[simps]
def Hom.id (L : Φ.LeftResolution X₂) : Hom L L where
f := 𝟙 _
/-- The composition of morphisms in `Φ.LeftResolution X₂`. -/
@[simps]
def Hom.comp {L L' L'' : Φ.LeftResolution X₂}
(φ : Hom L L') (ψ : Hom L' L'') :
Hom L L'' where
f := φ.f ≫ ψ.f
instance : Category (Φ.LeftResolution X₂) where
Hom := Hom
id := Hom.id
comp := Hom.comp
@[simp]
lemma id_f (L : Φ.LeftResolution X₂) : Hom.f (𝟙 L) = 𝟙 L.X₁ := rfl
@[simp, reassoc]
lemma comp_f {L L' L'' : Φ.LeftResolution X₂} (φ : L ⟶ L') (ψ : L' ⟶ L'') :
(φ ≫ ψ).f = φ.f ≫ ψ.f := rfl
@[ext]
lemma hom_ext {L L' : Φ.LeftResolution X₂} {φ₁ φ₂ : L ⟶ L'} (h : φ₁.f = φ₂.f) :
φ₁ = φ₂ :=
Hom.ext h
end LeftResolution
variable {Φ}
/-- The canonical map `Φ.LeftResolution X₂ → Φ.op.RightResolution (Opposite.op X₂)`. -/
@[simps]
def LeftResolution.op {X₂ : C₂} (L : Φ.LeftResolution X₂) :
Φ.op.RightResolution (Opposite.op X₂) where
X₁ := Opposite.op L.X₁
w := L.w.op
hw := L.hw
/-- The canonical map `Φ.op.LeftResolution X₂ → Φ.RightResolution X₂`. -/
@[simps]
def LeftResolution.unop {X₂ : C₂ᵒᵖ} (L : Φ.op.LeftResolution X₂) :
Φ.RightResolution X₂.unop where
X₁ := Opposite.unop L.X₁
w := L.w.unop
hw := L.hw
/-- The canonical map `Φ.RightResolution X₂ → Φ.op.LeftResolution (Opposite.op X₂)`. -/
@[simps]
def RightResolution.op {X₂ : C₂} (L : Φ.RightResolution X₂) :
Φ.op.LeftResolution (Opposite.op X₂) where
X₁ := Opposite.op L.X₁
w := L.w.op
hw := L.hw
/-- The canonical map `Φ.op.RightResolution X₂ → Φ.LeftResolution X₂`. -/
@[simps]
def RightResolution.unop {X₂ : C₂ᵒᵖ} (L : Φ.op.RightResolution X₂) :
Φ.LeftResolution X₂.unop where
X₁ := Opposite.unop L.X₁
w := L.w.unop
hw := L.hw
variable (Φ)
lemma nonempty_leftResolution_iff_op (X₂ : C₂) :
Nonempty (Φ.LeftResolution X₂) ↔ Nonempty (Φ.op.RightResolution (Opposite.op X₂)) :=
Equiv.nonempty_congr
{ toFun := fun L => L.op
invFun := fun R => R.unop }
lemma nonempty_rightResolution_iff_op (X₂ : C₂) :
Nonempty (Φ.RightResolution X₂) ↔ Nonempty (Φ.op.LeftResolution (Opposite.op X₂)) :=
Equiv.nonempty_congr
{ toFun := fun R => R.op
invFun := fun L => L.unop }
lemma hasLeftResolutions_iff_op : Φ.HasLeftResolutions ↔ Φ.op.HasRightResolutions :=
⟨fun _ X₂ => ⟨(Classical.arbitrary (Φ.LeftResolution X₂.unop)).op⟩,
fun _ X₂ => ⟨(Classical.arbitrary (Φ.op.RightResolution (Opposite.op X₂))).unop⟩⟩
lemma hasRightResolutions_iff_op : Φ.HasRightResolutions ↔ Φ.op.HasLeftResolutions :=
⟨fun _ X₂ => ⟨(Classical.arbitrary (Φ.RightResolution X₂.unop)).op⟩,
fun _ X₂ => ⟨(Classical.arbitrary (Φ.op.LeftResolution (Opposite.op X₂))).unop⟩⟩
instance [Φ.HasRightResolutions] : Φ.op.HasLeftResolutions := by
rwa [← hasRightResolutions_iff_op]
instance [Φ.HasLeftResolutions] : Φ.op.HasRightResolutions := by
rwa [← hasLeftResolutions_iff_op]
/-- The functor `(Φ.LeftResolution X₂)ᵒᵖ ⥤ Φ.op.RightResolution (Opposite.op X₂)`. -/
@[simps]
def LeftResolution.opFunctor (X₂ : C₂) :
(Φ.LeftResolution X₂)ᵒᵖ ⥤ Φ.op.RightResolution (Opposite.op X₂) where
obj L := L.unop.op
map φ :=
{ f := φ.unop.f.op
comm := Quiver.Hom.unop_inj φ.unop.comm }
/-- The functor `(Φ.op.RightResolution X₂)ᵒᵖ ⥤ Φ.LeftResolution X₂.unop`. -/
@[simps]
def RightResolution.unopFunctor (X₂ : C₂ᵒᵖ) :
(Φ.op.RightResolution X₂)ᵒᵖ ⥤ Φ.LeftResolution X₂.unop where
obj R := R.unop.unop
map φ :=
{ f := φ.unop.f.unop
comm := Quiver.Hom.op_inj φ.unop.comm }
/-- The equivalence of categories
`(Φ.LeftResolution X₂)ᵒᵖ ≌ Φ.op.RightResolution (Opposite.op X₂)`. -/
@[simps]
def LeftResolution.opEquivalence (X₂ : C₂) :
(Φ.LeftResolution X₂)ᵒᵖ ≌ Φ.op.RightResolution (Opposite.op X₂) where
functor := LeftResolution.opFunctor Φ X₂
inverse := (RightResolution.unopFunctor Φ (Opposite.op X₂)).rightOp
unitIso := Iso.refl _
counitIso := Iso.refl _
section
variable (L₂ : C₂ ⥤ D₂) [L₂.IsLocalization W₂]
lemma essSurj_of_hasRightResolutions [Φ.HasRightResolutions] : (Φ.functor ⋙ L₂).EssSurj where
mem_essImage X₂ := by
have := Localization.essSurj L₂ W₂
have R : Φ.RightResolution (L₂.objPreimage X₂) := Classical.arbitrary _
exact ⟨R.X₁, ⟨(Localization.isoOfHom L₂ W₂ _ R.hw).symm ≪≫ L₂.objObjPreimageIso X₂⟩⟩
lemma isIso_iff_of_hasRightResolutions [Φ.HasRightResolutions] {F G : D₂ ⥤ H} (α : F ⟶ G) :
IsIso α ↔ ∀ (X₁ : C₁), IsIso (α.app (L₂.obj (Φ.functor.obj X₁))) := by
constructor
· intros
infer_instance
· intro hα
have : ∀ (X₂ : D₂), IsIso (α.app X₂) := fun X₂ => by
have := Φ.essSurj_of_hasRightResolutions L₂
rw [← NatTrans.isIso_app_iff_of_iso α ((Φ.functor ⋙ L₂).objObjPreimageIso X₂)]
apply hα
exact NatIso.isIso_of_isIso_app α
lemma essSurj_of_hasLeftResolutions [Φ.HasLeftResolutions] : (Φ.functor ⋙ L₂).EssSurj where
mem_essImage X₂ := by
have := Localization.essSurj L₂ W₂
have L : Φ.LeftResolution (L₂.objPreimage X₂) := Classical.arbitrary _
exact ⟨L.X₁, ⟨Localization.isoOfHom L₂ W₂ _ L.hw ≪≫ L₂.objObjPreimageIso X₂⟩⟩
lemma isIso_iff_of_hasLeftResolutions [Φ.HasLeftResolutions] {F G : D₂ ⥤ H} (α : F ⟶ G) :
IsIso α ↔ ∀ (X₁ : C₁), IsIso (α.app (L₂.obj (Φ.functor.obj X₁))) := by
constructor
· intros
infer_instance
· intro hα
have : ∀ (X₂ : D₂), IsIso (α.app X₂) := fun X₂ => by
have := Φ.essSurj_of_hasLeftResolutions L₂
rw [← NatTrans.isIso_app_iff_of_iso α ((Φ.functor ⋙ L₂).objObjPreimageIso X₂)]
apply hα
exact NatIso.isIso_of_isIso_app α
end
end LocalizerMorphism
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Localization/Predicate.lean | import Mathlib.CategoryTheory.Localization.Construction
/-!
# Predicate for localized categories
In this file, a predicate `L.IsLocalization W` is introduced for a functor `L : C ⥤ D`
and `W : MorphismProperty C`: it expresses that `L` identifies `D` with the localized
category of `C` with respect to `W` (up to equivalence).
We introduce a universal property `StrictUniversalPropertyFixedTarget L W E` which
states that `L` inverts the morphisms in `W` and that all functors `C ⥤ E` inverting
`W` uniquely factors as a composition of `L ⋙ G` with `G : D ⥤ E`. Such universal
properties are inputs for the constructor `IsLocalization.mk'` for `L.IsLocalization W`.
When `L : C ⥤ D` is a localization functor for `W : MorphismProperty` (i.e. when
`[L.IsLocalization W]` holds), for any category `E`, there is
an equivalence `FunctorEquivalence L W E : (D ⥤ E) ≌ (W.FunctorsInverting E)`
that is induced by the composition with the functor `L`. When two functors
`F : C ⥤ E` and `F' : D ⥤ E` correspond via this equivalence, we shall say
that `F'` lifts `F`, and the associated isomorphism `L ⋙ F' ≅ F` is the
datum that is part of the class `Lifting L W F F'`. The functions
`liftNatTrans` and `liftNatIso` can be used to lift natural transformations
and natural isomorphisms between functors.
-/
noncomputable section
namespace CategoryTheory
open Category Functor
variable {C D : Type*} [Category C] [Category D] (L : C ⥤ D) (W : MorphismProperty C) (E : Type*)
[Category E]
namespace Functor
/-- The predicate expressing that, up to equivalence, a functor `L : C ⥤ D`
identifies the category `D` with the localized category of `C` with respect
to `W : MorphismProperty C`. -/
class IsLocalization : Prop where
/-- the functor inverts the given `MorphismProperty` -/
inverts : W.IsInvertedBy L
/-- the induced functor from the constructed localized category is an equivalence -/
isEquivalence : IsEquivalence (Localization.Construction.lift L inverts)
instance q_isLocalization : W.Q.IsLocalization W where
inverts := W.Q_inverts
isEquivalence := by
suffices Localization.Construction.lift W.Q W.Q_inverts = 𝟭 _ by
rw [this]
infer_instance
apply Localization.Construction.uniq
simp only [Localization.Construction.fac]
rfl
end Functor
namespace Localization
/-- This universal property states that a functor `L : C ⥤ D` inverts morphisms
in `W` and the all functors `D ⥤ E` (for a fixed category `E`) uniquely factors
through `L`. -/
structure StrictUniversalPropertyFixedTarget where
/-- the functor `L` inverts `W` -/
inverts : W.IsInvertedBy L
/-- any functor `C ⥤ E` which inverts `W` can be lifted as a functor `D ⥤ E` -/
lift : ∀ (F : C ⥤ E) (_ : W.IsInvertedBy F), D ⥤ E
/-- there is a factorisation involving the lifted functor -/
fac : ∀ (F : C ⥤ E) (hF : W.IsInvertedBy F), L ⋙ lift F hF = F
/-- uniqueness of the lifted functor -/
uniq : ∀ (F₁ F₂ : D ⥤ E) (_ : L ⋙ F₁ = L ⋙ F₂), F₁ = F₂
/-- The localized category `W.Localization` that was constructed satisfies
the universal property of the localization. -/
@[simps]
def strictUniversalPropertyFixedTargetQ : StrictUniversalPropertyFixedTarget W.Q W E where
inverts := W.Q_inverts
lift := Construction.lift
fac := Construction.fac
uniq := Construction.uniq
instance : Inhabited (StrictUniversalPropertyFixedTarget W.Q W E) :=
⟨strictUniversalPropertyFixedTargetQ _ _⟩
/-- When `W` consists of isomorphisms, the identity satisfies the universal property
of the localization. -/
@[simps]
def strictUniversalPropertyFixedTargetId (hW : W ≤ MorphismProperty.isomorphisms C) :
StrictUniversalPropertyFixedTarget (𝟭 C) W E where
inverts _ _ f hf := hW f hf
lift F _ := F
fac F hF := by
cases F
rfl
uniq F₁ F₂ eq := by
cases F₁
cases F₂
exact eq
end Localization
namespace Functor
theorem IsLocalization.mk' (h₁ : Localization.StrictUniversalPropertyFixedTarget L W D)
(h₂ : Localization.StrictUniversalPropertyFixedTarget L W W.Localization) :
IsLocalization L W :=
{ inverts := h₁.inverts
isEquivalence := IsEquivalence.mk' (h₂.lift W.Q W.Q_inverts)
(eqToIso (Localization.Construction.uniq _ _ (by
simp only [← Functor.assoc, Localization.Construction.fac, h₂.fac, Functor.comp_id])))
(eqToIso (h₁.uniq _ _ (by
simp only [← Functor.assoc, h₂.fac, Localization.Construction.fac, Functor.comp_id]))) }
theorem IsLocalization.for_id (hW : W ≤ MorphismProperty.isomorphisms C) : (𝟭 C).IsLocalization W :=
IsLocalization.mk' _ _ (Localization.strictUniversalPropertyFixedTargetId W _ hW)
(Localization.strictUniversalPropertyFixedTargetId W _ hW)
end Functor
namespace Localization
variable [L.IsLocalization W]
theorem inverts : W.IsInvertedBy L :=
(inferInstance : L.IsLocalization W).inverts
/-- The isomorphism `L.obj X ≅ L.obj Y` that is deduced from a morphism `f : X ⟶ Y` which
belongs to `W`, when `L.IsLocalization W`. -/
@[simps! hom]
def isoOfHom {X Y : C} (f : X ⟶ Y) (hf : W f) : L.obj X ≅ L.obj Y :=
haveI : IsIso (L.map f) := inverts L W f hf
asIso (L.map f)
@[reassoc (attr := simp)]
lemma isoOfHom_hom_inv_id {X Y : C} (f : X ⟶ Y) (hf : W f) :
L.map f ≫ (isoOfHom L W f hf).inv = 𝟙 _ :=
(isoOfHom L W f hf).hom_inv_id
@[reassoc (attr := simp)]
lemma isoOfHom_inv_hom_id {X Y : C} (f : X ⟶ Y) (hf : W f) :
(isoOfHom L W f hf).inv ≫ L.map f = 𝟙 _ :=
(isoOfHom L W f hf).inv_hom_id
@[simp]
lemma isoOfHom_id_inv (X : C) (hX : W (𝟙 X)) :
(isoOfHom L W (𝟙 X) hX).inv = 𝟙 _ := by
rw [← cancel_mono (isoOfHom L W (𝟙 X) hX).hom, Iso.inv_hom_id, id_comp,
isoOfHom_hom, Functor.map_id]
variable {W}
lemma Construction.wIso_eq_isoOfHom {X Y : C} (f : X ⟶ Y) (hf : W f) :
Construction.wIso f hf = isoOfHom W.Q W f hf := by ext; rfl
lemma Construction.wInv_eq_isoOfHom_inv {X Y : C} (f : X ⟶ Y) (hf : W f) :
Construction.wInv f hf = (isoOfHom W.Q W f hf).inv :=
congr_arg Iso.inv (wIso_eq_isoOfHom f hf)
instance : (Localization.Construction.lift L (inverts L W)).IsEquivalence :=
(inferInstance : L.IsLocalization W).isEquivalence
variable (W)
/-- A chosen equivalence of categories `W.Localization ≅ D` for a functor
`L : C ⥤ D` which satisfies `L.IsLocalization W`. This shall be used in
order to deduce properties of `L` from properties of `W.Q`. -/
def equivalenceFromModel : W.Localization ≌ D :=
(Localization.Construction.lift L (inverts L W)).asEquivalence
/-- Via the equivalence of categories `equivalence_from_model L W : W.localization ≌ D`,
one may identify the functors `W.Q` and `L`. -/
def qCompEquivalenceFromModelFunctorIso : W.Q ⋙ (equivalenceFromModel L W).functor ≅ L :=
eqToIso (Construction.fac _ _)
/-- Via the equivalence of categories `equivalence_from_model L W : W.localization ≌ D`,
one may identify the functors `L` and `W.Q`. -/
def compEquivalenceFromModelInverseIso : L ⋙ (equivalenceFromModel L W).inverse ≅ W.Q :=
calc
L ⋙ (equivalenceFromModel L W).inverse ≅ _ :=
isoWhiskerRight (qCompEquivalenceFromModelFunctorIso L W).symm _
_ ≅ W.Q ⋙ (equivalenceFromModel L W).functor ⋙ (equivalenceFromModel L W).inverse :=
(associator _ _ _)
_ ≅ W.Q ⋙ 𝟭 _ := isoWhiskerLeft _ (equivalenceFromModel L W).unitIso.symm
_ ≅ W.Q := rightUnitor _
theorem essSurj (W) [L.IsLocalization W] : L.EssSurj :=
⟨fun X =>
⟨(Construction.objEquiv W).invFun ((equivalenceFromModel L W).inverse.obj X),
Nonempty.intro
((qCompEquivalenceFromModelFunctorIso L W).symm.app _ ≪≫
(equivalenceFromModel L W).counitIso.app X)⟩⟩
/-- The functor `(D ⥤ E) ⥤ W.functors_inverting E` induced by the composition
with a localization functor `L : C ⥤ D` with respect to `W : MorphismProperty C`. -/
def whiskeringLeftFunctor : (D ⥤ E) ⥤ W.FunctorsInverting E :=
ObjectProperty.lift _ ((whiskeringLeft _ _ E).obj L)
(MorphismProperty.IsInvertedBy.of_comp W L (inverts L W))
instance : (whiskeringLeftFunctor L W E).IsEquivalence := by
let iso : (whiskeringLeft (MorphismProperty.Localization W) D E).obj
(equivalenceFromModel L W).functor ⋙
(Construction.whiskeringLeftEquivalence W E).functor ≅ whiskeringLeftFunctor L W E :=
NatIso.ofComponents (fun F => eqToIso (by
ext
change (W.Q ⋙ Localization.Construction.lift L (inverts L W)) ⋙ F = L ⋙ F
rw [Construction.fac])) (fun τ => by
ext
dsimp [Construction.whiskeringLeftEquivalence, equivalenceFromModel, whiskerLeft]
erw [NatTrans.comp_app, NatTrans.comp_app, eqToHom_app, eqToHom_app, eqToHom_refl,
eqToHom_refl, comp_id, id_comp]
· rfl
all_goals
change (W.Q ⋙ Localization.Construction.lift L (inverts L W)) ⋙ _ = L ⋙ _
rw [Construction.fac])
exact Functor.isEquivalence_of_iso iso
/-- The equivalence of categories `(D ⥤ E) ≌ (W.FunctorsInverting E)` induced by
the composition with a localization functor `L : C ⥤ D` with respect to
`W : MorphismProperty C`. -/
def functorEquivalence : D ⥤ E ≌ W.FunctorsInverting E :=
(whiskeringLeftFunctor L W E).asEquivalence
/-- The functor `(D ⥤ E) ⥤ (C ⥤ E)` given by the composition with a localization
functor `L : C ⥤ D` with respect to `W : MorphismProperty C`. -/
@[nolint unusedArguments]
def whiskeringLeftFunctor' [L.IsLocalization W] (E : Type*) [Category E] :
(D ⥤ E) ⥤ C ⥤ E :=
(whiskeringLeft C D E).obj L
theorem whiskeringLeftFunctor'_eq :
whiskeringLeftFunctor' L W E = Localization.whiskeringLeftFunctor L W E ⋙ inducedFunctor _ :=
rfl
variable {E} in
@[simp]
theorem whiskeringLeftFunctor'_obj (F : D ⥤ E) : (whiskeringLeftFunctor' L W E).obj F = L ⋙ F :=
rfl
instance : (whiskeringLeftFunctor' L W E).Full := by
rw [whiskeringLeftFunctor'_eq]
apply @Functor.Full.comp _ _ _ _ _ _ _ _ ?_ ?_
· infer_instance
apply InducedCategory.full -- why is it not found automatically ???
instance : (whiskeringLeftFunctor' L W E).Faithful := by
rw [whiskeringLeftFunctor'_eq]
apply @Functor.Faithful.comp _ _ _ _ _ _ _ _ ?_ ?_
· infer_instance
apply InducedCategory.faithful -- why is it not found automatically ???
lemma full_whiskeringLeft (L : C ⥤ D) (W) [L.IsLocalization W] (E : Type*) [Category E] :
((whiskeringLeft C D E).obj L).Full :=
inferInstanceAs (whiskeringLeftFunctor' L W E).Full
lemma faithful_whiskeringLeft (L : C ⥤ D) (W) [L.IsLocalization W] (E : Type*) [Category E] :
((whiskeringLeft C D E).obj L).Faithful :=
inferInstanceAs (whiskeringLeftFunctor' L W E).Faithful
variable {E}
theorem natTrans_ext (L : C ⥤ D) (W) [L.IsLocalization W] {F₁ F₂ : D ⥤ E} {τ τ' : F₁ ⟶ F₂}
(h : ∀ X : C, τ.app (L.obj X) = τ'.app (L.obj X)) : τ = τ' := by
haveI := essSurj L W
ext Y
rw [← cancel_epi (F₁.map (L.objObjPreimageIso Y).hom), τ.naturality, τ'.naturality, h]
/-- When `L : C ⥤ D` is a localization functor for `W : MorphismProperty C` and
`F : C ⥤ E` is a functor, we shall say that `F' : D ⥤ E` lifts `F` if the obvious diagram
is commutative up to an isomorphism. -/
class Lifting (L : C ⥤ D) (W : MorphismProperty C) (F : C ⥤ E) (F' : D ⥤ E) where
/-- the isomorphism relating the localization functor and the two other given functors -/
iso (L W F F') : L ⋙ F' ≅ F
@[deprecated (since := "2025-08-22")] alias Lifting.iso' := Lifting.iso
variable {W}
/-- Given a localization functor `L : C ⥤ D` for `W : MorphismProperty C` and
a functor `F : C ⥤ E` which inverts `W`, this is a choice of functor
`D ⥤ E` which lifts `F`. -/
def lift (F : C ⥤ E) (hF : W.IsInvertedBy F) (L : C ⥤ D) [L.IsLocalization W] : D ⥤ E :=
(functorEquivalence L W E).inverse.obj ⟨F, hF⟩
instance liftingLift (F : C ⥤ E) (hF : W.IsInvertedBy F) (L : C ⥤ D) [L.IsLocalization W] :
Lifting L W F (lift F hF L) :=
⟨(inducedFunctor _).mapIso ((functorEquivalence L W E).counitIso.app ⟨F, hF⟩)⟩
/-- The canonical isomorphism `L ⋙ lift F hF L ≅ F` for any functor `F : C ⥤ E`
which inverts `W`, when `L : C ⥤ D` is a localization functor for `W`. -/
def fac (F : C ⥤ E) (hF : W.IsInvertedBy F) (L : C ⥤ D) [L.IsLocalization W] :
L ⋙ lift F hF L ≅ F :=
Lifting.iso L W F _
instance liftingConstructionLift (F : C ⥤ D) (hF : W.IsInvertedBy F) :
Lifting W.Q W F (Construction.lift F hF) :=
⟨eqToIso (Construction.fac F hF)⟩
variable (W)
/-- Given a localization functor `L : C ⥤ D` for `W : MorphismProperty C`,
if `(F₁' F₂' : D ⥤ E)` are functors which lifts functors `(F₁ F₂ : C ⥤ E)`,
a natural transformation `τ : F₁ ⟶ F₂` uniquely lifts to a natural transformation `F₁' ⟶ F₂'`. -/
def liftNatTrans (F₁ F₂ : C ⥤ E) (F₁' F₂' : D ⥤ E) [Lifting L W F₁ F₁'] [Lifting L W F₂ F₂']
(τ : F₁ ⟶ F₂) : F₁' ⟶ F₂' :=
(whiskeringLeftFunctor' L W E).preimage
((Lifting.iso L W F₁ F₁').hom ≫ τ ≫ (Lifting.iso L W F₂ F₂').inv)
@[simp]
theorem liftNatTrans_app (F₁ F₂ : C ⥤ E) (F₁' F₂' : D ⥤ E) [Lifting L W F₁ F₁'] [Lifting L W F₂ F₂']
(τ : F₁ ⟶ F₂) (X : C) :
(liftNatTrans L W F₁ F₂ F₁' F₂' τ).app (L.obj X) =
(Lifting.iso L W F₁ F₁').hom.app X ≫ τ.app X ≫ (Lifting.iso L W F₂ F₂').inv.app X :=
congr_app (Functor.map_preimage (whiskeringLeftFunctor' L W E) _) X
@[reassoc (attr := simp)]
theorem comp_liftNatTrans (F₁ F₂ F₃ : C ⥤ E) (F₁' F₂' F₃' : D ⥤ E) [h₁ : Lifting L W F₁ F₁']
[h₂ : Lifting L W F₂ F₂'] [h₃ : Lifting L W F₃ F₃'] (τ : F₁ ⟶ F₂) (τ' : F₂ ⟶ F₃) :
liftNatTrans L W F₁ F₂ F₁' F₂' τ ≫ liftNatTrans L W F₂ F₃ F₂' F₃' τ' =
liftNatTrans L W F₁ F₃ F₁' F₃' (τ ≫ τ') :=
natTrans_ext L W fun X => by
simp only [NatTrans.comp_app, liftNatTrans_app, assoc, Iso.inv_hom_id_app_assoc]
@[simp]
theorem liftNatTrans_id (F : C ⥤ E) (F' : D ⥤ E) [h : Lifting L W F F'] :
liftNatTrans L W F F F' F' (𝟙 F) = 𝟙 F' :=
natTrans_ext L W fun X => by
simp only [liftNatTrans_app, NatTrans.id_app, id_comp, Iso.hom_inv_id_app]
rfl
/-- Given a localization functor `L : C ⥤ D` for `W : MorphismProperty C`,
if `(F₁' F₂' : D ⥤ E)` are functors which lifts functors `(F₁ F₂ : C ⥤ E)`,
a natural isomorphism `τ : F₁ ⟶ F₂` lifts to a natural isomorphism `F₁' ⟶ F₂'`. -/
@[simps]
def liftNatIso (F₁ F₂ : C ⥤ E) (F₁' F₂' : D ⥤ E) [h₁ : Lifting L W F₁ F₁'] [h₂ : Lifting L W F₂ F₂']
(e : F₁ ≅ F₂) : F₁' ≅ F₂' where
hom := liftNatTrans L W F₁ F₂ F₁' F₂' e.hom
inv := liftNatTrans L W F₂ F₁ F₂' F₁' e.inv
namespace Lifting
@[simps]
instance compRight {E' : Type*} [Category E'] (F : C ⥤ E) (F' : D ⥤ E) [Lifting L W F F']
(G : E ⥤ E') : Lifting L W (F ⋙ G) (F' ⋙ G) :=
⟨isoWhiskerRight (iso L W F F') G⟩
@[simps]
instance id : Lifting L W L (𝟭 D) :=
⟨rightUnitor L⟩
@[simps]
instance compLeft (F : D ⥤ E) : Localization.Lifting L W (L ⋙ F) F := ⟨Iso.refl _⟩
/-- Given a localization functor `L : C ⥤ D` for `W : MorphismProperty C`,
if `F₁' : D ⥤ E` lifts a functor `F₁ : C ⥤ D`, then a functor `F₂'` which
is isomorphic to `F₁'` also lifts a functor `F₂` that is isomorphic to `F₁`. -/
@[simps]
def ofIsos {F₁ F₂ : C ⥤ E} {F₁' F₂' : D ⥤ E} (e : F₁ ≅ F₂) (e' : F₁' ≅ F₂') [Lifting L W F₁ F₁'] :
Lifting L W F₂ F₂' :=
⟨isoWhiskerLeft L e'.symm ≪≫ iso L W F₁ F₁' ≪≫ e⟩
end Lifting
end Localization
namespace Functor
namespace IsLocalization
open Localization
theorem of_iso {L₁ L₂ : C ⥤ D} (e : L₁ ≅ L₂) [L₁.IsLocalization W] : L₂.IsLocalization W := by
have h := Localization.inverts L₁ W
rw [MorphismProperty.IsInvertedBy.iff_of_iso W e] at h
let F₁ := Localization.Construction.lift L₁ (Localization.inverts L₁ W)
let F₂ := Localization.Construction.lift L₂ h
exact
{ inverts := h
isEquivalence := Functor.isEquivalence_of_iso (liftNatIso W.Q W L₁ L₂ F₁ F₂ e) }
/-- If `L : C ⥤ D` is a localization for `W : MorphismProperty C`, then it is also
the case of a functor obtained by post-composing `L` with an equivalence of categories. -/
theorem of_equivalence_target {E : Type*} [Category E] (L' : C ⥤ E) (eq : D ≌ E)
[L.IsLocalization W] (e : L ⋙ eq.functor ≅ L') : L'.IsLocalization W := by
have h : W.IsInvertedBy L' := by
rw [← MorphismProperty.IsInvertedBy.iff_of_iso W e]
exact MorphismProperty.IsInvertedBy.of_comp W L (Localization.inverts L W) eq.functor
let F₁ := Localization.Construction.lift L (Localization.inverts L W)
let F₂ := Localization.Construction.lift L' h
let e' : F₁ ⋙ eq.functor ≅ F₂ := liftNatIso W.Q W (L ⋙ eq.functor) L' _ _ e
exact
{ inverts := h
isEquivalence := Functor.isEquivalence_of_iso e' }
instance (F : D ⥤ E) [F.IsEquivalence] [L.IsLocalization W] :
(L ⋙ F).IsLocalization W :=
of_equivalence_target L W _ F.asEquivalence (Iso.refl _)
lemma of_isEquivalence (L : C ⥤ D) (W : MorphismProperty C)
(hW : W ≤ MorphismProperty.isomorphisms C) [IsEquivalence L] :
L.IsLocalization W := by
haveI : (𝟭 C).IsLocalization W := for_id W hW
exact of_equivalence_target (𝟭 C) W L L.asEquivalence L.leftUnitor
end IsLocalization
end Functor
namespace Localization
variable {D₁ D₂ : Type _} [Category D₁] [Category D₂] (L₁ : C ⥤ D₁) (L₂ : C ⥤ D₂)
(W' : MorphismProperty C) [L₁.IsLocalization W'] [L₂.IsLocalization W']
/-- If `L₁ : C ⥤ D₁` and `L₂ : C ⥤ D₂` are two localization functors for the
same `MorphismProperty C`, this is an equivalence of categories `D₁ ≌ D₂`. -/
def uniq : D₁ ≌ D₂ :=
(equivalenceFromModel L₁ W').symm.trans (equivalenceFromModel L₂ W')
lemma uniq_symm : (uniq L₁ L₂ W').symm = uniq L₂ L₁ W' := by
dsimp [uniq, Equivalence.trans]
ext <;> aesop
/-- The functor of equivalence of localized categories given by `Localization.uniq` is
compatible with the localization functors. -/
def compUniqFunctor : L₁ ⋙ (uniq L₁ L₂ W').functor ≅ L₂ :=
calc
L₁ ⋙ (uniq L₁ L₂ W').functor ≅ (L₁ ⋙ (equivalenceFromModel L₁ W').inverse) ⋙
(equivalenceFromModel L₂ W').functor := (associator _ _ _).symm
_ ≅ W'.Q ⋙ (equivalenceFromModel L₂ W').functor :=
isoWhiskerRight (compEquivalenceFromModelInverseIso L₁ W') _
_ ≅ L₂ := qCompEquivalenceFromModelFunctorIso L₂ W'
/-- The inverse functor of equivalence of localized categories given by `Localization.uniq` is
compatible with the localization functors. -/
def compUniqInverse : L₂ ⋙ (uniq L₁ L₂ W').inverse ≅ L₁ := compUniqFunctor L₂ L₁ W'
instance : Lifting L₁ W' L₂ (uniq L₁ L₂ W').functor := ⟨compUniqFunctor L₁ L₂ W'⟩
instance : Lifting L₂ W' L₁ (uniq L₁ L₂ W').inverse := ⟨compUniqInverse L₁ L₂ W'⟩
/-- If `L₁ : C ⥤ D₁` and `L₂ : C ⥤ D₂` are two localization functors for the
same `MorphismProperty C`, any functor `F : D₁ ⥤ D₂` equipped with an isomorphism
`L₁ ⋙ F ≅ L₂` is isomorphic to the functor of the equivalence given by `uniq`. -/
def isoUniqFunctor (F : D₁ ⥤ D₂) (e : L₁ ⋙ F ≅ L₂) :
F ≅ (uniq L₁ L₂ W').functor :=
letI : Lifting L₁ W' L₂ F := ⟨e⟩
liftNatIso L₁ W' L₂ L₂ F (uniq L₁ L₂ W').functor (Iso.refl L₂)
lemma morphismProperty_eq_top [L.IsLocalization W] (P : MorphismProperty D) [P.RespectsIso]
[P.IsMultiplicative] (h₁ : ∀ ⦃X Y : C⦄ (f : X ⟶ Y), P (L.map f))
(h₂ : ∀ ⦃X Y : C⦄ (f : X ⟶ Y) (hf : W f), P (isoOfHom L W f hf).inv) :
P = ⊤ := by
let e := compUniqFunctor W.Q L W
have hP : P.inverseImage (uniq W.Q L W).functor = ⊤ :=
Construction.morphismProperty_eq_top _
(fun _ _ f ↦ (P.arrow_mk_iso_iff
(((Functor.mapArrowFunctor _ _).mapIso e).app (Arrow.mk f))).2 (h₁ f))
(fun X Y f hf ↦ by
refine (P.arrow_mk_iso_iff (Arrow.isoMk (e.app _) (e.app _) ?_)).2 (h₂ f hf)
dsimp
rw [Construction.wInv_eq_isoOfHom_inv, ← cancel_mono (isoOfHom L W f hf).hom,
assoc, assoc, Iso.inv_hom_id, comp_id, isoOfHom_hom, ← NatTrans.naturality,
Functor.comp_map, ← Functor.map_comp_assoc,
isoOfHom_inv_hom_id, map_id, id_comp])
rw [← P.map_inverseImage_eq_of_isEquivalence (uniq W.Q L W).functor, hP,
MorphismProperty.map_top_eq_top_of_essSurj_of_full]
lemma isGroupoid [L.IsLocalization ⊤] :
IsGroupoid D := by
rw [isGroupoid_iff_isomorphisms_eq_top]
exact morphismProperty_eq_top L ⊤ _
(fun _ _ f ↦ inverts L ⊤ _ (by simp))
(fun _ _ f hf ↦ Iso.isIso_inv _)
instance : IsGroupoid (⊤ : MorphismProperty C).Localization :=
isGroupoid <| MorphismProperty.Q ⊤
/-- Localization of a category with respect to all morphisms results in a groupoid. -/
def groupoid : Groupoid (⊤ : MorphismProperty C).Localization :=
Groupoid.ofIsGroupoid
end Localization
section
variable {X Y : C} (f g : X ⟶ Y)
/-- The property that two morphisms become equal in the localized category. -/
def AreEqualizedByLocalization : Prop := W.Q.map f = W.Q.map g
lemma areEqualizedByLocalization_iff [L.IsLocalization W] :
AreEqualizedByLocalization W f g ↔ L.map f = L.map g := by
dsimp [AreEqualizedByLocalization]
constructor
· intro h
let e := Localization.compUniqFunctor W.Q L W
rw [← NatIso.naturality_1 e f, ← NatIso.naturality_1 e g]
dsimp
rw [h]
· intro h
let e := Localization.compUniqFunctor L W.Q W
rw [← NatIso.naturality_1 e f, ← NatIso.naturality_1 e g]
dsimp
rw [h]
namespace AreEqualizedByLocalization
lemma mk (L : C ⥤ D) [L.IsLocalization W] (h : L.map f = L.map g) :
AreEqualizedByLocalization W f g :=
(areEqualizedByLocalization_iff L W f g).2 h
variable {W f g}
lemma map_eq (h : AreEqualizedByLocalization W f g) (L : C ⥤ D) [L.IsLocalization W] :
L.map f = L.map g :=
(areEqualizedByLocalization_iff L W f g).1 h
lemma map_eq_of_isInvertedBy (h : AreEqualizedByLocalization W f g)
(F : C ⥤ D) (hF : W.IsInvertedBy F) :
F.map f = F.map g := by
simp [← NatIso.naturality_1 (Localization.fac F hF W.Q), h.map_eq W.Q]
end AreEqualizedByLocalization
end
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Localization/Monoidal/Basic.lean | import Mathlib.CategoryTheory.Localization.Trifunctor
import Mathlib.CategoryTheory.Monoidal.Functor
/-!
# Localization of monoidal categories
Let `C` be a monoidal category equipped with a class of morphisms `W` which
is compatible with the monoidal category structure: this means `W`
is multiplicative and stable by left and right whiskerings (this is
the type class `W.IsMonoidal`). Let `L : C ⥤ D` be a localization functor
for `W`. In the file, we construct a monoidal category structure
on `D` such that the localization functor is monoidal. The structure
is actually defined on a type synonym `LocalizedMonoidal L W ε`.
Here, the data `ε : L.obj (𝟙_ C) ≅ unit` is an isomorphism to some
object `unit : D` which allows the user to provide a preferred choice
of a unit object.
The symmetric case is considered in the file `Mathlib.CategoryTheory.Localization.Monoidal.Braided`.
-/
namespace CategoryTheory
open Category MonoidalCategory
variable {C D : Type*} [Category C] [Category D] (L : C ⥤ D) (W : MorphismProperty C)
[MonoidalCategory C]
namespace MorphismProperty
/-- A class of morphisms `W` in a monoidal category is monoidal if it is multiplicative
and stable under left and right whiskering. Under this condition, the localized
category can be equipped with a monoidal category structure, see `LocalizedMonoidal`. -/
class IsMonoidal : Prop extends W.IsMultiplicative where
whiskerLeft (X : C) {Y₁ Y₂ : C} (g : Y₁ ⟶ Y₂) (hg : W g) : W (X ◁ g)
whiskerRight {X₁ X₂ : C} (f : X₁ ⟶ X₂) (hf : W f) (Y : C) : W (f ▷ Y)
/-- Alternative constructor for `W.IsMonoidal` given that `W` is multiplicative and stable under
tensoring morphisms. -/
lemma IsMonoidal.mk' [W.IsMultiplicative]
(h : ∀ {X₁ X₂ Y₁ Y₂ : C} (f : X₁ ⟶ X₂) (g : Y₁ ⟶ Y₂) (_ : W f) (_ : W g), W (f ⊗ₘ g)) :
W.IsMonoidal where
whiskerLeft X _ _ g hg := by simpa using h (𝟙 X) g (W.id_mem _) hg
whiskerRight f hf Y := by simpa using h f (𝟙 Y) hf (W.id_mem _)
variable [W.IsMonoidal]
lemma whiskerLeft_mem (X : C) {Y₁ Y₂ : C} (g : Y₁ ⟶ Y₂) (hg : W g) : W (X ◁ g) :=
IsMonoidal.whiskerLeft _ _ hg
lemma whiskerRight_mem {X₁ X₂ : C} (f : X₁ ⟶ X₂) (hf : W f) (Y : C) : W (f ▷ Y) :=
IsMonoidal.whiskerRight _ hf Y
lemma tensorHom_mem {X₁ X₂ : C} (f : X₁ ⟶ X₂) {Y₁ Y₂ : C} (g : Y₁ ⟶ Y₂)
(hf : W f) (hg : W g) : W (f ⊗ₘ g) := by
rw [tensorHom_def]
exact comp_mem _ _ _ (whiskerRight_mem _ _ hf _) (whiskerLeft_mem _ _ _ hg)
/-- The inverse image under a monoidal functor of a monoidal morphism property which respects
isomorphisms is monoidal. -/
instance {C' : Type*} [Category C'] [MonoidalCategory C'] (F : C' ⥤ C) [F.Monoidal]
[W.RespectsIso] : (W.inverseImage F).IsMonoidal := .mk' _ fun f g hf hg ↦ by
simp only [inverseImage_iff] at hf hg ⊢
rw [Functor.Monoidal.map_tensor _ f g]
apply MorphismProperty.RespectsIso.precomp
apply MorphismProperty.RespectsIso.postcomp
exact tensorHom_mem _ _ _ hf hg
end MorphismProperty
/-- Given a monoidal category `C`, a localization functor `L : C ⥤ D` with respect
to `W : MorphismProperty C` which satisfies `W.IsMonoidal`, and a choice
of object `unit : D` with an isomorphism `L.obj (𝟙_ C) ≅ unit`, this is a
type synonym for `D` on which we define the localized monoidal category structure. -/
@[nolint unusedArguments]
def LocalizedMonoidal (L : C ⥤ D) (W : MorphismProperty C)
[W.IsMonoidal] [L.IsLocalization W] {unit : D} (_ : L.obj (𝟙_ C) ≅ unit) :=
D
variable [W.IsMonoidal] [L.IsLocalization W] {unit : D} (ε : L.obj (𝟙_ C) ≅ unit)
namespace Localization
instance : Category (LocalizedMonoidal L W ε) :=
inferInstanceAs (Category D)
namespace Monoidal
/-- The monoidal functor from a monoidal category `C` to
its localization `LocalizedMonoidal L W ε`. -/
def toMonoidalCategory : C ⥤ LocalizedMonoidal L W ε := L
/-- The isomorphism `ε : L.obj (𝟙_ C) ≅ unit`,
as `(toMonoidalCategory L W ε).obj (𝟙_ C) ≅ unit`. -/
abbrev ε' : (toMonoidalCategory L W ε).obj (𝟙_ C) ≅ unit := ε
local notation "L'" => toMonoidalCategory L W ε
instance : (L').IsLocalization W := inferInstanceAs (L.IsLocalization W)
lemma isInvertedBy₂ :
MorphismProperty.IsInvertedBy₂ W W
(curriedTensor C ⋙ (Functor.whiskeringRight C C D).obj L') := by
rintro ⟨X₁, Y₁⟩ ⟨X₂, Y₂⟩ ⟨f₁, f₂⟩ ⟨hf₁, hf₂⟩
have := Localization.inverts L' W _ (W.whiskerRight_mem f₁ hf₁ Y₁)
have := Localization.inverts L' W _ (W.whiskerLeft_mem X₂ f₂ hf₂)
dsimp
infer_instance
/-- The localized tensor product, as a bifunctor. -/
noncomputable def tensorBifunctor :
LocalizedMonoidal L W ε ⥤ LocalizedMonoidal L W ε ⥤ LocalizedMonoidal L W ε :=
Localization.lift₂ _ (isInvertedBy₂ L W ε) L L
noncomputable instance : Lifting₂ L' L' W W (curriedTensor C ⋙ (Functor.whiskeringRight C C
(LocalizedMonoidal L W ε)).obj L') (tensorBifunctor L W ε) :=
inferInstanceAs (Lifting₂ L L W W (curriedTensor C ⋙ (Functor.whiskeringRight C C D).obj L')
(Localization.lift₂ _ (isInvertedBy₂ L W ε) L L))
/-- The bifunctor `tensorBifunctor` on `LocalizedMonoidal L W ε` is induced by
`curriedTensor C`. -/
noncomputable abbrev tensorBifunctorIso :
(((Functor.whiskeringLeft₂ D).obj L').obj L').obj (tensorBifunctor L W ε) ≅
(Functor.postcompose₂.obj L').obj (curriedTensor C) :=
Lifting₂.iso L' L' W W (curriedTensor C ⋙ (Functor.whiskeringRight C C
(LocalizedMonoidal L W ε)).obj L') (tensorBifunctor L W ε)
noncomputable instance (X : C) :
Lifting L' W (tensorLeft X ⋙ L') ((tensorBifunctor L W ε).obj ((L').obj X)) := by
apply Lifting₂.liftingLift₂ (hF := isInvertedBy₂ L W ε)
noncomputable instance (Y : C) :
Lifting L' W (tensorRight Y ⋙ L') ((tensorBifunctor L W ε).flip.obj ((L').obj Y)) := by
apply Lifting₂.liftingLift₂Flip (hF := isInvertedBy₂ L W ε)
/-- The left unitor in the localized monoidal category `LocalizedMonoidal L W ε`. -/
noncomputable def leftUnitor : (tensorBifunctor L W ε).obj unit ≅ 𝟭 _ :=
(tensorBifunctor L W ε).mapIso ε.symm ≪≫
Localization.liftNatIso L' W (tensorLeft (𝟙_ C) ⋙ L') L'
((tensorBifunctor L W ε).obj ((L').obj (𝟙_ _))) _
(Functor.isoWhiskerRight (leftUnitorNatIso C) _ ≪≫ L.leftUnitor)
/-- The right unitor in the localized monoidal category `LocalizedMonoidal L W ε`. -/
noncomputable def rightUnitor : (tensorBifunctor L W ε).flip.obj unit ≅ 𝟭 _ :=
(tensorBifunctor L W ε).flip.mapIso ε.symm ≪≫
Localization.liftNatIso L' W (tensorRight (𝟙_ C) ⋙ L') L'
((tensorBifunctor L W ε).flip.obj ((L').obj (𝟙_ _))) _
(Functor.isoWhiskerRight (rightUnitorNatIso C) _ ≪≫ L.leftUnitor)
/-- The associator in the localized monoidal category `LocalizedMonoidal L W ε`. -/
noncomputable def associator :
bifunctorComp₁₂ (tensorBifunctor L W ε) (tensorBifunctor L W ε) ≅
bifunctorComp₂₃ (tensorBifunctor L W ε) (tensorBifunctor L W ε) :=
Localization.associator L' L' L' L' L' L' W W W W W
(curriedAssociatorNatIso C) (tensorBifunctor L W ε) (tensorBifunctor L W ε)
(tensorBifunctor L W ε) (tensorBifunctor L W ε)
noncomputable instance monoidalCategoryStruct :
MonoidalCategoryStruct (LocalizedMonoidal L W ε) where
tensorObj X Y := ((tensorBifunctor L W ε).obj X).obj Y
whiskerLeft X _ _ g := ((tensorBifunctor L W ε).obj X).map g
whiskerRight f Y := ((tensorBifunctor L W ε).map f).app Y
tensorUnit := unit
associator X Y Z := (((associator L W ε).app X).app Y).app Z
leftUnitor Y := (leftUnitor L W ε).app Y
rightUnitor X := (rightUnitor L W ε).app X
/-- The compatibility isomorphism of the monoidal functor `toMonoidalCategory L W ε`
with respect to the tensor product. -/
noncomputable def μ (X Y : C) : (L').obj X ⊗ (L').obj Y ≅ (L').obj (X ⊗ Y) :=
((tensorBifunctorIso L W ε).app X).app Y
@[reassoc (attr := simp)]
lemma μ_natural_left {X₁ X₂ : C} (f : X₁ ⟶ X₂) (Y : C) :
(L').map f ▷ (L').obj Y ≫ (μ L W ε X₂ Y).hom =
(μ L W ε X₁ Y).hom ≫ (L').map (f ▷ Y) :=
NatTrans.naturality_app (tensorBifunctorIso L W ε).hom Y f
@[reassoc (attr := simp)]
lemma μ_inv_natural_left {X₁ X₂ : C} (f : X₁ ⟶ X₂) (Y : C) :
(μ L W ε X₁ Y).inv ≫ (L').map f ▷ (L').obj Y =
(L').map (f ▷ Y) ≫ (μ L W ε X₂ Y).inv := by
simp [Iso.eq_comp_inv]
@[reassoc (attr := simp)]
lemma μ_natural_right (X : C) {Y₁ Y₂ : C} (g : Y₁ ⟶ Y₂) :
(L').obj X ◁ (L').map g ≫ (μ L W ε X Y₂).hom =
(μ L W ε X Y₁).hom ≫ (L').map (X ◁ g) :=
((tensorBifunctorIso L W ε).hom.app X).naturality g
@[reassoc (attr := simp)]
lemma μ_inv_natural_right (X : C) {Y₁ Y₂ : C} (g : Y₁ ⟶ Y₂) :
(μ L W ε X Y₁).inv ≫ (L').obj X ◁ (L').map g =
(L').map (X ◁ g) ≫ (μ L W ε X Y₂).inv := by
simp [Iso.eq_comp_inv]
lemma leftUnitor_hom_app (Y : C) :
(λ_ ((L').obj Y)).hom =
(ε' L W ε).inv ▷ (L').obj Y ≫ (μ _ _ _ _ _).hom ≫ (L').map (λ_ Y).hom := by
dsimp [monoidalCategoryStruct, leftUnitor]
rw [liftNatTrans_app]
dsimp
rw [assoc]
change _ ≫ (μ L W ε _ _).hom ≫ _ ≫ 𝟙 _ ≫ 𝟙 _ = _
simp only [comp_id]
lemma rightUnitor_hom_app (X : C) :
(ρ_ ((L').obj X)).hom =
(L').obj X ◁ (ε' L W ε).inv ≫ (μ _ _ _ _ _).hom ≫
(L').map (ρ_ X).hom := by
dsimp [monoidalCategoryStruct, rightUnitor]
rw [liftNatTrans_app]
dsimp
rw [assoc]
change _ ≫ (μ L W ε _ _).hom ≫ _ ≫ 𝟙 _ ≫ 𝟙 _ = _
simp only [comp_id]
lemma associator_hom_app (X₁ X₂ X₃ : C) :
(α_ ((L').obj X₁) ((L').obj X₂) ((L').obj X₃)).hom =
((μ L W ε _ _).hom ⊗ₘ 𝟙 _) ≫ (μ L W ε _ _).hom ≫ (L').map (α_ X₁ X₂ X₃).hom ≫
(μ L W ε _ _).inv ≫ (𝟙 _ ⊗ₘ (μ L W ε _ _).inv) := by
dsimp [monoidalCategoryStruct, associator]
simp only [Functor.map_id, comp_id, NatTrans.id_app, id_comp]
rw [Localization.associator_hom_app_app_app]
rfl
lemma id_tensorHom (X : LocalizedMonoidal L W ε) {Y₁ Y₂ : LocalizedMonoidal L W ε} (f : Y₁ ⟶ Y₂) :
𝟙 X ⊗ₘ f = X ◁ f := by
simp [monoidalCategoryStruct]
lemma tensorHom_id {X₁ X₂ : LocalizedMonoidal L W ε} (f : X₁ ⟶ X₂) (Y : LocalizedMonoidal L W ε) :
f ⊗ₘ 𝟙 Y = f ▷ Y := by
simp [monoidalCategoryStruct]
@[reassoc]
lemma tensor_comp {X₁ Y₁ Z₁ X₂ Y₂ Z₂ : LocalizedMonoidal L W ε}
(f₁ : X₁ ⟶ Y₁) (f₂ : X₂ ⟶ Y₂) (g₁ : Y₁ ⟶ Z₁) (g₂ : Y₂ ⟶ Z₂) :
(f₁ ≫ g₁) ⊗ₘ (f₂ ≫ g₂) = (f₁ ⊗ₘ f₂) ≫ (g₁ ⊗ₘ g₂) := by
simp [monoidalCategoryStruct]
lemma id_tensorHom_id (X₁ X₂ : LocalizedMonoidal L W ε) : 𝟙 X₁ ⊗ₘ 𝟙 X₂ = 𝟙 (X₁ ⊗ X₂) := by
simp [monoidalCategoryStruct]
@[deprecated (since := "2025-07-14")] alias tensor_id := id_tensorHom_id
@[reassoc]
theorem whiskerLeft_comp (Q : LocalizedMonoidal L W ε) {X Y Z : LocalizedMonoidal L W ε}
(f : X ⟶ Y) (g : Y ⟶ Z) :
Q ◁ (f ≫ g) = Q ◁ f ≫ Q ◁ g := by
simp only [← id_tensorHom, ← tensor_comp, comp_id]
@[reassoc]
theorem whiskerRight_comp (Q : LocalizedMonoidal L W ε) {X Y Z : LocalizedMonoidal L W ε}
(f : X ⟶ Y) (g : Y ⟶ Z) :
(f ≫ g) ▷ Q = f ▷ Q ≫ g ▷ Q := by
simp only [← tensorHom_id, ← tensor_comp, comp_id]
lemma whiskerLeft_id (X Y : LocalizedMonoidal L W ε) :
X ◁ (𝟙 Y) = 𝟙 _ := by simp [monoidalCategoryStruct]
lemma whiskerRight_id (X Y : LocalizedMonoidal L W ε) :
(𝟙 X) ▷ Y = 𝟙 _ := by simp [monoidalCategoryStruct]
@[reassoc]
lemma whisker_exchange {Q X Y Z : LocalizedMonoidal L W ε} (f : Q ⟶ X) (g : Y ⟶ Z) :
Q ◁ g ≫ f ▷ Z = f ▷ Y ≫ X ◁ g := by
simp only [← id_tensorHom, ← tensorHom_id, ← tensor_comp, id_comp, comp_id]
@[reassoc]
lemma associator_naturality {X₁ X₂ X₃ Y₁ Y₂ Y₃ : LocalizedMonoidal L W ε}
(f₁ : X₁ ⟶ Y₁) (f₂ : X₂ ⟶ Y₂) (f₃ : X₃ ⟶ Y₃) :
((f₁ ⊗ₘ f₂) ⊗ₘ f₃) ≫ (α_ Y₁ Y₂ Y₃).hom = (α_ X₁ X₂ X₃).hom ≫ (f₁ ⊗ₘ f₂ ⊗ₘ f₃) := by
have h₁ := (((associator L W ε).hom.app Y₁).app Y₂).naturality f₃
have h₂ := NatTrans.congr_app (((associator L W ε).hom.app Y₁).naturality f₂) X₃
have h₃ := NatTrans.congr_app (NatTrans.congr_app ((associator L W ε).hom.naturality f₁) X₂) X₃
simp only [monoidalCategoryStruct, Functor.map_comp, assoc]
dsimp at h₁ h₂ h₃ ⊢
rw [h₁, assoc, reassoc_of% h₂, reassoc_of% h₃]
@[reassoc]
lemma associator_naturality₁ {X₁ X₂ X₃ Y₁ : LocalizedMonoidal L W ε} (f₁ : X₁ ⟶ Y₁) :
((f₁ ▷ X₂) ▷ X₃) ≫ (α_ Y₁ X₂ X₃).hom = (α_ X₁ X₂ X₃).hom ≫ (f₁ ▷ (X₂ ⊗ X₃)) := by
simp only [← tensorHom_id, associator_naturality, id_tensorHom_id]
@[reassoc]
lemma associator_naturality₂ {X₁ X₂ X₃ Y₂ : LocalizedMonoidal L W ε} (f₂ : X₂ ⟶ Y₂) :
((X₁ ◁ f₂) ▷ X₃) ≫ (α_ X₁ Y₂ X₃).hom = (α_ X₁ X₂ X₃).hom ≫ (X₁ ◁ (f₂ ▷ X₃)) := by
simp only [← tensorHom_id, ← id_tensorHom, associator_naturality]
@[reassoc]
lemma associator_naturality₃ {X₁ X₂ X₃ Y₃ : LocalizedMonoidal L W ε} (f₃ : X₃ ⟶ Y₃) :
((X₁ ⊗ X₂) ◁ f₃) ≫ (α_ X₁ X₂ Y₃).hom = (α_ X₁ X₂ X₃).hom ≫ (X₁ ◁ (X₂ ◁ f₃)) := by
simp only [← id_tensorHom, ← id_tensorHom_id, associator_naturality]
lemma pentagon_aux₁ {X₁ X₂ X₃ Y₁ : LocalizedMonoidal L W ε} (i : X₁ ≅ Y₁) :
((i.hom ▷ X₂) ▷ X₃) ≫ (α_ Y₁ X₂ X₃).hom ≫ (i.inv ▷ (X₂ ⊗ X₃)) = (α_ X₁ X₂ X₃).hom := by
simp only [associator_naturality₁_assoc, ← whiskerRight_comp,
Iso.hom_inv_id, whiskerRight_id, comp_id]
lemma pentagon_aux₂ {X₁ X₂ X₃ Y₂ : LocalizedMonoidal L W ε} (i : X₂ ≅ Y₂) :
((X₁ ◁ i.hom) ▷ X₃) ≫ (α_ X₁ Y₂ X₃).hom ≫ (X₁ ◁ (i.inv ▷ X₃)) = (α_ X₁ X₂ X₃).hom := by
simp only [associator_naturality₂_assoc, ← whiskerLeft_comp, ← whiskerRight_comp,
Iso.hom_inv_id, whiskerRight_id, whiskerLeft_id, comp_id]
lemma pentagon_aux₃ {X₁ X₂ X₃ Y₃ : LocalizedMonoidal L W ε} (i : X₃ ≅ Y₃) :
((X₁ ⊗ X₂) ◁ i.hom) ≫ (α_ X₁ X₂ Y₃).hom ≫ (X₁ ◁ (X₂ ◁ i.inv)) = (α_ X₁ X₂ X₃).hom := by
simp only [associator_naturality₃_assoc, ← whiskerLeft_comp,
Iso.hom_inv_id, whiskerLeft_id, comp_id]
instance : (L').EssSurj := Localization.essSurj L' W
variable {L W ε} in
lemma pentagon (Y₁ Y₂ Y₃ Y₄ : LocalizedMonoidal L W ε) :
Pentagon Y₁ Y₂ Y₃ Y₄ := by
obtain ⟨X₁, ⟨e₁⟩⟩ : ∃ X₁, Nonempty ((L').obj X₁ ≅ Y₁) := ⟨_, ⟨(L').objObjPreimageIso Y₁⟩⟩
obtain ⟨X₂, ⟨e₂⟩⟩ : ∃ X₂, Nonempty ((L').obj X₂ ≅ Y₂) := ⟨_, ⟨(L').objObjPreimageIso Y₂⟩⟩
obtain ⟨X₃, ⟨e₃⟩⟩ : ∃ X₃, Nonempty ((L').obj X₃ ≅ Y₃) := ⟨_, ⟨(L').objObjPreimageIso Y₃⟩⟩
obtain ⟨X₄, ⟨e₄⟩⟩ : ∃ X₄, Nonempty ((L').obj X₄ ≅ Y₄) := ⟨_, ⟨(L').objObjPreimageIso Y₄⟩⟩
suffices Pentagon ((L').obj X₁) ((L').obj X₂) ((L').obj X₃) ((L').obj X₄) by
dsimp [Pentagon]
refine Eq.trans ?_ (((((e₁.inv ⊗ₘ e₂.inv) ⊗ₘ e₃.inv) ⊗ₘ e₄.inv) ≫= this =≫
(e₁.hom ⊗ₘ e₂.hom ⊗ₘ e₃.hom ⊗ₘ e₄.hom)).trans ?_)
· rw [← id_tensorHom, ← id_tensorHom, ← tensorHom_id, ← tensorHom_id, assoc, assoc,
← tensor_comp, ← associator_naturality, id_comp, ← comp_id e₁.hom,
tensor_comp, ← associator_naturality_assoc, ← comp_id (𝟙 ((L').obj X₄)),
← tensor_comp_assoc, associator_naturality, comp_id, comp_id,
← tensor_comp_assoc, assoc, e₄.inv_hom_id, ← tensor_comp, e₁.inv_hom_id,
← tensor_comp, e₂.inv_hom_id, e₃.inv_hom_id, id_tensorHom_id, id_tensorHom_id, comp_id]
· rw [assoc, associator_naturality_assoc, associator_naturality_assoc,
← tensor_comp, e₁.inv_hom_id, ← tensor_comp, e₂.inv_hom_id, ← tensor_comp,
e₃.inv_hom_id, e₄.inv_hom_id, id_tensorHom_id, id_tensorHom_id, id_tensorHom_id, comp_id]
dsimp [Pentagon]
have : ((L').obj X₁ ◁ (μ L W ε X₂ X₃).inv) ▷ (L').obj X₄ ≫
(α_ ((L').obj X₁) ((L').obj X₂ ⊗ (L').obj X₃) ((L').obj X₄)).hom ≫
(L').obj X₁ ◁ (μ L W ε X₂ X₃).hom ▷ (L').obj X₄ =
(α_ ((L').obj X₁) ((L').obj (X₂ ⊗ X₃)) ((L').obj X₄)).hom :=
pentagon_aux₂ _ _ _ (μ L W ε X₂ X₃).symm
rw [associator_hom_app, tensorHom_id, id_tensorHom, associator_hom_app, tensorHom_id,
whiskerLeft_comp, whiskerRight_comp, whiskerRight_comp, whiskerRight_comp, assoc, assoc,
assoc, whiskerRight_comp, assoc,
reassoc_of% this, associator_hom_app, tensorHom_id,
← pentagon_aux₁ (X₂ := (L').obj X₃) (X₃ := (L').obj X₄) (i := μ L W ε X₁ X₂),
← pentagon_aux₃ (X₁ := (L').obj X₁) (X₂ := (L').obj X₂) (i := μ L W ε X₃ X₄),
associator_hom_app, associator_hom_app]
simp only [assoc, ← whiskerRight_comp_assoc, Iso.inv_hom_id, comp_id, μ_natural_left_assoc,
id_tensorHom, ← whiskerLeft_comp, Iso.inv_hom_id_assoc]
rw [← (L').map_comp_assoc, whiskerLeft_comp, μ_inv_natural_right_assoc, ← (L').map_comp_assoc]
simp only [assoc, MonoidalCategory.pentagon, Functor.map_comp, tensorHom_id,
whiskerRight_comp_assoc]
congr 3; simp only [← assoc]; congr
simp only [← cancel_mono (μ L W ε (X₁ ⊗ X₂) (X₃ ⊗ X₄)).inv, assoc, id_comp,
whisker_exchange_assoc, ← whiskerRight_comp_assoc,
Iso.inv_hom_id, whiskerRight_id, ← whiskerLeft_comp,
whiskerLeft_id]
lemma leftUnitor_naturality {X Y : LocalizedMonoidal L W ε} (f : X ⟶ Y) :
𝟙_ (LocalizedMonoidal L W ε) ◁ f ≫ (λ_ Y).hom = (λ_ X).hom ≫ f := by
simp [monoidalCategoryStruct]
lemma rightUnitor_naturality {X Y : LocalizedMonoidal L W ε} (f : X ⟶ Y) :
f ▷ 𝟙_ (LocalizedMonoidal L W ε) ≫ (ρ_ Y).hom = (ρ_ X).hom ≫ f :=
(rightUnitor L W ε).hom.naturality f
@[reassoc]
lemma triangle_aux₁ {X₁ X₂ X₃ Y₁ Y₂ Y₃ : LocalizedMonoidal L W ε}
(i₁ : X₁ ≅ Y₁) (i₂ : X₂ ≅ Y₂) (i₃ : X₃ ≅ Y₃) :
((i₁.hom ⊗ₘ i₂.hom) ⊗ₘ i₃.hom) ≫ (α_ Y₁ Y₂ Y₃).hom ≫ (i₁.inv ⊗ₘ i₂.inv ⊗ₘ i₃.inv) =
(α_ X₁ X₂ X₃).hom := by
simp only [associator_naturality_assoc, ← tensor_comp, Iso.hom_inv_id, id_tensorHom,
whiskerLeft_id, comp_id]
lemma triangle_aux₂ {X Y : LocalizedMonoidal L W ε} {X' Y' : C}
(e₁ : (L').obj X' ≅ X) (e₂ : (L').obj Y' ≅ Y) :
e₁.hom ⊗ₘ (ε.hom ⊗ₘ e₂.hom) ≫ (λ_ Y).hom =
(L').obj X' ◁ ((ε' L W ε).hom ▷ (L').obj Y' ≫
𝟙_ _ ◁ e₂.hom ≫ (λ_ Y).hom) ≫ e₁.hom ▷ Y := by
simp only [← tensorHom_id, ← id_tensorHom, ← tensor_comp, comp_id, id_comp,
← tensor_comp_assoc, id_comp]
congr 3
exact (comp_id _).symm
lemma triangle_aux₃ {X Y : LocalizedMonoidal L W ε} {X' Y' : C}
(e₁ : (L').obj X' ≅ X) (e₂ : (L').obj Y' ≅ Y) : (ρ_ X).hom ▷ _ =
((e₁.inv ⊗ₘ ε.inv) ⊗ₘ e₂.inv) ≫ _ ◁ e₂.hom ≫ ((μ L W ε X' (𝟙_ C)).hom ≫
(L').map (ρ_ X').hom) ▷ Y ≫ e₁.hom ▷ Y := by
simp only [← tensorHom_id, ← id_tensorHom, ← tensor_comp, assoc, comp_id,
id_comp, Iso.inv_hom_id]
congr
rw [← cancel_mono e₁.inv, assoc, assoc, assoc, Iso.hom_inv_id, comp_id,
← rightUnitor_naturality, rightUnitor_hom_app,
← tensorHom_id, ← id_tensorHom, ← tensor_comp_assoc, comp_id, id_comp]
variable {L W ε} in
lemma triangle (X Y : LocalizedMonoidal L W ε) :
(α_ X (𝟙_ _) Y).hom ≫ X ◁ (λ_ Y).hom = (ρ_ X).hom ▷ Y := by
obtain ⟨X', ⟨e₁⟩⟩ : ∃ X₁, Nonempty ((L').obj X₁ ≅ X) := ⟨_, ⟨(L').objObjPreimageIso X⟩⟩
obtain ⟨Y', ⟨e₂⟩⟩ : ∃ X₂, Nonempty ((L').obj X₂ ≅ Y) := ⟨_, ⟨(L').objObjPreimageIso Y⟩⟩
have h₁ := (associator_hom_app L W ε X' (𝟙_ _) Y' =≫
(𝟙 ((L').obj X') ⊗ₘ (μ L W ε (𝟙_ C) Y').hom))
simp only [assoc, id_tensorHom, ← whiskerLeft_comp,
Iso.inv_hom_id, whiskerLeft_id, comp_id, Iso.inv_hom_id,
← cancel_mono (μ L W ε X' (𝟙_ C ⊗ Y')).hom] at h₁
have h₂ := (ε' L W ε).hom ▷ (L').obj Y' ≫= leftUnitor_hom_app L W ε Y'
simp only [← whiskerRight_comp_assoc, Iso.hom_inv_id, whiskerRight_id, id_comp] at h₂
have h₃ := (((μ L W ε _ _).hom ⊗ₘ 𝟙 _) ≫ (μ L W ε _ _).hom) ≫=
((L').congr_map (MonoidalCategory.triangle X' Y'))
simp only [assoc, Functor.map_comp, ← reassoc_of% h₁] at h₃
rw [← μ_natural_left, tensorHom_id, ← whiskerRight_comp_assoc,
← μ_natural_right, ← Iso.comp_inv_eq, assoc, assoc, assoc,
Iso.hom_inv_id, comp_id, ← whiskerLeft_comp, ← h₂] at h₃
replace h₃ := ((e₁.inv ⊗ₘ ε.inv) ⊗ₘ e₂.inv) ≫= (h₃ =≫ (_ ◁ e₂.hom)) =≫ (e₁.hom ▷ _)
simp only [← whiskerLeft_comp, assoc, ← leftUnitor_naturality, ← whisker_exchange] at h₃
have : _ = (α_ X (𝟙_ (LocalizedMonoidal L W ε)) Y).hom :=
triangle_aux₁ _ _ _ e₁.symm ε.symm e₂.symm
simp only [← this, Iso.symm_hom, Iso.symm_inv, assoc,
← id_tensorHom, ← tensor_comp, comp_id]
convert h₃
· exact triangle_aux₂ _ _ _ e₁ e₂
· exact triangle_aux₃ _ _ _ e₁ e₂
noncomputable instance :
MonoidalCategory (LocalizedMonoidal L W ε) where
tensorHom_def := by intros; simp [monoidalCategoryStruct]
id_tensorHom_id := by intros; simp [monoidalCategoryStruct]
tensorHom_comp_tensorHom := by intros; simp [monoidalCategoryStruct]
whiskerLeft_id := by intros; simp [monoidalCategoryStruct]
id_whiskerRight := by intros; simp [monoidalCategoryStruct]
associator_naturality {X₁ X₂ X₃ Y₁ Y₂ Y₃} f₁ f₂ f₃ := by apply associator_naturality
leftUnitor_naturality := by intros; simp [monoidalCategoryStruct]
rightUnitor_naturality := fun f ↦ (rightUnitor L W ε).hom.naturality f
pentagon := pentagon
triangle := triangle
end Monoidal
end Localization
open Localization.Monoidal
noncomputable instance : (toMonoidalCategory L W ε).Monoidal :=
Functor.CoreMonoidal.toMonoidal
{ εIso := ε.symm
μIso X Y := μ L W ε X Y
associativity X Y Z := by simp [associator_hom_app L W ε X Y Z]
left_unitality Y := leftUnitor_hom_app L W ε Y
right_unitality X := rightUnitor_hom_app L W ε X }
local notation "L'" => toMonoidalCategory L W ε
lemma associator_hom (X Y Z : C) :
(α_ ((L').obj X) ((L').obj Y) ((L').obj Z)).hom =
(Functor.LaxMonoidal.μ (L') X Y) ▷ (L').obj Z ≫
(Functor.LaxMonoidal.μ (L') (X ⊗ Y) Z) ≫
(L').map (α_ X Y Z).hom ≫
(Functor.OplaxMonoidal.δ (L') X (Y ⊗ Z)) ≫
((L').obj X) ◁ (Functor.OplaxMonoidal.δ (L') Y Z) := by
simp
lemma associator_inv (X Y Z : C) :
(α_ ((L').obj X) ((L').obj Y) ((L').obj Z)).inv =
(L').obj X ◁ (Functor.LaxMonoidal.μ (L') Y Z) ≫
(Functor.LaxMonoidal.μ (L') X (Y ⊗ Z)) ≫
(L').map (α_ X Y Z).inv ≫
(Functor.OplaxMonoidal.δ (L') (X ⊗ Y) Z) ≫
(Functor.OplaxMonoidal.δ (L') X Y) ▷ ((L').obj Z) := by
simp
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Localization/Monoidal/Braided.lean | import Mathlib.CategoryTheory.Localization.Monoidal.Basic
import Mathlib.CategoryTheory.Monoidal.Braided.Multifunctor
/-!
# Localization of symmetric monoidal categories
Let `C` be a monoidal category equipped with a class of morphisms `W` which
is compatible with the monoidal category structure. The file
`Mathlib.CategoryTheory.Localization.Monoidal.Basic` constructs a monoidal structure on
the localized on `D` such that the localization functor is monoidal.
In this file we promote this monoidal structure to a braided structure in the case where `C` is
braided, in such a way that the localization functor is braided. If `C` is symmetric monoidal, then
the monoidal structure on `D` is also symmetric.
-/
open CategoryTheory Category MonoidalCategory BraidedCategory Functor
namespace CategoryTheory.Localization.Monoidal
variable {C D : Type*} [Category C] [Category D] (L : C ⥤ D) (W : MorphismProperty C)
[MonoidalCategory C] [W.IsMonoidal] [L.IsLocalization W]
{unit : D} (ε : L.obj (𝟙_ C) ≅ unit)
local notation "L'" => toMonoidalCategory L W ε
instance : (L').IsLocalization W := inferInstanceAs (L.IsLocalization W)
section Braided
variable [BraidedCategory C]
noncomputable instance : Lifting₂ L' L' W W ((curriedTensor C).flip ⋙ (whiskeringRight C C
(LocalizedMonoidal L W ε)).obj L') (tensorBifunctor L W ε).flip :=
inferInstanceAs (Lifting₂ L' L' W W (((curriedTensor C) ⋙ (whiskeringRight C C
(LocalizedMonoidal L W ε)).obj L')).flip (tensorBifunctor L W ε).flip )
/-- The braiding on the localized category as a natural isomorphism of bifunctors. -/
noncomputable def braidingNatIso : tensorBifunctor L W ε ≅ (tensorBifunctor L W ε).flip :=
lift₂NatIso L' L' W W
((curriedTensor C) ⋙ (whiskeringRight C C
(LocalizedMonoidal L W ε)).obj L')
(((curriedTensor C).flip ⋙ (whiskeringRight C C
(LocalizedMonoidal L W ε)).obj L'))
_ _ (isoWhiskerRight (curriedBraidingNatIso C) _)
lemma braidingNatIso_hom_app (X Y : C) :
((braidingNatIso L W ε).hom.app ((L').obj X)).app ((L').obj Y) =
(Functor.LaxMonoidal.μ (L') X Y) ≫
(L').map (β_ X Y).hom ≫
(Functor.OplaxMonoidal.δ (L') Y X) := by
simp [braidingNatIso, lift₂NatIso]
rfl
@[reassoc]
lemma braidingNatIso_hom_app_naturality_μ_left (X Y Z : C) :
((braidingNatIso L W ε).hom.app ((L').obj X)).app ((L').obj Y ⊗ (L').obj Z) ≫
(Functor.LaxMonoidal.μ (L') Y Z) ▷ (L').obj X =
(L').obj X ◁ (Functor.LaxMonoidal.μ (L') Y Z) ≫
((braidingNatIso L W ε).hom.app ((L').obj X)).app ((L').obj (Y ⊗ Z)) :=
(((braidingNatIso L W ε).hom.app ((L').obj X)).naturality ((Functor.LaxMonoidal.μ (L') Y Z))).symm
@[reassoc]
lemma braidingNatIso_hom_app_naturality_μ_right (X Y Z : C) :
((braidingNatIso L W ε).hom.app ((L').obj X ⊗ (L').obj Y)).app ((L').obj Z) ≫
(L').obj Z ◁ (Functor.LaxMonoidal.μ (L') X Y) =
(Functor.LaxMonoidal.μ (L') X Y) ▷ (L').obj Z ≫
((braidingNatIso L W ε).hom.app ((L').obj (X ⊗ Y))).app ((L').obj Z) :=
(NatTrans.congr_app ((braidingNatIso L W ε).hom.naturality
((Functor.LaxMonoidal.μ (L') X Y))) ((L').obj Z)).symm
@[reassoc]
lemma map_hexagon_forward (X Y Z : C) :
(α_ ((L').obj X) ((L').obj Y) ((L').obj Z)).hom ≫
(((braidingNatIso L W ε).app ((L').obj X)).app (((L').obj Y) ⊗ ((L').obj Z))).hom ≫
(α_ ((L').obj Y) ((L').obj Z) ((L').obj X)).hom =
(((braidingNatIso L W ε).app ((L').obj X)).app ((L').obj Y)).hom ▷ ((L').obj Z) ≫
(α_ ((L').obj Y) ((L').obj X) ((L').obj Z)).hom ≫
((L').obj Y) ◁ (((braidingNatIso L W ε).app ((L').obj X)).app ((L').obj Z)).hom := by
simp only [associator_hom, Iso.app_hom, braidingNatIso_hom_app]
slice_rhs 0 4 =>
simp only [Functor.flip_obj_obj, Functor.CoreMonoidal.toMonoidal_toLaxMonoidal,
Functor.CoreMonoidal.toMonoidal_toOplaxMonoidal, comp_whiskerRight, assoc,
Functor.Monoidal.whiskerRight_δ_μ_assoc, Functor.LaxMonoidal.μ_natural_left]
slice_lhs 6 7 =>
rw [braidingNatIso_hom_app_naturality_μ_left, braidingNatIso_hom_app]
simp
@[reassoc]
lemma map_hexagon_reverse (X Y Z : C) :
(α_ ((L').obj X) ((L').obj Y) ((L').obj Z)).inv ≫
(((braidingNatIso L W ε).app ((L').obj X ⊗ (L').obj Y)).app ((L').obj Z)).hom ≫
(α_ ((L').obj Z) ((L').obj X) ((L').obj Y)).inv =
((L').obj X) ◁ (((braidingNatIso L W ε).app ((L').obj Y)).app ((L').obj Z)).hom ≫
(α_ ((L').obj X) ((L').obj Z) ((L').obj Y)).inv ≫
(((braidingNatIso L W ε).app ((L').obj X)).app ((L').obj Z)).hom ▷ ((L').obj Y) := by
simp only [associator_inv, Iso.app_hom, braidingNatIso_hom_app]
slice_rhs 0 4 =>
simp only [Functor.flip_obj_obj, Functor.CoreMonoidal.toMonoidal_toLaxMonoidal,
Functor.CoreMonoidal.toMonoidal_toOplaxMonoidal, MonoidalCategory.whiskerLeft_comp, assoc,
Functor.Monoidal.whiskerLeft_δ_μ, comp_id]
slice_lhs 6 7 =>
rw [braidingNatIso_hom_app_naturality_μ_right, braidingNatIso_hom_app]
simp
noncomputable instance : BraidedCategory (LocalizedMonoidal L W ε) := by
refine .ofBifunctor (braidingNatIso L W ε) ?_ ?_
· apply natTrans₃_ext (L') (L') (L') W W W
simpa using map_hexagon_forward _ _ _
· apply natTrans₃_ext (L') (L') (L') W W W
simpa using map_hexagon_reverse _ _ _
lemma β_hom_app (X Y : C) :
(β_ ((L').obj X) ((L').obj Y)).hom =
(Functor.LaxMonoidal.μ (L') X Y) ≫
(L').map (β_ X Y).hom ≫
(Functor.OplaxMonoidal.δ (L') Y X) :=
braidingNatIso_hom_app L W ε X Y
noncomputable instance : (toMonoidalCategory L W ε).Braided where
braided X Y := by simp [β_hom_app]
end Braided
section Symmetric
variable [SymmetricCategory C]
noncomputable instance : SymmetricCategory (LocalizedMonoidal L W ε) := by
refine .ofCurried (natTrans₂_ext (L') (L') W W fun X Y ↦ ?_)
simp [-Functor.map_braiding, β_hom_app, ← Functor.map_comp_assoc]
end Symmetric
end CategoryTheory.Localization.Monoidal |
.lake/packages/mathlib/Mathlib/CategoryTheory/Localization/CalculusOfFractions/Preadditive.lean | import Mathlib.Algebra.Group.TransferInstance
import Mathlib.CategoryTheory.Localization.CalculusOfFractions.Fractions
import Mathlib.CategoryTheory.Localization.HasLocalization
import Mathlib.CategoryTheory.Preadditive.AdditiveFunctor
/-!
# The preadditive category structure on the localized category
In this file, it is shown that if `W : MorphismProperty C` has a left calculus
of fractions, and `C` is preadditive, then the localized category is preadditive,
and the localization functor is additive.
Let `L : C ⥤ D` be a localization functor for `W`. We first construct an abelian
group structure on `L.obj X ⟶ L.obj Y` for `X` and `Y` in `C`. The addition
is defined using representatives of two morphisms in `L` as left fractions with
the same denominator thanks to the lemmas in
`CategoryTheory.Localization.CalculusOfFractions.Fractions`.
As `L` is essentially surjective, we finally transport these abelian group structures
to `X' ⟶ Y'` for all `X'` and `Y'` in `D`.
Preadditive category instances are defined on the categories `W.Localization`
(and `W.Localization'`) under the assumption the `W` has a left calculus of fractions.
(It would be easy to deduce from the results in this file that if `W` has a right calculus
of fractions, then the localized category can also be equipped with
a preadditive structure, but only one of these two constructions can be made an instance!)
-/
namespace CategoryTheory
open MorphismProperty Preadditive Limits Category
variable {C D : Type*} [Category C] [Category D] [Preadditive C] (L : C ⥤ D)
{W : MorphismProperty C} [L.IsLocalization W]
namespace MorphismProperty
/-- The opposite of a left fraction. -/
abbrev LeftFraction.neg {X Y : C} (φ : W.LeftFraction X Y) :
W.LeftFraction X Y where
Y' := φ.Y'
f := -φ.f
s := φ.s
hs := φ.hs
namespace LeftFraction₂
variable {X Y : C} (φ : W.LeftFraction₂ X Y)
/-- The sum of two left fractions with the same denominator. -/
abbrev add : W.LeftFraction X Y where
Y' := φ.Y'
f := φ.f + φ.f'
s := φ.s
hs := φ.hs
@[simp]
lemma symm_add : φ.symm.add = φ.add := by
grind
@[simp]
lemma map_add (F : C ⥤ D) (hF : W.IsInvertedBy F) [Preadditive D] [F.Additive] :
φ.add.map F hF = φ.fst.map F hF + φ.snd.map F hF := by
have := hF φ.s φ.hs
rw [← cancel_mono (F.map φ.s), add_comp, LeftFraction.map_comp_map_s,
LeftFraction.map_comp_map_s, LeftFraction.map_comp_map_s, F.map_add]
end LeftFraction₂
end MorphismProperty
variable (W)
namespace Localization
namespace Preadditive
section ImplementationDetails
/-! The definitions in this section (like `neg'` and `add'`) should never be used
directly. These are auxiliary definitions in order to construct the preadditive
structure `Localization.preadditive` (which is made irreducible). The user
should only rely on the fact that the localization functor is additive, as this
completely determines the preadditive structure on the localized category when
there is a calculus of left fractions. -/
variable [W.HasLeftCalculusOfFractions] {X Y Z : C}
variable {L}
/-- The opposite of a map `L.obj X ⟶ L.obj Y` when `L : C ⥤ D` is a localization
functor, `C` is preadditive and there is a left calculus of fractions. -/
noncomputable def neg' (f : L.obj X ⟶ L.obj Y) : L.obj X ⟶ L.obj Y :=
(exists_leftFraction L W f).choose.neg.map L (inverts L W)
lemma neg'_eq (f : L.obj X ⟶ L.obj Y) (φ : W.LeftFraction X Y)
(hφ : f = φ.map L (inverts L W)) :
neg' W f = φ.neg.map L (inverts L W) := by
obtain ⟨φ₀, rfl, hφ₀⟩ : ∃ (φ₀ : W.LeftFraction X Y)
(_ : f = φ₀.map L (inverts L W)),
neg' W f = φ₀.neg.map L (inverts L W) :=
⟨_, (exists_leftFraction L W f).choose_spec, rfl⟩
rw [MorphismProperty.LeftFraction.map_eq_iff] at hφ
obtain ⟨Y', t₁, t₂, hst, hft, ht⟩ := hφ
have := inverts L W _ ht
rw [← cancel_mono (L.map (φ₀.s ≫ t₁))]
nth_rw 1 [L.map_comp]
rw [hφ₀, hst, LeftFraction.map_comp_map_s_assoc, L.map_comp,
LeftFraction.map_comp_map_s_assoc, ← L.map_comp, ← L.map_comp,
neg_comp, neg_comp, hft]
/-- The addition of two maps `L.obj X ⟶ L.obj Y` when `L : C ⥤ D` is a localization
functor, `C` is preadditive and there is a left calculus of fractions. -/
noncomputable def add' (f₁ f₂ : L.obj X ⟶ L.obj Y) : L.obj X ⟶ L.obj Y :=
(exists_leftFraction₂ L W f₁ f₂).choose.add.map L (inverts L W)
lemma add'_eq (f₁ f₂ : L.obj X ⟶ L.obj Y) (φ : W.LeftFraction₂ X Y)
(hφ₁ : f₁ = φ.fst.map L (inverts L W))
(hφ₂ : f₂ = φ.snd.map L (inverts L W)) :
add' W f₁ f₂ = φ.add.map L (inverts L W) := by
obtain ⟨φ₀, rfl, rfl, hφ₀⟩ : ∃ (φ₀ : W.LeftFraction₂ X Y)
(_ : f₁ = φ₀.fst.map L (inverts L W))
(_ : f₂ = φ₀.snd.map L (inverts L W)),
add' W f₁ f₂ = φ₀.add.map L (inverts L W) :=
⟨(exists_leftFraction₂ L W f₁ f₂).choose,
(exists_leftFraction₂ L W f₁ f₂).choose_spec.1,
(exists_leftFraction₂ L W f₁ f₂).choose_spec.2, rfl⟩
obtain ⟨Z, t₁, t₂, hst, hft, hft', ht⟩ := (LeftFraction₂.map_eq_iff L W φ₀ φ).1 ⟨hφ₁, hφ₂⟩
have := inverts L W _ ht
rw [hφ₀, ← cancel_mono (L.map (φ₀.s ≫ t₁))]
nth_rw 2 [hst]
rw [L.map_comp, L.map_comp, LeftFraction.map_comp_map_s_assoc,
LeftFraction.map_comp_map_s_assoc, ← L.map_comp, ← L.map_comp,
add_comp, add_comp, hft, hft']
lemma add'_comm (f₁ f₂ : L.obj X ⟶ L.obj Y) :
add' W f₁ f₂ = add' W f₂ f₁ := by
obtain ⟨α, h₁, h₂⟩ := exists_leftFraction₂ L W f₁ f₂
rw [add'_eq W f₁ f₂ α h₁ h₂, add'_eq W f₂ f₁ α.symm h₂ h₁, α.symm_add]
lemma add'_zero (f : L.obj X ⟶ L.obj Y) :
add' W f (L.map 0) = f := by
obtain ⟨α, hα⟩ := exists_leftFraction L W f
rw [add'_eq W f (L.map 0) (LeftFraction₂.mk α.f 0 α.s α.hs) hα, hα]; swap
· have := inverts L W _ α.hs
rw [← cancel_mono (L.map α.s), ← L.map_comp, Limits.zero_comp,
LeftFraction.map_comp_map_s]
dsimp [LeftFraction₂.add]
rw [add_zero]
lemma zero_add' (f : L.obj X ⟶ L.obj Y) :
add' W (L.map 0) f = f := by
rw [add'_comm, add'_zero]
lemma neg'_add'_self (f : L.obj X ⟶ L.obj Y) :
add' W (neg' W f) f = L.map 0 := by
obtain ⟨α, rfl⟩ := exists_leftFraction L W f
have := inverts L W _ α.hs
rw [add'_eq W _ _ (LeftFraction₂.mk (-α.f) α.f α.s α.hs) (neg'_eq W _ _ rfl) rfl]
simp only [← cancel_mono (L.map α.s), LeftFraction.map_comp_map_s, ← L.map_comp,
Limits.zero_comp, neg_add_cancel]
lemma add'_assoc (f₁ f₂ f₃ : L.obj X ⟶ L.obj Y) :
add' W (add' W f₁ f₂) f₃ = add' W f₁ (add' W f₂ f₃) := by
obtain ⟨α, h₁, h₂, h₃⟩ := exists_leftFraction₃ L W f₁ f₂ f₃
rw [add'_eq W f₁ f₂ α.forgetThd h₁ h₂, add'_eq W f₂ f₃ α.forgetFst h₂ h₃,
add'_eq W _ _ (LeftFraction₂.mk (α.f + α.f') α.f'' α.s α.hs) rfl h₃,
add'_eq W _ _ (LeftFraction₂.mk α.f (α.f' + α.f'') α.s α.hs) h₁ rfl]
dsimp [LeftFraction₂.add]
rw [add_assoc]
@[reassoc (attr := simp)]
lemma add'_comp (f₁ f₂ : L.obj X ⟶ L.obj Y) (g : L.obj Y ⟶ L.obj Z) :
add' W f₁ f₂ ≫ g = add' W (f₁ ≫ g) (f₂ ≫ g) := by
obtain ⟨α, h₁, h₂⟩ := exists_leftFraction₂ L W f₁ f₂
obtain ⟨β, hβ⟩ := exists_leftFraction L W g
obtain ⟨γ, hγ⟩ := (RightFraction.mk _ α.hs β.f).exists_leftFraction
dsimp at hγ
rw [add'_eq W f₁ f₂ α h₁ h₂, add'_eq W (f₁ ≫ g) (f₂ ≫ g)
(LeftFraction₂.mk (α.f ≫ γ.f) (α.f' ≫ γ.f) (β.s ≫ γ.s)
(W.comp_mem _ _ β.hs γ.hs))]; rotate_left
· rw [h₁, hβ]
exact LeftFraction.map_comp_map_eq_map _ _ _ hγ _
· rw [h₂, hβ]
exact LeftFraction.map_comp_map_eq_map _ _ _ hγ _
rw [hβ, LeftFraction.map_comp_map_eq_map _ _ γ hγ]
dsimp [LeftFraction₂.add]
rw [add_comp]
@[reassoc (attr := simp)]
lemma comp_add' (f : L.obj X ⟶ L.obj Y) (g₁ g₂ : L.obj Y ⟶ L.obj Z) :
f ≫ add' W g₁ g₂ = add' W (f ≫ g₁) (f ≫ g₂) := by
obtain ⟨α, hα⟩ := exists_leftFraction L W f
obtain ⟨β, hβ₁, hβ₂⟩ := exists_leftFraction₂ L W g₁ g₂
obtain ⟨γ, hγ₁, hγ₂⟩ := (RightFraction₂.mk _ α.hs β.f β.f').exists_leftFraction₂
dsimp at hγ₁ hγ₂
rw [add'_eq W g₁ g₂ β hβ₁ hβ₂, add'_eq W (f ≫ g₁) (f ≫ g₂)
(LeftFraction₂.mk (α.f ≫ γ.f) (α.f ≫ γ.f') (β.s ≫ γ.s) (W.comp_mem _ _ β.hs γ.hs))
(by simpa only [hα, hβ₁] using LeftFraction.map_comp_map_eq_map α β.fst γ.fst hγ₁ L)
(by simpa only [hα, hβ₂] using LeftFraction.map_comp_map_eq_map α β.snd γ.snd hγ₂ L),
hα, LeftFraction.map_comp_map_eq_map α β.add γ.add
(by simp only [add_comp, hγ₁, hγ₂, comp_add])]
dsimp [LeftFraction₂.add]
rw [comp_add]
@[simp]
lemma add'_map (f₁ f₂ : X ⟶ Y) :
add' W (L.map f₁) (L.map f₂) = L.map (f₁ + f₂) :=
(add'_eq W (L.map f₁) (L.map f₂) (LeftFraction₂.mk f₁ f₂ (𝟙 _) (W.id_mem _))
(LeftFraction.map_ofHom _ _ _ _).symm (LeftFraction.map_ofHom _ _ _ _).symm).trans
(LeftFraction.map_ofHom _ _ _ _)
variable (L X Y)
/-- The abelian group structure on `L.obj X ⟶ L.obj Y` when `L : C ⥤ D` is a localization
functor, `C` is preadditive and there is a left calculus of fractions. -/
noncomputable def addCommGroup' : AddCommGroup (L.obj X ⟶ L.obj Y) := by
letI : Zero (L.obj X ⟶ L.obj Y) := ⟨L.map 0⟩
letI : Add (L.obj X ⟶ L.obj Y) := ⟨add' W⟩
letI : Neg (L.obj X ⟶ L.obj Y) := ⟨neg' W⟩
exact
{ add_assoc := add'_assoc _
add_zero := add'_zero _
add_comm := add'_comm _
zero_add := zero_add' _
neg_add_cancel := neg'_add'_self _
nsmul := nsmulRec
zsmul := zsmulRec }
variable {X Y}
variable {L}
variable {X' Y' Z' : D} (eX : L.obj X ≅ X') (eY : L.obj Y ≅ Y') (eZ : L.obj Z ≅ Z')
/-- The bijection `(X' ⟶ Y') ≃ (L.obj X ⟶ L.obj Y)` induced by isomorphisms
`eX : L.obj X ≅ X'` and `eY : L.obj Y ≅ Y'`. -/
@[simps]
def homEquiv : (X' ⟶ Y') ≃ (L.obj X ⟶ L.obj Y) where
toFun f := eX.hom ≫ f ≫ eY.inv
invFun g := eX.inv ≫ g ≫ eY.hom
left_inv _ := by simp
right_inv _ := by simp
/-- The addition of morphisms in `D`, when `L : C ⥤ D` is a localization
functor, `C` is preadditive and there is a left calculus of fractions. -/
noncomputable def add (f₁ f₂ : X' ⟶ Y') : X' ⟶ Y' :=
(homEquiv eX eY).symm (add' W (homEquiv eX eY f₁) (homEquiv eX eY f₂))
@[reassoc]
lemma add_comp (f₁ f₂ : X' ⟶ Y') (g : Y' ⟶ Z') :
add W eX eY f₁ f₂ ≫ g = add W eX eZ (f₁ ≫ g) (f₂ ≫ g) := by
obtain ⟨f₁, rfl⟩ := (homEquiv eX eY).symm.surjective f₁
obtain ⟨f₂, rfl⟩ := (homEquiv eX eY).symm.surjective f₂
obtain ⟨g, rfl⟩ := (homEquiv eY eZ).symm.surjective g
simp [add]
@[reassoc]
lemma comp_add (f : X' ⟶ Y') (g₁ g₂ : Y' ⟶ Z') :
f ≫ add W eY eZ g₁ g₂ = add W eX eZ (f ≫ g₁) (f ≫ g₂) := by
obtain ⟨f, rfl⟩ := (homEquiv eX eY).symm.surjective f
obtain ⟨g₁, rfl⟩ := (homEquiv eY eZ).symm.surjective g₁
obtain ⟨g₂, rfl⟩ := (homEquiv eY eZ).symm.surjective g₂
simp [add]
lemma add_eq_add {X'' Y'' : C} (eX' : L.obj X'' ≅ X') (eY' : L.obj Y'' ≅ Y')
(f₁ f₂ : X' ⟶ Y') :
add W eX eY f₁ f₂ = add W eX' eY' f₁ f₂ := by
have h₁ := comp_add W eX' eX eY (𝟙 _) f₁ f₂
have h₂ := add_comp W eX' eY eY' f₁ f₂ (𝟙 _)
simp only [id_comp] at h₁
simp only [comp_id] at h₂
rw [h₁, h₂]
variable (L X' Y') in
/-- The abelian group structure on morphisms in `D`, when `L : C ⥤ D` is a localization
functor, `C` is preadditive and there is a left calculus of fractions. -/
noncomputable def addCommGroup : AddCommGroup (X' ⟶ Y') := by
have := Localization.essSurj L W
letI := addCommGroup' L W (L.objPreimage X') (L.objPreimage Y')
exact Equiv.addCommGroup (homEquiv (L.objObjPreimageIso X') (L.objObjPreimageIso Y'))
lemma add_eq (f₁ f₂ : X' ⟶ Y') :
letI := addCommGroup L W X' Y'
f₁ + f₂ = add W eX eY f₁ f₂ := by
apply add_eq_add
variable (L)
lemma map_add (f₁ f₂ : X ⟶ Y) :
letI := addCommGroup L W (L.obj X) (L.obj Y)
L.map (f₁ + f₂) = L.map f₁ + L.map f₂ := by
rw [add_eq W (Iso.refl _) (Iso.refl _) (L.map f₁) (L.map f₂)]
simp [add]
end ImplementationDetails
end Preadditive
variable [W.HasLeftCalculusOfFractions]
/-- The preadditive structure on `D`, when `L : C ⥤ D` is a localization
functor, `C` is preadditive and there is a left calculus of fractions. -/
noncomputable def preadditive : Preadditive D where
homGroup := Preadditive.addCommGroup L W
add_comp _ _ _ _ _ _ := by apply Preadditive.add_comp
comp_add _ _ _ _ _ _ := by apply Preadditive.comp_add
lemma functor_additive :
letI := preadditive L W
L.Additive :=
letI := preadditive L W
⟨by apply Preadditive.map_add⟩
attribute [irreducible] preadditive
include W in
lemma functor_additive_iff {E : Type*} [Category E] [Preadditive E] [Preadditive D] [L.Additive]
(G : D ⥤ E) :
G.Additive ↔ (L ⋙ G).Additive := by
constructor
· intro
infer_instance
· intro h
suffices ∀ ⦃X Y : C⦄ (f g : L.obj X ⟶ L.obj Y), G.map (f + g) = G.map f + G.map g by
refine ⟨fun {X Y f g} => ?_⟩
have hL := essSurj L W
have eq := this ((L.objObjPreimageIso X).hom ≫ f ≫ (L.objObjPreimageIso Y).inv)
((L.objObjPreimageIso X).hom ≫ g ≫ (L.objObjPreimageIso Y).inv)
rw [Functor.map_comp, Functor.map_comp, Functor.map_comp, Functor.map_comp,
← comp_add, ← comp_add, ← add_comp, ← add_comp, Functor.map_comp, Functor.map_comp] at eq
rw [← cancel_mono (G.map (L.objObjPreimageIso Y).inv),
← cancel_epi (G.map (L.objObjPreimageIso X).hom), eq]
intro X Y f g
obtain ⟨φ, rfl, rfl⟩ := exists_leftFraction₂ L W f g
have := Localization.inverts L W φ.s φ.hs
rw [← φ.map_add L (inverts L W), ← cancel_mono (G.map (L.map φ.s)), ← G.map_comp,
add_comp, ← G.map_comp, ← G.map_comp, LeftFraction.map_comp_map_s,
LeftFraction.map_comp_map_s, LeftFraction.map_comp_map_s, ← Functor.comp_map,
Functor.map_add, Functor.comp_map, Functor.comp_map]
noncomputable instance : Preadditive W.Localization := preadditive W.Q W
instance : W.Q.Additive := functor_additive W.Q W
instance [HasZeroObject C] : HasZeroObject W.Localization := W.Q.hasZeroObject_of_additive
variable [W.HasLocalization]
noncomputable instance : Preadditive W.Localization' := preadditive W.Q' W
instance : W.Q'.Additive := functor_additive W.Q' W
instance [HasZeroObject C] : HasZeroObject W.Localization' := W.Q'.hasZeroObject_of_additive
end Localization
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Localization/CalculusOfFractions/ComposableArrows.lean | import Mathlib.CategoryTheory.ComposableArrows.Basic
import Mathlib.CategoryTheory.Localization.CalculusOfFractions
/-! # Essential surjectivity of the functor induced on composable arrows
Assuming that `L : C ⥤ D` is a localization functor for a class of morphisms `W`
that has a calculus of left *or* right fractions, we show in this file
that the functor `L.mapComposableArrows n : ComposableArrows C n ⥤ ComposableArrows D n`
is essentially surjective for any `n : ℕ`.
-/
namespace CategoryTheory
namespace Localization
variable {C D : Type*} [Category C] [Category D] (L : C ⥤ D) (W : MorphismProperty C)
[L.IsLocalization W]
open ComposableArrows
lemma essSurj_mapComposableArrows_of_hasRightCalculusOfFractions
[W.HasRightCalculusOfFractions] (n : ℕ) :
(L.mapComposableArrows n).EssSurj where
mem_essImage Y := by
have := essSurj L W
induction n with
| zero =>
obtain ⟨Y, rfl⟩ := mk₀_surjective Y
exact ⟨mk₀ _, ⟨isoMk₀ (L.objObjPreimageIso Y)⟩⟩
| succ n hn =>
obtain ⟨Y, Z, f, rfl⟩ := ComposableArrows.precomp_surjective Y
obtain ⟨Y', ⟨e⟩⟩ := hn Y
obtain ⟨f', hf'⟩ := exists_rightFraction L W
((L.objObjPreimageIso Z).hom ≫ f ≫ (e.app 0).inv)
refine ⟨Y'.precomp f'.f,
⟨isoMkSucc (isoOfHom L W _ f'.hs ≪≫ L.objObjPreimageIso Z) e ?_⟩⟩
dsimp at hf' ⊢
simp [← cancel_mono (e.inv.app 0), hf']
lemma essSurj_mapComposableArrows [W.HasLeftCalculusOfFractions] (n : ℕ) :
(L.mapComposableArrows n).EssSurj := by
have := essSurj_mapComposableArrows_of_hasRightCalculusOfFractions L.op W.op n
have := Functor.essSurj_of_iso (L.mapComposableArrowsOpIso n).symm
exact Functor.essSurj_of_comp_fully_faithful _ (opEquivalence D n).functor.rightOp
end Localization
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Localization/CalculusOfFractions/OfAdjunction.lean | import Mathlib.CategoryTheory.Adjunction.Opposites
import Mathlib.CategoryTheory.Adjunction.FullyFaithful
import Mathlib.CategoryTheory.Localization.CalculusOfFractions
/-!
# The calculus of fractions deduced from an adjunction
If `G ⊣ F` is an adjunction, `F` is fully faithful,
and `W` is a class of morphisms that is inverted by `G`
and such that the morphism `adj.unit.app X` belongs to `W`
for any object `X`, then `G` is a localization functor
with respect to `W`. Moreover, if `W` is multiplicative,
then `W` has a calculus of left fractions. This
holds in particular if `W` is the inverse image of
the class of isomorphisms by `G`.
(The dual statement is also obtained.)
-/
namespace CategoryTheory
open MorphismProperty
namespace Adjunction
variable {C₁ C₂ : Type*} [Category C₁] [Category C₂]
{G : C₁ ⥤ C₂} {F : C₂ ⥤ C₁}
lemma hasLeftCalculusOfFractions (adj : G ⊣ F) (W : MorphismProperty C₁)
[W.IsMultiplicative] (hW : W.IsInvertedBy G) (hW' : (W.functorCategory C₁) adj.unit) :
W.HasLeftCalculusOfFractions where
exists_leftFraction X Y φ := by
obtain ⟨T, s, _, f, rfl⟩ := φ.cases
dsimp
have := hW s (by assumption)
exact ⟨{
f := adj.unit.app X ≫ F.map (inv (G.map s)) ≫ F.map (G.map f)
s := adj.unit.app Y
hs := hW' Y}, by
have := adj.unit.naturality s
dsimp at this ⊢
rw [reassoc_of% this, Functor.map_inv, IsIso.hom_inv_id_assoc, adj.unit_naturality]⟩
ext X' X Y f₁ f₂ s _ h := by
have := hW s (by assumption)
refine ⟨_, adj.unit.app Y, hW' _, ?_⟩
rw [← adj.unit_naturality f₁, ← adj.unit_naturality f₂]
congr 2
rw [← cancel_epi (G.map s), ← G.map_comp, ← G.map_comp, h]
lemma hasRightCalculusOfFractions (adj : F ⊣ G) (W : MorphismProperty C₁)
[W.IsMultiplicative] (hW : W.IsInvertedBy G) (hW' : (W.functorCategory _) adj.counit) :
W.HasRightCalculusOfFractions :=
have := hasLeftCalculusOfFractions adj.op W.op hW.op (fun _ ↦ hW' _)
inferInstanceAs W.op.unop.HasRightCalculusOfFractions
section
variable [F.Full] [F.Faithful]
lemma isLocalization_leftAdjoint
(adj : G ⊣ F) (W : MorphismProperty C₁)
(hW : W.IsInvertedBy G) (hW' : (W.functorCategory C₁) adj.unit) :
G.IsLocalization W := by
let Φ : W.Localization ⥤ C₂ := Localization.lift _ hW W.Q
let e : W.Q ⋙ Φ ≅ G := by apply Localization.fac
have : IsIso (Functor.whiskerRight adj.unit W.Q) := by
rw [NatTrans.isIso_iff_isIso_app]
intro X
exact Localization.inverts W.Q W _ (hW' X)
exact Functor.IsLocalization.of_equivalence_target W.Q W _
(Equivalence.mk Φ (F ⋙ W.Q)
(Localization.liftNatIso W.Q W W.Q (G ⋙ F ⋙ W.Q) _ _
(W.Q.leftUnitor.symm ≪≫ asIso (Functor.whiskerRight adj.unit W.Q) ≪≫
Functor.associator _ _ _))
(Functor.associator _ _ _ ≪≫ Functor.isoWhiskerLeft _ e ≪≫ asIso adj.counit)) e
lemma isLocalization_rightAdjoint
(adj : F ⊣ G) (W : MorphismProperty C₁)
(hW : W.IsInvertedBy G) (hW' : (W.functorCategory C₁) adj.counit) :
G.IsLocalization W := by
simpa using isLocalization_leftAdjoint adj.op W.op hW.op (fun X ↦ hW' X.unop)
lemma functorCategory_inverseImage_isomorphisms_unit (adj : G ⊣ F) :
((isomorphisms C₂).inverseImage G).functorCategory C₁ adj.unit := by
intro
simp only [Functor.id_obj, Functor.comp_obj, inverseImage_iff, isomorphisms.iff]
infer_instance
lemma functorCategory_inverseImage_isomorphisms_counit (adj : F ⊣ G) :
((isomorphisms C₂).inverseImage G).functorCategory C₁ adj.counit := by
intro
simp only [Functor.id_obj, Functor.comp_obj, inverseImage_iff, isomorphisms.iff]
infer_instance
lemma isLocalization_leftAdjoint' (adj : G ⊣ F) :
G.IsLocalization ((isomorphisms C₂).inverseImage G) :=
adj.isLocalization_leftAdjoint _ (fun _ _ _ h ↦ h)
adj.functorCategory_inverseImage_isomorphisms_unit
lemma isLocalization_rightAdjoint' (adj : F ⊣ G) :
G.IsLocalization ((isomorphisms C₂).inverseImage G) :=
adj.isLocalization_rightAdjoint _ (fun _ _ _ h ↦ h)
adj.functorCategory_inverseImage_isomorphisms_counit
lemma hasLeftCalculusOfFractions' (adj : G ⊣ F) :
((isomorphisms C₂).inverseImage G).HasLeftCalculusOfFractions :=
hasLeftCalculusOfFractions adj _ (fun _ _ _ h ↦ h)
adj.functorCategory_inverseImage_isomorphisms_unit
lemma hasRightCalculusOfFractions' (adj : F ⊣ G) :
((isomorphisms C₂).inverseImage G).HasRightCalculusOfFractions :=
hasRightCalculusOfFractions adj _ (fun _ _ _ h ↦ h)
adj.functorCategory_inverseImage_isomorphisms_counit
end
end Adjunction
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Localization/CalculusOfFractions/Fractions.lean | import Mathlib.CategoryTheory.Localization.CalculusOfFractions
/-!
# Lemmas on fractions
Let `W : MorphismProperty C`, and objects `X` and `Y` in `C`. In this file,
we introduce structures like `W.LeftFraction₂ X Y` which consists of two
left fractions with the "same denominator" which shall be important in
the construction of the preadditive structure on the localized category
when `C` is preadditive and `W` has a left calculus of fractions.
When `W` has a left calculus of fractions, we generalize the lemmas
`RightFraction.exists_leftFraction` as `RightFraction₂.exists_leftFraction₂`,
`Localization.exists_leftFraction` as `Localization.exists_leftFraction₂` and
`Localization.exists_leftFraction₃`, and
`LeftFraction.map_eq_iff` as `LeftFraction₂.map_eq_iff`.
## Implementation note
The lemmas in this file are phrased with data that is bundled into structures like
`LeftFraction₂` or `LeftFraction₃`. It could have been possible to phrase them
with "unbundled data". However, this would require introducing 4 or 5 variables instead
of one. It is also very convenient to use dot notation.
Many definitions have been made reducible so as to ease rewrites when this API is used.
-/
namespace CategoryTheory
variable {C D : Type*} [Category C] [Category D] (L : C ⥤ D) (W : MorphismProperty C)
[L.IsLocalization W]
namespace MorphismProperty
/-- This structure contains the data of two left fractions for
`W : MorphismProperty C` that have the same "denominator". -/
structure LeftFraction₂ (X Y : C) where
/-- the auxiliary object of left fractions -/
{Y' : C}
/-- the numerator of the first left fraction -/
f : X ⟶ Y'
/-- the numerator of the second left fraction -/
f' : X ⟶ Y'
/-- the denominator of the left fractions -/
s : Y ⟶ Y'
/-- the condition that the denominator belongs to the given morphism property -/
hs : W s
/-- This structure contains the data of three left fractions for
`W : MorphismProperty C` that have the same "denominator". -/
structure LeftFraction₃ (X Y : C) where
/-- the auxiliary object of left fractions -/
{Y' : C}
/-- the numerator of the first left fraction -/
f : X ⟶ Y'
/-- the numerator of the second left fraction -/
f' : X ⟶ Y'
/-- the numerator of the third left fraction -/
f'' : X ⟶ Y'
/-- the denominator of the left fractions -/
s : Y ⟶ Y'
/-- the condition that the denominator belongs to the given morphism property -/
hs : W s
/-- This structure contains the data of two right fractions for
`W : MorphismProperty C` that have the same "denominator". -/
structure RightFraction₂ (X Y : C) where
/-- the auxiliary object of right fractions -/
{X' : C}
/-- the denominator of the right fractions -/
s : X' ⟶ X
/-- the condition that the denominator belongs to the given morphism property -/
hs : W s
/-- the numerator of the first right fraction -/
f : X' ⟶ Y
/-- the numerator of the second right fraction -/
f' : X' ⟶ Y
variable {W}
/-- The equivalence relation on tuples of left fractions with the same denominator
for a morphism property `W`. The fact it is an equivalence relation is not
formalized, but it would follow easily from `LeftFraction₂.map_eq_iff`. -/
def LeftFraction₂Rel {X Y : C} (z₁ z₂ : W.LeftFraction₂ X Y) : Prop :=
∃ (Z : C) (t₁ : z₁.Y' ⟶ Z) (t₂ : z₂.Y' ⟶ Z) (_ : z₁.s ≫ t₁ = z₂.s ≫ t₂)
(_ : z₁.f ≫ t₁ = z₂.f ≫ t₂) (_ : z₁.f' ≫ t₁ = z₂.f' ≫ t₂), W (z₁.s ≫ t₁)
namespace LeftFraction₂
variable {X Y : C} (φ : W.LeftFraction₂ X Y)
/-- The first left fraction. -/
abbrev fst : W.LeftFraction X Y where
Y' := φ.Y'
f := φ.f
s := φ.s
hs := φ.hs
/-- The second left fraction. -/
abbrev snd : W.LeftFraction X Y where
Y' := φ.Y'
f := φ.f'
s := φ.s
hs := φ.hs
/-- The exchange of the two fractions. -/
abbrev symm : W.LeftFraction₂ X Y where
Y' := φ.Y'
f := φ.f'
f' := φ.f
s := φ.s
hs := φ.hs
end LeftFraction₂
namespace LeftFraction₃
variable {X Y : C} (φ : W.LeftFraction₃ X Y)
/-- The first left fraction. -/
abbrev fst : W.LeftFraction X Y where
Y' := φ.Y'
f := φ.f
s := φ.s
hs := φ.hs
/-- The second left fraction. -/
abbrev snd : W.LeftFraction X Y where
Y' := φ.Y'
f := φ.f'
s := φ.s
hs := φ.hs
/-- The third left fraction. -/
abbrev thd : W.LeftFraction X Y where
Y' := φ.Y'
f := φ.f''
s := φ.s
hs := φ.hs
/-- Forgets the first fraction. -/
abbrev forgetFst : W.LeftFraction₂ X Y where
Y' := φ.Y'
f := φ.f'
f' := φ.f''
s := φ.s
hs := φ.hs
/-- Forgets the second fraction. -/
abbrev forgetSnd : W.LeftFraction₂ X Y where
Y' := φ.Y'
f := φ.f
f' := φ.f''
s := φ.s
hs := φ.hs
/-- Forgets the third fraction. -/
abbrev forgetThd : W.LeftFraction₂ X Y where
Y' := φ.Y'
f := φ.f
f' := φ.f'
s := φ.s
hs := φ.hs
end LeftFraction₃
namespace LeftFraction₂Rel
variable {X Y : C} {z₁ z₂ : W.LeftFraction₂ X Y}
lemma fst (h : LeftFraction₂Rel z₁ z₂) : LeftFractionRel z₁.fst z₂.fst := by
obtain ⟨Z, t₁, t₂, hst, hft, _, ht⟩ := h
exact ⟨Z, t₁, t₂, hst, hft, ht⟩
lemma snd (h : LeftFraction₂Rel z₁ z₂) : LeftFractionRel z₁.snd z₂.snd := by
obtain ⟨Z, t₁, t₂, hst, _, hft', ht⟩ := h
exact ⟨Z, t₁, t₂, hst, hft', ht⟩
end LeftFraction₂Rel
namespace LeftFraction₂
variable (W)
variable [W.HasLeftCalculusOfFractions]
lemma map_eq_iff {X Y : C} (φ ψ : W.LeftFraction₂ X Y) :
(φ.fst.map L (Localization.inverts _ _) = ψ.fst.map L (Localization.inverts _ _) ∧
φ.snd.map L (Localization.inverts _ _) = ψ.snd.map L (Localization.inverts _ _)) ↔
LeftFraction₂Rel φ ψ := by
simp only [LeftFraction.map_eq_iff L W]
constructor
· intro ⟨h, h'⟩
obtain ⟨Z, t₁, t₂, hst, hft, ht⟩ := h
obtain ⟨Z', t₁', t₂', hst', hft', ht'⟩ := h'
dsimp at t₁ t₂ t₁' t₂' hst hft hst' hft' ht ht'
have ⟨α, hα⟩ := (RightFraction.mk _ ht (φ.s ≫ t₁')).exists_leftFraction
simp only [Category.assoc] at hα
obtain ⟨Z'', u, hu, fac⟩ := HasLeftCalculusOfFractions.ext _ _ _ φ.hs hα
have hα' : ψ.s ≫ t₂ ≫ α.f ≫ u = ψ.s ≫ t₂' ≫ α.s ≫ u := by
rw [← reassoc_of% hst, ← reassoc_of% hα, ← reassoc_of% hst']
obtain ⟨Z''', u', hu', fac'⟩ := HasLeftCalculusOfFractions.ext _ _ _ ψ.hs hα'
simp only [Category.assoc] at fac fac'
refine ⟨Z''', t₁' ≫ α.s ≫ u ≫ u', t₂' ≫ α.s ≫ u ≫ u', ?_, ?_, ?_, ?_⟩
· rw [reassoc_of% hst']
· rw [reassoc_of% fac, reassoc_of% hft, fac']
· rw [reassoc_of% hft']
· rw [← Category.assoc]
exact W.comp_mem _ _ ht' (W.comp_mem _ _ α.hs (W.comp_mem _ _ hu hu'))
· intro h
exact ⟨h.fst, h.snd⟩
end LeftFraction₂
namespace RightFraction₂
variable {X Y : C}
variable (φ : W.RightFraction₂ X Y)
/-- The first right fraction. -/
abbrev fst : W.RightFraction X Y where
X' := φ.X'
f := φ.f
s := φ.s
hs := φ.hs
/-- The second right fraction. -/
abbrev snd : W.RightFraction X Y where
X' := φ.X'
f := φ.f'
s := φ.s
hs := φ.hs
lemma exists_leftFraction₂ [W.HasLeftCalculusOfFractions] :
∃ (ψ : W.LeftFraction₂ X Y), φ.f ≫ ψ.s = φ.s ≫ ψ.f ∧
φ.f' ≫ ψ.s = φ.s ≫ ψ.f' := by
obtain ⟨ψ₁, hψ₁⟩ := φ.fst.exists_leftFraction
obtain ⟨ψ₂, hψ₂⟩ := φ.snd.exists_leftFraction
obtain ⟨α, hα⟩ := (RightFraction.mk _ ψ₁.hs ψ₂.s).exists_leftFraction
dsimp at hψ₁ hψ₂ hα
refine ⟨LeftFraction₂.mk (ψ₁.f ≫ α.f) (ψ₂.f ≫ α.s) (ψ₂.s ≫ α.s)
(W.comp_mem _ _ ψ₂.hs α.hs), ?_, ?_⟩
· dsimp
rw [hα, reassoc_of% hψ₁]
· rw [reassoc_of% hψ₂]
end RightFraction₂
end MorphismProperty
namespace Localization
variable [W.HasLeftCalculusOfFractions]
open MorphismProperty
lemma exists_leftFraction₂ {X Y : C} (f f' : L.obj X ⟶ L.obj Y) :
∃ (φ : W.LeftFraction₂ X Y), f = φ.fst.map L (inverts L W) ∧
f' = φ.snd.map L (inverts L W) := by
have ⟨φ, hφ⟩ := exists_leftFraction L W f
have ⟨φ', hφ'⟩ := exists_leftFraction L W f'
obtain ⟨α, hα⟩ := (RightFraction.mk _ φ.hs φ'.s).exists_leftFraction
let ψ : W.LeftFraction₂ X Y :=
{ Y' := α.Y'
f := φ.f ≫ α.f
f' := φ'.f ≫ α.s
s := φ'.s ≫ α.s
hs := W.comp_mem _ _ φ'.hs α.hs }
have := inverts L W _ φ'.hs
have := inverts L W _ α.hs
have : IsIso (L.map (φ'.s ≫ α.s)) := by
rw [L.map_comp]
infer_instance
refine ⟨ψ, ?_, ?_⟩
· rw [← cancel_mono (L.map (φ'.s ≫ α.s)), LeftFraction.map_comp_map_s,
hα, L.map_comp, hφ, LeftFraction.map_comp_map_s_assoc,
L.map_comp]
· rw [← cancel_mono (L.map (φ'.s ≫ α.s)), hφ']
nth_rw 1 [L.map_comp]
rw [LeftFraction.map_comp_map_s_assoc, LeftFraction.map_comp_map_s,
L.map_comp]
lemma exists_leftFraction₃ {X Y : C} (f f' f'' : L.obj X ⟶ L.obj Y) :
∃ (φ : W.LeftFraction₃ X Y), f = φ.fst.map L (inverts L W) ∧
f' = φ.snd.map L (inverts L W) ∧
f'' = φ.thd.map L (inverts L W) := by
obtain ⟨α, hα, hα'⟩ := exists_leftFraction₂ L W f f'
have ⟨β, hβ⟩ := exists_leftFraction L W f''
obtain ⟨γ, hγ⟩ := (RightFraction.mk _ α.hs β.s).exists_leftFraction
dsimp at hγ
let ψ : W.LeftFraction₃ X Y :=
{ Y' := γ.Y'
f := α.f ≫ γ.f
f' := α.f' ≫ γ.f
f'' := β.f ≫ γ.s
s := β.s ≫ γ.s
hs := W.comp_mem _ _ β.hs γ.hs }
have := inverts L W _ β.hs
have := inverts L W _ γ.hs
have : IsIso (L.map (β.s ≫ γ.s)) := by
rw [L.map_comp]
infer_instance
refine ⟨ψ, ?_, ?_, ?_⟩
· rw [← cancel_mono (L.map (β.s ≫ γ.s)), LeftFraction.map_comp_map_s, hα, hγ,
L.map_comp, LeftFraction.map_comp_map_s_assoc, L.map_comp]
· rw [← cancel_mono (L.map (β.s ≫ γ.s)), LeftFraction.map_comp_map_s, hα', hγ,
L.map_comp, LeftFraction.map_comp_map_s_assoc, L.map_comp]
· rw [← cancel_mono (L.map (β.s ≫ γ.s)), hβ]
nth_rw 1 [L.map_comp]
rw [LeftFraction.map_comp_map_s_assoc, LeftFraction.map_comp_map_s, L.map_comp]
end Localization
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Localization/DerivabilityStructure/Derives.lean | import Mathlib.CategoryTheory.Localization.DerivabilityStructure.PointwiseRightDerived
/-!
# Deriving functors using a derivability structure
Let `Φ : LocalizerMorphism W₁ W₂` be a localizer morphism between classes
of morphisms on categories `C₁` and `C₂`. Let `F : C₂ ⥤ H`.
When `Φ` is a left or right derivability structure, it allows to derive
the functor `F` (with respect to `W₂`) when `Φ.functor ⋙ F : C₁ ⥤ H`
inverts `W₁` (this is the most favorable case when we can apply the lemma
`hasPointwiseRightDerivedFunctor_iff_of_isRightDerivabilityStructure`).
We define `Φ.Derives F` as an abbreviation for `W₁.IsInvertedBy (Φ.functor ⋙ F)`.
When `h : Φ.Derives F` holds and `Φ` is a right derivability structure,
we show that `F` has a right derived functor with respect to `W₂`.
Under this assumption, if `L₂ : C₂ ⥤ D₂` is a localization functor
for `W₂`, then a functor `RF : D₂ ⥤ H` equipped with a natural
transformation `α : F ⟶ L₂ ⋙ RF` is the right derived functor of `F` iff
for any `X₁ : C₁`, the map `α.app (Φ.functor.obj X₁)` is an isomorphism.
-/
universe v₁ v₂ v₃ v₄ u₁ u₂ u₃ u₄
namespace CategoryTheory
open Limits Category
variable {C₁ : Type u₁} {C₂ : Type u₂} {H : Type u₃}
[Category.{v₁} C₁] [Category.{v₂} C₂] [Category.{v₃} H]
{D₂ : Type u₄} [Category.{v₄} D₂]
{W₁ : MorphismProperty C₁} {W₂ : MorphismProperty C₂}
namespace LocalizerMorphism
variable (Φ : LocalizerMorphism W₁ W₂) (F : C₂ ⥤ H)
/-- Given a localizer morphism `Φ : LocalizerMorphism W₁ W₂` between
morphism properties on `C₁` and `C₂`, and a functor `C₂ ⥤ H`, this
is the property that `W₁` is inverted by `Φ.functor ⋙ F`.
In case `Φ` is a (left/right) derivability structure, this allows
the construction of a derived functor for `F` relatively to `W₂`. -/
abbrev Derives : Prop := W₁.IsInvertedBy (Φ.functor ⋙ F)
namespace Derives
variable {Φ F} (h : Φ.Derives F) [Φ.IsRightDerivabilityStructure]
include h
lemma hasPointwiseRightDerivedFunctor : F.HasPointwiseRightDerivedFunctor W₂ := by
rw [hasPointwiseRightDerivedFunctor_iff_of_isRightDerivabilityStructure Φ F]
exact Functor.hasPointwiseRightDerivedFunctor_of_inverts _ h
section
variable {L₂ : C₂ ⥤ D₂} [L₂.IsLocalization W₂] {RF : D₂ ⥤ H} (α : F ⟶ L₂ ⋙ RF)
lemma isIso (X₁ : C₁) [RF.IsRightDerivedFunctor α W₂] :
IsIso (α.app (Φ.functor.obj X₁)) := by
let G : W₁.Localization ⥤ H := Localization.lift (Φ.functor ⋙ F) h W₁.Q
let eG := Localization.Lifting.iso W₁.Q W₁ (Φ.functor ⋙ F) G
have := Functor.isRightDerivedFunctor_of_inverts W₁ G eG
have := (Φ.functor ⋙ F).hasPointwiseRightDerivedFunctor_of_inverts h
rw [← Φ.isIso_iff_of_isRightDerivabilityStructure W₁.Q L₂ F G eG.inv RF α]
infer_instance
lemma isRightDerivedFunctor_of_isIso (hα : ∀ (X₁ : C₁), IsIso (α.app (Φ.functor.obj X₁))) :
RF.IsRightDerivedFunctor α W₂ := by
have := h.hasPointwiseRightDerivedFunctor
have := h.isIso (F.totalRightDerivedUnit L₂ W₂)
have := Φ.essSurj_of_hasRightResolutions L₂
let φ := (F.totalRightDerived L₂ W₂).rightDerivedDesc (F.totalRightDerivedUnit L₂ W₂) W₂ RF α
have hφ : F.totalRightDerivedUnit L₂ W₂ ≫ Functor.whiskerLeft L₂ φ = α :=
(F.totalRightDerived L₂ W₂).rightDerived_fac (F.totalRightDerivedUnit L₂ W₂) W₂ RF α
have : IsIso φ := by
rw [NatTrans.isIso_iff_isIso_app]
intro Y₂
rw [NatTrans.isIso_app_iff_of_iso φ ((Φ.functor ⋙ L₂).objObjPreimageIso Y₂).symm]
dsimp
simp only [← hφ, NatTrans.comp_app, Functor.whiskerLeft_app, isIso_comp_left_iff] at hα
infer_instance
rw [← Functor.isRightDerivedFunctor_iff_of_iso (F.totalRightDerivedUnit L₂ W₂) α W₂
(asIso φ) (by cat_disch)]
infer_instance
lemma isRightDerivedFunctor_iff_isIso :
RF.IsRightDerivedFunctor α W₂ ↔ ∀ (X₁ : C₁), IsIso (α.app (Φ.functor.obj X₁)) :=
⟨fun _ _ ↦ h.isIso α _, h.isRightDerivedFunctor_of_isIso α⟩
end
end Derives
end LocalizerMorphism
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Localization/DerivabilityStructure/Constructor.lean | import Mathlib.CategoryTheory.Localization.DerivabilityStructure.Basic
/-!
# Constructor for derivability structures
In this file, we provide a constructor for right derivability structures.
Assume that `W₁` and `W₂` are classes of morphisms in categories `C₁` and `C₂`,
and that we have a localizer morphism `Φ : LocalizerMorphism W₁ W₂` that is
a localized equivalence, i.e. `Φ.functor` induces an equivalence of categories
between the localized categories. Assume moreover that `W₂` contains identities.
Then, `Φ` is a right derivability structure
(`LocalizerMorphism.IsRightDerivabilityStructure.mk'`) if it satisfies the
two following conditions:
* for any `X₂ : C₂`, the category `Φ.RightResolution X₂` of resolutions of `X₂` is connected
* any arrow in `C₂` admits a resolution (i.e. `Φ.arrow.HasRightResolutions` holds, where
`Φ.arrow` is the induced localizer morphism on categories of arrows in `C₁` and `C₂`)
This statement is essentially Lemme 6.5 in
[the paper by Kahn and Maltsiniotis][KahnMaltsiniotis2008].
## References
* [Bruno Kahn and Georges Maltsiniotis, *Structures de dérivabilité*][KahnMaltsiniotis2008]
-/
namespace CategoryTheory
open Category Localization
variable {C₁ C₂ : Type*} [Category C₁] [Category C₂]
{W₁ : MorphismProperty C₁} {W₂ : MorphismProperty C₂}
namespace LocalizerMorphism
namespace IsRightDerivabilityStructure
section
variable (Φ : LocalizerMorphism W₁ W₂)
[∀ X₂, IsConnected (Φ.RightResolution X₂)]
[Φ.arrow.HasRightResolutions] [W₂.ContainsIdentities]
namespace Constructor
variable {D : Type*} [Category D] (L : C₂ ⥤ D) [L.IsLocalization W₂]
{X₂ : C₂} {X₃ : D} (y : L.obj X₂ ⟶ X₃)
/-- Given `Φ : LocalizerMorphism W₁ W₂`, `L : C₂ ⥤ D` a localization functor for `W₂` and
a morphism `y : L.obj X₂ ⟶ X₃`, this is the functor which sends `R : Φ.RightResolution d` to
`(isoOfHom L W₂ R.w R.hw).inv ≫ y` in the category `w.CostructuredArrowDownwards y`
where `w` is `TwoSquare.mk Φ.functor (Φ.functor ⋙ L) L (𝟭 _) (Functor.rightUnitor _).inv`. -/
@[simps]
noncomputable def fromRightResolution :
Φ.RightResolution X₂ ⥤ (TwoSquare.mk Φ.functor (Φ.functor ⋙ L) L (𝟭 _)
(Functor.rightUnitor _).inv).CostructuredArrowDownwards y where
obj R := CostructuredArrow.mk (Y := StructuredArrow.mk R.w)
(StructuredArrow.homMk ((isoOfHom L W₂ R.w R.hw).inv ≫ y))
map {R R'} φ := CostructuredArrow.homMk (StructuredArrow.homMk φ.f) (by
ext
dsimp
rw [← assoc, ← cancel_epi (isoOfHom L W₂ R.w R.hw).hom,
isoOfHom_hom, isoOfHom_hom_inv_id_assoc, assoc, ← L.map_comp_assoc,
φ.comm, isoOfHom_hom_inv_id_assoc])
lemma isConnected :
IsConnected ((TwoSquare.mk Φ.functor (Φ.functor ⋙ L) L (𝟭 _)
(Functor.rightUnitor _).inv).CostructuredArrowDownwards y) := by
let w := (TwoSquare.mk Φ.functor (Φ.functor ⋙ L) L (𝟭 _) (Functor.rightUnitor _).inv)
have : Nonempty (w.CostructuredArrowDownwards y) :=
⟨(fromRightResolution Φ L y).obj (Classical.arbitrary _)⟩
suffices ∀ (X : w.CostructuredArrowDownwards y),
∃ Y, Zigzag X ((fromRightResolution Φ L y).obj Y) by
refine zigzag_isConnected (fun X X' => ?_)
obtain ⟨Y, hX⟩ := this X
obtain ⟨Y', hX'⟩ := this X'
exact hX.trans ((zigzag_obj_of_zigzag _ (isPreconnected_zigzag Y Y')).trans hX'.symm)
intro X
obtain ⟨c, g, x, fac, rfl⟩ := TwoSquare.CostructuredArrowDownwards.mk_surjective X
dsimp [w] at x fac
rw [id_comp] at fac
let ρ : Φ.arrow.RightResolution (Arrow.mk g) := Classical.arbitrary _
refine ⟨RightResolution.mk ρ.w.left ρ.hw.1, ?_⟩
have := zigzag_obj_of_zigzag
(fromRightResolution Φ L x ⋙ w.costructuredArrowDownwardsPrecomp x y g fac)
(isPreconnected_zigzag (RightResolution.mk (𝟙 _) (W₂.id_mem _))
(RightResolution.mk ρ.w.right ρ.hw.2))
refine Zigzag.trans ?_ (Zigzag.trans this ?_)
· exact Zigzag.of_hom (eqToHom (by simp))
· apply Zigzag.of_inv
refine CostructuredArrow.homMk (StructuredArrow.homMk ρ.X₁.hom (by simp)) ?_
ext
dsimp
rw [← cancel_epi (isoOfHom L W₂ ρ.w.left ρ.hw.1).hom, isoOfHom_hom,
isoOfHom_hom_inv_id_assoc, ← L.map_comp_assoc, Arrow.w_mk_right, Arrow.mk_hom,
L.map_comp, assoc, isoOfHom_hom_inv_id_assoc, fac]
end Constructor
/-- If a localizer morphism `Φ` is a localized equivalence, then it is a right
derivability structure if the categories of right resolutions are connected and the
categories of right resolutions of arrows are nonempty. -/
lemma mk' [Φ.IsLocalizedEquivalence] : Φ.IsRightDerivabilityStructure := by
rw [Φ.isRightDerivabilityStructure_iff (Φ.functor ⋙ W₂.Q) W₂.Q (𝟭 _)
(Functor.rightUnitor _).symm, TwoSquare.guitartExact_iff_isConnected_downwards]
intro X₂ X₃ g
apply Constructor.isConnected
end
end IsRightDerivabilityStructure
end LocalizerMorphism
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Localization/DerivabilityStructure/Basic.lean | import Mathlib.CategoryTheory.Localization.Resolution
import Mathlib.CategoryTheory.Localization.Opposite
import Mathlib.CategoryTheory.GuitartExact.Opposite
/-!
# Derivability structures
Let `Φ : LocalizerMorphism W₁ W₂` be a localizer morphism, i.e. `W₁ : MorphismProperty C₁`,
`W₂ : MorphismProperty C₂`, and `Φ.functor : C₁ ⥤ C₂` is a functors which maps `W₁` to `W₂`.
Following the definition introduced by Bruno Kahn and Georges Maltsiniotis in
[Bruno Kahn and Georges Maltsiniotis, *Structures de dérivabilité*][KahnMaltsiniotis2008],
we say that `Φ` is a right derivability structure if `Φ` has right resolutions and
the following 2-square is Guitart exact, where `L₁ : C₁ ⥤ D₁` and `L₂ : C₂ ⥤ D₂` are
localization functors for `W₁` and `W₂`, and `F : D₁ ⥤ D₂` is the induced functor
on the localized categories:
```
Φ.functor
C₁ ⥤ C₂
| |
L₁| | L₂
v v
D₁ ⥤ D₂
F
```
## Implementation details
In the field `guitartExact'` of the structure `LocalizerMorphism.IsRightDerivabilityStructure`,
The condition that the square is Guitart exact is stated for the localization functors
of the constructed categories (`W₁.Q` and `W₂.Q`).
The lemma `LocalizerMorphism.isRightDerivabilityStructure_iff` show that it does
not depend of the choice of the localization functors.
## TODO
* Construct the injective derivability structure in order to derive functor from
the bounded below homotopy category in an abelian category with enough injectives
* Construct the projective derivability structure in order to derive functor from
the bounded above homotopy category in an abelian category with enough projectives
* Construct the flat derivability structure on the bounded above homotopy category
of categories of modules (and categories of sheaves of modules)
* Define the product derivability structure and formalize derived functors of
functors in several variables
## References
* [Bruno Kahn and Georges Maltsiniotis, *Structures de dérivabilité*][KahnMaltsiniotis2008]
-/
universe v₁ v₂ u₁ u₂
namespace CategoryTheory
open Category Localization Functor
variable {C₁ : Type u₁} {C₂ : Type u₂} [Category.{v₁} C₁] [Category.{v₂} C₂]
{W₁ : MorphismProperty C₁} {W₂ : MorphismProperty C₂}
namespace LocalizerMorphism
variable (Φ : LocalizerMorphism W₁ W₂)
/-- A localizer morphism `Φ : LocalizerMorphism W₁ W₂` is a right derivability
structure if it has right resolutions and the 2-square where the left and right functors
are localizations functors for `W₁` and `W₂` are Guitart exact. -/
class IsRightDerivabilityStructure : Prop where
hasRightResolutions : Φ.HasRightResolutions := by infer_instance
/-- Do not use this field directly: use the more general
`guitartExact_of_isRightDerivabilityStructure` instead,
see also the lemma `isRightDerivabilityStructure_iff`. -/
guitartExact' : TwoSquare.GuitartExact ((Φ.catCommSq W₁.Q W₂.Q).iso).hom
attribute [instance] IsRightDerivabilityStructure.hasRightResolutions
IsRightDerivabilityStructure.guitartExact'
variable {D₁ D₂ : Type*} [Category D₁] [Category D₂] (L₁ : C₁ ⥤ D₁) (L₂ : C₂ ⥤ D₂)
[L₁.IsLocalization W₁] [L₂.IsLocalization W₂] (F : D₁ ⥤ D₂)
lemma isRightDerivabilityStructure_iff [Φ.HasRightResolutions] (e : Φ.functor ⋙ L₂ ≅ L₁ ⋙ F) :
Φ.IsRightDerivabilityStructure ↔ TwoSquare.GuitartExact e.hom := by
have : Φ.IsRightDerivabilityStructure ↔
TwoSquare.GuitartExact ((Φ.catCommSq W₁.Q W₂.Q).iso).hom :=
⟨fun h => h.guitartExact', fun h => ⟨inferInstance, h⟩⟩
rw [this]
let e' := (Φ.catCommSq W₁.Q W₂.Q).iso
let E₁ := Localization.uniq W₁.Q L₁ W₁
let E₂ := Localization.uniq W₂.Q L₂ W₂
let e₁ : W₁.Q ⋙ E₁.functor ≅ L₁ := compUniqFunctor W₁.Q L₁ W₁
let e₂ : W₂.Q ⋙ E₂.functor ≅ L₂ := compUniqFunctor W₂.Q L₂ W₂
let e'' : (Φ.functor ⋙ W₂.Q) ⋙ E₂.functor ≅ (W₁.Q ⋙ E₁.functor) ⋙ F :=
associator _ _ _ ≪≫ isoWhiskerLeft _ e₂ ≪≫ e ≪≫ isoWhiskerRight e₁.symm F
let e''' : Φ.localizedFunctor W₁.Q W₂.Q ⋙ E₂.functor ≅ E₁.functor ⋙ F :=
liftNatIso W₁.Q W₁ _ _ _ _ e''
have : TwoSquare.vComp' e'.hom e'''.hom e₁ e₂ = e.hom := by
ext X₁
rw [TwoSquare.vComp'_app, liftNatIso_hom, liftNatTrans_app]
simp only [Functor.comp_obj, Iso.trans_hom, isoWhiskerLeft_hom, isoWhiskerRight_hom,
Iso.symm_hom, NatTrans.comp_app, Functor.associator_hom_app, whiskerLeft_app,
whiskerRight_app, id_comp, assoc, e'']
dsimp [Lifting.iso]
rw [F.map_id, id_comp, ← F.map_comp, Iso.inv_hom_id_app, F.map_id, comp_id,
← Functor.map_comp_assoc]
erw [show (CatCommSq.iso Φ.functor W₁.Q W₂.Q (localizedFunctor Φ W₁.Q W₂.Q)).hom =
(Lifting.iso W₁.Q W₁ _ _).inv by rfl, Iso.inv_hom_id_app]
simp
rw [← TwoSquare.GuitartExact.vComp'_iff_of_equivalences e'.hom E₁ E₂ e''' e₁ e₂, this]
instance guitartExact_of_isRightDerivabilityStructure' [h : Φ.IsRightDerivabilityStructure]
(e : Φ.functor ⋙ L₂ ≅ L₁ ⋙ F) : TwoSquare.GuitartExact e.hom := by
simpa only [Φ.isRightDerivabilityStructure_iff L₁ L₂ F e] using h
instance guitartExact_of_isRightDerivabilityStructure [Φ.IsRightDerivabilityStructure] :
TwoSquare.GuitartExact ((Φ.catCommSq L₁ L₂).iso).hom :=
guitartExact_of_isRightDerivabilityStructure' _ _ _ _ _
instance [W₁.ContainsIdentities] : (LocalizerMorphism.id W₁).HasRightResolutions :=
fun X₂ => ⟨RightResolution.mk (𝟙 X₂) (W₁.id_mem X₂)⟩
instance [W₁.ContainsIdentities] : (LocalizerMorphism.id W₁).IsRightDerivabilityStructure := by
rw [(LocalizerMorphism.id W₁).isRightDerivabilityStructure_iff W₁.Q W₁.Q (𝟭 W₁.Localization)
(Iso.refl _)]
dsimp
exact TwoSquare.guitartExact_id W₁.Q
/-- A localizer morphism `Φ : LocalizerMorphism W₁ W₂` is a left derivability
structure if it has left resolutions and the 2-square where the top and bottom functors
are localizations functors for `W₁` and `W₂` is Guitart exact. -/
class IsLeftDerivabilityStructure : Prop where
hasLeftResolutions : Φ.HasLeftResolutions := by infer_instance
/-- Do not use this field directly: use the more general
`guitartExact_of_isLeftDerivabilityStructure` instead,
see also the lemma `isLeftDerivabilityStructure_iff`. -/
guitartExact' : TwoSquare.GuitartExact ((Φ.catCommSq W₁.Q W₂.Q).iso).inv
attribute [instance] IsLeftDerivabilityStructure.hasLeftResolutions
IsLeftDerivabilityStructure.guitartExact'
lemma isLeftDerivabilityStructure_iff_op :
Φ.IsLeftDerivabilityStructure ↔
Φ.op.IsRightDerivabilityStructure := by
let F := Φ.localizedFunctor W₁.Q W₂.Q
let e : Φ.functor ⋙ W₂.Q ≅ W₁.Q ⋙ F := (Φ.catCommSq W₁.Q W₂.Q).iso
let e' : Φ.functor.op ⋙ W₂.Q.op ≅ W₁.Q.op ⋙ F.op := NatIso.op e.symm
have eq : TwoSquare.GuitartExact e'.hom ↔ TwoSquare.GuitartExact e.inv :=
TwoSquare.guitartExact_op_iff _
constructor
· rintro ⟨_, _⟩
rwa [Φ.op.isRightDerivabilityStructure_iff _ _ _ e', eq]
· intro
have : Φ.HasLeftResolutions := by
rw [hasLeftResolutions_iff_op]
infer_instance
refine ⟨inferInstance, ?_⟩
rw [← eq]
exact Φ.op.guitartExact_of_isRightDerivabilityStructure' _ _ _ e'
lemma isLeftDerivabilityStructure_iff [Φ.HasLeftResolutions] (e : Φ.functor ⋙ L₂ ≅ L₁ ⋙ F) :
Φ.IsLeftDerivabilityStructure ↔ TwoSquare.GuitartExact e.inv := by
rw [isLeftDerivabilityStructure_iff_op,
Φ.op.isRightDerivabilityStructure_iff L₁.op L₂.op F.op (NatIso.op e.symm),
← TwoSquare.guitartExact_op_iff e.inv]
rfl
instance guitartExact_of_isLeftDerivabilityStructure' [h : Φ.IsLeftDerivabilityStructure]
(e : Φ.functor ⋙ L₂ ≅ L₁ ⋙ F) : TwoSquare.GuitartExact e.inv := by
simpa only [Φ.isLeftDerivabilityStructure_iff L₁ L₂ F e] using h
instance guitartExact_of_isLeftDerivabilityStructure [Φ.IsLeftDerivabilityStructure] :
TwoSquare.GuitartExact ((Φ.catCommSq L₁ L₂).iso).inv :=
guitartExact_of_isLeftDerivabilityStructure' _ _ _ _ _
instance [W₁.ContainsIdentities] : (LocalizerMorphism.id W₁).HasLeftResolutions :=
fun X₂ => ⟨LeftResolution.mk (𝟙 X₂) (W₁.id_mem X₂)⟩
instance [W₁.ContainsIdentities] : (LocalizerMorphism.id W₁).IsLeftDerivabilityStructure := by
rw [(LocalizerMorphism.id W₁).isLeftDerivabilityStructure_iff W₁.Q W₁.Q (𝟭 W₁.Localization)
(Iso.refl _)]
dsimp
exact TwoSquare.guitartExact_id' W₁.Q
end LocalizerMorphism
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Localization/DerivabilityStructure/PointwiseRightDerived.lean | import Mathlib.CategoryTheory.Localization.DerivabilityStructure.Basic
import Mathlib.CategoryTheory.Functor.Derived.PointwiseRightDerived
import Mathlib.CategoryTheory.GuitartExact.KanExtension
import Mathlib.CategoryTheory.Limits.Final
/-!
# Existence of pointwise right derived functors via derivability structures
In this file, we show how a right derivability structure can be used in
order to construct (pointwise) right derived functors.
Let `Φ` be a right derivability structure from `W₁ : MorphismProperty C₁`
to `W₂ : MorphismProperty C₂`. Let `F : C₂ ⥤ H` be a functor.
Then, the lemma `hasPointwiseRightDerivedFunctor_iff_of_isRightDerivabilityStructure`
says that `F` has a pointwise right derived functor with respect to `W₂`
if and only if `Φ.functor ⋙ F` has a pointwise right derived functor
with respect to `W₁`. This is essentially the Proposition 5.5 from the article
*Structures de dérivabilité* by Bruno Kahn and Georges Maltsiniotis (there,
it was stated in terms of absolute derived functors).
In particular, if `Φ.functor ⋙ F` inverts `W₁`, it follows that the
right derived functor of `F` with respect to `W₂` exists.
## References
* [Bruno Kahn and Georges Maltsiniotis, *Structures de dérivabilité*][KahnMaltsiniotis2008]
-/
universe v₁ v₂ v₃ v₄ v₅ u₁ u₂ u₃ u₄ u₅
namespace CategoryTheory
open Limits Category Functor
variable {C₁ : Type u₁} {C₂ : Type u₂} {H : Type u₃}
[Category.{v₁} C₁] [Category.{v₂} C₂] [Category.{v₃} H]
{D₁ : Type u₄} {D₂ : Type u₅}
[Category.{v₄} D₁] [Category.{v₅} D₂]
{W₁ : MorphismProperty C₁} {W₂ : MorphismProperty C₂}
namespace LocalizerMorphism
variable (Φ : LocalizerMorphism W₁ W₂) (L₁ : C₁ ⥤ D₁) (L₂ : C₂ ⥤ D₂)
[L₁.IsLocalization W₁] [L₂.IsLocalization W₂]
(F : C₂ ⥤ H) (F₁ : D₁ ⥤ H) (α₁ : Φ.functor ⋙ F ⟶ L₁ ⋙ F₁)
(F₂ : D₂ ⥤ H) (α₂ : F ⟶ L₂ ⋙ F₂)
[F₁.IsRightDerivedFunctor α₁ W₁]
/-- If `Φ` is a localizer morphism from `W₁ : MorphismProperty C₁` to
`W₂ : MorphismProperty C₂`, if `L₁ : C₁ ⥤ D₁` and `L₂ : C₂ ⥤ D₂` are
localization functors for `W₁` and `W₂`, if `F : C₂ ⥤ H` is a functor,
if `F₁ : D₁ ⥤ H` is a right derived functor of `Φ.functor ⋙ F`,
and if `F₂ : D₂ ⥤ H` is a functor equipped with a
natural transformation `α₂ : F ⟶ L₂ ⋙ F₂`, this is the canonical
morphism `F₁ ⟶ Φ.localizedFunctor L₁ L₂ ⋙ F₂`. -/
noncomputable def rightDerivedFunctorComparison :
F₁ ⟶ Φ.localizedFunctor L₁ L₂ ⋙ F₂ :=
F₁.rightDerivedDesc α₁ W₁ (Φ.localizedFunctor L₁ L₂ ⋙ F₂)
(whiskerLeft _ α₂ ≫ (Functor.associator _ _ _).inv ≫
whiskerRight ((Φ.catCommSq L₁ L₂).iso).hom F₂ ≫ (Functor.associator _ _ _).hom)
@[reassoc]
lemma rightDerivedFunctorComparison_fac :
α₁ ≫ whiskerLeft _ (Φ.rightDerivedFunctorComparison L₁ L₂ F F₁ α₁ F₂ α₂) =
whiskerLeft Φ.functor α₂ ≫ ((Functor.associator _ _ _).inv ≫
whiskerRight ((Φ.catCommSq L₁ L₂).iso).hom F₂ ≫ (Functor.associator _ _ _).hom) := by
dsimp only [rightDerivedFunctorComparison]
rw [Functor.rightDerived_fac]
@[reassoc (attr := simp)]
lemma rightDerivedFunctorComparison_fac_app (X : C₁) :
α₁.app X ≫ (Φ.rightDerivedFunctorComparison L₁ L₂ F F₁ α₁ F₂ α₂).app (L₁.obj X) =
α₂.app (Φ.functor.obj X) ≫ F₂.map (((Φ.catCommSq L₁ L₂).iso).hom.app X) := by
simpa using congr_app (Φ.rightDerivedFunctorComparison_fac L₁ L₂ F F₁ α₁ F₂ α₂) X
variable [Φ.IsRightDerivabilityStructure]
lemma hasPointwiseRightDerivedFunctorAt_iff_of_isRightDerivabilityStructure (X : C₁) :
(Φ.functor ⋙ F).HasPointwiseRightDerivedFunctorAt W₁ X ↔
F.HasPointwiseRightDerivedFunctorAt W₂ (Φ.functor.obj X) := by
let e : W₂.Q.obj _ ≅ (Φ.localizedFunctor W₁.Q W₂.Q).obj _ := ((Φ.catCommSq W₁.Q W₂.Q).iso).app X
rw [F.hasPointwiseRightDerivedFunctorAt_iff W₂.Q W₂ (Φ.functor.obj X),
(Φ.functor ⋙ F).hasPointwiseRightDerivedFunctorAt_iff W₁.Q W₁ X,
TwoSquare.hasPointwiseLeftKanExtensionAt_iff ((Φ.catCommSq W₁.Q W₂.Q).iso).hom,
Functor.hasPointwiseLeftKanExtensionAt_iff_of_iso W₂.Q F e]
lemma hasPointwiseRightDerivedFunctor_iff_of_isRightDerivabilityStructure :
F.HasPointwiseRightDerivedFunctor W₂ ↔
((Φ.functor ⋙ F).HasPointwiseRightDerivedFunctor W₁) := by
constructor
· intro hF X₁
rw [hasPointwiseRightDerivedFunctorAt_iff_of_isRightDerivabilityStructure]
apply hF
· intro hF X₂
have R : Φ.RightResolution X₂ := Classical.arbitrary _
simpa only [hasPointwiseRightDerivedFunctorAt_iff_of_isRightDerivabilityStructure,
← F.hasPointwiseRightDerivedFunctorAt_iff_of_mem W₂ R.w R.hw] using hF R.X₁
section
variable [(Φ.functor ⋙ F).HasPointwiseRightDerivedFunctor W₁]
[F₂.IsRightDerivedFunctor α₂ W₂]
instance : IsIso (Φ.rightDerivedFunctorComparison L₁ L₂ F F₁ α₁ F₂ α₂) := by
have : F.HasPointwiseRightDerivedFunctor W₂ := by
rw [Φ.hasPointwiseRightDerivedFunctor_iff_of_isRightDerivabilityStructure]
infer_instance
dsimp only [rightDerivedFunctorComparison]
rw [← isRightDerivedFunctor_iff_isIso_rightDerivedDesc,
isRightDerivedFunctor_iff_isLeftKanExtension]
exact ((F₂.isPointwiseLeftKanExtensionOfHasPointwiseRightDerivedFunctor α₂ W₂).compTwoSquare
((Φ.catCommSq L₁ L₂).iso).hom).isLeftKanExtension
lemma isIso_iff_of_isRightDerivabilityStructure (X : C₁) :
IsIso (α₁.app X) ↔ IsIso (α₂.app (Φ.functor.obj X)) := by
rw [← isIso_comp_right_iff (α₁.app X)
((Φ.rightDerivedFunctorComparison L₁ L₂ F F₁ α₁ F₂ α₂).app (L₁.obj X)),
rightDerivedFunctorComparison_fac_app, isIso_comp_right_iff]
@[deprecated (since := "2025-11-16")] alias isIso_α_iff_of_isRightDerivabilityStructure :=
isIso_iff_of_isRightDerivabilityStructure
end
end LocalizerMorphism
end CategoryTheory |
.lake/packages/mathlib/Mathlib/CategoryTheory/Localization/DerivabilityStructure/OfFunctorialResolutions.lean | import Mathlib.CategoryTheory.Localization.DerivabilityStructure.Constructor
/-!
# Functorial resolutions give derivability structures
In this file, we provide a constructor for right derivability structures.
We assume that `Φ : LocalizerMorphism W₁ W₂` is given by
a fully faithful functor `Φ.functor : C₁ ⥤ C₂` and that we have a resolution
functor `ρ : C₂ ⥤ C₁` with a natural transformation `i : 𝟭 C₂ ⟶ ρ ⋙ Φ.functor`
such that `W₂ (i.app X₂)` for any `X₂ : C₂`. If we assume
that `W₁` is induced by `W₂`, that `W₂` is multiplicative and has
the two out of three property, then `Φ` is a right derivability structure.
-/
namespace CategoryTheory
variable {C₁ C₂ : Type*} [Category C₁] [Category C₂]
{W₁ : MorphismProperty C₁} {W₂ : MorphismProperty C₂}
namespace LocalizerMorphism
variable (Φ : LocalizerMorphism W₁ W₂)
{ρ : C₂ ⥤ C₁} (i : 𝟭 C₂ ⟶ ρ ⋙ Φ.functor) (hi : ∀ X₂, W₂ (i.app X₂))
(hW₁ : W₁ = W₂.inverseImage Φ.functor)
include hi in
lemma hasRightResolutions_arrow_of_functorial_resolutions :
Φ.arrow.HasRightResolutions :=
fun f ↦
⟨{ X₁ := Arrow.mk (ρ.map f.hom)
w := Arrow.homMk (i.app _) (i.app _) (i.naturality f.hom).symm
hw := ⟨hi _, hi _⟩ }⟩
namespace functorialRightResolutions
open Functor
variable {Φ i}
/-- If `Φ : LocalizerMorphism W₁ W₂` corresponds to a class `W₁` that is
the inverse image of `W₂` by the functor `Φ.functor` and that we
have functorial right resolutions, then this is a morphism of localizers
in the other direction. -/
@[simps]
def localizerMorphismInv [W₂.HasTwoOutOfThreeProperty] :
LocalizerMorphism W₂ W₁ where
functor := ρ
map := by
rw [hW₁]
intro X Y f hf
have := i.naturality f
dsimp at this
simp only [MorphismProperty.inverseImage_iff]
rw [← W₂.precomp_iff _ _ (hi X), ← this]
exact W₂.comp_mem _ _ hf (hi Y)
variable [Φ.functor.Full] [Φ.functor.Faithful]
variable (i) in
/-- If `Φ : LocalizerMorphism W₁ W₂` corresponds to a class `W₁` that is
induced by `W₂` via the fully faithful functor `Φ.functor` and we
have functorial right resolutions given by a functor `ρ : C₂ ⥤ C₁`, then
this is the natural transformation `𝟭 C₁ ⟶ Φ.functor ⋙ ρ` induced
by `i : 𝟭 C₂ ⟶ ρ ⋙ Φ.functor`. -/
noncomputable def ι : 𝟭 C₁ ⟶ Φ.functor ⋙ ρ :=
((whiskeringRight C₁ C₁ C₂).obj Φ.functor).preimage (whiskerLeft Φ.functor i)
@[simp]
lemma Φ_functor_map_ι_app (X₁ : C₁) :
Φ.functor.map ((ι i).app X₁) = i.app (Φ.functor.obj X₁) :=
NatTrans.congr_app (((whiskeringRight C₁ C₁ C₂).obj Φ.functor).map_preimage
(X := 𝟭 C₁) (Y := Φ.functor ⋙ ρ) (whiskerLeft Φ.functor i)) X₁
include hW₁ hi in
lemma W₁_ι_app (X₁ : C₁) : W₁ ((ι i).app X₁) := by
simpa [hW₁] using hi (Φ.functor.obj X₁)
end functorialRightResolutions
variable [Φ.functor.Full] [Φ.functor.Faithful] [W₂.HasTwoOutOfThreeProperty]
open functorialRightResolutions
include hi hW₁
lemma isLocalizedEquivalence_of_functorial_right_resolutions :
Φ.IsLocalizedEquivalence :=
Φ.isLocalizedEquivalence_of_unit_of_unit (localizerMorphismInv hi hW₁) (ι i) i
(W₁_ι_app hi hW₁) hi
variable [W₂.IsMultiplicative]
lemma isConnected_rightResolution_of_functorial_resolutions (X₂ : C₂) :
letI : W₁.IsMultiplicative := by rw [hW₁]; infer_instance
IsConnected (Φ.RightResolution X₂) := by
have : W₁.IsMultiplicative := by rw [hW₁]; infer_instance
have : Nonempty (Φ.RightResolution X₂) := ⟨{ hw := hi X₂, .. }⟩
have : IsPreconnected (Φ.RightResolution X₂) :=
zigzag_isPreconnected (fun R₀ R₄ ↦
calc
Zigzag R₀ { hw := W₂.comp_mem _ _ R₀.hw (hi _), .. } :=
Zigzag.of_hom { f := (ι i).app R₀.X₁ }
Zigzag (J := Φ.RightResolution X₂) _ { hw := hi X₂, .. } :=
Zigzag.of_inv
{ f := ρ.map R₀.w
comm := (i.naturality R₀.w).symm }
Zigzag (J := Φ.RightResolution X₂) _ { hw := W₂.comp_mem _ _ R₄.hw (hi _), .. } :=
Zigzag.of_hom
{ f := ρ.map R₄.w
comm := (i.naturality R₄.w).symm }
Zigzag _ R₄ := Zigzag.of_inv { f := (ι i).app R₄.X₁ })
constructor
lemma isRightDerivabilityStructure_of_functorial_resolutions :
Φ.IsRightDerivabilityStructure := by
have : W₁.IsMultiplicative := by rw [hW₁]; infer_instance
have := Φ.isLocalizedEquivalence_of_functorial_right_resolutions i hi hW₁
have := Φ.hasRightResolutions_arrow_of_functorial_resolutions i hi
have := Φ.isConnected_rightResolution_of_functorial_resolutions i hi hW₁
apply IsRightDerivabilityStructure.mk'
end LocalizerMorphism
end CategoryTheory |
.lake/packages/mathlib/Mathlib/GroupTheory/ArchimedeanDensely.lean | import Mathlib.Algebra.Order.Group.Units
import Mathlib.Algebra.Order.Monoid.LocallyFiniteOrder
import Mathlib.Data.Int.Interval
import Mathlib.GroupTheory.Archimedean
import Mathlib.GroupTheory.OrderOfElement
import Mathlib.GroupTheory.SpecificGroups.Cyclic
import Mathlib.Order.Interval.Finset.DenselyOrdered
/-!
# Archimedean groups are either discrete or densely ordered
This file proves a few additional facts about linearly ordered additive groups which satisfy the
`Archimedean` property -- they are either order-isomorphic and additively isomorphic to the
integers, or they are densely ordered.
They are placed here in a separate file (rather than incorporated as a continuation of
`GroupTheory.Archimedean`) because they rely on some imports from pointwise lemmas.
-/
open Set
open scoped WithZero
-- no earlier file imports the necessary requirements for the next three
theorem exists_pow_lt₀ {G : Type*} [LinearOrderedCommGroupWithZero G] [MulArchimedean G]
{a : G} (ha : a < 1) (b : Gˣ) : ∃ n : ℕ, a ^ n < b := by
rcases eq_or_ne a 0 with rfl | ha'
· use 1
simp
· lift a to Gˣ using IsUnit.mk0 _ ha'
simpa using exists_pow_lt ha b
/-- The subgroup generated by an element of a group equals the set of
integer powers of the element, such that each power is a unique element.
This is the stronger version of `Subgroup.mem_closure_singleton`. -/
@[to_additive /-- The additive subgroup generated by an element of an additive group equals the set
of integer multiples of the element, such that each multiple is a unique element.
This is the stronger version of `AddSubgroup.mem_closure_singleton`. -/]
lemma Subgroup.mem_closure_singleton_iff_existsUnique_zpow {G : Type*}
[CommGroup G] [LinearOrder G] [IsOrderedMonoid G] {a b : G} (ha : a ≠ 1) :
b ∈ closure {a} ↔ ∃! k : ℤ, a ^ k = b := by
rw [mem_closure_singleton]
constructor
· suffices Function.Injective (a ^ · : ℤ → G) by
rintro ⟨m, rfl⟩
exact ⟨m, rfl, fun k hk ↦ this hk⟩
rcases ha.lt_or_gt with ha | ha
· exact (zpow_right_strictAnti ha).injective
· exact (zpow_right_strictMono ha).injective
· exact fun h ↦ h.exists
lemma Int.addEquiv_eq_refl_or_neg (e : ℤ ≃+ ℤ) : e = .refl _ ∨ e = .neg _ := by
suffices e 1 = 1 ∨ -e 1 = 1 by simpa [AddEquiv.ext_int_iff, neg_eq_iff_eq_neg]
have he : ¬IsOfFinAddOrder (e 1) :=
not_isOfFinAddOrder_of_isAddTorsionFree ((AddEquiv.map_ne_zero_iff e).mpr Int.one_ne_zero)
rw [← AddSubgroup.zmultiples_eq_zmultiples_iff he]
simpa [e.surjective, eq_comm] using (e : ℤ →+ ℤ).map_zmultiples 1
instance : Fintype (ℤ ≃+ ℤ) where
elems := .cons (.neg _) ({.refl _}) (by simp [AddEquiv.ext_int_iff])
complete x := by
obtain rfl | rfl := Int.addEquiv_eq_refl_or_neg x <;>
simp
@[simp]
lemma Int.univ_addEquiv :
(Finset.univ : Finset (ℤ ≃+ ℤ)) = .cons (.neg ℤ) {.refl ℤ} (by simp [AddEquiv.ext_int_iff]) :=
rfl
@[simp] lemma Int.card_fintype_addEquiv : Fintype.card (ℤ ≃+ ℤ) = 2 := rfl
instance : Unique (ℤ ≃+o ℤ) where
uniq e := OrderAddMonoidIso.toAddEquiv_injective <|
Int.addEquiv_eq_refl_or_neg e |>.resolve_right fun H => by
replace H : e 1 = -1 := congr($H 1)
have h1 : 0 < e 1 := by
rw [← map_zero e, map_lt_map_iff]
simp
simp [H] at h1
open OrderDual in
instance : Unique (ℤ ≃+o ℤᵒᵈ) where
default := ⟨AddEquiv.neg ℤ |>.trans ⟨toDual, toDual_add⟩, by simp⟩
uniq e := OrderAddMonoidIso.toAddEquiv_injective <| by
simp only [OrderAddMonoidIso.toAddEquiv_eq_coe]
refine Int.addEquiv_eq_refl_or_neg ((e : ℤ ≃+ ℤᵒᵈ).trans ⟨toDual, toDual_add⟩)
|>.resolve_left fun H => by
replace H : e 1 = 1 := congr($H 1)
have h1 : 0 < e 1 := by
rw [← map_zero e, map_lt_map_iff]
simp
simp [H, ← ofDual_lt_ofDual] at h1
open Subgroup in
/-- In two linearly ordered groups, the closure of an element of one group
is isomorphic (and order-isomorphic) to the closure of an element in the other group. -/
@[to_additive /-- In two linearly ordered additive groups, the closure of an element of one group
is isomorphic (and order-isomorphic) to the closure of an element in the other group. -/]
noncomputable def LinearOrderedCommGroup.closure_equiv_closure {G G' : Type*}
[CommGroup G] [LinearOrder G] [IsOrderedMonoid G]
[CommGroup G'] [LinearOrder G'] [IsOrderedMonoid G'] (x : G) (y : G') (hxy : x = 1 ↔ y = 1) :
closure ({x} : Set G) ≃*o closure ({y} : Set G') :=
if hx : x = 1 then by
refine ⟨⟨⟨fun _ ↦ ⟨1, by simp [hxy.mp hx]⟩, fun _ ↦ ⟨1, by simp [hx]⟩, ?_, ?_⟩, ?_⟩, ?_⟩
· intro ⟨a, ha⟩
simpa [hx, closure_singleton_one, eq_comm] using ha
· intro ⟨a, ha⟩
simpa [hxy.mp hx, closure_singleton_one, eq_comm] using ha
· intros
simp
· intro ⟨a, ha⟩ ⟨b, hb⟩
simp only [hx, closure_singleton_one, mem_bot] at ha hb
simp [ha, hb]
else by
set x' := max x x⁻¹ with hx'
have xpos : 1 < x' := by
simp [hx', eq_comm, hx]
set y' := max y y⁻¹ with hy'
have ypos : 1 < y' := by
simp [hy', eq_comm, ← hxy, hx]
have hxc : closure {x} = closure {x'} := by
rcases max_cases x x⁻¹ with H|H <;>
simp [hx', H.left]
have hyc : closure {y} = closure {y'} := by
rcases max_cases y y⁻¹ with H|H <;>
simp [hy', H.left]
refine ⟨⟨⟨
fun a ↦ ⟨y' ^ ((mem_closure_singleton).mp
(by simpa [hxc] using a.prop)).choose, ?_⟩,
fun a ↦ ⟨x' ^ ((mem_closure_singleton).mp
(by simpa [hyc] using a.prop)).choose, ?_⟩,
?_, ?_⟩, ?_⟩, ?_⟩
· rw [hyc, mem_closure_singleton]
exact ⟨_, rfl⟩
· rw [hxc, mem_closure_singleton]
exact ⟨_, rfl⟩
· intro a
generalize_proofs A B C D
rw [Subtype.ext_iff, ← (C a).choose_spec, zpow_right_inj xpos,
← zpow_right_inj ypos, (A ⟨_, D a⟩).choose_spec]
· intro a
generalize_proofs A B C D
rw [Subtype.ext_iff, ← (C a).choose_spec, zpow_right_inj ypos,
← zpow_right_inj xpos, (A ⟨_, D a⟩).choose_spec]
· intro a b
generalize_proofs A B C D E F
simp only [coe_mul, MulMemClass.mk_mul_mk, Subtype.ext_iff]
rw [← zpow_add, zpow_right_inj ypos, ← zpow_right_inj xpos, zpow_add,
(A a).choose_spec, (A b).choose_spec, (A (a * b)).choose_spec]
simp
· intro a b
simp only [Subtype.mk_le_mk]
generalize_proofs A B C D
simp [zpow_le_zpow_iff_right ypos, ← zpow_le_zpow_iff_right xpos, A.choose_spec,
B.choose_spec]
variable {G : Type*} [CommGroup G] [LinearOrder G] [IsOrderedMonoid G] [MulArchimedean G]
@[to_additive]
lemma Subgroup.isLeast_of_closure_iff_eq_mabs {a b : G} :
IsLeast {y : G | y ∈ closure ({a} : Set G) ∧ 1 < y} b ↔ b = |a|ₘ ∧ 1 < b := by
constructor <;> intro h
· have := Subgroup.cyclic_of_min h
have ha : a ∈ closure ({b} : Set G) := by
simp [← this]
rw [mem_closure_singleton] at ha
obtain ⟨n, rfl⟩ := ha
have := h.left
simp only [mem_closure_singleton, mem_setOf_eq] at this
obtain ⟨m, hm⟩ := this.left
have key : m * n = 1 := by
rw [← zpow_right_inj this.right, zpow_mul', hm, zpow_one]
rw [Int.mul_eq_one_iff_eq_one_or_neg_one] at key
rw [eq_comm]
rcases key with ⟨rfl, rfl⟩|⟨rfl, rfl⟩ <;>
simp [this.right.le, this.right, mabs]
· wlog ha : 1 ≤ a generalizing a
· convert @this (a⁻¹) ?_ (by simpa using le_of_not_ge ha) using 4
· simp
· rwa [mabs_inv]
rw [mabs, sup_eq_left.mpr ((inv_le_one'.mpr ha).trans ha)] at h
rcases h with ⟨rfl, h⟩
refine ⟨?_, ?_⟩
· simp [h]
· intro x
simp only [mem_closure_singleton, mem_setOf_eq, and_imp, forall_exists_index]
rintro k rfl hk
rw [← zpow_one b, ← zpow_mul, one_mul, zpow_le_zpow_iff_right h, ← zero_add 1,
← Int.lt_iff_add_one_le]
contrapose! hk
rw [← Left.one_le_inv_iff, ← zpow_neg]
exact one_le_zpow ha (by simp [hk])
/-- If an element of a linearly ordered archimedean additive group is the least positive element,
then the whole group is isomorphic (and order-isomorphic) to the integers. -/
noncomputable def LinearOrderedAddCommGroup.int_orderAddMonoidIso_of_isLeast_pos {G : Type*}
[AddCommGroup G] [LinearOrder G] [IsOrderedAddMonoid G] [Archimedean G] {x : G}
(h : IsLeast {y : G | 0 < y} x) : G ≃+o ℤ := by
have : IsLeast {y : G | y ∈ (⊤ : AddSubgroup G) ∧ 0 < y} x := by simpa using h
replace this := AddSubgroup.cyclic_of_min this
let e : G ≃+o (⊤ : AddSubgroup G) := ⟨AddSubsemigroup.topEquiv.symm,
(AddEquiv.strictMono_symm AddSubsemigroup.strictMono_topEquiv).le_iff_le⟩
let e' : (⊤ : AddSubgroup G) ≃+o AddSubgroup.closure {x} :=
⟨AddEquiv.subsemigroupCongr (by simp [this]),
(AddEquiv.strictMono_subsemigroupCongr _).le_iff_le⟩
let g : (⊤ : AddSubgroup ℤ) ≃+o ℤ := ⟨AddSubsemigroup.topEquiv,
(AddSubsemigroup.strictMono_topEquiv).le_iff_le⟩
let g' : AddSubgroup.closure ({1} : Set ℤ) ≃+o (⊤ : AddSubgroup ℤ) :=
⟨(.subsemigroupCongr (by simp)),
(AddEquiv.strictMono_subsemigroupCongr _).le_iff_le⟩
let f := closure_equiv_closure x (1 : ℤ) (by simp [h.left.ne'])
exact ((((e.trans e').trans f).trans g').trans g : G ≃+o ℤ)
/-- If an element of a linearly ordered mul-archimedean group is the least element greater than 1,
then the whole group is isomorphic (and order-isomorphic) to the multiplicative integers. -/
noncomputable def LinearOrderedCommGroup.multiplicative_int_orderMonoidIso_of_isLeast_one_lt
{x : G} (h : IsLeast {y : G | 1 < y} x) : G ≃*o Multiplicative ℤ := by
have : IsLeast {y : Additive G | 0 < y} (.ofMul x) := h
let f' := LinearOrderedAddCommGroup.int_orderAddMonoidIso_of_isLeast_pos (G := Additive G) this
exact f'.toMultiplicativeRight
/-- Any locally finite linear additive group is archimedean. -/
lemma Archimedean.of_locallyFiniteOrder {G : Type*} [AddCommGroup G] [LinearOrder G]
[IsOrderedAddMonoid G] [LocallyFiniteOrder G] :
Archimedean G :=
.comap (LocallyFiniteOrder.addMonoidHom G) LocallyFiniteOrder.orderAddMonoidHom_strictMono
/-- Any locally finite linear group is mul-archimedean. -/
@[to_additive existing]
lemma MulArchimedean.of_locallyFiniteOrder {G : Type*} [CommGroup G] [LinearOrder G]
[IsOrderedMonoid G] [LocallyFiniteOrder G] :
MulArchimedean G :=
.comap (LocallyFiniteOrder.orderMonoidHom G).toMonoidHom
LocallyFiniteOrder.orderMonoidHom_strictMono
/-- Any linearly ordered archimedean additive group is either isomorphic (and order-isomorphic)
to the integers, or is densely ordered. -/
lemma LinearOrderedAddCommGroup.discrete_or_denselyOrdered (G : Type*)
[AddCommGroup G] [LinearOrder G] [IsOrderedAddMonoid G] [Archimedean G] :
Nonempty (G ≃+o ℤ) ∨ DenselyOrdered G := by
by_cases! H : ∃ x, IsLeast {y : G | 0 < y} x
· obtain ⟨x, hx⟩ := H
exact Or.inl ⟨(int_orderAddMonoidIso_of_isLeast_pos hx)⟩
· refine Or.inr ⟨?_⟩
intro x y hxy
specialize H (y - x)
obtain ⟨z, hz⟩ : ∃ z : G, 0 < z ∧ z < y - x := by
contrapose! H
refine ⟨by simp [hxy], fun _ ↦ H _⟩
refine ⟨x + z, ?_, ?_⟩
· simp [hz.left]
· simpa [lt_sub_iff_add_lt'] using hz.right
/-- Any linearly ordered archimedean additive group is either isomorphic (and order-isomorphic)
to the integers, or is densely ordered, exclusively.
(See also `LinearOrderedAddCommGroup.isAddCyclic_iff_not_denselyOrdered`.) -/
lemma LinearOrderedAddCommGroup.discrete_iff_not_denselyOrdered (G : Type*)
[AddCommGroup G] [LinearOrder G] [IsOrderedAddMonoid G] [Archimedean G] :
Nonempty (G ≃+o ℤ) ↔ ¬ DenselyOrdered G := by
suffices ∀ (_ : G ≃+o ℤ), ¬ DenselyOrdered G by
rcases LinearOrderedAddCommGroup.discrete_or_denselyOrdered G with ⟨⟨h⟩⟩|h
· simpa [this h] using ⟨h⟩
· simp only [h, not_true_eq_false, iff_false, not_nonempty_iff]
exact ⟨fun H ↦ (this H) h⟩
intro e H
rw [denselyOrdered_iff_of_orderIsoClass e] at H
obtain ⟨_, _⟩ := exists_between (one_pos (α := ℤ))
cutsat
/-- Any non-trivial linearly ordered archimedean additive group is either cyclic, or densely
ordered, exclusively. -/
lemma LinearOrderedAddCommGroup.isAddCyclic_iff_not_denselyOrdered {A : Type*}
[AddCommGroup A] [LinearOrder A] [IsOrderedAddMonoid A] [Archimedean A] [Nontrivial A] :
IsAddCyclic A ↔ ¬ DenselyOrdered A := by
rw [← discrete_iff_not_denselyOrdered, isAddCyclic_iff_nonempty_equiv_int]
variable (G) in
/-- Any linearly ordered mul-archimedean group is either isomorphic (and order-isomorphic)
to the multiplicative integers, or is densely ordered. -/
lemma LinearOrderedCommGroup.discrete_or_denselyOrdered :
Nonempty (G ≃*o Multiplicative ℤ) ∨ DenselyOrdered G := by
rw [← OrderAddMonoidIso.toMultiplicativeRight.nonempty_congr]
exact LinearOrderedAddCommGroup.discrete_or_denselyOrdered (Additive G)
variable (G) in
/-- Any linearly ordered mul-archimedean group is either isomorphic (and order-isomorphic)
to the multiplicative integers, or is densely ordered, exclusively.
(See also `LinearOrderedCommGroup.isCyclic_iff_not_denselyOrdered`.) -/
lemma LinearOrderedCommGroup.discrete_iff_not_denselyOrdered :
Nonempty (G ≃*o Multiplicative ℤ) ↔ ¬ DenselyOrdered G := by
let e : G ≃o Additive G := .refl G
rw [← OrderAddMonoidIso.toMultiplicativeRight.nonempty_congr,
LinearOrderedAddCommGroup.discrete_iff_not_denselyOrdered,
denselyOrdered_iff_of_orderIsoClass e]
/-- Any non-trivial linearly ordered mul-archimedean group is either cyclic, or densely ordered,
exclusively. -/
@[to_additive existing]
lemma LinearOrderedCommGroup.isCyclic_iff_not_denselyOrdered [Nontrivial G] :
IsCyclic G ↔ ¬ DenselyOrdered G := by
rw [← isAddCyclic_additive_iff, LinearOrderedAddCommGroup.isAddCyclic_iff_not_denselyOrdered]
rfl
/-- Any nontrivial (has other than 0 and 1) linearly ordered mul-archimedean group with zero is
either isomorphic (and order-isomorphic) to `ℤᵐ⁰`, or is densely ordered. -/
lemma LinearOrderedCommGroupWithZero.discrete_or_denselyOrdered (G : Type*)
[LinearOrderedCommGroupWithZero G] [Nontrivial Gˣ] [MulArchimedean G] :
Nonempty (G ≃*o ℤᵐ⁰) ∨ DenselyOrdered G := by
classical
rw [← denselyOrdered_units_iff]
refine (LinearOrderedCommGroup.discrete_or_denselyOrdered Gˣ).imp_left ?_
intro ⟨f⟩
exact ⟨OrderMonoidIso.withZeroUnits.symm.trans f.withZero⟩
open WithZero in
/-- Any nontrivial (has other than 0 and 1) linearly ordered mul-archimedean group with zero is
either isomorphic (and order-isomorphic) to `ℤᵐ⁰`, or is densely ordered, exclusively -/
lemma LinearOrderedCommGroupWithZero.discrete_iff_not_denselyOrdered (G : Type*)
[LinearOrderedCommGroupWithZero G] [Nontrivial Gˣ] [MulArchimedean G] :
Nonempty (G ≃*o ℤᵐ⁰) ↔ ¬ DenselyOrdered G := by
rw [← denselyOrdered_units_iff,
← LinearOrderedCommGroup.discrete_iff_not_denselyOrdered]
refine Nonempty.congr ?_ ?_ <;> intro f
· refine ⟨MulEquiv.withZero.symm (withZeroUnitsEquiv.trans f), ?_⟩
intros
simp only [MulEquiv.withZero, withZeroUnitsEquiv, MulEquiv.trans_apply,
MulEquiv.coe_mk, Equiv.coe_fn_mk, recZeroCoe_coe, OrderMonoidIso.coe_mulEquiv,
MulEquiv.symm_trans_apply, MulEquiv.symm_mk, Equiv.coe_fn_symm_mk, map_eq_zero, coe_ne_zero,
↓reduceDIte, unzero_coe, MulEquiv.toEquiv_eq_coe, Equiv.toFun_as_coe, EquivLike.coe_coe]
rw [← Units.val_le_val, ← map_le_map_iff f, ← coe_le_coe, coe_unzero, coe_unzero]
· refine ⟨withZeroUnitsEquiv.symm.trans (MulEquiv.withZero f), ?_⟩
intros
simp only [withZeroUnitsEquiv, MulEquiv.symm_mk, MulEquiv.withZero,
MulEquiv.toEquiv_eq_coe, Equiv.toFun_as_coe, EquivLike.coe_coe,
MulEquiv.trans_apply, MulEquiv.coe_mk, Equiv.coe_fn_symm_mk, Equiv.coe_fn_mk]
split_ifs <;>
simp_all [← Units.val_le_val]
section WellFounded
lemma LinearOrderedAddCommGroup.wellFoundedOn_setOf_le_lt_iff_nonempty_discrete
{G : Type*} [AddCommGroup G] [LinearOrder G] [IsOrderedAddMonoid G] [Nontrivial G] {g : G} :
Set.WellFoundedOn {x : G | g ≤ x} (· < ·) ↔ Nonempty (G ≃+o ℤ) := by
suffices Set.WellFoundedOn {x : G | 0 ≤ x} (· < ·) ↔ Nonempty (G ≃+o ℤ) by
rw [← this]
refine ⟨fun h ↦ (h.mapsTo (· + g) ?_).mono' ?_, fun h ↦ (h.mapsTo (· - g) ?_).mono' ?_⟩ <;>
· try intro
simp [Function.onFun]
constructor
· intro h
replace h : WellFounded (α := {x : G | 0 ≤ x}) (· < ·) := h
rw [WellFounded.wellFounded_iff_has_min] at h
by_cases! H : ∀ (x : G) {y}, 0 < y → ∃ n : ℕ, x ≤ n • y -- Archimedean
· replace H : Archimedean G := ⟨H⟩
rw [LinearOrderedAddCommGroup.discrete_iff_not_denselyOrdered]
intro hd
obtain ⟨y, hy⟩ := exists_ne (0 : G)
wlog hy' : 0 < y generalizing y
· refine this (-y) ?_ ?_
· simp [hy]
· simp only [not_lt] at hy'
simp [lt_of_le_of_ne hy' hy]
obtain ⟨⟨z, hz⟩, hz', hz''⟩ := h ({x | ⟨0, le_rfl⟩ < x}) ⟨⟨y, hy'.le⟩, hy'⟩
obtain ⟨w, hw, hw'⟩ := exists_between hz'
exact hz'' ⟨w, hw.le⟩ hw hw'
· exfalso
obtain ⟨x, y, hy0, H⟩ := H
obtain ⟨_, ⟨n, rfl⟩, hz⟩ :=
h (Set.range (fun n : ℕ ↦ ⟨x - n • y, sub_nonneg.mpr (H _).le⟩)) (range_nonempty _)
refine hz ⟨x - (n + 1) • y, sub_nonneg.mpr (H _).le⟩ ⟨_, rfl⟩ ?_
simp [add_smul, hy0]
· rintro ⟨f⟩
have : LocallyFiniteOrder G := LocallyFiniteOrder.ofOrderIsoClass f
exact BddBelow.wellFoundedOn_lt ⟨0, by simp [mem_lowerBounds]⟩
lemma LinearOrderedAddCommGroup.wellFoundedOn_setOf_ge_gt_iff_nonempty_discrete
{G : Type*} [AddCommGroup G] [LinearOrder G] [IsOrderedAddMonoid G] [Nontrivial G] (g : G) :
Set.WellFoundedOn {x : G | x ≤ g} (· > ·) ↔ Nonempty (G ≃+o ℤ) := by
rw [← wellFoundedOn_setOf_le_lt_iff_nonempty_discrete (g := -g)]
refine ⟨fun h ↦ (h.mapsTo (- ·) ?_).mono' ?_, fun h ↦ (h.mapsTo (- ·) ?_).mono' ?_⟩ <;>
· intro
simp [Function.onFun, neg_le]
lemma LinearOrderedCommGroup.wellFoundedOn_setOf_le_lt_iff_nonempty_discrete
{G : Type*} [CommGroup G] [LinearOrder G] [IsOrderedMonoid G] [Nontrivial G] {g : G} :
Set.WellFoundedOn {x : G | g ≤ x} (· < ·) ↔ Nonempty (G ≃*o Multiplicative ℤ) := by
let e : G ≃o Additive G := OrderIso.refl G
suffices Set.WellFoundedOn {x : G | g ≤ x} (· < ·) ↔ Set.WellFoundedOn {x | e g ≤ x} (· < ·) by
rw [this, LinearOrderedAddCommGroup.wellFoundedOn_setOf_le_lt_iff_nonempty_discrete,
OrderAddMonoidIso.toMultiplicativeRight.nonempty_congr]
refine ⟨fun h ↦ (h.mapsTo e.symm fun _ ↦ e.le_symm_apply.mpr).mono' ?_,
fun h ↦ (h.mapsTo e fun _ ↦ ?_).mono' ?_⟩ <;>
simp [Function.onFun]
lemma LinearOrderedCommGroup.wellFoundedOn_setOf_ge_gt_iff_nonempty_discrete
{G : Type*} [CommGroup G] [LinearOrder G] [IsOrderedMonoid G] [Nontrivial G] (g : G) :
Set.WellFoundedOn {x : G | x ≤ g} (· > ·) ↔ Nonempty (G ≃*o Multiplicative ℤ) := by
rw [← wellFoundedOn_setOf_le_lt_iff_nonempty_discrete (g := g⁻¹)]
refine ⟨fun h ↦ (h.mapsTo (·⁻¹) ?_).mono' ?_, fun h ↦ (h.mapsTo (·⁻¹) ?_).mono' ?_⟩ <;>
· intro
simp [Function.onFun, inv_le']
lemma LinearOrderedCommGroupWithZero.wellFoundedOn_setOf_le_lt_iff_nonempty_discrete_of_ne_zero
{G₀ : Type*} [LinearOrderedCommGroupWithZero G₀] [Nontrivial G₀ˣ] {g : G₀} (hg : g ≠ 0) :
Set.WellFoundedOn {x : G₀ | g ≤ x} (· < ·) ↔ Nonempty (G₀ ≃*o ℤᵐ⁰) := by
suffices Set.WellFoundedOn {x : G₀ | g ≤ x} (· < ·) ↔
Set.WellFoundedOn {x : G₀ˣ | Units.mk0 g hg ≤ x} (· < ·) by
rw [this, LinearOrderedCommGroup.wellFoundedOn_setOf_le_lt_iff_nonempty_discrete]
refine Nonempty.congr (fun f ↦ ⟨?_, ?_⟩) (fun f ↦ ⟨?_, ?_⟩)
· exact WithZero.withZeroUnitsEquiv.symm.trans f.withZero
· intro a b
rcases eq_or_ne a 0 with rfl | ha
· simp [WithZero.withZeroUnitsEquiv]
rcases eq_or_ne b 0 with rfl | hb
· simp [WithZero.withZeroUnitsEquiv]
simp [WithZero.withZeroUnitsEquiv, ha, hb, ← Units.val_le_val]
· exact MulEquiv.withZero.symm (WithZero.withZeroUnitsEquiv.trans f)
· intros
rw [← WithZero.coe_le_coe]
simp
rw [← Set.wellFoundedOn_sdiff_singleton (a := 0)]
refine ⟨fun h ↦ (h.mapsTo Units.val ?_).mono' ?_,
fun h ↦ (h.mapsTo ?_ ?_).mono' ?_⟩
· intro
simp [← Units.val_le_val]
· simp [Function.onFun]
· exact fun x ↦ if h : x = 0 then 1 else Units.mk0 x h
· simp +contextual [← Units.val_le_val, MapsTo]
· simp only [mem_diff, mem_setOf_eq, mem_singleton_iff, Function.onFun, and_imp]
intro _ _ ha0 _ _ hb0 h
simp [ha0, hb0, ← Units.val_lt_val, h]
lemma LinearOrderedCommGroupWithZero.wellFoundedOn_setOf_ge_gt_iff_nonempty_discrete_of_ne_zero
{G₀ : Type*} [LinearOrderedCommGroupWithZero G₀] [Nontrivial G₀ˣ] {g : G₀} (hg : g ≠ 0) :
Set.WellFoundedOn {x : G₀ | x ≤ g} (· > ·) ↔ Nonempty (G₀ ≃*o ℤᵐ⁰) := by
have hg' : g⁻¹ ≠ 0 := by simp [hg]
rw [← wellFoundedOn_setOf_le_lt_iff_nonempty_discrete_of_ne_zero hg',
← Set.wellFoundedOn_sdiff_singleton (a := 0)]
refine ⟨fun h ↦ (h.mapsTo (·⁻¹) ?_).mono' ?_, fun h ↦ (h.mapsTo (·⁻¹) ?_).mono' ?_⟩
· intro x
rcases eq_or_ne x 0 with rfl | hx
· simp [hg]
simp only [mem_setOf_eq, mem_diff, mem_singleton_iff, inv_eq_zero, hx, not_false_eq_true,
and_true]
refine (inv_le_comm₀ ?_ ?_).mp <;>
simp [zero_lt_iff, hg, hx]
· simp only [mem_setOf_eq, Function.onFun, gt_iff_lt]
intro a ha b _
refine inv_strictAnti₀ ?_
contrapose! ha
simp only [le_zero_iff] at ha
simp [zero_lt_iff, ha, hg]
· intro x
simp only [mem_diff, mem_setOf_eq, mem_singleton_iff, and_imp]
intro hxg hx
refine inv_anti₀ ?_ hxg
simp [zero_lt_iff, hx]
· simp only [mem_diff, mem_setOf_eq, mem_singleton_iff, gt_iff_lt, Function.onFun, and_imp]
intro a _ _ b _ hb0
refine inv_strictAnti₀ ?_
simp [zero_lt_iff, hb0]
instance instWellFoundedGTWithZeroMultiplicativeIntLeOne :
WellFoundedGT { v : ℤᵐ⁰ // v ≤ 1 } :=
{ wf :=
(LinearOrderedCommGroupWithZero.wellFoundedOn_setOf_ge_gt_iff_nonempty_discrete_of_ne_zero
one_ne_zero).mpr instNonemptyOfInhabited }
end WellFounded
@[to_additive]
lemma OrderMonoidIso.mulArchimedean {α β}
[CommMonoid α] [PartialOrder α] [CommMonoid β] [PartialOrder β]
(e : α ≃*o β) [MulArchimedean α] : MulArchimedean β := by
constructor
intro x y hxy
replace hxy : 1 < e.symm y := by simp [← map_lt_map_iff e, hxy]
refine (MulArchimedean.arch (e.symm x) hxy).imp ?_
simp [← map_pow, ← map_le_map_iff e]
lemma WithZero.mulArchimedean_iff {α} [CommGroup α] [PartialOrder α] :
MulArchimedean (WithZero α) ↔ MulArchimedean α := by
constructor <;> intro _
· exact OrderMonoidIso.unitsWithZero.mulArchimedean
· infer_instance
lemma Units.mulArchimedean_iff {G₀} [LinearOrderedCommGroupWithZero G₀] :
MulArchimedean G₀ˣ ↔ MulArchimedean G₀ := by
constructor <;> intro _
· exact OrderMonoidIso.withZeroUnits.mulArchimedean
· infer_instance
section LocallyFiniteOrder
variable {X : Type*} [Preorder X] [LocallyFiniteOrder X]
instance : LocallyFiniteOrder (Multiplicative X) :=
OrderIso.locallyFiniteOrder (⟨Multiplicative.toAdd, by simp⟩ : Multiplicative X ≃o X)
instance : LocallyFiniteOrder (Additive X) :=
OrderIso.locallyFiniteOrder (⟨Additive.toMul, by simp⟩ : Additive X ≃o X)
noncomputable
instance [Monoid X] : LocallyFiniteOrder (Units X) :=
OrderEmbedding.locallyFiniteOrder (⟨⟨Units.val, Units.val_injective⟩, by simp⟩ : Units X ↪o X)
instance [Group X] : LocallyFiniteOrder (WithZero X)ˣ :=
OrderIso.locallyFiniteOrder (OrderMonoidIso.unitsWithZero (α := X) : (WithZero X)ˣ ≃o X)
end LocallyFiniteOrder
section DenselyOrdered
variable {X : Type*} [LT X]
lemma denselyOrdered_additive_iff : DenselyOrdered (Additive X) ↔ DenselyOrdered X := Iff.rfl
lemma denselyOrdered_multiplicative_iff : DenselyOrdered (Multiplicative X) ↔ DenselyOrdered X :=
Iff.rfl
instance [DenselyOrdered X] : DenselyOrdered (Multiplicative X) :=
denselyOrdered_multiplicative_iff.2 ‹_›
instance [DenselyOrdered X] : DenselyOrdered (Additive X) :=
denselyOrdered_additive_iff.2 ‹_›
lemma WithZero.denselyOrdered_iff {M : Type*} [Preorder M] [NoMinOrder M] :
DenselyOrdered (WithZero M) ↔ DenselyOrdered M :=
WithBot.denselyOrdered_iff
instance {X : Type*} [Preorder X] [NoMinOrder X] [DenselyOrdered X] :
DenselyOrdered (WithZero X) :=
WithZero.denselyOrdered_iff.mpr inferInstance
lemma Int.not_denselyOrdered : ¬ DenselyOrdered ℤ :=
(LinearOrderedAddCommGroup.discrete_iff_not_denselyOrdered ℤ).mp ⟨.refl _⟩
lemma not_denselyOrdered_withZero_int : ¬ DenselyOrdered ℤᵐ⁰ :=
(LinearOrderedCommGroupWithZero.discrete_iff_not_denselyOrdered _).mp ⟨.refl _⟩
lemma WithZero.denselyOrdered_set_iff_subsingleton {X : Type*} [LinearOrder X]
[LocallyFiniteOrder X] {s : Set (WithZero X)} :
DenselyOrdered s ↔ s.Subsingleton :=
WithBot.denselyOrdered_set_iff_subsingleton
end DenselyOrdered |
.lake/packages/mathlib/Mathlib/GroupTheory/PGroup.lean | import Mathlib.GroupTheory.Perm.Cycle.Type
import Mathlib.GroupTheory.SpecificGroups.Cyclic
/-!
# p-groups
This file contains a proof that if `G` is a `p`-group acting on a finite set `α`,
then the number of fixed points of the action is congruent mod `p` to the cardinality of `α`.
It also contains proofs of some corollaries of this lemma about existence of fixed points.
-/
open Fintype MulAction
variable (p : ℕ) (G : Type*) [Group G]
/-- A p-group is a group in which every element has prime power order -/
def IsPGroup : Prop :=
∀ g : G, ∃ k : ℕ, g ^ p ^ k = 1
variable {p} {G}
namespace IsPGroup
theorem iff_orderOf [hp : Fact p.Prime] : IsPGroup p G ↔ ∀ g : G, ∃ k : ℕ, orderOf g = p ^ k :=
forall_congr' fun g =>
⟨fun ⟨_, hk⟩ =>
Exists.imp (fun _ h => h.right)
((Nat.dvd_prime_pow hp.out).mp (orderOf_dvd_of_pow_eq_one hk)),
Exists.imp fun k hk => by rw [← hk, pow_orderOf_eq_one]⟩
theorem of_card {n : ℕ} (hG : Nat.card G = p ^ n) : IsPGroup p G := fun g =>
⟨n, by rw [← hG, pow_card_eq_one']⟩
theorem of_bot : IsPGroup p (⊥ : Subgroup G) :=
of_card (n := 0) (by rw [Subgroup.card_bot, pow_zero])
theorem iff_card [Fact p.Prime] [Finite G] : IsPGroup p G ↔ ∃ n : ℕ, Nat.card G = p ^ n := by
have hG : Nat.card G ≠ 0 := Nat.card_pos.ne'
refine ⟨fun h => ?_, fun ⟨n, hn⟩ => of_card hn⟩
suffices ∀ q ∈ (Nat.card G).primeFactorsList, q = p by
use (Nat.card G).primeFactorsList.length
rw [← List.prod_replicate, ← List.eq_replicate_of_mem this, Nat.prod_primeFactorsList hG]
intro q hq
obtain ⟨hq1, hq2⟩ := (Nat.mem_primeFactorsList hG).mp hq
haveI : Fact q.Prime := ⟨hq1⟩
obtain ⟨g, hg⟩ := exists_prime_orderOf_dvd_card' q hq2
obtain ⟨k, hk⟩ := (iff_orderOf.mp h) g
exact (hq1.pow_eq_iff.mp (hg.symm.trans hk).symm).1.symm
alias ⟨exists_card_eq, _⟩ := iff_card
section GIsPGroup
variable (hG : IsPGroup p G)
include hG
theorem of_injective {H : Type*} [Group H] (ϕ : H →* G) (hϕ : Function.Injective ϕ) :
IsPGroup p H := by
simp_rw [IsPGroup, ← hϕ.eq_iff, ϕ.map_pow, ϕ.map_one]
exact fun h => hG (ϕ h)
theorem to_subgroup (H : Subgroup G) : IsPGroup p H :=
hG.of_injective H.subtype Subtype.coe_injective
theorem of_surjective {H : Type*} [Group H] (ϕ : G →* H) (hϕ : Function.Surjective ϕ) :
IsPGroup p H := by
refine fun h => Exists.elim (hϕ h) fun g hg => Exists.imp (fun k hk => ?_) (hG g)
rw [← hg, ← ϕ.map_pow, hk, ϕ.map_one]
theorem to_quotient (H : Subgroup G) [H.Normal] : IsPGroup p (G ⧸ H) :=
hG.of_surjective (QuotientGroup.mk' H) Quotient.mk''_surjective
theorem of_equiv {H : Type*} [Group H] (ϕ : G ≃* H) : IsPGroup p H :=
hG.of_surjective ϕ.toMonoidHom ϕ.surjective
theorem orderOf_coprime {n : ℕ} (hn : p.Coprime n) (g : G) : (orderOf g).Coprime n :=
let ⟨k, hk⟩ := hG g
(hn.pow_left k).coprime_dvd_left (orderOf_dvd_of_pow_eq_one hk)
/-- If `gcd(p,n) = 1`, then the `n`th power map is a bijection. -/
noncomputable def powEquiv {n : ℕ} (hn : p.Coprime n) : G ≃ G :=
let h : ∀ g : G, (Nat.card (Subgroup.zpowers g)).Coprime n := fun g =>
(Nat.card_zpowers g).symm ▸ hG.orderOf_coprime hn g
{ toFun := (· ^ n)
invFun := fun g => (powCoprime (h g)).symm ⟨g, Subgroup.mem_zpowers g⟩
left_inv := fun g =>
Subtype.ext_iff.1 <|
(powCoprime (h (g ^ n))).left_inv
⟨g, _, Subtype.ext_iff.1 <| (powCoprime (h g)).left_inv ⟨g, Subgroup.mem_zpowers g⟩⟩
right_inv := fun g =>
Subtype.ext_iff.1 <| (powCoprime (h g)).right_inv ⟨g, Subgroup.mem_zpowers g⟩ }
@[simp]
theorem powEquiv_apply {n : ℕ} (hn : p.Coprime n) (g : G) : hG.powEquiv hn g = g ^ n :=
rfl
@[simp]
theorem powEquiv_symm_apply {n : ℕ} (hn : p.Coprime n) (g : G) :
(hG.powEquiv hn).symm g = g ^ (orderOf g).gcdB n := by rw [← Nat.card_zpowers]; rfl
variable [hp : Fact p.Prime]
/-- If `p ∤ n`, then the `n`th power map is a bijection. -/
noncomputable abbrev powEquiv' {n : ℕ} (hn : ¬p ∣ n) : G ≃ G :=
powEquiv hG (hp.out.coprime_iff_not_dvd.mpr hn)
theorem index (H : Subgroup G) [H.FiniteIndex] : ∃ n : ℕ, H.index = p ^ n := by
obtain ⟨n, hn⟩ := iff_card.mp (hG.to_quotient H.normalCore)
obtain ⟨k, _, hk2⟩ :=
(Nat.dvd_prime_pow hp.out).mp
((congr_arg _ (H.normalCore.index_eq_card.trans hn)).mp
(Subgroup.index_dvd_of_le H.normalCore_le))
exact ⟨k, hk2⟩
theorem card_eq_or_dvd : Nat.card G = 1 ∨ p ∣ Nat.card G := by
cases finite_or_infinite G
· obtain ⟨n, hn⟩ := iff_card.mp hG
rw [hn]
rcases n with - | n
· exact Or.inl rfl
· exact Or.inr ⟨p ^ n, by rw [pow_succ']⟩
· rw [Nat.card_eq_zero_of_infinite]
exact Or.inr ⟨0, rfl⟩
theorem nontrivial_iff_card [Finite G] : Nontrivial G ↔ ∃ n > 0, Nat.card G = p ^ n :=
⟨fun hGnt =>
let ⟨k, hk⟩ := iff_card.1 hG
⟨k,
Nat.pos_of_ne_zero fun hk0 => by
rw [hk0, pow_zero] at hk; exact Finite.one_lt_card.ne' hk,
hk⟩,
fun ⟨_, hk0, hk⟩ =>
Finite.one_lt_card_iff_nontrivial.1 <|
hk.symm ▸ one_lt_pow₀ (Fact.out (p := p.Prime)).one_lt (ne_of_gt hk0)⟩
variable {α : Type*} [MulAction G α]
theorem card_orbit (a : α) [Finite (orbit G a)] : ∃ n : ℕ, Nat.card (orbit G a) = p ^ n := by
let ϕ := orbitEquivQuotientStabilizer G a
haveI := Finite.of_equiv (orbit G a) ϕ
haveI := (stabilizer G a).finiteIndex_of_finite_quotient
rw [Nat.card_congr ϕ]
exact hG.index (stabilizer G a)
variable (α) [Finite α]
/-- If `G` is a `p`-group acting on a finite set `α`, then the number of fixed points
of the action is congruent mod `p` to the cardinality of `α` -/
theorem card_modEq_card_fixedPoints : Nat.card α ≡ Nat.card (fixedPoints G α) [MOD p] := by
have := Fintype.ofFinite α
have := Fintype.ofFinite (fixedPoints G α)
rw [Nat.card_eq_fintype_card, Nat.card_eq_fintype_card]
classical
calc
card α = card (Σ y : Quotient (orbitRel G α), { x // Quotient.mk'' x = y }) :=
card_congr (Equiv.sigmaFiberEquiv (@Quotient.mk'' _ (orbitRel G α))).symm
_ = ∑ a : Quotient (orbitRel G α), card { x // Quotient.mk'' x = a } := card_sigma
_ ≡ ∑ _a : fixedPoints G α, 1 [MOD p] := ?_
_ = _ := by simp
rw [← ZMod.natCast_eq_natCast_iff _ _ p, Nat.cast_sum, Nat.cast_sum]
have key :
∀ x,
card { y // (Quotient.mk'' y : Quotient (orbitRel G α)) = Quotient.mk'' x } =
card (orbit G x) :=
fun x => by simp only [Quotient.eq'']; congr
refine
Eq.symm
(Finset.sum_bij_ne_zero (fun a _ _ => Quotient.mk'' a.1) (fun _ _ _ => Finset.mem_univ _)
(fun a₁ _ _ a₂ _ _ h =>
Subtype.eq (mem_fixedPoints'.mp a₂.2 a₁.1 (Quotient.exact' h)))
(fun b => Quotient.inductionOn' b fun b _ hb => ?_) fun a ha _ => by
rw [key, mem_fixedPoints_iff_card_orbit_eq_one.mp a.2])
obtain ⟨k, hk⟩ := hG.card_orbit b
rw [Nat.card_eq_fintype_card] at hk
have : k = 0 := by
contrapose! hb
simp [-Quotient.eq, key, hk, hb]
exact
⟨⟨b, mem_fixedPoints_iff_card_orbit_eq_one.2 <| by rw [hk, this, pow_zero]⟩,
Finset.mem_univ _, ne_of_eq_of_ne Nat.cast_one one_ne_zero, rfl⟩
/-- If a p-group acts on `α` and the cardinality of `α` is not a multiple
of `p` then the action has a fixed point. -/
theorem nonempty_fixed_point_of_prime_not_dvd_card (α) [MulAction G α] (hpα : ¬p ∣ Nat.card α) :
(fixedPoints G α).Nonempty :=
have : Finite α := Nat.finite_of_card_ne_zero (fun h ↦ (h ▸ hpα) (dvd_zero p))
@Set.Nonempty.of_subtype _ _
(by
rw [← Finite.card_pos_iff, pos_iff_ne_zero]
contrapose! hpα
rw [← Nat.modEq_zero_iff_dvd, ← hpα]
exact hG.card_modEq_card_fixedPoints α)
/-- If a p-group acts on `α` and the cardinality of `α` is a multiple
of `p`, and the action has one fixed point, then it has another fixed point. -/
theorem exists_fixed_point_of_prime_dvd_card_of_fixed_point (hpα : p ∣ Nat.card α) {a : α}
(ha : a ∈ fixedPoints G α) : ∃ b, b ∈ fixedPoints G α ∧ a ≠ b := by
have hpf : p ∣ Nat.card (fixedPoints G α) :=
Nat.modEq_zero_iff_dvd.mp ((hG.card_modEq_card_fixedPoints α).symm.trans hpα.modEq_zero_nat)
have hα : 1 < Nat.card (fixedPoints G α) :=
(Fact.out (p := p.Prime)).one_lt.trans_le (Nat.le_of_dvd (Finite.card_pos_iff.2 ⟨⟨a, ha⟩⟩) hpf)
rw [Finite.one_lt_card_iff_nontrivial] at hα
exact
let ⟨⟨b, hb⟩, hba⟩ := exists_ne (⟨a, ha⟩ : fixedPoints G α)
⟨b, hb, fun hab => hba (by simp_rw [hab])⟩
theorem center_nontrivial [Nontrivial G] [Finite G] : Nontrivial (Subgroup.center G) := by
classical
have := (hG.of_equiv ConjAct.toConjAct).exists_fixed_point_of_prime_dvd_card_of_fixed_point G
rw [ConjAct.fixedPoints_eq_center] at this
have dvd : p ∣ Nat.card G := by
obtain ⟨n, hn0, hn⟩ := hG.nontrivial_iff_card.mp inferInstance
exact hn.symm ▸ dvd_pow_self _ (ne_of_gt hn0)
obtain ⟨g, hg⟩ := this dvd (Subgroup.center G).one_mem
exact ⟨⟨1, ⟨g, hg.1⟩, mt Subtype.ext_iff.mp hg.2⟩⟩
theorem bot_lt_center [Nontrivial G] [Finite G] : ⊥ < Subgroup.center G := by
haveI := center_nontrivial hG
classical exact
bot_lt_iff_ne_bot.mpr ((Subgroup.center G).one_lt_card_iff_ne_bot.mp Finite.one_lt_card)
end GIsPGroup
theorem to_le {H K : Subgroup G} (hK : IsPGroup p K) (hHK : H ≤ K) : IsPGroup p H :=
hK.of_injective (Subgroup.inclusion hHK) fun a b h =>
Subtype.ext (by
change ((Subgroup.inclusion hHK) a : G) = (Subgroup.inclusion hHK) b
apply Subtype.ext_iff.mp h)
theorem to_inf_left {H K : Subgroup G} (hH : IsPGroup p H) : IsPGroup p (H ⊓ K : Subgroup G) :=
hH.to_le inf_le_left
theorem to_inf_right {H K : Subgroup G} (hK : IsPGroup p K) : IsPGroup p (H ⊓ K : Subgroup G) :=
hK.to_le inf_le_right
theorem map {H : Subgroup G} (hH : IsPGroup p H) {K : Type*} [Group K] (ϕ : G →* K) :
IsPGroup p (H.map ϕ) := by
rw [← H.range_subtype, MonoidHom.map_range]
exact hH.of_surjective (ϕ.restrict H).rangeRestrict (ϕ.restrict H).rangeRestrict_surjective
theorem comap_of_ker_isPGroup {H : Subgroup G} (hH : IsPGroup p H) {K : Type*} [Group K]
(ϕ : K →* G) (hϕ : IsPGroup p ϕ.ker) : IsPGroup p (H.comap ϕ) := by
intro g
obtain ⟨j, hj⟩ := hH ⟨ϕ g.1, g.2⟩
rw [Subtype.ext_iff, H.coe_pow, Subtype.coe_mk, ← ϕ.map_pow] at hj
obtain ⟨k, hk⟩ := hϕ ⟨g.1 ^ p ^ j, hj⟩
rw [Subtype.ext_iff, ϕ.ker.coe_pow, Subtype.coe_mk, ← pow_mul, ← pow_add] at hk
exact ⟨j + k, by rwa [Subtype.ext_iff, (H.comap ϕ).coe_pow]⟩
theorem ker_isPGroup_of_injective {K : Type*} [Group K] {ϕ : K →* G} (hϕ : Function.Injective ϕ) :
IsPGroup p ϕ.ker :=
(congr_arg (fun Q : Subgroup K => IsPGroup p Q) (ϕ.ker_eq_bot_iff.mpr hϕ)).mpr IsPGroup.of_bot
theorem comap_of_injective {H : Subgroup G} (hH : IsPGroup p H) {K : Type*} [Group K] (ϕ : K →* G)
(hϕ : Function.Injective ϕ) : IsPGroup p (H.comap ϕ) :=
hH.comap_of_ker_isPGroup ϕ (ker_isPGroup_of_injective hϕ)
theorem comap_subtype {H : Subgroup G} (hH : IsPGroup p H) {K : Subgroup G} :
IsPGroup p (H.comap K.subtype) :=
hH.comap_of_injective K.subtype Subtype.coe_injective
theorem to_sup_of_normal_right {H K : Subgroup G} (hH : IsPGroup p H) (hK : IsPGroup p K)
[K.Normal] : IsPGroup p (H ⊔ K : Subgroup G) := by
rw [← QuotientGroup.ker_mk' K, ← Subgroup.comap_map_eq]
apply (hH.map (QuotientGroup.mk' K)).comap_of_ker_isPGroup
rwa [QuotientGroup.ker_mk']
theorem to_sup_of_normal_left {H K : Subgroup G} (hH : IsPGroup p H) (hK : IsPGroup p K)
[H.Normal] : IsPGroup p (H ⊔ K : Subgroup G) := sup_comm H K ▸ to_sup_of_normal_right hK hH
theorem to_sup_of_normal_right' {H K : Subgroup G} (hH : IsPGroup p H) (hK : IsPGroup p K)
(hHK : H ≤ K.normalizer) : IsPGroup p (H ⊔ K : Subgroup G) :=
let hHK' :=
to_sup_of_normal_right (hH.of_equiv (Subgroup.subgroupOfEquivOfLe hHK).symm)
(hK.of_equiv (Subgroup.subgroupOfEquivOfLe Subgroup.le_normalizer).symm)
((congr_arg (fun H : Subgroup K.normalizer => IsPGroup p H)
((Subgroup.subgroupOf_sup hHK Subgroup.le_normalizer).symm)).mp
hHK').of_equiv
(Subgroup.subgroupOfEquivOfLe (sup_le hHK Subgroup.le_normalizer))
theorem to_sup_of_normal_left' {H K : Subgroup G} (hH : IsPGroup p H) (hK : IsPGroup p K)
(hHK : K ≤ H.normalizer) : IsPGroup p (H ⊔ K : Subgroup G) :=
sup_comm H K ▸ to_sup_of_normal_right' hK hH hHK
/-- finite p-groups with different p have coprime orders -/
theorem coprime_card_of_ne {G₂ : Type*} [Group G₂] (p₁ p₂ : ℕ) [hp₁ : Fact p₁.Prime]
[hp₂ : Fact p₂.Prime] (hne : p₁ ≠ p₂) (H₁ : Subgroup G) (H₂ : Subgroup G₂) [Finite H₁]
[Finite H₂] (hH₁ : IsPGroup p₁ H₁) (hH₂ : IsPGroup p₂ H₂) :
Nat.Coprime (Nat.card H₁) (Nat.card H₂) := by
obtain ⟨n₁, heq₁⟩ := iff_card.mp hH₁; rw [heq₁]; clear heq₁
obtain ⟨n₂, heq₂⟩ := iff_card.mp hH₂; rw [heq₂]; clear heq₂
exact Nat.coprime_pow_primes _ _ hp₁.elim hp₂.elim hne
/-- p-groups with different p are disjoint -/
theorem disjoint_of_ne (p₁ p₂ : ℕ) [hp₁ : Fact p₁.Prime] [hp₂ : Fact p₂.Prime] (hne : p₁ ≠ p₂)
(H₁ H₂ : Subgroup G) (hH₁ : IsPGroup p₁ H₁) (hH₂ : IsPGroup p₂ H₂) : Disjoint H₁ H₂ := by
rw [Subgroup.disjoint_def]
intro x hx₁ hx₂
obtain ⟨n₁, hn₁⟩ := iff_orderOf.mp hH₁ ⟨x, hx₁⟩
obtain ⟨n₂, hn₂⟩ := iff_orderOf.mp hH₂ ⟨x, hx₂⟩
rw [Subgroup.orderOf_mk] at hn₁ hn₂
have : p₁ ^ n₁ = p₂ ^ n₂ := by rw [← hn₁, ← hn₂]
rcases n₁.eq_zero_or_pos with (rfl | hn₁)
· simpa using hn₁
· exact absurd (eq_of_prime_pow_eq hp₁.out.prime hp₂.out.prime hn₁ this) hne
theorem le_or_disjoint_of_coprime [hp : Fact p.Prime] {P : Subgroup G} (hP : IsPGroup p P)
{H : Subgroup G} [H.Normal] (h_cop : (Nat.card H).Coprime H.index) :
P ≤ H ∨ Disjoint H P := by
by_cases h1 : Nat.card H = 0
· rw [h1, Nat.coprime_zero_left, Subgroup.index_eq_one] at h_cop
rw [h_cop]
exact Or.inl le_top
by_cases h2 : H.index = 0
· rw [h2, Nat.coprime_zero_right, Subgroup.card_eq_one] at h_cop
rw [h_cop]
exact Or.inr disjoint_bot_left
have : Finite G := by
apply Nat.finite_of_card_ne_zero
rw [← H.card_mul_index]
exact mul_ne_zero h1 h2
have h3 : (Nat.card H).Coprime (Nat.card P) ∨ H.index.Coprime (Nat.card P) := by
obtain ⟨k, hk⟩ := hP.exists_card_eq
refine hk ▸ Or.imp hp.out.coprime_pow_of_not_dvd hp.out.coprime_pow_of_not_dvd ?_
contrapose! h_cop
exact Nat.Prime.not_coprime_iff_dvd.mpr ⟨p, hp.out, h_cop⟩
refine h3.symm.imp (fun h4 ↦ ?_) (fun h4 ↦ ?_)
· rw [← Subgroup.relIndex_eq_one]
exact Nat.eq_one_of_dvd_coprimes h4 (H.relIndex_dvd_index_of_normal P)
(Subgroup.relIndex_dvd_card H P)
· exact disjoint_iff.mpr (Subgroup.inf_eq_bot_of_coprime h4)
section P2comm
variable [Fact p.Prime] {n : ℕ}
open Subgroup
/-- The cardinality of the `center` of a `p`-group is `p ^ k` where `k` is positive. -/
theorem card_center_eq_prime_pow (hGpn : Nat.card G = p ^ n) (hn : 0 < n) :
∃ k > 0, Nat.card (center G) = p ^ k := by
have : Finite G := Nat.finite_of_card_ne_zero (hGpn ▸ pow_ne_zero n (NeZero.ne p))
have hcG := to_subgroup (of_card hGpn) (center G)
rcases iff_card.1 hcG with _
haveI : Nontrivial G := (nontrivial_iff_card <| of_card hGpn).2 ⟨n, hn, hGpn⟩
exact (nontrivial_iff_card hcG).mp (center_nontrivial (of_card hGpn))
/-- The quotient by the center of a group of cardinality `p ^ 2` is cyclic. -/
theorem cyclic_center_quotient_of_card_eq_prime_sq (hG : Nat.card G = p ^ 2) :
IsCyclic (G ⧸ center G) := by
apply isCyclic_of_card_dvd_prime (p := p)
rw [← mul_dvd_mul_iff_left (NeZero.ne p), ← sq, ← hG, ← (center G).card_mul_index]
apply mul_dvd_mul_right
rcases card_center_eq_prime_pow hG zero_lt_two with ⟨k, hk0, hk⟩
rw [hk]
exact dvd_pow_self p hk0.ne'
/-- A group of order `p ^ 2` is commutative. See also `IsPGroup.commutative_of_card_eq_prime_sq`
for just the proof that `∀ a b, a * b = b * a` -/
def commGroupOfCardEqPrimeSq (hG : Nat.card G = p ^ 2) : CommGroup G :=
@commGroupOfCyclicCenterQuotient _ _ _ _ (cyclic_center_quotient_of_card_eq_prime_sq hG) _
(QuotientGroup.ker_mk' (center G)).le
/-- A group of order `p ^ 2` is commutative. See also `IsPGroup.commGroupOfCardEqPrimeSq`
for the `CommGroup` instance. -/
theorem commutative_of_card_eq_prime_sq (hG : Nat.card G = p ^ 2) : ∀ a b : G, a * b = b * a :=
(commGroupOfCardEqPrimeSq hG).mul_comm
end P2comm
end IsPGroup
namespace ZModModule
variable {n : ℕ} {G : Type*} [AddCommGroup G] [Module (ZMod n) G]
lemma isPGroup_multiplicative : IsPGroup n (Multiplicative G) := by
simpa [IsPGroup, Multiplicative.forall] using
fun _ ↦ ⟨1, by simp [← ofAdd_nsmul, ZModModule.char_nsmul_eq_zero]⟩
end ZModModule |
.lake/packages/mathlib/Mathlib/GroupTheory/NoncommPiCoprod.lean | import Mathlib.GroupTheory.OrderOfElement
import Mathlib.Data.Nat.GCD.BigOperators
import Mathlib.Order.SupIndep
/-!
# Canonical homomorphism from a finite family of monoids
This file defines the construction of the canonical homomorphism from a family of monoids.
Given a family of morphisms `ϕ i : N i →* M` for each `i : ι` where elements in the
images of different morphisms commute, we obtain a canonical morphism
`MonoidHom.noncommPiCoprod : (Π i, N i) →* M` that coincides with `ϕ`
## Main definitions
* `MonoidHom.noncommPiCoprod : (Π i, N i) →* M` is the main homomorphism
* `Subgroup.noncommPiCoprod : (Π i, H i) →* G` is the specialization to `H i : Subgroup G`
and the subgroup embedding.
## Main theorems
* `MonoidHom.noncommPiCoprod` coincides with `ϕ i` when restricted to `N i`
* `MonoidHom.noncommPiCoprod_mrange`: The range of `MonoidHom.noncommPiCoprod` is
`⨆ (i : ι), (ϕ i).mrange`
* `MonoidHom.noncommPiCoprod_range`: The range of `MonoidHom.noncommPiCoprod` is
`⨆ (i : ι), (ϕ i).range`
* `Subgroup.noncommPiCoprod_range`: The range of `Subgroup.noncommPiCoprod` is `⨆ (i : ι), H i`.
* `MonoidHom.injective_noncommPiCoprod_of_iSupIndep`: in the case of groups, `pi_hom.hom` is
injective if the `ϕ` are injective and the ranges of the `ϕ` are independent.
* `MonoidHom.independent_range_of_coprime_order`: If the `N i` have coprime orders, then the ranges
of the `ϕ` are independent.
* `Subgroup.independent_of_coprime_order`: If commuting normal subgroups `H i` have coprime orders,
they are independent.
-/
assert_not_exists Field
namespace Subgroup
variable {G : Type*} [Group G]
/-- `Finset.noncommProd` is “injective” in `f` if `f` maps into independent subgroups. This
generalizes (one direction of) `Subgroup.disjoint_iff_mul_eq_one`. -/
@[to_additive /-- `Finset.noncommSum` is “injective” in `f` if `f` maps into independent subgroups.
This generalizes (one direction of) `AddSubgroup.disjoint_iff_add_eq_zero`. -/]
theorem eq_one_of_noncommProd_eq_one_of_iSupIndep {ι : Type*} (s : Finset ι) (f : ι → G) (comm)
(K : ι → Subgroup G) (hind : iSupIndep K) (hmem : ∀ x ∈ s, f x ∈ K x)
(heq1 : s.noncommProd f comm = 1) : ∀ i ∈ s, f i = 1 := by
classical
revert heq1
induction s using Finset.induction_on with
| empty => simp
| insert i s hnotMem ih =>
have hcomm := comm.mono (Finset.coe_subset.2 <| Finset.subset_insert _ _)
simp only [Finset.forall_mem_insert] at hmem
have hmem_bsupr : s.noncommProd f hcomm ∈ ⨆ i ∈ (s : Set ι), K i := by
refine Subgroup.noncommProd_mem _ _ ?_
intro x hx
have : K x ≤ ⨆ i ∈ (s : Set ι), K i := le_iSup₂ (f := fun i _ => K i) x hx
exact this (hmem.2 x hx)
intro heq1
rw [Finset.noncommProd_insert_of_notMem _ _ _ _ hnotMem] at heq1
have hnotMem' : i ∉ (s : Set ι) := by simpa
obtain ⟨heq1i : f i = 1, heq1S : s.noncommProd f _ = 1⟩ :=
Subgroup.disjoint_iff_mul_eq_one.mp (hind.disjoint_biSup hnotMem') hmem.1 hmem_bsupr heq1
intro i h
simp only [Finset.mem_insert] at h
rcases h with (rfl | h)
· exact heq1i
· refine ih hcomm hmem.2 heq1S _ h
end Subgroup
section FamilyOfMonoids
variable {M : Type*} [Monoid M]
-- We have a family of monoids
-- The fintype assumption is not always used, but declared here, to keep things in order
variable {ι : Type*} [Fintype ι]
variable {N : ι → Type*} [∀ i, Monoid (N i)]
-- And morphisms ϕ into G
variable (ϕ : ∀ i : ι, N i →* M)
-- We assume that the elements of different morphism commute
variable (hcomm : Pairwise fun i j => ∀ x y, Commute (ϕ i x) (ϕ j y))
namespace MonoidHom
/-- The canonical homomorphism from a family of monoids. -/
@[to_additive /-- The canonical homomorphism from a family of additive monoids. See also
`LinearMap.lsum` for a linear version without the commutativity assumption. -/]
def noncommPiCoprod : (∀ i : ι, N i) →* M where
toFun f := Finset.univ.noncommProd (fun i => ϕ i (f i)) fun _ _ _ _ h => hcomm h _ _
map_one' := by
apply (Finset.noncommProd_eq_pow_card _ _ _ _ _).trans (one_pow _)
simp
map_mul' f g := by
classical
convert @Finset.noncommProd_mul_distrib _ _ _ _ (fun i => ϕ i (f i)) (fun i => ϕ i (g i)) _ _ _
· exact map_mul _ _ _
· rintro i - j - h
exact hcomm h _ _
variable {hcomm}
@[to_additive (attr := simp)]
theorem noncommPiCoprod_mulSingle [DecidableEq ι] (i : ι) (y : N i) :
noncommPiCoprod ϕ hcomm (Pi.mulSingle i y) = ϕ i y := by
change Finset.univ.noncommProd (fun j => ϕ j (Pi.mulSingle i y j)) (fun _ _ _ _ h => hcomm h _ _)
= ϕ i y
rw [← Finset.insert_erase (Finset.mem_univ i)]
rw [Finset.noncommProd_insert_of_notMem _ _ _ _ (Finset.notMem_erase i _)]
rw [Pi.mulSingle_eq_same]
rw [Finset.noncommProd_eq_pow_card]
· rw [one_pow]
exact mul_one _
· intro j hj
simp only [Finset.mem_erase] at hj
simp [hj]
/--
The universal property of `MonoidHom.noncommPiCoprod`
Given monoid morphisms `φᵢ : Nᵢ → M` whose images pairwise commute,
there exists a unique monoid morphism `φ : Πᵢ Nᵢ → M` that induces the `φᵢ`,
and it is given by `MonoidHom.noncommPiCoprod`. -/
@[to_additive /-- The universal property of `MonoidHom.noncommPiCoprod`
Given monoid morphisms `φᵢ : Nᵢ → M` whose images pairwise commute,
there exists a unique monoid morphism `φ : Πᵢ Nᵢ → M` that induces the `φᵢ`,
and it is given by `AddMonoidHom.noncommPiCoprod`. -/]
def noncommPiCoprodEquiv [DecidableEq ι] :
{ ϕ : ∀ i, N i →* M // Pairwise fun i j => ∀ x y, Commute (ϕ i x) (ϕ j y) } ≃
((∀ i, N i) →* M) where
toFun ϕ := noncommPiCoprod ϕ.1 ϕ.2
invFun f :=
⟨fun i => f.comp (MonoidHom.mulSingle N i), fun _ _ hij x y =>
Commute.map (Pi.mulSingle_commute hij x y) f⟩
left_inv ϕ := by
ext
simp only [coe_comp, Function.comp_apply, mulSingle_apply, noncommPiCoprod_mulSingle]
right_inv f := pi_ext fun i x => by
simp only [noncommPiCoprod_mulSingle, coe_comp, Function.comp_apply, mulSingle_apply]
@[to_additive]
theorem noncommPiCoprod_mrange :
MonoidHom.mrange (noncommPiCoprod ϕ hcomm) = ⨆ i : ι, MonoidHom.mrange (ϕ i) := by
letI := Classical.decEq ι
apply le_antisymm
· rintro x ⟨f, rfl⟩
refine Submonoid.noncommProd_mem _ _ _ (fun _ _ _ _ h => hcomm h _ _) (fun i _ => ?_)
apply Submonoid.mem_sSup_of_mem
· use i
simp
· refine iSup_le ?_
rintro i x ⟨y, rfl⟩
exact ⟨Pi.mulSingle i y, noncommPiCoprod_mulSingle _ _ _⟩
@[to_additive]
lemma commute_noncommPiCoprod {m : M}
(comm : ∀ i (x : N i), Commute m ((ϕ i x))) (h : (i : ι) → N i) :
Commute m (MonoidHom.noncommPiCoprod ϕ hcomm h) := by
dsimp only [MonoidHom.noncommPiCoprod, MonoidHom.coe_mk, OneHom.coe_mk]
apply Finset.noncommProd_induction
· exact fun x y ↦ Commute.mul_right
· exact Commute.one_right _
· exact fun x _ ↦ comm x (h x)
@[to_additive]
lemma noncommPiCoprod_apply (h : (i : ι) → N i) :
MonoidHom.noncommPiCoprod ϕ hcomm h = Finset.noncommProd Finset.univ (fun i ↦ ϕ i (h i))
(Pairwise.set_pairwise (fun ⦃i j⦄ a ↦ hcomm a (h i) (h j)) _) := by
dsimp only [MonoidHom.noncommPiCoprod, MonoidHom.coe_mk, OneHom.coe_mk]
/--
Given monoid morphisms `φᵢ : Nᵢ → M` and `f : M → P`, if we have sufficient commutativity, then
`f ∘ (∐ᵢ φᵢ) = ∐ᵢ (f ∘ φᵢ)` -/
@[to_additive]
theorem comp_noncommPiCoprod {P : Type*} [Monoid P] {f : M →* P}
(hcomm' : Pairwise fun i j => ∀ x y, Commute (f.comp (ϕ i) x) (f.comp (ϕ j) y) :=
Pairwise.mono hcomm (fun i j ↦ forall_imp (fun x h y ↦ by
simp only [MonoidHom.coe_comp, Function.comp_apply, Commute.map (h y) f]))) :
f.comp (MonoidHom.noncommPiCoprod ϕ hcomm) =
MonoidHom.noncommPiCoprod (fun i ↦ f.comp (ϕ i)) hcomm' :=
MonoidHom.ext fun _ ↦ by
simp only [MonoidHom.noncommPiCoprod, MonoidHom.coe_comp, MonoidHom.coe_mk, OneHom.coe_mk,
Function.comp_apply, Finset.map_noncommProd]
end MonoidHom
end FamilyOfMonoids
section FamilyOfGroups
variable {G : Type*} [Group G]
variable {ι : Type*}
variable {H : ι → Type*} [∀ i, Group (H i)]
variable (ϕ : ∀ i : ι, H i →* G)
namespace MonoidHom
-- The subgroup version of `MonoidHom.noncommPiCoprod_mrange`
@[to_additive]
theorem noncommPiCoprod_range [Fintype ι]
{hcomm : Pairwise fun i j : ι => ∀ (x : H i) (y : H j), Commute (ϕ i x) (ϕ j y)} :
(noncommPiCoprod ϕ hcomm).range = ⨆ i : ι, (ϕ i).range := by
letI := Classical.decEq ι
apply le_antisymm
· rintro x ⟨f, rfl⟩
refine Subgroup.noncommProd_mem _ (fun _ _ _ _ h => hcomm h _ _) ?_
intro i _hi
apply Subgroup.mem_sSup_of_mem
· use i
simp
· refine iSup_le ?_
rintro i x ⟨y, rfl⟩
exact ⟨Pi.mulSingle i y, noncommPiCoprod_mulSingle _ _ _⟩
@[to_additive]
theorem injective_noncommPiCoprod_of_iSupIndep [Fintype ι]
{hcomm : Pairwise fun i j : ι => ∀ (x : H i) (y : H j), Commute (ϕ i x) (ϕ j y)}
(hind : iSupIndep fun i => (ϕ i).range)
(hinj : ∀ i, Function.Injective (ϕ i)) : Function.Injective (noncommPiCoprod ϕ hcomm) := by
classical
apply (MonoidHom.ker_eq_bot_iff _).mp
rw [eq_bot_iff]
intro f heq1
have : ∀ i, i ∈ Finset.univ → ϕ i (f i) = 1 :=
Subgroup.eq_one_of_noncommProd_eq_one_of_iSupIndep _ _ (fun _ _ _ _ h => hcomm h _ _)
_ hind (by simp) heq1
ext i
apply hinj
simp [this i (Finset.mem_univ i)]
@[to_additive]
theorem independent_range_of_coprime_order
(hcomm : Pairwise fun i j : ι => ∀ (x : H i) (y : H j), Commute (ϕ i x) (ϕ j y))
[Finite ι] [∀ i, Fintype (H i)]
(hcoprime : Pairwise fun i j => Nat.Coprime (Fintype.card (H i)) (Fintype.card (H j))) :
iSupIndep fun i => (ϕ i).range := by
cases nonempty_fintype ι
letI := Classical.decEq ι
rintro i
rw [disjoint_iff_inf_le]
rintro f ⟨hxi, hxp⟩
dsimp at hxi hxp
rw [iSup_subtype', ← noncommPiCoprod_range] at hxp
rotate_left
· intro _ _ hj
apply hcomm
exact hj ∘ Subtype.ext
obtain ⟨g, hgf⟩ := hxp
obtain ⟨g', hg'f⟩ := hxi
have hxi : orderOf f ∣ Fintype.card (H i) := by
rw [← hg'f]
exact (orderOf_map_dvd _ _).trans orderOf_dvd_card
have hxp : orderOf f ∣ ∏ j : { j // j ≠ i }, Fintype.card (H j) := by
rw [← hgf, ← Fintype.card_pi]
exact (orderOf_map_dvd _ _).trans orderOf_dvd_card
change f = 1
rw [← pow_one f, ← orderOf_dvd_iff_pow_eq_one]
obtain ⟨c, hc⟩ := Nat.dvd_gcd hxp hxi
use c
rw [← hc]
symm
rw [← Nat.coprime_iff_gcd_eq_one, Nat.coprime_fintype_prod_left_iff, Subtype.forall]
intro j h
exact hcoprime h
end MonoidHom
end FamilyOfGroups
namespace Subgroup
-- We have a family of subgroups
variable {G : Type*} [Group G]
variable {ι : Type*} {H : ι → Subgroup G}
section CommutingSubgroups
-- We assume that the elements of different subgroups commute
-- with `hcomm : Pairwise fun i j : ι => ∀ x y : G, x ∈ H i → y ∈ H j → Commute x y`
@[to_additive]
theorem commute_subtype_of_commute
(hcomm : Pairwise fun i j : ι => ∀ x y : G, x ∈ H i → y ∈ H j → Commute x y) (i j : ι)
(hne : i ≠ j) :
∀ (x : H i) (y : H j), Commute ((H i).subtype x) ((H j).subtype y) := by
rintro ⟨x, hx⟩ ⟨y, hy⟩
exact hcomm hne x y hx hy
@[to_additive]
theorem independent_of_coprime_order
(hcomm : Pairwise fun i j : ι => ∀ x y : G, x ∈ H i → y ∈ H j → Commute x y)
[Finite ι] [∀ i, Fintype (H i)]
(hcoprime : Pairwise fun i j => Nat.Coprime (Fintype.card (H i)) (Fintype.card (H j))) :
iSupIndep H := by
simpa using
MonoidHom.independent_range_of_coprime_order (fun i => (H i).subtype)
(commute_subtype_of_commute hcomm) hcoprime
variable [Fintype ι]
/-- The canonical homomorphism from a family of subgroups where elements from different subgroups
commute -/
@[to_additive /-- The canonical homomorphism from a family of additive subgroups where elements from
different subgroups commute -/]
def noncommPiCoprod (hcomm : Pairwise fun i j : ι => ∀ x y : G, x ∈ H i → y ∈ H j → Commute x y) :
(∀ i : ι, H i) →* G :=
MonoidHom.noncommPiCoprod (fun i => (H i).subtype) (commute_subtype_of_commute hcomm)
@[to_additive (attr := simp)]
theorem noncommPiCoprod_mulSingle [DecidableEq ι]
{hcomm : Pairwise fun i j : ι => ∀ x y : G, x ∈ H i → y ∈ H j → Commute x y} (i : ι) (y : H i) :
noncommPiCoprod hcomm (Pi.mulSingle i y) = y := by apply MonoidHom.noncommPiCoprod_mulSingle
@[to_additive]
theorem noncommPiCoprod_range
{hcomm : Pairwise fun i j : ι => ∀ x y : G, x ∈ H i → y ∈ H j → Commute x y} :
(noncommPiCoprod hcomm).range = ⨆ i : ι, H i := by
simp [noncommPiCoprod, MonoidHom.noncommPiCoprod_range]
@[to_additive]
theorem injective_noncommPiCoprod_of_iSupIndep
{hcomm : Pairwise fun i j : ι => ∀ x y : G, x ∈ H i → y ∈ H j → Commute x y}
(hind : iSupIndep H) :
Function.Injective (noncommPiCoprod hcomm) := by
apply MonoidHom.injective_noncommPiCoprod_of_iSupIndep
· simpa using hind
· intro i
exact Subtype.coe_injective
@[to_additive]
theorem noncommPiCoprod_apply (comm) (u : (i : ι) → H i) :
Subgroup.noncommPiCoprod comm u = Finset.noncommProd Finset.univ (fun i ↦ u i)
(fun i _ j _ h ↦ comm h _ _ (u i).prop (u j).prop) := by
simp only [Subgroup.noncommPiCoprod, MonoidHom.noncommPiCoprod,
coe_subtype, MonoidHom.coe_mk, OneHom.coe_mk]
end CommutingSubgroups
end Subgroup |
.lake/packages/mathlib/Mathlib/GroupTheory/CoprodI.lean | import Mathlib.Algebra.Group.Action.End
import Mathlib.Algebra.Group.Action.Pointwise.Set.Basic
import Mathlib.Algebra.Group.Submonoid.Membership
import Mathlib.GroupTheory.Congruence.Basic
import Mathlib.GroupTheory.FreeGroup.IsFreeGroup
import Mathlib.SetTheory.Cardinal.Basic
/-!
# The coproduct (a.k.a. the free product) of groups or monoids
Given an `ι`-indexed family `M` of monoids,
we define their coproduct (a.k.a. free product) `Monoid.CoprodI M`.
As usual, we use the suffix `I` for an indexed (co)product,
leaving `Coprod` for the coproduct of two monoids.
When `ι` and all `M i` have decidable equality,
the free product bijects with the type `Monoid.CoprodI.Word M` of reduced words.
This bijection is constructed
by defining an action of `Monoid.CoprodI M` on `Monoid.CoprodI.Word M`.
When `M i` are all groups, `Monoid.CoprodI M` is also a group
(and the coproduct in the category of groups).
## Main definitions
- `Monoid.CoprodI M`: the free product, defined as a quotient of a free monoid.
- `Monoid.CoprodI.of {i} : M i →* Monoid.CoprodI M`.
- `Monoid.CoprodI.lift : (∀ {i}, M i →* N) ≃ (Monoid.CoprodI M →* N)`: the universal property.
- `Monoid.CoprodI.Word M`: the type of reduced words.
- `Monoid.CoprodI.Word.equiv M : Monoid.CoprodI M ≃ word M`.
- `Monoid.CoprodI.NeWord M i j`: an inductive description of non-empty words
with first letter from `M i` and last letter from `M j`,
together with an API (`singleton`, `append`, `head`, `tail`, `to_word`, `Prod`, `inv`).
Used in the proof of the Ping-Pong-lemma.
- `Monoid.CoprodI.lift_injective_of_ping_pong`: The Ping-Pong-lemma,
proving injectivity of the `lift`. See the documentation of that theorem for more information.
## Remarks
There are many answers to the question "what is the coproduct of a family `M` of monoids?",
and they are all equivalent but not obviously equivalent.
We provide two answers.
The first, almost tautological answer is given by `Monoid.CoprodI M`,
which is a quotient of the type of words in the alphabet `Σ i, M i`.
It's straightforward to define and easy to prove its universal property.
But this answer is not completely satisfactory,
because it's difficult to tell when two elements `x y : Monoid.CoprodI M` are distinct
since `Monoid.CoprodI M` is defined as a quotient.
The second, maximally efficient answer is given by `Monoid.CoprodI.Word M`.
An element of `Monoid.CoprodI.Word M` is a word in the alphabet `Σ i, M i`,
where the letter `⟨i, 1⟩` doesn't occur and no adjacent letters share an index `i`.
Since we only work with reduced words, there is no need for quotienting,
and it is easy to tell when two elements are distinct.
However it's not obvious that this is even a monoid!
We prove that every element of `Monoid.CoprodI M` can be represented by a unique reduced word,
i.e. `Monoid.CoprodI M` and `Monoid.CoprodI.Word M` are equivalent types.
This means that `Monoid.CoprodI.Word M` can be given a monoid structure,
and it lets us tell when two elements of `Monoid.CoprodI M` are distinct.
There is also a completely tautological, maximally inefficient answer
given by `MonCat.Colimits.ColimitType`.
Whereas `Monoid.CoprodI M` at least ensures that
(any instance of) associativity holds by reflexivity,
in this answer associativity holds because of quotienting.
Yet another answer, which is constructively more satisfying,
could be obtained by showing that `Monoid.CoprodI.Rel` is confluent.
## References
[van der Waerden, *Free products of groups*][MR25465]
-/
open Set
variable {ι : Type*} (M : ι → Type*) [∀ i, Monoid (M i)]
/-- A relation on the free monoid on alphabet `Σ i, M i`,
relating `⟨i, 1⟩` with `1` and `⟨i, x⟩ * ⟨i, y⟩` with `⟨i, x * y⟩`. -/
inductive Monoid.CoprodI.Rel : FreeMonoid (Σ i, M i) → FreeMonoid (Σ i, M i) → Prop
| of_one (i : ι) : Monoid.CoprodI.Rel (FreeMonoid.of ⟨i, 1⟩) 1
| of_mul {i : ι} (x y : M i) :
Monoid.CoprodI.Rel (FreeMonoid.of ⟨i, x⟩ * FreeMonoid.of ⟨i, y⟩) (FreeMonoid.of ⟨i, x * y⟩)
/-- The free product (categorical coproduct) of an indexed family of monoids. -/
def Monoid.CoprodI : Type _ := (conGen (Monoid.CoprodI.Rel M)).Quotient
deriving Monoid, Inhabited
namespace Monoid.CoprodI
/-- The type of reduced words. A reduced word cannot contain a letter `1`, and no two adjacent
letters can come from the same summand. -/
@[ext]
structure Word where
/-- A `Word` is a `List (Σ i, M i)`, such that `1` is not in the list, and no
two adjacent letters are from the same summand -/
toList : List (Σ i, M i)
/-- A reduced word does not contain `1` -/
ne_one : ∀ l ∈ toList, Sigma.snd l ≠ 1
/-- Adjacent letters are not from the same summand. -/
chain_ne : toList.IsChain fun l l' => Sigma.fst l ≠ Sigma.fst l'
variable {M}
/-- The inclusion of a summand into the free product. -/
def of {i : ι} : M i →* CoprodI M where
toFun x := Con.mk' _ (FreeMonoid.of <| Sigma.mk i x)
map_one' := (Con.eq _).mpr (ConGen.Rel.of _ _ (CoprodI.Rel.of_one i))
map_mul' x y := Eq.symm <| (Con.eq _).mpr (ConGen.Rel.of _ _ (CoprodI.Rel.of_mul x y))
theorem of_apply {i} (m : M i) : of m = Con.mk' _ (FreeMonoid.of <| Sigma.mk i m) :=
rfl
variable {N : Type*} [Monoid N]
/-- See note [partially-applied ext lemmas]. -/
@[ext 1100] -- This needs a higher `ext` priority
theorem ext_hom (f g : CoprodI M →* N) (h : ∀ i, f.comp (of : M i →* _) = g.comp of) : f = g :=
(MonoidHom.cancel_right Con.mk'_surjective).mp <|
FreeMonoid.hom_eq fun ⟨i, x⟩ => by
rw [MonoidHom.comp_apply, MonoidHom.comp_apply, ← of_apply]
unfold CoprodI
rw [← MonoidHom.comp_apply, ← MonoidHom.comp_apply, h]
/-- A map out of the free product corresponds to a family of maps out of the summands. This is the
universal property of the free product, characterizing it as a categorical coproduct. -/
@[simps symm_apply]
def lift : (∀ i, M i →* N) ≃ (CoprodI M →* N) where
toFun fi :=
Con.lift _ (FreeMonoid.lift fun p : Σ i, M i => fi p.fst p.snd) <|
Con.conGen_le <| by
simp_rw [Con.ker_rel]
rintro _ _ (i | ⟨x, y⟩) <;> simp
invFun f _ := f.comp of
left_inv := by
intro fi
ext i x
rfl
right_inv := by
intro f
ext i x
rfl
@[simp]
theorem lift_comp_of {N} [Monoid N] (fi : ∀ i, M i →* N) i : (lift fi).comp of = fi i :=
congr_fun (lift.symm_apply_apply fi) i
@[simp]
theorem lift_of {N} [Monoid N] (fi : ∀ i, M i →* N) {i} (m : M i) : lift fi (of m) = fi i m :=
DFunLike.congr_fun (lift_comp_of ..) m
@[simp]
theorem lift_comp_of' {N} [Monoid N] (f : CoprodI M →* N) :
lift (fun i ↦ f.comp (of (i := i))) = f :=
lift.apply_symm_apply f
@[simp]
theorem lift_of' : lift (fun i ↦ (of : M i →* CoprodI M)) = .id (CoprodI M) :=
lift_comp_of' (.id _)
theorem of_leftInverse [DecidableEq ι] (i : ι) :
Function.LeftInverse (lift <| Pi.mulSingle i (MonoidHom.id (M i))) of := fun x => by
simp only [lift_of, Pi.mulSingle_eq_same, MonoidHom.id_apply]
theorem of_injective (i : ι) : Function.Injective (of : M i →* _) := by
classical exact (of_leftInverse i).injective
theorem mrange_eq_iSup {N} [Monoid N] (f : ∀ i, M i →* N) :
MonoidHom.mrange (lift f) = ⨆ i, MonoidHom.mrange (f i) := by
rw [lift, Equiv.coe_fn_mk, Con.lift_range, FreeMonoid.mrange_lift,
range_sigma_eq_iUnion_range, Submonoid.closure_iUnion]
simp only [MonoidHom.mclosure_range]
theorem lift_mrange_le {N} [Monoid N] (f : ∀ i, M i →* N) {s : Submonoid N} :
MonoidHom.mrange (lift f) ≤ s ↔ ∀ i, MonoidHom.mrange (f i) ≤ s := by
simp [mrange_eq_iSup]
@[simp]
theorem iSup_mrange_of : ⨆ i, MonoidHom.mrange (of : M i →* CoprodI M) = ⊤ := by
simp [← mrange_eq_iSup]
@[simp]
theorem mclosure_iUnion_range_of :
Submonoid.closure (⋃ i, Set.range (of : M i →* CoprodI M)) = ⊤ := by
simp [Submonoid.closure_iUnion]
@[elab_as_elim]
theorem induction_left {motive : CoprodI M → Prop} (m : CoprodI M) (one : motive 1)
(mul : ∀ {i} (m : M i) x, motive x → motive (of m * x)) : motive m := by
induction m using Submonoid.induction_of_closure_eq_top_left mclosure_iUnion_range_of with
| one => exact one
| mul_left x hx y ihy =>
obtain ⟨i, m, rfl⟩ : ∃ (i : ι) (m : M i), of m = x := by simpa using hx
exact mul m y ihy
@[elab_as_elim]
theorem induction_on {motive : CoprodI M → Prop} (m : CoprodI M) (one : motive 1)
(of : ∀ (i) (m : M i), motive (of m))
(mul : ∀ x y, motive x → motive y → motive (x * y)) : motive m := by
induction m using CoprodI.induction_left with
| one => exact one
| mul m x hx => exact mul _ _ (of _ _) hx
section Group
variable (G : ι → Type*) [∀ i, Group (G i)]
instance : Inv (CoprodI G) where
inv :=
MulOpposite.unop ∘ lift fun i => (of : G i →* _).op.comp (MulEquiv.inv' (G i)).toMonoidHom
theorem inv_def (x : CoprodI G) :
x⁻¹ =
MulOpposite.unop
(lift (fun i => (of : G i →* _).op.comp (MulEquiv.inv' (G i)).toMonoidHom) x) :=
rfl
instance : Group (CoprodI G) :=
{ inv_mul_cancel := by
intro m
rw [inv_def]
induction m using CoprodI.induction_on with
| one => rw [MonoidHom.map_one, MulOpposite.unop_one, one_mul]
| of m ih =>
change of _⁻¹ * of _ = 1
rw [← of.map_mul, inv_mul_cancel, of.map_one]
| mul x y ihx ihy =>
rw [MonoidHom.map_mul, MulOpposite.unop_mul, mul_assoc, ← mul_assoc _ x y, ihx, one_mul,
ihy] }
theorem lift_range_le {N} [Group N] (f : ∀ i, G i →* N) {s : Subgroup N}
(h : ∀ i, (f i).range ≤ s) : (lift f).range ≤ s := by
rintro _ ⟨x, rfl⟩
induction x using CoprodI.induction_on with
| one => exact s.one_mem
| of i x =>
simp only [lift_of]
exact h i (Set.mem_range_self x)
| mul x y hx hy =>
simp only [map_mul]
exact s.mul_mem hx hy
theorem range_eq_iSup {N} [Group N] (f : ∀ i, G i →* N) : (lift f).range = ⨆ i, (f i).range := by
apply le_antisymm (lift_range_le _ f fun i => le_iSup (fun i => MonoidHom.range (f i)) i)
apply iSup_le _
rintro i _ ⟨x, rfl⟩
exact ⟨of x, by simp only [lift_of]⟩
end Group
namespace Word
/-- The empty reduced word. -/
@[simps]
def empty : Word M where
toList := []
ne_one := by simp
chain_ne := List.isChain_nil
instance : Inhabited (Word M) :=
⟨empty⟩
/-- A reduced word determines an element of the free product, given by multiplication. -/
def prod (w : Word M) : CoprodI M :=
List.prod (w.toList.map fun l => of l.snd)
@[simp]
theorem prod_empty : prod (empty : Word M) = 1 :=
rfl
/-- `fstIdx w` is `some i` if the first letter of `w` is `⟨i, m⟩` with `m : M i`. If `w` is empty
then it's `none`. -/
def fstIdx (w : Word M) : Option ι :=
w.toList.head?.map Sigma.fst
theorem fstIdx_ne_iff {w : Word M} {i} :
fstIdx w ≠ some i ↔ ∀ l ∈ w.toList.head?, i ≠ Sigma.fst l :=
not_iff_not.mp <| by simp [fstIdx]
variable (M)
/-- Given an index `i : ι`, `Pair M i` is the type of pairs `(head, tail)` where `head : M i` and
`tail : Word M`, subject to the constraint that first letter of `tail` can't be `⟨i, m⟩`.
By prepending `head` to `tail`, one obtains a new word. We'll show that any word can be uniquely
obtained in this way. -/
@[ext]
structure Pair (i : ι) where
/-- An element of `M i`, the first letter of the word. -/
head : M i
/-- The remaining letters of the word, excluding the first letter -/
tail : Word M
/-- The index first letter of tail of a `Pair M i` is not equal to `i` -/
fstIdx_ne : fstIdx tail ≠ some i
instance (i : ι) : Inhabited (Pair M i) :=
⟨⟨1, empty, by tauto⟩⟩
variable {M}
/-- Construct a new `Word` without any reduction. The underlying list of
`cons m w _ _` is `⟨_, m⟩::w` -/
@[simps]
def cons {i} (m : M i) (w : Word M) (hmw : w.fstIdx ≠ some i) (h1 : m ≠ 1) : Word M :=
{ toList := ⟨i, m⟩ :: w.toList,
ne_one := by
simp only [List.mem_cons]
rintro l (rfl | hl)
· exact h1
· exact w.ne_one l hl
chain_ne := w.chain_ne.cons (fstIdx_ne_iff.mp hmw) }
@[simp]
theorem fstIdx_cons {i} (m : M i) (w : Word M) (hmw : w.fstIdx ≠ some i) (h1 : m ≠ 1) :
fstIdx (cons m w hmw h1) = some i := by simp [cons, fstIdx]
@[simp]
theorem prod_cons (i) (m : M i) (w : Word M) (h1 : m ≠ 1) (h2 : w.fstIdx ≠ some i) :
prod (cons m w h2 h1) = of m * prod w := by
simp [cons, prod, List.map_cons, List.prod_cons]
section
variable [∀ i, DecidableEq (M i)]
/-- Given a pair `(head, tail)`, we can form a word by prepending `head` to `tail`, except if `head`
is `1 : M i` then we have to just return `Word` since we need the result to be reduced. -/
def rcons {i} (p : Pair M i) : Word M :=
if h : p.head = 1 then p.tail
else cons p.head p.tail p.fstIdx_ne h
@[simp]
theorem prod_rcons {i} (p : Pair M i) : prod (rcons p) = of p.head * prod p.tail :=
if hm : p.head = 1 then by rw [rcons, dif_pos hm, hm, MonoidHom.map_one, one_mul]
else by rw [rcons, dif_neg hm, cons, prod, List.map_cons, List.prod_cons, prod]
theorem rcons_inj {i} : Function.Injective (rcons : Pair M i → Word M) := by
rintro ⟨m, w, h⟩ ⟨m', w', h'⟩ he
by_cases hm : m = 1 <;> by_cases hm' : m' = 1
· simp only [rcons, dif_pos hm, dif_pos hm'] at he
simp_all
· exfalso
simp only [rcons, dif_pos hm, dif_neg hm'] at he
rw [he] at h
exact h rfl
· exfalso
simp only [rcons, dif_pos hm', dif_neg hm] at he
rw [← he] at h'
exact h' rfl
· have : m = m' ∧ w.toList = w'.toList := by
simpa [cons, rcons, dif_neg hm, dif_neg hm', eq_self_iff_true, Subtype.mk_eq_mk,
heq_iff_eq, ← Subtype.ext_iff] using he
rcases this with ⟨rfl, h⟩
congr
exact Word.ext h
theorem mem_rcons_iff {i j : ι} (p : Pair M i) (m : M j) :
⟨_, m⟩ ∈ (rcons p).toList ↔ ⟨_, m⟩ ∈ p.tail.toList ∨
m ≠ 1 ∧ (∃ h : i = j, m = h ▸ p.head) := by
simp only [rcons, cons, ne_eq]
grind
end
/-- Induct on a word by adding letters one at a time without reduction,
effectively inducting on the underlying `List`. -/
@[elab_as_elim]
def consRecOn {motive : Word M → Sort*} (w : Word M) (empty : motive empty)
(cons : ∀ (i) (m : M i) (w) h1 h2, motive w → motive (cons m w h1 h2)) :
motive w := by
rcases w with ⟨w, h1, h2⟩
induction w with
| nil => exact empty
| cons m w ih =>
refine cons m.1 m.2 ⟨w, fun _ hl => h1 _ (List.mem_cons_of_mem _ hl), h2.tail⟩ ?_ ?_ (ih _ _)
· rw [List.isChain_cons] at h2
simp only [fstIdx, ne_eq, Option.map_eq_some_iff,
Sigma.exists, exists_and_right, exists_eq_right, not_exists]
intro m' hm'
exact h2.1 _ hm' rfl
· exact h1 _ List.mem_cons_self
@[simp]
theorem consRecOn_empty {motive : Word M → Sort*} (h_empty : motive empty)
(h_cons : ∀ (i) (m : M i) (w) h1 h2, motive w → motive (cons m w h1 h2)) :
consRecOn empty h_empty h_cons = h_empty := rfl
@[simp]
theorem consRecOn_cons {motive : Word M → Sort*} (i) (m : M i) (w : Word M) h1 h2
(h_empty : motive empty)
(h_cons : ∀ (i) (m : M i) (w) h1 h2, motive w → motive (cons m w h1 h2)) :
consRecOn (cons m w h1 h2) h_empty h_cons = h_cons i m w h1 h2
(consRecOn w h_empty h_cons) := rfl
variable [DecidableEq ι] [∀ i, DecidableEq (M i)]
-- This definition is computable but not very nice to look at. Thankfully we don't have to inspect
-- it, since `rcons` is known to be injective.
/-- Given `i : ι`, any reduced word can be decomposed into a pair `p` such that `w = rcons p`. -/
private def equivPairAux (i) (w : Word M) : { p : Pair M i // rcons p = w } :=
consRecOn w ⟨⟨1, .empty, by simp [fstIdx, empty]⟩, by simp [rcons]⟩ <|
fun j m w h1 h2 _ =>
if ij : i = j then
{ val :=
{ head := ij ▸ m
tail := w
fstIdx_ne := ij ▸ h1 }
property := by subst ij; simp [rcons, h2] }
else ⟨⟨1, cons m w h1 h2, by simp [cons, fstIdx, Ne.symm ij]⟩, by simp [rcons]⟩
/-- The equivalence between words and pairs. Given a word, it decomposes it as a pair by removing
the first letter if it comes from `M i`. Given a pair, it prepends the head to the tail. -/
def equivPair (i) : Word M ≃ Pair M i where
toFun w := (equivPairAux i w).val
invFun := rcons
left_inv w := (equivPairAux i w).property
right_inv _ := rcons_inj (equivPairAux i _).property
theorem equivPair_symm (i) (p : Pair M i) : (equivPair i).symm p = rcons p :=
rfl
theorem equivPair_eq_of_fstIdx_ne {i} {w : Word M} (h : fstIdx w ≠ some i) :
equivPair i w = ⟨1, w, h⟩ :=
(equivPair i).apply_eq_iff_eq_symm_apply.mpr <| Eq.symm (dif_pos rfl)
theorem mem_equivPair_tail_iff {i j : ι} {w : Word M} (m : M i) :
(⟨i, m⟩ ∈ (equivPair j w).tail.toList) ↔ ⟨i, m⟩ ∈ w.toList.tail
∨ i ≠ j ∧ ∃ h : w.toList ≠ [], w.toList.head h = ⟨i, m⟩ := by
simp only [equivPair, equivPairAux, ne_eq, Equiv.coe_fn_mk]
induction w using consRecOn with
| empty => simp
| cons k g tail h1 h2 ih =>
simp only [consRecOn_cons]
split_ifs with h
· subst k
by_cases hij : j = i <;> simp_all
· by_cases hik : i = k
· subst i; simp_all [@eq_comm _ m g, @eq_comm _ k j, or_comm]
· simp [hik, Ne.symm hik]
theorem mem_of_mem_equivPair_tail {i j : ι} {w : Word M} (m : M i) :
(⟨i, m⟩ ∈ (equivPair j w).tail.toList) → ⟨i, m⟩ ∈ w.toList := by
rw [mem_equivPair_tail_iff]
rintro (h | h)
· exact List.mem_of_mem_tail h
· revert h; cases w.toList <;> simp +contextual
theorem equivPair_head {i : ι} {w : Word M} :
(equivPair i w).head =
if h : ∃ (h : w.toList ≠ []), (w.toList.head h).1 = i
then h.snd ▸ (w.toList.head h.1).2
else 1 := by
simp only [equivPair, equivPairAux]
induction w using consRecOn with
| empty => simp
| cons head =>
by_cases hi : i = head
· subst hi; simp
· simp [hi, Ne.symm hi]
instance summandAction (i) : MulAction (M i) (Word M) where
smul m w := rcons { equivPair i w with head := m * (equivPair i w).head }
one_smul w := by
apply (equivPair i).symm_apply_eq.mpr
simp [equivPair]
mul_smul m m' w := by
dsimp [instHSMul]
simp [mul_assoc, ← equivPair_symm, Equiv.apply_symm_apply]
instance : MulAction (CoprodI M) (Word M) :=
MulAction.ofEndHom (lift fun _ => MulAction.toEndHom)
theorem smul_def {i} (m : M i) (w : Word M) :
m • w = rcons { equivPair i w with head := m * (equivPair i w).head } :=
rfl
theorem of_smul_def (i) (w : Word M) (m : M i) :
of m • w = rcons { equivPair i w with head := m * (equivPair i w).head } :=
rfl
theorem equivPair_smul_same {i} (m : M i) (w : Word M) :
equivPair i (of m • w) = ⟨m * (equivPair i w).head, (equivPair i w).tail,
(equivPair i w).fstIdx_ne⟩ := by
rw [of_smul_def, ← equivPair_symm]
simp
@[simp]
theorem equivPair_tail {i} (p : Pair M i) :
equivPair i p.tail = ⟨1, p.tail, p.fstIdx_ne⟩ :=
equivPair_eq_of_fstIdx_ne _
theorem smul_eq_of_smul {i} (m : M i) (w : Word M) :
m • w = of m • w := rfl
theorem mem_smul_iff {i j : ι} {m₁ : M i} {m₂ : M j} {w : Word M} :
⟨_, m₁⟩ ∈ (of m₂ • w).toList ↔
(¬i = j ∧ ⟨i, m₁⟩ ∈ w.toList)
∨ (m₁ ≠ 1 ∧ ∃ (hij : i = j), (⟨i, m₁⟩ ∈ w.toList.tail) ∨
(∃ m', ⟨j, m'⟩ ∈ w.toList.head? ∧ m₁ = hij ▸ (m₂ * m')) ∨
(w.fstIdx ≠ some j ∧ m₁ = hij ▸ m₂)) := by
rw [of_smul_def, mem_rcons_iff, mem_equivPair_tail_iff, equivPair_head, or_assoc]
by_cases hij : i = j
· subst i
simp only [not_true, ne_eq, false_and, exists_prop, true_and, false_or]
by_cases hw : ⟨j, m₁⟩ ∈ w.toList.tail
· simp [hw, show m₁ ≠ 1 from w.ne_one _ (List.mem_of_mem_tail hw)]
· simp only [hw, false_or, Option.mem_def, and_congr_right_iff]
intro hm1
split_ifs with h
· rcases h with ⟨hnil, rfl⟩
simp only [List.head?_eq_head hnil, Option.some.injEq]
constructor
· rintro rfl
exact Or.inl ⟨_, rfl, rfl⟩
· rintro (⟨_, h, rfl⟩ | hm')
· simp only [Sigma.ext_iff, heq_eq_eq, true_and] at h
subst h
rfl
· simp only [fstIdx, Option.map_eq_some_iff, Sigma.exists,
exists_and_right, exists_eq_right, not_exists, ne_eq] at hm'
exact (hm'.1 (w.toList.head hnil).2 (by rw [List.head?_eq_head])).elim
· revert h
rw [fstIdx]
cases w.toList
· simp
· simp +contextual [Sigma.ext_iff]
· rcases w with ⟨_ | _, _, _⟩ <;>
simp [or_comm, hij, Ne.symm hij, eq_comm]
theorem mem_smul_iff_of_ne {i j : ι} (hij : i ≠ j) {m₁ : M i} {m₂ : M j} {w : Word M} :
⟨_, m₁⟩ ∈ (of m₂ • w).toList ↔ ⟨i, m₁⟩ ∈ w.toList := by
simp [mem_smul_iff, *]
theorem cons_eq_smul {i} {m : M i} {ls h1 h2} :
cons m ls h1 h2 = of m • ls := by
rw [of_smul_def, equivPair_eq_of_fstIdx_ne _]
· simp [cons, rcons, h2]
· exact h1
theorem rcons_eq_smul {i} (p : Pair M i) :
rcons p = of p.head • p.tail := by
simp [of_smul_def]
@[simp]
theorem equivPair_head_smul_equivPair_tail {i : ι} (w : Word M) :
of (equivPair i w).head • (equivPair i w).tail = w := by
rw [← rcons_eq_smul, ← equivPair_symm, Equiv.symm_apply_apply]
theorem equivPair_tail_eq_inv_smul {G : ι → Type*} [∀ i, Group (G i)]
[∀ i, DecidableEq (G i)] {i} (w : Word G) :
(equivPair i w).tail = (of (equivPair i w).head)⁻¹ • w :=
Eq.symm <| inv_smul_eq_iff.2 (equivPair_head_smul_equivPair_tail w).symm
@[elab_as_elim]
theorem smul_induction {motive : Word M → Prop} (empty : motive empty)
(smul : ∀ (i) (m : M i) (w), motive w → motive (of m • w)) (w : Word M) : motive w := by
induction w using consRecOn with
| empty => exact empty
| cons _ _ _ _ _ ih =>
rw [cons_eq_smul]
exact smul _ _ _ ih
@[simp]
theorem prod_smul (m) : ∀ w : Word M, prod (m • w) = m * prod w := by
induction m using CoprodI.induction_on with
| one =>
intro
rw [one_smul, one_mul]
| of _ =>
intros
rw [of_smul_def, prod_rcons, of.map_mul, mul_assoc, ← prod_rcons, ← equivPair_symm,
Equiv.symm_apply_apply]
| mul x y hx hy =>
intro w
rw [mul_smul, hx, hy, mul_assoc]
/-- Each element of the free product corresponds to a unique reduced word. -/
def equiv : CoprodI M ≃ Word M where
toFun m := m • empty
invFun w := prod w
left_inv m := by dsimp only; rw [prod_smul, prod_empty, mul_one]
right_inv := by
apply smul_induction
· dsimp only
rw [prod_empty, one_smul]
· dsimp only
intro i m w ih
rw [prod_smul, mul_smul, ih]
instance : DecidableEq (Word M) :=
Function.Injective.decidableEq fun _ _ => Word.ext
instance : DecidableEq (CoprodI M) :=
Equiv.decidableEq Word.equiv
end Word
variable (M) in
/-- A `NeWord M i j` is a representation of a non-empty reduced words where the first letter comes
from `M i` and the last letter comes from `M j`. It can be constructed from singletons and via
concatenation, and thus provides a useful induction principle. -/
inductive NeWord : ι → ι → Type _
| singleton : ∀ {i : ι} (x : M i), x ≠ 1 → NeWord i i
| append : ∀ {i j k l} (_w₁ : NeWord i j) (_hne : j ≠ k) (_w₂ : NeWord k l), NeWord i l
namespace NeWord
open Word
/-- The list represented by a given `NeWord` -/
@[simp]
def toList : ∀ {i j} (_w : NeWord M i j), List (Σ i, M i)
| i, _, singleton x _ => [⟨i, x⟩]
| _, _, append w₁ _ w₂ => w₁.toList ++ w₂.toList
theorem toList_ne_nil {i j} (w : NeWord M i j) : w.toList ≠ List.nil := by
induction w
· rintro ⟨rfl⟩
· apply List.append_ne_nil_of_left_ne_nil
assumption
/-- The first letter of a `NeWord` -/
@[simp]
def head : ∀ {i j} (_w : NeWord M i j), M i
| _, _, singleton x _ => x
| _, _, append w₁ _ _ => w₁.head
/-- The last letter of a `NeWord` -/
@[simp]
def last : ∀ {i j} (_w : NeWord M i j), M j
| _, _, singleton x _hne1 => x
| _, _, append _w₁ _hne w₂ => w₂.last
@[simp]
theorem toList_head? {i j} (w : NeWord M i j) : w.toList.head? = Option.some ⟨i, w.head⟩ := by
rw [← Option.mem_def]
induction w
· rw [Option.mem_def]
rfl
· exact List.mem_head?_append_of_mem_head? (by assumption)
@[simp]
theorem toList_getLast? {i j} (w : NeWord M i j) : w.toList.getLast? = Option.some ⟨j, w.last⟩ := by
rw [← Option.mem_def]
induction w
· rw [Option.mem_def]
rfl
· exact List.mem_getLast?_append_of_mem_getLast? (by assumption)
/-- The `Word M` represented by a `NeWord M i j` -/
def toWord {i j} (w : NeWord M i j) : Word M where
toList := w.toList
ne_one := by
induction w
· simpa only [toList, List.mem_singleton, ne_eq, forall_eq]
· intro l h
simp only [toList, List.mem_append] at h
cases h <;> aesop
chain_ne := by
induction w
· exact List.isChain_singleton _
· refine List.IsChain.append (by assumption) (by assumption) ?_
intro x hx y hy
rw [toList_getLast?, Option.mem_some_iff] at hx
rw [toList_head?, Option.mem_some_iff] at hy
subst hx
subst hy
assumption
/-- Every nonempty `Word M` can be constructed as a `NeWord M i j` -/
theorem of_word (w : Word M) (h : w ≠ empty) : ∃ (i j : _) (w' : NeWord M i j), w'.toWord = w := by
suffices ∃ (i j : _) (w' : NeWord M i j), w'.toWord.toList = w.toList by
rcases this with ⟨i, j, w, h⟩
refine ⟨i, j, w, ?_⟩
ext
rw [h]
obtain ⟨l, hnot1, hchain⟩ := w
induction l with
| nil => contradiction
| cons x l hi =>
rw [List.forall_mem_cons] at hnot1
rcases l with - | ⟨y, l⟩
· refine ⟨x.1, x.1, singleton x.2 hnot1.1, ?_⟩
simp [toWord]
· rw [List.isChain_cons_cons] at hchain
specialize hi hnot1.2 hchain.2 (by rintro ⟨rfl⟩)
obtain ⟨i, j, w', hw' : w'.toList = y::l⟩ := hi
obtain rfl : y = ⟨i, w'.head⟩ := by simpa [hw'] using w'.toList_head?
refine ⟨x.1, j, append (singleton x.2 hnot1.1) hchain.1 w', ?_⟩
simpa [toWord] using hw'
/-- A non-empty reduced word determines an element of the free product, given by multiplication. -/
def prod {i j} (w : NeWord M i j) :=
w.toWord.prod
@[simp]
theorem singleton_head {i} (x : M i) (hne_one : x ≠ 1) : (singleton x hne_one).head = x :=
rfl
@[simp]
theorem singleton_last {i} (x : M i) (hne_one : x ≠ 1) : (singleton x hne_one).last = x :=
rfl
@[simp]
theorem prod_singleton {i} (x : M i) (hne_one : x ≠ 1) : (singleton x hne_one).prod = of x := by
simp [toWord, prod, Word.prod]
@[simp]
theorem append_head {i j k l} {w₁ : NeWord M i j} {hne : j ≠ k} {w₂ : NeWord M k l} :
(append w₁ hne w₂).head = w₁.head :=
rfl
@[simp]
theorem append_last {i j k l} {w₁ : NeWord M i j} {hne : j ≠ k} {w₂ : NeWord M k l} :
(append w₁ hne w₂).last = w₂.last :=
rfl
@[simp]
theorem append_prod {i j k l} {w₁ : NeWord M i j} {hne : j ≠ k} {w₂ : NeWord M k l} :
(append w₁ hne w₂).prod = w₁.prod * w₂.prod := by simp [toWord, prod, Word.prod]
/-- One can replace the first letter in a non-empty reduced word by an element of the same
group -/
def replaceHead : ∀ {i j : ι} (x : M i) (_hnotone : x ≠ 1) (_w : NeWord M i j), NeWord M i j
| _, _, x, h, singleton _ _ => singleton x h
| _, _, x, h, append w₁ hne w₂ => append (replaceHead x h w₁) hne w₂
@[simp]
theorem replaceHead_head {i j : ι} (x : M i) (hnotone : x ≠ 1) (w : NeWord M i j) :
(replaceHead x hnotone w).head = x := by
induction w
· rfl
· simp [*, replaceHead]
/-- One can multiply an element from the left to a non-empty reduced word if it does not cancel
with the first element in the word. -/
def mulHead {i j : ι} (w : NeWord M i j) (x : M i) (hnotone : x * w.head ≠ 1) : NeWord M i j :=
replaceHead (x * w.head) hnotone w
@[simp]
theorem mulHead_head {i j : ι} (w : NeWord M i j) (x : M i) (hnotone : x * w.head ≠ 1) :
(mulHead w x hnotone).head = x * w.head := by
induction w
· rfl
· simp [*, mulHead]
@[simp]
theorem mulHead_prod {i j : ι} (w : NeWord M i j) (x : M i) (hnotone : x * w.head ≠ 1) :
(mulHead w x hnotone).prod = of x * w.prod := by
unfold mulHead
induction w with
| singleton => simp [replaceHead]
| append _ _ _ w_ih_w₁ w_ih_w₂ =>
specialize w_ih_w₁ _ hnotone
simp only [replaceHead, append_prod, ← mul_assoc]
congr 1
section Group
variable {G : ι → Type*} [∀ i, Group (G i)]
/-- The inverse of a non-empty reduced word -/
def inv : ∀ {i j} (_w : NeWord G i j), NeWord G j i
| _, _, singleton x h => singleton x⁻¹ (mt inv_eq_one.mp h)
| _, _, append w₁ h w₂ => append w₂.inv h.symm w₁.inv
@[simp]
theorem inv_prod {i j} (w : NeWord G i j) : w.inv.prod = w.prod⁻¹ := by
induction w <;> simp [inv, *]
@[simp]
theorem inv_head {i j} (w : NeWord G i j) : w.inv.head = w.last⁻¹ := by
induction w <;> simp [inv, *]
@[simp]
theorem inv_last {i j} (w : NeWord G i j) : w.inv.last = w.head⁻¹ := by
induction w <;> simp [inv, *]
end Group
end NeWord
section PingPongLemma
open Pointwise
open Cardinal
open scoped Function -- required for scoped `on` notation
variable {G : Type*} [Group G]
variable {H : ι → Type*} [∀ i, Group (H i)]
variable (f : ∀ i, H i →* G)
-- We need many groups or one group with many elements
variable (hcard : 3 ≤ #ι ∨ ∃ i, 3 ≤ #(H i))
-- A group action on α, and the ping-pong sets
variable {α : Type*} [MulAction G α]
variable (X : ι → Set α)
variable (hXnonempty : ∀ i, (X i).Nonempty)
variable (hXdisj : Pairwise (Disjoint on X))
variable (hpp : Pairwise fun i j => ∀ h : H i, h ≠ 1 → f i h • X j ⊆ X i)
include hpp
theorem lift_word_ping_pong {i j k} (w : NeWord H i j) (hk : j ≠ k) :
lift f w.prod • X k ⊆ X i := by
induction w generalizing k with
| singleton x hne_one => simpa using hpp hk _ hne_one
| @append i j k l w₁ hne w₂ hIw₁ hIw₂ =>
calc
lift f (NeWord.append w₁ hne w₂).prod • X k = lift f w₁.prod • lift f w₂.prod • X k := by
simp [MulAction.mul_smul]
_ ⊆ lift f w₁.prod • X _ := smul_set_subset_smul_set_iff.mpr (hIw₂ hk)
_ ⊆ X i := hIw₁ hne
include hXnonempty hXdisj
theorem lift_word_prod_nontrivial_of_other_i {i j k} (w : NeWord H i j) (hhead : k ≠ i)
(hlast : k ≠ j) : lift f w.prod ≠ 1 := by
intro heq1
have : X k ⊆ X i := by simpa [heq1] using lift_word_ping_pong f X hpp w hlast.symm
obtain ⟨x, hx⟩ := hXnonempty k
exact (hXdisj hhead).le_bot ⟨hx, this hx⟩
variable [Nontrivial ι]
theorem lift_word_prod_nontrivial_of_head_eq_last {i} (w : NeWord H i i) :
lift f w.prod ≠ 1 := by
obtain ⟨k, hk⟩ := exists_ne i
exact lift_word_prod_nontrivial_of_other_i f X hXnonempty hXdisj hpp w hk hk
theorem lift_word_prod_nontrivial_of_head_card {i j} (w : NeWord H i j)
(hcard : 3 ≤ #(H i)) (hheadtail : i ≠ j) : lift f w.prod ≠ 1 := by
obtain ⟨h, hn1, hnh⟩ := Cardinal.three_le hcard 1 w.head⁻¹
have hnot1 : h * w.head ≠ 1 := by
rw [← div_inv_eq_mul]
exact div_ne_one_of_ne hnh
let w' : NeWord H i i :=
NeWord.append (NeWord.mulHead w h hnot1) hheadtail.symm
(NeWord.singleton h⁻¹ (inv_ne_one.mpr hn1))
have hw' : lift f w'.prod ≠ 1 :=
lift_word_prod_nontrivial_of_head_eq_last f X hXnonempty hXdisj hpp w'
intro heq1
apply hw'
simp [w', heq1]
include hcard in
theorem lift_word_prod_nontrivial_of_not_empty {i j} (w : NeWord H i j) :
lift f w.prod ≠ 1 := by
classical
rcases hcard with hcard | hcard
· obtain ⟨i, h1, h2⟩ := Cardinal.three_le hcard i j
exact lift_word_prod_nontrivial_of_other_i f X hXnonempty hXdisj hpp w h1 h2
· obtain ⟨k, hcard⟩ := hcard
by_cases hh : i = k <;> by_cases hl : j = k
· subst hh
subst hl
exact lift_word_prod_nontrivial_of_head_eq_last f X hXnonempty hXdisj hpp w
· subst hh
change j ≠ i at hl
exact lift_word_prod_nontrivial_of_head_card f X hXnonempty hXdisj hpp w hcard hl.symm
· subst hl
change i ≠ j at hh
have : lift f w.inv.prod ≠ 1 :=
lift_word_prod_nontrivial_of_head_card f X hXnonempty hXdisj hpp w.inv hcard hh.symm
intro heq
apply this
simpa using heq
· change i ≠ k at hh
change j ≠ k at hl
exact lift_word_prod_nontrivial_of_other_i f X hXnonempty hXdisj hpp w hh.symm hl.symm
include hcard in
theorem empty_of_word_prod_eq_one {w : Word H} (h : lift f w.prod = 1) :
w = Word.empty := by
by_contra hnotempty
obtain ⟨i, j, w, rfl⟩ := NeWord.of_word w hnotempty
exact lift_word_prod_nontrivial_of_not_empty f hcard X hXnonempty hXdisj hpp w h
include hcard in
/-- The **Ping-Pong-Lemma**.
Given a group action of `G` on `X` so that the `H i` acts in a specific way on disjoint subsets
`X i` we can prove that `lift f` is injective, and thus the image of `lift f` is isomorphic to the
free product of the `H i`.
Often the Ping-Pong-Lemma is stated with regard to subgroups `H i` that generate the whole group;
we generalize to arbitrary group homomorphisms `f i : H i →* G` and do not require the group to be
generated by the images.
Usually the Ping-Pong-Lemma requires that one group `H i` has at least three elements. This
condition is only needed if `# ι = 2`, and we accept `3 ≤ # ι` as an alternative.
-/
theorem lift_injective_of_ping_pong : Function.Injective (lift f) := by
classical
apply (injective_iff_map_eq_one (lift f)).mpr
rw [(CoprodI.Word.equiv).forall_congr_left]
intro w Heq
dsimp [Word.equiv] at *
rw [empty_of_word_prod_eq_one f hcard X hXnonempty hXdisj hpp Heq, Word.prod_empty]
end PingPongLemma
/-- Given a family of free groups with distinguished bases, then their free product is free, with
a basis given by the union of the bases of the components. -/
def FreeGroupBasis.coprodI {ι : Type*} {X : ι → Type*} {G : ι → Type*} [∀ i, Group (G i)]
(B : ∀ i, FreeGroupBasis (X i) (G i)) :
FreeGroupBasis (Σ i, X i) (CoprodI G) :=
⟨MulEquiv.symm <| MonoidHom.toMulEquiv
(FreeGroup.lift fun x : Σ i, X i => CoprodI.of (B x.1 x.2))
(CoprodI.lift fun i : ι => (B i).lift fun x : X i =>
FreeGroup.of (⟨i, x⟩ : Σ i, X i))
(by ext; simp)
(by ext1 i; apply (B i).ext_hom; simp)⟩
/-- The free product of free groups is itself a free group. -/
instance {ι : Type*} (G : ι → Type*) [∀ i, Group (G i)] [∀ i, IsFreeGroup (G i)] :
IsFreeGroup (CoprodI G) :=
(FreeGroupBasis.coprodI (fun i ↦ IsFreeGroup.basis (G i))).isFreeGroup
-- NB: One might expect this theorem to be phrased with ℤ, but ℤ is an additive group,
-- and using `Multiplicative ℤ` runs into diamond issues.
/-- A free group is a free product of copies of the free_group over one generator. -/
@[simps!]
def _root_.freeGroupEquivCoprodI {ι : Type u_1} :
FreeGroup ι ≃* CoprodI fun _ : ι => FreeGroup Unit := by
refine MonoidHom.toMulEquiv ?_ ?_ ?_ ?_
· exact FreeGroup.lift fun i => @CoprodI.of ι _ _ i (FreeGroup.of Unit.unit)
· exact CoprodI.lift fun i => FreeGroup.lift fun _ => FreeGroup.of i
· ext; simp
· ext i a; cases a; simp
section PingPongLemma
open Pointwise Cardinal
open scoped Function -- required for scoped `on` notation
variable [Nontrivial ι]
variable {G : Type u_1} [Group G] (a : ι → G)
-- A group action on α, and the ping-pong sets
variable {α : Type*} [MulAction G α]
variable (X Y : ι → Set α)
variable (hXnonempty : ∀ i, (X i).Nonempty)
variable (hXdisj : Pairwise (Disjoint on X))
variable (hYdisj : Pairwise (Disjoint on Y))
variable (hXYdisj : ∀ i j, Disjoint (X i) (Y j))
variable (hX : ∀ i, a i • (Y i)ᶜ ⊆ X i)
variable (hY : ∀ i, a⁻¹ i • (X i)ᶜ ⊆ Y i)
include hXnonempty hXdisj hYdisj hXYdisj hX hY in
/-- The Ping-Pong-Lemma.
Given a group action of `G` on `X` so that the generators of the free groups act in specific
ways on disjoint subsets `X i` and `Y i` we can prove that `lift f` is injective, and thus the image
of `lift f` is isomorphic to the free group.
Often the Ping-Pong-Lemma is stated with regard to group elements that generate the whole group;
we generalize to arbitrary group homomorphisms from the free group to `G` and do not require the
group to be generated by the elements.
-/
theorem _root_.FreeGroup.injective_lift_of_ping_pong : Function.Injective (FreeGroup.lift a) := by
-- Step one: express the free group lift via the free product lift
have : FreeGroup.lift a =
(CoprodI.lift fun i => FreeGroup.lift fun _ => a i).comp
(@freeGroupEquivCoprodI ι).toMonoidHom := by
ext i
simp
rw [this, MonoidHom.coe_comp]
clear this
refine Function.Injective.comp ?_ (MulEquiv.injective freeGroupEquivCoprodI)
-- Step two: Invoke the ping-pong lemma for free products
change Function.Injective (lift fun i : ι => FreeGroup.lift fun _ => a i)
-- Prepare to instantiate lift_injective_of_ping_pong
let H : ι → Type _ := fun _i => FreeGroup Unit
let f : ∀ i, H i →* G := fun i => FreeGroup.lift fun _ => a i
let X' : ι → Set α := fun i => X i ∪ Y i
apply lift_injective_of_ping_pong f _ X'
· show ∀ i, (X' i).Nonempty
exact fun i => Set.Nonempty.inl (hXnonempty i)
· show Pairwise (Disjoint on X')
intro i j hij
simp only [X']
apply Disjoint.union_left <;> apply Disjoint.union_right
· exact hXdisj hij
· exact hXYdisj i j
· exact (hXYdisj j i).symm
· exact hYdisj hij
· change Pairwise fun i j => ∀ h : H i, h ≠ 1 → f i h • X' j ⊆ X' i
rintro i j hij
-- use free_group unit ≃ ℤ
refine FreeGroup.freeGroupUnitEquivInt.forall_congr_left.mpr ?_
intro n hne1
change FreeGroup.lift (fun _ => a i) (FreeGroup.of () ^ n) • X' j ⊆ X' i
simp only [map_zpow, FreeGroup.lift_apply_of]
change a i ^ n • X' j ⊆ X' i
have hnne0 : n ≠ 0 := by
rintro rfl
apply hne1
simp [H, FreeGroup.freeGroupUnitEquivInt]
clear hne1
simp only [X']
-- Positive and negative powers separately
rcases (lt_or_gt_of_ne hnne0).symm with hlt | hgt
· have h1n : 1 ≤ n := hlt
calc
a i ^ n • X' j ⊆ a i ^ n • (Y i)ᶜ :=
smul_set_mono ((hXYdisj j i).union_left <| hYdisj hij.symm).subset_compl_right
_ ⊆ X i := by
clear hnne0 hlt
induction n, h1n using Int.le_induction with
| base => rw [zpow_one]; exact hX i
| succ n _hle hi =>
calc
a i ^ (n + 1) • (Y i)ᶜ = (a i ^ n * a i) • (Y i)ᶜ := by rw [zpow_add, zpow_one]
_ = a i ^ n • a i • (Y i)ᶜ := MulAction.mul_smul _ _ _
_ ⊆ a i ^ n • X i := smul_set_mono <| hX i
_ ⊆ a i ^ n • (Y i)ᶜ := smul_set_mono (hXYdisj i i).subset_compl_right
_ ⊆ X i := hi
_ ⊆ X' i := Set.subset_union_left
· have h1n : n ≤ -1 := by
apply Int.le_of_lt_add_one
simpa using hgt
calc
a i ^ n • X' j ⊆ a i ^ n • (X i)ᶜ :=
smul_set_mono ((hXdisj hij.symm).union_left (hXYdisj i j).symm).subset_compl_right
_ ⊆ Y i := by
clear hnne0 hgt
induction n, h1n using Int.le_induction_down with
| base => rw [zpow_neg, zpow_one]; exact hY i
| pred n hle hi =>
calc
a i ^ (n - 1) • (X i)ᶜ = (a i ^ n * (a i)⁻¹) • (X i)ᶜ := by rw [zpow_sub, zpow_one]
_ = a i ^ n • (a i)⁻¹ • (X i)ᶜ := MulAction.mul_smul _ _ _
_ ⊆ a i ^ n • Y i := smul_set_mono <| hY i
_ ⊆ a i ^ n • (X i)ᶜ := smul_set_mono (hXYdisj i i).symm.subset_compl_right
_ ⊆ Y i := hi
_ ⊆ X' i := Set.subset_union_right
show _ ∨ ∃ i, 3 ≤ #(H i)
inhabit ι
right
use Inhabited.default
simp only [H]
rw [FreeGroup.freeGroupUnitEquivInt.cardinal_eq, Cardinal.mk_denumerable]
apply le_of_lt
exact nat_lt_aleph0 3
end PingPongLemma
end Monoid.CoprodI |
.lake/packages/mathlib/Mathlib/GroupTheory/Nilpotent.lean | import Mathlib.GroupTheory.Solvable
import Mathlib.GroupTheory.Sylow
import Mathlib.Algebra.Group.Subgroup.Order
import Mathlib.GroupTheory.Commutator.Finite
/-!
# Nilpotent groups
An API for nilpotent groups, that is, groups for which the upper central series
reaches `⊤`.
## Main definitions
Recall that if `H K : Subgroup G` then `⁅H, K⁆ : Subgroup G` is the subgroup of `G` generated
by the commutators `hkh⁻¹k⁻¹`. Recall also Lean's conventions that `⊤` denotes the
subgroup `G` of `G`, and `⊥` denotes the trivial subgroup `{1}`.
* `upperCentralSeries G : ℕ → Subgroup G` : the upper central series of a group `G`.
This is an increasing sequence of normal subgroups `H n` of `G` with `H 0 = ⊥` and
`H (n + 1) / H n` is the centre of `G / H n`.
* `lowerCentralSeries G : ℕ → Subgroup G` : the lower central series of a group `G`.
This is a decreasing sequence of normal subgroups `H n` of `G` with `H 0 = ⊤` and
`H (n + 1) = ⁅H n, G⁆`.
* `IsNilpotent` : A group G is nilpotent if its upper central series reaches `⊤`, or
equivalently if its lower central series reaches `⊥`.
* `Group.nilpotencyClass` : the length of the upper central series of a nilpotent group.
* `IsAscendingCentralSeries (H : ℕ → Subgroup G) : Prop` and
* `IsDescendingCentralSeries (H : ℕ → Subgroup G) : Prop` : Note that in the literature
a "central series" for a group is usually defined to be a *finite* sequence of normal subgroups
`H 0`, `H 1`, ..., starting at `⊤`, finishing at `⊥`, and with each `H n / H (n + 1)`
central in `G / H (n + 1)`. In this formalisation it is convenient to have two weaker predicates
on an infinite sequence of subgroups `H n` of `G`: we say a sequence is a *descending central
series* if it starts at `G` and `⁅H n, ⊤⁆ ⊆ H (n + 1)` for all `n`. Note that this series
may not terminate at `⊥`, and the `H i` need not be normal. Similarly a sequence is an
*ascending central series* if `H 0 = ⊥` and `⁅H (n + 1), ⊤⁆ ⊆ H n` for all `n`, again with no
requirement that the series reaches `⊤` or that the `H i` are normal.
## Main theorems
`G` is *defined* to be nilpotent if the upper central series reaches `⊤`.
* `nilpotent_iff_finite_ascending_central_series` : `G` is nilpotent iff some ascending central
series reaches `⊤`.
* `nilpotent_iff_finite_descending_central_series` : `G` is nilpotent iff some descending central
series reaches `⊥`.
* `nilpotent_iff_lower` : `G` is nilpotent iff the lower central series reaches `⊥`.
* The `Group.nilpotencyClass` can likewise be obtained from these equivalent
definitions, see `least_ascending_central_series_length_eq_nilpotencyClass`,
`least_descending_central_series_length_eq_nilpotencyClass` and
`lowerCentralSeries_length_eq_nilpotencyClass`.
* If `G` is nilpotent, then so are its subgroups, images, quotients and preimages.
Binary and finite products of nilpotent groups are nilpotent.
Infinite products are nilpotent if their nilpotent class is bounded.
Corresponding lemmas about the `Group.nilpotencyClass` are provided.
* The `Group.nilpotencyClass` of `G ⧸ center G` is given explicitly, and an induction principle
is derived from that.
* `IsNilpotent.to_isSolvable`: If `G` is nilpotent, it is solvable.
## Warning
A "central series" is usually defined to be a finite sequence of normal subgroups going
from `⊥` to `⊤` with the property that each subquotient is contained within the centre of
the associated quotient of `G`. This means that if `G` is not nilpotent, then
none of what we have called `upperCentralSeries G`, `lowerCentralSeries G` or
the sequences satisfying `IsAscendingCentralSeries` or `IsDescendingCentralSeries`
are actually central series. Note that the fact that the upper and lower central series
are not central series if `G` is not nilpotent is a standard abuse of notation.
-/
open Subgroup
section WithGroup
variable {G : Type*} [Group G] (H : Subgroup G) [Normal H]
/-- If `H` is a normal subgroup of `G`, then the set `{x : G | ∀ y : G, x*y*x⁻¹*y⁻¹ ∈ H}`
is a subgroup of `G` (because it is the preimage in `G` of the centre of the
quotient group `G/H`.)
-/
def upperCentralSeriesStep : Subgroup G where
carrier := { x : G | ∀ y : G, x * y * x⁻¹ * y⁻¹ ∈ H }
one_mem' y := by simp
mul_mem' {a b} ha hb y := by
convert Subgroup.mul_mem _ (ha (b * y * b⁻¹)) (hb y) using 1
group
inv_mem' {x} hx y := by
specialize hx y⁻¹
rw [mul_assoc, inv_inv] at hx ⊢
exact Subgroup.Normal.mem_comm inferInstance hx
theorem mem_upperCentralSeriesStep (x : G) :
x ∈ upperCentralSeriesStep H ↔ ∀ y, x * y * x⁻¹ * y⁻¹ ∈ H := Iff.rfl
open QuotientGroup
/-- The proof that `upperCentralSeriesStep H` is the preimage of the centre of `G/H` under
the canonical surjection. -/
theorem upperCentralSeriesStep_eq_comap_center :
upperCentralSeriesStep H = Subgroup.comap (mk' H) (center (G ⧸ H)) := by
ext
rw [mem_comap, mem_center_iff, forall_mk]
apply forall_congr'
intro y
rw [coe_mk', ← QuotientGroup.mk_mul, ← QuotientGroup.mk_mul, eq_comm, eq_iff_div_mem,
div_eq_mul_inv, mul_inv_rev, mul_assoc]
instance : Normal (upperCentralSeriesStep H) := by
rw [upperCentralSeriesStep_eq_comap_center]
infer_instance
variable (G)
/-- An auxiliary type-theoretic definition defining both the upper central series of
a group, and a proof that it is normal, all in one go. -/
def upperCentralSeriesAux : ℕ → Σ' H : Subgroup G, Normal H
| 0 => ⟨⊥, inferInstance⟩
| n + 1 =>
let un := upperCentralSeriesAux n
let _un_normal := un.2
⟨upperCentralSeriesStep un.1, inferInstance⟩
/-- `upperCentralSeries G n` is the `n`th term in the upper central series of `G`.
This is the increasing chain of subgroups of `G` that starts with the trivial subgroup `⊥` of `G`
and then continues defining `upperCentralSeries G (n + 1)` to be all the elements of `G`
that, modulo `upperCentralSeries G n`, belong to the center of the quotient
`G ⧸ upperCentralSeries G n`.
In particular, the identities
* `upperCentralSeries G 0 = ⊥` (`upperCentralSeries_zero`);
* `upperCentralSeries G 1 = center G` (`upperCentralSeries_one`);
hold.
-/
def upperCentralSeries (n : ℕ) : Subgroup G :=
(upperCentralSeriesAux G n).1
instance upperCentralSeries_normal (n : ℕ) : Normal (upperCentralSeries G n) :=
(upperCentralSeriesAux G n).2
@[simp]
theorem upperCentralSeries_zero : upperCentralSeries G 0 = ⊥ := rfl
@[simp]
theorem upperCentralSeries_one : upperCentralSeries G 1 = center G := by
ext
simp only [upperCentralSeries, upperCentralSeriesAux, upperCentralSeriesStep, mem_bot, mem_mk,
Submonoid.mem_mk, Subsemigroup.mem_mk, Set.mem_setOf_eq, mem_center_iff]
exact forall_congr' fun y => by rw [mul_inv_eq_one, mul_inv_eq_iff_eq_mul, eq_comm]
variable {G}
/-- The `n+1`st term of the upper central series `H i` has underlying set equal to the `x` such
that `⁅x,G⁆ ⊆ H n`. -/
theorem mem_upperCentralSeries_succ_iff {n : ℕ} {x : G} :
x ∈ upperCentralSeries G (n + 1) ↔ ∀ y : G, x * y * x⁻¹ * y⁻¹ ∈ upperCentralSeries G n :=
Iff.rfl
@[simp] lemma comap_upperCentralSeries {H : Type*} [Group H] (e : H ≃* G) :
∀ n, (upperCentralSeries G n).comap e = upperCentralSeries H n
| 0 => by simpa [MonoidHom.ker_eq_bot_iff] using e.injective
| n + 1 => by
ext
simp [mem_upperCentralSeries_succ_iff, ← comap_upperCentralSeries e n,
← e.toEquiv.forall_congr_right]
namespace Group
variable (G) in
-- `IsNilpotent` is already defined in the root namespace (for elements of rings).
-- TODO: Rename it to `IsNilpotentElement`?
/-- A group `G` is nilpotent if its upper central series is eventually `G`. -/
@[mk_iff]
class IsNilpotent (G : Type*) [Group G] : Prop where
nilpotent' : ∃ n : ℕ, upperCentralSeries G n = ⊤
lemma IsNilpotent.nilpotent (G : Type*) [Group G] [IsNilpotent G] :
∃ n : ℕ, upperCentralSeries G n = ⊤ := Group.IsNilpotent.nilpotent'
lemma isNilpotent_congr {H : Type*} [Group H] (e : G ≃* H) : IsNilpotent G ↔ IsNilpotent H := by
simp_rw [isNilpotent_iff]
refine exists_congr fun n ↦ ⟨fun h ↦ ?_, fun h ↦ ?_⟩
· simp [← Subgroup.comap_top e.symm.toMonoidHom, ← h]
· simp [← Subgroup.comap_top e.toMonoidHom, ← h]
@[simp] lemma isNilpotent_top : IsNilpotent (⊤ : Subgroup G) ↔ IsNilpotent G :=
isNilpotent_congr Subgroup.topEquiv
variable (G) in
/-- A group `G` is virtually nilpotent if it has a nilpotent cofinite subgroup `N`. -/
def IsVirtuallyNilpotent : Prop := ∃ N : Subgroup G, IsNilpotent N ∧ FiniteIndex N
lemma IsNilpotent.isVirtuallyNilpotent (hG : IsNilpotent G) : IsVirtuallyNilpotent G :=
⟨⊤, by simpa, inferInstance⟩
end Group
open Group
/-- A sequence of subgroups of `G` is an ascending central series if `H 0` is trivial and
`⁅H (n + 1), G⁆ ⊆ H n` for all `n`. Note that we do not require that `H n = G` for some `n`. -/
def IsAscendingCentralSeries (H : ℕ → Subgroup G) : Prop :=
H 0 = ⊥ ∧ ∀ (x : G) (n : ℕ), x ∈ H (n + 1) → ∀ g, x * g * x⁻¹ * g⁻¹ ∈ H n
/-- A sequence of subgroups of `G` is a descending central series if `H 0` is `G` and
`⁅H n, G⁆ ⊆ H (n + 1)` for all `n`. Note that we do not require that `H n = {1}` for some `n`. -/
def IsDescendingCentralSeries (H : ℕ → Subgroup G) :=
H 0 = ⊤ ∧ ∀ (x : G) (n : ℕ), x ∈ H n → ∀ g, x * g * x⁻¹ * g⁻¹ ∈ H (n + 1)
/-- Any ascending central series for a group is bounded above by the upper central series. -/
theorem ascending_central_series_le_upper (H : ℕ → Subgroup G) (hH : IsAscendingCentralSeries H) :
∀ n : ℕ, H n ≤ upperCentralSeries G n
| 0 => hH.1.symm ▸ le_refl ⊥
| n + 1 => by
intro x hx
rw [mem_upperCentralSeries_succ_iff]
exact fun y => ascending_central_series_le_upper H hH n (hH.2 x n hx y)
variable (G)
/-- The upper central series of a group is an ascending central series. -/
theorem upperCentralSeries_isAscendingCentralSeries :
IsAscendingCentralSeries (upperCentralSeries G) :=
⟨rfl, fun _x _n h => h⟩
theorem upperCentralSeries_mono : Monotone (upperCentralSeries G) := by
refine monotone_nat_of_le_succ ?_
intro n x hx y
rw [mul_assoc, mul_assoc, ← mul_assoc y x⁻¹ y⁻¹]
exact mul_mem hx (Normal.conj_mem (upperCentralSeries_normal G n) x⁻¹ (inv_mem hx) y)
/-- A group `G` is nilpotent iff there exists an ascending central series which reaches `G` in
finitely many steps. -/
theorem nilpotent_iff_finite_ascending_central_series :
IsNilpotent G ↔ ∃ n : ℕ, ∃ H : ℕ → Subgroup G, IsAscendingCentralSeries H ∧ H n = ⊤ := by
constructor
· rintro ⟨n, nH⟩
exact ⟨_, _, upperCentralSeries_isAscendingCentralSeries G, nH⟩
· rintro ⟨n, H, hH, hn⟩
use n
rw [eq_top_iff, ← hn]
exact ascending_central_series_le_upper H hH n
theorem is_descending_rev_series_of_is_ascending {H : ℕ → Subgroup G} {n : ℕ} (hn : H n = ⊤)
(hasc : IsAscendingCentralSeries H) : IsDescendingCentralSeries fun m : ℕ => H (n - m) := by
obtain ⟨h0, hH⟩ := hasc
refine ⟨hn, fun x m hx g => ?_⟩
dsimp at hx
by_cases! hm : n ≤ m
· rw [tsub_eq_zero_of_le hm, h0, Subgroup.mem_bot] at hx
subst hx
rw [show (1 : G) * g * (1⁻¹ : G) * g⁻¹ = 1 by group]
exact Subgroup.one_mem _
· apply hH
convert hx using 1
rw [tsub_add_eq_add_tsub (Nat.succ_le_of_lt hm), Nat.succ_eq_add_one, Nat.add_sub_add_right]
theorem is_ascending_rev_series_of_is_descending {H : ℕ → Subgroup G} {n : ℕ} (hn : H n = ⊥)
(hdesc : IsDescendingCentralSeries H) : IsAscendingCentralSeries fun m : ℕ => H (n - m) := by
obtain ⟨h0, hH⟩ := hdesc
refine ⟨hn, fun x m hx g => ?_⟩
dsimp only at hx ⊢
by_cases! hm : n ≤ m
· have hnm : n - m = 0 := tsub_eq_zero_iff_le.mpr hm
rw [hnm, h0]
exact mem_top _
· convert hH x _ hx g using 1
rw [tsub_add_eq_add_tsub (Nat.succ_le_of_lt hm), Nat.succ_eq_add_one, Nat.add_sub_add_right]
/-- A group `G` is nilpotent iff there exists a descending central series which reaches the
trivial group in a finite time. -/
theorem nilpotent_iff_finite_descending_central_series :
IsNilpotent G ↔ ∃ n : ℕ, ∃ H : ℕ → Subgroup G, IsDescendingCentralSeries H ∧ H n = ⊥ := by
rw [nilpotent_iff_finite_ascending_central_series]
constructor
· rintro ⟨n, H, hH, hn⟩
refine ⟨n, fun m => H (n - m), is_descending_rev_series_of_is_ascending G hn hH, ?_⟩
dsimp only
rw [tsub_self]
exact hH.1
· rintro ⟨n, H, hH, hn⟩
refine ⟨n, fun m => H (n - m), is_ascending_rev_series_of_is_descending G hn hH, ?_⟩
dsimp only
rw [tsub_self]
exact hH.1
/-- The lower central series of a group `G` is a sequence `H n` of subgroups of `G`, defined
by `H 0` is all of `G` and for `n≥1`, `H (n + 1) = ⁅H n, G⁆` -/
def lowerCentralSeries (G : Type*) [Group G] : ℕ → Subgroup G
| 0 => ⊤
| n + 1 => ⁅lowerCentralSeries G n, ⊤⁆
variable {G}
@[simp]
theorem lowerCentralSeries_zero : lowerCentralSeries G 0 = ⊤ := rfl
@[simp]
theorem lowerCentralSeries_one : lowerCentralSeries G 1 = commutator G := rfl
theorem mem_lowerCentralSeries_succ_iff (n : ℕ) (q : G) :
q ∈ lowerCentralSeries G (n + 1) ↔
q ∈ closure { x | ∃ p ∈ lowerCentralSeries G n,
∃ q ∈ (⊤ : Subgroup G), p * q * p⁻¹ * q⁻¹ = x } := Iff.rfl
theorem lowerCentralSeries_succ (n : ℕ) :
lowerCentralSeries G (n + 1) =
closure { x | ∃ p ∈ lowerCentralSeries G n, ∃ q ∈ (⊤ : Subgroup G), p * q * p⁻¹ * q⁻¹ = x } :=
rfl
instance lowerCentralSeries_normal (n : ℕ) : Normal (lowerCentralSeries G n) := by
induction n with
| zero => exact (⊤ : Subgroup G).normal_of_characteristic
| succ d hd => exact @Subgroup.commutator_normal _ _ (lowerCentralSeries G d) ⊤ hd _
theorem lowerCentralSeries_antitone : Antitone (lowerCentralSeries G) := by
refine antitone_nat_of_succ_le fun n x hx => ?_
simp only [mem_lowerCentralSeries_succ_iff, mem_top,
true_and] at hx
refine
closure_induction ?_ (Subgroup.one_mem _) (fun _ _ _ _ ↦ mul_mem) (fun _ _ ↦ inv_mem) hx
rintro y ⟨z, hz, a, ha⟩
rw [← ha, mul_assoc, mul_assoc, ← mul_assoc a z⁻¹ a⁻¹]
exact mul_mem hz (Normal.conj_mem (lowerCentralSeries_normal n) z⁻¹ (inv_mem hz) a)
/-- The lower central series of a group is a descending central series. -/
theorem lowerCentralSeries_isDescendingCentralSeries :
IsDescendingCentralSeries (lowerCentralSeries G) := by
constructor
· rfl
intro x n hxn g
exact commutator_mem_commutator hxn (mem_top g)
/-- Any descending central series for a group is bounded below by the lower central series. -/
theorem descending_central_series_ge_lower (H : ℕ → Subgroup G) (hH : IsDescendingCentralSeries H) :
∀ n : ℕ, lowerCentralSeries G n ≤ H n
| 0 => hH.1.symm ▸ le_refl ⊤
| n + 1 => commutator_le.mpr fun x hx q _ =>
hH.2 x n (descending_central_series_ge_lower H hH n hx) q
/-- A group is nilpotent if and only if its lower central series eventually reaches
the trivial subgroup. -/
theorem nilpotent_iff_lowerCentralSeries : IsNilpotent G ↔ ∃ n, lowerCentralSeries G n = ⊥ := by
rw [nilpotent_iff_finite_descending_central_series]
constructor
· rintro ⟨n, H, ⟨h0, hs⟩, hn⟩
use n
rw [eq_bot_iff, ← hn]
exact descending_central_series_ge_lower H ⟨h0, hs⟩ n
· rintro ⟨n, hn⟩
exact ⟨n, lowerCentralSeries G, lowerCentralSeries_isDescendingCentralSeries, hn⟩
section Classical
variable [hG : IsNilpotent G]
variable (G) in
open scoped Classical in
/-- The nilpotency class of a nilpotent group is the smallest natural `n` such that
the `n`-th term of the upper central series is `G`. -/
noncomputable def Group.nilpotencyClass : ℕ := Nat.find (IsNilpotent.nilpotent G)
open scoped Classical in
@[simp]
theorem upperCentralSeries_nilpotencyClass : upperCentralSeries G (Group.nilpotencyClass G) = ⊤ :=
Nat.find_spec (IsNilpotent.nilpotent G)
theorem upperCentralSeries_eq_top_iff_nilpotencyClass_le {n : ℕ} :
upperCentralSeries G n = ⊤ ↔ Group.nilpotencyClass G ≤ n := by
classical
constructor
· intro h
exact Nat.find_le h
· intro h
rw [eq_top_iff, ← upperCentralSeries_nilpotencyClass]
exact upperCentralSeries_mono _ h
open scoped Classical in
/-- The nilpotency class of a nilpotent `G` is equal to the smallest `n` for which an ascending
central series reaches `G` in its `n`-th term. -/
theorem least_ascending_central_series_length_eq_nilpotencyClass :
Nat.find ((nilpotent_iff_finite_ascending_central_series G).mp hG) =
Group.nilpotencyClass G := by
refine le_antisymm (Nat.find_mono ?_) (Nat.find_mono ?_)
· intro n hn
exact ⟨upperCentralSeries G, upperCentralSeries_isAscendingCentralSeries G, hn⟩
· rintro n ⟨H, ⟨hH, hn⟩⟩
rw [← top_le_iff, ← hn]
exact ascending_central_series_le_upper H hH n
open scoped Classical in
/-- The nilpotency class of a nilpotent `G` is equal to the smallest `n` for which the descending
central series reaches `⊥` in its `n`-th term. -/
theorem least_descending_central_series_length_eq_nilpotencyClass :
Nat.find ((nilpotent_iff_finite_descending_central_series G).mp hG) =
Group.nilpotencyClass G := by
rw [← least_ascending_central_series_length_eq_nilpotencyClass]
refine le_antisymm (Nat.find_mono ?_) (Nat.find_mono ?_)
· rintro n ⟨H, ⟨hH, hn⟩⟩
refine ⟨fun m => H (n - m), is_descending_rev_series_of_is_ascending G hn hH, ?_⟩
dsimp only
rw [tsub_self]
exact hH.1
· rintro n ⟨H, ⟨hH, hn⟩⟩
refine ⟨fun m => H (n - m), is_ascending_rev_series_of_is_descending G hn hH, ?_⟩
dsimp only
rw [tsub_self]
exact hH.1
open scoped Classical in
/-- The nilpotency class of a nilpotent `G` is equal to the length of the lower central series. -/
theorem lowerCentralSeries_length_eq_nilpotencyClass :
Nat.find (nilpotent_iff_lowerCentralSeries.mp hG) = Group.nilpotencyClass (G := G) := by
rw [← least_descending_central_series_length_eq_nilpotencyClass]
refine le_antisymm (Nat.find_mono ?_) (Nat.find_mono ?_)
· rintro n ⟨H, ⟨hH, hn⟩⟩
rw [← le_bot_iff, ← hn]
exact descending_central_series_ge_lower H hH n
· rintro n h
exact ⟨lowerCentralSeries G, ⟨lowerCentralSeries_isDescendingCentralSeries, h⟩⟩
@[simp]
theorem lowerCentralSeries_nilpotencyClass :
lowerCentralSeries G (Group.nilpotencyClass G) = ⊥ := by
classical
rw [← lowerCentralSeries_length_eq_nilpotencyClass]
exact Nat.find_spec (nilpotent_iff_lowerCentralSeries.mp hG)
theorem lowerCentralSeries_eq_bot_iff_nilpotencyClass_le {n : ℕ} :
lowerCentralSeries G n = ⊥ ↔ Group.nilpotencyClass G ≤ n := by
classical
constructor
· intro h
rw [← lowerCentralSeries_length_eq_nilpotencyClass]
exact Nat.find_le h
· intro h
rw [eq_bot_iff, ← lowerCentralSeries_nilpotencyClass]
exact lowerCentralSeries_antitone h
end Classical
theorem lowerCentralSeries_map_subtype_le (H : Subgroup G) (n : ℕ) :
(lowerCentralSeries H n).map H.subtype ≤ lowerCentralSeries G n := by
induction n with
| zero => simp
| succ d hd =>
rw [lowerCentralSeries_succ, lowerCentralSeries_succ, MonoidHom.map_closure]
apply Subgroup.closure_mono
rintro x1 ⟨x2, ⟨x3, hx3, x4, _hx4, rfl⟩, rfl⟩
exact ⟨x3, hd (mem_map.mpr ⟨x3, hx3, rfl⟩), x4, by simp⟩
/-- A subgroup of a nilpotent group is nilpotent -/
instance Subgroup.isNilpotent (H : Subgroup G) [hG : IsNilpotent G] : IsNilpotent H := by
rw [nilpotent_iff_lowerCentralSeries] at *
rcases hG with ⟨n, hG⟩
use n
have := lowerCentralSeries_map_subtype_le H n
simp only [hG, SetLike.le_def, mem_map, exists_imp] at this
exact eq_bot_iff.mpr fun x hx => Subtype.ext (this x ⟨hx, rfl⟩)
/-- The nilpotency class of a subgroup is less or equal to the nilpotency class of the group -/
theorem Subgroup.nilpotencyClass_le (H : Subgroup G) [hG : IsNilpotent G] :
Group.nilpotencyClass H ≤ Group.nilpotencyClass G := by
repeat rw [← lowerCentralSeries_length_eq_nilpotencyClass]
classical apply Nat.find_mono
intro n hG
have := lowerCentralSeries_map_subtype_le H n
simp only [hG, SetLike.le_def, mem_map, exists_imp] at this
exact eq_bot_iff.mpr fun x hx => Subtype.ext (this x ⟨hx, rfl⟩)
instance (priority := 100) Group.isNilpotent_of_subsingleton [Subsingleton G] : IsNilpotent G :=
nilpotent_iff_lowerCentralSeries.2 ⟨0, Subsingleton.elim ⊤ ⊥⟩
theorem upperCentralSeries.map {H : Type*} [Group H] {f : G →* H} (h : Function.Surjective f)
(n : ℕ) : Subgroup.map f (upperCentralSeries G n) ≤ upperCentralSeries H n := by
induction n with
| zero => simp
| succ d hd =>
rintro _ ⟨x, hx : x ∈ upperCentralSeries G d.succ, rfl⟩ y'
rcases h y' with ⟨y, rfl⟩
simpa using hd (mem_map_of_mem f (hx y))
theorem lowerCentralSeries.map {H : Type*} [Group H] (f : G →* H) (n : ℕ) :
Subgroup.map f (lowerCentralSeries G n) ≤ lowerCentralSeries H n := by
induction n with
| zero => simp
| succ d hd =>
rintro a ⟨x, hx : x ∈ lowerCentralSeries G d.succ, rfl⟩
refine closure_induction (hx := hx) ?_ (by simp [f.map_one, Subgroup.one_mem _])
(fun y z _ _ hy hz => by simp [MonoidHom.map_mul, Subgroup.mul_mem _ hy hz]) (fun y _ hy => by
rw [f.map_inv]; exact Subgroup.inv_mem _ hy)
rintro a ⟨y, hy, z, ⟨-, rfl⟩⟩
apply mem_closure.mpr
exact fun K hK => hK ⟨f y, hd (mem_map_of_mem f hy), by simp [commutatorElement_def]⟩
theorem lowerCentralSeries_succ_eq_bot {n : ℕ} (h : lowerCentralSeries G n ≤ center G) :
lowerCentralSeries G (n + 1) = ⊥ := by
rw [lowerCentralSeries_succ, closure_eq_bot_iff, Set.subset_singleton_iff]
rintro x ⟨y, hy1, z, ⟨⟩, rfl⟩
rw [mul_assoc, ← mul_inv_rev, mul_inv_eq_one, eq_comm]
exact mem_center_iff.mp (h hy1) z
/-- The preimage of a nilpotent group is nilpotent if the kernel of the homomorphism is contained
in the center -/
theorem isNilpotent_of_ker_le_center {H : Type*} [Group H] (f : G →* H) (hf1 : f.ker ≤ center G)
(hH : IsNilpotent H) : IsNilpotent G := by
rw [nilpotent_iff_lowerCentralSeries] at *
rcases hH with ⟨n, hn⟩
use n + 1
refine lowerCentralSeries_succ_eq_bot (le_trans ((Subgroup.map_eq_bot_iff _).mp ?_) hf1)
exact eq_bot_iff.mpr (hn ▸ lowerCentralSeries.map f n)
theorem nilpotencyClass_le_of_ker_le_center {H : Type*} [Group H] (f : G →* H)
(hf1 : f.ker ≤ center G) (hH : IsNilpotent H) :
Group.nilpotencyClass (hG := isNilpotent_of_ker_le_center f hf1 hH) ≤
Group.nilpotencyClass H + 1 := by
haveI : IsNilpotent G := isNilpotent_of_ker_le_center f hf1 hH
rw [← lowerCentralSeries_length_eq_nilpotencyClass]
classical apply Nat.find_min'
refine lowerCentralSeries_succ_eq_bot (le_trans ((Subgroup.map_eq_bot_iff _).mp ?_) hf1)
rw [eq_bot_iff]
apply le_trans (lowerCentralSeries.map f _)
simp only [lowerCentralSeries_nilpotencyClass, le_bot_iff]
/-- The range of a surjective homomorphism from a nilpotent group is nilpotent -/
theorem nilpotent_of_surjective {G' : Type*} [Group G'] [h : IsNilpotent G] (f : G →* G')
(hf : Function.Surjective f) : IsNilpotent G' := by
rcases h with ⟨n, hn⟩
use n
apply eq_top_iff.mpr
calc
⊤ = f.range := symm (f.range_eq_top_of_surjective hf)
_ = Subgroup.map f ⊤ := MonoidHom.range_eq_map _
_ = Subgroup.map f (upperCentralSeries G n) := by rw [hn]
_ ≤ upperCentralSeries G' n := upperCentralSeries.map hf n
/-- The nilpotency class of the range of a surjective homomorphism from a
nilpotent group is less or equal the nilpotency class of the domain -/
theorem nilpotencyClass_le_of_surjective {G' : Type*} [Group G'] (f : G →* G')
(hf : Function.Surjective f) [h : IsNilpotent G] :
Group.nilpotencyClass (hG := nilpotent_of_surjective _ hf) ≤ Group.nilpotencyClass G := by
classical apply Nat.find_mono
intro n hn
rw [eq_top_iff]
calc
⊤ = f.range := symm (f.range_eq_top_of_surjective hf)
_ = Subgroup.map f ⊤ := MonoidHom.range_eq_map _
_ = Subgroup.map f (upperCentralSeries G n) := by rw [hn]
_ ≤ upperCentralSeries G' n := upperCentralSeries.map hf n
/-- Nilpotency respects isomorphisms -/
theorem nilpotent_of_mulEquiv {G' : Type*} [Group G'] [_h : IsNilpotent G] (f : G ≃* G') :
IsNilpotent G' :=
nilpotent_of_surjective f.toMonoidHom (MulEquiv.surjective f)
/-- A quotient of a nilpotent group is nilpotent -/
instance nilpotent_quotient_of_nilpotent (H : Subgroup G) [H.Normal] [_h : IsNilpotent G] :
IsNilpotent (G ⧸ H) :=
nilpotent_of_surjective (QuotientGroup.mk' H) QuotientGroup.mk_surjective
/-- The nilpotency class of a quotient of `G` is less or equal the nilpotency class of `G` -/
theorem nilpotencyClass_quotient_le (H : Subgroup G) [H.Normal] [_h : IsNilpotent G] :
Group.nilpotencyClass (G ⧸ H) ≤ Group.nilpotencyClass G :=
nilpotencyClass_le_of_surjective (QuotientGroup.mk' H) QuotientGroup.mk_surjective
-- This technical lemma helps with rewriting the subgroup, which occurs in indices
private theorem comap_center_subst {H₁ H₂ : Subgroup G} [Normal H₁] [Normal H₂] (h : H₁ = H₂) :
comap (mk' H₁) (center (G ⧸ H₁)) = comap (mk' H₂) (center (G ⧸ H₂)) := by subst h; rfl
theorem comap_upperCentralSeries_quotient_center (n : ℕ) :
comap (mk' (center G)) (upperCentralSeries (G ⧸ center G) n) = upperCentralSeries G n.succ := by
induction n with
| zero =>
simp only [upperCentralSeries_zero, MonoidHom.comap_bot, ker_mk',
(upperCentralSeries_one G).symm]
| succ n ih =>
let Hn := upperCentralSeries (G ⧸ center G) n
calc
comap (mk' (center G)) (upperCentralSeriesStep Hn) =
comap (mk' (center G)) (comap (mk' Hn) (center ((G ⧸ center G) ⧸ Hn))) := by
rw [upperCentralSeriesStep_eq_comap_center]
_ = comap (mk' (comap (mk' (center G)) Hn)) (center (G ⧸ comap (mk' (center G)) Hn)) :=
QuotientGroup.comap_comap_center
_ = comap (mk' (upperCentralSeries G n.succ)) (center (G ⧸ upperCentralSeries G n.succ)) :=
(comap_center_subst ih)
_ = upperCentralSeriesStep (upperCentralSeries G n.succ) :=
symm (upperCentralSeriesStep_eq_comap_center _)
theorem nilpotencyClass_zero_iff_subsingleton [IsNilpotent G] :
Group.nilpotencyClass G = 0 ↔ Subsingleton G := by
classical
rw [Group.nilpotencyClass, Nat.find_eq_zero, upperCentralSeries_zero,
subsingleton_iff_bot_eq_top, Subgroup.subsingleton_iff]
/-- Quotienting the `center G` reduces the nilpotency class by 1 -/
theorem nilpotencyClass_quotient_center [hH : IsNilpotent G] :
Group.nilpotencyClass (G ⧸ center G) = Group.nilpotencyClass G - 1 := by
generalize hn : Group.nilpotencyClass G = n
rcases n with (rfl | n)
· simp only [nilpotencyClass_zero_iff_subsingleton, zero_tsub] at *
exact Quotient.instSubsingletonQuotient (leftRel (center G))
· suffices Group.nilpotencyClass (G ⧸ center G) = n by simpa
apply le_antisymm
· apply upperCentralSeries_eq_top_iff_nilpotencyClass_le.mp
apply comap_injective (f := (mk' (center G))) Quot.mk_surjective
rw [comap_upperCentralSeries_quotient_center, comap_top, Nat.succ_eq_add_one, ← hn]
exact upperCentralSeries_nilpotencyClass
· apply le_of_add_le_add_right
calc
n + 1 = Group.nilpotencyClass G := hn.symm
_ ≤ Group.nilpotencyClass (G ⧸ center G) + 1 :=
nilpotencyClass_le_of_ker_le_center _ (le_of_eq (ker_mk' _)) _
/-- The nilpotency class of a non-trivial group is one more than its quotient by the center -/
theorem nilpotencyClass_eq_quotient_center_plus_one [hH : IsNilpotent G] [Nontrivial G] :
Group.nilpotencyClass G = Group.nilpotencyClass (G ⧸ center G) + 1 := by
rw [nilpotencyClass_quotient_center]
rcases h : Group.nilpotencyClass G with ⟨⟩
· exfalso
rw [nilpotencyClass_zero_iff_subsingleton] at h
apply false_of_nontrivial_of_subsingleton G
· simp
/-- If the quotient by `center G` is nilpotent, then so is G. -/
theorem of_quotient_center_nilpotent (h : IsNilpotent (G ⧸ center G)) : IsNilpotent G := by
obtain ⟨n, hn⟩ := h.nilpotent
use n.succ
simp [← comap_upperCentralSeries_quotient_center, hn]
/-- A custom induction principle for nilpotent groups. The base case is a trivial group
(`subsingleton G`), and in the induction step, one can assume the hypothesis for
the group quotiented by its center. -/
@[elab_as_elim]
theorem nilpotent_center_quotient_ind {P : ∀ (G) [Group G] [IsNilpotent G], Prop}
(G : Type*) [Group G] [IsNilpotent G]
(hbase : ∀ (G) [Group G] [Subsingleton G], P G)
(hstep : ∀ (G) [Group G] [IsNilpotent G], P (G ⧸ center G) → P G) : P G := by
obtain ⟨n, h⟩ : ∃ n, Group.nilpotencyClass G = n := ⟨_, rfl⟩
induction n generalizing G with
| zero =>
haveI := nilpotencyClass_zero_iff_subsingleton.mp h
exact hbase _
| succ n ih =>
have hn : Group.nilpotencyClass (G ⧸ center G) = n := by
simp [nilpotencyClass_quotient_center, h]
exact hstep _ (ih _ hn)
theorem derived_le_lower_central (n : ℕ) : derivedSeries G n ≤ lowerCentralSeries G n := by
induction n with
| zero => simp
| succ i ih => apply commutator_mono ih; simp
/-- Abelian groups are nilpotent -/
instance (priority := 100) CommGroup.isNilpotent {G : Type*} [CommGroup G] : IsNilpotent G := by
use 1
rw [upperCentralSeries_one]
apply CommGroup.center_eq_top
/-- Abelian groups have nilpotency class at most one -/
theorem CommGroup.nilpotencyClass_le_one {G : Type*} [CommGroup G] :
Group.nilpotencyClass G ≤ 1 := by
rw [← upperCentralSeries_eq_top_iff_nilpotencyClass_le, upperCentralSeries_one]
apply CommGroup.center_eq_top
/-- Groups with nilpotency class at most one are abelian -/
def commGroupOfNilpotencyClass [IsNilpotent G] (h : Group.nilpotencyClass G ≤ 1) : CommGroup G :=
Group.commGroupOfCenterEqTop <| by
rw [← upperCentralSeries_one]
exact upperCentralSeries_eq_top_iff_nilpotencyClass_le.mpr h
section Prod
variable {G₁ G₂ : Type*} [Group G₁] [Group G₂]
theorem lowerCentralSeries_prod (n : ℕ) :
lowerCentralSeries (G₁ × G₂) n = (lowerCentralSeries G₁ n).prod (lowerCentralSeries G₂ n) := by
induction n with
| zero => simp
| succ n ih =>
calc
lowerCentralSeries (G₁ × G₂) n.succ = ⁅lowerCentralSeries (G₁ × G₂) n, ⊤⁆ := rfl
_ = ⁅(lowerCentralSeries G₁ n).prod (lowerCentralSeries G₂ n), ⊤⁆ := by rw [ih]
_ = ⁅(lowerCentralSeries G₁ n).prod (lowerCentralSeries G₂ n), (⊤ : Subgroup G₁).prod ⊤⁆ := by
simp
_ = ⁅lowerCentralSeries G₁ n, (⊤ : Subgroup G₁)⁆.prod ⁅lowerCentralSeries G₂ n, ⊤⁆ :=
(commutator_prod_prod _ _ _ _)
_ = (lowerCentralSeries G₁ n.succ).prod (lowerCentralSeries G₂ n.succ) := rfl
/-- Products of nilpotent groups are nilpotent -/
instance isNilpotent_prod [IsNilpotent G₁] [IsNilpotent G₂] : IsNilpotent (G₁ × G₂) := by
rw [nilpotent_iff_lowerCentralSeries]
refine ⟨max (Group.nilpotencyClass G₁) (Group.nilpotencyClass G₂), ?_⟩
rw [lowerCentralSeries_prod,
lowerCentralSeries_eq_bot_iff_nilpotencyClass_le.mpr (le_max_left _ _),
lowerCentralSeries_eq_bot_iff_nilpotencyClass_le.mpr (le_max_right _ _), bot_prod_bot]
/-- The nilpotency class of a product is the max of the nilpotency classes of the factors -/
theorem nilpotencyClass_prod [IsNilpotent G₁] [IsNilpotent G₂] :
Group.nilpotencyClass (G₁ × G₂) =
max (Group.nilpotencyClass G₁) (Group.nilpotencyClass G₂) := by
refine eq_of_forall_ge_iff fun k => ?_
simp only [max_le_iff, ← lowerCentralSeries_eq_bot_iff_nilpotencyClass_le,
lowerCentralSeries_prod, prod_eq_bot_iff]
end Prod
section BoundedPi
-- First the case of infinite products with bounded nilpotency class
variable {η : Type*} {Gs : η → Type*} [∀ i, Group (Gs i)]
theorem lowerCentralSeries_pi_le (n : ℕ) :
lowerCentralSeries (∀ i, Gs i) n ≤ Subgroup.pi Set.univ
fun i => lowerCentralSeries (Gs i) n := by
let pi := fun f : ∀ i, Subgroup (Gs i) => Subgroup.pi Set.univ f
induction n with
| zero => simp [pi_top]
| succ n ih =>
calc
lowerCentralSeries (∀ i, Gs i) n.succ = ⁅lowerCentralSeries (∀ i, Gs i) n, ⊤⁆ := rfl
_ ≤ ⁅pi fun i => lowerCentralSeries (Gs i) n, ⊤⁆ := commutator_mono ih (le_refl _)
_ = ⁅pi fun i => lowerCentralSeries (Gs i) n, pi fun i => ⊤⁆ := by simp [pi, pi_top]
_ ≤ pi fun i => ⁅lowerCentralSeries (Gs i) n, ⊤⁆ := commutator_pi_pi_le _ _
_ = pi fun i => lowerCentralSeries (Gs i) n.succ := rfl
/-- products of nilpotent groups are nilpotent if their nilpotency class is bounded -/
theorem isNilpotent_pi_of_bounded_class [∀ i, IsNilpotent (Gs i)] (n : ℕ)
(h : ∀ i, Group.nilpotencyClass (Gs i) ≤ n) : IsNilpotent (∀ i, Gs i) := by
rw [nilpotent_iff_lowerCentralSeries]
refine ⟨n, ?_⟩
rw [eq_bot_iff]
apply le_trans (lowerCentralSeries_pi_le _)
rw [← eq_bot_iff, pi_eq_bot_iff]
intro i
apply lowerCentralSeries_eq_bot_iff_nilpotencyClass_le.mpr (h i)
end BoundedPi
section FinitePi
-- Now for finite products
variable {η : Type*} {Gs : η → Type*} [∀ i, Group (Gs i)]
theorem lowerCentralSeries_pi_of_finite [Finite η] (n : ℕ) :
lowerCentralSeries (∀ i, Gs i) n = Subgroup.pi Set.univ
fun i => lowerCentralSeries (Gs i) n := by
let pi := fun f : ∀ i, Subgroup (Gs i) => Subgroup.pi Set.univ f
induction n with
| zero => simp [pi_top]
| succ n ih =>
calc
lowerCentralSeries (∀ i, Gs i) n.succ = ⁅lowerCentralSeries (∀ i, Gs i) n, ⊤⁆ := rfl
_ = ⁅pi fun i => lowerCentralSeries (Gs i) n, ⊤⁆ := by rw [ih]
_ = ⁅pi fun i => lowerCentralSeries (Gs i) n, pi fun i => ⊤⁆ := by simp [pi, pi_top]
_ = pi fun i => ⁅lowerCentralSeries (Gs i) n, ⊤⁆ := commutator_pi_pi_of_finite _ _
_ = pi fun i => lowerCentralSeries (Gs i) n.succ := rfl
/-- n-ary products of nilpotent groups are nilpotent -/
instance isNilpotent_pi [Finite η] [∀ i, IsNilpotent (Gs i)] : IsNilpotent (∀ i, Gs i) := by
cases nonempty_fintype η
rw [nilpotent_iff_lowerCentralSeries]
refine ⟨Finset.univ.sup fun i => Group.nilpotencyClass (Gs i), ?_⟩
rw [lowerCentralSeries_pi_of_finite, pi_eq_bot_iff]
intro i
rw [lowerCentralSeries_eq_bot_iff_nilpotencyClass_le]
exact Finset.le_sup (f := fun i => Group.nilpotencyClass (Gs i)) (Finset.mem_univ i)
/-- The nilpotency class of an n-ary product is the sup of the nilpotency classes of the factors -/
theorem nilpotencyClass_pi [Fintype η] [∀ i, IsNilpotent (Gs i)] :
Group.nilpotencyClass (∀ i, Gs i) = Finset.univ.sup fun i => Group.nilpotencyClass (Gs i) := by
apply eq_of_forall_ge_iff
intro k
simp only [Finset.sup_le_iff, ← lowerCentralSeries_eq_bot_iff_nilpotencyClass_le,
lowerCentralSeries_pi_of_finite, pi_eq_bot_iff, Finset.mem_univ, true_imp_iff]
end FinitePi
/-- A nilpotent subgroup is solvable -/
instance (priority := 100) IsNilpotent.to_isSolvable [h : IsNilpotent G] : IsSolvable G := by
obtain ⟨n, hn⟩ := nilpotent_iff_lowerCentralSeries.1 h
use n
rw [eq_bot_iff, ← hn]
exact derived_le_lower_central n
theorem normalizerCondition_of_isNilpotent [h : IsNilpotent G] : NormalizerCondition G := by
-- roughly based on https://groupprops.subwiki.org/wiki/Nilpotent_implies_normalizer_condition
rw [normalizerCondition_iff_only_full_group_self_normalizing]
apply @nilpotent_center_quotient_ind _ G _ _ <;> clear! G
· intro G _ _ H _
exact @Subsingleton.elim _ Unique.instSubsingleton _ _
· intro G _ _ ih H hH
have hch : center G ≤ H := Subgroup.center_le_normalizer.trans (le_of_eq hH)
have hkh : (mk' (center G)).ker ≤ H := by simpa using hch
have hsur : Function.Surjective (mk' (center G)) := Quot.mk_surjective
let H' := H.map (mk' (center G))
have hH' : H'.normalizer = H' := by
apply comap_injective hsur
rw [comap_normalizer_eq_of_surjective _ hsur, comap_map_eq_self hkh]
exact hH
apply map_injective_of_ker_le (mk' (center G)) hkh le_top
exact (ih H' hH').trans (symm (map_top_of_surjective _ hsur))
end WithGroup
section WithFiniteGroup
open Group Fintype
variable {G : Type*} [hG : Group G]
/-- A p-group is nilpotent -/
theorem IsPGroup.isNilpotent [Finite G] {p : ℕ} [hp : Fact (Nat.Prime p)] (h : IsPGroup p G) :
IsNilpotent G := by
cases nonempty_fintype G
classical
revert hG
apply @Fintype.induction_subsingleton_or_nontrivial _ G _
· intro _ _ _ _
infer_instance
· intro G _ _ ih _ h
have hcq : Fintype.card (G ⧸ center G) < Fintype.card G := by
simp only [← Nat.card_eq_fintype_card]
rw [card_eq_card_quotient_mul_card_subgroup (center G)]
simp only [Nat.card_eq_fintype_card]
apply lt_mul_of_one_lt_right
· exact Fintype.card_pos_iff.mpr One.instNonempty
· simp only [← Nat.card_eq_fintype_card]
exact (Subgroup.one_lt_card_iff_ne_bot _).mpr (ne_of_gt h.bot_lt_center)
have hnq : IsNilpotent (G ⧸ center G) := ih _ hcq (h.to_quotient (center G))
exact of_quotient_center_nilpotent hnq
variable [Finite G]
/-- If a finite group is the direct product of its Sylow groups, it is nilpotent -/
theorem isNilpotent_of_product_of_sylow_group
(e : (∀ p : (Nat.card G).primeFactors, ∀ P : Sylow p G, (↑P : Subgroup G)) ≃* G) :
IsNilpotent G := by
classical
let ps := (Nat.card G).primeFactors
have : ∀ (p : ps) (P : Sylow p G), IsNilpotent (↑P : Subgroup G) := by
intro p P
haveI : Fact (Nat.Prime ↑p) := Fact.mk <| Nat.prime_of_mem_primeFactors p.2
exact P.isPGroup'.isNilpotent
exact nilpotent_of_mulEquiv e
/-- A finite group is nilpotent iff the normalizer condition holds, and iff all maximal groups are
normal and iff all Sylow groups are normal and iff the group is the direct product of its Sylow
groups. -/
theorem isNilpotent_of_finite_tfae :
List.TFAE
[IsNilpotent G, NormalizerCondition G, ∀ H : Subgroup G, IsCoatom H → H.Normal,
∀ (p : ℕ) (_hp : Fact p.Prime) (P : Sylow p G), (↑P : Subgroup G).Normal,
Nonempty
((∀ p : (Nat.card G).primeFactors, ∀ P : Sylow p G, (↑P : Subgroup G)) ≃* G)] := by
tfae_have 1 → 2 := @normalizerCondition_of_isNilpotent _ _
tfae_have 2 → 3
| h, H => NormalizerCondition.normal_of_coatom H h
tfae_have 3 → 4
| h, p, _, P => Sylow.normal_of_all_max_subgroups_normal h _
tfae_have 4 → 5
| h => Nonempty.intro (Sylow.directProductOfNormal fun {p hp hP} => h p hp hP)
tfae_have 5 → 1
| ⟨e⟩ => isNilpotent_of_product_of_sylow_group e
tfae_finish
end WithFiniteGroup |
.lake/packages/mathlib/Mathlib/GroupTheory/FreeAbelianGroup.lean | import Mathlib.Algebra.Module.NatInt
import Mathlib.GroupTheory.Abelianization.Defs
import Mathlib.GroupTheory.FreeGroup.Basic
/-!
# Free abelian groups
The free abelian group on a type `α`, defined as the abelianisation of
the free group on `α`.
The free abelian group on `α` can be abstractly defined as the left adjoint of the
forgetful functor from abelian groups to types. Alternatively, one could define
it as the functions `α → ℤ` which send all but finitely many `(a : α)` to `0`,
under pointwise addition. In this file, it is defined as the abelianisation
of the free group on `α`. All the constructions and theorems required to show
the adjointness of the construction and the forgetful functor are proved in this
file, but the category-theoretic adjunction statement is in
`Mathlib/Algebra/Category/GrpCat/Adjunctions.lean`.
## Main definitions
Here we use the following variables: `(α β : Type*) (A : Type*) [AddCommGroup A]`
* `FreeAbelianGroup α` : the free abelian group on a type `α`. As an abelian
group it is `α →₀ ℤ`, the functions from `α` to `ℤ` such that all but finitely
many elements get mapped to zero, however this is not how it is implemented.
* `lift f : FreeAbelianGroup α →+ A` : the group homomorphism induced
by the map `f : α → A`.
* `map (f : α → β) : FreeAbelianGroup α →+ FreeAbelianGroup β` : functoriality
of `FreeAbelianGroup`.
* `instance [Monoid α] : Semigroup (FreeAbelianGroup α)`
* `instance [CommMonoid α] : CommRing (FreeAbelianGroup α)`
It has been suggested that we would be better off refactoring this file
and using `Finsupp` instead.
## Implementation issues
The definition is `def FreeAbelianGroup : Type u := Additive <| Abelianization <| FreeGroup α`.
Chris Hughes has suggested that this all be rewritten in terms of `Finsupp`.
Johan Commelin has written all the API relating the definition to `Finsupp`
in the lean-liquid repo.
The lemmas `map_pure`, `map_of`, `map_zero`, `map_add`, `map_neg` and `map_sub`
are proved about the `Functor.map` `<$>` construction, and need `α` and `β` to
be in the same universe. But
`FreeAbelianGroup.map (f : α → β)` is defined to be the `AddGroup`
homomorphism `FreeAbelianGroup α →+ FreeAbelianGroup β` (with `α` and `β` now
allowed to be in different universes), so `(map f).map_add`
etc. can be used to prove that `FreeAbelianGroup.map` preserves addition. The
functions `map_id`, `map_id_apply`, `map_comp`, `map_comp_apply` and `map_of_apply`
are about `FreeAbelianGroup.map`.
-/
assert_not_exists Cardinal Multiset
universe u v
variable (α : Type u) {G : Type*}
/--
If `α` is a type, then `FreeAbelianGroup α` is the free abelian group generated by `α`.
This is an abelian group equipped with a function
`FreeAbelianGroup.of : α → FreeAbelianGroup α` which has the following universal property:
if `G` is any abelian group, and `f : α → G` is any function, then this function is
the composite of `FreeAbelianGroup.of` and a unique group homomorphism
`FreeAbelianGroup.lift f : FreeAbelianGroup α →+ G`.
A typical element of `FreeAbelianGroup α` is a formal sum of
elements of `α` and their formal inverses.
For example if `x` and `y` are terms of type `α` then `x + x + x - y` is a
"typical" element of `FreeAbelianGroup α`. In particular if `α` is empty
then `FreeAbelianGroup α` is isomorphic to the trivial group, and if `α` has one term
then `FreeAbelianGroup α` is isomorphic to `ℤ`.
One can think of `FreeAbelianGroup α` as the functions `α →₀ ℤ` with finite support,
and addition given pointwise.
TODO: rename to `FreeAddCommGroup` and introduce a multiplicative version
-/
def FreeAbelianGroup : Type u :=
Additive <| Abelianization <| FreeGroup α
-- FIXME: this is super broken, because the functions have type `Additive .. → ..`
-- instead of `FreeAbelianGroup α → ..` and those are not defeq!
instance FreeAbelianGroup.addCommGroup : AddCommGroup (FreeAbelianGroup α) :=
@Additive.addCommGroup _ <| Abelianization.commGroup _
instance : Inhabited (FreeAbelianGroup α) :=
⟨0⟩
instance [IsEmpty α] : Unique (FreeAbelianGroup α) := by unfold FreeAbelianGroup; infer_instance
variable {α}
namespace FreeAbelianGroup
/-- The canonical map from `α` to `FreeAbelianGroup α`. -/
def of (x : α) : FreeAbelianGroup α :=
Additive.ofMul <| Abelianization.of <| FreeGroup.of x
/-- The map `FreeAbelianGroup α →+ A` induced by a map of types `α → A`. -/
def lift {β : Type v} [AddCommGroup β] : (α → β) ≃ (FreeAbelianGroup α →+ β) :=
(@FreeGroup.lift _ (Multiplicative β) _).trans <|
(@Abelianization.lift _ _ (Multiplicative β) _).trans MonoidHom.toAdditive
section lift
variable {β : Type v} [AddCommGroup β] (f : α → β)
open FreeAbelianGroup
-- Porting note: needed to add `(β := Multiplicative β)`
@[simp]
theorem lift_apply_of (x : α) : lift f (of x) = f x := by
convert Abelianization.lift_apply_of
(FreeGroup.lift f (β := Multiplicative β)) (FreeGroup.of x)
exact (FreeGroup.lift_apply_of (β := Multiplicative β)).symm
@[deprecated (since := "2025-07-23")] protected alias lift.of := lift_apply_of
theorem lift_unique (g : FreeAbelianGroup α →+ β) (hg : ∀ x, g (of x) = f x) {x} :
g x = lift f x :=
DFunLike.congr_fun (lift.symm_apply_eq.mp (funext hg : g ∘ of = f)) _
@[deprecated (since := "2025-07-23")] protected alias lift.unique := lift_unique
/-- See note [partially-applied ext lemmas]. -/
@[ext high]
theorem lift_ext (g h : FreeAbelianGroup α →+ β) (H : ∀ x, g (of x) = h (of x)) : g = h :=
lift.symm.injective <| funext H
@[deprecated (since := "2025-07-23")] protected alias lift.ext := lift_ext
theorem lift_comp_apply {α β γ} [AddCommGroup β] [AddCommGroup γ]
(a : FreeAbelianGroup α) (f : α → β) (g : β →+ γ) : lift (g ∘ f) a = g (lift f a) := by
rw [← AddMonoidHom.comp_apply g (lift f)]
refine (lift_unique _ _ ?_).symm
intro a
change g ((lift f) (of a)) = g (f a)
simp only [lift_apply_of]
@[deprecated lift_comp_apply (since := "2025-07-23")]
theorem lift.map_hom {α β γ} [AddCommGroup β] [AddCommGroup γ] (a : FreeAbelianGroup α) (f : α → β)
(g : β →+ γ) : g (lift f a) = lift (g ∘ f) a :=
(lift_comp_apply a f g).symm
end lift
section
open scoped Classical in
theorem of_injective : Function.Injective (of : α → FreeAbelianGroup α) :=
fun x y hoxy ↦ Classical.by_contradiction fun hxy : x ≠ y ↦
let f : FreeAbelianGroup α →+ ℤ := lift fun z ↦ if x = z then (1 : ℤ) else 0
have hfx1 : f (of x) = 1 := (lift_apply_of _ _).trans <| if_pos rfl
have hfy1 : f (of y) = 1 := hoxy ▸ hfx1
have hfy0 : f (of y) = 0 := (lift_apply_of _ _).trans <| if_neg hxy
one_ne_zero <| hfy1.symm.trans hfy0
@[simp]
theorem of_ne_zero (x : α) : of x ≠ 0 := by
intro h
let f : FreeAbelianGroup α →+ ℤ := lift 1
have hfx : f (of x) = 1 := lift_apply_of _ _
have hf0 : f (of x) = 0 := by rw [h, map_zero]
exact one_ne_zero <| hfx.symm.trans hf0
@[simp]
theorem zero_ne_of (x : α) : 0 ≠ of x := of_ne_zero _ |>.symm
instance [Nonempty α] : Nontrivial (FreeAbelianGroup α) where
exists_pair_ne := let ⟨x⟩ := ‹Nonempty α›; ⟨0, of x, zero_ne_of _⟩
end
attribute [local instance] QuotientGroup.leftRel
@[elab_as_elim]
protected theorem induction_on {C : FreeAbelianGroup α → Prop} (z : FreeAbelianGroup α) (C0 : C 0)
(C1 : ∀ x, C <| of x) (Cn : ∀ x, C (of x) → C (-of x)) (Cp : ∀ x y, C x → C y → C (x + y)) :
C z :=
Quotient.inductionOn' z fun x ↦
Quot.inductionOn x fun L ↦
List.recOn L C0 fun ⟨x, b⟩ _ ih ↦ Bool.recOn b (Cp _ _ (Cn _ (C1 x)) ih) (Cp _ _ (C1 x) ih)
theorem lift_add_apply [AddCommGroup G] (f g : α → G) (a : FreeAbelianGroup α) :
lift (f + g) a = lift f a + lift g a := by
refine FreeAbelianGroup.induction_on a ?_ ?_ ?_ ?_
· simp only [(lift _).map_zero, zero_add]
· intro x
simp only [lift_apply_of, Pi.add_apply]
· intro x _
simp only [map_neg, lift_apply_of, Pi.add_apply, neg_add]
· intro x y hx hy
simp only [(lift _).map_add, hx, hy, add_add_add_comm]
@[deprecated (since := "2025-07-13")] alias lift.add' := lift_add_apply
@[simp] lemma lift_add [AddCommGroup G] (f g : α → G) : lift (f + g) = lift f + lift g :=
AddMonoidHom.ext <| lift_add_apply _ _
/-- `FreeAbelianGroup.lift` as an equivalence of groups. -/
@[simps!]
def liftAddEquiv [AddCommGroup G] : (α → G) ≃+ (FreeAbelianGroup α →+ G) := ⟨lift, lift_add⟩
/-- If `g : FreeAbelianGroup X` and `A` is an abelian group then `liftAddGroupHom g`
is the additive group homomorphism sending a function `X → A` to the term of type `A`
corresponding to the evaluation of the induced map `FreeAbelianGroup X → A` at `g`. -/
@[simps!]
def liftAddGroupHom {α} (β) [AddCommGroup β] (a : FreeAbelianGroup α) : (α → β) →+ β :=
AddMonoidHom.mk' (fun f ↦ lift f a) (lift_add_apply · · _)
@[simp] lemma lift_neg [AddCommGroup G] (f : α → G) : lift (-f) = -lift f := liftAddEquiv.map_neg f
lemma lift_neg_apply [AddCommGroup G] (f : α → G) (a : FreeAbelianGroup α) :
lift (-f) a = -lift f a := congr($(lift_neg f) a)
@[deprecated (since := "2025-07-13")] alias lift_neg' := lift_neg
section Monad
variable {β : Type u}
instance : Monad FreeAbelianGroup.{u} where
pure α := of α
bind x f := lift f x
@[elab_as_elim]
protected theorem induction_on' {C : FreeAbelianGroup α → Prop} (z : FreeAbelianGroup α) (C0 : C 0)
(C1 : ∀ x, C <| pure x) (Cn : ∀ x, C (pure x) → C (-pure x))
(Cp : ∀ x y, C x → C y → C (x + y)) : C z :=
FreeAbelianGroup.induction_on z C0 C1 Cn Cp
@[simp]
theorem map_pure (f : α → β) (x : α) : f <$> (pure x : FreeAbelianGroup α) = pure (f x) :=
rfl
@[simp]
protected theorem map_zero (f : α → β) : f <$> (0 : FreeAbelianGroup α) = 0 :=
(lift (of ∘ f)).map_zero
@[simp]
protected theorem map_add (f : α → β) (x y : FreeAbelianGroup α) :
f <$> (x + y) = f <$> x + f <$> y :=
(lift _).map_add _ _
@[simp]
protected theorem map_neg (f : α → β) (x : FreeAbelianGroup α) : f <$> (-x) = -f <$> x :=
map_neg (lift <| of ∘ f) _
@[simp]
protected theorem map_sub (f : α → β) (x y : FreeAbelianGroup α) :
f <$> (x - y) = f <$> x - f <$> y :=
map_sub (lift <| of ∘ f) _ _
@[simp]
theorem map_of (f : α → β) (y : α) : f <$> of y = of (f y) :=
rfl
theorem pure_bind (f : α → FreeAbelianGroup β) (x) : pure x >>= f = f x :=
lift_apply_of _ _
@[simp]
theorem zero_bind (f : α → FreeAbelianGroup β) : 0 >>= f = 0 :=
(lift f).map_zero
@[simp]
theorem add_bind (f : α → FreeAbelianGroup β) (x y : FreeAbelianGroup α) :
x + y >>= f = (x >>= f) + (y >>= f) :=
(lift _).map_add _ _
@[simp]
theorem neg_bind (f : α → FreeAbelianGroup β) (x : FreeAbelianGroup α) : -x >>= f = -(x >>= f) :=
map_neg (lift f) _
@[simp]
theorem sub_bind (f : α → FreeAbelianGroup β) (x y : FreeAbelianGroup α) :
x - y >>= f = (x >>= f) - (y >>= f) :=
map_sub (lift f) _ _
@[simp]
theorem pure_seq (f : α → β) (x : FreeAbelianGroup α) : pure f <*> x = f <$> x :=
pure_bind _ _
@[simp]
theorem zero_seq (x : FreeAbelianGroup α) : (0 : FreeAbelianGroup (α → β)) <*> x = 0 :=
zero_bind _
@[simp]
theorem add_seq (f g : FreeAbelianGroup (α → β)) (x : FreeAbelianGroup α) :
f + g <*> x = (f <*> x) + (g <*> x) :=
add_bind _ _ _
@[simp]
theorem neg_seq (f : FreeAbelianGroup (α → β)) (x : FreeAbelianGroup α) : -f <*> x = -(f <*> x) :=
neg_bind _ _
@[simp]
theorem sub_seq (f g : FreeAbelianGroup (α → β)) (x : FreeAbelianGroup α) :
f - g <*> x = (f <*> x) - (g <*> x) :=
sub_bind _ _ _
/-- If `f : FreeAbelianGroup (α → β)`, then `f <*>` is an additive morphism
`FreeAbelianGroup α →+ FreeAbelianGroup β`. -/
def seqAddGroupHom (f : FreeAbelianGroup (α → β)) : FreeAbelianGroup α →+ FreeAbelianGroup β := by
refine .mk' (f <*> ·) fun x y ↦ ?_
change lift (· <$> (x + y)) _ = lift (· <$> x) _ + lift (· <$> y) _
simp [← Pi.add_def]
@[simp]
theorem seq_zero (f : FreeAbelianGroup (α → β)) : f <*> 0 = 0 :=
(seqAddGroupHom f).map_zero
@[simp]
theorem seq_add (f : FreeAbelianGroup (α → β)) (x y : FreeAbelianGroup α) :
f <*> x + y = (f <*> x) + (f <*> y) :=
(seqAddGroupHom f).map_add x y
@[simp]
theorem seq_neg (f : FreeAbelianGroup (α → β)) (x : FreeAbelianGroup α) : f <*> -x = -(f <*> x) :=
(seqAddGroupHom f).map_neg x
@[simp]
theorem seq_sub (f : FreeAbelianGroup (α → β)) (x y : FreeAbelianGroup α) :
f <*> x - y = (f <*> x) - (f <*> y) :=
(seqAddGroupHom f).map_sub x y
instance : LawfulMonad FreeAbelianGroup.{u} := LawfulMonad.mk'
(id_map := fun x ↦ FreeAbelianGroup.induction_on' x (FreeAbelianGroup.map_zero id) (map_pure id)
(fun x ih ↦ by rw [FreeAbelianGroup.map_neg, ih])
fun x y ihx ihy ↦ by rw [FreeAbelianGroup.map_add, ihx, ihy])
(pure_bind := fun x f ↦ pure_bind f x)
(bind_assoc := fun x f g ↦ FreeAbelianGroup.induction_on' x (by iterate 3 rw [zero_bind])
(fun x ↦ by iterate 2 rw [pure_bind]) (fun x ih ↦ by iterate 3 rw [neg_bind] <;> try rw [ih])
fun x y ihx ihy ↦ by iterate 3 rw [add_bind] <;> try rw [ihx, ihy])
instance : CommApplicative FreeAbelianGroup.{u} where
commutative_prod x y := by
refine FreeAbelianGroup.induction_on' x ?_ ?_ ?_ ?_
· rw [FreeAbelianGroup.map_zero, zero_seq, seq_zero]
· intro p
rw [map_pure, pure_seq]
exact FreeAbelianGroup.induction_on' y
(by rw [FreeAbelianGroup.map_zero, FreeAbelianGroup.map_zero, zero_seq])
(fun q ↦ by rw [map_pure, map_pure, pure_seq, map_pure])
(fun q ih ↦ by rw [FreeAbelianGroup.map_neg, FreeAbelianGroup.map_neg, neg_seq, ih])
fun y₁ y₂ ih1 ih2 ↦ by
rw [FreeAbelianGroup.map_add, FreeAbelianGroup.map_add, add_seq, ih1, ih2]
· intro p ih
rw [FreeAbelianGroup.map_neg, neg_seq, seq_neg, ih]
· intro x₁ x₂ ih1 ih2
rw [FreeAbelianGroup.map_add, add_seq, seq_add, ih1, ih2]
end Monad
universe w
variable {β : Type v} {γ : Type w}
/-- The additive group homomorphism `FreeAbelianGroup α →+ FreeAbelianGroup β` induced from a
map `α → β`. -/
def map (f : α → β) : FreeAbelianGroup α →+ FreeAbelianGroup β :=
lift (of ∘ f)
theorem lift_comp {α} {β} {γ} [AddCommGroup γ] (f : α → β) (g : β → γ) (x : FreeAbelianGroup α) :
lift (g ∘ f) x = lift g (map f x) := by
induction x using FreeAbelianGroup.induction_on with
| C0 => simp only [map_zero]
| C1 => simp only [lift_apply_of, map, Function.comp]
| Cn _ h => simp only [h, AddMonoidHom.map_neg]
| Cp _ _ h₁ h₂ => simp only [h₁, h₂, AddMonoidHom.map_add]
theorem map_id : map id = AddMonoidHom.id (FreeAbelianGroup α) :=
Eq.symm <|
lift_ext _ _ fun _ ↦ lift_unique of (AddMonoidHom.id _) fun _ ↦ AddMonoidHom.id_apply _ _
theorem map_id_apply (x : FreeAbelianGroup α) : map id x = x := by
rw [map_id]
rfl
theorem map_comp {f : α → β} {g : β → γ} : map (g ∘ f) = (map g).comp (map f) :=
Eq.symm <| lift_ext _ _ fun _ ↦ by simp [map]
theorem map_comp_apply {f : α → β} {g : β → γ} (x : FreeAbelianGroup α) :
map (g ∘ f) x = (map g) ((map f) x) := by
rw [map_comp]
rfl
-- version of map_of which uses `map`
@[simp]
theorem map_of_apply {f : α → β} (a : α) : map f (of a) = of (f a) :=
rfl
variable (α)
section Mul
variable [Mul α]
instance mul : Mul (FreeAbelianGroup α) :=
⟨fun x ↦ lift fun x₂ ↦ lift (fun x₁ ↦ of (x₁ * x₂)) x⟩
variable {α}
theorem mul_def (x y : FreeAbelianGroup α) :
x * y = lift (fun x₂ ↦ lift (fun x₁ ↦ of (x₁ * x₂)) x) y :=
rfl
@[simp]
theorem of_mul_of (x y : α) : of x * of y = of (x * y) := by
rw [mul_def, lift_apply_of, lift_apply_of]
theorem of_mul (x y : α) : of (x * y) = of x * of y :=
Eq.symm <| of_mul_of x y
instance distrib : Distrib (FreeAbelianGroup α) :=
{ FreeAbelianGroup.mul α, FreeAbelianGroup.addCommGroup α with
left_distrib := fun _ _ _ ↦ (lift _).map_add _ _
right_distrib x y z := by simp [mul_def, ← Pi.add_def] }
instance nonUnitalNonAssocRing : NonUnitalNonAssocRing (FreeAbelianGroup α) :=
{ FreeAbelianGroup.distrib,
FreeAbelianGroup.addCommGroup _ with
zero_mul := fun a ↦ by
have h : 0 * a + 0 * a = 0 * a := by simp [← add_mul]
simpa using h
mul_zero := fun _ ↦ rfl }
end Mul
section One
variable [One α]
instance one : One (FreeAbelianGroup α) :=
⟨of 1⟩
theorem one_def : (1 : FreeAbelianGroup α) = of 1 :=
rfl
theorem of_one : (of 1 : FreeAbelianGroup α) = 1 :=
rfl
end One
instance nonUnitalRing [Semigroup α] : NonUnitalRing (FreeAbelianGroup α) :=
{ FreeAbelianGroup.nonUnitalNonAssocRing with
mul_assoc := fun x y z ↦ by
refine FreeAbelianGroup.induction_on z (by simp only [mul_zero])
(fun L3 ↦ ?_) (fun L3 ih ↦ ?_) fun z₁ z₂ ih₁ ih₂ ↦ ?_
· refine FreeAbelianGroup.induction_on y (by simp only [mul_zero, zero_mul])
(fun L2 ↦ ?_) (fun L2 ih ↦ ?_) fun y₁ y₂ ih₁ ih₂ ↦ ?_
· refine FreeAbelianGroup.induction_on x (by simp only [zero_mul])
(fun L1 ↦ ?_) (fun L1 ih ↦ ?_) fun x₁ x₂ ih₁ ih₂ ↦ ?_
· rw [of_mul_of, of_mul_of, of_mul_of, of_mul_of, mul_assoc]
· rw [neg_mul, neg_mul, neg_mul, ih]
· rw [add_mul, add_mul, add_mul, ih₁, ih₂]
· rw [neg_mul, mul_neg, mul_neg, neg_mul, ih]
· rw [add_mul, mul_add, mul_add, add_mul, ih₁, ih₂]
· rw [mul_neg, mul_neg, mul_neg, ih]
· rw [mul_add, mul_add, mul_add, ih₁, ih₂] }
section Monoid
variable {R : Type*} [Monoid α] [Ring R]
instance ring : Ring (FreeAbelianGroup α) :=
{ FreeAbelianGroup.nonUnitalRing _,
FreeAbelianGroup.one _ with
mul_one := fun x ↦ by
rw [mul_def, one_def, lift_apply_of]
refine FreeAbelianGroup.induction_on x rfl (fun L ↦ ?_) (fun L ih ↦ ?_) fun x1 x2 ih1 ih2 ↦ ?_
· rw [lift_apply_of, mul_one]
· rw [map_neg, ih]
· rw [map_add, ih1, ih2]
one_mul := fun x ↦ by
simp_rw [mul_def, one_def, lift_apply_of]
refine FreeAbelianGroup.induction_on x rfl ?_ ?_ ?_
· intro L
rw [lift_apply_of, one_mul]
· intro L ih
rw [map_neg, ih]
· intro x1 x2 ih1 ih2
rw [map_add, ih1, ih2] }
variable {α}
/-- `FreeAbelianGroup.of` is a `MonoidHom` when `α` is a `Monoid`. -/
def ofMulHom : α →* FreeAbelianGroup α where
toFun := of
map_one' := of_one _
map_mul' := of_mul
@[simp]
theorem ofMulHom_coe : (ofMulHom : α → FreeAbelianGroup α) = of :=
rfl
/-- If `f` preserves multiplication, then so does `lift f`. -/
def liftMonoid : (α →* R) ≃ (FreeAbelianGroup α →+* R) where
toFun f := { lift f with
toFun := lift f
map_one' := (lift_apply_of f _).trans f.map_one
map_mul' := fun x y ↦ by
refine FreeAbelianGroup.induction_on y
(by simp only [mul_zero, map_zero]) (fun L2 ↦ ?_) (fun L2 ih ↦ ?_) ?_
· refine FreeAbelianGroup.induction_on x
(by simp only [zero_mul, map_zero]) (fun L1 ↦ ?_) (fun L1 ih ↦ ?_) ?_
· simp_rw [of_mul_of, lift_apply_of]
exact f.map_mul _ _
· simp_rw [neg_mul, map_neg, neg_mul]
exact congr_arg Neg.neg ih
· intro x1 x2 ih1 ih2
simp only [add_mul, map_add, ih1, ih2]
· rw [mul_neg, map_neg, map_neg, mul_neg, ih]
· intro y1 y2 ih1 ih2
rw [mul_add, map_add, map_add, mul_add, ih1, ih2] }
invFun F := MonoidHom.comp (↑F) ofMulHom
left_inv f := MonoidHom.ext <| by
simp only [RingHom.coe_monoidHom_mk, MonoidHom.coe_comp, MonoidHom.coe_mk, OneHom.coe_mk,
ofMulHom_coe, Function.comp_apply, lift_apply_of, forall_const]
right_inv F := RingHom.coe_addMonoidHom_injective <| by
simp only
rw [← lift.apply_symm_apply (↑F : FreeAbelianGroup α →+ R)]
rfl
@[simp]
theorem liftMonoid_coe_addMonoidHom (f : α →* R) : ↑(liftMonoid f) = lift f :=
rfl
@[simp]
theorem liftMonoid_coe (f : α →* R) : ⇑(liftMonoid f) = lift f :=
rfl
@[simp]
theorem liftMonoid_symm_coe (f : FreeAbelianGroup α →+* R) :
⇑(liftMonoid.symm f) = lift.symm f :=
rfl
end Monoid
instance [CommMonoid α] : CommRing (FreeAbelianGroup α) :=
{ FreeAbelianGroup.ring α with
mul_comm := fun x y ↦ by
refine FreeAbelianGroup.induction_on x (zero_mul y) ?_ ?_ ?_
· intro s
refine FreeAbelianGroup.induction_on y (zero_mul _).symm ?_ ?_ ?_
· intro t
dsimp only [(· * ·), Mul.mul]
iterate 4 rw [lift_apply_of]
congr 1
exact mul_comm _ _
· intro t ih
rw [mul_neg, ih, neg_mul_eq_neg_mul]
· intro y1 y2 ih1 ih2
rw [mul_add, add_mul, ih1, ih2]
· intro s ih
rw [neg_mul, ih, neg_mul_eq_mul_neg]
· intro x1 x2 ih1 ih2
rw [add_mul, mul_add, ih1, ih2] }
instance pemptyUnique : Unique (FreeAbelianGroup PEmpty) where
default := 0
uniq x := FreeAbelianGroup.induction_on x rfl (PEmpty.elim ·) (PEmpty.elim ·) (by
rintro - - rfl rfl
rfl)
/-- The free abelian group on a type with one term is isomorphic to `ℤ`. -/
def uniqueEquiv (T : Type*) [Unique T] : FreeAbelianGroup T ≃+ ℤ where
toFun := FreeAbelianGroup.lift fun _ ↦ (1 : ℤ)
invFun n := n • of Inhabited.default
left_inv z := FreeAbelianGroup.induction_on z
(by simp only [zero_smul, AddMonoidHom.map_zero])
(Unique.forall_iff.2 <| by simp only [one_smul, lift_apply_of]) (Unique.forall_iff.2 <| by simp)
fun x y hx hy ↦ by
simp only [AddMonoidHom.map_add, add_smul] at *
rw [hx, hy]
right_inv n := by
rw [AddMonoidHom.map_zsmul, lift_apply_of]
exact zsmul_int_one n
map_add' := AddMonoidHom.map_add _
@[deprecated (since := "2025-06-16")] alias punitEquiv := uniqueEquiv
/-- Isomorphic types have isomorphic free abelian groups. -/
def equivOfEquiv {α β : Type*} (f : α ≃ β) : FreeAbelianGroup α ≃+ FreeAbelianGroup β where
toFun := map f
invFun := map f.symm
left_inv x := by rw [← map_comp_apply, Equiv.symm_comp_self, map_id, AddMonoidHom.id_apply]
right_inv x := by rw [← map_comp_apply, Equiv.self_comp_symm, map_id, AddMonoidHom.id_apply]
map_add' := AddMonoidHom.map_add _
end FreeAbelianGroup |
.lake/packages/mathlib/Mathlib/GroupTheory/DivisibleHull.lean | import Mathlib.Algebra.Module.LocalizedModule.Basic
import Mathlib.Algebra.Order.Module.Archimedean
import Mathlib.Algebra.Order.Monoid.PNat
import Mathlib.Data.Sign.Defs
import Mathlib.RingTheory.Localization.FractionRing
/-!
# Divisible Hull of an abelian group
This file constructs the divisible hull of an `AddCommMonoid` as a `ℕ`-module localized at
`ℕ+` (implemented using `nonZeroDivisors ℕ`), which is a `ℚ≥0`-module.
Furthermore, we show that
* when `M` is a group, so is `DivisibleHull M`, which is also a `ℚ`-module
* when `M` is linearly ordered and cancellative, so is `DivisibleHull M`, which is also an
ordered `ℚ≥0`-module.
* when `M` is a linearly ordered group, `DivisibleHull M` is an ordered `ℚ`-module, and
`ArchimedeanClass` is preserved.
Despite the name, this file doesn't implement a `DivisibleBy` instance on `DivisibleHull`. This
should be implemented on `LocalizedModule` in a more general setting (TODO: implement this).
This file mainly focuses on the specialization to `ℕ` and the linear order property introduced by
it.
## Main declarations
* `DivisibleHull M` is the divisible hull of an abelian group.
* `DivisibleHull.archimedeanClassOrderIso M` is the equivalence between `ArchimedeanClass M` and
`ArchimedeanClass (DivisibleHull M)`.
-/
variable {M : Type*} [AddCommMonoid M]
local notation "↑ⁿ" => PNat.equivNonZeroDivisorsNat
variable (M) in
/-- The divisible hull of a `AddCommMonoid` (as a ℕ-module) is the localized module by
`ℕ+` (implemented using `nonZeroDivisors ℕ`), thus a ℕ-divisble group, or a `ℚ≥0`-module. -/
abbrev DivisibleHull := LocalizedModule (nonZeroDivisors ℕ) M
namespace DivisibleHull
/-- Create an element `m / s`. -/
def mk (m : M) (s : ℕ+) : DivisibleHull M := LocalizedModule.mk m (↑ⁿ s)
/-- Define coercion as `m ↦ m / 1`. -/
@[coe]
abbrev coe (m : M) := mk m 1
/-- Coercion from `M` to `DivisibleHull M` defined as `m ↦ m / 1`. -/
instance : Coe M (DivisibleHull M) where
coe := coe
@[simp]
theorem mk_zero (s : ℕ+) : mk (0 : M) s = 0 := by simp [mk]
@[elab_as_elim, induction_eliminator]
theorem ind {motive : DivisibleHull M → Prop} (mk : ∀ num den, motive (.mk num den)) :
∀ x, motive x :=
LocalizedModule.induction_on fun m s ↦ mk m (↑ⁿ.symm s)
theorem mk_eq_mk {m m' : M} {s s' : ℕ+} :
mk m s = mk m' s' ↔ ∃ u : ℕ+, u.val • s'.val • m = u.val • s.val • m' := by
unfold mk
rw [LocalizedModule.mk_eq, ↑ⁿ.exists_congr_left]
rfl
/-- If `f : M → ℕ+ → α` respects the equivalence on localization,
lift it to a function `DivisibleHull M → α`. -/
def liftOn {α : Type*} (x : DivisibleHull M)
(f : M → ℕ+ → α)
(h : ∀ (m m' : M) (s s' : ℕ+), mk m s = mk m' s' → f m s = f m' s') : α :=
LocalizedModule.liftOn x (fun p ↦ f p.1 (↑ⁿ.symm p.2)) fun p p' heq ↦
h p.1 p'.1 (↑ⁿ.symm p.2) (↑ⁿ.symm p'.2) <| by
obtain ⟨u, hu⟩ := heq
exact mk_eq_mk.mpr ⟨↑ⁿ.symm u, hu⟩
@[simp]
theorem liftOn_mk {α : Type*} (m : M) (s : ℕ+)
(f : M → ℕ+ → α)
(h : ∀ (m m' : M) (s s' : ℕ+), mk m s = mk m' s' → f m s = f m' s') :
liftOn (mk m s) f h = f m s := rfl
/-- If `f : M → ℕ+ → M → ℕ+ → α` respects the equivalence on
localization, lift it to a function `DivisibleHull M → DivisibleHull M → α`. -/
def liftOn₂ {α : Type*} (x y : DivisibleHull M)
(f : M → ℕ+ → M → ℕ+ → α)
(h : ∀ (m n m' n' : M) (s t s' t' : ℕ+),
mk m s = mk m' s' → mk n t = mk n' t' → f m s n t = f m' s' n' t') : α :=
LocalizedModule.liftOn₂ x y (fun p q ↦ f p.1 (↑ⁿ.symm p.2) q.1 (↑ⁿ.symm q.2))
fun p q p' q' heq heq' ↦
h p.1 q.1 p'.1 q'.1 (↑ⁿ.symm p.2) (↑ⁿ.symm q.2) (↑ⁿ.symm p'.2) (↑ⁿ.symm q'.2)
(by
obtain ⟨u, hu⟩ := heq
exact mk_eq_mk.mpr ⟨↑ⁿ.symm u, hu⟩)
(by
obtain ⟨u, hu⟩ := heq'
exact mk_eq_mk.mpr ⟨↑ⁿ.symm u, hu⟩)
@[simp]
theorem liftOn₂_mk {α : Type*} (m m' : M) (s s' : ℕ+)
(f : M → ℕ+ → M → ℕ+ → α)
(h : ∀ (m n m' n' : M) (s t s' t' : ℕ+),
mk m s = mk m' s' → mk n t = mk n' t' → f m s n t = f m' s' n' t') :
liftOn₂ (mk m s) (mk m' s') f h = f m s m' s' := rfl
theorem mk_add_mk {m1 m2 : M} {s1 s2 : ℕ+} :
mk m1 s1 + mk m2 s2 = mk (s2.val • m1 + s1.val • m2) (s1 * s2) := LocalizedModule.mk_add_mk
theorem mk_add_mk_left {m1 m2 : M} {s : ℕ+} :
mk m1 s + mk m2 s = mk (m1 + m2) s := by
rw [mk_add_mk, mk_eq_mk]
exact ⟨1, by simp [smul_smul]⟩
@[simp, norm_cast]
theorem coe_add {m1 m2 : M} : ↑(m1 + m2) = (↑m1 + ↑m2 : DivisibleHull M) := by simp [mk_add_mk_left]
variable (M) in
/-- Coercion from `M` to `DivisibleHull M` as an `AddMonoidHom`. -/
@[simps]
def coeAddMonoidHom : M →+ DivisibleHull M where
toFun := (↑)
map_zero' := by simp
map_add' := by simp
theorem nsmul_mk (a : ℕ) (m : M) (s : ℕ+) : a • mk m s = mk (a • m) s := by
induction a with
| zero => simp
| succ n h => simp [add_nsmul, mk_add_mk_left, h]
theorem nnqsmul_mk (a : ℚ≥0) (m : M) (s : ℕ+) :
a • mk m s = mk (a.num • m) (⟨a.den, a.den_pos⟩ * s) := by
convert LocalizedModule.mk'_smul_mk ℚ≥0 a.num m ⟨a.den, by simp⟩ (↑ⁿ s)
simp [IsLocalization.eq_mk'_iff_mul_eq]
section TorsionFree
variable [IsAddTorsionFree M]
theorem mk_eq_mk_iff_smul_eq_smul {m m' : M} {s s' : ℕ+} :
mk m s = mk m' s' ↔ s'.val • m = s.val • m' := by
aesop (add simp [mk_eq_mk, nsmul_right_inj])
theorem mk_left_injective (s : ℕ+) : Function.Injective (fun (m : M) ↦ mk m s) := by
intro m n h
simp_rw [mk_eq_mk_iff_smul_eq_smul] at h
exact nsmul_right_injective (by simp) h
theorem coe_injective : Function.Injective ((↑) : M → DivisibleHull M) :=
mk_left_injective 1
@[simp, norm_cast]
theorem coe_inj {m m' : M} : (m : DivisibleHull M) = ↑m' ↔ m = m' :=
coe_injective.eq_iff
end TorsionFree
section Group
variable {M : Type*} [AddCommGroup M]
theorem neg_mk (m : M) (s : ℕ+) : -mk m s = mk (-m) s :=
(eq_neg_of_add_eq_zero_left (by simp [mk_add_mk_left])).symm
noncomputable
instance : SMul ℚ (DivisibleHull M) where
smul a x := (SignType.sign a : ℤ) • (show ℚ≥0 from ⟨|a|, abs_nonneg _⟩) • x
theorem qsmul_def (a : ℚ) (x : DivisibleHull M) :
a • x = (SignType.sign a : ℤ) • (show ℚ≥0 from ⟨|a|, abs_nonneg _⟩) • x :=
rfl
theorem zero_qsmul (x : DivisibleHull M) : (0 : ℚ) • x = 0 := by
simp [qsmul_def]
theorem qsmul_of_nonneg {a : ℚ} (h : 0 ≤ a) (x : DivisibleHull M) :
a • x = (show ℚ≥0 from ⟨a, h⟩) • x := by
have := h.eq_or_lt
aesop (add simp [qsmul_def, abs_of_pos])
theorem qsmul_of_nonpos {a : ℚ} (h : a ≤ 0) (x : DivisibleHull M) :
a • x = -((show ℚ≥0 from ⟨-a, Left.nonneg_neg_iff.mpr h⟩) • x) := by
have := h.eq_or_lt
aesop (add simp [qsmul_def, abs_of_neg])
theorem qsmul_mk (a : ℚ) (m : M) (s : ℕ+) :
a • mk m s = mk (a.num • m) (⟨a.den, a.den_pos⟩ * s) := by
obtain h | h := le_total 0 a
· rw [qsmul_of_nonneg h, nnqsmul_mk, ← natCast_zsmul]
congr
simpa using h
· rw [qsmul_of_nonpos h]
have : a.num.natAbs • m = -a.num • m := by
rw [← natCast_zsmul]
congr
simpa using h
simp [nnqsmul_mk, this, ← neg_mk]
noncomputable
instance : Module ℚ (DivisibleHull M) where
one_smul x := by
induction x with | mk m s
simp [qsmul_of_nonneg zero_le_one, nnqsmul_mk]
zero_smul := zero_qsmul
smul_zero a := by simp [qsmul_def]
smul_add a x y := by simp [qsmul_def, smul_add]
add_smul a b x := by
induction x with | mk m s
simp_rw [qsmul_mk, mk_add_mk, mk_eq_mk]
use 1
suffices ((a + b).num * a.den * b.den * (s * s)) • m =
((a.num * b.den + b.num * a.den) * (a + b).den * (s * s)) • m by
convert this using 1
all_goals
simp [← natCast_zsmul, smul_smul, ← add_smul]
ring_nf
rw [Rat.add_num_den']
mul_smul a b x := by
induction x with | mk m s
simp_rw [qsmul_mk, mk_eq_mk]
use 1
suffices ((a * b).num * a.den * b.den * s) • m = (a.num * b.num * (a * b).den * s) • m by
convert this using 1
all_goals
simp [← natCast_zsmul, smul_smul]
ring_nf
rw [Rat.mul_num_den']
theorem zsmul_mk (a : ℤ) (m : M) (s : ℕ+) : a • mk m s = mk (a • m) s := by
simp [← Int.cast_smul_eq_zsmul ℚ a, qsmul_mk]
end Group
section LinearOrder
variable {M : Type*} [AddCommMonoid M] [LinearOrder M] [IsOrderedCancelAddMonoid M]
private theorem lift_aux (m n m' n' : M) (s t s' t' : ℕ+)
(h : mk m s = mk m' s') (h' : mk n t = mk n' t') :
(t.val • m ≤ s.val • n) = (t'.val • m' ≤ s'.val • n') := by
rw [mk_eq_mk_iff_smul_eq_smul] at h h'
rw [propext_iff, ← nsmul_le_nsmul_iff_right (mul_ne_zero s'.ne_zero t'.ne_zero)]
convert (nsmul_le_nsmul_iff_right (M := M) (mul_ne_zero s.ne_zero t.ne_zero)) using 2
· simp_rw [smul_smul, mul_rotate s'.val, ← smul_smul, h, smul_smul]
ring_nf
· simp_rw [smul_smul, ← mul_rotate s'.val, ← smul_smul, ← h', smul_smul]
ring_nf
instance : LE (DivisibleHull M) where
le x y := liftOn₂ x y (fun m s n t ↦ t.val • m ≤ s.val • n) lift_aux
@[simp]
theorem mk_le_mk {m m' : M} {s s' : ℕ+} :
mk m s ≤ mk m' s' ↔ s'.val • m ≤ s.val • m' := by rfl
instance : LinearOrder (DivisibleHull M) where
le_refl a := by
induction a with | mk m s
simp
le_trans a b c hab hbc := by
induction a with | mk ma sa
induction b with | mk mb sb
induction c with | mk mc sc
rw [mk_le_mk] at ⊢ hab hbc
rw [← nsmul_le_nsmul_iff_right (show sb.val ≠ 0 by simp), smul_comm _ _ ma, smul_comm _ _ mc]
rw [← nsmul_le_nsmul_iff_right (show sc.val ≠ 0 by simp), smul_comm _ _ mb] at hab
rw [← nsmul_le_nsmul_iff_right (show sa.val ≠ 0 by simp)] at hbc
exact hab.trans hbc
le_antisymm a b h h' := by
induction a with | mk ma sa
induction b with | mk mb sb
rw [mk_le_mk] at h h'
rw [mk_eq_mk_iff_smul_eq_smul]
exact le_antisymm h h'
le_total a b := by
induction a with | mk ma sa
induction b with | mk mb sb
simp_rw [mk_le_mk]
exact le_total _ _
toDecidableLE := by
unfold DecidableLE LE.le instLE liftOn₂ LocalizedModule.liftOn₂
infer_instance
@[simp]
theorem mk_lt_mk {m m' : M} {s s' : ℕ+} : mk m s < mk m' s' ↔ s'.val • m < s.val • m' := by
simp_rw [lt_iff_not_ge, mk_le_mk]
instance : IsOrderedCancelAddMonoid (DivisibleHull M) :=
.of_add_lt_add_left (fun a b c h ↦ by
induction a with | mk ma sa
induction b with | mk mb sb
induction c with | mk mc sc
simp_rw [mk_add_mk]
rw [mk_lt_mk] at ⊢ h
simp_rw [PNat.mul_coe, mul_smul, smul_add, smul_smul]
have := add_lt_add_left (nsmul_lt_nsmul_right (sa * sa).ne_zero h) ((sa * sb * sc.val) • ma)
simp_rw [PNat.mul_coe, smul_smul] at this
convert this using 3 <;> ring)
instance : IsStrictOrderedModule ℚ≥0 (DivisibleHull M) where
smul_lt_smul_of_pos_left a ha b c h := by
induction b with | mk mb sb
induction c with | mk mc sc
simp_rw [mk_lt_mk] at h
simp_rw [nnqsmul_mk, mk_lt_mk, smul_smul, PNat.mul_coe]
simp_rw [mul_right_comm _ _ a.num, mul_smul _ _ mc, mul_smul _ _ mb]
exact (nsmul_right_strictMono (by simpa using ha.ne.symm)).lt_iff_lt.mpr h
smul_lt_smul_of_pos_right a ha b c h := by
induction a with | mk m s
simp_rw [nnqsmul_mk, mk_lt_mk, smul_smul, PNat.mul_coe, PNat.mk_coe]
refine smul_lt_smul_of_pos_right ?_ ?_
· convert mul_lt_mul_of_pos_right (NNRat.lt_def.mp h) (show 0 < s.val by simp) using 1 <;> ring
· rw [← mk_zero 1, mk_lt_mk] at ha
simpa using ha
end LinearOrder
section OrderedGroup
variable {M : Type*} [AddCommGroup M] [LinearOrder M] [IsOrderedAddMonoid M]
instance : IsStrictOrderedModule ℚ (DivisibleHull M) where
smul_lt_smul_of_pos_left a ha b c h := by
simp_rw [qsmul_of_nonneg ha.le]
apply smul_lt_smul_of_pos_left h (by simpa using ha)
smul_lt_smul_of_pos_right a ha b c h := by
apply lt_of_sub_pos
rw [← sub_smul]
simp_rw [qsmul_of_nonneg (sub_pos_of_lt h).le]
apply smul_pos (by simpa [← NNRat.coe_pos] using h) ha
variable (M) in
/-- Coercion from `M` to `DivisibleHull M` as an `OrderAddMonoidHom`. -/
@[simps!]
def coeOrderAddMonoidHom : M →+o DivisibleHull M where
__ := coeAddMonoidHom M
monotone' a b h := by simpa using h
/-- `ArchimedeanClass.mk` of an element from `DivisibleHull` only depends on the numerator. -/
theorem archimedeanClassMk_mk_eq (m : M) (s s' : ℕ+) :
ArchimedeanClass.mk (mk m s) = ArchimedeanClass.mk (mk m s') := by
suffices (s : ℤ) • mk m s = (s' : ℤ) • mk m s' by
apply_fun ArchimedeanClass.mk at this
rw [ArchimedeanClass.mk_smul _ (by simp)] at this
rw [ArchimedeanClass.mk_smul _ (by simp)] at this
exact this
simp_rw [zsmul_mk, mk_eq_mk_iff_smul_eq_smul, natCast_zsmul, smul_smul, mul_comm s'.val]
variable (M) in
/-- Forward direction of `archimedeanClassOrderIso`. -/
private noncomputable
def archimedeanClassOrderHom : ArchimedeanClass M →o ArchimedeanClass (DivisibleHull M) :=
ArchimedeanClass.orderHom (coeOrderAddMonoidHom M)
/-- See `archimedeanClassOrderIso_symm_apply` for public API. -/
private theorem aux_archimedeanClassMk_mk (m : M) (s : ℕ+) :
ArchimedeanClass.mk (mk m s) = archimedeanClassOrderHom M (ArchimedeanClass.mk m) := by
rw [archimedeanClassOrderHom, ArchimedeanClass.orderHom_mk, coeOrderAddMonoidHom_apply]
apply archimedeanClassMk_mk_eq
/-- Use `Equiv.injective archimedeanClassOrderIso` for public API. -/
private theorem aux_archimedeanClassOrderHom_injective :
Function.Injective (archimedeanClassOrderHom M) :=
ArchimedeanClass.orderHom_injective coe_injective
variable (M) in
/-- Backward direction of `archimedeanClassOrderIso`. -/
private noncomputable
def archimedeanClassOrderHomInv : ArchimedeanClass (DivisibleHull M) →o ArchimedeanClass M :=
ArchimedeanClass.liftOrderHom (fun x ↦ x.liftOn (fun m s ↦ ArchimedeanClass.mk m)
(fun _ _ _ _ h ↦ by
apply aux_archimedeanClassOrderHom_injective
apply_fun ArchimedeanClass.mk at h
simpa [aux_archimedeanClassMk_mk] using h))
(fun a b h ↦ by
induction a with | mk _ _
induction b with | mk _ _
simp_rw [aux_archimedeanClassMk_mk] at h
simpa using ((archimedeanClassOrderHom M).monotone.strictMono_of_injective
aux_archimedeanClassOrderHom_injective).le_iff_le.mp h)
variable (M) in
/-- The Archimedean classes of `DivisibleHull M` are the same as those of `M`. -/
noncomputable
def archimedeanClassOrderIso : ArchimedeanClass M ≃o ArchimedeanClass (DivisibleHull M) := by
apply OrderIso.ofHomInv (archimedeanClassOrderHom M) (archimedeanClassOrderHomInv M)
· ext a
induction a with | mk a
induction a with | mk m s
suffices ArchimedeanClass.mk (mk m 1) = ArchimedeanClass.mk (mk m s) by
simpa [archimedeanClassOrderHom, archimedeanClassOrderHomInv]
simp_rw [aux_archimedeanClassMk_mk]
· ext a
induction a with | mk _
simp [archimedeanClassOrderHom, archimedeanClassOrderHomInv]
@[simp]
theorem archimedeanClassOrderIso_apply (a : ArchimedeanClass M) :
archimedeanClassOrderIso M a = ArchimedeanClass.orderHom (coeOrderAddMonoidHom M) a := rfl
@[simp]
theorem archimedeanClassOrderIso_symm_apply (m : M) (s : ℕ+) :
(archimedeanClassOrderIso M).symm (ArchimedeanClass.mk (mk m s)) = ArchimedeanClass.mk m := rfl
end OrderedGroup
end DivisibleHull |
.lake/packages/mathlib/Mathlib/GroupTheory/Solvable.lean | import Mathlib.Data.Fin.VecNotation
import Mathlib.GroupTheory.Abelianization.Defs
import Mathlib.GroupTheory.Perm.ViaEmbedding
import Mathlib.GroupTheory.Subgroup.Simple
import Mathlib.SetTheory.Cardinal.Order
/-!
# Solvable Groups
In this file we introduce the notion of a solvable group. We define a solvable group as one whose
derived series is eventually trivial. This requires defining the commutator of two subgroups and
the derived series of a group.
## Main definitions
* `derivedSeries G n` : the `n`th term in the derived series of `G`, defined by iterating
`general_commutator` starting with the top subgroup
* `IsSolvable G` : the group `G` is solvable
-/
open Subgroup
variable {G G' : Type*} [Group G] [Group G'] {f : G →* G'}
section derivedSeries
variable (G)
/-- The derived series of the group `G`, obtained by starting from the subgroup `⊤` and repeatedly
taking the commutator of the previous subgroup with itself for `n` times. -/
def derivedSeries : ℕ → Subgroup G
| 0 => ⊤
| n + 1 => ⁅derivedSeries n, derivedSeries n⁆
@[simp]
theorem derivedSeries_zero : derivedSeries G 0 = ⊤ :=
rfl
@[simp]
theorem derivedSeries_succ (n : ℕ) :
derivedSeries G (n + 1) = ⁅derivedSeries G n, derivedSeries G n⁆ :=
rfl
theorem derivedSeries_normal (n : ℕ) : (derivedSeries G n).Normal := by
induction n with
| zero => exact (⊤ : Subgroup G).normal_of_characteristic
| succ n ih => exact Subgroup.commutator_normal (derivedSeries G n) (derivedSeries G n)
@[simp 1100]
theorem derivedSeries_one : derivedSeries G 1 = commutator G :=
rfl
theorem derivedSeries_antitone : Antitone (derivedSeries G) :=
antitone_nat_of_succ_le fun n => (derivedSeries G n).commutator_le_self
instance derivedSeries_characteristic (n : ℕ) : (derivedSeries G n).Characteristic := by
induction n with
| zero => exact Subgroup.topCharacteristic
| succ n _ => exact Subgroup.commutator_characteristic _ _
end derivedSeries
section CommutatorMap
section DerivedSeriesMap
variable (f) in
theorem map_derivedSeries_le_derivedSeries (n : ℕ) :
(derivedSeries G n).map f ≤ derivedSeries G' n := by
induction n with
| zero => exact le_top
| succ n ih => simp only [derivedSeries_succ, map_commutator, commutator_mono, ih]
theorem derivedSeries_le_map_derivedSeries (hf : Function.Surjective f) (n : ℕ) :
derivedSeries G' n ≤ (derivedSeries G n).map f := by
induction n with
| zero => exact (map_top_of_surjective f hf).ge
| succ n ih => exact commutator_le_map_commutator ih ih
theorem map_derivedSeries_eq (hf : Function.Surjective f) (n : ℕ) :
(derivedSeries G n).map f = derivedSeries G' n :=
le_antisymm (map_derivedSeries_le_derivedSeries f n) (derivedSeries_le_map_derivedSeries hf n)
end DerivedSeriesMap
end CommutatorMap
section Solvable
variable (G)
/-- A group `G` is solvable if its derived series is eventually trivial. We use this definition
because it's the most convenient one to work with. -/
@[mk_iff isSolvable_def]
class IsSolvable : Prop where
/-- A group `G` is solvable if its derived series is eventually trivial. -/
solvable : ∃ n : ℕ, derivedSeries G n = ⊥
instance (priority := 100) CommGroup.isSolvable {G : Type*} [CommGroup G] : IsSolvable G :=
⟨⟨1, le_bot_iff.mp (Abelianization.commutator_subset_ker (MonoidHom.id G))⟩⟩
theorem isSolvable_of_comm {G : Type*} [hG : Group G] (h : ∀ a b : G, a * b = b * a) :
IsSolvable G := by
letI hG' : CommGroup G := { hG with mul_comm := h }
cases hG
exact CommGroup.isSolvable
theorem isSolvable_of_top_eq_bot (h : (⊤ : Subgroup G) = ⊥) : IsSolvable G :=
⟨⟨0, h⟩⟩
instance (priority := 100) isSolvable_of_subsingleton [Subsingleton G] : IsSolvable G :=
isSolvable_of_top_eq_bot G (by simp [eq_iff_true_of_subsingleton])
variable {G}
theorem solvable_of_ker_le_range {G' G'' : Type*} [Group G'] [Group G''] (f : G' →* G)
(g : G →* G'') (hfg : g.ker ≤ f.range) [hG' : IsSolvable G'] [hG'' : IsSolvable G''] :
IsSolvable G := by
obtain ⟨n, hn⟩ := id hG''
obtain ⟨m, hm⟩ := id hG'
refine ⟨⟨n + m, le_bot_iff.mp (Subgroup.map_bot f ▸ hm ▸ ?_)⟩⟩
clear hm
induction m with
| zero =>
exact f.range_eq_map ▸ ((derivedSeries G n).map_eq_bot_iff.mp
(le_bot_iff.mp ((map_derivedSeries_le_derivedSeries g n).trans hn.le))).trans hfg
| succ m hm => exact commutator_le_map_commutator hm hm
theorem solvable_of_solvable_injective (hf : Function.Injective f) [IsSolvable G'] :
IsSolvable G :=
solvable_of_ker_le_range (1 : G' →* G) f ((f.ker_eq_bot_iff.mpr hf).symm ▸ bot_le)
instance subgroup_solvable_of_solvable (H : Subgroup G) [IsSolvable G] : IsSolvable H :=
solvable_of_solvable_injective H.subtype_injective
theorem solvable_of_surjective (hf : Function.Surjective f) [IsSolvable G] : IsSolvable G' :=
solvable_of_ker_le_range f (1 : G' →* G) (f.range_eq_top_of_surjective hf ▸ le_top)
instance solvable_quotient_of_solvable (H : Subgroup G) [H.Normal] [IsSolvable G] :
IsSolvable (G ⧸ H) :=
solvable_of_surjective (QuotientGroup.mk'_surjective H)
instance solvable_prod {G' : Type*} [Group G'] [IsSolvable G] [IsSolvable G'] :
IsSolvable (G × G') :=
solvable_of_ker_le_range (MonoidHom.inl G G') (MonoidHom.snd G G') fun x hx =>
⟨x.1, Prod.ext rfl hx.symm⟩
variable (G) in
theorem IsSolvable.commutator_lt_top_of_nontrivial [hG : IsSolvable G] [Nontrivial G] :
commutator G < ⊤ := by
rw [lt_top_iff_ne_top]
obtain ⟨n, hn⟩ := hG
contrapose! hn
refine ne_of_eq_of_ne ?_ top_ne_bot
induction n with
| zero => exact derivedSeries_zero G
| succ n h => rwa [derivedSeries_succ, h]
theorem IsSolvable.commutator_lt_of_ne_bot [IsSolvable G] {H : Subgroup G} (hH : H ≠ ⊥) :
⁅H, H⁆ < H := by
rw [← nontrivial_iff_ne_bot] at hH
rw [← H.range_subtype, MonoidHom.range_eq_map, ← map_commutator, map_subtype_lt_map_subtype]
exact commutator_lt_top_of_nontrivial H
theorem isSolvable_iff_commutator_lt [WellFoundedLT (Subgroup G)] :
IsSolvable G ↔ ∀ H : Subgroup G, H ≠ ⊥ → ⁅H, H⁆ < H := by
refine ⟨fun _ _ ↦ IsSolvable.commutator_lt_of_ne_bot, fun h ↦ ?_⟩
suffices h : IsSolvable (⊤ : Subgroup G) from
solvable_of_surjective (MonoidHom.range_eq_top.mp (range_subtype ⊤))
refine WellFoundedLT.induction (C := fun (H : Subgroup G) ↦ IsSolvable H) ⊤ fun H hH ↦ ?_
rcases eq_or_ne H ⊥ with rfl | h'
· infer_instance
· obtain ⟨n, hn⟩ := hH ⁅H, H⁆ (h H h')
use n + 1
rw [← (map_injective (subtype_injective _)).eq_iff, Subgroup.map_bot] at hn ⊢
rw [← hn]
clear hn
induction n with
| zero =>
rw [derivedSeries_succ, derivedSeries_zero, derivedSeries_zero, map_commutator,
← MonoidHom.range_eq_map, ← MonoidHom.range_eq_map, range_subtype, range_subtype]
| succ n ih => rw [derivedSeries_succ, map_commutator, ih, derivedSeries_succ, map_commutator]
end Solvable
section IsSimpleGroup
variable [IsSimpleGroup G]
theorem IsSimpleGroup.derivedSeries_succ {n : ℕ} : derivedSeries G n.succ = commutator G := by
induction n with
| zero => exact derivedSeries_one G
| succ n ih =>
rw [_root_.derivedSeries_succ, ih, _root_.commutator]
rcases (commutator_normal (⊤ : Subgroup G) (⊤ : Subgroup G)).eq_bot_or_eq_top with h | h
· rw [h, commutator_bot_left]
· rwa [h]
theorem IsSimpleGroup.comm_iff_isSolvable : (∀ a b : G, a * b = b * a) ↔ IsSolvable G :=
⟨isSolvable_of_comm, fun ⟨⟨n, hn⟩⟩ => by
cases n
· intro a b
refine (mem_bot.1 ?_).trans (mem_bot.1 ?_).symm <;>
· rw [← hn]
exact mem_top _
· rw [IsSimpleGroup.derivedSeries_succ] at hn
intro a b
rw [← mul_inv_eq_one, mul_inv_rev, ← mul_assoc, ← mem_bot, ← hn, commutator_eq_closure]
exact subset_closure ⟨a, b, rfl⟩⟩
end IsSimpleGroup
section PermNotSolvable
theorem not_solvable_of_mem_derivedSeries {g : G} (h1 : g ≠ 1)
(h2 : ∀ n : ℕ, g ∈ derivedSeries G n) : ¬IsSolvable G :=
mt (isSolvable_def _).mp
(not_exists_of_forall_not fun n h =>
h1 (Subgroup.mem_bot.mp ((congr_arg (g ∈ ·) h).mp (h2 n))))
theorem Equiv.Perm.fin_5_not_solvable : ¬IsSolvable (Equiv.Perm (Fin 5)) := by
let x : Equiv.Perm (Fin 5) := ⟨![1, 2, 0, 3, 4], ![2, 0, 1, 3, 4], by decide, by decide⟩
let y : Equiv.Perm (Fin 5) := ⟨![3, 4, 2, 0, 1], ![3, 4, 2, 0, 1], by decide, by decide⟩
let z : Equiv.Perm (Fin 5) := ⟨![0, 3, 2, 1, 4], ![0, 3, 2, 1, 4], by decide, by decide⟩
have key : x = z * ⁅x, y * x * y⁻¹⁆ * z⁻¹ := by unfold x y z; decide
refine not_solvable_of_mem_derivedSeries (show x ≠ 1 by decide) fun n => ?_
induction n with
| zero => exact mem_top x
| succ n ih =>
rw [key, (derivedSeries_normal _ _).mem_comm_iff, inv_mul_cancel_left]
exact commutator_mem_commutator ih ((derivedSeries_normal _ _).conj_mem _ ih _)
theorem Equiv.Perm.not_solvable (X : Type*) (hX : 5 ≤ Cardinal.mk X) :
¬IsSolvable (Equiv.Perm X) := by
intro h
have key : Nonempty (Fin 5 ↪ X) := by
rwa [← Cardinal.lift_mk_le, Cardinal.mk_fin, Cardinal.lift_natCast, Cardinal.lift_id]
exact
Equiv.Perm.fin_5_not_solvable
(solvable_of_solvable_injective (Equiv.Perm.viaEmbeddingHom_injective (Nonempty.some key)))
end PermNotSolvable |
.lake/packages/mathlib/Mathlib/GroupTheory/Complement.lean | import Mathlib.GroupTheory.Index
/-!
# Complements
In this file we define the complement of a subgroup.
## Main definitions
- `Subgroup.IsComplement S T` where `S` and `T` are subsets of `G` states that every `g : G` can be
written uniquely as a product `s * t` for `s ∈ S`, `t ∈ T`.
- `H.LeftTransversal` where `H` is a subgroup of `G` is the type of all left-complements of `H`,
i.e. the set of all `S : Set G` that contain exactly one element of each left coset of `H`.
- `H.RightTransversal` where `H` is a subgroup of `G` is the set of all right-complements of `H`,
i.e. the set of all `T : Set G` that contain exactly one element of each right coset of `H`.
## Main results
- `isComplement'_of_coprime` : Subgroups of coprime order are complements.
-/
open Function Set
open scoped Pointwise
namespace Subgroup
variable {G : Type*} [Group G] (H K : Subgroup G) (S T : Set G)
/-- `S` and `T` are complements if `(*) : S × T → G` is a bijection.
This notion generalizes left transversals, right transversals, and complementary subgroups.
If `S` and `T` are `SetLike`s such as `Subgroup`s, see `isComplement_iff_bijective` for a
more ergonomic way to unfold.
-/
@[to_additive /-- `S` and `T` are complements if `(+) : S × T → G` is a bijection
If `S` and `T` are `SetLike`s such as `AddSubgroup`s, see `isComplement_iff_bijective` for a
more ergonomic way to unfold. -/]
def IsComplement : Prop :=
Function.Bijective fun x : S × T => x.1.1 * x.2.1
/-- `H` and `K` are complements if `(*) : H × K → G` is a bijection -/
@[to_additive /-- `H` and `K` are complements if `(+) : H × K → G` is a bijection -/]
abbrev IsComplement' :=
IsComplement (H : Set G) (K : Set G)
variable {H K S T}
/-- The correct way to unfold `IsComplement` for `SetLike`s such as `Subgroup`s -/
@[to_additive /-- The correct way to unfold `IsComplement` for `SetLike`s such as `AddSubgroup`s -/]
theorem isComplement_iff_bijective {S : Type*} [SetLike S G] (s t : S) :
IsComplement (G := G) s t ↔ Function.Bijective fun x : s × t => (x.1 : G) * (x.2 : G) :=
Iff.rfl
@[to_additive]
theorem isComplement'_def : IsComplement' H K ↔ IsComplement (H : Set G) (K : Set G) :=
Iff.rfl
@[to_additive]
theorem isComplement_iff_existsUnique :
IsComplement S T ↔ ∀ g : G, ∃! x : S × T, x.1.1 * x.2.1 = g :=
Function.bijective_iff_existsUnique _
@[to_additive]
theorem IsComplement.existsUnique (h : IsComplement S T) (g : G) :
∃! x : S × T, x.1.1 * x.2.1 = g :=
isComplement_iff_existsUnique.mp h g
@[to_additive]
theorem IsComplement'.symm (h : IsComplement' H K) : IsComplement' K H := by
let ϕ : H × K ≃ K × H :=
Equiv.mk (fun x => ⟨x.2⁻¹, x.1⁻¹⟩) (fun x => ⟨x.2⁻¹, x.1⁻¹⟩)
(fun x => Prod.ext (inv_inv _) (inv_inv _)) fun x => Prod.ext (inv_inv _) (inv_inv _)
let ψ : G ≃ G := Equiv.mk (fun g : G => g⁻¹) (fun g : G => g⁻¹) inv_inv inv_inv
suffices hf : (ψ ∘ fun x : H × K => x.1.1 * x.2.1) = (fun x : K × H => x.1.1 * x.2.1) ∘ ϕ by
rwa [isComplement'_def, isComplement_iff_bijective, ← Equiv.bijective_comp ϕ, ← hf,
ψ.comp_bijective]
exact funext fun x => mul_inv_rev _ _
@[to_additive]
theorem isComplement'_comm : IsComplement' H K ↔ IsComplement' K H :=
⟨IsComplement'.symm, IsComplement'.symm⟩
@[to_additive]
theorem isComplement_univ_singleton {g : G} : IsComplement (univ : Set G) {g} :=
⟨fun ⟨_, _, rfl⟩ ⟨_, _, rfl⟩ h => Prod.ext (Subtype.ext (mul_right_cancel h)) rfl, fun x =>
⟨⟨⟨x * g⁻¹, ⟨⟩⟩, g, rfl⟩, inv_mul_cancel_right x g⟩⟩
@[to_additive]
theorem isComplement_singleton_univ {g : G} : IsComplement ({g} : Set G) univ :=
⟨fun ⟨⟨_, rfl⟩, _⟩ ⟨⟨_, rfl⟩, _⟩ h => Prod.ext rfl (Subtype.ext (mul_left_cancel h)), fun x =>
⟨⟨⟨g, rfl⟩, g⁻¹ * x, ⟨⟩⟩, mul_inv_cancel_left g x⟩⟩
@[to_additive]
theorem isComplement_singleton_left {g : G} : IsComplement {g} S ↔ S = univ := by
refine
⟨fun h => top_le_iff.mp fun x _ => ?_, fun h => (congr_arg _ h).mpr isComplement_singleton_univ⟩
obtain ⟨⟨⟨z, rfl : z = g⟩, y, _⟩, hy⟩ := h.2 (g * x)
rwa [← mul_left_cancel hy]
@[to_additive]
theorem isComplement_singleton_right {g : G} : IsComplement S {g} ↔ S = univ := by
refine
⟨fun h => top_le_iff.mp fun x _ => ?_, fun h => h ▸ isComplement_univ_singleton⟩
obtain ⟨y, hy⟩ := h.2 (x * g)
conv_rhs at hy => rw [← show y.2.1 = g from y.2.2]
rw [← mul_right_cancel hy]
exact y.1.2
@[to_additive]
theorem isComplement_univ_left : IsComplement univ S ↔ ∃ g : G, S = {g} := by
refine
⟨fun h => Set.exists_eq_singleton_iff_nonempty_subsingleton.mpr ⟨?_, fun a ha b hb => ?_⟩, ?_⟩
· obtain ⟨a, _⟩ := h.2 1
exact ⟨a.2.1, a.2.2⟩
· have : (⟨⟨_, mem_top a⁻¹⟩, ⟨a, ha⟩⟩ : (⊤ : Set G) × S) = ⟨⟨_, mem_top b⁻¹⟩, ⟨b, hb⟩⟩ :=
h.1 ((inv_mul_cancel a).trans (inv_mul_cancel b).symm)
exact Subtype.ext_iff.mp (Prod.ext_iff.mp this).2
· rintro ⟨g, rfl⟩
exact isComplement_univ_singleton
@[to_additive]
theorem isComplement_univ_right : IsComplement S univ ↔ ∃ g : G, S = {g} := by
refine
⟨fun h => Set.exists_eq_singleton_iff_nonempty_subsingleton.mpr ⟨?_, fun a ha b hb => ?_⟩, ?_⟩
· obtain ⟨a, _⟩ := h.2 1
exact ⟨a.1.1, a.1.2⟩
· have : (⟨⟨a, ha⟩, ⟨_, mem_top a⁻¹⟩⟩ : S × (⊤ : Set G)) = ⟨⟨b, hb⟩, ⟨_, mem_top b⁻¹⟩⟩ :=
h.1 ((mul_inv_cancel a).trans (mul_inv_cancel b).symm)
exact Subtype.ext_iff.mp (Prod.ext_iff.mp this).1
· rintro ⟨g, rfl⟩
exact isComplement_singleton_univ
@[to_additive]
lemma IsComplement.mul_eq (h : IsComplement S T) : S * T = univ :=
eq_univ_of_forall fun x ↦ by simpa [mem_mul] using (h.existsUnique x).exists
@[to_additive (attr := simp)]
lemma not_isComplement_empty_left : ¬ IsComplement ∅ T :=
fun h ↦ by simpa [eq_comm (a := ∅)] using h.mul_eq
@[to_additive (attr := simp)]
lemma not_isComplement_empty_right : ¬ IsComplement S ∅ :=
fun h ↦ by simpa [eq_comm (a := ∅)] using h.mul_eq
@[to_additive]
lemma IsComplement.nonempty_left (hst : IsComplement S T) : S.Nonempty := by
contrapose! hst; simp [hst]
@[to_additive]
lemma IsComplement.nonempty_right (hst : IsComplement S T) : T.Nonempty := by
contrapose! hst; simp [hst]
@[to_additive] lemma IsComplement.pairwiseDisjoint_smul (hst : IsComplement S T) :
S.PairwiseDisjoint (· • T) := fun a ha b hb hab ↦ disjoint_iff_forall_ne.2 <| by
rintro _ ⟨c, hc, rfl⟩ _ ⟨d, hd, rfl⟩
exact hst.1.ne (a₁ := (⟨a, ha⟩, ⟨c, hc⟩)) (a₂:= (⟨b, hb⟩, ⟨d, hd⟩)) (by simp [hab])
@[to_additive AddSubgroup.IsComplement.card_mul_card]
lemma IsComplement.card_mul_card (h : IsComplement S T) : Nat.card S * Nat.card T = Nat.card G :=
(Nat.card_prod _ _).symm.trans <| Nat.card_congr <| Equiv.ofBijective _ h
@[to_additive]
theorem isComplement'_top_bot : IsComplement' (⊤ : Subgroup G) ⊥ :=
isComplement_univ_singleton
@[to_additive]
theorem isComplement'_bot_top : IsComplement' (⊥ : Subgroup G) ⊤ :=
isComplement_singleton_univ
@[to_additive (attr := simp)]
theorem isComplement'_bot_left : IsComplement' ⊥ H ↔ H = ⊤ :=
isComplement_singleton_left.trans coe_eq_univ
@[to_additive (attr := simp)]
theorem isComplement'_bot_right : IsComplement' H ⊥ ↔ H = ⊤ :=
isComplement_singleton_right.trans coe_eq_univ
@[to_additive (attr := simp)]
theorem isComplement'_top_left : IsComplement' ⊤ H ↔ H = ⊥ :=
isComplement_univ_left.trans coe_eq_singleton
@[to_additive (attr := simp)]
theorem isComplement'_top_right : IsComplement' H ⊤ ↔ H = ⊥ :=
isComplement_univ_right.trans coe_eq_singleton
@[to_additive]
lemma isComplement_iff_existsUnique_inv_mul_mem :
IsComplement S T ↔ ∀ g, ∃! s : S, (s : G)⁻¹ * g ∈ T := by
convert isComplement_iff_existsUnique with g
constructor <;> rintro ⟨x, hx, hx'⟩
· exact ⟨(x, ⟨_, hx⟩), by simp, by aesop⟩
· exact ⟨x.1, by simp [← hx], fun y hy ↦ (Prod.ext_iff.1 <| by simpa using hx' (y, ⟨_, hy⟩)).1⟩
@[to_additive]
lemma isComplement_iff_existsUnique_mul_inv_mem :
IsComplement S T ↔ ∀ g, ∃! t : T, g * (t : G)⁻¹ ∈ S := by
convert isComplement_iff_existsUnique with g
constructor <;> rintro ⟨x, hx, hx'⟩
· exact ⟨(⟨_, hx⟩, x), by simp, by aesop⟩
· exact ⟨x.2, by simp [← hx], fun y hy ↦ (Prod.ext_iff.1 <| by simpa using hx' (⟨_, hy⟩, y)).2⟩
@[to_additive]
lemma isComplement_subgroup_right_iff_existsUnique_quotientGroupMk :
IsComplement S H ↔ ∀ q : G ⧸ H, ∃! s : S, QuotientGroup.mk s.1 = q := by
simp_rw [isComplement_iff_existsUnique_inv_mul_mem, SetLike.mem_coe, ← QuotientGroup.eq,
QuotientGroup.forall_mk]
set_option linter.docPrime false in
@[to_additive]
lemma isComplement_subgroup_left_iff_existsUnique_quotientMk'' :
IsComplement H T ↔
∀ q : Quotient (QuotientGroup.rightRel H), ∃! t : T, Quotient.mk'' t.1 = q := by
simp_rw [isComplement_iff_existsUnique_mul_inv_mem, SetLike.mem_coe,
← QuotientGroup.rightRel_apply, ← Quotient.eq'', Quotient.forall]
@[to_additive]
lemma isComplement_subgroup_right_iff_bijective :
IsComplement S H ↔ Bijective (S.restrict (QuotientGroup.mk : G → G ⧸ H)) :=
isComplement_subgroup_right_iff_existsUnique_quotientGroupMk.trans
(bijective_iff_existsUnique (S.restrict QuotientGroup.mk)).symm
@[to_additive]
lemma isComplement_subgroup_left_iff_bijective :
IsComplement H T ↔
Bijective (T.restrict (Quotient.mk'' : G → Quotient (QuotientGroup.rightRel H))) :=
isComplement_subgroup_left_iff_existsUnique_quotientMk''.trans
(bijective_iff_existsUnique (T.restrict Quotient.mk'')).symm
@[to_additive]
lemma IsComplement.card_left (h : IsComplement S H) : Nat.card S = H.index :=
Nat.card_congr <| .ofBijective _ <| isComplement_subgroup_right_iff_bijective.mp h
@[to_additive]
theorem IsComplement.ncard_left (h : IsComplement S H) : S.ncard = H.index := by
rw [← Nat.card_coe_set_eq, h.card_left]
@[to_additive]
lemma IsComplement.card_right (h : IsComplement H T) : Nat.card T = H.index :=
Nat.card_congr <| (Equiv.ofBijective _ <| isComplement_subgroup_left_iff_bijective.mp h).trans <|
QuotientGroup.quotientRightRelEquivQuotientLeftRel H
@[to_additive]
theorem IsComplement.ncard_right (h : IsComplement H T) : T.ncard = H.index := by
rw [← Nat.card_coe_set_eq, h.card_right]
@[to_additive]
lemma isComplement_range_left {f : G ⧸ H → G} (hf : ∀ q, ↑(f q) = q) :
IsComplement (range f) H := by
rw [isComplement_subgroup_right_iff_bijective]
refine ⟨?_, fun q ↦ ⟨⟨f q, q, rfl⟩, hf q⟩⟩
rintro ⟨-, q₁, rfl⟩ ⟨-, q₂, rfl⟩ h
exact Subtype.ext <| congr_arg f <| ((hf q₁).symm.trans h).trans (hf q₂)
@[to_additive]
lemma isComplement_range_right {f : Quotient (QuotientGroup.rightRel H) → G}
(hf : ∀ q, Quotient.mk'' (f q) = q) : IsComplement H (range f) := by
rw [isComplement_subgroup_left_iff_bijective]
refine ⟨?_, fun q ↦ ⟨⟨f q, q, rfl⟩, hf q⟩⟩
rintro ⟨-, q₁, rfl⟩ ⟨-, q₂, rfl⟩ h
exact Subtype.ext <| congr_arg f <| ((hf q₁).symm.trans h).trans (hf q₂)
@[to_additive]
lemma exists_isComplement_left (H : Subgroup G) (g : G) : ∃ S, IsComplement S H ∧ g ∈ S := by
classical
refine ⟨Set.range (Function.update Quotient.out _ g), isComplement_range_left fun q ↦ ?_,
QuotientGroup.mk g, Function.update_self (Quotient.mk'' g) g Quotient.out⟩
by_cases hq : q = Quotient.mk'' g
· exact hq.symm ▸ congr_arg _ (Function.update_self (Quotient.mk'' g) g Quotient.out)
· refine Function.update_of_ne ?_ g Quotient.out ▸ q.out_eq'
exact hq
@[to_additive]
lemma exists_isComplement_right (H : Subgroup G) (g : G) :
∃ T, IsComplement H T ∧ g ∈ T := by
classical
refine ⟨Set.range (Function.update Quotient.out _ g), isComplement_range_right fun q ↦ ?_,
Quotient.mk'' g, Function.update_self (Quotient.mk'' g) g Quotient.out⟩
by_cases hq : q = Quotient.mk'' g
· exact hq.symm ▸ congr_arg _ (Function.update_self (Quotient.mk'' g) g Quotient.out)
· refine Function.update_of_ne ?_ g Quotient.out ▸ q.out_eq'
exact hq
/-- Given two subgroups `H' ⊆ H`, there exists a left transversal to `H'` inside `H`. -/
@[to_additive /-- Given two subgroups `H' ⊆ H`, there exists a transversal to `H'` inside `H` -/]
lemma exists_left_transversal_of_le {H' H : Subgroup G} (h : H' ≤ H) :
∃ S : Set G, S * H' = H ∧ Nat.card S * Nat.card H' = Nat.card H := by
let H'' : Subgroup H := H'.comap H.subtype
have : H' = H''.map H.subtype := by simp [H'', h]
rw [this]
obtain ⟨S, cmem, -⟩ := H''.exists_isComplement_left 1
refine ⟨H.subtype '' S, ?_, ?_⟩
· have : H.subtype '' (S * H'') = H.subtype '' S * H''.map H.subtype := image_mul H.subtype
rw [← this, cmem.mul_eq]
simp
· rw [← cmem.card_mul_card]
refine congr_arg₂ (· * ·) ?_ ?_ <;>
exact Nat.card_congr (Equiv.Set.image _ _ <| subtype_injective H).symm
/-- Given two subgroups `H' ⊆ H`, there exists a right transversal to `H'` inside `H`. -/
@[to_additive /-- Given two subgroups `H' ⊆ H`, there exists a transversal to `H'` inside `H` -/]
lemma exists_right_transversal_of_le {H' H : Subgroup G} (h : H' ≤ H) :
∃ S : Set G, H' * S = H ∧ Nat.card H' * Nat.card S = Nat.card H := by
let H'' : Subgroup H := H'.comap H.subtype
have : H' = H''.map H.subtype := by simp [H'', h]
rw [this]
obtain ⟨S, cmem, -⟩ := H''.exists_isComplement_right 1
refine ⟨H.subtype '' S, ?_, ?_⟩
· have : H.subtype '' (H'' * S) = H''.map H.subtype * H.subtype '' S := image_mul H.subtype
rw [← this, cmem.mul_eq]
simp
· have : Nat.card H'' * Nat.card S = Nat.card H := cmem.card_mul_card
rw [← this]
refine congr_arg₂ (· * ·) ?_ ?_ <;>
exact Nat.card_congr (Equiv.Set.image _ _ <| subtype_injective H).symm
namespace IsComplement
/-- The equivalence `G ≃ S × T`, such that the inverse is `(*) : S × T → G` -/
noncomputable def equiv {S T : Set G} (hST : IsComplement S T) : G ≃ S × T :=
(Equiv.ofBijective (fun x : S × T => x.1.1 * x.2.1) hST).symm
variable (hST : IsComplement S T) (hHT : IsComplement H T) (hSK : IsComplement S K)
@[simp] theorem equiv_symm_apply (x : S × T) : (hST.equiv.symm x : G) = x.1.1 * x.2.1 := rfl
@[simp]
theorem equiv_fst_mul_equiv_snd (g : G) : ↑(hST.equiv g).fst * (hST.equiv g).snd = g :=
(Equiv.ofBijective (fun x : S × T => x.1.1 * x.2.1) hST).right_inv g
theorem equiv_fst_eq_mul_inv (g : G) : ↑(hST.equiv g).fst = g * ((hST.equiv g).snd : G)⁻¹ :=
eq_mul_inv_of_mul_eq (hST.equiv_fst_mul_equiv_snd g)
theorem equiv_snd_eq_inv_mul (g : G) : ↑(hST.equiv g).snd = ((hST.equiv g).fst : G)⁻¹ * g :=
eq_inv_mul_of_mul_eq (hST.equiv_fst_mul_equiv_snd g)
theorem equiv_fst_eq_iff_leftCosetEquivalence {g₁ g₂ : G} :
(hSK.equiv g₁).fst = (hSK.equiv g₂).fst ↔ LeftCosetEquivalence K g₁ g₂ := by
rw [LeftCosetEquivalence, leftCoset_eq_iff]
constructor
· intro h
rw [← hSK.equiv_fst_mul_equiv_snd g₂, ← hSK.equiv_fst_mul_equiv_snd g₁, ← h,
mul_inv_rev, ← mul_assoc, inv_mul_cancel_right, ← coe_inv, ← coe_mul]
exact Subtype.property _
· intro h
apply (isComplement_iff_existsUnique_inv_mul_mem.1 hSK g₁).unique
· -- This used to be `simp [...]` before https://github.com/leanprover/lean4/pull/2644
rw [equiv_fst_eq_mul_inv]; simp
· rw [SetLike.mem_coe, ← mul_mem_cancel_right h]
-- This used to be `simp [...]` before https://github.com/leanprover/lean4/pull/2644
rw [equiv_fst_eq_mul_inv]; simp [← mul_assoc]
theorem equiv_snd_eq_iff_rightCosetEquivalence {g₁ g₂ : G} :
(hHT.equiv g₁).snd = (hHT.equiv g₂).snd ↔ RightCosetEquivalence H g₁ g₂ := by
rw [RightCosetEquivalence, rightCoset_eq_iff]
constructor
· intro h
rw [← hHT.equiv_fst_mul_equiv_snd g₂, ← hHT.equiv_fst_mul_equiv_snd g₁, ← h,
mul_inv_rev, mul_assoc, mul_inv_cancel_left, ← coe_inv, ← coe_mul]
exact Subtype.property _
· intro h
apply (isComplement_iff_existsUnique_mul_inv_mem.1 hHT g₁).unique
· -- This used to be `simp [...]` before https://github.com/leanprover/lean4/pull/2644
rw [equiv_snd_eq_inv_mul]; simp
· rw [SetLike.mem_coe, ← mul_mem_cancel_left h]
-- This used to be `simp [...]` before https://github.com/leanprover/lean4/pull/2644
rw [equiv_snd_eq_inv_mul, mul_assoc]; simp
theorem leftCosetEquivalence_equiv_fst (g : G) :
LeftCosetEquivalence K g ((hSK.equiv g).fst : G) := by
-- This used to be `simp [...]` before https://github.com/leanprover/lean4/pull/2644
rw [equiv_fst_eq_mul_inv]; simp [LeftCosetEquivalence, leftCoset_eq_iff]
theorem rightCosetEquivalence_equiv_snd (g : G) :
RightCosetEquivalence H g ((hHT.equiv g).snd : G) := by
-- This used to be `simp [...]` before https://github.com/leanprover/lean4/pull/2644
rw [RightCosetEquivalence, rightCoset_eq_iff, equiv_snd_eq_inv_mul]; simp
theorem equiv_fst_eq_self_of_mem_of_one_mem {g : G} (h1 : 1 ∈ T) (hg : g ∈ S) :
(hST.equiv g).fst = ⟨g, hg⟩ := by
have : hST.equiv.symm (⟨g, hg⟩, ⟨1, h1⟩) = g := by
rw [equiv, Equiv.ofBijective]; simp
conv_lhs => rw [← this, Equiv.apply_symm_apply]
theorem equiv_snd_eq_self_of_mem_of_one_mem {g : G} (h1 : 1 ∈ S) (hg : g ∈ T) :
(hST.equiv g).snd = ⟨g, hg⟩ := by
have : hST.equiv.symm (⟨1, h1⟩, ⟨g, hg⟩) = g := by
rw [equiv, Equiv.ofBijective]; simp
conv_lhs => rw [← this, Equiv.apply_symm_apply]
theorem equiv_snd_eq_one_of_mem_of_one_mem {g : G} (h1 : 1 ∈ T) (hg : g ∈ S) :
(hST.equiv g).snd = ⟨1, h1⟩ := by
ext
rw [equiv_snd_eq_inv_mul, equiv_fst_eq_self_of_mem_of_one_mem _ h1 hg, inv_mul_cancel]
theorem equiv_fst_eq_one_of_mem_of_one_mem {g : G} (h1 : 1 ∈ S) (hg : g ∈ T) :
(hST.equiv g).fst = ⟨1, h1⟩ := by
ext
rw [equiv_fst_eq_mul_inv, equiv_snd_eq_self_of_mem_of_one_mem _ h1 hg, mul_inv_cancel]
theorem equiv_mul_right (g : G) (k : K) :
hSK.equiv (g * k) = ((hSK.equiv g).fst, (hSK.equiv g).snd * k) := by
have : (hSK.equiv (g * k)).fst = (hSK.equiv g).fst :=
hSK.equiv_fst_eq_iff_leftCosetEquivalence.2
(by simp [LeftCosetEquivalence, leftCoset_eq_iff])
ext
· rw [this]
· rw [coe_mul, equiv_snd_eq_inv_mul, this, equiv_snd_eq_inv_mul, mul_assoc]
theorem equiv_mul_right_of_mem {g k : G} (h : k ∈ K) :
hSK.equiv (g * k) = ((hSK.equiv g).fst, (hSK.equiv g).snd * ⟨k, h⟩) :=
equiv_mul_right _ g ⟨k, h⟩
theorem equiv_mul_left (h : H) (g : G) :
hHT.equiv (h * g) = (h * (hHT.equiv g).fst, (hHT.equiv g).snd) := by
have : (hHT.equiv (h * g)).2 = (hHT.equiv g).2 := hHT.equiv_snd_eq_iff_rightCosetEquivalence.2 ?_
· ext
· rw [coe_mul, equiv_fst_eq_mul_inv, this, equiv_fst_eq_mul_inv, mul_assoc]
· rw [this]
· simp [RightCosetEquivalence, ← smul_smul]
theorem equiv_mul_left_of_mem {h g : G} (hh : h ∈ H) :
hHT.equiv (h * g) = (⟨h, hh⟩ * (hHT.equiv g).fst, (hHT.equiv g).snd) :=
equiv_mul_left _ ⟨h, hh⟩ g
theorem equiv_one (hs1 : 1 ∈ S) (ht1 : 1 ∈ T) :
hST.equiv 1 = (⟨1, hs1⟩, ⟨1, ht1⟩) := by
rw [Equiv.apply_eq_iff_eq_symm_apply]; simp [equiv]
theorem equiv_fst_eq_self_iff_mem {g : G} (h1 : 1 ∈ T) :
((hST.equiv g).fst : G) = g ↔ g ∈ S := by
constructor
· intro h
rw [← h]
exact Subtype.prop _
· intro h
rw [hST.equiv_fst_eq_self_of_mem_of_one_mem h1 h]
theorem equiv_snd_eq_self_iff_mem {g : G} (h1 : 1 ∈ S) :
((hST.equiv g).snd : G) = g ↔ g ∈ T := by
constructor
· intro h
rw [← h]
exact Subtype.prop _
· intro h
rw [hST.equiv_snd_eq_self_of_mem_of_one_mem h1 h]
theorem coe_equiv_fst_eq_one_iff_mem {g : G} (h1 : 1 ∈ S) :
((hST.equiv g).fst : G) = 1 ↔ g ∈ T := by
rw [equiv_fst_eq_mul_inv, mul_inv_eq_one, eq_comm, equiv_snd_eq_self_iff_mem _ h1]
theorem coe_equiv_snd_eq_one_iff_mem {g : G} (h1 : 1 ∈ T) :
((hST.equiv g).snd : G) = 1 ↔ g ∈ S := by
rw [equiv_snd_eq_inv_mul, inv_mul_eq_one, equiv_fst_eq_self_iff_mem _ h1]
/-- A left transversal is in bijection with left cosets. -/
@[to_additive /-- A left transversal is in bijection with left cosets. -/]
noncomputable def leftQuotientEquiv (hS : IsComplement S H) : G ⧸ H ≃ S :=
(Equiv.ofBijective _ (isComplement_subgroup_right_iff_bijective.mp hS)).symm
/-- A left transversal is finite iff the subgroup has finite index. -/
@[to_additive /-- A left transversal is finite iff the subgroup has finite index. -/]
theorem finite_left_iff (h : IsComplement S H) : Finite S ↔ H.FiniteIndex := by
rw [← h.leftQuotientEquiv.finite_iff]
exact ⟨fun _ ↦ finiteIndex_of_finite_quotient, fun _ ↦ finite_quotient_of_finiteIndex⟩
@[to_additive]
lemma finite_left [H.FiniteIndex] (hS : IsComplement S H) : S.Finite := hS.finite_left_iff.2 ‹_›
@[to_additive]
theorem quotientGroupMk_leftQuotientEquiv (hS : IsComplement S H) (q : G ⧸ H) :
Quotient.mk'' (leftQuotientEquiv hS q : G) = q :=
hS.leftQuotientEquiv.symm_apply_apply q
@[to_additive]
theorem leftQuotientEquiv_apply {f : G ⧸ H → G} (hf : ∀ q, (f q : G ⧸ H) = q) (q : G ⧸ H) :
(leftQuotientEquiv (isComplement_range_left hf) q : G) = f q := by
refine (Subtype.ext_iff.mp ?_).trans (Subtype.coe_mk (f q) ⟨q, rfl⟩)
exact (leftQuotientEquiv (isComplement_range_left hf)).apply_eq_iff_eq_symm_apply.mpr (hf q).symm
/-- A left transversal can be viewed as a function mapping each element of the group
to the chosen representative from that left coset. -/
@[to_additive /-- A left transversal can be viewed as a function mapping each element of the group
to the chosen representative from that left coset. -/]
noncomputable def toLeftFun (hS : IsComplement S H) : G → S := leftQuotientEquiv hS ∘ Quotient.mk''
@[to_additive]
theorem inv_toLeftFun_mul_mem (hS : IsComplement S H) (g : G) :
(toLeftFun hS g : G)⁻¹ * g ∈ H :=
QuotientGroup.leftRel_apply.mp <| Quotient.exact' <| quotientGroupMk_leftQuotientEquiv _ _
@[to_additive]
theorem inv_mul_toLeftFun_mem (hS : IsComplement S H) (g : G) :
g⁻¹ * toLeftFun hS g ∈ H :=
(congr_arg (· ∈ H) (by rw [mul_inv_rev, inv_inv])).mp (H.inv_mem (inv_toLeftFun_mul_mem hS g))
/-- A right transversal is in bijection with right cosets. -/
@[to_additive /-- A right transversal is in bijection with right cosets. -/]
noncomputable def rightQuotientEquiv (hT : IsComplement H T) :
Quotient (QuotientGroup.rightRel H) ≃ T :=
(Equiv.ofBijective _ (isComplement_subgroup_left_iff_bijective.mp hT)).symm
/-- A right transversal is finite iff the subgroup has finite index. -/
@[to_additive /-- A right transversal is finite iff the subgroup has finite index. -/]
theorem finite_right_iff (h : IsComplement H T) : Finite T ↔ H.FiniteIndex := by
rw [← h.rightQuotientEquiv.finite_iff,
(QuotientGroup.quotientRightRelEquivQuotientLeftRel H).finite_iff]
exact ⟨fun _ ↦ finiteIndex_of_finite_quotient, fun _ ↦ finite_quotient_of_finiteIndex⟩
@[to_additive]
lemma finite_right [H.FiniteIndex] (hT : IsComplement H T) : T.Finite := hT.finite_right_iff.2 ‹_›
@[to_additive]
theorem mk''_rightQuotientEquiv (hT : IsComplement H T)
(q : Quotient (QuotientGroup.rightRel H)) : Quotient.mk'' (rightQuotientEquiv hT q : G) = q :=
(rightQuotientEquiv hT).symm_apply_apply q
@[to_additive]
theorem rightQuotientEquiv_apply {f : Quotient (QuotientGroup.rightRel H) → G}
(hf : ∀ q, Quotient.mk'' (f q) = q) (q : Quotient (QuotientGroup.rightRel H)) :
(rightQuotientEquiv (isComplement_range_right hf) q : G) = f q := by
refine (Subtype.ext_iff.mp ?_).trans (Subtype.coe_mk (f q) ⟨q, rfl⟩)
exact (rightQuotientEquiv (isComplement_range_right hf)).apply_eq_iff_eq_symm_apply.2 (hf q).symm
/-- A right transversal can be viewed as a function mapping each element of the group
to the chosen representative from that right coset. -/
@[to_additive /-- A right transversal can be viewed as a function mapping each element of the group
to the chosen representative from that right coset. -/]
noncomputable def toRightFun (hT : IsComplement H T) : G → T := rightQuotientEquiv hT ∘ .mk''
@[to_additive]
theorem mul_inv_toRightFun_mem (hT : IsComplement H T) (g : G) :
g * (toRightFun hT g : G)⁻¹ ∈ H :=
QuotientGroup.rightRel_apply.mp <| Quotient.exact' <| mk''_rightQuotientEquiv _ _
@[to_additive]
theorem toRightFun_mul_inv_mem (hT : IsComplement H T) (g : G) :
(toRightFun hT g : G) * g⁻¹ ∈ H :=
(congr_arg (· ∈ H) (by rw [mul_inv_rev, inv_inv])).mp (H.inv_mem (mul_inv_toRightFun_mem hT g))
@[to_additive]
theorem encard_left [H.FiniteIndex] (h : IsComplement S H) : S.encard = H.index := by
rw [← h.finite_left.cast_ncard_eq, h.ncard_left]
@[to_additive]
theorem encard_right [H.FiniteIndex] (h : IsComplement H T) : T.encard = H.index := by
rw [← h.finite_right.cast_ncard_eq, h.ncard_right]
end IsComplement
section Action
open Pointwise MulAction
/-- The collection of left transversals of a subgroup -/
@[to_additive /-- The collection of left transversals of a subgroup. -/]
abbrev LeftTransversal (H : Subgroup G) := {S : Set G // IsComplement S H}
/-- The collection of right transversals of a subgroup -/
@[to_additive /-- The collection of right transversals of a subgroup. -/]
abbrev RightTransversal (H : Subgroup G) := {T : Set G // IsComplement H T}
variable {F : Type*} [Group F] [MulAction F G] [QuotientAction F H]
@[to_additive]
noncomputable instance : MulAction F H.LeftTransversal where
smul f T :=
⟨f • (T : Set G), by
refine isComplement_iff_existsUnique_inv_mul_mem.mpr fun g => ?_
obtain ⟨t, ht1, ht2⟩ := isComplement_iff_existsUnique_inv_mul_mem.mp T.2 (f⁻¹ • g)
refine ⟨⟨f • (t : G), Set.smul_mem_smul_set t.2⟩, ?_, ?_⟩
· exact smul_inv_smul f g ▸ QuotientAction.inv_mul_mem f ht1
· rintro ⟨-, t', ht', rfl⟩ h
replace h := QuotientAction.inv_mul_mem f⁻¹ h
simp only [Subtype.ext_iff, smul_left_cancel_iff, inv_smul_smul] at h ⊢
exact Subtype.ext_iff.mp (ht2 ⟨t', ht'⟩ h)⟩
one_smul T := Subtype.ext (one_smul F (T : Set G))
mul_smul f₁ f₂ T := Subtype.ext (mul_smul f₁ f₂ (T : Set G))
@[to_additive]
theorem smul_toLeftFun (f : F) (S : H.LeftTransversal) (g : G) :
(f • (S.2.toLeftFun g : G)) = (f • S).2.toLeftFun (f • g) :=
Subtype.ext_iff.mp <| @ExistsUnique.unique (↥(f • (S : Set G))) (fun s => (↑s)⁻¹ * f • g ∈ H)
(isComplement_iff_existsUnique_inv_mul_mem.mp (f • S).2 (f • g))
⟨f • (S.2.toLeftFun g : G), Set.smul_mem_smul_set (Subtype.coe_prop _)⟩
((f • S).2.toLeftFun (f • g))
(QuotientAction.inv_mul_mem f (S.2.inv_toLeftFun_mul_mem g))
((f • S).2.inv_toLeftFun_mul_mem (f • g))
@[to_additive]
theorem smul_leftQuotientEquiv (f : F) (S : H.LeftTransversal) (q : G ⧸ H) :
f • (S.2.leftQuotientEquiv q : G) = (f • S).2.leftQuotientEquiv (f • q) :=
Quotient.inductionOn' q fun g => smul_toLeftFun f S g
@[to_additive]
theorem smul_apply_eq_smul_apply_inv_smul (f : F) (S : H.LeftTransversal) (q : G ⧸ H) :
((f • S).2.leftQuotientEquiv q : G) = f • (S.2.leftQuotientEquiv (f⁻¹ • q) : G) := by
rw [smul_leftQuotientEquiv, smul_inv_smul]
end Action
@[to_additive]
instance : Inhabited H.LeftTransversal :=
⟨⟨Set.range Quotient.out, isComplement_range_left Quotient.out_eq'⟩⟩
@[to_additive]
instance : Inhabited H.RightTransversal :=
⟨⟨Set.range Quotient.out, isComplement_range_right Quotient.out_eq'⟩⟩
theorem IsComplement'.isCompl (h : IsComplement' H K) : IsCompl H K := by
refine
⟨disjoint_iff_inf_le.mpr fun g ⟨p, q⟩ =>
let x : H × K := ⟨⟨g, p⟩, 1⟩
let y : H × K := ⟨1, g, q⟩
Subtype.ext_iff.mp
(Prod.ext_iff.mp (show x = y from h.1 ((mul_one g).trans (one_mul g).symm))).1,
codisjoint_iff_le_sup.mpr fun g _ => ?_⟩
obtain ⟨⟨h, k⟩, rfl⟩ := h.2 g
exact Subgroup.mul_mem_sup h.2 k.2
theorem IsComplement'.sup_eq_top (h : IsComplement' H K) : H ⊔ K = ⊤ :=
h.isCompl.sup_eq_top
theorem IsComplement'.disjoint (h : IsComplement' H K) : Disjoint H K :=
h.isCompl.disjoint
theorem IsComplement'.index_eq_card (h : IsComplement' H K) : K.index = Nat.card H :=
h.card_left.symm
/-- If `H` and `K` are complementary with `K` normal, then `G ⧸ K` is isomorphic to `H`. -/
@[simps!]
noncomputable def IsComplement'.QuotientMulEquiv [K.Normal] (h : H.IsComplement' K) :
G ⧸ K ≃* H :=
MulEquiv.symm
{ h.leftQuotientEquiv.symm with
map_mul' := fun _ _ ↦ rfl }
theorem IsComplement.card_mul (h : IsComplement S T) :
Nat.card S * Nat.card T = Nat.card G :=
(Nat.card_prod _ _).symm.trans (Nat.card_eq_of_bijective _ h)
theorem IsComplement'.card_mul (h : IsComplement' H K) :
Nat.card H * Nat.card K = Nat.card G :=
IsComplement.card_mul h
theorem isComplement'_of_disjoint_and_mul_eq_univ (h1 : Disjoint H K)
(h2 : ↑H * ↑K = (Set.univ : Set G)) : IsComplement' H K := by
refine ⟨mul_injective_of_disjoint h1, fun g => ?_⟩
obtain ⟨h, hh, k, hk, hg⟩ := Set.eq_univ_iff_forall.mp h2 g
exact ⟨(⟨h, hh⟩, ⟨k, hk⟩), hg⟩
theorem isComplement'_of_card_mul_and_disjoint [Finite G]
(h1 : Nat.card H * Nat.card K = Nat.card G) (h2 : Disjoint H K) :
IsComplement' H K :=
(Nat.bijective_iff_injective_and_card _).mpr
⟨mul_injective_of_disjoint h2, (Nat.card_prod H K).trans h1⟩
theorem isComplement'_iff_card_mul_and_disjoint [Finite G] :
IsComplement' H K ↔ Nat.card H * Nat.card K = Nat.card G ∧ Disjoint H K :=
⟨fun h => ⟨h.card_mul, h.disjoint⟩, fun h => isComplement'_of_card_mul_and_disjoint h.1 h.2⟩
theorem isComplement'_of_coprime [Finite G]
(h1 : Nat.card H * Nat.card K = Nat.card G)
(h2 : Nat.Coprime (Nat.card H) (Nat.card K)) : IsComplement' H K :=
isComplement'_of_card_mul_and_disjoint h1 (disjoint_iff.mpr (inf_eq_bot_of_coprime h2))
theorem isComplement'_stabilizer {α : Type*} [MulAction G α] (a : α)
(h1 : ∀ h : H, h • a = a → h = 1) (h2 : ∀ g : G, ∃ h : H, h • g • a = a) :
IsComplement' H (MulAction.stabilizer G a) := by
refine isComplement_iff_existsUnique.mpr fun g => ?_
obtain ⟨h, hh⟩ := h2 g
have hh' : (↑h * g) • a = a := by rwa [mul_smul]
refine ⟨⟨h⁻¹, h * g, hh'⟩, inv_mul_cancel_left ↑h g, ?_⟩
rintro ⟨h', g, hg : g • a = a⟩ rfl
specialize h1 (h * h') (by rwa [mul_smul, smul_def h', ← hg, ← mul_smul, hg])
refine Prod.ext (eq_inv_of_mul_eq_one_right h1) (Subtype.ext ?_)
rwa [Subtype.ext_iff, coe_one, coe_mul, ← right_eq_mul, mul_assoc (↑h) (↑h') g] at h1
end Subgroup |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.