(* This program is free software; you can redistribute it and/or      *)
(* modify it under the terms of the GNU Lesser General Public License *)
(* as published by the Free Software Foundation; either version 2.1   *)
(* of the License, or (at your option) any later version.             *)
(*                                                                    *)
(* This program is distributed in the hope that it will be useful,    *)
(* but WITHOUT ANY WARRANTY; without even the implied warranty of     *)
(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the      *)
(* GNU General Public License for more details.                       *)
(*                                                                    *)
(* You should have received a copy of the GNU Lesser General Public   *)
(* License along with this program; if not, write to the Free         *)
(* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *)
(* 02110-1301 USA                                                     *)
Unset Standard Proposition Elimination Names.
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.
Proof with trivial.