(* 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                                                     *)
Require Export MiscRsa.
(******************************************************************************)
Inductive divides : nat -> nat -> Prop :=
dividesDef : forall a b q : nat, b = q * a -> divides a b.
intros a; apply dividesDef with (q := 1); auto with arith.
Qed.
intros x y; case x; case y; auto.
left; apply dividesDef with (q := 0); auto.
intros n; right; red in |- *; intros H'; inversion_clear H'.
rewrite (mult_comm q 0) in H; discriminate.
intros n; left; apply dividesDef with (q := 0); auto.
intros x' y'; case (divides_dec' (S x') (S y')); auto.
intros H'; left; apply div_divides; auto.
intros H'; right; red in |- *; intros H'0; case H'; auto.
inversion H'0.
exists q; auto.
apply is_div_def; auto with arith.
rewrite H; auto with arith.
Qed.
intros a b; case b.
intros H'; case H'; auto.
intros n H' H'0; inversion_clear H'0.
rewrite H; generalize H; case q; simpl in |- *; auto with arith; intros;
discriminate.
Qed.
intros a b H'1 H'2; red in |- *; intros H'3; absurd (a <= b); auto with arith.
apply divides_le; auto.
apply sym_not_eq; auto with arith.
Qed.
(********************************************************************)
Inductive prime : nat -> Prop :=
primeDef :
forall a : nat,
a <> 1 -> (forall b : nat, divides b a -> b <> 1 -> a = b) -> prime a.
Hint Resolve div_ref all_divides_O SO_divides_all not_prime_O not_prime_1.

Lemma lt_prime : forall p : nat, prime p -> 1 < p.