(* 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                                                     *)
(** divides. The division predicate.  @author Olga Caprotti and Martijn Oostdijk @version $Revision$ *)
(** * Division on nat *)
Definition Divides (n m : nat) : Prop := exists q : nat, m = n * q.
(** Divides with bounded ex quantifier. *)
Definition bDivides (d n : nat) :=
n = 0 \/ (exists q : nat, q < S n /\ n = d * q).
(** Divides is decidable. *)
(** If d|n, then either d<sqrt(n) or the other divisor x<sqrt(n). *)

Theorem sqrdivbound :
forall n d : nat,
Divides d n ->
exists x : nat, Divides x n /\ x * x <= n /\ (x = d \/ d * x = n).