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