(* This code is copyrighted by its authors; it is distributed under  *)
(* the terms of the LGPL license (see LICENSE and description files) *)
(* Contribution to the Coq Library   V6.3 (July 1999)                    *)
(****************************************************************************)
(*                                                                          *)
(*                                                                          *)
(*                   Solange Coupet-Grimal & Line Jakubiec                  *)
(*                                                                          *)
(*                                                                          *)
(*              Laboratoire d'Informatique de Marseille                     *)
(*               CMI-Technopole de Chateau-Gombert                          *)
(*                   39, Rue F. Joliot Curie                                *)
(*                   13453 MARSEILLE Cedex 13                               *)
(*           e-mail:{Solange.Coupet,Line.Jakubiec}@lim.univ-mrs.fr          *)
(*                                                                          *)
(*                                                                          *)
(*                                Coq V5.10                                 *)
(*                              May 30th 1996                               *)
(*                                                                          *)
(****************************************************************************)
(*                                Numerals.v                                *)
(****************************************************************************)
Require Export Dependent_lists.
Require Export Lib_Arith.
Definition Inj (A : Set) (P : A -> Prop) (e : {x : A | P x}) :=
let (a, _) return A := e in a.
Fixpoint exp (e x : nat) {struct x} : nat :=
match x with
| O => 1
| S p => e * exp e p
end.
Section Numerals.
Definition BT := {b : nat | 0 < b}.
Variable BASE : BT.
Definition base := Inj nat (fun b : nat => 0 < b) BASE.
Definition digit := {x : nat | x < base}.
Definition val : digit -> nat := Inj nat (fun x : nat => x < base).
Definition num := list digit.
Definition inf (n : nat) := {x : nat | x < n}.
Definition val_inf (n : nat) : inf n -> nat :=
Inj nat (fun x : nat => x < n).
Let Cons := cons digit.
Let Nil := nil digit.
Fixpoint Val (n : nat) (X : num n) {struct X} : nat :=
match X with
| nil => 0
| cons p xp X' => val xp * exp base p + Val p X'
end.

Lemma Val_val : forall x : digit, Val 1 (Cons 0 x Nil) = val x.
simpl in |- *.