src/HOL/Log.thy
 author nipkow Fri Aug 28 18:52:41 2009 +0200 (2009-08-28) changeset 32436 10cd49e0c067 parent 31336 e17f13cd1280 child 33716 c7b42ad3fadf permissions -rw-r--r--
Turned "x <= y ==> sup x y = y" (and relatives) into simp rules
```     1 (*  Title       : Log.thy
```
```     2     Author      : Jacques D. Fleuriot
```
```     3                   Additional contributions by Jeremy Avigad
```
```     4     Copyright   : 2000,2001 University of Edinburgh
```
```     5 *)
```
```     6
```
```     7 header{*Logarithms: Standard Version*}
```
```     8
```
```     9 theory Log
```
```    10 imports Transcendental
```
```    11 begin
```
```    12
```
```    13 definition
```
```    14   powr  :: "[real,real] => real"     (infixr "powr" 80) where
```
```    15     --{*exponentation with real exponent*}
```
```    16   "x powr a = exp(a * ln x)"
```
```    17
```
```    18 definition
```
```    19   log :: "[real,real] => real" where
```
```    20     --{*logarithm of @{term x} to base @{term a}*}
```
```    21   "log a x = ln x / ln a"
```
```    22
```
```    23
```
```    24
```
```    25 lemma powr_one_eq_one [simp]: "1 powr a = 1"
```
```    26 by (simp add: powr_def)
```
```    27
```
```    28 lemma powr_zero_eq_one [simp]: "x powr 0 = 1"
```
```    29 by (simp add: powr_def)
```
```    30
```
```    31 lemma powr_one_gt_zero_iff [simp]: "(x powr 1 = x) = (0 < x)"
```
```    32 by (simp add: powr_def)
```
```    33 declare powr_one_gt_zero_iff [THEN iffD2, simp]
```
```    34
```
```    35 lemma powr_mult:
```
```    36       "[| 0 < x; 0 < y |] ==> (x * y) powr a = (x powr a) * (y powr a)"
```
```    37 by (simp add: powr_def exp_add [symmetric] ln_mult right_distrib)
```
```    38
```
```    39 lemma powr_gt_zero [simp]: "0 < x powr a"
```
```    40 by (simp add: powr_def)
```
```    41
```
```    42 lemma powr_ge_pzero [simp]: "0 <= x powr y"
```
```    43 by (rule order_less_imp_le, rule powr_gt_zero)
```
```    44
```
```    45 lemma powr_not_zero [simp]: "x powr a \<noteq> 0"
```
```    46 by (simp add: powr_def)
```
```    47
```
```    48 lemma powr_divide:
```
```    49      "[| 0 < x; 0 < y |] ==> (x / y) powr a = (x powr a)/(y powr a)"
```
```    50 apply (simp add: divide_inverse positive_imp_inverse_positive powr_mult)
```
```    51 apply (simp add: powr_def exp_minus [symmetric] exp_add [symmetric] ln_inverse)
```
```    52 done
```
```    53
```
```    54 lemma powr_divide2: "x powr a / x powr b = x powr (a - b)"
```
```    55   apply (simp add: powr_def)
```
```    56   apply (subst exp_diff [THEN sym])
```
```    57   apply (simp add: left_diff_distrib)
```
```    58 done
```
```    59
```
```    60 lemma powr_add: "x powr (a + b) = (x powr a) * (x powr b)"
```
```    61 by (simp add: powr_def exp_add [symmetric] left_distrib)
```
```    62
```
```    63 lemma powr_powr: "(x powr a) powr b = x powr (a * b)"
```
```    64 by (simp add: powr_def)
```
```    65
```
```    66 lemma powr_powr_swap: "(x powr a) powr b = (x powr b) powr a"
```
```    67 by (simp add: powr_powr real_mult_commute)
```
```    68
```
```    69 lemma powr_minus: "x powr (-a) = inverse (x powr a)"
```
```    70 by (simp add: powr_def exp_minus [symmetric])
```
```    71
```
```    72 lemma powr_minus_divide: "x powr (-a) = 1/(x powr a)"
```
```    73 by (simp add: divide_inverse powr_minus)
```
```    74
```
```    75 lemma powr_less_mono: "[| a < b; 1 < x |] ==> x powr a < x powr b"
```
```    76 by (simp add: powr_def)
```
```    77
```
```    78 lemma powr_less_cancel: "[| x powr a < x powr b; 1 < x |] ==> a < b"
```
```    79 by (simp add: powr_def)
```
```    80
```
```    81 lemma powr_less_cancel_iff [simp]: "1 < x ==> (x powr a < x powr b) = (a < b)"
```
```    82 by (blast intro: powr_less_cancel powr_less_mono)
```
```    83
```
```    84 lemma powr_le_cancel_iff [simp]: "1 < x ==> (x powr a \<le> x powr b) = (a \<le> b)"
```
```    85 by (simp add: linorder_not_less [symmetric])
```
```    86
```
```    87 lemma log_ln: "ln x = log (exp(1)) x"
```
```    88 by (simp add: log_def)
```
```    89
```
```    90 lemma powr_log_cancel [simp]:
```
```    91      "[| 0 < a; a \<noteq> 1; 0 < x |] ==> a powr (log a x) = x"
```
```    92 by (simp add: powr_def log_def)
```
```    93
```
```    94 lemma log_powr_cancel [simp]: "[| 0 < a; a \<noteq> 1 |] ==> log a (a powr y) = y"
```
```    95 by (simp add: log_def powr_def)
```
```    96
```
```    97 lemma log_mult:
```
```    98      "[| 0 < a; a \<noteq> 1; 0 < x; 0 < y |]
```
```    99       ==> log a (x * y) = log a x + log a y"
```
```   100 by (simp add: log_def ln_mult divide_inverse left_distrib)
```
```   101
```
```   102 lemma log_eq_div_ln_mult_log:
```
```   103      "[| 0 < a; a \<noteq> 1; 0 < b; b \<noteq> 1; 0 < x |]
```
```   104       ==> log a x = (ln b/ln a) * log b x"
```
```   105 by (simp add: log_def divide_inverse)
```
```   106
```
```   107 text{*Base 10 logarithms*}
```
```   108 lemma log_base_10_eq1: "0 < x ==> log 10 x = (ln (exp 1) / ln 10) * ln x"
```
```   109 by (simp add: log_def)
```
```   110
```
```   111 lemma log_base_10_eq2: "0 < x ==> log 10 x = (log 10 (exp 1)) * ln x"
```
```   112 by (simp add: log_def)
```
```   113
```
```   114 lemma log_one [simp]: "log a 1 = 0"
```
```   115 by (simp add: log_def)
```
```   116
```
```   117 lemma log_eq_one [simp]: "[| 0 < a; a \<noteq> 1 |] ==> log a a = 1"
```
```   118 by (simp add: log_def)
```
```   119
```
```   120 lemma log_inverse:
```
```   121      "[| 0 < a; a \<noteq> 1; 0 < x |] ==> log a (inverse x) = - log a x"
```
```   122 apply (rule_tac a1 = "log a x" in add_left_cancel [THEN iffD1])
```
```   123 apply (simp add: log_mult [symmetric])
```
```   124 done
```
```   125
```
```   126 lemma log_divide:
```
```   127      "[|0 < a; a \<noteq> 1; 0 < x; 0 < y|] ==> log a (x/y) = log a x - log a y"
```
```   128 by (simp add: log_mult divide_inverse log_inverse)
```
```   129
```
```   130 lemma log_less_cancel_iff [simp]:
```
```   131      "[| 1 < a; 0 < x; 0 < y |] ==> (log a x < log a y) = (x < y)"
```
```   132 apply safe
```
```   133 apply (rule_tac [2] powr_less_cancel)
```
```   134 apply (drule_tac a = "log a x" in powr_less_mono, auto)
```
```   135 done
```
```   136
```
```   137 lemma log_le_cancel_iff [simp]:
```
```   138      "[| 1 < a; 0 < x; 0 < y |] ==> (log a x \<le> log a y) = (x \<le> y)"
```
```   139 by (simp add: linorder_not_less [symmetric])
```
```   140
```
```   141
```
```   142 lemma powr_realpow: "0 < x ==> x powr (real n) = x^n"
```
```   143   apply (induct n, simp)
```
```   144   apply (subgoal_tac "real(Suc n) = real n + 1")
```
```   145   apply (erule ssubst)
```
```   146   apply (subst powr_add, simp, simp)
```
```   147 done
```
```   148
```
```   149 lemma powr_realpow2: "0 <= x ==> 0 < n ==> x^n = (if (x = 0) then 0
```
```   150   else x powr (real n))"
```
```   151   apply (case_tac "x = 0", simp, simp)
```
```   152   apply (rule powr_realpow [THEN sym], simp)
```
```   153 done
```
```   154
```
```   155 lemma ln_pwr: "0 < x ==> 0 < y ==> ln(x powr y) = y * ln x"
```
```   156 by (unfold powr_def, simp)
```
```   157
```
```   158 lemma ln_bound: "1 <= x ==> ln x <= x"
```
```   159   apply (subgoal_tac "ln(1 + (x - 1)) <= x - 1")
```
```   160   apply simp
```
```   161   apply (rule ln_add_one_self_le_self, simp)
```
```   162 done
```
```   163
```
```   164 lemma powr_mono: "a <= b ==> 1 <= x ==> x powr a <= x powr b"
```
```   165   apply (case_tac "x = 1", simp)
```
```   166   apply (case_tac "a = b", simp)
```
```   167   apply (rule order_less_imp_le)
```
```   168   apply (rule powr_less_mono, auto)
```
```   169 done
```
```   170
```
```   171 lemma ge_one_powr_ge_zero: "1 <= x ==> 0 <= a ==> 1 <= x powr a"
```
```   172   apply (subst powr_zero_eq_one [THEN sym])
```
```   173   apply (rule powr_mono, assumption+)
```
```   174 done
```
```   175
```
```   176 lemma powr_less_mono2: "0 < a ==> 0 < x ==> x < y ==> x powr a <
```
```   177     y powr a"
```
```   178   apply (unfold powr_def)
```
```   179   apply (rule exp_less_mono)
```
```   180   apply (rule mult_strict_left_mono)
```
```   181   apply (subst ln_less_cancel_iff, assumption)
```
```   182   apply (rule order_less_trans)
```
```   183   prefer 2
```
```   184   apply assumption+
```
```   185 done
```
```   186
```
```   187 lemma powr_less_mono2_neg: "a < 0 ==> 0 < x ==> x < y ==> y powr a <
```
```   188     x powr a"
```
```   189   apply (unfold powr_def)
```
```   190   apply (rule exp_less_mono)
```
```   191   apply (rule mult_strict_left_mono_neg)
```
```   192   apply (subst ln_less_cancel_iff)
```
```   193   apply assumption
```
```   194   apply (rule order_less_trans)
```
```   195   prefer 2
```
```   196   apply assumption+
```
```   197 done
```
```   198
```
```   199 lemma powr_mono2: "0 <= a ==> 0 < x ==> x <= y ==> x powr a <= y powr a"
```
```   200   apply (case_tac "a = 0", simp)
```
```   201   apply (case_tac "x = y", simp)
```
```   202   apply (rule order_less_imp_le)
```
```   203   apply (rule powr_less_mono2, auto)
```
```   204 done
```
```   205
```
```   206 lemma ln_powr_bound: "1 <= x ==> 0 < a ==> ln x <= (x powr a) / a"
```
```   207   apply (rule mult_imp_le_div_pos)
```
```   208   apply (assumption)
```
```   209   apply (subst mult_commute)
```
```   210   apply (subst ln_pwr [THEN sym])
```
```   211   apply auto
```
```   212   apply (rule ln_bound)
```
```   213   apply (erule ge_one_powr_ge_zero)
```
```   214   apply (erule order_less_imp_le)
```
```   215 done
```
```   216
```
```   217 lemma ln_powr_bound2: "1 < x ==> 0 < a ==> (ln x) powr a <= (a powr a) * x"
```
```   218 proof -
```
```   219   assume "1 < x" and "0 < a"
```
```   220   then have "ln x <= (x powr (1 / a)) / (1 / a)"
```
```   221     apply (intro ln_powr_bound)
```
```   222     apply (erule order_less_imp_le)
```
```   223     apply (rule divide_pos_pos)
```
```   224     apply simp_all
```
```   225     done
```
```   226   also have "... = a * (x powr (1 / a))"
```
```   227     by simp
```
```   228   finally have "(ln x) powr a <= (a * (x powr (1 / a))) powr a"
```
```   229     apply (intro powr_mono2)
```
```   230     apply (rule order_less_imp_le, rule prems)
```
```   231     apply (rule ln_gt_zero)
```
```   232     apply (rule prems)
```
```   233     apply assumption
```
```   234     done
```
```   235   also have "... = (a powr a) * ((x powr (1 / a)) powr a)"
```
```   236     apply (rule powr_mult)
```
```   237     apply (rule prems)
```
```   238     apply (rule powr_gt_zero)
```
```   239     done
```
```   240   also have "(x powr (1 / a)) powr a = x powr ((1 / a) * a)"
```
```   241     by (rule powr_powr)
```
```   242   also have "... = x"
```
```   243     apply simp
```
```   244     apply (subgoal_tac "a ~= 0")
```
```   245     apply (insert prems, auto)
```
```   246     done
```
```   247   finally show ?thesis .
```
```   248 qed
```
```   249
```
```   250 lemma LIMSEQ_neg_powr: "0 < s ==> (%x. (real x) powr - s) ----> 0"
```
```   251   apply (unfold LIMSEQ_iff)
```
```   252   apply clarsimp
```
```   253   apply (rule_tac x = "natfloor(r powr (1 / - s)) + 1" in exI)
```
```   254   apply clarify
```
```   255   proof -
```
```   256     fix r fix n
```
```   257     assume "0 < s" and "0 < r" and "natfloor (r powr (1 / - s)) + 1 <= n"
```
```   258     have "r powr (1 / - s) < real(natfloor(r powr (1 / - s))) + 1"
```
```   259       by (rule real_natfloor_add_one_gt)
```
```   260     also have "... = real(natfloor(r powr (1 / -s)) + 1)"
```
```   261       by simp
```
```   262     also have "... <= real n"
```
```   263       apply (subst real_of_nat_le_iff)
```
```   264       apply (rule prems)
```
```   265       done
```
```   266     finally have "r powr (1 / - s) < real n".
```
```   267     then have "real n powr (- s) < (r powr (1 / - s)) powr - s"
```
```   268       apply (intro powr_less_mono2_neg)
```
```   269       apply (auto simp add: prems)
```
```   270       done
```
```   271     also have "... = r"
```
```   272       by (simp add: powr_powr prems less_imp_neq [THEN not_sym])
```
```   273     finally show "real n powr - s < r" .
```
```   274   qed
```
```   275
```
```   276 end
```