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