(* 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                                                     *)
(** prime. The primality predicate.  @author Olga Caprotti and Martijn Oostdijk @version $Revision$ *)
(** * Primality on nat *)
Definition Prime (n : nat) : Prop :=
n > 1 /\ (forall q : nat, Divides q n -> q = 1 \/ q = n).
(** Prime with bounded all quantifier. *)
Definition bPrime (n : nat) :=
n > 1 /\ (forall q : nat, q < S n -> Divides q n -> q = 1 \/ q = n).

(* Specifications: *)
Lemma primebprime : forall n : nat, Prime n <-> bPrime n.
(** Prime is decidable. *)
Lemma bprimedec : forall n : nat, bPrime n \/ ~ bPrime n.
Lemma primedec : forall n : nat, Prime n \/ ~ Prime n.
(** Non-primes n>1 have non-trivial divisors. *)
Lemma nonprime_witness :
forall n : nat,
n > 1 -> ~ Prime n -> exists d : nat, 1 < d /\ d < n /\ Divides d n.
Lemma nonprime_sqrwitness :
forall n : nat,
n > 1 -> ~ Prime n -> exists d : nat, 1 < d /\ d * d <= n /\ Divides d n.