src/smltest/IsacKnowledge/rational.sml
changeset 3881 72f0be16d83b
parent 3742 c62938a26b3e
equal deleted inserted replaced
3880:0b0dc38b1106 3881:72f0be16d83b
     3    Copyright (c) Stefan Karnel 2002
     3    Copyright (c) Stefan Karnel 2002
     4    Use is subject to license terms.
     4    Use is subject to license terms.
     5    
     5    
     6 use"../smltest/IsacKnowledge/rational.sml";
     6 use"../smltest/IsacKnowledge/rational.sml";
     7 use"rational.sml";
     7 use"rational.sml";
       
     8 
       
     9 LEGEND WN070906
       
    10    nonterm.SK   marks non-terminating examples
       
    11    ord.SK       PARTIALLY marks crucial ordering examples
       
    12    *SK*         of some (secondary) interest (on 070906)          
     8 ****************************************************************.*)
    13 ****************************************************************.*)
     9 
    14 
    10 (******************************************************************
    15 (******************************************************************
    11 WN060104 transfer marked (*SR..*)examples to the exp-collection
    16 WN060104 transfer marked (*SR..*)examples to the exp-collection
    12  # exp_IsacCore_Simp_Rat_Cancel.xml     from rational.sml    (*SRC*)  10 exp
    17  # exp_IsacCore_Simp_Rat_Cancel.xml     from rational.sml    (*SRC*)  10 exp
   420 term2str t'' = "(-1 - x - y) / (x - y)" (*true*);
   425 term2str t'' = "(-1 - x - y) / (x - y)" (*true*);
   421 
   426 
   422 val t = str2term "(x^^^2 - y^^^2)/(x^^^2 - 2*x*y + y^^^2) + 1 / (x - y)";
   427 val t = str2term "(x^^^2 - y^^^2)/(x^^^2 - 2*x*y + y^^^2) + 1 / (x - y)";
   423 val Some (t',_) = common_nominator_ thy t;
   428 val Some (t',_) = common_nominator_ thy t;
   424 val Some (t'',_) = add_fraction_ thy t;
   429 val Some (t'',_) = add_fraction_ thy t;
   425 term2str t' =
   430 if term2str t' = "(-1 * y ^^^ 2 + x ^^^ 2) / ((-1 * y + x) * (-1 * y + x))\
   426 "(-1 * y ^^^ 2 + x ^^^ 2) / ((-1 * y + x) * (-1 * y + x)) +\n1\
   431 \ +\n1 * (-1 * y + x) / ((-1 * y + x) * (-1 * y + x))" then ()
   427 \ * (-1 * y + x) / ((-1 * y + x) * (-1 * y + x))" (*true*);
   432 else raise error "rational.sml lex-ord 1";
   428 term2str t'' = "(-1 - y - x) / (y - x)" (*true*);
   433 if term2str t'' = "(-1 - y - x) / (y - x)" then ()
   429 (*WN.16.10.02 lexicographische ^^^^^^^ Ordnung  ???SK-*)
   434 else raise error "rational.sml lex-ord 2";
   430 
   435 (*WN.16.10.02 WN070905 lexicographische Ordnung erhalten ! SK.ord*)
   431 
   436 
   432   val t=(term_of o the o (parse thy)) 
   437 
   433   	    "(y^^^2 - x^^^2)/(y^^^2 - 2*y*x + x^^^2)";
   438 val t = str2term "(x^^^2 - y^^^2)/(x^^^2 - 2*x*y + y^^^2)";
   434   val Some (t',_) = norm_expanded_rat_ thy t;
   439 val Some (t',_) = norm_expanded_rat_ thy t; 
   435   term2str t';
   440 if term2str t' = "(x + y) / (x - y)" then ()
   436   "(y + x) / (y - x)";
   441 else raise error "rational.sml term2poly: invalid x ^^^ 2 - y ^^^ 2 1";
   437 (*val Some (t'',_) = norm_rational_ thy t;
   442 (*val Some (t'',_) = norm_rational_ thy t;
   438   term2str t'';
   443  *** RATIONALS_TERM2POLY_EXCEPTION: Invalid Polynomial 
   439   *** RATIONALS_TERM2POLY_EXCEPTION: Invalid Polynomial 
   444 WN.16.10.02 ?! + WN060831???SK4 
   440   WN.16.10.02 ?! + WN060831???SK4*)
   445 WN070905 *** term2poly: invalid = x ^^^ 2 - y ^^^ 2*)
       
   446 
   441  
   447  
   442   val t=(term_of o the o (parse thy)) 
   448 val t = str2term "(9 - x^^^2)/(9 - 6*x + x^^^2) + (1)/(3 + x)";
   443 	    "(9 - x^^^2)/(9 - 6*x + x^^^2) + (1)/(3 + x)";
   449 val Some (t',_) = norm_expanded_rat_ thy t;
   444   val Some (t',_) = norm_expanded_rat_ thy t;
   450 if term2str t' = "(12 + 5 * x + x ^^^ 2) / (9 - x ^^^ 2)" then ()
   445   term2str t';
   451 else raise error "rational.sml (9 - x^^^2)/(9 - 6*x + x^^^2) +...";
   446   "(12 + 5 * x + x ^^^ 2) / (9 - x ^^^ 2)";
       
   447 (*val Some (t'',_) = norm_rational_ thy t;
   452 (*val Some (t'',_) = norm_rational_ thy t;
   448   term2str t'';
   453   *** RATIONALS_TERM2POLY_EXCEPTION: Invalid Polynomial WN.16.10.02 ?!
   449   *** RATIONALS_TERM2POLY_EXCEPTION: Invalid Polynomial
   454 WN070906 *** term2poly: invalid = 9 - x ^^^ 2 SK.term2poly*)
   450   WN.16.10.02 ?!*)
       
   451  
   455  
   452   val t=(term_of o the o (parse thy)) 
   456   val t=(term_of o the o (parse thy)) 
   453 	    "(9 + (-1)* x^^^2)/(9 + (-1)* 6*x + x^^^2) + (1)/(3 + x)";
   457 	    "(9 + (-1)* x^^^2)/(9 + (-1)* 6*x + x^^^2) + (1)/(3 + x)";
   454   val Some (t',_) = norm_expanded_rat_ thy t;
   458   val Some (t',_) = norm_expanded_rat_ thy t;
   455   val Some (t'',_) = norm_rational_ thy t;
   459   val Some (t'',_) = norm_rational_ thy t;
   968 val t = str2term "(1/2 + (5*x)/2)^^^2 - ((13*x)/2 - 5/2)^^^2 - (6*x)^^^2 + 29";
   972 val t = str2term "(1/2 + (5*x)/2)^^^2 - ((13*x)/2 - 5/2)^^^2 - (6*x)^^^2 + 29";
   969 val Some (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
   973 val Some (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
   970 (*before 040209:if term2str t' = "(23 + (35 * x + -72 * x ^^^ 2)) / 1"then()*) 
   974 (*before 040209:if term2str t' = "(23 + (35 * x + -72 * x ^^^ 2)) / 1"then()*) 
   971 if term2str t' = "23 + 35 * x + -72 * x ^^^ 2" then ()
   975 if term2str t' = "23 + 35 * x + -72 * x ^^^ 2" then ()
   972 else raise error "rational.sml 3";
   976 else raise error "rational.sml 3";
   973 trace_rewrite:=true;
   977 (*trace_rewrite:=true;*)
   974 val t = str2term "Not (6*x is_atom)";
   978 val t = str2term "Not (6*x is_atom)";
   975 val Some (t',_) = rewrite_set_ thy false powers_erls t; term2str t';
   979 val Some (t',_) = rewrite_set_ thy false powers_erls t; term2str t';
   976 "True";
   980 "True";
   977 val t = str2term "1 < 2";
   981 val t = str2term "1 < 2";
   978 val Some (t',_) = rewrite_set_ thy false powers_erls t; term2str t';
   982 val Some (t',_) = rewrite_set_ thy false powers_erls t; term2str t';
  1033 val Some (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
  1037 val Some (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
  1034 "(-500 * (x * y ^^^ 3) /\n (x ^^^ 4 + (625 * y ^^^ 4 + -50 * (x ^^^ 2 * y ^^^ 2))) +\n 20 * (x * (y * x ^^^ 2)) /\n (x ^^^ 4 + (625 * y ^^^ 4 + -50 * (x ^^^ 2 * y ^^^ 2)))) /\n(20 * (x * y))";
  1038 "(-500 * (x * y ^^^ 3) /\n (x ^^^ 4 + (625 * y ^^^ 4 + -50 * (x ^^^ 2 * y ^^^ 2))) +\n 20 * (x * (y * x ^^^ 2)) /\n (x ^^^ 4 + (625 * y ^^^ 4 + -50 * (x ^^^ 2 * y ^^^ 2)))) /\n(20 * (x * y))";
  1035 trace_rewrite:=true;
  1039 trace_rewrite:=true;
  1036 trace_rewrite:=false;
  1040 trace_rewrite:=false;
  1037 
  1041 
  1038 (*WN.17.3.03 =========================================================^^^---*)
  1042 "nonterm.SK6 ----- SK060904-2a non-termination of add_fraction_p_";
  1039 
  1043 (*WN.2.6.03 from rlang.sml 56a 
  1040 
       
  1041 "----- SK060904-2a non-termination of add_fraction_p_";
       
  1042 (*WN.2.6.03 from rlang.sml 56a =======================================vvv---*)
       
  1043 (*... takes uncredible much time:*)
       
  1044 (*
       
  1045 WN060831????SK6
       
  1046 "----- SK060904-2a non-termination of add_fraction_p_";
       
  1047 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)";
  1044 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)";
  1048 val None = rewrite_set_ thy false common_nominator_p t;
  1045 val None = rewrite_set_ thy false common_nominator_p t;
  1049 writeln
  1046 
  1050 "----- rational.sml: add_fraction_p_ throws overflow exn ! -----\n\
  1047 WN060831 nonterm.SK7 
  1051 \----- rational.sml: add_fraction_p_ throws overflow exn ! -----\n\
       
  1052 \----- rational.sml: add_fraction_p_ throws overflow exn ! -----\n\
       
  1053 \----- rational.sml: add_fraction_p_ throws overflow exn ! -----\n\
       
  1054 \----- rational.sml: add_fraction_p_ throws overflow exn ! -----\n";
       
  1055 WN060831????SK7 
       
  1056 
       
  1057 val t = str2term "(a + b * x) / (a + -1 * (b * x)) + (-1 * a + b * x) / (a + b * x)";
  1048 val t = str2term "(a + b * x) / (a + -1 * (b * x)) + (-1 * a + b * x) / (a + b * x)";
  1058 val None = add_fraction_p_ thy t; 
  1049 val None = add_fraction_p_ thy t; 
  1059 *)
  1050 *)
  1060 
  1051 
  1061 (*
  1052 
  1062 GC #1.48.88.223.2775.290178:   (0 ms)
  1053 (* ------------------------------------------------------------------- *)
  1063 GC #1.48.88.223.2776.290363:   (0 ms)
       
  1064 GC #1.48.88.223.2777.290712:   (0 ms)
       
  1065 GC #1.48.88.223.2778.291102:   (0 ms)
       
  1066 GC #1.48.88.223.2779.291684:   (0 ms)
       
  1067 GC #1.48.88.223.2780.292389:   (0 ms)
       
  1068 GC #1.48.88.223.2781.293163:   (0 ms)
       
  1069 GC #1.48.88.223.2782.294133:   (0 ms)
       
  1070 GC #1.48.88.223.2783.295181:   (0 ms)
       
  1071 *)
       
  1072 (*WN.2.6.03 from rlang.sml 56a =======================================^^^---*)
       
  1073 
       
  1074 
       
  1075 
       
  1076 (* 25.08.03:  Durchlauf(rechen)zeit: 1 min *)
       
  1077 
       
  1078 (*---------vvv------------ MG: ab 1.7.03 ----------------vvv-----------*)
  1054 (*---------vvv------------ MG: ab 1.7.03 ----------------vvv-----------*)
  1079 
  1055 (*                 Simplifier fuer beliebige Buchterme                 *) 
  1080 (* ------------------------------------------------------------------- *)
  1056 (* ------------------------------------------------------------------- *)
  1081 (*                  Simplifier fr beliebige Buchterme                 *) 
  1057 (*----------------------- norm_Rational_mg ----------------------------*)
  1082 (* ------------------------------------------------------------------- *)
  1058 (* ------------------------------------------------------------------- *)
  1083 (*----------------------- norm_Rational_mg --------------------------*)
       
  1084 (* ------------------------------------------------------------------- *)
       
  1085 
       
  1086 
  1059 
  1087 "-------- numeral rationals --------------------------------------";
  1060 "-------- numeral rationals --------------------------------------";
  1088 "-------- numeral rationals --------------------------------------";
  1061 "-------- numeral rationals --------------------------------------";
  1089 "-------- numeral rationals --------------------------------------";
  1062 "-------- numeral rationals --------------------------------------";
  1090 
  1063 
  1091 (*SRA Schalk I, p.40 Nr. 164b *)
  1064 (*SRA Schalk I, p.40 Nr. 164b *)
  1092 val t = str2term "(47/6 - 76/9 + 13/4)/(35/12)";
  1065 val t = str2term "(47/6 - 76/9 + 13/4)/(35/12)";
  1093 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
  1066 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
  1094 term2str t;
  1067 term2str t;
  1095 if (term2str t) = 
  1068 if (term2str t) = "19 / 21" then ()
  1096 "19 / 21"
       
  1097 then ()
       
  1098 else raise error "rational.sml.sml: diff.behav. in norm_Rational_mg 1";
  1069 else raise error "rational.sml.sml: diff.behav. in norm_Rational_mg 1";
  1099 
  1070 
  1100 (*SRA Schalk I, p.40 Nr. 166a *)
  1071 (*SRA Schalk I, p.40 Nr. 166a *)
  1101 val t = str2term "((5/4)/(4+22/7) + 37/20)*(110/3 - 110/9 * 23/11)";
  1072 val t = str2term "((5/4)/(4+22/7) + 37/20)*(110/3 - 110/9 * 23/11)";
  1102 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
  1073 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
  1103 term2str t;
  1074 term2str t;
  1104 if (term2str t) = 
  1075 if (term2str t) = "45 / 2" then ()
  1105 "45 / 2"
       
  1106 then ()
       
  1107 else raise error "rational.sml.sml: diff.behav. in norm_Rational_mg 2";
  1076 else raise error "rational.sml.sml: diff.behav. in norm_Rational_mg 2";
  1108 
  1077 
  1109 
  1078 
  1110 "-------- cancellation -------------------------------------------";
  1079 "-------- cancellation -------------------------------------------";
  1111 "-------- cancellation -------------------------------------------";
  1080 "-------- cancellation -------------------------------------------";
  1340 "5 * a / (a + -1 * b)"
  1309 "5 * a / (a + -1 * b)"
  1341 then ()
  1310 then ()
  1342 else raise error "rational.sml.sml: diff.behav. in norm_Rational_mg 23";
  1311 else raise error "rational.sml.sml: diff.behav. in norm_Rational_mg 23";
  1343 
  1312 
  1344 (*Schalk I, p.68 Nr. 437a *)
  1313 (*Schalk I, p.68 Nr. 437a *)
  1345 (* SK loops: rechnet ewig; cancel_p h???gt sich auf... WN060420????MG4 *)
       
  1346 (* corrected *)
       
  1347 val t = str2term "(3*a - 4*b)/(4*c+3*e) * (3*a+4*b)/(9*a^^^2 - 16*b^^^2)";
  1314 val t = str2term "(3*a - 4*b)/(4*c+3*e) * (3*a+4*b)/(9*a^^^2 - 16*b^^^2)";
  1348 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
  1315 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
  1349 if (term2str t) = "1 / (4 * c + 3 * e)" then ()
  1316 if (term2str t) = "1 / (4 * c + 3 * e)" then ()
  1350 else raise error "rational.sml.sml: diff.behav. in norm_Rational_mg 24";
  1317 else raise error "rational.sml.sml: diff.behav. in norm_Rational_mg 24";
  1351 (**)
  1318 
  1352 
  1319 "----- S.K. corrected non-termination 060904";
  1353 (*SK loops .. WN060420????MG5 not canceled to "1 / (4*c + 3*e)"*)
       
  1354 (* corrected *)
       
  1355 val t = str2term "(3*a - 4*b) * (3*a+4*b)/((4*c+3*e)*(9*a^^^2 - 16*b^^^2))";
  1320 val t = str2term "(3*a - 4*b) * (3*a+4*b)/((4*c+3*e)*(9*a^^^2 - 16*b^^^2))";
  1356 val Some (t',_) = rewrite_set_ thy false make_polynomial t;
  1321 val Some (t',_) = rewrite_set_ thy false make_polynomial t;
  1357 term2str t' = "(9 * a ^^^ 2 + -16 * b ^^^ 2) /\n(36 * a ^^^ 2 * c + 27 * a ^^^ 2 * e + -64 * b ^^^ 2 * c +\n -48 * b ^^^ 2 * e)";
  1322 if term2str t' = "(9 * a ^^^ 2 + -16 * b ^^^ 2) /\n(36 * a ^^^ 2 * c + 27 * a ^^^ 2 * e + -64 * b ^^^ 2 * c +\n -48 * b ^^^ 2 * e)" then ()
  1358 (*..WN060831 _with_ parentheses ...*)
  1323 else raise error "rational.sml.sml: S.K.8..corrected 060904-6";
  1359 "----- SK060904-1b non-termination of cancel_p_";
  1324 
       
  1325 "----- S.K. corrected non-termination of cancel_p_";
  1360 val t'' = str2term "(9 * a ^^^ 2 + -16 * b ^^^ 2) /\
  1326 val t'' = str2term "(9 * a ^^^ 2 + -16 * b ^^^ 2) /\
  1361 \(36 * a^^^2 * c + (27 * a^^^2 * e + (-64 * b^^^2 * c + -48 * b^^^2 * e)))";
  1327 \(36 * a^^^2 * c + (27 * a^^^2 * e + (-64 * b^^^2 * c + -48 * b^^^2 * e)))";
  1362 (* WN060831????SK8*)
       
  1363 val Some (t',_) = rewrite_set_ thy false cancel_p t'';
  1328 val Some (t',_) = rewrite_set_ thy false cancel_p t'';
  1364 term2str t';
  1329 if term2str t' = "1 / (4 * c + 3 * e)" then ()
       
  1330 else raise error "rational.sml.sml: diff.behav. in cancel_p S.K.8";
  1365 
  1331 
  1366 (**)
  1332 (**)
  1367 
  1333 
  1368 (*Schalk I, p.68 Nr. 437b *)
  1334 (*Schalk I, p.68 Nr. 437b *)
  1369 (* SK loops, Falsches Ergebnis: cancel_p kann nicht weiter krzen!!! *)
  1335 (* nonterm.SK9 loops: cancel_p kann nicht weiter kuerzen!!! *)
  1370 val t = str2term "(a + b)/(x^^^2 - y^^^2) * ((x - y)^^^2/(a^^^2 - b^^^2))";
  1336 val t'' = str2term "(a + b)/(x^^^2 - y^^^2) * ((x - y)^^^2/(a^^^2 - b^^^2))";
  1371 (*
  1337 (* val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t'';
  1372 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
  1338    *)
  1373 term2str t; WN060831????SK9
  1339 
  1374 "(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)";
  1340 (*a casual output from above*)
       
  1341 val t = str2term 
       
  1342 "(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)"; 
       
  1343 (* WN060831 nonterm.SK10 
       
  1344 val Some (t,_) = rewrite_set_ thy false cancel_p t;
       
  1345 term2str t;
  1375 *)
  1346 *)
  1376 
  1347 
  1377 (* *)
       
  1378 val t = str2term 
       
  1379 "(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)"; 
       
  1380 (* WN060831????SK10 
       
  1381 val Some (t,_) = rewrite_set_ thy false cancel_p t;
       
  1382 term2str t;
       
  1383 *)
       
  1384 
       
  1385 (*SRM Schalk I, p.68 Nr. 438a *)
  1348 (*SRM Schalk I, p.68 Nr. 438a *)
  1386 val t = str2term 
  1349 val t = str2term 
  1387 "x*y/(x*y - y^^^2)*(x^^^2 - x*y)";
  1350 "x*y/(x*y - y^^^2)*(x^^^2 - x*y)";
  1388 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
  1351 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
  1389 term2str t;
  1352 term2str t;
  1410 if (term2str t) =
  1373 if (term2str t) =
  1411 "(-3 + x) / (2 + x)"
  1374 "(-3 + x) / (2 + x)"
  1412 then ()
  1375 then ()
  1413 else raise error "rational.sml.sml: diff.behav. in norm_Rational_mg 26";
  1376 else raise error "rational.sml.sml: diff.behav. in norm_Rational_mg 26";
  1414 
  1377 
  1415 (*Schalk I, p.68 Nr. 440b *)
  1378 "----- Schalk I, p.68 Nr. 440b SK11 works since 0707xx";
  1416 (* Achtung: rechnet ewig; cancel_p h???gt sich auf... WN060831????SK11
       
  1417 val t = str2term 
  1379 val t = str2term 
  1418 "(a^^^3 - 9*a)/(a^^^3*b - a*b^^^3)*(a^^^2*b+a*b^^^2)/(a+3)";
  1380 "(a^^^3 - 9*a)/(a^^^3*b - a*b^^^3)*(a^^^2*b+a*b^^^2)/(a+3)";
  1419 trace_rewrite := true;
  1381 val Some (t,_) = rewrite_set_ thy false norm_Rational t;
  1420 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
  1382 if term2str t = "(-3 * a + a ^^^ 2) / (a + -1 * b)" then ()
  1421 ###  rls: cancel_p on: 
  1383 else raise error "rational.sml.sml: diff.behav. in norm_Rational 27";
  1422 (-9 * (a ^ 3 * b) + -9 * (a ^ 2 * b ^ 2) + a ^ 5 * b + a ^ 4 * b ^ 2) /
  1384 
  1423 (3 * (a ^ 3 * b) + -3 * (a * b ^ 3) + a ^ 4 * b + -1 * (a ^ 2 * b ^ 3))
  1385 "----- SK12 works since 0707xx";
  1424 trace_rewrite := false;
       
  1425 term2str t;
       
  1426 if (term2str t) =
       
  1427 then ()
       
  1428 else raise error "rational.sml.sml: diff.behav. in norm_Rational_mg 27";
       
  1429 
       
  1430 val t = str2term "(a^^^3 - 9*a)*(a^^^2*b+a*b^^^2)/((a^^^3*b - a*b^^^3)*(a+3))";
  1386 val t = str2term "(a^^^3 - 9*a)*(a^^^2*b+a*b^^^2)/((a^^^3*b - a*b^^^3)*(a+3))";
  1431 val Some (t',_) = rewrite_set_ thy false make_polynomial t;
  1387 val Some (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
  1432 term2str t';
  1388 if term2str t' = "(-3 * a + a ^^^ 2) / (a + -1 * b)" then ()
  1433 "(-9 * a ^^^ 3 * b + -9 * a ^^^ 2 * b ^^^ 2 + a ^^^ 5 * b + a ^^^ 4 * b ^^^ 2)/
  1389 else raise error "rational.sml.sml: diff.behav. in norm_Rational 28";
  1434 (3 * a ^^^ 3 * b + -3 * a * b ^^^ 3 + a ^^^ 4 * b + -1 * a ^^^ 2 * b ^^^ 3)";
  1390 
  1435 val Some (t',_) = rewrite_set_ thy false cancel_p t;
       
  1436 term2str t';
       
  1437 WN060831????SK12*)
       
  1438 
  1391 
  1439 "-------- common denominator and multiplication ------------------";
  1392 "-------- common denominator and multiplication ------------------";
  1440 "-------- common denominator and multiplication ------------------";
  1393 "-------- common denominator and multiplication ------------------";
  1441 "-------- common denominator and multiplication ------------------";
  1394 "-------- common denominator and multiplication ------------------";
  1442 
  1395 
  1443 (*----------------------------------------------------------------------*)
  1396 (*----------------------------------------------------------------------*)
  1444 (*--------- Gemeinsamer Nenner und Multiplikation von Brchen ----------*)
  1397 (*--------- Gemeinsamer Nenner und Multiplikation von Bruechen ---------*)
  1445 (*----------------------------------------------------------------------*)
  1398 (*----------------------------------------------------------------------*)
  1446 
  1399 
  1447 
  1400 
  1448 (*SRAM Schalk I, p.69 Nr. 441b *)
  1401 (*SRAM Schalk I, p.69 Nr. 441b *)
  1449 val t = str2term "(4*a/3 + 3*b^^^2/a^^^3 + b/(4*a))*(4*b/(3*a))";
  1402 val t = str2term "(4*a/3 + 3*b^^^2/a^^^3 + b/(4*a))*(4*b/(3*a))";
  1528 val t = str2term 
  1481 val t = str2term 
  1529 "(a^^^2 + 1)/(a^^^2 - 1) / ((a+1)/(a - 1))";
  1482 "(a^^^2 + 1)/(a^^^2 - 1) / ((a+1)/(a - 1))";
  1530 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
  1483 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
  1531 term2str t;
  1484 term2str t;
  1532 if (term2str t) = 
  1485 if (term2str t) = 
  1533 "(1 + a ^^^ 2) / (1 + 2 * a + a ^^^ 2)"
  1486 "(1 + a ^^^ 2) / (1 + 2 * a + a ^^^ 2)" then ()
  1534 then ()
       
  1535 else raise error "rational.sml.sml: diff.behav. in norm_Rational_mg 36";
  1487 else raise error "rational.sml.sml: diff.behav. in norm_Rational_mg 36";
  1536 
  1488 
  1537 
  1489 
  1538 (*Schalk I, p.69 Nr. 455b *)
  1490 "----- Schalk I, p.69 Nr. 455b";
  1539 (* Achtung: Endlosschleife
       
  1540 val t = str2term "(x^^^2 - 4)/(y^^^2 - 9)/((2+x)/(3 - y))";
  1491 val t = str2term "(x^^^2 - 4)/(y^^^2 - 9)/((2+x)/(3 - y))";
  1541 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
  1492 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
  1542 term2str t;
  1493 if term2str t = "(2 + -1 * x) / (3 + y)" then ()
  1543 if (term2str t) = 
       
  1544 
       
  1545 then ()
       
  1546 else raise error "rational.sml.sml: diff.behav. in norm_Rational_mg 37";
  1494 else raise error "rational.sml.sml: diff.behav. in norm_Rational_mg 37";
  1547 
  1495 
  1548 "----- SK060904-1a non-termination of cancel_p_";
  1496 "----- SK060904-1a non-termination of cancel_p_ ?: worked before 0707xx";
  1549 val t = str2term "(x^^^2 - 4)*(3 - y)/((y^^^2 - 9)*(2+x))";
  1497 val t = str2term "(x^^^2 - 4)*(3 - y)/((y^^^2 - 9)*(2+x))";
  1550 val Some (t,_) = rewrite_set_ thy false make_polynomial t;
  1498 val Some (t,_) = rewrite_set_ thy false norm_Rational t;
  1551 term2str t;
  1499 if term2str t = "(2 + -1 * x) / (3 + y)" then ()
  1552 "(-12 + 4 * y + 3 * x ^^^ 2 + -1 * x ^^^ 2 * y) /
  1500 else raise error "rational.sml.sml: diff.behav. in norm_Rational_mg 37b";
  1553 (-18 + -9 * x + 2 * y ^^^ 2 + x * y ^^^ 2)"
  1501 
  1554 val Some (t,_) = rewrite_set_ thy false cancel_p t;
  1502 "----- ?: worked before 0707xx";
  1555 term2str t;
       
  1556 (* Achtung: rechnet ewig; cancel_p h???gt sich auf... ????SK*)
       
  1557 
       
  1558 val t = str2term "(3 + -1 * y) / (-9 + y ^^^ 2)";
  1503 val t = str2term "(3 + -1 * y) / (-9 + y ^^^ 2)";
  1559 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
  1504 val Some (t,_) = rewrite_set_ thy false norm_Rational t;
  1560 term2str t;
  1505 if term2str t = "-1 / (3 + y)" then ()
  1561 (*ENDLOSSCHLEIFE!!! ???MG!!!*)
  1506 else raise error "rational.sml: -1 / (3 + y) norm_Rational";
  1562 
       
  1563 val t = str2term "-1 / (3 + y)";
       
  1564 (*                ~~         *)
       
  1565 val Some (t,_) = rewrite_set_ thy false cancel_p t;
       
  1566 term2str t = "-1 / (3 + 1 * y)";
       
  1567 (********* Das ist das PROBLEM !!!!!!!??? *******************)
       
  1568 (*MG: -1 im Z???ler der Angabe verursacht das Problem ! WN060831???MG!!SK0*)
       
  1569 *)
       
  1570 
  1507 
  1571 (*SRD Schalk I, p.69 Nr. 456b *)
  1508 (*SRD Schalk I, p.69 Nr. 456b *)
  1572 val t = str2term 
  1509 val t = str2term 
  1573 "(b^^^3 - b^^^2)/(b^^^2+b)/(b^^^2 - 1)";
  1510 "(b^^^3 - b^^^2)/(b^^^2+b)/(b^^^2 - 1)";
  1574 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
  1511 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
  1575 term2str t;
  1512 term2str t;
  1576 if (term2str t) = 
  1513 if (term2str t) = "b / (1 + 2 * b + b ^^^ 2)" then ()
  1577 "b / (1 + 2 * b + b ^^^ 2)"
       
  1578 then ()
       
  1579 else raise error "rational.sml.sml: diff.behav. in norm_Rational_mg 38";
  1514 else raise error "rational.sml.sml: diff.behav. in norm_Rational_mg 38";
  1580 
  1515 
  1581 (*SRD Schalk I, p.69 Nr. 457b *)
  1516 (*SRD Schalk I, p.69 Nr. 457b *)
  1582 val t = str2term 
  1517 val t = str2term 
  1583 "(16*a^^^2 - 9*b^^^2)/(2*a+3*a*b) / ((4*a+3*b)/(4*a^^^2 - 9*a^^^2*b^^^2))";
  1518 "(16*a^^^2 - 9*b^^^2)/(2*a+3*a*b) / ((4*a+3*b)/(4*a^^^2 - 9*a^^^2*b^^^2))";
  1586 if (term2str t) = 
  1521 if (term2str t) = 
  1587 "8 * a ^^^ 2 + -6 * a * b + -12 * a ^^^ 2 * b + 9 * a * b ^^^ 2"
  1522 "8 * a ^^^ 2 + -6 * a * b + -12 * a ^^^ 2 * b + 9 * a * b ^^^ 2"
  1588 then ()
  1523 then ()
  1589 else raise error "rational.sml.sml: diff.behav. in norm_Rational_mg 39";
  1524 else raise error "rational.sml.sml: diff.behav. in norm_Rational_mg 39";
  1590 
  1525 
  1591 (*Schalk I, p.69 Nr. 458b *)
  1526 "----- Schalk I, p.69 Nr. 458b works since 0707";
  1592 (* Achtung: rechnet ewig; cancel_p h???gt sich auf... ????SK
       
  1593 val t = str2term 
  1527 val t = str2term 
  1594 "(2*a^^^2*x - a^^^2)/(a*x - b*x) / (b^^^2*(2*x - 1)/(x*(a - b)))";
  1528 "(2*a^^^2*x - a^^^2)/(a*x - b*x) / (b^^^2*(2*x - 1)/(x*(a - b)))";
  1595 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
  1529 val Some (t,_) = rewrite_set_ thy false norm_Rational t;
  1596 term2str t;
  1530 if term2str t = "a ^^^ 2 / b ^^^ 2" then ()
  1597 if (term2str t) = 
  1531 else raise error "rational.sml.sml: diff.behav. in norm_Rational_mg 39b";
  1598 
       
  1599 then ()
       
  1600 else raise error "rational.sml.sml: diff.behav. in norm_Rational_mg 40";
       
  1601 *)
       
  1602 
  1532 
  1603 (*SRD Schalk I, p.69 Nr. 459b *)
  1533 (*SRD Schalk I, p.69 Nr. 459b *)
  1604 val t = str2term 
  1534 val t = str2term "(a^^^2 - b^^^2)/(a*b) / (4*(a+b)^^^2/a)";
  1605 "(a^^^2 - b^^^2)/(a*b) / (4*(a+b)^^^2/a)";
  1535 val Some (t,_) = rewrite_set_ thy false norm_Rational t;
  1606 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
  1536 if term2str t = "(a + -1 * b) / (4 * a * b + 4 * b ^^^ 2)" then ()
  1607 term2str t;
       
  1608 if (term2str t) = 
       
  1609 "(a + -1 * b) / (4 * a * b + 4 * b ^^^ 2)"
       
  1610 then ()
       
  1611 else raise error "rational.sml.sml: diff.behav. in norm_Rational_mg 41";
  1537 else raise error "rational.sml.sml: diff.behav. in norm_Rational_mg 41";
  1612 
  1538 
  1613 
  1539 
  1614 (*Schalk I, p.69 Nr. 460b *)
  1540 (*Schalk I, p.69 Nr. 460b nonterm.SK
  1615 (* Achtung: rechnet ewig; cancel_p h???gt sich auf... ????SK
       
  1616 val t = str2term 
  1541 val t = str2term 
  1617 "(9*(x^^^2 - 8*x+16)/(4*(y^^^2 - 2*y+1)))/((3*x - 12)/(16*y - 16))";
  1542 "(9*(x^^^2 - 8*x+16)/(4*(y^^^2 - 2*y+1)))/((3*x - 12)/(16*y - 16))";
  1618 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
  1543 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
  1619 term2str t;
  1544 if term2str t = 
  1620 if (term2str t) = 
       
  1621 
       
  1622 then ()
  1545 then ()
  1623 else raise error "rational.sml.sml: diff.behav. in norm_Rational_mg 42";
  1546 else raise error "rational.sml.sml: diff.behav. in norm_Rational_mg 42";
  1624 
  1547 
  1625 val t = str2term 
  1548 val t = str2term 
  1626 "9*(x^^^2 - 8*x+16)*(16*y - 16)/(4*(y^^^2 - 2*y+1)*(3*x - 12))";
  1549 "9*(x^^^2 - 8*x+16)*(16*y - 16)/(4*(y^^^2 - 2*y+1)*(3*x - 12))";
  1627 val Some (t,_) = rewrite_set_ thy false make_polynomial t;
  1550 val Some (t',_) = rewrite_set_ thy false norm_Rational t;
  1628 term2str t;
  1551 ... non terminating.
       
  1552 val Some (t',_) = rewrite_set_ thy false make_polynomial t;
  1629 "(-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)";
  1553 "(-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)";
  1630 val Some (t,_) = rewrite_set_ thy false cancel_p t;
  1554 val Some (t,_) = rewrite_set_ thy false cancel_p t';
  1631 term2str t;
  1555 ... non terminating.*)
  1632  ????SK*)
       
  1633 
  1556 
  1634 (*SRD Schalk I, p.70 Nr. 472a *)
  1557 (*SRD Schalk I, p.70 Nr. 472a *)
  1635 val t = str2term "((8*x^^^2 - 32*y^^^2)/(2*x + 4*y))/\
  1558 val t = str2term "((8*x^^^2 - 32*y^^^2)/(2*x + 4*y))/\
  1636 		 \((4*x - 8*y)/(x + y))";
  1559 		 \((4*x - 8*y)/(x + y))";
  1637 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
  1560 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
  1695 "3 * b ^^^ 3 / (2 * a + -2 * b)"
  1618 "3 * b ^^^ 3 / (2 * a + -2 * b)"
  1696 then ()
  1619 then ()
  1697 else raise error "rational.sml.sml: diff.behav. in norm_Rational_mg 48";
  1620 else raise error "rational.sml.sml: diff.behav. in norm_Rational_mg 48";
  1698 
  1621 
  1699 (*----------------------------------------------------------------------*)
  1622 (*----------------------------------------------------------------------*)
  1700 (*---------------------- Mehrfache Dppelbrche -------------------------*)
  1623 (*---------------------- Mehrfache Dppelbrueche ------------------------*)
  1701 (*----------------------------------------------------------------------*)
  1624 (*----------------------------------------------------------------------*)
  1702 
  1625 
  1703 (*SRD.test Schalk I, p.70 Nr. 476b *) (* Rechenzeit: 10 sec *)
  1626 (*SRD.test Schalk I, p.70 Nr. 476b *) (* Rechenzeit: 10 sec *)
  1704 (*WN060419 crashes with method 'simplify' ????SK*)
  1627 (*WN060419 crashes with method 'simplify' ????SK*)
  1705 val t = str2term 
  1628 val t = str2term 
  1706 "((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)";
  1629 "((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)";
  1707 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
  1630 val Some (t,_) = rewrite_set_ thy false norm_Rational t;
  1708 term2str t;
  1631 if term2str t = "1 / (a ^^^ 2 + -1 * b ^^^ 2)" then ()
  1709 if (term2str t) = 
       
  1710 "1 / (a ^^^ 2 + -1 * b ^^^ 2)"
       
  1711 then ()
       
  1712 else raise error "rational.sml.sml: diff.behav. in norm_Rational_mg 49";
  1632 else raise error "rational.sml.sml: diff.behav. in norm_Rational_mg 49";
  1713 
  1633 
  1714 "----- Schalk I, p.70 Nr. 477a";
  1634 "----- Schalk I, p.70 Nr. 477a";
  1715 (* Achtung: rechnet ewig; Bsp zu komplex; 
  1635 (* MG Achtung: terme explodieren; Bsp zu komplex; 
  1716    L???ung sollte (ziemlich grosser) Faktorisierter Ausdruck sein 
  1636    L???ung sollte (ziemlich grosser) Faktorisierter Ausdruck sein 
  1717 val t = str2term "b*y/(b - 2*y)/((b^^^2 - y^^^2)/(b+2*y)) /\
  1637 val t = str2term "b*y/(b - 2*y)/((b^^^2 - y^^^2)/(b+2*y)) /\
  1718 		 \(b^^^2*y+b*y^^^2)*(a+x)^^^2/((b^^^2 - 4*y^^^2)*(a+2*x)^^^2)";
  1638 		 \(b^^^2*y+b*y^^^2)*(a+x)^^^2/((b^^^2 - 4*y^^^2)*(a+2*x)^^^2)";
  1719 val Some (t',_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
  1639 val Some (t',_) = rewrite_set_ thy false norm_Rational t;
  1720 term2str t';
  1640 
  1721 if (term2str t') = ????SK ???MG
       
  1722 
       
  1723 then ()
       
  1724 else raise error "rational.sml.sml: diff.behav. in norm_Rational_mg 50";
       
  1725 
  1641 
  1726 val t = str2term "b*y*(b+2*y)*(b^^^2 - 4*y^^^2)*(a+2*x)^^^2 / \
  1642 val t = str2term "b*y*(b+2*y)*(b^^^2 - 4*y^^^2)*(a+2*x)^^^2 / \
  1727 		 \((b - 2*y)*(b^^^2 - y^^^2)*(b^^^2*y+b*y^^^2)*(a+x)^^^2)";
  1643 		 \((b - 2*y)*(b^^^2 - y^^^2)*(b^^^2*y+b*y^^^2)*(a+x)^^^2)";
  1728 val Some (t,_) = rewrite_set_ thy false make_polynomial t;
  1644 val Some (t,_) = rewrite_set_ thy false make_polynomial t;
  1729 term2str t; ????SK ???MG
  1645 ????SK ???MG*)
  1730 "(a ^^^ 2 * b ^^^ 4 * y + 2 * a ^^^ 2 * b ^^^ 3 * y ^^^ 2 +\n -4 * a ^^^ 2 * b ^^^ 2 * y ^^^ 3 +\n -8 * a ^^^ 2 * b * y ^^^ 4 +\n 4 * a * b ^^^ 4 * x * y +\n 8 * a * b ^^^ 3 * x * y ^^^ 2 +\n -16 * a * b ^^^ 2 * x * y ^^^ 3 +\n -32 * a * b * x * y ^^^ 4 +\n 4 * b ^^^ 4 * x ^^^ 2 * y +\n 8 * b ^^^ 3 * x ^^^ 2 * y ^^^ 2 +\n -16 * b ^^^ 2 * x ^^^ 2 * y ^^^ 3 +\n -32 * b * x ^^^ 2 * y ^^^ 4) 
  1646 
  1731 /\n(a ^^^ 2 * b ^^^ 5 * y + -1 * a ^^^ 2 * b ^^^ 4 * y ^^^ 2 +\n -3 * a ^^^ 2 * b ^^^ 3 * y ^^^ 3 +\n a ^^^ 2 * b ^^^ 2 * y ^^^ 4 +\n 2 * a ^^^ 2 * b * y ^^^ 5 +\n 2 * a * b ^^^ 5 * x * y +\n -2 * a * b ^^^ 4 * x * y ^^^ 2 +\n -6 * a * b ^^^ 3 * x * y ^^^ 3 +\n 2 * a * b ^^^ 2 * x * y ^^^ 4 +\n 4 * a * b * x * y ^^^ 5 +\n b ^^^ 5 * x ^^^ 2 * y +\n -1 * b ^^^ 4 * x ^^^ 2 * y ^^^ 2 +\n -3 * b ^^^ 3 * x ^^^ 2 * y ^^^ 3 +\n b ^^^ 2 * x ^^^ 2 * y ^^^ 4 +\n 2 * b * x ^^^ 2 * y ^^^ 5)";
  1647 
  1732 *)
  1648 "----- Schalk I, p.70 Nr. 478b ----- Rechenzeit: 5 sec";
  1733 
       
  1734 (*Schalk I, p.70 Nr. 478b *) (* Rechenzeit: 5 sec *)
       
  1735 val t = str2term "(a - (a*b+b^^^2)/(a+b))/(b+(a - b)/(1+(a+b)/(a - b))) / \
  1649 val t = str2term "(a - (a*b+b^^^2)/(a+b))/(b+(a - b)/(1+(a+b)/(a - b))) / \
  1736 		 \((a - a^^^2/(a+b))/(a+(a*b)/(a - b)))";
  1650 		 \((a - a^^^2/(a+b))/(a+(a*b)/(a - b)))";
  1737 val Some (t',_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
  1651 val Some (t',_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
  1738 term2str t';
       
  1739 (* WN050820 was OK until STOP_REW_SUB introduced -- the ONLY change !!!
       
  1740    ????SK ???MG
       
  1741 if term2str t' = 
  1652 if term2str t' = 
  1742 "(2 * a ^^^ 3 + 2 * a ^^^ 2 * b) / (a ^^^ 2 * b + b ^^^ 3)"
  1653 "(2 * a ^^^ 3 + 2 * a ^^^ 2 * b) / (a ^^^ 2 * b + b ^^^ 3)"
  1743 then ()
  1654 then ()
  1744 else raise error "rational.sml.sml: diff.behav. in norm_Rational_mg 51";
  1655 else raise error "rational.sml.sml: diff.behav. in norm_Rational_mg 51";
  1745 -----------------------------------------------------------------------*)
  1656 
       
  1657 (* TODO.new_c:WN050820 STOP_REW_SUB introduced gave ...
       
  1658 if term2str t' = "(a ^^^ 4 + -1 * a ^^^ 2 * b ^^^ 2) /\n(a * b * (b + (a * (a + -1 * b) + -1 * b * (a + -1 * b)) / (2 * a)) *\n (a + -1 * b))" then ()
       
  1659 else raise error "rational.sml: works again";
       
  1660 re-outcommented with TODO.new_c: cvs before 071227, 11:50*)
       
  1661 
       
  1662 
  1746 
  1663 
  1747 (*Schalk I, p.70 Nr. 480a *)
  1664 (*Schalk I, p.70 Nr. 480a *)
  1748 (* SK Achtung: rechnet ewig; cancel_p kann nicht krzen: WN060831????SK00
  1665 (* Achtung: rechnet ewig; cancel_p kann nicht krzen: WN060831 nonterm.SK00
  1749 val t = str2term 
  1666 val t = str2term 
  1750 "(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)))";
  1667 "(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)))";
  1751 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
  1668 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
  1752 term2str t;
  1669 term2str t;
  1753 if (term2str t) = 
  1670 if (term2str t) = 
  1754 
  1671 
  1755 then ()
  1672 then ()
  1756 else raise error "rational.sml.sml: diff.behav. in norm_Rational_mg 52";
  1673 else raise error "rational.sml.sml: diff.behav. in norm_Rational_mg 52";
  1757 
  1674 
  1758 (*MG Berechne Zwischenergebnisse: WN060831????SK00*)
  1675 (*MG Berechne Zwischenergebnisse: WN060831 nonterm.SK00*)
  1759 val t = str2term 
  1676 val t = str2term 
  1760 "(1/x+1/y+1/z)/(1/x - 1/y - 1/z)";
  1677 "(1/x+1/y+1/z)/(1/x - 1/y - 1/z)";
  1761 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
  1678 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
  1762 term2str t;
  1679 term2str t;
  1763 "(x ^^^ 2 * y ^^^ 2 * z + x ^^^ 2 * y * z ^^^ 2 + x * y ^^^ 2 * z ^^^ 2) /
  1680 "(x ^^^ 2 * y ^^^ 2 * z + x ^^^ 2 * y * z ^^^ 2 + x * y ^^^ 2 * z ^^^ 2) /
  1800 
  1717 
  1801 (*Schalk I, p.60 Nr. 215d *)
  1718 (*Schalk I, p.60 Nr. 215d *)
  1802 (* Achtung: rechnet ewig ...
  1719 (* Achtung: rechnet ewig ...
  1803 val t = str2term "(a-b)^^^3 * (x+y)^^^4 / ((x+y)^^^2 * (a-b)^^^5)";
  1720 val t = str2term "(a-b)^^^3 * (x+y)^^^4 / ((x+y)^^^2 * (a-b)^^^5)";
  1804 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
  1721 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
  1805 term2str t;
  1722 term2str t; noterm.SK
  1806 *)
  1723 *)
  1807 
  1724 
  1808 (* Kein Wunder, denn Z???ler und Nenner extra als Polynom dargestellt ergibt:*)
  1725 (* Kein Wunder, denn Z???ler und Nenner extra als Polynom dargestellt ergibt:*)
  1809 (*
  1726 (*
  1810 val t = str2term "(a-b)^^^3 * (x+y)^^^4";
  1727 val t = str2term "(a-b)^^^3 * (x+y)^^^4";
  1817 "a^^^5 * x^^^2 + 2 * a^^^5 * x * y + a^^^5 * y^^^2 +\n-5 * a^^^4 * b * x^^^2 +\n-10 * a^^^4 * b * x * y +\n-5 * a^^^4 * b * y^^^2 +\n10 * a^^^3 * b^^^2 * x^^^2 +\n20 * a^^^3 * b^^^2 * x * y +\n10 * a^^^3 * b^^^2 * y^^^2 +\n-10 * a^^^2 * b^^^3 * x^^^2 +\n-20 * a^^^2 * b^^^3 * x * y +\n-10 * a^^^2 * b^^^3 * y^^^2 +\n5 * a * b^^^4 * x^^^2 +\n10 * a * b^^^4 * x * y +\n5 * a * b^^^4 * y^^^2 +\n-1 * b^^^5 * x^^^2 +\n-2 * b^^^5 * x * y +\n-1 * b^^^5 * y^^^2";
  1734 "a^^^5 * x^^^2 + 2 * a^^^5 * x * y + a^^^5 * y^^^2 +\n-5 * a^^^4 * b * x^^^2 +\n-10 * a^^^4 * b * x * y +\n-5 * a^^^4 * b * y^^^2 +\n10 * a^^^3 * b^^^2 * x^^^2 +\n20 * a^^^3 * b^^^2 * x * y +\n10 * a^^^3 * b^^^2 * y^^^2 +\n-10 * a^^^2 * b^^^3 * x^^^2 +\n-20 * a^^^2 * b^^^3 * x * y +\n-10 * a^^^2 * b^^^3 * y^^^2 +\n5 * a * b^^^4 * x^^^2 +\n10 * a * b^^^4 * x * y +\n5 * a * b^^^4 * y^^^2 +\n-1 * b^^^5 * x^^^2 +\n-2 * b^^^5 * x * y +\n-1 * b^^^5 * y^^^2";
  1818 *)
  1735 *)
  1819 (*anscheinend macht dem Rechner das Krzen diese Bruches keinen Spass mehr ...*)
  1736 (*anscheinend macht dem Rechner das Krzen diese Bruches keinen Spass mehr ...*)
  1820 
  1737 
  1821 (*--------------------------------------------------------------------*)
  1738 (*--------------------------------------------------------------------*)
  1822 (*Schalk I, p.70 Nr. 480b *)
  1739 (*Schalk I, p.70 Nr. 480b 
  1823 (*
       
  1824 trace_rewrite:=false; (*sonst dauert Berechnung sehr lange!*)
       
  1825 
       
  1826 val t = str2term "((12*x*y/(9*x^^^2 - y^^^2))/\
  1740 val t = str2term "((12*x*y/(9*x^^^2 - y^^^2))/\
  1827 		 \(1/(3*x - y)^^^2 - 1/(3*x + y)^^^2)) *\
  1741 		 \(1/(3*x - y)^^^2 - 1/(3*x + y)^^^2)) *\
  1828 		 \(1/(x - 5*y)^^^2 - 1/(x + 5*y)^^^2)/\
  1742 		 \(1/(x - 5*y)^^^2 - 1/(x + 5*y)^^^2)/\
  1829 		 \(20*x*y/(x^^^2 - 25*y^^^2))";
  1743 		 \(20*x*y/(x^^^2 - 25*y^^^2))";
  1830 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
  1744 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
  1831 term2str t;
  1745 SK.nonterm
  1832 "((180 * x^^^4 * y + 675 * x^^^3 * y^^^2 + 1105 * x^^^2 * y^^^3 +\n  -75 * x * y^^^4 +\n  -125 * y^^^5) /\n (x^^^3 + 5 * x^^^2 * y + -25 * x * y^^^2 + -125 * y^^^3) +\n (225 * x^^^2 * y^^^2 + -25 * y^^^4) /\n (x^^^2 + 10 * x * y + 25 * y^^^2)) /\n(20 * x * y)";
  1746 Kann nicht weiter vereinfacht werden !!!!?? *)
  1833 *)
       
  1834 (* Kann nicht weiter vereinfacht werden !!!!?? *)
       
  1835 
  1747 
  1836 (*--------------------------------------------------------------------*)
  1748 (*--------------------------------------------------------------------*)
  1837 (*Seltsames in common_nominator_p: *)
  1749 "---- MGs test set";
  1838 (*
  1750 val t = str2term " (1 + x^^^5) / (y + x) + x^^^3 / x ";
  1839 val t = str2term " (1 + x^^^5) / (x + y) + x^^^3 / x ";
       
  1840 (*                                  ~~~~~  !!! *)
       
  1841 val Some (t,_) = rewrite_set_ thy false common_nominator_p t;
  1751 val Some (t,_) = rewrite_set_ thy false common_nominator_p t;
  1842 term2str t;
  1752 if term2str t = "(1 + x ^^^ 3 + x ^^^ 5 + y * x ^^^ 2) / (x + y)" then()
  1843 *)
  1753 else raise error "";
  1844 (*### add_fraction_p_ called
       
  1845 uncaught exception nonexhaustive binding failure
       
  1846   raised at: stdIn:175.1-175.61*)
       
  1847 
       
  1848 val t = str2term " (1 + x^^^5) / (y + x) + x^^^3 / x ";
       
  1849 (*                                  ~~~~~  !!! *)
       
  1850 val Some (t,_) = rewrite_set_ thy false common_nominator_p t;
       
  1851 term2str t;
       
  1852 "(1 + 1 * x^^^3 + 1 * x^^^5 + 1 * (y * x^^^2)) / (1 * x + 1 * y)";
       
  1853 
  1754 
  1854 (*--------------------------------------------------------------------*)
  1755 (*--------------------------------------------------------------------*)
  1855 (* cancel_p liefert nicht immer Polynomnormalform (2): WN060831???SK3b
  1756 (* cancel_p liefert nicht immer Polynomnormalform (2): WN060831???SK3b
  1856    ---> Sortierung FALSCH !!  *)
  1757    ---> Sortierung FALSCH !!  *)
  1857 val t = str2term "b^^^3 * a^^^5/a ";
  1758 val t = str2term "b^^^3 * a^^^5/a ";
  1885 (********* Das ist das PROBLEM !!!!!!!??? *******************)
  1786 (********* Das ist das PROBLEM !!!!!!!??? *******************)
  1886 (* -1 im Z???ler der Angabe verursacht das Problem !*)
  1787 (* -1 im Z???ler der Angabe verursacht das Problem !*)
  1887 *)
  1788 *)
  1888 
  1789 
  1889 (* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *)
  1790 (* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *)
  1890 (*Eigenes*)
  1791 "----- MGs test set";
  1891 (* Achtung: Endlosschleife bei cancel_p:
       
  1892 val t = str2term "(a^^^2 + -1)/(a+1)";
  1792 val t = str2term "(a^^^2 + -1)/(a+1)";
  1893 val Some (t,_) = rewrite_set_ thy false make_polynomial t;
  1793 val Some (t',_) = rewrite_set_ thy false cancel_p t;
  1894 term2str t;
  1794 if term2str t' = "(-1 + a) / 1" then ()
  1895 "(-1 + a^^^2) / (1 + a)";
  1795 else raise error "rational.sml MG tests 3d";
  1896 val Some (t,_) = rewrite_set_ thy false cancel_p t;
  1796 
  1897 term2str t;
  1797 "----- NOT TERMINATING ?: worked before 0707xx";
  1898 "(-1 + 1 * a) / 1"; (*OK*)
       
  1899 *)
       
  1900 
       
  1901 "----- NOT TERMINATING";
       
  1902 val t = str2term "(a^^^2 - 1)*(b + 1) / ((b^^^2 - 1)*(a+1))";
  1798 val t = str2term "(a^^^2 - 1)*(b + 1) / ((b^^^2 - 1)*(a+1))";
  1903 val Some (t',_) = rewrite_set_ thy false make_polynomial t;
  1799 val Some (t'',_) = rewrite_set_ thy false norm_Rational t;
  1904 term2str t' =
  1800 if term2str t'' = "(1 + -1 * a) / (1 + -1 * b)" then ()
  1905    "(-1 + -1 * b + a ^^^ 2 + a ^^^ 2 * b) /\n(-1 + -1 * a + b ^^^ 2 + a * b ^^^ 2)";
  1801 else raise error "rational.sml MG tests 3e";
  1906 (* NOT TERMINATING
       
  1907 val Some (t'',_) = rewrite_set_ thy false cancel_p t';
       
  1908 term2str t'';
       
  1909  Endlosschleife*)
       
  1910 
  1802 
  1911 "----- corrected SK060905";
  1803 "----- corrected SK060905";
  1912 val t = str2term "(4*x^^^2 - 20*x + 25)/(2*x - 5)^^^3";
  1804 val t = str2term "(4*x^^^2 - 20*x + 25)/(2*x - 5)^^^3";
  1913 val Some (t',_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
  1805 val Some (t',_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
  1914 term2str t' = "-1 / (5 + -2 * x)" (*true*);
  1806 if term2str t' = "-1 / (5 + -2 * x)" then ()
       
  1807 else raise error "rational.sml corrected SK060905";
  1915 
  1808 
  1916 
  1809 
  1917 "--------------------------------------------------------------------";
  1810 "--------------------------------------------------------------------";
  1918 "----------------------- Muster-Beispiele fuer DA -------------------";
  1811 "----------------------- Muster-Beispiele fuer DA -------------------";
  1919 "--------------------------------------------------------------------";
  1812 "--------------------------------------------------------------------";
  2096 val t = str2term "a*b*c*d / (d*e*f*g)";
  1989 val t = str2term "a*b*c*d / (d*e*f*g)";
  2097 val Some (t', _) = cancel_p_ thy t; term2str t';
  1990 val Some (t', _) = cancel_p_ thy t; term2str t';
  2098 
  1991 
  2099 val t = str2term "a*(b*(c*d)) / (b*(e*(f*g)))";
  1992 val t = str2term "a*(b*(c*d)) / (b*(e*(f*g)))";
  2100 val Some (t', _) = cancel_p_ thy t; term2str t';
  1993 val Some (t', _) = cancel_p_ thy t; term2str t';
  2101 (*???SK order ???*)
  1994 (*???order.SK  ???*)
  2102 
  1995 
  2103 "----- SK060904-1a non-termination of cancel_p_ NOT CANCELED";
  1996 "----- SK060904-1a non-termination of cancel_p_ ? worked before 0707xx";
  2104 val t = str2term "(x^^^2 - 4)*(3 - y) / ((y^^^2 - 9)*(2+x))";
  1997 val t = str2term "(x^^^2 - 4)*(3 - y) / ((y^^^2 - 9)*(2+x))";
  2105 val Some (t',_) = rewrite_set_ thy false norm_Poly t; 
  1998 val Some (t',_) = rewrite_set_ thy false norm_Rational t; 
  2106 term2str t' =
  1999 if term2str t' = "(2 + -1 * x) / (3 + y)" then ()
  2107    "(-12 + 4 * y + 3 * x ^^^ 2 + -1 * x ^^^ 2 * y) /\n(-18 + -9 * x + 2 * y ^^^ 2 + x * y ^^^ 2)" (*true NOT CANCELED*);
  2000 else raise error "rational.sml SK060904-1a worked since 0707xx";
  2108 val Some (t'',_) = cancel_p_ thy t'; term2str t' =
  2001 
  2109 "(-12 + 4 * y + 3 * x ^^^ 2 + -1 * x ^^^ 2 * y) /\n(-18 + -9 * x + 2 * y ^^^ 2 + x * y ^^^ 2)" (*true NOT CANCELED*);
  2002 "----- SK060904-1b non-termination of cancel_p_ ... worked before 0707xx";
  2110 
       
  2111 "----- SK060904-1b non-termination of cancel_p_ ... corrected";
       
  2112 val t = str2term "(9 * a ^^^ 2 + -16 * b ^^^ 2) /\
  2003 val t = str2term "(9 * a ^^^ 2 + -16 * b ^^^ 2) /\
  2113 \(36 * a^^^2 * c + (27 * a^^^2 * e + (-64 * b^^^2 * c + -48 * b^^^2 * e)))";
  2004 \(36 * a^^^2 * c + (27 * a^^^2 * e + (-64 * b^^^2 * c + -48 * b^^^2 * e)))";
  2114 val Some (t',_) = cancel_p_ thy t; term2str t' = "1 / (4 * c + 3 * e)"(*true*);
  2005 val Some (t',_) = cancel_p_ thy t; 
       
  2006 if term2str t' = "1 / (4 * c + 3 * e)" then ()
       
  2007 else raise error "rational.sml SK060904-1b";
  2115 
  2008 
  2116 
  2009 
  2117 "----- SK060904-2a non-termination of add_fraction_p_";
  2010 "----- SK060904-2a non-termination of add_fraction_p_";
  2118 val t = str2term " (a + b * x) / (a + -1 * (b * x)) +  \
  2011 val t = str2term " (a + b * x) / (a + -1 * (b * x)) +  \
  2119 		 \ (-1 * a + b * x) / (a + b * x)      ";
  2012 		 \ (-1 * a + b * x) / (a + b * x)      ";
  2120 (*
  2013 (* nonterm.SK
  2121 val Some (t',_) = rewrite_set_ thy false common_nominator_p t;
  2014 val Some (t',_) = rewrite_set_ thy false common_nominator_p t;
  2122 
  2015 
  2123 common_nominator_p_ thy t;
  2016 common_nominator_p_ thy t;
  2124 " (a + b * x)*(a + b * x) / ((a + -1 * (b * x))*(a + -1 * (b * x))) +  \
  2017 " (a + b * x)*(a + b * x) / ((a + -1 * (b * x))*(a + -1 * (b * x))) +  \
  2125 \ (-1 * a + b * x)*(a + -1 * (b * x)) / ((a + b * x)*(-1 * a + b * x)) ";
  2018 \ (-1 * a + b * x)*(a + -1 * (b * x)) / ((a + b * x)*(-1 * a + b * x)) ";