-
Notifications
You must be signed in to change notification settings - Fork 51
/
Copy pathCategories.v
119 lines (104 loc) · 4.21 KB
/
Categories.v
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
(* This program is free software; you can redistribute it and/or *)
(* modify it under the terms of the GNU Lesser General Public License *)
(* as published by the Free Software Foundation; either version 2.1 *)
(* of the License, or (at your option) any later version. *)
(* *)
(* This program is distributed in the hope that it will be useful, *)
(* but WITHOUT ANY WARRANTY; without even the implied warranty of *)
(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *)
(* GNU General Public License for more details. *)
(* *)
(* You should have received a copy of the GNU Lesser General Public *)
(* License along with this program; if not, write to the Free *)
(* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *)
(* 02110-1301 USA *)
Set Implicit Arguments.
Unset Strict Implicit.
Require Export Cartesian.
(** Title "Categories." *)
Comments "Some basic category theory.".
Section Category_def.
Section Category_def1.
Variable Ob : Type.
Variable Hom : Ob -> Ob -> Setoid.
Variable
Hom_comp : forall a b c : Ob, MAP (cart (Hom b c) (Hom a b)) (Hom a c).
Variable Hom_id : forall a : Ob, Hom a a.
Definition Hom_comp_assoc :=
forall (a b c d : Ob) (f : Hom a b) (g : Hom b c) (h : Hom c d),
Equal (Hom_comp a b d (couple (Hom_comp b c d (couple h g)) f))
(Hom_comp a c d (couple h (Hom_comp a b c (couple g f)))).
Definition Hom_comp_unit_l :=
forall (a b : Ob) (f : Hom a b),
Equal (Hom_comp a b b (couple (Hom_id b) f)) f.
Definition Hom_comp_unit_r :=
forall (a b : Ob) (f : Hom a b),
Equal (Hom_comp a a b (couple f (Hom_id a))) f.
End Category_def1.
Record category : Type :=
{Ob :> Type;
Hom : Ob -> Ob -> Setoid;
Hom_comp : forall a b c : Ob, MAP (cart (Hom b c) (Hom a b)) (Hom a c);
Hom_id : forall a : Ob, Hom a a;
Hom_comp_assoc_prf : Hom_comp_assoc Hom_comp;
Hom_comp_unit_l_prf : Hom_comp_unit_l Hom_comp Hom_id;
Hom_comp_unit_r_prf : Hom_comp_unit_r Hom_comp Hom_id}.
Section Category_comp.
Variable C : category.
Definition comp_hom (a b c : C) (g : Hom b c) (f : Hom a b) :=
Hom_comp a b c (couple g f).
Lemma comp_hom_compatible :
forall (a b c : C) (x x' : Hom b c) (y y' : Hom a b),
Equal x x' -> Equal y y' -> Equal (comp_hom x y) (comp_hom x' y').
intros a b c x x' y y' H' H'0; try assumption.
unfold comp_hom in |- *; auto with algebra.
Qed.
Lemma comp_hom_assoc :
forall (a b c d : C) (f : Hom a b) (g : Hom b c) (h : Hom c d),
Equal (comp_hom (comp_hom h g) f) (comp_hom h (comp_hom g f)).
exact (Hom_comp_assoc_prf (c:=C)).
Qed.
Lemma comp_hom_unit_l :
forall (a b : C) (f : Hom a b), Equal (comp_hom (Hom_id b) f) f.
exact (Hom_comp_unit_l_prf (c:=C)).
Qed.
Lemma comp_hom_unit_r :
forall (a b : C) (f : Hom a b), Equal (comp_hom f (Hom_id a)) f.
exact (Hom_comp_unit_r_prf (c:=C)).
Qed.
End Category_comp.
Hint Resolve comp_hom_compatible comp_hom_assoc comp_hom_unit_l
comp_hom_unit_r: algebra.
Section Full_subcat_def.
Variable C : category.
Variable C' : Type.
Variable i : C' -> C.
Definition fsubcat_Hom (a b : C') := Hom (i a) (i b).
Definition fsubcat_Hom_comp :
forall a b c : C',
MAP (cart (fsubcat_Hom b c) (fsubcat_Hom a b)) (fsubcat_Hom a c).
intros a b c; try assumption.
exact (Hom_comp (i a) (i b) (i c)).
Defined.
Definition fsubcat_Hom_id (a : C') := Hom_id (i a).
Definition full_subcat : category.
apply
(Build_category (Ob:=C') (Hom:=fsubcat_Hom) (Hom_comp:=fsubcat_Hom_comp)
(Hom_id:=fsubcat_Hom_id)).
red in |- *.
unfold fsubcat_Hom, fsubcat_Hom_comp in |- *; simpl in |- *.
intros a b c d f g h; try assumption.
apply (Hom_comp_assoc_prf (c:=C)).
red in |- *.
unfold fsubcat_Hom, fsubcat_Hom_comp, fsubcat_Hom_id in |- *; simpl in |- *.
intros a b f; try assumption.
apply (Hom_comp_unit_l_prf (c:=C)).
red in |- *.
unfold fsubcat_Hom, fsubcat_Hom_comp, fsubcat_Hom_id in |- *; simpl in |- *.
intros a b f; try assumption.
apply (Hom_comp_unit_r_prf (c:=C)).
Defined.
End Full_subcat_def.
End Category_def.
Hint Resolve comp_hom_compatible comp_hom_assoc comp_hom_unit_l
comp_hom_unit_r: algebra.