Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(CategoryTheory): comma categories are accessible #20267

Open
wants to merge 72 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
25407bb
feat(CategoryTheory): presentable objects
joelriou Dec 13, 2024
e45308d
cleaning up
joelriou Dec 13, 2024
c07745c
typo
joelriou Dec 13, 2024
357684f
added ref
joelriou Dec 13, 2024
da24d3f
fixing imports
joelriou Dec 13, 2024
2ee8c78
Update docs/references.bib
joelriou Dec 13, 2024
05d573b
s/directed/filtered/
joelriou Dec 13, 2024
d48b4f3
cardinality of Arrow
joelriou Dec 13, 2024
fced99b
Merge remote-tracking branch 'origin/category-theory-arrow-cardinal' …
joelriou Dec 13, 2024
7379134
cardinal_le_cardinal_arrow
joelriou Dec 13, 2024
fbd5682
wip
joelriou Dec 13, 2024
aa8ed1c
Merge remote-tracking branch 'origin/category-theory-arrow-cardinal' …
joelriou Dec 13, 2024
f1aef0f
wip
joelriou Dec 13, 2024
ef6c402
wip
joelriou Dec 14, 2024
e71f7ab
better docstring
joelriou Dec 14, 2024
5f62e66
added lemma
joelriou Dec 14, 2024
594353a
Merge remote-tracking branch 'origin/category-theory-arrow-cardinal' …
joelriou Dec 14, 2024
7d53761
wip
joelriou Dec 14, 2024
c4c11d5
wip
joelriou Dec 14, 2024
05f0d4f
Merge remote-tracking branch 'origin/set-theory-has-cardinal-lt' into…
joelriou Dec 14, 2024
79630b3
wip
joelriou Dec 14, 2024
f95d69f
Merge remote-tracking branch 'origin/category-theory-accessible' into…
joelriou Dec 14, 2024
872779e
wip
joelriou Dec 14, 2024
7551261
better docstrings
joelriou Dec 14, 2024
5a8d816
Merge remote-tracking branch 'origin/category-theory-accessible' into…
joelriou Dec 14, 2024
710c427
wip
joelriou Dec 14, 2024
d8e0d6e
wip
joelriou Dec 15, 2024
c6e5a94
wip
joelriou Dec 15, 2024
24891ac
better name
joelriou Dec 15, 2024
ec18456
better proof
joelriou Dec 16, 2024
aa6308d
better docstring
joelriou Dec 16, 2024
8adce59
fixing imports
joelriou Dec 16, 2024
0e8940b
Merge remote-tracking branch 'origin/set-theory-has-cardinal-lt' into…
joelriou Dec 16, 2024
072f464
Merge remote-tracking branch 'origin/set-theory-has-cardinal-lt' into…
joelriou Dec 16, 2024
544c923
fix
joelriou Dec 16, 2024
e5199dc
wip
joelriou Dec 16, 2024
c5b79fe
cleaing up
joelriou Dec 16, 2024
aa56c74
wip
joelriou Dec 16, 2024
a1dce35
fix
joelriou Dec 16, 2024
bb53a92
fix
joelriou Dec 16, 2024
f187b1d
Merge remote-tracking branch 'origin/category-theory-is-cardinal-filt…
joelriou Dec 16, 2024
c66fd0f
wip
joelriou Dec 16, 2024
6471fa0
fix
joelriou Dec 16, 2024
08ee1bc
fixing imports
joelriou Dec 16, 2024
07e6a53
Merge remote-tracking branch 'origin/category-theory-parallel-maps' i…
joelriou Dec 16, 2024
7ef7e07
Merge remote-tracking branch 'origin/category-theory-is-cardinal-filt…
joelriou Dec 16, 2024
c41fdab
better docstring
joelriou Dec 16, 2024
e8c7e60
Merge remote-tracking branch 'origin/category-theory-accessible' into…
joelriou Dec 16, 2024
6736d81
fix
joelriou Dec 16, 2024
2e4ae0d
fixing imports
joelriou Dec 16, 2024
634efe7
Merge remote-tracking branch 'origin/category-theory-accessible' into…
joelriou Dec 16, 2024
f11dc45
Merge remote-tracking branch 'origin' into category-theory-accessible
joelriou Dec 26, 2024
df79ff1
fix
joelriou Dec 26, 2024
077572f
Merge remote-tracking branch 'origin/category-theory-accessible' into…
joelriou Dec 26, 2024
4713c29
wip
joelriou Dec 26, 2024
231364b
Merge remote-tracking branch 'origin' into category-theory-accessible
joelriou Dec 26, 2024
724ab4a
s/IsAccessible/IsCardinalAccessible/
joelriou Dec 26, 2024
ec52a3f
Merge remote-tracking branch 'origin/category-theory-accessible' into…
joelriou Dec 26, 2024
8304643
fix
joelriou Dec 26, 2024
059b583
Merge remote-tracking branch 'origin/category-theory-accessible2' int…
joelriou Dec 26, 2024
7cce429
HasCardinalFilteredColimits
joelriou Dec 26, 2024
b9df1cc
Merge remote-tracking branch 'origin/category-theory-accessible' into…
joelriou Dec 26, 2024
5861578
Merge remote-tracking branch 'origin/category-theory-accessible2' int…
joelriou Dec 26, 2024
b4b5e70
fix
joelriou Dec 26, 2024
bcf2d2f
fixed universes
joelriou Dec 26, 2024
306fdf5
Merge remote-tracking branch 'origin/category-theory-accessible2' int…
joelriou Dec 26, 2024
6881b3b
wip
joelriou Dec 27, 2024
159e05d
wip
joelriou Dec 27, 2024
e71fceb
wip
joelriou Dec 27, 2024
9b993a6
wip
joelriou Dec 27, 2024
bebe433
wip
joelriou Dec 27, 2024
8b9474e
wip
joelriou Dec 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Mathlib.lean
Original file line number Diff line number Diff line change
Expand Up @@ -1692,6 +1692,7 @@ import Mathlib.CategoryTheory.CofilteredSystem
import Mathlib.CategoryTheory.CommSq
import Mathlib.CategoryTheory.Comma.Arrow
import Mathlib.CategoryTheory.Comma.Basic
import Mathlib.CategoryTheory.Comma.CardinalArrow
import Mathlib.CategoryTheory.Comma.Final
import Mathlib.CategoryTheory.Comma.LocallySmall
import Mathlib.CategoryTheory.Comma.Over
Expand Down Expand Up @@ -2080,6 +2081,13 @@ import Mathlib.CategoryTheory.Preadditive.Yoneda.Basic
import Mathlib.CategoryTheory.Preadditive.Yoneda.Injective
import Mathlib.CategoryTheory.Preadditive.Yoneda.Limits
import Mathlib.CategoryTheory.Preadditive.Yoneda.Projective
import Mathlib.CategoryTheory.Presentable.Basic
import Mathlib.CategoryTheory.Presentable.CardinalFilteredPresentation
import Mathlib.CategoryTheory.Presentable.Comma
import Mathlib.CategoryTheory.Presentable.IsCardinalFiltered
import Mathlib.CategoryTheory.Presentable.Limits
import Mathlib.CategoryTheory.Presentable.LocallyPresentable
import Mathlib.CategoryTheory.Presentable.ParallelMaps
import Mathlib.CategoryTheory.Products.Associator
import Mathlib.CategoryTheory.Products.Basic
import Mathlib.CategoryTheory.Products.Bifunctor
Expand Down Expand Up @@ -4705,6 +4713,7 @@ import Mathlib.SetTheory.Cardinal.ENat
import Mathlib.SetTheory.Cardinal.Finite
import Mathlib.SetTheory.Cardinal.Finsupp
import Mathlib.SetTheory.Cardinal.Free
import Mathlib.SetTheory.Cardinal.HasCardinalLT
import Mathlib.SetTheory.Cardinal.SchroederBernstein
import Mathlib.SetTheory.Cardinal.Subfield
import Mathlib.SetTheory.Cardinal.ToNat
Expand Down
21 changes: 21 additions & 0 deletions Mathlib/CategoryTheory/Comma/Arrow.lean
Original file line number Diff line number Diff line change
Expand Up @@ -333,4 +333,25 @@ def Arrow.isoOfNatIso {C D : Type*} [Category C] [Category D] {F G : C ⥤ D} (e
(f : Arrow C) : F.mapArrow.obj f ≅ G.mapArrow.obj f :=
Arrow.isoMk (e.app f.left) (e.app f.right)

variable (T)

/-- `Arrow T` is equivalent to a sigma type. -/
@[simps!]
def Arrow.equivSigma :
Arrow T ≃ Σ (X Y : T), X ⟶ Y where
toFun f := ⟨_, _, f.hom⟩
invFun x := Arrow.mk x.2.2
left_inv _ := rfl
right_inv _ := rfl

/-- The equivalence `Arrow (Discrete S) ≃ S`. -/
def Arrow.discreteEquiv (S : Type u) : Arrow (Discrete S) ≃ S where
toFun f := f.left.as
invFun s := Arrow.mk (𝟙 (Discrete.mk s))
left_inv := by
rintro ⟨⟨_⟩, ⟨_⟩, f⟩
obtain rfl := Discrete.eq_of_hom f
rfl
right_inv _ := rfl

end CategoryTheory
121 changes: 121 additions & 0 deletions Mathlib/CategoryTheory/Comma/CardinalArrow.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
/-
Copyright (c) 2024 Joël Riou. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Joël Riou
-/

import Mathlib.CategoryTheory.Comma.Arrow
import Mathlib.CategoryTheory.FinCategory.Basic
import Mathlib.CategoryTheory.EssentiallySmall
import Mathlib.Data.Set.Finite.Basic
import Mathlib.SetTheory.Cardinal.HasCardinalLT

/-!
# Cardinal of Arrow

We obtain various results about the cardinality of `Arrow C`. For example,
If `A` is a (small) category, `Arrow C` is finite iff `FinCategory C` holds.

-/

universe w w' v u

namespace CategoryTheory

lemma Arrow.finite_iff (C : Type u) [SmallCategory C] :
Finite (Arrow C) ↔ Nonempty (FinCategory C) := by
constructor
· intro
refine ⟨?_, fun a b ↦ ?_⟩
· have := Finite.of_injective (fun (a : C) ↦ Arrow.mk (𝟙 a))
(fun _ _ ↦ congr_arg Comma.left)
apply Fintype.ofFinite
· have := Finite.of_injective (fun (f : a ⟶ b) ↦ Arrow.mk f)
(fun f g h ↦ by
change (Arrow.mk f).hom = (Arrow.mk g).hom
congr)
apply Fintype.ofFinite
· rintro ⟨_⟩
have := Fintype.ofEquiv _ (Arrow.equivSigma C).symm
infer_instance

instance Arrow.finite {C : Type u} [SmallCategory C] [FinCategory C] :
Finite (Arrow C) := by
rw [Arrow.finite_iff]
exact ⟨inferInstance⟩

/-- The bijection `Arrow Cᵒᵖ ≃ Arrow C`. -/
def Arrow.opEquiv (C : Type u) [Category.{v} C] : Arrow Cᵒᵖ ≃ Arrow C where
toFun f := Arrow.mk f.hom.unop
invFun g := Arrow.mk g.hom.op
left_inv _ := rfl
right_inv _ := rfl

@[simp]
lemma hasCardinal_arrow_op_iff (C : Type u) [Category.{v} C] (κ : Cardinal.{w}) :
HasCardinalLT (Arrow Cᵒᵖ) κ ↔ HasCardinalLT (Arrow C) κ :=
hasCardinalLT_iff_of_equiv (Arrow.opEquiv C) κ

@[simp]
lemma hasCardinalLT_arrow_discrete_iff {X : Type u} (κ : Cardinal.{w}) :
HasCardinalLT (Arrow (Discrete X)) κ ↔ HasCardinalLT X κ :=
hasCardinalLT_iff_of_equiv (Arrow.discreteEquiv X) κ

lemma small_of_small_arrow (C : Type u) [Category.{v} C] [Small.{w} (Arrow C)] :
Small.{w} C :=
small_of_injective (f := fun X ↦ Arrow.mk (𝟙 X)) (fun _ _ h ↦ congr_arg Comma.left h)

lemma locallySmall_of_small_arrow (C : Type u) [Category.{v} C] [Small.{w} (Arrow C)] :
LocallySmall.{w} C where
hom_small X Y :=
small_of_injective (f := fun f ↦ Arrow.mk f) (fun f g h ↦ by
change (Arrow.mk f).hom = (Arrow.mk g).hom
congr)

/-- The bijection `Arrow.{w} (ShrinkHoms C) ≃ Arrow C`. -/
noncomputable def Arrow.shrinkHomsEquiv (C : Type u) [Category.{v} C] [LocallySmall.{w} C] :
Arrow.{w} (ShrinkHoms C) ≃ Arrow C where
toFun := (ShrinkHoms.equivalence C).inverse.mapArrow.obj
invFun := (ShrinkHoms.equivalence C).functor.mapArrow.obj
left_inv _ := by simp [Functor.mapArrow]; rfl
right_inv _ := by simp [Functor.mapArrow]; rfl

-- to be moved
lemma Arrow.ext {C : Type u} [Category.{v} C] {f g : Arrow C}
(h₁ : f.left = g.left) (h₂ : f.right = g.right)
(h₃ : f.hom = eqToHom h₁ ≫ g.hom ≫ eqToHom h₂.symm) : f = g := by
obtain ⟨X, Y, f⟩ := f
obtain ⟨X', Y', g⟩ := g
obtain rfl : X = X' := h₁
obtain rfl : Y = Y' := h₂
obtain rfl : f = g := by simpa using h₃
rfl

/-- The bijection `Arrow (Shrink C) ≃ Arrow C`. -/
noncomputable def Arrow.shrinkEquiv (C : Type u) [Category.{v} C] [Small.{w} C] :
Arrow (Shrink.{w} C) ≃ Arrow C where
toFun := (Shrink.equivalence C).inverse.mapArrow.obj
invFun := (Shrink.equivalence C).functor.mapArrow.obj
left_inv f := Arrow.ext (by simp [Shrink.equivalence])
(by simp [Shrink.equivalence]) (by simp [Shrink.equivalence]; rfl)
right_inv _ := Arrow.ext (by simp [Shrink.equivalence])
(by simp [Shrink.equivalence]) (by simp [Shrink.equivalence])

@[simp]
lemma hasCardinalLT_arrow_shrinkHoms_iff (C : Type u) [Category.{v} C] [LocallySmall.{w'} C]
(κ : Cardinal.{w}) :
HasCardinalLT (Arrow.{w'} (ShrinkHoms C)) κ ↔ HasCardinalLT (Arrow C) κ :=
hasCardinalLT_iff_of_equiv (Arrow.shrinkHomsEquiv C) κ

@[simp]
lemma hasCardinalLT_arrow_shrink_iff (C : Type u) [Category.{v} C] [Small.{w'} C]
(κ : Cardinal.{w}) :
HasCardinalLT (Arrow (Shrink.{w'} C)) κ ↔ HasCardinalLT (Arrow C) κ :=
hasCardinalLT_iff_of_equiv (Arrow.shrinkEquiv C) κ

lemma hasCardinalLT_of_hasCardinalLT_arrow
{C : Type u} [Category.{v} C] {κ : Cardinal.{w}} (h : HasCardinalLT (Arrow C) κ) :
HasCardinalLT C κ :=
h.of_injective (fun X ↦ Arrow.mk (𝟙 X)) (fun _ _ h ↦ congr_arg Comma.left h)

end CategoryTheory
30 changes: 27 additions & 3 deletions Mathlib/CategoryTheory/EssentiallySmall.lean
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ the type `Skeleton C` is `w`-small, and `C` is `w`-locally small.
-/


universe w v v' u u'
universe w w' v v' u u'

open CategoryTheory

Expand Down Expand Up @@ -188,8 +188,32 @@ noncomputable instance [Small.{w} C] : Category.{v} (Shrink.{w} C) :=
InducedCategory.category (equivShrink C).symm

/-- The categorical equivalence between `C` and `Shrink C`, when `C` is small. -/
noncomputable def equivalence [Small.{w} C] : C ≌ Shrink.{w} C :=
(inducedFunctor (equivShrink C).symm).asEquivalence.symm
noncomputable def equivalence [Small.{w} C] : C ≌ Shrink.{w} C where
functor :=
{ obj := equivShrink C
map {X Y} f := by
change (equivShrink C).symm _ ⟶ (equivShrink C).symm _
exact eqToHom (by simp) ≫ f ≫ eqToHom (by simp)
map_comp f g := by
dsimp
erw [Category.assoc, Category.assoc, Category.assoc]
rw [eqToHom_trans_assoc, eqToHom_refl, Category.id_comp] }
inverse := inducedFunctor (equivShrink C).symm
unitIso := NatIso.ofComponents (fun X ↦ eqToIso (by simp))
counitIso := NatIso.ofComponents (fun X ↦ eqToIso (by simp)) (fun {X Y} f ↦ by
dsimp
erw [Category.assoc, Category.assoc, eqToHom_trans, eqToHom_refl, Category.comp_id]
· rfl
· simp)
functor_unitIso_comp X := by
dsimp
simp only [eqToHom_trans]
exact eqToHom_trans (by simp) _

instance (C : Type u) [Category.{v} C] [Small.{w'} C] [LocallySmall.{w} C] :
LocallySmall.{w} (Shrink.{w'} C) where
hom_small _ _ := small_of_injective
(fun _ _ h ↦ (Shrink.equivalence.{w'} C).inverse.map_injective h)

end Shrink

Expand Down
18 changes: 18 additions & 0 deletions Mathlib/CategoryTheory/Limits/Comma.lean
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,24 @@ instance hasColimitsOfSize [HasColimitsOfSize.{w, w'} A] [HasColimitsOfSize.{w,
[PreservesColimitsOfSize.{w, w'} L] : HasColimitsOfSize.{w, w'} (Comma L R) :=
⟨fun _ _ => inferInstance⟩

instance preservesColimitsOfShape_fst
[HasColimitsOfShape J A] [HasColimitsOfShape J B]
[PreservesColimitsOfShape J L] :
PreservesColimitsOfShape J (Comma.fst L R) where
preservesColimit {F} :=
preservesColimit_of_preserves_colimit_cocone (h :=
coconeOfPreservesIsColimit F (colimit.isColimit _) (colimit.isColimit _))
((colimit.isColimit _))

instance preservesColimitsOfShape_snd
[HasColimitsOfShape J A] [HasColimitsOfShape J B]
[PreservesColimitsOfShape J L] :
PreservesColimitsOfShape J (Comma.snd L R) where
preservesColimit {F} :=
preservesColimit_of_preserves_colimit_cocone (h :=
coconeOfPreservesIsColimit F (colimit.isColimit _) (colimit.isColimit _))
((colimit.isColimit _))

end Comma

namespace Arrow
Expand Down
29 changes: 25 additions & 4 deletions Mathlib/CategoryTheory/Limits/TypesFiltered.lean
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,16 @@ noncomputable def isColimitOf (t : Cocone F) (hsurj : ∀ x : t.pt, ∃ i xi, x

variable [IsFilteredOrEmpty J]

/-- Recognizing filtered colimits of types. The injectivity condition here is
slightly easier to check as compared to `isColimitOf`. -/
noncomputable def isColimitOf' (t : Cocone F) (hsurj : ∀ x : t.pt, ∃ i xi, x = t.ι.app i xi)
(hinj : ∀ i x y, t.ι.app i x = t.ι.app i y → ∃ (k : _) (f : i ⟶ k), F.map f x = F.map f y) :
IsColimit t :=
isColimitOf _ _ hsurj (fun i j xi xj h ↦ by
obtain ⟨k, g, hg⟩ := hinj (IsFiltered.max i j) (F.map (IsFiltered.leftToMax i j) xi)
(F.map (IsFiltered.rightToMax i j) xj) (by simp [FunctorToTypes.naturality, h])
exact ⟨k, IsFiltered.leftToMax i j ≫ g, IsFiltered.rightToMax i j ≫ g, by simpa using hg⟩)

protected theorem rel_equiv : _root_.Equivalence (FilteredColimit.Rel.{v, u} F) where
refl x := ⟨x.1, 𝟙 x.1, 𝟙 x.1, rfl⟩
symm := fun ⟨k, f, g, h⟩ => ⟨k, g, f, h.symm⟩
Expand All @@ -99,9 +109,7 @@ protected theorem rel_eq_eqvGen_quot_rel :
· rw [← (FilteredColimit.rel_equiv F).eqvGen_iff]
exact Relation.EqvGen.mono (rel_of_quot_rel F)

variable [HasColimit F]

theorem colimit_eq_iff_aux {i j : J} {xi : F.obj i} {xj : F.obj j} :
theorem colimit_eq_iff_aux [HasColimit F] {i j : J} {xi : F.obj i} {xj : F.obj j} :
(colimitCocone F).ι.app i xi = (colimitCocone F).ι.app j xj ↔
FilteredColimit.Rel.{v, u} F ⟨i, xi⟩ ⟨j, xj⟩ := by
dsimp
Expand All @@ -110,6 +118,7 @@ theorem colimit_eq_iff_aux {i j : J} {xi : F.obj i} {xj : F.obj j} :

theorem isColimit_eq_iff {t : Cocone F} (ht : IsColimit t) {i j : J} {xi : F.obj i} {xj : F.obj j} :
t.ι.app i xi = t.ι.app j xj ↔ ∃ (k : _) (f : i ⟶ k) (g : j ⟶ k), F.map f xi = F.map g xj := by
have : HasColimit F := ⟨_, ht⟩
refine Iff.trans ?_ (colimit_eq_iff_aux F)
rw [← (IsColimit.coconePointUniqueUpToIso ht (colimitCoconeIsColimit F)).toEquiv.injective.eq_iff]
convert Iff.rfl
Expand All @@ -118,7 +127,19 @@ theorem isColimit_eq_iff {t : Cocone F} (ht : IsColimit t) {i j : J} {xi : F.obj
· exact (congrFun
(IsColimit.comp_coconePointUniqueUpToIso_hom ht (colimitCoconeIsColimit F) _) xj).symm

theorem colimit_eq_iff {i j : J} {xi : F.obj i} {xj : F.obj j} :
variable {F} in
theorem isColimit_eq_iff' {t : Cocone F} (ht : IsColimit t) {i : J} (x y : F.obj i) :
t.ι.app i x = t.ι.app i y ↔ ∃ (j : _) (f : i ⟶ j), F.map f x = F.map f y := by
rw [isColimit_eq_iff _ ht]
constructor
· rintro ⟨k, f, g, h⟩
refine ⟨IsFiltered.coeq f g, f ≫ IsFiltered.coeqHom f g, ?_⟩
conv_rhs => rw [IsFiltered.coeq_condition]
simp only [FunctorToTypes.map_comp_apply, h]
· rintro ⟨j, f, h⟩
exact ⟨j, f, f, h⟩

theorem colimit_eq_iff [HasColimit F] {i j : J} {xi : F.obj i} {xj : F.obj j} :
colimit.ι F i xi = colimit.ι F j xj ↔
∃ (k : _) (f : i ⟶ k) (g : j ⟶ k), F.map f xi = F.map g xj :=
isColimit_eq_iff _ (colimit.isColimit F)
Expand Down
Loading
Loading