author | paulson |
Fri, 16 Nov 2001 18:24:11 +0100 | |
changeset 12224 | 02df7cbe7d25 |
parent 12018 | ec054019c910 |
child 13438 | 527811f00c56 |
permissions | -rw-r--r-- |
10751 | 1 |
(* Title : HOL/Real/Hyperreal/Hyper.ML |
2 |
ID : $Id$ |
|
3 |
Author : Jacques D. Fleuriot |
|
4 |
Copyright : 1998 University of Cambridge |
|
5 |
Description : Ultrapower construction of hyperreals |
|
6 |
*) |
|
7 |
||
8 |
(*------------------------------------------------------------------------ |
|
9 |
Proof that the set of naturals is not finite |
|
10 |
------------------------------------------------------------------------*) |
|
11 |
||
12 |
(*** based on James' proof that the set of naturals is not finite ***) |
|
13 |
Goal "finite (A::nat set) --> (EX n. ALL m. Suc (n + m) ~: A)"; |
|
14 |
by (rtac impI 1); |
|
15 |
by (eres_inst_tac [("F","A")] finite_induct 1); |
|
16 |
by (Blast_tac 1 THEN etac exE 1); |
|
17 |
by (res_inst_tac [("x","n + x")] exI 1); |
|
18 |
by (rtac allI 1 THEN eres_inst_tac [("x","x + m")] allE 1); |
|
19 |
by (auto_tac (claset(), simpset() addsimps add_ac)); |
|
20 |
by (auto_tac (claset(), |
|
21 |
simpset() addsimps [add_assoc RS sym, |
|
22 |
less_add_Suc2 RS less_not_refl2])); |
|
23 |
qed_spec_mp "finite_exhausts"; |
|
24 |
||
25 |
Goal "finite (A :: nat set) --> (EX n. n ~:A)"; |
|
26 |
by (rtac impI 1 THEN dtac finite_exhausts 1); |
|
27 |
by (Blast_tac 1); |
|
28 |
qed_spec_mp "finite_not_covers"; |
|
29 |
||
30 |
Goal "~ finite(UNIV:: nat set)"; |
|
31 |
by (fast_tac (claset() addSDs [finite_exhausts]) 1); |
|
32 |
qed "not_finite_nat"; |
|
33 |
||
34 |
(*------------------------------------------------------------------------ |
|
35 |
Existence of free ultrafilter over the naturals and proof of various |
|
36 |
properties of the FreeUltrafilterNat- an arbitrary free ultrafilter |
|
37 |
------------------------------------------------------------------------*) |
|
38 |
||
39 |
Goal "EX U. U: FreeUltrafilter (UNIV::nat set)"; |
|
40 |
by (rtac (not_finite_nat RS FreeUltrafilter_Ex) 1); |
|
41 |
qed "FreeUltrafilterNat_Ex"; |
|
42 |
||
43 |
Goalw [FreeUltrafilterNat_def] |
|
44 |
"FreeUltrafilterNat: FreeUltrafilter(UNIV:: nat set)"; |
|
45 |
by (rtac (FreeUltrafilterNat_Ex RS exE) 1); |
|
46 |
by (rtac someI2 1 THEN ALLGOALS(assume_tac)); |
|
47 |
qed "FreeUltrafilterNat_mem"; |
|
48 |
Addsimps [FreeUltrafilterNat_mem]; |
|
49 |
||
50 |
Goalw [FreeUltrafilterNat_def] "finite x ==> x ~: FreeUltrafilterNat"; |
|
51 |
by (rtac (FreeUltrafilterNat_Ex RS exE) 1); |
|
52 |
by (rtac someI2 1 THEN assume_tac 1); |
|
53 |
by (blast_tac (claset() addDs [mem_FreeUltrafiltersetD1]) 1); |
|
54 |
qed "FreeUltrafilterNat_finite"; |
|
55 |
||
56 |
Goal "x: FreeUltrafilterNat ==> ~ finite x"; |
|
57 |
by (blast_tac (claset() addDs [FreeUltrafilterNat_finite]) 1); |
|
58 |
qed "FreeUltrafilterNat_not_finite"; |
|
59 |
||
60 |
Goalw [FreeUltrafilterNat_def] "{} ~: FreeUltrafilterNat"; |
|
61 |
by (rtac (FreeUltrafilterNat_Ex RS exE) 1); |
|
62 |
by (rtac someI2 1 THEN assume_tac 1); |
|
63 |
by (blast_tac (claset() addDs [FreeUltrafilter_Ultrafilter, |
|
64 |
Ultrafilter_Filter,Filter_empty_not_mem]) 1); |
|
65 |
qed "FreeUltrafilterNat_empty"; |
|
66 |
Addsimps [FreeUltrafilterNat_empty]; |
|
67 |
||
68 |
Goal "[| X: FreeUltrafilterNat; Y: FreeUltrafilterNat |] \ |
|
69 |
\ ==> X Int Y : FreeUltrafilterNat"; |
|
70 |
by (cut_facts_tac [FreeUltrafilterNat_mem] 1); |
|
71 |
by (blast_tac (claset() addDs [FreeUltrafilter_Ultrafilter, |
|
72 |
Ultrafilter_Filter,mem_FiltersetD1]) 1); |
|
73 |
qed "FreeUltrafilterNat_Int"; |
|
74 |
||
75 |
Goal "[| X: FreeUltrafilterNat; X <= Y |] \ |
|
76 |
\ ==> Y : FreeUltrafilterNat"; |
|
77 |
by (cut_facts_tac [FreeUltrafilterNat_mem] 1); |
|
78 |
by (blast_tac (claset() addDs [FreeUltrafilter_Ultrafilter, |
|
79 |
Ultrafilter_Filter,mem_FiltersetD2]) 1); |
|
80 |
qed "FreeUltrafilterNat_subset"; |
|
81 |
||
82 |
Goal "X: FreeUltrafilterNat ==> -X ~: FreeUltrafilterNat"; |
|
83 |
by (Step_tac 1); |
|
84 |
by (dtac FreeUltrafilterNat_Int 1 THEN assume_tac 1); |
|
85 |
by Auto_tac; |
|
86 |
qed "FreeUltrafilterNat_Compl"; |
|
87 |
||
88 |
Goal "X~: FreeUltrafilterNat ==> -X : FreeUltrafilterNat"; |
|
89 |
by (cut_facts_tac [FreeUltrafilterNat_mem RS (FreeUltrafilter_iff RS iffD1)] 1); |
|
90 |
by (Step_tac 1 THEN dres_inst_tac [("x","X")] bspec 1); |
|
91 |
by (auto_tac (claset(), simpset() addsimps [UNIV_diff_Compl])); |
|
92 |
qed "FreeUltrafilterNat_Compl_mem"; |
|
93 |
||
94 |
Goal "(X ~: FreeUltrafilterNat) = (-X: FreeUltrafilterNat)"; |
|
95 |
by (blast_tac (claset() addDs [FreeUltrafilterNat_Compl, |
|
96 |
FreeUltrafilterNat_Compl_mem]) 1); |
|
97 |
qed "FreeUltrafilterNat_Compl_iff1"; |
|
98 |
||
99 |
Goal "(X: FreeUltrafilterNat) = (-X ~: FreeUltrafilterNat)"; |
|
100 |
by (auto_tac (claset(), |
|
101 |
simpset() addsimps [FreeUltrafilterNat_Compl_iff1 RS sym])); |
|
102 |
qed "FreeUltrafilterNat_Compl_iff2"; |
|
103 |
||
104 |
Goal "(UNIV::nat set) : FreeUltrafilterNat"; |
|
105 |
by (rtac (FreeUltrafilterNat_mem RS FreeUltrafilter_Ultrafilter RS |
|
106 |
Ultrafilter_Filter RS mem_FiltersetD4) 1); |
|
107 |
qed "FreeUltrafilterNat_UNIV"; |
|
108 |
Addsimps [FreeUltrafilterNat_UNIV]; |
|
109 |
||
110 |
Goal "UNIV : FreeUltrafilterNat"; |
|
111 |
by Auto_tac; |
|
112 |
qed "FreeUltrafilterNat_Nat_set"; |
|
113 |
Addsimps [FreeUltrafilterNat_Nat_set]; |
|
114 |
||
115 |
Goal "{n. P(n) = P(n)} : FreeUltrafilterNat"; |
|
116 |
by (Simp_tac 1); |
|
117 |
qed "FreeUltrafilterNat_Nat_set_refl"; |
|
118 |
AddIs [FreeUltrafilterNat_Nat_set_refl]; |
|
119 |
||
120 |
Goal "{n::nat. P} : FreeUltrafilterNat ==> P"; |
|
121 |
by (rtac ccontr 1); |
|
122 |
by (rotate_tac 1 1); |
|
123 |
by (Asm_full_simp_tac 1); |
|
124 |
qed "FreeUltrafilterNat_P"; |
|
125 |
||
126 |
Goal "{n. P(n)} : FreeUltrafilterNat ==> EX n. P(n)"; |
|
127 |
by (rtac ccontr 1 THEN rotate_tac 1 1); |
|
128 |
by (Asm_full_simp_tac 1); |
|
129 |
qed "FreeUltrafilterNat_Ex_P"; |
|
130 |
||
131 |
Goal "ALL n. P(n) ==> {n. P(n)} : FreeUltrafilterNat"; |
|
132 |
by (auto_tac (claset() addIs [FreeUltrafilterNat_Nat_set], simpset())); |
|
133 |
qed "FreeUltrafilterNat_all"; |
|
134 |
||
135 |
(*------------------------------------------------------- |
|
136 |
Define and use Ultrafilter tactics |
|
137 |
-------------------------------------------------------*) |
|
138 |
use "fuf.ML"; |
|
139 |
||
140 |
(*------------------------------------------------------- |
|
141 |
Now prove one further property of our free ultrafilter |
|
142 |
-------------------------------------------------------*) |
|
143 |
Goal "X Un Y: FreeUltrafilterNat \ |
|
144 |
\ ==> X: FreeUltrafilterNat | Y: FreeUltrafilterNat"; |
|
145 |
by Auto_tac; |
|
146 |
by (Ultra_tac 1); |
|
147 |
qed "FreeUltrafilterNat_Un"; |
|
148 |
||
149 |
(*------------------------------------------------------- |
|
150 |
Properties of hyprel |
|
151 |
-------------------------------------------------------*) |
|
152 |
||
153 |
(** Proving that hyprel is an equivalence relation **) |
|
154 |
(** Natural deduction for hyprel **) |
|
155 |
||
156 |
Goalw [hyprel_def] |
|
157 |
"((X,Y): hyprel) = ({n. X n = Y n}: FreeUltrafilterNat)"; |
|
158 |
by (Fast_tac 1); |
|
159 |
qed "hyprel_iff"; |
|
160 |
||
161 |
Goalw [hyprel_def] |
|
162 |
"{n. X n = Y n}: FreeUltrafilterNat ==> (X,Y): hyprel"; |
|
163 |
by (Fast_tac 1); |
|
164 |
qed "hyprelI"; |
|
165 |
||
166 |
Goalw [hyprel_def] |
|
167 |
"p: hyprel --> (EX X Y. \ |
|
168 |
\ p = (X,Y) & {n. X n = Y n} : FreeUltrafilterNat)"; |
|
169 |
by (Fast_tac 1); |
|
170 |
qed "hyprelE_lemma"; |
|
171 |
||
172 |
val [major,minor] = goal (the_context ()) |
|
173 |
"[| p: hyprel; \ |
|
174 |
\ !!X Y. [| p = (X,Y); {n. X n = Y n}: FreeUltrafilterNat\ |
|
175 |
\ |] ==> Q |] ==> Q"; |
|
176 |
by (cut_facts_tac [major RS (hyprelE_lemma RS mp)] 1); |
|
177 |
by (REPEAT (eresolve_tac [asm_rl,exE,conjE,minor] 1)); |
|
178 |
qed "hyprelE"; |
|
179 |
||
180 |
AddSIs [hyprelI]; |
|
181 |
AddSEs [hyprelE]; |
|
182 |
||
183 |
Goalw [hyprel_def] "(x,x): hyprel"; |
|
184 |
by (auto_tac (claset(), |
|
185 |
simpset() addsimps [FreeUltrafilterNat_Nat_set])); |
|
186 |
qed "hyprel_refl"; |
|
187 |
||
188 |
Goal "{n. X n = Y n} = {n. Y n = X n}"; |
|
189 |
by Auto_tac; |
|
190 |
qed "lemma_perm"; |
|
191 |
||
192 |
Goalw [hyprel_def] "(x,y): hyprel --> (y,x):hyprel"; |
|
193 |
by (auto_tac (claset() addIs [lemma_perm RS subst], simpset())); |
|
194 |
qed_spec_mp "hyprel_sym"; |
|
195 |
||
196 |
Goalw [hyprel_def] |
|
197 |
"(x,y): hyprel --> (y,z):hyprel --> (x,z):hyprel"; |
|
198 |
by Auto_tac; |
|
199 |
by (Ultra_tac 1); |
|
200 |
qed_spec_mp "hyprel_trans"; |
|
201 |
||
202 |
Goalw [equiv_def, refl_def, sym_def, trans_def] "equiv UNIV hyprel"; |
|
203 |
by (auto_tac (claset() addSIs [hyprel_refl] |
|
204 |
addSEs [hyprel_sym,hyprel_trans] |
|
205 |
delrules [hyprelI,hyprelE], |
|
206 |
simpset() addsimps [FreeUltrafilterNat_Nat_set])); |
|
207 |
qed "equiv_hyprel"; |
|
208 |
||
10834 | 209 |
(* (hyprel `` {x} = hyprel `` {y}) = ((x,y) : hyprel) *) |
10751 | 210 |
bind_thm ("equiv_hyprel_iff", |
211 |
[equiv_hyprel, UNIV_I, UNIV_I] MRS eq_equiv_class_iff); |
|
212 |
||
10834 | 213 |
Goalw [hypreal_def,hyprel_def,quotient_def] "hyprel``{x}:hypreal"; |
10751 | 214 |
by (Blast_tac 1); |
215 |
qed "hyprel_in_hypreal"; |
|
216 |
||
217 |
Goal "inj_on Abs_hypreal hypreal"; |
|
218 |
by (rtac inj_on_inverseI 1); |
|
219 |
by (etac Abs_hypreal_inverse 1); |
|
220 |
qed "inj_on_Abs_hypreal"; |
|
221 |
||
222 |
Addsimps [equiv_hyprel_iff,inj_on_Abs_hypreal RS inj_on_iff, |
|
223 |
hyprel_iff, hyprel_in_hypreal, Abs_hypreal_inverse]; |
|
224 |
||
225 |
Addsimps [equiv_hyprel RS eq_equiv_class_iff]; |
|
226 |
bind_thm ("eq_hyprelD", equiv_hyprel RSN (2,eq_equiv_class)); |
|
227 |
||
228 |
Goal "inj(Rep_hypreal)"; |
|
229 |
by (rtac inj_inverseI 1); |
|
230 |
by (rtac Rep_hypreal_inverse 1); |
|
231 |
qed "inj_Rep_hypreal"; |
|
232 |
||
10834 | 233 |
Goalw [hyprel_def] "x: hyprel `` {x}"; |
10751 | 234 |
by (Step_tac 1); |
235 |
by (auto_tac (claset() addSIs [FreeUltrafilterNat_Nat_set], simpset())); |
|
236 |
qed "lemma_hyprel_refl"; |
|
237 |
||
238 |
Addsimps [lemma_hyprel_refl]; |
|
239 |
||
240 |
Goalw [hypreal_def] "{} ~: hypreal"; |
|
241 |
by (auto_tac (claset() addSEs [quotientE], simpset())); |
|
242 |
qed "hypreal_empty_not_mem"; |
|
243 |
||
244 |
Addsimps [hypreal_empty_not_mem]; |
|
245 |
||
246 |
Goal "Rep_hypreal x ~= {}"; |
|
247 |
by (cut_inst_tac [("x","x")] Rep_hypreal 1); |
|
248 |
by Auto_tac; |
|
249 |
qed "Rep_hypreal_nonempty"; |
|
250 |
||
251 |
Addsimps [Rep_hypreal_nonempty]; |
|
252 |
||
253 |
(*------------------------------------------------------------------------ |
|
254 |
hypreal_of_real: the injection from real to hypreal |
|
255 |
------------------------------------------------------------------------*) |
|
256 |
||
257 |
Goal "inj(hypreal_of_real)"; |
|
258 |
by (rtac injI 1); |
|
259 |
by (rewtac hypreal_of_real_def); |
|
260 |
by (dtac (inj_on_Abs_hypreal RS inj_onD) 1); |
|
261 |
by (REPEAT (rtac hyprel_in_hypreal 1)); |
|
262 |
by (dtac eq_equiv_class 1); |
|
263 |
by (rtac equiv_hyprel 1); |
|
264 |
by (Fast_tac 1); |
|
265 |
by (rtac ccontr 1 THEN rotate_tac 1 1); |
|
266 |
by Auto_tac; |
|
267 |
qed "inj_hypreal_of_real"; |
|
268 |
||
269 |
val [prem] = goal (the_context ()) |
|
10834 | 270 |
"(!!x y. z = Abs_hypreal(hyprel``{x}) ==> P) ==> P"; |
10751 | 271 |
by (res_inst_tac [("x1","z")] |
272 |
(rewrite_rule [hypreal_def] Rep_hypreal RS quotientE) 1); |
|
273 |
by (dres_inst_tac [("f","Abs_hypreal")] arg_cong 1); |
|
274 |
by (res_inst_tac [("x","x")] prem 1); |
|
275 |
by (asm_full_simp_tac (simpset() addsimps [Rep_hypreal_inverse]) 1); |
|
276 |
qed "eq_Abs_hypreal"; |
|
277 |
||
278 |
(**** hypreal_minus: additive inverse on hypreal ****) |
|
279 |
||
280 |
Goalw [congruent_def] |
|
10834 | 281 |
"congruent hyprel (%X. hyprel``{%n. - (X n)})"; |
10751 | 282 |
by Safe_tac; |
283 |
by (ALLGOALS Ultra_tac); |
|
284 |
qed "hypreal_minus_congruent"; |
|
285 |
||
286 |
Goalw [hypreal_minus_def] |
|
10834 | 287 |
"- (Abs_hypreal(hyprel``{%n. X n})) = Abs_hypreal(hyprel `` {%n. -(X n)})"; |
10751 | 288 |
by (res_inst_tac [("f","Abs_hypreal")] arg_cong 1); |
289 |
by (simp_tac (simpset() addsimps |
|
290 |
[hyprel_in_hypreal RS Abs_hypreal_inverse, |
|
291 |
[equiv_hyprel, hypreal_minus_congruent] MRS UN_equiv_class]) 1); |
|
292 |
qed "hypreal_minus"; |
|
293 |
||
294 |
Goal "- (- z) = (z::hypreal)"; |
|
295 |
by (res_inst_tac [("z","z")] eq_Abs_hypreal 1); |
|
296 |
by (asm_simp_tac (simpset() addsimps [hypreal_minus]) 1); |
|
297 |
qed "hypreal_minus_minus"; |
|
298 |
||
299 |
Addsimps [hypreal_minus_minus]; |
|
300 |
||
301 |
Goal "inj(%r::hypreal. -r)"; |
|
302 |
by (rtac injI 1); |
|
303 |
by (dres_inst_tac [("f","uminus")] arg_cong 1); |
|
304 |
by (asm_full_simp_tac (simpset() addsimps [hypreal_minus_minus]) 1); |
|
305 |
qed "inj_hypreal_minus"; |
|
306 |
||
11701
3d51fbf81c17
sane numerals (stage 1): added generic 1, removed 1' and 2 on nat,
wenzelm
parents:
11655
diff
changeset
|
307 |
Goalw [hypreal_zero_def] "- 0 = (0::hypreal)"; |
10751 | 308 |
by (simp_tac (simpset() addsimps [hypreal_minus]) 1); |
309 |
qed "hypreal_minus_zero"; |
|
310 |
Addsimps [hypreal_minus_zero]; |
|
311 |
||
312 |
Goal "(-x = 0) = (x = (0::hypreal))"; |
|
313 |
by (res_inst_tac [("z","x")] eq_Abs_hypreal 1); |
|
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
314 |
by (auto_tac (claset(), simpset() addsimps [hypreal_zero_def, hypreal_minus])); |
10751 | 315 |
qed "hypreal_minus_zero_iff"; |
316 |
Addsimps [hypreal_minus_zero_iff]; |
|
317 |
||
318 |
||
319 |
(**** hyperreal addition: hypreal_add ****) |
|
320 |
||
321 |
Goalw [congruent2_def] |
|
10834 | 322 |
"congruent2 hyprel (%X Y. hyprel``{%n. X n + Y n})"; |
10751 | 323 |
by Safe_tac; |
324 |
by (ALLGOALS(Ultra_tac)); |
|
325 |
qed "hypreal_add_congruent2"; |
|
326 |
||
327 |
Goalw [hypreal_add_def] |
|
10834 | 328 |
"Abs_hypreal(hyprel``{%n. X n}) + Abs_hypreal(hyprel``{%n. Y n}) = \ |
329 |
\ Abs_hypreal(hyprel``{%n. X n + Y n})"; |
|
10751 | 330 |
by (simp_tac (simpset() addsimps |
331 |
[[equiv_hyprel, hypreal_add_congruent2] MRS UN_equiv_class2]) 1); |
|
332 |
qed "hypreal_add"; |
|
333 |
||
10834 | 334 |
Goal "Abs_hypreal(hyprel``{%n. X n}) - Abs_hypreal(hyprel``{%n. Y n}) = \ |
335 |
\ Abs_hypreal(hyprel``{%n. X n - Y n})"; |
|
10751 | 336 |
by (simp_tac (simpset() addsimps |
337 |
[hypreal_diff_def, hypreal_minus,hypreal_add]) 1); |
|
338 |
qed "hypreal_diff"; |
|
339 |
||
340 |
Goal "(z::hypreal) + w = w + z"; |
|
341 |
by (res_inst_tac [("z","z")] eq_Abs_hypreal 1); |
|
342 |
by (res_inst_tac [("z","w")] eq_Abs_hypreal 1); |
|
343 |
by (asm_simp_tac (simpset() addsimps (real_add_ac @ [hypreal_add])) 1); |
|
344 |
qed "hypreal_add_commute"; |
|
345 |
||
346 |
Goal "((z1::hypreal) + z2) + z3 = z1 + (z2 + z3)"; |
|
347 |
by (res_inst_tac [("z","z1")] eq_Abs_hypreal 1); |
|
348 |
by (res_inst_tac [("z","z2")] eq_Abs_hypreal 1); |
|
349 |
by (res_inst_tac [("z","z3")] eq_Abs_hypreal 1); |
|
350 |
by (asm_simp_tac (simpset() addsimps [hypreal_add, real_add_assoc]) 1); |
|
351 |
qed "hypreal_add_assoc"; |
|
352 |
||
353 |
(*For AC rewriting*) |
|
354 |
Goal "(x::hypreal)+(y+z)=y+(x+z)"; |
|
355 |
by (rtac (hypreal_add_commute RS trans) 1); |
|
356 |
by (rtac (hypreal_add_assoc RS trans) 1); |
|
357 |
by (rtac (hypreal_add_commute RS arg_cong) 1); |
|
358 |
qed "hypreal_add_left_commute"; |
|
359 |
||
360 |
(* hypreal addition is an AC operator *) |
|
361 |
bind_thms ("hypreal_add_ac", [hypreal_add_assoc,hypreal_add_commute, |
|
362 |
hypreal_add_left_commute]); |
|
363 |
||
364 |
Goalw [hypreal_zero_def] "(0::hypreal) + z = z"; |
|
365 |
by (res_inst_tac [("z","z")] eq_Abs_hypreal 1); |
|
366 |
by (asm_full_simp_tac (simpset() addsimps |
|
367 |
[hypreal_add]) 1); |
|
368 |
qed "hypreal_add_zero_left"; |
|
369 |
||
370 |
Goal "z + (0::hypreal) = z"; |
|
371 |
by (simp_tac (simpset() addsimps |
|
372 |
[hypreal_add_zero_left,hypreal_add_commute]) 1); |
|
373 |
qed "hypreal_add_zero_right"; |
|
374 |
||
375 |
Goalw [hypreal_zero_def] "z + -z = (0::hypreal)"; |
|
376 |
by (res_inst_tac [("z","z")] eq_Abs_hypreal 1); |
|
377 |
by (asm_full_simp_tac (simpset() addsimps [hypreal_minus, hypreal_add]) 1); |
|
378 |
qed "hypreal_add_minus"; |
|
379 |
||
380 |
Goal "-z + z = (0::hypreal)"; |
|
381 |
by (simp_tac (simpset() addsimps [hypreal_add_commute, hypreal_add_minus]) 1); |
|
382 |
qed "hypreal_add_minus_left"; |
|
383 |
||
384 |
Addsimps [hypreal_add_minus,hypreal_add_minus_left, |
|
385 |
hypreal_add_zero_left,hypreal_add_zero_right]; |
|
386 |
||
387 |
Goal "EX y. (x::hypreal) + y = 0"; |
|
388 |
by (fast_tac (claset() addIs [hypreal_add_minus]) 1); |
|
389 |
qed "hypreal_minus_ex"; |
|
390 |
||
391 |
Goal "EX! y. (x::hypreal) + y = 0"; |
|
392 |
by (auto_tac (claset() addIs [hypreal_add_minus], simpset())); |
|
393 |
by (dres_inst_tac [("f","%x. ya+x")] arg_cong 1); |
|
394 |
by (asm_full_simp_tac (simpset() addsimps [hypreal_add_assoc RS sym]) 1); |
|
395 |
by (asm_full_simp_tac (simpset() addsimps [hypreal_add_commute]) 1); |
|
396 |
qed "hypreal_minus_ex1"; |
|
397 |
||
398 |
Goal "EX! y. y + (x::hypreal) = 0"; |
|
399 |
by (auto_tac (claset() addIs [hypreal_add_minus_left], simpset())); |
|
400 |
by (dres_inst_tac [("f","%x. x+ya")] arg_cong 1); |
|
401 |
by (asm_full_simp_tac (simpset() addsimps [hypreal_add_assoc]) 1); |
|
402 |
by (asm_full_simp_tac (simpset() addsimps [hypreal_add_commute]) 1); |
|
403 |
qed "hypreal_minus_left_ex1"; |
|
404 |
||
405 |
Goal "x + y = (0::hypreal) ==> x = -y"; |
|
406 |
by (cut_inst_tac [("z","y")] hypreal_add_minus_left 1); |
|
407 |
by (res_inst_tac [("x1","y")] (hypreal_minus_left_ex1 RS ex1E) 1); |
|
408 |
by (Blast_tac 1); |
|
409 |
qed "hypreal_add_minus_eq_minus"; |
|
410 |
||
411 |
Goal "EX y::hypreal. x = -y"; |
|
412 |
by (cut_inst_tac [("x","x")] hypreal_minus_ex 1); |
|
413 |
by (etac exE 1 THEN dtac hypreal_add_minus_eq_minus 1); |
|
414 |
by (Fast_tac 1); |
|
415 |
qed "hypreal_as_add_inverse_ex"; |
|
416 |
||
417 |
Goal "-(x + (y::hypreal)) = -x + -y"; |
|
418 |
by (res_inst_tac [("z","x")] eq_Abs_hypreal 1); |
|
419 |
by (res_inst_tac [("z","y")] eq_Abs_hypreal 1); |
|
420 |
by (auto_tac (claset(), |
|
421 |
simpset() addsimps [hypreal_minus, hypreal_add, |
|
422 |
real_minus_add_distrib])); |
|
423 |
qed "hypreal_minus_add_distrib"; |
|
424 |
Addsimps [hypreal_minus_add_distrib]; |
|
425 |
||
426 |
Goal "-(y + -(x::hypreal)) = x + -y"; |
|
427 |
by (simp_tac (simpset() addsimps [hypreal_add_commute]) 1); |
|
428 |
qed "hypreal_minus_distrib1"; |
|
429 |
||
430 |
Goal "((x::hypreal) + y = x + z) = (y = z)"; |
|
431 |
by (Step_tac 1); |
|
432 |
by (dres_inst_tac [("f","%t.-x + t")] arg_cong 1); |
|
433 |
by (asm_full_simp_tac (simpset() addsimps [hypreal_add_assoc RS sym]) 1); |
|
434 |
qed "hypreal_add_left_cancel"; |
|
435 |
||
436 |
Goal "(y + (x::hypreal)= z + x) = (y = z)"; |
|
437 |
by (simp_tac (simpset() addsimps [hypreal_add_commute, |
|
438 |
hypreal_add_left_cancel]) 1); |
|
439 |
qed "hypreal_add_right_cancel"; |
|
440 |
||
441 |
Goal "z + ((- z) + w) = (w::hypreal)"; |
|
442 |
by (simp_tac (simpset() addsimps [hypreal_add_assoc RS sym]) 1); |
|
443 |
qed "hypreal_add_minus_cancelA"; |
|
444 |
||
445 |
Goal "(-z) + (z + w) = (w::hypreal)"; |
|
446 |
by (simp_tac (simpset() addsimps [hypreal_add_assoc RS sym]) 1); |
|
447 |
qed "hypreal_minus_add_cancelA"; |
|
448 |
||
449 |
Addsimps [hypreal_add_minus_cancelA, hypreal_minus_add_cancelA]; |
|
450 |
||
451 |
(**** hyperreal multiplication: hypreal_mult ****) |
|
452 |
||
453 |
Goalw [congruent2_def] |
|
10834 | 454 |
"congruent2 hyprel (%X Y. hyprel``{%n. X n * Y n})"; |
10751 | 455 |
by Safe_tac; |
456 |
by (ALLGOALS(Ultra_tac)); |
|
457 |
qed "hypreal_mult_congruent2"; |
|
458 |
||
459 |
Goalw [hypreal_mult_def] |
|
10834 | 460 |
"Abs_hypreal(hyprel``{%n. X n}) * Abs_hypreal(hyprel``{%n. Y n}) = \ |
461 |
\ Abs_hypreal(hyprel``{%n. X n * Y n})"; |
|
10751 | 462 |
by (simp_tac (simpset() addsimps |
463 |
[[equiv_hyprel, hypreal_mult_congruent2] MRS UN_equiv_class2]) 1); |
|
464 |
qed "hypreal_mult"; |
|
465 |
||
466 |
Goal "(z::hypreal) * w = w * z"; |
|
467 |
by (res_inst_tac [("z","z")] eq_Abs_hypreal 1); |
|
468 |
by (res_inst_tac [("z","w")] eq_Abs_hypreal 1); |
|
469 |
by (asm_simp_tac (simpset() addsimps ([hypreal_mult] @ real_mult_ac)) 1); |
|
470 |
qed "hypreal_mult_commute"; |
|
471 |
||
472 |
Goal "((z1::hypreal) * z2) * z3 = z1 * (z2 * z3)"; |
|
473 |
by (res_inst_tac [("z","z1")] eq_Abs_hypreal 1); |
|
474 |
by (res_inst_tac [("z","z2")] eq_Abs_hypreal 1); |
|
475 |
by (res_inst_tac [("z","z3")] eq_Abs_hypreal 1); |
|
476 |
by (asm_simp_tac (simpset() addsimps [hypreal_mult,real_mult_assoc]) 1); |
|
477 |
qed "hypreal_mult_assoc"; |
|
478 |
||
479 |
qed_goal "hypreal_mult_left_commute" (the_context ()) |
|
480 |
"(z1::hypreal) * (z2 * z3) = z2 * (z1 * z3)" |
|
481 |
(fn _ => [rtac (hypreal_mult_commute RS trans) 1, |
|
482 |
rtac (hypreal_mult_assoc RS trans) 1, |
|
483 |
rtac (hypreal_mult_commute RS arg_cong) 1]); |
|
484 |
||
485 |
(* hypreal multiplication is an AC operator *) |
|
486 |
bind_thms ("hypreal_mult_ac", [hypreal_mult_assoc, hypreal_mult_commute, |
|
487 |
hypreal_mult_left_commute]); |
|
488 |
||
11713
883d559b0b8c
sane numerals (stage 3): provide generic "1" on all number types;
wenzelm
parents:
11701
diff
changeset
|
489 |
Goalw [hypreal_one_def] "(1::hypreal) * z = z"; |
10751 | 490 |
by (res_inst_tac [("z","z")] eq_Abs_hypreal 1); |
491 |
by (asm_full_simp_tac (simpset() addsimps [hypreal_mult]) 1); |
|
492 |
qed "hypreal_mult_1"; |
|
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
493 |
Addsimps [hypreal_mult_1]; |
10751 | 494 |
|
11713
883d559b0b8c
sane numerals (stage 3): provide generic "1" on all number types;
wenzelm
parents:
11701
diff
changeset
|
495 |
Goal "z * (1::hypreal) = z"; |
10751 | 496 |
by (simp_tac (simpset() addsimps [hypreal_mult_commute, |
497 |
hypreal_mult_1]) 1); |
|
498 |
qed "hypreal_mult_1_right"; |
|
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
499 |
Addsimps [hypreal_mult_1_right]; |
10751 | 500 |
|
501 |
Goalw [hypreal_zero_def] "0 * z = (0::hypreal)"; |
|
502 |
by (res_inst_tac [("z","z")] eq_Abs_hypreal 1); |
|
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
503 |
by (asm_full_simp_tac (simpset() addsimps [hypreal_mult]) 1); |
10751 | 504 |
qed "hypreal_mult_0"; |
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
505 |
Addsimps [hypreal_mult_0]; |
10751 | 506 |
|
507 |
Goal "z * 0 = (0::hypreal)"; |
|
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
508 |
by (simp_tac (simpset() addsimps [hypreal_mult_commute]) 1); |
10751 | 509 |
qed "hypreal_mult_0_right"; |
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
510 |
Addsimps [hypreal_mult_0_right]; |
10751 | 511 |
|
512 |
Goal "-(x * y) = -x * (y::hypreal)"; |
|
513 |
by (res_inst_tac [("z","x")] eq_Abs_hypreal 1); |
|
514 |
by (res_inst_tac [("z","y")] eq_Abs_hypreal 1); |
|
515 |
by (auto_tac (claset(), |
|
516 |
simpset() addsimps [hypreal_minus, hypreal_mult] |
|
517 |
@ real_mult_ac @ real_add_ac)); |
|
518 |
qed "hypreal_minus_mult_eq1"; |
|
519 |
||
520 |
Goal "-(x * y) = (x::hypreal) * -y"; |
|
521 |
by (res_inst_tac [("z","x")] eq_Abs_hypreal 1); |
|
522 |
by (res_inst_tac [("z","y")] eq_Abs_hypreal 1); |
|
523 |
by (auto_tac (claset(), simpset() addsimps [hypreal_minus, hypreal_mult] |
|
524 |
@ real_mult_ac @ real_add_ac)); |
|
525 |
qed "hypreal_minus_mult_eq2"; |
|
526 |
||
527 |
(*Pull negations out*) |
|
528 |
Addsimps [hypreal_minus_mult_eq2 RS sym, hypreal_minus_mult_eq1 RS sym]; |
|
529 |
||
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
530 |
Goal "(- (1::hypreal)) * z = -z"; |
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
531 |
by (Simp_tac 1); |
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
532 |
qed "hypreal_mult_minus_1"; |
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
533 |
Addsimps [hypreal_mult_minus_1]; |
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
534 |
|
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
535 |
Goal "z * (- (1::hypreal)) = -z"; |
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
536 |
by (stac hypreal_mult_commute 1); |
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
537 |
by (Simp_tac 1); |
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
538 |
qed "hypreal_mult_minus_1_right"; |
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
539 |
Addsimps [hypreal_mult_minus_1_right]; |
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
540 |
|
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
541 |
Goal "(-x) * y = (x::hypreal) * -y"; |
10751 | 542 |
by Auto_tac; |
543 |
qed "hypreal_minus_mult_commute"; |
|
544 |
||
545 |
(*----------------------------------------------------------------------------- |
|
546 |
A few more theorems |
|
547 |
----------------------------------------------------------------------------*) |
|
548 |
Goal "(z::hypreal) + v = z' + v' ==> z + (v + w) = z' + (v' + w)"; |
|
549 |
by (asm_simp_tac (simpset() addsimps [hypreal_add_assoc RS sym]) 1); |
|
550 |
qed "hypreal_add_assoc_cong"; |
|
551 |
||
552 |
Goal "(z::hypreal) + (v + w) = v + (z + w)"; |
|
553 |
by (REPEAT (ares_tac [hypreal_add_commute RS hypreal_add_assoc_cong] 1)); |
|
554 |
qed "hypreal_add_assoc_swap"; |
|
555 |
||
556 |
Goal "((z1::hypreal) + z2) * w = (z1 * w) + (z2 * w)"; |
|
557 |
by (res_inst_tac [("z","z1")] eq_Abs_hypreal 1); |
|
558 |
by (res_inst_tac [("z","z2")] eq_Abs_hypreal 1); |
|
559 |
by (res_inst_tac [("z","w")] eq_Abs_hypreal 1); |
|
560 |
by (asm_simp_tac (simpset() addsimps [hypreal_mult,hypreal_add, |
|
561 |
real_add_mult_distrib]) 1); |
|
562 |
qed "hypreal_add_mult_distrib"; |
|
563 |
||
564 |
val hypreal_mult_commute'= read_instantiate [("z","w")] hypreal_mult_commute; |
|
565 |
||
566 |
Goal "(w::hypreal) * (z1 + z2) = (w * z1) + (w * z2)"; |
|
567 |
by (simp_tac (simpset() addsimps [hypreal_mult_commute',hypreal_add_mult_distrib]) 1); |
|
568 |
qed "hypreal_add_mult_distrib2"; |
|
569 |
||
570 |
||
571 |
Goalw [hypreal_diff_def] "((z1::hypreal) - z2) * w = (z1 * w) - (z2 * w)"; |
|
572 |
by (simp_tac (simpset() addsimps [hypreal_add_mult_distrib]) 1); |
|
573 |
qed "hypreal_diff_mult_distrib"; |
|
574 |
||
575 |
Goal "(w::hypreal) * (z1 - z2) = (w * z1) - (w * z2)"; |
|
576 |
by (simp_tac (simpset() addsimps [hypreal_mult_commute', |
|
577 |
hypreal_diff_mult_distrib]) 1); |
|
578 |
qed "hypreal_diff_mult_distrib2"; |
|
579 |
||
580 |
(*** one and zero are distinct ***) |
|
11713
883d559b0b8c
sane numerals (stage 3): provide generic "1" on all number types;
wenzelm
parents:
11701
diff
changeset
|
581 |
Goalw [hypreal_zero_def,hypreal_one_def] "0 ~= (1::hypreal)"; |
10751 | 582 |
by (auto_tac (claset(), simpset() addsimps [real_zero_not_eq_one])); |
583 |
qed "hypreal_zero_not_eq_one"; |
|
584 |
||
585 |
||
586 |
(**** multiplicative inverse on hypreal ****) |
|
587 |
||
588 |
Goalw [congruent_def] |
|
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
589 |
"congruent hyprel (%X. hyprel``{%n. if X n = 0 then 0 else inverse(X n)})"; |
10751 | 590 |
by (Auto_tac THEN Ultra_tac 1); |
591 |
qed "hypreal_inverse_congruent"; |
|
592 |
||
593 |
Goalw [hypreal_inverse_def] |
|
10834 | 594 |
"inverse (Abs_hypreal(hyprel``{%n. X n})) = \ |
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
595 |
\ Abs_hypreal(hyprel `` {%n. if X n = 0 then 0 else inverse(X n)})"; |
10751 | 596 |
by (res_inst_tac [("f","Abs_hypreal")] arg_cong 1); |
597 |
by (simp_tac (simpset() addsimps |
|
598 |
[hyprel_in_hypreal RS Abs_hypreal_inverse, |
|
599 |
[equiv_hyprel, hypreal_inverse_congruent] MRS UN_equiv_class]) 1); |
|
600 |
qed "hypreal_inverse"; |
|
601 |
||
602 |
Goal "inverse 0 = (0::hypreal)"; |
|
603 |
by (simp_tac (simpset() addsimps [hypreal_inverse, hypreal_zero_def]) 1); |
|
604 |
qed "HYPREAL_INVERSE_ZERO"; |
|
605 |
||
606 |
Goal "a / (0::hypreal) = 0"; |
|
607 |
by (simp_tac |
|
608 |
(simpset() addsimps [hypreal_divide_def, HYPREAL_INVERSE_ZERO]) 1); |
|
609 |
qed "HYPREAL_DIVISION_BY_ZERO"; (*NOT for adding to default simpset*) |
|
610 |
||
611 |
fun hypreal_div_undefined_case_tac s i = |
|
612 |
case_tac s i THEN |
|
613 |
asm_simp_tac |
|
614 |
(simpset() addsimps [HYPREAL_DIVISION_BY_ZERO, HYPREAL_INVERSE_ZERO]) i; |
|
615 |
||
616 |
Goal "inverse (inverse (z::hypreal)) = z"; |
|
617 |
by (hypreal_div_undefined_case_tac "z=0" 1); |
|
618 |
by (res_inst_tac [("z","z")] eq_Abs_hypreal 1); |
|
619 |
by (asm_full_simp_tac (simpset() addsimps |
|
620 |
[hypreal_inverse, hypreal_zero_def]) 1); |
|
621 |
qed "hypreal_inverse_inverse"; |
|
622 |
Addsimps [hypreal_inverse_inverse]; |
|
623 |
||
11713
883d559b0b8c
sane numerals (stage 3): provide generic "1" on all number types;
wenzelm
parents:
11701
diff
changeset
|
624 |
Goalw [hypreal_one_def] "inverse((1::hypreal)) = (1::hypreal)"; |
10751 | 625 |
by (full_simp_tac (simpset() addsimps [hypreal_inverse, |
626 |
real_zero_not_eq_one RS not_sym]) 1); |
|
627 |
qed "hypreal_inverse_1"; |
|
628 |
Addsimps [hypreal_inverse_1]; |
|
629 |
||
630 |
||
631 |
(*** existence of inverse ***) |
|
632 |
||
633 |
Goalw [hypreal_one_def,hypreal_zero_def] |
|
11713
883d559b0b8c
sane numerals (stage 3): provide generic "1" on all number types;
wenzelm
parents:
11701
diff
changeset
|
634 |
"x ~= 0 ==> x*inverse(x) = (1::hypreal)"; |
10751 | 635 |
by (res_inst_tac [("z","x")] eq_Abs_hypreal 1); |
636 |
by (rotate_tac 1 1); |
|
637 |
by (asm_full_simp_tac (simpset() addsimps [hypreal_inverse, hypreal_mult]) 1); |
|
638 |
by (dtac FreeUltrafilterNat_Compl_mem 1); |
|
639 |
by (blast_tac (claset() addSIs [real_mult_inv_right, |
|
640 |
FreeUltrafilterNat_subset]) 1); |
|
641 |
qed "hypreal_mult_inverse"; |
|
642 |
||
11713
883d559b0b8c
sane numerals (stage 3): provide generic "1" on all number types;
wenzelm
parents:
11701
diff
changeset
|
643 |
Goal "x ~= 0 ==> inverse(x)*x = (1::hypreal)"; |
10751 | 644 |
by (asm_simp_tac (simpset() addsimps [hypreal_mult_inverse, |
645 |
hypreal_mult_commute]) 1); |
|
646 |
qed "hypreal_mult_inverse_left"; |
|
647 |
||
648 |
Goal "(c::hypreal) ~= 0 ==> (c*a=c*b) = (a=b)"; |
|
649 |
by Auto_tac; |
|
650 |
by (dres_inst_tac [("f","%x. x*inverse c")] arg_cong 1); |
|
651 |
by (asm_full_simp_tac (simpset() addsimps [hypreal_mult_inverse] @ hypreal_mult_ac) 1); |
|
652 |
qed "hypreal_mult_left_cancel"; |
|
653 |
||
654 |
Goal "(c::hypreal) ~= 0 ==> (a*c=b*c) = (a=b)"; |
|
655 |
by (Step_tac 1); |
|
656 |
by (dres_inst_tac [("f","%x. x*inverse c")] arg_cong 1); |
|
657 |
by (asm_full_simp_tac (simpset() addsimps [hypreal_mult_inverse] @ hypreal_mult_ac) 1); |
|
658 |
qed "hypreal_mult_right_cancel"; |
|
659 |
||
660 |
Goalw [hypreal_zero_def] "x ~= 0 ==> inverse (x::hypreal) ~= 0"; |
|
661 |
by (res_inst_tac [("z","x")] eq_Abs_hypreal 1); |
|
662 |
by (asm_full_simp_tac (simpset() addsimps [hypreal_inverse, hypreal_mult]) 1); |
|
663 |
qed "hypreal_inverse_not_zero"; |
|
664 |
||
665 |
Addsimps [hypreal_mult_inverse,hypreal_mult_inverse_left]; |
|
666 |
||
667 |
Goal "[| x ~= 0; y ~= 0 |] ==> x * y ~= (0::hypreal)"; |
|
668 |
by (Step_tac 1); |
|
669 |
by (dres_inst_tac [("f","%z. inverse x*z")] arg_cong 1); |
|
670 |
by (asm_full_simp_tac (simpset() addsimps [hypreal_mult_assoc RS sym]) 1); |
|
671 |
qed "hypreal_mult_not_0"; |
|
672 |
||
673 |
Goal "x*y = (0::hypreal) ==> x = 0 | y = 0"; |
|
674 |
by (auto_tac (claset() addIs [ccontr] addDs [hypreal_mult_not_0], |
|
675 |
simpset())); |
|
676 |
qed "hypreal_mult_zero_disj"; |
|
677 |
||
678 |
Goal "inverse(-x) = -inverse(x::hypreal)"; |
|
679 |
by (hypreal_div_undefined_case_tac "x=0" 1); |
|
680 |
by (rtac (hypreal_mult_right_cancel RS iffD1) 1); |
|
681 |
by (stac hypreal_mult_inverse_left 2); |
|
682 |
by Auto_tac; |
|
683 |
qed "hypreal_minus_inverse"; |
|
684 |
||
685 |
Goal "inverse(x*y) = inverse(x)*inverse(y::hypreal)"; |
|
686 |
by (hypreal_div_undefined_case_tac "x=0" 1); |
|
687 |
by (hypreal_div_undefined_case_tac "y=0" 1); |
|
688 |
by (forw_inst_tac [("y","y")] hypreal_mult_not_0 1 THEN assume_tac 1); |
|
689 |
by (res_inst_tac [("c1","x")] (hypreal_mult_left_cancel RS iffD1) 1); |
|
690 |
by (auto_tac (claset(), simpset() addsimps [hypreal_mult_assoc RS sym])); |
|
691 |
by (res_inst_tac [("c1","y")] (hypreal_mult_left_cancel RS iffD1) 1); |
|
692 |
by (auto_tac (claset(), simpset() addsimps [hypreal_mult_left_commute])); |
|
693 |
by (asm_simp_tac (simpset() addsimps [hypreal_mult_assoc RS sym]) 1); |
|
694 |
qed "hypreal_inverse_distrib"; |
|
695 |
||
696 |
(*------------------------------------------------------------------ |
|
697 |
Theorems for ordering |
|
698 |
------------------------------------------------------------------*) |
|
699 |
||
700 |
(* prove introduction and elimination rules for hypreal_less *) |
|
701 |
||
702 |
Goalw [hypreal_less_def] |
|
11655 | 703 |
"(P < (Q::hypreal)) = (EX X Y. X : Rep_hypreal(P) & \ |
10751 | 704 |
\ Y : Rep_hypreal(Q) & \ |
705 |
\ {n. X n < Y n} : FreeUltrafilterNat)"; |
|
706 |
by (Fast_tac 1); |
|
707 |
qed "hypreal_less_iff"; |
|
708 |
||
709 |
Goalw [hypreal_less_def] |
|
710 |
"[| {n. X n < Y n} : FreeUltrafilterNat; \ |
|
711 |
\ X : Rep_hypreal(P); \ |
|
712 |
\ Y : Rep_hypreal(Q) |] ==> P < (Q::hypreal)"; |
|
713 |
by (Fast_tac 1); |
|
714 |
qed "hypreal_lessI"; |
|
715 |
||
716 |
||
717 |
Goalw [hypreal_less_def] |
|
718 |
"!! R1. [| R1 < (R2::hypreal); \ |
|
719 |
\ !!X Y. {n. X n < Y n} : FreeUltrafilterNat ==> P; \ |
|
720 |
\ !!X. X : Rep_hypreal(R1) ==> P; \ |
|
721 |
\ !!Y. Y : Rep_hypreal(R2) ==> P |] \ |
|
722 |
\ ==> P"; |
|
723 |
by Auto_tac; |
|
724 |
qed "hypreal_lessE"; |
|
725 |
||
726 |
Goalw [hypreal_less_def] |
|
727 |
"R1 < (R2::hypreal) ==> (EX X Y. {n. X n < Y n} : FreeUltrafilterNat & \ |
|
728 |
\ X : Rep_hypreal(R1) & \ |
|
729 |
\ Y : Rep_hypreal(R2))"; |
|
730 |
by (Fast_tac 1); |
|
731 |
qed "hypreal_lessD"; |
|
732 |
||
733 |
Goal "~ (R::hypreal) < R"; |
|
734 |
by (res_inst_tac [("z","R")] eq_Abs_hypreal 1); |
|
735 |
by (auto_tac (claset(), simpset() addsimps [hypreal_less_def])); |
|
736 |
by (Ultra_tac 1); |
|
737 |
qed "hypreal_less_not_refl"; |
|
738 |
||
739 |
(*** y < y ==> P ***) |
|
740 |
bind_thm("hypreal_less_irrefl",hypreal_less_not_refl RS notE); |
|
741 |
AddSEs [hypreal_less_irrefl]; |
|
742 |
||
743 |
Goal "!!(x::hypreal). x < y ==> x ~= y"; |
|
744 |
by (auto_tac (claset(), simpset() addsimps [hypreal_less_not_refl])); |
|
745 |
qed "hypreal_not_refl2"; |
|
746 |
||
747 |
Goal "!!(R1::hypreal). [| R1 < R2; R2 < R3 |] ==> R1 < R3"; |
|
748 |
by (res_inst_tac [("z","R1")] eq_Abs_hypreal 1); |
|
749 |
by (res_inst_tac [("z","R2")] eq_Abs_hypreal 1); |
|
750 |
by (res_inst_tac [("z","R3")] eq_Abs_hypreal 1); |
|
751 |
by (auto_tac (claset() addSIs [exI], simpset() addsimps [hypreal_less_def])); |
|
752 |
by (ultra_tac (claset() addIs [order_less_trans], simpset()) 1); |
|
753 |
qed "hypreal_less_trans"; |
|
754 |
||
755 |
Goal "!! (R1::hypreal). [| R1 < R2; R2 < R1 |] ==> P"; |
|
756 |
by (dtac hypreal_less_trans 1 THEN assume_tac 1); |
|
757 |
by (asm_full_simp_tac (simpset() addsimps |
|
758 |
[hypreal_less_not_refl]) 1); |
|
759 |
qed "hypreal_less_asym"; |
|
760 |
||
761 |
(*------------------------------------------------------- |
|
762 |
TODO: The following theorem should have been proved |
|
763 |
first and then used througout the proofs as it probably |
|
764 |
makes many of them more straightforward. |
|
765 |
-------------------------------------------------------*) |
|
766 |
Goalw [hypreal_less_def] |
|
10834 | 767 |
"(Abs_hypreal(hyprel``{%n. X n}) < \ |
768 |
\ Abs_hypreal(hyprel``{%n. Y n})) = \ |
|
10751 | 769 |
\ ({n. X n < Y n} : FreeUltrafilterNat)"; |
770 |
by (auto_tac (claset() addSIs [lemma_hyprel_refl], simpset())); |
|
771 |
by (Ultra_tac 1); |
|
772 |
qed "hypreal_less"; |
|
773 |
||
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
774 |
(*---------------------------------------------------------------------------- |
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
775 |
Trichotomy: the hyperreals are linearly ordered |
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
776 |
---------------------------------------------------------------------------*) |
10751 | 777 |
|
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
778 |
Goalw [hyprel_def] "EX x. x: hyprel `` {%n. 0}"; |
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
779 |
by (res_inst_tac [("x","%n. 0")] exI 1); |
10751 | 780 |
by (Step_tac 1); |
781 |
by (auto_tac (claset() addSIs [FreeUltrafilterNat_Nat_set], simpset())); |
|
11713
883d559b0b8c
sane numerals (stage 3): provide generic "1" on all number types;
wenzelm
parents:
11701
diff
changeset
|
782 |
qed "lemma_hyprel_0_mem"; |
10751 | 783 |
|
784 |
Goalw [hypreal_zero_def]"0 < x | x = 0 | x < (0::hypreal)"; |
|
785 |
by (res_inst_tac [("z","x")] eq_Abs_hypreal 1); |
|
786 |
by (auto_tac (claset(),simpset() addsimps [hypreal_less_def])); |
|
11713
883d559b0b8c
sane numerals (stage 3): provide generic "1" on all number types;
wenzelm
parents:
11701
diff
changeset
|
787 |
by (cut_facts_tac [lemma_hyprel_0_mem] 1 THEN etac exE 1); |
10751 | 788 |
by (dres_inst_tac [("x","xa")] spec 1); |
789 |
by (dres_inst_tac [("x","x")] spec 1); |
|
790 |
by (cut_inst_tac [("x","x")] lemma_hyprel_refl 1); |
|
791 |
by Auto_tac; |
|
792 |
by (dres_inst_tac [("x","x")] spec 1); |
|
793 |
by (dres_inst_tac [("x","xa")] spec 1); |
|
794 |
by Auto_tac; |
|
795 |
by (Ultra_tac 1); |
|
796 |
by (auto_tac (claset() addIs [real_linear_less2],simpset())); |
|
797 |
qed "hypreal_trichotomy"; |
|
798 |
||
799 |
val prems = Goal "[| (0::hypreal) < x ==> P; \ |
|
800 |
\ x = 0 ==> P; \ |
|
801 |
\ x < 0 ==> P |] ==> P"; |
|
802 |
by (cut_inst_tac [("x","x")] hypreal_trichotomy 1); |
|
803 |
by (REPEAT (eresolve_tac (disjE::prems) 1)); |
|
804 |
qed "hypreal_trichotomyE"; |
|
805 |
||
806 |
(*---------------------------------------------------------------------------- |
|
807 |
More properties of < |
|
808 |
----------------------------------------------------------------------------*) |
|
809 |
||
810 |
Goal "((x::hypreal) < y) = (0 < y + -x)"; |
|
811 |
by (res_inst_tac [("z","x")] eq_Abs_hypreal 1); |
|
812 |
by (res_inst_tac [("z","y")] eq_Abs_hypreal 1); |
|
813 |
by (auto_tac (claset(),simpset() addsimps [hypreal_add, |
|
814 |
hypreal_zero_def,hypreal_minus,hypreal_less])); |
|
815 |
by (ALLGOALS(Ultra_tac)); |
|
816 |
qed "hypreal_less_minus_iff"; |
|
817 |
||
818 |
Goal "((x::hypreal) < y) = (x + -y < 0)"; |
|
819 |
by (res_inst_tac [("z","x")] eq_Abs_hypreal 1); |
|
820 |
by (res_inst_tac [("z","y")] eq_Abs_hypreal 1); |
|
821 |
by (auto_tac (claset(),simpset() addsimps [hypreal_add, |
|
822 |
hypreal_zero_def,hypreal_minus,hypreal_less])); |
|
823 |
by (ALLGOALS(Ultra_tac)); |
|
824 |
qed "hypreal_less_minus_iff2"; |
|
825 |
||
826 |
Goal "((x::hypreal) = y) = (x + - y = 0)"; |
|
827 |
by Auto_tac; |
|
828 |
by (res_inst_tac [("x1","-y")] (hypreal_add_right_cancel RS iffD1) 1); |
|
829 |
by Auto_tac; |
|
830 |
qed "hypreal_eq_minus_iff"; |
|
831 |
||
832 |
Goal "((x::hypreal) = y) = (0 = y + - x)"; |
|
833 |
by Auto_tac; |
|
834 |
by (res_inst_tac [("x1","-x")] (hypreal_add_right_cancel RS iffD1) 1); |
|
835 |
by Auto_tac; |
|
836 |
qed "hypreal_eq_minus_iff2"; |
|
837 |
||
838 |
(* 07/00 *) |
|
839 |
Goal "(0::hypreal) - x = -x"; |
|
840 |
by (simp_tac (simpset() addsimps [hypreal_diff_def]) 1); |
|
841 |
qed "hypreal_diff_zero"; |
|
842 |
||
843 |
Goal "x - (0::hypreal) = x"; |
|
844 |
by (simp_tac (simpset() addsimps [hypreal_diff_def]) 1); |
|
845 |
qed "hypreal_diff_zero_right"; |
|
846 |
||
847 |
Goal "x - x = (0::hypreal)"; |
|
848 |
by (simp_tac (simpset() addsimps [hypreal_diff_def]) 1); |
|
849 |
qed "hypreal_diff_self"; |
|
850 |
||
851 |
Addsimps [hypreal_diff_zero, hypreal_diff_zero_right, hypreal_diff_self]; |
|
852 |
||
853 |
Goal "(x = y + z) = (x + -z = (y::hypreal))"; |
|
854 |
by (auto_tac (claset(),simpset() addsimps [hypreal_add_assoc])); |
|
855 |
qed "hypreal_eq_minus_iff3"; |
|
856 |
||
857 |
Goal "(x ~= a) = (x + -a ~= (0::hypreal))"; |
|
858 |
by (auto_tac (claset() addDs [hypreal_eq_minus_iff RS iffD2], |
|
859 |
simpset())); |
|
860 |
qed "hypreal_not_eq_minus_iff"; |
|
861 |
||
862 |
||
863 |
(*** linearity ***) |
|
864 |
||
865 |
Goal "(x::hypreal) < y | x = y | y < x"; |
|
866 |
by (stac hypreal_eq_minus_iff2 1); |
|
867 |
by (res_inst_tac [("x1","x")] (hypreal_less_minus_iff RS ssubst) 1); |
|
868 |
by (res_inst_tac [("x1","y")] (hypreal_less_minus_iff2 RS ssubst) 1); |
|
869 |
by (rtac hypreal_trichotomyE 1); |
|
870 |
by Auto_tac; |
|
871 |
qed "hypreal_linear"; |
|
872 |
||
873 |
Goal "((w::hypreal) ~= z) = (w<z | z<w)"; |
|
874 |
by (cut_facts_tac [hypreal_linear] 1); |
|
875 |
by (Blast_tac 1); |
|
876 |
qed "hypreal_neq_iff"; |
|
877 |
||
878 |
Goal "!!(x::hypreal). [| x < y ==> P; x = y ==> P; \ |
|
879 |
\ y < x ==> P |] ==> P"; |
|
880 |
by (cut_inst_tac [("x","x"),("y","y")] hypreal_linear 1); |
|
881 |
by Auto_tac; |
|
882 |
qed "hypreal_linear_less2"; |
|
883 |
||
884 |
(*------------------------------------------------------------------------------ |
|
885 |
Properties of <= |
|
886 |
------------------------------------------------------------------------------*) |
|
887 |
(*------ hypreal le iff reals le a.e ------*) |
|
888 |
||
889 |
Goalw [hypreal_le_def,real_le_def] |
|
10834 | 890 |
"(Abs_hypreal(hyprel``{%n. X n}) <= \ |
891 |
\ Abs_hypreal(hyprel``{%n. Y n})) = \ |
|
10751 | 892 |
\ ({n. X n <= Y n} : FreeUltrafilterNat)"; |
893 |
by (auto_tac (claset(),simpset() addsimps [hypreal_less])); |
|
894 |
by (ALLGOALS(Ultra_tac)); |
|
895 |
qed "hypreal_le"; |
|
896 |
||
897 |
(*---------------------------------------------------------*) |
|
898 |
(*---------------------------------------------------------*) |
|
899 |
Goalw [hypreal_le_def] |
|
900 |
"~(w < z) ==> z <= (w::hypreal)"; |
|
901 |
by (assume_tac 1); |
|
902 |
qed "hypreal_leI"; |
|
903 |
||
904 |
Goalw [hypreal_le_def] |
|
905 |
"z<=w ==> ~(w<(z::hypreal))"; |
|
906 |
by (assume_tac 1); |
|
907 |
qed "hypreal_leD"; |
|
908 |
||
909 |
bind_thm ("hypreal_leE", make_elim hypreal_leD); |
|
910 |
||
911 |
Goal "(~(w < z)) = (z <= (w::hypreal))"; |
|
912 |
by (fast_tac (claset() addSIs [hypreal_leI,hypreal_leD]) 1); |
|
913 |
qed "hypreal_less_le_iff"; |
|
914 |
||
915 |
Goalw [hypreal_le_def] "~ z <= w ==> w<(z::hypreal)"; |
|
916 |
by (Fast_tac 1); |
|
917 |
qed "not_hypreal_leE"; |
|
918 |
||
919 |
Goalw [hypreal_le_def] "!!(x::hypreal). x <= y ==> x < y | x = y"; |
|
920 |
by (cut_facts_tac [hypreal_linear] 1); |
|
921 |
by (fast_tac (claset() addEs [hypreal_less_irrefl,hypreal_less_asym]) 1); |
|
922 |
qed "hypreal_le_imp_less_or_eq"; |
|
923 |
||
924 |
Goalw [hypreal_le_def] "z<w | z=w ==> z <=(w::hypreal)"; |
|
925 |
by (cut_facts_tac [hypreal_linear] 1); |
|
926 |
by (fast_tac (claset() addEs [hypreal_less_irrefl,hypreal_less_asym]) 1); |
|
927 |
qed "hypreal_less_or_eq_imp_le"; |
|
928 |
||
929 |
Goal "(x <= (y::hypreal)) = (x < y | x=y)"; |
|
930 |
by (REPEAT(ares_tac [iffI, hypreal_less_or_eq_imp_le, hypreal_le_imp_less_or_eq] 1)); |
|
931 |
qed "hypreal_le_eq_less_or_eq"; |
|
932 |
val hypreal_le_less = hypreal_le_eq_less_or_eq; |
|
933 |
||
934 |
Goal "w <= (w::hypreal)"; |
|
935 |
by (simp_tac (simpset() addsimps [hypreal_le_eq_less_or_eq]) 1); |
|
936 |
qed "hypreal_le_refl"; |
|
937 |
||
938 |
(* Axiom 'linorder_linear' of class 'linorder': *) |
|
939 |
Goal "(z::hypreal) <= w | w <= z"; |
|
940 |
by (simp_tac (simpset() addsimps [hypreal_le_less]) 1); |
|
941 |
by (cut_facts_tac [hypreal_linear] 1); |
|
942 |
by (Blast_tac 1); |
|
943 |
qed "hypreal_le_linear"; |
|
944 |
||
945 |
Goal "[| i <= j; j <= k |] ==> i <= (k::hypreal)"; |
|
946 |
by (EVERY1 [dtac hypreal_le_imp_less_or_eq, dtac hypreal_le_imp_less_or_eq, |
|
947 |
rtac hypreal_less_or_eq_imp_le, |
|
948 |
fast_tac (claset() addIs [hypreal_less_trans])]); |
|
949 |
qed "hypreal_le_trans"; |
|
950 |
||
951 |
Goal "[| z <= w; w <= z |] ==> z = (w::hypreal)"; |
|
952 |
by (EVERY1 [dtac hypreal_le_imp_less_or_eq, dtac hypreal_le_imp_less_or_eq, |
|
953 |
fast_tac (claset() addEs [hypreal_less_irrefl,hypreal_less_asym])]); |
|
954 |
qed "hypreal_le_anti_sym"; |
|
955 |
||
956 |
Goal "[| ~ y < x; y ~= x |] ==> x < (y::hypreal)"; |
|
957 |
by (rtac not_hypreal_leE 1); |
|
958 |
by (fast_tac (claset() addDs [hypreal_le_imp_less_or_eq]) 1); |
|
959 |
qed "not_less_not_eq_hypreal_less"; |
|
960 |
||
961 |
(* Axiom 'order_less_le' of class 'order': *) |
|
11655 | 962 |
Goal "((w::hypreal) < z) = (w <= z & w ~= z)"; |
10751 | 963 |
by (simp_tac (simpset() addsimps [hypreal_le_def, hypreal_neq_iff]) 1); |
964 |
by (blast_tac (claset() addIs [hypreal_less_asym]) 1); |
|
965 |
qed "hypreal_less_le"; |
|
966 |
||
967 |
Goal "(0 < -R) = (R < (0::hypreal))"; |
|
968 |
by (res_inst_tac [("z","R")] eq_Abs_hypreal 1); |
|
969 |
by (auto_tac (claset(), |
|
970 |
simpset() addsimps [hypreal_zero_def, hypreal_less,hypreal_minus])); |
|
971 |
qed "hypreal_minus_zero_less_iff"; |
|
972 |
Addsimps [hypreal_minus_zero_less_iff]; |
|
973 |
||
974 |
Goal "(-R < 0) = ((0::hypreal) < R)"; |
|
975 |
by (res_inst_tac [("z","R")] eq_Abs_hypreal 1); |
|
976 |
by (auto_tac (claset(), |
|
977 |
simpset() addsimps [hypreal_zero_def, hypreal_less,hypreal_minus])); |
|
978 |
by (ALLGOALS(Ultra_tac)); |
|
979 |
qed "hypreal_minus_zero_less_iff2"; |
|
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
980 |
Addsimps [hypreal_minus_zero_less_iff2]; |
10751 | 981 |
|
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
982 |
Goalw [hypreal_le_def] "((0::hypreal) <= -r) = (r <= 0)"; |
10751 | 983 |
by (simp_tac (simpset() addsimps [hypreal_minus_zero_less_iff2]) 1); |
984 |
qed "hypreal_minus_zero_le_iff"; |
|
985 |
Addsimps [hypreal_minus_zero_le_iff]; |
|
986 |
||
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
987 |
Goalw [hypreal_le_def] "(-r <= (0::hypreal)) = (0 <= r)"; |
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
988 |
by (simp_tac (simpset() addsimps [hypreal_minus_zero_less_iff2]) 1); |
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
989 |
qed "hypreal_minus_zero_le_iff2"; |
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
990 |
Addsimps [hypreal_minus_zero_le_iff2]; |
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
991 |
|
10751 | 992 |
(*---------------------------------------------------------- |
993 |
hypreal_of_real preserves field and order properties |
|
994 |
-----------------------------------------------------------*) |
|
995 |
Goalw [hypreal_of_real_def] |
|
996 |
"hypreal_of_real (z1 + z2) = hypreal_of_real z1 + hypreal_of_real z2"; |
|
997 |
by (simp_tac (simpset() addsimps [hypreal_add, hypreal_add_mult_distrib]) 1); |
|
998 |
qed "hypreal_of_real_add"; |
|
999 |
Addsimps [hypreal_of_real_add]; |
|
1000 |
||
1001 |
Goalw [hypreal_of_real_def] |
|
1002 |
"hypreal_of_real (z1 * z2) = hypreal_of_real z1 * hypreal_of_real z2"; |
|
1003 |
by (simp_tac (simpset() addsimps [hypreal_mult, hypreal_add_mult_distrib2]) 1); |
|
1004 |
qed "hypreal_of_real_mult"; |
|
1005 |
Addsimps [hypreal_of_real_mult]; |
|
1006 |
||
1007 |
Goalw [hypreal_less_def,hypreal_of_real_def] |
|
1008 |
"(hypreal_of_real z1 < hypreal_of_real z2) = (z1 < z2)"; |
|
1009 |
by Auto_tac; |
|
1010 |
by (res_inst_tac [("x","%n. z1")] exI 2); |
|
1011 |
by (Step_tac 1); |
|
1012 |
by (res_inst_tac [("x","%n. z2")] exI 3); |
|
1013 |
by Auto_tac; |
|
1014 |
by (rtac FreeUltrafilterNat_P 1); |
|
1015 |
by (Ultra_tac 1); |
|
1016 |
qed "hypreal_of_real_less_iff"; |
|
1017 |
Addsimps [hypreal_of_real_less_iff]; |
|
1018 |
||
1019 |
Goalw [hypreal_le_def,real_le_def] |
|
1020 |
"(hypreal_of_real z1 <= hypreal_of_real z2) = (z1 <= z2)"; |
|
1021 |
by Auto_tac; |
|
1022 |
qed "hypreal_of_real_le_iff"; |
|
1023 |
Addsimps [hypreal_of_real_le_iff]; |
|
1024 |
||
1025 |
Goal "(hypreal_of_real z1 = hypreal_of_real z2) = (z1 = z2)"; |
|
1026 |
by (force_tac (claset() addIs [order_antisym, hypreal_of_real_le_iff RS iffD1], |
|
1027 |
simpset()) 1); |
|
1028 |
qed "hypreal_of_real_eq_iff"; |
|
1029 |
Addsimps [hypreal_of_real_eq_iff]; |
|
1030 |
||
1031 |
Goalw [hypreal_of_real_def] "hypreal_of_real (-r) = - hypreal_of_real r"; |
|
1032 |
by (auto_tac (claset(),simpset() addsimps [hypreal_minus])); |
|
1033 |
qed "hypreal_of_real_minus"; |
|
1034 |
Addsimps [hypreal_of_real_minus]; |
|
1035 |
||
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
1036 |
Goalw [hypreal_of_real_def,hypreal_one_def] "hypreal_of_real 1 = (1::hypreal)"; |
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
1037 |
by (Simp_tac 1); |
10751 | 1038 |
qed "hypreal_of_real_one"; |
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
1039 |
Addsimps [hypreal_of_real_one]; |
10751 | 1040 |
|
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
1041 |
Goalw [hypreal_of_real_def,hypreal_zero_def] "hypreal_of_real 0 = 0"; |
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
1042 |
by (Simp_tac 1); |
10751 | 1043 |
qed "hypreal_of_real_zero"; |
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
1044 |
Addsimps [hypreal_of_real_zero]; |
10751 | 1045 |
|
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
1046 |
Goal "(hypreal_of_real r = 0) = (r = 0)"; |
10751 | 1047 |
by (auto_tac (claset() addIs [FreeUltrafilterNat_P], |
1048 |
simpset() addsimps [hypreal_of_real_def, |
|
1049 |
hypreal_zero_def,FreeUltrafilterNat_Nat_set])); |
|
1050 |
qed "hypreal_of_real_zero_iff"; |
|
1051 |
||
1052 |
Goal "hypreal_of_real (inverse r) = inverse (hypreal_of_real r)"; |
|
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
1053 |
by (case_tac "r=0" 1); |
10751 | 1054 |
by (asm_simp_tac (simpset() addsimps [REAL_DIVIDE_ZERO, INVERSE_ZERO, |
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
1055 |
HYPREAL_INVERSE_ZERO]) 1); |
10751 | 1056 |
by (res_inst_tac [("c1","hypreal_of_real r")] |
1057 |
(hypreal_mult_left_cancel RS iffD1) 1); |
|
1058 |
by (stac (hypreal_of_real_mult RS sym) 2); |
|
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
1059 |
by (auto_tac (claset(), simpset() addsimps [hypreal_of_real_zero_iff])); |
10751 | 1060 |
qed "hypreal_of_real_inverse"; |
1061 |
Addsimps [hypreal_of_real_inverse]; |
|
1062 |
||
1063 |
Goal "hypreal_of_real (z1 / z2) = hypreal_of_real z1 / hypreal_of_real z2"; |
|
1064 |
by (simp_tac (simpset() addsimps [hypreal_divide_def, real_divide_def]) 1); |
|
1065 |
qed "hypreal_of_real_divide"; |
|
1066 |
Addsimps [hypreal_of_real_divide]; |
|
1067 |
||
1068 |
||
1069 |
(*** Division lemmas ***) |
|
1070 |
||
1071 |
Goal "(0::hypreal)/x = 0"; |
|
1072 |
by (simp_tac (simpset() addsimps [hypreal_divide_def]) 1); |
|
1073 |
qed "hypreal_zero_divide"; |
|
1074 |
||
11713
883d559b0b8c
sane numerals (stage 3): provide generic "1" on all number types;
wenzelm
parents:
11701
diff
changeset
|
1075 |
Goal "x/(1::hypreal) = x"; |
10751 | 1076 |
by (simp_tac (simpset() addsimps [hypreal_divide_def]) 1); |
1077 |
qed "hypreal_divide_one"; |
|
1078 |
Addsimps [hypreal_zero_divide, hypreal_divide_one]; |
|
1079 |
||
1080 |
Goal "(x::hypreal) * (y/z) = (x*y)/z"; |
|
1081 |
by (simp_tac (simpset() addsimps [hypreal_divide_def, hypreal_mult_assoc]) 1); |
|
1082 |
qed "hypreal_times_divide1_eq"; |
|
1083 |
||
1084 |
Goal "(y/z) * (x::hypreal) = (y*x)/z"; |
|
1085 |
by (simp_tac (simpset() addsimps [hypreal_divide_def]@hypreal_mult_ac) 1); |
|
1086 |
qed "hypreal_times_divide2_eq"; |
|
1087 |
||
1088 |
Addsimps [hypreal_times_divide1_eq, hypreal_times_divide2_eq]; |
|
1089 |
||
1090 |
Goal "(x::hypreal) / (y/z) = (x*z)/y"; |
|
1091 |
by (simp_tac (simpset() addsimps [hypreal_divide_def, hypreal_inverse_distrib]@ |
|
1092 |
hypreal_mult_ac) 1); |
|
1093 |
qed "hypreal_divide_divide1_eq"; |
|
1094 |
||
1095 |
Goal "((x::hypreal) / y) / z = x/(y*z)"; |
|
1096 |
by (simp_tac (simpset() addsimps [hypreal_divide_def, hypreal_inverse_distrib, |
|
1097 |
hypreal_mult_assoc]) 1); |
|
1098 |
qed "hypreal_divide_divide2_eq"; |
|
1099 |
||
1100 |
Addsimps [hypreal_divide_divide1_eq, hypreal_divide_divide2_eq]; |
|
1101 |
||
1102 |
(** As with multiplication, pull minus signs OUT of the / operator **) |
|
1103 |
||
1104 |
Goal "(-x) / (y::hypreal) = - (x/y)"; |
|
1105 |
by (simp_tac (simpset() addsimps [hypreal_divide_def]) 1); |
|
1106 |
qed "hypreal_minus_divide_eq"; |
|
1107 |
Addsimps [hypreal_minus_divide_eq]; |
|
1108 |
||
1109 |
Goal "(x / -(y::hypreal)) = - (x/y)"; |
|
1110 |
by (simp_tac (simpset() addsimps [hypreal_divide_def, hypreal_minus_inverse]) 1); |
|
1111 |
qed "hypreal_divide_minus_eq"; |
|
1112 |
Addsimps [hypreal_divide_minus_eq]; |
|
1113 |
||
1114 |
Goal "(x+y)/(z::hypreal) = x/z + y/z"; |
|
1115 |
by (simp_tac (simpset() addsimps [hypreal_divide_def, |
|
1116 |
hypreal_add_mult_distrib]) 1); |
|
1117 |
qed "hypreal_add_divide_distrib"; |
|
1118 |
||
1119 |
Goal "[|(x::hypreal) ~= 0; y ~= 0 |] \ |
|
1120 |
\ ==> inverse(x) + inverse(y) = (x + y)*inverse(x*y)"; |
|
1121 |
by (asm_full_simp_tac (simpset() addsimps [hypreal_inverse_distrib, |
|
1122 |
hypreal_add_mult_distrib,hypreal_mult_assoc RS sym]) 1); |
|
1123 |
by (stac hypreal_mult_assoc 1); |
|
1124 |
by (rtac (hypreal_mult_left_commute RS subst) 1); |
|
1125 |
by (asm_full_simp_tac (simpset() addsimps [hypreal_add_commute]) 1); |
|
1126 |
qed "hypreal_inverse_add"; |
|
1127 |
||
1128 |
Goal "x = -x ==> x = (0::hypreal)"; |
|
1129 |
by (res_inst_tac [("z","x")] eq_Abs_hypreal 1); |
|
1130 |
by (auto_tac (claset(), simpset() addsimps [hypreal_minus, hypreal_zero_def])); |
|
1131 |
by (Ultra_tac 1); |
|
1132 |
qed "hypreal_self_eq_minus_self_zero"; |
|
1133 |
||
1134 |
Goal "(x + x = 0) = (x = (0::hypreal))"; |
|
1135 |
by (res_inst_tac [("z","x")] eq_Abs_hypreal 1); |
|
1136 |
by (auto_tac (claset(), simpset() addsimps [hypreal_add, hypreal_zero_def])); |
|
1137 |
qed "hypreal_add_self_zero_cancel"; |
|
1138 |
Addsimps [hypreal_add_self_zero_cancel]; |
|
1139 |
||
1140 |
Goal "(x + x + y = y) = (x = (0::hypreal))"; |
|
1141 |
by Auto_tac; |
|
1142 |
by (dtac (hypreal_eq_minus_iff RS iffD1) 1); |
|
1143 |
by (auto_tac (claset(), |
|
1144 |
simpset() addsimps [hypreal_add_assoc, hypreal_self_eq_minus_self_zero])); |
|
1145 |
qed "hypreal_add_self_zero_cancel2"; |
|
1146 |
Addsimps [hypreal_add_self_zero_cancel2]; |
|
1147 |
||
1148 |
Goal "(x + (x + y) = y) = (x = (0::hypreal))"; |
|
1149 |
by (simp_tac (simpset() addsimps [hypreal_add_assoc RS sym]) 1); |
|
1150 |
qed "hypreal_add_self_zero_cancel2a"; |
|
1151 |
Addsimps [hypreal_add_self_zero_cancel2a]; |
|
1152 |
||
1153 |
Goal "(b = -a) = (-b = (a::hypreal))"; |
|
1154 |
by Auto_tac; |
|
1155 |
qed "hypreal_minus_eq_swap"; |
|
1156 |
||
1157 |
Goal "(-b = -a) = (b = (a::hypreal))"; |
|
1158 |
by (asm_full_simp_tac (simpset() addsimps |
|
1159 |
[hypreal_minus_eq_swap]) 1); |
|
1160 |
qed "hypreal_minus_eq_cancel"; |
|
1161 |
Addsimps [hypreal_minus_eq_cancel]; |
|
1162 |
||
1163 |
Goalw [hypreal_diff_def] "(x<y) = (x-y < (0::hypreal))"; |
|
1164 |
by (rtac hypreal_less_minus_iff2 1); |
|
1165 |
qed "hypreal_less_eq_diff"; |
|
1166 |
||
1167 |
(*** Subtraction laws ***) |
|
1168 |
||
1169 |
Goal "x + (y - z) = (x + y) - (z::hypreal)"; |
|
1170 |
by (simp_tac (simpset() addsimps hypreal_diff_def::hypreal_add_ac) 1); |
|
1171 |
qed "hypreal_add_diff_eq"; |
|
1172 |
||
1173 |
Goal "(x - y) + z = (x + z) - (y::hypreal)"; |
|
1174 |
by (simp_tac (simpset() addsimps hypreal_diff_def::hypreal_add_ac) 1); |
|
1175 |
qed "hypreal_diff_add_eq"; |
|
1176 |
||
1177 |
Goal "(x - y) - z = x - (y + (z::hypreal))"; |
|
1178 |
by (simp_tac (simpset() addsimps hypreal_diff_def::hypreal_add_ac) 1); |
|
1179 |
qed "hypreal_diff_diff_eq"; |
|
1180 |
||
1181 |
Goal "x - (y - z) = (x + z) - (y::hypreal)"; |
|
1182 |
by (simp_tac (simpset() addsimps hypreal_diff_def::hypreal_add_ac) 1); |
|
1183 |
qed "hypreal_diff_diff_eq2"; |
|
1184 |
||
1185 |
Goal "(x-y < z) = (x < z + (y::hypreal))"; |
|
1186 |
by (stac hypreal_less_eq_diff 1); |
|
1187 |
by (res_inst_tac [("y1", "z")] (hypreal_less_eq_diff RS ssubst) 1); |
|
1188 |
by (simp_tac (simpset() addsimps hypreal_diff_def::hypreal_add_ac) 1); |
|
1189 |
qed "hypreal_diff_less_eq"; |
|
1190 |
||
1191 |
Goal "(x < z-y) = (x + (y::hypreal) < z)"; |
|
1192 |
by (stac hypreal_less_eq_diff 1); |
|
1193 |
by (res_inst_tac [("y1", "z-y")] (hypreal_less_eq_diff RS ssubst) 1); |
|
1194 |
by (simp_tac (simpset() addsimps hypreal_diff_def::hypreal_add_ac) 1); |
|
1195 |
qed "hypreal_less_diff_eq"; |
|
1196 |
||
1197 |
Goalw [hypreal_le_def] "(x-y <= z) = (x <= z + (y::hypreal))"; |
|
1198 |
by (simp_tac (simpset() addsimps [hypreal_less_diff_eq]) 1); |
|
1199 |
qed "hypreal_diff_le_eq"; |
|
1200 |
||
1201 |
Goalw [hypreal_le_def] "(x <= z-y) = (x + (y::hypreal) <= z)"; |
|
1202 |
by (simp_tac (simpset() addsimps [hypreal_diff_less_eq]) 1); |
|
1203 |
qed "hypreal_le_diff_eq"; |
|
1204 |
||
1205 |
Goalw [hypreal_diff_def] "(x-y = z) = (x = z + (y::hypreal))"; |
|
1206 |
by (auto_tac (claset(), simpset() addsimps [hypreal_add_assoc])); |
|
1207 |
qed "hypreal_diff_eq_eq"; |
|
1208 |
||
1209 |
Goalw [hypreal_diff_def] "(x = z-y) = (x + (y::hypreal) = z)"; |
|
1210 |
by (auto_tac (claset(), simpset() addsimps [hypreal_add_assoc])); |
|
1211 |
qed "hypreal_eq_diff_eq"; |
|
1212 |
||
1213 |
(*This list of rewrites simplifies (in)equalities by bringing subtractions |
|
1214 |
to the top and then moving negative terms to the other side. |
|
1215 |
Use with hypreal_add_ac*) |
|
1216 |
val hypreal_compare_rls = |
|
1217 |
[symmetric hypreal_diff_def, |
|
1218 |
hypreal_add_diff_eq, hypreal_diff_add_eq, hypreal_diff_diff_eq, |
|
1219 |
hypreal_diff_diff_eq2, |
|
1220 |
hypreal_diff_less_eq, hypreal_less_diff_eq, hypreal_diff_le_eq, |
|
1221 |
hypreal_le_diff_eq, hypreal_diff_eq_eq, hypreal_eq_diff_eq]; |
|
1222 |
||
1223 |
||
1224 |
(** For the cancellation simproc. |
|
1225 |
The idea is to cancel like terms on opposite sides by subtraction **) |
|
1226 |
||
1227 |
Goal "(x::hypreal) - y = x' - y' ==> (x<y) = (x'<y')"; |
|
1228 |
by (stac hypreal_less_eq_diff 1); |
|
1229 |
by (res_inst_tac [("y1", "y")] (hypreal_less_eq_diff RS ssubst) 1); |
|
1230 |
by (Asm_simp_tac 1); |
|
1231 |
qed "hypreal_less_eqI"; |
|
1232 |
||
1233 |
Goal "(x::hypreal) - y = x' - y' ==> (y<=x) = (y'<=x')"; |
|
1234 |
by (dtac hypreal_less_eqI 1); |
|
1235 |
by (asm_simp_tac (simpset() addsimps [hypreal_le_def]) 1); |
|
1236 |
qed "hypreal_le_eqI"; |
|
1237 |
||
1238 |
Goal "(x::hypreal) - y = x' - y' ==> (x=y) = (x'=y')"; |
|
1239 |
by Safe_tac; |
|
1240 |
by (ALLGOALS |
|
1241 |
(asm_full_simp_tac |
|
1242 |
(simpset() addsimps [hypreal_eq_diff_eq, hypreal_diff_eq_eq]))); |
|
1243 |
qed "hypreal_eq_eqI"; |
|
1244 |