4 use"../kbtest/rational.sml";
5 use"kbtest/rational.sml";
9 (*--------------------------------15.10.02---
11 print("\n\n********************* tests *************************\n\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_)));
14 (* result: [(1,[0,0,1]),(1,[0,0,0])] *)
15 if mv_pquot1=[(1,[0,0,1]),(1,[0,0,0])] then () else error ("Test failed");
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])] *)
19 if mv_prest1=[(1,[1,0,1]),(~1,[0,0,1])] then () else error ("Test failed");
21 val mv_pquot2 = (#1(mv_division([(4,[2]),(8,[1]),(16,[0])],[(1,[1]),(1,[0])],LEX_)));
22 (* result: [(4,[1]),(4,[0])] *)
23 if mv_pquot2=[(4,[1]),(4,[0])] then () else error ("Test failed");
25 val mv_prest2 = (#2(mv_division([(4,[2]),(8,[1]),(16,[0])],[(1,[1]),(1,[0])],LEX_)));
26 (* result: [(12,[0]] *)
27 if mv_prest2=[(12,[0])] then () else error ("Test failed");
29 val mv_pquot3 = (#1(mv_division([(4,[2]),(~4,[0])],[(2,[1]),(2,[0])],LEX_)));
30 (* [(2,[1]),(~2,[0])] *)
31 if mv_pquot3=[(2,[1]),(~2,[0])] then () else error ("Test failed");
33 val mv_prest3 = (#2(mv_division([(1,[2]),(~1,[0])],[(2,[1]),(2,[0])],LEX_)));
34 (* [(1,[2]),(~1,[0])] *)
35 if mv_prest3=[(1,[2]),(~1,[0])] then () else error ("Test failed");
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_)));
39 if mv_pquot4=[(1,[0,1,1])] then () else error ("Test failed");
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])] *)
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");
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])]*)
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");
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_)));
51 if mv_prest5=[] then () else error ("Test failed");
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_)));
55 if mv_pquot6=[(1,[1,0,0]),(1,[0,1,0]),(1,[0,0,0])] then () else error ("Test failed");
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 error ("Test failed");
61 (* mv_division ([(1,[0,0,0])],[(0,[1,2,3])],LEX_); *)
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])]);
65 (* [(1,[0,1]),(1,[0,0])] *)
66 if mv_cont1=[(1,[0,1]),(1,[0,0])] then () else error ("Test failed");
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])]*)
70 if mv_pp1=[(1,[1,0]),(1,[0,0])] then () else error ("Test failed");
72 val mv_cont2=mv_content([(2,[1]),(4,[0])]);
74 if mv_cont2=[(2,[0])] then () else error ("Test failed");
76 val mv_pp2=mv_pp([(2,[1]),(4,[0])]);
77 (* [(1,[1]),(2,[0])] *)
78 if mv_pp2=[(1,[1]),(2,[0])] then () else error ("Test failed");
80 val mv_cont3=mv_content[(8,[2,1,1]),(12,[1,0,2]),(10,[2,2,0]),(16,[1,1,1])];
82 if mv_cont3=[(2,[0,0,0])] then () else error ("Test failed");
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])] *)
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");
88 val mv_cont4=mv_content[(2,[2,1,0]),(3,[1,0,1]),(2,[1,1,0]),(3,[0,0,1])];
90 if mv_cont4=[(1,[0,0,0])] then () else error ("Test failed");
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])] *)
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");
96 val con1=mv_content([(9,[2,0]),(15,[1,1]),(12,[1,0]),(6,[0,2]),(12,[0,1])]);
98 if con1=[(3,[0,0])] then () else error ("Test failed");
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])] *)
102 if pp1=[(3,[2,0]),(5,[1,1]),(4,[1,0]),(2,[0,2]),(4,[0,1])] then () else error ("Test failed");
104 val con2=mv_content([(1,[2,0]),(1,[1,1]),(1,[1,0]),(1,[0,2]),(1,[0,1])]);
106 if con2=[(1,[0,0])] then () else error ("Test failed");
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])] *)
110 if pp2=[(1,[2,0]),(1,[1,1]),(1,[1,0]),(1,[0,2]),(1,[0,1])] then () else error ("Test failed");
112 val cont1 = mv_content [(1,[2,1,0]),(2,[2,1,0])];
114 if cont1=[(3,[0,1,0])] then () else error ("Test failed");
116 val pp1 = mv_pp [(1,[2,1,0]),(2,[2,1,0])];
118 if pp1=[(1,[2,0,0])] then () else error ("Test failed");
120 val cont2 = mv_content [(4,[1,2,0]),(2,[2,1,0])];
122 if cont2=[(2,[0,1,0])] then () else error ("Test failed");
124 val pp2 = mv_pp [(4,[1,2,0]),(2,[2,1,0])];
125 (* [(1,[2,0,0]),(2,[1,1,0])] *)
126 if pp2=[(1,[2,0,0]),(2,[1,1,0])] then () else error ("Test failed");
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])];
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])];
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])];
136 (* [(2,[1,1]),(2,[0,0])] *)
137 if ggt1=[(2,[1,1]),(2,[0,0])] then () else error ("Test failed");
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])] *)
141 if ggt2=[(2,[1,1,0]),(3,[0,0,1])] then () else error ("Test failed");
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])] *)
145 if ggt3=[(1,[1,0,0]),(~1,[0,0,1])] then () else error ("Test failed");
147 val ggt4 = gcd_poly [(1,[2,1,0]),(2,[2,1,0])] [(5,[1,0,0])];
149 if ggt4=[(1,[1,0,0])] then () else error ("Test failed");
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])] *)
153 if ggt5=[(1,[1,0,0]),(~1,[0,0,1])] then () else error ("Test failed");
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])];
157 if ggt6=[(1,[1,0,0])] then () else error ("Test failed");
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])] *)
161 if ggt7=[(13,[3,1,1]),(~19,[2,1,2]),(7,[2,1,0])] then () else error ("Test failed");
163 print("\n\n***** kgv-tests *****\n");
164 val kgv1=lcm_poly [(10,[])] [(15,[])];
166 if kgv1=[(30,[])] then () else error ("Test failed");
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])] *)
170 if kgv2=[(1,[2,0,0]),(~2,[1,0,1]),(1,[0,0,2])] then () else error ("Test failed");
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])] *)
174 if kgv3=[(4,[3,0,0]),(~4,[2,0,1]),(~4,[1,0,2]),(4,[0,0,3])] then () else error ("Test failed");
177 print("***** TERM2POLY-TESTS *****\n");
178 val t0 = (term_of o the o (parse thy)) "3 * 4";
179 val t1 = (term_of o the o (parse thy)) "27";
180 val t11= (term_of o the o (parse thy)) "27 * c";
181 val t2 = (term_of o the o (parse thy)) "b";
182 val t23= (term_of o the o (parse thy)) "c^^^7";
183 val t24= (term_of o the o (parse thy)) "5 * c^^^7";
184 val t26= (term_of o the o (parse thy)) "a * b";
185 val t3 = (term_of o the o (parse thy)) "2 + a";
186 val t4 = (term_of o the o (parse thy)) "b + a";
187 val t5 = (term_of o the o (parse thy)) "2 + a^^^3";*)
188 val t6 = (term_of o the o (parse thy)) "5*a^^^2*b^^^3*c+4*a^^^4*b+2*a*c";
189 val t7 = (term_of o the o (parse thy)) "a-b";
191 (the o term2poly) t0;
192 (the o term2poly) t1;
193 (the o term2poly) t11;
194 (the o term2poly) t2;
195 (the o term2poly) t23;
196 (the o term2poly) t24;
197 (the o term2poly) t26;
198 (the o term2poly) t3;
199 (the o term2poly) t4;
200 (the o term2poly) t5;
201 (the o term2poly) t6;
202 (the o term2poly) t7;*)
205 print("\n\n***** STEP_CANCEL_TESTS: *****\n");
207 val term2 = (term_of o the o (parse thy)) " (9 * a^^^2 * b) /// (6 * a * c)";
208 val div2 = step_cancel term2;
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;
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");*)
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;
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");*)
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;
226 (*val mul1=(term_of o the o (parse thy)) "(5*a*b*c+4*a*b+2*a*c)";
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")));
229 val t1=mv_mul(mul1,mul2,LEX_);
230 val t2=mv_mul(mul3,mul2,LEX_);
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 error ("Test failed");*)
234 print("\n\n***** all tests successfull ;-) ******\n\n");
238 val thy = Rational.thy;
239 val rls = Prls {func=cancel};
240 val t = (term_of o the o (parse thy))
241 "(1 + 1 * a ^^^ 1)///(-2 + 2 * a ^^^ 2)";
242 val (t,asm) = the (rewrite_set_ thy eval_rls false rls t);
245 val thy' = "Rational";
247 val t' = "(1 + 1 * a ^^^ 1)///(-2 + 2 * a ^^^ 2)";
248 val (t',asm') = the (rewrite_set thy' "eval_rls" false rls' t');
249 (*if t' = "1 /// (-2 + 2 * a)" then ()
250 else error "tests/rationals.sml(1): new behaviour";*)
253 val thy' = "Rational";
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) ";
256 val (t',asm') = the (rewrite_set thy' "eval_rls" false rls' t');
258 val thy' = "Rational";
260 val t' = "(a^^^2 * b + 2 * a * b + b ) /// ( a^^^2 - 1 )";
261 val (t',asm') = the (rewrite_set thy' "eval_rls" false rls' t');
264 val term2 = (term_of o the o (parse thy)) "(a^^^2 * b + 2 * a * b + b ) /// ( a^^^2 - 1 )";
265 val div2 = direct_cancel term2;
266 val t = (term_of o the o (parse thy)) "(1 + 1 * a ^^^ 1)///(-2 + 2 * a ^^^ 2) = 0";*)
270 (*WN folgendes aus examples he"uberkopiert ...*)
277 val thy' = "Rational";
279 val mp = "make_polynomial";
283 print("\n\nexample 186:\n");
285 val e186a'="(14 * x * y) / ( x * y )";
286 val e186a = the (rewrite_set thy' "rational_erls" false rls' e186a');
288 val e186b'="(60 * a * b) / ( 15 * a * b )";
289 val e186b = the (rewrite_set thy' "rational_erls" false rls' e186b');
291 val e186c'="(144 * a^^^2 * b * c) / (12 * a * b * c )";
292 val e186c = (the (rewrite_set thy' "rational_erls" false rls' e186c'))
293 handle e => print_exn e;
294 val t = (term_of o the o (parse thy)) e186c';
297 print("\n\nexample 187:\n");
299 val e187a'="(12 * x * y) / (8 * y^^^2 )";
300 val e187a = the (rewrite_set thy' "rational_erls" false rls' e187a');
302 val e187b'="(8 * x^^^2 * y * z ) / (18 * x * y^^^2 * z )";
303 val e187b = the (rewrite_set thy' "rational_erls" false rls' e187b');
305 val e187c'="(9 * x^^^5 * y^^^2 * z^^^4) / (15 * x^^^6 * y^^^3 * z )";
306 val e187c = the (rewrite_set thy' "rational_erls" false rls' e187c');
308 print("\n\nexample 188:\n");
310 val e188a'="(8 * x + -8) / (9 * x + -9 )";
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))";
313 if t="((-8) + 8 * x) / ((-9) + 9 * x)"then()
314 else error "rationals.sml: e188a new behaviour";
316 val e188b'="(5 * x + -15) / (6 * x + -18 )";
317 val e188b = the (rewrite_set thy' "rational_erls" false rls' e188b');
319 val e188c'="( a + -1 * b ) / ( b + -1 * a )";
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))";
322 if t="(a + -1 * b) / (b + -1 * a)"then()
323 else error "rationals.sml: e188c new behaviour";
325 print("\n\nexample 190:\n");
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');
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()
331 (*TERMORDER ~~~~~~~ ~~~~~~~*)
332 else error "rationals.sml: e190c new behaviour";
334 print("\n\nexample 191:\n");
336 val e191a'="( x^^^2 + -1 * y^^^2 ) / ( x + y )";
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))";
339 if t="(x ^^^ 2 + -1 * y ^^^ 2) / (x + y)"then()
340 else error "rationals.sml: e191a new behaviour";
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');
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()
346 else error "rationals.sml: 'e191c' new behaviour";
348 print("\n\nexample 192:\n");
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');
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()
355 else error "rationals.sml: 'e192b' new behaviour";
357 print("\n\nexample 193:\n");
359 val e193a'="( x^^^2 + -6 * x + 9 ) / ( x^^^2 + -9 )";
360 val e193a = the (rewrite_set thy' "rational_erls" false rls' e193a');
362 val e193b'="( x^^^2 + -8 * x + 16 ) / ( 2 * x^^^2 + -32 )";
363 val e193b = the (rewrite_set thy' "rational_erls" false rls' e193b');
365 val e193c'="( 2 * x + -50 * x^^^3 ) / ( 25 * x^^^2 + -10 * x + 1 )";
366 val SOME(t,_) = rewrite_set thy' "rational_erls" false rls' e193c';
367 --------------------------------15.10.02---*)
370 (*---------- WN: 10.9.02:
371 ML> val e204a = the (rewrite_set thy' "rational_erls" false rls' e204a');
372 *** RATIONALS_STEP_CANCEL_EXCEPTION: Invalid fraction
373 print("\n\nexample 204:\n");
375 val e204a'="((5 * x) / 9) + ((3 * x) / 9) + (x / 9)";
376 val e204a = the (rewrite_set thy' "rational_erls" false rls' e204a');
378 val e204b'="5 / x + -3 / x + -1 / x";
379 val e204b = the (rewrite_set thy' "rational_erls" false rls' e204b');
381 print("\n\nexample 205:\n");
383 val e205a'="((4 * x + 7) / 8) + ((4 * x + 3) / 8)";
384 val e205a = the (rewrite_set thy' "rational_erls" false rls' e205a');
386 val e205b'="((5 * x + 2) / 3) + ((-2 * x + 1) / 3)";
387 val e205b = the (rewrite_set thy' "rational_erls" false rls' e205b');
389 print("\n\nexample 206:\n");
391 val e206a'="((5 * x + 4) / (2 * x + -1)) + ((9 * x + 5) / (2 * x + -1))";
392 val e206a = the (rewrite_set thy' "rational_erls" false rls' e206a');
394 val e206b'="((17 * x + -23) / (5 * x + 4)) + ((-25 + -17 * x) / (5 * x + 4))";
395 val e206b = the (rewrite_set thy' "rational_erls" false rls' e206b');
397 print("\n\nexample 207:\n");
398 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)) ";
399 val e207 = the (rewrite_set thy' "rational_erls" false rls' e207');
401 print("\n\nexample 208:\n");
402 val e208'="((3 * x + 2) / (x + 2)) + ((5 * x + -1) / (x + 2)) + ((-7 * x + -3) / (x + 2)) + ((-1 * x + -3) / (x + 2)) ";
403 val e208 = the (rewrite_set thy' "rational_erls" false rls' e208');
405 print("\n\nexample 209:\n");
406 val e209'="((3 * x + -7 * y + 3 * z) / (4)) + ((2 * x + 17 * y + 10 * z) / (4)) + ((-1 * x + 2 * y + z) / (4)) ";
407 val e209 = the (rewrite_set thy' "rational_erls" false rls' e209');
409 print("\n\nexample 210:\n");
410 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)) ";
411 val e210 = the (rewrite_set thy' "rational_erls" false rls' e210');
413 print("\n\nexample 211:\n");
415 val e211a'="((b) / (a + -1 * b)) + ((-1 * a) / (a + -1 * b))";
416 val e211a = the (rewrite_set thy' "rational_erls" false rls' e211a');
418 val e211b'="((b) / (b^^^2 + -1 * a^^^2)) + ((-1 * a) / (b^^^2 + -1 * a^^^2))";
419 val e211b = the (rewrite_set thy' "rational_erls" false rls' e211b');
421 print("\n\nexample 212:\n");
423 val e212a'="((4) / (x)) + ((-3) / (y)) + -1";
424 val e212a = the (rewrite_set thy' "rational_erls" false rls' e212a');
426 val e212b'="((4) / (x)) + ((-5) / (y)) + ((6) / (x*y))";
427 val e212b = the (rewrite_set thy' "rational_erls" false rls' e212b');
429 print("\n\nexample 213:\n");
431 val e213a'="((5 * x) / (3 * y^^^2)) + ((19 * z) / (6 * x * y)) + ((-2 * x) / (3 * y^^^2)) + ((7 * y^^^2) / (6 * x^^^2)) ";
432 val e213a = the (rewrite_set thy' "rational_erls" false rls' e213a');
434 val e213b'="((2 * b) / (3 * a^^^2)) + ((3 * c) / (7 * a * b)) + ((4 * b) / (3 * a^^^2)) + ((3 * a) / (7 * b^^^2))";
435 val e213b = the (rewrite_set thy' "rational_erls" false rls' e213b');
437 print("\n\nexample 214:\n");
439 val e214a'="((3 * x + 2 * y + 2 * z) / (4)) + ((-5 * x + -3 * y) / (3)) + ((x + y + -2 * z) / (2))";
440 val e214a = the (rewrite_set thy' "rational_erls" false rls' e214a');
442 val e214b'="((5 * x + 2 * y + z) / (2)) + ((-7 * x + -3 * y) / (3)) + ((3 * x + 6 * y + -1 * z) / (12))";
443 val e214b = the (rewrite_set thy' "rational_erls" false rls' e214b');
445 print("\n\nexample 216:\n");
447 val e216a'="((2 * b + 3 * c) / (a * c)) + ((3 * a + b) / (a * b)) + ((-2 * b^^^2 + -3 * a * c) / (a * b * c))";
448 val e216a = the (rewrite_set thy' "rational_erls" false rls' e216a');
450 val e216b'="((2 * a + 3 * b) / (b * c)) + ((3 * c + a) / (a * c)) + ((-2 * a^^^2 + -3 * b * c) / (a * b * c))";
451 val e216b = the (rewrite_set thy' "rational_erls" false rls' e216b');
453 print("\n\nexample 217:\n");
454 val e217'="((z + -1) / (z)) + ((3 * z ^^^2 + -6 * z + 5) / (z^^^2)) + ((-4 * z^^^3 + 7 * z^^^2 + -5 * z + 5) / (z^^^3))";
455 val e217 = the (rewrite_set thy' "rational_erls" false rls' e217');
457 print("\n\nexample 218:\n");
458 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))";
459 val e218 = the (rewrite_set thy' "rational_erls" false rls' e218');
461 print("\n\nexample 219:\n");
463 val e219a'="((1) / (y + 1)) + ((1) / (y + 2)) + ((1) / (y + 3))";
464 val e219a = the (rewrite_set thy' "rational_erls" false rls' e219a');
466 val e219b'="((1) / (x + 1)) + ((1) / (x + 2)) + ((-2) / (x + 3))";
467 val e219b = the (rewrite_set thy' "rational_erls" false rls' e219b');
469 print("\n\nexample 220:\n");
471 val e220a'="((17) / (5 * r + -2)) + ((-13) / (2 * r + 3)) + ((4) / (3 * r + -5))";
472 val e220a = the (rewrite_set thy' "rational_erls" false rls' e220a');
474 val e220b'="((20 * a) / (a + -3)) + ((-19 * a) / (a + -4)) + ((a) / (a + -5))";
475 val e220b = the (rewrite_set thy' "rational_erls" false rls' e220b');
477 print("\n\nexample 221:\n");
479 val e221a'="((a + b) / (a + -1 * b)) + ((a + -1 * b) / (a + b))";
480 val e221a = the (rewrite_set thy' "rational_erls" false rls' e221a');
482 val e221b'="((x + -1 * y) / (x + y)) + ((x + y) / (x + -1 * y)) ";
483 val e221b = the (rewrite_set thy' "rational_erls" false rls' e221b');
485 print("\n\nexample 222:\n");
487 val e222a'="((1 + -1 * x) / (1 + x)) + ((-1 + -1 * x) / (1 + -1 * x)) + ((4 * x) / (1 + -1 * x^^^2))";
488 val e222a = the (rewrite_set thy' "rational_erls" false rls' e222a');
490 val e222b'="((1 + x ) / (1 + -1 * x)) + ((-1 + x) / (1 + x)) + ((2 * x) / (1 + -1 * x^^^2))";
491 val e222b = the (rewrite_set thy' "rational_erls" false rls' e222b');
493 print("\n\nexample 225:\n");
495 val e225a'="((6 * a) / (a^^^2 + -64)) + ((a + 2) / (2 * a + 16)) + ((-1) / (2))";
496 val e225a = the (rewrite_set thy' "rational_erls" false rls' e225a');
498 val e225b'="((a + 2 ) / (2 * a + 12)) + ((4 * a) / (a^^^2 + -36)) + ((-1) / (2))";
499 val e225b = the (rewrite_set thy' "rational_erls" false rls' e225b');
501 print("\n\nexample 226:\n");
503 val e226a'="((35 * z) / (49 * z^^^2 + -4)) + -1 + ((14 * z + -1) / (14 * z + 4)) ";
504 val e226a = the (rewrite_set thy' "rational_erls" false rls' e226a');
506 val e226b'="((45 * a * b) / (25 * a^^^2 + -9 * b^^^2)) + ((20 * a + 3 * b) / (10 * a + 6 * b)) + -2";
507 val e226b = the (rewrite_set thy' "rational_erls" false rls' e226b');
509 print("\n\nexample 227:\n");
511 val e227a'="((6 * z + 11) / (6 * z + 14)) + ((9 * z ) / (9 * z^^^2 + -49)) + -1 ";
512 val e227a = the (rewrite_set thy' "rational_erls" false rls' e227a');
514 val e227b'="((16 * a + 37 * b) / (4 * a + 10 * b)) + ((6 * a * b) / (4 * a^^^2 + -25 * b^^^2)) + -4 ";
515 val e227b = the (rewrite_set thy' "rational_erls" false rls' e227b');
517 print("\n\nexample 228:\n");
519 val e228a'="((7 * a + 11) / (3 * a^^^2 + -3)) + ((-2 * a + -1) / (a^^^2 + -1 * a)) + ((-1) / (3 * a + 3))";
520 val e228a = the (rewrite_set thy' "rational_erls" false rls' e228a');
522 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))";
523 val e228b = the (rewrite_set thy' "rational_erls" false rls' e228b');
526 print("\n\nexample 229:\n");
528 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))";
529 val e229a = the (rewrite_set thy' "rational_erls" false rls' e229a');
531 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))";
532 val e229b = the (rewrite_set thy' "rational_erls" false rls' e229b');
534 print("\n\nexample 230:\n");
536 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))";
537 val e230a = the (rewrite_set thy' "rational_erls" false rls' e230a');
539 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))";
540 val e230b = the (rewrite_set thy' "rational_erls" false rls' e230b');
542 print("\n\nexample 231:\n");
544 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))";
545 val e231a = the (rewrite_set thy' "rational_erls" false rls' e231a');
547 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))";
548 val e231b = the (rewrite_set thy' "rational_erls" false rls' e231b');
550 print("\n\nexample 232:\n");
552 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))";
553 val e232a = the (rewrite_set thy' "rational_erls" false rls' e232a');
555 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))";
556 val e232b = the (rewrite_set thy' "rational_erls" false rls' e232b');
558 print("\n\nexample 233:\n");
560 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))";
561 val e233a = the (rewrite_set thy' "rational_erls" false rls' e233a');
563 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))";
564 val e233b = the (rewrite_set thy' "rational_erls" false rls' e233b');
566 print("\n\nexample 234:\n");
568 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))";
569 val e234a = the (rewrite_set thy' "rational_erls" false rls' e234a');
571 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)) ";
572 val e234b = the (rewrite_set thy' "rational_erls" false rls' e234b');
574 print("\n\nexample 235:\n");
576 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))";
577 val e235a = the (rewrite_set thy' "rational_erls" false rls' e235a');
579 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)) ";
580 val e235b = the (rewrite_set thy' "rational_erls" false rls' e235b');
582 print("\n\nexample 236:\n");
584 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))";
585 val e236a = the (rewrite_set thy' "rational_erls" false rls' e236a');
587 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)) ";
588 val e236b = the (rewrite_set thy' "rational_erls" false rls' e236b');
590 print("\n\nexample heuberger:\n");
591 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)";
592 val eheu = the (rewrite_set thy' "rational_erls" false rls' eheu');
594 print("\n\nexample stiefel:\n");
595 val est1'="(7) / (-14) + (-2) / (4)";
596 val est1 = the (rewrite_set thy' "rational_erls" false rls' est1');
597 if est1 = ("(-1) / 1",[]) then ()
598 else error "new behaviour in rationals.sml: est1'";
599 -------------------------------------------------------------------------*)
603 val t = (term_of o the o (parse thy))
604 "(9 - x ^^^ 2) / (9 - 6 * x + x ^^^ 2)";
605 val SOME (t',_) = factor_expanded_ thy t;
608 "((-3) - x) * ((-3) + x) / (((-3) + x) * ((-3) + x))"
609 "(3 + x) * (3 - x) / ((3 - x) * (3 - x))"
614 (*WN.28.8.02: tests for the 'reverse-rewrite' functions:
615 these are defined in Rationals.ML and stored in
616 the 'reverse-ruleset' cancel*)
618 (*the term for which reverse rewriting is demonstrated*)
619 val t = (term_of o the o (parse thy))
620 "(9 - x ^^^ 2) / (9 + 6 * x + x ^^^ 2)";
621 val Rrls {scr=Rfuns {init_state=ini,locate_rule=loc,
622 next_rule=nex,normal_form=nor,...},...} = cancel;
624 (*normal_form produces the result in ONE step*)
625 val SOME (t',_) = nor t;
628 (*initialize the interpreter state used by the 'me'*)
629 val (t,_,revsets,_) = ini t;
631 (*find the rule 'r' to apply to term 't'*)
632 val SOME r = nex revsets t;
633 (*val r = Thm ("sym_#mult_2_3","6 = 2 * 3") : rule*)
635 (*check, if the rule 'r' applied by the user to 't' belongs to the ruleset;
636 if the rule is OK, the term resulting from applying the rule is returned,too;
637 there might be several rule applications inbetween,
638 which are listed after the thead in reverse order*)
639 val (r,(t,asm))::_ = loc revsets t r;
641 "(9 - x ^^^ 2) / (3 ^^^ 2 + 6 * x + x ^^^ 2)";
643 (*find the next rule to apply*)
644 val SOME r = nex revsets t;
645 (*val r = Thm ("sym_#power_3_2","9 = 3 ^^^ 2") : rule*)
647 (*check the next rule*)
648 val (r,(t,asm))::_ = loc revsets t r;
650 "(3 ^^^ 2 - x ^^^ 2) / (3 ^^^ 2 + 6 * x + x ^^^ 2)";
652 (*find and check the next rules, rewrite*)
653 val SOME r = nex revsets t;
654 val (r,(t,asm))::_ = loc revsets t r;
656 "(3 ^^^ 2 - x ^^^ 2) / (3 ^^^ 2 + 2 * 3 * x + x ^^^ 2)";
658 val SOME r = nex revsets t;
659 val (r,(t,asm))::_ = loc revsets t r;
661 "(3 - x) * (3 + x) / (3 ^^^ 2 + 2 * 3 * x + x ^^^ 2)";
663 val SOME r = nex revsets t;
664 val (r,(t,asm))::_ = loc revsets t r;
666 "(3 - x) * (3 + x) / ((3 + x) * (3 + x))";
668 val SOME r = nex revsets t;
669 val (r,(t,asm))::_ = loc revsets t r;
671 if ss = "(3 - x) / (3 + x)" then ()
672 else error "rational.sml: new behav. in rev-set cancel";
677 (*WN.11.9.02: the 'reverse-ruleset' cancel*)
679 (*the term for which reverse rewriting is demonstrated*)
680 val t = (term_of o the o (parse thy))
681 "(9 + (-1)*x^^^2) / (9 + ((-6)*x + x^^^2))";
682 val Rrls {scr=Rfuns {init_state=ini,locate_rule=loc,
683 next_rule=nex,normal_form=nor,...},...} = cancel;
684 (*normal_form produces the result in ONE step*)
685 val SOME (t',_) = nor t;
687 (*initialize the interpreter state used by the 'me'*)
688 val (t,_,revsets,_) = ini t;
691 filter_out (eq_Thms ["sym_real_add_zero_left",
693 "sym_real_mult_1"]) rs;
695 10.10.02: dieser Fall terminiert nicht (make_poly enth"alt zu viele rules)
696 val SOME r = nex revsets t;
697 val (r,(t,asm))::_ = loc revsets t r;
700 val SOME r = nex revsets t;
701 val (r,(t,asm))::_ = loc revsets t r;
704 ------ revset ----------------------------------------------------
705 /// [Thm ("sym_real_add_zero_left","?z = 0 + ?z"),
706 /// Thm ("sym_real_mult_0","0 = 0 * ?z"),
707 ! Thm ("sym_#mult_2_(-3)","(-6) * x = 2 * ((-3) * x)"),
708 ! Thm ("sym_#add_(-3)_3","0 = (-3) + 3"),
710 ? Thm ("sym_real_num_collect_assoc",
711 "[| ?l is_const; ?m is_const |]
712 ==> (?l + ?m) * ?n + ?k = ?l * ?n + (?m * ?n + ?k)"),
713 OK Thm ("sym_real_mult_2_assoc","2 * ?z1.0 + ?k = ?z1.0 + (?z1.0 + ?k)"),
714 OK Thm ("sym_real_add_left_commute","?y + (?x + ?z) = ?x + (?y + ?z)"),
715 /// Thm ("sym_real_mult_1","?z = 1 * ?z"),
716 ! Thm ("sym_#power_3_2","9 = 3 ^^^ 2"),
717 ! Thm ("sym_#mult_-1_-1","1 * x ^^^ 2 = -1 * (-1 * x ^^^ 2)"),
718 ! Thm ("sym_#mult_-1_3","(-3) * x = -1 * (3 * x)"),
719 OK Thm ("realpow_twoI","?r1 ^^^ 2 = ?r1 * ?r1" [.]),
720 OK Thm ("sym_real_add_assoc",
721 "?z1.0 + (?z2.0 + ?z3.0) = ?z1.0 + ?z2.0 + ?z3.0"),
723 ("sym_real_mult_assoc","?z1.0 * (?z2.0 * ?z3.0) = ?z1.0 * ?z2.0 * ?z3.0"),
724 OK Thm ("sym_real_mult_left_commute",
725 "?z2.0 * (?z1.0 * ?z3.0) = ?z1.0 * (?z2.0 * ?z3.0)"),
726 OK Thm ("sym_real_mult_commute","?w * ?z = ?z * ?w"),
727 ? Thm ("sym_real_add_mult_distrib2",
728 "?w * ?z1.0 + ?w * ?z2.0 = ?w * (?z1.0 + ?z2.0)"),
729 ? Thm ("sym_real_add_mult_distrib",
730 "?z1.0 * ?w + ?z2.0 * ?w = (?z1.0 + ?z2.0) * ?w"),
731 OK Thm ("real_mult_div_cancel2","?k ~= 0 ==> ?m * ?k / (?n * ?k) = ?m / ?n")]
732 -------- revset ----------------------------------------------------
734 val t = (term_of o the o (parse thy)) "(-6) * x";
735 val t = (term_of o the o (parse thy))
736 "(9 + (-1)*x^^^2) / (9 + ((-6)*x + x^^^2))";
737 val thm = (mk_thm thy "(-6) * x = 2 * ((-3) * x)")
738 handle e => print_exn e;
739 val SOME (t',_) = rewrite_ thy e_rew_ord e_rls false thm t;
741 ----------------------------------------------------------------------*)
745 (* SK: Testbeispiele --- WN kopiert Rational.ML -> rational.sml-----
747 val t1 = (term_of o the o (parse thy)) "((3 * x^^^2 + 6 *x + 3) / (2*x + 2))";
748 val SOME (t1',rest)= cancel_ thy t1;
749 val SOME (t1'',_)= factor_out_gcd_ thy t1;
750 print(term2str t1'^" + Einschr\"ankung: "^term2str (hd(rest)));
753 val t1 = (term_of o the o (parse thy)) "((-3 * x^^^2 + 6 *x - 3) / (2*x - 2))";
754 val SOME (t1',_)= cancel_ thy t1;
755 val SOME (t1'',_)= factor_expanded_ thy t1;
759 val t2 = (term_of o the o (parse thy)) "((x+ (-1)) / (x + 1)) + ((x + 1) / (x + (-1)))";
760 val SOME (t2',_) = add_fractions_ thy t2;
761 val SOME (t2'',_) = common_nominators_ thy t2;
765 val t2 = (term_of o the o (parse thy)) "((x - 1) / (x + 1)) + ((x + 1) / (x - 1))";
766 val SOME (t2',_) = add_expanded_frac_ thy t2;
767 val SOME (t2'',_) = common_expanded_nom_ thy t2;
772 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))";
773 val SOME (t3',_) = common_nominators_ thy t3;
774 val SOME (t3'',_) = add_fractions_ thy t3;
778 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))";
779 val SOME (t3',_) = common_expanded_nom_ thy t3;
780 val SOME (t3'',_) = add_expanded_frac_ thy t3;
783 -------------------------------*)
786 val SOME(t4,t5) = norm_rational_ thy t3;
790 (*val test1 = (term_of o the o (parse thy)) "1 - x^^^2 - 5 * x^^^5";
791 val test2 = (term_of o the o (parse thy)) "1 + (-1) * x ^^^ 2 + (-5) * x ^^^ 5";
792 val test2 = (term_of o the o (parse thy)) "1 - x";
793 val test2 = (term_of o the o (parse thy)) "1 + (-1) * x";
794 term2str(expanded2term(test1));
795 term2str(term2expanded(test2)); *)
799 (* WN kopiert 16.10.02 Rational.ML -> rational.sml-----vvv---*)
801 val t=(term_of o the o (parse thy)) "(9 - x^^^2)/(9 - 6*x + x^^^2)";
802 val SOME (t',_) = factout_ thy t;
803 val SOME (t'',_) = cancel_ thy t;
806 "(3 + x) * (3 - x) / ((3 - x) * (3 - x))";
809 val t=(term_of o the o(parse thy))
810 "(9 - x^^^2) / (9 - 6*x + x^^^2) + 1 / (3 - x)";
811 val SOME (t',_) = common_nominator_ thy t;
812 val SOME (t'',_) = add_fraction_ thy t;
815 "(9 - x ^^^ 2) / ((3 - x) * (3 - x)) + 1 * (3 - x) / ((3 - x) * (3 - x))";
818 (*WN.16.10.02 hinzugef"ugt -----vv---*)
819 val t=(term_of o the o(parse thy))
820 "(9 - x^^^2) / (9 - 6*x + x^^^2) + 1";
821 val SOME (t',_) = common_nominator_ thy t;
822 val SOME (t'',_) = add_fraction_ thy t;
825 "(9 - x ^^^ 2) / (9 - 6 * x + x ^^^ 2) +\
826 \1 * (9 - 6 * x + x ^^^ 2) / (9 - 6 * x + x ^^^ 2)";
829 val t=(term_of o the o(parse thy))
830 "1 + (9 - x^^^2) / (9 - 6*x + x^^^2)";
831 val SOME (t',_) = common_nominator_ thy t;
832 val SOME (t'',_) = add_fraction_ thy t;
835 "1 * (9 - 6 * x + x ^^^ 2) / (9 - 6 * x + x ^^^ 2) +\
836 \(9 - x ^^^ 2) / (9 - 6 * x + x ^^^ 2)";
838 (*WN.16.10.02 hinzugef"ugt -----^^---*)
840 val t=(term_of o the o (parse thy))
841 "(y^^^2 - x^^^2)/(y^^^2 - 2*y*x + x^^^2)";
842 val SOME (t',_) = factout_ thy t;
843 val SOME (t'',_) = cancel_ thy t;
846 "(y + x) * (y - x) / ((y - x) * (y - x))";
849 val t=(term_of o the o (parse thy))
850 "(y^^^2 - x^^^2)/(y^^^2 - 2*y*x + x^^^2) + 1 / (y - x)";
851 val SOME (t',_) = common_nominator_ thy t;
852 val SOME (t'',_) = add_fraction_ thy t;
855 "((-1) * x ^^^ 2 + y ^^^ 2) / (((-1) * x + y) * ((-1) * x + y)) +\
856 \1 * ((-1) * x + y) / (((-1) * x + y) * ((-1) * x + y))";
857 "((-1) - x - y) / (x - y)";
858 (*WN.16.10.02 ^^^^^^^ Reihenfolge aus Angabe umgekehrt ?!*)
860 val t=(term_of o the o (parse thy))
861 "(x^^^2 - y^^^2)/(x^^^2 - 2*x*y + y^^^2) + 1 / (x - y)";
862 val SOME (t',_) = common_nominator_ thy t;
863 val SOME (t'',_) = add_fraction_ thy t;
866 "((-1) * y ^^^ 2 + x ^^^ 2) / (((-1) * y + x) * ((-1) * y + x)) +\
867 \1 * ((-1) * y + x) / (((-1) * y + x) * ((-1) * y + x))";
868 "((-1) - y - x) / (y - x)";
869 (*WN.16.10.02 ^^^^^^^ lexicographische Ordnung ?!*)
871 val t=(term_of o the o (parse thy))
872 "(y^^^2 - x^^^2)/(y^^^2 - 2*y*x + x^^^2)";
873 val SOME (t',_) = norm_expanded_rat_ thy t;
876 (*val SOME (t'',_) = norm_rational_ thy t;
878 *** RATIONALS_TERM2POLY_EXCEPTION: Invalid Polynomial
881 val t=(term_of o the o (parse thy))
882 "(9 - x^^^2)/(9 - 6*x + x^^^2) + (1)/(3 + x)";
883 val SOME (t',_) = norm_expanded_rat_ thy t;
885 "(12 + 5 * x + x ^^^ 2) / (9 - x ^^^ 2)";
886 (*val SOME (t'',_) = norm_rational_ thy t;
888 *** RATIONALS_TERM2POLY_EXCEPTION: Invalid Polynomial
891 val t=(term_of o the o (parse thy))
892 "(9 + (-1)* x^^^2)/(9 + (-1)* 6*x + x^^^2) + (1)/(3 + x)";
893 val SOME (t',_) = norm_expanded_rat_ thy t;
894 val SOME (t'',_) = norm_rational_ thy t;
897 "(12 + 5 * x + x ^^^ 2) / (9 - x ^^^ 2)";
898 "(12 + 5 * x + x ^^^ 2) / (9 + (-1) * x ^^^ 2)";
899 (* WN kopiert 16.10.02 Rational.ML -> rational.sml-----^^^---*)