src/HOL/Ln.thy
author blanchet
Tue, 14 Sep 2010 13:24:18 +0200
changeset 39359 6f49c7fbb1b1
parent 36777 be5461582d0f
child 40864 4abaaadfdaf2
permissions -rw-r--r--
remove "fast_descs" option from Nitpick; the option has been unsound for over a year and is too imprecise to be of any use when made sound
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
imports Transcendental
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
     9
begin
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    10
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    11
lemma exp_first_two_terms: "exp x = 1 + x + suminf (%n. 
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    12
  inverse(real (fact (n+2))) * (x ^ (n+2)))"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    13
proof -
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    14
  have "exp x = suminf (%n. inverse(real (fact n)) * (x ^ n))"
19765
dfe940911617 misc cleanup;
wenzelm
parents: 17013
diff changeset
    15
    by (simp add: exp_def)
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    16
  also from summable_exp have "... = (SUM n : {0..<2}. 
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    17
      inverse(real (fact n)) * (x ^ n)) + suminf (%n.
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    18
      inverse(real (fact (n+2))) * (x ^ (n+2)))" (is "_ = ?a + _")
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    19
    by (rule suminf_split_initial_segment)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    20
  also have "?a = 1 + x"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    21
    by (simp add: numerals)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    22
  finally show ?thesis .
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    23
qed
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    24
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    25
lemma exp_tail_after_first_two_terms_summable: 
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    26
  "summable (%n. inverse(real (fact (n+2))) * (x ^ (n+2)))"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    27
proof -
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    28
  note summable_exp
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    29
  thus ?thesis
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    30
    by (frule summable_ignore_initial_segment)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    31
qed
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    32
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    33
lemma aux1: assumes a: "0 <= x" and b: "x <= 1"
32038
4127b89f48ab Repaired uses of factorial.
avigad
parents: 31883
diff changeset
    34
    shows "inverse (real (fact ((n::nat) + 2))) * x ^ (n + 2) <= (x^2/2) * ((1/2)^n)"
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    35
proof (induct n)
32038
4127b89f48ab Repaired uses of factorial.
avigad
parents: 31883
diff changeset
    36
  show "inverse (real (fact ((0::nat) + 2))) * x ^ (0 + 2) <= 
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    37
      x ^ 2 / 2 * (1 / 2) ^ 0"
23482
2f4be6844f7c tuned and used field_simps
nipkow
parents: 23477
diff changeset
    38
    by (simp add: real_of_nat_Suc power2_eq_square)
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    39
next
32038
4127b89f48ab Repaired uses of factorial.
avigad
parents: 31883
diff changeset
    40
  fix n :: nat
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    41
  assume c: "inverse (real (fact (n + 2))) * x ^ (n + 2)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    42
       <= x ^ 2 / 2 * (1 / 2) ^ n"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    43
  show "inverse (real (fact (Suc n + 2))) * x ^ (Suc n + 2)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    44
           <= x ^ 2 / 2 * (1 / 2) ^ Suc n"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    45
  proof -
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    46
    have "inverse(real (fact (Suc n + 2))) <= 
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    47
        (1 / 2) *inverse (real (fact (n+2)))"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    48
    proof -
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    49
      have "Suc n + 2 = Suc (n + 2)" by simp
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    50
      then have "fact (Suc n + 2) = Suc (n + 2) * fact (n + 2)" 
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    51
        by simp
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    52
      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
    53
        apply (rule subst)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    54
        apply (rule refl)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    55
        done
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    56
      also have "... = real(Suc (n + 2)) * real(fact (n + 2))"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    57
        by (rule real_of_nat_mult)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    58
      finally have "real (fact (Suc n + 2)) = 
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    59
         real (Suc (n + 2)) * real (fact (n + 2))" .
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    60
      then have "inverse(real (fact (Suc n + 2))) = 
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    61
         inverse(real (Suc (n + 2))) * inverse(real (fact (n + 2)))"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    62
        apply (rule ssubst)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    63
        apply (rule inverse_mult_distrib)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    64
        done
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    65
      also have "... <= (1/2) * inverse(real (fact (n + 2)))"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    66
        apply (rule mult_right_mono)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    67
        apply (subst inverse_eq_divide)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    68
        apply simp
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    69
        apply (rule inv_real_of_nat_fact_ge_zero)
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
      finally show ?thesis .
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    72
    qed
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    73
    moreover have "x ^ (Suc n + 2) <= x ^ (n + 2)"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    74
      apply (simp add: mult_compare_simps)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    75
      apply (simp add: prems)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    76
      apply (subgoal_tac "0 <= x * (x * x^n)")
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    77
      apply force
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    78
      apply (rule mult_nonneg_nonneg, rule a)+
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    79
      apply (rule zero_le_power, rule a)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    80
      done
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    81
    ultimately have "inverse (real (fact (Suc n + 2))) *  x ^ (Suc n + 2) <=
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    82
        (1 / 2 * inverse (real (fact (n + 2)))) * x ^ (n + 2)"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    83
      apply (rule mult_mono)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    84
      apply (rule mult_nonneg_nonneg)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    85
      apply simp
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    86
      apply (subst inverse_nonnegative_iff_nonnegative)
27483
7c58324cd418 use real_of_nat_ge_zero instead of real_of_nat_fact_ge_zero
huffman
parents: 25875
diff changeset
    87
      apply (rule real_of_nat_ge_zero)
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    88
      apply (rule zero_le_power)
23441
ee218296d635 avoid using implicit prems in assumption
huffman
parents: 23114
diff changeset
    89
      apply (rule a)
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    90
      done
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    91
    also have "... = 1 / 2 * (inverse (real (fact (n + 2))) * x ^ (n + 2))"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    92
      by simp
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    93
    also have "... <= 1 / 2 * (x ^ 2 / 2 * (1 / 2) ^ n)"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    94
      apply (rule mult_left_mono)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    95
      apply (rule prems)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    96
      apply simp
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    97
      done
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    98
    also have "... = x ^ 2 / 2 * (1 / 2 * (1 / 2) ^ n)"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    99
      by auto
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   100
    also have "(1::real) / 2 * (1 / 2) ^ n = (1 / 2) ^ (Suc n)"
30273
ecd6f0ca62ea declare power_Suc [simp]; remove redundant type-specific versions of power_Suc
huffman
parents: 29667
diff changeset
   101
      by (rule power_Suc [THEN sym])
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   102
    finally show ?thesis .
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   103
  qed
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   104
qed
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   105
20692
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20563
diff changeset
   106
lemma aux2: "(%n. (x::real) ^ 2 / 2 * (1 / 2) ^ n) sums x^2"
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   107
proof -
20692
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20563
diff changeset
   108
  have "(%n. (1 / 2::real)^n) sums (1 / (1 - (1/2)))"
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   109
    apply (rule geometric_sums)
22998
97e1f9c2cc46 avoid using redundant lemmas from RealDef.thy
huffman
parents: 22654
diff changeset
   110
    by (simp add: abs_less_iff)
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   111
  also have "(1::real) / (1 - 1/2) = 2"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   112
    by simp
20692
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20563
diff changeset
   113
  finally have "(%n. (1 / 2::real)^n) sums 2" .
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   114
  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
   115
    by (rule sums_mult)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   116
  also have "x^2 / 2 * 2 = x^2"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   117
    by simp
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   118
  finally show ?thesis .
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   119
qed
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   120
23114
1bd84606b403 add type annotations for exp
huffman
parents: 22998
diff changeset
   121
lemma exp_bound: "0 <= (x::real) ==> x <= 1 ==> exp x <= 1 + x + x^2"
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   122
proof -
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   123
  assume a: "0 <= x"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   124
  assume b: "x <= 1"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   125
  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
   126
      (x ^ (n+2)))"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   127
    by (rule exp_first_two_terms)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   128
  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
   129
  proof -
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   130
    have "suminf (%n. inverse(real (fact (n+2))) * (x ^ (n+2))) <=
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   131
        suminf (%n. (x^2/2) * ((1/2)^n))"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   132
      apply (rule summable_le)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   133
      apply (auto simp only: aux1 prems)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   134
      apply (rule exp_tail_after_first_two_terms_summable)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   135
      by (rule sums_summable, rule aux2)  
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   136
    also have "... = x^2"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   137
      by (rule sums_unique [THEN sym], rule aux2)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   138
    finally show ?thesis .
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   139
  qed
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   140
  ultimately show ?thesis
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   141
    by auto
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   142
qed
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   143
23114
1bd84606b403 add type annotations for exp
huffman
parents: 22998
diff changeset
   144
lemma aux4: "0 <= (x::real) ==> x <= 1 ==> exp (x - x^2) <= 1 + x" 
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   145
proof -
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   146
  assume a: "0 <= x" and b: "x <= 1"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   147
  have "exp (x - x^2) = exp x / exp (x^2)"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   148
    by (rule exp_diff)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   149
  also have "... <= (1 + x + x^2) / exp (x ^2)"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   150
    apply (rule divide_right_mono) 
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   151
    apply (rule exp_bound)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   152
    apply (rule a, rule b)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   153
    apply simp
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
  also have "... <= (1 + x + x^2) / (1 + x^2)"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   156
    apply (rule divide_left_mono)
17013
74bc935273ea renamed exp_ge_add_one_self2 to exp_ge_add_one_self
avigad
parents: 16963
diff changeset
   157
    apply (auto simp add: exp_ge_add_one_self_aux)
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   158
    apply (rule add_nonneg_nonneg)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   159
    apply (insert prems, auto)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   160
    apply (rule mult_pos_pos)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   161
    apply auto
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   162
    apply (rule add_pos_nonneg)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   163
    apply auto
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   164
    done
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   165
  also from a have "... <= 1 + x"
23482
2f4be6844f7c tuned and used field_simps
nipkow
parents: 23477
diff changeset
   166
    by(simp add:field_simps zero_compare_simps)
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   167
  finally show ?thesis .
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   168
qed
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   169
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   170
lemma ln_one_plus_pos_lower_bound: "0 <= x ==> x <= 1 ==> 
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   171
    x - x^2 <= ln (1 + x)"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   172
proof -
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   173
  assume a: "0 <= x" and b: "x <= 1"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   174
  then have "exp (x - x^2) <= 1 + x"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   175
    by (rule aux4)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   176
  also have "... = exp (ln (1 + x))"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   177
  proof -
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   178
    from a have "0 < 1 + x" by auto
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   179
    thus ?thesis
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   180
      by (auto simp only: exp_ln_iff [THEN sym])
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   181
  qed
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   182
  finally have "exp (x - x ^ 2) <= exp (ln (1 + x))" .
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   183
  thus ?thesis by (auto simp only: exp_le_cancel_iff)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   184
qed
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   185
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   186
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
   187
proof -
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   188
  assume a: "0 <= (x::real)" and b: "x < 1"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   189
  have "(1 - x) * (1 + x + x^2) = (1 - x^3)"
29667
53103fc8ffa3 Replaced group_ and ring_simps by algebra_simps;
nipkow
parents: 28952
diff changeset
   190
    by (simp add: algebra_simps power2_eq_square power3_eq_cube)
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   191
  also have "... <= 1"
25875
536dfdc25e0a added simp attributes/ proofs fixed
nipkow
parents: 23482
diff changeset
   192
    by (auto simp add: a)
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   193
  finally have "(1 - x) * (1 + x + x ^ 2) <= 1" .
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   194
  moreover have "0 < 1 + x + x^2"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   195
    apply (rule add_pos_nonneg)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   196
    apply (insert a, auto)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   197
    done
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   198
  ultimately have "1 - x <= 1 / (1 + x + x^2)"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   199
    by (elim mult_imp_le_div_pos)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   200
  also have "... <= 1 / exp x"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   201
    apply (rule divide_left_mono)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   202
    apply (rule exp_bound, rule a)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   203
    apply (insert prems, auto)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   204
    apply (rule mult_pos_pos)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   205
    apply (rule add_pos_nonneg)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   206
    apply auto
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   207
    done
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   208
  also have "... = exp (-x)"
36777
be5461582d0f avoid using real-specific versions of generic lemmas
huffman
parents: 33667
diff changeset
   209
    by (auto simp add: exp_minus divide_inverse)
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   210
  finally have "1 - x <= exp (- x)" .
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   211
  also have "1 - x = exp (ln (1 - x))"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   212
  proof -
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   213
    have "0 < 1 - x"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   214
      by (insert b, auto)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   215
    thus ?thesis
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   216
      by (auto simp only: exp_ln_iff [THEN sym])
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   217
  qed
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   218
  finally have "exp (ln (1 - x)) <= exp (- x)" .
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   219
  thus ?thesis by (auto simp only: exp_le_cancel_iff)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   220
qed
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   221
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   222
lemma aux5: "x < 1 ==> ln(1 - x) = - ln(1 + x / (1 - x))"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   223
proof -
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   224
  assume a: "x < 1"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   225
  have "ln(1 - x) = - ln(1 / (1 - x))"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   226
  proof -
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   227
    have "ln(1 - x) = - (- ln (1 - x))"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   228
      by auto
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   229
    also have "- ln(1 - x) = ln 1 - ln(1 - x)"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   230
      by simp
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   231
    also have "... = ln(1 / (1 - x))"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   232
      apply (rule ln_div [THEN sym])
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   233
      by (insert a, auto)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   234
    finally show ?thesis .
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   235
  qed
23482
2f4be6844f7c tuned and used field_simps
nipkow
parents: 23477
diff changeset
   236
  also have " 1 / (1 - x) = 1 + x / (1 - x)" using a by(simp add:field_simps)
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   237
  finally show ?thesis .
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   238
qed
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   239
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   240
lemma ln_one_minus_pos_lower_bound: "0 <= x ==> x <= (1 / 2) ==> 
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   241
    - x - 2 * x^2 <= ln (1 - x)"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   242
proof -
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   243
  assume a: "0 <= x" and b: "x <= (1 / 2)"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   244
  from b have c: "x < 1"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   245
    by auto
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   246
  then have "ln (1 - x) = - ln (1 + x / (1 - x))"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   247
    by (rule aux5)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   248
  also have "- (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 "ln (1 + x / (1 - x)) <= x / (1 - x)"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   251
      apply (rule ln_add_one_self_le_self)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   252
      apply (rule divide_nonneg_pos)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   253
      by (insert a c, auto) 
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   254
    thus ?thesis
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   255
      by auto
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   256
  qed
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   257
  also have "- (x / (1 - x)) = -x / (1 - x)"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   258
    by auto
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   259
  finally have d: "- x / (1 - x) <= ln (1 - x)" .
23482
2f4be6844f7c tuned and used field_simps
nipkow
parents: 23477
diff changeset
   260
  have "0 < 1 - x" using prems by simp
2f4be6844f7c tuned and used field_simps
nipkow
parents: 23477
diff changeset
   261
  hence e: "-x - 2 * x^2 <= - x / (1 - x)"
2f4be6844f7c tuned and used field_simps
nipkow
parents: 23477
diff changeset
   262
    using mult_right_le_one_le[of "x*x" "2*x"] prems
2f4be6844f7c tuned and used field_simps
nipkow
parents: 23477
diff changeset
   263
    by(simp add:field_simps power2_eq_square)
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   264
  from e d show "- x - 2 * x^2 <= ln (1 - x)"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   265
    by (rule order_trans)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   266
qed
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   267
23114
1bd84606b403 add type annotations for exp
huffman
parents: 22998
diff changeset
   268
lemma exp_ge_add_one_self [simp]: "1 + (x::real) <= exp x"
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   269
  apply (case_tac "0 <= x")
17013
74bc935273ea renamed exp_ge_add_one_self2 to exp_ge_add_one_self
avigad
parents: 16963
diff changeset
   270
  apply (erule exp_ge_add_one_self_aux)
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   271
  apply (case_tac "x <= -1")
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   272
  apply (subgoal_tac "1 + x <= 0")
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   273
  apply (erule order_trans)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   274
  apply simp
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   275
  apply simp
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   276
  apply (subgoal_tac "1 + x = exp(ln (1 + x))")
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   277
  apply (erule ssubst)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   278
  apply (subst exp_le_cancel_iff)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   279
  apply (subgoal_tac "ln (1 - (- x)) <= - (- x)")
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   280
  apply simp
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   281
  apply (rule ln_one_minus_pos_upper_bound) 
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   282
  apply auto
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   283
done
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   284
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   285
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
   286
  apply (subgoal_tac "x = ln (exp x)")
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   287
  apply (erule ssubst)back
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   288
  apply (subst ln_le_cancel_iff)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   289
  apply auto
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   290
done
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   291
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   292
lemma abs_ln_one_plus_x_minus_x_bound_nonneg:
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   293
    "0 <= x ==> x <= 1 ==> abs(ln (1 + x) - x) <= x^2"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   294
proof -
23441
ee218296d635 avoid using implicit prems in assumption
huffman
parents: 23114
diff changeset
   295
  assume x: "0 <= x"
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   296
  assume "x <= 1"
23441
ee218296d635 avoid using implicit prems in assumption
huffman
parents: 23114
diff changeset
   297
  from x have "ln (1 + x) <= x"
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   298
    by (rule ln_add_one_self_le_self)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   299
  then have "ln (1 + x) - x <= 0" 
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   300
    by simp
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   301
  then have "abs(ln(1 + x) - x) = - (ln(1 + x) - x)"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   302
    by (rule abs_of_nonpos)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   303
  also have "... = x - ln (1 + x)" 
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   304
    by simp
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   305
  also have "... <= x^2"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   306
  proof -
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   307
    from prems have "x - x^2 <= ln (1 + x)"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   308
      by (intro ln_one_plus_pos_lower_bound)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   309
    thus ?thesis
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   310
      by simp
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   311
  qed
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   312
  finally show ?thesis .
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   313
qed
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   314
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   315
lemma abs_ln_one_plus_x_minus_x_bound_nonpos:
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   316
    "-(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
   317
proof -
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   318
  assume "-(1 / 2) <= x"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   319
  assume "x <= 0"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   320
  have "abs(ln (1 + x) - x) = x - ln(1 - (-x))" 
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   321
    apply (subst abs_of_nonpos)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   322
    apply simp
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   323
    apply (rule ln_add_one_self_le_self2)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   324
    apply (insert prems, auto)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   325
    done
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   326
  also have "... <= 2 * x^2"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   327
    apply (subgoal_tac "- (-x) - 2 * (-x)^2 <= ln (1 - (-x))")
29667
53103fc8ffa3 Replaced group_ and ring_simps by algebra_simps;
nipkow
parents: 28952
diff changeset
   328
    apply (simp add: algebra_simps)
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   329
    apply (rule ln_one_minus_pos_lower_bound)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   330
    apply (insert prems, auto)
29667
53103fc8ffa3 Replaced group_ and ring_simps by algebra_simps;
nipkow
parents: 28952
diff changeset
   331
    done
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   332
  finally show ?thesis .
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   333
qed
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   334
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   335
lemma abs_ln_one_plus_x_minus_x_bound:
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   336
    "abs x <= 1 / 2 ==> abs(ln (1 + x) - x) <= 2 * x^2"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   337
  apply (case_tac "0 <= x")
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   338
  apply (rule order_trans)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   339
  apply (rule abs_ln_one_plus_x_minus_x_bound_nonneg)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   340
  apply auto
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   341
  apply (rule abs_ln_one_plus_x_minus_x_bound_nonpos)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   342
  apply auto
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   343
done
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   344
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   345
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
   346
proof -
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   347
  assume "exp 1 <= x" and "x <= y"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   348
  have a: "0 < x" and b: "0 < y"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   349
    apply (insert prems)
23114
1bd84606b403 add type annotations for exp
huffman
parents: 22998
diff changeset
   350
    apply (subgoal_tac "0 < exp (1::real)")
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   351
    apply arith
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   352
    apply auto
23114
1bd84606b403 add type annotations for exp
huffman
parents: 22998
diff changeset
   353
    apply (subgoal_tac "0 < exp (1::real)")
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   354
    apply arith
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   355
    apply auto
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   356
    done
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   357
  have "x * ln y - x * ln x = x * (ln y - ln x)"
29667
53103fc8ffa3 Replaced group_ and ring_simps by algebra_simps;
nipkow
parents: 28952
diff changeset
   358
    by (simp add: algebra_simps)
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   359
  also have "... = x * ln(y / x)"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   360
    apply (subst ln_div)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   361
    apply (rule b, rule a, rule refl)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   362
    done
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   363
  also have "y / x = (x + (y - x)) / x"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   364
    by simp
23482
2f4be6844f7c tuned and used field_simps
nipkow
parents: 23477
diff changeset
   365
  also have "... = 1 + (y - x) / x" using a prems by(simp add:field_simps)
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   366
  also have "x * ln(1 + (y - x) / x) <= x * ((y - x) / x)"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   367
    apply (rule mult_left_mono)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   368
    apply (rule ln_add_one_self_le_self)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   369
    apply (rule divide_nonneg_pos)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   370
    apply (insert prems a, simp_all) 
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   371
    done
23482
2f4be6844f7c tuned and used field_simps
nipkow
parents: 23477
diff changeset
   372
  also have "... = y - x" using a by simp
2f4be6844f7c tuned and used field_simps
nipkow
parents: 23477
diff changeset
   373
  also have "... = (y - x) * ln (exp 1)" by simp
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   374
  also have "... <= (y - x) * ln x"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   375
    apply (rule mult_left_mono)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   376
    apply (subst ln_le_cancel_iff)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   377
    apply force
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   378
    apply (rule a)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   379
    apply (rule prems)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   380
    apply (insert prems, simp)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   381
    done
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   382
  also have "... = y * ln x - x * ln x"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   383
    by (rule left_diff_distrib)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   384
  finally have "x * ln y <= y * ln x"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   385
    by arith
23482
2f4be6844f7c tuned and used field_simps
nipkow
parents: 23477
diff changeset
   386
  then have "ln y <= (y * ln x) / x" using a by(simp add:field_simps)
2f4be6844f7c tuned and used field_simps
nipkow
parents: 23477
diff changeset
   387
  also have "... = y * (ln x / x)"  by simp
2f4be6844f7c tuned and used field_simps
nipkow
parents: 23477
diff changeset
   388
  finally show ?thesis using b by(simp add:field_simps)
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   389
qed
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   390
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   391
end