1 (**************************************************************************)
4 (* ||A|| A project by Andrea Asperti *)
6 (* ||I|| Developers: *)
7 (* ||T|| The HELM team. *)
8 (* ||A|| http://helm.cs.unibo.it *)
10 (* \ / This file is distributed under the terms of the *)
11 (* v GNU General Public License Version 2 *)
13 (**************************************************************************)
15 (* ********************************************************************** *)
16 (* Progetto FreeScale *)
18 (* Sviluppato da: Ing. Cosimo Oliboni, oliboni@cs.unibo.it *)
19 (* Sviluppo: 2008-2010 *)
21 (* ********************************************************************** *)
23 include "num/bool.ma".
30 ndefinition bool_destruct_aux ≝
31 Πb1,b2:bool.ΠP:Prop.b1 = b2 →
32 match eq_bool b1 b2 with [ true ⇒ P → P | false ⇒ P ].
34 ndefinition bool_destruct : bool_destruct_aux.
43 nlemma symmetric_eqbool : symmetricT bool bool eq_bool.
51 nlemma symmetric_andbool : symmetricT bool bool and_bool.
59 nlemma associative_andbool : ∀b1,b2,b3.((b1 ⊗ b2) ⊗ b3) = (b1 ⊗ (b2 ⊗ b3)).
68 nlemma symmetric_orbool : symmetricT bool bool or_bool.
76 nlemma associative_orbool : ∀b1,b2,b3.((b1 ⊕ b2) ⊕ b3) = (b1 ⊕ (b2 ⊕ b3)).
85 nlemma symmetric_xorbool : symmetricT bool bool xor_bool.
93 nlemma associative_xorbool : ∀b1,b2,b3.((b1 ⊙ b2) ⊙ b3) = (b1 ⊙ (b2 ⊙ b3)).
102 nlemma eqbool_to_eq : ∀b1,b2:bool.(eq_bool b1 b2 = true) → (b1 = b2).
107 ##[ ##1,4: #H; napply refl_eq
108 ##| ##*: #H; ndestruct (*napply (bool_destruct … H)*)
112 nlemma eq_to_eqbool : ∀b1,b2.b1 = b2 → eq_bool b1 b2 = true.
117 ##[ ##1,4: #H; napply refl_eq
118 ##| ##*: #H; ndestruct (*napply (bool_destruct … H)*)
122 nlemma decidable_bool : ∀x,y:bool.decidable (x = y).
127 ##[ ##1,4: napply (or2_intro1 (? = ?) (? ≠ ?) …); napply refl_eq
128 ##| ##*: napply (or2_intro2 (? = ?) (? ≠ ?) …);
131 ndestruct (*napply (bool_destruct … H)*)
135 nlemma decidable_bexpr : ∀x.(x = true) ∨ (x = false).
137 ##[ ##1: napply (or2_intro1 (true = true) (true = false) (refl_eq …))
138 ##| ##2: napply (or2_intro2 (false = true) (false = false) (refl_eq …))
142 nlemma neqbool_to_neq : ∀b1,b2:bool.(eq_bool b1 b2 = false) → (b1 ≠ b2).
147 ##[ ##1,4: #H; ndestruct (*napply (bool_destruct … H)*)
148 ##| ##*: #H; #H1; ndestruct (*napply (bool_destruct … H1)*)
152 nlemma neq_to_neqbool : ∀b1,b2.b1 ≠ b2 → eq_bool b1 b2 = false.
157 ##[ ##1,4: #H; nelim (H (refl_eq …))
158 ##| ##*: #H; napply refl_eq
162 nlemma eqfalse_to_neqtrue : ∀x.x = false → x ≠ true.
164 ##[ ##1: #H; ndestruct (*napply (bool_destruct … H)*)
165 ##| ##2: #H; nnormalize; #H1; ndestruct (*napply (bool_destruct … H1)*)
169 nlemma eqtrue_to_neqfalse : ∀x.x = true → x ≠ false.
171 ##[ ##1: #H; nnormalize; #H1; ndestruct (*napply (bool_destruct … H1)*)
172 ##| ##2: #H; ndestruct (*napply (bool_destruct … H)*)
176 nlemma neqfalse_to_eqtrue : ∀x.x ≠ false → x = true.
178 ##[ ##1: #H; napply refl_eq
179 ##| ##2: nnormalize; #H; nelim (H (refl_eq …))
183 nlemma neqtrue_to_eqfalse : ∀x.x ≠ true → x = false.
185 ##[ ##1: nnormalize; #H; nelim (H (refl_eq …))
186 ##| ##2: #H; napply refl_eq
190 nlemma andb_true_true_l: ∀b1,b2.(b1 ⊗ b2) = true → b1 = true.
195 ##[ ##1,2: #H; napply refl_eq
196 ##| ##*: #H; ndestruct (*napply (bool_destruct … H)*)
200 nlemma andb_true_true_r: ∀b1,b2.(b1 ⊗ b2) = true → b2 = true.
205 ##[ ##1,3: #H; napply refl_eq
206 ##| ##*: #H; ndestruct (*napply (bool_destruct … H)*)
211 : ∀b1,b2.(b1 ⊗ b2) = false →
212 (b1 = false) ∨ (b2 = false).
217 ##[ ##1: #H; ndestruct (*napply (bool_destruct … H)*)
218 ##| ##2,4: #H; napply (or2_intro2 … H)
219 ##| ##3: #H; napply (or2_intro1 … H)
224 : ∀b1,b2,b3.(b1 ⊗ b2 ⊗ b3) = false →
225 Or3 (b1 = false) (b2 = false) (b3 = false).
231 ##[ ##1: #H; ndestruct (*napply (bool_destruct … H)*)
232 ##| ##5,6,7,8: #H; napply (or3_intro1 … H)
233 ##| ##2,4: #H; napply (or3_intro3 … H)
234 ##| ##3: #H; napply (or3_intro2 … H)
239 : ∀b1,b2,b3,b4.(b1 ⊗ b2 ⊗ b3 ⊗ b4) = false →
240 Or4 (b1 = false) (b2 = false) (b3 = false) (b4 = false).
247 ##[ ##1: #H; ndestruct (*napply (bool_destruct … H)*)
248 ##| ##9,10,11,12,13,14,15,16: #H; napply (or4_intro1 … H)
249 ##| ##5,6,7,8: #H; napply (or4_intro2 … H)
250 ##| ##3,4: #H; napply (or4_intro3 … H)
251 ##| ##2: #H; napply (or4_intro4 … H)
256 : ∀b1,b2,b3,b4,b5.(b1 ⊗ b2 ⊗ b3 ⊗ b4 ⊗ b5) = false →
257 Or5 (b1 = false) (b2 = false) (b3 = false) (b4 = false) (b5 = false).
258 #b1; #b2; #b3; #b4; #b5;
265 ##[ ##1: #H; ndestruct (*napply (bool_destruct … H)*)
266 ##| ##17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32: #H; napply (or5_intro1 … H)
267 ##| ##9,10,11,12,13,14,15,16: #H; napply (or5_intro2 … H)
268 ##| ##5,6,7,8: #H; napply (or5_intro3 … H)
269 ##| ##3,4: #H; napply (or5_intro4 … H)
270 ##| ##2: #H; napply (or5_intro5 … H)
274 nlemma andb_false2_1 : ∀b.(false ⊗ b) = false.
275 #b; nnormalize; napply refl_eq. nqed.
276 nlemma andb_false2_2 : ∀b.(b ⊗ false) = false.
277 #b; nelim b; nnormalize; napply refl_eq. nqed.
279 nlemma andb_false3_1 : ∀b1,b2.(false ⊗ b1 ⊗ b2) = false.
280 #b1; #b2; nnormalize; napply refl_eq. nqed.
281 nlemma andb_false3_2 : ∀b1,b2.(b1 ⊗ false ⊗ b2) = false.
282 #b1; #b2; nelim b1; nnormalize; napply refl_eq. nqed.
283 nlemma andb_false3_3 : ∀b1,b2.(b1 ⊗ b2 ⊗ false) = false.
284 #b1; #b2; nelim b1; nelim b2; nnormalize; napply refl_eq. nqed.
286 nlemma andb_false4_1 : ∀b1,b2,b3.(false ⊗ b1 ⊗ b2 ⊗ b3) = false.
287 #b1; #b2; #b3; nnormalize; napply refl_eq. nqed.
288 nlemma andb_false4_2 : ∀b1,b2,b3.(b1 ⊗ false ⊗ b2 ⊗ b3) = false.
289 #b1; #b2; #b3; nelim b1; nnormalize; napply refl_eq. nqed.
290 nlemma andb_false4_3 : ∀b1,b2,b3.(b1 ⊗ b2 ⊗ false ⊗ b3) = false.
291 #b1; #b2; #b3; nelim b1; nelim b2; nnormalize; napply refl_eq. nqed.
292 nlemma andb_false4_4 : ∀b1,b2,b3.(b1 ⊗ b2 ⊗ b3 ⊗ false) = false.
293 #b1; #b2; #b3; nelim b1; nelim b2; nelim b3; nnormalize; napply refl_eq. nqed.
295 nlemma andb_false5_1 : ∀b1,b2,b3,b4.(false ⊗ b1 ⊗ b2 ⊗ b3 ⊗ b4) = false.
296 #b1; #b2; #b3; #b4; nnormalize; napply refl_eq. nqed.
297 nlemma andb_false5_2 : ∀b1,b2,b3,b4.(b1 ⊗ false ⊗ b2 ⊗ b3 ⊗ b4) = false.
298 #b1; #b2; #b3; #b4; nelim b1; nnormalize; napply refl_eq. nqed.
299 nlemma andb_false5_3 : ∀b1,b2,b3,b4.(b1 ⊗ b2 ⊗ false ⊗ b3 ⊗ b4) = false.
300 #b1; #b2; #b3; #b4; nelim b1; nelim b2; nnormalize; napply refl_eq. nqed.
301 nlemma andb_false5_4 : ∀b1,b2,b3,b4.(b1 ⊗ b2 ⊗ b3 ⊗ false ⊗ b4) = false.
302 #b1; #b2; #b3; #b4; nelim b1; nelim b2; nelim b3; nnormalize; napply refl_eq. nqed.
303 nlemma andb_false5_5 : ∀b1,b2,b3,b4.(b1 ⊗ b2 ⊗ b3 ⊗ b4 ⊗ false) = false.
304 #b1; #b2; #b3; #b4; nelim b1; nelim b2; nelim b3; nelim b4; nnormalize; napply refl_eq. nqed.
306 nlemma orb_false_false_l : ∀b1,b2:bool.(b1 ⊕ b2) = false → b1 = false.
311 ##[ ##4: #H; napply refl_eq
312 ##| ##*: #H; ndestruct (*napply (bool_destruct … H)*)
316 nlemma orb_false_false_r : ∀b1,b2:bool.(b1 ⊕ b2) = false → b2 = false.
321 ##[ ##4: #H; napply refl_eq
322 ##| ##*: #H; ndestruct (*napply (bool_destruct … H)*)