Skip to content

Commit b9c5c13

Browse files
authored
Cartesian natural transformation (#31)
* feat: start proving that cartesian NTs are cartesian * feat: counit of mapPullbackAdj is cartesian * chore: cleanup * fix: stray typeclass * feat: finish proof * doc: consistent TwoSquare convention
1 parent b9532aa commit b9c5c13

8 files changed

Lines changed: 202 additions & 96 deletions

File tree

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/-
2+
Copyright (c) 2025 Wojciech Nawrocki. All rights reserved.
3+
Released under Apache 2.0 license as described in the file LICENSE.
4+
Authors: Wojciech Nawrocki
5+
-/
6+
import Mathlib.CategoryTheory.CommSq
7+
8+
namespace CategoryTheory.Functor
9+
10+
theorem reflect_commSq
11+
{C D : Type*} [Category C] [Category D]
12+
(F : C ⥤ D) [Functor.Faithful F]
13+
{X Y Z W : C} {f : X ⟶ Y} {g : X ⟶ Z} {h : Y ⟶ W} {i : Z ⟶ W} :
14+
CommSq (F.map f) (F.map g) (F.map h) (F.map i) →
15+
CommSq f g h i := by
16+
intro cs
17+
constructor
18+
apply Functor.map_injective F
19+
simpa [← Functor.map_comp] using cs.w
20+
21+
end CategoryTheory.Functor

Poly/ForMathlib/CategoryTheory/Comma/Over/Basic.lean

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ lemma homMk_comp'_assoc {X Y Z W : T} (f : X ⟶ Y) (g : Y ⟶ Z) (h : Z ⟶ W)
3535
lemma homMk_id {X B : T} (f : X ⟶ B) (h : 𝟙 X ≫ f = f) : homMk (𝟙 X) h = 𝟙 (mk f) :=
3636
rfl
3737

38+
@[simp]
39+
theorem mkIdTerminal_from_left {B : T} (U : Over B) : (mkIdTerminal.from U).left = U.hom := by
40+
simp [mkIdTerminal, CostructuredArrow.mkIdTerminal, Limits.IsTerminal.from, Functor.preimage]
41+
3842
/-- `Over.Sigma Y U` is a shorthand for `(Over.map Y.hom).obj U`.
3943
This is a category-theoretic analogue of `Sigma` for types. -/
4044
abbrev Sigma {X : T} (Y : Over X) (U : Over (Y.left)) : Over X :=

Poly/ForMathlib/CategoryTheory/Comma/Over/Pullback.lean

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ import Mathlib.CategoryTheory.Monoidal.Cartesian.Basic
88
import Mathlib.CategoryTheory.Limits.Constructions.Over.Basic
99
import Mathlib.CategoryTheory.Monad.Products
1010
import Poly.ForMathlib.CategoryTheory.Comma.Over.Basic
11-
11+
import Poly.ForMathlib.CategoryTheory.NatTrans
12+
import Poly.ForMathlib.CategoryTheory.Limits.Shapes.Pullback.CommSq
1213

1314
noncomputable section
1415

@@ -24,6 +25,19 @@ variable {C : Type u₁} [Category.{v₁} C]
2425

2526
namespace Over
2627

28+
theorem isCartesian_mapPullbackAdj_counit [HasPullbacks C] {X Y : C} (f : X ⟶ Y) :
29+
NatTrans.IsCartesian (Over.mapPullbackAdj f).counit := by
30+
intro A B U
31+
apply IsPullback.of_right
32+
(h₁₂ := Over.homMk (V := Over.mk f) (pullback.snd B.hom f) <| by simp)
33+
(v₁₃ := Over.mkIdTerminal.from _)
34+
(h₂₂ := Over.mkIdTerminal.from _)
35+
case p => ext; simp
36+
. apply (Over.forget Y).reflect_isPullback
37+
convert (IsPullback.of_hasPullback A.hom f).flip using 1 <;> simp
38+
. apply (Over.forget Y).reflect_isPullback
39+
convert (IsPullback.of_hasPullback B.hom f).flip using 1 <;> simp
40+
2741
/-- The reindexing of `Z : Over X` along `Y : Over X`, defined by pulling back `Z` along
2842
`Y.hom : Y.left ⟶ X`. -/
2943
abbrev Reindex [HasPullbacks C] {X : C} (Y : Over X) (Z : Over X) : Over Y.left :=
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/-
2+
Copyright (c) 2025 Wojciech Nawrocki. All rights reserved.
3+
Released under Apache 2.0 license as described in the file LICENSE.
4+
Authors: Wojciech Nawrocki
5+
-/
6+
import Mathlib.CategoryTheory.Limits.Shapes.Pullback.CommSq
7+
import Poly.ForMathlib.CategoryTheory.CommSq
8+
9+
namespace CategoryTheory.Functor
10+
open Limits
11+
12+
theorem reflect_isPullback
13+
{C D : Type*} [Category C] [Category D] (F : C ⥤ D)
14+
{X Y Z W : C} (f : X ⟶ Y) (g : X ⟶ Z) (h : Y ⟶ W) (i : Z ⟶ W)
15+
[rl : ReflectsLimit (cospan h i) F] [Functor.Faithful F] :
16+
IsPullback (F.map f) (F.map g) (F.map h) (F.map i) →
17+
IsPullback f g h i := by
18+
intro pb
19+
have sq := F.reflect_commSq pb.toCommSq
20+
apply IsPullback.mk sq
21+
apply rl.reflects
22+
let i := cospanCompIso F h i
23+
apply IsLimit.equivOfNatIsoOfIso i.symm pb.cone _ _ pb.isLimit
24+
let j :
25+
((Cones.postcompose i.symm.hom).obj pb.cone).pt ≅
26+
(F.mapCone <| PullbackCone.mk f g sq.w).pt :=
27+
Iso.refl _
28+
apply WalkingCospan.ext j <;> simp +zetaDelta
29+
30+
end CategoryTheory.Functor

Poly/ForMathlib/CategoryTheory/LocallyCartesianClosed/BeckChevalley.lean

Lines changed: 34 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -80,41 +80,48 @@ def mapIsoSquare {X Y Z W : C} {h : X ⟶ Z} {f : X ⟶ Y} {g : Z ⟶ W} {k : Y
8080
Over.map h ⋙ Over.map g ≅ Over.map f ⋙ Over.map k :=
8181
eqToIso (map_square_eq sq)
8282

83-
variable [HasBinaryProducts C] [HasPullbacks C]
83+
variable [HasPullbacks C]
8484

8585
variable {X Y Z W : C} (h : X ⟶ Z) (f : X ⟶ Y) (g : Z ⟶ W) (k : Y ⟶ W)
86-
(sq : CommSq h f g k)
86+
(sq : CommSq h f g k)
8787

8888
/-- The Beck-Chevalley natural transformation `pullback f ⋙ map h ⟶ map k ⋙ pullback g`
8989
constructed as a mate of `mapIsoSquare`:
9090
```
91-
Over X -- .map h -> Over Z
92-
93-
.pullback f | | .pullback g
94-
| |
95-
Over Y -- .map k -> Over W
91+
Over Y - pullback f → Over X
92+
| |
93+
map k | | map h
94+
95+
Over W - pullback g → Over Z
9696
```
9797
-/
9898
--pullbackBeckChevalleySquare
9999
def pullbackMapTwoSquare : TwoSquare (pullback f) (map k) (map h) (pullback g) :=
100100
mateEquiv (mapPullbackAdj f) (mapPullbackAdj g) (mapIsoSquare sq).hom
101101

102102
/--
103-
The natural transformation `pullback f ⋙ forget X ⟶ forget Y ⋙ 𝟭 C` as the mate the isomorphism
104-
`mapForget f`:
103+
The natural transformation `pullback f ⋙ forget X ⟶ forget Y ⋙ 𝟭 C`
104+
as the mate of the isomorphism `mapForget f`:
105105
```
106-
Over X --.forget X -> C
107-
|
108-
.pullback f | | 𝟭
109-
| |
110-
Over Y --.forget Y -> C
106+
Over Y - pullback f → Over X
107+
| |
108+
forget Y | | forget X
109+
110+
C ======== 𝟭 ======== C
111111
```
112112
-/
113-
--pullbackForgetBeckChevalleySquare
114-
def pullbackForgetTwoSquare : TwoSquare (pullback f) (forget Y) (forget X) (𝟭 C) := by
115-
let iso := (mapForget f).inv
116-
rw [← Functor.comp_id (forget X)] at iso
117-
exact (mateEquiv (mapPullbackAdj f) (Adjunction.id)) iso
113+
def pullbackForgetTwoSquare : TwoSquare (pullback f) (forget Y) (forget X) (𝟭 C) :=
114+
mateEquiv (mapPullbackAdj f) Adjunction.id (mapForget f).inv
115+
116+
theorem isCartesian_pullbackForgetTwoSquare {X Y : C} (f : X ⟶ Y) :
117+
NatTrans.IsCartesian (pullbackForgetTwoSquare f) := by
118+
unfold pullbackForgetTwoSquare
119+
simp only [mateEquiv_apply]
120+
repeat apply IsCartesian.comp; apply isCartesian_of_isIso
121+
apply IsCartesian.comp
122+
. apply IsCartesian.whiskerRight
123+
apply isCartesian_mapPullbackAdj_counit
124+
. apply isCartesian_of_isIso
118125

119126
/-- The natural transformation `pullback f ⋙ forget X ⟶ forget Y`, a variant of
120127
`pullbackForgetTwoSquare`. -/
@@ -130,7 +137,7 @@ def pullbackMapTriangle (h' : Y ⟶ Z) (w : f ≫ h' = h) :
130137
let iso := (mapComp f h').hom
131138
rw [w] at iso
132139
rw [← Functor.comp_id (map h)] at iso
133-
exact (mateEquiv (mapPullbackAdj f) (Adjunction.id)) iso
140+
exact (mateEquiv (mapPullbackAdj f) Adjunction.id) iso
134141

135142
/-- The isomorphism between the pullbacks along a commutative square. This is constructed as the
136143
conjugate of the `mapIsoSquare`.
@@ -151,11 +158,11 @@ def pullbackIsoSquare : pullback k ⋙ pullback f ≅ pullback g ⋙ pullback h
151158
`pushforward g ⋙ pullback k ⟶ pullback h ⋙ pushforward f` constructed as a mate of
152159
`pullbackMapTwoSquare`.
153160
```
154-
Over X ←-.pullback h-- Over Z
155-
| |
156-
.pushforward f | | .pushforward g
157-
158-
Over Y ←-.pullback k-- Over W
161+
Over Z - pushforward g → Over W
162+
| |
163+
pullback h | | pullback k
164+
165+
Over X - pushforward f → Over Y
159166
```
160167
-/
161168
--pushforwardBeckChevalleySquare
@@ -169,12 +176,11 @@ def pushforwardPullbackTwoSquare
169176
A variant of `pushforwardTwoSquare` involving `star` instead of `pullback`.
170177
-/
171178
--pushforwardStarBeckChevalleySquare
172-
def starPushforwardTriangle
173-
[ExponentiableMorphism f] :
179+
def starPushforwardTriangle [HasBinaryProducts C] [ExponentiableMorphism f] :
174180
star Y ⟶ star X ⋙ pushforward f := by
175181
let iso := (starPullbackIsoStar f).hom
176182
rw [← Functor.id_comp (star X)] at iso
177-
exact (mateEquiv (Adjunction.id) (adj f)) iso
183+
exact (mateEquiv Adjunction.id (adj f)) iso
178184

179185
/-- The conjugate isomorphism between the pushforwards along a commutative square.
180186
```

Poly/ForMathlib/CategoryTheory/LocallyCartesianClosed/Distributivity.lean

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ def cellLeftTriangle : e f u ≫ u = w f u := by
9292
def cellLeft : pullback (e f u) ⋙ map (w f u) ⟶ map u :=
9393
pullbackMapTriangle _ _ _ (cellLeftTriangle f u)
9494

95-
lemma cellLeftCartesian : cartesian (cellLeft f u) := by
96-
unfold cartesian
95+
lemma isCartesian_cellLeft : IsCartesian (cellLeft f u) := by
96+
unfold IsCartesian
9797
simp only [id_obj, mk_left, comp_obj, pullback_obj_left, Functor.comp_map]
9898
unfold cellLeft
9999
intros i j f'
@@ -107,8 +107,8 @@ def cellRightCommSq : CommSq (g f u) (w f u) (v f u) f :=
107107
def cellRight' : pushforward (g f u) ⋙ map (v f u)
108108
≅ map (w f u) ⋙ pushforward f := sorry
109109

110-
lemma cellRightCartesian : cartesian (cellRight' f u).hom :=
111-
cartesian_of_isIso ((cellRight' f u).hom)
110+
lemma isCartesian_cellRight' : IsCartesian (cellRight' f u).hom :=
111+
isCartesian_of_isIso ((cellRight' f u).hom)
112112

113113
def pasteCell1 : pullback (e f u) ⋙ pushforward (g f u) ⋙ map (v f u) ⟶
114114
pullback (e f u) ⋙ map (w f u) ⋙ pushforward f := by
@@ -122,19 +122,19 @@ def pasteCell2 : (pullback (e f u) ⋙ map (w f u)) ⋙ pushforward f
122122

123123
def pasteCell := pasteCell1 f u ≫ pasteCell2 f u
124124

125-
def paste : cartesian (pasteCell f u) := by
126-
apply cartesian.comp
125+
def paste : IsCartesian (pasteCell f u) := by
126+
apply IsCartesian.comp
127127
· unfold pasteCell1
128-
apply cartesian.whiskerLeft (cellRightCartesian f u)
128+
apply (isCartesian_cellRight' f u).whiskerLeft
129129
· unfold pasteCell2
130-
apply cartesian.whiskerRight (cellLeftCartesian f u)
130+
apply (isCartesian_cellLeft f u).whiskerRight
131131

132132
-- use `pushforwardPullbackTwoSquare` to construct this iso.
133133
def pentagonIso : map u ⋙ pushforward f ≅
134134
pullback (e f u) ⋙ pushforward (g f u) ⋙ map (v f u) := by
135-
have := cartesian_of_isPullback_to_terminal (pasteCell f u)
135+
have := isCartesian_of_isPullback_to_terminal (pasteCell f u)
136136
letI : IsIso ((pasteCell f u).app (⊤_ Over ((𝟭 (Over B)).obj (Over.mk u)).left)) := sorry
137-
have := isIso_of_cartesian (pasteCell f u) (paste f u)
137+
have := isIso_of_isCartesian (pasteCell f u) (paste f u)
138138
exact (asIso (pasteCell f u)).symm
139139

140140
end CategoryTheory

0 commit comments

Comments
 (0)