]> matita.cs.unibo.it Git - helm.git/blobdiff - matita/matita/lib/basics/deqsets.ma
A few integrations (closed an axiom in finset).
[helm.git] / matita / matita / lib / basics / deqsets.ma
index 38c9a1e05211336f41bd6ef5369beec006979bdb..c17db5dc0cb4b1e899ae76533a686ad5322fb450 100644 (file)
@@ -14,11 +14,12 @@ include "basics/bool.ma".
 
 (****** DeqSet: a set with a decidbale equality ******)
 
-record DeqSet : Type[1] ≝ { carr :> Type[0];
+record DeqSet : Type[1] ≝ { 
+   carr :> Type[0];
    eqb: carr → carr → bool;
    eqb_true: ∀x,y. (eqb x y = true) ↔ (x = y)
 }.
-
+    
 notation "a == b" non associative with precedence 45 for @{ 'eqb $a $b }.
 interpretation "eqb" 'eqb a b = (eqb ? a b).
 
@@ -76,6 +77,45 @@ example exhint: ∀b:bool. (b == false) = true → b = false.
 #b #H @(\P H).
 qed.
 
+(* option *)
+
+definition eq_option ≝
+  λA:DeqSet.λa1,a2:option A.
+    match a1 with 
+    [ None ⇒ match a2 with [None ⇒ true | _ ⇒ false]
+    | Some a1' ⇒ match a2 with [None ⇒ false | Some a2' ⇒ a1'==a2']].
+
+lemma eq_option_true: ∀A:DeqSet.∀a1,a2:option A.
+  eq_option A a1 a2 = true ↔ a1 = a2.
+#A *
+  [* 
+    [% //
+    |#a1 % normalize #H destruct 
+    ]
+  |#a1 *  
+    [normalize % #H destruct
+    |#a2 normalize %
+      [#Heq >(\P Heq) //
+      |#H destruct @(\b ?) //
+      ]
+  ]
+qed.
+
+definition DeqOption ≝ λA:DeqSet.
+  mk_DeqSet (option A) (eq_option A) (eq_option_true A).
+  
+unification hint  0 ≔ C; 
+    T ≟ carr C,
+    X ≟ DeqOption C
+(* ---------------------------------------- *) ⊢ 
+    option T ≡ carr X.
+
+unification hint  0 ≔ T,a1,a2; 
+    X ≟ DeqOption T
+(* ---------------------------------------- *) ⊢ 
+    eq_option T a1 a2 ≡ eqb X a1 a2.
+
+
 (* pairs *)
 definition eq_pairs ≝
   λA,B:DeqSet.λp1,p2:A×B.(\fst p1 == \fst p2) ∧ (\snd p1 == \snd p2).
@@ -168,7 +208,8 @@ qed.
 
 definition DeqSig ≝ λA:DeqSet.λP:A→Prop.
   mk_DeqSet (Σx:A.P x) (eq_sigma A P) (eq_sigma_true A P).
-  
+
+(*
 unification hint  0 ≔ C,P; 
     T ≟ carr C,
     X ≟ DeqSig C P
@@ -179,4 +220,4 @@ unification hint  0 ≔ T,P,p1,p2;
     X ≟ DeqSig T P
 (* ---------------------------------------- *) ⊢ 
     eq_sigma T P p1 p2 ≡ eqb X p1 p2.
-
+*)