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