| author | blanchet |
| Wed, 04 Mar 2009 11:05:29 +0100 | |
| changeset 30242 | aea5d7fa7ef5 |
| parent 28952 | 15a4b2cf8c34 |
| child 30411 | 9c9b6511ad1b |
| permissions | -rw-r--r-- |
|
28952
15a4b2cf8c34
made repository layout more coherent with logical distribution structure; stripped some $Id$s
haftmann
parents:
28001
diff
changeset
|
1 |
(* Title: HOL/ex/Sqrt.thy |
| 13957 | 2 |
Author: Markus Wenzel, TU Muenchen |
| 14981 | 3 |
|
| 13957 | 4 |
*) |
5 |
||
6 |
header {* Square roots of primes are irrational *}
|
|
7 |
||
| 15149 | 8 |
theory Sqrt |
|
28952
15a4b2cf8c34
made repository layout more coherent with logical distribution structure; stripped some $Id$s
haftmann
parents:
28001
diff
changeset
|
9 |
imports Complex_Main Primes |
| 15149 | 10 |
begin |
| 13957 | 11 |
|
| 28001 | 12 |
text {* The definition and the key representation theorem for the set of
|
13 |
rational numbers has been moved to a core theory. *} |
|
| 13957 | 14 |
|
| 28001 | 15 |
declare Rats_abs_nat_div_natE[elim?] |
| 13957 | 16 |
|
17 |
subsection {* Main theorem *}
|
|
18 |
||
19 |
text {*
|
|
20 |
The square root of any prime number (including @{text 2}) is
|
|
21 |
irrational. |
|
22 |
*} |
|
23 |
||
| 19086 | 24 |
theorem sqrt_prime_irrational: |
25 |
assumes "prime p" |
|
26 |
shows "sqrt (real p) \<notin> \<rat>" |
|
| 13957 | 27 |
proof |
| 19086 | 28 |
from `prime p` have p: "1 < p" by (simp add: prime_def) |
| 13957 | 29 |
assume "sqrt (real p) \<in> \<rat>" |
30 |
then obtain m n where |
|
31 |
n: "n \<noteq> 0" and sqrt_rat: "\<bar>sqrt (real p)\<bar> = real m / real n" |
|
| 27556 | 32 |
and gcd: "gcd m n = 1" .. |
| 13957 | 33 |
have eq: "m\<twosuperior> = p * n\<twosuperior>" |
34 |
proof - |
|
35 |
from n and sqrt_rat have "real m = \<bar>sqrt (real p)\<bar> * real n" by simp |
|
36 |
then have "real (m\<twosuperior>) = (sqrt (real p))\<twosuperior> * real (n\<twosuperior>)" |
|
|
14353
79f9fbef9106
Added lemmas to Ring_and_Field with slightly modified simplification rules
paulson
parents:
14305
diff
changeset
|
37 |
by (auto simp add: power2_eq_square) |
| 13957 | 38 |
also have "(sqrt (real p))\<twosuperior> = real p" by simp |
39 |
also have "\<dots> * real (n\<twosuperior>) = real (p * n\<twosuperior>)" by simp |
|
40 |
finally show ?thesis .. |
|
41 |
qed |
|
42 |
have "p dvd m \<and> p dvd n" |
|
43 |
proof |
|
44 |
from eq have "p dvd m\<twosuperior>" .. |
|
| 19086 | 45 |
with `prime p` show "p dvd m" by (rule prime_dvd_power_two) |
| 13957 | 46 |
then obtain k where "m = p * k" .. |
|
14353
79f9fbef9106
Added lemmas to Ring_and_Field with slightly modified simplification rules
paulson
parents:
14305
diff
changeset
|
47 |
with eq have "p * n\<twosuperior> = p\<twosuperior> * k\<twosuperior>" by (auto simp add: power2_eq_square mult_ac) |
|
79f9fbef9106
Added lemmas to Ring_and_Field with slightly modified simplification rules
paulson
parents:
14305
diff
changeset
|
48 |
with p have "n\<twosuperior> = p * k\<twosuperior>" by (simp add: power2_eq_square) |
| 13957 | 49 |
then have "p dvd n\<twosuperior>" .. |
| 19086 | 50 |
with `prime p` show "p dvd n" by (rule prime_dvd_power_two) |
| 13957 | 51 |
qed |
| 27556 | 52 |
then have "p dvd gcd m n" .. |
| 13957 | 53 |
with gcd have "p dvd 1" by simp |
54 |
then have "p \<le> 1" by (simp add: dvd_imp_le) |
|
55 |
with p show False by simp |
|
56 |
qed |
|
57 |
||
58 |
corollary "sqrt (real (2::nat)) \<notin> \<rat>" |
|
59 |
by (rule sqrt_prime_irrational) (rule two_is_prime) |
|
60 |
||
61 |
||
62 |
subsection {* Variations *}
|
|
63 |
||
64 |
text {*
|
|
65 |
Here is an alternative version of the main proof, using mostly |
|
66 |
linear forward-reasoning. While this results in less top-down |
|
67 |
structure, it is probably closer to proofs seen in mathematics. |
|
68 |
*} |
|
69 |
||
| 19086 | 70 |
theorem |
71 |
assumes "prime p" |
|
72 |
shows "sqrt (real p) \<notin> \<rat>" |
|
| 13957 | 73 |
proof |
| 19086 | 74 |
from `prime p` have p: "1 < p" by (simp add: prime_def) |
| 13957 | 75 |
assume "sqrt (real p) \<in> \<rat>" |
76 |
then obtain m n where |
|
77 |
n: "n \<noteq> 0" and sqrt_rat: "\<bar>sqrt (real p)\<bar> = real m / real n" |
|
| 27556 | 78 |
and gcd: "gcd m n = 1" .. |
| 13957 | 79 |
from n and sqrt_rat have "real m = \<bar>sqrt (real p)\<bar> * real n" by simp |
80 |
then have "real (m\<twosuperior>) = (sqrt (real p))\<twosuperior> * real (n\<twosuperior>)" |
|
|
14353
79f9fbef9106
Added lemmas to Ring_and_Field with slightly modified simplification rules
paulson
parents:
14305
diff
changeset
|
81 |
by (auto simp add: power2_eq_square) |
| 13957 | 82 |
also have "(sqrt (real p))\<twosuperior> = real p" by simp |
83 |
also have "\<dots> * real (n\<twosuperior>) = real (p * n\<twosuperior>)" by simp |
|
84 |
finally have eq: "m\<twosuperior> = p * n\<twosuperior>" .. |
|
85 |
then have "p dvd m\<twosuperior>" .. |
|
| 19086 | 86 |
with `prime p` have dvd_m: "p dvd m" by (rule prime_dvd_power_two) |
| 13957 | 87 |
then obtain k where "m = p * k" .. |
|
14353
79f9fbef9106
Added lemmas to Ring_and_Field with slightly modified simplification rules
paulson
parents:
14305
diff
changeset
|
88 |
with eq have "p * n\<twosuperior> = p\<twosuperior> * k\<twosuperior>" by (auto simp add: power2_eq_square mult_ac) |
|
79f9fbef9106
Added lemmas to Ring_and_Field with slightly modified simplification rules
paulson
parents:
14305
diff
changeset
|
89 |
with p have "n\<twosuperior> = p * k\<twosuperior>" by (simp add: power2_eq_square) |
| 13957 | 90 |
then have "p dvd n\<twosuperior>" .. |
| 19086 | 91 |
with `prime p` have "p dvd n" by (rule prime_dvd_power_two) |
| 27556 | 92 |
with dvd_m have "p dvd gcd m n" by (rule gcd_greatest) |
| 13957 | 93 |
with gcd have "p dvd 1" by simp |
94 |
then have "p \<le> 1" by (simp add: dvd_imp_le) |
|
95 |
with p show False by simp |
|
96 |
qed |
|
97 |
||
98 |
end |