src/HOL/Hyperreal/Ln.thy
 author huffman Sun Sep 24 05:49:50 2006 +0200 (2006-09-24) changeset 20692 6df83a636e67 parent 20563 44eda2314aab child 22654 c2b6b5a9e136 permissions -rwxr-xr-x
generalized types of sums, summable, and suminf
 avigad@16959 ` 1` ```(* Title: Ln.thy ``` avigad@16959 ` 2` ``` Author: Jeremy Avigad ``` nipkow@16963 ` 3` ``` ID: \$Id\$ ``` avigad@16959 ` 4` ```*) ``` avigad@16959 ` 5` avigad@16959 ` 6` ```header {* Properties of ln *} ``` avigad@16959 ` 7` avigad@16959 ` 8` ```theory Ln ``` avigad@16959 ` 9` ```imports Transcendental ``` avigad@16959 ` 10` ```begin ``` avigad@16959 ` 11` avigad@16959 ` 12` ```lemma exp_first_two_terms: "exp x = 1 + x + suminf (%n. ``` avigad@16959 ` 13` ``` inverse(real (fact (n+2))) * (x ^ (n+2)))" ``` avigad@16959 ` 14` ```proof - ``` avigad@16959 ` 15` ``` have "exp x = suminf (%n. inverse(real (fact n)) * (x ^ n))" ``` wenzelm@19765 ` 16` ``` by (simp add: exp_def) ``` avigad@16959 ` 17` ``` also from summable_exp have "... = (SUM n : {0..<2}. ``` avigad@16959 ` 18` ``` inverse(real (fact n)) * (x ^ n)) + suminf (%n. ``` avigad@16959 ` 19` ``` inverse(real (fact (n+2))) * (x ^ (n+2)))" (is "_ = ?a + _") ``` avigad@16959 ` 20` ``` by (rule suminf_split_initial_segment) ``` avigad@16959 ` 21` ``` also have "?a = 1 + x" ``` avigad@16959 ` 22` ``` by (simp add: numerals) ``` avigad@16959 ` 23` ``` finally show ?thesis . ``` avigad@16959 ` 24` ```qed ``` avigad@16959 ` 25` avigad@16959 ` 26` ```lemma exp_tail_after_first_two_terms_summable: ``` avigad@16959 ` 27` ``` "summable (%n. inverse(real (fact (n+2))) * (x ^ (n+2)))" ``` avigad@16959 ` 28` ```proof - ``` avigad@16959 ` 29` ``` note summable_exp ``` avigad@16959 ` 30` ``` thus ?thesis ``` avigad@16959 ` 31` ``` by (frule summable_ignore_initial_segment) ``` avigad@16959 ` 32` ```qed ``` avigad@16959 ` 33` avigad@16959 ` 34` ```lemma aux1: assumes a: "0 <= x" and b: "x <= 1" ``` avigad@16959 ` 35` ``` shows "inverse (real (fact (n + 2))) * x ^ (n + 2) <= (x^2/2) * ((1/2)^n)" ``` avigad@16959 ` 36` ```proof (induct n) ``` avigad@16959 ` 37` ``` show "inverse (real (fact (0 + 2))) * x ^ (0 + 2) <= ``` avigad@16959 ` 38` ``` x ^ 2 / 2 * (1 / 2) ^ 0" ``` avigad@16959 ` 39` ``` apply (simp add: power2_eq_square) ``` avigad@16959 ` 40` ``` apply (subgoal_tac "real (Suc (Suc 0)) = 2") ``` avigad@16959 ` 41` ``` apply (erule ssubst) ``` avigad@16959 ` 42` ``` apply simp ``` avigad@16959 ` 43` ``` apply simp ``` avigad@16959 ` 44` ``` done ``` avigad@16959 ` 45` ```next ``` avigad@16959 ` 46` ``` fix n ``` avigad@16959 ` 47` ``` assume c: "inverse (real (fact (n + 2))) * x ^ (n + 2) ``` avigad@16959 ` 48` ``` <= x ^ 2 / 2 * (1 / 2) ^ n" ``` avigad@16959 ` 49` ``` show "inverse (real (fact (Suc n + 2))) * x ^ (Suc n + 2) ``` avigad@16959 ` 50` ``` <= x ^ 2 / 2 * (1 / 2) ^ Suc n" ``` avigad@16959 ` 51` ``` proof - ``` avigad@16959 ` 52` ``` have "inverse(real (fact (Suc n + 2))) <= ``` avigad@16959 ` 53` ``` (1 / 2) *inverse (real (fact (n+2)))" ``` avigad@16959 ` 54` ``` proof - ``` avigad@16959 ` 55` ``` have "Suc n + 2 = Suc (n + 2)" by simp ``` avigad@16959 ` 56` ``` then have "fact (Suc n + 2) = Suc (n + 2) * fact (n + 2)" ``` avigad@16959 ` 57` ``` by simp ``` avigad@16959 ` 58` ``` then have "real(fact (Suc n + 2)) = real(Suc (n + 2) * fact (n + 2))" ``` avigad@16959 ` 59` ``` apply (rule subst) ``` avigad@16959 ` 60` ``` apply (rule refl) ``` avigad@16959 ` 61` ``` done ``` avigad@16959 ` 62` ``` also have "... = real(Suc (n + 2)) * real(fact (n + 2))" ``` avigad@16959 ` 63` ``` by (rule real_of_nat_mult) ``` avigad@16959 ` 64` ``` finally have "real (fact (Suc n + 2)) = ``` avigad@16959 ` 65` ``` real (Suc (n + 2)) * real (fact (n + 2))" . ``` avigad@16959 ` 66` ``` then have "inverse(real (fact (Suc n + 2))) = ``` avigad@16959 ` 67` ``` inverse(real (Suc (n + 2))) * inverse(real (fact (n + 2)))" ``` avigad@16959 ` 68` ``` apply (rule ssubst) ``` avigad@16959 ` 69` ``` apply (rule inverse_mult_distrib) ``` avigad@16959 ` 70` ``` done ``` avigad@16959 ` 71` ``` also have "... <= (1/2) * inverse(real (fact (n + 2)))" ``` avigad@16959 ` 72` ``` apply (rule mult_right_mono) ``` avigad@16959 ` 73` ``` apply (subst inverse_eq_divide) ``` avigad@16959 ` 74` ``` apply simp ``` avigad@16959 ` 75` ``` apply (rule inv_real_of_nat_fact_ge_zero) ``` avigad@16959 ` 76` ``` done ``` avigad@16959 ` 77` ``` finally show ?thesis . ``` avigad@16959 ` 78` ``` qed ``` avigad@16959 ` 79` ``` moreover have "x ^ (Suc n + 2) <= x ^ (n + 2)" ``` avigad@16959 ` 80` ``` apply (simp add: mult_compare_simps) ``` avigad@16959 ` 81` ``` apply (simp add: prems) ``` avigad@16959 ` 82` ``` apply (subgoal_tac "0 <= x * (x * x^n)") ``` avigad@16959 ` 83` ``` apply force ``` avigad@16959 ` 84` ``` apply (rule mult_nonneg_nonneg, rule a)+ ``` avigad@16959 ` 85` ``` apply (rule zero_le_power, rule a) ``` avigad@16959 ` 86` ``` done ``` avigad@16959 ` 87` ``` ultimately have "inverse (real (fact (Suc n + 2))) * x ^ (Suc n + 2) <= ``` avigad@16959 ` 88` ``` (1 / 2 * inverse (real (fact (n + 2)))) * x ^ (n + 2)" ``` avigad@16959 ` 89` ``` apply (rule mult_mono) ``` avigad@16959 ` 90` ``` apply (rule mult_nonneg_nonneg) ``` avigad@16959 ` 91` ``` apply simp ``` avigad@16959 ` 92` ``` apply (subst inverse_nonnegative_iff_nonnegative) ``` avigad@16959 ` 93` ``` apply (rule real_of_nat_fact_ge_zero) ``` avigad@16959 ` 94` ``` apply (rule zero_le_power) ``` avigad@16959 ` 95` ``` apply assumption ``` avigad@16959 ` 96` ``` done ``` avigad@16959 ` 97` ``` also have "... = 1 / 2 * (inverse (real (fact (n + 2))) * x ^ (n + 2))" ``` avigad@16959 ` 98` ``` by simp ``` avigad@16959 ` 99` ``` also have "... <= 1 / 2 * (x ^ 2 / 2 * (1 / 2) ^ n)" ``` avigad@16959 ` 100` ``` apply (rule mult_left_mono) ``` avigad@16959 ` 101` ``` apply (rule prems) ``` avigad@16959 ` 102` ``` apply simp ``` avigad@16959 ` 103` ``` done ``` avigad@16959 ` 104` ``` also have "... = x ^ 2 / 2 * (1 / 2 * (1 / 2) ^ n)" ``` avigad@16959 ` 105` ``` by auto ``` avigad@16959 ` 106` ``` also have "(1::real) / 2 * (1 / 2) ^ n = (1 / 2) ^ (Suc n)" ``` avigad@16959 ` 107` ``` by (rule realpow_Suc [THEN sym]) ``` avigad@16959 ` 108` ``` finally show ?thesis . ``` avigad@16959 ` 109` ``` qed ``` avigad@16959 ` 110` ```qed ``` avigad@16959 ` 111` huffman@20692 ` 112` ```lemma aux2: "(%n. (x::real) ^ 2 / 2 * (1 / 2) ^ n) sums x^2" ``` avigad@16959 ` 113` ```proof - ``` huffman@20692 ` 114` ``` have "(%n. (1 / 2::real)^n) sums (1 / (1 - (1/2)))" ``` avigad@16959 ` 115` ``` apply (rule geometric_sums) ``` avigad@16959 ` 116` ``` by (simp add: abs_interval_iff) ``` avigad@16959 ` 117` ``` also have "(1::real) / (1 - 1/2) = 2" ``` avigad@16959 ` 118` ``` by simp ``` huffman@20692 ` 119` ``` finally have "(%n. (1 / 2::real)^n) sums 2" . ``` avigad@16959 ` 120` ``` then have "(%n. x ^ 2 / 2 * (1 / 2) ^ n) sums (x^2 / 2 * 2)" ``` avigad@16959 ` 121` ``` by (rule sums_mult) ``` avigad@16959 ` 122` ``` also have "x^2 / 2 * 2 = x^2" ``` avigad@16959 ` 123` ``` by simp ``` avigad@16959 ` 124` ``` finally show ?thesis . ``` avigad@16959 ` 125` ```qed ``` avigad@16959 ` 126` avigad@16959 ` 127` ```lemma exp_bound: "0 <= x ==> x <= 1 ==> exp x <= 1 + x + x^2" ``` avigad@16959 ` 128` ```proof - ``` avigad@16959 ` 129` ``` assume a: "0 <= x" ``` avigad@16959 ` 130` ``` assume b: "x <= 1" ``` avigad@16959 ` 131` ``` have c: "exp x = 1 + x + suminf (%n. inverse(real (fact (n+2))) * ``` avigad@16959 ` 132` ``` (x ^ (n+2)))" ``` avigad@16959 ` 133` ``` by (rule exp_first_two_terms) ``` avigad@16959 ` 134` ``` moreover have "suminf (%n. inverse(real (fact (n+2))) * (x ^ (n+2))) <= x^2" ``` avigad@16959 ` 135` ``` proof - ``` avigad@16959 ` 136` ``` have "suminf (%n. inverse(real (fact (n+2))) * (x ^ (n+2))) <= ``` avigad@16959 ` 137` ``` suminf (%n. (x^2/2) * ((1/2)^n))" ``` avigad@16959 ` 138` ``` apply (rule summable_le) ``` avigad@16959 ` 139` ``` apply (auto simp only: aux1 prems) ``` avigad@16959 ` 140` ``` apply (rule exp_tail_after_first_two_terms_summable) ``` avigad@16959 ` 141` ``` by (rule sums_summable, rule aux2) ``` avigad@16959 ` 142` ``` also have "... = x^2" ``` avigad@16959 ` 143` ``` by (rule sums_unique [THEN sym], rule aux2) ``` avigad@16959 ` 144` ``` finally show ?thesis . ``` avigad@16959 ` 145` ``` qed ``` avigad@16959 ` 146` ``` ultimately show ?thesis ``` avigad@16959 ` 147` ``` by auto ``` avigad@16959 ` 148` ```qed ``` avigad@16959 ` 149` avigad@16959 ` 150` ```lemma aux3: "(0::real) <= x ==> (1 + x + x^2)/(1 + x^2) <= 1 + x" ``` avigad@16959 ` 151` ``` apply (subst pos_divide_le_eq) ``` avigad@16959 ` 152` ``` apply (simp add: zero_compare_simps) ``` avigad@16959 ` 153` ``` apply (simp add: ring_eq_simps zero_compare_simps) ``` avigad@16959 ` 154` ```done ``` avigad@16959 ` 155` avigad@16959 ` 156` ```lemma aux4: "0 <= x ==> x <= 1 ==> exp (x - x^2) <= 1 + x" ``` avigad@16959 ` 157` ```proof - ``` avigad@16959 ` 158` ``` assume a: "0 <= x" and b: "x <= 1" ``` avigad@16959 ` 159` ``` have "exp (x - x^2) = exp x / exp (x^2)" ``` avigad@16959 ` 160` ``` by (rule exp_diff) ``` avigad@16959 ` 161` ``` also have "... <= (1 + x + x^2) / exp (x ^2)" ``` avigad@16959 ` 162` ``` apply (rule divide_right_mono) ``` avigad@16959 ` 163` ``` apply (rule exp_bound) ``` avigad@16959 ` 164` ``` apply (rule a, rule b) ``` avigad@16959 ` 165` ``` apply simp ``` avigad@16959 ` 166` ``` done ``` avigad@16959 ` 167` ``` also have "... <= (1 + x + x^2) / (1 + x^2)" ``` avigad@16959 ` 168` ``` apply (rule divide_left_mono) ``` avigad@17013 ` 169` ``` apply (auto simp add: exp_ge_add_one_self_aux) ``` avigad@16959 ` 170` ``` apply (rule add_nonneg_nonneg) ``` avigad@16959 ` 171` ``` apply (insert prems, auto) ``` avigad@16959 ` 172` ``` apply (rule mult_pos_pos) ``` avigad@16959 ` 173` ``` apply auto ``` avigad@16959 ` 174` ``` apply (rule add_pos_nonneg) ``` avigad@16959 ` 175` ``` apply auto ``` avigad@16959 ` 176` ``` done ``` avigad@16959 ` 177` ``` also from a have "... <= 1 + x" ``` avigad@16959 ` 178` ``` by (rule aux3) ``` avigad@16959 ` 179` ``` finally show ?thesis . ``` avigad@16959 ` 180` ```qed ``` avigad@16959 ` 181` avigad@16959 ` 182` ```lemma ln_one_plus_pos_lower_bound: "0 <= x ==> x <= 1 ==> ``` avigad@16959 ` 183` ``` x - x^2 <= ln (1 + x)" ``` avigad@16959 ` 184` ```proof - ``` avigad@16959 ` 185` ``` assume a: "0 <= x" and b: "x <= 1" ``` avigad@16959 ` 186` ``` then have "exp (x - x^2) <= 1 + x" ``` avigad@16959 ` 187` ``` by (rule aux4) ``` avigad@16959 ` 188` ``` also have "... = exp (ln (1 + x))" ``` avigad@16959 ` 189` ``` proof - ``` avigad@16959 ` 190` ``` from a have "0 < 1 + x" by auto ``` avigad@16959 ` 191` ``` thus ?thesis ``` avigad@16959 ` 192` ``` by (auto simp only: exp_ln_iff [THEN sym]) ``` avigad@16959 ` 193` ``` qed ``` avigad@16959 ` 194` ``` finally have "exp (x - x ^ 2) <= exp (ln (1 + x))" . ``` avigad@16959 ` 195` ``` thus ?thesis by (auto simp only: exp_le_cancel_iff) ``` avigad@16959 ` 196` ```qed ``` avigad@16959 ` 197` avigad@16959 ` 198` ```lemma ln_one_minus_pos_upper_bound: "0 <= x ==> x < 1 ==> ln (1 - x) <= - x" ``` avigad@16959 ` 199` ```proof - ``` avigad@16959 ` 200` ``` assume a: "0 <= (x::real)" and b: "x < 1" ``` avigad@16959 ` 201` ``` have "(1 - x) * (1 + x + x^2) = (1 - x^3)" ``` avigad@16959 ` 202` ``` by (simp add: ring_eq_simps power2_eq_square power3_eq_cube) ``` avigad@16959 ` 203` ``` also have "... <= 1" ``` avigad@16959 ` 204` ``` by (auto intro: zero_le_power simp add: a) ``` avigad@16959 ` 205` ``` finally have "(1 - x) * (1 + x + x ^ 2) <= 1" . ``` avigad@16959 ` 206` ``` moreover have "0 < 1 + x + x^2" ``` avigad@16959 ` 207` ``` apply (rule add_pos_nonneg) ``` avigad@16959 ` 208` ``` apply (insert a, auto) ``` avigad@16959 ` 209` ``` done ``` avigad@16959 ` 210` ``` ultimately have "1 - x <= 1 / (1 + x + x^2)" ``` avigad@16959 ` 211` ``` by (elim mult_imp_le_div_pos) ``` avigad@16959 ` 212` ``` also have "... <= 1 / exp x" ``` avigad@16959 ` 213` ``` apply (rule divide_left_mono) ``` avigad@16959 ` 214` ``` apply (rule exp_bound, rule a) ``` avigad@16959 ` 215` ``` apply (insert prems, auto) ``` avigad@16959 ` 216` ``` apply (rule mult_pos_pos) ``` avigad@16959 ` 217` ``` apply (rule add_pos_nonneg) ``` avigad@16959 ` 218` ``` apply auto ``` avigad@16959 ` 219` ``` done ``` avigad@16959 ` 220` ``` also have "... = exp (-x)" ``` avigad@16959 ` 221` ``` by (auto simp add: exp_minus real_divide_def) ``` avigad@16959 ` 222` ``` finally have "1 - x <= exp (- x)" . ``` avigad@16959 ` 223` ``` also have "1 - x = exp (ln (1 - x))" ``` avigad@16959 ` 224` ``` proof - ``` avigad@16959 ` 225` ``` have "0 < 1 - x" ``` avigad@16959 ` 226` ``` by (insert b, auto) ``` avigad@16959 ` 227` ``` thus ?thesis ``` avigad@16959 ` 228` ``` by (auto simp only: exp_ln_iff [THEN sym]) ``` avigad@16959 ` 229` ``` qed ``` avigad@16959 ` 230` ``` finally have "exp (ln (1 - x)) <= exp (- x)" . ``` avigad@16959 ` 231` ``` thus ?thesis by (auto simp only: exp_le_cancel_iff) ``` avigad@16959 ` 232` ```qed ``` avigad@16959 ` 233` avigad@16959 ` 234` ```lemma aux5: "x < 1 ==> ln(1 - x) = - ln(1 + x / (1 - x))" ``` avigad@16959 ` 235` ```proof - ``` avigad@16959 ` 236` ``` assume a: "x < 1" ``` avigad@16959 ` 237` ``` have "ln(1 - x) = - ln(1 / (1 - x))" ``` avigad@16959 ` 238` ``` proof - ``` avigad@16959 ` 239` ``` have "ln(1 - x) = - (- ln (1 - x))" ``` avigad@16959 ` 240` ``` by auto ``` avigad@16959 ` 241` ``` also have "- ln(1 - x) = ln 1 - ln(1 - x)" ``` avigad@16959 ` 242` ``` by simp ``` avigad@16959 ` 243` ``` also have "... = ln(1 / (1 - x))" ``` avigad@16959 ` 244` ``` apply (rule ln_div [THEN sym]) ``` avigad@16959 ` 245` ``` by (insert a, auto) ``` avigad@16959 ` 246` ``` finally show ?thesis . ``` avigad@16959 ` 247` ``` qed ``` avigad@16959 ` 248` ``` also have " 1 / (1 - x) = 1 + x / (1 - x)" ``` avigad@16959 ` 249` ``` proof - ``` avigad@16959 ` 250` ``` have "1 / (1 - x) = (1 - x + x) / (1 - x)" ``` avigad@16959 ` 251` ``` by auto ``` avigad@16959 ` 252` ``` also have "... = (1 - x) / (1 - x) + x / (1 - x)" ``` avigad@16959 ` 253` ``` by (rule add_divide_distrib) ``` avigad@16959 ` 254` ``` also have "... = 1 + x / (1-x)" ``` avigad@16959 ` 255` ``` apply (subst add_right_cancel) ``` avigad@16959 ` 256` ``` apply (insert a, simp) ``` avigad@16959 ` 257` ``` done ``` avigad@16959 ` 258` ``` finally show ?thesis . ``` avigad@16959 ` 259` ``` qed ``` avigad@16959 ` 260` ``` finally show ?thesis . ``` avigad@16959 ` 261` ```qed ``` avigad@16959 ` 262` avigad@16959 ` 263` ```lemma ln_one_minus_pos_lower_bound: "0 <= x ==> x <= (1 / 2) ==> ``` avigad@16959 ` 264` ``` - x - 2 * x^2 <= ln (1 - x)" ``` avigad@16959 ` 265` ```proof - ``` avigad@16959 ` 266` ``` assume a: "0 <= x" and b: "x <= (1 / 2)" ``` avigad@16959 ` 267` ``` from b have c: "x < 1" ``` avigad@16959 ` 268` ``` by auto ``` avigad@16959 ` 269` ``` then have "ln (1 - x) = - ln (1 + x / (1 - x))" ``` avigad@16959 ` 270` ``` by (rule aux5) ``` avigad@16959 ` 271` ``` also have "- (x / (1 - x)) <= ..." ``` avigad@16959 ` 272` ``` proof - ``` avigad@16959 ` 273` ``` have "ln (1 + x / (1 - x)) <= x / (1 - x)" ``` avigad@16959 ` 274` ``` apply (rule ln_add_one_self_le_self) ``` avigad@16959 ` 275` ``` apply (rule divide_nonneg_pos) ``` avigad@16959 ` 276` ``` by (insert a c, auto) ``` avigad@16959 ` 277` ``` thus ?thesis ``` avigad@16959 ` 278` ``` by auto ``` avigad@16959 ` 279` ``` qed ``` avigad@16959 ` 280` ``` also have "- (x / (1 - x)) = -x / (1 - x)" ``` avigad@16959 ` 281` ``` by auto ``` avigad@16959 ` 282` ``` finally have d: "- x / (1 - x) <= ln (1 - x)" . ``` avigad@16959 ` 283` ``` have e: "-x - 2 * x^2 <= - x / (1 - x)" ``` avigad@16959 ` 284` ``` apply (rule mult_imp_le_div_pos) ``` avigad@16959 ` 285` ``` apply (insert prems, force) ``` avigad@16959 ` 286` ``` apply (auto simp add: ring_eq_simps power2_eq_square) ``` avigad@16959 ` 287` ``` apply (subgoal_tac "- (x * x) + x * (x * (x * 2)) = x^2 * (2 * x - 1)") ``` avigad@16959 ` 288` ``` apply (erule ssubst) ``` avigad@16959 ` 289` ``` apply (rule mult_nonneg_nonpos) ``` avigad@16959 ` 290` ``` apply auto ``` avigad@16959 ` 291` ``` apply (auto simp add: ring_eq_simps power2_eq_square) ``` avigad@16959 ` 292` ``` done ``` avigad@16959 ` 293` ``` from e d show "- x - 2 * x^2 <= ln (1 - x)" ``` avigad@16959 ` 294` ``` by (rule order_trans) ``` avigad@16959 ` 295` ```qed ``` avigad@16959 ` 296` avigad@17013 ` 297` ```lemma exp_ge_add_one_self [simp]: "1 + x <= exp x" ``` avigad@16959 ` 298` ``` apply (case_tac "0 <= x") ``` avigad@17013 ` 299` ``` apply (erule exp_ge_add_one_self_aux) ``` avigad@16959 ` 300` ``` apply (case_tac "x <= -1") ``` avigad@16959 ` 301` ``` apply (subgoal_tac "1 + x <= 0") ``` avigad@16959 ` 302` ``` apply (erule order_trans) ``` avigad@16959 ` 303` ``` apply simp ``` avigad@16959 ` 304` ``` apply simp ``` avigad@16959 ` 305` ``` apply (subgoal_tac "1 + x = exp(ln (1 + x))") ``` avigad@16959 ` 306` ``` apply (erule ssubst) ``` avigad@16959 ` 307` ``` apply (subst exp_le_cancel_iff) ``` avigad@16959 ` 308` ``` apply (subgoal_tac "ln (1 - (- x)) <= - (- x)") ``` avigad@16959 ` 309` ``` apply simp ``` avigad@16959 ` 310` ``` apply (rule ln_one_minus_pos_upper_bound) ``` avigad@16959 ` 311` ``` apply auto ``` avigad@16959 ` 312` ``` apply (rule sym) ``` avigad@16959 ` 313` ``` apply (subst exp_ln_iff) ``` avigad@16959 ` 314` ``` apply auto ``` avigad@16959 ` 315` ```done ``` avigad@16959 ` 316` avigad@16959 ` 317` ```lemma ln_add_one_self_le_self2: "-1 < x ==> ln(1 + x) <= x" ``` avigad@16959 ` 318` ``` apply (subgoal_tac "x = ln (exp x)") ``` avigad@16959 ` 319` ``` apply (erule ssubst)back ``` avigad@16959 ` 320` ``` apply (subst ln_le_cancel_iff) ``` avigad@16959 ` 321` ``` apply auto ``` avigad@16959 ` 322` ```done ``` avigad@16959 ` 323` avigad@16959 ` 324` ```lemma abs_ln_one_plus_x_minus_x_bound_nonneg: ``` avigad@16959 ` 325` ``` "0 <= x ==> x <= 1 ==> abs(ln (1 + x) - x) <= x^2" ``` avigad@16959 ` 326` ```proof - ``` avigad@16959 ` 327` ``` assume "0 <= x" ``` avigad@16959 ` 328` ``` assume "x <= 1" ``` avigad@16959 ` 329` ``` have "ln (1 + x) <= x" ``` avigad@16959 ` 330` ``` by (rule ln_add_one_self_le_self) ``` avigad@16959 ` 331` ``` then have "ln (1 + x) - x <= 0" ``` avigad@16959 ` 332` ``` by simp ``` avigad@16959 ` 333` ``` then have "abs(ln(1 + x) - x) = - (ln(1 + x) - x)" ``` avigad@16959 ` 334` ``` by (rule abs_of_nonpos) ``` avigad@16959 ` 335` ``` also have "... = x - ln (1 + x)" ``` avigad@16959 ` 336` ``` by simp ``` avigad@16959 ` 337` ``` also have "... <= x^2" ``` avigad@16959 ` 338` ``` proof - ``` avigad@16959 ` 339` ``` from prems have "x - x^2 <= ln (1 + x)" ``` avigad@16959 ` 340` ``` by (intro ln_one_plus_pos_lower_bound) ``` avigad@16959 ` 341` ``` thus ?thesis ``` avigad@16959 ` 342` ``` by simp ``` avigad@16959 ` 343` ``` qed ``` avigad@16959 ` 344` ``` finally show ?thesis . ``` avigad@16959 ` 345` ```qed ``` avigad@16959 ` 346` avigad@16959 ` 347` ```lemma abs_ln_one_plus_x_minus_x_bound_nonpos: ``` avigad@16959 ` 348` ``` "-(1 / 2) <= x ==> x <= 0 ==> abs(ln (1 + x) - x) <= 2 * x^2" ``` avigad@16959 ` 349` ```proof - ``` avigad@16959 ` 350` ``` assume "-(1 / 2) <= x" ``` avigad@16959 ` 351` ``` assume "x <= 0" ``` avigad@16959 ` 352` ``` have "abs(ln (1 + x) - x) = x - ln(1 - (-x))" ``` avigad@16959 ` 353` ``` apply (subst abs_of_nonpos) ``` avigad@16959 ` 354` ``` apply simp ``` avigad@16959 ` 355` ``` apply (rule ln_add_one_self_le_self2) ``` avigad@16959 ` 356` ``` apply (insert prems, auto) ``` avigad@16959 ` 357` ``` done ``` avigad@16959 ` 358` ``` also have "... <= 2 * x^2" ``` avigad@16959 ` 359` ``` apply (subgoal_tac "- (-x) - 2 * (-x)^2 <= ln (1 - (-x))") ``` avigad@16959 ` 360` ``` apply (simp add: compare_rls) ``` avigad@16959 ` 361` ``` apply (rule ln_one_minus_pos_lower_bound) ``` avigad@16959 ` 362` ``` apply (insert prems, auto) ``` avigad@16959 ` 363` ``` done ``` avigad@16959 ` 364` ``` finally show ?thesis . ``` avigad@16959 ` 365` ```qed ``` avigad@16959 ` 366` avigad@16959 ` 367` ```lemma abs_ln_one_plus_x_minus_x_bound: ``` avigad@16959 ` 368` ``` "abs x <= 1 / 2 ==> abs(ln (1 + x) - x) <= 2 * x^2" ``` avigad@16959 ` 369` ``` apply (case_tac "0 <= x") ``` avigad@16959 ` 370` ``` apply (rule order_trans) ``` avigad@16959 ` 371` ``` apply (rule abs_ln_one_plus_x_minus_x_bound_nonneg) ``` avigad@16959 ` 372` ``` apply auto ``` avigad@16959 ` 373` ``` apply (rule abs_ln_one_plus_x_minus_x_bound_nonpos) ``` avigad@16959 ` 374` ``` apply auto ``` avigad@16959 ` 375` ```done ``` avigad@16959 ` 376` avigad@16959 ` 377` ```lemma DERIV_ln: "0 < x ==> DERIV ln x :> 1 / x" ``` avigad@16959 ` 378` ``` apply (unfold deriv_def, unfold LIM_def, clarsimp) ``` avigad@16959 ` 379` ``` apply (rule exI) ``` avigad@16959 ` 380` ``` apply (rule conjI) ``` avigad@16959 ` 381` ``` prefer 2 ``` avigad@16959 ` 382` ``` apply clarsimp ``` huffman@20563 ` 383` ``` apply (subgoal_tac "(ln (x + xa) - ln x) / xa - (1 / x) = ``` avigad@16959 ` 384` ``` (ln (1 + xa / x) - xa / x) / xa") ``` avigad@16959 ` 385` ``` apply (erule ssubst) ``` avigad@16959 ` 386` ``` apply (subst abs_divide) ``` avigad@16959 ` 387` ``` apply (rule mult_imp_div_pos_less) ``` avigad@16959 ` 388` ``` apply force ``` avigad@16959 ` 389` ``` apply (rule order_le_less_trans) ``` avigad@16959 ` 390` ``` apply (rule abs_ln_one_plus_x_minus_x_bound) ``` avigad@16959 ` 391` ``` apply (subst abs_divide) ``` avigad@16959 ` 392` ``` apply (subst abs_of_pos, assumption) ``` avigad@16959 ` 393` ``` apply (erule mult_imp_div_pos_le) ``` avigad@16959 ` 394` ``` apply (subgoal_tac "abs xa < min (x / 2) (r * x^2 / 2)") ``` avigad@16959 ` 395` ``` apply force ``` avigad@16959 ` 396` ``` apply assumption ``` webertj@20432 ` 397` ``` apply (simp add: power2_eq_square mult_compare_simps) ``` avigad@16959 ` 398` ``` apply (rule mult_imp_div_pos_less) ``` avigad@16959 ` 399` ``` apply (rule mult_pos_pos, assumption, assumption) ``` avigad@16959 ` 400` ``` apply (subgoal_tac "xa * xa = abs xa * abs xa") ``` avigad@16959 ` 401` ``` apply (erule ssubst) ``` avigad@16959 ` 402` ``` apply (subgoal_tac "abs xa * (abs xa * 2) < abs xa * (r * (x * x))") ``` avigad@16959 ` 403` ``` apply (simp only: mult_ac) ``` avigad@16959 ` 404` ``` apply (rule mult_strict_left_mono) ``` avigad@16959 ` 405` ``` apply (erule conjE, assumption) ``` avigad@16959 ` 406` ``` apply force ``` avigad@16959 ` 407` ``` apply simp ``` avigad@16959 ` 408` ``` apply (subst ln_div [THEN sym]) ``` avigad@16959 ` 409` ``` apply arith ``` avigad@16959 ` 410` ``` apply (auto simp add: ring_eq_simps add_frac_eq frac_eq_eq ``` avigad@16959 ` 411` ``` add_divide_distrib power2_eq_square) ``` avigad@16959 ` 412` ``` apply (rule mult_pos_pos, assumption)+ ``` avigad@16959 ` 413` ``` apply assumption ``` avigad@16959 ` 414` ```done ``` avigad@16959 ` 415` avigad@16959 ` 416` ```lemma ln_x_over_x_mono: "exp 1 <= x ==> x <= y ==> (ln y / y) <= (ln x / x)" ``` avigad@16959 ` 417` ```proof - ``` avigad@16959 ` 418` ``` assume "exp 1 <= x" and "x <= y" ``` avigad@16959 ` 419` ``` have a: "0 < x" and b: "0 < y" ``` avigad@16959 ` 420` ``` apply (insert prems) ``` avigad@16959 ` 421` ``` apply (subgoal_tac "0 < exp 1") ``` avigad@16959 ` 422` ``` apply arith ``` avigad@16959 ` 423` ``` apply auto ``` avigad@16959 ` 424` ``` apply (subgoal_tac "0 < exp 1") ``` avigad@16959 ` 425` ``` apply arith ``` avigad@16959 ` 426` ``` apply auto ``` avigad@16959 ` 427` ``` done ``` avigad@16959 ` 428` ``` have "x * ln y - x * ln x = x * (ln y - ln x)" ``` avigad@16959 ` 429` ``` by (simp add: ring_eq_simps) ``` avigad@16959 ` 430` ``` also have "... = x * ln(y / x)" ``` avigad@16959 ` 431` ``` apply (subst ln_div) ``` avigad@16959 ` 432` ``` apply (rule b, rule a, rule refl) ``` avigad@16959 ` 433` ``` done ``` avigad@16959 ` 434` ``` also have "y / x = (x + (y - x)) / x" ``` avigad@16959 ` 435` ``` by simp ``` avigad@16959 ` 436` ``` also have "... = 1 + (y - x) / x" ``` avigad@16959 ` 437` ``` apply (simp only: add_divide_distrib) ``` avigad@16959 ` 438` ``` apply (simp add: prems) ``` avigad@16959 ` 439` ``` apply (insert a, arith) ``` avigad@16959 ` 440` ``` done ``` avigad@16959 ` 441` ``` also have "x * ln(1 + (y - x) / x) <= x * ((y - x) / x)" ``` avigad@16959 ` 442` ``` apply (rule mult_left_mono) ``` avigad@16959 ` 443` ``` apply (rule ln_add_one_self_le_self) ``` avigad@16959 ` 444` ``` apply (rule divide_nonneg_pos) ``` avigad@16959 ` 445` ``` apply (insert prems a, simp_all) ``` avigad@16959 ` 446` ``` done ``` avigad@16959 ` 447` ``` also have "... = y - x" ``` avigad@16959 ` 448` ``` by (insert a, simp) ``` avigad@16959 ` 449` ``` also have "... = (y - x) * ln (exp 1)" ``` avigad@16959 ` 450` ``` by simp ``` avigad@16959 ` 451` ``` also have "... <= (y - x) * ln x" ``` avigad@16959 ` 452` ``` apply (rule mult_left_mono) ``` avigad@16959 ` 453` ``` apply (subst ln_le_cancel_iff) ``` avigad@16959 ` 454` ``` apply force ``` avigad@16959 ` 455` ``` apply (rule a) ``` avigad@16959 ` 456` ``` apply (rule prems) ``` avigad@16959 ` 457` ``` apply (insert prems, simp) ``` avigad@16959 ` 458` ``` done ``` avigad@16959 ` 459` ``` also have "... = y * ln x - x * ln x" ``` avigad@16959 ` 460` ``` by (rule left_diff_distrib) ``` avigad@16959 ` 461` ``` finally have "x * ln y <= y * ln x" ``` avigad@16959 ` 462` ``` by arith ``` avigad@16959 ` 463` ``` then have "ln y <= (y * ln x) / x" ``` avigad@16959 ` 464` ``` apply (subst pos_le_divide_eq) ``` avigad@16959 ` 465` ``` apply (rule a) ``` avigad@16959 ` 466` ``` apply (simp add: mult_ac) ``` avigad@16959 ` 467` ``` done ``` avigad@16959 ` 468` ``` also have "... = y * (ln x / x)" ``` avigad@16959 ` 469` ``` by simp ``` avigad@16959 ` 470` ``` finally show ?thesis ``` avigad@16959 ` 471` ``` apply (subst pos_divide_le_eq) ``` avigad@16959 ` 472` ``` apply (rule b) ``` avigad@16959 ` 473` ``` apply (simp add: mult_ac) ``` avigad@16959 ` 474` ``` done ``` avigad@16959 ` 475` ```qed ``` avigad@16959 ` 476` avigad@16959 ` 477` ```end ```