]> matita.cs.unibo.it Git - helm.git/blob - helm/software/matita/nlibrary/sets/setoids1.ma
non uniform coercions landed in hints_declaration.ma, setoids and sets library
[helm.git] / helm / software / 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 nrecord 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 ndefinition setoid1_of_setoid: setoid → setoid1.
31  #s; @ (carr s); @ (eq0…) (refl…) (sym…) (trans…);
32 nqed.
33
34 interpretation "setoid1 eq" 'eq t x y = (eq_rel1 ? (eq1 t) x y).
35 interpretation "setoid eq" 'eq t x y = (eq_rel ? (eq0 t) x y).
36
37 notation > "hvbox(a break =_12 b)" non associative with precedence 45
38 for @{ eq_rel2 (carr2 (setoid2_of_setoid1 ?)) (eq2 (setoid2_of_setoid1 ?)) $a $b }.
39 notation > "hvbox(a break =_0 b)" non associative with precedence 45
40 for @{ eq_rel ? (eq0 ?) $a $b }.
41 notation > "hvbox(a break =_1 b)" non associative with precedence 45
42 for @{ eq_rel1 ? (eq1 ?) $a $b }.
43
44 interpretation "setoid1 symmetry" 'invert r = (sym1 ???? r).
45 interpretation "setoid symmetry" 'invert r = (sym ???? r).
46 notation ".=_1 r" with precedence 50 for @{'trans_x1 $r}.
47 interpretation "trans1" 'trans r = (trans1 ????? r).
48 interpretation "trans" 'trans r = (trans ????? r).
49 interpretation "trans1_x1" 'trans_x1 r = (trans1 ????? r).
50
51 nrecord unary_morphism1 (A,B: setoid1) : Type[1] ≝ { 
52   fun11:1> A → B;
53   prop11: ∀a,a'. eq1 ? a a' → eq1 ? (fun11 a) (fun11 a') 
54 }.
55  
56 notation > "B ⇒_1 C" right associative with precedence 72 for @{'umorph1 $B $C}.
57 notation "hvbox(B break ⇒\sub 1 C)" right associative with precedence 72 for @{'umorph1 $B $C}.
58 interpretation "unary morphism 1" 'umorph1 A B = (unary_morphism1 A B).
59  
60 notation "┼_1 c" with precedence 89 for @{'prop1_x1 $c }.
61 interpretation "prop11" 'prop1 c = (prop11 ????? c).
62 interpretation "prop11_x1" 'prop1_x1 c = (prop11 ????? c).
63 interpretation "refl1" 'refl = (refl1 ???).
64
65 ndefinition unary_morphism1_setoid1: setoid1 → setoid1 → setoid1.
66  #s; #s1; @ (s ⇒_1 s1); @
67      [ #f; #g; napply (∀a,a':s. a=a' → f a = g a')
68      | #x; #a; #a'; #Ha; napply (.= †Ha); napply refl1
69      | #x; #y; #H; #a; #a'; #Ha; napply (.= †Ha); napply sym1; /2/
70      | #x; #y; #z; #H1; #H2; #a; #a'; #Ha; napply (.= †Ha); napply trans1; ##[##2: napply H1 | ##skip | napply H2]//;##]
71 nqed.
72
73 unification hint 0 ≔ S, T ;
74    R ≟ (unary_morphism1_setoid1 S T)
75 (* --------------------------------- *) ⊢
76    carr1 R ≡ S ⇒_1 T.
77    
78 notation "l ╪_1 r" with precedence 89 for @{'prop2_x1 $l $r }.
79 interpretation "prop21" 'prop2 l r = (prop11 ? (unary_morphism1_setoid1 ??) ? ?? l ?? r).
80 interpretation "prop21_x1" 'prop2_x1 l r = (prop11 ? (unary_morphism1_setoid1 ??) ? ?? l ?? r).
81
82 nlemma unary_morph1_eq1: ∀A,B.∀f,g: A ⇒_1 B. (∀x. f x = g x) → f = g.
83 /3/. nqed.
84
85 nlemma mk_binary_morphism1:
86  ∀A,B,C: setoid1. ∀f: A → B → C. (∀a,a',b,b'. a=a' → b=b' → f a b = f a' b') →
87   A ⇒_1 (unary_morphism1_setoid1 B C).
88  #A; #B; #C; #f; #H; @ [ #x; @ (f x) ] #a; #a'; #Ha [##2: napply unary_morph1_eq1; #y]
89  /2/.
90 nqed.
91
92 ndefinition composition1 ≝
93  λo1,o2,o3:Type[1].λf:o2 → o3.λg: o1 → o2.λx.f (g x).
94  
95 interpretation "function composition" 'compose f g = (composition ??? f g).
96 interpretation "function composition1" 'compose f g = (composition1 ??? f g).
97
98 ndefinition comp1_unary_morphisms: 
99   ∀o1,o2,o3:setoid1.o2 ⇒_1 o3 → o1 ⇒_1 o2 → o1 ⇒_1 o3.
100 #o1; #o2; #o3; #f; #g; @ (f ∘ g);
101  #a; #a'; #e; nnormalize; napply (.= †(†e)); napply #.
102 nqed.
103
104 unification hint 0 ≔ o1,o2,o3:setoid1,f:o2 ⇒_1 o3,g:o1 ⇒_1 o2;
105    R ≟ (mk_unary_morphism1 ?? (composition1 … f g)
106         (prop11 ?? (comp1_unary_morphisms o1 o2 o3 f g)))
107  (* -------------------------------------------------------------------- *) ⊢
108                               fun11 ?? R ≡ (composition1 … f g).
109                               
110 ndefinition comp1_binary_morphisms:
111  ∀o1,o2,o3. (o2 ⇒_1 o3) ⇒_1 ((o1 ⇒_1 o2) ⇒_1 (o1 ⇒_1 o3)).
112 #o1; #o2; #o3; napply mk_binary_morphism1
113  [ #f; #g; napply (comp1_unary_morphisms … f g) 
114  | #a; #a'; #b; #b'; #ea; #eb; #x; #x'; #Hx; nnormalize; /3/ ]
115 nqed.