]> matita.cs.unibo.it Git - helm.git/blob - helm/software/matita/nlibrary/sets/setoids.ma
58fe2184456dc39dddfa35854563ac686c960b82
[helm.git] / helm / software / matita / nlibrary / sets / setoids.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 "logic/connectives.ma".
16 include "properties/relations.ma".
17 include "hints_declaration.ma".
18
19 (*
20 notation "hvbox(a break = \sub \ID b)" non associative with precedence 45
21 for @{ 'eqID $a $b }.
22
23 notation > "hvbox(a break =_\ID b)" non associative with precedence 45
24 for @{ cic:/matita/logic/equality/eq.ind#xpointer(1/1) ? $a $b }.
25
26 interpretation "ID eq" 'eqID x y = (cic:/matita/logic/equality/eq.ind#xpointer(1/1) ? x y).
27 *)
28
29 nrecord setoid : Type[1] ≝
30  { carr:> Type[0];
31    eq: equivalence_relation carr
32  }.
33
34 interpretation "setoid eq" 'eq t x y = (eq_rel ? (eq t) x y).
35
36 notation > "hvbox(a break =_0 b)" non associative with precedence 45
37 for @{ eq_rel ? (eq ?) $a $b }.
38
39 interpretation "setoid symmetry" 'invert r = (sym ???? r).
40 notation ".= r" with precedence 50 for @{'trans $r}.
41 interpretation "trans" 'trans r = (trans ????? r).
42
43 nrecord unary_morphism (A,B: setoid) : Type[0] ≝
44  { fun1:1> A → B;
45    prop1: ∀a,a'. eq ? a a' → eq ? (fun1 a) (fun1 a')
46  }.
47
48 notation "† c" with precedence 90 for @{'prop1 $c }.
49 notation "l ‡ r" with precedence 90 for @{'prop2 $l $r }.
50 notation "#" with precedence 90 for @{'refl}.
51 interpretation "prop1" 'prop1 c  = (prop1 ????? c).
52 interpretation "refl" 'refl = (refl ???).
53
54 ndefinition unary_morph_setoid : setoid → setoid → setoid.
55 #S1; #S2; @ (unary_morphism S1 S2); @;
56 ##[ #f; #g; napply (∀x,x'. x=x' → f x = g x');
57 ##| #f; #x; #x'; #Hx; napply (.= †Hx); napply #;
58 ##| #f; #g; #H; #x; #x'; #Hx; napply ((H … Hx^-1)^-1);
59 ##| #f; #g; #h; #H1; #H2; #x; #x'; #Hx; napply (trans … (H1 …) (H2 …)); //; ##]
60 nqed.
61
62 unification hint 0
63  (∀o1,o2. (λx,y:Type[0].True) (carr (unary_morph_setoid o1 o2)) (unary_morphism o1 o2)).
64
65 interpretation "prop2" 'prop2 l r = (prop1 ? (unary_morph_setoid ??) ? ?? l ?? r).
66
67 nlemma unary_morph_eq: ∀A,B.∀f,g: unary_morphism A B. (∀x. f x = g x) → f=g.
68 /3/. nqed.
69
70 nlemma mk_binary_morphism:
71  ∀A,B,C: setoid. ∀f: A → B → C. (∀a,a',b,b'. a=a' → b=b' → f a b = f a' b') →
72   unary_morphism A (unary_morph_setoid B C).
73  #A; #B; #C; #f; #H; @ [ #x; @ (f x) ] #a; #a'; #Ha [##2: napply unary_morph_eq; #y]
74  /2/.
75 nqed.
76
77 ndefinition composition ≝
78  λo1,o2,o3:Type[0].λf:o2 → o3.λg: o1 → o2.λx.f (g x).
79  
80 interpretation "function composition" 'compose f g = (composition ??? f g).
81
82 ndefinition comp_unary_morphisms:
83  ∀o1,o2,o3:setoid.
84   unary_morphism o2 o3 → unary_morphism o1 o2 →
85    unary_morphism o1 o3.
86 #o1; #o2; #o3; #f; #g; @ (f ∘ g);
87  #a; #a'; #e; nnormalize; napply (.= †(†e)); napply #.
88 nqed.
89
90 unification hint 0 ≔ o1,o2,o3:setoid,f:unary_morphism o2 o3,g:unary_morphism o1 o2;
91    R ≟ (mk_unary_morphism ?? (composition … f g)
92         (prop1 ?? (comp_unary_morphisms o1 o2 o3 f g)))
93  (* -------------------------------------------------------------------- *) ⊢
94                               fun1 ?? R ≡ (composition … f g).
95
96 ndefinition comp_binary_morphisms:
97  ∀o1,o2,o3.
98   unary_morphism (unary_morph_setoid o2 o3)
99    (unary_morph_setoid (unary_morph_setoid o1 o2) (unary_morph_setoid o1 o3)).
100 #o1; #o2; #o3; napply mk_binary_morphism
101  [ #f; #g; napply (comp_unary_morphisms … f g) (*CSC: why not ∘?*)
102  | #a; #a'; #b; #b'; #ea; #eb; #x; #x'; #Hx; nnormalize; /3/ ]
103 nqed.