test/Tools/isac/Knowledge/rational-old.sml
branchisac-update-Isa09-2
changeset 38031 460c24a6a6ba
parent 37991 028442673981
child 38043 6a36acec95d9
equal deleted inserted replaced
38030:95d956108461 38031:460c24a6a6ba
    10 (* tests*)
    10 (* tests*)
    11 print("\n\n*********************   tests    *************************\n\n");
    11 print("\n\n*********************   tests    *************************\n\n");
    12 print("\n\n***** divide tests *****\n");
    12 print("\n\n***** divide tests *****\n");
    13 val mv_pquot1 = (#1(mv_division([(1,[1,1,1]),(1,[1,1,0]),(1,[1,0,1]),(1,[0,0,0])],[(1,[1,1,0]),(1,[0,0,0])],LEX_)));
    13 val mv_pquot1 = (#1(mv_division([(1,[1,1,1]),(1,[1,1,0]),(1,[1,0,1]),(1,[0,0,0])],[(1,[1,1,0]),(1,[0,0,0])],LEX_)));
    14 (* result: [(1,[0,0,1]),(1,[0,0,0])] *)
    14 (* result: [(1,[0,0,1]),(1,[0,0,0])] *)
    15 if mv_pquot1=[(1,[0,0,1]),(1,[0,0,0])] then () else raise error ("Test failed");
    15 if mv_pquot1=[(1,[0,0,1]),(1,[0,0,0])] then () else error ("Test failed");
    16 
    16 
    17 val mv_prest1 = (#2(mv_division([(1,[1,1,1]),(1,[1,1,0]),(1,[1,0,1]),(1,[0,0,0])],[(1,[1,1,0]),(1,[0,0,0])],LEX_)));
    17 val mv_prest1 = (#2(mv_division([(1,[1,1,1]),(1,[1,1,0]),(1,[1,0,1]),(1,[0,0,0])],[(1,[1,1,0]),(1,[0,0,0])],LEX_)));
    18 (* result: [(1,[1,0,1]),(~1,[0,0,1])] *)
    18 (* result: [(1,[1,0,1]),(~1,[0,0,1])] *)
    19 if mv_prest1=[(1,[1,0,1]),(~1,[0,0,1])] then () else raise error ("Test failed");
    19 if mv_prest1=[(1,[1,0,1]),(~1,[0,0,1])] then () else error ("Test failed");
    20 
    20 
    21 val mv_pquot2 = (#1(mv_division([(4,[2]),(8,[1]),(16,[0])],[(1,[1]),(1,[0])],LEX_)));
    21 val mv_pquot2 = (#1(mv_division([(4,[2]),(8,[1]),(16,[0])],[(1,[1]),(1,[0])],LEX_)));
    22 (* result: [(4,[1]),(4,[0])] *)
    22 (* result: [(4,[1]),(4,[0])] *)
    23 if mv_pquot2=[(4,[1]),(4,[0])] then () else raise error ("Test failed");
    23 if mv_pquot2=[(4,[1]),(4,[0])] then () else error ("Test failed");
    24 
    24 
    25 val mv_prest2 = (#2(mv_division([(4,[2]),(8,[1]),(16,[0])],[(1,[1]),(1,[0])],LEX_))); 
    25 val mv_prest2 = (#2(mv_division([(4,[2]),(8,[1]),(16,[0])],[(1,[1]),(1,[0])],LEX_))); 
    26 (* result: [(12,[0]] *)
    26 (* result: [(12,[0]] *)
    27 if mv_prest2=[(12,[0])] then () else raise error ("Test failed");
    27 if mv_prest2=[(12,[0])] then () else error ("Test failed");
    28 
    28 
    29 val mv_pquot3 = (#1(mv_division([(4,[2]),(~4,[0])],[(2,[1]),(2,[0])],LEX_)));
    29 val mv_pquot3 = (#1(mv_division([(4,[2]),(~4,[0])],[(2,[1]),(2,[0])],LEX_)));
    30 (* [(2,[1]),(~2,[0])] *)
    30 (* [(2,[1]),(~2,[0])] *)
    31 if mv_pquot3=[(2,[1]),(~2,[0])] then () else raise error ("Test failed");
    31 if mv_pquot3=[(2,[1]),(~2,[0])] then () else error ("Test failed");
    32 
    32 
    33 val mv_prest3 = (#2(mv_division([(1,[2]),(~1,[0])],[(2,[1]),(2,[0])],LEX_)));
    33 val mv_prest3 = (#2(mv_division([(1,[2]),(~1,[0])],[(2,[1]),(2,[0])],LEX_)));
    34 (* [(1,[2]),(~1,[0])] *)
    34 (* [(1,[2]),(~1,[0])] *)
    35 if mv_prest3=[(1,[2]),(~1,[0])] then () else raise error ("Test failed");
    35 if mv_prest3=[(1,[2]),(~1,[0])] then () else error ("Test failed");
    36 
    36 
    37 val mv_pquot4 = (#1(mv_division([(3,[1,1,1]),(4,[1,0,1]),(3,[0,0,1])],[(2,[1,0,0]),(4,[0,0,1])],LEX_)));
    37 val mv_pquot4 = (#1(mv_division([(3,[1,1,1]),(4,[1,0,1]),(3,[0,0,1])],[(2,[1,0,0]),(4,[0,0,1])],LEX_)));
    38 (* [(1,[0,1,1])] *)
    38 (* [(1,[0,1,1])] *)
    39 if mv_pquot4=[(1,[0,1,1])] then () else raise error ("Test failed");
    39 if mv_pquot4=[(1,[0,1,1])] then () else error ("Test failed");
    40 
    40 
    41 val mv_prest4 = (#2(mv_division([(3,[1,1,1]),(4,[1,0,1]),(3,[0,0,1])],[(2,[1,0,0]),(4,[0,0,1])],GGO_)));
    41 val mv_prest4 = (#2(mv_division([(3,[1,1,1]),(4,[1,0,1]),(3,[0,0,1])],[(2,[1,0,0]),(4,[0,0,1])],GGO_)));
    42 (* [(1,[1,1,1]),(~4,[0,1,2]),(4,[1,0,1]),(3,[0,0,1])] *)
    42 (* [(1,[1,1,1]),(~4,[0,1,2]),(4,[1,0,1]),(3,[0,0,1])] *)
    43 if mv_prest4 =[(1,[1,1,1]),(~4,[0,1,2]),(4,[1,0,1]),(3,[0,0,1])] then () else raise error ("Test failed");
    43 if mv_prest4 =[(1,[1,1,1]),(~4,[0,1,2]),(4,[1,0,1]),(3,[0,0,1])] then () else error ("Test failed");
    44 
    44 
    45 val mv_pquot5 = (#1(mv_division([(3,[1,1,1]),(4,[1,0,1]),(3,[0,0,1]),(6,[2,1,3]),(4,[0,4,1]),(1,[2,2,1])],[(1,[0,0,1])],LEX_))); 
    45 val mv_pquot5 = (#1(mv_division([(3,[1,1,1]),(4,[1,0,1]),(3,[0,0,1]),(6,[2,1,3]),(4,[0,4,1]),(1,[2,2,1])],[(1,[0,0,1])],LEX_))); 
    46 (* [(1,[2,2,0]),(6,[2,1,2]),(3,[1,1,0]),(4,[1,0,0]),(4,[0,4,0]),(3,[0,0,0])]*)
    46 (* [(1,[2,2,0]),(6,[2,1,2]),(3,[1,1,0]),(4,[1,0,0]),(4,[0,4,0]),(3,[0,0,0])]*)
    47 if mv_pquot5=[(1,[2,2,0]),(6,[2,1,2]),(3,[1,1,0]),(4,[1,0,0]),(4,[0,4,0]),(3,[0,0,0])] then () else raise error ("Test failed");
    47 if mv_pquot5=[(1,[2,2,0]),(6,[2,1,2]),(3,[1,1,0]),(4,[1,0,0]),(4,[0,4,0]),(3,[0,0,0])] then () else error ("Test failed");
    48 
    48 
    49 val mv_prest5 = (#2(mv_division([(3,[1,1,1]),(4,[1,0,1]),(3,[0,0,1]),(6,[2,1,3]),(4,[0,4,1]),(1,[2,2,1])],[(1,[0,0,1])],LEX_)));
    49 val mv_prest5 = (#2(mv_division([(3,[1,1,1]),(4,[1,0,1]),(3,[0,0,1]),(6,[2,1,3]),(4,[0,4,1]),(1,[2,2,1])],[(1,[0,0,1])],LEX_)));
    50 (* [] *)
    50 (* [] *)
    51 if mv_prest5=[] then () else raise error ("Test failed");
    51 if mv_prest5=[] then () else error ("Test failed");
    52 
    52 
    53 (* (x^2 + 2(a+1)x + (a^2+2a+1)) / (x+a+1) = x+a+1 *)
    53 (* (x^2 + 2(a+1)x + (a^2+2a+1)) / (x+a+1) = x+a+1 *)
    54 val mv_pquot6 = (#1(mv_division([(1,[2,0,0]),(2,[1,1,0]),(2,[1,0,0]),(1,[0,2,0]),(2,[0,1,0]),(1,[0,0,0])],[(1,[1,0,0]),(1,[0,1,0]),(1,[0,0,0])],LEX_)));
    54 val mv_pquot6 = (#1(mv_division([(1,[2,0,0]),(2,[1,1,0]),(2,[1,0,0]),(1,[0,2,0]),(2,[0,1,0]),(1,[0,0,0])],[(1,[1,0,0]),(1,[0,1,0]),(1,[0,0,0])],LEX_)));
    55 if mv_pquot6=[(1,[1,0,0]),(1,[0,1,0]),(1,[0,0,0])] then () else raise error ("Test failed");
    55 if mv_pquot6=[(1,[1,0,0]),(1,[0,1,0]),(1,[0,0,0])] then () else error ("Test failed");
    56 
    56 
    57 val mv_prest6 = (#2(mv_division([(1,[2,0,0]),(2,[1,1,0]),(2,[1,0,0]),(1,[0,2,0]),(2,[0,1,0]),(1,[0,0,0])],[(1,[1,0,0]),(1,[0,1,0]),(1,[0,0,0])],LEX_)));
    57 val mv_prest6 = (#2(mv_division([(1,[2,0,0]),(2,[1,1,0]),(2,[1,0,0]),(1,[0,2,0]),(2,[0,1,0]),(1,[0,0,0])],[(1,[1,0,0]),(1,[0,1,0]),(1,[0,0,0])],LEX_)));
    58 if mv_prest6=[] then () else raise error ("Test failed");
    58 if mv_prest6=[] then () else error ("Test failed");
    59 
    59 
    60 (* Exception tests *)
    60 (* Exception tests *)
    61 (* mv_division ([(1,[0,0,0])],[(0,[1,2,3])],LEX_); *)
    61 (* mv_division ([(1,[0,0,0])],[(0,[1,2,3])],LEX_); *)
    62 
    62 
    63 print("\n\n***** MV_CONTENT-TESTS *****\n");
    63 print("\n\n***** MV_CONTENT-TESTS *****\n");
    64 val mv_cont1=mv_content([(1,[2,1]),(1,[2,0]),(1,[1,1]),(1,[1,0]),(1,[0,1]),(1,[0,0])]); 
    64 val mv_cont1=mv_content([(1,[2,1]),(1,[2,0]),(1,[1,1]),(1,[1,0]),(1,[0,1]),(1,[0,0])]); 
    65 (* [(1,[0,1]),(1,[0,0])] *)
    65 (* [(1,[0,1]),(1,[0,0])] *)
    66 if  mv_cont1=[(1,[0,1]),(1,[0,0])] then () else raise error ("Test failed");
    66 if  mv_cont1=[(1,[0,1]),(1,[0,0])] then () else error ("Test failed");
    67 
    67 
    68 val mv_pp1=mv_pp([(1,[1,1]),(1,[1,0]),(1,[0,1]),(1,[0,0])]); 
    68 val mv_pp1=mv_pp([(1,[1,1]),(1,[1,0]),(1,[0,1]),(1,[0,0])]); 
    69 (*[(1,[1,0]),(1,[0,0])]*)
    69 (*[(1,[1,0]),(1,[0,0])]*)
    70 if mv_pp1=[(1,[1,0]),(1,[0,0])] then () else raise error ("Test failed");
    70 if mv_pp1=[(1,[1,0]),(1,[0,0])] then () else error ("Test failed");
    71 
    71 
    72 val mv_cont2=mv_content([(2,[1]),(4,[0])]);
    72 val mv_cont2=mv_content([(2,[1]),(4,[0])]);
    73 (* [(2,[0])] *)
    73 (* [(2,[0])] *)
    74 if mv_cont2=[(2,[0])] then () else raise error ("Test failed");
    74 if mv_cont2=[(2,[0])] then () else error ("Test failed");
    75 
    75 
    76 val mv_pp2=mv_pp([(2,[1]),(4,[0])]);
    76 val mv_pp2=mv_pp([(2,[1]),(4,[0])]);
    77 (* [(1,[1]),(2,[0])] *)
    77 (* [(1,[1]),(2,[0])] *)
    78 if mv_pp2=[(1,[1]),(2,[0])] then () else raise error ("Test failed");
    78 if mv_pp2=[(1,[1]),(2,[0])] then () else error ("Test failed");
    79 
    79 
    80 val mv_cont3=mv_content[(8,[2,1,1]),(12,[1,0,2]),(10,[2,2,0]),(16,[1,1,1])];
    80 val mv_cont3=mv_content[(8,[2,1,1]),(12,[1,0,2]),(10,[2,2,0]),(16,[1,1,1])];
    81 (* [(2,[0,0,0])] *)
    81 (* [(2,[0,0,0])] *)
    82 if mv_cont3=[(2,[0,0,0])] then () else raise error ("Test failed");
    82 if mv_cont3=[(2,[0,0,0])] then () else error ("Test failed");
    83 
    83 
    84 val mv_pp3=mv_pp[(8,[2,1,1]),(12,[1,0,2]),(10,[2,2,0]),(16,[1,1,1])];
    84 val mv_pp3=mv_pp[(8,[2,1,1]),(12,[1,0,2]),(10,[2,2,0]),(16,[1,1,1])];
    85 (* [(5,[2,2,0]),(4,[2,1,1]),(8,[1,1,1]),(6,[1,0,2])] *)
    85 (* [(5,[2,2,0]),(4,[2,1,1]),(8,[1,1,1]),(6,[1,0,2])] *)
    86 if mv_pp3=[(5,[2,2,0]),(4,[2,1,1]),(8,[1,1,1]),(6,[1,0,2])] then () else raise error ("Test failed");
    86 if mv_pp3=[(5,[2,2,0]),(4,[2,1,1]),(8,[1,1,1]),(6,[1,0,2])] then () else error ("Test failed");
    87 
    87 
    88 val mv_cont4=mv_content[(2,[2,1,0]),(3,[1,0,1]),(2,[1,1,0]),(3,[0,0,1])];
    88 val mv_cont4=mv_content[(2,[2,1,0]),(3,[1,0,1]),(2,[1,1,0]),(3,[0,0,1])];
    89 (* [(1,[0,0,0])] *)
    89 (* [(1,[0,0,0])] *)
    90 if mv_cont4=[(1,[0,0,0])] then () else raise error ("Test failed");
    90 if mv_cont4=[(1,[0,0,0])] then () else error ("Test failed");
    91 
    91 
    92 val mv_pp4=mv_pp [(2,[2,1,0]),(3,[1,0,1]),(2,[1,1,0]),(3,[0,0,1])]; 
    92 val mv_pp4=mv_pp [(2,[2,1,0]),(3,[1,0,1]),(2,[1,1,0]),(3,[0,0,1])]; 
    93 (* [(2,[2,1,0]),(2,[1,1,0]),(3,[1,0,1]),(3,[0,0,1])] *)
    93 (* [(2,[2,1,0]),(2,[1,1,0]),(3,[1,0,1]),(3,[0,0,1])] *)
    94 if mv_pp4=[(2,[2,1,0]),(2,[1,1,0]),(3,[1,0,1]),(3,[0,0,1])] then () else raise error ("Test failed");
    94 if mv_pp4=[(2,[2,1,0]),(2,[1,1,0]),(3,[1,0,1]),(3,[0,0,1])] then () else error ("Test failed");
    95 
    95 
    96 val con1=mv_content([(9,[2,0]),(15,[1,1]),(12,[1,0]),(6,[0,2]),(12,[0,1])]);
    96 val con1=mv_content([(9,[2,0]),(15,[1,1]),(12,[1,0]),(6,[0,2]),(12,[0,1])]);
    97 (* [(3,[0,0])] *) 
    97 (* [(3,[0,0])] *) 
    98 if con1=[(3,[0,0])] then () else raise error ("Test failed");
    98 if con1=[(3,[0,0])] then () else error ("Test failed");
    99 
    99 
   100 val pp1=mv_pp([(9,[2,0]),(15,[1,1]),(12,[1,0]),(6,[0,2]),(12,[0,1])]);
   100 val pp1=mv_pp([(9,[2,0]),(15,[1,1]),(12,[1,0]),(6,[0,2]),(12,[0,1])]);
   101 (* [(3,[2,0]),(5,[1,1]),(4,[1,0]),(2,[0,2]),(4,[0,1])] *) 
   101 (* [(3,[2,0]),(5,[1,1]),(4,[1,0]),(2,[0,2]),(4,[0,1])] *) 
   102 if pp1=[(3,[2,0]),(5,[1,1]),(4,[1,0]),(2,[0,2]),(4,[0,1])] then () else raise error ("Test failed");
   102 if pp1=[(3,[2,0]),(5,[1,1]),(4,[1,0]),(2,[0,2]),(4,[0,1])] then () else error ("Test failed");
   103 
   103 
   104 val con2=mv_content([(1,[2,0]),(1,[1,1]),(1,[1,0]),(1,[0,2]),(1,[0,1])]); 
   104 val con2=mv_content([(1,[2,0]),(1,[1,1]),(1,[1,0]),(1,[0,2]),(1,[0,1])]); 
   105 (* [(1,[0,0])] *)
   105 (* [(1,[0,0])] *)
   106 if con2=[(1,[0,0])] then () else raise error ("Test failed");
   106 if con2=[(1,[0,0])] then () else error ("Test failed");
   107 
   107 
   108 val pp2 =mv_pp([(1,[2,0]),(1,[1,1]),(1,[1,0]),(1,[0,2]),(1,[0,1])]); 
   108 val pp2 =mv_pp([(1,[2,0]),(1,[1,1]),(1,[1,0]),(1,[0,2]),(1,[0,1])]); 
   109 (* [(1,[2,0]),(1,[1,1]),(1,[1,0]),(1,[0,2]),(1,[0,1])] *)
   109 (* [(1,[2,0]),(1,[1,1]),(1,[1,0]),(1,[0,2]),(1,[0,1])] *)
   110 if pp2=[(1,[2,0]),(1,[1,1]),(1,[1,0]),(1,[0,2]),(1,[0,1])] then () else raise error ("Test failed");
   110 if pp2=[(1,[2,0]),(1,[1,1]),(1,[1,0]),(1,[0,2]),(1,[0,1])] then () else error ("Test failed");
   111 
   111 
   112 val cont1 = mv_content [(1,[2,1,0]),(2,[2,1,0])]; 
   112 val cont1 = mv_content [(1,[2,1,0]),(2,[2,1,0])]; 
   113 (* [(3,[0,1,0])] *)
   113 (* [(3,[0,1,0])] *)
   114 if cont1=[(3,[0,1,0])] then () else raise error ("Test failed");
   114 if cont1=[(3,[0,1,0])] then () else error ("Test failed");
   115 
   115 
   116 val pp1 = mv_pp [(1,[2,1,0]),(2,[2,1,0])]; 
   116 val pp1 = mv_pp [(1,[2,1,0]),(2,[2,1,0])]; 
   117 (* [(1,[2,0,0])] *)
   117 (* [(1,[2,0,0])] *)
   118 if pp1=[(1,[2,0,0])] then () else raise error ("Test failed");
   118 if pp1=[(1,[2,0,0])] then () else error ("Test failed");
   119 
   119 
   120 val cont2 = mv_content [(4,[1,2,0]),(2,[2,1,0])]; 
   120 val cont2 = mv_content [(4,[1,2,0]),(2,[2,1,0])]; 
   121 (* [(2,[0,1,0])] *)
   121 (* [(2,[0,1,0])] *)
   122 if cont2=[(2,[0,1,0])] then () else raise error ("Test failed");
   122 if cont2=[(2,[0,1,0])] then () else error ("Test failed");
   123 
   123 
   124 val pp2 = mv_pp [(4,[1,2,0]),(2,[2,1,0])];
   124 val pp2 = mv_pp [(4,[1,2,0]),(2,[2,1,0])];
   125 (* [(1,[2,0,0]),(2,[1,1,0])] *)
   125 (* [(1,[2,0,0]),(2,[1,1,0])] *)
   126 if pp2=[(1,[2,0,0]),(2,[1,1,0])] then () else raise error ("Test failed");
   126 if pp2=[(1,[2,0,0]),(2,[1,1,0])] then () else error ("Test failed");
   127 
   127 
   128 print("\n\n\n\n********************************************************\n\n");
   128 print("\n\n\n\n********************************************************\n\n");
   129 val cont3=mv_content [(65,[3,2,2]),(52,[3,2,1]),(26,[3,1,2]),(~95,[2,2,3]),(~76,[2,2,2]),(35,[2,2,1]),(28,[2,2,0]),(~38,[2,1,3]),(14,[2,1,1])];
   129 val cont3=mv_content [(65,[3,2,2]),(52,[3,2,1]),(26,[3,1,2]),(~95,[2,2,3]),(~76,[2,2,2]),(35,[2,2,1]),(28,[2,2,0]),(~38,[2,1,3]),(14,[2,1,1])];
   130 (*if cont3=[(1,[0,1,0])] then () else raise error ("Test failed"); *)
   130 (*if cont3=[(1,[0,1,0])] then () else error ("Test failed"); *)
   131 val pp3=mv_pp [(65,[3,2,2]),(52,[3,2,1]),(26,[3,1,2]),(~95,[2,2,3]),(~76,[2,2,2]),(35,[2,2,1]),(28,[2,2,0]),(~38,[2,1,3]),(14,[2,1,1])];
   131 val pp3=mv_pp [(65,[3,2,2]),(52,[3,2,1]),(26,[3,1,2]),(~95,[2,2,3]),(~76,[2,2,2]),(35,[2,2,1]),(28,[2,2,0]),(~38,[2,1,3]),(14,[2,1,1])];
   132 
   132 
   133 
   133 
   134 print("\n\n***** gcd-tests *****\n"); 
   134 print("\n\n***** gcd-tests *****\n"); 
   135 val ggt1 = gcd_poly [(4,[2,2]),(8,[1,1]),(4,[0,0])] [(2,[1,1]),(2,[0,0])]; 
   135 val ggt1 = gcd_poly [(4,[2,2]),(8,[1,1]),(4,[0,0])] [(2,[1,1]),(2,[0,0])]; 
   136 (* [(2,[1,1]),(2,[0,0])] *)
   136 (* [(2,[1,1]),(2,[0,0])] *)
   137 if ggt1=[(2,[1,1]),(2,[0,0])] then () else raise error ("Test failed");
   137 if ggt1=[(2,[1,1]),(2,[0,0])] then () else error ("Test failed");
   138 
   138 
   139 val ggt2 = gcd_poly [(8,[2,1,1]),(12,[1,0,2]),(10,[2,2,0]),(15,[1,1,1])] [(2,[2,1,0]),(3,[1,0,1]),(2,[1,1,0]),(3,[0,0,1])];
   139 val ggt2 = gcd_poly [(8,[2,1,1]),(12,[1,0,2]),(10,[2,2,0]),(15,[1,1,1])] [(2,[2,1,0]),(3,[1,0,1]),(2,[1,1,0]),(3,[0,0,1])];
   140 (* [(2,[1,1,0]),(3,[0,0,1])] *)
   140 (* [(2,[1,1,0]),(3,[0,0,1])] *)
   141 if ggt2=[(2,[1,1,0]),(3,[0,0,1])] then () else raise error ("Test failed");
   141 if ggt2=[(2,[1,1,0]),(3,[0,0,1])] then () else error ("Test failed");
   142 
   142 
   143 val ggt3 = gcd_poly [(1,[2,0,0]),(~2,[1,0,1]),(1,[0,0,2])] [(1,[1,0,0]),(~1,[0,0,1])]; 
   143 val ggt3 = gcd_poly [(1,[2,0,0]),(~2,[1,0,1]),(1,[0,0,2])] [(1,[1,0,0]),(~1,[0,0,1])]; 
   144 (* [(1,[1,0,0]),(~1,[0,0,1])] *)
   144 (* [(1,[1,0,0]),(~1,[0,0,1])] *)
   145 if ggt3=[(1,[1,0,0]),(~1,[0,0,1])] then () else raise error ("Test failed");
   145 if ggt3=[(1,[1,0,0]),(~1,[0,0,1])] then () else error ("Test failed");
   146 
   146 
   147 val ggt4 = gcd_poly [(1,[2,1,0]),(2,[2,1,0])] [(5,[1,0,0])]; 
   147 val ggt4 = gcd_poly [(1,[2,1,0]),(2,[2,1,0])] [(5,[1,0,0])]; 
   148 (* [(1,[1,0,0])] *)
   148 (* [(1,[1,0,0])] *)
   149 if ggt4=[(1,[1,0,0])] then () else raise error ("Test failed");
   149 if ggt4=[(1,[1,0,0])] then () else error ("Test failed");
   150 
   150 
   151 val ggt5 = gcd_poly [(4,[2,0,0]),(~8,[1,0,1]),(4,[0,0,2])] [(1,[2,0,0]),(~1,[0,0,2])]; 
   151 val ggt5 = gcd_poly [(4,[2,0,0]),(~8,[1,0,1]),(4,[0,0,2])] [(1,[2,0,0]),(~1,[0,0,2])]; 
   152 (* [(1,[1,0,0]),(~1,[0,0,1])] *)
   152 (* [(1,[1,0,0]),(~1,[0,0,1])] *)
   153 if ggt5=[(1,[1,0,0]),(~1,[0,0,1])] then () else raise error ("Test failed");
   153 if ggt5=[(1,[1,0,0]),(~1,[0,0,1])] then () else error ("Test failed");
   154 
   154 
   155 val ggt6 = gcd_poly [(10,[2,1,1]),(14,[1,1,0]),(3,[1,0,1]),(20,[1,2,1])] [(5,[1,1,1]),(7,[2,1,1])];
   155 val ggt6 = gcd_poly [(10,[2,1,1]),(14,[1,1,0]),(3,[1,0,1]),(20,[1,2,1])] [(5,[1,1,1]),(7,[2,1,1])];
   156 (* [(1,[0,0,0])] *)
   156 (* [(1,[0,0,0])] *)
   157 if ggt6=[(1,[1,0,0])] then () else raise error ("Test failed");
   157 if ggt6=[(1,[1,0,0])] then () else error ("Test failed");
   158 
   158 
   159 val ggt7 = gcd_poly [(~169,[4,3,3]),(273,[4,2,2]),(247,[3,3,4]),(~91,[3,3,2]),(78,[3,3,1]),(~399,[3,2,3]),(147,[3,2,1]),(~114,[2,3,2]),(42,[2,3,0])]  [(65,[3,2,2]),(52,[3,2,1]),(26,[3,1,2]),(~95,[2,2,3]),(~76,[2,2,2]),(35,[2,2,1]),(28,[2,2,0]),(~38,[2,1,3]),(14,[2,1,1])];
   159 val ggt7 = gcd_poly [(~169,[4,3,3]),(273,[4,2,2]),(247,[3,3,4]),(~91,[3,3,2]),(78,[3,3,1]),(~399,[3,2,3]),(147,[3,2,1]),(~114,[2,3,2]),(42,[2,3,0])]  [(65,[3,2,2]),(52,[3,2,1]),(26,[3,1,2]),(~95,[2,2,3]),(~76,[2,2,2]),(35,[2,2,1]),(28,[2,2,0]),(~38,[2,1,3]),(14,[2,1,1])];
   160 (* [(13,[3,1,1]),(~19,[2,1,2]),(7,[2,1,0])] *)
   160 (* [(13,[3,1,1]),(~19,[2,1,2]),(7,[2,1,0])] *)
   161 if ggt7=[(13,[3,1,1]),(~19,[2,1,2]),(7,[2,1,0])] then () else raise error ("Test failed");
   161 if ggt7=[(13,[3,1,1]),(~19,[2,1,2]),(7,[2,1,0])] then () else error ("Test failed");
   162 
   162 
   163 print("\n\n***** kgv-tests *****\n"); 
   163 print("\n\n***** kgv-tests *****\n"); 
   164 val kgv1=lcm_poly [(10,[])] [(15,[])];
   164 val kgv1=lcm_poly [(10,[])] [(15,[])];
   165 (* [(30,[])] *)
   165 (* [(30,[])] *)
   166 if kgv1=[(30,[])] then () else raise error ("Test failed");
   166 if kgv1=[(30,[])] then () else error ("Test failed");
   167 
   167 
   168 val kgv2=lcm_poly [(1,[2,0,0]),(~2,[1,0,1]),(1,[0,0,2])] [(1,[1,0,0]),(~1,[0,0,1])]; 
   168 val kgv2=lcm_poly [(1,[2,0,0]),(~2,[1,0,1]),(1,[0,0,2])] [(1,[1,0,0]),(~1,[0,0,1])]; 
   169 (* [(1,[2,0,0]),(~2,[1,0,1]),(1,[0,0,2])] *)
   169 (* [(1,[2,0,0]),(~2,[1,0,1]),(1,[0,0,2])] *)
   170 if kgv2=[(1,[2,0,0]),(~2,[1,0,1]),(1,[0,0,2])] then () else raise error ("Test failed");
   170 if kgv2=[(1,[2,0,0]),(~2,[1,0,1]),(1,[0,0,2])] then () else error ("Test failed");
   171 
   171 
   172 val kgv3=lcm_poly [(4,[2,0,0]),(~8,[1,0,1]),(4,[0,0,2])] [(1,[2,0,0]),(~1,[0,0,2])]; 
   172 val kgv3=lcm_poly [(4,[2,0,0]),(~8,[1,0,1]),(4,[0,0,2])] [(1,[2,0,0]),(~1,[0,0,2])]; 
   173 (* [(4,[3,0,0]),(~4,[2,0,1]),(~4,[1,0,2]),(4,[0,0,3])] *)
   173 (* [(4,[3,0,0]),(~4,[2,0,1]),(~4,[1,0,2]),(4,[0,0,3])] *)
   174 if kgv3=[(4,[3,0,0]),(~4,[2,0,1]),(~4,[1,0,2]),(4,[0,0,3])] then () else raise error ("Test failed");
   174 if kgv3=[(4,[3,0,0]),(~4,[2,0,1]),(~4,[1,0,2]),(4,[0,0,3])] then () else error ("Test failed");
   175 
   175 
   176 (*
   176 (*
   177 print("***** TERM2POLY-TESTS *****\n"); 
   177 print("***** TERM2POLY-TESTS *****\n"); 
   178 val t0 = (term_of o the o (parse thy)) "3 * 4";
   178 val t0 = (term_of o the o (parse thy)) "3 * 4";
   179 val t1 = (term_of o the o (parse thy)) "27";
   179 val t1 = (term_of o the o (parse thy)) "27";
   209 atomt div2; 
   209 atomt div2; 
   210 *)
   210 *)
   211 
   211 
   212 val term1 = (term_of o the o (parse thy)) "(10 * a^^^2 * b * c + 14 * a * b + 3 * a * c + 20 * a * b^^^2 * c) /// a";
   212 val term1 = (term_of o the o (parse thy)) "(10 * a^^^2 * b * c + 14 * a * b + 3 * a * c + 20 * a * b^^^2 * c) /// a";
   213 val div1  = step_cancel term1;
   213 val div1  = step_cancel term1;
   214 (*if div1 =  (term_of o the o (parse thy)) "((10 * a * b * c + 14 * b + 3 * c + 20 * b^^^2 * c) * a) /// (1 * a)" then () else raise raise error ("Test failed");*)
   214 (*if div1 =  (term_of o the o (parse thy)) "((10 * a * b * c + 14 * b + 3 * c + 20 * b^^^2 * c) * a) /// (1 * a)" then () else raise error ("Test failed");*)
   215 
   215 
   216 val term2 = (term_of o the o (parse thy)) "(10 * a^^^2 * b * c + 14 * a * b + 3 * a * c + 20 * a * b^^^2 * c) /// (5 * a * b * c  +  7 * a^^^2 * b * c) ";
   216 val term2 = (term_of o the o (parse thy)) "(10 * a^^^2 * b * c + 14 * a * b + 3 * a * c + 20 * a * b^^^2 * c) /// (5 * a * b * c  +  7 * a^^^2 * b * c) ";
   217 val div2  = step_cancel term2;
   217 val div2  = step_cancel term2;
   218 (*if div2 = ([(10,[1,1,1]),(20,[0,2,1]),(14,[0,1,0]),(3,[0,0,1])],[(1,[1,0,0])],[(7,[1,1,1]),(5,[0,1,1])]) then () else raise raise error ("Test failed");*)
   218 (*if div2 = ([(10,[1,1,1]),(20,[0,2,1]),(14,[0,1,0]),(3,[0,0,1])],[(1,[1,0,0])],[(7,[1,1,1]),(5,[0,1,1])]) then () else raise error ("Test failed");*)
   219 
   219 
   220 
   220 
   221 val term3 = (term_of o the o (parse thy)) "(10 * a^^^2 * b * c) /// (1 * x * y * z) ";
   221 val term3 = (term_of o the o (parse thy)) "(10 * a^^^2 * b * c) /// (1 * x * y * z) ";
   222 val div3 = step_cancel term3;
   222 val div3 = step_cancel term3;
   223 
   223 
   227 val mul2=(the (term2poly((term_of o the o (parse thy)) "13*a^^^2*b*c+7*a*b-19*a*b*c^^^2")));
   227 val mul2=(the (term2poly((term_of o the o (parse thy)) "13*a^^^2*b*c+7*a*b-19*a*b*c^^^2")));
   228 val mul3=(the (term2poly((term_of o the o (parse thy)) "6*a*b^^^2-13*a^^^2*b^^^2*c^^^2+21*a^^^2*b*c")));
   228 val mul3=(the (term2poly((term_of o the o (parse thy)) "6*a*b^^^2-13*a^^^2*b^^^2*c^^^2+21*a^^^2*b*c")));
   229 val t1=mv_mul(mul1,mul2,LEX_);
   229 val t1=mv_mul(mul1,mul2,LEX_);
   230 val t2=mv_mul(mul3,mul2,LEX_);
   230 val t2=mv_mul(mul3,mul2,LEX_);
   231 val div3=step_cancel t1 t2;
   231 val div3=step_cancel t1 t2;
   232 if div3=([(5,[0,1,1]),(4,[0,1,0]),(2,[0,0,1])],[(13,[3,1,1]),(~19,[2,1,2]),(7,[2,1,0])],[(~13,[1,2,2]),(21,[1,1,1]),(6,[0,2,0])]) then () else raise error ("Test failed");*)
   232 if div3=([(5,[0,1,1]),(4,[0,1,0]),(2,[0,0,1])],[(13,[3,1,1]),(~19,[2,1,2]),(7,[2,1,0])],[(~13,[1,2,2]),(21,[1,1,1]),(6,[0,2,0])]) then () else error ("Test failed");*)
   233 
   233 
   234 print("\n\n***** all tests successfull ;-) ******\n\n");
   234 print("\n\n***** all tests successfull ;-) ******\n\n");
   235 
   235 
   236 
   236 
   237 
   237 
   245 val thy' = "Rational";
   245 val thy' = "Rational";
   246 val rls' = "cancel";
   246 val rls' = "cancel";
   247 val t' = "(1 + 1 * a ^^^ 1)///(-2 + 2 * a ^^^ 2)";
   247 val t' = "(1 + 1 * a ^^^ 1)///(-2 + 2 * a ^^^ 2)";
   248 val (t',asm') = the (rewrite_set thy' "eval_rls" false rls' t');
   248 val (t',asm') = the (rewrite_set thy' "eval_rls" false rls' t');
   249 (*if t' = "1 /// (-2 + 2 * a)" then ()
   249 (*if t' = "1 /// (-2 + 2 * a)" then ()
   250 else raise error "tests/rationals.sml(1): new behaviour";*)
   250 else error "tests/rationals.sml(1): new behaviour";*)
   251 
   251 
   252 
   252 
   253 val thy' = "Rational";
   253 val thy' = "Rational";
   254 val rls' = "cancel";
   254 val rls' = "cancel";
   255 val t' = "(10 * a^^^2 * b * c + 14 * a * b + 3 * a * c + 20 * a * b^^^2 * c) /// (5 * a * b * c  +  7 * a^^^2 * b * c) ";
   255 val t' = "(10 * a^^^2 * b * c + 14 * a * b + 3 * a * c + 20 * a * b^^^2 * c) /// (5 * a * b * c  +  7 * a^^^2 * b * c) ";
   309 print("a)\n");
   309 print("a)\n");
   310 val e188a'="(8 * x + -8) / (9 * x + -9 )";
   310 val e188a'="(8 * x + -8) / (9 * x + -9 )";
   311 val e188a = the (rewrite_set thy' "rational_erls" false rls' e188a');
   311 val e188a = the (rewrite_set thy' "rational_erls" false rls' e188a');
   312 val SOME (t,_) = rewrite_set thy' "rational_erls" false mp "(8*((-1) + x))/(9*((-1) + x))";
   312 val SOME (t,_) = rewrite_set thy' "rational_erls" false mp "(8*((-1) + x))/(9*((-1) + x))";
   313 if t="((-8) + 8 * x) / ((-9) + 9 * x)"then()
   313 if t="((-8) + 8 * x) / ((-9) + 9 * x)"then()
   314 else raise error "rationals.sml: e188a new behaviour";
   314 else error "rationals.sml: e188a new behaviour";
   315 print("b)\n");
   315 print("b)\n");
   316 val e188b'="(5 * x + -15) / (6 * x + -18 )";
   316 val e188b'="(5 * x + -15) / (6 * x + -18 )";
   317 val e188b = the (rewrite_set thy' "rational_erls" false rls' e188b');
   317 val e188b = the (rewrite_set thy' "rational_erls" false rls' e188b');
   318 print("c)\n");
   318 print("c)\n");
   319 val e188c'="( a + -1 * b ) / ( b + -1 * a )";
   319 val e188c'="( a + -1 * b ) / ( b + -1 * a )";
   320 val e188c = the (rewrite_set thy' "rational_erls" false rls' e188c');
   320 val e188c = the (rewrite_set thy' "rational_erls" false rls' e188c');
   321 val SOME (t,_) = rewrite_set thy' "rational_erls" false mp "((-1)*(b + (-1) * a))/(1*(b + (-1) * a))";
   321 val SOME (t,_) = rewrite_set thy' "rational_erls" false mp "((-1)*(b + (-1) * a))/(1*(b + (-1) * a))";
   322 if t="(a + -1 * b) / (b + -1 * a)"then()
   322 if t="(a + -1 * b) / (b + -1 * a)"then()
   323 else raise error "rationals.sml: e188c new behaviour";
   323 else error "rationals.sml: e188c new behaviour";
   324 
   324 
   325 print("\n\nexample 190:\n");
   325 print("\n\nexample 190:\n");
   326 print("c)\n");
   326 print("c)\n");
   327 val e190c'="( 27 * a^^^3 + 9 * a^^^2 + 3 * a + 1 ) / ( 27 * a^^^3 + 18 * a^^^2 + 3 * a )";
   327 val e190c'="( 27 * a^^^3 + 9 * a^^^2 + 3 * a + 1 ) / ( 27 * a^^^3 + 18 * a^^^2 + 3 * a )";
   328 val e190c = the (rewrite_set thy' "rational_erls" false rls' e190c');
   328 val e190c = the (rewrite_set thy' "rational_erls" false rls' e190c');
   329 val SOME (t,_) = rewrite_set thy' "rational_erls" false mp "((1 + 9 * a ^^^ 2)*(1 + 3 * a))/((3 * a + 9 * a ^^^ 2)*(1 + 3 * a))";
   329 val SOME (t,_) = rewrite_set thy' "rational_erls" false mp "((1 + 9 * a ^^^ 2)*(1 + 3 * a))/((3 * a + 9 * a ^^^ 2)*(1 + 3 * a))";
   330 if t="(1 + (3 * a + (27 * a ^^^ 3 + 9 * a ^^^ 2))) /\n(3 * a + (18 * a ^^^ 2 + 27 * a ^^^ 3))"then()
   330 if t="(1 + (3 * a + (27 * a ^^^ 3 + 9 * a ^^^ 2))) /\n(3 * a + (18 * a ^^^ 2 + 27 * a ^^^ 3))"then()
   331 (*TERMORDER               ~~~~~~~       ~~~~~~~*)
   331 (*TERMORDER               ~~~~~~~       ~~~~~~~*)
   332 else raise error "rationals.sml: e190c new behaviour";
   332 else error "rationals.sml: e190c new behaviour";
   333 
   333 
   334 print("\n\nexample 191:\n");
   334 print("\n\nexample 191:\n");
   335 print("a)\n");
   335 print("a)\n");
   336 val e191a'="( x^^^2 + -1 * y^^^2 ) / ( x + y )";
   336 val e191a'="( x^^^2 + -1 * y^^^2 ) / ( x + y )";
   337 val e191a = the (rewrite_set thy' "rational_erls" false rls' e191a'); 
   337 val e191a = the (rewrite_set thy' "rational_erls" false rls' e191a'); 
   338 val SOME (t,_) = rewrite_set thy' "rational_erls" false mp "((x + (-1) * y)*(x + y))/((1)*(x + y))";
   338 val SOME (t,_) = rewrite_set thy' "rational_erls" false mp "((x + (-1) * y)*(x + y))/((1)*(x + y))";
   339 if t="(x ^^^ 2 + -1 * y ^^^ 2) / (x + y)"then()
   339 if t="(x ^^^ 2 + -1 * y ^^^ 2) / (x + y)"then()
   340 else raise error "rationals.sml: e191a new behaviour";
   340 else error "rationals.sml: e191a new behaviour";
   341 print("c)\n");
   341 print("c)\n");
   342 val e191c'="( 9 * x^^^2 + -30 * x + 25 ) / ( 9 * x^^^2 + -25 )";
   342 val e191c'="( 9 * x^^^2 + -30 * x + 25 ) / ( 9 * x^^^2 + -25 )";
   343 val e191c = the (rewrite_set thy' "rational_erls" false rls' e191c');
   343 val e191c = the (rewrite_set thy' "rational_erls" false rls' e191c');
   344 val SOME (t,_) = rewrite_set thy' "rational_erls" false mp "(((-5) + 3 * x)*((-5) + 3 * x))/((5 + 3 * x)*((-5) + 3 * x))";
   344 val SOME (t,_) = rewrite_set thy' "rational_erls" false mp "(((-5) + 3 * x)*((-5) + 3 * x))/((5 + 3 * x)*((-5) + 3 * x))";
   345 if t="(25 + ((-30) * x + 9 * x ^^^ 2)) / ((-25) + 9 * x ^^^ 2)"then()
   345 if t="(25 + ((-30) * x + 9 * x ^^^ 2)) / ((-25) + 9 * x ^^^ 2)"then()
   346 else raise error "rationals.sml: 'e191c' new behaviour";
   346 else error "rationals.sml: 'e191c' new behaviour";
   347 
   347 
   348 print("\n\nexample 192:\n");
   348 print("\n\nexample 192:\n");
   349 print("b)\n");
   349 print("b)\n");
   350 val e192b'="( 7 * x^^^3 + -1 * x^^^2 * y ) / ( 7 * x * y^^^2 + -1 *  y^^^3 )";
   350 val e192b'="( 7 * x^^^3 + -1 * x^^^2 * y ) / ( 7 * x * y^^^2 + -1 *  y^^^3 )";
   351 val e192b = the (rewrite_set thy' "rational_erls" false rls' e192b');
   351 val e192b = the (rewrite_set thy' "rational_erls" false rls' e192b');
   352 val SOME (t,_) = rewrite_set thy' "rational_erls" false mp "((x ^^^ 2)*(7 * x + (-1) * y))/((y ^^^ 2)*(7 * x + (-1) * y))";
   352 val SOME (t,_) = rewrite_set thy' "rational_erls" false mp "((x ^^^ 2)*(7 * x + (-1) * y))/((y ^^^ 2)*(7 * x + (-1) * y))";
   353 if t="(7 * x ^^^ 3 + -1 * (y * x ^^^ 2)) / (-1 * y ^^^ 3 + 7 * (x * y ^^^ 2))"then()
   353 if t="(7 * x ^^^ 3 + -1 * (y * x ^^^ 2)) / (-1 * y ^^^ 3 + 7 * (x * y ^^^ 2))"then()
   354 (*TERMORDER                ~~~~~*)
   354 (*TERMORDER                ~~~~~*)
   355 else raise error "rationals.sml: 'e192b' new behaviour";
   355 else error "rationals.sml: 'e192b' new behaviour";
   356 
   356 
   357 print("\n\nexample 193:\n");
   357 print("\n\nexample 193:\n");
   358 print("a)\n");
   358 print("a)\n");
   359 val e193a'="( x^^^2 + -6 * x + 9 ) / ( x^^^2 + -9 )";
   359 val e193a'="( x^^^2 + -6 * x + 9 ) / ( x^^^2 + -9 )";
   360 val e193a = the (rewrite_set thy' "rational_erls" false rls' e193a');
   360 val e193a = the (rewrite_set thy' "rational_erls" false rls' e193a');
   593 
   593 
   594 print("\n\nexample stiefel:\n");
   594 print("\n\nexample stiefel:\n");
   595 val est1'="(7) / (-14) + (-2) / (4)";
   595 val est1'="(7) / (-14) + (-2) / (4)";
   596 val est1 = the (rewrite_set thy' "rational_erls" false rls' est1');
   596 val est1 = the (rewrite_set thy' "rational_erls" false rls' est1');
   597 if est1 = ("(-1) / 1",[]) then ()
   597 if est1 = ("(-1) / 1",[]) then ()
   598 else raise error "new behaviour in rationals.sml: est1'";
   598 else error "new behaviour in rationals.sml: est1'";
   599 -------------------------------------------------------------------------*)
   599 -------------------------------------------------------------------------*)
   600 
   600 
   601 
   601 
   602 (*
   602 (*
   603    val t = (term_of o the o (parse thy))
   603    val t = (term_of o the o (parse thy))
   667 
   667 
   668   val SOME r = nex revsets t;
   668   val SOME r = nex revsets t;
   669   val (r,(t,asm))::_ = loc revsets t r;
   669   val (r,(t,asm))::_ = loc revsets t r;
   670   val ss = term2str t;
   670   val ss = term2str t;
   671   if ss = "(3 - x) / (3 + x)" then ()
   671   if ss = "(3 - x) / (3 + x)" then ()
   672   else raise error "rational.sml: new behav. in rev-set cancel";
   672   else error "rational.sml: new behav. in rev-set cancel";
   673   terms2str asm; 
   673   terms2str asm; 
   674 
   674 
   675 
   675 
   676 
   676 
   677 (*WN.11.9.02: the 'reverse-ruleset' cancel*)
   677 (*WN.11.9.02: the 'reverse-ruleset' cancel*)