Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit 2f088fc

Browse files
kim-emrwbarton
authored andcommitted
feat(category_theory): working in Sort rather than Type (#824)
1 parent 404e2c9 commit 2f088fc

30 files changed

+237
-171
lines changed

src/category_theory/adjunction.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ universes v₁ v₂ v₃ u₁ u₂ u₃ -- declare the `v`'s first; see `categor
1616

1717
local attribute [elab_simple] whisker_left whisker_right
1818

19-
variables {C : Type u₁} [𝒞 : category.{v₁} C] {D : Type u₂} [𝒟 : category.{v₂} D]
19+
variables {C : Sort u₁} [𝒞 : category.{v₁} C] {D : Sort u₂} [𝒟 : category.{v₂} D]
2020
include 𝒞 𝒟
2121

2222
/--
@@ -179,7 +179,7 @@ TODO
179179
-/
180180

181181
section
182-
variables {E : Type u₃} [ℰ : category.{v₃} E] (H : D ⥤ E) (I : E ⥤ D)
182+
variables {E : Sort u₃} [ℰ : category.{v₃} E] (H : D ⥤ E) (I : E ⥤ D)
183183

184184
def comp (adj₁ : adjunction F G) (adj₂ : adjunction H I) : adjunction (F ⋙ H) (I ⋙ G) :=
185185
{ hom_equiv := λ X Z, equiv.trans (adj₂.hom_equiv _ _) (adj₁.hom_equiv _ _),
@@ -275,7 +275,7 @@ open category_theory.limits
275275

276276
universes u₁ u₂ v
277277

278-
variables {C : Type u₁} [𝒞 : category.{v} C] {D : Type u₂} [𝒟 : category.{v} D]
278+
variables {C : Sort u₁} [𝒞 : category.{v+1} C] {D : Sort u₂} [𝒟 : category.{v+1} D]
279279
include 𝒞 𝒟
280280

281281
variables {F : C ⥤ D} {G : D ⥤ C} (adj : adjunction F G)

src/category_theory/category.lean

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ powerful tactics.
3333
def_replacer obviously
3434
@[obviously] meta def obviously' := tactic.tidy
3535

36-
class has_hom (obj : Type u) : Type (max u (v+1)) :=
37-
(hom : obj → obj → Type v)
36+
class has_hom (obj : Sort u) : Sort (max u (v+1)) :=
37+
(hom : obj → obj → Sort v)
3838

3939
infixr ` ⟶ `:10 := has_hom.hom -- type as \h
4040

41-
class category_struct (obj : Type u)
42-
extends has_hom.{v} obj :=
41+
class category_struct (obj : Sort u)
42+
extends has_hom.{v} obj : Sort (max u (v+1)) :=
4343
(id : Π X : obj, hom X X)
4444
(comp : Π {X Y Z : obj}, (X ⟶ Y) → (Y ⟶ Z) → (X ⟶ Z))
4545

@@ -51,8 +51,8 @@ The typeclass `category C` describes morphisms associated to objects of type `C`
5151
The universe levels of the objects and morphisms are unconstrained, and will often need to be
5252
specified explicitly, as `category.{v} C`. (See also `large_category` and `small_category`.)
5353
-/
54-
class category (obj : Type u)
55-
extends category_struct.{v} obj :=
54+
class category (obj : Sort u)
55+
extends category_struct.{v} obj : Sort (max u (v+1)) :=
5656
(id_comp' : ∀ {X Y : obj} (f : hom X Y), 𝟙 X ≫ f = f . obviously)
5757
(comp_id' : ∀ {X Y : obj} (f : hom X Y), f ≫ 𝟙 Y = f . obviously)
5858
(assoc' : ∀ {W X Y Z : obj} (f : hom W X) (g : hom X Y) (h : hom Y Z),
@@ -76,14 +76,14 @@ A `large_category` has objects in one universe level higher than the universe le
7676
the morphisms. It is useful for examples such as the category of types, or the category
7777
of groups, etc.
7878
-/
79-
abbreviation large_category (C : Type (u+1)) : Type (u+1) := category.{u} C
79+
abbreviation large_category (C : Sort (u+1)) : Sort (u+1) := category.{u} C
8080
/--
8181
A `small_category` has objects and morphisms in the same universe level.
8282
-/
83-
abbreviation small_category (C : Type u) : Type (u+1) := category.{u} C
83+
abbreviation small_category (C : Sort u) : Sort (u+1) := category.{u} C
8484

8585
section
86-
variables {C : Type u} [𝒞 : category.{v} C] {X Y Z : C}
86+
variables {C : Sort u} [𝒞 : category.{v} C] {X Y Z : C}
8787
include 𝒞
8888

8989
class epi (f : X ⟶ Y) : Prop :=
@@ -124,14 +124,14 @@ variables {C : Type u}
124124

125125
def End [has_hom.{v} C] (X : C) := X ⟶ X
126126

127-
instance End.has_one [category_struct.{v} C] {X : C} : has_one (End X) := by refine { one := 𝟙 X }
128-
instance End.has_mul [category_struct.{v} C] {X : C} : has_mul (End X) := by refine { mul := λ x y, x ≫ y }
129-
instance End.monoid [category.{v} C] {X : C} : monoid (End X) :=
127+
instance End.has_one [category_struct.{v+1} C] {X : C} : has_one (End X) := by refine { one := 𝟙 X }
128+
instance End.has_mul [category_struct.{v+1} C] {X : C} : has_mul (End X) := by refine { mul := λ x y, x ≫ y }
129+
instance End.monoid [category.{v+1} C] {X : C} : monoid (End X) :=
130130
by refine { .. End.has_one, .. End.has_mul, .. }; dsimp [has_mul.mul,has_one.one]; obviously
131131

132-
@[simp] lemma End.one_def {C : Type u} [category_struct.{v} C] {X : C} : (1 : End X) = 𝟙 X := rfl
132+
@[simp] lemma End.one_def {C : Type u} [category_struct.{v+1} C] {X : C} : (1 : End X) = 𝟙 X := rfl
133133

134-
@[simp] lemma End.mul_def {C : Type u} [category_struct.{v} C] {X : C} (xs ys : End X) : xs * ys = xs ≫ ys := rfl
134+
@[simp] lemma End.mul_def {C : Type u} [category_struct.{v+1} C] {X : C} (xs ys : End X) : xs * ys = xs ≫ ys := rfl
135135

136136
end
137137

src/category_theory/comma.lean

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ import category_theory.equivalence
1212
namespace category_theory
1313

1414
universes v₁ v₂ v₃ u₁ u₂ u₃ -- declare the `v`'s first; see `category_theory.category` for an explanation
15-
variables {A : Type u₁} [𝒜 : category.{v₁} A]
16-
variables {B : Type u₂} [ℬ : category.{v₂} B]
17-
variables {T : Type u₃} [𝒯 : category.{v₃} T]
15+
variables {A : Sort u₁} [𝒜 : category.{v₁} A]
16+
variables {B : Sort u₂} [ℬ : category.{v₂} B]
17+
variables {T : Sort u₃} [𝒯 : category.{v₃} T]
1818
include 𝒜 ℬ 𝒯
1919

2020
structure comma (L : A ⥤ T) (R : B ⥤ T) :=
@@ -193,7 +193,7 @@ end comma
193193

194194
omit 𝒜 ℬ
195195

196-
def over (X : T) := comma.{v₃ 0 v₃} (functor.id T) (functor.of.obj X)
196+
def over (X : T) := comma.{v₃ 1 v₃} (functor.id T) (functor.of.obj X)
197197

198198
namespace over
199199

@@ -244,8 +244,8 @@ variables {Y : T} {f : X ⟶ Y} {U V : over X} {g : U ⟶ V}
244244
end
245245

246246
section
247-
variables {D : Type u₃} [Dcat : category.{v₃} D]
248-
include Dcat
247+
variables {D : Sort u₃} [𝒟 : category.{v₃} D]
248+
include 𝒟
249249

250250
def post (F : T ⥤ D) : over X ⥤ over (F.obj X) :=
251251
{ obj := λ Y, mk $ F.map Y.hom,
@@ -257,7 +257,7 @@ end
257257

258258
end over
259259

260-
def under (X : T) := comma.{0 v₃ v₃} (functor.of.obj X) (functor.id T)
260+
def under (X : T) := comma.{1 v₃ v₃} (functor.of.obj X) (functor.id T)
261261

262262
namespace under
263263

@@ -308,8 +308,8 @@ variables {Y : T} {f : X ⟶ Y} {U V : under Y} {g : U ⟶ V}
308308
end
309309

310310
section
311-
variables {D : Type u₃} [Dcat : category.{v₃} D]
312-
include Dcat
311+
variables {D : Sort u₃} [𝒟 : category.{v₃} D]
312+
include 𝒟
313313

314314
def post {X : T} (F : T ⥤ D) : under X ⥤ under (F.obj X) :=
315315
{ obj := λ Y, mk $ F.map Y.hom,

src/category_theory/concrete_category.lean

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import category_theory.types
1111
universes u v
1212

1313
namespace category_theory
14-
variables {c d : Type u → Type v} {α : Type u}
14+
variables {c d : Sort u → Sort v} {α : Sort u}
1515

1616
/--
1717
`concrete_category @hom` collects the evidence that a type constructor `c` and a
@@ -28,23 +28,23 @@ attribute [class] concrete_category
2828

2929
/-- `bundled` is a type bundled with a type class instance for that type. Only
3030
the type class is exposed as a parameter. -/
31-
structure bundled (c : Type u → Type v) : Type (max (u+1) v) :=
32-
(α : Type u)
31+
structure bundled (c : Sort u → Sort v) : Sort (max (u+1) v) :=
32+
(α : Sort u)
3333
(str : c α)
3434

35-
def mk_ob {c : Type u → Type v} (α : Type u) [str : c α] : bundled c := ⟨α, str⟩
35+
def mk_ob {c : Sort u → Sort v} (α : Sort u) [str : c α] : bundled c := ⟨α, str⟩
3636

3737
namespace bundled
3838

3939
instance : has_coe_to_sort (bundled c) :=
40-
{ S := Type u, coe := bundled.α }
40+
{ S := Sort u, coe := bundled.α }
4141

4242
/-- Map over the bundled structure -/
4343
def map (f : ∀ {α}, c α → d α) (b : bundled c) : bundled d :=
4444
⟨b.α, f b.str⟩
4545

4646
section concrete_category
47-
variables (hom : ∀ {α β : Type u}, c α → c β → (α → β) → Prop)
47+
variables (hom : ∀ {α β : Sort u}, c α → c β → (α → β) → Prop)
4848
variables [h : concrete_category @hom]
4949
include h
5050

@@ -74,21 +74,26 @@ end concrete_category
7474
end bundled
7575

7676
def concrete_functor
77-
{C : Type u → Type v} {hC : ∀{α β}, C α → C β → (α → β) → Prop} [concrete_category @hC]
78-
{D : Type u → Type v} {hD : ∀{α β}, D α → D β → (α → β) → Prop} [concrete_category @hD]
77+
{C : Sort u → Sort v} {hC : ∀{α β}, C α → C β → (α → β) → Prop} [concrete_category @hC]
78+
{D : Sort u → Sort v} {hD : ∀{α β}, D α → D β → (α → β) → Prop} [concrete_category @hD]
7979
(m : ∀{α}, C α → D α) (h : ∀{α β} {ia : C α} {ib : C β} {f}, hC ia ib f → hD (m ia) (m ib) f) :
8080
bundled C ⥤ bundled D :=
8181
{ obj := bundled.map @m,
82-
map := λ X Y f, ⟨ f, h f.2 ⟩}
82+
map := λ X Y f, ⟨ f, h f.2 }
8383

8484
section forget
85-
variables {C : Type u → Type v} {hom : ∀α β, C α → C β → (α → β) → Prop} [i : concrete_category hom]
85+
variables {C : Sort u → Sort v} {hom : ∀α β, C α → C β → (α → β) → Prop} [i : concrete_category hom]
8686
include i
8787

88-
/-- The forgetful functor from a bundled category to `Type`. -/
89-
def forget : bundled C ⥤ Type u := { obj := bundled.α, map := λa b h, h.1 }
88+
/-- The forgetful functor from a bundled category to `Sort`. -/
89+
def forget : bundled C ⥤ Sort u := { obj := bundled.α, map := λ a b h, h.1 }
9090

91-
instance forget.faithful : faithful (forget : bundled C ⥤ Type u) := {}
91+
instance forget.faithful : faithful (forget : bundled C ⥤ Sort u) :=
92+
{ injectivity' :=
93+
begin
94+
rintros X Y ⟨f,_⟩ ⟨g,_⟩ p,
95+
congr, exact p,
96+
end }
9297

9398
end forget
9499

src/category_theory/const.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ open category_theory
1111

1212
namespace category_theory.functor
1313

14-
variables (J : Type u₁) [𝒥 : category.{v₁} J]
15-
variables {C : Type u₂} [𝒞 : category.{v₂} C]
14+
variables (J : Sort u₁) [𝒥 : category.{v₁} J]
15+
variables {C : Sort u₂} [𝒞 : category.{v₂} C]
1616
include 𝒥 𝒞
1717

1818
def const : C ⥤ (J ⥤ C) :=
@@ -28,7 +28,7 @@ namespace const
2828
end const
2929

3030
section
31-
variables {D : Type u₃} [𝒟 : category.{v₃} D]
31+
variables {D : Sort u₃} [𝒟 : category.{v₃} D]
3232
include 𝒟
3333

3434
/-- These are actually equal, of course, but not definitionally equal

src/category_theory/discrete_category.lean

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@ namespace category_theory
1111

1212
universes v₁ v₂ u₁ u₂ -- declare the `v`'s first; see `category_theory.category` for an explanation
1313

14+
-- We only work in `Type`, rather than `Sort`, as we need to use `ulift`.
1415
def discrete (α : Type u₁) := α
1516

1617
instance discrete_category (α : Type u₁) : small_category (discrete α) :=
1718
{ hom := λ X Y, ulift (plift (X = Y)),
1819
id := by tidy,
1920
comp := by tidy }
2021

21-
variables {C : Type u₂} [𝒞 : category.{v₂} C]
22+
variables {C : Sort u₂} [𝒞 : category.{v₂} C]
2223
include 𝒞
2324

2425
namespace functor

src/category_theory/eq_to_hom.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ universes v v' u u' -- declare the `v`'s first; see `category_theory.category` f
99

1010
namespace category_theory
1111

12-
variables {C : Type u} [𝒞 : category.{v} C]
12+
variables {C : Sort u} [𝒞 : category.{v} C]
1313
include 𝒞
1414

1515
def eq_to_hom {X Y : C} (p : X = Y) : X ⟶ Y := by rw p; exact 𝟙 _
@@ -33,7 +33,7 @@ rfl
3333
eq_to_iso p ≪≫ eq_to_iso q = eq_to_iso (p.trans q) :=
3434
by ext; simp
3535

36-
variables {D : Type u'} [𝒟 : category.{v'} D]
36+
variables {D : Sort u'} [𝒟 : category.{v'} D]
3737
include 𝒟
3838

3939
namespace functor

src/category_theory/equivalence.lean

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace category_theory
1212

1313
universes v₁ v₂ v₃ u₁ u₂ u₃ -- declare the `v`'s first; see `category_theory.category` for an explanation
1414

15-
structure equivalence (C : Type u₁) [category.{v₁} C] (D : Type u₂) [category.{v₂} D] :=
15+
structure equivalence (C : Sort u₁) [category.{v₁} C] (D : Sort u₂) [category.{v₂} D] :=
1616
(functor : C ⥤ D)
1717
(inverse : D ⥤ C)
1818
(fun_inv_id' : (functor ⋙ inverse) ≅ (category_theory.functor.id C) . obviously)
@@ -25,14 +25,14 @@ infixr ` ≌ `:10 := equivalence
2525

2626
namespace equivalence
2727

28-
variables {C : Type u₁} [𝒞 : category.{v₁} C]
28+
variables {C : Sort u₁} [𝒞 : category.{v₁} C]
2929
include 𝒞
3030

3131
@[refl] def refl : C ≌ C :=
3232
{ functor := functor.id C,
3333
inverse := functor.id C }
3434

35-
variables {D : Type u₂} [𝒟 : category.{v₂} D]
35+
variables {D : Sort u₂} [𝒟 : category.{v₂} D]
3636
include 𝒟
3737

3838
@[symm] def symm (e : C ≌ D) : D ≌ C :=
@@ -54,7 +54,7 @@ begin
5454
refl
5555
end
5656

57-
variables {E : Type u₃} [ℰ : category.{v₃} E]
57+
variables {E : Sort u₃} [ℰ : category.{v₃} E]
5858
include
5959

6060
@[simp] private def effe_iso_id (e : C ≌ D) (f : D ≌ E) (X : C) :
@@ -94,11 +94,11 @@ calc
9494

9595
end equivalence
9696

97-
variables {C : Type u₁} [𝒞 : category.{v₁} C]
97+
variables {C : Sort u₁} [𝒞 : category.{v₁} C]
9898
include 𝒞
9999

100100
section
101-
variables {D : Type u₂} [𝒟 : category.{v₂} D]
101+
variables {D : Sort u₂} [𝒟 : category.{v₂} D]
102102
include 𝒟
103103

104104
class is_equivalence (F : C ⥤ D) :=
@@ -111,7 +111,7 @@ restate_axiom is_equivalence.inv_fun_id'
111111
end
112112

113113
namespace is_equivalence
114-
variables {D : Type u₂} [𝒟 : category.{v₂} D]
114+
variables {D : Sort u₂} [𝒟 : category.{v₂} D]
115115
include 𝒟
116116

117117
instance of_equivalence (F : C ≌ D) : is_equivalence (F.functor) :=
@@ -129,7 +129,7 @@ instance is_equivalence_refl : is_equivalence (functor.id C) :=
129129
{ inverse := functor.id C }
130130
end functor
131131

132-
variables {D : Type u₂} [𝒟 : category.{v₂} D]
132+
variables {D : Sort u₂} [𝒟 : category.{v₂} D]
133133
include 𝒟
134134

135135
namespace functor
@@ -153,7 +153,7 @@ def as_equivalence (F : C ⥤ D) [is_equivalence F] : C ≌ D :=
153153
fun_inv_id' := is_equivalence.fun_inv_id F,
154154
inv_fun_id' := is_equivalence.inv_fun_id F }
155155

156-
variables {E : Type u₃} [ℰ : category.{v₃} E]
156+
variables {E : Sort u₃} [ℰ : category.{v₃} E]
157157
include
158158

159159
instance is_equivalence_trans (F : C ⥤ D) (G : D ⥤ E) [is_equivalence F] [is_equivalence G] :

src/category_theory/full_subcategory.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ section induced
2424
2525
-/
2626

27-
variables {C : Type u₁} {D : Type u₂} [𝒟 : category.{v u₂} D]
27+
variables {C : Sort u₁} {D : Sort u₂} [𝒟 : category.{v u₂} D]
2828
include 𝒟
2929
variables (F : C → D)
3030
include F
3131

32-
def induced_category : Type u₁ := C
32+
def induced_category : Sort u₁ := C
3333

3434
instance induced_category.category : category.{v} (induced_category F) :=
3535
{ hom := λ X Y, F X ⟶ F Y,
@@ -50,7 +50,7 @@ end induced
5050
section full_subcategory
5151
/- A full subcategory is the special case of an induced category with F = subtype.val. -/
5252

53-
variables {C : Type u₂} [𝒞 : category.{v} C]
53+
variables {C : Sort u₂} [𝒞 : category.{v} C]
5454
include 𝒞
5555
variables (Z : C → Prop)
5656

0 commit comments

Comments
 (0)