author | paulson |
Thu, 04 Mar 2004 12:06:07 +0100 | |
changeset 14430 | 5cb24165a2e1 |
parent 14421 | ee97b6463cb4 |
child 14468 | 6be497cacab5 |
permissions | -rw-r--r-- |
10751 | 1 |
(* Title : HOL/Real/Hyperreal/HyperDef.thy |
2 |
ID : $Id$ |
|
3 |
Author : Jacques D. Fleuriot |
|
4 |
Copyright : 1998 University of Cambridge |
|
5 |
Description : Construction of hyperreals using ultrafilters |
|
13487 | 6 |
*) |
10751 | 7 |
|
14299 | 8 |
theory HyperDef = Filter + Real |
9 |
files ("fuf.ML"): (*Warning: file fuf.ML refers to the name Hyperdef!*) |
|
10751 | 10 |
|
11 |
||
12 |
constdefs |
|
14299 | 13 |
|
14361
ad2f5da643b4
* Support for raw latex output in control symbols: \<^raw...>
schirmer
parents:
14348
diff
changeset
|
14 |
FreeUltrafilterNat :: "nat set set" ("\<U>") |
14299 | 15 |
"FreeUltrafilterNat == (SOME U. U \<in> FreeUltrafilter (UNIV:: nat set))" |
16 |
||
17 |
hyprel :: "((nat=>real)*(nat=>real)) set" |
|
18 |
"hyprel == {p. \<exists>X Y. p = ((X::nat=>real),Y) & |
|
10751 | 19 |
{n::nat. X(n) = Y(n)}: FreeUltrafilterNat}" |
20 |
||
14299 | 21 |
typedef hypreal = "UNIV//hyprel" |
22 |
by (auto simp add: quotient_def) |
|
10751 | 23 |
|
14299 | 24 |
instance hypreal :: ord .. |
25 |
instance hypreal :: zero .. |
|
26 |
instance hypreal :: one .. |
|
27 |
instance hypreal :: plus .. |
|
28 |
instance hypreal :: times .. |
|
29 |
instance hypreal :: minus .. |
|
30 |
instance hypreal :: inverse .. |
|
10751 | 31 |
|
32 |
||
14299 | 33 |
defs (overloaded) |
34 |
||
35 |
hypreal_zero_def: |
|
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
36 |
"0 == Abs_hypreal(hyprel``{%n::nat. (0::real)})" |
10751 | 37 |
|
14299 | 38 |
hypreal_one_def: |
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
39 |
"1 == Abs_hypreal(hyprel``{%n::nat. (1::real)})" |
10751 | 40 |
|
14299 | 41 |
hypreal_minus_def: |
42 |
"- P == Abs_hypreal(\<Union>X \<in> Rep_hypreal(P). hyprel``{%n::nat. - (X n)})" |
|
10751 | 43 |
|
14299 | 44 |
hypreal_diff_def: |
10751 | 45 |
"x - y == x + -(y::hypreal)" |
46 |
||
14299 | 47 |
hypreal_inverse_def: |
48 |
"inverse P == Abs_hypreal(\<Union>X \<in> Rep_hypreal(P). |
|
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
49 |
hyprel``{%n. if X n = 0 then 0 else inverse (X n)})" |
10751 | 50 |
|
14299 | 51 |
hypreal_divide_def: |
10751 | 52 |
"P / Q::hypreal == P * inverse Q" |
13487 | 53 |
|
10751 | 54 |
constdefs |
55 |
||
14299 | 56 |
hypreal_of_real :: "real => hypreal" |
10834 | 57 |
"hypreal_of_real r == Abs_hypreal(hyprel``{%n::nat. r})" |
10751 | 58 |
|
10919
144ede948e58
renamings: real_of_nat, real_of_int -> (overloaded) real
paulson
parents:
10834
diff
changeset
|
59 |
omega :: hypreal (*an infinite number = [<1,2,3,...>] *) |
144ede948e58
renamings: real_of_nat, real_of_int -> (overloaded) real
paulson
parents:
10834
diff
changeset
|
60 |
"omega == Abs_hypreal(hyprel``{%n::nat. real (Suc n)})" |
13487 | 61 |
|
10919
144ede948e58
renamings: real_of_nat, real_of_int -> (overloaded) real
paulson
parents:
10834
diff
changeset
|
62 |
epsilon :: hypreal (*an infinitesimal number = [<1,1/2,1/3,...>] *) |
144ede948e58
renamings: real_of_nat, real_of_int -> (overloaded) real
paulson
parents:
10834
diff
changeset
|
63 |
"epsilon == Abs_hypreal(hyprel``{%n::nat. inverse (real (Suc n))})" |
144ede948e58
renamings: real_of_nat, real_of_int -> (overloaded) real
paulson
parents:
10834
diff
changeset
|
64 |
|
144ede948e58
renamings: real_of_nat, real_of_int -> (overloaded) real
paulson
parents:
10834
diff
changeset
|
65 |
syntax (xsymbols) |
14299 | 66 |
omega :: hypreal ("\<omega>") |
67 |
epsilon :: hypreal ("\<epsilon>") |
|
10919
144ede948e58
renamings: real_of_nat, real_of_int -> (overloaded) real
paulson
parents:
10834
diff
changeset
|
68 |
|
10751 | 69 |
|
14370 | 70 |
defs (overloaded) |
13487 | 71 |
|
14299 | 72 |
hypreal_add_def: |
73 |
"P + Q == Abs_hypreal(\<Union>X \<in> Rep_hypreal(P). \<Union>Y \<in> Rep_hypreal(Q). |
|
10834 | 74 |
hyprel``{%n::nat. X n + Y n})" |
10751 | 75 |
|
14299 | 76 |
hypreal_mult_def: |
77 |
"P * Q == Abs_hypreal(\<Union>X \<in> Rep_hypreal(P). \<Union>Y \<in> Rep_hypreal(Q). |
|
10834 | 78 |
hyprel``{%n::nat. X n * Y n})" |
10751 | 79 |
|
14370 | 80 |
hypreal_le_def: |
81 |
"P \<le> (Q::hypreal) == \<exists>X Y. X \<in> Rep_hypreal(P) & |
|
14299 | 82 |
Y \<in> Rep_hypreal(Q) & |
14370 | 83 |
{n::nat. X n \<le> Y n} \<in> FreeUltrafilterNat" |
84 |
||
85 |
hypreal_less_def: "(x < (y::hypreal)) == (x \<le> y & x \<noteq> y)" |
|
10751 | 86 |
|
14329 | 87 |
hrabs_def: "abs (r::hypreal) == (if 0 \<le> r then r else -r)" |
88 |
||
89 |
||
90 |
subsection{*The Set of Naturals is not Finite*} |
|
14299 | 91 |
|
92 |
(*** based on James' proof that the set of naturals is not finite ***) |
|
14329 | 93 |
lemma finite_exhausts [rule_format]: |
94 |
"finite (A::nat set) --> (\<exists>n. \<forall>m. Suc (n + m) \<notin> A)" |
|
14299 | 95 |
apply (rule impI) |
14301 | 96 |
apply (erule_tac F = A in finite_induct) |
97 |
apply (blast, erule exE) |
|
14299 | 98 |
apply (rule_tac x = "n + x" in exI) |
14301 | 99 |
apply (rule allI, erule_tac x = "x + m" in allE) |
14299 | 100 |
apply (auto simp add: add_ac) |
101 |
done |
|
102 |
||
14329 | 103 |
lemma finite_not_covers [rule_format (no_asm)]: |
104 |
"finite (A :: nat set) --> (\<exists>n. n \<notin>A)" |
|
14301 | 105 |
by (rule impI, drule finite_exhausts, blast) |
14299 | 106 |
|
107 |
lemma not_finite_nat: "~ finite(UNIV:: nat set)" |
|
14301 | 108 |
by (fast dest!: finite_exhausts) |
14299 | 109 |
|
14329 | 110 |
|
111 |
subsection{*Existence of Free Ultrafilter over the Naturals*} |
|
112 |
||
113 |
text{*Also, proof of various properties of @{term FreeUltrafilterNat}: |
|
114 |
an arbitrary free ultrafilter*} |
|
14299 | 115 |
|
116 |
lemma FreeUltrafilterNat_Ex: "\<exists>U. U: FreeUltrafilter (UNIV::nat set)" |
|
14301 | 117 |
by (rule not_finite_nat [THEN FreeUltrafilter_Ex]) |
14299 | 118 |
|
14301 | 119 |
lemma FreeUltrafilterNat_mem [simp]: |
14299 | 120 |
"FreeUltrafilterNat: FreeUltrafilter(UNIV:: nat set)" |
121 |
apply (unfold FreeUltrafilterNat_def) |
|
122 |
apply (rule FreeUltrafilterNat_Ex [THEN exE]) |
|
14301 | 123 |
apply (rule someI2, assumption+) |
14299 | 124 |
done |
125 |
||
126 |
lemma FreeUltrafilterNat_finite: "finite x ==> x \<notin> FreeUltrafilterNat" |
|
127 |
apply (unfold FreeUltrafilterNat_def) |
|
128 |
apply (rule FreeUltrafilterNat_Ex [THEN exE]) |
|
14301 | 129 |
apply (rule someI2, assumption) |
14299 | 130 |
apply (blast dest: mem_FreeUltrafiltersetD1) |
131 |
done |
|
132 |
||
133 |
lemma FreeUltrafilterNat_not_finite: "x: FreeUltrafilterNat ==> ~ finite x" |
|
14301 | 134 |
by (blast dest: FreeUltrafilterNat_finite) |
14299 | 135 |
|
14301 | 136 |
lemma FreeUltrafilterNat_empty [simp]: "{} \<notin> FreeUltrafilterNat" |
14299 | 137 |
apply (unfold FreeUltrafilterNat_def) |
138 |
apply (rule FreeUltrafilterNat_Ex [THEN exE]) |
|
14301 | 139 |
apply (rule someI2, assumption) |
140 |
apply (blast dest: FreeUltrafilter_Ultrafilter Ultrafilter_Filter |
|
141 |
Filter_empty_not_mem) |
|
14299 | 142 |
done |
143 |
||
14329 | 144 |
lemma FreeUltrafilterNat_Int: |
145 |
"[| X: FreeUltrafilterNat; Y: FreeUltrafilterNat |] |
|
14299 | 146 |
==> X Int Y \<in> FreeUltrafilterNat" |
147 |
apply (cut_tac FreeUltrafilterNat_mem) |
|
148 |
apply (blast dest: FreeUltrafilter_Ultrafilter Ultrafilter_Filter mem_FiltersetD1) |
|
149 |
done |
|
150 |
||
14329 | 151 |
lemma FreeUltrafilterNat_subset: |
14365
3d4df8c166ae
replacing HOL/Real/PRat, PNat by the rational number development
paulson
parents:
14361
diff
changeset
|
152 |
"[| X: FreeUltrafilterNat; X \<subseteq> Y |] |
14299 | 153 |
==> Y \<in> FreeUltrafilterNat" |
154 |
apply (cut_tac FreeUltrafilterNat_mem) |
|
155 |
apply (blast dest: FreeUltrafilter_Ultrafilter Ultrafilter_Filter mem_FiltersetD2) |
|
156 |
done |
|
157 |
||
14329 | 158 |
lemma FreeUltrafilterNat_Compl: |
159 |
"X: FreeUltrafilterNat ==> -X \<notin> FreeUltrafilterNat" |
|
14301 | 160 |
apply safe |
161 |
apply (drule FreeUltrafilterNat_Int, assumption, auto) |
|
14299 | 162 |
done |
163 |
||
14329 | 164 |
lemma FreeUltrafilterNat_Compl_mem: |
165 |
"X\<notin> FreeUltrafilterNat ==> -X \<in> FreeUltrafilterNat" |
|
14299 | 166 |
apply (cut_tac FreeUltrafilterNat_mem [THEN FreeUltrafilter_iff [THEN iffD1]]) |
14301 | 167 |
apply (safe, drule_tac x = X in bspec) |
14299 | 168 |
apply (auto simp add: UNIV_diff_Compl) |
169 |
done |
|
170 |
||
14329 | 171 |
lemma FreeUltrafilterNat_Compl_iff1: |
172 |
"(X \<notin> FreeUltrafilterNat) = (-X: FreeUltrafilterNat)" |
|
14301 | 173 |
by (blast dest: FreeUltrafilterNat_Compl FreeUltrafilterNat_Compl_mem) |
14299 | 174 |
|
14329 | 175 |
lemma FreeUltrafilterNat_Compl_iff2: |
176 |
"(X: FreeUltrafilterNat) = (-X \<notin> FreeUltrafilterNat)" |
|
14301 | 177 |
by (auto simp add: FreeUltrafilterNat_Compl_iff1 [symmetric]) |
14299 | 178 |
|
14378
69c4d5997669
generic of_nat and of_int functions, and generalization of iszero
paulson
parents:
14371
diff
changeset
|
179 |
lemma cofinite_mem_FreeUltrafilterNat: "finite (-X) ==> X \<in> FreeUltrafilterNat" |
69c4d5997669
generic of_nat and of_int functions, and generalization of iszero
paulson
parents:
14371
diff
changeset
|
180 |
apply (drule FreeUltrafilterNat_finite) |
69c4d5997669
generic of_nat and of_int functions, and generalization of iszero
paulson
parents:
14371
diff
changeset
|
181 |
apply (simp add: FreeUltrafilterNat_Compl_iff2 [symmetric]) |
69c4d5997669
generic of_nat and of_int functions, and generalization of iszero
paulson
parents:
14371
diff
changeset
|
182 |
done |
69c4d5997669
generic of_nat and of_int functions, and generalization of iszero
paulson
parents:
14371
diff
changeset
|
183 |
|
14301 | 184 |
lemma FreeUltrafilterNat_UNIV [simp]: "(UNIV::nat set) \<in> FreeUltrafilterNat" |
185 |
by (rule FreeUltrafilterNat_mem [THEN FreeUltrafilter_Ultrafilter, THEN Ultrafilter_Filter, THEN mem_FiltersetD4]) |
|
14299 | 186 |
|
14301 | 187 |
lemma FreeUltrafilterNat_Nat_set [simp]: "UNIV \<in> FreeUltrafilterNat" |
188 |
by auto |
|
14299 | 189 |
|
14329 | 190 |
lemma FreeUltrafilterNat_Nat_set_refl [intro]: |
191 |
"{n. P(n) = P(n)} \<in> FreeUltrafilterNat" |
|
14301 | 192 |
by simp |
14299 | 193 |
|
194 |
lemma FreeUltrafilterNat_P: "{n::nat. P} \<in> FreeUltrafilterNat ==> P" |
|
14301 | 195 |
by (rule ccontr, simp) |
14299 | 196 |
|
197 |
lemma FreeUltrafilterNat_Ex_P: "{n. P(n)} \<in> FreeUltrafilterNat ==> \<exists>n. P(n)" |
|
14301 | 198 |
by (rule ccontr, simp) |
14299 | 199 |
|
200 |
lemma FreeUltrafilterNat_all: "\<forall>n. P(n) ==> {n. P(n)} \<in> FreeUltrafilterNat" |
|
14301 | 201 |
by (auto intro: FreeUltrafilterNat_Nat_set) |
14299 | 202 |
|
14329 | 203 |
|
204 |
text{*Define and use Ultrafilter tactics*} |
|
14299 | 205 |
use "fuf.ML" |
206 |
||
207 |
method_setup fuf = {* |
|
208 |
Method.ctxt_args (fn ctxt => |
|
209 |
Method.METHOD (fn facts => |
|
210 |
fuf_tac (Classical.get_local_claset ctxt, |
|
211 |
Simplifier.get_local_simpset ctxt) 1)) *} |
|
212 |
"free ultrafilter tactic" |
|
213 |
||
214 |
method_setup ultra = {* |
|
215 |
Method.ctxt_args (fn ctxt => |
|
216 |
Method.METHOD (fn facts => |
|
217 |
ultra_tac (Classical.get_local_claset ctxt, |
|
218 |
Simplifier.get_local_simpset ctxt) 1)) *} |
|
219 |
"ultrafilter tactic" |
|
220 |
||
221 |
||
14329 | 222 |
text{*One further property of our free ultrafilter*} |
223 |
lemma FreeUltrafilterNat_Un: |
|
224 |
"X Un Y: FreeUltrafilterNat |
|
14299 | 225 |
==> X: FreeUltrafilterNat | Y: FreeUltrafilterNat" |
226 |
apply auto |
|
14301 | 227 |
apply ultra |
14299 | 228 |
done |
229 |
||
230 |
||
14329 | 231 |
subsection{*Properties of @{term hyprel}*} |
232 |
||
233 |
text{*Proving that @{term hyprel} is an equivalence relation*} |
|
14299 | 234 |
|
14365
3d4df8c166ae
replacing HOL/Real/PRat, PNat by the rational number development
paulson
parents:
14361
diff
changeset
|
235 |
lemma hyprel_iff: "((X,Y) \<in> hyprel) = ({n. X n = Y n}: FreeUltrafilterNat)" |
14301 | 236 |
by (unfold hyprel_def, fast) |
14299 | 237 |
|
14365
3d4df8c166ae
replacing HOL/Real/PRat, PNat by the rational number development
paulson
parents:
14361
diff
changeset
|
238 |
lemma hyprel_refl: "(x,x) \<in> hyprel" |
14299 | 239 |
apply (unfold hyprel_def) |
240 |
apply (auto simp add: FreeUltrafilterNat_Nat_set) |
|
241 |
done |
|
242 |
||
14365
3d4df8c166ae
replacing HOL/Real/PRat, PNat by the rational number development
paulson
parents:
14361
diff
changeset
|
243 |
lemma hyprel_sym [rule_format (no_asm)]: "(x,y) \<in> hyprel --> (y,x) \<in> hyprel" |
14301 | 244 |
by (simp add: hyprel_def eq_commute) |
14299 | 245 |
|
246 |
lemma hyprel_trans: |
|
14365
3d4df8c166ae
replacing HOL/Real/PRat, PNat by the rational number development
paulson
parents:
14361
diff
changeset
|
247 |
"[|(x,y) \<in> hyprel; (y,z) \<in> hyprel|] ==> (x,z) \<in> hyprel" |
3d4df8c166ae
replacing HOL/Real/PRat, PNat by the rational number development
paulson
parents:
14361
diff
changeset
|
248 |
by (unfold hyprel_def, auto, ultra) |
14299 | 249 |
|
250 |
lemma equiv_hyprel: "equiv UNIV hyprel" |
|
251 |
apply (simp add: equiv_def refl_def sym_def trans_def hyprel_refl) |
|
252 |
apply (blast intro: hyprel_sym hyprel_trans) |
|
253 |
done |
|
254 |
||
255 |
(* (hyprel `` {x} = hyprel `` {y}) = ((x,y) \<in> hyprel) *) |
|
256 |
lemmas equiv_hyprel_iff = |
|
257 |
eq_equiv_class_iff [OF equiv_hyprel UNIV_I UNIV_I, simp] |
|
258 |
||
14301 | 259 |
lemma hyprel_in_hypreal [simp]: "hyprel``{x}:hypreal" |
260 |
by (unfold hypreal_def hyprel_def quotient_def, blast) |
|
14299 | 261 |
|
262 |
lemma inj_on_Abs_hypreal: "inj_on Abs_hypreal hypreal" |
|
263 |
apply (rule inj_on_inverseI) |
|
264 |
apply (erule Abs_hypreal_inverse) |
|
265 |
done |
|
266 |
||
267 |
declare inj_on_Abs_hypreal [THEN inj_on_iff, simp] |
|
14301 | 268 |
Abs_hypreal_inverse [simp] |
14299 | 269 |
|
270 |
declare equiv_hyprel [THEN eq_equiv_class_iff, simp] |
|
271 |
||
272 |
declare hyprel_iff [iff] |
|
273 |
||
274 |
lemmas eq_hyprelD = eq_equiv_class [OF _ equiv_hyprel] |
|
275 |
||
276 |
lemma inj_Rep_hypreal: "inj(Rep_hypreal)" |
|
277 |
apply (rule inj_on_inverseI) |
|
278 |
apply (rule Rep_hypreal_inverse) |
|
279 |
done |
|
280 |
||
14301 | 281 |
lemma lemma_hyprel_refl [simp]: "x \<in> hyprel `` {x}" |
282 |
apply (unfold hyprel_def, safe) |
|
14299 | 283 |
apply (auto intro!: FreeUltrafilterNat_Nat_set) |
284 |
done |
|
285 |
||
14301 | 286 |
lemma hypreal_empty_not_mem [simp]: "{} \<notin> hypreal" |
14299 | 287 |
apply (unfold hypreal_def) |
288 |
apply (auto elim!: quotientE equalityCE) |
|
289 |
done |
|
290 |
||
14301 | 291 |
lemma Rep_hypreal_nonempty [simp]: "Rep_hypreal x \<noteq> {}" |
292 |
by (cut_tac x = x in Rep_hypreal, auto) |
|
14299 | 293 |
|
294 |
||
14329 | 295 |
subsection{*@{term hypreal_of_real}: |
296 |
the Injection from @{typ real} to @{typ hypreal}*} |
|
14299 | 297 |
|
298 |
lemma inj_hypreal_of_real: "inj(hypreal_of_real)" |
|
299 |
apply (rule inj_onI) |
|
300 |
apply (unfold hypreal_of_real_def) |
|
301 |
apply (drule inj_on_Abs_hypreal [THEN inj_onD]) |
|
302 |
apply (rule hyprel_in_hypreal)+ |
|
303 |
apply (drule eq_equiv_class) |
|
304 |
apply (rule equiv_hyprel) |
|
305 |
apply (simp_all add: split: split_if_asm) |
|
306 |
done |
|
307 |
||
308 |
lemma eq_Abs_hypreal: |
|
309 |
"(!!x y. z = Abs_hypreal(hyprel``{x}) ==> P) ==> P" |
|
310 |
apply (rule_tac x1=z in Rep_hypreal [unfolded hypreal_def, THEN quotientE]) |
|
14301 | 311 |
apply (drule_tac f = Abs_hypreal in arg_cong) |
14299 | 312 |
apply (force simp add: Rep_hypreal_inverse) |
313 |
done |
|
314 |
||
14329 | 315 |
|
316 |
subsection{*Hyperreal Addition*} |
|
317 |
||
318 |
lemma hypreal_add_congruent2: |
|
319 |
"congruent2 hyprel (%X Y. hyprel``{%n. X n + Y n})" |
|
320 |
apply (unfold congruent2_def, auto, ultra) |
|
321 |
done |
|
322 |
||
323 |
lemma hypreal_add: |
|
324 |
"Abs_hypreal(hyprel``{%n. X n}) + Abs_hypreal(hyprel``{%n. Y n}) = |
|
325 |
Abs_hypreal(hyprel``{%n. X n + Y n})" |
|
326 |
apply (unfold hypreal_add_def) |
|
327 |
apply (simp add: UN_equiv_class2 [OF equiv_hyprel hypreal_add_congruent2]) |
|
328 |
done |
|
329 |
||
330 |
lemma hypreal_add_commute: "(z::hypreal) + w = w + z" |
|
14371
c78c7da09519
Conversion of HyperNat to Isar format and its declaration as a semiring
paulson
parents:
14370
diff
changeset
|
331 |
apply (rule eq_Abs_hypreal [of z]) |
c78c7da09519
Conversion of HyperNat to Isar format and its declaration as a semiring
paulson
parents:
14370
diff
changeset
|
332 |
apply (rule eq_Abs_hypreal [of w]) |
14334 | 333 |
apply (simp add: add_ac hypreal_add) |
14329 | 334 |
done |
335 |
||
336 |
lemma hypreal_add_assoc: "((z1::hypreal) + z2) + z3 = z1 + (z2 + z3)" |
|
14371
c78c7da09519
Conversion of HyperNat to Isar format and its declaration as a semiring
paulson
parents:
14370
diff
changeset
|
337 |
apply (rule eq_Abs_hypreal [of z1]) |
c78c7da09519
Conversion of HyperNat to Isar format and its declaration as a semiring
paulson
parents:
14370
diff
changeset
|
338 |
apply (rule eq_Abs_hypreal [of z2]) |
c78c7da09519
Conversion of HyperNat to Isar format and its declaration as a semiring
paulson
parents:
14370
diff
changeset
|
339 |
apply (rule eq_Abs_hypreal [of z3]) |
14329 | 340 |
apply (simp add: hypreal_add real_add_assoc) |
341 |
done |
|
342 |
||
14331 | 343 |
lemma hypreal_add_zero_left: "(0::hypreal) + z = z" |
14371
c78c7da09519
Conversion of HyperNat to Isar format and its declaration as a semiring
paulson
parents:
14370
diff
changeset
|
344 |
apply (rule eq_Abs_hypreal [of z]) |
c78c7da09519
Conversion of HyperNat to Isar format and its declaration as a semiring
paulson
parents:
14370
diff
changeset
|
345 |
apply (simp add: hypreal_zero_def hypreal_add) |
14329 | 346 |
done |
347 |
||
348 |
instance hypreal :: plus_ac0 |
|
349 |
by (intro_classes, |
|
350 |
(assumption | |
|
351 |
rule hypreal_add_commute hypreal_add_assoc hypreal_add_zero_left)+) |
|
352 |
||
353 |
lemma hypreal_add_zero_right [simp]: "z + (0::hypreal) = z" |
|
354 |
by (simp add: hypreal_add_zero_left hypreal_add_commute) |
|
355 |
||
356 |
||
357 |
subsection{*Additive inverse on @{typ hypreal}*} |
|
14299 | 358 |
|
359 |
lemma hypreal_minus_congruent: |
|
360 |
"congruent hyprel (%X. hyprel``{%n. - (X n)})" |
|
361 |
by (force simp add: congruent_def) |
|
362 |
||
363 |
lemma hypreal_minus: |
|
364 |
"- (Abs_hypreal(hyprel``{%n. X n})) = Abs_hypreal(hyprel `` {%n. -(X n)})" |
|
365 |
apply (unfold hypreal_minus_def) |
|
14301 | 366 |
apply (rule_tac f = Abs_hypreal in arg_cong) |
367 |
apply (simp add: hyprel_in_hypreal [THEN Abs_hypreal_inverse] |
|
14299 | 368 |
UN_equiv_class [OF equiv_hyprel hypreal_minus_congruent]) |
369 |
done |
|
370 |
||
14329 | 371 |
lemma hypreal_diff: |
372 |
"Abs_hypreal(hyprel``{%n. X n}) - Abs_hypreal(hyprel``{%n. Y n}) = |
|
14299 | 373 |
Abs_hypreal(hyprel``{%n. X n - Y n})" |
14301 | 374 |
apply (simp add: hypreal_diff_def hypreal_minus hypreal_add) |
14299 | 375 |
done |
376 |
||
14301 | 377 |
lemma hypreal_add_minus [simp]: "z + -z = (0::hypreal)" |
14299 | 378 |
apply (unfold hypreal_zero_def) |
14301 | 379 |
apply (rule_tac z = z in eq_Abs_hypreal) |
14299 | 380 |
apply (simp add: hypreal_minus hypreal_add) |
381 |
done |
|
382 |
||
14331 | 383 |
lemma hypreal_add_minus_left: "-z + z = (0::hypreal)" |
14301 | 384 |
by (simp add: hypreal_add_commute hypreal_add_minus) |
14299 | 385 |
|
14329 | 386 |
|
387 |
subsection{*Hyperreal Multiplication*} |
|
14299 | 388 |
|
389 |
lemma hypreal_mult_congruent2: |
|
390 |
"congruent2 hyprel (%X Y. hyprel``{%n. X n * Y n})" |
|
14301 | 391 |
apply (unfold congruent2_def, auto, ultra) |
14299 | 392 |
done |
393 |
||
394 |
lemma hypreal_mult: |
|
395 |
"Abs_hypreal(hyprel``{%n. X n}) * Abs_hypreal(hyprel``{%n. Y n}) = |
|
396 |
Abs_hypreal(hyprel``{%n. X n * Y n})" |
|
397 |
apply (unfold hypreal_mult_def) |
|
398 |
apply (simp add: UN_equiv_class2 [OF equiv_hyprel hypreal_mult_congruent2]) |
|
399 |
done |
|
400 |
||
401 |
lemma hypreal_mult_commute: "(z::hypreal) * w = w * z" |
|
14371
c78c7da09519
Conversion of HyperNat to Isar format and its declaration as a semiring
paulson
parents:
14370
diff
changeset
|
402 |
apply (rule eq_Abs_hypreal [of z]) |
c78c7da09519
Conversion of HyperNat to Isar format and its declaration as a semiring
paulson
parents:
14370
diff
changeset
|
403 |
apply (rule eq_Abs_hypreal [of w]) |
14331 | 404 |
apply (simp add: hypreal_mult mult_ac) |
14299 | 405 |
done |
406 |
||
407 |
lemma hypreal_mult_assoc: "((z1::hypreal) * z2) * z3 = z1 * (z2 * z3)" |
|
14371
c78c7da09519
Conversion of HyperNat to Isar format and its declaration as a semiring
paulson
parents:
14370
diff
changeset
|
408 |
apply (rule eq_Abs_hypreal [of z1]) |
c78c7da09519
Conversion of HyperNat to Isar format and its declaration as a semiring
paulson
parents:
14370
diff
changeset
|
409 |
apply (rule eq_Abs_hypreal [of z2]) |
c78c7da09519
Conversion of HyperNat to Isar format and its declaration as a semiring
paulson
parents:
14370
diff
changeset
|
410 |
apply (rule eq_Abs_hypreal [of z3]) |
14331 | 411 |
apply (simp add: hypreal_mult mult_assoc) |
14299 | 412 |
done |
413 |
||
14331 | 414 |
lemma hypreal_mult_1: "(1::hypreal) * z = z" |
14299 | 415 |
apply (unfold hypreal_one_def) |
14301 | 416 |
apply (rule_tac z = z in eq_Abs_hypreal) |
14299 | 417 |
apply (simp add: hypreal_mult) |
418 |
done |
|
14301 | 419 |
|
14329 | 420 |
lemma hypreal_add_mult_distrib: |
421 |
"((z1::hypreal) + z2) * w = (z1 * w) + (z2 * w)" |
|
14371
c78c7da09519
Conversion of HyperNat to Isar format and its declaration as a semiring
paulson
parents:
14370
diff
changeset
|
422 |
apply (rule eq_Abs_hypreal [of z1]) |
c78c7da09519
Conversion of HyperNat to Isar format and its declaration as a semiring
paulson
parents:
14370
diff
changeset
|
423 |
apply (rule eq_Abs_hypreal [of z2]) |
c78c7da09519
Conversion of HyperNat to Isar format and its declaration as a semiring
paulson
parents:
14370
diff
changeset
|
424 |
apply (rule eq_Abs_hypreal [of w]) |
14334 | 425 |
apply (simp add: hypreal_mult hypreal_add left_distrib) |
14299 | 426 |
done |
427 |
||
14331 | 428 |
text{*one and zero are distinct*} |
14299 | 429 |
lemma hypreal_zero_not_eq_one: "0 \<noteq> (1::hypreal)" |
430 |
apply (unfold hypreal_zero_def hypreal_one_def) |
|
431 |
apply (auto simp add: real_zero_not_eq_one) |
|
432 |
done |
|
433 |
||
434 |
||
14329 | 435 |
subsection{*Multiplicative Inverse on @{typ hypreal} *} |
14299 | 436 |
|
437 |
lemma hypreal_inverse_congruent: |
|
438 |
"congruent hyprel (%X. hyprel``{%n. if X n = 0 then 0 else inverse(X n)})" |
|
439 |
apply (unfold congruent_def) |
|
14301 | 440 |
apply (auto, ultra) |
14299 | 441 |
done |
442 |
||
443 |
lemma hypreal_inverse: |
|
444 |
"inverse (Abs_hypreal(hyprel``{%n. X n})) = |
|
445 |
Abs_hypreal(hyprel `` {%n. if X n = 0 then 0 else inverse(X n)})" |
|
446 |
apply (unfold hypreal_inverse_def) |
|
14301 | 447 |
apply (rule_tac f = Abs_hypreal in arg_cong) |
448 |
apply (simp add: hyprel_in_hypreal [THEN Abs_hypreal_inverse] |
|
14299 | 449 |
UN_equiv_class [OF equiv_hyprel hypreal_inverse_congruent]) |
450 |
done |
|
451 |
||
14331 | 452 |
lemma hypreal_mult_inverse: |
14299 | 453 |
"x \<noteq> 0 ==> x*inverse(x) = (1::hypreal)" |
454 |
apply (unfold hypreal_one_def hypreal_zero_def) |
|
14371
c78c7da09519
Conversion of HyperNat to Isar format and its declaration as a semiring
paulson
parents:
14370
diff
changeset
|
455 |
apply (rule eq_Abs_hypreal [of x]) |
14299 | 456 |
apply (simp add: hypreal_inverse hypreal_mult) |
457 |
apply (drule FreeUltrafilterNat_Compl_mem) |
|
14334 | 458 |
apply (blast intro!: right_inverse FreeUltrafilterNat_subset) |
14299 | 459 |
done |
460 |
||
14331 | 461 |
lemma hypreal_mult_inverse_left: |
14329 | 462 |
"x \<noteq> 0 ==> inverse(x)*x = (1::hypreal)" |
14301 | 463 |
by (simp add: hypreal_mult_inverse hypreal_mult_commute) |
14299 | 464 |
|
14331 | 465 |
instance hypreal :: field |
466 |
proof |
|
467 |
fix x y z :: hypreal |
|
468 |
show "(x + y) + z = x + (y + z)" by (rule hypreal_add_assoc) |
|
469 |
show "x + y = y + x" by (rule hypreal_add_commute) |
|
470 |
show "0 + x = x" by simp |
|
471 |
show "- x + x = 0" by (simp add: hypreal_add_minus_left) |
|
472 |
show "x - y = x + (-y)" by (simp add: hypreal_diff_def) |
|
473 |
show "(x * y) * z = x * (y * z)" by (rule hypreal_mult_assoc) |
|
474 |
show "x * y = y * x" by (rule hypreal_mult_commute) |
|
475 |
show "1 * x = x" by (simp add: hypreal_mult_1) |
|
476 |
show "(x + y) * z = x * z + y * z" by (simp add: hypreal_add_mult_distrib) |
|
477 |
show "0 \<noteq> (1::hypreal)" by (rule hypreal_zero_not_eq_one) |
|
478 |
show "x \<noteq> 0 ==> inverse x * x = 1" by (simp add: hypreal_mult_inverse_left) |
|
14430
5cb24165a2e1
new material from Avigad, and simplified treatment of division by 0
paulson
parents:
14421
diff
changeset
|
479 |
show "x / y = x * inverse y" by (simp add: hypreal_divide_def) |
14331 | 480 |
qed |
481 |
||
482 |
||
483 |
instance hypreal :: division_by_zero |
|
484 |
proof |
|
14430
5cb24165a2e1
new material from Avigad, and simplified treatment of division by 0
paulson
parents:
14421
diff
changeset
|
485 |
show "inverse 0 = (0::hypreal)" |
14421
ee97b6463cb4
new Ring_and_Field hierarchy, eliminating redundant axioms
paulson
parents:
14387
diff
changeset
|
486 |
by (simp add: hypreal_inverse hypreal_zero_def) |
14331 | 487 |
qed |
488 |
||
14329 | 489 |
|
490 |
subsection{*Properties of The @{text "\<le>"} Relation*} |
|
14299 | 491 |
|
492 |
lemma hypreal_le: |
|
14365
3d4df8c166ae
replacing HOL/Real/PRat, PNat by the rational number development
paulson
parents:
14361
diff
changeset
|
493 |
"(Abs_hypreal(hyprel``{%n. X n}) \<le> Abs_hypreal(hyprel``{%n. Y n})) = |
3d4df8c166ae
replacing HOL/Real/PRat, PNat by the rational number development
paulson
parents:
14361
diff
changeset
|
494 |
({n. X n \<le> Y n} \<in> FreeUltrafilterNat)" |
14299 | 495 |
apply (unfold hypreal_le_def) |
14387
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14378
diff
changeset
|
496 |
apply (auto intro!: lemma_hyprel_refl, ultra) |
14299 | 497 |
done |
498 |
||
14365
3d4df8c166ae
replacing HOL/Real/PRat, PNat by the rational number development
paulson
parents:
14361
diff
changeset
|
499 |
lemma hypreal_le_refl: "w \<le> (w::hypreal)" |
14370 | 500 |
apply (rule eq_Abs_hypreal [of w]) |
501 |
apply (simp add: hypreal_le) |
|
14299 | 502 |
done |
503 |
||
14365
3d4df8c166ae
replacing HOL/Real/PRat, PNat by the rational number development
paulson
parents:
14361
diff
changeset
|
504 |
lemma hypreal_le_trans: "[| i \<le> j; j \<le> k |] ==> i \<le> (k::hypreal)" |
14370 | 505 |
apply (rule eq_Abs_hypreal [of i]) |
506 |
apply (rule eq_Abs_hypreal [of j]) |
|
507 |
apply (rule eq_Abs_hypreal [of k]) |
|
14387
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14378
diff
changeset
|
508 |
apply (simp add: hypreal_le, ultra) |
14299 | 509 |
done |
510 |
||
14365
3d4df8c166ae
replacing HOL/Real/PRat, PNat by the rational number development
paulson
parents:
14361
diff
changeset
|
511 |
lemma hypreal_le_anti_sym: "[| z \<le> w; w \<le> z |] ==> z = (w::hypreal)" |
14370 | 512 |
apply (rule eq_Abs_hypreal [of z]) |
513 |
apply (rule eq_Abs_hypreal [of w]) |
|
14387
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14378
diff
changeset
|
514 |
apply (simp add: hypreal_le, ultra) |
14299 | 515 |
done |
516 |
||
517 |
(* Axiom 'order_less_le' of class 'order': *) |
|
14365
3d4df8c166ae
replacing HOL/Real/PRat, PNat by the rational number development
paulson
parents:
14361
diff
changeset
|
518 |
lemma hypreal_less_le: "((w::hypreal) < z) = (w \<le> z & w \<noteq> z)" |
14387
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14378
diff
changeset
|
519 |
by (simp add: hypreal_less_def) |
14299 | 520 |
|
14329 | 521 |
instance hypreal :: order |
14370 | 522 |
proof qed |
523 |
(assumption | |
|
524 |
rule hypreal_le_refl hypreal_le_trans hypreal_le_anti_sym hypreal_less_le)+ |
|
525 |
||
526 |
||
527 |
(* Axiom 'linorder_linear' of class 'linorder': *) |
|
528 |
lemma hypreal_le_linear: "(z::hypreal) \<le> w | w \<le> z" |
|
529 |
apply (rule eq_Abs_hypreal [of z]) |
|
530 |
apply (rule eq_Abs_hypreal [of w]) |
|
14387
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14378
diff
changeset
|
531 |
apply (auto simp add: hypreal_le, ultra) |
14370 | 532 |
done |
14329 | 533 |
|
534 |
instance hypreal :: linorder |
|
535 |
by (intro_classes, rule hypreal_le_linear) |
|
536 |
||
14370 | 537 |
lemma hypreal_not_refl2: "!!(x::hypreal). x < y ==> x \<noteq> y" |
538 |
by (auto simp add: order_less_irrefl) |
|
14329 | 539 |
|
14370 | 540 |
lemma hypreal_add_left_mono: "x \<le> y ==> z + x \<le> z + (y::hypreal)" |
541 |
apply (rule eq_Abs_hypreal [of x]) |
|
542 |
apply (rule eq_Abs_hypreal [of y]) |
|
543 |
apply (rule eq_Abs_hypreal [of z]) |
|
544 |
apply (auto simp add: hypreal_le hypreal_add) |
|
14329 | 545 |
done |
546 |
||
547 |
lemma hypreal_mult_less_mono2: "[| (0::hypreal)<z; x<y |] ==> z*x<z*y" |
|
14370 | 548 |
apply (rule eq_Abs_hypreal [of x]) |
549 |
apply (rule eq_Abs_hypreal [of y]) |
|
550 |
apply (rule eq_Abs_hypreal [of z]) |
|
551 |
apply (auto simp add: hypreal_zero_def hypreal_le hypreal_mult |
|
14387
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14378
diff
changeset
|
552 |
linorder_not_le [symmetric], ultra) |
14329 | 553 |
done |
554 |
||
14370 | 555 |
|
14329 | 556 |
subsection{*The Hyperreals Form an Ordered Field*} |
557 |
||
558 |
instance hypreal :: ordered_field |
|
559 |
proof |
|
560 |
fix x y z :: hypreal |
|
14348
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
paulson
parents:
14341
diff
changeset
|
561 |
show "x \<le> y ==> z + x \<le> z + y" |
14370 | 562 |
by (rule hypreal_add_left_mono) |
14348
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
paulson
parents:
14341
diff
changeset
|
563 |
show "x < y ==> 0 < z ==> z * x < z * y" |
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
paulson
parents:
14341
diff
changeset
|
564 |
by (simp add: hypreal_mult_less_mono2) |
14329 | 565 |
show "\<bar>x\<bar> = (if x < 0 then -x else x)" |
566 |
by (auto dest: order_le_less_trans simp add: hrabs_def linorder_not_le) |
|
567 |
qed |
|
568 |
||
14331 | 569 |
lemma hypreal_mult_1_right: "z * (1::hypreal) = z" |
570 |
by (rule Ring_and_Field.mult_1_right) |
|
571 |
||
572 |
lemma hypreal_mult_minus_1 [simp]: "(- (1::hypreal)) * z = -z" |
|
14387
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14378
diff
changeset
|
573 |
by simp |
14331 | 574 |
|
575 |
lemma hypreal_mult_minus_1_right [simp]: "z * (- (1::hypreal)) = -z" |
|
576 |
by (subst hypreal_mult_commute, simp) |
|
14329 | 577 |
|
578 |
(*Used ONCE: in NSA.ML*) |
|
579 |
lemma hypreal_minus_distrib1: "-(y + -(x::hypreal)) = x + -y" |
|
580 |
by (simp add: hypreal_add_commute) |
|
581 |
||
582 |
(*Used ONCE: in Lim.ML*) |
|
583 |
lemma hypreal_eq_minus_iff3: "(x = y + z) = (x + -z = (y::hypreal))" |
|
584 |
by (auto simp add: hypreal_add_assoc) |
|
585 |
||
14331 | 586 |
lemma hypreal_eq_minus_iff: "((x::hypreal) = y) = (x + - y = 0)" |
587 |
apply auto |
|
588 |
apply (rule Ring_and_Field.add_right_cancel [of _ "-y", THEN iffD1], auto) |
|
589 |
done |
|
590 |
||
591 |
(*Used 3 TIMES: in Lim.ML*) |
|
14329 | 592 |
lemma hypreal_not_eq_minus_iff: "(x \<noteq> a) = (x + -a \<noteq> (0::hypreal))" |
593 |
by (auto dest: hypreal_eq_minus_iff [THEN iffD2]) |
|
594 |
||
595 |
lemma hypreal_mult_left_cancel: "(c::hypreal) \<noteq> 0 ==> (c*a=c*b) = (a=b)" |
|
14387
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14378
diff
changeset
|
596 |
by auto |
14329 | 597 |
|
598 |
lemma hypreal_mult_right_cancel: "(c::hypreal) \<noteq> 0 ==> (a*c=b*c) = (a=b)" |
|
14387
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14378
diff
changeset
|
599 |
by auto |
14329 | 600 |
|
601 |
lemma hypreal_mult_not_0: "[| x \<noteq> 0; y \<noteq> 0 |] ==> x * y \<noteq> (0::hypreal)" |
|
602 |
by simp |
|
603 |
||
604 |
lemma hypreal_minus_inverse: "inverse(-x) = -inverse(x::hypreal)" |
|
605 |
by (rule Ring_and_Field.inverse_minus_eq) |
|
606 |
||
607 |
lemma hypreal_inverse_distrib: "inverse(x*y) = inverse(x)*inverse(y::hypreal)" |
|
608 |
by (rule Ring_and_Field.inverse_mult_distrib) |
|
609 |
||
610 |
||
611 |
subsection{* Division lemmas *} |
|
612 |
||
613 |
lemma hypreal_divide_one: "x/(1::hypreal) = x" |
|
614 |
by (simp add: hypreal_divide_def) |
|
615 |
||
616 |
||
617 |
(** As with multiplication, pull minus signs OUT of the / operator **) |
|
618 |
||
619 |
lemma hypreal_add_divide_distrib: "(x+y)/(z::hypreal) = x/z + y/z" |
|
620 |
by (rule Ring_and_Field.add_divide_distrib) |
|
621 |
||
622 |
lemma hypreal_inverse_add: |
|
623 |
"[|(x::hypreal) \<noteq> 0; y \<noteq> 0 |] |
|
624 |
==> inverse(x) + inverse(y) = (x + y)*inverse(x*y)" |
|
625 |
by (simp add: Ring_and_Field.inverse_add mult_assoc) |
|
626 |
||
627 |
||
14371
c78c7da09519
Conversion of HyperNat to Isar format and its declaration as a semiring
paulson
parents:
14370
diff
changeset
|
628 |
subsection{*The Embedding @{term hypreal_of_real} Preserves Field and |
c78c7da09519
Conversion of HyperNat to Isar format and its declaration as a semiring
paulson
parents:
14370
diff
changeset
|
629 |
Order Properties*} |
14329 | 630 |
|
14301 | 631 |
lemma hypreal_of_real_add [simp]: |
14369 | 632 |
"hypreal_of_real (w + z) = hypreal_of_real w + hypreal_of_real z" |
14299 | 633 |
apply (unfold hypreal_of_real_def) |
14331 | 634 |
apply (simp add: hypreal_add left_distrib) |
14299 | 635 |
done |
636 |
||
14301 | 637 |
lemma hypreal_of_real_mult [simp]: |
14369 | 638 |
"hypreal_of_real (w * z) = hypreal_of_real w * hypreal_of_real z" |
14299 | 639 |
apply (unfold hypreal_of_real_def) |
14331 | 640 |
apply (simp add: hypreal_mult right_distrib) |
14299 | 641 |
done |
642 |
||
14301 | 643 |
lemma hypreal_of_real_one [simp]: "hypreal_of_real 1 = (1::hypreal)" |
644 |
by (unfold hypreal_of_real_def hypreal_one_def, simp) |
|
14299 | 645 |
|
14301 | 646 |
lemma hypreal_of_real_zero [simp]: "hypreal_of_real 0 = 0" |
647 |
by (unfold hypreal_of_real_def hypreal_zero_def, simp) |
|
14299 | 648 |
|
14370 | 649 |
lemma hypreal_of_real_le_iff [simp]: |
650 |
"(hypreal_of_real w \<le> hypreal_of_real z) = (w \<le> z)" |
|
651 |
apply (unfold hypreal_le_def hypreal_of_real_def, auto) |
|
14369 | 652 |
apply (rule_tac [2] x = "%n. w" in exI, safe) |
653 |
apply (rule_tac [3] x = "%n. z" in exI, auto) |
|
654 |
apply (rule FreeUltrafilterNat_P, ultra) |
|
655 |
done |
|
656 |
||
14370 | 657 |
lemma hypreal_of_real_less_iff [simp]: |
658 |
"(hypreal_of_real w < hypreal_of_real z) = (w < z)" |
|
659 |
by (simp add: linorder_not_le [symmetric]) |
|
14369 | 660 |
|
661 |
lemma hypreal_of_real_eq_iff [simp]: |
|
662 |
"(hypreal_of_real w = hypreal_of_real z) = (w = z)" |
|
663 |
by (force intro: order_antisym hypreal_of_real_le_iff [THEN iffD1]) |
|
664 |
||
665 |
text{*As above, for 0*} |
|
666 |
||
667 |
declare hypreal_of_real_less_iff [of 0, simplified, simp] |
|
668 |
declare hypreal_of_real_le_iff [of 0, simplified, simp] |
|
669 |
declare hypreal_of_real_eq_iff [of 0, simplified, simp] |
|
670 |
||
671 |
declare hypreal_of_real_less_iff [of _ 0, simplified, simp] |
|
672 |
declare hypreal_of_real_le_iff [of _ 0, simplified, simp] |
|
673 |
declare hypreal_of_real_eq_iff [of _ 0, simplified, simp] |
|
674 |
||
675 |
text{*As above, for 1*} |
|
676 |
||
677 |
declare hypreal_of_real_less_iff [of 1, simplified, simp] |
|
678 |
declare hypreal_of_real_le_iff [of 1, simplified, simp] |
|
679 |
declare hypreal_of_real_eq_iff [of 1, simplified, simp] |
|
680 |
||
681 |
declare hypreal_of_real_less_iff [of _ 1, simplified, simp] |
|
682 |
declare hypreal_of_real_le_iff [of _ 1, simplified, simp] |
|
683 |
declare hypreal_of_real_eq_iff [of _ 1, simplified, simp] |
|
684 |
||
685 |
lemma hypreal_of_real_minus [simp]: |
|
686 |
"hypreal_of_real (-r) = - hypreal_of_real r" |
|
14370 | 687 |
by (auto simp add: hypreal_of_real_def hypreal_minus) |
14299 | 688 |
|
14329 | 689 |
lemma hypreal_of_real_inverse [simp]: |
690 |
"hypreal_of_real (inverse r) = inverse (hypreal_of_real r)" |
|
14370 | 691 |
apply (case_tac "r=0", simp) |
14299 | 692 |
apply (rule_tac c1 = "hypreal_of_real r" in hypreal_mult_left_cancel [THEN iffD1]) |
14369 | 693 |
apply (auto simp add: hypreal_of_real_mult [symmetric]) |
14299 | 694 |
done |
695 |
||
14329 | 696 |
lemma hypreal_of_real_divide [simp]: |
14369 | 697 |
"hypreal_of_real (w / z) = hypreal_of_real w / hypreal_of_real z" |
14301 | 698 |
by (simp add: hypreal_divide_def real_divide_def) |
14299 | 699 |
|
700 |
||
14329 | 701 |
subsection{*Misc Others*} |
14299 | 702 |
|
14370 | 703 |
lemma hypreal_less: |
704 |
"(Abs_hypreal(hyprel``{%n. X n}) < Abs_hypreal(hyprel``{%n. Y n})) = |
|
705 |
({n. X n < Y n} \<in> FreeUltrafilterNat)" |
|
14387
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14378
diff
changeset
|
706 |
apply (auto simp add: hypreal_le linorder_not_le [symmetric], ultra+) |
14370 | 707 |
done |
708 |
||
14299 | 709 |
lemma hypreal_zero_num: "0 = Abs_hypreal (hyprel `` {%n. 0})" |
14301 | 710 |
by (simp add: hypreal_zero_def [THEN meta_eq_to_obj_eq, symmetric]) |
14299 | 711 |
|
712 |
lemma hypreal_one_num: "1 = Abs_hypreal (hyprel `` {%n. 1})" |
|
14301 | 713 |
by (simp add: hypreal_one_def [THEN meta_eq_to_obj_eq, symmetric]) |
14299 | 714 |
|
14301 | 715 |
lemma hypreal_omega_gt_zero [simp]: "0 < omega" |
14299 | 716 |
apply (unfold omega_def) |
717 |
apply (auto simp add: hypreal_less hypreal_zero_num) |
|
718 |
done |
|
719 |
||
14329 | 720 |
lemma hypreal_hrabs: |
721 |
"abs (Abs_hypreal (hyprel `` {X})) = |
|
722 |
Abs_hypreal(hyprel `` {%n. abs (X n)})" |
|
723 |
apply (auto simp add: hrabs_def hypreal_zero_def hypreal_le hypreal_minus) |
|
724 |
apply (ultra, arith)+ |
|
725 |
done |
|
726 |
||
14370 | 727 |
|
728 |
||
729 |
lemma hypreal_add_zero_less_le_mono: "[|r < x; (0::hypreal) \<le> y|] ==> r < x+y" |
|
730 |
by (auto dest: add_less_le_mono) |
|
731 |
||
732 |
text{*The precondition could be weakened to @{term "0\<le>x"}*} |
|
733 |
lemma hypreal_mult_less_mono: |
|
734 |
"[| u<v; x<y; (0::hypreal) < v; 0 < x |] ==> u*x < v* y" |
|
735 |
by (simp add: Ring_and_Field.mult_strict_mono order_less_imp_le) |
|
736 |
||
737 |
||
738 |
subsection{*Existence of Infinite Hyperreal Number*} |
|
739 |
||
740 |
lemma Rep_hypreal_omega: "Rep_hypreal(omega) \<in> hypreal" |
|
741 |
apply (unfold omega_def) |
|
742 |
apply (rule Rep_hypreal) |
|
743 |
done |
|
744 |
||
745 |
text{*Existence of infinite number not corresponding to any real number. |
|
746 |
Use assumption that member @{term FreeUltrafilterNat} is not finite.*} |
|
747 |
||
748 |
||
749 |
text{*A few lemmas first*} |
|
750 |
||
751 |
lemma lemma_omega_empty_singleton_disj: "{n::nat. x = real n} = {} | |
|
752 |
(\<exists>y. {n::nat. x = real n} = {y})" |
|
14387
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14378
diff
changeset
|
753 |
by force |
14370 | 754 |
|
755 |
lemma lemma_finite_omega_set: "finite {n::nat. x = real n}" |
|
756 |
by (cut_tac x = x in lemma_omega_empty_singleton_disj, auto) |
|
757 |
||
758 |
lemma not_ex_hypreal_of_real_eq_omega: |
|
759 |
"~ (\<exists>x. hypreal_of_real x = omega)" |
|
760 |
apply (unfold omega_def hypreal_of_real_def) |
|
761 |
apply (auto simp add: real_of_nat_Suc diff_eq_eq [symmetric] |
|
762 |
lemma_finite_omega_set [THEN FreeUltrafilterNat_finite]) |
|
763 |
done |
|
764 |
||
765 |
lemma hypreal_of_real_not_eq_omega: "hypreal_of_real x \<noteq> omega" |
|
766 |
by (cut_tac not_ex_hypreal_of_real_eq_omega, auto) |
|
767 |
||
768 |
text{*Existence of infinitesimal number also not corresponding to any |
|
769 |
real number*} |
|
770 |
||
771 |
lemma lemma_epsilon_empty_singleton_disj: |
|
772 |
"{n::nat. x = inverse(real(Suc n))} = {} | |
|
773 |
(\<exists>y. {n::nat. x = inverse(real(Suc n))} = {y})" |
|
14387
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14378
diff
changeset
|
774 |
by auto |
14370 | 775 |
|
776 |
lemma lemma_finite_epsilon_set: "finite {n. x = inverse(real(Suc n))}" |
|
777 |
by (cut_tac x = x in lemma_epsilon_empty_singleton_disj, auto) |
|
778 |
||
779 |
lemma not_ex_hypreal_of_real_eq_epsilon: |
|
780 |
"~ (\<exists>x. hypreal_of_real x = epsilon)" |
|
781 |
apply (unfold epsilon_def hypreal_of_real_def) |
|
782 |
apply (auto simp add: lemma_finite_epsilon_set [THEN FreeUltrafilterNat_finite]) |
|
783 |
done |
|
784 |
||
785 |
lemma hypreal_of_real_not_eq_epsilon: "hypreal_of_real x \<noteq> epsilon" |
|
786 |
by (cut_tac not_ex_hypreal_of_real_eq_epsilon, auto) |
|
787 |
||
788 |
lemma hypreal_epsilon_not_zero: "epsilon \<noteq> 0" |
|
789 |
by (unfold epsilon_def hypreal_zero_def, auto) |
|
790 |
||
791 |
lemma hypreal_epsilon_inverse_omega: "epsilon = inverse(omega)" |
|
792 |
by (simp add: hypreal_inverse omega_def epsilon_def) |
|
793 |
||
794 |
||
14299 | 795 |
ML |
796 |
{* |
|
14329 | 797 |
val hrabs_def = thm "hrabs_def"; |
798 |
val hypreal_hrabs = thm "hypreal_hrabs"; |
|
799 |
||
14299 | 800 |
val hypreal_zero_def = thm "hypreal_zero_def"; |
801 |
val hypreal_one_def = thm "hypreal_one_def"; |
|
802 |
val hypreal_minus_def = thm "hypreal_minus_def"; |
|
803 |
val hypreal_diff_def = thm "hypreal_diff_def"; |
|
804 |
val hypreal_inverse_def = thm "hypreal_inverse_def"; |
|
805 |
val hypreal_divide_def = thm "hypreal_divide_def"; |
|
806 |
val hypreal_of_real_def = thm "hypreal_of_real_def"; |
|
807 |
val omega_def = thm "omega_def"; |
|
808 |
val epsilon_def = thm "epsilon_def"; |
|
809 |
val hypreal_add_def = thm "hypreal_add_def"; |
|
810 |
val hypreal_mult_def = thm "hypreal_mult_def"; |
|
811 |
val hypreal_less_def = thm "hypreal_less_def"; |
|
812 |
val hypreal_le_def = thm "hypreal_le_def"; |
|
813 |
||
814 |
val finite_exhausts = thm "finite_exhausts"; |
|
815 |
val finite_not_covers = thm "finite_not_covers"; |
|
816 |
val not_finite_nat = thm "not_finite_nat"; |
|
817 |
val FreeUltrafilterNat_Ex = thm "FreeUltrafilterNat_Ex"; |
|
818 |
val FreeUltrafilterNat_mem = thm "FreeUltrafilterNat_mem"; |
|
819 |
val FreeUltrafilterNat_finite = thm "FreeUltrafilterNat_finite"; |
|
820 |
val FreeUltrafilterNat_not_finite = thm "FreeUltrafilterNat_not_finite"; |
|
821 |
val FreeUltrafilterNat_empty = thm "FreeUltrafilterNat_empty"; |
|
822 |
val FreeUltrafilterNat_Int = thm "FreeUltrafilterNat_Int"; |
|
823 |
val FreeUltrafilterNat_subset = thm "FreeUltrafilterNat_subset"; |
|
824 |
val FreeUltrafilterNat_Compl = thm "FreeUltrafilterNat_Compl"; |
|
825 |
val FreeUltrafilterNat_Compl_mem = thm "FreeUltrafilterNat_Compl_mem"; |
|
826 |
val FreeUltrafilterNat_Compl_iff1 = thm "FreeUltrafilterNat_Compl_iff1"; |
|
827 |
val FreeUltrafilterNat_Compl_iff2 = thm "FreeUltrafilterNat_Compl_iff2"; |
|
828 |
val FreeUltrafilterNat_UNIV = thm "FreeUltrafilterNat_UNIV"; |
|
829 |
val FreeUltrafilterNat_Nat_set = thm "FreeUltrafilterNat_Nat_set"; |
|
830 |
val FreeUltrafilterNat_Nat_set_refl = thm "FreeUltrafilterNat_Nat_set_refl"; |
|
831 |
val FreeUltrafilterNat_P = thm "FreeUltrafilterNat_P"; |
|
832 |
val FreeUltrafilterNat_Ex_P = thm "FreeUltrafilterNat_Ex_P"; |
|
833 |
val FreeUltrafilterNat_all = thm "FreeUltrafilterNat_all"; |
|
834 |
val FreeUltrafilterNat_Un = thm "FreeUltrafilterNat_Un"; |
|
835 |
val hyprel_iff = thm "hyprel_iff"; |
|
836 |
val hyprel_refl = thm "hyprel_refl"; |
|
837 |
val hyprel_sym = thm "hyprel_sym"; |
|
838 |
val hyprel_trans = thm "hyprel_trans"; |
|
839 |
val equiv_hyprel = thm "equiv_hyprel"; |
|
840 |
val hyprel_in_hypreal = thm "hyprel_in_hypreal"; |
|
841 |
val Abs_hypreal_inverse = thm "Abs_hypreal_inverse"; |
|
842 |
val inj_on_Abs_hypreal = thm "inj_on_Abs_hypreal"; |
|
843 |
val inj_Rep_hypreal = thm "inj_Rep_hypreal"; |
|
844 |
val lemma_hyprel_refl = thm "lemma_hyprel_refl"; |
|
845 |
val hypreal_empty_not_mem = thm "hypreal_empty_not_mem"; |
|
846 |
val Rep_hypreal_nonempty = thm "Rep_hypreal_nonempty"; |
|
847 |
val inj_hypreal_of_real = thm "inj_hypreal_of_real"; |
|
848 |
val eq_Abs_hypreal = thm "eq_Abs_hypreal"; |
|
849 |
val hypreal_minus_congruent = thm "hypreal_minus_congruent"; |
|
850 |
val hypreal_minus = thm "hypreal_minus"; |
|
851 |
val hypreal_add_congruent2 = thm "hypreal_add_congruent2"; |
|
852 |
val hypreal_add = thm "hypreal_add"; |
|
853 |
val hypreal_diff = thm "hypreal_diff"; |
|
854 |
val hypreal_add_commute = thm "hypreal_add_commute"; |
|
855 |
val hypreal_add_assoc = thm "hypreal_add_assoc"; |
|
856 |
val hypreal_add_zero_left = thm "hypreal_add_zero_left"; |
|
857 |
val hypreal_add_zero_right = thm "hypreal_add_zero_right"; |
|
858 |
val hypreal_add_minus = thm "hypreal_add_minus"; |
|
859 |
val hypreal_add_minus_left = thm "hypreal_add_minus_left"; |
|
860 |
val hypreal_minus_distrib1 = thm "hypreal_minus_distrib1"; |
|
861 |
val hypreal_mult_congruent2 = thm "hypreal_mult_congruent2"; |
|
862 |
val hypreal_mult = thm "hypreal_mult"; |
|
863 |
val hypreal_mult_commute = thm "hypreal_mult_commute"; |
|
864 |
val hypreal_mult_assoc = thm "hypreal_mult_assoc"; |
|
865 |
val hypreal_mult_1 = thm "hypreal_mult_1"; |
|
866 |
val hypreal_mult_1_right = thm "hypreal_mult_1_right"; |
|
867 |
val hypreal_mult_minus_1 = thm "hypreal_mult_minus_1"; |
|
868 |
val hypreal_mult_minus_1_right = thm "hypreal_mult_minus_1_right"; |
|
869 |
val hypreal_zero_not_eq_one = thm "hypreal_zero_not_eq_one"; |
|
870 |
val hypreal_inverse_congruent = thm "hypreal_inverse_congruent"; |
|
871 |
val hypreal_inverse = thm "hypreal_inverse"; |
|
872 |
val hypreal_mult_inverse = thm "hypreal_mult_inverse"; |
|
873 |
val hypreal_mult_inverse_left = thm "hypreal_mult_inverse_left"; |
|
874 |
val hypreal_mult_left_cancel = thm "hypreal_mult_left_cancel"; |
|
875 |
val hypreal_mult_right_cancel = thm "hypreal_mult_right_cancel"; |
|
876 |
val hypreal_mult_not_0 = thm "hypreal_mult_not_0"; |
|
877 |
val hypreal_minus_inverse = thm "hypreal_minus_inverse"; |
|
878 |
val hypreal_inverse_distrib = thm "hypreal_inverse_distrib"; |
|
879 |
val hypreal_not_refl2 = thm "hypreal_not_refl2"; |
|
880 |
val hypreal_less = thm "hypreal_less"; |
|
881 |
val hypreal_eq_minus_iff = thm "hypreal_eq_minus_iff"; |
|
882 |
val hypreal_eq_minus_iff3 = thm "hypreal_eq_minus_iff3"; |
|
883 |
val hypreal_not_eq_minus_iff = thm "hypreal_not_eq_minus_iff"; |
|
884 |
val hypreal_le = thm "hypreal_le"; |
|
885 |
val hypreal_le_refl = thm "hypreal_le_refl"; |
|
886 |
val hypreal_le_linear = thm "hypreal_le_linear"; |
|
887 |
val hypreal_le_trans = thm "hypreal_le_trans"; |
|
888 |
val hypreal_le_anti_sym = thm "hypreal_le_anti_sym"; |
|
889 |
val hypreal_less_le = thm "hypreal_less_le"; |
|
890 |
val hypreal_of_real_add = thm "hypreal_of_real_add"; |
|
891 |
val hypreal_of_real_mult = thm "hypreal_of_real_mult"; |
|
892 |
val hypreal_of_real_less_iff = thm "hypreal_of_real_less_iff"; |
|
893 |
val hypreal_of_real_le_iff = thm "hypreal_of_real_le_iff"; |
|
894 |
val hypreal_of_real_eq_iff = thm "hypreal_of_real_eq_iff"; |
|
895 |
val hypreal_of_real_minus = thm "hypreal_of_real_minus"; |
|
896 |
val hypreal_of_real_one = thm "hypreal_of_real_one"; |
|
897 |
val hypreal_of_real_zero = thm "hypreal_of_real_zero"; |
|
898 |
val hypreal_of_real_inverse = thm "hypreal_of_real_inverse"; |
|
899 |
val hypreal_of_real_divide = thm "hypreal_of_real_divide"; |
|
900 |
val hypreal_divide_one = thm "hypreal_divide_one"; |
|
901 |
val hypreal_add_divide_distrib = thm "hypreal_add_divide_distrib"; |
|
902 |
val hypreal_inverse_add = thm "hypreal_inverse_add"; |
|
903 |
val hypreal_zero_num = thm "hypreal_zero_num"; |
|
904 |
val hypreal_one_num = thm "hypreal_one_num"; |
|
905 |
val hypreal_omega_gt_zero = thm "hypreal_omega_gt_zero"; |
|
14370 | 906 |
|
907 |
val hypreal_add_zero_less_le_mono = thm"hypreal_add_zero_less_le_mono"; |
|
908 |
val Rep_hypreal_omega = thm"Rep_hypreal_omega"; |
|
909 |
val lemma_omega_empty_singleton_disj = thm"lemma_omega_empty_singleton_disj"; |
|
910 |
val lemma_finite_omega_set = thm"lemma_finite_omega_set"; |
|
911 |
val not_ex_hypreal_of_real_eq_omega = thm"not_ex_hypreal_of_real_eq_omega"; |
|
912 |
val hypreal_of_real_not_eq_omega = thm"hypreal_of_real_not_eq_omega"; |
|
913 |
val not_ex_hypreal_of_real_eq_epsilon = thm"not_ex_hypreal_of_real_eq_epsilon"; |
|
914 |
val hypreal_of_real_not_eq_epsilon = thm"hypreal_of_real_not_eq_epsilon"; |
|
915 |
val hypreal_epsilon_not_zero = thm"hypreal_epsilon_not_zero"; |
|
916 |
val hypreal_epsilon_inverse_omega = thm"hypreal_epsilon_inverse_omega"; |
|
14299 | 917 |
*} |
918 |
||
10751 | 919 |
end |