src/HOL/Power.thy
changeset 15004 44ac09ba7213
parent 14738 83f1a514dcb4
child 15066 d2f2b908e0a4
     1.1 --- a/src/HOL/Power.thy	Thu Jun 24 17:52:02 2004 +0200
     1.2 +++ b/src/HOL/Power.thy	Thu Jun 24 17:52:55 2004 +0200
     1.3 @@ -11,55 +11,55 @@
     1.4  
     1.5  subsection{*Powers for Arbitrary (Semi)Rings*}
     1.6  
     1.7 -axclass ringpower \<subseteq> comm_semiring_1_cancel, power
     1.8 -  power_0 [simp]:   "a ^ 0       = 1"
     1.9 -  power_Suc: "a ^ (Suc n) = a * (a ^ n)"
    1.10 +axclass recpower \<subseteq> comm_semiring_1_cancel, power
    1.11 +  power_0 [simp]: "a ^ 0       = 1"
    1.12 +  power_Suc:      "a ^ (Suc n) = a * (a ^ n)"
    1.13  
    1.14 -lemma power_0_Suc [simp]: "(0::'a::ringpower) ^ (Suc n) = 0"
    1.15 +lemma power_0_Suc [simp]: "(0::'a::recpower) ^ (Suc n) = 0"
    1.16  by (simp add: power_Suc)
    1.17  
    1.18  text{*It looks plausible as a simprule, but its effect can be strange.*}
    1.19 -lemma power_0_left: "0^n = (if n=0 then 1 else (0::'a::ringpower))"
    1.20 +lemma power_0_left: "0^n = (if n=0 then 1 else (0::'a::recpower))"
    1.21  by (induct_tac "n", auto)
    1.22  
    1.23 -lemma power_one [simp]: "1^n = (1::'a::ringpower)"
    1.24 +lemma power_one [simp]: "1^n = (1::'a::recpower)"
    1.25  apply (induct_tac "n")
    1.26  apply (auto simp add: power_Suc)
    1.27  done
    1.28  
    1.29 -lemma power_one_right [simp]: "(a::'a::ringpower) ^ 1 = a"
    1.30 +lemma power_one_right [simp]: "(a::'a::recpower) ^ 1 = a"
    1.31  by (simp add: power_Suc)
    1.32  
    1.33 -lemma power_add: "(a::'a::ringpower) ^ (m+n) = (a^m) * (a^n)"
    1.34 +lemma power_add: "(a::'a::recpower) ^ (m+n) = (a^m) * (a^n)"
    1.35  apply (induct_tac "n")
    1.36  apply (simp_all add: power_Suc mult_ac)
    1.37  done
    1.38  
    1.39 -lemma power_mult: "(a::'a::ringpower) ^ (m*n) = (a^m) ^ n"
    1.40 +lemma power_mult: "(a::'a::recpower) ^ (m*n) = (a^m) ^ n"
    1.41  apply (induct_tac "n")
    1.42  apply (simp_all add: power_Suc power_add)
    1.43  done
    1.44  
    1.45 -lemma power_mult_distrib: "((a::'a::ringpower) * b) ^ n = (a^n) * (b^n)"
    1.46 +lemma power_mult_distrib: "((a::'a::recpower) * b) ^ n = (a^n) * (b^n)"
    1.47  apply (induct_tac "n")
    1.48  apply (auto simp add: power_Suc mult_ac)
    1.49  done
    1.50  
    1.51  lemma zero_less_power:
    1.52 -     "0 < (a::'a::{ordered_semidom,ringpower}) ==> 0 < a^n"
    1.53 +     "0 < (a::'a::{ordered_semidom,recpower}) ==> 0 < a^n"
    1.54  apply (induct_tac "n")
    1.55  apply (simp_all add: power_Suc zero_less_one mult_pos)
    1.56  done
    1.57  
    1.58  lemma zero_le_power:
    1.59 -     "0 \<le> (a::'a::{ordered_semidom,ringpower}) ==> 0 \<le> a^n"
    1.60 +     "0 \<le> (a::'a::{ordered_semidom,recpower}) ==> 0 \<le> a^n"
    1.61  apply (simp add: order_le_less)
    1.62  apply (erule disjE)
    1.63  apply (simp_all add: zero_less_power zero_less_one power_0_left)
    1.64  done
    1.65  
    1.66  lemma one_le_power:
    1.67 -     "1 \<le> (a::'a::{ordered_semidom,ringpower}) ==> 1 \<le> a^n"
    1.68 +     "1 \<le> (a::'a::{ordered_semidom,recpower}) ==> 1 \<le> a^n"
    1.69  apply (induct_tac "n")
    1.70  apply (simp_all add: power_Suc)
    1.71  apply (rule order_trans [OF _ mult_mono [of 1 _ 1]])
    1.72 @@ -70,7 +70,7 @@
    1.73    by (simp add: order_trans [OF zero_le_one order_less_imp_le])
    1.74  
    1.75  lemma power_gt1_lemma:
    1.76 -  assumes gt1: "1 < (a::'a::{ordered_semidom,ringpower})"
    1.77 +  assumes gt1: "1 < (a::'a::{ordered_semidom,recpower})"
    1.78    shows "1 < a * a^n"
    1.79  proof -
    1.80    have "1*1 < a*1" using gt1 by simp
    1.81 @@ -81,11 +81,11 @@
    1.82  qed
    1.83  
    1.84  lemma power_gt1:
    1.85 -     "1 < (a::'a::{ordered_semidom,ringpower}) ==> 1 < a ^ (Suc n)"
    1.86 +     "1 < (a::'a::{ordered_semidom,recpower}) ==> 1 < a ^ (Suc n)"
    1.87  by (simp add: power_gt1_lemma power_Suc)
    1.88  
    1.89  lemma power_le_imp_le_exp:
    1.90 -  assumes gt1: "(1::'a::{ringpower,ordered_semidom}) < a"
    1.91 +  assumes gt1: "(1::'a::{recpower,ordered_semidom}) < a"
    1.92    shows "!!n. a^m \<le> a^n ==> m \<le> n"
    1.93  proof (induct m)
    1.94    case 0
    1.95 @@ -109,26 +109,26 @@
    1.96  
    1.97  text{*Surely we can strengthen this? It holds for @{text "0<a<1"} too.*}
    1.98  lemma power_inject_exp [simp]:
    1.99 -     "1 < (a::'a::{ordered_semidom,ringpower}) ==> (a^m = a^n) = (m=n)"
   1.100 +     "1 < (a::'a::{ordered_semidom,recpower}) ==> (a^m = a^n) = (m=n)"
   1.101    by (force simp add: order_antisym power_le_imp_le_exp)
   1.102  
   1.103  text{*Can relax the first premise to @{term "0<a"} in the case of the
   1.104  natural numbers.*}
   1.105  lemma power_less_imp_less_exp:
   1.106 -     "[| (1::'a::{ringpower,ordered_semidom}) < a; a^m < a^n |] ==> m < n"
   1.107 +     "[| (1::'a::{recpower,ordered_semidom}) < a; a^m < a^n |] ==> m < n"
   1.108  by (simp add: order_less_le [of m n] order_less_le [of "a^m" "a^n"]
   1.109                power_le_imp_le_exp)
   1.110  
   1.111  
   1.112  lemma power_mono:
   1.113 -     "[|a \<le> b; (0::'a::{ringpower,ordered_semidom}) \<le> a|] ==> a^n \<le> b^n"
   1.114 +     "[|a \<le> b; (0::'a::{recpower,ordered_semidom}) \<le> a|] ==> a^n \<le> b^n"
   1.115  apply (induct_tac "n")
   1.116  apply (simp_all add: power_Suc)
   1.117  apply (auto intro: mult_mono zero_le_power order_trans [of 0 a b])
   1.118  done
   1.119  
   1.120  lemma power_strict_mono [rule_format]:
   1.121 -     "[|a < b; (0::'a::{ringpower,ordered_semidom}) \<le> a|]
   1.122 +     "[|a < b; (0::'a::{recpower,ordered_semidom}) \<le> a|]
   1.123        ==> 0 < n --> a^n < b^n"
   1.124  apply (induct_tac "n")
   1.125  apply (auto simp add: mult_strict_mono zero_le_power power_Suc
   1.126 @@ -136,51 +136,51 @@
   1.127  done
   1.128  
   1.129  lemma power_eq_0_iff [simp]:
   1.130 -     "(a^n = 0) = (a = (0::'a::{ordered_idom,ringpower}) & 0<n)"
   1.131 +     "(a^n = 0) = (a = (0::'a::{ordered_idom,recpower}) & 0<n)"
   1.132  apply (induct_tac "n")
   1.133  apply (auto simp add: power_Suc zero_neq_one [THEN not_sym])
   1.134  done
   1.135  
   1.136  lemma field_power_eq_0_iff [simp]:
   1.137 -     "(a^n = 0) = (a = (0::'a::{field,ringpower}) & 0<n)"
   1.138 +     "(a^n = 0) = (a = (0::'a::{field,recpower}) & 0<n)"
   1.139  apply (induct_tac "n")
   1.140  apply (auto simp add: power_Suc field_mult_eq_0_iff zero_neq_one[THEN not_sym])
   1.141  done
   1.142  
   1.143 -lemma field_power_not_zero: "a \<noteq> (0::'a::{field,ringpower}) ==> a^n \<noteq> 0"
   1.144 +lemma field_power_not_zero: "a \<noteq> (0::'a::{field,recpower}) ==> a^n \<noteq> 0"
   1.145  by force
   1.146  
   1.147  lemma nonzero_power_inverse:
   1.148 -  "a \<noteq> 0 ==> inverse ((a::'a::{field,ringpower}) ^ n) = (inverse a) ^ n"
   1.149 +  "a \<noteq> 0 ==> inverse ((a::'a::{field,recpower}) ^ n) = (inverse a) ^ n"
   1.150  apply (induct_tac "n")
   1.151  apply (auto simp add: power_Suc nonzero_inverse_mult_distrib mult_commute)
   1.152  done
   1.153  
   1.154  text{*Perhaps these should be simprules.*}
   1.155  lemma power_inverse:
   1.156 -  "inverse ((a::'a::{field,division_by_zero,ringpower}) ^ n) = (inverse a) ^ n"
   1.157 +  "inverse ((a::'a::{field,division_by_zero,recpower}) ^ n) = (inverse a) ^ n"
   1.158  apply (induct_tac "n")
   1.159  apply (auto simp add: power_Suc inverse_mult_distrib)
   1.160  done
   1.161  
   1.162  lemma nonzero_power_divide:
   1.163 -    "b \<noteq> 0 ==> (a/b) ^ n = ((a::'a::{field,ringpower}) ^ n) / (b ^ n)"
   1.164 +    "b \<noteq> 0 ==> (a/b) ^ n = ((a::'a::{field,recpower}) ^ n) / (b ^ n)"
   1.165  by (simp add: divide_inverse power_mult_distrib nonzero_power_inverse)
   1.166  
   1.167  lemma power_divide:
   1.168 -    "(a/b) ^ n = ((a::'a::{field,division_by_zero,ringpower}) ^ n / b ^ n)"
   1.169 +    "(a/b) ^ n = ((a::'a::{field,division_by_zero,recpower}) ^ n / b ^ n)"
   1.170  apply (case_tac "b=0", simp add: power_0_left)
   1.171  apply (rule nonzero_power_divide)
   1.172  apply assumption
   1.173  done
   1.174  
   1.175 -lemma power_abs: "abs(a ^ n) = abs(a::'a::{ordered_idom,ringpower}) ^ n"
   1.176 +lemma power_abs: "abs(a ^ n) = abs(a::'a::{ordered_idom,recpower}) ^ n"
   1.177  apply (induct_tac "n")
   1.178  apply (auto simp add: power_Suc abs_mult)
   1.179  done
   1.180  
   1.181  lemma zero_less_power_abs_iff [simp]:
   1.182 -     "(0 < (abs a)^n) = (a \<noteq> (0::'a::{ordered_idom,ringpower}) | n=0)"
   1.183 +     "(0 < (abs a)^n) = (a \<noteq> (0::'a::{ordered_idom,recpower}) | n=0)"
   1.184  proof (induct "n")
   1.185    case 0
   1.186      show ?case by (simp add: zero_less_one)
   1.187 @@ -190,12 +190,12 @@
   1.188  qed
   1.189  
   1.190  lemma zero_le_power_abs [simp]:
   1.191 -     "(0::'a::{ordered_idom,ringpower}) \<le> (abs a)^n"
   1.192 +     "(0::'a::{ordered_idom,recpower}) \<le> (abs a)^n"
   1.193  apply (induct_tac "n")
   1.194  apply (auto simp add: zero_le_one zero_le_power)
   1.195  done
   1.196  
   1.197 -lemma power_minus: "(-a) ^ n = (- 1)^n * (a::'a::{comm_ring_1,ringpower}) ^ n"
   1.198 +lemma power_minus: "(-a) ^ n = (- 1)^n * (a::'a::{comm_ring_1,recpower}) ^ n"
   1.199  proof -
   1.200    have "-a = (- 1) * a"  by (simp add: minus_mult_left [symmetric])
   1.201    thus ?thesis by (simp only: power_mult_distrib)
   1.202 @@ -203,14 +203,14 @@
   1.203  
   1.204  text{*Lemma for @{text power_strict_decreasing}*}
   1.205  lemma power_Suc_less:
   1.206 -     "[|(0::'a::{ordered_semidom,ringpower}) < a; a < 1|]
   1.207 +     "[|(0::'a::{ordered_semidom,recpower}) < a; a < 1|]
   1.208        ==> a * a^n < a^n"
   1.209  apply (induct_tac n)
   1.210  apply (auto simp add: power_Suc mult_strict_left_mono)
   1.211  done
   1.212  
   1.213  lemma power_strict_decreasing:
   1.214 -     "[|n < N; 0 < a; a < (1::'a::{ordered_semidom,ringpower})|]
   1.215 +     "[|n < N; 0 < a; a < (1::'a::{ordered_semidom,recpower})|]
   1.216        ==> a^N < a^n"
   1.217  apply (erule rev_mp)
   1.218  apply (induct_tac "N")
   1.219 @@ -223,7 +223,7 @@
   1.220  
   1.221  text{*Proof resembles that of @{text power_strict_decreasing}*}
   1.222  lemma power_decreasing:
   1.223 -     "[|n \<le> N; 0 \<le> a; a \<le> (1::'a::{ordered_semidom,ringpower})|]
   1.224 +     "[|n \<le> N; 0 \<le> a; a \<le> (1::'a::{ordered_semidom,recpower})|]
   1.225        ==> a^N \<le> a^n"
   1.226  apply (erule rev_mp)
   1.227  apply (induct_tac "N")
   1.228 @@ -235,13 +235,13 @@
   1.229  done
   1.230  
   1.231  lemma power_Suc_less_one:
   1.232 -     "[| 0 < a; a < (1::'a::{ordered_semidom,ringpower}) |] ==> a ^ Suc n < 1"
   1.233 +     "[| 0 < a; a < (1::'a::{ordered_semidom,recpower}) |] ==> a ^ Suc n < 1"
   1.234  apply (insert power_strict_decreasing [of 0 "Suc n" a], simp)
   1.235  done
   1.236  
   1.237  text{*Proof again resembles that of @{text power_strict_decreasing}*}
   1.238  lemma power_increasing:
   1.239 -     "[|n \<le> N; (1::'a::{ordered_semidom,ringpower}) \<le> a|] ==> a^n \<le> a^N"
   1.240 +     "[|n \<le> N; (1::'a::{ordered_semidom,recpower}) \<le> a|] ==> a^n \<le> a^N"
   1.241  apply (erule rev_mp)
   1.242  apply (induct_tac "N")
   1.243  apply (auto simp add: power_Suc le_Suc_eq)
   1.244 @@ -253,13 +253,13 @@
   1.245  
   1.246  text{*Lemma for @{text power_strict_increasing}*}
   1.247  lemma power_less_power_Suc:
   1.248 -     "(1::'a::{ordered_semidom,ringpower}) < a ==> a^n < a * a^n"
   1.249 +     "(1::'a::{ordered_semidom,recpower}) < a ==> a^n < a * a^n"
   1.250  apply (induct_tac n)
   1.251  apply (auto simp add: power_Suc mult_strict_left_mono order_less_trans [OF zero_less_one])
   1.252  done
   1.253  
   1.254  lemma power_strict_increasing:
   1.255 -     "[|n < N; (1::'a::{ordered_semidom,ringpower}) < a|] ==> a^n < a^N"
   1.256 +     "[|n < N; (1::'a::{ordered_semidom,recpower}) < a|] ==> a^n < a^N"
   1.257  apply (erule rev_mp)
   1.258  apply (induct_tac "N")
   1.259  apply (auto simp add: power_less_power_Suc power_Suc less_Suc_eq)
   1.260 @@ -272,7 +272,7 @@
   1.261  
   1.262  lemma power_le_imp_le_base:
   1.263    assumes le: "a ^ Suc n \<le> b ^ Suc n"
   1.264 -      and xnonneg: "(0::'a::{ordered_semidom,ringpower}) \<le> a"
   1.265 +      and xnonneg: "(0::'a::{ordered_semidom,recpower}) \<le> a"
   1.266        and ynonneg: "0 \<le> b"
   1.267    shows "a \<le> b"
   1.268   proof (rule ccontr)
   1.269 @@ -286,7 +286,7 @@
   1.270  
   1.271  lemma power_inject_base:
   1.272       "[| a ^ Suc n = b ^ Suc n; 0 \<le> a; 0 \<le> b |]
   1.273 -      ==> a = (b::'a::{ordered_semidom,ringpower})"
   1.274 +      ==> a = (b::'a::{ordered_semidom,recpower})"
   1.275  by (blast intro: power_le_imp_le_base order_antisym order_eq_refl sym)
   1.276  
   1.277  
   1.278 @@ -296,7 +296,7 @@
   1.279    "p ^ 0 = 1"
   1.280    "p ^ (Suc n) = (p::nat) * (p ^ n)"
   1.281  
   1.282 -instance nat :: ringpower
   1.283 +instance nat :: recpower
   1.284  proof
   1.285    fix z n :: nat
   1.286    show "z^0 = 1" by simp