src/HOL/NSA/HyperDef.thy
author haftmann
Mon Apr 27 10:11:44 2009 +0200 (2009-04-27)
changeset 31001 7e6ffd8f51a9
parent 30968 10fef94f40fc
child 31017 2c227493ea56
permissions -rw-r--r--
cleaned up theory power further
     1 (*  Title       : HOL/NSA/HyperDef.thy
     2     Author      : Jacques D. Fleuriot
     3     Copyright   : 1998  University of Cambridge
     4     Conversion to Isar and new proofs by Lawrence C Paulson, 2004
     5 *)
     6 
     7 header{*Construction of Hyperreals Using Ultrafilters*}
     8 
     9 theory HyperDef
    10 imports HyperNat Real
    11 uses ("hypreal_arith.ML")
    12 begin
    13 
    14 types hypreal = "real star"
    15 
    16 abbreviation
    17   hypreal_of_real :: "real => real star" where
    18   "hypreal_of_real == star_of"
    19 
    20 abbreviation
    21   hypreal_of_hypnat :: "hypnat \<Rightarrow> hypreal" where
    22   "hypreal_of_hypnat \<equiv> of_hypnat"
    23 
    24 definition
    25   omega :: hypreal where
    26    -- {*an infinite number @{text "= [<1,2,3,...>]"} *}
    27   "omega = star_n (\<lambda>n. real (Suc n))"
    28 
    29 definition
    30   epsilon :: hypreal where
    31    -- {*an infinitesimal number @{text "= [<1,1/2,1/3,...>]"} *}
    32   "epsilon = star_n (\<lambda>n. inverse (real (Suc n)))"
    33 
    34 notation (xsymbols)
    35   omega  ("\<omega>") and
    36   epsilon  ("\<epsilon>")
    37 
    38 notation (HTML output)
    39   omega  ("\<omega>") and
    40   epsilon  ("\<epsilon>")
    41 
    42 
    43 subsection {* Real vector class instances *}
    44 
    45 instantiation star :: (scaleR) scaleR
    46 begin
    47 
    48 definition
    49   star_scaleR_def [transfer_unfold, code del]: "scaleR r \<equiv> *f* (scaleR r)"
    50 
    51 instance ..
    52 
    53 end
    54 
    55 lemma Standard_scaleR [simp]: "x \<in> Standard \<Longrightarrow> scaleR r x \<in> Standard"
    56 by (simp add: star_scaleR_def)
    57 
    58 lemma star_of_scaleR [simp]: "star_of (scaleR r x) = scaleR r (star_of x)"
    59 by transfer (rule refl)
    60 
    61 instance star :: (real_vector) real_vector
    62 proof
    63   fix a b :: real
    64   show "\<And>x y::'a star. scaleR a (x + y) = scaleR a x + scaleR a y"
    65     by transfer (rule scaleR_right_distrib)
    66   show "\<And>x::'a star. scaleR (a + b) x = scaleR a x + scaleR b x"
    67     by transfer (rule scaleR_left_distrib)
    68   show "\<And>x::'a star. scaleR a (scaleR b x) = scaleR (a * b) x"
    69     by transfer (rule scaleR_scaleR)
    70   show "\<And>x::'a star. scaleR 1 x = x"
    71     by transfer (rule scaleR_one)
    72 qed
    73 
    74 instance star :: (real_algebra) real_algebra
    75 proof
    76   fix a :: real
    77   show "\<And>x y::'a star. scaleR a x * y = scaleR a (x * y)"
    78     by transfer (rule mult_scaleR_left)
    79   show "\<And>x y::'a star. x * scaleR a y = scaleR a (x * y)"
    80     by transfer (rule mult_scaleR_right)
    81 qed
    82 
    83 instance star :: (real_algebra_1) real_algebra_1 ..
    84 
    85 instance star :: (real_div_algebra) real_div_algebra ..
    86 
    87 instance star :: (field_char_0) field_char_0 ..
    88 
    89 instance star :: (real_field) real_field ..
    90 
    91 lemma star_of_real_def [transfer_unfold]: "of_real r = star_of (of_real r)"
    92 by (unfold of_real_def, transfer, rule refl)
    93 
    94 lemma Standard_of_real [simp]: "of_real r \<in> Standard"
    95 by (simp add: star_of_real_def)
    96 
    97 lemma star_of_of_real [simp]: "star_of (of_real r) = of_real r"
    98 by transfer (rule refl)
    99 
   100 lemma of_real_eq_star_of [simp]: "of_real = star_of"
   101 proof
   102   fix r :: real
   103   show "of_real r = star_of r"
   104     by transfer simp
   105 qed
   106 
   107 lemma Reals_eq_Standard: "(Reals :: hypreal set) = Standard"
   108 by (simp add: Reals_def Standard_def)
   109 
   110 
   111 subsection {* Injection from @{typ hypreal} *}
   112 
   113 definition
   114   of_hypreal :: "hypreal \<Rightarrow> 'a::real_algebra_1 star" where
   115   [transfer_unfold, code del]: "of_hypreal = *f* of_real"
   116 
   117 lemma Standard_of_hypreal [simp]:
   118   "r \<in> Standard \<Longrightarrow> of_hypreal r \<in> Standard"
   119 by (simp add: of_hypreal_def)
   120 
   121 lemma of_hypreal_0 [simp]: "of_hypreal 0 = 0"
   122 by transfer (rule of_real_0)
   123 
   124 lemma of_hypreal_1 [simp]: "of_hypreal 1 = 1"
   125 by transfer (rule of_real_1)
   126 
   127 lemma of_hypreal_add [simp]:
   128   "\<And>x y. of_hypreal (x + y) = of_hypreal x + of_hypreal y"
   129 by transfer (rule of_real_add)
   130 
   131 lemma of_hypreal_minus [simp]: "\<And>x. of_hypreal (- x) = - of_hypreal x"
   132 by transfer (rule of_real_minus)
   133 
   134 lemma of_hypreal_diff [simp]:
   135   "\<And>x y. of_hypreal (x - y) = of_hypreal x - of_hypreal y"
   136 by transfer (rule of_real_diff)
   137 
   138 lemma of_hypreal_mult [simp]:
   139   "\<And>x y. of_hypreal (x * y) = of_hypreal x * of_hypreal y"
   140 by transfer (rule of_real_mult)
   141 
   142 lemma of_hypreal_inverse [simp]:
   143   "\<And>x. of_hypreal (inverse x) =
   144    inverse (of_hypreal x :: 'a::{real_div_algebra,division_by_zero} star)"
   145 by transfer (rule of_real_inverse)
   146 
   147 lemma of_hypreal_divide [simp]:
   148   "\<And>x y. of_hypreal (x / y) =
   149    (of_hypreal x / of_hypreal y :: 'a::{real_field,division_by_zero} star)"
   150 by transfer (rule of_real_divide)
   151 
   152 lemma of_hypreal_eq_iff [simp]:
   153   "\<And>x y. (of_hypreal x = of_hypreal y) = (x = y)"
   154 by transfer (rule of_real_eq_iff)
   155 
   156 lemma of_hypreal_eq_0_iff [simp]:
   157   "\<And>x. (of_hypreal x = 0) = (x = 0)"
   158 by transfer (rule of_real_eq_0_iff)
   159 
   160 
   161 subsection{*Properties of @{term starrel}*}
   162 
   163 lemma lemma_starrel_refl [simp]: "x \<in> starrel `` {x}"
   164 by (simp add: starrel_def)
   165 
   166 lemma starrel_in_hypreal [simp]: "starrel``{x}:star"
   167 by (simp add: star_def starrel_def quotient_def, blast)
   168 
   169 declare Abs_star_inject [simp] Abs_star_inverse [simp]
   170 declare equiv_starrel [THEN eq_equiv_class_iff, simp]
   171 
   172 subsection{*@{term hypreal_of_real}: 
   173             the Injection from @{typ real} to @{typ hypreal}*}
   174 
   175 lemma inj_star_of: "inj star_of"
   176 by (rule inj_onI, simp)
   177 
   178 lemma mem_Rep_star_iff: "(X \<in> Rep_star x) = (x = star_n X)"
   179 by (cases x, simp add: star_n_def)
   180 
   181 lemma Rep_star_star_n_iff [simp]:
   182   "(X \<in> Rep_star (star_n Y)) = ({n. Y n = X n} \<in> \<U>)"
   183 by (simp add: star_n_def)
   184 
   185 lemma Rep_star_star_n: "X \<in> Rep_star (star_n X)"
   186 by simp
   187 
   188 subsection{* Properties of @{term star_n} *}
   189 
   190 lemma star_n_add:
   191   "star_n X + star_n Y = star_n (%n. X n + Y n)"
   192 by (simp only: star_add_def starfun2_star_n)
   193 
   194 lemma star_n_minus:
   195    "- star_n X = star_n (%n. -(X n))"
   196 by (simp only: star_minus_def starfun_star_n)
   197 
   198 lemma star_n_diff:
   199      "star_n X - star_n Y = star_n (%n. X n - Y n)"
   200 by (simp only: star_diff_def starfun2_star_n)
   201 
   202 lemma star_n_mult:
   203   "star_n X * star_n Y = star_n (%n. X n * Y n)"
   204 by (simp only: star_mult_def starfun2_star_n)
   205 
   206 lemma star_n_inverse:
   207       "inverse (star_n X) = star_n (%n. inverse(X n))"
   208 by (simp only: star_inverse_def starfun_star_n)
   209 
   210 lemma star_n_le:
   211       "star_n X \<le> star_n Y =  
   212        ({n. X n \<le> Y n} \<in> FreeUltrafilterNat)"
   213 by (simp only: star_le_def starP2_star_n)
   214 
   215 lemma star_n_less:
   216       "star_n X < star_n Y = ({n. X n < Y n} \<in> FreeUltrafilterNat)"
   217 by (simp only: star_less_def starP2_star_n)
   218 
   219 lemma star_n_zero_num: "0 = star_n (%n. 0)"
   220 by (simp only: star_zero_def star_of_def)
   221 
   222 lemma star_n_one_num: "1 = star_n (%n. 1)"
   223 by (simp only: star_one_def star_of_def)
   224 
   225 lemma star_n_abs:
   226      "abs (star_n X) = star_n (%n. abs (X n))"
   227 by (simp only: star_abs_def starfun_star_n)
   228 
   229 subsection{*Misc Others*}
   230 
   231 lemma hypreal_not_refl2: "!!(x::hypreal). x < y ==> x \<noteq> y"
   232 by (auto)
   233 
   234 lemma hypreal_eq_minus_iff: "((x::hypreal) = y) = (x + - y = 0)"
   235 by auto
   236 
   237 lemma hypreal_mult_left_cancel: "(c::hypreal) \<noteq> 0 ==> (c*a=c*b) = (a=b)"
   238 by auto
   239     
   240 lemma hypreal_mult_right_cancel: "(c::hypreal) \<noteq> 0 ==> (a*c=b*c) = (a=b)"
   241 by auto
   242 
   243 lemma hypreal_omega_gt_zero [simp]: "0 < omega"
   244 by (simp add: omega_def star_n_zero_num star_n_less)
   245 
   246 subsection{*Existence of Infinite Hyperreal Number*}
   247 
   248 text{*Existence of infinite number not corresponding to any real number.
   249 Use assumption that member @{term FreeUltrafilterNat} is not finite.*}
   250 
   251 
   252 text{*A few lemmas first*}
   253 
   254 lemma lemma_omega_empty_singleton_disj: "{n::nat. x = real n} = {} |  
   255       (\<exists>y. {n::nat. x = real n} = {y})"
   256 by force
   257 
   258 lemma lemma_finite_omega_set: "finite {n::nat. x = real n}"
   259 by (cut_tac x = x in lemma_omega_empty_singleton_disj, auto)
   260 
   261 lemma not_ex_hypreal_of_real_eq_omega: 
   262       "~ (\<exists>x. hypreal_of_real x = omega)"
   263 apply (simp add: omega_def)
   264 apply (simp add: star_of_def star_n_eq_iff)
   265 apply (auto simp add: real_of_nat_Suc diff_eq_eq [symmetric] 
   266             lemma_finite_omega_set [THEN FreeUltrafilterNat.finite])
   267 done
   268 
   269 lemma hypreal_of_real_not_eq_omega: "hypreal_of_real x \<noteq> omega"
   270 by (insert not_ex_hypreal_of_real_eq_omega, auto)
   271 
   272 text{*Existence of infinitesimal number also not corresponding to any
   273  real number*}
   274 
   275 lemma lemma_epsilon_empty_singleton_disj:
   276      "{n::nat. x = inverse(real(Suc n))} = {} |  
   277       (\<exists>y. {n::nat. x = inverse(real(Suc n))} = {y})"
   278 by auto
   279 
   280 lemma lemma_finite_epsilon_set: "finite {n. x = inverse(real(Suc n))}"
   281 by (cut_tac x = x in lemma_epsilon_empty_singleton_disj, auto)
   282 
   283 lemma not_ex_hypreal_of_real_eq_epsilon: "~ (\<exists>x. hypreal_of_real x = epsilon)"
   284 by (auto simp add: epsilon_def star_of_def star_n_eq_iff
   285                    lemma_finite_epsilon_set [THEN FreeUltrafilterNat.finite])
   286 
   287 lemma hypreal_of_real_not_eq_epsilon: "hypreal_of_real x \<noteq> epsilon"
   288 by (insert not_ex_hypreal_of_real_eq_epsilon, auto)
   289 
   290 lemma hypreal_epsilon_not_zero: "epsilon \<noteq> 0"
   291 by (simp add: epsilon_def star_zero_def star_of_def star_n_eq_iff
   292          del: star_of_zero)
   293 
   294 lemma hypreal_epsilon_inverse_omega: "epsilon = inverse(omega)"
   295 by (simp add: epsilon_def omega_def star_n_inverse)
   296 
   297 lemma hypreal_epsilon_gt_zero: "0 < epsilon"
   298 by (simp add: hypreal_epsilon_inverse_omega)
   299 
   300 subsection{*Absolute Value Function for the Hyperreals*}
   301 
   302 lemma hrabs_add_less:
   303      "[| abs x < r; abs y < s |] ==> abs(x+y) < r + (s::hypreal)"
   304 by (simp add: abs_if split: split_if_asm)
   305 
   306 lemma hrabs_less_gt_zero: "abs x < r ==> (0::hypreal) < r"
   307 by (blast intro!: order_le_less_trans abs_ge_zero)
   308 
   309 lemma hrabs_disj: "abs x = (x::'a::abs_if) | abs x = -x"
   310 by (simp add: abs_if)
   311 
   312 lemma hrabs_add_lemma_disj: "(y::hypreal) + - x + (y + - z) = abs (x + - z) ==> y = z | x = y"
   313 by (simp add: abs_if split add: split_if_asm)
   314 
   315 
   316 subsection{*Embedding the Naturals into the Hyperreals*}
   317 
   318 abbreviation
   319   hypreal_of_nat :: "nat => hypreal" where
   320   "hypreal_of_nat == of_nat"
   321 
   322 lemma SNat_eq: "Nats = {n. \<exists>N. n = hypreal_of_nat N}"
   323 by (simp add: Nats_def image_def)
   324 
   325 (*------------------------------------------------------------*)
   326 (* naturals embedded in hyperreals                            *)
   327 (* is a hyperreal c.f. NS extension                           *)
   328 (*------------------------------------------------------------*)
   329 
   330 lemma hypreal_of_nat_eq:
   331      "hypreal_of_nat (n::nat) = hypreal_of_real (real n)"
   332 by (simp add: real_of_nat_def)
   333 
   334 lemma hypreal_of_nat:
   335      "hypreal_of_nat m = star_n (%n. real m)"
   336 apply (fold star_of_def)
   337 apply (simp add: real_of_nat_def)
   338 done
   339 
   340 (*
   341 FIXME: we should declare this, as for type int, but many proofs would break.
   342 It replaces x+-y by x-y.
   343 Addsimps [symmetric hypreal_diff_def]
   344 *)
   345 
   346 use "hypreal_arith.ML"
   347 declaration {* K hypreal_arith_setup *}
   348 
   349 
   350 subsection {* Exponentials on the Hyperreals *}
   351 
   352 lemma hpowr_0 [simp]:   "r ^ 0       = (1::hypreal)"
   353 by (rule power_0)
   354 
   355 lemma hpowr_Suc [simp]: "r ^ (Suc n) = (r::hypreal) * (r ^ n)"
   356 by (rule power_Suc)
   357 
   358 lemma hrealpow_two: "(r::hypreal) ^ Suc (Suc 0) = r * r"
   359 by simp
   360 
   361 lemma hrealpow_two_le [simp]: "(0::hypreal) \<le> r ^ Suc (Suc 0)"
   362 by (auto simp add: zero_le_mult_iff)
   363 
   364 lemma hrealpow_two_le_add_order [simp]:
   365      "(0::hypreal) \<le> u ^ Suc (Suc 0) + v ^ Suc (Suc 0)"
   366 by (simp only: hrealpow_two_le add_nonneg_nonneg)
   367 
   368 lemma hrealpow_two_le_add_order2 [simp]:
   369      "(0::hypreal) \<le> u ^ Suc (Suc 0) + v ^ Suc (Suc 0) + w ^ Suc (Suc 0)"
   370 by (simp only: hrealpow_two_le add_nonneg_nonneg)
   371 
   372 lemma hypreal_add_nonneg_eq_0_iff:
   373      "[| 0 \<le> x; 0 \<le> y |] ==> (x+y = 0) = (x = 0 & y = (0::hypreal))"
   374 by arith
   375 
   376 
   377 text{*FIXME: DELETE THESE*}
   378 lemma hypreal_three_squares_add_zero_iff:
   379      "(x*x + y*y + z*z = 0) = (x = 0 & y = 0 & z = (0::hypreal))"
   380 apply (simp only: zero_le_square add_nonneg_nonneg hypreal_add_nonneg_eq_0_iff, auto)
   381 done
   382 
   383 lemma hrealpow_three_squares_add_zero_iff [simp]:
   384      "(x ^ Suc (Suc 0) + y ^ Suc (Suc 0) + z ^ Suc (Suc 0) = (0::hypreal)) = 
   385       (x = 0 & y = 0 & z = 0)"
   386 by (simp only: hypreal_three_squares_add_zero_iff hrealpow_two)
   387 
   388 (*FIXME: This and RealPow.abs_realpow_two should be replaced by an abstract
   389   result proved in Ring_and_Field*)
   390 lemma hrabs_hrealpow_two [simp]:
   391      "abs(x ^ Suc (Suc 0)) = (x::hypreal) ^ Suc (Suc 0)"
   392 by (simp add: abs_mult)
   393 
   394 lemma two_hrealpow_ge_one [simp]: "(1::hypreal) \<le> 2 ^ n"
   395 by (insert power_increasing [of 0 n "2::hypreal"], simp)
   396 
   397 lemma two_hrealpow_gt [simp]: "hypreal_of_nat n < 2 ^ n"
   398 apply (induct n)
   399 apply (auto simp add: left_distrib)
   400 apply (cut_tac n = n in two_hrealpow_ge_one, arith)
   401 done
   402 
   403 lemma hrealpow:
   404     "star_n X ^ m = star_n (%n. (X n::real) ^ m)"
   405 apply (induct_tac "m")
   406 apply (auto simp add: star_n_one_num star_n_mult power_0)
   407 done
   408 
   409 lemma hrealpow_sum_square_expand:
   410      "(x + (y::hypreal)) ^ Suc (Suc 0) =
   411       x ^ Suc (Suc 0) + y ^ Suc (Suc 0) + (hypreal_of_nat (Suc (Suc 0)))*x*y"
   412 by (simp add: right_distrib left_distrib)
   413 
   414 lemma power_hypreal_of_real_number_of:
   415      "(number_of v :: hypreal) ^ n = hypreal_of_real ((number_of v) ^ n)"
   416 by simp
   417 declare power_hypreal_of_real_number_of [of _ "number_of w", standard, simp]
   418 (*
   419 lemma hrealpow_HFinite:
   420   fixes x :: "'a::{real_normed_algebra,recpower} star"
   421   shows "x \<in> HFinite ==> x ^ n \<in> HFinite"
   422 apply (induct_tac "n")
   423 apply (auto simp add: power_Suc intro: HFinite_mult)
   424 done
   425 *)
   426 
   427 subsection{*Powers with Hypernatural Exponents*}
   428 
   429 definition pow :: "['a::power star, nat star] \<Rightarrow> 'a star" (infixr "pow" 80) where
   430   hyperpow_def [transfer_unfold, code del]: "R pow N = ( *f2* op ^) R N"
   431   (* hypernatural powers of hyperreals *)
   432 
   433 lemma Standard_hyperpow [simp]:
   434   "\<lbrakk>r \<in> Standard; n \<in> Standard\<rbrakk> \<Longrightarrow> r pow n \<in> Standard"
   435 unfolding hyperpow_def by simp
   436 
   437 lemma hyperpow: "star_n X pow star_n Y = star_n (%n. X n ^ Y n)"
   438 by (simp add: hyperpow_def starfun2_star_n)
   439 
   440 lemma hyperpow_zero [simp]:
   441   "\<And>n. (0::'a::{recpower,semiring_0} star) pow (n + (1::hypnat)) = 0"
   442 by transfer simp
   443 
   444 lemma hyperpow_not_zero:
   445   "\<And>r n. r \<noteq> (0::'a::{recpower,field} star) ==> r pow n \<noteq> 0"
   446 by transfer (rule field_power_not_zero)
   447 
   448 lemma hyperpow_inverse:
   449   "\<And>r n. r \<noteq> (0::'a::{recpower,division_by_zero,field} star)
   450    \<Longrightarrow> inverse (r pow n) = (inverse r) pow n"
   451 by transfer (rule power_inverse)
   452 
   453 lemma hyperpow_hrabs:
   454   "\<And>r n. abs (r::'a::{recpower,ordered_idom} star) pow n = abs (r pow n)"
   455 by transfer (rule power_abs [symmetric])
   456 
   457 lemma hyperpow_add:
   458   "\<And>r n m. (r::'a::recpower star) pow (n + m) = (r pow n) * (r pow m)"
   459 by transfer (rule power_add)
   460 
   461 lemma hyperpow_one [simp]:
   462   "\<And>r. (r::'a::monoid_mult star) pow (1::hypnat) = r"
   463 by transfer (rule power_one_right)
   464 
   465 lemma hyperpow_two:
   466   "\<And>r. (r::'a::recpower star) pow ((1::hypnat) + (1::hypnat)) = r * r"
   467 by transfer (simp add: power_Suc)
   468 
   469 lemma hyperpow_gt_zero:
   470   "\<And>r n. (0::'a::{recpower,ordered_semidom} star) < r \<Longrightarrow> 0 < r pow n"
   471 by transfer (rule zero_less_power)
   472 
   473 lemma hyperpow_ge_zero:
   474   "\<And>r n. (0::'a::{recpower,ordered_semidom} star) \<le> r \<Longrightarrow> 0 \<le> r pow n"
   475 by transfer (rule zero_le_power)
   476 
   477 lemma hyperpow_le:
   478   "\<And>x y n. \<lbrakk>(0::'a::{recpower,ordered_semidom} star) < x; x \<le> y\<rbrakk>
   479    \<Longrightarrow> x pow n \<le> y pow n"
   480 by transfer (rule power_mono [OF _ order_less_imp_le])
   481 
   482 lemma hyperpow_eq_one [simp]:
   483   "\<And>n. 1 pow n = (1::'a::recpower star)"
   484 by transfer (rule power_one)
   485 
   486 lemma hrabs_hyperpow_minus_one [simp]:
   487   "\<And>n. abs(-1 pow n) = (1::'a::{number_ring,recpower,ordered_idom} star)"
   488 by transfer (rule abs_power_minus_one)
   489 
   490 lemma hyperpow_mult:
   491   "\<And>r s n. (r * s::'a::{comm_monoid_mult,recpower} star) pow n
   492    = (r pow n) * (s pow n)"
   493 by transfer (rule power_mult_distrib)
   494 
   495 lemma hyperpow_two_le [simp]:
   496   "(0::'a::{recpower,ordered_ring_strict} star) \<le> r pow (1 + 1)"
   497 by (auto simp add: hyperpow_two zero_le_mult_iff)
   498 
   499 lemma hrabs_hyperpow_two [simp]:
   500   "abs(x pow (1 + 1)) =
   501    (x::'a::{recpower,ordered_ring_strict} star) pow (1 + 1)"
   502 by (simp only: abs_of_nonneg hyperpow_two_le)
   503 
   504 lemma hyperpow_two_hrabs [simp]:
   505   "abs(x::'a::{recpower,ordered_idom} star) pow (1 + 1)  = x pow (1 + 1)"
   506 by (simp add: hyperpow_hrabs)
   507 
   508 text{*The precondition could be weakened to @{term "0\<le>x"}*}
   509 lemma hypreal_mult_less_mono:
   510      "[| u<v;  x<y;  (0::hypreal) < v;  0 < x |] ==> u*x < v* y"
   511  by (simp add: Ring_and_Field.mult_strict_mono order_less_imp_le)
   512 
   513 lemma hyperpow_two_gt_one:
   514   "\<And>r::'a::{recpower,ordered_semidom} star. 1 < r \<Longrightarrow> 1 < r pow (1 + 1)"
   515 by transfer (simp add: power_gt1 del: power_Suc)
   516 
   517 lemma hyperpow_two_ge_one:
   518   "\<And>r::'a::{recpower,ordered_semidom} star. 1 \<le> r \<Longrightarrow> 1 \<le> r pow (1 + 1)"
   519 by transfer (simp add: one_le_power del: power_Suc)
   520 
   521 lemma two_hyperpow_ge_one [simp]: "(1::hypreal) \<le> 2 pow n"
   522 apply (rule_tac y = "1 pow n" in order_trans)
   523 apply (rule_tac [2] hyperpow_le, auto)
   524 done
   525 
   526 lemma hyperpow_minus_one2 [simp]:
   527      "!!n. -1 pow ((1 + 1)*n) = (1::hypreal)"
   528 by transfer (subst power_mult, simp)
   529 
   530 lemma hyperpow_less_le:
   531      "!!r n N. [|(0::hypreal) \<le> r; r \<le> 1; n < N|] ==> r pow N \<le> r pow n"
   532 by transfer (rule power_decreasing [OF order_less_imp_le])
   533 
   534 lemma hyperpow_SHNat_le:
   535      "[| 0 \<le> r;  r \<le> (1::hypreal);  N \<in> HNatInfinite |]
   536       ==> ALL n: Nats. r pow N \<le> r pow n"
   537 by (auto intro!: hyperpow_less_le simp add: HNatInfinite_iff)
   538 
   539 lemma hyperpow_realpow:
   540       "(hypreal_of_real r) pow (hypnat_of_nat n) = hypreal_of_real (r ^ n)"
   541 by transfer (rule refl)
   542 
   543 lemma hyperpow_SReal [simp]:
   544      "(hypreal_of_real r) pow (hypnat_of_nat n) \<in> Reals"
   545 by (simp add: Reals_eq_Standard)
   546 
   547 lemma hyperpow_zero_HNatInfinite [simp]:
   548      "N \<in> HNatInfinite ==> (0::hypreal) pow N = 0"
   549 by (drule HNatInfinite_is_Suc, auto)
   550 
   551 lemma hyperpow_le_le:
   552      "[| (0::hypreal) \<le> r; r \<le> 1; n \<le> N |] ==> r pow N \<le> r pow n"
   553 apply (drule order_le_less [of n, THEN iffD1])
   554 apply (auto intro: hyperpow_less_le)
   555 done
   556 
   557 lemma hyperpow_Suc_le_self2:
   558      "[| (0::hypreal) \<le> r; r < 1 |] ==> r pow (n + (1::hypnat)) \<le> r"
   559 apply (drule_tac n = " (1::hypnat) " in hyperpow_le_le)
   560 apply auto
   561 done
   562 
   563 lemma hyperpow_hypnat_of_nat: "\<And>x. x pow hypnat_of_nat n = x ^ n"
   564 by transfer (rule refl)
   565 
   566 lemma of_hypreal_hyperpow:
   567   "\<And>x n. of_hypreal (x pow n) =
   568    (of_hypreal x::'a::{real_algebra_1,recpower} star) pow n"
   569 by transfer (rule of_real_power)
   570 
   571 end