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.Definition BT := {b : nat | 0 < b}.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).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.