src/HOL/Log.thy
 changeset 28952 15a4b2cf8c34 parent 21404 eb85850d3eb7 child 31336 e17f13cd1280
```     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/src/HOL/Log.thy	Wed Dec 03 15:58:44 2008 +0100
1.3 @@ -0,0 +1,276 @@
1.4 +(*  Title       : Log.thy
1.5 +    Author      : Jacques D. Fleuriot
1.7 +    Copyright   : 2000,2001 University of Edinburgh
1.8 +*)
1.9 +
1.11 +
1.12 +theory Log
1.13 +imports Transcendental
1.14 +begin
1.15 +
1.16 +definition
1.17 +  powr  :: "[real,real] => real"     (infixr "powr" 80) where
1.18 +    --{*exponentation with real exponent*}
1.19 +  "x powr a = exp(a * ln x)"
1.20 +
1.21 +definition
1.22 +  log :: "[real,real] => real" where
1.23 +    --{*logarithm of @{term x} to base @{term a}*}
1.24 +  "log a x = ln x / ln a"
1.25 +
1.26 +
1.27 +
1.28 +lemma powr_one_eq_one [simp]: "1 powr a = 1"
1.30 +
1.31 +lemma powr_zero_eq_one [simp]: "x powr 0 = 1"
1.33 +
1.34 +lemma powr_one_gt_zero_iff [simp]: "(x powr 1 = x) = (0 < x)"
1.36 +declare powr_one_gt_zero_iff [THEN iffD2, simp]
1.37 +
1.38 +lemma powr_mult:
1.39 +      "[| 0 < x; 0 < y |] ==> (x * y) powr a = (x powr a) * (y powr a)"
1.41 +
1.42 +lemma powr_gt_zero [simp]: "0 < x powr a"
1.44 +
1.45 +lemma powr_ge_pzero [simp]: "0 <= x powr y"
1.46 +by (rule order_less_imp_le, rule powr_gt_zero)
1.47 +
1.48 +lemma powr_not_zero [simp]: "x powr a \<noteq> 0"
1.50 +
1.51 +lemma powr_divide:
1.52 +     "[| 0 < x; 0 < y |] ==> (x / y) powr a = (x powr a)/(y powr a)"
1.53 +apply (simp add: divide_inverse positive_imp_inverse_positive powr_mult)
1.55 +done
1.56 +
1.57 +lemma powr_divide2: "x powr a / x powr b = x powr (a - b)"
1.58 +  apply (simp add: powr_def)
1.59 +  apply (subst exp_diff [THEN sym])
1.60 +  apply (simp add: left_diff_distrib)
1.61 +done
1.62 +
1.63 +lemma powr_add: "x powr (a + b) = (x powr a) * (x powr b)"
1.65 +
1.66 +lemma powr_powr: "(x powr a) powr b = x powr (a * b)"
1.68 +
1.69 +lemma powr_powr_swap: "(x powr a) powr b = (x powr b) powr a"
1.70 +by (simp add: powr_powr real_mult_commute)
1.71 +
1.72 +lemma powr_minus: "x powr (-a) = inverse (x powr a)"
1.73 +by (simp add: powr_def exp_minus [symmetric])
1.74 +
1.75 +lemma powr_minus_divide: "x powr (-a) = 1/(x powr a)"
1.76 +by (simp add: divide_inverse powr_minus)
1.77 +
1.78 +lemma powr_less_mono: "[| a < b; 1 < x |] ==> x powr a < x powr b"
1.80 +
1.81 +lemma powr_less_cancel: "[| x powr a < x powr b; 1 < x |] ==> a < b"
1.83 +
1.84 +lemma powr_less_cancel_iff [simp]: "1 < x ==> (x powr a < x powr b) = (a < b)"
1.85 +by (blast intro: powr_less_cancel powr_less_mono)
1.86 +
1.87 +lemma powr_le_cancel_iff [simp]: "1 < x ==> (x powr a \<le> x powr b) = (a \<le> b)"
1.88 +by (simp add: linorder_not_less [symmetric])
1.89 +
1.90 +lemma log_ln: "ln x = log (exp(1)) x"
1.92 +
1.93 +lemma powr_log_cancel [simp]:
1.94 +     "[| 0 < a; a \<noteq> 1; 0 < x |] ==> a powr (log a x) = x"
1.95 +by (simp add: powr_def log_def)
1.96 +
1.97 +lemma log_powr_cancel [simp]: "[| 0 < a; a \<noteq> 1 |] ==> log a (a powr y) = y"
1.98 +by (simp add: log_def powr_def)
1.99 +
1.100 +lemma log_mult:
1.101 +     "[| 0 < a; a \<noteq> 1; 0 < x; 0 < y |]
1.102 +      ==> log a (x * y) = log a x + log a y"
1.103 +by (simp add: log_def ln_mult divide_inverse left_distrib)
1.104 +
1.105 +lemma log_eq_div_ln_mult_log:
1.106 +     "[| 0 < a; a \<noteq> 1; 0 < b; b \<noteq> 1; 0 < x |]
1.107 +      ==> log a x = (ln b/ln a) * log b x"
1.108 +by (simp add: log_def divide_inverse)
1.109 +
1.110 +text{*Base 10 logarithms*}
1.111 +lemma log_base_10_eq1: "0 < x ==> log 10 x = (ln (exp 1) / ln 10) * ln x"
1.113 +
1.114 +lemma log_base_10_eq2: "0 < x ==> log 10 x = (log 10 (exp 1)) * ln x"
1.116 +
1.117 +lemma log_one [simp]: "log a 1 = 0"
1.119 +
1.120 +lemma log_eq_one [simp]: "[| 0 < a; a \<noteq> 1 |] ==> log a a = 1"
1.122 +
1.123 +lemma log_inverse:
1.124 +     "[| 0 < a; a \<noteq> 1; 0 < x |] ==> log a (inverse x) = - log a x"
1.125 +apply (rule_tac a1 = "log a x" in add_left_cancel [THEN iffD1])
1.126 +apply (simp add: log_mult [symmetric])
1.127 +done
1.128 +
1.129 +lemma log_divide:
1.130 +     "[|0 < a; a \<noteq> 1; 0 < x; 0 < y|] ==> log a (x/y) = log a x - log a y"
1.131 +by (simp add: log_mult divide_inverse log_inverse)
1.132 +
1.133 +lemma log_less_cancel_iff [simp]:
1.134 +     "[| 1 < a; 0 < x; 0 < y |] ==> (log a x < log a y) = (x < y)"
1.135 +apply safe
1.136 +apply (rule_tac [2] powr_less_cancel)
1.137 +apply (drule_tac a = "log a x" in powr_less_mono, auto)
1.138 +done
1.139 +
1.140 +lemma log_le_cancel_iff [simp]:
1.141 +     "[| 1 < a; 0 < x; 0 < y |] ==> (log a x \<le> log a y) = (x \<le> y)"
1.142 +by (simp add: linorder_not_less [symmetric])
1.143 +
1.144 +
1.145 +lemma powr_realpow: "0 < x ==> x powr (real n) = x^n"
1.146 +  apply (induct n, simp)
1.147 +  apply (subgoal_tac "real(Suc n) = real n + 1")
1.148 +  apply (erule ssubst)
1.149 +  apply (subst powr_add, simp, simp)
1.150 +done
1.151 +
1.152 +lemma powr_realpow2: "0 <= x ==> 0 < n ==> x^n = (if (x = 0) then 0
1.153 +  else x powr (real n))"
1.154 +  apply (case_tac "x = 0", simp, simp)
1.155 +  apply (rule powr_realpow [THEN sym], simp)
1.156 +done
1.157 +
1.158 +lemma ln_pwr: "0 < x ==> 0 < y ==> ln(x powr y) = y * ln x"
1.159 +by (unfold powr_def, simp)
1.160 +
1.161 +lemma ln_bound: "1 <= x ==> ln x <= x"
1.162 +  apply (subgoal_tac "ln(1 + (x - 1)) <= x - 1")
1.163 +  apply simp
1.164 +  apply (rule ln_add_one_self_le_self, simp)
1.165 +done
1.166 +
1.167 +lemma powr_mono: "a <= b ==> 1 <= x ==> x powr a <= x powr b"
1.168 +  apply (case_tac "x = 1", simp)
1.169 +  apply (case_tac "a = b", simp)
1.170 +  apply (rule order_less_imp_le)
1.171 +  apply (rule powr_less_mono, auto)
1.172 +done
1.173 +
1.174 +lemma ge_one_powr_ge_zero: "1 <= x ==> 0 <= a ==> 1 <= x powr a"
1.175 +  apply (subst powr_zero_eq_one [THEN sym])
1.176 +  apply (rule powr_mono, assumption+)
1.177 +done
1.178 +
1.179 +lemma powr_less_mono2: "0 < a ==> 0 < x ==> x < y ==> x powr a <
1.180 +    y powr a"
1.181 +  apply (unfold powr_def)
1.182 +  apply (rule exp_less_mono)
1.183 +  apply (rule mult_strict_left_mono)
1.184 +  apply (subst ln_less_cancel_iff, assumption)
1.185 +  apply (rule order_less_trans)
1.186 +  prefer 2
1.187 +  apply assumption+
1.188 +done
1.189 +
1.190 +lemma powr_less_mono2_neg: "a < 0 ==> 0 < x ==> x < y ==> y powr a <
1.191 +    x powr a"
1.192 +  apply (unfold powr_def)
1.193 +  apply (rule exp_less_mono)
1.194 +  apply (rule mult_strict_left_mono_neg)
1.195 +  apply (subst ln_less_cancel_iff)
1.196 +  apply assumption
1.197 +  apply (rule order_less_trans)
1.198 +  prefer 2
1.199 +  apply assumption+
1.200 +done
1.201 +
1.202 +lemma powr_mono2: "0 <= a ==> 0 < x ==> x <= y ==> x powr a <= y powr a"
1.203 +  apply (case_tac "a = 0", simp)
1.204 +  apply (case_tac "x = y", simp)
1.205 +  apply (rule order_less_imp_le)
1.206 +  apply (rule powr_less_mono2, auto)
1.207 +done
1.208 +
1.209 +lemma ln_powr_bound: "1 <= x ==> 0 < a ==> ln x <= (x powr a) / a"
1.210 +  apply (rule mult_imp_le_div_pos)
1.211 +  apply (assumption)
1.212 +  apply (subst mult_commute)
1.213 +  apply (subst ln_pwr [THEN sym])
1.214 +  apply auto
1.215 +  apply (rule ln_bound)
1.216 +  apply (erule ge_one_powr_ge_zero)
1.217 +  apply (erule order_less_imp_le)
1.218 +done
1.219 +
1.220 +lemma ln_powr_bound2: "1 < x ==> 0 < a ==> (ln x) powr a <= (a powr a) * x"
1.221 +proof -
1.222 +  assume "1 < x" and "0 < a"
1.223 +  then have "ln x <= (x powr (1 / a)) / (1 / a)"
1.224 +    apply (intro ln_powr_bound)
1.225 +    apply (erule order_less_imp_le)
1.226 +    apply (rule divide_pos_pos)
1.227 +    apply simp_all
1.228 +    done
1.229 +  also have "... = a * (x powr (1 / a))"
1.230 +    by simp
1.231 +  finally have "(ln x) powr a <= (a * (x powr (1 / a))) powr a"
1.232 +    apply (intro powr_mono2)
1.233 +    apply (rule order_less_imp_le, rule prems)
1.234 +    apply (rule ln_gt_zero)
1.235 +    apply (rule prems)
1.236 +    apply assumption
1.237 +    done
1.238 +  also have "... = (a powr a) * ((x powr (1 / a)) powr a)"
1.239 +    apply (rule powr_mult)
1.240 +    apply (rule prems)
1.241 +    apply (rule powr_gt_zero)
1.242 +    done
1.243 +  also have "(x powr (1 / a)) powr a = x powr ((1 / a) * a)"
1.244 +    by (rule powr_powr)
1.245 +  also have "... = x"
1.246 +    apply simp
1.247 +    apply (subgoal_tac "a ~= 0")
1.248 +    apply (insert prems, auto)
1.249 +    done
1.250 +  finally show ?thesis .
1.251 +qed
1.252 +
1.253 +lemma LIMSEQ_neg_powr: "0 < s ==> (%x. (real x) powr - s) ----> 0"
1.254 +  apply (unfold LIMSEQ_def)
1.255 +  apply clarsimp
1.256 +  apply (rule_tac x = "natfloor(r powr (1 / - s)) + 1" in exI)
1.257 +  apply clarify
1.258 +  proof -
1.259 +    fix r fix n
1.260 +    assume "0 < s" and "0 < r" and "natfloor (r powr (1 / - s)) + 1 <= n"
1.261 +    have "r powr (1 / - s) < real(natfloor(r powr (1 / - s))) + 1"
1.263 +    also have "... = real(natfloor(r powr (1 / -s)) + 1)"
1.264 +      by simp
1.265 +    also have "... <= real n"
1.266 +      apply (subst real_of_nat_le_iff)
1.267 +      apply (rule prems)
1.268 +      done
1.269 +    finally have "r powr (1 / - s) < real n".
1.270 +    then have "real n powr (- s) < (r powr (1 / - s)) powr - s"
1.271 +      apply (intro powr_less_mono2_neg)
1.272 +      apply (auto simp add: prems)
1.273 +      done
1.274 +    also have "... = r"
1.275 +      by (simp add: powr_powr prems less_imp_neq [THEN not_sym])
1.276 +    finally show "real n powr - s < r" .
1.277 +  qed
1.278 +
1.279 +end
```