src/HOL/Hyperreal/Log.thy
author nipkow
Mon Aug 16 14:22:27 2004 +0200 (2004-08-16)
changeset 15131 c69542757a4d
parent 15085 5693a977a767
child 15140 322485b816ac
permissions -rw-r--r--
New theory header syntax.
     1 (*  Title       : Log.thy
     2     Author      : Jacques D. Fleuriot
     3     Copyright   : 2000,2001 University of Edinburgh
     4 *)
     5 
     6 header{*Logarithms: Standard Version*}
     7 
     8 theory Log
     9 import Transcendental
    10 begin
    11 
    12 constdefs
    13 
    14   powr  :: "[real,real] => real"     (infixr "powr" 80)
    15     --{*exponentation with real exponent*}
    16     "x powr a == exp(a * ln x)"
    17 
    18   log :: "[real,real] => real"
    19     --{*logarithm of @{term x} to base @{term a}*}
    20     "log a x == ln x / ln a"
    21 
    22 
    23 
    24 lemma powr_one_eq_one [simp]: "1 powr a = 1"
    25 by (simp add: powr_def)
    26 
    27 lemma powr_zero_eq_one [simp]: "x powr 0 = 1"
    28 by (simp add: powr_def)
    29 
    30 lemma powr_one_gt_zero_iff [simp]: "(x powr 1 = x) = (0 < x)"
    31 by (simp add: powr_def)
    32 declare powr_one_gt_zero_iff [THEN iffD2, simp]
    33 
    34 lemma powr_mult: 
    35       "[| 0 < x; 0 < y |] ==> (x * y) powr a = (x powr a) * (y powr a)"
    36 by (simp add: powr_def exp_add [symmetric] ln_mult right_distrib)
    37 
    38 lemma powr_gt_zero [simp]: "0 < x powr a"
    39 by (simp add: powr_def)
    40 
    41 lemma powr_not_zero [simp]: "x powr a \<noteq> 0"
    42 by (simp add: powr_def)
    43 
    44 lemma powr_divide:
    45      "[| 0 < x; 0 < y |] ==> (x / y) powr a = (x powr a)/(y powr a)"
    46 apply (simp add: divide_inverse positive_imp_inverse_positive powr_mult)
    47 apply (simp add: powr_def exp_minus [symmetric] exp_add [symmetric] ln_inverse)
    48 done
    49 
    50 lemma powr_add: "x powr (a + b) = (x powr a) * (x powr b)"
    51 by (simp add: powr_def exp_add [symmetric] left_distrib)
    52 
    53 lemma powr_powr: "(x powr a) powr b = x powr (a * b)"
    54 by (simp add: powr_def)
    55 
    56 lemma powr_powr_swap: "(x powr a) powr b = (x powr b) powr a"
    57 by (simp add: powr_powr real_mult_commute)
    58 
    59 lemma powr_minus: "x powr (-a) = inverse (x powr a)"
    60 by (simp add: powr_def exp_minus [symmetric])
    61 
    62 lemma powr_minus_divide: "x powr (-a) = 1/(x powr a)"
    63 by (simp add: divide_inverse powr_minus)
    64 
    65 lemma powr_less_mono: "[| a < b; 1 < x |] ==> x powr a < x powr b"
    66 by (simp add: powr_def)
    67 
    68 lemma powr_less_cancel: "[| x powr a < x powr b; 1 < x |] ==> a < b"
    69 by (simp add: powr_def)
    70 
    71 lemma powr_less_cancel_iff [simp]: "1 < x ==> (x powr a < x powr b) = (a < b)"
    72 by (blast intro: powr_less_cancel powr_less_mono)
    73 
    74 lemma powr_le_cancel_iff [simp]: "1 < x ==> (x powr a \<le> x powr b) = (a \<le> b)"
    75 by (simp add: linorder_not_less [symmetric])
    76 
    77 lemma log_ln: "ln x = log (exp(1)) x"
    78 by (simp add: log_def)
    79 
    80 lemma powr_log_cancel [simp]:
    81      "[| 0 < a; a \<noteq> 1; 0 < x |] ==> a powr (log a x) = x"
    82 by (simp add: powr_def log_def)
    83 
    84 lemma log_powr_cancel [simp]: "[| 0 < a; a \<noteq> 1 |] ==> log a (a powr y) = y"
    85 by (simp add: log_def powr_def)
    86 
    87 lemma log_mult: 
    88      "[| 0 < a; a \<noteq> 1; 0 < x; 0 < y |]  
    89       ==> log a (x * y) = log a x + log a y"
    90 by (simp add: log_def ln_mult divide_inverse left_distrib)
    91 
    92 lemma log_eq_div_ln_mult_log: 
    93      "[| 0 < a; a \<noteq> 1; 0 < b; b \<noteq> 1; 0 < x |]  
    94       ==> log a x = (ln b/ln a) * log b x"
    95 by (simp add: log_def divide_inverse)
    96 
    97 text{*Base 10 logarithms*}
    98 lemma log_base_10_eq1: "0 < x ==> log 10 x = (ln (exp 1) / ln 10) * ln x"
    99 by (simp add: log_def)
   100 
   101 lemma log_base_10_eq2: "0 < x ==> log 10 x = (log 10 (exp 1)) * ln x"
   102 by (simp add: log_def)
   103 
   104 lemma log_one [simp]: "log a 1 = 0"
   105 by (simp add: log_def)
   106 
   107 lemma log_eq_one [simp]: "[| 0 < a; a \<noteq> 1 |] ==> log a a = 1"
   108 by (simp add: log_def)
   109 
   110 lemma log_inverse:
   111      "[| 0 < a; a \<noteq> 1; 0 < x |] ==> log a (inverse x) = - log a x"
   112 apply (rule_tac a1 = "log a x" in add_left_cancel [THEN iffD1])
   113 apply (simp add: log_mult [symmetric])
   114 done
   115 
   116 lemma log_divide:
   117      "[|0 < a; a \<noteq> 1; 0 < x; 0 < y|] ==> log a (x/y) = log a x - log a y"
   118 by (simp add: log_mult divide_inverse log_inverse)
   119 
   120 lemma log_less_cancel_iff [simp]:
   121      "[| 1 < a; 0 < x; 0 < y |] ==> (log a x < log a y) = (x < y)"
   122 apply safe
   123 apply (rule_tac [2] powr_less_cancel)
   124 apply (drule_tac a = "log a x" in powr_less_mono, auto)
   125 done
   126 
   127 lemma log_le_cancel_iff [simp]:
   128      "[| 1 < a; 0 < x; 0 < y |] ==> (log a x \<le> log a y) = (x \<le> y)"
   129 by (simp add: linorder_not_less [symmetric])
   130 
   131 
   132 subsection{*Further Results Courtesy Jeremy Avigad*}
   133 
   134 lemma powr_realpow: "0 < x ==> x powr (real n) = x^n"
   135   apply (induct n, simp)
   136   apply (subgoal_tac "real(Suc n) = real n + 1")
   137   apply (erule ssubst)
   138   apply (subst powr_add, simp, simp)
   139 done
   140 
   141 lemma powr_realpow2: "0 <= x ==> 0 < n ==> x^n = (if (x = 0) then 0
   142   else x powr (real n))"
   143   apply (case_tac "x = 0", simp, simp)
   144   apply (rule powr_realpow [THEN sym], simp)
   145 done
   146 
   147 lemma ln_pwr: "0 < x ==> 0 < y ==> ln(x powr y) = y * ln x"
   148 by (unfold powr_def, simp)
   149 
   150 lemma ln_bound: "1 <= x ==> ln x <= x"
   151   apply (subgoal_tac "ln(1 + (x - 1)) <= x - 1")
   152   apply simp
   153   apply (rule ln_add_one_self_le_self, simp)
   154 done
   155 
   156 lemma powr_mono: "a <= b ==> 1 <= x ==> x powr a <= x powr b"
   157   apply (case_tac "x = 1", simp)
   158   apply (case_tac "a = b", simp)
   159   apply (rule order_less_imp_le)
   160   apply (rule powr_less_mono, auto)
   161 done
   162 
   163 lemma ge_one_powr_ge_zero: "1 <= x ==> 0 <= a ==> 1 <= x powr a"
   164   apply (subst powr_zero_eq_one [THEN sym])
   165   apply (rule powr_mono, assumption+)
   166 done
   167 
   168 lemma powr_less_mono2: "0 < a ==> 0 < x ==> x < y ==> x powr a <
   169     y powr a"
   170   apply (unfold powr_def)
   171   apply (rule exp_less_mono)
   172   apply (rule mult_strict_left_mono)
   173   apply (subst ln_less_cancel_iff, assumption)
   174   apply (rule order_less_trans)
   175   prefer 2
   176   apply assumption+
   177 done
   178 
   179 lemma powr_mono2: "0 <= a ==> 0 < x ==> x <= y ==> x powr a <= y powr a";
   180   apply (case_tac "a = 0", simp)
   181   apply (case_tac "x = y", simp)
   182   apply (rule order_less_imp_le)
   183   apply (rule powr_less_mono2, auto)
   184 done
   185 
   186 
   187 
   188 ML
   189 {*
   190 val powr_one_eq_one = thm "powr_one_eq_one";
   191 val powr_zero_eq_one = thm "powr_zero_eq_one";
   192 val powr_one_gt_zero_iff = thm "powr_one_gt_zero_iff";
   193 val powr_mult = thm "powr_mult";
   194 val powr_gt_zero = thm "powr_gt_zero";
   195 val powr_not_zero = thm "powr_not_zero";
   196 val powr_divide = thm "powr_divide";
   197 val powr_add = thm "powr_add";
   198 val powr_powr = thm "powr_powr";
   199 val powr_powr_swap = thm "powr_powr_swap";
   200 val powr_minus = thm "powr_minus";
   201 val powr_minus_divide = thm "powr_minus_divide";
   202 val powr_less_mono = thm "powr_less_mono";
   203 val powr_less_cancel = thm "powr_less_cancel";
   204 val powr_less_cancel_iff = thm "powr_less_cancel_iff";
   205 val powr_le_cancel_iff = thm "powr_le_cancel_iff";
   206 val log_ln = thm "log_ln";
   207 val powr_log_cancel = thm "powr_log_cancel";
   208 val log_powr_cancel = thm "log_powr_cancel";
   209 val log_mult = thm "log_mult";
   210 val log_eq_div_ln_mult_log = thm "log_eq_div_ln_mult_log";
   211 val log_base_10_eq1 = thm "log_base_10_eq1";
   212 val log_base_10_eq2 = thm "log_base_10_eq2";
   213 val log_one = thm "log_one";
   214 val log_eq_one = thm "log_eq_one";
   215 val log_inverse = thm "log_inverse";
   216 val log_divide = thm "log_divide";
   217 val log_less_cancel_iff = thm "log_less_cancel_iff";
   218 val log_le_cancel_iff = thm "log_le_cancel_iff";
   219 *}
   220 
   221 end