6 Assorted facts that need binary literals and the arithmetic decision procedure |
6 Assorted facts that need binary literals and the arithmetic decision procedure |
7 |
7 |
8 Also, common factor cancellation |
8 Also, common factor cancellation |
9 *) |
9 *) |
10 |
10 |
|
11 (*****????????????????***VERY EARLY! (HOL itself)*********) |
|
12 Goal "(number_of w = x+y) = (x+y = number_of w)"; |
|
13 by Auto_tac; |
|
14 qed "number_of_add_reorient"; |
|
15 AddIffs [number_of_add_reorient]; |
|
16 |
|
17 Goal "(number_of w = x-y) = (x-y = number_of w)"; |
|
18 by Auto_tac; |
|
19 qed "number_of_diff_reorient"; |
|
20 AddIffs [number_of_diff_reorient]; |
|
21 |
|
22 Goal "(number_of w = x*y) = (x*y = number_of w)"; |
|
23 by Auto_tac; |
|
24 qed "number_of_mult_reorient"; |
|
25 AddIffs [number_of_mult_reorient]; |
|
26 |
|
27 Goal "(number_of w = x div y) = (x div y = number_of w)"; |
|
28 by Auto_tac; |
|
29 qed "number_of_div_reorient"; |
|
30 AddIffs [number_of_div_reorient]; |
|
31 |
|
32 Goal "(number_of w = x mod y) = (x mod y = number_of w)"; |
|
33 by Auto_tac; |
|
34 qed "number_of_mod_reorient"; |
|
35 AddIffs [number_of_mod_reorient]; |
|
36 |
|
37 Goal "(number_of w = x/y) = (x/y = number_of w)"; |
|
38 by Auto_tac; |
|
39 qed "number_of_divide_reorient"; |
|
40 AddIffs [number_of_divide_reorient]; |
|
41 |
|
42 |
11 (** Division and inverse **) |
43 (** Division and inverse **) |
|
44 |
|
45 Goal "#0/x = (#0::real)"; |
|
46 by (simp_tac (simpset() addsimps [real_divide_def]) 1); |
|
47 qed "real_0_divide"; |
|
48 Addsimps [real_0_divide]; |
12 |
49 |
13 Goal "((#0::real) < inverse x) = (#0 < x)"; |
50 Goal "((#0::real) < inverse x) = (#0 < x)"; |
14 by (case_tac "x=#0" 1); |
51 by (case_tac "x=#0" 1); |
15 by (asm_simp_tac (HOL_ss addsimps [rename_numerals INVERSE_ZERO]) 1); |
52 by (asm_simp_tac (HOL_ss addsimps [rename_numerals INVERSE_ZERO]) 1); |
16 by (auto_tac (claset() addDs [rename_numerals real_inverse_less_zero], |
53 by (auto_tac (claset() addDs [rename_numerals real_inverse_less_zero], |
61 Goal "(x::real)/#1 = x"; |
98 Goal "(x::real)/#1 = x"; |
62 by (simp_tac (simpset() addsimps [real_divide_def]) 1); |
99 by (simp_tac (simpset() addsimps [real_divide_def]) 1); |
63 qed "real_divide_1"; |
100 qed "real_divide_1"; |
64 Addsimps [real_divide_1]; |
101 Addsimps [real_divide_1]; |
65 |
102 |
|
103 Goal "(inverse(x::real) = #0) = (x = #0)"; |
|
104 by (auto_tac (claset(), simpset() addsimps [rename_numerals INVERSE_ZERO])); |
|
105 by (rtac ccontr 1); |
|
106 by (blast_tac (claset() addDs [rename_numerals real_inverse_not_zero]) 1); |
|
107 qed "real_inverse_zero_iff"; |
|
108 AddIffs [real_inverse_zero_iff]; |
|
109 |
|
110 Goal "(x/y = #0) = (x=#0 | y=(#0::real))"; |
|
111 by (auto_tac (claset(), simpset() addsimps [real_divide_def])); |
|
112 qed "real_divide_eq_0_iff"; |
|
113 AddIffs [real_divide_eq_0_iff]; |
|
114 |
66 |
115 |
67 (**** Factor cancellation theorems for "real" ****) |
116 (**** Factor cancellation theorems for "real" ****) |
68 |
117 |
69 (** Cancellation laws for k*m < k*n and m*k < n*k, also for <= and =, |
118 (** Cancellation laws for k*m < k*n and m*k < n*k, also for <= and =, |
70 but not (yet?) for k*m < n*k. **) |
119 but not (yet?) for k*m < n*k. **) |
72 bind_thm ("real_mult_minus_right", real_minus_mult_eq2 RS sym); |
121 bind_thm ("real_mult_minus_right", real_minus_mult_eq2 RS sym); |
73 |
122 |
74 Goal "(-y < -x) = ((x::real) < y)"; |
123 Goal "(-y < -x) = ((x::real) < y)"; |
75 by (arith_tac 1); |
124 by (arith_tac 1); |
76 qed "real_minus_less_minus"; |
125 qed "real_minus_less_minus"; |
|
126 Addsimps [real_minus_less_minus]; |
77 |
127 |
78 Goal "[| i<j; k < (0::real) |] ==> j*k < i*k"; |
128 Goal "[| i<j; k < (0::real) |] ==> j*k < i*k"; |
79 by (rtac (real_minus_less_minus RS iffD1) 1); |
129 by (rtac (real_minus_less_minus RS iffD1) 1); |
80 by (auto_tac (claset(), |
130 by (auto_tac (claset(), |
81 simpset() delsimps [real_minus_mult_eq2 RS sym] |
131 simpset() delsimps [real_minus_mult_eq2 RS sym] |
364 by (stac real_mult_eq_cancel2 1); |
414 by (stac real_mult_eq_cancel2 1); |
365 by (Asm_simp_tac 1); |
415 by (Asm_simp_tac 1); |
366 qed "real_divide_eq_eq"; |
416 qed "real_divide_eq_eq"; |
367 Addsimps [inst "z" "number_of ?w" real_divide_eq_eq]; |
417 Addsimps [inst "z" "number_of ?w" real_divide_eq_eq]; |
368 |
418 |
369 |
419 Goal "(m/k = n/k) = (k = #0 | m = (n::real))"; |
370 (** Moved from RealOrd.ML to use #0 **) |
420 by (case_tac "k=#0" 1); |
371 |
421 by (asm_simp_tac (simpset() addsimps [REAL_DIVIDE_ZERO]) 1); |
|
422 by (asm_simp_tac (simpset() addsimps [real_divide_eq_eq, real_eq_divide_eq, |
|
423 real_mult_eq_cancel2]) 1); |
|
424 qed "real_divide_eq_cancel2"; |
|
425 |
|
426 Goal "(k/m = k/n) = (k = #0 | m = (n::real))"; |
|
427 by (case_tac "m=#0 | n = #0" 1); |
|
428 by (auto_tac (claset(), |
|
429 simpset() addsimps [REAL_DIVIDE_ZERO, real_divide_eq_eq, |
|
430 real_eq_divide_eq, real_mult_eq_cancel1])); |
|
431 qed "real_divide_eq_cancel1"; |
|
432 |
|
433 (*Moved from RealOrd.ML to use #0 *) |
372 Goal "[| #0 < r; #0 < x|] ==> (inverse x < inverse (r::real)) = (r < x)"; |
434 Goal "[| #0 < r; #0 < x|] ==> (inverse x < inverse (r::real)) = (r < x)"; |
373 by (auto_tac (claset() addIs [real_inverse_less_swap], simpset())); |
435 by (auto_tac (claset() addIs [real_inverse_less_swap], simpset())); |
374 by (res_inst_tac [("t","r")] (real_inverse_inverse RS subst) 1); |
436 by (res_inst_tac [("t","r")] (real_inverse_inverse RS subst) 1); |
375 by (res_inst_tac [("t","x")] (real_inverse_inverse RS subst) 1); |
437 by (res_inst_tac [("t","x")] (real_inverse_inverse RS subst) 1); |
376 by (auto_tac (claset() addIs [real_inverse_less_swap], |
438 by (auto_tac (claset() addIs [real_inverse_less_swap], |
385 |
447 |
386 Goal "[| (#0::real) < d1; #0 < d2 |] ==> EX e. #0 < e & e < d1 & e < d2"; |
448 Goal "[| (#0::real) < d1; #0 < d2 |] ==> EX e. #0 < e & e < d1 & e < d2"; |
387 by (res_inst_tac [("x","(min d1 d2)/#2")] exI 1); |
449 by (res_inst_tac [("x","(min d1 d2)/#2")] exI 1); |
388 by (asm_simp_tac (simpset() addsimps [min_def]) 1); |
450 by (asm_simp_tac (simpset() addsimps [min_def]) 1); |
389 qed "real_lbound_gt_zero"; |
451 qed "real_lbound_gt_zero"; |
|
452 |
|
453 |
|
454 (*** General rewrites to improve automation, like those for type "int" ***) |
|
455 |
|
456 (** The next several equations can make the simplifier loop! **) |
|
457 |
|
458 Goal "(x < - y) = (y < - (x::real))"; |
|
459 by Auto_tac; |
|
460 qed "real_less_minus"; |
|
461 |
|
462 Goal "(- x < y) = (- y < (x::real))"; |
|
463 by Auto_tac; |
|
464 qed "real_minus_less"; |
|
465 |
|
466 Goal "(x <= - y) = (y <= - (x::real))"; |
|
467 by Auto_tac; |
|
468 qed "real_le_minus"; |
|
469 |
|
470 Goal "(- x <= y) = (- y <= (x::real))"; |
|
471 by Auto_tac; |
|
472 qed "real_minus_le"; |
|
473 |
|
474 Goal "(x = - y) = (y = - (x::real))"; |
|
475 by Auto_tac; |
|
476 qed "real_equation_minus"; |
|
477 |
|
478 Goal "(- x = y) = (- (y::real) = x)"; |
|
479 by Auto_tac; |
|
480 qed "real_minus_equation"; |
|
481 |
|
482 |
|
483 (*Distributive laws for literals*) |
|
484 Addsimps (map (inst "w" "number_of ?v") |
|
485 [real_add_mult_distrib, real_add_mult_distrib2, |
|
486 real_diff_mult_distrib, real_diff_mult_distrib2]); |
|
487 |
|
488 Addsimps (map (inst "x" "number_of ?v") |
|
489 [real_less_minus, real_le_minus, real_equation_minus]); |
|
490 Addsimps (map (inst "y" "number_of ?v") |
|
491 [real_minus_less, real_minus_le, real_minus_equation]); |
|
492 |
|
493 |
|
494 (*** Simprules combining x+y and #0 ***) |
|
495 |
|
496 Goal "(x+y = (#0::real)) = (y = -x)"; |
|
497 by Auto_tac; |
|
498 qed "real_add_eq_0_iff"; |
|
499 AddIffs [real_add_eq_0_iff]; |
|
500 |
|
501 (**?????????not needed with re-orientation |
|
502 Goal "((#0::real) = x+y) = (y = -x)"; |
|
503 by Auto_tac; |
|
504 qed "real_0_eq_add_iff"; |
|
505 AddIffs [real_0_eq_add_iff]; |
|
506 ????????*) |
|
507 |
|
508 Goal "(x+y < (#0::real)) = (y < -x)"; |
|
509 by Auto_tac; |
|
510 qed "real_add_less_0_iff"; |
|
511 AddIffs [real_add_less_0_iff]; |
|
512 |
|
513 Goal "((#0::real) < x+y) = (-x < y)"; |
|
514 by Auto_tac; |
|
515 qed "real_0_less_add_iff"; |
|
516 AddIffs [real_0_less_add_iff]; |
|
517 |
|
518 Goal "(x+y <= (#0::real)) = (y <= -x)"; |
|
519 by Auto_tac; |
|
520 qed "real_add_le_0_iff"; |
|
521 AddIffs [real_add_le_0_iff]; |
|
522 |
|
523 Goal "((#0::real) <= x+y) = (-x <= y)"; |
|
524 by Auto_tac; |
|
525 qed "real_0_le_add_iff"; |
|
526 AddIffs [real_0_le_add_iff]; |
|
527 |
|
528 |
|
529 (*** Simprules combining x-y and #0 ***) |
|
530 |
|
531 Goal "(x-y = (#0::real)) = (x = y)"; |
|
532 by Auto_tac; |
|
533 qed "real_diff_eq_0_iff"; |
|
534 AddIffs [real_diff_eq_0_iff]; |
|
535 |
|
536 Goal "((#0::real) = x-y) = (x = y)"; |
|
537 by Auto_tac; |
|
538 qed "real_0_eq_diff_iff"; |
|
539 AddIffs [real_0_eq_diff_iff]; |
|
540 |
|
541 Goal "(x-y < (#0::real)) = (x < y)"; |
|
542 by Auto_tac; |
|
543 qed "real_diff_less_0_iff"; |
|
544 AddIffs [real_diff_less_0_iff]; |
|
545 |
|
546 Goal "((#0::real) < x-y) = (y < x)"; |
|
547 by Auto_tac; |
|
548 qed "real_0_less_diff_iff"; |
|
549 AddIffs [real_0_less_diff_iff]; |
|
550 |
|
551 Goal "(x-y <= (#0::real)) = (x <= y)"; |
|
552 by Auto_tac; |
|
553 qed "real_diff_le_0_iff"; |
|
554 AddIffs [real_diff_le_0_iff]; |
|
555 |
|
556 Goal "((#0::real) <= x-y) = (y <= x)"; |
|
557 by Auto_tac; |
|
558 qed "real_0_le_diff_iff"; |
|
559 AddIffs [real_0_le_diff_iff]; |
|
560 |
|
561 (* |
|
562 ?? still needed ?? |
|
563 Addsimps [symmetric real_diff_def]; |
|
564 *) |
|
565 |
|
566 Goal "-(x-y) = y - (x::real)"; |
|
567 by (arith_tac 1); |
|
568 qed "real_minus_diff_eq"; |
|
569 Addsimps [real_minus_diff_eq]; |
|
570 |
|
571 |
|
572 (*** Density of the Reals ***) |
|
573 |
|
574 Goal "x < y ==> x < (x+y) / (#2::real)"; |
|
575 by Auto_tac; |
|
576 qed "real_less_half_sum"; |
|
577 |
|
578 Goal "x < y ==> (x+y)/(#2::real) < y"; |
|
579 by Auto_tac; |
|
580 qed "real_gt_half_sum"; |
|
581 |
|
582 Goal "x < y ==> EX r::real. x < r & r < y"; |
|
583 by (blast_tac (claset() addSIs [real_less_half_sum, real_gt_half_sum]) 1); |
|
584 qed "real_dense"; |
|
585 |
|
586 |
|
587 (*Replaces "inverse #nn" by #1/#nn *) |
|
588 Addsimps [inst "x" "number_of ?w" real_inverse_eq_divide]; |
|
589 |
|
590 |