(************************************************************************)
(*         *      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)         *)
(************************************************************************)
(** * DecimalFacts : some facts about Decimal numbers *)
Variant digits := d0 | d1 | d2 | d3 | d4 | d5 | d6 | d7 | d8 | d9.
Fixpoint to_list (u : uint) : list digits :=
match u with
| Nil => nil
| D0 u => cons d0 (to_list u)
| D1 u => cons d1 (to_list u)
| D2 u => cons d2 (to_list u)
| D3 u => cons d3 (to_list u)
| D4 u => cons d4 (to_list u)
| D5 u => cons d5 (to_list u)
| D6 u => cons d6 (to_list u)
| D7 u => cons d7 (to_list u)
| D8 u => cons d8 (to_list u)
| D9 u => cons d9 (to_list u)
end.
Fixpoint of_list (l : list digits) : uint :=
match l with
| nil => Nil
| cons d0 l => D0 (of_list l)
| cons d1 l => D1 (of_list l)
| cons d2 l => D2 (of_list l)
| cons d3 l => D3 (of_list l)
| cons d4 l => D4 (of_list l)
| cons d5 l => D5 (of_list l)
| cons d6 l => D6 (of_list l)
| cons d7 l => D7 (of_list l)
| cons d8 l => D8 (of_list l)
| cons d9 l => D9 (of_list l)
end.

Lemma nztail_spec d :
let (r, n) := nztail d in
let (r', n') := lnztail (to_list d) in
to_list r = r' /\ n = n'.