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