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