Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 0 additions & 4 deletions Poly/ForMathlib/CategoryTheory/Comma/Over/Basic.lean
Original file line numberDiff line numberDiff line change
Expand Up@@ -35,10 +35,6 @@ lemma homMk_comp'_assoc {X Y Z W : T} (f : X ⟶ Y) (g : Y ⟶ Z) (h : Z ⟶ W)
lemma homMk_id {X B : T} (f : X ⟶ B) (h : 𝟙 X ≫ f = f) : homMk (𝟙 X) h = 𝟙 (mk f) :=
rfl

@[simp]
theorem mkIdTerminal_from_left {B : T} (U : Over B) : (mkIdTerminal.from U).left = U.hom := by
simp [mkIdTerminal, CostructuredArrow.mkIdTerminal, Limits.IsTerminal.from, Functor.preimage]

/-- `Over.Sigma Y U` is a shorthand for `(Over.map Y.hom).obj U`.
This is a category-theoretic analogue of `Sigma` for types. -/
abbrev Sigma {X : T} (Y : Over X) (U : Over (Y.left)) : Over X :=
Expand Down
12 changes: 3 additions & 9 deletions Poly/ForMathlib/CategoryTheory/Comma/Over/Pullback.lean
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,7 +9,7 @@ import Mathlib.CategoryTheory.Limits.Constructions.Over.Basic
import Mathlib.CategoryTheory.Monad.Products
import Poly.ForMathlib.CategoryTheory.Comma.Over.Basic
import Poly.ForMathlib.CategoryTheory.NatTrans
import Poly.ForMathlib.CategoryTheory.Limits.Shapes.Pullback.CommSq
import Poly.ForMathlib.CategoryTheory.Limits.Shapes.Pullback.IsPullback.Basic

noncomputable section

Expand All@@ -19,7 +19,7 @@ namespace CategoryTheory

open Category Limits Comonad MonoidalCategory CartesianMonoidalCategory

attribute [local instance] CartesianMonoidalCategory.ofFiniteProducts
attribute [local instance] CartesianMonoidalCategory.ofHasFiniteProducts

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

Expand DownExpand Up@@ -211,7 +211,7 @@ lemma star_map [HasBinaryProducts C] {X : C} {Y Z : C} (f : Y ⟶ Z) :
instance [HasBinaryProducts C] (X : C) : (forget X).IsLeftAdjoint :=
⟨_, ⟨forgetAdjStar X⟩⟩

attribute [local instance] CartesianMonoidalCategory.ofFiniteProducts
attribute [local instance] CartesianMonoidalCategory.ofHasFiniteProducts

lemma whiskerLeftProdMapId [HasFiniteLimits C] {X : C} {A A' : C} {g : A ⟶ A'} :
X ◁ g = prod.map (𝟙 X) g := by
Expand DownExpand Up@@ -298,12 +298,6 @@ def starIsoToOverTerminal [HasTerminal C] [HasBinaryProducts C] :

variable {C}

/-- A natural isomorphism between the functors `star X` and `star Y ⋙ pullback f`
for any morphism `f : X ⟶ Y`. -/
def starPullbackIsoStar [HasBinaryProducts C] [HasPullbacks C] {X Y : C} (f : X ⟶ Y) :
star Y ⋙ pullback f ≅ star X :=
conjugateIsoEquiv ((mapPullbackAdj f).comp (forgetAdjStar Y)) (forgetAdjStar X) (mapForget f)

/-- The functor `Over.pullback f : Over Y ⥤ Over X` is naturally isomorphic to
`Over.star : Over Y ⥤ Over (Over.mk f)` post-composed with the
iterated slice equivlanece `Over (Over.mk f) ⥤ Over X`. -/
Expand Down
33 changes: 17 additions & 16 deletions Poly/ForMathlib/CategoryTheory/Comma/Over/Sections.lean
Original file line numberDiff line numberDiff line change
Expand Up@@ -28,7 +28,7 @@ variable {C : Type u₁} [Category.{v₁} C]

attribute [local instance] hasBinaryProducts_of_hasTerminal_and_pullbacks
attribute [local instance] hasFiniteProducts_of_has_binary_and_terminal
attribute [local instance] CartesianMonoidalCategory.ofFiniteProducts
attribute [local instance] CartesianMonoidalCategory.ofHasFiniteProducts

section

Expand DownExpand Up@@ -69,11 +69,11 @@ end

variable [HasTerminal C] [HasPullbacks C]

variable (I : C) [Exponentiable I]
variable (I : C) [Closed I]

/-- The first leg of a cospan constructing a pullback diagram in `C` used to define `sections` . -/
def curryId : ⊤_ C ⟶ (I ⟹ I) :=
CartesianClosed.curry (fst I (⊤_ C))
MonoidalClosed.curry (fst I (⊤_ C))

variable {I}

Expand All@@ -90,14 +90,14 @@ pullback diagram:
⊤_ C ----> I ⟹ I
```-/
abbrev sectionsObj (X : Over I) : C :=
Limits.pullback (curryId I) ((exp I).map X.hom)
Limits.pullback (curryId I) ((ihom I).map X.hom)

/-- The functoriality of `sectionsObj`. -/
def sectionsMap {X X' : Over I} (u : X ⟶ X') :
sectionsObj X ⟶ sectionsObj X' := by
fapply pullback.map
· exact 𝟙 _
· exact (exp I).map u.left
· exact (ihom I).map u.left
· exact 𝟙 _
· simp only [comp_id, id_comp]
· simp only [comp_id, ← Functor.map_comp, w]
Expand DownExpand Up@@ -130,29 +130,30 @@ variable {I}
in `C`. See `sectionsCurry`. -/
def sectionsCurryAux {X : Over I} {A : C} (u : (star I).obj A ⟶ X) :
A ⟶ (I ⟹ X.left) :=
CartesianClosed.curry (u.left)
MonoidalClosed.curry (u.left)

/-- The currying operation `Hom ((star I).obj A) X → Hom A (I ⟹ X.left)`. -/
def sectionsCurry {X : Over I} {A : C} (u : (star I).obj A ⟶ X) :
A ⟶ (sections I).obj X := by
apply pullback.lift (terminal.from A)
(CartesianClosed.curry ((prodIsoTensorObj _ _).inv ≫ u.left)) (uncurry_injective _)
rw [uncurry_natural_left]
simp [curryId, uncurry_natural_right, uncurry_curry]
(MonoidalClosed.curry ((prodIsoTensorObj _ _).inv ≫ u.left))
(MonoidalClosed.uncurry_injective _)
rw [MonoidalClosed.uncurry_natural_left]
simp [curryId, MonoidalClosed.uncurry_natural_right, MonoidalClosed.uncurry_curry]

/-- The uncurrying operation `Hom A (section X) → Hom ((star I).obj A) X`. -/
def sectionsUncurry {X : Over I} {A : C} (v : A ⟶ (sections I).obj X) :
(star I).obj A ⟶ X := by
let v₂ : A ⟶ (I ⟹ X.left) := v ≫ pullback.snd ..
have w : terminal.from A ≫ (curryId I) = v₂ ≫ (exp I).map X.hom := by
have w : terminal.from A ≫ (curryId I) = v₂ ≫ (ihom I).map X.hom := by
rw [IsTerminal.hom_ext terminalIsTerminal (terminal.from A ) (v ≫ (pullback.fst ..))]
simp [v₂, pullback.condition]
dsimp [curryId] at w
have w' := homEquiv_naturality_right_square (F := MonoidalCategory.tensorLeft I)
(adj := exp.adjunction I) _ _ _ _ w
simp [CartesianClosed.curry] at w'
refine Over.homMk ((prodIsoTensorObj I A).hom ≫ CartesianClosed.uncurry v₂) ?_
· dsimp [CartesianClosed.uncurry] at *
(adj := ihom.adjunction I) _ _ _ _ w
simp [MonoidalClosed.curry] at w'
refine Over.homMk ((prodIsoTensorObj I A).hom ≫ MonoidalClosed.uncurry v₂) ?_
· dsimp [MonoidalClosed.uncurry] at *
rw [Category.assoc, ← w']
simp [star_obj_hom]

Expand DownExpand Up@@ -188,13 +189,13 @@ def coreHomEquiv : CoreHomEquiv (star I) (sections I) where
simp only [star_map]
rw [← Over.homMk_comp] -- note: in a newer version of mathlib this is `Over.homMk_eta`
congr 1
simp [CartesianClosed.uncurry_natural_left]
simp [MonoidalClosed.uncurry_natural_left]
homEquiv_naturality_right := by
intro A X' X u g
dsimp [sectionsCurry, sectionsUncurry, curryId]
apply pullback.hom_ext (IsTerminal.hom_ext terminalIsTerminal _ _)
simp [sectionsMap, curryId]
rw [← CartesianClosed.curry_natural_right, Category.assoc]
rw [← MonoidalClosed.curry_natural_right, Category.assoc]

variable (I)

Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,7 +3,7 @@ Copyright (c) 2025 Wojciech Nawrocki. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Wojciech Nawrocki
-/
import Mathlib.CategoryTheory.Limits.Shapes.Pullback.CommSq
import Mathlib.CategoryTheory.Limits.Shapes.Pullback.IsPullback.Basic
import Poly.ForMathlib.CategoryTheory.CommSq

namespace CategoryTheory.Functor
Expand Down
21 changes: 11 additions & 10 deletions Poly/ForMathlib/CategoryTheory/LocallyCartesianClosed/Basic.lean
Original file line numberDiff line numberDiff line change
Expand Up@@ -67,7 +67,7 @@ open CategoryTheory Category MonoidalCategory CartesianMonoidalCategory Limits F

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

attribute [local instance] CartesianMonoidalCategory.ofFiniteProducts
attribute [local instance] CartesianMonoidalCategory.ofHasFiniteProducts

/-- A morphism `f : I ⟶ J` is exponentiable if the pullback functor `Over J ⥤ Over I`
has a right adjoint. -/
Expand DownExpand Up@@ -179,7 +179,7 @@ instance isMultiplicative : (ExponentiableMorphism (C:= C)).IsMultiplicative whe
/-- A morphism with a pushforward is an exponentiable object in the slice category. -/
def exponentiableOverMk [HasFiniteWidePullbacks C] {X I : C} (f : X ⟶ I)
[ExponentiableMorphism f] :
Exponentiable (Over.mk f) where
Closed (Over.mk f) where
rightAdj := pullback f ⋙ pushforward f
adj := by
apply ofNatIsoLeft _ _
Expand All@@ -192,7 +192,7 @@ morphism `X.hom`.
Here the pushforward functor along a morphism `f : I ⟶ J` is defined using the section functor
`Over (Over.mk f) ⥤ Over J`.
-/
def ofOverExponentiable [HasFiniteWidePullbacks C] {I : C} (X : Over I) [Exponentiable X] :
def ofOverExponentiable [HasFiniteWidePullbacks C] {I : C} (X : Over I) [Closed X] :
ExponentiableMorphism X.hom :=
⟨X.iteratedSliceEquiv.inverse ⋙ sections X, ⟨by
refine ofNatIsoLeft (Adjunction.comp ?_ ?_) (starIteratedSliceForwardIsoPullback X.hom)
Expand All@@ -217,7 +217,7 @@ variable {C} [HasFiniteWidePullbacks C] [HasPushforwards C]
/-- In a category where pushforwards exists along all morphisms, every slice category `Over I` is
cartesian closed. -/
instance cartesianClosedOver (I : C) :
CartesianClosed (Over I) where
MonoidalClosed (Over I) where
closed X := @exponentiableOverMk _ _ _ _ _ _ X.hom (HasPushforwards.exponentiable X.hom)

end HasPushforwards
Expand All@@ -226,13 +226,13 @@ namespace CartesianClosedOver

open Over Reindex IsIso CartesianClosed HasPushforwards ExponentiableMorphism

variable {C} [HasFiniteWidePullbacks C] {I J : C} [CartesianClosed (Over J)]
variable {C} [HasFiniteWidePullbacks C] {I J : C} [MonoidalClosed (Over J)]

instance (f : I ⟶ J) : ExponentiableMorphism f :=
ExponentiableMorphism.ofOverExponentiable (Over.mk f)

/-- A category with cartesian closed slices has pushforwards along all morphisms. -/
instance hasPushforwards [Π (I : C), CartesianClosed (Over I)] : HasPushforwards C where
instance hasPushforwards [Π (I : C), MonoidalClosed (Over I)] : HasPushforwards C where
exponentiable f := ExponentiableMorphism.ofOverExponentiable (Over.mk f)

end CartesianClosedOver
Expand All@@ -242,7 +242,7 @@ is exponentiable and all the slices are cartesian closed. -/
class LocallyCartesianClosed [HasFiniteWidePullbacks C] extends
HasPushforwards C where
/-- every slice category `Over I` is cartesian closed. This is filled in by default. -/
cartesianClosedOver : Π (I : C), CartesianClosed (Over I) := HasPushforwards.cartesianClosedOver
cartesianClosedOver : Π (I : C), MonoidalClosed (Over I) := HasPushforwards.cartesianClosedOver

namespace LocallyCartesianClosed

Expand All@@ -256,7 +256,7 @@ attribute [scoped instance] hasFiniteLimits_of_hasTerminal_and_pullbacks
instance mkOfHasPushforwards [HasPushforwards C] : LocallyCartesianClosed C where

/-- A category with cartesian closed slices is locally cartesian closed. -/
instance mkOfCartesianClosedOver [Π (I : C), CartesianClosed (Over I)] :
instance mkOfCartesianClosedOver [Π (I : C), MonoidalClosed (Over I)] :
LocallyCartesianClosed C where

variable [LocallyCartesianClosed C]
Expand All@@ -282,15 +282,16 @@ abbrev ev' {I : C} (X : Over I) (Y : Over X.left) : Reindex X (Pi X Y) ⟶ Y :=
adj X.hom |>.counit.app Y

/-- A locally cartesian closed category with a terminal object is cartesian closed. -/
def cartesianClosed [HasTerminal C] :
CartesianClosed C := cartesianClosedOfEquiv <| equivOverTerminal C
def monoidalClosed [HasTerminal C] :
MonoidalClosed C := cartesianClosedOfEquiv <| equivOverTerminal C

/-- The slices of a locally cartesian closed category are locally cartesian closed. -/
def overLocallyCartesianClosed (I : C) : LocallyCartesianClosed (Over I) := by
apply (config := { allowSynthFailures:= true}) mkOfCartesianClosedOver
intro X
exact cartesianClosedOfEquiv (C := Over (X.left)) X.iteratedSliceEquiv.symm

open CartesianClosed in
/-- The exponential `X^^A` in the slice category `Over I` is isomorphic to the pushforward of the
pullback of `X` along `A`. -/
def expIso {I : C} (A X : Over I) : Pi A (Reindex A X) ≅ A ⟹ X := Iso.refl _
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
Authors: Sina Hazratpour, Emily Riehl
-/
import Poly.ForMathlib.CategoryTheory.LocallyCartesianClosed.Basic
import Mathlib.CategoryTheory.Limits.Shapes.Pullback.CommSq
import Mathlib.CategoryTheory.Limits.Shapes.Pullback.IsPullback.Basic

/-!
# Beck-Chevalley natural transformations and natural isomorphisms
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -22,10 +22,10 @@ abbrev Psh (C : Type u) [Category.{v} C] : Type (max u (v + 1)) := Cᵒᵖ ⥤ T

variable {C : Type*} [SmallCategory C] [HasTerminal C]

attribute [local instance] CartesianMonoidalCategory.ofFiniteProducts
attribute [local instance] CartesianMonoidalCategory.ofHasFiniteProducts

instance cartesianClosedOver {C : Type u} [Category.{max u v} C] (P : Psh C) :
CartesianClosed (Over P) :=
instance monoidalClosedOver {C : Type u} [Category.{max u v} C] (P : Psh C) :
MonoidalClosed (Over P) :=
cartesianClosedOfEquiv (overEquivPresheafCostructuredArrow P).symm

instance locallyCartesianClosed : LocallyCartesianClosed (Psh C) := by
Expand Down
2 changes: 1 addition & 1 deletion Poly/ForMathlib/CategoryTheory/NatTrans.lean
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,7 +6,7 @@ Authors: Sina Hazratpour

import Mathlib.CategoryTheory.NatTrans
import Mathlib.CategoryTheory.Functor.TwoSquare
import Mathlib.CategoryTheory.Limits.Shapes.Pullback.CommSq
import Mathlib.CategoryTheory.Limits.Shapes.Pullback.IsPullback.Basic

open CategoryTheory Limits IsPullback

Expand Down
4 changes: 3 additions & 1 deletion Poly/ForMathlib/CategoryTheory/PartialProduct.lean
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,7 +3,7 @@ Copyright (c) 2025 Sina Hazratpour. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Sina Hazratpour
-/
import Mathlib.CategoryTheory.Limits.Shapes.Pullback.CommSq
import Mathlib.CategoryTheory.Limits.Shapes.Pullback.IsPullback.Basic
import Mathlib.CategoryTheory.Comma.Over.Pullback
import Poly.ForMathlib.CategoryTheory.Comma.Over.Pullback
import Mathlib.CategoryTheory.Monoidal.Closed.Cartesian
Expand DownExpand Up@@ -100,6 +100,8 @@ structure Fan.Hom (c c' : Fan s X) where

attribute [reassoc (attr := simp)] Fan.Hom.w_left Fan.Hom.w_right

-- TODO: this is taking ages to check since 4.28.0-rc1.
set_option maxHeartbeats 0 in
@[simps]
instance : Category (Fan s X) where
Hom := Fan.Hom
Expand Down
2 changes: 1 addition & 1 deletion Poly/Type/Univariate.lean
Original file line numberDiff line numberDiff line change
Expand Up@@ -189,7 +189,7 @@ def Obj.iget [DecidableEq P.B] {X} [Inhabited X] (x : P X) (i : P.Total) : X :=
@[simp]
theorem iget_map [DecidableEq P.B] [Inhabited X] [Inhabited Y] (x : P X)
(f : X → Y) (i : P.Total) (h : i.1 = x.1) : (P.map f x).iget i = f (x.iget i) := by
simp only [Obj.iget, fst_map, *, dif_pos, eq_self_iff_true]
simp only [Obj.iget, fst_map, *, dif_pos]
cases x
rfl

Expand Down
20 changes: 10 additions & 10 deletions lake-manifest.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,7 +15,7 @@
"type": "git",
"subDir": null,
"scope": "",
"rev": "dd5e5d97469dec395f29661366030566355ad9be",
"rev": "b8dad038b1b3a05b77d6884b15b8db03ec01dca1",
"name": "mathlib",
"manifestFile": "lake-manifest.json",
"inputRev": null,
Expand All@@ -25,7 +25,7 @@
"type": "git",
"subDir": null,
"scope": "leanprover-community",
"rev": "b3dd6c3ebc0a71685e86bea9223be39ea4c299fb",
"rev": "7311586e1a56af887b1081d05e80c11b6c41d212",
"name": "plausible",
"manifestFile": "lake-manifest.json",
"inputRev": "main",
Expand All@@ -45,7 +45,7 @@
"type": "git",
"subDir": null,
"scope": "leanprover-community",
"rev": "cff9dd30f2c161b9efd7c657cafed1f967645890",
"rev": "b5908dbac486279f1133cb937648c63c30b455af",
"name": "importGraph",
"manifestFile": "lake-manifest.json",
"inputRev": "main",
Expand All@@ -55,17 +55,17 @@
"type": "git",
"subDir": null,
"scope": "leanprover-community",
"rev": "ef8377f31b5535430b6753a974d685b0019d0681",
"rev": "6d65c6e0a25b8a52c13c3adeb63ecde3bfbb6294",
"name": "proofwidgets",
"manifestFile": "lake-manifest.json",
"inputRev": "v0.0.84",
"inputRev": "v0.0.86",
"inherited": true,
"configFile": "lakefile.lean"},
{"url": "https://github.com/leanprover-community/aesop",
"type": "git",
"subDir": null,
"scope": "leanprover-community",
"rev": "fa78cf032194308a950a264ed87b422a2a7c1c6c",
"rev": "f08e838d4f9aea519f3cde06260cfb686fd4bab0",
"name": "aesop",
"manifestFile": "lake-manifest.json",
"inputRev": "master",
Expand All@@ -75,7 +75,7 @@
"type": "git",
"subDir": null,
"scope": "leanprover-community",
"rev": "8920dcbb96a4e8bf641fc399ac9c0888e4a6be72",
"rev": "23324752757bf28124a518ec284044c8db79fee5",
"name": "Qq",
"manifestFile": "lake-manifest.json",
"inputRev": "master",
Expand All@@ -85,7 +85,7 @@
"type": "git",
"subDir": null,
"scope": "leanprover-community",
"rev": "dff865b7ee7011518d59abfc101c368293173150",
"rev": "100083c18750b6a9b7553c65f6b052c0a2f6bcb4",
"name": "batteries",
"manifestFile": "lake-manifest.json",
"inputRev": "main",
Expand All@@ -95,10 +95,10 @@
"type": "git",
"subDir": null,
"scope": "leanprover",
"rev": "726b98c53e2da249c1de768fbbbb5e67bc9cef60",
"rev": "28e0856d4424863a85b18f38868c5420c55f9bae",
"name": "Cli",
"manifestFile": "lake-manifest.json",
"inputRev": "v4.27.0-rc1",
"inputRev": "v4.28.0-rc1",
"inherited": true,
"configFile": "lakefile.toml"}],
"name": "Poly",
Expand Down
2 changes: 1 addition & 1 deletion lean-toolchain
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
leanprover/lean4:v4.27.0-rc1
leanprover/lean4:v4.28.0-rc1
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 0 additions & 4 deletions Poly/ForMathlib/CategoryTheory/Comma/Over/Basic.lean
Original file line numberDiff line numberDiff line change
Expand Up@@ -35,10 +35,6 @@ lemma homMk_comp'_assoc {X Y Z W : T} (f : X ⟶ Y) (g : Y ⟶ Z) (h : Z ⟶ W)
lemma homMk_id {X B : T} (f : X ⟶ B) (h : 𝟙 X ≫ f = f) : homMk (𝟙 X) h = 𝟙 (mk f) :=
rfl

@[simp]
theorem mkIdTerminal_from_left {B : T} (U : Over B) : (mkIdTerminal.from U).left = U.hom := by
simp [mkIdTerminal, CostructuredArrow.mkIdTerminal, Limits.IsTerminal.from, Functor.preimage]

/-- `Over.Sigma Y U` is a shorthand for `(Over.map Y.hom).obj U`.
This is a category-theoretic analogue of `Sigma` for types. -/
abbrev Sigma {X : T} (Y : Over X) (U : Over (Y.left)) : Over X :=
Expand Down
12 changes: 3 additions & 9 deletions Poly/ForMathlib/CategoryTheory/Comma/Over/Pullback.lean
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,7 +9,7 @@ import Mathlib.CategoryTheory.Limits.Constructions.Over.Basic
import Mathlib.CategoryTheory.Monad.Products
import Poly.ForMathlib.CategoryTheory.Comma.Over.Basic
import Poly.ForMathlib.CategoryTheory.NatTrans
import Poly.ForMathlib.CategoryTheory.Limits.Shapes.Pullback.CommSq
import Poly.ForMathlib.CategoryTheory.Limits.Shapes.Pullback.IsPullback.Basic

noncomputable section

Expand All@@ -19,7 +19,7 @@ namespace CategoryTheory

open Category Limits Comonad MonoidalCategory CartesianMonoidalCategory

attribute [local instance] CartesianMonoidalCategory.ofFiniteProducts
attribute [local instance] CartesianMonoidalCategory.ofHasFiniteProducts

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

Expand DownExpand Up@@ -211,7 +211,7 @@ lemma star_map [HasBinaryProducts C] {X : C} {Y Z : C} (f : Y ⟶ Z) :
instance [HasBinaryProducts C] (X : C) : (forget X).IsLeftAdjoint :=
⟨_, ⟨forgetAdjStar X⟩⟩

attribute [local instance] CartesianMonoidalCategory.ofFiniteProducts
attribute [local instance] CartesianMonoidalCategory.ofHasFiniteProducts

lemma whiskerLeftProdMapId [HasFiniteLimits C] {X : C} {A A' : C} {g : A ⟶ A'} :
X ◁ g = prod.map (𝟙 X) g := by
Expand DownExpand Up@@ -298,12 +298,6 @@ def starIsoToOverTerminal [HasTerminal C] [HasBinaryProducts C] :

variable {C}

/-- A natural isomorphism between the functors `star X` and `star Y ⋙ pullback f`
for any morphism `f : X ⟶ Y`. -/
def starPullbackIsoStar [HasBinaryProducts C] [HasPullbacks C] {X Y : C} (f : X ⟶ Y) :
star Y ⋙ pullback f ≅ star X :=
conjugateIsoEquiv ((mapPullbackAdj f).comp (forgetAdjStar Y)) (forgetAdjStar X) (mapForget f)

/-- The functor `Over.pullback f : Over Y ⥤ Over X` is naturally isomorphic to
`Over.star : Over Y ⥤ Over (Over.mk f)` post-composed with the
iterated slice equivlanece `Over (Over.mk f) ⥤ Over X`. -/
Expand Down
33 changes: 17 additions & 16 deletions Poly/ForMathlib/CategoryTheory/Comma/Over/Sections.lean
Original file line numberDiff line numberDiff line change
Expand Up@@ -28,7 +28,7 @@ variable {C : Type u₁} [Category.{v₁} C]

attribute [local instance] hasBinaryProducts_of_hasTerminal_and_pullbacks
attribute [local instance] hasFiniteProducts_of_has_binary_and_terminal
attribute [local instance] CartesianMonoidalCategory.ofFiniteProducts
attribute [local instance] CartesianMonoidalCategory.ofHasFiniteProducts

section

Expand DownExpand Up@@ -69,11 +69,11 @@ end

variable [HasTerminal C] [HasPullbacks C]

variable (I : C) [Exponentiable I]
variable (I : C) [Closed I]

/-- The first leg of a cospan constructing a pullback diagram in `C` used to define `sections` . -/
def curryId : ⊤_ C ⟶ (I ⟹ I) :=
CartesianClosed.curry (fst I (⊤_ C))
MonoidalClosed.curry (fst I (⊤_ C))

variable {I}

Expand All@@ -90,14 +90,14 @@ pullback diagram:
⊤_ C ----> I ⟹ I
```-/
abbrev sectionsObj (X : Over I) : C :=
Limits.pullback (curryId I) ((exp I).map X.hom)
Limits.pullback (curryId I) ((ihom I).map X.hom)

/-- The functoriality of `sectionsObj`. -/
def sectionsMap {X X' : Over I} (u : X ⟶ X') :
sectionsObj X ⟶ sectionsObj X' := by
fapply pullback.map
· exact 𝟙 _
· exact (exp I).map u.left
· exact (ihom I).map u.left
· exact 𝟙 _
· simp only [comp_id, id_comp]
· simp only [comp_id, ← Functor.map_comp, w]
Expand DownExpand Up@@ -130,29 +130,30 @@ variable {I}
in `C`. See `sectionsCurry`. -/
def sectionsCurryAux {X : Over I} {A : C} (u : (star I).obj A ⟶ X) :
A ⟶ (I ⟹ X.left) :=
CartesianClosed.curry (u.left)
MonoidalClosed.curry (u.left)

/-- The currying operation `Hom ((star I).obj A) X → Hom A (I ⟹ X.left)`. -/
def sectionsCurry {X : Over I} {A : C} (u : (star I).obj A ⟶ X) :
A ⟶ (sections I).obj X := by
apply pullback.lift (terminal.from A)
(CartesianClosed.curry ((prodIsoTensorObj _ _).inv ≫ u.left)) (uncurry_injective _)
rw [uncurry_natural_left]
simp [curryId, uncurry_natural_right, uncurry_curry]
(MonoidalClosed.curry ((prodIsoTensorObj _ _).inv ≫ u.left))
(MonoidalClosed.uncurry_injective _)
rw [MonoidalClosed.uncurry_natural_left]
simp [curryId, MonoidalClosed.uncurry_natural_right, MonoidalClosed.uncurry_curry]

/-- The uncurrying operation `Hom A (section X) → Hom ((star I).obj A) X`. -/
def sectionsUncurry {X : Over I} {A : C} (v : A ⟶ (sections I).obj X) :
(star I).obj A ⟶ X := by
let v₂ : A ⟶ (I ⟹ X.left) := v ≫ pullback.snd ..
have w : terminal.from A ≫ (curryId I) = v₂ ≫ (exp I).map X.hom := by
have w : terminal.from A ≫ (curryId I) = v₂ ≫ (ihom I).map X.hom := by
rw [IsTerminal.hom_ext terminalIsTerminal (terminal.from A ) (v ≫ (pullback.fst ..))]
simp [v₂, pullback.condition]
dsimp [curryId] at w
have w' := homEquiv_naturality_right_square (F := MonoidalCategory.tensorLeft I)
(adj := exp.adjunction I) _ _ _ _ w
simp [CartesianClosed.curry] at w'
refine Over.homMk ((prodIsoTensorObj I A).hom ≫ CartesianClosed.uncurry v₂) ?_
· dsimp [CartesianClosed.uncurry] at *
(adj := ihom.adjunction I) _ _ _ _ w
simp [MonoidalClosed.curry] at w'
refine Over.homMk ((prodIsoTensorObj I A).hom ≫ MonoidalClosed.uncurry v₂) ?_
· dsimp [MonoidalClosed.uncurry] at *
rw [Category.assoc, ← w']
simp [star_obj_hom]

Expand DownExpand Up@@ -188,13 +189,13 @@ def coreHomEquiv : CoreHomEquiv (star I) (sections I) where
simp only [star_map]
rw [← Over.homMk_comp] -- note: in a newer version of mathlib this is `Over.homMk_eta`
congr 1
simp [CartesianClosed.uncurry_natural_left]
simp [MonoidalClosed.uncurry_natural_left]
homEquiv_naturality_right := by
intro A X' X u g
dsimp [sectionsCurry, sectionsUncurry, curryId]
apply pullback.hom_ext (IsTerminal.hom_ext terminalIsTerminal _ _)
simp [sectionsMap, curryId]
rw [← CartesianClosed.curry_natural_right, Category.assoc]
rw [← MonoidalClosed.curry_natural_right, Category.assoc]

variable (I)

Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,7 +3,7 @@ Copyright (c) 2025 Wojciech Nawrocki. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Wojciech Nawrocki
-/
import Mathlib.CategoryTheory.Limits.Shapes.Pullback.CommSq
import Mathlib.CategoryTheory.Limits.Shapes.Pullback.IsPullback.Basic
import Poly.ForMathlib.CategoryTheory.CommSq

namespace CategoryTheory.Functor
Expand Down
21 changes: 11 additions & 10 deletions Poly/ForMathlib/CategoryTheory/LocallyCartesianClosed/Basic.lean
Original file line numberDiff line numberDiff line change
Expand Up@@ -67,7 +67,7 @@ open CategoryTheory Category MonoidalCategory CartesianMonoidalCategory Limits F

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

attribute [local instance] CartesianMonoidalCategory.ofFiniteProducts
attribute [local instance] CartesianMonoidalCategory.ofHasFiniteProducts

/-- A morphism `f : I ⟶ J` is exponentiable if the pullback functor `Over J ⥤ Over I`
has a right adjoint. -/
Expand DownExpand Up@@ -179,7 +179,7 @@ instance isMultiplicative : (ExponentiableMorphism (C:= C)).IsMultiplicative whe
/-- A morphism with a pushforward is an exponentiable object in the slice category. -/
def exponentiableOverMk [HasFiniteWidePullbacks C] {X I : C} (f : X ⟶ I)
[ExponentiableMorphism f] :
Exponentiable (Over.mk f) where
Closed (Over.mk f) where
rightAdj := pullback f ⋙ pushforward f
adj := by
apply ofNatIsoLeft _ _
Expand All@@ -192,7 +192,7 @@ morphism `X.hom`.
Here the pushforward functor along a morphism `f : I ⟶ J` is defined using the section functor
`Over (Over.mk f) ⥤ Over J`.
-/
def ofOverExponentiable [HasFiniteWidePullbacks C] {I : C} (X : Over I) [Exponentiable X] :
def ofOverExponentiable [HasFiniteWidePullbacks C] {I : C} (X : Over I) [Closed X] :
ExponentiableMorphism X.hom :=
⟨X.iteratedSliceEquiv.inverse ⋙ sections X, ⟨by
refine ofNatIsoLeft (Adjunction.comp ?_ ?_) (starIteratedSliceForwardIsoPullback X.hom)
Expand All@@ -217,7 +217,7 @@ variable {C} [HasFiniteWidePullbacks C] [HasPushforwards C]
/-- In a category where pushforwards exists along all morphisms, every slice category `Over I` is
cartesian closed. -/
instance cartesianClosedOver (I : C) :
CartesianClosed (Over I) where
MonoidalClosed (Over I) where
closed X := @exponentiableOverMk _ _ _ _ _ _ X.hom (HasPushforwards.exponentiable X.hom)

end HasPushforwards
Expand All@@ -226,13 +226,13 @@ namespace CartesianClosedOver

open Over Reindex IsIso CartesianClosed HasPushforwards ExponentiableMorphism

variable {C} [HasFiniteWidePullbacks C] {I J : C} [CartesianClosed (Over J)]
variable {C} [HasFiniteWidePullbacks C] {I J : C} [MonoidalClosed (Over J)]

instance (f : I ⟶ J) : ExponentiableMorphism f :=
ExponentiableMorphism.ofOverExponentiable (Over.mk f)

/-- A category with cartesian closed slices has pushforwards along all morphisms. -/
instance hasPushforwards [Π (I : C), CartesianClosed (Over I)] : HasPushforwards C where
instance hasPushforwards [Π (I : C), MonoidalClosed (Over I)] : HasPushforwards C where
exponentiable f := ExponentiableMorphism.ofOverExponentiable (Over.mk f)

end CartesianClosedOver
Expand All@@ -242,7 +242,7 @@ is exponentiable and all the slices are cartesian closed. -/
class LocallyCartesianClosed [HasFiniteWidePullbacks C] extends
HasPushforwards C where
/-- every slice category `Over I` is cartesian closed. This is filled in by default. -/
cartesianClosedOver : Π (I : C), CartesianClosed (Over I) := HasPushforwards.cartesianClosedOver
cartesianClosedOver : Π (I : C), MonoidalClosed (Over I) := HasPushforwards.cartesianClosedOver

namespace LocallyCartesianClosed

Expand All@@ -256,7 +256,7 @@ attribute [scoped instance] hasFiniteLimits_of_hasTerminal_and_pullbacks
instance mkOfHasPushforwards [HasPushforwards C] : LocallyCartesianClosed C where

/-- A category with cartesian closed slices is locally cartesian closed. -/
instance mkOfCartesianClosedOver [Π (I : C), CartesianClosed (Over I)] :
instance mkOfCartesianClosedOver [Π (I : C), MonoidalClosed (Over I)] :
LocallyCartesianClosed C where

variable [LocallyCartesianClosed C]
Expand All@@ -282,15 +282,16 @@ abbrev ev' {I : C} (X : Over I) (Y : Over X.left) : Reindex X (Pi X Y) ⟶ Y :=
adj X.hom |>.counit.app Y

/-- A locally cartesian closed category with a terminal object is cartesian closed. -/
def cartesianClosed [HasTerminal C] :
CartesianClosed C := cartesianClosedOfEquiv <| equivOverTerminal C
def monoidalClosed [HasTerminal C] :
MonoidalClosed C := cartesianClosedOfEquiv <| equivOverTerminal C

/-- The slices of a locally cartesian closed category are locally cartesian closed. -/
def overLocallyCartesianClosed (I : C) : LocallyCartesianClosed (Over I) := by
apply (config := { allowSynthFailures:= true}) mkOfCartesianClosedOver
intro X
exact cartesianClosedOfEquiv (C := Over (X.left)) X.iteratedSliceEquiv.symm

open CartesianClosed in
/-- The exponential `X^^A` in the slice category `Over I` is isomorphic to the pushforward of the
pullback of `X` along `A`. -/
def expIso {I : C} (A X : Over I) : Pi A (Reindex A X) ≅ A ⟹ X := Iso.refl _
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
Authors: Sina Hazratpour, Emily Riehl
-/
import Poly.ForMathlib.CategoryTheory.LocallyCartesianClosed.Basic
import Mathlib.CategoryTheory.Limits.Shapes.Pullback.CommSq
import Mathlib.CategoryTheory.Limits.Shapes.Pullback.IsPullback.Basic

/-!
# Beck-Chevalley natural transformations and natural isomorphisms
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -22,10 +22,10 @@ abbrev Psh (C : Type u) [Category.{v} C] : Type (max u (v + 1)) := Cᵒᵖ ⥤ T

variable {C : Type*} [SmallCategory C] [HasTerminal C]

attribute [local instance] CartesianMonoidalCategory.ofFiniteProducts
attribute [local instance] CartesianMonoidalCategory.ofHasFiniteProducts

instance cartesianClosedOver {C : Type u} [Category.{max u v} C] (P : Psh C) :
CartesianClosed (Over P) :=
instance monoidalClosedOver {C : Type u} [Category.{max u v} C] (P : Psh C) :
MonoidalClosed (Over P) :=
cartesianClosedOfEquiv (overEquivPresheafCostructuredArrow P).symm

instance locallyCartesianClosed : LocallyCartesianClosed (Psh C) := by
Expand Down
2 changes: 1 addition & 1 deletion Poly/ForMathlib/CategoryTheory/NatTrans.lean
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,7 +6,7 @@ Authors: Sina Hazratpour

import Mathlib.CategoryTheory.NatTrans
import Mathlib.CategoryTheory.Functor.TwoSquare
import Mathlib.CategoryTheory.Limits.Shapes.Pullback.CommSq
import Mathlib.CategoryTheory.Limits.Shapes.Pullback.IsPullback.Basic

open CategoryTheory Limits IsPullback

Expand Down
4 changes: 3 additions & 1 deletion Poly/ForMathlib/CategoryTheory/PartialProduct.lean
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,7 +3,7 @@ Copyright (c) 2025 Sina Hazratpour. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Sina Hazratpour
-/
import Mathlib.CategoryTheory.Limits.Shapes.Pullback.CommSq
import Mathlib.CategoryTheory.Limits.Shapes.Pullback.IsPullback.Basic
import Mathlib.CategoryTheory.Comma.Over.Pullback
import Poly.ForMathlib.CategoryTheory.Comma.Over.Pullback
import Mathlib.CategoryTheory.Monoidal.Closed.Cartesian
Expand DownExpand Up@@ -100,6 +100,8 @@ structure Fan.Hom (c c' : Fan s X) where

attribute [reassoc (attr := simp)] Fan.Hom.w_left Fan.Hom.w_right

-- TODO: this is taking ages to check since 4.28.0-rc1.
set_option maxHeartbeats 0 in
@[simps]
instance : Category (Fan s X) where
Hom := Fan.Hom
Expand Down
2 changes: 1 addition & 1 deletion Poly/Type/Univariate.lean
Original file line numberDiff line numberDiff line change
Expand Up@@ -189,7 +189,7 @@ def Obj.iget [DecidableEq P.B] {X} [Inhabited X] (x : P X) (i : P.Total) : X :=
@[simp]
theorem iget_map [DecidableEq P.B] [Inhabited X] [Inhabited Y] (x : P X)
(f : X → Y) (i : P.Total) (h : i.1 = x.1) : (P.map f x).iget i = f (x.iget i) := by
simp only [Obj.iget, fst_map, *, dif_pos, eq_self_iff_true]
simp only [Obj.iget, fst_map, *, dif_pos]
cases x
rfl

Expand Down
20 changes: 10 additions & 10 deletions lake-manifest.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,7 +15,7 @@
"type": "git",
"subDir": null,
"scope": "",
"rev": "dd5e5d97469dec395f29661366030566355ad9be",
"rev": "b8dad038b1b3a05b77d6884b15b8db03ec01dca1",
"name": "mathlib",
"manifestFile": "lake-manifest.json",
"inputRev": null,
Expand All@@ -25,7 +25,7 @@
"type": "git",
"subDir": null,
"scope": "leanprover-community",
"rev": "b3dd6c3ebc0a71685e86bea9223be39ea4c299fb",
"rev": "7311586e1a56af887b1081d05e80c11b6c41d212",
"name": "plausible",
"manifestFile": "lake-manifest.json",
"inputRev": "main",
Expand All@@ -45,7 +45,7 @@
"type": "git",
"subDir": null,
"scope": "leanprover-community",
"rev": "cff9dd30f2c161b9efd7c657cafed1f967645890",
"rev": "b5908dbac486279f1133cb937648c63c30b455af",
"name": "importGraph",
"manifestFile": "lake-manifest.json",
"inputRev": "main",
Expand All@@ -55,17 +55,17 @@
"type": "git",
"subDir": null,
"scope": "leanprover-community",
"rev": "ef8377f31b5535430b6753a974d685b0019d0681",
"rev": "6d65c6e0a25b8a52c13c3adeb63ecde3bfbb6294",
"name": "proofwidgets",
"manifestFile": "lake-manifest.json",
"inputRev": "v0.0.84",
"inputRev": "v0.0.86",
"inherited": true,
"configFile": "lakefile.lean"},
{"url": "https://github.com/leanprover-community/aesop",
"type": "git",
"subDir": null,
"scope": "leanprover-community",
"rev": "fa78cf032194308a950a264ed87b422a2a7c1c6c",
"rev": "f08e838d4f9aea519f3cde06260cfb686fd4bab0",
"name": "aesop",
"manifestFile": "lake-manifest.json",
"inputRev": "master",
Expand All@@ -75,7 +75,7 @@
"type": "git",
"subDir": null,
"scope": "leanprover-community",
"rev": "8920dcbb96a4e8bf641fc399ac9c0888e4a6be72",
"rev": "23324752757bf28124a518ec284044c8db79fee5",
"name": "Qq",
"manifestFile": "lake-manifest.json",
"inputRev": "master",
Expand All@@ -85,7 +85,7 @@
"type": "git",
"subDir": null,
"scope": "leanprover-community",
"rev": "dff865b7ee7011518d59abfc101c368293173150",
"rev": "100083c18750b6a9b7553c65f6b052c0a2f6bcb4",
"name": "batteries",
"manifestFile": "lake-manifest.json",
"inputRev": "main",
Expand All@@ -95,10 +95,10 @@
"type": "git",
"subDir": null,
"scope": "leanprover",
"rev": "726b98c53e2da249c1de768fbbbb5e67bc9cef60",
"rev": "28e0856d4424863a85b18f38868c5420c55f9bae",
"name": "Cli",
"manifestFile": "lake-manifest.json",
"inputRev": "v4.27.0-rc1",
"inputRev": "v4.28.0-rc1",
"inherited": true,
"configFile": "lakefile.toml"}],
"name": "Poly",
Expand Down
2 changes: 1 addition & 1 deletion lean-toolchain
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
leanprover/lean4:v4.27.0-rc1
leanprover/lean4:v4.28.0-rc1
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 0 additions & 4 deletions Poly/ForMathlib/CategoryTheory/Comma/Over/Basic.lean
Original file line numberDiff line numberDiff line change
Expand Up@@ -35,10 +35,6 @@ lemma homMk_comp'_assoc {X Y Z W : T} (f : X ⟶ Y) (g : Y ⟶ Z) (h : Z ⟶ W)
lemma homMk_id {X B : T} (f : X ⟶ B) (h : 𝟙 X ≫ f = f) : homMk (𝟙 X) h = 𝟙 (mk f) :=
rfl

@[simp]
theorem mkIdTerminal_from_left {B : T} (U : Over B) : (mkIdTerminal.from U).left = U.hom := by
simp [mkIdTerminal, CostructuredArrow.mkIdTerminal, Limits.IsTerminal.from, Functor.preimage]

/-- `Over.Sigma Y U` is a shorthand for `(Over.map Y.hom).obj U`.
This is a category-theoretic analogue of `Sigma` for types. -/
abbrev Sigma {X : T} (Y : Over X) (U : Over (Y.left)) : Over X :=
Expand Down
12 changes: 3 additions & 9 deletions Poly/ForMathlib/CategoryTheory/Comma/Over/Pullback.lean
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,7 +9,7 @@ import Mathlib.CategoryTheory.Limits.Constructions.Over.Basic
import Mathlib.CategoryTheory.Monad.Products
import Poly.ForMathlib.CategoryTheory.Comma.Over.Basic
import Poly.ForMathlib.CategoryTheory.NatTrans
import Poly.ForMathlib.CategoryTheory.Limits.Shapes.Pullback.CommSq
import Poly.ForMathlib.CategoryTheory.Limits.Shapes.Pullback.IsPullback.Basic

noncomputable section

Expand All@@ -19,7 +19,7 @@ namespace CategoryTheory

open Category Limits Comonad MonoidalCategory CartesianMonoidalCategory

attribute [local instance] CartesianMonoidalCategory.ofFiniteProducts
attribute [local instance] CartesianMonoidalCategory.ofHasFiniteProducts

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

Expand DownExpand Up@@ -211,7 +211,7 @@ lemma star_map [HasBinaryProducts C] {X : C} {Y Z : C} (f : Y ⟶ Z) :
instance [HasBinaryProducts C] (X : C) : (forget X).IsLeftAdjoint :=
⟨_, ⟨forgetAdjStar X⟩⟩

attribute [local instance] CartesianMonoidalCategory.ofFiniteProducts
attribute [local instance] CartesianMonoidalCategory.ofHasFiniteProducts

lemma whiskerLeftProdMapId [HasFiniteLimits C] {X : C} {A A' : C} {g : A ⟶ A'} :
X ◁ g = prod.map (𝟙 X) g := by
Expand DownExpand Up@@ -298,12 +298,6 @@ def starIsoToOverTerminal [HasTerminal C] [HasBinaryProducts C] :

variable {C}

/-- A natural isomorphism between the functors `star X` and `star Y ⋙ pullback f`
for any morphism `f : X ⟶ Y`. -/
def starPullbackIsoStar [HasBinaryProducts C] [HasPullbacks C] {X Y : C} (f : X ⟶ Y) :
star Y ⋙ pullback f ≅ star X :=
conjugateIsoEquiv ((mapPullbackAdj f).comp (forgetAdjStar Y)) (forgetAdjStar X) (mapForget f)

/-- The functor `Over.pullback f : Over Y ⥤ Over X` is naturally isomorphic to
`Over.star : Over Y ⥤ Over (Over.mk f)` post-composed with the
iterated slice equivlanece `Over (Over.mk f) ⥤ Over X`. -/
Expand Down
33 changes: 17 additions & 16 deletions Poly/ForMathlib/CategoryTheory/Comma/Over/Sections.lean
Original file line numberDiff line numberDiff line change
Expand Up@@ -28,7 +28,7 @@ variable {C : Type u₁} [Category.{v₁} C]

attribute [local instance] hasBinaryProducts_of_hasTerminal_and_pullbacks
attribute [local instance] hasFiniteProducts_of_has_binary_and_terminal
attribute [local instance] CartesianMonoidalCategory.ofFiniteProducts
attribute [local instance] CartesianMonoidalCategory.ofHasFiniteProducts

section

Expand DownExpand Up@@ -69,11 +69,11 @@ end

variable [HasTerminal C] [HasPullbacks C]

variable (I : C) [Exponentiable I]
variable (I : C) [Closed I]

/-- The first leg of a cospan constructing a pullback diagram in `C` used to define `sections` . -/
def curryId : ⊤_ C ⟶ (I ⟹ I) :=
CartesianClosed.curry (fst I (⊤_ C))
MonoidalClosed.curry (fst I (⊤_ C))

variable {I}

Expand All@@ -90,14 +90,14 @@ pullback diagram:
⊤_ C ----> I ⟹ I
```-/
abbrev sectionsObj (X : Over I) : C :=
Limits.pullback (curryId I) ((exp I).map X.hom)
Limits.pullback (curryId I) ((ihom I).map X.hom)

/-- The functoriality of `sectionsObj`. -/
def sectionsMap {X X' : Over I} (u : X ⟶ X') :
sectionsObj X ⟶ sectionsObj X' := by
fapply pullback.map
· exact 𝟙 _
· exact (exp I).map u.left
· exact (ihom I).map u.left
· exact 𝟙 _
· simp only [comp_id, id_comp]
· simp only [comp_id, ← Functor.map_comp, w]
Expand DownExpand Up@@ -130,29 +130,30 @@ variable {I}
in `C`. See `sectionsCurry`. -/
def sectionsCurryAux {X : Over I} {A : C} (u : (star I).obj A ⟶ X) :
A ⟶ (I ⟹ X.left) :=
CartesianClosed.curry (u.left)
MonoidalClosed.curry (u.left)

/-- The currying operation `Hom ((star I).obj A) X → Hom A (I ⟹ X.left)`. -/
def sectionsCurry {X : Over I} {A : C} (u : (star I).obj A ⟶ X) :
A ⟶ (sections I).obj X := by
apply pullback.lift (terminal.from A)
(CartesianClosed.curry ((prodIsoTensorObj _ _).inv ≫ u.left)) (uncurry_injective _)
rw [uncurry_natural_left]
simp [curryId, uncurry_natural_right, uncurry_curry]
(MonoidalClosed.curry ((prodIsoTensorObj _ _).inv ≫ u.left))
(MonoidalClosed.uncurry_injective _)
rw [MonoidalClosed.uncurry_natural_left]
simp [curryId, MonoidalClosed.uncurry_natural_right, MonoidalClosed.uncurry_curry]

/-- The uncurrying operation `Hom A (section X) → Hom ((star I).obj A) X`. -/
def sectionsUncurry {X : Over I} {A : C} (v : A ⟶ (sections I).obj X) :
(star I).obj A ⟶ X := by
let v₂ : A ⟶ (I ⟹ X.left) := v ≫ pullback.snd ..
have w : terminal.from A ≫ (curryId I) = v₂ ≫ (exp I).map X.hom := by
have w : terminal.from A ≫ (curryId I) = v₂ ≫ (ihom I).map X.hom := by
rw [IsTerminal.hom_ext terminalIsTerminal (terminal.from A ) (v ≫ (pullback.fst ..))]
simp [v₂, pullback.condition]
dsimp [curryId] at w
have w' := homEquiv_naturality_right_square (F := MonoidalCategory.tensorLeft I)
(adj := exp.adjunction I) _ _ _ _ w
simp [CartesianClosed.curry] at w'
refine Over.homMk ((prodIsoTensorObj I A).hom ≫ CartesianClosed.uncurry v₂) ?_
· dsimp [CartesianClosed.uncurry] at *
(adj := ihom.adjunction I) _ _ _ _ w
simp [MonoidalClosed.curry] at w'
refine Over.homMk ((prodIsoTensorObj I A).hom ≫ MonoidalClosed.uncurry v₂) ?_
· dsimp [MonoidalClosed.uncurry] at *
rw [Category.assoc, ← w']
simp [star_obj_hom]

Expand DownExpand Up@@ -188,13 +189,13 @@ def coreHomEquiv : CoreHomEquiv (star I) (sections I) where
simp only [star_map]
rw [← Over.homMk_comp] -- note: in a newer version of mathlib this is `Over.homMk_eta`
congr 1
simp [CartesianClosed.uncurry_natural_left]
simp [MonoidalClosed.uncurry_natural_left]
homEquiv_naturality_right := by
intro A X' X u g
dsimp [sectionsCurry, sectionsUncurry, curryId]
apply pullback.hom_ext (IsTerminal.hom_ext terminalIsTerminal _ _)
simp [sectionsMap, curryId]
rw [← CartesianClosed.curry_natural_right, Category.assoc]
rw [← MonoidalClosed.curry_natural_right, Category.assoc]

variable (I)

Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,7 +3,7 @@ Copyright (c) 2025 Wojciech Nawrocki. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Wojciech Nawrocki
-/
import Mathlib.CategoryTheory.Limits.Shapes.Pullback.CommSq
import Mathlib.CategoryTheory.Limits.Shapes.Pullback.IsPullback.Basic
import Poly.ForMathlib.CategoryTheory.CommSq

namespace CategoryTheory.Functor
Expand Down
21 changes: 11 additions & 10 deletions Poly/ForMathlib/CategoryTheory/LocallyCartesianClosed/Basic.lean
Original file line numberDiff line numberDiff line change
Expand Up@@ -67,7 +67,7 @@ open CategoryTheory Category MonoidalCategory CartesianMonoidalCategory Limits F

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

attribute [local instance] CartesianMonoidalCategory.ofFiniteProducts
attribute [local instance] CartesianMonoidalCategory.ofHasFiniteProducts

/-- A morphism `f : I ⟶ J` is exponentiable if the pullback functor `Over J ⥤ Over I`
has a right adjoint. -/
Expand DownExpand Up@@ -179,7 +179,7 @@ instance isMultiplicative : (ExponentiableMorphism (C:= C)).IsMultiplicative whe
/-- A morphism with a pushforward is an exponentiable object in the slice category. -/
def exponentiableOverMk [HasFiniteWidePullbacks C] {X I : C} (f : X ⟶ I)
[ExponentiableMorphism f] :
Exponentiable (Over.mk f) where
Closed (Over.mk f) where
rightAdj := pullback f ⋙ pushforward f
adj := by
apply ofNatIsoLeft _ _
Expand All@@ -192,7 +192,7 @@ morphism `X.hom`.
Here the pushforward functor along a morphism `f : I ⟶ J` is defined using the section functor
`Over (Over.mk f) ⥤ Over J`.
-/
def ofOverExponentiable [HasFiniteWidePullbacks C] {I : C} (X : Over I) [Exponentiable X] :
def ofOverExponentiable [HasFiniteWidePullbacks C] {I : C} (X : Over I) [Closed X] :
ExponentiableMorphism X.hom :=
⟨X.iteratedSliceEquiv.inverse ⋙ sections X, ⟨by
refine ofNatIsoLeft (Adjunction.comp ?_ ?_) (starIteratedSliceForwardIsoPullback X.hom)
Expand All@@ -217,7 +217,7 @@ variable {C} [HasFiniteWidePullbacks C] [HasPushforwards C]
/-- In a category where pushforwards exists along all morphisms, every slice category `Over I` is
cartesian closed. -/
instance cartesianClosedOver (I : C) :
CartesianClosed (Over I) where
MonoidalClosed (Over I) where
closed X := @exponentiableOverMk _ _ _ _ _ _ X.hom (HasPushforwards.exponentiable X.hom)

end HasPushforwards
Expand All@@ -226,13 +226,13 @@ namespace CartesianClosedOver

open Over Reindex IsIso CartesianClosed HasPushforwards ExponentiableMorphism

variable {C} [HasFiniteWidePullbacks C] {I J : C} [CartesianClosed (Over J)]
variable {C} [HasFiniteWidePullbacks C] {I J : C} [MonoidalClosed (Over J)]

instance (f : I ⟶ J) : ExponentiableMorphism f :=
ExponentiableMorphism.ofOverExponentiable (Over.mk f)

/-- A category with cartesian closed slices has pushforwards along all morphisms. -/
instance hasPushforwards [Π (I : C), CartesianClosed (Over I)] : HasPushforwards C where
instance hasPushforwards [Π (I : C), MonoidalClosed (Over I)] : HasPushforwards C where
exponentiable f := ExponentiableMorphism.ofOverExponentiable (Over.mk f)

end CartesianClosedOver
Expand All@@ -242,7 +242,7 @@ is exponentiable and all the slices are cartesian closed. -/
class LocallyCartesianClosed [HasFiniteWidePullbacks C] extends
HasPushforwards C where
/-- every slice category `Over I` is cartesian closed. This is filled in by default. -/
cartesianClosedOver : Π (I : C), CartesianClosed (Over I) := HasPushforwards.cartesianClosedOver
cartesianClosedOver : Π (I : C), MonoidalClosed (Over I) := HasPushforwards.cartesianClosedOver

namespace LocallyCartesianClosed

Expand All@@ -256,7 +256,7 @@ attribute [scoped instance] hasFiniteLimits_of_hasTerminal_and_pullbacks
instance mkOfHasPushforwards [HasPushforwards C] : LocallyCartesianClosed C where

/-- A category with cartesian closed slices is locally cartesian closed. -/
instance mkOfCartesianClosedOver [Π (I : C), CartesianClosed (Over I)] :
instance mkOfCartesianClosedOver [Π (I : C), MonoidalClosed (Over I)] :
LocallyCartesianClosed C where

variable [LocallyCartesianClosed C]
Expand All@@ -282,15 +282,16 @@ abbrev ev' {I : C} (X : Over I) (Y : Over X.left) : Reindex X (Pi X Y) ⟶ Y :=
adj X.hom |>.counit.app Y

/-- A locally cartesian closed category with a terminal object is cartesian closed. -/
def cartesianClosed [HasTerminal C] :
CartesianClosed C := cartesianClosedOfEquiv <| equivOverTerminal C
def monoidalClosed [HasTerminal C] :
MonoidalClosed C := cartesianClosedOfEquiv <| equivOverTerminal C

/-- The slices of a locally cartesian closed category are locally cartesian closed. -/
def overLocallyCartesianClosed (I : C) : LocallyCartesianClosed (Over I) := by
apply (config := { allowSynthFailures:= true}) mkOfCartesianClosedOver
intro X
exact cartesianClosedOfEquiv (C := Over (X.left)) X.iteratedSliceEquiv.symm

open CartesianClosed in
/-- The exponential `X^^A` in the slice category `Over I` is isomorphic to the pushforward of the
pullback of `X` along `A`. -/
def expIso {I : C} (A X : Over I) : Pi A (Reindex A X) ≅ A ⟹ X := Iso.refl _
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
Authors: Sina Hazratpour, Emily Riehl
-/
import Poly.ForMathlib.CategoryTheory.LocallyCartesianClosed.Basic
import Mathlib.CategoryTheory.Limits.Shapes.Pullback.CommSq
import Mathlib.CategoryTheory.Limits.Shapes.Pullback.IsPullback.Basic

/-!
# Beck-Chevalley natural transformations and natural isomorphisms
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -22,10 +22,10 @@ abbrev Psh (C : Type u) [Category.{v} C] : Type (max u (v + 1)) := Cᵒᵖ ⥤ T

variable {C : Type*} [SmallCategory C] [HasTerminal C]

attribute [local instance] CartesianMonoidalCategory.ofFiniteProducts
attribute [local instance] CartesianMonoidalCategory.ofHasFiniteProducts

instance cartesianClosedOver {C : Type u} [Category.{max u v} C] (P : Psh C) :
CartesianClosed (Over P) :=
instance monoidalClosedOver {C : Type u} [Category.{max u v} C] (P : Psh C) :
MonoidalClosed (Over P) :=
cartesianClosedOfEquiv (overEquivPresheafCostructuredArrow P).symm

instance locallyCartesianClosed : LocallyCartesianClosed (Psh C) := by
Expand Down
2 changes: 1 addition & 1 deletion Poly/ForMathlib/CategoryTheory/NatTrans.lean
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,7 +6,7 @@ Authors: Sina Hazratpour

import Mathlib.CategoryTheory.NatTrans
import Mathlib.CategoryTheory.Functor.TwoSquare
import Mathlib.CategoryTheory.Limits.Shapes.Pullback.CommSq
import Mathlib.CategoryTheory.Limits.Shapes.Pullback.IsPullback.Basic

open CategoryTheory Limits IsPullback

Expand Down
4 changes: 3 additions & 1 deletion Poly/ForMathlib/CategoryTheory/PartialProduct.lean
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,7 +3,7 @@ Copyright (c) 2025 Sina Hazratpour. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Sina Hazratpour
-/
import Mathlib.CategoryTheory.Limits.Shapes.Pullback.CommSq
import Mathlib.CategoryTheory.Limits.Shapes.Pullback.IsPullback.Basic
import Mathlib.CategoryTheory.Comma.Over.Pullback
import Poly.ForMathlib.CategoryTheory.Comma.Over.Pullback
import Mathlib.CategoryTheory.Monoidal.Closed.Cartesian
Expand DownExpand Up@@ -100,6 +100,8 @@ structure Fan.Hom (c c' : Fan s X) where

attribute [reassoc (attr := simp)] Fan.Hom.w_left Fan.Hom.w_right

-- TODO: this is taking ages to check since 4.28.0-rc1.
set_option maxHeartbeats 0 in
@[simps]
instance : Category (Fan s X) where
Hom := Fan.Hom
Expand Down
2 changes: 1 addition & 1 deletion Poly/Type/Univariate.lean
Original file line numberDiff line numberDiff line change
Expand Up@@ -189,7 +189,7 @@ def Obj.iget [DecidableEq P.B] {X} [Inhabited X] (x : P X) (i : P.Total) : X :=
@[simp]
theorem iget_map [DecidableEq P.B] [Inhabited X] [Inhabited Y] (x : P X)
(f : X → Y) (i : P.Total) (h : i.1 = x.1) : (P.map f x).iget i = f (x.iget i) := by
simp only [Obj.iget, fst_map, *, dif_pos, eq_self_iff_true]
simp only [Obj.iget, fst_map, *, dif_pos]
cases x
rfl

Expand Down
20 changes: 10 additions & 10 deletions lake-manifest.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,7 +15,7 @@
"type": "git",
"subDir": null,
"scope": "",
"rev": "dd5e5d97469dec395f29661366030566355ad9be",
"rev": "b8dad038b1b3a05b77d6884b15b8db03ec01dca1",
"name": "mathlib",
"manifestFile": "lake-manifest.json",
"inputRev": null,
Expand All@@ -25,7 +25,7 @@
"type": "git",
"subDir": null,
"scope": "leanprover-community",
"rev": "b3dd6c3ebc0a71685e86bea9223be39ea4c299fb",
"rev": "7311586e1a56af887b1081d05e80c11b6c41d212",
"name": "plausible",
"manifestFile": "lake-manifest.json",
"inputRev": "main",
Expand All@@ -45,7 +45,7 @@
"type": "git",
"subDir": null,
"scope": "leanprover-community",
"rev": "cff9dd30f2c161b9efd7c657cafed1f967645890",
"rev": "b5908dbac486279f1133cb937648c63c30b455af",
"name": "importGraph",
"manifestFile": "lake-manifest.json",
"inputRev": "main",
Expand All@@ -55,17 +55,17 @@
"type": "git",
"subDir": null,
"scope": "leanprover-community",
"rev": "ef8377f31b5535430b6753a974d685b0019d0681",
"rev": "6d65c6e0a25b8a52c13c3adeb63ecde3bfbb6294",
"name": "proofwidgets",
"manifestFile": "lake-manifest.json",
"inputRev": "v0.0.84",
"inputRev": "v0.0.86",
"inherited": true,
"configFile": "lakefile.lean"},
{"url": "https://github.com/leanprover-community/aesop",
"type": "git",
"subDir": null,
"scope": "leanprover-community",
"rev": "fa78cf032194308a950a264ed87b422a2a7c1c6c",
"rev": "f08e838d4f9aea519f3cde06260cfb686fd4bab0",
"name": "aesop",
"manifestFile": "lake-manifest.json",
"inputRev": "master",
Expand All@@ -75,7 +75,7 @@
"type": "git",
"subDir": null,
"scope": "leanprover-community",
"rev": "8920dcbb96a4e8bf641fc399ac9c0888e4a6be72",
"rev": "23324752757bf28124a518ec284044c8db79fee5",
"name": "Qq",
"manifestFile": "lake-manifest.json",
"inputRev": "master",
Expand All@@ -85,7 +85,7 @@
"type": "git",
"subDir": null,
"scope": "leanprover-community",
"rev": "dff865b7ee7011518d59abfc101c368293173150",
"rev": "100083c18750b6a9b7553c65f6b052c0a2f6bcb4",
"name": "batteries",
"manifestFile": "lake-manifest.json",
"inputRev": "main",
Expand All@@ -95,10 +95,10 @@
"type": "git",
"subDir": null,
"scope": "leanprover",
"rev": "726b98c53e2da249c1de768fbbbb5e67bc9cef60",
"rev": "28e0856d4424863a85b18f38868c5420c55f9bae",
"name": "Cli",
"manifestFile": "lake-manifest.json",
"inputRev": "v4.27.0-rc1",
"inputRev": "v4.28.0-rc1",
"inherited": true,
"configFile": "lakefile.toml"}],
"name": "Poly",
Expand Down
2 changes: 1 addition & 1 deletion lean-toolchain
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
leanprover/lean4:v4.27.0-rc1
leanprover/lean4:v4.28.0-rc1
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 0 additions & 4 deletions Poly/ForMathlib/CategoryTheory/Comma/Over/Basic.lean
Original file line numberDiff line numberDiff line change
Expand Up@@ -35,10 +35,6 @@ lemma homMk_comp'_assoc {X Y Z W : T} (f : X ⟶ Y) (g : Y ⟶ Z) (h : Z ⟶ W)
lemma homMk_id {X B : T} (f : X ⟶ B) (h : 𝟙 X ≫ f = f) : homMk (𝟙 X) h = 𝟙 (mk f) :=
rfl

@[simp]
theorem mkIdTerminal_from_left {B : T} (U : Over B) : (mkIdTerminal.from U).left = U.hom := by
simp [mkIdTerminal, CostructuredArrow.mkIdTerminal, Limits.IsTerminal.from, Functor.preimage]

/-- `Over.Sigma Y U` is a shorthand for `(Over.map Y.hom).obj U`.
This is a category-theoretic analogue of `Sigma` for types. -/
abbrev Sigma {X : T} (Y : Over X) (U : Over (Y.left)) : Over X :=
Expand Down
12 changes: 3 additions & 9 deletions Poly/ForMathlib/CategoryTheory/Comma/Over/Pullback.lean
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,7 +9,7 @@ import Mathlib.CategoryTheory.Limits.Constructions.Over.Basic
import Mathlib.CategoryTheory.Monad.Products
import Poly.ForMathlib.CategoryTheory.Comma.Over.Basic
import Poly.ForMathlib.CategoryTheory.NatTrans
import Poly.ForMathlib.CategoryTheory.Limits.Shapes.Pullback.CommSq
import Poly.ForMathlib.CategoryTheory.Limits.Shapes.Pullback.IsPullback.Basic

noncomputable section

Expand All@@ -19,7 +19,7 @@ namespace CategoryTheory

open Category Limits Comonad MonoidalCategory CartesianMonoidalCategory

attribute [local instance] CartesianMonoidalCategory.ofFiniteProducts
attribute [local instance] CartesianMonoidalCategory.ofHasFiniteProducts

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

Expand DownExpand Up@@ -211,7 +211,7 @@ lemma star_map [HasBinaryProducts C] {X : C} {Y Z : C} (f : Y ⟶ Z) :
instance [HasBinaryProducts C] (X : C) : (forget X).IsLeftAdjoint :=
⟨_, ⟨forgetAdjStar X⟩⟩

attribute [local instance] CartesianMonoidalCategory.ofFiniteProducts
attribute [local instance] CartesianMonoidalCategory.ofHasFiniteProducts

lemma whiskerLeftProdMapId [HasFiniteLimits C] {X : C} {A A' : C} {g : A ⟶ A'} :
X ◁ g = prod.map (𝟙 X) g := by
Expand DownExpand Up@@ -298,12 +298,6 @@ def starIsoToOverTerminal [HasTerminal C] [HasBinaryProducts C] :

variable {C}

/-- A natural isomorphism between the functors `star X` and `star Y ⋙ pullback f`
for any morphism `f : X ⟶ Y`. -/
def starPullbackIsoStar [HasBinaryProducts C] [HasPullbacks C] {X Y : C} (f : X ⟶ Y) :
star Y ⋙ pullback f ≅ star X :=
conjugateIsoEquiv ((mapPullbackAdj f).comp (forgetAdjStar Y)) (forgetAdjStar X) (mapForget f)

/-- The functor `Over.pullback f : Over Y ⥤ Over X` is naturally isomorphic to
`Over.star : Over Y ⥤ Over (Over.mk f)` post-composed with the
iterated slice equivlanece `Over (Over.mk f) ⥤ Over X`. -/
Expand Down
33 changes: 17 additions & 16 deletions Poly/ForMathlib/CategoryTheory/Comma/Over/Sections.lean
Original file line numberDiff line numberDiff line change
Expand Up@@ -28,7 +28,7 @@ variable {C : Type u₁} [Category.{v₁} C]

attribute [local instance] hasBinaryProducts_of_hasTerminal_and_pullbacks
attribute [local instance] hasFiniteProducts_of_has_binary_and_terminal
attribute [local instance] CartesianMonoidalCategory.ofFiniteProducts
attribute [local instance] CartesianMonoidalCategory.ofHasFiniteProducts

section

Expand DownExpand Up@@ -69,11 +69,11 @@ end

variable [HasTerminal C] [HasPullbacks C]

variable (I : C) [Exponentiable I]
variable (I : C) [Closed I]

/-- The first leg of a cospan constructing a pullback diagram in `C` used to define `sections` . -/
def curryId : ⊤_ C ⟶ (I ⟹ I) :=
CartesianClosed.curry (fst I (⊤_ C))
MonoidalClosed.curry (fst I (⊤_ C))

variable {I}

Expand All@@ -90,14 +90,14 @@ pullback diagram:
⊤_ C ----> I ⟹ I
```-/
abbrev sectionsObj (X : Over I) : C :=
Limits.pullback (curryId I) ((exp I).map X.hom)
Limits.pullback (curryId I) ((ihom I).map X.hom)

/-- The functoriality of `sectionsObj`. -/
def sectionsMap {X X' : Over I} (u : X ⟶ X') :
sectionsObj X ⟶ sectionsObj X' := by
fapply pullback.map
· exact 𝟙 _
· exact (exp I).map u.left
· exact (ihom I).map u.left
· exact 𝟙 _
· simp only [comp_id, id_comp]
· simp only [comp_id, ← Functor.map_comp, w]
Expand DownExpand Up@@ -130,29 +130,30 @@ variable {I}
in `C`. See `sectionsCurry`. -/
def sectionsCurryAux {X : Over I} {A : C} (u : (star I).obj A ⟶ X) :
A ⟶ (I ⟹ X.left) :=
CartesianClosed.curry (u.left)
MonoidalClosed.curry (u.left)

/-- The currying operation `Hom ((star I).obj A) X → Hom A (I ⟹ X.left)`. -/
def sectionsCurry {X : Over I} {A : C} (u : (star I).obj A ⟶ X) :
A ⟶ (sections I).obj X := by
apply pullback.lift (terminal.from A)
(CartesianClosed.curry ((prodIsoTensorObj _ _).inv ≫ u.left)) (uncurry_injective _)
rw [uncurry_natural_left]
simp [curryId, uncurry_natural_right, uncurry_curry]
(MonoidalClosed.curry ((prodIsoTensorObj _ _).inv ≫ u.left))
(MonoidalClosed.uncurry_injective _)
rw [MonoidalClosed.uncurry_natural_left]
simp [curryId, MonoidalClosed.uncurry_natural_right, MonoidalClosed.uncurry_curry]

/-- The uncurrying operation `Hom A (section X) → Hom ((star I).obj A) X`. -/
def sectionsUncurry {X : Over I} {A : C} (v : A ⟶ (sections I).obj X) :
(star I).obj A ⟶ X := by
let v₂ : A ⟶ (I ⟹ X.left) := v ≫ pullback.snd ..
have w : terminal.from A ≫ (curryId I) = v₂ ≫ (exp I).map X.hom := by
have w : terminal.from A ≫ (curryId I) = v₂ ≫ (ihom I).map X.hom := by
rw [IsTerminal.hom_ext terminalIsTerminal (terminal.from A ) (v ≫ (pullback.fst ..))]
simp [v₂, pullback.condition]
dsimp [curryId] at w
have w' := homEquiv_naturality_right_square (F := MonoidalCategory.tensorLeft I)
(adj := exp.adjunction I) _ _ _ _ w
simp [CartesianClosed.curry] at w'
refine Over.homMk ((prodIsoTensorObj I A).hom ≫ CartesianClosed.uncurry v₂) ?_
· dsimp [CartesianClosed.uncurry] at *
(adj := ihom.adjunction I) _ _ _ _ w
simp [MonoidalClosed.curry] at w'
refine Over.homMk ((prodIsoTensorObj I A).hom ≫ MonoidalClosed.uncurry v₂) ?_
· dsimp [MonoidalClosed.uncurry] at *
rw [Category.assoc, ← w']
simp [star_obj_hom]

Expand DownExpand Up@@ -188,13 +189,13 @@ def coreHomEquiv : CoreHomEquiv (star I) (sections I) where
simp only [star_map]
rw [← Over.homMk_comp] -- note: in a newer version of mathlib this is `Over.homMk_eta`
congr 1
simp [CartesianClosed.uncurry_natural_left]
simp [MonoidalClosed.uncurry_natural_left]
homEquiv_naturality_right := by
intro A X' X u g
dsimp [sectionsCurry, sectionsUncurry, curryId]
apply pullback.hom_ext (IsTerminal.hom_ext terminalIsTerminal _ _)
simp [sectionsMap, curryId]
rw [← CartesianClosed.curry_natural_right, Category.assoc]
rw [← MonoidalClosed.curry_natural_right, Category.assoc]

variable (I)

Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,7 +3,7 @@ Copyright (c) 2025 Wojciech Nawrocki. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Wojciech Nawrocki
-/
import Mathlib.CategoryTheory.Limits.Shapes.Pullback.CommSq
import Mathlib.CategoryTheory.Limits.Shapes.Pullback.IsPullback.Basic
import Poly.ForMathlib.CategoryTheory.CommSq

namespace CategoryTheory.Functor
Expand Down
21 changes: 11 additions & 10 deletions Poly/ForMathlib/CategoryTheory/LocallyCartesianClosed/Basic.lean
Original file line numberDiff line numberDiff line change
Expand Up@@ -67,7 +67,7 @@ open CategoryTheory Category MonoidalCategory CartesianMonoidalCategory Limits F

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

attribute [local instance] CartesianMonoidalCategory.ofFiniteProducts
attribute [local instance] CartesianMonoidalCategory.ofHasFiniteProducts

/-- A morphism `f : I ⟶ J` is exponentiable if the pullback functor `Over J ⥤ Over I`
has a right adjoint. -/
Expand DownExpand Up@@ -179,7 +179,7 @@ instance isMultiplicative : (ExponentiableMorphism (C:= C)).IsMultiplicative whe
/-- A morphism with a pushforward is an exponentiable object in the slice category. -/
def exponentiableOverMk [HasFiniteWidePullbacks C] {X I : C} (f : X ⟶ I)
[ExponentiableMorphism f] :
Exponentiable (Over.mk f) where
Closed (Over.mk f) where
rightAdj := pullback f ⋙ pushforward f
adj := by
apply ofNatIsoLeft _ _
Expand All@@ -192,7 +192,7 @@ morphism `X.hom`.
Here the pushforward functor along a morphism `f : I ⟶ J` is defined using the section functor
`Over (Over.mk f) ⥤ Over J`.
-/
def ofOverExponentiable [HasFiniteWidePullbacks C] {I : C} (X : Over I) [Exponentiable X] :
def ofOverExponentiable [HasFiniteWidePullbacks C] {I : C} (X : Over I) [Closed X] :
ExponentiableMorphism X.hom :=
⟨X.iteratedSliceEquiv.inverse ⋙ sections X, ⟨by
refine ofNatIsoLeft (Adjunction.comp ?_ ?_) (starIteratedSliceForwardIsoPullback X.hom)
Expand All@@ -217,7 +217,7 @@ variable {C} [HasFiniteWidePullbacks C] [HasPushforwards C]
/-- In a category where pushforwards exists along all morphisms, every slice category `Over I` is
cartesian closed. -/
instance cartesianClosedOver (I : C) :
CartesianClosed (Over I) where
MonoidalClosed (Over I) where
closed X := @exponentiableOverMk _ _ _ _ _ _ X.hom (HasPushforwards.exponentiable X.hom)

end HasPushforwards
Expand All@@ -226,13 +226,13 @@ namespace CartesianClosedOver

open Over Reindex IsIso CartesianClosed HasPushforwards ExponentiableMorphism

variable {C} [HasFiniteWidePullbacks C] {I J : C} [CartesianClosed (Over J)]
variable {C} [HasFiniteWidePullbacks C] {I J : C} [MonoidalClosed (Over J)]

instance (f : I ⟶ J) : ExponentiableMorphism f :=
ExponentiableMorphism.ofOverExponentiable (Over.mk f)

/-- A category with cartesian closed slices has pushforwards along all morphisms. -/
instance hasPushforwards [Π (I : C), CartesianClosed (Over I)] : HasPushforwards C where
instance hasPushforwards [Π (I : C), MonoidalClosed (Over I)] : HasPushforwards C where
exponentiable f := ExponentiableMorphism.ofOverExponentiable (Over.mk f)

end CartesianClosedOver
Expand All@@ -242,7 +242,7 @@ is exponentiable and all the slices are cartesian closed. -/
class LocallyCartesianClosed [HasFiniteWidePullbacks C] extends
HasPushforwards C where
/-- every slice category `Over I` is cartesian closed. This is filled in by default. -/
cartesianClosedOver : Π (I : C), CartesianClosed (Over I) := HasPushforwards.cartesianClosedOver
cartesianClosedOver : Π (I : C), MonoidalClosed (Over I) := HasPushforwards.cartesianClosedOver

namespace LocallyCartesianClosed

Expand All@@ -256,7 +256,7 @@ attribute [scoped instance] hasFiniteLimits_of_hasTerminal_and_pullbacks
instance mkOfHasPushforwards [HasPushforwards C] : LocallyCartesianClosed C where

/-- A category with cartesian closed slices is locally cartesian closed. -/
instance mkOfCartesianClosedOver [Π (I : C), CartesianClosed (Over I)] :
instance mkOfCartesianClosedOver [Π (I : C), MonoidalClosed (Over I)] :
LocallyCartesianClosed C where

variable [LocallyCartesianClosed C]
Expand All@@ -282,15 +282,16 @@ abbrev ev' {I : C} (X : Over I) (Y : Over X.left) : Reindex X (Pi X Y) ⟶ Y :=
adj X.hom |>.counit.app Y

/-- A locally cartesian closed category with a terminal object is cartesian closed. -/
def cartesianClosed [HasTerminal C] :
CartesianClosed C := cartesianClosedOfEquiv <| equivOverTerminal C
def monoidalClosed [HasTerminal C] :
MonoidalClosed C := cartesianClosedOfEquiv <| equivOverTerminal C

/-- The slices of a locally cartesian closed category are locally cartesian closed. -/
def overLocallyCartesianClosed (I : C) : LocallyCartesianClosed (Over I) := by
apply (config := { allowSynthFailures:= true}) mkOfCartesianClosedOver
intro X
exact cartesianClosedOfEquiv (C := Over (X.left)) X.iteratedSliceEquiv.symm

open CartesianClosed in
/-- The exponential `X^^A` in the slice category `Over I` is isomorphic to the pushforward of the
pullback of `X` along `A`. -/
def expIso {I : C} (A X : Over I) : Pi A (Reindex A X) ≅ A ⟹ X := Iso.refl _
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
Authors: Sina Hazratpour, Emily Riehl
-/
import Poly.ForMathlib.CategoryTheory.LocallyCartesianClosed.Basic
import Mathlib.CategoryTheory.Limits.Shapes.Pullback.CommSq
import Mathlib.CategoryTheory.Limits.Shapes.Pullback.IsPullback.Basic

/-!
# Beck-Chevalley natural transformations and natural isomorphisms
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -22,10 +22,10 @@ abbrev Psh (C : Type u) [Category.{v} C] : Type (max u (v + 1)) := Cᵒᵖ ⥤ T

variable {C : Type*} [SmallCategory C] [HasTerminal C]

attribute [local instance] CartesianMonoidalCategory.ofFiniteProducts
attribute [local instance] CartesianMonoidalCategory.ofHasFiniteProducts

instance cartesianClosedOver {C : Type u} [Category.{max u v} C] (P : Psh C) :
CartesianClosed (Over P) :=
instance monoidalClosedOver {C : Type u} [Category.{max u v} C] (P : Psh C) :
MonoidalClosed (Over P) :=
cartesianClosedOfEquiv (overEquivPresheafCostructuredArrow P).symm

instance locallyCartesianClosed : LocallyCartesianClosed (Psh C) := by
Expand Down
2 changes: 1 addition & 1 deletion Poly/ForMathlib/CategoryTheory/NatTrans.lean
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,7 +6,7 @@ Authors: Sina Hazratpour

import Mathlib.CategoryTheory.NatTrans
import Mathlib.CategoryTheory.Functor.TwoSquare
import Mathlib.CategoryTheory.Limits.Shapes.Pullback.CommSq
import Mathlib.CategoryTheory.Limits.Shapes.Pullback.IsPullback.Basic

open CategoryTheory Limits IsPullback

Expand Down
4 changes: 3 additions & 1 deletion Poly/ForMathlib/CategoryTheory/PartialProduct.lean
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,7 +3,7 @@ Copyright (c) 2025 Sina Hazratpour. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Sina Hazratpour
-/
import Mathlib.CategoryTheory.Limits.Shapes.Pullback.CommSq
import Mathlib.CategoryTheory.Limits.Shapes.Pullback.IsPullback.Basic
import Mathlib.CategoryTheory.Comma.Over.Pullback
import Poly.ForMathlib.CategoryTheory.Comma.Over.Pullback
import Mathlib.CategoryTheory.Monoidal.Closed.Cartesian
Expand DownExpand Up@@ -100,6 +100,8 @@ structure Fan.Hom (c c' : Fan s X) where

attribute [reassoc (attr := simp)] Fan.Hom.w_left Fan.Hom.w_right

-- TODO: this is taking ages to check since 4.28.0-rc1.
set_option maxHeartbeats 0 in
@[simps]
instance : Category (Fan s X) where
Hom := Fan.Hom
Expand Down
2 changes: 1 addition & 1 deletion Poly/Type/Univariate.lean
Original file line numberDiff line numberDiff line change
Expand Up@@ -189,7 +189,7 @@ def Obj.iget [DecidableEq P.B] {X} [Inhabited X] (x : P X) (i : P.Total) : X :=
@[simp]
theorem iget_map [DecidableEq P.B] [Inhabited X] [Inhabited Y] (x : P X)
(f : X → Y) (i : P.Total) (h : i.1 = x.1) : (P.map f x).iget i = f (x.iget i) := by
simp only [Obj.iget, fst_map, *, dif_pos, eq_self_iff_true]
simp only [Obj.iget, fst_map, *, dif_pos]
cases x
rfl

Expand Down
20 changes: 10 additions & 10 deletions lake-manifest.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,7 +15,7 @@
"type": "git",
"subDir": null,
"scope": "",
"rev": "dd5e5d97469dec395f29661366030566355ad9be",
"rev": "b8dad038b1b3a05b77d6884b15b8db03ec01dca1",
"name": "mathlib",
"manifestFile": "lake-manifest.json",
"inputRev": null,
Expand All@@ -25,7 +25,7 @@
"type": "git",
"subDir": null,
"scope": "leanprover-community",
"rev": "b3dd6c3ebc0a71685e86bea9223be39ea4c299fb",
"rev": "7311586e1a56af887b1081d05e80c11b6c41d212",
"name": "plausible",
"manifestFile": "lake-manifest.json",
"inputRev": "main",
Expand All@@ -45,7 +45,7 @@
"type": "git",
"subDir": null,
"scope": "leanprover-community",
"rev": "cff9dd30f2c161b9efd7c657cafed1f967645890",
"rev": "b5908dbac486279f1133cb937648c63c30b455af",
"name": "importGraph",
"manifestFile": "lake-manifest.json",
"inputRev": "main",
Expand All@@ -55,17 +55,17 @@
"type": "git",
"subDir": null,
"scope": "leanprover-community",
"rev": "ef8377f31b5535430b6753a974d685b0019d0681",
"rev": "6d65c6e0a25b8a52c13c3adeb63ecde3bfbb6294",
"name": "proofwidgets",
"manifestFile": "lake-manifest.json",
"inputRev": "v0.0.84",
"inputRev": "v0.0.86",
"inherited": true,
"configFile": "lakefile.lean"},
{"url": "https://github.com/leanprover-community/aesop",
"type": "git",
"subDir": null,
"scope": "leanprover-community",
"rev": "fa78cf032194308a950a264ed87b422a2a7c1c6c",
"rev": "f08e838d4f9aea519f3cde06260cfb686fd4bab0",
"name": "aesop",
"manifestFile": "lake-manifest.json",
"inputRev": "master",
Expand All@@ -75,7 +75,7 @@
"type": "git",
"subDir": null,
"scope": "leanprover-community",
"rev": "8920dcbb96a4e8bf641fc399ac9c0888e4a6be72",
"rev": "23324752757bf28124a518ec284044c8db79fee5",
"name": "Qq",
"manifestFile": "lake-manifest.json",
"inputRev": "master",
Expand All@@ -85,7 +85,7 @@
"type": "git",
"subDir": null,
"scope": "leanprover-community",
"rev": "dff865b7ee7011518d59abfc101c368293173150",
"rev": "100083c18750b6a9b7553c65f6b052c0a2f6bcb4",
"name": "batteries",
"manifestFile": "lake-manifest.json",
"inputRev": "main",
Expand All@@ -95,10 +95,10 @@
"type": "git",
"subDir": null,
"scope": "leanprover",
"rev": "726b98c53e2da249c1de768fbbbb5e67bc9cef60",
"rev": "28e0856d4424863a85b18f38868c5420c55f9bae",
"name": "Cli",
"manifestFile": "lake-manifest.json",
"inputRev": "v4.27.0-rc1",
"inputRev": "v4.28.0-rc1",
"inherited": true,
"configFile": "lakefile.toml"}],
"name": "Poly",
Expand Down
2 changes: 1 addition & 1 deletion lean-toolchain
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
leanprover/lean4:v4.27.0-rc1
leanprover/lean4:v4.28.0-rc1
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 0 additions & 4 deletions Poly/ForMathlib/CategoryTheory/Comma/Over/Basic.lean
Original file line numberDiff line numberDiff line change
Expand Up@@ -35,10 +35,6 @@ lemma homMk_comp'_assoc {X Y Z W : T} (f : X ⟶ Y) (g : Y ⟶ Z) (h : Z ⟶ W)
lemma homMk_id {X B : T} (f : X ⟶ B) (h : 𝟙 X ≫ f = f) : homMk (𝟙 X) h = 𝟙 (mk f) :=
rfl

@[simp]
theorem mkIdTerminal_from_left {B : T} (U : Over B) : (mkIdTerminal.from U).left = U.hom := by
simp [mkIdTerminal, CostructuredArrow.mkIdTerminal, Limits.IsTerminal.from, Functor.preimage]

/-- `Over.Sigma Y U` is a shorthand for `(Over.map Y.hom).obj U`.
This is a category-theoretic analogue of `Sigma` for types. -/
abbrev Sigma {X : T} (Y : Over X) (U : Over (Y.left)) : Over X :=
Expand Down
12 changes: 3 additions & 9 deletions Poly/ForMathlib/CategoryTheory/Comma/Over/Pullback.lean
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,7 +9,7 @@ import Mathlib.CategoryTheory.Limits.Constructions.Over.Basic
import Mathlib.CategoryTheory.Monad.Products
import Poly.ForMathlib.CategoryTheory.Comma.Over.Basic
import Poly.ForMathlib.CategoryTheory.NatTrans
import Poly.ForMathlib.CategoryTheory.Limits.Shapes.Pullback.CommSq
import Poly.ForMathlib.CategoryTheory.Limits.Shapes.Pullback.IsPullback.Basic

noncomputable section

Expand All@@ -19,7 +19,7 @@ namespace CategoryTheory

open Category Limits Comonad MonoidalCategory CartesianMonoidalCategory

attribute [local instance] CartesianMonoidalCategory.ofFiniteProducts
attribute [local instance] CartesianMonoidalCategory.ofHasFiniteProducts

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

Expand DownExpand Up@@ -211,7 +211,7 @@ lemma star_map [HasBinaryProducts C] {X : C} {Y Z : C} (f : Y ⟶ Z) :
instance [HasBinaryProducts C] (X : C) : (forget X).IsLeftAdjoint :=
⟨_, ⟨forgetAdjStar X⟩⟩

attribute [local instance] CartesianMonoidalCategory.ofFiniteProducts
attribute [local instance] CartesianMonoidalCategory.ofHasFiniteProducts

lemma whiskerLeftProdMapId [HasFiniteLimits C] {X : C} {A A' : C} {g : A ⟶ A'} :
X ◁ g = prod.map (𝟙 X) g := by
Expand DownExpand Up@@ -298,12 +298,6 @@ def starIsoToOverTerminal [HasTerminal C] [HasBinaryProducts C] :

variable {C}

/-- A natural isomorphism between the functors `star X` and `star Y ⋙ pullback f`
for any morphism `f : X ⟶ Y`. -/
def starPullbackIsoStar [HasBinaryProducts C] [HasPullbacks C] {X Y : C} (f : X ⟶ Y) :
star Y ⋙ pullback f ≅ star X :=
conjugateIsoEquiv ((mapPullbackAdj f).comp (forgetAdjStar Y)) (forgetAdjStar X) (mapForget f)

/-- The functor `Over.pullback f : Over Y ⥤ Over X` is naturally isomorphic to
`Over.star : Over Y ⥤ Over (Over.mk f)` post-composed with the
iterated slice equivlanece `Over (Over.mk f) ⥤ Over X`. -/
Expand Down
33 changes: 17 additions & 16 deletions Poly/ForMathlib/CategoryTheory/Comma/Over/Sections.lean
Original file line numberDiff line numberDiff line change
Expand Up@@ -28,7 +28,7 @@ variable {C : Type u₁} [Category.{v₁} C]

attribute [local instance] hasBinaryProducts_of_hasTerminal_and_pullbacks
attribute [local instance] hasFiniteProducts_of_has_binary_and_terminal
attribute [local instance] CartesianMonoidalCategory.ofFiniteProducts
attribute [local instance] CartesianMonoidalCategory.ofHasFiniteProducts

section

Expand DownExpand Up@@ -69,11 +69,11 @@ end

variable [HasTerminal C] [HasPullbacks C]

variable (I : C) [Exponentiable I]
variable (I : C) [Closed I]

/-- The first leg of a cospan constructing a pullback diagram in `C` used to define `sections` . -/
def curryId : ⊤_ C ⟶ (I ⟹ I) :=
CartesianClosed.curry (fst I (⊤_ C))
MonoidalClosed.curry (fst I (⊤_ C))

variable {I}

Expand All@@ -90,14 +90,14 @@ pullback diagram:
⊤_ C ----> I ⟹ I
```-/
abbrev sectionsObj (X : Over I) : C :=
Limits.pullback (curryId I) ((exp I).map X.hom)
Limits.pullback (curryId I) ((ihom I).map X.hom)

/-- The functoriality of `sectionsObj`. -/
def sectionsMap {X X' : Over I} (u : X ⟶ X') :
sectionsObj X ⟶ sectionsObj X' := by
fapply pullback.map
· exact 𝟙 _
· exact (exp I).map u.left
· exact (ihom I).map u.left
· exact 𝟙 _
· simp only [comp_id, id_comp]
· simp only [comp_id, ← Functor.map_comp, w]
Expand DownExpand Up@@ -130,29 +130,30 @@ variable {I}
in `C`. See `sectionsCurry`. -/
def sectionsCurryAux {X : Over I} {A : C} (u : (star I).obj A ⟶ X) :
A ⟶ (I ⟹ X.left) :=
CartesianClosed.curry (u.left)
MonoidalClosed.curry (u.left)

/-- The currying operation `Hom ((star I).obj A) X → Hom A (I ⟹ X.left)`. -/
def sectionsCurry {X : Over I} {A : C} (u : (star I).obj A ⟶ X) :
A ⟶ (sections I).obj X := by
apply pullback.lift (terminal.from A)
(CartesianClosed.curry ((prodIsoTensorObj _ _).inv ≫ u.left)) (uncurry_injective _)
rw [uncurry_natural_left]
simp [curryId, uncurry_natural_right, uncurry_curry]
(MonoidalClosed.curry ((prodIsoTensorObj _ _).inv ≫ u.left))
(MonoidalClosed.uncurry_injective _)
rw [MonoidalClosed.uncurry_natural_left]
simp [curryId, MonoidalClosed.uncurry_natural_right, MonoidalClosed.uncurry_curry]

/-- The uncurrying operation `Hom A (section X) → Hom ((star I).obj A) X`. -/
def sectionsUncurry {X : Over I} {A : C} (v : A ⟶ (sections I).obj X) :
(star I).obj A ⟶ X := by
let v₂ : A ⟶ (I ⟹ X.left) := v ≫ pullback.snd ..
have w : terminal.from A ≫ (curryId I) = v₂ ≫ (exp I).map X.hom := by
have w : terminal.from A ≫ (curryId I) = v₂ ≫ (ihom I).map X.hom := by
rw [IsTerminal.hom_ext terminalIsTerminal (terminal.from A ) (v ≫ (pullback.fst ..))]
simp [v₂, pullback.condition]
dsimp [curryId] at w
have w' := homEquiv_naturality_right_square (F := MonoidalCategory.tensorLeft I)
(adj := exp.adjunction I) _ _ _ _ w
simp [CartesianClosed.curry] at w'
refine Over.homMk ((prodIsoTensorObj I A).hom ≫ CartesianClosed.uncurry v₂) ?_
· dsimp [CartesianClosed.uncurry] at *
(adj := ihom.adjunction I) _ _ _ _ w
simp [MonoidalClosed.curry] at w'
refine Over.homMk ((prodIsoTensorObj I A).hom ≫ MonoidalClosed.uncurry v₂) ?_
· dsimp [MonoidalClosed.uncurry] at *
rw [Category.assoc, ← w']
simp [star_obj_hom]

Expand DownExpand Up@@ -188,13 +189,13 @@ def coreHomEquiv : CoreHomEquiv (star I) (sections I) where
simp only [star_map]
rw [← Over.homMk_comp] -- note: in a newer version of mathlib this is `Over.homMk_eta`
congr 1
simp [CartesianClosed.uncurry_natural_left]
simp [MonoidalClosed.uncurry_natural_left]
homEquiv_naturality_right := by
intro A X' X u g
dsimp [sectionsCurry, sectionsUncurry, curryId]
apply pullback.hom_ext (IsTerminal.hom_ext terminalIsTerminal _ _)
simp [sectionsMap, curryId]
rw [← CartesianClosed.curry_natural_right, Category.assoc]
rw [← MonoidalClosed.curry_natural_right, Category.assoc]

variable (I)

Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,7 +3,7 @@ Copyright (c) 2025 Wojciech Nawrocki. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Wojciech Nawrocki
-/
import Mathlib.CategoryTheory.Limits.Shapes.Pullback.CommSq
import Mathlib.CategoryTheory.Limits.Shapes.Pullback.IsPullback.Basic
import Poly.ForMathlib.CategoryTheory.CommSq

namespace CategoryTheory.Functor
Expand Down
21 changes: 11 additions & 10 deletions Poly/ForMathlib/CategoryTheory/LocallyCartesianClosed/Basic.lean
Original file line numberDiff line numberDiff line change
Expand Up@@ -67,7 +67,7 @@ open CategoryTheory Category MonoidalCategory CartesianMonoidalCategory Limits F

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

attribute [local instance] CartesianMonoidalCategory.ofFiniteProducts
attribute [local instance] CartesianMonoidalCategory.ofHasFiniteProducts

/-- A morphism `f : I ⟶ J` is exponentiable if the pullback functor `Over J ⥤ Over I`
has a right adjoint. -/
Expand DownExpand Up@@ -179,7 +179,7 @@ instance isMultiplicative : (ExponentiableMorphism (C:= C)).IsMultiplicative whe
/-- A morphism with a pushforward is an exponentiable object in the slice category. -/
def exponentiableOverMk [HasFiniteWidePullbacks C] {X I : C} (f : X ⟶ I)
[ExponentiableMorphism f] :
Exponentiable (Over.mk f) where
Closed (Over.mk f) where
rightAdj := pullback f ⋙ pushforward f
adj := by
apply ofNatIsoLeft _ _
Expand All@@ -192,7 +192,7 @@ morphism `X.hom`.
Here the pushforward functor along a morphism `f : I ⟶ J` is defined using the section functor
`Over (Over.mk f) ⥤ Over J`.
-/
def ofOverExponentiable [HasFiniteWidePullbacks C] {I : C} (X : Over I) [Exponentiable X] :
def ofOverExponentiable [HasFiniteWidePullbacks C] {I : C} (X : Over I) [Closed X] :
ExponentiableMorphism X.hom :=
⟨X.iteratedSliceEquiv.inverse ⋙ sections X, ⟨by
refine ofNatIsoLeft (Adjunction.comp ?_ ?_) (starIteratedSliceForwardIsoPullback X.hom)
Expand All@@ -217,7 +217,7 @@ variable {C} [HasFiniteWidePullbacks C] [HasPushforwards C]
/-- In a category where pushforwards exists along all morphisms, every slice category `Over I` is
cartesian closed. -/
instance cartesianClosedOver (I : C) :
CartesianClosed (Over I) where
MonoidalClosed (Over I) where
closed X := @exponentiableOverMk _ _ _ _ _ _ X.hom (HasPushforwards.exponentiable X.hom)

end HasPushforwards
Expand All@@ -226,13 +226,13 @@ namespace CartesianClosedOver

open Over Reindex IsIso CartesianClosed HasPushforwards ExponentiableMorphism

variable {C} [HasFiniteWidePullbacks C] {I J : C} [CartesianClosed (Over J)]
variable {C} [HasFiniteWidePullbacks C] {I J : C} [MonoidalClosed (Over J)]

instance (f : I ⟶ J) : ExponentiableMorphism f :=
ExponentiableMorphism.ofOverExponentiable (Over.mk f)

/-- A category with cartesian closed slices has pushforwards along all morphisms. -/
instance hasPushforwards [Π (I : C), CartesianClosed (Over I)] : HasPushforwards C where
instance hasPushforwards [Π (I : C), MonoidalClosed (Over I)] : HasPushforwards C where
exponentiable f := ExponentiableMorphism.ofOverExponentiable (Over.mk f)

end CartesianClosedOver
Expand All@@ -242,7 +242,7 @@ is exponentiable and all the slices are cartesian closed. -/
class LocallyCartesianClosed [HasFiniteWidePullbacks C] extends
HasPushforwards C where
/-- every slice category `Over I` is cartesian closed. This is filled in by default. -/
cartesianClosedOver : Π (I : C), CartesianClosed (Over I) := HasPushforwards.cartesianClosedOver
cartesianClosedOver : Π (I : C), MonoidalClosed (Over I) := HasPushforwards.cartesianClosedOver

namespace LocallyCartesianClosed

Expand All@@ -256,7 +256,7 @@ attribute [scoped instance] hasFiniteLimits_of_hasTerminal_and_pullbacks
instance mkOfHasPushforwards [HasPushforwards C] : LocallyCartesianClosed C where

/-- A category with cartesian closed slices is locally cartesian closed. -/
instance mkOfCartesianClosedOver [Π (I : C), CartesianClosed (Over I)] :
instance mkOfCartesianClosedOver [Π (I : C), MonoidalClosed (Over I)] :
LocallyCartesianClosed C where

variable [LocallyCartesianClosed C]
Expand All@@ -282,15 +282,16 @@ abbrev ev' {I : C} (X : Over I) (Y : Over X.left) : Reindex X (Pi X Y) ⟶ Y :=
adj X.hom |>.counit.app Y

/-- A locally cartesian closed category with a terminal object is cartesian closed. -/
def cartesianClosed [HasTerminal C] :
CartesianClosed C := cartesianClosedOfEquiv <| equivOverTerminal C
def monoidalClosed [HasTerminal C] :
MonoidalClosed C := cartesianClosedOfEquiv <| equivOverTerminal C

/-- The slices of a locally cartesian closed category are locally cartesian closed. -/
def overLocallyCartesianClosed (I : C) : LocallyCartesianClosed (Over I) := by
apply (config := { allowSynthFailures:= true}) mkOfCartesianClosedOver
intro X
exact cartesianClosedOfEquiv (C := Over (X.left)) X.iteratedSliceEquiv.symm

open CartesianClosed in
/-- The exponential `X^^A` in the slice category `Over I` is isomorphic to the pushforward of the
pullback of `X` along `A`. -/
def expIso {I : C} (A X : Over I) : Pi A (Reindex A X) ≅ A ⟹ X := Iso.refl _
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
Authors: Sina Hazratpour, Emily Riehl
-/
import Poly.ForMathlib.CategoryTheory.LocallyCartesianClosed.Basic
import Mathlib.CategoryTheory.Limits.Shapes.Pullback.CommSq
import Mathlib.CategoryTheory.Limits.Shapes.Pullback.IsPullback.Basic

/-!
# Beck-Chevalley natural transformations and natural isomorphisms
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -22,10 +22,10 @@ abbrev Psh (C : Type u) [Category.{v} C] : Type (max u (v + 1)) := Cᵒᵖ ⥤ T

variable {C : Type*} [SmallCategory C] [HasTerminal C]

attribute [local instance] CartesianMonoidalCategory.ofFiniteProducts
attribute [local instance] CartesianMonoidalCategory.ofHasFiniteProducts

instance cartesianClosedOver {C : Type u} [Category.{max u v} C] (P : Psh C) :
CartesianClosed (Over P) :=
instance monoidalClosedOver {C : Type u} [Category.{max u v} C] (P : Psh C) :
MonoidalClosed (Over P) :=
cartesianClosedOfEquiv (overEquivPresheafCostructuredArrow P).symm

instance locallyCartesianClosed : LocallyCartesianClosed (Psh C) := by
Expand Down
2 changes: 1 addition & 1 deletion Poly/ForMathlib/CategoryTheory/NatTrans.lean
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,7 +6,7 @@ Authors: Sina Hazratpour

import Mathlib.CategoryTheory.NatTrans
import Mathlib.CategoryTheory.Functor.TwoSquare
import Mathlib.CategoryTheory.Limits.Shapes.Pullback.CommSq
import Mathlib.CategoryTheory.Limits.Shapes.Pullback.IsPullback.Basic

open CategoryTheory Limits IsPullback

Expand Down
4 changes: 3 additions & 1 deletion Poly/ForMathlib/CategoryTheory/PartialProduct.lean
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,7 +3,7 @@ Copyright (c) 2025 Sina Hazratpour. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Sina Hazratpour
-/
import Mathlib.CategoryTheory.Limits.Shapes.Pullback.CommSq
import Mathlib.CategoryTheory.Limits.Shapes.Pullback.IsPullback.Basic
import Mathlib.CategoryTheory.Comma.Over.Pullback
import Poly.ForMathlib.CategoryTheory.Comma.Over.Pullback
import Mathlib.CategoryTheory.Monoidal.Closed.Cartesian
Expand DownExpand Up@@ -100,6 +100,8 @@ structure Fan.Hom (c c' : Fan s X) where

attribute [reassoc (attr := simp)] Fan.Hom.w_left Fan.Hom.w_right

-- TODO: this is taking ages to check since 4.28.0-rc1.
set_option maxHeartbeats 0 in
@[simps]
instance : Category (Fan s X) where
Hom := Fan.Hom
Expand Down
2 changes: 1 addition & 1 deletion Poly/Type/Univariate.lean
Original file line numberDiff line numberDiff line change
Expand Up@@ -189,7 +189,7 @@ def Obj.iget [DecidableEq P.B] {X} [Inhabited X] (x : P X) (i : P.Total) : X :=
@[simp]
theorem iget_map [DecidableEq P.B] [Inhabited X] [Inhabited Y] (x : P X)
(f : X → Y) (i : P.Total) (h : i.1 = x.1) : (P.map f x).iget i = f (x.iget i) := by
simp only [Obj.iget, fst_map, *, dif_pos, eq_self_iff_true]
simp only [Obj.iget, fst_map, *, dif_pos]
cases x
rfl

Expand Down
20 changes: 10 additions & 10 deletions lake-manifest.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,7 +15,7 @@
"type": "git",
"subDir": null,
"scope": "",
"rev": "dd5e5d97469dec395f29661366030566355ad9be",
"rev": "b8dad038b1b3a05b77d6884b15b8db03ec01dca1",
"name": "mathlib",
"manifestFile": "lake-manifest.json",
"inputRev": null,
Expand All@@ -25,7 +25,7 @@
"type": "git",
"subDir": null,
"scope": "leanprover-community",
"rev": "b3dd6c3ebc0a71685e86bea9223be39ea4c299fb",
"rev": "7311586e1a56af887b1081d05e80c11b6c41d212",
"name": "plausible",
"manifestFile": "lake-manifest.json",
"inputRev": "main",
Expand All@@ -45,7 +45,7 @@
"type": "git",
"subDir": null,
"scope": "leanprover-community",
"rev": "cff9dd30f2c161b9efd7c657cafed1f967645890",
"rev": "b5908dbac486279f1133cb937648c63c30b455af",
"name": "importGraph",
"manifestFile": "lake-manifest.json",
"inputRev": "main",
Expand All@@ -55,17 +55,17 @@
"type": "git",
"subDir": null,
"scope": "leanprover-community",
"rev": "ef8377f31b5535430b6753a974d685b0019d0681",
"rev": "6d65c6e0a25b8a52c13c3adeb63ecde3bfbb6294",
"name": "proofwidgets",
"manifestFile": "lake-manifest.json",
"inputRev": "v0.0.84",
"inputRev": "v0.0.86",
"inherited": true,
"configFile": "lakefile.lean"},
{"url": "https://github.com/leanprover-community/aesop",
"type": "git",
"subDir": null,
"scope": "leanprover-community",
"rev": "fa78cf032194308a950a264ed87b422a2a7c1c6c",
"rev": "f08e838d4f9aea519f3cde06260cfb686fd4bab0",
"name": "aesop",
"manifestFile": "lake-manifest.json",
"inputRev": "master",
Expand All@@ -75,7 +75,7 @@
"type": "git",
"subDir": null,
"scope": "leanprover-community",
"rev": "8920dcbb96a4e8bf641fc399ac9c0888e4a6be72",
"rev": "23324752757bf28124a518ec284044c8db79fee5",
"name": "Qq",
"manifestFile": "lake-manifest.json",
"inputRev": "master",
Expand All@@ -85,7 +85,7 @@
"type": "git",
"subDir": null,
"scope": "leanprover-community",
"rev": "dff865b7ee7011518d59abfc101c368293173150",
"rev": "100083c18750b6a9b7553c65f6b052c0a2f6bcb4",
"name": "batteries",
"manifestFile": "lake-manifest.json",
"inputRev": "main",
Expand All@@ -95,10 +95,10 @@
"type": "git",
"subDir": null,
"scope": "leanprover",
"rev": "726b98c53e2da249c1de768fbbbb5e67bc9cef60",
"rev": "28e0856d4424863a85b18f38868c5420c55f9bae",
"name": "Cli",
"manifestFile": "lake-manifest.json",
"inputRev": "v4.27.0-rc1",
"inputRev": "v4.28.0-rc1",
"inherited": true,
"configFile": "lakefile.toml"}],
"name": "Poly",
Expand Down
2 changes: 1 addition & 1 deletion lean-toolchain
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
leanprover/lean4:v4.27.0-rc1
leanprover/lean4:v4.28.0-rc1
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 0 additions & 4 deletions Poly/ForMathlib/CategoryTheory/Comma/Over/Basic.lean
Original file line numberDiff line numberDiff line change
Expand Up@@ -35,10 +35,6 @@ lemma homMk_comp'_assoc {X Y Z W : T} (f : X ⟶ Y) (g : Y ⟶ Z) (h : Z ⟶ W)
lemma homMk_id {X B : T} (f : X ⟶ B) (h : 𝟙 X ≫ f = f) : homMk (𝟙 X) h = 𝟙 (mk f) :=
rfl

@[simp]
theorem mkIdTerminal_from_left {B : T} (U : Over B) : (mkIdTerminal.from U).left = U.hom := by
simp [mkIdTerminal, CostructuredArrow.mkIdTerminal, Limits.IsTerminal.from, Functor.preimage]

/-- `Over.Sigma Y U` is a shorthand for `(Over.map Y.hom).obj U`.
This is a category-theoretic analogue of `Sigma` for types. -/
abbrev Sigma {X : T} (Y : Over X) (U : Over (Y.left)) : Over X :=
Expand Down
12 changes: 3 additions & 9 deletions Poly/ForMathlib/CategoryTheory/Comma/Over/Pullback.lean
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,7 +9,7 @@ import Mathlib.CategoryTheory.Limits.Constructions.Over.Basic
import Mathlib.CategoryTheory.Monad.Products
import Poly.ForMathlib.CategoryTheory.Comma.Over.Basic
import Poly.ForMathlib.CategoryTheory.NatTrans
import Poly.ForMathlib.CategoryTheory.Limits.Shapes.Pullback.CommSq
import Poly.ForMathlib.CategoryTheory.Limits.Shapes.Pullback.IsPullback.Basic

noncomputable section

Expand All@@ -19,7 +19,7 @@ namespace CategoryTheory

open Category Limits Comonad MonoidalCategory CartesianMonoidalCategory

attribute [local instance] CartesianMonoidalCategory.ofFiniteProducts
attribute [local instance] CartesianMonoidalCategory.ofHasFiniteProducts

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

Expand DownExpand Up@@ -211,7 +211,7 @@ lemma star_map [HasBinaryProducts C] {X : C} {Y Z : C} (f : Y ⟶ Z) :
instance [HasBinaryProducts C] (X : C) : (forget X).IsLeftAdjoint :=
⟨_, ⟨forgetAdjStar X⟩⟩

attribute [local instance] CartesianMonoidalCategory.ofFiniteProducts
attribute [local instance] CartesianMonoidalCategory.ofHasFiniteProducts

lemma whiskerLeftProdMapId [HasFiniteLimits C] {X : C} {A A' : C} {g : A ⟶ A'} :
X ◁ g = prod.map (𝟙 X) g := by
Expand DownExpand Up@@ -298,12 +298,6 @@ def starIsoToOverTerminal [HasTerminal C] [HasBinaryProducts C] :

variable {C}

/-- A natural isomorphism between the functors `star X` and `star Y ⋙ pullback f`
for any morphism `f : X ⟶ Y`. -/
def starPullbackIsoStar [HasBinaryProducts C] [HasPullbacks C] {X Y : C} (f : X ⟶ Y) :
star Y ⋙ pullback f ≅ star X :=
conjugateIsoEquiv ((mapPullbackAdj f).comp (forgetAdjStar Y)) (forgetAdjStar X) (mapForget f)

/-- The functor `Over.pullback f : Over Y ⥤ Over X` is naturally isomorphic to
`Over.star : Over Y ⥤ Over (Over.mk f)` post-composed with the
iterated slice equivlanece `Over (Over.mk f) ⥤ Over X`. -/
Expand Down
33 changes: 17 additions & 16 deletions Poly/ForMathlib/CategoryTheory/Comma/Over/Sections.lean
Original file line numberDiff line numberDiff line change
Expand Up@@ -28,7 +28,7 @@ variable {C : Type u₁} [Category.{v₁} C]

attribute [local instance] hasBinaryProducts_of_hasTerminal_and_pullbacks
attribute [local instance] hasFiniteProducts_of_has_binary_and_terminal
attribute [local instance] CartesianMonoidalCategory.ofFiniteProducts
attribute [local instance] CartesianMonoidalCategory.ofHasFiniteProducts

section

Expand DownExpand Up@@ -69,11 +69,11 @@ end

variable [HasTerminal C] [HasPullbacks C]

variable (I : C) [Exponentiable I]
variable (I : C) [Closed I]

/-- The first leg of a cospan constructing a pullback diagram in `C` used to define `sections` . -/
def curryId : ⊤_ C ⟶ (I ⟹ I) :=
CartesianClosed.curry (fst I (⊤_ C))
MonoidalClosed.curry (fst I (⊤_ C))

variable {I}

Expand All@@ -90,14 +90,14 @@ pullback diagram:
⊤_ C ----> I ⟹ I
```-/
abbrev sectionsObj (X : Over I) : C :=
Limits.pullback (curryId I) ((exp I).map X.hom)
Limits.pullback (curryId I) ((ihom I).map X.hom)

/-- The functoriality of `sectionsObj`. -/
def sectionsMap {X X' : Over I} (u : X ⟶ X') :
sectionsObj X ⟶ sectionsObj X' := by
fapply pullback.map
· exact 𝟙 _
· exact (exp I).map u.left
· exact (ihom I).map u.left
· exact 𝟙 _
· simp only [comp_id, id_comp]
· simp only [comp_id, ← Functor.map_comp, w]
Expand DownExpand Up@@ -130,29 +130,30 @@ variable {I}
in `C`. See `sectionsCurry`. -/
def sectionsCurryAux {X : Over I} {A : C} (u : (star I).obj A ⟶ X) :
A ⟶ (I ⟹ X.left) :=
CartesianClosed.curry (u.left)
MonoidalClosed.curry (u.left)

/-- The currying operation `Hom ((star I).obj A) X → Hom A (I ⟹ X.left)`. -/
def sectionsCurry {X : Over I} {A : C} (u : (star I).obj A ⟶ X) :
A ⟶ (sections I).obj X := by
apply pullback.lift (terminal.from A)
(CartesianClosed.curry ((prodIsoTensorObj _ _).inv ≫ u.left)) (uncurry_injective _)
rw [uncurry_natural_left]
simp [curryId, uncurry_natural_right, uncurry_curry]
(MonoidalClosed.curry ((prodIsoTensorObj _ _).inv ≫ u.left))
(MonoidalClosed.uncurry_injective _)
rw [MonoidalClosed.uncurry_natural_left]
simp [curryId, MonoidalClosed.uncurry_natural_right, MonoidalClosed.uncurry_curry]

/-- The uncurrying operation `Hom A (section X) → Hom ((star I).obj A) X`. -/
def sectionsUncurry {X : Over I} {A : C} (v : A ⟶ (sections I).obj X) :
(star I).obj A ⟶ X := by
let v₂ : A ⟶ (I ⟹ X.left) := v ≫ pullback.snd ..
have w : terminal.from A ≫ (curryId I) = v₂ ≫ (exp I).map X.hom := by
have w : terminal.from A ≫ (curryId I) = v₂ ≫ (ihom I).map X.hom := by
rw [IsTerminal.hom_ext terminalIsTerminal (terminal.from A ) (v ≫ (pullback.fst ..))]
simp [v₂, pullback.condition]
dsimp [curryId] at w
have w' := homEquiv_naturality_right_square (F := MonoidalCategory.tensorLeft I)
(adj := exp.adjunction I) _ _ _ _ w
simp [CartesianClosed.curry] at w'
refine Over.homMk ((prodIsoTensorObj I A).hom ≫ CartesianClosed.uncurry v₂) ?_
· dsimp [CartesianClosed.uncurry] at *
(adj := ihom.adjunction I) _ _ _ _ w
simp [MonoidalClosed.curry] at w'
refine Over.homMk ((prodIsoTensorObj I A).hom ≫ MonoidalClosed.uncurry v₂) ?_
· dsimp [MonoidalClosed.uncurry] at *
rw [Category.assoc, ← w']
simp [star_obj_hom]

Expand DownExpand Up@@ -188,13 +189,13 @@ def coreHomEquiv : CoreHomEquiv (star I) (sections I) where
simp only [star_map]
rw [← Over.homMk_comp] -- note: in a newer version of mathlib this is `Over.homMk_eta`
congr 1
simp [CartesianClosed.uncurry_natural_left]
simp [MonoidalClosed.uncurry_natural_left]
homEquiv_naturality_right := by
intro A X' X u g
dsimp [sectionsCurry, sectionsUncurry, curryId]
apply pullback.hom_ext (IsTerminal.hom_ext terminalIsTerminal _ _)
simp [sectionsMap, curryId]
rw [← CartesianClosed.curry_natural_right, Category.assoc]
rw [← MonoidalClosed.curry_natural_right, Category.assoc]

variable (I)

Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,7 +3,7 @@ Copyright (c) 2025 Wojciech Nawrocki. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Wojciech Nawrocki
-/
import Mathlib.CategoryTheory.Limits.Shapes.Pullback.CommSq
import Mathlib.CategoryTheory.Limits.Shapes.Pullback.IsPullback.Basic
import Poly.ForMathlib.CategoryTheory.CommSq

namespace CategoryTheory.Functor
Expand Down
21 changes: 11 additions & 10 deletions Poly/ForMathlib/CategoryTheory/LocallyCartesianClosed/Basic.lean
Original file line numberDiff line numberDiff line change
Expand Up@@ -67,7 +67,7 @@ open CategoryTheory Category MonoidalCategory CartesianMonoidalCategory Limits F

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

attribute [local instance] CartesianMonoidalCategory.ofFiniteProducts
attribute [local instance] CartesianMonoidalCategory.ofHasFiniteProducts

/-- A morphism `f : I ⟶ J` is exponentiable if the pullback functor `Over J ⥤ Over I`
has a right adjoint. -/
Expand DownExpand Up@@ -179,7 +179,7 @@ instance isMultiplicative : (ExponentiableMorphism (C:= C)).IsMultiplicative whe
/-- A morphism with a pushforward is an exponentiable object in the slice category. -/
def exponentiableOverMk [HasFiniteWidePullbacks C] {X I : C} (f : X ⟶ I)
[ExponentiableMorphism f] :
Exponentiable (Over.mk f) where
Closed (Over.mk f) where
rightAdj := pullback f ⋙ pushforward f
adj := by
apply ofNatIsoLeft _ _
Expand All@@ -192,7 +192,7 @@ morphism `X.hom`.
Here the pushforward functor along a morphism `f : I ⟶ J` is defined using the section functor
`Over (Over.mk f) ⥤ Over J`.
-/
def ofOverExponentiable [HasFiniteWidePullbacks C] {I : C} (X : Over I) [Exponentiable X] :
def ofOverExponentiable [HasFiniteWidePullbacks C] {I : C} (X : Over I) [Closed X] :
ExponentiableMorphism X.hom :=
⟨X.iteratedSliceEquiv.inverse ⋙ sections X, ⟨by
refine ofNatIsoLeft (Adjunction.comp ?_ ?_) (starIteratedSliceForwardIsoPullback X.hom)
Expand All@@ -217,7 +217,7 @@ variable {C} [HasFiniteWidePullbacks C] [HasPushforwards C]
/-- In a category where pushforwards exists along all morphisms, every slice category `Over I` is
cartesian closed. -/
instance cartesianClosedOver (I : C) :
CartesianClosed (Over I) where
MonoidalClosed (Over I) where
closed X := @exponentiableOverMk _ _ _ _ _ _ X.hom (HasPushforwards.exponentiable X.hom)

end HasPushforwards
Expand All@@ -226,13 +226,13 @@ namespace CartesianClosedOver

open Over Reindex IsIso CartesianClosed HasPushforwards ExponentiableMorphism

variable {C} [HasFiniteWidePullbacks C] {I J : C} [CartesianClosed (Over J)]
variable {C} [HasFiniteWidePullbacks C] {I J : C} [MonoidalClosed (Over J)]

instance (f : I ⟶ J) : ExponentiableMorphism f :=
ExponentiableMorphism.ofOverExponentiable (Over.mk f)

/-- A category with cartesian closed slices has pushforwards along all morphisms. -/
instance hasPushforwards [Π (I : C), CartesianClosed (Over I)] : HasPushforwards C where
instance hasPushforwards [Π (I : C), MonoidalClosed (Over I)] : HasPushforwards C where
exponentiable f := ExponentiableMorphism.ofOverExponentiable (Over.mk f)

end CartesianClosedOver
Expand All@@ -242,7 +242,7 @@ is exponentiable and all the slices are cartesian closed. -/
class LocallyCartesianClosed [HasFiniteWidePullbacks C] extends
HasPushforwards C where
/-- every slice category `Over I` is cartesian closed. This is filled in by default. -/
cartesianClosedOver : Π (I : C), CartesianClosed (Over I) := HasPushforwards.cartesianClosedOver
cartesianClosedOver : Π (I : C), MonoidalClosed (Over I) := HasPushforwards.cartesianClosedOver

namespace LocallyCartesianClosed

Expand All@@ -256,7 +256,7 @@ attribute [scoped instance] hasFiniteLimits_of_hasTerminal_and_pullbacks
instance mkOfHasPushforwards [HasPushforwards C] : LocallyCartesianClosed C where

/-- A category with cartesian closed slices is locally cartesian closed. -/
instance mkOfCartesianClosedOver [Π (I : C), CartesianClosed (Over I)] :
instance mkOfCartesianClosedOver [Π (I : C), MonoidalClosed (Over I)] :
LocallyCartesianClosed C where

variable [LocallyCartesianClosed C]
Expand All@@ -282,15 +282,16 @@ abbrev ev' {I : C} (X : Over I) (Y : Over X.left) : Reindex X (Pi X Y) ⟶ Y :=
adj X.hom |>.counit.app Y

/-- A locally cartesian closed category with a terminal object is cartesian closed. -/
def cartesianClosed [HasTerminal C] :
CartesianClosed C := cartesianClosedOfEquiv <| equivOverTerminal C
def monoidalClosed [HasTerminal C] :
MonoidalClosed C := cartesianClosedOfEquiv <| equivOverTerminal C

/-- The slices of a locally cartesian closed category are locally cartesian closed. -/
def overLocallyCartesianClosed (I : C) : LocallyCartesianClosed (Over I) := by
apply (config := { allowSynthFailures:= true}) mkOfCartesianClosedOver
intro X
exact cartesianClosedOfEquiv (C := Over (X.left)) X.iteratedSliceEquiv.symm

open CartesianClosed in
/-- The exponential `X^^A` in the slice category `Over I` is isomorphic to the pushforward of the
pullback of `X` along `A`. -/
def expIso {I : C} (A X : Over I) : Pi A (Reindex A X) ≅ A ⟹ X := Iso.refl _
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
Authors: Sina Hazratpour, Emily Riehl
-/
import Poly.ForMathlib.CategoryTheory.LocallyCartesianClosed.Basic
import Mathlib.CategoryTheory.Limits.Shapes.Pullback.CommSq
import Mathlib.CategoryTheory.Limits.Shapes.Pullback.IsPullback.Basic

/-!
# Beck-Chevalley natural transformations and natural isomorphisms
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -22,10 +22,10 @@ abbrev Psh (C : Type u) [Category.{v} C] : Type (max u (v + 1)) := Cᵒᵖ ⥤ T

variable {C : Type*} [SmallCategory C] [HasTerminal C]

attribute [local instance] CartesianMonoidalCategory.ofFiniteProducts
attribute [local instance] CartesianMonoidalCategory.ofHasFiniteProducts

instance cartesianClosedOver {C : Type u} [Category.{max u v} C] (P : Psh C) :
CartesianClosed (Over P) :=
instance monoidalClosedOver {C : Type u} [Category.{max u v} C] (P : Psh C) :
MonoidalClosed (Over P) :=
cartesianClosedOfEquiv (overEquivPresheafCostructuredArrow P).symm

instance locallyCartesianClosed : LocallyCartesianClosed (Psh C) := by
Expand Down
2 changes: 1 addition & 1 deletion Poly/ForMathlib/CategoryTheory/NatTrans.lean
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,7 +6,7 @@ Authors: Sina Hazratpour

import Mathlib.CategoryTheory.NatTrans
import Mathlib.CategoryTheory.Functor.TwoSquare
import Mathlib.CategoryTheory.Limits.Shapes.Pullback.CommSq
import Mathlib.CategoryTheory.Limits.Shapes.Pullback.IsPullback.Basic

open CategoryTheory Limits IsPullback

Expand Down
4 changes: 3 additions & 1 deletion Poly/ForMathlib/CategoryTheory/PartialProduct.lean
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,7 +3,7 @@ Copyright (c) 2025 Sina Hazratpour. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Sina Hazratpour
-/
import Mathlib.CategoryTheory.Limits.Shapes.Pullback.CommSq
import Mathlib.CategoryTheory.Limits.Shapes.Pullback.IsPullback.Basic
import Mathlib.CategoryTheory.Comma.Over.Pullback
import Poly.ForMathlib.CategoryTheory.Comma.Over.Pullback
import Mathlib.CategoryTheory.Monoidal.Closed.Cartesian
Expand DownExpand Up@@ -100,6 +100,8 @@ structure Fan.Hom (c c' : Fan s X) where

attribute [reassoc (attr := simp)] Fan.Hom.w_left Fan.Hom.w_right

-- TODO: this is taking ages to check since 4.28.0-rc1.
set_option maxHeartbeats 0 in
@[simps]
instance : Category (Fan s X) where
Hom := Fan.Hom
Expand Down
2 changes: 1 addition & 1 deletion Poly/Type/Univariate.lean
Original file line numberDiff line numberDiff line change
Expand Up@@ -189,7 +189,7 @@ def Obj.iget [DecidableEq P.B] {X} [Inhabited X] (x : P X) (i : P.Total) : X :=
@[simp]
theorem iget_map [DecidableEq P.B] [Inhabited X] [Inhabited Y] (x : P X)
(f : X → Y) (i : P.Total) (h : i.1 = x.1) : (P.map f x).iget i = f (x.iget i) := by
simp only [Obj.iget, fst_map, *, dif_pos, eq_self_iff_true]
simp only [Obj.iget, fst_map, *, dif_pos]
cases x
rfl

Expand Down
20 changes: 10 additions & 10 deletions lake-manifest.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,7 +15,7 @@
"type": "git",
"subDir": null,
"scope": "",
"rev": "dd5e5d97469dec395f29661366030566355ad9be",
"rev": "b8dad038b1b3a05b77d6884b15b8db03ec01dca1",
"name": "mathlib",
"manifestFile": "lake-manifest.json",
"inputRev": null,
Expand All@@ -25,7 +25,7 @@
"type": "git",
"subDir": null,
"scope": "leanprover-community",
"rev": "b3dd6c3ebc0a71685e86bea9223be39ea4c299fb",
"rev": "7311586e1a56af887b1081d05e80c11b6c41d212",
"name": "plausible",
"manifestFile": "lake-manifest.json",
"inputRev": "main",
Expand All@@ -45,7 +45,7 @@
"type": "git",
"subDir": null,
"scope": "leanprover-community",
"rev": "cff9dd30f2c161b9efd7c657cafed1f967645890",
"rev": "b5908dbac486279f1133cb937648c63c30b455af",
"name": "importGraph",
"manifestFile": "lake-manifest.json",
"inputRev": "main",
Expand All@@ -55,17 +55,17 @@
"type": "git",
"subDir": null,
"scope": "leanprover-community",
"rev": "ef8377f31b5535430b6753a974d685b0019d0681",
"rev": "6d65c6e0a25b8a52c13c3adeb63ecde3bfbb6294",
"name": "proofwidgets",
"manifestFile": "lake-manifest.json",
"inputRev": "v0.0.84",
"inputRev": "v0.0.86",
"inherited": true,
"configFile": "lakefile.lean"},
{"url": "https://github.com/leanprover-community/aesop",
"type": "git",
"subDir": null,
"scope": "leanprover-community",
"rev": "fa78cf032194308a950a264ed87b422a2a7c1c6c",
"rev": "f08e838d4f9aea519f3cde06260cfb686fd4bab0",
"name": "aesop",
"manifestFile": "lake-manifest.json",
"inputRev": "master",
Expand All@@ -75,7 +75,7 @@
"type": "git",
"subDir": null,
"scope": "leanprover-community",
"rev": "8920dcbb96a4e8bf641fc399ac9c0888e4a6be72",
"rev": "23324752757bf28124a518ec284044c8db79fee5",
"name": "Qq",
"manifestFile": "lake-manifest.json",
"inputRev": "master",
Expand All@@ -85,7 +85,7 @@
"type": "git",
"subDir": null,
"scope": "leanprover-community",
"rev": "dff865b7ee7011518d59abfc101c368293173150",
"rev": "100083c18750b6a9b7553c65f6b052c0a2f6bcb4",
"name": "batteries",
"manifestFile": "lake-manifest.json",
"inputRev": "main",
Expand All@@ -95,10 +95,10 @@
"type": "git",
"subDir": null,
"scope": "leanprover",
"rev": "726b98c53e2da249c1de768fbbbb5e67bc9cef60",
"rev": "28e0856d4424863a85b18f38868c5420c55f9bae",
"name": "Cli",
"manifestFile": "lake-manifest.json",
"inputRev": "v4.27.0-rc1",
"inputRev": "v4.28.0-rc1",
"inherited": true,
"configFile": "lakefile.toml"}],
"name": "Poly",
Expand Down
2 changes: 1 addition & 1 deletion lean-toolchain
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
leanprover/lean4:v4.27.0-rc1
leanprover/lean4:v4.28.0-rc1
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 0 additions & 4 deletions Poly/ForMathlib/CategoryTheory/Comma/Over/Basic.lean
Original file line numberDiff line numberDiff line change
Expand Up@@ -35,10 +35,6 @@ lemma homMk_comp'_assoc {X Y Z W : T} (f : X ⟶ Y) (g : Y ⟶ Z) (h : Z ⟶ W)
lemma homMk_id {X B : T} (f : X ⟶ B) (h : 𝟙 X ≫ f = f) : homMk (𝟙 X) h = 𝟙 (mk f) :=
rfl

@[simp]
theorem mkIdTerminal_from_left {B : T} (U : Over B) : (mkIdTerminal.from U).left = U.hom := by
simp [mkIdTerminal, CostructuredArrow.mkIdTerminal, Limits.IsTerminal.from, Functor.preimage]

/-- `Over.Sigma Y U` is a shorthand for `(Over.map Y.hom).obj U`.
This is a category-theoretic analogue of `Sigma` for types. -/
abbrev Sigma {X : T} (Y : Over X) (U : Over (Y.left)) : Over X :=
Expand Down
12 changes: 3 additions & 9 deletions Poly/ForMathlib/CategoryTheory/Comma/Over/Pullback.lean
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,7 +9,7 @@ import Mathlib.CategoryTheory.Limits.Constructions.Over.Basic
import Mathlib.CategoryTheory.Monad.Products
import Poly.ForMathlib.CategoryTheory.Comma.Over.Basic
import Poly.ForMathlib.CategoryTheory.NatTrans
import Poly.ForMathlib.CategoryTheory.Limits.Shapes.Pullback.CommSq
import Poly.ForMathlib.CategoryTheory.Limits.Shapes.Pullback.IsPullback.Basic

noncomputable section

Expand All@@ -19,7 +19,7 @@ namespace CategoryTheory

open Category Limits Comonad MonoidalCategory CartesianMonoidalCategory

attribute [local instance] CartesianMonoidalCategory.ofFiniteProducts
attribute [local instance] CartesianMonoidalCategory.ofHasFiniteProducts

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

Expand DownExpand Up@@ -211,7 +211,7 @@ lemma star_map [HasBinaryProducts C] {X : C} {Y Z : C} (f : Y ⟶ Z) :
instance [HasBinaryProducts C] (X : C) : (forget X).IsLeftAdjoint :=
⟨_, ⟨forgetAdjStar X⟩⟩

attribute [local instance] CartesianMonoidalCategory.ofFiniteProducts
attribute [local instance] CartesianMonoidalCategory.ofHasFiniteProducts

lemma whiskerLeftProdMapId [HasFiniteLimits C] {X : C} {A A' : C} {g : A ⟶ A'} :
X ◁ g = prod.map (𝟙 X) g := by
Expand DownExpand Up@@ -298,12 +298,6 @@ def starIsoToOverTerminal [HasTerminal C] [HasBinaryProducts C] :

variable {C}

/-- A natural isomorphism between the functors `star X` and `star Y ⋙ pullback f`
for any morphism `f : X ⟶ Y`. -/
def starPullbackIsoStar [HasBinaryProducts C] [HasPullbacks C] {X Y : C} (f : X ⟶ Y) :
star Y ⋙ pullback f ≅ star X :=
conjugateIsoEquiv ((mapPullbackAdj f).comp (forgetAdjStar Y)) (forgetAdjStar X) (mapForget f)

/-- The functor `Over.pullback f : Over Y ⥤ Over X` is naturally isomorphic to
`Over.star : Over Y ⥤ Over (Over.mk f)` post-composed with the
iterated slice equivlanece `Over (Over.mk f) ⥤ Over X`. -/
Expand Down
33 changes: 17 additions & 16 deletions Poly/ForMathlib/CategoryTheory/Comma/Over/Sections.lean
Original file line numberDiff line numberDiff line change
Expand Up@@ -28,7 +28,7 @@ variable {C : Type u₁} [Category.{v₁} C]

attribute [local instance] hasBinaryProducts_of_hasTerminal_and_pullbacks
attribute [local instance] hasFiniteProducts_of_has_binary_and_terminal
attribute [local instance] CartesianMonoidalCategory.ofFiniteProducts
attribute [local instance] CartesianMonoidalCategory.ofHasFiniteProducts

section

Expand DownExpand Up@@ -69,11 +69,11 @@ end

variable [HasTerminal C] [HasPullbacks C]

variable (I : C) [Exponentiable I]
variable (I : C) [Closed I]

/-- The first leg of a cospan constructing a pullback diagram in `C` used to define `sections` . -/
def curryId : ⊤_ C ⟶ (I ⟹ I) :=
CartesianClosed.curry (fst I (⊤_ C))
MonoidalClosed.curry (fst I (⊤_ C))

variable {I}

Expand All@@ -90,14 +90,14 @@ pullback diagram:
⊤_ C ----> I ⟹ I
```-/
abbrev sectionsObj (X : Over I) : C :=
Limits.pullback (curryId I) ((exp I).map X.hom)
Limits.pullback (curryId I) ((ihom I).map X.hom)

/-- The functoriality of `sectionsObj`. -/
def sectionsMap {X X' : Over I} (u : X ⟶ X') :
sectionsObj X ⟶ sectionsObj X' := by
fapply pullback.map
· exact 𝟙 _
· exact (exp I).map u.left
· exact (ihom I).map u.left
· exact 𝟙 _
· simp only [comp_id, id_comp]
· simp only [comp_id, ← Functor.map_comp, w]
Expand DownExpand Up@@ -130,29 +130,30 @@ variable {I}
in `C`. See `sectionsCurry`. -/
def sectionsCurryAux {X : Over I} {A : C} (u : (star I).obj A ⟶ X) :
A ⟶ (I ⟹ X.left) :=
CartesianClosed.curry (u.left)
MonoidalClosed.curry (u.left)

/-- The currying operation `Hom ((star I).obj A) X → Hom A (I ⟹ X.left)`. -/
def sectionsCurry {X : Over I} {A : C} (u : (star I).obj A ⟶ X) :
A ⟶ (sections I).obj X := by
apply pullback.lift (terminal.from A)
(CartesianClosed.curry ((prodIsoTensorObj _ _).inv ≫ u.left)) (uncurry_injective _)
rw [uncurry_natural_left]
simp [curryId, uncurry_natural_right, uncurry_curry]
(MonoidalClosed.curry ((prodIsoTensorObj _ _).inv ≫ u.left))
(MonoidalClosed.uncurry_injective _)
rw [MonoidalClosed.uncurry_natural_left]
simp [curryId, MonoidalClosed.uncurry_natural_right, MonoidalClosed.uncurry_curry]

/-- The uncurrying operation `Hom A (section X) → Hom ((star I).obj A) X`. -/
def sectionsUncurry {X : Over I} {A : C} (v : A ⟶ (sections I).obj X) :
(star I).obj A ⟶ X := by
let v₂ : A ⟶ (I ⟹ X.left) := v ≫ pullback.snd ..
have w : terminal.from A ≫ (curryId I) = v₂ ≫ (exp I).map X.hom := by
have w : terminal.from A ≫ (curryId I) = v₂ ≫ (ihom I).map X.hom := by
rw [IsTerminal.hom_ext terminalIsTerminal (terminal.from A ) (v ≫ (pullback.fst ..))]
simp [v₂, pullback.condition]
dsimp [curryId] at w
have w' := homEquiv_naturality_right_square (F := MonoidalCategory.tensorLeft I)
(adj := exp.adjunction I) _ _ _ _ w
simp [CartesianClosed.curry] at w'
refine Over.homMk ((prodIsoTensorObj I A).hom ≫ CartesianClosed.uncurry v₂) ?_
· dsimp [CartesianClosed.uncurry] at *
(adj := ihom.adjunction I) _ _ _ _ w
simp [MonoidalClosed.curry] at w'
refine Over.homMk ((prodIsoTensorObj I A).hom ≫ MonoidalClosed.uncurry v₂) ?_
· dsimp [MonoidalClosed.uncurry] at *
rw [Category.assoc, ← w']
simp [star_obj_hom]

Expand DownExpand Up@@ -188,13 +189,13 @@ def coreHomEquiv : CoreHomEquiv (star I) (sections I) where
simp only [star_map]
rw [← Over.homMk_comp] -- note: in a newer version of mathlib this is `Over.homMk_eta`
congr 1
simp [CartesianClosed.uncurry_natural_left]
simp [MonoidalClosed.uncurry_natural_left]
homEquiv_naturality_right := by
intro A X' X u g
dsimp [sectionsCurry, sectionsUncurry, curryId]
apply pullback.hom_ext (IsTerminal.hom_ext terminalIsTerminal _ _)
simp [sectionsMap, curryId]
rw [← CartesianClosed.curry_natural_right, Category.assoc]
rw [← MonoidalClosed.curry_natural_right, Category.assoc]

variable (I)

Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,7 +3,7 @@ Copyright (c) 2025 Wojciech Nawrocki. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Wojciech Nawrocki
-/
import Mathlib.CategoryTheory.Limits.Shapes.Pullback.CommSq
import Mathlib.CategoryTheory.Limits.Shapes.Pullback.IsPullback.Basic
import Poly.ForMathlib.CategoryTheory.CommSq

namespace CategoryTheory.Functor
Expand Down
21 changes: 11 additions & 10 deletions Poly/ForMathlib/CategoryTheory/LocallyCartesianClosed/Basic.lean
Original file line numberDiff line numberDiff line change
Expand Up@@ -67,7 +67,7 @@ open CategoryTheory Category MonoidalCategory CartesianMonoidalCategory Limits F

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

attribute [local instance] CartesianMonoidalCategory.ofFiniteProducts
attribute [local instance] CartesianMonoidalCategory.ofHasFiniteProducts

/-- A morphism `f : I ⟶ J` is exponentiable if the pullback functor `Over J ⥤ Over I`
has a right adjoint. -/
Expand DownExpand Up@@ -179,7 +179,7 @@ instance isMultiplicative : (ExponentiableMorphism (C:= C)).IsMultiplicative whe
/-- A morphism with a pushforward is an exponentiable object in the slice category. -/
def exponentiableOverMk [HasFiniteWidePullbacks C] {X I : C} (f : X ⟶ I)
[ExponentiableMorphism f] :
Exponentiable (Over.mk f) where
Closed (Over.mk f) where
rightAdj := pullback f ⋙ pushforward f
adj := by
apply ofNatIsoLeft _ _
Expand All@@ -192,7 +192,7 @@ morphism `X.hom`.
Here the pushforward functor along a morphism `f : I ⟶ J` is defined using the section functor
`Over (Over.mk f) ⥤ Over J`.
-/
def ofOverExponentiable [HasFiniteWidePullbacks C] {I : C} (X : Over I) [Exponentiable X] :
def ofOverExponentiable [HasFiniteWidePullbacks C] {I : C} (X : Over I) [Closed X] :
ExponentiableMorphism X.hom :=
⟨X.iteratedSliceEquiv.inverse ⋙ sections X, ⟨by
refine ofNatIsoLeft (Adjunction.comp ?_ ?_) (starIteratedSliceForwardIsoPullback X.hom)
Expand All@@ -217,7 +217,7 @@ variable {C} [HasFiniteWidePullbacks C] [HasPushforwards C]
/-- In a category where pushforwards exists along all morphisms, every slice category `Over I` is
cartesian closed. -/
instance cartesianClosedOver (I : C) :
CartesianClosed (Over I) where
MonoidalClosed (Over I) where
closed X := @exponentiableOverMk _ _ _ _ _ _ X.hom (HasPushforwards.exponentiable X.hom)

end HasPushforwards
Expand All@@ -226,13 +226,13 @@ namespace CartesianClosedOver

open Over Reindex IsIso CartesianClosed HasPushforwards ExponentiableMorphism

variable {C} [HasFiniteWidePullbacks C] {I J : C} [CartesianClosed (Over J)]
variable {C} [HasFiniteWidePullbacks C] {I J : C} [MonoidalClosed (Over J)]

instance (f : I ⟶ J) : ExponentiableMorphism f :=
ExponentiableMorphism.ofOverExponentiable (Over.mk f)

/-- A category with cartesian closed slices has pushforwards along all morphisms. -/
instance hasPushforwards [Π (I : C), CartesianClosed (Over I)] : HasPushforwards C where
instance hasPushforwards [Π (I : C), MonoidalClosed (Over I)] : HasPushforwards C where
exponentiable f := ExponentiableMorphism.ofOverExponentiable (Over.mk f)

end CartesianClosedOver
Expand All@@ -242,7 +242,7 @@ is exponentiable and all the slices are cartesian closed. -/
class LocallyCartesianClosed [HasFiniteWidePullbacks C] extends
HasPushforwards C where
/-- every slice category `Over I` is cartesian closed. This is filled in by default. -/
cartesianClosedOver : Π (I : C), CartesianClosed (Over I) := HasPushforwards.cartesianClosedOver
cartesianClosedOver : Π (I : C), MonoidalClosed (Over I) := HasPushforwards.cartesianClosedOver

namespace LocallyCartesianClosed

Expand All@@ -256,7 +256,7 @@ attribute [scoped instance] hasFiniteLimits_of_hasTerminal_and_pullbacks
instance mkOfHasPushforwards [HasPushforwards C] : LocallyCartesianClosed C where

/-- A category with cartesian closed slices is locally cartesian closed. -/
instance mkOfCartesianClosedOver [Π (I : C), CartesianClosed (Over I)] :
instance mkOfCartesianClosedOver [Π (I : C), MonoidalClosed (Over I)] :
LocallyCartesianClosed C where

variable [LocallyCartesianClosed C]
Expand All@@ -282,15 +282,16 @@ abbrev ev' {I : C} (X : Over I) (Y : Over X.left) : Reindex X (Pi X Y) ⟶ Y :=
adj X.hom |>.counit.app Y

/-- A locally cartesian closed category with a terminal object is cartesian closed. -/
def cartesianClosed [HasTerminal C] :
CartesianClosed C := cartesianClosedOfEquiv <| equivOverTerminal C
def monoidalClosed [HasTerminal C] :
MonoidalClosed C := cartesianClosedOfEquiv <| equivOverTerminal C

/-- The slices of a locally cartesian closed category are locally cartesian closed. -/
def overLocallyCartesianClosed (I : C) : LocallyCartesianClosed (Over I) := by
apply (config := { allowSynthFailures:= true}) mkOfCartesianClosedOver
intro X
exact cartesianClosedOfEquiv (C := Over (X.left)) X.iteratedSliceEquiv.symm

open CartesianClosed in
/-- The exponential `X^^A` in the slice category `Over I` is isomorphic to the pushforward of the
pullback of `X` along `A`. -/
def expIso {I : C} (A X : Over I) : Pi A (Reindex A X) ≅ A ⟹ X := Iso.refl _
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
Authors: Sina Hazratpour, Emily Riehl
-/
import Poly.ForMathlib.CategoryTheory.LocallyCartesianClosed.Basic
import Mathlib.CategoryTheory.Limits.Shapes.Pullback.CommSq
import Mathlib.CategoryTheory.Limits.Shapes.Pullback.IsPullback.Basic

/-!
# Beck-Chevalley natural transformations and natural isomorphisms
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -22,10 +22,10 @@ abbrev Psh (C : Type u) [Category.{v} C] : Type (max u (v + 1)) := Cᵒᵖ ⥤ T

variable {C : Type*} [SmallCategory C] [HasTerminal C]

attribute [local instance] CartesianMonoidalCategory.ofFiniteProducts
attribute [local instance] CartesianMonoidalCategory.ofHasFiniteProducts

instance cartesianClosedOver {C : Type u} [Category.{max u v} C] (P : Psh C) :
CartesianClosed (Over P) :=
instance monoidalClosedOver {C : Type u} [Category.{max u v} C] (P : Psh C) :
MonoidalClosed (Over P) :=
cartesianClosedOfEquiv (overEquivPresheafCostructuredArrow P).symm

instance locallyCartesianClosed : LocallyCartesianClosed (Psh C) := by
Expand Down
2 changes: 1 addition & 1 deletion Poly/ForMathlib/CategoryTheory/NatTrans.lean
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,7 +6,7 @@ Authors: Sina Hazratpour

import Mathlib.CategoryTheory.NatTrans
import Mathlib.CategoryTheory.Functor.TwoSquare
import Mathlib.CategoryTheory.Limits.Shapes.Pullback.CommSq
import Mathlib.CategoryTheory.Limits.Shapes.Pullback.IsPullback.Basic

open CategoryTheory Limits IsPullback

Expand Down
4 changes: 3 additions & 1 deletion Poly/ForMathlib/CategoryTheory/PartialProduct.lean
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,7 +3,7 @@ Copyright (c) 2025 Sina Hazratpour. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Sina Hazratpour
-/
import Mathlib.CategoryTheory.Limits.Shapes.Pullback.CommSq
import Mathlib.CategoryTheory.Limits.Shapes.Pullback.IsPullback.Basic
import Mathlib.CategoryTheory.Comma.Over.Pullback
import Poly.ForMathlib.CategoryTheory.Comma.Over.Pullback
import Mathlib.CategoryTheory.Monoidal.Closed.Cartesian
Expand DownExpand Up@@ -100,6 +100,8 @@ structure Fan.Hom (c c' : Fan s X) where

attribute [reassoc (attr := simp)] Fan.Hom.w_left Fan.Hom.w_right

-- TODO: this is taking ages to check since 4.28.0-rc1.
set_option maxHeartbeats 0 in
@[simps]
instance : Category (Fan s X) where
Hom := Fan.Hom
Expand Down
2 changes: 1 addition & 1 deletion Poly/Type/Univariate.lean
Original file line numberDiff line numberDiff line change
Expand Up@@ -189,7 +189,7 @@ def Obj.iget [DecidableEq P.B] {X} [Inhabited X] (x : P X) (i : P.Total) : X :=
@[simp]
theorem iget_map [DecidableEq P.B] [Inhabited X] [Inhabited Y] (x : P X)
(f : X → Y) (i : P.Total) (h : i.1 = x.1) : (P.map f x).iget i = f (x.iget i) := by
simp only [Obj.iget, fst_map, *, dif_pos, eq_self_iff_true]
simp only [Obj.iget, fst_map, *, dif_pos]
cases x
rfl

Expand Down
20 changes: 10 additions & 10 deletions lake-manifest.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,7 +15,7 @@
"type": "git",
"subDir": null,
"scope": "",
"rev": "dd5e5d97469dec395f29661366030566355ad9be",
"rev": "b8dad038b1b3a05b77d6884b15b8db03ec01dca1",
"name": "mathlib",
"manifestFile": "lake-manifest.json",
"inputRev": null,
Expand All@@ -25,7 +25,7 @@
"type": "git",
"subDir": null,
"scope": "leanprover-community",
"rev": "b3dd6c3ebc0a71685e86bea9223be39ea4c299fb",
"rev": "7311586e1a56af887b1081d05e80c11b6c41d212",
"name": "plausible",
"manifestFile": "lake-manifest.json",
"inputRev": "main",
Expand All@@ -45,7 +45,7 @@
"type": "git",
"subDir": null,
"scope": "leanprover-community",
"rev": "cff9dd30f2c161b9efd7c657cafed1f967645890",
"rev": "b5908dbac486279f1133cb937648c63c30b455af",
"name": "importGraph",
"manifestFile": "lake-manifest.json",
"inputRev": "main",
Expand All@@ -55,17 +55,17 @@
"type": "git",
"subDir": null,
"scope": "leanprover-community",
"rev": "ef8377f31b5535430b6753a974d685b0019d0681",
"rev": "6d65c6e0a25b8a52c13c3adeb63ecde3bfbb6294",
"name": "proofwidgets",
"manifestFile": "lake-manifest.json",
"inputRev": "v0.0.84",
"inputRev": "v0.0.86",
"inherited": true,
"configFile": "lakefile.lean"},
{"url": "https://github.com/leanprover-community/aesop",
"type": "git",
"subDir": null,
"scope": "leanprover-community",
"rev": "fa78cf032194308a950a264ed87b422a2a7c1c6c",
"rev": "f08e838d4f9aea519f3cde06260cfb686fd4bab0",
"name": "aesop",
"manifestFile": "lake-manifest.json",
"inputRev": "master",
Expand All@@ -75,7 +75,7 @@
"type": "git",
"subDir": null,
"scope": "leanprover-community",
"rev": "8920dcbb96a4e8bf641fc399ac9c0888e4a6be72",
"rev": "23324752757bf28124a518ec284044c8db79fee5",
"name": "Qq",
"manifestFile": "lake-manifest.json",
"inputRev": "master",
Expand All@@ -85,7 +85,7 @@
"type": "git",
"subDir": null,
"scope": "leanprover-community",
"rev": "dff865b7ee7011518d59abfc101c368293173150",
"rev": "100083c18750b6a9b7553c65f6b052c0a2f6bcb4",
"name": "batteries",
"manifestFile": "lake-manifest.json",
"inputRev": "main",
Expand All@@ -95,10 +95,10 @@
"type": "git",
"subDir": null,
"scope": "leanprover",
"rev": "726b98c53e2da249c1de768fbbbb5e67bc9cef60",
"rev": "28e0856d4424863a85b18f38868c5420c55f9bae",
"name": "Cli",
"manifestFile": "lake-manifest.json",
"inputRev": "v4.27.0-rc1",
"inputRev": "v4.28.0-rc1",
"inherited": true,
"configFile": "lakefile.toml"}],
"name": "Poly",
Expand Down
2 changes: 1 addition & 1 deletion lean-toolchain
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
leanprover/lean4:v4.27.0-rc1
leanprover/lean4:v4.28.0-rc1
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 0 additions & 4 deletions Poly/ForMathlib/CategoryTheory/Comma/Over/Basic.lean
Original file line numberDiff line numberDiff line change
Expand Up@@ -35,10 +35,6 @@ lemma homMk_comp'_assoc {X Y Z W : T} (f : X ⟶ Y) (g : Y ⟶ Z) (h : Z ⟶ W)
lemma homMk_id {X B : T} (f : X ⟶ B) (h : 𝟙 X ≫ f = f) : homMk (𝟙 X) h = 𝟙 (mk f) :=
rfl

@[simp]
theorem mkIdTerminal_from_left {B : T} (U : Over B) : (mkIdTerminal.from U).left = U.hom := by
simp [mkIdTerminal, CostructuredArrow.mkIdTerminal, Limits.IsTerminal.from, Functor.preimage]

/-- `Over.Sigma Y U` is a shorthand for `(Over.map Y.hom).obj U`.
This is a category-theoretic analogue of `Sigma` for types. -/
abbrev Sigma {X : T} (Y : Over X) (U : Over (Y.left)) : Over X :=
Expand Down
12 changes: 3 additions & 9 deletions Poly/ForMathlib/CategoryTheory/Comma/Over/Pullback.lean
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,7 +9,7 @@ import Mathlib.CategoryTheory.Limits.Constructions.Over.Basic
import Mathlib.CategoryTheory.Monad.Products
import Poly.ForMathlib.CategoryTheory.Comma.Over.Basic
import Poly.ForMathlib.CategoryTheory.NatTrans
import Poly.ForMathlib.CategoryTheory.Limits.Shapes.Pullback.CommSq
import Poly.ForMathlib.CategoryTheory.Limits.Shapes.Pullback.IsPullback.Basic

noncomputable section

Expand All@@ -19,7 +19,7 @@ namespace CategoryTheory

open Category Limits Comonad MonoidalCategory CartesianMonoidalCategory

attribute [local instance] CartesianMonoidalCategory.ofFiniteProducts
attribute [local instance] CartesianMonoidalCategory.ofHasFiniteProducts

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

Expand DownExpand Up@@ -211,7 +211,7 @@ lemma star_map [HasBinaryProducts C] {X : C} {Y Z : C} (f : Y ⟶ Z) :
instance [HasBinaryProducts C] (X : C) : (forget X).IsLeftAdjoint :=
⟨_, ⟨forgetAdjStar X⟩⟩

attribute [local instance] CartesianMonoidalCategory.ofFiniteProducts
attribute [local instance] CartesianMonoidalCategory.ofHasFiniteProducts

lemma whiskerLeftProdMapId [HasFiniteLimits C] {X : C} {A A' : C} {g : A ⟶ A'} :
X ◁ g = prod.map (𝟙 X) g := by
Expand DownExpand Up@@ -298,12 +298,6 @@ def starIsoToOverTerminal [HasTerminal C] [HasBinaryProducts C] :

variable {C}

/-- A natural isomorphism between the functors `star X` and `star Y ⋙ pullback f`
for any morphism `f : X ⟶ Y`. -/
def starPullbackIsoStar [HasBinaryProducts C] [HasPullbacks C] {X Y : C} (f : X ⟶ Y) :
star Y ⋙ pullback f ≅ star X :=
conjugateIsoEquiv ((mapPullbackAdj f).comp (forgetAdjStar Y)) (forgetAdjStar X) (mapForget f)

/-- The functor `Over.pullback f : Over Y ⥤ Over X` is naturally isomorphic to
`Over.star : Over Y ⥤ Over (Over.mk f)` post-composed with the
iterated slice equivlanece `Over (Over.mk f) ⥤ Over X`. -/
Expand Down
33 changes: 17 additions & 16 deletions Poly/ForMathlib/CategoryTheory/Comma/Over/Sections.lean
Original file line numberDiff line numberDiff line change
Expand Up@@ -28,7 +28,7 @@ variable {C : Type u₁} [Category.{v₁} C]

attribute [local instance] hasBinaryProducts_of_hasTerminal_and_pullbacks
attribute [local instance] hasFiniteProducts_of_has_binary_and_terminal
attribute [local instance] CartesianMonoidalCategory.ofFiniteProducts
attribute [local instance] CartesianMonoidalCategory.ofHasFiniteProducts

section

Expand DownExpand Up@@ -69,11 +69,11 @@ end

variable [HasTerminal C] [HasPullbacks C]

variable (I : C) [Exponentiable I]
variable (I : C) [Closed I]

/-- The first leg of a cospan constructing a pullback diagram in `C` used to define `sections` . -/
def curryId : ⊤_ C ⟶ (I ⟹ I) :=
CartesianClosed.curry (fst I (⊤_ C))
MonoidalClosed.curry (fst I (⊤_ C))

variable {I}

Expand All@@ -90,14 +90,14 @@ pullback diagram:
⊤_ C ----> I ⟹ I
```-/
abbrev sectionsObj (X : Over I) : C :=
Limits.pullback (curryId I) ((exp I).map X.hom)
Limits.pullback (curryId I) ((ihom I).map X.hom)

/-- The functoriality of `sectionsObj`. -/
def sectionsMap {X X' : Over I} (u : X ⟶ X') :
sectionsObj X ⟶ sectionsObj X' := by
fapply pullback.map
· exact 𝟙 _
· exact (exp I).map u.left
· exact (ihom I).map u.left
· exact 𝟙 _
· simp only [comp_id, id_comp]
· simp only [comp_id, ← Functor.map_comp, w]
Expand DownExpand Up@@ -130,29 +130,30 @@ variable {I}
in `C`. See `sectionsCurry`. -/
def sectionsCurryAux {X : Over I} {A : C} (u : (star I).obj A ⟶ X) :
A ⟶ (I ⟹ X.left) :=
CartesianClosed.curry (u.left)
MonoidalClosed.curry (u.left)

/-- The currying operation `Hom ((star I).obj A) X → Hom A (I ⟹ X.left)`. -/
def sectionsCurry {X : Over I} {A : C} (u : (star I).obj A ⟶ X) :
A ⟶ (sections I).obj X := by
apply pullback.lift (terminal.from A)
(CartesianClosed.curry ((prodIsoTensorObj _ _).inv ≫ u.left)) (uncurry_injective _)
rw [uncurry_natural_left]
simp [curryId, uncurry_natural_right, uncurry_curry]
(MonoidalClosed.curry ((prodIsoTensorObj _ _).inv ≫ u.left))
(MonoidalClosed.uncurry_injective _)
rw [MonoidalClosed.uncurry_natural_left]
simp [curryId, MonoidalClosed.uncurry_natural_right, MonoidalClosed.uncurry_curry]

/-- The uncurrying operation `Hom A (section X) → Hom ((star I).obj A) X`. -/
def sectionsUncurry {X : Over I} {A : C} (v : A ⟶ (sections I).obj X) :
(star I).obj A ⟶ X := by
let v₂ : A ⟶ (I ⟹ X.left) := v ≫ pullback.snd ..
have w : terminal.from A ≫ (curryId I) = v₂ ≫ (exp I).map X.hom := by
have w : terminal.from A ≫ (curryId I) = v₂ ≫ (ihom I).map X.hom := by
rw [IsTerminal.hom_ext terminalIsTerminal (terminal.from A ) (v ≫ (pullback.fst ..))]
simp [v₂, pullback.condition]
dsimp [curryId] at w
have w' := homEquiv_naturality_right_square (F := MonoidalCategory.tensorLeft I)
(adj := exp.adjunction I) _ _ _ _ w
simp [CartesianClosed.curry] at w'
refine Over.homMk ((prodIsoTensorObj I A).hom ≫ CartesianClosed.uncurry v₂) ?_
· dsimp [CartesianClosed.uncurry] at *
(adj := ihom.adjunction I) _ _ _ _ w
simp [MonoidalClosed.curry] at w'
refine Over.homMk ((prodIsoTensorObj I A).hom ≫ MonoidalClosed.uncurry v₂) ?_
· dsimp [MonoidalClosed.uncurry] at *
rw [Category.assoc, ← w']
simp [star_obj_hom]

Expand DownExpand Up@@ -188,13 +189,13 @@ def coreHomEquiv : CoreHomEquiv (star I) (sections I) where
simp only [star_map]
rw [← Over.homMk_comp] -- note: in a newer version of mathlib this is `Over.homMk_eta`
congr 1
simp [CartesianClosed.uncurry_natural_left]
simp [MonoidalClosed.uncurry_natural_left]
homEquiv_naturality_right := by
intro A X' X u g
dsimp [sectionsCurry, sectionsUncurry, curryId]
apply pullback.hom_ext (IsTerminal.hom_ext terminalIsTerminal _ _)
simp [sectionsMap, curryId]
rw [← CartesianClosed.curry_natural_right, Category.assoc]
rw [← MonoidalClosed.curry_natural_right, Category.assoc]

variable (I)

Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,7 +3,7 @@ Copyright (c) 2025 Wojciech Nawrocki. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Wojciech Nawrocki
-/
import Mathlib.CategoryTheory.Limits.Shapes.Pullback.CommSq
import Mathlib.CategoryTheory.Limits.Shapes.Pullback.IsPullback.Basic
import Poly.ForMathlib.CategoryTheory.CommSq

namespace CategoryTheory.Functor
Expand Down
21 changes: 11 additions & 10 deletions Poly/ForMathlib/CategoryTheory/LocallyCartesianClosed/Basic.lean
Original file line numberDiff line numberDiff line change
Expand Up@@ -67,7 +67,7 @@ open CategoryTheory Category MonoidalCategory CartesianMonoidalCategory Limits F

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

attribute [local instance] CartesianMonoidalCategory.ofFiniteProducts
attribute [local instance] CartesianMonoidalCategory.ofHasFiniteProducts

/-- A morphism `f : I ⟶ J` is exponentiable if the pullback functor `Over J ⥤ Over I`
has a right adjoint. -/
Expand DownExpand Up@@ -179,7 +179,7 @@ instance isMultiplicative : (ExponentiableMorphism (C:= C)).IsMultiplicative whe
/-- A morphism with a pushforward is an exponentiable object in the slice category. -/
def exponentiableOverMk [HasFiniteWidePullbacks C] {X I : C} (f : X ⟶ I)
[ExponentiableMorphism f] :
Exponentiable (Over.mk f) where
Closed (Over.mk f) where
rightAdj := pullback f ⋙ pushforward f
adj := by
apply ofNatIsoLeft _ _
Expand All@@ -192,7 +192,7 @@ morphism `X.hom`.
Here the pushforward functor along a morphism `f : I ⟶ J` is defined using the section functor
`Over (Over.mk f) ⥤ Over J`.
-/
def ofOverExponentiable [HasFiniteWidePullbacks C] {I : C} (X : Over I) [Exponentiable X] :
def ofOverExponentiable [HasFiniteWidePullbacks C] {I : C} (X : Over I) [Closed X] :
ExponentiableMorphism X.hom :=
⟨X.iteratedSliceEquiv.inverse ⋙ sections X, ⟨by
refine ofNatIsoLeft (Adjunction.comp ?_ ?_) (starIteratedSliceForwardIsoPullback X.hom)
Expand All@@ -217,7 +217,7 @@ variable {C} [HasFiniteWidePullbacks C] [HasPushforwards C]
/-- In a category where pushforwards exists along all morphisms, every slice category `Over I` is
cartesian closed. -/
instance cartesianClosedOver (I : C) :
CartesianClosed (Over I) where
MonoidalClosed (Over I) where
closed X := @exponentiableOverMk _ _ _ _ _ _ X.hom (HasPushforwards.exponentiable X.hom)

end HasPushforwards
Expand All@@ -226,13 +226,13 @@ namespace CartesianClosedOver

open Over Reindex IsIso CartesianClosed HasPushforwards ExponentiableMorphism

variable {C} [HasFiniteWidePullbacks C] {I J : C} [CartesianClosed (Over J)]
variable {C} [HasFiniteWidePullbacks C] {I J : C} [MonoidalClosed (Over J)]

instance (f : I ⟶ J) : ExponentiableMorphism f :=
ExponentiableMorphism.ofOverExponentiable (Over.mk f)

/-- A category with cartesian closed slices has pushforwards along all morphisms. -/
instance hasPushforwards [Π (I : C), CartesianClosed (Over I)] : HasPushforwards C where
instance hasPushforwards [Π (I : C), MonoidalClosed (Over I)] : HasPushforwards C where
exponentiable f := ExponentiableMorphism.ofOverExponentiable (Over.mk f)

end CartesianClosedOver
Expand All@@ -242,7 +242,7 @@ is exponentiable and all the slices are cartesian closed. -/
class LocallyCartesianClosed [HasFiniteWidePullbacks C] extends
HasPushforwards C where
/-- every slice category `Over I` is cartesian closed. This is filled in by default. -/
cartesianClosedOver : Π (I : C), CartesianClosed (Over I) := HasPushforwards.cartesianClosedOver
cartesianClosedOver : Π (I : C), MonoidalClosed (Over I) := HasPushforwards.cartesianClosedOver

namespace LocallyCartesianClosed

Expand All@@ -256,7 +256,7 @@ attribute [scoped instance] hasFiniteLimits_of_hasTerminal_and_pullbacks
instance mkOfHasPushforwards [HasPushforwards C] : LocallyCartesianClosed C where

/-- A category with cartesian closed slices is locally cartesian closed. -/
instance mkOfCartesianClosedOver [Π (I : C), CartesianClosed (Over I)] :
instance mkOfCartesianClosedOver [Π (I : C), MonoidalClosed (Over I)] :
LocallyCartesianClosed C where

variable [LocallyCartesianClosed C]
Expand All@@ -282,15 +282,16 @@ abbrev ev' {I : C} (X : Over I) (Y : Over X.left) : Reindex X (Pi X Y) ⟶ Y :=
adj X.hom |>.counit.app Y

/-- A locally cartesian closed category with a terminal object is cartesian closed. -/
def cartesianClosed [HasTerminal C] :
CartesianClosed C := cartesianClosedOfEquiv <| equivOverTerminal C
def monoidalClosed [HasTerminal C] :
MonoidalClosed C := cartesianClosedOfEquiv <| equivOverTerminal C

/-- The slices of a locally cartesian closed category are locally cartesian closed. -/
def overLocallyCartesianClosed (I : C) : LocallyCartesianClosed (Over I) := by
apply (config := { allowSynthFailures:= true}) mkOfCartesianClosedOver
intro X
exact cartesianClosedOfEquiv (C := Over (X.left)) X.iteratedSliceEquiv.symm

open CartesianClosed in
/-- The exponential `X^^A` in the slice category `Over I` is isomorphic to the pushforward of the
pullback of `X` along `A`. -/
def expIso {I : C} (A X : Over I) : Pi A (Reindex A X) ≅ A ⟹ X := Iso.refl _
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
Authors: Sina Hazratpour, Emily Riehl
-/
import Poly.ForMathlib.CategoryTheory.LocallyCartesianClosed.Basic
import Mathlib.CategoryTheory.Limits.Shapes.Pullback.CommSq
import Mathlib.CategoryTheory.Limits.Shapes.Pullback.IsPullback.Basic

/-!
# Beck-Chevalley natural transformations and natural isomorphisms
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -22,10 +22,10 @@ abbrev Psh (C : Type u) [Category.{v} C] : Type (max u (v + 1)) := Cᵒᵖ ⥤ T

variable {C : Type*} [SmallCategory C] [HasTerminal C]

attribute [local instance] CartesianMonoidalCategory.ofFiniteProducts
attribute [local instance] CartesianMonoidalCategory.ofHasFiniteProducts

instance cartesianClosedOver {C : Type u} [Category.{max u v} C] (P : Psh C) :
CartesianClosed (Over P) :=
instance monoidalClosedOver {C : Type u} [Category.{max u v} C] (P : Psh C) :
MonoidalClosed (Over P) :=
cartesianClosedOfEquiv (overEquivPresheafCostructuredArrow P).symm

instance locallyCartesianClosed : LocallyCartesianClosed (Psh C) := by
Expand Down
2 changes: 1 addition & 1 deletion Poly/ForMathlib/CategoryTheory/NatTrans.lean
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,7 +6,7 @@ Authors: Sina Hazratpour

import Mathlib.CategoryTheory.NatTrans
import Mathlib.CategoryTheory.Functor.TwoSquare
import Mathlib.CategoryTheory.Limits.Shapes.Pullback.CommSq
import Mathlib.CategoryTheory.Limits.Shapes.Pullback.IsPullback.Basic

open CategoryTheory Limits IsPullback

Expand Down
4 changes: 3 additions & 1 deletion Poly/ForMathlib/CategoryTheory/PartialProduct.lean
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,7 +3,7 @@ Copyright (c) 2025 Sina Hazratpour. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Sina Hazratpour
-/
import Mathlib.CategoryTheory.Limits.Shapes.Pullback.CommSq
import Mathlib.CategoryTheory.Limits.Shapes.Pullback.IsPullback.Basic
import Mathlib.CategoryTheory.Comma.Over.Pullback
import Poly.ForMathlib.CategoryTheory.Comma.Over.Pullback
import Mathlib.CategoryTheory.Monoidal.Closed.Cartesian
Expand DownExpand Up@@ -100,6 +100,8 @@ structure Fan.Hom (c c' : Fan s X) where

attribute [reassoc (attr := simp)] Fan.Hom.w_left Fan.Hom.w_right

-- TODO: this is taking ages to check since 4.28.0-rc1.
set_option maxHeartbeats 0 in
@[simps]
instance : Category (Fan s X) where
Hom := Fan.Hom
Expand Down
2 changes: 1 addition & 1 deletion Poly/Type/Univariate.lean
Original file line numberDiff line numberDiff line change
Expand Up@@ -189,7 +189,7 @@ def Obj.iget [DecidableEq P.B] {X} [Inhabited X] (x : P X) (i : P.Total) : X :=
@[simp]
theorem iget_map [DecidableEq P.B] [Inhabited X] [Inhabited Y] (x : P X)
(f : X → Y) (i : P.Total) (h : i.1 = x.1) : (P.map f x).iget i = f (x.iget i) := by
simp only [Obj.iget, fst_map, *, dif_pos, eq_self_iff_true]
simp only [Obj.iget, fst_map, *, dif_pos]
cases x
rfl

Expand Down
20 changes: 10 additions & 10 deletions lake-manifest.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,7 +15,7 @@
"type": "git",
"subDir": null,
"scope": "",
"rev": "dd5e5d97469dec395f29661366030566355ad9be",
"rev": "b8dad038b1b3a05b77d6884b15b8db03ec01dca1",
"name": "mathlib",
"manifestFile": "lake-manifest.json",
"inputRev": null,
Expand All@@ -25,7 +25,7 @@
"type": "git",
"subDir": null,
"scope": "leanprover-community",
"rev": "b3dd6c3ebc0a71685e86bea9223be39ea4c299fb",
"rev": "7311586e1a56af887b1081d05e80c11b6c41d212",
"name": "plausible",
"manifestFile": "lake-manifest.json",
"inputRev": "main",
Expand All@@ -45,7 +45,7 @@
"type": "git",
"subDir": null,
"scope": "leanprover-community",
"rev": "cff9dd30f2c161b9efd7c657cafed1f967645890",
"rev": "b5908dbac486279f1133cb937648c63c30b455af",
"name": "importGraph",
"manifestFile": "lake-manifest.json",
"inputRev": "main",
Expand All@@ -55,17 +55,17 @@
"type": "git",
"subDir": null,
"scope": "leanprover-community",
"rev": "ef8377f31b5535430b6753a974d685b0019d0681",
"rev": "6d65c6e0a25b8a52c13c3adeb63ecde3bfbb6294",
"name": "proofwidgets",
"manifestFile": "lake-manifest.json",
"inputRev": "v0.0.84",
"inputRev": "v0.0.86",
"inherited": true,
"configFile": "lakefile.lean"},
{"url": "https://github.com/leanprover-community/aesop",
"type": "git",
"subDir": null,
"scope": "leanprover-community",
"rev": "fa78cf032194308a950a264ed87b422a2a7c1c6c",
"rev": "f08e838d4f9aea519f3cde06260cfb686fd4bab0",
"name": "aesop",
"manifestFile": "lake-manifest.json",
"inputRev": "master",
Expand All@@ -75,7 +75,7 @@
"type": "git",
"subDir": null,
"scope": "leanprover-community",
"rev": "8920dcbb96a4e8bf641fc399ac9c0888e4a6be72",
"rev": "23324752757bf28124a518ec284044c8db79fee5",
"name": "Qq",
"manifestFile": "lake-manifest.json",
"inputRev": "master",
Expand All@@ -85,7 +85,7 @@
"type": "git",
"subDir": null,
"scope": "leanprover-community",
"rev": "dff865b7ee7011518d59abfc101c368293173150",
"rev": "100083c18750b6a9b7553c65f6b052c0a2f6bcb4",
"name": "batteries",
"manifestFile": "lake-manifest.json",
"inputRev": "main",
Expand All@@ -95,10 +95,10 @@
"type": "git",
"subDir": null,
"scope": "leanprover",
"rev": "726b98c53e2da249c1de768fbbbb5e67bc9cef60",
"rev": "28e0856d4424863a85b18f38868c5420c55f9bae",
"name": "Cli",
"manifestFile": "lake-manifest.json",
"inputRev": "v4.27.0-rc1",
"inputRev": "v4.28.0-rc1",
"inherited": true,
"configFile": "lakefile.toml"}],
"name": "Poly",
Expand Down
2 changes: 1 addition & 1 deletion lean-toolchain
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
leanprover/lean4:v4.27.0-rc1
leanprover/lean4:v4.28.0-rc1