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 (* Sviluppo: 2008-2010 *)
21 (* ********************************************************************** *)
23 include "common/nat.ma".
24 include "num/word32.ma".
26 (* ************************ *)
27 (* NUMERI FINITI → NATURALI *)
28 (* ************************ *)
30 nlet rec nat_of_qu_aux n (r:rec_quatern n) on r ≝
33 | qu_S t n' ⇒ S (nat_of_qu_aux t n')
36 ndefinition nat_of_qu : quatern → nat ≝ λn.nat_of_qu_aux n (qu_to_recqu n).
38 nlet rec nat_of_oct_aux n (r:rec_oct n) on r ≝
41 | oc_S t n' ⇒ S (nat_of_oct_aux t n')
44 ndefinition nat_of_oct : oct → nat ≝ λn.nat_of_oct_aux n (oct_to_recoct n).
46 nlet rec nat_of_ex_aux n (r:rec_exadecim n) on r ≝
49 | ex_S t n' ⇒ S (nat_of_ex_aux t n')
52 ndefinition nat_of_ex : exadecim → nat ≝ λn.nat_of_ex_aux n (ex_to_recex n).
54 nlet rec nat_of_bit_aux n (r:rec_bitrigesim n) on r ≝
57 | bi_S t n' ⇒ S (nat_of_bit_aux t n')
60 ndefinition nat_of_bit : bitrigesim → nat ≝ λn.nat_of_bit_aux n (bit_to_recbit n).
62 nlet rec nat_of_b8_aux n (r:rec_byte8 n) on r ≝
65 | b8_S t n' ⇒ S (nat_of_b8_aux t n')
68 ndefinition nat_of_b8 : byte8 → nat ≝ λn:byte8.nat_of_b8_aux n (b8_to_recb8 n).
70 nlet rec nat_of_w16_aux n (r:rec_word16 n) on r : nat ≝
73 | w16_S t n' ⇒ S (nat_of_w16_aux t n')
76 ndefinition nat_of_w16 : word16 → nat ≝ λn:word16.nat_of_w16_aux n (w16_to_recw16 n).
78 ndefinition nat_of_w32 : word32 → nat ≝ λn:word32.(nat65536 * (nat_of_w16 (cnH ? n))) + (nat_of_w16 (cnL ? n)).