author  nipkow 
Sun, 24 Jun 2007 20:55:41 +0200  
changeset 23482  2f4be6844f7c 
parent 23477  f4b83f03cac9 
child 25875  536dfdc25e0a 
permissions  rwxrxrx 
16959  1 
(* Title: Ln.thy 
2 
Author: Jeremy Avigad 

16963  3 
ID: $Id$ 
16959  4 
*) 
5 

6 
header {* Properties of ln *} 

7 

8 
theory Ln 

9 
imports Transcendental 

10 
begin 

11 

12 
lemma exp_first_two_terms: "exp x = 1 + x + suminf (%n. 

13 
inverse(real (fact (n+2))) * (x ^ (n+2)))" 

14 
proof  

15 
have "exp x = suminf (%n. inverse(real (fact n)) * (x ^ n))" 

19765  16 
by (simp add: exp_def) 
16959  17 
also from summable_exp have "... = (SUM n : {0..<2}. 
18 
inverse(real (fact n)) * (x ^ n)) + suminf (%n. 

19 
inverse(real (fact (n+2))) * (x ^ (n+2)))" (is "_ = ?a + _") 

20 
by (rule suminf_split_initial_segment) 

21 
also have "?a = 1 + x" 

22 
by (simp add: numerals) 

23 
finally show ?thesis . 

24 
qed 

25 

26 
lemma exp_tail_after_first_two_terms_summable: 

27 
"summable (%n. inverse(real (fact (n+2))) * (x ^ (n+2)))" 

28 
proof  

29 
note summable_exp 

30 
thus ?thesis 

31 
by (frule summable_ignore_initial_segment) 

32 
qed 

33 

34 
lemma aux1: assumes a: "0 <= x" and b: "x <= 1" 

35 
shows "inverse (real (fact (n + 2))) * x ^ (n + 2) <= (x^2/2) * ((1/2)^n)" 

36 
proof (induct n) 

37 
show "inverse (real (fact (0 + 2))) * x ^ (0 + 2) <= 

38 
x ^ 2 / 2 * (1 / 2) ^ 0" 

23482  39 
by (simp add: real_of_nat_Suc power2_eq_square) 
16959  40 
next 
41 
fix n 

42 
assume c: "inverse (real (fact (n + 2))) * x ^ (n + 2) 

43 
<= x ^ 2 / 2 * (1 / 2) ^ n" 

44 
show "inverse (real (fact (Suc n + 2))) * x ^ (Suc n + 2) 

45 
<= x ^ 2 / 2 * (1 / 2) ^ Suc n" 

46 
proof  

47 
have "inverse(real (fact (Suc n + 2))) <= 

48 
(1 / 2) *inverse (real (fact (n+2)))" 

49 
proof  

50 
have "Suc n + 2 = Suc (n + 2)" by simp 

51 
then have "fact (Suc n + 2) = Suc (n + 2) * fact (n + 2)" 

52 
by simp 

53 
then have "real(fact (Suc n + 2)) = real(Suc (n + 2) * fact (n + 2))" 

54 
apply (rule subst) 

55 
apply (rule refl) 

56 
done 

57 
also have "... = real(Suc (n + 2)) * real(fact (n + 2))" 

58 
by (rule real_of_nat_mult) 

59 
finally have "real (fact (Suc n + 2)) = 

60 
real (Suc (n + 2)) * real (fact (n + 2))" . 

61 
then have "inverse(real (fact (Suc n + 2))) = 

62 
inverse(real (Suc (n + 2))) * inverse(real (fact (n + 2)))" 

63 
apply (rule ssubst) 

64 
apply (rule inverse_mult_distrib) 

65 
done 

66 
also have "... <= (1/2) * inverse(real (fact (n + 2)))" 

67 
apply (rule mult_right_mono) 

68 
apply (subst inverse_eq_divide) 

69 
apply simp 

70 
apply (rule inv_real_of_nat_fact_ge_zero) 

71 
done 

72 
finally show ?thesis . 

73 
qed 

74 
moreover have "x ^ (Suc n + 2) <= x ^ (n + 2)" 

75 
apply (simp add: mult_compare_simps) 

76 
apply (simp add: prems) 

77 
apply (subgoal_tac "0 <= x * (x * x^n)") 

78 
apply force 

79 
apply (rule mult_nonneg_nonneg, rule a)+ 

80 
apply (rule zero_le_power, rule a) 

81 
done 

82 
ultimately have "inverse (real (fact (Suc n + 2))) * x ^ (Suc n + 2) <= 

83 
(1 / 2 * inverse (real (fact (n + 2)))) * x ^ (n + 2)" 

84 
apply (rule mult_mono) 

85 
apply (rule mult_nonneg_nonneg) 

86 
apply simp 

87 
apply (subst inverse_nonnegative_iff_nonnegative) 

88 
apply (rule real_of_nat_fact_ge_zero) 

89 
apply (rule zero_le_power) 

23441  90 
apply (rule a) 
16959  91 
done 
92 
also have "... = 1 / 2 * (inverse (real (fact (n + 2))) * x ^ (n + 2))" 

93 
by simp 

94 
also have "... <= 1 / 2 * (x ^ 2 / 2 * (1 / 2) ^ n)" 

95 
apply (rule mult_left_mono) 

96 
apply (rule prems) 

97 
apply simp 

98 
done 

99 
also have "... = x ^ 2 / 2 * (1 / 2 * (1 / 2) ^ n)" 

100 
by auto 

101 
also have "(1::real) / 2 * (1 / 2) ^ n = (1 / 2) ^ (Suc n)" 

102 
by (rule realpow_Suc [THEN sym]) 

103 
finally show ?thesis . 

104 
qed 

105 
qed 

106 

20692  107 
lemma aux2: "(%n. (x::real) ^ 2 / 2 * (1 / 2) ^ n) sums x^2" 
16959  108 
proof  
20692  109 
have "(%n. (1 / 2::real)^n) sums (1 / (1  (1/2)))" 
16959  110 
apply (rule geometric_sums) 
22998  111 
by (simp add: abs_less_iff) 
16959  112 
also have "(1::real) / (1  1/2) = 2" 
113 
by simp 

20692  114 
finally have "(%n. (1 / 2::real)^n) sums 2" . 
16959  115 
then have "(%n. x ^ 2 / 2 * (1 / 2) ^ n) sums (x^2 / 2 * 2)" 
116 
by (rule sums_mult) 

117 
also have "x^2 / 2 * 2 = x^2" 

118 
by simp 

119 
finally show ?thesis . 

120 
qed 

121 

23114  122 
lemma exp_bound: "0 <= (x::real) ==> x <= 1 ==> exp x <= 1 + x + x^2" 
16959  123 
proof  
124 
assume a: "0 <= x" 

125 
assume b: "x <= 1" 

126 
have c: "exp x = 1 + x + suminf (%n. inverse(real (fact (n+2))) * 

127 
(x ^ (n+2)))" 

128 
by (rule exp_first_two_terms) 

129 
moreover have "suminf (%n. inverse(real (fact (n+2))) * (x ^ (n+2))) <= x^2" 

130 
proof  

131 
have "suminf (%n. inverse(real (fact (n+2))) * (x ^ (n+2))) <= 

132 
suminf (%n. (x^2/2) * ((1/2)^n))" 

133 
apply (rule summable_le) 

134 
apply (auto simp only: aux1 prems) 

135 
apply (rule exp_tail_after_first_two_terms_summable) 

136 
by (rule sums_summable, rule aux2) 

137 
also have "... = x^2" 

138 
by (rule sums_unique [THEN sym], rule aux2) 

139 
finally show ?thesis . 

140 
qed 

141 
ultimately show ?thesis 

142 
by auto 

143 
qed 

144 

23114  145 
lemma aux4: "0 <= (x::real) ==> x <= 1 ==> exp (x  x^2) <= 1 + x" 
16959  146 
proof  
147 
assume a: "0 <= x" and b: "x <= 1" 

148 
have "exp (x  x^2) = exp x / exp (x^2)" 

149 
by (rule exp_diff) 

150 
also have "... <= (1 + x + x^2) / exp (x ^2)" 

151 
apply (rule divide_right_mono) 

152 
apply (rule exp_bound) 

153 
apply (rule a, rule b) 

154 
apply simp 

155 
done 

156 
also have "... <= (1 + x + x^2) / (1 + x^2)" 

157 
apply (rule divide_left_mono) 

17013
74bc935273ea
renamed exp_ge_add_one_self2 to exp_ge_add_one_self
avigad
parents:
16963
diff
changeset

158 
apply (auto simp add: exp_ge_add_one_self_aux) 
16959  159 
apply (rule add_nonneg_nonneg) 
160 
apply (insert prems, auto) 

161 
apply (rule mult_pos_pos) 

162 
apply auto 

163 
apply (rule add_pos_nonneg) 

164 
apply auto 

165 
done 

166 
also from a have "... <= 1 + x" 

23482  167 
by(simp add:field_simps zero_compare_simps) 
16959  168 
finally show ?thesis . 
169 
qed 

170 

171 
lemma ln_one_plus_pos_lower_bound: "0 <= x ==> x <= 1 ==> 

172 
x  x^2 <= ln (1 + x)" 

173 
proof  

174 
assume a: "0 <= x" and b: "x <= 1" 

175 
then have "exp (x  x^2) <= 1 + x" 

176 
by (rule aux4) 

177 
also have "... = exp (ln (1 + x))" 

178 
proof  

179 
from a have "0 < 1 + x" by auto 

180 
thus ?thesis 

181 
by (auto simp only: exp_ln_iff [THEN sym]) 

182 
qed 

183 
finally have "exp (x  x ^ 2) <= exp (ln (1 + x))" . 

184 
thus ?thesis by (auto simp only: exp_le_cancel_iff) 

185 
qed 

186 

187 
lemma ln_one_minus_pos_upper_bound: "0 <= x ==> x < 1 ==> ln (1  x) <=  x" 

188 
proof  

189 
assume a: "0 <= (x::real)" and b: "x < 1" 

190 
have "(1  x) * (1 + x + x^2) = (1  x^3)" 

23477
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
nipkow
parents:
23441
diff
changeset

191 
by (simp add: ring_simps power2_eq_square power3_eq_cube) 
16959  192 
also have "... <= 1" 
193 
by (auto intro: zero_le_power simp add: a) 

194 
finally have "(1  x) * (1 + x + x ^ 2) <= 1" . 

195 
moreover have "0 < 1 + x + x^2" 

196 
apply (rule add_pos_nonneg) 

197 
apply (insert a, auto) 

198 
done 

199 
ultimately have "1  x <= 1 / (1 + x + x^2)" 

200 
by (elim mult_imp_le_div_pos) 

201 
also have "... <= 1 / exp x" 

202 
apply (rule divide_left_mono) 

203 
apply (rule exp_bound, rule a) 

204 
apply (insert prems, auto) 

205 
apply (rule mult_pos_pos) 

206 
apply (rule add_pos_nonneg) 

207 
apply auto 

208 
done 

209 
also have "... = exp (x)" 

210 
by (auto simp add: exp_minus real_divide_def) 

211 
finally have "1  x <= exp ( x)" . 

212 
also have "1  x = exp (ln (1  x))" 

213 
proof  

214 
have "0 < 1  x" 

215 
by (insert b, auto) 

216 
thus ?thesis 

217 
by (auto simp only: exp_ln_iff [THEN sym]) 

218 
qed 

219 
finally have "exp (ln (1  x)) <= exp ( x)" . 

220 
thus ?thesis by (auto simp only: exp_le_cancel_iff) 

221 
qed 

222 

223 
lemma aux5: "x < 1 ==> ln(1  x) =  ln(1 + x / (1  x))" 

224 
proof  

225 
assume a: "x < 1" 

226 
have "ln(1  x) =  ln(1 / (1  x))" 

227 
proof  

228 
have "ln(1  x) =  ( ln (1  x))" 

229 
by auto 

230 
also have " ln(1  x) = ln 1  ln(1  x)" 

231 
by simp 

232 
also have "... = ln(1 / (1  x))" 

233 
apply (rule ln_div [THEN sym]) 

234 
by (insert a, auto) 

235 
finally show ?thesis . 

236 
qed 

23482  237 
also have " 1 / (1  x) = 1 + x / (1  x)" using a by(simp add:field_simps) 
16959  238 
finally show ?thesis . 
239 
qed 

240 

241 
lemma ln_one_minus_pos_lower_bound: "0 <= x ==> x <= (1 / 2) ==> 

242 
 x  2 * x^2 <= ln (1  x)" 

243 
proof  

244 
assume a: "0 <= x" and b: "x <= (1 / 2)" 

245 
from b have c: "x < 1" 

246 
by auto 

247 
then have "ln (1  x) =  ln (1 + x / (1  x))" 

248 
by (rule aux5) 

249 
also have " (x / (1  x)) <= ..." 

250 
proof  

251 
have "ln (1 + x / (1  x)) <= x / (1  x)" 

252 
apply (rule ln_add_one_self_le_self) 

253 
apply (rule divide_nonneg_pos) 

254 
by (insert a c, auto) 

255 
thus ?thesis 

256 
by auto 

257 
qed 

258 
also have " (x / (1  x)) = x / (1  x)" 

259 
by auto 

260 
finally have d: " x / (1  x) <= ln (1  x)" . 

23482  261 
have "0 < 1  x" using prems by simp 
262 
hence e: "x  2 * x^2 <=  x / (1  x)" 

263 
using mult_right_le_one_le[of "x*x" "2*x"] prems 

264 
by(simp add:field_simps power2_eq_square) 

16959  265 
from e d show " x  2 * x^2 <= ln (1  x)" 
266 
by (rule order_trans) 

267 
qed 

268 

23114  269 
lemma exp_ge_add_one_self [simp]: "1 + (x::real) <= exp x" 
16959  270 
apply (case_tac "0 <= x") 
17013
74bc935273ea
renamed exp_ge_add_one_self2 to exp_ge_add_one_self
avigad
parents:
16963
diff
changeset

271 
apply (erule exp_ge_add_one_self_aux) 
16959  272 
apply (case_tac "x <= 1") 
273 
apply (subgoal_tac "1 + x <= 0") 

274 
apply (erule order_trans) 

275 
apply simp 

276 
apply simp 

277 
apply (subgoal_tac "1 + x = exp(ln (1 + x))") 

278 
apply (erule ssubst) 

279 
apply (subst exp_le_cancel_iff) 

280 
apply (subgoal_tac "ln (1  ( x)) <=  ( x)") 

281 
apply simp 

282 
apply (rule ln_one_minus_pos_upper_bound) 

283 
apply auto 

284 
done 

285 

286 
lemma ln_add_one_self_le_self2: "1 < x ==> ln(1 + x) <= x" 

287 
apply (subgoal_tac "x = ln (exp x)") 

288 
apply (erule ssubst)back 

289 
apply (subst ln_le_cancel_iff) 

290 
apply auto 

291 
done 

292 

293 
lemma abs_ln_one_plus_x_minus_x_bound_nonneg: 

294 
"0 <= x ==> x <= 1 ==> abs(ln (1 + x)  x) <= x^2" 

295 
proof  

23441  296 
assume x: "0 <= x" 
16959  297 
assume "x <= 1" 
23441  298 
from x have "ln (1 + x) <= x" 
16959  299 
by (rule ln_add_one_self_le_self) 
300 
then have "ln (1 + x)  x <= 0" 

301 
by simp 

302 
then have "abs(ln(1 + x)  x) =  (ln(1 + x)  x)" 

303 
by (rule abs_of_nonpos) 

304 
also have "... = x  ln (1 + x)" 

305 
by simp 

306 
also have "... <= x^2" 

307 
proof  

308 
from prems have "x  x^2 <= ln (1 + x)" 

309 
by (intro ln_one_plus_pos_lower_bound) 

310 
thus ?thesis 

311 
by simp 

312 
qed 

313 
finally show ?thesis . 

314 
qed 

315 

316 
lemma abs_ln_one_plus_x_minus_x_bound_nonpos: 

317 
"(1 / 2) <= x ==> x <= 0 ==> abs(ln (1 + x)  x) <= 2 * x^2" 

318 
proof  

319 
assume "(1 / 2) <= x" 

320 
assume "x <= 0" 

321 
have "abs(ln (1 + x)  x) = x  ln(1  (x))" 

322 
apply (subst abs_of_nonpos) 

323 
apply simp 

324 
apply (rule ln_add_one_self_le_self2) 

325 
apply (insert prems, auto) 

326 
done 

327 
also have "... <= 2 * x^2" 

328 
apply (subgoal_tac " (x)  2 * (x)^2 <= ln (1  (x))") 

329 
apply (simp add: compare_rls) 

330 
apply (rule ln_one_minus_pos_lower_bound) 

331 
apply (insert prems, auto) 

332 
done 

333 
finally show ?thesis . 

334 
qed 

335 

336 
lemma abs_ln_one_plus_x_minus_x_bound: 

337 
"abs x <= 1 / 2 ==> abs(ln (1 + x)  x) <= 2 * x^2" 

338 
apply (case_tac "0 <= x") 

339 
apply (rule order_trans) 

340 
apply (rule abs_ln_one_plus_x_minus_x_bound_nonneg) 

341 
apply auto 

342 
apply (rule abs_ln_one_plus_x_minus_x_bound_nonpos) 

343 
apply auto 

344 
done 

345 

346 
lemma DERIV_ln: "0 < x ==> DERIV ln x :> 1 / x" 

347 
apply (unfold deriv_def, unfold LIM_def, clarsimp) 

348 
apply (rule exI) 

349 
apply (rule conjI) 

350 
prefer 2 

351 
apply clarsimp 

20563  352 
apply (subgoal_tac "(ln (x + xa)  ln x) / xa  (1 / x) = 
16959  353 
(ln (1 + xa / x)  xa / x) / xa") 
354 
apply (erule ssubst) 

355 
apply (subst abs_divide) 

356 
apply (rule mult_imp_div_pos_less) 

357 
apply force 

358 
apply (rule order_le_less_trans) 

359 
apply (rule abs_ln_one_plus_x_minus_x_bound) 

360 
apply (subst abs_divide) 

361 
apply (subst abs_of_pos, assumption) 

362 
apply (erule mult_imp_div_pos_le) 

363 
apply (subgoal_tac "abs xa < min (x / 2) (r * x^2 / 2)") 

364 
apply force 

365 
apply assumption 

20432
07ec57376051
lin_arith_prover: splitting reverted because of performance loss
webertj
parents:
20256
diff
changeset

366 
apply (simp add: power2_eq_square mult_compare_simps) 
16959  367 
apply (rule mult_imp_div_pos_less) 
368 
apply (rule mult_pos_pos, assumption, assumption) 

369 
apply (subgoal_tac "xa * xa = abs xa * abs xa") 

370 
apply (erule ssubst) 

371 
apply (subgoal_tac "abs xa * (abs xa * 2) < abs xa * (r * (x * x))") 

372 
apply (simp only: mult_ac) 

373 
apply (rule mult_strict_left_mono) 

374 
apply (erule conjE, assumption) 

375 
apply force 

376 
apply simp 

377 
apply (subst ln_div [THEN sym]) 

378 
apply arith 

23477
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
nipkow
parents:
23441
diff
changeset

379 
apply (auto simp add: ring_simps add_frac_eq frac_eq_eq 
16959  380 
add_divide_distrib power2_eq_square) 
381 
apply (rule mult_pos_pos, assumption)+ 

382 
apply assumption 

383 
done 

384 

385 
lemma ln_x_over_x_mono: "exp 1 <= x ==> x <= y ==> (ln y / y) <= (ln x / x)" 

386 
proof  

387 
assume "exp 1 <= x" and "x <= y" 

388 
have a: "0 < x" and b: "0 < y" 

389 
apply (insert prems) 

23114  390 
apply (subgoal_tac "0 < exp (1::real)") 
16959  391 
apply arith 
392 
apply auto 

23114  393 
apply (subgoal_tac "0 < exp (1::real)") 
16959  394 
apply arith 
395 
apply auto 

396 
done 

397 
have "x * ln y  x * ln x = x * (ln y  ln x)" 

23477
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
nipkow
parents:
23441
diff
changeset

398 
by (simp add: ring_simps) 
16959  399 
also have "... = x * ln(y / x)" 
400 
apply (subst ln_div) 

401 
apply (rule b, rule a, rule refl) 

402 
done 

403 
also have "y / x = (x + (y  x)) / x" 

404 
by simp 

23482  405 
also have "... = 1 + (y  x) / x" using a prems by(simp add:field_simps) 
16959  406 
also have "x * ln(1 + (y  x) / x) <= x * ((y  x) / x)" 
407 
apply (rule mult_left_mono) 

408 
apply (rule ln_add_one_self_le_self) 

409 
apply (rule divide_nonneg_pos) 

410 
apply (insert prems a, simp_all) 

411 
done 

23482  412 
also have "... = y  x" using a by simp 
413 
also have "... = (y  x) * ln (exp 1)" by simp 

16959  414 
also have "... <= (y  x) * ln x" 
415 
apply (rule mult_left_mono) 

416 
apply (subst ln_le_cancel_iff) 

417 
apply force 

418 
apply (rule a) 

419 
apply (rule prems) 

420 
apply (insert prems, simp) 

421 
done 

422 
also have "... = y * ln x  x * ln x" 

423 
by (rule left_diff_distrib) 

424 
finally have "x * ln y <= y * ln x" 

425 
by arith 

23482  426 
then have "ln y <= (y * ln x) / x" using a by(simp add:field_simps) 
427 
also have "... = y * (ln x / x)" by simp 

428 
finally show ?thesis using b by(simp add:field_simps) 

16959  429 
qed 
430 

431 
end 