]> matita.cs.unibo.it Git - helm.git/blob - helm/software/matita/contribs/ng_assembly/num/bool_lemmas.ma
freescle porting, work in progress
[helm.git] / helm / software / matita / contribs / ng_assembly / num / bool_lemmas.ma
1 (**************************************************************************)
2 (*       ___                                                              *)
3 (*      ||M||                                                             *)
4 (*      ||A||       A project by Andrea Asperti                           *)
5 (*      ||T||                                                             *)
6 (*      ||I||       Developers:                                           *)
7 (*      ||T||         The HELM team.                                      *)
8 (*      ||A||         http://helm.cs.unibo.it                             *)
9 (*      \   /                                                             *)
10 (*       \ /        This file is distributed under the terms of the       *)
11 (*        v         GNU General Public License Version 2                  *)
12 (*                                                                        *)
13 (**************************************************************************)
14
15 (* ********************************************************************** *)
16 (*                          Progetto FreeScale                            *)
17 (*                                                                        *)
18 (*   Sviluppato da: Cosimo Oliboni, oliboni@cs.unibo.it                   *)
19 (*     Cosimo Oliboni, oliboni@cs.unibo.it                                *)
20 (*                                                                        *)
21 (* ********************************************************************** *)
22
23 include "num/bool.ma".
24
25 (* ******** *)
26 (* BOOLEANI *)
27 (* ******** *)
28
29 ndefinition bool_destruct_aux ≝
30 Πb1,b2:bool.ΠP:Prop.b1 = b2 →
31  match b1 with
32   [ true ⇒ match b2 with [ true ⇒ P → P | false ⇒ P ]
33   | false ⇒ match b2 with [ true ⇒ P | false ⇒ P → P ]
34   ].
35
36 ndefinition bool_destruct : bool_destruct_aux.
37  #b1; #b2; #P;
38  nelim b1;
39  nelim b2;
40  nnormalize;
41  #H;
42  ##[ ##2: napply False_ind;
43           nchange with (match true with [ true ⇒ False | false ⇒ True]);
44           nrewrite > H;
45           nnormalize;
46           napply I
47  ##| ##3: napply False_ind;
48           nchange with (match true with [ true ⇒ False | false ⇒ True]);
49           nrewrite < H;
50           nnormalize;
51           napply I
52  ##| ##1,4: napply (λx:P.x)
53  ##]
54 nqed.
55
56 nlemma symmetric_eqbool : symmetricT bool bool eq_bool.
57  #b1; #b2;
58  nelim b1;
59  nelim b2;
60  nnormalize;
61  napply refl_eq.
62 nqed.
63
64 nlemma symmetric_andbool : symmetricT bool bool and_bool.
65  #b1; #b2;
66  nelim b1;
67  nelim b2;
68  nnormalize;
69  napply refl_eq.
70 nqed.
71
72 nlemma associative_andbool : ∀b1,b2,b3.((b1 ⊗ b2) ⊗ b3) = (b1 ⊗ (b2 ⊗ b3)).
73  #b1; #b2; #b3;
74  nelim b1;
75  nelim b2;
76  nelim b3;
77  nnormalize;
78  napply refl_eq.
79 nqed.
80
81 nlemma symmetric_orbool : symmetricT bool bool or_bool.
82  #b1; #b2;
83  nelim b1;
84  nelim b2;
85  nnormalize;
86  napply refl_eq.
87 nqed.
88
89 nlemma associative_orbool : ∀b1,b2,b3.((b1 ⊕ b2) ⊕ b3) = (b1 ⊕ (b2 ⊕ b3)).
90  #b1; #b2; #b3;
91  nelim b1;
92  nelim b2;
93  nelim b3;
94  nnormalize;
95  napply refl_eq.
96 nqed.
97
98 nlemma symmetric_xorbool : symmetricT bool bool xor_bool.
99  #b1; #b2;
100  nelim b1;
101  nelim b2;
102  nnormalize;
103  napply refl_eq.
104 nqed.
105
106 nlemma associative_xorbool : ∀b1,b2,b3.((b1 ⊙ b2) ⊙ b3) = (b1 ⊙ (b2 ⊙ b3)).
107  #b1; #b2; #b3;
108  nelim b1;
109  nelim b2;
110  nelim b3;
111  nnormalize;
112  napply refl_eq.
113 nqed.
114
115 nlemma eqbool_to_eq : ∀b1,b2:bool.(eq_bool b1 b2 = true) → (b1 = b2).
116  #b1; #b2;
117  ncases b1;
118  ncases b2;
119  nnormalize;
120  ##[ ##1,4: #H; napply refl_eq
121  ##| ##*: #H; napply (bool_destruct … H)
122  ##]
123 nqed.
124
125 nlemma eq_to_eqbool : ∀b1,b2.b1 = b2 → eq_bool b1 b2 = true.
126  #b1; #b2;
127  ncases b1;
128  ncases b2;
129  nnormalize;
130  ##[ ##1,4: #H; napply refl_eq
131  ##| ##*: #H; napply (bool_destruct … H)
132  ##]
133 nqed.
134
135 nlemma andb_true_true_l: ∀b1,b2.(b1 ⊗ b2) = true → b1 = true.
136  #b1; #b2;
137  ncases b1;
138  ncases b2;
139  nnormalize;
140  ##[ ##1,2: #H; napply refl_eq
141  ##| ##*: #H; napply (bool_destruct … H)
142  ##]
143 nqed.
144
145 nlemma andb_true_true_r: ∀b1,b2.(b1 ⊗ b2) = true → b2 = true.
146  #b1; #b2;
147  ncases b1;
148  ncases b2;
149  nnormalize;
150  ##[ ##1,3: #H; napply refl_eq
151  ##| ##*: #H; napply (bool_destruct … H)
152  ##]
153 nqed.
154
155 nlemma andb_false : ∀b1,b2.(b1 ⊗ b2) = false → (b1 = false) ∨ (b2 = false).
156  #b1; #b2;
157  ncases b1;
158  ncases b2;
159  nnormalize;
160  ##[ ##1: #H; napply (bool_destruct … H)
161  ##| ##2,4: #H; napply (or_intror … H)
162  ##| ##3: #H; napply (or_introl … H)
163  ##]
164 nqed.
165
166 nlemma orb_false_false_l : ∀b1,b2:bool.(b1 ⊕ b2) = false → b1 = false.
167  #b1; #b2;
168  ncases b1;
169  ncases b2;
170  nnormalize;
171  ##[ ##4: #H; napply refl_eq
172  ##| ##*: #H; napply (bool_destruct … H)
173  ##]
174 nqed.
175
176 nlemma orb_false_false_r : ∀b1,b2:bool.(b1 ⊕ b2) = false → b2 = false.
177  #b1; #b2;
178  ncases b1;
179  ncases b2;
180  nnormalize;
181  ##[ ##4: #H; napply refl_eq
182  ##| ##*: #H; napply (bool_destruct … H)
183  ##]
184 nqed.