src/HOL/Hyperreal/NthRoot.thy
 author wenzelm Mon Oct 09 02:19:51 2006 +0200 (2006-10-09) changeset 20898 113c9516a2d7 parent 20687 fedb901be392 child 21404 eb85850d3eb7 permissions -rw-r--r--
attribute symmetric: zero_var_indexes;
 paulson@12196 ` 1` ```(* Title : NthRoot.thy ``` paulson@12196 ` 2` ``` Author : Jacques D. Fleuriot ``` paulson@12196 ` 3` ``` Copyright : 1998 University of Cambridge ``` paulson@14477 ` 4` ``` Conversion to Isar and new proofs by Lawrence C Paulson, 2004 ``` paulson@12196 ` 5` ```*) ``` paulson@12196 ` 6` paulson@14324 ` 7` ```header{*Existence of Nth Root*} ``` paulson@14324 ` 8` nipkow@15131 ` 9` ```theory NthRoot ``` huffman@20515 ` 10` ```imports SEQ ``` nipkow@15131 ` 11` ```begin ``` paulson@14324 ` 12` huffman@20687 ` 13` ```definition ``` huffman@20687 ` 14` huffman@20687 ` 15` ``` root :: "[nat, real] \ real" ``` huffman@20687 ` 16` ``` "root n x = (THE u. (0 < x \ 0 < u) \ (u ^ n = x))" ``` huffman@20687 ` 17` huffman@20687 ` 18` ``` sqrt :: "real \ real" ``` huffman@20687 ` 19` ``` "sqrt x = root 2 x" ``` huffman@20687 ` 20` huffman@20687 ` 21` wenzelm@14767 ` 22` ```text {* ``` wenzelm@14767 ` 23` ``` Various lemmas needed for this result. We follow the proof given by ``` wenzelm@14767 ` 24` ``` John Lindsay Orr (\texttt{jorr@math.unl.edu}) in his Analysis ``` wenzelm@14767 ` 25` ``` Webnotes available at \url{http://www.math.unl.edu/~webnotes}. ``` wenzelm@14767 ` 26` wenzelm@14767 ` 27` ``` Lemmas about sequences of reals are used to reach the result. ``` wenzelm@14767 ` 28` ```*} ``` paulson@14324 ` 29` paulson@14324 ` 30` ```lemma lemma_nth_realpow_non_empty: ``` paulson@14324 ` 31` ``` "[| (0::real) < a; 0 < n |] ==> \s. s : {x. x ^ n <= a & 0 < x}" ``` paulson@14324 ` 32` ```apply (case_tac "1 <= a") ``` paulson@14477 ` 33` ```apply (rule_tac x = 1 in exI) ``` paulson@14334 ` 34` ```apply (drule_tac [2] linorder_not_le [THEN iffD1]) ``` paulson@14477 ` 35` ```apply (drule_tac [2] less_not_refl2 [THEN not0_implies_Suc], simp) ``` paulson@14348 ` 36` ```apply (force intro!: realpow_Suc_le_self simp del: realpow_Suc) ``` paulson@14324 ` 37` ```done ``` paulson@14324 ` 38` paulson@14348 ` 39` ```text{*Used only just below*} ``` paulson@14348 ` 40` ```lemma realpow_ge_self2: "[| (1::real) \ r; 0 < n |] ==> r \ r ^ n" ``` paulson@14348 ` 41` ```by (insert power_increasing [of 1 n r], simp) ``` paulson@14348 ` 42` paulson@14324 ` 43` ```lemma lemma_nth_realpow_isUb_ex: ``` paulson@14324 ` 44` ``` "[| (0::real) < a; 0 < n |] ``` paulson@14324 ` 45` ``` ==> \u. isUb (UNIV::real set) {x. x ^ n <= a & 0 < x} u" ``` paulson@14324 ` 46` ```apply (case_tac "1 <= a") ``` paulson@14477 ` 47` ```apply (rule_tac x = a in exI) ``` paulson@14334 ` 48` ```apply (drule_tac [2] linorder_not_le [THEN iffD1]) ``` paulson@14477 ` 49` ```apply (rule_tac [2] x = 1 in exI) ``` paulson@14477 ` 50` ```apply (rule_tac [!] setleI [THEN isUbI], safe) ``` paulson@14324 ` 51` ```apply (simp_all (no_asm)) ``` paulson@14324 ` 52` ```apply (rule_tac [!] ccontr) ``` paulson@14334 ` 53` ```apply (drule_tac [!] linorder_not_le [THEN iffD1]) ``` paulson@14477 ` 54` ```apply (drule realpow_ge_self2, assumption) ``` paulson@14477 ` 55` ```apply (drule_tac n = n in realpow_less) ``` paulson@14324 ` 56` ```apply (assumption+) ``` paulson@14477 ` 57` ```apply (drule real_le_trans, assumption) ``` paulson@14477 ` 58` ```apply (drule_tac y = "y ^ n" in order_less_le_trans, assumption, simp) ``` paulson@14477 ` 59` ```apply (drule_tac n = n in zero_less_one [THEN realpow_less], auto) ``` paulson@14324 ` 60` ```done ``` paulson@14324 ` 61` paulson@14324 ` 62` ```lemma nth_realpow_isLub_ex: ``` paulson@14324 ` 63` ``` "[| (0::real) < a; 0 < n |] ``` paulson@14324 ` 64` ``` ==> \u. isLub (UNIV::real set) {x. x ^ n <= a & 0 < x} u" ``` paulson@14365 ` 65` ```by (blast intro: lemma_nth_realpow_isUb_ex lemma_nth_realpow_non_empty reals_complete) ``` paulson@14365 ` 66` paulson@14324 ` 67` ``` ``` paulson@14324 ` 68` ```subsection{*First Half -- Lemmas First*} ``` paulson@14324 ` 69` paulson@14324 ` 70` ```lemma lemma_nth_realpow_seq: ``` paulson@14324 ` 71` ``` "isLub (UNIV::real set) {x. x ^ n <= a & (0::real) < x} u ``` paulson@14324 ` 72` ``` ==> u + inverse(real (Suc k)) ~: {x. x ^ n <= a & 0 < x}" ``` paulson@14477 ` 73` ```apply (safe, drule isLubD2, blast) ``` paulson@14365 ` 74` ```apply (simp add: linorder_not_less [symmetric]) ``` paulson@14324 ` 75` ```done ``` paulson@14324 ` 76` paulson@14324 ` 77` ```lemma lemma_nth_realpow_isLub_gt_zero: ``` paulson@14324 ` 78` ``` "[| isLub (UNIV::real set) {x. x ^ n <= a & (0::real) < x} u; ``` paulson@14324 ` 79` ``` 0 < a; 0 < n |] ==> 0 < u" ``` paulson@14477 ` 80` ```apply (drule lemma_nth_realpow_non_empty, auto) ``` paulson@14477 ` 81` ```apply (drule_tac y = s in isLub_isUb [THEN isUbD]) ``` paulson@14324 ` 82` ```apply (auto intro: order_less_le_trans) ``` paulson@14324 ` 83` ```done ``` paulson@14324 ` 84` paulson@14324 ` 85` ```lemma lemma_nth_realpow_isLub_ge: ``` paulson@14324 ` 86` ``` "[| isLub (UNIV::real set) {x. x ^ n <= a & (0::real) < x} u; ``` paulson@14324 ` 87` ``` 0 < a; 0 < n |] ==> ALL k. a <= (u + inverse(real (Suc k))) ^ n" ``` paulson@14477 ` 88` ```apply safe ``` paulson@14477 ` 89` ```apply (frule lemma_nth_realpow_seq, safe) ``` paulson@15085 ` 90` ```apply (auto elim: order_less_asym simp add: linorder_not_less [symmetric] ``` paulson@15085 ` 91` ``` iff: real_0_less_add_iff) --{*legacy iff rule!*} ``` paulson@14365 ` 92` ```apply (simp add: linorder_not_less) ``` paulson@14324 ` 93` ```apply (rule order_less_trans [of _ 0]) ``` paulson@14325 ` 94` ```apply (auto intro: lemma_nth_realpow_isLub_gt_zero) ``` paulson@14324 ` 95` ```done ``` paulson@14324 ` 96` paulson@14324 ` 97` ```text{*First result we want*} ``` paulson@14324 ` 98` ```lemma realpow_nth_ge: ``` paulson@14324 ` 99` ``` "[| (0::real) < a; 0 < n; ``` paulson@14324 ` 100` ``` isLub (UNIV::real set) ``` paulson@14324 ` 101` ``` {x. x ^ n <= a & 0 < x} u |] ==> a <= u ^ n" ``` paulson@14477 ` 102` ```apply (frule lemma_nth_realpow_isLub_ge, safe) ``` paulson@14324 ` 103` ```apply (rule LIMSEQ_inverse_real_of_nat_add [THEN LIMSEQ_pow, THEN LIMSEQ_le_const]) ``` paulson@14334 ` 104` ```apply (auto simp add: real_of_nat_def) ``` paulson@14324 ` 105` ```done ``` paulson@14324 ` 106` paulson@14324 ` 107` ```subsection{*Second Half*} ``` paulson@14324 ` 108` paulson@14324 ` 109` ```lemma less_isLub_not_isUb: ``` paulson@14324 ` 110` ``` "[| isLub (UNIV::real set) S u; x < u |] ``` paulson@14324 ` 111` ``` ==> ~ isUb (UNIV::real set) S x" ``` paulson@14477 ` 112` ```apply safe ``` paulson@14477 ` 113` ```apply (drule isLub_le_isUb, assumption) ``` paulson@14477 ` 114` ```apply (drule order_less_le_trans, auto) ``` paulson@14324 ` 115` ```done ``` paulson@14324 ` 116` paulson@14324 ` 117` ```lemma not_isUb_less_ex: ``` paulson@14324 ` 118` ``` "~ isUb (UNIV::real set) S u ==> \x \ S. u < x" ``` wenzelm@18585 ` 119` ```apply (rule ccontr, erule contrapos_np) ``` paulson@14324 ` 120` ```apply (rule setleI [THEN isUbI]) ``` paulson@14365 ` 121` ```apply (auto simp add: linorder_not_less [symmetric]) ``` paulson@14324 ` 122` ```done ``` paulson@14324 ` 123` paulson@14325 ` 124` ```lemma real_mult_less_self: "0 < r ==> r * (1 + -inverse(real (Suc n))) < r" ``` paulson@14334 ` 125` ```apply (simp (no_asm) add: right_distrib) ``` paulson@14334 ` 126` ```apply (rule add_less_cancel_left [of "-r", THEN iffD1]) ``` avigad@16775 ` 127` ```apply (auto intro: mult_pos_pos ``` paulson@14334 ` 128` ``` simp add: add_assoc [symmetric] neg_less_0_iff_less) ``` paulson@14325 ` 129` ```done ``` paulson@14325 ` 130` paulson@14325 ` 131` ```lemma real_mult_add_one_minus_ge_zero: ``` paulson@14325 ` 132` ``` "0 < r ==> 0 <= r*(1 + -inverse(real (Suc n)))" ``` paulson@15085 ` 133` ```by (simp add: zero_le_mult_iff real_of_nat_inverse_le_iff real_0_le_add_iff) ``` paulson@14325 ` 134` paulson@14324 ` 135` ```lemma lemma_nth_realpow_isLub_le: ``` paulson@14324 ` 136` ``` "[| isLub (UNIV::real set) {x. x ^ n <= a & (0::real) < x} u; ``` paulson@14325 ` 137` ``` 0 < a; 0 < n |] ==> ALL k. (u*(1 + -inverse(real (Suc k)))) ^ n <= a" ``` paulson@14477 ` 138` ```apply safe ``` paulson@14324 ` 139` ```apply (frule less_isLub_not_isUb [THEN not_isUb_less_ex]) ``` paulson@14477 ` 140` ```apply (rule_tac n = k in real_mult_less_self) ``` paulson@14477 ` 141` ```apply (blast intro: lemma_nth_realpow_isLub_gt_zero, safe) ``` paulson@14477 ` 142` ```apply (drule_tac n = k in ``` paulson@14477 ` 143` ``` lemma_nth_realpow_isLub_gt_zero [THEN real_mult_add_one_minus_ge_zero], assumption+) ``` paulson@14348 ` 144` ```apply (blast intro: order_trans order_less_imp_le power_mono) ``` paulson@14324 ` 145` ```done ``` paulson@14324 ` 146` paulson@14324 ` 147` ```text{*Second result we want*} ``` paulson@14324 ` 148` ```lemma realpow_nth_le: ``` paulson@14324 ` 149` ``` "[| (0::real) < a; 0 < n; ``` paulson@14324 ` 150` ``` isLub (UNIV::real set) ``` paulson@14324 ` 151` ``` {x. x ^ n <= a & 0 < x} u |] ==> u ^ n <= a" ``` paulson@14477 ` 152` ```apply (frule lemma_nth_realpow_isLub_le, safe) ``` paulson@14348 ` 153` ```apply (rule LIMSEQ_inverse_real_of_nat_add_minus_mult ``` paulson@14348 ` 154` ``` [THEN LIMSEQ_pow, THEN LIMSEQ_le_const2]) ``` paulson@14334 ` 155` ```apply (auto simp add: real_of_nat_def) ``` paulson@14324 ` 156` ```done ``` paulson@14324 ` 157` paulson@14348 ` 158` ```text{*The theorem at last!*} ``` paulson@14324 ` 159` ```lemma realpow_nth: "[| (0::real) < a; 0 < n |] ==> \r. r ^ n = a" ``` paulson@14477 ` 160` ```apply (frule nth_realpow_isLub_ex, auto) ``` paulson@14477 ` 161` ```apply (auto intro: realpow_nth_le realpow_nth_ge order_antisym) ``` paulson@14324 ` 162` ```done ``` paulson@14324 ` 163` paulson@14324 ` 164` ```(* positive only *) ``` paulson@14324 ` 165` ```lemma realpow_pos_nth: "[| (0::real) < a; 0 < n |] ==> \r. 0 < r & r ^ n = a" ``` paulson@14477 ` 166` ```apply (frule nth_realpow_isLub_ex, auto) ``` paulson@14477 ` 167` ```apply (auto intro: realpow_nth_le realpow_nth_ge order_antisym lemma_nth_realpow_isLub_gt_zero) ``` paulson@14324 ` 168` ```done ``` paulson@14324 ` 169` paulson@14324 ` 170` ```lemma realpow_pos_nth2: "(0::real) < a ==> \r. 0 < r & r ^ Suc n = a" ``` paulson@14477 ` 171` ```by (blast intro: realpow_pos_nth) ``` paulson@14324 ` 172` paulson@14324 ` 173` ```(* uniqueness of nth positive root *) ``` paulson@14324 ` 174` ```lemma realpow_pos_nth_unique: ``` paulson@14324 ` 175` ``` "[| (0::real) < a; 0 < n |] ==> EX! r. 0 < r & r ^ n = a" ``` paulson@14324 ` 176` ```apply (auto intro!: realpow_pos_nth) ``` paulson@14477 ` 177` ```apply (cut_tac x = r and y = y in linorder_less_linear, auto) ``` paulson@14477 ` 178` ```apply (drule_tac x = r in realpow_less) ``` paulson@14477 ` 179` ```apply (drule_tac [4] x = y in realpow_less, auto) ``` paulson@14324 ` 180` ```done ``` paulson@14324 ` 181` huffman@20687 ` 182` ```subsection {* Nth Root *} ``` huffman@20687 ` 183` huffman@20687 ` 184` ```lemma real_root_zero [simp]: "root (Suc n) 0 = 0" ``` huffman@20687 ` 185` ```apply (simp add: root_def) ``` huffman@20687 ` 186` ```apply (safe intro!: the_equality power_0_Suc elim!: realpow_zero_zero) ``` huffman@20687 ` 187` ```done ``` huffman@20687 ` 188` huffman@20687 ` 189` ```lemma real_root_pow_pos: ``` huffman@20687 ` 190` ``` "0 < x ==> (root (Suc n) x) ^ (Suc n) = x" ``` huffman@20687 ` 191` ```apply (simp add: root_def del: realpow_Suc) ``` huffman@20687 ` 192` ```apply (drule_tac n="Suc n" in realpow_pos_nth_unique, simp) ``` huffman@20687 ` 193` ```apply (erule theI' [THEN conjunct2]) ``` huffman@20687 ` 194` ```done ``` huffman@20687 ` 195` huffman@20687 ` 196` ```lemma real_root_pow_pos2: "0 \ x ==> (root (Suc n) x) ^ (Suc n) = x" ``` huffman@20687 ` 197` ```by (auto dest!: real_le_imp_less_or_eq dest: real_root_pow_pos) ``` huffman@20687 ` 198` huffman@20687 ` 199` ```lemma real_root_pos: ``` huffman@20687 ` 200` ``` "0 < x ==> root(Suc n) (x ^ (Suc n)) = x" ``` huffman@20687 ` 201` ```apply (simp add: root_def) ``` huffman@20687 ` 202` ```apply (rule the_equality) ``` huffman@20687 ` 203` ```apply (frule_tac [2] n = n in zero_less_power) ``` huffman@20687 ` 204` ```apply (auto simp add: zero_less_mult_iff) ``` huffman@20687 ` 205` ```apply (rule_tac x = u and y = x in linorder_cases) ``` huffman@20687 ` 206` ```apply (drule_tac n1 = n and x = u in zero_less_Suc [THEN [3] realpow_less]) ``` huffman@20687 ` 207` ```apply (drule_tac [4] n1 = n and x = x in zero_less_Suc [THEN [3] realpow_less]) ``` huffman@20687 ` 208` ```apply (auto) ``` huffman@20687 ` 209` ```done ``` huffman@20687 ` 210` huffman@20687 ` 211` ```lemma real_root_pos2: "0 \ x ==> root(Suc n) (x ^ (Suc n)) = x" ``` huffman@20687 ` 212` ```by (auto dest!: real_le_imp_less_or_eq real_root_pos) ``` huffman@20687 ` 213` huffman@20687 ` 214` ```lemma real_root_gt_zero: ``` huffman@20687 ` 215` ``` "0 < x ==> 0 < root (Suc n) x" ``` huffman@20687 ` 216` ```apply (simp add: root_def del: realpow_Suc) ``` huffman@20687 ` 217` ```apply (drule_tac n="Suc n" in realpow_pos_nth_unique, simp) ``` huffman@20687 ` 218` ```apply (erule theI' [THEN conjunct1]) ``` huffman@20687 ` 219` ```done ``` huffman@20687 ` 220` huffman@20687 ` 221` ```lemma real_root_pos_pos: ``` huffman@20687 ` 222` ``` "0 < x ==> 0 \ root(Suc n) x" ``` huffman@20687 ` 223` ```by (rule real_root_gt_zero [THEN order_less_imp_le]) ``` huffman@20687 ` 224` huffman@20687 ` 225` ```lemma real_root_pos_pos_le: "0 \ x ==> 0 \ root(Suc n) x" ``` huffman@20687 ` 226` ```by (auto simp add: order_le_less real_root_gt_zero) ``` huffman@20687 ` 227` huffman@20687 ` 228` ```lemma real_root_one [simp]: "root (Suc n) 1 = 1" ``` huffman@20687 ` 229` ```apply (simp add: root_def) ``` huffman@20687 ` 230` ```apply (rule the_equality, auto) ``` huffman@20687 ` 231` ```apply (rule ccontr) ``` huffman@20687 ` 232` ```apply (rule_tac x = u and y = 1 in linorder_cases) ``` huffman@20687 ` 233` ```apply (drule_tac n = n in realpow_Suc_less_one) ``` huffman@20687 ` 234` ```apply (drule_tac [4] n = n in power_gt1_lemma) ``` huffman@20687 ` 235` ```apply (auto) ``` huffman@20687 ` 236` ```done ``` huffman@20687 ` 237` huffman@20687 ` 238` huffman@20687 ` 239` ```subsection{*Square Root*} ``` huffman@20687 ` 240` huffman@20687 ` 241` ```text{*needed because 2 is a binary numeral!*} ``` huffman@20687 ` 242` ```lemma root_2_eq [simp]: "root 2 = root (Suc (Suc 0))" ``` huffman@20687 ` 243` ```by (simp del: nat_numeral_0_eq_0 nat_numeral_1_eq_1 ``` huffman@20687 ` 244` ``` add: nat_numeral_0_eq_0 [symmetric]) ``` huffman@20687 ` 245` huffman@20687 ` 246` ```lemma real_sqrt_zero [simp]: "sqrt 0 = 0" ``` huffman@20687 ` 247` ```by (simp add: sqrt_def) ``` huffman@20687 ` 248` huffman@20687 ` 249` ```lemma real_sqrt_one [simp]: "sqrt 1 = 1" ``` huffman@20687 ` 250` ```by (simp add: sqrt_def) ``` huffman@20687 ` 251` huffman@20687 ` 252` ```lemma real_sqrt_pow2_iff [iff]: "((sqrt x)\ = x) = (0 \ x)" ``` huffman@20687 ` 253` ```apply (simp add: sqrt_def) ``` huffman@20687 ` 254` ```apply (rule iffI) ``` huffman@20687 ` 255` ``` apply (cut_tac r = "root 2 x" in realpow_two_le) ``` huffman@20687 ` 256` ``` apply (simp add: numeral_2_eq_2) ``` huffman@20687 ` 257` ```apply (subst numeral_2_eq_2) ``` huffman@20687 ` 258` ```apply (erule real_root_pow_pos2) ``` huffman@20687 ` 259` ```done ``` huffman@20687 ` 260` huffman@20687 ` 261` ```lemma [simp]: "(sqrt(u2\ + v2\))\ = u2\ + v2\" ``` huffman@20687 ` 262` ```by (rule realpow_two_le_add_order [THEN real_sqrt_pow2_iff [THEN iffD2]]) ``` huffman@20687 ` 263` huffman@20687 ` 264` ```lemma real_sqrt_pow2 [simp]: "0 \ x ==> (sqrt x)\ = x" ``` huffman@20687 ` 265` ```by (simp) ``` huffman@20687 ` 266` huffman@20687 ` 267` ```lemma real_sqrt_abs_abs [simp]: "sqrt\x\ ^ 2 = \x\" ``` huffman@20687 ` 268` ```by (rule real_sqrt_pow2_iff [THEN iffD2], arith) ``` huffman@20687 ` 269` huffman@20687 ` 270` ```lemma real_pow_sqrt_eq_sqrt_pow: ``` huffman@20687 ` 271` ``` "0 \ x ==> (sqrt x)\ = sqrt(x\)" ``` huffman@20687 ` 272` ```apply (simp add: sqrt_def) ``` huffman@20687 ` 273` ```apply (simp only: numeral_2_eq_2 real_root_pow_pos2 real_root_pos2) ``` huffman@20687 ` 274` ```done ``` huffman@20687 ` 275` huffman@20687 ` 276` ```lemma real_pow_sqrt_eq_sqrt_abs_pow2: ``` huffman@20687 ` 277` ``` "0 \ x ==> (sqrt x)\ = sqrt(\x\ ^ 2)" ``` huffman@20687 ` 278` ```by (simp add: real_pow_sqrt_eq_sqrt_pow [symmetric]) ``` huffman@20687 ` 279` huffman@20687 ` 280` ```lemma real_sqrt_pow_abs: "0 \ x ==> (sqrt x)\ = \x\" ``` huffman@20687 ` 281` ```apply (rule real_sqrt_abs_abs [THEN subst]) ``` huffman@20687 ` 282` ```apply (rule_tac x1 = x in real_pow_sqrt_eq_sqrt_abs_pow2 [THEN ssubst]) ``` huffman@20687 ` 283` ```apply (rule_tac [2] real_pow_sqrt_eq_sqrt_pow [symmetric]) ``` huffman@20687 ` 284` ```apply (assumption, arith) ``` huffman@20687 ` 285` ```done ``` huffman@20687 ` 286` huffman@20687 ` 287` ```lemma not_real_square_gt_zero [simp]: "(~ (0::real) < x*x) = (x = 0)" ``` huffman@20687 ` 288` ```apply auto ``` huffman@20687 ` 289` ```apply (cut_tac x = x and y = 0 in linorder_less_linear) ``` huffman@20687 ` 290` ```apply (simp add: zero_less_mult_iff) ``` huffman@20687 ` 291` ```done ``` huffman@20687 ` 292` huffman@20687 ` 293` ```lemma real_sqrt_gt_zero: "0 < x ==> 0 < sqrt(x)" ``` huffman@20687 ` 294` ```by (simp add: sqrt_def real_root_gt_zero) ``` huffman@20687 ` 295` huffman@20687 ` 296` ```lemma real_sqrt_ge_zero: "0 \ x ==> 0 \ sqrt(x)" ``` huffman@20687 ` 297` ```by (auto intro: real_sqrt_gt_zero simp add: order_le_less) ``` huffman@20687 ` 298` huffman@20687 ` 299` ```lemma real_sqrt_mult_self_sum_ge_zero [simp]: "0 \ sqrt(x*x + y*y)" ``` huffman@20687 ` 300` ```by (rule real_sqrt_ge_zero [OF real_mult_self_sum_ge_zero]) ``` huffman@20687 ` 301` huffman@20687 ` 302` huffman@20687 ` 303` ```(*we need to prove something like this: ``` huffman@20687 ` 304` ```lemma "[|r ^ n = a; 0 0 < r|] ==> root n a = r" ``` huffman@20687 ` 305` ```apply (case_tac n, simp) ``` huffman@20687 ` 306` ```apply (simp add: root_def) ``` huffman@20687 ` 307` ```apply (rule someI2 [of _ r], safe) ``` huffman@20687 ` 308` ```apply (auto simp del: realpow_Suc dest: power_inject_base) ``` huffman@20687 ` 309` ```*) ``` huffman@20687 ` 310` huffman@20687 ` 311` ```lemma sqrt_eqI: "[|r\ = a; 0 \ r|] ==> sqrt a = r" ``` huffman@20687 ` 312` ```apply (erule subst) ``` huffman@20687 ` 313` ```apply (simp add: sqrt_def numeral_2_eq_2 del: realpow_Suc) ``` huffman@20687 ` 314` ```apply (erule real_root_pos2) ``` huffman@20687 ` 315` ```done ``` huffman@20687 ` 316` huffman@20687 ` 317` ```lemma real_sqrt_mult_distrib: ``` huffman@20687 ` 318` ``` "[| 0 \ x; 0 \ y |] ==> sqrt(x*y) = sqrt(x) * sqrt(y)" ``` huffman@20687 ` 319` ```apply (rule sqrt_eqI) ``` huffman@20687 ` 320` ```apply (simp add: power_mult_distrib) ``` huffman@20687 ` 321` ```apply (simp add: zero_le_mult_iff real_sqrt_ge_zero) ``` huffman@20687 ` 322` ```done ``` huffman@20687 ` 323` huffman@20687 ` 324` ```lemma real_sqrt_mult_distrib2: ``` huffman@20687 ` 325` ``` "[|0\x; 0\y |] ==> sqrt(x*y) = sqrt(x) * sqrt(y)" ``` huffman@20687 ` 326` ```by (auto intro: real_sqrt_mult_distrib simp add: order_le_less) ``` huffman@20687 ` 327` huffman@20687 ` 328` ```lemma real_sqrt_sum_squares_ge_zero [simp]: "0 \ sqrt (x\ + y\)" ``` huffman@20687 ` 329` ```by (auto intro!: real_sqrt_ge_zero) ``` huffman@20687 ` 330` huffman@20687 ` 331` ```lemma real_sqrt_sum_squares_mult_ge_zero [simp]: ``` huffman@20687 ` 332` ``` "0 \ sqrt ((x\ + y\)*(xa\ + ya\))" ``` huffman@20687 ` 333` ```by (auto intro!: real_sqrt_ge_zero simp add: zero_le_mult_iff) ``` huffman@20687 ` 334` huffman@20687 ` 335` ```lemma real_sqrt_sum_squares_mult_squared_eq [simp]: ``` huffman@20687 ` 336` ``` "sqrt ((x\ + y\) * (xa\ + ya\)) ^ 2 = (x\ + y\) * (xa\ + ya\)" ``` huffman@20687 ` 337` ```by (auto simp add: zero_le_mult_iff simp del: realpow_Suc) ``` huffman@20687 ` 338` huffman@20687 ` 339` ```lemma real_sqrt_abs [simp]: "sqrt(x\) = \x\" ``` huffman@20687 ` 340` ```apply (rule abs_realpow_two [THEN subst]) ``` huffman@20687 ` 341` ```apply (rule real_sqrt_abs_abs [THEN subst]) ``` huffman@20687 ` 342` ```apply (subst real_pow_sqrt_eq_sqrt_pow) ``` huffman@20687 ` 343` ```apply (auto simp add: numeral_2_eq_2) ``` huffman@20687 ` 344` ```done ``` huffman@20687 ` 345` huffman@20687 ` 346` ```lemma real_sqrt_abs2 [simp]: "sqrt(x*x) = \x\" ``` huffman@20687 ` 347` ```apply (rule realpow_two [THEN subst]) ``` huffman@20687 ` 348` ```apply (subst numeral_2_eq_2 [symmetric]) ``` huffman@20687 ` 349` ```apply (rule real_sqrt_abs) ``` huffman@20687 ` 350` ```done ``` huffman@20687 ` 351` huffman@20687 ` 352` ```lemma real_sqrt_pow2_gt_zero: "0 < x ==> 0 < (sqrt x)\" ``` huffman@20687 ` 353` ```by simp ``` huffman@20687 ` 354` huffman@20687 ` 355` ```lemma real_sqrt_not_eq_zero: "0 < x ==> sqrt x \ 0" ``` huffman@20687 ` 356` ```apply (frule real_sqrt_pow2_gt_zero) ``` huffman@20687 ` 357` ```apply (auto simp add: numeral_2_eq_2) ``` huffman@20687 ` 358` ```done ``` huffman@20687 ` 359` huffman@20687 ` 360` ```lemma real_inv_sqrt_pow2: "0 < x ==> inverse (sqrt(x)) ^ 2 = inverse x" ``` wenzelm@20898 ` 361` ```by (cut_tac n = 2 and a = "sqrt x" in power_inverse [symmetric], auto) ``` huffman@20687 ` 362` huffman@20687 ` 363` ```lemma real_sqrt_eq_zero_cancel: "[| 0 \ x; sqrt(x) = 0|] ==> x = 0" ``` huffman@20687 ` 364` ```apply (drule real_le_imp_less_or_eq) ``` huffman@20687 ` 365` ```apply (auto dest: real_sqrt_not_eq_zero) ``` huffman@20687 ` 366` ```done ``` huffman@20687 ` 367` huffman@20687 ` 368` ```lemma real_sqrt_eq_zero_cancel_iff [simp]: "0 \ x ==> ((sqrt x = 0) = (x=0))" ``` huffman@20687 ` 369` ```by (auto simp add: real_sqrt_eq_zero_cancel) ``` huffman@20687 ` 370` huffman@20687 ` 371` ```lemma real_sqrt_sum_squares_ge1 [simp]: "x \ sqrt(x\ + y\)" ``` huffman@20687 ` 372` ```apply (subgoal_tac "x \ 0 | 0 \ x", safe) ``` huffman@20687 ` 373` ```apply (rule real_le_trans) ``` huffman@20687 ` 374` ```apply (auto simp del: realpow_Suc) ``` huffman@20687 ` 375` ```apply (rule_tac n = 1 in realpow_increasing) ``` huffman@20687 ` 376` ```apply (auto simp add: numeral_2_eq_2 [symmetric] simp del: realpow_Suc) ``` huffman@20687 ` 377` ```done ``` huffman@20687 ` 378` huffman@20687 ` 379` ```lemma real_sqrt_sum_squares_ge2 [simp]: "y \ sqrt(z\ + y\)" ``` huffman@20687 ` 380` ```apply (simp (no_asm) add: real_add_commute del: realpow_Suc) ``` huffman@20687 ` 381` ```done ``` huffman@20687 ` 382` huffman@20687 ` 383` ```lemma real_sqrt_ge_one: "1 \ x ==> 1 \ sqrt x" ``` huffman@20687 ` 384` ```apply (rule_tac n = 1 in realpow_increasing) ``` huffman@20687 ` 385` ```apply (auto simp add: numeral_2_eq_2 [symmetric] real_sqrt_ge_zero simp ``` huffman@20687 ` 386` ``` del: realpow_Suc) ``` huffman@20687 ` 387` ```done ``` huffman@20687 ` 388` paulson@14324 ` 389` ```end ```