| author | wenzelm | 
| Thu, 26 Feb 2009 22:13:01 +0100 | |
| changeset 30127 | cd3f37ba3e25 | 
| parent 30079 | 293b896b9c25 | 
| child 30242 | aea5d7fa7ef5 | 
| permissions | -rw-r--r-- | 
| 3390 
0c7625196d95
New theory "Power" of exponentiation (and binomial coefficients)
 paulson parents: diff
changeset | 1 | (* Title: HOL/Power.thy | 
| 
0c7625196d95
New theory "Power" of exponentiation (and binomial coefficients)
 paulson parents: diff
changeset | 2 | ID: $Id$ | 
| 
0c7625196d95
New theory "Power" of exponentiation (and binomial coefficients)
 paulson parents: diff
changeset | 3 | Author: Lawrence C Paulson, Cambridge University Computer Laboratory | 
| 
0c7625196d95
New theory "Power" of exponentiation (and binomial coefficients)
 paulson parents: diff
changeset | 4 | Copyright 1997 University of Cambridge | 
| 
0c7625196d95
New theory "Power" of exponentiation (and binomial coefficients)
 paulson parents: diff
changeset | 5 | |
| 
0c7625196d95
New theory "Power" of exponentiation (and binomial coefficients)
 paulson parents: diff
changeset | 6 | *) | 
| 
0c7625196d95
New theory "Power" of exponentiation (and binomial coefficients)
 paulson parents: diff
changeset | 7 | |
| 16733 
236dfafbeb63
linear arithmetic now takes "&" in assumptions apart.
 nipkow parents: 
15251diff
changeset | 8 | header{*Exponentiation*}
 | 
| 14348 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 9 | |
| 15131 | 10 | theory Power | 
| 21413 | 11 | imports Nat | 
| 15131 | 12 | begin | 
| 14348 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 13 | |
| 29608 | 14 | class power = | 
| 25062 | 15 | fixes power :: "'a \<Rightarrow> nat \<Rightarrow> 'a" (infixr "^" 80) | 
| 24996 | 16 | |
| 21199 
2d83f93c3580
* Added annihilation axioms ("x * 0 = 0") to axclass semiring_0.
 krauss parents: 
17149diff
changeset | 17 | subsection{*Powers for Arbitrary Monoids*}
 | 
| 14348 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 18 | |
| 22390 | 19 | class recpower = monoid_mult + power + | 
| 25062 | 20 | assumes power_0 [simp]: "a ^ 0 = 1" | 
| 21 | assumes power_Suc: "a ^ Suc n = a * (a ^ n)" | |
| 14348 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 22 | |
| 21199 
2d83f93c3580
* Added annihilation axioms ("x * 0 = 0") to axclass semiring_0.
 krauss parents: 
17149diff
changeset | 23 | lemma power_0_Suc [simp]: "(0::'a::{recpower,semiring_0}) ^ (Suc n) = 0"
 | 
| 23183 | 24 | by (simp add: power_Suc) | 
| 14348 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 25 | |
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 26 | text{*It looks plausible as a simprule, but its effect can be strange.*}
 | 
| 21199 
2d83f93c3580
* Added annihilation axioms ("x * 0 = 0") to axclass semiring_0.
 krauss parents: 
17149diff
changeset | 27 | lemma power_0_left: "0^n = (if n=0 then 1 else (0::'a::{recpower,semiring_0}))"
 | 
| 23183 | 28 | by (induct n) simp_all | 
| 14348 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 29 | |
| 15004 | 30 | lemma power_one [simp]: "1^n = (1::'a::recpower)" | 
| 23183 | 31 | by (induct n) (simp_all add: power_Suc) | 
| 14348 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 32 | |
| 15004 | 33 | lemma power_one_right [simp]: "(a::'a::recpower) ^ 1 = a" | 
| 30079 
293b896b9c25
make proofs work whether or not One_nat_def is a simp rule; replace 1 with Suc 0 in the rhs of some simp rules
 huffman parents: 
30056diff
changeset | 34 | unfolding One_nat_def by (simp add: power_Suc) | 
| 14348 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 35 | |
| 21199 
2d83f93c3580
* Added annihilation axioms ("x * 0 = 0") to axclass semiring_0.
 krauss parents: 
17149diff
changeset | 36 | lemma power_commutes: "(a::'a::recpower) ^ n * a = a * a ^ n" | 
| 23183 | 37 | by (induct n) (simp_all add: power_Suc mult_assoc) | 
| 21199 
2d83f93c3580
* Added annihilation axioms ("x * 0 = 0") to axclass semiring_0.
 krauss parents: 
17149diff
changeset | 38 | |
| 28131 
3130d7b3149d
add lemma power_Suc2; generalize power_minus from class comm_ring_1 to ring_1
 huffman parents: 
25874diff
changeset | 39 | lemma power_Suc2: "(a::'a::recpower) ^ Suc n = a ^ n * a" | 
| 
3130d7b3149d
add lemma power_Suc2; generalize power_minus from class comm_ring_1 to ring_1
 huffman parents: 
25874diff
changeset | 40 | by (simp add: power_Suc power_commutes) | 
| 
3130d7b3149d
add lemma power_Suc2; generalize power_minus from class comm_ring_1 to ring_1
 huffman parents: 
25874diff
changeset | 41 | |
| 15004 | 42 | lemma power_add: "(a::'a::recpower) ^ (m+n) = (a^m) * (a^n)" | 
| 23183 | 43 | by (induct m) (simp_all add: power_Suc mult_ac) | 
| 14348 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 44 | |
| 15004 | 45 | lemma power_mult: "(a::'a::recpower) ^ (m*n) = (a^m) ^ n" | 
| 23183 | 46 | by (induct n) (simp_all add: power_Suc power_add) | 
| 14348 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 47 | |
| 21199 
2d83f93c3580
* Added annihilation axioms ("x * 0 = 0") to axclass semiring_0.
 krauss parents: 
17149diff
changeset | 48 | lemma power_mult_distrib: "((a::'a::{recpower,comm_monoid_mult}) * b) ^ n = (a^n) * (b^n)"
 | 
| 23183 | 49 | by (induct n) (simp_all add: power_Suc mult_ac) | 
| 14348 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 50 | |
| 25874 | 51 | lemma zero_less_power[simp]: | 
| 15004 | 52 |      "0 < (a::'a::{ordered_semidom,recpower}) ==> 0 < a^n"
 | 
| 15251 | 53 | apply (induct "n") | 
| 16775 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16733diff
changeset | 54 | apply (simp_all add: power_Suc zero_less_one mult_pos_pos) | 
| 14348 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 55 | done | 
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 56 | |
| 25874 | 57 | lemma zero_le_power[simp]: | 
| 15004 | 58 |      "0 \<le> (a::'a::{ordered_semidom,recpower}) ==> 0 \<le> a^n"
 | 
| 14348 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 59 | apply (simp add: order_le_less) | 
| 14577 | 60 | apply (erule disjE) | 
| 25874 | 61 | apply (simp_all add: zero_less_one power_0_left) | 
| 14348 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 62 | done | 
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 63 | |
| 25874 | 64 | lemma one_le_power[simp]: | 
| 15004 | 65 |      "1 \<le> (a::'a::{ordered_semidom,recpower}) ==> 1 \<le> a^n"
 | 
| 15251 | 66 | apply (induct "n") | 
| 14348 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 67 | apply (simp_all add: power_Suc) | 
| 14577 | 68 | apply (rule order_trans [OF _ mult_mono [of 1 _ 1]]) | 
| 69 | apply (simp_all add: zero_le_one order_trans [OF zero_le_one]) | |
| 14348 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 70 | done | 
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 71 | |
| 14738 | 72 | lemma gt1_imp_ge0: "1 < a ==> 0 \<le> (a::'a::ordered_semidom)" | 
| 14348 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 73 | by (simp add: order_trans [OF zero_le_one order_less_imp_le]) | 
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 74 | |
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 75 | lemma power_gt1_lemma: | 
| 15004 | 76 |   assumes gt1: "1 < (a::'a::{ordered_semidom,recpower})"
 | 
| 14577 | 77 | shows "1 < a * a^n" | 
| 14348 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 78 | proof - | 
| 14577 | 79 | have "1*1 < a*1" using gt1 by simp | 
| 80 | also have "\<dots> \<le> a * a^n" using gt1 | |
| 81 | by (simp only: mult_mono gt1_imp_ge0 one_le_power order_less_imp_le | |
| 82 | zero_le_one order_refl) | |
| 83 | finally show ?thesis by simp | |
| 14348 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 84 | qed | 
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 85 | |
| 25874 | 86 | lemma one_less_power[simp]: | 
| 24376 | 87 |   "\<lbrakk>1 < (a::'a::{ordered_semidom,recpower}); 0 < n\<rbrakk> \<Longrightarrow> 1 < a ^ n"
 | 
| 88 | by (cases n, simp_all add: power_gt1_lemma power_Suc) | |
| 89 | ||
| 14348 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 90 | lemma power_gt1: | 
| 15004 | 91 |      "1 < (a::'a::{ordered_semidom,recpower}) ==> 1 < a ^ (Suc n)"
 | 
| 14348 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 92 | by (simp add: power_gt1_lemma power_Suc) | 
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 93 | |
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 94 | lemma power_le_imp_le_exp: | 
| 15004 | 95 |   assumes gt1: "(1::'a::{recpower,ordered_semidom}) < a"
 | 
| 14577 | 96 | shows "!!n. a^m \<le> a^n ==> m \<le> n" | 
| 97 | proof (induct m) | |
| 14348 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 98 | case 0 | 
| 14577 | 99 | show ?case by simp | 
| 14348 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 100 | next | 
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 101 | case (Suc m) | 
| 14577 | 102 | show ?case | 
| 103 | proof (cases n) | |
| 104 | case 0 | |
| 105 | from prems have "a * a^m \<le> 1" by (simp add: power_Suc) | |
| 106 | with gt1 show ?thesis | |
| 107 | by (force simp only: power_gt1_lemma | |
| 108 | linorder_not_less [symmetric]) | |
| 109 | next | |
| 110 | case (Suc n) | |
| 111 | from prems show ?thesis | |
| 112 | by (force dest: mult_left_le_imp_le | |
| 113 | simp add: power_Suc order_less_trans [OF zero_less_one gt1]) | |
| 114 | qed | |
| 14348 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 115 | qed | 
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 116 | |
| 14577 | 117 | text{*Surely we can strengthen this? It holds for @{text "0<a<1"} too.*}
 | 
| 14348 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 118 | lemma power_inject_exp [simp]: | 
| 15004 | 119 |      "1 < (a::'a::{ordered_semidom,recpower}) ==> (a^m = a^n) = (m=n)"
 | 
| 14577 | 120 | by (force simp add: order_antisym power_le_imp_le_exp) | 
| 14348 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 121 | |
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 122 | text{*Can relax the first premise to @{term "0<a"} in the case of the
 | 
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 123 | natural numbers.*} | 
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 124 | lemma power_less_imp_less_exp: | 
| 15004 | 125 |      "[| (1::'a::{recpower,ordered_semidom}) < a; a^m < a^n |] ==> m < n"
 | 
| 14577 | 126 | by (simp add: order_less_le [of m n] order_less_le [of "a^m" "a^n"] | 
| 127 | power_le_imp_le_exp) | |
| 14348 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 128 | |
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 129 | |
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 130 | lemma power_mono: | 
| 15004 | 131 |      "[|a \<le> b; (0::'a::{recpower,ordered_semidom}) \<le> a|] ==> a^n \<le> b^n"
 | 
| 15251 | 132 | apply (induct "n") | 
| 14348 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 133 | apply (simp_all add: power_Suc) | 
| 25874 | 134 | apply (auto intro: mult_mono order_trans [of 0 a b]) | 
| 14348 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 135 | done | 
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 136 | |
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 137 | lemma power_strict_mono [rule_format]: | 
| 15004 | 138 |      "[|a < b; (0::'a::{recpower,ordered_semidom}) \<le> a|]
 | 
| 14577 | 139 | ==> 0 < n --> a^n < b^n" | 
| 15251 | 140 | apply (induct "n") | 
| 25874 | 141 | apply (auto simp add: mult_strict_mono power_Suc | 
| 14348 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 142 | order_le_less_trans [of 0 a b]) | 
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 143 | done | 
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 144 | |
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 145 | lemma power_eq_0_iff [simp]: | 
| 30056 | 146 | "(a^n = 0) \<longleftrightarrow> | 
| 147 |    (a = (0::'a::{mult_zero,zero_neq_one,no_zero_divisors,recpower}) & n\<noteq>0)"
 | |
| 15251 | 148 | apply (induct "n") | 
| 30056 | 149 | apply (auto simp add: power_Suc zero_neq_one [THEN not_sym] no_zero_divisors) | 
| 14348 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 150 | done | 
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 151 | |
| 30056 | 152 | |
| 25134 
3d4953e88449
Eliminated most of the neq0_conv occurrences. As a result, many
 nipkow parents: 
25062diff
changeset | 153 | lemma field_power_not_zero: | 
| 
3d4953e88449
Eliminated most of the neq0_conv occurrences. As a result, many
 nipkow parents: 
25062diff
changeset | 154 |   "a \<noteq> (0::'a::{ring_1_no_zero_divisors,recpower}) ==> a^n \<noteq> 0"
 | 
| 14348 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 155 | by force | 
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 156 | |
| 14353 
79f9fbef9106
Added lemmas to Ring_and_Field with slightly modified simplification rules
 paulson parents: 
14348diff
changeset | 157 | lemma nonzero_power_inverse: | 
| 22991 | 158 |   fixes a :: "'a::{division_ring,recpower}"
 | 
| 159 | shows "a \<noteq> 0 ==> inverse (a ^ n) = (inverse a) ^ n" | |
| 15251 | 160 | apply (induct "n") | 
| 22988 
f6b8184f5b4a
generalize some lemmas from field to division_ring
 huffman parents: 
22957diff
changeset | 161 | apply (auto simp add: power_Suc nonzero_inverse_mult_distrib power_commutes) | 
| 22991 | 162 | done (* TODO: reorient or rename to nonzero_inverse_power *) | 
| 14353 
79f9fbef9106
Added lemmas to Ring_and_Field with slightly modified simplification rules
 paulson parents: 
14348diff
changeset | 163 | |
| 14348 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 164 | text{*Perhaps these should be simprules.*}
 | 
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 165 | lemma power_inverse: | 
| 22991 | 166 |   fixes a :: "'a::{division_ring,division_by_zero,recpower}"
 | 
| 167 | shows "inverse (a ^ n) = (inverse a) ^ n" | |
| 168 | apply (cases "a = 0") | |
| 169 | apply (simp add: power_0_left) | |
| 170 | apply (simp add: nonzero_power_inverse) | |
| 171 | done (* TODO: reorient or rename to inverse_power *) | |
| 14348 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 172 | |
| 16775 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16733diff
changeset | 173 | lemma power_one_over: "1 / (a::'a::{field,division_by_zero,recpower})^n = 
 | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16733diff
changeset | 174 | (1 / a)^n" | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16733diff
changeset | 175 | apply (simp add: divide_inverse) | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16733diff
changeset | 176 | apply (rule power_inverse) | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16733diff
changeset | 177 | done | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16733diff
changeset | 178 | |
| 14577 | 179 | lemma nonzero_power_divide: | 
| 15004 | 180 |     "b \<noteq> 0 ==> (a/b) ^ n = ((a::'a::{field,recpower}) ^ n) / (b ^ n)"
 | 
| 14353 
79f9fbef9106
Added lemmas to Ring_and_Field with slightly modified simplification rules
 paulson parents: 
14348diff
changeset | 181 | by (simp add: divide_inverse power_mult_distrib nonzero_power_inverse) | 
| 
79f9fbef9106
Added lemmas to Ring_and_Field with slightly modified simplification rules
 paulson parents: 
14348diff
changeset | 182 | |
| 14577 | 183 | lemma power_divide: | 
| 15004 | 184 |     "(a/b) ^ n = ((a::'a::{field,division_by_zero,recpower}) ^ n / b ^ n)"
 | 
| 14353 
79f9fbef9106
Added lemmas to Ring_and_Field with slightly modified simplification rules
 paulson parents: 
14348diff
changeset | 185 | apply (case_tac "b=0", simp add: power_0_left) | 
| 14577 | 186 | apply (rule nonzero_power_divide) | 
| 187 | apply assumption | |
| 14353 
79f9fbef9106
Added lemmas to Ring_and_Field with slightly modified simplification rules
 paulson parents: 
14348diff
changeset | 188 | done | 
| 
79f9fbef9106
Added lemmas to Ring_and_Field with slightly modified simplification rules
 paulson parents: 
14348diff
changeset | 189 | |
| 15004 | 190 | lemma power_abs: "abs(a ^ n) = abs(a::'a::{ordered_idom,recpower}) ^ n"
 | 
| 15251 | 191 | apply (induct "n") | 
| 14348 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 192 | apply (auto simp add: power_Suc abs_mult) | 
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 193 | done | 
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 194 | |
| 24286 
7619080e49f0
ATP blacklisting is now in theory data, attribute noatp
 paulson parents: 
23544diff
changeset | 195 | lemma zero_less_power_abs_iff [simp,noatp]: | 
| 15004 | 196 |      "(0 < (abs a)^n) = (a \<noteq> (0::'a::{ordered_idom,recpower}) | n=0)"
 | 
| 14353 
79f9fbef9106
Added lemmas to Ring_and_Field with slightly modified simplification rules
 paulson parents: 
14348diff
changeset | 197 | proof (induct "n") | 
| 
79f9fbef9106
Added lemmas to Ring_and_Field with slightly modified simplification rules
 paulson parents: 
14348diff
changeset | 198 | case 0 | 
| 
79f9fbef9106
Added lemmas to Ring_and_Field with slightly modified simplification rules
 paulson parents: 
14348diff
changeset | 199 | show ?case by (simp add: zero_less_one) | 
| 
79f9fbef9106
Added lemmas to Ring_and_Field with slightly modified simplification rules
 paulson parents: 
14348diff
changeset | 200 | next | 
| 
79f9fbef9106
Added lemmas to Ring_and_Field with slightly modified simplification rules
 paulson parents: 
14348diff
changeset | 201 | case (Suc n) | 
| 25231 | 202 | show ?case by (auto simp add: prems power_Suc zero_less_mult_iff | 
| 203 | abs_zero) | |
| 14353 
79f9fbef9106
Added lemmas to Ring_and_Field with slightly modified simplification rules
 paulson parents: 
14348diff
changeset | 204 | qed | 
| 
79f9fbef9106
Added lemmas to Ring_and_Field with slightly modified simplification rules
 paulson parents: 
14348diff
changeset | 205 | |
| 
79f9fbef9106
Added lemmas to Ring_and_Field with slightly modified simplification rules
 paulson parents: 
14348diff
changeset | 206 | lemma zero_le_power_abs [simp]: | 
| 15004 | 207 |      "(0::'a::{ordered_idom,recpower}) \<le> (abs a)^n"
 | 
| 22957 | 208 | by (rule zero_le_power [OF abs_ge_zero]) | 
| 14353 
79f9fbef9106
Added lemmas to Ring_and_Field with slightly modified simplification rules
 paulson parents: 
14348diff
changeset | 209 | |
| 28131 
3130d7b3149d
add lemma power_Suc2; generalize power_minus from class comm_ring_1 to ring_1
 huffman parents: 
25874diff
changeset | 210 | lemma power_minus: "(-a) ^ n = (- 1)^n * (a::'a::{ring_1,recpower}) ^ n"
 | 
| 
3130d7b3149d
add lemma power_Suc2; generalize power_minus from class comm_ring_1 to ring_1
 huffman parents: 
25874diff
changeset | 211 | proof (induct n) | 
| 
3130d7b3149d
add lemma power_Suc2; generalize power_minus from class comm_ring_1 to ring_1
 huffman parents: 
25874diff
changeset | 212 | case 0 show ?case by simp | 
| 
3130d7b3149d
add lemma power_Suc2; generalize power_minus from class comm_ring_1 to ring_1
 huffman parents: 
25874diff
changeset | 213 | next | 
| 
3130d7b3149d
add lemma power_Suc2; generalize power_minus from class comm_ring_1 to ring_1
 huffman parents: 
25874diff
changeset | 214 | case (Suc n) then show ?case | 
| 
3130d7b3149d
add lemma power_Suc2; generalize power_minus from class comm_ring_1 to ring_1
 huffman parents: 
25874diff
changeset | 215 | by (simp add: power_Suc2 mult_assoc) | 
| 14348 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 216 | qed | 
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 217 | |
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 218 | text{*Lemma for @{text power_strict_decreasing}*}
 | 
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 219 | lemma power_Suc_less: | 
| 15004 | 220 |      "[|(0::'a::{ordered_semidom,recpower}) < a; a < 1|]
 | 
| 14348 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 221 | ==> a * a^n < a^n" | 
| 15251 | 222 | apply (induct n) | 
| 14577 | 223 | apply (auto simp add: power_Suc mult_strict_left_mono) | 
| 14348 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 224 | done | 
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 225 | |
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 226 | lemma power_strict_decreasing: | 
| 15004 | 227 |      "[|n < N; 0 < a; a < (1::'a::{ordered_semidom,recpower})|]
 | 
| 14348 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 228 | ==> a^N < a^n" | 
| 14577 | 229 | apply (erule rev_mp) | 
| 15251 | 230 | apply (induct "N") | 
| 14577 | 231 | apply (auto simp add: power_Suc power_Suc_less less_Suc_eq) | 
| 232 | apply (rename_tac m) | |
| 14348 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 233 | apply (subgoal_tac "a * a^m < 1 * a^n", simp) | 
| 14577 | 234 | apply (rule mult_strict_mono) | 
| 25874 | 235 | apply (auto simp add: zero_less_one order_less_imp_le) | 
| 14348 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 236 | done | 
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 237 | |
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 238 | text{*Proof resembles that of @{text power_strict_decreasing}*}
 | 
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 239 | lemma power_decreasing: | 
| 15004 | 240 |      "[|n \<le> N; 0 \<le> a; a \<le> (1::'a::{ordered_semidom,recpower})|]
 | 
| 14348 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 241 | ==> a^N \<le> a^n" | 
| 14577 | 242 | apply (erule rev_mp) | 
| 15251 | 243 | apply (induct "N") | 
| 14577 | 244 | apply (auto simp add: power_Suc le_Suc_eq) | 
| 245 | apply (rename_tac m) | |
| 14348 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 246 | apply (subgoal_tac "a * a^m \<le> 1 * a^n", simp) | 
| 14577 | 247 | apply (rule mult_mono) | 
| 25874 | 248 | apply (auto simp add: zero_le_one) | 
| 14348 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 249 | done | 
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 250 | |
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 251 | lemma power_Suc_less_one: | 
| 15004 | 252 |      "[| 0 < a; a < (1::'a::{ordered_semidom,recpower}) |] ==> a ^ Suc n < 1"
 | 
| 14577 | 253 | apply (insert power_strict_decreasing [of 0 "Suc n" a], simp) | 
| 14348 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 254 | done | 
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 255 | |
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 256 | text{*Proof again resembles that of @{text power_strict_decreasing}*}
 | 
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 257 | lemma power_increasing: | 
| 15004 | 258 |      "[|n \<le> N; (1::'a::{ordered_semidom,recpower}) \<le> a|] ==> a^n \<le> a^N"
 | 
| 14577 | 259 | apply (erule rev_mp) | 
| 15251 | 260 | apply (induct "N") | 
| 14577 | 261 | apply (auto simp add: power_Suc le_Suc_eq) | 
| 14348 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 262 | apply (rename_tac m) | 
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 263 | apply (subgoal_tac "1 * a^n \<le> a * a^m", simp) | 
| 14577 | 264 | apply (rule mult_mono) | 
| 25874 | 265 | apply (auto simp add: order_trans [OF zero_le_one]) | 
| 14348 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 266 | done | 
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 267 | |
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 268 | text{*Lemma for @{text power_strict_increasing}*}
 | 
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 269 | lemma power_less_power_Suc: | 
| 15004 | 270 |      "(1::'a::{ordered_semidom,recpower}) < a ==> a^n < a * a^n"
 | 
| 15251 | 271 | apply (induct n) | 
| 14577 | 272 | apply (auto simp add: power_Suc mult_strict_left_mono order_less_trans [OF zero_less_one]) | 
| 14348 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 273 | done | 
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 274 | |
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 275 | lemma power_strict_increasing: | 
| 15004 | 276 |      "[|n < N; (1::'a::{ordered_semidom,recpower}) < a|] ==> a^n < a^N"
 | 
| 14577 | 277 | apply (erule rev_mp) | 
| 15251 | 278 | apply (induct "N") | 
| 14577 | 279 | apply (auto simp add: power_less_power_Suc power_Suc less_Suc_eq) | 
| 14348 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 280 | apply (rename_tac m) | 
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 281 | apply (subgoal_tac "1 * a^n < a * a^m", simp) | 
| 14577 | 282 | apply (rule mult_strict_mono) | 
| 25874 | 283 | apply (auto simp add: order_less_trans [OF zero_less_one] order_less_imp_le) | 
| 14348 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 284 | done | 
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 285 | |
| 25134 
3d4953e88449
Eliminated most of the neq0_conv occurrences. As a result, many
 nipkow parents: 
25062diff
changeset | 286 | lemma power_increasing_iff [simp]: | 
| 
3d4953e88449
Eliminated most of the neq0_conv occurrences. As a result, many
 nipkow parents: 
25062diff
changeset | 287 |   "1 < (b::'a::{ordered_semidom,recpower}) ==> (b ^ x \<le> b ^ y) = (x \<le> y)"
 | 
| 
3d4953e88449
Eliminated most of the neq0_conv occurrences. As a result, many
 nipkow parents: 
25062diff
changeset | 288 | by (blast intro: power_le_imp_le_exp power_increasing order_less_imp_le) | 
| 15066 | 289 | |
| 290 | lemma power_strict_increasing_iff [simp]: | |
| 25134 
3d4953e88449
Eliminated most of the neq0_conv occurrences. As a result, many
 nipkow parents: 
25062diff
changeset | 291 |   "1 < (b::'a::{ordered_semidom,recpower}) ==> (b ^ x < b ^ y) = (x < y)"
 | 
| 
3d4953e88449
Eliminated most of the neq0_conv occurrences. As a result, many
 nipkow parents: 
25062diff
changeset | 292 | by (blast intro: power_less_imp_less_exp power_strict_increasing) | 
| 15066 | 293 | |
| 14348 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 294 | lemma power_le_imp_le_base: | 
| 25134 
3d4953e88449
Eliminated most of the neq0_conv occurrences. As a result, many
 nipkow parents: 
25062diff
changeset | 295 | assumes le: "a ^ Suc n \<le> b ^ Suc n" | 
| 
3d4953e88449
Eliminated most of the neq0_conv occurrences. As a result, many
 nipkow parents: 
25062diff
changeset | 296 |     and ynonneg: "(0::'a::{ordered_semidom,recpower}) \<le> b"
 | 
| 
3d4953e88449
Eliminated most of the neq0_conv occurrences. As a result, many
 nipkow parents: 
25062diff
changeset | 297 | shows "a \<le> b" | 
| 
3d4953e88449
Eliminated most of the neq0_conv occurrences. As a result, many
 nipkow parents: 
25062diff
changeset | 298 | proof (rule ccontr) | 
| 
3d4953e88449
Eliminated most of the neq0_conv occurrences. As a result, many
 nipkow parents: 
25062diff
changeset | 299 | assume "~ a \<le> b" | 
| 
3d4953e88449
Eliminated most of the neq0_conv occurrences. As a result, many
 nipkow parents: 
25062diff
changeset | 300 | then have "b < a" by (simp only: linorder_not_le) | 
| 
3d4953e88449
Eliminated most of the neq0_conv occurrences. As a result, many
 nipkow parents: 
25062diff
changeset | 301 | then have "b ^ Suc n < a ^ Suc n" | 
| 
3d4953e88449
Eliminated most of the neq0_conv occurrences. As a result, many
 nipkow parents: 
25062diff
changeset | 302 | by (simp only: prems power_strict_mono) | 
| 
3d4953e88449
Eliminated most of the neq0_conv occurrences. As a result, many
 nipkow parents: 
25062diff
changeset | 303 | from le and this show "False" | 
| 
3d4953e88449
Eliminated most of the neq0_conv occurrences. As a result, many
 nipkow parents: 
25062diff
changeset | 304 | by (simp add: linorder_not_less [symmetric]) | 
| 
3d4953e88449
Eliminated most of the neq0_conv occurrences. As a result, many
 nipkow parents: 
25062diff
changeset | 305 | qed | 
| 14577 | 306 | |
| 22853 | 307 | lemma power_less_imp_less_base: | 
| 308 |   fixes a b :: "'a::{ordered_semidom,recpower}"
 | |
| 309 | assumes less: "a ^ n < b ^ n" | |
| 310 | assumes nonneg: "0 \<le> b" | |
| 311 | shows "a < b" | |
| 312 | proof (rule contrapos_pp [OF less]) | |
| 313 | assume "~ a < b" | |
| 314 | hence "b \<le> a" by (simp only: linorder_not_less) | |
| 315 | hence "b ^ n \<le> a ^ n" using nonneg by (rule power_mono) | |
| 316 | thus "~ a ^ n < b ^ n" by (simp only: linorder_not_less) | |
| 317 | qed | |
| 318 | ||
| 14348 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 319 | lemma power_inject_base: | 
| 14577 | 320 | "[| a ^ Suc n = b ^ Suc n; 0 \<le> a; 0 \<le> b |] | 
| 15004 | 321 |       ==> a = (b::'a::{ordered_semidom,recpower})"
 | 
| 14348 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 322 | by (blast intro: power_le_imp_le_base order_antisym order_eq_refl sym) | 
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 323 | |
| 22955 | 324 | lemma power_eq_imp_eq_base: | 
| 325 |   fixes a b :: "'a::{ordered_semidom,recpower}"
 | |
| 326 | shows "\<lbrakk>a ^ n = b ^ n; 0 \<le> a; 0 \<le> b; 0 < n\<rbrakk> \<Longrightarrow> a = b" | |
| 327 | by (cases n, simp_all, rule power_inject_base) | |
| 328 | ||
| 29978 
33df3c4eb629
generalize le_imp_power_dvd and power_le_dvd; move from Divides to Power
 huffman parents: 
29608diff
changeset | 329 | text {* The divides relation *}
 | 
| 
33df3c4eb629
generalize le_imp_power_dvd and power_le_dvd; move from Divides to Power
 huffman parents: 
29608diff
changeset | 330 | |
| 
33df3c4eb629
generalize le_imp_power_dvd and power_le_dvd; move from Divides to Power
 huffman parents: 
29608diff
changeset | 331 | lemma le_imp_power_dvd: | 
| 
33df3c4eb629
generalize le_imp_power_dvd and power_le_dvd; move from Divides to Power
 huffman parents: 
29608diff
changeset | 332 |   fixes a :: "'a::{comm_semiring_1,recpower}"
 | 
| 
33df3c4eb629
generalize le_imp_power_dvd and power_le_dvd; move from Divides to Power
 huffman parents: 
29608diff
changeset | 333 | assumes "m \<le> n" shows "a^m dvd a^n" | 
| 
33df3c4eb629
generalize le_imp_power_dvd and power_le_dvd; move from Divides to Power
 huffman parents: 
29608diff
changeset | 334 | proof | 
| 
33df3c4eb629
generalize le_imp_power_dvd and power_le_dvd; move from Divides to Power
 huffman parents: 
29608diff
changeset | 335 | have "a^n = a^(m + (n - m))" | 
| 
33df3c4eb629
generalize le_imp_power_dvd and power_le_dvd; move from Divides to Power
 huffman parents: 
29608diff
changeset | 336 | using `m \<le> n` by simp | 
| 
33df3c4eb629
generalize le_imp_power_dvd and power_le_dvd; move from Divides to Power
 huffman parents: 
29608diff
changeset | 337 | also have "\<dots> = a^m * a^(n - m)" | 
| 
33df3c4eb629
generalize le_imp_power_dvd and power_le_dvd; move from Divides to Power
 huffman parents: 
29608diff
changeset | 338 | by (rule power_add) | 
| 
33df3c4eb629
generalize le_imp_power_dvd and power_le_dvd; move from Divides to Power
 huffman parents: 
29608diff
changeset | 339 | finally show "a^n = a^m * a^(n - m)" . | 
| 
33df3c4eb629
generalize le_imp_power_dvd and power_le_dvd; move from Divides to Power
 huffman parents: 
29608diff
changeset | 340 | qed | 
| 
33df3c4eb629
generalize le_imp_power_dvd and power_le_dvd; move from Divides to Power
 huffman parents: 
29608diff
changeset | 341 | |
| 
33df3c4eb629
generalize le_imp_power_dvd and power_le_dvd; move from Divides to Power
 huffman parents: 
29608diff
changeset | 342 | lemma power_le_dvd: | 
| 
33df3c4eb629
generalize le_imp_power_dvd and power_le_dvd; move from Divides to Power
 huffman parents: 
29608diff
changeset | 343 |   fixes a b :: "'a::{comm_semiring_1,recpower}"
 | 
| 
33df3c4eb629
generalize le_imp_power_dvd and power_le_dvd; move from Divides to Power
 huffman parents: 
29608diff
changeset | 344 | shows "a^n dvd b \<Longrightarrow> m \<le> n \<Longrightarrow> a^m dvd b" | 
| 
33df3c4eb629
generalize le_imp_power_dvd and power_le_dvd; move from Divides to Power
 huffman parents: 
29608diff
changeset | 345 | by (rule dvd_trans [OF le_imp_power_dvd]) | 
| 
33df3c4eb629
generalize le_imp_power_dvd and power_le_dvd; move from Divides to Power
 huffman parents: 
29608diff
changeset | 346 | |
| 14348 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 347 | |
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 348 | subsection{*Exponentiation for the Natural Numbers*}
 | 
| 3390 
0c7625196d95
New theory "Power" of exponentiation (and binomial coefficients)
 paulson parents: diff
changeset | 349 | |
| 25836 | 350 | instantiation nat :: recpower | 
| 351 | begin | |
| 21456 | 352 | |
| 25836 | 353 | primrec power_nat where | 
| 354 | "p ^ 0 = (1\<Colon>nat)" | |
| 355 | | "p ^ (Suc n) = (p\<Colon>nat) * (p ^ n)" | |
| 14577 | 356 | |
| 25836 | 357 | instance proof | 
| 14438 | 358 | fix z n :: nat | 
| 14348 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 359 | show "z^0 = 1" by simp | 
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 360 | show "z^(Suc n) = z * (z^n)" by simp | 
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 361 | qed | 
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 362 | |
| 25836 | 363 | end | 
| 364 | ||
| 23305 | 365 | lemma of_nat_power: | 
| 366 |   "of_nat (m ^ n) = (of_nat m::'a::{semiring_1,recpower}) ^ n"
 | |
| 23431 
25ca91279a9b
change simp rules for of_nat to work like int did previously (reorient of_nat_Suc, remove of_nat_mult [simp]); preserve original variable names in legacy int theorems
 huffman parents: 
23305diff
changeset | 367 | by (induct n, simp_all add: power_Suc of_nat_mult) | 
| 23305 | 368 | |
| 30079 
293b896b9c25
make proofs work whether or not One_nat_def is a simp rule; replace 1 with Suc 0 in the rhs of some simp rules
 huffman parents: 
30056diff
changeset | 369 | lemma nat_one_le_power [simp]: "Suc 0 \<le> i ==> Suc 0 \<le> i^n" | 
| 
293b896b9c25
make proofs work whether or not One_nat_def is a simp rule; replace 1 with Suc 0 in the rhs of some simp rules
 huffman parents: 
30056diff
changeset | 370 | by (rule one_le_power [of i n, unfolded One_nat_def]) | 
| 14348 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 371 | |
| 25162 | 372 | lemma nat_zero_less_power_iff [simp]: "(x^n > 0) = (x > (0::nat) | n=0)" | 
| 21413 | 373 | by (induct "n", auto) | 
| 14348 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 374 | |
| 30056 | 375 | lemma nat_power_eq_Suc_0_iff [simp]: | 
| 376 | "((x::nat)^m = Suc 0) = (m = 0 | x = Suc 0)" | |
| 377 | by (induct_tac m, auto) | |
| 378 | ||
| 379 | lemma power_Suc_0[simp]: "(Suc 0)^n = Suc 0" | |
| 380 | by simp | |
| 381 | ||
| 14348 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 382 | text{*Valid for the naturals, but what if @{text"0<i<1"}?
 | 
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 383 | Premises cannot be weakened: consider the case where @{term "i=0"},
 | 
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 384 | @{term "m=1"} and @{term "n=0"}.*}
 | 
| 21413 | 385 | lemma nat_power_less_imp_less: | 
| 386 | assumes nonneg: "0 < (i\<Colon>nat)" | |
| 387 | assumes less: "i^m < i^n" | |
| 388 | shows "m < n" | |
| 389 | proof (cases "i = 1") | |
| 390 | case True with less power_one [where 'a = nat] show ?thesis by simp | |
| 391 | next | |
| 392 | case False with nonneg have "1 < i" by auto | |
| 393 | from power_strict_increasing_iff [OF this] less show ?thesis .. | |
| 394 | qed | |
| 14348 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 395 | |
| 17149 
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
 ballarin parents: 
16796diff
changeset | 396 | lemma power_diff: | 
| 
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
 ballarin parents: 
16796diff
changeset | 397 | assumes nz: "a ~= 0" | 
| 
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
 ballarin parents: 
16796diff
changeset | 398 |   shows "n <= m ==> (a::'a::{recpower, field}) ^ (m-n) = (a^m) / (a^n)"
 | 
| 
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
 ballarin parents: 
16796diff
changeset | 399 | by (induct m n rule: diff_induct) | 
| 
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
 ballarin parents: 
16796diff
changeset | 400 | (simp_all add: power_Suc nonzero_mult_divide_cancel_left nz) | 
| 
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
 ballarin parents: 
16796diff
changeset | 401 | |
| 
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
 ballarin parents: 
16796diff
changeset | 402 | |
| 14348 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 403 | text{*ML bindings for the general exponentiation theorems*}
 | 
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 404 | ML | 
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 405 | {*
 | 
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 406 | val power_0 = thm"power_0"; | 
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 407 | val power_Suc = thm"power_Suc"; | 
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 408 | val power_0_Suc = thm"power_0_Suc"; | 
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 409 | val power_0_left = thm"power_0_left"; | 
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 410 | val power_one = thm"power_one"; | 
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 411 | val power_one_right = thm"power_one_right"; | 
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 412 | val power_add = thm"power_add"; | 
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 413 | val power_mult = thm"power_mult"; | 
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 414 | val power_mult_distrib = thm"power_mult_distrib"; | 
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 415 | val zero_less_power = thm"zero_less_power"; | 
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 416 | val zero_le_power = thm"zero_le_power"; | 
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 417 | val one_le_power = thm"one_le_power"; | 
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 418 | val gt1_imp_ge0 = thm"gt1_imp_ge0"; | 
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 419 | val power_gt1_lemma = thm"power_gt1_lemma"; | 
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 420 | val power_gt1 = thm"power_gt1"; | 
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 421 | val power_le_imp_le_exp = thm"power_le_imp_le_exp"; | 
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 422 | val power_inject_exp = thm"power_inject_exp"; | 
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 423 | val power_less_imp_less_exp = thm"power_less_imp_less_exp"; | 
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 424 | val power_mono = thm"power_mono"; | 
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 425 | val power_strict_mono = thm"power_strict_mono"; | 
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 426 | val power_eq_0_iff = thm"power_eq_0_iff"; | 
| 25134 
3d4953e88449
Eliminated most of the neq0_conv occurrences. As a result, many
 nipkow parents: 
25062diff
changeset | 427 | val field_power_eq_0_iff = thm"power_eq_0_iff"; | 
| 14348 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 428 | val field_power_not_zero = thm"field_power_not_zero"; | 
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 429 | val power_inverse = thm"power_inverse"; | 
| 14353 
79f9fbef9106
Added lemmas to Ring_and_Field with slightly modified simplification rules
 paulson parents: 
14348diff
changeset | 430 | val nonzero_power_divide = thm"nonzero_power_divide"; | 
| 
79f9fbef9106
Added lemmas to Ring_and_Field with slightly modified simplification rules
 paulson parents: 
14348diff
changeset | 431 | val power_divide = thm"power_divide"; | 
| 14348 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 432 | val power_abs = thm"power_abs"; | 
| 14353 
79f9fbef9106
Added lemmas to Ring_and_Field with slightly modified simplification rules
 paulson parents: 
14348diff
changeset | 433 | val zero_less_power_abs_iff = thm"zero_less_power_abs_iff"; | 
| 
79f9fbef9106
Added lemmas to Ring_and_Field with slightly modified simplification rules
 paulson parents: 
14348diff
changeset | 434 | val zero_le_power_abs = thm "zero_le_power_abs"; | 
| 14348 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 435 | val power_minus = thm"power_minus"; | 
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 436 | val power_Suc_less = thm"power_Suc_less"; | 
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 437 | val power_strict_decreasing = thm"power_strict_decreasing"; | 
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 438 | val power_decreasing = thm"power_decreasing"; | 
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 439 | val power_Suc_less_one = thm"power_Suc_less_one"; | 
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 440 | val power_increasing = thm"power_increasing"; | 
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 441 | val power_strict_increasing = thm"power_strict_increasing"; | 
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 442 | val power_le_imp_le_base = thm"power_le_imp_le_base"; | 
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 443 | val power_inject_base = thm"power_inject_base"; | 
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 444 | *} | 
| 14577 | 445 | |
| 14348 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 446 | text{*ML bindings for the remaining theorems*}
 | 
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 447 | ML | 
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 448 | {*
 | 
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 449 | val nat_one_le_power = thm"nat_one_le_power"; | 
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 450 | val nat_power_less_imp_less = thm"nat_power_less_imp_less"; | 
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 451 | val nat_zero_less_power_iff = thm"nat_zero_less_power_iff"; | 
| 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
8844diff
changeset | 452 | *} | 
| 3390 
0c7625196d95
New theory "Power" of exponentiation (and binomial coefficients)
 paulson parents: diff
changeset | 453 | |
| 
0c7625196d95
New theory "Power" of exponentiation (and binomial coefficients)
 paulson parents: diff
changeset | 454 | end |