author | paulson |
Wed, 10 Jan 2001 17:21:31 +0100 | |
changeset 10857 | 47b1f34ddd09 |
parent 10784 | 27e4d90b35b5 |
child 10919 | 144ede948e58 |
permissions | -rw-r--r-- |
10751 | 1 |
(* Title: Real/Hyperreal/HyperOrd.ML |
2 |
Author: Jacques D. Fleuriot |
|
3 |
Copyright: 1998 University of Cambridge |
|
4 |
2000 University of Edinburgh |
|
5 |
Description: Type "hypreal" is a linear order and also |
|
6 |
satisfies plus_ac0: + is an AC-operator with zero |
|
7 |
*) |
|
8 |
||
9 |
(**** The simproc abel_cancel ****) |
|
10 |
||
11 |
(*** Two lemmas needed for the simprocs ***) |
|
12 |
||
13 |
(*Deletion of other terms in the formula, seeking the -x at the front of z*) |
|
14 |
Goal "((x::hypreal) + (y + z) = y + u) = ((x + z) = u)"; |
|
15 |
by (stac hypreal_add_left_commute 1); |
|
16 |
by (rtac hypreal_add_left_cancel 1); |
|
17 |
qed "hypreal_add_cancel_21"; |
|
18 |
||
19 |
(*A further rule to deal with the case that |
|
20 |
everything gets cancelled on the right.*) |
|
21 |
Goal "((x::hypreal) + (y + z) = y) = (x = -z)"; |
|
22 |
by (stac hypreal_add_left_commute 1); |
|
23 |
by (res_inst_tac [("t", "y")] (hypreal_add_zero_right RS subst) 1 |
|
24 |
THEN stac hypreal_add_left_cancel 1); |
|
25 |
by (simp_tac (simpset() addsimps [hypreal_eq_diff_eq RS sym]) 1); |
|
26 |
qed "hypreal_add_cancel_end"; |
|
27 |
||
28 |
||
29 |
structure Hyperreal_Cancel_Data = |
|
30 |
struct |
|
31 |
val ss = HOL_ss |
|
32 |
val eq_reflection = eq_reflection |
|
33 |
||
34 |
val sg_ref = Sign.self_ref (Theory.sign_of (the_context ())) |
|
35 |
val T = Type("HyperDef.hypreal",[]) |
|
36 |
val zero = Const ("0", T) |
|
37 |
val restrict_to_left = restrict_to_left |
|
38 |
val add_cancel_21 = hypreal_add_cancel_21 |
|
39 |
val add_cancel_end = hypreal_add_cancel_end |
|
40 |
val add_left_cancel = hypreal_add_left_cancel |
|
41 |
val add_assoc = hypreal_add_assoc |
|
42 |
val add_commute = hypreal_add_commute |
|
43 |
val add_left_commute = hypreal_add_left_commute |
|
44 |
val add_0 = hypreal_add_zero_left |
|
45 |
val add_0_right = hypreal_add_zero_right |
|
46 |
||
47 |
val eq_diff_eq = hypreal_eq_diff_eq |
|
48 |
val eqI_rules = [hypreal_less_eqI, hypreal_eq_eqI, hypreal_le_eqI] |
|
49 |
fun dest_eqI th = |
|
50 |
#1 (HOLogic.dest_bin "op =" HOLogic.boolT |
|
51 |
(HOLogic.dest_Trueprop (concl_of th))) |
|
52 |
||
53 |
val diff_def = hypreal_diff_def |
|
54 |
val minus_add_distrib = hypreal_minus_add_distrib |
|
55 |
val minus_minus = hypreal_minus_minus |
|
56 |
val minus_0 = hypreal_minus_zero |
|
57 |
val add_inverses = [hypreal_add_minus, hypreal_add_minus_left] |
|
58 |
val cancel_simps = [hypreal_add_minus_cancelA, hypreal_minus_add_cancelA] |
|
59 |
end; |
|
60 |
||
61 |
structure Hyperreal_Cancel = Abel_Cancel (Hyperreal_Cancel_Data); |
|
62 |
||
63 |
Addsimprocs [Hyperreal_Cancel.sum_conv, Hyperreal_Cancel.rel_conv]; |
|
64 |
||
65 |
Goal "- (z - y) = y - (z::hypreal)"; |
|
66 |
by (Simp_tac 1); |
|
67 |
qed "hypreal_minus_diff_eq"; |
|
68 |
Addsimps [hypreal_minus_diff_eq]; |
|
69 |
||
70 |
||
71 |
Goal "((x::hypreal) < y) = (-y < -x)"; |
|
72 |
by (stac hypreal_less_minus_iff 1); |
|
73 |
by (res_inst_tac [("x1","x")] (hypreal_less_minus_iff RS ssubst) 1); |
|
74 |
by (simp_tac (simpset() addsimps [hypreal_add_commute]) 1); |
|
75 |
qed "hypreal_less_swap_iff"; |
|
76 |
||
77 |
Goalw [hypreal_zero_def] |
|
78 |
"((0::hypreal) < x) = (-x < x)"; |
|
79 |
by (res_inst_tac [("z","x")] eq_Abs_hypreal 1); |
|
80 |
by (auto_tac (claset(), simpset() addsimps [hypreal_less, hypreal_minus])); |
|
81 |
by (ALLGOALS(Ultra_tac)); |
|
82 |
qed "hypreal_gt_zero_iff"; |
|
83 |
||
84 |
Goal "(A::hypreal) < B ==> A + C < B + C"; |
|
85 |
by (res_inst_tac [("z","A")] eq_Abs_hypreal 1); |
|
86 |
by (res_inst_tac [("z","B")] eq_Abs_hypreal 1); |
|
87 |
by (res_inst_tac [("z","C")] eq_Abs_hypreal 1); |
|
88 |
by (auto_tac (claset() addSIs [exI], |
|
89 |
simpset() addsimps [hypreal_less_def,hypreal_add])); |
|
90 |
by (Ultra_tac 1); |
|
91 |
qed "hypreal_add_less_mono1"; |
|
92 |
||
93 |
Goal "!!(A::hypreal). A < B ==> C + A < C + B"; |
|
94 |
by (auto_tac (claset() addIs [hypreal_add_less_mono1], |
|
95 |
simpset() addsimps [hypreal_add_commute])); |
|
96 |
qed "hypreal_add_less_mono2"; |
|
97 |
||
98 |
Goal "(x < (0::hypreal)) = (x < -x)"; |
|
99 |
by (rtac (hypreal_minus_zero_less_iff RS subst) 1); |
|
100 |
by (stac hypreal_gt_zero_iff 1); |
|
101 |
by (Full_simp_tac 1); |
|
102 |
qed "hypreal_lt_zero_iff"; |
|
103 |
||
104 |
Goalw [hypreal_le_def] "((0::hypreal) <= x) = (-x <= x)"; |
|
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
105 |
by (auto_tac (claset(), simpset() addsimps [hypreal_lt_zero_iff RS sym])); |
10751 | 106 |
qed "hypreal_ge_zero_iff"; |
107 |
||
108 |
Goalw [hypreal_le_def] "(x <= (0::hypreal)) = (x <= -x)"; |
|
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
109 |
by (auto_tac (claset(), simpset() addsimps [hypreal_gt_zero_iff RS sym])); |
10751 | 110 |
qed "hypreal_le_zero_iff"; |
111 |
||
112 |
Goalw [hypreal_zero_def] |
|
113 |
"[| 0 < x; 0 < y |] ==> (0::hypreal) < x + y"; |
|
114 |
by (res_inst_tac [("z","x")] eq_Abs_hypreal 1); |
|
115 |
by (res_inst_tac [("z","y")] eq_Abs_hypreal 1); |
|
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
116 |
by (auto_tac (claset(), |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
117 |
simpset() addsimps [hypreal_less_def,hypreal_add])); |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
118 |
by (auto_tac (claset() addSIs [exI], |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
119 |
simpset() addsimps [hypreal_less_def,hypreal_add])); |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
120 |
by (ultra_tac (claset() addIs [real_add_order], simpset()) 1); |
10751 | 121 |
qed "hypreal_add_order"; |
122 |
||
123 |
Goal "[| 0 < x; 0 <= y |] ==> (0::hypreal) < x + y"; |
|
124 |
by (auto_tac (claset() addDs [sym, order_le_imp_less_or_eq] |
|
125 |
addIs [hypreal_add_order], |
|
126 |
simpset())); |
|
127 |
qed "hypreal_add_order_le"; |
|
128 |
||
129 |
Goalw [hypreal_zero_def] |
|
130 |
"[| 0 < x; 0 < y |] ==> (0::hypreal) < x * y"; |
|
131 |
by (res_inst_tac [("z","x")] eq_Abs_hypreal 1); |
|
132 |
by (res_inst_tac [("z","y")] eq_Abs_hypreal 1); |
|
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
133 |
by (auto_tac (claset() addSIs [exI], |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
134 |
simpset() addsimps [hypreal_less_def,hypreal_mult])); |
10751 | 135 |
by (ultra_tac (claset() addIs [rename_numerals real_mult_order], |
136 |
simpset()) 1); |
|
137 |
qed "hypreal_mult_order"; |
|
138 |
||
139 |
Goal "[| x < 0; y < 0 |] ==> (0::hypreal) < x * y"; |
|
140 |
by (REPEAT(dtac (hypreal_minus_zero_less_iff RS iffD2) 1)); |
|
141 |
by (dtac hypreal_mult_order 1 THEN assume_tac 1); |
|
142 |
by (Asm_full_simp_tac 1); |
|
143 |
qed "hypreal_mult_less_zero1"; |
|
144 |
||
145 |
Goal "[| 0 < x; y < 0 |] ==> x*y < (0::hypreal)"; |
|
146 |
by (dtac (hypreal_minus_zero_less_iff RS iffD2) 1); |
|
147 |
by (dtac hypreal_mult_order 1 THEN assume_tac 1); |
|
148 |
by (rtac (hypreal_minus_zero_less_iff RS iffD1) 1); |
|
149 |
by (Asm_full_simp_tac 1); |
|
150 |
qed "hypreal_mult_less_zero"; |
|
151 |
||
152 |
Goalw [hypreal_one_def,hypreal_zero_def,hypreal_less_def] "0 < 1hr"; |
|
153 |
by (res_inst_tac [("x","%n. #0")] exI 1); |
|
154 |
by (res_inst_tac [("x","%n. #1")] exI 1); |
|
155 |
by (auto_tac (claset(), |
|
156 |
simpset() addsimps [real_zero_less_one, FreeUltrafilterNat_Nat_set])); |
|
157 |
qed "hypreal_zero_less_one"; |
|
158 |
||
159 |
Goal "[| 0 <= x; 0 <= y |] ==> (0::hypreal) <= x + y"; |
|
160 |
by (REPEAT(dtac order_le_imp_less_or_eq 1)); |
|
161 |
by (auto_tac (claset() addIs [hypreal_add_order, order_less_imp_le], |
|
162 |
simpset())); |
|
163 |
qed "hypreal_le_add_order"; |
|
164 |
||
165 |
(*** Monotonicity results ***) |
|
166 |
||
167 |
Goal "(v+z < w+z) = (v < (w::hypreal))"; |
|
168 |
by (Simp_tac 1); |
|
169 |
qed "hypreal_add_right_cancel_less"; |
|
170 |
||
171 |
Goal "(z+v < z+w) = (v < (w::hypreal))"; |
|
172 |
by (Simp_tac 1); |
|
173 |
qed "hypreal_add_left_cancel_less"; |
|
174 |
||
175 |
Addsimps [hypreal_add_right_cancel_less, |
|
176 |
hypreal_add_left_cancel_less]; |
|
177 |
||
178 |
Goal "(v+z <= w+z) = (v <= (w::hypreal))"; |
|
179 |
by (Simp_tac 1); |
|
180 |
qed "hypreal_add_right_cancel_le"; |
|
181 |
||
182 |
Goal "(z+v <= z+w) = (v <= (w::hypreal))"; |
|
183 |
by (Simp_tac 1); |
|
184 |
qed "hypreal_add_left_cancel_le"; |
|
185 |
||
186 |
Addsimps [hypreal_add_right_cancel_le, hypreal_add_left_cancel_le]; |
|
187 |
||
188 |
Goal "[| (z1::hypreal) < y1; z2 < y2 |] ==> z1 + z2 < y1 + y2"; |
|
189 |
by (dtac (hypreal_less_minus_iff RS iffD1) 1); |
|
190 |
by (dtac (hypreal_less_minus_iff RS iffD1) 1); |
|
191 |
by (dtac hypreal_add_order 1 THEN assume_tac 1); |
|
192 |
by (thin_tac "0 < y2 + - z2" 1); |
|
193 |
by (dres_inst_tac [("C","z1 + z2")] hypreal_add_less_mono1 1); |
|
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
194 |
by (auto_tac (claset(), |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
195 |
simpset() addsimps [hypreal_minus_add_distrib RS sym] @ hypreal_add_ac |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
196 |
delsimps [hypreal_minus_add_distrib])); |
10751 | 197 |
qed "hypreal_add_less_mono"; |
198 |
||
199 |
Goal "(q1::hypreal) <= q2 ==> x + q1 <= x + q2"; |
|
200 |
by (dtac order_le_imp_less_or_eq 1); |
|
201 |
by (Step_tac 1); |
|
202 |
by (auto_tac (claset() addSIs [order_less_imp_le,hypreal_add_less_mono1], |
|
203 |
simpset() addsimps [hypreal_add_commute])); |
|
204 |
qed "hypreal_add_left_le_mono1"; |
|
205 |
||
206 |
Goal "(q1::hypreal) <= q2 ==> q1 + x <= q2 + x"; |
|
207 |
by (auto_tac (claset() addDs [hypreal_add_left_le_mono1], |
|
208 |
simpset() addsimps [hypreal_add_commute])); |
|
209 |
qed "hypreal_add_le_mono1"; |
|
210 |
||
211 |
Goal "[|(i::hypreal)<=j; k<=l |] ==> i + k <= j + l"; |
|
212 |
by (etac (hypreal_add_le_mono1 RS order_trans) 1); |
|
213 |
by (Simp_tac 1); |
|
214 |
qed "hypreal_add_le_mono"; |
|
215 |
||
216 |
Goal "[|(i::hypreal)<j; k<=l |] ==> i + k < j + l"; |
|
217 |
by (auto_tac (claset() addSDs [order_le_imp_less_or_eq] |
|
218 |
addIs [hypreal_add_less_mono1,hypreal_add_less_mono], |
|
219 |
simpset())); |
|
220 |
qed "hypreal_add_less_le_mono"; |
|
221 |
||
222 |
Goal "[|(i::hypreal)<=j; k<l |] ==> i + k < j + l"; |
|
223 |
by (auto_tac (claset() addSDs [order_le_imp_less_or_eq] |
|
224 |
addIs [hypreal_add_less_mono2,hypreal_add_less_mono], |
|
225 |
simpset())); |
|
226 |
qed "hypreal_add_le_less_mono"; |
|
227 |
||
228 |
Goal "(A::hypreal) + C < B + C ==> A < B"; |
|
229 |
by (Full_simp_tac 1); |
|
230 |
qed "hypreal_less_add_right_cancel"; |
|
231 |
||
232 |
Goal "(C::hypreal) + A < C + B ==> A < B"; |
|
233 |
by (Full_simp_tac 1); |
|
234 |
qed "hypreal_less_add_left_cancel"; |
|
235 |
||
236 |
Goal "[|r < x; (0::hypreal) <= y|] ==> r < x + y"; |
|
237 |
by (auto_tac (claset() addDs [hypreal_add_less_le_mono], |
|
238 |
simpset())); |
|
239 |
qed "hypreal_add_zero_less_le_mono"; |
|
240 |
||
241 |
Goal "!!(A::hypreal). A + C <= B + C ==> A <= B"; |
|
242 |
by (dres_inst_tac [("x","-C")] hypreal_add_le_mono1 1); |
|
243 |
by (asm_full_simp_tac (simpset() addsimps [hypreal_add_assoc]) 1); |
|
244 |
qed "hypreal_le_add_right_cancel"; |
|
245 |
||
246 |
Goal "!!(A::hypreal). C + A <= C + B ==> A <= B"; |
|
247 |
by (dres_inst_tac [("x","-C")] hypreal_add_left_le_mono1 1); |
|
248 |
by (asm_full_simp_tac (simpset() addsimps [hypreal_add_assoc RS sym]) 1); |
|
249 |
qed "hypreal_le_add_left_cancel"; |
|
250 |
||
251 |
Goal "(0::hypreal) <= x*x"; |
|
252 |
by (res_inst_tac [("x","0"),("y","x")] hypreal_linear_less2 1); |
|
253 |
by (auto_tac (claset() addIs [hypreal_mult_order, |
|
254 |
hypreal_mult_less_zero1,order_less_imp_le], |
|
255 |
simpset())); |
|
256 |
qed "hypreal_le_square"; |
|
257 |
Addsimps [hypreal_le_square]; |
|
258 |
||
259 |
Goalw [hypreal_le_def] "- (x*x) <= (0::hypreal)"; |
|
260 |
by (auto_tac (claset() addSDs [hypreal_le_square RS order_le_less_trans], |
|
261 |
simpset() addsimps [hypreal_minus_zero_less_iff])); |
|
262 |
qed "hypreal_less_minus_square"; |
|
263 |
Addsimps [hypreal_less_minus_square]; |
|
264 |
||
265 |
Goal "(0*x<r)=((0::hypreal)<r)"; |
|
266 |
by (Simp_tac 1); |
|
267 |
qed "hypreal_mult_0_less"; |
|
268 |
||
269 |
Goal "[| (0::hypreal) < z; x < y |] ==> x*z < y*z"; |
|
270 |
by (rotate_tac 1 1); |
|
271 |
by (dtac (hypreal_less_minus_iff RS iffD1) 1); |
|
272 |
by (rtac (hypreal_less_minus_iff RS iffD2) 1); |
|
273 |
by (dtac hypreal_mult_order 1 THEN assume_tac 1); |
|
274 |
by (asm_full_simp_tac (simpset() addsimps [hypreal_add_mult_distrib2, |
|
275 |
hypreal_mult_commute ]) 1); |
|
276 |
qed "hypreal_mult_less_mono1"; |
|
277 |
||
278 |
Goal "[| (0::hypreal)<z; x<y |] ==> z*x<z*y"; |
|
279 |
by (asm_simp_tac (simpset() addsimps [hypreal_mult_commute,hypreal_mult_less_mono1]) 1); |
|
280 |
qed "hypreal_mult_less_mono2"; |
|
281 |
||
282 |
Goal "[| (0::hypreal)<=z; x<y |] ==> x*z<=y*z"; |
|
283 |
by (EVERY1 [rtac hypreal_less_or_eq_imp_le, dtac order_le_imp_less_or_eq]); |
|
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
284 |
by (auto_tac (claset() addIs [hypreal_mult_less_mono1], simpset())); |
10751 | 285 |
qed "hypreal_mult_le_less_mono1"; |
286 |
||
287 |
Goal "[| (0::hypreal)<=z; x<y |] ==> z*x<=z*y"; |
|
288 |
by (asm_simp_tac (simpset() addsimps [hypreal_mult_commute, |
|
289 |
hypreal_mult_le_less_mono1]) 1); |
|
290 |
qed "hypreal_mult_le_less_mono2"; |
|
291 |
||
292 |
val prem1::prem2::prem3::rest = goal thy |
|
293 |
"[| (0::hypreal)<y; x<r; y*r<t*s |] ==> y*x<t*s"; |
|
294 |
by (rtac ([[prem1,prem2] MRS hypreal_mult_less_mono2, prem3] |
|
295 |
MRS order_less_trans) 1); |
|
296 |
qed "hypreal_mult_less_trans"; |
|
297 |
||
298 |
Goal "[| 0<=y; x<r; y*r<t*s; (0::hypreal)<t*s|] ==> y*x<t*s"; |
|
299 |
by (dtac order_le_imp_less_or_eq 1); |
|
300 |
by (fast_tac (HOL_cs addEs [hypreal_mult_0_less RS iffD2, |
|
301 |
hypreal_mult_less_trans]) 1); |
|
302 |
qed "hypreal_mult_le_less_trans"; |
|
303 |
||
304 |
Goal "[| 0 <= y; x <= r; y*r < t*s; (0::hypreal) < t*s|] ==> y*x < t*s"; |
|
305 |
by (dres_inst_tac [("x","x")] order_le_imp_less_or_eq 1); |
|
306 |
by (fast_tac (claset() addIs [hypreal_mult_le_less_trans]) 1); |
|
307 |
qed "hypreal_mult_le_le_trans"; |
|
308 |
||
309 |
Goal "[| u<v; x<y; (0::hypreal) < v; 0 < x |] ==> u*x < v* y"; |
|
310 |
by (etac (hypreal_mult_less_mono1 RS order_less_trans) 1); |
|
311 |
by (assume_tac 1); |
|
312 |
by (etac hypreal_mult_less_mono2 1); |
|
313 |
by (assume_tac 1); |
|
314 |
qed "hypreal_mult_less_mono"; |
|
315 |
||
316 |
(*UNUSED at present but possibly more useful than hypreal_mult_less_mono*) |
|
317 |
Goal "[| x < y; r1 < r2; (0::hypreal) <= r1; 0 <= x|] ==> r1 * x < r2 * y"; |
|
318 |
by (subgoal_tac "0<r2" 1); |
|
319 |
by (blast_tac (claset() addIs [order_le_less_trans]) 2); |
|
320 |
by (case_tac "x=0" 1); |
|
321 |
by (auto_tac (claset() addSDs [order_le_imp_less_or_eq] |
|
322 |
addIs [hypreal_mult_less_mono, hypreal_mult_order], |
|
323 |
simpset())); |
|
324 |
qed "hypreal_mult_less_mono'"; |
|
325 |
||
326 |
Goal "0 < x ==> 0 < inverse (x::hypreal)"; |
|
327 |
by (EVERY1[rtac ccontr, dtac hypreal_leI]); |
|
328 |
by (forward_tac [hypreal_minus_zero_less_iff2 RS iffD2] 1); |
|
329 |
by (forward_tac [hypreal_not_refl2 RS not_sym] 1); |
|
330 |
by (dtac (hypreal_not_refl2 RS not_sym RS hypreal_inverse_not_zero) 1); |
|
331 |
by (EVERY1[dtac order_le_imp_less_or_eq, Step_tac]); |
|
332 |
by (dtac hypreal_mult_less_zero1 1 THEN assume_tac 1); |
|
333 |
by (auto_tac (claset() addIs [hypreal_zero_less_one RS hypreal_less_asym], |
|
334 |
simpset() addsimps [hypreal_minus_zero_less_iff])); |
|
335 |
qed "hypreal_inverse_gt_zero"; |
|
336 |
||
337 |
Goal "x < 0 ==> inverse (x::hypreal) < 0"; |
|
338 |
by (ftac hypreal_not_refl2 1); |
|
339 |
by (dtac (hypreal_minus_zero_less_iff RS iffD2) 1); |
|
340 |
by (rtac (hypreal_minus_zero_less_iff RS iffD1) 1); |
|
341 |
by (stac (hypreal_minus_inverse RS sym) 1); |
|
342 |
by (auto_tac (claset() addIs [hypreal_inverse_gt_zero], simpset())); |
|
343 |
qed "hypreal_inverse_less_zero"; |
|
344 |
||
345 |
Goal "[| 0 <= x; 0 <= y |] ==> (x+y = 0) = (x = 0 & y = (0::hypreal))"; |
|
346 |
by (auto_tac (claset() addIs [order_antisym], simpset())); |
|
347 |
qed "hypreal_add_nonneg_eq_0_iff"; |
|
348 |
||
349 |
Goal "(x*y = 0) = (x = 0 | y = (0::hypreal))"; |
|
350 |
by Auto_tac; |
|
351 |
by (blast_tac (claset() addDs [hypreal_mult_zero_disj]) 1); |
|
352 |
qed "hypreal_mult_is_0"; |
|
353 |
||
354 |
Goal "(x*x + y*y + z*z = 0) = (x = 0 & y = 0 & z = (0::hypreal))"; |
|
355 |
by (simp_tac (HOL_ss addsimps [hypreal_le_square, hypreal_le_add_order, |
|
356 |
hypreal_add_nonneg_eq_0_iff, hypreal_mult_is_0]) 1); |
|
357 |
qed "hypreal_three_squares_add_zero_iff"; |
|
358 |
||
359 |
Goal "(x::hypreal)*x <= x*x + y*y"; |
|
360 |
by (res_inst_tac [("z","x")] eq_Abs_hypreal 1); |
|
361 |
by (res_inst_tac [("z","y")] eq_Abs_hypreal 1); |
|
362 |
by (auto_tac (claset(), |
|
363 |
simpset() addsimps [hypreal_mult,hypreal_add,hypreal_le])); |
|
364 |
qed "hypreal_self_le_add_pos"; |
|
365 |
Addsimps [hypreal_self_le_add_pos]; |
|
366 |
||
367 |
(*lcp: new lemma unfortunately needed...*) |
|
368 |
Goal "-(x*x) <= (y*y::real)"; |
|
369 |
by (rtac order_trans 1); |
|
370 |
by (rtac real_le_square 2); |
|
371 |
by Auto_tac; |
|
372 |
qed "minus_square_le_square"; |
|
373 |
||
374 |
Goal "(x::hypreal)*x <= x*x + y*y + z*z"; |
|
375 |
by (res_inst_tac [("z","x")] eq_Abs_hypreal 1); |
|
376 |
by (res_inst_tac [("z","y")] eq_Abs_hypreal 1); |
|
377 |
by (res_inst_tac [("z","z")] eq_Abs_hypreal 1); |
|
378 |
by (auto_tac (claset(), |
|
379 |
simpset() addsimps [hypreal_mult, hypreal_add, hypreal_le, |
|
380 |
minus_square_le_square])); |
|
381 |
qed "hypreal_self_le_add_pos2"; |
|
382 |
Addsimps [hypreal_self_le_add_pos2]; |
|
383 |
||
384 |
||
385 |
(*---------------------------------------------------------------------------- |
|
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
386 |
Existence of infinite hyperreal number |
10751 | 387 |
----------------------------------------------------------------------------*) |
388 |
||
389 |
Goalw [omega_def] "Rep_hypreal(whr) : hypreal"; |
|
390 |
by (rtac Rep_hypreal 1); |
|
391 |
qed "Rep_hypreal_omega"; |
|
392 |
||
393 |
(* existence of infinite number not corresponding to any real number *) |
|
394 |
(* use assumption that member FreeUltrafilterNat is not finite *) |
|
395 |
(* a few lemmas first *) |
|
396 |
||
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
397 |
Goal "{n::nat. x = real_of_nat n} = {} | \ |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
398 |
\ (EX y. {n::nat. x = real_of_nat n} = {y})"; |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
399 |
by (auto_tac (claset() addDs [inj_real_of_nat RS injD], simpset())); |
10751 | 400 |
qed "lemma_omega_empty_singleton_disj"; |
401 |
||
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
402 |
Goal "finite {n::nat. x = real_of_nat n}"; |
10751 | 403 |
by (cut_inst_tac [("x","x")] lemma_omega_empty_singleton_disj 1); |
404 |
by Auto_tac; |
|
405 |
qed "lemma_finite_omega_set"; |
|
406 |
||
407 |
Goalw [omega_def,hypreal_of_real_def] |
|
408 |
"~ (EX x. hypreal_of_real x = whr)"; |
|
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
409 |
by (auto_tac (claset(), |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
410 |
simpset() addsimps [real_of_nat_Suc, real_diff_eq_eq RS sym, |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
411 |
lemma_finite_omega_set RS FreeUltrafilterNat_finite])); |
10751 | 412 |
qed "not_ex_hypreal_of_real_eq_omega"; |
413 |
||
414 |
Goal "hypreal_of_real x ~= whr"; |
|
415 |
by (cut_facts_tac [not_ex_hypreal_of_real_eq_omega] 1); |
|
416 |
by Auto_tac; |
|
417 |
qed "hypreal_of_real_not_eq_omega"; |
|
418 |
||
419 |
(* existence of infinitesimal number also not *) |
|
420 |
(* corresponding to any real number *) |
|
421 |
||
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
422 |
Goal "inverse (real_of_nat x) = inverse (real_of_nat y) ==> x = y"; |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
423 |
by (rtac (inj_real_of_nat RS injD) 1); |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
424 |
by (Asm_full_simp_tac 1); |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
425 |
qed "real_of_nat_inverse_inj"; |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
426 |
|
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
427 |
Goal "{n::nat. x = inverse(real_of_nat(Suc n))} = {} | \ |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
428 |
\ (EX y. {n::nat. x = inverse(real_of_nat(Suc n))} = {y})"; |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
429 |
by (auto_tac (claset(), simpset() addsimps [inj_real_of_nat RS inj_eq])); |
10751 | 430 |
qed "lemma_epsilon_empty_singleton_disj"; |
431 |
||
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
432 |
Goal "finite {n::nat. x = inverse(real_of_nat(Suc n))}"; |
10751 | 433 |
by (cut_inst_tac [("x","x")] lemma_epsilon_empty_singleton_disj 1); |
434 |
by Auto_tac; |
|
435 |
qed "lemma_finite_epsilon_set"; |
|
436 |
||
437 |
Goalw [epsilon_def,hypreal_of_real_def] |
|
438 |
"~ (EX x. hypreal_of_real x = ehr)"; |
|
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
439 |
by (auto_tac (claset(), |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
440 |
simpset() addsimps [lemma_finite_epsilon_set RS FreeUltrafilterNat_finite])); |
10751 | 441 |
qed "not_ex_hypreal_of_real_eq_epsilon"; |
442 |
||
443 |
Goal "hypreal_of_real x ~= ehr"; |
|
444 |
by (cut_facts_tac [not_ex_hypreal_of_real_eq_epsilon] 1); |
|
445 |
by Auto_tac; |
|
446 |
qed "hypreal_of_real_not_eq_epsilon"; |
|
447 |
||
448 |
Goalw [epsilon_def,hypreal_zero_def] "ehr ~= 0"; |
|
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
449 |
by Auto_tac; |
10751 | 450 |
by (auto_tac (claset(), |
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
451 |
simpset() addsimps [real_of_nat_Suc_gt_zero RS real_not_refl2 RS not_sym])); |
10751 | 452 |
qed "hypreal_epsilon_not_zero"; |
453 |
||
454 |
Goal "ehr = inverse(whr)"; |
|
455 |
by (asm_full_simp_tac (simpset() addsimps |
|
456 |
[hypreal_inverse, omega_def, epsilon_def]) 1); |
|
457 |
qed "hypreal_epsilon_inverse_omega"; |
|
458 |
||
459 |
||
460 |
(* this proof is so much simpler than one for reals!! *) |
|
461 |
Goal "[| 0 < r; r < x |] ==> inverse x < inverse (r::hypreal)"; |
|
462 |
by (res_inst_tac [("z","x")] eq_Abs_hypreal 1); |
|
463 |
by (res_inst_tac [("z","r")] eq_Abs_hypreal 1); |
|
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
464 |
by (auto_tac (claset(), |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
465 |
simpset() addsimps [hypreal_inverse, hypreal_less,hypreal_zero_def])); |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
466 |
by (ultra_tac (claset() addIs [real_inverse_less_swap], simpset()) 1); |
10751 | 467 |
qed "hypreal_inverse_less_swap"; |
468 |
||
469 |
Goal "[| 0 < r; 0 < x|] ==> (r < x) = (inverse x < inverse (r::hypreal))"; |
|
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
470 |
by (auto_tac (claset() addIs [hypreal_inverse_less_swap], simpset())); |
10751 | 471 |
by (res_inst_tac [("t","r")] (hypreal_inverse_inverse RS subst) 1); |
472 |
by (res_inst_tac [("t","x")] (hypreal_inverse_inverse RS subst) 1); |
|
473 |
by (rtac hypreal_inverse_less_swap 1); |
|
474 |
by (auto_tac (claset(), simpset() addsimps [hypreal_inverse_gt_zero])); |
|
475 |
qed "hypreal_inverse_less_iff"; |
|
476 |
||
477 |
Goal "[| 0 < z; x < y |] ==> x * inverse z < y * inverse (z::hypreal)"; |
|
478 |
by (blast_tac (claset() addSIs [hypreal_mult_less_mono1, |
|
479 |
hypreal_inverse_gt_zero]) 1); |
|
480 |
qed "hypreal_mult_inverse_less_mono1"; |
|
481 |
||
482 |
Goal "[| 0 < z; x < y |] ==> inverse z * x < inverse (z::hypreal) * y"; |
|
483 |
by (blast_tac (claset() addSIs [hypreal_mult_less_mono2, |
|
484 |
hypreal_inverse_gt_zero]) 1); |
|
485 |
qed "hypreal_mult_inverse_less_mono2"; |
|
486 |
||
487 |
Goal "[| (0::hypreal) < z; x*z < y*z |] ==> x < y"; |
|
488 |
by (forw_inst_tac [("x","x*z")] hypreal_mult_inverse_less_mono1 1); |
|
489 |
by (dtac (hypreal_not_refl2 RS not_sym) 2); |
|
490 |
by (auto_tac (claset() addSDs [hypreal_mult_inverse], |
|
491 |
simpset() addsimps hypreal_mult_ac)); |
|
492 |
qed "hypreal_less_mult_right_cancel"; |
|
493 |
||
494 |
Goal "[| (0::hypreal) < z; z*x < z*y |] ==> x < y"; |
|
495 |
by (auto_tac (claset() addIs [hypreal_less_mult_right_cancel], |
|
496 |
simpset() addsimps [hypreal_mult_commute])); |
|
497 |
qed "hypreal_less_mult_left_cancel"; |
|
498 |
||
499 |
Goal "[| 0 < r; (0::hypreal) < ra; r < x; ra < y |] ==> r*ra < x*y"; |
|
500 |
by (forw_inst_tac [("y","r")] order_less_trans 1); |
|
501 |
by (dres_inst_tac [("z","ra"),("x","r")] hypreal_mult_less_mono1 2); |
|
502 |
by (dres_inst_tac [("z","x"),("x","ra")] hypreal_mult_less_mono2 3); |
|
503 |
by (auto_tac (claset() addIs [order_less_trans], simpset())); |
|
504 |
qed "hypreal_mult_less_gt_zero"; |
|
505 |
||
506 |
Goal "[| 0 < r; (0::hypreal) < ra; r <= x; ra <= y |] ==> r*ra <= x*y"; |
|
507 |
by (REPEAT(dtac order_le_imp_less_or_eq 1)); |
|
508 |
by (rtac hypreal_less_or_eq_imp_le 1); |
|
509 |
by (auto_tac (claset() addIs [hypreal_mult_less_mono1, |
|
510 |
hypreal_mult_less_mono2,hypreal_mult_less_gt_zero], |
|
511 |
simpset())); |
|
512 |
qed "hypreal_mult_le_ge_zero"; |
|
513 |
||
514 |
(*---------------------------------------------------------------------------- |
|
515 |
Some convenient biconditionals for products of signs |
|
516 |
----------------------------------------------------------------------------*) |
|
517 |
||
518 |
Goal "((0::hypreal) < x*y) = (0 < x & 0 < y | x < 0 & y < 0)"; |
|
519 |
by (auto_tac (claset(), |
|
520 |
simpset() addsimps [order_le_less, linorder_not_less, |
|
521 |
hypreal_mult_order, hypreal_mult_less_zero1])); |
|
522 |
by (ALLGOALS (rtac ccontr)); |
|
523 |
by (auto_tac (claset(), |
|
524 |
simpset() addsimps [order_le_less, linorder_not_less])); |
|
525 |
by (ALLGOALS (etac rev_mp)); |
|
526 |
by (ALLGOALS (dtac hypreal_mult_less_zero THEN' assume_tac)); |
|
527 |
by (auto_tac (claset() addDs [order_less_not_sym], |
|
528 |
simpset() addsimps [hypreal_mult_commute])); |
|
529 |
qed "hypreal_zero_less_mult_iff"; |
|
530 |
||
531 |
Goal "((0::hypreal) <= x*y) = (0 <= x & 0 <= y | x <= 0 & y <= 0)"; |
|
532 |
by (auto_tac (claset() addDs [hypreal_mult_zero_disj], |
|
533 |
simpset() addsimps [order_le_less, linorder_not_less, |
|
534 |
hypreal_zero_less_mult_iff])); |
|
535 |
qed "hypreal_zero_le_mult_iff"; |
|
536 |
||
537 |
Goal "(x*y < (0::hypreal)) = (0 < x & y < 0 | x < 0 & 0 < y)"; |
|
538 |
by (auto_tac (claset(), |
|
539 |
simpset() addsimps [hypreal_zero_le_mult_iff, |
|
540 |
linorder_not_le RS sym])); |
|
541 |
by (auto_tac (claset() addDs [order_less_not_sym], |
|
542 |
simpset() addsimps [linorder_not_le])); |
|
543 |
qed "hypreal_mult_less_zero_iff"; |
|
544 |
||
545 |
Goal "(x*y <= (0::hypreal)) = (0 <= x & y <= 0 | x <= 0 & 0 <= y)"; |
|
546 |
by (auto_tac (claset() addDs [order_less_not_sym], |
|
547 |
simpset() addsimps [hypreal_zero_less_mult_iff, |
|
548 |
linorder_not_less RS sym])); |
|
549 |
qed "hypreal_mult_le_zero_iff"; |
|
550 |