src/HOL/Real/RealPow.thy
author paulson
Mon Jan 12 16:45:35 2004 +0100 (2004-01-12)
changeset 14352 a8b1a44d8264
parent 14348 744c868ee0b7
child 14387 e96d5c42c4b0
permissions -rw-r--r--
Modified real arithmetic simplification
     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 = RealArith:
    10 
    11 declare abs_mult_self [simp]
    12 
    13 instance real :: power ..
    14 
    15 primrec (realpow)
    16      realpow_0:   "r ^ 0       = 1"
    17      realpow_Suc: "r ^ (Suc n) = (r::real) * (r ^ n)"
    18 
    19 
    20 instance real :: ringpower
    21 proof
    22   fix z :: real
    23   fix n :: nat
    24   show "z^0 = 1" by simp
    25   show "z^(Suc n) = z * (z^n)" by simp
    26 qed
    27 
    28 
    29 lemma realpow_not_zero: "r \<noteq> (0::real) ==> r ^ n \<noteq> 0"
    30   by (rule field_power_not_zero)
    31 
    32 lemma realpow_zero_zero: "r ^ n = (0::real) ==> r = 0"
    33 by simp
    34 
    35 lemma realpow_two: "(r::real)^ (Suc (Suc 0)) = r * r"
    36 by simp
    37 
    38 text{*Legacy: weaker version of the theorem @{text power_strict_mono},
    39 used 6 times in NthRoot and Transcendental*}
    40 lemma realpow_less:
    41      "[|(0::real) < x; x < y; 0 < n|] ==> x ^ n < y ^ n"
    42 apply (rule power_strict_mono, auto) 
    43 done
    44 
    45 lemma abs_realpow_minus_one [simp]: "abs((-1) ^ n) = (1::real)"
    46 by (simp add: power_abs)
    47 
    48 lemma realpow_two_le [simp]: "(0::real) \<le> r^ Suc (Suc 0)"
    49 by (simp add: real_le_square)
    50 
    51 lemma abs_realpow_two [simp]: "abs((x::real)^Suc (Suc 0)) = x^Suc (Suc 0)"
    52 by (simp add: abs_mult)
    53 
    54 lemma realpow_two_abs [simp]: "abs(x::real)^Suc (Suc 0) = x^Suc (Suc 0)"
    55 by (simp add: power_abs [symmetric] abs_eqI1 del: realpow_Suc)
    56 
    57 lemma two_realpow_ge_one [simp]: "(1::real) \<le> 2 ^ n"
    58 by (insert power_increasing [of 0 n "2::real"], simp)
    59 
    60 lemma two_realpow_gt [simp]: "real (n::nat) < 2 ^ n"
    61 apply (induct_tac "n")
    62 apply (auto simp add: real_of_nat_Suc)
    63 apply (subst real_mult_2)
    64 apply (rule real_add_less_le_mono)
    65 apply (auto simp add: two_realpow_ge_one)
    66 done
    67 
    68 lemma realpow_minus_one [simp]: "(-1) ^ (2*n) = (1::real)"
    69 by (induct_tac "n", auto)
    70 
    71 lemma realpow_minus_one_odd [simp]: "(-1) ^ Suc (2*n) = -(1::real)"
    72 by auto
    73 
    74 lemma realpow_minus_one_even [simp]: "(-1) ^ Suc (Suc (2*n)) = (1::real)"
    75 by auto
    76 
    77 lemma realpow_Suc_le_self: "[| 0 \<le> r; r \<le> (1::real) |] ==> r ^ Suc n \<le> r"
    78 by (insert power_decreasing [of 1 "Suc n" r], simp)
    79 
    80 text{*Used ONCE in Transcendental*}
    81 lemma realpow_Suc_less_one: "[| 0 < r; r < (1::real) |] ==> r ^ Suc n < 1"
    82 by (insert power_strict_decreasing [of 0 "Suc n" r], simp)
    83 
    84 text{*Used ONCE in Lim.ML*}
    85 lemma realpow_minus_mult [rule_format]:
    86      "0 < n --> (x::real) ^ (n - 1) * x = x ^ n" 
    87 apply (simp split add: nat_diff_split)
    88 done
    89 
    90 lemma realpow_two_mult_inverse [simp]:
    91      "r \<noteq> 0 ==> r * inverse r ^Suc (Suc 0) = inverse (r::real)"
    92 by (simp add: realpow_two real_mult_assoc [symmetric])
    93 
    94 lemma realpow_two_minus [simp]: "(-x)^Suc (Suc 0) = (x::real)^Suc (Suc 0)"
    95 by simp
    96 
    97 lemma realpow_two_diff:
    98      "(x::real)^Suc (Suc 0) - y^Suc (Suc 0) = (x - y) * (x + y)"
    99 apply (unfold real_diff_def)
   100 apply (simp add: right_distrib left_distrib mult_ac)
   101 done
   102 
   103 lemma realpow_two_disj:
   104      "((x::real)^Suc (Suc 0) = y^Suc (Suc 0)) = (x = y | x = -y)"
   105 apply (cut_tac x = x and y = y in realpow_two_diff)
   106 apply (auto simp del: realpow_Suc)
   107 done
   108 
   109 lemma realpow_real_of_nat: "real (m::nat) ^ n = real (m ^ n)"
   110 apply (induct_tac "n")
   111 apply (auto simp add: real_of_nat_one real_of_nat_mult)
   112 done
   113 
   114 lemma realpow_real_of_nat_two_pos [simp] : "0 < real (Suc (Suc 0) ^ n)"
   115 apply (induct_tac "n")
   116 apply (auto simp add: real_of_nat_mult zero_less_mult_iff)
   117 done
   118 
   119 lemma realpow_increasing:
   120      "[|(0::real) \<le> x; 0 \<le> y; x ^ Suc n \<le> y ^ Suc n|] ==> x \<le> y"
   121   by (rule power_le_imp_le_base)
   122 
   123 
   124 lemma zero_less_realpow_abs_iff [simp]:
   125      "(0 < (abs x)^n) = (x \<noteq> (0::real) | n=0)" 
   126 apply (induct_tac "n")
   127 apply (auto simp add: zero_less_mult_iff)
   128 done
   129 
   130 lemma zero_le_realpow_abs [simp]: "(0::real) \<le> (abs x)^n"
   131 apply (induct_tac "n")
   132 apply (auto simp add: zero_le_mult_iff)
   133 done
   134 
   135 
   136 subsection{*Literal Arithmetic Involving Powers, Type @{typ real}*}
   137 
   138 lemma real_of_int_power: "real (x::int) ^ n = real (x ^ n)"
   139 apply (induct_tac "n")
   140 apply (simp_all (no_asm_simp) add: nat_mult_distrib)
   141 done
   142 declare real_of_int_power [symmetric, simp]
   143 
   144 lemma power_real_number_of:
   145      "(number_of v :: real) ^ n = real ((number_of v :: int) ^ n)"
   146 by (simp only: real_number_of_def real_of_int_power)
   147 
   148 declare power_real_number_of [of _ "number_of w", standard, simp]
   149 
   150 
   151 subsection{*Various Other Theorems*}
   152 
   153 text{*Used several times in Hyperreal/Transcendental.ML*}
   154 lemma real_sum_squares_cancel_a: "x * x = -(y * y) ==> x = (0::real) & y=0"
   155   by (auto intro: real_sum_squares_cancel)
   156 
   157 lemma real_squared_diff_one_factored: "x*x - (1::real) = (x + 1)*(x - 1)"
   158 by (auto simp add: left_distrib right_distrib real_diff_def)
   159 
   160 lemma real_mult_is_one [simp]: "(x*x = (1::real)) = (x = 1 | x = - 1)"
   161 apply auto
   162 apply (drule right_minus_eq [THEN iffD2]) 
   163 apply (auto simp add: real_squared_diff_one_factored)
   164 done
   165 
   166 lemma real_le_add_half_cancel: "(x + y/2 \<le> (y::real)) = (x \<le> y /2)"
   167 by auto
   168 
   169 lemma real_minus_half_eq [simp]: "(x::real) - x/2 = x/2"
   170 by auto
   171 
   172 lemma real_mult_inverse_cancel:
   173      "[|(0::real) < x; 0 < x1; x1 * y < x * u |] 
   174       ==> inverse x * y < inverse x1 * u"
   175 apply (rule_tac c=x in mult_less_imp_less_left) 
   176 apply (auto simp add: real_mult_assoc [symmetric])
   177 apply (simp (no_asm) add: mult_ac)
   178 apply (rule_tac c=x1 in mult_less_imp_less_right) 
   179 apply (auto simp add: mult_ac)
   180 done
   181 
   182 text{*Used once: in Hyperreal/Transcendental.ML*}
   183 lemma real_mult_inverse_cancel2:
   184      "[|(0::real) < x;0 < x1; x1 * y < x * u |] ==> y * inverse x < u * inverse x1"
   185 apply (auto dest: real_mult_inverse_cancel simp add: mult_ac)
   186 done
   187 
   188 lemma inverse_real_of_nat_gt_zero [simp]: "0 < inverse (real (Suc n))"
   189 by auto
   190 
   191 lemma inverse_real_of_nat_ge_zero [simp]: "0 \<le> inverse (real (Suc n))"
   192 by auto
   193 
   194 lemma real_sum_squares_not_zero: "x ~= 0 ==> x * x + y * y ~= (0::real)"
   195 by (blast dest!: real_sum_squares_cancel)
   196 
   197 lemma real_sum_squares_not_zero2: "y ~= 0 ==> x * x + y * y ~= (0::real)"
   198 by (blast dest!: real_sum_squares_cancel2)
   199 
   200 
   201 subsection {*Various Other Theorems*}
   202 
   203 lemma realpow_divide: 
   204     "(x/y) ^ n = ((x::real) ^ n/ y ^ n)"
   205 apply (unfold real_divide_def)
   206 apply (auto simp add: power_mult_distrib power_inverse)
   207 done
   208 
   209 lemma realpow_two_sum_zero_iff [simp]:
   210      "(x ^ 2 + y ^ 2 = (0::real)) = (x = 0 & y = 0)"
   211 apply (auto intro: real_sum_squares_cancel real_sum_squares_cancel2 
   212                    simp add: power2_eq_square)
   213 done
   214 
   215 lemma realpow_two_le_add_order [simp]: "(0::real) \<le> u ^ 2 + v ^ 2"
   216 apply (rule real_le_add_order)
   217 apply (auto simp add: power2_eq_square)
   218 done
   219 
   220 lemma realpow_two_le_add_order2 [simp]: "(0::real) \<le> u ^ 2 + v ^ 2 + w ^ 2"
   221 apply (rule real_le_add_order)+
   222 apply (auto simp add: power2_eq_square)
   223 done
   224 
   225 lemma real_sum_square_gt_zero: "x ~= 0 ==> (0::real) < x * x + y * y"
   226 apply (cut_tac x = x and y = y in real_mult_self_sum_ge_zero)
   227 apply (drule real_le_imp_less_or_eq)
   228 apply (drule_tac y = y in real_sum_squares_not_zero, auto)
   229 done
   230 
   231 lemma real_sum_square_gt_zero2: "y ~= 0 ==> (0::real) < x * x + y * y"
   232 apply (rule real_add_commute [THEN subst])
   233 apply (erule real_sum_square_gt_zero)
   234 done
   235 
   236 lemma real_minus_mult_self_le [simp]: "-(u * u) \<le> (x * (x::real))"
   237 by (rule_tac j = 0 in real_le_trans, auto)
   238 
   239 lemma realpow_square_minus_le [simp]: "-(u ^ 2) \<le> (x::real) ^ 2"
   240 by (auto simp add: power2_eq_square)
   241 
   242 lemma realpow_num_eq_if: "(m::real) ^ n = (if n=0 then 1 else m * m ^ (n - 1))"
   243 by (case_tac "n", auto)
   244 
   245 lemma real_num_zero_less_two_pow [simp]: "0 < (2::real) ^ (4*d)"
   246 apply (induct_tac "d")
   247 apply (auto simp add: realpow_num_eq_if)
   248 done
   249 
   250 lemma lemma_realpow_num_two_mono:
   251      "x * (4::real)   < y ==> x * (2 ^ 8) < y * (2 ^ 6)"
   252 apply (subgoal_tac " (2::real) ^ 8 = 4 * (2 ^ 6) ")
   253 apply (simp (no_asm_simp) add: real_mult_assoc [symmetric])
   254 apply (auto simp add: realpow_num_eq_if)
   255 done
   256 
   257 lemma zero_le_x_squared [simp]: "(0::real) \<le> x^2"
   258 by (simp add: power2_eq_square)
   259 
   260 
   261 
   262 ML
   263 {*
   264 val realpow_0 = thm "realpow_0";
   265 val realpow_Suc = thm "realpow_Suc";
   266 
   267 val realpow_not_zero = thm "realpow_not_zero";
   268 val realpow_zero_zero = thm "realpow_zero_zero";
   269 val realpow_two = thm "realpow_two";
   270 val realpow_less = thm "realpow_less";
   271 val abs_realpow_minus_one = thm "abs_realpow_minus_one";
   272 val realpow_two_le = thm "realpow_two_le";
   273 val abs_realpow_two = thm "abs_realpow_two";
   274 val realpow_two_abs = thm "realpow_two_abs";
   275 val two_realpow_ge_one = thm "two_realpow_ge_one";
   276 val two_realpow_gt = thm "two_realpow_gt";
   277 val realpow_minus_one = thm "realpow_minus_one";
   278 val realpow_minus_one_odd = thm "realpow_minus_one_odd";
   279 val realpow_minus_one_even = thm "realpow_minus_one_even";
   280 val realpow_Suc_le_self = thm "realpow_Suc_le_self";
   281 val realpow_Suc_less_one = thm "realpow_Suc_less_one";
   282 val realpow_minus_mult = thm "realpow_minus_mult";
   283 val realpow_two_mult_inverse = thm "realpow_two_mult_inverse";
   284 val realpow_two_minus = thm "realpow_two_minus";
   285 val realpow_two_disj = thm "realpow_two_disj";
   286 val realpow_real_of_nat = thm "realpow_real_of_nat";
   287 val realpow_real_of_nat_two_pos = thm "realpow_real_of_nat_two_pos";
   288 val realpow_increasing = thm "realpow_increasing";
   289 val zero_less_realpow_abs_iff = thm "zero_less_realpow_abs_iff";
   290 val zero_le_realpow_abs = thm "zero_le_realpow_abs";
   291 val real_of_int_power = thm "real_of_int_power";
   292 val power_real_number_of = thm "power_real_number_of";
   293 val real_sum_squares_cancel_a = thm "real_sum_squares_cancel_a";
   294 val real_mult_inverse_cancel2 = thm "real_mult_inverse_cancel2";
   295 val real_squared_diff_one_factored = thm "real_squared_diff_one_factored";
   296 val real_mult_is_one = thm "real_mult_is_one";
   297 val real_le_add_half_cancel = thm "real_le_add_half_cancel";
   298 val real_minus_half_eq = thm "real_minus_half_eq";
   299 val real_mult_inverse_cancel = thm "real_mult_inverse_cancel";
   300 val real_mult_inverse_cancel2 = thm "real_mult_inverse_cancel2";
   301 val inverse_real_of_nat_gt_zero = thm "inverse_real_of_nat_gt_zero";
   302 val inverse_real_of_nat_ge_zero = thm "inverse_real_of_nat_ge_zero";
   303 val real_sum_squares_not_zero = thm "real_sum_squares_not_zero";
   304 val real_sum_squares_not_zero2 = thm "real_sum_squares_not_zero2";
   305 
   306 val realpow_divide = thm "realpow_divide";
   307 val realpow_two_sum_zero_iff = thm "realpow_two_sum_zero_iff";
   308 val realpow_two_le_add_order = thm "realpow_two_le_add_order";
   309 val realpow_two_le_add_order2 = thm "realpow_two_le_add_order2";
   310 val real_sum_square_gt_zero = thm "real_sum_square_gt_zero";
   311 val real_sum_square_gt_zero2 = thm "real_sum_square_gt_zero2";
   312 val real_minus_mult_self_le = thm "real_minus_mult_self_le";
   313 val realpow_square_minus_le = thm "realpow_square_minus_le";
   314 val realpow_num_eq_if = thm "realpow_num_eq_if";
   315 val real_num_zero_less_two_pow = thm "real_num_zero_less_two_pow";
   316 val lemma_realpow_num_two_mono = thm "lemma_realpow_num_two_mono";
   317 val zero_le_x_squared = thm "zero_le_x_squared";
   318 *}
   319 
   320 
   321 end