(* 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                                                     *)
(** modulo Modulo Arithmetic.  @author Olga Caprotti and Martijn Oostdijk @version $Revision$ *)
(** (Mod a b n) means (a = b (mod n)) *)
Definition Mod (a b : Z) (n : nat) :=
exists q : Z, a = (b + Z_of_nat n * q)%Z.
(** ZMod, same as Mod but only uses Z. *)
Definition ZMod (a b n : Z) := exists q : Z, a = (b + n * q)%Z.

Lemma zmoddivmin : forall a b n : Z, ZMod a b n <-> ZDivides n (a - b).