]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/software/matita/nlibrary/sets/sets.ma
More Gonthierism. Are they the right solution?
[helm.git] / helm / software / matita / nlibrary / sets / sets.ma
index 20d069caa6be1a0038dbc4b21618fbc25fdc252f..f4b924dccaa26dc047f8ebc557d909b41f4e01fe 100644 (file)
@@ -14,7 +14,7 @@
 
 include "logic/cprop.ma".
 
-nrecord powerset (A: setoid) : Type[1] ≝ { mem_op: unary_morphism1 A CPROP }.
+nrecord powerset (A: setoid) : Type[1] ≝ { mem_op:> unary_morphism1 A CPROP }.
 
 interpretation "powerset" 'powerset A = (powerset A).
 
@@ -41,11 +41,11 @@ ndefinition powerset_setoid1: setoid → setoid1.
   [ napply (Ω \sup S)
   | napply mk_equivalence_relation1
      [ #A; #B; napply (∀x. iff (x ∈ A) (x ∈ B))
-     | nnormalize; #x; #x0; napply mk_iff; #H; nassumption
-     | nnormalize; #x; #y; #H; #A; napply mk_iff; #K
+     | nwhd; #x; #x0; napply mk_iff; #H; nassumption
+     | nwhd; #x; #y; #H; #A; napply mk_iff; #K
         [ napply (fi ?? (H ?)) | napply (if ?? (H ?)) ]
         nassumption
-     | nnormalize; #A; #B; #C; #H1; #H2; #H3; napply mk_iff; #H4
+     | 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.
@@ -67,13 +67,30 @@ ndefinition overlaps ≝ λA.λU,V:Ω \sup A.∃x:A.x ∈ U ∧ x ∈ V.
 
 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‡#))); nnormalize; napply conj; nassumption
-  | napply (. ((H‡#)‡(H‡#))); nnormalize; napply conj; nassumption]
+ndefinition intersects ≝ λA:Type[0].λU,V:A → CProp[0]. λx. U x ∧ V x.
+
+interpretation "intersects" 'intersects U V = (intersects ? U V).
+
+(* dovrebbe essere un binario? *)
+ndefinition intersects_ok: ∀A. Ω \sup A → Ω \sup A → Ω \sup A.
+ #A; #U; #V; napply mk_powerset; napply mk_unary_morphism1
+  [ napply (intersects ? (mem_op ? U) (mem_op ? V))
+  | #a; #a'; #H; napply mk_iff; *; #H1; #H2
+    [ nwhd; napply (. ((H^-1‡#)‡(H^-1‡#))); nwhd; napply conj; nassumption
+    | nwhd; napply (. ((H‡#)‡(H‡#))); nwhd; napply conj; nassumption]
+nqed.
+
+unification hint 0 (∀A.∀U,V: Ω \sup A.∀w.(λx,y.True)
+ (intersects A U V w) (fun11 ?? (mem_op ? (intersects_ok A U V)) w)).
+
+nlemma test: ∀A. ∀U,V: Ω \sup A. ∀x,x':A. x=x' → (U ∩ V) x → (U ∩ V) x'.
+ #A; #U; #V; #x; #x'; #H; #p;
+ nwhd in ⊢ (? ? % % ?);
+ (* l'unification hint non funziona *)
+  nchange with (? ∈ (intersects_ok ? ? ?));
+  napply (. (†H^-1));
+  nassumption.
 nqed.
-  
-(*interpretation "intersects" 'intersects U V = (intersects ? U V).*)
 
 (*
 ndefinition union ≝ λA.λU,V:Ω \sup A. {x | x ∈ U ∨ x ∈ V }.
@@ -82,4 +99,18 @@ interpretation "union" 'union U V = (union ? U V).
 
 ndefinition singleton ≝ λA:setoid.λa:A.{b | a=b}.
 
-interpretation "singleton" 'singl a = (singleton ? a).*)
\ No newline at end of file
+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}.
+*)