(************************************************************************)
(*         *      The Rocq Prover / The Rocq Development Team           *)
(*  v      *         Copyright INRIA, CNRS and contributors             *)
(* <O___,, * (see version control and CREDITS file for authors & dates) *)
(*   \VV/  **************************************************************)
(*    //   *    This file is distributed under the terms of the         *)
(*         *     GNU Lesser General Public License Version 2.1          *)
(*         *     (see LICENSE file for the text of the license)         *)
(************************************************************************)
(** * HexadecimalZ  Proofs that conversions between hexadecimal numbers and [Z] are bijections. *)

(* Specifications: *)
Lemma of_to (z:Z) : Z.of_hex_int (Z.to_hex_int z) = z.
Lemma to_of (d:int) : Z.to_hex_int (Z.of_hex_int d) = norm d.
(** Some consequences *)
Lemma to_int_inj n n' : Z.to_hex_int n = Z.to_hex_int n' -> n = n'.
Lemma to_int_surj d : exists n, Z.to_hex_int n = norm d.
Lemma of_int_norm d : Z.of_hex_int (norm d) = Z.of_hex_int d.
Lemma of_inj d d' :
Z.of_hex_int d = Z.of_hex_int d' -> norm d = norm d'.
Lemma of_iff d d' : Z.of_hex_int d = Z.of_hex_int d' <-> norm d = norm d'.
(** Various lemmas *)
Lemma of_hex_uint_iter_D0 d n :
Z.of_hex_uint (app d (Nat.iter n D0 Nil))
= Nat.iter n (Z.mul 0x10) (Z.of_hex_uint d).
Lemma of_hex_int_iter_D0 d n :
Z.of_hex_int (app_int d (Nat.iter n D0 Nil))
= Nat.iter n (Z.mul 0x10) (Z.of_hex_int d).