(* Copyright (C) 2005-2008 Sebastien Briais *)
(* http://lamp.epfl.ch/~sbriais/ *)
(* This library 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 library 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 *)
(* Lesser General Public License for more details. *)
(* You should have received a copy of the GNU Lesser General Public *)
(* License along with this library; if not, write to the Free Software *)
(* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *)
(* 02110-1301 USA *)
(** First, we show the following theorem: *)
(** if p is a prime number and gcd(p,k)=1 then sqrt(p*k) is not rational *)
(** Then, we strengthen the result to the n-th root of p^r*k *)
(** where 0 < r < n obtaining the theorem: *)
(**  if p is a prime number, gcd(p,k)=1 and 0 < r < n then the n-th root of p^r*k is not rational *)
Unset Standard Proposition Elimination Names.
intros.
intro.
assert (divides a p).
apply prime_square;trivial.
exists (k*(square b)).
rewrite <- H2;ring.
elim H3;intro n_a;intro.
rewrite H4 in H2;rewrite square_mult_lemma in H2;unfold square in H2.
assert (k*(b*b)=p*(n_a*n_a)).
apply mult_lemma6 with p.
intro H5;rewrite H5 in H;apply not_prime_zero;trivial.
rewrite mult_assoc;rewrite H2;ring.
assert (divides b p).
apply prime_square;trivial;unfold square.
apply gauss with k.
apply rel_prime_sym;trivial.
exists (n_a*n_a);trivial.
assert (p=1).
unfold rel_prime in H1.
elim H1;intros.
apply divides_antisym;try (apply one_min_div).
apply H8;red;tauto.
elim H;tauto.
Qed.

(** Theorem: if p is prime, p and k are relatively prime, then sqrt(p*k) is not rationnal *)
Theorem sqrt_prime_irrat : forall (p k a b:nat),(is_prime p)->(rel_prime p k)->(b<>O)->(p*k*(square b) <> (square a)).