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 "num/byte8.ma".
24 include "num/exadecim_lemmas.ma".
30 nlemma byte8_destruct_1 :
32 mk_byte8 x1 y1 = mk_byte8 x2 y2 → x1 = x2.
33 #x1; #x2; #y1; #y2; #H;
34 nchange with (match mk_byte8 x2 y2 with [ mk_byte8 a _ ⇒ x1 = a ]);
40 nlemma byte8_destruct_2 :
42 mk_byte8 x1 y1 = mk_byte8 x2 y2 → y1 = y2.
43 #x1; #x2; #y1; #y2; #H;
44 nchange with (match mk_byte8 x2 y2 with [ mk_byte8 _ b ⇒ y1 = b ]);
50 nlemma symmetric_eqb8 : symmetricT byte8 bool eq_b8.
55 nchange with (((eq_ex e3 e1)⊗(eq_ex e4 e2)) = ((eq_ex e1 e3)⊗(eq_ex e2 e4)));
56 nrewrite > (symmetric_eqex e1 e3);
57 nrewrite > (symmetric_eqex e2 e4);
61 nlemma symmetric_andb8 : symmetricT byte8 byte8 and_b8.
66 nchange with ((mk_byte8 (and_ex e3 e1) (and_ex e4 e2)) = (mk_byte8 (and_ex e1 e3) (and_ex e2 e4)));
67 nrewrite > (symmetric_andex e1 e3);
68 nrewrite > (symmetric_andex e2 e4);
72 nlemma associative_andb8 : ∀b1,b2,b3.(and_b8 (and_b8 b1 b2) b3) = (and_b8 b1 (and_b8 b2 b3)).
80 nchange with (mk_byte8 (and_ex (and_ex e1 e3) e5) (and_ex (and_ex e2 e4) e6) =
81 mk_byte8 (and_ex e1 (and_ex e3 e5)) (and_ex e2 (and_ex e4 e6)));
82 nrewrite < (associative_andex e1 e3 e5);
83 nrewrite < (associative_andex e2 e4 e6);
87 nlemma symmetric_orb8 : symmetricT byte8 byte8 or_b8.
92 nchange with ((mk_byte8 (or_ex e3 e1) (or_ex e4 e2)) = (mk_byte8 (or_ex e1 e3) (or_ex e2 e4)));
93 nrewrite > (symmetric_orex e1 e3);
94 nrewrite > (symmetric_orex e2 e4);
98 nlemma associative_orb8 : ∀b1,b2,b3.(or_b8 (or_b8 b1 b2) b3) = (or_b8 b1 (or_b8 b2 b3)).
106 nchange with (mk_byte8 (or_ex (or_ex e1 e3) e5) (or_ex (or_ex e2 e4) e6) =
107 mk_byte8 (or_ex e1 (or_ex e3 e5)) (or_ex e2 (or_ex e4 e6)));
108 nrewrite < (associative_orex e1 e3 e5);
109 nrewrite < (associative_orex e2 e4 e6);
113 nlemma symmetric_xorb8 : symmetricT byte8 byte8 xor_b8.
118 nchange with ((mk_byte8 (xor_ex e3 e1) (xor_ex e4 e2)) = (mk_byte8 (xor_ex e1 e3) (xor_ex e2 e4)));
119 nrewrite > (symmetric_xorex e1 e3);
120 nrewrite > (symmetric_xorex e2 e4);
124 nlemma associative_xorb8 : ∀b1,b2,b3.(xor_b8 (xor_b8 b1 b2) b3) = (xor_b8 b1 (xor_b8 b2 b3)).
132 nchange with (mk_byte8 (xor_ex (xor_ex e1 e3) e5) (xor_ex (xor_ex e2 e4) e6) =
133 mk_byte8 (xor_ex e1 (xor_ex e3 e5)) (xor_ex e2 (xor_ex e4 e6)));
134 nrewrite < (associative_xorex e1 e3 e5);
135 nrewrite < (associative_xorex e2 e4 e6);
139 nlemma symmetric_plusb8_dc_dc : ∀b1,b2,c.plus_b8_dc_dc b1 b2 c = plus_b8_dc_dc b2 b1 c.
146 match plus_ex_dc_dc e2 e4 c with
147 [ pair l c ⇒ match plus_ex_dc_dc e1 e3 c with
148 [ pair h c' ⇒ pair … 〈h,l〉 c' ]] =
149 match plus_ex_dc_dc e4 e2 c with
150 [ pair l c ⇒ match plus_ex_dc_dc e3 e1 c with
151 [ pair h c' ⇒ pair … 〈h,l〉 c' ]]);
152 nrewrite > (symmetric_plusex_dc_dc e4 e2 c);
153 ncases (plus_ex_dc_dc e2 e4 c);
156 match plus_ex_dc_dc e1 e3 c1 with
157 [ pair h c' ⇒ pair … 〈h,e5〉 c' ] =
158 match plus_ex_dc_dc e3 e1 c1 with
159 [ pair h c' ⇒ pair … 〈h,e5〉 c' ]);
160 nrewrite > (symmetric_plusex_dc_dc e1 e3 c1);
164 nlemma symmetric_plusb8_dc_d : ∀b1,b2,c.plus_b8_dc_d b1 b2 c = plus_b8_dc_d b2 b1 c.
171 match plus_ex_dc_dc e2 e4 c with
172 [ pair l c ⇒ 〈plus_ex_dc_d e1 e3 c,l〉 ] =
173 match plus_ex_dc_dc e4 e2 c with
174 [ pair l c ⇒ 〈plus_ex_dc_d e3 e1 c,l〉 ]);
175 nrewrite > (symmetric_plusex_dc_dc e4 e2 c);
176 ncases (plus_ex_dc_dc e2 e4 c);
178 nchange with (〈plus_ex_dc_d e1 e3 c1,e5〉 = 〈plus_ex_dc_d e3 e1 c1,e5〉);
179 nrewrite > (symmetric_plusex_dc_d e1 e3 c1);
183 nlemma symmetric_plusb8_dc_c : ∀b1,b2,c.plus_b8_dc_c b1 b2 c = plus_b8_dc_c b2 b1 c.
190 plus_ex_dc_c e1 e3 (plus_ex_dc_c e2 e4 c) =
191 plus_ex_dc_c e3 e1 (plus_ex_dc_c e4 e2 c));
192 nrewrite > (symmetric_plusex_dc_c e4 e2 c);
193 nrewrite > (symmetric_plusex_dc_c e3 e1 (plus_ex_dc_c e2 e4 c));
197 nlemma symmetric_plusb8_d_dc : ∀b1,b2.plus_b8_d_dc b1 b2 = plus_b8_d_dc b2 b1.
204 match plus_ex_d_dc e2 e4 with
205 [ pair l c ⇒ match plus_ex_dc_dc e1 e3 c with
206 [ pair h c' ⇒ pair … 〈h,l〉 c' ]] =
207 match plus_ex_d_dc e4 e2 with
208 [ pair l c ⇒ match plus_ex_dc_dc e3 e1 c with
209 [ pair h c' ⇒ pair … 〈h,l〉 c' ]]);
210 nrewrite > (symmetric_plusex_d_dc e4 e2);
211 ncases (plus_ex_d_dc e2 e4);
214 match plus_ex_dc_dc e1 e3 c with
215 [ pair h c' ⇒ pair … 〈h,e5〉 c' ] =
216 match plus_ex_dc_dc e3 e1 c with
217 [ pair h c' ⇒ pair … 〈h,e5〉 c' ]);
218 nrewrite > (symmetric_plusex_dc_dc e1 e3 c);
222 nlemma symmetric_plusb8_d_d : ∀b1,b2.plus_b8_d_d b1 b2 = plus_b8_d_d b2 b1.
229 match plus_ex_d_dc e2 e4 with
230 [ pair l c ⇒ 〈plus_ex_dc_d e1 e3 c,l〉 ] =
231 match plus_ex_d_dc e4 e2 with
232 [ pair l c ⇒ 〈plus_ex_dc_d e3 e1 c,l〉 ]);
233 nrewrite > (symmetric_plusex_d_dc e4 e2);
234 ncases (plus_ex_d_dc e2 e4);
236 nchange with (〈plus_ex_dc_d e1 e3 c,e5〉 = 〈plus_ex_dc_d e3 e1 c,e5〉);
237 nrewrite > (symmetric_plusex_dc_d e1 e3 c);
241 nlemma symmetric_plusb8_d_c : ∀b1,b2.plus_b8_d_c b1 b2 = plus_b8_d_c b2 b1.
248 plus_ex_dc_c e1 e3 (plus_ex_d_c e2 e4) =
249 plus_ex_dc_c e3 e1 (plus_ex_d_c e4 e2));
250 nrewrite > (symmetric_plusex_d_c e4 e2);
251 nrewrite > (symmetric_plusex_dc_c e3 e1 (plus_ex_d_c e2 e4));
255 nlemma symmetric_mulex : symmetricT exadecim byte8 mul_ex.
263 nlemma eqb8_to_eq : ∀b1,b2:byte8.(eq_b8 b1 b2 = true) → (b1 = b2).
268 nchange in ⊢ (% → ?) with (((eq_ex e3 e1)⊗(eq_ex e4 e2)) = true);
270 nrewrite < (eqex_to_eq … (andb_true_true_l … H));
271 nrewrite < (eqex_to_eq … (andb_true_true_r … H));
275 nlemma eq_to_eqb8 : ∀b1,b2.b1 = b2 → eq_b8 b1 b2 = true.
281 nrewrite < (byte8_destruct_1 … H);
282 nrewrite < (byte8_destruct_2 … H);
283 nchange with (((eq_ex e3 e3)⊗(eq_ex e4 e4)) = true);
284 nrewrite > (eq_to_eqex e3 e3 (refl_eq …));
285 nrewrite > (eq_to_eqex e4 e4 (refl_eq …));