]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/software/matita/nlibrary/sets/setoids1.ma
Good definition found.
[helm.git] / helm / software / matita / nlibrary / sets / setoids1.ma
index 0571b6dfa8e5e2c890657ff682fc14f5341e5592..69e0958744de4f83c3257f88ad3b8e4ac78ef8fa 100644 (file)
 (*                                                                        *)
 (**************************************************************************)
 
+include "properties/relations1.ma".
 include "sets/setoids.ma".
+include "hints_declaration.ma".
 
-(*
-definition reflexive1 ≝ λA:Type.λR:A→A→CProp.∀x:A.R x x.
-definition symmetric1 ≝ λC:Type.λlt:C→C→CProp. ∀x,y:C.lt x y → lt y x.
-definition transitive1 ≝ λA:Type.λR:A→A→CProp.∀x,y,z:A.R x y → R y z → R x z.
-
-record setoid1 : Type ≝
- { carr1:> Type;
-   eq1: carr1 → carr1 → CProp;
-   refl1: reflexive1 ? eq1;
-   sym1: symmetric1 ? eq1;
-   trans1: transitive1 ? eq1
+nrecord setoid1: Type[2] ≝
+ { carr1:> Type[1];
+   eq1: equivalence_relation1 carr1
  }.
 
-definition proofs1: CProp → setoid1.
- intro;
- constructor 1;
-  [ apply A
-  | intros;
-    apply True
-  | intro;
-    constructor 1
-  | intros 3;
-    constructor 1
-  | intros 5;
-    constructor 1]
-qed.
-
-ndefinition CCProp: setoid1.
- constructor 1;
-  [ apply CProp
-  | apply iff
-  | intro;
-    split;
-    intro;
-    assumption
-  | intros 3;
-    cases H; clear H;
-    split;
-    assumption
-  | intros 5;
-    cases H; cases H1; clear H H1;
-    split;
-    intros;
-    [ apply (H4 (H2 H))
-    | apply (H3 (H5 H))]]
-qed.
-
-record function_space1 (A: setoid1) (B: setoid1): Type ≝
- { f1:1> A → B;
-   f1_ok: ∀a,a':A. proofs1 (eq1 ? a a') → proofs1 (eq1 ? (f1 a) (f1 a'))
+ndefinition setoid1_of_setoid: setoid → setoid1.
+ #s; napply mk_setoid1
+  [ napply (carr s)
+  | napply (mk_equivalence_relation1 s)
+    [ napply eq
+    | napply refl
+    | napply sym
+    | napply trans]##]
+nqed.
+
+(*ncoercion setoid1_of_setoid : ∀s:setoid. setoid1 ≝ setoid1_of_setoid
+ on _s: setoid to setoid1.*)
+(*prefer coercion Type_OF_setoid.*)
+
+interpretation "setoid1 eq" 'eq t x y = (eq_rel1 ? (eq1 t) x y).
+interpretation "setoid eq" 'eq t x y = (eq_rel ? (eq t) x y).
+
+notation > "hvbox(a break =_12 b)" non associative with precedence 45
+for @{ eq_rel2 (carr2 (setoid2_of_setoid1 ?)) (eq2 (setoid2_of_setoid1 ?)) $a $b }.
+notation > "hvbox(a break =_0 b)" non associative with precedence 45
+for @{ eq_rel ? (eq ?) $a $b }.
+notation > "hvbox(a break =_1 b)" non associative with precedence 45
+for @{ eq_rel1 ? (eq1 ?) $a $b }.
+
+interpretation "setoid1 symmetry" 'invert r = (sym1 ???? r).
+interpretation "setoid symmetry" 'invert r = (sym ???? r).
+notation ".= r" with precedence 50 for @{'trans $r}.
+interpretation "trans1" 'trans r = (trans1 ????? r).
+interpretation "trans" 'trans r = (trans ????? r).
+
+nrecord unary_morphism1 (A,B: setoid1) : Type[1] ≝
+ { fun11:1> A → B;
+   prop11: ∀a,a'. eq1 ? a a' → eq1 ? (fun11 a) (fun11 a')
  }.
 
-definition function_space_setoid1: setoid1 → setoid1 → setoid1.
- intros (A B);
- constructor 1;
-  [ apply (function_space1 A B);
-  | intros;
-    apply (∀a:A. proofs1 (eq1 ? (f a) (f1 a)));
-  |*: cases daemon] (* simplify;
-    intros;
-    apply (f1_ok ? ? x);
-    unfold proofs; simplify;
-    apply (refl1 A)
-  | simplify;
-    intros;
-    unfold proofs; simplify;
-    apply (sym1 B);
-    apply (f a)
-  | simplify;
-    intros;
-    unfold carr; unfold proofs; simplify;
-    apply (trans1 B ? (y a));
-    [ apply (f a)
-    | apply (f1 a)]] *)
-qed.
-
-interpretation "function_space_setoid1" 'Imply a b = (function_space_setoid1 a b).
-
-definition setoids: setoid1.
- constructor 1;
-  [ apply setoid;
-  | apply isomorphism;
-  | intro;
-    split;
-     [1,2: constructor 1;
-        [1,3: intro; assumption;
-        |*: intros; assumption]
-     |3,4:
-       intros;
-       simplify;
-       unfold proofs; simplify;
-       apply refl;]
-  |*: cases daemon]
-qed.
-
-definition setoid1_of_setoid: setoid → setoid1.
- intro;
- constructor 1;
-  [ apply (carr s)
-  | apply (eq s)
-  | apply (refl s)
-  | apply (sym s)
-  | apply (trans s)]
-qed.
-
-coercion setoid1_of_setoid.
-
-record forall (A:setoid)  (B: A ⇒ CCProp): CProp ≝
- { fo:> ∀a:A.proofs (B a) }.
-
-record subset (A: setoid) : CProp ≝
- { mem: A ⇒ CCProp }.
-
-definition ssubset: setoid → setoid1.
- intro;
- constructor 1;
-  [ apply (subset s);
-  | apply (λU,V:subset s. ∀a. mem ? U a \liff mem ? V a)
-  | simplify;
-    intros;
-    split;
-    intro;
-    assumption
-  | simplify;
-    cases daemon
-  | cases daemon]
-qed.
-
-definition mmem: ∀A:setoid. (ssubset A) ⇒ A ⇒ CCProp.
- intros;
- constructor 1;
-  [ apply mem; 
-  | unfold function_space_setoid1; simplify;
-    intros (b b');
-    change in ⊢ (? (? (?→? (? %)))) with (mem ? b a \liff mem ? b' a);
-    unfold proofs1; simplify; intros;
-    unfold proofs1 in c; simplify in c;
-    unfold ssubset in c; simplify in c;
-    cases (c a); clear c;
-    split;
-    assumption]
-qed.
-
-definition sand: CCProp ⇒ CCProp.
-
-definition intersection: ∀A. ssubset A ⇒ ssubset A ⇒ ssubset A.
- intro;
- constructor 1;
-  [ intro;
-    constructor 1;
-     [ intro;
-       constructor 1;
-       constructor 1;
-       intro;
-       apply (mem ? c c2 ∧ mem ? c1 c2);
-     |
-  |
-  |
-
-*)
+interpretation "prop11" 'prop1 c = (prop11 ????? c).
+interpretation "refl1" 'refl = (refl1 ???).
+
+ndefinition unary_morphism1_setoid1: setoid1 → setoid1 → setoid1.
+ #s; #s1; @ (unary_morphism1 s s1); @
+     [ #f; #g; napply (∀a,a':s. a=a' → f a = g a')
+     | #x; #a; #a'; #Ha; napply (.= †Ha); napply refl1
+     | #x; #y; #H; #a; #a'; #Ha; napply (.= †Ha); napply sym1; /2/
+     | #x; #y; #z; #H1; #H2; #a; #a'; #Ha; napply (.= †Ha); napply trans1; ##[##2: napply H1 | ##skip | napply H2]//;##]
+nqed.
+
+unification hint 0 ≔ S, T ;
+ R ≟ (unary_morphism1_setoid1 S T)
+(* --------------------------------- *) ⊢
+   carr1 R ≡ unary_morphism1 S T.
+
+interpretation "prop21" 'prop2 l r = (prop11 ? (unary_morphism1_setoid1 ??) ? ?? l ?? r).
+
+nlemma unary_morph1_eq1: ∀A,B.∀f,g: unary_morphism1 A B. (∀x. f x = g x) → f=g.
+/3/. nqed.
+
+nlemma mk_binary_morphism1:
+ ∀A,B,C: setoid1. ∀f: A → B → C. (∀a,a',b,b'. a=a' → b=b' → f a b = f a' b') →
+  unary_morphism1 A (unary_morphism1_setoid1 B C).
+ #A; #B; #C; #f; #H; @ [ #x; @ (f x) ] #a; #a'; #Ha [##2: napply unary_morph1_eq1; #y]
+ /2/.
+nqed.
+
+ndefinition composition1 ≝
+ λo1,o2,o3:Type[1].λf:o2 → o3.λg: o1 → o2.λx.f (g x).
+interpretation "function composition" 'compose f g = (composition ??? f g).
+interpretation "function composition1" 'compose f g = (composition1 ??? f g).
+
+ndefinition comp1_unary_morphisms:
+ ∀o1,o2,o3:setoid1.
+  unary_morphism1 o2 o3 → unary_morphism1 o1 o2 →
+   unary_morphism1 o1 o3.
+#o1; #o2; #o3; #f; #g; @ (f ∘ g);
+ #a; #a'; #e; nnormalize; napply (.= †(†e)); napply #.
+nqed.
+
+unification hint 0 ≔ o1,o2,o3:setoid1,f:unary_morphism1 o2 o3,g:unary_morphism1 o1 o2;
+   R ≟ (mk_unary_morphism1 ?? (composition1 … f g)
+        (prop11 ?? (comp1_unary_morphisms o1 o2 o3 f g)))
+ (* -------------------------------------------------------------------- *) ⊢
+                              fun11 ?? R ≡ (composition1 … f g).
+                              
+ndefinition comp1_binary_morphisms:
+ ∀o1,o2,o3.
+  unary_morphism1 (unary_morphism1_setoid1 o2 o3)
+   (unary_morphism1_setoid1 (unary_morphism1_setoid1 o1 o2) (unary_morphism1_setoid1 o1 o3)).
+#o1; #o2; #o3; napply mk_binary_morphism1
+ [ #f; #g; napply (comp1_unary_morphisms … f g) (*CSC: why not ∘?*)
+ | #a; #a'; #b; #b'; #ea; #eb; #x; #x'; #Hx; nnormalize; /3/ ]
+nqed.
\ No newline at end of file