src/HOL/Real/RealPow.thy
author paulson
Thu Nov 27 10:47:55 2003 +0100 (2003-11-27)
changeset 14268 5cf13e80be0e
parent 14265 95b42e69436c
child 14269 502a7c95de73
permissions -rw-r--r--
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
New theorems for Ring_and_Field. Fixing affected proofs.
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
wenzelm@9435
     9
theory RealPow = RealAbs:
paulson@7077
    10
wenzelm@9435
    11
(*belongs to theory RealAbs*)
wenzelm@9435
    12
lemmas [arith_split] = abs_split
wenzelm@9435
    13
wenzelm@10309
    14
instance real :: power ..
paulson@7077
    15
wenzelm@8856
    16
primrec (realpow)
paulson@12018
    17
     realpow_0:   "r ^ 0       = 1"
wenzelm@9435
    18
     realpow_Suc: "r ^ (Suc n) = (r::real) * (r ^ n)"
paulson@7077
    19
paulson@14265
    20
paulson@14268
    21
lemma realpow_zero [simp]: "(0::real) ^ (Suc n) = 0"
paulson@14268
    22
by auto
paulson@14265
    23
paulson@14268
    24
lemma realpow_not_zero [rule_format]: "r \<noteq> (0::real) --> r ^ n \<noteq> 0"
paulson@14268
    25
by (induct_tac "n", auto)
paulson@14265
    26
paulson@14265
    27
lemma realpow_zero_zero: "r ^ n = (0::real) ==> r = 0"
paulson@14265
    28
apply (rule ccontr)
paulson@14265
    29
apply (auto dest: realpow_not_zero)
paulson@14265
    30
done
paulson@14265
    31
paulson@14265
    32
lemma realpow_inverse: "inverse ((r::real) ^ n) = (inverse r) ^ n"
paulson@14265
    33
apply (induct_tac "n")
paulson@14265
    34
apply (auto simp add: real_inverse_distrib)
paulson@14265
    35
done
paulson@14265
    36
paulson@14265
    37
lemma realpow_abs: "abs(r ^ n) = abs(r::real) ^ n"
paulson@14265
    38
apply (induct_tac "n")
paulson@14265
    39
apply (auto simp add: abs_mult)
paulson@14265
    40
done
paulson@14265
    41
paulson@14265
    42
lemma realpow_add: "(r::real) ^ (n + m) = (r ^ n) * (r ^ m)"
paulson@14265
    43
apply (induct_tac "n")
paulson@14265
    44
apply (auto simp add: real_mult_ac)
paulson@14265
    45
done
paulson@14265
    46
paulson@14268
    47
lemma realpow_one [simp]: "(r::real) ^ 1 = r"
paulson@14268
    48
by simp
paulson@14265
    49
paulson@14265
    50
lemma realpow_two: "(r::real)^ (Suc (Suc 0)) = r * r"
paulson@14268
    51
by simp
paulson@14265
    52
paulson@14268
    53
lemma realpow_gt_zero [rule_format]: "(0::real) < r --> 0 < r ^ n"
paulson@14265
    54
apply (induct_tac "n")
paulson@14265
    55
apply (auto intro: real_mult_order simp add: real_zero_less_one)
paulson@14265
    56
done
paulson@14265
    57
paulson@14268
    58
lemma realpow_ge_zero [rule_format]: "(0::real) \<le> r --> 0 \<le> r ^ n"
paulson@14265
    59
apply (induct_tac "n")
paulson@14265
    60
apply (auto simp add: real_0_le_mult_iff)
paulson@14265
    61
done
paulson@14265
    62
paulson@14268
    63
lemma realpow_le [rule_format]: "(0::real) \<le> x & x \<le> y --> x ^ n \<le> y ^ n"
paulson@14265
    64
apply (induct_tac "n")
paulson@14265
    65
apply (auto intro!: real_mult_le_mono)
paulson@14265
    66
apply (simp (no_asm_simp) add: realpow_ge_zero)
paulson@14265
    67
done
paulson@14265
    68
paulson@14265
    69
lemma realpow_0_left [rule_format, simp]:
paulson@14265
    70
     "0 < n --> 0 ^ n = (0::real)"
paulson@14268
    71
apply (induct_tac "n", auto) 
paulson@14265
    72
done
paulson@14265
    73
paulson@14265
    74
lemma realpow_less' [rule_format]:
paulson@14265
    75
     "[|(0::real) \<le> x; x < y |] ==> 0 < n --> x ^ n < y ^ n"
paulson@14265
    76
apply (induct n) 
paulson@14268
    77
apply (auto simp add: real_mult_less_mono' realpow_ge_zero) 
paulson@14265
    78
done
paulson@14265
    79
paulson@14265
    80
text{*Legacy: weaker version of the theorem above*}
paulson@14268
    81
lemma realpow_less:
paulson@14265
    82
     "[|(0::real) < x; x < y; 0 < n|] ==> x ^ n < y ^ n"
paulson@14268
    83
apply (rule realpow_less', auto) 
paulson@14265
    84
done
paulson@14265
    85
paulson@14268
    86
lemma realpow_eq_one [simp]: "1 ^ n = (1::real)"
paulson@14268
    87
by (induct_tac "n", auto)
paulson@14265
    88
paulson@14268
    89
lemma abs_realpow_minus_one [simp]: "abs((-1) ^ n) = (1::real)"
paulson@14265
    90
apply (induct_tac "n")
paulson@14265
    91
apply (auto simp add: abs_mult)
paulson@14265
    92
done
paulson@14265
    93
paulson@14265
    94
lemma realpow_mult: "((r::real) * s) ^ n = (r ^ n) * (s ^ n)"
paulson@14265
    95
apply (induct_tac "n")
paulson@14265
    96
apply (auto simp add: real_mult_ac)
paulson@14265
    97
done
paulson@14265
    98
paulson@14268
    99
lemma realpow_two_le [simp]: "(0::real) \<le> r^ Suc (Suc 0)"
paulson@14268
   100
by (simp add: real_le_square)
paulson@14265
   101
paulson@14268
   102
lemma abs_realpow_two [simp]: "abs((x::real)^Suc (Suc 0)) = x^Suc (Suc 0)"
paulson@14268
   103
by (simp add: abs_eqI1 real_le_square)
paulson@14265
   104
paulson@14268
   105
lemma realpow_two_abs [simp]: "abs(x::real)^Suc (Suc 0) = x^Suc (Suc 0)"
paulson@14268
   106
by (simp add: realpow_abs [symmetric] abs_eqI1 del: realpow_Suc)
paulson@14265
   107
paulson@14265
   108
lemma realpow_two_gt_one: "(1::real) < r ==> 1 < r^ (Suc (Suc 0))"
paulson@14265
   109
apply auto
paulson@14265
   110
apply (cut_tac real_zero_less_one)
paulson@14268
   111
apply (frule_tac x = 0 in order_less_trans, assumption)
paulson@14268
   112
apply (drule_tac  z = r and x = 1 in real_mult_less_mono1)
paulson@14265
   113
apply (auto intro: order_less_trans)
paulson@14265
   114
done
paulson@14265
   115
paulson@14268
   116
lemma realpow_ge_one [rule_format]: "(1::real) < r --> 1 \<le> r ^ n"
paulson@14268
   117
apply (induct_tac "n", auto)
paulson@14265
   118
apply (subgoal_tac "1*1 \<le> r * r^n")
paulson@14268
   119
apply (rule_tac [2] real_mult_le_mono, auto)
paulson@14265
   120
done
paulson@14265
   121
paulson@14265
   122
lemma realpow_ge_one2: "(1::real) \<le> r ==> 1 \<le> r ^ n"
paulson@14265
   123
apply (drule order_le_imp_less_or_eq)
paulson@14265
   124
apply (auto dest: realpow_ge_one)
paulson@14265
   125
done
paulson@14265
   126
paulson@14268
   127
lemma two_realpow_ge_one [simp]: "(1::real) \<le> 2 ^ n"
paulson@14265
   128
apply (rule_tac y = "1 ^ n" in order_trans)
paulson@14265
   129
apply (rule_tac [2] realpow_le)
paulson@14265
   130
apply (auto intro: order_less_imp_le)
paulson@14265
   131
done
paulson@14265
   132
paulson@14268
   133
lemma two_realpow_gt [simp]: "real (n::nat) < 2 ^ n"
paulson@14265
   134
apply (induct_tac "n")
paulson@14265
   135
apply (auto simp add: real_of_nat_Suc)
paulson@14265
   136
apply (subst real_mult_2)
paulson@14265
   137
apply (rule real_add_less_le_mono)
paulson@14265
   138
apply (auto simp add: two_realpow_ge_one)
paulson@14265
   139
done
paulson@14265
   140
paulson@14268
   141
lemma realpow_minus_one [simp]: "(-1) ^ (2*n) = (1::real)"
paulson@14268
   142
by (induct_tac "n", auto)
paulson@14268
   143
paulson@14268
   144
lemma realpow_minus_one_odd [simp]: "(-1) ^ Suc (2*n) = -(1::real)"
paulson@14268
   145
by auto
paulson@14265
   146
paulson@14268
   147
lemma realpow_minus_one_even [simp]: "(-1) ^ Suc (Suc (2*n)) = (1::real)"
paulson@14268
   148
by auto
paulson@14265
   149
paulson@14268
   150
lemma realpow_Suc_less [rule_format]:
paulson@14268
   151
     "(0::real) < r & r < (1::real) --> r ^ Suc n < r ^ n"
paulson@14268
   152
  by (induct_tac "n", auto)
paulson@14265
   153
paulson@14268
   154
lemma realpow_Suc_le [rule_format]: "0 \<le> r & r < (1::real) --> r ^ Suc n \<le> r ^ n"
paulson@14265
   155
apply (induct_tac "n")
paulson@14265
   156
apply (auto intro: order_less_imp_le dest!: order_le_imp_less_or_eq)
paulson@14265
   157
done
paulson@14265
   158
paulson@14268
   159
lemma realpow_zero_le [simp]: "(0::real) \<le> 0 ^ n"
paulson@14268
   160
by (case_tac "n", auto)
paulson@14265
   161
paulson@14268
   162
lemma realpow_Suc_le2 [rule_format]: "0 < r & r < (1::real) --> r ^ Suc n \<le> r ^ n"
paulson@14268
   163
by (blast intro!: order_less_imp_le realpow_Suc_less)
paulson@14265
   164
paulson@14265
   165
lemma realpow_Suc_le3: "[| 0 \<le> r; r < (1::real) |] ==> r ^ Suc n \<le> r ^ n"
paulson@14265
   166
apply (erule order_le_imp_less_or_eq [THEN disjE])
paulson@14268
   167
apply (rule realpow_Suc_le2, auto)
paulson@14265
   168
done
paulson@14265
   169
paulson@14268
   170
lemma realpow_less_le [rule_format]: "0 \<le> r & r < (1::real) & n < N --> r ^ N \<le> r ^ n"
paulson@14265
   171
apply (induct_tac "N")
paulson@14265
   172
apply (simp_all (no_asm_simp))
paulson@14265
   173
apply clarify
paulson@14268
   174
apply (subgoal_tac "r * r ^ na \<le> 1 * r ^ n", simp)
paulson@14265
   175
apply (rule real_mult_le_mono)
paulson@14265
   176
apply (auto simp add: realpow_ge_zero less_Suc_eq)
paulson@14265
   177
done
paulson@14265
   178
paulson@14265
   179
lemma realpow_le_le: "[| 0 \<le> r; r < (1::real); n \<le> N |] ==> r ^ N \<le> r ^ n"
paulson@14268
   180
apply (drule_tac n = N in le_imp_less_or_eq)
paulson@14265
   181
apply (auto intro: realpow_less_le)
paulson@14265
   182
done
paulson@14265
   183
paulson@14265
   184
lemma realpow_Suc_le_self: "[| 0 < r; r < (1::real) |] ==> r ^ Suc n \<le> r"
paulson@14268
   185
by (drule_tac n = 1 and N = "Suc n" in order_less_imp_le [THEN realpow_le_le], auto)
paulson@14265
   186
paulson@14265
   187
lemma realpow_Suc_less_one: "[| 0 < r; r < (1::real) |] ==> r ^ Suc n < 1"
paulson@14268
   188
by (blast intro: realpow_Suc_le_self order_le_less_trans)
paulson@14268
   189
paulson@14268
   190
lemma realpow_le_Suc [rule_format]: "(1::real) \<le> r --> r ^ n \<le> r ^ Suc n"
paulson@14268
   191
by (induct_tac "n", auto)
paulson@14268
   192
paulson@14268
   193
lemma realpow_less_Suc [rule_format]: "(1::real) < r --> r ^ n < r ^ Suc n"
paulson@14268
   194
by (induct_tac "n", auto)
paulson@14265
   195
paulson@14268
   196
lemma realpow_le_Suc2 [rule_format]: "(1::real) < r --> r ^ n \<le> r ^ Suc n"
paulson@14268
   197
by (blast intro!: order_less_imp_le realpow_less_Suc)
paulson@14268
   198
paulson@14268
   199
(*One use in RealPow.thy*)
paulson@14268
   200
lemma real_mult_self_le2: "[| (1::real) \<le> r; (1::real) \<le> x |]  ==> x \<le> r * x"
paulson@14268
   201
apply (subgoal_tac "1 * x \<le> r * x", simp) 
paulson@14268
   202
apply (rule mult_right_mono, auto) 
paulson@14265
   203
done
paulson@14265
   204
paulson@14268
   205
lemma realpow_gt_ge2 [rule_format]: "(1::real) \<le> r & n < N --> r ^ n \<le> r ^ N"
paulson@14268
   206
apply (induct_tac "N", auto)
paulson@14268
   207
apply (frule_tac [!] n = na in realpow_ge_one2)
paulson@14268
   208
apply (drule_tac [!] real_mult_self_le2, assumption)
paulson@14268
   209
prefer 2 apply assumption
paulson@14265
   210
apply (auto intro: order_trans simp add: less_Suc_eq)
paulson@14265
   211
done
paulson@14265
   212
paulson@14265
   213
lemma realpow_ge_ge2: "[| (1::real) \<le> r; n \<le> N |] ==> r ^ n \<le> r ^ N"
paulson@14268
   214
apply (drule_tac n = N in le_imp_less_or_eq)
paulson@14265
   215
apply (auto intro: realpow_gt_ge2)
paulson@14265
   216
done
paulson@14265
   217
paulson@14268
   218
lemma realpow_Suc_ge_self2: "(1::real) \<le> r ==> r \<le> r ^ Suc n"
paulson@14268
   219
by (drule_tac n = 1 and N = "Suc n" in realpow_ge_ge2, auto)
paulson@14265
   220
paulson@14268
   221
(*Used ONCE in Hyperreal/NthRoot.ML*)
paulson@14265
   222
lemma realpow_ge_self2: "[| (1::real) \<le> r; 0 < n |] ==> r \<le> r ^ n"
paulson@14265
   223
apply (drule less_not_refl2 [THEN not0_implies_Suc])
paulson@14265
   224
apply (auto intro!: realpow_Suc_ge_self2)
paulson@14265
   225
done
paulson@14265
   226
paulson@14268
   227
lemma realpow_minus_mult [rule_format, simp]:
paulson@14268
   228
     "0 < n --> (x::real) ^ (n - 1) * x = x ^ n"
paulson@14265
   229
apply (induct_tac "n")
paulson@14265
   230
apply (auto simp add: real_mult_commute)
paulson@14265
   231
done
paulson@14265
   232
paulson@14268
   233
lemma realpow_two_mult_inverse [simp]: "r \<noteq> 0 ==> r * inverse r ^Suc (Suc 0) = inverse (r::real)"
paulson@14268
   234
by (simp add: realpow_two real_mult_assoc [symmetric])
paulson@14265
   235
paulson@14265
   236
(* 05/00 *)
paulson@14268
   237
lemma realpow_two_minus [simp]: "(-x)^Suc (Suc 0) = (x::real)^Suc (Suc 0)"
paulson@14268
   238
by simp
paulson@14265
   239
paulson@14265
   240
lemma realpow_two_diff: "(x::real)^Suc (Suc 0) - y^Suc (Suc 0) = (x - y) * (x + y)"
paulson@14265
   241
apply (unfold real_diff_def)
paulson@14265
   242
apply (simp add: real_add_mult_distrib2 real_add_mult_distrib real_mult_ac)
paulson@14265
   243
done
paulson@14265
   244
paulson@14265
   245
lemma realpow_two_disj: "((x::real)^Suc (Suc 0) = y^Suc (Suc 0)) = (x = y | x = -y)"
paulson@14268
   246
apply (cut_tac x = x and y = y in realpow_two_diff)
paulson@14265
   247
apply (auto simp del: realpow_Suc)
paulson@14265
   248
done
paulson@14265
   249
paulson@14265
   250
(* used in Transc *)
paulson@14265
   251
lemma realpow_diff: "[|(x::real) \<noteq> 0; m \<le> n |] ==> x ^ (n - m) = x ^ n * inverse (x ^ m)"
paulson@14268
   252
by (auto simp add: le_eq_less_or_eq less_iff_Suc_add realpow_add realpow_not_zero real_mult_ac)
paulson@14265
   253
paulson@14265
   254
lemma realpow_real_of_nat: "real (m::nat) ^ n = real (m ^ n)"
paulson@14265
   255
apply (induct_tac "n")
paulson@14265
   256
apply (auto simp add: real_of_nat_one real_of_nat_mult)
paulson@14265
   257
done
paulson@14265
   258
paulson@14268
   259
lemma realpow_real_of_nat_two_pos [simp] : "0 < real (Suc (Suc 0) ^ n)"
paulson@14265
   260
apply (induct_tac "n")
paulson@14265
   261
apply (auto simp add: real_of_nat_mult real_0_less_mult_iff)
paulson@14265
   262
done
paulson@14265
   263
paulson@14265
   264
lemma realpow_increasing:
paulson@14265
   265
  assumes xnonneg: "(0::real) \<le> x"
paulson@14265
   266
      and ynonneg: "0 \<le> y"
paulson@14265
   267
      and le: "x ^ Suc n \<le> y ^ Suc n"
paulson@14265
   268
  shows "x \<le> y"
paulson@14265
   269
 proof (rule ccontr)
paulson@14265
   270
   assume "~ x \<le> y"
paulson@14265
   271
   then have "y<x" by simp
paulson@14265
   272
   then have "y ^ Suc n < x ^ Suc n"
paulson@14265
   273
     by (simp only: prems realpow_less') 
paulson@14265
   274
   from le and this show "False"
paulson@14265
   275
     by simp
paulson@14265
   276
 qed
paulson@14265
   277
  
paulson@14265
   278
lemma realpow_Suc_cancel_eq: "[| (0::real) \<le> x; 0 \<le> y; x ^ Suc n = y ^ Suc n |] ==> x = y"
paulson@14268
   279
by (blast intro: realpow_increasing order_antisym order_eq_refl sym)
paulson@14265
   280
paulson@14265
   281
paulson@14265
   282
(*** Logical equivalences for inequalities ***)
paulson@14265
   283
paulson@14268
   284
lemma realpow_eq_0_iff [simp]: "(x^n = 0) = (x = (0::real) & 0<n)"
paulson@14268
   285
by (induct_tac "n", auto)
paulson@14265
   286
paulson@14268
   287
lemma zero_less_realpow_abs_iff [simp]: "(0 < (abs x)^n) = (x \<noteq> (0::real) | n=0)"
paulson@14265
   288
apply (induct_tac "n")
paulson@14265
   289
apply (auto simp add: real_0_less_mult_iff)
paulson@14265
   290
done
paulson@14265
   291
paulson@14268
   292
lemma zero_le_realpow_abs [simp]: "(0::real) \<le> (abs x)^n"
paulson@14265
   293
apply (induct_tac "n")
paulson@14265
   294
apply (auto simp add: real_0_le_mult_iff)
paulson@14265
   295
done
paulson@14265
   296
paulson@14265
   297
paulson@14265
   298
(*** Literal arithmetic involving powers, type real ***)
paulson@14265
   299
paulson@14265
   300
lemma real_of_int_power: "real (x::int) ^ n = real (x ^ n)"
paulson@14265
   301
apply (induct_tac "n")
paulson@14265
   302
apply (simp_all (no_asm_simp) add: nat_mult_distrib)
paulson@14265
   303
done
paulson@14265
   304
declare real_of_int_power [symmetric, simp]
paulson@14265
   305
paulson@14265
   306
lemma power_real_number_of: "(number_of v :: real) ^ n = real ((number_of v :: int) ^ n)"
paulson@14268
   307
by (simp only: real_number_of_def real_of_int_power)
paulson@14265
   308
paulson@14265
   309
declare power_real_number_of [of _ "number_of w", standard, simp]
paulson@14265
   310
paulson@14265
   311
paulson@14265
   312
lemma real_power_two: "(r::real)\<twosuperior> = r * r"
paulson@14265
   313
  by (simp add: numeral_2_eq_2)
paulson@14265
   314
paulson@14265
   315
lemma real_sqr_ge_zero [iff]: "0 \<le> (r::real)\<twosuperior>"
paulson@14265
   316
  by (simp add: real_power_two)
paulson@14265
   317
paulson@14265
   318
lemma real_sqr_gt_zero: "(r::real) \<noteq> 0 ==> 0 < r\<twosuperior>"
paulson@14265
   319
proof -
paulson@14265
   320
  assume "r \<noteq> 0"
paulson@14265
   321
  hence "0 \<noteq> r\<twosuperior>" by simp
paulson@14265
   322
  also have "0 \<le> r\<twosuperior>" by (simp add: real_sqr_ge_zero)
paulson@14265
   323
  finally show ?thesis .
paulson@14265
   324
qed
paulson@14265
   325
paulson@14265
   326
lemma real_sqr_not_zero: "r \<noteq> 0 ==> (r::real)\<twosuperior> \<noteq> 0"
paulson@14265
   327
  by simp
paulson@14265
   328
paulson@14265
   329
paulson@14268
   330
subsection{*Various Other Theorems*}
paulson@14268
   331
paulson@14268
   332
text{*Used several times in Hyperreal/Transcendental.ML*}
paulson@14268
   333
lemma real_sum_squares_cancel_a: "x * x = -(y * y) ==> x = (0::real) & y=0"
paulson@14268
   334
  by (auto intro: real_sum_squares_cancel)
paulson@14268
   335
paulson@14268
   336
lemma real_squared_diff_one_factored: "x*x - (1::real) = (x + 1)*(x - 1)"
paulson@14268
   337
apply (auto simp add: real_add_mult_distrib real_add_mult_distrib2 real_diff_def)
paulson@14268
   338
done
paulson@14268
   339
paulson@14268
   340
lemma real_mult_is_one: "(x*x = (1::real)) = (x = 1 | x = - 1)"
paulson@14268
   341
apply auto
paulson@14268
   342
apply (drule right_minus_eq [THEN iffD2]) 
paulson@14268
   343
apply (auto simp add: real_squared_diff_one_factored)
paulson@14268
   344
done
paulson@14268
   345
declare real_mult_is_one [iff]
paulson@14268
   346
paulson@14268
   347
lemma real_le_add_half_cancel: "(x + y/2 <= (y::real)) = (x <= y /2)"
paulson@14268
   348
apply auto
paulson@14268
   349
done
paulson@14268
   350
declare real_le_add_half_cancel [simp]
paulson@14268
   351
paulson@14268
   352
lemma real_minus_half_eq: "(x::real) - x/2 = x/2"
paulson@14268
   353
apply auto
paulson@14268
   354
done
paulson@14268
   355
declare real_minus_half_eq [simp]
paulson@14268
   356
paulson@14268
   357
lemma real_mult_inverse_cancel:
paulson@14268
   358
     "[|(0::real) < x; 0 < x1; x1 * y < x * u |] 
paulson@14268
   359
      ==> inverse x * y < inverse x1 * u"
paulson@14268
   360
apply (rule_tac c=x in mult_less_imp_less_left) 
paulson@14268
   361
apply (auto simp add: real_mult_assoc [symmetric])
paulson@14268
   362
apply (simp (no_asm) add: real_mult_ac)
paulson@14268
   363
apply (rule_tac c=x1 in mult_less_imp_less_right) 
paulson@14268
   364
apply (auto simp add: real_mult_ac)
paulson@14268
   365
done
paulson@14268
   366
paulson@14268
   367
text{*Used once: in Hyperreal/Transcendental.ML*}
paulson@14268
   368
lemma real_mult_inverse_cancel2: "[|(0::real) < x;0 < x1; x1 * y < x * u |] ==> y * inverse x < u * inverse x1"
paulson@14268
   369
apply (auto dest: real_mult_inverse_cancel simp add: real_mult_ac)
paulson@14268
   370
done
paulson@14268
   371
paulson@14268
   372
lemma inverse_real_of_nat_gt_zero: "0 < inverse (real (Suc n))"
paulson@14268
   373
apply auto
paulson@14268
   374
done
paulson@14268
   375
declare inverse_real_of_nat_gt_zero [simp]
paulson@14268
   376
paulson@14268
   377
lemma inverse_real_of_nat_ge_zero: "0 <= inverse (real (Suc n))"
paulson@14268
   378
apply auto
paulson@14268
   379
done
paulson@14268
   380
declare inverse_real_of_nat_ge_zero [simp]
paulson@14268
   381
paulson@14268
   382
lemma real_sum_squares_not_zero: "x ~= 0 ==> x * x + y * y ~= (0::real)"
paulson@14268
   383
apply (blast dest!: real_sum_squares_cancel) 
paulson@14268
   384
done
paulson@14268
   385
paulson@14268
   386
lemma real_sum_squares_not_zero2: "y ~= 0 ==> x * x + y * y ~= (0::real)"
paulson@14268
   387
apply (blast dest!: real_sum_squares_cancel2) 
paulson@14268
   388
done
paulson@14268
   389
paulson@14268
   390
(* nice theorem *)
paulson@14268
   391
lemma abs_mult_abs: "abs x * abs x = x * (x::real)"
paulson@14268
   392
apply (insert linorder_less_linear [of x 0]) 
paulson@14268
   393
apply (auto simp add: abs_eqI2 abs_minus_eqI2)
paulson@14268
   394
done
paulson@14268
   395
declare abs_mult_abs [simp]
paulson@14268
   396
paulson@14268
   397
paulson@14268
   398
subsection {*Various Other Theorems*}
paulson@14268
   399
paulson@14268
   400
lemma realpow_divide: 
paulson@14268
   401
    "(x/y) ^ n = ((x::real) ^ n/ y ^ n)"
paulson@14268
   402
apply (unfold real_divide_def)
paulson@14268
   403
apply (auto simp add: realpow_mult realpow_inverse)
paulson@14268
   404
done
paulson@14268
   405
paulson@14268
   406
lemma realpow_ge_zero2 [rule_format (no_asm)]: "(0::real) <= r --> 0 <= r ^ n"
paulson@14268
   407
apply (induct_tac "n")
paulson@14268
   408
apply (auto simp add: real_0_le_mult_iff)
paulson@14268
   409
done
paulson@14268
   410
paulson@14268
   411
lemma realpow_le2 [rule_format (no_asm)]: "(0::real) <= x & x <= y --> x ^ n <= y ^ n"
paulson@14268
   412
apply (induct_tac "n")
paulson@14268
   413
apply (auto intro!: real_mult_le_mono simp add: realpow_ge_zero2)
paulson@14268
   414
done
paulson@14268
   415
paulson@14268
   416
lemma realpow_Suc_gt_one: "(1::real) < r ==> 1 < r ^ (Suc n)"
paulson@14268
   417
apply (frule_tac n = "n" in realpow_ge_one)
paulson@14268
   418
apply (drule real_le_imp_less_or_eq, safe)
paulson@14268
   419
apply (frule real_zero_less_one [THEN real_less_trans])
paulson@14268
   420
apply (drule_tac y = "r ^ n" in real_mult_less_mono2)
paulson@14268
   421
apply assumption
paulson@14268
   422
apply (auto dest: real_less_trans)
paulson@14268
   423
done
paulson@14268
   424
paulson@14268
   425
lemma realpow_two_sum_zero_iff: "(x ^ 2 + y ^ 2 = (0::real)) = (x = 0 & y = 0)"
paulson@14268
   426
apply (auto intro: real_sum_squares_cancel real_sum_squares_cancel2 simp add: numeral_2_eq_2)
paulson@14268
   427
done
paulson@14268
   428
declare realpow_two_sum_zero_iff [simp]
paulson@14268
   429
paulson@14268
   430
lemma realpow_two_le_add_order: "(0::real) <= u ^ 2 + v ^ 2"
paulson@14268
   431
apply (rule real_le_add_order)
paulson@14268
   432
apply (auto simp add: numeral_2_eq_2)
paulson@14268
   433
done
paulson@14268
   434
declare realpow_two_le_add_order [simp]
paulson@14268
   435
paulson@14268
   436
lemma realpow_two_le_add_order2: "(0::real) <= u ^ 2 + v ^ 2 + w ^ 2"
paulson@14268
   437
apply (rule real_le_add_order)+
paulson@14268
   438
apply (auto simp add: numeral_2_eq_2)
paulson@14268
   439
done
paulson@14268
   440
declare realpow_two_le_add_order2 [simp]
paulson@14268
   441
paulson@14268
   442
lemma real_mult_self_sum_ge_zero: "(0::real) <= x*x + y*y"
paulson@14268
   443
apply (cut_tac u = "x" and v = "y" in realpow_two_le_add_order)
paulson@14268
   444
apply (auto simp add: numeral_2_eq_2)
paulson@14268
   445
done
paulson@14268
   446
declare real_mult_self_sum_ge_zero [simp]
paulson@14268
   447
declare real_mult_self_sum_ge_zero [THEN abs_eqI1, simp]
paulson@14268
   448
paulson@14268
   449
lemma real_sum_square_gt_zero: "x ~= 0 ==> (0::real) < x * x + y * y"
paulson@14268
   450
apply (cut_tac x = "x" and y = "y" in real_mult_self_sum_ge_zero)
paulson@14268
   451
apply (drule real_le_imp_less_or_eq)
paulson@14268
   452
apply (drule_tac y = "y" in real_sum_squares_not_zero)
paulson@14268
   453
apply auto
paulson@14268
   454
done
paulson@14268
   455
paulson@14268
   456
lemma real_sum_square_gt_zero2: "y ~= 0 ==> (0::real) < x * x + y * y"
paulson@14268
   457
apply (rule real_add_commute [THEN subst])
paulson@14268
   458
apply (erule real_sum_square_gt_zero)
paulson@14268
   459
done
paulson@14268
   460
paulson@14268
   461
lemma real_minus_mult_self_le: "-(u * u) <= (x * (x::real))"
paulson@14268
   462
apply (rule_tac j = "0" in real_le_trans)
paulson@14268
   463
apply auto
paulson@14268
   464
done
paulson@14268
   465
declare real_minus_mult_self_le [simp]
paulson@14268
   466
paulson@14268
   467
lemma realpow_square_minus_le: "-(u ^ 2) <= (x::real) ^ 2"
paulson@14268
   468
apply (auto simp add: numeral_2_eq_2)
paulson@14268
   469
done
paulson@14268
   470
declare realpow_square_minus_le [simp]
paulson@14268
   471
paulson@14268
   472
lemma realpow_num_eq_if: "(m::real) ^ n = (if n=0 then 1 else m * m ^ (n - 1))"
paulson@14268
   473
apply (case_tac "n")
paulson@14268
   474
apply auto
paulson@14268
   475
done
paulson@14268
   476
paulson@14268
   477
lemma real_num_zero_less_two_pow: "0 < (2::real) ^ (4*d)"
paulson@14268
   478
apply (induct_tac "d")
paulson@14268
   479
apply (auto simp add: realpow_num_eq_if)
paulson@14268
   480
done
paulson@14268
   481
declare real_num_zero_less_two_pow [simp]
paulson@14268
   482
paulson@14268
   483
lemma lemma_realpow_num_two_mono: "x * (4::real)   < y ==> x * (2 ^ 8) < y * (2 ^ 6)"
paulson@14268
   484
apply (subgoal_tac " (2::real) ^ 8 = 4 * (2 ^ 6) ")
paulson@14268
   485
apply (simp (no_asm_simp) add: real_mult_assoc [symmetric])
paulson@14268
   486
apply (auto simp add: realpow_num_eq_if)
paulson@14268
   487
done
paulson@14268
   488
paulson@14268
   489
lemma lemma_realpow_4: "2 ^ 2 = (4::real)"
paulson@14268
   490
apply (simp (no_asm) add: realpow_num_eq_if)
paulson@14268
   491
done
paulson@14268
   492
declare lemma_realpow_4 [simp]
paulson@14268
   493
paulson@14268
   494
lemma lemma_realpow_16: "2 ^ 4 = (16::real)"
paulson@14268
   495
apply (simp (no_asm) add: realpow_num_eq_if)
paulson@14268
   496
done
paulson@14268
   497
declare lemma_realpow_16 [simp]
paulson@14268
   498
paulson@14268
   499
lemma zero_le_x_squared: "(0::real) <= x^2"
paulson@14268
   500
apply (simp add: numeral_2_eq_2)
paulson@14268
   501
done
paulson@14268
   502
declare zero_le_x_squared [simp]
paulson@14268
   503
paulson@14268
   504
paulson@14268
   505
paulson@14265
   506
ML
paulson@14265
   507
{*
paulson@14265
   508
val realpow_0 = thm "realpow_0";
paulson@14265
   509
val realpow_Suc = thm "realpow_Suc";
paulson@14265
   510
paulson@14265
   511
val realpow_zero = thm "realpow_zero";
paulson@14265
   512
val realpow_not_zero = thm "realpow_not_zero";
paulson@14265
   513
val realpow_zero_zero = thm "realpow_zero_zero";
paulson@14265
   514
val realpow_inverse = thm "realpow_inverse";
paulson@14265
   515
val realpow_abs = thm "realpow_abs";
paulson@14265
   516
val realpow_add = thm "realpow_add";
paulson@14265
   517
val realpow_one = thm "realpow_one";
paulson@14265
   518
val realpow_two = thm "realpow_two";
paulson@14265
   519
val realpow_gt_zero = thm "realpow_gt_zero";
paulson@14265
   520
val realpow_ge_zero = thm "realpow_ge_zero";
paulson@14265
   521
val realpow_le = thm "realpow_le";
paulson@14265
   522
val realpow_0_left = thm "realpow_0_left";
paulson@14265
   523
val realpow_less = thm "realpow_less";
paulson@14265
   524
val realpow_eq_one = thm "realpow_eq_one";
paulson@14265
   525
val abs_realpow_minus_one = thm "abs_realpow_minus_one";
paulson@14265
   526
val realpow_mult = thm "realpow_mult";
paulson@14265
   527
val realpow_two_le = thm "realpow_two_le";
paulson@14265
   528
val abs_realpow_two = thm "abs_realpow_two";
paulson@14265
   529
val realpow_two_abs = thm "realpow_two_abs";
paulson@14265
   530
val realpow_two_gt_one = thm "realpow_two_gt_one";
paulson@14265
   531
val realpow_ge_one = thm "realpow_ge_one";
paulson@14265
   532
val realpow_ge_one2 = thm "realpow_ge_one2";
paulson@14265
   533
val two_realpow_ge_one = thm "two_realpow_ge_one";
paulson@14265
   534
val two_realpow_gt = thm "two_realpow_gt";
paulson@14265
   535
val realpow_minus_one = thm "realpow_minus_one";
paulson@14265
   536
val realpow_minus_one_odd = thm "realpow_minus_one_odd";
paulson@14265
   537
val realpow_minus_one_even = thm "realpow_minus_one_even";
paulson@14265
   538
val realpow_Suc_less = thm "realpow_Suc_less";
paulson@14265
   539
val realpow_Suc_le = thm "realpow_Suc_le";
paulson@14265
   540
val realpow_zero_le = thm "realpow_zero_le";
paulson@14265
   541
val realpow_Suc_le2 = thm "realpow_Suc_le2";
paulson@14265
   542
val realpow_Suc_le3 = thm "realpow_Suc_le3";
paulson@14265
   543
val realpow_less_le = thm "realpow_less_le";
paulson@14265
   544
val realpow_le_le = thm "realpow_le_le";
paulson@14265
   545
val realpow_Suc_le_self = thm "realpow_Suc_le_self";
paulson@14265
   546
val realpow_Suc_less_one = thm "realpow_Suc_less_one";
paulson@14265
   547
val realpow_le_Suc = thm "realpow_le_Suc";
paulson@14265
   548
val realpow_less_Suc = thm "realpow_less_Suc";
paulson@14265
   549
val realpow_le_Suc2 = thm "realpow_le_Suc2";
paulson@14265
   550
val realpow_gt_ge2 = thm "realpow_gt_ge2";
paulson@14265
   551
val realpow_ge_ge2 = thm "realpow_ge_ge2";
paulson@14265
   552
val realpow_Suc_ge_self2 = thm "realpow_Suc_ge_self2";
paulson@14265
   553
val realpow_ge_self2 = thm "realpow_ge_self2";
paulson@14265
   554
val realpow_minus_mult = thm "realpow_minus_mult";
paulson@14265
   555
val realpow_two_mult_inverse = thm "realpow_two_mult_inverse";
paulson@14265
   556
val realpow_two_minus = thm "realpow_two_minus";
paulson@14265
   557
val realpow_two_disj = thm "realpow_two_disj";
paulson@14265
   558
val realpow_diff = thm "realpow_diff";
paulson@14265
   559
val realpow_real_of_nat = thm "realpow_real_of_nat";
paulson@14265
   560
val realpow_real_of_nat_two_pos = thm "realpow_real_of_nat_two_pos";
paulson@14265
   561
val realpow_increasing = thm "realpow_increasing";
paulson@14265
   562
val realpow_Suc_cancel_eq = thm "realpow_Suc_cancel_eq";
paulson@14265
   563
val realpow_eq_0_iff = thm "realpow_eq_0_iff";
paulson@14265
   564
val zero_less_realpow_abs_iff = thm "zero_less_realpow_abs_iff";
paulson@14265
   565
val zero_le_realpow_abs = thm "zero_le_realpow_abs";
paulson@14265
   566
val real_of_int_power = thm "real_of_int_power";
paulson@14265
   567
val power_real_number_of = thm "power_real_number_of";
paulson@14265
   568
val real_power_two = thm "real_power_two";
paulson@14265
   569
val real_sqr_ge_zero = thm "real_sqr_ge_zero";
paulson@14265
   570
val real_sqr_gt_zero = thm "real_sqr_gt_zero";
paulson@14265
   571
val real_sqr_not_zero = thm "real_sqr_not_zero";
paulson@14268
   572
val real_sum_squares_cancel_a = thm "real_sum_squares_cancel_a";
paulson@14268
   573
val real_mult_inverse_cancel2 = thm "real_mult_inverse_cancel2";
paulson@14268
   574
val real_squared_diff_one_factored = thm "real_squared_diff_one_factored";
paulson@14268
   575
val real_mult_is_one = thm "real_mult_is_one";
paulson@14268
   576
val real_le_add_half_cancel = thm "real_le_add_half_cancel";
paulson@14268
   577
val real_minus_half_eq = thm "real_minus_half_eq";
paulson@14268
   578
val real_mult_inverse_cancel = thm "real_mult_inverse_cancel";
paulson@14268
   579
val real_mult_inverse_cancel2 = thm "real_mult_inverse_cancel2";
paulson@14268
   580
val inverse_real_of_nat_gt_zero = thm "inverse_real_of_nat_gt_zero";
paulson@14268
   581
val inverse_real_of_nat_ge_zero = thm "inverse_real_of_nat_ge_zero";
paulson@14268
   582
val real_sum_squares_not_zero = thm "real_sum_squares_not_zero";
paulson@14268
   583
val real_sum_squares_not_zero2 = thm "real_sum_squares_not_zero2";
paulson@14268
   584
val abs_mult_abs = thm "abs_mult_abs";
paulson@14268
   585
paulson@14268
   586
val realpow_divide = thm "realpow_divide";
paulson@14268
   587
val realpow_ge_zero2 = thm "realpow_ge_zero2";
paulson@14268
   588
val realpow_le2 = thm "realpow_le2";
paulson@14268
   589
val realpow_Suc_gt_one = thm "realpow_Suc_gt_one";
paulson@14268
   590
val realpow_two_sum_zero_iff = thm "realpow_two_sum_zero_iff";
paulson@14268
   591
val realpow_two_le_add_order = thm "realpow_two_le_add_order";
paulson@14268
   592
val realpow_two_le_add_order2 = thm "realpow_two_le_add_order2";
paulson@14268
   593
val real_mult_self_sum_ge_zero = thm "real_mult_self_sum_ge_zero";
paulson@14268
   594
val real_sum_square_gt_zero = thm "real_sum_square_gt_zero";
paulson@14268
   595
val real_sum_square_gt_zero2 = thm "real_sum_square_gt_zero2";
paulson@14268
   596
val real_minus_mult_self_le = thm "real_minus_mult_self_le";
paulson@14268
   597
val realpow_square_minus_le = thm "realpow_square_minus_le";
paulson@14268
   598
val realpow_num_eq_if = thm "realpow_num_eq_if";
paulson@14268
   599
val real_num_zero_less_two_pow = thm "real_num_zero_less_two_pow";
paulson@14268
   600
val lemma_realpow_num_two_mono = thm "lemma_realpow_num_two_mono";
paulson@14268
   601
val lemma_realpow_4 = thm "lemma_realpow_4";
paulson@14268
   602
val lemma_realpow_16 = thm "lemma_realpow_16";
paulson@14268
   603
val zero_le_x_squared = thm "zero_le_x_squared";
paulson@14265
   604
*}
paulson@14265
   605
paulson@14265
   606
paulson@7077
   607
end