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