src/HOL/NthRoot.thy
 author wenzelm Wed Oct 10 15:17:40 2012 +0200 (2012-10-10) changeset 49753 a344f1a21211 parent 44349 f057535311c5 child 49962 a8cc904a6820 permissions -rw-r--r--
eliminated spurious fact duplicates;
 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` huffman@22956 ` 7` ```header {* Nth Roots of Real Numbers *} ``` paulson@14324 ` 8` nipkow@15131 ` 9` ```theory NthRoot ``` haftmann@28952 ` 10` ```imports Parity Deriv ``` nipkow@15131 ` 11` ```begin ``` paulson@14324 ` 12` huffman@22956 ` 13` ```subsection {* Existence of Nth Root *} ``` huffman@20687 ` 14` huffman@23009 ` 15` ```text {* Existence follows from the Intermediate Value Theorem *} ``` paulson@14324 ` 16` huffman@23009 ` 17` ```lemma realpow_pos_nth: ``` huffman@23009 ` 18` ``` assumes n: "0 < n" ``` huffman@23009 ` 19` ``` assumes a: "0 < a" ``` huffman@23009 ` 20` ``` shows "\r>0. r ^ n = (a::real)" ``` huffman@23009 ` 21` ```proof - ``` huffman@23009 ` 22` ``` have "\r\0. r \ (max 1 a) \ r ^ n = a" ``` huffman@23009 ` 23` ``` proof (rule IVT) ``` huffman@23009 ` 24` ``` show "0 ^ n \ a" using n a by (simp add: power_0_left) ``` huffman@23009 ` 25` ``` show "0 \ max 1 a" by simp ``` huffman@23009 ` 26` ``` from n have n1: "1 \ n" by simp ``` huffman@23009 ` 27` ``` have "a \ max 1 a ^ 1" by simp ``` huffman@23009 ` 28` ``` also have "max 1 a ^ 1 \ max 1 a ^ n" ``` huffman@23009 ` 29` ``` using n1 by (rule power_increasing, simp) ``` huffman@23009 ` 30` ``` finally show "a \ max 1 a ^ n" . ``` huffman@23009 ` 31` ``` show "\r. 0 \ r \ r \ max 1 a \ isCont (\x. x ^ n) r" ``` huffman@44289 ` 32` ``` by simp ``` huffman@23009 ` 33` ``` qed ``` huffman@23009 ` 34` ``` then obtain r where r: "0 \ r \ r ^ n = a" by fast ``` huffman@23009 ` 35` ``` with n a have "r \ 0" by (auto simp add: power_0_left) ``` huffman@23009 ` 36` ``` with r have "0 < r \ r ^ n = a" by simp ``` huffman@23009 ` 37` ``` thus ?thesis .. ``` huffman@23009 ` 38` ```qed ``` paulson@14325 ` 39` huffman@23047 ` 40` ```(* Used by Integration/RealRandVar.thy in AFP *) ``` huffman@23047 ` 41` ```lemma realpow_pos_nth2: "(0::real) < a \ \r>0. r ^ Suc n = a" ``` huffman@23047 ` 42` ```by (blast intro: realpow_pos_nth) ``` huffman@23047 ` 43` huffman@23009 ` 44` ```text {* Uniqueness of nth positive root *} ``` paulson@14324 ` 45` paulson@14324 ` 46` ```lemma realpow_pos_nth_unique: ``` huffman@23009 ` 47` ``` "\0 < n; 0 < a\ \ \!r. 0 < r \ r ^ n = (a::real)" ``` paulson@14324 ` 48` ```apply (auto intro!: realpow_pos_nth) ``` huffman@23009 ` 49` ```apply (rule_tac n=n in power_eq_imp_eq_base, simp_all) ``` paulson@14324 ` 50` ```done ``` paulson@14324 ` 51` huffman@20687 ` 52` ```subsection {* Nth Root *} ``` huffman@20687 ` 53` huffman@22956 ` 54` ```text {* We define roots of negative reals such that ``` huffman@22956 ` 55` ``` @{term "root n (- x) = - root n x"}. This allows ``` huffman@22956 ` 56` ``` us to omit side conditions from many theorems. *} ``` huffman@20687 ` 57` huffman@22956 ` 58` ```definition ``` huffman@22956 ` 59` ``` root :: "[nat, real] \ real" where ``` huffman@22956 ` 60` ``` "root n x = (if 0 < x then (THE u. 0 < u \ u ^ n = x) else ``` huffman@22956 ` 61` ``` if x < 0 then - (THE u. 0 < u \ u ^ n = - x) else 0)" ``` huffman@20687 ` 62` huffman@22956 ` 63` ```lemma real_root_zero [simp]: "root n 0 = 0" ``` huffman@22956 ` 64` ```unfolding root_def by simp ``` huffman@22956 ` 65` huffman@22956 ` 66` ```lemma real_root_minus: "0 < n \ root n (- x) = - root n x" ``` huffman@22956 ` 67` ```unfolding root_def by simp ``` huffman@22956 ` 68` huffman@22956 ` 69` ```lemma real_root_gt_zero: "\0 < n; 0 < x\ \ 0 < root n x" ``` huffman@20687 ` 70` ```apply (simp add: root_def) ``` huffman@22956 ` 71` ```apply (drule (1) realpow_pos_nth_unique) ``` huffman@20687 ` 72` ```apply (erule theI' [THEN conjunct1]) ``` huffman@20687 ` 73` ```done ``` huffman@20687 ` 74` huffman@22956 ` 75` ```lemma real_root_pow_pos: (* TODO: rename *) ``` huffman@22956 ` 76` ``` "\0 < n; 0 < x\ \ root n x ^ n = x" ``` huffman@22956 ` 77` ```apply (simp add: root_def) ``` huffman@22956 ` 78` ```apply (drule (1) realpow_pos_nth_unique) ``` huffman@22956 ` 79` ```apply (erule theI' [THEN conjunct2]) ``` huffman@22956 ` 80` ```done ``` huffman@20687 ` 81` huffman@22956 ` 82` ```lemma real_root_pow_pos2 [simp]: (* TODO: rename *) ``` huffman@22956 ` 83` ``` "\0 < n; 0 \ x\ \ root n x ^ n = x" ``` huffman@22956 ` 84` ```by (auto simp add: order_le_less real_root_pow_pos) ``` huffman@22956 ` 85` huffman@23046 ` 86` ```lemma odd_real_root_pow: "odd n \ root n x ^ n = x" ``` huffman@23046 ` 87` ```apply (rule_tac x=0 and y=x in linorder_le_cases) ``` huffman@23046 ` 88` ```apply (erule (1) real_root_pow_pos2 [OF odd_pos]) ``` huffman@23046 ` 89` ```apply (subgoal_tac "root n (- x) ^ n = - x") ``` huffman@23046 ` 90` ```apply (simp add: real_root_minus odd_pos) ``` huffman@23046 ` 91` ```apply (simp add: odd_pos) ``` huffman@23046 ` 92` ```done ``` huffman@23046 ` 93` huffman@22956 ` 94` ```lemma real_root_ge_zero: "\0 < n; 0 \ x\ \ 0 \ root n x" ``` huffman@20687 ` 95` ```by (auto simp add: order_le_less real_root_gt_zero) ``` huffman@20687 ` 96` huffman@22956 ` 97` ```lemma real_root_power_cancel: "\0 < n; 0 \ x\ \ root n (x ^ n) = x" ``` huffman@22956 ` 98` ```apply (subgoal_tac "0 \ x ^ n") ``` huffman@22956 ` 99` ```apply (subgoal_tac "0 \ root n (x ^ n)") ``` huffman@22956 ` 100` ```apply (subgoal_tac "root n (x ^ n) ^ n = x ^ n") ``` huffman@22956 ` 101` ```apply (erule (3) power_eq_imp_eq_base) ``` huffman@22956 ` 102` ```apply (erule (1) real_root_pow_pos2) ``` huffman@22956 ` 103` ```apply (erule (1) real_root_ge_zero) ``` huffman@22956 ` 104` ```apply (erule zero_le_power) ``` huffman@20687 ` 105` ```done ``` huffman@20687 ` 106` huffman@23046 ` 107` ```lemma odd_real_root_power_cancel: "odd n \ root n (x ^ n) = x" ``` huffman@23046 ` 108` ```apply (rule_tac x=0 and y=x in linorder_le_cases) ``` huffman@23046 ` 109` ```apply (erule (1) real_root_power_cancel [OF odd_pos]) ``` huffman@23046 ` 110` ```apply (subgoal_tac "root n ((- x) ^ n) = - x") ``` huffman@23046 ` 111` ```apply (simp add: real_root_minus odd_pos) ``` huffman@23046 ` 112` ```apply (erule real_root_power_cancel [OF odd_pos], simp) ``` huffman@23046 ` 113` ```done ``` huffman@23046 ` 114` huffman@22956 ` 115` ```lemma real_root_pos_unique: ``` huffman@22956 ` 116` ``` "\0 < n; 0 \ y; y ^ n = x\ \ root n x = y" ``` huffman@22956 ` 117` ```by (erule subst, rule real_root_power_cancel) ``` huffman@22956 ` 118` huffman@23046 ` 119` ```lemma odd_real_root_unique: ``` huffman@23046 ` 120` ``` "\odd n; y ^ n = x\ \ root n x = y" ``` huffman@23046 ` 121` ```by (erule subst, rule odd_real_root_power_cancel) ``` huffman@23046 ` 122` huffman@22956 ` 123` ```lemma real_root_one [simp]: "0 < n \ root n 1 = 1" ``` huffman@22956 ` 124` ```by (simp add: real_root_pos_unique) ``` huffman@22956 ` 125` huffman@22956 ` 126` ```text {* Root function is strictly monotonic, hence injective *} ``` huffman@22956 ` 127` huffman@22956 ` 128` ```lemma real_root_less_mono_lemma: ``` huffman@22956 ` 129` ``` "\0 < n; 0 \ x; x < y\ \ root n x < root n y" ``` huffman@22856 ` 130` ```apply (subgoal_tac "0 \ y") ``` huffman@22956 ` 131` ```apply (subgoal_tac "root n x ^ n < root n y ^ n") ``` huffman@22956 ` 132` ```apply (erule power_less_imp_less_base) ``` huffman@22956 ` 133` ```apply (erule (1) real_root_ge_zero) ``` huffman@22956 ` 134` ```apply simp ``` huffman@22956 ` 135` ```apply simp ``` huffman@22721 ` 136` ```done ``` huffman@22721 ` 137` huffman@22956 ` 138` ```lemma real_root_less_mono: "\0 < n; x < y\ \ root n x < root n y" ``` huffman@22956 ` 139` ```apply (cases "0 \ x") ``` huffman@22956 ` 140` ```apply (erule (2) real_root_less_mono_lemma) ``` huffman@22956 ` 141` ```apply (cases "0 \ y") ``` huffman@22956 ` 142` ```apply (rule_tac y=0 in order_less_le_trans) ``` huffman@22956 ` 143` ```apply (subgoal_tac "0 < root n (- x)") ``` huffman@22956 ` 144` ```apply (simp add: real_root_minus) ``` huffman@22956 ` 145` ```apply (simp add: real_root_gt_zero) ``` huffman@22956 ` 146` ```apply (simp add: real_root_ge_zero) ``` huffman@22956 ` 147` ```apply (subgoal_tac "root n (- y) < root n (- x)") ``` huffman@22956 ` 148` ```apply (simp add: real_root_minus) ``` huffman@22956 ` 149` ```apply (simp add: real_root_less_mono_lemma) ``` huffman@22721 ` 150` ```done ``` huffman@22721 ` 151` huffman@22956 ` 152` ```lemma real_root_le_mono: "\0 < n; x \ y\ \ root n x \ root n y" ``` huffman@22956 ` 153` ```by (auto simp add: order_le_less real_root_less_mono) ``` huffman@22956 ` 154` huffman@22721 ` 155` ```lemma real_root_less_iff [simp]: ``` huffman@22956 ` 156` ``` "0 < n \ (root n x < root n y) = (x < y)" ``` huffman@22956 ` 157` ```apply (cases "x < y") ``` huffman@22956 ` 158` ```apply (simp add: real_root_less_mono) ``` huffman@22956 ` 159` ```apply (simp add: linorder_not_less real_root_le_mono) ``` huffman@22721 ` 160` ```done ``` huffman@22721 ` 161` huffman@22721 ` 162` ```lemma real_root_le_iff [simp]: ``` huffman@22956 ` 163` ``` "0 < n \ (root n x \ root n y) = (x \ y)" ``` huffman@22956 ` 164` ```apply (cases "x \ y") ``` huffman@22956 ` 165` ```apply (simp add: real_root_le_mono) ``` huffman@22956 ` 166` ```apply (simp add: linorder_not_le real_root_less_mono) ``` huffman@22721 ` 167` ```done ``` huffman@22721 ` 168` huffman@22721 ` 169` ```lemma real_root_eq_iff [simp]: ``` huffman@22956 ` 170` ``` "0 < n \ (root n x = root n y) = (x = y)" ``` huffman@22956 ` 171` ```by (simp add: order_eq_iff) ``` huffman@22956 ` 172` huffman@22956 ` 173` ```lemmas real_root_gt_0_iff [simp] = real_root_less_iff [where x=0, simplified] ``` huffman@22956 ` 174` ```lemmas real_root_lt_0_iff [simp] = real_root_less_iff [where y=0, simplified] ``` huffman@22956 ` 175` ```lemmas real_root_ge_0_iff [simp] = real_root_le_iff [where x=0, simplified] ``` huffman@22956 ` 176` ```lemmas real_root_le_0_iff [simp] = real_root_le_iff [where y=0, simplified] ``` huffman@22956 ` 177` ```lemmas real_root_eq_0_iff [simp] = real_root_eq_iff [where y=0, simplified] ``` huffman@22721 ` 178` huffman@23257 ` 179` ```lemma real_root_gt_1_iff [simp]: "0 < n \ (1 < root n y) = (1 < y)" ``` huffman@23257 ` 180` ```by (insert real_root_less_iff [where x=1], simp) ``` huffman@23257 ` 181` huffman@23257 ` 182` ```lemma real_root_lt_1_iff [simp]: "0 < n \ (root n x < 1) = (x < 1)" ``` huffman@23257 ` 183` ```by (insert real_root_less_iff [where y=1], simp) ``` huffman@23257 ` 184` huffman@23257 ` 185` ```lemma real_root_ge_1_iff [simp]: "0 < n \ (1 \ root n y) = (1 \ y)" ``` huffman@23257 ` 186` ```by (insert real_root_le_iff [where x=1], simp) ``` huffman@23257 ` 187` huffman@23257 ` 188` ```lemma real_root_le_1_iff [simp]: "0 < n \ (root n x \ 1) = (x \ 1)" ``` huffman@23257 ` 189` ```by (insert real_root_le_iff [where y=1], simp) ``` huffman@23257 ` 190` huffman@23257 ` 191` ```lemma real_root_eq_1_iff [simp]: "0 < n \ (root n x = 1) = (x = 1)" ``` huffman@23257 ` 192` ```by (insert real_root_eq_iff [where y=1], simp) ``` huffman@23257 ` 193` huffman@23257 ` 194` ```text {* Roots of roots *} ``` huffman@23257 ` 195` huffman@23257 ` 196` ```lemma real_root_Suc_0 [simp]: "root (Suc 0) x = x" ``` huffman@23257 ` 197` ```by (simp add: odd_real_root_unique) ``` huffman@23257 ` 198` huffman@23257 ` 199` ```lemma real_root_pos_mult_exp: ``` huffman@23257 ` 200` ``` "\0 < m; 0 < n; 0 < x\ \ root (m * n) x = root m (root n x)" ``` huffman@23257 ` 201` ```by (rule real_root_pos_unique, simp_all add: power_mult) ``` huffman@23257 ` 202` huffman@23257 ` 203` ```lemma real_root_mult_exp: ``` huffman@23257 ` 204` ``` "\0 < m; 0 < n\ \ root (m * n) x = root m (root n x)" ``` huffman@23257 ` 205` ```apply (rule linorder_cases [where x=x and y=0]) ``` huffman@23257 ` 206` ```apply (subgoal_tac "root (m * n) (- x) = root m (root n (- x))") ``` huffman@23257 ` 207` ```apply (simp add: real_root_minus) ``` huffman@23257 ` 208` ```apply (simp_all add: real_root_pos_mult_exp) ``` huffman@23257 ` 209` ```done ``` huffman@23257 ` 210` huffman@23257 ` 211` ```lemma real_root_commute: ``` huffman@23257 ` 212` ``` "\0 < m; 0 < n\ \ root m (root n x) = root n (root m x)" ``` huffman@23257 ` 213` ```by (simp add: real_root_mult_exp [symmetric] mult_commute) ``` huffman@23257 ` 214` huffman@23257 ` 215` ```text {* Monotonicity in first argument *} ``` huffman@23257 ` 216` huffman@23257 ` 217` ```lemma real_root_strict_decreasing: ``` huffman@23257 ` 218` ``` "\0 < n; n < N; 1 < x\ \ root N x < root n x" ``` huffman@23257 ` 219` ```apply (subgoal_tac "root n (root N x) ^ n < root N (root n x) ^ N", simp) ``` huffman@23257 ` 220` ```apply (simp add: real_root_commute power_strict_increasing ``` huffman@23257 ` 221` ``` del: real_root_pow_pos2) ``` huffman@23257 ` 222` ```done ``` huffman@23257 ` 223` huffman@23257 ` 224` ```lemma real_root_strict_increasing: ``` huffman@23257 ` 225` ``` "\0 < n; n < N; 0 < x; x < 1\ \ root n x < root N x" ``` huffman@23257 ` 226` ```apply (subgoal_tac "root N (root n x) ^ N < root n (root N x) ^ n", simp) ``` huffman@23257 ` 227` ```apply (simp add: real_root_commute power_strict_decreasing ``` huffman@23257 ` 228` ``` del: real_root_pow_pos2) ``` huffman@23257 ` 229` ```done ``` huffman@23257 ` 230` huffman@23257 ` 231` ```lemma real_root_decreasing: ``` huffman@23257 ` 232` ``` "\0 < n; n < N; 1 \ x\ \ root N x \ root n x" ``` huffman@23257 ` 233` ```by (auto simp add: order_le_less real_root_strict_decreasing) ``` huffman@23257 ` 234` huffman@23257 ` 235` ```lemma real_root_increasing: ``` huffman@23257 ` 236` ``` "\0 < n; n < N; 0 \ x; x \ 1\ \ root n x \ root N x" ``` huffman@23257 ` 237` ```by (auto simp add: order_le_less real_root_strict_increasing) ``` huffman@23257 ` 238` huffman@22956 ` 239` ```text {* Roots of multiplication and division *} ``` huffman@22956 ` 240` huffman@22956 ` 241` ```lemma real_root_mult_lemma: ``` huffman@22956 ` 242` ``` "\0 < n; 0 \ x; 0 \ y\ \ root n (x * y) = root n x * root n y" ``` huffman@22956 ` 243` ```by (simp add: real_root_pos_unique mult_nonneg_nonneg power_mult_distrib) ``` huffman@22956 ` 244` huffman@22956 ` 245` ```lemma real_root_inverse_lemma: ``` huffman@22956 ` 246` ``` "\0 < n; 0 \ x\ \ root n (inverse x) = inverse (root n x)" ``` huffman@22956 ` 247` ```by (simp add: real_root_pos_unique power_inverse [symmetric]) ``` huffman@22721 ` 248` huffman@22721 ` 249` ```lemma real_root_mult: ``` huffman@22956 ` 250` ``` assumes n: "0 < n" ``` huffman@22956 ` 251` ``` shows "root n (x * y) = root n x * root n y" ``` huffman@22956 ` 252` ```proof (rule linorder_le_cases, rule_tac [!] linorder_le_cases) ``` huffman@22956 ` 253` ``` assume "0 \ x" and "0 \ y" ``` huffman@22956 ` 254` ``` thus ?thesis by (rule real_root_mult_lemma [OF n]) ``` huffman@22956 ` 255` ```next ``` huffman@22956 ` 256` ``` assume "0 \ x" and "y \ 0" ``` huffman@22956 ` 257` ``` hence "0 \ x" and "0 \ - y" by simp_all ``` huffman@22956 ` 258` ``` hence "root n (x * - y) = root n x * root n (- y)" ``` huffman@22956 ` 259` ``` by (rule real_root_mult_lemma [OF n]) ``` huffman@22956 ` 260` ``` thus ?thesis by (simp add: real_root_minus [OF n]) ``` huffman@22956 ` 261` ```next ``` huffman@22956 ` 262` ``` assume "x \ 0" and "0 \ y" ``` huffman@22956 ` 263` ``` hence "0 \ - x" and "0 \ y" by simp_all ``` huffman@22956 ` 264` ``` hence "root n (- x * y) = root n (- x) * root n y" ``` huffman@22956 ` 265` ``` by (rule real_root_mult_lemma [OF n]) ``` huffman@22956 ` 266` ``` thus ?thesis by (simp add: real_root_minus [OF n]) ``` huffman@22956 ` 267` ```next ``` huffman@22956 ` 268` ``` assume "x \ 0" and "y \ 0" ``` huffman@22956 ` 269` ``` hence "0 \ - x" and "0 \ - y" by simp_all ``` huffman@22956 ` 270` ``` hence "root n (- x * - y) = root n (- x) * root n (- y)" ``` huffman@22956 ` 271` ``` by (rule real_root_mult_lemma [OF n]) ``` huffman@22956 ` 272` ``` thus ?thesis by (simp add: real_root_minus [OF n]) ``` huffman@22956 ` 273` ```qed ``` huffman@22721 ` 274` huffman@22721 ` 275` ```lemma real_root_inverse: ``` huffman@22956 ` 276` ``` assumes n: "0 < n" ``` huffman@22956 ` 277` ``` shows "root n (inverse x) = inverse (root n x)" ``` huffman@22956 ` 278` ```proof (rule linorder_le_cases) ``` huffman@22956 ` 279` ``` assume "0 \ x" ``` huffman@22956 ` 280` ``` thus ?thesis by (rule real_root_inverse_lemma [OF n]) ``` huffman@22956 ` 281` ```next ``` huffman@22956 ` 282` ``` assume "x \ 0" ``` huffman@22956 ` 283` ``` hence "0 \ - x" by simp ``` huffman@22956 ` 284` ``` hence "root n (inverse (- x)) = inverse (root n (- x))" ``` huffman@22956 ` 285` ``` by (rule real_root_inverse_lemma [OF n]) ``` huffman@22956 ` 286` ``` thus ?thesis by (simp add: real_root_minus [OF n]) ``` huffman@22956 ` 287` ```qed ``` huffman@22721 ` 288` huffman@22956 ` 289` ```lemma real_root_divide: ``` huffman@22956 ` 290` ``` "0 < n \ root n (x / y) = root n x / root n y" ``` huffman@22956 ` 291` ```by (simp add: divide_inverse real_root_mult real_root_inverse) ``` huffman@22956 ` 292` huffman@22956 ` 293` ```lemma real_root_power: ``` huffman@22956 ` 294` ``` "0 < n \ root n (x ^ k) = root n x ^ k" ``` huffman@22956 ` 295` ```by (induct k, simp_all add: real_root_mult) ``` huffman@22721 ` 296` huffman@23042 ` 297` ```lemma real_root_abs: "0 < n \ root n \x\ = \root n x\" ``` huffman@23042 ` 298` ```by (simp add: abs_if real_root_minus) ``` huffman@23042 ` 299` huffman@23042 ` 300` ```text {* Continuity and derivatives *} ``` huffman@23042 ` 301` huffman@23042 ` 302` ```lemma isCont_root_pos: ``` huffman@23042 ` 303` ``` assumes n: "0 < n" ``` huffman@23042 ` 304` ``` assumes x: "0 < x" ``` huffman@23042 ` 305` ``` shows "isCont (root n) x" ``` huffman@23042 ` 306` ```proof - ``` huffman@23042 ` 307` ``` have "isCont (root n) (root n x ^ n)" ``` huffman@23042 ` 308` ``` proof (rule isCont_inverse_function [where f="\a. a ^ n"]) ``` huffman@23042 ` 309` ``` show "0 < root n x" using n x by simp ``` huffman@23042 ` 310` ``` show "\z. \z - root n x\ \ root n x \ root n (z ^ n) = z" ``` huffman@23042 ` 311` ``` by (simp add: abs_le_iff real_root_power_cancel n) ``` huffman@23042 ` 312` ``` show "\z. \z - root n x\ \ root n x \ isCont (\a. a ^ n) z" ``` huffman@44289 ` 313` ``` by simp ``` huffman@23042 ` 314` ``` qed ``` huffman@23042 ` 315` ``` thus ?thesis using n x by simp ``` huffman@23042 ` 316` ```qed ``` huffman@23042 ` 317` huffman@23042 ` 318` ```lemma isCont_root_neg: ``` huffman@23042 ` 319` ``` "\0 < n; x < 0\ \ isCont (root n) x" ``` huffman@23042 ` 320` ```apply (subgoal_tac "isCont (\x. - root n (- x)) x") ``` huffman@23042 ` 321` ```apply (simp add: real_root_minus) ``` huffman@23069 ` 322` ```apply (rule isCont_o2 [OF isCont_minus [OF isCont_ident]]) ``` huffman@44289 ` 323` ```apply (simp add: isCont_root_pos) ``` huffman@23042 ` 324` ```done ``` huffman@23042 ` 325` huffman@23042 ` 326` ```lemma isCont_root_zero: ``` huffman@23042 ` 327` ``` "0 < n \ isCont (root n) 0" ``` huffman@23042 ` 328` ```unfolding isCont_def ``` huffman@23042 ` 329` ```apply (rule LIM_I) ``` huffman@23042 ` 330` ```apply (rule_tac x="r ^ n" in exI, safe) ``` nipkow@25875 ` 331` ```apply (simp) ``` huffman@23042 ` 332` ```apply (simp add: real_root_abs [symmetric]) ``` huffman@23042 ` 333` ```apply (rule_tac n="n" in power_less_imp_less_base, simp_all) ``` huffman@23042 ` 334` ```done ``` huffman@23042 ` 335` huffman@23042 ` 336` ```lemma isCont_real_root: "0 < n \ isCont (root n) x" ``` huffman@23042 ` 337` ```apply (rule_tac x=x and y=0 in linorder_cases) ``` huffman@23042 ` 338` ```apply (simp_all add: isCont_root_pos isCont_root_neg isCont_root_zero) ``` huffman@23042 ` 339` ```done ``` huffman@23042 ` 340` huffman@23042 ` 341` ```lemma DERIV_real_root: ``` huffman@23042 ` 342` ``` assumes n: "0 < n" ``` huffman@23042 ` 343` ``` assumes x: "0 < x" ``` huffman@23042 ` 344` ``` shows "DERIV (root n) x :> inverse (real n * root n x ^ (n - Suc 0))" ``` huffman@23042 ` 345` ```proof (rule DERIV_inverse_function) ``` huffman@23044 ` 346` ``` show "0 < x" using x . ``` huffman@23044 ` 347` ``` show "x < x + 1" by simp ``` huffman@23044 ` 348` ``` show "\y. 0 < y \ y < x + 1 \ root n y ^ n = y" ``` huffman@23042 ` 349` ``` using n by simp ``` huffman@23042 ` 350` ``` show "DERIV (\x. x ^ n) (root n x) :> real n * root n x ^ (n - Suc 0)" ``` huffman@23042 ` 351` ``` by (rule DERIV_pow) ``` huffman@23042 ` 352` ``` show "real n * root n x ^ (n - Suc 0) \ 0" ``` huffman@23042 ` 353` ``` using n x by simp ``` huffman@23042 ` 354` ``` show "isCont (root n) x" ``` huffman@23441 ` 355` ``` using n by (rule isCont_real_root) ``` huffman@23042 ` 356` ```qed ``` huffman@23042 ` 357` huffman@23046 ` 358` ```lemma DERIV_odd_real_root: ``` huffman@23046 ` 359` ``` assumes n: "odd n" ``` huffman@23046 ` 360` ``` assumes x: "x \ 0" ``` huffman@23046 ` 361` ``` shows "DERIV (root n) x :> inverse (real n * root n x ^ (n - Suc 0))" ``` huffman@23046 ` 362` ```proof (rule DERIV_inverse_function) ``` huffman@23046 ` 363` ``` show "x - 1 < x" by simp ``` huffman@23046 ` 364` ``` show "x < x + 1" by simp ``` huffman@23046 ` 365` ``` show "\y. x - 1 < y \ y < x + 1 \ root n y ^ n = y" ``` huffman@23046 ` 366` ``` using n by (simp add: odd_real_root_pow) ``` huffman@23046 ` 367` ``` show "DERIV (\x. x ^ n) (root n x) :> real n * root n x ^ (n - Suc 0)" ``` huffman@23046 ` 368` ``` by (rule DERIV_pow) ``` huffman@23046 ` 369` ``` show "real n * root n x ^ (n - Suc 0) \ 0" ``` huffman@23046 ` 370` ``` using odd_pos [OF n] x by simp ``` huffman@23046 ` 371` ``` show "isCont (root n) x" ``` huffman@23046 ` 372` ``` using odd_pos [OF n] by (rule isCont_real_root) ``` huffman@23046 ` 373` ```qed ``` huffman@23046 ` 374` hoelzl@31880 ` 375` ```lemma DERIV_even_real_root: ``` hoelzl@31880 ` 376` ``` assumes n: "0 < n" and "even n" ``` hoelzl@31880 ` 377` ``` assumes x: "x < 0" ``` hoelzl@31880 ` 378` ``` shows "DERIV (root n) x :> inverse (- real n * root n x ^ (n - Suc 0))" ``` hoelzl@31880 ` 379` ```proof (rule DERIV_inverse_function) ``` hoelzl@31880 ` 380` ``` show "x - 1 < x" by simp ``` hoelzl@31880 ` 381` ``` show "x < 0" using x . ``` hoelzl@31880 ` 382` ```next ``` hoelzl@31880 ` 383` ``` show "\y. x - 1 < y \ y < 0 \ - (root n y ^ n) = y" ``` hoelzl@31880 ` 384` ``` proof (rule allI, rule impI, erule conjE) ``` hoelzl@31880 ` 385` ``` fix y assume "x - 1 < y" and "y < 0" ``` hoelzl@31880 ` 386` ``` hence "root n (-y) ^ n = -y" using `0 < n` by simp ``` hoelzl@31880 ` 387` ``` with real_root_minus[OF `0 < n`] and `even n` ``` hoelzl@31880 ` 388` ``` show "- (root n y ^ n) = y" by simp ``` hoelzl@31880 ` 389` ``` qed ``` hoelzl@31880 ` 390` ```next ``` hoelzl@31880 ` 391` ``` show "DERIV (\x. - (x ^ n)) (root n x) :> - real n * root n x ^ (n - Suc 0)" ``` hoelzl@31880 ` 392` ``` by (auto intro!: DERIV_intros) ``` hoelzl@31880 ` 393` ``` show "- real n * root n x ^ (n - Suc 0) \ 0" ``` hoelzl@31880 ` 394` ``` using n x by simp ``` hoelzl@31880 ` 395` ``` show "isCont (root n) x" ``` hoelzl@31880 ` 396` ``` using n by (rule isCont_real_root) ``` hoelzl@31880 ` 397` ```qed ``` hoelzl@31880 ` 398` hoelzl@31880 ` 399` ```lemma DERIV_real_root_generic: ``` hoelzl@31880 ` 400` ``` assumes "0 < n" and "x \ 0" ``` wenzelm@49753 ` 401` ``` and "\ even n ; 0 < x \ \ D = inverse (real n * root n x ^ (n - Suc 0))" ``` wenzelm@49753 ` 402` ``` and "\ even n ; x < 0 \ \ D = - inverse (real n * root n x ^ (n - Suc 0))" ``` wenzelm@49753 ` 403` ``` and "odd n \ D = inverse (real n * root n x ^ (n - Suc 0))" ``` hoelzl@31880 ` 404` ``` shows "DERIV (root n) x :> D" ``` hoelzl@31880 ` 405` ```using assms by (cases "even n", cases "0 < x", ``` hoelzl@31880 ` 406` ``` auto intro: DERIV_real_root[THEN DERIV_cong] ``` hoelzl@31880 ` 407` ``` DERIV_odd_real_root[THEN DERIV_cong] ``` hoelzl@31880 ` 408` ``` DERIV_even_real_root[THEN DERIV_cong]) ``` hoelzl@31880 ` 409` huffman@22956 ` 410` ```subsection {* Square Root *} ``` huffman@20687 ` 411` huffman@22956 ` 412` ```definition ``` huffman@22956 ` 413` ``` sqrt :: "real \ real" where ``` huffman@22956 ` 414` ``` "sqrt = root 2" ``` huffman@20687 ` 415` huffman@22956 ` 416` ```lemma pos2: "0 < (2::nat)" by simp ``` huffman@22956 ` 417` huffman@22956 ` 418` ```lemma real_sqrt_unique: "\y\ = x; 0 \ y\ \ sqrt x = y" ``` huffman@22956 ` 419` ```unfolding sqrt_def by (rule real_root_pos_unique [OF pos2]) ``` huffman@20687 ` 420` huffman@22956 ` 421` ```lemma real_sqrt_abs [simp]: "sqrt (x\) = \x\" ``` huffman@22956 ` 422` ```apply (rule real_sqrt_unique) ``` huffman@22956 ` 423` ```apply (rule power2_abs) ``` huffman@22956 ` 424` ```apply (rule abs_ge_zero) ``` huffman@22956 ` 425` ```done ``` huffman@20687 ` 426` huffman@22956 ` 427` ```lemma real_sqrt_pow2 [simp]: "0 \ x \ (sqrt x)\ = x" ``` huffman@22956 ` 428` ```unfolding sqrt_def by (rule real_root_pow_pos2 [OF pos2]) ``` huffman@22856 ` 429` huffman@22956 ` 430` ```lemma real_sqrt_pow2_iff [simp]: "((sqrt x)\ = x) = (0 \ x)" ``` huffman@22856 ` 431` ```apply (rule iffI) ``` huffman@22856 ` 432` ```apply (erule subst) ``` huffman@22856 ` 433` ```apply (rule zero_le_power2) ``` huffman@22856 ` 434` ```apply (erule real_sqrt_pow2) ``` huffman@20687 ` 435` ```done ``` huffman@20687 ` 436` huffman@22956 ` 437` ```lemma real_sqrt_zero [simp]: "sqrt 0 = 0" ``` huffman@22956 ` 438` ```unfolding sqrt_def by (rule real_root_zero) ``` huffman@22956 ` 439` huffman@22956 ` 440` ```lemma real_sqrt_one [simp]: "sqrt 1 = 1" ``` huffman@22956 ` 441` ```unfolding sqrt_def by (rule real_root_one [OF pos2]) ``` huffman@22956 ` 442` huffman@22956 ` 443` ```lemma real_sqrt_minus: "sqrt (- x) = - sqrt x" ``` huffman@22956 ` 444` ```unfolding sqrt_def by (rule real_root_minus [OF pos2]) ``` huffman@22956 ` 445` huffman@22956 ` 446` ```lemma real_sqrt_mult: "sqrt (x * y) = sqrt x * sqrt y" ``` huffman@22956 ` 447` ```unfolding sqrt_def by (rule real_root_mult [OF pos2]) ``` huffman@22956 ` 448` huffman@22956 ` 449` ```lemma real_sqrt_inverse: "sqrt (inverse x) = inverse (sqrt x)" ``` huffman@22956 ` 450` ```unfolding sqrt_def by (rule real_root_inverse [OF pos2]) ``` huffman@22956 ` 451` huffman@22956 ` 452` ```lemma real_sqrt_divide: "sqrt (x / y) = sqrt x / sqrt y" ``` huffman@22956 ` 453` ```unfolding sqrt_def by (rule real_root_divide [OF pos2]) ``` huffman@22956 ` 454` huffman@22956 ` 455` ```lemma real_sqrt_power: "sqrt (x ^ k) = sqrt x ^ k" ``` huffman@22956 ` 456` ```unfolding sqrt_def by (rule real_root_power [OF pos2]) ``` huffman@22956 ` 457` huffman@22956 ` 458` ```lemma real_sqrt_gt_zero: "0 < x \ 0 < sqrt x" ``` huffman@22956 ` 459` ```unfolding sqrt_def by (rule real_root_gt_zero [OF pos2]) ``` huffman@22956 ` 460` huffman@22956 ` 461` ```lemma real_sqrt_ge_zero: "0 \ x \ 0 \ sqrt x" ``` huffman@22956 ` 462` ```unfolding sqrt_def by (rule real_root_ge_zero [OF pos2]) ``` huffman@20687 ` 463` huffman@22956 ` 464` ```lemma real_sqrt_less_mono: "x < y \ sqrt x < sqrt y" ``` huffman@22956 ` 465` ```unfolding sqrt_def by (rule real_root_less_mono [OF pos2]) ``` huffman@22956 ` 466` huffman@22956 ` 467` ```lemma real_sqrt_le_mono: "x \ y \ sqrt x \ sqrt y" ``` huffman@22956 ` 468` ```unfolding sqrt_def by (rule real_root_le_mono [OF pos2]) ``` huffman@22956 ` 469` huffman@22956 ` 470` ```lemma real_sqrt_less_iff [simp]: "(sqrt x < sqrt y) = (x < y)" ``` huffman@22956 ` 471` ```unfolding sqrt_def by (rule real_root_less_iff [OF pos2]) ``` huffman@22956 ` 472` huffman@22956 ` 473` ```lemma real_sqrt_le_iff [simp]: "(sqrt x \ sqrt y) = (x \ y)" ``` huffman@22956 ` 474` ```unfolding sqrt_def by (rule real_root_le_iff [OF pos2]) ``` huffman@22956 ` 475` huffman@22956 ` 476` ```lemma real_sqrt_eq_iff [simp]: "(sqrt x = sqrt y) = (x = y)" ``` huffman@22956 ` 477` ```unfolding sqrt_def by (rule real_root_eq_iff [OF pos2]) ``` huffman@22956 ` 478` huffman@22956 ` 479` ```lemmas real_sqrt_gt_0_iff [simp] = real_sqrt_less_iff [where x=0, simplified] ``` huffman@22956 ` 480` ```lemmas real_sqrt_lt_0_iff [simp] = real_sqrt_less_iff [where y=0, simplified] ``` huffman@22956 ` 481` ```lemmas real_sqrt_ge_0_iff [simp] = real_sqrt_le_iff [where x=0, simplified] ``` huffman@22956 ` 482` ```lemmas real_sqrt_le_0_iff [simp] = real_sqrt_le_iff [where y=0, simplified] ``` huffman@22956 ` 483` ```lemmas real_sqrt_eq_0_iff [simp] = real_sqrt_eq_iff [where y=0, simplified] ``` huffman@22956 ` 484` huffman@22956 ` 485` ```lemmas real_sqrt_gt_1_iff [simp] = real_sqrt_less_iff [where x=1, simplified] ``` huffman@22956 ` 486` ```lemmas real_sqrt_lt_1_iff [simp] = real_sqrt_less_iff [where y=1, simplified] ``` huffman@22956 ` 487` ```lemmas real_sqrt_ge_1_iff [simp] = real_sqrt_le_iff [where x=1, simplified] ``` huffman@22956 ` 488` ```lemmas real_sqrt_le_1_iff [simp] = real_sqrt_le_iff [where y=1, simplified] ``` huffman@22956 ` 489` ```lemmas real_sqrt_eq_1_iff [simp] = real_sqrt_eq_iff [where y=1, simplified] ``` huffman@20687 ` 490` huffman@23042 ` 491` ```lemma isCont_real_sqrt: "isCont sqrt x" ``` huffman@23042 ` 492` ```unfolding sqrt_def by (rule isCont_real_root [OF pos2]) ``` huffman@23042 ` 493` hoelzl@31880 ` 494` ```lemma DERIV_real_sqrt_generic: ``` hoelzl@31880 ` 495` ``` assumes "x \ 0" ``` hoelzl@31880 ` 496` ``` assumes "x > 0 \ D = inverse (sqrt x) / 2" ``` hoelzl@31880 ` 497` ``` assumes "x < 0 \ D = - inverse (sqrt x) / 2" ``` hoelzl@31880 ` 498` ``` shows "DERIV sqrt x :> D" ``` hoelzl@31880 ` 499` ``` using assms unfolding sqrt_def ``` hoelzl@31880 ` 500` ``` by (auto intro!: DERIV_real_root_generic) ``` hoelzl@31880 ` 501` huffman@23042 ` 502` ```lemma DERIV_real_sqrt: ``` huffman@23042 ` 503` ``` "0 < x \ DERIV sqrt x :> inverse (sqrt x) / 2" ``` hoelzl@31880 ` 504` ``` using DERIV_real_sqrt_generic by simp ``` hoelzl@31880 ` 505` hoelzl@31880 ` 506` ```declare ``` hoelzl@31880 ` 507` ``` DERIV_real_sqrt_generic[THEN DERIV_chain2, THEN DERIV_cong, DERIV_intros] ``` hoelzl@31880 ` 508` ``` DERIV_real_root_generic[THEN DERIV_chain2, THEN DERIV_cong, DERIV_intros] ``` huffman@23042 ` 509` huffman@20687 ` 510` ```lemma not_real_square_gt_zero [simp]: "(~ (0::real) < x*x) = (x = 0)" ``` huffman@20687 ` 511` ```apply auto ``` huffman@20687 ` 512` ```apply (cut_tac x = x and y = 0 in linorder_less_linear) ``` huffman@20687 ` 513` ```apply (simp add: zero_less_mult_iff) ``` huffman@20687 ` 514` ```done ``` huffman@20687 ` 515` huffman@20687 ` 516` ```lemma real_sqrt_abs2 [simp]: "sqrt(x*x) = \x\" ``` huffman@22856 ` 517` ```apply (subst power2_eq_square [symmetric]) ``` huffman@20687 ` 518` ```apply (rule real_sqrt_abs) ``` huffman@20687 ` 519` ```done ``` huffman@20687 ` 520` huffman@20687 ` 521` ```lemma real_inv_sqrt_pow2: "0 < x ==> inverse (sqrt(x)) ^ 2 = inverse x" ``` huffman@22856 ` 522` ```by (simp add: power_inverse [symmetric]) ``` huffman@20687 ` 523` huffman@20687 ` 524` ```lemma real_sqrt_eq_zero_cancel: "[| 0 \ x; sqrt(x) = 0|] ==> x = 0" ``` huffman@22956 ` 525` ```by simp ``` huffman@20687 ` 526` huffman@20687 ` 527` ```lemma real_sqrt_ge_one: "1 \ x ==> 1 \ sqrt x" ``` huffman@22956 ` 528` ```by simp ``` huffman@20687 ` 529` huffman@22443 ` 530` ```lemma sqrt_divide_self_eq: ``` huffman@22443 ` 531` ``` assumes nneg: "0 \ x" ``` huffman@22443 ` 532` ``` shows "sqrt x / x = inverse (sqrt x)" ``` huffman@22443 ` 533` ```proof cases ``` huffman@22443 ` 534` ``` assume "x=0" thus ?thesis by simp ``` huffman@22443 ` 535` ```next ``` huffman@22443 ` 536` ``` assume nz: "x\0" ``` huffman@22443 ` 537` ``` hence pos: "0 0" by (simp add: divide_inverse nneg nz) ``` huffman@22443 ` 541` ``` show "inverse (sqrt x) / (sqrt x / x) = 1" ``` huffman@22443 ` 542` ``` by (simp add: divide_inverse mult_assoc [symmetric] ``` huffman@22443 ` 543` ``` power2_eq_square [symmetric] real_inv_sqrt_pow2 pos nz) ``` huffman@22443 ` 544` ``` qed ``` huffman@22443 ` 545` ```qed ``` huffman@22443 ` 546` huffman@22721 ` 547` ```lemma real_divide_square_eq [simp]: "(((r::real) * a) / (r * r)) = a / r" ``` huffman@22721 ` 548` ```apply (simp add: divide_inverse) ``` huffman@22721 ` 549` ```apply (case_tac "r=0") ``` huffman@22721 ` 550` ```apply (auto simp add: mult_ac) ``` huffman@22721 ` 551` ```done ``` huffman@22721 ` 552` huffman@23049 ` 553` ```lemma lemma_real_divide_sqrt_less: "0 < u ==> u / sqrt 2 < u" ``` huffman@35216 ` 554` ```by (simp add: divide_less_eq) ``` huffman@23049 ` 555` huffman@23049 ` 556` ```lemma four_x_squared: ``` huffman@23049 ` 557` ``` fixes x::real ``` huffman@23049 ` 558` ``` shows "4 * x\ = (2 * x)\" ``` huffman@23049 ` 559` ```by (simp add: power2_eq_square) ``` huffman@23049 ` 560` huffman@22856 ` 561` ```subsection {* Square Root of Sum of Squares *} ``` huffman@22856 ` 562` huffman@44320 ` 563` ```lemma real_sqrt_sum_squares_ge_zero: "0 \ sqrt (x\ + y\)" ``` huffman@44320 ` 564` ``` by simp (* TODO: delete *) ``` huffman@22856 ` 565` huffman@23049 ` 566` ```declare real_sqrt_sum_squares_ge_zero [THEN abs_of_nonneg, simp] ``` huffman@23049 ` 567` huffman@22856 ` 568` ```lemma real_sqrt_sum_squares_mult_ge_zero [simp]: ``` huffman@22856 ` 569` ``` "0 \ sqrt ((x\ + y\)*(xa\ + ya\))" ``` huffman@44320 ` 570` ``` by (simp add: zero_le_mult_iff) ``` huffman@22856 ` 571` huffman@22856 ` 572` ```lemma real_sqrt_sum_squares_mult_squared_eq [simp]: ``` huffman@22856 ` 573` ``` "sqrt ((x\ + y\) * (xa\ + ya\)) ^ 2 = (x\ + y\) * (xa\ + ya\)" ``` huffman@44320 ` 574` ``` by (simp add: zero_le_mult_iff) ``` huffman@22856 ` 575` huffman@23049 ` 576` ```lemma real_sqrt_sum_squares_eq_cancel: "sqrt (x\ + y\) = x \ y = 0" ``` huffman@23049 ` 577` ```by (drule_tac f = "%x. x\" in arg_cong, simp) ``` huffman@23049 ` 578` huffman@23049 ` 579` ```lemma real_sqrt_sum_squares_eq_cancel2: "sqrt (x\ + y\) = y \ x = 0" ``` huffman@23049 ` 580` ```by (drule_tac f = "%x. x\" in arg_cong, simp) ``` huffman@23049 ` 581` huffman@23049 ` 582` ```lemma real_sqrt_sum_squares_ge1 [simp]: "x \ sqrt (x\ + y\)" ``` huffman@22856 ` 583` ```by (rule power2_le_imp_le, simp_all) ``` huffman@22856 ` 584` huffman@23049 ` 585` ```lemma real_sqrt_sum_squares_ge2 [simp]: "y \ sqrt (x\ + y\)" ``` huffman@23049 ` 586` ```by (rule power2_le_imp_le, simp_all) ``` huffman@23049 ` 587` huffman@23049 ` 588` ```lemma real_sqrt_ge_abs1 [simp]: "\x\ \ sqrt (x\ + y\)" ``` huffman@22856 ` 589` ```by (rule power2_le_imp_le, simp_all) ``` huffman@22856 ` 590` huffman@23049 ` 591` ```lemma real_sqrt_ge_abs2 [simp]: "\y\ \ sqrt (x\ + y\)" ``` huffman@23049 ` 592` ```by (rule power2_le_imp_le, simp_all) ``` huffman@23049 ` 593` huffman@23049 ` 594` ```lemma le_real_sqrt_sumsq [simp]: "x \ sqrt (x * x + y * y)" ``` huffman@23049 ` 595` ```by (simp add: power2_eq_square [symmetric]) ``` huffman@23049 ` 596` huffman@22858 ` 597` ```lemma real_sqrt_sum_squares_triangle_ineq: ``` huffman@22858 ` 598` ``` "sqrt ((a + c)\ + (b + d)\) \ sqrt (a\ + b\) + sqrt (c\ + d\)" ``` huffman@22858 ` 599` ```apply (rule power2_le_imp_le, simp) ``` huffman@22858 ` 600` ```apply (simp add: power2_sum) ``` huffman@22858 ` 601` ```apply (simp only: mult_assoc right_distrib [symmetric]) ``` huffman@22858 ` 602` ```apply (rule mult_left_mono) ``` huffman@22858 ` 603` ```apply (rule power2_le_imp_le) ``` huffman@22858 ` 604` ```apply (simp add: power2_sum power_mult_distrib) ``` nipkow@23477 ` 605` ```apply (simp add: ring_distribs) ``` huffman@22858 ` 606` ```apply (subgoal_tac "0 \ b\ * c\ + a\ * d\ - 2 * (a * c) * (b * d)", simp) ``` huffman@22858 ` 607` ```apply (rule_tac b="(a * d - b * c)\" in ord_le_eq_trans) ``` huffman@22858 ` 608` ```apply (rule zero_le_power2) ``` huffman@22858 ` 609` ```apply (simp add: power2_diff power_mult_distrib) ``` huffman@22858 ` 610` ```apply (simp add: mult_nonneg_nonneg) ``` huffman@22858 ` 611` ```apply simp ``` huffman@22858 ` 612` ```apply (simp add: add_increasing) ``` huffman@22858 ` 613` ```done ``` huffman@22858 ` 614` huffman@23122 ` 615` ```lemma real_sqrt_sum_squares_less: ``` huffman@23122 ` 616` ``` "\\x\ < u / sqrt 2; \y\ < u / sqrt 2\ \ sqrt (x\ + y\) < u" ``` huffman@23122 ` 617` ```apply (rule power2_less_imp_less, simp) ``` huffman@23122 ` 618` ```apply (drule power_strict_mono [OF _ abs_ge_zero pos2]) ``` huffman@23122 ` 619` ```apply (drule power_strict_mono [OF _ abs_ge_zero pos2]) ``` huffman@23122 ` 620` ```apply (simp add: power_divide) ``` huffman@23122 ` 621` ```apply (drule order_le_less_trans [OF abs_ge_zero]) ``` huffman@23122 ` 622` ```apply (simp add: zero_less_divide_iff) ``` huffman@23122 ` 623` ```done ``` huffman@23122 ` 624` huffman@23049 ` 625` ```text{*Needed for the infinitely close relation over the nonstandard ``` huffman@23049 ` 626` ``` complex numbers*} ``` huffman@23049 ` 627` ```lemma lemma_sqrt_hcomplex_capprox: ``` huffman@23049 ` 628` ``` "[| 0 < u; x < u/2; y < u/2; 0 \ x; 0 \ y |] ==> sqrt (x\ + y\) < u" ``` huffman@23049 ` 629` ```apply (rule_tac y = "u/sqrt 2" in order_le_less_trans) ``` huffman@23049 ` 630` ```apply (erule_tac [2] lemma_real_divide_sqrt_less) ``` huffman@23049 ` 631` ```apply (rule power2_le_imp_le) ``` huffman@44349 ` 632` ```apply (auto simp add: zero_le_divide_iff power_divide) ``` huffman@23049 ` 633` ```apply (rule_tac t = "u\" in real_sum_of_halves [THEN subst]) ``` huffman@23049 ` 634` ```apply (rule add_mono) ``` huffman@30273 ` 635` ```apply (auto simp add: four_x_squared intro: power_mono) ``` huffman@23049 ` 636` ```done ``` huffman@23049 ` 637` huffman@22956 ` 638` ```text "Legacy theorem names:" ``` huffman@22956 ` 639` ```lemmas real_root_pos2 = real_root_power_cancel ``` huffman@22956 ` 640` ```lemmas real_root_pos_pos = real_root_gt_zero [THEN order_less_imp_le] ``` huffman@22956 ` 641` ```lemmas real_root_pos_pos_le = real_root_ge_zero ``` huffman@22956 ` 642` ```lemmas real_sqrt_mult_distrib = real_sqrt_mult ``` huffman@22956 ` 643` ```lemmas real_sqrt_mult_distrib2 = real_sqrt_mult ``` huffman@22956 ` 644` ```lemmas real_sqrt_eq_zero_cancel_iff = real_sqrt_eq_0_iff ``` huffman@22956 ` 645` huffman@22956 ` 646` ```(* needed for CauchysMeanTheorem.het_base from AFP *) ``` huffman@22956 ` 647` ```lemma real_root_pos: "0 < x \ root (Suc n) (x ^ (Suc n)) = x" ``` huffman@22956 ` 648` ```by (rule real_root_power_cancel [OF zero_less_Suc order_less_imp_le]) ``` huffman@22956 ` 649` paulson@14324 ` 650` ```end ```