Fixpoint rest (p r s n : nat) {struct n} : nat :=
  match n with
  | O => r
  | S n' =>
      match s with
      | O => 0
      | S O => rest p 0 p n'
      | S s' => rest p (S r) s' n'
      end
  end.Definition mod_ (m n : nat) : nat := rest n 0 n m.

(* Specifications: *)
Lemma mod_eq_0 : forall m : nat, mod_ 0 m = 0.