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: Cosimo Oliboni, oliboni@cs.unibo.it *)
19 (* Cosimo Oliboni, oliboni@cs.unibo.it *)
21 (* ********************************************************************** *)
23 include "freescale/word16_lemmas.ma".
24 include "freescale/word32.ma".
30 nlemma word32_destruct_1 :
32 mk_word32 x1 y1 = mk_word32 x2 y2 → x1 = x2.
33 #x1; #x2; #y1; #y2; #H;
34 nchange with (match mk_word32 x2 y2 with [ mk_word32 a _ ⇒ x1 = a ]);
40 nlemma word32_destruct_2 :
42 mk_word32 x1 y1 = mk_word32 x2 y2 → y1 = y2.
43 #x1; #x2; #y1; #y2; #H;
44 nchange with (match mk_word32 x2 y2 with [ mk_word32 _ b ⇒ y1 = b ]);
50 nlemma symmetric_eqw32 : symmetricT word32 bool eq_w32.
55 nchange with (((eq_w16 w3 w1)⊗(eq_w16 w4 w2)) = ((eq_w16 w1 w3)⊗(eq_w16 w2 w4)));
56 nrewrite > (symmetric_eqw16 w1 w3);
57 nrewrite > (symmetric_eqw16 w2 w4);
61 nlemma symmetric_andw32 : symmetricT word32 word32 and_w32.
66 nchange with ((mk_word32 (and_w16 w3 w1) (and_w16 w4 w2)) = (mk_word32 (and_w16 w1 w3) (and_w16 w2 w4)));
67 nrewrite > (symmetric_andw16 w1 w3);
68 nrewrite > (symmetric_andw16 w2 w4);
72 nlemma associative_andw32 : ∀dw1,dw2,dw3.(and_w32 (and_w32 dw1 dw2) dw3) = (and_w32 dw1 (and_w32 dw2 dw3)).
80 nchange with (mk_word32 (and_w16 (and_w16 w1 w3) w5) (and_w16 (and_w16 w2 w4) w6) =
81 mk_word32 (and_w16 w1 (and_w16 w3 w5)) (and_w16 w2 (and_w16 w4 w6)));
82 nrewrite < (associative_andw16 w1 w3 w5);
83 nrewrite < (associative_andw16 w2 w4 w6);
87 nlemma symmetric_orw32 : symmetricT word32 word32 or_w32.
92 nchange with ((mk_word32 (or_w16 w3 w1) (or_w16 w4 w2)) = (mk_word32 (or_w16 w1 w3) (or_w16 w2 w4)));
93 nrewrite > (symmetric_orw16 w1 w3);
94 nrewrite > (symmetric_orw16 w2 w4);
98 nlemma associative_orw32 : ∀dw1,dw2,dw3.(or_w32 (or_w32 dw1 dw2) dw3) = (or_w32 dw1 (or_w32 dw2 dw3)).
106 nchange with (mk_word32 (or_w16 (or_w16 w1 w3) w5) (or_w16 (or_w16 w2 w4) w6) =
107 mk_word32 (or_w16 w1 (or_w16 w3 w5)) (or_w16 w2 (or_w16 w4 w6)));
108 nrewrite < (associative_orw16 w1 w3 w5);
109 nrewrite < (associative_orw16 w2 w4 w6);
113 nlemma symmetric_xorw32 : symmetricT word32 word32 xor_w32.
118 nchange with ((mk_word32 (xor_w16 w3 w1) (xor_w16 w4 w2)) = (mk_word32 (xor_w16 w1 w3) (xor_w16 w2 w4)));
119 nrewrite > (symmetric_xorw16 w1 w3);
120 nrewrite > (symmetric_xorw16 w2 w4);
124 nlemma associative_xorw32 : ∀dw1,dw2,dw3.(xor_w32 (xor_w32 dw1 dw2) dw3) = (xor_w32 dw1 (xor_w32 dw2 dw3)).
132 nchange with (mk_word32 (xor_w16 (xor_w16 w1 w3) w5) (xor_w16 (xor_w16 w2 w4) w6) =
133 mk_word32 (xor_w16 w1 (xor_w16 w3 w5)) (xor_w16 w2 (xor_w16 w4 w6)));
134 nrewrite < (associative_xorw16 w1 w3 w5);
135 nrewrite < (associative_xorw16 w2 w4 w6);
139 nlemma symmetric_plusw32_dc_dc : ∀dw1,dw2,c.plus_w32_dc_dc dw1 dw2 c = plus_w32_dc_dc dw2 dw1 c.
146 match plus_w16_dc_dc w2 w4 c with
147 [ pair l c ⇒ match plus_w16_dc_dc w1 w3 c with
148 [ pair h c' ⇒ pair ?? 〈h.l〉 c' ]] =
149 match plus_w16_dc_dc w4 w2 c with
150 [ pair l c ⇒ match plus_w16_dc_dc w3 w1 c with
151 [ pair h c' ⇒ pair ?? 〈h.l〉 c' ]]);
152 nrewrite > (symmetric_plusw16_dc_dc w4 w2 c);
153 ncases (plus_w16_dc_dc w2 w4 c);
156 match plus_w16_dc_dc w1 w3 c1 with
157 [ pair h c' ⇒ pair ?? 〈h.w5〉 c' ] =
158 match plus_w16_dc_dc w3 w1 c1 with
159 [ pair h c' ⇒ pair ?? 〈h.w5〉 c' ]);
160 nrewrite > (symmetric_plusw16_dc_dc w1 w3 c1);
164 nlemma symmetric_plusw32_dc_d : ∀dw1,dw2,c.plus_w32_dc_d dw1 dw2 c = plus_w32_dc_d dw2 dw1 c.
171 match plus_w16_dc_dc w2 w4 c with
172 [ pair l c ⇒ 〈plus_w16_dc_d w1 w3 c.l〉 ] =
173 match plus_w16_dc_dc w4 w2 c with
174 [ pair l c ⇒ 〈plus_w16_dc_d w3 w1 c.l〉 ]);
175 nrewrite > (symmetric_plusw16_dc_dc w4 w2 c);
176 ncases (plus_w16_dc_dc w2 w4 c);
178 nchange with (〈plus_w16_dc_d w1 w3 c1.w5〉 = 〈plus_w16_dc_d w3 w1 c1.w5〉);
179 nrewrite > (symmetric_plusw16_dc_d w1 w3 c1);
183 nlemma symmetric_plusw32_dc_c : ∀dw1,dw2,c.plus_w32_dc_c dw1 dw2 c = plus_w32_dc_c dw2 dw1 c.
190 plus_w16_dc_c w1 w3 (plus_w16_dc_c w2 w4 c) =
191 plus_w16_dc_c w3 w1 (plus_w16_dc_c w4 w2 c));
192 nrewrite > (symmetric_plusw16_dc_c w4 w2 c);
193 nrewrite > (symmetric_plusw16_dc_c w3 w1 (plus_w16_dc_c w2 w4 c));
197 nlemma symmetric_plusw32_d_dc : ∀dw1,dw2.plus_w32_d_dc dw1 dw2 = plus_w32_d_dc dw2 dw1.
204 match plus_w16_d_dc w2 w4 with
205 [ pair l c ⇒ match plus_w16_dc_dc w1 w3 c with
206 [ pair h c' ⇒ pair ?? 〈h.l〉 c' ]] =
207 match plus_w16_d_dc w4 w2 with
208 [ pair l c ⇒ match plus_w16_dc_dc w3 w1 c with
209 [ pair h c' ⇒ pair ?? 〈h.l〉 c' ]]);
210 nrewrite > (symmetric_plusw16_d_dc w4 w2);
211 ncases (plus_w16_d_dc w2 w4);
214 match plus_w16_dc_dc w1 w3 c with
215 [ pair h c' ⇒ pair ?? 〈h.w5〉 c' ] =
216 match plus_w16_dc_dc w3 w1 c with
217 [ pair h c' ⇒ pair ?? 〈h.w5〉 c' ]);
218 nrewrite > (symmetric_plusw16_dc_dc w1 w3 c);
222 nlemma symmetric_plusw32_d_d : ∀dw1,dw2.plus_w32_d_d dw1 dw2 = plus_w32_d_d dw2 dw1.
229 match plus_w16_d_dc w2 w4 with
230 [ pair l c ⇒ 〈plus_w16_dc_d w1 w3 c.l〉 ] =
231 match plus_w16_d_dc w4 w2 with
232 [ pair l c ⇒ 〈plus_w16_dc_d w3 w1 c.l〉 ]);
233 nrewrite > (symmetric_plusw16_d_dc w4 w2);
234 ncases (plus_w16_d_dc w2 w4);
236 nchange with (〈plus_w16_dc_d w1 w3 c.w5〉 = 〈plus_w16_dc_d w3 w1 c.w5〉);
237 nrewrite > (symmetric_plusw16_dc_d w1 w3 c);
241 nlemma symmetric_plusw32_d_c : ∀dw1,dw2.plus_w32_d_c dw1 dw2 = plus_w32_d_c dw2 dw1.
248 plus_w16_dc_c w1 w3 (plus_w16_d_c w2 w4) =
249 plus_w16_dc_c w3 w1 (plus_w16_d_c w4 w2));
250 nrewrite > (symmetric_plusw16_d_c w4 w2);
251 nrewrite > (symmetric_plusw16_dc_c w3 w1 (plus_w16_d_c w2 w4));
255 nlemma symmetric_mulw16 : symmetricT word16 word32 mul_w16.
261 nchange with (match mul_b8 b2 b4 with
262 [ mk_word16 t1_h t1_l ⇒ match mul_b8 b1 b4 with
263 [ mk_word16 t2_h t2_l ⇒ match mul_b8 b3 b2 with
264 [ mk_word16 t3_h t3_l ⇒ match mul_b8 b1 b3 with
265 [ mk_word16 t4_h t4_l ⇒ plus_w32_d_d (plus_w32_d_d (plus_w32_d_d 〈〈〈x0,x0〉:t3_h〉.〈t3_l:〈x0,x0〉〉〉 〈〈〈x0,x0〉:t2_h〉.〈t2_l:〈x0,x0〉〉〉) 〈〈t4_h:t4_l〉.〈〈x0,x0〉:〈x0,x0〉〉〉)〈〈〈x0,x0〉:〈x0,x0〉〉.〈t1_h:t1_l〉〉
266 ]]]] = match mul_b8 b4 b2 with
267 [ mk_word16 t1_h t1_l ⇒ match mul_b8 b3 b2 with
268 [ mk_word16 t2_h t2_l ⇒ match mul_b8 b1 b4 with
269 [ mk_word16 t3_h t3_l ⇒ match mul_b8 b3 b1 with
270 [ mk_word16 t4_h t4_l ⇒ plus_w32_d_d (plus_w32_d_d (plus_w32_d_d 〈〈〈x0,x0〉:t3_h〉.〈t3_l:〈x0,x0〉〉〉 〈〈〈x0,x0〉:t2_h〉.〈t2_l:〈x0,x0〉〉〉) 〈〈t4_h:t4_l〉.〈〈x0,x0〉:〈x0,x0〉〉〉)〈〈〈x0,x0〉:〈x0,x0〉〉.〈t1_h:t1_l〉〉
272 nrewrite < (symmetric_mulb8 b2 b4);
273 ncases (mul_b8 b2 b4);
275 nchange with (match mul_b8 b1 b4 with
276 [ mk_word16 t2_h t2_l ⇒ match mul_b8 b3 b2 with
277 [ mk_word16 t3_h t3_l ⇒ match mul_b8 b1 b3 with
278 [ mk_word16 t4_h t4_l ⇒ plus_w32_d_d (plus_w32_d_d (plus_w32_d_d 〈〈〈x0,x0〉:t3_h〉.〈t3_l:〈x0,x0〉〉〉 〈〈〈x0,x0〉:t2_h〉.〈t2_l:〈x0,x0〉〉〉) 〈〈t4_h:t4_l〉.〈〈x0,x0〉:〈x0,x0〉〉〉)〈〈〈x0,x0〉:〈x0,x0〉〉.〈b5:b6〉〉
279 ]]] = match mul_b8 b3 b2 with
280 [ mk_word16 t2_h t2_l ⇒ match mul_b8 b1 b4 with
281 [ mk_word16 t3_h t3_l ⇒ match mul_b8 b3 b1 with
282 [ mk_word16 t4_h t4_l ⇒ plus_w32_d_d (plus_w32_d_d (plus_w32_d_d 〈〈〈x0,x0〉:t3_h〉.〈t3_l:〈x0,x0〉〉〉 〈〈〈x0,x0〉:t2_h〉.〈t2_l:〈x0,x0〉〉〉) 〈〈t4_h:t4_l〉.〈〈x0,x0〉:〈x0,x0〉〉〉)〈〈〈x0,x0〉:〈x0,x0〉〉.〈b5:b6〉〉
284 ncases (mul_b8 b3 b2);
286 ncases (mul_b8 b1 b4);
288 nchange with (match mul_b8 b1 b3 with
289 [ mk_word16 t4_h t4_l ⇒ plus_w32_d_d (plus_w32_d_d (plus_w32_d_d 〈〈〈x0,x0〉:b7〉.〈b8:〈x0,x0〉〉〉 〈〈〈x0,x0〉:b9〉.〈b10:〈x0,x0〉〉〉) 〈〈t4_h:t4_l〉.〈〈x0,x0〉:〈x0,x0〉〉〉)〈〈〈x0,x0〉:〈x0,x0〉〉.〈b5:b6〉〉
290 ] = match mul_b8 b3 b1 with
291 [ mk_word16 t4_h t4_l ⇒ plus_w32_d_d (plus_w32_d_d (plus_w32_d_d 〈〈〈x0,x0〉:b9〉.〈b10:〈x0,x0〉〉〉 〈〈〈x0,x0〉:b7〉.〈b8:〈x0,x0〉〉〉) 〈〈t4_h:t4_l〉.〈〈x0,x0〉:〈x0,x0〉〉〉)〈〈〈x0,x0〉:〈x0,x0〉〉.〈b5:b6〉〉
293 nrewrite < (symmetric_mulb8 b1 b3);
294 ncases (mul_b8 b1 b3);
296 nchange with ((plus_w32_d_d (plus_w32_d_d (plus_w32_d_d 〈〈〈x0,x0〉:b7〉.〈b8:〈x0,x0〉〉〉 〈〈〈x0,x0〉:b9〉.〈b10:〈x0,x0〉〉〉) 〈〈b11:b12〉.〈〈x0,x0〉:〈x0,x0〉〉〉)〈〈〈x0,x0〉:〈x0,x0〉〉.〈b5:b6〉〉) =
297 (plus_w32_d_d (plus_w32_d_d (plus_w32_d_d 〈〈〈x0,x0〉:b9〉.〈b10:〈x0,x0〉〉〉 〈〈〈x0,x0〉:b7〉.〈b8:〈x0,x0〉〉〉) 〈〈b11:b12〉.〈〈x0,x0〉:〈x0,x0〉〉〉)〈〈〈x0,x0〉:〈x0,x0〉〉.〈b5:b6〉〉));
298 nrewrite > (symmetric_plusw32_d_d 〈〈〈x0,x0〉:b7〉.〈b8:〈x0,x0〉〉〉 〈〈〈x0,x0〉:b9〉.〈b10:〈x0,x0〉〉〉);
302 nlemma eqw32_to_eq : ∀dw1,dw2:word32.(eq_w32 dw1 dw2 = true) → (dw1 = dw2).
307 nchange in ⊢ (% → ?) with (((eq_w16 w3 w1)⊗(eq_w16 w4 w2)) = true);
309 nrewrite < (eqw16_to_eq ?? (andb_true_true_l ?? H));
310 nrewrite < (eqw16_to_eq ?? (andb_true_true_r ?? H));
314 nlemma eq_to_eqw32 : ∀dw1,dw2.dw1 = dw2 → eq_w32 dw1 dw2 = true.
320 nrewrite < (word32_destruct_1 ???? H);
321 nrewrite < (word32_destruct_2 ???? H);
322 nchange with (((eq_w16 w3 w3)⊗(eq_w16 w4 w4)) = true);
323 nrewrite > (eq_to_eqw16 w3 w3 (refl_eq ??));
324 nrewrite > (eq_to_eqw16 w4 w4 (refl_eq ??));