]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/software/matita/nlibrary/sets/sets.ma
...
[helm.git] / helm / software / matita / nlibrary / sets / sets.ma
index c06ce33f6bb8e46520daeeebf3ab9a4c0b463aeb..20065cec4156afcc5f9b974968dd99f1a3bb17ae 100644 (file)
 (*                                                                        *)
 (**************************************************************************)
 
-include "logic/connectives.ma".
+include "logic/cprop.ma".
 
-nrecord powerset (A: Type) : Type[1] ≝ { mem: A → CProp }.
-(* This is a projection! *)
-ndefinition mem ≝ λA.λr:powerset A.match r with [mk_powerset f ⇒ f].
+nrecord powerset (A: setoid) : Type[1] ≝ { mem_op: unary_morphism1 A CPROP }.
 
 interpretation "powerset" 'powerset A = (powerset A).
 
-interpretation "subset construction" 'subset \eta.x = (mk_powerset ? x).
+interpretation "subset construction" 'subset \eta.x =
+ (mk_powerset ? (mk_unary_morphism1 ? CPROP x ?)).
 
-interpretation "mem" 'mem a S = (mem ? S a).
+interpretation "mem" 'mem a S = (mem_op ? S a).
 
-ndefinition subseteq ≝ λA.λU,V.∀a:A. a ∈ U → a ∈ V.
+ndefinition subseteq ≝ λA:setoid.λU,V.∀a:A. a ∈ U → a ∈ V.
 
 interpretation "subseteq" 'subseteq U V = (subseteq ? U V).
 
@@ -34,50 +33,67 @@ nqed.
 
 ntheorem subseteq_trans: ∀A.∀S1,S2,S3: Ω \sup A. S1 ⊆ S2 → S2 ⊆ S3 → S1 ⊆ S3.
  #A; #S1; #S2; #S3; #H12; #H23; #x; #H;
- napply (H23 ??); napply (H12 ??); nassumption;
+ napply H23; napply H12; nassumption;
 nqed.
 
+ndefinition powerset_setoid1: setoid → setoid1.
+ #S; napply mk_setoid1
+  [ napply (Ω \sup S)
+  | napply mk_equivalence_relation1
+     [ #A; #B; napply (∀x. iff (x ∈ A) (x ∈ B))
+     | nwhd; #x; #x0; napply mk_iff; #H; nassumption
+     | nwhd; #x; #y; #H; #A; napply mk_iff; #K
+        [ napply (fi ?? (H ?)) | napply (if ?? (H ?)) ]
+        nassumption
+     | nwhd; #A; #B; #C; #H1; #H2; #H3; napply mk_iff; #H4
+        [ napply (if ?? (H2 ?)); napply (if ?? (H1 ?)); nassumption
+        | napply (fi ?? (H1 ?)); napply (fi ?? (H2 ?)); nassumption]##]
+nqed.
+
+unification hint 0 (∀A.(λx,y.True) (Ω \sup A) (carr1 (powerset_setoid1 A))).
+
+ndefinition mem: ∀A:setoid. binary_morphism1 A (powerset_setoid1 A) CPROP.
+ #A; napply mk_binary_morphism1
+  [ napply (λa.λA.a ∈ A)
+  | #a; #a'; #B; #B'; #Ha; #HB; napply mk_iff; #H
+     [ napply (. (†Ha^-1)); (* CSC: notation for ∈ not working *)
+       napply (if ?? (HB ?)); nassumption
+     | napply (. (†Ha)); napply (fi ?? (HB ?)); nassumption]##]
+nqed.
+
+unification hint 0 (∀A,x,S. (λx,y.True) (mem_op A x S) (fun21 ??? (mem A) S x)).
+
 ndefinition overlaps ≝ λA.λU,V:Ω \sup A.∃x:A.x ∈ U ∧ x ∈ V.
 
-interpretation "overlaps" 'overlaps U V = (fun1 ??? (overlaps ?) U V).
-
-definition intersects:
- ∀A. binary_morphism1 (powerset_setoid A) (powerset_setoid A) (powerset_setoid A).
- intros;
- constructor 1;
-  [ apply (λU,V. {x | x ∈ U ∧ x ∈ V });
-    intros; simplify; apply (.= (H‡#)‡(H‡#)); apply refl1;
-  | intros;
-    split; intros 2; simplify in f ⊢ %;
-    [ apply (. (#‡H)‡(#‡H1)); assumption
-    | apply (. (#‡(H \sup -1))‡(#‡(H1 \sup -1))); assumption]]
-qed.
-
-interpretation "intersects" 'intersects U V = (fun1 ??? (intersects ?) U V).
-
-definition union:
- ∀A. binary_morphism1 (powerset_setoid A) (powerset_setoid A) (powerset_setoid A).
- intros;
- constructor 1;
-  [ apply (λU,V. {x | x ∈ U ∨ x ∈ V });
-    intros; simplify; apply (.= (H‡#)‡(H‡#)); apply refl1
-  | intros;
-    split; intros 2; simplify in f ⊢ %;
-    [ apply (. (#‡H)‡(#‡H1)); assumption
-    | apply (. (#‡(H \sup -1))‡(#‡(H1 \sup -1))); assumption]]
-qed.
-
-interpretation "union" 'union U V = (fun1 ??? (union ?) U V).
-
-definition singleton: ∀A:setoid. unary_morphism A (Ω \sup A).
- intros; constructor 1;
-  [ apply (λA:setoid.λa:A.{b | a=b});
-    intros; simplify;
-    split; intro;
-    apply (.= H1);
-     [ apply H | apply (H \sup -1) ]
-  | intros; split; intros 2; simplify in f ⊢ %; apply trans;
-     [ apply a |4: apply a'] try assumption; apply sym; assumption]
-qed.
-
-interpretation "singleton" 'singl a = (fun_1 ?? (singleton ?) a).
\ No newline at end of file
+interpretation "overlaps" 'overlaps U V = (overlaps ? U V).
+
+ndefinition intersects ≝ λA.λU,V:Ω \sup A. {x | x ∈ U ∧ x ∈ V }.
+ #a; #a'; #H; napply mk_iff; *; #H1; #H2
+  [ napply (. ((H^-1‡#)‡(H^-1‡#))); nwhd; napply conj; nassumption
+  | napply (. ((H‡#)‡(H‡#))); nwhd; napply conj; nassumption]
+nqed.
+  
+(*interpretation "intersects" 'intersects U V = (intersects ? U V).*)
+
+(*
+ndefinition union ≝ λA.λU,V:Ω \sup A. {x | x ∈ U ∨ x ∈ V }.
+
+interpretation "union" 'union U V = (union ? U V).
+
+ndefinition singleton ≝ λA:setoid.λa:A.{b | a=b}.
+
+interpretation "singleton" 'singl a = (singleton ? a).*)
+
+(*
+(* qui non funziona una cippa *)
+ndefinition image: ∀A,B. (carr A → carr B) → Ω \sup A → Ω \sup B ≝
+ λA,B:setoid.λf:carr A → carr B.λSa:Ω \sup A.
+  {y | ∃x. x ∈ Sa ∧ eq_rel (carr B) (eq B) ? ?(*(f x) y*)}.
+  ##[##2: napply (f x); ##|##3: napply y]
+ #a; #a'; #H; nwhd; nnormalize; (* per togliere setoid1_of_setoid *) napply (mk_iff ????);
+ *; #x; #Hx; napply (ex_intro … x)
+  [ napply (. (#‡(#‡#))); 
+
+ndefinition counter_image: ∀A,B. (A → B) → Ω \sup B → Ω \sup A ≝
+ λA,B,f,Sb. {x | ∃y. y ∈ Sb ∧ f x = y}.
+*)