Fixpoint Zsum_digit f k :=
  match k with
  | O => Z0
  | S k => (Zsum_digit f k + f (Z_of_nat k) * Zpower beta (Z_of_nat k))%Z
  end.

(* Specifications: *)
Theorem Zsum_digit_digit : forall n k, Zsum_digit (Zdigit n) k = Z.rem n (Zpower beta (Z_of_nat k)).
Theorem Zpower_gt_id : forall n, (n < Zpower beta n)%Z.
Theorem Zdigit_ext : forall n1 n2, (forall k, (0 <= k)%Z -> Zdigit n1 k = Zdigit n2 k) -> n1 = n2.
Theorem ZOmod_plus_pow_digit : forall u v n, (0 <= u * v)%Z -> (forall k, (0 <= k < n)%Z -> Zdigit u k = Z0 \/ Zdigit v k = Z0) -> Z.rem (u + v) (Zpower beta n) = (Z.rem u (Zpower beta n) + Z.rem v (Zpower beta n))%Z.
Theorem ZOdiv_plus_pow_digit : forall u v n, (0 <= u * v)%Z -> (forall k, (0 <= k < n)%Z -> Zdigit u k = Z0 \/ Zdigit v k = Z0) -> Z.quot (u + v) (Zpower beta n) = (Z.quot u (Zpower beta n) + Z.quot v (Zpower beta n))%Z.
Theorem Zdigit_plus : forall u v, (0 <= u * v)%Z -> (forall k, (0 <= k)%Z -> Zdigit u k = Z0 \/ Zdigit v k = Z0) -> forall k, Zdigit (u + v) k = (Zdigit u k + Zdigit v k)%Z.
Theorem Zsum_digit_digit : forall n k, Zsum_digit (Zdigit n) k = Z.rem n (Zpower beta (Z_of_nat k)).
Theorem Zpower_gt_id : forall n, (n < Zpower beta n)%Z.
Theorem Zdigit_ext : forall n1 n2, (forall k, (0 <= k)%Z -> Zdigit n1 k = Zdigit n2 k) -> n1 = n2.
Theorem ZOmod_plus_pow_digit : forall u v n, (0 <= u * v)%Z -> (forall k, (0 <= k < n)%Z -> Zdigit u k = Z0 \/ Zdigit v k = Z0) -> Z.rem (u + v) (Zpower beta n) = (Z.rem u (Zpower beta n) + Z.rem v (Zpower beta n))%Z.
Theorem ZOdiv_plus_pow_digit : forall u v n, (0 <= u * v)%Z -> (forall k, (0 <= k < n)%Z -> Zdigit u k = Z0 \/ Zdigit v k = Z0) -> Z.quot (u + v) (Zpower beta n) = (Z.quot u (Zpower beta n) + Z.quot v (Zpower beta n))%Z.
Theorem Zdigit_plus : forall u v, (0 <= u * v)%Z -> (forall k, (0 <= k)%Z -> Zdigit u k = Z0 \/ Zdigit v k = Z0) -> forall k, Zdigit (u + v) k = (Zdigit u k + Zdigit v k)%Z.