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".
24 include "common/comp.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.
42 nlemma symmetric_eqbool : symmetricT bool bool eq_bool.
50 nlemma symmetric_andbool : symmetricT bool bool and_bool.
58 nlemma associative_andbool : ∀b1,b2,b3.((b1 ⊗ b2) ⊗ b3) = (b1 ⊗ (b2 ⊗ b3)).
67 nlemma symmetric_orbool : symmetricT bool bool or_bool.
75 nlemma associative_orbool : ∀b1,b2,b3.((b1 ⊕ b2) ⊕ b3) = (b1 ⊕ (b2 ⊕ b3)).
84 nlemma symmetric_xorbool : symmetricT bool bool xor_bool.
92 nlemma associative_xorbool : ∀b1,b2,b3.((b1 ⊙ b2) ⊙ b3) = (b1 ⊙ (b2 ⊙ b3)).
101 nlemma eqbool_to_eq : ∀b1,b2:bool.(eq_bool b1 b2 = true) → (b1 = b2).
106 ##[ ##1,4: #H; napply refl_eq
107 ##| ##*: #H; ndestruct (*napply (bool_destruct … H)*)
111 nlemma eq_to_eqbool : ∀b1,b2.b1 = b2 → eq_bool b1 b2 = true.
116 ##[ ##1,4: #H; napply refl_eq
117 ##| ##*: #H; ndestruct (*napply (bool_destruct … H)*)
121 nlemma decidable_bool : ∀x,y:bool.decidable (x = y).
126 ##[ ##1,4: napply (or2_intro1 (? = ?) (? ≠ ?) …); napply refl_eq
127 ##| ##*: napply (or2_intro2 (? = ?) (? ≠ ?) …);
130 ndestruct (*napply (bool_destruct … H)*)
134 nlemma decidable_bexpr : ∀x.(x = true) ∨ (x = false).
136 ##[ ##1: napply (or2_intro1 (true = true) (true = false) (refl_eq …))
137 ##| ##2: napply (or2_intro2 (false = true) (false = false) (refl_eq …))
141 nlemma neqbool_to_neq : ∀b1,b2:bool.(eq_bool b1 b2 = false) → (b1 ≠ b2).
146 ##[ ##1,4: #H; ndestruct (*napply (bool_destruct … H)*)
147 ##| ##*: #H; #H1; ndestruct (*napply (bool_destruct … H1)*)
151 nlemma neq_to_neqbool : ∀b1,b2.b1 ≠ b2 → eq_bool b1 b2 = false.
156 ##[ ##1,4: #H; nelim (H (refl_eq …))
157 ##| ##*: #H; napply refl_eq
161 nlemma eqfalse_to_neqtrue : ∀x.x = false → x ≠ true.
163 ##[ ##1: #H; ndestruct (*napply (bool_destruct … H)*)
164 ##| ##2: #H; nnormalize; #H1; ndestruct (*napply (bool_destruct … H1)*)
168 nlemma eqtrue_to_neqfalse : ∀x.x = true → x ≠ false.
170 ##[ ##1: #H; nnormalize; #H1; ndestruct (*napply (bool_destruct … H1)*)
171 ##| ##2: #H; ndestruct (*napply (bool_destruct … H)*)
175 nlemma neqfalse_to_eqtrue : ∀x.x ≠ false → x = true.
177 ##[ ##1: #H; napply refl_eq
178 ##| ##2: nnormalize; #H; nelim (H (refl_eq …))
182 nlemma neqtrue_to_eqfalse : ∀x.x ≠ true → x = false.
184 ##[ ##1: nnormalize; #H; nelim (H (refl_eq …))
185 ##| ##2: #H; napply refl_eq
189 nlemma andb_true_true_l: ∀b1,b2.(b1 ⊗ b2) = true → b1 = true.
194 ##[ ##1,2: #H; napply refl_eq
195 ##| ##*: #H; ndestruct (*napply (bool_destruct … H)*)
199 nlemma andb_true_true_r: ∀b1,b2.(b1 ⊗ b2) = true → b2 = true.
204 ##[ ##1,3: #H; napply refl_eq
205 ##| ##*: #H; ndestruct (*napply (bool_destruct … H)*)
210 : ∀b1,b2.(b1 ⊗ b2) = false →
211 (b1 = false) ∨ (b2 = false).
216 ##[ ##1: #H; ndestruct (*napply (bool_destruct … H)*)
217 ##| ##2,4: #H; napply (or2_intro2 … H)
218 ##| ##3: #H; napply (or2_intro1 … H)
223 : ∀b1,b2,b3.(b1 ⊗ b2 ⊗ b3) = false →
224 Or3 (b1 = false) (b2 = false) (b3 = false).
230 ##[ ##1: #H; ndestruct (*napply (bool_destruct … H)*)
231 ##| ##5,6,7,8: #H; napply (or3_intro1 … H)
232 ##| ##2,4: #H; napply (or3_intro3 … H)
233 ##| ##3: #H; napply (or3_intro2 … H)
238 : ∀b1,b2,b3,b4.(b1 ⊗ b2 ⊗ b3 ⊗ b4) = false →
239 Or4 (b1 = false) (b2 = false) (b3 = false) (b4 = false).
246 ##[ ##1: #H; ndestruct (*napply (bool_destruct … H)*)
247 ##| ##9,10,11,12,13,14,15,16: #H; napply (or4_intro1 … H)
248 ##| ##5,6,7,8: #H; napply (or4_intro2 … H)
249 ##| ##3,4: #H; napply (or4_intro3 … H)
250 ##| ##2: #H; napply (or4_intro4 … H)
255 : ∀b1,b2,b3,b4,b5.(b1 ⊗ b2 ⊗ b3 ⊗ b4 ⊗ b5) = false →
256 Or5 (b1 = false) (b2 = false) (b3 = false) (b4 = false) (b5 = false).
257 #b1; #b2; #b3; #b4; #b5;
264 ##[ ##1: #H; ndestruct (*napply (bool_destruct … H)*)
265 ##| ##17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32: #H; napply (or5_intro1 … H)
266 ##| ##9,10,11,12,13,14,15,16: #H; napply (or5_intro2 … H)
267 ##| ##5,6,7,8: #H; napply (or5_intro3 … H)
268 ##| ##3,4: #H; napply (or5_intro4 … H)
269 ##| ##2: #H; napply (or5_intro5 … H)
273 nlemma andb_false2_1 : ∀b.(false ⊗ b) = false.
274 #b; nnormalize; napply refl_eq. nqed.
275 nlemma andb_false2_2 : ∀b.(b ⊗ false) = false.
276 #b; nelim b; nnormalize; napply refl_eq. nqed.
278 nlemma andb_false3_1 : ∀b1,b2.(false ⊗ b1 ⊗ b2) = false.
279 #b1; #b2; nnormalize; napply refl_eq. nqed.
280 nlemma andb_false3_2 : ∀b1,b2.(b1 ⊗ false ⊗ b2) = false.
281 #b1; #b2; nelim b1; nnormalize; napply refl_eq. nqed.
282 nlemma andb_false3_3 : ∀b1,b2.(b1 ⊗ b2 ⊗ false) = false.
283 #b1; #b2; nelim b1; nelim b2; nnormalize; napply refl_eq. nqed.
285 nlemma andb_false4_1 : ∀b1,b2,b3.(false ⊗ b1 ⊗ b2 ⊗ b3) = false.
286 #b1; #b2; #b3; nnormalize; napply refl_eq. nqed.
287 nlemma andb_false4_2 : ∀b1,b2,b3.(b1 ⊗ false ⊗ b2 ⊗ b3) = false.
288 #b1; #b2; #b3; nelim b1; nnormalize; napply refl_eq. nqed.
289 nlemma andb_false4_3 : ∀b1,b2,b3.(b1 ⊗ b2 ⊗ false ⊗ b3) = false.
290 #b1; #b2; #b3; nelim b1; nelim b2; nnormalize; napply refl_eq. nqed.
291 nlemma andb_false4_4 : ∀b1,b2,b3.(b1 ⊗ b2 ⊗ b3 ⊗ false) = false.
292 #b1; #b2; #b3; nelim b1; nelim b2; nelim b3; nnormalize; napply refl_eq. nqed.
294 nlemma andb_false5_1 : ∀b1,b2,b3,b4.(false ⊗ b1 ⊗ b2 ⊗ b3 ⊗ b4) = false.
295 #b1; #b2; #b3; #b4; nnormalize; napply refl_eq. nqed.
296 nlemma andb_false5_2 : ∀b1,b2,b3,b4.(b1 ⊗ false ⊗ b2 ⊗ b3 ⊗ b4) = false.
297 #b1; #b2; #b3; #b4; nelim b1; nnormalize; napply refl_eq. nqed.
298 nlemma andb_false5_3 : ∀b1,b2,b3,b4.(b1 ⊗ b2 ⊗ false ⊗ b3 ⊗ b4) = false.
299 #b1; #b2; #b3; #b4; nelim b1; nelim b2; nnormalize; napply refl_eq. nqed.
300 nlemma andb_false5_4 : ∀b1,b2,b3,b4.(b1 ⊗ b2 ⊗ b3 ⊗ false ⊗ b4) = false.
301 #b1; #b2; #b3; #b4; nelim b1; nelim b2; nelim b3; nnormalize; napply refl_eq. nqed.
302 nlemma andb_false5_5 : ∀b1,b2,b3,b4.(b1 ⊗ b2 ⊗ b3 ⊗ b4 ⊗ false) = false.
303 #b1; #b2; #b3; #b4; nelim b1; nelim b2; nelim b3; nelim b4; nnormalize; napply refl_eq. nqed.
305 nlemma orb_false_false_l : ∀b1,b2:bool.(b1 ⊕ b2) = false → b1 = false.
310 ##[ ##4: #H; napply refl_eq
311 ##| ##*: #H; ndestruct (*napply (bool_destruct … H)*)
315 nlemma orb_false_false_r : ∀b1,b2:bool.(b1 ⊕ b2) = false → b2 = false.
320 ##[ ##4: #H; napply refl_eq
321 ##| ##*: #H; ndestruct (*napply (bool_destruct … H)*)
325 nlemma bool_is_comparable : comparable.
328 ##| napply forall_bool
330 ##| napply eqbool_to_eq
331 ##| napply eq_to_eqbool
332 ##| napply neqbool_to_neq
333 ##| napply neq_to_neqbool
334 ##| napply decidable_bool
335 ##| napply symmetric_eqbool
339 unification hint 0 ≔ ⊢ carr bool_is_comparable ≡ bool.