]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/matita/library/datatypes/bool.ma
added bool_elim (elimination which preserves infos on the eliminated value)
[helm.git] / helm / matita / library / datatypes / bool.ma
index a223d7d0c9333c27b77e328b253e19229fe319f1..11f1d7a8c49d48047e12caaeec555c207e1ca784 100644 (file)
@@ -19,7 +19,18 @@ include "logic/equality.ma".
 inductive bool : Set \def 
   | true : bool
   | false : bool.
-  
+
+theorem bool_elim: \forall P:bool \to Prop. \forall b:bool.
+  (b = true \to P true)
+  \to (b = false \to P false)
+  \to P b.
+  intros 2 (P b).
+  elim b;
+  [ apply H; reflexivity
+  | apply H1; reflexivity
+  ]
+qed.
+
 theorem not_eq_true_false : true \neq false.
 simplify.intro.
 change with 
@@ -84,3 +95,26 @@ match b with
 | false  \Rightarrow Q].
 
 (*CSC: missing notation for if_then_else *)
+
+theorem bool_to_decidable_eq:
+ \forall b1,b2:bool. decidable (b1=b2).
+ intros.
+ unfold decidable.
+ elim b1.
+  elim b2.
+   left. reflexivity.
+   right. exact not_eq_true_false.
+  elim b2.
+   right. unfold Not. intro.
+   apply not_eq_true_false.
+   symmetry. exact H.
+   left. reflexivity.
+qed.
+
+theorem P_x_to_P_x_to_eq:
+ \forall A:Set. \forall P: A \to bool.
+  \forall x:A. \forall p1,p2:P x = true. p1 = p2.
+ intros.
+ apply eq_to_eq_to_eq_p_q.
+ exact bool_to_decidable_eq.
+qed.