1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/src/sml/kbtest/rational-old.sml Thu Apr 17 18:01:03 2003 +0200
1.3 @@ -0,0 +1,902 @@
1.4 +(* tests for rationals
1.5 + Stefan Karnel
1.6 + 2002
1.7 + use"../kbtest/rational.sml";
1.8 + use"kbtest/rational.sml";
1.9 + use"rational.sml";
1.10 +*)
1.11 +
1.12 +(*--------------------------------15.10.02---
1.13 +(* tests*)
1.14 +print("\n\n********************* tests *************************\n\n");
1.15 +print("\n\n***** divide tests *****\n");
1.16 +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_)));
1.17 +(* result: [(1,[0,0,1]),(1,[0,0,0])] *)
1.18 +if mv_pquot1=[(1,[0,0,1]),(1,[0,0,0])] then () else raise error ("Test failed");
1.19 +
1.20 +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_)));
1.21 +(* result: [(1,[1,0,1]),(~1,[0,0,1])] *)
1.22 +if mv_prest1=[(1,[1,0,1]),(~1,[0,0,1])] then () else raise error ("Test failed");
1.23 +
1.24 +val mv_pquot2 = (#1(mv_division([(4,[2]),(8,[1]),(16,[0])],[(1,[1]),(1,[0])],LEX_)));
1.25 +(* result: [(4,[1]),(4,[0])] *)
1.26 +if mv_pquot2=[(4,[1]),(4,[0])] then () else raise error ("Test failed");
1.27 +
1.28 +val mv_prest2 = (#2(mv_division([(4,[2]),(8,[1]),(16,[0])],[(1,[1]),(1,[0])],LEX_)));
1.29 +(* result: [(12,[0]] *)
1.30 +if mv_prest2=[(12,[0])] then () else raise error ("Test failed");
1.31 +
1.32 +val mv_pquot3 = (#1(mv_division([(4,[2]),(~4,[0])],[(2,[1]),(2,[0])],LEX_)));
1.33 +(* [(2,[1]),(~2,[0])] *)
1.34 +if mv_pquot3=[(2,[1]),(~2,[0])] then () else raise error ("Test failed");
1.35 +
1.36 +val mv_prest3 = (#2(mv_division([(1,[2]),(~1,[0])],[(2,[1]),(2,[0])],LEX_)));
1.37 +(* [(1,[2]),(~1,[0])] *)
1.38 +if mv_prest3=[(1,[2]),(~1,[0])] then () else raise error ("Test failed");
1.39 +
1.40 +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_)));
1.41 +(* [(1,[0,1,1])] *)
1.42 +if mv_pquot4=[(1,[0,1,1])] then () else raise error ("Test failed");
1.43 +
1.44 +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_)));
1.45 +(* [(1,[1,1,1]),(~4,[0,1,2]),(4,[1,0,1]),(3,[0,0,1])] *)
1.46 +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");
1.47 +
1.48 +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_)));
1.49 +(* [(1,[2,2,0]),(6,[2,1,2]),(3,[1,1,0]),(4,[1,0,0]),(4,[0,4,0]),(3,[0,0,0])]*)
1.50 +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");
1.51 +
1.52 +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_)));
1.53 +(* [] *)
1.54 +if mv_prest5=[] then () else raise error ("Test failed");
1.55 +
1.56 +(* (x^2 + 2(a+1)x + (a^2+2a+1)) / (x+a+1) = x+a+1 *)
1.57 +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_)));
1.58 +if mv_pquot6=[(1,[1,0,0]),(1,[0,1,0]),(1,[0,0,0])] then () else raise error ("Test failed");
1.59 +
1.60 +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_)));
1.61 +if mv_prest6=[] then () else raise error ("Test failed");
1.62 +
1.63 +(* Exception tests *)
1.64 +(* mv_division ([(1,[0,0,0])],[(0,[1,2,3])],LEX_); *)
1.65 +
1.66 +print("\n\n***** MV_CONTENT-TESTS *****\n");
1.67 +val mv_cont1=mv_content([(1,[2,1]),(1,[2,0]),(1,[1,1]),(1,[1,0]),(1,[0,1]),(1,[0,0])]);
1.68 +(* [(1,[0,1]),(1,[0,0])] *)
1.69 +if mv_cont1=[(1,[0,1]),(1,[0,0])] then () else raise error ("Test failed");
1.70 +
1.71 +val mv_pp1=mv_pp([(1,[1,1]),(1,[1,0]),(1,[0,1]),(1,[0,0])]);
1.72 +(*[(1,[1,0]),(1,[0,0])]*)
1.73 +if mv_pp1=[(1,[1,0]),(1,[0,0])] then () else raise error ("Test failed");
1.74 +
1.75 +val mv_cont2=mv_content([(2,[1]),(4,[0])]);
1.76 +(* [(2,[0])] *)
1.77 +if mv_cont2=[(2,[0])] then () else raise error ("Test failed");
1.78 +
1.79 +val mv_pp2=mv_pp([(2,[1]),(4,[0])]);
1.80 +(* [(1,[1]),(2,[0])] *)
1.81 +if mv_pp2=[(1,[1]),(2,[0])] then () else raise error ("Test failed");
1.82 +
1.83 +val mv_cont3=mv_content[(8,[2,1,1]),(12,[1,0,2]),(10,[2,2,0]),(16,[1,1,1])];
1.84 +(* [(2,[0,0,0])] *)
1.85 +if mv_cont3=[(2,[0,0,0])] then () else raise error ("Test failed");
1.86 +
1.87 +val mv_pp3=mv_pp[(8,[2,1,1]),(12,[1,0,2]),(10,[2,2,0]),(16,[1,1,1])];
1.88 +(* [(5,[2,2,0]),(4,[2,1,1]),(8,[1,1,1]),(6,[1,0,2])] *)
1.89 +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");
1.90 +
1.91 +val mv_cont4=mv_content[(2,[2,1,0]),(3,[1,0,1]),(2,[1,1,0]),(3,[0,0,1])];
1.92 +(* [(1,[0,0,0])] *)
1.93 +if mv_cont4=[(1,[0,0,0])] then () else raise error ("Test failed");
1.94 +
1.95 +val mv_pp4=mv_pp [(2,[2,1,0]),(3,[1,0,1]),(2,[1,1,0]),(3,[0,0,1])];
1.96 +(* [(2,[2,1,0]),(2,[1,1,0]),(3,[1,0,1]),(3,[0,0,1])] *)
1.97 +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");
1.98 +
1.99 +val con1=mv_content([(9,[2,0]),(15,[1,1]),(12,[1,0]),(6,[0,2]),(12,[0,1])]);
1.100 +(* [(3,[0,0])] *)
1.101 +if con1=[(3,[0,0])] then () else raise error ("Test failed");
1.102 +
1.103 +val pp1=mv_pp([(9,[2,0]),(15,[1,1]),(12,[1,0]),(6,[0,2]),(12,[0,1])]);
1.104 +(* [(3,[2,0]),(5,[1,1]),(4,[1,0]),(2,[0,2]),(4,[0,1])] *)
1.105 +if pp1=[(3,[2,0]),(5,[1,1]),(4,[1,0]),(2,[0,2]),(4,[0,1])] then () else raise error ("Test failed");
1.106 +
1.107 +val con2=mv_content([(1,[2,0]),(1,[1,1]),(1,[1,0]),(1,[0,2]),(1,[0,1])]);
1.108 +(* [(1,[0,0])] *)
1.109 +if con2=[(1,[0,0])] then () else raise error ("Test failed");
1.110 +
1.111 +val pp2 =mv_pp([(1,[2,0]),(1,[1,1]),(1,[1,0]),(1,[0,2]),(1,[0,1])]);
1.112 +(* [(1,[2,0]),(1,[1,1]),(1,[1,0]),(1,[0,2]),(1,[0,1])] *)
1.113 +if pp2=[(1,[2,0]),(1,[1,1]),(1,[1,0]),(1,[0,2]),(1,[0,1])] then () else raise error ("Test failed");
1.114 +
1.115 +val cont1 = mv_content [(1,[2,1,0]),(2,[2,1,0])];
1.116 +(* [(3,[0,1,0])] *)
1.117 +if cont1=[(3,[0,1,0])] then () else raise error ("Test failed");
1.118 +
1.119 +val pp1 = mv_pp [(1,[2,1,0]),(2,[2,1,0])];
1.120 +(* [(1,[2,0,0])] *)
1.121 +if pp1=[(1,[2,0,0])] then () else raise error ("Test failed");
1.122 +
1.123 +val cont2 = mv_content [(4,[1,2,0]),(2,[2,1,0])];
1.124 +(* [(2,[0,1,0])] *)
1.125 +if cont2=[(2,[0,1,0])] then () else raise error ("Test failed");
1.126 +
1.127 +val pp2 = mv_pp [(4,[1,2,0]),(2,[2,1,0])];
1.128 +(* [(1,[2,0,0]),(2,[1,1,0])] *)
1.129 +if pp2=[(1,[2,0,0]),(2,[1,1,0])] then () else raise error ("Test failed");
1.130 +
1.131 +print("\n\n\n\n********************************************************\n\n");
1.132 +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])];
1.133 +(*if cont3=[(1,[0,1,0])] then () else raise error ("Test failed"); *)
1.134 +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])];
1.135 +
1.136 +
1.137 +print("\n\n***** gcd-tests *****\n");
1.138 +val ggt1 = gcd_poly [(4,[2,2]),(8,[1,1]),(4,[0,0])] [(2,[1,1]),(2,[0,0])];
1.139 +(* [(2,[1,1]),(2,[0,0])] *)
1.140 +if ggt1=[(2,[1,1]),(2,[0,0])] then () else raise error ("Test failed");
1.141 +
1.142 +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])];
1.143 +(* [(2,[1,1,0]),(3,[0,0,1])] *)
1.144 +if ggt2=[(2,[1,1,0]),(3,[0,0,1])] then () else raise error ("Test failed");
1.145 +
1.146 +val ggt3 = gcd_poly [(1,[2,0,0]),(~2,[1,0,1]),(1,[0,0,2])] [(1,[1,0,0]),(~1,[0,0,1])];
1.147 +(* [(1,[1,0,0]),(~1,[0,0,1])] *)
1.148 +if ggt3=[(1,[1,0,0]),(~1,[0,0,1])] then () else raise error ("Test failed");
1.149 +
1.150 +val ggt4 = gcd_poly [(1,[2,1,0]),(2,[2,1,0])] [(5,[1,0,0])];
1.151 +(* [(1,[1,0,0])] *)
1.152 +if ggt4=[(1,[1,0,0])] then () else raise error ("Test failed");
1.153 +
1.154 +val ggt5 = gcd_poly [(4,[2,0,0]),(~8,[1,0,1]),(4,[0,0,2])] [(1,[2,0,0]),(~1,[0,0,2])];
1.155 +(* [(1,[1,0,0]),(~1,[0,0,1])] *)
1.156 +if ggt5=[(1,[1,0,0]),(~1,[0,0,1])] then () else raise error ("Test failed");
1.157 +
1.158 +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])];
1.159 +(* [(1,[0,0,0])] *)
1.160 +if ggt6=[(1,[1,0,0])] then () else raise error ("Test failed");
1.161 +
1.162 +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])];
1.163 +(* [(13,[3,1,1]),(~19,[2,1,2]),(7,[2,1,0])] *)
1.164 +if ggt7=[(13,[3,1,1]),(~19,[2,1,2]),(7,[2,1,0])] then () else raise error ("Test failed");
1.165 +
1.166 +print("\n\n***** kgv-tests *****\n");
1.167 +val kgv1=lcm_poly [(10,[])] [(15,[])];
1.168 +(* [(30,[])] *)
1.169 +if kgv1=[(30,[])] then () else raise error ("Test failed");
1.170 +
1.171 +val kgv2=lcm_poly [(1,[2,0,0]),(~2,[1,0,1]),(1,[0,0,2])] [(1,[1,0,0]),(~1,[0,0,1])];
1.172 +(* [(1,[2,0,0]),(~2,[1,0,1]),(1,[0,0,2])] *)
1.173 +if kgv2=[(1,[2,0,0]),(~2,[1,0,1]),(1,[0,0,2])] then () else raise error ("Test failed");
1.174 +
1.175 +val kgv3=lcm_poly [(4,[2,0,0]),(~8,[1,0,1]),(4,[0,0,2])] [(1,[2,0,0]),(~1,[0,0,2])];
1.176 +(* [(4,[3,0,0]),(~4,[2,0,1]),(~4,[1,0,2]),(4,[0,0,3])] *)
1.177 +if kgv3=[(4,[3,0,0]),(~4,[2,0,1]),(~4,[1,0,2]),(4,[0,0,3])] then () else raise error ("Test failed");
1.178 +
1.179 +(*
1.180 +print("***** TERM2POLY-TESTS *****\n");
1.181 +val t0 = (term_of o the o (parse thy)) "3 * 4";
1.182 +val t1 = (term_of o the o (parse thy)) "27";
1.183 +val t11= (term_of o the o (parse thy)) "27 * c";
1.184 +val t2 = (term_of o the o (parse thy)) "b";
1.185 +val t23= (term_of o the o (parse thy)) "c^^^7";
1.186 +val t24= (term_of o the o (parse thy)) "5 * c^^^7";
1.187 +val t26= (term_of o the o (parse thy)) "a * b";
1.188 +val t3 = (term_of o the o (parse thy)) "2 + a";
1.189 +val t4 = (term_of o the o (parse thy)) "b + a";
1.190 +val t5 = (term_of o the o (parse thy)) "2 + a^^^3";*)
1.191 +val t6 = (term_of o the o (parse thy)) "5*a^^^2*b^^^3*c+4*a^^^4*b+2*a*c";
1.192 +val t7 = (term_of o the o (parse thy)) "a-b";
1.193 +(*
1.194 +(the o term2poly) t0;
1.195 +(the o term2poly) t1;
1.196 +(the o term2poly) t11;
1.197 +(the o term2poly) t2;
1.198 +(the o term2poly) t23;
1.199 +(the o term2poly) t24;
1.200 +(the o term2poly) t26;
1.201 +(the o term2poly) t3;
1.202 +(the o term2poly) t4;
1.203 +(the o term2poly) t5;
1.204 +(the o term2poly) t6;
1.205 +(the o term2poly) t7;*)
1.206 +
1.207 +
1.208 +print("\n\n***** STEP_CANCEL_TESTS: *****\n");
1.209 +(*
1.210 +val term2 = (term_of o the o (parse thy)) " (9 * a^^^2 * b) /// (6 * a * c)";
1.211 +val div2 = step_cancel term2;
1.212 +atomt div2;
1.213 +*)
1.214 +
1.215 +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";
1.216 +val div1 = step_cancel term1;
1.217 +(*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");*)
1.218 +
1.219 +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) ";
1.220 +val div2 = step_cancel term2;
1.221 +(*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");*)
1.222 +
1.223 +
1.224 +val term3 = (term_of o the o (parse thy)) "(10 * a^^^2 * b * c) /// (1 * x * y * z) ";
1.225 +val div3 = step_cancel term3;
1.226 +
1.227 +
1.228 +
1.229 +(*val mul1=(term_of o the o (parse thy)) "(5*a*b*c+4*a*b+2*a*c)";
1.230 +val mul2=(the (term2poly((term_of o the o (parse thy)) "13*a^^^2*b*c+7*a*b-19*a*b*c^^^2")));
1.231 +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")));
1.232 +val t1=mv_mul(mul1,mul2,LEX_);
1.233 +val t2=mv_mul(mul3,mul2,LEX_);
1.234 +val div3=step_cancel t1 t2;
1.235 +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");*)
1.236 +
1.237 +print("\n\n***** all tests successfull ;-) ******\n\n");
1.238 +
1.239 +
1.240 +
1.241 +val thy = Rational.thy;
1.242 +val rls = Prls {func=cancel};
1.243 +val t = (term_of o the o (parse thy))
1.244 + "(1 + 1 * a ^^^ 1)///(-2 + 2 * a ^^^ 2)";
1.245 +val (t,asm) = the (rewrite_set_ thy eval_rls false rls t);
1.246 +
1.247 +
1.248 +val thy' = "Rational.thy";
1.249 +val rls' = "cancel";
1.250 +val t' = "(1 + 1 * a ^^^ 1)///(-2 + 2 * a ^^^ 2)";
1.251 +val (t',asm') = the (rewrite_set thy' "eval_rls" false rls' t');
1.252 +(*if t' = "1 /// (-2 + 2 * a)" then ()
1.253 +else raise error "tests/rationals.sml(1): new behaviour";*)
1.254 +
1.255 +
1.256 +val thy' = "Rational.thy";
1.257 +val rls' = "cancel";
1.258 +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) ";
1.259 +val (t',asm') = the (rewrite_set thy' "eval_rls" false rls' t');
1.260 +
1.261 +val thy' = "Rational.thy";
1.262 +val rls' = "cancel";
1.263 +val t' = "(a^^^2 * b + 2 * a * b + b ) /// ( a^^^2 - 1 )";
1.264 +val (t',asm') = the (rewrite_set thy' "eval_rls" false rls' t');
1.265 +
1.266 +(*
1.267 +val term2 = (term_of o the o (parse thy)) "(a^^^2 * b + 2 * a * b + b ) /// ( a^^^2 - 1 )";
1.268 +val div2 = direct_cancel term2;
1.269 +val t = (term_of o the o (parse thy)) "(1 + 1 * a ^^^ 1)///(-2 + 2 * a ^^^ 2) = 0";*)
1.270 +
1.271 +
1.272 +
1.273 +(*WN folgendes aus examples he"uberkopiert ...*)
1.274 +
1.275 +(* examples from:
1.276 + Mathematik 1
1.277 + Schalk
1.278 + Reniets Verlag *)
1.279 +
1.280 +val thy' = "Rational.thy";
1.281 +val rls' = "cancel";
1.282 +val mp = "make_polynomial";
1.283 +
1.284 +(* page 63 *)
1.285 +
1.286 +print("\n\nexample 186:\n");
1.287 +print("a)\n");
1.288 +val e186a'="(14 * x * y) / ( x * y )";
1.289 +val e186a = the (rewrite_set thy' "rational_erls" false rls' e186a');
1.290 +print("b)\n");
1.291 +val e186b'="(60 * a * b) / ( 15 * a * b )";
1.292 +val e186b = the (rewrite_set thy' "rational_erls" false rls' e186b');
1.293 +print("c)\n");
1.294 +val e186c'="(144 * a^^^2 * b * c) / (12 * a * b * c )";
1.295 +val e186c = (the (rewrite_set thy' "rational_erls" false rls' e186c'))
1.296 + handle e => print_exn e;
1.297 +val t = (term_of o the o (parse thy)) e186c';
1.298 +atomt t;
1.299 +
1.300 +print("\n\nexample 187:\n");
1.301 +print("a)\n");
1.302 +val e187a'="(12 * x * y) / (8 * y^^^2 )";
1.303 +val e187a = the (rewrite_set thy' "rational_erls" false rls' e187a');
1.304 +print("b)\n");
1.305 +val e187b'="(8 * x^^^2 * y * z ) / (18 * x * y^^^2 * z )";
1.306 +val e187b = the (rewrite_set thy' "rational_erls" false rls' e187b');
1.307 +print("c)\n");
1.308 +val e187c'="(9 * x^^^5 * y^^^2 * z^^^4) / (15 * x^^^6 * y^^^3 * z )";
1.309 +val e187c = the (rewrite_set thy' "rational_erls" false rls' e187c');
1.310 +
1.311 +print("\n\nexample 188:\n");
1.312 +print("a)\n");
1.313 +val e188a'="(8 * x + -8) / (9 * x + -9 )";
1.314 +val e188a = the (rewrite_set thy' "rational_erls" false rls' e188a');
1.315 +val Some (t,_) = rewrite_set thy' "rational_erls" false mp "(8*((-1) + x))/(9*((-1) + x))";
1.316 +if t="((-8) + 8 * x) / ((-9) + 9 * x)"then()
1.317 +else raise error "rationals.sml: e188a new behaviour";
1.318 +print("b)\n");
1.319 +val e188b'="(5 * x + -15) / (6 * x + -18 )";
1.320 +val e188b = the (rewrite_set thy' "rational_erls" false rls' e188b');
1.321 +print("c)\n");
1.322 +val e188c'="( a + -1 * b ) / ( b + -1 * a )";
1.323 +val e188c = the (rewrite_set thy' "rational_erls" false rls' e188c');
1.324 +val Some (t,_) = rewrite_set thy' "rational_erls" false mp "((-1)*(b + (-1) * a))/(1*(b + (-1) * a))";
1.325 +if t="(a + -1 * b) / (b + -1 * a)"then()
1.326 +else raise error "rationals.sml: e188c new behaviour";
1.327 +
1.328 +print("\n\nexample 190:\n");
1.329 +print("c)\n");
1.330 +val e190c'="( 27 * a^^^3 + 9 * a^^^2 + 3 * a + 1 ) / ( 27 * a^^^3 + 18 * a^^^2 + 3 * a )";
1.331 +val e190c = the (rewrite_set thy' "rational_erls" false rls' e190c');
1.332 +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))";
1.333 +if t="(1 + (3 * a + (27 * a ^^^ 3 + 9 * a ^^^ 2))) /\n(3 * a + (18 * a ^^^ 2 + 27 * a ^^^ 3))"then()
1.334 +(*TERMORDER ~~~~~~~ ~~~~~~~*)
1.335 +else raise error "rationals.sml: e190c new behaviour";
1.336 +
1.337 +print("\n\nexample 191:\n");
1.338 +print("a)\n");
1.339 +val e191a'="( x^^^2 + -1 * y^^^2 ) / ( x + y )";
1.340 +val e191a = the (rewrite_set thy' "rational_erls" false rls' e191a');
1.341 +val Some (t,_) = rewrite_set thy' "rational_erls" false mp "((x + (-1) * y)*(x + y))/((1)*(x + y))";
1.342 +if t="(x ^^^ 2 + -1 * y ^^^ 2) / (x + y)"then()
1.343 +else raise error "rationals.sml: e191a new behaviour";
1.344 +print("c)\n");
1.345 +val e191c'="( 9 * x^^^2 + -30 * x + 25 ) / ( 9 * x^^^2 + -25 )";
1.346 +val e191c = the (rewrite_set thy' "rational_erls" false rls' e191c');
1.347 +val Some (t,_) = rewrite_set thy' "rational_erls" false mp "(((-5) + 3 * x)*((-5) + 3 * x))/((5 + 3 * x)*((-5) + 3 * x))";
1.348 +if t="(25 + ((-30) * x + 9 * x ^^^ 2)) / ((-25) + 9 * x ^^^ 2)"then()
1.349 +else raise error "rationals.sml: 'e191c' new behaviour";
1.350 +
1.351 +print("\n\nexample 192:\n");
1.352 +print("b)\n");
1.353 +val e192b'="( 7 * x^^^3 + -1 * x^^^2 * y ) / ( 7 * x * y^^^2 + -1 * y^^^3 )";
1.354 +val e192b = the (rewrite_set thy' "rational_erls" false rls' e192b');
1.355 +val Some (t,_) = rewrite_set thy' "rational_erls" false mp "((x ^^^ 2)*(7 * x + (-1) * y))/((y ^^^ 2)*(7 * x + (-1) * y))";
1.356 +if t="(7 * x ^^^ 3 + -1 * (y * x ^^^ 2)) / (-1 * y ^^^ 3 + 7 * (x * y ^^^ 2))"then()
1.357 +(*TERMORDER ~~~~~*)
1.358 +else raise error "rationals.sml: 'e192b' new behaviour";
1.359 +
1.360 +print("\n\nexample 193:\n");
1.361 +print("a)\n");
1.362 +val e193a'="( x^^^2 + -6 * x + 9 ) / ( x^^^2 + -9 )";
1.363 +val e193a = the (rewrite_set thy' "rational_erls" false rls' e193a');
1.364 +print("b)\n");
1.365 +val e193b'="( x^^^2 + -8 * x + 16 ) / ( 2 * x^^^2 + -32 )";
1.366 +val e193b = the (rewrite_set thy' "rational_erls" false rls' e193b');
1.367 +print("c)\n");
1.368 +val e193c'="( 2 * x + -50 * x^^^3 ) / ( 25 * x^^^2 + -10 * x + 1 )";
1.369 +val Some(t,_) = rewrite_set thy' "rational_erls" false rls' e193c';
1.370 +--------------------------------15.10.02---*)
1.371 +
1.372 +
1.373 +(*---------- WN: 10.9.02:
1.374 +ML> val e204a = the (rewrite_set thy' "rational_erls" false rls' e204a');
1.375 +*** RATIONALS_STEP_CANCEL_EXCEPTION: Invalid fraction
1.376 +print("\n\nexample 204:\n");
1.377 +print("a)\n");
1.378 +val e204a'="((5 * x) / 9) + ((3 * x) / 9) + (x / 9)";
1.379 +val e204a = the (rewrite_set thy' "rational_erls" false rls' e204a');
1.380 +print("b)\n");
1.381 +val e204b'="5 / x + -3 / x + -1 / x";
1.382 +val e204b = the (rewrite_set thy' "rational_erls" false rls' e204b');
1.383 +
1.384 +print("\n\nexample 205:\n");
1.385 +print("a)\n");
1.386 +val e205a'="((4 * x + 7) / 8) + ((4 * x + 3) / 8)";
1.387 +val e205a = the (rewrite_set thy' "rational_erls" false rls' e205a');
1.388 +print("b)\n");
1.389 +val e205b'="((5 * x + 2) / 3) + ((-2 * x + 1) / 3)";
1.390 +val e205b = the (rewrite_set thy' "rational_erls" false rls' e205b');
1.391 +
1.392 +print("\n\nexample 206:\n");
1.393 +print("a)\n");
1.394 +val e206a'="((5 * x + 4) / (2 * x + -1)) + ((9 * x + 5) / (2 * x + -1))";
1.395 +val e206a = the (rewrite_set thy' "rational_erls" false rls' e206a');
1.396 +print("b)\n");
1.397 +val e206b'="((17 * x + -23) / (5 * x + 4)) + ((-25 + -17 * x) / (5 * x + 4))";
1.398 +val e206b = the (rewrite_set thy' "rational_erls" false rls' e206b');
1.399 +
1.400 +print("\n\nexample 207:\n");
1.401 +val e207'="((3 * x * y + 3 * y) / (x * y)) + ((5 * x * y + 7 * y) / (x * y)) + ((9 * x * y + -2 * y) / (x * y)) + ((x * y + 4 * y) / (x * y)) ";
1.402 +val e207 = the (rewrite_set thy' "rational_erls" false rls' e207');
1.403 +
1.404 +print("\n\nexample 208:\n");
1.405 +val e208'="((3 * x + 2) / (x + 2)) + ((5 * x + -1) / (x + 2)) + ((-7 * x + -3) / (x + 2)) + ((-1 * x + -3) / (x + 2)) ";
1.406 +val e208 = the (rewrite_set thy' "rational_erls" false rls' e208');
1.407 +
1.408 +print("\n\nexample 209:\n");
1.409 +val e209'="((3 * x + -7 * y + 3 * z) / (4)) + ((2 * x + 17 * y + 10 * z) / (4)) + ((-1 * x + 2 * y + z) / (4)) ";
1.410 +val e209 = the (rewrite_set thy' "rational_erls" false rls' e209');
1.411 +
1.412 +print("\n\nexample 210:\n");
1.413 +val e210'="((2 * x + 3 + -1 * x^^^2) / (5 * x)) + ((5 * x^^^2 + -2 * x + 1) / (5 * x)) + ((-3 * x^^^2 + -2 * x + 1) / (5 * x)) + ((-1 * x^^^2 + -3 * x + -5) / (5 * x)) ";
1.414 +val e210 = the (rewrite_set thy' "rational_erls" false rls' e210');
1.415 +
1.416 +print("\n\nexample 211:\n");
1.417 +print("a)\n");
1.418 +val e211a'="((b) / (a + -1 * b)) + ((-1 * a) / (a + -1 * b))";
1.419 +val e211a = the (rewrite_set thy' "rational_erls" false rls' e211a');
1.420 +print("b)\n");
1.421 +val e211b'="((b) / (b^^^2 + -1 * a^^^2)) + ((-1 * a) / (b^^^2 + -1 * a^^^2))";
1.422 +val e211b = the (rewrite_set thy' "rational_erls" false rls' e211b');
1.423 +
1.424 +print("\n\nexample 212:\n");
1.425 +print("a)\n");
1.426 +val e212a'="((4) / (x)) + ((-3) / (y)) + -1";
1.427 +val e212a = the (rewrite_set thy' "rational_erls" false rls' e212a');
1.428 +print("b)\n");
1.429 +val e212b'="((4) / (x)) + ((-5) / (y)) + ((6) / (x*y))";
1.430 +val e212b = the (rewrite_set thy' "rational_erls" false rls' e212b');
1.431 +
1.432 +print("\n\nexample 213:\n");
1.433 +print("a)\n");
1.434 +val e213a'="((5 * x) / (3 * y^^^2)) + ((19 * z) / (6 * x * y)) + ((-2 * x) / (3 * y^^^2)) + ((7 * y^^^2) / (6 * x^^^2)) ";
1.435 +val e213a = the (rewrite_set thy' "rational_erls" false rls' e213a');
1.436 +print("b)\n");
1.437 +val e213b'="((2 * b) / (3 * a^^^2)) + ((3 * c) / (7 * a * b)) + ((4 * b) / (3 * a^^^2)) + ((3 * a) / (7 * b^^^2))";
1.438 +val e213b = the (rewrite_set thy' "rational_erls" false rls' e213b');
1.439 +
1.440 +print("\n\nexample 214:\n");
1.441 +print("a)\n");
1.442 +val e214a'="((3 * x + 2 * y + 2 * z) / (4)) + ((-5 * x + -3 * y) / (3)) + ((x + y + -2 * z) / (2))";
1.443 +val e214a = the (rewrite_set thy' "rational_erls" false rls' e214a');
1.444 +print("b)\n");
1.445 +val e214b'="((5 * x + 2 * y + z) / (2)) + ((-7 * x + -3 * y) / (3)) + ((3 * x + 6 * y + -1 * z) / (12))";
1.446 +val e214b = the (rewrite_set thy' "rational_erls" false rls' e214b');
1.447 +
1.448 +print("\n\nexample 216:\n");
1.449 +print("a)\n");
1.450 +val e216a'="((2 * b + 3 * c) / (a * c)) + ((3 * a + b) / (a * b)) + ((-2 * b^^^2 + -3 * a * c) / (a * b * c))";
1.451 +val e216a = the (rewrite_set thy' "rational_erls" false rls' e216a');
1.452 +print("b)\n");
1.453 +val e216b'="((2 * a + 3 * b) / (b * c)) + ((3 * c + a) / (a * c)) + ((-2 * a^^^2 + -3 * b * c) / (a * b * c))";
1.454 +val e216b = the (rewrite_set thy' "rational_erls" false rls' e216b');
1.455 +
1.456 +print("\n\nexample 217:\n");
1.457 +val e217'="((z + -1) / (z)) + ((3 * z ^^^2 + -6 * z + 5) / (z^^^2)) + ((-4 * z^^^3 + 7 * z^^^2 + -5 * z + 5) / (z^^^3))";
1.458 +val e217 = the (rewrite_set thy' "rational_erls" false rls' e217');
1.459 +
1.460 +print("\n\nexample 218:\n");
1.461 +val e218'="((9 * a^^^3 - 5 * a^^^2 + 2 * a + 8) / (108 * a^^^4)) + ((-5 * a + 3 * a^^^2 + 4) / (8 * a^^^3)) + ((-261 * a^^^3 + 19 * a^^^2 + -112 * a + 16) / (216 * a^^^4))";
1.462 +val e218 = the (rewrite_set thy' "rational_erls" false rls' e218');
1.463 +
1.464 +print("\n\nexample 219:\n");
1.465 +print("a)\n");
1.466 +val e219a'="((1) / (y + 1)) + ((1) / (y + 2)) + ((1) / (y + 3))";
1.467 +val e219a = the (rewrite_set thy' "rational_erls" false rls' e219a');
1.468 +print("b)\n");
1.469 +val e219b'="((1) / (x + 1)) + ((1) / (x + 2)) + ((-2) / (x + 3))";
1.470 +val e219b = the (rewrite_set thy' "rational_erls" false rls' e219b');
1.471 +
1.472 +print("\n\nexample 220:\n");
1.473 +print("a)\n");
1.474 +val e220a'="((17) / (5 * r + -2)) + ((-13) / (2 * r + 3)) + ((4) / (3 * r + -5))";
1.475 +val e220a = the (rewrite_set thy' "rational_erls" false rls' e220a');
1.476 +print("b)\n");
1.477 +val e220b'="((20 * a) / (a + -3)) + ((-19 * a) / (a + -4)) + ((a) / (a + -5))";
1.478 +val e220b = the (rewrite_set thy' "rational_erls" false rls' e220b');
1.479 +
1.480 +print("\n\nexample 221:\n");
1.481 +print("a)\n");
1.482 +val e221a'="((a + b) / (a + -1 * b)) + ((a + -1 * b) / (a + b))";
1.483 +val e221a = the (rewrite_set thy' "rational_erls" false rls' e221a');
1.484 +print("b)\n");
1.485 +val e221b'="((x + -1 * y) / (x + y)) + ((x + y) / (x + -1 * y)) ";
1.486 +val e221b = the (rewrite_set thy' "rational_erls" false rls' e221b');
1.487 +
1.488 +print("\n\nexample 222:\n");
1.489 +print("a)\n");
1.490 +val e222a'="((1 + -1 * x) / (1 + x)) + ((-1 + -1 * x) / (1 + -1 * x)) + ((4 * x) / (1 + -1 * x^^^2))";
1.491 +val e222a = the (rewrite_set thy' "rational_erls" false rls' e222a');
1.492 +print("b)\n");
1.493 +val e222b'="((1 + x ) / (1 + -1 * x)) + ((-1 + x) / (1 + x)) + ((2 * x) / (1 + -1 * x^^^2))";
1.494 +val e222b = the (rewrite_set thy' "rational_erls" false rls' e222b');
1.495 +
1.496 +print("\n\nexample 225:\n");
1.497 +print("a)\n");
1.498 +val e225a'="((6 * a) / (a^^^2 + -64)) + ((a + 2) / (2 * a + 16)) + ((-1) / (2))";
1.499 +val e225a = the (rewrite_set thy' "rational_erls" false rls' e225a');
1.500 +print("b)\n");
1.501 +val e225b'="((a + 2 ) / (2 * a + 12)) + ((4 * a) / (a^^^2 + -36)) + ((-1) / (2))";
1.502 +val e225b = the (rewrite_set thy' "rational_erls" false rls' e225b');
1.503 +
1.504 +print("\n\nexample 226:\n");
1.505 +print("a)\n");
1.506 +val e226a'="((35 * z) / (49 * z^^^2 + -4)) + -1 + ((14 * z + -1) / (14 * z + 4)) ";
1.507 +val e226a = the (rewrite_set thy' "rational_erls" false rls' e226a');
1.508 +print("b)\n");
1.509 +val e226b'="((45 * a * b) / (25 * a^^^2 + -9 * b^^^2)) + ((20 * a + 3 * b) / (10 * a + 6 * b)) + -2";
1.510 +val e226b = the (rewrite_set thy' "rational_erls" false rls' e226b');
1.511 +
1.512 +print("\n\nexample 227:\n");
1.513 +print("a)\n");
1.514 +val e227a'="((6 * z + 11) / (6 * z + 14)) + ((9 * z ) / (9 * z^^^2 + -49)) + -1 ";
1.515 +val e227a = the (rewrite_set thy' "rational_erls" false rls' e227a');
1.516 +print("b)\n");
1.517 +val e227b'="((16 * a + 37 * b) / (4 * a + 10 * b)) + ((6 * a * b) / (4 * a^^^2 + -25 * b^^^2)) + -4 ";
1.518 +val e227b = the (rewrite_set thy' "rational_erls" false rls' e227b');
1.519 +
1.520 +print("\n\nexample 228:\n");
1.521 +print("a)\n");
1.522 +val e228a'="((7 * a + 11) / (3 * a^^^2 + -3)) + ((-2 * a + -1) / (a^^^2 + -1 * a)) + ((-1) / (3 * a + 3))";
1.523 +val e228a = the (rewrite_set thy' "rational_erls" false rls' e228a');
1.524 +print("b)\n");
1.525 +val e228b'="((11 * z + 2 * b) / (4 * b * z + -8 * b^^^2)) + ((-8 * z) / (z^^^2 + -4 * b^^^2)) + ((-9 * z + -2 * b) / (4 * b * z + 8 * b^^^2))";
1.526 +val e228b = the (rewrite_set thy' "rational_erls" false rls' e228b');
1.527 +
1.528 +
1.529 +print("\n\nexample 229:\n");
1.530 +print("a)\n");
1.531 +val e229a'="((5 * x^^^2 + y) / (x + 2 * y)) + ((-8 * x^^^3 + 4 * x^^^2 * y + 3 * x * y) / (x^^^2 + -4 * y^^^2)) + ((3 * x^^^2 + -4 * y) / (x + -2 * y))";
1.532 +val e229a = the (rewrite_set thy' "rational_erls" false rls' e229a');
1.533 +print("b)\n");
1.534 +val e229b'="((7 * x^^^2 + y) / (x + 3 * y)) + ((-24 * x^^^2 * y + 5 * x * y + 21 * y^^^2) / (x^^^2 + -9 * y^^^2)) + ((4 * x^^^2 + -6 * y) / (x + -3 * y))";
1.535 +val e229b = the (rewrite_set thy' "rational_erls" false rls' e229b');
1.536 +
1.537 +print("\n\nexample 230:\n");
1.538 +print("a)\n");
1.539 +val e230a'="((5 * x^^^2 + y) / (2 * x + y)) + ((-16 * x^^^3 + 2 * x^^^2 * y + 6 * x * y) / (4 * x^^^2 + -1 * y^^^2)) + ((3 * x^^^2 + -4 * y) / (2 * x + -1 * y))";
1.540 +val e230a = the (rewrite_set thy' "rational_erls" false rls' e230a');
1.541 +print("b)\n");
1.542 +val e230b'="((7 * x^^^2 + y) / (3 * x + y)) + ((-3 * x^^^3 + 15 * x * y + -7 * x^^^2 * y + 7 * y^^^2) / (9 * x^^^2 + -1 * y^^^2)) + ((4 * x^^^2 + -6 * y) / (3 * x + -1 * y))";
1.543 +val e230b = the (rewrite_set thy' "rational_erls" false rls' e230b');
1.544 +
1.545 +print("\n\nexample 231:\n");
1.546 +print("a)\n");
1.547 +val e231a'="((2 * x + 5 * y) / (x)) + ((2 * x^^^3 + -5 * y^^^3 + 3 * x * y^^^2) / (x^^^3 + -2 * x^^^2 * y + x * y^^^2)) + ((-3 * x + -6 * y) / (x + -1 * y))";
1.548 +val e231a = the (rewrite_set thy' "rational_erls" false rls' e231a');
1.549 +print("b)\n");
1.550 +val e231b'="((6 * x + 2 * y) / (x)) + ((6 * x^^^2 * y + -4 * x * y^^^2 + -2 * y^^^3) / (x^^^3 + -2 * x^^^2 * y + x * y^^^2)) + ((-5 * x + -3 * y) / (x + -1 * y))";
1.551 +val e231b = the (rewrite_set thy' "rational_erls" false rls' e231b');
1.552 +
1.553 +print("\n\nexample 232:\n");
1.554 +print("a)\n");
1.555 +val e232a'="((2 * x + 3 * y) / (x)) + ((4 * x^^^3 + -1 * x * y^^^2 + -3 * y^^^3) / (x^^^3 + -2 * x^^^2 * y + x * y^^^2)) + ((-5 * x + -6 * y) / (x + -1 * y))";
1.556 +val e232a = the (rewrite_set thy' "rational_erls" false rls' e232a');
1.557 +print("b)\n");
1.558 +val e232b'="((5 * x + 2 * y) / (x)) + ((2 * x^^^3 + -3 * x * y^^^2 + 3 * x^^^2 * y + -2 * y^^^3) / (x^^^3 + -2 * x^^^2 * y + x * y^^^2)) + ((-6 * x + -3 * y) / (x + -1 * y))";
1.559 +val e232b = the (rewrite_set thy' "rational_erls" false rls' e232b');
1.560 +
1.561 +print("\n\nexample 233:\n");
1.562 +print("a)\n");
1.563 +val e233a'="((5 * x + 6 * y) / (x)) + ((5 * x * y^^^2 + -6 * y^^^3 + -2 * x^^^3 + 3 * x^^^2 * y) / (x^^^3 + -2 * x^^^2 * y + x * y^^^2)) + ((-2 * x + -3 * y) / (x + -1 * y))";
1.564 +val e233a = the (rewrite_set thy' "rational_erls" false rls' e233a');
1.565 +print("b)\n");
1.566 +val e233b'="((6 * x + 5 * y) / (x)) + ((4 * x^^^2 * y + 3 * x * y^^^2 + -5 * y^^^3 + -2 * x^^^3) / (x^^^3 + -2 * x^^^2 * y + x * y^^^2)) + ((-3 * x + -2 * y) / (x + -1 * y))";
1.567 +val e233b = the (rewrite_set thy' "rational_erls" false rls' e233b');
1.568 +
1.569 +print("\n\nexample 234:\n");
1.570 +print("a)\n");
1.571 +val e234a'="((5 * a + b) / (2 * a * b + -2 * b^^^2)) + ((-3 * a + -1 * b) / (2 * a * b + 2 * b^^^2)) + ((-2 * a) / (a^^^2 + -1 * b^^^2))";
1.572 +val e234a = the (rewrite_set thy' "rational_erls" false rls' e234a');
1.573 +print("b)\n");
1.574 +val e234b'="((5 * a + 3 * b) / (6 * a * b + -18 * b^^^2)) + ((-3 * a + -3 * b) / (6 * a * b + 18 * b^^^2)) + ((-2 * a) / (a^^^2 + -9 * b^^^2)) ";
1.575 +val e234b = the (rewrite_set thy' "rational_erls" false rls' e234b');
1.576 +
1.577 +print("\n\nexample 235:\n");
1.578 +print("a)\n");
1.579 +val e235a'="((10 * x + 3 * y) / (12 * x * y + -18 * y^^^2)) + ((-6 * x + -3 * y) / (12 * x * y + 18 * y^^^2)) + ((-4 * x) / (4 * x^^^2 + -9 * y^^^2))";
1.580 +val e235a = the (rewrite_set thy' "rational_erls" false rls' e235a');
1.581 +print("b)\n");
1.582 +val e235b'="((8 * a + b) / (4 * a * b + -2 * b^^^2)) + ((-4 * a + -1 * b) / (4 * a * b + 2 * b^^^2)) + ((-2 * a) / (4 * a^^^2 + -1 * b^^^2)) ";
1.583 +val e235b = the (rewrite_set thy' "rational_erls" false rls' e235b');
1.584 +
1.585 +print("\n\nexample 236:\n");
1.586 +print("a)\n");
1.587 +val e236a'="((8 * a + 5 * b) / (20 * a * b + -50 * b^^^2)) + ((-4 * a + -5 * b) / (20 * a * b + 50 * b^^^2)) + ((-2 * a) / (4 * a^^^2 + -25 * b^^^2))";
1.588 +val e236a = the (rewrite_set thy' "rational_erls" false rls' e236a');
1.589 +print("b)\n");
1.590 +val e236b'="((24 * x + y) / (6 * x * y + -2 * y^^^2)) + ((-18 * x + -1 * y) / (6 * x * y + 2 * y^^^2)) + ((-15 * x) / (9 * x^^^2 + -1 * y^^^2)) ";
1.591 +val e236b = the (rewrite_set thy' "rational_erls" false rls' e236b');
1.592 +
1.593 +print("\n\nexample heuberger:\n");
1.594 +val eheu'="(x^^^4 + x * y + x^^^3 * y + y^^^2) / (x + 5 * x^^^2 + y + 5 * x * y + x^^^2 * y^^^3 + x * y^^^4)";
1.595 +val eheu = the (rewrite_set thy' "rational_erls" false rls' eheu');
1.596 +
1.597 +print("\n\nexample stiefel:\n");
1.598 +val est1'="(7) / (-14) + (-2) / (4)";
1.599 +val est1 = the (rewrite_set thy' "rational_erls" false rls' est1');
1.600 +if est1 = ("(-1) / 1",[]) then ()
1.601 +else raise error "new behaviour in rationals.sml: est1'";
1.602 +-------------------------------------------------------------------------*)
1.603 +
1.604 +
1.605 +(*
1.606 + val t = (term_of o the o (parse thy))
1.607 + "(9 - x ^^^ 2) / (9 - 6 * x + x ^^^ 2)";
1.608 + val Some (t',_) = factor_expanded_ thy t;
1.609 + term2str t';
1.610 +
1.611 + "((-3) - x) * ((-3) + x) / (((-3) + x) * ((-3) + x))"
1.612 + "(3 + x) * (3 - x) / ((3 - x) * (3 - x))"
1.613 +*)
1.614 +
1.615 +
1.616 +
1.617 +(*WN.28.8.02: tests for the 'reverse-rewrite' functions:
1.618 + these are defined in Rationals.ML and stored in
1.619 + the 'reverse-ruleset' cancel*)
1.620 +
1.621 +(*the term for which reverse rewriting is demonstrated*)
1.622 + val t = (term_of o the o (parse thy))
1.623 + "(9 - x ^^^ 2) / (9 + 6 * x + x ^^^ 2)";
1.624 + val Rrls {scr=Rfuns {init_state=ini,locate_rule=loc,
1.625 + next_rule=nex,normal_form=nor,...},...} = cancel;
1.626 +
1.627 +(*normal_form produces the result in ONE step*)
1.628 + val Some (t',_) = nor t;
1.629 + term2str t';
1.630 +
1.631 +(*initialize the interpreter state used by the 'me'*)
1.632 + val (t,_,revsets,_) = ini t;
1.633 +
1.634 +(*find the rule 'r' to apply to term 't'*)
1.635 + val Some r = nex revsets t;
1.636 + (*val r = Thm ("sym_#mult_2_3","6 = 2 * 3") : rule*)
1.637 +
1.638 +(*check, if the rule 'r' applied by the user to 't' belongs to the ruleset;
1.639 + if the rule is OK, the term resulting from applying the rule is returned,too;
1.640 + there might be several rule applications inbetween,
1.641 + which are listed after the thead in reverse order*)
1.642 + val (r,(t,asm))::_ = loc revsets t r;
1.643 + term2str t;
1.644 + "(9 - x ^^^ 2) / (3 ^^^ 2 + 6 * x + x ^^^ 2)";
1.645 +
1.646 +(*find the next rule to apply*)
1.647 + val Some r = nex revsets t;
1.648 + (*val r = Thm ("sym_#power_3_2","9 = 3 ^^^ 2") : rule*)
1.649 +
1.650 +(*check the next rule*)
1.651 + val (r,(t,asm))::_ = loc revsets t r;
1.652 + term2str t;
1.653 + "(3 ^^^ 2 - x ^^^ 2) / (3 ^^^ 2 + 6 * x + x ^^^ 2)";
1.654 +
1.655 +(*find and check the next rules, rewrite*)
1.656 + val Some r = nex revsets t;
1.657 + val (r,(t,asm))::_ = loc revsets t r;
1.658 + term2str t;
1.659 + "(3 ^^^ 2 - x ^^^ 2) / (3 ^^^ 2 + 2 * 3 * x + x ^^^ 2)";
1.660 +
1.661 + val Some r = nex revsets t;
1.662 + val (r,(t,asm))::_ = loc revsets t r;
1.663 + term2str t;
1.664 + "(3 - x) * (3 + x) / (3 ^^^ 2 + 2 * 3 * x + x ^^^ 2)";
1.665 +
1.666 + val Some r = nex revsets t;
1.667 + val (r,(t,asm))::_ = loc revsets t r;
1.668 + term2str t;
1.669 + "(3 - x) * (3 + x) / ((3 + x) * (3 + x))";
1.670 +
1.671 + val Some r = nex revsets t;
1.672 + val (r,(t,asm))::_ = loc revsets t r;
1.673 + val ss = term2str t;
1.674 + if ss = "(3 - x) / (3 + x)" then ()
1.675 + else raise error "rational.sml: new behav. in rev-set cancel";
1.676 + terms2str asm;
1.677 +
1.678 +
1.679 +
1.680 +(*WN.11.9.02: the 'reverse-ruleset' cancel*)
1.681 +
1.682 + (*the term for which reverse rewriting is demonstrated*)
1.683 + val t = (term_of o the o (parse thy))
1.684 + "(9 + (-1)*x^^^2) / (9 + ((-6)*x + x^^^2))";
1.685 + val Rrls {scr=Rfuns {init_state=ini,locate_rule=loc,
1.686 + next_rule=nex,normal_form=nor,...},...} = cancel;
1.687 + (*normal_form produces the result in ONE step*)
1.688 + val Some (t',_) = nor t;
1.689 + term2str t';
1.690 + (*initialize the interpreter state used by the 'me'*)
1.691 + val (t,_,revsets,_) = ini t;
1.692 +(*
1.693 + val [rs] = revsets;
1.694 + filter_out (eq_Thms ["sym_real_add_zero_left",
1.695 + "sym_real_mult_0",
1.696 + "sym_real_mult_1"]) rs;
1.697 +
1.698 + 10.10.02: dieser Fall terminiert nicht (make_poly enth"alt zu viele rules)
1.699 + val Some r = nex revsets t;
1.700 + val (r,(t,asm))::_ = loc revsets t r;
1.701 + term2str t;
1.702 +
1.703 + val Some r = nex revsets t;
1.704 + val (r,(t,asm))::_ = loc revsets t r;
1.705 + term2str t;
1.706 +
1.707 + ------ revset ----------------------------------------------------
1.708 +/// [Thm ("sym_real_add_zero_left","?z = 0 + ?z"),
1.709 +/// Thm ("sym_real_mult_0","0 = 0 * ?z"),
1.710 +! Thm ("sym_#mult_2_(-3)","(-6) * x = 2 * ((-3) * x)"),
1.711 +! Thm ("sym_#add_(-3)_3","0 = (-3) + 3"),
1.712 +
1.713 +? Thm ("sym_real_num_collect_assoc",
1.714 + "[| ?l is_const; ?m is_const |]
1.715 + ==> (?l + ?m) * ?n + ?k = ?l * ?n + (?m * ?n + ?k)"),
1.716 +OK Thm ("sym_real_mult_2_assoc","2 * ?z1.0 + ?k = ?z1.0 + (?z1.0 + ?k)"),
1.717 +OK Thm ("sym_real_add_left_commute","?y + (?x + ?z) = ?x + (?y + ?z)"),
1.718 +/// Thm ("sym_real_mult_1","?z = 1 * ?z"),
1.719 +! Thm ("sym_#power_3_2","9 = 3 ^^^ 2"),
1.720 +! Thm ("sym_#mult_-1_-1","1 * x ^^^ 2 = -1 * (-1 * x ^^^ 2)"),
1.721 +! Thm ("sym_#mult_-1_3","(-3) * x = -1 * (3 * x)"),
1.722 +OK Thm ("realpow_twoI","?r1 ^^^ 2 = ?r1 * ?r1" [.]),
1.723 +OK Thm ("sym_real_add_assoc",
1.724 + "?z1.0 + (?z2.0 + ?z3.0) = ?z1.0 + ?z2.0 + ?z3.0"),
1.725 +OK Thm
1.726 + ("sym_real_mult_assoc","?z1.0 * (?z2.0 * ?z3.0) = ?z1.0 * ?z2.0 * ?z3.0"),
1.727 +OK Thm ("sym_real_mult_left_commute",
1.728 + "?z2.0 * (?z1.0 * ?z3.0) = ?z1.0 * (?z2.0 * ?z3.0)"),
1.729 +OK Thm ("sym_real_mult_commute","?w * ?z = ?z * ?w"),
1.730 +? Thm ("sym_real_add_mult_distrib2",
1.731 + "?w * ?z1.0 + ?w * ?z2.0 = ?w * (?z1.0 + ?z2.0)"),
1.732 +? Thm ("sym_real_add_mult_distrib",
1.733 + "?z1.0 * ?w + ?z2.0 * ?w = (?z1.0 + ?z2.0) * ?w"),
1.734 +OK Thm ("real_mult_div_cancel2","?k ~= 0 ==> ?m * ?k / (?n * ?k) = ?m / ?n")]
1.735 + -------- revset ----------------------------------------------------
1.736 +
1.737 + val t = (term_of o the o (parse thy)) "(-6) * x";
1.738 + val t = (term_of o the o (parse thy))
1.739 + "(9 + (-1)*x^^^2) / (9 + ((-6)*x + x^^^2))";
1.740 + val thm = (mk_thm thy "(-6) * x = 2 * ((-3) * x)")
1.741 + handle e => print_exn e;
1.742 + val Some (t',_) = rewrite_ thy e_rew_ord e_rls false thm t;
1.743 + term2str t';
1.744 +----------------------------------------------------------------------*)
1.745 +
1.746 +
1.747 +
1.748 +(* SK: Testbeispiele --- WN kopiert Rational.ML -> rational.sml-----
1.749 +
1.750 +val t1 = (term_of o the o (parse thy)) "((3 * x^^^2 + 6 *x + 3) / (2*x + 2))";
1.751 +val Some (t1',rest)= cancel_ thy t1;
1.752 +val Some (t1'',_)= factor_out_gcd_ thy t1;
1.753 +print(term2str t1'^" + Einschr\"ankung: "^term2str (hd(rest)));
1.754 +term2str t1'';
1.755 +
1.756 +val t1 = (term_of o the o (parse thy)) "((-3 * x^^^2 + 6 *x - 3) / (2*x - 2))";
1.757 +val Some (t1',_)= cancel_ thy t1;
1.758 +val Some (t1'',_)= factor_expanded_ thy t1;
1.759 +term2str t1';
1.760 +term2str t1'';
1.761 +
1.762 +val t2 = (term_of o the o (parse thy)) "((x+ (-1)) / (x + 1)) + ((x + 1) / (x + (-1)))";
1.763 +val Some (t2',_) = add_fractions_ thy t2;
1.764 +val Some (t2'',_) = common_nominators_ thy t2;
1.765 +term2str t2';
1.766 +term2str t2'';
1.767 +
1.768 +val t2 = (term_of o the o (parse thy)) "((x - 1) / (x + 1)) + ((x + 1) / (x - 1))";
1.769 +val Some (t2',_) = add_expanded_frac_ thy t2;
1.770 +val Some (t2'',_) = common_expanded_nom_ thy t2;
1.771 +term2str t2';
1.772 +term2str t2'';
1.773 +
1.774 +
1.775 +val t3 = (term_of o the o (parse thy)) "((1) / (2*x + 2)) + ((1) / (2*x + (-2))) + ((1) / ( x^^^2 + (-1)))+((1) / (x^^^2 + (-2)*x + 1))";
1.776 +val Some (t3',_) = common_nominators_ thy t3;
1.777 +val Some (t3'',_) = add_fractions_ thy t3;
1.778 +(term2str t3');
1.779 +(term2str t3'');
1.780 +
1.781 +val t3 = (term_of o the o (parse thy)) "((1) / (2*x + 2)) + ((1) / (2*x - 2)) + ((1) / ( x^^^2 - 1))+((1) / (x^^^2 - 2 * x + 1))";
1.782 +val Some (t3',_) = common_expanded_nom_ thy t3;
1.783 +val Some (t3'',_) = add_expanded_frac_ thy t3;
1.784 +(term2str t3');
1.785 +(term2str t3'');
1.786 +-------------------------------*)
1.787 +
1.788 +(*
1.789 +val Some(t4,t5) = norm_rational_ thy t3;
1.790 +term2str t4;
1.791 +term2str (hd(t5));*)
1.792 +
1.793 +(*val test1 = (term_of o the o (parse thy)) "1 - x^^^2 - 5 * x^^^5";
1.794 +val test2 = (term_of o the o (parse thy)) "1 + (-1) * x ^^^ 2 + (-5) * x ^^^ 5";
1.795 +val test2 = (term_of o the o (parse thy)) "1 - x";
1.796 +val test2 = (term_of o the o (parse thy)) "1 + (-1) * x";
1.797 +term2str(expanded2term(test1));
1.798 +term2str(term2expanded(test2)); *)
1.799 +
1.800 +
1.801 +
1.802 +(* WN kopiert 16.10.02 Rational.ML -> rational.sml-----vvv---*)
1.803 +
1.804 + val t=(term_of o the o (parse thy)) "(9 - x^^^2)/(9 - 6*x + x^^^2)";
1.805 + val Some (t',_) = factout_ thy t;
1.806 + val Some (t'',_) = cancel_ thy t;
1.807 + term2str t';
1.808 + term2str t'';
1.809 + "(3 + x) * (3 - x) / ((3 - x) * (3 - x))";
1.810 + "(3 + x) / (3 - x)";
1.811 +
1.812 + val t=(term_of o the o(parse thy))
1.813 + "(9 - x^^^2) / (9 - 6*x + x^^^2) + 1 / (3 - x)";
1.814 + val Some (t',_) = common_nominator_ thy t;
1.815 + val Some (t'',_) = add_fraction_ thy t;
1.816 + term2str t';
1.817 + term2str t'';
1.818 + "(9 - x ^^^ 2) / ((3 - x) * (3 - x)) + 1 * (3 - x) / ((3 - x) * (3 - x))";
1.819 + "(4 + x) / (3 - x)";
1.820 +
1.821 + (*WN.16.10.02 hinzugef"ugt -----vv---*)
1.822 + val t=(term_of o the o(parse thy))
1.823 + "(9 - x^^^2) / (9 - 6*x + x^^^2) + 1";
1.824 + val Some (t',_) = common_nominator_ thy t;
1.825 + val Some (t'',_) = add_fraction_ thy t;
1.826 + term2str t';
1.827 + term2str t'';
1.828 + "(9 - x ^^^ 2) / (9 - 6 * x + x ^^^ 2) +\
1.829 + \1 * (9 - 6 * x + x ^^^ 2) / (9 - 6 * x + x ^^^ 2)";
1.830 + "6 / (3 - x)";
1.831 +
1.832 + val t=(term_of o the o(parse thy))
1.833 + "1 + (9 - x^^^2) / (9 - 6*x + x^^^2)";
1.834 + val Some (t',_) = common_nominator_ thy t;
1.835 + val Some (t'',_) = add_fraction_ thy t;
1.836 + term2str t';
1.837 + term2str t'';
1.838 + "1 * (9 - 6 * x + x ^^^ 2) / (9 - 6 * x + x ^^^ 2) +\
1.839 + \(9 - x ^^^ 2) / (9 - 6 * x + x ^^^ 2)";
1.840 + "6 / (3 - x)";
1.841 + (*WN.16.10.02 hinzugef"ugt -----^^---*)
1.842 +
1.843 + val t=(term_of o the o (parse thy))
1.844 + "(y^^^2 - x^^^2)/(y^^^2 - 2*y*x + x^^^2)";
1.845 + val Some (t',_) = factout_ thy t;
1.846 + val Some (t'',_) = cancel_ thy t;
1.847 + term2str t';
1.848 + term2str t'';
1.849 + "(y + x) * (y - x) / ((y - x) * (y - x))";
1.850 + "(y + x) / (y - x)";
1.851 +
1.852 + val t=(term_of o the o (parse thy))
1.853 + "(y^^^2 - x^^^2)/(y^^^2 - 2*y*x + x^^^2) + 1 / (y - x)";
1.854 + val Some (t',_) = common_nominator_ thy t;
1.855 + val Some (t'',_) = add_fraction_ thy t;
1.856 + term2str t';
1.857 + term2str t'';
1.858 + "((-1) * x ^^^ 2 + y ^^^ 2) / (((-1) * x + y) * ((-1) * x + y)) +\
1.859 + \1 * ((-1) * x + y) / (((-1) * x + y) * ((-1) * x + y))";
1.860 + "((-1) - x - y) / (x - y)";
1.861 + (*WN.16.10.02 ^^^^^^^ Reihenfolge aus Angabe umgekehrt ?!*)
1.862 +
1.863 + val t=(term_of o the o (parse thy))
1.864 + "(x^^^2 - y^^^2)/(x^^^2 - 2*x*y + y^^^2) + 1 / (x - y)";
1.865 + val Some (t',_) = common_nominator_ thy t;
1.866 + val Some (t'',_) = add_fraction_ thy t;
1.867 + term2str t';
1.868 + term2str t'';
1.869 + "((-1) * y ^^^ 2 + x ^^^ 2) / (((-1) * y + x) * ((-1) * y + x)) +\
1.870 + \1 * ((-1) * y + x) / (((-1) * y + x) * ((-1) * y + x))";
1.871 + "((-1) - y - x) / (y - x)";
1.872 + (*WN.16.10.02 ^^^^^^^ lexicographische Ordnung ?!*)
1.873 +
1.874 + val t=(term_of o the o (parse thy))
1.875 + "(y^^^2 - x^^^2)/(y^^^2 - 2*y*x + x^^^2)";
1.876 + val Some (t',_) = norm_expanded_rat_ thy t;
1.877 + term2str t';
1.878 + "(y + x) / (y - x)";
1.879 +(*val Some (t'',_) = norm_rational_ thy t;
1.880 + term2str t'';
1.881 + *** RATIONALS_TERM2POLY_EXCEPTION: Invalid Polynomial
1.882 + WN.16.10.02 ?!*)
1.883 +
1.884 + val t=(term_of o the o (parse thy))
1.885 + "(9 - x^^^2)/(9 - 6*x + x^^^2) + (1)/(3 + x)";
1.886 + val Some (t',_) = norm_expanded_rat_ thy t;
1.887 + term2str t';
1.888 + "(12 + 5 * x + x ^^^ 2) / (9 - x ^^^ 2)";
1.889 +(*val Some (t'',_) = norm_rational_ thy t;
1.890 + term2str t'';
1.891 + *** RATIONALS_TERM2POLY_EXCEPTION: Invalid Polynomial
1.892 + WN.16.10.02 ?!*)
1.893 +
1.894 + val t=(term_of o the o (parse thy))
1.895 + "(9 + (-1)* x^^^2)/(9 + (-1)* 6*x + x^^^2) + (1)/(3 + x)";
1.896 + val Some (t',_) = norm_expanded_rat_ thy t;
1.897 + val Some (t'',_) = norm_rational_ thy t;
1.898 + term2str t';
1.899 + term2str t'';
1.900 + "(12 + 5 * x + x ^^^ 2) / (9 - x ^^^ 2)";
1.901 + "(12 + 5 * x + x ^^^ 2) / (9 + (-1) * x ^^^ 2)";
1.902 +(* WN kopiert 16.10.02 Rational.ML -> rational.sml-----^^^---*)
1.903 +
1.904 +
1.905 +