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.
simpl in |- *.
intros x.
rewrite (mult_1_r (val x)).
auto.
Qed.
intros n X; elim X.
auto.
intros n0 y l H_rec.
simpl in |- *.
apply lt_le_trans with (pred base * exp_n base n0 + exp_n base n0).
apply le_lt_plus_mult.
elim y.
intros x H_y.
simpl in |- *.
auto. (*lt_le_pred*)
trivial.
replace (pred base) with (base - 1). (*pred_minus*)
rewrite mult_minus_distr_r.
simpl in |- *.
elim plus_n_O.
elim exp_n_plus_p1.
elim plus_Snm_nSm; simpl in |- *; elim plus_n_O.
elim plus_comm.
elim le_plus_minus.
apply le_mult_cst; auto.
apply le_exp_n_mult.
unfold base in |- *; case BASE; auto.
auto.
Qed.
Definition val_bound (n : nat) (X : num n) : inf (exp base n) :=
exist (fun p : nat => p < exp base n) (Val n X) (upper_bound n X).
simpl in |- *; intros.
elim H.
apply same_quotient_order; auto; apply upper_bound.
intros; apply same_quotient_order; auto; apply upper_bound.
Qed.

Lemma comp_eq_most :
forall (n : nat) (x y : digit) (X Y : num n),
val x = val y ->
Val n X < Val n Y -> Val (S n) (Cons n x X) < Val (S n) (Cons n y Y).