src/HOL/Hyperreal/Ln.thy
author nipkow
Sun, 24 Jun 2007 20:55:41 +0200
changeset 23482 2f4be6844f7c
parent 23477 f4b83f03cac9
child 25875 536dfdc25e0a
permissions -rwxr-xr-x
tuned and used field_simps
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
16963
32626fb8ae49 addedd ID line
nipkow
parents: 16959
diff changeset
     3
    ID:         $Id$
16959
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
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
     6
header {* Properties of ln *}
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
     7
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
     8
theory Ln
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
     9
imports Transcendental
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    10
begin
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    11
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    12
lemma exp_first_two_terms: "exp x = 1 + x + suminf (%n. 
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    13
  inverse(real (fact (n+2))) * (x ^ (n+2)))"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    14
proof -
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    15
  have "exp x = suminf (%n. inverse(real (fact n)) * (x ^ n))"
19765
dfe940911617 misc cleanup;
wenzelm
parents: 17013
diff changeset
    16
    by (simp add: exp_def)
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    17
  also from summable_exp have "... = (SUM n : {0..<2}. 
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    18
      inverse(real (fact n)) * (x ^ n)) + suminf (%n.
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    19
      inverse(real (fact (n+2))) * (x ^ (n+2)))" (is "_ = ?a + _")
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    20
    by (rule suminf_split_initial_segment)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    21
  also have "?a = 1 + x"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    22
    by (simp add: numerals)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    23
  finally show ?thesis .
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    24
qed
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    25
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    26
lemma exp_tail_after_first_two_terms_summable: 
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    27
  "summable (%n. inverse(real (fact (n+2))) * (x ^ (n+2)))"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    28
proof -
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    29
  note summable_exp
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    30
  thus ?thesis
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    31
    by (frule summable_ignore_initial_segment)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    32
qed
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    33
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    34
lemma aux1: assumes a: "0 <= x" and b: "x <= 1"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    35
    shows "inverse (real (fact (n + 2))) * x ^ (n + 2) <= (x^2/2) * ((1/2)^n)"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    36
proof (induct n)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    37
  show "inverse (real (fact (0 + 2))) * x ^ (0 + 2) <= 
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    38
      x ^ 2 / 2 * (1 / 2) ^ 0"
23482
2f4be6844f7c tuned and used field_simps
nipkow
parents: 23477
diff changeset
    39
    by (simp add: real_of_nat_Suc power2_eq_square)
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    40
next
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    41
  fix n
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    42
  assume c: "inverse (real (fact (n + 2))) * x ^ (n + 2)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    43
       <= x ^ 2 / 2 * (1 / 2) ^ n"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    44
  show "inverse (real (fact (Suc n + 2))) * x ^ (Suc n + 2)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    45
           <= x ^ 2 / 2 * (1 / 2) ^ Suc n"
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 "inverse(real (fact (Suc n + 2))) <= 
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    48
        (1 / 2) *inverse (real (fact (n+2)))"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    49
    proof -
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    50
      have "Suc n + 2 = Suc (n + 2)" by simp
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    51
      then have "fact (Suc n + 2) = Suc (n + 2) * fact (n + 2)" 
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    52
        by simp
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    53
      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
    54
        apply (rule subst)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    55
        apply (rule refl)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    56
        done
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    57
      also have "... = real(Suc (n + 2)) * real(fact (n + 2))"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    58
        by (rule real_of_nat_mult)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    59
      finally have "real (fact (Suc n + 2)) = 
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    60
         real (Suc (n + 2)) * real (fact (n + 2))" .
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    61
      then have "inverse(real (fact (Suc n + 2))) = 
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    62
         inverse(real (Suc (n + 2))) * inverse(real (fact (n + 2)))"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    63
        apply (rule ssubst)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    64
        apply (rule inverse_mult_distrib)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    65
        done
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    66
      also have "... <= (1/2) * inverse(real (fact (n + 2)))"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    67
        apply (rule mult_right_mono)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    68
        apply (subst inverse_eq_divide)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    69
        apply simp
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    70
        apply (rule inv_real_of_nat_fact_ge_zero)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    71
        done
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    72
      finally show ?thesis .
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    73
    qed
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    74
    moreover have "x ^ (Suc n + 2) <= x ^ (n + 2)"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    75
      apply (simp add: mult_compare_simps)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    76
      apply (simp add: prems)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    77
      apply (subgoal_tac "0 <= x * (x * x^n)")
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    78
      apply force
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    79
      apply (rule mult_nonneg_nonneg, rule a)+
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    80
      apply (rule zero_le_power, rule a)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    81
      done
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    82
    ultimately have "inverse (real (fact (Suc n + 2))) *  x ^ (Suc n + 2) <=
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    83
        (1 / 2 * inverse (real (fact (n + 2)))) * x ^ (n + 2)"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    84
      apply (rule mult_mono)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    85
      apply (rule mult_nonneg_nonneg)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    86
      apply simp
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    87
      apply (subst inverse_nonnegative_iff_nonnegative)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    88
      apply (rule real_of_nat_fact_ge_zero)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    89
      apply (rule zero_le_power)
23441
ee218296d635 avoid using implicit prems in assumption
huffman
parents: 23114
diff changeset
    90
      apply (rule a)
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    91
      done
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    92
    also have "... = 1 / 2 * (inverse (real (fact (n + 2))) * x ^ (n + 2))"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    93
      by simp
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    94
    also have "... <= 1 / 2 * (x ^ 2 / 2 * (1 / 2) ^ n)"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    95
      apply (rule mult_left_mono)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    96
      apply (rule prems)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    97
      apply simp
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    98
      done
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
    99
    also have "... = x ^ 2 / 2 * (1 / 2 * (1 / 2) ^ n)"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   100
      by auto
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   101
    also have "(1::real) / 2 * (1 / 2) ^ n = (1 / 2) ^ (Suc n)"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   102
      by (rule realpow_Suc [THEN sym])
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   103
    finally show ?thesis .
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   104
  qed
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   105
qed
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   106
20692
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20563
diff changeset
   107
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
   108
proof -
20692
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20563
diff changeset
   109
  have "(%n. (1 / 2::real)^n) sums (1 / (1 - (1/2)))"
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   110
    apply (rule geometric_sums)
22998
97e1f9c2cc46 avoid using redundant lemmas from RealDef.thy
huffman
parents: 22654
diff changeset
   111
    by (simp add: abs_less_iff)
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   112
  also have "(1::real) / (1 - 1/2) = 2"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   113
    by simp
20692
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20563
diff changeset
   114
  finally have "(%n. (1 / 2::real)^n) sums 2" .
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   115
  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
   116
    by (rule sums_mult)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   117
  also have "x^2 / 2 * 2 = x^2"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   118
    by simp
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   119
  finally show ?thesis .
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   120
qed
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   121
23114
1bd84606b403 add type annotations for exp
huffman
parents: 22998
diff changeset
   122
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
   123
proof -
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   124
  assume a: "0 <= x"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   125
  assume b: "x <= 1"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   126
  have c: "exp x = 1 + x + suminf (%n. inverse(real (fact (n+2))) * 
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   127
      (x ^ (n+2)))"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   128
    by (rule exp_first_two_terms)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   129
  moreover have "suminf (%n. inverse(real (fact (n+2))) * (x ^ (n+2))) <= x^2"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   130
  proof -
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   131
    have "suminf (%n. inverse(real (fact (n+2))) * (x ^ (n+2))) <=
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   132
        suminf (%n. (x^2/2) * ((1/2)^n))"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   133
      apply (rule summable_le)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   134
      apply (auto simp only: aux1 prems)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   135
      apply (rule exp_tail_after_first_two_terms_summable)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   136
      by (rule sums_summable, rule aux2)  
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   137
    also have "... = x^2"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   138
      by (rule sums_unique [THEN sym], rule aux2)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   139
    finally show ?thesis .
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   140
  qed
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   141
  ultimately show ?thesis
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   142
    by auto
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   143
qed
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   144
23114
1bd84606b403 add type annotations for exp
huffman
parents: 22998
diff changeset
   145
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
   146
proof -
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   147
  assume a: "0 <= x" and b: "x <= 1"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   148
  have "exp (x - x^2) = exp x / exp (x^2)"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   149
    by (rule exp_diff)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   150
  also have "... <= (1 + x + x^2) / exp (x ^2)"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   151
    apply (rule divide_right_mono) 
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   152
    apply (rule exp_bound)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   153
    apply (rule a, rule b)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   154
    apply simp
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   155
    done
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   156
  also have "... <= (1 + x + x^2) / (1 + x^2)"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   157
    apply (rule divide_left_mono)
17013
74bc935273ea renamed exp_ge_add_one_self2 to exp_ge_add_one_self
avigad
parents: 16963
diff changeset
   158
    apply (auto simp add: exp_ge_add_one_self_aux)
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   159
    apply (rule add_nonneg_nonneg)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   160
    apply (insert prems, auto)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   161
    apply (rule mult_pos_pos)
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
    apply (rule add_pos_nonneg)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   164
    apply auto
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   165
    done
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   166
  also from a have "... <= 1 + x"
23482
2f4be6844f7c tuned and used field_simps
nipkow
parents: 23477
diff changeset
   167
    by(simp add:field_simps zero_compare_simps)
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   168
  finally show ?thesis .
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   169
qed
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   170
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   171
lemma ln_one_plus_pos_lower_bound: "0 <= x ==> x <= 1 ==> 
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   172
    x - x^2 <= ln (1 + x)"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   173
proof -
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   174
  assume a: "0 <= x" and b: "x <= 1"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   175
  then have "exp (x - x^2) <= 1 + x"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   176
    by (rule aux4)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   177
  also have "... = exp (ln (1 + x))"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   178
  proof -
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   179
    from a have "0 < 1 + x" by auto
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   180
    thus ?thesis
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   181
      by (auto simp only: exp_ln_iff [THEN sym])
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   182
  qed
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   183
  finally have "exp (x - x ^ 2) <= exp (ln (1 + x))" .
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   184
  thus ?thesis by (auto simp only: exp_le_cancel_iff)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   185
qed
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   186
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   187
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
   188
proof -
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   189
  assume a: "0 <= (x::real)" and b: "x < 1"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   190
  have "(1 - x) * (1 + x + x^2) = (1 - x^3)"
23477
f4b83f03cac9 tuned and renamed group_eq_simps and ring_eq_simps
nipkow
parents: 23441
diff changeset
   191
    by (simp add: ring_simps power2_eq_square power3_eq_cube)
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   192
  also have "... <= 1"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   193
    by (auto intro: zero_le_power simp add: a)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   194
  finally have "(1 - x) * (1 + x + x ^ 2) <= 1" .
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   195
  moreover have "0 < 1 + x + x^2"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   196
    apply (rule add_pos_nonneg)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   197
    apply (insert a, auto)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   198
    done
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   199
  ultimately have "1 - x <= 1 / (1 + x + x^2)"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   200
    by (elim mult_imp_le_div_pos)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   201
  also have "... <= 1 / exp x"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   202
    apply (rule divide_left_mono)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   203
    apply (rule exp_bound, rule a)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   204
    apply (insert prems, auto)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   205
    apply (rule mult_pos_pos)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   206
    apply (rule add_pos_nonneg)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   207
    apply auto
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   208
    done
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   209
  also have "... = exp (-x)"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   210
    by (auto simp add: exp_minus real_divide_def)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   211
  finally have "1 - x <= exp (- x)" .
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   212
  also have "1 - x = exp (ln (1 - x))"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   213
  proof -
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   214
    have "0 < 1 - x"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   215
      by (insert b, auto)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   216
    thus ?thesis
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   217
      by (auto simp only: exp_ln_iff [THEN sym])
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   218
  qed
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   219
  finally have "exp (ln (1 - x)) <= exp (- x)" .
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   220
  thus ?thesis by (auto simp only: exp_le_cancel_iff)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   221
qed
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   222
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   223
lemma aux5: "x < 1 ==> ln(1 - x) = - ln(1 + x / (1 - x))"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   224
proof -
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   225
  assume a: "x < 1"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   226
  have "ln(1 - x) = - ln(1 / (1 - x))"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   227
  proof -
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   228
    have "ln(1 - x) = - (- ln (1 - x))"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   229
      by auto
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   230
    also have "- ln(1 - x) = ln 1 - ln(1 - x)"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   231
      by simp
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   232
    also have "... = ln(1 / (1 - x))"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   233
      apply (rule ln_div [THEN sym])
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   234
      by (insert a, auto)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   235
    finally show ?thesis .
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   236
  qed
23482
2f4be6844f7c tuned and used field_simps
nipkow
parents: 23477
diff changeset
   237
  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
   238
  finally show ?thesis .
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   239
qed
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   240
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   241
lemma ln_one_minus_pos_lower_bound: "0 <= x ==> x <= (1 / 2) ==> 
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   242
    - x - 2 * x^2 <= ln (1 - x)"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   243
proof -
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   244
  assume a: "0 <= x" and b: "x <= (1 / 2)"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   245
  from b have c: "x < 1"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   246
    by auto
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   247
  then have "ln (1 - x) = - ln (1 + x / (1 - x))"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   248
    by (rule aux5)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   249
  also have "- (x / (1 - x)) <= ..."
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   250
  proof - 
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   251
    have "ln (1 + x / (1 - x)) <= x / (1 - x)"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   252
      apply (rule ln_add_one_self_le_self)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   253
      apply (rule divide_nonneg_pos)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   254
      by (insert a c, auto) 
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   255
    thus ?thesis
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   256
      by auto
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   257
  qed
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   258
  also have "- (x / (1 - x)) = -x / (1 - x)"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   259
    by auto
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   260
  finally have d: "- x / (1 - x) <= ln (1 - x)" .
23482
2f4be6844f7c tuned and used field_simps
nipkow
parents: 23477
diff changeset
   261
  have "0 < 1 - x" using prems by simp
2f4be6844f7c tuned and used field_simps
nipkow
parents: 23477
diff changeset
   262
  hence e: "-x - 2 * x^2 <= - x / (1 - x)"
2f4be6844f7c tuned and used field_simps
nipkow
parents: 23477
diff changeset
   263
    using mult_right_le_one_le[of "x*x" "2*x"] prems
2f4be6844f7c tuned and used field_simps
nipkow
parents: 23477
diff changeset
   264
    by(simp add:field_simps power2_eq_square)
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   265
  from e d show "- x - 2 * x^2 <= ln (1 - x)"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   266
    by (rule order_trans)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   267
qed
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   268
23114
1bd84606b403 add type annotations for exp
huffman
parents: 22998
diff changeset
   269
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
   270
  apply (case_tac "0 <= x")
17013
74bc935273ea renamed exp_ge_add_one_self2 to exp_ge_add_one_self
avigad
parents: 16963
diff changeset
   271
  apply (erule exp_ge_add_one_self_aux)
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   272
  apply (case_tac "x <= -1")
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   273
  apply (subgoal_tac "1 + x <= 0")
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   274
  apply (erule order_trans)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   275
  apply simp
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   276
  apply simp
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   277
  apply (subgoal_tac "1 + x = exp(ln (1 + x))")
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   278
  apply (erule ssubst)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   279
  apply (subst exp_le_cancel_iff)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   280
  apply (subgoal_tac "ln (1 - (- x)) <= - (- x)")
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   281
  apply simp
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   282
  apply (rule ln_one_minus_pos_upper_bound) 
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   283
  apply auto
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   284
done
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   285
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   286
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
   287
  apply (subgoal_tac "x = ln (exp x)")
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   288
  apply (erule ssubst)back
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   289
  apply (subst ln_le_cancel_iff)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   290
  apply auto
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   291
done
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   292
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   293
lemma abs_ln_one_plus_x_minus_x_bound_nonneg:
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   294
    "0 <= x ==> x <= 1 ==> abs(ln (1 + x) - x) <= x^2"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   295
proof -
23441
ee218296d635 avoid using implicit prems in assumption
huffman
parents: 23114
diff changeset
   296
  assume x: "0 <= x"
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   297
  assume "x <= 1"
23441
ee218296d635 avoid using implicit prems in assumption
huffman
parents: 23114
diff changeset
   298
  from x have "ln (1 + x) <= x"
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   299
    by (rule ln_add_one_self_le_self)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   300
  then have "ln (1 + x) - x <= 0" 
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   301
    by simp
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   302
  then have "abs(ln(1 + x) - x) = - (ln(1 + x) - x)"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   303
    by (rule abs_of_nonpos)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   304
  also have "... = x - ln (1 + x)" 
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   305
    by simp
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   306
  also have "... <= x^2"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   307
  proof -
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   308
    from prems have "x - x^2 <= ln (1 + x)"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   309
      by (intro ln_one_plus_pos_lower_bound)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   310
    thus ?thesis
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   311
      by simp
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
  finally show ?thesis .
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   314
qed
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   315
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   316
lemma abs_ln_one_plus_x_minus_x_bound_nonpos:
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   317
    "-(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
   318
proof -
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   319
  assume "-(1 / 2) <= x"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   320
  assume "x <= 0"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   321
  have "abs(ln (1 + x) - x) = x - ln(1 - (-x))" 
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   322
    apply (subst abs_of_nonpos)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   323
    apply simp
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   324
    apply (rule ln_add_one_self_le_self2)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   325
    apply (insert prems, auto)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   326
    done
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   327
  also have "... <= 2 * x^2"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   328
    apply (subgoal_tac "- (-x) - 2 * (-x)^2 <= ln (1 - (-x))")
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   329
    apply (simp add: compare_rls)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   330
    apply (rule ln_one_minus_pos_lower_bound)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   331
    apply (insert prems, auto)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   332
    done 
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   333
  finally show ?thesis .
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   334
qed
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   335
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   336
lemma abs_ln_one_plus_x_minus_x_bound:
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   337
    "abs x <= 1 / 2 ==> abs(ln (1 + x) - x) <= 2 * x^2"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   338
  apply (case_tac "0 <= x")
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   339
  apply (rule order_trans)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   340
  apply (rule abs_ln_one_plus_x_minus_x_bound_nonneg)
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
  apply (rule abs_ln_one_plus_x_minus_x_bound_nonpos)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   343
  apply auto
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   344
done
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   345
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   346
lemma DERIV_ln: "0 < x ==> DERIV ln x :> 1 / x"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   347
  apply (unfold deriv_def, unfold LIM_def, clarsimp)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   348
  apply (rule exI)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   349
  apply (rule conjI)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   350
  prefer 2
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   351
  apply clarsimp
20563
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20432
diff changeset
   352
  apply (subgoal_tac "(ln (x + xa) - ln x) / xa - (1 / x) = 
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   353
      (ln (1 + xa / x) - xa / x) / xa")
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   354
  apply (erule ssubst)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   355
  apply (subst abs_divide)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   356
  apply (rule mult_imp_div_pos_less)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   357
  apply force
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   358
  apply (rule order_le_less_trans)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   359
  apply (rule abs_ln_one_plus_x_minus_x_bound)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   360
  apply (subst abs_divide)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   361
  apply (subst abs_of_pos, assumption)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   362
  apply (erule mult_imp_div_pos_le)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   363
  apply (subgoal_tac "abs xa < min (x / 2) (r * x^2 / 2)")
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   364
  apply force
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   365
  apply assumption
20432
07ec57376051 lin_arith_prover: splitting reverted because of performance loss
webertj
parents: 20256
diff changeset
   366
  apply (simp add: power2_eq_square mult_compare_simps)
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   367
  apply (rule mult_imp_div_pos_less)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   368
  apply (rule mult_pos_pos, assumption, assumption)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   369
  apply (subgoal_tac "xa * xa = abs xa * abs xa")
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   370
  apply (erule ssubst)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   371
  apply (subgoal_tac "abs xa * (abs xa * 2) < abs xa * (r * (x * x))")
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   372
  apply (simp only: mult_ac)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   373
  apply (rule mult_strict_left_mono)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   374
  apply (erule conjE, assumption)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   375
  apply force
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   376
  apply simp
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   377
  apply (subst ln_div [THEN sym])
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   378
  apply arith
23477
f4b83f03cac9 tuned and renamed group_eq_simps and ring_eq_simps
nipkow
parents: 23441
diff changeset
   379
  apply (auto simp add: ring_simps add_frac_eq frac_eq_eq 
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   380
    add_divide_distrib power2_eq_square)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   381
  apply (rule mult_pos_pos, assumption)+
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   382
  apply assumption
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   383
done
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   384
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   385
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
   386
proof -
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   387
  assume "exp 1 <= x" and "x <= y"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   388
  have a: "0 < x" and b: "0 < y"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   389
    apply (insert prems)
23114
1bd84606b403 add type annotations for exp
huffman
parents: 22998
diff changeset
   390
    apply (subgoal_tac "0 < exp (1::real)")
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   391
    apply arith
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   392
    apply auto
23114
1bd84606b403 add type annotations for exp
huffman
parents: 22998
diff changeset
   393
    apply (subgoal_tac "0 < exp (1::real)")
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   394
    apply arith
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   395
    apply auto
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   396
    done
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   397
  have "x * ln y - x * ln x = x * (ln y - ln x)"
23477
f4b83f03cac9 tuned and renamed group_eq_simps and ring_eq_simps
nipkow
parents: 23441
diff changeset
   398
    by (simp add: ring_simps)
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   399
  also have "... = x * ln(y / x)"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   400
    apply (subst ln_div)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   401
    apply (rule b, rule a, rule refl)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   402
    done
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   403
  also have "y / x = (x + (y - x)) / x"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   404
    by simp
23482
2f4be6844f7c tuned and used field_simps
nipkow
parents: 23477
diff changeset
   405
  also have "... = 1 + (y - x) / x" using a prems by(simp add:field_simps)
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   406
  also have "x * ln(1 + (y - x) / x) <= x * ((y - x) / x)"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   407
    apply (rule mult_left_mono)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   408
    apply (rule ln_add_one_self_le_self)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   409
    apply (rule divide_nonneg_pos)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   410
    apply (insert prems a, simp_all) 
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   411
    done
23482
2f4be6844f7c tuned and used field_simps
nipkow
parents: 23477
diff changeset
   412
  also have "... = y - x" using a by simp
2f4be6844f7c tuned and used field_simps
nipkow
parents: 23477
diff changeset
   413
  also have "... = (y - x) * ln (exp 1)" by simp
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   414
  also have "... <= (y - x) * ln x"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   415
    apply (rule mult_left_mono)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   416
    apply (subst ln_le_cancel_iff)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   417
    apply force
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   418
    apply (rule a)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   419
    apply (rule prems)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   420
    apply (insert prems, simp)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   421
    done
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   422
  also have "... = y * ln x - x * ln x"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   423
    by (rule left_diff_distrib)
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   424
  finally have "x * ln y <= y * ln x"
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   425
    by arith
23482
2f4be6844f7c tuned and used field_simps
nipkow
parents: 23477
diff changeset
   426
  then have "ln y <= (y * ln x) / x" using a by(simp add:field_simps)
2f4be6844f7c tuned and used field_simps
nipkow
parents: 23477
diff changeset
   427
  also have "... = y * (ln x / x)"  by simp
2f4be6844f7c tuned and used field_simps
nipkow
parents: 23477
diff changeset
   428
  finally show ?thesis using b by(simp add:field_simps)
16959
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   429
qed
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   430
17a0c4d79b4c added a new theory; properties of ln
avigad
parents:
diff changeset
   431
end