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