src/HOL/Real/RealPow.thy
author wenzelm
Fri Jun 02 23:22:29 2006 +0200 (2006-06-02)
changeset 19765 dfe940911617
parent 19279 48b527d0331b
child 20517 86343f2386a8
permissions -rw-r--r--
misc cleanup;
     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
    10 imports RealDef
    11 begin
    12 
    13 declare abs_mult_self [simp]
    14 
    15 instance real :: power ..
    16 
    17 primrec (realpow)
    18      realpow_0:   "r ^ 0       = 1"
    19      realpow_Suc: "r ^ (Suc n) = (r::real) * (r ^ n)"
    20 
    21 
    22 instance real :: recpower
    23 proof
    24   fix z :: real
    25   fix n :: nat
    26   show "z^0 = 1" by simp
    27   show "z^(Suc n) = z * (z^n)" by simp
    28 qed
    29 
    30 
    31 lemma realpow_not_zero: "r \<noteq> (0::real) ==> r ^ n \<noteq> 0"
    32   by (rule field_power_not_zero)
    33 
    34 lemma realpow_zero_zero: "r ^ n = (0::real) ==> r = 0"
    35 by simp
    36 
    37 lemma realpow_two: "(r::real)^ (Suc (Suc 0)) = r * r"
    38 by simp
    39 
    40 text{*Legacy: weaker version of the theorem @{text power_strict_mono}*}
    41 lemma realpow_less:
    42      "[|(0::real) < x; x < y; 0 < n|] ==> x ^ n < y ^ n"
    43 apply (rule power_strict_mono, auto) 
    44 done
    45 
    46 lemma realpow_two_le [simp]: "(0::real) \<le> r^ Suc (Suc 0)"
    47 by (simp add: real_le_square)
    48 
    49 lemma abs_realpow_two [simp]: "abs((x::real)^Suc (Suc 0)) = x^Suc (Suc 0)"
    50 by (simp add: abs_mult)
    51 
    52 lemma realpow_two_abs [simp]: "abs(x::real)^Suc (Suc 0) = x^Suc (Suc 0)"
    53 by (simp add: power_abs [symmetric] del: realpow_Suc)
    54 
    55 lemma two_realpow_ge_one [simp]: "(1::real) \<le> 2 ^ n"
    56 by (insert power_increasing [of 0 n "2::real"], simp)
    57 
    58 lemma two_realpow_gt [simp]: "real (n::nat) < 2 ^ n"
    59 apply (induct "n")
    60 apply (auto simp add: real_of_nat_Suc)
    61 apply (subst mult_2)
    62 apply (rule real_add_less_le_mono)
    63 apply (auto simp add: two_realpow_ge_one)
    64 done
    65 
    66 lemma realpow_Suc_le_self: "[| 0 \<le> r; r \<le> (1::real) |] ==> r ^ Suc n \<le> r"
    67 by (insert power_decreasing [of 1 "Suc n" r], simp)
    68 
    69 lemma realpow_Suc_less_one: "[| 0 < r; r < (1::real) |] ==> r ^ Suc n < 1"
    70 by (insert power_strict_decreasing [of 0 "Suc n" r], simp)
    71 
    72 lemma realpow_minus_mult [rule_format]:
    73      "0 < n --> (x::real) ^ (n - 1) * x = x ^ n" 
    74 apply (simp split add: nat_diff_split)
    75 done
    76 
    77 lemma realpow_two_mult_inverse [simp]:
    78      "r \<noteq> 0 ==> r * inverse r ^Suc (Suc 0) = inverse (r::real)"
    79 by (simp add: realpow_two real_mult_assoc [symmetric])
    80 
    81 lemma realpow_two_minus [simp]: "(-x)^Suc (Suc 0) = (x::real)^Suc (Suc 0)"
    82 by simp
    83 
    84 lemma realpow_two_diff:
    85      "(x::real)^Suc (Suc 0) - y^Suc (Suc 0) = (x - y) * (x + y)"
    86 apply (unfold real_diff_def)
    87 apply (simp add: right_distrib left_distrib mult_ac)
    88 done
    89 
    90 lemma realpow_two_disj:
    91      "((x::real)^Suc (Suc 0) = y^Suc (Suc 0)) = (x = y | x = -y)"
    92 apply (cut_tac x = x and y = y in realpow_two_diff)
    93 apply (auto simp del: realpow_Suc)
    94 done
    95 
    96 lemma realpow_real_of_nat: "real (m::nat) ^ n = real (m ^ n)"
    97 apply (induct "n")
    98 apply (auto simp add: real_of_nat_one real_of_nat_mult)
    99 done
   100 
   101 lemma realpow_real_of_nat_two_pos [simp] : "0 < real (Suc (Suc 0) ^ n)"
   102 apply (induct "n")
   103 apply (auto simp add: real_of_nat_mult zero_less_mult_iff)
   104 done
   105 
   106 lemma realpow_increasing:
   107      "[|(0::real) \<le> x; 0 \<le> y; x ^ Suc n \<le> y ^ Suc n|] ==> x \<le> y"
   108   by (rule power_le_imp_le_base)
   109 
   110 
   111 lemma zero_less_realpow_abs_iff [simp]:
   112      "(0 < (abs x)^n) = (x \<noteq> (0::real) | n=0)" 
   113 apply (induct "n")
   114 apply (auto simp add: zero_less_mult_iff)
   115 done
   116 
   117 lemma zero_le_realpow_abs [simp]: "(0::real) \<le> (abs x)^n"
   118 apply (induct "n")
   119 apply (auto simp add: zero_le_mult_iff)
   120 done
   121 
   122 
   123 subsection{*Literal Arithmetic Involving Powers, Type @{typ real}*}
   124 
   125 lemma real_of_int_power: "real (x::int) ^ n = real (x ^ n)"
   126 apply (induct "n")
   127 apply (simp_all add: nat_mult_distrib)
   128 done
   129 declare real_of_int_power [symmetric, simp]
   130 
   131 lemma power_real_number_of:
   132      "(number_of v :: real) ^ n = real ((number_of v :: int) ^ n)"
   133 by (simp only: real_number_of [symmetric] real_of_int_power)
   134 
   135 declare power_real_number_of [of _ "number_of w", standard, simp]
   136 
   137 
   138 subsection{*Various Other Theorems*}
   139 
   140 lemma real_sum_squares_cancel_a: "x * x = -(y * y) ==> x = (0::real) & y=0"
   141   apply (auto dest: real_sum_squares_cancel simp add: real_add_eq_0_iff [symmetric])
   142   apply (auto dest: real_sum_squares_cancel simp add: add_commute)
   143   done
   144 
   145 lemma real_squared_diff_one_factored: "x*x - (1::real) = (x + 1)*(x - 1)"
   146 by (auto simp add: left_distrib right_distrib real_diff_def)
   147 
   148 lemma real_mult_is_one [simp]: "(x*x = (1::real)) = (x = 1 | x = - 1)"
   149 apply auto
   150 apply (drule right_minus_eq [THEN iffD2]) 
   151 apply (auto simp add: real_squared_diff_one_factored)
   152 done
   153 
   154 lemma real_le_add_half_cancel: "(x + y/2 \<le> (y::real)) = (x \<le> y /2)"
   155 by auto
   156 
   157 lemma real_minus_half_eq [simp]: "(x::real) - x/2 = x/2"
   158 by auto
   159 
   160 lemma real_mult_inverse_cancel:
   161      "[|(0::real) < x; 0 < x1; x1 * y < x * u |] 
   162       ==> inverse x * y < inverse x1 * u"
   163 apply (rule_tac c=x in mult_less_imp_less_left) 
   164 apply (auto simp add: real_mult_assoc [symmetric])
   165 apply (simp (no_asm) add: mult_ac)
   166 apply (rule_tac c=x1 in mult_less_imp_less_right) 
   167 apply (auto simp add: mult_ac)
   168 done
   169 
   170 lemma real_mult_inverse_cancel2:
   171      "[|(0::real) < x;0 < x1; x1 * y < x * u |] ==> y * inverse x < u * inverse x1"
   172 apply (auto dest: real_mult_inverse_cancel simp add: mult_ac)
   173 done
   174 
   175 lemma inverse_real_of_nat_gt_zero [simp]: "0 < inverse (real (Suc n))"
   176 by auto
   177 
   178 lemma inverse_real_of_nat_ge_zero [simp]: "0 \<le> inverse (real (Suc n))"
   179 by auto
   180 
   181 lemma real_sum_squares_not_zero: "x ~= 0 ==> x * x + y * y ~= (0::real)"
   182 by (blast dest!: real_sum_squares_cancel)
   183 
   184 lemma real_sum_squares_not_zero2: "y ~= 0 ==> x * x + y * y ~= (0::real)"
   185 by (blast dest!: real_sum_squares_cancel2)
   186 
   187 
   188 subsection {*Various Other Theorems*}
   189 
   190 lemma realpow_divide: 
   191     "(x/y) ^ n = ((x::real) ^ n/ y ^ n)"
   192 apply (unfold real_divide_def)
   193 apply (auto simp add: power_mult_distrib power_inverse)
   194 done
   195 
   196 lemma realpow_two_sum_zero_iff [simp]:
   197      "(x ^ 2 + y ^ 2 = (0::real)) = (x = 0 & y = 0)"
   198 apply (auto intro: real_sum_squares_cancel real_sum_squares_cancel2 
   199                    simp add: power2_eq_square)
   200 done
   201 
   202 lemma realpow_two_le_add_order [simp]: "(0::real) \<le> u ^ 2 + v ^ 2"
   203 apply (rule real_le_add_order)
   204 apply (auto simp add: power2_eq_square)
   205 done
   206 
   207 lemma realpow_two_le_add_order2 [simp]: "(0::real) \<le> u ^ 2 + v ^ 2 + w ^ 2"
   208 apply (rule real_le_add_order)+
   209 apply (auto simp add: power2_eq_square)
   210 done
   211 
   212 lemma real_sum_square_gt_zero: "x ~= 0 ==> (0::real) < x * x + y * y"
   213 apply (cut_tac x = x and y = y in real_mult_self_sum_ge_zero)
   214 apply (drule real_le_imp_less_or_eq)
   215 apply (drule_tac y = y in real_sum_squares_not_zero, auto)
   216 done
   217 
   218 lemma real_sum_square_gt_zero2: "y ~= 0 ==> (0::real) < x * x + y * y"
   219 apply (rule real_add_commute [THEN subst])
   220 apply (erule real_sum_square_gt_zero)
   221 done
   222 
   223 lemma real_minus_mult_self_le [simp]: "-(u * u) \<le> (x * (x::real))"
   224 by (rule_tac j = 0 in real_le_trans, auto)
   225 
   226 lemma realpow_square_minus_le [simp]: "-(u ^ 2) \<le> (x::real) ^ 2"
   227 by (auto simp add: power2_eq_square)
   228 
   229 (* The following theorem is by Benjamin Porter *)
   230 lemma real_sq_order:
   231   fixes x::real
   232   assumes xgt0: "0 \<le> x" and ygt0: "0 \<le> y" and sq: "x^2 \<le> y^2"
   233   shows "x \<le> y"
   234 proof (rule ccontr)
   235   assume "\<not>(x \<le> y)"
   236   then have ylx: "y < x" by simp
   237   hence "y \<le> x" by simp
   238   with xgt0 have "x*y \<le> x*x"
   239     by (simp add: pordered_comm_semiring_class.mult_mono)
   240   moreover
   241   have "\<not> (y = 0)"
   242   proof
   243     assume "y = 0"
   244     with ylx have xg0: "0 < x" by simp
   245     from xg0 xg0 have "0 < x*x" by (rule real_mult_order)
   246     moreover have "y*y = 0" by simp
   247     ultimately show False using sq by auto
   248   qed
   249   with ygt0 have "0 < y" by simp
   250   with ylx have "y*y < x*y" by auto
   251   ultimately have "y*y < x*x" by simp
   252   with sq show False by (auto simp add: power2_eq_square [symmetric])
   253 qed
   254 
   255 lemma realpow_num_eq_if: "(m::real) ^ n = (if n=0 then 1 else m * m ^ (n - 1))"
   256 by (case_tac "n", auto)
   257 
   258 lemma real_num_zero_less_two_pow [simp]: "0 < (2::real) ^ (4*d)"
   259 apply (induct "d")
   260 apply (auto simp add: realpow_num_eq_if)
   261 done
   262 
   263 lemma lemma_realpow_num_two_mono:
   264      "x * (4::real)   < y ==> x * (2 ^ 8) < y * (2 ^ 6)"
   265 apply (subgoal_tac " (2::real) ^ 8 = 4 * (2 ^ 6) ")
   266 apply (simp (no_asm_simp) add: real_mult_assoc [symmetric])
   267 apply (auto simp add: realpow_num_eq_if)
   268 done
   269 
   270 end