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

Commit 36dd78e

Browse files
Scott Morrisonjohoelzl
authored andcommitted
feat(category_theory): full and faithful functors, switching products
also the evaluation functor, and replace the ↝ arrow with ⥤, by request
1 parent 6ddc3fc commit 36dd78e

File tree

10 files changed

+147
-52
lines changed

10 files changed

+147
-52
lines changed

category_theory/category.lean

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ A `small_category` has objects and morphisms in the same universe level.
6666
-/
6767
abbreviation small_category (C : Type u) : Type (u+1) := category.{u u} C
6868

69+
section
6970
variables {C : Type u} [𝒞 : category.{u v} C] {X Y Z : C}
7071
include 𝒞
7172

@@ -78,6 +79,16 @@ class mono (f : X ⟶ Y) : Prop :=
7879
⟨ λ p, epi.left_cancellation g h p, begin intro a, subst a end
7980
@[simp] lemma cancel_mono (f : X ⟶ Y) [mono f] (g h : Z ⟶ X) : (g ≫ f = h ≫ f) ↔ g = h :=
8081
⟨ λ p, mono.right_cancellation g h p, begin intro a, subst a end
82+
end
8183

84+
section
85+
variable (C : Type u)
86+
variable [small_category C]
87+
88+
instance : large_category (ulift.{(u+1)} C) :=
89+
{ hom := λ X Y, (X.down ⟶ Y.down),
90+
id := λ X, 𝟙 X.down,
91+
comp := λ _ _ _ f g, f ≫ g }
92+
end
8293

8394
end category_theory

category_theory/embedding.lean

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
-- Copyright (c) 2018 Scott Morrison. All rights reserved.
2+
-- Released under Apache 2.0 license as described in the file LICENSE.
3+
-- Authors: Scott Morrison
4+
5+
import category_theory.isomorphism
6+
7+
namespace category_theory
8+
9+
universes u₁ v₁ u₂ v₂
10+
11+
section
12+
variables {C : Type u₁} [𝒞 : category.{u₁ v₁} C] {D : Type u₂} [𝒟 : category.{u₂ v₂} D]
13+
include 𝒞 𝒟
14+
15+
class full (F : C ⥤ D) :=
16+
(preimage : ∀ {X Y : C} (f : (F X) ⟶ (F Y)), X ⟶ Y)
17+
(witness' : ∀ {X Y : C} (f : (F X) ⟶ (F Y)), F.map (preimage f) = f . obviously)
18+
19+
restate_axiom full.witness'
20+
attribute [simp] full.witness
21+
22+
def preimage (F : C ⥤ D) [full F] {X Y : C} (f : F X ⟶ F Y) : X ⟶ Y := full.preimage.{u₁ v₁ u₂ v₂} f
23+
@[simp] lemma image_preimage (F : C ⥤ D) [full F] {X Y : C} (f : F X ⟶ F Y) : F.map (preimage F f) = f := begin unfold preimage, obviously end
24+
25+
class faithful (F : C ⥤ D) : Prop :=
26+
(injectivity' : ∀ {X Y : C} {f g : X ⟶ Y} (p : F.map f = F.map g), f = g . obviously)
27+
28+
restate_axiom faithful.injectivity'
29+
30+
section
31+
variables {F : C ⥤ D} [full F] [faithful F] {X Y : C}
32+
def preimage_iso (f : (F X) ≅ (F Y)) : X ≅ Y :=
33+
{ hom := preimage F (f : F X ⟶ F Y),
34+
inv := preimage F (f.symm : F Y ⟶ F X),
35+
hom_inv_id' := begin apply @faithful.injectivity _ _ _ _ F, obviously, end,
36+
inv_hom_id' := begin apply @faithful.injectivity _ _ _ _ F, obviously, end, }
37+
38+
@[simp] lemma preimage_iso_coe (f : (F X) ≅ (F Y)) : ((preimage_iso f) : X ⟶ Y) = preimage F (f : F X ⟶ F Y) := rfl
39+
@[simp] lemma preimage_iso_symm_coe (f : (F X) ≅ (F Y)) : ((preimage_iso f).symm : Y ⟶ X) = preimage F (f.symm : F Y ⟶ F X) := rfl
40+
end
41+
42+
class embedding (F : C ⥤ D) extends (full F), (faithful F).
43+
end
44+
45+
variables {C : Type u₁} [𝒞 : category.{u₁ v₁} C]
46+
include 𝒞
47+
48+
instance : full (functor.id C) :=
49+
{ preimage := λ _ _ f, f }
50+
51+
instance : faithful (functor.id C) := by obviously
52+
53+
instance : embedding (functor.id C) := { ((by apply_instance) : full (functor.id C)) with }
54+
55+
end category_theory

category_theory/functor.lean

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Defines a functor between categories.
99
by the underlying function on objects, the name is capitalised.)
1010
1111
Introduces notations
12-
`C D` for the type of all functors from `C` to `D`.
12+
`C D` for the type of all functors from `C` to `D`.
1313
(I would like a better arrow here, unfortunately ⇒ (`\functor`) is taken by core.)
1414
`F X` (a coercion) for a functor `F` acting on an object `X`.
1515
-/
@@ -39,31 +39,31 @@ structure functor (C : Type u₁) [category.{u₁ v₁} C] (D : Type u₂) [cate
3939
(map_id' : ∀ (X : C), map' (𝟙 X) = 𝟙 (obj X) . obviously)
4040
(map_comp' : ∀ {X Y Z : C} (f : X ⟶ Y) (g : Y ⟶ Z), map' (f ≫ g) = (map' f) ≫ (map' g) . obviously)
4141

42-
infixr ` `:70 := functor -- type as \lea --
42+
infixr ` `:70 := functor -- type as \func --
4343

4444
namespace functor
4545

4646
section
4747
variables {C : Type u₁} [𝒞 : category.{u₁ v₁} C] {D : Type u₂} [𝒟 : category.{u₂ v₂} D]
4848
include 𝒞 𝒟
4949

50-
instance : has_coe_to_fun (C D) :=
50+
instance : has_coe_to_fun (C D) :=
5151
{ F := λ F, C → D,
5252
coe := λ F, F.obj }
5353

54-
def map (F : C D) {X Y : C} (f : X ⟶ Y) : (F X) ⟶ (F Y) := F.map' f
54+
def map (F : C D) {X Y : C} (f : X ⟶ Y) : (F X) ⟶ (F Y) := F.map' f
5555

56-
@[simp] lemma map_id (F : C D) (X : C) : F.map (𝟙 X) = 𝟙 (F X) :=
56+
@[simp] lemma map_id (F : C D) (X : C) : F.map (𝟙 X) = 𝟙 (F X) :=
5757
begin unfold functor.map, erw F.map_id', refl end
58-
@[simp] lemma map_comp (F : C D) {X Y Z : C} (f : X ⟶ Y) (g : Y ⟶ Z) :
58+
@[simp] lemma map_comp (F : C D) {X Y Z : C} (f : X ⟶ Y) (g : Y ⟶ Z) :
5959
F.map (f ≫ g) = F.map f ≫ F.map g :=
6060
begin unfold functor.map, erw F.map_comp' end
6161

6262
-- We define a refl lemma 'refolding' the coercion,
6363
-- and two lemmas for the coercion applied to an explicit structure.
64-
@[simp] lemma obj_eq_coe {F : C D} (X : C) : F.obj X = F X := by unfold_coes
64+
@[simp] lemma obj_eq_coe {F : C D} (X : C) : F.obj X = F X := by unfold_coes
6565
@[simp] lemma mk_obj (o : C → D) (m mi mc) (X : C) :
66-
({ functor . obj := o, map' := m, map_id' := mi, map_comp' := mc } : C D) X = o X := rfl
66+
({ functor . obj := o, map' := m, map_id' := mi, map_comp' := mc } : C D) X = o X := rfl
6767
@[simp] lemma mk_map (o : C → D) (m mi mc) {X Y : C} (f : X ⟶ Y) :
6868
functor.map { functor . obj := o, map' := m, map_id' := mi, map_comp' := mc } f = m f := rfl
6969
end
@@ -73,7 +73,7 @@ variables (C : Type u₁) [𝒞 : category.{u₁ v₁} C]
7373
include 𝒞
7474

7575
/-- `functor.id C` is the identity functor on a category `C`. -/
76-
protected def id : C C :=
76+
protected def id : C C :=
7777
{ obj := λ X, X,
7878
map' := λ _ _ f, f }
7979

@@ -92,14 +92,14 @@ include 𝒞 𝒟 ℰ
9292
/--
9393
`F ⋙ G` is the composition of a functor `F` and a functor `G` (`F` first, then `G`).
9494
-/
95-
def comp (F : C D) (G : D E) : C E :=
95+
def comp (F : C D) (G : D E) : C E :=
9696
{ obj := λ X, G (F X),
9797
map' := λ _ _ f, G.map (F.map f) }
9898

9999
infixr ` ⋙ `:80 := comp
100100

101-
@[simp] lemma comp_obj (F : C D) (G : D E) (X : C) : (F ⋙ G) X = G (F X) := rfl
102-
@[simp] lemma comp_map (F : C D) (G : D E) (X Y : C) (f : X ⟶ Y) :
101+
@[simp] lemma comp_obj (F : C D) (G : D E) (X : C) : (F ⋙ G) X = G (F X) := rfl
102+
@[simp] lemma comp_map (F : C D) (G : D E) (X Y : C) (f : X ⟶ Y) :
103103
(F ⋙ G).map f = G.map (F.map f) := rfl
104104
end
105105

category_theory/functor_category.lean

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Notice that if `C` and `D` are both small categories at the same universe level,
1717
However if `C` and `D` are both large categories at the same universe level, this is a small category at the next higher level.
1818
-/
1919
instance functor.category (C : Type u₁) [category.{u₁ v₁} C] (D : Type u₂) [category.{u₂ v₂} D] :
20-
category.{(max u₁ v₁ u₂ v₂) (max u₁ v₂)} (C D) :=
20+
category.{(max u₁ v₁ u₂ v₂) (max u₁ v₂)} (C D) :=
2121
{ hom := λ F G, F ⟹ G,
2222
id := λ F, nat_trans.id F,
2323
comp := λ _ _ _ α β, α ⊟ β }
@@ -28,8 +28,8 @@ section
2828
variables {C : Type u₁} [𝒞 : category.{u₁ v₁} C] {D : Type u₂} [𝒟 : category.{u₂ v₂} D]
2929
include 𝒞 𝒟
3030

31-
@[simp] lemma id_app (F : C D) (X : C) : (𝟙 F : F ⟹ F) X = 𝟙 (F X) := rfl
32-
@[simp] lemma comp_app {F G H : C D} (α : F ⟶ G) (β : G ⟶ H) (X : C) :
31+
@[simp] lemma id_app (F : C D) (X : C) : (𝟙 F : F ⟹ F) X = 𝟙 (F X) := rfl
32+
@[simp] lemma comp_app {F G H : C D} (α : F ⟶ G) (β : G ⟶ H) (X : C) :
3333
((α ≫ β) : F ⟹ H) X = (α : F ⟹ G) X ≫ (β : G ⟹ H) X := rfl
3434
end
3535

@@ -42,10 +42,10 @@ variables {C : Type u₁} [𝒞 : category.{u₁ v₁} C]
4242
{E : Type u₃} [ℰ : category.{u₃ v₃} E]
4343
include 𝒞 𝒟 ℰ
4444

45-
lemma app_naturality {F G : C (D E)} (T : F ⟹ G) (X : C) {Y Z : D} (f : Y ⟶ Z) :
45+
lemma app_naturality {F G : C (D E)} (T : F ⟹ G) (X : C) {Y Z : D} (f : Y ⟶ Z) :
4646
((F X).map f) ≫ ((T X) Z) = ((T X) Y) ≫ ((G X).map f) := (T X).naturality f
4747

48-
lemma naturality_app {F G : C (D E)} (T : F ⟹ G) (Z : D) {X Y : C} (f : X ⟶ Y) :
48+
lemma naturality_app {F G : C (D E)} (T : F ⟹ G) (Z : D) {X Y : C} (f : X ⟶ Y) :
4949
((F.map f) Z) ≫ ((T Y) Z) = ((T X) Z) ≫ ((G.map f) Z) := congr_fun (congr_arg app (T.naturality f)) Z
5050

5151
end nat_trans

category_theory/isomorphism.lean

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,16 +121,16 @@ variables {D : Type u₂}
121121
variables [𝒟 : category.{u₂ v₂} D]
122122
include 𝒟
123123

124-
def on_iso (F : C D) {X Y : C} (i : X ≅ Y) : (F X) ≅ (F Y) :=
124+
def on_iso (F : C D) {X Y : C} (i : X ≅ Y) : (F X) ≅ (F Y) :=
125125
{ hom := F.map i.hom,
126126
inv := F.map i.inv,
127127
hom_inv_id' := by erw [←map_comp, iso.hom_inv_id, ←map_id],
128128
inv_hom_id' := by erw [←map_comp, iso.inv_hom_id, ←map_id] }
129129

130-
@[simp] lemma on_iso_hom (F : C D) {X Y : C} (i : X ≅ Y) : ((F.on_iso i) : F X ⟶ F Y) = F.map (i : X ⟶ Y) := rfl
131-
@[simp] lemma on_iso_inv (F : C D) {X Y : C} (i : X ≅ Y) : ((F.on_iso i).symm : F Y ⟶ F X) = F.map (i.symm : Y ⟶ X) := rfl
130+
@[simp] lemma on_iso_hom (F : C D) {X Y : C} (i : X ≅ Y) : ((F.on_iso i) : F X ⟶ F Y) = F.map (i : X ⟶ Y) := rfl
131+
@[simp] lemma on_iso_inv (F : C D) {X Y : C} (i : X ≅ Y) : ((F.on_iso i).symm : F Y ⟶ F X) = F.map (i.symm : Y ⟶ X) := rfl
132132

133-
instance (F : C D) (f : X ⟶ Y) [is_iso f] : is_iso (F.map f) :=
133+
instance (F : C D) (f : X ⟶ Y) [is_iso f] : is_iso (F.map f) :=
134134
{ inv := F.map (inv f),
135135
hom_inv_id' := begin rw ← F.map_comp, erw is_iso.hom_inv_id, rw map_id, end,
136136
inv_hom_id' := begin rw ← F.map_comp, erw is_iso.inv_hom_id, rw map_id, end }
@@ -167,7 +167,7 @@ universes u₁ v₁ u₂ v₂
167167
variables {D : Type u₂} [𝒟 : category.{u₂ v₂} D]
168168
include 𝒟
169169

170-
@[simp] lemma eq_to_iso (F : C D) {X Y : C} (p : X = Y) : F.on_iso (eq_to_iso p) = eq_to_iso (congr_arg F.obj p) :=
170+
@[simp] lemma eq_to_iso (F : C D) {X Y : C} (p : X = Y) : F.on_iso (eq_to_iso p) = eq_to_iso (congr_arg F.obj p) :=
171171
begin /- obviously says: -/ ext1, induction p, dsimp at *, simp at * end
172172
end functor
173173

category_theory/natural_transformation.lean

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,40 +29,40 @@ coercion available so you can write `α X` for the component of a transformation
2929
3030
Naturality is expressed by `α.naturality_lemma`.
3131
-/
32-
structure nat_trans (F G : C D) : Type (max u₁ v₂) :=
32+
structure nat_trans (F G : C D) : Type (max u₁ v₂) :=
3333
(app : Π X : C, (F X) ⟶ (G X))
3434
(naturality' : ∀ {X Y : C} (f : X ⟶ Y), (F.map f) ≫ (app Y) = (app X) ≫ (G.map f) . obviously)
3535

3636
infixr ` ⟹ `:50 := nat_trans -- type as \==> or ⟹
3737

3838
namespace nat_trans
3939

40-
instance {F G : C D} : has_coe_to_fun (F ⟹ G) :=
40+
instance {F G : C D} : has_coe_to_fun (F ⟹ G) :=
4141
{ F := λ α, Π X : C, (F X) ⟶ (G X),
4242
coe := λ α, α.app }
4343

44-
@[simp] lemma app_eq_coe {F G : C D} (α : F ⟹ G) (X : C) : α.app X = α X := by unfold_coes
45-
@[simp] lemma mk_app {F G : C D} (app : Π X : C, (F X) ⟶ (G X)) (naturality) (X : C) :
44+
@[simp] lemma app_eq_coe {F G : C D} (α : F ⟹ G) (X : C) : α.app X = α X := by unfold_coes
45+
@[simp] lemma mk_app {F G : C D} (app : Π X : C, (F X) ⟶ (G X)) (naturality) (X : C) :
4646
{ nat_trans . app := app, naturality' := naturality } X = app X := rfl
4747

48-
lemma naturality {F G : C D} (α : F ⟹ G) {X Y : C} (f : X ⟶ Y) :
48+
lemma naturality {F G : C D} (α : F ⟹ G) {X Y : C} (f : X ⟶ Y) :
4949
(F.map f) ≫ (α Y) = (α X) ≫ (G.map f) :=
5050
begin
5151
/- `obviously'` says: -/
5252
erw nat_trans.naturality', refl
5353
end
5454

5555
/-- `nat_trans.id F` is the identity natural transformation on a functor `F`. -/
56-
protected def id (F : C D) : F ⟹ F :=
57-
{ app := λ X, 𝟙 (F X) }
56+
protected def id (F : C D) : F ⟹ F :=
57+
{ app := λ X, 𝟙 (F X) }
5858

59-
@[simp] lemma id_app (F : C D) (X : C) : (nat_trans.id F) X = 𝟙 (F X) := rfl
59+
@[simp] lemma id_app (F : C D) (X : C) : (nat_trans.id F) X = 𝟙 (F X) := rfl
6060

6161
open category
6262
open category_theory.functor
6363

6464
section
65-
variables {F G H I : C D}
65+
variables {F G H I : C D}
6666

6767
-- We'll want to be able to prove that two natural transformations are equal if they are componentwise equal.
6868
@[extensionality] lemma ext (α β : F ⟹ G) (w : ∀ X : C, α X = β X) : α = β :=
@@ -88,7 +88,7 @@ variables {E : Type u₃} [ℰ : category.{u₃ v₃} E]
8888
include
8989

9090
/-- `hcomp α β` is the horizontal composition of natural transformations. -/
91-
def hcomp {F G : C D} {H I : D E} (α : F ⟹ G) (β : H ⟹ I) : (F ⋙ H) ⟹ (G ⋙ I) :=
91+
def hcomp {F G : C D} {H I : D E} (α : F ⟹ G) (β : H ⟹ I) : (F ⋙ H) ⟹ (G ⋙ I) :=
9292
{ app := λ X : C, (β (F X)) ≫ (I.map (α X)),
9393
naturality' := begin
9494
/- `obviously'` says: -/
@@ -102,12 +102,12 @@ def hcomp {F G : C ↝ D} {H I : D ↝ E} (α : F ⟹ G) (β : H ⟹ I) : (F ⋙
102102

103103
notation α `◫` β:80 := hcomp α β
104104

105-
@[simp] lemma hcomp_app {F G : C D} {H I : D E} (α : F ⟹ G) (β : H ⟹ I) (X : C) :
105+
@[simp] lemma hcomp_app {F G : C D} {H I : D E} (α : F ⟹ G) (β : H ⟹ I) (X : C) :
106106
(α ◫ β) X = (β (F X)) ≫ (I.map (α X)) := rfl
107107

108108
-- Note that we don't yet prove a `hcomp_assoc` lemma here: even stating it is painful, because we need to use associativity of functor composition
109109

110-
lemma exchange {F G H : C D} {I J K : D E} (α : F ⟹ G) (β : G ⟹ H) (γ : I ⟹ J) (δ : J ⟹ K) :
110+
lemma exchange {F G H : C D} {I J K : D E} (α : F ⟹ G) (β : G ⟹ H) (γ : I ⟹ J) (δ : J ⟹ K) :
111111
((α ⊟ β) ◫ (γ ⊟ δ)) = ((α ◫ γ) ⊟ (β ◫ δ)) :=
112112
begin
113113
-- `obviously'` says:

category_theory/opposites.lean

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,20 @@ section
2727
variables {D : Type u₂} [𝒟 : category.{u₂ v₂} D]
2828
include 𝒟
2929

30-
protected definition op (F : C D) : (Cᵒᵖ) (Dᵒᵖ) :=
30+
protected definition op (F : C D) : (Cᵒᵖ) (Dᵒᵖ) :=
3131
{ obj := λ X, F X,
3232
map' := λ X Y f, F.map f,
3333
map_id' := begin /- `obviously'` says: -/ intros, erw [map_id], refl, end,
3434
map_comp' := begin /- `obviously'` says: -/ intros, erw [map_comp], refl end }
3535

36-
@[simp] lemma opposite_obj (F : C D) (X : C) : (F.op) X = F X := rfl
37-
@[simp] lemma opposite_map (F : C D) {X Y : C} (f : X ⟶ Y) : (F.op).map f = F.map f := rfl
36+
@[simp] lemma opposite_obj (F : C D) (X : C) : (F.op) X = F X := rfl
37+
@[simp] lemma opposite_map (F : C D) {X Y : C} (f : X ⟶ Y) : (F.op).map f = F.map f := rfl
3838
end
3939

4040
variable (C)
4141

4242
/-- `functor.hom` is the hom-pairing, sending (X,Y) to X → Y, contravariant in X and covariant in Y. -/
43-
definition hom : (Cᵒᵖ × C) (Type v₁) :=
43+
definition hom : (Cᵒᵖ × C) (Type v₁) :=
4444
{ obj := λ p, @category.hom C _ p.1 p.2,
4545
map' := λ X Y f, λ h, f.1 ≫ h ≫ f.2,
4646
map_id' := begin /- `obviously'` says: -/ intros, ext, intros, cases X, dsimp at *, simp, erw [category.id_comp] end,

0 commit comments

Comments
 (0)