src/HOL/Ln.thy
author haftmann
Fri, 15 Feb 2013 08:31:31 +0100
changeset 51143 0a2371e7ced3
parent 50326 b5afeccab2db
permissions -rw-r--r--
two target language numeral types: integer and natural, as replacement for code_numeral; former theory HOL/Library/Code_Numeral_Types replaces HOL/Code_Numeral; refined stack of theories implementing int and/or nat by target language numerals; reduced number of target language numeral types to exactly one
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
47244
a7f85074c169 tuned proofs
huffman
parents: 47242
diff changeset
    11
lemma ln_one_plus_pos_lower_bound: "0 <= x ==> x <= 1 ==> 
a7f85074c169 tuned proofs
huffman
parents: 47242
diff changeset
    12
    x - x^2 <= ln (1 + x)"
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    13
proof -
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    14
  assume a: "0 <= x" and b: "x <= 1"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    15
  have "exp (x - x^2) = exp x / exp (x^2)"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    16
    by (rule exp_diff)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    17
  also have "... <= (1 + x + x^2) / exp (x ^2)"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    18
    apply (rule divide_right_mono) 
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    19
    apply (rule exp_bound)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    20
    apply (rule a, rule b)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    21
    apply simp
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    22
    done
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    23
  also have "... <= (1 + x + x^2) / (1 + x^2)"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    24
    apply (rule divide_left_mono)
47244
a7f85074c169 tuned proofs
huffman
parents: 47242
diff changeset
    25
    apply (simp add: exp_ge_add_one_self_aux)
a7f85074c169 tuned proofs
huffman
parents: 47242
diff changeset
    26
    apply (simp add: a)
a7f85074c169 tuned proofs
huffman
parents: 47242
diff changeset
    27
    apply (simp add: mult_pos_pos add_pos_nonneg)
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    28
    done
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    29
  also from a have "... <= 1 + x"
44289
d81d09cdab9c optimize some proofs
huffman
parents: 43336
diff changeset
    30
    by (simp add: field_simps add_strict_increasing zero_le_mult_iff)
47244
a7f85074c169 tuned proofs
huffman
parents: 47242
diff changeset
    31
  finally have "exp (x - x^2) <= 1 + x" .
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    32
  also have "... = exp (ln (1 + x))"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    33
  proof -
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    34
    from a have "0 < 1 + x" by auto
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    35
    thus ?thesis
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    36
      by (auto simp only: exp_ln_iff [THEN sym])
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    37
  qed
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    38
  finally have "exp (x - x ^ 2) <= exp (ln (1 + x))" .
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    39
  thus ?thesis by (auto simp only: exp_le_cancel_iff)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    40
qed
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    41
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    42
lemma aux5: "x < 1 ==> ln(1 - x) = - ln(1 + x / (1 - x))"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    43
proof -
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    44
  assume a: "x < 1"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    45
  have "ln(1 - x) = - ln(1 / (1 - x))"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    46
  proof -
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    47
    have "ln(1 - x) = - (- ln (1 - x))"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    48
      by auto
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    49
    also have "- ln(1 - x) = ln 1 - ln(1 - x)"
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
    also have "... = ln(1 / (1 - x))"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    52
      apply (rule ln_div [THEN sym])
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    53
      by (insert a, auto)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    54
    finally show ?thesis .
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    55
  qed
23482
2f4be6844f7c tuned and used field_simps
nipkow
parents: 23477
diff changeset
    56
  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
    57
  finally show ?thesis .
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    58
qed
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    59
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    60
lemma ln_one_minus_pos_lower_bound: "0 <= x ==> x <= (1 / 2) ==> 
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    61
    - x - 2 * x^2 <= ln (1 - x)"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    62
proof -
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    63
  assume a: "0 <= x" and b: "x <= (1 / 2)"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    64
  from b have c: "x < 1"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    65
    by auto
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    66
  then have "ln (1 - x) = - ln (1 + x / (1 - x))"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    67
    by (rule aux5)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    68
  also have "- (x / (1 - x)) <= ..."
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    69
  proof - 
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    70
    have "ln (1 + x / (1 - x)) <= x / (1 - x)"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    71
      apply (rule ln_add_one_self_le_self)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    72
      apply (rule divide_nonneg_pos)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    73
      by (insert a c, auto) 
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    74
    thus ?thesis
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    75
      by auto
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    76
  qed
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    77
  also have "- (x / (1 - x)) = -x / (1 - x)"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    78
    by auto
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    79
  finally have d: "- x / (1 - x) <= ln (1 - x)" .
41550
efa734d9b221 eliminated global prems;
wenzelm
parents: 40864
diff changeset
    80
  have "0 < 1 - x" using a b by simp
23482
2f4be6844f7c tuned and used field_simps
nipkow
parents: 23477
diff changeset
    81
  hence e: "-x - 2 * x^2 <= - x / (1 - x)"
41550
efa734d9b221 eliminated global prems;
wenzelm
parents: 40864
diff changeset
    82
    using mult_right_le_one_le[of "x*x" "2*x"] a b
efa734d9b221 eliminated global prems;
wenzelm
parents: 40864
diff changeset
    83
    by (simp add:field_simps power2_eq_square)
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    84
  from e d show "- x - 2 * x^2 <= ln (1 - x)"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    85
    by (rule order_trans)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    86
qed
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    87
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    88
lemma ln_add_one_self_le_self2: "-1 < x ==> ln(1 + x) <= x"
47244
a7f85074c169 tuned proofs
huffman
parents: 47242
diff changeset
    89
  apply (subgoal_tac "ln (1 + x) \<le> ln (exp x)", simp)
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    90
  apply (subst ln_le_cancel_iff)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    91
  apply auto
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    92
done
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    93
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    94
lemma abs_ln_one_plus_x_minus_x_bound_nonneg:
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    95
    "0 <= x ==> x <= 1 ==> abs(ln (1 + x) - x) <= x^2"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    96
proof -
23441
ee218296d635 avoid using implicit prems in assumption
huffman
parents: 23114
diff changeset
    97
  assume x: "0 <= x"
41550
efa734d9b221 eliminated global prems;
wenzelm
parents: 40864
diff changeset
    98
  assume x1: "x <= 1"
23441
ee218296d635 avoid using implicit prems in assumption
huffman
parents: 23114
diff changeset
    99
  from x have "ln (1 + x) <= x"
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   100
    by (rule ln_add_one_self_le_self)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   101
  then have "ln (1 + x) - x <= 0" 
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   102
    by simp
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   103
  then have "abs(ln(1 + x) - x) = - (ln(1 + x) - x)"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   104
    by (rule abs_of_nonpos)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   105
  also have "... = x - ln (1 + x)" 
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   106
    by simp
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   107
  also have "... <= x^2"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   108
  proof -
41550
efa734d9b221 eliminated global prems;
wenzelm
parents: 40864
diff changeset
   109
    from x x1 have "x - x^2 <= ln (1 + x)"
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   110
      by (intro ln_one_plus_pos_lower_bound)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   111
    thus ?thesis
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   112
      by simp
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   113
  qed
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   114
  finally show ?thesis .
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   115
qed
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   116
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   117
lemma abs_ln_one_plus_x_minus_x_bound_nonpos:
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   118
    "-(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
   119
proof -
41550
efa734d9b221 eliminated global prems;
wenzelm
parents: 40864
diff changeset
   120
  assume a: "-(1 / 2) <= x"
efa734d9b221 eliminated global prems;
wenzelm
parents: 40864
diff changeset
   121
  assume b: "x <= 0"
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   122
  have "abs(ln (1 + x) - x) = x - ln(1 - (-x))" 
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   123
    apply (subst abs_of_nonpos)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   124
    apply simp
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   125
    apply (rule ln_add_one_self_le_self2)
41550
efa734d9b221 eliminated global prems;
wenzelm
parents: 40864
diff changeset
   126
    using a apply auto
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   127
    done
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   128
  also have "... <= 2 * x^2"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   129
    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
   130
    apply (simp add: algebra_simps)
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   131
    apply (rule ln_one_minus_pos_lower_bound)
41550
efa734d9b221 eliminated global prems;
wenzelm
parents: 40864
diff changeset
   132
    using a b apply auto
29667
53103fc8ffa3 Replaced group_ and ring_simps by algebra_simps;
nipkow
parents: 28952
diff changeset
   133
    done
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   134
  finally show ?thesis .
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
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   137
lemma abs_ln_one_plus_x_minus_x_bound:
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   138
    "abs x <= 1 / 2 ==> abs(ln (1 + x) - x) <= 2 * x^2"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   139
  apply (case_tac "0 <= x")
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   140
  apply (rule order_trans)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   141
  apply (rule abs_ln_one_plus_x_minus_x_bound_nonneg)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   142
  apply auto
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   143
  apply (rule abs_ln_one_plus_x_minus_x_bound_nonpos)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   144
  apply auto
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   145
done
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   146
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   147
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
   148
proof -
41550
efa734d9b221 eliminated global prems;
wenzelm
parents: 40864
diff changeset
   149
  assume x: "exp 1 <= x" "x <= y"
44289
d81d09cdab9c optimize some proofs
huffman
parents: 43336
diff changeset
   150
  moreover have "0 < exp (1::real)" by simp
d81d09cdab9c optimize some proofs
huffman
parents: 43336
diff changeset
   151
  ultimately have a: "0 < x" and b: "0 < y"
d81d09cdab9c optimize some proofs
huffman
parents: 43336
diff changeset
   152
    by (fast intro: less_le_trans order_trans)+
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   153
  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
   154
    by (simp add: algebra_simps)
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   155
  also have "... = x * ln(y / x)"
44289
d81d09cdab9c optimize some proofs
huffman
parents: 43336
diff changeset
   156
    by (simp only: ln_div a b)
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   157
  also have "y / x = (x + (y - x)) / x"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   158
    by simp
44289
d81d09cdab9c optimize some proofs
huffman
parents: 43336
diff changeset
   159
  also have "... = 1 + (y - x) / x"
d81d09cdab9c optimize some proofs
huffman
parents: 43336
diff changeset
   160
    using x a by (simp add: field_simps)
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   161
  also have "x * ln(1 + (y - x) / x) <= x * ((y - x) / x)"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   162
    apply (rule mult_left_mono)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   163
    apply (rule ln_add_one_self_le_self)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   164
    apply (rule divide_nonneg_pos)
41550
efa734d9b221 eliminated global prems;
wenzelm
parents: 40864
diff changeset
   165
    using x a apply simp_all
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   166
    done
23482
2f4be6844f7c tuned and used field_simps
nipkow
parents: 23477
diff changeset
   167
  also have "... = y - x" using a by simp
2f4be6844f7c tuned and used field_simps
nipkow
parents: 23477
diff changeset
   168
  also have "... = (y - x) * ln (exp 1)" by simp
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   169
  also have "... <= (y - x) * ln x"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   170
    apply (rule mult_left_mono)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   171
    apply (subst ln_le_cancel_iff)
44289
d81d09cdab9c optimize some proofs
huffman
parents: 43336
diff changeset
   172
    apply fact
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   173
    apply (rule a)
41550
efa734d9b221 eliminated global prems;
wenzelm
parents: 40864
diff changeset
   174
    apply (rule x)
efa734d9b221 eliminated global prems;
wenzelm
parents: 40864
diff changeset
   175
    using x apply simp
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   176
    done
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   177
  also have "... = y * ln x - x * ln x"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   178
    by (rule left_diff_distrib)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   179
  finally have "x * ln y <= y * ln x"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   180
    by arith
41550
efa734d9b221 eliminated global prems;
wenzelm
parents: 40864
diff changeset
   181
  then have "ln y <= (y * ln x) / x" using a by (simp add: field_simps)
efa734d9b221 eliminated global prems;
wenzelm
parents: 40864
diff changeset
   182
  also have "... = y * (ln x / x)" by simp
efa734d9b221 eliminated global prems;
wenzelm
parents: 40864
diff changeset
   183
  finally show ?thesis using b by (simp add: field_simps)
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   184
qed
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   185
43336
05aa7380f7fc lemmas relating ln x and x - 1
hoelzl
parents: 41959
diff changeset
   186
lemma ln_le_minus_one:
05aa7380f7fc lemmas relating ln x and x - 1
hoelzl
parents: 41959
diff changeset
   187
  "0 < x \<Longrightarrow> ln x \<le> x - 1"
05aa7380f7fc lemmas relating ln x and x - 1
hoelzl
parents: 41959
diff changeset
   188
  using exp_ge_add_one_self[of "ln x"] by simp
05aa7380f7fc lemmas relating ln x and x - 1
hoelzl
parents: 41959
diff changeset
   189
05aa7380f7fc lemmas relating ln x and x - 1
hoelzl
parents: 41959
diff changeset
   190
lemma ln_eq_minus_one:
05aa7380f7fc lemmas relating ln x and x - 1
hoelzl
parents: 41959
diff changeset
   191
  assumes "0 < x" "ln x = x - 1" shows "x = 1"
05aa7380f7fc lemmas relating ln x and x - 1
hoelzl
parents: 41959
diff changeset
   192
proof -
05aa7380f7fc lemmas relating ln x and x - 1
hoelzl
parents: 41959
diff changeset
   193
  let "?l y" = "ln y - y + 1"
05aa7380f7fc lemmas relating ln x and x - 1
hoelzl
parents: 41959
diff changeset
   194
  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
   195
    by (auto intro!: DERIV_intros)
05aa7380f7fc lemmas relating ln x and x - 1
hoelzl
parents: 41959
diff changeset
   196
05aa7380f7fc lemmas relating ln x and x - 1
hoelzl
parents: 41959
diff changeset
   197
  show ?thesis
05aa7380f7fc lemmas relating ln x and x - 1
hoelzl
parents: 41959
diff changeset
   198
  proof (cases rule: linorder_cases)
05aa7380f7fc lemmas relating ln x and x - 1
hoelzl
parents: 41959
diff changeset
   199
    assume "x < 1"
05aa7380f7fc lemmas relating ln x and x - 1
hoelzl
parents: 41959
diff changeset
   200
    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
   201
    from `x < a` have "?l x < ?l a"
05aa7380f7fc lemmas relating ln x and x - 1
hoelzl
parents: 41959
diff changeset
   202
    proof (rule DERIV_pos_imp_increasing, safe)
05aa7380f7fc lemmas relating ln x and x - 1
hoelzl
parents: 41959
diff changeset
   203
      fix y assume "x \<le> y" "y \<le> a"
05aa7380f7fc lemmas relating ln x and x - 1
hoelzl
parents: 41959
diff changeset
   204
      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
   205
        by (auto simp: field_simps)
05aa7380f7fc lemmas relating ln x and x - 1
hoelzl
parents: 41959
diff changeset
   206
      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
   207
        by auto
05aa7380f7fc lemmas relating ln x and x - 1
hoelzl
parents: 41959
diff changeset
   208
    qed
05aa7380f7fc lemmas relating ln x and x - 1
hoelzl
parents: 41959
diff changeset
   209
    also have "\<dots> \<le> 0"
05aa7380f7fc lemmas relating ln x and x - 1
hoelzl
parents: 41959
diff changeset
   210
      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
   211
    finally show "x = 1" using assms by auto
05aa7380f7fc lemmas relating ln x and x - 1
hoelzl
parents: 41959
diff changeset
   212
  next
05aa7380f7fc lemmas relating ln x and x - 1
hoelzl
parents: 41959
diff changeset
   213
    assume "1 < x"
05aa7380f7fc lemmas relating ln x and x - 1
hoelzl
parents: 41959
diff changeset
   214
    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
   215
    from `a < x` have "?l x < ?l a"
05aa7380f7fc lemmas relating ln x and x - 1
hoelzl
parents: 41959
diff changeset
   216
    proof (rule DERIV_neg_imp_decreasing, safe)
05aa7380f7fc lemmas relating ln x and x - 1
hoelzl
parents: 41959
diff changeset
   217
      fix y assume "a \<le> y" "y \<le> x"
05aa7380f7fc lemmas relating ln x and x - 1
hoelzl
parents: 41959
diff changeset
   218
      with `1 < a` have "1 / y - 1 < 0" "0 < y"
05aa7380f7fc lemmas relating ln x and x - 1
hoelzl
parents: 41959
diff changeset
   219
        by (auto simp: field_simps)
05aa7380f7fc lemmas relating ln x and x - 1
hoelzl
parents: 41959
diff changeset
   220
      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
   221
        by blast
05aa7380f7fc lemmas relating ln x and x - 1
hoelzl
parents: 41959
diff changeset
   222
    qed
05aa7380f7fc lemmas relating ln x and x - 1
hoelzl
parents: 41959
diff changeset
   223
    also have "\<dots> \<le> 0"
05aa7380f7fc lemmas relating ln x and x - 1
hoelzl
parents: 41959
diff changeset
   224
      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
   225
    finally show "x = 1" using assms by auto
05aa7380f7fc lemmas relating ln x and x - 1
hoelzl
parents: 41959
diff changeset
   226
  qed simp
05aa7380f7fc lemmas relating ln x and x - 1
hoelzl
parents: 41959
diff changeset
   227
qed
05aa7380f7fc lemmas relating ln x and x - 1
hoelzl
parents: 41959
diff changeset
   228
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   229
end