author | huffman |
Sat, 31 Mar 2012 20:09:24 +0200 | |
changeset 47242 | 1caeecc72aea |
parent 44305 | 3bdc02eb1637 |
child 47244 | a7f85074c169 |
permissions | -rw-r--r-- |
41959 | 1 |
(* Title: HOL/Ln.thy |
16959 | 2 |
Author: Jeremy Avigad |
3 |
*) |
|
4 |
||
5 |
header {* Properties of ln *} |
|
6 |
||
7 |
theory Ln |
|
8 |
imports Transcendental |
|
9 |
begin |
|
10 |
||
11 |
lemma exp_first_two_terms: "exp x = 1 + x + suminf (%n. |
|
40864
4abaaadfdaf2
moved activation of coercion inference into RealDef and declared function real a coercion.
nipkow
parents:
36777
diff
changeset
|
12 |
inverse(fact (n+2)) * (x ^ (n+2)))" |
16959 | 13 |
proof - |
40864
4abaaadfdaf2
moved activation of coercion inference into RealDef and declared function real a coercion.
nipkow
parents:
36777
diff
changeset
|
14 |
have "exp x = suminf (%n. inverse(fact n) * (x ^ n))" |
19765 | 15 |
by (simp add: exp_def) |
40864
4abaaadfdaf2
moved activation of coercion inference into RealDef and declared function real a coercion.
nipkow
parents:
36777
diff
changeset
|
16 |
also from summable_exp have "... = (SUM n::nat : {0..<2}. |
4abaaadfdaf2
moved activation of coercion inference into RealDef and declared function real a coercion.
nipkow
parents:
36777
diff
changeset
|
17 |
inverse(fact n) * (x ^ n)) + suminf (%n. |
4abaaadfdaf2
moved activation of coercion inference into RealDef and declared function real a coercion.
nipkow
parents:
36777
diff
changeset
|
18 |
inverse(fact(n+2)) * (x ^ (n+2)))" (is "_ = ?a + _") |
16959 | 19 |
by (rule suminf_split_initial_segment) |
20 |
also have "?a = 1 + x" |
|
44289 | 21 |
by (simp add: numeral_2_eq_2) |
16959 | 22 |
finally show ?thesis . |
23 |
qed |
|
24 |
||
25 |
lemma exp_tail_after_first_two_terms_summable: |
|
40864
4abaaadfdaf2
moved activation of coercion inference into RealDef and declared function real a coercion.
nipkow
parents:
36777
diff
changeset
|
26 |
"summable (%n. inverse(fact (n+2)) * (x ^ (n+2)))" |
16959 | 27 |
proof - |
28 |
note summable_exp |
|
29 |
thus ?thesis |
|
30 |
by (frule summable_ignore_initial_segment) |
|
31 |
qed |
|
32 |
||
33 |
lemma aux1: assumes a: "0 <= x" and b: "x <= 1" |
|
40864
4abaaadfdaf2
moved activation of coercion inference into RealDef and declared function real a coercion.
nipkow
parents:
36777
diff
changeset
|
34 |
shows "inverse (fact ((n::nat) + 2)) * x ^ (n + 2) <= (x^2/2) * ((1/2)^n)" |
47242 | 35 |
proof - |
36 |
have "2 * 2 ^ n \<le> fact (n + 2)" |
|
37 |
by (induct n, simp, simp) |
|
38 |
hence "real ((2::nat) * 2 ^ n) \<le> real (fact (n + 2))" |
|
39 |
by (simp only: real_of_nat_le_iff) |
|
40 |
hence "2 * 2 ^ n \<le> real (fact (n + 2))" |
|
41 |
by simp |
|
42 |
hence "inverse (fact (n + 2)) \<le> inverse (2 * 2 ^ n)" |
|
43 |
by (rule le_imp_inverse_le) simp |
|
44 |
hence "inverse (fact (n + 2)) \<le> 1/2 * (1/2)^n" |
|
45 |
by (simp add: inverse_mult_distrib power_inverse) |
|
46 |
hence "inverse (fact (n + 2)) * (x^n * x\<twosuperior>) \<le> 1/2 * (1/2)^n * (1 * x\<twosuperior>)" |
|
47 |
by (rule mult_mono) |
|
48 |
(rule mult_mono, simp_all add: power_le_one a b mult_nonneg_nonneg) |
|
49 |
thus ?thesis |
|
50 |
unfolding power_add by (simp add: mult_ac del: fact_Suc) |
|
16959 | 51 |
qed |
52 |
||
20692 | 53 |
lemma aux2: "(%n. (x::real) ^ 2 / 2 * (1 / 2) ^ n) sums x^2" |
16959 | 54 |
proof - |
20692 | 55 |
have "(%n. (1 / 2::real)^n) sums (1 / (1 - (1/2)))" |
16959 | 56 |
apply (rule geometric_sums) |
22998 | 57 |
by (simp add: abs_less_iff) |
16959 | 58 |
also have "(1::real) / (1 - 1/2) = 2" |
59 |
by simp |
|
20692 | 60 |
finally have "(%n. (1 / 2::real)^n) sums 2" . |
16959 | 61 |
then have "(%n. x ^ 2 / 2 * (1 / 2) ^ n) sums (x^2 / 2 * 2)" |
62 |
by (rule sums_mult) |
|
63 |
also have "x^2 / 2 * 2 = x^2" |
|
64 |
by simp |
|
65 |
finally show ?thesis . |
|
66 |
qed |
|
67 |
||
23114 | 68 |
lemma exp_bound: "0 <= (x::real) ==> x <= 1 ==> exp x <= 1 + x + x^2" |
16959 | 69 |
proof - |
70 |
assume a: "0 <= x" |
|
71 |
assume b: "x <= 1" |
|
40864
4abaaadfdaf2
moved activation of coercion inference into RealDef and declared function real a coercion.
nipkow
parents:
36777
diff
changeset
|
72 |
have c: "exp x = 1 + x + suminf (%n. inverse(fact (n+2)) * |
16959 | 73 |
(x ^ (n+2)))" |
74 |
by (rule exp_first_two_terms) |
|
40864
4abaaadfdaf2
moved activation of coercion inference into RealDef and declared function real a coercion.
nipkow
parents:
36777
diff
changeset
|
75 |
moreover have "suminf (%n. inverse(fact (n+2)) * (x ^ (n+2))) <= x^2" |
16959 | 76 |
proof - |
40864
4abaaadfdaf2
moved activation of coercion inference into RealDef and declared function real a coercion.
nipkow
parents:
36777
diff
changeset
|
77 |
have "suminf (%n. inverse(fact (n+2)) * (x ^ (n+2))) <= |
16959 | 78 |
suminf (%n. (x^2/2) * ((1/2)^n))" |
79 |
apply (rule summable_le) |
|
41550 | 80 |
apply (auto simp only: aux1 a b) |
16959 | 81 |
apply (rule exp_tail_after_first_two_terms_summable) |
82 |
by (rule sums_summable, rule aux2) |
|
83 |
also have "... = x^2" |
|
84 |
by (rule sums_unique [THEN sym], rule aux2) |
|
85 |
finally show ?thesis . |
|
86 |
qed |
|
87 |
ultimately show ?thesis |
|
88 |
by auto |
|
89 |
qed |
|
90 |
||
23114 | 91 |
lemma aux4: "0 <= (x::real) ==> x <= 1 ==> exp (x - x^2) <= 1 + x" |
16959 | 92 |
proof - |
93 |
assume a: "0 <= x" and b: "x <= 1" |
|
94 |
have "exp (x - x^2) = exp x / exp (x^2)" |
|
95 |
by (rule exp_diff) |
|
96 |
also have "... <= (1 + x + x^2) / exp (x ^2)" |
|
97 |
apply (rule divide_right_mono) |
|
98 |
apply (rule exp_bound) |
|
99 |
apply (rule a, rule b) |
|
100 |
apply simp |
|
101 |
done |
|
102 |
also have "... <= (1 + x + x^2) / (1 + x^2)" |
|
103 |
apply (rule divide_left_mono) |
|
17013
74bc935273ea
renamed exp_ge_add_one_self2 to exp_ge_add_one_self
avigad
parents:
16963
diff
changeset
|
104 |
apply (auto simp add: exp_ge_add_one_self_aux) |
16959 | 105 |
apply (rule add_nonneg_nonneg) |
41550 | 106 |
using a apply auto |
16959 | 107 |
apply (rule mult_pos_pos) |
108 |
apply auto |
|
109 |
apply (rule add_pos_nonneg) |
|
110 |
apply auto |
|
111 |
done |
|
112 |
also from a have "... <= 1 + x" |
|
44289 | 113 |
by (simp add: field_simps add_strict_increasing zero_le_mult_iff) |
16959 | 114 |
finally show ?thesis . |
115 |
qed |
|
116 |
||
117 |
lemma ln_one_plus_pos_lower_bound: "0 <= x ==> x <= 1 ==> |
|
118 |
x - x^2 <= ln (1 + x)" |
|
119 |
proof - |
|
120 |
assume a: "0 <= x" and b: "x <= 1" |
|
121 |
then have "exp (x - x^2) <= 1 + x" |
|
122 |
by (rule aux4) |
|
123 |
also have "... = exp (ln (1 + x))" |
|
124 |
proof - |
|
125 |
from a have "0 < 1 + x" by auto |
|
126 |
thus ?thesis |
|
127 |
by (auto simp only: exp_ln_iff [THEN sym]) |
|
128 |
qed |
|
129 |
finally have "exp (x - x ^ 2) <= exp (ln (1 + x))" . |
|
130 |
thus ?thesis by (auto simp only: exp_le_cancel_iff) |
|
131 |
qed |
|
132 |
||
133 |
lemma ln_one_minus_pos_upper_bound: "0 <= x ==> x < 1 ==> ln (1 - x) <= - x" |
|
134 |
proof - |
|
135 |
assume a: "0 <= (x::real)" and b: "x < 1" |
|
136 |
have "(1 - x) * (1 + x + x^2) = (1 - x^3)" |
|
29667 | 137 |
by (simp add: algebra_simps power2_eq_square power3_eq_cube) |
16959 | 138 |
also have "... <= 1" |
25875 | 139 |
by (auto simp add: a) |
16959 | 140 |
finally have "(1 - x) * (1 + x + x ^ 2) <= 1" . |
141 |
moreover have "0 < 1 + x + x^2" |
|
142 |
apply (rule add_pos_nonneg) |
|
41550 | 143 |
using a apply auto |
16959 | 144 |
done |
145 |
ultimately have "1 - x <= 1 / (1 + x + x^2)" |
|
146 |
by (elim mult_imp_le_div_pos) |
|
147 |
also have "... <= 1 / exp x" |
|
148 |
apply (rule divide_left_mono) |
|
149 |
apply (rule exp_bound, rule a) |
|
41550 | 150 |
using a b apply auto |
16959 | 151 |
apply (rule mult_pos_pos) |
152 |
apply (rule add_pos_nonneg) |
|
153 |
apply auto |
|
154 |
done |
|
155 |
also have "... = exp (-x)" |
|
36777
be5461582d0f
avoid using real-specific versions of generic lemmas
huffman
parents:
33667
diff
changeset
|
156 |
by (auto simp add: exp_minus divide_inverse) |
16959 | 157 |
finally have "1 - x <= exp (- x)" . |
158 |
also have "1 - x = exp (ln (1 - x))" |
|
159 |
proof - |
|
160 |
have "0 < 1 - x" |
|
161 |
by (insert b, auto) |
|
162 |
thus ?thesis |
|
163 |
by (auto simp only: exp_ln_iff [THEN sym]) |
|
164 |
qed |
|
165 |
finally have "exp (ln (1 - x)) <= exp (- x)" . |
|
166 |
thus ?thesis by (auto simp only: exp_le_cancel_iff) |
|
167 |
qed |
|
168 |
||
169 |
lemma aux5: "x < 1 ==> ln(1 - x) = - ln(1 + x / (1 - x))" |
|
170 |
proof - |
|
171 |
assume a: "x < 1" |
|
172 |
have "ln(1 - x) = - ln(1 / (1 - x))" |
|
173 |
proof - |
|
174 |
have "ln(1 - x) = - (- ln (1 - x))" |
|
175 |
by auto |
|
176 |
also have "- ln(1 - x) = ln 1 - ln(1 - x)" |
|
177 |
by simp |
|
178 |
also have "... = ln(1 / (1 - x))" |
|
179 |
apply (rule ln_div [THEN sym]) |
|
180 |
by (insert a, auto) |
|
181 |
finally show ?thesis . |
|
182 |
qed |
|
23482 | 183 |
also have " 1 / (1 - x) = 1 + x / (1 - x)" using a by(simp add:field_simps) |
16959 | 184 |
finally show ?thesis . |
185 |
qed |
|
186 |
||
187 |
lemma ln_one_minus_pos_lower_bound: "0 <= x ==> x <= (1 / 2) ==> |
|
188 |
- x - 2 * x^2 <= ln (1 - x)" |
|
189 |
proof - |
|
190 |
assume a: "0 <= x" and b: "x <= (1 / 2)" |
|
191 |
from b have c: "x < 1" |
|
192 |
by auto |
|
193 |
then have "ln (1 - x) = - ln (1 + x / (1 - x))" |
|
194 |
by (rule aux5) |
|
195 |
also have "- (x / (1 - x)) <= ..." |
|
196 |
proof - |
|
197 |
have "ln (1 + x / (1 - x)) <= x / (1 - x)" |
|
198 |
apply (rule ln_add_one_self_le_self) |
|
199 |
apply (rule divide_nonneg_pos) |
|
200 |
by (insert a c, auto) |
|
201 |
thus ?thesis |
|
202 |
by auto |
|
203 |
qed |
|
204 |
also have "- (x / (1 - x)) = -x / (1 - x)" |
|
205 |
by auto |
|
206 |
finally have d: "- x / (1 - x) <= ln (1 - x)" . |
|
41550 | 207 |
have "0 < 1 - x" using a b by simp |
23482 | 208 |
hence e: "-x - 2 * x^2 <= - x / (1 - x)" |
41550 | 209 |
using mult_right_le_one_le[of "x*x" "2*x"] a b |
210 |
by (simp add:field_simps power2_eq_square) |
|
16959 | 211 |
from e d show "- x - 2 * x^2 <= ln (1 - x)" |
212 |
by (rule order_trans) |
|
213 |
qed |
|
214 |
||
23114 | 215 |
lemma exp_ge_add_one_self [simp]: "1 + (x::real) <= exp x" |
16959 | 216 |
apply (case_tac "0 <= x") |
17013
74bc935273ea
renamed exp_ge_add_one_self2 to exp_ge_add_one_self
avigad
parents:
16963
diff
changeset
|
217 |
apply (erule exp_ge_add_one_self_aux) |
16959 | 218 |
apply (case_tac "x <= -1") |
219 |
apply (subgoal_tac "1 + x <= 0") |
|
220 |
apply (erule order_trans) |
|
221 |
apply simp |
|
222 |
apply simp |
|
223 |
apply (subgoal_tac "1 + x = exp(ln (1 + x))") |
|
224 |
apply (erule ssubst) |
|
225 |
apply (subst exp_le_cancel_iff) |
|
226 |
apply (subgoal_tac "ln (1 - (- x)) <= - (- x)") |
|
227 |
apply simp |
|
228 |
apply (rule ln_one_minus_pos_upper_bound) |
|
229 |
apply auto |
|
230 |
done |
|
231 |
||
232 |
lemma ln_add_one_self_le_self2: "-1 < x ==> ln(1 + x) <= x" |
|
233 |
apply (subgoal_tac "x = ln (exp x)") |
|
234 |
apply (erule ssubst)back |
|
235 |
apply (subst ln_le_cancel_iff) |
|
236 |
apply auto |
|
237 |
done |
|
238 |
||
239 |
lemma abs_ln_one_plus_x_minus_x_bound_nonneg: |
|
240 |
"0 <= x ==> x <= 1 ==> abs(ln (1 + x) - x) <= x^2" |
|
241 |
proof - |
|
23441 | 242 |
assume x: "0 <= x" |
41550 | 243 |
assume x1: "x <= 1" |
23441 | 244 |
from x have "ln (1 + x) <= x" |
16959 | 245 |
by (rule ln_add_one_self_le_self) |
246 |
then have "ln (1 + x) - x <= 0" |
|
247 |
by simp |
|
248 |
then have "abs(ln(1 + x) - x) = - (ln(1 + x) - x)" |
|
249 |
by (rule abs_of_nonpos) |
|
250 |
also have "... = x - ln (1 + x)" |
|
251 |
by simp |
|
252 |
also have "... <= x^2" |
|
253 |
proof - |
|
41550 | 254 |
from x x1 have "x - x^2 <= ln (1 + x)" |
16959 | 255 |
by (intro ln_one_plus_pos_lower_bound) |
256 |
thus ?thesis |
|
257 |
by simp |
|
258 |
qed |
|
259 |
finally show ?thesis . |
|
260 |
qed |
|
261 |
||
262 |
lemma abs_ln_one_plus_x_minus_x_bound_nonpos: |
|
263 |
"-(1 / 2) <= x ==> x <= 0 ==> abs(ln (1 + x) - x) <= 2 * x^2" |
|
264 |
proof - |
|
41550 | 265 |
assume a: "-(1 / 2) <= x" |
266 |
assume b: "x <= 0" |
|
16959 | 267 |
have "abs(ln (1 + x) - x) = x - ln(1 - (-x))" |
268 |
apply (subst abs_of_nonpos) |
|
269 |
apply simp |
|
270 |
apply (rule ln_add_one_self_le_self2) |
|
41550 | 271 |
using a apply auto |
16959 | 272 |
done |
273 |
also have "... <= 2 * x^2" |
|
274 |
apply (subgoal_tac "- (-x) - 2 * (-x)^2 <= ln (1 - (-x))") |
|
29667 | 275 |
apply (simp add: algebra_simps) |
16959 | 276 |
apply (rule ln_one_minus_pos_lower_bound) |
41550 | 277 |
using a b apply auto |
29667 | 278 |
done |
16959 | 279 |
finally show ?thesis . |
280 |
qed |
|
281 |
||
282 |
lemma abs_ln_one_plus_x_minus_x_bound: |
|
283 |
"abs x <= 1 / 2 ==> abs(ln (1 + x) - x) <= 2 * x^2" |
|
284 |
apply (case_tac "0 <= x") |
|
285 |
apply (rule order_trans) |
|
286 |
apply (rule abs_ln_one_plus_x_minus_x_bound_nonneg) |
|
287 |
apply auto |
|
288 |
apply (rule abs_ln_one_plus_x_minus_x_bound_nonpos) |
|
289 |
apply auto |
|
290 |
done |
|
291 |
||
292 |
lemma ln_x_over_x_mono: "exp 1 <= x ==> x <= y ==> (ln y / y) <= (ln x / x)" |
|
293 |
proof - |
|
41550 | 294 |
assume x: "exp 1 <= x" "x <= y" |
44289 | 295 |
moreover have "0 < exp (1::real)" by simp |
296 |
ultimately have a: "0 < x" and b: "0 < y" |
|
297 |
by (fast intro: less_le_trans order_trans)+ |
|
16959 | 298 |
have "x * ln y - x * ln x = x * (ln y - ln x)" |
29667 | 299 |
by (simp add: algebra_simps) |
16959 | 300 |
also have "... = x * ln(y / x)" |
44289 | 301 |
by (simp only: ln_div a b) |
16959 | 302 |
also have "y / x = (x + (y - x)) / x" |
303 |
by simp |
|
44289 | 304 |
also have "... = 1 + (y - x) / x" |
305 |
using x a by (simp add: field_simps) |
|
16959 | 306 |
also have "x * ln(1 + (y - x) / x) <= x * ((y - x) / x)" |
307 |
apply (rule mult_left_mono) |
|
308 |
apply (rule ln_add_one_self_le_self) |
|
309 |
apply (rule divide_nonneg_pos) |
|
41550 | 310 |
using x a apply simp_all |
16959 | 311 |
done |
23482 | 312 |
also have "... = y - x" using a by simp |
313 |
also have "... = (y - x) * ln (exp 1)" by simp |
|
16959 | 314 |
also have "... <= (y - x) * ln x" |
315 |
apply (rule mult_left_mono) |
|
316 |
apply (subst ln_le_cancel_iff) |
|
44289 | 317 |
apply fact |
16959 | 318 |
apply (rule a) |
41550 | 319 |
apply (rule x) |
320 |
using x apply simp |
|
16959 | 321 |
done |
322 |
also have "... = y * ln x - x * ln x" |
|
323 |
by (rule left_diff_distrib) |
|
324 |
finally have "x * ln y <= y * ln x" |
|
325 |
by arith |
|
41550 | 326 |
then have "ln y <= (y * ln x) / x" using a by (simp add: field_simps) |
327 |
also have "... = y * (ln x / x)" by simp |
|
328 |
finally show ?thesis using b by (simp add: field_simps) |
|
16959 | 329 |
qed |
330 |
||
43336 | 331 |
lemma ln_le_minus_one: |
332 |
"0 < x \<Longrightarrow> ln x \<le> x - 1" |
|
333 |
using exp_ge_add_one_self[of "ln x"] by simp |
|
334 |
||
335 |
lemma ln_eq_minus_one: |
|
336 |
assumes "0 < x" "ln x = x - 1" shows "x = 1" |
|
337 |
proof - |
|
338 |
let "?l y" = "ln y - y + 1" |
|
339 |
have D: "\<And>x. 0 < x \<Longrightarrow> DERIV ?l x :> (1 / x - 1)" |
|
340 |
by (auto intro!: DERIV_intros) |
|
341 |
||
342 |
show ?thesis |
|
343 |
proof (cases rule: linorder_cases) |
|
344 |
assume "x < 1" |
|
345 |
from dense[OF `x < 1`] obtain a where "x < a" "a < 1" by blast |
|
346 |
from `x < a` have "?l x < ?l a" |
|
347 |
proof (rule DERIV_pos_imp_increasing, safe) |
|
348 |
fix y assume "x \<le> y" "y \<le> a" |
|
349 |
with `0 < x` `a < 1` have "0 < 1 / y - 1" "0 < y" |
|
350 |
by (auto simp: field_simps) |
|
351 |
with D show "\<exists>z. DERIV ?l y :> z \<and> 0 < z" |
|
352 |
by auto |
|
353 |
qed |
|
354 |
also have "\<dots> \<le> 0" |
|
355 |
using ln_le_minus_one `0 < x` `x < a` by (auto simp: field_simps) |
|
356 |
finally show "x = 1" using assms by auto |
|
357 |
next |
|
358 |
assume "1 < x" |
|
359 |
from dense[OF `1 < x`] obtain a where "1 < a" "a < x" by blast |
|
360 |
from `a < x` have "?l x < ?l a" |
|
361 |
proof (rule DERIV_neg_imp_decreasing, safe) |
|
362 |
fix y assume "a \<le> y" "y \<le> x" |
|
363 |
with `1 < a` have "1 / y - 1 < 0" "0 < y" |
|
364 |
by (auto simp: field_simps) |
|
365 |
with D show "\<exists>z. DERIV ?l y :> z \<and> z < 0" |
|
366 |
by blast |
|
367 |
qed |
|
368 |
also have "\<dots> \<le> 0" |
|
369 |
using ln_le_minus_one `1 < a` by (auto simp: field_simps) |
|
370 |
finally show "x = 1" using assms by auto |
|
371 |
qed simp |
|
372 |
qed |
|
373 |
||
16959 | 374 |
end |