src/HOL/RealPow.thy
author wenzelm
Thu Feb 11 23:00:22 2010 +0100 (2010-02-11)
changeset 35115 446c5063e4fd
parent 31021 53642251a04f
child 35123 e286d5df187a
permissions -rw-r--r--
modernized translations;
formal markup of @{syntax_const} and @{const_syntax};
minor tuning;
     1 (*  Title       : HOL/RealPow.thy
     2     Author      : Jacques D. Fleuriot  
     3     Copyright   : 1998  University of Cambridge
     4 *)
     5 
     6 header {* Natural powers theory *}
     7 
     8 theory RealPow
     9 imports RealDef
    10 uses ("Tools/float_syntax.ML")
    11 begin
    12 
    13 declare abs_mult_self [simp]
    14 
    15 lemma two_realpow_ge_one [simp]: "(1::real) \<le> 2 ^ n"
    16 by simp
    17 
    18 lemma two_realpow_gt [simp]: "real (n::nat) < 2 ^ n"
    19 apply (induct "n")
    20 apply (auto simp add: real_of_nat_Suc)
    21 apply (subst mult_2)
    22 apply (rule add_less_le_mono)
    23 apply (auto simp add: two_realpow_ge_one)
    24 done
    25 
    26 lemma realpow_Suc_le_self: "[| 0 \<le> r; r \<le> (1::real) |] ==> r ^ Suc n \<le> r"
    27 by (insert power_decreasing [of 1 "Suc n" r], simp)
    28 
    29 lemma realpow_minus_mult [rule_format]:
    30      "0 < n --> (x::real) ^ (n - 1) * x = x ^ n"
    31 apply (simp split add: nat_diff_split)
    32 done
    33 
    34 lemma realpow_two_mult_inverse [simp]:
    35      "r \<noteq> 0 ==> r * inverse r ^Suc (Suc 0) = inverse (r::real)"
    36 by (simp add:  real_mult_assoc [symmetric])
    37 
    38 lemma realpow_two_minus [simp]: "(-x)^Suc (Suc 0) = (x::real)^Suc (Suc 0)"
    39 by simp
    40 
    41 lemma realpow_two_diff:
    42      "(x::real)^Suc (Suc 0) - y^Suc (Suc 0) = (x - y) * (x + y)"
    43 apply (unfold real_diff_def)
    44 apply (simp add: algebra_simps)
    45 done
    46 
    47 lemma realpow_two_disj:
    48      "((x::real)^Suc (Suc 0) = y^Suc (Suc 0)) = (x = y | x = -y)"
    49 apply (cut_tac x = x and y = y in realpow_two_diff)
    50 apply auto
    51 done
    52 
    53 lemma realpow_real_of_nat: "real (m::nat) ^ n = real (m ^ n)"
    54 apply (induct "n")
    55 apply (auto simp add: real_of_nat_one real_of_nat_mult)
    56 done
    57 
    58 lemma realpow_real_of_nat_two_pos [simp] : "0 < real (Suc (Suc 0) ^ n)"
    59 apply (induct "n")
    60 apply (auto simp add: real_of_nat_mult zero_less_mult_iff)
    61 done
    62 
    63 (* used by AFP Integration theory *)
    64 lemma realpow_increasing:
    65      "[|(0::real) \<le> x; 0 \<le> y; x ^ Suc n \<le> y ^ Suc n|] ==> x \<le> y"
    66   by (rule power_le_imp_le_base)
    67 
    68 
    69 subsection{*Literal Arithmetic Involving Powers, Type @{typ real}*}
    70 
    71 lemma real_of_int_power: "real (x::int) ^ n = real (x ^ n)"
    72 apply (induct "n")
    73 apply (simp_all add: nat_mult_distrib)
    74 done
    75 declare real_of_int_power [symmetric, simp]
    76 
    77 lemma power_real_number_of:
    78      "(number_of v :: real) ^ n = real ((number_of v :: int) ^ n)"
    79 by (simp only: real_number_of [symmetric] real_of_int_power)
    80 
    81 declare power_real_number_of [of _ "number_of w", standard, simp]
    82 
    83 
    84 subsection{* Squares of Reals *}
    85 
    86 lemma real_two_squares_add_zero_iff [simp]:
    87   "(x * x + y * y = 0) = ((x::real) = 0 \<and> y = 0)"
    88 by (rule sum_squares_eq_zero_iff)
    89 
    90 lemma real_sum_squares_cancel: "x * x + y * y = 0 ==> x = (0::real)"
    91 by simp
    92 
    93 lemma real_sum_squares_cancel2: "x * x + y * y = 0 ==> y = (0::real)"
    94 by simp
    95 
    96 lemma real_mult_self_sum_ge_zero: "(0::real) \<le> x*x + y*y"
    97 by (rule sum_squares_ge_zero)
    98 
    99 lemma real_sum_squares_cancel_a: "x * x = -(y * y) ==> x = (0::real) & y=0"
   100 by (simp add: real_add_eq_0_iff [symmetric])
   101 
   102 lemma real_squared_diff_one_factored: "x*x - (1::real) = (x + 1)*(x - 1)"
   103 by (simp add: left_distrib right_diff_distrib)
   104 
   105 lemma real_mult_is_one [simp]: "(x*x = (1::real)) = (x = 1 | x = - 1)"
   106 apply auto
   107 apply (drule right_minus_eq [THEN iffD2]) 
   108 apply (auto simp add: real_squared_diff_one_factored)
   109 done
   110 
   111 lemma real_sum_squares_not_zero: "x ~= 0 ==> x * x + y * y ~= (0::real)"
   112 by simp
   113 
   114 lemma real_sum_squares_not_zero2: "y ~= 0 ==> x * x + y * y ~= (0::real)"
   115 by simp
   116 
   117 lemma realpow_two_sum_zero_iff [simp]:
   118      "(x ^ 2 + y ^ 2 = (0::real)) = (x = 0 & y = 0)"
   119 by (rule sum_power2_eq_zero_iff)
   120 
   121 lemma realpow_two_le_add_order [simp]: "(0::real) \<le> u ^ 2 + v ^ 2"
   122 by (rule sum_power2_ge_zero)
   123 
   124 lemma realpow_two_le_add_order2 [simp]: "(0::real) \<le> u ^ 2 + v ^ 2 + w ^ 2"
   125 by (intro add_nonneg_nonneg zero_le_power2)
   126 
   127 lemma real_sum_square_gt_zero: "x ~= 0 ==> (0::real) < x * x + y * y"
   128 by (simp add: sum_squares_gt_zero_iff)
   129 
   130 lemma real_sum_square_gt_zero2: "y ~= 0 ==> (0::real) < x * x + y * y"
   131 by (simp add: sum_squares_gt_zero_iff)
   132 
   133 lemma real_minus_mult_self_le [simp]: "-(u * u) \<le> (x * (x::real))"
   134 by (rule_tac j = 0 in real_le_trans, auto)
   135 
   136 lemma realpow_square_minus_le [simp]: "-(u ^ 2) \<le> (x::real) ^ 2"
   137 by (auto simp add: power2_eq_square)
   138 
   139 (* The following theorem is by Benjamin Porter *)
   140 lemma real_sq_order:
   141   fixes x::real
   142   assumes xgt0: "0 \<le> x" and ygt0: "0 \<le> y" and sq: "x^2 \<le> y^2"
   143   shows "x \<le> y"
   144 proof -
   145   from sq have "x ^ Suc (Suc 0) \<le> y ^ Suc (Suc 0)"
   146     by (simp only: numeral_2_eq_2)
   147   thus "x \<le> y" using ygt0
   148     by (rule power_le_imp_le_base)
   149 qed
   150 
   151 
   152 subsection {*Various Other Theorems*}
   153 
   154 lemma real_le_add_half_cancel: "(x + y/2 \<le> (y::real)) = (x \<le> y /2)"
   155 by auto
   156 
   157 lemma real_minus_half_eq [simp]: "(x::real) - x/2 = x/2"
   158 by auto
   159 
   160 lemma real_mult_inverse_cancel:
   161      "[|(0::real) < x; 0 < x1; x1 * y < x * u |] 
   162       ==> inverse x * y < inverse x1 * u"
   163 apply (rule_tac c=x in mult_less_imp_less_left) 
   164 apply (auto simp add: real_mult_assoc [symmetric])
   165 apply (simp (no_asm) add: mult_ac)
   166 apply (rule_tac c=x1 in mult_less_imp_less_right) 
   167 apply (auto simp add: mult_ac)
   168 done
   169 
   170 lemma real_mult_inverse_cancel2:
   171      "[|(0::real) < x;0 < x1; x1 * y < x * u |] ==> y * inverse x < u * inverse x1"
   172 apply (auto dest: real_mult_inverse_cancel simp add: mult_ac)
   173 done
   174 
   175 lemma inverse_real_of_nat_gt_zero [simp]: "0 < inverse (real (Suc n))"
   176 by simp
   177 
   178 lemma inverse_real_of_nat_ge_zero [simp]: "0 \<le> inverse (real (Suc n))"
   179 by simp
   180 
   181 lemma realpow_num_eq_if: "(m::real) ^ n = (if n=0 then 1 else m * m ^ (n - 1))"
   182 by (case_tac "n", auto)
   183 
   184 subsection{* Float syntax *}
   185 
   186 syntax "_Float" :: "float_const \<Rightarrow> 'a"    ("_")
   187 
   188 use "Tools/float_syntax.ML"
   189 setup FloatSyntax.setup
   190 
   191 text{* Test: *}
   192 lemma "123.456 = -111.111 + 200 + 30 + 4 + 5/10 + 6/100 + (7/1000::real)"
   193 by simp
   194 
   195 end