810 |
867 |
811 (*SRAM Schalk I, p.92 Nr. 476a*) |
868 (*SRAM Schalk I, p.92 Nr. 476a*) |
812 val t = str2term "(x^^^2/(1 - x^^^2) + 1)/(x/(1 - x) + 1) * (1 + x)"; |
869 val t = str2term "(x^^^2/(1 - x^^^2) + 1)/(x/(1 - x) + 1) * (1 + x)"; |
813 (*. a/b : c/d translated to a/b * d/c .*) |
870 (*. a/b : c/d translated to a/b * d/c .*) |
814 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t'; |
871 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t'; |
815 (*if term2str t' = "1 / 1" then () else error "rational.sml 8";3.6.03*) |
|
816 if term2str t' = "1" then () else error "rational.sml 8"; |
872 if term2str t' = "1" then () else error "rational.sml 8"; |
817 |
873 |
818 (*............................vvv---TODO: sollte gehen mit poly_order *) |
|
819 (*Schalk I, p.92 Nr. 472a*) |
874 (*Schalk I, p.92 Nr. 472a*) |
820 val t = str2term "((8*x^^^2 - 32*y^^^2)/(2*x + 4*y))/((4*x - 8*y)/(x + y))"; |
875 val t = str2term "((8*x^^^2 - 32*y^^^2)/(2*x + 4*y))/((4*x - 8*y)/(x + y))"; |
821 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t'; |
876 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t'; |
822 if term2str t' = "x + y" then () else error "rational.sml p.92 Nr. 472a"; |
877 if term2str t' = "x + y" then () else error "rational.sml p.92 Nr. 472a"; |
823 |
878 |
824 (*Schalk I, p.70 Nr. 480b; a/b : c/d translated to a/b * d/c*) |
879 (*Schalk I, p.70 Nr. 480b: SEE rational.sml --- nonterminating rls norm_Rational ---*) |
825 val t = str2term ("((12*x*y/(9*x^^^2 - y^^^2))/" ^ |
880 |
826 "(1/(3*x - y)^^^2 - 1/(3*x + y)^^^2)) *" ^ |
881 (*WN130910 add_fractions_p exception Div raised + history: |
827 "(1/(x - 5*y)^^^2 - 1/(x + 5*y)^^^2)/" ^ |
882 ### WN.2.6.03 from rlang.sml 56a |
828 "(20*x*y/(x^^^2 - 25*y^^^2))"); |
|
829 (*... nicht simpl, zerlegt ...*) |
|
830 val t = str2term ("((12*x*y/(9*x^^^2 - y^^^2))/" ^ |
|
831 "(1/(3*x - y)^^^2 - 1/(3*x + y)^^^2))"); |
|
832 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t'; |
|
833 "(-12 * (x * y ^^^ 3) + 108 * (x * (y * x ^^^ 2))) / (12 * (x * y))"; |
|
834 (* ~~~~~~~~~~ poly_order notwendig!*) |
|
835 val t = str2term ("(1/(x - 5*y)^^^2 - 1/(x + 5*y)^^^2)/" ^ |
|
836 "(20*x*y/(x^^^2 - 25*y^^^2))"); |
|
837 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t'; |
|
838 if term2str t' = "1 / (x ^^^ 2 + -25 * y ^^^ 2)" then () |
|
839 else error "rational.sml norm_Rational 1 / (x ^^^ 2 + -25 * y ^^^ 2)"; |
|
840 |
|
841 "nonterm.SK6 ----- SK060904-2a non-termination of add_fraction_p_"; |
|
842 (*WN.2.6.03 from rlang.sml 56a |
|
843 val t = str2term "(a + b * x) / (a + -1 * (b * x)) + (-1 * a + b * x) / (a + b * x) = 4 * (a * b) / (a ^^^ 2 + -1 * b ^^^ 2)"; |
883 val t = str2term "(a + b * x) / (a + -1 * (b * x)) + (-1 * a + b * x) / (a + b * x) = 4 * (a * b) / (a ^^^ 2 + -1 * b ^^^ 2)"; |
844 val NONE = rewrite_set_ thy false common_nominator_p t; |
884 val NONE = rewrite_set_ thy false add_fractions_p t; |
845 |
885 |
846 WN060831 nonterm.SK7 |
886 THE ERROR ALREADY OCCURS IN THIS PART: |
847 val t = str2term "(a + b * x) / (a + -1 * (b * x)) + (-1 * a + b * x) / (a + b * x)"; |
887 val t = str2term "(a + b * x) / (a + -1 * (b * x)) + (-1 * a + b * x) / (a + b * x)"; |
848 val NONE = add_fraction_p_ thy t; |
888 val NONE = add_fraction_p_ thy t; |
849 *) |
889 |
850 |
890 SEE Test_Some.thy: section {* add_fractions_p downto exception Div raised === |
851 |
891 *) |
852 (* ------------------------------------------------------------------- *) |
892 |
853 (*---------vvv------------ MG: ab 1.7.03 ----------------vvv-----------*) |
893 "-------- rational numerals --------------------------------------------------"; |
854 (* Simplifier fuer beliebige Buchterme *) |
894 "-------- rational numerals --------------------------------------------------"; |
855 (* ------------------------------------------------------------------- *) |
895 "-------- rational numerals --------------------------------------------------"; |
856 (*----------------------- norm_Rational_mg ----------------------------*) |
|
857 (* ------------------------------------------------------------------- *) |
|
858 |
|
859 "-------- numeral rationals -----------------------------"; |
|
860 "-------- numeral rationals -----------------------------"; |
|
861 "-------- numeral rationals -----------------------------"; |
|
862 (*SRA Schalk I, p.40 Nr. 164b *) |
896 (*SRA Schalk I, p.40 Nr. 164b *) |
863 val t = str2term "(47/6 - 76/9 + 13/4)/(35/12)"; |
897 val t = str2term "(47/6 - 76/9 + 13/4)/(35/12)"; |
864 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t; |
898 val SOME (t, _) = rewrite_set_ thy false norm_Rational t; |
865 term2str t; |
899 term2str t; |
866 if (term2str t) = "19 / 21" then () |
900 if term2str t = "19 / 21" then () |
867 else error "rational.sml: diff.behav. in norm_Rational_mg 1"; |
901 else error "rational.sml: diff.behav. in norm_Rational_mg 1"; |
868 |
902 |
869 (*SRA Schalk I, p.40 Nr. 166a *) |
903 (*SRA Schalk I, p.40 Nr. 166a *) |
870 val t = str2term "((5/4)/(4+22/7) + 37/20)*(110/3 - 110/9 * 23/11)"; |
904 val t = str2term "((5/4)/(4+22/7) + 37/20)*(110/3 - 110/9 * 23/11)"; |
871 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t; |
905 val SOME (t, _) = rewrite_set_ thy false norm_Rational t; |
872 term2str t; |
906 term2str t; |
873 if (term2str t) = "45 / 2" then () |
907 if term2str t = "45 / 2" then () |
874 else error "rational.sml: diff.behav. in norm_Rational_mg 2"; |
908 else error "rational.sml: diff.behav. in norm_Rational_mg 2"; |
875 |
909 |
876 |
910 "-------- examples cancellation from: Mathematik 1 Schalk --------------------"; |
877 "-------- cancellation ----------------------------------"; |
911 "-------- examples cancellation from: Mathematik 1 Schalk --------------------"; |
878 "-------- cancellation ----------------------------------"; |
912 "-------- examples cancellation from: Mathematik 1 Schalk --------------------"; |
879 "-------- cancellation ----------------------------------"; |
|
880 (* e190c Stefan K.*) |
913 (* e190c Stefan K.*) |
881 val t = str2term |
914 val t = str2term "((1 + 9*a^^^2) * (1 + 3*a)) / ((3*a + 9*a^^^2) * (1 + 3*a))"; |
882 "((1 + 9 * a ^^^ 2)*(1 + 3 * a))/((3 * a + 9 * a ^^^ 2)*(1 + 3 * a))"; |
915 val SOME (t, _) = rewrite_set_ thy false norm_Rational t; |
883 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t; |
916 if term2str t = "(1 + 9 * a ^^^ 2) / (3 * a + 9 * a ^^^ 2)" |
|
917 then () else error "rational.sml: diff.behav. in norm_Rational_mg 3"; |
|
918 |
|
919 (* e192b Stefan K.*) |
|
920 val t = str2term "(x^^^2 * (7*x + (-1)*y)) / (y^^^2 * (7*x + (-1)*y))"; |
|
921 val SOME (t, _) = rewrite_set_ thy false norm_Rational t; |
|
922 if term2str t = "x ^^^ 2 / y ^^^ 2" |
|
923 then () else error "rational.sml: diff.behav. in norm_Rational_mg 4"; |
|
924 |
|
925 (*SRC Schalk I, p.66 Nr. 379c *) |
|
926 val t = str2term "(a - b)/(b - a)"; |
|
927 val SOME (t, _) = rewrite_set_ thy false norm_Rational t; |
884 term2str t; |
928 term2str t; |
885 if (term2str t) = |
929 if term2str t = "-1" |
886 "(1 + 9 * a ^^^ 2) / (3 * a + 9 * a ^^^ 2)" |
930 then () else error "rational.sml: diff.behav. in norm_Rational_mg 5"; |
887 then () |
|
888 else error "rational.sml: diff.behav. in norm_Rational_mg 3"; |
|
889 |
|
890 (* e192b Stefan K.*) |
|
891 val t = str2term |
|
892 "((x ^^^ 2)*(7 * x + (-1) * y))/((y ^^^ 2)*(7 * x + (-1) * y))"; |
|
893 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t; |
|
894 term2str t; |
|
895 if (term2str t) = |
|
896 "x ^^^ 2 / y ^^^ 2" |
|
897 then () |
|
898 else error "rational.sml: diff.behav. in norm_Rational_mg 4"; |
|
899 |
|
900 (*SRC Schalk I, p.66 Nr. 379c *) |
|
901 val t = str2term |
|
902 "(a - b)/(b - a)"; |
|
903 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t; |
|
904 term2str t; |
|
905 if (term2str t) = |
|
906 "-1" |
|
907 then () |
|
908 else error "rational.sml: diff.behav. in norm_Rational_mg 5"; |
|
909 |
931 |
910 (*SRC Schalk I, p.66 Nr. 380b *) |
932 (*SRC Schalk I, p.66 Nr. 380b *) |
911 val t = str2term |
933 val t = str2term "15*(3*x + 3) * (4*x + 9) / (12*(2*x + 7) * (5*x + 5))"; |
912 "15*(3*x+3)*(4*x+9)/(12*(2*x+7)*(5*x+5))"; |
934 val SOME (t, _) = rewrite_set_ thy false norm_Rational t; |
913 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t; |
935 if term2str t = "(27 + 12 * x) / (28 + 8 * x)" |
914 term2str t; |
936 then () else error "rational.sml: diff.behav. in norm_Rational_mg 6"; |
915 if (term2str t) = |
937 |
916 "(27 + 12 * x) / (28 + 8 * x)" |
938 (*Schalk I, p.60 Nr. 215c: was not cancelled with Isabelle2002 *) |
917 then () |
939 val t = str2term "(a + b)^^^4 * (x - y) / ((x - y)^^^3 * (a + b)^^^2)"; |
918 else error "rational.sml: diff.behav. in norm_Rational_mg 6"; |
940 val SOME (t, _) = rewrite_set_ thy false norm_Rational t; |
919 |
941 if term2str t = "(a ^^^ 2 + 2 * a * b + b ^^^ 2) / (x ^^^ 2 + -2 * x * y + y ^^^ 2)" |
920 (*Schalk I, p.60 Nr. 215c *) |
942 then () else error "rational.sml: diff.behav. in norm_Rational_mg 7"; |
921 (* Falsches Ergebnis: rechnet lange und cancel_p kann nicht weiter krzen!!!*) |
|
922 (* WN060831????MG1 |
|
923 val t = str2term "(a+b)^^^4*(x - y)/((x - y)^^^3*(a+b)^^^2)"; |
|
924 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t; |
|
925 term2str t; |
|
926 if (term2str t) = |
|
927 "(a ^^^ 4 * x + -1 * a ^^^ 4 * y + 4 * a ^^^ 3 * b * x + -4 * a ^^^ 3 * b * y + 6 * a ^^^ 2 * b ^^^ 2 * x + -6 * a ^^^ 2 * b ^^^ 2 * y + 4 * a * b ^^^ 3 * x + -4 * a * b ^^^ 3 * y + b ^^^ 4 * x + -1 * b ^^^ 4 * y) /(a ^^^ 2 * x ^^^ 3 + -3 * a ^^^ 2 * x ^^^ 2 * y + 3 * a ^^^ 2 * x * y ^^^ 2 + -1 * a ^^^ 2 * y ^^^ 3 + 2 * a * b * x ^^^ 3 + -6 * a * b * x ^^^ 2 * y + 6 * a * b * x * y ^^^ 2 + -2 * a * b * y ^^^ 3 + b ^^^ 2 * x ^^^ 3 + -3 * b ^^^ 2 * x ^^^ 2 * y + 3 * b ^^^ 2 * x * y ^^^ 2 + -1 * b ^^^ 2 * y ^^^ 3)" |
|
928 then () |
|
929 else error "rational.sml: diff.behav. in norm_Rational_mg 7"; |
|
930 *) |
|
931 (*val t = str2term |
|
932 "(a ^^^ 4 * x + -1 * a ^^^ 4 * y + 4 * a ^^^ 3 * b * x + -4 * a ^^^ 3 * b * y + 6 * a ^^^ 2 * b ^^^ 2 * x + -6 * a ^^^ 2 * b ^^^ 2 * y + 4 * a * b ^^^ 3 * x + -4 * a * b ^^^ 3 * y + b ^^^ 4 * x + -1 * b ^^^ 4 * y) /(a ^^^ 2 * x ^^^ 3 + -3 * a ^^^ 2 * x ^^^ 2 * y + 3 * a ^^^ 2 * x * y ^^^ 2 + -1 * a ^^^ 2 * y ^^^ 3 + 2 * a * b * x ^^^ 3 + -6 * a * b * x ^^^ 2 * y + 6 * a * b * x * y ^^^ 2 + -2 * a * b * y ^^^ 3 + b ^^^ 2 * x ^^^ 3 + -3 * b ^^^ 2 * x ^^^ 2 * y + 3 * b ^^^ 2 * x * y ^^^ 2 + -1 * b ^^^ 2 * y ^^^ 3)" |
|
933 val SOME (t,_) = rewrite_set_ thy false cancel_p t; |
|
934 term2str t;*) |
|
935 (* uncaught exception nonexhaustive binding failure |
|
936 raised at: stdIn:93.1-93.51 *) |
|
937 |
|
938 (*Schalk I, p.66 Nr. 381a *) |
|
939 (* ACHTUNG: rechnet ca. 2 Minuten !!! *) |
|
940 (* WN060831???MG2 |
|
941 val t = str2term "18*(a+b)^^^3*(a - b)^^^2/(72*(a - b)^^^3*(a+b)^^^2)"; |
|
942 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t; |
|
943 term2str t; |
|
944 if (term2str t) = |
|
945 "(a + b) / (4 * a + -4 * b)" |
|
946 then () else error "rational.sml: diff.behav. in norm_Rational_mg 8"; |
|
947 *) |
|
948 |
943 |
949 (*SRC Schalk I, p.66 Nr. 381b *) |
944 (*SRC Schalk I, p.66 Nr. 381b *) |
950 val t = str2term |
945 val t = str2term |
951 "(4*x^^^2 - 20*x + 25)/(2*x - 5)^^^3"; |
946 "(4*x^^^2 - 20*x + 25)/(2*x - 5)^^^3"; |
952 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t; |
947 val SOME (t, _) = rewrite_set_ thy false norm_Rational t; |
953 term2str t; |
948 if term2str t = "1 / (-5 + 2 * x)" |
954 if (term2str t) = |
949 then () else error "rational.sml: diff.behav. in norm_Rational_mg 9"; |
955 "-1 / (5 + -2 * x)" |
950 |
956 then () |
951 (* e190c Stefan K.*) |
957 else error "rational.sml: diff.behav. in norm_Rational_mg 9"; |
952 val t = str2term "((1 + 9*a^^^2) * (1 + 3*a)) / ((3*a + 9*a^^^2) * (1 + 3 * a))"; |
|
953 val SOME (t, _) = rewrite_set_ thy false norm_Rational t; |
|
954 if term2str t = "(1 + 9 * a ^^^ 2) / (3 * a + 9 * a ^^^ 2)" |
|
955 then () else error "rational.sml: diff.behav. in norm_Rational_mg 3"; |
|
956 |
|
957 (* e192b Stefan K.*) |
|
958 val t = str2term "(x^^^2 * (7*x + (-1)*y)) / (y^^^2 * (7*x + (-1)*y))"; |
|
959 val SOME (t, _) = rewrite_set_ thy false norm_Rational t; |
|
960 if term2str t = "x ^^^ 2 / y ^^^ 2" |
|
961 then () else error "rational.sml: diff.behav. in norm_Rational_mg 4"; |
|
962 |
|
963 (*SRC Schalk I, p.66 Nr. 379c *) |
|
964 val t = str2term "(a - b) / (b - a)"; |
|
965 val SOME (t, _) = rewrite_set_ thy false norm_Rational t; |
|
966 if term2str t = "-1" |
|
967 then () else error "rational.sml: diff.behav. in norm_Rational_mg 5"; |
|
968 |
|
969 (*SRC Schalk I, p.66 Nr. 380b *) |
|
970 val t = str2term "15*(3*x + 3) * (4*x + 9) / (12*(2*x + 7) * (5*x + 5))"; |
|
971 val SOME (t, _) = rewrite_set_ thy false norm_Rational t; |
|
972 if term2str t = "(27 + 12 * x) / (28 + 8 * x)" |
|
973 then () else error "rational.sml: diff.behav. in norm_Rational_mg 6"; |
|
974 |
|
975 (*Schalk I, p.60 Nr. 215c *) |
|
976 val t = str2term "(a + b)^^^4 * (x - y) / ((x - y)^^^3 * (a + b)^^^2)"; |
|
977 val SOME (t, _) = rewrite_set_ thy false norm_Rational t; |
|
978 if term2str t = "(a ^^^ 2 + 2 * a * b + b ^^^ 2) / (x ^^^ 2 + -2 * x * y + y ^^^ 2)" |
|
979 then () else error "Schalk I, p.60 Nr. 215c: with Isabelle2002 cancellation incomplete, changed"; |
|
980 |
|
981 (* extreme example from somewhere *) |
|
982 val t = str2term |
|
983 ("(a^^^4 * x + -1*a^^^4 * y + 4*a^^^3 * b * x + -4*a^^^3 * b * y + " ^ |
|
984 "6*a^^^2 * b^^^2 * x + -6*a^^^2 * b^^^2 * y + 4*a * b^^^3 * x + -4*a * b^^^3 * y + " ^ |
|
985 "b^^^4 * x + -1*b^^^4 * y) " ^ |
|
986 " / (a^^^2 * x^^^3 + -3*a^^^2 * x^^^2 * y + 3*a^^^2 * x * y^^^2 + -1*a^^^2 * y^^^3 + " ^ |
|
987 "2*a * b * x^^^3 + -6*a * b * x^^^2 * y + 6*a * b * x * y^^^2 + -2*a * b * y^^^3 + " ^ |
|
988 "b^^^2 * x^^^3 + -3*b^^^2 * x^^^2 * y + 3*b^^^2 * x * y^^^2 + -1*b ^^^ 2 * y ^^^ 3)") |
|
989 val SOME (t, _) = rewrite_set_ thy false cancel_p t; |
|
990 if term2str t = "(a ^^^ 2 + 2 * a * b + b ^^^ 2) / (x ^^^ 2 + -2 * x * y + y ^^^ 2)" |
|
991 then () else error "with Isabelle2002: NONE -- now SOME changed"; |
|
992 |
|
993 (*Schalk I, p.66 Nr. 381a *) |
|
994 (* ATTENTION: here the rls is very slow. In Isabelle2002 this required 2 min *) |
|
995 val t = str2term "18*(a + b)^^^3 * (a - b)^^^2 / (72*(a - b)^^^3 * (a + b)^^^2)"; |
|
996 val SOME (t, _) = rewrite_set_ thy false norm_Rational t; |
|
997 if term2str t = "(a + b) / (4 * a + -4 * b)" |
|
998 then () else error "rational.sml: diff.behav. in norm_Rational_mg 8"; |
|
999 |
|
1000 (*SRC Schalk I, p.66 Nr. 381b *) |
|
1001 val t = str2term "(4*x^^^2 - 20*x + 25) / (2*x - 5)^^^3"; |
|
1002 val SOME (t, _) = rewrite_set_ thy false norm_Rational t; |
|
1003 if term2str t = "1 / (-5 + 2 * x)" |
|
1004 then () else error "rational.sml: diff.behav. in norm_Rational_mg 9"; |
958 |
1005 |
959 (*SRC Schalk I, p.66 Nr. 381c *) |
1006 (*SRC Schalk I, p.66 Nr. 381c *) |
960 val t = str2term |
1007 val t = str2term "(27*a^^^3 + 9*a^^^2+3*a+1) / (27*a^^^3 + 18*a^^^2+3*a)"; |
961 "(27*a^^^3+9*a^^^2+3*a+1)/(27*a^^^3+18*a^^^2+3*a)"; |
1008 val SOME (t, _) = rewrite_set_ thy false norm_Rational t; |
962 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t; |
1009 if term2str t = "(1 + 9 * a ^^^ 2) / (3 * a + 9 * a ^^^ 2)" |
963 term2str t; |
1010 then () else error "rational.sml: diff.behav. in norm_Rational_mg 10"; |
964 if (term2str t) = |
|
965 "(1 + 9 * a ^^^ 2) / (3 * a + 9 * a ^^^ 2)" |
|
966 then () |
|
967 else error "rational.sml: diff.behav. in norm_Rational_mg 10"; |
|
968 |
1011 |
969 (*SRC Schalk I, p.66 Nr. 383a *) |
1012 (*SRC Schalk I, p.66 Nr. 383a *) |
970 val t = str2term |
1013 val t = str2term "(5*a^^^2 - 5*a*b) / (a - b)^^^2"; |
971 "(5*a^^^2 - 5*a*b)/(a - b)^^^2"; |
1014 val SOME (t, _) = rewrite_set_ thy false norm_Rational t; |
972 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t; |
1015 if term2str t = "-5 * a / (-1 * a + b)" |
973 term2str t; |
1016 then () else error "rational.sml: diff.behav. in norm_Rational_mg 11"; |
974 if (term2str t) = |
1017 |
975 "5 * a / (a + -1 * b)" |
1018 "----- NOT TERMINATING ?: worked before 0707xx"; |
976 then () |
1019 val t = str2term "(a^^^2 - 1)*(b + 1) / ((b^^^2 - 1)*(a+1))"; |
977 else error "rational.sml: diff.behav. in norm_Rational_mg 11"; |
1020 (* WN130911 "exception Div raised" by |
978 |
1021 cancel_p_ thy (str2term ("(-1 + -1 * b + a ^^^ 2 + a ^^^ 2 * b) /" ^ |
979 |
1022 "(-1 + -1 * a + b ^^^ 2 + a * b ^^^ 2)")) |
980 "-------- common denominator ----------------------------"; |
1023 |
981 "-------- common denominator ----------------------------"; |
1024 val SOME (t, _) = rewrite_set_ thy false norm_Rational t; |
982 "-------- common denominator ----------------------------"; |
1025 if term2str t = "(1 + -1 * a) / (1 + -1 * b)" then () |
|
1026 else error "rational.sml MG tests 3e"; |
|
1027 *) |
|
1028 |
|
1029 "-------- examples common denominator from: Mathematik 1 Schalk --------------"; |
|
1030 "-------- examples common denominator from: Mathematik 1 Schalk --------------"; |
|
1031 "-------- examples common denominator from: Mathematik 1 Schalk --------------"; |
983 (*SRA Schalk I, p.67 Nr. 403a *) |
1032 (*SRA Schalk I, p.67 Nr. 403a *) |
984 val t = str2term |
1033 val t = str2term "4/x - 3/y - 1"; |
985 "4/x - 3/y - 1"; |
1034 val SOME (t, _) = rewrite_set_ thy false norm_Rational t; |
986 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t; |
1035 if term2str t = "(-3 * x + 4 * y + -1 * x * y) / (x * y)" |
987 term2str t; |
1036 then () else error "rational.sml: diff.behav. in norm_Rational_mg 12"; |
988 if (term2str t) = |
1037 |
989 "(-3 * x + 4 * y + -1 * x * y) / (x * y)" |
1038 val t = str2term "(2*a+3*b)/(b*c) + (3*c+a)/(a*c) - (2*a^^^2+3*b*c)/(a*b*c)"; |
990 then () |
1039 val SOME (t, _) = rewrite_set_ thy false norm_Rational t; |
991 else error "rational.sml: diff.behav. in norm_Rational_mg 12"; |
1040 if term2str t = "4 / c" |
992 |
1041 then () else error "rational.sml: diff.behav. in norm_Rational_mg 13"; |
993 (*SRA Schalk I, p.67 Nr. 407b *) |
|
994 val t = str2term |
|
995 "(2*a+3*b)/(b*c) + (3*c+a)/(a*c) - (2*a^^^2+3*b*c)/(a*b*c)"; |
|
996 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t; |
|
997 term2str t; |
|
998 if (term2str t) = |
|
999 "4 / c" |
|
1000 then () |
|
1001 else error "rational.sml: diff.behav. in norm_Rational_mg 13"; |
|
1002 |
1042 |
1003 (*SRA Schalk I, p.67 Nr. 410b *) |
1043 (*SRA Schalk I, p.67 Nr. 410b *) |
1004 val t = str2term |
1044 val t = str2term "1/(x+1) + 1/(x+2) - 2/(x+3)"; |
1005 "1/(x+1) + 1/(x+2) - 2/(x+3)"; |
1045 (* WN130911 non-termination due to non-termination of |
1006 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t; |
1046 cancel_p_ thy (str2term "(5 + 3 * x) / (6 + 11 * x + 6 * x ^^^ 2 + x ^^^ 3)") |
1007 term2str t; |
1047 |
1008 if (term2str t) = |
1048 val SOME (t, _) = rewrite_set_ thy false norm_Rational t; |
1009 "(5 + 3 * x) / (6 + 11 * x + 6 * x ^^^ 2 + x ^^^ 3)" |
1049 if term2str t = "(5 + 3 * x) / (6 + 11 * x + 6 * x ^^^ 2 + x ^^^ 3)" |
1010 then () |
1050 then () else error "rational.sml: diff.behav. in norm_Rational_mg 14"; |
1011 else error "rational.sml: diff.behav. in norm_Rational_mg 14"; |
1051 *) |
1012 |
1052 |
1013 (*SRA Schalk I, p.67 Nr. 413b *) |
1053 (*SRA Schalk I, p.67 Nr. 413b *) |
1014 val t = str2term |
1054 val t = str2term "(1 + x)/(1 - x) - (1 - x)/(1 + x) + 2*x/(1 - x^^^2)"; |
1015 "(1+x)/(1 - x) - (1 - x)/(1+x) + 2*x/(1 - x^^^2)"; |
1055 val SOME (t, _) = rewrite_set_ thy false norm_Rational t; |
1016 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t; |
1056 if term2str t = "6 * x / (1 + -1 * x ^^^ 2)" |
1017 term2str t; |
1057 then () else error "rational.sml: diff.behav. in norm_Rational_mg 15"; |
1018 if (term2str t) = |
|
1019 "6 * x / (1 + -1 * x ^^^ 2)" |
|
1020 then () |
|
1021 else error "rational.sml: diff.behav. in norm_Rational_mg 15"; |
|
1022 |
1058 |
1023 (*SRA Schalk I, p.68 Nr. 414a *) |
1059 (*SRA Schalk I, p.68 Nr. 414a *) |
1024 val t = str2term |
1060 val t = str2term "(x + 2)/(x - 1) + (x - 3)/(x - 2) - (x + 1)/((x - 1)*(x - 2))"; |
1025 "(x + 2)/(x - 1) + (x - 3)/(x - 2) - (x + 1)/((x - 1)*(x - 2))"; |
1061 val SOME (t, _) = rewrite_set_ thy false norm_Rational t; |
1026 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t; |
1062 if term2str t ="(-2 + -5 * x + 2 * x ^^^ 2) / (2 + -3 * x + x ^^^ 2)" |
1027 term2str t; |
1063 then () else error "rational.sml: diff.behav. in norm_Rational_mg 16"; |
1028 if (term2str t) = |
|
1029 "(-2 + -5 * x + 2 * x ^^^ 2) / (2 + -3 * x + x ^^^ 2)" |
|
1030 then () |
|
1031 else error "rational.sml: diff.behav. in norm_Rational_mg 16"; |
|
1032 |
|
1033 (*SRA Schalk I, p.68 Nr. 423a *) |
|
1034 val t = str2term |
|
1035 "(2*x+3*y)/x + (4*x^^^3 - x*y^^^2 - 3*y^^^3)/(x^^^3 - 2*x^^^2*y+x*y^^^2) - (5*x+6*y)/(x - y)"; |
|
1036 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t; |
|
1037 term2str t; |
|
1038 if (term2str t) = |
|
1039 "1" |
|
1040 then () |
|
1041 else error "rational.sml: diff.behav. in norm_Rational_mg 17"; |
|
1042 |
1064 |
1043 (*SRA Schalk I, p.68 Nr. 428b *) |
1065 (*SRA Schalk I, p.68 Nr. 428b *) |
1044 val t = str2term |
1066 val t = str2term |
1045 "1/(a - b)^^^2 + 1/(a+b)^^^2 - 2/(a^^^2 - b^^^2) - 4*(b^^^2 - 1)/(a^^^2 - b^^^2)^^^2"; |
1067 "1/(a - b)^^^2 + 1/(a + b)^^^2 - 2/(a^^^2 - b^^^2) - 4*(b^^^2 - 1)/(a^^^2 - b^^^2)^^^2"; |
1046 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t; |
1068 (* WN130911 non-termination due to non-termination of |
1047 term2str t; |
1069 cancel_p_ thy (str2term "(4 + -4 * b ^^^ 2) / (a ^^^ 4 + -2 * (a ^^^ 2 * b ^^^ 2) + b ^^^ 4)") |
1048 if (term2str t) = |
1070 |
1049 "4 / (a ^^^ 4 + -2 * a ^^^ 2 * b ^^^ 2 + b ^^^ 4)" |
1071 val SOME (t, _) = rewrite_set_ thy false norm_Rational t; |
1050 then () |
1072 if term2str t = "4 / (a ^^^ 4 + -2 * a ^^^ 2 * b ^^^ 2 + b ^^^ 4)" |
1051 else error "rational.sml: diff.behav. in norm_Rational_mg 18"; |
1073 then () else error "rational.sml: diff.behav. in norm_Rational_mg 18"; |
|
1074 *) |
1052 |
1075 |
1053 (*SRA Schalk I, p.68 Nr. 430b *) |
1076 (*SRA Schalk I, p.68 Nr. 430b *) |
1054 val t = str2term |
1077 val t = str2term |
1055 "a^^^2/(a - 3*b) - 108*a*b^^^3/((a+3*b)*(a^^^2 - 9*b^^^2)) - 9*b^^^2*(a - 3*b)/(a+3*b)^^^2"; |
1078 "a^^^2/(a - 3*b) - 108*a*b^^^3/((a+3*b)*(a^^^2 - 9*b^^^2)) - 9*b^^^2*(a - 3*b)/(a+3*b)^^^2"; |
1056 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t; |
1079 val SOME (t, _) = rewrite_set_ thy false norm_Rational t; |
1057 term2str t; |
1080 if term2str t = "a + 3 * b" |
1058 if (term2str t) = |
1081 then () else error "rational.sml: diff.behav. in norm_Rational_mg 19"; |
1059 "a + 3 * b" |
|
1060 then () |
|
1061 else error "rational.sml: diff.behav. in norm_Rational_mg 19"; |
|
1062 |
|
1063 |
1082 |
1064 (*SRA Schalk I, p.68 Nr. 432 *) |
1083 (*SRA Schalk I, p.68 Nr. 432 *) |
1065 val t = str2term |
1084 val t = str2term |
1066 "(a^^^2+a*b)/(a^^^2 - b^^^2) - (b^^^2 - a*b)/(b^^^2 - a^^^2) + a^^^2*(a - b)/(a^^^3 - a^^^2*b) - 2*a*(a^^^2 - b^^^2)/(a^^^3 - a*b^^^2) - 2*b^^^2/(a^^^2 - b^^^2)"; |
1085 ("(a^^^2 + a*b) / (a^^^2 - b^^^2) - (b^^^2 - a*b) / (b^^^2 - a^^^2) + " ^ |
1067 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t; |
1086 "a^^^2*(a - b) / (a^^^3 - a^^^2*b) - 2*a*(a^^^2 - b^^^2) / (a^^^3 - a*b^^^2) - " ^ |
|
1087 "2*b^^^2 / (a^^^2 - b^^^2)"); |
|
1088 val SOME (t, _) = rewrite_set_ thy false norm_Rational t; |
1068 term2str t; |
1089 term2str t; |
1069 if (term2str t) = |
1090 if term2str t = "0" |
1070 "0" |
1091 then () else error "rational.sml: diff.behav. in norm_Rational_mg 20"; |
1071 then () |
1092 |
1072 else error "rational.sml: diff.behav. in norm_Rational_mg 20"; |
1093 (* some example *) |
1073 |
1094 val t = str2term "3*a / (a*b) + x/y"; |
1074 (*Eigenes*) |
1095 val SOME (t, _) = rewrite_set_ thy false norm_Rational t; |
|
1096 if term2str t = "(3 * y + b * x) / (b * y)" |
|
1097 then () else error "rational.sml: diff.behav. in norm_Rational_mg 21"; |
|
1098 |
|
1099 "-------- examples multiply and cancel from: Mathematik 1 Schalk -------------"; |
|
1100 "-------- examples multiply and cancel from: Mathematik 1 Schalk -------------"; |
|
1101 "-------- examples multiply and cancel from: Mathematik 1 Schalk -------------"; |
|
1102 (*------- SRM Schalk I, p.68 Nr. 436a *) |
|
1103 val t = str2term "3*(x+y) / (15*(x - y)) * 25*(x - y)^^^2 / (18*(x + y)^^^2)"; |
|
1104 val SOME (t, _) = rewrite_set_ thy false norm_Rational t; |
|
1105 if term2str t = "(-5 * x + 5 * y) / (-18 * x + -18 * y)" |
|
1106 then () else error "rational.sml: diff.behav. in norm_Rational_mg 22"; |
|
1107 |
|
1108 (*------- SRM.test Schalk I, p.68 Nr. 436b *) |
|
1109 val t = str2term "5*a*(a - b)^^^2*(a + b)^^^3/(7*b*(a - b)^^^3) * 7*b/(a + b)^^^3"; |
|
1110 val SOME (t, _) = rewrite_set_ thy false norm_Rational t; |
|
1111 if term2str t = "5 * a / (a + -1 * b)" |
|
1112 then () else error "rational.sml: diff.behav. in norm_Rational_mg 23"; |
|
1113 |
|
1114 (*------- Schalk I, p.68 Nr. 437a *) |
|
1115 val t = str2term "(3*a - 4*b) / (4*c+3*e) * (3*a+4*b)/(9*a^^^2 - 16*b^^^2)"; |
|
1116 (* raises an exception for unclear reasons: |
|
1117 val SOME (t, _) = rewrite_set_ thy false norm_Rational t; |
|
1118 : |
|
1119 ### rls: cancel_p on: (9 * a ^^^ 2 + -16 * b ^^^ 2) / (4 * c + 3 * e) / |
|
1120 (9 * a ^^^ 2 + -16 * b ^^^ 2) |
|
1121 exception Div raised |
|
1122 |
|
1123 BUT |
1075 val t = str2term |
1124 val t = str2term |
1076 "3*a/(a*b) + x/y"; |
1125 ("(9 * a ^^^ 2 + -16 * b ^^^ 2) / (4 * c + 3 * e) /" ^ |
1077 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t; |
1126 "(9 * a ^^^ 2 + -16 * b ^^^ 2)"); |
1078 term2str t; |
1127 NONE = cancel_p_ thy t; |
1079 if (term2str t) = |
1128 |
1080 "(3 * y + b * x) / (b * y)" |
1129 if term2str t = "1 / (4 * c + 3 * e)" then () |
1081 then () |
|
1082 else error "rational.sml: diff.behav. in norm_Rational_mg 21"; |
|
1083 |
|
1084 |
|
1085 "-------- multiply and cancel ---------------------------"; |
|
1086 "-------- multiply and cancel ---------------------------"; |
|
1087 "-------- multiply and cancel ---------------------------"; |
|
1088 (*SRM Schalk I, p.68 Nr. 436a *) |
|
1089 val t = str2term |
|
1090 "3*(x+y)/(15*(x - y)) * 25*(x - y)^^^2/(18*(x+y)^^^2)"; |
|
1091 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t; |
|
1092 term2str t; |
|
1093 if (term2str t) = |
|
1094 "(5 * x + -5 * y) / (18 * x + 18 * y)" |
|
1095 then () |
|
1096 else error "rational.sml: diff.behav. in norm_Rational_mg 22"; |
|
1097 |
|
1098 (*SRM.test Schalk I, p.68 Nr. 436b *) |
|
1099 (*WN060420???MG3 crashes with method 'simplify' in |
|
1100 IsacCore > Simplification > Rational Terms > Multiplication > No.2*) |
|
1101 val t = str2term "5*a*(a - b)^^^2*(a + b)^^^3/(7*b*(a - b)^^^3) * 7*b/(a + b)^^^3"; |
|
1102 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t; |
|
1103 term2str t; |
|
1104 if (term2str t) = |
|
1105 "5 * a / (a + -1 * b)" |
|
1106 then () |
|
1107 else error "rational.sml: diff.behav. in norm_Rational_mg 23"; |
|
1108 |
|
1109 (*Schalk I, p.68 Nr. 437a *) |
|
1110 val t = str2term "(3*a - 4*b)/(4*c+3*e) * (3*a+4*b)/(9*a^^^2 - 16*b^^^2)"; |
|
1111 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t; |
|
1112 if (term2str t) = "1 / (4 * c + 3 * e)" then () |
|
1113 else error "rational.sml: diff.behav. in norm_Rational_mg 24"; |
1130 else error "rational.sml: diff.behav. in norm_Rational_mg 24"; |
|
1131 *) |
1114 |
1132 |
1115 "----- S.K. corrected non-termination 060904"; |
1133 "----- S.K. corrected non-termination 060904"; |
1116 val t = str2term "(3*a - 4*b) * (3*a+4*b)/((4*c+3*e)*(9*a^^^2 - 16*b^^^2))"; |
1134 val t = str2term "(3*a - 4*b) * (3*a+4*b)/((4*c+3*e)*(9*a^^^2 - 16*b^^^2))"; |
1117 val SOME (t',_) = rewrite_set_ thy false make_polynomial t; |
1135 val SOME (t, _) = rewrite_set_ thy false make_polynomial t; |
1118 term2str t'; |
1136 if term2str t = |
1119 if term2str t' = |
|
1120 "(9 * a ^^^ 2 + -16 * b ^^^ 2) /\n(36 * a ^^^ 2 * c + 27 * a ^^^ 2 * e + -64 * b ^^^ 2 * c +\n -48 * b ^^^ 2 * e)" |
1137 "(9 * a ^^^ 2 + -16 * b ^^^ 2) /\n(36 * a ^^^ 2 * c + 27 * a ^^^ 2 * e + -64 * b ^^^ 2 * c +\n -48 * b ^^^ 2 * e)" |
1121 (*"(9 * a ^^^ 2 + -16 * b ^^^ 2) / (36 * a ^^^ 2 * c + 27 * a ^^^ 2 * e + -64 * b ^^^ 2 * c + -48 * b ^^^ 2 * e)"*) |
1138 (*"(9 * a ^^^ 2 + -16 * b ^^^ 2) / (36 * a ^^^ 2 * c + 27 * a ^^^ 2 * e + -64 * b ^^^ 2 * c + -48 * b ^^^ 2 * e)"*) |
1122 then () else error "rational.sml: S.K.8..corrected 060904-6"; |
1139 then () else error "rational.sml: S.K.8..corrected 060904-6"; |
1123 |
1140 |
1124 "----- S.K. corrected non-termination of cancel_p_"; |
1141 "----- S.K. corrected non-termination of cancel_p_"; |
1125 val t'' = str2term ("(9 * a ^^^ 2 + -16 * b ^^^ 2) /" ^ |
1142 val t'' = str2term ("(9 * a ^^^ 2 + -16 * b ^^^ 2) /" ^ |
1126 "(36 * a^^^2 * c + (27 * a^^^2 * e + (-64 * b^^^2 * c + -48 * b^^^2 * e)))"); |
1143 "(36 * a^^^2 * c + (27 * a^^^2 * e + (-64 * b^^^2 * c + -48 * b^^^2 * e)))"); |
1127 val SOME (t',_) = rewrite_set_ thy false cancel_p t''; |
1144 val SOME (t',_) = rewrite_set_ thy false cancel_p t''; |
1128 if term2str t' = "1 / (4 * c + 3 * e)" then () |
1145 if term2str t' = "1 / (4 * c + 3 * e)" |
1129 else error "rational.sml: diff.behav. in cancel_p S.K.8"; |
1146 then () else error "rational.sml: diff.behav. in cancel_p S.K.8"; |
1130 |
1147 |
1131 (*Schalk I, p.68 Nr. 437b *) |
1148 (*------- Schalk I, p.68 Nr. 437b*) |
1132 (* nonterm.SK9 loops: cancel_p kann nicht weiter kuerzen!!! *) |
1149 val t = str2term "(a + b)/(x^^^2 - y^^^2) * ((x - y)^^^2/(a^^^2 - b^^^2))"; |
1133 val t'' = str2term "(a + b)/(x^^^2 - y^^^2) * ((x - y)^^^2/(a^^^2 - b^^^2))"; |
1150 (*val SOME (t, _) = rewrite_set_ thy false norm_Rational t; |
1134 (* val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t''; |
1151 : |
1135 *) |
1152 #### rls: cancel_p on: (a * x ^^^ 2 + -2 * (a * (x * y)) + a * y ^^^ 2 + b * x ^^^ 2 + |
1136 |
1153 -2 * (b * (x * y)) + |
1137 "================delete==="; |
1154 b * y ^^^ 2) / |
1138 (*a casual output from above*) |
1155 (a ^^^ 2 * x ^^^ 2 + -1 * (a ^^^ 2 * y ^^^ 2) + -1 * (b ^^^ 2 * x ^^^ 2) + |
|
1156 b ^^^ 2 * y ^^^ 2) |
|
1157 exception Div raised |
|
1158 *) |
|
1159 |
|
1160 (*------- SRM Schalk I, p.68 Nr. 438a *) |
|
1161 val t = str2term "x*y / (x*y - y^^^2) * (x^^^2 - x*y)"; |
|
1162 val SOME (t, _) = rewrite_set_ thy false norm_Rational t; |
|
1163 if term2str t = "x ^^^ 2" |
|
1164 then () else error "rational.sml: diff.behav. in norm_Rational_mg 24"; |
|
1165 |
|
1166 (*------- SRM Schalk I, p.68 Nr. 439b *) |
|
1167 val t = str2term "(4*x^^^2 + 4*x + 1) * ((x^^^2 - 2*x^^^3) / (4*x^^^2 + 2*x))"; |
|
1168 val SOME (t, _) = rewrite_set_ thy false norm_Rational t; |
|
1169 if term2str t = "(x + -4 * x ^^^ 3) / 2" |
|
1170 then () else error "rational.sml: diff.behav. in norm_Rational_mg 25"; |
|
1171 |
|
1172 (*------- SRM Schalk I, p.68 Nr. 440a *) |
|
1173 val t = str2term "(x^^^2 - 2*x) / (x^^^2 - 3*x) * (x - 3)^^^2 / (x^^^2 - 4)"; |
|
1174 val SOME (t, _) = rewrite_set_ thy false norm_Rational t; |
|
1175 if term2str t = "(-3 + x) / (2 + x)" |
|
1176 then () else error "rational.sml: diff.behav. in norm_Rational_mg 26"; |
|
1177 |
|
1178 "----- Schalk I, p.68 Nr. 440b SK11 works since 0707xx"; |
|
1179 val t = str2term "(a^^^3 - 9*a) / (a^^^3*b - a*b^^^3) * (a^^^2*b + a*b^^^2) / (a+3)"; |
|
1180 (* WN130911 non-termination for unclear reasons: |
|
1181 val SOME (t, _) = rewrite_set_ thy false norm_Rational t; |
|
1182 |
|
1183 ... ENDS WITH THIS TRACE: |
|
1184 : |
|
1185 ### rls: cancel_p on: (-9 * (a ^^^ 3 * b) + -9 * (a ^^^ 2 * b ^^^ 2) + a ^^^ 5 * b + |
|
1186 a ^^^ 4 * b ^^^ 2) / |
|
1187 (a ^^^ 3 * b + -1 * (a * b ^^^ 3)) / |
|
1188 (3 + a) |
|
1189 BUT THIS IS CORRECTLY RECOGNISED |
1139 val t = str2term |
1190 val t = str2term |
1140 "(a * x ^^^ 2 + -2 * a * x * y + a * y ^^^ 2 + b * x ^^^ 2 + -2 * b * x * y + b * y ^^^ 2) /(a ^^^ 2 * x ^^^ 2 + -1 * a ^^^ 2 * y ^^^ 2 + -1 * b ^^^ 2 * x ^^^ 2 + b ^^^ 2 * y ^^^ 2)"; |
1191 ("(-9 * (a^^^3 * b) + -9 * (a^^^2 * b^^^2) + a^^^5 * b + a^^^4 * b^^^2) /" ^ |
1141 (* WN060831 nonterm.SK10 |
1192 "(a^^^3 * b + -1 * (a * b^^^3)) / (3 + (a::real))"); |
1142 val SOME (t,_) = rewrite_set_ thy false cancel_p t; |
1193 AS |
1143 term2str t; |
1194 NONE = cancel_p_ thy t; |
1144 *) |
1195 |
1145 |
|
1146 (*SRM Schalk I, p.68 Nr. 438a *) |
|
1147 val t = str2term |
|
1148 "x*y/(x*y - y^^^2)*(x^^^2 - x*y)"; |
|
1149 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t; |
|
1150 term2str t; |
|
1151 if (term2str t) = |
|
1152 "x ^^^ 2" |
|
1153 then () |
|
1154 else error "rational.sml: diff.behav. in norm_Rational_mg 24"; |
|
1155 |
|
1156 (*SRM Schalk I, p.68 Nr. 439b *) |
|
1157 val t = str2term |
|
1158 "(4*x^^^2+4*x+1)*((x^^^2 - 2*x^^^3)/(4*x^^^2+2*x))"; |
|
1159 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t; |
|
1160 term2str t; |
|
1161 if (term2str t) = |
|
1162 "(x + -4 * x ^^^ 3) / 2" |
|
1163 then () |
|
1164 else error "rational.sml: diff.behav. in norm_Rational_mg 25"; |
|
1165 |
|
1166 (*SRM Schalk I, p.68 Nr. 440a *) |
|
1167 val t = str2term |
|
1168 "(x^^^2 - 2*x)/(x^^^2 - 3*x) * (x - 3)^^^2/(x^^^2 - 4)"; |
|
1169 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t; |
|
1170 term2str t; |
|
1171 if (term2str t) = |
|
1172 "(-3 + x) / (2 + x)" |
|
1173 then () |
|
1174 else error "rational.sml: diff.behav. in norm_Rational_mg 26"; |
|
1175 |
|
1176 "----- Schalk I, p.68 Nr. 440b SK11 works since 0707xx"; |
|
1177 val t = str2term |
|
1178 "(a^^^3 - 9*a)/(a^^^3*b - a*b^^^3)*(a^^^2*b+a*b^^^2)/(a+3)"; |
|
1179 val SOME (t,_) = rewrite_set_ thy false norm_Rational t; |
|
1180 if term2str t = "(-3 * a + a ^^^ 2) / (a + -1 * b)" then () |
1196 if term2str t = "(-3 * a + a ^^^ 2) / (a + -1 * b)" then () |
1181 else error "rational.sml: diff.behav. in norm_Rational 27"; |
1197 else error "rational.sml: diff.behav. in norm_Rational 27"; |
|
1198 *) |
1182 |
1199 |
1183 "----- SK12 works since 0707xx"; |
1200 "----- SK12 works since 0707xx"; |
1184 val t = str2term "(a^^^3 - 9*a)*(a^^^2*b+a*b^^^2)/((a^^^3*b - a*b^^^3)*(a+3))"; |
1201 val t = str2term "(a^^^3 - 9*a) * (a^^^2*b+a*b^^^2) / ((a^^^3*b - a*b^^^3) * (a+3))"; |
1185 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t'; |
1202 (* WN130911 non-termination due to non-termination of |
|
1203 cancel_p_ thy (str2term "(4 + -4 * b ^^^ 2) / (a ^^^ 4 + -2 * (a ^^^ 2 * b ^^^ 2) + b ^^^ 4)") |
|
1204 |
|
1205 val SOME (t, _) = rewrite_set_ thy false norm_Rational t; |
1186 if term2str t' = "(-3 * a + a ^^^ 2) / (a + -1 * b)" then () |
1206 if term2str t' = "(-3 * a + a ^^^ 2) / (a + -1 * b)" then () |
1187 else error "rational.sml: diff.behav. in norm_Rational 28"; |
1207 else error "rational.sml: diff.behav. in norm_Rational 28"; |
1188 |
1208 *) |
1189 |
1209 |
1190 "-------- common denominator and multiplication ---------"; |
1210 "-------- examples common denominator and multiplication from: Schalk --------"; |
1191 "-------- common denominator and multiplication ---------"; |
1211 "-------- examples common denominator and multiplication from: Schalk --------"; |
1192 "-------- common denominator and multiplication ---------"; |
1212 "-------- examples common denominator and multiplication from: Schalk --------"; |
1193 (*SRAM Schalk I, p.69 Nr. 441b *) |
1213 (*------- SRAM Schalk I, p.69 Nr. 441b *) |
1194 val t = str2term "(4*a/3 + 3*b^^^2/a^^^3 + b/(4*a))*(4*b/(3*a))"; |
1214 val t = str2term "(4*a/3 + 3*b^^^2/a^^^3 + b/(4*a))*(4*b/(3*a))"; |
1195 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t; |
1215 val SOME (t, _) = rewrite_set_ thy false norm_Rational t; |
1196 term2str t; |
1216 if term2str t = "(36 * b ^^^ 3 + 3 * a ^^^ 2 * b ^^^ 2 + 16 * a ^^^ 4 * b) / (9 * a ^^^ 4)" |
1197 if (term2str t) = |
|
1198 "(36 * b ^^^ 3 + 3 * a ^^^ 2 * b ^^^ 2 + 16 * a ^^^ 4 * b) / (9 * a ^^^ 4)" |
|
1199 then () else error "rational.sml: diff.behav. in norm_Rational_mg 28"; |
1217 then () else error "rational.sml: diff.behav. in norm_Rational_mg 28"; |
1200 |
1218 |
1201 (*SRAM Schalk I, p.69 Nr. 442b *) |
1219 (*------- SRAM Schalk I, p.69 Nr. 442b *) |
1202 val t = str2term "(15*a^^^2/x^^^3 - 5*b^^^4/x^^^2 + 25*c^^^2/x)*(x^^^3/(5*a*b^^^3*c^^^3)) + 1/c^^^3 * (b*x/a - 3*a/b^^^3)"; |
1220 val t = str2term ("(15*a^^^2/x^^^3 - 5*b^^^4/x^^^2 + 25*c^^^2/x) * " ^ |
1203 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t; |
1221 "(x^^^3/(5*a*b^^^3*c^^^3)) + 1/c^^^3 * (b*x/a - 3*a/b^^^3)"); |
1204 term2str t; |
1222 val SOME (t, _) = rewrite_set_ thy false norm_Rational t; |
1205 if (term2str t) = |
1223 if term2str t = "5 * x ^^^ 2 / (a * b ^^^ 3 * c)" |
1206 "5 * x ^^^ 2 / (a * b ^^^ 3 * c)" |
|
1207 then () else error "rational.sml: diff.behav. in norm_Rational_mg 29"; |
1224 then () else error "rational.sml: diff.behav. in norm_Rational_mg 29"; |
1208 |
1225 |
1209 (*SRAM Schalk I, p.69 Nr. 443b *) |
1226 (*------- SRAM Schalk I, p.69 Nr. 443b *) |
1210 val t = str2term "(a/2 + b/3)*(b/3 - a/2)"; |
1227 val t = str2term "(a/2 + b/3) * (b/3 - a/2)"; |
1211 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t; |
1228 val SOME (t, _) = rewrite_set_ thy false norm_Rational t; |
1212 term2str t; |
1229 if term2str t = "(-9 * a ^^^ 2 + 4 * b ^^^ 2) / 36" |
1213 if (term2str t) = |
|
1214 "(-9 * a ^^^ 2 + 4 * b ^^^ 2) / 36" |
|
1215 then () else error "rational.sml: diff.behav. in norm_Rational_mg 30"; |
1230 then () else error "rational.sml: diff.behav. in norm_Rational_mg 30"; |
1216 |
1231 |
1217 (*SRAM Schalk I, p.69 Nr. 445b *) |
1232 (*------- SRAM Schalk I, p.69 Nr. 445b *) |
1218 val t = str2term "(a^^^2/9 + 2*a/(3*b) + 4/b^^^2)*(a/3 - 2/b) + 8/b^^^3"; |
1233 val t = str2term "(a^^^2/9 + 2*a/(3*b) + 4/b^^^2)*(a/3 - 2/b) + 8/b^^^3"; |
1219 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t; |
1234 val SOME (t, _) = rewrite_set_ thy false norm_Rational t; |
1220 term2str t; |
1235 if term2str t = "a ^^^ 3 / 27" |
1221 if (term2str t) = |
|
1222 "a ^^^ 3 / 27" |
|
1223 then () else error "rational.sml: diff.behav. in norm_Rational_mg 31"; |
1236 then () else error "rational.sml: diff.behav. in norm_Rational_mg 31"; |
1224 |
1237 |
1225 (*SRAM Schalk I, p.69 Nr. 446b *) |
1238 (*------- SRAM Schalk I, p.69 Nr. 446b *) |
1226 val t = str2term "(x/(5*x + 4*y) - y/(5*x - 4*y) + 1)*(25*x^^^2 - 16*y^^^2)"; |
1239 val t = str2term "(x/(5*x + 4*y) - y/(5*x - 4*y) + 1)*(25*x^^^2 - 16*y^^^2)"; |
1227 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t; |
1240 val SOME (t, _) = rewrite_set_ thy false norm_Rational t; |
1228 term2str t; |
1241 if term2str t = "30 * x ^^^ 2 + -9 * x * y + -20 * y ^^^ 2" |
1229 if (term2str t) = |
1242 then () else error "rational.sml: diff.behav. in norm_Rational_mg 32"; |
1230 "30 * x ^^^ 2 + -9 * x * y + -20 * y ^^^ 2" |
1243 |
1231 then () |
1244 (*------- SRAM Schalk I, p.69 Nr. 449a *)(*Achtung: rechnet ca 8 Sekunden*) |
1232 else error "rational.sml: diff.behav. in norm_Rational_mg 32"; |
|
1233 |
|
1234 (*SRAM Schalk I, p.69 Nr. 449a *)(*Achtung: rechnet ca 8 Sekunden*) |
|
1235 val t = str2term |
1245 val t = str2term |
1236 "(2*x^^^2/(3*y)+x/y^^^2)*(4*x^^^4/(9*y^^^2)+x^^^2/y^^^4)*(2*x^^^2/(3*y) - x/y^^^2)"; |
1246 "(2*x^^^2/(3*y)+x/y^^^2)*(4*x^^^4/(9*y^^^2)+x^^^2/y^^^4)*(2*x^^^2/(3*y) - x/y^^^2)"; |
1237 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t; |
1247 val SOME (t, _) = rewrite_set_ thy false norm_Rational t; |
1238 term2str t; |
1248 if term2str t = "(-81 * x ^^^ 4 + 16 * x ^^^ 8 * y ^^^ 4) / (81 * y ^^^ 8)" |
1239 if (term2str t) = "(-81 * x ^^^ 4 + 16 * x ^^^ 8 * y ^^^ 4) / (81 * y ^^^ 8)" |
|
1240 then () else error "rational.sml: diff.behav. in norm_Rational_mg 33"; |
1249 then () else error "rational.sml: diff.behav. in norm_Rational_mg 33"; |
1241 |
1250 |
1242 |
1251 (*------- SRAM Schalk I, p.69 Nr. 450a *) |
1243 (*SRAM Schalk I, p.69 Nr. 450a *) |
|
1244 val t = str2term |
1252 val t = str2term |
1245 "(4*x/(3*y)+2*y/(3*x))^^^2 - (2*y/(3*x) - 2*x/y)*(2*y/(3*x)+2*x/y)"; |
1253 "(4*x/(3*y)+2*y/(3*x))^^^2 - (2*y/(3*x) - 2*x/y)*(2*y/(3*x)+2*x/y)"; |
1246 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t; |
1254 val SOME (t, _) = rewrite_set_ thy false norm_Rational t; |
1247 term2str t; |
1255 if term2str t = "(52 * x ^^^ 2 + 16 * y ^^^ 2) / (9 * y ^^^ 2)" |
1248 if (term2str t) = |
1256 then () else error "rational.sml: diff.behav. in norm_Rational_mg 34"; |
1249 "(52 * x ^^^ 2 + 16 * y ^^^ 2) / (9 * y ^^^ 2)" |
1257 |
1250 then () |
1258 (*------- SRAM Schalk I, p.69 Nr. 442b --- abgewandelt*) |
1251 else error "rational.sml: diff.behav. in norm_Rational_mg 34"; |
|
1252 |
|
1253 |
|
1254 "-------- double fractions ------------------------------"; |
|
1255 "-------- double fractions ------------------------------"; |
|
1256 "-------- double fractions ------------------------------"; |
|
1257 (*SRD Schalk I, p.69 Nr. 454b *) |
|
1258 val t = str2term |
1259 val t = str2term |
1259 "((2 - x)/(2*a)) / (2*a/(x - 2))"; |
1260 ("(15*a^^^4/(a*x^^^3) - 5*a*((b^^^4 - 5*c^^^2*x) / x^^^2)) * " ^ |
1260 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t; |
1261 "(x^^^3/(5*a*b^^^3*c^^^3)) + a/c^^^3 * (x*(b/a) - 3*b*(a/b^^^4))"); |
1261 term2str t; |
1262 val SOME (t, _) = rewrite_set_ thy false norm_Rational t; |
1262 if (term2str t) = |
1263 if term2str t = "5 * x ^^^ 2 / (b ^^^ 3 * c)" |
1263 "(-4 + 4 * x + -1 * x ^^^ 2) / (4 * a ^^^ 2)" |
1264 then () else error "rational.sml: diff.behav. in norm_Rational_mg 53"; |
1264 then () |
1265 |
1265 else error "rational.sml: diff.behav. in norm_Rational_mg 35"; |
1266 |
1266 |
1267 "-------- examples double fractions from: Mathematik 1 Schalk ----------------"; |
1267 (*SRD Schalk I, p.69 Nr. 455a *) |
1268 "-------- examples double fractions from: Mathematik 1 Schalk ----------------"; |
1268 val t = str2term |
1269 "-------- examples double fractions from: Mathematik 1 Schalk ----------------"; |
1269 "(a^^^2 + 1)/(a^^^2 - 1) / ((a+1)/(a - 1))"; |
1270 "----- SRD Schalk I, p.69 Nr. 454b"; |
1270 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t; |
1271 val t = str2term "((2 - x)/(2*a)) / (2*a/(x - 2))"; |
1271 term2str t; |
1272 val SOME (t, _) = rewrite_set_ thy false norm_Rational t; |
1272 if (term2str t) = |
1273 if term2str t = "(-4 + 4 * x + -1 * x ^^^ 2) / (4 * a ^^^ 2)" |
1273 "(1 + a ^^^ 2) / (1 + 2 * a + a ^^^ 2)" then () |
1274 then () else error "rational.sml: diff.behav. in norm_Rational_mg 35"; |
|
1275 |
|
1276 "----- SRD Schalk I, p.69 Nr. 455a"; |
|
1277 val t = str2term "(a^^^2 + 1)/(a^^^2 - 1) / ((a+1)/(a - 1))"; |
|
1278 val SOME (t, _) = rewrite_set_ thy false norm_Rational t; |
|
1279 if term2str t = "(1 + a ^^^ 2) / (1 + 2 * a + a ^^^ 2)" then () |
1274 else error "rational.sml: diff.behav. in norm_Rational_mg 36"; |
1280 else error "rational.sml: diff.behav. in norm_Rational_mg 36"; |
1275 |
|
1276 |
1281 |
1277 "----- Schalk I, p.69 Nr. 455b"; |
1282 "----- Schalk I, p.69 Nr. 455b"; |
1278 val t = str2term "(x^^^2 - 4)/(y^^^2 - 9)/((2+x)/(3 - y))"; |
1283 val t = str2term "(x^^^2 - 4)/(y^^^2 - 9)/((2+x)/(3 - y))"; |
1279 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t; |
1284 (* WN130911 non-termination due to non-termination of |
|
1285 cancel_p_ thy (str2term ("(-12 + 4 * y + 3 * x ^^^ 2 + -1 * (x ^^^ 2 * y)) /" ^ |
|
1286 "(-18 + -9 * x + 2 * y ^^^ 2 + x * y ^^^ 2)")) |
|
1287 |
|
1288 val SOME (t, _) = rewrite_set_ thy false norm_Rational t; |
1280 if term2str t = "(2 + -1 * x) / (3 + y)" then () |
1289 if term2str t = "(2 + -1 * x) / (3 + y)" then () |
1281 else error "rational.sml: diff.behav. in norm_Rational_mg 37"; |
1290 else error "rational.sml: diff.behav. in norm_Rational_mg 37"; |
|
1291 *) |
1282 |
1292 |
1283 "----- SK060904-1a non-termination of cancel_p_ ?: worked before 0707xx"; |
1293 "----- SK060904-1a non-termination of cancel_p_ ?: worked before 0707xx"; |
1284 val t = str2term "(x^^^2 - 4)*(3 - y)/((y^^^2 - 9)*(2+x))"; |
1294 val t = str2term "(x^^^2 - 4)*(3 - y) / ((y^^^2 - 9)*(2+x))"; |
1285 val SOME (t,_) = rewrite_set_ thy false norm_Rational t; |
1295 (* WN130911 non-termination due to non-termination of |
|
1296 cancel_p_ thy (str2term ("(-12 + 4 * y + 3 * x ^^^ 2 + -1 * (x ^^^ 2 * y)) /" ^ |
|
1297 "(-18 + -9 * x + 2 * y ^^^ 2 + x * y ^^^ 2)")) |
|
1298 |
|
1299 val SOME (t, _) = rewrite_set_ thy false norm_Rational t; |
1286 if term2str t = "(2 + -1 * x) / (3 + y)" then () |
1300 if term2str t = "(2 + -1 * x) / (3 + y)" then () |
1287 else error "rational.sml: diff.behav. in norm_Rational_mg 37b"; |
1301 else error "rational.sml: diff.behav. in norm_Rational_mg 37b"; |
|
1302 *) |
1288 |
1303 |
1289 "----- ?: worked before 0707xx"; |
1304 "----- ?: worked before 0707xx"; |
1290 val t = str2term "(3 + -1 * y) / (-9 + y ^^^ 2)"; |
1305 val t = str2term "(3 + -1 * y) / (-9 + y ^^^ 2)"; |
1291 val SOME (t,_) = rewrite_set_ thy false norm_Rational t; |
1306 val SOME (t, _) = rewrite_set_ thy false norm_Rational t; |
1292 if term2str t = "-1 / (3 + y)" then () |
1307 if term2str t = "-1 / (3 + y)" |
1293 else error "rational.sml: -1 / (3 + y) norm_Rational"; |
1308 then () else error "rational.sml: -1 / (3 + y) norm_Rational"; |
1294 |
1309 |
1295 (*SRD Schalk I, p.69 Nr. 456b *) |
1310 "----- SRD Schalk I, p.69 Nr. 456b"; |
|
1311 val t = str2term "(b^^^3 - b^^^2) / (b^^^2+b) / (b^^^2 - 1)"; |
|
1312 val SOME (t, _) = rewrite_set_ thy false norm_Rational t; |
|
1313 if term2str t = "b / (1 + 2 * b + b ^^^ 2)" |
|
1314 then () else error "rational.sml: diff.behav. in norm_Rational_mg 38"; |
|
1315 |
|
1316 "----- SRD Schalk I, p.69 Nr. 457b"; |
|
1317 val t = str2term "(16*a^^^2 - 9*b^^^2)/(2*a+3*a*b) / ((4*a+3*b)/(4*a^^^2 - 9*a^^^2*b^^^2))"; |
|
1318 val SOME (t, _) = rewrite_set_ thy false norm_Rational t; |
|
1319 if term2str t = "8 * a ^^^ 2 + -6 * a * b + -12 * a ^^^ 2 * b + 9 * a * b ^^^ 2" |
|
1320 then () else error "rational.sml: diff.behav. in norm_Rational_mg 39"; |
|
1321 |
|
1322 "----- Schalk I, p.69 Nr. 458b works since 0707"; |
|
1323 val t = str2term "(2*a^^^2*x - a^^^2) / (a*x - b*x) / (b^^^2*(2*x - 1) / (x*(a - b)))"; |
|
1324 (*val SOME (t, _) = rewrite_set_ thy false norm_Rational t; |
|
1325 : |
|
1326 ### rls: cancel_p on: (-1 * a ^^^ 2 + 2 * (a ^^^ 2 * x)) / (a * x + -1 * (b * x)) / |
|
1327 ((-1 * b ^^^ 2 + 2 * (b ^^^ 2 * x)) / (a * x + -1 * (b * x))) |
|
1328 exception Div raised |
|
1329 |
|
1330 BUT |
1296 val t = str2term |
1331 val t = str2term |
1297 "(b^^^3 - b^^^2)/(b^^^2+b)/(b^^^2 - 1)"; |
1332 ("(-1 * a ^^^ 2 + 2 * (a ^^^ 2 * x)) / (a * x + -1 * (b * x)) /" ^ |
1298 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t; |
1333 "((-1 * b ^^^ 2 + 2 * (b ^^^ 2 * x)) / (a * x + -1 * (b * x)))"); |
1299 term2str t; |
1334 NONE = cancel_p_ thy t; |
1300 if (term2str t) = "b / (1 + 2 * b + b ^^^ 2)" then () |
1335 |
1301 else error "rational.sml: diff.behav. in norm_Rational_mg 38"; |
|
1302 |
|
1303 (*SRD Schalk I, p.69 Nr. 457b *) |
|
1304 val t = str2term |
|
1305 "(16*a^^^2 - 9*b^^^2)/(2*a+3*a*b) / ((4*a+3*b)/(4*a^^^2 - 9*a^^^2*b^^^2))"; |
|
1306 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t; |
|
1307 term2str t; |
|
1308 if (term2str t) = |
|
1309 "8 * a ^^^ 2 + -6 * a * b + -12 * a ^^^ 2 * b + 9 * a * b ^^^ 2" |
|
1310 then () else error "rational.sml: diff.behav. in norm_Rational_mg 39"; |
|
1311 |
|
1312 "----- Schalk I, p.69 Nr. 458b works since 0707"; |
|
1313 val t = str2term |
|
1314 "(2*a^^^2*x - a^^^2)/(a*x - b*x) / (b^^^2*(2*x - 1)/(x*(a - b)))"; |
|
1315 val SOME (t,_) = rewrite_set_ thy false norm_Rational t; |
|
1316 if term2str t = "a ^^^ 2 / b ^^^ 2" then () |
1336 if term2str t = "a ^^^ 2 / b ^^^ 2" then () |
1317 else error "rational.sml: diff.behav. in norm_Rational_mg 39b"; |
1337 else error "rational.sml: diff.behav. in norm_Rational_mg 39b"; |
1318 |
1338 *) |
1319 (*SRD Schalk I, p.69 Nr. 459b *) |
1339 |
|
1340 "----- SRD Schalk I, p.69 Nr. 459b"; |
1320 val t = str2term "(a^^^2 - b^^^2)/(a*b) / (4*(a+b)^^^2/a)"; |
1341 val t = str2term "(a^^^2 - b^^^2)/(a*b) / (4*(a+b)^^^2/a)"; |
1321 val SOME (t,_) = rewrite_set_ thy false norm_Rational t; |
1342 val SOME (t, _) = rewrite_set_ thy false norm_Rational t; |
1322 if term2str t = "(a + -1 * b) / (4 * a * b + 4 * b ^^^ 2)" then () |
1343 if term2str t = "(a + -1 * b) / (4 * a * b + 4 * b ^^^ 2)" then () |
1323 else error "rational.sml: diff.behav. in norm_Rational_mg 41"; |
1344 else error "rational.sml: diff.behav. in norm_Rational_mg 41"; |
1324 |
1345 |
1325 |
1346 "----- Schalk I, p.69 Nr. 460b nonterm.SK"; |
1326 (*Schalk I, p.69 Nr. 460b nonterm.SK |
1347 val t = str2term "(9*(x^^^2 - 8*x + 16) / (4*(y^^^2 - 2*y + 1))) / ((3*x - 12) / (16*y - 16))"; |
|
1348 (*val SOME (t, _) = rewrite_set_ thy false norm_Rational t; |
|
1349 exception Div raised |
|
1350 |
|
1351 BUT |
1327 val t = str2term |
1352 val t = str2term |
1328 "(9*(x^^^2 - 8*x+16)/(4*(y^^^2 - 2*y+1)))/((3*x - 12)/(16*y - 16))"; |
1353 ("(144 + -72 * x + 9 * x ^^^ 2) / (4 + -8 * y + 4 * y ^^^ 2) /" ^ |
1329 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t; |
1354 "((-12 + 3 * x) / (-16 + 16 * y))"); |
1330 if term2str t = |
1355 NONE = cancel_p_ thy t; |
1331 then () |
1356 |
1332 else error "rational.sml: diff.behav. in norm_Rational_mg 42"; |
1357 if term2str t = !!!!!!!!!!!!!!!!!!!!!!!!! |
1333 |
1358 then () else error "rational.sml: diff.behav. in norm_Rational_mg 42"; |
1334 val t = str2term |
1359 *) |
1335 "9*(x^^^2 - 8*x+16)*(16*y - 16)/(4*(y^^^2 - 2*y+1)*(3*x - 12))"; |
1360 |
1336 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; |
1361 "----- some variant of the above; was non-terminating before"; |
1337 ... non terminating. |
1362 val t = str2term "9*(x^^^2 - 8*x+16)*(16*y - 16)/(4*(y^^^2 - 2*y+1)*(3*x - 12))"; |
1338 val SOME (t',_) = rewrite_set_ thy false make_polynomial t; |
1363 val SOME (t , _) = rewrite_set_ thy false norm_Rational t; |
1339 "(-2304 + 1152 * x + 2304 * y + -144 * x ^^^ 2 + -1152 * x * y + 144 * x ^^^ 2 * y) /(-48 + 12 * x + 96 * y + -24 * x * y + -48 * y ^^^ 2 + 12 * x * y ^^^ 2)"; |
1364 if term2str t = "(48 + -12 * x) / (1 + -1 * y)" |
1340 val SOME (t,_) = rewrite_set_ thy false cancel_p t'; |
1365 then () else error "some variant of the above; was non-terminating before"; |
1341 ... non terminating.*) |
1366 |
1342 |
1367 "----- SRD Schalk I, p.70 Nr. 472a"; |
1343 (*SRD Schalk I, p.70 Nr. 472a *) |
1368 val t = str2term ("((8*x^^^2 - 32*y^^^2) / (2*x + 4*y)) / ((4*x - 8*y) / (x + y))"); |
1344 val t = str2term ("((8*x^^^2 - 32*y^^^2)/(2*x + 4*y))/" ^ |
1369 val SOME (t, _) = rewrite_set_ thy false norm_Rational t; |
1345 "((4*x - 8*y)/(x + y))"); |
1370 if term2str t = "x + y" |
1346 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t; |
1371 then () else error "rational.sml: diff.behav. in norm_Rational_mg 43"; |
1347 term2str t; |
1372 |
1348 if (term2str t) = |
1373 "----- Schalk I, p.70 Nr. 478b ----- Rechenzeit: 5 sec"; |
1349 "x + y" |
1374 val t = str2term ("(a - (a*b + b^^^2)/(a+b))/(b+(a - b)/(1+(a+b)/(a - b))) / " ^ |
1350 then () |
1375 "((a - a^^^2/(a+b))/(a+(a*b)/(a - b)))"); |
1351 else error "rational.sml: diff.behav. in norm_Rational_mg 43"; |
1376 val SOME (t, _) = rewrite_set_ thy false norm_Rational t; |
1352 |
1377 if term2str t = "(2 * a ^^^ 3 + 2 * a ^^^ 2 * b) / (a ^^^ 2 * b + b ^^^ 3)" |
1353 |
1378 then () else error "rational.sml: diff.behav. in norm_Rational_mg 51"; |
1354 (*----------------------------------------------------------------------*) |
|
1355 (*---------------------- Einfache Dppelbrche --------------------------*) |
|
1356 (*----------------------------------------------------------------------*) |
|
1357 |
1379 |
1358 (*SRD Schalk I, p.69 Nr. 461a *) |
1380 (*SRD Schalk I, p.69 Nr. 461a *) |
1359 val t = str2term |
1381 val t = str2term "(2/(x+3) + 2/(x - 3)) / (8*x/(x^^^2 - 9))"; |
1360 "(2/(x+3) + 2/(x - 3)) / (8*x/(x^^^2 - 9))"; |
1382 val SOME (t, _) = rewrite_set_ thy false norm_Rational t; |
1361 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t; |
1383 if term2str t = "1 / 2" |
1362 term2str t; |
1384 then () else error "rational.sml: diff.behav. in norm_Rational_mg 44"; |
1363 if (term2str t) = |
|
1364 "1 / 2" |
|
1365 then () |
|
1366 else error "rational.sml: diff.behav. in norm_Rational_mg 44"; |
|
1367 |
1385 |
1368 (*SRD Schalk I, p.69 Nr. 464b *) |
1386 (*SRD Schalk I, p.69 Nr. 464b *) |
1369 val t = str2term |
1387 val t = str2term "(a - a/(a - 2)) / (a + a/(a - 2))"; |
1370 "(a - a/(a - 2)) / (a + a/(a - 2))"; |
1388 val SOME (t, _) = rewrite_set_ thy false norm_Rational t; |
1371 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t; |
1389 if term2str t = "(-3 + a) / (-1 + a)" |
1372 term2str t; |
1390 then () else error "rational.sml: diff.behav. in norm_Rational_mg 45"; |
1373 if (term2str t) = |
|
1374 "(3 + -1 * a) / (1 + -1 * a)" |
|
1375 then () |
|
1376 else error "rational.sml: diff.behav. in norm_Rational_mg 45"; |
|
1377 |
1391 |
1378 (*SRD Schalk I, p.69 Nr. 465b *) |
1392 (*SRD Schalk I, p.69 Nr. 465b *) |
1379 val t = str2term |
1393 val t = str2term "((x+3*y)/9 + (4*y^^^2 - 9*z^^^2)/(16*x)) / (x/9 + y/6 + z/4)"; |
1380 "((x+3*y)/9 + (4*y^^^2 - 9*z^^^2)/(16*x)) /(x/9+y/6+z/4)"; |
1394 (* WN130911 non-termination due to non-termination of |
1381 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t; |
1395 cancel_p_ thy (str2term |
1382 term2str t; |
1396 ("("(576 * x ^^^ 2 + 1728 * (x * y) + 1296 * y ^^^ 2 + -2916 * z ^^^ 2) /" ^ |
1383 if (term2str t) = |
1397 "(576 * x ^^^ 2 + 864 * (x * y) + 1296 * (x * z))")) |
1384 "(4 * x + 6 * y + -9 * z) / (4 * x)" |
1398 |
1385 then () |
1399 val SOME (t, _) = rewrite_set_ thy false norm_Rational t; |
1386 else error "rational.sml: diff.behav. in norm_Rational_mg 46"; |
1400 if term2str t = "(4 * x + 6 * y + -9 * z) / (4 * x)" |
|
1401 then () else error "rational.sml: diff.behav. in norm_Rational_mg 46"; |
|
1402 *) |
1387 |
1403 |
1388 (*SRD Schalk I, p.69 Nr. 466b *) |
1404 (*SRD Schalk I, p.69 Nr. 466b *) |
1389 val t = str2term |
1405 val t = str2term "((1 - 7*(x - 2)/(x^^^2 - 4)) / (6/(x+2))) / (3/(x+5)+30/(x^^^2 - 25))"; |
1390 "((1 - 7*(x - 2)/(x^^^2 - 4)) / (6/(x+2))) / (3/(x+5)+30/(x^^^2 - 25))"; |
1406 val SOME (t, _) = rewrite_set_ thy false norm_Rational t; |
1391 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t; |
1407 if term2str t = "(25 + -10 * x + x ^^^ 2) / 18" |
1392 term2str t; |
1408 then () else error "rational.sml: diff.behav. in norm_Rational_mg 47"; |
1393 if (term2str t) = |
|
1394 "(25 + -10 * x + x ^^^ 2) / 18" |
|
1395 then () |
|
1396 else error "rational.sml: diff.behav. in norm_Rational_mg 47"; |
|
1397 |
1409 |
1398 (*SRD Schalk I, p.70 Nr. 469 *) |
1410 (*SRD Schalk I, p.70 Nr. 469 *) |
1399 val t = str2term |
1411 val t = str2term ("3*b^^^2 / (4*a^^^2 - 8*a*b + 4*b^^^2) / " ^ |
1400 "3*b^^^2/(4*a^^^2 - 8*a*b + 4*b^^^2)/(a/(a^^^2*b - b^^^3) + (a - b)/(4*a*b^^^2+4*b^^^3) - 1/(4*b^^^2))"; |
1412 "(a / (a^^^2*b - b^^^3) + (a - b) / (4*a*b^^^2 + 4*b^^^3) - 1 / (4*b^^^2))"); |
1401 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t; |
1413 val SOME (t, _) = rewrite_set_ thy false norm_Rational t; |
1402 term2str t; |
1414 if term2str t = "-3 * b ^^^ 3 / (-2 * a + 2 * b)" |
1403 if (term2str t) = |
1415 then () else error "rational.sml: diff.behav. in norm_Rational_mg 48"; |
1404 "3 * b ^^^ 3 / (2 * a + -2 * b)" |
1416 |
1405 then () |
1417 "-------- me Schalk I No.186 -------------------------------------------------"; |
1406 else error "rational.sml: diff.behav. in norm_Rational_mg 48"; |
1418 "-------- me Schalk I No.186 -------------------------------------------------"; |
1407 |
1419 "-------- me Schalk I No.186 -------------------------------------------------"; |
1408 (*----------------------------------------------------------------------*) |
1420 val fmz = ["Term ((14 * x * y) / ( x * y ))", "normalform N"]; |
1409 (*---------------------- Mehrfache Dppelbrueche ------------------------*) |
|
1410 (*----------------------------------------------------------------------*) |
|
1411 |
|
1412 (*SRD.test Schalk I, p.70 Nr. 476b *) (* Rechenzeit: 10 sec *) |
|
1413 (*WN060419 crashes with method 'simplify' ????SK*) |
|
1414 val t = str2term |
|
1415 "((a^^^2 - b^^^2)/(2*a*b)+2*a*b/(a^^^2 - b^^^2))/((a^^^2+b^^^2)/(2*a*b)+1) / ((a^^^2+b^^^2)^^^2/(a+b)^^^2)"; |
|
1416 val SOME (t,_) = rewrite_set_ thy false norm_Rational t; |
|
1417 if term2str t = "1 / (a ^^^ 2 + -1 * b ^^^ 2)" then () |
|
1418 else error "rational.sml: diff.behav. in norm_Rational_mg 49"; |
|
1419 |
|
1420 "----- Schalk I, p.70 Nr. 477a"; |
|
1421 (* MG Achtung: terme explodieren; Bsp zu komplex; |
|
1422 L???ung sollte (ziemlich grosser) Faktorisierter Ausdruck sein |
|
1423 val t = str2term "b*y/(b - 2*y)/((b^^^2 - y^^^2)/(b+2*y)) /" ^ |
|
1424 "(b^^^2*y+b*y^^^2)*(a+x)^^^2/((b^^^2 - 4*y^^^2)*(a+2*x)^^^2)"; |
|
1425 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; |
|
1426 |
|
1427 |
|
1428 val t = str2term "b*y*(b+2*y)*(b^^^2 - 4*y^^^2)*(a+2*x)^^^2 / " ^ |
|
1429 "((b - 2*y)*(b^^^2 - y^^^2)*(b^^^2*y+b*y^^^2)*(a+x)^^^2)"; |
|
1430 val SOME (t,_) = rewrite_set_ thy false make_polynomial t; |
|
1431 ????SK ???MG*) |
|
1432 |
|
1433 |
|
1434 "----- Schalk I, p.70 Nr. 478b ----- Rechenzeit: 5 sec"; |
|
1435 val t = str2term ("(a - (a*b+b^^^2)/(a+b))/(b+(a - b)/(1+(a+b)/(a - b))) / " ^ |
|
1436 "((a - a^^^2/(a+b))/(a+(a*b)/(a - b)))"); |
|
1437 val SOME (t',_) = rewrite_set_ thy false norm_Rational(*_mg*) t; |
|
1438 if term2str t' = |
|
1439 "(2 * a ^^^ 3 + 2 * a ^^^ 2 * b) / (a ^^^ 2 * b + b ^^^ 3)" |
|
1440 then () |
|
1441 else error "rational.sml: diff.behav. in norm_Rational_mg 51"; |
|
1442 |
|
1443 (* TODO.new_c:WN050820 STOP_REW_SUB introduced gave ... |
|
1444 if term2str t' = "(a ^^^ 4 + -1 * a ^^^ 2 * b ^^^ 2) /(a * b * (b + (a * (a + -1 * b) + -1 * b * (a + -1 * b)) / (2 * a)) * (a + -1 * b))" then () |
|
1445 else error "rational.sml: works again"; |
|
1446 re-outcommented with TODO.new_c: cvs before 071227, 11:50*) |
|
1447 |
|
1448 |
|
1449 |
|
1450 (*Schalk I, p.70 Nr. 480a *) |
|
1451 (* Achtung: rechnet ewig; cancel_p kann nicht krzen: WN060831 nonterm.SK00 |
|
1452 val t = str2term |
|
1453 "(1/x+1/y+1/z)/(1/x - 1/y - 1/z) / (2*x^^^2/(x^^^2 - z^^^2)/(x/(x+z)+x/(x - z)))"; |
|
1454 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t; |
|
1455 term2str t; |
|
1456 if (term2str t) = |
|
1457 |
|
1458 then () |
|
1459 else error "rational.sml: diff.behav. in norm_Rational_mg 52"; |
|
1460 |
|
1461 (*MG Berechne Zwischenergebnisse: WN060831 nonterm.SK00*) |
|
1462 val t = str2term |
|
1463 "(1/x+1/y+1/z)/(1/x - 1/y - 1/z)"; |
|
1464 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t; |
|
1465 term2str t; |
|
1466 "(x ^^^ 2 * y ^^^ 2 * z + x ^^^ 2 * y * z ^^^ 2 + x * y ^^^ 2 * z ^^^ 2) / |
|
1467 (-1 * x ^^^ 2 * y ^^^ 2 * z + -1 * x ^^^ 2 * y * z ^^^ 2 + x * y ^^^ 2 * z ^^^ 2)"; |
|
1468 val t = str2term |
|
1469 "2*x^^^2/(x^^^2 - z^^^2)/(x/(x+z)+x/(x - z))"; |
|
1470 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t; |
|
1471 term2str t; |
|
1472 "1" |
|
1473 |
|
1474 (* SK 1. Ausdruck kann nicht weiter gekrzt werden; cancel_p !!!*) |
|
1475 ### rls: cancel_p on: |
|
1476 (x ^^^ 2 * (y ^^^ 2 * z) + x ^^^ 2 * (y * z ^^^ 2) + x * (y ^^^ 2 * z ^^^ 2)) / |
|
1477 (-1 * (x ^^^ 2 * (y ^^^ 2 * z)) + -1 * (x ^^^ 2 * (y * z ^^^ 2)) + x * (y ^^^ 2 * z ^^^ 2)) |
|
1478 GC #3.61.81.101.197.17503: (0 ms) |
|
1479 *** RATIONALS_DIRECT_CANCEL_EXCEPTION: Invalid fraction |
|
1480 |
|
1481 val t = str2term |
|
1482 "(x^^^2 * (y^^^2 * z) + x^^^2 * (y * z^^^2) + x * (y^^^2 * z^^^2)) / (-1 * (x^^^2 * (y^^^2 * z)) + -1 * (x^^^2 * (y * z^^^2)) + x * (y^^^2 * z^^^2))"; |
|
1483 val SOME (t,_) = rewrite_set_ thy false cancel_p t; |
|
1484 term2str t; |
|
1485 (*uncaught exception nonexhaustive binding failure*) |
|
1486 |
|
1487 (* Das kann er aber krzen !!????: *) |
|
1488 val t = str2term |
|
1489 "(x^^^2 * (y^^^2 * z) + x * (y^^^2 * z^^^2)) / (-1 * (x^^^2 * (y * z^^^2)) + x * (y^^^2 * z^^^2))"; |
|
1490 val SOME (t,_) = rewrite_set_ thy false cancel_p t; |
|
1491 term2str t; |
|
1492 "(-1 * (y * x) + -1 * (z * y)) / (1 * (z * x) + -1 * (z * y))"; |
|
1493 *) |
|
1494 |
|
1495 |
|
1496 "-------- crucial examples ------------------------------"; |
|
1497 "-------- crucial examples ------------------------------"; |
|
1498 "-------- crucial examples ------------------------------"; |
|
1499 (*Schalk I, p.60 Nr. 215d *) |
|
1500 (* Achtung: rechnet ewig ... |
|
1501 val t = str2term "(a-b)^^^3 * (x+y)^^^4 / ((x+y)^^^2 * (a-b)^^^5)"; |
|
1502 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t; |
|
1503 term2str t; noterm.SK |
|
1504 *) |
|
1505 |
|
1506 (* Kein Wunder, denn Z???ler und Nenner extra als Polynom dargestellt ergibt:*) |
|
1507 (* |
|
1508 val t = str2term "(a-b)^^^3 * (x+y)^^^4"; |
|
1509 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t; |
|
1510 term2str t; |
|
1511 "a^^^3 * x^^^4 + 4 * a^^^3 * x^^^3 * y +6 * a^^^3 * x^^^2 * y^^^2 +4 * a^^^3 * x * y^^^3 +a^^^3 * y^^^4 +-3 * a^^^2 * b * x^^^4 +-12 * a^^^2 * b * x^^^3 * y +-18 * a^^^2 * b * x^^^2 * y^^^2 +-12 * a^^^2 * b * x * y^^^3 +-3 * a^^^2 * b * y^^^4 +3 * a * b^^^2 * x^^^4 +12 * a * b^^^2 * x^^^3 * y +18 * a * b^^^2 * x^^^2 * y^^^2 +12 * a * b^^^2 * x * y^^^3 +3 * a * b^^^2 * y^^^4 +-1 * b^^^3 * x^^^4 +-4 * b^^^3 * x^^^3 * y +-6 * b^^^3 * x^^^2 * y^^^2 +-4 * b^^^3 * x * y^^^3 +-1 * b^^^3 * y^^^4"; |
|
1512 val t = str2term "((x+y)^^^2 * (a-b)^^^5)"; |
|
1513 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t; |
|
1514 term2str t; |
|
1515 "a^^^5 * x^^^2 + 2 * a^^^5 * x * y + a^^^5 * y^^^2 +-5 * a^^^4 * b * x^^^2 +-10 * a^^^4 * b * x * y +-5 * a^^^4 * b * y^^^2 +10 * a^^^3 * b^^^2 * x^^^2 +20 * a^^^3 * b^^^2 * x * y +10 * a^^^3 * b^^^2 * y^^^2 +-10 * a^^^2 * b^^^3 * x^^^2 +-20 * a^^^2 * b^^^3 * x * y +-10 * a^^^2 * b^^^3 * y^^^2 +5 * a * b^^^4 * x^^^2 +10 * a * b^^^4 * x * y +5 * a * b^^^4 * y^^^2 +-1 * b^^^5 * x^^^2 +-2 * b^^^5 * x * y +-1 * b^^^5 * y^^^2"; |
|
1516 *) |
|
1517 (*anscheinend macht dem Rechner das Krzen diese Bruches keinen Spass mehr ...*) |
|
1518 |
|
1519 (*--------------------------------------------------------------------*) |
|
1520 (*Schalk I, p.70 Nr. 480b |
|
1521 val t = str2term "((12*x*y/(9*x^^^2 - y^^^2))/" ^ |
|
1522 "(1/(3*x - y)^^^2 - 1/(3*x + y)^^^2)) *" ^ |
|
1523 "(1/(x - 5*y)^^^2 - 1/(x + 5*y)^^^2)/" ^ |
|
1524 "(20*x*y/(x^^^2 - 25*y^^^2))"; |
|
1525 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t; |
|
1526 SK.nonterm |
|
1527 Kann nicht weiter vereinfacht werden !!!!?? *) |
|
1528 |
|
1529 (*--------------------------------------------------------------------*) |
|
1530 "---- MGs test set"; |
|
1531 val t = str2term " (1 + x^^^5) / (y + x) + x^^^3 / x "; |
|
1532 val SOME (t,_) = rewrite_set_ thy false common_nominator_p t; |
|
1533 if term2str t = "(1 + x ^^^ 3 + x ^^^ 5 + y * x ^^^ 2) / (x + y)" then() |
|
1534 else error ""; |
|
1535 |
|
1536 (*--------------------------------------------------------------------*) |
|
1537 (* cancel_p liefert nicht immer Polynomnormalform (2): WN060831???SK3b |
|
1538 ---> Sortierung FALSCH !! *) |
|
1539 val t = str2term "b^^^3 * a^^^5/a "; |
|
1540 val SOME (t,_) = rewrite_set_ thy false cancel_p t; |
|
1541 term2str t; |
|
1542 "1 * (a^^^4 * b^^^3) / 1"; (*OK*) |
|
1543 |
|
1544 val t = str2term "b^^^3 * a^^^5/b "; |
|
1545 val SOME (t,_) = rewrite_set_ thy false cancel_p t; |
|
1546 term2str t; |
|
1547 "1 * (b^^^2 * a^^^5) / 1"; (*cancel_p sortiert hier falsch um!*) |
|
1548 |
|
1549 (* Problem liegt NICHT bei ord_make_polynomial! (siehe folgende Bsple) *) |
|
1550 (* |
|
1551 val x = str2term "x"; val bdv = str2term "bdv"; |
|
1552 val t1 = str2term "b^^^2 * a^^^5"; |
|
1553 val t2 = str2term "a^^^5 * b^^^2 "; |
|
1554 ord_make_polynomial false Rational.thy [(x,bdv)] (t1,t2); (*false*) |
|
1555 *) |
|
1556 (* ==> "b^^^2 * a^^^5" > "a^^^5 * b^^^2 " ... OK!*) |
|
1557 |
|
1558 (*--------------------------------------------------------------------*) |
|
1559 (* cancel_p liefert nicht immer Polynomnormalform (2): WN060831???SK3c |
|
1560 ---> erzeugt berflssige "1 * ..." |
|
1561 |
|
1562 val t = str2term "-1 / (3 + y)"; |
|
1563 (*~~ *) |
|
1564 val SOME (t,_) = rewrite_set_ thy false cancel_p t; |
|
1565 term2str t; |
|
1566 "-1 / (3 + 1 * y)"; |
|
1567 (********* Das ist das PROBLEM !!!!!!!??? *******************) |
|
1568 (* -1 im Z???ler der Angabe verursacht das Problem !*) |
|
1569 *) |
|
1570 |
|
1571 (* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *) |
|
1572 "----- MGs test set"; |
|
1573 val t = str2term "(a^^^2 + -1)/(a+1)"; |
|
1574 val SOME (t',_) = rewrite_set_ thy false cancel_p t; |
|
1575 if term2str t' = "(-1 + a) / 1" then () |
|
1576 else error "rational.sml MG tests 3d"; |
|
1577 |
|
1578 "----- NOT TERMINATING ?: worked before 0707xx"; |
|
1579 val t = str2term "(a^^^2 - 1)*(b + 1) / ((b^^^2 - 1)*(a+1))"; |
|
1580 val SOME (t'',_) = rewrite_set_ thy false norm_Rational t; |
|
1581 if term2str t'' = "(1 + -1 * a) / (1 + -1 * b)" then () |
|
1582 else error "rational.sml MG tests 3e"; |
|
1583 |
|
1584 "----- corrected SK060905"; |
|
1585 val t = str2term "(4*x^^^2 - 20*x + 25)/(2*x - 5)^^^3"; |
|
1586 val SOME (t',_) = rewrite_set_ thy false norm_Rational(*_mg*) t; |
|
1587 if term2str t' = "-1 / (5 + -2 * x)" then () |
|
1588 else error "rational.sml corrected SK060905"; |
|
1589 |
|
1590 |
|
1591 "-------- examples for Stefan Karnels thesis ------------"; |
|
1592 "-------- examples for Stefan Karnels thesis ------------"; |
|
1593 "-------- examples for Stefan Karnels thesis ------------"; |
|
1594 (*SRAM Schalk I, p.69 Nr. 442b --- abgewandelt*) |
|
1595 val t = str2term |
|
1596 "(15*a^^^4/(a*x^^^3) - 5*a*((b^^^4 - 5*c^^^2*x)/x^^^2))*(x^^^3/(5*a*b^^^3*c^^^3)) + a/c^^^3 * (x*(b/a) - 3*b*(a/b^^^4))"; |
|
1597 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t; |
|
1598 term2str t; |
|
1599 if (term2str t) = |
|
1600 "5 * x ^^^ 2 / (b ^^^ 3 * c)" |
|
1601 then () |
|
1602 else error "rational.sml: diff.behav. in norm_Rational_mg 53"; |
|
1603 |
|
1604 |
|
1605 "-------- me Schalk I No.186 ----------------------------"; |
|
1606 "-------- me Schalk I No.186 ----------------------------"; |
|
1607 "-------- me Schalk I No.186 ----------------------------"; |
|
1608 val fmz = ["Term ((14 * x * y) / ( x * y ))", |
|
1609 "normalform N"]; |
|
1610 val (dI',pI',mI') = |
1421 val (dI',pI',mI') = |
1611 ("Rational",["rational","simplification"], |
1422 ("Rational",["rational","simplification"], |
1612 ["simplification","of_rationals"]); |
1423 ["simplification","of_rationals"]); |
1613 val p = e_pos'; val c = []; |
1424 val p = e_pos'; val c = []; |
1614 val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))]; |
1425 val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))]; |
1625 val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;(*++ for explicit script*) |
1436 val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;(*++ for explicit script*) |
1626 case (f2str f, nxt) of |
1437 case (f2str f, nxt) of |
1627 ("14", ("End_Proof'", _)) => () |
1438 ("14", ("End_Proof'", _)) => () |
1628 | _ => error "rational.sml diff.behav. in me Schalk I No.186"; |
1439 | _ => error "rational.sml diff.behav. in me Schalk I No.186"; |
1629 |
1440 |
1630 |
1441 "-------- interSteps ..Simp_Rat_Double_No-1.xml ------------------------------"; |
1631 "-------- interSteps ..Simp_Rat_Double_No-1.xml ---------"; |
1442 "-------- interSteps ..Simp_Rat_Double_No-1.xml ------------------------------"; |
1632 "-------- interSteps ..Simp_Rat_Double_No-1.xml ---------"; |
1443 "-------- interSteps ..Simp_Rat_Double_No-1.xml ------------------------------"; |
1633 "-------- interSteps ..Simp_Rat_Double_No-1.xml ---------"; |
|
1634 states:=[]; |
1444 states:=[]; |
1635 CalcTree |
1445 CalcTree [(["Term (((2 - x)/(2*a)) / (2*a/(x - 2)))", "normalform N"], |
1636 [(["Term (((2 - x)/(2*a)) / (2*a/(x - 2)))", "normalform N"], |
1446 ("Rational", ["rational", "simplification"], ["simplification", "of_rationals"]))]; |
1637 ("Rational",["rational","simplification"], |
|
1638 ["simplification","of_rationals"]))]; |
|
1639 Iterator 1; |
1447 Iterator 1; |
1640 moveActiveRoot 1; |
1448 moveActiveRoot 1; |
1641 autoCalculate 1 CompleteCalc; |
1449 autoCalculate 1 CompleteCalc; |
1642 val ((pt,p),_) = get_calc 1; show_pt pt; |
1450 val ((pt, p), _) = get_calc 1; |
1643 |
1451 (* |
1644 interSteps 1 ([1],Res); |
1452 show_pt pt; |
1645 val ((pt,p),_) = get_calc 1; show_pt pt; |
1453 [ |
1646 |
1454 (([], Frm), Simplify ((2 - x) / (2 * a) / (2 * a / (x - 2)))), |
1647 |
1455 (([1], Frm), (2 - x) / (2 * a) / (2 * a / (x - 2))), |
1648 "-------- interSteps ..Simp_Rat_Cancel_No-1.xml ---------"; |
1456 (([1], Res), (2 + -1 * x) / (2 * a) / (2 * a / (x + -1 * 2))), |
1649 "-------- interSteps ..Simp_Rat_Cancel_No-1.xml ---------"; |
1457 (([2], Res), (2 + -1 * x) / (2 * a) / (2 * a / (-2 + x))), |
1650 "-------- interSteps ..Simp_Rat_Cancel_No-1.xml ---------"; |
1458 (([3], Res), (2 + -1 * x) * (-2 + x) / (2 * a * (2 * a))), |
|
1459 (([4], Res), (-4 + 4 * x + -1 * x ^^^ 2) / (4 * a ^^^ 2)), |
|
1460 (([], Res), (-4 + 4 * x + -1 * x ^^^ 2) / (4 * a ^^^ 2))] |
|
1461 *) |
|
1462 interSteps 1 ([1], Res); |
|
1463 val ((pt, p), _) = get_calc 1; |
|
1464 (*show_pt pt; |
|
1465 [ |
|
1466 (([], Frm), Simplify ((2 - x) / (2 * a) / (2 * a / (x - 2)))), |
|
1467 (([1], Frm), (2 - x) / (2 * a) / (2 * a / (x - 2))), |
|
1468 (([1,1], Frm), (2 - x) / (2 * a) / (2 * a / (x - 2))), |
|
1469 (([1,1], Res), (2 - x) / (2 * a) / (2 * a / (x + -1 * 2))), |
|
1470 (([1,2], Res), (2 + -1 * x) / (2 * a) / (2 * a / (x + -1 * 2))), |
|
1471 (([1], Res), (2 + -1 * x) / (2 * a) / (2 * a / (x + -1 * 2))), |
|
1472 (([2], Res), (2 + -1 * x) / (2 * a) / (2 * a / (-2 + x))), |
|
1473 (([3], Res), (2 + -1 * x) * (-2 + x) / (2 * a * (2 * a))), |
|
1474 (([4], Res), (-4 + 4 * x + -1 * x ^^^ 2) / (4 * a ^^^ 2)), |
|
1475 (([], Res), (-4 + 4 * x + -1 * x ^^^ 2) / (4 * a ^^^ 2))] |
|
1476 *) |
|
1477 val (t, asm) = get_obj g_result pt [1, 1]; |
|
1478 if term2str t = "(2 - x) / (2 * a) / (2 * a / (x + -1 * 2))" andalso terms2str asm = "[]" |
|
1479 then () else error "2nd interSteps ..Simp_Rat_Double_No-1 changed on [1, 1]"; |
|
1480 val (t, asm) = get_obj g_result pt [1, 2]; |
|
1481 if term2str t = "(2 + -1 * x) / (2 * a) / (2 * a / (x + -1 * 2))" andalso terms2str asm = "[]" |
|
1482 then () else error "3rd interSteps ..Simp_Rat_Double_No-1 changed on [1, 2]"; |
|
1483 |
|
1484 |
|
1485 "-------- interSteps ..Simp_Rat_Cancel_No-1.xml ------------------------------"; |
|
1486 "-------- interSteps ..Simp_Rat_Cancel_No-1.xml ------------------------------"; |
|
1487 "-------- interSteps ..Simp_Rat_Cancel_No-1.xml ------------------------------"; |
1651 states:=[]; |
1488 states:=[]; |
1652 CalcTree |
1489 CalcTree [(["Term ((a^2 + -1*b^2) / (a^2 + -2*a*b + b^2))", "normalform N"], |
1653 [(["Term ((a^2 + -1*b^2) / (a^2 + -2*a*b + b^2))", "normalform N"], |
1490 ("Rational", ["rational", "simplification"], ["simplification", "of_rationals"]))]; |
1654 ("Rational",["rational","simplification"], |
|
1655 ["simplification","of_rationals"]))]; |
|
1656 Iterator 1; |
1491 Iterator 1; |
1657 moveActiveRoot 1; |
1492 moveActiveRoot 1; |
1658 autoCalculate 1 CompleteCalc; |
1493 autoCalculate 1 CompleteCalc; |
1659 val ((pt,p),_) = get_calc 1; show_pt pt; |
1494 val ((pt, p), _) = get_calc 1; |
1660 (*========== inhibit exn 110314 ================================================ |
1495 (*show_pt pt; |
1661 (*with explicit script done already... and removed [1,..] at below... |
1496 [ |
1662 interSteps 1 ([1],Res); |
1497 (([], Frm), Simplify ((a ^^^ 2 + -1 * b ^^^ 2) / (a ^^^ 2 + -2 * a * b + b ^^^ 2))), |
1663 val ((pt,p),_) = get_calc 1; show_pt pt; |
1498 (([1], Frm), (a ^^^ 2 + -1 * b ^^^ 2) / (a ^^^ 2 + -2 * a * b + b ^^^ 2)), |
1664 *) |
1499 (([1], Res), (a ^^^ 2 + -1 * b ^^^ 2) / (a ^^^ 2 + -2 * (a * b) + b ^^^ 2)), |
1665 interSteps 1 ([2],Res); |
1500 (([2], Res), (a + b) / (a + -1 * b)), |
1666 val ((pt,p),_) = get_calc 1; show_pt pt; |
1501 (([], Res), (a + b) / (a + -1 * b))] |
1667 |
1502 *) |
|
1503 interSteps 1 ([2], Res); |
|
1504 val ((pt, p), _) = get_calc 1; |
|
1505 (*show_pt pt; |
|
1506 [ |
|
1507 (([], Frm), Simplify ((a ^^^ 2 + -1 * b ^^^ 2) / (a ^^^ 2 + -2 * a * b + b ^^^ 2))), |
|
1508 (([1], Frm), (a ^^^ 2 + -1 * b ^^^ 2) / (a ^^^ 2 + -2 * a * b + b ^^^ 2)), |
|
1509 (([1], Res), (a ^^^ 2 + -1 * b ^^^ 2) / (a ^^^ 2 + -2 * (a * b) + b ^^^ 2)), |
|
1510 (([2,1], Frm), (a ^^^ 2 + -1 * b ^^^ 2) / (a ^^^ 2 + -2 * (a * b) + b ^^^ 2)), |
|
1511 (([2,1], Res), (a + b) / (a + -1 * b)), |
|
1512 (([2], Res), (a + b) / (a + -1 * b)), |
|
1513 (([], Res), (a + b) / (a + -1 * b))] |
|
1514 *) |
1668 interSteps 1 ([2,1],Res); |
1515 interSteps 1 ([2,1],Res); |
1669 val ((pt,p),_) = get_calc 1; show_pt pt; |
1516 val ((pt, p), _) = get_calc 1; |
|
1517 (*show_pt pt; |
|
1518 [ |
|
1519 (([], Frm), Simplify ((a ^^^ 2 + -1 * b ^^^ 2) / (a ^^^ 2 + -2 * a * b + b ^^^ 2))), |
|
1520 (([1], Frm), (a ^^^ 2 + -1 * b ^^^ 2) / (a ^^^ 2 + -2 * a * b + b ^^^ 2)), |
|
1521 (([1], Res), (a ^^^ 2 + -1 * b ^^^ 2) / (a ^^^ 2 + -2 * (a * b) + b ^^^ 2)), |
|
1522 (([2,1], Frm), (a ^^^ 2 + -1 * b ^^^ 2) / (a ^^^ 2 + -2 * (a * b) + b ^^^ 2)), |
|
1523 (([2,1,1], Frm), (a ^^^ 2 + -1 * b ^^^ 2) / (a ^^^ 2 + -2 * (a * b) + b ^^^ 2)), |
|
1524 (([2,1,1], Res), (a ^^^ 2 + -1 * (a * b) + a * b + -1 * b ^^^ 2) / |
|
1525 (a ^^^ 2 + -2 * (a * b) + 1 * b ^^^ 2)), |
|
1526 (([2,1,2], Res), (a ^^^ 2 + -1 * (a * b) + a * b + -1 * b ^^^ 2) / |
|
1527 (a ^^^ 2 + -2 * (a * b) + -1 ^^^ 2 * b ^^^ 2)), |
|
1528 (([2,1,3], Res), (a ^^^ 2 + -1 * (a * b) + a * b + -1 * b ^^^ 2) / |
|
1529 (a ^^^ 2 + -2 * (a * b) + (-1 * b) ^^^ 2)), |
|
1530 (([2,1,4], Res), (a * a + -1 * (a * b) + a * b + -1 * b ^^^ 2) / |
|
1531 (a ^^^ 2 + -2 * (a * b) + (-1 * b) ^^^ 2)), |
|
1532 (([2,1,5], Res), (a * a + -1 * (a * b) + a * b + -1 * (b * b)) / |
|
1533 (a ^^^ 2 + -2 * (a * b) + (-1 * b) ^^^ 2)), |
|
1534 (([2,1,6], Res), (a * a + -1 * (a * b) + a * b + -1 * (b * b)) / |
|
1535 (a ^^^ 2 + -1 * (2 * (a * b)) + (-1 * b) ^^^ 2)), |
|
1536 (([2,1,7], Res), (a * a + a * (-1 * b) + (b * a + b * (-1 * b))) / |
|
1537 (a ^^^ 2 + 2 * (a * (-1 * b)) + (-1 * b) ^^^ 2)), |
|
1538 (([2,1,8], Res), (a * a + a * (-1 * b) + (b * a + b * (-1 * b))) / |
|
1539 (a ^^^ 2 + 2 * a * (-1 * b) + (-1 * b) ^^^ 2)), |
|
1540 (([2,1,9], Res), (a * (a + -1 * b) + (b * a + b * (-1 * b))) / |
|
1541 (a ^^^ 2 + 2 * a * (-1 * b) + (-1 * b) ^^^ 2)), |
|
1542 (([2,1,10], Res), (a * (a + -1 * b) + b * (a + -1 * b)) / |
|
1543 (a ^^^ 2 + 2 * a * (-1 * b) + (-1 * b) ^^^ 2)), |
|
1544 (([2,1,11], Res), (a + b) * (a + -1 * b) / (a ^^^ 2 + 2 * a * (-1 * b) + (-1 * b) ^^^ 2)), |
|
1545 (([2,1,12], Res), (a + b) * (a + -1 * b) / ((a + -1 * b) * (a + -1 * b))), |
|
1546 (([2,1,13], Res), (a + b) / (a + -1 * b)), |
|
1547 (([2,1], Res), (a + b) / (a + -1 * b)), |
|
1548 (([2], Res), (a + b) / (a + -1 * b)), |
|
1549 (([], Res), (a + b) / (a + -1 * b))] |
|
1550 *) |
1670 val newnds = children (get_nd pt [2,1]) (*see "fun detailrls"*); |
1551 val newnds = children (get_nd pt [2,1]) (*see "fun detailrls"*); |
1671 (*if length newnds = 12 then () WN060905*) |
1552 if length newnds = 13 then () else error "rational.sml: interSteps cancel_p rev_rew_p"; |
1672 if length newnds = 13 then () |
|
1673 else error "rational.sml: interSteps cancel_p rev_rew_p"; |
|
1674 |
1553 |
1675 val p = ([2,1,9],Res); |
1554 val p = ([2,1,9],Res); |
1676 getTactic 1 p; |
1555 getTactic 1 p; |
1677 val (_, tac, _) = pt_extract (pt, p); |
1556 val (_, tac, _) = pt_extract (pt, p); |
1678 (*case tac of SOME (Rewrite ("sym_real_plus_binom_times1", _)) => () |
1557 case tac of SOME (Rewrite ("sym_distrib_left", _)) => () |
1679 WN060905*) |
|
1680 case tac of SOME (Rewrite ("sym_real_add_mult_distrib2", _)) => () |
|
1681 | _ => error "rational.sml: getTactic, sym_real_plus_binom_times1"; |
1558 | _ => error "rational.sml: getTactic, sym_real_plus_binom_times1"; |
1682 ============ inhibit exn 110314 ==============================================*) |
1559 |
1683 |
1560 |
1684 |
1561 "-------- investigate rulesets for cancel_p ----------------------------------"; |
1685 "-------- investigate rulesets for cancel_p -------------"; |
1562 "-------- investigate rulesets for cancel_p ----------------------------------"; |
1686 "-------- investigate rulesets for cancel_p -------------"; |
1563 "-------- investigate rulesets for cancel_p ----------------------------------"; |
1687 "-------- investigate rulesets for cancel_p -------------"; |
|
1688 val thy = @{theory "Rational"}; |
1564 val thy = @{theory "Rational"}; |
1689 "---------------- (a^^^2 + -1*b^^^2) / (a^^^2 + -2*a*b + b^^^2)"; |
|
1690 val t = str2term "(a^^^2 + -1*b^^^2) / (a^^^2 + -2*a*b + b^^^2)"; |
1565 val t = str2term "(a^^^2 + -1*b^^^2) / (a^^^2 + -2*a*b + b^^^2)"; |
1691 val tt = str2term "(1 * a + 1 * b) * (1 * a + -1 * b)"(*numerator only*); |
1566 val tt = str2term "(1 * a + 1 * b) * (1 * a + -1 * b)"(*numerator only*); |
|
1567 |
1692 "----- with rewrite_set_"; |
1568 "----- with rewrite_set_"; |
1693 val SOME (tt',asm) = rewrite_set_ thy false make_polynomial tt; |
1569 val SOME (tt',asm) = rewrite_set_ thy false make_polynomial tt; |
1694 term2str tt'= "a ^^^ 2 + -1 * b ^^^ 2" (*true*); |
1570 if term2str tt'= "a ^^^ 2 + -1 * b ^^^ 2" then () else error "rls chancel_p 1"; |
1695 val tt = str2term "((1 * a + -1 * b) * (1 * a + -1 * b))"(*denominator only*); |
1571 val tt = str2term "((1 * a + -1 * b) * (1 * a + -1 * b))"(*denominator only*); |
1696 val SOME (tt',asm) = rewrite_set_ thy false make_polynomial tt; |
1572 val SOME (tt',asm) = rewrite_set_ thy false make_polynomial tt; |
1697 term2str tt' = "a ^^^ 2 + -2 * a * b + b ^^^ 2" (*true*); |
1573 if term2str tt' = "a ^^^ 2 + -2 * a * b + b ^^^ 2" then () else error "rls chancel_p 2"; |
1698 |
1574 |
1699 "----- with make_deriv"; |
1575 "----- with make_deriv; WN1130912 not investigated further, will be discontinued"; |
1700 val SOME (tt, _) = factout_p_ thy t; term2str tt = |
1576 val SOME (tt, _) = factout_p_ thy t; |
1701 "(1 * a + 1 * b) * (1 * a + -1 * b) / ((1 * a + -1 * b) * (1 * a + -1 * b))"; |
1577 if term2str tt = "(a + b) * (a + -1 * b) / ((a + -1 * b) * (a + -1 * b))" |
1702 (* |
1578 then () else error "rls chancel_p 3"; |
1703 "--- with ruleset as before 060829"; |
1579 term2str tt = "(1 * a + 1 * b) * (1 * a + -1 * b) / ((1 * a + -1 * b) * (1 * a + -1 * b))"; |
1704 val {rules, rew_ord=(_,ro),...} = |
1580 |
1705 rep_rls (assoc_rls "make_polynomial"); |
1581 "--- with simpler ruleset"; |
|
1582 val {rules, rew_ord= (_, ro), ...} = rep_rls (assoc_rls "rev_rew_p"); |
1706 val der = make_deriv thy Atools_erls rules ro NONE tt; |
1583 val der = make_deriv thy Atools_erls rules ro NONE tt; |
1707 print_depth 99; map (term2str o #1) der; print_depth 3; |
1584 if length der = 12 then () else error "WN1130912 rls chancel_p 4"; |
1708 print_depth 99; map (rule2str o #2) der; print_depth 3; |
|
1709 ... did not terminate*) |
|
1710 "--- with simpler ruleset"; |
|
1711 val {rules, rew_ord=(_,ro),...} = |
|
1712 rep_rls (assoc_rls "rev_rew_p"); |
|
1713 val der = make_deriv thy Atools_erls rules ro NONE tt; |
|
1714 print_depth 99; writeln (deriv2str der); print_depth 3; |
1585 print_depth 99; writeln (deriv2str der); print_depth 3; |
1715 |
1586 |
1716 print_depth 99; map (term2str o #1) der; print_depth 3; |
1587 print_depth 99; map (term2str o #1) der; print_depth 3; |
1717 "...,(-1 * b ^^^ 2 + a ^^^ 2) / (-2 * (a * b) + a ^^^ 2 + (-1 * b) ^^^ 2) ]"; |
1588 "...,(-1 * b ^^^ 2 + a ^^^ 2) / (-2 * (a * b) + a ^^^ 2 + (-1 * b) ^^^ 2) ]"; |
1718 print_depth 99; map (rule2str o #2) der; print_depth 3; |
1589 print_depth 99; map (rule2str o #2) der; print_depth 3; |
1719 print_depth 99; map (term2str o #1 o #3) der; print_depth 3; |
1590 print_depth 99; map (term2str o #1 o #3) der; print_depth 3; |
1720 |
1591 |
1721 val der = make_deriv thy Atools_erls rules ro NONE |
1592 val der = make_deriv thy Atools_erls rules ro NONE |
1722 (str2term "(1 * a + 1 * b) * (1 * a + -1 * b)"); |
1593 (str2term "(1 * a + 1 * b) * (1 * a + -1 * b)"); |
1723 print_depth 99; writeln (deriv2str der); print_depth 3; |
1594 print_depth 99; writeln (deriv2str der); print_depth 3; |
1724 |
1595 |
1725 val {rules, rew_ord=(_,ro),...} = |
1596 val {rules, rew_ord=(_,ro),...} = rep_rls (assoc_rls "rev_rew_p"); |
1726 rep_rls (assoc_rls "rev_rew_p"); |
|
1727 val der = make_deriv thy Atools_erls rules ro NONE |
1597 val der = make_deriv thy Atools_erls rules ro NONE |
1728 (str2term "(1 * a + -1 * b) * (1 * a + -1 * b)"); |
1598 (str2term "(1 * a + -1 * b) * (1 * a + -1 * b)"); |
1729 print_depth 99; writeln (deriv2str der); print_depth 3; |
1599 print_depth 99; writeln (deriv2str der); print_depth 3; |
1730 print_depth 99; map (term2str o #1) der; print_depth 3; |
1600 print_depth 99; map (term2str o #1) der; print_depth 3; |
1731 (*WN060829 ...postponed*) |
1601 (*WN060829 ...postponed*) |
1732 |
1602 |
1733 |
1603 |
1734 "-------- investigate format of factout_ and factout_p_ -"; |
1604 "-------- fun eval_get_denominator -------------------------------------------"; |
1735 "-------- investigate format of factout_ and factout_p_ -"; |
1605 "-------- fun eval_get_denominator -------------------------------------------"; |
1736 "-------- investigate format of factout_ and factout_p_ -"; |
1606 "-------- fun eval_get_denominator -------------------------------------------"; |
1737 val {rules, rew_ord = (_,ro),...} = rep_rls (assoc_rls "make_polynomial"); |
|
1738 val (thy, eval_rls) = (@{theory "Rational"}, Atools_erls)(*see 'fun init_state'*); |
|
1739 val Rrls {scr = Rfuns {init_state,...},...} = assoc_rls "cancel_p"; |
|
1740 |
|
1741 "----- see Rational.ML, local cancel_p, fun init_state"; |
|
1742 val t = str2term "(a^^^2 + (-1)*b^^^2) / (a^^^2 + (-2)*a*b + b^^^2)"; |
|
1743 val SOME (t',_) = factout_p_ thy t; term2str t'; |
|
1744 (* |
|
1745 val rtas = reverse_deriv thy eval_rls rules ro NONE t'; |
|
1746 writeln(trtas2str rst); |
|
1747 *) |
|
1748 |
|
1749 |
|
1750 "----- see Rational.ML, local cancel_p, fun init_state"; |
|
1751 val t = str2term "a^^^2 / a"; |
|
1752 val SOME (t',_) = factout_p_ thy t; |
|
1753 term2str t' = "a * a / (1 * a)" (*true*); |
|
1754 (*... can be canceled with |
|
1755 real_mult_div_cancel2 ?k ~= 0 ==> ?m * ?k / (?n * ?k) = ?m / ?n"*) |
|
1756 (* sml/ME/rewtools.sml: |
|
1757 val rtas = reverse_deriv thy Atools_erls rules ro NONE t'; |
|
1758 writeln (deri2str rtas); |
|
1759 *) |
|
1760 |
|
1761 |
|
1762 "-------- SK 060904 ----------------------------------------------"; |
|
1763 "----- order on polynomials -- input + output"; |
|
1764 val thy = @{theory "Isac"}; |
|
1765 val t = str2term "(a + -1 * b) / (-1 * a + b)"; |
|
1766 val SOME (t', _) = factout_p_ thy t; term2str t'; |
|
1767 val SOME (t', _) = cancel_p_ thy t; term2str t'; |
|
1768 |
|
1769 val t = str2term "a*b*c*d / (d*e*f*g)"; |
|
1770 val SOME (t', _) = cancel_p_ thy t; term2str t'; |
|
1771 |
|
1772 val t = str2term "a*(b*(c*d)) / (b*(e*(f*g)))"; |
|
1773 val SOME (t', _) = cancel_p_ thy t; term2str t'; |
|
1774 (*???order.SK ???*) |
|
1775 |
|
1776 "----- SK060904-1a non-termination of cancel_p_ ? worked before 0707xx"; |
|
1777 val t = str2term "(x^^^2 - 4)*(3 - y) / ((y^^^2 - 9)*(2+x))"; |
|
1778 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; |
|
1779 if term2str t' = "(2 + -1 * x) / (3 + y)" then () |
|
1780 else error "rational.sml SK060904-1a worked since 0707xx"; |
|
1781 |
|
1782 "----- SK060904-1b non-termination of cancel_p_ ... worked before 0707xx"; |
|
1783 val t = str2term ("(9 * a ^^^ 2 + -16 * b ^^^ 2) /" ^ |
|
1784 "(36 * a^^^2 * c + (27 * a^^^2 * e + (-64 * b^^^2 * c + -48 * b^^^2 * e)))"); |
|
1785 val SOME (t',_) = cancel_p_ thy t; |
|
1786 if term2str t' = "1 / (4 * c + 3 * e)" then () |
|
1787 else error "rational.sml SK060904-1b"; |
|
1788 |
|
1789 |
|
1790 "----- SK060904-2a non-termination of add_fraction_p_"; |
|
1791 val t = str2term (" (a + b * x) / (a + -1 * (b * x)) + " ^ |
|
1792 " (-1 * a + b * x) / (a + b * x) "); |
|
1793 (* nonterm.SK |
|
1794 val SOME (t',_) = rewrite_set_ thy false common_nominator_p t; |
|
1795 |
|
1796 common_nominator_p_ thy t; |
|
1797 " (a + b * x)*(a + b * x) / ((a + -1 * (b * x))*(a + -1 * (b * x))) + " ^ |
|
1798 " (-1 * a + b * x)*(a + -1 * (b * x)) / ((a + b * x)*(-1 * a + b * x)) "; |
|
1799 |
|
1800 add_fraction_p_ thy t; |
|
1801 " ((a + b * x)*(a + b * x) + (-1 * a + b * x)*(a + -1 * (b * x))) /" ^ |
|
1802 " ((a + b * x)*(-1 * a + b * x)) "; |
|
1803 *) |
|
1804 |
|
1805 |
|
1806 "-------- how to stepwise construct Scripts -------------"; |
|
1807 "-------- how to stepwise construct Scripts -------------"; |
|
1808 "-------- how to stepwise construct Scripts -------------"; |
|
1809 val thy = @{theory "Rational"}; |
|
1810 (*no trailing _*) |
|
1811 val p1 = parse thy ( |
|
1812 "Script SimplifyScript (t_t::real) = " ^ |
|
1813 " (Rewrite_Set discard_minus False " ^ |
|
1814 " t_t)"); |
|
1815 |
|
1816 (*required (): (Rewrite_Set discard_minus False)*) |
|
1817 val p2 = parse thy ( |
|
1818 "Script SimplifyScript (t_t::real) = " ^ |
|
1819 " (Rewrite_Set discard_minus False " ^ |
|
1820 " t_t)"); |
|
1821 |
|
1822 val p3 = parse thy ( |
|
1823 "Script SimplifyScript (t_t::real) = " ^ |
|
1824 " ((Rewrite_Set discard_minus False) " ^ |
|
1825 " t_t)"); |
|
1826 |
|
1827 val p4 = parse thy ( |
|
1828 "Script SimplifyScript (t_t::real) = " ^ |
|
1829 " ((Rewrite_Set discard_minus False) " ^ |
|
1830 " t_t)"); |
|
1831 |
|
1832 val p5 = parse thy ( |
|
1833 "Script SimplifyScript (t_t::real) = " ^ |
|
1834 " ((Try (Rewrite_Set discard_minus False) " ^ |
|
1835 " Try (Rewrite_Set discard_parentheses False)) " ^ |
|
1836 " t_t)"); |
|
1837 |
|
1838 val p6 = parse thy ( |
|
1839 "Script SimplifyScript (t_t::real) = " ^ |
|
1840 " ((Try (Rewrite_Set discard_minus False) @@ " ^ |
|
1841 " Try (Rewrite_Set rat_mult_poly False) @@ " ^ |
|
1842 " Try (Rewrite_Set make_rat_poly_with_parentheses False) @@ " ^ |
|
1843 " Try (Rewrite_Set cancel_p_rls False) @@ " ^ |
|
1844 " (Repeat " ^ |
|
1845 " ((Try (Rewrite_Set common_nominator_p_rls False) @@ " ^ |
|
1846 " Try (Rewrite_Set rat_mult_div_pow False) @@ " ^ |
|
1847 " Try (Rewrite_Set make_rat_poly_with_parentheses False) @@" ^ |
|
1848 " Try (Rewrite_Set cancel_p_rls False) @@ " ^ |
|
1849 " Try (Rewrite_Set rat_reduce_1 False)))) @@ " ^ |
|
1850 " Try (Rewrite_Set discard_parentheses False)) " ^ |
|
1851 " t_t)" |
|
1852 ); |
|
1853 |
|
1854 "----------- get_denominator ----------------------------"; |
|
1855 "----------- get_denominator ----------------------------"; |
|
1856 "----------- get_denominator ----------------------------"; |
|
1857 val thy = @{theory Isac}; |
1607 val thy = @{theory Isac}; |
1858 val t = term_of (the (parse thy "get_denominator ((a +x)/b)")); |
1608 val t = term_of (the (parse thy "get_denominator ((a +x)/b)")); |
1859 val SOME (_, t') = eval_get_denominator "" 0 t thy; |
1609 val SOME (_, t') = eval_get_denominator "" 0 t thy; |
1860 if term2str t' = "get_denominator ((a + x) / b) = b" then () |
1610 if term2str t' = "get_denominator ((a + x) / b) = b" |
1861 else error "get_denominator ((a + x) / b) = b" |
1611 then () else error "get_denominator ((a + x) / b) = b" |
1862 |
1612 |
1863 |
1613 |
1864 "--------- several errpats in complicated term -------------------"; |
1614 "-------- several errpats in complicated term --------------------------------"; |
1865 "--------- several errpats in complicated term -------------------"; |
1615 "-------- several errpats in complicated term --------------------------------"; |
1866 "--------- several errpats in complicated term -------------------"; |
1616 "-------- several errpats in complicated term --------------------------------"; |
1867 (*TODO: instead of Gabriella's example here (27.Jul.12) find a simpler one*) |
1617 (*WN12xxxx TODO: instead of Gabriella's example here (27.Jul.12) find a simpler one |
1868 states:=[]; |
1618 WN130912: kept this test, although not clear what for*) |
1869 CalcTree |
1619 states := []; |
1870 [(["Term ((5*b + 25)/(a^2 - b^2) * (a - b)/(5*b))", "normalform N"], |
1620 CalcTree [(["Term ((5*b + 25)/(a^2 - b^2) * (a - b)/(5*b))", "normalform N"], |
1871 ("Rational",["rational","simplification"], ["simplification","of_rationals"]))]; |
1621 ("Rational", ["rational", "simplification"], ["simplification", "of_rationals"]))]; |
1872 Iterator 1; |
1622 Iterator 1; |
1873 moveActiveRoot 1; |
1623 moveActiveRoot 1; |
1874 autoCalculate 1 CompleteCalc; |
1624 autoCalculate 1 CompleteCalc; |
1875 val ((pt,p),_) = get_calc 1; show_pt pt; |
1625 val ((pt, p), _) = get_calc 1; |
1876 |
1626 (*show_pt pt; |
1877 "-------- nonterminating cancel_p, norm_Rational 2002 ---"; |
1627 [ |
1878 "-------- nonterminating cancel_p, norm_Rational 2002 ---"; |
1628 (([], Frm), Simplify ((5 * b + 25) / (a ^^^ 2 - b ^^^ 2) * (a - b) / (5 * b))), |
1879 "-------- nonterminating cancel_p, norm_Rational 2002 ---"; |
1629 (([1], Frm), (5 * b + 25) / (a ^^^ 2 - b ^^^ 2) * (a - b) / (5 * b)), |
1880 (*------------------------------------------------------------------------------------\ |
1630 (([1], Res), (5 * b + 25) / (a ^^^ 2 + -1 * b ^^^ 2) * (a + -1 * b) / (5 * b)), |
1881 "--- WN121204: searched rational.sml for "nonterm", added new numbering" ^ |
1631 (([2], Res), (5 * b + 25) * (a + -1 * b) / (a ^^^ 2 + -1 * b ^^^ 2) / (5 * b)), |
1882 " and thoroughly tested with this numbering subsequently"; |
1632 (([3], Res), (25 * a + -25 * b + 5 * (a * b) + -5 * b ^^^ 2) / (a ^^^ 2 + -1 * b ^^^ 2) / |
1883 "--- 1 ---"; |
1633 (5 * b)), |
1884 WN.2.6.03 from rlang.sml 56a |
1634 (([4], Res), (25 + 5 * b) / (a + b) / (5 * b)), |
1885 val t = str2term "(a + b * x) / (a + -1 * (b * x)) + (-1 * a + b * x) / (a + b * x) = 4 * (a * b) / (a ^^^ 2 + -1 * b ^^^ 2)"; |
1635 (([5], Res), (25 + 5 * b) / ((a + b) * (5 * b))), |
1886 val NONE = rewrite_set_ thy false common_nominator_p t; |
1636 (([6], Res), (25 + 5 * b) / (5 * (a * b) + 5 * b ^^^ 2)), |
1887 "--- 2 ---"; |
1637 (([7], Res), (5 + b) / (a * b + b ^^^ 2)), |
1888 WN060831 nonterm.SK7 |
1638 (([], Res), (5 + b) / (a * b + b ^^^ 2))] *) |
1889 val t = str2term "(a + b * x) / (a + -1 * (b * x)) + (-1 * a + b * x) / (a + b * x)"; |
1639 |
1890 val NONE = add_fraction_p_ thy t; |
1640 |
1891 "--- 3 ---"; |
1641 |
1892 nonterm.SK9 loops: cancel_p kann nicht weiter kuerzen!!! *) |
|
1893 val t'' = str2term "(a + b)/(x^^^2 - y^^^2) * ((x - y)^^^2/(a^^^2 - b^^^2))"; |
|
1894 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t''; |
|
1895 "--- 4 ---"; |
|
1896 val t = str2term |
|
1897 "(a * x ^^^ 2 + -2 * a * x * y + a * y ^^^ 2 + b * x ^^^ 2 + -2 * b * x * y + b * y ^^^ 2) /(a ^^^ 2 * x ^^^ 2 + -1 * a ^^^ 2 * y ^^^ 2 + -1 * b ^^^ 2 * x ^^^ 2 + b ^^^ 2 * y ^^^ 2)"; |
|
1898 WN060831 nonterm.SK10 |
|
1899 val SOME (t,_) = rewrite_set_ thy false cancel_p t; |
|
1900 term2str t; |
|
1901 "--- 5 ---"; |
|
1902 val t = str2term |
|
1903 "(9*(x^^^2 - 8*x+16)/(4*(y^^^2 - 2*y+1)))/((3*x - 12)/(16*y - 16))"; |
|
1904 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t; |
|
1905 if term2str t = |
|
1906 then () |
|
1907 else error "rational.sml: diff.behav. in norm_Rational_mg 42"; |
|
1908 "--- 6 ---"; |
|
1909 val t = str2term |
|
1910 "9*(x^^^2 - 8*x+16)*(16*y - 16)/(4*(y^^^2 - 2*y+1)*(3*x - 12))"; |
|
1911 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; |
|
1912 ... non terminating. |
|
1913 "--- 7 ---"; |
|
1914 val SOME (t',_) = rewrite_set_ thy false make_polynomial t; |
|
1915 "(-2304 + 1152 * x + 2304 * y + -144 * x ^^^ 2 + -1152 * x * y + 144 * x ^^^ 2 * y) /(-48 + 12 * x + 96 * y + -24 * x * y + -48 * y ^^^ 2 + 12 * x * y ^^^ 2)"; |
|
1916 val SOME (t,_) = rewrite_set_ thy false cancel_p t'; |
|
1917 "--- 8 ---"; |
|
1918 val t = str2term "(a-b)^^^3 * (x+y)^^^4 / ((x+y)^^^2 * (a-b)^^^5)"; |
|
1919 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t; |
|
1920 "--- 9 ---"; |
|
1921 val t = str2term "((12*x*y/(9*x^^^2 - y^^^2))/" ^ |
|
1922 "(1/(3*x - y)^^^2 - 1/(3*x + y)^^^2)) *" ^ |
|
1923 "(1/(x - 5*y)^^^2 - 1/(x + 5*y)^^^2)/" ^ |
|
1924 "(20*x*y/(x^^^2 - 25*y^^^2))"; |
|
1925 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t; |
|
1926 "--- 10 ---"; |
|
1927 SK060904-2a non-termination of add_fraction_p_"; |
|
1928 val t = str2term (" (a + b * x) / (a + -1 * (b * x)) + " ^ |
|
1929 " (-1 * a + b * x) / (a + b * x) "); |
|
1930 (* nonterm.SK = WN130830 |
|
1931 val SOME (t',_) = rewrite_set_ thy false common_nominator_p t; |
|
1932 "--- 11 ---"; |
|
1933 common_nominator_p_ thy t; |
|
1934 " (a + b * x)*(a + b * x) / ((a + -1 * (b * x))*(a + -1 * (b * x))) + " ^ |
|
1935 " (-1 * a + b * x)*(a + -1 * (b * x)) / ((a + b * x)*(-1 * a + b * x)) "; |
|
1936 "--- 12 ---"; |
|
1937 add_fraction_p_ thy t; |
|
1938 " ((a + b * x)*(a + b * x) + (-1 * a + b * x)*(a + -1 * (b * x))) /" ^ |
|
1939 " ((a + b * x)*(-1 * a + b * x)) "; |
|
1940 --------------------------------------------------------------------------------------/*) |
|
1941 |
|
1942 (*------------------------------------------------------------------------------------\ |
|
1943 "WN121205: thoroughly tested with the above numbering."; |
|
1944 " errors in cancel_p: --- 4,5,6,7."; |
|
1945 " error in common_nominator_p, common_nominator_p_: --- 10; 1,2?."; |
|
1946 " errors caused by ruleset norm_Rational: --- 8,9."; |
|
1947 trace_rewrite := false; |
|
1948 |
|
1949 "--- 1 ---: non-terminating with ### add_fract: done t22 "; = WN130830 |
|
1950 val t = str2term "(a + b * x) / (a + -1 * (b * x)) + (-1 * a + b * x) / (a + b * x) = 4 * (a * b) / (a ^^^ 2 + -1 * b ^^^ 2)"; |
|
1951 trace_rewrite := false; |
|
1952 rewrite_set_ thy false common_nominator_p t; |
|
1953 |
|
1954 "--- 2 ---: non-terminating with ### add_fract: done t22 "; |
|
1955 val t = str2term "(a + b * x) / (a + -1 * (b * x)) + (-1 * a + b * x) / (a + b * x)"; |
|
1956 add_fraction_p_ thy t; |
|
1957 |
|
1958 "--- 3 ---: norm_Rational calls Rrls cancel_p with non-normalised polys"; |
|
1959 val t = str2term "(a + b)/(x^^^2 - y^^^2) * ((x - y)^^^2/(a^^^2 - b^^^2))"; |
|
1960 rewrite_set_ thy false norm_Rational t; |
|
1961 (*tracing end...#### rls: cancel_p on: |
|
1962 (a * x ^^^ 2 + -2 * (a * (x * y)) + a * y ^^^ 2 + b * x ^^^ 2 + -2 * (b * (x * y)) + b * y ^^^ 2) / |
|
1963 (a ^^^ 2 * x ^^^ 2 + -1 * (a ^^^ 2 * y ^^^ 2) + -1 * (b ^^^ 2 * x ^^^ 2) + b ^^^ 2 * y ^^^ 2) *) |
|
1964 |
|
1965 "--- 4 ---: non-terminating with Rrls cancel_p on plausible input"; |
|
1966 val t = str2term ( |
|
1967 "(a * x ^^^ 2 + -2 * a * x * y + a * y ^^^ 2 + b * x ^^^ 2 + -2 * b * x * y + b * y ^^^ 2) /"^ |
|
1968 "(a ^^^ 2 * x ^^^ 2 + -1 * a ^^^ 2 * y ^^^ 2 + -1 * b ^^^ 2 * x ^^^ 2 + b ^^^ 2 * y ^^^ 2)"); |
|
1969 rewrite_set_ thy false cancel_p t; |
|
1970 (*# rls: cancel_p on: |
|
1971 (a * x ^^^ 2 + -2 * a * x * y + a * y ^^^ 2 + b * x ^^^ 2 + -2 * b * x * y + b * y ^^^ 2) / |
|
1972 (a ^^^ 2 * x ^^^ 2 + -1 * a ^^^ 2 * y ^^^ 2 + -1 * b ^^^ 2 * x ^^^ 2 + b ^^^ 2 * y ^^^ 2) *) |
|
1973 |
|
1974 "--- 5 ---: non-terminating with Rrls cancel_p on plausible input"; |
|
1975 val t = str2term "(9*(x^^^2 - 8*x+16)/(4*(y^^^2 - 2*y+1)))/((3*x - 12)/(16*y - 16))"; |
|
1976 rewrite_set_ thy false norm_Rational t; |
|
1977 (*#### rls: cancel_p on: |
|
1978 (2304 + -1152 * x + -2304 * y + 144 * x ^^^ 2 + 1152 * (x * y) + -144 * (x ^^^ 2 * y)) / |
|
1979 (48 + -12 * x + -96 * y + 24 * (x * y) + 48 * y ^^^ 2 + -12 * (x * y ^^^ 2)) *) |
|
1980 |
|
1981 "--- 6 ---: non-terminating with Rrls cancel_p on plausible input"; |
|
1982 val t = str2term |
|
1983 "9*(x^^^2 - 8*x+16)*(16*y - 16)/(4*(y^^^2 - 2*y+1)*(3*x - 12))"; |
|
1984 rewrite_set_ thy false norm_Rational t; |
|
1985 (*### rls: cancel_p on: (-2304 + 1152 * x + 2304 * y + -144 * x ^^^ 2 + -1152 * (x * y) + |
|
1986 144 * (x ^^^ 2 * y)) / |
|
1987 (-48 + 12 * x + 96 * y + -24 * (x * y) + -48 * y ^^^ 2 + 12 * (x * y ^^^ 2)) *) |
|
1988 |
|
1989 "--- 7 ---: non-terminating with Rrls cancel_p on plausible input"; |
|
1990 val t' = str2term ( |
|
1991 "(-2304 + 1152 * x + 2304 * y + -144 * x ^^^ 2 + -1152 * x * y + 144 * x ^^^ 2 * y) /"^ |
|
1992 "(-48 + 12 * x + 96 * y + -24 * x * y + -48 * y ^^^ 2 + 12 * x * y ^^^ 2)"); |
|
1993 rewrite_set_ thy false cancel_p t'; |
|
1994 |
|
1995 "--- 8 ---: bottom of output cannot be looked ad (due to looping?)"; |
|
1996 val t = str2term "(a-b)^^^3 * (x+y)^^^4 / ((x+y)^^^2 * (a-b)^^^5)"; |
|
1997 val SOME (t,_) = rewrite_set_ thy false norm_Rational t; |
|
1998 |
|
1999 "--- 9 ---: probably error in norm_Rational"; |
|
2000 val t = str2term ( |
|
2001 "((12*x*y / (9*x^^^2 - y^^^2)) / (1/(3*x - y)^^^2 - 1/(3*x + y)^^^2)) *" ^ |
|
2002 "(1/(x - 5*y)^^^2 - 1/(x + 5*y)^^^2) / (20*x*y/(x^^^2 - 25*y^^^2))"); |
|
2003 rewrite_set_ thy false norm_Rational t; |
|
2004 (*#### rls: cancel_p on: (19440 * (x ^^^ 8 * y ^^^ 2) + -490320 * (x ^^^ 6 * y ^^^ 4) + |
|
2005 108240 * (x ^^^ 4 * y ^^^ 6) + |
|
2006 -6000 * (x ^^^ 2 * y ^^^ 8)) / |
|
2007 (2160 * (x ^^^ 8 * y ^^^ 2) + -108240 * (x ^^^ 6 * y ^^^ 4) + |
|
2008 1362000 * (x ^^^ 4 * y ^^^ 6) + |
|
2009 -150000 * (x ^^^ 2 * y ^^^ 8)) *) |
|
2010 |
|
2011 "--- 10 ---: non-terminating with ### add_fract: done t22: error in common_nominator_p "; |
|
2012 val t = str2term (" (a + b * x) / (a + -1 * (b * x)) + (-1 * a + b * x) / (a + b * x)"); |
|
2013 rewrite_set_ thy false common_nominator_p t; (*### add_fract: done t22 *) |
|
2014 common_nominator_p_ thy t; (*loops without output*) |
|
2015 "--- reformulated 10:"; |
|
2016 val t = str2term "(a + -1 * (b * x)) / (a + b * x)"; |
|
2017 rewrite_set_ thy false cancel_p t = NONE; |
|
2018 "--- 11 ---"; |
|
2019 "--- 12 ---"; |
|
2020 "...both are to be considered after common_nominator_p_ is improved"; |
|
2021 --------------------------------------------------------------------------------------/*) |
|
2022 ============ inhibit exn WN130824 TODO ======================================================*) |
|
2023 |
|