31 "-------- fun is_polyexp -----------------------------------------------------------------------"; |
31 "-------- fun is_polyexp -----------------------------------------------------------------------"; |
32 "-------- fun is_polyexp -----------------------------------------------------------------------"; |
32 "-------- fun is_polyexp -----------------------------------------------------------------------"; |
33 val t = TermC.str2term "x / x"; |
33 val t = TermC.str2term "x / x"; |
34 if is_polyexp t then error "NOT is_polyexp (x / x)" else (); |
34 if is_polyexp t then error "NOT is_polyexp (x / x)" else (); |
35 |
35 |
36 val t = TermC.str2term "-1 * A * 3"; |
36 val t = TermC.str2term "- 1 * A * 3"; |
37 if is_polyexp t then () else error "is_polyexp (-1 * A * 3)"; |
37 if is_polyexp t then () else error "is_polyexp (- 1 * A * 3)"; |
38 |
38 |
39 val t = TermC.str2term "-1 * AA * 3"; |
39 val t = TermC.str2term "- 1 * AA * 3"; |
40 if is_polyexp t then () else error "is_polyexp (-1 * AA * 3)"; |
40 if is_polyexp t then () else error "is_polyexp (- 1 * AA * 3)"; |
41 |
41 |
42 val t = TermC.str2term "x * x + x * y + (- 1 * y * x + - 1 * y * y)::real"; |
42 val t = TermC.str2term "x * x + x * y + (- 1 * y * x + - 1 * y * y)::real"; |
43 if is_polyexp t then () else error "is_polyexp (x * x + x * y + (- 1 * y * x + - 1 * y * y))"; |
43 if is_polyexp t then () else error "is_polyexp (x * x + x * y + (- 1 * y * x + - 1 * y * y))"; |
44 |
44 |
45 "-------- fun has_degree_in --------------------------------------------------------------------"; |
45 "-------- fun has_degree_in --------------------------------------------------------------------"; |
447 val SOME (t', _) = rewrite_set_ thy true order_mult_ t; |
447 val SOME (t', _) = rewrite_set_ thy true order_mult_ t; |
448 if UnparseC.term t' = "x * x \<up> 2" then () |
448 if UnparseC.term t' = "x * x \<up> 2" then () |
449 else error "poly.sml Poly.is_multUnordered doesn't work"; |
449 else error "poly.sml Poly.is_multUnordered doesn't work"; |
450 |
450 |
451 (* 100928 Rewrite.trace_on shows the first occurring difference in 267b: |
451 (* 100928 Rewrite.trace_on shows the first occurring difference in 267b: |
452 ### rls: order_mult_ on: 5 * x \<up> 2 * (2 * x \<up> 7) + 5 * x \<up> 2 * 3 + (6 * x \<up> 7 + 9) + (-1 * (3 * x \<up> 5 * (6 * x \<up> 4)) + -1 * (3 * x \<up> 5 * -1) + |
452 ### rls: order_mult_ on: 5 * x \<up> 2 * (2 * x \<up> 7) + 5 * x \<up> 2 * 3 + (6 * x \<up> 7 + 9) + (- 1 * (3 * x \<up> 5 * (6 * x \<up> 4)) + - 1 * (3 * x \<up> 5 * - 1) + |
453 (-48 * x \<up> 4 + 8)) |
453 (-48 * x \<up> 4 + 8)) |
454 ###### rls: Rule_Set.empty-is_multUnordered on: p is_multUnordered |
454 ###### rls: Rule_Set.empty-is_multUnordered on: p is_multUnordered |
455 ####### try calc: Poly.is_multUnordered' |
455 ####### try calc: Poly.is_multUnordered' |
456 ======= calc. to: False !!!!!!!!!!!!! INSTEAD OF TRUE in 2002 !!!!!!!!!!!!! |
456 ======= calc. to: False !!!!!!!!!!!!! INSTEAD OF TRUE in 2002 !!!!!!!!!!!!! |
457 *) |
457 *) |
458 val t = TermC.str2term "5 * x \<up> 2 * (2 * x \<up> 7) + 5 * x \<up> 2 * 3 + (6 * x \<up> 7 + 9) + (-1 * (3 * x \<up> 5 * (6 * x \<up> 4)) + -1 * (3 * x \<up> 5 * -1) + (-48 * x \<up> 4 + 8))"; |
458 val t = TermC.str2term "5 * x \<up> 2 * (2 * x \<up> 7) + 5 * x \<up> 2 * 3 + (6 * x \<up> 7 + 9) + (- 1 * (3 * x \<up> 5 * (6 * x \<up> 4)) + - 1 * (3 * x \<up> 5 * - 1) + (-48 * x \<up> 4 + 8))"; |
459 |
459 |
460 "----- is_multUnordered ---"; |
460 "----- is_multUnordered ---"; |
461 val tsort = sort_variables t; |
461 val tsort = sort_variables t; |
462 UnparseC.term tsort = "2 * (5 * (x \<up> 2 * x \<up> 7)) + 3 * (5 * x \<up> 2) + 6 * x \<up> 7 + 9 +\n-1 * (3 * (6 * (x \<up> 4 * x \<up> 5))) +\n-1 * (-1 * (3 * x \<up> 5)) +\n-48 * x \<up> 4 +\n8"; |
462 UnparseC.term tsort = "2 * (5 * (x \<up> 2 * x \<up> 7)) + 3 * (5 * x \<up> 2) + 6 * x \<up> 7 + 9 +\n- 1 * (3 * (6 * (x \<up> 4 * x \<up> 5))) +\n- 1 * (- 1 * (3 * x \<up> 5)) +\n-48 * x \<up> 4 +\n8"; |
463 is_polyexp t; |
463 is_polyexp t; |
464 tsort = t; |
464 tsort = t; |
465 is_polyexp t andalso not (t = sort_variables t); |
465 is_polyexp t andalso not (t = sort_variables t); |
466 if is_multUnordered t then () else error "poly.sml diff. is_multUnordered 1"; |
466 if is_multUnordered t then () else error "poly.sml diff. is_multUnordered 1"; |
467 |
467 |
468 "----- eval_is_multUnordered ---"; |
468 "----- eval_is_multUnordered ---"; |
469 val tm = TermC.str2term "(5 * x \<up> 2 * (2 * x \<up> 7) + 5 * x \<up> 2 * 3 + (6 * x \<up> 7 + 9) + (-1 * (3 * x \<up> 5 * (6 * x \<up> 4)) + -1 * (3 * x \<up> 5 * -1) + (-48 * x \<up> 4 + 8))) is_multUnordered"; |
469 val tm = TermC.str2term "(5 * x \<up> 2 * (2 * x \<up> 7) + 5 * x \<up> 2 * 3 + (6 * x \<up> 7 + 9) + (- 1 * (3 * x \<up> 5 * (6 * x \<up> 4)) + - 1 * (3 * x \<up> 5 * - 1) + (-48 * x \<up> 4 + 8))) is_multUnordered"; |
470 case eval_is_multUnordered "testid" "" tm thy of |
470 case eval_is_multUnordered "testid" "" tm thy of |
471 SOME (_, Const ("HOL.Trueprop", _) $ |
471 SOME (_, Const ("HOL.Trueprop", _) $ |
472 (Const ("HOL.eq", _) $ |
472 (Const ("HOL.eq", _) $ |
473 (Const ("Poly.is_multUnordered", _) $ _) $ |
473 (Const ("Poly.is_multUnordered", _) $ _) $ |
474 Const ("HOL.True", _))) => () |
474 Const ("HOL.True", _))) => () |
493 SOME |
493 SOME |
494 ("xxx 3 * a + - 2 * a_", |
494 ("xxx 3 * a + - 2 * a_", |
495 Const ("HOL.Trueprop", _) $ (Const ("HOL.eq", _) $ _ $ |
495 Const ("HOL.Trueprop", _) $ (Const ("HOL.eq", _) $ _ $ |
496 Const ("HOL.False", _))) => () |
496 Const ("HOL.False", _))) => () |
497 (* Const ("HOL.True", _))) => () <<<<<--------------------------- this is false*) |
497 (* Const ("HOL.True", _))) => () <<<<<--------------------------- this is false*) |
498 | _ => error "eval_is_multUnordered 3 * a + -2 * a CHANGED"; |
498 | _ => error "eval_is_multUnordered 3 * a + - 2 * a CHANGED"; |
499 |
499 |
500 "----- is_multUnordered --- (- 2 * a) is_multUnordered = False"; |
500 "----- is_multUnordered --- (- 2 * a) is_multUnordered = False"; |
501 val t as (_ $ arg) = TermC.str2term "(- 2 * a) is_multUnordered"; |
501 val t as (_ $ arg) = TermC.str2term "(- 2 * a) is_multUnordered"; |
502 |
502 |
503 (*+*)if UnparseC.term (sort_variables arg) = "- 2 * a" andalso is_polyexp arg = true |
503 (*+*)if UnparseC.term (sort_variables arg) = "- 2 * a" andalso is_polyexp arg = true |
507 case eval_is_multUnordered "xxx " "yyy " t thy of |
507 case eval_is_multUnordered "xxx " "yyy " t thy of |
508 SOME |
508 SOME |
509 ("xxx - 2 * a_", |
509 ("xxx - 2 * a_", |
510 Const ("HOL.Trueprop", _) $ (Const ("HOL.eq", _) $ _ $ |
510 Const ("HOL.Trueprop", _) $ (Const ("HOL.eq", _) $ _ $ |
511 Const ("HOL.False", _))) => () |
511 Const ("HOL.False", _))) => () |
512 | _ => error "eval_is_multUnordered 3 * a + -2 * a CHANGED"; |
512 | _ => error "eval_is_multUnordered 3 * a + - 2 * a CHANGED"; |
513 |
513 |
514 "----- is_multUnordered --- (a) is_multUnordered = False"; |
514 "----- is_multUnordered --- (a) is_multUnordered = False"; |
515 val t as (_ $ arg) = TermC.str2term "(a) is_multUnordered"; |
515 val t as (_ $ arg) = TermC.str2term "(a) is_multUnordered"; |
516 |
516 |
517 (*+*)if UnparseC.term (sort_variables arg) = "a" andalso is_polyexp arg = true |
517 (*+*)if UnparseC.term (sort_variables arg) = "a" andalso is_polyexp arg = true |
521 case eval_is_multUnordered "xxx " "yyy " t thy of |
521 case eval_is_multUnordered "xxx " "yyy " t thy of |
522 SOME |
522 SOME |
523 ("xxx a_", |
523 ("xxx a_", |
524 Const ("HOL.Trueprop", _) $ (Const ("HOL.eq", _) $ _ $ |
524 Const ("HOL.Trueprop", _) $ (Const ("HOL.eq", _) $ _ $ |
525 Const ("HOL.False", _))) => () |
525 Const ("HOL.False", _))) => () |
526 | _ => error "eval_is_multUnordered 3 * a + -2 * a CHANGED"; |
526 | _ => error "eval_is_multUnordered 3 * a + - 2 * a CHANGED"; |
527 |
527 |
528 "----- is_multUnordered --- (- 2) is_multUnordered = False"; |
528 "----- is_multUnordered --- (- 2) is_multUnordered = False"; |
529 val t as (_ $ arg) = TermC.str2term "(- 2) is_multUnordered"; |
529 val t as (_ $ arg) = TermC.str2term "(- 2) is_multUnordered"; |
530 |
530 |
531 (*+*)if UnparseC.term (sort_variables arg) = "- 2" andalso is_polyexp arg = true |
531 (*+*)if UnparseC.term (sort_variables arg) = "- 2" andalso is_polyexp arg = true |
535 case eval_is_multUnordered "xxx " "yyy " t thy of |
535 case eval_is_multUnordered "xxx " "yyy " t thy of |
536 SOME |
536 SOME |
537 ("xxx - 2_", |
537 ("xxx - 2_", |
538 Const ("HOL.Trueprop", _) $ (Const ("HOL.eq", _) $ _ $ |
538 Const ("HOL.Trueprop", _) $ (Const ("HOL.eq", _) $ _ $ |
539 Const ("HOL.False", _))) => () |
539 Const ("HOL.False", _))) => () |
540 | _ => error "eval_is_multUnordered 3 * a + -2 * a CHANGED"; |
540 | _ => error "eval_is_multUnordered 3 * a + - 2 * a CHANGED"; |
541 |
541 |
542 |
542 |
543 "-------- fun is_multUnordered (x - a) \<up> 3 -----------------------------------------------------"; |
543 "-------- fun is_multUnordered (x - a) \<up> 3 -----------------------------------------------------"; |
544 "-------- fun is_multUnordered (x - a) \<up> 3 -----------------------------------------------------"; |
544 "-------- fun is_multUnordered (x - a) \<up> 3 -----------------------------------------------------"; |
545 "-------- fun is_multUnordered (x - a) \<up> 3 -----------------------------------------------------"; |
545 "-------- fun is_multUnordered (x - a) \<up> 3 -----------------------------------------------------"; |
552 x \<up> 3 + 3 * x \<up> 2 * (- 1 * a) + 3 * x * ((- 1) \<up> 2 * a \<up> 2) + (- 1) \<up> 3 * a \<up> 3 is_multUnordered |
552 x \<up> 3 + 3 * x \<up> 2 * (- 1 * a) + 3 * x * ((- 1) \<up> 2 * a \<up> 2) + (- 1) \<up> 3 * a \<up> 3 is_multUnordered |
553 ####### try calc: "Poly.is_multUnordered" |
553 ####### try calc: "Poly.is_multUnordered" |
554 ######## eval asms: |
554 ######## eval asms: |
555 N:x \<up> 3 + 3 * x \<up> 2 * (- 1 * a) + 3 * x * ((- 1) \<up> 2 * a \<up> 2) + (- 1) \<up> 3 * a \<up> 3 is_multUnordered = True" |
555 N:x \<up> 3 + 3 * x \<up> 2 * (- 1 * a) + 3 * x * ((- 1) \<up> 2 * a \<up> 2) + (- 1) \<up> 3 * a \<up> 3 is_multUnordered = True" |
556 -------------------------------------------------------------------------------------------------== |
556 -------------------------------------------------------------------------------------------------== |
557 O:x \<up> 3 + 3 * x \<up> 2 * (-1 * a) + 3 * x * (-1 \<up> 2 * a \<up> 2) + -1 \<up> 3 * a \<up> 3 is_multUnordered = True" |
557 O:x \<up> 3 + 3 * x \<up> 2 * (- 1 * a) + 3 * x * (- 1 \<up> 2 * a \<up> 2) + - 1 \<up> 3 * a \<up> 3 is_multUnordered = True" |
558 ####### calc. to: True |
558 ####### calc. to: True |
559 ####### try calc: "Poly.is_multUnordered" |
559 ####### try calc: "Poly.is_multUnordered" |
560 ####### try calc: "Poly.is_multUnordered" |
560 ####### try calc: "Poly.is_multUnordered" |
561 ### rls: order_mult_ on: |
561 ### rls: order_mult_ on: |
562 N:x \<up> 3 + - 1 * (3 * (a * x \<up> 2)) + 3 * (a \<up> 2 * (x * (- 1) \<up> 2)) + a \<up> 3 * (- 1) \<up> 3 |
562 N:x \<up> 3 + - 1 * (3 * (a * x \<up> 2)) + 3 * (a \<up> 2 * (x * (- 1) \<up> 2)) + a \<up> 3 * (- 1) \<up> 3 |
563 --------+--------------------------+---------------------------------+---------------------------<> |
563 --------+--------------------------+---------------------------------+---------------------------<> |
564 O:x \<up> 3 + -1 * (3 * (a * x \<up> 2)) + -1 \<up> 2 * (3 * (a \<up> 2 * x)) + -1 \<up> 3 * a \<up> 3 |
564 O:x \<up> 3 + - 1 * (3 * (a * x \<up> 2)) + - 1 \<up> 2 * (3 * (a \<up> 2 * x)) + - 1 \<up> 3 * a \<up> 3 |
565 -------------------------------------------------------------------------------------------------<> |
565 -------------------------------------------------------------------------------------------------<> |
566 *) |
566 *) |
567 val t = TermC.str2term "x \<up> 3 + 3 * x \<up> 2 * (- 1 * a) + 3 * x * ((- 1) \<up> 2 * a \<up> 2) + (- 1) \<up> 3 * a \<up> 3"; |
567 val t = TermC.str2term "x \<up> 3 + 3 * x \<up> 2 * (- 1 * a) + 3 * x * ((- 1) \<up> 2 * a \<up> 2) + (- 1) \<up> 3 * a \<up> 3"; |
568 (* |
568 (* |
569 "~~~~~ fun is_multUnordered |
569 "~~~~~ fun is_multUnordered |
723 |
723 |
724 |
724 |
725 "-------- complex examples from textbook Schalk I ----------------------------------------------"; |
725 "-------- complex examples from textbook Schalk I ----------------------------------------------"; |
726 "-------- complex examples from textbook Schalk I ----------------------------------------------"; |
726 "-------- complex examples from textbook Schalk I ----------------------------------------------"; |
727 "-------- complex examples from textbook Schalk I ----------------------------------------------"; |
727 "-------- complex examples from textbook Schalk I ----------------------------------------------"; |
728 val t = TermC.str2term "1 + 2 * x \<up> 4 + 2 * -2 * x \<up> 4 + x \<up> 8"; |
728 val t = TermC.str2term "1 + 2 * x \<up> 4 + 2 * - 2 * x \<up> 4 + x \<up> 8"; |
729 val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t; |
729 val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t; |
730 if (UnparseC.term t) = "1 + -2 * x \<up> 4 + x \<up> 8" |
730 if (UnparseC.term t) = "1 + - 2 * x \<up> 4 + x \<up> 8" |
731 then () else error "poly.sml: diff.behav. in make_polynomial 9b"; |
731 then () else error "poly.sml: diff.behav. in make_polynomial 9b"; |
732 |
732 |
733 "-----SPB Schalk I p.64 No.296a ---"; |
733 "-----SPB Schalk I p.64 No.296a ---"; |
734 val t = TermC.str2term "(x - a) \<up> 3"; |
734 val t = TermC.str2term "(x - a) \<up> 3"; |
735 val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t; |
735 val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t; |
736 if (UnparseC.term t) = "-1 * a \<up> 3 + 3 * a \<up> 2 * x + -3 * a * x \<up> 2 + x \<up> 3" |
736 if (UnparseC.term t) = "- 1 * a \<up> 3 + 3 * a \<up> 2 * x + - 3 * a * x \<up> 2 + x \<up> 3" |
737 then () else error "poly.sml: diff.behav. in make_polynomial 10"; |
737 then () else error "poly.sml: diff.behav. in make_polynomial 10"; |
738 |
738 |
739 "-----SPB Schalk I p.64 No.296c ---"; |
739 "-----SPB Schalk I p.64 No.296c ---"; |
740 val t = TermC.str2term "(-3*x - 4*y) \<up> 3"; |
740 val t = TermC.str2term "(-3*x - 4*y) \<up> 3"; |
741 val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t; |
741 val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t; |
742 if (UnparseC.term t) = "-27 * x \<up> 3 + -108 * x \<up> 2 * y + -144 * x * y \<up> 2 +\n-64 * y \<up> 3" |
742 if (UnparseC.term t) = "- 27 * x \<up> 3 + - 108 * x \<up> 2 * y + - 144 * x * y \<up> 2 +\n- 64 * y \<up> 3" |
743 then () else error "poly.sml: diff.behav. in make_polynomial 11"; |
743 then () else error "poly.sml: diff.behav. in make_polynomial 11"; |
744 |
744 |
745 "-----SPB Schalk I p.62 No.242c ---"; |
745 "-----SPB Schalk I p.62 No.242c ---"; |
746 val t = TermC.str2term "x \<up> (-4)*(x \<up> (-4)*y \<up> (-2)) \<up> (-1)*y \<up> (-2)"; |
746 val t = TermC.str2term "x \<up> (- 4)*(x \<up> (- 4)*y \<up> (- 2)) \<up> (- 1)*y \<up> (- 2)"; |
747 val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t; |
747 val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t; |
748 if (UnparseC.term t) = "1" |
748 if (UnparseC.term t) = "1" |
749 then () else error "poly.sml: diff.behav. in make_polynomial 12"; |
749 then () else error "poly.sml: diff.behav. in make_polynomial 12"; |
750 |
750 |
751 "-----SPB Schalk I p.60 No.209a ---"; |
751 "-----SPB Schalk I p.60 No.209a ---"; |
763 |
763 |
764 "-------- complex Eigene Beispiele (Mathias Goldgruber) ----------------------------------------"; |
764 "-------- complex Eigene Beispiele (Mathias Goldgruber) ----------------------------------------"; |
765 "-------- complex Eigene Beispiele (Mathias Goldgruber) ----------------------------------------"; |
765 "-------- complex Eigene Beispiele (Mathias Goldgruber) ----------------------------------------"; |
766 "-------- complex Eigene Beispiele (Mathias Goldgruber) ----------------------------------------"; |
766 "-------- complex Eigene Beispiele (Mathias Goldgruber) ----------------------------------------"; |
767 "-----SPO ---"; |
767 "-----SPO ---"; |
768 val t = TermC.str2term "a \<up> 2*a \<up> (-2)"; |
768 val t = TermC.str2term "a \<up> 2*a \<up> (- 2)"; |
769 val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t; |
769 val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t; |
770 if UnparseC.term t = "1" then () |
770 if UnparseC.term t = "1" then () |
771 else error "poly.sml: diff.behav. in make_polynomial 15"; |
771 else error "poly.sml: diff.behav. in make_polynomial 15"; |
772 |
772 |
773 "-----SPO ---"; |
773 "-----SPO ---"; |
774 val t = TermC.str2term "a \<up> 2*b*b \<up> (-1)"; |
774 val t = TermC.str2term "a \<up> 2*b*b \<up> (- 1)"; |
775 val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t; |
775 val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t; |
776 if UnparseC.term t = "a \<up> 2" then () |
776 if UnparseC.term t = "a \<up> 2" then () |
777 else error "poly.sml: diff.behav. in make_polynomial 18"; |
777 else error "poly.sml: diff.behav. in make_polynomial 18"; |
778 "-----SPO ---"; |
778 "-----SPO ---"; |
779 val t = TermC.str2term "a \<up> 2*a \<up> (-2)"; |
779 val t = TermC.str2term "a \<up> 2*a \<up> (- 2)"; |
780 val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t; |
780 val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t; |
781 if (UnparseC.term t) = "1" then () |
781 if (UnparseC.term t) = "1" then () |
782 else error "poly.sml: diff.behav. in make_polynomial 19"; |
782 else error "poly.sml: diff.behav. in make_polynomial 19"; |
783 "-----SPO ---"; |
783 "-----SPO ---"; |
784 val t = TermC.str2term "b + a - b"; |
784 val t = TermC.str2term "b + a - b"; |