author huffman Sun, 24 Sep 2006 02:56:59 +0200 changeset 20687 fedb901be392 parent 20686 e3d2b881ed0f child 20688 690d866a165d
move root and sqrt stuff from Transcendental to NthRoot
 src/HOL/Hyperreal/NthRoot.thy file | annotate | diff | comparison | revisions src/HOL/Hyperreal/Transcendental.thy file | annotate | diff | comparison | revisions
```--- a/src/HOL/Hyperreal/NthRoot.thy	Sun Sep 24 01:04:44 2006 +0200
+++ b/src/HOL/Hyperreal/NthRoot.thy	Sun Sep 24 02:56:59 2006 +0200
@@ -10,6 +10,15 @@
imports SEQ
begin

+definition
+
+  root :: "[nat, real] \<Rightarrow> real"
+  "root n x = (THE u. (0 < x \<longrightarrow> 0 < u) \<and> (u ^ n = x))"
+
+  sqrt :: "real \<Rightarrow> real"
+  "sqrt x = root 2 x"
+
+
text {*
Various lemmas needed for this result. We follow the proof given by
John Lindsay Orr (\texttt{jorr@math.unl.edu}) in his Analysis
@@ -170,4 +179,211 @@
apply (drule_tac [4] x = y in realpow_less, auto)
done

+subsection {* Nth Root *}
+
+lemma real_root_zero [simp]: "root (Suc n) 0 = 0"
+apply (safe intro!: the_equality power_0_Suc elim!: realpow_zero_zero)
+done
+
+lemma real_root_pow_pos:
+     "0 < x ==> (root (Suc n) x) ^ (Suc n) = x"
+apply (simp add: root_def del: realpow_Suc)
+apply (drule_tac n="Suc n" in realpow_pos_nth_unique, simp)
+apply (erule theI' [THEN conjunct2])
+done
+
+lemma real_root_pow_pos2: "0 \<le> x ==> (root (Suc n) x) ^ (Suc n) = x"
+by (auto dest!: real_le_imp_less_or_eq dest: real_root_pow_pos)
+
+lemma real_root_pos:
+     "0 < x ==> root(Suc n) (x ^ (Suc n)) = x"
+apply (rule the_equality)
+apply (frule_tac [2] n = n in zero_less_power)
+apply (rule_tac x = u and y = x in linorder_cases)
+apply (drule_tac n1 = n and x = u in zero_less_Suc [THEN [3] realpow_less])
+apply (drule_tac [4] n1 = n and x = x in zero_less_Suc [THEN [3] realpow_less])
+apply (auto)
+done
+
+lemma real_root_pos2: "0 \<le> x ==> root(Suc n) (x ^ (Suc n)) = x"
+by (auto dest!: real_le_imp_less_or_eq real_root_pos)
+
+lemma real_root_gt_zero:
+     "0 < x ==> 0 < root (Suc n) x"
+apply (simp add: root_def del: realpow_Suc)
+apply (drule_tac n="Suc n" in realpow_pos_nth_unique, simp)
+apply (erule theI' [THEN conjunct1])
+done
+
+lemma real_root_pos_pos:
+     "0 < x ==> 0 \<le> root(Suc n) x"
+by (rule real_root_gt_zero [THEN order_less_imp_le])
+
+lemma real_root_pos_pos_le: "0 \<le> x ==> 0 \<le> root(Suc n) x"
+by (auto simp add: order_le_less real_root_gt_zero)
+
+lemma real_root_one [simp]: "root (Suc n) 1 = 1"
+apply (rule the_equality, auto)
+apply (rule ccontr)
+apply (rule_tac x = u and y = 1 in linorder_cases)
+apply (drule_tac n = n in realpow_Suc_less_one)
+apply (drule_tac [4] n = n in power_gt1_lemma)
+apply (auto)
+done
+
+
+subsection{*Square Root*}
+
+text{*needed because 2 is a binary numeral!*}
+lemma root_2_eq [simp]: "root 2 = root (Suc (Suc 0))"
+by (simp del: nat_numeral_0_eq_0 nat_numeral_1_eq_1
+
+lemma real_sqrt_zero [simp]: "sqrt 0 = 0"
+
+lemma real_sqrt_one [simp]: "sqrt 1 = 1"
+
+lemma real_sqrt_pow2_iff [iff]: "((sqrt x)\<twosuperior> = x) = (0 \<le> x)"
+apply (rule iffI)
+ apply (cut_tac r = "root 2 x" in realpow_two_le)
+apply (subst numeral_2_eq_2)
+apply (erule real_root_pow_pos2)
+done
+
+lemma [simp]: "(sqrt(u2\<twosuperior> + v2\<twosuperior>))\<twosuperior> = u2\<twosuperior> + v2\<twosuperior>"
+by (rule realpow_two_le_add_order [THEN real_sqrt_pow2_iff [THEN iffD2]])
+
+lemma real_sqrt_pow2 [simp]: "0 \<le> x ==> (sqrt x)\<twosuperior> = x"
+by (simp)
+
+lemma real_sqrt_abs_abs [simp]: "sqrt\<bar>x\<bar> ^ 2 = \<bar>x\<bar>"
+by (rule real_sqrt_pow2_iff [THEN iffD2], arith)
+
+lemma real_pow_sqrt_eq_sqrt_pow:
+      "0 \<le> x ==> (sqrt x)\<twosuperior> = sqrt(x\<twosuperior>)"
+apply (simp only: numeral_2_eq_2 real_root_pow_pos2 real_root_pos2)
+done
+
+lemma real_pow_sqrt_eq_sqrt_abs_pow2:
+     "0 \<le> x ==> (sqrt x)\<twosuperior> = sqrt(\<bar>x\<bar> ^ 2)"
+
+lemma real_sqrt_pow_abs: "0 \<le> x ==> (sqrt x)\<twosuperior> = \<bar>x\<bar>"
+apply (rule real_sqrt_abs_abs [THEN subst])
+apply (rule_tac x1 = x in real_pow_sqrt_eq_sqrt_abs_pow2 [THEN ssubst])
+apply (rule_tac [2] real_pow_sqrt_eq_sqrt_pow [symmetric])
+apply (assumption, arith)
+done
+
+lemma not_real_square_gt_zero [simp]: "(~ (0::real) < x*x) = (x = 0)"
+apply auto
+apply (cut_tac x = x and y = 0 in linorder_less_linear)
+done
+
+lemma real_sqrt_gt_zero: "0 < x ==> 0 < sqrt(x)"
+
+lemma real_sqrt_ge_zero: "0 \<le> x ==> 0 \<le> sqrt(x)"
+by (auto intro: real_sqrt_gt_zero simp add: order_le_less)
+
+lemma real_sqrt_mult_self_sum_ge_zero [simp]: "0 \<le> sqrt(x*x + y*y)"
+by (rule real_sqrt_ge_zero [OF real_mult_self_sum_ge_zero])
+
+
+(*we need to prove something like this:
+lemma "[|r ^ n = a; 0<n; 0 < a \<longrightarrow> 0 < r|] ==> root n a = r"
+apply (case_tac n, simp)
+apply (rule someI2 [of _ r], safe)
+apply (auto simp del: realpow_Suc dest: power_inject_base)
+*)
+
+lemma sqrt_eqI: "[|r\<twosuperior> = a; 0 \<le> r|] ==> sqrt a = r"
+apply (erule subst)
+apply (simp add: sqrt_def numeral_2_eq_2 del: realpow_Suc)
+apply (erule real_root_pos2)
+done
+
+lemma real_sqrt_mult_distrib:
+     "[| 0 \<le> x; 0 \<le> y |] ==> sqrt(x*y) = sqrt(x) * sqrt(y)"
+apply (rule sqrt_eqI)
+done
+
+lemma real_sqrt_mult_distrib2:
+     "[|0\<le>x; 0\<le>y |] ==> sqrt(x*y) =  sqrt(x) * sqrt(y)"
+by (auto intro: real_sqrt_mult_distrib simp add: order_le_less)
+
+lemma real_sqrt_sum_squares_ge_zero [simp]: "0 \<le> sqrt (x\<twosuperior> + y\<twosuperior>)"
+by (auto intro!: real_sqrt_ge_zero)
+
+lemma real_sqrt_sum_squares_mult_ge_zero [simp]:
+     "0 \<le> sqrt ((x\<twosuperior> + y\<twosuperior>)*(xa\<twosuperior> + ya\<twosuperior>))"
+by (auto intro!: real_sqrt_ge_zero simp add: zero_le_mult_iff)
+
+lemma real_sqrt_sum_squares_mult_squared_eq [simp]:
+     "sqrt ((x\<twosuperior> + y\<twosuperior>) * (xa\<twosuperior> + ya\<twosuperior>)) ^ 2 = (x\<twosuperior> + y\<twosuperior>) * (xa\<twosuperior> + ya\<twosuperior>)"
+by (auto simp add: zero_le_mult_iff simp del: realpow_Suc)
+
+lemma real_sqrt_abs [simp]: "sqrt(x\<twosuperior>) = \<bar>x\<bar>"
+apply (rule abs_realpow_two [THEN subst])
+apply (rule real_sqrt_abs_abs [THEN subst])
+apply (subst real_pow_sqrt_eq_sqrt_pow)
+done
+
+lemma real_sqrt_abs2 [simp]: "sqrt(x*x) = \<bar>x\<bar>"
+apply (rule realpow_two [THEN subst])
+apply (subst numeral_2_eq_2 [symmetric])
+apply (rule real_sqrt_abs)
+done
+
+lemma real_sqrt_pow2_gt_zero: "0 < x ==> 0 < (sqrt x)\<twosuperior>"
+by simp
+
+lemma real_sqrt_not_eq_zero: "0 < x ==> sqrt x \<noteq> 0"
+apply (frule real_sqrt_pow2_gt_zero)
+done
+
+lemma real_inv_sqrt_pow2: "0 < x ==> inverse (sqrt(x)) ^ 2 = inverse x"
+by (cut_tac n1 = 2 and a1 = "sqrt x" in power_inverse [symmetric], auto)
+
+lemma real_sqrt_eq_zero_cancel: "[| 0 \<le> x; sqrt(x) = 0|] ==> x = 0"
+apply (drule real_le_imp_less_or_eq)
+apply (auto dest: real_sqrt_not_eq_zero)
+done
+
+lemma real_sqrt_eq_zero_cancel_iff [simp]: "0 \<le> x ==> ((sqrt x = 0) = (x=0))"
+
+lemma real_sqrt_sum_squares_ge1 [simp]: "x \<le> sqrt(x\<twosuperior> + y\<twosuperior>)"
+apply (subgoal_tac "x \<le> 0 | 0 \<le> x", safe)
+apply (rule real_le_trans)
+apply (auto simp del: realpow_Suc)
+apply (rule_tac n = 1 in realpow_increasing)
+apply (auto simp add: numeral_2_eq_2 [symmetric] simp del: realpow_Suc)
+done
+
+lemma real_sqrt_sum_squares_ge2 [simp]: "y \<le> sqrt(z\<twosuperior> + y\<twosuperior>)"
+done
+
+lemma real_sqrt_ge_one: "1 \<le> x ==> 1 \<le> sqrt x"
+apply (rule_tac n = 1 in realpow_increasing)
+apply (auto simp add: numeral_2_eq_2 [symmetric] real_sqrt_ge_zero simp
+            del: realpow_Suc)
+done
+
end```
```--- a/src/HOL/Hyperreal/Transcendental.thy	Sun Sep 24 01:04:44 2006 +0200
+++ b/src/HOL/Hyperreal/Transcendental.thy	Sun Sep 24 02:56:59 2006 +0200
@@ -12,11 +12,6 @@
begin

definition
-  root :: "[nat,real] => real"
-  "root n x = (THE u. ((0::real) < x --> 0 < u) & (u ^ n = x))"
-
-  sqrt :: "real => real"
-  "sqrt x = root 2 x"

exp :: "real => real"
"exp x = (\<Sum>n. inverse(real (fact n)) * (x ^ n))"
@@ -51,211 +46,6 @@
"arctan y = (SOME x. -(pi/2) < x & x < pi/2 & tan x = y)"

-lemma real_root_zero [simp]: "root (Suc n) 0 = 0"
-apply (safe intro!: the_equality power_0_Suc elim!: realpow_zero_zero)
-done
-
-lemma real_root_pow_pos:
-     "0 < x ==> (root (Suc n) x) ^ (Suc n) = x"
-apply (simp add: root_def del: realpow_Suc)
-apply (drule_tac n="Suc n" in realpow_pos_nth_unique, simp)
-apply (erule theI' [THEN conjunct2])
-done
-
-lemma real_root_pow_pos2: "0 \<le> x ==> (root (Suc n) x) ^ (Suc n) = x"
-by (auto dest!: real_le_imp_less_or_eq dest: real_root_pow_pos)
-
-lemma real_root_pos:
-     "0 < x ==> root(Suc n) (x ^ (Suc n)) = x"
-apply (rule the_equality)
-apply (frule_tac [2] n = n in zero_less_power)
-apply (rule_tac x = u and y = x in linorder_cases)
-apply (drule_tac n1 = n and x = u in zero_less_Suc [THEN [3] realpow_less])
-apply (drule_tac [4] n1 = n and x = x in zero_less_Suc [THEN [3] realpow_less])
-apply (auto)
-done
-
-lemma real_root_pos2: "0 \<le> x ==> root(Suc n) (x ^ (Suc n)) = x"
-by (auto dest!: real_le_imp_less_or_eq real_root_pos)
-
-lemma real_root_gt_zero:
-     "0 < x ==> 0 < root (Suc n) x"
-apply (simp add: root_def del: realpow_Suc)
-apply (drule_tac n="Suc n" in realpow_pos_nth_unique, simp)
-apply (erule theI' [THEN conjunct1])
-done
-
-lemma real_root_pos_pos:
-     "0 < x ==> 0 \<le> root(Suc n) x"
-by (rule real_root_gt_zero [THEN order_less_imp_le])
-
-lemma real_root_pos_pos_le: "0 \<le> x ==> 0 \<le> root(Suc n) x"
-by (auto simp add: order_le_less real_root_gt_zero)
-
-lemma real_root_one [simp]: "root (Suc n) 1 = 1"
-apply (rule the_equality, auto)
-apply (rule ccontr)
-apply (rule_tac x = u and y = 1 in linorder_cases)
-apply (drule_tac n = n in realpow_Suc_less_one)
-apply (drule_tac [4] n = n in power_gt1_lemma)
-apply (auto)
-done
-
-
-subsection{*Square Root*}
-
-text{*needed because 2 is a binary numeral!*}
-lemma root_2_eq [simp]: "root 2 = root (Suc (Suc 0))"
-by (simp del: nat_numeral_0_eq_0 nat_numeral_1_eq_1
-
-lemma real_sqrt_zero [simp]: "sqrt 0 = 0"
-
-lemma real_sqrt_one [simp]: "sqrt 1 = 1"
-
-lemma real_sqrt_pow2_iff [iff]: "((sqrt x)\<twosuperior> = x) = (0 \<le> x)"
-apply (rule iffI)
- apply (cut_tac r = "root 2 x" in realpow_two_le)
-apply (subst numeral_2_eq_2)
-apply (erule real_root_pow_pos2)
-done
-
-lemma [simp]: "(sqrt(u2\<twosuperior> + v2\<twosuperior>))\<twosuperior> = u2\<twosuperior> + v2\<twosuperior>"
-by (rule realpow_two_le_add_order [THEN real_sqrt_pow2_iff [THEN iffD2]])
-
-lemma real_sqrt_pow2 [simp]: "0 \<le> x ==> (sqrt x)\<twosuperior> = x"
-by (simp)
-
-lemma real_sqrt_abs_abs [simp]: "sqrt\<bar>x\<bar> ^ 2 = \<bar>x\<bar>"
-by (rule real_sqrt_pow2_iff [THEN iffD2], arith)
-
-lemma real_pow_sqrt_eq_sqrt_pow:
-      "0 \<le> x ==> (sqrt x)\<twosuperior> = sqrt(x\<twosuperior>)"
-apply (simp only: numeral_2_eq_2 real_root_pow_pos2 real_root_pos2)
-done
-
-lemma real_pow_sqrt_eq_sqrt_abs_pow2:
-     "0 \<le> x ==> (sqrt x)\<twosuperior> = sqrt(\<bar>x\<bar> ^ 2)"
-
-lemma real_sqrt_pow_abs: "0 \<le> x ==> (sqrt x)\<twosuperior> = \<bar>x\<bar>"
-apply (rule real_sqrt_abs_abs [THEN subst])
-apply (rule_tac x1 = x in real_pow_sqrt_eq_sqrt_abs_pow2 [THEN ssubst])
-apply (rule_tac [2] real_pow_sqrt_eq_sqrt_pow [symmetric])
-apply (assumption, arith)
-done
-
-lemma not_real_square_gt_zero [simp]: "(~ (0::real) < x*x) = (x = 0)"
-apply auto
-apply (cut_tac x = x and y = 0 in linorder_less_linear)
-done
-
-lemma real_sqrt_gt_zero: "0 < x ==> 0 < sqrt(x)"
-
-lemma real_sqrt_ge_zero: "0 \<le> x ==> 0 \<le> sqrt(x)"
-by (auto intro: real_sqrt_gt_zero simp add: order_le_less)
-
-lemma real_sqrt_mult_self_sum_ge_zero [simp]: "0 \<le> sqrt(x*x + y*y)"
-by (rule real_sqrt_ge_zero [OF real_mult_self_sum_ge_zero])
-
-
-(*we need to prove something like this:
-lemma "[|r ^ n = a; 0<n; 0 < a \<longrightarrow> 0 < r|] ==> root n a = r"
-apply (case_tac n, simp)
-apply (rule someI2 [of _ r], safe)
-apply (auto simp del: realpow_Suc dest: power_inject_base)
-*)
-
-lemma sqrt_eqI: "[|r\<twosuperior> = a; 0 \<le> r|] ==> sqrt a = r"
-apply (erule subst)
-apply (simp add: sqrt_def numeral_2_eq_2 del: realpow_Suc)
-apply (erule real_root_pos2)
-done
-
-lemma real_sqrt_mult_distrib:
-     "[| 0 \<le> x; 0 \<le> y |] ==> sqrt(x*y) = sqrt(x) * sqrt(y)"
-apply (rule sqrt_eqI)
-done
-
-lemma real_sqrt_mult_distrib2:
-     "[|0\<le>x; 0\<le>y |] ==> sqrt(x*y) =  sqrt(x) * sqrt(y)"
-by (auto intro: real_sqrt_mult_distrib simp add: order_le_less)
-
-lemma real_sqrt_sum_squares_ge_zero [simp]: "0 \<le> sqrt (x\<twosuperior> + y\<twosuperior>)"
-by (auto intro!: real_sqrt_ge_zero)
-
-lemma real_sqrt_sum_squares_mult_ge_zero [simp]:
-     "0 \<le> sqrt ((x\<twosuperior> + y\<twosuperior>)*(xa\<twosuperior> + ya\<twosuperior>))"
-by (auto intro!: real_sqrt_ge_zero simp add: zero_le_mult_iff)
-
-lemma real_sqrt_sum_squares_mult_squared_eq [simp]:
-     "sqrt ((x\<twosuperior> + y\<twosuperior>) * (xa\<twosuperior> + ya\<twosuperior>)) ^ 2 = (x\<twosuperior> + y\<twosuperior>) * (xa\<twosuperior> + ya\<twosuperior>)"
-by (auto simp add: zero_le_mult_iff simp del: realpow_Suc)
-
-lemma real_sqrt_abs [simp]: "sqrt(x\<twosuperior>) = \<bar>x\<bar>"
-apply (rule abs_realpow_two [THEN subst])
-apply (rule real_sqrt_abs_abs [THEN subst])
-apply (subst real_pow_sqrt_eq_sqrt_pow)
-done
-
-lemma real_sqrt_abs2 [simp]: "sqrt(x*x) = \<bar>x\<bar>"
-apply (rule realpow_two [THEN subst])
-apply (subst numeral_2_eq_2 [symmetric])
-apply (rule real_sqrt_abs)
-done
-
-lemma real_sqrt_pow2_gt_zero: "0 < x ==> 0 < (sqrt x)\<twosuperior>"
-by simp
-
-lemma real_sqrt_not_eq_zero: "0 < x ==> sqrt x \<noteq> 0"
-apply (frule real_sqrt_pow2_gt_zero)
-done
-
-lemma real_inv_sqrt_pow2: "0 < x ==> inverse (sqrt(x)) ^ 2 = inverse x"
-by (cut_tac n1 = 2 and a1 = "sqrt x" in power_inverse [symmetric], auto)
-
-lemma real_sqrt_eq_zero_cancel: "[| 0 \<le> x; sqrt(x) = 0|] ==> x = 0"
-apply (drule real_le_imp_less_or_eq)
-apply (auto dest: real_sqrt_not_eq_zero)
-done
-
-lemma real_sqrt_eq_zero_cancel_iff [simp]: "0 \<le> x ==> ((sqrt x = 0) = (x=0))"
-
-lemma real_sqrt_sum_squares_ge1 [simp]: "x \<le> sqrt(x\<twosuperior> + y\<twosuperior>)"
-apply (subgoal_tac "x \<le> 0 | 0 \<le> x", safe)
-apply (rule real_le_trans)
-apply (auto simp del: realpow_Suc)
-apply (rule_tac n = 1 in realpow_increasing)
-apply (auto simp add: numeral_2_eq_2 [symmetric] simp del: realpow_Suc)
-done
-
-lemma real_sqrt_sum_squares_ge2 [simp]: "y \<le> sqrt(z\<twosuperior> + y\<twosuperior>)"