(**************************************************************)
(*   Copyright Dominique Larchey-Wendling [*]                 *)
(*                                                            *)
(*                             [*] Affiliation LORIA -- CNRS  *)
(**************************************************************)
(*      This file is distributed under the terms of the       *)
(*         CeCILL v2 FREE SOFTWARE LICENSE AGREEMENT          *)
(**************************************************************)
(** ** Prime numbers *)
Set Implicit Arguments.
Section prime.
Hint Resolve divides_0 divides_mult divides_refl divides_0_inv.
Infix "<d" := divides (at level 70, no associativity).
Definition prime p := p <> 1 /\ forall q, q <d p -> q = 1 \/ q = p.
Fact prime_2 : prime 2.
Fact prime_ge_2 p : prime p -> 2 <= p.
Fact prime_gcd p q : prime p -> is_gcd p q 1 \/ p <d q.
Fact prime_div_mult p x y : prime p -> p <d x*y -> p <d x \/ p <d y.
Definition prime_or_div p : 2 <= p -> { q | 2 <= q < p /\ q <d p } + { prime p }.

Theorem prime_factor n : 2 <= n -> { p | prime p /\ p <d n }.
Section prime_rect.