src/HOL/Real/RealPow.thy
author huffman
Tue Sep 12 17:05:44 2006 +0200 (2006-09-12)
changeset 20517 86343f2386a8
parent 19765 dfe940911617
child 20634 45fe31e72391
permissions -rw-r--r--
simplify some proofs, remove obsolete realpow_divide
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
wenzelm@19765
    40
text{*Legacy: weaker version of the theorem @{text power_strict_mono}*}
paulson@14348
    41
lemma realpow_less:
paulson@14348
    42
     "[|(0::real) < x; x < y; 0 < n|] ==> x ^ n < y ^ n"
paulson@14348
    43
apply (rule power_strict_mono, auto) 
paulson@14265
    44
done
paulson@14265
    45
paulson@14268
    46
lemma realpow_two_le [simp]: "(0::real) \<le> r^ Suc (Suc 0)"
paulson@14268
    47
by (simp add: real_le_square)
paulson@14265
    48
paulson@14268
    49
lemma abs_realpow_two [simp]: "abs((x::real)^Suc (Suc 0)) = x^Suc (Suc 0)"
paulson@14348
    50
by (simp add: abs_mult)
paulson@14265
    51
paulson@14268
    52
lemma realpow_two_abs [simp]: "abs(x::real)^Suc (Suc 0) = x^Suc (Suc 0)"
paulson@15229
    53
by (simp add: power_abs [symmetric] del: realpow_Suc)
paulson@14265
    54
paulson@14268
    55
lemma two_realpow_ge_one [simp]: "(1::real) \<le> 2 ^ n"
paulson@14348
    56
by (insert power_increasing [of 0 n "2::real"], simp)
paulson@14265
    57
paulson@14268
    58
lemma two_realpow_gt [simp]: "real (n::nat) < 2 ^ n"
paulson@15251
    59
apply (induct "n")
paulson@14265
    60
apply (auto simp add: real_of_nat_Suc)
paulson@14387
    61
apply (subst mult_2)
paulson@14265
    62
apply (rule real_add_less_le_mono)
paulson@14265
    63
apply (auto simp add: two_realpow_ge_one)
paulson@14265
    64
done
paulson@14265
    65
paulson@14348
    66
lemma realpow_Suc_le_self: "[| 0 \<le> r; r \<le> (1::real) |] ==> r ^ Suc n \<le> r"
paulson@14348
    67
by (insert power_decreasing [of 1 "Suc n" r], simp)
paulson@14265
    68
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
lemma realpow_minus_mult [rule_format]:
paulson@14348
    73
     "0 < n --> (x::real) ^ (n - 1) * x = x ^ n" 
paulson@14348
    74
apply (simp split add: nat_diff_split)
paulson@14265
    75
done
paulson@14265
    76
paulson@14348
    77
lemma realpow_two_mult_inverse [simp]:
paulson@14348
    78
     "r \<noteq> 0 ==> r * inverse r ^Suc (Suc 0) = inverse (r::real)"
paulson@14268
    79
by (simp add: realpow_two real_mult_assoc [symmetric])
paulson@14265
    80
paulson@14268
    81
lemma realpow_two_minus [simp]: "(-x)^Suc (Suc 0) = (x::real)^Suc (Suc 0)"
paulson@14268
    82
by simp
paulson@14265
    83
paulson@14348
    84
lemma realpow_two_diff:
paulson@14348
    85
     "(x::real)^Suc (Suc 0) - y^Suc (Suc 0) = (x - y) * (x + y)"
paulson@14265
    86
apply (unfold real_diff_def)
paulson@14334
    87
apply (simp add: right_distrib left_distrib mult_ac)
paulson@14265
    88
done
paulson@14265
    89
paulson@14348
    90
lemma realpow_two_disj:
paulson@14348
    91
     "((x::real)^Suc (Suc 0) = y^Suc (Suc 0)) = (x = y | x = -y)"
paulson@14268
    92
apply (cut_tac x = x and y = y in realpow_two_diff)
paulson@14265
    93
apply (auto simp del: realpow_Suc)
paulson@14265
    94
done
paulson@14265
    95
paulson@14265
    96
lemma realpow_real_of_nat: "real (m::nat) ^ n = real (m ^ n)"
paulson@15251
    97
apply (induct "n")
paulson@14265
    98
apply (auto simp add: real_of_nat_one real_of_nat_mult)
paulson@14265
    99
done
paulson@14265
   100
paulson@14268
   101
lemma realpow_real_of_nat_two_pos [simp] : "0 < real (Suc (Suc 0) ^ n)"
paulson@15251
   102
apply (induct "n")
paulson@14334
   103
apply (auto simp add: real_of_nat_mult zero_less_mult_iff)
paulson@14265
   104
done
paulson@14265
   105
paulson@14265
   106
lemma realpow_increasing:
paulson@14348
   107
     "[|(0::real) \<le> x; 0 \<le> y; x ^ Suc n \<le> y ^ Suc n|] ==> x \<le> y"
paulson@14348
   108
  by (rule power_le_imp_le_base)
paulson@14265
   109
paulson@14265
   110
paulson@14348
   111
lemma zero_less_realpow_abs_iff [simp]:
paulson@14348
   112
     "(0 < (abs x)^n) = (x \<noteq> (0::real) | n=0)" 
paulson@15251
   113
apply (induct "n")
paulson@14334
   114
apply (auto simp add: zero_less_mult_iff)
paulson@14265
   115
done
paulson@14265
   116
paulson@14268
   117
lemma zero_le_realpow_abs [simp]: "(0::real) \<le> (abs x)^n"
paulson@15251
   118
apply (induct "n")
paulson@14334
   119
apply (auto simp add: zero_le_mult_iff)
paulson@14265
   120
done
paulson@14265
   121
paulson@14265
   122
paulson@14348
   123
subsection{*Literal Arithmetic Involving Powers, Type @{typ real}*}
paulson@14265
   124
paulson@14265
   125
lemma real_of_int_power: "real (x::int) ^ n = real (x ^ n)"
paulson@15251
   126
apply (induct "n")
paulson@14387
   127
apply (simp_all add: nat_mult_distrib)
paulson@14265
   128
done
paulson@14265
   129
declare real_of_int_power [symmetric, simp]
paulson@14265
   130
paulson@14348
   131
lemma power_real_number_of:
paulson@14348
   132
     "(number_of v :: real) ^ n = real ((number_of v :: int) ^ n)"
paulson@14387
   133
by (simp only: real_number_of [symmetric] real_of_int_power)
paulson@14265
   134
paulson@14265
   135
declare power_real_number_of [of _ "number_of w", standard, simp]
paulson@14265
   136
paulson@14265
   137
paulson@14268
   138
subsection{*Various Other Theorems*}
paulson@14268
   139
paulson@14268
   140
lemma real_sum_squares_cancel_a: "x * x = -(y * y) ==> x = (0::real) & y=0"
paulson@15085
   141
  apply (auto dest: real_sum_squares_cancel simp add: real_add_eq_0_iff [symmetric])
paulson@15085
   142
  apply (auto dest: real_sum_squares_cancel simp add: add_commute)
paulson@15085
   143
  done
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@14348
   170
lemma real_mult_inverse_cancel2:
paulson@14348
   171
     "[|(0::real) < x;0 < x1; x1 * y < x * u |] ==> y * inverse x < u * inverse x1"
paulson@14334
   172
apply (auto dest: real_mult_inverse_cancel simp add: mult_ac)
paulson@14268
   173
done
paulson@14268
   174
paulson@14348
   175
lemma inverse_real_of_nat_gt_zero [simp]: "0 < inverse (real (Suc n))"
huffman@20517
   176
by simp
paulson@14268
   177
paulson@14348
   178
lemma inverse_real_of_nat_ge_zero [simp]: "0 \<le> inverse (real (Suc n))"
huffman@20517
   179
by simp
paulson@14268
   180
paulson@14268
   181
lemma real_sum_squares_not_zero: "x ~= 0 ==> x * x + y * y ~= (0::real)"
paulson@14348
   182
by (blast dest!: real_sum_squares_cancel)
paulson@14268
   183
paulson@14268
   184
lemma real_sum_squares_not_zero2: "y ~= 0 ==> x * x + y * y ~= (0::real)"
paulson@14348
   185
by (blast dest!: real_sum_squares_cancel2)
paulson@14268
   186
paulson@14268
   187
paulson@14268
   188
subsection {*Various Other Theorems*}
paulson@14268
   189
paulson@14348
   190
lemma realpow_two_sum_zero_iff [simp]:
paulson@14348
   191
     "(x ^ 2 + y ^ 2 = (0::real)) = (x = 0 & y = 0)"
paulson@14348
   192
apply (auto intro: real_sum_squares_cancel real_sum_squares_cancel2 
paulson@14352
   193
                   simp add: power2_eq_square)
paulson@14268
   194
done
paulson@14268
   195
paulson@14348
   196
lemma realpow_two_le_add_order [simp]: "(0::real) \<le> u ^ 2 + v ^ 2"
paulson@14268
   197
apply (rule real_le_add_order)
paulson@14352
   198
apply (auto simp add: power2_eq_square)
paulson@14268
   199
done
paulson@14268
   200
paulson@14348
   201
lemma realpow_two_le_add_order2 [simp]: "(0::real) \<le> u ^ 2 + v ^ 2 + w ^ 2"
paulson@14268
   202
apply (rule real_le_add_order)+
paulson@14352
   203
apply (auto simp add: power2_eq_square)
paulson@14268
   204
done
paulson@14268
   205
paulson@14268
   206
lemma real_sum_square_gt_zero: "x ~= 0 ==> (0::real) < x * x + y * y"
paulson@14348
   207
apply (cut_tac x = x and y = y in real_mult_self_sum_ge_zero)
paulson@14268
   208
apply (drule real_le_imp_less_or_eq)
paulson@14348
   209
apply (drule_tac y = y in real_sum_squares_not_zero, auto)
paulson@14268
   210
done
paulson@14268
   211
paulson@14268
   212
lemma real_sum_square_gt_zero2: "y ~= 0 ==> (0::real) < x * x + y * y"
paulson@14268
   213
apply (rule real_add_commute [THEN subst])
paulson@14268
   214
apply (erule real_sum_square_gt_zero)
paulson@14268
   215
done
paulson@14268
   216
paulson@14348
   217
lemma real_minus_mult_self_le [simp]: "-(u * u) \<le> (x * (x::real))"
paulson@14348
   218
by (rule_tac j = 0 in real_le_trans, auto)
paulson@14268
   219
paulson@14348
   220
lemma realpow_square_minus_le [simp]: "-(u ^ 2) \<le> (x::real) ^ 2"
paulson@14352
   221
by (auto simp add: power2_eq_square)
paulson@14268
   222
ballarin@19279
   223
(* The following theorem is by Benjamin Porter *)
ballarin@19279
   224
lemma real_sq_order:
ballarin@19279
   225
  fixes x::real
ballarin@19279
   226
  assumes xgt0: "0 \<le> x" and ygt0: "0 \<le> y" and sq: "x^2 \<le> y^2"
ballarin@19279
   227
  shows "x \<le> y"
huffman@20517
   228
proof -
huffman@20517
   229
  from sq have "x ^ Suc (Suc 0) \<le> y ^ Suc (Suc 0)"
huffman@20517
   230
    by (simp only: numeral_2_eq_2)
huffman@20517
   231
  thus "x \<le> y" using xgt0 ygt0
huffman@20517
   232
    by (rule power_le_imp_le_base)
ballarin@19279
   233
qed
ballarin@19279
   234
paulson@14268
   235
lemma realpow_num_eq_if: "(m::real) ^ n = (if n=0 then 1 else m * m ^ (n - 1))"
paulson@14348
   236
by (case_tac "n", auto)
paulson@14268
   237
paulson@14348
   238
lemma real_num_zero_less_two_pow [simp]: "0 < (2::real) ^ (4*d)"
huffman@20517
   239
by (simp add: zero_less_power)
paulson@14268
   240
paulson@14348
   241
lemma lemma_realpow_num_two_mono:
paulson@14348
   242
     "x * (4::real)   < y ==> x * (2 ^ 8) < y * (2 ^ 6)"
paulson@14268
   243
apply (subgoal_tac " (2::real) ^ 8 = 4 * (2 ^ 6) ")
paulson@14268
   244
apply (simp (no_asm_simp) add: real_mult_assoc [symmetric])
paulson@14268
   245
apply (auto simp add: realpow_num_eq_if)
paulson@14268
   246
done
paulson@14268
   247
paulson@7077
   248
end