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