misc tuning and modernization;
authorwenzelm
Tue Nov 01 00:44:24 2016 +0100 (2016-11-01)
changeset 64435c93b0e6131c3
parent 64434 af5235830c16
child 64436 254c9411fc48
misc tuning and modernization;
src/HOL/Nonstandard_Analysis/Free_Ultrafilter.thy
src/HOL/Nonstandard_Analysis/HDeriv.thy
src/HOL/Nonstandard_Analysis/HLim.thy
src/HOL/Nonstandard_Analysis/HyperDef.thy
src/HOL/Nonstandard_Analysis/HyperNat.thy
src/HOL/Nonstandard_Analysis/NSA.thy
src/HOL/Nonstandard_Analysis/NSComplex.thy
src/HOL/Nonstandard_Analysis/NatStar.thy
src/HOL/Nonstandard_Analysis/Star.thy
src/HOL/Nonstandard_Analysis/StarDef.thy
src/HOL/Nonstandard_Analysis/document/root.tex
src/HOL/Nonstandard_Analysis/transfer.ML
     1.1 --- a/src/HOL/Nonstandard_Analysis/Free_Ultrafilter.thy	Mon Oct 31 16:26:36 2016 +0100
     1.2 +++ b/src/HOL/Nonstandard_Analysis/Free_Ultrafilter.thy	Tue Nov 01 00:44:24 2016 +0100
     1.3 @@ -2,14 +2,15 @@
     1.4      Author:     Jacques D. Fleuriot, University of Cambridge
     1.5      Author:     Lawrence C Paulson
     1.6      Author:     Brian Huffman
     1.7 -*) 
     1.8 +*)
     1.9  
    1.10  section \<open>Filters and Ultrafilters\<close>
    1.11  
    1.12  theory Free_Ultrafilter
    1.13 -imports "~~/src/HOL/Library/Infinite_Set"
    1.14 +  imports "~~/src/HOL/Library/Infinite_Set"
    1.15  begin
    1.16  
    1.17 +
    1.18  subsection \<open>Definitions and basic properties\<close>
    1.19  
    1.20  subsubsection \<open>Ultrafilters\<close>
    1.21 @@ -43,28 +44,29 @@
    1.22  
    1.23  end
    1.24  
    1.25 +
    1.26  subsection \<open>Maximal filter = Ultrafilter\<close>
    1.27  
    1.28  text \<open>
    1.29 -   A filter F is an ultrafilter iff it is a maximal filter,
    1.30 -   i.e. whenever G is a filter and @{term "F \<subseteq> G"} then @{term "F = G"}
    1.31 +   A filter \<open>F\<close> is an ultrafilter iff it is a maximal filter,
    1.32 +   i.e. whenever \<open>G\<close> is a filter and @{prop "F \<subseteq> G"} then @{prop "F = G"}
    1.33  \<close>
    1.34 +
    1.35  text \<open>
    1.36 -  Lemmas that shows existence of an extension to what was assumed to
    1.37 +  Lemma that shows existence of an extension to what was assumed to
    1.38    be a maximal filter. Will be used to derive contradiction in proof of
    1.39    property of ultrafilter.
    1.40  \<close>
    1.41  
    1.42 -lemma extend_filter:
    1.43 -  "frequently P F \<Longrightarrow> inf F (principal {x. P x}) \<noteq> bot"
    1.44 -  unfolding trivial_limit_def eventually_inf_principal by (simp add: not_eventually)
    1.45 +lemma extend_filter: "frequently P F \<Longrightarrow> inf F (principal {x. P x}) \<noteq> bot"
    1.46 +  by (simp add: trivial_limit_def eventually_inf_principal not_eventually)
    1.47  
    1.48  lemma max_filter_ultrafilter:
    1.49 -  assumes proper: "F \<noteq> bot"
    1.50 +  assumes "F \<noteq> bot"
    1.51    assumes max: "\<And>G. G \<noteq> bot \<Longrightarrow> G \<le> F \<Longrightarrow> F = G"
    1.52    shows "ultrafilter F"
    1.53  proof
    1.54 -  fix P show "eventually P F \<or> (\<forall>\<^sub>Fx in F. \<not> P x)"
    1.55 +  show "eventually P F \<or> (\<forall>\<^sub>Fx in F. \<not> P x)" for P
    1.56    proof (rule disjCI)
    1.57      assume "\<not> (\<forall>\<^sub>Fx in F. \<not> P x)"
    1.58      then have "inf F (principal {x. P x}) \<noteq> bot"
    1.59 @@ -84,7 +86,9 @@
    1.60    done
    1.61  
    1.62  lemma (in ultrafilter) max_filter:
    1.63 -  assumes G: "G \<noteq> bot" and sub: "G \<le> F" shows "F = G"
    1.64 +  assumes G: "G \<noteq> bot"
    1.65 +    and sub: "G \<le> F"
    1.66 +  shows "F = G"
    1.67  proof (rule antisym)
    1.68    show "F \<le> G"
    1.69      using sub
    1.70 @@ -92,10 +96,9 @@
    1.71               intro!: eventually_frequently G proper)
    1.72  qed fact
    1.73  
    1.74 +
    1.75  subsection \<open>Ultrafilter Theorem\<close>
    1.76  
    1.77 -text "A local context makes proof of ultrafilter Theorem more modular"
    1.78 -
    1.79  lemma ex_max_ultrafilter:
    1.80    fixes F :: "'a filter"
    1.81    assumes F: "F \<noteq> bot"
    1.82 @@ -104,73 +107,77 @@
    1.83    let ?X = "{G. G \<noteq> bot \<and> G \<le> F}"
    1.84    let ?R = "{(b, a). a \<noteq> bot \<and> a \<le> b \<and> b \<le> F}"
    1.85  
    1.86 -  have bot_notin_R: "\<And>c. c \<in> Chains ?R \<Longrightarrow> bot \<notin> c"
    1.87 +  have bot_notin_R: "c \<in> Chains ?R \<Longrightarrow> bot \<notin> c" for c
    1.88      by (auto simp: Chains_def)
    1.89  
    1.90    have [simp]: "Field ?R = ?X"
    1.91      by (auto simp: Field_def bot_unique)
    1.92  
    1.93 -  have "\<exists>m\<in>Field ?R. \<forall>a\<in>Field ?R. (m, a) \<in> ?R \<longrightarrow> a = m"
    1.94 +  have "\<exists>m\<in>Field ?R. \<forall>a\<in>Field ?R. (m, a) \<in> ?R \<longrightarrow> a = m" (is "\<exists>m\<in>?A. ?B m")
    1.95    proof (rule Zorns_po_lemma)
    1.96      show "Partial_order ?R"
    1.97 -      unfolding partial_order_on_def preorder_on_def
    1.98 -      by (auto simp: antisym_def refl_on_def trans_def Field_def bot_unique)
    1.99 +      by (auto simp: partial_order_on_def preorder_on_def
   1.100 +          antisym_def refl_on_def trans_def Field_def bot_unique)
   1.101      show "\<forall>C\<in>Chains ?R. \<exists>u\<in>Field ?R. \<forall>a\<in>C. (a, u) \<in> ?R"
   1.102      proof (safe intro!: bexI del: notI)
   1.103 -      fix c x assume c: "c \<in> Chains ?R"
   1.104 +      fix c x
   1.105 +      assume c: "c \<in> Chains ?R"
   1.106  
   1.107 -      { assume "c \<noteq> {}"
   1.108 -        with c have "Inf c = bot \<longleftrightarrow> (\<exists>x\<in>c. x = bot)"
   1.109 +      have Inf_c: "Inf c \<noteq> bot" "Inf c \<le> F" if "c \<noteq> {}"
   1.110 +      proof -
   1.111 +        from c that have "Inf c = bot \<longleftrightarrow> (\<exists>x\<in>c. x = bot)"
   1.112            unfolding trivial_limit_def by (intro eventually_Inf_base) (auto simp: Chains_def)
   1.113 -        with c have 1: "Inf c \<noteq> bot"
   1.114 +        with c show "Inf c \<noteq> bot"
   1.115            by (simp add: bot_notin_R)
   1.116 -        from \<open>c \<noteq> {}\<close> obtain x where "x \<in> c" by auto
   1.117 -        with c have 2: "Inf c \<le> F"
   1.118 +        from that obtain x where "x \<in> c" by auto
   1.119 +        with c show "Inf c \<le> F"
   1.120            by (auto intro!: Inf_lower2[of x] simp: Chains_def)
   1.121 -        note 1 2 }
   1.122 -      note Inf_c = this
   1.123 +      qed
   1.124        then have [simp]: "inf F (Inf c) = (if c = {} then F else Inf c)"
   1.125          using c by (auto simp add: inf_absorb2)
   1.126  
   1.127 -      show "inf F (Inf c) \<noteq> bot"
   1.128 -        using c by (simp add: F Inf_c)
   1.129 +      from c show "inf F (Inf c) \<noteq> bot"
   1.130 +        by (simp add: F Inf_c)
   1.131 +      from c show "inf F (Inf c) \<in> Field ?R"
   1.132 +        by (simp add: Chains_def Inf_c F)
   1.133  
   1.134 -      show "inf F (Inf c) \<in> Field ?R"
   1.135 -        using c by (simp add: Chains_def Inf_c F)
   1.136 -
   1.137 -      assume x: "x \<in> c"
   1.138 +      assume "x \<in> c"
   1.139        with c show "inf F (Inf c) \<le> x" "x \<le> F"
   1.140          by (auto intro: Inf_lower simp: Chains_def)
   1.141      qed
   1.142    qed
   1.143 -  then guess U ..
   1.144 -  then show ?thesis
   1.145 -    by (intro exI[of _ U] conjI max_filter_ultrafilter) auto
   1.146 +  then obtain U where U: "U \<in> ?A" "?B U" ..
   1.147 +  show ?thesis
   1.148 +  proof
   1.149 +    from U show "U \<le> F \<and> ultrafilter U"
   1.150 +      by (auto intro!: max_filter_ultrafilter)
   1.151 +  qed
   1.152  qed
   1.153  
   1.154 +
   1.155  subsubsection \<open>Free Ultrafilters\<close>
   1.156  
   1.157 -text \<open>There exists a free ultrafilter on any infinite set\<close>
   1.158 +text \<open>There exists a free ultrafilter on any infinite set.\<close>
   1.159  
   1.160  locale freeultrafilter = ultrafilter +
   1.161    assumes infinite: "eventually P F \<Longrightarrow> infinite {x. P x}"
   1.162  begin
   1.163  
   1.164  lemma finite: "finite {x. P x} \<Longrightarrow> \<not> eventually P F"
   1.165 -  by (erule contrapos_pn, erule infinite)
   1.166 +  by (erule contrapos_pn) (erule infinite)
   1.167  
   1.168  lemma finite': "finite {x. \<not> P x} \<Longrightarrow> eventually P F"
   1.169    by (drule finite) (simp add: not_eventually frequently_eq_eventually)
   1.170  
   1.171  lemma le_cofinite: "F \<le> cofinite"
   1.172    by (intro filter_leI)
   1.173 -     (auto simp add: eventually_cofinite not_eventually frequently_eq_eventually dest!: finite)
   1.174 +    (auto simp add: eventually_cofinite not_eventually frequently_eq_eventually dest!: finite)
   1.175  
   1.176  lemma singleton: "\<not> eventually (\<lambda>x. x = a) F"
   1.177 -by (rule finite, simp)
   1.178 +  by (rule finite) simp
   1.179  
   1.180  lemma singleton': "\<not> eventually (op = a) F"
   1.181 -by (rule finite, simp)
   1.182 +  by (rule finite) simp
   1.183  
   1.184  lemma ultrafilter: "ultrafilter F" ..
   1.185  
   1.186 @@ -186,7 +193,8 @@
   1.187    interpret ultrafilter U by fact
   1.188    have "freeultrafilter U"
   1.189    proof
   1.190 -    fix P assume "eventually P U"
   1.191 +    fix P
   1.192 +    assume "eventually P U"
   1.193      with proper have "frequently P U"
   1.194        by (rule eventually_frequently)
   1.195      then have "frequently P cofinite"
     2.1 --- a/src/HOL/Nonstandard_Analysis/HDeriv.thy	Mon Oct 31 16:26:36 2016 +0100
     2.2 +++ b/src/HOL/Nonstandard_Analysis/HDeriv.thy	Tue Nov 01 00:44:24 2016 +0100
     2.3 @@ -4,284 +4,252 @@
     2.4      Conversion to Isar and new proofs by Lawrence C Paulson, 2004
     2.5  *)
     2.6  
     2.7 -section\<open>Differentiation (Nonstandard)\<close>
     2.8 +section \<open>Differentiation (Nonstandard)\<close>
     2.9  
    2.10  theory HDeriv
    2.11 -imports HLim
    2.12 +  imports HLim
    2.13  begin
    2.14  
    2.15 -text\<open>Nonstandard Definitions\<close>
    2.16 +text \<open>Nonstandard Definitions.\<close>
    2.17  
    2.18 -definition
    2.19 -  nsderiv :: "['a::real_normed_field \<Rightarrow> 'a, 'a, 'a] \<Rightarrow> bool"
    2.20 -          ("(NSDERIV (_)/ (_)/ :> (_))" [1000, 1000, 60] 60) where
    2.21 -  "NSDERIV f x :> D = (\<forall>h \<in> Infinitesimal - {0}.
    2.22 -      (( *f* f)(star_of x + h)
    2.23 -       - star_of (f x))/h \<approx> star_of D)"
    2.24 +definition nsderiv :: "['a::real_normed_field \<Rightarrow> 'a, 'a, 'a] \<Rightarrow> bool"
    2.25 +    ("(NSDERIV (_)/ (_)/ :> (_))" [1000, 1000, 60] 60)
    2.26 +  where "NSDERIV f x :> D \<longleftrightarrow>
    2.27 +    (\<forall>h \<in> Infinitesimal - {0}. (( *f* f)(star_of x + h) - star_of (f x)) / h \<approx> star_of D)"
    2.28  
    2.29 -definition
    2.30 -  NSdifferentiable :: "['a::real_normed_field \<Rightarrow> 'a, 'a] \<Rightarrow> bool"
    2.31 -    (infixl "NSdifferentiable" 60) where
    2.32 -  "f NSdifferentiable x = (\<exists>D. NSDERIV f x :> D)"
    2.33 +definition NSdifferentiable :: "['a::real_normed_field \<Rightarrow> 'a, 'a] \<Rightarrow> bool"
    2.34 +    (infixl "NSdifferentiable" 60)
    2.35 +  where "f NSdifferentiable x \<longleftrightarrow> (\<exists>D. NSDERIV f x :> D)"
    2.36  
    2.37 -definition
    2.38 -  increment :: "[real=>real,real,hypreal] => hypreal" where
    2.39 -  "increment f x h = (@inc. f NSdifferentiable x &
    2.40 -           inc = ( *f* f)(hypreal_of_real x + h) - hypreal_of_real (f x))"
    2.41 +definition increment :: "(real \<Rightarrow> real) \<Rightarrow> real \<Rightarrow> hypreal \<Rightarrow> hypreal"
    2.42 +  where "increment f x h =
    2.43 +    (SOME inc. f NSdifferentiable x \<and> inc = ( *f* f) (hypreal_of_real x + h) - hypreal_of_real (f x))"
    2.44  
    2.45  
    2.46  subsection \<open>Derivatives\<close>
    2.47  
    2.48 -lemma DERIV_NS_iff:
    2.49 -      "(DERIV f x :> D) = ((%h. (f(x + h) - f(x))/h) \<midarrow>0\<rightarrow>\<^sub>N\<^sub>S D)"
    2.50 -by (simp add: DERIV_def LIM_NSLIM_iff)
    2.51 +lemma DERIV_NS_iff: "(DERIV f x :> D) \<longleftrightarrow> (\<lambda>h. (f (x + h) - f x) / h) \<midarrow>0\<rightarrow>\<^sub>N\<^sub>S D"
    2.52 +  by (simp add: DERIV_def LIM_NSLIM_iff)
    2.53  
    2.54 -lemma NS_DERIV_D: "DERIV f x :> D ==> (%h. (f(x + h) - f(x))/h) \<midarrow>0\<rightarrow>\<^sub>N\<^sub>S D"
    2.55 -by (simp add: DERIV_def LIM_NSLIM_iff)
    2.56 +lemma NS_DERIV_D: "DERIV f x :> D \<Longrightarrow> (\<lambda>h. (f (x + h) - f x) / h) \<midarrow>0\<rightarrow>\<^sub>N\<^sub>S D"
    2.57 +  by (simp add: DERIV_def LIM_NSLIM_iff)
    2.58  
    2.59 -lemma hnorm_of_hypreal:
    2.60 -  "\<And>r. hnorm (( *f* of_real) r::'a::real_normed_div_algebra star) = \<bar>r\<bar>"
    2.61 -by transfer (rule norm_of_real)
    2.62 +lemma hnorm_of_hypreal: "\<And>r. hnorm (( *f* of_real) r::'a::real_normed_div_algebra star) = \<bar>r\<bar>"
    2.63 +  by transfer (rule norm_of_real)
    2.64  
    2.65  lemma Infinitesimal_of_hypreal:
    2.66 -  "x \<in> Infinitesimal \<Longrightarrow>
    2.67 -   (( *f* of_real) x::'a::real_normed_div_algebra star) \<in> Infinitesimal"
    2.68 -apply (rule InfinitesimalI2)
    2.69 -apply (drule (1) InfinitesimalD2)
    2.70 -apply (simp add: hnorm_of_hypreal)
    2.71 -done
    2.72 +  "x \<in> Infinitesimal \<Longrightarrow> (( *f* of_real) x::'a::real_normed_div_algebra star) \<in> Infinitesimal"
    2.73 +  apply (rule InfinitesimalI2)
    2.74 +  apply (drule (1) InfinitesimalD2)
    2.75 +  apply (simp add: hnorm_of_hypreal)
    2.76 +  done
    2.77  
    2.78 -lemma of_hypreal_eq_0_iff:
    2.79 -  "\<And>x. (( *f* of_real) x = (0::'a::real_algebra_1 star)) = (x = 0)"
    2.80 -by transfer (rule of_real_eq_0_iff)
    2.81 +lemma of_hypreal_eq_0_iff: "\<And>x. (( *f* of_real) x = (0::'a::real_algebra_1 star)) = (x = 0)"
    2.82 +  by transfer (rule of_real_eq_0_iff)
    2.83  
    2.84 -lemma NSDeriv_unique:
    2.85 -     "[| NSDERIV f x :> D; NSDERIV f x :> E |] ==> D = E"
    2.86 -apply (subgoal_tac "( *f* of_real) \<epsilon> \<in> Infinitesimal - {0::'a star}")
    2.87 -apply (simp only: nsderiv_def)
    2.88 -apply (drule (1) bspec)+
    2.89 -apply (drule (1) approx_trans3)
    2.90 -apply simp
    2.91 -apply (simp add: Infinitesimal_of_hypreal Infinitesimal_epsilon)
    2.92 -apply (simp add: of_hypreal_eq_0_iff hypreal_epsilon_not_zero)
    2.93 -done
    2.94 +lemma NSDeriv_unique: "NSDERIV f x :> D \<Longrightarrow> NSDERIV f x :> E \<Longrightarrow> D = E"
    2.95 +  apply (subgoal_tac "( *f* of_real) \<epsilon> \<in> Infinitesimal - {0::'a star}")
    2.96 +   apply (simp only: nsderiv_def)
    2.97 +   apply (drule (1) bspec)+
    2.98 +   apply (drule (1) approx_trans3)
    2.99 +   apply simp
   2.100 +  apply (simp add: Infinitesimal_of_hypreal Infinitesimal_epsilon)
   2.101 +  apply (simp add: of_hypreal_eq_0_iff hypreal_epsilon_not_zero)
   2.102 +  done
   2.103  
   2.104 -text \<open>First NSDERIV in terms of NSLIM\<close>
   2.105 +text \<open>First \<open>NSDERIV\<close> in terms of \<open>NSLIM\<close>.\<close>
   2.106  
   2.107 -text\<open>first equivalence\<close>
   2.108 -lemma NSDERIV_NSLIM_iff:
   2.109 -      "(NSDERIV f x :> D) = ((%h. (f(x + h) - f(x))/h) \<midarrow>0\<rightarrow>\<^sub>N\<^sub>S D)"
   2.110 -apply (simp add: nsderiv_def NSLIM_def, auto)
   2.111 -apply (drule_tac x = xa in bspec)
   2.112 -apply (rule_tac [3] ccontr)
   2.113 -apply (drule_tac [3] x = h in spec)
   2.114 -apply (auto simp add: mem_infmal_iff starfun_lambda_cancel)
   2.115 -done
   2.116 +text \<open>First equivalence.\<close>
   2.117 +lemma NSDERIV_NSLIM_iff: "(NSDERIV f x :> D) \<longleftrightarrow> (\<lambda>h. (f (x + h) - f x) / h) \<midarrow>0\<rightarrow>\<^sub>N\<^sub>S D"
   2.118 +  apply (auto simp add: nsderiv_def NSLIM_def)
   2.119 +   apply (drule_tac x = xa in bspec)
   2.120 +    apply (rule_tac [3] ccontr)
   2.121 +    apply (drule_tac [3] x = h in spec)
   2.122 +    apply (auto simp add: mem_infmal_iff starfun_lambda_cancel)
   2.123 +  done
   2.124  
   2.125 -text\<open>second equivalence\<close>
   2.126 -lemma NSDERIV_NSLIM_iff2:
   2.127 -     "(NSDERIV f x :> D) = ((%z. (f(z) - f(x)) / (z-x)) \<midarrow>x\<rightarrow>\<^sub>N\<^sub>S D)"
   2.128 +text \<open>Second equivalence.\<close>
   2.129 +lemma NSDERIV_NSLIM_iff2: "(NSDERIV f x :> D) \<longleftrightarrow> (\<lambda>z. (f z - f x) / (z - x)) \<midarrow>x\<rightarrow>\<^sub>N\<^sub>S D"
   2.130    by (simp add: NSDERIV_NSLIM_iff DERIV_LIM_iff LIM_NSLIM_iff [symmetric])
   2.131  
   2.132 -(* while we're at it! *)
   2.133 -
   2.134 +text \<open>While we're at it!\<close>
   2.135  lemma NSDERIV_iff2:
   2.136 -     "(NSDERIV f x :> D) =
   2.137 -      (\<forall>w.
   2.138 -        w \<noteq> star_of x & w \<approx> star_of x -->
   2.139 -        ( *f* (%z. (f z - f x) / (z-x))) w \<approx> star_of D)"
   2.140 -by (simp add: NSDERIV_NSLIM_iff2 NSLIM_def)
   2.141 +  "(NSDERIV f x :> D) \<longleftrightarrow>
   2.142 +    (\<forall>w. w \<noteq> star_of x & w \<approx> star_of x \<longrightarrow> ( *f* (%z. (f z - f x) / (z-x))) w \<approx> star_of D)"
   2.143 +  by (simp add: NSDERIV_NSLIM_iff2 NSLIM_def)
   2.144  
   2.145 -(*FIXME DELETE*)
   2.146 -lemma hypreal_not_eq_minus_iff:
   2.147 -  "(x \<noteq> a) = (x - a \<noteq> (0::'a::ab_group_add))"
   2.148 -by auto
   2.149 +(* FIXME delete *)
   2.150 +lemma hypreal_not_eq_minus_iff: "x \<noteq> a \<longleftrightarrow> x - a \<noteq> (0::'a::ab_group_add)"
   2.151 +  by auto
   2.152  
   2.153  lemma NSDERIVD5:
   2.154 -  "(NSDERIV f x :> D) ==>
   2.155 -   (\<forall>u. u \<approx> hypreal_of_real x -->
   2.156 -     ( *f* (%z. f z - f x)) u \<approx> hypreal_of_real D * (u - hypreal_of_real x))"
   2.157 -apply (auto simp add: NSDERIV_iff2)
   2.158 -apply (case_tac "u = hypreal_of_real x", auto)
   2.159 -apply (drule_tac x = u in spec, auto)
   2.160 -apply (drule_tac c = "u - hypreal_of_real x" and b = "hypreal_of_real D" in approx_mult1)
   2.161 -apply (drule_tac [!] hypreal_not_eq_minus_iff [THEN iffD1])
   2.162 -apply (subgoal_tac [2] "( *f* (%z. z-x)) u \<noteq> (0::hypreal) ")
   2.163 -apply (auto simp add:
   2.164 -         approx_minus_iff [THEN iffD1, THEN mem_infmal_iff [THEN iffD2]]
   2.165 -         Infinitesimal_subset_HFinite [THEN subsetD])
   2.166 -done
   2.167 +  "(NSDERIV f x :> D) \<Longrightarrow>
   2.168 +   (\<forall>u. u \<approx> hypreal_of_real x \<longrightarrow>
   2.169 +     ( *f* (\<lambda>z. f z - f x)) u \<approx> hypreal_of_real D * (u - hypreal_of_real x))"
   2.170 +  apply (auto simp add: NSDERIV_iff2)
   2.171 +  apply (case_tac "u = hypreal_of_real x", auto)
   2.172 +  apply (drule_tac x = u in spec, auto)
   2.173 +  apply (drule_tac c = "u - hypreal_of_real x" and b = "hypreal_of_real D" in approx_mult1)
   2.174 +   apply (drule_tac [!] hypreal_not_eq_minus_iff [THEN iffD1])
   2.175 +   apply (subgoal_tac [2] "( *f* (%z. z-x)) u \<noteq> (0::hypreal) ")
   2.176 +    apply (auto simp: approx_minus_iff [THEN iffD1, THEN mem_infmal_iff [THEN iffD2]]
   2.177 +      Infinitesimal_subset_HFinite [THEN subsetD])
   2.178 +  done
   2.179  
   2.180  lemma NSDERIVD4:
   2.181 -     "(NSDERIV f x :> D) ==>
   2.182 -      (\<forall>h \<in> Infinitesimal.
   2.183 -               (( *f* f)(hypreal_of_real x + h) -
   2.184 -                 hypreal_of_real (f x))\<approx> (hypreal_of_real D) * h)"
   2.185 -apply (auto simp add: nsderiv_def)
   2.186 -apply (case_tac "h = (0::hypreal) ")
   2.187 -apply auto
   2.188 -apply (drule_tac x = h in bspec)
   2.189 -apply (drule_tac [2] c = h in approx_mult1)
   2.190 -apply (auto intro: Infinitesimal_subset_HFinite [THEN subsetD])
   2.191 -done
   2.192 +  "(NSDERIV f x :> D) \<Longrightarrow>
   2.193 +    (\<forall>h \<in> Infinitesimal.
   2.194 +      ( *f* f)(hypreal_of_real x + h) - hypreal_of_real (f x) \<approx> hypreal_of_real D * h)"
   2.195 +  apply (auto simp add: nsderiv_def)
   2.196 +  apply (case_tac "h = 0")
   2.197 +   apply auto
   2.198 +  apply (drule_tac x = h in bspec)
   2.199 +   apply (drule_tac [2] c = h in approx_mult1)
   2.200 +    apply (auto intro: Infinitesimal_subset_HFinite [THEN subsetD])
   2.201 +  done
   2.202  
   2.203  lemma NSDERIVD3:
   2.204 -     "(NSDERIV f x :> D) ==>
   2.205 -      (\<forall>h \<in> Infinitesimal - {0}.
   2.206 -               (( *f* f)(hypreal_of_real x + h) -
   2.207 -                 hypreal_of_real (f x))\<approx> (hypreal_of_real D) * h)"
   2.208 -apply (auto simp add: nsderiv_def)
   2.209 -apply (rule ccontr, drule_tac x = h in bspec)
   2.210 -apply (drule_tac [2] c = h in approx_mult1)
   2.211 -apply (auto intro: Infinitesimal_subset_HFinite [THEN subsetD] simp add: mult.assoc)
   2.212 -done
   2.213 +  "(NSDERIV f x :> D) \<Longrightarrow>
   2.214 +    \<forall>h \<in> Infinitesimal - {0}.
   2.215 +      (( *f* f) (hypreal_of_real x + h) - hypreal_of_real (f x)) \<approx> hypreal_of_real D * h"
   2.216 +  apply (auto simp add: nsderiv_def)
   2.217 +  apply (rule ccontr, drule_tac x = h in bspec)
   2.218 +   apply (drule_tac [2] c = h in approx_mult1)
   2.219 +    apply (auto intro: Infinitesimal_subset_HFinite [THEN subsetD] simp add: mult.assoc)
   2.220 +  done
   2.221  
   2.222 -text\<open>Differentiability implies continuity
   2.223 -         nice and simple "algebraic" proof\<close>
   2.224 -lemma NSDERIV_isNSCont: "NSDERIV f x :> D ==> isNSCont f x"
   2.225 -apply (auto simp add: nsderiv_def isNSCont_NSLIM_iff NSLIM_def)
   2.226 -apply (drule approx_minus_iff [THEN iffD1])
   2.227 -apply (drule hypreal_not_eq_minus_iff [THEN iffD1])
   2.228 -apply (drule_tac x = "xa - star_of x" in bspec)
   2.229 - prefer 2 apply (simp add: add.assoc [symmetric])
   2.230 -apply (auto simp add: mem_infmal_iff [symmetric] add.commute)
   2.231 -apply (drule_tac c = "xa - star_of x" in approx_mult1)
   2.232 -apply (auto intro: Infinitesimal_subset_HFinite [THEN subsetD]
   2.233 -            simp add: mult.assoc nonzero_mult_div_cancel_right)
   2.234 -apply (drule_tac x3=D in
   2.235 -           HFinite_star_of [THEN [2] Infinitesimal_HFinite_mult,
   2.236 -             THEN mem_infmal_iff [THEN iffD1]])
   2.237 -apply (auto simp add: mult.commute
   2.238 -            intro: approx_trans approx_minus_iff [THEN iffD2])
   2.239 -done
   2.240 +text \<open>Differentiability implies continuity nice and simple "algebraic" proof.\<close>
   2.241 +lemma NSDERIV_isNSCont: "NSDERIV f x :> D \<Longrightarrow> isNSCont f x"
   2.242 +  apply (auto simp add: nsderiv_def isNSCont_NSLIM_iff NSLIM_def)
   2.243 +  apply (drule approx_minus_iff [THEN iffD1])
   2.244 +  apply (drule hypreal_not_eq_minus_iff [THEN iffD1])
   2.245 +  apply (drule_tac x = "xa - star_of x" in bspec)
   2.246 +   prefer 2 apply (simp add: add.assoc [symmetric])
   2.247 +   apply (auto simp add: mem_infmal_iff [symmetric] add.commute)
   2.248 +  apply (drule_tac c = "xa - star_of x" in approx_mult1)
   2.249 +   apply (auto intro: Infinitesimal_subset_HFinite [THEN subsetD] simp add: mult.assoc)
   2.250 +  apply (drule_tac x3=D in
   2.251 +      HFinite_star_of [THEN [2] Infinitesimal_HFinite_mult, THEN mem_infmal_iff [THEN iffD1]])
   2.252 +  apply (auto simp add: mult.commute intro: approx_trans approx_minus_iff [THEN iffD2])
   2.253 +  done
   2.254  
   2.255 -text\<open>Differentiation rules for combinations of functions
   2.256 -      follow from clear, straightforard, algebraic
   2.257 -      manipulations\<close>
   2.258 -text\<open>Constant function\<close>
   2.259 +text \<open>Differentiation rules for combinations of functions
   2.260 +  follow from clear, straightforard, algebraic manipulations.\<close>
   2.261 +
   2.262 +text \<open>Constant function.\<close>
   2.263  
   2.264  (* use simple constant nslimit theorem *)
   2.265 -lemma NSDERIV_const [simp]: "(NSDERIV (%x. k) x :> 0)"
   2.266 -by (simp add: NSDERIV_NSLIM_iff)
   2.267 -
   2.268 -text\<open>Sum of functions- proved easily\<close>
   2.269 +lemma NSDERIV_const [simp]: "NSDERIV (\<lambda>x. k) x :> 0"
   2.270 +  by (simp add: NSDERIV_NSLIM_iff)
   2.271  
   2.272 -lemma NSDERIV_add: "[| NSDERIV f x :> Da;  NSDERIV g x :> Db |]
   2.273 -      ==> NSDERIV (%x. f x + g x) x :> Da + Db"
   2.274 -apply (auto simp add: NSDERIV_NSLIM_iff NSLIM_def)
   2.275 -apply (auto simp add: add_divide_distrib diff_divide_distrib dest!: spec)
   2.276 -apply (drule_tac b = "star_of Da" and d = "star_of Db" in approx_add)
   2.277 -apply (auto simp add: ac_simps algebra_simps)
   2.278 -done
   2.279 -
   2.280 -text\<open>Product of functions - Proof is trivial but tedious
   2.281 -  and long due to rearrangement of terms\<close>
   2.282 +text \<open>Sum of functions- proved easily.\<close>
   2.283  
   2.284 -lemma lemma_nsderiv1:
   2.285 -  fixes a b c d :: "'a::comm_ring star"
   2.286 -  shows "(a*b) - (c*d) = (b*(a - c)) + (c*(b - d))"
   2.287 -by (simp add: right_diff_distrib ac_simps)
   2.288 +lemma NSDERIV_add:
   2.289 +  "NSDERIV f x :> Da \<Longrightarrow> NSDERIV g x :> Db \<Longrightarrow> NSDERIV (\<lambda>x. f x + g x) x :> Da + Db"
   2.290 +  apply (auto simp add: NSDERIV_NSLIM_iff NSLIM_def)
   2.291 +  apply (auto simp add: add_divide_distrib diff_divide_distrib dest!: spec)
   2.292 +  apply (drule_tac b = "star_of Da" and d = "star_of Db" in approx_add)
   2.293 +   apply (auto simp add: ac_simps algebra_simps)
   2.294 +  done
   2.295  
   2.296 -lemma lemma_nsderiv2:
   2.297 -  fixes x y z :: "'a::real_normed_field star"
   2.298 -  shows "[| (x - y) / z = star_of D + yb; z \<noteq> 0;
   2.299 -         z \<in> Infinitesimal; yb \<in> Infinitesimal |]
   2.300 -      ==> x - y \<approx> 0"
   2.301 -apply (simp add: nonzero_divide_eq_eq)
   2.302 -apply (auto intro!: Infinitesimal_HFinite_mult2 HFinite_add
   2.303 -            simp add: mult.assoc mem_infmal_iff [symmetric])
   2.304 -apply (erule Infinitesimal_subset_HFinite [THEN subsetD])
   2.305 -done
   2.306 +text \<open>Product of functions - Proof is trivial but tedious
   2.307 +  and long due to rearrangement of terms.\<close>
   2.308 +
   2.309 +lemma lemma_nsderiv1: "(a * b) - (c * d) = (b * (a - c)) + (c * (b - d))"
   2.310 +  for a b c d :: "'a::comm_ring star"
   2.311 +  by (simp add: right_diff_distrib ac_simps)
   2.312  
   2.313 -lemma NSDERIV_mult: "[| NSDERIV f x :> Da; NSDERIV g x :> Db |]
   2.314 -      ==> NSDERIV (%x. f x * g x) x :> (Da * g(x)) + (Db * f(x))"
   2.315 -apply (auto simp add: NSDERIV_NSLIM_iff NSLIM_def)
   2.316 -apply (auto dest!: spec
   2.317 -      simp add: starfun_lambda_cancel lemma_nsderiv1)
   2.318 -apply (simp (no_asm) add: add_divide_distrib diff_divide_distrib)
   2.319 -apply (drule bex_Infinitesimal_iff2 [THEN iffD2])+
   2.320 -apply (auto simp add: times_divide_eq_right [symmetric]
   2.321 -            simp del: times_divide_eq_right times_divide_eq_left)
   2.322 -apply (drule_tac D = Db in lemma_nsderiv2, assumption+)
   2.323 -apply (drule_tac
   2.324 -     approx_minus_iff [THEN iffD2, THEN bex_Infinitesimal_iff2 [THEN iffD2]])
   2.325 -apply (auto intro!: approx_add_mono1
   2.326 -            simp add: distrib_right distrib_left mult.commute add.assoc)
   2.327 -apply (rule_tac b1 = "star_of Db * star_of (f x)"
   2.328 -         in add.commute [THEN subst])
   2.329 -apply (auto intro!: Infinitesimal_add_approx_self2 [THEN approx_sym]
   2.330 -                    Infinitesimal_add Infinitesimal_mult
   2.331 -                    Infinitesimal_star_of_mult
   2.332 -                    Infinitesimal_star_of_mult2
   2.333 -          simp add: add.assoc [symmetric])
   2.334 -done
   2.335 +lemma lemma_nsderiv2: "(x - y) / z = star_of D + yb \<Longrightarrow> z \<noteq> 0 \<Longrightarrow>
   2.336 +  z \<in> Infinitesimal \<Longrightarrow> yb \<in> Infinitesimal \<Longrightarrow> x - y \<approx> 0"
   2.337 +  for x y z :: "'a::real_normed_field star"
   2.338 +  apply (simp add: nonzero_divide_eq_eq)
   2.339 +  apply (auto intro!: Infinitesimal_HFinite_mult2 HFinite_add
   2.340 +      simp add: mult.assoc mem_infmal_iff [symmetric])
   2.341 +  apply (erule Infinitesimal_subset_HFinite [THEN subsetD])
   2.342 +  done
   2.343  
   2.344 -text\<open>Multiplying by a constant\<close>
   2.345 -lemma NSDERIV_cmult: "NSDERIV f x :> D
   2.346 -      ==> NSDERIV (%x. c * f x) x :> c*D"
   2.347 -apply (simp only: times_divide_eq_right [symmetric] NSDERIV_NSLIM_iff
   2.348 -                  minus_mult_right right_diff_distrib [symmetric])
   2.349 -apply (erule NSLIM_const [THEN NSLIM_mult])
   2.350 -done
   2.351 +lemma NSDERIV_mult:
   2.352 +  "NSDERIV f x :> Da \<Longrightarrow> NSDERIV g x :> Db \<Longrightarrow>
   2.353 +    NSDERIV (\<lambda>x. f x * g x) x :> (Da * g x) + (Db * f x)"
   2.354 +  apply (auto simp add: NSDERIV_NSLIM_iff NSLIM_def)
   2.355 +  apply (auto dest!: spec simp add: starfun_lambda_cancel lemma_nsderiv1)
   2.356 +  apply (simp (no_asm) add: add_divide_distrib diff_divide_distrib)
   2.357 +  apply (drule bex_Infinitesimal_iff2 [THEN iffD2])+
   2.358 +  apply (auto simp add: times_divide_eq_right [symmetric]
   2.359 +      simp del: times_divide_eq_right times_divide_eq_left)
   2.360 +  apply (drule_tac D = Db in lemma_nsderiv2, assumption+)
   2.361 +  apply (drule_tac approx_minus_iff [THEN iffD2, THEN bex_Infinitesimal_iff2 [THEN iffD2]])
   2.362 +  apply (auto intro!: approx_add_mono1 simp: distrib_right distrib_left mult.commute add.assoc)
   2.363 +  apply (rule_tac b1 = "star_of Db * star_of (f x)" in add.commute [THEN subst])
   2.364 +  apply (auto intro!: Infinitesimal_add_approx_self2 [THEN approx_sym]
   2.365 +      Infinitesimal_add Infinitesimal_mult Infinitesimal_star_of_mult Infinitesimal_star_of_mult2
   2.366 +      simp add: add.assoc [symmetric])
   2.367 +  done
   2.368  
   2.369 -text\<open>Negation of function\<close>
   2.370 -lemma NSDERIV_minus: "NSDERIV f x :> D ==> NSDERIV (%x. -(f x)) x :> -D"
   2.371 +text \<open>Multiplying by a constant.\<close>
   2.372 +lemma NSDERIV_cmult: "NSDERIV f x :> D \<Longrightarrow> NSDERIV (\<lambda>x. c * f x) x :> c * D"
   2.373 +  apply (simp only: times_divide_eq_right [symmetric] NSDERIV_NSLIM_iff
   2.374 +      minus_mult_right right_diff_distrib [symmetric])
   2.375 +  apply (erule NSLIM_const [THEN NSLIM_mult])
   2.376 +  done
   2.377 +
   2.378 +text \<open>Negation of function.\<close>
   2.379 +lemma NSDERIV_minus: "NSDERIV f x :> D \<Longrightarrow> NSDERIV (\<lambda>x. - f x) x :> - D"
   2.380  proof (simp add: NSDERIV_NSLIM_iff)
   2.381    assume "(\<lambda>h. (f (x + h) - f x) / h) \<midarrow>0\<rightarrow>\<^sub>N\<^sub>S D"
   2.382 -  hence deriv: "(\<lambda>h. - ((f(x+h) - f x) / h)) \<midarrow>0\<rightarrow>\<^sub>N\<^sub>S - D"
   2.383 +  then have deriv: "(\<lambda>h. - ((f(x+h) - f x) / h)) \<midarrow>0\<rightarrow>\<^sub>N\<^sub>S - D"
   2.384      by (rule NSLIM_minus)
   2.385    have "\<forall>h. - ((f (x + h) - f x) / h) = (- f (x + h) + f x) / h"
   2.386      by (simp add: minus_divide_left)
   2.387 -  with deriv
   2.388 -  have "(\<lambda>h. (- f (x + h) + f x) / h) \<midarrow>0\<rightarrow>\<^sub>N\<^sub>S - D" by simp
   2.389 -  then show "(\<lambda>h. (f (x + h) - f x) / h) \<midarrow>0\<rightarrow>\<^sub>N\<^sub>S D \<Longrightarrow>
   2.390 -    (\<lambda>h. (f x - f (x + h)) / h) \<midarrow>0\<rightarrow>\<^sub>N\<^sub>S - D" by simp
   2.391 +  with deriv have "(\<lambda>h. (- f (x + h) + f x) / h) \<midarrow>0\<rightarrow>\<^sub>N\<^sub>S - D"
   2.392 +    by simp
   2.393 +  then show "(\<lambda>h. (f (x + h) - f x) / h) \<midarrow>0\<rightarrow>\<^sub>N\<^sub>S D \<Longrightarrow> (\<lambda>h. (f x - f (x + h)) / h) \<midarrow>0\<rightarrow>\<^sub>N\<^sub>S - D"
   2.394 +    by simp
   2.395  qed
   2.396  
   2.397 -text\<open>Subtraction\<close>
   2.398 -lemma NSDERIV_add_minus: "[| NSDERIV f x :> Da; NSDERIV g x :> Db |] ==> NSDERIV (%x. f x + -g x) x :> Da + -Db"
   2.399 -by (blast dest: NSDERIV_add NSDERIV_minus)
   2.400 +text \<open>Subtraction.\<close>
   2.401 +lemma NSDERIV_add_minus:
   2.402 +  "NSDERIV f x :> Da \<Longrightarrow> NSDERIV g x :> Db \<Longrightarrow> NSDERIV (\<lambda>x. f x + - g x) x :> Da + - Db"
   2.403 +  by (blast dest: NSDERIV_add NSDERIV_minus)
   2.404  
   2.405  lemma NSDERIV_diff:
   2.406 -  "NSDERIV f x :> Da \<Longrightarrow> NSDERIV g x :> Db \<Longrightarrow> NSDERIV (\<lambda>x. f x - g x) x :> Da-Db"
   2.407 +  "NSDERIV f x :> Da \<Longrightarrow> NSDERIV g x :> Db \<Longrightarrow> NSDERIV (\<lambda>x. f x - g x) x :> Da - Db"
   2.408    using NSDERIV_add_minus [of f x Da g Db] by simp
   2.409  
   2.410 -text\<open>Similarly to the above, the chain rule admits an entirely
   2.411 -   straightforward derivation. Compare this with Harrison's
   2.412 -   HOL proof of the chain rule, which proved to be trickier and
   2.413 -   required an alternative characterisation of differentiability-
   2.414 -   the so-called Carathedory derivative. Our main problem is
   2.415 -   manipulation of terms.\<close>
   2.416 +text \<open>Similarly to the above, the chain rule admits an entirely
   2.417 +  straightforward derivation. Compare this with Harrison's
   2.418 +  HOL proof of the chain rule, which proved to be trickier and
   2.419 +  required an alternative characterisation of differentiability-
   2.420 +  the so-called Carathedory derivative. Our main problem is
   2.421 +  manipulation of terms.\<close>
   2.422  
   2.423 -(* lemmas *)
   2.424 +
   2.425 +subsection \<open>Lemmas\<close>
   2.426  
   2.427  lemma NSDERIV_zero:
   2.428 -      "[| NSDERIV g x :> D;
   2.429 -               ( *f* g) (star_of x + xa) = star_of (g x);
   2.430 -               xa \<in> Infinitesimal;
   2.431 -               xa \<noteq> 0
   2.432 -            |] ==> D = 0"
   2.433 -apply (simp add: nsderiv_def)
   2.434 -apply (drule bspec, auto)
   2.435 -done
   2.436 +  "NSDERIV g x :> D \<Longrightarrow> ( *f* g) (star_of x + xa) = star_of (g x) \<Longrightarrow>
   2.437 +    xa \<in> Infinitesimal \<Longrightarrow> xa \<noteq> 0 \<Longrightarrow> D = 0"
   2.438 +  apply (simp add: nsderiv_def)
   2.439 +  apply (drule bspec)
   2.440 +   apply auto
   2.441 +  done
   2.442  
   2.443 -(* can be proved differently using NSLIM_isCont_iff *)
   2.444 +text \<open>Can be proved differently using \<open>NSLIM_isCont_iff\<close>.\<close>
   2.445  lemma NSDERIV_approx:
   2.446 -     "[| NSDERIV f x :> D;  h \<in> Infinitesimal;  h \<noteq> 0 |]
   2.447 -      ==> ( *f* f) (star_of x + h) - star_of (f x) \<approx> 0"
   2.448 -apply (simp add: nsderiv_def)
   2.449 -apply (simp add: mem_infmal_iff [symmetric])
   2.450 -apply (rule Infinitesimal_ratio)
   2.451 -apply (rule_tac [3] approx_star_of_HFinite, auto)
   2.452 -done
   2.453 +  "NSDERIV f x :> D \<Longrightarrow> h \<in> Infinitesimal \<Longrightarrow> h \<noteq> 0 \<Longrightarrow>
   2.454 +    ( *f* f) (star_of x + h) - star_of (f x) \<approx> 0"
   2.455 +  apply (simp add: nsderiv_def)
   2.456 +  apply (simp add: mem_infmal_iff [symmetric])
   2.457 +  apply (rule Infinitesimal_ratio)
   2.458 +    apply (rule_tac [3] approx_star_of_HFinite, auto)
   2.459 +  done
   2.460  
   2.461 -(*---------------------------------------------------------------
   2.462 -   from one version of differentiability
   2.463 +text \<open>From one version of differentiability
   2.464  
   2.465 -                f(x) - f(a)
   2.466 -              --------------- \<approx> Db
   2.467 -                  x - a
   2.468 - ---------------------------------------------------------------*)
   2.469 +        \<open>f x - f a\<close>
   2.470 +      \<open>-------------- \<approx> Db\<close>
   2.471 +          \<open>x - a\<close>
   2.472 +\<close>
   2.473  
   2.474  lemma NSDERIVD1: "[| NSDERIV f (g x) :> Da;
   2.475           ( *f* g) (star_of(x) + xa) \<noteq> star_of (g x);
   2.476 @@ -290,186 +258,185 @@
   2.477                     - star_of (f (g x)))
   2.478                / (( *f* g) (star_of(x) + xa) - star_of (g x))
   2.479               \<approx> star_of(Da)"
   2.480 -by (auto simp add: NSDERIV_NSLIM_iff2 NSLIM_def)
   2.481 +  by (auto simp add: NSDERIV_NSLIM_iff2 NSLIM_def)
   2.482  
   2.483 -(*--------------------------------------------------------------
   2.484 -   from other version of differentiability
   2.485 +text \<open>From other version of differentiability
   2.486  
   2.487 -                f(x + h) - f(x)
   2.488 -               ----------------- \<approx> Db
   2.489 -                       h
   2.490 - --------------------------------------------------------------*)
   2.491 +      \<open>f (x + h) - f x\<close>
   2.492 +     \<open>------------------ \<approx> Db\<close>
   2.493 +             \<open>h\<close>
   2.494 +\<close>
   2.495  
   2.496  lemma NSDERIVD2: "[| NSDERIV g x :> Db; xa \<in> Infinitesimal; xa \<noteq> 0 |]
   2.497        ==> (( *f* g) (star_of(x) + xa) - star_of(g x)) / xa
   2.498            \<approx> star_of(Db)"
   2.499 -by (auto simp add: NSDERIV_NSLIM_iff NSLIM_def mem_infmal_iff starfun_lambda_cancel)
   2.500 +  by (auto simp add: NSDERIV_NSLIM_iff NSLIM_def mem_infmal_iff starfun_lambda_cancel)
   2.501  
   2.502 -lemma lemma_chain: "(z::'a::real_normed_field star) \<noteq> 0 ==> x*y = (x*inverse(z))*(z*y)"
   2.503 +lemma lemma_chain: "z \<noteq> 0 \<Longrightarrow> x * y = (x * inverse z) * (z * y)"
   2.504 +  for x y z :: "'a::real_normed_field star"
   2.505  proof -
   2.506    assume z: "z \<noteq> 0"
   2.507    have "x * y = x * (inverse z * z) * y" by (simp add: z)
   2.508 -  thus ?thesis by (simp add: mult.assoc)
   2.509 +  then show ?thesis by (simp add: mult.assoc)
   2.510  qed
   2.511  
   2.512 -text\<open>This proof uses both definitions of differentiability.\<close>
   2.513 -lemma NSDERIV_chain: "[| NSDERIV f (g x) :> Da; NSDERIV g x :> Db |]
   2.514 -      ==> NSDERIV (f o g) x :> Da * Db"
   2.515 -apply (simp (no_asm_simp) add: NSDERIV_NSLIM_iff NSLIM_def
   2.516 -                mem_infmal_iff [symmetric])
   2.517 -apply clarify
   2.518 -apply (frule_tac f = g in NSDERIV_approx)
   2.519 -apply (auto simp add: starfun_lambda_cancel2 starfun_o [symmetric])
   2.520 -apply (case_tac "( *f* g) (star_of (x) + xa) = star_of (g x) ")
   2.521 -apply (drule_tac g = g in NSDERIV_zero)
   2.522 -apply (auto simp add: divide_inverse)
   2.523 -apply (rule_tac z1 = "( *f* g) (star_of (x) + xa) - star_of (g x) " and y1 = "inverse xa" in lemma_chain [THEN ssubst])
   2.524 -apply (erule hypreal_not_eq_minus_iff [THEN iffD1])
   2.525 -apply (rule approx_mult_star_of)
   2.526 -apply (simp_all add: divide_inverse [symmetric])
   2.527 -apply (blast intro: NSDERIVD1 approx_minus_iff [THEN iffD2])
   2.528 -apply (blast intro: NSDERIVD2)
   2.529 -done
   2.530 +text \<open>This proof uses both definitions of differentiability.\<close>
   2.531 +lemma NSDERIV_chain:
   2.532 +  "NSDERIV f (g x) :> Da \<Longrightarrow> NSDERIV g x :> Db \<Longrightarrow> NSDERIV (f \<circ> g) x :> Da * Db"
   2.533 +  apply (simp (no_asm_simp) add: NSDERIV_NSLIM_iff NSLIM_def mem_infmal_iff [symmetric])
   2.534 +  apply clarify
   2.535 +  apply (frule_tac f = g in NSDERIV_approx)
   2.536 +    apply (auto simp add: starfun_lambda_cancel2 starfun_o [symmetric])
   2.537 +  apply (case_tac "( *f* g) (star_of (x) + xa) = star_of (g x) ")
   2.538 +   apply (drule_tac g = g in NSDERIV_zero)
   2.539 +      apply (auto simp add: divide_inverse)
   2.540 +  apply (rule_tac z1 = "( *f* g) (star_of (x) + xa) - star_of (g x) " and y1 = "inverse xa" in lemma_chain [THEN ssubst])
   2.541 +   apply (erule hypreal_not_eq_minus_iff [THEN iffD1])
   2.542 +  apply (rule approx_mult_star_of)
   2.543 +   apply (simp_all add: divide_inverse [symmetric])
   2.544 +   apply (blast intro: NSDERIVD1 approx_minus_iff [THEN iffD2])
   2.545 +  apply (blast intro: NSDERIVD2)
   2.546 +  done
   2.547  
   2.548 -text\<open>Differentiation of natural number powers\<close>
   2.549 -lemma NSDERIV_Id [simp]: "NSDERIV (%x. x) x :> 1"
   2.550 -by (simp add: NSDERIV_NSLIM_iff NSLIM_def del: divide_self_if)
   2.551 +text \<open>Differentiation of natural number powers.\<close>
   2.552 +lemma NSDERIV_Id [simp]: "NSDERIV (\<lambda>x. x) x :> 1"
   2.553 +  by (simp add: NSDERIV_NSLIM_iff NSLIM_def del: divide_self_if)
   2.554  
   2.555  lemma NSDERIV_cmult_Id [simp]: "NSDERIV (op * c) x :> c"
   2.556 -by (cut_tac c = c and x = x in NSDERIV_Id [THEN NSDERIV_cmult], simp)
   2.557 +  using NSDERIV_Id [THEN NSDERIV_cmult] by simp
   2.558  
   2.559  lemma NSDERIV_inverse:
   2.560    fixes x :: "'a::real_normed_field"
   2.561    assumes "x \<noteq> 0" \<comment> \<open>can't get rid of @{term "x \<noteq> 0"} because it isn't continuous at zero\<close>
   2.562    shows "NSDERIV (\<lambda>x. inverse x) x :> - (inverse x ^ Suc (Suc 0))"
   2.563  proof -
   2.564 -  { fix h :: "'a star"
   2.565 +  {
   2.566 +    fix h :: "'a star"
   2.567      assume h_Inf: "h \<in> Infinitesimal"
   2.568 -    from this assms have not_0: "star_of x + h \<noteq> 0" by (rule Infinitesimal_add_not_zero)
   2.569 +    from this assms have not_0: "star_of x + h \<noteq> 0"
   2.570 +      by (rule Infinitesimal_add_not_zero)
   2.571      assume "h \<noteq> 0"
   2.572 -    from h_Inf have "h * star_of x \<in> Infinitesimal" by (rule Infinitesimal_HFinite_mult) simp
   2.573 +    from h_Inf have "h * star_of x \<in> Infinitesimal"
   2.574 +      by (rule Infinitesimal_HFinite_mult) simp
   2.575      with assms have "inverse (- (h * star_of x) + - (star_of x * star_of x)) \<approx>
   2.576        inverse (- (star_of x * star_of x))"
   2.577 -      apply - apply (rule inverse_add_Infinitesimal_approx2)
   2.578 -      apply (auto
   2.579 -        dest!: hypreal_of_real_HFinite_diff_Infinitesimal
   2.580 +      apply -
   2.581 +      apply (rule inverse_add_Infinitesimal_approx2)
   2.582 +      apply (auto dest!: hypreal_of_real_HFinite_diff_Infinitesimal
   2.583          simp add: inverse_minus_eq [symmetric] HFinite_minus_iff)
   2.584        done
   2.585      moreover from not_0 \<open>h \<noteq> 0\<close> assms
   2.586 -      have "inverse (- (h * star_of x) + - (star_of x * star_of x)) =
   2.587 -        (inverse (star_of x + h) - inverse (star_of x)) / h"
   2.588 +    have "inverse (- (h * star_of x) + - (star_of x * star_of x)) =
   2.589 +      (inverse (star_of x + h) - inverse (star_of x)) / h"
   2.590        apply (simp add: division_ring_inverse_diff nonzero_inverse_mult_distrib [symmetric]
   2.591 -        nonzero_inverse_minus_eq [symmetric] ac_simps ring_distribs)
   2.592 +          nonzero_inverse_minus_eq [symmetric] ac_simps ring_distribs)
   2.593        apply (subst nonzero_inverse_minus_eq [symmetric])
   2.594        using distrib_right [symmetric, of h "star_of x" "star_of x"] apply simp
   2.595        apply (simp add: field_simps)
   2.596        done
   2.597      ultimately have "(inverse (star_of x + h) - inverse (star_of x)) / h \<approx>
   2.598        - (inverse (star_of x) * inverse (star_of x))"
   2.599 -      using assms by simp 
   2.600 -  } then show ?thesis by (simp add: nsderiv_def)
   2.601 +      using assms by simp
   2.602 +  }
   2.603 +  then show ?thesis by (simp add: nsderiv_def)
   2.604  qed
   2.605  
   2.606 +
   2.607  subsubsection \<open>Equivalence of NS and Standard definitions\<close>
   2.608  
   2.609  lemma divideR_eq_divide: "x /\<^sub>R y = x / y"
   2.610 -by (simp add: divide_inverse mult.commute)
   2.611 +  by (simp add: divide_inverse mult.commute)
   2.612  
   2.613 -text\<open>Now equivalence between NSDERIV and DERIV\<close>
   2.614 -lemma NSDERIV_DERIV_iff: "(NSDERIV f x :> D) = (DERIV f x :> D)"
   2.615 -by (simp add: DERIV_def NSDERIV_NSLIM_iff LIM_NSLIM_iff)
   2.616 +text \<open>Now equivalence between \<open>NSDERIV\<close> and \<open>DERIV\<close>.\<close>
   2.617 +lemma NSDERIV_DERIV_iff: "NSDERIV f x :> D \<longleftrightarrow> DERIV f x :> D"
   2.618 +  by (simp add: DERIV_def NSDERIV_NSLIM_iff LIM_NSLIM_iff)
   2.619  
   2.620 -(* NS version *)
   2.621 -lemma NSDERIV_pow: "NSDERIV (%x. x ^ n) x :> real n * (x ^ (n - Suc 0))"
   2.622 -by (simp add: NSDERIV_DERIV_iff DERIV_pow)
   2.623 +text \<open>NS version.\<close>
   2.624 +lemma NSDERIV_pow: "NSDERIV (\<lambda>x. x ^ n) x :> real n * (x ^ (n - Suc 0))"
   2.625 +  by (simp add: NSDERIV_DERIV_iff DERIV_pow)
   2.626  
   2.627 -text\<open>Derivative of inverse\<close>
   2.628 -
   2.629 +text \<open>Derivative of inverse.\<close>
   2.630  lemma NSDERIV_inverse_fun:
   2.631 -  fixes x :: "'a::{real_normed_field}"
   2.632 -  shows "[| NSDERIV f x :> d; f(x) \<noteq> 0 |]
   2.633 -      ==> NSDERIV (%x. inverse(f x)) x :> (- (d * inverse(f(x) ^ Suc (Suc 0))))"
   2.634 -by (simp add: NSDERIV_DERIV_iff DERIV_inverse_fun del: power_Suc)
   2.635 +  "NSDERIV f x :> d \<Longrightarrow> f x \<noteq> 0 \<Longrightarrow>
   2.636 +    NSDERIV (\<lambda>x. inverse (f x)) x :> (- (d * inverse (f x ^ Suc (Suc 0))))"
   2.637 +  for x :: "'a::{real_normed_field}"
   2.638 +  by (simp add: NSDERIV_DERIV_iff DERIV_inverse_fun del: power_Suc)
   2.639  
   2.640 -text\<open>Derivative of quotient\<close>
   2.641 -
   2.642 +text \<open>Derivative of quotient.\<close>
   2.643  lemma NSDERIV_quotient:
   2.644 -  fixes x :: "'a::{real_normed_field}"
   2.645 -  shows "[| NSDERIV f x :> d; NSDERIV g x :> e; g(x) \<noteq> 0 |]
   2.646 -       ==> NSDERIV (%y. f(y) / (g y)) x :> (d*g(x)
   2.647 -                            - (e*f(x))) / (g(x) ^ Suc (Suc 0))"
   2.648 -by (simp add: NSDERIV_DERIV_iff DERIV_quotient del: power_Suc)
   2.649 +  fixes x :: "'a::real_normed_field"
   2.650 +  shows "NSDERIV f x :> d \<Longrightarrow> NSDERIV g x :> e \<Longrightarrow> g x \<noteq> 0 \<Longrightarrow>
   2.651 +    NSDERIV (\<lambda>y. f y / g y) x :> (d * g x - (e * f x)) / (g x ^ Suc (Suc 0))"
   2.652 +  by (simp add: NSDERIV_DERIV_iff DERIV_quotient del: power_Suc)
   2.653  
   2.654 -lemma CARAT_NSDERIV: "NSDERIV f x :> l ==>
   2.655 -      \<exists>g. (\<forall>z. f z - f x = g z * (z-x)) & isNSCont g x & g x = l"
   2.656 -by (auto simp add: NSDERIV_DERIV_iff isNSCont_isCont_iff CARAT_DERIV
   2.657 -                   mult.commute)
   2.658 +lemma CARAT_NSDERIV:
   2.659 +  "NSDERIV f x :> l \<Longrightarrow> \<exists>g. (\<forall>z. f z - f x = g z * (z - x)) \<and> isNSCont g x \<and> g x = l"
   2.660 +  by (auto simp add: NSDERIV_DERIV_iff isNSCont_isCont_iff CARAT_DERIV mult.commute)
   2.661  
   2.662 -lemma hypreal_eq_minus_iff3: "(x = y + z) = (x + -z = (y::hypreal))"
   2.663 -by auto
   2.664 +lemma hypreal_eq_minus_iff3: "x = y + z \<longleftrightarrow> x + - z = y"
   2.665 +  for x y z :: hypreal
   2.666 +  by auto
   2.667  
   2.668  lemma CARAT_DERIVD:
   2.669 -  assumes all: "\<forall>z. f z - f x = g z * (z-x)"
   2.670 -      and nsc: "isNSCont g x"
   2.671 +  assumes all: "\<forall>z. f z - f x = g z * (z - x)"
   2.672 +    and nsc: "isNSCont g x"
   2.673    shows "NSDERIV f x :> g x"
   2.674  proof -
   2.675 -  from nsc
   2.676 -  have "\<forall>w. w \<noteq> star_of x \<and> w \<approx> star_of x \<longrightarrow>
   2.677 -         ( *f* g) w * (w - star_of x) / (w - star_of x) \<approx>
   2.678 -         star_of (g x)"
   2.679 -    by (simp add: isNSCont_def nonzero_mult_div_cancel_right)
   2.680 -  thus ?thesis using all
   2.681 +  from nsc have "\<forall>w. w \<noteq> star_of x \<and> w \<approx> star_of x \<longrightarrow>
   2.682 +       ( *f* g) w * (w - star_of x) / (w - star_of x) \<approx> star_of (g x)"
   2.683 +    by (simp add: isNSCont_def)
   2.684 +  with all show ?thesis
   2.685      by (simp add: NSDERIV_iff2 starfun_if_eq cong: if_cong)
   2.686  qed
   2.687  
   2.688 +
   2.689  subsubsection \<open>Differentiability predicate\<close>
   2.690  
   2.691 -lemma NSdifferentiableD: "f NSdifferentiable x ==> \<exists>D. NSDERIV f x :> D"
   2.692 -by (simp add: NSdifferentiable_def)
   2.693 +lemma NSdifferentiableD: "f NSdifferentiable x \<Longrightarrow> \<exists>D. NSDERIV f x :> D"
   2.694 +  by (simp add: NSdifferentiable_def)
   2.695  
   2.696 -lemma NSdifferentiableI: "NSDERIV f x :> D ==> f NSdifferentiable x"
   2.697 -by (force simp add: NSdifferentiable_def)
   2.698 +lemma NSdifferentiableI: "NSDERIV f x :> D \<Longrightarrow> f NSdifferentiable x"
   2.699 +  by (force simp add: NSdifferentiable_def)
   2.700  
   2.701  
   2.702  subsection \<open>(NS) Increment\<close>
   2.703 -lemma incrementI:
   2.704 -      "f NSdifferentiable x ==>
   2.705 -      increment f x h = ( *f* f) (hypreal_of_real(x) + h) -
   2.706 -      hypreal_of_real (f x)"
   2.707 -by (simp add: increment_def)
   2.708  
   2.709 -lemma incrementI2: "NSDERIV f x :> D ==>
   2.710 -     increment f x h = ( *f* f) (hypreal_of_real(x) + h) -
   2.711 -     hypreal_of_real (f x)"
   2.712 -apply (erule NSdifferentiableI [THEN incrementI])
   2.713 -done
   2.714 +lemma incrementI:
   2.715 +  "f NSdifferentiable x \<Longrightarrow>
   2.716 +    increment f x h = ( *f* f) (hypreal_of_real x + h) - hypreal_of_real (f x)"
   2.717 +  by (simp add: increment_def)
   2.718 +
   2.719 +lemma incrementI2:
   2.720 +  "NSDERIV f x :> D \<Longrightarrow>
   2.721 +    increment f x h = ( *f* f) (hypreal_of_real x + h) - hypreal_of_real (f x)"
   2.722 +  by (erule NSdifferentiableI [THEN incrementI])
   2.723  
   2.724 -(* The Increment theorem -- Keisler p. 65 *)
   2.725 -lemma increment_thm: "[| NSDERIV f x :> D; h \<in> Infinitesimal; h \<noteq> 0 |]
   2.726 -      ==> \<exists>e \<in> Infinitesimal. increment f x h = hypreal_of_real(D)*h + e*h"
   2.727 -apply (frule_tac h = h in incrementI2, simp add: nsderiv_def)
   2.728 -apply (drule bspec, auto)
   2.729 -apply (drule bex_Infinitesimal_iff2 [THEN iffD2], clarify)
   2.730 -apply (frule_tac b1 = "hypreal_of_real (D) + y"
   2.731 -        in mult_right_cancel [THEN iffD2])
   2.732 -apply (erule_tac [2] V = "(( *f* f) (hypreal_of_real (x) + h) - hypreal_of_real (f x)) / h = hypreal_of_real (D) + y" in thin_rl)
   2.733 -apply assumption
   2.734 -apply (simp add: times_divide_eq_right [symmetric])
   2.735 -apply (auto simp add: distrib_right)
   2.736 -done
   2.737 +text \<open>The Increment theorem -- Keisler p. 65.\<close>
   2.738 +lemma increment_thm:
   2.739 +  "NSDERIV f x :> D \<Longrightarrow> h \<in> Infinitesimal \<Longrightarrow> h \<noteq> 0 \<Longrightarrow>
   2.740 +    \<exists>e \<in> Infinitesimal. increment f x h = hypreal_of_real D * h + e * h"
   2.741 +  apply (frule_tac h = h in incrementI2, simp add: nsderiv_def)
   2.742 +  apply (drule bspec, auto)
   2.743 +  apply (drule bex_Infinitesimal_iff2 [THEN iffD2], clarify)
   2.744 +  apply (frule_tac b1 = "hypreal_of_real D + y" in mult_right_cancel [THEN iffD2])
   2.745 +   apply (erule_tac [2]
   2.746 +      V = "(( *f* f) (hypreal_of_real x + h) - hypreal_of_real (f x)) / h = hypreal_of_real (D) + y"
   2.747 +      in thin_rl)
   2.748 +   apply assumption
   2.749 +  apply (simp add: times_divide_eq_right [symmetric])
   2.750 +  apply (auto simp add: distrib_right)
   2.751 +  done
   2.752  
   2.753  lemma increment_thm2:
   2.754 -     "[| NSDERIV f x :> D; h \<approx> 0; h \<noteq> 0 |]
   2.755 -      ==> \<exists>e \<in> Infinitesimal. increment f x h =
   2.756 -              hypreal_of_real(D)*h + e*h"
   2.757 -by (blast dest!: mem_infmal_iff [THEN iffD2] intro!: increment_thm)
   2.758 -
   2.759 +  "NSDERIV f x :> D \<Longrightarrow> h \<approx> 0 \<Longrightarrow> h \<noteq> 0 \<Longrightarrow>
   2.760 +    \<exists>e \<in> Infinitesimal. increment f x h = hypreal_of_real D * h + e * h"
   2.761 +  by (blast dest!: mem_infmal_iff [THEN iffD2] intro!: increment_thm)
   2.762  
   2.763 -lemma increment_approx_zero: "[| NSDERIV f x :> D; h \<approx> 0; h \<noteq> 0 |]
   2.764 -      ==> increment f x h \<approx> 0"
   2.765 -apply (drule increment_thm2,
   2.766 -       auto intro!: Infinitesimal_HFinite_mult2 HFinite_add simp add: distrib_right [symmetric] mem_infmal_iff [symmetric])
   2.767 -apply (erule Infinitesimal_subset_HFinite [THEN subsetD])
   2.768 -done
   2.769 +lemma increment_approx_zero: "NSDERIV f x :> D \<Longrightarrow> h \<approx> 0 \<Longrightarrow> h \<noteq> 0 \<Longrightarrow> increment f x h \<approx> 0"
   2.770 +  apply (drule increment_thm2)
   2.771 +    apply (auto intro!: Infinitesimal_HFinite_mult2 HFinite_add
   2.772 +      simp add: distrib_right [symmetric] mem_infmal_iff [symmetric])
   2.773 +  apply (erule Infinitesimal_subset_HFinite [THEN subsetD])
   2.774 +  done
   2.775  
   2.776  end
     3.1 --- a/src/HOL/Nonstandard_Analysis/HLim.thy	Mon Oct 31 16:26:36 2016 +0100
     3.2 +++ b/src/HOL/Nonstandard_Analysis/HLim.thy	Tue Nov 01 00:44:24 2016 +0100
     3.3 @@ -3,330 +3,308 @@
     3.4      Author:     Lawrence C Paulson
     3.5  *)
     3.6  
     3.7 -section\<open>Limits and Continuity (Nonstandard)\<close>
     3.8 +section \<open>Limits and Continuity (Nonstandard)\<close>
     3.9  
    3.10  theory HLim
    3.11    imports Star
    3.12    abbrevs "--->" = "\<midarrow>\<rightarrow>\<^sub>N\<^sub>S"
    3.13  begin
    3.14  
    3.15 -text\<open>Nonstandard Definitions\<close>
    3.16 +text \<open>Nonstandard Definitions.\<close>
    3.17  
    3.18 -definition
    3.19 -  NSLIM :: "['a::real_normed_vector => 'b::real_normed_vector, 'a, 'b] => bool"
    3.20 -            ("((_)/ \<midarrow>(_)/\<rightarrow>\<^sub>N\<^sub>S (_))" [60, 0, 60] 60) where
    3.21 -  "f \<midarrow>a\<rightarrow>\<^sub>N\<^sub>S L =
    3.22 -    (\<forall>x. (x \<noteq> star_of a & x \<approx> star_of a --> ( *f* f) x \<approx> star_of L))"
    3.23 +definition NSLIM :: "('a::real_normed_vector \<Rightarrow> 'b::real_normed_vector) \<Rightarrow> 'a \<Rightarrow> 'b \<Rightarrow> bool"
    3.24 +    ("((_)/ \<midarrow>(_)/\<rightarrow>\<^sub>N\<^sub>S (_))" [60, 0, 60] 60)
    3.25 +  where "f \<midarrow>a\<rightarrow>\<^sub>N\<^sub>S L \<longleftrightarrow> (\<forall>x. x \<noteq> star_of a \<and> x \<approx> star_of a \<longrightarrow> ( *f* f) x \<approx> star_of L)"
    3.26  
    3.27 -definition
    3.28 -  isNSCont :: "['a::real_normed_vector => 'b::real_normed_vector, 'a] => bool" where
    3.29 -    \<comment>\<open>NS definition dispenses with limit notions\<close>
    3.30 -  "isNSCont f a = (\<forall>y. y \<approx> star_of a -->
    3.31 -         ( *f* f) y \<approx> star_of (f a))"
    3.32 +definition isNSCont :: "('a::real_normed_vector \<Rightarrow> 'b::real_normed_vector) \<Rightarrow> 'a \<Rightarrow> bool"
    3.33 +  where  \<comment> \<open>NS definition dispenses with limit notions\<close>
    3.34 +    "isNSCont f a \<longleftrightarrow> (\<forall>y. y \<approx> star_of a \<longrightarrow> ( *f* f) y \<approx> star_of (f a))"
    3.35  
    3.36 -definition
    3.37 -  isNSUCont :: "['a::real_normed_vector => 'b::real_normed_vector] => bool" where
    3.38 -  "isNSUCont f = (\<forall>x y. x \<approx> y --> ( *f* f) x \<approx> ( *f* f) y)"
    3.39 +definition isNSUCont :: "('a::real_normed_vector \<Rightarrow> 'b::real_normed_vector) \<Rightarrow> bool"
    3.40 +  where "isNSUCont f \<longleftrightarrow> (\<forall>x y. x \<approx> y \<longrightarrow> ( *f* f) x \<approx> ( *f* f) y)"
    3.41  
    3.42  
    3.43  subsection \<open>Limits of Functions\<close>
    3.44  
    3.45 -lemma NSLIM_I:
    3.46 -  "(\<And>x. \<lbrakk>x \<noteq> star_of a; x \<approx> star_of a\<rbrakk> \<Longrightarrow> starfun f x \<approx> star_of L)
    3.47 -   \<Longrightarrow> f \<midarrow>a\<rightarrow>\<^sub>N\<^sub>S L"
    3.48 -by (simp add: NSLIM_def)
    3.49 +lemma NSLIM_I: "(\<And>x. x \<noteq> star_of a \<Longrightarrow> x \<approx> star_of a \<Longrightarrow> starfun f x \<approx> star_of L) \<Longrightarrow> f \<midarrow>a\<rightarrow>\<^sub>N\<^sub>S L"
    3.50 +  by (simp add: NSLIM_def)
    3.51 +
    3.52 +lemma NSLIM_D: "f \<midarrow>a\<rightarrow>\<^sub>N\<^sub>S L \<Longrightarrow> x \<noteq> star_of a \<Longrightarrow> x \<approx> star_of a \<Longrightarrow> starfun f x \<approx> star_of L"
    3.53 +  by (simp add: NSLIM_def)
    3.54  
    3.55 -lemma NSLIM_D:
    3.56 -  "\<lbrakk>f \<midarrow>a\<rightarrow>\<^sub>N\<^sub>S L; x \<noteq> star_of a; x \<approx> star_of a\<rbrakk>
    3.57 -   \<Longrightarrow> starfun f x \<approx> star_of L"
    3.58 -by (simp add: NSLIM_def)
    3.59 +text \<open>Proving properties of limits using nonstandard definition.
    3.60 +  The properties hold for standard limits as well!\<close>
    3.61  
    3.62 -text\<open>Proving properties of limits using nonstandard definition.
    3.63 -      The properties hold for standard limits as well!\<close>
    3.64 -
    3.65 -lemma NSLIM_mult:
    3.66 -  fixes l m :: "'a::real_normed_algebra"
    3.67 -  shows "[| f \<midarrow>x\<rightarrow>\<^sub>N\<^sub>S l; g \<midarrow>x\<rightarrow>\<^sub>N\<^sub>S m |]
    3.68 -      ==> (%x. f(x) * g(x)) \<midarrow>x\<rightarrow>\<^sub>N\<^sub>S (l * m)"
    3.69 -by (auto simp add: NSLIM_def intro!: approx_mult_HFinite)
    3.70 +lemma NSLIM_mult: "f \<midarrow>x\<rightarrow>\<^sub>N\<^sub>S l \<Longrightarrow> g \<midarrow>x\<rightarrow>\<^sub>N\<^sub>S m \<Longrightarrow> (\<lambda>x. f x * g x) \<midarrow>x\<rightarrow>\<^sub>N\<^sub>S (l * m)"
    3.71 +  for l m :: "'a::real_normed_algebra"
    3.72 +  by (auto simp add: NSLIM_def intro!: approx_mult_HFinite)
    3.73  
    3.74 -lemma starfun_scaleR [simp]:
    3.75 -  "starfun (\<lambda>x. f x *\<^sub>R g x) = (\<lambda>x. scaleHR (starfun f x) (starfun g x))"
    3.76 -by transfer (rule refl)
    3.77 +lemma starfun_scaleR [simp]: "starfun (\<lambda>x. f x *\<^sub>R g x) = (\<lambda>x. scaleHR (starfun f x) (starfun g x))"
    3.78 +  by transfer (rule refl)
    3.79  
    3.80 -lemma NSLIM_scaleR:
    3.81 -  "[| f \<midarrow>x\<rightarrow>\<^sub>N\<^sub>S l; g \<midarrow>x\<rightarrow>\<^sub>N\<^sub>S m |]
    3.82 -      ==> (%x. f(x) *\<^sub>R g(x)) \<midarrow>x\<rightarrow>\<^sub>N\<^sub>S (l *\<^sub>R m)"
    3.83 -by (auto simp add: NSLIM_def intro!: approx_scaleR_HFinite)
    3.84 +lemma NSLIM_scaleR: "f \<midarrow>x\<rightarrow>\<^sub>N\<^sub>S l \<Longrightarrow> g \<midarrow>x\<rightarrow>\<^sub>N\<^sub>S m \<Longrightarrow> (\<lambda>x. f x *\<^sub>R g x) \<midarrow>x\<rightarrow>\<^sub>N\<^sub>S (l *\<^sub>R m)"
    3.85 +  by (auto simp add: NSLIM_def intro!: approx_scaleR_HFinite)
    3.86  
    3.87 -lemma NSLIM_add:
    3.88 -     "[| f \<midarrow>x\<rightarrow>\<^sub>N\<^sub>S l; g \<midarrow>x\<rightarrow>\<^sub>N\<^sub>S m |]
    3.89 -      ==> (%x. f(x) + g(x)) \<midarrow>x\<rightarrow>\<^sub>N\<^sub>S (l + m)"
    3.90 -by (auto simp add: NSLIM_def intro!: approx_add)
    3.91 +lemma NSLIM_add: "f \<midarrow>x\<rightarrow>\<^sub>N\<^sub>S l \<Longrightarrow> g \<midarrow>x\<rightarrow>\<^sub>N\<^sub>S m \<Longrightarrow> (\<lambda>x. f x + g x) \<midarrow>x\<rightarrow>\<^sub>N\<^sub>S (l + m)"
    3.92 +  by (auto simp add: NSLIM_def intro!: approx_add)
    3.93  
    3.94 -lemma NSLIM_const [simp]: "(%x. k) \<midarrow>x\<rightarrow>\<^sub>N\<^sub>S k"
    3.95 -by (simp add: NSLIM_def)
    3.96 +lemma NSLIM_const [simp]: "(\<lambda>x. k) \<midarrow>x\<rightarrow>\<^sub>N\<^sub>S k"
    3.97 +  by (simp add: NSLIM_def)
    3.98  
    3.99 -lemma NSLIM_minus: "f \<midarrow>a\<rightarrow>\<^sub>N\<^sub>S L ==> (%x. -f(x)) \<midarrow>a\<rightarrow>\<^sub>N\<^sub>S -L"
   3.100 -by (simp add: NSLIM_def)
   3.101 +lemma NSLIM_minus: "f \<midarrow>a\<rightarrow>\<^sub>N\<^sub>S L \<Longrightarrow> (\<lambda>x. - f x) \<midarrow>a\<rightarrow>\<^sub>N\<^sub>S -L"
   3.102 +  by (simp add: NSLIM_def)
   3.103  
   3.104 -lemma NSLIM_diff:
   3.105 -  "\<lbrakk>f \<midarrow>x\<rightarrow>\<^sub>N\<^sub>S l; g \<midarrow>x\<rightarrow>\<^sub>N\<^sub>S m\<rbrakk> \<Longrightarrow> (\<lambda>x. f x - g x) \<midarrow>x\<rightarrow>\<^sub>N\<^sub>S (l - m)"
   3.106 +lemma NSLIM_diff: "f \<midarrow>x\<rightarrow>\<^sub>N\<^sub>S l \<Longrightarrow> g \<midarrow>x\<rightarrow>\<^sub>N\<^sub>S m \<Longrightarrow> (\<lambda>x. f x - g x) \<midarrow>x\<rightarrow>\<^sub>N\<^sub>S (l - m)"
   3.107    by (simp only: NSLIM_add NSLIM_minus diff_conv_add_uminus)
   3.108  
   3.109 -lemma NSLIM_add_minus: "[| f \<midarrow>x\<rightarrow>\<^sub>N\<^sub>S l; g \<midarrow>x\<rightarrow>\<^sub>N\<^sub>S m |] ==> (%x. f(x) + -g(x)) \<midarrow>x\<rightarrow>\<^sub>N\<^sub>S (l + -m)"
   3.110 -by (simp only: NSLIM_add NSLIM_minus)
   3.111 +lemma NSLIM_add_minus: "f \<midarrow>x\<rightarrow>\<^sub>N\<^sub>S l \<Longrightarrow> g \<midarrow>x\<rightarrow>\<^sub>N\<^sub>S m \<Longrightarrow> (\<lambda>x. f x + - g x) \<midarrow>x\<rightarrow>\<^sub>N\<^sub>S (l + -m)"
   3.112 +  by (simp only: NSLIM_add NSLIM_minus)
   3.113  
   3.114 -lemma NSLIM_inverse:
   3.115 -  fixes L :: "'a::real_normed_div_algebra"
   3.116 -  shows "[| f \<midarrow>a\<rightarrow>\<^sub>N\<^sub>S L;  L \<noteq> 0 |]
   3.117 -      ==> (%x. inverse(f(x))) \<midarrow>a\<rightarrow>\<^sub>N\<^sub>S (inverse L)"
   3.118 -apply (simp add: NSLIM_def, clarify)
   3.119 -apply (drule spec)
   3.120 -apply (auto simp add: star_of_approx_inverse)
   3.121 -done
   3.122 +lemma NSLIM_inverse: "f \<midarrow>a\<rightarrow>\<^sub>N\<^sub>S L \<Longrightarrow> L \<noteq> 0 \<Longrightarrow> (\<lambda>x. inverse (f x)) \<midarrow>a\<rightarrow>\<^sub>N\<^sub>S (inverse L)"
   3.123 +  for L :: "'a::real_normed_div_algebra"
   3.124 +  apply (simp add: NSLIM_def, clarify)
   3.125 +  apply (drule spec)
   3.126 +  apply (auto simp add: star_of_approx_inverse)
   3.127 +  done
   3.128  
   3.129  lemma NSLIM_zero:
   3.130 -  assumes f: "f \<midarrow>a\<rightarrow>\<^sub>N\<^sub>S l" shows "(%x. f(x) - l) \<midarrow>a\<rightarrow>\<^sub>N\<^sub>S 0"
   3.131 +  assumes f: "f \<midarrow>a\<rightarrow>\<^sub>N\<^sub>S l"
   3.132 +  shows "(\<lambda>x. f(x) - l) \<midarrow>a\<rightarrow>\<^sub>N\<^sub>S 0"
   3.133  proof -
   3.134    have "(\<lambda>x. f x - l) \<midarrow>a\<rightarrow>\<^sub>N\<^sub>S l - l"
   3.135      by (rule NSLIM_diff [OF f NSLIM_const])
   3.136 -  thus ?thesis by simp
   3.137 +  then show ?thesis by simp
   3.138  qed
   3.139  
   3.140 -lemma NSLIM_zero_cancel: "(%x. f(x) - l) \<midarrow>x\<rightarrow>\<^sub>N\<^sub>S 0 ==> f \<midarrow>x\<rightarrow>\<^sub>N\<^sub>S l"
   3.141 -apply (drule_tac g = "%x. l" and m = l in NSLIM_add)
   3.142 -apply (auto simp add: add.assoc)
   3.143 -done
   3.144 +lemma NSLIM_zero_cancel: "(\<lambda>x. f x - l) \<midarrow>x\<rightarrow>\<^sub>N\<^sub>S 0 \<Longrightarrow> f \<midarrow>x\<rightarrow>\<^sub>N\<^sub>S l"
   3.145 +  apply (drule_tac g = "%x. l" and m = l in NSLIM_add)
   3.146 +   apply (auto simp add: add.assoc)
   3.147 +  done
   3.148  
   3.149 -lemma NSLIM_const_not_eq:
   3.150 -  fixes a :: "'a::real_normed_algebra_1"
   3.151 -  shows "k \<noteq> L \<Longrightarrow> \<not> (\<lambda>x. k) \<midarrow>a\<rightarrow>\<^sub>N\<^sub>S L"
   3.152 -apply (simp add: NSLIM_def)
   3.153 -apply (rule_tac x="star_of a + of_hypreal \<epsilon>" in exI)
   3.154 -apply (simp add: hypreal_epsilon_not_zero approx_def)
   3.155 -done
   3.156 +lemma NSLIM_const_not_eq: "k \<noteq> L \<Longrightarrow> \<not> (\<lambda>x. k) \<midarrow>a\<rightarrow>\<^sub>N\<^sub>S L"
   3.157 +  for a :: "'a::real_normed_algebra_1"
   3.158 +  apply (simp add: NSLIM_def)
   3.159 +  apply (rule_tac x="star_of a + of_hypreal \<epsilon>" in exI)
   3.160 +  apply (simp add: hypreal_epsilon_not_zero approx_def)
   3.161 +  done
   3.162  
   3.163 -lemma NSLIM_not_zero:
   3.164 -  fixes a :: "'a::real_normed_algebra_1"
   3.165 -  shows "k \<noteq> 0 \<Longrightarrow> \<not> (\<lambda>x. k) \<midarrow>a\<rightarrow>\<^sub>N\<^sub>S 0"
   3.166 -by (rule NSLIM_const_not_eq)
   3.167 +lemma NSLIM_not_zero: "k \<noteq> 0 \<Longrightarrow> \<not> (\<lambda>x. k) \<midarrow>a\<rightarrow>\<^sub>N\<^sub>S 0"
   3.168 +  for a :: "'a::real_normed_algebra_1"
   3.169 +  by (rule NSLIM_const_not_eq)
   3.170  
   3.171 -lemma NSLIM_const_eq:
   3.172 -  fixes a :: "'a::real_normed_algebra_1"
   3.173 -  shows "(\<lambda>x. k) \<midarrow>a\<rightarrow>\<^sub>N\<^sub>S L \<Longrightarrow> k = L"
   3.174 -apply (rule ccontr)
   3.175 -apply (blast dest: NSLIM_const_not_eq)
   3.176 -done
   3.177 +lemma NSLIM_const_eq: "(\<lambda>x. k) \<midarrow>a\<rightarrow>\<^sub>N\<^sub>S L \<Longrightarrow> k = L"
   3.178 +  for a :: "'a::real_normed_algebra_1"
   3.179 +  by (rule ccontr) (blast dest: NSLIM_const_not_eq)
   3.180 +
   3.181 +lemma NSLIM_unique: "f \<midarrow>a\<rightarrow>\<^sub>N\<^sub>S L \<Longrightarrow> f \<midarrow>a\<rightarrow>\<^sub>N\<^sub>S M \<Longrightarrow> L = M"
   3.182 +  for a :: "'a::real_normed_algebra_1"
   3.183 +  by (drule (1) NSLIM_diff) (auto dest!: NSLIM_const_eq)
   3.184  
   3.185 -lemma NSLIM_unique:
   3.186 -  fixes a :: "'a::real_normed_algebra_1"
   3.187 -  shows "\<lbrakk>f \<midarrow>a\<rightarrow>\<^sub>N\<^sub>S L; f \<midarrow>a\<rightarrow>\<^sub>N\<^sub>S M\<rbrakk> \<Longrightarrow> L = M"
   3.188 -apply (drule (1) NSLIM_diff)
   3.189 -apply (auto dest!: NSLIM_const_eq)
   3.190 -done
   3.191 +lemma NSLIM_mult_zero: "f \<midarrow>x\<rightarrow>\<^sub>N\<^sub>S 0 \<Longrightarrow> g \<midarrow>x\<rightarrow>\<^sub>N\<^sub>S 0 \<Longrightarrow> (\<lambda>x. f x * g x) \<midarrow>x\<rightarrow>\<^sub>N\<^sub>S 0"
   3.192 +  for f g :: "'a::real_normed_vector \<Rightarrow> 'b::real_normed_algebra"
   3.193 +  by (drule NSLIM_mult) auto
   3.194  
   3.195 -lemma NSLIM_mult_zero:
   3.196 -  fixes f g :: "'a::real_normed_vector \<Rightarrow> 'b::real_normed_algebra"
   3.197 -  shows "[| f \<midarrow>x\<rightarrow>\<^sub>N\<^sub>S 0; g \<midarrow>x\<rightarrow>\<^sub>N\<^sub>S 0 |] ==> (%x. f(x)*g(x)) \<midarrow>x\<rightarrow>\<^sub>N\<^sub>S 0"
   3.198 -by (drule NSLIM_mult, auto)
   3.199 +lemma NSLIM_self: "(\<lambda>x. x) \<midarrow>a\<rightarrow>\<^sub>N\<^sub>S a"
   3.200 +  by (simp add: NSLIM_def)
   3.201  
   3.202 -lemma NSLIM_self: "(%x. x) \<midarrow>a\<rightarrow>\<^sub>N\<^sub>S a"
   3.203 -by (simp add: NSLIM_def)
   3.204  
   3.205  subsubsection \<open>Equivalence of @{term filterlim} and @{term NSLIM}\<close>
   3.206  
   3.207  lemma LIM_NSLIM:
   3.208 -  assumes f: "f \<midarrow>a\<rightarrow> L" shows "f \<midarrow>a\<rightarrow>\<^sub>N\<^sub>S L"
   3.209 +  assumes f: "f \<midarrow>a\<rightarrow> L"
   3.210 +  shows "f \<midarrow>a\<rightarrow>\<^sub>N\<^sub>S L"
   3.211  proof (rule NSLIM_I)
   3.212    fix x
   3.213    assume neq: "x \<noteq> star_of a"
   3.214    assume approx: "x \<approx> star_of a"
   3.215    have "starfun f x - star_of L \<in> Infinitesimal"
   3.216    proof (rule InfinitesimalI2)
   3.217 -    fix r::real assume r: "0 < r"
   3.218 -    from LIM_D [OF f r]
   3.219 -    obtain s where s: "0 < s" and
   3.220 -      less_r: "\<And>x. \<lbrakk>x \<noteq> a; norm (x - a) < s\<rbrakk> \<Longrightarrow> norm (f x - L) < r"
   3.221 +    fix r :: real
   3.222 +    assume r: "0 < r"
   3.223 +    from LIM_D [OF f r] obtain s
   3.224 +      where s: "0 < s" and less_r: "\<And>x. x \<noteq> a \<Longrightarrow> norm (x - a) < s \<Longrightarrow> norm (f x - L) < r"
   3.225        by fast
   3.226      from less_r have less_r':
   3.227 -       "\<And>x. \<lbrakk>x \<noteq> star_of a; hnorm (x - star_of a) < star_of s\<rbrakk>
   3.228 -        \<Longrightarrow> hnorm (starfun f x - star_of L) < star_of r"
   3.229 +      "\<And>x. x \<noteq> star_of a \<Longrightarrow> hnorm (x - star_of a) < star_of s \<Longrightarrow>
   3.230 +        hnorm (starfun f x - star_of L) < star_of r"
   3.231        by transfer
   3.232      from approx have "x - star_of a \<in> Infinitesimal"
   3.233 -      by (unfold approx_def)
   3.234 -    hence "hnorm (x - star_of a) < star_of s"
   3.235 +      by (simp only: approx_def)
   3.236 +    then have "hnorm (x - star_of a) < star_of s"
   3.237        using s by (rule InfinitesimalD2)
   3.238      with neq show "hnorm (starfun f x - star_of L) < star_of r"
   3.239        by (rule less_r')
   3.240    qed
   3.241 -  thus "starfun f x \<approx> star_of L"
   3.242 +  then show "starfun f x \<approx> star_of L"
   3.243      by (unfold approx_def)
   3.244  qed
   3.245  
   3.246  lemma NSLIM_LIM:
   3.247 -  assumes f: "f \<midarrow>a\<rightarrow>\<^sub>N\<^sub>S L" shows "f \<midarrow>a\<rightarrow> L"
   3.248 +  assumes f: "f \<midarrow>a\<rightarrow>\<^sub>N\<^sub>S L"
   3.249 +  shows "f \<midarrow>a\<rightarrow> L"
   3.250  proof (rule LIM_I)
   3.251 -  fix r::real assume r: "0 < r"
   3.252 -  have "\<exists>s>0. \<forall>x. x \<noteq> star_of a \<and> hnorm (x - star_of a) < s
   3.253 -        \<longrightarrow> hnorm (starfun f x - star_of L) < star_of r"
   3.254 +  fix r :: real
   3.255 +  assume r: "0 < r"
   3.256 +  have "\<exists>s>0. \<forall>x. x \<noteq> star_of a \<and> hnorm (x - star_of a) < s \<longrightarrow>
   3.257 +    hnorm (starfun f x - star_of L) < star_of r"
   3.258    proof (rule exI, safe)
   3.259 -    show "0 < \<epsilon>" by (rule hypreal_epsilon_gt_zero)
   3.260 +    show "0 < \<epsilon>"
   3.261 +      by (rule hypreal_epsilon_gt_zero)
   3.262    next
   3.263 -    fix x assume neq: "x \<noteq> star_of a"
   3.264 +    fix x
   3.265 +    assume neq: "x \<noteq> star_of a"
   3.266      assume "hnorm (x - star_of a) < \<epsilon>"
   3.267 -    with Infinitesimal_epsilon
   3.268 -    have "x - star_of a \<in> Infinitesimal"
   3.269 +    with Infinitesimal_epsilon have "x - star_of a \<in> Infinitesimal"
   3.270        by (rule hnorm_less_Infinitesimal)
   3.271 -    hence "x \<approx> star_of a"
   3.272 +    then have "x \<approx> star_of a"
   3.273        by (unfold approx_def)
   3.274      with f neq have "starfun f x \<approx> star_of L"
   3.275        by (rule NSLIM_D)
   3.276 -    hence "starfun f x - star_of L \<in> Infinitesimal"
   3.277 +    then have "starfun f x - star_of L \<in> Infinitesimal"
   3.278        by (unfold approx_def)
   3.279 -    thus "hnorm (starfun f x - star_of L) < star_of r"
   3.280 +    then show "hnorm (starfun f x - star_of L) < star_of r"
   3.281        using r by (rule InfinitesimalD2)
   3.282    qed
   3.283 -  thus "\<exists>s>0. \<forall>x. x \<noteq> a \<and> norm (x - a) < s \<longrightarrow> norm (f x - L) < r"
   3.284 +  then show "\<exists>s>0. \<forall>x. x \<noteq> a \<and> norm (x - a) < s \<longrightarrow> norm (f x - L) < r"
   3.285      by transfer
   3.286  qed
   3.287  
   3.288 -theorem LIM_NSLIM_iff: "(f \<midarrow>x\<rightarrow> L) = (f \<midarrow>x\<rightarrow>\<^sub>N\<^sub>S L)"
   3.289 -by (blast intro: LIM_NSLIM NSLIM_LIM)
   3.290 +theorem LIM_NSLIM_iff: "f \<midarrow>x\<rightarrow> L \<longleftrightarrow> f \<midarrow>x\<rightarrow>\<^sub>N\<^sub>S L"
   3.291 +  by (blast intro: LIM_NSLIM NSLIM_LIM)
   3.292  
   3.293  
   3.294  subsection \<open>Continuity\<close>
   3.295  
   3.296 -lemma isNSContD:
   3.297 -  "\<lbrakk>isNSCont f a; y \<approx> star_of a\<rbrakk> \<Longrightarrow> ( *f* f) y \<approx> star_of (f a)"
   3.298 -by (simp add: isNSCont_def)
   3.299 +lemma isNSContD: "isNSCont f a \<Longrightarrow> y \<approx> star_of a \<Longrightarrow> ( *f* f) y \<approx> star_of (f a)"
   3.300 +  by (simp add: isNSCont_def)
   3.301 +
   3.302 +lemma isNSCont_NSLIM: "isNSCont f a \<Longrightarrow> f \<midarrow>a\<rightarrow>\<^sub>N\<^sub>S (f a)"
   3.303 +  by (simp add: isNSCont_def NSLIM_def)
   3.304  
   3.305 -lemma isNSCont_NSLIM: "isNSCont f a ==> f \<midarrow>a\<rightarrow>\<^sub>N\<^sub>S (f a) "
   3.306 -by (simp add: isNSCont_def NSLIM_def)
   3.307 +lemma NSLIM_isNSCont: "f \<midarrow>a\<rightarrow>\<^sub>N\<^sub>S (f a) \<Longrightarrow> isNSCont f a"
   3.308 +  apply (auto simp add: isNSCont_def NSLIM_def)
   3.309 +  apply (case_tac "y = star_of a")
   3.310 +   apply auto
   3.311 +  done
   3.312  
   3.313 -lemma NSLIM_isNSCont: "f \<midarrow>a\<rightarrow>\<^sub>N\<^sub>S (f a) ==> isNSCont f a"
   3.314 -apply (simp add: isNSCont_def NSLIM_def, auto)
   3.315 -apply (case_tac "y = star_of a", auto)
   3.316 -done
   3.317 +text \<open>NS continuity can be defined using NS Limit in
   3.318 +  similar fashion to standard definition of continuity.\<close>
   3.319 +lemma isNSCont_NSLIM_iff: "isNSCont f a \<longleftrightarrow> f \<midarrow>a\<rightarrow>\<^sub>N\<^sub>S (f a)"
   3.320 +  by (blast intro: isNSCont_NSLIM NSLIM_isNSCont)
   3.321  
   3.322 -text\<open>NS continuity can be defined using NS Limit in
   3.323 -    similar fashion to standard definition of continuity\<close>
   3.324 -lemma isNSCont_NSLIM_iff: "(isNSCont f a) = (f \<midarrow>a\<rightarrow>\<^sub>N\<^sub>S (f a))"
   3.325 -by (blast intro: isNSCont_NSLIM NSLIM_isNSCont)
   3.326 +text \<open>Hence, NS continuity can be given in terms of standard limit.\<close>
   3.327 +lemma isNSCont_LIM_iff: "(isNSCont f a) = (f \<midarrow>a\<rightarrow> (f a))"
   3.328 +  by (simp add: LIM_NSLIM_iff isNSCont_NSLIM_iff)
   3.329  
   3.330 -text\<open>Hence, NS continuity can be given
   3.331 -  in terms of standard limit\<close>
   3.332 -lemma isNSCont_LIM_iff: "(isNSCont f a) = (f \<midarrow>a\<rightarrow> (f a))"
   3.333 -by (simp add: LIM_NSLIM_iff isNSCont_NSLIM_iff)
   3.334 +text \<open>Moreover, it's trivial now that NS continuity
   3.335 +  is equivalent to standard continuity.\<close>
   3.336 +lemma isNSCont_isCont_iff: "isNSCont f a \<longleftrightarrow> isCont f a"
   3.337 +  by (simp add: isCont_def) (rule isNSCont_LIM_iff)
   3.338  
   3.339 -text\<open>Moreover, it's trivial now that NS continuity
   3.340 -  is equivalent to standard continuity\<close>
   3.341 -lemma isNSCont_isCont_iff: "(isNSCont f a) = (isCont f a)"
   3.342 -apply (simp add: isCont_def)
   3.343 -apply (rule isNSCont_LIM_iff)
   3.344 -done
   3.345 +text \<open>Standard continuity \<open>\<Longrightarrow>\<close> NS continuity.\<close>
   3.346 +lemma isCont_isNSCont: "isCont f a \<Longrightarrow> isNSCont f a"
   3.347 +  by (erule isNSCont_isCont_iff [THEN iffD2])
   3.348  
   3.349 -text\<open>Standard continuity ==> NS continuity\<close>
   3.350 -lemma isCont_isNSCont: "isCont f a ==> isNSCont f a"
   3.351 -by (erule isNSCont_isCont_iff [THEN iffD2])
   3.352 +text \<open>NS continuity \<open>==>\<close> Standard continuity.\<close>
   3.353 +lemma isNSCont_isCont: "isNSCont f a ==> isCont f a"
   3.354 +  by (erule isNSCont_isCont_iff [THEN iffD1])
   3.355  
   3.356 -text\<open>NS continuity ==> Standard continuity\<close>
   3.357 -lemma isNSCont_isCont: "isNSCont f a ==> isCont f a"
   3.358 -by (erule isNSCont_isCont_iff [THEN iffD1])
   3.359 +
   3.360 +text \<open>Alternative definition of continuity.\<close>
   3.361  
   3.362 -text\<open>Alternative definition of continuity\<close>
   3.363 +text \<open>Prove equivalence between NS limits --
   3.364 +  seems easier than using standard definition.\<close>
   3.365 +lemma NSLIM_h_iff: "f \<midarrow>a\<rightarrow>\<^sub>N\<^sub>S L \<longleftrightarrow> (\<lambda>h. f (a + h)) \<midarrow>0\<rightarrow>\<^sub>N\<^sub>S L"
   3.366 +  apply (simp add: NSLIM_def, auto)
   3.367 +   apply (drule_tac x = "star_of a + x" in spec)
   3.368 +   apply (drule_tac [2] x = "- star_of a + x" in spec, safe, simp)
   3.369 +      apply (erule mem_infmal_iff [THEN iffD2, THEN Infinitesimal_add_approx_self [THEN approx_sym]])
   3.370 +     apply (erule_tac [3] approx_minus_iff2 [THEN iffD1])
   3.371 +    prefer 2 apply (simp add: add.commute)
   3.372 +   apply (rule_tac x = x in star_cases)
   3.373 +   apply (rule_tac [2] x = x in star_cases)
   3.374 +   apply (auto simp add: starfun star_of_def star_n_minus star_n_add add.assoc star_n_zero_num)
   3.375 +  done
   3.376  
   3.377 -(* Prove equivalence between NS limits - *)
   3.378 -(* seems easier than using standard definition  *)
   3.379 -lemma NSLIM_h_iff: "(f \<midarrow>a\<rightarrow>\<^sub>N\<^sub>S L) = ((%h. f(a + h)) \<midarrow>0\<rightarrow>\<^sub>N\<^sub>S L)"
   3.380 -apply (simp add: NSLIM_def, auto)
   3.381 -apply (drule_tac x = "star_of a + x" in spec)
   3.382 -apply (drule_tac [2] x = "- star_of a + x" in spec, safe, simp)
   3.383 -apply (erule mem_infmal_iff [THEN iffD2, THEN Infinitesimal_add_approx_self [THEN approx_sym]])
   3.384 -apply (erule_tac [3] approx_minus_iff2 [THEN iffD1])
   3.385 - prefer 2 apply (simp add: add.commute)
   3.386 -apply (rule_tac x = x in star_cases)
   3.387 -apply (rule_tac [2] x = x in star_cases)
   3.388 -apply (auto simp add: starfun star_of_def star_n_minus star_n_add add.assoc star_n_zero_num)
   3.389 -done
   3.390 -
   3.391 -lemma NSLIM_isCont_iff: "(f \<midarrow>a\<rightarrow>\<^sub>N\<^sub>S f a) = ((%h. f(a + h)) \<midarrow>0\<rightarrow>\<^sub>N\<^sub>S f a)"
   3.392 +lemma NSLIM_isCont_iff: "f \<midarrow>a\<rightarrow>\<^sub>N\<^sub>S f a \<longleftrightarrow> (\<lambda>h. f (a + h)) \<midarrow>0\<rightarrow>\<^sub>N\<^sub>S f a"
   3.393    by (fact NSLIM_h_iff)
   3.394  
   3.395 -lemma isNSCont_minus: "isNSCont f a ==> isNSCont (%x. - f x) a"
   3.396 -by (simp add: isNSCont_def)
   3.397 +lemma isNSCont_minus: "isNSCont f a \<Longrightarrow> isNSCont (\<lambda>x. - f x) a"
   3.398 +  by (simp add: isNSCont_def)
   3.399  
   3.400 -lemma isNSCont_inverse:
   3.401 -  fixes f :: "'a::real_normed_vector \<Rightarrow> 'b::real_normed_div_algebra"
   3.402 -  shows "[| isNSCont f x; f x \<noteq> 0 |] ==> isNSCont (%x. inverse (f x)) x"
   3.403 -by (auto intro: isCont_inverse simp add: isNSCont_isCont_iff)
   3.404 +lemma isNSCont_inverse: "isNSCont f x \<Longrightarrow> f x \<noteq> 0 \<Longrightarrow> isNSCont (\<lambda>x. inverse (f x)) x"
   3.405 +  for f :: "'a::real_normed_vector \<Rightarrow> 'b::real_normed_div_algebra"
   3.406 +  by (auto intro: isCont_inverse simp add: isNSCont_isCont_iff)
   3.407  
   3.408 -lemma isNSCont_const [simp]: "isNSCont (%x. k) a"
   3.409 -by (simp add: isNSCont_def)
   3.410 +lemma isNSCont_const [simp]: "isNSCont (\<lambda>x. k) a"
   3.411 +  by (simp add: isNSCont_def)
   3.412  
   3.413 -lemma isNSCont_abs [simp]: "isNSCont abs (a::real)"
   3.414 -apply (simp add: isNSCont_def)
   3.415 -apply (auto intro: approx_hrabs simp add: starfun_rabs_hrabs)
   3.416 -done
   3.417 +lemma isNSCont_abs [simp]: "isNSCont abs a"
   3.418 +  for a :: real
   3.419 +  by (auto simp: isNSCont_def intro: approx_hrabs simp: starfun_rabs_hrabs)
   3.420  
   3.421  
   3.422  subsection \<open>Uniform Continuity\<close>
   3.423  
   3.424 -lemma isNSUContD: "[| isNSUCont f; x \<approx> y|] ==> ( *f* f) x \<approx> ( *f* f) y"
   3.425 -by (simp add: isNSUCont_def)
   3.426 +lemma isNSUContD: "isNSUCont f \<Longrightarrow> x \<approx> y \<Longrightarrow> ( *f* f) x \<approx> ( *f* f) y"
   3.427 +  by (simp add: isNSUCont_def)
   3.428  
   3.429  lemma isUCont_isNSUCont:
   3.430    fixes f :: "'a::real_normed_vector \<Rightarrow> 'b::real_normed_vector"
   3.431 -  assumes f: "isUCont f" shows "isNSUCont f"
   3.432 -proof (unfold isNSUCont_def, safe)
   3.433 +  assumes f: "isUCont f"
   3.434 +  shows "isNSUCont f"
   3.435 +  unfolding isNSUCont_def
   3.436 +proof safe
   3.437    fix x y :: "'a star"
   3.438    assume approx: "x \<approx> y"
   3.439    have "starfun f x - starfun f y \<in> Infinitesimal"
   3.440    proof (rule InfinitesimalI2)
   3.441 -    fix r::real assume r: "0 < r"
   3.442 -    with f obtain s where s: "0 < s" and
   3.443 -      less_r: "\<And>x y. norm (x - y) < s \<Longrightarrow> norm (f x - f y) < r"
   3.444 +    fix r :: real
   3.445 +    assume r: "0 < r"
   3.446 +    with f obtain s where s: "0 < s"
   3.447 +      and less_r: "\<And>x y. norm (x - y) < s \<Longrightarrow> norm (f x - f y) < r"
   3.448        by (auto simp add: isUCont_def dist_norm)
   3.449      from less_r have less_r':
   3.450 -       "\<And>x y. hnorm (x - y) < star_of s
   3.451 -        \<Longrightarrow> hnorm (starfun f x - starfun f y) < star_of r"
   3.452 +      "\<And>x y. hnorm (x - y) < star_of s \<Longrightarrow> hnorm (starfun f x - starfun f y) < star_of r"
   3.453        by transfer
   3.454      from approx have "x - y \<in> Infinitesimal"
   3.455        by (unfold approx_def)
   3.456 -    hence "hnorm (x - y) < star_of s"
   3.457 +    then have "hnorm (x - y) < star_of s"
   3.458        using s by (rule InfinitesimalD2)
   3.459 -    thus "hnorm (starfun f x - starfun f y) < star_of r"
   3.460 +    then show "hnorm (starfun f x - starfun f y) < star_of r"
   3.461        by (rule less_r')
   3.462    qed
   3.463 -  thus "starfun f x \<approx> starfun f y"
   3.464 +  then show "starfun f x \<approx> starfun f y"
   3.465      by (unfold approx_def)
   3.466  qed
   3.467  
   3.468  lemma isNSUCont_isUCont:
   3.469    fixes f :: "'a::real_normed_vector \<Rightarrow> 'b::real_normed_vector"
   3.470 -  assumes f: "isNSUCont f" shows "isUCont f"
   3.471 -proof (unfold isUCont_def dist_norm, safe)
   3.472 -  fix r::real assume r: "0 < r"
   3.473 -  have "\<exists>s>0. \<forall>x y. hnorm (x - y) < s
   3.474 -        \<longrightarrow> hnorm (starfun f x - starfun f y) < star_of r"
   3.475 +  assumes f: "isNSUCont f"
   3.476 +  shows "isUCont f"
   3.477 +  unfolding isUCont_def dist_norm
   3.478 +proof safe
   3.479 +  fix r :: real
   3.480 +  assume r: "0 < r"
   3.481 +  have "\<exists>s>0. \<forall>x y. hnorm (x - y) < s \<longrightarrow> hnorm (starfun f x - starfun f y) < star_of r"
   3.482    proof (rule exI, safe)
   3.483 -    show "0 < \<epsilon>" by (rule hypreal_epsilon_gt_zero)
   3.484 +    show "0 < \<epsilon>"
   3.485 +      by (rule hypreal_epsilon_gt_zero)
   3.486    next
   3.487      fix x y :: "'a star"
   3.488      assume "hnorm (x - y) < \<epsilon>"
   3.489 -    with Infinitesimal_epsilon
   3.490 -    have "x - y \<in> Infinitesimal"
   3.491 +    with Infinitesimal_epsilon have "x - y \<in> Infinitesimal"
   3.492        by (rule hnorm_less_Infinitesimal)
   3.493 -    hence "x \<approx> y"
   3.494 +    then have "x \<approx> y"
   3.495        by (unfold approx_def)
   3.496      with f have "starfun f x \<approx> starfun f y"
   3.497        by (simp add: isNSUCont_def)
   3.498 -    hence "starfun f x - starfun f y \<in> Infinitesimal"
   3.499 +    then have "starfun f x - starfun f y \<in> Infinitesimal"
   3.500        by (unfold approx_def)
   3.501 -    thus "hnorm (starfun f x - starfun f y) < star_of r"
   3.502 +    then show "hnorm (starfun f x - starfun f y) < star_of r"
   3.503        using r by (rule InfinitesimalD2)
   3.504    qed
   3.505 -  thus "\<exists>s>0. \<forall>x y. norm (x - y) < s \<longrightarrow> norm (f x - f y) < r"
   3.506 +  then show "\<exists>s>0. \<forall>x y. norm (x - y) < s \<longrightarrow> norm (f x - f y) < r"
   3.507      by transfer
   3.508  qed
   3.509  
     4.1 --- a/src/HOL/Nonstandard_Analysis/HyperDef.thy	Mon Oct 31 16:26:36 2016 +0100
     4.2 +++ b/src/HOL/Nonstandard_Analysis/HyperDef.thy	Tue Nov 01 00:44:24 2016 +0100
     4.3 @@ -4,50 +4,42 @@
     4.4      Conversion to Isar and new proofs by Lawrence C Paulson, 2004
     4.5  *)
     4.6  
     4.7 -section\<open>Construction of Hyperreals Using Ultrafilters\<close>
     4.8 +section \<open>Construction of Hyperreals Using Ultrafilters\<close>
     4.9  
    4.10  theory HyperDef
    4.11 -imports Complex_Main HyperNat
    4.12 +  imports Complex_Main HyperNat
    4.13  begin
    4.14  
    4.15  type_synonym hypreal = "real star"
    4.16  
    4.17 -abbreviation
    4.18 -  hypreal_of_real :: "real => real star" where
    4.19 -  "hypreal_of_real == star_of"
    4.20 +abbreviation hypreal_of_real :: "real \<Rightarrow> real star"
    4.21 +  where "hypreal_of_real \<equiv> star_of"
    4.22  
    4.23 -abbreviation
    4.24 -  hypreal_of_hypnat :: "hypnat \<Rightarrow> hypreal" where
    4.25 -  "hypreal_of_hypnat \<equiv> of_hypnat"
    4.26 +abbreviation hypreal_of_hypnat :: "hypnat \<Rightarrow> hypreal"
    4.27 +  where "hypreal_of_hypnat \<equiv> of_hypnat"
    4.28  
    4.29 -definition
    4.30 -  omega :: hypreal  ("\<omega>") where
    4.31 -   \<comment> \<open>an infinite number \<open>= [<1,2,3,...>]\<close>\<close>
    4.32 -  "\<omega> = star_n (\<lambda>n. real (Suc n))"
    4.33 +definition omega :: hypreal  ("\<omega>")
    4.34 +  where "\<omega> = star_n (\<lambda>n. real (Suc n))"
    4.35 +    \<comment> \<open>an infinite number \<open>= [<1, 2, 3, \<dots>>]\<close>\<close>
    4.36  
    4.37 -definition
    4.38 -  epsilon :: hypreal  ("\<epsilon>") where
    4.39 -   \<comment> \<open>an infinitesimal number \<open>= [<1,1/2,1/3,...>]\<close>\<close>
    4.40 -  "\<epsilon> = star_n (\<lambda>n. inverse (real (Suc n)))"
    4.41 +definition epsilon :: hypreal  ("\<epsilon>")
    4.42 +  where "\<epsilon> = star_n (\<lambda>n. inverse (real (Suc n)))"
    4.43 +    \<comment> \<open>an infinitesimal number \<open>= [<1, 1/2, 1/3, \<dots>>]\<close>\<close>
    4.44  
    4.45  
    4.46  subsection \<open>Real vector class instances\<close>
    4.47  
    4.48  instantiation star :: (scaleR) scaleR
    4.49  begin
    4.50 -
    4.51 -definition
    4.52 -  star_scaleR_def [transfer_unfold]: "scaleR r \<equiv> *f* (scaleR r)"
    4.53 -
    4.54 -instance ..
    4.55 -
    4.56 +  definition star_scaleR_def [transfer_unfold]: "scaleR r \<equiv> *f* (scaleR r)"
    4.57 +  instance ..
    4.58  end
    4.59  
    4.60  lemma Standard_scaleR [simp]: "x \<in> Standard \<Longrightarrow> scaleR r x \<in> Standard"
    4.61 -by (simp add: star_scaleR_def)
    4.62 +  by (simp add: star_scaleR_def)
    4.63  
    4.64  lemma star_of_scaleR [simp]: "star_of (scaleR r x) = scaleR r (star_of x)"
    4.65 -by transfer (rule refl)
    4.66 +  by transfer (rule refl)
    4.67  
    4.68  instance star :: (real_vector) real_vector
    4.69  proof
    4.70 @@ -80,230 +72,213 @@
    4.71  instance star :: (real_field) real_field ..
    4.72  
    4.73  lemma star_of_real_def [transfer_unfold]: "of_real r = star_of (of_real r)"
    4.74 -by (unfold of_real_def, transfer, rule refl)
    4.75 +  by (unfold of_real_def, transfer, rule refl)
    4.76  
    4.77  lemma Standard_of_real [simp]: "of_real r \<in> Standard"
    4.78 -by (simp add: star_of_real_def)
    4.79 +  by (simp add: star_of_real_def)
    4.80  
    4.81  lemma star_of_of_real [simp]: "star_of (of_real r) = of_real r"
    4.82 -by transfer (rule refl)
    4.83 +  by transfer (rule refl)
    4.84  
    4.85  lemma of_real_eq_star_of [simp]: "of_real = star_of"
    4.86  proof
    4.87 -  fix r :: real
    4.88 -  show "of_real r = star_of r"
    4.89 +  show "of_real r = star_of r" for r :: real
    4.90      by transfer simp
    4.91  qed
    4.92  
    4.93  lemma Reals_eq_Standard: "(\<real> :: hypreal set) = Standard"
    4.94 -by (simp add: Reals_def Standard_def)
    4.95 +  by (simp add: Reals_def Standard_def)
    4.96  
    4.97  
    4.98  subsection \<open>Injection from @{typ hypreal}\<close>
    4.99  
   4.100 -definition
   4.101 -  of_hypreal :: "hypreal \<Rightarrow> 'a::real_algebra_1 star" where
   4.102 -  [transfer_unfold]: "of_hypreal = *f* of_real"
   4.103 +definition of_hypreal :: "hypreal \<Rightarrow> 'a::real_algebra_1 star"
   4.104 +  where [transfer_unfold]: "of_hypreal = *f* of_real"
   4.105  
   4.106 -lemma Standard_of_hypreal [simp]:
   4.107 -  "r \<in> Standard \<Longrightarrow> of_hypreal r \<in> Standard"
   4.108 -by (simp add: of_hypreal_def)
   4.109 +lemma Standard_of_hypreal [simp]: "r \<in> Standard \<Longrightarrow> of_hypreal r \<in> Standard"
   4.110 +  by (simp add: of_hypreal_def)
   4.111  
   4.112  lemma of_hypreal_0 [simp]: "of_hypreal 0 = 0"
   4.113 -by transfer (rule of_real_0)
   4.114 +  by transfer (rule of_real_0)
   4.115  
   4.116  lemma of_hypreal_1 [simp]: "of_hypreal 1 = 1"
   4.117 -by transfer (rule of_real_1)
   4.118 +  by transfer (rule of_real_1)
   4.119  
   4.120 -lemma of_hypreal_add [simp]:
   4.121 -  "\<And>x y. of_hypreal (x + y) = of_hypreal x + of_hypreal y"
   4.122 -by transfer (rule of_real_add)
   4.123 +lemma of_hypreal_add [simp]: "\<And>x y. of_hypreal (x + y) = of_hypreal x + of_hypreal y"
   4.124 +  by transfer (rule of_real_add)
   4.125  
   4.126  lemma of_hypreal_minus [simp]: "\<And>x. of_hypreal (- x) = - of_hypreal x"
   4.127 -by transfer (rule of_real_minus)
   4.128 +  by transfer (rule of_real_minus)
   4.129  
   4.130 -lemma of_hypreal_diff [simp]:
   4.131 -  "\<And>x y. of_hypreal (x - y) = of_hypreal x - of_hypreal y"
   4.132 -by transfer (rule of_real_diff)
   4.133 +lemma of_hypreal_diff [simp]: "\<And>x y. of_hypreal (x - y) = of_hypreal x - of_hypreal y"
   4.134 +  by transfer (rule of_real_diff)
   4.135  
   4.136 -lemma of_hypreal_mult [simp]:
   4.137 -  "\<And>x y. of_hypreal (x * y) = of_hypreal x * of_hypreal y"
   4.138 -by transfer (rule of_real_mult)
   4.139 +lemma of_hypreal_mult [simp]: "\<And>x y. of_hypreal (x * y) = of_hypreal x * of_hypreal y"
   4.140 +  by transfer (rule of_real_mult)
   4.141  
   4.142  lemma of_hypreal_inverse [simp]:
   4.143    "\<And>x. of_hypreal (inverse x) =
   4.144 -   inverse (of_hypreal x :: 'a::{real_div_algebra, division_ring} star)"
   4.145 -by transfer (rule of_real_inverse)
   4.146 +    inverse (of_hypreal x :: 'a::{real_div_algebra, division_ring} star)"
   4.147 +  by transfer (rule of_real_inverse)
   4.148  
   4.149  lemma of_hypreal_divide [simp]:
   4.150    "\<And>x y. of_hypreal (x / y) =
   4.151 -   (of_hypreal x / of_hypreal y :: 'a::{real_field, field} star)"
   4.152 -by transfer (rule of_real_divide)
   4.153 +    (of_hypreal x / of_hypreal y :: 'a::{real_field, field} star)"
   4.154 +  by transfer (rule of_real_divide)
   4.155  
   4.156 -lemma of_hypreal_eq_iff [simp]:
   4.157 -  "\<And>x y. (of_hypreal x = of_hypreal y) = (x = y)"
   4.158 -by transfer (rule of_real_eq_iff)
   4.159 +lemma of_hypreal_eq_iff [simp]: "\<And>x y. (of_hypreal x = of_hypreal y) = (x = y)"
   4.160 +  by transfer (rule of_real_eq_iff)
   4.161  
   4.162 -lemma of_hypreal_eq_0_iff [simp]:
   4.163 -  "\<And>x. (of_hypreal x = 0) = (x = 0)"
   4.164 -by transfer (rule of_real_eq_0_iff)
   4.165 +lemma of_hypreal_eq_0_iff [simp]: "\<And>x. (of_hypreal x = 0) = (x = 0)"
   4.166 +  by transfer (rule of_real_eq_0_iff)
   4.167  
   4.168  
   4.169 -subsection\<open>Properties of @{term starrel}\<close>
   4.170 +subsection \<open>Properties of @{term starrel}\<close>
   4.171  
   4.172  lemma lemma_starrel_refl [simp]: "x \<in> starrel `` {x}"
   4.173 -by (simp add: starrel_def)
   4.174 +  by (simp add: starrel_def)
   4.175  
   4.176  lemma starrel_in_hypreal [simp]: "starrel``{x}:star"
   4.177 -by (simp add: star_def starrel_def quotient_def, blast)
   4.178 +  by (simp add: star_def starrel_def quotient_def, blast)
   4.179  
   4.180  declare Abs_star_inject [simp] Abs_star_inverse [simp]
   4.181  declare equiv_starrel [THEN eq_equiv_class_iff, simp]
   4.182  
   4.183 -subsection\<open>@{term hypreal_of_real}:
   4.184 -            the Injection from @{typ real} to @{typ hypreal}\<close>
   4.185 +
   4.186 +subsection \<open>@{term hypreal_of_real}: the Injection from @{typ real} to @{typ hypreal}\<close>
   4.187  
   4.188  lemma inj_star_of: "inj star_of"
   4.189 -by (rule inj_onI, simp)
   4.190 +  by (rule inj_onI) simp
   4.191  
   4.192 -lemma mem_Rep_star_iff: "(X \<in> Rep_star x) = (x = star_n X)"
   4.193 -by (cases x, simp add: star_n_def)
   4.194 +lemma mem_Rep_star_iff: "X \<in> Rep_star x \<longleftrightarrow> x = star_n X"
   4.195 +  by (cases x) (simp add: star_n_def)
   4.196  
   4.197 -lemma Rep_star_star_n_iff [simp]:
   4.198 -  "(X \<in> Rep_star (star_n Y)) = (eventually (\<lambda>n. Y n = X n) \<U>)"
   4.199 -by (simp add: star_n_def)
   4.200 +lemma Rep_star_star_n_iff [simp]: "X \<in> Rep_star (star_n Y) \<longleftrightarrow> eventually (\<lambda>n. Y n = X n) \<U>"
   4.201 +  by (simp add: star_n_def)
   4.202  
   4.203  lemma Rep_star_star_n: "X \<in> Rep_star (star_n X)"
   4.204 -by simp
   4.205 +  by simp
   4.206  
   4.207 -subsection\<open>Properties of @{term star_n}\<close>
   4.208  
   4.209 -lemma star_n_add:
   4.210 -  "star_n X + star_n Y = star_n (%n. X n + Y n)"
   4.211 -by (simp only: star_add_def starfun2_star_n)
   4.212 +subsection \<open>Properties of @{term star_n}\<close>
   4.213 +
   4.214 +lemma star_n_add: "star_n X + star_n Y = star_n (\<lambda>n. X n + Y n)"
   4.215 +  by (simp only: star_add_def starfun2_star_n)
   4.216  
   4.217 -lemma star_n_minus:
   4.218 -   "- star_n X = star_n (%n. -(X n))"
   4.219 -by (simp only: star_minus_def starfun_star_n)
   4.220 +lemma star_n_minus: "- star_n X = star_n (\<lambda>n. -(X n))"
   4.221 +  by (simp only: star_minus_def starfun_star_n)
   4.222  
   4.223 -lemma star_n_diff:
   4.224 -     "star_n X - star_n Y = star_n (%n. X n - Y n)"
   4.225 -by (simp only: star_diff_def starfun2_star_n)
   4.226 +lemma star_n_diff: "star_n X - star_n Y = star_n (\<lambda>n. X n - Y n)"
   4.227 +  by (simp only: star_diff_def starfun2_star_n)
   4.228  
   4.229 -lemma star_n_mult:
   4.230 -  "star_n X * star_n Y = star_n (%n. X n * Y n)"
   4.231 -by (simp only: star_mult_def starfun2_star_n)
   4.232 +lemma star_n_mult: "star_n X * star_n Y = star_n (\<lambda>n. X n * Y n)"
   4.233 +  by (simp only: star_mult_def starfun2_star_n)
   4.234  
   4.235 -lemma star_n_inverse:
   4.236 -      "inverse (star_n X) = star_n (%n. inverse(X n))"
   4.237 -by (simp only: star_inverse_def starfun_star_n)
   4.238 +lemma star_n_inverse: "inverse (star_n X) = star_n (\<lambda>n. inverse (X n))"
   4.239 +  by (simp only: star_inverse_def starfun_star_n)
   4.240  
   4.241 -lemma star_n_le:
   4.242 -      "star_n X \<le> star_n Y = (eventually (\<lambda>n. X n \<le> Y n) FreeUltrafilterNat)"
   4.243 -by (simp only: star_le_def starP2_star_n)
   4.244 +lemma star_n_le: "star_n X \<le> star_n Y = eventually (\<lambda>n. X n \<le> Y n) FreeUltrafilterNat"
   4.245 +  by (simp only: star_le_def starP2_star_n)
   4.246 +
   4.247 +lemma star_n_less: "star_n X < star_n Y = eventually (\<lambda>n. X n < Y n) FreeUltrafilterNat"
   4.248 +  by (simp only: star_less_def starP2_star_n)
   4.249  
   4.250 -lemma star_n_less:
   4.251 -      "star_n X < star_n Y = (eventually (\<lambda>n. X n < Y n) FreeUltrafilterNat)"
   4.252 -by (simp only: star_less_def starP2_star_n)
   4.253 +lemma star_n_zero_num: "0 = star_n (\<lambda>n. 0)"
   4.254 +  by (simp only: star_zero_def star_of_def)
   4.255  
   4.256 -lemma star_n_zero_num: "0 = star_n (%n. 0)"
   4.257 -by (simp only: star_zero_def star_of_def)
   4.258 +lemma star_n_one_num: "1 = star_n (\<lambda>n. 1)"
   4.259 +  by (simp only: star_one_def star_of_def)
   4.260  
   4.261 -lemma star_n_one_num: "1 = star_n (%n. 1)"
   4.262 -by (simp only: star_one_def star_of_def)
   4.263 -
   4.264 -lemma star_n_abs: "\<bar>star_n X\<bar> = star_n (%n. \<bar>X n\<bar>)"
   4.265 -by (simp only: star_abs_def starfun_star_n)
   4.266 +lemma star_n_abs: "\<bar>star_n X\<bar> = star_n (\<lambda>n. \<bar>X n\<bar>)"
   4.267 +  by (simp only: star_abs_def starfun_star_n)
   4.268  
   4.269  lemma hypreal_omega_gt_zero [simp]: "0 < \<omega>"
   4.270 -by (simp add: omega_def star_n_zero_num star_n_less)
   4.271 -
   4.272 -subsection\<open>Existence of Infinite Hyperreal Number\<close>
   4.273 -
   4.274 -text\<open>Existence of infinite number not corresponding to any real number.
   4.275 -Use assumption that member @{term FreeUltrafilterNat} is not finite.\<close>
   4.276 +  by (simp add: omega_def star_n_zero_num star_n_less)
   4.277  
   4.278  
   4.279 -text\<open>A few lemmas first\<close>
   4.280 +subsection \<open>Existence of Infinite Hyperreal Number\<close>
   4.281 +
   4.282 +text \<open>Existence of infinite number not corresponding to any real number.
   4.283 +  Use assumption that member @{term FreeUltrafilterNat} is not finite.\<close>
   4.284 +
   4.285 +text \<open>A few lemmas first.\<close>
   4.286  
   4.287  lemma lemma_omega_empty_singleton_disj:
   4.288    "{n::nat. x = real n} = {} \<or> (\<exists>y. {n::nat. x = real n} = {y})"
   4.289 -by force
   4.290 +  by force
   4.291  
   4.292  lemma lemma_finite_omega_set: "finite {n::nat. x = real n}"
   4.293    using lemma_omega_empty_singleton_disj [of x] by auto
   4.294  
   4.295 -lemma not_ex_hypreal_of_real_eq_omega:
   4.296 -      "~ (\<exists>x. hypreal_of_real x = \<omega>)"
   4.297 -apply (simp add: omega_def star_of_def star_n_eq_iff)
   4.298 -apply clarify
   4.299 -apply (rule_tac x2="x-1" in lemma_finite_omega_set [THEN FreeUltrafilterNat.finite, THEN notE])
   4.300 -apply (erule eventually_mono)
   4.301 -apply auto
   4.302 -done
   4.303 +lemma not_ex_hypreal_of_real_eq_omega: "\<nexists>x. hypreal_of_real x = \<omega>"
   4.304 +  apply (simp add: omega_def star_of_def star_n_eq_iff)
   4.305 +  apply clarify
   4.306 +  apply (rule_tac x2="x-1" in lemma_finite_omega_set [THEN FreeUltrafilterNat.finite, THEN notE])
   4.307 +  apply (erule eventually_mono)
   4.308 +  apply auto
   4.309 +  done
   4.310  
   4.311  lemma hypreal_of_real_not_eq_omega: "hypreal_of_real x \<noteq> \<omega>"
   4.312 -by (insert not_ex_hypreal_of_real_eq_omega, auto)
   4.313 +  using not_ex_hypreal_of_real_eq_omega by auto
   4.314  
   4.315 -text\<open>Existence of infinitesimal number also not corresponding to any
   4.316 - real number\<close>
   4.317 +text \<open>Existence of infinitesimal number also not corresponding to any real number.\<close>
   4.318  
   4.319  lemma lemma_epsilon_empty_singleton_disj:
   4.320 -     "{n::nat. x = inverse(real(Suc n))} = {} |
   4.321 -      (\<exists>y. {n::nat. x = inverse(real(Suc n))} = {y})"
   4.322 -by auto
   4.323 +  "{n::nat. x = inverse(real(Suc n))} = {} \<or> (\<exists>y. {n::nat. x = inverse(real(Suc n))} = {y})"
   4.324 +  by auto
   4.325  
   4.326 -lemma lemma_finite_epsilon_set: "finite {n. x = inverse(real(Suc n))}"
   4.327 -by (cut_tac x = x in lemma_epsilon_empty_singleton_disj, auto)
   4.328 +lemma lemma_finite_epsilon_set: "finite {n. x = inverse (real (Suc n))}"
   4.329 +  using lemma_epsilon_empty_singleton_disj [of x] by auto
   4.330  
   4.331 -lemma not_ex_hypreal_of_real_eq_epsilon: "~ (\<exists>x. hypreal_of_real x = \<epsilon>)"
   4.332 -by (auto simp add: epsilon_def star_of_def star_n_eq_iff
   4.333 -                   lemma_finite_epsilon_set [THEN FreeUltrafilterNat.finite] simp del: of_nat_Suc)
   4.334 +lemma not_ex_hypreal_of_real_eq_epsilon: "\<nexists>x. hypreal_of_real x = \<epsilon>"
   4.335 +  by (auto simp: epsilon_def star_of_def star_n_eq_iff
   4.336 +      lemma_finite_epsilon_set [THEN FreeUltrafilterNat.finite] simp del: of_nat_Suc)
   4.337  
   4.338  lemma hypreal_of_real_not_eq_epsilon: "hypreal_of_real x \<noteq> \<epsilon>"
   4.339 -by (insert not_ex_hypreal_of_real_eq_epsilon, auto)
   4.340 +  using not_ex_hypreal_of_real_eq_epsilon by auto
   4.341  
   4.342  lemma hypreal_epsilon_not_zero: "\<epsilon> \<noteq> 0"
   4.343 -by (simp add: epsilon_def star_zero_def star_of_def star_n_eq_iff FreeUltrafilterNat.proper
   4.344 -         del: star_of_zero)
   4.345 +  by (simp add: epsilon_def star_zero_def star_of_def star_n_eq_iff FreeUltrafilterNat.proper
   4.346 +      del: star_of_zero)
   4.347  
   4.348  lemma hypreal_epsilon_inverse_omega: "\<epsilon> = inverse \<omega>"
   4.349 -by (simp add: epsilon_def omega_def star_n_inverse)
   4.350 +  by (simp add: epsilon_def omega_def star_n_inverse)
   4.351  
   4.352  lemma hypreal_epsilon_gt_zero: "0 < \<epsilon>"
   4.353 -by (simp add: hypreal_epsilon_inverse_omega)
   4.354 -
   4.355 -subsection\<open>Absolute Value Function for the Hyperreals\<close>
   4.356 -
   4.357 -lemma hrabs_add_less: "[| \<bar>x\<bar> < r; \<bar>y\<bar> < s |] ==> \<bar>x + y\<bar> < r + (s::hypreal)"
   4.358 -by (simp add: abs_if split: if_split_asm)
   4.359 -
   4.360 -lemma hrabs_less_gt_zero: "\<bar>x\<bar> < r ==> (0::hypreal) < r"
   4.361 -by (blast intro!: order_le_less_trans abs_ge_zero)
   4.362 -
   4.363 -lemma hrabs_disj: "\<bar>x\<bar> = (x::'a::abs_if) \<or> \<bar>x\<bar> = -x"
   4.364 -by (simp add: abs_if)
   4.365 -
   4.366 -lemma hrabs_add_lemma_disj: "(y::hypreal) + - x + (y + - z) = \<bar>x + - z\<bar> ==> y = z | x = y"
   4.367 -by (simp add: abs_if split: if_split_asm)
   4.368 +  by (simp add: hypreal_epsilon_inverse_omega)
   4.369  
   4.370  
   4.371 -subsection\<open>Embedding the Naturals into the Hyperreals\<close>
   4.372 +subsection \<open>Absolute Value Function for the Hyperreals\<close>
   4.373 +
   4.374 +lemma hrabs_add_less: "\<bar>x\<bar> < r \<Longrightarrow> \<bar>y\<bar> < s \<Longrightarrow> \<bar>x + y\<bar> < r + s"
   4.375 +  for x y r s :: hypreal
   4.376 +  by (simp add: abs_if split: if_split_asm)
   4.377 +
   4.378 +lemma hrabs_less_gt_zero: "\<bar>x\<bar> < r \<Longrightarrow> 0 < r"
   4.379 +  for x r :: hypreal
   4.380 +  by (blast intro!: order_le_less_trans abs_ge_zero)
   4.381  
   4.382 -abbreviation
   4.383 -  hypreal_of_nat :: "nat => hypreal" where
   4.384 -  "hypreal_of_nat == of_nat"
   4.385 +lemma hrabs_disj: "\<bar>x\<bar> = x \<or> \<bar>x\<bar> = -x"
   4.386 +  for x :: "'a::abs_if"
   4.387 +  by (simp add: abs_if)
   4.388 +
   4.389 +lemma hrabs_add_lemma_disj: "y + - x + (y + - z) = \<bar>x + - z\<bar> \<Longrightarrow> y = z \<or> x = y"
   4.390 +  for x y z :: hypreal
   4.391 +  by (simp add: abs_if split: if_split_asm)
   4.392 +
   4.393 +
   4.394 +subsection \<open>Embedding the Naturals into the Hyperreals\<close>
   4.395 +
   4.396 +abbreviation hypreal_of_nat :: "nat \<Rightarrow> hypreal"
   4.397 +  where "hypreal_of_nat \<equiv> of_nat"
   4.398  
   4.399  lemma SNat_eq: "Nats = {n. \<exists>N. n = hypreal_of_nat N}"
   4.400 -by (simp add: Nats_def image_def)
   4.401 +  by (simp add: Nats_def image_def)
   4.402  
   4.403 -(*------------------------------------------------------------*)
   4.404 -(* naturals embedded in hyperreals                            *)
   4.405 -(* is a hyperreal c.f. NS extension                           *)
   4.406 -(*------------------------------------------------------------*)
   4.407 +text \<open>Naturals embedded in hyperreals: is a hyperreal c.f. NS extension.\<close>
   4.408  
   4.409 -lemma hypreal_of_nat: "hypreal_of_nat m = star_n (%n. real m)"
   4.410 -by (simp add: star_of_def [symmetric])
   4.411 +lemma hypreal_of_nat: "hypreal_of_nat m = star_n (\<lambda>n. real m)"
   4.412 +  by (simp add: star_of_def [symmetric])
   4.413  
   4.414  declaration \<open>
   4.415    K (Lin_Arith.add_inj_thms [@{thm star_of_le} RS iffD2,
   4.416 @@ -314,75 +289,77 @@
   4.417    #> Lin_Arith.add_inj_const (@{const_name "StarDef.star_of"}, @{typ "real \<Rightarrow> hypreal"}))
   4.418  \<close>
   4.419  
   4.420 -simproc_setup fast_arith_hypreal ("(m::hypreal) < n" | "(m::hypreal) <= n" | "(m::hypreal) = n") =
   4.421 +simproc_setup fast_arith_hypreal ("(m::hypreal) < n" | "(m::hypreal) \<le> n" | "(m::hypreal) = n") =
   4.422    \<open>K Lin_Arith.simproc\<close>
   4.423  
   4.424  
   4.425  subsection \<open>Exponentials on the Hyperreals\<close>
   4.426  
   4.427 -lemma hpowr_0 [simp]:   "r ^ 0       = (1::hypreal)"
   4.428 -by (rule power_0)
   4.429 -
   4.430 -lemma hpowr_Suc [simp]: "r ^ (Suc n) = (r::hypreal) * (r ^ n)"
   4.431 -by (rule power_Suc)
   4.432 +lemma hpowr_0 [simp]: "r ^ 0 = (1::hypreal)"
   4.433 +  for r :: hypreal
   4.434 +  by (rule power_0)
   4.435  
   4.436 -lemma hrealpow_two: "(r::hypreal) ^ Suc (Suc 0) = r * r"
   4.437 -by simp
   4.438 +lemma hpowr_Suc [simp]: "r ^ (Suc n) = r * (r ^ n)"
   4.439 +  for r :: hypreal
   4.440 +  by (rule power_Suc)
   4.441  
   4.442 -lemma hrealpow_two_le [simp]: "(0::hypreal) \<le> r ^ Suc (Suc 0)"
   4.443 -by (auto simp add: zero_le_mult_iff)
   4.444 +lemma hrealpow_two: "r ^ Suc (Suc 0) = r * r"
   4.445 +  for r :: hypreal
   4.446 +  by simp
   4.447  
   4.448 -lemma hrealpow_two_le_add_order [simp]:
   4.449 -     "(0::hypreal) \<le> u ^ Suc (Suc 0) + v ^ Suc (Suc 0)"
   4.450 -by (simp only: hrealpow_two_le add_nonneg_nonneg)
   4.451 +lemma hrealpow_two_le [simp]: "0 \<le> r ^ Suc (Suc 0)"
   4.452 +  for r :: hypreal
   4.453 +  by (auto simp add: zero_le_mult_iff)
   4.454 +
   4.455 +lemma hrealpow_two_le_add_order [simp]: "0 \<le> u ^ Suc (Suc 0) + v ^ Suc (Suc 0)"
   4.456 +  for u v :: hypreal
   4.457 +  by (simp only: hrealpow_two_le add_nonneg_nonneg)
   4.458  
   4.459 -lemma hrealpow_two_le_add_order2 [simp]:
   4.460 -     "(0::hypreal) \<le> u ^ Suc (Suc 0) + v ^ Suc (Suc 0) + w ^ Suc (Suc 0)"
   4.461 -by (simp only: hrealpow_two_le add_nonneg_nonneg)
   4.462 +lemma hrealpow_two_le_add_order2 [simp]: "0 \<le> u ^ Suc (Suc 0) + v ^ Suc (Suc 0) + w ^ Suc (Suc 0)"
   4.463 +  for u v w :: hypreal
   4.464 +  by (simp only: hrealpow_two_le add_nonneg_nonneg)
   4.465  
   4.466 -lemma hypreal_add_nonneg_eq_0_iff:
   4.467 -     "[| 0 \<le> x; 0 \<le> y |] ==> (x+y = 0) = (x = 0 & y = (0::hypreal))"
   4.468 -by arith
   4.469 +lemma hypreal_add_nonneg_eq_0_iff: "0 \<le> x \<Longrightarrow> 0 \<le> y \<Longrightarrow> x + y = 0 \<longleftrightarrow> x = 0 \<and> y = 0"
   4.470 +  for x y :: hypreal
   4.471 +  by arith
   4.472  
   4.473  
   4.474 -text\<open>FIXME: DELETE THESE\<close>
   4.475 -lemma hypreal_three_squares_add_zero_iff:
   4.476 -     "(x*x + y*y + z*z = 0) = (x = 0 & y = 0 & z = (0::hypreal))"
   4.477 -apply (simp only: zero_le_square add_nonneg_nonneg hypreal_add_nonneg_eq_0_iff, auto)
   4.478 -done
   4.479 +(* FIXME: DELETE THESE *)
   4.480 +lemma hypreal_three_squares_add_zero_iff: "x * x + y * y + z * z = 0 \<longleftrightarrow> x = 0 \<and> y = 0 \<and> z = 0"
   4.481 +  for x y z :: hypreal
   4.482 +  by (simp only: zero_le_square add_nonneg_nonneg hypreal_add_nonneg_eq_0_iff) auto
   4.483  
   4.484  lemma hrealpow_three_squares_add_zero_iff [simp]:
   4.485 -     "(x ^ Suc (Suc 0) + y ^ Suc (Suc 0) + z ^ Suc (Suc 0) = (0::hypreal)) =
   4.486 -      (x = 0 & y = 0 & z = 0)"
   4.487 -by (simp only: hypreal_three_squares_add_zero_iff hrealpow_two)
   4.488 +  "x ^ Suc (Suc 0) + y ^ Suc (Suc 0) + z ^ Suc (Suc 0) = 0 \<longleftrightarrow> x = 0 \<and> y = 0 \<and> z = 0"
   4.489 +  for x y z :: hypreal
   4.490 +  by (simp only: hypreal_three_squares_add_zero_iff hrealpow_two)
   4.491  
   4.492  (*FIXME: This and RealPow.abs_realpow_two should be replaced by an abstract
   4.493    result proved in Rings or Fields*)
   4.494 -lemma hrabs_hrealpow_two [simp]: "\<bar>x ^ Suc (Suc 0)\<bar> = (x::hypreal) ^ Suc (Suc 0)"
   4.495 -by (simp add: abs_mult)
   4.496 +lemma hrabs_hrealpow_two [simp]: "\<bar>x ^ Suc (Suc 0)\<bar> = x ^ Suc (Suc 0)"
   4.497 +  for x :: hypreal
   4.498 +  by (simp add: abs_mult)
   4.499  
   4.500  lemma two_hrealpow_ge_one [simp]: "(1::hypreal) \<le> 2 ^ n"
   4.501 -by (insert power_increasing [of 0 n "2::hypreal"], simp)
   4.502 +  using power_increasing [of 0 n "2::hypreal"] by simp
   4.503  
   4.504 -lemma hrealpow:
   4.505 -    "star_n X ^ m = star_n (%n. (X n::real) ^ m)"
   4.506 -apply (induct_tac "m")
   4.507 -apply (auto simp add: star_n_one_num star_n_mult power_0)
   4.508 -done
   4.509 +lemma hrealpow: "star_n X ^ m = star_n (\<lambda>n. (X n::real) ^ m)"
   4.510 +  by (induct m) (auto simp: star_n_one_num star_n_mult)
   4.511  
   4.512  lemma hrealpow_sum_square_expand:
   4.513 -     "(x + (y::hypreal)) ^ Suc (Suc 0) =
   4.514 -      x ^ Suc (Suc 0) + y ^ Suc (Suc 0) + (hypreal_of_nat (Suc (Suc 0)))*x*y"
   4.515 -by (simp add: distrib_left distrib_right)
   4.516 +  "(x + y) ^ Suc (Suc 0) =
   4.517 +    x ^ Suc (Suc 0) + y ^ Suc (Suc 0) + (hypreal_of_nat (Suc (Suc 0))) * x * y"
   4.518 +  for x y :: hypreal
   4.519 +  by (simp add: distrib_left distrib_right)
   4.520  
   4.521  lemma power_hypreal_of_real_numeral:
   4.522 -     "(numeral v :: hypreal) ^ n = hypreal_of_real ((numeral v) ^ n)"
   4.523 -by simp
   4.524 +  "(numeral v :: hypreal) ^ n = hypreal_of_real ((numeral v) ^ n)"
   4.525 +  by simp
   4.526  declare power_hypreal_of_real_numeral [of _ "numeral w", simp] for w
   4.527  
   4.528  lemma power_hypreal_of_real_neg_numeral:
   4.529 -     "(- numeral v :: hypreal) ^ n = hypreal_of_real ((- numeral v) ^ n)"
   4.530 -by simp
   4.531 +  "(- numeral v :: hypreal) ^ n = hypreal_of_real ((- numeral v) ^ n)"
   4.532 +  by simp
   4.533  declare power_hypreal_of_real_neg_numeral [of _ "numeral w", simp] for w
   4.534  (*
   4.535  lemma hrealpow_HFinite:
   4.536 @@ -393,148 +370,119 @@
   4.537  done
   4.538  *)
   4.539  
   4.540 -subsection\<open>Powers with Hypernatural Exponents\<close>
   4.541  
   4.542 -definition pow :: "['a::power star, nat star] \<Rightarrow> 'a star" (infixr "pow" 80) where
   4.543 -  hyperpow_def [transfer_unfold]: "R pow N = ( *f2* op ^) R N"
   4.544 -  (* hypernatural powers of hyperreals *)
   4.545 +subsection \<open>Powers with Hypernatural Exponents\<close>
   4.546  
   4.547 -lemma Standard_hyperpow [simp]:
   4.548 -  "\<lbrakk>r \<in> Standard; n \<in> Standard\<rbrakk> \<Longrightarrow> r pow n \<in> Standard"
   4.549 -unfolding hyperpow_def by simp
   4.550 +text \<open>Hypernatural powers of hyperreals.\<close>
   4.551 +definition pow :: "'a::power star \<Rightarrow> nat star \<Rightarrow> 'a star"  (infixr "pow" 80)
   4.552 +  where hyperpow_def [transfer_unfold]: "R pow N = ( *f2* op ^) R N"
   4.553  
   4.554 -lemma hyperpow: "star_n X pow star_n Y = star_n (%n. X n ^ Y n)"
   4.555 -by (simp add: hyperpow_def starfun2_star_n)
   4.556 -
   4.557 -lemma hyperpow_zero [simp]:
   4.558 -  "\<And>n. (0::'a::{power,semiring_0} star) pow (n + (1::hypnat)) = 0"
   4.559 -by transfer simp
   4.560 +lemma Standard_hyperpow [simp]: "r \<in> Standard \<Longrightarrow> n \<in> Standard \<Longrightarrow> r pow n \<in> Standard"
   4.561 +  by (simp add: hyperpow_def)
   4.562  
   4.563 -lemma hyperpow_not_zero:
   4.564 -  "\<And>r n. r \<noteq> (0::'a::{field} star) ==> r pow n \<noteq> 0"
   4.565 -by transfer (rule power_not_zero)
   4.566 +lemma hyperpow: "star_n X pow star_n Y = star_n (\<lambda>n. X n ^ Y n)"
   4.567 +  by (simp add: hyperpow_def starfun2_star_n)
   4.568 +
   4.569 +lemma hyperpow_zero [simp]: "\<And>n. (0::'a::{power,semiring_0} star) pow (n + (1::hypnat)) = 0"
   4.570 +  by transfer simp
   4.571  
   4.572 -lemma hyperpow_inverse:
   4.573 -  "\<And>r n. r \<noteq> (0::'a::field star)
   4.574 -   \<Longrightarrow> inverse (r pow n) = (inverse r) pow n"
   4.575 -by transfer (rule power_inverse [symmetric])
   4.576 +lemma hyperpow_not_zero: "\<And>r n. r \<noteq> (0::'a::{field} star) \<Longrightarrow> r pow n \<noteq> 0"
   4.577 +  by transfer (rule power_not_zero)
   4.578  
   4.579 -lemma hyperpow_hrabs:
   4.580 -  "\<And>r n. \<bar>r::'a::{linordered_idom} star\<bar> pow n = \<bar>r pow n\<bar>"
   4.581 -by transfer (rule power_abs [symmetric])
   4.582 +lemma hyperpow_inverse: "\<And>r n. r \<noteq> (0::'a::field star) \<Longrightarrow> inverse (r pow n) = (inverse r) pow n"
   4.583 +  by transfer (rule power_inverse [symmetric])
   4.584  
   4.585 -lemma hyperpow_add:
   4.586 -  "\<And>r n m. (r::'a::monoid_mult star) pow (n + m) = (r pow n) * (r pow m)"
   4.587 -by transfer (rule power_add)
   4.588 +lemma hyperpow_hrabs: "\<And>r n. \<bar>r::'a::{linordered_idom} star\<bar> pow n = \<bar>r pow n\<bar>"
   4.589 +  by transfer (rule power_abs [symmetric])
   4.590  
   4.591 -lemma hyperpow_one [simp]:
   4.592 -  "\<And>r. (r::'a::monoid_mult star) pow (1::hypnat) = r"
   4.593 -by transfer (rule power_one_right)
   4.594 +lemma hyperpow_add: "\<And>r n m. (r::'a::monoid_mult star) pow (n + m) = (r pow n) * (r pow m)"
   4.595 +  by transfer (rule power_add)
   4.596  
   4.597 -lemma hyperpow_two:
   4.598 -  "\<And>r. (r::'a::monoid_mult star) pow (2::hypnat) = r * r"
   4.599 -by transfer (rule power2_eq_square)
   4.600 +lemma hyperpow_one [simp]: "\<And>r. (r::'a::monoid_mult star) pow (1::hypnat) = r"
   4.601 +  by transfer (rule power_one_right)
   4.602  
   4.603 -lemma hyperpow_gt_zero:
   4.604 -  "\<And>r n. (0::'a::{linordered_semidom} star) < r \<Longrightarrow> 0 < r pow n"
   4.605 -by transfer (rule zero_less_power)
   4.606 +lemma hyperpow_two: "\<And>r. (r::'a::monoid_mult star) pow (2::hypnat) = r * r"
   4.607 +  by transfer (rule power2_eq_square)
   4.608  
   4.609 -lemma hyperpow_ge_zero:
   4.610 -  "\<And>r n. (0::'a::{linordered_semidom} star) \<le> r \<Longrightarrow> 0 \<le> r pow n"
   4.611 -by transfer (rule zero_le_power)
   4.612 +lemma hyperpow_gt_zero: "\<And>r n. (0::'a::{linordered_semidom} star) < r \<Longrightarrow> 0 < r pow n"
   4.613 +  by transfer (rule zero_less_power)
   4.614 +
   4.615 +lemma hyperpow_ge_zero: "\<And>r n. (0::'a::{linordered_semidom} star) \<le> r \<Longrightarrow> 0 \<le> r pow n"
   4.616 +  by transfer (rule zero_le_power)
   4.617  
   4.618 -lemma hyperpow_le:
   4.619 -  "\<And>x y n. \<lbrakk>(0::'a::{linordered_semidom} star) < x; x \<le> y\<rbrakk>
   4.620 -   \<Longrightarrow> x pow n \<le> y pow n"
   4.621 -by transfer (rule power_mono [OF _ order_less_imp_le])
   4.622 +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"
   4.623 +  by transfer (rule power_mono [OF _ order_less_imp_le])
   4.624  
   4.625 -lemma hyperpow_eq_one [simp]:
   4.626 -  "\<And>n. 1 pow n = (1::'a::monoid_mult star)"
   4.627 -by transfer (rule power_one)
   4.628 +lemma hyperpow_eq_one [simp]: "\<And>n. 1 pow n = (1::'a::monoid_mult star)"
   4.629 +  by transfer (rule power_one)
   4.630  
   4.631 -lemma hrabs_hyperpow_minus [simp]:
   4.632 -  "\<And>(a::'a::{linordered_idom} star) n. \<bar>(-a) pow n\<bar> = \<bar>a pow n\<bar>"
   4.633 -by transfer (rule abs_power_minus)
   4.634 +lemma hrabs_hyperpow_minus [simp]: "\<And>(a::'a::linordered_idom star) n. \<bar>(-a) pow n\<bar> = \<bar>a pow n\<bar>"
   4.635 +  by transfer (rule abs_power_minus)
   4.636  
   4.637 -lemma hyperpow_mult:
   4.638 -  "\<And>r s n. (r * s::'a::{comm_monoid_mult} star) pow n
   4.639 -   = (r pow n) * (s pow n)"
   4.640 -by transfer (rule power_mult_distrib)
   4.641 +lemma hyperpow_mult: "\<And>r s n. (r * s::'a::comm_monoid_mult star) pow n = (r pow n) * (s pow n)"
   4.642 +  by transfer (rule power_mult_distrib)
   4.643  
   4.644 -lemma hyperpow_two_le [simp]:
   4.645 -  "\<And>r. (0::'a::{monoid_mult,linordered_ring_strict} star) \<le> r pow 2"
   4.646 -by (auto simp add: hyperpow_two zero_le_mult_iff)
   4.647 +lemma hyperpow_two_le [simp]: "\<And>r. (0::'a::{monoid_mult,linordered_ring_strict} star) \<le> r pow 2"
   4.648 +  by (auto simp add: hyperpow_two zero_le_mult_iff)
   4.649  
   4.650  lemma hrabs_hyperpow_two [simp]:
   4.651 -  "\<bar>x pow 2\<bar> =
   4.652 -   (x::'a::{monoid_mult,linordered_ring_strict} star) pow 2"
   4.653 -by (simp only: abs_of_nonneg hyperpow_two_le)
   4.654 +  "\<bar>x pow 2\<bar> = (x::'a::{monoid_mult,linordered_ring_strict} star) pow 2"
   4.655 +  by (simp only: abs_of_nonneg hyperpow_two_le)
   4.656  
   4.657 -lemma hyperpow_two_hrabs [simp]:
   4.658 -  "\<bar>x::'a::{linordered_idom} star\<bar> pow 2 = x pow 2"
   4.659 -by (simp add: hyperpow_hrabs)
   4.660 +lemma hyperpow_two_hrabs [simp]: "\<bar>x::'a::linordered_idom star\<bar> pow 2 = x pow 2"
   4.661 +  by (simp add: hyperpow_hrabs)
   4.662  
   4.663 -text\<open>The precondition could be weakened to @{term "0\<le>x"}\<close>
   4.664 -lemma hypreal_mult_less_mono:
   4.665 -     "[| u<v;  x<y;  (0::hypreal) < v;  0 < x |] ==> u*x < v* y"
   4.666 - by (simp add: mult_strict_mono order_less_imp_le)
   4.667 +text \<open>The precondition could be weakened to @{term "0\<le>x"}.\<close>
   4.668 +lemma hypreal_mult_less_mono: "u < v \<Longrightarrow> x < y \<Longrightarrow> 0 < v \<Longrightarrow> 0 < x \<Longrightarrow> u * x < v * y"
   4.669 +  for u v x y :: hypreal
   4.670 +  by (simp add: mult_strict_mono order_less_imp_le)
   4.671  
   4.672 -lemma hyperpow_two_gt_one:
   4.673 -  "\<And>r::'a::{linordered_semidom} star. 1 < r \<Longrightarrow> 1 < r pow 2"
   4.674 -by transfer simp
   4.675 +lemma hyperpow_two_gt_one: "\<And>r::'a::linordered_semidom star. 1 < r \<Longrightarrow> 1 < r pow 2"
   4.676 +  by transfer simp
   4.677  
   4.678 -lemma hyperpow_two_ge_one:
   4.679 -  "\<And>r::'a::{linordered_semidom} star. 1 \<le> r \<Longrightarrow> 1 \<le> r pow 2"
   4.680 -by transfer (rule one_le_power)
   4.681 +lemma hyperpow_two_ge_one: "\<And>r::'a::linordered_semidom star. 1 \<le> r \<Longrightarrow> 1 \<le> r pow 2"
   4.682 +  by transfer (rule one_le_power)
   4.683  
   4.684  lemma two_hyperpow_ge_one [simp]: "(1::hypreal) \<le> 2 pow n"
   4.685 -apply (rule_tac y = "1 pow n" in order_trans)
   4.686 -apply (rule_tac [2] hyperpow_le, auto)
   4.687 -done
   4.688 +  apply (rule_tac y = "1 pow n" in order_trans)
   4.689 +   apply (rule_tac [2] hyperpow_le)
   4.690 +    apply auto
   4.691 +  done
   4.692  
   4.693 -lemma hyperpow_minus_one2 [simp]:
   4.694 -     "\<And>n. (- 1) pow (2*n) = (1::hypreal)"
   4.695 -by transfer (rule power_minus1_even)
   4.696 +lemma hyperpow_minus_one2 [simp]: "\<And>n. (- 1) pow (2 * n) = (1::hypreal)"
   4.697 +  by transfer (rule power_minus1_even)
   4.698  
   4.699 -lemma hyperpow_less_le:
   4.700 -     "!!r n N. [|(0::hypreal) \<le> r; r \<le> 1; n < N|] ==> r pow N \<le> r pow n"
   4.701 -by transfer (rule power_decreasing [OF order_less_imp_le])
   4.702 +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"
   4.703 +  by transfer (rule power_decreasing [OF order_less_imp_le])
   4.704  
   4.705  lemma hyperpow_SHNat_le:
   4.706 -     "[| 0 \<le> r;  r \<le> (1::hypreal);  N \<in> HNatInfinite |]
   4.707 -      ==> ALL n: Nats. r pow N \<le> r pow n"
   4.708 -by (auto intro!: hyperpow_less_le simp add: HNatInfinite_iff)
   4.709 +  "0 \<le> r \<Longrightarrow> r \<le> (1::hypreal) \<Longrightarrow> N \<in> HNatInfinite \<Longrightarrow> \<forall>n\<in>Nats. r pow N \<le> r pow n"
   4.710 +  by (auto intro!: hyperpow_less_le simp: HNatInfinite_iff)
   4.711  
   4.712 -lemma hyperpow_realpow:
   4.713 -      "(hypreal_of_real r) pow (hypnat_of_nat n) = hypreal_of_real (r ^ n)"
   4.714 -by transfer (rule refl)
   4.715 +lemma hyperpow_realpow: "(hypreal_of_real r) pow (hypnat_of_nat n) = hypreal_of_real (r ^ n)"
   4.716 +  by transfer (rule refl)
   4.717  
   4.718 -lemma hyperpow_SReal [simp]:
   4.719 -     "(hypreal_of_real r) pow (hypnat_of_nat n) \<in> \<real>"
   4.720 -by (simp add: Reals_eq_Standard)
   4.721 +lemma hyperpow_SReal [simp]: "(hypreal_of_real r) pow (hypnat_of_nat n) \<in> \<real>"
   4.722 +  by (simp add: Reals_eq_Standard)
   4.723  
   4.724 -lemma hyperpow_zero_HNatInfinite [simp]:
   4.725 -     "N \<in> HNatInfinite ==> (0::hypreal) pow N = 0"
   4.726 -by (drule HNatInfinite_is_Suc, auto)
   4.727 +lemma hyperpow_zero_HNatInfinite [simp]: "N \<in> HNatInfinite \<Longrightarrow> (0::hypreal) pow N = 0"
   4.728 +  by (drule HNatInfinite_is_Suc, auto)
   4.729  
   4.730 -lemma hyperpow_le_le:
   4.731 -     "[| (0::hypreal) \<le> r; r \<le> 1; n \<le> N |] ==> r pow N \<le> r pow n"
   4.732 -apply (drule order_le_less [of n, THEN iffD1])
   4.733 -apply (auto intro: hyperpow_less_le)
   4.734 -done
   4.735 +lemma hyperpow_le_le: "(0::hypreal) \<le> r \<Longrightarrow> r \<le> 1 \<Longrightarrow> n \<le> N \<Longrightarrow> r pow N \<le> r pow n"
   4.736 +  apply (drule order_le_less [of n, THEN iffD1])
   4.737 +  apply (auto intro: hyperpow_less_le)
   4.738 +  done
   4.739  
   4.740 -lemma hyperpow_Suc_le_self2:
   4.741 -     "[| (0::hypreal) \<le> r; r < 1 |] ==> r pow (n + (1::hypnat)) \<le> r"
   4.742 -apply (drule_tac n = " (1::hypnat) " in hyperpow_le_le)
   4.743 -apply auto
   4.744 -done
   4.745 +lemma hyperpow_Suc_le_self2: "(0::hypreal) \<le> r \<Longrightarrow> r < 1 \<Longrightarrow> r pow (n + (1::hypnat)) \<le> r"
   4.746 +  apply (drule_tac n = " (1::hypnat) " in hyperpow_le_le)
   4.747 +    apply auto
   4.748 +  done
   4.749  
   4.750  lemma hyperpow_hypnat_of_nat: "\<And>x. x pow hypnat_of_nat n = x ^ n"
   4.751 -by transfer (rule refl)
   4.752 +  by transfer (rule refl)
   4.753  
   4.754  lemma of_hypreal_hyperpow:
   4.755 -  "\<And>x n. of_hypreal (x pow n) =
   4.756 -   (of_hypreal x::'a::{real_algebra_1} star) pow n"
   4.757 -by transfer (rule of_real_power)
   4.758 +  "\<And>x n. of_hypreal (x pow n) = (of_hypreal x::'a::{real_algebra_1} star) pow n"
   4.759 +  by transfer (rule of_real_power)
   4.760  
   4.761  end
     5.1 --- a/src/HOL/Nonstandard_Analysis/HyperNat.thy	Mon Oct 31 16:26:36 2016 +0100
     5.2 +++ b/src/HOL/Nonstandard_Analysis/HyperNat.thy	Tue Nov 01 00:44:24 2016 +0100
     5.3 @@ -5,410 +5,395 @@
     5.4  Converted to Isar and polished by lcp
     5.5  *)
     5.6  
     5.7 -section\<open>Hypernatural numbers\<close>
     5.8 +section \<open>Hypernatural numbers\<close>
     5.9  
    5.10  theory HyperNat
    5.11 -imports StarDef
    5.12 +  imports StarDef
    5.13  begin
    5.14  
    5.15  type_synonym hypnat = "nat star"
    5.16  
    5.17 -abbreviation
    5.18 -  hypnat_of_nat :: "nat => nat star" where
    5.19 -  "hypnat_of_nat == star_of"
    5.20 +abbreviation hypnat_of_nat :: "nat \<Rightarrow> nat star"
    5.21 +  where "hypnat_of_nat \<equiv> star_of"
    5.22  
    5.23 -definition
    5.24 -  hSuc :: "hypnat => hypnat" where
    5.25 -  hSuc_def [transfer_unfold]: "hSuc = *f* Suc"
    5.26 +definition hSuc :: "hypnat \<Rightarrow> hypnat"
    5.27 +  where hSuc_def [transfer_unfold]: "hSuc = *f* Suc"
    5.28  
    5.29 -subsection\<open>Properties Transferred from Naturals\<close>
    5.30 +
    5.31 +subsection \<open>Properties Transferred from Naturals\<close>
    5.32  
    5.33  lemma hSuc_not_zero [iff]: "\<And>m. hSuc m \<noteq> 0"
    5.34 -by transfer (rule Suc_not_Zero)
    5.35 +  by transfer (rule Suc_not_Zero)
    5.36  
    5.37  lemma zero_not_hSuc [iff]: "\<And>m. 0 \<noteq> hSuc m"
    5.38 -by transfer (rule Zero_not_Suc)
    5.39 +  by transfer (rule Zero_not_Suc)
    5.40  
    5.41 -lemma hSuc_hSuc_eq [iff]: "\<And>m n. (hSuc m = hSuc n) = (m = n)"
    5.42 -by transfer (rule nat.inject)
    5.43 +lemma hSuc_hSuc_eq [iff]: "\<And>m n. hSuc m = hSuc n \<longleftrightarrow> m = n"
    5.44 +  by transfer (rule nat.inject)
    5.45  
    5.46  lemma zero_less_hSuc [iff]: "\<And>n. 0 < hSuc n"
    5.47 -by transfer (rule zero_less_Suc)
    5.48 +  by transfer (rule zero_less_Suc)
    5.49  
    5.50 -lemma hypnat_minus_zero [simp]: "!!z. z - z = (0::hypnat)"
    5.51 -by transfer (rule diff_self_eq_0)
    5.52 +lemma hypnat_minus_zero [simp]: "\<And>z::hypnat. z - z = 0"
    5.53 +  by transfer (rule diff_self_eq_0)
    5.54  
    5.55 -lemma hypnat_diff_0_eq_0 [simp]: "!!n. (0::hypnat) - n = 0"
    5.56 -by transfer (rule diff_0_eq_0)
    5.57 +lemma hypnat_diff_0_eq_0 [simp]: "\<And>n::hypnat. 0 - n = 0"
    5.58 +  by transfer (rule diff_0_eq_0)
    5.59  
    5.60 -lemma hypnat_add_is_0 [iff]: "!!m n. (m+n = (0::hypnat)) = (m=0 & n=0)"
    5.61 -by transfer (rule add_is_0)
    5.62 +lemma hypnat_add_is_0 [iff]: "\<And>m n::hypnat. m + n = 0 \<longleftrightarrow> m = 0 \<and> n = 0"
    5.63 +  by transfer (rule add_is_0)
    5.64  
    5.65 -lemma hypnat_diff_diff_left: "!!i j k. (i::hypnat) - j - k = i - (j+k)"
    5.66 -by transfer (rule diff_diff_left)
    5.67 +lemma hypnat_diff_diff_left: "\<And>i j k::hypnat. i - j - k = i - (j + k)"
    5.68 +  by transfer (rule diff_diff_left)
    5.69  
    5.70 -lemma hypnat_diff_commute: "!!i j k. (i::hypnat) - j - k = i-k-j"
    5.71 -by transfer (rule diff_commute)
    5.72 +lemma hypnat_diff_commute: "\<And>i j k::hypnat. i - j - k = i - k - j"
    5.73 +  by transfer (rule diff_commute)
    5.74  
    5.75 -lemma hypnat_diff_add_inverse [simp]: "!!m n. ((n::hypnat) + m) - n = m"
    5.76 -by transfer (rule diff_add_inverse)
    5.77 +lemma hypnat_diff_add_inverse [simp]: "\<And>m n::hypnat. n + m - n = m"
    5.78 +  by transfer (rule diff_add_inverse)
    5.79  
    5.80 -lemma hypnat_diff_add_inverse2 [simp]:  "!!m n. ((m::hypnat) + n) - n = m"
    5.81 -by transfer (rule diff_add_inverse2)
    5.82 +lemma hypnat_diff_add_inverse2 [simp]:  "\<And>m n::hypnat. m + n - n = m"
    5.83 +  by transfer (rule diff_add_inverse2)
    5.84  
    5.85 -lemma hypnat_diff_cancel [simp]: "!!k m n. ((k::hypnat) + m) - (k+n) = m - n"
    5.86 -by transfer (rule diff_cancel)
    5.87 +lemma hypnat_diff_cancel [simp]: "\<And>k m n::hypnat. (k + m) - (k + n) = m - n"
    5.88 +  by transfer (rule diff_cancel)
    5.89  
    5.90 -lemma hypnat_diff_cancel2 [simp]: "!!k m n. ((m::hypnat) + k) - (n+k) = m - n"
    5.91 -by transfer (rule diff_cancel2)
    5.92 +lemma hypnat_diff_cancel2 [simp]: "\<And>k m n::hypnat. (m + k) - (n + k) = m - n"
    5.93 +  by transfer (rule diff_cancel2)
    5.94  
    5.95 -lemma hypnat_diff_add_0 [simp]: "!!m n. (n::hypnat) - (n+m) = (0::hypnat)"
    5.96 -by transfer (rule diff_add_0)
    5.97 +lemma hypnat_diff_add_0 [simp]: "\<And>m n::hypnat. n - (n + m) = 0"
    5.98 +  by transfer (rule diff_add_0)
    5.99  
   5.100 -lemma hypnat_diff_mult_distrib: "!!k m n. ((m::hypnat) - n) * k = (m * k) - (n * k)"
   5.101 -by transfer (rule diff_mult_distrib)
   5.102 +lemma hypnat_diff_mult_distrib: "\<And>k m n::hypnat. (m - n) * k = (m * k) - (n * k)"
   5.103 +  by transfer (rule diff_mult_distrib)
   5.104  
   5.105 -lemma hypnat_diff_mult_distrib2: "!!k m n. (k::hypnat) * (m - n) = (k * m) - (k * n)"
   5.106 -by transfer (rule diff_mult_distrib2)
   5.107 +lemma hypnat_diff_mult_distrib2: "\<And>k m n::hypnat. k * (m - n) = (k * m) - (k * n)"
   5.108 +  by transfer (rule diff_mult_distrib2)
   5.109  
   5.110 -lemma hypnat_le_zero_cancel [iff]: "!!n. (n \<le> (0::hypnat)) = (n = 0)"
   5.111 -by transfer (rule le_0_eq)
   5.112 +lemma hypnat_le_zero_cancel [iff]: "\<And>n::hypnat. n \<le> 0 \<longleftrightarrow> n = 0"
   5.113 +  by transfer (rule le_0_eq)
   5.114  
   5.115 -lemma hypnat_mult_is_0 [simp]: "!!m n. (m*n = (0::hypnat)) = (m=0 | n=0)"
   5.116 -by transfer (rule mult_is_0)
   5.117 +lemma hypnat_mult_is_0 [simp]: "\<And>m n::hypnat. m * n = 0 \<longleftrightarrow> m = 0 \<or> n = 0"
   5.118 +  by transfer (rule mult_is_0)
   5.119  
   5.120 -lemma hypnat_diff_is_0_eq [simp]: "!!m n. ((m::hypnat) - n = 0) = (m \<le> n)"
   5.121 -by transfer (rule diff_is_0_eq)
   5.122 +lemma hypnat_diff_is_0_eq [simp]: "\<And>m n::hypnat. m - n = 0 \<longleftrightarrow> m \<le> n"
   5.123 +  by transfer (rule diff_is_0_eq)
   5.124  
   5.125 -lemma hypnat_not_less0 [iff]: "!!n. ~ n < (0::hypnat)"
   5.126 -by transfer (rule not_less0)
   5.127 +lemma hypnat_not_less0 [iff]: "\<And>n::hypnat. \<not> n < 0"
   5.128 +  by transfer (rule not_less0)
   5.129 +
   5.130 +lemma hypnat_less_one [iff]: "\<And>n::hypnat. n < 1 \<longleftrightarrow> n = 0"
   5.131 +  by transfer (rule less_one)
   5.132  
   5.133 -lemma hypnat_less_one [iff]:
   5.134 -      "!!n. (n < (1::hypnat)) = (n=0)"
   5.135 -by transfer (rule less_one)
   5.136 +lemma hypnat_add_diff_inverse: "\<And>m n::hypnat. \<not> m < n \<Longrightarrow> n + (m - n) = m"
   5.137 +  by transfer (rule add_diff_inverse)
   5.138  
   5.139 -lemma hypnat_add_diff_inverse: "!!m n. ~ m<n ==> n+(m-n) = (m::hypnat)"
   5.140 -by transfer (rule add_diff_inverse)
   5.141 +lemma hypnat_le_add_diff_inverse [simp]: "\<And>m n::hypnat. n \<le> m \<Longrightarrow> n + (m - n) = m"
   5.142 +  by transfer (rule le_add_diff_inverse)
   5.143  
   5.144 -lemma hypnat_le_add_diff_inverse [simp]: "!!m n. n \<le> m ==> n+(m-n) = (m::hypnat)"
   5.145 -by transfer (rule le_add_diff_inverse)
   5.146 -
   5.147 -lemma hypnat_le_add_diff_inverse2 [simp]: "!!m n. n\<le>m ==> (m-n)+n = (m::hypnat)"
   5.148 -by transfer (rule le_add_diff_inverse2)
   5.149 +lemma hypnat_le_add_diff_inverse2 [simp]: "\<And>m n::hypnat. n \<le> m \<Longrightarrow> (m - n) + n = m"
   5.150 +  by transfer (rule le_add_diff_inverse2)
   5.151  
   5.152  declare hypnat_le_add_diff_inverse2 [OF order_less_imp_le]
   5.153  
   5.154 -lemma hypnat_le0 [iff]: "!!n. (0::hypnat) \<le> n"
   5.155 -by transfer (rule le0)
   5.156 +lemma hypnat_le0 [iff]: "\<And>n::hypnat. 0 \<le> n"
   5.157 +  by transfer (rule le0)
   5.158  
   5.159 -lemma hypnat_le_add1 [simp]: "!!x n. (x::hypnat) \<le> x + n"
   5.160 -by transfer (rule le_add1)
   5.161 +lemma hypnat_le_add1 [simp]: "\<And>x n::hypnat. x \<le> x + n"
   5.162 +  by transfer (rule le_add1)
   5.163  
   5.164 -lemma hypnat_add_self_le [simp]: "!!x n. (x::hypnat) \<le> n + x"
   5.165 -by transfer (rule le_add2)
   5.166 +lemma hypnat_add_self_le [simp]: "\<And>x n::hypnat. x \<le> n + x"
   5.167 +  by transfer (rule le_add2)
   5.168  
   5.169 -lemma hypnat_add_one_self_less [simp]: "(x::hypnat) < x + (1::hypnat)"
   5.170 +lemma hypnat_add_one_self_less [simp]: "x < x + 1" for x :: hypnat
   5.171    by (fact less_add_one)
   5.172  
   5.173 -lemma hypnat_neq0_conv [iff]: "!!n. (n \<noteq> 0) = (0 < (n::hypnat))"
   5.174 -by transfer (rule neq0_conv)
   5.175 +lemma hypnat_neq0_conv [iff]: "\<And>n::hypnat. n \<noteq> 0 \<longleftrightarrow> 0 < n"
   5.176 +  by transfer (rule neq0_conv)
   5.177  
   5.178 -lemma hypnat_gt_zero_iff: "((0::hypnat) < n) = ((1::hypnat) \<le> n)"
   5.179 -by (auto simp add: linorder_not_less [symmetric])
   5.180 +lemma hypnat_gt_zero_iff: "0 < n \<longleftrightarrow> 1 \<le> n" for n :: hypnat
   5.181 +  by (auto simp add: linorder_not_less [symmetric])
   5.182  
   5.183 -lemma hypnat_gt_zero_iff2: "(0 < n) = (\<exists>m. n = m + (1::hypnat))"
   5.184 +lemma hypnat_gt_zero_iff2: "0 < n \<longleftrightarrow> (\<exists>m. n = m + 1)" for n :: hypnat
   5.185    by (auto intro!: add_nonneg_pos exI[of _ "n - 1"] simp: hypnat_gt_zero_iff)
   5.186  
   5.187 -lemma hypnat_add_self_not_less: "~ (x + y < (x::hypnat))"
   5.188 -by (simp add: linorder_not_le [symmetric] add.commute [of x])
   5.189 +lemma hypnat_add_self_not_less: "\<not> x + y < x" for x y :: hypnat
   5.190 +  by (simp add: linorder_not_le [symmetric] add.commute [of x])
   5.191  
   5.192 -lemma hypnat_diff_split:
   5.193 -    "P(a - b::hypnat) = ((a<b --> P 0) & (ALL d. a = b + d --> P d))"
   5.194 -    \<comment> \<open>elimination of \<open>-\<close> on \<open>hypnat\<close>\<close>
   5.195 -proof (cases "a<b" rule: case_split)
   5.196 +lemma hypnat_diff_split: "P (a - b) \<longleftrightarrow> (a < b \<longrightarrow> P 0) \<and> (\<forall>d. a = b + d \<longrightarrow> P d)"
   5.197 +  for a b :: hypnat
   5.198 +  \<comment> \<open>elimination of \<open>-\<close> on \<open>hypnat\<close>\<close>
   5.199 +proof (cases "a < b" rule: case_split)
   5.200    case True
   5.201 -    thus ?thesis
   5.202 -      by (auto simp add: hypnat_add_self_not_less order_less_imp_le
   5.203 -                         hypnat_diff_is_0_eq [THEN iffD2])
   5.204 +  then show ?thesis
   5.205 +    by (auto simp add: hypnat_add_self_not_less order_less_imp_le hypnat_diff_is_0_eq [THEN iffD2])
   5.206  next
   5.207    case False
   5.208 -    thus ?thesis
   5.209 -      by (auto simp add: linorder_not_less dest: order_le_less_trans)
   5.210 +  then show ?thesis
   5.211 +    by (auto simp add: linorder_not_less dest: order_le_less_trans)
   5.212  qed
   5.213  
   5.214 -subsection\<open>Properties of the set of embedded natural numbers\<close>
   5.215 +
   5.216 +subsection \<open>Properties of the set of embedded natural numbers\<close>
   5.217  
   5.218  lemma of_nat_eq_star_of [simp]: "of_nat = star_of"
   5.219  proof
   5.220 -  fix n :: nat
   5.221 -  show "of_nat n = star_of n" by transfer simp
   5.222 +  show "of_nat n = star_of n" for n
   5.223 +    by transfer simp
   5.224  qed
   5.225  
   5.226  lemma Nats_eq_Standard: "(Nats :: nat star set) = Standard"
   5.227 -by (auto simp add: Nats_def Standard_def)
   5.228 +  by (auto simp: Nats_def Standard_def)
   5.229  
   5.230  lemma hypnat_of_nat_mem_Nats [simp]: "hypnat_of_nat n \<in> Nats"
   5.231 -by (simp add: Nats_eq_Standard)
   5.232 +  by (simp add: Nats_eq_Standard)
   5.233  
   5.234 -lemma hypnat_of_nat_one [simp]: "hypnat_of_nat (Suc 0) = (1::hypnat)"
   5.235 -by transfer simp
   5.236 +lemma hypnat_of_nat_one [simp]: "hypnat_of_nat (Suc 0) = 1"
   5.237 +  by transfer simp
   5.238  
   5.239 -lemma hypnat_of_nat_Suc [simp]:
   5.240 -     "hypnat_of_nat (Suc n) = hypnat_of_nat n + (1::hypnat)"
   5.241 -by transfer simp
   5.242 +lemma hypnat_of_nat_Suc [simp]: "hypnat_of_nat (Suc n) = hypnat_of_nat n + 1"
   5.243 +  by transfer simp
   5.244  
   5.245 -lemma of_nat_eq_add [rule_format]:
   5.246 -     "\<forall>d::hypnat. of_nat m = of_nat n + d --> d \<in> range of_nat"
   5.247 -apply (induct n)
   5.248 -apply (auto simp add: add.assoc)
   5.249 -apply (case_tac x)
   5.250 -apply (auto simp add: add.commute [of 1])
   5.251 -done
   5.252 +lemma of_nat_eq_add [rule_format]: "\<forall>d::hypnat. of_nat m = of_nat n + d --> d \<in> range of_nat"
   5.253 +  apply (induct n)
   5.254 +   apply (auto simp add: add.assoc)
   5.255 +  apply (case_tac x)
   5.256 +   apply (auto simp add: add.commute [of 1])
   5.257 +  done
   5.258  
   5.259 -lemma Nats_diff [simp]: "[|a \<in> Nats; b \<in> Nats|] ==> (a-b :: hypnat) \<in> Nats"
   5.260 -by (simp add: Nats_eq_Standard)
   5.261 +lemma Nats_diff [simp]: "a \<in> Nats \<Longrightarrow> b \<in> Nats \<Longrightarrow> a - b \<in> Nats" for a b :: hypnat
   5.262 +  by (simp add: Nats_eq_Standard)
   5.263  
   5.264  
   5.265 -subsection\<open>Infinite Hypernatural Numbers -- @{term HNatInfinite}\<close>
   5.266 +subsection \<open>Infinite Hypernatural Numbers -- @{term HNatInfinite}\<close>
   5.267 +
   5.268 +text \<open>The set of infinite hypernatural numbers.\<close>
   5.269 +definition HNatInfinite :: "hypnat set"
   5.270 +  where "HNatInfinite = {n. n \<notin> Nats}"
   5.271  
   5.272 -definition
   5.273 -  (* the set of infinite hypernatural numbers *)
   5.274 -  HNatInfinite :: "hypnat set" where
   5.275 -  "HNatInfinite = {n. n \<notin> Nats}"
   5.276 +lemma Nats_not_HNatInfinite_iff: "x \<in> Nats \<longleftrightarrow> x \<notin> HNatInfinite"
   5.277 +  by (simp add: HNatInfinite_def)
   5.278  
   5.279 -lemma Nats_not_HNatInfinite_iff: "(x \<in> Nats) = (x \<notin> HNatInfinite)"
   5.280 -by (simp add: HNatInfinite_def)
   5.281 -
   5.282 -lemma HNatInfinite_not_Nats_iff: "(x \<in> HNatInfinite) = (x \<notin> Nats)"
   5.283 -by (simp add: HNatInfinite_def)
   5.284 +lemma HNatInfinite_not_Nats_iff: "x \<in> HNatInfinite \<longleftrightarrow> x \<notin> Nats"
   5.285 +  by (simp add: HNatInfinite_def)
   5.286  
   5.287  lemma star_of_neq_HNatInfinite: "N \<in> HNatInfinite \<Longrightarrow> star_of n \<noteq> N"
   5.288 -by (auto simp add: HNatInfinite_def Nats_eq_Standard)
   5.289 +  by (auto simp add: HNatInfinite_def Nats_eq_Standard)
   5.290  
   5.291 -lemma star_of_Suc_lessI:
   5.292 -  "\<And>N. \<lbrakk>star_of n < N; star_of (Suc n) \<noteq> N\<rbrakk> \<Longrightarrow> star_of (Suc n) < N"
   5.293 -by transfer (rule Suc_lessI)
   5.294 +lemma star_of_Suc_lessI: "\<And>N. star_of n < N \<Longrightarrow> star_of (Suc n) \<noteq> N \<Longrightarrow> star_of (Suc n) < N"
   5.295 +  by transfer (rule Suc_lessI)
   5.296  
   5.297  lemma star_of_less_HNatInfinite:
   5.298    assumes N: "N \<in> HNatInfinite"
   5.299    shows "star_of n < N"
   5.300  proof (induct n)
   5.301    case 0
   5.302 -  from N have "star_of 0 \<noteq> N" by (rule star_of_neq_HNatInfinite)
   5.303 -  thus "star_of 0 < N" by simp
   5.304 +  from N have "star_of 0 \<noteq> N"
   5.305 +    by (rule star_of_neq_HNatInfinite)
   5.306 +  then show ?case by simp
   5.307  next
   5.308    case (Suc n)
   5.309 -  from N have "star_of (Suc n) \<noteq> N" by (rule star_of_neq_HNatInfinite)
   5.310 -  with Suc show "star_of (Suc n) < N" by (rule star_of_Suc_lessI)
   5.311 +  from N have "star_of (Suc n) \<noteq> N"
   5.312 +    by (rule star_of_neq_HNatInfinite)
   5.313 +  with Suc show ?case
   5.314 +    by (rule star_of_Suc_lessI)
   5.315  qed
   5.316  
   5.317  lemma star_of_le_HNatInfinite: "N \<in> HNatInfinite \<Longrightarrow> star_of n \<le> N"
   5.318 -by (rule star_of_less_HNatInfinite [THEN order_less_imp_le])
   5.319 +  by (rule star_of_less_HNatInfinite [THEN order_less_imp_le])
   5.320 +
   5.321  
   5.322  subsubsection \<open>Closure Rules\<close>
   5.323  
   5.324 -lemma Nats_less_HNatInfinite: "\<lbrakk>x \<in> Nats; y \<in> HNatInfinite\<rbrakk> \<Longrightarrow> x < y"
   5.325 -by (auto simp add: Nats_def star_of_less_HNatInfinite)
   5.326 +lemma Nats_less_HNatInfinite: "x \<in> Nats \<Longrightarrow> y \<in> HNatInfinite \<Longrightarrow> x < y"
   5.327 +  by (auto simp add: Nats_def star_of_less_HNatInfinite)
   5.328  
   5.329 -lemma Nats_le_HNatInfinite: "\<lbrakk>x \<in> Nats; y \<in> HNatInfinite\<rbrakk> \<Longrightarrow> x \<le> y"
   5.330 -by (rule Nats_less_HNatInfinite [THEN order_less_imp_le])
   5.331 +lemma Nats_le_HNatInfinite: "x \<in> Nats \<Longrightarrow> y \<in> HNatInfinite \<Longrightarrow> x \<le> y"
   5.332 +  by (rule Nats_less_HNatInfinite [THEN order_less_imp_le])
   5.333  
   5.334  lemma zero_less_HNatInfinite: "x \<in> HNatInfinite \<Longrightarrow> 0 < x"
   5.335 -by (simp add: Nats_less_HNatInfinite)
   5.336 +  by (simp add: Nats_less_HNatInfinite)
   5.337  
   5.338  lemma one_less_HNatInfinite: "x \<in> HNatInfinite \<Longrightarrow> 1 < x"
   5.339 -by (simp add: Nats_less_HNatInfinite)
   5.340 +  by (simp add: Nats_less_HNatInfinite)
   5.341  
   5.342  lemma one_le_HNatInfinite: "x \<in> HNatInfinite \<Longrightarrow> 1 \<le> x"
   5.343 -by (simp add: Nats_le_HNatInfinite)
   5.344 +  by (simp add: Nats_le_HNatInfinite)
   5.345  
   5.346  lemma zero_not_mem_HNatInfinite [simp]: "0 \<notin> HNatInfinite"
   5.347 -by (simp add: HNatInfinite_def)
   5.348 +  by (simp add: HNatInfinite_def)
   5.349  
   5.350 -lemma Nats_downward_closed:
   5.351 -  "\<lbrakk>x \<in> Nats; (y::hypnat) \<le> x\<rbrakk> \<Longrightarrow> y \<in> Nats"
   5.352 -apply (simp only: linorder_not_less [symmetric])
   5.353 -apply (erule contrapos_np)
   5.354 -apply (drule HNatInfinite_not_Nats_iff [THEN iffD2])
   5.355 -apply (erule (1) Nats_less_HNatInfinite)
   5.356 -done
   5.357 +lemma Nats_downward_closed: "x \<in> Nats \<Longrightarrow> y \<le> x \<Longrightarrow> y \<in> Nats" for x y :: hypnat
   5.358 +  apply (simp only: linorder_not_less [symmetric])
   5.359 +  apply (erule contrapos_np)
   5.360 +  apply (drule HNatInfinite_not_Nats_iff [THEN iffD2])
   5.361 +  apply (erule (1) Nats_less_HNatInfinite)
   5.362 +  done
   5.363  
   5.364 -lemma HNatInfinite_upward_closed:
   5.365 -  "\<lbrakk>x \<in> HNatInfinite; x \<le> y\<rbrakk> \<Longrightarrow> y \<in> HNatInfinite"
   5.366 -apply (simp only: HNatInfinite_not_Nats_iff)
   5.367 -apply (erule contrapos_nn)
   5.368 -apply (erule (1) Nats_downward_closed)
   5.369 -done
   5.370 +lemma HNatInfinite_upward_closed: "x \<in> HNatInfinite \<Longrightarrow> x \<le> y \<Longrightarrow> y \<in> HNatInfinite"
   5.371 +  apply (simp only: HNatInfinite_not_Nats_iff)
   5.372 +  apply (erule contrapos_nn)
   5.373 +  apply (erule (1) Nats_downward_closed)
   5.374 +  done
   5.375  
   5.376  lemma HNatInfinite_add: "x \<in> HNatInfinite \<Longrightarrow> x + y \<in> HNatInfinite"
   5.377 -apply (erule HNatInfinite_upward_closed)
   5.378 -apply (rule hypnat_le_add1)
   5.379 -done
   5.380 +  apply (erule HNatInfinite_upward_closed)
   5.381 +  apply (rule hypnat_le_add1)
   5.382 +  done
   5.383  
   5.384  lemma HNatInfinite_add_one: "x \<in> HNatInfinite \<Longrightarrow> x + 1 \<in> HNatInfinite"
   5.385 -by (rule HNatInfinite_add)
   5.386 +  by (rule HNatInfinite_add)
   5.387  
   5.388 -lemma HNatInfinite_diff:
   5.389 -  "\<lbrakk>x \<in> HNatInfinite; y \<in> Nats\<rbrakk> \<Longrightarrow> x - y \<in> HNatInfinite"
   5.390 -apply (frule (1) Nats_le_HNatInfinite)
   5.391 -apply (simp only: HNatInfinite_not_Nats_iff)
   5.392 -apply (erule contrapos_nn)
   5.393 -apply (drule (1) Nats_add, simp)
   5.394 -done
   5.395 +lemma HNatInfinite_diff: "x \<in> HNatInfinite \<Longrightarrow> y \<in> Nats \<Longrightarrow> x - y \<in> HNatInfinite"
   5.396 +  apply (frule (1) Nats_le_HNatInfinite)
   5.397 +  apply (simp only: HNatInfinite_not_Nats_iff)
   5.398 +  apply (erule contrapos_nn)
   5.399 +  apply (drule (1) Nats_add, simp)
   5.400 +  done
   5.401  
   5.402 -lemma HNatInfinite_is_Suc: "x \<in> HNatInfinite ==> \<exists>y. x = y + (1::hypnat)"
   5.403 -apply (rule_tac x = "x - (1::hypnat) " in exI)
   5.404 -apply (simp add: Nats_le_HNatInfinite)
   5.405 -done
   5.406 +lemma HNatInfinite_is_Suc: "x \<in> HNatInfinite \<Longrightarrow> \<exists>y. x = y + 1" for x :: hypnat
   5.407 +  apply (rule_tac x = "x - (1::hypnat) " in exI)
   5.408 +  apply (simp add: Nats_le_HNatInfinite)
   5.409 +  done
   5.410  
   5.411  
   5.412 -subsection\<open>Existence of an infinite hypernatural number\<close>
   5.413 +subsection \<open>Existence of an infinite hypernatural number\<close>
   5.414  
   5.415 -definition
   5.416 -  (* \<omega> is in fact an infinite hypernatural number = [<1,2,3,...>] *)
   5.417 -  whn :: hypnat where
   5.418 -  hypnat_omega_def: "whn = star_n (%n::nat. n)"
   5.419 +text \<open>\<open>\<omega>\<close> is in fact an infinite hypernatural number = \<open>[<1, 2, 3, \<dots>>]\<close>\<close>
   5.420 +definition whn :: hypnat
   5.421 +  where hypnat_omega_def: "whn = star_n (\<lambda>n::nat. n)"
   5.422  
   5.423  lemma hypnat_of_nat_neq_whn: "hypnat_of_nat n \<noteq> whn"
   5.424 -by (simp add: FreeUltrafilterNat.singleton' hypnat_omega_def star_of_def star_n_eq_iff)
   5.425 +  by (simp add: FreeUltrafilterNat.singleton' hypnat_omega_def star_of_def star_n_eq_iff)
   5.426  
   5.427  lemma whn_neq_hypnat_of_nat: "whn \<noteq> hypnat_of_nat n"
   5.428 -by (simp add: FreeUltrafilterNat.singleton hypnat_omega_def star_of_def star_n_eq_iff)
   5.429 +  by (simp add: FreeUltrafilterNat.singleton hypnat_omega_def star_of_def star_n_eq_iff)
   5.430  
   5.431  lemma whn_not_Nats [simp]: "whn \<notin> Nats"
   5.432 -by (simp add: Nats_def image_def whn_neq_hypnat_of_nat)
   5.433 +  by (simp add: Nats_def image_def whn_neq_hypnat_of_nat)
   5.434  
   5.435  lemma HNatInfinite_whn [simp]: "whn \<in> HNatInfinite"
   5.436 -by (simp add: HNatInfinite_def)
   5.437 +  by (simp add: HNatInfinite_def)
   5.438  
   5.439  lemma lemma_unbounded_set [simp]: "eventually (\<lambda>n::nat. m < n) \<U>"
   5.440    by (rule filter_leD[OF FreeUltrafilterNat.le_cofinite])
   5.441       (auto simp add: cofinite_eq_sequentially eventually_at_top_dense)
   5.442  
   5.443 -lemma hypnat_of_nat_eq:
   5.444 -     "hypnat_of_nat m  = star_n (%n::nat. m)"
   5.445 -by (simp add: star_of_def)
   5.446 +lemma hypnat_of_nat_eq: "hypnat_of_nat m  = star_n (\<lambda>n::nat. m)"
   5.447 +  by (simp add: star_of_def)
   5.448  
   5.449  lemma SHNat_eq: "Nats = {n. \<exists>N. n = hypnat_of_nat N}"
   5.450 -by (simp add: Nats_def image_def)
   5.451 +  by (simp add: Nats_def image_def)
   5.452  
   5.453  lemma Nats_less_whn: "n \<in> Nats \<Longrightarrow> n < whn"
   5.454 -by (simp add: Nats_less_HNatInfinite)
   5.455 +  by (simp add: Nats_less_HNatInfinite)
   5.456  
   5.457  lemma Nats_le_whn: "n \<in> Nats \<Longrightarrow> n \<le> whn"
   5.458 -by (simp add: Nats_le_HNatInfinite)
   5.459 +  by (simp add: Nats_le_HNatInfinite)
   5.460  
   5.461  lemma hypnat_of_nat_less_whn [simp]: "hypnat_of_nat n < whn"
   5.462 -by (simp add: Nats_less_whn)
   5.463 +  by (simp add: Nats_less_whn)
   5.464  
   5.465  lemma hypnat_of_nat_le_whn [simp]: "hypnat_of_nat n \<le> whn"
   5.466 -by (simp add: Nats_le_whn)
   5.467 +  by (simp add: Nats_le_whn)
   5.468  
   5.469  lemma hypnat_zero_less_hypnat_omega [simp]: "0 < whn"
   5.470 -by (simp add: Nats_less_whn)
   5.471 +  by (simp add: Nats_less_whn)
   5.472  
   5.473  lemma hypnat_one_less_hypnat_omega [simp]: "1 < whn"
   5.474 -by (simp add: Nats_less_whn)
   5.475 +  by (simp add: Nats_less_whn)
   5.476  
   5.477  
   5.478 -subsubsection\<open>Alternative characterization of the set of infinite hypernaturals\<close>
   5.479 +subsubsection \<open>Alternative characterization of the set of infinite hypernaturals\<close>
   5.480  
   5.481 -text\<open>@{term "HNatInfinite = {N. \<forall>n \<in> Nats. n < N}"}\<close>
   5.482 +text \<open>@{term "HNatInfinite = {N. \<forall>n \<in> Nats. n < N}"}\<close>
   5.483  
   5.484  (*??delete? similar reasoning in hypnat_omega_gt_SHNat above*)
   5.485  lemma HNatInfinite_FreeUltrafilterNat_lemma:
   5.486    assumes "\<forall>N::nat. eventually (\<lambda>n. f n \<noteq> N) \<U>"
   5.487    shows "eventually (\<lambda>n. N < f n) \<U>"
   5.488 -apply (induct N)
   5.489 -using assms
   5.490 -apply (drule_tac x = 0 in spec, simp)
   5.491 -using assms
   5.492 -apply (drule_tac x = "Suc N" in spec)
   5.493 -apply (auto elim: eventually_elim2)
   5.494 -done
   5.495 +  apply (induct N)
   5.496 +  using assms
   5.497 +   apply (drule_tac x = 0 in spec, simp)
   5.498 +  using assms
   5.499 +  apply (drule_tac x = "Suc N" in spec)
   5.500 +  apply (auto elim: eventually_elim2)
   5.501 +  done
   5.502  
   5.503  lemma HNatInfinite_iff: "HNatInfinite = {N. \<forall>n \<in> Nats. n < N}"
   5.504 -apply (safe intro!: Nats_less_HNatInfinite)
   5.505 -apply (auto simp add: HNatInfinite_def)
   5.506 -done
   5.507 +  apply (safe intro!: Nats_less_HNatInfinite)
   5.508 +  apply (auto simp add: HNatInfinite_def)
   5.509 +  done
   5.510  
   5.511  
   5.512 -subsubsection\<open>Alternative Characterization of @{term HNatInfinite} using
   5.513 -Free Ultrafilter\<close>
   5.514 +subsubsection \<open>Alternative Characterization of @{term HNatInfinite} using Free Ultrafilter\<close>
   5.515  
   5.516  lemma HNatInfinite_FreeUltrafilterNat:
   5.517 -     "star_n X \<in> HNatInfinite ==> \<forall>u. eventually (\<lambda>n. u < X n) FreeUltrafilterNat"
   5.518 -apply (auto simp add: HNatInfinite_iff SHNat_eq)
   5.519 -apply (drule_tac x="star_of u" in spec, simp)
   5.520 -apply (simp add: star_of_def star_less_def starP2_star_n)
   5.521 -done
   5.522 +  "star_n X \<in> HNatInfinite \<Longrightarrow> \<forall>u. eventually (\<lambda>n. u < X n) FreeUltrafilterNat"
   5.523 +  apply (auto simp add: HNatInfinite_iff SHNat_eq)
   5.524 +  apply (drule_tac x="star_of u" in spec, simp)
   5.525 +  apply (simp add: star_of_def star_less_def starP2_star_n)
   5.526 +  done
   5.527  
   5.528  lemma FreeUltrafilterNat_HNatInfinite:
   5.529 -     "\<forall>u. eventually (\<lambda>n. u < X n) FreeUltrafilterNat ==> star_n X \<in> HNatInfinite"
   5.530 -by (auto simp add: star_less_def starP2_star_n HNatInfinite_iff SHNat_eq hypnat_of_nat_eq)
   5.531 +  "\<forall>u. eventually (\<lambda>n. u < X n) FreeUltrafilterNat \<Longrightarrow> star_n X \<in> HNatInfinite"
   5.532 +  by (auto simp add: star_less_def starP2_star_n HNatInfinite_iff SHNat_eq hypnat_of_nat_eq)
   5.533  
   5.534  lemma HNatInfinite_FreeUltrafilterNat_iff:
   5.535 -     "(star_n X \<in> HNatInfinite) = (\<forall>u. eventually (\<lambda>n. u < X n) FreeUltrafilterNat)"
   5.536 -by (rule iffI [OF HNatInfinite_FreeUltrafilterNat
   5.537 -                 FreeUltrafilterNat_HNatInfinite])
   5.538 +  "(star_n X \<in> HNatInfinite) = (\<forall>u. eventually (\<lambda>n. u < X n) FreeUltrafilterNat)"
   5.539 +  by (rule iffI [OF HNatInfinite_FreeUltrafilterNat FreeUltrafilterNat_HNatInfinite])
   5.540 +
   5.541  
   5.542  subsection \<open>Embedding of the Hypernaturals into other types\<close>
   5.543  
   5.544 -definition
   5.545 -  of_hypnat :: "hypnat \<Rightarrow> 'a::semiring_1_cancel star" where
   5.546 -  of_hypnat_def [transfer_unfold]: "of_hypnat = *f* of_nat"
   5.547 +definition of_hypnat :: "hypnat \<Rightarrow> 'a::semiring_1_cancel star"
   5.548 +  where of_hypnat_def [transfer_unfold]: "of_hypnat = *f* of_nat"
   5.549  
   5.550  lemma of_hypnat_0 [simp]: "of_hypnat 0 = 0"
   5.551 -by transfer (rule of_nat_0)
   5.552 +  by transfer (rule of_nat_0)
   5.553  
   5.554  lemma of_hypnat_1 [simp]: "of_hypnat 1 = 1"
   5.555 -by transfer (rule of_nat_1)
   5.556 +  by transfer (rule of_nat_1)
   5.557  
   5.558  lemma of_hypnat_hSuc: "\<And>m. of_hypnat (hSuc m) = 1 + of_hypnat m"
   5.559 -by transfer (rule of_nat_Suc)
   5.560 +  by transfer (rule of_nat_Suc)
   5.561  
   5.562 -lemma of_hypnat_add [simp]:
   5.563 -  "\<And>m n. of_hypnat (m + n) = of_hypnat m + of_hypnat n"
   5.564 -by transfer (rule of_nat_add)
   5.565 +lemma of_hypnat_add [simp]: "\<And>m n. of_hypnat (m + n) = of_hypnat m + of_hypnat n"
   5.566 +  by transfer (rule of_nat_add)
   5.567  
   5.568 -lemma of_hypnat_mult [simp]:
   5.569 -  "\<And>m n. of_hypnat (m * n) = of_hypnat m * of_hypnat n"
   5.570 -by transfer (rule of_nat_mult)
   5.571 +lemma of_hypnat_mult [simp]: "\<And>m n. of_hypnat (m * n) = of_hypnat m * of_hypnat n"
   5.572 +  by transfer (rule of_nat_mult)
   5.573  
   5.574  lemma of_hypnat_less_iff [simp]:
   5.575 -  "\<And>m n. (of_hypnat m < (of_hypnat n::'a::linordered_semidom star)) = (m < n)"
   5.576 -by transfer (rule of_nat_less_iff)
   5.577 +  "\<And>m n. of_hypnat m < (of_hypnat n::'a::linordered_semidom star) \<longleftrightarrow> m < n"
   5.578 +  by transfer (rule of_nat_less_iff)
   5.579  
   5.580  lemma of_hypnat_0_less_iff [simp]:
   5.581 -  "\<And>n. (0 < (of_hypnat n::'a::linordered_semidom star)) = (0 < n)"
   5.582 -by transfer (rule of_nat_0_less_iff)
   5.583 +  "\<And>n. 0 < (of_hypnat n::'a::linordered_semidom star) \<longleftrightarrow> 0 < n"
   5.584 +  by transfer (rule of_nat_0_less_iff)
   5.585  
   5.586 -lemma of_hypnat_less_0_iff [simp]:
   5.587 -  "\<And>m. \<not> (of_hypnat m::'a::linordered_semidom star) < 0"
   5.588 -by transfer (rule of_nat_less_0_iff)
   5.589 +lemma of_hypnat_less_0_iff [simp]: "\<And>m. \<not> (of_hypnat m::'a::linordered_semidom star) < 0"
   5.590 +  by transfer (rule of_nat_less_0_iff)
   5.591  
   5.592  lemma of_hypnat_le_iff [simp]:
   5.593 -  "\<And>m n. (of_hypnat m \<le> (of_hypnat n::'a::linordered_semidom star)) = (m \<le> n)"
   5.594 -by transfer (rule of_nat_le_iff)
   5.595 +  "\<And>m n. of_hypnat m \<le> (of_hypnat n::'a::linordered_semidom star) \<longleftrightarrow> m \<le> n"
   5.596 +  by transfer (rule of_nat_le_iff)
   5.597  
   5.598 -lemma of_hypnat_0_le_iff [simp]:
   5.599 -  "\<And>n. 0 \<le> (of_hypnat n::'a::linordered_semidom star)"
   5.600 -by transfer (rule of_nat_0_le_iff)
   5.601 +lemma of_hypnat_0_le_iff [simp]: "\<And>n. 0 \<le> (of_hypnat n::'a::linordered_semidom star)"
   5.602 +  by transfer (rule of_nat_0_le_iff)
   5.603  
   5.604 -lemma of_hypnat_le_0_iff [simp]:
   5.605 -  "\<And>m. ((of_hypnat m::'a::linordered_semidom star) \<le> 0) = (m = 0)"
   5.606 -by transfer (rule of_nat_le_0_iff)
   5.607 +lemma of_hypnat_le_0_iff [simp]: "\<And>m. (of_hypnat m::'a::linordered_semidom star) \<le> 0 \<longleftrightarrow> m = 0"
   5.608 +  by transfer (rule of_nat_le_0_iff)
   5.609  
   5.610  lemma of_hypnat_eq_iff [simp]:
   5.611 -  "\<And>m n. (of_hypnat m = (of_hypnat n::'a::linordered_semidom star)) = (m = n)"
   5.612 -by transfer (rule of_nat_eq_iff)
   5.613 +  "\<And>m n. of_hypnat m = (of_hypnat n::'a::linordered_semidom star) \<longleftrightarrow> m = n"
   5.614 +  by transfer (rule of_nat_eq_iff)
   5.615  
   5.616 -lemma of_hypnat_eq_0_iff [simp]:
   5.617 -  "\<And>m. ((of_hypnat m::'a::linordered_semidom star) = 0) = (m = 0)"
   5.618 -by transfer (rule of_nat_eq_0_iff)
   5.619 +lemma of_hypnat_eq_0_iff [simp]: "\<And>m. (of_hypnat m::'a::linordered_semidom star) = 0 \<longleftrightarrow> m = 0"
   5.620 +  by transfer (rule of_nat_eq_0_iff)
   5.621  
   5.622  lemma HNatInfinite_of_hypnat_gt_zero:
   5.623    "N \<in> HNatInfinite \<Longrightarrow> (0::'a::linordered_semidom star) < of_hypnat N"
   5.624 -by (rule ccontr, simp add: linorder_not_less)
   5.625 +  by (rule ccontr) (simp add: linorder_not_less)
   5.626  
   5.627  end
     6.1 --- a/src/HOL/Nonstandard_Analysis/NSA.thy	Mon Oct 31 16:26:36 2016 +0100
     6.2 +++ b/src/HOL/Nonstandard_Analysis/NSA.thy	Tue Nov 01 00:44:24 2016 +0100
     6.3 @@ -3,649 +3,584 @@
     6.4      Author:     Lawrence C Paulson, University of Cambridge
     6.5  *)
     6.6  
     6.7 -section\<open>Infinite Numbers, Infinitesimals, Infinitely Close Relation\<close>
     6.8 +section \<open>Infinite Numbers, Infinitesimals, Infinitely Close Relation\<close>
     6.9  
    6.10  theory NSA
    6.11 -imports HyperDef "~~/src/HOL/Library/Lub_Glb"
    6.12 +  imports HyperDef "~~/src/HOL/Library/Lub_Glb"
    6.13  begin
    6.14  
    6.15 -definition
    6.16 -  hnorm :: "'a::real_normed_vector star \<Rightarrow> real star" where
    6.17 -  [transfer_unfold]: "hnorm = *f* norm"
    6.18 +definition hnorm :: "'a::real_normed_vector star \<Rightarrow> real star"
    6.19 +  where [transfer_unfold]: "hnorm = *f* norm"
    6.20  
    6.21 -definition
    6.22 -  Infinitesimal  :: "('a::real_normed_vector) star set" where
    6.23 -  "Infinitesimal = {x. \<forall>r \<in> Reals. 0 < r --> hnorm x < r}"
    6.24 +definition Infinitesimal  :: "('a::real_normed_vector) star set"
    6.25 +  where "Infinitesimal = {x. \<forall>r \<in> Reals. 0 < r \<longrightarrow> hnorm x < r}"
    6.26  
    6.27 -definition
    6.28 -  HFinite :: "('a::real_normed_vector) star set" where
    6.29 -  "HFinite = {x. \<exists>r \<in> Reals. hnorm x < r}"
    6.30 +definition HFinite :: "('a::real_normed_vector) star set"
    6.31 +  where "HFinite = {x. \<exists>r \<in> Reals. hnorm x < r}"
    6.32  
    6.33 -definition
    6.34 -  HInfinite :: "('a::real_normed_vector) star set" where
    6.35 -  "HInfinite = {x. \<forall>r \<in> Reals. r < hnorm x}"
    6.36 +definition HInfinite :: "('a::real_normed_vector) star set"
    6.37 +  where "HInfinite = {x. \<forall>r \<in> Reals. r < hnorm x}"
    6.38  
    6.39 -definition
    6.40 -  approx :: "['a::real_normed_vector star, 'a star] => bool"  (infixl "\<approx>" 50) where
    6.41 -    \<comment>\<open>the `infinitely close' relation\<close>
    6.42 -  "(x \<approx> y) = ((x - y) \<in> Infinitesimal)"
    6.43 +definition approx :: "'a::real_normed_vector star \<Rightarrow> 'a star \<Rightarrow> bool"  (infixl "\<approx>" 50)
    6.44 +  where "x \<approx> y \<longleftrightarrow> x - y \<in> Infinitesimal"
    6.45 +    \<comment> \<open>the ``infinitely close'' relation\<close>
    6.46  
    6.47 -definition
    6.48 -  st        :: "hypreal => hypreal" where
    6.49 -    \<comment>\<open>the standard part of a hyperreal\<close>
    6.50 -  "st = (%x. @r. x \<in> HFinite & r \<in> \<real> & r \<approx> x)"
    6.51 +definition st :: "hypreal \<Rightarrow> hypreal"
    6.52 +  where "st = (\<lambda>x. SOME r. x \<in> HFinite \<and> r \<in> \<real> \<and> r \<approx> x)"
    6.53 +    \<comment> \<open>the standard part of a hyperreal\<close>
    6.54  
    6.55 -definition
    6.56 -  monad     :: "'a::real_normed_vector star => 'a star set" where
    6.57 -  "monad x = {y. x \<approx> y}"
    6.58 +definition monad :: "'a::real_normed_vector star \<Rightarrow> 'a star set"
    6.59 +  where "monad x = {y. x \<approx> y}"
    6.60  
    6.61 -definition
    6.62 -  galaxy    :: "'a::real_normed_vector star => 'a star set" where
    6.63 -  "galaxy x = {y. (x + -y) \<in> HFinite}"
    6.64 +definition galaxy :: "'a::real_normed_vector star \<Rightarrow> 'a star set"
    6.65 +  where "galaxy x = {y. (x + -y) \<in> HFinite}"
    6.66  
    6.67 -lemma SReal_def: "\<real> == {x. \<exists>r. x = hypreal_of_real r}"
    6.68 -by (simp add: Reals_def image_def)
    6.69 +lemma SReal_def: "\<real> \<equiv> {x. \<exists>r. x = hypreal_of_real r}"
    6.70 +  by (simp add: Reals_def image_def)
    6.71 +
    6.72  
    6.73  subsection \<open>Nonstandard Extension of the Norm Function\<close>
    6.74  
    6.75 -definition
    6.76 -  scaleHR :: "real star \<Rightarrow> 'a star \<Rightarrow> 'a::real_normed_vector star" where
    6.77 -  [transfer_unfold]: "scaleHR = starfun2 scaleR"
    6.78 +definition scaleHR :: "real star \<Rightarrow> 'a star \<Rightarrow> 'a::real_normed_vector star"
    6.79 +  where [transfer_unfold]: "scaleHR = starfun2 scaleR"
    6.80  
    6.81  lemma Standard_hnorm [simp]: "x \<in> Standard \<Longrightarrow> hnorm x \<in> Standard"
    6.82 -by (simp add: hnorm_def)
    6.83 +  by (simp add: hnorm_def)
    6.84  
    6.85  lemma star_of_norm [simp]: "star_of (norm x) = hnorm (star_of x)"
    6.86 -by transfer (rule refl)
    6.87 +  by transfer (rule refl)
    6.88  
    6.89 -lemma hnorm_ge_zero [simp]:
    6.90 -  "\<And>x::'a::real_normed_vector star. 0 \<le> hnorm x"
    6.91 -by transfer (rule norm_ge_zero)
    6.92 +lemma hnorm_ge_zero [simp]: "\<And>x::'a::real_normed_vector star. 0 \<le> hnorm x"
    6.93 +  by transfer (rule norm_ge_zero)
    6.94  
    6.95 -lemma hnorm_eq_zero [simp]:
    6.96 -  "\<And>x::'a::real_normed_vector star. (hnorm x = 0) = (x = 0)"
    6.97 -by transfer (rule norm_eq_zero)
    6.98 +lemma hnorm_eq_zero [simp]: "\<And>x::'a::real_normed_vector star. hnorm x = 0 \<longleftrightarrow> x = 0"
    6.99 +  by transfer (rule norm_eq_zero)
   6.100  
   6.101 -lemma hnorm_triangle_ineq:
   6.102 -  "\<And>x y::'a::real_normed_vector star. hnorm (x + y) \<le> hnorm x + hnorm y"
   6.103 -by transfer (rule norm_triangle_ineq)
   6.104 -
   6.105 -lemma hnorm_triangle_ineq3:
   6.106 -  "\<And>x y::'a::real_normed_vector star. \<bar>hnorm x - hnorm y\<bar> \<le> hnorm (x - y)"
   6.107 -by transfer (rule norm_triangle_ineq3)
   6.108 +lemma hnorm_triangle_ineq: "\<And>x y::'a::real_normed_vector star. hnorm (x + y) \<le> hnorm x + hnorm y"
   6.109 +  by transfer (rule norm_triangle_ineq)
   6.110  
   6.111 -lemma hnorm_scaleR:
   6.112 -  "\<And>x::'a::real_normed_vector star.
   6.113 -   hnorm (a *\<^sub>R x) = \<bar>star_of a\<bar> * hnorm x"
   6.114 -by transfer (rule norm_scaleR)
   6.115 +lemma hnorm_triangle_ineq3: "\<And>x y::'a::real_normed_vector star. \<bar>hnorm x - hnorm y\<bar> \<le> hnorm (x - y)"
   6.116 +  by transfer (rule norm_triangle_ineq3)
   6.117 +
   6.118 +lemma hnorm_scaleR: "\<And>x::'a::real_normed_vector star. hnorm (a *\<^sub>R x) = \<bar>star_of a\<bar> * hnorm x"
   6.119 +  by transfer (rule norm_scaleR)
   6.120  
   6.121 -lemma hnorm_scaleHR:
   6.122 -  "\<And>a (x::'a::real_normed_vector star).
   6.123 -   hnorm (scaleHR a x) = \<bar>a\<bar> * hnorm x"
   6.124 -by transfer (rule norm_scaleR)
   6.125 +lemma hnorm_scaleHR: "\<And>a (x::'a::real_normed_vector star). hnorm (scaleHR a x) = \<bar>a\<bar> * hnorm x"
   6.126 +  by transfer (rule norm_scaleR)
   6.127  
   6.128 -lemma hnorm_mult_ineq:
   6.129 -  "\<And>x y::'a::real_normed_algebra star. hnorm (x * y) \<le> hnorm x * hnorm y"
   6.130 -by transfer (rule norm_mult_ineq)
   6.131 +lemma hnorm_mult_ineq: "\<And>x y::'a::real_normed_algebra star. hnorm (x * y) \<le> hnorm x * hnorm y"
   6.132 +  by transfer (rule norm_mult_ineq)
   6.133  
   6.134 -lemma hnorm_mult:
   6.135 -  "\<And>x y::'a::real_normed_div_algebra star. hnorm (x * y) = hnorm x * hnorm y"
   6.136 -by transfer (rule norm_mult)
   6.137 +lemma hnorm_mult: "\<And>x y::'a::real_normed_div_algebra star. hnorm (x * y) = hnorm x * hnorm y"
   6.138 +  by transfer (rule norm_mult)
   6.139  
   6.140 -lemma hnorm_hyperpow:
   6.141 -  "\<And>(x::'a::{real_normed_div_algebra} star) n.
   6.142 -   hnorm (x pow n) = hnorm x pow n"
   6.143 -by transfer (rule norm_power)
   6.144 +lemma hnorm_hyperpow: "\<And>(x::'a::{real_normed_div_algebra} star) n. hnorm (x pow n) = hnorm x pow n"
   6.145 +  by transfer (rule norm_power)
   6.146 +
   6.147 +lemma hnorm_one [simp]: "hnorm (1::'a::real_normed_div_algebra star) = 1"
   6.148 +  by transfer (rule norm_one)
   6.149  
   6.150 -lemma hnorm_one [simp]:
   6.151 -  "hnorm (1::'a::real_normed_div_algebra star) = 1"
   6.152 -by transfer (rule norm_one)
   6.153 +lemma hnorm_zero [simp]: "hnorm (0::'a::real_normed_vector star) = 0"
   6.154 +  by transfer (rule norm_zero)
   6.155  
   6.156 -lemma hnorm_zero [simp]:
   6.157 -  "hnorm (0::'a::real_normed_vector star) = 0"
   6.158 -by transfer (rule norm_zero)
   6.159 +lemma zero_less_hnorm_iff [simp]: "\<And>x::'a::real_normed_vector star. 0 < hnorm x \<longleftrightarrow> x \<noteq> 0"
   6.160 +  by transfer (rule zero_less_norm_iff)
   6.161  
   6.162 -lemma zero_less_hnorm_iff [simp]:
   6.163 -  "\<And>x::'a::real_normed_vector star. (0 < hnorm x) = (x \<noteq> 0)"
   6.164 -by transfer (rule zero_less_norm_iff)
   6.165 +lemma hnorm_minus_cancel [simp]: "\<And>x::'a::real_normed_vector star. hnorm (- x) = hnorm x"
   6.166 +  by transfer (rule norm_minus_cancel)
   6.167  
   6.168 -lemma hnorm_minus_cancel [simp]:
   6.169 -  "\<And>x::'a::real_normed_vector star. hnorm (- x) = hnorm x"
   6.170 -by transfer (rule norm_minus_cancel)
   6.171 +lemma hnorm_minus_commute: "\<And>a b::'a::real_normed_vector star. hnorm (a - b) = hnorm (b - a)"
   6.172 +  by transfer (rule norm_minus_commute)
   6.173  
   6.174 -lemma hnorm_minus_commute:
   6.175 -  "\<And>a b::'a::real_normed_vector star. hnorm (a - b) = hnorm (b - a)"
   6.176 -by transfer (rule norm_minus_commute)
   6.177 -
   6.178 -lemma hnorm_triangle_ineq2:
   6.179 -  "\<And>a b::'a::real_normed_vector star. hnorm a - hnorm b \<le> hnorm (a - b)"
   6.180 -by transfer (rule norm_triangle_ineq2)
   6.181 +lemma hnorm_triangle_ineq2: "\<And>a b::'a::real_normed_vector star. hnorm a - hnorm b \<le> hnorm (a - b)"
   6.182 +  by transfer (rule norm_triangle_ineq2)
   6.183  
   6.184 -lemma hnorm_triangle_ineq4:
   6.185 -  "\<And>a b::'a::real_normed_vector star. hnorm (a - b) \<le> hnorm a + hnorm b"
   6.186 -by transfer (rule norm_triangle_ineq4)
   6.187 +lemma hnorm_triangle_ineq4: "\<And>a b::'a::real_normed_vector star. hnorm (a - b) \<le> hnorm a + hnorm b"
   6.188 +  by transfer (rule norm_triangle_ineq4)
   6.189  
   6.190 -lemma abs_hnorm_cancel [simp]:
   6.191 -  "\<And>a::'a::real_normed_vector star. \<bar>hnorm a\<bar> = hnorm a"
   6.192 -by transfer (rule abs_norm_cancel)
   6.193 +lemma abs_hnorm_cancel [simp]: "\<And>a::'a::real_normed_vector star. \<bar>hnorm a\<bar> = hnorm a"
   6.194 +  by transfer (rule abs_norm_cancel)
   6.195  
   6.196 -lemma hnorm_of_hypreal [simp]:
   6.197 -  "\<And>r. hnorm (of_hypreal r::'a::real_normed_algebra_1 star) = \<bar>r\<bar>"
   6.198 -by transfer (rule norm_of_real)
   6.199 +lemma hnorm_of_hypreal [simp]: "\<And>r. hnorm (of_hypreal r::'a::real_normed_algebra_1 star) = \<bar>r\<bar>"
   6.200 +  by transfer (rule norm_of_real)
   6.201  
   6.202  lemma nonzero_hnorm_inverse:
   6.203 -  "\<And>a::'a::real_normed_div_algebra star.
   6.204 -   a \<noteq> 0 \<Longrightarrow> hnorm (inverse a) = inverse (hnorm a)"
   6.205 -by transfer (rule nonzero_norm_inverse)
   6.206 +  "\<And>a::'a::real_normed_div_algebra star. a \<noteq> 0 \<Longrightarrow> hnorm (inverse a) = inverse (hnorm a)"
   6.207 +  by transfer (rule nonzero_norm_inverse)
   6.208  
   6.209  lemma hnorm_inverse:
   6.210 -  "\<And>a::'a::{real_normed_div_algebra, division_ring} star.
   6.211 -   hnorm (inverse a) = inverse (hnorm a)"
   6.212 -by transfer (rule norm_inverse)
   6.213 +  "\<And>a::'a::{real_normed_div_algebra, division_ring} star. hnorm (inverse a) = inverse (hnorm a)"
   6.214 +  by transfer (rule norm_inverse)
   6.215  
   6.216 -lemma hnorm_divide:
   6.217 -  "\<And>a b::'a::{real_normed_field, field} star.
   6.218 -   hnorm (a / b) = hnorm a / hnorm b"
   6.219 -by transfer (rule norm_divide)
   6.220 +lemma hnorm_divide: "\<And>a b::'a::{real_normed_field, field} star. hnorm (a / b) = hnorm a / hnorm b"
   6.221 +  by transfer (rule norm_divide)
   6.222  
   6.223 -lemma hypreal_hnorm_def [simp]:
   6.224 -  "\<And>r::hypreal. hnorm r = \<bar>r\<bar>"
   6.225 -by transfer (rule real_norm_def)
   6.226 +lemma hypreal_hnorm_def [simp]: "\<And>r::hypreal. hnorm r = \<bar>r\<bar>"
   6.227 +  by transfer (rule real_norm_def)
   6.228  
   6.229  lemma hnorm_add_less:
   6.230 -  "\<And>(x::'a::real_normed_vector star) y r s.
   6.231 -   \<lbrakk>hnorm x < r; hnorm y < s\<rbrakk> \<Longrightarrow> hnorm (x + y) < r + s"
   6.232 -by transfer (rule norm_add_less)
   6.233 +  "\<And>(x::'a::real_normed_vector star) y r s. hnorm x < r \<Longrightarrow> hnorm y < s \<Longrightarrow> hnorm (x + y) < r + s"
   6.234 +  by transfer (rule norm_add_less)
   6.235  
   6.236  lemma hnorm_mult_less:
   6.237 -  "\<And>(x::'a::real_normed_algebra star) y r s.
   6.238 -   \<lbrakk>hnorm x < r; hnorm y < s\<rbrakk> \<Longrightarrow> hnorm (x * y) < r * s"
   6.239 -by transfer (rule norm_mult_less)
   6.240 +  "\<And>(x::'a::real_normed_algebra star) y r s. hnorm x < r \<Longrightarrow> hnorm y < s \<Longrightarrow> hnorm (x * y) < r * s"
   6.241 +  by transfer (rule norm_mult_less)
   6.242  
   6.243 -lemma hnorm_scaleHR_less:
   6.244 -  "\<lbrakk>\<bar>x\<bar> < r; hnorm y < s\<rbrakk> \<Longrightarrow> hnorm (scaleHR x y) < r * s"
   6.245 -apply (simp only: hnorm_scaleHR)
   6.246 -apply (simp add: mult_strict_mono')
   6.247 -done
   6.248 +lemma hnorm_scaleHR_less: "\<bar>x\<bar> < r \<Longrightarrow> hnorm y < s \<Longrightarrow> hnorm (scaleHR x y) < r * s"
   6.249 + by (simp only: hnorm_scaleHR) (simp add: mult_strict_mono')
   6.250 +
   6.251 +
   6.252 +subsection \<open>Closure Laws for the Standard Reals\<close>
   6.253  
   6.254 -subsection\<open>Closure Laws for the Standard Reals\<close>
   6.255 +lemma Reals_minus_iff [simp]: "- x \<in> \<real> \<longleftrightarrow> x \<in> \<real>"
   6.256 +  apply auto
   6.257 +  apply (drule Reals_minus)
   6.258 +  apply auto
   6.259 +  done
   6.260  
   6.261 -lemma Reals_minus_iff [simp]: "(-x \<in> \<real>) = (x \<in> \<real>)"
   6.262 -apply auto
   6.263 -apply (drule Reals_minus, auto)
   6.264 -done
   6.265 +lemma Reals_add_cancel: "x + y \<in> \<real> \<Longrightarrow> y \<in> \<real> \<Longrightarrow> x \<in> \<real>"
   6.266 +  by (drule (1) Reals_diff) simp
   6.267  
   6.268 -lemma Reals_add_cancel: "\<lbrakk>x + y \<in> \<real>; y \<in> \<real>\<rbrakk> \<Longrightarrow> x \<in> \<real>"
   6.269 -by (drule (1) Reals_diff, simp)
   6.270 -
   6.271 -lemma SReal_hrabs: "(x::hypreal) \<in> \<real> ==> \<bar>x\<bar> \<in> \<real>"
   6.272 -by (simp add: Reals_eq_Standard)
   6.273 +lemma SReal_hrabs: "x \<in> \<real> \<Longrightarrow> \<bar>x\<bar> \<in> \<real>"
   6.274 +  for x :: hypreal
   6.275 +  by (simp add: Reals_eq_Standard)
   6.276  
   6.277  lemma SReal_hypreal_of_real [simp]: "hypreal_of_real x \<in> \<real>"
   6.278 -by (simp add: Reals_eq_Standard)
   6.279 +  by (simp add: Reals_eq_Standard)
   6.280  
   6.281 -lemma SReal_divide_numeral: "r \<in> \<real> ==> r/(numeral w::hypreal) \<in> \<real>"
   6.282 -by simp
   6.283 +lemma SReal_divide_numeral: "r \<in> \<real> \<Longrightarrow> r / (numeral w::hypreal) \<in> \<real>"
   6.284 +  by simp
   6.285  
   6.286  text \<open>\<open>\<epsilon>\<close> is not in Reals because it is an infinitesimal\<close>
   6.287  lemma SReal_epsilon_not_mem: "\<epsilon> \<notin> \<real>"
   6.288 -apply (simp add: SReal_def)
   6.289 -apply (auto simp add: hypreal_of_real_not_eq_epsilon [THEN not_sym])
   6.290 -done
   6.291 +  by (auto simp: SReal_def hypreal_of_real_not_eq_epsilon [symmetric])
   6.292  
   6.293  lemma SReal_omega_not_mem: "\<omega> \<notin> \<real>"
   6.294 -apply (simp add: SReal_def)
   6.295 -apply (auto simp add: hypreal_of_real_not_eq_omega [THEN not_sym])
   6.296 -done
   6.297 +  by (auto simp: SReal_def hypreal_of_real_not_eq_omega [symmetric])
   6.298  
   6.299  lemma SReal_UNIV_real: "{x. hypreal_of_real x \<in> \<real>} = (UNIV::real set)"
   6.300 -by simp
   6.301 +  by simp
   6.302  
   6.303 -lemma SReal_iff: "(x \<in> \<real>) = (\<exists>y. x = hypreal_of_real y)"
   6.304 -by (simp add: SReal_def)
   6.305 +lemma SReal_iff: "x \<in> \<real> \<longleftrightarrow> (\<exists>y. x = hypreal_of_real y)"
   6.306 +  by (simp add: SReal_def)
   6.307  
   6.308  lemma hypreal_of_real_image: "hypreal_of_real `(UNIV::real set) = \<real>"
   6.309 -by (simp add: Reals_eq_Standard Standard_def)
   6.310 +  by (simp add: Reals_eq_Standard Standard_def)
   6.311  
   6.312  lemma inv_hypreal_of_real_image: "inv hypreal_of_real ` \<real> = UNIV"
   6.313 -apply (auto simp add: SReal_def)
   6.314 -apply (rule inj_star_of [THEN inv_f_f, THEN subst], blast)
   6.315 -done
   6.316 +  apply (auto simp add: SReal_def)
   6.317 +  apply (rule inj_star_of [THEN inv_f_f, THEN subst], blast)
   6.318 +  done
   6.319  
   6.320 -lemma SReal_hypreal_of_real_image:
   6.321 -      "[| \<exists>x. x: P; P \<subseteq> \<real> |] ==> \<exists>Q. P = hypreal_of_real ` Q"
   6.322 -by (simp add: SReal_def image_def, blast)
   6.323 +lemma SReal_hypreal_of_real_image: "\<exists>x. x \<in> P \<Longrightarrow> P \<subseteq> \<real> \<Longrightarrow> \<exists>Q. P = hypreal_of_real ` Q"
   6.324 +  unfolding SReal_def image_def by blast
   6.325  
   6.326 -lemma SReal_dense:
   6.327 -     "[| (x::hypreal) \<in> \<real>; y \<in> \<real>;  x<y |] ==> \<exists>r \<in> Reals. x<r & r<y"
   6.328 -apply (auto simp add: SReal_def)
   6.329 -apply (drule dense, auto)
   6.330 -done
   6.331 +lemma SReal_dense: "x \<in> \<real> \<Longrightarrow> y \<in> \<real> \<Longrightarrow> x < y \<Longrightarrow> \<exists>r \<in> Reals. x < r \<and> r < y"
   6.332 +  for x y :: hypreal
   6.333 +  apply (auto simp: SReal_def)
   6.334 +  apply (drule dense)
   6.335 +  apply auto
   6.336 +  done
   6.337  
   6.338 -text\<open>Completeness of Reals, but both lemmas are unused.\<close>
   6.339 +
   6.340 +text \<open>Completeness of Reals, but both lemmas are unused.\<close>
   6.341  
   6.342  lemma SReal_sup_lemma:
   6.343 -     "P \<subseteq> \<real> ==> ((\<exists>x \<in> P. y < x) =
   6.344 -      (\<exists>X. hypreal_of_real X \<in> P & y < hypreal_of_real X))"
   6.345 -by (blast dest!: SReal_iff [THEN iffD1])
   6.346 +  "P \<subseteq> \<real> \<Longrightarrow> (\<exists>x \<in> P. y < x) = (\<exists>X. hypreal_of_real X \<in> P \<and> y < hypreal_of_real X)"
   6.347 +  by (blast dest!: SReal_iff [THEN iffD1])
   6.348  
   6.349  lemma SReal_sup_lemma2:
   6.350 -     "[| P \<subseteq> \<real>; \<exists>x. x \<in> P; \<exists>y \<in> Reals. \<forall>x \<in> P. x < y |]
   6.351 -      ==> (\<exists>X. X \<in> {w. hypreal_of_real w \<in> P}) &
   6.352 -          (\<exists>Y. \<forall>X \<in> {w. hypreal_of_real w \<in> P}. X < Y)"
   6.353 -apply (rule conjI)
   6.354 -apply (fast dest!: SReal_iff [THEN iffD1])
   6.355 -apply (auto, frule subsetD, assumption)
   6.356 -apply (drule SReal_iff [THEN iffD1])
   6.357 -apply (auto, rule_tac x = ya in exI, auto)
   6.358 -done
   6.359 +  "P \<subseteq> \<real> \<Longrightarrow> \<exists>x. x \<in> P \<Longrightarrow> \<exists>y \<in> Reals. \<forall>x \<in> P. x < y \<Longrightarrow>
   6.360 +    (\<exists>X. X \<in> {w. hypreal_of_real w \<in> P}) \<and>
   6.361 +    (\<exists>Y. \<forall>X \<in> {w. hypreal_of_real w \<in> P}. X < Y)"
   6.362 +  apply (rule conjI)
   6.363 +   apply (fast dest!: SReal_iff [THEN iffD1])
   6.364 +  apply (auto, frule subsetD, assumption)
   6.365 +  apply (drule SReal_iff [THEN iffD1])
   6.366 +  apply (auto, rule_tac x = ya in exI, auto)
   6.367 +  done
   6.368  
   6.369  
   6.370 -subsection\<open>Set of Finite Elements is a Subring of the Extended Reals\<close>
   6.371 +subsection \<open>Set of Finite Elements is a Subring of the Extended Reals\<close>
   6.372  
   6.373 -lemma HFinite_add: "[|x \<in> HFinite; y \<in> HFinite|] ==> (x+y) \<in> HFinite"
   6.374 -apply (simp add: HFinite_def)
   6.375 -apply (blast intro!: Reals_add hnorm_add_less)
   6.376 -done
   6.377 +lemma HFinite_add: "x \<in> HFinite \<Longrightarrow> y \<in> HFinite \<Longrightarrow> x + y \<in> HFinite"
   6.378 +  unfolding HFinite_def by (blast intro!: Reals_add hnorm_add_less)
   6.379  
   6.380 -lemma HFinite_mult:
   6.381 -  fixes x y :: "'a::real_normed_algebra star"
   6.382 -  shows "[|x \<in> HFinite; y \<in> HFinite|] ==> x*y \<in> HFinite"
   6.383 -apply (simp add: HFinite_def)
   6.384 -apply (blast intro!: Reals_mult hnorm_mult_less)
   6.385 -done
   6.386 +lemma HFinite_mult: "x \<in> HFinite \<Longrightarrow> y \<in> HFinite \<Longrightarrow> x * y \<in> HFinite"
   6.387 +  for x y :: "'a::real_normed_algebra star"
   6.388 +  unfolding HFinite_def by (blast intro!: Reals_mult hnorm_mult_less)
   6.389  
   6.390 -lemma HFinite_scaleHR:
   6.391 -  "[|x \<in> HFinite; y \<in> HFinite|] ==> scaleHR x y \<in> HFinite"
   6.392 -apply (simp add: HFinite_def)
   6.393 -apply (blast intro!: Reals_mult hnorm_scaleHR_less)
   6.394 -done
   6.395 +lemma HFinite_scaleHR: "x \<in> HFinite \<Longrightarrow> y \<in> HFinite \<Longrightarrow> scaleHR x y \<in> HFinite"
   6.396 +  by (auto simp: HFinite_def intro!: Reals_mult hnorm_scaleHR_less)
   6.397  
   6.398 -lemma HFinite_minus_iff: "(-x \<in> HFinite) = (x \<in> HFinite)"
   6.399 -by (simp add: HFinite_def)
   6.400 +lemma HFinite_minus_iff: "- x \<in> HFinite \<longleftrightarrow> x \<in> HFinite"
   6.401 +  by (simp add: HFinite_def)
   6.402  
   6.403  lemma HFinite_star_of [simp]: "star_of x \<in> HFinite"
   6.404 -apply (simp add: HFinite_def)
   6.405 -apply (rule_tac x="star_of (norm x) + 1" in bexI)
   6.406 -apply (transfer, simp)
   6.407 -apply (blast intro: Reals_add SReal_hypreal_of_real Reals_1)
   6.408 -done
   6.409 +  apply (simp add: HFinite_def)
   6.410 +  apply (rule_tac x="star_of (norm x) + 1" in bexI)
   6.411 +   apply (transfer, simp)
   6.412 +  apply (blast intro: Reals_add SReal_hypreal_of_real Reals_1)
   6.413 +  done
   6.414  
   6.415  lemma SReal_subset_HFinite: "(\<real>::hypreal set) \<subseteq> HFinite"
   6.416 -by (auto simp add: SReal_def)
   6.417 +  by (auto simp add: SReal_def)
   6.418  
   6.419 -lemma HFiniteD: "x \<in> HFinite ==> \<exists>t \<in> Reals. hnorm x < t"
   6.420 -by (simp add: HFinite_def)
   6.421 +lemma HFiniteD: "x \<in> HFinite \<Longrightarrow> \<exists>t \<in> Reals. hnorm x < t"
   6.422 +  by (simp add: HFinite_def)
   6.423  
   6.424 -lemma HFinite_hrabs_iff [iff]: "(\<bar>x::hypreal\<bar> \<in> HFinite) = (x \<in> HFinite)"
   6.425 -by (simp add: HFinite_def)
   6.426 +lemma HFinite_hrabs_iff [iff]: "\<bar>x\<bar> \<in> HFinite \<longleftrightarrow> x \<in> HFinite"
   6.427 +  for x :: hypreal
   6.428 +  by (simp add: HFinite_def)
   6.429  
   6.430 -lemma HFinite_hnorm_iff [iff]:
   6.431 -  "(hnorm (x::hypreal) \<in> HFinite) = (x \<in> HFinite)"
   6.432 -by (simp add: HFinite_def)
   6.433 +lemma HFinite_hnorm_iff [iff]: "hnorm x \<in> HFinite \<longleftrightarrow> x \<in> HFinite"
   6.434 +  for x :: hypreal
   6.435 +  by (simp add: HFinite_def)
   6.436  
   6.437  lemma HFinite_numeral [simp]: "numeral w \<in> HFinite"
   6.438 -unfolding star_numeral_def by (rule HFinite_star_of)
   6.439 +  unfolding star_numeral_def by (rule HFinite_star_of)
   6.440  
   6.441 -(** As always with numerals, 0 and 1 are special cases **)
   6.442 +text \<open>As always with numerals, \<open>0\<close> and \<open>1\<close> are special cases.\<close>
   6.443  
   6.444  lemma HFinite_0 [simp]: "0 \<in> HFinite"
   6.445 -unfolding star_zero_def by (rule HFinite_star_of)
   6.446 +  unfolding star_zero_def by (rule HFinite_star_of)
   6.447  
   6.448  lemma HFinite_1 [simp]: "1 \<in> HFinite"
   6.449 -unfolding star_one_def by (rule HFinite_star_of)
   6.450 +  unfolding star_one_def by (rule HFinite_star_of)
   6.451  
   6.452 -lemma hrealpow_HFinite:
   6.453 -  fixes x :: "'a::{real_normed_algebra,monoid_mult} star"
   6.454 -  shows "x \<in> HFinite ==> x ^ n \<in> HFinite"
   6.455 -apply (induct n)
   6.456 -apply (auto simp add: power_Suc intro: HFinite_mult)
   6.457 -done
   6.458 +lemma hrealpow_HFinite: "x \<in> HFinite \<Longrightarrow> x ^ n \<in> HFinite"
   6.459 +  for x :: "'a::{real_normed_algebra,monoid_mult} star"
   6.460 +  by (induct n) (auto simp add: power_Suc intro: HFinite_mult)
   6.461  
   6.462 -lemma HFinite_bounded:
   6.463 -  "[|(x::hypreal) \<in> HFinite; y \<le> x; 0 \<le> y |] ==> y \<in> HFinite"
   6.464 -apply (cases "x \<le> 0")
   6.465 -apply (drule_tac y = x in order_trans)
   6.466 -apply (drule_tac [2] order_antisym)
   6.467 -apply (auto simp add: linorder_not_le)
   6.468 -apply (auto intro: order_le_less_trans simp add: abs_if HFinite_def)
   6.469 -done
   6.470 +lemma HFinite_bounded: "x \<in> HFinite \<Longrightarrow> y \<le> x \<Longrightarrow> 0 \<le> y \<Longrightarrow> y \<in> HFinite"
   6.471 +  for x y :: hypreal
   6.472 +  apply (cases "x \<le> 0")
   6.473 +   apply (drule_tac y = x in order_trans)
   6.474 +    apply (drule_tac [2] order_antisym)
   6.475 +     apply (auto simp add: linorder_not_le)
   6.476 +  apply (auto intro: order_le_less_trans simp add: abs_if HFinite_def)
   6.477 +  done
   6.478  
   6.479  
   6.480 -subsection\<open>Set of Infinitesimals is a Subring of the Hyperreals\<close>
   6.481 +subsection \<open>Set of Infinitesimals is a Subring of the Hyperreals\<close>
   6.482  
   6.483 -lemma InfinitesimalI:
   6.484 -  "(\<And>r. \<lbrakk>r \<in> \<real>; 0 < r\<rbrakk> \<Longrightarrow> hnorm x < r) \<Longrightarrow> x \<in> Infinitesimal"
   6.485 -by (simp add: Infinitesimal_def)
   6.486 +lemma InfinitesimalI: "(\<And>r. r \<in> \<real> \<Longrightarrow> 0 < r \<Longrightarrow> hnorm x < r) \<Longrightarrow> x \<in> Infinitesimal"
   6.487 +  by (simp add: Infinitesimal_def)
   6.488  
   6.489 -lemma InfinitesimalD:
   6.490 -      "x \<in> Infinitesimal ==> \<forall>r \<in> Reals. 0 < r --> hnorm x < r"
   6.491 -by (simp add: Infinitesimal_def)
   6.492 +lemma InfinitesimalD: "x \<in> Infinitesimal \<Longrightarrow> \<forall>r \<in> Reals. 0 < r \<longrightarrow> hnorm x < r"
   6.493 +  by (simp add: Infinitesimal_def)
   6.494  
   6.495 -lemma InfinitesimalI2:
   6.496 -  "(\<And>r. 0 < r \<Longrightarrow> hnorm x < star_of r) \<Longrightarrow> x \<in> Infinitesimal"
   6.497 -by (auto simp add: Infinitesimal_def SReal_def)
   6.498 +lemma InfinitesimalI2: "(\<And>r. 0 < r \<Longrightarrow> hnorm x < star_of r) \<Longrightarrow> x \<in> Infinitesimal"
   6.499 +  by (auto simp add: Infinitesimal_def SReal_def)
   6.500  
   6.501 -lemma InfinitesimalD2:
   6.502 -  "\<lbrakk>x \<in> Infinitesimal; 0 < r\<rbrakk> \<Longrightarrow> hnorm x < star_of r"
   6.503 -by (auto simp add: Infinitesimal_def SReal_def)
   6.504 +lemma InfinitesimalD2: "x \<in> Infinitesimal \<Longrightarrow> 0 < r \<Longrightarrow> hnorm x < star_of r"
   6.505 +  by (auto simp add: Infinitesimal_def SReal_def)
   6.506  
   6.507  lemma Infinitesimal_zero [iff]: "0 \<in> Infinitesimal"
   6.508 -by (simp add: Infinitesimal_def)
   6.509 +  by (simp add: Infinitesimal_def)
   6.510  
   6.511 -lemma hypreal_sum_of_halves: "x/(2::hypreal) + x/(2::hypreal) = x"
   6.512 -by auto
   6.513 +lemma hypreal_sum_of_halves: "x / 2 + x / 2 = x"
   6.514 +  for x :: hypreal
   6.515 +  by auto
   6.516  
   6.517 -lemma Infinitesimal_add:
   6.518 -     "[| x \<in> Infinitesimal; y \<in> Infinitesimal |] ==> (x+y) \<in> Infinitesimal"
   6.519 -apply (rule InfinitesimalI)
   6.520 -apply (rule hypreal_sum_of_halves [THEN subst])
   6.521 -apply (drule half_gt_zero)
   6.522 -apply (blast intro: hnorm_add_less SReal_divide_numeral dest: InfinitesimalD)
   6.523 -done
   6.524 +lemma Infinitesimal_add: "x \<in> Infinitesimal \<Longrightarrow> y \<in> Infinitesimal \<Longrightarrow> x + y \<in> Infinitesimal"
   6.525 +  apply (rule InfinitesimalI)
   6.526 +  apply (rule hypreal_sum_of_halves [THEN subst])
   6.527 +  apply (drule half_gt_zero)
   6.528 +  apply (blast intro: hnorm_add_less SReal_divide_numeral dest: InfinitesimalD)
   6.529 +  done
   6.530  
   6.531 -lemma Infinitesimal_minus_iff [simp]: "(-x:Infinitesimal) = (x:Infinitesimal)"
   6.532 -by (simp add: Infinitesimal_def)
   6.533 +lemma Infinitesimal_minus_iff [simp]: "- x \<in> Infinitesimal \<longleftrightarrow> x \<in> Infinitesimal"
   6.534 +  by (simp add: Infinitesimal_def)
   6.535  
   6.536 -lemma Infinitesimal_hnorm_iff:
   6.537 -  "(hnorm x \<in> Infinitesimal) = (x \<in> Infinitesimal)"
   6.538 -by (simp add: Infinitesimal_def)
   6.539 +lemma Infinitesimal_hnorm_iff: "hnorm x \<in> Infinitesimal \<longleftrightarrow> x \<in> Infinitesimal"
   6.540 +  by (simp add: Infinitesimal_def)
   6.541  
   6.542 -lemma Infinitesimal_hrabs_iff [iff]:
   6.543 -  "(\<bar>x::hypreal\<bar> \<in> Infinitesimal) = (x \<in> Infinitesimal)"
   6.544 -by (simp add: abs_if)
   6.545 +lemma Infinitesimal_hrabs_iff [iff]: "\<bar>x\<bar> \<in> Infinitesimal \<longleftrightarrow> x \<in> Infinitesimal"
   6.546 +  for x :: hypreal
   6.547 +  by (simp add: abs_if)
   6.548  
   6.549  lemma Infinitesimal_of_hypreal_iff [simp]:
   6.550 -  "((of_hypreal x::'a::real_normed_algebra_1 star) \<in> Infinitesimal) =
   6.551 -   (x \<in> Infinitesimal)"
   6.552 -by (subst Infinitesimal_hnorm_iff [symmetric], simp)
   6.553 +  "(of_hypreal x::'a::real_normed_algebra_1 star) \<in> Infinitesimal \<longleftrightarrow> x \<in> Infinitesimal"
   6.554 +  by (subst Infinitesimal_hnorm_iff [symmetric]) simp
   6.555  
   6.556 -lemma Infinitesimal_diff:
   6.557 -     "[| x \<in> Infinitesimal;  y \<in> Infinitesimal |] ==> x-y \<in> Infinitesimal"
   6.558 +lemma Infinitesimal_diff: "x \<in> Infinitesimal \<Longrightarrow> y \<in> Infinitesimal \<Longrightarrow> x - y \<in> Infinitesimal"
   6.559    using Infinitesimal_add [of x "- y"] by simp
   6.560  
   6.561 -lemma Infinitesimal_mult:
   6.562 -  fixes x y :: "'a::real_normed_algebra star"
   6.563 -  shows "[|x \<in> Infinitesimal; y \<in> Infinitesimal|] ==> (x * y) \<in> Infinitesimal"
   6.564 -apply (rule InfinitesimalI)
   6.565 -apply (subgoal_tac "hnorm (x * y) < 1 * r", simp only: mult_1)
   6.566 -apply (rule hnorm_mult_less)
   6.567 -apply (simp_all add: InfinitesimalD)
   6.568 -done
   6.569 +lemma Infinitesimal_mult: "x \<in> Infinitesimal \<Longrightarrow> y \<in> Infinitesimal \<Longrightarrow> x * y \<in> Infinitesimal"
   6.570 +  for x y :: "'a::real_normed_algebra star"
   6.571 +  apply (rule InfinitesimalI)
   6.572 +  apply (subgoal_tac "hnorm (x * y) < 1 * r")
   6.573 +   apply (simp only: mult_1)
   6.574 +  apply (rule hnorm_mult_less)
   6.575 +   apply (simp_all add: InfinitesimalD)
   6.576 +  done
   6.577  
   6.578 -lemma Infinitesimal_HFinite_mult:
   6.579 -  fixes x y :: "'a::real_normed_algebra star"
   6.580 -  shows "[| x \<in> Infinitesimal; y \<in> HFinite |] ==> (x * y) \<in> Infinitesimal"
   6.581 -apply (rule InfinitesimalI)
   6.582 -apply (drule HFiniteD, clarify)
   6.583 -apply (subgoal_tac "0 < t")
   6.584 -apply (subgoal_tac "hnorm (x * y) < (r / t) * t", simp)
   6.585 -apply (subgoal_tac "0 < r / t")
   6.586 -apply (rule hnorm_mult_less)
   6.587 -apply (simp add: InfinitesimalD)
   6.588 -apply assumption
   6.589 -apply simp
   6.590 -apply (erule order_le_less_trans [OF hnorm_ge_zero])
   6.591 -done
   6.592 +lemma Infinitesimal_HFinite_mult: "x \<in> Infinitesimal \<Longrightarrow> y \<in> HFinite \<Longrightarrow> x * y \<in> Infinitesimal"
   6.593 +  for x y :: "'a::real_normed_algebra star"
   6.594 +  apply (rule InfinitesimalI)
   6.595 +  apply (drule HFiniteD, clarify)
   6.596 +  apply (subgoal_tac "0 < t")
   6.597 +   apply (subgoal_tac "hnorm (x * y) < (r / t) * t", simp)
   6.598 +   apply (subgoal_tac "0 < r / t")
   6.599 +    apply (rule hnorm_mult_less)
   6.600 +     apply (simp add: InfinitesimalD)
   6.601 +    apply assumption
   6.602 +   apply simp
   6.603 +  apply (erule order_le_less_trans [OF hnorm_ge_zero])
   6.604 +  done
   6.605  
   6.606  lemma Infinitesimal_HFinite_scaleHR:
   6.607 -  "[| x \<in> Infinitesimal; y \<in> HFinite |] ==> scaleHR x y \<in> Infinitesimal"
   6.608 -apply (rule InfinitesimalI)
   6.609 -apply (drule HFiniteD, clarify)
   6.610 -apply (drule InfinitesimalD)
   6.611 -apply (simp add: hnorm_scaleHR)
   6.612 -apply (subgoal_tac "0 < t")
   6.613 -apply (subgoal_tac "\<bar>x\<bar> * hnorm y < (r / t) * t", simp)
   6.614 -apply (subgoal_tac "0 < r / t")
   6.615 -apply (rule mult_strict_mono', simp_all)
   6.616 -apply (erule order_le_less_trans [OF hnorm_ge_zero])
   6.617 -done
   6.618 +  "x \<in> Infinitesimal \<Longrightarrow> y \<in> HFinite \<Longrightarrow> scaleHR x y \<in> Infinitesimal"
   6.619 +  apply (rule InfinitesimalI)
   6.620 +  apply (drule HFiniteD, clarify)
   6.621 +  apply (drule InfinitesimalD)
   6.622 +  apply (simp add: hnorm_scaleHR)
   6.623 +  apply (subgoal_tac "0 < t")
   6.624 +   apply (subgoal_tac "\<bar>x\<bar> * hnorm y < (r / t) * t", simp)
   6.625 +   apply (subgoal_tac "0 < r / t")
   6.626 +    apply (rule mult_strict_mono', simp_all)
   6.627 +  apply (erule order_le_less_trans [OF hnorm_ge_zero])
   6.628 +  done
   6.629  
   6.630  lemma Infinitesimal_HFinite_mult2:
   6.631 -  fixes x y :: "'a::real_normed_algebra star"
   6.632 -  shows "[| x \<in> Infinitesimal; y \<in> HFinite |] ==> (y * x) \<in> Infinitesimal"
   6.633 -apply (rule InfinitesimalI)
   6.634 -apply (drule HFiniteD, clarify)
   6.635 -apply (subgoal_tac "0 < t")
   6.636 -apply (subgoal_tac "hnorm (y * x) < t * (r / t)", simp)
   6.637 -apply (subgoal_tac "0 < r / t")
   6.638 -apply (rule hnorm_mult_less)
   6.639 -apply assumption
   6.640 -apply (simp add: InfinitesimalD)
   6.641 -apply simp
   6.642 -apply (erule order_le_less_trans [OF hnorm_ge_zero])
   6.643 -done
   6.644 +  "x \<in> Infinitesimal \<Longrightarrow> y \<in> HFinite \<Longrightarrow> y * x \<in> Infinitesimal"
   6.645 +  for x y :: "'a::real_normed_algebra star"
   6.646 +  apply (rule InfinitesimalI)
   6.647 +  apply (drule HFiniteD, clarify)
   6.648 +  apply (subgoal_tac "0 < t")
   6.649 +   apply (subgoal_tac "hnorm (y * x) < t * (r / t)", simp)
   6.650 +   apply (subgoal_tac "0 < r / t")
   6.651 +    apply (rule hnorm_mult_less)
   6.652 +     apply assumption
   6.653 +    apply (simp add: InfinitesimalD)
   6.654 +   apply simp
   6.655 +  apply (erule order_le_less_trans [OF hnorm_ge_zero])
   6.656 +  done
   6.657  
   6.658 -lemma Infinitesimal_scaleR2:
   6.659 -  "x \<in> Infinitesimal ==> a *\<^sub>R x \<in> Infinitesimal"
   6.660 -apply (case_tac "a = 0", simp)
   6.661 -apply (rule InfinitesimalI)
   6.662 -apply (drule InfinitesimalD)
   6.663 -apply (drule_tac x="r / \<bar>star_of a\<bar>" in bspec)
   6.664 -apply (simp add: Reals_eq_Standard)
   6.665 -apply simp
   6.666 -apply (simp add: hnorm_scaleR pos_less_divide_eq mult.commute)
   6.667 -done
   6.668 +lemma Infinitesimal_scaleR2: "x \<in> Infinitesimal \<Longrightarrow> a *\<^sub>R x \<in> Infinitesimal"
   6.669 +  apply (case_tac "a = 0", simp)
   6.670 +  apply (rule InfinitesimalI)
   6.671 +  apply (drule InfinitesimalD)
   6.672 +  apply (drule_tac x="r / \<bar>star_of a\<bar>" in bspec)
   6.673 +   apply (simp add: Reals_eq_Standard)
   6.674 +  apply simp
   6.675 +  apply (simp add: hnorm_scaleR pos_less_divide_eq mult.commute)
   6.676 +  done
   6.677  
   6.678  lemma Compl_HFinite: "- HFinite = HInfinite"
   6.679 -apply (auto simp add: HInfinite_def HFinite_def linorder_not_less)
   6.680 -apply (rule_tac y="r + 1" in order_less_le_trans, simp)
   6.681 -apply simp
   6.682 -done
   6.683 +  apply (auto simp add: HInfinite_def HFinite_def linorder_not_less)
   6.684 +  apply (rule_tac y="r + 1" in order_less_le_trans, simp)
   6.685 +  apply simp
   6.686 +  done
   6.687  
   6.688 -lemma HInfinite_inverse_Infinitesimal:
   6.689 -  fixes x :: "'a::real_normed_div_algebra star"
   6.690 -  shows "x \<in> HInfinite ==> inverse x \<in> Infinitesimal"
   6.691 -apply (rule InfinitesimalI)
   6.692 -apply (subgoal_tac "x \<noteq> 0")
   6.693 -apply (rule inverse_less_imp_less)
   6.694 -apply (simp add: nonzero_hnorm_inverse)
   6.695 -apply (simp add: HInfinite_def Reals_inverse)
   6.696 -apply assumption
   6.697 -apply (clarify, simp add: Compl_HFinite [symmetric])
   6.698 -done
   6.699 +lemma HInfinite_inverse_Infinitesimal: "x \<in> HInfinite \<Longrightarrow> inverse x \<in> Infinitesimal"
   6.700 +  for x :: "'a::real_normed_div_algebra star"
   6.701 +  apply (rule InfinitesimalI)
   6.702 +  apply (subgoal_tac "x \<noteq> 0")
   6.703 +   apply (rule inverse_less_imp_less)
   6.704 +    apply (simp add: nonzero_hnorm_inverse)
   6.705 +    apply (simp add: HInfinite_def Reals_inverse)
   6.706 +   apply assumption
   6.707 +  apply (clarify, simp add: Compl_HFinite [symmetric])
   6.708 +  done
   6.709  
   6.710  lemma HInfiniteI: "(\<And>r. r \<in> \<real> \<Longrightarrow> r < hnorm x) \<Longrightarrow> x \<in> HInfinite"
   6.711 -by (simp add: HInfinite_def)
   6.712 +  by (simp add: HInfinite_def)
   6.713  
   6.714 -lemma HInfiniteD: "\<lbrakk>x \<in> HInfinite; r \<in> \<real>\<rbrakk> \<Longrightarrow> r < hnorm x"
   6.715 -by (simp add: HInfinite_def)
   6.716 +lemma HInfiniteD: "x \<in> HInfinite \<Longrightarrow> r \<in> \<real> \<Longrightarrow> r < hnorm x"
   6.717 +  by (simp add: HInfinite_def)
   6.718  
   6.719 -lemma HInfinite_mult:
   6.720 -  fixes x y :: "'a::real_normed_div_algebra star"
   6.721 -  shows "[|x \<in> HInfinite; y \<in> HInfinite|] ==> (x*y) \<in> HInfinite"
   6.722 -apply (rule HInfiniteI, simp only: hnorm_mult)
   6.723 -apply (subgoal_tac "r * 1 < hnorm x * hnorm y", simp only: mult_1)
   6.724 -apply (case_tac "x = 0", simp add: HInfinite_def)
   6.725 -apply (rule mult_strict_mono)
   6.726 -apply (simp_all add: HInfiniteD)
   6.727 -done
   6.728 +lemma HInfinite_mult: "x \<in> HInfinite \<Longrightarrow> y \<in> HInfinite \<Longrightarrow> x * y \<in> HInfinite"
   6.729 +  for x y :: "'a::real_normed_div_algebra star"
   6.730 +  apply (rule HInfiniteI, simp only: hnorm_mult)
   6.731 +  apply (subgoal_tac "r * 1 < hnorm x * hnorm y", simp only: mult_1)
   6.732 +  apply (case_tac "x = 0", simp add: HInfinite_def)
   6.733 +  apply (rule mult_strict_mono)
   6.734 +     apply (simp_all add: HInfiniteD)
   6.735 +  done
   6.736  
   6.737 -lemma hypreal_add_zero_less_le_mono: "[|r < x; (0::hypreal) \<le> y|] ==> r < x+y"
   6.738 -by (auto dest: add_less_le_mono)
   6.739 +lemma hypreal_add_zero_less_le_mono: "r < x \<Longrightarrow> 0 \<le> y \<Longrightarrow> r < x + y"
   6.740 +  for r x y :: hypreal
   6.741 +  by (auto dest: add_less_le_mono)
   6.742  
   6.743 -lemma HInfinite_add_ge_zero:
   6.744 -     "[|(x::hypreal) \<in> HInfinite; 0 \<le> y; 0 \<le> x|] ==> (x + y): HInfinite"
   6.745 -by (auto intro!: hypreal_add_zero_less_le_mono
   6.746 -       simp add: abs_if add.commute add_nonneg_nonneg HInfinite_def)
   6.747 +lemma HInfinite_add_ge_zero: "x \<in> HInfinite \<Longrightarrow> 0 \<le> y \<Longrightarrow> 0 \<le> x \<Longrightarrow> x + y \<in> HInfinite"
   6.748 +  for x y :: hypreal
   6.749 +  by (auto simp: abs_if add.commute HInfinite_def)
   6.750  
   6.751 -lemma HInfinite_add_ge_zero2:
   6.752 -     "[|(x::hypreal) \<in> HInfinite; 0 \<le> y; 0 \<le> x|] ==> (y + x): HInfinite"
   6.753 -by (auto intro!: HInfinite_add_ge_zero simp add: add.commute)
   6.754 +lemma HInfinite_add_ge_zero2: "x \<in> HInfinite \<Longrightarrow> 0 \<le> y \<Longrightarrow> 0 \<le> x \<Longrightarrow> y + x \<in> HInfinite"
   6.755 +  for x y :: hypreal
   6.756 +  by (auto intro!: HInfinite_add_ge_zero simp add: add.commute)
   6.757  
   6.758 -lemma HInfinite_add_gt_zero:
   6.759 -     "[|(x::hypreal) \<in> HInfinite; 0 < y; 0 < x|] ==> (x + y): HInfinite"
   6.760 -by (blast intro: HInfinite_add_ge_zero order_less_imp_le)
   6.761 +lemma HInfinite_add_gt_zero: "x \<in> HInfinite \<Longrightarrow> 0 < y \<Longrightarrow> 0 < x \<Longrightarrow> x + y \<in> HInfinite"
   6.762 +  for x y :: hypreal
   6.763 +  by (blast intro: HInfinite_add_ge_zero order_less_imp_le)
   6.764  
   6.765 -lemma HInfinite_minus_iff: "(-x \<in> HInfinite) = (x \<in> HInfinite)"
   6.766 -by (simp add: HInfinite_def)
   6.767 +lemma HInfinite_minus_iff: "- x \<in> HInfinite \<longleftrightarrow> x \<in> HInfinite"
   6.768 +  by (simp add: HInfinite_def)
   6.769  
   6.770 -lemma HInfinite_add_le_zero:
   6.771 -     "[|(x::hypreal) \<in> HInfinite; y \<le> 0; x \<le> 0|] ==> (x + y): HInfinite"
   6.772 -apply (drule HInfinite_minus_iff [THEN iffD2])
   6.773 -apply (rule HInfinite_minus_iff [THEN iffD1])
   6.774 -apply (simp only: minus_add add.commute)
   6.775 -apply (rule HInfinite_add_ge_zero)
   6.776 -apply simp_all
   6.777 -done
   6.778 +lemma HInfinite_add_le_zero: "x \<in> HInfinite \<Longrightarrow> y \<le> 0 \<Longrightarrow> x \<le> 0 \<Longrightarrow> x + y \<in> HInfinite"
   6.779 +  for x y :: hypreal
   6.780 +  apply (drule HInfinite_minus_iff [THEN iffD2])
   6.781 +  apply (rule HInfinite_minus_iff [THEN iffD1])
   6.782 +  apply (simp only: minus_add add.commute)
   6.783 +  apply (rule HInfinite_add_ge_zero)
   6.784 +    apply simp_all
   6.785 +  done
   6.786  
   6.787 -lemma HInfinite_add_lt_zero:
   6.788 -     "[|(x::hypreal) \<in> HInfinite; y < 0; x < 0|] ==> (x + y): HInfinite"
   6.789 -by (blast intro: HInfinite_add_le_zero order_less_imp_le)
   6.790 +lemma HInfinite_add_lt_zero: "x \<in> HInfinite \<Longrightarrow> y < 0 \<Longrightarrow> x < 0 \<Longrightarrow> x + y \<in> HInfinite"
   6.791 +  for x y :: hypreal
   6.792 +  by (blast intro: HInfinite_add_le_zero order_less_imp_le)
   6.793  
   6.794  lemma HFinite_sum_squares:
   6.795 -  fixes a b c :: "'a::real_normed_algebra star"
   6.796 -  shows "[|a: HFinite; b: HFinite; c: HFinite|]
   6.797 -      ==> a*a + b*b + c*c \<in> HFinite"
   6.798 -by (auto intro: HFinite_mult HFinite_add)
   6.799 +  "a \<in> HFinite \<Longrightarrow> b \<in> HFinite \<Longrightarrow> c \<in> HFinite \<Longrightarrow> a * a + b * b + c * c \<in> HFinite"
   6.800 +  for a b c :: "'a::real_normed_algebra star"
   6.801 +  by (auto intro: HFinite_mult HFinite_add)
   6.802  
   6.803 -lemma not_Infinitesimal_not_zero: "x \<notin> Infinitesimal ==> x \<noteq> 0"
   6.804 -by auto
   6.805 +lemma not_Infinitesimal_not_zero: "x \<notin> Infinitesimal \<Longrightarrow> x \<noteq> 0"
   6.806 +  by auto
   6.807  
   6.808 -lemma not_Infinitesimal_not_zero2: "x \<in> HFinite - Infinitesimal ==> x \<noteq> 0"
   6.809 -by auto
   6.810 +lemma not_Infinitesimal_not_zero2: "x \<in> HFinite - Infinitesimal \<Longrightarrow> x \<noteq> 0"
   6.811 +  by auto
   6.812  
   6.813  lemma HFinite_diff_Infinitesimal_hrabs:
   6.814 -  "(x::hypreal) \<in> HFinite - Infinitesimal ==> \<bar>x\<bar> \<in> HFinite - Infinitesimal"
   6.815 -by blast
   6.816 +  "x \<in> HFinite - Infinitesimal \<Longrightarrow> \<bar>x\<bar> \<in> HFinite - Infinitesimal"
   6.817 +  for x :: hypreal
   6.818 +  by blast
   6.819  
   6.820 -lemma hnorm_le_Infinitesimal:
   6.821 -  "\<lbrakk>e \<in> Infinitesimal; hnorm x \<le> e\<rbrakk> \<Longrightarrow> x \<in> Infinitesimal"
   6.822 -by (auto simp add: Infinitesimal_def abs_less_iff)
   6.823 +lemma hnorm_le_Infinitesimal: "e \<in> Infinitesimal \<Longrightarrow> hnorm x \<le> e \<Longrightarrow> x \<in> Infinitesimal"
   6.824 +  by (auto simp: Infinitesimal_def abs_less_iff)
   6.825  
   6.826 -lemma hnorm_less_Infinitesimal:
   6.827 -  "\<lbrakk>e \<in> Infinitesimal; hnorm x < e\<rbrakk> \<Longrightarrow> x \<in> Infinitesimal"
   6.828 -by (erule hnorm_le_Infinitesimal, erule order_less_imp_le)
   6.829 +lemma hnorm_less_Infinitesimal: "e \<in> Infinitesimal \<Longrightarrow> hnorm x < e \<Longrightarrow> x \<in> Infinitesimal"
   6.830 +  by (erule hnorm_le_Infinitesimal, erule order_less_imp_le)
   6.831  
   6.832 -lemma hrabs_le_Infinitesimal:
   6.833 -     "[| e \<in> Infinitesimal; \<bar>x::hypreal\<bar> \<le> e |] ==> x \<in> Infinitesimal"
   6.834 -by (erule hnorm_le_Infinitesimal, simp)
   6.835 +lemma hrabs_le_Infinitesimal: "e \<in> Infinitesimal \<Longrightarrow> \<bar>x\<bar> \<le> e \<Longrightarrow> x \<in> Infinitesimal"
   6.836 +  for x :: hypreal
   6.837 +  by (erule hnorm_le_Infinitesimal) simp
   6.838  
   6.839 -lemma hrabs_less_Infinitesimal:
   6.840 -      "[| e \<in> Infinitesimal; \<bar>x::hypreal\<bar> < e |] ==> x \<in> Infinitesimal"
   6.841 -by (erule hnorm_less_Infinitesimal, simp)
   6.842 +lemma hrabs_less_Infinitesimal: "e \<in> Infinitesimal \<Longrightarrow> \<bar>x\<bar> < e \<Longrightarrow> x \<in> Infinitesimal"
   6.843 +  for x :: hypreal
   6.844 +  by (erule hnorm_less_Infinitesimal) simp
   6.845  
   6.846  lemma Infinitesimal_interval:
   6.847 -      "[| e \<in> Infinitesimal; e' \<in> Infinitesimal; e' < x ; x < e |]
   6.848 -       ==> (x::hypreal) \<in> Infinitesimal"
   6.849 -by (auto simp add: Infinitesimal_def abs_less_iff)
   6.850 +  "e \<in> Infinitesimal \<Longrightarrow> e' \<in> Infinitesimal \<Longrightarrow> e' < x \<Longrightarrow> x < e \<Longrightarrow> x \<in> Infinitesimal"
   6.851 +  for x :: hypreal
   6.852 +  by (auto simp add: Infinitesimal_def abs_less_iff)
   6.853  
   6.854  lemma Infinitesimal_interval2:
   6.855 -     "[| e \<in> Infinitesimal; e' \<in> Infinitesimal;
   6.856 -         e' \<le> x ; x \<le> e |] ==> (x::hypreal) \<in> Infinitesimal"
   6.857 -by (auto intro: Infinitesimal_interval simp add: order_le_less)
   6.858 +  "e \<in> Infinitesimal \<Longrightarrow> e' \<in> Infinitesimal \<Longrightarrow> e' \<le> x \<Longrightarrow> x \<le> e \<Longrightarrow> x \<in> Infinitesimal"
   6.859 +  for x :: hypreal
   6.860 +  by (auto intro: Infinitesimal_interval simp add: order_le_less)
   6.861  
   6.862  
   6.863 -lemma lemma_Infinitesimal_hyperpow:
   6.864 -     "[| (x::hypreal) \<in> Infinitesimal; 0 < N |] ==> \<bar>x pow N\<bar> \<le> \<bar>x\<bar>"
   6.865 -apply (unfold Infinitesimal_def)
   6.866 -apply (auto intro!: hyperpow_Suc_le_self2
   6.867 -          simp add: hyperpow_hrabs [symmetric] hypnat_gt_zero_iff2 abs_ge_zero)
   6.868 -done
   6.869 +lemma lemma_Infinitesimal_hyperpow: "x \<in> Infinitesimal \<Longrightarrow> 0 < N \<Longrightarrow> \<bar>x pow N\<bar> \<le> \<bar>x\<bar>"
   6.870 +  for x :: hypreal
   6.871 +  apply (unfold Infinitesimal_def)
   6.872 +  apply (auto intro!: hyperpow_Suc_le_self2
   6.873 +      simp: hyperpow_hrabs [symmetric] hypnat_gt_zero_iff2 abs_ge_zero)
   6.874 +  done
   6.875  
   6.876 -lemma Infinitesimal_hyperpow:
   6.877 -     "[| (x::hypreal) \<in> Infinitesimal; 0 < N |] ==> x pow N \<in> Infinitesimal"
   6.878 -apply (rule hrabs_le_Infinitesimal)
   6.879 -apply (rule_tac [2] lemma_Infinitesimal_hyperpow, auto)
   6.880 -done
   6.881 +lemma Infinitesimal_hyperpow: "x \<in> Infinitesimal \<Longrightarrow> 0 < N \<Longrightarrow> x pow N \<in> Infinitesimal"
   6.882 +  for x :: hypreal
   6.883 +  apply (rule hrabs_le_Infinitesimal)
   6.884 +   apply (rule_tac [2] lemma_Infinitesimal_hyperpow)
   6.885 +  apply auto
   6.886 +  done
   6.887  
   6.888  lemma hrealpow_hyperpow_Infinitesimal_iff:
   6.889 -     "(x ^ n \<in> Infinitesimal) = (x pow (hypnat_of_nat n) \<in> Infinitesimal)"
   6.890 -by (simp only: hyperpow_hypnat_of_nat)
   6.891 +  "(x ^ n \<in> Infinitesimal) \<longleftrightarrow> x pow (hypnat_of_nat n) \<in> Infinitesimal"
   6.892 +  by (simp only: hyperpow_hypnat_of_nat)
   6.893  
   6.894 -lemma Infinitesimal_hrealpow:
   6.895 -     "[| (x::hypreal) \<in> Infinitesimal; 0 < n |] ==> x ^ n \<in> Infinitesimal"
   6.896 -by (simp add: hrealpow_hyperpow_Infinitesimal_iff Infinitesimal_hyperpow)
   6.897 +lemma Infinitesimal_hrealpow: "x \<in> Infinitesimal \<Longrightarrow> 0 < n \<Longrightarrow> x ^ n \<in> Infinitesimal"
   6.898 +  for x :: hypreal
   6.899 +  by (simp add: hrealpow_hyperpow_Infinitesimal_iff Infinitesimal_hyperpow)
   6.900  
   6.901  lemma not_Infinitesimal_mult:
   6.902 -  fixes x y :: "'a::real_normed_div_algebra star"
   6.903 -  shows "[| x \<notin> Infinitesimal;  y \<notin> Infinitesimal|] ==> (x*y) \<notin>Infinitesimal"
   6.904 -apply (unfold Infinitesimal_def, clarify, rename_tac r s)
   6.905 -apply (simp only: linorder_not_less hnorm_mult)
   6.906 -apply (drule_tac x = "r * s" in bspec)
   6.907 -apply (fast intro: Reals_mult)
   6.908 -apply (simp)
   6.909 -apply (drule_tac c = s and d = "hnorm y" and a = r and b = "hnorm x" in mult_mono)
   6.910 -apply (simp_all (no_asm_simp))
   6.911 -done
   6.912 +  "x \<notin> Infinitesimal \<Longrightarrow> y \<notin> Infinitesimal \<Longrightarrow> x * y \<notin> Infinitesimal"
   6.913 +  for x y :: "'a::real_normed_div_algebra star"
   6.914 +  apply (unfold Infinitesimal_def, clarify, rename_tac r s)
   6.915 +  apply (simp only: linorder_not_less hnorm_mult)
   6.916 +  apply (drule_tac x = "r * s" in bspec)
   6.917 +   apply (fast intro: Reals_mult)
   6.918 +  apply simp
   6.919 +  apply (drule_tac c = s and d = "hnorm y" and a = r and b = "hnorm x" in mult_mono)
   6.920 +     apply simp_all
   6.921 +  done
   6.922  
   6.923 -lemma Infinitesimal_mult_disj:
   6.924 -  fixes x y :: "'a::real_normed_div_algebra star"
   6.925 -  shows "x*y \<in> Infinitesimal ==> x \<in> Infinitesimal | y \<in> Infinitesimal"
   6.926 -apply (rule ccontr)
   6.927 -apply (drule de_Morgan_disj [THEN iffD1])
   6.928 -apply (fast dest: not_Infinitesimal_mult)
   6.929 -done
   6.930 +lemma Infinitesimal_mult_disj: "x * y \<in> Infinitesimal \<Longrightarrow> x \<in> Infinitesimal \<or> y \<in> Infinitesimal"
   6.931 +  for x y :: "'a::real_normed_div_algebra star"
   6.932 +  apply (rule ccontr)
   6.933 +  apply (drule de_Morgan_disj [THEN iffD1])
   6.934 +  apply (fast dest: not_Infinitesimal_mult)
   6.935 +  done
   6.936  
   6.937 -lemma HFinite_Infinitesimal_not_zero: "x \<in> HFinite-Infinitesimal ==> x \<noteq> 0"
   6.938 -by blast
   6.939 +lemma HFinite_Infinitesimal_not_zero: "x \<in> HFinite-Infinitesimal \<Longrightarrow> x \<noteq> 0"
   6.940 +  by blast
   6.941  
   6.942  lemma HFinite_Infinitesimal_diff_mult:
   6.943 -  fixes x y :: "'a::real_normed_div_algebra star"
   6.944 -  shows "[| x \<in> HFinite - Infinitesimal;
   6.945 -                   y \<in> HFinite - Infinitesimal
   6.946 -                |] ==> (x*y) \<in> HFinite - Infinitesimal"
   6.947 -apply clarify
   6.948 -apply (blast dest: HFinite_mult not_Infinitesimal_mult)
   6.949 -done
   6.950 +  "x \<in> HFinite - Infinitesimal \<Longrightarrow> y \<in> HFinite - Infinitesimal \<Longrightarrow> x * y \<in> HFinite - Infinitesimal"
   6.951 +  for x y :: "'a::real_normed_div_algebra star"
   6.952 +  apply clarify
   6.953 +  apply (blast dest: HFinite_mult not_Infinitesimal_mult)
   6.954 +  done
   6.955  
   6.956 -lemma Infinitesimal_subset_HFinite:
   6.957 -      "Infinitesimal \<subseteq> HFinite"
   6.958 -apply (simp add: Infinitesimal_def HFinite_def, auto)
   6.959 -apply (rule_tac x = 1 in bexI, auto)
   6.960 -done
   6.961 +lemma Infinitesimal_subset_HFinite: "Infinitesimal \<subseteq> HFinite"
   6.962 +  apply (simp add: Infinitesimal_def HFinite_def)
   6.963 +  apply auto
   6.964 +  apply (rule_tac x = 1 in bexI)
   6.965 +  apply auto
   6.966 +  done
   6.967  
   6.968 -lemma Infinitesimal_star_of_mult:
   6.969 -  fixes x :: "'a::real_normed_algebra star"
   6.970 -  shows "x \<in> Infinitesimal ==> x * star_of r \<in> Infinitesimal"
   6.971 -by (erule HFinite_star_of [THEN [2] Infinitesimal_HFinite_mult])
   6.972 +lemma Infinitesimal_star_of_mult: "x \<in> Infinitesimal \<Longrightarrow> x * star_of r \<in> Infinitesimal"
   6.973 +  for x :: "'a::real_normed_algebra star"
   6.974 +  by (erule HFinite_star_of [THEN [2] Infinitesimal_HFinite_mult])
   6.975  
   6.976 -lemma Infinitesimal_star_of_mult2:
   6.977 -  fixes x :: "'a::real_normed_algebra star"
   6.978 -  shows "x \<in> Infinitesimal ==> star_of r * x \<in> Infinitesimal"
   6.979 -by (erule HFinite_star_of [THEN [2] Infinitesimal_HFinite_mult2])
   6.980 +lemma Infinitesimal_star_of_mult2: "x \<in> Infinitesimal \<Longrightarrow> star_of r * x \<in> Infinitesimal"
   6.981 +  for x :: "'a::real_normed_algebra star"
   6.982 +  by (erule HFinite_star_of [THEN [2] Infinitesimal_HFinite_mult2])
   6.983  
   6.984  
   6.985 -subsection\<open>The Infinitely Close Relation\<close>
   6.986 +subsection \<open>The Infinitely Close Relation\<close>
   6.987  
   6.988 -lemma mem_infmal_iff: "(x \<in> Infinitesimal) = (x \<approx> 0)"
   6.989 -by (simp add: Infinitesimal_def approx_def)
   6.990 +lemma mem_infmal_iff: "x \<in> Infinitesimal \<longleftrightarrow> x \<approx> 0"
   6.991 +  by (simp add: Infinitesimal_def approx_def)
   6.992  
   6.993 -lemma approx_minus_iff: " (x \<approx> y) = (x - y \<approx> 0)"
   6.994 -by (simp add: approx_def)
   6.995 +lemma approx_minus_iff: "x \<approx> y \<longleftrightarrow> x - y \<approx> 0"
   6.996 +  by (simp add: approx_def)
   6.997  
   6.998 -lemma approx_minus_iff2: " (x \<approx> y) = (-y + x \<approx> 0)"
   6.999 -by (simp add: approx_def add.commute)
  6.1000 +lemma approx_minus_iff2: "x \<approx> y \<longleftrightarrow> - y + x \<approx> 0"
  6.1001 +  by (simp add: approx_def add.commute)
  6.1002  
  6.1003  lemma approx_refl [iff]: "x \<approx> x"
  6.1004 -by (simp add: approx_def Infinitesimal_def)
  6.1005 +  by (simp add: approx_def Infinitesimal_def)
  6.1006  
  6.1007 -lemma hypreal_minus_distrib1: "-(y + -(x::'a::ab_group_add)) = x + -y"
  6.1008 -by (simp add: add.commute)
  6.1009 +lemma hypreal_minus_distrib1: "- (y + - x) = x + -y"
  6.1010 +  for x y :: "'a::ab_group_add"
  6.1011 +  by (simp add: add.commute)
  6.1012  
  6.1013 -lemma approx_sym: "x \<approx> y ==> y \<approx> x"
  6.1014 -apply (simp add: approx_def)
  6.1015 -apply (drule Infinitesimal_minus_iff [THEN iffD2])
  6.1016 -apply simp
  6.1017 -done
  6.1018 +lemma approx_sym: "x \<approx> y \<Longrightarrow> y \<approx> x"
  6.1019 +  apply (simp add: approx_def)
  6.1020 +  apply (drule Infinitesimal_minus_iff [THEN iffD2])
  6.1021 +  apply simp
  6.1022 +  done
  6.1023  
  6.1024 -lemma approx_trans: "[| x \<approx> y; y \<approx> z |] ==> x \<approx> z"
  6.1025 -apply (simp add: approx_def)
  6.1026 -apply (drule (1) Infinitesimal_add)
  6.1027 -apply simp
  6.1028 -done
  6.1029 +lemma approx_trans: "x \<approx> y \<Longrightarrow> y \<approx> z \<Longrightarrow> x \<approx> z"
  6.1030 +  apply (simp add: approx_def)
  6.1031 +  apply (drule (1) Infinitesimal_add)
  6.1032 +  apply simp
  6.1033 +  done
  6.1034  
  6.1035 -lemma approx_trans2: "[| r \<approx> x; s \<approx> x |] ==> r \<approx> s"
  6.1036 -by (blast intro: approx_sym approx_trans)
  6.1037 +lemma approx_trans2: "r \<approx> x \<Longrightarrow> s \<approx> x \<Longrightarrow> r \<approx> s"
  6.1038 +  by (blast intro: approx_sym approx_trans)
  6.1039  
  6.1040 -lemma approx_trans3: "[| x \<approx> r; x \<approx> s|] ==> r \<approx> s"
  6.1041 -by (blast intro: approx_sym approx_trans)
  6.1042 +lemma approx_trans3: "x \<approx> r \<Longrightarrow> x \<approx> s \<Longrightarrow> r \<approx> s"
  6.1043 +  by (blast intro: approx_sym approx_trans)
  6.1044  
  6.1045 -lemma approx_reorient: "(x \<approx> y) = (y \<approx> x)"
  6.1046 -by (blast intro: approx_sym)
  6.1047 +lemma approx_reorient: "x \<approx> y \<longleftrightarrow> y \<approx> x"
  6.1048 +  by (blast intro: approx_sym)
  6.1049  
  6.1050 -(*reorientation simplification procedure: reorients (polymorphic)
  6.1051 -  0 = x, 1 = x, nnn = x provided x isn't 0, 1 or a numeral.*)
  6.1052 +text \<open>Reorientation simplification procedure: reorients (polymorphic)
  6.1053 +  \<open>0 = x\<close>, \<open>1 = x\<close>, \<open>nnn = x\<close> provided \<open>x\<close> isn't \<open>0\<close>, \<open>1\<close> or a numeral.\<close>
  6.1054  simproc_setup approx_reorient_simproc
  6.1055    ("0 \<approx> x" | "1 \<approx> y" | "numeral w \<approx> z" | "- 1 \<approx> y" | "- numeral w \<approx> r") =
  6.1056  \<open>
  6.1057 @@ -658,1133 +593,1067 @@
  6.1058    in proc end
  6.1059  \<close>
  6.1060  
  6.1061 -lemma Infinitesimal_approx_minus: "(x-y \<in> Infinitesimal) = (x \<approx> y)"
  6.1062 -by (simp add: approx_minus_iff [symmetric] mem_infmal_iff)
  6.1063 +lemma Infinitesimal_approx_minus: "x - y \<in> Infinitesimal \<longleftrightarrow> x \<approx> y"
  6.1064 +  by (simp add: approx_minus_iff [symmetric] mem_infmal_iff)
  6.1065  
  6.1066 -lemma approx_monad_iff: "(x \<approx> y) = (monad(x)=monad(y))"
  6.1067 -apply (simp add: monad_def)
  6.1068 -apply (auto dest: approx_sym elim!: approx_trans equalityCE)
  6.1069 -done
  6.1070 +lemma approx_monad_iff: "x \<approx> y \<longleftrightarrow> monad x = monad y"
  6.1071 +  by (auto simp add: monad_def dest: approx_sym elim!: approx_trans equalityCE)
  6.1072  
  6.1073 -lemma Infinitesimal_approx:
  6.1074 -     "[| x \<in> Infinitesimal; y \<in> Infinitesimal |] ==> x \<approx> y"
  6.1075 -apply (simp add: mem_infmal_iff)
  6.1076 -apply (blast intro: approx_trans approx_sym)
  6.1077 -done
  6.1078 +lemma Infinitesimal_approx: "x \<in> Infinitesimal \<Longrightarrow> y \<in> Infinitesimal \<Longrightarrow> x \<approx> y"
  6.1079 +  apply (simp add: mem_infmal_iff)
  6.1080 +  apply (blast intro: approx_trans approx_sym)
  6.1081 +  done
  6.1082  
  6.1083 -lemma approx_add: "[| a \<approx> b; c \<approx> d |] ==> a+c \<approx> b+d"
  6.1084 +lemma approx_add: "a \<approx> b \<Longrightarrow> c \<approx> d \<Longrightarrow> a + c \<approx> b + d"
  6.1085  proof (unfold approx_def)
  6.1086    assume inf: "a - b \<in> Infinitesimal" "c - d \<in> Infinitesimal"
  6.1087    have "a + c - (b + d) = (a - b) + (c - d)" by simp
  6.1088 -  also have "... \<in> Infinitesimal" using inf by (rule Infinitesimal_add)
  6.1089 +  also have "... \<in> Infinitesimal"
  6.1090 +    using inf by (rule Infinitesimal_add)
  6.1091    finally show "a + c - (b + d) \<in> Infinitesimal" .
  6.1092  qed
  6.1093  
  6.1094 -lemma approx_minus: "a \<approx> b ==> -a \<approx> -b"
  6.1095 -apply (rule approx_minus_iff [THEN iffD2, THEN approx_sym])
  6.1096 -apply (drule approx_minus_iff [THEN iffD1])
  6.1097 -apply (simp add: add.commute)
  6.1098 -done
  6.1099 +lemma approx_minus: "a \<approx> b \<Longrightarrow> - a \<approx> - b"
  6.1100 +  apply (rule approx_minus_iff [THEN iffD2, THEN approx_sym])
  6.1101 +  apply (drule approx_minus_iff [THEN iffD1])
  6.1102 +  apply (simp add: add.commute)
  6.1103 +  done
  6.1104  
  6.1105 -lemma approx_minus2: "-a \<approx> -b ==> a \<approx> b"
  6.1106 -by (auto dest: approx_minus)
  6.1107 +lemma approx_minus2: "- a \<approx> - b \<Longrightarrow> a \<approx> b"
  6.1108 +  by (auto dest: approx_minus)
  6.1109  
  6.1110 -lemma approx_minus_cancel [simp]: "(-a \<approx> -b) = (a \<approx> b)"
  6.1111 -by (blast intro: approx_minus approx_minus2)
  6.1112 +lemma approx_minus_cancel [simp]: "- a \<approx> - b \<longleftrightarrow> a \<approx> b"
  6.1113 +  by (blast intro: approx_minus approx_minus2)
  6.1114  
  6.1115 -lemma approx_add_minus: "[| a \<approx> b; c \<approx> d |] ==> a + -c \<approx> b + -d"
  6.1116 -by (blast intro!: approx_add approx_minus)
  6.1117 +lemma approx_add_minus: "a \<approx> b \<Longrightarrow> c \<approx> d \<Longrightarrow> a + - c \<approx> b + - d"
  6.1118 +  by (blast intro!: approx_add approx_minus)
  6.1119  
  6.1120 -lemma approx_diff: "[| a \<approx> b; c \<approx> d |] ==> a - c \<approx> b - d"
  6.1121 +lemma approx_diff: "a \<approx> b \<Longrightarrow> c \<approx> d \<Longrightarrow> a - c \<approx> b - d"
  6.1122    using approx_add [of a b "- c" "- d"] by simp
  6.1123  
  6.1124 -lemma approx_mult1:
  6.1125 -  fixes a b c :: "'a::real_normed_algebra star"
  6.1126 -  shows "[| a \<approx> b; c: HFinite|] ==> a*c \<approx> b*c"
  6.1127 -by (simp add: approx_def Infinitesimal_HFinite_mult
  6.1128 -              left_diff_distrib [symmetric])
  6.1129 +lemma approx_mult1: "a \<approx> b \<Longrightarrow> c \<in> HFinite \<Longrightarrow> a * c \<approx> b * c"
  6.1130 +  for a b c :: "'a::real_normed_algebra star"
  6.1131 +  by (simp add: approx_def Infinitesimal_HFinite_mult left_diff_distrib [symmetric])
  6.1132 +
  6.1133 +lemma approx_mult2: "a \<approx> b \<Longrightarrow> c \<in> HFinite \<Longrightarrow> c * a \<approx> c * b"
  6.1134 +  for a b c :: "'a::real_normed_algebra star"
  6.1135 +  by (simp add: approx_def Infinitesimal_HFinite_mult2 right_diff_distrib [symmetric])
  6.1136  
  6.1137 -lemma approx_mult2:
  6.1138 -  fixes a b c :: "'a::real_normed_algebra star"
  6.1139 -  shows "[|a \<approx> b; c: HFinite|] ==> c*a \<approx> c*b"
  6.1140 -by (simp add: approx_def Infinitesimal_HFinite_mult2
  6.1141 -              right_diff_distrib [symmetric])
  6.1142 +lemma approx_mult_subst: "u \<approx> v * x \<Longrightarrow> x \<approx> y \<Longrightarrow> v \<in> HFinite \<Longrightarrow> u \<approx> v * y"
  6.1143 +  for u v x y :: "'a::real_normed_algebra star"
  6.1144 +  by (blast intro: approx_mult2 approx_trans)
  6.1145  
  6.1146 -lemma approx_mult_subst:
  6.1147 -  fixes u v x y :: "'a::real_normed_algebra star"
  6.1148 -  shows "[|u \<approx> v*x; x \<approx> y; v \<in> HFinite|] ==> u \<approx> v*y"
  6.1149 -by (blast intro: approx_mult2 approx_trans)
  6.1150 -
  6.1151 -lemma approx_mult_subst2:
  6.1152 -  fixes u v x y :: "'a::real_normed_algebra star"
  6.1153 -  shows "[| u \<approx> x*v; x \<approx> y; v \<in> HFinite |] ==> u \<approx> y*v"
  6.1154 -by (blast intro: approx_mult1 approx_trans)
  6.1155 +lemma approx_mult_subst2: "u \<approx> x * v \<Longrightarrow> x \<approx> y \<Longrightarrow> v \<in> HFinite \<Longrightarrow> u \<approx> y * v"
  6.1156 +  for u v x y :: "'a::real_normed_algebra star"
  6.1157 +  by (blast intro: approx_mult1 approx_trans)
  6.1158  
  6.1159 -lemma approx_mult_subst_star_of:
  6.1160 -  fixes u x y :: "'a::real_normed_algebra star"
  6.1161 -  shows "[| u \<approx> x*star_of v; x \<approx> y |] ==> u \<approx> y*star_of v"
  6.1162 -by (auto intro: approx_mult_subst2)
  6.1163 +lemma approx_mult_subst_star_of: "u \<approx> x * star_of v \<Longrightarrow> x \<approx> y \<Longrightarrow> u \<approx> y * star_of v"
  6.1164 +  for u x y :: "'a::real_normed_algebra star"
  6.1165 +  by (auto intro: approx_mult_subst2)
  6.1166  
  6.1167 -lemma approx_eq_imp: "a = b ==> a \<approx> b"
  6.1168 -by (simp add: approx_def)
  6.1169 +lemma approx_eq_imp: "a = b \<Longrightarrow> a \<approx> b"
  6.1170 +  by (simp add: approx_def)
  6.1171  
  6.1172 -lemma Infinitesimal_minus_approx: "x \<in> Infinitesimal ==> -x \<approx> x"
  6.1173 -by (blast intro: Infinitesimal_minus_iff [THEN iffD2]
  6.1174 -                    mem_infmal_iff [THEN iffD1] approx_trans2)
  6.1175 +lemma Infinitesimal_minus_approx: "x \<in> Infinitesimal \<Longrightarrow> - x \<approx> x"
  6.1176 +  by (blast intro: Infinitesimal_minus_iff [THEN iffD2] mem_infmal_iff [THEN iffD1] approx_trans2)
  6.1177  
  6.1178 -lemma bex_Infinitesimal_iff: "(\<exists>y \<in> Infinitesimal. x - z = y) = (x \<approx> z)"
  6.1179 -by (simp add: approx_def)
  6.1180 +lemma bex_Infinitesimal_iff: "(\<exists>y \<in> Infinitesimal. x - z = y) \<longleftrightarrow> x \<approx> z"
  6.1181 +  by (simp add: approx_def)
  6.1182  
  6.1183 -lemma bex_Infinitesimal_iff2: "(\<exists>y \<in> Infinitesimal. x = z + y) = (x \<approx> z)"
  6.1184 -by (force simp add: bex_Infinitesimal_iff [symmetric])
  6.1185 +lemma bex_Infinitesimal_iff2: "(\<exists>y \<in> Infinitesimal. x = z + y) \<longleftrightarrow> x \<approx> z"
  6.1186 +  by (force simp add: bex_Infinitesimal_iff [symmetric])
  6.1187  
  6.1188 -lemma Infinitesimal_add_approx: "[| y \<in> Infinitesimal; x + y = z |] ==> x \<approx> z"
  6.1189 -apply (rule bex_Infinitesimal_iff [THEN iffD1])
  6.1190 -apply (drule Infinitesimal_minus_iff [THEN iffD2])
  6.1191 -apply (auto simp add: add.assoc [symmetric])
  6.1192 -done
  6.1193 +lemma Infinitesimal_add_approx: "y \<in> Infinitesimal \<Longrightarrow> x + y = z \<Longrightarrow> x \<approx> z"
  6.1194 +  apply (rule bex_Infinitesimal_iff [THEN iffD1])
  6.1195 +  apply (drule Infinitesimal_minus_iff [THEN iffD2])
  6.1196 +  apply (auto simp add: add.assoc [symmetric])
  6.1197 +  done
  6.1198  
  6.1199 -lemma Infinitesimal_add_approx_self: "y \<in> Infinitesimal ==> x \<approx> x + y"
  6.1200 -apply (rule bex_Infinitesimal_iff [THEN iffD1])
  6.1201 -apply (drule Infinitesimal_minus_iff [THEN iffD2])
  6.1202 -apply (auto simp add: add.assoc [symmetric])
  6.1203 -done
  6.1204 +lemma Infinitesimal_add_approx_self: "y \<in> Infinitesimal \<Longrightarrow> x \<approx> x + y"
  6.1205 +  apply (rule bex_Infinitesimal_iff [THEN iffD1])
  6.1206 +  apply (drule Infinitesimal_minus_iff [THEN iffD2])
  6.1207 +  apply (auto simp add: add.assoc [symmetric])
  6.1208 +  done
  6.1209  
  6.1210 -lemma Infinitesimal_add_approx_self2: "y \<in> Infinitesimal ==> x \<approx> y + x"
  6.1211 -by (auto dest: Infinitesimal_add_approx_self simp add: add.commute)
  6.1212 +lemma Infinitesimal_add_approx_self2: "y \<in> Infinitesimal \<Longrightarrow> x \<approx> y + x"
  6.1213 +  by (auto dest: Infinitesimal_add_approx_self simp add: add.commute)
  6.1214  
  6.1215 -lemma Infinitesimal_add_minus_approx_self: "y \<in> Infinitesimal ==> x \<approx> x + -y"
  6.1216 -by (blast intro!: Infinitesimal_add_approx_self Infinitesimal_minus_iff [THEN iffD2])
  6.1217 +lemma Infinitesimal_add_minus_approx_self: "y \<in> Infinitesimal \<Longrightarrow> x \<approx> x + - y"
  6.1218 +  by (blast intro!: Infinitesimal_add_approx_self Infinitesimal_minus_iff [THEN iffD2])
  6.1219  
  6.1220 -lemma Infinitesimal_add_cancel: "[| y \<in> Infinitesimal; x+y \<approx> z|] ==> x \<approx> z"
  6.1221 -apply (drule_tac x = x in Infinitesimal_add_approx_self [THEN approx_sym])
  6.1222 -apply (erule approx_trans3 [THEN approx_sym], assumption)
  6.1223 -done
  6.1224 +lemma Infinitesimal_add_cancel: "y \<in> Infinitesimal \<Longrightarrow> x + y \<approx> z \<Longrightarrow> x \<approx> z"
  6.1225 +  apply (drule_tac x = x in Infinitesimal_add_approx_self [THEN approx_sym])
  6.1226 +  apply (erule approx_trans3 [THEN approx_sym], assumption)
  6.1227 +  done
  6.1228  
  6.1229 -lemma Infinitesimal_add_right_cancel:
  6.1230 -     "[| y \<in> Infinitesimal; x \<approx> z + y|] ==> x \<approx> z"
  6.1231 -apply (drule_tac x = z in Infinitesimal_add_approx_self2 [THEN approx_sym])
  6.1232 -apply (erule approx_trans3 [THEN approx_sym])
  6.1233 -apply (simp add: add.commute)
  6.1234 -apply (erule approx_sym)
  6.1235 -done
  6.1236 +lemma Infinitesimal_add_right_cancel: "y \<in> Infinitesimal \<Longrightarrow> x \<approx> z + y \<Longrightarrow> x \<approx> z"
  6.1237 +  apply (drule_tac x = z in Infinitesimal_add_approx_self2 [THEN approx_sym])
  6.1238 +  apply (erule approx_trans3 [THEN approx_sym])
  6.1239 +  apply (simp add: add.commute)
  6.1240 +  apply (erule approx_sym)
  6.1241 +  done
  6.1242  
  6.1243 -lemma approx_add_left_cancel: "d + b  \<approx> d + c ==> b \<approx> c"
  6.1244 -apply (drule approx_minus_iff [THEN iffD1])
  6.1245 -apply (simp add: approx_minus_iff [symmetric] ac_simps)
  6.1246 -done
  6.1247 +lemma approx_add_left_cancel: "d + b  \<approx> d + c \<Longrightarrow> b \<approx> c"
  6.1248 +  apply (drule approx_minus_iff [THEN iffD1])
  6.1249 +  apply (simp add: approx_minus_iff [symmetric] ac_simps)
  6.1250 +  done
  6.1251  
  6.1252 -lemma approx_add_right_cancel: "b + d \<approx> c + d ==> b \<approx> c"
  6.1253 -apply (rule approx_add_left_cancel)
  6.1254 -apply (simp add: add.commute)
  6.1255 -done
  6.1256 +lemma approx_add_right_cancel: "b + d \<approx> c + d \<Longrightarrow> b \<approx> c"
  6.1257 +  apply (rule approx_add_left_cancel)
  6.1258 +  apply (simp add: add.commute)
  6.1259 +  done
  6.1260  
  6.1261 -lemma approx_add_mono1: "b \<approx> c ==> d + b \<approx> d + c"
  6.1262 -apply (rule approx_minus_iff [THEN iffD2])
  6.1263 -apply (simp add: approx_minus_iff [symmetric] ac_simps)
  6.1264 -done
  6.1265 +lemma approx_add_mono1: "b \<approx> c \<Longrightarrow> d + b \<approx> d + c"
  6.1266 +  apply (rule approx_minus_iff [THEN iffD2])
  6.1267 +  apply (simp add: approx_minus_iff [symmetric] ac_simps)
  6.1268 +  done
  6.1269  
  6.1270 -lemma approx_add_mono2: "b \<approx> c ==> b + a \<approx> c + a"
  6.1271 -by (simp add: add.commute approx_add_mono1)
  6.1272 +lemma approx_add_mono2: "b \<approx> c \<Longrightarrow> b + a \<approx> c + a"
  6.1273 +  by (simp add: add.commute approx_add_mono1)
  6.1274  
  6.1275 -lemma approx_add_left_iff [simp]: "(a + b \<approx> a + c) = (b \<approx> c)"
  6.1276 -by (fast elim: approx_add_left_cancel approx_add_mono1)
  6.1277 +lemma approx_add_left_iff [simp]: "a + b \<approx> a + c \<longleftrightarrow> b \<approx> c"
  6.1278 +  by (fast elim: approx_add_left_cancel approx_add_mono1)
  6.1279  
  6.1280 -lemma approx_add_right_iff [simp]: "(b + a \<approx> c + a) = (b \<approx> c)"
  6.1281 -by (simp add: add.commute)
  6.1282 +lemma approx_add_right_iff [simp]: "b + a \<approx> c + a \<longleftrightarrow> b \<approx> c"
  6.1283 +  by (simp add: add.commute)
  6.1284  
  6.1285 -lemma approx_HFinite: "[| x \<in> HFinite; x \<approx> y |] ==> y \<in> HFinite"
  6.1286 -apply (drule bex_Infinitesimal_iff2 [THEN iffD2], safe)
  6.1287 -apply (drule Infinitesimal_subset_HFinite [THEN subsetD, THEN HFinite_minus_iff [THEN iffD2]])
  6.1288 -apply (drule HFinite_add)
  6.1289 -apply (auto simp add: add.assoc)
  6.1290 -done
  6.1291 +lemma approx_HFinite: "x \<in> HFinite \<Longrightarrow> x \<approx> y \<Longrightarrow> y \<in> HFinite"
  6.1292 +  apply (drule bex_Infinitesimal_iff2 [THEN iffD2], safe)
  6.1293 +  apply (drule Infinitesimal_subset_HFinite [THEN subsetD, THEN HFinite_minus_iff [THEN iffD2]])
  6.1294 +  apply (drule HFinite_add)
  6.1295 +   apply (auto simp add: add.assoc)
  6.1296 +  done
  6.1297  
  6.1298 -lemma approx_star_of_HFinite: "x \<approx> star_of D ==> x \<in> HFinite"
  6.1299 -by (rule approx_sym [THEN [2] approx_HFinite], auto)
  6.1300 +lemma approx_star_of_HFinite: "x \<approx> star_of D \<Longrightarrow> x \<in> HFinite"
  6.1301 +  by (rule approx_sym [THEN [2] approx_HFinite], auto)
  6.1302  
  6.1303 -lemma approx_mult_HFinite:
  6.1304 -  fixes a b c d :: "'a::real_normed_algebra star"
  6.1305 -  shows "[|a \<approx> b; c \<approx> d; b: HFinite; d: HFinite|] ==> a*c \<approx> b*d"
  6.1306 -apply (rule approx_trans)
  6.1307 -apply (rule_tac [2] approx_mult2)
  6.1308 -apply (rule approx_mult1)
  6.1309 -prefer 2 apply (blast intro: approx_HFinite approx_sym, auto)
  6.1310 -done
  6.1311 +lemma approx_mult_HFinite: "a \<approx> b \<Longrightarrow> c \<approx> d \<Longrightarrow> b \<in> HFinite \<Longrightarrow> d \<in> HFinite \<Longrightarrow> a * c \<approx> b * d"
  6.1312 +  for a b c d :: "'a::real_normed_algebra star"
  6.1313 +  apply (rule approx_trans)
  6.1314 +   apply (rule_tac [2] approx_mult2)
  6.1315 +    apply (rule approx_mult1)
  6.1316 +     prefer 2 apply (blast intro: approx_HFinite approx_sym, auto)
  6.1317 +  done
  6.1318  
  6.1319 -lemma scaleHR_left_diff_distrib:
  6.1320 -  "\<And>a b x. scaleHR (a - b) x = scaleHR a x - scaleHR b x"
  6.1321 -by transfer (rule scaleR_left_diff_distrib)
  6.1322 +lemma scaleHR_left_diff_distrib: "\<And>a b x. scaleHR (a - b) x = scaleHR a x - scaleHR b x"
  6.1323 +  by transfer (rule scaleR_left_diff_distrib)
  6.1324  
  6.1325 -lemma approx_scaleR1:
  6.1326 -  "[| a \<approx> star_of b; c: HFinite|] ==> scaleHR a c \<approx> b *\<^sub>R c"
  6.1327 -apply (unfold approx_def)
  6.1328 -apply (drule (1) Infinitesimal_HFinite_scaleHR)
  6.1329 -apply (simp only: scaleHR_left_diff_distrib)
  6.1330 -apply (simp add: scaleHR_def star_scaleR_def [symmetric])
  6.1331 -done
  6.1332 +lemma approx_scaleR1: "a \<approx> star_of b \<Longrightarrow> c \<in> HFinite \<Longrightarrow> scaleHR a c \<approx> b *\<^sub>R c"
  6.1333 +  apply (unfold approx_def)
  6.1334 +  apply (drule (1) Infinitesimal_HFinite_scaleHR)
  6.1335 +  apply (simp only: scaleHR_left_diff_distrib)
  6.1336 +  apply (simp add: scaleHR_def star_scaleR_def [symmetric])
  6.1337 +  done
  6.1338  
  6.1339 -lemma approx_scaleR2:
  6.1340 -  "a \<approx> b ==> c *\<^sub>R a \<approx> c *\<^sub>R b"
  6.1341 -by (simp add: approx_def Infinitesimal_scaleR2
  6.1342 -              scaleR_right_diff_distrib [symmetric])
  6.1343 +lemma approx_scaleR2: "a \<approx> b \<Longrightarrow> c *\<^sub>R a \<approx> c *\<^sub>R b"
  6.1344 +  by (simp add: approx_def Infinitesimal_scaleR2 scaleR_right_diff_distrib [symmetric])
  6.1345 +
  6.1346 +lemma approx_scaleR_HFinite: "a \<approx> star_of b \<Longrightarrow> c \<approx> d \<Longrightarrow> d \<in> HFinite \<Longrightarrow> scaleHR a c \<approx> b *\<^sub>R d"
  6.1347 +  apply (rule approx_trans)
  6.1348 +   apply (rule_tac [2] approx_scaleR2)
  6.1349 +   apply (rule approx_scaleR1)
  6.1350 +    prefer 2 apply (blast intro: approx_HFinite approx_sym, auto)
  6.1351 +  done
  6.1352  
  6.1353 -lemma approx_scaleR_HFinite:
  6.1354 -  "[|a \<approx> star_of b; c \<approx> d; d: HFinite|] ==> scaleHR a c \<approx> b *\<^sub>R d"
  6.1355 -apply (rule approx_trans)
  6.1356 -apply (rule_tac [2] approx_scaleR2)
  6.1357 -apply (rule approx_scaleR1)
  6.1358 -prefer 2 apply (blast intro: approx_HFinite approx_sym, auto)
  6.1359 -done
  6.1360 +lemma approx_mult_star_of: "a \<approx> star_of b \<Longrightarrow> c \<approx> star_of d \<Longrightarrow> a * c \<approx> star_of b * star_of d"
  6.1361 +  for a c :: "'a::real_normed_algebra star"
  6.1362 +  by (blast intro!: approx_mult_HFinite approx_star_of_HFinite HFinite_star_of)
  6.1363 +
  6.1364 +lemma approx_SReal_mult_cancel_zero: "a \<in> \<real> \<Longrightarrow> a \<noteq> 0 \<Longrightarrow> a * x \<approx> 0 \<Longrightarrow> x \<approx> 0"
  6.1365 +  for a x :: hypreal
  6.1366 +  apply (drule Reals_inverse [THEN SReal_subset_HFinite [THEN subsetD]])
  6.1367 +  apply (auto dest: approx_mult2 simp add: mult.assoc [symmetric])
  6.1368 +  done
  6.1369  
  6.1370 -lemma approx_mult_star_of:
  6.1371 -  fixes a c :: "'a::real_normed_algebra star"
  6.1372 -  shows "[|a \<approx> star_of b; c \<approx> star_of d |]
  6.1373 -      ==> a*c \<approx> star_of b*star_of d"
  6.1374 -by (blast intro!: approx_mult_HFinite approx_star_of_HFinite HFinite_star_of)
  6.1375 +lemma approx_mult_SReal1: "a \<in> \<real> \<Longrightarrow> x \<approx> 0 \<Longrightarrow> x * a \<approx> 0"
  6.1376 +  for a x :: hypreal
  6.1377 +  by (auto dest: SReal_subset_HFinite [THEN subsetD] approx_mult1)
  6.1378  
  6.1379 -lemma approx_SReal_mult_cancel_zero:
  6.1380 -     "[| (a::hypreal) \<in> \<real>; a \<noteq> 0; a*x \<approx> 0 |] ==> x \<approx> 0"
  6.1381 -apply (drule Reals_inverse [THEN SReal_subset_HFinite [THEN subsetD]])
  6.1382 -apply (auto dest: approx_mult2 simp add: mult.assoc [symmetric])
  6.1383 -done
  6.1384 +lemma approx_mult_SReal2: "a \<in> \<real> \<Longrightarrow> x \<approx> 0 \<Longrightarrow> a * x \<approx> 0"
  6.1385 +  for a x :: hypreal
  6.1386 +  by (auto dest: SReal_subset_HFinite [THEN subsetD] approx_mult2)
  6.1387  
  6.1388 -lemma approx_mult_SReal1: "[| (a::hypreal) \<in> \<real>; x \<approx> 0 |] ==> x*a \<approx> 0"
  6.1389 -by (auto dest: SReal_subset_HFinite [THEN subsetD] approx_mult1)
  6.1390 -
  6.1391 -lemma approx_mult_SReal2: "[| (a::hypreal) \<in> \<real>; x \<approx> 0 |] ==> a*x \<approx> 0"
  6.1392 -by (auto dest: SReal_subset_HFinite [THEN subsetD] approx_mult2)
  6.1393 +lemma approx_mult_SReal_zero_cancel_iff [simp]: "a \<in> \<real> \<Longrightarrow> a \<noteq> 0 \<Longrightarrow> a * x \<approx> 0 \<longleftrightarrow> x \<approx> 0"
  6.1394 +  for a x :: hypreal
  6.1395 +  by (blast intro: approx_SReal_mult_cancel_zero approx_mult_SReal2)
  6.1396  
  6.1397 -lemma approx_mult_SReal_zero_cancel_iff [simp]:
  6.1398 -     "[|(a::hypreal) \<in> \<real>; a \<noteq> 0 |] ==> (a*x \<approx> 0) = (x \<approx> 0)"
  6.1399 -by (blast intro: approx_SReal_mult_cancel_zero approx_mult_SReal2)
  6.1400 +lemma approx_SReal_mult_cancel: "a \<in> \<real> \<Longrightarrow> a \<noteq> 0 \<Longrightarrow> a * w \<approx> a * z \<Longrightarrow> w \<approx> z"
  6.1401 +  for a w z :: hypreal
  6.1402 +  apply (drule Reals_inverse [THEN SReal_subset_HFinite [THEN subsetD]])
  6.1403 +  apply (auto dest: approx_mult2 simp add: mult.assoc [symmetric])
  6.1404 +  done
  6.1405  
  6.1406 -lemma approx_SReal_mult_cancel:
  6.1407 -     "[| (a::hypreal) \<in> \<real>; a \<noteq> 0; a* w \<approx> a*z |] ==> w \<approx> z"
  6.1408 -apply (drule Reals_inverse [THEN SReal_subset_HFinite [THEN subsetD]])
  6.1409 -apply (auto dest: approx_mult2 simp add: mult.assoc [symmetric])
  6.1410 -done
  6.1411 +lemma approx_SReal_mult_cancel_iff1 [simp]: "a \<in> \<real> \<Longrightarrow> a \<noteq> 0 \<Longrightarrow> a * w \<approx> a * z \<longleftrightarrow> w \<approx> z"
  6.1412 +  for a w z :: hypreal
  6.1413 +  by (auto intro!: approx_mult2 SReal_subset_HFinite [THEN subsetD]
  6.1414 +      intro: approx_SReal_mult_cancel)
  6.1415  
  6.1416 -lemma approx_SReal_mult_cancel_iff1 [simp]:
  6.1417 -     "[| (a::hypreal) \<in> \<real>; a \<noteq> 0|] ==> (a* w \<approx> a*z) = (w \<approx> z)"
  6.1418 -by (auto intro!: approx_mult2 SReal_subset_HFinite [THEN subsetD]
  6.1419 -         intro: approx_SReal_mult_cancel)
  6.1420 +lemma approx_le_bound: "z \<le> f \<Longrightarrow> f \<approx> g \<Longrightarrow> g \<le> z ==> f \<approx> z"
  6.1421 +  for z :: hypreal
  6.1422 +  apply (simp add: bex_Infinitesimal_iff2 [symmetric], auto)
  6.1423 +  apply (rule_tac x = "g + y - z" in bexI)
  6.1424 +   apply simp
  6.1425 +  apply (rule Infinitesimal_interval2)
  6.1426 +     apply (rule_tac [2] Infinitesimal_zero, auto)
  6.1427 +  done
  6.1428  
  6.1429 -lemma approx_le_bound: "[| (z::hypreal) \<le> f; f \<approx> g; g \<le> z |] ==> f \<approx> z"
  6.1430 -apply (simp add: bex_Infinitesimal_iff2 [symmetric], auto)
  6.1431 -apply (rule_tac x = "g+y-z" in bexI)
  6.1432 -apply (simp (no_asm))
  6.1433 -apply (rule Infinitesimal_interval2)
  6.1434 -apply (rule_tac [2] Infinitesimal_zero, auto)
  6.1435 -done
  6.1436 -
  6.1437 -lemma approx_hnorm:
  6.1438 -  fixes x y :: "'a::real_normed_vector star"
  6.1439 -  shows "x \<approx> y \<Longrightarrow> hnorm x \<approx> hnorm y"
  6.1440 +lemma approx_hnorm: "x \<approx> y \<Longrightarrow> hnorm x \<approx> hnorm y"
  6.1441 +  for x y :: "'a::real_normed_vector star"
  6.1442  proof (unfold approx_def)
  6.1443    assume "x - y \<in> Infinitesimal"
  6.1444 -  hence 1: "hnorm (x - y) \<in> Infinitesimal"
  6.1445 +  then have "hnorm (x - y) \<in> Infinitesimal"
  6.1446      by (simp only: Infinitesimal_hnorm_iff)
  6.1447 -  moreover have 2: "(0::real star) \<in> Infinitesimal"
  6.1448 +  moreover have "(0::real star) \<in> Infinitesimal"
  6.1449      by (rule Infinitesimal_zero)
  6.1450 -  moreover have 3: "0 \<le> \<bar>hnorm x - hnorm y\<bar>"
  6.1451 +  moreover have "0 \<le> \<bar>hnorm x - hnorm y\<bar>"
  6.1452      by (rule abs_ge_zero)
  6.1453 -  moreover have 4: "\<bar>hnorm x - hnorm y\<bar> \<le> hnorm (x - y)"
  6.1454 +  moreover have "\<bar>hnorm x - hnorm y\<bar> \<le> hnorm (x - y)"
  6.1455      by (rule hnorm_triangle_ineq3)
  6.1456    ultimately have "\<bar>hnorm x - hnorm y\<bar> \<in> Infinitesimal"
  6.1457      by (rule Infinitesimal_interval2)
  6.1458 -  thus "hnorm x - hnorm y \<in> Infinitesimal"
  6.1459 +  then show "hnorm x - hnorm y \<in> Infinitesimal"
  6.1460      by (simp only: Infinitesimal_hrabs_iff)
  6.1461  qed
  6.1462  
  6.1463  
  6.1464 -subsection\<open>Zero is the Only Infinitesimal that is also a Real\<close>
  6.1465 +subsection \<open>Zero is the Only Infinitesimal that is also a Real\<close>
  6.1466  
  6.1467 -lemma Infinitesimal_less_SReal:
  6.1468 -     "[| (x::hypreal) \<in> \<real>; y \<in> Infinitesimal; 0 < x |] ==> y < x"
  6.1469 -apply (simp add: Infinitesimal_def)
  6.1470 -apply (rule abs_ge_self [THEN order_le_less_trans], auto)
  6.1471 -done
  6.1472 +lemma Infinitesimal_less_SReal: "x \<in> \<real> \<Longrightarrow> y \<in> Infinitesimal \<Longrightarrow> 0 < x \<Longrightarrow> y < x"
  6.1473 +  for x y :: hypreal
  6.1474 +  apply (simp add: Infinitesimal_def)
  6.1475 +  apply (rule abs_ge_self [THEN order_le_less_trans], auto)
  6.1476 +  done
  6.1477  
  6.1478 -lemma Infinitesimal_less_SReal2:
  6.1479 -     "(y::hypreal) \<in> Infinitesimal ==> \<forall>r \<in> Reals. 0 < r --> y < r"
  6.1480 -by (blast intro: Infinitesimal_less_SReal)
  6.1481 +lemma Infinitesimal_less_SReal2: "y \<in> Infinitesimal \<Longrightarrow> \<forall>r \<in> Reals. 0 < r \<longrightarrow> y < r"
  6.1482 +  for y :: hypreal
  6.1483 +  by (blast intro: Infinitesimal_less_SReal)
  6.1484  
  6.1485 -lemma SReal_not_Infinitesimal:
  6.1486 -     "[| 0 < y;  (y::hypreal) \<in> \<real>|] ==> y \<notin> Infinitesimal"
  6.1487 -apply (simp add: Infinitesimal_def)
  6.1488 -apply (auto simp add: abs_if)
  6.1489 -done
  6.1490 +lemma SReal_not_Infinitesimal: "0 < y \<Longrightarrow> y \<in> \<real> ==> y \<notin> Infinitesimal"
  6.1491 +  for y :: hypreal
  6.1492 +  apply (simp add: Infinitesimal_def)
  6.1493 +  apply (auto simp add: abs_if)
  6.1494 +  done
  6.1495  
  6.1496 -lemma SReal_minus_not_Infinitesimal:
  6.1497 -     "[| y < 0;  (y::hypreal) \<in> \<real> |] ==> y \<notin> Infinitesimal"
  6.1498 -apply (subst Infinitesimal_minus_iff [symmetric])
  6.1499 -apply (rule SReal_not_Infinitesimal, auto)
  6.1500 -done
  6.1501 +lemma SReal_minus_not_Infinitesimal: "y < 0 \<Longrightarrow> y \<in> \<real> \<Longrightarrow> y \<notin> Infinitesimal"
  6.1502 +  for y :: hypreal
  6.1503 +  apply (subst Infinitesimal_minus_iff [symmetric])
  6.1504 +  apply (rule SReal_not_Infinitesimal, auto)
  6.1505 +  done
  6.1506  
  6.1507  lemma SReal_Int_Infinitesimal_zero: "\<real> Int Infinitesimal = {0::hypreal}"
  6.1508 -apply auto
  6.1509 -apply (cut_tac x = x and y = 0 in linorder_less_linear)
  6.1510 -apply (blast dest: SReal_not_Infinitesimal SReal_minus_not_Infinitesimal)
  6.1511 -done
  6.1512 +  apply auto
  6.1513 +  apply (cut_tac x = x and y = 0 in linorder_less_linear)
  6.1514 +  apply (blast dest: SReal_not_Infinitesimal SReal_minus_not_Infinitesimal)
  6.1515 +  done
  6.1516  
  6.1517 -lemma SReal_Infinitesimal_zero:
  6.1518 -  "[| (x::hypreal) \<in> \<real>; x \<in> Infinitesimal|] ==> x = 0"
  6.1519 -by (cut_tac SReal_Int_Infinitesimal_zero, blast)
  6.1520 +lemma SReal_Infinitesimal_zero: "x \<in> \<real> \<Longrightarrow> x \<in> Infinitesimal \<Longrightarrow> x = 0"
  6.1521 +  for x :: hypreal
  6.1522 +  using SReal_Int_Infinitesimal_zero by blast
  6.1523  
  6.1524 -lemma SReal_HFinite_diff_Infinitesimal:
  6.1525 -     "[| (x::hypreal) \<in> \<real>; x \<noteq> 0 |] ==> x \<in> HFinite - Infinitesimal"
  6.1526 -by (auto dest: SReal_Infinitesimal_zero SReal_subset_HFinite [THEN subsetD])
  6.1527 +lemma SReal_HFinite_diff_Infinitesimal: "x \<in> \<real> \<Longrightarrow> x \<noteq> 0 \<Longrightarrow> x \<in> HFinite - Infinitesimal"
  6.1528 +  for x :: hypreal
  6.1529 +  by (auto dest: SReal_Infinitesimal_zero SReal_subset_HFinite [THEN subsetD])
  6.1530  
  6.1531  lemma hypreal_of_real_HFinite_diff_Infinitesimal:
  6.1532 -     "hypreal_of_real x \<noteq> 0 ==> hypreal_of_real x \<in> HFinite - Infinitesimal"
  6.1533 -by (rule SReal_HFinite_diff_Infinitesimal, auto)
  6.1534 +  "hypreal_of_real x \<noteq> 0 \<Longrightarrow> hypreal_of_real x \<in> HFinite - Infinitesimal"
  6.1535 +  by (rule SReal_HFinite_diff_Infinitesimal) auto
  6.1536  
  6.1537 -lemma star_of_Infinitesimal_iff_0 [iff]:
  6.1538 -  "(star_of x \<in> Infinitesimal) = (x = 0)"
  6.1539 -apply (auto simp add: Infinitesimal_def)
  6.1540 -apply (drule_tac x="hnorm (star_of x)" in bspec)
  6.1541 -apply (simp add: SReal_def)
  6.1542 -apply (rule_tac x="norm x" in exI, simp)
  6.1543 -apply simp
  6.1544 -done
  6.1545 +lemma star_of_Infinitesimal_iff_0 [iff]: "star_of x \<in> Infinitesimal \<longleftrightarrow> x = 0"
  6.1546 +  apply (auto simp add: Infinitesimal_def)
  6.1547 +  apply (drule_tac x="hnorm (star_of x)" in bspec)
  6.1548 +   apply (simp add: SReal_def)
  6.1549 +   apply (rule_tac x="norm x" in exI, simp)
  6.1550 +  apply simp
  6.1551 +  done
  6.1552  
  6.1553 -lemma star_of_HFinite_diff_Infinitesimal:
  6.1554 -     "x \<noteq> 0 ==> star_of x \<in> HFinite - Infinitesimal"
  6.1555 -by simp
  6.1556 +lemma star_of_HFinite_diff_Infinitesimal: "x \<noteq> 0 \<Longrightarrow> star_of x \<in> HFinite - Infinitesimal"
  6.1557 +  by simp
  6.1558  
  6.1559  lemma numeral_not_Infinitesimal [simp]:
  6.1560 -     "numeral w \<noteq> (0::hypreal) ==> (numeral w :: hypreal) \<notin> Infinitesimal"
  6.1561 -by (fast dest: Reals_numeral [THEN SReal_Infinitesimal_zero])
  6.1562 +  "numeral w \<noteq> (0::hypreal) \<Longrightarrow> (numeral w :: hypreal) \<notin> Infinitesimal"
  6.1563 +  by (fast dest: Reals_numeral [THEN SReal_Infinitesimal_zero])
  6.1564  
  6.1565 -(*again: 1 is a special case, but not 0 this time*)
  6.1566 +text \<open>Again: \<open>1\<close> is a special case, but not \<open>0\<close> this time.\<close>
  6.1567  lemma one_not_Infinitesimal [simp]:
  6.1568    "(1::'a::{real_normed_vector,zero_neq_one} star) \<notin> Infinitesimal"
  6.1569 -apply (simp only: star_one_def star_of_Infinitesimal_iff_0)
  6.1570 -apply simp
  6.1571 -done
  6.1572 +  apply (simp only: star_one_def star_of_Infinitesimal_iff_0)
  6.1573 +  apply simp
  6.1574 +  done
  6.1575  
  6.1576 -lemma approx_SReal_not_zero:
  6.1577 -  "[| (y::hypreal) \<in> \<real>; x \<approx> y; y\<noteq> 0 |] ==> x \<noteq> 0"
  6.1578 -apply (cut_tac x = 0 and y = y in linorder_less_linear, simp)
  6.1579 -apply (blast dest: approx_sym [THEN mem_infmal_iff [THEN iffD2]] SReal_not_Infinitesimal SReal_minus_not_Infinitesimal)
  6.1580 -done
  6.1581 +lemma approx_SReal_not_zero: "y \<in> \<real> \<Longrightarrow> x \<approx> y \<Longrightarrow> y \<noteq> 0 \<Longrightarrow> x \<noteq> 0"
  6.1582 +  for x y :: hypreal
  6.1583 +  apply (cut_tac x = 0 and y = y in linorder_less_linear, simp)
  6.1584 +  apply (blast dest: approx_sym [THEN mem_infmal_iff [THEN iffD2]]
  6.1585 +      SReal_not_Infinitesimal SReal_minus_not_Infinitesimal)
  6.1586 +  done
  6.1587  
  6.1588  lemma HFinite_diff_Infinitesimal_approx:
  6.1589 -     "[| x \<approx> y; y \<in> HFinite - Infinitesimal |]
  6.1590 -      ==> x \<in> HFinite - Infinitesimal"
  6.1591 -apply (auto intro: approx_sym [THEN [2] approx_HFinite]
  6.1592 -            simp add: mem_infmal_iff)
  6.1593 -apply (drule approx_trans3, assumption)
  6.1594 -apply (blast dest: approx_sym)
  6.1595 -done
  6.1596 +  "x \<approx> y \<Longrightarrow> y \<in> HFinite - Infinitesimal \<Longrightarrow> x \<in> HFinite - Infinitesimal"
  6.1597 +  apply (auto intro: approx_sym [THEN [2] approx_HFinite] simp: mem_infmal_iff)
  6.1598 +  apply (drule approx_trans3, assumption)
  6.1599 +  apply (blast dest: approx_sym)
  6.1600 +  done
  6.1601  
  6.1602 -(*The premise y\<noteq>0 is essential; otherwise x/y =0 and we lose the
  6.1603 -  HFinite premise.*)
  6.1604 +text \<open>The premise \<open>y \<noteq> 0\<close> is essential; otherwise \<open>x / y = 0\<close> and we lose the
  6.1605 +  \<open>HFinite\<close> premise.\<close>
  6.1606  lemma Infinitesimal_ratio:
  6.1607 -  fixes x y :: "'a::{real_normed_div_algebra,field} star"
  6.1608 -  shows "[| y \<noteq> 0;  y \<in> Infinitesimal;  x/y \<in> HFinite |]
  6.1609 -         ==> x \<in> Infinitesimal"
  6.1610 -apply (drule Infinitesimal_HFinite_mult2, assumption)
  6.1611 -apply (simp add: divide_inverse mult.assoc)
  6.1612 -done
  6.1613 +  "y \<noteq> 0 \<Longrightarrow> y \<in> Infinitesimal \<Longrightarrow> x / y \<in> HFinite \<Longrightarrow> x \<in> Infinitesimal"
  6.1614 +  for x y :: "'a::{real_normed_div_algebra,field} star"
  6.1615 +  apply (drule Infinitesimal_HFinite_mult2, assumption)
  6.1616 +  apply (simp add: divide_inverse mult.assoc)
  6.1617 +  done
  6.1618 +
  6.1619 +lemma Infinitesimal_SReal_divide: "x \<in> Infinitesimal \<Longrightarrow> y \<in> \<real> \<Longrightarrow> x / y \<in> Infinitesimal"
  6.1620 +  for x y :: hypreal
  6.1621 +  apply (simp add: divide_inverse)
  6.1622 +  apply (auto intro!: Infinitesimal_HFinite_mult
  6.1623 +      dest!: Reals_inverse [THEN SReal_subset_HFinite [THEN subsetD]])
  6.1624 +  done
  6.1625 +
  6.1626 +
  6.1627 +section \<open>Standard Part Theorem\<close>
  6.1628  
  6.1629 -lemma Infinitesimal_SReal_divide:
  6.1630 -  "[| (x::hypreal) \<in> Infinitesimal; y \<in> \<real> |] ==> x/y \<in> Infinitesimal"
  6.1631 -apply (simp add: divide_inverse)
  6.1632 -apply (auto intro!: Infinitesimal_HFinite_mult
  6.1633 -            dest!: Reals_inverse [THEN SReal_subset_HFinite [THEN subsetD]])
  6.1634 -done
  6.1635 +text \<open>
  6.1636 +  Every finite \<open>x \<in> R*\<close> is infinitely close to a unique real number
  6.1637 +  (i.e. a member of \<open>Reals\<close>).
  6.1638 +\<close>
  6.1639  
  6.1640 -(*------------------------------------------------------------------
  6.1641 -       Standard Part Theorem: Every finite x: R* is infinitely
  6.1642 -       close to a unique real number (i.e a member of Reals)
  6.1643 - ------------------------------------------------------------------*)
  6.1644  
  6.1645 -subsection\<open>Uniqueness: Two Infinitely Close Reals are Equal\<close>
  6.1646 +subsection \<open>Uniqueness: Two Infinitely Close Reals are Equal\<close>
  6.1647  
  6.1648 -lemma star_of_approx_iff [simp]: "(star_of x \<approx> star_of y) = (x = y)"
  6.1649 -apply safe
  6.1650 -apply (simp add: approx_def)
  6.1651 -apply (simp only: star_of_diff [symmetric])
  6.1652 -apply (simp only: star_of_Infinitesimal_iff_0)
  6.1653 -apply simp
  6.1654 -done
  6.1655 +lemma star_of_approx_iff [simp]: "star_of x \<approx> star_of y \<longleftrightarrow> x = y"
  6.1656 +  apply safe
  6.1657 +  apply (simp add: approx_def)
  6.1658 +  apply (simp only: star_of_diff [symmetric])
  6.1659 +  apply (simp only: star_of_Infinitesimal_iff_0)
  6.1660 +  apply simp
  6.1661 +  done
  6.1662  
  6.1663 -lemma SReal_approx_iff:
  6.1664 -  "[|(x::hypreal) \<in> \<real>; y \<in> \<real>|] ==> (x \<approx> y) = (x = y)"
  6.1665 -apply auto
  6.1666 -apply (simp add: approx_def)
  6.1667 -apply (drule (1) Reals_diff)
  6.1668 -apply (drule (1) SReal_Infinitesimal_zero)
  6.1669 -apply simp
  6.1670 -done
  6.1671 +lemma SReal_approx_iff: "x \<in> \<real> \<Longrightarrow> y \<in> \<real> \<Longrightarrow> x \<approx> y \<longleftrightarrow> x = y"
  6.1672 +  for x y :: hypreal
  6.1673 +  apply auto
  6.1674 +  apply (simp add: approx_def)
  6.1675 +  apply (drule (1) Reals_diff)
  6.1676 +  apply (drule (1) SReal_Infinitesimal_zero)
  6.1677 +  apply simp
  6.1678 +  done
  6.1679  
  6.1680  lemma numeral_approx_iff [simp]:
  6.1681 -     "(numeral v \<approx> (numeral w :: 'a::{numeral,real_normed_vector} star)) =
  6.1682 -      (numeral v = (numeral w :: 'a))"
  6.1683 -apply (unfold star_numeral_def)
  6.1684 -apply (rule star_of_approx_iff)
  6.1685 -done
  6.1686 +  "(numeral v \<approx> (numeral w :: 'a::{numeral,real_normed_vector} star)) =
  6.1687 +    (numeral v = (numeral w :: 'a))"
  6.1688 +  apply (unfold star_numeral_def)
  6.1689 +  apply (rule star_of_approx_iff)
  6.1690 +  done
  6.1691  
  6.1692 -(*And also for 0 \<approx> #nn and 1 \<approx> #nn, #nn \<approx> 0 and #nn \<approx> 1.*)
  6.1693 +text \<open>And also for \<open>0 \<approx> #nn\<close> and \<open>1 \<approx> #nn\<close>, \<open>#nn \<approx> 0\<close> and \<open>#nn \<approx> 1\<close>.\<close>
  6.1694  lemma [simp]:
  6.1695 -  "(numeral w \<approx> (0::'a::{numeral,real_normed_vector} star)) =
  6.1696 -   (numeral w = (0::'a))"
  6.1697 -  "((0::'a::{numeral,real_normed_vector} star) \<approx> numeral w) =
  6.1698 -   (numeral w = (0::'a))"
  6.1699 -  "(numeral w \<approx> (1::'b::{numeral,one,real_normed_vector} star)) =
  6.1700 -   (numeral w = (1::'b))"
  6.1701 -  "((1::'b::{numeral,one,real_normed_vector} star) \<approx> numeral w) =
  6.1702 -   (numeral w = (1::'b))"
  6.1703 -  "~ (0 \<approx> (1::'c::{zero_neq_one,real_normed_vector} star))"
  6.1704 -  "~ (1 \<approx> (0::'c::{zero_neq_one,real_normed_vector} star))"
  6.1705 -apply (unfold star_numeral_def star_zero_def star_one_def)
  6.1706 -apply (unfold star_of_approx_iff)
  6.1707 -by (auto intro: sym)
  6.1708 +  "(numeral w \<approx> (0::'a::{numeral,real_normed_vector} star)) = (numeral w = (0::'a))"
  6.1709 +  "((0::'a::{numeral,real_normed_vector} star) \<approx> numeral w) = (numeral w = (0::'a))"
  6.1710 +  "(numeral w \<approx> (1::'b::{numeral,one,real_normed_vector} star)) = (numeral w = (1::'b))"
  6.1711 +  "((1::'b::{numeral,one,real_normed_vector} star) \<approx> numeral w) = (numeral w = (1::'b))"
  6.1712 +  "\<not> (0 \<approx> (1::'c::{zero_neq_one,real_normed_vector} star))"
  6.1713 +  "\<not> (1 \<approx> (0::'c::{zero_neq_one,real_normed_vector} star))"
  6.1714 +       apply (unfold star_numeral_def star_zero_def star_one_def)
  6.1715 +       apply (unfold star_of_approx_iff)
  6.1716 +       apply (auto intro: sym)
  6.1717 +  done
  6.1718  
  6.1719 -lemma star_of_approx_numeral_iff [simp]:
  6.1720 -     "(star_of k \<approx> numeral w) = (k = numeral w)"
  6.1721 -by (subst star_of_approx_iff [symmetric], auto)
  6.1722 +lemma star_of_approx_numeral_iff [simp]: "star_of k \<approx> numeral w \<longleftrightarrow> k = numeral w"
  6.1723 +  by (subst star_of_approx_iff [symmetric]) auto
  6.1724  
  6.1725 -lemma star_of_approx_zero_iff [simp]: "(star_of k \<approx> 0) = (k = 0)"
  6.1726 -by (simp_all add: star_of_approx_iff [symmetric])
  6.1727 +lemma star_of_approx_zero_iff [simp]: "star_of k \<approx> 0 \<longleftrightarrow> k = 0"
  6.1728 +  by (simp_all add: star_of_approx_iff [symmetric])
  6.1729  
  6.1730 -lemma star_of_approx_one_iff [simp]: "(star_of k \<approx> 1) = (k = 1)"
  6.1731 -by (simp_all add: star_of_approx_iff [symmetric])
  6.1732 +lemma star_of_approx_one_iff [simp]: "star_of k \<approx> 1 \<longleftrightarrow> k = 1"
  6.1733 +  by (simp_all add: star_of_approx_iff [symmetric])
  6.1734  
  6.1735 -lemma approx_unique_real:
  6.1736 -     "[| (r::hypreal) \<in> \<real>; s \<in> \<real>; r \<approx> x; s \<approx> x|] ==> r = s"
  6.1737 -by (blast intro: SReal_approx_iff [THEN iffD1] approx_trans2)
  6.1738 +lemma approx_unique_real: "r \<in> \<real> \<Longrightarrow> s \<in> \<real> \<Longrightarrow> r \<approx> x \<Longrightarrow> s \<approx> x \<Longrightarrow> r = s"
  6.1739 +  for r s :: hypreal
  6.1740 +  by (blast intro: SReal_approx_iff [THEN iffD1] approx_trans2)
  6.1741  
  6.1742  
  6.1743 -subsection\<open>Existence of Unique Real Infinitely Close\<close>
  6.1744 +subsection \<open>Existence of Unique Real Infinitely Close\<close>
  6.1745  
  6.1746 -subsubsection\<open>Lifting of the Ub and Lub Properties\<close>
  6.1747 +subsubsection \<open>Lifting of the Ub and Lub Properties\<close>
  6.1748  
  6.1749 -lemma hypreal_of_real_isUb_iff:
  6.1750 -      "(isUb \<real> (hypreal_of_real ` Q) (hypreal_of_real Y)) =
  6.1751 -       (isUb (UNIV :: real set) Q Y)"
  6.1752 -by (simp add: isUb_def setle_def)
  6.1753 +lemma hypreal_of_real_isUb_iff: "isUb \<real> (hypreal_of_real ` Q) (hypreal_of_real Y) = isUb UNIV Q Y"
  6.1754 +  for Q :: "real set" and Y :: real
  6.1755 +  by (simp add: isUb_def setle_def)
  6.1756  
  6.1757 -lemma hypreal_of_real_isLub1:
  6.1758 -     "isLub \<real> (hypreal_of_real ` Q) (hypreal_of_real Y)
  6.1759 -      ==> isLub (UNIV :: real set) Q Y"
  6.1760 -apply (simp add: isLub_def leastP_def)
  6.1761 -apply (auto intro: hypreal_of_real_isUb_iff [THEN iffD2]
  6.1762 -            simp add: hypreal_of_real_isUb_iff setge_def)
  6.1763 -done
  6.1764 +lemma hypreal_of_real_isLub1: "isLub \<real> (hypreal_of_real ` Q) (hypreal_of_real Y) \<Longrightarrow> isLub UNIV Q Y"
  6.1765 +  for Q :: "real set" and Y :: real
  6.1766 +  apply (simp add: isLub_def leastP_def)
  6.1767 +  apply (auto intro: hypreal_of_real_isUb_iff [THEN iffD2]
  6.1768 +      simp add: hypreal_of_real_isUb_iff setge_def)
  6.1769 +  done
  6.1770  
  6.1771 -lemma hypreal_of_real_isLub2:
  6.1772 -      "isLub (UNIV :: real set) Q Y
  6.1773 -       ==> isLub \<real> (hypreal_of_real ` Q) (hypreal_of_real Y)"
  6.1774 -apply (auto simp add: isLub_def leastP_def hypreal_of_real_isUb_iff setge_def)
  6.1775 -by (metis SReal_iff hypreal_of_real_isUb_iff isUbD2a star_of_le)
  6.1776 +lemma hypreal_of_real_isLub2: "isLub UNIV Q Y \<Longrightarrow> isLub \<real> (hypreal_of_real ` Q) (hypreal_of_real Y)"
  6.1777 +  for Q :: "real set" and Y :: real
  6.1778 +  apply (auto simp add: isLub_def leastP_def hypreal_of_real_isUb_iff setge_def)
  6.1779 +  apply (metis SReal_iff hypreal_of_real_isUb_iff isUbD2a star_of_le)
  6.1780 +  done
  6.1781  
  6.1782  lemma hypreal_of_real_isLub_iff:
  6.1783 -     "(isLub \<real> (hypreal_of_real ` Q) (hypreal_of_real Y)) =
  6.1784 -      (isLub (UNIV :: real set) Q Y)"
  6.1785 -by (blast intro: hypreal_of_real_isLub1 hypreal_of_real_isLub2)
  6.1786 +  "isLub \<real> (hypreal_of_real ` Q) (hypreal_of_real Y) = isLub (UNIV :: real set) Q Y"
  6.1787 +  for Q :: "real set" and Y :: real
  6.1788 +  by (blast intro: hypreal_of_real_isLub1 hypreal_of_real_isLub2)
  6.1789  
  6.1790 -lemma lemma_isUb_hypreal_of_real:
  6.1791 -     "isUb \<real> P Y ==> \<exists>Yo. isUb \<real> P (hypreal_of_real Yo)"
  6.1792 -by (auto simp add: SReal_iff isUb_def)
  6.1793 +lemma lemma_isUb_hypreal_of_real: "isUb \<real> P Y \<Longrightarrow> \<exists>Yo. isUb \<real> P (hypreal_of_real Yo)"
  6.1794 +  by (auto simp add: SReal_iff isUb_def)
  6.1795 +
  6.1796 +lemma lemma_isLub_hypreal_of_real: "isLub \<real> P Y \<Longrightarrow> \<exists>Yo. isLub \<real> P (hypreal_of_real Yo)"
  6.1797 +  by (auto simp add: isLub_def leastP_def isUb_def SReal_iff)
  6.1798  
  6.1799 -lemma lemma_isLub_hypreal_of_real:
  6.1800 -     "isLub \<real> P Y ==> \<exists>Yo. isLub \<real> P (hypreal_of_real Yo)"
  6.1801 -by (auto simp add: isLub_def leastP_def isUb_def SReal_iff)
  6.1802 +lemma lemma_isLub_hypreal_of_real2: "\<exists>Yo. isLub \<real> P (hypreal_of_real Yo) \<Longrightarrow> \<exists>Y. isLub \<real> P Y"
  6.1803 +  by (auto simp add: isLub_def leastP_def isUb_def)
  6.1804  
  6.1805 -lemma lemma_isLub_hypreal_of_real2:
  6.1806 -     "\<exists>Yo. isLub \<real> P (hypreal_of_real Yo) ==> \<exists>Y. isLub \<real> P Y"
  6.1807 -by (auto simp add: isLub_def leastP_def isUb_def)
  6.1808 +lemma SReal_complete: "P \<subseteq> \<real> \<Longrightarrow> \<exists>x. x \<in> P \<Longrightarrow> \<exists>Y. isUb \<real> P Y \<Longrightarrow> \<exists>t::hypreal. isLub \<real> P t"
  6.1809 +  apply (frule SReal_hypreal_of_real_image)
  6.1810 +   apply (auto, drule lemma_isUb_hypreal_of_real)
  6.1811 +  apply (auto intro!: reals_complete lemma_isLub_hypreal_of_real2
  6.1812 +      simp add: hypreal_of_real_isLub_iff hypreal_of_real_isUb_iff)
  6.1813 +  done
  6.1814 +
  6.1815  
  6.1816 -lemma SReal_complete:
  6.1817 -     "[| P \<subseteq> \<real>;  \<exists>x. x \<in> P;  \<exists>Y. isUb \<real> P Y |]
  6.1818 -      ==> \<exists>t::hypreal. isLub \<real> P t"
  6.1819 -apply (frule SReal_hypreal_of_real_image)
  6.1820 -apply (auto, drule lemma_isUb_hypreal_of_real)
  6.1821 -apply (auto intro!: reals_complete lemma_isLub_hypreal_of_real2
  6.1822 -            simp add: hypreal_of_real_isLub_iff hypreal_of_real_isUb_iff)
  6.1823 -done
  6.1824 +text \<open>Lemmas about lubs.\<close>
  6.1825  
  6.1826 -(* lemma about lubs *)
  6.1827 +lemma lemma_st_part_ub: "x \<in> HFinite \<Longrightarrow> \<exists>u. isUb \<real> {s. s \<in> \<real> \<and> s < x} u"
  6.1828 +  for x :: hypreal
  6.1829 +  apply (drule HFiniteD, safe)
  6.1830 +  apply (rule exI, rule isUbI)
  6.1831 +   apply (auto intro: setleI isUbI simp add: abs_less_iff)
  6.1832 +  done
  6.1833  
  6.1834 -lemma lemma_st_part_ub:
  6.1835 -     "(x::hypreal) \<in> HFinite ==> \<exists>u. isUb \<real> {s. s \<in> \<real> & s < x} u"
  6.1836 -apply (drule HFiniteD, safe)
  6.1837 -apply (rule exI, rule isUbI)
  6.1838 -apply (auto intro: setleI isUbI simp add: abs_less_iff)
  6.1839 -done
  6.1840 +lemma lemma_st_part_nonempty: "x \<in> HFinite \<Longrightarrow> \<exists>y. y \<in> {s. s \<in> \<real> \<and> s < x}"
  6.1841 +  for x :: hypreal
  6.1842 +  apply (drule HFiniteD, safe)
  6.1843 +  apply (drule Reals_minus)
  6.1844 +  apply (rule_tac x = "-t" in exI)
  6.1845 +  apply (auto simp add: abs_less_iff)
  6.1846 +  done
  6.1847  
  6.1848 -lemma lemma_st_part_nonempty:
  6.1849 -  "(x::hypreal) \<in> HFinite ==> \<exists>y. y \<in> {s. s \<in> \<real> & s < x}"
  6.1850 -apply (drule HFiniteD, safe)
  6.1851 -apply (drule Reals_minus)
  6.1852 -apply (rule_tac x = "-t" in exI)
  6.1853 -apply (auto simp add: abs_less_iff)
  6.1854 -done
  6.1855 -
  6.1856 -lemma lemma_st_part_lub:
  6.1857 -     "(x::hypreal) \<in> HFinite ==> \<exists>t. isLub \<real> {s. s \<in> \<real> & s < x} t"
  6.1858 -by (blast intro!: SReal_complete lemma_st_part_ub lemma_st_part_nonempty Collect_restrict)
  6.1859 +lemma lemma_st_part_lub: "x \<in> HFinite \<Longrightarrow> \<exists>t. isLub \<real> {s. s \<in> \<real> \<and> s < x} t"
  6.1860 +  for x :: hypreal
  6.1861 +  by (blast intro!: SReal_complete lemma_st_part_ub lemma_st_part_nonempty Collect_restrict)
  6.1862  
  6.1863  lemma lemma_st_part_le1:
  6.1864 -     "[| (x::hypreal) \<in> HFinite;  isLub \<real> {s. s \<in> \<real> & s < x} t;
  6.1865 -         r \<in> \<real>;  0 < r |] ==> x \<le> t + r"
  6.1866 -apply (frule isLubD1a)
  6.1867 -apply (rule ccontr, drule linorder_not_le [THEN iffD2])
  6.1868 -apply (drule (1) Reals_add)
  6.1869 -apply (drule_tac y = "r + t" in isLubD1 [THEN setleD], auto)
  6.1870 -done
  6.1871 +  "x \<in> HFinite \<Longrightarrow> isLub \<real> {s. s \<in> \<real> \<and> s < x} t \<Longrightarrow> r \<in> \<real> \<Longrightarrow> 0 < r \<Longrightarrow> x \<le> t + r"
  6.1872 +  for x r t :: hypreal
  6.1873 +  apply (frule isLubD1a)
  6.1874 +  apply (rule ccontr, drule linorder_not_le [THEN iffD2])
  6.1875 +  apply (drule (1) Reals_add)
  6.1876 +  apply (drule_tac y = "r + t" in isLubD1 [THEN setleD], auto)
  6.1877 +  done
  6.1878  
  6.1879 -lemma hypreal_setle_less_trans:
  6.1880 -     "[| S *<= (x::hypreal); x < y |] ==> S *<= y"
  6.1881 -apply (simp add: setle_def)
  6.1882 -apply (auto dest!: bspec order_le_less_trans intro: order_less_imp_le)
  6.1883 -done
  6.1884 +lemma hypreal_setle_less_trans: "S *<= x \<Longrightarrow> x < y \<Longrightarrow> S *<= y"
  6.1885 +  for x y :: hypreal
  6.1886 +  apply (simp add: setle_def)
  6.1887 +  apply (auto dest!: bspec order_le_less_trans intro: order_less_imp_le)
  6.1888 +  done
  6.1889  
  6.1890 -lemma hypreal_gt_isUb:
  6.1891 -     "[| isUb R S (x::hypreal); x < y; y \<in> R |] ==> isUb R S y"
  6.1892 -apply (simp add: isUb_def)
  6.1893 -apply (blast intro: hypreal_setle_less_trans)
  6.1894 -done
  6.1895 +lemma hypreal_gt_isUb: "isUb R S x \<Longrightarrow> x < y \<Longrightarrow> y \<in> R \<Longrightarrow> isUb R S y"
  6.1896 +  for x y :: hypreal
  6.1897 +  apply (simp add: isUb_def)
  6.1898 +  apply (blast intro: hypreal_setle_less_trans)
  6.1899 +  done
  6.1900  
  6.1901 -lemma lemma_st_part_gt_ub:
  6.1902 -     "[| (x::hypreal) \<in> HFinite; x < y; y \<in> \<real> |]
  6.1903 -      ==> isUb \<real> {s. s \<in> \<real> & s < x} y"
  6.1904 -by (auto dest: order_less_trans intro: order_less_imp_le intro!: isUbI setleI)
  6.1905 +lemma lemma_st_part_gt_ub: "x \<in> HFinite \<Longrightarrow> x < y \<Longrightarrow> y \<in> \<real> \<Longrightarrow> isUb \<real> {s. s \<in> \<real> \<and> s < x} y"
  6.1906 +  for x y :: hypreal
  6.1907 +  by (auto dest: order_less_trans intro: order_less_imp_le intro!: isUbI setleI)
  6.1908  
  6.1909 -lemma lemma_minus_le_zero: "t \<le> t + -r ==> r \<le> (0::hypreal)"
  6.1910 -apply (drule_tac c = "-t" in add_left_mono)
  6.1911 -apply (auto simp add: add.assoc [symmetric])
  6.1912 -done
  6.1913 +lemma lemma_minus_le_zero: "t \<le> t + -r \<Longrightarrow> r \<le> 0"
  6.1914 +  for r t :: hypreal
  6.1915 +  apply (drule_tac c = "-t" in add_left_mono)
  6.1916 +  apply (auto simp add: add.assoc [symmetric])
  6.1917 +  done
  6.1918  
  6.1919  lemma lemma_st_part_le2:
  6.1920 -     "[| (x::hypreal) \<in> HFinite;
  6.1921 -         isLub \<real> {s. s \<in> \<real> & s < x} t;
  6.1922 -         r \<in> \<real>; 0 < r |]
  6.1923 -      ==> t + -r \<le> x"
  6.1924 -apply (frule isLubD1a)
  6.1925 -apply (rule ccontr, drule linorder_not_le [THEN iffD1])
  6.1926 -apply (drule Reals_minus, drule_tac a = t in Reals_add, assumption)
  6.1927 -apply (drule lemma_st_part_gt_ub, assumption+)
  6.1928 -apply (drule isLub_le_isUb, assumption)
  6.1929 -apply (drule lemma_minus_le_zero)
  6.1930 -apply (auto dest: order_less_le_trans)
  6.1931 -done
  6.1932 +  "x \<in> HFinite \<Longrightarrow> isLub \<real> {s. s \<in> \<real> \<and> s < x} t \<Longrightarrow> r \<in> \<real> \<Longrightarrow> 0 < r \<Longrightarrow> t + -r \<le> x"
  6.1933 +  for x r t :: hypreal
  6.1934 +  apply (frule isLubD1a)
  6.1935 +  apply (rule ccontr, drule linorder_not_le [THEN iffD1])
  6.1936 +  apply (drule Reals_minus, drule_tac a = t in Reals_add, assumption)
  6.1937 +  apply (drule lemma_st_part_gt_ub, assumption+)
  6.1938 +  apply (drule isLub_le_isUb, assumption)
  6.1939 +  apply (drule lemma_minus_le_zero)
  6.1940 +  apply (auto dest: order_less_le_trans)
  6.1941 +  done
  6.1942  
  6.1943  lemma lemma_st_part1a:
  6.1944 -     "[| (x::hypreal) \<in> HFinite;
  6.1945 -         isLub \<real> {s. s \<in> \<real> & s < x} t;
  6.1946 -         r \<in> \<real>; 0 < r |]
  6.1947 -      ==> x + -t \<le> r"
  6.1948 -apply (subgoal_tac "x \<le> t+r")
  6.1949 -apply (auto intro: lemma_st_part_le1)
  6.1950 -done
  6.1951 +  "x \<in> HFinite \<Longrightarrow> isLub \<real> {s. s \<in> \<real> \<and> s < x} t \<Longrightarrow> r \<in> \<real> \<Longrightarrow> 0 < r \<Longrightarrow> x + -t \<le> r"
  6.1952 +  for x r t :: hypreal
  6.1953 +  apply (subgoal_tac "x \<le> t + r")
  6.1954 +   apply (auto intro: lemma_st_part_le1)
  6.1955 +  done
  6.1956  
  6.1957  lemma lemma_st_part2a:
  6.1958 -     "[| (x::hypreal) \<in> HFinite;
  6.1959 -         isLub \<real> {s. s \<in> \<real> & s < x} t;
  6.1960 -         r \<in> \<real>;  0 < r |]
  6.1961 -      ==> -(x + -t) \<le> r"
  6.1962 -apply (subgoal_tac "(t + -r \<le> x)")
  6.1963 -apply simp
  6.1964 -apply (rule lemma_st_part_le2)
  6.1965 -apply auto
  6.1966 -done
  6.1967 +  "x \<in> HFinite \<Longrightarrow> isLub \<real> {s. s \<in> \<real> \<and> s < x} t \<Longrightarrow> r \<in> \<real> \<Longrightarrow> 0 < r \<Longrightarrow> - (x + -t) \<le> r"
  6.1968 +  for x r t :: hypreal
  6.1969 +  apply (subgoal_tac "(t + -r \<le> x)")
  6.1970 +   apply simp
  6.1971 +  apply (rule lemma_st_part_le2)
  6.1972 +     apply auto
  6.1973 +  done
  6.1974  
  6.1975 -lemma lemma_SReal_ub:
  6.1976 -     "(x::hypreal) \<in> \<real> ==> isUb \<real> {s. s \<in> \<real> & s < x} x"
  6.1977 -by (auto intro: isUbI setleI order_less_imp_le)
  6.1978 +lemma lemma_SReal_ub: "x \<in> \<real> \<Longrightarrow> isUb \<real> {s. s \<in> \<real> \<and> s < x} x"
  6.1979 +  for x :: hypreal
  6.1980 +  by (auto intro: isUbI setleI order_less_imp_le)
  6.1981  
  6.1982 -lemma lemma_SReal_lub:
  6.1983 -     "(x::hypreal) \<in> \<real> ==> isLub \<real> {s. s \<in> \<real> & s < x} x"
  6.1984 -apply (auto intro!: isLubI2 lemma_SReal_ub setgeI)
  6.1985 -apply (frule isUbD2a)
  6.1986 -apply (rule_tac x = x and y = y in linorder_cases)
  6.1987 -apply (auto intro!: order_less_imp_le)
  6.1988 -apply (drule SReal_dense, assumption, assumption, safe)
  6.1989 -apply (drule_tac y = r in isUbD)
  6.1990 -apply (auto dest: order_less_le_trans)
  6.1991 -done
  6.1992 +lemma lemma_SReal_lub: "x \<in> \<real> \<Longrightarrow> isLub \<real> {s. s \<in> \<real> \<and> s < x} x"
  6.1993 +  for x :: hypreal
  6.1994 +  apply (auto intro!: isLubI2 lemma_SReal_ub setgeI)
  6.1995 +  apply (frule isUbD2a)
  6.1996 +  apply (rule_tac x = x and y = y in linorder_cases)
  6.1997 +    apply (auto intro!: order_less_imp_le)
  6.1998 +  apply (drule SReal_dense, assumption, assumption, safe)
  6.1999 +  apply (drule_tac y = r in isUbD)
  6.2000 +   apply (auto dest: order_less_le_trans)
  6.2001 +  done
  6.2002  
  6.2003  lemma lemma_st_part_not_eq1:
  6.2004 -     "[| (x::hypreal) \<in> HFinite;
  6.2005 -         isLub \<real> {s. s \<in> \<real> & s < x} t;
  6.2006 -         r \<in> \<real>; 0 < r |]
  6.2007 -      ==> x + -t \<noteq> r"
  6.2008 -apply auto
  6.2009 -apply (frule isLubD1a [THEN Reals_minus])
  6.2010 -using Reals_add_cancel [of x "- t"] apply simp
  6.2011 -apply (drule_tac x = x in lemma_SReal_lub)
  6.2012 -apply (drule isLub_unique, assumption, auto)
  6.2013 -done
  6.2014 +  "x \<in> HFinite \<Longrightarrow> isLub \<real> {s. s \<in> \<real> \<and> s < x} t \<Longrightarrow> r \<in> \<real> \<Longrightarrow> 0 < r \<Longrightarrow> x + - t \<noteq> r"
  6.2015 +  for x r t :: hypreal
  6.2016 +  apply auto
  6.2017 +  apply (frule isLubD1a [THEN Reals_minus])
  6.2018 +  using Reals_add_cancel [of x "- t"] apply simp
  6.2019 +  apply (drule_tac x = x in lemma_SReal_lub)
  6.2020 +  apply (drule isLub_unique, assumption, auto)
  6.2021 +  done
  6.2022  
  6.2023  lemma lemma_st_part_not_eq2:
  6.2024 -     "[| (x::hypreal) \<in> HFinite;
  6.2025 -         isLub \<real> {s. s \<in> \<real> & s < x} t;
  6.2026 -         r \<in> \<real>; 0 < r |]
  6.2027 -      ==> -(x + -t) \<noteq> r"
  6.2028 -apply (auto)
  6.2029 -apply (frule isLubD1a)
  6.2030 -using Reals_add_cancel [of "- x" t] apply simp
  6.2031 -apply (drule_tac x = x in lemma_SReal_lub)
  6.2032 -apply (drule isLub_unique, assumption, auto)
  6.2033 -done
  6.2034 +  "x \<in> HFinite \<Longrightarrow> isLub \<real> {s. s \<in> \<real> \<and> s < x} t \<Longrightarrow> r \<in> \<real> \<Longrightarrow> 0 < r \<Longrightarrow> - (x + -t) \<noteq> r"
  6.2035 +  for x r t :: hypreal
  6.2036 +  apply (auto)
  6.2037 +  apply (frule isLubD1a)
  6.2038 +  using Reals_add_cancel [of "- x" t] apply simp
  6.2039 +  apply (drule_tac x = x in lemma_SReal_lub)
  6.2040 +  apply (drule isLub_unique, assumption, auto)
  6.2041 +  done
  6.2042  
  6.2043  lemma lemma_st_part_major:
  6.2044 -     "[| (x::hypreal) \<in> HFinite;
  6.2045 -         isLub \<real> {s. s \<in> \<real> & s < x} t;
  6.2046 -         r \<in> \<real>; 0 < r |]
  6.2047 -      ==> \<bar>x - t\<bar> < r"
  6.2048 -apply (frule lemma_st_part1a)
  6.2049 -apply (frule_tac [4] lemma_st_part2a, auto)
  6.2050 -apply (drule order_le_imp_less_or_eq)+
  6.2051 -apply auto
  6.2052 -using lemma_st_part_not_eq2 apply fastforce
  6.2053 -using lemma_st_part_not_eq1 apply fastforce
  6.2054 -done
  6.2055 +  "x \<in> HFinite \<Longrightarrow> isLub \<real> {s. s \<in> \<real> \<and> s < x} t \<Longrightarrow> r \<in> \<real> \<Longrightarrow> 0 < r \<Longrightarrow> \<bar>x - t\<bar> < r"
  6.2056 +  for x r t :: hypreal
  6.2057 +  apply (frule lemma_st_part1a)
  6.2058 +     apply (frule_tac [4] lemma_st_part2a, auto)
  6.2059 +  apply (drule order_le_imp_less_or_eq)+
  6.2060 +  apply auto
  6.2061 +  using lemma_st_part_not_eq2 apply fastforce
  6.2062 +  using lemma_st_part_not_eq1 apply fastforce
  6.2063 +  done
  6.2064  
  6.2065  lemma lemma_st_part_major2:
  6.2066 -     "[| (x::hypreal) \<in> HFinite; isLub \<real> {s. s \<in> \<real> & s < x} t |]
  6.2067 -      ==> \<forall>r \<in> Reals. 0 < r --> \<bar>x - t\<bar> < r"
  6.2068 -by (blast dest!: lemma_st_part_major)
  6.2069 -
  6.2070 +  "x \<in> HFinite \<Longrightarrow> isLub \<real> {s. s \<in> \<real> \<and> s < x} t \<Longrightarrow> \<forall>r \<in> Reals. 0 < r \<longrightarrow> \<bar>x - t\<bar> < r"
  6.2071 +  for x t :: hypreal
  6.2072 +  by (blast dest!: lemma_st_part_major)
  6.2073  
  6.2074  
  6.2075 -text\<open>Existence of real and Standard Part Theorem\<close>
  6.2076 -lemma lemma_st_part_Ex:
  6.2077 -     "(x::hypreal) \<in> HFinite
  6.2078 -       ==> \<exists>t \<in> Reals. \<forall>r \<in> Reals. 0 < r --> \<bar>x - t\<bar> < r"
  6.2079 -apply (frule lemma_st_part_lub, safe)
  6.2080 -apply (frule isLubD1a)
  6.2081 -apply (blast dest: lemma_st_part_major2)
  6.2082 -done
  6.2083 +text\<open>Existence of real and Standard Part Theorem.\<close>
  6.2084 +
  6.2085 +lemma lemma_st_part_Ex: "x \<in> HFinite \<Longrightarrow> \<exists>t\<in>Reals. \<forall>r \<in> Reals. 0 < r \<longrightarrow> \<bar>x - t\<bar> < r"
  6.2086 +  for x :: hypreal
  6.2087 +  apply (frule lemma_st_part_lub, safe)
  6.2088 +  apply (frule isLubD1a)
  6.2089 +  apply (blast dest: lemma_st_part_major2)
  6.2090 +  done
  6.2091  
  6.2092 -lemma st_part_Ex:
  6.2093 -     "(x::hypreal) \<in> HFinite ==> \<exists>t \<in> Reals. x \<approx> t"
  6.2094 -apply (simp add: approx_def Infinitesimal_def)
  6.2095 -apply (drule lemma_st_part_Ex, auto)
  6.2096 -done
  6.2097 +lemma st_part_Ex: "x \<in> HFinite \<Longrightarrow> \<exists>t\<in>Reals. x \<approx> t"
  6.2098 +  for x :: hypreal
  6.2099 +  apply (simp add: approx_def Infinitesimal_def)
  6.2100 +  apply (drule lemma_st_part_Ex, auto)
  6.2101 +  done
  6.2102  
  6.2103 -text\<open>There is a unique real infinitely close\<close>
  6.2104 -lemma st_part_Ex1: "x \<in> HFinite ==> \<exists>!t::hypreal. t \<in> \<real> & x \<approx> t"
  6.2105 -apply (drule st_part_Ex, safe)
  6.2106 -apply (drule_tac [2] approx_sym, drule_tac [2] approx_sym, drule_tac [2] approx_sym)
  6.2107 -apply (auto intro!: approx_unique_real)
  6.2108 -done
  6.2109 +text \<open>There is a unique real infinitely close.\<close>
  6.2110 +lemma st_part_Ex1: "x \<in> HFinite \<Longrightarrow> \<exists>!t::hypreal. t \<in> \<real> \<and> x \<approx> t"
  6.2111 +  apply (drule st_part_Ex, safe)
  6.2112 +   apply (drule_tac [2] approx_sym, drule_tac [2] approx_sym, drule_tac [2] approx_sym)
  6.2113 +   apply (auto intro!: approx_unique_real)
  6.2114 +  done
  6.2115  
  6.2116 -subsection\<open>Finite, Infinite and Infinitesimal\<close>
  6.2117 +
  6.2118 +subsection \<open>Finite, Infinite and Infinitesimal\<close>
  6.2119  
  6.2120  lemma HFinite_Int_HInfinite_empty [simp]: "HFinite Int HInfinite = {}"
  6.2121 -apply (simp add: HFinite_def HInfinite_def)
  6.2122 -apply (auto dest: order_less_trans)
  6.2123 -done
  6.2124 +  apply (simp add: HFinite_def HInfinite_def)
  6.2125 +  apply (auto dest: order_less_trans)
  6.2126 +  done
  6.2127  
  6.2128  lemma HFinite_not_HInfinite:
  6.2129 -  assumes x: "x \<in> HFinite" shows "x \<notin> HInfinite"
  6.2130 +  assumes x: "x \<in> HFinite"
  6.2131 +  shows "x \<notin> HInfinite"
  6.2132  proof
  6.2133    assume x': "x \<in> HInfinite"
  6.2134    with x have "x \<in> HFinite \<inter> HInfinite" by blast
  6.2135 -  thus False by auto
  6.2136 +  then show False by auto
  6.2137  qed
  6.2138  
  6.2139 -lemma not_HFinite_HInfinite: "x\<notin> HFinite ==> x \<in> HInfinite"
  6.2140 -apply (simp add: HInfinite_def HFinite_def, auto)
  6.2141 -apply (drule_tac x = "r + 1" in bspec)
  6.2142 -apply (auto)
  6.2143 -done
  6.2144 +lemma not_HFinite_HInfinite: "x \<notin> HFinite \<Longrightarrow> x \<in> HInfinite"
  6.2145 +  apply (simp add: HInfinite_def HFinite_def, auto)
  6.2146 +  apply (drule_tac x = "r + 1" in bspec)
  6.2147 +   apply (auto)
  6.2148 +  done
  6.2149  
  6.2150 -lemma HInfinite_HFinite_disj: "x \<in> HInfinite | x \<in> HFinite"
  6.2151 -by (blast intro: not_HFinite_HInfinite)
  6.2152 +lemma HInfinite_HFinite_disj: "x \<in> HInfinite \<or> x \<in> HFinite"
  6.2153 +  by (blast intro: not_HFinite_HInfinite)
  6.2154  
  6.2155 -lemma HInfinite_HFinite_iff: "(x \<in> HInfinite) = (x \<notin> HFinite)"
  6.2156 -by (blast dest: HFinite_not_HInfinite not_HFinite_HInfinite)
  6.2157 +lemma HInfinite_HFinite_iff: "x \<in> HInfinite \<longleftrightarrow> x \<notin> HFinite"
  6.2158 +  by (blast dest: HFinite_not_HInfinite not_HFinite_HInfinite)
  6.2159  
  6.2160 -lemma HFinite_HInfinite_iff: "(x \<in> HFinite) = (x \<notin> HInfinite)"
  6.2161 -by (simp add: HInfinite_HFinite_iff)
  6.2162 +lemma HFinite_HInfinite_iff: "x \<in> HFinite \<longleftrightarrow> x \<notin> HInfinite"
  6.2163 +  by (simp add: HInfinite_HFinite_iff)
  6.2164  
  6.2165  
  6.2166  lemma HInfinite_diff_HFinite_Infinitesimal_disj:
  6.2167 -     "x \<notin> Infinitesimal ==> x \<in> HInfinite | x \<in> HFinite - Infinitesimal"
  6.2168 -by (fast intro: not_HFinite_HInfinite)
  6.2169 +  "x \<notin> Infinitesimal \<Longrightarrow> x \<in> HInfinite \<or> x \<in> HFinite - Infinitesimal"
  6.2170 +  by (fast intro: not_HFinite_HInfinite)
  6.2171  
  6.2172 -lemma HFinite_inverse:
  6.2173 -  fixes x :: "'a::real_normed_div_algebra star"
  6.2174 -  shows "[| x \<in> HFinite; x \<notin> Infinitesimal |] ==> inverse x \<in> HFinite"
  6.2175 -apply (subgoal_tac "x \<noteq> 0")
  6.2176 -apply (cut_tac x = "inverse x" in HInfinite_HFinite_disj)
  6.2177 -apply (auto dest!: HInfinite_inverse_Infinitesimal
  6.2178 -            simp add: nonzero_inverse_inverse_eq)
  6.2179 -done
  6.2180 +lemma HFinite_inverse: "x \<in> HFinite \<Longrightarrow> x \<notin> Infinitesimal \<Longrightarrow> inverse x \<in> HFinite"
  6.2181 +  for x :: "'a::real_normed_div_algebra star"
  6.2182 +  apply (subgoal_tac "x \<noteq> 0")
  6.2183 +   apply (cut_tac x = "inverse x" in HInfinite_HFinite_disj)
  6.2184 +   apply (auto dest!: HInfinite_inverse_Infinitesimal simp: nonzero_inverse_inverse_eq)
  6.2185 +  done
  6.2186  
  6.2187 -lemma HFinite_inverse2:
  6.2188 -  fixes x :: "'a::real_normed_div_algebra star"
  6.2189 -  shows "x \<in> HFinite - Infinitesimal ==> inverse x \<in> HFinite"
  6.2190 -by (blast intro: HFinite_inverse)
  6.2191 +lemma HFinite_inverse2: "x \<in> HFinite - Infinitesimal \<Longrightarrow> inverse x \<in> HFinite"
  6.2192 +  for x :: "'a::real_normed_div_algebra star"
  6.2193 +  by (blast intro: HFinite_inverse)
  6.2194  
  6.2195 -(* stronger statement possible in fact *)
  6.2196 -lemma Infinitesimal_inverse_HFinite:
  6.2197 -  fixes x :: "'a::real_normed_div_algebra star"
  6.2198 -  shows "x \<notin> Infinitesimal ==> inverse(x) \<in> HFinite"
  6.2199 -apply (drule HInfinite_diff_HFinite_Infinitesimal_disj)
  6.2200 -apply (blast intro: HFinite_inverse HInfinite_inverse_Infinitesimal Infinitesimal_subset_HFinite [THEN subsetD])
  6.2201 -done
  6.2202 +text \<open>Stronger statement possible in fact.\<close>
  6.2203 +lemma Infinitesimal_inverse_HFinite: "x \<notin> Infinitesimal \<Longrightarrow> inverse x \<in> HFinite"
  6.2204 +  for x :: "'a::real_normed_div_algebra star"
  6.2205 +  apply (drule HInfinite_diff_HFinite_Infinitesimal_disj)
  6.2206 +  apply (blast intro: HFinite_inverse HInfinite_inverse_Infinitesimal Infinitesimal_subset_HFinite [THEN subsetD])
  6.2207 +  done
  6.2208  
  6.2209  lemma HFinite_not_Infinitesimal_inverse:
  6.2210 -  fixes x :: "'a::real_normed_div_algebra star"
  6.2211 -  shows "x \<in> HFinite - Infinitesimal ==> inverse x \<in> HFinite - Infinitesimal"
  6.2212 -apply (auto intro: Infinitesimal_inverse_HFinite)
  6.2213 -apply (drule Infinitesimal_HFinite_mult2, assumption)
  6.2214 -apply (simp add: not_Infinitesimal_not_zero)
  6.2215 -done
  6.2216 +  "x \<in> HFinite - Infinitesimal \<Longrightarrow> inverse x \<in> HFinite - Infinitesimal"
  6.2217 +  for x :: "'a::real_normed_div_algebra star"
  6.2218 +  apply (auto intro: Infinitesimal_inverse_HFinite)
  6.2219 +  apply (drule Infinitesimal_HFinite_mult2, assumption)
  6.2220 +  apply (simp add: not_Infinitesimal_not_zero)
  6.2221 +  done
  6.2222  
  6.2223 -lemma approx_inverse:
  6.2224 -  fixes x y :: "'a::real_normed_div_algebra star"
  6.2225 -  shows
  6.2226 -     "[| x \<approx> y; y \<in>  HFinite - Infinitesimal |]
  6.2227 -      ==> inverse x \<approx> inverse y"
  6.2228 -apply (frule HFinite_diff_Infinitesimal_approx, assumption)
  6.2229 -apply (frule not_Infinitesimal_not_zero2)
  6.2230 -apply (frule_tac x = x in not_Infinitesimal_not_zero2)
  6.2231 -apply (drule HFinite_inverse2)+
  6.2232 -apply (drule approx_mult2, assumption, auto)
  6.2233 -apply (drule_tac c = "inverse x" in approx_mult1, assumption)
  6.2234 -apply (auto intro: approx_sym simp add: mult.assoc)
  6.2235 -done
  6.2236 +lemma approx_inverse: "x \<approx> y \<Longrightarrow> y \<in> HFinite - Infinitesimal \<Longrightarrow> inverse x \<approx> inverse y"
  6.2237 +  for x y :: "'a::real_normed_div_algebra star"
  6.2238 +  apply (frule HFinite_diff_Infinitesimal_approx, assumption)
  6.2239 +  apply (frule not_Infinitesimal_not_zero2)
  6.2240 +  apply (frule_tac x = x in not_Infinitesimal_not_zero2)
  6.2241 +  apply (drule HFinite_inverse2)+
  6.2242 +  apply (drule approx_mult2, assumption, auto)
  6.2243 +  apply (drule_tac c = "inverse x" in approx_mult1, assumption)
  6.2244 +  apply (auto intro: approx_sym simp add: mult.assoc)
  6.2245 +  done
  6.2246  
  6.2247  (*Used for NSLIM_inverse, NSLIMSEQ_inverse*)
  6.2248  lemmas star_of_approx_inverse = star_of_HFinite_diff_Infinitesimal [THEN [2] approx_inverse]
  6.2249  lemmas hypreal_of_real_approx_inverse =  hypreal_of_real_HFinite_diff_Infinitesimal [THEN [2] approx_inverse]
  6.2250  
  6.2251  lemma inverse_add_Infinitesimal_approx:
  6.2252 -  fixes x h :: "'a::real_normed_div_algebra star"
  6.2253 -  shows
  6.2254 -     "[| x \<in> HFinite - Infinitesimal;
  6.2255 -         h \<in> Infinitesimal |] ==> inverse(x + h) \<approx> inverse x"
  6.2256 -apply (auto intro: approx_inverse approx_sym Infinitesimal_add_approx_self)
  6.2257 -done
  6.2258 +  "x \<in> HFinite - Infinitesimal \<Longrightarrow> h \<in> Infinitesimal \<Longrightarrow> inverse (x + h) \<approx> inverse x"
  6.2259 +  for x h :: "'a::real_normed_div_algebra star"
  6.2260 +  by (auto intro: approx_inverse approx_sym Infinitesimal_add_approx_self)
  6.2261  
  6.2262  lemma inverse_add_Infinitesimal_approx2:
  6.2263 -  fixes x h :: "'a::real_normed_div_algebra star"
  6.2264 -  shows
  6.2265 -     "[| x \<in> HFinite - Infinitesimal;
  6.2266 -         h \<in> Infinitesimal |] ==> inverse(h + x) \<approx> inverse x"
  6.2267 -apply (rule add.commute [THEN subst])
  6.2268 -apply (blast intro: inverse_add_Infinitesimal_approx)
  6.2269 -done
  6.2270 +  "x \<in> HFinite - Infinitesimal \<Longrightarrow> h \<in> Infinitesimal \<Longrightarrow> inverse (h + x) \<approx> inverse x"
  6.2271 +  for x h :: "'a::real_normed_div_algebra star"
  6.2272 +  apply (rule add.commute [THEN subst])
  6.2273 +  apply (blast intro: inverse_add_Infinitesimal_approx)
  6.2274 +  done
  6.2275  
  6.2276  lemma inverse_add_Infinitesimal_approx_Infinitesimal:
  6.2277 -  fixes x h :: "'a::real_normed_div_algebra star"
  6.2278 -  shows
  6.2279 -     "[| x \<in> HFinite - Infinitesimal;
  6.2280 -         h \<in> Infinitesimal |] ==> inverse(x + h) - inverse x \<approx> h"
  6.2281 -apply (rule approx_trans2)
  6.2282 -apply (auto intro: inverse_add_Infinitesimal_approx
  6.2283 -            simp add: mem_infmal_iff approx_minus_iff [symmetric])
  6.2284 -done
  6.2285 +  "x \<in> HFinite - Infinitesimal \<Longrightarrow> h \<in> Infinitesimal \<Longrightarrow> inverse (x + h) - inverse x \<approx> h"
  6.2286 +  for x h :: "'a::real_normed_div_algebra star"
  6.2287 +  apply (rule approx_trans2)
  6.2288 +   apply (auto intro: inverse_add_Infinitesimal_approx
  6.2289 +      simp add: mem_infmal_iff approx_minus_iff [symmetric])
  6.2290 +  done
  6.2291  
  6.2292 -lemma Infinitesimal_square_iff:
  6.2293 -  fixes x :: "'a::real_normed_div_algebra star"
  6.2294 -  shows "(x \<in> Infinitesimal) = (x*x \<in> Infinitesimal)"
  6.2295 -apply (auto intro: Infinitesimal_mult)
  6.2296 -apply (rule ccontr, frule Infinitesimal_inverse_HFinite)
  6.2297 -apply (frule not_Infinitesimal_not_zero)
  6.2298 -apply (auto dest: Infinitesimal_HFinite_mult simp add: mult.assoc)
  6.2299 -done
  6.2300 +lemma Infinitesimal_square_iff: "x \<in> Infinitesimal \<longleftrightarrow> x * x \<in> Infinitesimal"
  6.2301 +  for x :: "'a::real_normed_div_algebra star"
  6.2302 +  apply (auto intro: Infinitesimal_mult)
  6.2303 +  apply (rule ccontr, frule Infinitesimal_inverse_HFinite)
  6.2304 +  apply (frule not_Infinitesimal_not_zero)
  6.2305 +  apply (auto dest: Infinitesimal_HFinite_mult simp add: mult.assoc)
  6.2306 +  done
  6.2307  declare Infinitesimal_square_iff [symmetric, simp]
  6.2308  
  6.2309 -lemma HFinite_square_iff [simp]:
  6.2310 -  fixes x :: "'a::real_normed_div_algebra star"
  6.2311 -  shows "(x*x \<in> HFinite) = (x \<in> HFinite)"
  6.2312 -apply (auto intro: HFinite_mult)
  6.2313 -apply (auto dest: HInfinite_mult simp add: HFinite_HInfinite_iff)
  6.2314 -done
  6.2315 +lemma HFinite_square_iff [simp]: "x * x \<in> HFinite \<longleftrightarrow> x \<in> HFinite"
  6.2316 +  for x :: "'a::real_normed_div_algebra star"
  6.2317 +  apply (auto intro: HFinite_mult)
  6.2318 +  apply (auto dest: HInfinite_mult simp add: HFinite_HInfinite_iff)
  6.2319 +  done
  6.2320  
  6.2321 -lemma HInfinite_square_iff [simp]:
  6.2322 -  fixes x :: "'a::real_normed_div_algebra star"
  6.2323 -  shows "(x*x \<in> HInfinite) = (x \<in> HInfinite)"
  6.2324 -by (auto simp add: HInfinite_HFinite_iff)
  6.2325 +lemma HInfinite_square_iff [simp]: "x * x \<in> HInfinite \<longleftrightarrow> x \<in> HInfinite"
  6.2326 +  for x :: "'a::real_normed_div_algebra star"
  6.2327 +  by (auto simp add: HInfinite_HFinite_iff)
  6.2328  
  6.2329 -lemma approx_HFinite_mult_cancel:
  6.2330 -  fixes a w z :: "'a::real_normed_div_algebra star"
  6.2331 -  shows "[| a: HFinite-Infinitesimal; a* w \<approx> a*z |] ==> w \<approx> z"
  6.2332 -apply safe
  6.2333 -apply (frule HFinite_inverse, assumption)
  6.2334 -apply (drule not_Infinitesimal_not_zero)
  6.2335 -apply (auto dest: approx_mult2 simp add: mult.assoc [symmetric])
  6.2336 -done
  6.2337 +lemma approx_HFinite_mult_cancel: "a \<in> HFinite - Infinitesimal \<Longrightarrow> a * w \<approx> a * z \<Longrightarrow> w \<approx> z"
  6.2338 +  for a w z :: "'a::real_normed_div_algebra star"
  6.2339 +  apply safe
  6.2340 +  apply (frule HFinite_inverse, assumption)
  6.2341 +  apply (drule not_Infinitesimal_not_zero)
  6.2342 +  apply (auto dest: approx_mult2 simp add: mult.assoc [symmetric])
  6.2343 +  done
  6.2344  
  6.2345 -lemma approx_HFinite_mult_cancel_iff1:
  6.2346 -  fixes a w z :: "'a::real_normed_div_algebra star"
  6.2347 -  shows "a: HFinite-Infinitesimal ==> (a * w \<approx> a * z) = (w \<approx> z)"
  6.2348 -by (auto intro: approx_mult2 approx_HFinite_mult_cancel)
  6.2349 +lemma approx_HFinite_mult_cancel_iff1: "a \<in> HFinite - Infinitesimal \<Longrightarrow> a * w \<approx> a * z \<longleftrightarrow> w \<approx> z"
  6.2350 +  for a w z :: "'a::real_normed_div_algebra star"
  6.2351 +  by (auto intro: approx_mult2 approx_HFinite_mult_cancel)
  6.2352  
  6.2353 -lemma HInfinite_HFinite_add_cancel:
  6.2354 -     "[| x + y \<in> HInfinite; y \<in> HFinite |] ==> x \<in> HInfinite"
  6.2355 -apply (rule ccontr)
  6.2356 -apply (drule HFinite_HInfinite_iff [THEN iffD2])
  6.2357 -apply (auto dest: HFinite_add simp add: HInfinite_HFinite_iff)
  6.2358 -done
  6.2359 +lemma HInfinite_HFinite_add_cancel: "x + y \<in> HInfinite \<Longrightarrow> y \<in> HFinite \<Longrightarrow> x \<in> HInfinite"
  6.2360 +  apply (rule ccontr)
  6.2361 +  apply (drule HFinite_HInfinite_iff [THEN iffD2])
  6.2362 +  apply (auto dest: HFinite_add simp add: HInfinite_HFinite_iff)
  6.2363 +  done
  6.2364  
  6.2365 -lemma HInfinite_HFinite_add:
  6.2366 -     "[| x \<in> HInfinite; y \<in> HFinite |] ==> x + y \<in> HInfinite"
  6.2367 -apply (rule_tac y = "-y" in HInfinite_HFinite_add_cancel)
  6.2368 -apply (auto simp add: add.assoc HFinite_minus_iff)
  6.2369 -done
  6.2370 +lemma HInfinite_HFinite_add: "x \<in> HInfinite \<Longrightarrow> y \<in> HFinite \<Longrightarrow> x + y \<in> HInfinite"
  6.2371 +  apply (rule_tac y = "-y" in HInfinite_HFinite_add_cancel)
  6.2372 +   apply (auto simp add: add.assoc HFinite_minus_iff)
  6.2373 +  done
  6.2374  
  6.2375 -lemma HInfinite_ge_HInfinite:
  6.2376 -     "[| (x::hypreal) \<in> HInfinite; x \<le> y; 0 \<le> x |] ==> y \<in> HInfinite"
  6.2377 -by (auto intro: HFinite_bounded simp add: HInfinite_HFinite_iff)
  6.2378 +lemma HInfinite_ge_HInfinite: "x \<in> HInfinite \<Longrightarrow> x \<le> y \<Longrightarrow> 0 \<le> x \<Longrightarrow> y \<in> HInfinite"
  6.2379 +  for x y :: hypreal
  6.2380 +  by (auto intro: HFinite_bounded simp add: HInfinite_HFinite_iff)
  6.2381  
  6.2382 -lemma Infinitesimal_inverse_HInfinite:
  6.2383 -  fixes x :: "'a::real_normed_div_algebra star"
  6.2384 -  shows "[| x \<in> Infinitesimal; x \<noteq> 0 |] ==> inverse x \<in> HInfinite"
  6.2385 -apply (rule ccontr, drule HFinite_HInfinite_iff [THEN iffD2])
  6.2386 -apply (auto dest: Infinitesimal_HFinite_mult2)
  6.2387 -done
  6.2388 +lemma Infinitesimal_inverse_HInfinite: "x \<in> Infinitesimal \<Longrightarrow> x \<noteq> 0 \<Longrightarrow> inverse x \<in> HInfinite"
  6.2389 +  for x :: "'a::real_normed_div_algebra star"
  6.2390 +  apply (rule ccontr, drule HFinite_HInfinite_iff [THEN iffD2])
  6.2391 +  apply (auto dest: Infinitesimal_HFinite_mult2)
  6.2392 +  done
  6.2393  
  6.2394  lemma HInfinite_HFinite_not_Infinitesimal_mult:
  6.2395 -  fixes x y :: "'a::real_normed_div_algebra star"
  6.2396 -  shows "[| x \<in> HInfinite; y \<in> HFinite - Infinitesimal |]
  6.2397 -      ==> x * y \<in> HInfinite"
  6.2398 -apply (rule ccontr, drule HFinite_HInfinite_iff [THEN iffD2])
  6.2399 -apply (frule HFinite_Infinitesimal_not_zero)
  6.2400 -apply (drule HFinite_not_Infinitesimal_inverse)
  6.2401 -apply (safe, drule HFinite_mult)
  6.2402 -apply (auto simp add: mult.assoc HFinite_HInfinite_iff)
  6.2403 -done
  6.2404 +  "x \<in> HInfinite \<Longrightarrow> y \<in> HFinite - Infinitesimal \<Longrightarrow> x * y \<in> HInfinite"
  6.2405 +  for x y :: "'a::real_normed_div_algebra star"
  6.2406 +  apply (rule ccontr, drule HFinite_HInfinite_iff [THEN iffD2])
  6.2407 +  apply (frule HFinite_Infinitesimal_not_zero)
  6.2408 +  apply (drule HFinite_not_Infinitesimal_inverse)
  6.2409 +  apply (safe, drule HFinite_mult)
  6.2410 +   apply (auto simp add: mult.assoc HFinite_HInfinite_iff)
  6.2411 +  done
  6.2412  
  6.2413  lemma HInfinite_HFinite_not_Infinitesimal_mult2:
  6.2414 -  fixes x y :: "'a::real_normed_div_algebra star"
  6.2415 -  shows "[| x \<in> HInfinite; y \<in> HFinite - Infinitesimal |]
  6.2416 -      ==> y * x \<in> HInfinite"
  6.2417 -apply (rule ccontr, drule HFinite_HInfinite_iff [THEN iffD2])
  6.2418 -apply (frule HFinite_Infinitesimal_not_zero)
  6.2419 -apply (drule HFinite_not_Infinitesimal_inverse)
  6.2420 -apply (safe, drule_tac x="inverse y" in HFinite_mult)
  6.2421 -apply assumption
  6.2422 -apply (auto simp add: mult.assoc [symmetric] HFinite_HInfinite_iff)
  6.2423 -done
  6.2424 +  "x \<in> HInfinite \<Longrightarrow> y \<in> HFinite - Infinitesimal \<Longrightarrow> y * x \<in> HInfinite"
  6.2425 +  for x y :: "'a::real_normed_div_algebra star"
  6.2426 +  apply (rule ccontr, drule HFinite_HInfinite_iff [THEN iffD2])
  6.2427 +  apply (frule HFinite_Infinitesimal_not_zero)
  6.2428 +  apply (drule HFinite_not_Infinitesimal_inverse)
  6.2429 +  apply (safe, drule_tac x="inverse y" in HFinite_mult)
  6.2430 +   apply assumption
  6.2431 +  apply (auto simp add: mult.assoc [symmetric] HFinite_HInfinite_iff)
  6.2432 +  done
  6.2433  
  6.2434 -lemma HInfinite_gt_SReal:
  6.2435 -  "[| (x::hypreal) \<in> HInfinite; 0 < x; y \<in> \<real> |] ==> y < x"
  6.2436 -by (auto dest!: bspec simp add: HInfinite_def abs_if order_less_imp_le)
  6.2437 +lemma HInfinite_gt_SReal: "x \<in> HInfinite \<Longrightarrow> 0 < x \<Longrightarrow> y \<in> \<real> \<Longrightarrow> y < x"
  6.2438 +  for x y :: hypreal
  6.2439 +  by (auto dest!: bspec simp add: HInfinite_def abs_if order_less_imp_le)
  6.2440  
  6.2441 -lemma HInfinite_gt_zero_gt_one:
  6.2442 -  "[| (x::hypreal) \<in> HInfinite; 0 < x |] ==> 1 < x"
  6.2443 -by (auto intro: HInfinite_gt_SReal)
  6.2444 +lemma HInfinite_gt_zero_gt_one: "x \<in> HInfinite \<Longrightarrow> 0 < x \<Longrightarrow> 1 < x"
  6.2445 +  for x :: hypreal
  6.2446 +  by (auto intro: HInfinite_gt_SReal)
  6.2447  
  6.2448  
  6.2449  lemma not_HInfinite_one [simp]: "1 \<notin> HInfinite"
  6.2450 -apply (simp (no_asm) add: HInfinite_HFinite_iff)
  6.2451 -done
  6.2452 +  by (simp add: HInfinite_HFinite_iff)
  6.2453  
  6.2454 -lemma approx_hrabs_disj: "\<bar>x::hypreal\<bar> \<approx> x \<or> \<bar>x\<bar> \<approx> -x"
  6.2455 -by (cut_tac x = x in hrabs_disj, auto)
  6.2456 +lemma approx_hrabs_disj: "\<bar>x\<bar> \<approx> x \<or> \<bar>x\<bar> \<approx> -x"
  6.2457 +  for x :: hypreal
  6.2458 +  using hrabs_disj [of x] by auto
  6.2459  
  6.2460  
  6.2461 -subsection\<open>Theorems about Monads\<close>
  6.2462 -
  6.2463 -lemma monad_hrabs_Un_subset: "monad \<bar>x\<bar> \<le> monad(x::hypreal) Un monad(-x)"
  6.2464 -by (rule_tac x1 = x in hrabs_disj [THEN disjE], auto)
  6.2465 +subsection \<open>Theorems about Monads\<close>
  6.2466  
  6.2467 -lemma Infinitesimal_monad_eq: "e \<in> Infinitesimal ==> monad (x+e) = monad x"
  6.2468 -by (fast intro!: Infinitesimal_add_approx_self [THEN approx_sym] approx_monad_iff [THEN iffD1])
  6.2469 +lemma monad_hrabs_Un_subset: "monad \<bar>x\<bar> \<le> monad x \<union> monad (- x)"
  6.2470 +  for x :: hypreal
  6.2471 +  by (rule hrabs_disj [of x, THEN disjE]) auto
  6.2472  
  6.2473 -lemma mem_monad_iff: "(u \<in> monad x) = (-u \<in> monad (-x))"
  6.2474 -by (simp add: monad_def)
  6.2475 +lemma Infinitesimal_monad_eq: "e \<in> Infinitesimal \<Longrightarrow> monad (x + e) = monad x"
  6.2476 +  by (fast intro!: Infinitesimal_add_approx_self [THEN approx_sym] approx_monad_iff [THEN iffD1])
  6.2477  
  6.2478 -lemma Infinitesimal_monad_zero_iff: "(x \<in> Infinitesimal) = (x \<in> monad 0)"
  6.2479 -by (auto intro: approx_sym simp add: monad_def mem_infmal_iff)
  6.2480 +lemma mem_monad_iff: "u \<in> monad x \<longleftrightarrow> - u \<in> monad (- x)"
  6.2481 +  by (simp add: monad_def)
  6.2482 +
  6.2483 +lemma Infinitesimal_monad_zero_iff: "x \<in> Infinitesimal \<longleftrightarrow> x \<in> monad 0"
  6.2484 +  by (auto intro: approx_sym simp add: monad_def mem_infmal_iff)
  6.2485  
  6.2486 -lemma monad_zero_minus_iff: "(x \<in> monad 0) = (-x \<in> monad 0)"
  6.2487 -apply (simp (no_asm) add: Infinitesimal_monad_zero_iff [symmetric])
  6.2488 -done
  6.2489 +lemma monad_zero_minus_iff: "x \<in> monad 0 \<longleftrightarrow> - x \<in> monad 0"
  6.2490 +  by (simp add: Infinitesimal_monad_zero_iff [symmetric])
  6.2491  
  6.2492 -lemma monad_zero_hrabs_iff: "((x::hypreal) \<in> monad 0) = (\<bar>x\<bar> \<in> monad 0)"
  6.2493 -apply (rule_tac x1 = x in hrabs_disj [THEN disjE])
  6.2494 -apply (auto simp add: monad_zero_minus_iff [symmetric])
  6.2495 -done
  6.2496 +lemma monad_zero_hrabs_iff: "x \<in> monad 0 \<longleftrightarrow> \<bar>x\<bar> \<in> monad 0"
  6.2497 +  for x :: hypreal
  6.2498 +  by (rule hrabs_disj [of x, THEN disjE]) (auto simp: monad_zero_minus_iff [symmetric])
  6.2499  
  6.2500  lemma mem_monad_self [simp]: "x \<in> monad x"
  6.2501 -by (simp add: monad_def)
  6.2502 +  by (simp add: monad_def)
  6.2503  
  6.2504  
  6.2505 -subsection\<open>Proof that @{term "x \<approx> y"} implies @{term"\<bar>x\<bar> \<approx> \<bar>y\<bar>"}\<close>
  6.2506 +subsection \<open>Proof that @{term "x \<approx> y"} implies @{term"\<bar>x\<bar> \<approx> \<bar>y\<bar>"}\<close>
  6.2507  
  6.2508 -lemma approx_subset_monad: "x \<approx> y ==> {x,y} \<le> monad x"
  6.2509 -apply (simp (no_asm))
  6.2510 -apply (simp add: approx_monad_iff)
  6.2511 -done
  6.2512 +lemma approx_subset_monad: "x \<approx> y \<Longrightarrow> {x, y} \<le> monad x"
  6.2513 +  by (simp (no_asm)) (simp add: approx_monad_iff)
  6.2514  
  6.2515 -lemma approx_subset_monad2: "x \<approx> y ==> {x,y} \<le> monad y"
  6.2516 -apply (drule approx_sym)
  6.2517 -apply (fast dest: approx_subset_monad)
  6.2518 -done
  6.2519 +lemma approx_subset_monad2: "x \<approx> y \<Longrightarrow> {x, y} \<le> monad y"
  6.2520 +  apply (drule approx_sym)
  6.2521 +  apply (fast dest: approx_subset_monad)
  6.2522 +  done
  6.2523  
  6.2524 -lemma mem_monad_approx: "u \<in> monad x ==> x \<approx> u"
  6.2525 -by (simp add: monad_def)
  6.2526 +lemma mem_monad_approx: "u \<in> monad x \<Longrightarrow> x \<approx> u"
  6.2527 +  by (simp add: monad_def)
  6.2528 +
  6.2529 +lemma approx_mem_monad: "x \<approx> u \<Longrightarrow> u \<in> monad x"
  6.2530 +  by (simp add: monad_def)
  6.2531  
  6.2532 -lemma approx_mem_monad: "x \<approx> u ==> u \<in> monad x"
  6.2533 -by (simp add: monad_def)
  6.2534 -
  6.2535 -lemma approx_mem_monad2: "x \<approx> u ==> x \<in> monad u"
  6.2536 -apply (simp add: monad_def)
  6.2537 -apply (blast intro!: approx_sym)
  6.2538 -done
  6.2539 +lemma approx_mem_monad2: "x \<approx> u \<Longrightarrow> x \<in> monad u"
  6.2540 +  apply (simp add: monad_def)
  6.2541 +  apply (blast intro!: approx_sym)
  6.2542 +  done
  6.2543  
  6.2544 -lemma approx_mem_monad_zero: "[| x \<approx> y;x \<in> monad 0 |] ==> y \<in> monad 0"
  6.2545 -apply (drule mem_monad_approx)
  6.2546 -apply (fast intro: approx_mem_monad approx_trans)
  6.2547 -done
  6.2548 +lemma approx_mem_monad_zero: "x \<approx> y \<Longrightarrow> x \<in> monad 0 \<Longrightarrow> y \<in> monad 0"
  6.2549 +  apply (drule mem_monad_approx)
  6.2550 +  apply (fast intro: approx_mem_monad approx_trans)
  6.2551 +  done
  6.2552  
  6.2553 -lemma Infinitesimal_approx_hrabs:
  6.2554 -     "[| x \<approx> y; (x::hypreal) \<in> Infinitesimal |] ==> \<bar>x\<bar> \<approx> \<bar>y\<bar>"
  6.2555 -apply (drule Infinitesimal_monad_zero_iff [THEN iffD1])
  6.2556 -apply (blast intro: approx_mem_monad_zero monad_zero_hrabs_iff [THEN iffD1] mem_monad_approx approx_trans3)
  6.2557 -done
  6.2558 +lemma Infinitesimal_approx_hrabs: "x \<approx> y \<Longrightarrow> x \<in> Infinitesimal \<Longrightarrow> \<bar>x\<bar> \<approx> \<bar>y\<bar>"
  6.2559 +  for x y :: hypreal
  6.2560 +  apply (drule Infinitesimal_monad_zero_iff [THEN iffD1])
  6.2561 +  apply (blast intro: approx_mem_monad_zero monad_zero_hrabs_iff [THEN iffD1]
  6.2562 +      mem_monad_approx approx_trans3)
  6.2563 +  done
  6.2564  
  6.2565 -lemma less_Infinitesimal_less:
  6.2566 -     "[| 0 < x;  (x::hypreal) \<notin>Infinitesimal;  e :Infinitesimal |] ==> e < x"
  6.2567 -apply (rule ccontr)
  6.2568 -apply (auto intro: Infinitesimal_zero [THEN [2] Infinitesimal_interval]
  6.2569 -            dest!: order_le_imp_less_or_eq simp add: linorder_not_less)
  6.2570 -done
  6.2571 +lemma less_Infinitesimal_less: "0 < x \<Longrightarrow> x \<notin> Infinitesimal \<Longrightarrow> e \<in> Infinitesimal \<Longrightarrow> e < x"
  6.2572 +  for x :: hypreal
  6.2573 +  apply (rule ccontr)
  6.2574 +  apply (auto intro: Infinitesimal_zero [THEN [2] Infinitesimal_interval]
  6.2575 +      dest!: order_le_imp_less_or_eq simp add: linorder_not_less)
  6.2576 +  done
  6.2577  
  6.2578 -lemma Ball_mem_monad_gt_zero:
  6.2579 -     "[| 0 < (x::hypreal);  x \<notin> Infinitesimal; u \<in> monad x |] ==> 0 < u"
  6.2580 -apply (drule mem_monad_approx [THEN approx_sym])
  6.2581 -apply (erule bex_Infinitesimal_iff2 [THEN iffD2, THEN bexE])
  6.2582 -apply (drule_tac e = "-xa" in less_Infinitesimal_less, auto)
  6.2583 -done
  6.2584 +lemma Ball_mem_monad_gt_zero: "0 < x \<Longrightarrow> x \<notin> Infinitesimal \<Longrightarrow> u \<in> monad x \<Longrightarrow> 0 < u"
  6.2585 +  for u x :: hypreal
  6.2586 +  apply (drule mem_monad_approx [THEN approx_sym])
  6.2587 +  apply (erule bex_Infinitesimal_iff2 [THEN iffD2, THEN bexE])
  6.2588 +  apply (drule_tac e = "-xa" in less_Infinitesimal_less, auto)
  6.2589 +  done
  6.2590  
  6.2591 -lemma Ball_mem_monad_less_zero:
  6.2592 -     "[| (x::hypreal) < 0; x \<notin> Infinitesimal; u \<in> monad x |] ==> u < 0"
  6.2593 -apply (drule mem_monad_approx [THEN approx_sym])
  6.2594 -apply (erule bex_Infinitesimal_iff [THEN iffD2, THEN bexE])
  6.2595 -apply (cut_tac x = "-x" and e = xa in less_Infinitesimal_less, auto)
  6.2596 -done
  6.2597 +lemma Ball_mem_monad_less_zero: "x < 0 \<Longrightarrow> x \<notin> Infinitesimal \<Longrightarrow> u \<in> monad x \<Longrightarrow> u < 0"
  6.2598 +  for u x :: hypreal
  6.2599 +  apply (drule mem_monad_approx [THEN approx_sym])
  6.2600 +  apply (erule bex_Infinitesimal_iff [THEN iffD2, THEN bexE])
  6.2601 +  apply (cut_tac x = "-x" and e = xa in less_Infinitesimal_less, auto)
  6.2602 +  done
  6.2603  
  6.2604 -lemma lemma_approx_gt_zero:
  6.2605 -     "[|0 < (x::hypreal); x \<notin> Infinitesimal; x \<approx> y|] ==> 0 < y"
  6.2606 -by (blast dest: Ball_mem_monad_gt_zero approx_subset_monad)
  6.2607 +lemma lemma_approx_gt_zero: "0 < x \<Longrightarrow> x \<notin> Infinitesimal \<Longrightarrow> x \<approx> y \<Longrightarrow> 0 < y"
  6.2608 +  for x y :: hypreal
  6.2609 +  by (blast dest: Ball_mem_monad_gt_zero approx_subset_monad)
  6.2610  
  6.2611 -lemma lemma_approx_less_zero:
  6.2612 -     "[|(x::hypreal) < 0; x \<notin> Infinitesimal; x \<approx> y|] ==> y < 0"
  6.2613 -by (blast dest: Ball_mem_monad_less_zero approx_subset_monad)
  6.2614 +lemma lemma_approx_less_zero: "x < 0 \<Longrightarrow> x \<notin> Infinitesimal \<Longrightarrow> x \<approx> y \<Longrightarrow> y < 0"
  6.2615 +  for x y :: hypreal
  6.2616 +  by (blast dest: Ball_mem_monad_less_zero approx_subset_monad)
  6.2617  
  6.2618 -theorem approx_hrabs: "(x::hypreal) \<approx> y ==> \<bar>x\<bar> \<approx> \<bar>y\<bar>"
  6.2619 -by (drule approx_hnorm, simp)
  6.2620 +lemma approx_hrabs: "x \<approx> y \<Longrightarrow> \<bar>x\<bar> \<approx> \<bar>y\<bar>"
  6.2621 +  for x y :: hypreal
  6.2622 +  by (drule approx_hnorm) simp
  6.2623  
  6.2624 -lemma approx_hrabs_zero_cancel: "\<bar>x::hypreal\<bar> \<approx> 0 ==> x \<approx> 0"
  6.2625 -apply (cut_tac x = x in hrabs_disj)
  6.2626 -apply (auto dest: approx_minus)
  6.2627 -done
  6.2628 +lemma approx_hrabs_zero_cancel: "\<bar>x\<bar> \<approx> 0 \<Longrightarrow> x \<approx> 0"
  6.2629 +  for x :: hypreal
  6.2630 +  using hrabs_disj [of x] by (auto dest: approx_minus)
  6.2631  
  6.2632 -lemma approx_hrabs_add_Infinitesimal:
  6.2633 -  "(e::hypreal) \<in> Infinitesimal ==> \<bar>x\<bar> \<approx> \<bar>x + e\<bar>"
  6.2634 -by (fast intro: approx_hrabs Infinitesimal_add_approx_self)
  6.2635 +lemma approx_hrabs_add_Infinitesimal: "e \<in> Infinitesimal \<Longrightarrow> \<bar>x\<bar> \<approx> \<bar>x + e\<bar>"
  6.2636 +  for e x :: hypreal
  6.2637 +  by (fast intro: approx_hrabs Infinitesimal_add_approx_self)
  6.2638  
  6.2639 -lemma approx_hrabs_add_minus_Infinitesimal:
  6.2640 -     "(e::hypreal) \<in> Infinitesimal ==> \<bar>x\<bar> \<approx> \<bar>x + -e\<bar>"
  6.2641 -by (fast intro: approx_hrabs Infinitesimal_add_minus_approx_self)
  6.2642 +lemma approx_hrabs_add_minus_Infinitesimal: "e \<in> Infinitesimal ==> \<bar>x\<bar> \<approx> \<bar>x + -e\<bar>"
  6.2643 +  for e x :: hypreal
  6.2644 +  by (fast intro: approx_hrabs Infinitesimal_add_minus_approx_self)
  6.2645  
  6.2646  lemma hrabs_add_Infinitesimal_cancel:
  6.2647 -     "[| (e::hypreal) \<in> Infinitesimal; e' \<in> Infinitesimal;
  6.2648 -         \<bar>x + e\<bar> = \<bar>y + e'\<bar>|] ==> \<bar>x\<bar> \<approx> \<bar>y\<bar>"
  6.2649 -apply (drule_tac x = x in approx_hrabs_add_Infinitesimal)
  6.2650 -apply (drule_tac x = y in approx_hrabs_add_Infinitesimal)
  6.2651 -apply (auto intro: approx_trans2)
  6.2652 -done
  6.2653 +  "e \<in> Infinitesimal \<Longrightarrow> e' \<in> Infinitesimal \<Longrightarrow> \<bar>x + e\<bar> = \<bar>y + e'\<bar> \<Longrightarrow> \<bar>x\<bar> \<approx> \<bar>y\<bar>"
  6.2654 +  for e e' x y :: hypreal
  6.2655 +  apply (drule_tac x = x in approx_hrabs_add_Infinitesimal)
  6.2656 +  apply (drule_tac x = y in approx_hrabs_add_Infinitesimal)
  6.2657 +  apply (auto intro: approx_trans2)
  6.2658 +  done
  6.2659  
  6.2660  lemma hrabs_add_minus_Infinitesimal_cancel:
  6.2661 -     "[| (e::hypreal) \<in> Infinitesimal; e' \<in> Infinitesimal;
  6.2662 -         \<bar>x + -e\<bar> = \<bar>y + -e'\<bar>|] ==> \<bar>x\<bar> \<approx> \<bar>y\<bar>"
  6.2663 -apply (drule_tac x = x in approx_hrabs_add_minus_Infinitesimal)
  6.2664 -apply (drule_tac x = y in approx_hrabs_add_minus_Infinitesimal)
  6.2665 -apply (auto intro: approx_trans2)
  6.2666 -done
  6.2667 +  "e \<in> Infinitesimal \<Longrightarrow> e' \<in> Infinitesimal \<Longrightarrow> \<bar>x + -e\<bar> = \<bar>y + -e'\<bar> \<Longrightarrow> \<bar>x\<bar> \<approx> \<bar>y\<bar>"
  6.2668 +  for e e' x y :: hypreal
  6.2669 +  apply (drule_tac x = x in approx_hrabs_add_minus_Infinitesimal)
  6.2670 +  apply (drule_tac x = y in approx_hrabs_add_minus_Infinitesimal)
  6.2671 +  apply (auto intro: approx_trans2)
  6.2672 +  done
  6.2673 +
  6.2674  
  6.2675  subsection \<open>More @{term HFinite} and @{term Infinitesimal} Theorems\<close>
  6.2676  
  6.2677 -(* interesting slightly counterintuitive theorem: necessary
  6.2678 -   for proving that an open interval is an NS open set
  6.2679 -*)
  6.2680 +text \<open>
  6.2681 +  Interesting slightly counterintuitive theorem: necessary
  6.2682 +  for proving that an open interval is an NS open set.
  6.2683 +\<close>
  6.2684  lemma Infinitesimal_add_hypreal_of_real_less:
  6.2685 -     "[| x < y;  u \<in> Infinitesimal |]
  6.2686 -      ==> hypreal_of_real x + u < hypreal_of_real y"
  6.2687 -apply (simp add: Infinitesimal_def)
  6.2688 -apply (drule_tac x = "hypreal_of_real y + -hypreal_of_real x" in bspec, simp)
  6.2689 -apply (simp add: abs_less_iff)
  6.2690 -done
  6.2691 +  "x < y \<Longrightarrow> u \<in> Infinitesimal \<Longrightarrow> hypreal_of_real x + u < hypreal_of_real y"
  6.2692 +  apply (simp add: Infinitesimal_def)
  6.2693 +  apply (drule_tac x = "hypreal_of_real y + -hypreal_of_real x" in bspec, simp)
  6.2694 +  apply (simp add: abs_less_iff)
  6.2695 +  done
  6.2696  
  6.2697  lemma Infinitesimal_add_hrabs_hypreal_of_real_less:
  6.2698 -     "[| x \<in> Infinitesimal; \<bar>hypreal_of_real r\<bar> < hypreal_of_real y |]
  6.2699 -      ==> \<bar>hypreal_of_real r + x\<bar> < hypreal_of_real y"
  6.2700 -apply (drule_tac x = "hypreal_of_real r" in approx_hrabs_add_Infinitesimal)
  6.2701 -apply (drule approx_sym [THEN bex_Infinitesimal_iff2 [THEN iffD2]])
  6.2702 -apply (auto intro!: Infinitesimal_add_hypreal_of_real_less
  6.2703 -            simp del: star_of_abs
  6.2704 -            simp add: star_of_abs [symmetric])
  6.2705 -done
  6.2706 +  "x \<in> Infinitesimal \<Longrightarrow> \<bar>hypreal_of_real r\<bar> < hypreal_of_real y \<Longrightarrow>
  6.2707 +    \<bar>hypreal_of_real r + x\<bar> < hypreal_of_real y"
  6.2708 +  apply (drule_tac x = "hypreal_of_real r" in approx_hrabs_add_Infinitesimal)
  6.2709 +  apply (drule approx_sym [THEN bex_Infinitesimal_iff2 [THEN iffD2]])
  6.2710 +  apply (auto intro!: Infinitesimal_add_hypreal_of_real_less
  6.2711 +      simp del: star_of_abs simp add: star_of_abs [symmetric])
  6.2712 +  done
  6.2713  
  6.2714  lemma Infinitesimal_add_hrabs_hypreal_of_real_less2:
  6.2715 -     "[| x \<in> Infinitesimal;  \<bar>hypreal_of_real r\<bar> < hypreal_of_real y |]
  6.2716 -      ==> \<bar>x + hypreal_of_real r\<bar> < hypreal_of_real y"
  6.2717 -apply (rule add.commute [THEN subst])
  6.2718 -apply (erule Infinitesimal_add_hrabs_hypreal_of_real_less, assumption)
  6.2719 -done
  6.2720 +  "x \<in> Infinitesimal \<Longrightarrow> \<bar>hypreal_of_real r\<bar> < hypreal_of_real y \<Longrightarrow>
  6.2721 +    \<bar>x + hypreal_of_real r\<bar> < hypreal_of_real y"
  6.2722 +  apply (rule add.commute [THEN subst])
  6.2723 +  apply (erule Infinitesimal_add_hrabs_hypreal_of_real_less, assumption)
  6.2724 +  done
  6.2725  
  6.2726  lemma hypreal_of_real_le_add_Infininitesimal_cancel:
  6.2727 -     "[| u \<in> Infinitesimal; v \<in> Infinitesimal;
  6.2728 -         hypreal_of_real x + u \<le> hypreal_of_real y + v |]
  6.2729 -      ==> hypreal_of_real x \<le> hypreal_of_real y"
  6.2730 -apply (simp add: linorder_not_less [symmetric], auto)
  6.2731 -apply (drule_tac u = "v-u" in Infinitesimal_add_hypreal_of_real_less)
  6.2732 -apply (auto simp add: Infinitesimal_diff)
  6.2733 -done
  6.2734 +  "u \<in> Infinitesimal \<Longrightarrow> v \<in> Infinitesimal \<Longrightarrow>
  6.2735 +    hypreal_of_real x + u \<le> hypreal_of_real y + v \<Longrightarrow>
  6.2736 +    hypreal_of_real x \<le> hypreal_of_real y"
  6.2737 +  apply (simp add: linorder_not_less [symmetric], auto)
  6.2738 +  apply (drule_tac u = "v-u" in Infinitesimal_add_hypreal_of_real_less)
  6.2739 +   apply (auto simp add: Infinitesimal_diff)
  6.2740 +  done
  6.2741  
  6.2742  lemma hypreal_of_real_le_add_Infininitesimal_cancel2:
  6.2743 -     "[| u \<in> Infinitesimal; v \<in> Infinitesimal;
  6.2744 -         hypreal_of_real x + u \<le> hypreal_of_real y + v |]
  6.2745 -      ==> x \<le> y"
  6.2746 -by (blast intro: star_of_le [THEN iffD1]
  6.2747 -          intro!: hypreal_of_real_le_add_Infininitesimal_cancel)
  6.2748 +  "u \<in> Infinitesimal \<Longrightarrow> v \<in> Infinitesimal \<Longrightarrow>
  6.2749 +    hypreal_of_real x + u \<le> hypreal_of_real y + v \<Longrightarrow> x \<le> y"
  6.2750 +  by (blast intro: star_of_le [THEN iffD1] intro!: hypreal_of_real_le_add_Infininitesimal_cancel)
  6.2751  
  6.2752  lemma hypreal_of_real_less_Infinitesimal_le_zero:
  6.2753 -    "[| hypreal_of_real x < e; e \<in> Infinitesimal |] ==> hypreal_of_real x \<le> 0"
  6.2754 -apply (rule linorder_not_less [THEN iffD1], safe)
  6.2755 -apply (drule Infinitesimal_interval)
  6.2756 -apply (drule_tac [4] SReal_hypreal_of_real [THEN SReal_Infinitesimal_zero], auto)
  6.2757 -done
  6.2758 +  "hypreal_of_real x < e \<Longrightarrow> e \<in> Infinitesimal \<Longrightarrow> hypreal_of_real x \<le> 0"
  6.2759 +  apply (rule linorder_not_less [THEN iffD1], safe)
  6.2760 +  apply (drule Infinitesimal_interval)
  6.2761 +     apply (drule_tac [4] SReal_hypreal_of_real [THEN SReal_Infinitesimal_zero], auto)
  6.2762 +  done
  6.2763  
  6.2764  (*used once, in Lim/NSDERIV_inverse*)
  6.2765 -lemma Infinitesimal_add_not_zero:
  6.2766 -     "[| h \<in> Infinitesimal; x \<noteq> 0 |] ==> star_of x + h \<noteq> 0"
  6.2767 -apply auto
  6.2768 -apply (subgoal_tac "h = - star_of x", auto intro: minus_unique [symmetric])
  6.2769 -done
  6.2770 +lemma Infinitesimal_add_not_zero: "h \<in> Infinitesimal \<Longrightarrow> x \<noteq> 0 \<Longrightarrow> star_of x + h \<noteq> 0"
  6.2771 +  apply auto
  6.2772 +  apply (subgoal_tac "h = - star_of x")
  6.2773 +   apply (auto intro: minus_unique [symmetric])
  6.2774 +  done
  6.2775  
  6.2776 -lemma Infinitesimal_square_cancel [simp]:
  6.2777 -     "(x::hypreal)*x + y*y \<in> Infinitesimal ==> x*x \<in> Infinitesimal"
  6.2778 -apply (rule Infinitesimal_interval2)
  6.2779 -apply (rule_tac [3] zero_le_square, assumption)
  6.2780 -apply (auto)
  6.2781 -done
  6.2782 +lemma Infinitesimal_square_cancel [simp]: "x * x + y * y \<in> Infinitesimal \<Longrightarrow> x * x \<in> Infinitesimal"
  6.2783 +  for x y :: hypreal
  6.2784 +  apply (rule Infinitesimal_interval2)
  6.2785 +     apply (rule_tac [3] zero_le_square, assumption)
  6.2786 +   apply auto
  6.2787 +  done
  6.2788  
  6.2789 -lemma HFinite_square_cancel [simp]:
  6.2790 -  "(x::hypreal)*x + y*y \<in> HFinite ==> x*x \<in> HFinite"
  6.2791 -apply (rule HFinite_bounded, assumption)
  6.2792 -apply (auto)
  6.2793 -done
  6.2794 +lemma HFinite_square_cancel [simp]: "x * x + y * y \<in> HFinite \<Longrightarrow> x * x \<in> HFinite"
  6.2795 +  for x y :: hypreal
  6.2796 +  apply (rule HFinite_bounded, assumption)
  6.2797 +   apply auto
  6.2798 +  done
  6.2799  
  6.2800 -lemma Infinitesimal_square_cancel2 [simp]:
  6.2801 -     "(x::hypreal)*x + y*y \<in> Infinitesimal ==> y*y \<in> Infinitesimal"
  6.2802 -apply (rule Infinitesimal_square_cancel)
  6.2803 -apply (rule add.commute [THEN subst])
  6.2804 -apply (simp (no_asm))
  6.2805 -done
  6.2806 +lemma Infinitesimal_square_cancel2 [simp]: "x * x + y * y \<in> Infinitesimal \<Longrightarrow> y * y \<in> Infinitesimal"
  6.2807 +  for x y :: hypreal
  6.2808 +  apply (rule Infinitesimal_square_cancel)
  6.2809 +  apply (rule add.commute [THEN subst])
  6.2810 +  apply simp
  6.2811 +  done
  6.2812  
  6.2813 -lemma HFinite_square_cancel2 [simp]:
  6.2814 -  "(x::hypreal)*x + y*y \<in> HFinite ==> y*y \<in> HFinite"
  6.2815 -apply (rule HFinite_square_cancel)
  6.2816 -apply (rule add.commute [THEN subst])
  6.2817 -apply (simp (no_asm))
  6.2818 -done
  6.2819 +lemma HFinite_square_cancel2 [simp]: "x * x + y * y \<in> HFinite \<Longrightarrow> y * y \<in> HFinite"
  6.2820 +  for x y :: hypreal
  6.2821 +  apply (rule HFinite_square_cancel)
  6.2822 +  apply (rule add.commute [THEN subst])
  6.2823 +  apply simp
  6.2824 +  done
  6.2825  
  6.2826  lemma Infinitesimal_sum_square_cancel [simp]:
  6.2827 -     "(x::hypreal)*x + y*y + z*z \<in> Infinitesimal ==> x*x \<in> Infinitesimal"
  6.2828 -apply (rule Infinitesimal_interval2, assumption)
  6.2829 -apply (rule_tac [2] zero_le_square, simp)
  6.2830 -apply (insert zero_le_square [of y])
  6.2831 -apply (insert zero_le_square [of z], simp del:zero_le_square)
  6.2832 -done
  6.2833 +  "x * x + y * y + z * z \<in> Infinitesimal \<Longrightarrow> x * x \<in> Infinitesimal"
  6.2834 +  for x y z :: hypreal
  6.2835 +  apply (rule Infinitesimal_interval2, assumption)
  6.2836 +    apply (rule_tac [2] zero_le_square, simp)
  6.2837 +  apply (insert zero_le_square [of y])
  6.2838 +  apply (insert zero_le_square [of z], simp del:zero_le_square)
  6.2839 +  done
  6.2840  
  6.2841 -lemma HFinite_sum_square_cancel [simp]:
  6.2842 -     "(x::hypreal)*x + y*y + z*z \<in> HFinite ==> x*x \<in> HFinite"
  6.2843 -apply (rule HFinite_bounded, assumption)
  6.2844 -apply (rule_tac [2] zero_le_square)
  6.2845 -apply (insert zero_le_square [of y])
  6.2846 -apply (insert zero_le_square [of z], simp del:zero_le_square)
  6.2847 -done
  6.2848 +lemma HFinite_sum_square_cancel [simp]: "x * x + y * y + z * z \<in> HFinite \<Longrightarrow> x * x \<in> HFinite"
  6.2849 +  for x y z :: hypreal
  6.2850 +  apply (rule HFinite_bounded, assumption)
  6.2851 +   apply (rule_tac [2] zero_le_square)
  6.2852 +  apply (insert zero_le_square [of y])
  6.2853 +  apply (insert zero_le_square [of z], simp del:zero_le_square)
  6.2854 +  done
  6.2855  
  6.2856  lemma Infinitesimal_sum_square_cancel2 [simp]:
  6.2857 -     "(y::hypreal)*y + x*x + z*z \<in> Infinitesimal ==> x*x \<in> Infinitesimal"
  6.2858 -apply (rule Infinitesimal_sum_square_cancel)
  6.2859 -apply (simp add: ac_simps)
  6.2860 -done
  6.2861 +  "y * y + x * x + z * z \<in> Infinitesimal \<Longrightarrow> x * x \<in> Infinitesimal"
  6.2862 +  for x y z :: hypreal
  6.2863 +  apply (rule Infinitesimal_sum_square_cancel)
  6.2864 +  apply (simp add: ac_simps)
  6.2865 +  done
  6.2866  
  6.2867 -lemma HFinite_sum_square_cancel2 [simp]:
  6.2868 -     "(y::hypreal)*y + x*x + z*z \<in> HFinite ==> x*x \<in> HFinite"
  6.2869 -apply (rule HFinite_sum_square_cancel)
  6.2870 -apply (simp add: ac_simps)
  6.2871 -done
  6.2872 +lemma HFinite_sum_square_cancel2 [simp]: "y * y + x * x + z * z \<in> HFinite \<Longrightarrow> x * x \<in> HFinite"
  6.2873 +  for x y z :: hypreal
  6.2874 +  apply (rule HFinite_sum_square_cancel)
  6.2875 +  apply (simp add: ac_simps)
  6.2876 +  done
  6.2877  
  6.2878  lemma Infinitesimal_sum_square_cancel3 [simp]:
  6.2879 -     "(z::hypreal)*z + y*y + x*x \<in> Infinitesimal ==> x*x \<in> Infinitesimal"
  6.2880 -apply (rule Infinitesimal_sum_square_cancel)
  6.2881 -apply (simp add: ac_simps)
  6.2882 -done
  6.2883 +  "z * z + y * y + x * x \<in> Infinitesimal \<Longrightarrow> x * x \<in> Infinitesimal"
  6.2884 +  for x y z :: hypreal
  6.2885 +  apply (rule Infinitesimal_sum_square_cancel)
  6.2886 +  apply (simp add: ac_simps)
  6.2887 +  done
  6.2888  
  6.2889 -lemma HFinite_sum_square_cancel3 [simp]:
  6.2890 -     "(z::hypreal)*z + y*y + x*x \<in> HFinite ==> x*x \<in> HFinite"
  6.2891 -apply (rule HFinite_sum_square_cancel)
  6.2892 -apply (simp add: ac_simps)
  6.2893 -done
  6.2894 +lemma HFinite_sum_square_cancel3 [simp]: "z * z + y * y + x * x \<in> HFinite \<Longrightarrow> x * x \<in> HFinite"
  6.2895 +  for x y z :: hypreal
  6.2896 +  apply (rule HFinite_sum_square_cancel)
  6.2897 +  apply (simp add: ac_simps)
  6.2898 +  done
  6.2899  
  6.2900 -lemma monad_hrabs_less:
  6.2901 -     "[| y \<in> monad x; 0 < hypreal_of_real e |]
  6.2902 -      ==> \<bar>y - x\<bar> < hypreal_of_real e"
  6.2903 -apply (drule mem_monad_approx [THEN approx_sym])
  6.2904 -apply (drule bex_Infinitesimal_iff [THEN iffD2])
  6.2905 -apply (auto dest!: InfinitesimalD)
  6.2906 -done
  6.2907 +lemma monad_hrabs_less: "y \<in> monad x \<Longrightarrow> 0 < hypreal_of_real e \<Longrightarrow> \<bar>y - x\<bar> < hypreal_of_real e"
  6.2908 +  apply (drule mem_monad_approx [THEN approx_sym])
  6.2909 +  apply (drule bex_Infinitesimal_iff [THEN iffD2])
  6.2910 +  apply (auto dest!: InfinitesimalD)
  6.2911 +  done
  6.2912  
  6.2913 -lemma mem_monad_SReal_HFinite:
  6.2914 -     "x \<in> monad (hypreal_of_real  a) ==> x \<in> HFinite"
  6.2915 -apply (drule mem_monad_approx [THEN approx_sym])
  6.2916 -apply (drule bex_Infinitesimal_iff2 [THEN iffD2])
  6.2917 -apply (safe dest!: Infinitesimal_subset_HFinite [THEN subsetD])
  6.2918 -apply (erule SReal_hypreal_of_real [THEN SReal_subset_HFinite [THEN subsetD], THEN HFinite_add])
  6.2919 -done
  6.2920 +lemma mem_monad_SReal_HFinite: "x \<in> monad (hypreal_of_real  a) \<Longrightarrow> x \<in> HFinite"
  6.2921 +  apply (drule mem_monad_approx [THEN approx_sym])
  6.2922 +  apply (drule bex_Infinitesimal_iff2 [THEN iffD2])
  6.2923 +  apply (safe dest!: Infinitesimal_subset_HFinite [THEN subsetD])
  6.2924 +  apply (erule SReal_hypreal_of_real [THEN SReal_subset_HFinite [THEN subsetD], THEN HFinite_add])
  6.2925 +  done
  6.2926  
  6.2927  
  6.2928 -subsection\<open>Theorems about Standard Part\<close>
  6.2929 +subsection \<open>Theorems about Standard Part\<close>
  6.2930  
  6.2931 -lemma st_approx_self: "x \<in> HFinite ==> st x \<approx> x"
  6.2932 -apply (simp add: st_def)
  6.2933 -apply (frule st_part_Ex, safe)
  6.2934 -apply (rule someI2)
  6.2935 -apply (auto intro: approx_sym)
  6.2936 -done
  6.2937 +lemma st_approx_self: "x \<in> HFinite \<Longrightarrow> st x \<approx> x"
  6.2938 +  apply (simp add: st_def)
  6.2939 +  apply (frule st_part_Ex, safe)
  6.2940 +  apply (rule someI2)
  6.2941 +   apply (auto intro: approx_sym)
  6.2942 +  done
  6.2943  
  6.2944 -lemma st_SReal: "x \<in> HFinite ==> st x \<in> \<real>"
  6.2945 -apply (simp add: st_def)
  6.2946 -apply (frule st_part_Ex, safe)
  6.2947 -apply (rule someI2)
  6.2948 -apply (auto intro: approx_sym)
  6.2949 -done
  6.2950 +lemma st_SReal: "x \<in> HFinite \<Longrightarrow> st x \<in> \<real>"
  6.2951 +  apply (simp add: st_def)
  6.2952 +  apply (frule st_part_Ex, safe)
  6.2953 +  apply (rule someI2)
  6.2954 +   apply (auto intro: approx_sym)
  6.2955 +  done
  6.2956  
  6.2957 -lemma st_HFinite: "x \<in> HFinite ==> st x \<in> HFinite"
  6.2958 -by (erule st_SReal [THEN SReal_subset_HFinite [THEN subsetD]])
  6.2959 +lemma st_HFinite: "x \<in> HFinite \<Longrightarrow> st x \<in> HFinite"
  6.2960 +  by (erule st_SReal [THEN SReal_subset_HFinite [THEN subsetD]])
  6.2961  
  6.2962 -lemma st_unique: "\<lbrakk>r \<in> \<real>; r \<approx> x\<rbrakk> \<Longrightarrow> st x = r"
  6.2963 -apply (frule SReal_subset_HFinite [THEN subsetD])
  6.2964 -apply (drule (1) approx_HFinite)
  6.2965 -apply (unfold st_def)
  6.2966 -apply (rule some_equality)
  6.2967 -apply (auto intro: approx_unique_real)
  6.2968 -done
  6.2969 +lemma st_unique: "r \<in> \<real> \<Longrightarrow> r \<approx> x \<Longrightarrow> st x = r"
  6.2970 +  apply (frule SReal_subset_HFinite [THEN subsetD])
  6.2971 +  apply (drule (1) approx_HFinite)
  6.2972 +  apply (unfold st_def)
  6.2973 +  apply (rule some_equality)
  6.2974 +   apply (auto intro: approx_unique_real)
  6.2975 +  done
  6.2976  
  6.2977 -lemma st_SReal_eq: "x \<in> \<real> ==> st x = x"
  6.2978 +lemma st_SReal_eq: "x \<in> \<real> \<Longrightarrow> st x = x"
  6.2979    by (metis approx_refl st_unique)
  6.2980  
  6.2981  lemma st_hypreal_of_real [simp]: "st (hypreal_of_real x) = hypreal_of_real x"
  6.2982 -by (rule SReal_hypreal_of_real [THEN st_SReal_eq])
  6.2983 +  by (rule SReal_hypreal_of_real [THEN st_SReal_eq])
  6.2984  
  6.2985 -lemma st_eq_approx: "[| x \<in> HFinite; y \<in> HFinite; st x = st y |] ==> x \<approx> y"
  6.2986 -by (auto dest!: st_approx_self elim!: approx_trans3)
  6.2987 +lemma st_eq_approx: "x \<in> HFinite \<Longrightarrow> y \<in> HFinite \<Longrightarrow> st x = st y \<Longrightarrow> x \<approx> y"
  6.2988 +  by (auto dest!: st_approx_self elim!: approx_trans3)
  6.2989  
  6.2990  lemma approx_st_eq:
  6.2991    assumes x: "x \<in> HFinite" and y: "y \<in> HFinite" and xy: "x \<approx> y"
  6.2992 @@ -1796,32 +1665,27 @@
  6.2993      by (fast elim: approx_trans approx_trans2 SReal_approx_iff [THEN iffD1])
  6.2994  qed
  6.2995  
  6.2996 -lemma st_eq_approx_iff:
  6.2997 -     "[| x \<in> HFinite; y \<in> HFinite|]
  6.2998 -                   ==> (x \<approx> y) = (st x = st y)"
  6.2999 -by (blast intro: approx_st_eq st_eq_approx)
  6.3000 +lemma st_eq_approx_iff: "x \<in> HFinite \<Longrightarrow> y \<in> HFinite \<Longrightarrow> x \<approx> y \<longleftrightarrow> st x = st y"
  6.3001 +  by (blast intro: approx_st_eq st_eq_approx)
  6.3002  
  6.3003 -lemma st_Infinitesimal_add_SReal:
  6.3004 -     "[| x \<in> \<real>; e \<in> Infinitesimal |] ==> st(x + e) = x"
  6.3005 -apply (erule st_unique)
  6.3006 -apply (erule Infinitesimal_add_approx_self)
  6.3007 -done
  6.3008 +lemma st_Infinitesimal_add_SReal: "x \<in> \<real> \<Longrightarrow> e \<in> Infinitesimal \<Longrightarrow> st (x + e) = x"
  6.3009 +  apply (erule st_unique)
  6.3010 +  apply (erule Infinitesimal_add_approx_self)
  6.3011 +  done
  6.3012  
  6.3013 -lemma st_Infinitesimal_add_SReal2:
  6.3014 -     "[| x \<in> \<real>; e \<in> Infinitesimal |] ==> st(e + x) = x"
  6.3015 -apply (erule st_unique)
  6.3016 -apply (erule Infinitesimal_add_approx_self2)
  6.3017 -done
  6.3018 +lemma st_Infinitesimal_add_SReal2: "x \<in> \<real> \<Longrightarrow> e \<in> Infinitesimal \<Longrightarrow> st (e + x) = x"
  6.3019 +  apply (erule st_unique)
  6.3020 +  apply (erule Infinitesimal_add_approx_self2)
  6.3021 +  done
  6.3022  
  6.3023 -lemma HFinite_st_Infinitesimal_add:
  6.3024 -     "x \<in> HFinite ==> \<exists>e \<in> Infinitesimal. x = st(x) + e"
  6.3025 -by (blast dest!: st_approx_self [THEN approx_sym] bex_Infinitesimal_iff2 [THEN iffD2])
  6.3026 +lemma HFinite_st_Infinitesimal_add: "x \<in> HFinite \<Longrightarrow> \<exists>e \<in> Infinitesimal. x = st(x) + e"
  6.3027 +  by (blast dest!: st_approx_self [THEN approx_sym] bex_Infinitesimal_iff2 [THEN iffD2])
  6.3028  
  6.3029 -lemma st_add: "\<lbrakk>x \<in> HFinite; y \<in> HFinite\<rbrakk> \<Longrightarrow> st (x + y) = st x + st y"
  6.3030 -by (simp add: st_unique st_SReal st_approx_self approx_add)
  6.3031 +lemma st_add: "x \<in> HFinite \<Longrightarrow> y \<in> HFinite \<Longrightarrow> st (x + y) = st x + st y"
  6.3032 +  by (simp add: st_unique st_SReal st_approx_self approx_add)
  6.3033  
  6.3034  lemma st_numeral [simp]: "st (numeral w) = numeral w"
  6.3035 -by (rule Reals_numeral [THEN st_SReal_eq])
  6.3036 +  by (rule Reals_numeral [THEN st_SReal_eq])
  6.3037  
  6.3038  lemma st_neg_numeral [simp]: "st (- numeral w) = - numeral w"
  6.3039  proof -
  6.3040 @@ -1831,79 +1695,71 @@
  6.3041  qed
  6.3042  
  6.3043  lemma st_0 [simp]: "st 0 = 0"
  6.3044 -by (simp add: st_SReal_eq)
  6.3045 +  by (simp add: st_SReal_eq)
  6.3046  
  6.3047  lemma st_1 [simp]: "st 1 = 1"
  6.3048 -by (simp add: st_SReal_eq)
  6.3049 +  by (simp add: st_SReal_eq)
  6.3050  
  6.3051  lemma st_neg_1 [simp]: "st (- 1) = - 1"
  6.3052 -by (simp add: st_SReal_eq)
  6.3053 +  by (simp add: st_SReal_eq)
  6.3054  
  6.3055  lemma st_minus: "x \<in> HFinite \<Longrightarrow> st (- x) = - st x"
  6.3056 -by (simp add: st_unique st_SReal st_approx_self approx_minus)
  6.3057 +  by (simp add: st_unique st_SReal st_approx_self approx_minus)
  6.3058  
  6.3059  lemma st_diff: "\<lbrakk>x \<in> HFinite; y \<in> HFinite\<rbrakk> \<Longrightarrow> st (x - y) = st x - st y"
  6.3060 -by (simp add: st_unique st_SReal st_approx_self approx_diff)
  6.3061 +  by (simp add: st_unique st_SReal st_approx_self approx_diff)
  6.3062  
  6.3063  lemma st_mult: "\<lbrakk>x \<in> HFinite; y \<in> HFinite\<rbrakk> \<Longrightarrow> st (x * y) = st x * st y"
  6.3064 -by (simp add: st_unique st_SReal st_approx_self approx_mult_HFinite)
  6.3065 +  by (simp add: st_unique st_SReal st_approx_self approx_mult_HFinite)
  6.3066  
  6.3067 -lemma st_Infinitesimal: "x \<in> Infinitesimal ==> st x = 0"
  6.3068 -by (simp add: st_unique mem_infmal_iff)
  6.3069 +lemma st_Infinitesimal: "x \<in> Infinitesimal \<Longrightarrow> st x = 0"
  6.3070 +  by (simp add: st_unique mem_infmal_iff)
  6.3071  
  6.3072 -lemma st_not_Infinitesimal: "st(x) \<noteq> 0 ==> x \<notin> Infinitesimal"
  6.3073 +lemma st_not_Infinitesimal: "st(x) \<noteq> 0 \<Longrightarrow> x \<notin> Infinitesimal"
  6.3074  by (fast intro: st_Infinitesimal)
  6.3075  
  6.3076 -lemma st_inverse:
  6.3077 -     "[| x \<in> HFinite; st x \<noteq> 0 |]
  6.3078 -      ==> st(inverse x) = inverse (st x)"
  6.3079 -apply (rule_tac c1 = "st x" in mult_left_cancel [THEN iffD1])
  6.3080 -apply (auto simp add: st_mult [symmetric] st_not_Infinitesimal HFinite_inverse)
  6.3081 -apply (subst right_inverse, auto)
  6.3082 -done
  6.3083 +lemma st_inverse: "x \<in> HFinite \<Longrightarrow> st x \<noteq> 0 \<Longrightarrow> st (inverse x) = inverse (st x)"
  6.3084 +  apply (rule_tac c1 = "st x" in mult_left_cancel [THEN iffD1])
  6.3085 +   apply (auto simp add: st_mult [symmetric] st_not_Infinitesimal HFinite_inverse)
  6.3086 +  apply (subst right_inverse, auto)
  6.3087 +  done
  6.3088  
  6.3089 -lemma st_divide [simp]:
  6.3090 -     "[| x \<in> HFinite; y \<in> HFinite; st y \<noteq> 0 |]
  6.3091 -      ==> st(x/y) = (st x) / (st y)"
  6.3092 -by (simp add: divide_inverse st_mult st_not_Infinitesimal HFinite_inverse st_inverse)
  6.3093 +lemma st_divide [simp]: "x \<in> HFinite \<Longrightarrow> y \<in> HFinite \<Longrightarrow> st y \<noteq> 0 \<Longrightarrow> st (x / y) = st x / st y"
  6.3094 +  by (simp add: divide_inverse st_mult st_not_Infinitesimal HFinite_inverse st_inverse)
  6.3095  
  6.3096 -lemma st_idempotent [simp]: "x \<in> HFinite ==> st(st(x)) = st(x)"
  6.3097 -by (blast intro: st_HFinite st_approx_self approx_st_eq)
  6.3098 +lemma st_idempotent [simp]: "x \<in> HFinite \<Longrightarrow> st (st x) = st x"
  6.3099 +  by (blast intro: st_HFinite st_approx_self approx_st_eq)
  6.3100  
  6.3101  lemma Infinitesimal_add_st_less:
  6.3102 -     "[| x \<in> HFinite; y \<in> HFinite; u \<in> Infinitesimal; st x < st y |]
  6.3103 -      ==> st x + u < st y"
  6.3104 -apply (drule st_SReal)+
  6.3105 -apply (auto intro!: Infinitesimal_add_hypreal_of_real_less simp add: SReal_iff)
  6.3106 -done
  6.3107 +  "x \<in> HFinite \<Longrightarrow> y \<in> HFinite \<Longrightarrow> u \<in> Infinitesimal \<Longrightarrow> st x < st y \<Longrightarrow> st x + u < st y"
  6.3108 +  apply (drule st_SReal)+
  6.3109 +  apply (auto intro!: Infinitesimal_add_hypreal_of_real_less simp add: SReal_iff)
  6.3110 +  done
  6.3111  
  6.3112  lemma Infinitesimal_add_st_le_cancel:
  6.3113 -     "[| x \<in> HFinite; y \<in> HFinite;
  6.3114 -         u \<in> Infinitesimal; st x \<le> st y + u
  6.3115 -      |] ==> st x \<le> st y"
  6.3116 -apply (simp add: linorder_not_less [symmetric])
  6.3117 -apply (auto dest: Infinitesimal_add_st_less)
  6.3118 -done
  6.3119 +  "x \<in> HFinite \<Longrightarrow> y \<in> HFinite \<Longrightarrow> u \<in> Infinitesimal \<Longrightarrow>
  6.3120 +    st x \<le> st y + u \<Longrightarrow> st x \<le> st y"
  6.3121 +  apply (simp add: linorder_not_less [symmetric])
  6.3122 +  apply (auto dest: Infinitesimal_add_st_less)
  6.3123 +  done
  6.3124  
  6.3125 -lemma st_le: "[| x \<in> HFinite; y \<in> HFinite; x \<le> y |] ==> st(x) \<le> st(y)"
  6.3126 -by (metis approx_le_bound approx_sym linear st_SReal st_approx_self st_part_Ex1)
  6.3127 +lemma st_le: "x \<in> HFinite \<Longrightarrow> y \<in> HFinite \<Longrightarrow> x \<le> y \<Longrightarrow> st x \<le> st y"
  6.3128 +  by (metis approx_le_bound approx_sym linear st_SReal st_approx_self st_part_Ex1)
  6.3129  
  6.3130 -lemma st_zero_le: "[| 0 \<le> x;  x \<in> HFinite |] ==> 0 \<le> st x"
  6.3131 -apply (subst st_0 [symmetric])
  6.3132 -apply (rule st_le, auto)
  6.3133 -done
  6.3134 +lemma st_zero_le: "0 \<le> x \<Longrightarrow> x \<in> HFinite \<Longrightarrow> 0 \<le> st x"
  6.3135 +  apply (subst st_0 [symmetric])
  6.3136 +  apply (rule st_le, auto)
  6.3137 +  done
  6.3138  
  6.3139 -lemma st_zero_ge: "[| x \<le> 0;  x \<in> HFinite |] ==> st x \<le> 0"
  6.3140 -apply (subst st_0 [symmetric])
  6.3141 -apply (rule st_le, auto)
  6.3142 -done
  6.3143 +lemma st_zero_ge: "x \<le> 0 \<Longrightarrow> x \<in> HFinite \<Longrightarrow> st x \<le> 0"
  6.3144 +  apply (subst st_0 [symmetric])
  6.3145 +  apply (rule st_le, auto)
  6.3146 +  done
  6.3147  
  6.3148 -lemma st_hrabs: "x \<in> HFinite ==> \<bar>st x\<bar> = st \<bar>x\<bar>"
  6.3149 -apply (simp add: linorder_not_le st_zero_le abs_if st_minus
  6.3150 -   linorder_not_less)
  6.3151 -apply (auto dest!: st_zero_ge [OF order_less_imp_le])
  6.3152 -done
  6.3153 -
  6.3154 +lemma st_hrabs: "x \<in> HFinite \<Longrightarrow> \<bar>st x\<bar> = st \<bar>x\<bar>"
  6.3155 +  apply (simp add: linorder_not_le st_zero_le abs_if st_minus linorder_not_less)
  6.3156 +  apply (auto dest!: st_zero_ge [OF order_less_imp_le])
  6.3157 +  done
  6.3158  
  6.3159  
  6.3160  subsection \<open>Alternative Definitions using Free Ultrafilter\<close>
  6.3161 @@ -1911,78 +1767,73 @@
  6.3162  subsubsection \<open>@{term HFinite}\<close>
  6.3163  
  6.3164  lemma HFinite_FreeUltrafilterNat:
  6.3165 -    "star_n X \<in> HFinite
  6.3166 -   ==> \<exists>u. eventually (\<lambda>n. norm (X n) < u) FreeUltrafilterNat"
  6.3167 -apply (auto simp add: HFinite_def SReal_def)
  6.3168 -apply (rule_tac x=r in exI)
  6.3169 -apply (simp add: hnorm_def star_of_def starfun_star_n)
  6.3170 -apply (simp add: star_less_def starP2_star_n)
  6.3171 -done
  6.3172 +  "star_n X \<in> HFinite \<Longrightarrow> \<exists>u. eventually (\<lambda>n. norm (X n) < u) FreeUltrafilterNat"
  6.3173 +  apply (auto simp add: HFinite_def SReal_def)
  6.3174 +  apply (rule_tac x=r in exI)
  6.3175 +  apply (simp add: hnorm_def star_of_def starfun_star_n)
  6.3176 +  apply (simp add: star_less_def starP2_star_n)
  6.3177 +  done
  6.3178  
  6.3179  lemma FreeUltrafilterNat_HFinite:
  6.3180 -     "\<exists>u. eventually (\<lambda>n. norm (X n) < u) FreeUltrafilterNat
  6.3181 -       ==>  star_n X \<in> HFinite"
  6.3182 -apply (auto simp add: HFinite_def mem_Rep_star_iff)
  6.3183 -apply (rule_tac x="star_of u" in bexI)
  6.3184 -apply (simp add: hnorm_def starfun_star_n star_of_def)
  6.3185 -apply (simp add: star_less_def starP2_star_n)
  6.3186 -apply (simp add: SReal_def)
  6.3187 -done
  6.3188 +  "\<exists>u. eventually (\<lambda>n. norm (X n) < u) FreeUltrafilterNat \<Longrightarrow> star_n X \<in> HFinite"
  6.3189 +  apply (auto simp add: HFinite_def mem_Rep_star_iff)
  6.3190 +  apply (rule_tac x="star_of u" in bexI)
  6.3191 +   apply (simp add: hnorm_def starfun_star_n star_of_def)
  6.3192 +   apply (simp add: star_less_def starP2_star_n)
  6.3193 +  apply (simp add: SReal_def)
  6.3194 +  done
  6.3195  
  6.3196  lemma HFinite_FreeUltrafilterNat_iff:
  6.3197 -     "(star_n X \<in> HFinite) = (\<exists>u. eventually (\<lambda>n. norm (X n) < u) FreeUltrafilterNat)"
  6.3198 -by (blast intro!: HFinite_FreeUltrafilterNat FreeUltrafilterNat_HFinite)
  6.3199 +  "star_n X \<in> HFinite \<longleftrightarrow> (\<exists>u. eventually (\<lambda>n. norm (X n) < u) FreeUltrafilterNat)"
  6.3200 +  by (blast intro!: HFinite_FreeUltrafilterNat FreeUltrafilterNat_HFinite)
  6.3201 +
  6.3202  
  6.3203  subsubsection \<open>@{term HInfinite}\<close>
  6.3204  
  6.3205  lemma lemma_Compl_eq: "- {n. u < norm (f n)} = {n. norm (f n) \<le> u}"
  6.3206 -by auto
  6.3207 +  by auto
  6.3208  
  6.3209  lemma lemma_Compl_eq2: "- {n. norm (f n) < u} = {n. u \<le> norm (f n)}"
  6.3210 -by auto
  6.3211 +  by auto
  6.3212  
  6.3213 -lemma lemma_Int_eq1:
  6.3214 -     "{n. norm (f n) \<le> u} Int {n. u \<le> norm (f n)} = {n. norm(f n) = u}"
  6.3215 -by auto
  6.3216 +lemma lemma_Int_eq1: "{n. norm (f n) \<le> u} Int {n. u \<le> norm (f n)} = {n. norm(f n) = u}"
  6.3217 +  by auto
  6.3218  
  6.3219 -lemma lemma_FreeUltrafilterNat_one:
  6.3220 -     "{n. norm (f n) = u} \<le> {n. norm (f n) < u + (1::real)}"
  6.3221 -by auto
  6.3222 +lemma lemma_FreeUltrafilterNat_one: "{n. norm (f n) = u} \<le> {n. norm (f n) < u + (1::real)}"
  6.3223 +  by auto
  6.3224  
  6.3225 -(*-------------------------------------
  6.3226 -  Exclude this type of sets from free
  6.3227 -  ultrafilter for Infinite numbers!
  6.3228 - -------------------------------------*)
  6.3229 +text \<open>Exclude this type of sets from free ultrafilter for Infinite numbers!\<close>
  6.3230  lemma FreeUltrafilterNat_const_Finite:
  6.3231 -     "eventually (\<lambda>n. norm (X n) = u) FreeUltrafilterNat ==> star_n X \<in> HFinite"
  6.3232 -apply (rule FreeUltrafilterNat_HFinite)
  6.3233 -apply (rule_tac x = "u + 1" in exI)
  6.3234 -apply (auto elim: eventually_mono)
  6.3235 -done
  6.3236 +  "eventually (\<lambda>n. norm (X n) = u) FreeUltrafilterNat \<Longrightarrow> star_n X \<in> HFinite"
  6.3237 +  apply (rule FreeUltrafilterNat_HFinite)
  6.3238 +  apply (rule_tac x = "u + 1" in exI)
  6.3239 +  apply (auto elim: eventually_mono)
  6.3240 +  done
  6.3241  
  6.3242  lemma HInfinite_FreeUltrafilterNat:
  6.3243 -     "star_n X \<in> HInfinite ==> \<forall>u. eventually (\<lambda>n. u < norm (X n)) FreeUltrafilterNat"
  6.3244 -apply (drule HInfinite_HFinite_iff [THEN iffD1])
  6.3245 -apply (simp add: HFinite_FreeUltrafilterNat_iff)
  6.3246 -apply (rule allI, drule_tac x="u + 1" in spec)
  6.3247 -apply (simp add: FreeUltrafilterNat.eventually_not_iff[symmetric])
  6.3248 -apply (auto elim: eventually_mono)
  6.3249 -done
  6.3250 +  "star_n X \<in> HInfinite \<Longrightarrow> \<forall>u. eventually (\<lambda>n. u < norm (X n)) FreeUltrafilterNat"
  6.3251 +  apply (drule HInfinite_HFinite_iff [THEN iffD1])
  6.3252 +  apply (simp add: HFinite_FreeUltrafilterNat_iff)
  6.3253 +  apply (rule allI, drule_tac x="u + 1" in spec)
  6.3254 +  apply (simp add: FreeUltrafilterNat.eventually_not_iff[symmetric])
  6.3255 +  apply (auto elim: eventually_mono)
  6.3256 +  done
  6.3257  
  6.3258 -lemma lemma_Int_HI:
  6.3259 -     "{n. norm (Xa n) < u} Int {n. X n = Xa n} \<subseteq> {n. norm (X n) < (u::real)}"
  6.3260 -by auto
  6.3261 +lemma lemma_Int_HI: "{n. norm (Xa n) < u} \<inter> {n. X n = Xa n} \<subseteq> {n. norm (X n) < u}"
  6.3262 +  for u :: real
  6.3263 +  by auto
  6.3264  
  6.3265 -lemma lemma_Int_HIa: "{n. u < norm (X n)} Int {n. norm (X n) < u} = {}"
  6.3266 -by (auto intro: order_less_asym)
  6.3267 +lemma lemma_Int_HIa: "{n. u < norm (X n)} \<inter> {n. norm (X n) < u} = {}"
  6.3268 +  by (auto intro: order_less_asym)
  6.3269  
  6.3270  lemma FreeUltrafilterNat_HInfinite:
  6.3271 -     "\<forall>u. eventually (\<lambda>n. u < norm (X n)) FreeUltrafilterNat ==> star_n X \<in> HInfinite"
  6.3272 -apply (rule HInfinite_HFinite_iff [THEN iffD2])
  6.3273 -apply (safe, drule HFinite_FreeUltrafilterNat, safe)
  6.3274 -apply (drule_tac x = u in spec)
  6.3275 +  "\<forall>u. eventually (\<lambda>n. u < norm (X n)) FreeUltrafilterNat \<Longrightarrow> star_n X \<in> HInfinite"
  6.3276 +  apply (rule HInfinite_HFinite_iff [THEN iffD2])
  6.3277 +  apply (safe, drule HFinite_FreeUltrafilterNat, safe)
  6.3278 +  apply (drule_tac x = u in spec)
  6.3279  proof -
  6.3280 -  fix u assume "\<forall>\<^sub>Fn in \<U>. norm (X n) < u" "\<forall>\<^sub>Fn in \<U>. u < norm (X n)"
  6.3281 +  fix u
  6.3282 +  assume "\<forall>\<^sub>Fn in \<U>. norm (X n) < u" "\<forall>\<^sub>Fn in \<U>. u < norm (X n)"
  6.3283    then have "\<forall>\<^sub>F x in \<U>. False"
  6.3284      by eventually_elim auto
  6.3285    then show False
  6.3286 @@ -1990,230 +1841,204 @@
  6.3287  qed
  6.3288  
  6.3289  lemma HInfinite_FreeUltrafilterNat_iff:
  6.3290 -     "(star_n X \<in> HInfinite) = (\<forall>u. eventually (\<lambda>n. u < norm (X n)) FreeUltrafilterNat)"
  6.3291 -by (blast intro!: HInfinite_FreeUltrafilterNat FreeUltrafilterNat_HInfinite)
  6.3292 +  "star_n X \<in> HInfinite \<longleftrightarrow> (\<forall>u. eventually (\<lambda>n. u < norm (X n)) FreeUltrafilterNat)"
  6.3293 +  by (blast intro!: HInfinite_FreeUltrafilterNat FreeUltrafilterNat_HInfinite)
  6.3294 +
  6.3295  
  6.3296  subsubsection \<open>@{term Infinitesimal}\<close>
  6.3297  
  6.3298 -lemma ball_SReal_eq: "(\<forall>x::hypreal \<in> Reals. P x) = (\<forall>x::real. P (star_of x))"
  6.3299 -by (unfold SReal_def, auto)
  6.3300 +lemma ball_SReal_eq: "(\<forall>x::hypreal \<in> Reals. P x) \<longleftrightarrow> (\<forall>x::real. P (star_of x))"
  6.3301 +  by (auto simp: SReal_def)
  6.3302  
  6.3303  lemma Infinitesimal_FreeUltrafilterNat:
  6.3304 -     "star_n X \<in> Infinitesimal ==> \<forall>u>0. eventually (\<lambda>n. norm (X n) < u) \<U>"
  6.3305 -apply (simp add: Infinitesimal_def ball_SReal_eq)
  6.3306 -apply (simp add: hnorm_def starfun_star_n star_of_def)
  6.3307 -apply (simp add: star_less_def starP2_star_n)
  6.3308 -done
  6.3309 +  "star_n X \<in> Infinitesimal \<Longrightarrow> \<forall>u>0. eventually (\<lambda>n. norm (X n) < u) \<U>"
  6.3310 +  apply (simp add: Infinitesimal_def ball_SReal_eq)
  6.3311 +  apply (simp add: hnorm_def starfun_star_n star_of_def)
  6.3312 +  apply (simp add: star_less_def starP2_star_n)
  6.3313 +  done
  6.3314  
  6.3315  lemma FreeUltrafilterNat_Infinitesimal:
  6.3316 -     "\<forall>u>0. eventually (\<lambda>n. norm (X n) < u) \<U> ==> star_n X \<in> Infinitesimal"
  6.3317 -apply (simp add: Infinitesimal_def ball_SReal_eq)
  6.3318 -apply (simp add: hnorm_def starfun_star_n star_of_def)
  6.3319 -apply (simp add: star_less_def starP2_star_n)
  6.3320 -done
  6.3321 +  "\<forall>u>0. eventually (\<lambda>n. norm (X n) < u) \<U> \<Longrightarrow> star_n X \<in> Infinitesimal"
  6.3322 +  apply (simp add: Infinitesimal_def ball_SReal_eq)
  6.3323 +  apply (simp add: hnorm_def starfun_star_n star_of_def)
  6.3324 +  apply (simp add: star_less_def starP2_star_n)
  6.3325 +  done
  6.3326  
  6.3327  lemma Infinitesimal_FreeUltrafilterNat_iff:
  6.3328 -     "(star_n X \<in> Infinitesimal) = (\<forall>u>0. eventually (\<lambda>n. norm (X n) < u) \<U>)"
  6.3329 -by (blast intro!: Infinitesimal_FreeUltrafilterNat FreeUltrafilterNat_Infinitesimal)
  6.3330 +  "(star_n X \<in> Infinitesimal) = (\<forall>u>0. eventually (\<lambda>n. norm (X n) < u) \<U>)"
  6.3331 +  by (blast intro!: Infinitesimal_FreeUltrafilterNat FreeUltrafilterNat_Infinitesimal)
  6.3332 +
  6.3333  
  6.3334 -(*------------------------------------------------------------------------
  6.3335 -         Infinitesimals as smaller than 1/n for all n::nat (> 0)
  6.3336 - ------------------------------------------------------------------------*)
  6.3337 +text \<open>Infinitesimals as smaller than \<open>1/n\<close> for all \<open>n::nat (> 0)\<close>.\<close>
  6.3338  
  6.3339 -lemma lemma_Infinitesimal:
  6.3340 -     "(\<forall>r. 0 < r --> x < r) = (\<forall>n. x < inverse(real (Suc n)))"
  6.3341 -apply (auto simp del: of_nat_Suc)
  6.3342 -apply (blast dest!: reals_Archimedean intro: order_less_trans)
  6.3343 -done
  6.3344 +lemma lemma_Infinitesimal: "(\<forall>r. 0 < r \<longrightarrow> x < r) \<longleftrightarrow> (\<forall>n. x < inverse (real (Suc n)))"
  6.3345 +  apply (auto simp del: of_nat_Suc)
  6.3346 +  apply (blast dest!: reals_Archimedean intro: order_less_trans)
  6.3347 +  done
  6.3348  
  6.3349  lemma lemma_Infinitesimal2:
  6.3350 -     "(\<forall>r \<in> Reals. 0 < r --> x < r) =
  6.3351 -      (\<forall>n. x < inverse(hypreal_of_nat (Suc n)))"
  6.3352 -apply safe
  6.3353 - apply (drule_tac x = "inverse (hypreal_of_real (real (Suc n))) " in bspec)
  6.3354 -  apply simp_all
  6.3355 +  "(\<forall>r \<in> Reals. 0 < r \<longrightarrow> x < r) \<longleftrightarrow> (\<forall>n. x < inverse(hypreal_of_nat (Suc n)))"
  6.3356 +  apply safe
  6.3357 +   apply (drule_tac x = "inverse (hypreal_of_real (real (Suc n))) " in bspec)
  6.3358 +    apply simp_all
  6.3359    using less_imp_of_nat_less apply fastforce
  6.3360 -apply (auto dest!: reals_Archimedean simp add: SReal_iff simp del: of_nat_Suc)
  6.3361 -apply (drule star_of_less [THEN iffD2])
  6.3362 -apply simp
  6.3363 -apply (blast intro: order_less_trans)
  6.3364 -done
  6.3365 +  apply (auto dest!: reals_Archimedean simp add: SReal_iff simp del: of_nat_Suc)
  6.3366 +  apply (drule star_of_less [THEN iffD2])
  6.3367 +  apply simp
  6.3368 +  apply (blast intro: order_less_trans)
  6.3369 +  done
  6.3370  
  6.3371  
  6.3372  lemma Infinitesimal_hypreal_of_nat_iff:
  6.3373 -     "Infinitesimal = {x. \<forall>n. hnorm x < inverse (hypreal_of_nat (Suc n))}"
  6.3374 -apply (simp add: Infinitesimal_def)
  6.3375 -apply (auto simp add: lemma_Infinitesimal2)
  6.3376 -done
  6.3377 +  "Infinitesimal = {x. \<forall>n. hnorm x < inverse (hypreal_of_nat (Suc n))}"
  6.3378 +  apply (simp add: Infinitesimal_def)
  6.3379 +  apply (auto simp add: lemma_Infinitesimal2)
  6.3380 +  done
  6.3381  
  6.3382  
  6.3383 -subsection\<open>Proof that \<open>\<omega>\<close> is an infinite number\<close>
  6.3384 +subsection \<open>Proof that \<open>\<omega>\<close> is an infinite number\<close>
  6.3385  
  6.3386 -text\<open>It will follow that \<open>\<epsilon>\<close> is an infinitesimal number.\<close>
  6.3387 +text \<open>It will follow that \<open>\<epsilon>\<close> is an infinitesimal number.\<close>
  6.3388  
  6.3389  lemma Suc_Un_eq: "{n. n < Suc m} = {n. n < m} Un {n. n = m}"
  6.3390 -by (auto simp add: less_Suc_eq)
  6.3391 +  by (auto simp add: less_Suc_eq)
  6.3392  
  6.3393 -(*-------------------------------------------
  6.3394 -  Prove that any segment is finite and hence cannot belong to FreeUltrafilterNat
  6.3395 - -------------------------------------------*)
  6.3396 +
  6.3397 +text \<open>Prove that any segment is finite and hence cannot belong to \<open>FreeUltrafilterNat\<close>.\<close>
  6.3398  
  6.3399  lemma finite_real_of_nat_segment: "finite {n::nat. real n < real (m::nat)}"
  6.3400 -  by (auto intro: finite_Collect_less_nat)
  6.3401 +  by auto
  6.3402  
  6.3403  lemma finite_real_of_nat_less_real: "finite {n::nat. real n < u}"
  6.3404 -apply (cut_tac x = u in reals_Archimedean2, safe)
  6.3405 -apply (rule finite_real_of_nat_segment [THEN [2] finite_subset])
  6.3406 -apply (auto dest: order_less_trans)
  6.3407 -done
  6.3408 +  apply (cut_tac x = u in reals_Archimedean2, safe)
  6.3409 +  apply (rule finite_real_of_nat_segment [THEN [2] finite_subset])
  6.3410 +  apply (auto dest: order_less_trans)
  6.3411 +  done
  6.3412  
  6.3413 -lemma lemma_real_le_Un_eq:
  6.3414 -     "{n. f n \<le> u} = {n. f n < u} Un {n. u = (f n :: real)}"
  6.3415 -by (auto dest: order_le_imp_less_or_eq simp add: order_less_imp_le)
  6.3416 +lemma lemma_real_le_Un_eq: "{n. f n \<le> u} = {n. f n < u} \<union> {n. u = (f n :: real)}"
  6.3417 +  by (auto dest: order_le_imp_less_or_eq simp add: order_less_imp_le)
  6.3418  
  6.3419  lemma finite_real_of_nat_le_real: "finite {n::nat. real n \<le> u}"
  6.3420 -by (auto simp add: lemma_real_le_Un_eq lemma_finite_omega_set finite_real_of_nat_less_real)
  6.3421 +  by (auto simp add: lemma_real_le_Un_eq lemma_finite_omega_set finite_real_of_nat_less_real)
  6.3422  
  6.3423  lemma finite_rabs_real_of_nat_le_real: "finite {n::nat. \<bar>real n\<bar> \<le> u}"
  6.3424 -apply (simp (no_asm) add: finite_real_of_nat_le_real)
  6.3425 -done
  6.3426 +  by (simp add: finite_real_of_nat_le_real)
  6.3427  
  6.3428  lemma rabs_real_of_nat_le_real_FreeUltrafilterNat:
  6.3429 -     "\<not> eventually (\<lambda>n. \<bar>real n\<bar> \<le> u) FreeUltrafilterNat"
  6.3430 -by (blast intro!: FreeUltrafilterNat.finite finite_rabs_real_of_nat_le_real)
  6.3431 +  "\<not> eventually (\<lambda>n. \<bar>real n\<bar> \<le> u) FreeUltrafilterNat"
  6.3432 +  by (blast intro!: FreeUltrafilterNat.finite finite_rabs_real_of_nat_le_real)
  6.3433  
  6.3434  lemma FreeUltrafilterNat_nat_gt_real: "eventually (\<lambda>n. u < real n) FreeUltrafilterNat"
  6.3435 -apply (rule FreeUltrafilterNat.finite')
  6.3436 -apply (subgoal_tac "{n::nat. \<not> u < real n} = {n. real n \<le> u}")
  6.3437 -apply (auto simp add: finite_real_of_nat_le_real)
  6.3438 -done
  6.3439 +  apply (rule FreeUltrafilterNat.finite')
  6.3440 +  apply (subgoal_tac "{n::nat. \<not> u < real n} = {n. real n \<le> u}")
  6.3441 +   apply (auto simp add: finite_real_of_nat_le_real)
  6.3442 +  done
  6.3443  
  6.3444 -(*--------------------------------------------------------------
  6.3445 - The complement of {n. \<bar>real n\<bar> \<le> u} =
  6.3446 - {n. u < \<bar>real n\<bar>} is in FreeUltrafilterNat
  6.3447 - by property of (free) ultrafilters
  6.3448 - --------------------------------------------------------------*)
  6.3449 +text \<open>The complement of \<open>{n. \<bar>real n\<bar> \<le> u} = {n. u < \<bar>real n\<bar>}\<close> is in
  6.3450 +  \<open>FreeUltrafilterNat\<close> by property of (free) ultrafilters.\<close>
  6.3451  
  6.3452  lemma Compl_real_le_eq: "- {n::nat. real n \<le> u} = {n. u < real n}"
  6.3453 -by (auto dest!: order_le_less_trans simp add: linorder_not_le)
  6.3454 +  by (auto dest!: order_le_less_trans simp add: linorder_not_le)
  6.3455  
  6.3456 -text\<open>@{term \<omega>} is a member of @{term HInfinite}\<close>
  6.3457 -
  6.3458 +text \<open>@{term \<omega>} is a member of @{term HInfinite}.\<close>
  6.3459  theorem HInfinite_omega [simp]: "\<omega> \<in> HInfinite"
  6.3460 -apply (simp add: omega_def)
  6.3461 -apply (rule FreeUltrafilterNat_HInfinite)
  6.3462 -apply clarify
  6.3463 -apply (rule_tac u1 = "u-1" in eventually_mono [OF FreeUltrafilterNat_nat_gt_real])
  6.3464 -apply auto
  6.3465 -done
  6.3466 +  apply (simp add: omega_def)
  6.3467 +  apply (rule FreeUltrafilterNat_HInfinite)
  6.3468 +  apply clarify
  6.3469 +  apply (rule_tac u1 = "u-1" in eventually_mono [OF FreeUltrafilterNat_nat_gt_real])
  6.3470 +  apply auto
  6.3471 +  done
  6.3472  
  6.3473 -(*-----------------------------------------------
  6.3474 -       Epsilon is a member of Infinitesimal
  6.3475 - -----------------------------------------------*)
  6.3476 +
  6.3477 +text \<open>Epsilon is a member of Infinitesimal.\<close>
  6.3478  
  6.3479  lemma Infinitesimal_epsilon [simp]: "\<epsilon> \<in> Infinitesimal"
  6.3480 -by (auto intro!: HInfinite_inverse_Infinitesimal HInfinite_omega simp add: hypreal_epsilon_inverse_omega)
  6.3481 +  by (auto intro!: HInfinite_inverse_Infinitesimal HInfinite_omega
  6.3482 +      simp add: hypreal_epsilon_inverse_omega)
  6.3483  
  6.3484  lemma HFinite_epsilon [simp]: "\<epsilon> \<in> HFinite"
  6.3485 -by (auto intro: Infinitesimal_subset_HFinite [THEN subsetD])
  6.3486 +  by (auto intro: Infinitesimal_subset_HFinite [THEN subsetD])
  6.3487  
  6.3488  lemma epsilon_approx_zero [simp]: "\<epsilon> \<approx> 0"
  6.3489 -apply (simp (no_asm) add: mem_infmal_iff [symmetric])
  6.3490 -done
  6.3491 -
  6.3492 -(*------------------------------------------------------------------------
  6.3493 -  Needed for proof that we define a hyperreal [<X(n)] \<approx> hypreal_of_real a given
  6.3494 -  that \<forall>n. |X n - a| < 1/n. Used in proof of NSLIM => LIM.
  6.3495 - -----------------------------------------------------------------------*)
  6.3496 +  by (simp add: mem_infmal_iff [symmetric])
  6.3497  
  6.3498 -lemma real_of_nat_less_inverse_iff:
  6.3499 -     "0 < u  ==> (u < inverse (real(Suc n))) = (real(Suc n) < inverse u)"
  6.3500 -apply (simp add: inverse_eq_divide)
  6.3501 -apply (subst pos_less_divide_eq, assumption)
  6.3502 -apply (subst pos_less_divide_eq)
  6.3503 - apply simp
  6.3504 -apply (simp add: mult.commute)
  6.3505 -done
  6.3506 +text \<open>Needed for proof that we define a hyperreal \<open>[<X(n)] \<approx> hypreal_of_real a\<close> given
  6.3507 +  that \<open>\<forall>n. |X n - a| < 1/n\<close>. Used in proof of \<open>NSLIM \<Rightarrow> LIM\<close>.\<close>
  6.3508 +lemma real_of_nat_less_inverse_iff: "0 < u \<Longrightarrow> u < inverse (real(Suc n)) \<longleftrightarrow> real(Suc n) < inverse u"
  6.3509 +  apply (simp add: inverse_eq_divide)
  6.3510 +  apply (subst pos_less_divide_eq, assumption)
  6.3511 +  apply (subst pos_less_divide_eq)
  6.3512 +   apply simp
  6.3513 +  apply (simp add: mult.commute)
  6.3514 +  done
  6.3515  
  6.3516 -lemma finite_inverse_real_of_posnat_gt_real:
  6.3517 -     "0 < u ==> finite {n. u < inverse(real(Suc n))}"
  6.3518 +lemma finite_inverse_real_of_posnat_gt_real: "0 < u \<Longrightarrow> finite {n. u < inverse (real (Suc n))}"
  6.3519  proof (simp only: real_of_nat_less_inverse_iff)
  6.3520    have "{n. 1 + real n < inverse u} = {n. real n < inverse u - 1}"
  6.3521      by fastforce
  6.3522 -  thus "finite {n. real (Suc n) < inverse u}"
  6.3523 -    using finite_real_of_nat_less_real [of "inverse u - 1"] by auto
  6.3524 +  then show "finite {n. real (Suc n) < inverse u}"
  6.3525 +    using finite_real_of_nat_less_real [of "inverse u - 1"]
  6.3526 +    by auto
  6.3527  qed
  6.3528  
  6.3529  lemma lemma_real_le_Un_eq2:
  6.3530 -     "{n. u \<le> inverse(real(Suc n))} =
  6.3531 -     {n. u < inverse(real(Suc n))} Un {n. u = inverse(real(Suc n))}"
  6.3532 -by (auto dest: order_le_imp_less_or_eq simp add: order_less_imp_le)
  6.3533 +  "{n. u \<le> inverse(real(Suc n))} =
  6.3534 +    {n. u < inverse(real(Suc n))} \<union> {n. u = inverse(real(Suc n))}"
  6.3535 +  by (auto dest: order_le_imp_less_or_eq simp add: order_less_imp_le)
  6.3536  
  6.3537 -lemma finite_inverse_real_of_posnat_ge_real:
  6.3538 -     "0 < u ==> finite {n. u \<le> inverse(real(Suc n))}"
  6.3539 -by (auto simp add: lemma_real_le_Un_eq2 lemma_finite_epsilon_set finite_inverse_real_of_posnat_gt_real
  6.3540 -            simp del: of_nat_Suc)
  6.3541 +lemma finite_inverse_real_of_posnat_ge_real: "0 < u \<Longrightarrow> finite {n. u \<le> inverse (real (Suc n))}"
  6.3542 +  by (auto simp add: lemma_real_le_Un_eq2 lemma_finite_epsilon_set finite_inverse_real_of_posnat_gt_real
  6.3543 +      simp del: of_nat_Suc)
  6.3544  
  6.3545  lemma inverse_real_of_posnat_ge_real_FreeUltrafilterNat:
  6.3546 -     "0 < u ==> \<not> eventually (\<lambda>n. u \<le> inverse(real(Suc n))) FreeUltrafilterNat"
  6.3547 -by (blast intro!: FreeUltrafilterNat.finite finite_inverse_real_of_posnat_ge_real)
  6.3548 +  "0 < u \<Longrightarrow> \<not> eventually (\<lambda>n. u \<le> inverse(real(Suc n))) FreeUltrafilterNat"
  6.3549 +  by (blast intro!: FreeUltrafilterNat.finite finite_inverse_real_of_posnat_ge_real)
  6.3550  
  6.3551 -(*--------------------------------------------------------------
  6.3552 -    The complement of  {n. u \<le> inverse(real(Suc n))} =
  6.3553 -    {n. inverse(real(Suc n)) < u} is in FreeUltrafilterNat
  6.3554 -    by property of (free) ultrafilters
  6.3555 - --------------------------------------------------------------*)
  6.3556 -lemma Compl_le_inverse_eq:
  6.3557 -     "- {n. u \<le> inverse(real(Suc n))} = {n. inverse(real(Suc n)) < u}"
  6.3558 -by (auto dest!: order_le_less_trans simp add: linorder_not_le)
  6.3559 +text \<open>The complement of \<open>{n. u \<le> inverse(real(Suc n))} = {n. inverse (real (Suc n)) < u}\<close>
  6.3560 +  is in \<open>FreeUltrafilterNat\<close> by property of (free) ultrafilters.\<close>
  6.3561 +lemma Compl_le_inverse_eq: "- {n. u \<le> inverse(real(Suc n))} = {n. inverse(real(Suc n)) < u}"
  6.3562 +  by (auto dest!: order_le_less_trans simp add: linorder_not_le)
  6.3563  
  6.3564  
  6.3565  lemma FreeUltrafilterNat_inverse_real_of_posnat:
  6.3566 -     "0 < u ==> eventually (\<lambda>n. inverse(real(Suc n)) < u) FreeUltrafilterNat"
  6.3567 -by (drule inverse_real_of_posnat_ge_real_FreeUltrafilterNat)
  6.3568 -   (simp add: FreeUltrafilterNat.eventually_not_iff not_le[symmetric])
  6.3569 +  "0 < u \<Longrightarrow> eventually (\<lambda>n. inverse(real(Suc n)) < u) FreeUltrafilterNat"
  6.3570 +  by (drule inverse_real_of_posnat_ge_real_FreeUltrafilterNat)
  6.3571 +    (simp add: FreeUltrafilterNat.eventually_not_iff not_le[symmetric])
  6.3572  
  6.3573 -text\<open>Example of an hypersequence (i.e. an extended standard sequence)
  6.3574 -   whose term with an hypernatural suffix is an infinitesimal i.e.
  6.3575 -   the whn'nth term of the hypersequence is a member of Infinitesimal\<close>
  6.3576 +text \<open>Example of an hypersequence (i.e. an extended standard sequence)
  6.3577 +  whose term with an hypernatural suffix is an infinitesimal i.e.
  6.3578 +  the whn'nth term of the hypersequence is a member of Infinitesimal\<close>
  6.3579  
  6.3580 -lemma SEQ_Infinitesimal:
  6.3581 -      "( *f* (%n::nat. inverse(real(Suc n)))) whn : Infinitesimal"
  6.3582 -by (simp add: hypnat_omega_def starfun_star_n star_n_inverse Infinitesimal_FreeUltrafilterNat_iff
  6.3583 -        FreeUltrafilterNat_inverse_real_of_posnat del: of_nat_Suc)
  6.3584 +lemma SEQ_Infinitesimal: "( *f* (\<lambda>n::nat. inverse(real(Suc n)))) whn \<in> Infinitesimal"
  6.3585 +  by (simp add: hypnat_omega_def starfun_star_n star_n_inverse Infinitesimal_FreeUltrafilterNat_iff
  6.3586 +      FreeUltrafilterNat_inverse_real_of_posnat del: of_nat_Suc)
  6.3587  
  6.3588 -text\<open>Example where we get a hyperreal from a real sequence
  6.3589 -      for which a particular property holds. The theorem is
  6.3590 -      used in proofs about equivalence of nonstandard and
  6.3591 -      standard neighbourhoods. Also used for equivalence of
  6.3592 -      nonstandard ans standard definitions of pointwise
  6.3593 -      limit.\<close>
  6.3594 +text \<open>Example where we get a hyperreal from a real sequence
  6.3595 +  for which a particular property holds. The theorem is
  6.3596 +  used in proofs about equivalence of nonstandard and
  6.3597 +  standard neighbourhoods. Also used for equivalence of
  6.3598 +  nonstandard ans standard definitions of pointwise
  6.3599 +  limit.\<close>
  6.3600  
  6.3601 -(*-----------------------------------------------------
  6.3602 -    |X(n) - x| < 1/n ==> [<X n>] - hypreal_of_real x| \<in> Infinitesimal
  6.3603 - -----------------------------------------------------*)
  6.3604 +text \<open>\<open>|X(n) - x| < 1/n \<Longrightarrow> [<X n>] - hypreal_of_real x| \<in> Infinitesimal\<close>\<close>
  6.3605  lemma real_seq_to_hypreal_Infinitesimal:
  6.3606 -     "\<forall>n. norm(X n - x) < inverse(real(Suc n))
  6.3607 -     ==> star_n X - star_of x \<in> Infinitesimal"
  6.3608 -unfolding star_n_diff star_of_def Infinitesimal_FreeUltrafilterNat_iff star_n_inverse
  6.3609 -by (auto dest!: FreeUltrafilterNat_inverse_real_of_posnat
  6.3610 -         intro: order_less_trans elim!: eventually_mono)
  6.3611 +  "\<forall>n. norm (X n - x) < inverse (real (Suc n)) \<Longrightarrow> star_n X - star_of x \<in> Infinitesimal"
  6.3612 +  unfolding star_n_diff star_of_def Infinitesimal_FreeUltrafilterNat_iff star_n_inverse
  6.3613 +  by (auto dest!: FreeUltrafilterNat_inverse_real_of_posnat
  6.3614 +      intro: order_less_trans elim!: eventually_mono)
  6.3615  
  6.3616  lemma real_seq_to_hypreal_approx:
  6.3617 -     "\<forall>n. norm(X n - x) < inverse(real(Suc n))
  6.3618 -      ==> star_n X \<approx> star_of x"
  6.3619 -by (metis bex_Infinitesimal_iff real_seq_to_hypreal_Infinitesimal)
  6.3620 +  "\<forall>n. norm (X n - x) < inverse (real (Suc n)) \<Longrightarrow> star_n X \<approx> star_of x"
  6.3621 +  by (metis bex_Infinitesimal_iff real_seq_to_hypreal_Infinitesimal)
  6.3622  
  6.3623  lemma real_seq_to_hypreal_approx2:
  6.3624 -     "\<forall>n. norm(x - X n) < inverse(real(Suc n))
  6.3625 -               ==> star_n X \<approx> star_of x"
  6.3626 -by (metis norm_minus_commute real_seq_to_hypreal_approx)
  6.3627 +  "\<forall>n. norm (x - X n) < inverse(real(Suc n)) \<Longrightarrow> star_n X \<approx> star_of x"
  6.3628 +  by (metis norm_minus_commute real_seq_to_hypreal_approx)
  6.3629  
  6.3630  lemma real_seq_to_hypreal_Infinitesimal2:
  6.3631 -     "\<forall>n. norm(X n - Y n) < inverse(real(Suc n))
  6.3632 -      ==> star_n X - star_n Y \<in> Infinitesimal"
  6.3633 -unfolding Infinitesimal_FreeUltrafilterNat_iff star_n_diff
  6.3634 -by (auto dest!: FreeUltrafilterNat_inverse_real_of_posnat
  6.3635 -         intro: order_less_trans elim!: eventually_mono)
  6.3636 +  "\<forall>n. norm(X n - Y n) < inverse(real(Suc n)) \<Longrightarrow> star_n X - star_n Y \<in> Infinitesimal"
  6.3637 +  unfolding Infinitesimal_FreeUltrafilterNat_iff star_n_diff
  6.3638 +  by (auto dest!: FreeUltrafilterNat_inverse_real_of_posnat
  6.3639 +      intro: order_less_trans elim!: eventually_mono)
  6.3640  
  6.3641  end
     7.1 --- a/src/HOL/Nonstandard_Analysis/NSComplex.thy	Mon Oct 31 16:26:36 2016 +0100
     7.2 +++ b/src/HOL/Nonstandard_Analysis/NSComplex.thy	Tue Nov 01 00:44:24 2016 +0100
     7.3 @@ -3,654 +3,604 @@
     7.4      Author:     Lawrence C Paulson
     7.5  *)
     7.6  
     7.7 -section\<open>Nonstandard Complex Numbers\<close>
     7.8 +section \<open>Nonstandard Complex Numbers\<close>
     7.9  
    7.10  theory NSComplex
    7.11 -imports NSA
    7.12 +  imports NSA
    7.13  begin
    7.14  
    7.15  type_synonym hcomplex = "complex star"
    7.16  
    7.17 -abbreviation
    7.18 -  hcomplex_of_complex :: "complex => complex star" where
    7.19 -  "hcomplex_of_complex == star_of"
    7.20 +abbreviation hcomplex_of_complex :: "complex \<Rightarrow> complex star"
    7.21 +  where "hcomplex_of_complex \<equiv> star_of"
    7.22  
    7.23 -abbreviation
    7.24 -  hcmod :: "complex star => real star" where
    7.25 -  "hcmod == hnorm"
    7.26 +abbreviation hcmod :: "complex star \<Rightarrow> real star"
    7.27 +  where "hcmod \<equiv> hnorm"
    7.28  
    7.29  
    7.30 -  (*--- real and Imaginary parts ---*)
    7.31 +subsubsection \<open>Real and Imaginary parts\<close>
    7.32 +
    7.33 +definition hRe :: "hcomplex \<Rightarrow> hypreal"
    7.34 +  where "hRe = *f* Re"
    7.35 +
    7.36 +definition hIm :: "hcomplex \<Rightarrow> hypreal"
    7.37 +  where "hIm = *f* Im"
    7.38 +
    7.39  
    7.40 -definition
    7.41 -  hRe :: "hcomplex => hypreal" where
    7.42 -  "hRe = *f* Re"
    7.43 +subsubsection \<open>Imaginary unit\<close>
    7.44 +
    7.45 +definition iii :: hcomplex
    7.46 +  where "iii = star_of \<i>"
    7.47  
    7.48 -definition
    7.49 -  hIm :: "hcomplex => hypreal" where
    7.50 -  "hIm = *f* Im"
    7.51 +
    7.52 +subsubsection \<open>Complex conjugate\<close>
    7.53 +
    7.54 +definition hcnj :: "hcomplex \<Rightarrow> hcomplex"
    7.55 +  where "hcnj = *f* cnj"
    7.56  
    7.57  
    7.58 -  (*------ imaginary unit ----------*)
    7.59 +subsubsection \<open>Argand\<close>
    7.60  
    7.61 -definition
    7.62 -  iii :: hcomplex where
    7.63 -  "iii = star_of \<i>"
    7.64 -
    7.65 -  (*------- complex conjugate ------*)
    7.66 +definition hsgn :: "hcomplex \<Rightarrow> hcomplex"
    7.67 +  where "hsgn = *f* sgn"
    7.68  
    7.69 -definition
    7.70 -  hcnj :: "hcomplex => hcomplex" where
    7.71 -  "hcnj = *f* cnj"
    7.72 -
    7.73 -  (*------------ Argand -------------*)
    7.74 +definition harg :: "hcomplex \<Rightarrow> hypreal"
    7.75 +  where "harg = *f* arg"
    7.76  
    7.77 -definition
    7.78 -  hsgn :: "hcomplex => hcomplex" where
    7.79 -  "hsgn = *f* sgn"
    7.80 +definition  \<comment> \<open>abbreviation for \<open>cos a + i sin a\<close>\<close>
    7.81 +  hcis :: "hypreal \<Rightarrow> hcomplex"
    7.82 +  where "hcis = *f* cis"
    7.83  
    7.84 -definition
    7.85 -  harg :: "hcomplex => hypreal" where
    7.86 -  "harg = *f* arg"
    7.87 +
    7.88 +subsubsection \<open>Injection from hyperreals\<close>
    7.89  
    7.90 -definition
    7.91 -  (* abbreviation for (cos a + i sin a) *)
    7.92 -  hcis :: "hypreal => hcomplex" where
    7.93 -  "hcis = *f* cis"
    7.94 +abbreviation hcomplex_of_hypreal :: "hypreal \<Rightarrow> hcomplex"
    7.95 +  where "hcomplex_of_hypreal \<equiv> of_hypreal"
    7.96  
    7.97 -  (*----- injection from hyperreals -----*)
    7.98 +definition  \<comment> \<open>abbreviation for \<open>r * (cos a + i sin a)\<close>\<close>
    7.99 +  hrcis :: "hypreal \<Rightarrow> hypreal \<Rightarrow> hcomplex"
   7.100 +  where "hrcis = *f2* rcis"
   7.101  
   7.102 -abbreviation
   7.103 -  hcomplex_of_hypreal :: "hypreal \<Rightarrow> hcomplex" where
   7.104 -  "hcomplex_of_hypreal \<equiv> of_hypreal"
   7.105  
   7.106 -definition
   7.107 -  (* abbreviation for r*(cos a + i sin a) *)
   7.108 -  hrcis :: "[hypreal, hypreal] => hcomplex" where
   7.109 -  "hrcis = *f2* rcis"
   7.110 +subsubsection \<open>\<open>e ^ (x + iy)\<close>\<close>
   7.111  
   7.112 -  (*------------ e ^ (x + iy) ------------*)
   7.113 -definition
   7.114 -  hExp :: "hcomplex => hcomplex" where
   7.115 -  "hExp = *f* exp"
   7.116 +definition hExp :: "hcomplex \<Rightarrow> hcomplex"
   7.117 +  where "hExp = *f* exp"
   7.118  
   7.119 -definition
   7.120 -  HComplex :: "[hypreal,hypreal] => hcomplex" where
   7.121 -  "HComplex = *f2* Complex"
   7.122 +definition HComplex :: "hypreal \<Rightarrow> hypreal \<Rightarrow> hcomplex"
   7.123 +  where "HComplex = *f2* Complex"
   7.124  
   7.125  lemmas hcomplex_defs [transfer_unfold] =
   7.126    hRe_def hIm_def iii_def hcnj_def hsgn_def harg_def hcis_def
   7.127    hrcis_def hExp_def HComplex_def
   7.128  
   7.129  lemma Standard_hRe [simp]: "x \<in> Standard \<Longrightarrow> hRe x \<in> Standard"
   7.130 -by (simp add: hcomplex_defs)
   7.131 +  by (simp add: hcomplex_defs)
   7.132  
   7.133  lemma Standard_hIm [simp]: "x \<in> Standard \<Longrightarrow> hIm x \<in> Standard"
   7.134 -by (simp add: hcomplex_defs)
   7.135 +  by (simp add: hcomplex_defs)
   7.136  
   7.137  lemma Standard_iii [simp]: "iii \<in> Standard"
   7.138 -by (simp add: hcomplex_defs)
   7.139 +  by (simp add: hcomplex_defs)
   7.140  
   7.141  lemma Standard_hcnj [simp]: "x \<in> Standard \<Longrightarrow> hcnj x \<in> Standard"
   7.142 -by (simp add: hcomplex_defs)
   7.143 +  by (simp add: hcomplex_defs)
   7.144  
   7.145  lemma Standard_hsgn [simp]: "x \<in> Standard \<Longrightarrow> hsgn x \<in> Standard"
   7.146 -by (simp add: hcomplex_defs)
   7.147 +  by (simp add: hcomplex_defs)
   7.148  
   7.149  lemma Standard_harg [simp]: "x \<in> Standard \<Longrightarrow> harg x \<in> Standard"
   7.150 -by (simp add: hcomplex_defs)
   7.151 +  by (simp add: hcomplex_defs)
   7.152  
   7.153  lemma Standard_hcis [simp]: "r \<in> Standard \<Longrightarrow> hcis r \<in> Standard"
   7.154 -by (simp add: hcomplex_defs)
   7.155 +  by (simp add: hcomplex_defs)
   7.156  
   7.157  lemma Standard_hExp [simp]: "x \<in> Standard \<Longrightarrow> hExp x \<in> Standard"
   7.158 -by (simp add: hcomplex_defs)
   7.159 +  by (simp add: hcomplex_defs)
   7.160  
   7.161 -lemma Standard_hrcis [simp]:
   7.162 -  "\<lbrakk>r \<in> Standard; s \<in> Standard\<rbrakk> \<Longrightarrow> hrcis r s \<in> Standard"
   7.163 -by (simp add: hcomplex_defs)
   7.164 +lemma Standard_hrcis [simp]: "r \<in> Standard \<Longrightarrow> s \<in> Standard \<Longrightarrow> hrcis r s \<in> Standard"
   7.165 +  by (simp add: hcomplex_defs)
   7.166  
   7.167 -lemma Standard_HComplex [simp]:
   7.168 -  "\<lbrakk>r \<in> Standard; s \<in> Standard\<rbrakk> \<Longrightarrow> HComplex r s \<in> Standard"
   7.169 -by (simp add: hcomplex_defs)
   7.170 +lemma Standard_HComplex [simp]: "r \<in> Standard \<Longrightarrow> s \<in> Standard \<Longrightarrow> HComplex r s \<in> Standard"
   7.171 +  by (simp add: hcomplex_defs)
   7.172  
   7.173  lemma hcmod_def: "hcmod = *f* cmod"
   7.174 -by (rule hnorm_def)
   7.175 +  by (rule hnorm_def)
   7.176  
   7.177  
   7.178 -subsection\<open>Properties of Nonstandard Real and Imaginary Parts\<close>
   7.179 +subsection \<open>Properties of Nonstandard Real and Imaginary Parts\<close>
   7.180  
   7.181 -lemma hcomplex_hRe_hIm_cancel_iff:
   7.182 -     "!!w z. (w=z) = (hRe(w) = hRe(z) & hIm(w) = hIm(z))"
   7.183 -by transfer (rule complex_Re_Im_cancel_iff)
   7.184 +lemma hcomplex_hRe_hIm_cancel_iff: "\<And>w z. w = z \<longleftrightarrow> hRe w = hRe z \<and> hIm w = hIm z"
   7.185 +  by transfer (rule complex_Re_Im_cancel_iff)
   7.186  
   7.187 -lemma hcomplex_equality [intro?]:
   7.188 -  "!!z w. hRe z = hRe w ==> hIm z = hIm w ==> z = w"
   7.189 -by transfer (rule complex_equality)
   7.190 +lemma hcomplex_equality [intro?]: "\<And>z w. hRe z = hRe w \<Longrightarrow> hIm z = hIm w \<Longrightarrow> z = w"
   7.191 +  by transfer (rule complex_equality)
   7.192  
   7.193  lemma hcomplex_hRe_zero [simp]: "hRe 0 = 0"
   7.194 -by transfer simp
   7.195 +  by transfer simp
   7.196  
   7.197  lemma hcomplex_hIm_zero [simp]: "hIm 0 = 0"
   7.198 -by transfer simp
   7.199 +  by transfer simp
   7.200  
   7.201  lemma hcomplex_hRe_one [simp]: "hRe 1 = 1"
   7.202 -by transfer simp
   7.203 +  by transfer simp
   7.204  
   7.205  lemma hcomplex_hIm_one [simp]: "hIm 1 = 0"
   7.206 -by transfer simp
   7.207 +  by transfer simp
   7.208 +
   7.209 +
   7.210 +subsection \<open>Addition for Nonstandard Complex Numbers\<close>
   7.211 +
   7.212 +lemma hRe_add: "\<And>x y. hRe (x + y) = hRe x + hRe y"
   7.213 +  by transfer simp
   7.214 +
   7.215 +lemma hIm_add: "\<And>x y. hIm (x + y) = hIm x + hIm y"
   7.216 +  by transfer simp
   7.217  
   7.218  
   7.219 -subsection\<open>Addition for Nonstandard Complex Numbers\<close>
   7.220 -
   7.221 -lemma hRe_add: "!!x y. hRe(x + y) = hRe(x) + hRe(y)"
   7.222 -by transfer simp
   7.223 +subsection \<open>More Minus Laws\<close>
   7.224  
   7.225 -lemma hIm_add: "!!x y. hIm(x + y) = hIm(x) + hIm(y)"
   7.226 -by transfer simp
   7.227 +lemma hRe_minus: "\<And>z. hRe (- z) = - hRe z"
   7.228 +  by transfer (rule uminus_complex.sel)
   7.229  
   7.230 -subsection\<open>More Minus Laws\<close>
   7.231 -
   7.232 -lemma hRe_minus: "!!z. hRe(-z) = - hRe(z)"
   7.233 -by transfer (rule uminus_complex.sel)
   7.234 +lemma hIm_minus: "\<And>z. hIm (- z) = - hIm z"
   7.235 +  by transfer (rule uminus_complex.sel)
   7.236  
   7.237 -lemma hIm_minus: "!!z. hIm(-z) = - hIm(z)"
   7.238 -by transfer (rule uminus_complex.sel)
   7.239 +lemma hcomplex_add_minus_eq_minus: "x + y = 0 \<Longrightarrow> x = - y"
   7.240 +  for x y :: hcomplex
   7.241 +  apply (drule minus_unique)
   7.242 +  apply (simp add: minus_equation_iff [of x y])
   7.243 +  done
   7.244  
   7.245 -lemma hcomplex_add_minus_eq_minus:
   7.246 -      "x + y = (0::hcomplex) ==> x = -y"
   7.247 -apply (drule minus_unique)
   7.248 -apply (simp add: minus_equation_iff [of x y])
   7.249 -done
   7.250 +lemma hcomplex_i_mult_eq [simp]: "iii * iii = - 1"
   7.251 +  by transfer (rule i_squared)
   7.252  
   7.253 -lemma hcomplex_i_mult_eq [simp]: "iii * iii = -1"
   7.254 -by transfer (rule i_squared)
   7.255 -
   7.256 -lemma hcomplex_i_mult_left [simp]: "!!z. iii * (iii * z) = -z"
   7.257 -by transfer (rule complex_i_mult_minus)
   7.258 +lemma hcomplex_i_mult_left [simp]: "\<And>z. iii * (iii * z) = - z"
   7.259 +  by transfer (rule complex_i_mult_minus)
   7.260  
   7.261  lemma hcomplex_i_not_zero [simp]: "iii \<noteq> 0"
   7.262 -by transfer (rule complex_i_not_zero)
   7.263 +  by transfer (rule complex_i_not_zero)
   7.264  
   7.265  
   7.266 -subsection\<open>More Multiplication Laws\<close>
   7.267 +subsection \<open>More Multiplication Laws\<close>
   7.268  
   7.269 -lemma hcomplex_mult_minus_one: "- 1 * (z::hcomplex) = -z"
   7.270 -by simp
   7.271 -
   7.272 -lemma hcomplex_mult_minus_one_right: "(z::hcomplex) * - 1 = -z"
   7.273 -by simp
   7.274 +lemma hcomplex_mult_minus_one: "- 1 * z = - z"
   7.275 +  for z :: hcomplex
   7.276 +  by simp
   7.277  
   7.278 -lemma hcomplex_mult_left_cancel:
   7.279 -     "(c::hcomplex) \<noteq> (0::hcomplex) ==> (c*a=c*b) = (a=b)"
   7.280 -by simp
   7.281 +lemma hcomplex_mult_minus_one_right: "z * - 1 = - z"
   7.282 +  for z :: hcomplex
   7.283 +  by simp
   7.284  
   7.285 -lemma hcomplex_mult_right_cancel:
   7.286 -     "(c::hcomplex) \<noteq> (0::hcomplex) ==> (a*c=b*c) = (a=b)"
   7.287 -by simp
   7.288 +lemma hcomplex_mult_left_cancel: "c \<noteq> 0 \<Longrightarrow> c * a = c * b \<longleftrightarrow> a = b"
   7.289 +  for a b c :: hcomplex
   7.290 +  by simp
   7.291 +
   7.292 +lemma hcomplex_mult_right_cancel: "c \<noteq> 0 \<Longrightarrow> a * c = b * c \<longleftrightarrow> a = b"
   7.293 +  for a b c :: hcomplex
   7.294 +  by simp
   7.295  
   7.296  
   7.297 -subsection\<open>Subraction and Division\<close>
   7.298 +subsection \<open>Subtraction and Division\<close>
   7.299  
   7.300 -lemma hcomplex_diff_eq_eq [simp]: "((x::hcomplex) - y = z) = (x = z + y)"
   7.301  (* TODO: delete *)
   7.302 -by (rule diff_eq_eq)
   7.303 +lemma hcomplex_diff_eq_eq [simp]: "x - y = z \<longleftrightarrow> x = z + y"
   7.304 +  for x y z :: hcomplex
   7.305 +  by (rule diff_eq_eq)
   7.306  
   7.307  
   7.308 -subsection\<open>Embedding Properties for @{term hcomplex_of_hypreal} Map\<close>
   7.309 +subsection \<open>Embedding Properties for @{term hcomplex_of_hypreal} Map\<close>
   7.310 +
   7.311 +lemma hRe_hcomplex_of_hypreal [simp]: "\<And>z. hRe (hcomplex_of_hypreal z) = z"
   7.312 +  by transfer (rule Re_complex_of_real)
   7.313  
   7.314 -lemma hRe_hcomplex_of_hypreal [simp]: "!!z. hRe(hcomplex_of_hypreal z) = z"
   7.315 -by transfer (rule Re_complex_of_real)
   7.316 +lemma hIm_hcomplex_of_hypreal [simp]: "\<And>z. hIm (hcomplex_of_hypreal z) = 0"
   7.317 +  by transfer (rule Im_complex_of_real)
   7.318  
   7.319 -lemma hIm_hcomplex_of_hypreal [simp]: "!!z. hIm(hcomplex_of_hypreal z) = 0"
   7.320 -by transfer (rule Im_complex_of_real)
   7.321 +lemma hcomplex_of_hypreal_epsilon_not_zero [simp]: "hcomplex_of_hypreal \<epsilon> \<noteq> 0"
   7.322 +  by (simp add: hypreal_epsilon_not_zero)
   7.323  
   7.324 -lemma hcomplex_of_hypreal_epsilon_not_zero [simp]:
   7.325 -     "hcomplex_of_hypreal \<epsilon> \<noteq> 0"
   7.326 -by (simp add: hypreal_epsilon_not_zero)
   7.327 +
   7.328 +subsection \<open>\<open>HComplex\<close> theorems\<close>
   7.329  
   7.330 -subsection\<open>HComplex theorems\<close>
   7.331 +lemma hRe_HComplex [simp]: "\<And>x y. hRe (HComplex x y) = x"
   7.332 +  by transfer simp
   7.333  
   7.334 -lemma hRe_HComplex [simp]: "!!x y. hRe (HComplex x y) = x"
   7.335 -by transfer simp
   7.336 +lemma hIm_HComplex [simp]: "\<And>x y. hIm (HComplex x y) = y"
   7.337 +  by transfer simp
   7.338  
   7.339 -lemma hIm_HComplex [simp]: "!!x y. hIm (HComplex x y) = y"
   7.340 -by transfer simp
   7.341 -
   7.342 -lemma hcomplex_surj [simp]: "!!z. HComplex (hRe z) (hIm z) = z"
   7.343 -by transfer (rule complex_surj)
   7.344 +lemma hcomplex_surj [simp]: "\<And>z. HComplex (hRe z) (hIm z) = z"
   7.345 +  by transfer (rule complex_surj)
   7.346  
   7.347  lemma hcomplex_induct [case_names rect(*, induct type: hcomplex*)]:
   7.348 -     "(\<And>x y. P (HComplex x y)) ==> P z"
   7.349 -by (rule hcomplex_surj [THEN subst], blast)
   7.350 +  "(\<And>x y. P (HComplex x y)) \<Longrightarrow> P z"
   7.351 +  by (rule hcomplex_surj [THEN subst]) blast
   7.352  
   7.353  
   7.354 -subsection\<open>Modulus (Absolute Value) of Nonstandard Complex Number\<close>
   7.355 +subsection \<open>Modulus (Absolute Value) of Nonstandard Complex Number\<close>
   7.356  
   7.357  lemma hcomplex_of_hypreal_abs:
   7.358 -     "hcomplex_of_hypreal \<bar>x\<bar> =
   7.359 -      hcomplex_of_hypreal (hcmod (hcomplex_of_hypreal x))"
   7.360 -by simp
   7.361 +  "hcomplex_of_hypreal \<bar>x\<bar> = hcomplex_of_hypreal (hcmod (hcomplex_of_hypreal x))"
   7.362 +  by simp
   7.363  
   7.364 -lemma HComplex_inject [simp]:
   7.365 -  "!!x y x' y'. HComplex x y = HComplex x' y' = (x=x' & y=y')"
   7.366 -by transfer (rule complex.inject)
   7.367 +lemma HComplex_inject [simp]: "\<And>x y x' y'. HComplex x y = HComplex x' y' \<longleftrightarrow> x = x' \<and> y = y'"
   7.368 +  by transfer (rule complex.inject)
   7.369  
   7.370  lemma HComplex_add [simp]:
   7.371 -  "!!x1 y1 x2 y2. HComplex x1 y1 + HComplex x2 y2 = HComplex (x1+x2) (y1+y2)"
   7.372 -by transfer (rule complex_add)
   7.373 +  "\<And>x1 y1 x2 y2. HComplex x1 y1 + HComplex x2 y2 = HComplex (x1 + x2) (y1 + y2)"
   7.374 +  by transfer (rule complex_add)
   7.375  
   7.376 -lemma HComplex_minus [simp]: "!!x y. - HComplex x y = HComplex (-x) (-y)"
   7.377 -by transfer (rule complex_minus)
   7.378 +lemma HComplex_minus [simp]: "\<And>x y. - HComplex x y = HComplex (- x) (- y)"
   7.379 +  by transfer (rule complex_minus)
   7.380  
   7.381  lemma HComplex_diff [simp]:
   7.382 -  "!!x1 y1 x2 y2. HComplex x1 y1 - HComplex x2 y2 = HComplex (x1-x2) (y1-y2)"
   7.383 -by transfer (rule complex_diff)
   7.384 +  "\<And>x1 y1 x2 y2. HComplex x1 y1 - HComplex x2 y2 = HComplex (x1 - x2) (y1 - y2)"
   7.385 +  by transfer (rule complex_diff)
   7.386  
   7.387  lemma HComplex_mult [simp]:
   7.388 -  "!!x1 y1 x2 y2. HComplex x1 y1 * HComplex x2 y2 =
   7.389 -   HComplex (x1*x2 - y1*y2) (x1*y2 + y1*x2)"
   7.390 -by transfer (rule complex_mult)
   7.391 +  "\<And>x1 y1 x2 y2. HComplex x1 y1 * HComplex x2 y2 = HComplex (x1*x2 - y1*y2) (x1*y2 + y1*x2)"
   7.392 +  by transfer (rule complex_mult)
   7.393  
   7.394 -(*HComplex_inverse is proved below*)
   7.395 +text \<open>\<open>HComplex_inverse\<close> is proved below.\<close>
   7.396  
   7.397 -lemma hcomplex_of_hypreal_eq: "!!r. hcomplex_of_hypreal r = HComplex r 0"
   7.398 -by transfer (rule complex_of_real_def)
   7.399 +lemma hcomplex_of_hypreal_eq: "\<And>r. hcomplex_of_hypreal r = HComplex r 0"
   7.400 +  by transfer (rule complex_of_real_def)
   7.401  
   7.402  lemma HComplex_add_hcomplex_of_hypreal [simp]:
   7.403 -     "!!x y r. HComplex x y + hcomplex_of_hypreal r = HComplex (x+r) y"
   7.404 -by transfer (rule Complex_add_complex_of_real)
   7.405 +  "\<And>x y r. HComplex x y + hcomplex_of_hypreal r = HComplex (x + r) y"
   7.406 +  by transfer (rule Complex_add_complex_of_real)
   7.407  
   7.408  lemma hcomplex_of_hypreal_add_HComplex [simp]:
   7.409 -     "!!r x y. hcomplex_of_hypreal r + HComplex x y = HComplex (r+x) y"
   7.410 -by transfer (rule complex_of_real_add_Complex)
   7.411 +  "\<And>r x y. hcomplex_of_hypreal r + HComplex x y = HComplex (r + x) y"
   7.412 +  by transfer (rule complex_of_real_add_Complex)
   7.413  
   7.414  lemma HComplex_mult_hcomplex_of_hypreal:
   7.415 -     "!!x y r. HComplex x y * hcomplex_of_hypreal r = HComplex (x*r) (y*r)"
   7.416 -by transfer (rule Complex_mult_complex_of_real)
   7.417 +  "\<And>x y r. HComplex x y * hcomplex_of_hypreal r = HComplex (x * r) (y * r)"
   7.418 +  by transfer (rule Complex_mult_complex_of_real)
   7.419  
   7.420  lemma hcomplex_of_hypreal_mult_HComplex:
   7.421 -     "!!r x y. hcomplex_of_hypreal r * HComplex x y = HComplex (r*x) (r*y)"
   7.422 -by transfer (rule complex_of_real_mult_Complex)
   7.423 +  "\<And>r x y. hcomplex_of_hypreal r * HComplex x y = HComplex (r * x) (r * y)"
   7.424 +  by transfer (rule complex_of_real_mult_Complex)
   7.425  
   7.426 -lemma i_hcomplex_of_hypreal [simp]:
   7.427 -     "!!r. iii * hcomplex_of_hypreal r = HComplex 0 r"
   7.428 -by transfer (rule i_complex_of_real)
   7.429 +lemma i_hcomplex_of_hypreal [simp]: "\<And>r. iii * hcomplex_of_hypreal r = HComplex 0 r"
   7.430 +  by transfer (rule i_complex_of_real)
   7.431  
   7.432 -lemma hcomplex_of_hypreal_i [simp]:
   7.433 -     "!!r. hcomplex_of_hypreal r * iii = HComplex 0 r"
   7.434 -by transfer (rule complex_of_real_i)
   7.435 +lemma hcomplex_of_hypreal_i [simp]: "\<And>r. hcomplex_of_hypreal r * iii = HComplex 0 r"
   7.436 +  by transfer (rule complex_of_real_i)
   7.437  
   7.438  
   7.439 -subsection\<open>Conjugation\<close>
   7.440 +subsection \<open>Conjugation\<close>
   7.441  
   7.442 -lemma hcomplex_hcnj_cancel_iff [iff]: "!!x y. (hcnj x = hcnj y) = (x = y)"
   7.443 -by transfer (rule complex_cnj_cancel_iff)
   7.444 +lemma hcomplex_hcnj_cancel_iff [iff]: "\<And>x y. hcnj x = hcnj y \<longleftrightarrow> x = y"
   7.445 +  by transfer (rule complex_cnj_cancel_iff)
   7.446  
   7.447 -lemma hcomplex_hcnj_hcnj [simp]: "!!z. hcnj (hcnj z) = z"
   7.448 -by transfer (rule complex_cnj_cnj)
   7.449 +lemma hcomplex_hcnj_hcnj [simp]: "\<And>z. hcnj (hcnj z) = z"
   7.450 +  by transfer (rule complex_cnj_cnj)
   7.451  
   7.452  lemma hcomplex_hcnj_hcomplex_of_hypreal [simp]:
   7.453 -     "!!x. hcnj (hcomplex_of_hypreal x) = hcomplex_of_hypreal x"
   7.454 -by transfer (rule complex_cnj_complex_of_real)
   7.455 +  "\<And>x. hcnj (hcomplex_of_hypreal x) = hcomplex_of_hypreal x"
   7.456 +  by transfer (rule complex_cnj_complex_of_real)
   7.457  
   7.458 -lemma hcomplex_hmod_hcnj [simp]: "!!z. hcmod (hcnj z) = hcmod z"
   7.459 -by transfer (rule complex_mod_cnj)
   7.460 +lemma hcomplex_hmod_hcnj [simp]: "\<And>z. hcmod (hcnj z) = hcmod z"
   7.461 +  by transfer (rule complex_mod_cnj)
   7.462  
   7.463 -lemma hcomplex_hcnj_minus: "!!z. hcnj (-z) = - hcnj z"
   7.464 -by transfer (rule complex_cnj_minus)
   7.465 +lemma hcomplex_hcnj_minus: "\<And>z. hcnj (- z) = - hcnj z"
   7.466 +  by transfer (rule complex_cnj_minus)
   7.467  
   7.468 -lemma hcomplex_hcnj_inverse: "!!z. hcnj(inverse z) = inverse(hcnj z)"
   7.469 -by transfer (rule complex_cnj_inverse)
   7.470 +lemma hcomplex_hcnj_inverse: "\<And>z. hcnj (inverse z) = inverse (hcnj z)"
   7.471 +  by transfer (rule complex_cnj_inverse)
   7.472  
   7.473 -lemma hcomplex_hcnj_add: "!!w z. hcnj(w + z) = hcnj(w) + hcnj(z)"
   7.474 -by transfer (rule complex_cnj_add)
   7.475 +lemma hcomplex_hcnj_add: "\<And>w z. hcnj (w + z) = hcnj w + hcnj z"
   7.476 +  by transfer (rule complex_cnj_add)
   7.477  
   7.478 -lemma hcomplex_hcnj_diff: "!!w z. hcnj(w - z) = hcnj(w) - hcnj(z)"
   7.479 -by transfer (rule complex_cnj_diff)
   7.480 +lemma hcomplex_hcnj_diff: "\<And>w z. hcnj (w - z) = hcnj w - hcnj z"
   7.481 +  by transfer (rule complex_cnj_diff)
   7.482  
   7.483 -lemma hcomplex_hcnj_mult: "!!w z. hcnj(w * z) = hcnj(w) * hcnj(z)"
   7.484 -by transfer (rule complex_cnj_mult)
   7.485 +lemma hcomplex_hcnj_mult: "\<And>w z. hcnj (w * z) = hcnj w * hcnj z"
   7.486 +  by transfer (rule complex_cnj_mult)
   7.487  
   7.488 -lemma hcomplex_hcnj_divide: "!!w z. hcnj(w / z) = (hcnj w)/(hcnj z)"
   7.489 -by transfer (rule complex_cnj_divide)
   7.490 +lemma hcomplex_hcnj_divide: "\<And>w z. hcnj (w / z) = hcnj w / hcnj z"
   7.491 +  by transfer (rule complex_cnj_divide)
   7.492  
   7.493  lemma hcnj_one [simp]: "hcnj 1 = 1"
   7.494 -by transfer (rule complex_cnj_one)
   7.495 +  by transfer (rule complex_cnj_one)
   7.496  
   7.497  lemma hcomplex_hcnj_zero [simp]: "hcnj 0 = 0"
   7.498 -by transfer (rule complex_cnj_zero)
   7.499 -
   7.500 -lemma hcomplex_hcnj_zero_iff [iff]: "!!z. (hcnj z = 0) = (z = 0)"
   7.501 -by transfer (rule complex_cnj_zero_iff)
   7.502 -
   7.503 -lemma hcomplex_mult_hcnj:
   7.504 -     "!!z. z * hcnj z = hcomplex_of_hypreal ((hRe z)\<^sup>2 + (hIm z)\<^sup>2)"
   7.505 -by transfer (rule complex_mult_cnj)
   7.506 -
   7.507 -
   7.508 -subsection\<open>More Theorems about the Function @{term hcmod}\<close>
   7.509 +  by transfer (rule complex_cnj_zero)
   7.510  
   7.511 -lemma hcmod_hcomplex_of_hypreal_of_nat [simp]:
   7.512 -     "hcmod (hcomplex_of_hypreal(hypreal_of_nat n)) = hypreal_of_nat n"
   7.513 -by simp
   7.514 -
   7.515 -lemma hcmod_hcomplex_of_hypreal_of_hypnat [simp]:
   7.516 -     "hcmod (hcomplex_of_hypreal(hypreal_of_hypnat n)) = hypreal_of_hypnat n"
   7.517 -by simp
   7.518 +lemma hcomplex_hcnj_zero_iff [iff]: "\<And>z. hcnj z = 0 \<longleftrightarrow> z = 0"
   7.519 +  by transfer (rule complex_cnj_zero_iff)
   7.520  
   7.521 -lemma hcmod_mult_hcnj: "!!z. hcmod(z * hcnj(z)) = (hcmod z)\<^sup>2"
   7.522 -by transfer (rule complex_mod_mult_cnj)
   7.523 -
   7.524 -lemma hcmod_triangle_ineq2 [simp]:
   7.525 -  "!!a b. hcmod(b + a) - hcmod b \<le> hcmod a"
   7.526 -by transfer (rule complex_mod_triangle_ineq2)
   7.527 -
   7.528 -lemma hcmod_diff_ineq [simp]: "!!a b. hcmod(a) - hcmod(b) \<le> hcmod(a + b)"
   7.529 -by transfer (rule norm_diff_ineq)
   7.530 +lemma hcomplex_mult_hcnj: "\<And>z. z * hcnj z = hcomplex_of_hypreal ((hRe z)\<^sup>2 + (hIm z)\<^sup>2)"
   7.531 +  by transfer (rule complex_mult_cnj)
   7.532  
   7.533  
   7.534 -subsection\<open>Exponentiation\<close>
   7.535 +subsection \<open>More Theorems about the Function @{term hcmod}\<close>
   7.536 +
   7.537 +lemma hcmod_hcomplex_of_hypreal_of_nat [simp]:
   7.538 +  "hcmod (hcomplex_of_hypreal (hypreal_of_nat n)) = hypreal_of_nat n"
   7.539 +  by simp
   7.540 +
   7.541 +lemma hcmod_hcomplex_of_hypreal_of_hypnat [simp]:
   7.542 +  "hcmod (hcomplex_of_hypreal(hypreal_of_hypnat n)) = hypreal_of_hypnat n"
   7.543 +  by simp
   7.544 +
   7.545 +lemma hcmod_mult_hcnj: "\<And>z. hcmod (z * hcnj z) = (hcmod z)\<^sup>2"
   7.546 +  by transfer (rule complex_mod_mult_cnj)
   7.547  
   7.548 -lemma hcomplexpow_0 [simp]:   "z ^ 0       = (1::hcomplex)"
   7.549 -by (rule power_0)
   7.550 +lemma hcmod_triangle_ineq2 [simp]: "\<And>a b. hcmod (b + a) - hcmod b \<le> hcmod a"
   7.551 +  by transfer (rule complex_mod_triangle_ineq2)
   7.552 +
   7.553 +lemma hcmod_diff_ineq [simp]: "\<And>a b. hcmod a - hcmod b \<le> hcmod (a + b)"
   7.554 +  by transfer (rule norm_diff_ineq)
   7.555 +
   7.556  
   7.557 -lemma hcomplexpow_Suc [simp]: "z ^ (Suc n) = (z::hcomplex) * (z ^ n)"
   7.558 -by (rule power_Suc)
   7.559 +subsection \<open>Exponentiation\<close>
   7.560 +
   7.561 +lemma hcomplexpow_0 [simp]: "z ^ 0 = 1"
   7.562 +  for z :: hcomplex
   7.563 +  by (rule power_0)
   7.564 +
   7.565 +lemma hcomplexpow_Suc [simp]: "z ^ (Suc n) = z * (z ^ n)"
   7.566 +  for z :: hcomplex
   7.567 +  by (rule power_Suc)
   7.568  
   7.569  lemma hcomplexpow_i_squared [simp]: "iii\<^sup>2 = -1"
   7.570 -by transfer (rule power2_i)
   7.571 +  by transfer (rule power2_i)
   7.572  
   7.573 -lemma hcomplex_of_hypreal_pow:
   7.574 -     "!!x. hcomplex_of_hypreal (x ^ n) = (hcomplex_of_hypreal x) ^ n"
   7.575 -by transfer (rule of_real_power)
   7.576 +lemma hcomplex_of_hypreal_pow: "\<And>x. hcomplex_of_hypreal (x ^ n) = hcomplex_of_hypreal x ^ n"
   7.577 +  by transfer (rule of_real_power)
   7.578  
   7.579 -lemma hcomplex_hcnj_pow: "!!z. hcnj(z ^ n) = hcnj(z) ^ n"
   7.580 -by transfer (rule complex_cnj_power)
   7.581 +lemma hcomplex_hcnj_pow: "\<And>z. hcnj (z ^ n) = hcnj z ^ n"
   7.582 +  by transfer (rule complex_cnj_power)
   7.583  
   7.584 -lemma hcmod_hcomplexpow: "!!x. hcmod(x ^ n) = hcmod(x) ^ n"
   7.585 -by transfer (rule norm_power)
   7.586 +lemma hcmod_hcomplexpow: "\<And>x. hcmod (x ^ n) = hcmod x ^ n"
   7.587 +  by transfer (rule norm_power)
   7.588  
   7.589  lemma hcpow_minus:
   7.590 -     "!!x n. (-x::hcomplex) pow n =
   7.591 -      (if ( *p* even) n then (x pow n) else -(x pow n))"
   7.592 -by transfer simp
   7.593 +  "\<And>x n. (- x :: hcomplex) pow n = (if ( *p* even) n then (x pow n) else - (x pow n))"
   7.594 +  by transfer simp
   7.595  
   7.596 -lemma hcpow_mult:
   7.597 -  "((r::hcomplex) * s) pow n = (r pow n) * (s pow n)"
   7.598 +lemma hcpow_mult: "(r * s) pow n = (r pow n) * (s pow n)"
   7.599 +  for r s :: hcomplex
   7.600    by (fact hyperpow_mult)
   7.601  
   7.602 -lemma hcpow_zero2 [simp]:
   7.603 -  "\<And>n. 0 pow (hSuc n) = (0::'a::semiring_1 star)"
   7.604 +lemma hcpow_zero2 [simp]: "\<And>n. 0 pow (hSuc n) = (0::'a::semiring_1 star)"
   7.605    by transfer (rule power_0_Suc)
   7.606  
   7.607 -lemma hcpow_not_zero [simp,intro]:
   7.608 -  "!!r n. r \<noteq> 0 ==> r pow n \<noteq> (0::hcomplex)"
   7.609 +lemma hcpow_not_zero [simp,intro]: "\<And>r n. r \<noteq> 0 \<Longrightarrow> r pow n \<noteq> (0::hcomplex)"
   7.610    by (fact hyperpow_not_zero)
   7.611  
   7.612 -lemma hcpow_zero_zero:
   7.613 -  "r pow n = (0::hcomplex) ==> r = 0"
   7.614 +lemma hcpow_zero_zero: "r pow n = 0 \<Longrightarrow> r = 0"
   7.615 +  for r :: hcomplex
   7.616    by (blast intro: ccontr dest: hcpow_not_zero)
   7.617  
   7.618 -subsection\<open>The Function @{term hsgn}\<close>
   7.619 +
   7.620 +subsection \<open>The Function @{term hsgn}\<close>
   7.621  
   7.622  lemma hsgn_zero [simp]: "hsgn 0 = 0"
   7.623 -by transfer (rule sgn_zero)
   7.624 +  by transfer (rule sgn_zero)
   7.625  
   7.626  lemma hsgn_one [simp]: "hsgn 1 = 1"
   7.627 -by transfer (rule sgn_one)
   7.628 +  by transfer (rule sgn_one)
   7.629  
   7.630 -lemma hsgn_minus: "!!z. hsgn (-z) = - hsgn(z)"
   7.631 -by transfer (rule sgn_minus)
   7.632 +lemma hsgn_minus: "\<And>z. hsgn (- z) = - hsgn z"
   7.633 +  by transfer (rule sgn_minus)
   7.634  
   7.635 -lemma hsgn_eq: "!!z. hsgn z = z / hcomplex_of_hypreal (hcmod z)"
   7.636 -by transfer (rule sgn_eq)
   7.637 +lemma hsgn_eq: "\<And>z. hsgn z = z / hcomplex_of_hypreal (hcmod z)"
   7.638 +  by transfer (rule sgn_eq)
   7.639  
   7.640 -lemma hcmod_i: "!!x y. hcmod (HComplex x y) = ( *f* sqrt) (x\<^sup>2 + y\<^sup>2)"
   7.641 -by transfer (rule complex_norm)
   7.642 +lemma hcmod_i: "\<And>x y. hcmod (HComplex x y) = ( *f* sqrt) (x\<^sup>2 + y\<^sup>2)"
   7.643 +  by transfer (rule complex_norm)
   7.644  
   7.645  lemma hcomplex_eq_cancel_iff1 [simp]:
   7.646 -     "(hcomplex_of_hypreal xa = HComplex x y) = (xa = x & y = 0)"
   7.647 -by (simp add: hcomplex_of_hypreal_eq)
   7.648 +  "hcomplex_of_hypreal xa = HComplex x y \<longleftrightarrow> xa = x \<and> y = 0"
   7.649 +  by (simp add: hcomplex_of_hypreal_eq)
   7.650  
   7.651  lemma hcomplex_eq_cancel_iff2 [simp]:
   7.652 -     "(HComplex x y = hcomplex_of_hypreal xa) = (x = xa & y = 0)"
   7.653 -by (simp add: hcomplex_of_hypreal_eq)
   7.654 +  "HComplex x y = hcomplex_of_hypreal xa \<longleftrightarrow> x = xa \<and> y = 0"
   7.655 +  by (simp add: hcomplex_of_hypreal_eq)
   7.656  
   7.657 -lemma HComplex_eq_0 [simp]: "!!x y. (HComplex x y = 0) = (x = 0 & y = 0)"
   7.658 -by transfer (rule Complex_eq_0)
   7.659 +lemma HComplex_eq_0 [simp]: "\<And>x y. HComplex x y = 0 \<longleftrightarrow> x = 0 \<and> y = 0"
   7.660 +  by transfer (rule Complex_eq_0)
   7.661  
   7.662 -lemma HComplex_eq_1 [simp]: "!!x y. (HComplex x y = 1) = (x = 1 & y = 0)"
   7.663 -by transfer (rule Complex_eq_1)
   7.664 +lemma HComplex_eq_1 [simp]: "\<And>x y. HComplex x y = 1 \<longleftrightarrow> x = 1 \<and> y = 0"
   7.665 +  by transfer (rule Complex_eq_1)
   7.666  
   7.667  lemma i_eq_HComplex_0_1: "iii = HComplex 0 1"
   7.668 -by transfer (simp add: complex_eq_iff)
   7.669 +  by transfer (simp add: complex_eq_iff)
   7.670  
   7.671 -lemma HComplex_eq_i [simp]: "!!x y. (HComplex x y = iii) = (x = 0 & y = 1)"
   7.672 -by transfer (rule Complex_eq_i)
   7.673 -
   7.674 -lemma hRe_hsgn [simp]: "!!z. hRe(hsgn z) = hRe(z)/hcmod z"
   7.675 -by transfer (rule Re_sgn)
   7.676 +lemma HComplex_eq_i [simp]: "\<And>x y. HComplex x y = iii \<longleftrightarrow> x = 0 \<and> y = 1"
   7.677 +  by transfer (rule Complex_eq_i)
   7.678  
   7.679 -lemma hIm_hsgn [simp]: "!!z. hIm(hsgn z) = hIm(z)/hcmod z"
   7.680 -by transfer (rule Im_sgn)
   7.681 +lemma hRe_hsgn [simp]: "\<And>z. hRe (hsgn z) = hRe z / hcmod z"
   7.682 +  by transfer (rule Re_sgn)
   7.683  
   7.684 -lemma HComplex_inverse:
   7.685 -     "!!x y. inverse (HComplex x y) = HComplex (x/(x\<^sup>2 + y\<^sup>2)) (-y/(x\<^sup>2 + y\<^sup>2))"
   7.686 -by transfer (rule complex_inverse)
   7.687 -
   7.688 -lemma hRe_mult_i_eq[simp]:
   7.689 -    "!!y. hRe (iii * hcomplex_of_hypreal y) = 0"
   7.690 -by transfer simp
   7.691 +lemma hIm_hsgn [simp]: "\<And>z. hIm (hsgn z) = hIm z / hcmod z"
   7.692 +  by transfer (rule Im_sgn)
   7.693  
   7.694 -lemma hIm_mult_i_eq [simp]:
   7.695 -    "!!y. hIm (iii * hcomplex_of_hypreal y) = y"
   7.696 -by transfer simp
   7.697 +lemma HComplex_inverse: "\<And>x y. inverse (HComplex x y) = HComplex (x / (x\<^sup>2 + y\<^sup>2)) (- y / (x\<^sup>2 + y\<^sup>2))"
   7.698 +  by transfer (rule complex_inverse)
   7.699  
   7.700 -lemma hcmod_mult_i [simp]: "!!y. hcmod (iii * hcomplex_of_hypreal y) = \<bar>y\<bar>"
   7.701 -by transfer (simp add: norm_complex_def)
   7.702 -
   7.703 -lemma hcmod_mult_i2 [simp]: "!!y. hcmod (hcomplex_of_hypreal y * iii) = \<bar>y\<bar>"
   7.704 -by transfer (simp add: norm_complex_def)
   7.705 +lemma hRe_mult_i_eq[simp]: "\<And>y. hRe (iii * hcomplex_of_hypreal y) = 0"
   7.706 +  by transfer simp
   7.707  
   7.708 -(*---------------------------------------------------------------------------*)
   7.709 -(*  harg                                                                     *)
   7.710 -(*---------------------------------------------------------------------------*)
   7.711 +lemma hIm_mult_i_eq [simp]: "\<And>y. hIm (iii * hcomplex_of_hypreal y) = y"
   7.712 +  by transfer simp
   7.713  
   7.714 -lemma cos_harg_i_mult_zero [simp]:
   7.715 -     "!!y. y \<noteq> 0 ==> ( *f* cos) (harg(HComplex 0 y)) = 0"
   7.716 -by transfer simp
   7.717 +lemma hcmod_mult_i [simp]: "\<And>y. hcmod (iii * hcomplex_of_hypreal y) = \<bar>y\<bar>"
   7.718 +  by transfer (simp add: norm_complex_def)
   7.719  
   7.720 -lemma hcomplex_of_hypreal_zero_iff [simp]:
   7.721 -     "!!y. (hcomplex_of_hypreal y = 0) = (y = 0)"
   7.722 -by transfer (rule of_real_eq_0_iff)
   7.723 +lemma hcmod_mult_i2 [simp]: "\<And>y. hcmod (hcomplex_of_hypreal y * iii) = \<bar>y\<bar>"
   7.724 +  by transfer (simp add: norm_complex_def)
   7.725  
   7.726  
   7.727 -subsection\<open>Polar Form for Nonstandard Complex Numbers\<close>
   7.728 +subsubsection \<open>\<open>harg\<close>\<close>
   7.729 +
   7.730 +lemma cos_harg_i_mult_zero [simp]: "\<And>y. y \<noteq> 0 \<Longrightarrow> ( *f* cos) (harg (HComplex 0 y)) = 0"
   7.731 +  by transfer simp
   7.732  
   7.733 -lemma complex_split_polar2:
   7.734 -     "\<forall>n. \<exists>r a. (z n) =  complex_of_real r * (Complex (cos a) (sin a))"
   7.735 -by (auto intro: complex_split_polar)
   7.736 +lemma hcomplex_of_hypreal_zero_iff [simp]: "\<And>y. hcomplex_of_hypreal y = 0 \<longleftrightarrow> y = 0"
   7.737 +  by transfer (rule of_real_eq_0_iff)
   7.738 +
   7.739 +
   7.740 +subsection \<open>Polar Form for Nonstandard Complex Numbers\<close>
   7.741 +
   7.742 +lemma complex_split_polar2: "\<forall>n. \<exists>r a. (z n) = complex_of_real r * Complex (cos a) (sin a)"
   7.743 +  by (auto intro: complex_split_polar)
   7.744  
   7.745  lemma hcomplex_split_polar:
   7.746 -  "!!z. \<exists>r a. z = hcomplex_of_hypreal r * (HComplex(( *f* cos) a)(( *f* sin) a))"
   7.747 -by transfer (simp add: complex_split_polar)
   7.748 +  "\<And>z. \<exists>r a. z = hcomplex_of_hypreal r * (HComplex (( *f* cos) a) (( *f* sin) a))"
   7.749 +  by transfer (simp add: complex_split_polar)
   7.750  
   7.751  lemma hcis_eq:
   7.752 -   "!!a. hcis a =
   7.753 -    (hcomplex_of_hypreal(( *f* cos) a) +
   7.754 -    iii * hcomplex_of_hypreal(( *f* sin) a))"
   7.755 -by transfer (simp add: complex_eq_iff)
   7.756 +  "\<And>a. hcis a = hcomplex_of_hypreal (( *f* cos) a) + iii * hcomplex_of_hypreal (( *f* sin) a)"
   7.757 +  by transfer (simp add: complex_eq_iff)
   7.758  
   7.759 -lemma hrcis_Ex: "!!z. \<exists>r a. z = hrcis r a"
   7.760 -by transfer (rule rcis_Ex)
   7.761 +lemma hrcis_Ex: "\<And>z. \<exists>r a. z = hrcis r a"
   7.762 +  by transfer (rule rcis_Ex)
   7.763  
   7.764  lemma hRe_hcomplex_polar [simp]:
   7.765 -  "!!r a. hRe (hcomplex_of_hypreal r * HComplex (( *f* cos) a) (( *f* sin) a)) =
   7.766 -      r * ( *f* cos) a"
   7.767 -by transfer simp
   7.768 +  "\<And>r a. hRe (hcomplex_of_hypreal r * HComplex (( *f* cos) a) (( *f* sin) a)) = r * ( *f* cos) a"
   7.769 +  by transfer simp
   7.770  
   7.771 -lemma hRe_hrcis [simp]: "!!r a. hRe(hrcis r a) = r * ( *f* cos) a"
   7.772 -by transfer (rule Re_rcis)
   7.773 +lemma hRe_hrcis [simp]: "\<And>r a. hRe (hrcis r a) = r * ( *f* cos) a"
   7.774 +  by transfer (rule Re_rcis)
   7.775  
   7.776  lemma hIm_hcomplex_polar [simp]:
   7.777 -  "!!r a. hIm (hcomplex_of_hypreal r * HComplex (( *f* cos) a) (( *f* sin) a)) =
   7.778 -      r * ( *f* sin) a"
   7.779 -by transfer simp
   7.780 +  "\<And>r a. hIm (hcomplex_of_hypreal r * HComplex (( *f* cos) a) (( *f* sin) a)) = r * ( *f* sin) a"
   7.781 +  by transfer simp
   7.782  
   7.783 -lemma hIm_hrcis [simp]: "!!r a. hIm(hrcis r a) = r * ( *f* sin) a"
   7.784 -by transfer (rule Im_rcis)
   7.785 +lemma hIm_hrcis [simp]: "\<And>r a. hIm (hrcis r a) = r * ( *f* sin) a"
   7.786 +  by transfer (rule Im_rcis)
   7.787  
   7.788 -lemma hcmod_unit_one [simp]:
   7.789 -     "!!a. hcmod (HComplex (( *f* cos) a) (( *f* sin) a)) = 1"
   7.790 -by transfer (simp add: cmod_unit_one)
   7.791 +lemma hcmod_unit_one [simp]: "\<And>a. hcmod (HComplex (( *f* cos) a) (( *f* sin) a)) = 1"
   7.792 +  by transfer (simp add: cmod_unit_one)
   7.793  
   7.794  lemma hcmod_complex_polar [simp]:
   7.795 -  "!!r a. hcmod (hcomplex_of_hypreal r * HComplex (( *f* cos) a) (( *f* sin) a)) = \<bar>r\<bar>"
   7.796 -by transfer (simp add: cmod_complex_polar)
   7.797 -
   7.798 -lemma hcmod_hrcis [simp]: "!!r a. hcmod(hrcis r a) = \<bar>r\<bar>"
   7.799 -by transfer (rule complex_mod_rcis)
   7.800 +  "\<And>r a. hcmod (hcomplex_of_hypreal r * HComplex (( *f* cos) a) (( *f* sin) a)) = \<bar>r\<bar>"
   7.801 +  by transfer (simp add: cmod_complex_polar)
   7.802  
   7.803 -(*---------------------------------------------------------------------------*)
   7.804 -(*  (r1 * hrcis a) * (r2 * hrcis b) = r1 * r2 * hrcis (a + b)                *)
   7.805 -(*---------------------------------------------------------------------------*)
   7.806 +lemma hcmod_hrcis [simp]: "\<And>r a. hcmod(hrcis r a) = \<bar>r\<bar>"
   7.807 +  by transfer (rule complex_mod_rcis)
   7.808  
   7.809 -lemma hcis_hrcis_eq: "!!a. hcis a = hrcis 1 a"
   7.810 -by transfer (rule cis_rcis_eq)
   7.811 +text \<open>\<open>(r1 * hrcis a) * (r2 * hrcis b) = r1 * r2 * hrcis (a + b)\<close>\<close>
   7.812 +
   7.813 +lemma hcis_hrcis_eq: "\<And>a. hcis a = hrcis 1 a"
   7.814 +  by transfer (rule cis_rcis_eq)
   7.815  declare hcis_hrcis_eq [symmetric, simp]
   7.816  
   7.817 -lemma hrcis_mult:
   7.818 -  "!!a b r1 r2. hrcis r1 a * hrcis r2 b = hrcis (r1*r2) (a + b)"
   7.819 -by transfer (rule rcis_mult)
   7.820 +lemma hrcis_mult: "\<And>a b r1 r2. hrcis r1 a * hrcis r2 b = hrcis (r1 * r2) (a + b)"
   7.821 +  by transfer (rule rcis_mult)
   7.822  
   7.823 -lemma hcis_mult: "!!a b. hcis a * hcis b = hcis (a + b)"
   7.824 -by transfer (rule cis_mult)
   7.825 +lemma hcis_mult: "\<And>a b. hcis a * hcis b = hcis (a + b)"
   7.826 +  by transfer (rule cis_mult)
   7.827  
   7.828  lemma hcis_zero [simp]: "hcis 0 = 1"
   7.829 -by transfer (rule cis_zero)
   7.830 +  by transfer (rule cis_zero)
   7.