| author | haftmann | 
| Thu, 23 Sep 2010 10:39:25 +0200 | |
| changeset 39647 | 7bf0c7f0f24c | 
| parent 36777 | be5461582d0f | 
| child 41550 | efa734d9b221 | 
| permissions | -rw-r--r-- | 
| 12224 | 1 | (* Title : Log.thy | 
| 2 | Author : Jacques D. Fleuriot | |
| 16819 | 3 | Additional contributions by Jeremy Avigad | 
| 12224 | 4 | Copyright : 2000,2001 University of Edinburgh | 
| 5 | *) | |
| 6 | ||
| 14411 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 7 | header{*Logarithms: Standard Version*}
 | 
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 8 | |
| 15131 | 9 | theory Log | 
| 15140 | 10 | imports Transcendental | 
| 15131 | 11 | begin | 
| 12224 | 12 | |
| 19765 | 13 | definition | 
| 21404 
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
 wenzelm parents: 
19765diff
changeset | 14 | powr :: "[real,real] => real" (infixr "powr" 80) where | 
| 14411 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 15 |     --{*exponentation with real exponent*}
 | 
| 19765 | 16 | "x powr a = exp(a * ln x)" | 
| 12224 | 17 | |
| 21404 
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
 wenzelm parents: 
19765diff
changeset | 18 | definition | 
| 
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
 wenzelm parents: 
19765diff
changeset | 19 | log :: "[real,real] => real" where | 
| 15053 | 20 |     --{*logarithm of @{term x} to base @{term a}*}
 | 
| 19765 | 21 | "log a x = ln x / ln a" | 
| 12224 | 22 | |
| 14411 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 23 | |
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 24 | |
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 25 | lemma powr_one_eq_one [simp]: "1 powr a = 1" | 
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 26 | by (simp add: powr_def) | 
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 27 | |
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 28 | lemma powr_zero_eq_one [simp]: "x powr 0 = 1" | 
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 29 | by (simp add: powr_def) | 
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 30 | |
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 31 | lemma powr_one_gt_zero_iff [simp]: "(x powr 1 = x) = (0 < x)" | 
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 32 | by (simp add: powr_def) | 
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 33 | declare powr_one_gt_zero_iff [THEN iffD2, simp] | 
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 34 | |
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 35 | lemma powr_mult: | 
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 36 | "[| 0 < x; 0 < y |] ==> (x * y) powr a = (x powr a) * (y powr a)" | 
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 37 | by (simp add: powr_def exp_add [symmetric] ln_mult right_distrib) | 
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 38 | |
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 39 | lemma powr_gt_zero [simp]: "0 < x powr a" | 
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 40 | by (simp add: powr_def) | 
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 41 | |
| 16819 | 42 | lemma powr_ge_pzero [simp]: "0 <= x powr y" | 
| 43 | by (rule order_less_imp_le, rule powr_gt_zero) | |
| 44 | ||
| 14411 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 45 | lemma powr_not_zero [simp]: "x powr a \<noteq> 0" | 
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 46 | by (simp add: powr_def) | 
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 47 | |
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 48 | lemma powr_divide: | 
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 49 | "[| 0 < x; 0 < y |] ==> (x / y) powr a = (x powr a)/(y powr a)" | 
| 14430 
5cb24165a2e1
new material from Avigad, and simplified treatment of division by 0
 paulson parents: 
14411diff
changeset | 50 | apply (simp add: divide_inverse positive_imp_inverse_positive powr_mult) | 
| 14411 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 51 | apply (simp add: powr_def exp_minus [symmetric] exp_add [symmetric] ln_inverse) | 
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 52 | done | 
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 53 | |
| 16819 | 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 | ||
| 14411 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 60 | lemma powr_add: "x powr (a + b) = (x powr a) * (x powr b)" | 
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 61 | by (simp add: powr_def exp_add [symmetric] left_distrib) | 
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 62 | |
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 63 | lemma powr_powr: "(x powr a) powr b = x powr (a * b)" | 
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 64 | by (simp add: powr_def) | 
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 65 | |
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 66 | lemma powr_powr_swap: "(x powr a) powr b = (x powr b) powr a" | 
| 36777 
be5461582d0f
avoid using real-specific versions of generic lemmas
 huffman parents: 
36622diff
changeset | 67 | by (simp add: powr_powr mult_commute) | 
| 14411 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 68 | |
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 69 | lemma powr_minus: "x powr (-a) = inverse (x powr a)" | 
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 70 | by (simp add: powr_def exp_minus [symmetric]) | 
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 71 | |
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 72 | lemma powr_minus_divide: "x powr (-a) = 1/(x powr a)" | 
| 14430 
5cb24165a2e1
new material from Avigad, and simplified treatment of division by 0
 paulson parents: 
14411diff
changeset | 73 | by (simp add: divide_inverse powr_minus) | 
| 14411 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 74 | |
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 75 | lemma powr_less_mono: "[| a < b; 1 < x |] ==> x powr a < x powr b" | 
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 76 | by (simp add: powr_def) | 
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 77 | |
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 78 | lemma powr_less_cancel: "[| x powr a < x powr b; 1 < x |] ==> a < b" | 
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 79 | by (simp add: powr_def) | 
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 80 | |
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 81 | lemma powr_less_cancel_iff [simp]: "1 < x ==> (x powr a < x powr b) = (a < b)" | 
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 82 | by (blast intro: powr_less_cancel powr_less_mono) | 
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 83 | |
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 84 | lemma powr_le_cancel_iff [simp]: "1 < x ==> (x powr a \<le> x powr b) = (a \<le> b)" | 
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 85 | by (simp add: linorder_not_less [symmetric]) | 
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 86 | |
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 87 | lemma log_ln: "ln x = log (exp(1)) x" | 
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 88 | by (simp add: log_def) | 
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 89 | |
| 33716 | 90 | lemma DERIV_log: "x > 0 ==> DERIV (%y. log b y) x :> 1 / (ln b * x)" | 
| 91 | apply (subst log_def) | |
| 92 | apply (subgoal_tac "(%y. ln y / ln b) = (%y. (1 / ln b) * ln y)") | |
| 93 | apply (erule ssubst) | |
| 94 | apply (subgoal_tac "1 / (ln b * x) = (1 / ln b) * (1 / x)") | |
| 95 | apply (erule ssubst) | |
| 96 | apply (rule DERIV_cmult) | |
| 97 | apply (erule DERIV_ln_divide) | |
| 98 | apply auto | |
| 99 | done | |
| 100 | ||
| 14411 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 101 | lemma powr_log_cancel [simp]: | 
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 102 | "[| 0 < a; a \<noteq> 1; 0 < x |] ==> a powr (log a x) = x" | 
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 103 | by (simp add: powr_def log_def) | 
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 104 | |
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 105 | lemma log_powr_cancel [simp]: "[| 0 < a; a \<noteq> 1 |] ==> log a (a powr y) = y" | 
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 106 | by (simp add: log_def powr_def) | 
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 107 | |
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 108 | lemma log_mult: | 
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 109 | "[| 0 < a; a \<noteq> 1; 0 < x; 0 < y |] | 
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 110 | ==> log a (x * y) = log a x + log a y" | 
| 14430 
5cb24165a2e1
new material from Avigad, and simplified treatment of division by 0
 paulson parents: 
14411diff
changeset | 111 | by (simp add: log_def ln_mult divide_inverse left_distrib) | 
| 14411 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 112 | |
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 113 | lemma log_eq_div_ln_mult_log: | 
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 114 | "[| 0 < a; a \<noteq> 1; 0 < b; b \<noteq> 1; 0 < x |] | 
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 115 | ==> log a x = (ln b/ln a) * log b x" | 
| 14430 
5cb24165a2e1
new material from Avigad, and simplified treatment of division by 0
 paulson parents: 
14411diff
changeset | 116 | by (simp add: log_def divide_inverse) | 
| 14411 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 117 | |
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 118 | text{*Base 10 logarithms*}
 | 
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 119 | lemma log_base_10_eq1: "0 < x ==> log 10 x = (ln (exp 1) / ln 10) * ln x" | 
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 120 | by (simp add: log_def) | 
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 121 | |
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 122 | lemma log_base_10_eq2: "0 < x ==> log 10 x = (log 10 (exp 1)) * ln x" | 
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 123 | by (simp add: log_def) | 
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 124 | |
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 125 | lemma log_one [simp]: "log a 1 = 0" | 
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 126 | by (simp add: log_def) | 
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 127 | |
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 128 | lemma log_eq_one [simp]: "[| 0 < a; a \<noteq> 1 |] ==> log a a = 1" | 
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 129 | by (simp add: log_def) | 
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 130 | |
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 131 | lemma log_inverse: | 
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 132 | "[| 0 < a; a \<noteq> 1; 0 < x |] ==> log a (inverse x) = - log a x" | 
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 133 | apply (rule_tac a1 = "log a x" in add_left_cancel [THEN iffD1]) | 
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 134 | apply (simp add: log_mult [symmetric]) | 
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 135 | done | 
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 136 | |
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 137 | lemma log_divide: | 
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 138 | "[|0 < a; a \<noteq> 1; 0 < x; 0 < y|] ==> log a (x/y) = log a x - log a y" | 
| 14430 
5cb24165a2e1
new material from Avigad, and simplified treatment of division by 0
 paulson parents: 
14411diff
changeset | 139 | by (simp add: log_mult divide_inverse log_inverse) | 
| 14411 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 140 | |
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 141 | lemma log_less_cancel_iff [simp]: | 
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 142 | "[| 1 < a; 0 < x; 0 < y |] ==> (log a x < log a y) = (x < y)" | 
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 143 | apply safe | 
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 144 | apply (rule_tac [2] powr_less_cancel) | 
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 145 | apply (drule_tac a = "log a x" in powr_less_mono, auto) | 
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 146 | done | 
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 147 | |
| 36622 
e393a91f86df
Generalize swap_inj_on; add simps for Times; add Ex_list_of_length, log_inj; Added missing locale edges for linordered semiring with 1.
 hoelzl parents: 
33716diff
changeset | 148 | lemma log_inj: assumes "1 < b" shows "inj_on (log b) {0 <..}"
 | 
| 
e393a91f86df
Generalize swap_inj_on; add simps for Times; add Ex_list_of_length, log_inj; Added missing locale edges for linordered semiring with 1.
 hoelzl parents: 
33716diff
changeset | 149 | proof (rule inj_onI, simp) | 
| 
e393a91f86df
Generalize swap_inj_on; add simps for Times; add Ex_list_of_length, log_inj; Added missing locale edges for linordered semiring with 1.
 hoelzl parents: 
33716diff
changeset | 150 | fix x y assume pos: "0 < x" "0 < y" and *: "log b x = log b y" | 
| 
e393a91f86df
Generalize swap_inj_on; add simps for Times; add Ex_list_of_length, log_inj; Added missing locale edges for linordered semiring with 1.
 hoelzl parents: 
33716diff
changeset | 151 | show "x = y" | 
| 
e393a91f86df
Generalize swap_inj_on; add simps for Times; add Ex_list_of_length, log_inj; Added missing locale edges for linordered semiring with 1.
 hoelzl parents: 
33716diff
changeset | 152 | proof (cases rule: linorder_cases) | 
| 
e393a91f86df
Generalize swap_inj_on; add simps for Times; add Ex_list_of_length, log_inj; Added missing locale edges for linordered semiring with 1.
 hoelzl parents: 
33716diff
changeset | 153 | assume "x < y" hence "log b x < log b y" | 
| 
e393a91f86df
Generalize swap_inj_on; add simps for Times; add Ex_list_of_length, log_inj; Added missing locale edges for linordered semiring with 1.
 hoelzl parents: 
33716diff
changeset | 154 | using log_less_cancel_iff[OF `1 < b`] pos by simp | 
| 
e393a91f86df
Generalize swap_inj_on; add simps for Times; add Ex_list_of_length, log_inj; Added missing locale edges for linordered semiring with 1.
 hoelzl parents: 
33716diff
changeset | 155 | thus ?thesis using * by simp | 
| 
e393a91f86df
Generalize swap_inj_on; add simps for Times; add Ex_list_of_length, log_inj; Added missing locale edges for linordered semiring with 1.
 hoelzl parents: 
33716diff
changeset | 156 | next | 
| 
e393a91f86df
Generalize swap_inj_on; add simps for Times; add Ex_list_of_length, log_inj; Added missing locale edges for linordered semiring with 1.
 hoelzl parents: 
33716diff
changeset | 157 | assume "y < x" hence "log b y < log b x" | 
| 
e393a91f86df
Generalize swap_inj_on; add simps for Times; add Ex_list_of_length, log_inj; Added missing locale edges for linordered semiring with 1.
 hoelzl parents: 
33716diff
changeset | 158 | using log_less_cancel_iff[OF `1 < b`] pos by simp | 
| 
e393a91f86df
Generalize swap_inj_on; add simps for Times; add Ex_list_of_length, log_inj; Added missing locale edges for linordered semiring with 1.
 hoelzl parents: 
33716diff
changeset | 159 | thus ?thesis using * by simp | 
| 
e393a91f86df
Generalize swap_inj_on; add simps for Times; add Ex_list_of_length, log_inj; Added missing locale edges for linordered semiring with 1.
 hoelzl parents: 
33716diff
changeset | 160 | qed simp | 
| 
e393a91f86df
Generalize swap_inj_on; add simps for Times; add Ex_list_of_length, log_inj; Added missing locale edges for linordered semiring with 1.
 hoelzl parents: 
33716diff
changeset | 161 | qed | 
| 
e393a91f86df
Generalize swap_inj_on; add simps for Times; add Ex_list_of_length, log_inj; Added missing locale edges for linordered semiring with 1.
 hoelzl parents: 
33716diff
changeset | 162 | |
| 14411 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 163 | lemma log_le_cancel_iff [simp]: | 
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 164 | "[| 1 < a; 0 < x; 0 < y |] ==> (log a x \<le> log a y) = (x \<le> y)" | 
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 165 | by (simp add: linorder_not_less [symmetric]) | 
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 166 | |
| 
7851e526b8b7
converted Hyperreal/Log and Hyperreal/HLog to Isar scripts
 paulson parents: 
12224diff
changeset | 167 | |
| 15085 
5693a977a767
removed some [iff] declarations from RealDef.thy, concerning inequalities
 paulson parents: 
15053diff
changeset | 168 | lemma powr_realpow: "0 < x ==> x powr (real n) = x^n" | 
| 
5693a977a767
removed some [iff] declarations from RealDef.thy, concerning inequalities
 paulson parents: 
15053diff
changeset | 169 | apply (induct n, simp) | 
| 
5693a977a767
removed some [iff] declarations from RealDef.thy, concerning inequalities
 paulson parents: 
15053diff
changeset | 170 | apply (subgoal_tac "real(Suc n) = real n + 1") | 
| 
5693a977a767
removed some [iff] declarations from RealDef.thy, concerning inequalities
 paulson parents: 
15053diff
changeset | 171 | apply (erule ssubst) | 
| 
5693a977a767
removed some [iff] declarations from RealDef.thy, concerning inequalities
 paulson parents: 
15053diff
changeset | 172 | apply (subst powr_add, simp, simp) | 
| 
5693a977a767
removed some [iff] declarations from RealDef.thy, concerning inequalities
 paulson parents: 
15053diff
changeset | 173 | done | 
| 
5693a977a767
removed some [iff] declarations from RealDef.thy, concerning inequalities
 paulson parents: 
15053diff
changeset | 174 | |
| 
5693a977a767
removed some [iff] declarations from RealDef.thy, concerning inequalities
 paulson parents: 
15053diff
changeset | 175 | lemma powr_realpow2: "0 <= x ==> 0 < n ==> x^n = (if (x = 0) then 0 | 
| 
5693a977a767
removed some [iff] declarations from RealDef.thy, concerning inequalities
 paulson parents: 
15053diff
changeset | 176 | else x powr (real n))" | 
| 
5693a977a767
removed some [iff] declarations from RealDef.thy, concerning inequalities
 paulson parents: 
15053diff
changeset | 177 | apply (case_tac "x = 0", simp, simp) | 
| 
5693a977a767
removed some [iff] declarations from RealDef.thy, concerning inequalities
 paulson parents: 
15053diff
changeset | 178 | apply (rule powr_realpow [THEN sym], simp) | 
| 
5693a977a767
removed some [iff] declarations from RealDef.thy, concerning inequalities
 paulson parents: 
15053diff
changeset | 179 | done | 
| 
5693a977a767
removed some [iff] declarations from RealDef.thy, concerning inequalities
 paulson parents: 
15053diff
changeset | 180 | |
| 33716 | 181 | lemma ln_powr: "0 < x ==> 0 < y ==> ln(x powr y) = y * ln x" | 
| 15085 
5693a977a767
removed some [iff] declarations from RealDef.thy, concerning inequalities
 paulson parents: 
15053diff
changeset | 182 | by (unfold powr_def, simp) | 
| 
5693a977a767
removed some [iff] declarations from RealDef.thy, concerning inequalities
 paulson parents: 
15053diff
changeset | 183 | |
| 33716 | 184 | lemma log_powr: "0 < x ==> 0 \<le> y ==> log b (x powr y) = y * log b x" | 
| 185 | apply (case_tac "y = 0") | |
| 186 | apply force | |
| 187 | apply (auto simp add: log_def ln_powr field_simps) | |
| 188 | done | |
| 189 | ||
| 190 | lemma log_nat_power: "0 < x ==> log b (x^n) = real n * log b x" | |
| 191 | apply (subst powr_realpow [symmetric]) | |
| 192 | apply (auto simp add: log_powr) | |
| 193 | done | |
| 194 | ||
| 15085 
5693a977a767
removed some [iff] declarations from RealDef.thy, concerning inequalities
 paulson parents: 
15053diff
changeset | 195 | lemma ln_bound: "1 <= x ==> ln x <= x" | 
| 
5693a977a767
removed some [iff] declarations from RealDef.thy, concerning inequalities
 paulson parents: 
15053diff
changeset | 196 | apply (subgoal_tac "ln(1 + (x - 1)) <= x - 1") | 
| 
5693a977a767
removed some [iff] declarations from RealDef.thy, concerning inequalities
 paulson parents: 
15053diff
changeset | 197 | apply simp | 
| 
5693a977a767
removed some [iff] declarations from RealDef.thy, concerning inequalities
 paulson parents: 
15053diff
changeset | 198 | apply (rule ln_add_one_self_le_self, simp) | 
| 
5693a977a767
removed some [iff] declarations from RealDef.thy, concerning inequalities
 paulson parents: 
15053diff
changeset | 199 | done | 
| 
5693a977a767
removed some [iff] declarations from RealDef.thy, concerning inequalities
 paulson parents: 
15053diff
changeset | 200 | |
| 
5693a977a767
removed some [iff] declarations from RealDef.thy, concerning inequalities
 paulson parents: 
15053diff
changeset | 201 | lemma powr_mono: "a <= b ==> 1 <= x ==> x powr a <= x powr b" | 
| 
5693a977a767
removed some [iff] declarations from RealDef.thy, concerning inequalities
 paulson parents: 
15053diff
changeset | 202 | apply (case_tac "x = 1", simp) | 
| 
5693a977a767
removed some [iff] declarations from RealDef.thy, concerning inequalities
 paulson parents: 
15053diff
changeset | 203 | apply (case_tac "a = b", simp) | 
| 
5693a977a767
removed some [iff] declarations from RealDef.thy, concerning inequalities
 paulson parents: 
15053diff
changeset | 204 | apply (rule order_less_imp_le) | 
| 
5693a977a767
removed some [iff] declarations from RealDef.thy, concerning inequalities
 paulson parents: 
15053diff
changeset | 205 | apply (rule powr_less_mono, auto) | 
| 
5693a977a767
removed some [iff] declarations from RealDef.thy, concerning inequalities
 paulson parents: 
15053diff
changeset | 206 | done | 
| 
5693a977a767
removed some [iff] declarations from RealDef.thy, concerning inequalities
 paulson parents: 
15053diff
changeset | 207 | |
| 
5693a977a767
removed some [iff] declarations from RealDef.thy, concerning inequalities
 paulson parents: 
15053diff
changeset | 208 | lemma ge_one_powr_ge_zero: "1 <= x ==> 0 <= a ==> 1 <= x powr a" | 
| 
5693a977a767
removed some [iff] declarations from RealDef.thy, concerning inequalities
 paulson parents: 
15053diff
changeset | 209 | apply (subst powr_zero_eq_one [THEN sym]) | 
| 
5693a977a767
removed some [iff] declarations from RealDef.thy, concerning inequalities
 paulson parents: 
15053diff
changeset | 210 | apply (rule powr_mono, assumption+) | 
| 
5693a977a767
removed some [iff] declarations from RealDef.thy, concerning inequalities
 paulson parents: 
15053diff
changeset | 211 | done | 
| 
5693a977a767
removed some [iff] declarations from RealDef.thy, concerning inequalities
 paulson parents: 
15053diff
changeset | 212 | |
| 
5693a977a767
removed some [iff] declarations from RealDef.thy, concerning inequalities
 paulson parents: 
15053diff
changeset | 213 | lemma powr_less_mono2: "0 < a ==> 0 < x ==> x < y ==> x powr a < | 
| 
5693a977a767
removed some [iff] declarations from RealDef.thy, concerning inequalities
 paulson parents: 
15053diff
changeset | 214 | y powr a" | 
| 
5693a977a767
removed some [iff] declarations from RealDef.thy, concerning inequalities
 paulson parents: 
15053diff
changeset | 215 | apply (unfold powr_def) | 
| 
5693a977a767
removed some [iff] declarations from RealDef.thy, concerning inequalities
 paulson parents: 
15053diff
changeset | 216 | apply (rule exp_less_mono) | 
| 
5693a977a767
removed some [iff] declarations from RealDef.thy, concerning inequalities
 paulson parents: 
15053diff
changeset | 217 | apply (rule mult_strict_left_mono) | 
| 
5693a977a767
removed some [iff] declarations from RealDef.thy, concerning inequalities
 paulson parents: 
15053diff
changeset | 218 | apply (subst ln_less_cancel_iff, assumption) | 
| 
5693a977a767
removed some [iff] declarations from RealDef.thy, concerning inequalities
 paulson parents: 
15053diff
changeset | 219 | apply (rule order_less_trans) | 
| 
5693a977a767
removed some [iff] declarations from RealDef.thy, concerning inequalities
 paulson parents: 
15053diff
changeset | 220 | prefer 2 | 
| 
5693a977a767
removed some [iff] declarations from RealDef.thy, concerning inequalities
 paulson parents: 
15053diff
changeset | 221 | apply assumption+ | 
| 
5693a977a767
removed some [iff] declarations from RealDef.thy, concerning inequalities
 paulson parents: 
15053diff
changeset | 222 | done | 
| 
5693a977a767
removed some [iff] declarations from RealDef.thy, concerning inequalities
 paulson parents: 
15053diff
changeset | 223 | |
| 16819 | 224 | lemma powr_less_mono2_neg: "a < 0 ==> 0 < x ==> x < y ==> y powr a < | 
| 225 | x powr a" | |
| 226 | apply (unfold powr_def) | |
| 227 | apply (rule exp_less_mono) | |
| 228 | apply (rule mult_strict_left_mono_neg) | |
| 229 | apply (subst ln_less_cancel_iff) | |
| 230 | apply assumption | |
| 231 | apply (rule order_less_trans) | |
| 232 | prefer 2 | |
| 233 | apply assumption+ | |
| 234 | done | |
| 235 | ||
| 236 | lemma powr_mono2: "0 <= a ==> 0 < x ==> x <= y ==> x powr a <= y powr a" | |
| 15085 
5693a977a767
removed some [iff] declarations from RealDef.thy, concerning inequalities
 paulson parents: 
15053diff
changeset | 237 | apply (case_tac "a = 0", simp) | 
| 
5693a977a767
removed some [iff] declarations from RealDef.thy, concerning inequalities
 paulson parents: 
15053diff
changeset | 238 | apply (case_tac "x = y", simp) | 
| 
5693a977a767
removed some [iff] declarations from RealDef.thy, concerning inequalities
 paulson parents: 
15053diff
changeset | 239 | apply (rule order_less_imp_le) | 
| 
5693a977a767
removed some [iff] declarations from RealDef.thy, concerning inequalities
 paulson parents: 
15053diff
changeset | 240 | apply (rule powr_less_mono2, auto) | 
| 
5693a977a767
removed some [iff] declarations from RealDef.thy, concerning inequalities
 paulson parents: 
15053diff
changeset | 241 | done | 
| 
5693a977a767
removed some [iff] declarations from RealDef.thy, concerning inequalities
 paulson parents: 
15053diff
changeset | 242 | |
| 16819 | 243 | lemma ln_powr_bound: "1 <= x ==> 0 < a ==> ln x <= (x powr a) / a" | 
| 244 | apply (rule mult_imp_le_div_pos) | |
| 245 | apply (assumption) | |
| 246 | apply (subst mult_commute) | |
| 33716 | 247 | apply (subst ln_powr [THEN sym]) | 
| 16819 | 248 | apply auto | 
| 249 | apply (rule ln_bound) | |
| 250 | apply (erule ge_one_powr_ge_zero) | |
| 251 | apply (erule order_less_imp_le) | |
| 252 | done | |
| 253 | ||
| 254 | lemma ln_powr_bound2: "1 < x ==> 0 < a ==> (ln x) powr a <= (a powr a) * x" | |
| 255 | proof - | |
| 256 | assume "1 < x" and "0 < a" | |
| 257 | then have "ln x <= (x powr (1 / a)) / (1 / a)" | |
| 258 | apply (intro ln_powr_bound) | |
| 259 | apply (erule order_less_imp_le) | |
| 260 | apply (rule divide_pos_pos) | |
| 261 | apply simp_all | |
| 262 | done | |
| 263 | also have "... = a * (x powr (1 / a))" | |
| 264 | by simp | |
| 265 | finally have "(ln x) powr a <= (a * (x powr (1 / a))) powr a" | |
| 266 | apply (intro powr_mono2) | |
| 267 | apply (rule order_less_imp_le, rule prems) | |
| 268 | apply (rule ln_gt_zero) | |
| 269 | apply (rule prems) | |
| 270 | apply assumption | |
| 271 | done | |
| 272 | also have "... = (a powr a) * ((x powr (1 / a)) powr a)" | |
| 273 | apply (rule powr_mult) | |
| 274 | apply (rule prems) | |
| 275 | apply (rule powr_gt_zero) | |
| 276 | done | |
| 277 | also have "(x powr (1 / a)) powr a = x powr ((1 / a) * a)" | |
| 278 | by (rule powr_powr) | |
| 279 | also have "... = x" | |
| 280 | apply simp | |
| 281 | apply (subgoal_tac "a ~= 0") | |
| 282 | apply (insert prems, auto) | |
| 283 | done | |
| 284 | finally show ?thesis . | |
| 285 | qed | |
| 286 | ||
| 287 | lemma LIMSEQ_neg_powr: "0 < s ==> (%x. (real x) powr - s) ----> 0" | |
| 31336 
e17f13cd1280
generalize constants in SEQ.thy to class metric_space
 huffman parents: 
28952diff
changeset | 288 | apply (unfold LIMSEQ_iff) | 
| 16819 | 289 | apply clarsimp | 
| 290 | apply (rule_tac x = "natfloor(r powr (1 / - s)) + 1" in exI) | |
| 291 | apply clarify | |
| 292 | proof - | |
| 293 | fix r fix n | |
| 294 | assume "0 < s" and "0 < r" and "natfloor (r powr (1 / - s)) + 1 <= n" | |
| 295 | have "r powr (1 / - s) < real(natfloor(r powr (1 / - s))) + 1" | |
| 296 | by (rule real_natfloor_add_one_gt) | |
| 297 | also have "... = real(natfloor(r powr (1 / -s)) + 1)" | |
| 298 | by simp | |
| 299 | also have "... <= real n" | |
| 300 | apply (subst real_of_nat_le_iff) | |
| 301 | apply (rule prems) | |
| 302 | done | |
| 303 | finally have "r powr (1 / - s) < real n". | |
| 304 | then have "real n powr (- s) < (r powr (1 / - s)) powr - s" | |
| 305 | apply (intro powr_less_mono2_neg) | |
| 306 | apply (auto simp add: prems) | |
| 307 | done | |
| 308 | also have "... = r" | |
| 309 | by (simp add: powr_powr prems less_imp_neq [THEN not_sym]) | |
| 310 | finally show "real n powr - s < r" . | |
| 311 | qed | |
| 312 | ||
| 12224 | 313 | end |