Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
174 commits
Select commit Hold shift + click to select a range
a300a09
wip
joelriou Sep 10, 2025
7ceaabe
docstring
joelriou Sep 10, 2025
f0e932e
typos
joelriou Sep 10, 2025
6904a8f
typos
joelriou Sep 10, 2025
f2d5360
fix
joelriou Sep 10, 2025
e4b10d1
feat(CategoryTheory): a set S of objects is a strong generator if any…
joelriou Sep 11, 2025
10f039a
fix
joelriou Sep 11, 2025
4070522
fix
joelriou Sep 11, 2025
22d6d1d
feat(CategoryTheory): canonical colimits
joelriou Sep 11, 2025
6f3b53e
feat(CategoryTheory): dense functors
joelriou Sep 11, 2025
3621cdf
wip
joelriou Sep 11, 2025
1451f14
Merge remote-tracking branch 'origin/strong-generator-of-colimit' int…
joelriou Sep 11, 2025
67b9b21
isStrongGenerator_range_of_isDense
joelriou Sep 11, 2025
0757d2d
feat(CategoryTheory): colimits of objects satisfying a property
joelriou Sep 20, 2025
d6676bd
fix
joelriou Sep 20, 2025
a57afac
typo
joelriou Sep 20, 2025
31376ce
fix
joelriou Sep 20, 2025
fd70884
better syntax
joelriou Sep 20, 2025
73661c2
typo
joelriou Sep 20, 2025
41d6537
fixing imports
joelriou Sep 20, 2025
89f7db3
feat(CategoryTheory): limit presentations
joelriou Sep 21, 2025
34da8ad
Merge branch 'object-property-colimits-of-shape' into object-property…
joelriou Sep 21, 2025
627eb98
wip
joelriou Sep 21, 2025
35c1354
feat(CategoryTheory/ObjectProperty): closure under limits
joelriou Sep 21, 2025
581970c
typo
joelriou Sep 21, 2025
6b20d72
wip
joelriou Sep 21, 2025
b5c6c94
wip
joelriou Sep 21, 2025
f2e0f5c
Merge remote-tracking branch 'origin/master' into object-property-lim…
joelriou Sep 22, 2025
d940d3b
Merge remote-tracking branch 'origin/master' into object-property-lim…
joelriou Sep 22, 2025
54e8d01
wip
joelriou Sep 22, 2025
796f4b0
wip
joelriou Sep 22, 2025
d912563
wip
joelriou Sep 22, 2025
71eea38
wip
joelriou Sep 22, 2025
01df6fa
generalising universes
joelriou Sep 22, 2025
d328e58
wip
joelriou Sep 22, 2025
f7f1478
fixing the build
joelriou Sep 22, 2025
2b7b1ce
fix
joelriou Sep 22, 2025
d3c4a13
fixing the build
joelriou Sep 23, 2025
57c6400
chore(CategoryTheory): split Limits.Presentation
joelriou Sep 23, 2025
14ca7ef
added comment
joelriou Sep 23, 2025
43c5d3b
fix
joelriou Sep 23, 2025
d8abdda
updated Mathlib.lean
joelriou Sep 23, 2025
4a16754
wip
joelriou Sep 23, 2025
ebfbf0b
Merge branch 'split-limits-presentation' into refactor-object-propert…
joelriou Sep 23, 2025
98b8c68
Update Mathlib/CategoryTheory/Limits/Presentation.lean
joelriou Sep 23, 2025
733dbd9
Update Mathlib/CategoryTheory/Limits/Presentation.lean
joelriou Sep 23, 2025
3c9f5e8
Update Mathlib/CategoryTheory/Limits/Presentation.lean
joelriou Sep 23, 2025
cfa5139
Update Mathlib/CategoryTheory/ObjectProperty/ColimitsOfShape.lean
joelriou Sep 23, 2025
8945e38
Merge remote-tracking branch 'origin/master' into object-property-col…
joelriou Sep 23, 2025
579a4cc
removed unnecessary universe
joelriou Sep 23, 2025
37d7868
Merge remote-tracking branch 'origin/master' into limit-presentation
joelriou Sep 23, 2025
316fe41
Merge remote-tracking branch 'origin/limit-presentation' into object-…
joelriou Sep 23, 2025
6e01466
suggestions by chrisflav
joelriou Sep 23, 2025
e55e768
move definitions to a file with fewer imports
joelriou Sep 23, 2025
27e7875
Update Mathlib/CategoryTheory/Limits/Canonical.lean
joelriou Sep 23, 2025
36eba45
Merge remote-tracking branch 'origin/master' into canonical-colimit
joelriou Sep 26, 2025
ce92beb
Merge remote-tracking branch 'origin/master' into object-property-col…
joelriou Sep 26, 2025
97379ae
Update Mathlib/CategoryTheory/ObjectProperty/ColimitsOfShape.lean
joelriou Sep 28, 2025
1d4d02b
Update Mathlib/CategoryTheory/ObjectProperty/ColimitsOfShape.lean
joelriou Sep 28, 2025
a3e86ad
Merge remote-tracking branch 'origin/master' into object-property-col…
joelriou Sep 28, 2025
b0c3cb9
Small.of_le
joelriou Sep 28, 2025
87ad9d8
added docstring
joelriou Sep 28, 2025
e987d4a
Merge branch 'object-property-colimits-of-shape' into object-property…
joelriou Sep 28, 2025
34e7f38
small fixes
joelriou Sep 28, 2025
742c302
Merge remote-tracking branch 'origin/master' into object-property-lim…
joelriou Sep 28, 2025
9e31e42
Merge remote-tracking branch 'origin/master' into object-property-lim…
joelriou Sep 29, 2025
d9ae191
Merge remote-tracking branch 'origin/master' into object-property-lim…
joelriou Oct 2, 2025
10f966a
Merge remote-tracking branch 'origin/object-property-limits-of-shape'…
joelriou Oct 2, 2025
c3622af
Merge remote-tracking branch 'origin/split-limits-presentation' into …
joelriou Oct 2, 2025
db20612
fix
joelriou Oct 2, 2025
042df44
Merge remote-tracking branch 'origin/master' into refactor-object-pro…
joelriou Oct 2, 2025
36bfb71
fixing imports
joelriou Oct 2, 2025
60e563b
Merge remote-tracking branch 'origin/refactor-object-property-closed-…
joelriou Oct 2, 2025
9109d81
Merge remote-tracking branch 'origin/master' into dense-functor
joelriou Oct 5, 2025
5aea955
Merge remote-tracking branch 'origin/master' into split-limits-presen…
joelriou Oct 5, 2025
fba5a70
Merge remote-tracking branch 'origin/split-limits-presentation' into …
joelriou Oct 5, 2025
50e7294
Merge remote-tracking branch 'origin/master' into strong-generator
joelriou Oct 5, 2025
00cd1a8
typo
joelriou Oct 5, 2025
45cb05f
Merge remote-tracking branch 'origin/refactor-object-property-closed-…
joelriou Oct 6, 2025
9a0751d
refactor(CategoryTheory/Generator): use ObjectProperty
joelriou Oct 6, 2025
13098da
fix
joelriou Oct 7, 2025
8189bf8
fix
joelriou Oct 7, 2025
4c41a3a
fix
joelriou Oct 7, 2025
8c8bf90
fix
joelriou Oct 7, 2025
bf53e9d
fix
joelriou Oct 7, 2025
03da717
feat(CategoryTheory): the opposite of a property of objects
joelriou Oct 7, 2025
079c5ab
fix
joelriou Oct 7, 2025
81d5a0e
Merge remote-tracking branch 'origin/master' into canonical-colimit
joelriou Oct 7, 2025
950f503
use pointwise left Kan extensions
joelriou Oct 7, 2025
69bd04e
typo
joelriou Oct 7, 2025
6c2e6ee
Merge remote-tracking branch 'origin/refactor-isseparating' into stro…
joelriou Oct 7, 2025
33a42d7
wip
joelriou Oct 7, 2025
86cba62
Merge remote-tracking branch 'origin/strong-generator' into strong-ge…
joelriou Oct 7, 2025
9c37792
fix
joelriou Oct 7, 2025
5f0fefe
better name
joelriou Oct 7, 2025
75f8e57
Merge remote-tracking branch 'origin/canonical-colimit' into dense-fu…
joelriou Oct 7, 2025
be9237b
Apply suggestion from @chrisflav
joelriou Oct 7, 2025
9a5146d
Apply suggestion from @chrisflav
joelriou Oct 7, 2025
3a0923c
op_monotone
joelriou Oct 7, 2025
f2cbc1b
better names
joelriou Oct 7, 2025
0688e80
Merge remote-tracking branch 'origin/refactor-isseparating-prerequisi…
joelriou Oct 7, 2025
6ce7bc4
fix
joelriou Oct 7, 2025
63524b2
fix
joelriou Oct 7, 2025
2500706
Merge remote-tracking branch 'origin/master' into refactor-isseparating
joelriou Oct 8, 2025
e585c37
Merge remote-tracking branch 'origin/master' into split-limits-presen…
joelriou Oct 8, 2025
8056afb
Merge remote-tracking branch 'origin/master' into refactor-isseparating
joelriou Oct 11, 2025
cfa5594
Merge remote-tracking branch 'origin/refactor-isseparating' into stro…
joelriou Oct 11, 2025
5bdcd3c
fix
joelriou Oct 11, 2025
2fa0344
Merge remote-tracking branch 'origin/strong-generator' into strong-ge…
joelriou Oct 11, 2025
09eec3f
wip
joelriou Oct 11, 2025
854a78b
Merge remote-tracking branch 'origin/master' into split-limits-presen…
joelriou Oct 11, 2025
552c1ab
Merge remote-tracking branch 'origin/split-limits-presentation' into …
joelriou Oct 11, 2025
8dd48c2
Merge remote-tracking branch 'origin/refactor-object-property-closed-…
joelriou Oct 11, 2025
1681b22
Merge remote-tracking branch 'origin/master' into canonical-colimit
joelriou Oct 12, 2025
9ffe338
Merge remote-tracking branch 'origin/strong-generator-of-colimit' int…
joelriou Oct 12, 2025
0638741
Merge remote-tracking branch 'origin/canonical-colimit' into dense-fu…
joelriou Oct 12, 2025
185a679
fix
joelriou Oct 12, 2025
97d64f8
fix
joelriou Oct 12, 2025
e763701
chore(CategoryTheory/Presentable): cleaning up HasCardinalFilteredGen…
joelriou Oct 12, 2025
52e7c0e
Merge remote-tracking branch 'origin/master' into object-property-lim…
joelriou Oct 13, 2025
7412fde
Merge remote-tracking branch 'origin/master' into refactor-object-pro…
joelriou Oct 13, 2025
6ec9b89
Apply suggestion from @joelriou
joelriou Oct 13, 2025
59c5327
wip
joelriou Oct 15, 2025
bbd2dba
wip
joelriou Oct 15, 2025
408a8b1
wip
joelriou Oct 15, 2025
89a50d8
wip
joelriou Oct 15, 2025
aab450c
mostly done
joelriou Oct 16, 2025
be4e3ff
whitespace
joelriou Oct 16, 2025
1b28b7a
typo
joelriou Oct 16, 2025
3356032
wip
joelriou Oct 16, 2025
d02c37f
wip
joelriou Oct 16, 2025
c2dc61c
wip
joelriou Oct 16, 2025
34775f4
sorry free
joelriou Oct 16, 2025
a721f3c
wip
joelriou Oct 16, 2025
6da7d95
fix
joelriou Oct 16, 2025
84436ae
fixed references.bib
joelriou Oct 16, 2025
5ed0d36
Merge remote-tracking branch 'origin/master' into refactor-object-pro…
joelriou Oct 16, 2025
72af181
cleaning up
joelriou Oct 16, 2025
3827cdd
cleaning up
joelriou Oct 17, 2025
d0a2a09
feat(SetTheory): more API for HasCardinalLT
joelriou Oct 17, 2025
1abd47e
feat(CategoryTheory): κ-filtered categories are stable under products
joelriou Oct 17, 2025
f33c54b
stacks tags
joelriou Oct 17, 2025
1130f7d
Merge remote-tracking branches 'origin/has-cardinal-lt-operations' an…
joelriou Oct 17, 2025
ba18e31
fix
joelriou Oct 17, 2025
c37429b
cleaning up
joelriou Oct 17, 2025
432e1b9
feat(Order/Category): partial orders with order embeddings as morphisms
joelriou Oct 19, 2025
2facfab
feat(Order/Category): PartOrdEmb has filtering colimits
joelriou Oct 19, 2025
ff653e1
sorry free
joelriou Oct 20, 2025
a8d9e19
Merge remote-tracking branch 'origin/master' into refactor-object-pro…
joelriou Oct 20, 2025
a5eca07
Merge remote-tracking branch 'origin/refactor-object-property-closed-…
joelriou Oct 20, 2025
8465feb
Merge remote-tracking branch 'origin/master' into refactor-isseparating
joelriou Oct 20, 2025
d66500e
Merge remote-tracking branch 'origin/refactor-isseparating' into stro…
joelriou Oct 20, 2025
122ee58
Merge remote-tracking branch 'origin/strong-generator' into strong-ge…
joelriou Oct 20, 2025
6a97e77
Merge remote-tracking branch 'origin/strong-generator-of-colimit' int…
joelriou Oct 20, 2025
8813a7f
Merge remote-tracking branch 'origin/dense-functor' into refactor-are…
joelriou Oct 20, 2025
25d09d5
Merge remote-tracking branch 'origin/object-property-limits-closure' …
joelriou Oct 20, 2025
01f1e21
Merge remote-tracking branch 'origin/master' into refactor-object-pro…
joelriou Oct 25, 2025
6755b2b
apply (config := { allowSynthFailures := true })
joelriou Oct 25, 2025
fa01e0c
removed unnecessary line
joelriou Oct 25, 2025
be9f65b
Update Mathlib/CategoryTheory/Limits/MorphismProperty.lean
joelriou Oct 27, 2025
cd54e27
Merge remote-tracking branch 'origin/refactor-object-property-closed-…
joelriou Oct 27, 2025
5ca0c28
Merge remote-tracking branch 'origin/master' into object-property-lim…
joelriou Oct 27, 2025
f54dc73
Merge remote-tracking branch 'origin/master' into strong-generator
joelriou Oct 27, 2025
fc280dd
removed braces
joelriou Oct 27, 2025
b25562b
Merge remote-tracking branch 'origin/master' into object-property-lim…
joelriou Oct 28, 2025
e66de9b
Merge remote-tracking branch 'origin/master' into strong-generator
joelriou Oct 28, 2025
b6c0c05
Merge remote-tracking branch 'origin/strong-generator' into strong-ge…
joelriou Oct 28, 2025
91ba2eb
Merge remote-tracking branch 'origin/strong-generator-of-colimit' int…
joelriou Oct 28, 2025
6468978
Merge remote-tracking branch 'origin/dense-functor' into refactor-are…
joelriou Oct 28, 2025
cbe3498
Merge remote-tracking branch 'origin/object-property-limits-closure' …
joelriou Oct 28, 2025
3ff799f
Merge remote-tracking branch 'origin/cardinal-directed' into partial-…
joelriou Oct 28, 2025
ad4c29d
wip
joelriou Oct 28, 2025
f3158c7
Merge remote-tracking branch 'origin/refactor-are-cardinal-filtered-g…
joelriou Oct 28, 2025
cb64b8c
wip
joelriou Oct 28, 2025
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
7 changes: 7 additions & 0 deletions Mathlib.lean
Original file line number Diff line number Diff line change
Expand Up @@ -2314,6 +2314,7 @@ import Mathlib.CategoryTheory.Functor.Functorial
import Mathlib.CategoryTheory.Functor.Hom
import Mathlib.CategoryTheory.Functor.KanExtension.Adjunction
import Mathlib.CategoryTheory.Functor.KanExtension.Basic
import Mathlib.CategoryTheory.Functor.KanExtension.Dense
import Mathlib.CategoryTheory.Functor.KanExtension.DenseAt
import Mathlib.CategoryTheory.Functor.KanExtension.Pointwise
import Mathlib.CategoryTheory.Functor.KanExtension.Preserves
Expand All @@ -2340,6 +2341,7 @@ import Mathlib.CategoryTheory.Generator.Indization
import Mathlib.CategoryTheory.Generator.Preadditive
import Mathlib.CategoryTheory.Generator.Presheaf
import Mathlib.CategoryTheory.Generator.Sheaf
import Mathlib.CategoryTheory.Generator.StrongGenerator
import Mathlib.CategoryTheory.GlueData
import Mathlib.CategoryTheory.GradedObject
import Mathlib.CategoryTheory.GradedObject.Associator
Expand Down Expand Up @@ -2711,11 +2713,13 @@ import Mathlib.CategoryTheory.Noetherian
import Mathlib.CategoryTheory.ObjectProperty.Basic
import Mathlib.CategoryTheory.ObjectProperty.ClosedUnderIsomorphisms
import Mathlib.CategoryTheory.ObjectProperty.ColimitsOfShape
import Mathlib.CategoryTheory.ObjectProperty.CompleteLattice
import Mathlib.CategoryTheory.ObjectProperty.ContainsZero
import Mathlib.CategoryTheory.ObjectProperty.EpiMono
import Mathlib.CategoryTheory.ObjectProperty.Extensions
import Mathlib.CategoryTheory.ObjectProperty.FullSubcategory
import Mathlib.CategoryTheory.ObjectProperty.Ind
import Mathlib.CategoryTheory.ObjectProperty.LimitsClosure
import Mathlib.CategoryTheory.ObjectProperty.LimitsOfShape
import Mathlib.CategoryTheory.ObjectProperty.Local
import Mathlib.CategoryTheory.ObjectProperty.Opposite
Expand Down Expand Up @@ -2759,8 +2763,10 @@ 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.CardinalDirectedPoset
import Mathlib.CategoryTheory.Presentable.CardinalFilteredPresentation
import Mathlib.CategoryTheory.Presentable.ColimitPresentation
import Mathlib.CategoryTheory.Presentable.Directed
import Mathlib.CategoryTheory.Presentable.Finite
import Mathlib.CategoryTheory.Presentable.IsCardinalFiltered
import Mathlib.CategoryTheory.Presentable.Limits
Expand Down Expand Up @@ -5113,6 +5119,7 @@ import Mathlib.Order.Category.LinOrd
import Mathlib.Order.Category.NonemptyFinLinOrd
import Mathlib.Order.Category.OmegaCompletePartialOrder
import Mathlib.Order.Category.PartOrd
import Mathlib.Order.Category.PartOrdEmb
import Mathlib.Order.Category.Preord
import Mathlib.Order.Category.Semilat
import Mathlib.Order.Chain
Expand Down
4 changes: 4 additions & 0 deletions Mathlib/CategoryTheory/Comma/Arrow.lean
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ theorem mk_eq (f : Arrow T) : Arrow.mk f.hom = f := by
cases f
rfl

lemma mk_surjective (f : Arrow T) :
∃ (X Y : T) (g : X ⟶ Y), f = Arrow.mk g :=
⟨_, _, f.hom, rfl⟩

theorem mk_injective (A B : T) :
Function.Injective (Arrow.mk : (A ⟶ B) → Arrow T) := fun f g h => by
cases h
Expand Down
14 changes: 13 additions & 1 deletion Mathlib/CategoryTheory/Comma/StructuredArrow/Small.lean
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,20 @@ be used in the proof of the Special Adjoint Functor Theorem.
namespace CategoryTheory

-- morphism levels before object levels. See note [category theory universes].
universe v₁ v₂ u₁ u₂
universe w v₁ v₂ u₁ u₂

variable {C : Type u₁} [Category.{v₁} C] {D : Type u₂} [Category.{v₂} D]

namespace StructuredArrow

variable {S : D} {T : C ⥤ D}

instance [Small.{w} C] [LocallySmall.{w} D] : Small.{w} (StructuredArrow S T) :=
small_of_surjective (f := fun (f : Σ (X : C), S ⟶ T.obj X) ↦ StructuredArrow.mk f.2)
(fun f ↦ by
obtain ⟨X, f, rfl⟩ := f.mk_surjective
exact ⟨⟨X, f⟩, rfl⟩)

instance small_inverseImage_proj_of_locallySmall
{P : ObjectProperty C} [ObjectProperty.Small.{v₁} P] [LocallySmall.{v₁} D] :
ObjectProperty.Small.{v₁} (P.inverseImage (proj S T)) := by
Expand All @@ -45,6 +51,12 @@ namespace CostructuredArrow

variable {S : C ⥤ D} {T : D}

instance [Small.{w} C] [LocallySmall.{w} D] : Small.{w} (CostructuredArrow S T) :=
small_of_surjective (f := fun (f : Σ (X : C), S.obj X ⟶ T) ↦ CostructuredArrow.mk f.2)
(fun f ↦ by
obtain ⟨X, f, rfl⟩ := f.mk_surjective
exact ⟨⟨X, f⟩, rfl⟩)

instance small_inverseImage_proj_of_locallySmall
{P : ObjectProperty C} [ObjectProperty.Small.{v₁} P] [LocallySmall.{v₁} D] :
ObjectProperty.Small.{v₁} (P.inverseImage (proj S T)) := by
Expand Down
26 changes: 12 additions & 14 deletions Mathlib/CategoryTheory/Filtered/Final.lean
Original file line number Diff line number Diff line change
Expand Up @@ -436,24 +436,22 @@ end Pi

section Prod

open IsFiltered in
instance final_fst [IsFilteredOrEmpty C] [IsFiltered D] : (Prod.fst C D).Final := by
apply Functor.final_of_exists_of_isFiltered
· exact fun c => ⟨(c, nonempty.some), ⟨𝟙 c⟩⟩
· intro c ⟨c', d'⟩ f g
exact ⟨(coeq f g, d'), (coeqHom f g, 𝟙 d'), coeq_condition _ _⟩
instance final_fst [IsFiltered D] : (Prod.fst C D).Final := by
let F : D ⥤ Discrete PUnit.{1} := (Functor.const _).obj (Discrete.mk .unit)
have hF : F.Final := Functor.final_of_isFiltered_of_pUnit _
change (Functor.prod (𝟭 C) F ⋙ (prod.rightUnitorEquivalence.{0} C).functor).Final
infer_instance

instance final_snd [IsFiltered C] [IsFilteredOrEmpty D] : (Prod.snd C D).Final :=
instance final_snd [IsFiltered C] : (Prod.snd C D).Final :=
inferInstanceAs ((Prod.braiding C D).functor ⋙ Prod.fst D C).Final

open IsCofiltered in
instance initial_fst [IsCofilteredOrEmpty C] [IsCofiltered D] : (Prod.fst C D).Initial := by
apply Functor.initial_of_exists_of_isCofiltered
· exact fun c => ⟨(c, nonempty.some), ⟨𝟙 c⟩⟩
· intro c ⟨c', d'⟩ f g
exact ⟨(eq f g, d'), (eqHom f g, 𝟙 d'), eq_condition _ _⟩
instance initial_fst [IsCofiltered D] : (Prod.fst C D).Initial := by
let F : D ⥤ Discrete PUnit.{1} := (Functor.const _).obj (Discrete.mk .unit)
have hF : F.Initial := Functor.initial_of_isCofiltered_pUnit _
change (Functor.prod (𝟭 C) F ⋙ (prod.rightUnitorEquivalence.{0} C).functor).Initial
infer_instance

instance initial_snd [IsCofiltered C] [IsCofilteredOrEmpty D] : (Prod.snd C D).Initial :=
instance initial_snd [IsCofiltered C] : (Prod.snd C D).Initial :=
inferInstanceAs ((Prod.braiding C D).functor ⋙ Prod.fst D C).Initial

end Prod
Expand Down
124 changes: 124 additions & 0 deletions Mathlib/CategoryTheory/Functor/KanExtension/Dense.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
/-
Copyright (c) 2025 Joël Riou. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Joël Riou
-/
import Mathlib.CategoryTheory.Functor.KanExtension.DenseAt
import Mathlib.CategoryTheory.Limits.Presheaf
import Mathlib.CategoryTheory.Generator.StrongGenerator

/-!
# Dense functors

A functor `F : C ⥤ D` is dense (`F.IsDense`) if `𝟭 D` is a pointwise
left Kan extension of `F` along itself, i.e. any `Y : D` is the
colimit of all `F.obj X` for all morphisms `F.obj X ⟶ Y` (which
is the condition `F.DenseAt Y`).
When `F` is full, we show that this
is equivalent to saying that the restricted Yoneda functor
`D ⥤ Cᵒᵖ ⥤ Type _` is fully faithful (see the lemma
`Functor.isDense_iff_fullyFaithful_restrictedULiftYoneda`).

We also show that the range of a dense functor is a strong
generator (see `Functor.isStrongGenerator_of_isDense`).

## References

* https://ncatlab.org/nlab/show/dense+subcategory

-/

universe w v₁ v₂ u₁ u₂

namespace CategoryTheory

open Limits Opposite Presheaf

variable {C : Type u₁} {D : Type u₂} [Category.{v₁} C] [Category.{v₂} D]

namespace Functor

/-- A functor `F : C ⥤ D` is dense if any `Y : D` is a canonical colimit
relatively to `F`. -/
class IsDense (F : C ⥤ D) : Prop where
isDenseAt (F) (Y : D) : F.isDenseAt Y

/-- This is a choice of structure `F.DenseAt Y` when `F : C ⥤ D`
is dense, and `Y : D`. -/
noncomputable def denseAt (F : C ⥤ D) [F.IsDense] (Y : D) : F.DenseAt Y :=
(IsDense.isDenseAt F Y).some

lemma isDense_iff_nonempty_isPointwiseLeftKanExtension (F : C ⥤ D) :
F.IsDense ↔
Nonempty ((LeftExtension.mk _ (rightUnitor F).inv).IsPointwiseLeftKanExtension) :=
⟨fun _ ↦ ⟨fun _ ↦ F.denseAt _⟩, fun ⟨h⟩ ↦ ⟨fun _ ↦ ⟨h _⟩⟩⟩

variable (F : C ⥤ D)

instance [F.IsDense] : (restrictedULiftYoneda.{w} F).Faithful where
map_injective h :=
(F.denseAt _).hom_ext' (fun X p ↦ by
simpa using ULift.up_injective (congr_fun (NatTrans.congr_app h (op X)) (ULift.up p)))

instance [F.IsDense] : (restrictedULiftYoneda.{w} F).Full where
map_surjective {Y Z} f := by
let c : Cocone (CostructuredArrow.proj F Y ⋙ F) :=
{ pt := Z
ι :=
{ app g := ((f.app (op g.left)) (ULift.up g.hom)).down
naturality g₁ g₂ φ := by
simpa [uliftFunctor, uliftYoneda,
restrictedULiftYoneda, ← ULift.down_inj] using
(congr_fun (f.naturality φ.left.op) (ULift.up g₂.hom)).symm }}
refine ⟨(F.denseAt Y).desc c, ?_⟩
ext ⟨X⟩ ⟨x⟩
have := (F.denseAt Y).fac c (.mk x)
dsimp [c] at this
simpa using ULift.down_injective this

variable {F} in
lemma IsDense.of_fullyFaithful_restrictedULiftYoneda [F.Full]
(h : (restrictedULiftYoneda.{w} F).FullyFaithful) :
F.IsDense where
isDenseAt Y := by
let φ (s : Cocone (CostructuredArrow.proj F Y ⋙ F)) :
(restrictedULiftYoneda.{w} F).obj Y ⟶ (restrictedULiftYoneda F).obj s.pt :=
{ app := fun ⟨X⟩ ⟨x⟩ ↦ ULift.up (s.ι.app (.mk x))
naturality := by
rintro ⟨X₁⟩ ⟨X₂⟩ ⟨f⟩
ext ⟨x⟩
let α : CostructuredArrow.mk (F.map f ≫ x) ⟶ CostructuredArrow.mk x :=
CostructuredArrow.homMk f
simp [uliftYoneda, ← s.w α, α] }
have hφ (s) (j) : (restrictedULiftYoneda F).map j.hom ≫ φ s =
(restrictedULiftYoneda F).map (s.ι.app j) := by
ext ⟨X⟩ ⟨x⟩
let α : .mk (x ≫ j.hom) ⟶ j := CostructuredArrow.homMk (F.preimage x)
have := s.w α
dsimp [uliftYoneda, φ, α] at this ⊢
rw [← this, map_preimage]
exact
⟨{desc s := (h.preimage (φ s))
fac s j := h.map_injective (by simp [hφ])
uniq s m hm := h.map_injective (by
ext ⟨X⟩ ⟨x⟩
simp [uliftYoneda, φ, ← hm])}⟩

lemma isDense_iff_fullyFaithful_restrictedULiftYoneda [F.Full] :
F.IsDense ↔ Nonempty (restrictedULiftYoneda.{w} F).FullyFaithful :=
⟨fun _ ↦ ⟨FullyFaithful.ofFullyFaithful _⟩,
fun ⟨h⟩ ↦ IsDense.of_fullyFaithful_restrictedULiftYoneda h⟩

open ObjectProperty in
lemma isStrongGenerator_of_isDense [F.IsDense] :
IsStrongGenerator (.ofObj F.obj) :=
(IsStrongGenerator.mk_of_exists_colimitsOfShape.{max u₁ u₂ v₁ v₂} (fun Y ↦ ⟨_, _, ⟨{
ι := _
diag := _
isColimit := (IsColimit.whiskerEquivalence (F.denseAt Y)
((ShrinkHoms.equivalence _).symm.trans ((Shrink.equivalence _)).symm))
prop_diag_obj := by simp }⟩⟩))

end Functor

end CategoryTheory
Loading
Loading