src/HOL/Real/RealPow.thy
author paulson
Fri Nov 21 11:15:40 2003 +0100 (2003-11-21)
changeset 14265 95b42e69436c
parent 12018 ec054019c910
child 14268 5cf13e80be0e
permissions -rw-r--r--
HOL: installation of Ring_and_Field as the basis for Naturals and Reals
     1 (*  Title       : HOL/Real/RealPow.thy
     2     ID          : $Id$
     3     Author      : Jacques D. Fleuriot  
     4     Copyright   : 1998  University of Cambridge
     5     Description : Natural powers theory
     6 
     7 *)
     8 
     9 theory RealPow = RealAbs:
    10 
    11 (*belongs to theory RealAbs*)
    12 lemmas [arith_split] = abs_split
    13 
    14 instance real :: power ..
    15 
    16 primrec (realpow)
    17      realpow_0:   "r ^ 0       = 1"
    18      realpow_Suc: "r ^ (Suc n) = (r::real) * (r ^ n)"
    19 
    20 
    21 (*FIXME: most of the theorems for Suc (Suc 0) are redundant!
    22 *)
    23 
    24 lemma realpow_zero: "(0::real) ^ (Suc n) = 0"
    25 apply auto
    26 done
    27 declare realpow_zero [simp]
    28 
    29 lemma realpow_not_zero [rule_format (no_asm)]: "r \<noteq> (0::real) --> r ^ n \<noteq> 0"
    30 apply (induct_tac "n")
    31 apply auto
    32 done
    33 
    34 lemma realpow_zero_zero: "r ^ n = (0::real) ==> r = 0"
    35 apply (rule ccontr)
    36 apply (auto dest: realpow_not_zero)
    37 done
    38 
    39 lemma realpow_inverse: "inverse ((r::real) ^ n) = (inverse r) ^ n"
    40 apply (induct_tac "n")
    41 apply (auto simp add: real_inverse_distrib)
    42 done
    43 
    44 lemma realpow_abs: "abs(r ^ n) = abs(r::real) ^ n"
    45 apply (induct_tac "n")
    46 apply (auto simp add: abs_mult)
    47 done
    48 
    49 lemma realpow_add: "(r::real) ^ (n + m) = (r ^ n) * (r ^ m)"
    50 apply (induct_tac "n")
    51 apply (auto simp add: real_mult_ac)
    52 done
    53 
    54 lemma realpow_one: "(r::real) ^ 1 = r"
    55 apply (simp (no_asm))
    56 done
    57 declare realpow_one [simp]
    58 
    59 lemma realpow_two: "(r::real)^ (Suc (Suc 0)) = r * r"
    60 apply (simp (no_asm))
    61 done
    62 
    63 lemma realpow_gt_zero [rule_format (no_asm)]: "(0::real) < r --> 0 < r ^ n"
    64 apply (induct_tac "n")
    65 apply (auto intro: real_mult_order simp add: real_zero_less_one)
    66 done
    67 
    68 lemma realpow_ge_zero [rule_format (no_asm)]: "(0::real) \<le> r --> 0 \<le> r ^ n"
    69 apply (induct_tac "n")
    70 apply (auto simp add: real_0_le_mult_iff)
    71 done
    72 
    73 lemma realpow_le [rule_format (no_asm)]: "(0::real) \<le> x & x \<le> y --> x ^ n \<le> y ^ n"
    74 apply (induct_tac "n")
    75 apply (auto intro!: real_mult_le_mono)
    76 apply (simp (no_asm_simp) add: realpow_ge_zero)
    77 done
    78 
    79 lemma realpow_0_left [rule_format, simp]:
    80      "0 < n --> 0 ^ n = (0::real)"
    81 apply (induct_tac "n")
    82 apply (auto ); 
    83 done
    84 
    85 lemma realpow_less' [rule_format]:
    86      "[|(0::real) \<le> x; x < y |] ==> 0 < n --> x ^ n < y ^ n"
    87 apply (induct n) 
    88 apply (auto simp add: real_mult_less_mono' realpow_ge_zero); 
    89 done
    90 
    91 text{*Legacy: weaker version of the theorem above*}
    92 lemma realpow_less [rule_format]:
    93      "[|(0::real) < x; x < y; 0 < n|] ==> x ^ n < y ^ n"
    94 apply (rule realpow_less') 
    95 apply (auto ); 
    96 done
    97 
    98 lemma realpow_eq_one: "1 ^ n = (1::real)"
    99 apply (induct_tac "n")
   100 apply auto
   101 done
   102 declare realpow_eq_one [simp]
   103 
   104 lemma abs_realpow_minus_one: "abs((-1) ^ n) = (1::real)"
   105 apply (induct_tac "n")
   106 apply (auto simp add: abs_mult)
   107 done
   108 declare abs_realpow_minus_one [simp]
   109 
   110 lemma realpow_mult: "((r::real) * s) ^ n = (r ^ n) * (s ^ n)"
   111 apply (induct_tac "n")
   112 apply (auto simp add: real_mult_ac)
   113 done
   114 
   115 lemma realpow_two_le: "(0::real) \<le> r^ Suc (Suc 0)"
   116 apply (simp (no_asm) add: real_le_square)
   117 done
   118 declare realpow_two_le [simp]
   119 
   120 lemma abs_realpow_two: "abs((x::real)^Suc (Suc 0)) = x^Suc (Suc 0)"
   121 apply (simp (no_asm) add: abs_eqI1 real_le_square)
   122 done
   123 declare abs_realpow_two [simp]
   124 
   125 lemma realpow_two_abs: "abs(x::real)^Suc (Suc 0) = x^Suc (Suc 0)"
   126 apply (simp (no_asm) add: realpow_abs [symmetric] abs_eqI1 del: realpow_Suc)
   127 done
   128 declare realpow_two_abs [simp]
   129 
   130 lemma realpow_two_gt_one: "(1::real) < r ==> 1 < r^ (Suc (Suc 0))"
   131 apply auto
   132 apply (cut_tac real_zero_less_one)
   133 apply (frule_tac x = "0" in order_less_trans)
   134 apply assumption
   135 apply (drule_tac  z = "r" and x = "1" in real_mult_less_mono1)
   136 apply (auto intro: order_less_trans)
   137 done
   138 
   139 lemma realpow_ge_one [rule_format (no_asm)]: "(1::real) < r --> 1 \<le> r ^ n"
   140 apply (induct_tac "n")
   141 apply auto
   142 apply (subgoal_tac "1*1 \<le> r * r^n")
   143 apply (rule_tac [2] real_mult_le_mono)
   144 apply auto
   145 done
   146 
   147 lemma realpow_ge_one2: "(1::real) \<le> r ==> 1 \<le> r ^ n"
   148 apply (drule order_le_imp_less_or_eq)
   149 apply (auto dest: realpow_ge_one)
   150 done
   151 
   152 lemma two_realpow_ge_one: "(1::real) \<le> 2 ^ n"
   153 apply (rule_tac y = "1 ^ n" in order_trans)
   154 apply (rule_tac [2] realpow_le)
   155 apply (auto intro: order_less_imp_le)
   156 done
   157 
   158 lemma two_realpow_gt: "real (n::nat) < 2 ^ n"
   159 apply (induct_tac "n")
   160 apply (auto simp add: real_of_nat_Suc)
   161 apply (subst real_mult_2)
   162 apply (rule real_add_less_le_mono)
   163 apply (auto simp add: two_realpow_ge_one)
   164 done
   165 declare two_realpow_gt [simp] two_realpow_ge_one [simp]
   166 
   167 lemma realpow_minus_one: "(-1) ^ (2*n) = (1::real)"
   168 apply (induct_tac "n")
   169 apply auto
   170 done
   171 declare realpow_minus_one [simp]
   172 
   173 lemma realpow_minus_one_odd: "(-1) ^ Suc (2*n) = -(1::real)"
   174 apply auto
   175 done
   176 declare realpow_minus_one_odd [simp]
   177 
   178 lemma realpow_minus_one_even: "(-1) ^ Suc (Suc (2*n)) = (1::real)"
   179 apply auto
   180 done
   181 declare realpow_minus_one_even [simp]
   182 
   183 lemma realpow_Suc_less [rule_format (no_asm)]: "(0::real) < r & r < (1::real) --> r ^ Suc n < r ^ n"
   184 apply (induct_tac "n")
   185 apply auto
   186 done
   187 
   188 lemma realpow_Suc_le [rule_format (no_asm)]: "0 \<le> r & r < (1::real) --> r ^ Suc n \<le> r ^ n"
   189 apply (induct_tac "n")
   190 apply (auto intro: order_less_imp_le dest!: order_le_imp_less_or_eq)
   191 done
   192 
   193 lemma realpow_zero_le: "(0::real) \<le> 0 ^ n"
   194 apply (case_tac "n")
   195 apply auto
   196 done
   197 declare realpow_zero_le [simp]
   198 
   199 lemma realpow_Suc_le2 [rule_format (no_asm)]: "0 < r & r < (1::real) --> r ^ Suc n \<le> r ^ n"
   200 apply (blast intro!: order_less_imp_le realpow_Suc_less)
   201 done
   202 
   203 lemma realpow_Suc_le3: "[| 0 \<le> r; r < (1::real) |] ==> r ^ Suc n \<le> r ^ n"
   204 apply (erule order_le_imp_less_or_eq [THEN disjE])
   205 apply (rule realpow_Suc_le2)
   206 apply auto
   207 done
   208 
   209 lemma realpow_less_le [rule_format (no_asm)]: "0 \<le> r & r < (1::real) & n < N --> r ^ N \<le> r ^ n"
   210 apply (induct_tac "N")
   211 apply (simp_all (no_asm_simp))
   212 apply clarify
   213 apply (subgoal_tac "r * r ^ na \<le> 1 * r ^ n")
   214 apply simp
   215 apply (rule real_mult_le_mono)
   216 apply (auto simp add: realpow_ge_zero less_Suc_eq)
   217 done
   218 
   219 lemma realpow_le_le: "[| 0 \<le> r; r < (1::real); n \<le> N |] ==> r ^ N \<le> r ^ n"
   220 apply (drule_tac n = "N" in le_imp_less_or_eq)
   221 apply (auto intro: realpow_less_le)
   222 done
   223 
   224 lemma realpow_Suc_le_self: "[| 0 < r; r < (1::real) |] ==> r ^ Suc n \<le> r"
   225 apply (drule_tac n = "1" and N = "Suc n" in order_less_imp_le [THEN realpow_le_le])
   226 apply auto
   227 done
   228 
   229 lemma realpow_Suc_less_one: "[| 0 < r; r < (1::real) |] ==> r ^ Suc n < 1"
   230 apply (blast intro: realpow_Suc_le_self order_le_less_trans)
   231 done
   232 
   233 lemma realpow_le_Suc [rule_format (no_asm)]: "(1::real) \<le> r --> r ^ n \<le> r ^ Suc n"
   234 apply (induct_tac "n")
   235 apply auto
   236 done
   237 
   238 lemma realpow_less_Suc [rule_format (no_asm)]: "(1::real) < r --> r ^ n < r ^ Suc n"
   239 apply (induct_tac "n")
   240 apply auto
   241 done
   242 
   243 lemma realpow_le_Suc2 [rule_format (no_asm)]: "(1::real) < r --> r ^ n \<le> r ^ Suc n"
   244 apply (blast intro!: order_less_imp_le realpow_less_Suc)
   245 done
   246 
   247 lemma realpow_gt_ge [rule_format (no_asm)]: "(1::real) < r & n < N --> r ^ n \<le> r ^ N"
   248 apply (induct_tac "N")
   249 apply auto
   250 apply (frule_tac [!] n = "na" in realpow_ge_one)
   251 apply (drule_tac [!] real_mult_self_le)
   252 apply assumption
   253 prefer 2 apply (assumption)
   254 apply (auto intro: order_trans simp add: less_Suc_eq)
   255 done
   256 
   257 lemma realpow_gt_ge2 [rule_format (no_asm)]: "(1::real) \<le> r & n < N --> r ^ n \<le> r ^ N"
   258 apply (induct_tac "N")
   259 apply auto
   260 apply (frule_tac [!] n = "na" in realpow_ge_one2)
   261 apply (drule_tac [!] real_mult_self_le2)
   262 apply assumption
   263 prefer 2 apply (assumption)
   264 apply (auto intro: order_trans simp add: less_Suc_eq)
   265 done
   266 
   267 lemma realpow_ge_ge: "[| (1::real) < r; n \<le> N |] ==> r ^ n \<le> r ^ N"
   268 apply (drule_tac n = "N" in le_imp_less_or_eq)
   269 apply (auto intro: realpow_gt_ge)
   270 done
   271 
   272 lemma realpow_ge_ge2: "[| (1::real) \<le> r; n \<le> N |] ==> r ^ n \<le> r ^ N"
   273 apply (drule_tac n = "N" in le_imp_less_or_eq)
   274 apply (auto intro: realpow_gt_ge2)
   275 done
   276 
   277 lemma realpow_Suc_ge_self [rule_format (no_asm)]: "(1::real) < r ==> r \<le> r ^ Suc n"
   278 apply (drule_tac n = "1" and N = "Suc n" in realpow_ge_ge)
   279 apply auto
   280 done
   281 
   282 lemma realpow_Suc_ge_self2 [rule_format (no_asm)]: "(1::real) \<le> r ==> r \<le> r ^ Suc n"
   283 apply (drule_tac n = "1" and N = "Suc n" in realpow_ge_ge2)
   284 apply auto
   285 done
   286 
   287 lemma realpow_ge_self: "[| (1::real) < r; 0 < n |] ==> r \<le> r ^ n"
   288 apply (drule less_not_refl2 [THEN not0_implies_Suc])
   289 apply (auto intro!: realpow_Suc_ge_self)
   290 done
   291 
   292 lemma realpow_ge_self2: "[| (1::real) \<le> r; 0 < n |] ==> r \<le> r ^ n"
   293 apply (drule less_not_refl2 [THEN not0_implies_Suc])
   294 apply (auto intro!: realpow_Suc_ge_self2)
   295 done
   296 
   297 lemma realpow_minus_mult [rule_format (no_asm)]: "0 < n --> (x::real) ^ (n - 1) * x = x ^ n"
   298 apply (induct_tac "n")
   299 apply (auto simp add: real_mult_commute)
   300 done
   301 declare realpow_minus_mult [simp]
   302 
   303 lemma realpow_two_mult_inverse: "r \<noteq> 0 ==> r * inverse r ^Suc (Suc 0) = inverse (r::real)"
   304 apply (simp (no_asm_simp) add: realpow_two real_mult_assoc [symmetric])
   305 done
   306 declare realpow_two_mult_inverse [simp]
   307 
   308 (* 05/00 *)
   309 lemma realpow_two_minus: "(-x)^Suc (Suc 0) = (x::real)^Suc (Suc 0)"
   310 apply (simp (no_asm))
   311 done
   312 declare realpow_two_minus [simp]
   313 
   314 lemma realpow_two_diff: "(x::real)^Suc (Suc 0) - y^Suc (Suc 0) = (x - y) * (x + y)"
   315 apply (unfold real_diff_def)
   316 apply (simp add: real_add_mult_distrib2 real_add_mult_distrib real_mult_ac)
   317 done
   318 
   319 lemma realpow_two_disj: "((x::real)^Suc (Suc 0) = y^Suc (Suc 0)) = (x = y | x = -y)"
   320 apply (cut_tac x = "x" and y = "y" in realpow_two_diff)
   321 apply (auto simp del: realpow_Suc)
   322 done
   323 
   324 (* used in Transc *)
   325 lemma realpow_diff: "[|(x::real) \<noteq> 0; m \<le> n |] ==> x ^ (n - m) = x ^ n * inverse (x ^ m)"
   326 apply (auto simp add: le_eq_less_or_eq less_iff_Suc_add realpow_add realpow_not_zero real_mult_ac)
   327 done
   328 
   329 lemma realpow_real_of_nat: "real (m::nat) ^ n = real (m ^ n)"
   330 apply (induct_tac "n")
   331 apply (auto simp add: real_of_nat_one real_of_nat_mult)
   332 done
   333 
   334 lemma realpow_real_of_nat_two_pos: "0 < real (Suc (Suc 0) ^ n)"
   335 apply (induct_tac "n")
   336 apply (auto simp add: real_of_nat_mult real_0_less_mult_iff)
   337 done
   338 declare realpow_real_of_nat_two_pos [simp] 
   339 
   340 lemma realpow_increasing:
   341   assumes xnonneg: "(0::real) \<le> x"
   342       and ynonneg: "0 \<le> y"
   343       and le: "x ^ Suc n \<le> y ^ Suc n"
   344   shows "x \<le> y"
   345  proof (rule ccontr)
   346    assume "~ x \<le> y"
   347    then have "y<x" by simp
   348    then have "y ^ Suc n < x ^ Suc n"
   349      by (simp only: prems realpow_less') 
   350    from le and this show "False"
   351      by simp
   352  qed
   353   
   354 lemma realpow_Suc_cancel_eq: "[| (0::real) \<le> x; 0 \<le> y; x ^ Suc n = y ^ Suc n |] ==> x = y"
   355 apply (blast intro: realpow_increasing order_antisym order_eq_refl sym)
   356 done
   357 
   358 
   359 (*** Logical equivalences for inequalities ***)
   360 
   361 lemma realpow_eq_0_iff: "(x^n = 0) = (x = (0::real) & 0<n)"
   362 apply (induct_tac "n")
   363 apply auto
   364 done
   365 declare realpow_eq_0_iff [simp]
   366 
   367 lemma zero_less_realpow_abs_iff: "(0 < (abs x)^n) = (x \<noteq> (0::real) | n=0)"
   368 apply (induct_tac "n")
   369 apply (auto simp add: real_0_less_mult_iff)
   370 done
   371 declare zero_less_realpow_abs_iff [simp]
   372 
   373 lemma zero_le_realpow_abs: "(0::real) \<le> (abs x)^n"
   374 apply (induct_tac "n")
   375 apply (auto simp add: real_0_le_mult_iff)
   376 done
   377 declare zero_le_realpow_abs [simp]
   378 
   379 
   380 (*** Literal arithmetic involving powers, type real ***)
   381 
   382 lemma real_of_int_power: "real (x::int) ^ n = real (x ^ n)"
   383 apply (induct_tac "n")
   384 apply (simp_all (no_asm_simp) add: nat_mult_distrib)
   385 done
   386 declare real_of_int_power [symmetric, simp]
   387 
   388 lemma power_real_number_of: "(number_of v :: real) ^ n = real ((number_of v :: int) ^ n)"
   389 apply (simp only: real_number_of_def real_of_int_power)
   390 done
   391 
   392 declare power_real_number_of [of _ "number_of w", standard, simp]
   393 
   394 
   395 lemma real_power_two: "(r::real)\<twosuperior> = r * r"
   396   by (simp add: numeral_2_eq_2)
   397 
   398 lemma real_sqr_ge_zero [iff]: "0 \<le> (r::real)\<twosuperior>"
   399   by (simp add: real_power_two)
   400 
   401 lemma real_sqr_gt_zero: "(r::real) \<noteq> 0 ==> 0 < r\<twosuperior>"
   402 proof -
   403   assume "r \<noteq> 0"
   404   hence "0 \<noteq> r\<twosuperior>" by simp
   405   also have "0 \<le> r\<twosuperior>" by (simp add: real_sqr_ge_zero)
   406   finally show ?thesis .
   407 qed
   408 
   409 lemma real_sqr_not_zero: "r \<noteq> 0 ==> (r::real)\<twosuperior> \<noteq> 0"
   410   by simp
   411 
   412 
   413 ML
   414 {*
   415 val realpow_0 = thm "realpow_0";
   416 val realpow_Suc = thm "realpow_Suc";
   417 
   418 val realpow_zero = thm "realpow_zero";
   419 val realpow_not_zero = thm "realpow_not_zero";
   420 val realpow_zero_zero = thm "realpow_zero_zero";
   421 val realpow_inverse = thm "realpow_inverse";
   422 val realpow_abs = thm "realpow_abs";
   423 val realpow_add = thm "realpow_add";
   424 val realpow_one = thm "realpow_one";
   425 val realpow_two = thm "realpow_two";
   426 val realpow_gt_zero = thm "realpow_gt_zero";
   427 val realpow_ge_zero = thm "realpow_ge_zero";
   428 val realpow_le = thm "realpow_le";
   429 val realpow_0_left = thm "realpow_0_left";
   430 val realpow_less = thm "realpow_less";
   431 val realpow_eq_one = thm "realpow_eq_one";
   432 val abs_realpow_minus_one = thm "abs_realpow_minus_one";
   433 val realpow_mult = thm "realpow_mult";
   434 val realpow_two_le = thm "realpow_two_le";
   435 val abs_realpow_two = thm "abs_realpow_two";
   436 val realpow_two_abs = thm "realpow_two_abs";
   437 val realpow_two_gt_one = thm "realpow_two_gt_one";
   438 val realpow_ge_one = thm "realpow_ge_one";
   439 val realpow_ge_one2 = thm "realpow_ge_one2";
   440 val two_realpow_ge_one = thm "two_realpow_ge_one";
   441 val two_realpow_gt = thm "two_realpow_gt";
   442 val realpow_minus_one = thm "realpow_minus_one";
   443 val realpow_minus_one_odd = thm "realpow_minus_one_odd";
   444 val realpow_minus_one_even = thm "realpow_minus_one_even";
   445 val realpow_Suc_less = thm "realpow_Suc_less";
   446 val realpow_Suc_le = thm "realpow_Suc_le";
   447 val realpow_zero_le = thm "realpow_zero_le";
   448 val realpow_Suc_le2 = thm "realpow_Suc_le2";
   449 val realpow_Suc_le3 = thm "realpow_Suc_le3";
   450 val realpow_less_le = thm "realpow_less_le";
   451 val realpow_le_le = thm "realpow_le_le";
   452 val realpow_Suc_le_self = thm "realpow_Suc_le_self";
   453 val realpow_Suc_less_one = thm "realpow_Suc_less_one";
   454 val realpow_le_Suc = thm "realpow_le_Suc";
   455 val realpow_less_Suc = thm "realpow_less_Suc";
   456 val realpow_le_Suc2 = thm "realpow_le_Suc2";
   457 val realpow_gt_ge = thm "realpow_gt_ge";
   458 val realpow_gt_ge2 = thm "realpow_gt_ge2";
   459 val realpow_ge_ge = thm "realpow_ge_ge";
   460 val realpow_ge_ge2 = thm "realpow_ge_ge2";
   461 val realpow_Suc_ge_self = thm "realpow_Suc_ge_self";
   462 val realpow_Suc_ge_self2 = thm "realpow_Suc_ge_self2";
   463 val realpow_ge_self = thm "realpow_ge_self";
   464 val realpow_ge_self2 = thm "realpow_ge_self2";
   465 val realpow_minus_mult = thm "realpow_minus_mult";
   466 val realpow_two_mult_inverse = thm "realpow_two_mult_inverse";
   467 val realpow_two_minus = thm "realpow_two_minus";
   468 val realpow_two_diff = thm "realpow_two_diff";
   469 val realpow_two_disj = thm "realpow_two_disj";
   470 val realpow_diff = thm "realpow_diff";
   471 val realpow_real_of_nat = thm "realpow_real_of_nat";
   472 val realpow_real_of_nat_two_pos = thm "realpow_real_of_nat_two_pos";
   473 val realpow_increasing = thm "realpow_increasing";
   474 val realpow_Suc_cancel_eq = thm "realpow_Suc_cancel_eq";
   475 val realpow_eq_0_iff = thm "realpow_eq_0_iff";
   476 val zero_less_realpow_abs_iff = thm "zero_less_realpow_abs_iff";
   477 val zero_le_realpow_abs = thm "zero_le_realpow_abs";
   478 val real_of_int_power = thm "real_of_int_power";
   479 val power_real_number_of = thm "power_real_number_of";
   480 val real_power_two = thm "real_power_two";
   481 val real_sqr_ge_zero = thm "real_sqr_ge_zero";
   482 val real_sqr_gt_zero = thm "real_sqr_gt_zero";
   483 val real_sqr_not_zero = thm "real_sqr_not_zero";
   484 *}
   485 
   486 
   487 end