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 (* Ultima modifica: 05/08/2009 *)
21 (* ********************************************************************** *)
23 include "num/byte8.ma".
29 nrecord word16 : Type ≝
36 notation "〈x:y〉" non associative with precedence 80
37 for @{ 'mk_word16 $x $y }.
38 interpretation "mk_word16" 'mk_word16 x y = (mk_word16 x y).
41 ndefinition eq_w16 ≝ λw1,w2.(eq_b8 (w16h w1) (w16h w2)) ⊗ (eq_b8 (w16l w1) (w16l w2)).
45 λw1,w2:word16.match lt_b8 (w16h w1) (w16h w2) with
47 | false ⇒ match gt_b8 (w16h w1) (w16h w2) with
49 | false ⇒ lt_b8 (w16l w1) (w16l w2) ]].
52 ndefinition le_w16 ≝ λw1,w2:word16.(eq_w16 w1 w2) ⊕ (lt_w16 w1 w2).
55 ndefinition gt_w16 ≝ λw1,w2:word16.⊖ (le_w16 w1 w2).
58 ndefinition ge_w16 ≝ λw1,w2:word16.⊖ (lt_w16 w1 w2).
62 λw1,w2:word16.mk_word16 (and_b8 (w16h w1) (w16h w2)) (and_b8 (w16l w1) (w16l w2)).
66 λw1,w2:word16.mk_word16 (or_b8 (w16h w1) (w16h w2)) (or_b8 (w16l w1) (w16l w2)).
70 λw1,w2:word16.mk_word16 (xor_b8 (w16h w1) (w16h w2)) (xor_b8 (w16l w1) (w16l w2)).
72 (* operatore rotazione destra con carry *)
74 λw:word16.λc:bool.match rcr_b8 (w16h w) c with
75 [ pair wh' c' ⇒ match rcr_b8 (w16l w) c' with
76 [ pair wl' c'' ⇒ pair … (mk_word16 wh' wl') c'' ]].
78 (* operatore shift destro *)
80 λw:word16.match rcr_b8 (w16h w) false with
81 [ pair wh' c' ⇒ match rcr_b8 (w16l w) c' with
82 [ pair wl' c'' ⇒ pair … (mk_word16 wh' wl') c'' ]].
84 (* operatore rotazione destra *)
86 λw:word16.match rcr_b8 (w16h w) false with
87 [ pair wh' c' ⇒ match rcr_b8 (w16l w) c' with
88 [ pair wl' c'' ⇒ match c'' with
89 [ true ⇒ mk_word16 (or_b8 (mk_byte8 x8 x0) wh') wl'
90 | false ⇒ mk_word16 wh' wl' ]]].
92 (* operatore rotazione destra n-volte *)
93 nlet rec ror_w16_n (w:word16) (n:nat) on n ≝
96 | S n' ⇒ ror_w16_n (ror_w16 w) n' ].
98 (* operatore rotazione sinistra con carry *)
100 λw:word16.λc:bool.match rcl_b8 (w16l w) c with
101 [ pair wl' c' ⇒ match rcl_b8 (w16h w) c' with
102 [ pair wh' c'' ⇒ pair … (mk_word16 wh' wl') c'' ]].
104 (* operatore shift sinistro *)
105 ndefinition shl_w16 ≝
106 λw:word16.match rcl_b8 (w16l w) false with
107 [ pair wl' c' ⇒ match rcl_b8 (w16h w) c' with
108 [ pair wh' c'' ⇒ pair … (mk_word16 wh' wl') c'' ]].
110 (* operatore rotazione sinistra *)
111 ndefinition rol_w16 ≝
112 λw:word16.match rcl_b8 (w16l w) false with
113 [ pair wl' c' ⇒ match rcl_b8 (w16h w) c' with
114 [ pair wh' c'' ⇒ match c'' with
115 [ true ⇒ mk_word16 wh' (or_b8 (mk_byte8 x0 x1) wl')
116 | false ⇒ mk_word16 wh' wl' ]]].
118 (* operatore rotazione sinistra n-volte *)
119 nlet rec rol_w16_n (w:word16) (n:nat) on n ≝
122 | S n' ⇒ rol_w16_n (rol_w16 w) n' ].
124 (* operatore not/complemento a 1 *)
125 ndefinition not_w16 ≝
126 λw:word16.mk_word16 (not_b8 (w16h w)) (not_b8 (w16l w)).
128 (* operatore somma con data+carry → data+carry *)
129 ndefinition plus_w16_dc_dc ≝
130 λw1,w2:word16.λc:bool.
131 match plus_b8_dc_dc (w16l w1) (w16l w2) c with
132 [ pair l c ⇒ match plus_b8_dc_dc (w16h w1) (w16h w2) c with
133 [ pair h c' ⇒ pair … 〈h:l〉 c' ]].
135 (* operatore somma con data+carry → data *)
136 ndefinition plus_w16_dc_d ≝
137 λw1,w2:word16.λc:bool.
138 match plus_b8_dc_dc (w16l w1) (w16l w2) c with
139 [ pair l c ⇒ 〈plus_b8_dc_d (w16h w1) (w16h w2) c:l〉 ].
141 (* operatore somma con data+carry → c *)
142 ndefinition plus_w16_dc_c ≝
143 λw1,w2:word16.λc:bool.
144 plus_b8_dc_c (w16h w1) (w16h w2) (plus_b8_dc_c (w16l w1) (w16l w2) c).
146 (* operatore somma con data → data+carry *)
147 ndefinition plus_w16_d_dc ≝
149 match plus_b8_d_dc (w16l w1) (w16l w2) with
150 [ pair l c ⇒ match plus_b8_dc_dc (w16h w1) (w16h w2) c with
151 [ pair h c' ⇒ pair … 〈h:l〉 c' ]].
153 (* operatore somma con data → data *)
154 ndefinition plus_w16_d_d ≝
156 match plus_b8_d_dc (w16l w1) (w16l w2) with
157 [ pair l c ⇒ 〈plus_b8_dc_d (w16h w1) (w16h w2) c:l〉 ].
159 (* operatore somma con data → c *)
160 ndefinition plus_w16_d_c ≝
162 plus_b8_dc_c (w16h w1) (w16h w2) (plus_b8_d_c (w16l w1) (w16l w2)).
164 (* operatore Most Significant Bit *)
165 ndefinition MSB_w16 ≝ λw:word16.eq_ex x8 (and_ex x8 (b8h (w16h w))).
167 (* operatore predecessore *)
168 ndefinition pred_w16 ≝
169 λw:word16.match eq_b8 (w16l w) (mk_byte8 x0 x0) with
170 [ true ⇒ mk_word16 (pred_b8 (w16h w)) (pred_b8 (w16l w))
171 | false ⇒ mk_word16 (w16h w) (pred_b8 (w16l w)) ].
173 (* operatore successore *)
174 ndefinition succ_w16 ≝
175 λw:word16.match eq_b8 (w16l w) (mk_byte8 xF xF) with
176 [ true ⇒ mk_word16 (succ_b8 (w16h w)) (succ_b8 (w16l w))
177 | false ⇒ mk_word16 (w16h w) (succ_b8 (w16l w)) ].
179 (* operatore neg/complemento a 2 *)
180 ndefinition compl_w16 ≝
181 λw:word16.match MSB_w16 w with
182 [ true ⇒ succ_w16 (not_w16 w)
183 | false ⇒ not_w16 (pred_w16 w) ].
186 operatore moltiplicazione senza segno: b*b=[0x0000,0xFE01]
187 ... in pratica (〈a,b〉*〈c,d〉) = (a*c)<<8+(a*d)<<4+(b*c)<<4+(b*d)
190 λb1,b2:byte8.match b1 with
191 [ mk_byte8 b1h b1l ⇒ match b2 with
192 [ mk_byte8 b2h b2l ⇒ match mul_ex b1l b2l with
193 [ mk_byte8 t1_h t1_l ⇒ match mul_ex b1h b2l with
194 [ mk_byte8 t2_h t2_l ⇒ match mul_ex b2h b1l with
195 [ mk_byte8 t3_h t3_l ⇒ match mul_ex b1h b2h with
196 [ mk_byte8 t4_h t4_l ⇒
199 (plus_w16_d_d 〈〈x0,t3_h〉:〈t3_l,x0〉〉 〈〈x0,t2_h〉:〈t2_l,x0〉〉) 〈〈t4_h,t4_l〉:〈x0,x0〉〉)〈〈x0,x0〉:〈t1_h,t1_l〉〉
202 (* divisione senza segno (secondo la logica delle ALU): (quoziente resto) overflow *)
203 nlet rec div_b8_aux (divd:word16) (divs:word16) (molt:byte8) (q:byte8) (c:nat) on c ≝
204 let w' ≝ plus_w16_d_d divd (compl_w16 divs) in
206 [ O ⇒ match le_w16 divs divd with
207 [ true ⇒ triple … (or_b8 molt q) (w16l w') (⊖ (eq_b8 (w16h w') 〈x0,x0〉))
208 | false ⇒ triple … q (w16l divd) (⊖ (eq_b8 (w16h divd) 〈x0,x0〉)) ]
209 | S c' ⇒ match le_w16 divs divd with
210 [ true ⇒ div_b8_aux w' (ror_w16 divs) (ror_b8 molt) (or_b8 molt q) c'
211 | false ⇒ div_b8_aux divd (ror_w16 divs) (ror_b8 molt) q c' ]].
214 λw:word16.λb:byte8.match eq_b8 b 〈x0,x0〉 with
216 la combinazione n/0 e' illegale, segnala solo overflow senza dare risultato
218 [ true ⇒ triple … 〈xF,xF〉 (w16l w) true
219 | false ⇒ match eq_w16 w 〈〈x0,x0〉:〈x0,x0〉〉 with
220 (* 0 diviso qualsiasi cosa diverso da 0 da' q=0 r=0 o=false *)
221 [ true ⇒ triple … 〈x0,x0〉 〈x0,x0〉 false
222 (* 1) e' una divisione sensata che produrra' overflow/risultato *)
223 (* 2) parametri: dividendo, divisore, moltiplicatore, quoziente, contatore *)
224 (* 3) ad ogni ciclo il divisore e il moltiplicatore vengono scalati di 1 a dx *)
225 (* 4) il moltiplicatore e' la quantita' aggiunta al quoziente se il divisore *)
226 (* puo' essere sottratto al dividendo *)
227 | false ⇒ div_b8_aux w (rol_w16_n 〈〈x0,x0〉:b〉 7) 〈x8,x0〉 〈x0,x0〉 7 ]].
229 (* operatore x in [inf,sup] *)
230 ndefinition inrange_w16 ≝
231 λx,inf,sup:word16.(le_w16 inf sup) ⊗ (ge_w16 x inf) ⊗ (le_w16 x sup).
233 (* iteratore sulle word *)
234 ndefinition forall_w16 ≝
238 P (mk_word16 bh bl ))).
240 (* word16 ricorsive *)
241 ninductive rec_word16 : word16 → Type ≝
242 w16_O : rec_word16 〈〈x0,x0〉:〈x0,x0〉〉
243 | w16_S : ∀n.rec_word16 n → rec_word16 (succ_w16 n).
245 (* word16 → word16 ricorsive *)
246 ndefinition w16_to_recw16_aux1_1 : Πn.rec_word16 〈n:〈x0,x0〉〉 → rec_word16 〈n:〈x1,x0〉〉 ≝
247 λn.λrecw:rec_word16 〈n:〈x0,x0〉〉.
248 w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (
249 w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? recw
252 ndefinition w16_to_recw16_aux1_2 : Πn.rec_word16 〈n:〈x0,x0〉〉 → rec_word16 〈n:〈x2,x0〉〉 ≝
253 λn.λrecw:rec_word16 〈n:〈x0,x0〉〉.
254 w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (
255 w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_to_recw16_aux1_1 ? recw)
258 ndefinition w16_to_recw16_aux1_3 : Πn.rec_word16 〈n:〈x0,x0〉〉 → rec_word16 〈n:〈x3,x0〉〉 ≝
259 λn.λrecw:rec_word16 〈n:〈x0,x0〉〉.
260 w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (
261 w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_to_recw16_aux1_2 ? recw)
264 ndefinition w16_to_recw16_aux1_4 : Πn.rec_word16 〈n:〈x0,x0〉〉 → rec_word16 〈n:〈x4,x0〉〉 ≝
265 λn.λrecw:rec_word16 〈n:〈x0,x0〉〉.
266 w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (
267 w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_to_recw16_aux1_3 ? recw)
270 ndefinition w16_to_recw16_aux1_5 : Πn.rec_word16 〈n:〈x0,x0〉〉 → rec_word16 〈n:〈x5,x0〉〉 ≝
271 λn.λrecw:rec_word16 〈n:〈x0,x0〉〉.
272 w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (
273 w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_to_recw16_aux1_4 ? recw)
276 ndefinition w16_to_recw16_aux1_6 : Πn.rec_word16 〈n:〈x0,x0〉〉 → rec_word16 〈n:〈x6,x0〉〉 ≝
277 λn.λrecw:rec_word16 〈n:〈x0,x0〉〉.
278 w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (
279 w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_to_recw16_aux1_5 ? recw)
282 ndefinition w16_to_recw16_aux1_7 : Πn.rec_word16 〈n:〈x0,x0〉〉 → rec_word16 〈n:〈x7,x0〉〉 ≝
283 λn.λrecw:rec_word16 〈n:〈x0,x0〉〉.
284 w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (
285 w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_to_recw16_aux1_6 ? recw)
288 ndefinition w16_to_recw16_aux1_8 : Πn.rec_word16 〈n:〈x0,x0〉〉 → rec_word16 〈n:〈x8,x0〉〉 ≝
289 λn.λrecw:rec_word16 〈n:〈x0,x0〉〉.
290 w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (
291 w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_to_recw16_aux1_7 ? recw)
294 ndefinition w16_to_recw16_aux1_9 : Πn.rec_word16 〈n:〈x0,x0〉〉 → rec_word16 〈n:〈x9,x0〉〉 ≝
295 λn.λrecw:rec_word16 〈n:〈x0,x0〉〉.
296 w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (
297 w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_to_recw16_aux1_8 ? recw)
300 ndefinition w16_to_recw16_aux1_10 : Πn.rec_word16 〈n:〈x0,x0〉〉 → rec_word16 〈n:〈xA,x0〉〉 ≝
301 λn.λrecw:rec_word16 〈n:〈x0,x0〉〉.
302 w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (
303 w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_to_recw16_aux1_9 ? recw)
306 ndefinition w16_to_recw16_aux1_11 : Πn.rec_word16 〈n:〈x0,x0〉〉 → rec_word16 〈n:〈xB,x0〉〉 ≝
307 λn.λrecw:rec_word16 〈n:〈x0,x0〉〉.
308 w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (
309 w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_to_recw16_aux1_10 ? recw)
312 ndefinition w16_to_recw16_aux1_12 : Πn.rec_word16 〈n:〈x0,x0〉〉 → rec_word16 〈n:〈xC,x0〉〉 ≝
313 λn.λrecw:rec_word16 〈n:〈x0,x0〉〉.
314 w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (
315 w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_to_recw16_aux1_11 ? recw)
318 ndefinition w16_to_recw16_aux1_13 : Πn.rec_word16 〈n:〈x0,x0〉〉 → rec_word16 〈n:〈xD,x0〉〉 ≝
319 λn.λrecw:rec_word16 〈n:〈x0,x0〉〉.
320 w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (
321 w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_to_recw16_aux1_12 ? recw)
324 ndefinition w16_to_recw16_aux1_14 : Πn.rec_word16 〈n:〈x0,x0〉〉 → rec_word16 〈n:〈xE,x0〉〉 ≝
325 λn.λrecw:rec_word16 〈n:〈x0,x0〉〉.
326 w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (
327 w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_to_recw16_aux1_13 ? recw)
330 ndefinition w16_to_recw16_aux1_15 : Πn.rec_word16 〈n:〈x0,x0〉〉 → rec_word16 〈n:〈xF,x0〉〉 ≝
331 λn.λrecw:rec_word16 〈n:〈x0,x0〉〉.
332 w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (
333 w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_to_recw16_aux1_14 ? recw)
336 ndefinition w16_to_recw16_aux1 : Πn.rec_word16 〈n:〈x0,x0〉〉 → rec_word16 〈(succ_b8 n):〈x0,x0〉〉 ≝
337 λn.λrecw:rec_word16 〈n:〈x0,x0〉〉.
338 w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (
339 w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_S ? (w16_to_recw16_aux1_15 ? recw)
342 (* ... cifra byte superiore *)
343 nlet rec w16_to_recw16_aux2 (n:byte8) (r:rec_byte8 n) on r ≝
344 match r return λx.λy:rec_byte8 x.rec_word16 〈x:〈x0,x0〉〉 with
346 | b8_S t n' ⇒ w16_to_recw16_aux1 ? (w16_to_recw16_aux2 t n')
349 (* ... cifra esadecimale n.2 *)
350 ndefinition w16_to_recw16_aux3 ≝
351 λb,n.λrecw:rec_word16 〈b:〈x0,x0〉〉.
352 match n return λx.rec_word16 〈b:〈x,x0〉〉 with
354 | x1 ⇒ w16_to_recw16_aux1_1 ? recw
355 | x2 ⇒ w16_to_recw16_aux1_2 ? recw
356 | x3 ⇒ w16_to_recw16_aux1_3 ? recw
357 | x4 ⇒ w16_to_recw16_aux1_4 ? recw
358 | x5 ⇒ w16_to_recw16_aux1_5 ? recw
359 | x6 ⇒ w16_to_recw16_aux1_6 ? recw
360 | x7 ⇒ w16_to_recw16_aux1_7 ? recw
361 | x8 ⇒ w16_to_recw16_aux1_8 ? recw
362 | x9 ⇒ w16_to_recw16_aux1_9 ? recw
363 | xA ⇒ w16_to_recw16_aux1_10 ? recw
364 | xB ⇒ w16_to_recw16_aux1_11 ? recw
365 | xC ⇒ w16_to_recw16_aux1_12 ? recw
366 | xD ⇒ w16_to_recw16_aux1_13 ? recw
367 | xE ⇒ w16_to_recw16_aux1_14 ? recw
368 | xF ⇒ w16_to_recw16_aux1_15 ? recw
371 nlemma w16_to_recw16_aux4_1 : Πn,e.rec_word16 〈n:〈e,x0〉〉 → rec_word16 〈n:〈e,x1〉〉.
373 (* non funziona nelim e *)
375 nelim e in H:(%) ⊢ %;
376 #input; napply (w16_S ? input).
379 nlemma w16_to_recw16_aux4_2 : Πn,e.rec_word16 〈n:〈e,x0〉〉 → rec_word16 〈n:〈e,x2〉〉.
381 nelim e in H:(%) ⊢ %;
382 #input; napply (w16_S ? (w16_to_recw16_aux4_1 … input)).
385 nlemma w16_to_recw16_aux4_3 : Πn,e.rec_word16 〈n:〈e,x0〉〉 → rec_word16 〈n:〈e,x3〉〉.
387 nelim e in H:(%) ⊢ %;
388 #input; napply (w16_S ? (w16_to_recw16_aux4_2 … input)).
391 nlemma w16_to_recw16_aux4_4 : Πn,e.rec_word16 〈n:〈e,x0〉〉 → rec_word16 〈n:〈e,x4〉〉.
393 nelim e in H:(%) ⊢ %;
394 #input; napply (w16_S ? (w16_to_recw16_aux4_3 … input)).
397 nlemma w16_to_recw16_aux4_5 : Πn,e.rec_word16 〈n:〈e,x0〉〉 → rec_word16 〈n:〈e,x5〉〉.
399 nelim e in H:(%) ⊢ %;
400 #input; napply (w16_S ? (w16_to_recw16_aux4_4 … input)).
403 nlemma w16_to_recw16_aux4_6 : Πn,e.rec_word16 〈n:〈e,x0〉〉 → rec_word16 〈n:〈e,x6〉〉.
405 nelim e in H:(%) ⊢ %;
406 #input; napply (w16_S ? (w16_to_recw16_aux4_5 … input)).
409 nlemma w16_to_recw16_aux4_7 : Πn,e.rec_word16 〈n:〈e,x0〉〉 → rec_word16 〈n:〈e,x7〉〉.
411 nelim e in H:(%) ⊢ %;
412 #input; napply (w16_S ? (w16_to_recw16_aux4_6 … input)).
415 nlemma w16_to_recw16_aux4_8 : Πn,e.rec_word16 〈n:〈e,x0〉〉 → rec_word16 〈n:〈e,x8〉〉.
417 nelim e in H:(%) ⊢ %;
418 #input; napply (w16_S ? (w16_to_recw16_aux4_7 … input)).
421 nlemma w16_to_recw16_aux4_9 : Πn,e.rec_word16 〈n:〈e,x0〉〉 → rec_word16 〈n:〈e,x9〉〉.
423 nelim e in H:(%) ⊢ %;
424 #input; napply (w16_S ? (w16_to_recw16_aux4_8 … input)).
427 nlemma w16_to_recw16_aux4_10 : Πn,e.rec_word16 〈n:〈e,x0〉〉 → rec_word16 〈n:〈e,xA〉〉.
429 nelim e in H:(%) ⊢ %;
430 #input; napply (w16_S ? (w16_to_recw16_aux4_9 … input)).
433 nlemma w16_to_recw16_aux4_11 : Πn,e.rec_word16 〈n:〈e,x0〉〉 → rec_word16 〈n:〈e,xB〉〉.
435 nelim e in H:(%) ⊢ %;
436 #input; napply (w16_S ? (w16_to_recw16_aux4_10 … input)).
439 nlemma w16_to_recw16_aux4_12 : Πn,e.rec_word16 〈n:〈e,x0〉〉 → rec_word16 〈n:〈e,xC〉〉.
441 nelim e in H:(%) ⊢ %;
442 #input; napply (w16_S ? (w16_to_recw16_aux4_11 … input)).
445 nlemma w16_to_recw16_aux4_13 : Πn,e.rec_word16 〈n:〈e,x0〉〉 → rec_word16 〈n:〈e,xD〉〉.
447 nelim e in H:(%) ⊢ %;
448 #input; napply (w16_S ? (w16_to_recw16_aux4_12 … input)).
451 nlemma w16_to_recw16_aux4_14 : Πn,e.rec_word16 〈n:〈e,x0〉〉 → rec_word16 〈n:〈e,xE〉〉.
453 nelim e in H:(%) ⊢ %;
454 #input; napply (w16_S ? (w16_to_recw16_aux4_13 … input)).
457 nlemma w16_to_recw16_aux4_15 : Πn,e.rec_word16 〈n:〈e,x0〉〉 → rec_word16 〈n:〈e,xF〉〉.
459 nelim e in H:(%) ⊢ %;
460 #input; napply (w16_S ? (w16_to_recw16_aux4_14 … input)).
463 (* ... cifra esadecimale n.1 *)
464 ndefinition w16_to_recw16_aux4 ≝
465 λb,e,n.λrecw:rec_word16 〈b:〈e,x0〉〉.
466 match n return λx.rec_word16 〈b:〈e,x〉〉 with
468 | x1 ⇒ w16_to_recw16_aux4_1 … recw
469 | x2 ⇒ w16_to_recw16_aux4_2 … recw
470 | x3 ⇒ w16_to_recw16_aux4_3 … recw
471 | x4 ⇒ w16_to_recw16_aux4_4 … recw
472 | x5 ⇒ w16_to_recw16_aux4_5 … recw
473 | x6 ⇒ w16_to_recw16_aux4_6 … recw
474 | x7 ⇒ w16_to_recw16_aux4_7 … recw
475 | x8 ⇒ w16_to_recw16_aux4_8 … recw
476 | x9 ⇒ w16_to_recw16_aux4_9 … recw
477 | xA ⇒ w16_to_recw16_aux4_10 … recw
478 | xB ⇒ w16_to_recw16_aux4_11 … recw
479 | xC ⇒ w16_to_recw16_aux4_12 … recw
480 | xD ⇒ w16_to_recw16_aux4_13 … recw
481 | xE ⇒ w16_to_recw16_aux4_14 … recw
482 | xF ⇒ w16_to_recw16_aux4_15 … recw
485 ndefinition w16_to_recw16 : Πw.rec_word16 w.
487 nletin K ≝ (w16_to_recw16_aux4 (w16h w) (b8h (w16l w)) (b8l (w16l w))
488 (w16_to_recw16_aux3 (w16h w) (b8h (w16l w)) (w16_to_recw16_aux2 (w16h w) (b8_to_recb8 (w16h w)))));
489 nelim w in K:(%) ⊢ %;
492 #e1; #e2; nnormalize; #H; napply H.