175 lemma real_mult_congruent2_lemma: |
175 lemma real_mult_congruent2_lemma: |
176 "!!(x1::preal). [| x1 + y2 = x2 + y1 |] ==> |
176 "!!(x1::preal). [| x1 + y2 = x2 + y1 |] ==> |
177 x * x1 + y * y1 + (x * y2 + y * x2) = |
177 x * x1 + y * y1 + (x * y2 + y * x2) = |
178 x * x2 + y * y2 + (x * y1 + y * x1)" |
178 x * x2 + y * y2 + (x * y1 + y * x1)" |
179 apply (simp add: add_left_commute add_assoc [symmetric]) |
179 apply (simp add: add_left_commute add_assoc [symmetric]) |
180 apply (simp add: preal_add_assoc preal_add_mult_distrib2 [symmetric]) |
180 apply (simp add: add_assoc right_distrib [symmetric]) |
181 apply (simp add: preal_add_commute) |
181 apply (simp add: add_commute) |
182 done |
182 done |
183 |
183 |
184 lemma real_mult_congruent2: |
184 lemma real_mult_congruent2: |
185 "(%p1 p2. |
185 "(%p1 p2. |
186 (%(x1,y1). (%(x2,y2). |
186 (%(x1,y1). (%(x2,y2). |
187 { Abs_Real (realrel``{(x1*x2 + y1*y2, x1*y2+y1*x2)}) }) p2) p1) |
187 { Abs_Real (realrel``{(x1*x2 + y1*y2, x1*y2+y1*x2)}) }) p2) p1) |
188 respects2 realrel" |
188 respects2 realrel" |
189 apply (rule congruent2_commuteI [OF equiv_realrel], clarify) |
189 apply (rule congruent2_commuteI [OF equiv_realrel], clarify) |
190 apply (simp add: preal_mult_commute preal_add_commute) |
190 apply (simp add: mult_commute add_commute) |
191 apply (auto simp add: real_mult_congruent2_lemma) |
191 apply (auto simp add: real_mult_congruent2_lemma) |
192 done |
192 done |
193 |
193 |
194 lemma real_mult: |
194 lemma real_mult: |
195 "Abs_Real((realrel``{(x1,y1)})) * Abs_Real((realrel``{(x2,y2)})) = |
195 "Abs_Real((realrel``{(x1,y1)})) * Abs_Real((realrel``{(x2,y2)})) = |
196 Abs_Real(realrel `` {(x1*x2+y1*y2,x1*y2+y1*x2)})" |
196 Abs_Real(realrel `` {(x1*x2+y1*y2,x1*y2+y1*x2)})" |
197 by (simp add: real_mult_def UN_UN_split_split_eq |
197 by (simp add: real_mult_def UN_UN_split_split_eq |
198 UN_equiv_class2 [OF equiv_realrel equiv_realrel real_mult_congruent2]) |
198 UN_equiv_class2 [OF equiv_realrel equiv_realrel real_mult_congruent2]) |
199 |
199 |
200 lemma real_mult_commute: "(z::real) * w = w * z" |
200 lemma real_mult_commute: "(z::real) * w = w * z" |
201 by (cases z, cases w, simp add: real_mult preal_add_ac preal_mult_ac) |
201 by (cases z, cases w, simp add: real_mult add_ac mult_ac) |
202 |
202 |
203 lemma real_mult_assoc: "((z1::real) * z2) * z3 = z1 * (z2 * z3)" |
203 lemma real_mult_assoc: "((z1::real) * z2) * z3 = z1 * (z2 * z3)" |
204 apply (cases z1, cases z2, cases z3) |
204 apply (cases z1, cases z2, cases z3) |
205 apply (simp add: real_mult preal_add_mult_distrib2 preal_add_ac preal_mult_ac) |
205 apply (simp add: real_mult right_distrib add_ac mult_ac) |
206 done |
206 done |
207 |
207 |
208 lemma real_mult_1: "(1::real) * z = z" |
208 lemma real_mult_1: "(1::real) * z = z" |
209 apply (cases z) |
209 apply (cases z) |
210 apply (simp add: real_mult real_one_def preal_add_mult_distrib2 |
210 apply (simp add: real_mult real_one_def right_distrib |
211 preal_mult_1_right preal_mult_ac preal_add_ac) |
211 mult_1_right mult_ac add_ac) |
212 done |
212 done |
213 |
213 |
214 lemma real_add_mult_distrib: "((z1::real) + z2) * w = (z1 * w) + (z2 * w)" |
214 lemma real_add_mult_distrib: "((z1::real) + z2) * w = (z1 * w) + (z2 * w)" |
215 apply (cases z1, cases z2, cases w) |
215 apply (cases z1, cases z2, cases w) |
216 apply (simp add: real_add real_mult preal_add_mult_distrib2 |
216 apply (simp add: real_add real_mult right_distrib add_ac mult_ac) |
217 preal_add_ac preal_mult_ac) |
|
218 done |
217 done |
219 |
218 |
220 text{*one and zero are distinct*} |
219 text{*one and zero are distinct*} |
221 lemma real_zero_not_eq_one: "0 \<noteq> (1::real)" |
220 lemma real_zero_not_eq_one: "0 \<noteq> (1::real)" |
222 proof - |
221 proof - |
223 have "(1::preal) < 1 + 1" |
222 have "(1::preal) < 1 + 1" |
224 by (simp add: preal_self_less_add_left) |
223 by (simp add: preal_self_less_add_left) |
225 thus ?thesis |
224 thus ?thesis |
226 by (simp add: real_zero_def real_one_def preal_add_right_cancel_iff) |
225 by (simp add: real_zero_def real_one_def) |
227 qed |
226 qed |
228 |
227 |
229 instance real :: comm_ring_1 |
228 instance real :: comm_ring_1 |
230 proof |
229 proof |
231 fix x y z :: real |
230 fix x y z :: real |
252 x = "Abs_Real (realrel``{(1, inverse (D) + 1)})" |
251 x = "Abs_Real (realrel``{(1, inverse (D) + 1)})" |
253 in exI) |
252 in exI) |
254 apply (rule_tac [2] |
253 apply (rule_tac [2] |
255 x = "Abs_Real (realrel``{(inverse (D) + 1, 1)})" |
254 x = "Abs_Real (realrel``{(inverse (D) + 1, 1)})" |
256 in exI) |
255 in exI) |
257 apply (auto simp add: real_mult preal_mult_1_right |
256 apply (auto simp add: real_mult ring_distrib |
258 preal_add_mult_distrib2 preal_add_mult_distrib preal_mult_1 |
257 preal_mult_inverse_right add_ac mult_ac) |
259 preal_mult_inverse_right preal_add_ac preal_mult_ac) |
|
260 done |
258 done |
261 |
259 |
262 lemma real_mult_inverse_left: "x \<noteq> 0 ==> inverse(x)*x = (1::real)" |
260 lemma real_mult_inverse_left: "x \<noteq> 0 ==> inverse(x)*x = (1::real)" |
263 apply (simp add: real_inverse_def) |
261 apply (simp add: real_inverse_def) |
264 apply (drule real_mult_inverse_left_ex, safe) |
262 apply (drule real_mult_inverse_left_ex, safe) |
300 following two lemmas.*} |
298 following two lemmas.*} |
301 lemma preal_eq_le_imp_le: |
299 lemma preal_eq_le_imp_le: |
302 assumes eq: "a+b = c+d" and le: "c \<le> a" |
300 assumes eq: "a+b = c+d" and le: "c \<le> a" |
303 shows "b \<le> (d::preal)" |
301 shows "b \<le> (d::preal)" |
304 proof - |
302 proof - |
305 have "c+d \<le> a+d" by (simp add: prems preal_cancels) |
303 have "c+d \<le> a+d" by (simp add: prems) |
306 hence "a+b \<le> a+d" by (simp add: prems) |
304 hence "a+b \<le> a+d" by (simp add: prems) |
307 thus "b \<le> d" by (simp add: preal_cancels) |
305 thus "b \<le> d" by simp |
308 qed |
306 qed |
309 |
307 |
310 lemma real_le_lemma: |
308 lemma real_le_lemma: |
311 assumes l: "u1 + v2 \<le> u2 + v1" |
309 assumes l: "u1 + v2 \<le> u2 + v1" |
312 and "x1 + v1 = u1 + y1" |
310 and "x1 + v1 = u1 + y1" |
313 and "x2 + v2 = u2 + y2" |
311 and "x2 + v2 = u2 + y2" |
314 shows "x1 + y2 \<le> x2 + (y1::preal)" |
312 shows "x1 + y2 \<le> x2 + (y1::preal)" |
315 proof - |
313 proof - |
316 have "(x1+v1) + (u2+y2) = (u1+y1) + (x2+v2)" by (simp add: prems) |
314 have "(x1+v1) + (u2+y2) = (u1+y1) + (x2+v2)" by (simp add: prems) |
317 hence "(x1+y2) + (u2+v1) = (x2+y1) + (u1+v2)" by (simp add: preal_add_ac) |
315 hence "(x1+y2) + (u2+v1) = (x2+y1) + (u1+v2)" by (simp add: add_ac) |
318 also have "... \<le> (x2+y1) + (u2+v1)" |
316 also have "... \<le> (x2+y1) + (u2+v1)" by (simp add: prems) |
319 by (simp add: prems preal_add_le_cancel_left) |
317 finally show ?thesis by simp |
320 finally show ?thesis by (simp add: preal_add_le_cancel_right) |
318 qed |
321 qed |
|
322 |
319 |
323 lemma real_le: |
320 lemma real_le: |
324 "(Abs_Real(realrel``{(x1,y1)}) \<le> Abs_Real(realrel``{(x2,y2)})) = |
321 "(Abs_Real(realrel``{(x1,y1)}) \<le> Abs_Real(realrel``{(x2,y2)})) = |
325 (x1 + y2 \<le> x2 + y1)" |
322 (x1 + y2 \<le> x2 + y1)" |
326 apply (simp add: real_le_def) |
323 apply (simp add: real_le_def) |
327 apply (auto intro: real_le_lemma) |
324 apply (auto intro: real_le_lemma) |
328 done |
325 done |
329 |
326 |
330 lemma real_le_anti_sym: "[| z \<le> w; w \<le> z |] ==> z = (w::real)" |
327 lemma real_le_anti_sym: "[| z \<le> w; w \<le> z |] ==> z = (w::real)" |
331 by (cases z, cases w, simp add: real_le) |
328 by (cases z, cases w, simp add: real_le) |
334 assumes "x + v \<le> u + y" |
331 assumes "x + v \<le> u + y" |
335 and "u + v' \<le> u' + v" |
332 and "u + v' \<le> u' + v" |
336 and "x2 + v2 = u2 + y2" |
333 and "x2 + v2 = u2 + y2" |
337 shows "x + v' \<le> u' + (y::preal)" |
334 shows "x + v' \<le> u' + (y::preal)" |
338 proof - |
335 proof - |
339 have "(x+v') + (u+v) = (x+v) + (u+v')" by (simp add: preal_add_ac) |
336 have "(x+v') + (u+v) = (x+v) + (u+v')" by (simp add: add_ac) |
340 also have "... \<le> (u+y) + (u+v')" |
337 also have "... \<le> (u+y) + (u+v')" by (simp add: prems) |
341 by (simp add: preal_add_le_cancel_right prems) |
338 also have "... \<le> (u+y) + (u'+v)" by (simp add: prems) |
342 also have "... \<le> (u+y) + (u'+v)" |
339 also have "... = (u'+y) + (u+v)" by (simp add: add_ac) |
343 by (simp add: preal_add_le_cancel_left prems) |
340 finally show ?thesis by simp |
344 also have "... = (u'+y) + (u+v)" by (simp add: preal_add_ac) |
|
345 finally show ?thesis by (simp add: preal_add_le_cancel_right) |
|
346 qed |
341 qed |
347 |
342 |
348 lemma real_le_trans: "[| i \<le> j; j \<le> k |] ==> i \<le> (k::real)" |
343 lemma real_le_trans: "[| i \<le> j; j \<le> k |] ==> i \<le> (k::real)" |
349 apply (cases i, cases j, cases k) |
344 apply (cases i, cases j, cases k) |
350 apply (simp add: real_le) |
345 apply (simp add: real_le) |
351 apply (blast intro: real_trans_lemma) |
346 apply (blast intro: real_trans_lemma) |
352 done |
347 done |
353 |
348 |
354 (* Axiom 'order_less_le' of class 'order': *) |
349 (* Axiom 'order_less_le' of class 'order': *) |
355 lemma real_less_le: "((w::real) < z) = (w \<le> z & w \<noteq> z)" |
350 lemma real_less_le: "((w::real) < z) = (w \<le> z & w \<noteq> z)" |
356 by (simp add: real_less_def) |
351 by (simp add: real_less_def) |
360 (assumption | |
355 (assumption | |
361 rule real_le_refl real_le_trans real_le_anti_sym real_less_le)+ |
356 rule real_le_refl real_le_trans real_le_anti_sym real_less_le)+ |
362 |
357 |
363 (* Axiom 'linorder_linear' of class 'linorder': *) |
358 (* Axiom 'linorder_linear' of class 'linorder': *) |
364 lemma real_le_linear: "(z::real) \<le> w | w \<le> z" |
359 lemma real_le_linear: "(z::real) \<le> w | w \<le> z" |
365 apply (cases z, cases w) |
360 apply (cases z, cases w) |
366 apply (auto simp add: real_le real_zero_def preal_add_ac preal_cancels) |
361 apply (auto simp add: real_le real_zero_def add_ac) |
367 done |
362 done |
368 |
363 |
369 |
364 |
370 instance real :: linorder |
365 instance real :: linorder |
371 by (intro_classes, rule real_le_linear) |
366 by (intro_classes, rule real_le_linear) |
372 |
367 |
373 |
368 |
374 lemma real_le_eq_diff: "(x \<le> y) = (x-y \<le> (0::real))" |
369 lemma real_le_eq_diff: "(x \<le> y) = (x-y \<le> (0::real))" |
375 apply (cases x, cases y) |
370 apply (cases x, cases y) |
376 apply (auto simp add: real_le real_zero_def real_diff_def real_add real_minus |
371 apply (auto simp add: real_le real_zero_def real_diff_def real_add real_minus |
377 preal_add_ac) |
372 add_ac) |
378 apply (simp_all add: preal_add_assoc [symmetric] preal_cancels) |
373 apply (simp_all add: add_assoc [symmetric]) |
379 done |
374 done |
380 |
375 |
381 lemma real_add_left_mono: |
376 lemma real_add_left_mono: |
382 assumes le: "x \<le> y" shows "z + x \<le> z + (y::real)" |
377 assumes le: "x \<le> y" shows "z + x \<le> z + (y::real)" |
383 proof - |
378 proof - |
398 apply (simp add: linorder_not_le [where 'a = real, symmetric] |
393 apply (simp add: linorder_not_le [where 'a = real, symmetric] |
399 linorder_not_le [where 'a = preal] |
394 linorder_not_le [where 'a = preal] |
400 real_zero_def real_le real_mult) |
395 real_zero_def real_le real_mult) |
401 --{*Reduce to the (simpler) @{text "\<le>"} relation *} |
396 --{*Reduce to the (simpler) @{text "\<le>"} relation *} |
402 apply (auto dest!: less_add_left_Ex |
397 apply (auto dest!: less_add_left_Ex |
403 simp add: preal_add_ac preal_mult_ac |
398 simp add: add_ac mult_ac |
404 preal_add_mult_distrib2 preal_cancels preal_self_less_add_left) |
399 right_distrib preal_self_less_add_left) |
405 done |
400 done |
406 |
401 |
407 lemma real_mult_less_mono2: "[| (0::real) < z; x < y |] ==> z * x < z * y" |
402 lemma real_mult_less_mono2: "[| (0::real) < z; x < y |] ==> z * x < z * y" |
408 apply (rule real_sum_gt_zero_less) |
403 apply (rule real_sum_gt_zero_less) |
409 apply (drule real_less_sum_gt_zero [of x y]) |
404 apply (drule real_less_sum_gt_zero [of x y]) |
431 to be essential for proving completeness of the reals from that of the |
426 to be essential for proving completeness of the reals from that of the |
432 positive reals.*} |
427 positive reals.*} |
433 |
428 |
434 lemma real_of_preal_add: |
429 lemma real_of_preal_add: |
435 "real_of_preal ((x::preal) + y) = real_of_preal x + real_of_preal y" |
430 "real_of_preal ((x::preal) + y) = real_of_preal x + real_of_preal y" |
436 by (simp add: real_of_preal_def real_add preal_add_mult_distrib preal_mult_1 |
431 by (simp add: real_of_preal_def real_add left_distrib add_ac) |
437 preal_add_ac) |
|
438 |
432 |
439 lemma real_of_preal_mult: |
433 lemma real_of_preal_mult: |
440 "real_of_preal ((x::preal) * y) = real_of_preal x* real_of_preal y" |
434 "real_of_preal ((x::preal) * y) = real_of_preal x* real_of_preal y" |
441 by (simp add: real_of_preal_def real_mult preal_add_mult_distrib2 |
435 by (simp add: real_of_preal_def real_mult right_distrib add_ac mult_ac) |
442 preal_mult_1 preal_mult_1_right preal_add_ac preal_mult_ac) |
|
443 |
436 |
444 |
437 |
445 text{*Gleason prop 9-4.4 p 127*} |
438 text{*Gleason prop 9-4.4 p 127*} |
446 lemma real_of_preal_trichotomy: |
439 lemma real_of_preal_trichotomy: |
447 "\<exists>m. (x::real) = real_of_preal m | x = 0 | x = -(real_of_preal m)" |
440 "\<exists>m. (x::real) = real_of_preal m | x = 0 | x = -(real_of_preal m)" |
448 apply (simp add: real_of_preal_def real_zero_def, cases x) |
441 apply (simp add: real_of_preal_def real_zero_def, cases x) |
449 apply (auto simp add: real_minus preal_add_ac) |
442 apply (auto simp add: real_minus add_ac) |
450 apply (cut_tac x = x and y = y in linorder_less_linear) |
443 apply (cut_tac x = x and y = y in linorder_less_linear) |
451 apply (auto dest!: less_add_left_Ex simp add: preal_add_assoc [symmetric]) |
444 apply (auto dest!: less_add_left_Ex simp add: add_assoc [symmetric]) |
452 done |
445 done |
453 |
446 |
454 lemma real_of_preal_leD: |
447 lemma real_of_preal_leD: |
455 "real_of_preal m1 \<le> real_of_preal m2 ==> m1 \<le> m2" |
448 "real_of_preal m1 \<le> real_of_preal m2 ==> m1 \<le> m2" |
456 by (simp add: real_of_preal_def real_le preal_cancels) |
449 by (simp add: real_of_preal_def real_le) |
457 |
450 |
458 lemma real_of_preal_lessI: "m1 < m2 ==> real_of_preal m1 < real_of_preal m2" |
451 lemma real_of_preal_lessI: "m1 < m2 ==> real_of_preal m1 < real_of_preal m2" |
459 by (auto simp add: real_of_preal_leD linorder_not_le [symmetric]) |
452 by (auto simp add: real_of_preal_leD linorder_not_le [symmetric]) |
460 |
453 |
461 lemma real_of_preal_lessD: |
454 lemma real_of_preal_lessD: |
462 "real_of_preal m1 < real_of_preal m2 ==> m1 < m2" |
455 "real_of_preal m1 < real_of_preal m2 ==> m1 < m2" |
463 by (simp add: real_of_preal_def real_le linorder_not_le [symmetric] |
456 by (simp add: real_of_preal_def real_le linorder_not_le [symmetric]) |
464 preal_cancels) |
|
465 |
|
466 |
457 |
467 lemma real_of_preal_less_iff [simp]: |
458 lemma real_of_preal_less_iff [simp]: |
468 "(real_of_preal m1 < real_of_preal m2) = (m1 < m2)" |
459 "(real_of_preal m1 < real_of_preal m2) = (m1 < m2)" |
469 by (blast intro: real_of_preal_lessI real_of_preal_lessD) |
460 by (blast intro: real_of_preal_lessI real_of_preal_lessD) |
470 |
461 |
471 lemma real_of_preal_le_iff: |
462 lemma real_of_preal_le_iff: |
472 "(real_of_preal m1 \<le> real_of_preal m2) = (m1 \<le> m2)" |
463 "(real_of_preal m1 \<le> real_of_preal m2) = (m1 \<le> m2)" |
473 by (simp add: linorder_not_less [symmetric]) |
464 by (simp add: linorder_not_less [symmetric]) |
474 |
465 |
475 lemma real_of_preal_zero_less: "0 < real_of_preal m" |
466 lemma real_of_preal_zero_less: "0 < real_of_preal m" |
476 apply (auto simp add: real_zero_def real_of_preal_def real_less_def real_le_def |
467 apply (insert preal_self_less_add_left [of 1 m]) |
477 preal_add_ac preal_cancels) |
468 apply (auto simp add: real_zero_def real_of_preal_def |
478 apply (simp_all add: preal_add_assoc [symmetric] preal_cancels) |
469 real_less_def real_le_def add_ac) |
479 apply (blast intro: preal_self_less_add_left order_less_imp_le) |
470 apply (rule_tac x="m + 1" in exI, rule_tac x="1" in exI) |
480 apply (insert preal_not_eq_self [of "preal_of_rat 1" m]) |
471 apply (simp add: add_ac) |
481 apply (simp add: preal_add_ac) |
|
482 done |
472 done |
483 |
473 |
484 lemma real_of_preal_minus_less_zero: "- real_of_preal m < 0" |
474 lemma real_of_preal_minus_less_zero: "- real_of_preal m < 0" |
485 by (simp add: real_of_preal_zero_less) |
475 by (simp add: real_of_preal_zero_less) |
486 |
476 |