@@ -9,7 +9,8 @@ Defines a functor between categories.
9
9
by the underlying function on objects, the name is capitalised.)
10
10
11
11
Introduces notations
12
- `C ↝ D` for the type of all functors from `C` to `D`. (I would like a better arrow here, unfortunately ⇒ (`\functor`) is taken by core.)
12
+ `C ↝ D` for the type of all functors from `C` to `D`.
13
+ (I would like a better arrow here, unfortunately ⇒ (`\functor`) is taken by core.)
13
14
`F X` (a coercion) for a functor `F` acting on an object `X`.
14
15
-/
15
16
@@ -22,20 +23,20 @@ universes u₁ v₁ u₂ v₂ u₃ v₃
22
23
/--
23
24
`functor C D` represents a functor between categories `C` and `D`.
24
25
25
- To apply a functor `F` to an object use `F X`, and to a morphism use `F.map f`.
26
+ To apply a functor `F` to an object use `F X` (which uses a coercion) , and to a morphism use `F.map f`.
26
27
27
28
The axiom `map_id_lemma` expresses preservation of identities, and
28
29
`map_comp_lemma` expresses functoriality.
30
+
31
+ Implementation note: when constructing a `functor`, you need to define the
32
+ `map'` field (which does not know about the coercion).
33
+ When using a `functor`, use the `map` field (which makes use of the coercion).
29
34
-/
30
35
structure functor (C : Type u₁) [category.{u₁ v₁} C] (D : Type u₂) [category.{u₂ v₂} D] : Type (max u₁ v₁ u₂ v₂) :=
31
36
(obj : C → D)
32
- (map : Π {X Y : C}, (X ⟶ Y) → ((obj X) ⟶ (obj Y)))
33
- (map_id : ∀ (X : C), map (𝟙 X) = 𝟙 (obj X) . obviously)
34
- (map_comp : ∀ {X Y Z : C} (f : X ⟶ Y) (g : Y ⟶ Z), map (f ≫ g) = (map f) ≫ (map g) . obviously)
35
-
36
- restate_axiom functor.map_id
37
- restate_axiom functor.map_comp
38
- attribute [simp,ematch] functor.map_id_lemma functor.map_comp_lemma
37
+ (map' : Π {X Y : C}, (X ⟶ Y) → ((obj X) ⟶ (obj Y)))
38
+ (map_id : ∀ (X : C), map' (𝟙 X) = 𝟙 (obj X) . obviously)
39
+ (map_comp : ∀ {X Y Z : C} (f : X ⟶ Y) (g : Y ⟶ Z), map' (f ≫ g) = (map' f) ≫ (map' g) . obviously)
39
40
40
41
infixr ` ↝ `:70 := functor -- type as \lea --
41
42
@@ -49,7 +50,20 @@ instance : has_coe_to_fun (C ↝ D) :=
49
50
{ F := λ F, C → D,
50
51
coe := λ F, F.obj }
51
52
52
- @[simp] lemma coe_def (F : C ↝ D) (X : C) : F X = F.obj X := rfl
53
+ def map (F : C ↝ D) {X Y : C} (f : X ⟶ Y) : (F X) ⟶ (F Y) := F.map' f
54
+
55
+ @[simp,ematch] lemma map_id_lemma (F : C ↝ D) (X : C) : F.map (𝟙 X) = 𝟙 (F X) :=
56
+ begin unfold functor.map, erw F.map_id, refl end
57
+ @[simp,ematch] lemma map_comp_lemma (F : C ↝ D) {X Y Z : C} (f : X ⟶ Y) (g : Y ⟶ Z) :
58
+ F.map (f ≫ g) = F.map f ≫ F.map g :=
59
+ begin unfold functor.map, erw F.map_comp end
60
+
61
+ -- We do not define a refl lemma unfolding the coercion.
62
+ -- However we do provide lemmas for the coercion applied to an explicit structure.
63
+ @[simp] lemma mk_obj (o : C → D) (m mi mc) (X : C) :
64
+ ({ functor . obj := o, map' := m, map_id := mi, map_comp := mc } : C ↝ D) X = o X := rfl
65
+ @[simp] lemma mk_map (o : C → D) (m mi mc) {X Y : C} (f : X ⟶ Y) :
66
+ functor.map { functor . obj := o, map' := m, map_id := mi, map_comp := mc } f = m f := rfl
53
67
end
54
68
55
69
section
@@ -59,7 +73,7 @@ include 𝒞
59
73
/-- `functor.id C` is the identity functor on a category `C`. -/
60
74
protected def id : C ↝ C :=
61
75
{ obj := λ X, X,
62
- map := λ _ _ f, f,
76
+ map' := λ _ _ f, f,
63
77
map_id := begin /- `obviously'` says: -/ intros, refl end ,
64
78
map_comp := begin /- `obviously'` says: -/ intros, refl end }
65
79
@@ -70,22 +84,25 @@ variable {C}
70
84
end
71
85
72
86
section
73
- variables {C : Type u₁} [𝒞 : category.{u₁ v₁} C] {D : Type u₂} [𝒟 : category.{u₂ v₂} D] {E : Type u₃} [ℰ : category.{u₃ v₃} E]
87
+ variables {C : Type u₁} [𝒞 : category.{u₁ v₁} C]
88
+ {D : Type u₂} [𝒟 : category.{u₂ v₂} D]
89
+ {E : Type u₃} [ℰ : category.{u₃ v₃} E]
74
90
include 𝒞 𝒟 ℰ
75
91
76
92
/--
77
93
`F ⋙ G` is the composition of a functor `F` and a functor `G` (`F` first, then `G`).
78
94
-/
79
95
def comp (F : C ↝ D) (G : D ↝ E) : C ↝ E :=
80
- { obj := λ X, G.obj (F.obj X),
81
- map := λ _ _ f, G.map (F.map f),
96
+ { obj := λ X, G (F X),
97
+ map' := λ _ _ f, G.map (F.map f),
82
98
map_id := begin /- `obviously'` says: -/ intros, simp end ,
83
99
map_comp := begin /- `obviously'` says: -/ intros, simp end }
84
100
85
101
infixr ` ⋙ `:80 := comp
86
102
87
103
@[simp] lemma comp_obj (F : C ↝ D) (G : D ↝ E) (X : C) : (F ⋙ G) X = G (F X) := rfl
88
- @[simp] lemma comp_map (F : C ↝ D) (G : D ↝ E) (X Y : C) (f : X ⟶ Y) : (F ⋙ G).map f = G.map (F.map f) := rfl
104
+ @[simp] lemma comp_map (F : C ↝ D) (G : D ↝ E) (X Y : C) (f : X ⟶ Y) :
105
+ (F ⋙ G).map f = G.map (F.map f) := rfl
89
106
end
90
107
91
108
end functor
0 commit comments