1 (**************************************************************************)
4 (* ||A|| A project by Andrea Asperti *)
6 (* ||I|| Developers: *)
7 (* ||T|| A.Asperti, C.Sacerdoti Coen, *)
8 (* ||A|| E.Tassi, S.Zacchiroli *)
10 (* \ / This file is distributed under the terms of the *)
11 (* v GNU Lesser General Public License Version 2.1 *)
13 (**************************************************************************)
15 set "baseuri" "cic:/matita/datatypes/bool/".
17 include "logic/equality.ma".
19 inductive bool : Set \def
23 theorem bool_elim: \forall P:bool \to Prop. \forall b:bool.
25 \to (b = false \to P false)
29 [ apply H; reflexivity
30 | apply H1; reflexivity
34 theorem not_eq_true_false : true \neq false.
38 [ true \Rightarrow False
39 | flase \Rightarrow True].
40 rewrite > H.simplify.exact I.
43 definition notb : bool \to bool \def
46 [ true \Rightarrow false
47 | false \Rightarrow true ].
49 theorem notb_elim: \forall b:bool.\forall P:bool \to Prop.
51 [ true \Rightarrow P false
52 | false \Rightarrow P true] \to P (notb b).
53 intros 2.elim b.exact H. exact H.
56 (*CSC: the URI must disappear: there is a bug now *)
57 interpretation "boolean not" 'not x = (cic:/matita/datatypes/bool/notb.con x).
59 definition andb : bool \to bool \to bool\def
63 | false \Rightarrow false ].
65 (*CSC: the URI must disappear: there is a bug now *)
66 interpretation "boolean and" 'and x y = (cic:/matita/datatypes/bool/andb.con x y).
68 theorem andb_elim: \forall b1,b2:bool. \forall P:bool \to Prop.
70 [ true \Rightarrow P b2
71 | false \Rightarrow P false] \to P (b1 \land b2).
72 intros 3.elim b1.exact H. exact H.
75 theorem andb_true_true: \forall b1,b2. (b1 \land b2) = true \to b1 = true.
81 theorem andb_true_true_r: \forall b1,b2. (b1 \land b2) = true \to b2 = true.
84 |apply False_ind.apply not_eq_true_false.
85 apply sym_eq.assumption
89 definition orb : bool \to bool \to bool\def
92 [ true \Rightarrow true
93 | false \Rightarrow b2].
95 theorem orb_elim: \forall b1,b2:bool. \forall P:bool \to Prop.
97 [ true \Rightarrow P true
98 | false \Rightarrow P b2] \to P (orb b1 b2).
99 intros 3.elim b1.exact H. exact H.
102 (*CSC: the URI must disappear: there is a bug now *)
103 interpretation "boolean or" 'or x y = (cic:/matita/datatypes/bool/orb.con x y).
105 definition if_then_else : bool \to Prop \to Prop \to Prop \def
106 \lambda b:bool.\lambda P,Q:Prop.
109 | false \Rightarrow Q].
111 (*CSC: missing notation for if_then_else *)
113 theorem bool_to_decidable_eq:
114 \forall b1,b2:bool. decidable (b1=b2).
120 right. exact not_eq_true_false.
122 right. unfold Not. intro.
123 apply not_eq_true_false.
128 theorem P_x_to_P_x_to_eq:
129 \forall A:Set. \forall P: A \to bool.
130 \forall x:A. \forall p1,p2:P x = true. p1 = p2.
132 apply eq_to_eq_to_eq_p_q.
133 exact bool_to_decidable_eq.
137 (* some basic properties of and - or*)
138 theorem andb_sym: \forall A,B:bool.
139 (A \land B) = (B \land A).
147 theorem andb_assoc: \forall A,B,C:bool.
148 (A \land (B \land C)) = ((A \land B) \land C).
157 theorem orb_sym: \forall A,B:bool.
158 (A \lor B) = (B \lor A).
166 theorem true_to_true_to_andb_true: \forall A,B:bool.
167 A = true \to B = true \to (A \land B) = true.