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