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 *)
19 (* Cosimo Oliboni, oliboni@cs.unibo.it *)
21 (* Questo materiale fa parte della tesi: *)
22 (* "Formalizzazione Interattiva dei Microcontroller a 8bit FreeScale" *)
24 (* data ultima modifica 15/11/2007 *)
25 (* ********************************************************************** *)
27 include "freescale/exadecim_lemmas.ma".
28 include "freescale/byte8.ma".
34 nlemma byte8_destruct_1 :
36 mk_byte8 x1 y1 = mk_byte8 x2 y2 → x1 = x2.
37 #x1; #x2; #y1; #y2; #H;
38 nchange with (match mk_byte8 x2 y2 with [ mk_byte8 a _ ⇒ x1 = a ]);
44 nlemma byte8_destruct_2 :
46 mk_byte8 x1 y1 = mk_byte8 x2 y2 → y1 = y2.
47 #x1; #x2; #y1; #y2; #H;
48 nchange with (match mk_byte8 x2 y2 with [ mk_byte8 _ b ⇒ y1 = b ]);
54 nlemma symmetric_eqb8 : symmetricT byte8 bool eq_b8.
59 nchange with (((eq_ex e3 e1)⊗(eq_ex e4 e2)) = ((eq_ex e1 e3)⊗(eq_ex e2 e4)));
60 nrewrite > (symmetric_eqex e1 e3);
61 nrewrite > (symmetric_eqex e2 e4);
65 nlemma symmetric_andb8 : symmetricT byte8 byte8 and_b8.
70 nchange with ((mk_byte8 (and_ex e3 e1) (and_ex e4 e2)) = (mk_byte8 (and_ex e1 e3) (and_ex e2 e4)));
71 nrewrite > (symmetric_andex e1 e3);
72 nrewrite > (symmetric_andex e2 e4);
76 nlemma associative_andb8 : ∀b1,b2,b3.(and_b8 (and_b8 b1 b2) b3) = (and_b8 b1 (and_b8 b2 b3)).
84 nchange with (mk_byte8 (and_ex (and_ex e1 e3) e5) (and_ex (and_ex e2 e4) e6) =
85 mk_byte8 (and_ex e1 (and_ex e3 e5)) (and_ex e2 (and_ex e4 e6)));
86 nrewrite < (associative_andex e1 e3 e5);
87 nrewrite < (associative_andex e2 e4 e6);
91 nlemma symmetric_orb8 : symmetricT byte8 byte8 or_b8.
96 nchange with ((mk_byte8 (or_ex e3 e1) (or_ex e4 e2)) = (mk_byte8 (or_ex e1 e3) (or_ex e2 e4)));
97 nrewrite > (symmetric_orex e1 e3);
98 nrewrite > (symmetric_orex e2 e4);
102 nlemma associative_orb8 : ∀b1,b2,b3.(or_b8 (or_b8 b1 b2) b3) = (or_b8 b1 (or_b8 b2 b3)).
110 nchange with (mk_byte8 (or_ex (or_ex e1 e3) e5) (or_ex (or_ex e2 e4) e6) =
111 mk_byte8 (or_ex e1 (or_ex e3 e5)) (or_ex e2 (or_ex e4 e6)));
112 nrewrite < (associative_orex e1 e3 e5);
113 nrewrite < (associative_orex e2 e4 e6);
117 nlemma symmetric_xorb8 : symmetricT byte8 byte8 xor_b8.
122 nchange with ((mk_byte8 (xor_ex e3 e1) (xor_ex e4 e2)) = (mk_byte8 (xor_ex e1 e3) (xor_ex e2 e4)));
123 nrewrite > (symmetric_xorex e1 e3);
124 nrewrite > (symmetric_xorex e2 e4);
128 nlemma associative_xorb8 : ∀b1,b2,b3.(xor_b8 (xor_b8 b1 b2) b3) = (xor_b8 b1 (xor_b8 b2 b3)).
136 nchange with (mk_byte8 (xor_ex (xor_ex e1 e3) e5) (xor_ex (xor_ex e2 e4) e6) =
137 mk_byte8 (xor_ex e1 (xor_ex e3 e5)) (xor_ex e2 (xor_ex e4 e6)));
138 nrewrite < (associative_xorex e1 e3 e5);
139 nrewrite < (associative_xorex e2 e4 e6);
143 nlemma symmetric_plusb8_dc_dc : ∀b1,b2,c.plus_b8_dc_dc b1 b2 c = plus_b8_dc_dc b2 b1 c.
150 match plus_ex_dc_dc e2 e4 c with
151 [ pair l c ⇒ match plus_ex_dc_dc e1 e3 c with
152 [ pair h c' ⇒ pair ?? 〈h,l〉 c' ]] =
153 match plus_ex_dc_dc e4 e2 c with
154 [ pair l c ⇒ match plus_ex_dc_dc e3 e1 c with
155 [ pair h c' ⇒ pair ?? 〈h,l〉 c' ]]);
156 nrewrite > (symmetric_plusex_dc_dc e4 e2 c);
157 ncases (plus_ex_dc_dc e2 e4 c);
160 match plus_ex_dc_dc e1 e3 c1 with
161 [ pair h c' ⇒ pair ?? 〈h,e5〉 c' ] =
162 match plus_ex_dc_dc e3 e1 c1 with
163 [ pair h c' ⇒ pair ?? 〈h,e5〉 c' ]);
164 nrewrite > (symmetric_plusex_dc_dc e1 e3 c1);
168 nlemma symmetric_plusb8_dc_d : ∀b1,b2,c.plus_b8_dc_d b1 b2 c = plus_b8_dc_d b2 b1 c.
175 match plus_ex_dc_dc e2 e4 c with
176 [ pair l c ⇒ 〈plus_ex_dc_d e1 e3 c,l〉 ] =
177 match plus_ex_dc_dc e4 e2 c with
178 [ pair l c ⇒ 〈plus_ex_dc_d e3 e1 c,l〉 ]);
179 nrewrite > (symmetric_plusex_dc_dc e4 e2 c);
180 ncases (plus_ex_dc_dc e2 e4 c);
182 nchange with (〈plus_ex_dc_d e1 e3 c1,e5〉 = 〈plus_ex_dc_d e3 e1 c1,e5〉);
183 nrewrite > (symmetric_plusex_dc_d e1 e3 c1);
187 nlemma symmetric_plusb8_dc_c : ∀b1,b2,c.plus_b8_dc_c b1 b2 c = plus_b8_dc_c b2 b1 c.
194 plus_ex_dc_c e1 e3 (plus_ex_dc_c e2 e4 c) =
195 plus_ex_dc_c e3 e1 (plus_ex_dc_c e4 e2 c));
196 nrewrite > (symmetric_plusex_dc_c e4 e2 c);
197 nrewrite > (symmetric_plusex_dc_c e3 e1 (plus_ex_dc_c e2 e4 c));
201 nlemma symmetric_plusb8_d_dc : ∀b1,b2.plus_b8_d_dc b1 b2 = plus_b8_d_dc b2 b1.
208 match plus_ex_d_dc e2 e4 with
209 [ pair l c ⇒ match plus_ex_dc_dc e1 e3 c with
210 [ pair h c' ⇒ pair ?? 〈h,l〉 c' ]] =
211 match plus_ex_d_dc e4 e2 with
212 [ pair l c ⇒ match plus_ex_dc_dc e3 e1 c with
213 [ pair h c' ⇒ pair ?? 〈h,l〉 c' ]]);
214 nrewrite > (symmetric_plusex_d_dc e4 e2);
215 ncases (plus_ex_d_dc e2 e4);
218 match plus_ex_dc_dc e1 e3 c with
219 [ pair h c' ⇒ pair ?? 〈h,e5〉 c' ] =
220 match plus_ex_dc_dc e3 e1 c with
221 [ pair h c' ⇒ pair ?? 〈h,e5〉 c' ]);
222 nrewrite > (symmetric_plusex_dc_dc e1 e3 c);
226 nlemma symmetric_plusb8_d_d : ∀b1,b2.plus_b8_d_d b1 b2 = plus_b8_d_d b2 b1.
233 match plus_ex_d_dc e2 e4 with
234 [ pair l c ⇒ 〈plus_ex_dc_d e1 e3 c,l〉 ] =
235 match plus_ex_d_dc e4 e2 with
236 [ pair l c ⇒ 〈plus_ex_dc_d e3 e1 c,l〉 ]);
237 nrewrite > (symmetric_plusex_d_dc e4 e2);
238 ncases (plus_ex_d_dc e2 e4);
240 nchange with (〈plus_ex_dc_d e1 e3 c,e5〉 = 〈plus_ex_dc_d e3 e1 c,e5〉);
241 nrewrite > (symmetric_plusex_dc_d e1 e3 c);
245 nlemma symmetric_plusb8_d_c : ∀b1,b2.plus_b8_d_c b1 b2 = plus_b8_d_c b2 b1.
252 plus_ex_dc_c e1 e3 (plus_ex_d_c e2 e4) =
253 plus_ex_dc_c e3 e1 (plus_ex_d_c e4 e2));
254 nrewrite > (symmetric_plusex_d_c e4 e2);
255 nrewrite > (symmetric_plusex_dc_c e3 e1 (plus_ex_d_c e2 e4));
259 nlemma symmetric_mulex : symmetricT exadecim byte8 mul_ex.
267 nlemma eqb8_to_eq : ∀b1,b2:byte8.(eq_b8 b1 b2 = true) → (b1 = b2).
272 nchange in ⊢ (% → ?) with (((eq_ex e3 e1)⊗(eq_ex e4 e2)) = true);
274 nrewrite < (eqex_to_eq ?? (andb_true_true_l ?? H));
275 nrewrite < (eqex_to_eq ?? (andb_true_true_r ?? H));
279 nlemma eq_to_eqb8 : ∀b1,b2.b1 = b2 → eq_b8 b1 b2 = true.
285 nrewrite < (byte8_destruct_1 ???? H);
286 nrewrite < (byte8_destruct_2 ???? H);
287 nchange with (((eq_ex e3 e3)⊗(eq_ex e4 e4)) = true);
288 nrewrite > (eq_to_eqex e3 e3 (refl_eq ??));
289 nrewrite > (eq_to_eqex e4 e4 (refl_eq ??));