| 1 |
|
| 2 |
|
| 3 |
Module Export Datatypes. |
| 4 |
|
| 5 |
Set Implicit Arguments. |
| 6 |
Local Set Primitive Projections. |
| 7 |
|
| 8 |
Record prod (A B : Type) := pair { fst : A ; snd : B }. |
| 9 |
|
| 10 |
Notation "x * y" := (prod x y) : type_scope. |
| 11 |
Notation "( x , y , .. , z )" := (pair .. (pair x y) .. z) : core_scope. |
| 12 |
|
| 13 |
End Datatypes. |
| 14 |
|
| 15 |
|
| 16 |
Delimit Scope morphism_scope with morphism. |
| 17 |
Delimit Scope category_scope with category. |
| 18 |
Delimit Scope object_scope with object. |
| 19 |
|
| 20 |
Record PreCategory := |
| 21 |
Build_PreCategory { |
| 22 |
object :> Type; |
| 23 |
morphism : object -> object -> Type; |
| 24 |
identity : forall x, morphism x x; |
| 25 |
}. |
| 26 |
|
| 27 |
Bind Scope category_scope with PreCategory. |
| 28 |
Arguments identity {!C%_category} / x%_object : rename. |
| 29 |
|
| 30 |
Local Open Scope morphism_scope. |
| 31 |
|
| 32 |
Section prod. |
| 33 |
Variables C D : PreCategory. |
| 34 |
|
| 35 |
Definition prod : PreCategory := (@Build_PreCategory |
| 36 |
(C * D)%type |
| 37 |
(fun s d => (morphism C (fst s) (fst d) |
| 38 |
* morphism D (snd s) (snd d))%type) |
| 39 |
(fun x => (identity (fst x), identity (snd x)))). |
| 40 |
|
| 41 |
End prod. |
| 42 |
|
| 43 |
Local Infix "*" := prod : category_scope. |
| 44 |
Delimit Scope functor_scope with functor. |
| 45 |
|
| 46 |
Section Functor. |
| 47 |
Variables C D : PreCategory. |
| 48 |
|
| 49 |
Record Functor := |
| 50 |
{ |
| 51 |
object_of :> C -> D; |
| 52 |
morphism_of : forall s d, morphism C s d |
| 53 |
-> morphism D (object_of s) (object_of d); |
| 54 |
identity_of : forall x, morphism_of _ _ (identity x) |
| 55 |
= identity (object_of x) |
| 56 |
}. |
| 57 |
End Functor. |
| 58 |
Arguments morphism_of [C%_category] [D%_category] F%_functor [s%_object d%_object] m%_morphism : rename, simpl nomatch. |
| 59 |
|
| 60 |
Parameter C1 C2 D : PreCategory. |
| 61 |
|
| 62 |
Parameter F : Functor (C1 * C2) D. |
| 63 |
|
| 64 |
Lemma foo (c1:C1) (x : object C2) |
| 65 |
: @morphism_of _ _ F |
| 66 |
(@pair (object C1) (object C2) c1 x) |
| 67 |
(@pair (object C1) (object C2) c1 x) |
| 68 |
(identity c1, identity x) |
| 69 |
= identity (F (c1, x)). |
| 70 |
Proof. |
| 71 |
rewrite identity_of. |
| 72 |
reflexivity. |
| 73 |
Qed. |