(* 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).
(** Prime is decidable. *)
(** Non-primes n>1 have non-trivial divisors. *)
(** Non-primes n>1 have prime-divisors. *)
(** Prime(n) if all prime divisors > sqrt(n). *)
(** Two is a prime. *)
(** * Primality on Z *)
(** ZPrime, just like Prime but uses only Z. *)
Definition ZPrime (n : Z) : Prop :=
(n > 1)%Z /\ (forall q : Z, (q >= 0)%Z -> ZDivides q n -> q = 1%Z \/ q = n).
(** All numbers in natlist are prime. *)
Definition allPrime : natlist -> Prop := alllist nat Prime.
Definition allZPrime : Zlist -> Prop := alllist Z ZPrime.

Lemma allprimeallzprime :
forall l : natlist, allPrime l -> allZPrime (map _ _ Z_of_nat l).