Library Stdlib.Numbers.HexadecimalN
Require Import Hexadecimal HexadecimalFacts HexadecimalPos PArith NArith.
Module Unsigned.
Lemma of_to (n:N) : N.of_hex_uint (N.to_hex_uint n) = n.
Lemma to_of (d:uint) : N.to_hex_uint (N.of_hex_uint d) = unorm d.
Lemma to_uint_inj n n' : N.to_hex_uint n = N.to_hex_uint n' -> n = n'.
Lemma to_uint_surj d : exists p, N.to_hex_uint p = unorm d.
Lemma of_uint_norm d : N.of_hex_uint (unorm d) = N.of_hex_uint d.
Lemma of_inj d d' :
N.of_hex_uint d = N.of_hex_uint d' -> unorm d = unorm d'.
Lemma of_iff d d' : N.of_hex_uint d = N.of_hex_uint d' <-> unorm d = unorm d'.
End Unsigned.
Conversion from/to signed hexadecimal numbers
Module Signed.
Lemma of_to (n:N) : N.of_hex_int (N.to_hex_int n) = Some n.
Lemma to_of (d:int)(n:N) : N.of_hex_int d = Some n -> N.to_hex_int n = norm d.
Lemma to_int_inj n n' : N.to_hex_int n = N.to_hex_int n' -> n = n'.
Lemma to_int_pos_surj d : exists n, N.to_hex_int n = norm (Pos d).
Lemma of_int_norm d : N.of_hex_int (norm d) = N.of_hex_int d.
Lemma of_inj_pos d d' :
N.of_hex_int (Pos d) = N.of_hex_int (Pos d') -> unorm d = unorm d'.
End Signed.