| author | wenzelm | 
| Fri, 24 Nov 2023 11:10:31 +0100 | |
| changeset 79045 | 24d04dd5bf01 | 
| parent 78099 | 4d9349989d94 | 
| child 80914 | d97fdabd9e2b | 
| permissions | -rw-r--r-- | 
| 62479 | 1  | 
(* Title: HOL/Nonstandard_Analysis/NSA.thy  | 
| 
32960
 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 
wenzelm 
parents: 
32155 
diff
changeset
 | 
2  | 
Author: Jacques D. Fleuriot, University of Cambridge  | 
| 
 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 
wenzelm 
parents: 
32155 
diff
changeset
 | 
3  | 
Author: Lawrence C Paulson, University of Cambridge  | 
| 27468 | 4  | 
*)  | 
5  | 
||
| 64435 | 6  | 
section \<open>Infinite Numbers, Infinitesimals, Infinitely Close Relation\<close>  | 
| 27468 | 7  | 
|
8  | 
theory NSA  | 
|
| 70221 | 9  | 
imports HyperDef "HOL-Library.Lub_Glb"  | 
| 27468 | 10  | 
begin  | 
11  | 
||
| 64435 | 12  | 
definition hnorm :: "'a::real_normed_vector star \<Rightarrow> real star"  | 
13  | 
where [transfer_unfold]: "hnorm = *f* norm"  | 
|
| 27468 | 14  | 
|
| 64435 | 15  | 
definition Infinitesimal  :: "('a::real_normed_vector) star set"
 | 
16  | 
  where "Infinitesimal = {x. \<forall>r \<in> Reals. 0 < r \<longrightarrow> hnorm x < r}"
 | 
|
| 27468 | 17  | 
|
| 64435 | 18  | 
definition HFinite :: "('a::real_normed_vector) star set"
 | 
19  | 
  where "HFinite = {x. \<exists>r \<in> Reals. hnorm x < r}"
 | 
|
| 27468 | 20  | 
|
| 64435 | 21  | 
definition HInfinite :: "('a::real_normed_vector) star set"
 | 
22  | 
  where "HInfinite = {x. \<forall>r \<in> Reals. r < hnorm x}"
 | 
|
| 27468 | 23  | 
|
| 64435 | 24  | 
definition approx :: "'a::real_normed_vector star \<Rightarrow> 'a star \<Rightarrow> bool" (infixl "\<approx>" 50)  | 
25  | 
where "x \<approx> y \<longleftrightarrow> x - y \<in> Infinitesimal"  | 
|
26  | 
\<comment> \<open>the ``infinitely close'' relation\<close>  | 
|
| 27468 | 27  | 
|
| 64435 | 28  | 
definition st :: "hypreal \<Rightarrow> hypreal"  | 
29  | 
where "st = (\<lambda>x. SOME r. x \<in> HFinite \<and> r \<in> \<real> \<and> r \<approx> x)"  | 
|
30  | 
\<comment> \<open>the standard part of a hyperreal\<close>  | 
|
| 27468 | 31  | 
|
| 64435 | 32  | 
definition monad :: "'a::real_normed_vector star \<Rightarrow> 'a star set"  | 
33  | 
  where "monad x = {y. x \<approx> y}"
 | 
|
| 27468 | 34  | 
|
| 64435 | 35  | 
definition galaxy :: "'a::real_normed_vector star \<Rightarrow> 'a star set"  | 
36  | 
  where "galaxy x = {y. (x + -y) \<in> HFinite}"
 | 
|
| 27468 | 37  | 
|
| 64435 | 38  | 
lemma SReal_def: "\<real> \<equiv> {x. \<exists>r. x = hypreal_of_real r}"
 | 
39  | 
by (simp add: Reals_def image_def)  | 
|
40  | 
||
| 27468 | 41  | 
|
| 61975 | 42  | 
subsection \<open>Nonstandard Extension of the Norm Function\<close>  | 
| 27468 | 43  | 
|
| 64435 | 44  | 
definition scaleHR :: "real star \<Rightarrow> 'a star \<Rightarrow> 'a::real_normed_vector star"  | 
45  | 
where [transfer_unfold]: "scaleHR = starfun2 scaleR"  | 
|
| 27468 | 46  | 
|
47  | 
lemma Standard_hnorm [simp]: "x \<in> Standard \<Longrightarrow> hnorm x \<in> Standard"  | 
|
| 64435 | 48  | 
by (simp add: hnorm_def)  | 
| 27468 | 49  | 
|
50  | 
lemma star_of_norm [simp]: "star_of (norm x) = hnorm (star_of x)"  | 
|
| 64435 | 51  | 
by transfer (rule refl)  | 
| 27468 | 52  | 
|
| 64435 | 53  | 
lemma hnorm_ge_zero [simp]: "\<And>x::'a::real_normed_vector star. 0 \<le> hnorm x"  | 
54  | 
by transfer (rule norm_ge_zero)  | 
|
| 27468 | 55  | 
|
| 64435 | 56  | 
lemma hnorm_eq_zero [simp]: "\<And>x::'a::real_normed_vector star. hnorm x = 0 \<longleftrightarrow> x = 0"  | 
57  | 
by transfer (rule norm_eq_zero)  | 
|
| 27468 | 58  | 
|
| 64435 | 59  | 
lemma hnorm_triangle_ineq: "\<And>x y::'a::real_normed_vector star. hnorm (x + y) \<le> hnorm x + hnorm y"  | 
60  | 
by transfer (rule norm_triangle_ineq)  | 
|
| 27468 | 61  | 
|
| 64435 | 62  | 
lemma hnorm_triangle_ineq3: "\<And>x y::'a::real_normed_vector star. \<bar>hnorm x - hnorm y\<bar> \<le> hnorm (x - y)"  | 
63  | 
by transfer (rule norm_triangle_ineq3)  | 
|
64  | 
||
65  | 
lemma hnorm_scaleR: "\<And>x::'a::real_normed_vector star. hnorm (a *\<^sub>R x) = \<bar>star_of a\<bar> * hnorm x"  | 
|
66  | 
by transfer (rule norm_scaleR)  | 
|
| 27468 | 67  | 
|
| 64435 | 68  | 
lemma hnorm_scaleHR: "\<And>a (x::'a::real_normed_vector star). hnorm (scaleHR a x) = \<bar>a\<bar> * hnorm x"  | 
69  | 
by transfer (rule norm_scaleR)  | 
|
| 27468 | 70  | 
|
| 64435 | 71  | 
lemma hnorm_mult_ineq: "\<And>x y::'a::real_normed_algebra star. hnorm (x * y) \<le> hnorm x * hnorm y"  | 
72  | 
by transfer (rule norm_mult_ineq)  | 
|
| 27468 | 73  | 
|
| 64435 | 74  | 
lemma hnorm_mult: "\<And>x y::'a::real_normed_div_algebra star. hnorm (x * y) = hnorm x * hnorm y"  | 
75  | 
by transfer (rule norm_mult)  | 
|
| 27468 | 76  | 
|
| 64435 | 77  | 
lemma hnorm_hyperpow: "\<And>(x::'a::{real_normed_div_algebra} star) n. hnorm (x pow n) = hnorm x pow n"
 | 
78  | 
by transfer (rule norm_power)  | 
|
79  | 
||
80  | 
lemma hnorm_one [simp]: "hnorm (1::'a::real_normed_div_algebra star) = 1"  | 
|
81  | 
by transfer (rule norm_one)  | 
|
| 27468 | 82  | 
|
| 64435 | 83  | 
lemma hnorm_zero [simp]: "hnorm (0::'a::real_normed_vector star) = 0"  | 
84  | 
by transfer (rule norm_zero)  | 
|
| 27468 | 85  | 
|
| 64435 | 86  | 
lemma zero_less_hnorm_iff [simp]: "\<And>x::'a::real_normed_vector star. 0 < hnorm x \<longleftrightarrow> x \<noteq> 0"  | 
87  | 
by transfer (rule zero_less_norm_iff)  | 
|
| 27468 | 88  | 
|
| 64435 | 89  | 
lemma hnorm_minus_cancel [simp]: "\<And>x::'a::real_normed_vector star. hnorm (- x) = hnorm x"  | 
90  | 
by transfer (rule norm_minus_cancel)  | 
|
| 27468 | 91  | 
|
| 64435 | 92  | 
lemma hnorm_minus_commute: "\<And>a b::'a::real_normed_vector star. hnorm (a - b) = hnorm (b - a)"  | 
93  | 
by transfer (rule norm_minus_commute)  | 
|
| 27468 | 94  | 
|
| 64435 | 95  | 
lemma hnorm_triangle_ineq2: "\<And>a b::'a::real_normed_vector star. hnorm a - hnorm b \<le> hnorm (a - b)"  | 
96  | 
by transfer (rule norm_triangle_ineq2)  | 
|
| 27468 | 97  | 
|
| 64435 | 98  | 
lemma hnorm_triangle_ineq4: "\<And>a b::'a::real_normed_vector star. hnorm (a - b) \<le> hnorm a + hnorm b"  | 
99  | 
by transfer (rule norm_triangle_ineq4)  | 
|
| 27468 | 100  | 
|
| 64435 | 101  | 
lemma abs_hnorm_cancel [simp]: "\<And>a::'a::real_normed_vector star. \<bar>hnorm a\<bar> = hnorm a"  | 
102  | 
by transfer (rule abs_norm_cancel)  | 
|
| 27468 | 103  | 
|
| 64435 | 104  | 
lemma hnorm_of_hypreal [simp]: "\<And>r. hnorm (of_hypreal r::'a::real_normed_algebra_1 star) = \<bar>r\<bar>"  | 
105  | 
by transfer (rule norm_of_real)  | 
|
| 27468 | 106  | 
|
107  | 
lemma nonzero_hnorm_inverse:  | 
|
| 64435 | 108  | 
"\<And>a::'a::real_normed_div_algebra star. a \<noteq> 0 \<Longrightarrow> hnorm (inverse a) = inverse (hnorm a)"  | 
109  | 
by transfer (rule nonzero_norm_inverse)  | 
|
| 27468 | 110  | 
|
111  | 
lemma hnorm_inverse:  | 
|
| 64435 | 112  | 
  "\<And>a::'a::{real_normed_div_algebra, division_ring} star. hnorm (inverse a) = inverse (hnorm a)"
 | 
113  | 
by transfer (rule norm_inverse)  | 
|
| 27468 | 114  | 
|
| 64435 | 115  | 
lemma hnorm_divide: "\<And>a b::'a::{real_normed_field, field} star. hnorm (a / b) = hnorm a / hnorm b"
 | 
116  | 
by transfer (rule norm_divide)  | 
|
| 27468 | 117  | 
|
| 64435 | 118  | 
lemma hypreal_hnorm_def [simp]: "\<And>r::hypreal. hnorm r = \<bar>r\<bar>"  | 
119  | 
by transfer (rule real_norm_def)  | 
|
| 27468 | 120  | 
|
121  | 
lemma hnorm_add_less:  | 
|
| 64435 | 122  | 
"\<And>(x::'a::real_normed_vector star) y r s. hnorm x < r \<Longrightarrow> hnorm y < s \<Longrightarrow> hnorm (x + y) < r + s"  | 
123  | 
by transfer (rule norm_add_less)  | 
|
| 27468 | 124  | 
|
125  | 
lemma hnorm_mult_less:  | 
|
| 64435 | 126  | 
"\<And>(x::'a::real_normed_algebra star) y r s. hnorm x < r \<Longrightarrow> hnorm y < s \<Longrightarrow> hnorm (x * y) < r * s"  | 
127  | 
by transfer (rule norm_mult_less)  | 
|
| 27468 | 128  | 
|
| 64435 | 129  | 
lemma hnorm_scaleHR_less: "\<bar>x\<bar> < r \<Longrightarrow> hnorm y < s \<Longrightarrow> hnorm (scaleHR x y) < r * s"  | 
130  | 
by (simp only: hnorm_scaleHR) (simp add: mult_strict_mono')  | 
|
131  | 
||
132  | 
||
133  | 
subsection \<open>Closure Laws for the Standard Reals\<close>  | 
|
| 27468 | 134  | 
|
| 64435 | 135  | 
lemma Reals_add_cancel: "x + y \<in> \<real> \<Longrightarrow> y \<in> \<real> \<Longrightarrow> x \<in> \<real>"  | 
136  | 
by (drule (1) Reals_diff) simp  | 
|
| 27468 | 137  | 
|
| 64435 | 138  | 
lemma SReal_hrabs: "x \<in> \<real> \<Longrightarrow> \<bar>x\<bar> \<in> \<real>"  | 
139  | 
for x :: hypreal  | 
|
140  | 
by (simp add: Reals_eq_Standard)  | 
|
| 27468 | 141  | 
|
| 61070 | 142  | 
lemma SReal_hypreal_of_real [simp]: "hypreal_of_real x \<in> \<real>"  | 
| 64435 | 143  | 
by (simp add: Reals_eq_Standard)  | 
| 27468 | 144  | 
|
| 64435 | 145  | 
lemma SReal_divide_numeral: "r \<in> \<real> \<Longrightarrow> r / (numeral w::hypreal) \<in> \<real>"  | 
146  | 
by simp  | 
|
| 27468 | 147  | 
|
| 61981 | 148  | 
text \<open>\<open>\<epsilon>\<close> is not in Reals because it is an infinitesimal\<close>  | 
149  | 
lemma SReal_epsilon_not_mem: "\<epsilon> \<notin> \<real>"  | 
|
| 64435 | 150  | 
by (auto simp: SReal_def hypreal_of_real_not_eq_epsilon [symmetric])  | 
| 27468 | 151  | 
|
| 61981 | 152  | 
lemma SReal_omega_not_mem: "\<omega> \<notin> \<real>"  | 
| 64435 | 153  | 
by (auto simp: SReal_def hypreal_of_real_not_eq_omega [symmetric])  | 
| 27468 | 154  | 
|
| 61070 | 155  | 
lemma SReal_UNIV_real: "{x. hypreal_of_real x \<in> \<real>} = (UNIV::real set)"
 | 
| 64435 | 156  | 
by simp  | 
| 27468 | 157  | 
|
| 64435 | 158  | 
lemma SReal_iff: "x \<in> \<real> \<longleftrightarrow> (\<exists>y. x = hypreal_of_real y)"  | 
159  | 
by (simp add: SReal_def)  | 
|
| 27468 | 160  | 
|
| 61070 | 161  | 
lemma hypreal_of_real_image: "hypreal_of_real `(UNIV::real set) = \<real>"  | 
| 64435 | 162  | 
by (simp add: Reals_eq_Standard Standard_def)  | 
| 27468 | 163  | 
|
| 61070 | 164  | 
lemma inv_hypreal_of_real_image: "inv hypreal_of_real ` \<real> = UNIV"  | 
| 70221 | 165  | 
by (simp add: Reals_eq_Standard Standard_def inj_star_of)  | 
| 27468 | 166  | 
|
| 64435 | 167  | 
lemma SReal_dense: "x \<in> \<real> \<Longrightarrow> y \<in> \<real> \<Longrightarrow> x < y \<Longrightarrow> \<exists>r \<in> Reals. x < r \<and> r < y"  | 
168  | 
for x y :: hypreal  | 
|
| 70221 | 169  | 
using dense by (fastforce simp add: SReal_def)  | 
| 27468 | 170  | 
|
171  | 
||
| 64435 | 172  | 
subsection \<open>Set of Finite Elements is a Subring of the Extended Reals\<close>  | 
| 27468 | 173  | 
|
| 64435 | 174  | 
lemma HFinite_add: "x \<in> HFinite \<Longrightarrow> y \<in> HFinite \<Longrightarrow> x + y \<in> HFinite"  | 
175  | 
unfolding HFinite_def by (blast intro!: Reals_add hnorm_add_less)  | 
|
| 27468 | 176  | 
|
| 64435 | 177  | 
lemma HFinite_mult: "x \<in> HFinite \<Longrightarrow> y \<in> HFinite \<Longrightarrow> x * y \<in> HFinite"  | 
178  | 
for x y :: "'a::real_normed_algebra star"  | 
|
179  | 
unfolding HFinite_def by (blast intro!: Reals_mult hnorm_mult_less)  | 
|
| 27468 | 180  | 
|
| 64435 | 181  | 
lemma HFinite_scaleHR: "x \<in> HFinite \<Longrightarrow> y \<in> HFinite \<Longrightarrow> scaleHR x y \<in> HFinite"  | 
182  | 
by (auto simp: HFinite_def intro!: Reals_mult hnorm_scaleHR_less)  | 
|
| 27468 | 183  | 
|
| 64435 | 184  | 
lemma HFinite_minus_iff: "- x \<in> HFinite \<longleftrightarrow> x \<in> HFinite"  | 
185  | 
by (simp add: HFinite_def)  | 
|
| 27468 | 186  | 
|
187  | 
lemma HFinite_star_of [simp]: "star_of x \<in> HFinite"  | 
|
| 70221 | 188  | 
by (simp add: HFinite_def) (metis SReal_hypreal_of_real gt_ex star_of_less star_of_norm)  | 
| 27468 | 189  | 
|
| 61070 | 190  | 
lemma SReal_subset_HFinite: "(\<real>::hypreal set) \<subseteq> HFinite"  | 
| 64435 | 191  | 
by (auto simp add: SReal_def)  | 
| 27468 | 192  | 
|
| 64435 | 193  | 
lemma HFiniteD: "x \<in> HFinite \<Longrightarrow> \<exists>t \<in> Reals. hnorm x < t"  | 
194  | 
by (simp add: HFinite_def)  | 
|
| 27468 | 195  | 
|
| 64435 | 196  | 
lemma HFinite_hrabs_iff [iff]: "\<bar>x\<bar> \<in> HFinite \<longleftrightarrow> x \<in> HFinite"  | 
197  | 
for x :: hypreal  | 
|
198  | 
by (simp add: HFinite_def)  | 
|
| 27468 | 199  | 
|
| 64435 | 200  | 
lemma HFinite_hnorm_iff [iff]: "hnorm x \<in> HFinite \<longleftrightarrow> x \<in> HFinite"  | 
201  | 
for x :: hypreal  | 
|
202  | 
by (simp add: HFinite_def)  | 
|
| 27468 | 203  | 
|
| 
47108
 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
 
huffman 
parents: 
45541 
diff
changeset
 | 
204  | 
lemma HFinite_numeral [simp]: "numeral w \<in> HFinite"  | 
| 64435 | 205  | 
unfolding star_numeral_def by (rule HFinite_star_of)  | 
| 27468 | 206  | 
|
| 64435 | 207  | 
text \<open>As always with numerals, \<open>0\<close> and \<open>1\<close> are special cases.\<close>  | 
| 27468 | 208  | 
|
209  | 
lemma HFinite_0 [simp]: "0 \<in> HFinite"  | 
|
| 64435 | 210  | 
unfolding star_zero_def by (rule HFinite_star_of)  | 
| 27468 | 211  | 
|
212  | 
lemma HFinite_1 [simp]: "1 \<in> HFinite"  | 
|
| 64435 | 213  | 
unfolding star_one_def by (rule HFinite_star_of)  | 
| 27468 | 214  | 
|
| 64435 | 215  | 
lemma hrealpow_HFinite: "x \<in> HFinite \<Longrightarrow> x ^ n \<in> HFinite"  | 
216  | 
  for x :: "'a::{real_normed_algebra,monoid_mult} star"
 | 
|
| 70221 | 217  | 
by (induct n) (auto intro: HFinite_mult)  | 
| 27468 | 218  | 
|
| 70221 | 219  | 
lemma HFinite_bounded:  | 
220  | 
fixes x y :: hypreal  | 
|
221  | 
assumes "x \<in> HFinite" and y: "y \<le> x" "0 \<le> y" shows "y \<in> HFinite"  | 
|
222  | 
proof (cases "x \<le> 0")  | 
|
223  | 
case True  | 
|
224  | 
then have "y = 0"  | 
|
225  | 
using y by auto  | 
|
226  | 
then show ?thesis  | 
|
227  | 
by simp  | 
|
228  | 
next  | 
|
229  | 
case False  | 
|
230  | 
then show ?thesis  | 
|
231  | 
using assms le_less_trans by (auto simp: HFinite_def)  | 
|
232  | 
qed  | 
|
| 27468 | 233  | 
|
234  | 
||
| 64435 | 235  | 
subsection \<open>Set of Infinitesimals is a Subring of the Hyperreals\<close>  | 
| 27468 | 236  | 
|
| 64435 | 237  | 
lemma InfinitesimalI: "(\<And>r. r \<in> \<real> \<Longrightarrow> 0 < r \<Longrightarrow> hnorm x < r) \<Longrightarrow> x \<in> Infinitesimal"  | 
238  | 
by (simp add: Infinitesimal_def)  | 
|
| 27468 | 239  | 
|
| 64435 | 240  | 
lemma InfinitesimalD: "x \<in> Infinitesimal \<Longrightarrow> \<forall>r \<in> Reals. 0 < r \<longrightarrow> hnorm x < r"  | 
241  | 
by (simp add: Infinitesimal_def)  | 
|
| 27468 | 242  | 
|
| 64435 | 243  | 
lemma InfinitesimalI2: "(\<And>r. 0 < r \<Longrightarrow> hnorm x < star_of r) \<Longrightarrow> x \<in> Infinitesimal"  | 
244  | 
by (auto simp add: Infinitesimal_def SReal_def)  | 
|
| 27468 | 245  | 
|
| 64435 | 246  | 
lemma InfinitesimalD2: "x \<in> Infinitesimal \<Longrightarrow> 0 < r \<Longrightarrow> hnorm x < star_of r"  | 
247  | 
by (auto simp add: Infinitesimal_def SReal_def)  | 
|
| 27468 | 248  | 
|
249  | 
lemma Infinitesimal_zero [iff]: "0 \<in> Infinitesimal"  | 
|
| 64435 | 250  | 
by (simp add: Infinitesimal_def)  | 
| 27468 | 251  | 
|
| 70221 | 252  | 
lemma Infinitesimal_add:  | 
253  | 
assumes "x \<in> Infinitesimal" "y \<in> Infinitesimal"  | 
|
254  | 
shows "x + y \<in> Infinitesimal"  | 
|
255  | 
proof (rule InfinitesimalI)  | 
|
256  | 
show "hnorm (x + y) < r"  | 
|
257  | 
if "r \<in> \<real>" and "0 < r" for r :: "real star"  | 
|
258  | 
proof -  | 
|
259  | 
have "hnorm x < r/2" "hnorm y < r/2"  | 
|
260  | 
using InfinitesimalD SReal_divide_numeral assms half_gt_zero that by blast+  | 
|
261  | 
then show ?thesis  | 
|
262  | 
using hnorm_add_less by fastforce  | 
|
263  | 
qed  | 
|
264  | 
qed  | 
|
| 27468 | 265  | 
|
| 64435 | 266  | 
lemma Infinitesimal_minus_iff [simp]: "- x \<in> Infinitesimal \<longleftrightarrow> x \<in> Infinitesimal"  | 
267  | 
by (simp add: Infinitesimal_def)  | 
|
| 27468 | 268  | 
|
| 64435 | 269  | 
lemma Infinitesimal_hnorm_iff: "hnorm x \<in> Infinitesimal \<longleftrightarrow> x \<in> Infinitesimal"  | 
270  | 
by (simp add: Infinitesimal_def)  | 
|
| 27468 | 271  | 
|
| 64435 | 272  | 
lemma Infinitesimal_hrabs_iff [iff]: "\<bar>x\<bar> \<in> Infinitesimal \<longleftrightarrow> x \<in> Infinitesimal"  | 
273  | 
for x :: hypreal  | 
|
274  | 
by (simp add: abs_if)  | 
|
| 27468 | 275  | 
|
276  | 
lemma Infinitesimal_of_hypreal_iff [simp]:  | 
|
| 64435 | 277  | 
"(of_hypreal x::'a::real_normed_algebra_1 star) \<in> Infinitesimal \<longleftrightarrow> x \<in> Infinitesimal"  | 
278  | 
by (subst Infinitesimal_hnorm_iff [symmetric]) simp  | 
|
| 27468 | 279  | 
|
| 64435 | 280  | 
lemma Infinitesimal_diff: "x \<in> Infinitesimal \<Longrightarrow> y \<in> Infinitesimal \<Longrightarrow> x - y \<in> Infinitesimal"  | 
| 
54230
 
b1d955791529
more simplification rules on unary and binary minus
 
haftmann 
parents: 
51521 
diff
changeset
 | 
281  | 
using Infinitesimal_add [of x "- y"] by simp  | 
| 27468 | 282  | 
|
| 70221 | 283  | 
lemma Infinitesimal_mult:  | 
284  | 
fixes x y :: "'a::real_normed_algebra star"  | 
|
285  | 
assumes "x \<in> Infinitesimal" "y \<in> Infinitesimal"  | 
|
286  | 
shows "x * y \<in> Infinitesimal"  | 
|
287  | 
proof (rule InfinitesimalI)  | 
|
288  | 
show "hnorm (x * y) < r"  | 
|
289  | 
if "r \<in> \<real>" and "0 < r" for r :: "real star"  | 
|
290  | 
proof -  | 
|
291  | 
have "hnorm x < 1" "hnorm y < r"  | 
|
292  | 
using assms that by (auto simp add: InfinitesimalD)  | 
|
293  | 
then show ?thesis  | 
|
294  | 
using hnorm_mult_less by fastforce  | 
|
295  | 
qed  | 
|
296  | 
qed  | 
|
| 27468 | 297  | 
|
| 70221 | 298  | 
lemma Infinitesimal_HFinite_mult:  | 
299  | 
fixes x y :: "'a::real_normed_algebra star"  | 
|
300  | 
assumes "x \<in> Infinitesimal" "y \<in> HFinite"  | 
|
301  | 
shows "x * y \<in> Infinitesimal"  | 
|
302  | 
proof (rule InfinitesimalI)  | 
|
303  | 
obtain t where "hnorm y < t" "t \<in> Reals"  | 
|
304  | 
using HFiniteD \<open>y \<in> HFinite\<close> by blast  | 
|
305  | 
then have "t > 0"  | 
|
306  | 
using hnorm_ge_zero le_less_trans by blast  | 
|
307  | 
show "hnorm (x * y) < r"  | 
|
308  | 
if "r \<in> \<real>" and "0 < r" for r :: "real star"  | 
|
309  | 
proof -  | 
|
310  | 
have "hnorm x < r/t"  | 
|
311  | 
by (meson InfinitesimalD Reals_divide \<open>hnorm y < t\<close> \<open>t \<in> \<real>\<close> assms(1) divide_pos_pos hnorm_ge_zero le_less_trans that)  | 
|
312  | 
then have "hnorm (x * y) < (r / t) * t"  | 
|
313  | 
using \<open>hnorm y < t\<close> hnorm_mult_less by blast  | 
|
314  | 
then show ?thesis  | 
|
315  | 
using \<open>0 < t\<close> by auto  | 
|
316  | 
qed  | 
|
317  | 
qed  | 
|
| 27468 | 318  | 
|
319  | 
lemma Infinitesimal_HFinite_scaleHR:  | 
|
| 70221 | 320  | 
assumes "x \<in> Infinitesimal" "y \<in> HFinite"  | 
321  | 
shows "scaleHR x y \<in> Infinitesimal"  | 
|
322  | 
proof (rule InfinitesimalI)  | 
|
323  | 
obtain t where "hnorm y < t" "t \<in> Reals"  | 
|
324  | 
using HFiniteD \<open>y \<in> HFinite\<close> by blast  | 
|
325  | 
then have "t > 0"  | 
|
326  | 
using hnorm_ge_zero le_less_trans by blast  | 
|
327  | 
show "hnorm (scaleHR x y) < r"  | 
|
328  | 
if "r \<in> \<real>" and "0 < r" for r :: "real star"  | 
|
329  | 
proof -  | 
|
330  | 
have "\<bar>x\<bar> * hnorm y < (r / t) * t"  | 
|
331  | 
by (metis InfinitesimalD Reals_divide \<open>0 < t\<close> \<open>hnorm y < t\<close> \<open>t \<in> \<real>\<close> assms(1) divide_pos_pos hnorm_ge_zero hypreal_hnorm_def mult_strict_mono' that)  | 
|
332  | 
then show ?thesis  | 
|
333  | 
by (simp add: \<open>0 < t\<close> hnorm_scaleHR less_imp_not_eq2)  | 
|
334  | 
qed  | 
|
335  | 
qed  | 
|
| 27468 | 336  | 
|
337  | 
lemma Infinitesimal_HFinite_mult2:  | 
|
| 70221 | 338  | 
fixes x y :: "'a::real_normed_algebra star"  | 
339  | 
assumes "x \<in> Infinitesimal" "y \<in> HFinite"  | 
|
340  | 
shows "y * x \<in> Infinitesimal"  | 
|
341  | 
proof (rule InfinitesimalI)  | 
|
342  | 
obtain t where "hnorm y < t" "t \<in> Reals"  | 
|
343  | 
using HFiniteD \<open>y \<in> HFinite\<close> by blast  | 
|
344  | 
then have "t > 0"  | 
|
345  | 
using hnorm_ge_zero le_less_trans by blast  | 
|
346  | 
show "hnorm (y * x) < r"  | 
|
347  | 
if "r \<in> \<real>" and "0 < r" for r :: "real star"  | 
|
348  | 
proof -  | 
|
349  | 
have "hnorm x < r/t"  | 
|
350  | 
by (meson InfinitesimalD Reals_divide \<open>hnorm y < t\<close> \<open>t \<in> \<real>\<close> assms(1) divide_pos_pos hnorm_ge_zero le_less_trans that)  | 
|
351  | 
then have "hnorm (y * x) < t * (r / t)"  | 
|
352  | 
using \<open>hnorm y < t\<close> hnorm_mult_less by blast  | 
|
353  | 
then show ?thesis  | 
|
354  | 
using \<open>0 < t\<close> by auto  | 
|
355  | 
qed  | 
|
356  | 
qed  | 
|
| 27468 | 357  | 
|
| 70221 | 358  | 
lemma Infinitesimal_scaleR2:  | 
359  | 
assumes "x \<in> Infinitesimal" shows "a *\<^sub>R x \<in> Infinitesimal"  | 
|
360  | 
by (metis HFinite_star_of Infinitesimal_HFinite_mult2 Infinitesimal_hnorm_iff assms hnorm_scaleR hypreal_hnorm_def star_of_norm)  | 
|
| 27468 | 361  | 
|
362  | 
lemma Compl_HFinite: "- HFinite = HInfinite"  | 
|
| 70221 | 363  | 
proof -  | 
364  | 
have "r < hnorm x" if *: "\<And>s. s \<in> \<real> \<Longrightarrow> s \<le> hnorm x" and "r \<in> \<real>"  | 
|
365  | 
for x :: "'a star" and r :: hypreal  | 
|
366  | 
using * [of "r+1"] \<open>r \<in> \<real>\<close> by auto  | 
|
367  | 
then show ?thesis  | 
|
368  | 
by (auto simp add: HInfinite_def HFinite_def linorder_not_less)  | 
|
369  | 
qed  | 
|
| 27468 | 370  | 
|
| 70221 | 371  | 
lemma HInfinite_inverse_Infinitesimal:  | 
372  | 
"x \<in> HInfinite \<Longrightarrow> inverse x \<in> Infinitesimal"  | 
|
| 64435 | 373  | 
for x :: "'a::real_normed_div_algebra star"  | 
| 70221 | 374  | 
by (simp add: HInfinite_def InfinitesimalI hnorm_inverse inverse_less_imp_less)  | 
375  | 
||
376  | 
lemma inverse_Infinitesimal_iff_HInfinite:  | 
|
377  | 
"x \<noteq> 0 \<Longrightarrow> inverse x \<in> Infinitesimal \<longleftrightarrow> x \<in> HInfinite"  | 
|
378  | 
for x :: "'a::real_normed_div_algebra star"  | 
|
379  | 
by (metis Compl_HFinite Compl_iff HInfinite_inverse_Infinitesimal InfinitesimalD Infinitesimal_HFinite_mult Reals_1 hnorm_one left_inverse less_irrefl zero_less_one)  | 
|
| 27468 | 380  | 
|
381  | 
lemma HInfiniteI: "(\<And>r. r \<in> \<real> \<Longrightarrow> r < hnorm x) \<Longrightarrow> x \<in> HInfinite"  | 
|
| 64435 | 382  | 
by (simp add: HInfinite_def)  | 
| 27468 | 383  | 
|
| 64435 | 384  | 
lemma HInfiniteD: "x \<in> HInfinite \<Longrightarrow> r \<in> \<real> \<Longrightarrow> r < hnorm x"  | 
385  | 
by (simp add: HInfinite_def)  | 
|
| 27468 | 386  | 
|
| 70221 | 387  | 
lemma HInfinite_mult:  | 
388  | 
fixes x y :: "'a::real_normed_div_algebra star"  | 
|
389  | 
assumes "x \<in> HInfinite" "y \<in> HInfinite" shows "x * y \<in> HInfinite"  | 
|
390  | 
proof (rule HInfiniteI, simp only: hnorm_mult)  | 
|
391  | 
have "x \<noteq> 0"  | 
|
392  | 
using Compl_HFinite HFinite_0 assms by blast  | 
|
393  | 
show "r < hnorm x * hnorm y"  | 
|
394  | 
if "r \<in> \<real>" for r :: "real star"  | 
|
395  | 
proof -  | 
|
396  | 
have "r = r * 1"  | 
|
397  | 
by simp  | 
|
398  | 
also have "\<dots> < hnorm x * hnorm y"  | 
|
399  | 
by (meson HInfiniteD Reals_1 \<open>x \<noteq> 0\<close> assms le_numeral_extra(1) mult_strict_mono that zero_less_hnorm_iff)  | 
|
400  | 
finally show ?thesis .  | 
|
401  | 
qed  | 
|
402  | 
qed  | 
|
| 27468 | 403  | 
|
| 64435 | 404  | 
lemma hypreal_add_zero_less_le_mono: "r < x \<Longrightarrow> 0 \<le> y \<Longrightarrow> r < x + y"  | 
405  | 
for r x y :: hypreal  | 
|
| 70221 | 406  | 
by simp  | 
| 27468 | 407  | 
|
| 64435 | 408  | 
lemma HInfinite_add_ge_zero: "x \<in> HInfinite \<Longrightarrow> 0 \<le> y \<Longrightarrow> 0 \<le> x \<Longrightarrow> x + y \<in> HInfinite"  | 
409  | 
for x y :: hypreal  | 
|
410  | 
by (auto simp: abs_if add.commute HInfinite_def)  | 
|
| 27468 | 411  | 
|
| 64435 | 412  | 
lemma HInfinite_add_ge_zero2: "x \<in> HInfinite \<Longrightarrow> 0 \<le> y \<Longrightarrow> 0 \<le> x \<Longrightarrow> y + x \<in> HInfinite"  | 
413  | 
for x y :: hypreal  | 
|
414  | 
by (auto intro!: HInfinite_add_ge_zero simp add: add.commute)  | 
|
| 27468 | 415  | 
|
| 64435 | 416  | 
lemma HInfinite_add_gt_zero: "x \<in> HInfinite \<Longrightarrow> 0 < y \<Longrightarrow> 0 < x \<Longrightarrow> x + y \<in> HInfinite"  | 
417  | 
for x y :: hypreal  | 
|
418  | 
by (blast intro: HInfinite_add_ge_zero order_less_imp_le)  | 
|
| 27468 | 419  | 
|
| 64435 | 420  | 
lemma HInfinite_minus_iff: "- x \<in> HInfinite \<longleftrightarrow> x \<in> HInfinite"  | 
421  | 
by (simp add: HInfinite_def)  | 
|
| 27468 | 422  | 
|
| 64435 | 423  | 
lemma HInfinite_add_le_zero: "x \<in> HInfinite \<Longrightarrow> y \<le> 0 \<Longrightarrow> x \<le> 0 \<Longrightarrow> x + y \<in> HInfinite"  | 
424  | 
for x y :: hypreal  | 
|
| 70221 | 425  | 
by (metis (no_types, lifting) HInfinite_add_ge_zero2 HInfinite_minus_iff add.inverse_distrib_swap neg_0_le_iff_le)  | 
| 27468 | 426  | 
|
| 64435 | 427  | 
lemma HInfinite_add_lt_zero: "x \<in> HInfinite \<Longrightarrow> y < 0 \<Longrightarrow> x < 0 \<Longrightarrow> x + y \<in> HInfinite"  | 
428  | 
for x y :: hypreal  | 
|
429  | 
by (blast intro: HInfinite_add_le_zero order_less_imp_le)  | 
|
| 27468 | 430  | 
|
| 64435 | 431  | 
lemma not_Infinitesimal_not_zero: "x \<notin> Infinitesimal \<Longrightarrow> x \<noteq> 0"  | 
432  | 
by auto  | 
|
| 27468 | 433  | 
|
434  | 
lemma HFinite_diff_Infinitesimal_hrabs:  | 
|
| 64435 | 435  | 
"x \<in> HFinite - Infinitesimal \<Longrightarrow> \<bar>x\<bar> \<in> HFinite - Infinitesimal"  | 
436  | 
for x :: hypreal  | 
|
437  | 
by blast  | 
|
| 27468 | 438  | 
|
| 64435 | 439  | 
lemma hnorm_le_Infinitesimal: "e \<in> Infinitesimal \<Longrightarrow> hnorm x \<le> e \<Longrightarrow> x \<in> Infinitesimal"  | 
440  | 
by (auto simp: Infinitesimal_def abs_less_iff)  | 
|
| 27468 | 441  | 
|
| 64435 | 442  | 
lemma hnorm_less_Infinitesimal: "e \<in> Infinitesimal \<Longrightarrow> hnorm x < e \<Longrightarrow> x \<in> Infinitesimal"  | 
443  | 
by (erule hnorm_le_Infinitesimal, erule order_less_imp_le)  | 
|
| 27468 | 444  | 
|
| 64435 | 445  | 
lemma hrabs_le_Infinitesimal: "e \<in> Infinitesimal \<Longrightarrow> \<bar>x\<bar> \<le> e \<Longrightarrow> x \<in> Infinitesimal"  | 
446  | 
for x :: hypreal  | 
|
447  | 
by (erule hnorm_le_Infinitesimal) simp  | 
|
| 27468 | 448  | 
|
| 64435 | 449  | 
lemma hrabs_less_Infinitesimal: "e \<in> Infinitesimal \<Longrightarrow> \<bar>x\<bar> < e \<Longrightarrow> x \<in> Infinitesimal"  | 
450  | 
for x :: hypreal  | 
|
451  | 
by (erule hnorm_less_Infinitesimal) simp  | 
|
| 27468 | 452  | 
|
453  | 
lemma Infinitesimal_interval:  | 
|
| 64435 | 454  | 
"e \<in> Infinitesimal \<Longrightarrow> e' \<in> Infinitesimal \<Longrightarrow> e' < x \<Longrightarrow> x < e \<Longrightarrow> x \<in> Infinitesimal"  | 
455  | 
for x :: hypreal  | 
|
456  | 
by (auto simp add: Infinitesimal_def abs_less_iff)  | 
|
| 27468 | 457  | 
|
458  | 
lemma Infinitesimal_interval2:  | 
|
| 64435 | 459  | 
"e \<in> Infinitesimal \<Longrightarrow> e' \<in> Infinitesimal \<Longrightarrow> e' \<le> x \<Longrightarrow> x \<le> e \<Longrightarrow> x \<in> Infinitesimal"  | 
460  | 
for x :: hypreal  | 
|
461  | 
by (auto intro: Infinitesimal_interval simp add: order_le_less)  | 
|
| 27468 | 462  | 
|
| 64435 | 463  | 
lemma lemma_Infinitesimal_hyperpow: "x \<in> Infinitesimal \<Longrightarrow> 0 < N \<Longrightarrow> \<bar>x pow N\<bar> \<le> \<bar>x\<bar>"  | 
464  | 
for x :: hypreal  | 
|
| 70221 | 465  | 
apply (clarsimp simp: Infinitesimal_def)  | 
466  | 
by (metis Reals_1 abs_ge_zero hyperpow_Suc_le_self2 hyperpow_hrabs hypnat_gt_zero_iff2 zero_less_one)  | 
|
| 27468 | 467  | 
|
| 64435 | 468  | 
lemma Infinitesimal_hyperpow: "x \<in> Infinitesimal \<Longrightarrow> 0 < N \<Longrightarrow> x pow N \<in> Infinitesimal"  | 
469  | 
for x :: hypreal  | 
|
| 70221 | 470  | 
using hrabs_le_Infinitesimal lemma_Infinitesimal_hyperpow by blast  | 
| 27468 | 471  | 
|
472  | 
lemma hrealpow_hyperpow_Infinitesimal_iff:  | 
|
| 64435 | 473  | 
"(x ^ n \<in> Infinitesimal) \<longleftrightarrow> x pow (hypnat_of_nat n) \<in> Infinitesimal"  | 
474  | 
by (simp only: hyperpow_hypnat_of_nat)  | 
|
| 27468 | 475  | 
|
| 64435 | 476  | 
lemma Infinitesimal_hrealpow: "x \<in> Infinitesimal \<Longrightarrow> 0 < n \<Longrightarrow> x ^ n \<in> Infinitesimal"  | 
477  | 
for x :: hypreal  | 
|
478  | 
by (simp add: hrealpow_hyperpow_Infinitesimal_iff Infinitesimal_hyperpow)  | 
|
| 27468 | 479  | 
|
480  | 
lemma not_Infinitesimal_mult:  | 
|
| 64435 | 481  | 
"x \<notin> Infinitesimal \<Longrightarrow> y \<notin> Infinitesimal \<Longrightarrow> x * y \<notin> Infinitesimal"  | 
482  | 
for x y :: "'a::real_normed_div_algebra star"  | 
|
| 70221 | 483  | 
by (metis (no_types, lifting) inverse_Infinitesimal_iff_HInfinite ComplI Compl_HFinite Infinitesimal_HFinite_mult divide_inverse eq_divide_imp inverse_inverse_eq mult_zero_right)  | 
| 27468 | 484  | 
|
| 64435 | 485  | 
lemma Infinitesimal_mult_disj: "x * y \<in> Infinitesimal \<Longrightarrow> x \<in> Infinitesimal \<or> y \<in> Infinitesimal"  | 
486  | 
for x y :: "'a::real_normed_div_algebra star"  | 
|
| 70221 | 487  | 
using not_Infinitesimal_mult by blast  | 
| 27468 | 488  | 
|
| 64435 | 489  | 
lemma HFinite_Infinitesimal_not_zero: "x \<in> HFinite-Infinitesimal \<Longrightarrow> x \<noteq> 0"  | 
490  | 
by blast  | 
|
| 27468 | 491  | 
|
492  | 
lemma HFinite_Infinitesimal_diff_mult:  | 
|
| 64435 | 493  | 
"x \<in> HFinite - Infinitesimal \<Longrightarrow> y \<in> HFinite - Infinitesimal \<Longrightarrow> x * y \<in> HFinite - Infinitesimal"  | 
494  | 
for x y :: "'a::real_normed_div_algebra star"  | 
|
| 70221 | 495  | 
by (simp add: HFinite_mult not_Infinitesimal_mult)  | 
| 27468 | 496  | 
|
| 64435 | 497  | 
lemma Infinitesimal_subset_HFinite: "Infinitesimal \<subseteq> HFinite"  | 
| 70221 | 498  | 
using HFinite_def InfinitesimalD Reals_1 zero_less_one by blast  | 
| 27468 | 499  | 
|
| 64435 | 500  | 
lemma Infinitesimal_star_of_mult: "x \<in> Infinitesimal \<Longrightarrow> x * star_of r \<in> Infinitesimal"  | 
501  | 
for x :: "'a::real_normed_algebra star"  | 
|
502  | 
by (erule HFinite_star_of [THEN [2] Infinitesimal_HFinite_mult])  | 
|
| 27468 | 503  | 
|
| 64435 | 504  | 
lemma Infinitesimal_star_of_mult2: "x \<in> Infinitesimal \<Longrightarrow> star_of r * x \<in> Infinitesimal"  | 
505  | 
for x :: "'a::real_normed_algebra star"  | 
|
506  | 
by (erule HFinite_star_of [THEN [2] Infinitesimal_HFinite_mult2])  | 
|
| 27468 | 507  | 
|
508  | 
||
| 64435 | 509  | 
subsection \<open>The Infinitely Close Relation\<close>  | 
| 27468 | 510  | 
|
| 64435 | 511  | 
lemma mem_infmal_iff: "x \<in> Infinitesimal \<longleftrightarrow> x \<approx> 0"  | 
512  | 
by (simp add: Infinitesimal_def approx_def)  | 
|
| 27468 | 513  | 
|
| 64435 | 514  | 
lemma approx_minus_iff: "x \<approx> y \<longleftrightarrow> x - y \<approx> 0"  | 
515  | 
by (simp add: approx_def)  | 
|
| 27468 | 516  | 
|
| 64435 | 517  | 
lemma approx_minus_iff2: "x \<approx> y \<longleftrightarrow> - y + x \<approx> 0"  | 
518  | 
by (simp add: approx_def add.commute)  | 
|
| 27468 | 519  | 
|
| 61982 | 520  | 
lemma approx_refl [iff]: "x \<approx> x"  | 
| 64435 | 521  | 
by (simp add: approx_def Infinitesimal_def)  | 
| 27468 | 522  | 
|
| 70221 | 523  | 
lemma approx_sym: "x \<approx> y \<Longrightarrow> y \<approx> x"  | 
524  | 
by (metis Infinitesimal_minus_iff approx_def minus_diff_eq)  | 
|
| 27468 | 525  | 
|
| 70221 | 526  | 
lemma approx_trans:  | 
527  | 
assumes "x \<approx> y" "y \<approx> z" shows "x \<approx> z"  | 
|
528  | 
proof -  | 
|
529  | 
have "x - y \<in> Infinitesimal" "z - y \<in> Infinitesimal"  | 
|
530  | 
using assms approx_def approx_sym by auto  | 
|
531  | 
then have "x - z \<in> Infinitesimal"  | 
|
532  | 
using Infinitesimal_diff by force  | 
|
533  | 
then show ?thesis  | 
|
534  | 
by (simp add: approx_def)  | 
|
535  | 
qed  | 
|
| 27468 | 536  | 
|
| 64435 | 537  | 
lemma approx_trans2: "r \<approx> x \<Longrightarrow> s \<approx> x \<Longrightarrow> r \<approx> s"  | 
538  | 
by (blast intro: approx_sym approx_trans)  | 
|
| 27468 | 539  | 
|
| 64435 | 540  | 
lemma approx_trans3: "x \<approx> r \<Longrightarrow> x \<approx> s \<Longrightarrow> r \<approx> s"  | 
541  | 
by (blast intro: approx_sym approx_trans)  | 
|
| 27468 | 542  | 
|
| 64435 | 543  | 
lemma approx_reorient: "x \<approx> y \<longleftrightarrow> y \<approx> x"  | 
544  | 
by (blast intro: approx_sym)  | 
|
| 27468 | 545  | 
|
| 64435 | 546  | 
text \<open>Reorientation simplification procedure: reorients (polymorphic)  | 
547  | 
\<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>  | 
|
| 
45541
 
934866fc776c
simplify implementation of approx_reorient_simproc
 
huffman 
parents: 
45540 
diff
changeset
 | 
548  | 
simproc_setup approx_reorient_simproc  | 
| 61982 | 549  | 
  ("0 \<approx> x" | "1 \<approx> y" | "numeral w \<approx> z" | "- 1 \<approx> y" | "- numeral w \<approx> r") =
 | 
| 61975 | 550  | 
\<open>  | 
| 
45541
 
934866fc776c
simplify implementation of approx_reorient_simproc
 
huffman 
parents: 
45540 
diff
changeset
 | 
551  | 
  let val rule = @{thm approx_reorient} RS eq_reflection
 | 
| 
78099
 
4d9349989d94
more uniform simproc_setup: avoid vacuous abstraction over morphism, which sometimes captures context values in its functional closure;
 
wenzelm 
parents: 
75866 
diff
changeset
 | 
552  | 
fun proc ct =  | 
| 59582 | 553  | 
case Thm.term_of ct of  | 
| 
45541
 
934866fc776c
simplify implementation of approx_reorient_simproc
 
huffman 
parents: 
45540 
diff
changeset
 | 
554  | 
_ $ t $ u => if can HOLogic.dest_number u then NONE  | 
| 
 
934866fc776c
simplify implementation of approx_reorient_simproc
 
huffman 
parents: 
45540 
diff
changeset
 | 
555  | 
else if can HOLogic.dest_number t then SOME rule else NONE  | 
| 
 
934866fc776c
simplify implementation of approx_reorient_simproc
 
huffman 
parents: 
45540 
diff
changeset
 | 
556  | 
| _ => NONE  | 
| 
78099
 
4d9349989d94
more uniform simproc_setup: avoid vacuous abstraction over morphism, which sometimes captures context values in its functional closure;
 
wenzelm 
parents: 
75866 
diff
changeset
 | 
557  | 
in K (K proc) end  | 
| 61975 | 558  | 
\<close>  | 
| 27468 | 559  | 
|
| 64435 | 560  | 
lemma Infinitesimal_approx_minus: "x - y \<in> Infinitesimal \<longleftrightarrow> x \<approx> y"  | 
561  | 
by (simp add: approx_minus_iff [symmetric] mem_infmal_iff)  | 
|
| 27468 | 562  | 
|
| 64435 | 563  | 
lemma approx_monad_iff: "x \<approx> y \<longleftrightarrow> monad x = monad y"  | 
| 70221 | 564  | 
apply (simp add: monad_def set_eq_iff)  | 
565  | 
using approx_reorient approx_trans by blast  | 
|
| 27468 | 566  | 
|
| 64435 | 567  | 
lemma Infinitesimal_approx: "x \<in> Infinitesimal \<Longrightarrow> y \<in> Infinitesimal \<Longrightarrow> x \<approx> y"  | 
| 70221 | 568  | 
by (simp add: Infinitesimal_diff approx_def)  | 
| 27468 | 569  | 
|
| 64435 | 570  | 
lemma approx_add: "a \<approx> b \<Longrightarrow> c \<approx> d \<Longrightarrow> a + c \<approx> b + d"  | 
| 27468 | 571  | 
proof (unfold approx_def)  | 
572  | 
assume inf: "a - b \<in> Infinitesimal" "c - d \<in> Infinitesimal"  | 
|
573  | 
have "a + c - (b + d) = (a - b) + (c - d)" by simp  | 
|
| 64435 | 574  | 
also have "... \<in> Infinitesimal"  | 
575  | 
using inf by (rule Infinitesimal_add)  | 
|
| 27468 | 576  | 
finally show "a + c - (b + d) \<in> Infinitesimal" .  | 
577  | 
qed  | 
|
578  | 
||
| 64435 | 579  | 
lemma approx_minus: "a \<approx> b \<Longrightarrow> - a \<approx> - b"  | 
| 70221 | 580  | 
by (metis approx_def approx_sym minus_diff_eq minus_diff_minus)  | 
| 27468 | 581  | 
|
| 64435 | 582  | 
lemma approx_minus2: "- a \<approx> - b \<Longrightarrow> a \<approx> b"  | 
583  | 
by (auto dest: approx_minus)  | 
|
| 27468 | 584  | 
|
| 64435 | 585  | 
lemma approx_minus_cancel [simp]: "- a \<approx> - b \<longleftrightarrow> a \<approx> b"  | 
586  | 
by (blast intro: approx_minus approx_minus2)  | 
|
| 27468 | 587  | 
|
| 64435 | 588  | 
lemma approx_add_minus: "a \<approx> b \<Longrightarrow> c \<approx> d \<Longrightarrow> a + - c \<approx> b + - d"  | 
589  | 
by (blast intro!: approx_add approx_minus)  | 
|
| 27468 | 590  | 
|
| 64435 | 591  | 
lemma approx_diff: "a \<approx> b \<Longrightarrow> c \<approx> d \<Longrightarrow> a - c \<approx> b - d"  | 
| 
54230
 
b1d955791529
more simplification rules on unary and binary minus
 
haftmann 
parents: 
51521 
diff
changeset
 | 
592  | 
using approx_add [of a b "- c" "- d"] by simp  | 
| 27468 | 593  | 
|
| 64435 | 594  | 
lemma approx_mult1: "a \<approx> b \<Longrightarrow> c \<in> HFinite \<Longrightarrow> a * c \<approx> b * c"  | 
595  | 
for a b c :: "'a::real_normed_algebra star"  | 
|
596  | 
by (simp add: approx_def Infinitesimal_HFinite_mult left_diff_distrib [symmetric])  | 
|
597  | 
||
598  | 
lemma approx_mult2: "a \<approx> b \<Longrightarrow> c \<in> HFinite \<Longrightarrow> c * a \<approx> c * b"  | 
|
599  | 
for a b c :: "'a::real_normed_algebra star"  | 
|
600  | 
by (simp add: approx_def Infinitesimal_HFinite_mult2 right_diff_distrib [symmetric])  | 
|
| 27468 | 601  | 
|
| 64435 | 602  | 
lemma approx_mult_subst: "u \<approx> v * x \<Longrightarrow> x \<approx> y \<Longrightarrow> v \<in> HFinite \<Longrightarrow> u \<approx> v * y"  | 
603  | 
for u v x y :: "'a::real_normed_algebra star"  | 
|
604  | 
by (blast intro: approx_mult2 approx_trans)  | 
|
| 27468 | 605  | 
|
| 64435 | 606  | 
lemma approx_mult_subst2: "u \<approx> x * v \<Longrightarrow> x \<approx> y \<Longrightarrow> v \<in> HFinite \<Longrightarrow> u \<approx> y * v"  | 
607  | 
for u v x y :: "'a::real_normed_algebra star"  | 
|
608  | 
by (blast intro: approx_mult1 approx_trans)  | 
|
| 27468 | 609  | 
|
| 64435 | 610  | 
lemma approx_mult_subst_star_of: "u \<approx> x * star_of v \<Longrightarrow> x \<approx> y \<Longrightarrow> u \<approx> y * star_of v"  | 
611  | 
for u x y :: "'a::real_normed_algebra star"  | 
|
612  | 
by (auto intro: approx_mult_subst2)  | 
|
| 27468 | 613  | 
|
| 64435 | 614  | 
lemma approx_eq_imp: "a = b \<Longrightarrow> a \<approx> b"  | 
615  | 
by (simp add: approx_def)  | 
|
| 27468 | 616  | 
|
| 64435 | 617  | 
lemma Infinitesimal_minus_approx: "x \<in> Infinitesimal \<Longrightarrow> - x \<approx> x"  | 
618  | 
by (blast intro: Infinitesimal_minus_iff [THEN iffD2] mem_infmal_iff [THEN iffD1] approx_trans2)  | 
|
| 27468 | 619  | 
|
| 64435 | 620  | 
lemma bex_Infinitesimal_iff: "(\<exists>y \<in> Infinitesimal. x - z = y) \<longleftrightarrow> x \<approx> z"  | 
621  | 
by (simp add: approx_def)  | 
|
| 27468 | 622  | 
|
| 64435 | 623  | 
lemma bex_Infinitesimal_iff2: "(\<exists>y \<in> Infinitesimal. x = z + y) \<longleftrightarrow> x \<approx> z"  | 
624  | 
by (force simp add: bex_Infinitesimal_iff [symmetric])  | 
|
| 27468 | 625  | 
|
| 64435 | 626  | 
lemma Infinitesimal_add_approx: "y \<in> Infinitesimal \<Longrightarrow> x + y = z \<Longrightarrow> x \<approx> z"  | 
| 70221 | 627  | 
using approx_sym bex_Infinitesimal_iff2 by blast  | 
| 27468 | 628  | 
|
| 64435 | 629  | 
lemma Infinitesimal_add_approx_self: "y \<in> Infinitesimal \<Longrightarrow> x \<approx> x + y"  | 
| 70221 | 630  | 
by (simp add: Infinitesimal_add_approx)  | 
| 27468 | 631  | 
|
| 64435 | 632  | 
lemma Infinitesimal_add_approx_self2: "y \<in> Infinitesimal \<Longrightarrow> x \<approx> y + x"  | 
633  | 
by (auto dest: Infinitesimal_add_approx_self simp add: add.commute)  | 
|
| 27468 | 634  | 
|
| 64435 | 635  | 
lemma Infinitesimal_add_minus_approx_self: "y \<in> Infinitesimal \<Longrightarrow> x \<approx> x + - y"  | 
636  | 
by (blast intro!: Infinitesimal_add_approx_self Infinitesimal_minus_iff [THEN iffD2])  | 
|
| 27468 | 637  | 
|
| 64435 | 638  | 
lemma Infinitesimal_add_cancel: "y \<in> Infinitesimal \<Longrightarrow> x + y \<approx> z \<Longrightarrow> x \<approx> z"  | 
| 70221 | 639  | 
using Infinitesimal_add_approx approx_trans by blast  | 
| 27468 | 640  | 
|
| 64435 | 641  | 
lemma Infinitesimal_add_right_cancel: "y \<in> Infinitesimal \<Longrightarrow> x \<approx> z + y \<Longrightarrow> x \<approx> z"  | 
| 70221 | 642  | 
by (metis Infinitesimal_add_approx_self approx_monad_iff)  | 
| 27468 | 643  | 
|
| 70221 | 644  | 
lemma approx_add_left_cancel: "d + b \<approx> d + c \<Longrightarrow> b \<approx> c"  | 
645  | 
by (metis add_diff_cancel_left bex_Infinitesimal_iff)  | 
|
| 27468 | 646  | 
|
| 64435 | 647  | 
lemma approx_add_right_cancel: "b + d \<approx> c + d \<Longrightarrow> b \<approx> c"  | 
| 70221 | 648  | 
by (simp add: approx_def)  | 
| 27468 | 649  | 
|
| 64435 | 650  | 
lemma approx_add_mono1: "b \<approx> c \<Longrightarrow> d + b \<approx> d + c"  | 
| 70221 | 651  | 
by (simp add: approx_add)  | 
| 27468 | 652  | 
|
| 64435 | 653  | 
lemma approx_add_mono2: "b \<approx> c \<Longrightarrow> b + a \<approx> c + a"  | 
654  | 
by (simp add: add.commute approx_add_mono1)  | 
|
| 27468 | 655  | 
|
| 64435 | 656  | 
lemma approx_add_left_iff [simp]: "a + b \<approx> a + c \<longleftrightarrow> b \<approx> c"  | 
657  | 
by (fast elim: approx_add_left_cancel approx_add_mono1)  | 
|
| 27468 | 658  | 
|
| 64435 | 659  | 
lemma approx_add_right_iff [simp]: "b + a \<approx> c + a \<longleftrightarrow> b \<approx> c"  | 
660  | 
by (simp add: add.commute)  | 
|
| 27468 | 661  | 
|
| 64435 | 662  | 
lemma approx_HFinite: "x \<in> HFinite \<Longrightarrow> x \<approx> y \<Longrightarrow> y \<in> HFinite"  | 
| 70221 | 663  | 
by (metis HFinite_add Infinitesimal_subset_HFinite approx_sym subsetD bex_Infinitesimal_iff2)  | 
| 27468 | 664  | 
|
| 64435 | 665  | 
lemma approx_star_of_HFinite: "x \<approx> star_of D \<Longrightarrow> x \<in> HFinite"  | 
666  | 
by (rule approx_sym [THEN [2] approx_HFinite], auto)  | 
|
| 27468 | 667  | 
|
| 64435 | 668  | 
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"  | 
669  | 
for a b c d :: "'a::real_normed_algebra star"  | 
|
| 70221 | 670  | 
by (meson approx_HFinite approx_mult2 approx_mult_subst2 approx_sym)  | 
| 27468 | 671  | 
|
| 64435 | 672  | 
lemma scaleHR_left_diff_distrib: "\<And>a b x. scaleHR (a - b) x = scaleHR a x - scaleHR b x"  | 
673  | 
by transfer (rule scaleR_left_diff_distrib)  | 
|
| 27468 | 674  | 
|
| 64435 | 675  | 
lemma approx_scaleR1: "a \<approx> star_of b \<Longrightarrow> c \<in> HFinite \<Longrightarrow> scaleHR a c \<approx> b *\<^sub>R c"  | 
| 70221 | 676  | 
unfolding approx_def  | 
677  | 
by (metis Infinitesimal_HFinite_scaleHR scaleHR_def scaleHR_left_diff_distrib star_scaleR_def starfun2_star_of)  | 
|
| 27468 | 678  | 
|
| 64435 | 679  | 
lemma approx_scaleR2: "a \<approx> b \<Longrightarrow> c *\<^sub>R a \<approx> c *\<^sub>R b"  | 
680  | 
by (simp add: approx_def Infinitesimal_scaleR2 scaleR_right_diff_distrib [symmetric])  | 
|
681  | 
||
682  | 
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"  | 
|
| 70221 | 683  | 
by (meson approx_HFinite approx_scaleR1 approx_scaleR2 approx_sym approx_trans)  | 
| 27468 | 684  | 
|
| 64435 | 685  | 
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"  | 
686  | 
for a c :: "'a::real_normed_algebra star"  | 
|
687  | 
by (blast intro!: approx_mult_HFinite approx_star_of_HFinite HFinite_star_of)  | 
|
688  | 
||
| 70221 | 689  | 
lemma approx_SReal_mult_cancel_zero:  | 
690  | 
fixes a x :: hypreal  | 
|
691  | 
assumes "a \<in> \<real>" "a \<noteq> 0" "a * x \<approx> 0" shows "x \<approx> 0"  | 
|
692  | 
proof -  | 
|
693  | 
have "inverse a \<in> HFinite"  | 
|
694  | 
using Reals_inverse SReal_subset_HFinite assms(1) by blast  | 
|
695  | 
then show ?thesis  | 
|
696  | 
using assms by (auto dest: approx_mult2 simp add: mult.assoc [symmetric])  | 
|
697  | 
qed  | 
|
| 27468 | 698  | 
|
| 64435 | 699  | 
lemma approx_mult_SReal1: "a \<in> \<real> \<Longrightarrow> x \<approx> 0 \<Longrightarrow> x * a \<approx> 0"  | 
700  | 
for a x :: hypreal  | 
|
701  | 
by (auto dest: SReal_subset_HFinite [THEN subsetD] approx_mult1)  | 
|
| 27468 | 702  | 
|
| 64435 | 703  | 
lemma approx_mult_SReal2: "a \<in> \<real> \<Longrightarrow> x \<approx> 0 \<Longrightarrow> a * x \<approx> 0"  | 
704  | 
for a x :: hypreal  | 
|
705  | 
by (auto dest: SReal_subset_HFinite [THEN subsetD] approx_mult2)  | 
|
| 27468 | 706  | 
|
| 64435 | 707  | 
lemma approx_mult_SReal_zero_cancel_iff [simp]: "a \<in> \<real> \<Longrightarrow> a \<noteq> 0 \<Longrightarrow> a * x \<approx> 0 \<longleftrightarrow> x \<approx> 0"  | 
708  | 
for a x :: hypreal  | 
|
709  | 
by (blast intro: approx_SReal_mult_cancel_zero approx_mult_SReal2)  | 
|
| 27468 | 710  | 
|
| 70221 | 711  | 
lemma approx_SReal_mult_cancel:  | 
712  | 
fixes a w z :: hypreal  | 
|
713  | 
assumes "a \<in> \<real>" "a \<noteq> 0" "a * w \<approx> a * z" shows "w \<approx> z"  | 
|
714  | 
proof -  | 
|
715  | 
have "inverse a \<in> HFinite"  | 
|
716  | 
using Reals_inverse SReal_subset_HFinite assms(1) by blast  | 
|
717  | 
then show ?thesis  | 
|
718  | 
using assms by (auto dest: approx_mult2 simp add: mult.assoc [symmetric])  | 
|
719  | 
qed  | 
|
| 27468 | 720  | 
|
| 64435 | 721  | 
lemma approx_SReal_mult_cancel_iff1 [simp]: "a \<in> \<real> \<Longrightarrow> a \<noteq> 0 \<Longrightarrow> a * w \<approx> a * z \<longleftrightarrow> w \<approx> z"  | 
722  | 
for a w z :: hypreal  | 
|
| 70221 | 723  | 
by (meson SReal_subset_HFinite approx_SReal_mult_cancel approx_mult2 subsetD)  | 
| 27468 | 724  | 
|
| 70221 | 725  | 
lemma approx_le_bound:  | 
726  | 
fixes z :: hypreal  | 
|
727  | 
assumes "z \<le> f" " f \<approx> g" "g \<le> z" shows "f \<approx> z"  | 
|
728  | 
proof -  | 
|
729  | 
obtain y where "z \<le> g + y" and "y \<in> Infinitesimal" "f = g + y"  | 
|
730  | 
using assms bex_Infinitesimal_iff2 by auto  | 
|
731  | 
then have "z - g \<in> Infinitesimal"  | 
|
732  | 
using assms(3) hrabs_le_Infinitesimal by auto  | 
|
733  | 
then show ?thesis  | 
|
734  | 
by (metis approx_def approx_trans2 assms(2))  | 
|
735  | 
qed  | 
|
| 27468 | 736  | 
|
| 64435 | 737  | 
lemma approx_hnorm: "x \<approx> y \<Longrightarrow> hnorm x \<approx> hnorm y"  | 
738  | 
for x y :: "'a::real_normed_vector star"  | 
|
| 27468 | 739  | 
proof (unfold approx_def)  | 
740  | 
assume "x - y \<in> Infinitesimal"  | 
|
| 64435 | 741  | 
then have "hnorm (x - y) \<in> Infinitesimal"  | 
| 27468 | 742  | 
by (simp only: Infinitesimal_hnorm_iff)  | 
| 64435 | 743  | 
moreover have "(0::real star) \<in> Infinitesimal"  | 
| 27468 | 744  | 
by (rule Infinitesimal_zero)  | 
| 64435 | 745  | 
moreover have "0 \<le> \<bar>hnorm x - hnorm y\<bar>"  | 
| 27468 | 746  | 
by (rule abs_ge_zero)  | 
| 64435 | 747  | 
moreover have "\<bar>hnorm x - hnorm y\<bar> \<le> hnorm (x - y)"  | 
| 27468 | 748  | 
by (rule hnorm_triangle_ineq3)  | 
749  | 
ultimately have "\<bar>hnorm x - hnorm y\<bar> \<in> Infinitesimal"  | 
|
750  | 
by (rule Infinitesimal_interval2)  | 
|
| 64435 | 751  | 
then show "hnorm x - hnorm y \<in> Infinitesimal"  | 
| 27468 | 752  | 
by (simp only: Infinitesimal_hrabs_iff)  | 
753  | 
qed  | 
|
754  | 
||
755  | 
||
| 64435 | 756  | 
subsection \<open>Zero is the Only Infinitesimal that is also a Real\<close>  | 
| 27468 | 757  | 
|
| 64435 | 758  | 
lemma Infinitesimal_less_SReal: "x \<in> \<real> \<Longrightarrow> y \<in> Infinitesimal \<Longrightarrow> 0 < x \<Longrightarrow> y < x"  | 
759  | 
for x y :: hypreal  | 
|
| 70221 | 760  | 
using InfinitesimalD by fastforce  | 
| 27468 | 761  | 
|
| 64435 | 762  | 
lemma Infinitesimal_less_SReal2: "y \<in> Infinitesimal \<Longrightarrow> \<forall>r \<in> Reals. 0 < r \<longrightarrow> y < r"  | 
763  | 
for y :: hypreal  | 
|
764  | 
by (blast intro: Infinitesimal_less_SReal)  | 
|
| 27468 | 765  | 
|
| 64435 | 766  | 
lemma SReal_not_Infinitesimal: "0 < y \<Longrightarrow> y \<in> \<real> ==> y \<notin> Infinitesimal"  | 
767  | 
for y :: hypreal  | 
|
| 70221 | 768  | 
by (auto simp add: Infinitesimal_def abs_if)  | 
| 27468 | 769  | 
|
| 64435 | 770  | 
lemma SReal_minus_not_Infinitesimal: "y < 0 \<Longrightarrow> y \<in> \<real> \<Longrightarrow> y \<notin> Infinitesimal"  | 
771  | 
for y :: hypreal  | 
|
| 70221 | 772  | 
using Infinitesimal_minus_iff Reals_minus SReal_not_Infinitesimal neg_0_less_iff_less by blast  | 
| 27468 | 773  | 
|
| 61070 | 774  | 
lemma SReal_Int_Infinitesimal_zero: "\<real> Int Infinitesimal = {0::hypreal}"
 | 
| 70221 | 775  | 
proof -  | 
776  | 
have "x = 0" if "x \<in> \<real>" "x \<in> Infinitesimal" for x :: "real star"  | 
|
777  | 
using that SReal_minus_not_Infinitesimal SReal_not_Infinitesimal not_less_iff_gr_or_eq by blast  | 
|
778  | 
then show ?thesis  | 
|
779  | 
by auto  | 
|
780  | 
qed  | 
|
| 27468 | 781  | 
|
| 64435 | 782  | 
lemma SReal_Infinitesimal_zero: "x \<in> \<real> \<Longrightarrow> x \<in> Infinitesimal \<Longrightarrow> x = 0"  | 
783  | 
for x :: hypreal  | 
|
784  | 
using SReal_Int_Infinitesimal_zero by blast  | 
|
| 27468 | 785  | 
|
| 64435 | 786  | 
lemma SReal_HFinite_diff_Infinitesimal: "x \<in> \<real> \<Longrightarrow> x \<noteq> 0 \<Longrightarrow> x \<in> HFinite - Infinitesimal"  | 
787  | 
for x :: hypreal  | 
|
788  | 
by (auto dest: SReal_Infinitesimal_zero SReal_subset_HFinite [THEN subsetD])  | 
|
| 27468 | 789  | 
|
790  | 
lemma hypreal_of_real_HFinite_diff_Infinitesimal:  | 
|
| 64435 | 791  | 
"hypreal_of_real x \<noteq> 0 \<Longrightarrow> hypreal_of_real x \<in> HFinite - Infinitesimal"  | 
792  | 
by (rule SReal_HFinite_diff_Infinitesimal) auto  | 
|
| 27468 | 793  | 
|
| 64435 | 794  | 
lemma star_of_Infinitesimal_iff_0 [iff]: "star_of x \<in> Infinitesimal \<longleftrightarrow> x = 0"  | 
| 70221 | 795  | 
proof  | 
796  | 
show "x = 0" if "star_of x \<in> Infinitesimal"  | 
|
797  | 
proof -  | 
|
798  | 
have "hnorm (star_n (\<lambda>n. x)) \<in> Standard"  | 
|
799  | 
by (metis Reals_eq_Standard SReal_iff star_of_def star_of_norm)  | 
|
800  | 
then show ?thesis  | 
|
801  | 
by (metis InfinitesimalD2 less_irrefl star_of_norm that zero_less_norm_iff)  | 
|
802  | 
qed  | 
|
803  | 
qed auto  | 
|
| 27468 | 804  | 
|
| 64435 | 805  | 
lemma star_of_HFinite_diff_Infinitesimal: "x \<noteq> 0 \<Longrightarrow> star_of x \<in> HFinite - Infinitesimal"  | 
806  | 
by simp  | 
|
| 27468 | 807  | 
|
| 
47108
 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
 
huffman 
parents: 
45541 
diff
changeset
 | 
808  | 
lemma numeral_not_Infinitesimal [simp]:  | 
| 64435 | 809  | 
"numeral w \<noteq> (0::hypreal) \<Longrightarrow> (numeral w :: hypreal) \<notin> Infinitesimal"  | 
810  | 
by (fast dest: Reals_numeral [THEN SReal_Infinitesimal_zero])  | 
|
| 27468 | 811  | 
|
| 64435 | 812  | 
text \<open>Again: \<open>1\<close> is a special case, but not \<open>0\<close> this time.\<close>  | 
| 27468 | 813  | 
lemma one_not_Infinitesimal [simp]:  | 
814  | 
  "(1::'a::{real_normed_vector,zero_neq_one} star) \<notin> Infinitesimal"
 | 
|
| 70221 | 815  | 
by (metis star_of_Infinitesimal_iff_0 star_one_def zero_neq_one)  | 
| 27468 | 816  | 
|
| 64435 | 817  | 
lemma approx_SReal_not_zero: "y \<in> \<real> \<Longrightarrow> x \<approx> y \<Longrightarrow> y \<noteq> 0 \<Longrightarrow> x \<noteq> 0"  | 
818  | 
for x y :: hypreal  | 
|
| 70221 | 819  | 
using SReal_Infinitesimal_zero approx_sym mem_infmal_iff by auto  | 
| 27468 | 820  | 
|
821  | 
lemma HFinite_diff_Infinitesimal_approx:  | 
|
| 64435 | 822  | 
"x \<approx> y \<Longrightarrow> y \<in> HFinite - Infinitesimal \<Longrightarrow> x \<in> HFinite - Infinitesimal"  | 
| 70221 | 823  | 
by (meson Diff_iff approx_HFinite approx_sym approx_trans3 mem_infmal_iff)  | 
| 27468 | 824  | 
|
| 64435 | 825  | 
text \<open>The premise \<open>y \<noteq> 0\<close> is essential; otherwise \<open>x / y = 0\<close> and we lose the  | 
826  | 
\<open>HFinite\<close> premise.\<close>  | 
|
| 27468 | 827  | 
lemma Infinitesimal_ratio:  | 
| 64435 | 828  | 
"y \<noteq> 0 \<Longrightarrow> y \<in> Infinitesimal \<Longrightarrow> x / y \<in> HFinite \<Longrightarrow> x \<in> Infinitesimal"  | 
829  | 
  for x y :: "'a::{real_normed_div_algebra,field} star"
 | 
|
| 70221 | 830  | 
using Infinitesimal_HFinite_mult by fastforce  | 
| 64435 | 831  | 
|
832  | 
lemma Infinitesimal_SReal_divide: "x \<in> Infinitesimal \<Longrightarrow> y \<in> \<real> \<Longrightarrow> x / y \<in> Infinitesimal"  | 
|
833  | 
for x y :: hypreal  | 
|
| 70221 | 834  | 
by (metis HFinite_star_of Infinitesimal_HFinite_mult Reals_inverse SReal_iff divide_inverse)  | 
| 64435 | 835  | 
|
836  | 
||
837  | 
section \<open>Standard Part Theorem\<close>  | 
|
| 27468 | 838  | 
|
| 64435 | 839  | 
text \<open>  | 
840  | 
Every finite \<open>x \<in> R*\<close> is infinitely close to a unique real number  | 
|
841  | 
(i.e. a member of \<open>Reals\<close>).  | 
|
842  | 
\<close>  | 
|
| 27468 | 843  | 
|
844  | 
||
| 64435 | 845  | 
subsection \<open>Uniqueness: Two Infinitely Close Reals are Equal\<close>  | 
| 27468 | 846  | 
|
| 64435 | 847  | 
lemma star_of_approx_iff [simp]: "star_of x \<approx> star_of y \<longleftrightarrow> x = y"  | 
| 70221 | 848  | 
by (metis approx_def right_minus_eq star_of_Infinitesimal_iff_0 star_of_simps(2))  | 
| 27468 | 849  | 
|
| 64435 | 850  | 
lemma SReal_approx_iff: "x \<in> \<real> \<Longrightarrow> y \<in> \<real> \<Longrightarrow> x \<approx> y \<longleftrightarrow> x = y"  | 
851  | 
for x y :: hypreal  | 
|
| 70221 | 852  | 
by (meson Reals_diff SReal_Infinitesimal_zero approx_def approx_refl right_minus_eq)  | 
| 27468 | 853  | 
|
| 
47108
 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
 
huffman 
parents: 
45541 
diff
changeset
 | 
854  | 
lemma numeral_approx_iff [simp]:  | 
| 70221 | 855  | 
  "(numeral v \<approx> (numeral w :: 'a::{numeral,real_normed_vector} star)) = (numeral v = (numeral w :: 'a))"
 | 
856  | 
by (metis star_of_approx_iff star_of_numeral)  | 
|
| 27468 | 857  | 
|
| 64435 | 858  | 
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>  | 
| 27468 | 859  | 
lemma [simp]:  | 
| 64435 | 860  | 
  "(numeral w \<approx> (0::'a::{numeral,real_normed_vector} star)) = (numeral w = (0::'a))"
 | 
861  | 
  "((0::'a::{numeral,real_normed_vector} star) \<approx> numeral w) = (numeral w = (0::'a))"
 | 
|
862  | 
  "(numeral w \<approx> (1::'b::{numeral,one,real_normed_vector} star)) = (numeral w = (1::'b))"
 | 
|
863  | 
  "((1::'b::{numeral,one,real_normed_vector} star) \<approx> numeral w) = (numeral w = (1::'b))"
 | 
|
864  | 
  "\<not> (0 \<approx> (1::'c::{zero_neq_one,real_normed_vector} star))"
 | 
|
865  | 
  "\<not> (1 \<approx> (0::'c::{zero_neq_one,real_normed_vector} star))"
 | 
|
| 70221 | 866  | 
unfolding star_numeral_def star_zero_def star_one_def star_of_approx_iff  | 
867  | 
by (auto intro: sym)  | 
|
| 27468 | 868  | 
|
| 64435 | 869  | 
lemma star_of_approx_numeral_iff [simp]: "star_of k \<approx> numeral w \<longleftrightarrow> k = numeral w"  | 
870  | 
by (subst star_of_approx_iff [symmetric]) auto  | 
|
| 27468 | 871  | 
|
| 64435 | 872  | 
lemma star_of_approx_zero_iff [simp]: "star_of k \<approx> 0 \<longleftrightarrow> k = 0"  | 
873  | 
by (simp_all add: star_of_approx_iff [symmetric])  | 
|
| 27468 | 874  | 
|
| 64435 | 875  | 
lemma star_of_approx_one_iff [simp]: "star_of k \<approx> 1 \<longleftrightarrow> k = 1"  | 
876  | 
by (simp_all add: star_of_approx_iff [symmetric])  | 
|
| 27468 | 877  | 
|
| 64435 | 878  | 
lemma approx_unique_real: "r \<in> \<real> \<Longrightarrow> s \<in> \<real> \<Longrightarrow> r \<approx> x \<Longrightarrow> s \<approx> x \<Longrightarrow> r = s"  | 
879  | 
for r s :: hypreal  | 
|
880  | 
by (blast intro: SReal_approx_iff [THEN iffD1] approx_trans2)  | 
|
| 27468 | 881  | 
|
882  | 
||
| 64435 | 883  | 
subsection \<open>Existence of Unique Real Infinitely Close\<close>  | 
| 27468 | 884  | 
|
| 64435 | 885  | 
subsubsection \<open>Lifting of the Ub and Lub Properties\<close>  | 
| 27468 | 886  | 
|
| 64435 | 887  | 
lemma hypreal_of_real_isUb_iff: "isUb \<real> (hypreal_of_real ` Q) (hypreal_of_real Y) = isUb UNIV Q Y"  | 
888  | 
for Q :: "real set" and Y :: real  | 
|
889  | 
by (simp add: isUb_def setle_def)  | 
|
| 27468 | 890  | 
|
| 70221 | 891  | 
lemma hypreal_of_real_isLub_iff:  | 
| 70224 | 892  | 
"isLub \<real> (hypreal_of_real ` Q) (hypreal_of_real Y) = isLub (UNIV :: real set) Q Y" (is "?lhs = ?rhs")  | 
| 64435 | 893  | 
for Q :: "real set" and Y :: real  | 
| 70221 | 894  | 
proof  | 
895  | 
assume ?lhs  | 
|
896  | 
then show ?rhs  | 
|
897  | 
by (simp add: isLub_def leastP_def) (metis hypreal_of_real_isUb_iff mem_Collect_eq setge_def star_of_le)  | 
|
898  | 
next  | 
|
899  | 
assume ?rhs  | 
|
900  | 
then show ?lhs  | 
|
901  | 
apply (simp add: isLub_def leastP_def hypreal_of_real_isUb_iff setge_def)  | 
|
902  | 
by (metis SReal_iff hypreal_of_real_isUb_iff isUb_def star_of_le)  | 
|
903  | 
qed  | 
|
| 27468 | 904  | 
|
| 64435 | 905  | 
lemma lemma_isUb_hypreal_of_real: "isUb \<real> P Y \<Longrightarrow> \<exists>Yo. isUb \<real> P (hypreal_of_real Yo)"  | 
906  | 
by (auto simp add: SReal_iff isUb_def)  | 
|
907  | 
||
908  | 
lemma lemma_isLub_hypreal_of_real: "isLub \<real> P Y \<Longrightarrow> \<exists>Yo. isLub \<real> P (hypreal_of_real Yo)"  | 
|
909  | 
by (auto simp add: isLub_def leastP_def isUb_def SReal_iff)  | 
|
| 27468 | 910  | 
|
| 70221 | 911  | 
lemma SReal_complete:  | 
912  | 
fixes P :: "hypreal set"  | 
|
913  | 
  assumes "isUb \<real> P Y" "P \<subseteq> \<real>" "P \<noteq> {}"
 | 
|
914  | 
shows "\<exists>t. isLub \<real> P t"  | 
|
915  | 
proof -  | 
|
916  | 
obtain Q where "P = hypreal_of_real ` Q"  | 
|
917  | 
by (metis \<open>P \<subseteq> \<real>\<close> hypreal_of_real_image subset_imageE)  | 
|
918  | 
then show ?thesis  | 
|
919  | 
    by (metis assms(1) \<open>P \<noteq> {}\<close> equals0I hypreal_of_real_isLub_iff hypreal_of_real_isUb_iff image_empty lemma_isUb_hypreal_of_real reals_complete)
 | 
|
920  | 
qed  | 
|
| 64435 | 921  | 
|
| 27468 | 922  | 
|
| 64435 | 923  | 
text \<open>Lemmas about lubs.\<close>  | 
| 27468 | 924  | 
|
| 70221 | 925  | 
lemma lemma_st_part_lub:  | 
926  | 
fixes x :: hypreal  | 
|
927  | 
assumes "x \<in> HFinite"  | 
|
928  | 
  shows "\<exists>t. isLub \<real> {s. s \<in> \<real> \<and> s < x} t"
 | 
|
929  | 
proof -  | 
|
930  | 
obtain t where t: "t \<in> \<real>" "hnorm x < t"  | 
|
931  | 
using HFiniteD assms by blast  | 
|
932  | 
  then have "isUb \<real> {s. s \<in> \<real> \<and> s < x} t"
 | 
|
933  | 
by (simp add: abs_less_iff isUbI le_less_linear less_imp_not_less setleI)  | 
|
934  | 
moreover have "\<exists>y. y \<in> \<real> \<and> y < x"  | 
|
935  | 
using t by (rule_tac x = "-t" in exI) (auto simp add: abs_less_iff)  | 
|
936  | 
ultimately show ?thesis  | 
|
937  | 
using SReal_complete by fastforce  | 
|
938  | 
qed  | 
|
| 27468 | 939  | 
|
| 64435 | 940  | 
lemma hypreal_setle_less_trans: "S *<= x \<Longrightarrow> x < y \<Longrightarrow> S *<= y"  | 
941  | 
for x y :: hypreal  | 
|
| 70221 | 942  | 
by (meson le_less_trans less_imp_le setle_def)  | 
| 27468 | 943  | 
|
| 64435 | 944  | 
lemma hypreal_gt_isUb: "isUb R S x \<Longrightarrow> x < y \<Longrightarrow> y \<in> R \<Longrightarrow> isUb R S y"  | 
945  | 
for x y :: hypreal  | 
|
| 70221 | 946  | 
using hypreal_setle_less_trans isUb_def by blast  | 
| 27468 | 947  | 
|
| 64435 | 948  | 
lemma lemma_SReal_ub: "x \<in> \<real> \<Longrightarrow> isUb \<real> {s. s \<in> \<real> \<and> s < x} x"
 | 
949  | 
for x :: hypreal  | 
|
950  | 
by (auto intro: isUbI setleI order_less_imp_le)  | 
|
| 27468 | 951  | 
|
| 70224 | 952  | 
lemma lemma_SReal_lub:  | 
953  | 
fixes x :: hypreal  | 
|
954  | 
  assumes "x \<in> \<real>" shows "isLub \<real> {s. s \<in> \<real> \<and> s < x} x"
 | 
|
955  | 
proof -  | 
|
956  | 
  have "x \<le> y" if "isUb \<real> {s \<in> \<real>. s < x} y" for y
 | 
|
957  | 
proof -  | 
|
958  | 
have "y \<in> \<real>"  | 
|
959  | 
using isUbD2a that by blast  | 
|
960  | 
show ?thesis  | 
|
961  | 
proof (cases x y rule: linorder_cases)  | 
|
962  | 
case greater  | 
|
963  | 
then obtain r where "y < r" "r < x"  | 
|
964  | 
using dense by blast  | 
|
965  | 
then show ?thesis  | 
|
| 70232 | 966  | 
using isUbD [OF that]  | 
967  | 
by simp (meson SReal_dense \<open>y \<in> \<real>\<close> assms greater not_le)  | 
|
| 70224 | 968  | 
qed auto  | 
969  | 
qed  | 
|
970  | 
with assms show ?thesis  | 
|
971  | 
by (simp add: isLubI2 isUbI setgeI setleI)  | 
|
972  | 
qed  | 
|
| 27468 | 973  | 
|
974  | 
lemma lemma_st_part_major:  | 
|
| 70224 | 975  | 
fixes x r t :: hypreal  | 
976  | 
  assumes x: "x \<in> HFinite" and r: "r \<in> \<real>" "0 < r" and t: "isLub \<real> {s. s \<in> \<real> \<and> s < x} t"
 | 
|
977  | 
shows "\<bar>x - t\<bar> < r"  | 
|
978  | 
proof -  | 
|
979  | 
have "t \<in> \<real>"  | 
|
980  | 
using isLubD1a t by blast  | 
|
981  | 
  have lemma_st_part_gt_ub: "x < r \<Longrightarrow> r \<in> \<real> \<Longrightarrow> isUb \<real> {s. s \<in> \<real> \<and> s < x} r"
 | 
|
982  | 
for r :: hypreal  | 
|
983  | 
by (auto dest: order_less_trans intro: order_less_imp_le intro!: isUbI setleI)  | 
|
984  | 
||
985  | 
  have "isUb \<real> {s \<in> \<real>. s < x} t"
 | 
|
986  | 
by (simp add: t isLub_isUb)  | 
|
987  | 
then have "\<not> r + t < x"  | 
|
988  | 
by (metis (mono_tags, lifting) Reals_add \<open>t \<in> \<real>\<close> add_le_same_cancel2 isUbD leD mem_Collect_eq r)  | 
|
989  | 
then have "x - t \<le> r"  | 
|
990  | 
by simp  | 
|
991  | 
moreover have "\<not> x < t - r"  | 
|
992  | 
using lemma_st_part_gt_ub isLub_le_isUb \<open>t \<in> \<real>\<close> r t x by fastforce  | 
|
993  | 
then have "- (x - t) \<le> r"  | 
|
994  | 
by linarith  | 
|
995  | 
moreover have False if "x - t = r \<or> - (x - t) = r"  | 
|
996  | 
proof -  | 
|
997  | 
have "x \<in> \<real>"  | 
|
998  | 
by (metis \<open>t \<in> \<real>\<close> \<open>r \<in> \<real>\<close> that Reals_add_cancel Reals_minus_iff add_uminus_conv_diff)  | 
|
999  | 
    then have "isLub \<real> {s \<in> \<real>. s < x} x"
 | 
|
1000  | 
by (rule lemma_SReal_lub)  | 
|
1001  | 
then show False  | 
|
1002  | 
using r t that x isLub_unique by force  | 
|
1003  | 
qed  | 
|
1004  | 
ultimately show ?thesis  | 
|
1005  | 
using abs_less_iff dual_order.order_iff_strict by blast  | 
|
1006  | 
qed  | 
|
| 27468 | 1007  | 
|
1008  | 
lemma lemma_st_part_major2:  | 
|
| 64435 | 1009  | 
  "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"
 | 
1010  | 
for x t :: hypreal  | 
|
1011  | 
by (blast dest!: lemma_st_part_major)  | 
|
| 27468 | 1012  | 
|
| 
61649
 
268d88ec9087
Tweaks for "real": Removal of [iff] status for some lemmas, adding [simp] for others. Plus fixes.
 
paulson <lp15@cam.ac.uk> 
parents: 
61609 
diff
changeset
 | 
1013  | 
|
| 64435 | 1014  | 
text\<open>Existence of real and Standard Part Theorem.\<close>  | 
1015  | 
||
1016  | 
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"  | 
|
1017  | 
for x :: hypreal  | 
|
| 70221 | 1018  | 
by (meson isLubD1a lemma_st_part_lub lemma_st_part_major2)  | 
| 27468 | 1019  | 
|
| 64435 | 1020  | 
lemma st_part_Ex: "x \<in> HFinite \<Longrightarrow> \<exists>t\<in>Reals. x \<approx> t"  | 
1021  | 
for x :: hypreal  | 
|
| 70221 | 1022  | 
by (metis InfinitesimalI approx_def hypreal_hnorm_def lemma_st_part_Ex)  | 
| 27468 | 1023  | 
|
| 64435 | 1024  | 
text \<open>There is a unique real infinitely close.\<close>  | 
1025  | 
lemma st_part_Ex1: "x \<in> HFinite \<Longrightarrow> \<exists>!t::hypreal. t \<in> \<real> \<and> x \<approx> t"  | 
|
| 70221 | 1026  | 
by (meson SReal_approx_iff approx_trans2 st_part_Ex)  | 
| 27468 | 1027  | 
|
| 64435 | 1028  | 
|
1029  | 
subsection \<open>Finite, Infinite and Infinitesimal\<close>  | 
|
| 27468 | 1030  | 
|
1031  | 
lemma HFinite_Int_HInfinite_empty [simp]: "HFinite Int HInfinite = {}"
 | 
|
| 70221 | 1032  | 
using Compl_HFinite by blast  | 
| 27468 | 1033  | 
|
| 
56217
 
dc429a5b13c4
Some rationalisation of basic lemmas
 
paulson <lp15@cam.ac.uk> 
parents: 
54489 
diff
changeset
 | 
1034  | 
lemma HFinite_not_HInfinite:  | 
| 70221 | 1035  | 
assumes x: "x \<in> HFinite" shows "x \<notin> HInfinite"  | 
1036  | 
using Compl_HFinite x by blast  | 
|
| 27468 | 1037  | 
|
| 64435 | 1038  | 
lemma not_HFinite_HInfinite: "x \<notin> HFinite \<Longrightarrow> x \<in> HInfinite"  | 
| 70221 | 1039  | 
using Compl_HFinite by blast  | 
| 27468 | 1040  | 
|
| 64435 | 1041  | 
lemma HInfinite_HFinite_disj: "x \<in> HInfinite \<or> x \<in> HFinite"  | 
1042  | 
by (blast intro: not_HFinite_HInfinite)  | 
|
| 27468 | 1043  | 
|
| 64435 | 1044  | 
lemma HInfinite_HFinite_iff: "x \<in> HInfinite \<longleftrightarrow> x \<notin> HFinite"  | 
1045  | 
by (blast dest: HFinite_not_HInfinite not_HFinite_HInfinite)  | 
|
| 27468 | 1046  | 
|
| 64435 | 1047  | 
lemma HFinite_HInfinite_iff: "x \<in> HFinite \<longleftrightarrow> x \<notin> HInfinite"  | 
1048  | 
by (simp add: HInfinite_HFinite_iff)  | 
|
| 27468 | 1049  | 
|
1050  | 
lemma HInfinite_diff_HFinite_Infinitesimal_disj:  | 
|
| 64435 | 1051  | 
"x \<notin> Infinitesimal \<Longrightarrow> x \<in> HInfinite \<or> x \<in> HFinite - Infinitesimal"  | 
1052  | 
by (fast intro: not_HFinite_HInfinite)  | 
|
| 27468 | 1053  | 
|
| 64435 | 1054  | 
lemma HFinite_inverse: "x \<in> HFinite \<Longrightarrow> x \<notin> Infinitesimal \<Longrightarrow> inverse x \<in> HFinite"  | 
1055  | 
for x :: "'a::real_normed_div_algebra star"  | 
|
| 70221 | 1056  | 
using HInfinite_inverse_Infinitesimal not_HFinite_HInfinite by force  | 
| 27468 | 1057  | 
|
| 64435 | 1058  | 
lemma HFinite_inverse2: "x \<in> HFinite - Infinitesimal \<Longrightarrow> inverse x \<in> HFinite"  | 
1059  | 
for x :: "'a::real_normed_div_algebra star"  | 
|
1060  | 
by (blast intro: HFinite_inverse)  | 
|
| 27468 | 1061  | 
|
| 64435 | 1062  | 
text \<open>Stronger statement possible in fact.\<close>  | 
1063  | 
lemma Infinitesimal_inverse_HFinite: "x \<notin> Infinitesimal \<Longrightarrow> inverse x \<in> HFinite"  | 
|
1064  | 
for x :: "'a::real_normed_div_algebra star"  | 
|
| 70221 | 1065  | 
using HFinite_HInfinite_iff HInfinite_inverse_Infinitesimal by fastforce  | 
| 27468 | 1066  | 
|
1067  | 
lemma HFinite_not_Infinitesimal_inverse:  | 
|
| 64435 | 1068  | 
"x \<in> HFinite - Infinitesimal \<Longrightarrow> inverse x \<in> HFinite - Infinitesimal"  | 
1069  | 
for x :: "'a::real_normed_div_algebra star"  | 
|
| 70221 | 1070  | 
using HFinite_Infinitesimal_not_zero HFinite_inverse2 Infinitesimal_HFinite_mult2 by fastforce  | 
| 27468 | 1071  | 
|
| 70224 | 1072  | 
lemma approx_inverse:  | 
1073  | 
fixes x y :: "'a::real_normed_div_algebra star"  | 
|
1074  | 
assumes "x \<approx> y" and y: "y \<in> HFinite - Infinitesimal" shows "inverse x \<approx> inverse y"  | 
|
1075  | 
proof -  | 
|
1076  | 
have x: "x \<in> HFinite - Infinitesimal"  | 
|
1077  | 
using HFinite_diff_Infinitesimal_approx assms(1) y by blast  | 
|
1078  | 
with y HFinite_inverse2 have "inverse x \<in> HFinite" "inverse y \<in> HFinite"  | 
|
1079  | 
by blast+  | 
|
1080  | 
then have "inverse y * x \<approx> 1"  | 
|
1081  | 
by (metis Diff_iff approx_mult2 assms(1) left_inverse not_Infinitesimal_not_zero y)  | 
|
1082  | 
then show ?thesis  | 
|
1083  | 
by (metis (no_types, lifting) DiffD2 HFinite_Infinitesimal_not_zero Infinitesimal_mult_disj x approx_def approx_sym left_diff_distrib left_inverse)  | 
|
1084  | 
qed  | 
|
| 27468 | 1085  | 
|
1086  | 
(*Used for NSLIM_inverse, NSLIMSEQ_inverse*)  | 
|
1087  | 
lemmas star_of_approx_inverse = star_of_HFinite_diff_Infinitesimal [THEN [2] approx_inverse]  | 
|
1088  | 
lemmas hypreal_of_real_approx_inverse = hypreal_of_real_HFinite_diff_Infinitesimal [THEN [2] approx_inverse]  | 
|
1089  | 
||
1090  | 
lemma inverse_add_Infinitesimal_approx:  | 
|
| 64435 | 1091  | 
"x \<in> HFinite - Infinitesimal \<Longrightarrow> h \<in> Infinitesimal \<Longrightarrow> inverse (x + h) \<approx> inverse x"  | 
1092  | 
for x h :: "'a::real_normed_div_algebra star"  | 
|
1093  | 
by (auto intro: approx_inverse approx_sym Infinitesimal_add_approx_self)  | 
|
| 27468 | 1094  | 
|
1095  | 
lemma inverse_add_Infinitesimal_approx2:  | 
|
| 64435 | 1096  | 
"x \<in> HFinite - Infinitesimal \<Longrightarrow> h \<in> Infinitesimal \<Longrightarrow> inverse (h + x) \<approx> inverse x"  | 
1097  | 
for x h :: "'a::real_normed_div_algebra star"  | 
|
| 70221 | 1098  | 
by (metis add.commute inverse_add_Infinitesimal_approx)  | 
| 27468 | 1099  | 
|
1100  | 
lemma inverse_add_Infinitesimal_approx_Infinitesimal:  | 
|
| 64435 | 1101  | 
"x \<in> HFinite - Infinitesimal \<Longrightarrow> h \<in> Infinitesimal \<Longrightarrow> inverse (x + h) - inverse x \<approx> h"  | 
1102  | 
for x h :: "'a::real_normed_div_algebra star"  | 
|
| 70221 | 1103  | 
by (meson Infinitesimal_approx bex_Infinitesimal_iff inverse_add_Infinitesimal_approx)  | 
| 27468 | 1104  | 
|
| 64435 | 1105  | 
lemma Infinitesimal_square_iff: "x \<in> Infinitesimal \<longleftrightarrow> x * x \<in> Infinitesimal"  | 
1106  | 
for x :: "'a::real_normed_div_algebra star"  | 
|
| 70221 | 1107  | 
using Infinitesimal_mult Infinitesimal_mult_disj by auto  | 
| 27468 | 1108  | 
declare Infinitesimal_square_iff [symmetric, simp]  | 
1109  | 
||
| 64435 | 1110  | 
lemma HFinite_square_iff [simp]: "x * x \<in> HFinite \<longleftrightarrow> x \<in> HFinite"  | 
1111  | 
for x :: "'a::real_normed_div_algebra star"  | 
|
| 70221 | 1112  | 
using HFinite_HInfinite_iff HFinite_mult HInfinite_mult by blast  | 
| 27468 | 1113  | 
|
| 64435 | 1114  | 
lemma HInfinite_square_iff [simp]: "x * x \<in> HInfinite \<longleftrightarrow> x \<in> HInfinite"  | 
1115  | 
for x :: "'a::real_normed_div_algebra star"  | 
|
1116  | 
by (auto simp add: HInfinite_HFinite_iff)  | 
|
| 27468 | 1117  | 
|
| 64435 | 1118  | 
lemma approx_HFinite_mult_cancel: "a \<in> HFinite - Infinitesimal \<Longrightarrow> a * w \<approx> a * z \<Longrightarrow> w \<approx> z"  | 
1119  | 
for a w z :: "'a::real_normed_div_algebra star"  | 
|
| 70221 | 1120  | 
by (metis DiffD2 Infinitesimal_mult_disj bex_Infinitesimal_iff right_diff_distrib)  | 
| 27468 | 1121  | 
|
| 64435 | 1122  | 
lemma approx_HFinite_mult_cancel_iff1: "a \<in> HFinite - Infinitesimal \<Longrightarrow> a * w \<approx> a * z \<longleftrightarrow> w \<approx> z"  | 
1123  | 
for a w z :: "'a::real_normed_div_algebra star"  | 
|
1124  | 
by (auto intro: approx_mult2 approx_HFinite_mult_cancel)  | 
|
| 27468 | 1125  | 
|
| 64435 | 1126  | 
lemma HInfinite_HFinite_add_cancel: "x + y \<in> HInfinite \<Longrightarrow> y \<in> HFinite \<Longrightarrow> x \<in> HInfinite"  | 
| 70221 | 1127  | 
using HFinite_add HInfinite_HFinite_iff by blast  | 
| 27468 | 1128  | 
|
| 64435 | 1129  | 
lemma HInfinite_HFinite_add: "x \<in> HInfinite \<Longrightarrow> y \<in> HFinite \<Longrightarrow> x + y \<in> HInfinite"  | 
| 
73932
 
fd21b4a93043
added opaque_combs and renamed hide_lams to opaque_lifting
 
desharna 
parents: 
70723 
diff
changeset
 | 
1130  | 
by (metis (no_types, opaque_lifting) HFinite_HInfinite_iff HFinite_add HFinite_minus_iff add.commute add_minus_cancel)  | 
| 27468 | 1131  | 
|
| 64435 | 1132  | 
lemma HInfinite_ge_HInfinite: "x \<in> HInfinite \<Longrightarrow> x \<le> y \<Longrightarrow> 0 \<le> x \<Longrightarrow> y \<in> HInfinite"  | 
1133  | 
for x y :: hypreal  | 
|
1134  | 
by (auto intro: HFinite_bounded simp add: HInfinite_HFinite_iff)  | 
|
| 27468 | 1135  | 
|
| 64435 | 1136  | 
lemma Infinitesimal_inverse_HInfinite: "x \<in> Infinitesimal \<Longrightarrow> x \<noteq> 0 \<Longrightarrow> inverse x \<in> HInfinite"  | 
1137  | 
for x :: "'a::real_normed_div_algebra star"  | 
|
| 70221 | 1138  | 
by (metis Infinitesimal_HFinite_mult not_HFinite_HInfinite one_not_Infinitesimal right_inverse)  | 
| 27468 | 1139  | 
|
1140  | 
lemma HInfinite_HFinite_not_Infinitesimal_mult:  | 
|
| 64435 | 1141  | 
"x \<in> HInfinite \<Longrightarrow> y \<in> HFinite - Infinitesimal \<Longrightarrow> x * y \<in> HInfinite"  | 
1142  | 
for x y :: "'a::real_normed_div_algebra star"  | 
|
| 
73932
 
fd21b4a93043
added opaque_combs and renamed hide_lams to opaque_lifting
 
desharna 
parents: 
70723 
diff
changeset
 | 
1143  | 
by (metis (no_types, opaque_lifting) HFinite_HInfinite_iff HFinite_Infinitesimal_not_zero HFinite_inverse2 HFinite_mult mult.assoc mult.right_neutral right_inverse)  | 
| 27468 | 1144  | 
|
1145  | 
lemma HInfinite_HFinite_not_Infinitesimal_mult2:  | 
|
| 64435 | 1146  | 
"x \<in> HInfinite \<Longrightarrow> y \<in> HFinite - Infinitesimal \<Longrightarrow> y * x \<in> HInfinite"  | 
1147  | 
for x y :: "'a::real_normed_div_algebra star"  | 
|
| 70221 | 1148  | 
by (metis Diff_iff HInfinite_HFinite_iff HInfinite_inverse_Infinitesimal Infinitesimal_HFinite_mult2 divide_inverse mult_zero_right nonzero_eq_divide_eq)  | 
| 27468 | 1149  | 
|
| 64435 | 1150  | 
lemma HInfinite_gt_SReal: "x \<in> HInfinite \<Longrightarrow> 0 < x \<Longrightarrow> y \<in> \<real> \<Longrightarrow> y < x"  | 
1151  | 
for x y :: hypreal  | 
|
1152  | 
by (auto dest!: bspec simp add: HInfinite_def abs_if order_less_imp_le)  | 
|
| 27468 | 1153  | 
|
| 64435 | 1154  | 
lemma HInfinite_gt_zero_gt_one: "x \<in> HInfinite \<Longrightarrow> 0 < x \<Longrightarrow> 1 < x"  | 
1155  | 
for x :: hypreal  | 
|
1156  | 
by (auto intro: HInfinite_gt_SReal)  | 
|
| 27468 | 1157  | 
|
1158  | 
lemma not_HInfinite_one [simp]: "1 \<notin> HInfinite"  | 
|
| 64435 | 1159  | 
by (simp add: HInfinite_HFinite_iff)  | 
| 27468 | 1160  | 
|
| 64435 | 1161  | 
lemma approx_hrabs_disj: "\<bar>x\<bar> \<approx> x \<or> \<bar>x\<bar> \<approx> -x"  | 
1162  | 
for x :: hypreal  | 
|
| 70232 | 1163  | 
by (simp add: abs_if)  | 
| 27468 | 1164  | 
|
1165  | 
||
| 64435 | 1166  | 
subsection \<open>Theorems about Monads\<close>  | 
| 27468 | 1167  | 
|
| 64435 | 1168  | 
lemma monad_hrabs_Un_subset: "monad \<bar>x\<bar> \<le> monad x \<union> monad (- x)"  | 
1169  | 
for x :: hypreal  | 
|
| 70232 | 1170  | 
by (simp add: abs_if)  | 
| 27468 | 1171  | 
|
| 64435 | 1172  | 
lemma Infinitesimal_monad_eq: "e \<in> Infinitesimal \<Longrightarrow> monad (x + e) = monad x"  | 
1173  | 
by (fast intro!: Infinitesimal_add_approx_self [THEN approx_sym] approx_monad_iff [THEN iffD1])  | 
|
| 27468 | 1174  | 
|
| 64435 | 1175  | 
lemma mem_monad_iff: "u \<in> monad x \<longleftrightarrow> - u \<in> monad (- x)"  | 
1176  | 
by (simp add: monad_def)  | 
|
1177  | 
||
1178  | 
lemma Infinitesimal_monad_zero_iff: "x \<in> Infinitesimal \<longleftrightarrow> x \<in> monad 0"  | 
|
1179  | 
by (auto intro: approx_sym simp add: monad_def mem_infmal_iff)  | 
|
| 27468 | 1180  | 
|
| 64435 | 1181  | 
lemma monad_zero_minus_iff: "x \<in> monad 0 \<longleftrightarrow> - x \<in> monad 0"  | 
1182  | 
by (simp add: Infinitesimal_monad_zero_iff [symmetric])  | 
|
| 27468 | 1183  | 
|
| 64435 | 1184  | 
lemma monad_zero_hrabs_iff: "x \<in> monad 0 \<longleftrightarrow> \<bar>x\<bar> \<in> monad 0"  | 
1185  | 
for x :: hypreal  | 
|
| 70232 | 1186  | 
using Infinitesimal_monad_zero_iff by blast  | 
| 27468 | 1187  | 
|
1188  | 
lemma mem_monad_self [simp]: "x \<in> monad x"  | 
|
| 64435 | 1189  | 
by (simp add: monad_def)  | 
| 27468 | 1190  | 
|
1191  | 
||
| 69597 | 1192  | 
subsection \<open>Proof that \<^term>\<open>x \<approx> y\<close> implies \<^term>\<open>\<bar>x\<bar> \<approx> \<bar>y\<bar>\<close>\<close>  | 
| 27468 | 1193  | 
|
| 64435 | 1194  | 
lemma approx_subset_monad: "x \<approx> y \<Longrightarrow> {x, y} \<le> monad x"
 | 
1195  | 
by (simp (no_asm)) (simp add: approx_monad_iff)  | 
|
| 27468 | 1196  | 
|
| 64435 | 1197  | 
lemma approx_subset_monad2: "x \<approx> y \<Longrightarrow> {x, y} \<le> monad y"
 | 
| 70221 | 1198  | 
using approx_subset_monad approx_sym by auto  | 
| 27468 | 1199  | 
|
| 64435 | 1200  | 
lemma mem_monad_approx: "u \<in> monad x \<Longrightarrow> x \<approx> u"  | 
1201  | 
by (simp add: monad_def)  | 
|
1202  | 
||
1203  | 
lemma approx_mem_monad: "x \<approx> u \<Longrightarrow> u \<in> monad x"  | 
|
1204  | 
by (simp add: monad_def)  | 
|
| 27468 | 1205  | 
|
| 64435 | 1206  | 
lemma approx_mem_monad2: "x \<approx> u \<Longrightarrow> x \<in> monad u"  | 
| 70221 | 1207  | 
using approx_mem_monad approx_sym by blast  | 
| 27468 | 1208  | 
|
| 64435 | 1209  | 
lemma approx_mem_monad_zero: "x \<approx> y \<Longrightarrow> x \<in> monad 0 \<Longrightarrow> y \<in> monad 0"  | 
| 70221 | 1210  | 
using approx_trans monad_def by blast  | 
| 27468 | 1211  | 
|
| 64435 | 1212  | 
lemma Infinitesimal_approx_hrabs: "x \<approx> y \<Longrightarrow> x \<in> Infinitesimal \<Longrightarrow> \<bar>x\<bar> \<approx> \<bar>y\<bar>"  | 
1213  | 
for x y :: hypreal  | 
|
| 70221 | 1214  | 
using approx_hnorm by fastforce  | 
| 27468 | 1215  | 
|
| 64435 | 1216  | 
lemma less_Infinitesimal_less: "0 < x \<Longrightarrow> x \<notin> Infinitesimal \<Longrightarrow> e \<in> Infinitesimal \<Longrightarrow> e < x"  | 
1217  | 
for x :: hypreal  | 
|
| 70221 | 1218  | 
using Infinitesimal_interval less_linear by blast  | 
| 27468 | 1219  | 
|
| 64435 | 1220  | 
lemma Ball_mem_monad_gt_zero: "0 < x \<Longrightarrow> x \<notin> Infinitesimal \<Longrightarrow> u \<in> monad x \<Longrightarrow> 0 < u"  | 
1221  | 
for u x :: hypreal  | 
|
| 70224 | 1222  | 
by (metis bex_Infinitesimal_iff2 less_Infinitesimal_less less_add_same_cancel2 mem_monad_approx)  | 
| 27468 | 1223  | 
|
| 64435 | 1224  | 
lemma Ball_mem_monad_less_zero: "x < 0 \<Longrightarrow> x \<notin> Infinitesimal \<Longrightarrow> u \<in> monad x \<Longrightarrow> u < 0"  | 
1225  | 
for u x :: hypreal  | 
|
| 70224 | 1226  | 
by (metis Ball_mem_monad_gt_zero approx_monad_iff less_asym linorder_neqE_linordered_idom mem_infmal_iff mem_monad_approx mem_monad_self)  | 
| 27468 | 1227  | 
|
| 64435 | 1228  | 
lemma lemma_approx_gt_zero: "0 < x \<Longrightarrow> x \<notin> Infinitesimal \<Longrightarrow> x \<approx> y \<Longrightarrow> 0 < y"  | 
1229  | 
for x y :: hypreal  | 
|
1230  | 
by (blast dest: Ball_mem_monad_gt_zero approx_subset_monad)  | 
|
| 27468 | 1231  | 
|
| 64435 | 1232  | 
lemma lemma_approx_less_zero: "x < 0 \<Longrightarrow> x \<notin> Infinitesimal \<Longrightarrow> x \<approx> y \<Longrightarrow> y < 0"  | 
1233  | 
for x y :: hypreal  | 
|
1234  | 
by (blast dest: Ball_mem_monad_less_zero approx_subset_monad)  | 
|
| 27468 | 1235  | 
|
| 64435 | 1236  | 
lemma approx_hrabs: "x \<approx> y \<Longrightarrow> \<bar>x\<bar> \<approx> \<bar>y\<bar>"  | 
1237  | 
for x y :: hypreal  | 
|
1238  | 
by (drule approx_hnorm) simp  | 
|
| 27468 | 1239  | 
|
| 64435 | 1240  | 
lemma approx_hrabs_zero_cancel: "\<bar>x\<bar> \<approx> 0 \<Longrightarrow> x \<approx> 0"  | 
1241  | 
for x :: hypreal  | 
|
| 70232 | 1242  | 
using mem_infmal_iff by blast  | 
| 27468 | 1243  | 
|
| 64435 | 1244  | 
lemma approx_hrabs_add_Infinitesimal: "e \<in> Infinitesimal \<Longrightarrow> \<bar>x\<bar> \<approx> \<bar>x + e\<bar>"  | 
1245  | 
for e x :: hypreal  | 
|
1246  | 
by (fast intro: approx_hrabs Infinitesimal_add_approx_self)  | 
|
| 27468 | 1247  | 
|
| 64435 | 1248  | 
lemma approx_hrabs_add_minus_Infinitesimal: "e \<in> Infinitesimal ==> \<bar>x\<bar> \<approx> \<bar>x + -e\<bar>"  | 
1249  | 
for e x :: hypreal  | 
|
1250  | 
by (fast intro: approx_hrabs Infinitesimal_add_minus_approx_self)  | 
|
| 27468 | 1251  | 
|
1252  | 
lemma hrabs_add_Infinitesimal_cancel:  | 
|
| 64435 | 1253  | 
"e \<in> Infinitesimal \<Longrightarrow> e' \<in> Infinitesimal \<Longrightarrow> \<bar>x + e\<bar> = \<bar>y + e'\<bar> \<Longrightarrow> \<bar>x\<bar> \<approx> \<bar>y\<bar>"  | 
1254  | 
for e e' x y :: hypreal  | 
|
| 70221 | 1255  | 
by (metis approx_hrabs_add_Infinitesimal approx_trans2)  | 
| 27468 | 1256  | 
|
1257  | 
lemma hrabs_add_minus_Infinitesimal_cancel:  | 
|
| 64435 | 1258  | 
"e \<in> Infinitesimal \<Longrightarrow> e' \<in> Infinitesimal \<Longrightarrow> \<bar>x + -e\<bar> = \<bar>y + -e'\<bar> \<Longrightarrow> \<bar>x\<bar> \<approx> \<bar>y\<bar>"  | 
1259  | 
for e e' x y :: hypreal  | 
|
| 70221 | 1260  | 
by (meson Infinitesimal_minus_iff hrabs_add_Infinitesimal_cancel)  | 
| 64435 | 1261  | 
|
| 27468 | 1262  | 
|
| 69597 | 1263  | 
subsection \<open>More \<^term>\<open>HFinite\<close> and \<^term>\<open>Infinitesimal\<close> Theorems\<close>  | 
| 27468 | 1264  | 
|
| 64435 | 1265  | 
text \<open>  | 
1266  | 
Interesting slightly counterintuitive theorem: necessary  | 
|
1267  | 
for proving that an open interval is an NS open set.  | 
|
1268  | 
\<close>  | 
|
| 27468 | 1269  | 
lemma Infinitesimal_add_hypreal_of_real_less:  | 
| 70224 | 1270  | 
assumes "x < y" and u: "u \<in> Infinitesimal"  | 
1271  | 
shows "hypreal_of_real x + u < hypreal_of_real y"  | 
|
1272  | 
proof -  | 
|
1273  | 
have "\<bar>u\<bar> < hypreal_of_real y - hypreal_of_real x"  | 
|
1274  | 
using InfinitesimalD \<open>x < y\<close> u by fastforce  | 
|
1275  | 
then show ?thesis  | 
|
1276  | 
by (simp add: abs_less_iff)  | 
|
1277  | 
qed  | 
|
| 27468 | 1278  | 
|
1279  | 
lemma Infinitesimal_add_hrabs_hypreal_of_real_less:  | 
|
| 64435 | 1280  | 
"x \<in> Infinitesimal \<Longrightarrow> \<bar>hypreal_of_real r\<bar> < hypreal_of_real y \<Longrightarrow>  | 
1281  | 
\<bar>hypreal_of_real r + x\<bar> < hypreal_of_real y"  | 
|
| 70224 | 1282  | 
by (metis Infinitesimal_add_hypreal_of_real_less approx_hrabs_add_Infinitesimal approx_sym bex_Infinitesimal_iff2 star_of_abs star_of_less)  | 
| 27468 | 1283  | 
|
1284  | 
lemma Infinitesimal_add_hrabs_hypreal_of_real_less2:  | 
|
| 64435 | 1285  | 
"x \<in> Infinitesimal \<Longrightarrow> \<bar>hypreal_of_real r\<bar> < hypreal_of_real y \<Longrightarrow>  | 
1286  | 
\<bar>x + hypreal_of_real r\<bar> < hypreal_of_real y"  | 
|
| 70221 | 1287  | 
using Infinitesimal_add_hrabs_hypreal_of_real_less by fastforce  | 
| 27468 | 1288  | 
|
1289  | 
lemma hypreal_of_real_le_add_Infininitesimal_cancel:  | 
|
| 70224 | 1290  | 
assumes le: "hypreal_of_real x + u \<le> hypreal_of_real y + v"  | 
1291  | 
and u: "u \<in> Infinitesimal" and v: "v \<in> Infinitesimal"  | 
|
1292  | 
shows "hypreal_of_real x \<le> hypreal_of_real y"  | 
|
1293  | 
proof (rule ccontr)  | 
|
1294  | 
assume "\<not> hypreal_of_real x \<le> hypreal_of_real y"  | 
|
1295  | 
then have "hypreal_of_real y + (v - u) < hypreal_of_real x"  | 
|
1296  | 
by (simp add: Infinitesimal_add_hypreal_of_real_less Infinitesimal_diff u v)  | 
|
1297  | 
then show False  | 
|
1298  | 
by (simp add: add_diff_eq add_le_imp_le_diff le leD)  | 
|
1299  | 
qed  | 
|
| 27468 | 1300  | 
|
1301  | 
lemma hypreal_of_real_le_add_Infininitesimal_cancel2:  | 
|
| 64435 | 1302  | 
"u \<in> Infinitesimal \<Longrightarrow> v \<in> Infinitesimal \<Longrightarrow>  | 
1303  | 
hypreal_of_real x + u \<le> hypreal_of_real y + v \<Longrightarrow> x \<le> y"  | 
|
1304  | 
by (blast intro: star_of_le [THEN iffD1] intro!: hypreal_of_real_le_add_Infininitesimal_cancel)  | 
|
| 27468 | 1305  | 
|
1306  | 
lemma hypreal_of_real_less_Infinitesimal_le_zero:  | 
|
| 64435 | 1307  | 
"hypreal_of_real x < e \<Longrightarrow> e \<in> Infinitesimal \<Longrightarrow> hypreal_of_real x \<le> 0"  | 
| 70221 | 1308  | 
by (metis Infinitesimal_interval eq_iff le_less_linear star_of_Infinitesimal_iff_0 star_of_eq_0)  | 
| 27468 | 1309  | 
|
| 64435 | 1310  | 
lemma Infinitesimal_add_not_zero: "h \<in> Infinitesimal \<Longrightarrow> x \<noteq> 0 \<Longrightarrow> star_of x + h \<noteq> 0"  | 
| 70224 | 1311  | 
by (metis Infinitesimal_add_approx_self star_of_approx_zero_iff)  | 
| 27468 | 1312  | 
|
| 64435 | 1313  | 
lemma monad_hrabs_less: "y \<in> monad x \<Longrightarrow> 0 < hypreal_of_real e \<Longrightarrow> \<bar>y - x\<bar> < hypreal_of_real e"  | 
| 70221 | 1314  | 
by (simp add: Infinitesimal_approx_minus approx_sym less_Infinitesimal_less mem_monad_approx)  | 
| 27468 | 1315  | 
|
| 64435 | 1316  | 
lemma mem_monad_SReal_HFinite: "x \<in> monad (hypreal_of_real a) \<Longrightarrow> x \<in> HFinite"  | 
| 70221 | 1317  | 
using HFinite_star_of approx_HFinite mem_monad_approx by blast  | 
| 27468 | 1318  | 
|
1319  | 
||
| 64435 | 1320  | 
subsection \<open>Theorems about Standard Part\<close>  | 
| 27468 | 1321  | 
|
| 64435 | 1322  | 
lemma st_approx_self: "x \<in> HFinite \<Longrightarrow> st x \<approx> x"  | 
| 70221 | 1323  | 
by (metis (no_types, lifting) approx_refl approx_trans3 someI_ex st_def st_part_Ex st_part_Ex1)  | 
| 27468 | 1324  | 
|
| 64435 | 1325  | 
lemma st_SReal: "x \<in> HFinite \<Longrightarrow> st x \<in> \<real>"  | 
| 70224 | 1326  | 
by (metis (mono_tags, lifting) approx_sym someI_ex st_def st_part_Ex)  | 
| 27468 | 1327  | 
|
| 64435 | 1328  | 
lemma st_HFinite: "x \<in> HFinite \<Longrightarrow> st x \<in> HFinite"  | 
1329  | 
by (erule st_SReal [THEN SReal_subset_HFinite [THEN subsetD]])  | 
|
| 27468 | 1330  | 
|
| 64435 | 1331  | 
lemma st_unique: "r \<in> \<real> \<Longrightarrow> r \<approx> x \<Longrightarrow> st x = r"  | 
| 70224 | 1332  | 
by (meson SReal_subset_HFinite approx_HFinite approx_unique_real st_SReal st_approx_self subsetD)  | 
| 27468 | 1333  | 
|
| 64435 | 1334  | 
lemma st_SReal_eq: "x \<in> \<real> \<Longrightarrow> st x = x"  | 
| 
61649
 
268d88ec9087
Tweaks for "real": Removal of [iff] status for some lemmas, adding [simp] for others. Plus fixes.
 
paulson <lp15@cam.ac.uk> 
parents: 
61609 
diff
changeset
 | 
1335  | 
by (metis approx_refl st_unique)  | 
| 27468 | 1336  | 
|
1337  | 
lemma st_hypreal_of_real [simp]: "st (hypreal_of_real x) = hypreal_of_real x"  | 
|
| 64435 | 1338  | 
by (rule SReal_hypreal_of_real [THEN st_SReal_eq])  | 
| 27468 | 1339  | 
|
| 64435 | 1340  | 
lemma st_eq_approx: "x \<in> HFinite \<Longrightarrow> y \<in> HFinite \<Longrightarrow> st x = st y \<Longrightarrow> x \<approx> y"  | 
1341  | 
by (auto dest!: st_approx_self elim!: approx_trans3)  | 
|
| 27468 | 1342  | 
|
| 
56217
 
dc429a5b13c4
Some rationalisation of basic lemmas
 
paulson <lp15@cam.ac.uk> 
parents: 
54489 
diff
changeset
 | 
1343  | 
lemma approx_st_eq:  | 
| 61982 | 1344  | 
assumes x: "x \<in> HFinite" and y: "y \<in> HFinite" and xy: "x \<approx> y"  | 
| 27468 | 1345  | 
shows "st x = st y"  | 
1346  | 
proof -  | 
|
| 61982 | 1347  | 
have "st x \<approx> x" "st y \<approx> y" "st x \<in> \<real>" "st y \<in> \<real>"  | 
| 41541 | 1348  | 
by (simp_all add: st_approx_self st_SReal x y)  | 
1349  | 
with xy show ?thesis  | 
|
| 27468 | 1350  | 
by (fast elim: approx_trans approx_trans2 SReal_approx_iff [THEN iffD1])  | 
1351  | 
qed  | 
|
1352  | 
||
| 64435 | 1353  | 
lemma st_eq_approx_iff: "x \<in> HFinite \<Longrightarrow> y \<in> HFinite \<Longrightarrow> x \<approx> y \<longleftrightarrow> st x = st y"  | 
1354  | 
by (blast intro: approx_st_eq st_eq_approx)  | 
|
| 27468 | 1355  | 
|
| 64435 | 1356  | 
lemma st_Infinitesimal_add_SReal: "x \<in> \<real> \<Longrightarrow> e \<in> Infinitesimal \<Longrightarrow> st (x + e) = x"  | 
| 70224 | 1357  | 
by (simp add: Infinitesimal_add_approx_self st_unique)  | 
| 27468 | 1358  | 
|
| 64435 | 1359  | 
lemma st_Infinitesimal_add_SReal2: "x \<in> \<real> \<Longrightarrow> e \<in> Infinitesimal \<Longrightarrow> st (e + x) = x"  | 
| 70224 | 1360  | 
by (metis add.commute st_Infinitesimal_add_SReal)  | 
| 27468 | 1361  | 
|
| 64435 | 1362  | 
lemma HFinite_st_Infinitesimal_add: "x \<in> HFinite \<Longrightarrow> \<exists>e \<in> Infinitesimal. x = st(x) + e"  | 
1363  | 
by (blast dest!: st_approx_self [THEN approx_sym] bex_Infinitesimal_iff2 [THEN iffD2])  | 
|
| 27468 | 1364  | 
|
| 64435 | 1365  | 
lemma st_add: "x \<in> HFinite \<Longrightarrow> y \<in> HFinite \<Longrightarrow> st (x + y) = st x + st y"  | 
1366  | 
by (simp add: st_unique st_SReal st_approx_self approx_add)  | 
|
| 27468 | 1367  | 
|
| 
47108
 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
 
huffman 
parents: 
45541 
diff
changeset
 | 
1368  | 
lemma st_numeral [simp]: "st (numeral w) = numeral w"  | 
| 64435 | 1369  | 
by (rule Reals_numeral [THEN st_SReal_eq])  | 
| 
47108
 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
 
huffman 
parents: 
45541 
diff
changeset
 | 
1370  | 
|
| 
54489
 
03ff4d1e6784
eliminiated neg_numeral in favour of - (numeral _)
 
haftmann 
parents: 
54263 
diff
changeset
 | 
1371  | 
lemma st_neg_numeral [simp]: "st (- numeral w) = - numeral w"  | 
| 70224 | 1372  | 
using st_unique by auto  | 
| 27468 | 1373  | 
|
| 45540 | 1374  | 
lemma st_0 [simp]: "st 0 = 0"  | 
| 64435 | 1375  | 
by (simp add: st_SReal_eq)  | 
| 45540 | 1376  | 
|
1377  | 
lemma st_1 [simp]: "st 1 = 1"  | 
|
| 64435 | 1378  | 
by (simp add: st_SReal_eq)  | 
| 27468 | 1379  | 
|
| 
54489
 
03ff4d1e6784
eliminiated neg_numeral in favour of - (numeral _)
 
haftmann 
parents: 
54263 
diff
changeset
 | 
1380  | 
lemma st_neg_1 [simp]: "st (- 1) = - 1"  | 
| 64435 | 1381  | 
by (simp add: st_SReal_eq)  | 
| 
54489
 
03ff4d1e6784
eliminiated neg_numeral in favour of - (numeral _)
 
haftmann 
parents: 
54263 
diff
changeset
 | 
1382  | 
|
| 27468 | 1383  | 
lemma st_minus: "x \<in> HFinite \<Longrightarrow> st (- x) = - st x"  | 
| 64435 | 1384  | 
by (simp add: st_unique st_SReal st_approx_self approx_minus)  | 
| 27468 | 1385  | 
|
1386  | 
lemma st_diff: "\<lbrakk>x \<in> HFinite; y \<in> HFinite\<rbrakk> \<Longrightarrow> st (x - y) = st x - st y"  | 
|
| 64435 | 1387  | 
by (simp add: st_unique st_SReal st_approx_self approx_diff)  | 
| 27468 | 1388  | 
|
1389  | 
lemma st_mult: "\<lbrakk>x \<in> HFinite; y \<in> HFinite\<rbrakk> \<Longrightarrow> st (x * y) = st x * st y"  | 
|
| 64435 | 1390  | 
by (simp add: st_unique st_SReal st_approx_self approx_mult_HFinite)  | 
| 27468 | 1391  | 
|
| 64435 | 1392  | 
lemma st_Infinitesimal: "x \<in> Infinitesimal \<Longrightarrow> st x = 0"  | 
1393  | 
by (simp add: st_unique mem_infmal_iff)  | 
|
| 27468 | 1394  | 
|
| 64435 | 1395  | 
lemma st_not_Infinitesimal: "st(x) \<noteq> 0 \<Longrightarrow> x \<notin> Infinitesimal"  | 
| 27468 | 1396  | 
by (fast intro: st_Infinitesimal)  | 
1397  | 
||
| 64435 | 1398  | 
lemma st_inverse: "x \<in> HFinite \<Longrightarrow> st x \<noteq> 0 \<Longrightarrow> st (inverse x) = inverse (st x)"  | 
| 70224 | 1399  | 
by (simp add: approx_inverse st_SReal st_approx_self st_not_Infinitesimal st_unique)  | 
| 27468 | 1400  | 
|
| 64435 | 1401  | 
lemma st_divide [simp]: "x \<in> HFinite \<Longrightarrow> y \<in> HFinite \<Longrightarrow> st y \<noteq> 0 \<Longrightarrow> st (x / y) = st x / st y"  | 
1402  | 
by (simp add: divide_inverse st_mult st_not_Infinitesimal HFinite_inverse st_inverse)  | 
|
| 27468 | 1403  | 
|
| 64435 | 1404  | 
lemma st_idempotent [simp]: "x \<in> HFinite \<Longrightarrow> st (st x) = st x"  | 
1405  | 
by (blast intro: st_HFinite st_approx_self approx_st_eq)  | 
|
| 27468 | 1406  | 
|
1407  | 
lemma Infinitesimal_add_st_less:  | 
|
| 64435 | 1408  | 
"x \<in> HFinite \<Longrightarrow> y \<in> HFinite \<Longrightarrow> u \<in> Infinitesimal \<Longrightarrow> st x < st y \<Longrightarrow> st x + u < st y"  | 
| 70224 | 1409  | 
by (metis Infinitesimal_add_hypreal_of_real_less SReal_iff st_SReal star_of_less)  | 
| 27468 | 1410  | 
|
1411  | 
lemma Infinitesimal_add_st_le_cancel:  | 
|
| 64435 | 1412  | 
"x \<in> HFinite \<Longrightarrow> y \<in> HFinite \<Longrightarrow> u \<in> Infinitesimal \<Longrightarrow>  | 
1413  | 
st x \<le> st y + u \<Longrightarrow> st x \<le> st y"  | 
|
| 70224 | 1414  | 
by (meson Infinitesimal_add_st_less leD le_less_linear)  | 
| 27468 | 1415  | 
|
| 64435 | 1416  | 
lemma st_le: "x \<in> HFinite \<Longrightarrow> y \<in> HFinite \<Longrightarrow> x \<le> y \<Longrightarrow> st x \<le> st y"  | 
1417  | 
by (metis approx_le_bound approx_sym linear st_SReal st_approx_self st_part_Ex1)  | 
|
| 27468 | 1418  | 
|
| 64435 | 1419  | 
lemma st_zero_le: "0 \<le> x \<Longrightarrow> x \<in> HFinite \<Longrightarrow> 0 \<le> st x"  | 
| 70224 | 1420  | 
by (metis HFinite_0 st_0 st_le)  | 
| 27468 | 1421  | 
|
| 64435 | 1422  | 
lemma st_zero_ge: "x \<le> 0 \<Longrightarrow> x \<in> HFinite \<Longrightarrow> st x \<le> 0"  | 
| 70224 | 1423  | 
by (metis HFinite_0 st_0 st_le)  | 
| 27468 | 1424  | 
|
| 64435 | 1425  | 
lemma st_hrabs: "x \<in> HFinite \<Longrightarrow> \<bar>st x\<bar> = st \<bar>x\<bar>"  | 
| 70224 | 1426  | 
by (simp add: order_class.order.antisym st_zero_ge linorder_not_le st_zero_le abs_if st_minus linorder_not_less)  | 
| 27468 | 1427  | 
|
1428  | 
||
| 61975 | 1429  | 
subsection \<open>Alternative Definitions using Free Ultrafilter\<close>  | 
| 27468 | 1430  | 
|
| 69597 | 1431  | 
subsubsection \<open>\<^term>\<open>HFinite\<close>\<close>  | 
| 27468 | 1432  | 
|
1433  | 
lemma HFinite_FreeUltrafilterNat:  | 
|
| 70224 | 1434  | 
assumes "star_n X \<in> HFinite"  | 
1435  | 
shows "\<exists>u. eventually (\<lambda>n. norm (X n) < u) \<U>"  | 
|
1436  | 
proof -  | 
|
1437  | 
obtain r where "hnorm (star_n X) < hypreal_of_real r"  | 
|
1438  | 
using HFiniteD SReal_iff assms by fastforce  | 
|
1439  | 
then have "\<forall>\<^sub>F n in \<U>. norm (X n) < r"  | 
|
1440  | 
by (simp add: hnorm_def star_n_less star_of_def starfun_star_n)  | 
|
1441  | 
then show ?thesis ..  | 
|
1442  | 
qed  | 
|
| 27468 | 1443  | 
|
1444  | 
lemma FreeUltrafilterNat_HFinite:  | 
|
| 70224 | 1445  | 
assumes "eventually (\<lambda>n. norm (X n) < u) \<U>"  | 
1446  | 
shows "star_n X \<in> HFinite"  | 
|
1447  | 
proof -  | 
|
1448  | 
have "hnorm (star_n X) < hypreal_of_real u"  | 
|
1449  | 
by (simp add: assms hnorm_def star_n_less star_of_def starfun_star_n)  | 
|
1450  | 
then show ?thesis  | 
|
1451  | 
by (meson HInfiniteD SReal_hypreal_of_real less_asym not_HFinite_HInfinite)  | 
|
1452  | 
qed  | 
|
| 27468 | 1453  | 
|
1454  | 
lemma HFinite_FreeUltrafilterNat_iff:  | 
|
| 64438 | 1455  | 
"star_n X \<in> HFinite \<longleftrightarrow> (\<exists>u. eventually (\<lambda>n. norm (X n) < u) \<U>)"  | 
| 70224 | 1456  | 
using FreeUltrafilterNat_HFinite HFinite_FreeUltrafilterNat by blast  | 
| 64435 | 1457  | 
|
| 27468 | 1458  | 
|
| 69597 | 1459  | 
subsubsection \<open>\<^term>\<open>HInfinite\<close>\<close>  | 
| 27468 | 1460  | 
|
| 64435 | 1461  | 
text \<open>Exclude this type of sets from free ultrafilter for Infinite numbers!\<close>  | 
| 27468 | 1462  | 
lemma FreeUltrafilterNat_const_Finite:  | 
| 64438 | 1463  | 
"eventually (\<lambda>n. norm (X n) = u) \<U> \<Longrightarrow> star_n X \<in> HFinite"  | 
| 70224 | 1464  | 
by (simp add: FreeUltrafilterNat_HFinite [where u = "u+1"] eventually_mono)  | 
| 27468 | 1465  | 
|
1466  | 
lemma HInfinite_FreeUltrafilterNat:  | 
|
| 75866 | 1467  | 
assumes "star_n X \<in> HInfinite" shows "\<forall>\<^sub>F n in \<U>. u < norm (X n)"  | 
1468  | 
proof -  | 
|
1469  | 
have "\<not> (\<forall>\<^sub>F n in \<U>. norm (X n) < u + 1)"  | 
|
1470  | 
using FreeUltrafilterNat_HFinite HFinite_HInfinite_iff assms by auto  | 
|
1471  | 
then show ?thesis  | 
|
1472  | 
by (auto simp flip: FreeUltrafilterNat.eventually_not_iff elim: eventually_mono)  | 
|
1473  | 
qed  | 
|
| 27468 | 1474  | 
|
1475  | 
lemma FreeUltrafilterNat_HInfinite:  | 
|
| 70224 | 1476  | 
assumes "\<And>u. eventually (\<lambda>n. u < norm (X n)) \<U>"  | 
1477  | 
shows "star_n X \<in> HInfinite"  | 
|
| 60041 | 1478  | 
proof -  | 
| 70224 | 1479  | 
  { fix u
 | 
1480  | 
assume "\<forall>\<^sub>Fn in \<U>. norm (X n) < u" "\<forall>\<^sub>Fn in \<U>. u < norm (X n)"  | 
|
1481  | 
then have "\<forall>\<^sub>F x in \<U>. False"  | 
|
1482  | 
by eventually_elim auto  | 
|
1483  | 
then have False  | 
|
1484  | 
by (simp add: eventually_False FreeUltrafilterNat.proper) }  | 
|
1485  | 
then show ?thesis  | 
|
1486  | 
using HFinite_FreeUltrafilterNat HInfinite_HFinite_iff assms by blast  | 
|
| 60041 | 1487  | 
qed  | 
| 27468 | 1488  | 
|
1489  | 
lemma HInfinite_FreeUltrafilterNat_iff:  | 
|
| 64438 | 1490  | 
"star_n X \<in> HInfinite \<longleftrightarrow> (\<forall>u. eventually (\<lambda>n. u < norm (X n)) \<U>)"  | 
| 70224 | 1491  | 
using HInfinite_FreeUltrafilterNat FreeUltrafilterNat_HInfinite by blast  | 
| 64435 | 1492  | 
|
| 27468 | 1493  | 
|
| 69597 | 1494  | 
subsubsection \<open>\<^term>\<open>Infinitesimal\<close>\<close>  | 
| 27468 | 1495  | 
|
| 64435 | 1496  | 
lemma ball_SReal_eq: "(\<forall>x::hypreal \<in> Reals. P x) \<longleftrightarrow> (\<forall>x::real. P (star_of x))"  | 
1497  | 
by (auto simp: SReal_def)  | 
|
| 27468 | 1498  | 
|
1499  | 
||
1500  | 
lemma Infinitesimal_FreeUltrafilterNat_iff:  | 
|
| 70224 | 1501  | 
"(star_n X \<in> Infinitesimal) = (\<forall>u>0. eventually (\<lambda>n. norm (X n) < u) \<U>)" (is "?lhs = ?rhs")  | 
| 75866 | 1502  | 
proof -  | 
1503  | 
have "?lhs \<longleftrightarrow> (\<forall>r>0. hnorm (star_n X) < hypreal_of_real r)"  | 
|
1504  | 
by (simp add: Infinitesimal_def ball_SReal_eq)  | 
|
1505  | 
also have "... \<longleftrightarrow> ?rhs"  | 
|
1506  | 
by (simp add: hnorm_def starfun_star_n star_of_def star_less_def starP2_star_n)  | 
|
1507  | 
finally show ?thesis .  | 
|
| 70224 | 1508  | 
qed  | 
| 64435 | 1509  | 
|
| 27468 | 1510  | 
|
| 64435 | 1511  | 
text \<open>Infinitesimals as smaller than \<open>1/n\<close> for all \<open>n::nat (> 0)\<close>.\<close>  | 
| 27468 | 1512  | 
|
| 64435 | 1513  | 
lemma lemma_Infinitesimal: "(\<forall>r. 0 < r \<longrightarrow> x < r) \<longleftrightarrow> (\<forall>n. x < inverse (real (Suc n)))"  | 
| 70221 | 1514  | 
by (meson inverse_positive_iff_positive less_trans of_nat_0_less_iff reals_Archimedean zero_less_Suc)  | 
| 27468 | 1515  | 
|
1516  | 
lemma lemma_Infinitesimal2:  | 
|
| 75866 | 1517  | 
"(\<forall>r \<in> Reals. 0 < r \<longrightarrow> x < r) \<longleftrightarrow> (\<forall>n. x < inverse(hypreal_of_nat (Suc n)))" (is "_ = ?rhs")  | 
1518  | 
proof (intro iffI strip)  | 
|
1519  | 
assume R: ?rhs  | 
|
1520  | 
fix r::hypreal  | 
|
1521  | 
assume "r \<in> \<real>" "0 < r"  | 
|
1522  | 
then obtain n y where "inverse (real (Suc n)) < y" and r: "r = hypreal_of_real y"  | 
|
1523  | 
by (metis SReal_iff reals_Archimedean star_of_0_less)  | 
|
1524  | 
then have "inverse (1 + hypreal_of_nat n) < hypreal_of_real y"  | 
|
1525  | 
by (metis of_nat_Suc star_of_inverse star_of_less star_of_nat_def)  | 
|
1526  | 
then show "x < r"  | 
|
1527  | 
by (metis R r le_less_trans less_imp_le of_nat_Suc)  | 
|
1528  | 
qed (meson Reals_inverse Reals_of_nat of_nat_0_less_iff positive_imp_inverse_positive zero_less_Suc)  | 
|
| 27468 | 1529  | 
|
1530  | 
||
1531  | 
lemma Infinitesimal_hypreal_of_nat_iff:  | 
|
| 64435 | 1532  | 
  "Infinitesimal = {x. \<forall>n. hnorm x < inverse (hypreal_of_nat (Suc n))}"
 | 
| 70221 | 1533  | 
using Infinitesimal_def lemma_Infinitesimal2 by auto  | 
| 27468 | 1534  | 
|
1535  | 
||
| 64435 | 1536  | 
subsection \<open>Proof that \<open>\<omega>\<close> is an infinite number\<close>  | 
| 27468 | 1537  | 
|
| 64435 | 1538  | 
text \<open>It will follow that \<open>\<epsilon>\<close> is an infinitesimal number.\<close>  | 
| 27468 | 1539  | 
|
1540  | 
lemma Suc_Un_eq: "{n. n < Suc m} = {n. n < m} Un {n. n = m}"
 | 
|
| 64435 | 1541  | 
by (auto simp add: less_Suc_eq)  | 
| 27468 | 1542  | 
|
| 64435 | 1543  | 
|
| 64438 | 1544  | 
text \<open>Prove that any segment is finite and hence cannot belong to \<open>\<U>\<close>.\<close>  | 
| 27468 | 1545  | 
|
1546  | 
lemma finite_real_of_nat_segment: "finite {n::nat. real n < real (m::nat)}"
 | 
|
| 64435 | 1547  | 
by auto  | 
| 27468 | 1548  | 
|
1549  | 
lemma finite_real_of_nat_less_real: "finite {n::nat. real n < u}"
 | 
|
| 75866 | 1550  | 
proof -  | 
1551  | 
obtain m where "u < real m"  | 
|
1552  | 
using reals_Archimedean2 by blast  | 
|
1553  | 
  then have "{n. real n < u} \<subseteq> {..<m}"
 | 
|
1554  | 
by force  | 
|
1555  | 
then show ?thesis  | 
|
1556  | 
using finite_nat_iff_bounded by force  | 
|
1557  | 
qed  | 
|
| 27468 | 1558  | 
|
1559  | 
lemma finite_real_of_nat_le_real: "finite {n::nat. real n \<le> u}"
 | 
|
| 70221 | 1560  | 
by (metis infinite_nat_iff_unbounded leD le_nat_floor mem_Collect_eq)  | 
| 27468 | 1561  | 
|
| 61945 | 1562  | 
lemma finite_rabs_real_of_nat_le_real: "finite {n::nat. \<bar>real n\<bar> \<le> u}"
 | 
| 64435 | 1563  | 
by (simp add: finite_real_of_nat_le_real)  | 
| 27468 | 1564  | 
|
1565  | 
lemma rabs_real_of_nat_le_real_FreeUltrafilterNat:  | 
|
| 64438 | 1566  | 
"\<not> eventually (\<lambda>n. \<bar>real n\<bar> \<le> u) \<U>"  | 
| 64435 | 1567  | 
by (blast intro!: FreeUltrafilterNat.finite finite_rabs_real_of_nat_le_real)  | 
| 27468 | 1568  | 
|
| 64438 | 1569  | 
lemma FreeUltrafilterNat_nat_gt_real: "eventually (\<lambda>n. u < real n) \<U>"  | 
| 70224 | 1570  | 
proof -  | 
1571  | 
  have "{n::nat. \<not> u < real n} = {n. real n \<le> u}"
 | 
|
1572  | 
by auto  | 
|
1573  | 
then show ?thesis  | 
|
1574  | 
by (auto simp add: FreeUltrafilterNat.finite' finite_real_of_nat_le_real)  | 
|
1575  | 
qed  | 
|
| 27468 | 1576  | 
|
| 64435 | 1577  | 
text \<open>The complement of \<open>{n. \<bar>real n\<bar> \<le> u} = {n. u < \<bar>real n\<bar>}\<close> is in
 | 
| 64438 | 1578  | 
\<open>\<U>\<close> by property of (free) ultrafilters.\<close>  | 
| 27468 | 1579  | 
|
| 69597 | 1580  | 
text \<open>\<^term>\<open>\<omega>\<close> is a member of \<^term>\<open>HInfinite\<close>.\<close>  | 
| 61981 | 1581  | 
theorem HInfinite_omega [simp]: "\<omega> \<in> HInfinite"  | 
| 70224 | 1582  | 
proof -  | 
1583  | 
have "\<forall>\<^sub>F n in \<U>. u < norm (1 + real n)" for u  | 
|
1584  | 
using FreeUltrafilterNat_nat_gt_real [of "u-1"] eventually_mono by fastforce  | 
|
1585  | 
then show ?thesis  | 
|
1586  | 
by (simp add: omega_def FreeUltrafilterNat_HInfinite)  | 
|
1587  | 
qed  | 
|
| 27468 | 1588  | 
|
| 64435 | 1589  | 
|
1590  | 
text \<open>Epsilon is a member of Infinitesimal.\<close>  | 
|
| 27468 | 1591  | 
|
| 61981 | 1592  | 
lemma Infinitesimal_epsilon [simp]: "\<epsilon> \<in> Infinitesimal"  | 
| 64435 | 1593  | 
by (auto intro!: HInfinite_inverse_Infinitesimal HInfinite_omega  | 
| 
70723
 
4e39d87c9737
imported new material mostly due to Sébastien Gouëzel
 
paulson <lp15@cam.ac.uk> 
parents: 
70232 
diff
changeset
 | 
1594  | 
simp add: epsilon_inverse_omega)  | 
| 27468 | 1595  | 
|
| 61981 | 1596  | 
lemma HFinite_epsilon [simp]: "\<epsilon> \<in> HFinite"  | 
| 64435 | 1597  | 
by (auto intro: Infinitesimal_subset_HFinite [THEN subsetD])  | 
| 27468 | 1598  | 
|
| 61982 | 1599  | 
lemma epsilon_approx_zero [simp]: "\<epsilon> \<approx> 0"  | 
| 64435 | 1600  | 
by (simp add: mem_infmal_iff [symmetric])  | 
| 27468 | 1601  | 
|
| 64435 | 1602  | 
text \<open>Needed for proof that we define a hyperreal \<open>[<X(n)] \<approx> hypreal_of_real a\<close> given  | 
1603  | 
that \<open>\<forall>n. |X n - a| < 1/n\<close>. Used in proof of \<open>NSLIM \<Rightarrow> LIM\<close>.\<close>  | 
|
1604  | 
lemma real_of_nat_less_inverse_iff: "0 < u \<Longrightarrow> u < inverse (real(Suc n)) \<longleftrightarrow> real(Suc n) < inverse u"  | 
|
| 70221 | 1605  | 
using less_imp_inverse_less by force  | 
| 27468 | 1606  | 
|
| 64435 | 1607  | 
lemma finite_inverse_real_of_posnat_gt_real: "0 < u \<Longrightarrow> finite {n. u < inverse (real (Suc n))}"
 | 
| 
61609
 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 
paulson <lp15@cam.ac.uk> 
parents: 
61378 
diff
changeset
 | 
1608  | 
proof (simp only: real_of_nat_less_inverse_iff)  | 
| 
 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 
paulson <lp15@cam.ac.uk> 
parents: 
61378 
diff
changeset
 | 
1609  | 
  have "{n. 1 + real n < inverse u} = {n. real n < inverse u - 1}"
 | 
| 
 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 
paulson <lp15@cam.ac.uk> 
parents: 
61378 
diff
changeset
 | 
1610  | 
by fastforce  | 
| 64435 | 1611  | 
  then show "finite {n. real (Suc n) < inverse u}"
 | 
1612  | 
using finite_real_of_nat_less_real [of "inverse u - 1"]  | 
|
1613  | 
by auto  | 
|
| 
61609
 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 
paulson <lp15@cam.ac.uk> 
parents: 
61378 
diff
changeset
 | 
1614  | 
qed  | 
| 27468 | 1615  | 
|
| 70232 | 1616  | 
lemma finite_inverse_real_of_posnat_ge_real:  | 
1617  | 
assumes "0 < u"  | 
|
1618  | 
  shows "finite {n. u \<le> inverse (real (Suc n))}"
 | 
|
1619  | 
proof -  | 
|
1620  | 
have "\<forall>na. u \<le> inverse (1 + real na) \<longrightarrow> na \<le> ceiling (inverse u)"  | 
|
| 75866 | 1621  | 
by (smt (verit, best) assms ceiling_less_cancel ceiling_of_nat inverse_inverse_eq inverse_le_iff_le)  | 
| 70232 | 1622  | 
then show ?thesis  | 
1623  | 
apply (auto simp add: finite_nat_set_iff_bounded_le)  | 
|
1624  | 
by (meson assms inverse_positive_iff_positive le_nat_iff less_imp_le zero_less_ceiling)  | 
|
1625  | 
qed  | 
|
| 27468 | 1626  | 
|
1627  | 
lemma inverse_real_of_posnat_ge_real_FreeUltrafilterNat:  | 
|
| 64438 | 1628  | 
"0 < u \<Longrightarrow> \<not> eventually (\<lambda>n. u \<le> inverse(real(Suc n))) \<U>"  | 
| 64435 | 1629  | 
by (blast intro!: FreeUltrafilterNat.finite finite_inverse_real_of_posnat_ge_real)  | 
| 27468 | 1630  | 
|
1631  | 
lemma FreeUltrafilterNat_inverse_real_of_posnat:  | 
|
| 64438 | 1632  | 
"0 < u \<Longrightarrow> eventually (\<lambda>n. inverse(real(Suc n)) < u) \<U>"  | 
| 64435 | 1633  | 
by (drule inverse_real_of_posnat_ge_real_FreeUltrafilterNat)  | 
1634  | 
(simp add: FreeUltrafilterNat.eventually_not_iff not_le[symmetric])  | 
|
| 27468 | 1635  | 
|
| 64435 | 1636  | 
text \<open>Example of an hypersequence (i.e. an extended standard sequence)  | 
1637  | 
whose term with an hypernatural suffix is an infinitesimal i.e.  | 
|
1638  | 
the whn'nth term of the hypersequence is a member of Infinitesimal\<close>  | 
|
| 27468 | 1639  | 
|
| 64435 | 1640  | 
lemma SEQ_Infinitesimal: "( *f* (\<lambda>n::nat. inverse(real(Suc n)))) whn \<in> Infinitesimal"  | 
1641  | 
by (simp add: hypnat_omega_def starfun_star_n star_n_inverse Infinitesimal_FreeUltrafilterNat_iff  | 
|
1642  | 
FreeUltrafilterNat_inverse_real_of_posnat del: of_nat_Suc)  | 
|
| 27468 | 1643  | 
|
| 64435 | 1644  | 
text \<open>Example where we get a hyperreal from a real sequence  | 
1645  | 
for which a particular property holds. The theorem is  | 
|
1646  | 
used in proofs about equivalence of nonstandard and  | 
|
1647  | 
standard neighbourhoods. Also used for equivalence of  | 
|
1648  | 
nonstandard ans standard definitions of pointwise  | 
|
1649  | 
limit.\<close>  | 
|
| 27468 | 1650  | 
|
| 64435 | 1651  | 
text \<open>\<open>|X(n) - x| < 1/n \<Longrightarrow> [<X n>] - hypreal_of_real x| \<in> Infinitesimal\<close>\<close>  | 
| 27468 | 1652  | 
lemma real_seq_to_hypreal_Infinitesimal:  | 
| 64435 | 1653  | 
"\<forall>n. norm (X n - x) < inverse (real (Suc n)) \<Longrightarrow> star_n X - star_of x \<in> Infinitesimal"  | 
1654  | 
unfolding star_n_diff star_of_def Infinitesimal_FreeUltrafilterNat_iff star_n_inverse  | 
|
1655  | 
by (auto dest!: FreeUltrafilterNat_inverse_real_of_posnat  | 
|
1656  | 
intro: order_less_trans elim!: eventually_mono)  | 
|
| 27468 | 1657  | 
|
1658  | 
lemma real_seq_to_hypreal_approx:  | 
|
| 64435 | 1659  | 
"\<forall>n. norm (X n - x) < inverse (real (Suc n)) \<Longrightarrow> star_n X \<approx> star_of x"  | 
1660  | 
by (metis bex_Infinitesimal_iff real_seq_to_hypreal_Infinitesimal)  | 
|
| 27468 | 1661  | 
|
1662  | 
lemma real_seq_to_hypreal_approx2:  | 
|
| 64435 | 1663  | 
"\<forall>n. norm (x - X n) < inverse(real(Suc n)) \<Longrightarrow> star_n X \<approx> star_of x"  | 
1664  | 
by (metis norm_minus_commute real_seq_to_hypreal_approx)  | 
|
| 27468 | 1665  | 
|
1666  | 
lemma real_seq_to_hypreal_Infinitesimal2:  | 
|
| 64435 | 1667  | 
"\<forall>n. norm(X n - Y n) < inverse(real(Suc n)) \<Longrightarrow> star_n X - star_n Y \<in> Infinitesimal"  | 
1668  | 
unfolding Infinitesimal_FreeUltrafilterNat_iff star_n_diff  | 
|
1669  | 
by (auto dest!: FreeUltrafilterNat_inverse_real_of_posnat  | 
|
1670  | 
intro: order_less_trans elim!: eventually_mono)  | 
|
| 27468 | 1671  | 
|
1672  | 
end  |