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