]> matita.cs.unibo.it Git - helm.git/blob - matitaB/matita/nlibrary/sets/setoids1.ma
Keeping track of locations of disambiguated ids and symbols.
[helm.git] / matitaB / matita / nlibrary / sets / setoids1.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 include "properties/relations1.ma".
16 include "sets/setoids.ma".
17 include "hints_declaration.ma".
18
19 record setoid1: Type[2] ≝ { 
20   carr1:> Type[1];
21   eq1: equivalence_relation1 carr1 
22 }.
23
24 unification hint 0 ≔ R : setoid1; 
25    MR ≟ (carr1 R), 
26    lock ≟ mk_lock2 Type[1] MR setoid1 R 
27 (* ---------------------------------------- *) ⊢ 
28    setoid1 ≡ force2 ? MR lock.
29
30 notation < "[\setoid1\ensp\of term 19 x]" non associative with precedence 90 for @{'mk_setoid1 $x}.
31 interpretation "mk_setoid1" 'mk_setoid1 x = (mk_setoid1 x ?).
32
33 (* da capire se mettere come coercion *)
34 definition setoid1_of_setoid: setoid → setoid1.
35  #s % [@(carr s)] % [@(eq0…)|@(refl…)|@(sym…)|@(trans…)]
36 qed.
37
38 alias symbol "hint_decl" = "hint_decl_CProp2".
39 alias symbol "hint_decl" (instance 1) = "hint_decl_Type2".
40 unification hint 0 ≔ A,x,y;
41    T  ≟ carr A, 
42    R  ≟ setoid1_of_setoid A,
43    T1 ≟ carr1 R
44 (*-----------------------------------------------*) ⊢
45    eq_rel T (eq0 A) x y ≡ eq_rel1 T1 (eq1 R) x y.
46
47 unification hint 0 ≔ A;
48    R  ≟ setoid1_of_setoid A
49 (*-----------------------------------------------*) ⊢
50    carr A ≡ carr1 R.
51
52 interpretation "setoid1 eq" 'eq t x y = (eq_rel1 ? (eq1 t) x y).
53 interpretation "setoid eq" 'eq t x y = (eq_rel ? (eq0 t) x y).
54
55 notation > "hvbox(a break =_12 b)" non associative with precedence 45
56 for @{ eq_rel2 (carr2 (setoid2_of_setoid1 ?)) (eq2 (setoid2_of_setoid1 ?)) $a $b }.
57 notation > "hvbox(a break =_0 b)" non associative with precedence 45
58 for @{ eq_rel ? (eq0 ?) $a $b }.
59 notation > "hvbox(a break =_1 b)" non associative with precedence 45
60 for @{ eq_rel1 ? (eq1 ?) $a $b }.
61
62 interpretation "setoid1 symmetry" 'invert r = (sym1 ???? r).
63 interpretation "setoid symmetry" 'invert r = (sym ???? r).
64 notation ".=_1 r" with precedence 50 for @{'trans_x1 $r}.
65 interpretation "trans1" 'trans r = (trans1 ????? r).
66 interpretation "trans" 'trans r = (trans ????? r).
67 interpretation "trans1_x1" 'trans_x1 r = (trans1 ????? r).
68
69 record unary_morphism1 (A,B: setoid1) : Type[1] ≝ { 
70   fun11:1> A → B;
71   prop11: ∀a,a'. eq1 ? a a' → eq1 ? (fun11 a) (fun11 a') 
72 }.
73  
74 notation > "B ⇒_1 C" right associative with precedence 72 for @{'umorph1 $B $C}.
75 notation "hvbox(B break ⇒\sub 1 C)" right associative with precedence 72 for @{'umorph1 $B $C}.
76 interpretation "unary morphism 1" 'umorph1 A B = (unary_morphism1 A B).
77  
78 notation "┼_1 c" with precedence 89 for @{'prop1_x1 $c }.
79 interpretation "prop11" 'prop1 c = (prop11 ????? c).
80 interpretation "prop11_x1" 'prop1_x1 c = (prop11 ????? c).
81 interpretation "refl1" 'refl = (refl1 ???).
82
83 definition unary_morphism1_setoid1: setoid1 → setoid1 → setoid1.
84  #s #s1 % [@(s ⇒_1 s1)] %
85      [ #f #g @(∀a,a':s. a=a' → f a = g a')
86      | #x #a #a' #Ha @(.= †Ha) @refl1
87      | #x #y #H #a #a' #Ha @(.= †Ha) @sym1 /2/
88      | #x #y #z #H1 #H2 #a #a' #Ha @(.= †Ha) @trans1
89        [2: @H1 | skip | @H2] // ]
90 qed.
91
92 unification hint 0 ≔ S, T ;
93    R ≟ (unary_morphism1_setoid1 S T)
94 (* --------------------------------- *) ⊢
95    carr1 R ≡ unary_morphism1 S T.
96    
97 notation "l ╪_1 r" with precedence 89 for @{'prop2_x1 $l $r }.
98 interpretation "prop21" 'prop2 l r = (prop11 ? (unary_morphism1_setoid1 ??) ? ?? l ?? r).
99 interpretation "prop21_x1" 'prop2_x1 l r = (prop11 ? (unary_morphism1_setoid1 ??) ? ?? l ?? r).
100
101 lemma unary_morph1_eq1: ∀A,B.∀f,g: A ⇒_1 B. (∀x. f x = g x) → f = g.
102 /3/
103 qed.
104
105 (* DISAMBIGUATION XXX: this takes some time to disambiguate *)
106 lemma mk_binary_morphism1:
107  ∀A,B,C: setoid1. ∀f: A → B → C. (∀a,a',b,b'. a=a' → b=b' → f a b = f a' b') →
108   A ⇒_1 (unary_morphism1_setoid1 B C).
109  #A #B #C #f #H % [ #x % [@(f x)]] #a #a' #Ha [2: @unary_morph1_eq1 #y]
110  /2/
111 qed.
112
113 definition composition1 ≝
114  λo1,o2,o3:Type[1].λf:o2 → o3.λg: o1 → o2.λx.f (g x).
115  
116 interpretation "function composition" 'compose f g = (composition ??? f g).
117 interpretation "function composition1" 'compose f g = (composition1 ??? f g).
118
119 definition comp1_unary_morphisms: 
120   ∀o1,o2,o3:setoid1.o2 ⇒_1 o3 → o1 ⇒_1 o2 → o1 ⇒_1 o3.
121 #o1 #o2 #o3 #f #g % [@ (f ∘ g)]
122  #a #a' #e normalize @(.= †(†e)) @#
123 qed.
124
125 unification hint 0 ≔ o1,o2,o3:setoid1,f:o2 ⇒_1 o3,g:o1 ⇒_1 o2;
126    R ≟ (mk_unary_morphism1 ?? (composition1 ??? (fun11 ?? f) (fun11 ?? g))
127         (prop11 ?? (comp1_unary_morphisms o1 o2 o3 f g)))
128  (* -------------------------------------------------------------------- *) ⊢
129        fun11 o1 o3 R ≡ composition1 ??? (fun11 ?? f) (fun11 ?? g).
130                               
131 definition comp1_binary_morphisms:
132  ∀o1,o2,o3. (o2 ⇒_1 o3) ⇒_1 ((o1 ⇒_1 o2) ⇒_1 (o1 ⇒_1 o3)).
133 #o1 #o2 #o3 @mk_binary_morphism1
134  [ #f #g @(comp1_unary_morphisms … f g)
135  | #a #a' #b #b' #ea #eb #x #x' #Hx normalize /3/ ]
136 qed.