--- a/src/HOL/ex/Sqrt.thy Sat Nov 22 14:13:36 2014 +0100
+++ b/src/HOL/ex/Sqrt.thy Sat Nov 22 14:57:04 2014 +0100
@@ -2,19 +2,19 @@
Author: Markus Wenzel, Tobias Nipkow, TU Muenchen
*)
-section {* Square roots of primes are irrational *}
+section \<open>Square roots of primes are irrational\<close>
theory Sqrt
imports Complex_Main "~~/src/HOL/Number_Theory/Primes"
begin
-text {* The square root of any prime number (including 2) is irrational. *}
+text \<open>The square root of any prime number (including 2) is irrational.\<close>
theorem sqrt_prime_irrational:
assumes "prime (p::nat)"
shows "sqrt p \<notin> \<rat>"
proof
- from `prime p` have p: "1 < p" by (simp add: prime_nat_def)
+ from \<open>prime p\<close> have p: "1 < p" by (simp add: prime_nat_def)
assume "sqrt p \<in> \<rat>"
then obtain m n :: nat where
n: "n \<noteq> 0" and sqrt_rat: "\<bar>sqrt p\<bar> = m / n"
@@ -31,12 +31,12 @@
have "p dvd m \<and> p dvd n"
proof
from eq have "p dvd m\<^sup>2" ..
- with `prime p` show "p dvd m" by (rule prime_dvd_power_nat)
+ with \<open>prime p\<close> show "p dvd m" by (rule prime_dvd_power_nat)
then obtain k where "m = p * k" ..
with eq have "p * n\<^sup>2 = p\<^sup>2 * k\<^sup>2" by (auto simp add: power2_eq_square ac_simps)
with p have "n\<^sup>2 = p * k\<^sup>2" by (simp add: power2_eq_square)
then have "p dvd n\<^sup>2" ..
- with `prime p` show "p dvd n" by (rule prime_dvd_power_nat)
+ with \<open>prime p\<close> show "p dvd n" by (rule prime_dvd_power_nat)
qed
then have "p dvd gcd m n" ..
with gcd have "p dvd 1" by simp
@@ -47,19 +47,20 @@
corollary sqrt_2_not_rat: "sqrt 2 \<notin> \<rat>"
using sqrt_prime_irrational[of 2] by simp
-subsection {* Variations *}
-text {*
+subsection \<open>Variations\<close>
+
+text \<open>
Here is an alternative version of the main proof, using mostly
linear forward-reasoning. While this results in less top-down
structure, it is probably closer to proofs seen in mathematics.
-*}
+\<close>
theorem
assumes "prime (p::nat)"
shows "sqrt p \<notin> \<rat>"
proof
- from `prime p` have p: "1 < p" by (simp add: prime_nat_def)
+ from \<open>prime p\<close> have p: "1 < p" by (simp add: prime_nat_def)
assume "sqrt p \<in> \<rat>"
then obtain m n :: nat where
n: "n \<noteq> 0" and sqrt_rat: "\<bar>sqrt p\<bar> = m / n"
@@ -71,12 +72,12 @@
also have "\<dots> * n\<^sup>2 = p * n\<^sup>2" by simp
finally have eq: "m\<^sup>2 = p * n\<^sup>2" ..
then have "p dvd m\<^sup>2" ..
- with `prime p` have dvd_m: "p dvd m" by (rule prime_dvd_power_nat)
+ with \<open>prime p\<close> have dvd_m: "p dvd m" by (rule prime_dvd_power_nat)
then obtain k where "m = p * k" ..
with eq have "p * n\<^sup>2 = p\<^sup>2 * k\<^sup>2" by (auto simp add: power2_eq_square ac_simps)
with p have "n\<^sup>2 = p * k\<^sup>2" by (simp add: power2_eq_square)
then have "p dvd n\<^sup>2" ..
- with `prime p` have "p dvd n" by (rule prime_dvd_power_nat)
+ with \<open>prime p\<close> have "p dvd n" by (rule prime_dvd_power_nat)
with dvd_m have "p dvd gcd m n" by (rule gcd_greatest_nat)
with gcd have "p dvd 1" by simp
then have "p \<le> 1" by (simp add: dvd_imp_le)
@@ -84,9 +85,9 @@
qed
-text {* Another old chestnut, which is a consequence of the irrationality of 2. *}
+text \<open>Another old chestnut, which is a consequence of the irrationality of 2.\<close>
-lemma "\<exists>a b::real. a \<notin> \<rat> \<and> b \<notin> \<rat> \<and> a powr b \<in> \<rat>" (is "EX a b. ?P a b")
+lemma "\<exists>a b::real. a \<notin> \<rat> \<and> b \<notin> \<rat> \<and> a powr b \<in> \<rat>" (is "\<exists>a b. ?P a b")
proof cases
assume "sqrt 2 powr sqrt 2 \<in> \<rat>"
then have "?P (sqrt 2) (sqrt 2)"