]> matita.cs.unibo.it Git - helm.git/blob - helm/software/matita/nlibrary/sets/categories.ma
Porting of Sambin's stuff started.
[helm.git] / helm / software / matita / nlibrary / sets / categories.ma
1
2 include "sets/sets.ma".
3
4 ndefinition binary_morph_setoid : setoid → setoid → setoid → setoid.
5 #S1; #S2; #T; @ (binary_morphism S1 S2 T); @;
6 ##[ #f; #g; napply (∀x,y. f x y = g x y);
7 ##| #f; #x; #y; napply #;
8 ##| #f; #g; #H; #x; #y; napply ((H x y)^-1);
9 ##| #f; #g; #h; #H1; #H2; #x; #y; napply (trans … (H1 …) (H2 …)); ##]
10 nqed.
11
12 ndefinition unary_morph_setoid : setoid → setoid → setoid.
13 #S1; #S2; @ (unary_morphism S1 S2); @;
14 ##[ #f; #g; napply (∀x. f x = g x);
15 ##| #f; #x; napply #;
16 ##| #f; #g; #H; #x; napply ((H x)^-1);
17 ##| #f; #g; #h; #H1; #H2; #x; napply (trans … (H1 …) (H2 …)); ##]
18 nqed.
19
20 nrecord category : Type[2] ≝
21  { objs:> Type[1];
22    arrows: objs → objs → setoid;
23    id: ∀o:objs. arrows o o;
24    comp: ∀o1,o2,o3. binary_morphism (arrows o1 o2) (arrows o2 o3) (arrows o1 o3);
25    comp_assoc: ∀o1,o2,o3,o4. ∀a12,a23,a34.
26     comp o1 o3 o4 (comp o1 o2 o3 a12 a23) a34 = comp o1 o2 o4 a12 (comp o2 o3 o4 a23 a34);
27    id_neutral_left: ∀o1,o2. ∀a: arrows o1 o2. comp ??? (id o1) a = a;
28    id_neutral_right: ∀o1,o2. ∀a: arrows o1 o2. comp ??? a (id o2) = a
29  }.
30
31 notation "hvbox(A break ⇒ B)" right associative with precedence 50 for @{ 'arrows $A $B }.
32 interpretation "arrows1" 'arrows A B = (unary_morphism1 A B).
33 interpretation "arrows" 'arrows A B = (unary_morphism A B).
34
35 notation > "𝐈𝐝 term 90 A" non associative with precedence 90 for @{ 'id $A }.
36 notation < "mpadded width -90% (𝐈) 𝐝 \sub term 90 A" non associative with precedence 90 for @{ 'id $A }.
37
38 interpretation "id" 'id A = (id ? A).
39
40 ndefinition SETOID : category.
41 @; 
42 ##[ napply setoid;
43 ##| napply unary_morph_setoid;
44 ##| #o; @ (λx.x); #a; #b; #H; napply H;
45 ##| #o1; #o2; #o3; @; 
46     ##[ #f; #g; @(λx.g (f x)); #a; #b; #H; napply (.= (††H)); napply #;
47     ##| #f; #g; #f'; #g'; #H1; #H2; nwhd; #x; napply (.= (H2 (f x)));
48         napply (.= (†(H1 x))); napply #; ##]
49 ##| #o1; #o2; #o3; #o4; #f; #g; #h; nwhd; #x; napply #;
50 ##|##6,7: #o1; #o2; #f; nwhd; #x; napply #; ##]
51 nqed.
52
53 unification hint 0 ≔ ;
54    R ≟ (mk_category setoid unary_morph_setoid (id SETOID) (comp SETOID)
55           (comp_assoc SETOID) (id_neutral_left SETOID)
56           (id_neutral_right SETOID))
57  (* -------------------------------------------------------------------- *) ⊢
58                               objs R ≡ setoid.
59                               
60  unification hint 0 ≔ x,y ;
61    R ≟ (mk_category setoid unary_morph_setoid (id SETOID) (comp SETOID)
62           (comp_assoc SETOID) (id_neutral_left SETOID)
63           (id_neutral_right SETOID))
64  (* -------------------------------------------------------------------- *) ⊢
65                   arrows R x y ≡ unary_morph_setoid x y. 
66                   
67 unification hint 0 ≔ A,B ;               
68                   T ≟ (unary_morph_setoid A B)
69            (* ----------------------------------- *) ⊢              
70                   unary_morphism A B ≡ carr T. 
71                 
72                 
73 ndefinition TYPE : setoid1.
74 @ setoid; @; 
75 ##[ #T1; #T2; 
76     alias symbol "eq" = "setoid eq".
77     napply (∃f:T1 ⇒ T2.∃g:T2 ⇒ T1. (∀x.f (g x) = x) ∧ (∀y.g (f y) = y));
78 ##| #A; @ (𝐈𝐝 A); @ (𝐈𝐝 A); @; #x; napply #;
79 ##| #A; #B; *; #f; *; #g; *; #Hfg; #Hgf; @g; @f; @; nassumption; 
80 ##| #A; #B; #C; *; #f; *; #f'; *; #Hf; #Hf'; *; #g; *; #g'; *; #Hg; #Hg'; 
81     @; ##[ @(λx.g (f x)); #a; #b; #H; napply (.= (††H)); napply #;
82        ##| @; ##[ @(λx.f'(g' x)); #a; #b; #H; napply (.= (††H)); napply #; ##]
83     @; #x;
84     ##[ napply (.= (†(Hf …))); napply Hg;
85     ##| napply (.= (†(Hg' …))); napply Hf'; ##] ##] 
86 nqed.
87
88 unification hint 0 ≔ ;
89           R ≟ (mk_setoid1 setoid (eq1 TYPE))
90   (* -------------------------------------------- *) ⊢
91                  carr1 R ≡ setoid.
92    
93 nrecord unary_morphism01 (A : setoid) (B: setoid1) : Type[1] ≝
94  { fun01:1> A → B;
95    prop01: ∀a,a'. eq ? a a' → eq1 ? (fun01 a) (fun01 a')
96  }.
97  
98 interpretation "prop01" 'prop1 c  = (prop01 ????? c).