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