(** The other direction *)

(* Specifications: *)
Lemma succ_double_alt d :
Little.succ_double d = Little.succ (Little.double d).
Lemma double_succ d :
Little.double (Little.succ d) =
Little.succ (Little.succ_double d).
Lemma to_lu_succ n :
to_lu (N.succ n) = Little.succ (to_lu n).
Lemma nat_iter_S n {A} (f:A->A) i :
Nat.iter (S n) f i = f (Nat.iter n f i).
Lemma nat_iter_0 {A} (f:A->A) i : Nat.iter 0 f i = i.
Lemma to_ldec_tenfold p :
to_lu (10 * Npos p) = D0 (to_lu (Npos p)).
Lemma of_lu_0 d : of_lu d = 0 <-> nztail d = Nil.
Lemma to_of_lu_tenfold d :
to_lu (of_lu d) = lnorm d ->
to_lu (10 * of_lu d) = lnorm (D0 d).
Lemma Nadd_alt n m : n + m = Nat.iter (N.to_nat n) N.succ m.
Ltac simpl_to_nat := simpl N.to_nat; unfold Pos.to_nat; simpl Pos.iter_op.
Lemma to_of_lu d : to_lu (of_lu d) = lnorm d.
(** Second bijection result *)
Lemma to_of (d:uint) : N.to_uint (Pos.of_uint d) = unorm d.
(** Some consequences *)
Lemma to_uint_nonzero p : Pos.to_uint p <> zero.
Lemma to_uint_nonnil p : Pos.to_uint p <> Nil.
Lemma to_uint_inj p p' : Pos.to_uint p = Pos.to_uint p' -> p = p'.
Lemma to_uint_pos_surj d :
unorm d<>zero -> exists p, Pos.to_uint p = unorm d.
Lemma of_uint_norm d : Pos.of_uint (unorm d) = Pos.of_uint d.
Lemma of_inj d d' :
Pos.of_uint d = Pos.of_uint d' -> unorm d = unorm d'.
Lemma of_iff d d' : Pos.of_uint d = Pos.of_uint d' <-> unorm d = unorm d'.
Lemma nztail_to_uint p :
let (h, n) := Decimal.nztail (Pos.to_uint p) in
Npos p = Pos.of_uint h * 10^(N.of_nat n).
Lemma succ_double_alt d :
Little.succ_double d = Little.succ (Little.double d).
Lemma double_succ d :
Little.double (Little.succ d) =
Little.succ (Little.succ_double d).
Lemma to_lu_succ n :
to_lu (N.succ n) = Little.succ (to_lu n).
Lemma nat_iter_S n {A} (f:A->A) i :
Nat.iter (S n) f i = f (Nat.iter n f i).
Lemma nat_iter_0 {A} (f:A->A) i : Nat.iter 0 f i = i.
Lemma to_lhex_tenfold p :
to_lu (0x10 * Npos p) = D0 (to_lu (Npos p)).
Lemma of_lu_0 d : of_lu d = 0 <-> nztail d = Nil.
Lemma to_of_lu_tenfold d :
to_lu (of_lu d) = lnorm d ->
to_lu (0x10 * of_lu d) = lnorm (D0 d).
Lemma Nadd_alt n m : n + m = Nat.iter (N.to_nat n) N.succ m.
Ltac simpl_to_nat := simpl N.to_nat; unfold Pos.to_nat; simpl Pos.iter_op.
Lemma to_of_lu d : to_lu (of_lu d) = lnorm d.
(** Second bijection result *)
Lemma to_of (d:uint) : N.to_hex_uint (Pos.of_hex_uint d) = unorm d.
(** Some consequences *)
Lemma to_uint_nonzero p : Pos.to_hex_uint p <> zero.
Lemma to_uint_nonnil p : Pos.to_hex_uint p <> Nil.
Lemma to_uint_inj p p' : Pos.to_hex_uint p = Pos.to_hex_uint p' -> p = p'.
Lemma to_uint_pos_surj d :
unorm d<>zero -> exists p, Pos.to_hex_uint p = unorm d.
Lemma of_uint_norm d : Pos.of_hex_uint (unorm d) = Pos.of_hex_uint d.
Lemma of_inj d d' :
Pos.of_hex_uint d = Pos.of_hex_uint d' -> unorm d = unorm d'.
Lemma of_iff d d' : Pos.of_hex_uint d = Pos.of_hex_uint d' <-> unorm d = unorm d'.
(* various lemmas *)
Lemma nztail_to_hex_uint p :
let (h, n) := Hexadecimal.nztail (Pos.to_hex_uint p) in
Npos p = Pos.of_hex_uint h * 0x10^(N.of_nat n).