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 include "logic/equality.ma".
16 include "higher_order_defs/functions.ma".
18 inductive bool : Set \def
22 theorem bool_elim: \forall P:bool \to Prop. \forall b:bool.
24 \to (b = false \to P false)
28 [ apply H; reflexivity
29 | apply H1; reflexivity
33 theorem not_eq_true_false : true \neq false.
37 [ true \Rightarrow False
38 | false \Rightarrow True].
39 rewrite > H.simplify.exact I.
42 definition notb : bool \to bool \def
45 [ true \Rightarrow false
46 | false \Rightarrow true ].
48 (* FG: interpretation right after definition *)
49 interpretation "boolean not" 'not x = (notb x).
51 theorem notb_elim: \forall b:bool.\forall P:bool \to Prop.
53 [ true \Rightarrow P false
54 | false \Rightarrow P true] \to P (notb b).
55 intros 2.elim b.exact H. exact H.
58 theorem notb_notb: \forall b:bool. notb (notb b) = b.
63 theorem injective_notb: injective bool bool notb.
67 rewrite < (notb_notb y).
72 definition andb : bool \to bool \to bool\def
76 | false \Rightarrow false ].
78 interpretation "boolean and" 'and x y = (andb x y).
80 theorem andb_elim: \forall b1,b2:bool. \forall P:bool \to Prop.
82 [ true \Rightarrow P b2
83 | false \Rightarrow P false] \to P (b1 \land b2).
84 intros 3.elim b1.exact H. exact H.
87 theorem and_true: \forall a,b:bool.
88 andb a b =true \to a =true \land b= true.
91 [reflexivity|assumption]
93 apply not_eq_true_false.
99 theorem andb_true_true: \forall b1,b2. (b1 \land b2) = true \to b1 = true.
105 theorem andb_true_true_r: \forall b1,b2. (b1 \land b2) = true \to b2 = true.
108 |apply False_ind.apply not_eq_true_false.
109 apply sym_eq.assumption
113 definition orb : bool \to bool \to bool\def
116 [ true \Rightarrow true
117 | false \Rightarrow b2].
119 (* FG: interpretation right after definition *)
120 interpretation "boolean or" 'or x y = (orb x y).
122 theorem orb_elim: \forall b1,b2:bool. \forall P:bool \to Prop.
124 [ true \Rightarrow P true
125 | false \Rightarrow P b2] \to P (orb b1 b2).
126 intros 3.elim b1.exact H. exact H.
129 definition if_then_else : bool \to Prop \to Prop \to Prop \def
130 \lambda b:bool.\lambda P,Q:Prop.
133 | false \Rightarrow Q].
135 (*CSC: missing notation for if_then_else *)
137 theorem bool_to_decidable_eq:
138 \forall b1,b2:bool. decidable (b1=b2).
144 right. exact not_eq_true_false.
146 right. unfold Not. intro.
147 apply not_eq_true_false.
152 theorem P_x_to_P_x_to_eq:
153 \forall A:Set. \forall P: A \to bool.
154 \forall x:A. \forall p1,p2:P x = true. p1 = p2.
156 apply eq_to_eq_to_eq_p_q.
157 exact bool_to_decidable_eq.
161 (* some basic properties of and - or*)
162 theorem andb_sym: \forall A,B:bool.
163 (A \land B) = (B \land A).
171 theorem andb_assoc: \forall A,B,C:bool.
172 (A \land (B \land C)) = ((A \land B) \land C).
181 theorem orb_sym: \forall A,B:bool.
182 (A \lor B) = (B \lor A).
190 theorem true_to_true_to_andb_true: \forall A,B:bool.
191 A = true \to B = true \to (A \land B) = true.