src/HOL/RealPow.thy
author huffman
Sat Jun 06 09:11:12 2009 -0700 (2009-06-06)
changeset 31488 5691ccb8d6b5
parent 31021 53642251a04f
child 35123 e286d5df187a
permissions -rw-r--r--
generalize tendsto to class topological_space
haftmann@28952
     1
(*  Title       : HOL/RealPow.thy
paulson@7077
     2
    Author      : Jacques D. Fleuriot  
paulson@7077
     3
    Copyright   : 1998  University of Cambridge
huffman@20634
     4
*)
paulson@7077
     5
huffman@20634
     6
header {* Natural powers theory *}
paulson@7077
     7
nipkow@15131
     8
theory RealPow
nipkow@15140
     9
imports RealDef
haftmann@28952
    10
uses ("Tools/float_syntax.ML")
nipkow@15131
    11
begin
wenzelm@9435
    12
paulson@14348
    13
declare abs_mult_self [simp]
paulson@14348
    14
paulson@14268
    15
lemma two_realpow_ge_one [simp]: "(1::real) \<le> 2 ^ n"
nipkow@25875
    16
by simp
paulson@14265
    17
paulson@14268
    18
lemma two_realpow_gt [simp]: "real (n::nat) < 2 ^ n"
paulson@15251
    19
apply (induct "n")
paulson@14265
    20
apply (auto simp add: real_of_nat_Suc)
paulson@14387
    21
apply (subst mult_2)
huffman@22962
    22
apply (rule add_less_le_mono)
paulson@14265
    23
apply (auto simp add: two_realpow_ge_one)
paulson@14265
    24
done
paulson@14265
    25
paulson@14348
    26
lemma realpow_Suc_le_self: "[| 0 \<le> r; r \<le> (1::real) |] ==> r ^ Suc n \<le> r"
paulson@14348
    27
by (insert power_decreasing [of 1 "Suc n" r], simp)
paulson@14265
    28
paulson@14348
    29
lemma realpow_minus_mult [rule_format]:
huffman@30082
    30
     "0 < n --> (x::real) ^ (n - 1) * x = x ^ n"
paulson@14348
    31
apply (simp split add: nat_diff_split)
paulson@14265
    32
done
paulson@14265
    33
paulson@14348
    34
lemma realpow_two_mult_inverse [simp]:
paulson@14348
    35
     "r \<noteq> 0 ==> r * inverse r ^Suc (Suc 0) = inverse (r::real)"
obua@23292
    36
by (simp add:  real_mult_assoc [symmetric])
paulson@14265
    37
paulson@14268
    38
lemma realpow_two_minus [simp]: "(-x)^Suc (Suc 0) = (x::real)^Suc (Suc 0)"
paulson@14268
    39
by simp
paulson@14265
    40
paulson@14348
    41
lemma realpow_two_diff:
paulson@14348
    42
     "(x::real)^Suc (Suc 0) - y^Suc (Suc 0) = (x - y) * (x + y)"
paulson@14265
    43
apply (unfold real_diff_def)
nipkow@29667
    44
apply (simp add: algebra_simps)
paulson@14265
    45
done
paulson@14265
    46
paulson@14348
    47
lemma realpow_two_disj:
paulson@14348
    48
     "((x::real)^Suc (Suc 0) = y^Suc (Suc 0)) = (x = y | x = -y)"
paulson@14268
    49
apply (cut_tac x = x and y = y in realpow_two_diff)
huffman@30273
    50
apply auto
paulson@14265
    51
done
paulson@14265
    52
paulson@14265
    53
lemma realpow_real_of_nat: "real (m::nat) ^ n = real (m ^ n)"
paulson@15251
    54
apply (induct "n")
paulson@14265
    55
apply (auto simp add: real_of_nat_one real_of_nat_mult)
paulson@14265
    56
done
paulson@14265
    57
paulson@14268
    58
lemma realpow_real_of_nat_two_pos [simp] : "0 < real (Suc (Suc 0) ^ n)"
paulson@15251
    59
apply (induct "n")
paulson@14334
    60
apply (auto simp add: real_of_nat_mult zero_less_mult_iff)
paulson@14265
    61
done
paulson@14265
    62
huffman@22962
    63
(* used by AFP Integration theory *)
paulson@14265
    64
lemma realpow_increasing:
paulson@14348
    65
     "[|(0::real) \<le> x; 0 \<le> y; x ^ Suc n \<le> y ^ Suc n|] ==> x \<le> y"
paulson@14348
    66
  by (rule power_le_imp_le_base)
paulson@14265
    67
paulson@14265
    68
paulson@14348
    69
subsection{*Literal Arithmetic Involving Powers, Type @{typ real}*}
paulson@14265
    70
paulson@14265
    71
lemma real_of_int_power: "real (x::int) ^ n = real (x ^ n)"
paulson@15251
    72
apply (induct "n")
paulson@14387
    73
apply (simp_all add: nat_mult_distrib)
paulson@14265
    74
done
paulson@14265
    75
declare real_of_int_power [symmetric, simp]
paulson@14265
    76
paulson@14348
    77
lemma power_real_number_of:
paulson@14348
    78
     "(number_of v :: real) ^ n = real ((number_of v :: int) ^ n)"
paulson@14387
    79
by (simp only: real_number_of [symmetric] real_of_int_power)
paulson@14265
    80
paulson@14265
    81
declare power_real_number_of [of _ "number_of w", standard, simp]
paulson@14265
    82
paulson@14265
    83
huffman@22970
    84
subsection{* Squares of Reals *}
huffman@22970
    85
huffman@22970
    86
lemma real_two_squares_add_zero_iff [simp]:
huffman@22970
    87
  "(x * x + y * y = 0) = ((x::real) = 0 \<and> y = 0)"
huffman@22970
    88
by (rule sum_squares_eq_zero_iff)
huffman@22970
    89
huffman@22970
    90
lemma real_sum_squares_cancel: "x * x + y * y = 0 ==> x = (0::real)"
huffman@22970
    91
by simp
huffman@22970
    92
huffman@22970
    93
lemma real_sum_squares_cancel2: "x * x + y * y = 0 ==> y = (0::real)"
huffman@22970
    94
by simp
huffman@22970
    95
huffman@22970
    96
lemma real_mult_self_sum_ge_zero: "(0::real) \<le> x*x + y*y"
huffman@22970
    97
by (rule sum_squares_ge_zero)
paulson@14268
    98
paulson@14268
    99
lemma real_sum_squares_cancel_a: "x * x = -(y * y) ==> x = (0::real) & y=0"
huffman@22970
   100
by (simp add: real_add_eq_0_iff [symmetric])
paulson@14268
   101
paulson@14268
   102
lemma real_squared_diff_one_factored: "x*x - (1::real) = (x + 1)*(x - 1)"
huffman@22970
   103
by (simp add: left_distrib right_diff_distrib)
paulson@14268
   104
paulson@14348
   105
lemma real_mult_is_one [simp]: "(x*x = (1::real)) = (x = 1 | x = - 1)"
paulson@14268
   106
apply auto
paulson@14268
   107
apply (drule right_minus_eq [THEN iffD2]) 
paulson@14268
   108
apply (auto simp add: real_squared_diff_one_factored)
paulson@14268
   109
done
paulson@14268
   110
huffman@22970
   111
lemma real_sum_squares_not_zero: "x ~= 0 ==> x * x + y * y ~= (0::real)"
huffman@22970
   112
by simp
huffman@22970
   113
huffman@22970
   114
lemma real_sum_squares_not_zero2: "y ~= 0 ==> x * x + y * y ~= (0::real)"
huffman@22970
   115
by simp
huffman@22970
   116
huffman@22970
   117
lemma realpow_two_sum_zero_iff [simp]:
huffman@22970
   118
     "(x ^ 2 + y ^ 2 = (0::real)) = (x = 0 & y = 0)"
huffman@22970
   119
by (rule sum_power2_eq_zero_iff)
huffman@22970
   120
huffman@22970
   121
lemma realpow_two_le_add_order [simp]: "(0::real) \<le> u ^ 2 + v ^ 2"
huffman@22970
   122
by (rule sum_power2_ge_zero)
huffman@22970
   123
huffman@22970
   124
lemma realpow_two_le_add_order2 [simp]: "(0::real) \<le> u ^ 2 + v ^ 2 + w ^ 2"
huffman@22970
   125
by (intro add_nonneg_nonneg zero_le_power2)
huffman@22970
   126
huffman@22970
   127
lemma real_sum_square_gt_zero: "x ~= 0 ==> (0::real) < x * x + y * y"
huffman@22970
   128
by (simp add: sum_squares_gt_zero_iff)
huffman@22970
   129
huffman@22970
   130
lemma real_sum_square_gt_zero2: "y ~= 0 ==> (0::real) < x * x + y * y"
huffman@22970
   131
by (simp add: sum_squares_gt_zero_iff)
huffman@22970
   132
huffman@22970
   133
lemma real_minus_mult_self_le [simp]: "-(u * u) \<le> (x * (x::real))"
huffman@22970
   134
by (rule_tac j = 0 in real_le_trans, auto)
huffman@22970
   135
huffman@22970
   136
lemma realpow_square_minus_le [simp]: "-(u ^ 2) \<le> (x::real) ^ 2"
huffman@22970
   137
by (auto simp add: power2_eq_square)
huffman@22970
   138
huffman@22970
   139
(* The following theorem is by Benjamin Porter *)
huffman@22970
   140
lemma real_sq_order:
huffman@22970
   141
  fixes x::real
huffman@22970
   142
  assumes xgt0: "0 \<le> x" and ygt0: "0 \<le> y" and sq: "x^2 \<le> y^2"
huffman@22970
   143
  shows "x \<le> y"
huffman@22970
   144
proof -
huffman@22970
   145
  from sq have "x ^ Suc (Suc 0) \<le> y ^ Suc (Suc 0)"
huffman@22970
   146
    by (simp only: numeral_2_eq_2)
huffman@22970
   147
  thus "x \<le> y" using ygt0
huffman@22970
   148
    by (rule power_le_imp_le_base)
huffman@22970
   149
qed
huffman@22970
   150
huffman@22970
   151
huffman@22970
   152
subsection {*Various Other Theorems*}
huffman@22970
   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 realpow_num_eq_if: "(m::real) ^ n = (if n=0 then 1 else m * m ^ (n - 1))"
paulson@14348
   182
by (case_tac "n", auto)
paulson@14268
   183
nipkow@28906
   184
subsection{* Float syntax *}
nipkow@28906
   185
nipkow@28906
   186
syntax "_Float" :: "float_const \<Rightarrow> 'a"    ("_")
nipkow@28906
   187
haftmann@28952
   188
use "Tools/float_syntax.ML"
nipkow@28906
   189
setup FloatSyntax.setup
nipkow@28906
   190
nipkow@28906
   191
text{* Test: *}
nipkow@28906
   192
lemma "123.456 = -111.111 + 200 + 30 + 4 + 5/10 + 6/100 + (7/1000::real)"
nipkow@28906
   193
by simp
nipkow@28906
   194
paulson@7077
   195
end