]> matita.cs.unibo.it Git - helm.git/blob - helm/software/matita/nlibrary/sets/categories.ma
6d57deddb02d493a2e6c3b8a0d178a5ce01cac14
[helm.git] / helm / software / matita / nlibrary / sets / categories.ma
1 (**************************************************************************)
2 (*       ___                                                              *)
3 (*      ||M||                                                             *)
4 (*      ||A||       A project by Andrea Asperti                           *)
5 (*      ||T||                                                             *)
6 (*      ||I||       Developers:                                           *)
7 (*      ||T||         The HELM team.                                      *)
8 (*      ||A||         http://helm.cs.unibo.it                             *)
9 (*      \   /                                                             *)
10 (*       \ /        This file is distributed under the terms of the       *)
11 (*        v         GNU General Public License Version 2                  *)
12 (*                                                                        *)
13 (**************************************************************************)
14
15
16 include "sets/sets.ma".
17
18 nrecord category : Type[2] ≝
19  { objs:> Type[1];
20    arrows: objs → objs → setoid;
21    id: ∀o:objs. arrows o o;
22    comp: ∀o1,o2,o3. unary_morphism (arrows o2 o3) (unary_morph_setoid (arrows o1 o2) (arrows o1 o3));
23    comp_assoc: ∀o1,o2,o3,o4. ∀a34,a23,a12.
24     comp o1 o3 o4 a34 (comp o1 o2 o3 a23 a12) = comp o1 o2 o4 (comp o2 o3 o4 a34 a23) a12;
25    id_neutral_left: ∀o1,o2. ∀a: arrows o1 o2. comp ??? (id o2) a = a;
26    id_neutral_right: ∀o1,o2. ∀a: arrows o1 o2. comp ??? a (id o1) = a
27  }.
28
29 notation > "𝐈𝐝 term 90 A" non associative with precedence 90 for @{ 'id $A }.
30 notation < "mpadded width -90% (𝐈) 𝐝 \sub term 90 A" non associative with precedence 90 for @{ 'id $A }.
31
32 interpretation "id" 'id A = (id ? A).
33
34 ndefinition SETOID : category.
35 @; 
36 ##[ napply setoid;
37 ##| napply unary_morph_setoid;
38 ##| #o; @ (λx.x); #a; #b; #H; napply H;
39 ##| napply comp_binary_morphisms; (*CSC: why not ∘?*)
40 ##| #o1; #o2; #o3; #o4; #f; #g; #h; #x; #x'; #Hx; nnormalize; napply (†(†(†Hx)))
41 ##|##6,7: #o1; #o2; #f; #x; #x'; #Hx; nnormalize; napply (†Hx) ]
42 nqed.
43
44 unification hint 0 ≔ ;
45    R ≟ (mk_category setoid unary_morph_setoid (id SETOID) (comp SETOID)
46           (comp_assoc SETOID) (id_neutral_left SETOID)
47           (id_neutral_right SETOID))
48  (* -------------------------------------------------------------------- *) ⊢
49                               objs R ≡ setoid.
50                               
51  unification hint 0 ≔ x,y ;
52    R ≟ (mk_category setoid unary_morph_setoid (id SETOID) (comp SETOID)
53           (comp_assoc SETOID) (id_neutral_left SETOID)
54           (id_neutral_right SETOID))
55  (* -------------------------------------------------------------------- *) ⊢
56                   arrows R x y ≡ unary_morph_setoid x y. 
57                   
58 unification hint 0 ≔ A,B ;               
59                   T ≟ (unary_morph_setoid A B)
60            (* ----------------------------------- *) ⊢              
61                   unary_morphism A B ≡ carr T. 
62                 
63                 
64 ndefinition TYPE : setoid1.
65 @ setoid; @; 
66 ##[ #T1; #T2; 
67     alias symbol "eq" = "setoid eq".
68     napply (∃f:T1 ⇒_0 T2.∃g:T2 ⇒_0 T1. (∀x.f (g x) = x) ∧ (∀y.g (f y) = y));
69 ##| #A; @ (𝐈𝐝 A); @ (𝐈𝐝 A); @; #x; napply #;
70 ##| #A; #B; *; #f; *; #g; *; #Hfg; #Hgf; @g; @f; @; nassumption; 
71 ##| #A; #B; #C; *; #f; *; #f'; *; #Hf; #Hf'; *; #g; *; #g'; *; #Hg; #Hg'; 
72     @; ##[ @(λx.g (f x)); #a; #b; #H; napply (.= (††H)); napply #;
73        ##| @; ##[ @(λx.f'(g' x)); #a; #b; #H; napply (.= (††H)); napply #; ##]
74     @; #x;
75     ##[ napply (.= (†(Hf …))); napply Hg;
76     ##| napply (.= (†(Hg' …))); napply Hf'; ##] ##] 
77 nqed.
78
79 unification hint 0 ≔ ;
80           R ≟ (mk_setoid1 setoid (eq1 TYPE))
81   (* -------------------------------------------- *) ⊢
82                  carr1 R ≡ setoid.
83    
84 nrecord unary_morphism01 (A : setoid) (B: setoid1) : Type[1] ≝
85  { fun01:1> A → B;
86    prop01: ∀a,a'. eq0 ? a a' → eq1 ? (fun01 a) (fun01 a')
87  }.
88  
89 interpretation "prop01" 'prop1 c  = (prop01 ????? c).