Skip to content

Commit 7499ee4

Browse files
committed
refactor: move morphisms in StructuredArrow to a lower universe (#6397)
This PR changes the definition ```lean abbrev fromPUnit (X : C) : Discrete PUnit.{v + 1} ⥤ C := (Functor.const _).obj X ``` to ```lean abbrev fromPUnit (X : C) : Discrete PUnit.{w + 1} ⥤ C := (Functor.const _).obj X ``` and then redefines ```lean def StructuredArrow (S : D) (T : C ⥤ D) := Comma (Functor.fromPUnit S) T ``` to ```lean def StructuredArrow (S : D) (T : C ⥤ D) := Comma (Functor.fromPUnit.{0} S) T ``` The effect of this is that given `{C : Type u₁} [Category.{v₁} C] {D : Type u₂} [Category.{v₂} D] (S : D) (T : C ⥤ D)`, the morphisms of `StructuredArrow S T` no longer live in `max v₁ v₂`, but in `v₁`, as they should. Thus, this PR is basically a better version of #6388. My guess for why we used to have the larger universe is that back in the day, the universes for limits were much more restricted, so stating the results of `Limits/Comma.lean` was not possible if the morphisms of `StructuredArrow` live in `v₁`. Luckily, by now it is possible to state everything correctly, and this PR adjusts `Limits/Comma.lean` and `Limits/Over.lean` accordingly.
1 parent cf01bda commit 7499ee4

File tree

5 files changed

+45
-42
lines changed

5 files changed

+45
-42
lines changed

Mathlib/CategoryTheory/Closed/Zero.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ object and one morphism.
2323
-/
2424

2525

26-
universe v u
26+
universe w v u
2727

2828
noncomputable section
2929

@@ -60,7 +60,7 @@ attribute [local instance] uniqueHomsetOfZero
6060
/-- A cartesian closed category with a zero object is equivalent to the category with one object and
6161
one morphism.
6262
-/
63-
def equivPUnit [HasZeroObject C] : C ≌ Discrete PUnit :=
63+
def equivPUnit [HasZeroObject C] : C ≌ Discrete PUnit.{w + 1} :=
6464
Equivalence.mk (Functor.star C) (Functor.fromPUnit 0)
6565
(NatIso.ofComponents
6666
(fun X =>

Mathlib/CategoryTheory/Limits/Comma.lean

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ namespace CategoryTheory
2727

2828
open Category Limits
2929

30-
universe w' w v u₁ u₂ u₃
30+
universe w' w v₁ v₂ v₃ u₁ u₂ u₃
3131

3232
variable {J : Type w} [Category.{w'} J]
3333

34-
variable {A : Type u₁} [Category.{v} A]
34+
variable {A : Type u₁} [Category.{v} A]
3535

36-
variable {B : Type u₂} [Category.{v} B]
36+
variable {B : Type u₂} [Category.{v} B]
3737

38-
variable {T : Type u₃} [Category.{v} T]
38+
variable {T : Type u₃} [Category.{v} T]
3939

4040
namespace Comma
4141

@@ -153,9 +153,10 @@ instance hasLimitsOfShape [HasLimitsOfShape J A] [HasLimitsOfShape J B]
153153
[PreservesLimitsOfShape J R] : HasLimitsOfShape J (Comma L R) where
154154
#align category_theory.comma.has_limits_of_shape CategoryTheory.Comma.hasLimitsOfShape
155155

156-
instance hasLimits [HasLimits A] [HasLimits B] [PreservesLimits R] : HasLimits (Comma L R) :=
156+
instance hasLimitsOfSize [HasLimitsOfSize.{w, w'} A] [HasLimitsOfSize.{w, w'} B]
157+
[PreservesLimitsOfSize.{w, w'} R] : HasLimitsOfSize.{w, w'} (Comma L R) :=
157158
fun _ _ => inferInstance⟩
158-
#align category_theory.comma.has_limits CategoryTheory.Comma.hasLimits
159+
#align category_theory.comma.has_limits CategoryTheory.Comma.hasLimitsOfSize
159160

160161
instance hasColimit (F : J ⥤ Comma L R) [HasColimit (F ⋙ fst L R)] [HasColimit (F ⋙ snd L R)]
161162
[PreservesColimit (F ⋙ fst L R) L] : HasColimit F :=
@@ -166,10 +167,10 @@ instance hasColimitsOfShape [HasColimitsOfShape J A] [HasColimitsOfShape J B]
166167
[PreservesColimitsOfShape J L] : HasColimitsOfShape J (Comma L R) where
167168
#align category_theory.comma.has_colimits_of_shape CategoryTheory.Comma.hasColimitsOfShape
168169

169-
instance hasColimits [HasColimits A] [HasColimits B] [PreservesColimits L] :
170-
HasColimits (Comma L R) :=
170+
instance hasColimitsOfSize [HasColimitsOfSize.{w, w'} A] [HasColimitsOfSize.{w, w'} B]
171+
[PreservesColimitsOfSize.{w, w'} L] : HasColimitsOfSize.{w, w'} (Comma L R) :=
171172
fun _ _ => inferInstance⟩
172-
#align category_theory.comma.has_colimits CategoryTheory.Comma.hasColimits
173+
#align category_theory.comma.has_colimits CategoryTheory.Comma.hasColimitsOfSize
173174

174175
end Comma
175176

@@ -220,9 +221,10 @@ instance hasLimitsOfShape [HasLimitsOfShape J A] [PreservesLimitsOfShape J G] :
220221
HasLimitsOfShape J (StructuredArrow X G) where
221222
#align category_theory.structured_arrow.has_limits_of_shape CategoryTheory.StructuredArrow.hasLimitsOfShape
222223

223-
instance hasLimits [HasLimits A] [PreservesLimits G] : HasLimits (StructuredArrow X G) :=
224+
instance hasLimitsOfSize [HasLimitsOfSize.{w, w'} A] [PreservesLimitsOfSize.{w, w'} G] :
225+
HasLimitsOfSize.{w, w'} (StructuredArrow X G) :=
224226
fun J hJ => by infer_instance⟩
225-
#align category_theory.structured_arrow.has_limits CategoryTheory.StructuredArrow.hasLimits
227+
#align category_theory.structured_arrow.has_limits CategoryTheory.StructuredArrow.hasLimitsOfSize
226228

227229
noncomputable instance createsLimit [i : PreservesLimit (F ⋙ proj X G) G] :
228230
CreatesLimit F (proj X G) :=
@@ -237,8 +239,9 @@ noncomputable instance createsLimitsOfShape [PreservesLimitsOfShape J G] :
237239
CreatesLimitsOfShape J (proj X G) where
238240
#align category_theory.structured_arrow.creates_limits_of_shape CategoryTheory.StructuredArrow.createsLimitsOfShape
239241

240-
noncomputable instance createsLimits [PreservesLimits G] : CreatesLimits (proj X G : _) where
241-
#align category_theory.structured_arrow.creates_limits CategoryTheory.StructuredArrow.createsLimits
242+
noncomputable instance createsLimitsOfSize [PreservesLimitsOfSize.{w, w'} G] :
243+
CreatesLimitsOfSize.{w, w'} (proj X G : _) where
244+
#align category_theory.structured_arrow.creates_limits CategoryTheory.StructuredArrow.createsLimitsOfSize
242245

243246
instance mono_right_of_mono [HasPullbacks A] [PreservesLimitsOfShape WalkingCospan G]
244247
{Y Z : StructuredArrow X G} (f : Y ⟶ Z) [Mono f] : Mono f.right :=
@@ -267,9 +270,10 @@ instance hasColimitsOfShape [HasColimitsOfShape J A] [PreservesColimitsOfShape J
267270
HasColimitsOfShape J (CostructuredArrow G X) where
268271
#align category_theory.costructured_arrow.has_colimits_of_shape CategoryTheory.CostructuredArrow.hasColimitsOfShape
269272

270-
instance hasColimits [HasColimits A] [PreservesColimits G] : HasColimits (CostructuredArrow G X) :=
273+
instance hasColimitsOfSize [HasColimitsOfSize.{w, w'} A] [PreservesColimitsOfSize.{w, w'} G] :
274+
HasColimitsOfSize.{w, w'} (CostructuredArrow G X) :=
271275
fun _ _ => inferInstance⟩
272-
#align category_theory.costructured_arrow.has_colimits CategoryTheory.CostructuredArrow.hasColimits
276+
#align category_theory.costructured_arrow.has_colimits CategoryTheory.CostructuredArrow.hasColimitsOfSize
273277

274278
noncomputable instance createsColimit [i : PreservesColimit (F ⋙ proj G X) G] :
275279
CreatesColimit F (proj G X) :=
@@ -284,8 +288,9 @@ noncomputable instance createsColimitsOfShape [PreservesColimitsOfShape J G] :
284288
CreatesColimitsOfShape J (proj G X) where
285289
#align category_theory.costructured_arrow.creates_colimits_of_shape CategoryTheory.CostructuredArrow.createsColimitsOfShape
286290

287-
noncomputable instance createsColimits [PreservesColimits G] : CreatesColimits (proj G X : _) where
288-
#align category_theory.costructured_arrow.creates_colimits CategoryTheory.CostructuredArrow.createsColimits
291+
noncomputable instance createsColimitsOfSize [PreservesColimitsOfSize.{w, w'} G] :
292+
CreatesColimitsOfSize.{w, w'} (proj G X : _) where
293+
#align category_theory.costructured_arrow.creates_colimits CategoryTheory.CostructuredArrow.createsColimitsOfSize
289294

290295
instance epi_left_of_epi [HasPushouts A] [PreservesColimitsOfShape WalkingSpan G]
291296
{Y Z : CostructuredArrow G X} (f : Y ⟶ Z) [Epi f] : Epi f.left :=

Mathlib/CategoryTheory/Limits/Over.lean

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ TODO: If `C` has binary products, then `forget X : Over X ⥤ C` has a right adj
2929
noncomputable section
3030

3131
-- morphism levels before object levels. See note [category_theory universes].
32-
universe v u
32+
universe w' w v u
3333

3434
open CategoryTheory CategoryTheory.Limits
3535

36-
variable {J : Type v} [SmallCategory J]
36+
variable {J : Type w} [Category.{w'} J]
3737

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

@@ -51,9 +51,9 @@ instance [HasColimitsOfShape J C] : HasColimitsOfShape J (Over X) where
5151
instance [HasColimits C] : HasColimits (Over X) :=
5252
⟨inferInstance⟩
5353

54-
instance createsColimits : CreatesColimits (forget X) :=
55-
CostructuredArrow.createsColimits
56-
#align category_theory.over.creates_colimits CategoryTheory.Over.createsColimits
54+
instance createsColimitsOfSize : CreatesColimitsOfSize.{w, w'} (forget X) :=
55+
CostructuredArrow.createsColimitsOfSize
56+
#align category_theory.over.creates_colimits CategoryTheory.Over.createsColimitsOfSize
5757

5858
-- We can automatically infer that the forgetful functor preserves and reflects colimits.
5959
example [HasColimits C] : PreservesColimits (forget X) :=
@@ -150,9 +150,9 @@ theorem mono_iff_mono_right [HasPullbacks C] {f g : Under X} (h : f ⟶ g) : Mon
150150
StructuredArrow.mono_iff_mono_right _
151151
#align category_theory.under.mono_iff_mono_right CategoryTheory.Under.mono_iff_mono_right
152152

153-
instance createsLimits : CreatesLimits (forget X) :=
154-
StructuredArrow.createsLimits
155-
#align category_theory.under.creates_limits CategoryTheory.Under.createsLimits
153+
instance createsLimitsOfSize : CreatesLimitsOfSize.{w, w'} (forget X) :=
154+
StructuredArrow.createsLimitsOfSize
155+
#align category_theory.under.creates_limits CategoryTheory.Under.createsLimitsOfSize
156156

157157
-- We can automatically infer that the forgetful functor preserves and reflects limits.
158158
example [HasLimits C] : PreservesLimits (forget X) :=

Mathlib/CategoryTheory/PUnit.lean

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ and construct the equivalence `(Discrete PUnit ⥤ C) ≌ C`.
1717
-/
1818

1919

20-
universe v u
20+
universe w v u
2121

2222
-- morphism levels before object levels. See note [CategoryTheory universes].
2323
namespace CategoryTheory
@@ -28,7 +28,7 @@ namespace Functor
2828

2929
/-- The constant functor sending everything to `PUnit.star`. -/
3030
@[simps!]
31-
def star : C ⥤ Discrete PUnit :=
31+
def star : C ⥤ Discrete PUnit.{w + 1} :=
3232
(Functor.const _).obj ⟨⟨⟩⟩
3333
#align category_theory.functor.star CategoryTheory.Functor.star
3434
-- Porting note: simp can simplify this
@@ -37,26 +37,26 @@ variable {C}
3737

3838
/-- Any two functors to `Discrete PUnit` are isomorphic. -/
3939
@[simps!]
40-
def punitExt (F G : C ⥤ Discrete PUnit) : F ≅ G :=
40+
def punitExt (F G : C ⥤ Discrete PUnit.{w + 1}) : F ≅ G :=
4141
NatIso.ofComponents fun X => eqToIso (by simp only [eq_iff_true_of_subsingleton])
4242
#align category_theory.functor.punit_ext CategoryTheory.Functor.punitExt
4343
-- Porting note: simp does indeed fire for these despite the linter warning
4444
attribute [nolint simpNF] punitExt_hom_app_down_down punitExt_inv_app_down_down
4545

4646
/-- Any two functors to `Discrete PUnit` are *equal*.
4747
You probably want to use `punitExt` instead of this. -/
48-
theorem punit_ext' (F G : C ⥤ Discrete PUnit) : F = G :=
48+
theorem punit_ext' (F G : C ⥤ Discrete PUnit.{w + 1}) : F = G :=
4949
Functor.ext fun X => by simp only [eq_iff_true_of_subsingleton]
5050
#align category_theory.functor.punit_ext' CategoryTheory.Functor.punit_ext'
5151

5252
/-- The functor from `Discrete PUnit` sending everything to the given object. -/
53-
abbrev fromPUnit (X : C) : Discrete PUnit.{v + 1} ⥤ C :=
53+
abbrev fromPUnit (X : C) : Discrete PUnit.{w + 1} ⥤ C :=
5454
(Functor.const _).obj X
5555
#align category_theory.functor.from_punit CategoryTheory.Functor.fromPUnit
5656

5757
/-- Functors from `Discrete PUnit` are equivalent to the category itself. -/
5858
@[simps]
59-
def equiv : Discrete PUnit ⥤ C ≌ C where
59+
def equiv : Discrete PUnit.{w + 1} ⥤ C ≌ C where
6060
functor :=
6161
{ obj := fun F => F.obj ⟨⟨⟩⟩
6262
map := fun θ => θ.app ⟨⟨⟩⟩ }
@@ -71,7 +71,7 @@ end Functor
7171
any two objects. (In fact, such a category is also a groupoid;
7272
see `CategoryTheory.Groupoid.ofHomUnique`) -/
7373
theorem equiv_punit_iff_unique :
74-
Nonempty (C ≌ Discrete PUnit) ↔ Nonempty C ∧ ∀ x y : C, Nonempty <| Unique (x ⟶ y) := by
74+
Nonempty (C ≌ Discrete PUnit.{w + 1}) ↔ Nonempty C ∧ ∀ x y : C, Nonempty <| Unique (x ⟶ y) := by
7575
constructor
7676
· rintro ⟨h⟩
7777
refine' ⟨⟨h.inverse.obj ⟨⟨⟩⟩⟩, fun x y => Nonempty.intro _⟩

Mathlib/CategoryTheory/StructuredArrow.lean

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,11 @@ variable {C : Type u₁} [Category.{v₁} C] {D : Type u₂} [Category.{v₂} D]
3333
has as its objects `D`-morphisms of the form `S ⟶ T Y`, for some `Y : C`,
3434
and morphisms `C`-morphisms `Y ⟶ Y'` making the obvious triangle commute.
3535
-/
36+
-- We explicitly come from `PUnit.{1}` here to obtain the correct universe for morphisms of
37+
-- structured arrows.
3638
-- @[nolint has_nonempty_instance]
3739
def StructuredArrow (S : D) (T : C ⥤ D) :=
38-
Comma (Functor.fromPUnit S) T
40+
Comma (Functor.fromPUnit.{0} S) T
3941
#align category_theory.structured_arrow CategoryTheory.StructuredArrow
4042

4143
-- Porting note: not found by inferInstance
@@ -173,9 +175,6 @@ instance proj_faithful : Faithful (proj S T) where
173175
map_injective {_ _} := ext
174176
#align category_theory.structured_arrow.proj_faithful CategoryTheory.StructuredArrow.proj_faithful
175177

176-
instance : LocallySmall.{v₁} (StructuredArrow S T) where
177-
hom_small _ _ := small_of_injective ext
178-
179178
/-- The converse of this is true with additional assumptions, see `mono_iff_mono_right`. -/
180179
theorem mono_of_mono_right {A B : StructuredArrow S T} (f : A ⟶ B) [h : Mono f.right] : Mono f :=
181180
(proj S T).mono_of_mono_map h
@@ -368,9 +367,11 @@ end StructuredArrow
368367
has as its objects `D`-morphisms of the form `S Y ⟶ T`, for some `Y : C`,
369368
and morphisms `C`-morphisms `Y ⟶ Y'` making the obvious triangle commute.
370369
-/
370+
-- We explicitly come from `PUnit.{1}` here to obtain the correct universe for morphisms of
371+
-- costructured arrows.
371372
-- @[nolint has_nonempty_instance] -- Porting note: removed
372373
def CostructuredArrow (S : C ⥤ D) (T : D) :=
373-
Comma S (Functor.fromPUnit T)
374+
Comma S (Functor.fromPUnit.{0} T)
374375
#align category_theory.costructured_arrow CategoryTheory.CostructuredArrow
375376

376377
instance (S : C ⥤ D) (T : D) : Category (CostructuredArrow S T) := commaCategory
@@ -502,9 +503,6 @@ theorem ext_iff {A B : CostructuredArrow S T} (f g : A ⟶ B) : f = g ↔ f.left
502503
instance proj_faithful : Faithful (proj S T) where map_injective {_ _} := ext
503504
#align category_theory.costructured_arrow.proj_faithful CategoryTheory.CostructuredArrow.proj_faithful
504505

505-
instance : LocallySmall.{v₁} (CostructuredArrow S T) where
506-
hom_small _ _ := small_of_injective ext
507-
508506
theorem mono_of_mono_left {A B : CostructuredArrow S T} (f : A ⟶ B) [h : Mono f.left] : Mono f :=
509507
(proj S T).mono_of_mono_map h
510508
#align category_theory.costructured_arrow.mono_of_mono_left CategoryTheory.CostructuredArrow.mono_of_mono_left

0 commit comments

Comments
 (0)