src/HOL/Ln.thy
author huffman
Fri, 19 Aug 2011 07:45:22 -0700
changeset 44305 3bdc02eb1637
parent 44289 d81d09cdab9c
child 47242 1caeecc72aea
permissions -rw-r--r--
remove some redundant simp rules
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
41959
b460124855b8 tuned headers;
wenzelm
parents: 41550
diff changeset
     1
(*  Title:      HOL/Ln.thy
16959
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"
44289
d81d09cdab9c optimize some proofs
huffman
parents: 43336
diff changeset
    21
    by (simp add: numeral_2_eq_2)
16959
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
44305
3bdc02eb1637 remove some redundant simp rules
huffman
parents: 44289
diff changeset
    68
        apply (simp del: fact_Suc)
16959
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)"
44289
d81d09cdab9c optimize some proofs
huffman
parents: 43336
diff changeset
    73
      by (simp add: mult_left_le_one_le mult_nonneg_nonneg a b)
40864
4abaaadfdaf2 moved activation of coercion inference into RealDef and declared function real a coercion.
nipkow
parents: 36777
diff changeset
    74
    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
    75
        (1 / 2 * inverse (fact (n + 2))) * x ^ (n + 2)"
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    76
      apply (rule mult_mono)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    77
      apply (rule mult_nonneg_nonneg)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    78
      apply simp
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    79
      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
    80
      apply (rule real_of_nat_ge_zero)
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    81
      apply (rule zero_le_power)
23441
ee218296d635 avoid using implicit prems in assumption
huffman
parents: 23114
diff changeset
    82
      apply (rule a)
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    83
      done
40864
4abaaadfdaf2 moved activation of coercion inference into RealDef and declared function real a coercion.
nipkow
parents: 36777
diff changeset
    84
    also have "... = 1 / 2 * (inverse (fact (n + 2)) * x ^ (n + 2))"
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    85
      by simp
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    86
    also have "... <= 1 / 2 * (x ^ 2 / 2 * (1 / 2) ^ n)"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    87
      apply (rule mult_left_mono)
41550
efa734d9b221 eliminated global prems;
wenzelm
parents: 40864
diff changeset
    88
      apply (rule c)
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    89
      apply simp
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 "... = x ^ 2 / 2 * (1 / 2 * (1 / 2) ^ n)"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    92
      by auto
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    93
    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
    94
      by (rule power_Suc [THEN sym])
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    95
    finally show ?thesis .
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    96
  qed
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    97
qed
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    98
20692
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20563
diff changeset
    99
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
   100
proof -
20692
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20563
diff changeset
   101
  have "(%n. (1 / 2::real)^n) sums (1 / (1 - (1/2)))"
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   102
    apply (rule geometric_sums)
22998
97e1f9c2cc46 avoid using redundant lemmas from RealDef.thy
huffman
parents: 22654
diff changeset
   103
    by (simp add: abs_less_iff)
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   104
  also have "(1::real) / (1 - 1/2) = 2"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   105
    by simp
20692
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20563
diff changeset
   106
  finally have "(%n. (1 / 2::real)^n) sums 2" .
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   107
  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
   108
    by (rule sums_mult)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   109
  also have "x^2 / 2 * 2 = x^2"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   110
    by simp
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   111
  finally show ?thesis .
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   112
qed
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   113
23114
1bd84606b403 add type annotations for exp
huffman
parents: 22998
diff changeset
   114
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
   115
proof -
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   116
  assume a: "0 <= x"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   117
  assume b: "x <= 1"
40864
4abaaadfdaf2 moved activation of coercion inference into RealDef and declared function real a coercion.
nipkow
parents: 36777
diff changeset
   118
  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
   119
      (x ^ (n+2)))"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   120
    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
   121
  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
   122
  proof -
40864
4abaaadfdaf2 moved activation of coercion inference into RealDef and declared function real a coercion.
nipkow
parents: 36777
diff changeset
   123
    have "suminf (%n. inverse(fact (n+2)) * (x ^ (n+2))) <=
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   124
        suminf (%n. (x^2/2) * ((1/2)^n))"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   125
      apply (rule summable_le)
41550
efa734d9b221 eliminated global prems;
wenzelm
parents: 40864
diff changeset
   126
      apply (auto simp only: aux1 a b)
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   127
      apply (rule exp_tail_after_first_two_terms_summable)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   128
      by (rule sums_summable, rule aux2)  
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   129
    also have "... = x^2"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   130
      by (rule sums_unique [THEN sym], rule aux2)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   131
    finally show ?thesis .
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   132
  qed
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   133
  ultimately show ?thesis
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   134
    by auto
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   135
qed
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   136
23114
1bd84606b403 add type annotations for exp
huffman
parents: 22998
diff changeset
   137
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
   138
proof -
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   139
  assume a: "0 <= x" and b: "x <= 1"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   140
  have "exp (x - x^2) = exp x / exp (x^2)"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   141
    by (rule exp_diff)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   142
  also have "... <= (1 + x + x^2) / exp (x ^2)"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   143
    apply (rule divide_right_mono) 
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   144
    apply (rule exp_bound)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   145
    apply (rule a, rule b)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   146
    apply simp
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   147
    done
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   148
  also have "... <= (1 + x + x^2) / (1 + x^2)"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   149
    apply (rule divide_left_mono)
17013
74bc935273ea renamed exp_ge_add_one_self2 to exp_ge_add_one_self
avigad
parents: 16963
diff changeset
   150
    apply (auto simp add: exp_ge_add_one_self_aux)
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   151
    apply (rule add_nonneg_nonneg)
41550
efa734d9b221 eliminated global prems;
wenzelm
parents: 40864
diff changeset
   152
    using a apply auto
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   153
    apply (rule mult_pos_pos)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   154
    apply auto
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   155
    apply (rule add_pos_nonneg)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   156
    apply auto
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   157
    done
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   158
  also from a have "... <= 1 + x"
44289
d81d09cdab9c optimize some proofs
huffman
parents: 43336
diff changeset
   159
    by (simp add: field_simps add_strict_increasing zero_le_mult_iff)
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   160
  finally show ?thesis .
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   161
qed
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   162
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   163
lemma ln_one_plus_pos_lower_bound: "0 <= x ==> x <= 1 ==> 
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   164
    x - x^2 <= ln (1 + x)"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   165
proof -
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   166
  assume a: "0 <= x" and b: "x <= 1"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   167
  then have "exp (x - x^2) <= 1 + x"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   168
    by (rule aux4)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   169
  also have "... = exp (ln (1 + x))"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   170
  proof -
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   171
    from a have "0 < 1 + x" by auto
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   172
    thus ?thesis
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   173
      by (auto simp only: exp_ln_iff [THEN sym])
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   174
  qed
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   175
  finally have "exp (x - x ^ 2) <= exp (ln (1 + x))" .
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   176
  thus ?thesis by (auto simp only: exp_le_cancel_iff)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   177
qed
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   178
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   179
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
   180
proof -
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   181
  assume a: "0 <= (x::real)" and b: "x < 1"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   182
  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
   183
    by (simp add: algebra_simps power2_eq_square power3_eq_cube)
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   184
  also have "... <= 1"
25875
536dfdc25e0a added simp attributes/ proofs fixed
nipkow
parents: 23482
diff changeset
   185
    by (auto simp add: a)
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   186
  finally have "(1 - x) * (1 + x + x ^ 2) <= 1" .
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   187
  moreover have "0 < 1 + x + x^2"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   188
    apply (rule add_pos_nonneg)
41550
efa734d9b221 eliminated global prems;
wenzelm
parents: 40864
diff changeset
   189
    using a apply auto
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   190
    done
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   191
  ultimately have "1 - x <= 1 / (1 + x + x^2)"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   192
    by (elim mult_imp_le_div_pos)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   193
  also have "... <= 1 / exp x"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   194
    apply (rule divide_left_mono)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   195
    apply (rule exp_bound, rule a)
41550
efa734d9b221 eliminated global prems;
wenzelm
parents: 40864
diff changeset
   196
    using a b apply auto
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   197
    apply (rule mult_pos_pos)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   198
    apply (rule add_pos_nonneg)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   199
    apply auto
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   200
    done
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   201
  also have "... = exp (-x)"
36777
be5461582d0f avoid using real-specific versions of generic lemmas
huffman
parents: 33667
diff changeset
   202
    by (auto simp add: exp_minus divide_inverse)
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   203
  finally have "1 - x <= exp (- x)" .
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   204
  also have "1 - x = exp (ln (1 - x))"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   205
  proof -
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   206
    have "0 < 1 - x"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   207
      by (insert b, auto)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   208
    thus ?thesis
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   209
      by (auto simp only: exp_ln_iff [THEN sym])
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   210
  qed
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   211
  finally have "exp (ln (1 - x)) <= exp (- x)" .
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   212
  thus ?thesis by (auto simp only: exp_le_cancel_iff)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   213
qed
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   214
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   215
lemma aux5: "x < 1 ==> ln(1 - x) = - ln(1 + x / (1 - x))"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   216
proof -
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   217
  assume a: "x < 1"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   218
  have "ln(1 - x) = - ln(1 / (1 - x))"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   219
  proof -
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   220
    have "ln(1 - x) = - (- ln (1 - x))"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   221
      by auto
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   222
    also have "- ln(1 - x) = ln 1 - ln(1 - x)"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   223
      by simp
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   224
    also have "... = ln(1 / (1 - x))"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   225
      apply (rule ln_div [THEN sym])
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   226
      by (insert a, auto)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   227
    finally show ?thesis .
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   228
  qed
23482
2f4be6844f7c tuned and used field_simps
nipkow
parents: 23477
diff changeset
   229
  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
   230
  finally show ?thesis .
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   231
qed
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   232
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   233
lemma ln_one_minus_pos_lower_bound: "0 <= x ==> x <= (1 / 2) ==> 
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   234
    - x - 2 * x^2 <= ln (1 - x)"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   235
proof -
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   236
  assume a: "0 <= x" and b: "x <= (1 / 2)"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   237
  from b have c: "x < 1"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   238
    by auto
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   239
  then have "ln (1 - x) = - ln (1 + x / (1 - x))"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   240
    by (rule aux5)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   241
  also have "- (x / (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
    have "ln (1 + x / (1 - x)) <= x / (1 - x)"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   244
      apply (rule ln_add_one_self_le_self)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   245
      apply (rule divide_nonneg_pos)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   246
      by (insert a c, auto) 
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   247
    thus ?thesis
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   248
      by auto
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   249
  qed
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   250
  also have "- (x / (1 - x)) = -x / (1 - x)"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   251
    by auto
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   252
  finally have d: "- x / (1 - x) <= ln (1 - x)" .
41550
efa734d9b221 eliminated global prems;
wenzelm
parents: 40864
diff changeset
   253
  have "0 < 1 - x" using a b by simp
23482
2f4be6844f7c tuned and used field_simps
nipkow
parents: 23477
diff changeset
   254
  hence e: "-x - 2 * x^2 <= - x / (1 - x)"
41550
efa734d9b221 eliminated global prems;
wenzelm
parents: 40864
diff changeset
   255
    using mult_right_le_one_le[of "x*x" "2*x"] a b
efa734d9b221 eliminated global prems;
wenzelm
parents: 40864
diff changeset
   256
    by (simp add:field_simps power2_eq_square)
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   257
  from e d show "- x - 2 * x^2 <= ln (1 - x)"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   258
    by (rule order_trans)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   259
qed
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   260
23114
1bd84606b403 add type annotations for exp
huffman
parents: 22998
diff changeset
   261
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
   262
  apply (case_tac "0 <= x")
17013
74bc935273ea renamed exp_ge_add_one_self2 to exp_ge_add_one_self
avigad
parents: 16963
diff changeset
   263
  apply (erule exp_ge_add_one_self_aux)
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   264
  apply (case_tac "x <= -1")
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   265
  apply (subgoal_tac "1 + x <= 0")
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   266
  apply (erule order_trans)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   267
  apply simp
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   268
  apply simp
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   269
  apply (subgoal_tac "1 + x = exp(ln (1 + x))")
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   270
  apply (erule ssubst)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   271
  apply (subst exp_le_cancel_iff)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   272
  apply (subgoal_tac "ln (1 - (- x)) <= - (- x)")
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 (rule ln_one_minus_pos_upper_bound) 
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   275
  apply auto
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   276
done
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   277
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   278
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
   279
  apply (subgoal_tac "x = ln (exp x)")
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   280
  apply (erule ssubst)back
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   281
  apply (subst ln_le_cancel_iff)
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 abs_ln_one_plus_x_minus_x_bound_nonneg:
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   286
    "0 <= x ==> x <= 1 ==> abs(ln (1 + x) - x) <= x^2"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   287
proof -
23441
ee218296d635 avoid using implicit prems in assumption
huffman
parents: 23114
diff changeset
   288
  assume x: "0 <= x"
41550
efa734d9b221 eliminated global prems;
wenzelm
parents: 40864
diff changeset
   289
  assume x1: "x <= 1"
23441
ee218296d635 avoid using implicit prems in assumption
huffman
parents: 23114
diff changeset
   290
  from x have "ln (1 + x) <= x"
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   291
    by (rule ln_add_one_self_le_self)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   292
  then have "ln (1 + x) - x <= 0" 
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   293
    by simp
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   294
  then have "abs(ln(1 + x) - x) = - (ln(1 + x) - x)"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   295
    by (rule abs_of_nonpos)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   296
  also have "... = x - ln (1 + x)" 
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   297
    by simp
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   298
  also have "... <= x^2"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   299
  proof -
41550
efa734d9b221 eliminated global prems;
wenzelm
parents: 40864
diff changeset
   300
    from x x1 have "x - x^2 <= ln (1 + x)"
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   301
      by (intro ln_one_plus_pos_lower_bound)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   302
    thus ?thesis
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
  qed
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   305
  finally show ?thesis .
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   306
qed
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   307
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   308
lemma abs_ln_one_plus_x_minus_x_bound_nonpos:
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   309
    "-(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
   310
proof -
41550
efa734d9b221 eliminated global prems;
wenzelm
parents: 40864
diff changeset
   311
  assume a: "-(1 / 2) <= x"
efa734d9b221 eliminated global prems;
wenzelm
parents: 40864
diff changeset
   312
  assume b: "x <= 0"
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   313
  have "abs(ln (1 + x) - x) = x - ln(1 - (-x))" 
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   314
    apply (subst abs_of_nonpos)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   315
    apply simp
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   316
    apply (rule ln_add_one_self_le_self2)
41550
efa734d9b221 eliminated global prems;
wenzelm
parents: 40864
diff changeset
   317
    using a apply auto
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   318
    done
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   319
  also have "... <= 2 * x^2"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   320
    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
   321
    apply (simp add: algebra_simps)
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   322
    apply (rule ln_one_minus_pos_lower_bound)
41550
efa734d9b221 eliminated global prems;
wenzelm
parents: 40864
diff changeset
   323
    using a b apply auto
29667
53103fc8ffa3 Replaced group_ and ring_simps by algebra_simps;
nipkow
parents: 28952
diff changeset
   324
    done
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   325
  finally show ?thesis .
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   326
qed
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   327
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   328
lemma abs_ln_one_plus_x_minus_x_bound:
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   329
    "abs x <= 1 / 2 ==> abs(ln (1 + x) - x) <= 2 * x^2"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   330
  apply (case_tac "0 <= x")
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   331
  apply (rule order_trans)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   332
  apply (rule abs_ln_one_plus_x_minus_x_bound_nonneg)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   333
  apply auto
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   334
  apply (rule abs_ln_one_plus_x_minus_x_bound_nonpos)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   335
  apply auto
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   336
done
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   337
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   338
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
   339
proof -
41550
efa734d9b221 eliminated global prems;
wenzelm
parents: 40864
diff changeset
   340
  assume x: "exp 1 <= x" "x <= y"
44289
d81d09cdab9c optimize some proofs
huffman
parents: 43336
diff changeset
   341
  moreover have "0 < exp (1::real)" by simp
d81d09cdab9c optimize some proofs
huffman
parents: 43336
diff changeset
   342
  ultimately have a: "0 < x" and b: "0 < y"
d81d09cdab9c optimize some proofs
huffman
parents: 43336
diff changeset
   343
    by (fast intro: less_le_trans order_trans)+
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   344
  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
   345
    by (simp add: algebra_simps)
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   346
  also have "... = x * ln(y / x)"
44289
d81d09cdab9c optimize some proofs
huffman
parents: 43336
diff changeset
   347
    by (simp only: ln_div a b)
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   348
  also have "y / x = (x + (y - x)) / x"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   349
    by simp
44289
d81d09cdab9c optimize some proofs
huffman
parents: 43336
diff changeset
   350
  also have "... = 1 + (y - x) / x"
d81d09cdab9c optimize some proofs
huffman
parents: 43336
diff changeset
   351
    using x a by (simp add: field_simps)
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   352
  also have "x * ln(1 + (y - x) / x) <= x * ((y - x) / x)"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   353
    apply (rule mult_left_mono)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   354
    apply (rule ln_add_one_self_le_self)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   355
    apply (rule divide_nonneg_pos)
41550
efa734d9b221 eliminated global prems;
wenzelm
parents: 40864
diff changeset
   356
    using x a apply simp_all
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   357
    done
23482
2f4be6844f7c tuned and used field_simps
nipkow
parents: 23477
diff changeset
   358
  also have "... = y - x" using a by simp
2f4be6844f7c tuned and used field_simps
nipkow
parents: 23477
diff changeset
   359
  also have "... = (y - x) * ln (exp 1)" by simp
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   360
  also have "... <= (y - x) * ln x"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   361
    apply (rule mult_left_mono)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   362
    apply (subst ln_le_cancel_iff)
44289
d81d09cdab9c optimize some proofs
huffman
parents: 43336
diff changeset
   363
    apply fact
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   364
    apply (rule a)
41550
efa734d9b221 eliminated global prems;
wenzelm
parents: 40864
diff changeset
   365
    apply (rule x)
efa734d9b221 eliminated global prems;
wenzelm
parents: 40864
diff changeset
   366
    using x apply simp
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   367
    done
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   368
  also have "... = y * ln x - x * ln x"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   369
    by (rule left_diff_distrib)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   370
  finally have "x * ln y <= y * ln x"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   371
    by arith
41550
efa734d9b221 eliminated global prems;
wenzelm
parents: 40864
diff changeset
   372
  then have "ln y <= (y * ln x) / x" using a by (simp add: field_simps)
efa734d9b221 eliminated global prems;
wenzelm
parents: 40864
diff changeset
   373
  also have "... = y * (ln x / x)" by simp
efa734d9b221 eliminated global prems;
wenzelm
parents: 40864
diff changeset
   374
  finally show ?thesis using b by (simp add: field_simps)
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   375
qed
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   376
43336
05aa7380f7fc lemmas relating ln x and x - 1
hoelzl
parents: 41959
diff changeset
   377
lemma ln_le_minus_one:
05aa7380f7fc lemmas relating ln x and x - 1
hoelzl
parents: 41959
diff changeset
   378
  "0 < x \<Longrightarrow> ln x \<le> x - 1"
05aa7380f7fc lemmas relating ln x and x - 1
hoelzl
parents: 41959
diff changeset
   379
  using exp_ge_add_one_self[of "ln x"] by simp
05aa7380f7fc lemmas relating ln x and x - 1
hoelzl
parents: 41959
diff changeset
   380
05aa7380f7fc lemmas relating ln x and x - 1
hoelzl
parents: 41959
diff changeset
   381
lemma ln_eq_minus_one:
05aa7380f7fc lemmas relating ln x and x - 1
hoelzl
parents: 41959
diff changeset
   382
  assumes "0 < x" "ln x = x - 1" shows "x = 1"
05aa7380f7fc lemmas relating ln x and x - 1
hoelzl
parents: 41959
diff changeset
   383
proof -
05aa7380f7fc lemmas relating ln x and x - 1
hoelzl
parents: 41959
diff changeset
   384
  let "?l y" = "ln y - y + 1"
05aa7380f7fc lemmas relating ln x and x - 1
hoelzl
parents: 41959
diff changeset
   385
  have D: "\<And>x. 0 < x \<Longrightarrow> DERIV ?l x :> (1 / x - 1)"
05aa7380f7fc lemmas relating ln x and x - 1
hoelzl
parents: 41959
diff changeset
   386
    by (auto intro!: DERIV_intros)
05aa7380f7fc lemmas relating ln x and x - 1
hoelzl
parents: 41959
diff changeset
   387
05aa7380f7fc lemmas relating ln x and x - 1
hoelzl
parents: 41959
diff changeset
   388
  show ?thesis
05aa7380f7fc lemmas relating ln x and x - 1
hoelzl
parents: 41959
diff changeset
   389
  proof (cases rule: linorder_cases)
05aa7380f7fc lemmas relating ln x and x - 1
hoelzl
parents: 41959
diff changeset
   390
    assume "x < 1"
05aa7380f7fc lemmas relating ln x and x - 1
hoelzl
parents: 41959
diff changeset
   391
    from dense[OF `x < 1`] obtain a where "x < a" "a < 1" by blast
05aa7380f7fc lemmas relating ln x and x - 1
hoelzl
parents: 41959
diff changeset
   392
    from `x < a` have "?l x < ?l a"
05aa7380f7fc lemmas relating ln x and x - 1
hoelzl
parents: 41959
diff changeset
   393
    proof (rule DERIV_pos_imp_increasing, safe)
05aa7380f7fc lemmas relating ln x and x - 1
hoelzl
parents: 41959
diff changeset
   394
      fix y assume "x \<le> y" "y \<le> a"
05aa7380f7fc lemmas relating ln x and x - 1
hoelzl
parents: 41959
diff changeset
   395
      with `0 < x` `a < 1` have "0 < 1 / y - 1" "0 < y"
05aa7380f7fc lemmas relating ln x and x - 1
hoelzl
parents: 41959
diff changeset
   396
        by (auto simp: field_simps)
05aa7380f7fc lemmas relating ln x and x - 1
hoelzl
parents: 41959
diff changeset
   397
      with D show "\<exists>z. DERIV ?l y :> z \<and> 0 < z"
05aa7380f7fc lemmas relating ln x and x - 1
hoelzl
parents: 41959
diff changeset
   398
        by auto
05aa7380f7fc lemmas relating ln x and x - 1
hoelzl
parents: 41959
diff changeset
   399
    qed
05aa7380f7fc lemmas relating ln x and x - 1
hoelzl
parents: 41959
diff changeset
   400
    also have "\<dots> \<le> 0"
05aa7380f7fc lemmas relating ln x and x - 1
hoelzl
parents: 41959
diff changeset
   401
      using ln_le_minus_one `0 < x` `x < a` by (auto simp: field_simps)
05aa7380f7fc lemmas relating ln x and x - 1
hoelzl
parents: 41959
diff changeset
   402
    finally show "x = 1" using assms by auto
05aa7380f7fc lemmas relating ln x and x - 1
hoelzl
parents: 41959
diff changeset
   403
  next
05aa7380f7fc lemmas relating ln x and x - 1
hoelzl
parents: 41959
diff changeset
   404
    assume "1 < x"
05aa7380f7fc lemmas relating ln x and x - 1
hoelzl
parents: 41959
diff changeset
   405
    from dense[OF `1 < x`] obtain a where "1 < a" "a < x" by blast
05aa7380f7fc lemmas relating ln x and x - 1
hoelzl
parents: 41959
diff changeset
   406
    from `a < x` have "?l x < ?l a"
05aa7380f7fc lemmas relating ln x and x - 1
hoelzl
parents: 41959
diff changeset
   407
    proof (rule DERIV_neg_imp_decreasing, safe)
05aa7380f7fc lemmas relating ln x and x - 1
hoelzl
parents: 41959
diff changeset
   408
      fix y assume "a \<le> y" "y \<le> x"
05aa7380f7fc lemmas relating ln x and x - 1
hoelzl
parents: 41959
diff changeset
   409
      with `1 < a` have "1 / y - 1 < 0" "0 < y"
05aa7380f7fc lemmas relating ln x and x - 1
hoelzl
parents: 41959
diff changeset
   410
        by (auto simp: field_simps)
05aa7380f7fc lemmas relating ln x and x - 1
hoelzl
parents: 41959
diff changeset
   411
      with D show "\<exists>z. DERIV ?l y :> z \<and> z < 0"
05aa7380f7fc lemmas relating ln x and x - 1
hoelzl
parents: 41959
diff changeset
   412
        by blast
05aa7380f7fc lemmas relating ln x and x - 1
hoelzl
parents: 41959
diff changeset
   413
    qed
05aa7380f7fc lemmas relating ln x and x - 1
hoelzl
parents: 41959
diff changeset
   414
    also have "\<dots> \<le> 0"
05aa7380f7fc lemmas relating ln x and x - 1
hoelzl
parents: 41959
diff changeset
   415
      using ln_le_minus_one `1 < a` by (auto simp: field_simps)
05aa7380f7fc lemmas relating ln x and x - 1
hoelzl
parents: 41959
diff changeset
   416
    finally show "x = 1" using assms by auto
05aa7380f7fc lemmas relating ln x and x - 1
hoelzl
parents: 41959
diff changeset
   417
  qed simp
05aa7380f7fc lemmas relating ln x and x - 1
hoelzl
parents: 41959
diff changeset
   418
qed
05aa7380f7fc lemmas relating ln x and x - 1
hoelzl
parents: 41959
diff changeset
   419
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   420
end