1 (* Title: tests for rationals
3 Copyright (c) Stefan Karnel 2002
4 Use is subject to license terms.
6 12345678901234567890123456789012345678901234567890123456789012345678901234567890
7 10 20 30 40 50 60 70 80
9 WN120317.TODO postponed test/../ratinal,ratinal2.sml to joint work with dmeind
11 nonterm.SK marks non-terminating examples
12 ord.SK PARTIALLY marks crucial ordering examples
13 *SK* of some (secondary) interest (on 070906)
14 WN060104 transfer examples marked with (*SR..*) to the exp-collection
17 "--------------------------------------------------------";
18 "--------------------------------------------------------";
19 "table of contents --------------------------------------";
20 "--------------------------------------------------------";
21 "~~~~~BEGIN: decomment structure RationalI : RATIONALI ~~";
22 "-------- ... missing WN060103 --------------------------";
23 "-------- fun monom2term, fun poly2term' ---------------";
24 "~~~~~END: decomment structure RationalI : RATIONALI ~~~~";
25 "-------- external calculating functions test -----------";
26 "-------- cancel from: Mathematik 1 Schalk Reniets Verlag";
27 "-------- common_nominator_p ----------------------------";
28 "-------- reverse rewrite -------------------------------";
29 "-------- 'reverse-ruleset' cancel_p --------------------";
30 "-------- norm_Rational ---------------------------------";
31 "-------- numeral rationals -----------------------------";
32 "-------- cancellation ----------------------------------";
33 "-------- common denominator ----------------------------";
34 "-------- multiply and cancel ---------------------------";
35 "-------- common denominator and multiplication ---------";
36 "-------- double fractions ------------------------------";
37 "-------- crucial examples ------------------------------";
38 "-------- examples for Stefan Karnels thesis ------------";
39 "-------- me Schalk I No.186 ----------------------------";
40 "-------- interSteps ..Simp_Rat_Double_No-1.xml ---------";
41 "-------- interSteps ..Simp_Rat_Cancel_No-1.xml ---------";
42 "-------- investigate rulesets for cancel_p -------------";
43 "-------- investigate format of factout_ and factout_p_ -";
44 "-------- how to stepwise construct Scripts -------------";
45 "----------- get_denominator ----------------------------";
46 "--------------------------------------------------------";
47 "--------------------------------------------------------";
48 "--------------------------------------------------------";
51 "~~~~~BEGIN: decomment structure RationalI : RATIONALI ~~";
52 (*.~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
53 tests of internal functions: to make them work,
54 out-comment (*!!!*) in knowledge/Rational.ML:
56 structure RationalI : RATIONALI =
63 !!!##*)~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~.*)
65 "-------- ... missing WN060103 --------------------------";
66 "-------- ... missing WN060103 --------------------------";
67 "-------- ... missing WN060103 --------------------------";
68 (*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
69 writeln ("********************* rational.sml - TESTS *************************");
70 writeln ("***** divide tests *****");
71 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_)));
72 (* result: [(1,[0,0,1]),(1,[0,0,0])] *)
73 if mv_pquot1=[(1,[0,0,1]),(1,[0,0,0])] then () else error ("rational.sml: example failed");
75 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_)));
76 (* result: [(1,[1,0,1]),(~1,[0,0,1])] *)
77 if mv_prest1=[(1,[1,0,1]),(~1,[0,0,1])] then () else error ("rational.sml: example failed");
79 val mv_pquot2 = (#1(mv_division([(4,[2]),(8,[1]),(16,[0])],[(1,[1]),(1,[0])],LEX_)));
80 (* result: [(4,[1]),(4,[0])] *)
81 if mv_pquot2=[(4,[1]),(4,[0])] then () else error ("rational.sml: example failed");
83 val mv_prest2 = (#2(mv_division([(4,[2]),(8,[1]),(16,[0])],[(1,[1]),(1,[0])],LEX_)));
84 (* result: [(12,[0]] *)
85 if mv_prest2=[(12,[0])] then () else error ("rational.sml: example failed");
87 val mv_pquot3 = (#1(mv_division([(4,[2]),(~4,[0])],[(2,[1]),(2,[0])],LEX_)));
88 (* [(2,[1]),(~2,[0])] *)
89 if mv_pquot3=[(2,[1]),(~2,[0])] then () else error ("rational.sml: example failed");
91 val mv_prest3 = (#2(mv_division([(1,[2]),(~1,[0])],[(2,[1]),(2,[0])],LEX_)));
92 (* [(1,[2]),(~1,[0])] *)
93 if mv_prest3=[(1,[2]),(~1,[0])] then () else error ("rational.sml: example failed");
95 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_)));
97 if mv_pquot4=[(1,[0,1,1])] then () else error ("rational.sml: example failed");
99 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_)));
100 (* [(1,[1,1,1]),(~4,[0,1,2]),(4,[1,0,1]),(3,[0,0,1])] *)
101 if mv_prest4 =[(1,[1,1,1]),(~4,[0,1,2]),(4,[1,0,1]),(3,[0,0,1])] then () else error ("rational.sml: example failed");
103 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_)));
104 (* [(1,[2,2,0]),(6,[2,1,2]),(3,[1,1,0]),(4,[1,0,0]),(4,[0,4,0]),(3,[0,0,0])]*)
105 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 ("rational.sml: example failed");
107 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_)));
109 if mv_prest5=[] then () else error ("rational.sml: example failed");
111 (* (x^2 + 2(a+1)x + (a^2+2a+1)) / (x+a+1) = x+a+1 *)
112 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_)));
113 if mv_pquot6=[(1,[1,0,0]),(1,[0,1,0]),(1,[0,0,0])] then () else error ("rational.sml: example failed");
115 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_)));
116 if mv_prest6=[] then () else error ("rational.sml: example failed");
119 writeln ("***** MV_CONTENT-TESTS *****");
120 val mv_cont1=mv_content([(1,[2,1]),(1,[2,0]),(1,[1,1]),(1,[1,0]),(1,[0,1]),(1,[0,0])]);
121 (* [(1,[0,1]),(1,[0,0])] *)
122 if mv_cont1=[(1,[0,1]),(1,[0,0])] then () else error ("rational.sml: example failed");
124 val mv_pp1=mv_pp([(1,[1,1]),(1,[1,0]),(1,[0,1]),(1,[0,0])]);
125 (*[(1,[1,0]),(1,[0,0])]*)
126 if mv_pp1=[(1,[1,0]),(1,[0,0])] then () else error ("rational.sml: example failed");
128 val mv_cont2=mv_content([(2,[1]),(4,[0])]);
130 if mv_cont2=[(2,[0])] then () else error ("rational.sml: example failed");
132 val mv_pp2=mv_pp([(2,[1]),(4,[0])]);
133 (* [(1,[1]),(2,[0])] *)
134 if mv_pp2=[(1,[1]),(2,[0])] then () else error ("rational.sml: example failed");
136 val mv_cont3=mv_content[(8,[2,1,1]),(12,[1,0,2]),(10,[2,2,0]),(16,[1,1,1])];
138 if mv_cont3=[(2,[0,0,0])] then () else error ("rational.sml: example failed");
140 val mv_pp3=mv_pp[(8,[2,1,1]),(12,[1,0,2]),(10,[2,2,0]),(16,[1,1,1])];
141 (* [(5,[2,2,0]),(4,[2,1,1]),(8,[1,1,1]),(6,[1,0,2])] *)
142 if mv_pp3=[(5,[2,2,0]),(4,[2,1,1]),(8,[1,1,1]),(6,[1,0,2])] then () else error ("rational.sml: example failed");
144 val mv_cont4=mv_content[(2,[2,1,0]),(3,[1,0,1]),(2,[1,1,0]),(3,[0,0,1])];
146 if mv_cont4=[(1,[0,0,0])] then () else error ("rational.sml: example failed");
148 val mv_pp4=mv_pp [(2,[2,1,0]),(3,[1,0,1]),(2,[1,1,0]),(3,[0,0,1])];
149 (* [(2,[2,1,0]),(2,[1,1,0]),(3,[1,0,1]),(3,[0,0,1])] *)
150 if mv_pp4=[(2,[2,1,0]),(2,[1,1,0]),(3,[1,0,1]),(3,[0,0,1])] then () else error ("rational.sml: example failed");
152 val con1=mv_content([(9,[2,0]),(15,[1,1]),(12,[1,0]),(6,[0,2]),(12,[0,1])]);
154 if con1=[(3,[0,0])] then () else error ("rational.sml: example failed");
156 val pp1=mv_pp([(9,[2,0]),(15,[1,1]),(12,[1,0]),(6,[0,2]),(12,[0,1])]);
157 (* [(3,[2,0]),(5,[1,1]),(4,[1,0]),(2,[0,2]),(4,[0,1])] *)
158 if pp1=[(3,[2,0]),(5,[1,1]),(4,[1,0]),(2,[0,2]),(4,[0,1])] then () else error ("rational.sml: example failed");
160 val con2=mv_content([(1,[2,0]),(1,[1,1]),(1,[1,0]),(1,[0,2]),(1,[0,1])]);
162 if con2=[(1,[0,0])] then () else error ("rational.sml: example failed");
164 val pp2 =mv_pp([(1,[2,0]),(1,[1,1]),(1,[1,0]),(1,[0,2]),(1,[0,1])]);
165 (* [(1,[2,0]),(1,[1,1]),(1,[1,0]),(1,[0,2]),(1,[0,1])] *)
166 if pp2=[(1,[2,0]),(1,[1,1]),(1,[1,0]),(1,[0,2]),(1,[0,1])] then () else error ("rational.sml: example failed");
168 val cont1 = mv_content [(1,[2,1,0]),(2,[2,1,0])];
170 if cont1=[(3,[0,1,0])] then () else error ("rational.sml: example failed");
172 val pp1 = mv_pp [(1,[2,1,0]),(2,[2,1,0])];
174 if pp1=[(1,[2,0,0])] then () else error ("rational.sml: example failed");
176 val cont2 = mv_content [(4,[1,2,0]),(2,[2,1,0])];
178 if cont2=[(2,[0,1,0])] then () else error ("rational.sml: example failed");
180 val pp2 = mv_pp [(4,[1,2,0]),(2,[2,1,0])];
181 (* [(1,[2,0,0]),(2,[1,1,0])] *)
182 if pp2=[(1,[2,0,0]),(2,[1,1,0])] then () else error ("rational.sml: example failed");
184 writeln ("********************************************************");
185 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])];
186 if cont3=[(5,[0,2,1]),(4,[0,2,0]),(2,[0,1,1])] then () else error ("rational.sml: example failed");
187 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])];
190 "-------- fun monom2term, fun poly2term' ---------------";
191 "-------- fun monom2term, fun poly2term' ---------------";
192 "-------- fun monom2term, fun poly2term' ---------------";
193 val t = monom2term ((3,[2,1,0]), ["c","b","a"](*reverse ???SK-*));
194 term2str t = "3 * (c ^^^ 2 * b)" (*true*);
196 val t = monom2term ((1,[1,0]), ["b","a"]);
197 term2str t = "b" (*true*);
199 val t = poly2term ([(1,[0,0,0]),(2,[1,0,0]),(3,[2,1,0]),(4,[3,2,1])],
201 term2str t = "1 + 2 * c + 3 * (c ^^^ 2 * b) + 4 * (c ^^^ 3 * (b ^^^ 2 * a))";
203 val t = poly2term ([(1,[1,0]),(1,[0,1])], ["b","a"]);
204 term2str t = "a + b" (*true*);
206 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*)
207 "~~~~~END: decomment structure RationalI : RATIONALI ~~~~";
208 "~~~~~END: decomment structure RationalI : RATIONALI ~~~~";
209 "~~~~~END: decomment structure RationalI : RATIONALI ~~~~";
212 fun parse_rat str = (term_of o the o (parse thy)) str;
214 writeln ("***** mv_gcd-tests *****");
215 val ggt1 = mv_gcd [(4,[2,2]),(8,[1,1]),(4,[0,0])] [(2,[1,1]),(2,[0,0])];
216 (* [(2,[1,1]),(2,[0,0])] *)
217 if ggt1=[(2,[1,1]),(2,[0,0])] then () else error ("rational.sml: example failed");
219 val ggt2 = mv_gcd [(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])];
220 (* [(2,[1,1,0]),(3,[0,0,1])] *)
221 if ggt2=[(2,[1,1,0]),(3,[0,0,1])] then () else error ("rational.sml: example failed");
224 val ggt3 = mv_gcd [(1,[2,0]),(~2,[1,1]),(1,[0,2])] [(1,[1,0]),(~1,[0,1])];
225 (* [(1,[1,0]),(~1,[0,1])] *)
226 if ggt3=[(1,[1,0]),(~1,[0,1])] then () else error ("rational.sml: example failed");
229 val ggt4 = mv_gcd [(1,[2,1,0]),(2,[2,1,0])] [(5,[1,0,0])];
231 if ggt4=[(1,[1,0,0])] then () else error ("rational.sml: example failed");
234 val ggt5 = mv_gcd [(4,[2,0]),(~8,[1,1]),(4,[0,2])] [(1,[2,0]),(~1,[0,2])];
235 (* [(1,[1,0]),(~1,[0,1])] *)
236 if ggt5=[(1,[1,0]),(~1,[0,1])] then () else error ("rational.sml: example failed");
239 val ggt6 = mv_gcd [(10,[2,1,1]),(14,[1,1,0]),(3,[1,0,1]),(20,[1,2,1])] [(5,[1,1,1]),(7,[2,1,1])];
241 if ggt6=[(1,[1,0,0])] then () else error ("rational.sml: example failed");
243 writeln ("***** kgv-tests *****");
244 val kgv1=mv_lcm [(10,[])] [(15,[])];
246 if kgv1=[(30,[])] then () else error ("rational.sml: example failed");
248 val kgv2=mv_lcm [(1,[2,0]),(~2,[1,1]),(1,[0,2])] [(1,[1,0]),(~1,[0,1])];
249 (* [(1,[2,0]),(~2,[1,1]),(1,[0,2])] *)
250 if kgv2=[(1,[2,0]),(~2,[1,1]),(1,[0,2])] then () else error ("rational.sml: example failed");
252 val kgv3=mv_lcm [(4,[2,0]),(~8,[1,1]),(4,[0,2])] [(1,[2,0]),(~1,[0,2])];
253 (* [(4,[3,0]),(~4,[2,1]),(~4,[1,2]),(4,[0,3])] *)
254 if kgv3=[(4,[3,0]),(~4,[2,1]),(~4,[1,2]),(4,[0,3])] then () else error ("rational.sml: example failed");
257 writeln ("***** STEP_CANCEL_TESTS: *****");
259 val term2 = (term_of o the o (parse thy)) " (9 * a^^^2 * b) / (6 * a * c)";
260 val div2 = term2str (step_cancel term2);
261 if div2 = "3 * (a * b) * (3 * a) / (2 * c * (3 * a))" then () else error ("rational.sml: example failed");
264 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";
265 val div1 = term2str(step_cancel term1);
266 if div1 = "(3 * c + 14 * b + 20 * (b ^^^ 2 * c) + 10 * (a * (b * c))) * a / (1 * a)" then () else error ("rational.sml: example failed");
268 val term3 = (term_of o the o (parse thy)) "(10 * a^^^2 * b * c) / (1 * x * y * z) ";
269 val div3 = term2str(step_cancel term3);
270 if div3="10 * a ^^^ 2 * b * c / (1 * x * y * z)" then () else error ("rational.sml: example failed");
272 --------------------------------------------------------------------------!!!*)
274 (*-----versuche 13.3.03-----
275 val t = str2term "1 - x^^^2 - 5 * x^^^5";
276 val vs=(((map free2str) o vars) t);
277 val SOME ml = expanded2poly t vs;
279 poly2term'(rev(sort (mv_geq LEX_) (ml)),vs);
280 poly2term'([(~5,[5]),(~1,[2]),(1,[0])], vs);
281 monom2term((~5,[5]),vs);
282 monom2term((~1,[2]),vs);
283 val t' = monom2term((1,[0]),vs);(*uncaught exception LIST*)
285 val (i,is) = (~1,[2]);
286 val ttt = Const ("Groups.times_class.times", [HOLogic.realT,HOLogic.realT]---> HOLogic.realT) $
287 (Const ("uminus", HOLogic.realT --> HOLogic.realT) $
288 Free ((str_of_int o abs) i, HOLogic.realT)) $
289 powerproduct2term(is, vs);
291 -------versuche 13.3.03-----*)
293 val t = str2term "1 - x^^^2 - 5 * x^^^5";
294 val SOME t' = expanded2polynomial t; term2str t';
295 "1 + - 1 * x ^^^ 2 + - 5 * x ^^^ 5";
296 val t = str2term "1 - x";
297 val SOME t' = expanded2polynomial t; term2str t';
299 val t = str2term "1 + (-1) * x";
300 val SOME t' = expanded2polynomial t; term2str t';
302 val t = (term_of o the o (parse thy)) "1 + (-1) * x ^^^ 2 + (-5) * x ^^^5";
303 val SOME t' = polynomial2expanded t; term2str t';
304 "1 - x ^^^ 2 - 5 * x ^^^ 5";
307 "-------- external calculating functions test -----------";
308 "-------- external calculating functions test -----------";
309 "-------- external calculating functions test -----------";
310 val t1 = (term_of o the o (parse thy)) "((3 * x^^^2 + 6 *x + 3) / (2*x + 2))";
311 val SOME (t1',asm)= factout_p_ thy t1;
312 term2str t1'; terms2str asm;
313 "(3 + 3 * x) * (1 + 1 * x) / (2 * (1 + 1 * x))";
315 val SOME (t1',asm)= cancel_p_ thy t1;
316 term2str t1'; terms2str asm;
318 "[\"1 + 1 * x ~= 0\"]";
320 val t = (term_of o the o (parse thy)) "((-3 * x^^^2 + 6 *x - 3) / (2*x - 2))";
321 val SOME (t',asm)= cancel_ thy t;
322 term2str t'; terms2str asm;
325 val SOME (t',asm)= factout_ thy t;
326 term2str t'; terms2str asm;
327 "(3 - 3 * x) * (-1 + x) / (2 * (-1 + x))";
330 val t = str2term "((x+ (-1)) / (x + 1)) + ((x + 1) / (x + (-1)))";
331 val SOME (t',asm) = add_fraction_p_ thy t;
332 term2str t'; terms2str asm;
333 "(2 + 2 * x ^^^ 2) / (-1 + 1 * x ^^^ 2)";
335 val SOME (t',asm) = common_nominator_p_ thy t;
336 term2str t'; terms2str asm;
337 "(-1 + 1 * x) * (-1 + 1 * x) / ((1 + 1 * x) * (-1 + 1 * x)) +\n(1 + 1 * x) * (1 + 1 * x) / ((1 + 1 * x) * (-1 + 1 * x))";
340 val t = str2term "((x - 1) / (x + 1)) + ((x + 1) / (x - 1))";
341 val SOME (t',asm) = add_fraction_ thy t;
342 term2str t'; terms2str asm;
343 "(2 + 2 * x ^^^ 2) / (-1 + x ^^^ 2)";
345 val SOME (t',asm) = common_nominator_ thy t;
346 term2str t'; terms2str asm;
347 "(-1 + x) * (-1 + x) / ((1 + x) * (-1 + x)) +\n(1 + x) * (1 + x) / ((1 + x) * (-1 + x))";
350 val t = str2term "((1) / (2*x + 2)) + ((1) / (2*x + (-2))) + ((1) / ( x^^^2 + (-1)))+((1) / (x^^^2 + (-2)*x + 1))";
351 val SOME (t',asm) = common_nominator_p_ thy t;
352 term2str t'; terms2str asm;
353 "1 * (1 + -2 * x + 1 * x ^^^ 2) /\n((-1 + 1 * x) * (2 * ((-1 + 1 * x) * (1 + 1 * x)))) +\n(1 * (-1 + 1 * x ^^^ 2) /\n ((-1 + 1 * x) * (2 * ((-1 + 1 * x) * (1 + 1 * x)))) +\n (1 * (-2 + 2 * x) / ((-1 + 1 * x) * (2 * ((-1 + 1 * x) * (1 + 1 * x)))) +\n 1 * (#";
355 val SOME (t',asm) = add_fraction_p_ thy t;
356 term2str t'; terms2str asm;
357 "1 * x / (1 + -2 * x + 1 * x ^^^ 2)";
358 "[\"1 + 1 * x ~= 0\"]";
359 val SOME(t',asm) = norm_rational_ thy t;
360 term2str t'; terms2str asm;
361 "1 * x / (1 + -2 * x + 1 * x ^^^ 2)";
362 "[\"1 + 1 * x ~= 0\"]";
364 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))";
365 val SOME (t3',_) = common_nominator_ thy t3;
366 val SOME (t3'',_) = add_fraction_ thy t3;
370 val SOME(t4,t5) = norm_expanded_rat_ thy t3;
376 val t=(term_of o the o (parse thy)) "(9 - x^^^2)/(9 - 6*x + x^^^2)";
377 val SOME (t',_) = factout_ thy t;
378 val SOME (t'',_) = cancel_ thy t;
381 "(3 + x) * (3 - x) / ((3 - x) * (3 - x))";
384 val t=(term_of o the o (parse thy))
385 "(9 - x^^^2) / (9 - 6*x + x^^^2) + 1 / (3 - x)";
386 val SOME (t',_) = common_nominator_ thy t;
387 val SOME (t'',_) = add_fraction_ thy t;
390 "(9 - x ^^^ 2) / ((3 - x) * (3 - x)) + 1 * (3 - x) / ((3 - x) * (3 - x))";
393 (*WN021016 added -----vv---*)
394 val t = str2term "(9 - x^^^2) / (9 - 6*x + x^^^2) + 1";
395 val SOME (t',_) = common_nominator_ thy t;
396 val SOME (t'',_) = add_fraction_ thy t;
397 term2str t' = "(9 - x ^^^ 2) / (9 - 6 * x + x ^^^ 2) +\n1" ^
398 " * (9 - 6 * x + x ^^^ 2) / (9 - 6 * x + x ^^^ 2)" (*true*);
399 term2str t'' = "6 / (3 - x)" (*true*);
401 val t = str2term "1 + (9 - x^^^2) / (9 - 6*x + x^^^2)";
402 val SOME (t',_) = common_nominator_ thy t;
403 val SOME (t'',_) = add_fraction_ thy t;
404 term2str t' = "1 * (9 - 6 * x + x ^^^ 2) / (9 - 6 * x + x ^^^ 2) +\n" ^
405 "(9 - x ^^^ 2) / (9 - 6 * x + x ^^^ 2)" (*true*);
406 term2str t'' = "6 / (3 - x)" (*true*);
407 (*WN021016 added -----^^---*)
408 (*WN030602 added -----vv--- no rewrite -> NONE !*)
409 val t = str2term "1 / a";
410 val NONE = cancel_p_ thy t;
411 val NONE = rewrite_set_ thy false cancel_p t;
412 (*WN.2.6.03 added -------^^---*)
414 val t = str2term "(y^^^2 - x^^^2)/(y^^^2 - 2*y*x + x^^^2)";
415 val SOME (t',_) = factout_ thy t;
416 val SOME (t'',_) = cancel_ thy t;
417 term2str t' = "(y + x) * (y - x) / ((y - x) * (y - x))"(*true*);
418 term2str t'' = "(y + x) / (y - x)";
420 val t = str2term "(y^^^2 - x^^^2)/(y^^^2 - 2*y*x + x^^^2) + 1 / (y - x)";
421 val SOME (t',_) = common_nominator_ thy t;
422 val SOME (t'',_) = add_fraction_ thy t;
424 "(-1 * x ^^^ 2 + y ^^^ 2) / ((-1 * x + y) * (-1 * x + y)) +\n1" ^
425 " * (-1 * x + y) / ((-1 * x + y) * (-1 * x + y))" (*true*);
426 term2str t'' = "(-1 - x - y) / (x - y)" (*true*);
428 val t = str2term "(x^^^2 - y^^^2)/(x^^^2 - 2*x*y + y^^^2) + 1 / (x - y)";
429 val SOME (t',_) = common_nominator_ thy t;
430 val SOME (t'',_) = add_fraction_ thy t;
431 if term2str t' = "(-1 * y ^^^ 2 + x ^^^ 2) / ((-1 * y + x) * (-1 * y + x))" ^
432 " +\n1 * (-1 * y + x) / ((-1 * y + x) * (-1 * y + x))" then ()
433 else error "rational.sml lex-ord 1";
434 if term2str t'' = "(-1 - y - x) / (y - x)" then ()
435 else error "rational.sml lex-ord 2";
436 (*WN.16.10.02 WN070905 lexicographische Ordnung erhalten ! SK.ord*)
439 val t = str2term "(x^^^2 - y^^^2)/(x^^^2 - 2*x*y + y^^^2)";
440 val SOME (t',_) = norm_expanded_rat_ thy t;
441 if term2str t' = "(x + y) / (x - y)" then ()
442 else error "rational.sml term2poly: invalid x ^^^ 2 - y ^^^ 2 No.1";
443 (*val SOME (t'',_) = norm_rational_ thy t;
444 *** RATIONALS_TERM2POLY_EXCEPTION: Invalid Polynomial
445 WN.16.10.02 ?! + WN060831???SK4
446 WN070905 *** term2poly: invalid = x ^^^ 2 - y ^^^ 2*)
449 val t = str2term "(9 - x^^^2)/(9 - 6*x + x^^^2) + (1)/(3 + x)";
450 val SOME (t',_) = norm_expanded_rat_ thy t;
451 if term2str t' = "(12 + 5 * x + x ^^^ 2) / (9 - x ^^^ 2)" then ()
452 else error "rational.sml (9 - x^^^2)/(9 - 6*x + x^^^2) +...";
453 (*val SOME (t'',_) = norm_rational_ thy t;
454 *** RATIONALS_TERM2POLY_EXCEPTION: Invalid Polynomial WN.16.10.02 ?!
455 WN070906 *** term2poly: invalid = 9 - x ^^^ 2 SK.term2poly*)
457 val t=(term_of o the o (parse thy))
458 "(9 + (-1)* x^^^2)/(9 + (-1)* 6*x + x^^^2) + (1)/(3 + x)";
459 val SOME (t',_) = norm_expanded_rat_ thy t;
460 val SOME (t'',_) = norm_rational_ thy t;
463 "(12 + 5 * x + x ^^^ 2) / (9 - x ^^^ 2)";
464 "(12 + 5 * x + x ^^^ 2) / (9 + (-1) * x ^^^ 2)";
467 "-------- cancel from: Mathematik 1 Schalk Reniets Verlag";
468 "-------- cancel from: Mathematik 1 Schalk Reniets Verlag";
469 "-------- cancel from: Mathematik 1 Schalk Reniets Verlag";
470 val thy = @{theory "Rational"};
471 val thy' = "Rational";
473 val mp = "make_polynomial";
475 writeln ("example 186:");
477 val e186a'="(14 * x * y) / ( x * y )";(*SRC*)
478 rewrite_set_ thy false cancel (str2term e186a');
480 val e186a = the (rewrite_set thy' false "cancel" e186a');
481 is_expanded (parse_rat "14 * x * y");
482 is_expanded (parse_rat "x * y");
483 if e186a = ("14 / 1", "[\"y * x ~= 0\"]") then ()
484 else error "rational.sml cancel Schalk e186a";
487 val e186b'="(60 * a * b) / ( 15 * a * b )";
488 val e186b = the (rewrite_set thy' false "cancel" e186b');
490 val e186c'="(144 * a^^^2 * b * c) / (12 * a * b * c )";
491 val e186c = (the (rewrite_set thy' false "cancel" e186c'))
492 handle e => print_exn_G e;
493 val t = (term_of o the o (parse thy)) e186c';
494 if e186c = ("12 * a / 1", "[\"12 * (c * (b * a)) ~= 0\"]") then ()
495 else error "rational.sml cancel Schalk e186c";
497 writeln ("example 187:");
499 val e187a'="(12 * x * y) / (8 * y^^^2 )";(*SRC*)
500 val e187a = the (rewrite_set thy' false "cancel" e187a');
502 val e187b'="(8 * x^^^2 * y * z ) / (18 * x * y^^^2 * z )";
503 val e187b = the (rewrite_set thy' false "cancel" e187b');
505 val e187d'="(9 * x^^^5 * y^^^2 * z^^^4) / (15 * x^^^6 * y^^^3 * z )";(*SRC*)
506 val e187d = the (rewrite_set thy' false "cancel" e187d');
507 if e187d = ("3 * z ^^^ 3 / (5 * (y * x))",
508 "[\"3 * (z * (y ^^^ 2 * x ^^^ 5)) ~= 0\"]") then ()
509 else error "rational.sml cancel Schalk e186d";
511 writeln "example 188:";
512 val e188a'="(-8 + 8 * x) / (-9 + 9 * x)";(*SRC*)
513 val e188a = the (rewrite_set thy' false "cancel" e188a');
514 is_expanded (parse_rat "8 * x + -8");
515 (* e188a = ("8 / 9",["not ((-1) + x = 0)"]) then () 13.3.03*)
516 if e188a = ("8 / 9", "[\"-1 + x ~= 0\"]") then ()
517 else error "rational.sml: e188a new behaviour";
519 val SOME (t,_) = rewrite_set thy' false mp "(8*((-1) + x))/(9*((-1) + x))";
521 val e188b'="(-15 + 5 * x) / (-18 + 6 * x)";(*SRC*)
522 val SOME (t, asm) = rewrite_set thy' false "cancel" e188b';
523 t = "5 / 6" (*true*);
526 val e188c'="( a + -1 * b ) / ( b + -1 * a )";
527 val e188c = the (rewrite_set thy' false "cancel_p" e188c');
528 (*is_expanded (parse_rat "a + -1 * b");*)
530 rewrite_set thy' false mp "((-1)*(b + (-1) * a))/(1*(b + (-1) * a))";
531 if t= "(a + -1 * b) / (-1 * a + b)" then()
532 else error "rational.sml: e188c new behaviour";
534 writeln ("example 190:");
536 val e190c'="( 27 * a^^^3 + 9 * a^^^2 + 3 * a + 1 ) / ( 27 * a^^^3 + 18 * a^^^2 + 3 * a )";
537 val e190c = the (rewrite_set thy' false "cancel" e190c');
538 val SOME (t,_) = rewrite_set thy' false mp "((1 + 9 * a ^^^ 2)*(1 + 3 * a))/((3 * a + 9 * a ^^^ 2)*(1 + 3 * a))";
539 if t = "(1 + 3 * a + 9 * a ^^^ 2 + 27 * a ^^^ 3) /\n(3 * a + 18 * a ^^^ 2 + 27 * a ^^^ 3)" then ()
540 else error "rational.sml: e190c new behaviour";
542 writeln ("example 191:");
544 val e191a'="( x^^^2 + -1 * y^^^2 ) / ( x + y )";
546 val e191a = the (rewrite_set thy' false "cancel" e191a');
547 is_expanded (parse_rat "x^^^2 + -1 * y^^^2");
549 is_expanded (parse_rat "x + y");
551 val SOME (t,_) = rewrite_set thy' false mp "((x + (-1) * y)*(x + y))/((1)*(x + y))";
552 (* t="(x ^^^ 2 + -1 * y ^^^ 2) / (x + y)" then() WN.13.3.03*)
553 if t="(x ^^^ 2 + -1 * y ^^^ 2) / (x + y)" then()
554 else error "rational.sml: e191a new behaviour";
557 val e191c'="( 9 * x^^^2 + -30 * x + 25 ) / ( 9 * x^^^2 + -25 )";
559 val e191c = the (rewrite_set thy' false "cancel" e191c');
560 is_expanded (parse_rat "9 * x^^^2 + -30 * x + 25");
562 is_expanded (parse_rat "25 + -30*x + 9*x^^^2");
564 is_expanded (parse_rat "-25 + 9*x^^^2");
566 val SOME (t,_) = rewrite_set thy' false mp "(((-5) + 3 * x)*((-5) + 3 * x))/((5 + 3 * x)*((-5) + 3 * x))";
567 (* t="(25 + ((-30) * x + 9 * x ^^^ 2)) / ((-25) + 9 * x ^^^ 2)"then() 13.3.03*)
568 if t= "(25 + -30 * x + 9 * x ^^^ 2) / (-25 + 9 * x ^^^ 2)" then()
569 else error "rational.sml: 'e191c' new behaviour";
572 writeln ("example 192:");
574 val e192b'="( 7 * x^^^3 + -1 * x^^^2 * y ) / ( 7 * x * y^^^2 + -1 * y^^^3 )";
576 val e192b = the (rewrite_set thy' false "cancel" e192b');
577 -------------------*)
578 val SOME (t',_) = rewrite_set thy' false mp "((x ^^^ 2)*(7 * x + (-1) * y))/((y ^^^ 2)*(7 * x + (-1) * y))";
579 (*========== inhibit exn 110317 ================================================
580 if t' = "(7 * x ^^^ 3 + -1 * x ^^^ 2 * y) / (7 * x * y ^^^ 2 + -1 * y ^^^ 3)"
581 (*"(-1 * y * x ^^^ 2 + 7 * x ^^^ 3) / (-1 * y ^^^ 3 + 7 * x * y ^^^ 2)"WN050929*)
582 then () else error "rational.sml: 'e192b' new behaviour";
583 (*^^^ works with MG's simplifier vvv*)
584 val t =str2term"((x ^^^ 2)*(7 * x + (-1) * y))/((y ^^^ 2)*(7 * x + (-1) * y))";
585 val SOME (t',_) = rewrite_set_ thy false make_polynomial t;
586 if term2str t' = "(7 * x ^^^ 3 + -1 * x ^^^ 2 * y) / (7 * x * y ^^^ 2 + -1 * y ^^^ 3)" then () else error "rational.sml: 'e192b'MG new behaviour";
587 ============ inhibit exn 110317 ==============================================*)
589 writeln ("example 193:");
591 val e193a'="( x^^^2 + -6 * x + 9 ) / ( x^^^2 + -9 )";
593 val e193a = the (rewrite_set thy' false "cancel" e193a');
594 -------------------*)
596 val e193b'="( x^^^2 + -8 * x + 16 ) / ( 2 * x^^^2 + -32 )";
598 val e193b = the (rewrite_set thy' false "cancel" e193b');
600 val e193c'="( 2 * x + -50 * x^^^3 ) / ( 25 * x^^^2 + -10 * x + 1 )";
601 val SOME(t,_) = rewrite_set thy' false "cancel" e193c';
602 -------------------*)
604 val wn01 = "(-25 + 9*x^^^2)/(5 + 3*x)";
605 val SOME (t, asm) = rewrite_set thy' false "cancel" wn01;
606 (* t = "((-5) + 3 * x) / 1" then () WN.13.3.03*)
607 if t = "(-5 + 3 * x) / 1" andalso asm = "[\"5 + 3 * x ~= 0\"]" then ()
608 else error "rational.sml: new behav. in cancel wn01";
610 "-------- common_nominator_p ----------------------------";
611 "-------- common_nominator_p ----------------------------";
612 "-------- common_nominator_p ----------------------------";
613 val rls' = "common_nominator_p";
615 writeln ("example 204:");
617 val e204a'="((5 * x) / 9) + ((3 * x) / 9) + (x / 9)";
618 val e204a = the (rewrite_set thy' false "common_nominator_p" e204a');
620 val e204b'="5 / x + -3 / x + -1 / x";
621 val e204b = the (rewrite_set thy' false "common_nominator_p" e204b');
622 if e204b = ("1 / x", "[]") then ()
623 else error "rational.sml common_nominator_p example e204b";
625 writeln ("example 205:");
627 val e205a'="((4 * x + 7) / 8) + ((4 * x + 3) / 8)";
628 val e205a = the (rewrite_set thy' false "common_nominator_p" e205a');
630 val e205b'="((5 * x + 2) / 3) + ((-2 * x + 1) / 3)";
631 val e205b = the (rewrite_set thy' false "common_nominator_p" e205b');
632 if e205b = ("(1 + x) / 1", "[]") then ()
633 else error "rational.sml common_nominator_p example e204b";
635 writeln ("example 206:");
637 val e206a'="((5 * x + 4) / (2 * x + -1)) + ((9 * x + 5) / (2 * x + -1))";
638 val e206a = the (rewrite_set thy' false "common_nominator_p" e206a');
640 val e206b'="((17 * x + -23) / (5 * x + 4)) + ((-25 + -17 * x) / (5 * x + 4))";
641 val e206b = the (rewrite_set thy' false "common_nominator_p" e206b');
643 writeln ("example 207:");
644 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)) ";
645 val e207 = the (rewrite_set thy' false "common_nominator_p" e207');
647 writeln ("example 208:");
648 val e208'="((3 * x + 2) / (x + 2)) + ((5 * x + -1) / (x + 2)) + ((-7 * x + -3) / (x + 2)) + ((-1 * x + -3) / (x + 2)) ";
649 val e208 = the (rewrite_set thy' false "common_nominator_p" e208');
651 writeln ("example 209:");
652 val e209'="((3 * x + -7 * y + 3 * z) / (4)) + ((2 * x + 17 * y + 10 * z) / (4)) + ((-1 * x + 2 * y + z) / (4)) ";
653 val e209 = the (rewrite_set thy' false "common_nominator_p" e209');
655 writeln ("example 210:");
656 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)) ";
657 val e210 = the (rewrite_set thy' false "common_nominator_p" e210');
659 writeln ("example 211:");
661 val e211a'="((b) / (a + -1 * b)) + ((-1 * a) / (a + -1 * b))";
662 val e211a = the (rewrite_set thy' false "common_nominator_p" e211a');
664 val e211b'="((b) / (b^^^2 + -1 * a^^^2)) + ((-1 * a) / (b^^^2 + -1 * a^^^2))";
665 val e211b = the (rewrite_set thy' false "common_nominator_p" e211b');
667 writeln ("example 212:");
669 val e212a'="((4) / (x)) + ((-3) / (y)) + -1";
670 val e212a = the (rewrite_set thy' false "common_nominator_p" e212a');
672 val e212b'="((4) / (x)) + ((-5) / (y)) + ((6) / (x*y))";
673 val e212b = the (rewrite_set thy' false "common_nominator_p" e212b');
675 writeln ("example 213:");
677 val e213a'="((5 * x) / (3 * y^^^2)) + ((19 * z) / (6 * x * y)) + ((-2 * x) / (3 * y^^^2)) + ((7 * y^^^2) / (6 * x^^^2)) ";
678 val e213a = the (rewrite_set thy' false "common_nominator_p" e213a');
680 val e213b'="((2 * b) / (3 * a^^^2)) + ((3 * c) / (7 * a * b)) + ((4 * b) / (3 * a^^^2)) + ((3 * a) / (7 * b^^^2))";
681 val e213b = the (rewrite_set thy' false "common_nominator_p" e213b');
683 writeln ("example 214:");
685 val e214a'="((3 * x + 2 * y + 2 * z) / (4)) + ((-5 * x + -3 * y) / (3)) + ((x + y + -2 * z) / (2))";
686 val e214a = the (rewrite_set thy' false "common_nominator_p" e214a');
688 val e214b'="((5 * x + 2 * y + z) / (2)) + ((-7 * x + -3 * y) / (3)) + ((3 * x + 6 * y + -1 * z) / (12))";
689 val e214b = the (rewrite_set thy' false "common_nominator_p" e214b');
691 writeln ("example 216:");
693 val e216a'="((2 * b + 3 * c) / (a * c)) + ((3 * a + b) / (a * b)) + ((-2 * b^^^2 + -3 * a * c) / (a * b * c))";
694 val e216a = the (rewrite_set thy' false "common_nominator_p" e216a');
696 val e216b'="((2 * a + 3 * b) / (b * c)) + ((3 * c + a) / (a * c)) + ((-2 * a^^^2 + -3 * b * c) / (a * b * c))";
697 val e216b = the (rewrite_set thy' false "common_nominator_p" e216b');
699 writeln ("example 217:");
700 val e217'="((z + -1) / (z)) + ((3 * z ^^^2 + -6 * z + 5) / (z^^^2)) + ((-4 * z^^^3 + 7 * z^^^2 + -5 * z + 5) / (z^^^3))";
701 val e217 = the (rewrite_set thy' false "common_nominator_p" e217');
704 val rls' = "common_nominator";
705 writeln ("example 218:");
706 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))";
707 val e218 = the (rewrite_set thy' false "common_nominator" e218');
708 if e218 = ("(16 - 63 * a ^^^ 2 - 81 * a ^^^ 3) / (108 * a ^^^ 4)", "[]") then ()
709 else error "rationa.sml common_nominator example e218";
711 writeln ("example 219:");
713 val e219a'="((1) / (y + 1)) + ((1) / (y + 2)) + ((1) / (y + 3))";
714 val e219a = the (rewrite_set thy' false "common_nominator" e219a');
716 val e219b'="((1) / (x + 1)) + ((1) / (x + 2)) + ((-2) / (x + 3))";
717 val e219b = the (rewrite_set thy' false "common_nominator" e219b');
718 if e219b = ("(5 + 3 * x) / (6 + 11 * x + 6 * x ^^^ 2 + x ^^^ 3)", "[]") then ()
719 else error "rationa.sml common_nominator example e219b";
721 writeln ("example 220:");
723 val e220a'="((17) / (5 * r + -2)) + ((-13) / (2 * r + 3)) + ((4) / (3 * r + -5))";
724 val e220a = the (rewrite_set thy' false "common_nominator" e220a');
726 val e220b'="((20 * a) / (a + -3)) + ((-19 * a) / (a + -4)) + ((a) / (a + -5))";
727 val e220b = the (rewrite_set thy' false "common_nominator" e220b');
729 writeln ("example 221:");
731 val e221a'="((a + b) / (a + -1 * b)) + ((a + -1 * b) / (a + b))";
732 val e221a = the (rewrite_set thy' false "common_nominator" e221a');
734 val e221b'="((x + -1 * y) / (x + y)) + ((x + y) / (x + -1 * y)) ";
735 val e221b = the (rewrite_set thy' false "common_nominator" e221b');
737 writeln ("example 222:");
739 val e222a'="((1 + -1 * x) / (1 + x)) + ((-1 + -1 * x) / (1 + -1 * x)) + ((4 * x) / (1 + -1 * x^^^2))";
740 val e222a = the (rewrite_set thy' false "common_nominator" e222a');
742 val e222b'="((1 + x ) / (1 + -1 * x)) + ((-1 + x) / (1 + x)) + ((2 * x) / (1 + -1 * x^^^2))";
743 val e222b = the (rewrite_set thy' false "common_nominator" e222b');
745 writeln ("example 225:");
747 val e225a'="((6 * a) / (a^^^2 + -64)) + ((a + 2) / (2 * a + 16)) + ((-1) / (2))";
748 val e225a = the (rewrite_set thy' false "common_nominator" e225a');
750 val e225b'="((a + 2 ) / (2 * a + 12)) + ((4 * a) / (a^^^2 + -36)) + ((-1) / (2))";
751 val e225b = the (rewrite_set thy' false "common_nominator" e225b');
753 writeln ("example 226:");
755 val e226a'="((35 * z) / (49 * z^^^2 + -4)) + -1 + ((14 * z + -1) / (14 * z + 4)) ";
756 val e226a = the (rewrite_set thy' false "common_nominator" e226a');
758 val e226b'="((45 * a * b) / (25 * a^^^2 + -9 * b^^^2)) + ((20 * a + 3 * b) / (10 * a + 6 * b)) + -2";
759 val e226b = the (rewrite_set thy' false "common_nominator" e226b');
761 writeln ("example 227:");
763 val e227a'="((6 * z + 11) / (6 * z + 14)) + ((9 * z ) / (9 * z^^^2 + -49)) + -1 ";
764 val e227a = the (rewrite_set thy' false "common_nominator" e227a');
766 val e227b'="((16 * a + 37 * b) / (4 * a + 10 * b)) + ((6 * a * b) / (4 * a^^^2 + -25 * b^^^2)) + -4 ";
767 val e227b = the (rewrite_set thy' false "common_nominator" e227b');
769 writeln ("example 228:");
771 val e228a'="((7 * a + 11) / (3 * a^^^2 + -3)) + ((-2 * a + -1) / (a^^^2 + -1 * a)) + ((-1) / (3 * a + 3))";
772 val e228a = the (rewrite_set thy' false "common_nominator" e228a');
774 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))";
775 val e228b = the (rewrite_set thy' false "common_nominator" e228b');
778 writeln ("example 229:");
780 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))";
781 val e229a = the (rewrite_set thy' false "common_nominator" e229a');
783 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))";
784 val e229b = the (rewrite_set thy' false "common_nominator" e229b');
786 writeln ("example 230:");
788 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))";
789 val e230a = the (rewrite_set thy' false "common_nominator" e230a');
791 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))";
792 val e230b = the (rewrite_set thy' false "common_nominator" e230b');
794 writeln ("example 231:");
796 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))";
797 val e231a = the (rewrite_set thy' false "common_nominator" e231a');
799 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))";
800 val e231b = the (rewrite_set thy' false "common_nominator" e231b');
802 writeln ("example 232:");
804 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))";
805 val e232a = the (rewrite_set thy' false "common_nominator" e232a');
807 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))";
808 val e232b = the (rewrite_set thy' false "common_nominator" e232b');
810 writeln ("example 233:");
812 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))";
813 val e233a = the (rewrite_set thy' false "common_nominator" e233a');
815 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))";
816 val e233b = the (rewrite_set thy' false "common_nominator" e233b');
818 writeln ("example 234:");
820 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))";
821 val e234a = the (rewrite_set thy' false "common_nominator" e234a');
823 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)) ";
824 val e234b = the (rewrite_set thy' false "common_nominator" e234b');
826 writeln ("example 235:");
828 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))";
829 val e235a = the (rewrite_set thy' false "common_nominator" e235a');
831 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)) ";
832 val e235b = the (rewrite_set thy' false "common_nominator" e235b');
834 writeln ("example 236:");
836 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))";
837 val e236a = the (rewrite_set thy' false "common_nominator" e236a');
839 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)) ";
840 val e236b = the (rewrite_set thy' false "common_nominator" e236b');
844 writeln ("example heuberger:");
845 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)";
846 val eheu = the (rewrite_set thy' false "cancel" eheu');
848 val rls' = "common_nominator_p";
849 writeln ("example stiefel:");
850 val est1'="(7) / (-14) + (-2) / (4)";
851 val est1 = the (rewrite_set thy' false "common_nominator_p" est1');
852 if est1 = ("-1 / 1", "[]") then ()
853 else error "new behaviour in rational.sml: est1'";
855 val t = (term_of o the o (parse thy))
856 "(9 - x ^^^ 2) / (9 - 6 * x + x ^^^ 2)";
857 val SOME (t',_) = factout_ thy t;
858 if term2str t' = "(3 + x) * (3 - x) / ((3 - x) * (3 - x))" then ()
859 else error "rational.sml factout_ (9 - x ^^^ 2) / (9 - 6 * x + x ^^^ 2)";
862 "-------- reverse rewrite -------------------------------";
863 "-------- reverse rewrite -------------------------------";
864 "-------- reverse rewrite -------------------------------";
865 (*WN.28.8.02: tests for the 'reverse-rewrite' functions:
866 these are defined in Rationals.ML and stored in
867 the 'reverse-ruleset' cancel*)
869 (*the term for which reverse rewriting is demonstrated*)
870 val t = (term_of o the o (parse thy))
871 "(9 - x ^^^ 2) / (9 + 6 * x + x ^^^ 2)";
872 val Rrls {scr=Rfuns {init_state=ini,locate_rule=loc,
873 next_rule=nex,normal_form=nor,...},...} = cancel;
875 (*normal_form produces the result in ONE step*)
876 val SOME (t',_) = nor t;
877 if term2str t' = "(3 - x) / (3 + x)" then ()
878 else error "rational.sml normal_form (9 - x ^^^ 2) / (9 - 6 * x + x ^^^ 2)";
880 (*initialize the interpreter state used by the 'me'*)
881 val (t,_,revsets,_) = ini t;
883 (*find the rule 'r' to apply to term 't'*)
884 val SOME (r as (Thm (str, thm))) = nex revsets t;
885 if str = "sym_#power_Float ((3,0), (0,0)) __ ((2,0), (0,0))"
886 andalso string_of_thm thm =
887 (string_of_thm o make_thm o (cterm_of (@{theory "Isac"})))
888 (Trueprop $ (term_of o the o (parse thy)) "9 = 3 ^^^ 2") then ()
889 else error "rational.sml next_rule (9 - x ^^^ 2) / (9 - 6 * x + x ^^^ 2)";
890 (* before Isa02->09-2 was not checked automatically, ?was different?:
891 val SOME r = nex revsets t;
892 val r = Thm ("sym_#mult_2_3","6 = 2 * 3") : rule*)
894 (* check, if the rule 'r' applied by the user to 't' belongs to the ruleset;
895 if the rule is OK, the term resulting from applying the rule is returned,too;
896 there might be several rule applications inbetween,
897 which are listed after the head in reverse order *)
898 val (r, (t, asm))::_ = loc revsets t r;
899 if term2str t = "(9 - x ^^^ 2) / (3 ^^^ 2 + 6 * x + x ^^^ 2)" andalso asm = []
901 else error "rational.sml locate_rule (9 - x ^^^ 2) / (9 - 6 * x + x ^^^ 2)";
903 (* find the next rule to apply *)
904 val SOME (r as (Thm (str, thm))) = nex revsets t;
905 if str = "sym_#power_Float ((3,0), (0,0)) __ ((2,0), (0,0))" andalso
906 string_of_thm thm = (string_of_thm o make_thm o (cterm_of (@{theory "Isac"})))
907 (Trueprop $ (term_of o the o (parse thy)) "9 = 3 ^^^ 2") then ()
908 else error "rational.sml next_rule (9 - x ^^^ 2) / (9 - 6 * x + x ^^^ 2)";
910 (*check the next rule*)
911 val (r, (t, asm)) :: _ = loc revsets t r;
912 if term2str t = "(3 ^^^ 2 - x ^^^ 2) / (3 ^^^ 2 + 6 * x + x ^^^ 2)" then ()
913 else error "rational.sml locate_rule (9 - x ^^^ 2) / (9 - 6 * x + x ^^^ 2) II";
915 (*find and check the next rules, rewrite*)
916 val SOME r = nex revsets t;
917 val (r,(t,asm))::_ = loc revsets t r;
918 if term2str t = "(3 ^^^ 2 - x ^^^ 2) / (3 ^^^ 2 + 2 * 3 * x + x ^^^ 2)" then ()
919 else error "rational.sml locate_rule II";
921 val SOME r = nex revsets t;
922 val (r,(t,asm))::_ = loc revsets t r;
923 if term2str t = "(3 - x) * (3 + x) / (3 ^^^ 2 + 2 * 3 * x + x ^^^ 2)" then ()
924 else error "rational.sml next_rule II";
926 val SOME r = nex revsets t;
927 val (r,(t,asm))::_ = loc revsets t r;
928 if term2str t = "(3 - x) * (3 + x) / ((3 + x) * (3 + x))" then ()
929 else error "rational.sml next_rule III";
931 val SOME r = nex revsets t;
932 val (r, (t, asm)) :: _ = loc revsets t r;
934 if ss = "(3 - x) / (3 + x)" andalso terms2str asm = "[\"3 + x ~= 0\"]" then ()
935 else error "rational.sml: new behav. in rev-set cancel";
937 "-------- 'reverse-ruleset' cancel_p --------------------";
938 "-------- 'reverse-ruleset' cancel_p --------------------";
939 "-------- 'reverse-ruleset' cancel_p --------------------";
940 (*WN.11.9.02: the 'reverse-ruleset' cancel_p*)
942 (*the term for which reverse rewriting is demonstrated*)
943 val t = str2term "(9 + (-1)*x^^^2) / (9 + ((-6)*x + x^^^2))";
944 val Rrls {scr=Rfuns {init_state=ini,locate_rule=loc,
945 next_rule=nex,normal_form=nor,...},...} = cancel_p;
947 (*normal_form produces the result in ONE step*)
948 val SOME (t',_) = nor t;
949 term2str t' = "(3 + 1 * x) / (3 + -1 * x)";
951 (*initialize the interpreter state used by the 'me'*)
952 val SOME (t', asm) = cancel_p_ thy t;
953 term2str t' = "(3 + x) / (3 + -1 * x)" (*true*);
954 terms2str asm = "[\"3 + -1 * x ~= 0\"]" (*true*);
955 val (t,_,revsets,_) = ini t;
957 (* WN.10.10.02: dieser Fall terminiert nicht
958 (make_polynomial enth"alt zu viele rules)
959 WN060823 'init_state' requires rewriting on specified location in the term
960 print_depth 99; Rfuns; print_depth 3;
961 WN060831 cycling "sym_order_mult_rls_" "sym_real_mult_assoc"
962 as was with make_polynomial before ?!?*)
964 val SOME r = nex revsets t;
965 eq_Thm (r, Thm ("sym_#power_Float ((3,0), (0,0)) __ ((2,0), (0,0))",
966 mk_thm thy "9 = 3 ^^^ 2"));
967 (*WN060831 *** id_of_thm
968 Exception- ERROR raised ...
969 val (r,(t,asm))::_ = loc revsets t r;
972 val SOME r = nex revsets t;
973 val (r,(t,asm))::_ = loc revsets t r;
977 writeln "****************** all tests successfull *************************";
981 (*WN.17.3.03 =========================================================vvv---*)
982 "-------- norm_Rational ---------------------------------";
983 "-------- norm_Rational ---------------------------------";
984 "-------- norm_Rational ---------------------------------";
985 val t = str2term "(3*x+5)/18 - x/2 - -(3*x - 2)/9 = 0";
986 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
987 if term2str t' = "1 / 18 = 0" then () else error "rational.sml 1";
989 val t = str2term "(17*x - 51)/9 - (-(13*x - 3)/6) + 11 - (9*x - 7)/4 = 0";
990 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
991 if term2str t' = "(237 + 65 * x) / 36 = 0" then ()
992 else error "rational.sml 2";
994 val t = str2term "(1/2 + (5*x)/2)^^^2 - ((13*x)/2 - 5/2)^^^2 - (6*x)^^^2 + 29";
995 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
996 if term2str t' = "23 + 35 * x + -72 * x ^^^ 2" then ()
997 else error "rational.sml 3";
999 (*trace_rewrite:=true;*)
1000 val t = str2term "Not (6*x is_atom)";
1001 val SOME (t',_) = rewrite_set_ thy false powers_erls t; term2str t';
1003 val t = str2term "1 < 2";
1004 val SOME (t',_) = rewrite_set_ thy false powers_erls t; term2str t';
1007 val t = str2term "(6*x)^^^2";
1008 val SOME (t',_) = rewrite_ thy dummy_ord powers_erls false
1009 (num_str @{thm realpow_def_atom}) t;
1010 if term2str t' = "6 * x * (6 * x) ^^^ (2 + -1)" then ()
1011 else error "rational.sml powers_erls (6*x)^^^2";
1013 val t = str2term "-1 * (-2 * (5 / 2 * (13 * x / 2)))";
1014 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
1015 if term2str t' = "65 * x / 2" then () else error "rational.sml 4";
1017 val t = str2term "1 - ((13*x)/2 - 5/2)^^^2";
1018 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
1019 (*bef.040209: if term2str t' = "(-21 + (130 * x + -169 * x ^^^ 2)) / 4"then()*)
1020 if term2str t' = "(-21 + 130 * x + -169 * x ^^^ 2) / 4" then ()
1021 else error "rational.sml 5";
1023 (*SRAM Schalk I, p.92 Nr. 609a*)
1024 val t = str2term "2*(3 - x/5)/3 - 4*(1 - x/3) - x/3 - 2*(x/2 - 1/4)/27 +5/54";
1025 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
1026 if term2str t' = "(-255 + 112 * x) / 135" then ()
1027 else error "rational.sml 6";
1029 (*SRAM Schalk I, p.92 Nr. 610c*)
1030 val t = str2term "((x- 1)/(x+1) + 1) / ((x- 1)/(x+1) - (x+1)/(x- 1)) - 2";
1031 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
1032 if term2str t' = "(-3 + -1 * x) / 2" then () else error "rational.sml 7";
1034 (*SRAM Schalk I, p.92 Nr. 476a*)
1035 val t = str2term "(x^^^2/(1 - x^^^2) + 1)/(x/(1 - x) + 1) * (1 + x)";
1036 (*. a/b : c/d translated to a/b * d/c .*)
1037 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
1038 (*if term2str t' = "1 / 1" then () else error "rational.sml 8";3.6.03*)
1039 if term2str t' = "1" then () else error "rational.sml 8";
1041 (*............................vvv---TODO: sollte gehen mit poly_order *)
1042 (*Schalk I, p.92 Nr. 472a*)
1043 val t = str2term "((8*x^^^2 - 32*y^^^2)/(2*x + 4*y))/((4*x - 8*y)/(x + y))";
1044 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
1045 if term2str t' = "x + y" then () else error "rational.sml p.92 Nr. 472a";
1047 (*Schalk I, p.70 Nr. 480b; a/b : c/d translated to a/b * d/c*)
1048 val t = str2term ("((12*x*y/(9*x^^^2 - y^^^2))/" ^
1049 "(1/(3*x - y)^^^2 - 1/(3*x + y)^^^2)) *" ^
1050 "(1/(x - 5*y)^^^2 - 1/(x + 5*y)^^^2)/" ^
1051 "(20*x*y/(x^^^2 - 25*y^^^2))");
1052 (*... nicht simpl, zerlegt ...*)
1053 val t = str2term ("((12*x*y/(9*x^^^2 - y^^^2))/" ^
1054 "(1/(3*x - y)^^^2 - 1/(3*x + y)^^^2))");
1055 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
1056 "(-12 * (x * y ^^^ 3) + 108 * (x * (y * x ^^^ 2))) / (12 * (x * y))";
1057 (* ~~~~~~~~~~ poly_order notwendig!*)
1058 val t = str2term ("(1/(x - 5*y)^^^2 - 1/(x + 5*y)^^^2)/" ^
1059 "(20*x*y/(x^^^2 - 25*y^^^2))");
1060 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
1061 if term2str t' = "1 / (x ^^^ 2 + -25 * y ^^^ 2)" then ()
1062 else error "rational.sml norm_Rational 1 / (x ^^^ 2 + -25 * y ^^^ 2)";
1064 "nonterm.SK6 ----- SK060904-2a non-termination of add_fraction_p_";
1065 (*WN.2.6.03 from rlang.sml 56a
1066 val t = str2term "(a + b * x) / (a + -1 * (b * x)) + (-1 * a + b * x) / (a + b * x) = 4 * (a * b) / (a ^^^ 2 + -1 * b ^^^ 2)";
1067 val NONE = rewrite_set_ thy false common_nominator_p t;
1069 WN060831 nonterm.SK7
1070 val t = str2term "(a + b * x) / (a + -1 * (b * x)) + (-1 * a + b * x) / (a + b * x)";
1071 val NONE = add_fraction_p_ thy t;
1075 (* ------------------------------------------------------------------- *)
1076 (*---------vvv------------ MG: ab 1.7.03 ----------------vvv-----------*)
1077 (* Simplifier fuer beliebige Buchterme *)
1078 (* ------------------------------------------------------------------- *)
1079 (*----------------------- norm_Rational_mg ----------------------------*)
1080 (* ------------------------------------------------------------------- *)
1082 "-------- numeral rationals -----------------------------";
1083 "-------- numeral rationals -----------------------------";
1084 "-------- numeral rationals -----------------------------";
1085 (*SRA Schalk I, p.40 Nr. 164b *)
1086 val t = str2term "(47/6 - 76/9 + 13/4)/(35/12)";
1087 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1089 if (term2str t) = "19 / 21" then ()
1090 else error "rational.sml: diff.behav. in norm_Rational_mg 1";
1092 (*SRA Schalk I, p.40 Nr. 166a *)
1093 val t = str2term "((5/4)/(4+22/7) + 37/20)*(110/3 - 110/9 * 23/11)";
1094 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1096 if (term2str t) = "45 / 2" then ()
1097 else error "rational.sml: diff.behav. in norm_Rational_mg 2";
1100 "-------- cancellation ----------------------------------";
1101 "-------- cancellation ----------------------------------";
1102 "-------- cancellation ----------------------------------";
1103 (* e190c Stefan K.*)
1105 "((1 + 9 * a ^^^ 2)*(1 + 3 * a))/((3 * a + 9 * a ^^^ 2)*(1 + 3 * a))";
1106 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1109 "(1 + 9 * a ^^^ 2) / (3 * a + 9 * a ^^^ 2)"
1111 else error "rational.sml: diff.behav. in norm_Rational_mg 3";
1113 (* e192b Stefan K.*)
1115 "((x ^^^ 2)*(7 * x + (-1) * y))/((y ^^^ 2)*(7 * x + (-1) * y))";
1116 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1121 else error "rational.sml: diff.behav. in norm_Rational_mg 4";
1123 (*SRC Schalk I, p.66 Nr. 379c *)
1126 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1131 else error "rational.sml: diff.behav. in norm_Rational_mg 5";
1133 (*SRC Schalk I, p.66 Nr. 380b *)
1135 "15*(3*x+3)*(4*x+9)/(12*(2*x+7)*(5*x+5))";
1136 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1139 "(27 + 12 * x) / (28 + 8 * x)"
1141 else error "rational.sml: diff.behav. in norm_Rational_mg 6";
1143 (*Schalk I, p.60 Nr. 215c *)
1144 (* Falsches Ergebnis: rechnet lange und cancel_p kann nicht weiter krzen!!!*)
1146 val t = str2term "(a+b)^^^4*(x - y)/((x - y)^^^3*(a+b)^^^2)";
1147 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1150 "(a ^^^ 4 * x + -1 * a ^^^ 4 * y + 4 * a ^^^ 3 * b * x + -4 * a ^^^ 3 * b * y + 6 * a ^^^ 2 * b ^^^ 2 * x + -6 * a ^^^ 2 * b ^^^ 2 * y + 4 * a * b ^^^ 3 * x + -4 * a * b ^^^ 3 * y + b ^^^ 4 * x + -1 * b ^^^ 4 * y) /(a ^^^ 2 * x ^^^ 3 + -3 * a ^^^ 2 * x ^^^ 2 * y + 3 * a ^^^ 2 * x * y ^^^ 2 + -1 * a ^^^ 2 * y ^^^ 3 + 2 * a * b * x ^^^ 3 + -6 * a * b * x ^^^ 2 * y + 6 * a * b * x * y ^^^ 2 + -2 * a * b * y ^^^ 3 + b ^^^ 2 * x ^^^ 3 + -3 * b ^^^ 2 * x ^^^ 2 * y + 3 * b ^^^ 2 * x * y ^^^ 2 + -1 * b ^^^ 2 * y ^^^ 3)"
1152 else error "rational.sml: diff.behav. in norm_Rational_mg 7";
1155 "(a ^^^ 4 * x + -1 * a ^^^ 4 * y + 4 * a ^^^ 3 * b * x + -4 * a ^^^ 3 * b * y + 6 * a ^^^ 2 * b ^^^ 2 * x + -6 * a ^^^ 2 * b ^^^ 2 * y + 4 * a * b ^^^ 3 * x + -4 * a * b ^^^ 3 * y + b ^^^ 4 * x + -1 * b ^^^ 4 * y) /(a ^^^ 2 * x ^^^ 3 + -3 * a ^^^ 2 * x ^^^ 2 * y + 3 * a ^^^ 2 * x * y ^^^ 2 + -1 * a ^^^ 2 * y ^^^ 3 + 2 * a * b * x ^^^ 3 + -6 * a * b * x ^^^ 2 * y + 6 * a * b * x * y ^^^ 2 + -2 * a * b * y ^^^ 3 + b ^^^ 2 * x ^^^ 3 + -3 * b ^^^ 2 * x ^^^ 2 * y + 3 * b ^^^ 2 * x * y ^^^ 2 + -1 * b ^^^ 2 * y ^^^ 3)"
1156 val SOME (t,_) = rewrite_set_ thy false cancel_p t;
1158 (* uncaught exception nonexhaustive binding failure
1159 raised at: stdIn:93.1-93.51 *)
1161 (*Schalk I, p.66 Nr. 381a *)
1162 (* ACHTUNG: rechnet ca. 2 Minuten !!! *)
1164 val t = str2term "18*(a+b)^^^3*(a - b)^^^2/(72*(a - b)^^^3*(a+b)^^^2)";
1165 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1168 "(a + b) / (4 * a + -4 * b)"
1169 then () else error "rational.sml: diff.behav. in norm_Rational_mg 8";
1172 (*SRC Schalk I, p.66 Nr. 381b *)
1174 "(4*x^^^2 - 20*x + 25)/(2*x - 5)^^^3";
1175 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1180 else error "rational.sml: diff.behav. in norm_Rational_mg 9";
1182 (*SRC Schalk I, p.66 Nr. 381c *)
1184 "(27*a^^^3+9*a^^^2+3*a+1)/(27*a^^^3+18*a^^^2+3*a)";
1185 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1188 "(1 + 9 * a ^^^ 2) / (3 * a + 9 * a ^^^ 2)"
1190 else error "rational.sml: diff.behav. in norm_Rational_mg 10";
1192 (*SRC Schalk I, p.66 Nr. 383a *)
1194 "(5*a^^^2 - 5*a*b)/(a - b)^^^2";
1195 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1198 "5 * a / (a + -1 * b)"
1200 else error "rational.sml: diff.behav. in norm_Rational_mg 11";
1203 "-------- common denominator ----------------------------";
1204 "-------- common denominator ----------------------------";
1205 "-------- common denominator ----------------------------";
1206 (*SRA Schalk I, p.67 Nr. 403a *)
1209 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1212 "(-3 * x + 4 * y + -1 * x * y) / (x * y)"
1214 else error "rational.sml: diff.behav. in norm_Rational_mg 12";
1216 (*SRA Schalk I, p.67 Nr. 407b *)
1218 "(2*a+3*b)/(b*c) + (3*c+a)/(a*c) - (2*a^^^2+3*b*c)/(a*b*c)";
1219 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1224 else error "rational.sml: diff.behav. in norm_Rational_mg 13";
1226 (*SRA Schalk I, p.67 Nr. 410b *)
1228 "1/(x+1) + 1/(x+2) - 2/(x+3)";
1229 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1232 "(5 + 3 * x) / (6 + 11 * x + 6 * x ^^^ 2 + x ^^^ 3)"
1234 else error "rational.sml: diff.behav. in norm_Rational_mg 14";
1236 (*SRA Schalk I, p.67 Nr. 413b *)
1238 "(1+x)/(1 - x) - (1 - x)/(1+x) + 2*x/(1 - x^^^2)";
1239 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1242 "6 * x / (1 + -1 * x ^^^ 2)"
1244 else error "rational.sml: diff.behav. in norm_Rational_mg 15";
1246 (*SRA Schalk I, p.68 Nr. 414a *)
1248 "(x + 2)/(x - 1) + (x - 3)/(x - 2) - (x + 1)/((x - 1)*(x - 2))";
1249 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1252 "(-2 + -5 * x + 2 * x ^^^ 2) / (2 + -3 * x + x ^^^ 2)"
1254 else error "rational.sml: diff.behav. in norm_Rational_mg 16";
1256 (*SRA Schalk I, p.68 Nr. 423a *)
1258 "(2*x+3*y)/x + (4*x^^^3 - x*y^^^2 - 3*y^^^3)/(x^^^3 - 2*x^^^2*y+x*y^^^2) - (5*x+6*y)/(x - y)";
1259 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1264 else error "rational.sml: diff.behav. in norm_Rational_mg 17";
1266 (*SRA Schalk I, p.68 Nr. 428b *)
1268 "1/(a - b)^^^2 + 1/(a+b)^^^2 - 2/(a^^^2 - b^^^2) - 4*(b^^^2 - 1)/(a^^^2 - b^^^2)^^^2";
1269 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1272 "4 / (a ^^^ 4 + -2 * a ^^^ 2 * b ^^^ 2 + b ^^^ 4)"
1274 else error "rational.sml: diff.behav. in norm_Rational_mg 18";
1276 (*SRA Schalk I, p.68 Nr. 430b *)
1278 "a^^^2/(a - 3*b) - 108*a*b^^^3/((a+3*b)*(a^^^2 - 9*b^^^2)) - 9*b^^^2*(a - 3*b)/(a+3*b)^^^2";
1279 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1284 else error "rational.sml: diff.behav. in norm_Rational_mg 19";
1287 (*SRA Schalk I, p.68 Nr. 432 *)
1289 "(a^^^2+a*b)/(a^^^2 - b^^^2) - (b^^^2 - a*b)/(b^^^2 - a^^^2) + a^^^2*(a - b)/(a^^^3 - a^^^2*b) - 2*a*(a^^^2 - b^^^2)/(a^^^3 - a*b^^^2) - 2*b^^^2/(a^^^2 - b^^^2)";
1290 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1295 else error "rational.sml: diff.behav. in norm_Rational_mg 20";
1300 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1303 "(3 * y + b * x) / (b * y)"
1305 else error "rational.sml: diff.behav. in norm_Rational_mg 21";
1308 "-------- multiply and cancel ---------------------------";
1309 "-------- multiply and cancel ---------------------------";
1310 "-------- multiply and cancel ---------------------------";
1311 (*SRM Schalk I, p.68 Nr. 436a *)
1313 "3*(x+y)/(15*(x - y)) * 25*(x - y)^^^2/(18*(x+y)^^^2)";
1314 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1317 "(5 * x + -5 * y) / (18 * x + 18 * y)"
1319 else error "rational.sml: diff.behav. in norm_Rational_mg 22";
1321 (*SRM.test Schalk I, p.68 Nr. 436b *)
1322 (*WN060420???MG3 crashes with method 'simplify' in
1323 IsacCore > Simplification > Rational Terms > Multiplication > No.2*)
1324 val t = str2term "5*a*(a - b)^^^2*(a + b)^^^3/(7*b*(a - b)^^^3) * 7*b/(a + b)^^^3";
1325 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1328 "5 * a / (a + -1 * b)"
1330 else error "rational.sml: diff.behav. in norm_Rational_mg 23";
1332 (*Schalk I, p.68 Nr. 437a *)
1333 val t = str2term "(3*a - 4*b)/(4*c+3*e) * (3*a+4*b)/(9*a^^^2 - 16*b^^^2)";
1334 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1335 if (term2str t) = "1 / (4 * c + 3 * e)" then ()
1336 else error "rational.sml: diff.behav. in norm_Rational_mg 24";
1338 "----- S.K. corrected non-termination 060904";
1339 val t = str2term "(3*a - 4*b) * (3*a+4*b)/((4*c+3*e)*(9*a^^^2 - 16*b^^^2))";
1340 val SOME (t',_) = rewrite_set_ thy false make_polynomial t;
1343 "(9 * a ^^^ 2 + -16 * b ^^^ 2) /\n(36 * a ^^^ 2 * c + 27 * a ^^^ 2 * e + -64 * b ^^^ 2 * c +\n -48 * b ^^^ 2 * e)"
1344 (*"(9 * a ^^^ 2 + -16 * b ^^^ 2) / (36 * a ^^^ 2 * c + 27 * a ^^^ 2 * e + -64 * b ^^^ 2 * c + -48 * b ^^^ 2 * e)"*)
1345 then () else error "rational.sml: S.K.8..corrected 060904-6";
1347 "----- S.K. corrected non-termination of cancel_p_";
1348 val t'' = str2term ("(9 * a ^^^ 2 + -16 * b ^^^ 2) /" ^
1349 "(36 * a^^^2 * c + (27 * a^^^2 * e + (-64 * b^^^2 * c + -48 * b^^^2 * e)))");
1350 val SOME (t',_) = rewrite_set_ thy false cancel_p t'';
1351 if term2str t' = "1 / (4 * c + 3 * e)" then ()
1352 else error "rational.sml: diff.behav. in cancel_p S.K.8";
1354 (*Schalk I, p.68 Nr. 437b *)
1355 (* nonterm.SK9 loops: cancel_p kann nicht weiter kuerzen!!! *)
1356 val t'' = str2term "(a + b)/(x^^^2 - y^^^2) * ((x - y)^^^2/(a^^^2 - b^^^2))";
1357 (* val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t'';
1360 "================delete===";
1361 (*a casual output from above*)
1363 "(a * x ^^^ 2 + -2 * a * x * y + a * y ^^^ 2 + b * x ^^^ 2 + -2 * b * x * y + b * y ^^^ 2) /(a ^^^ 2 * x ^^^ 2 + -1 * a ^^^ 2 * y ^^^ 2 + -1 * b ^^^ 2 * x ^^^ 2 + b ^^^ 2 * y ^^^ 2)";
1364 (* WN060831 nonterm.SK10
1365 val SOME (t,_) = rewrite_set_ thy false cancel_p t;
1369 (*SRM Schalk I, p.68 Nr. 438a *)
1371 "x*y/(x*y - y^^^2)*(x^^^2 - x*y)";
1372 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1377 else error "rational.sml: diff.behav. in norm_Rational_mg 24";
1379 (*SRM Schalk I, p.68 Nr. 439b *)
1381 "(4*x^^^2+4*x+1)*((x^^^2 - 2*x^^^3)/(4*x^^^2+2*x))";
1382 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1385 "(x + -4 * x ^^^ 3) / 2"
1387 else error "rational.sml: diff.behav. in norm_Rational_mg 25";
1389 (*SRM Schalk I, p.68 Nr. 440a *)
1391 "(x^^^2 - 2*x)/(x^^^2 - 3*x) * (x - 3)^^^2/(x^^^2 - 4)";
1392 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1395 "(-3 + x) / (2 + x)"
1397 else error "rational.sml: diff.behav. in norm_Rational_mg 26";
1399 "----- Schalk I, p.68 Nr. 440b SK11 works since 0707xx";
1401 "(a^^^3 - 9*a)/(a^^^3*b - a*b^^^3)*(a^^^2*b+a*b^^^2)/(a+3)";
1402 val SOME (t,_) = rewrite_set_ thy false norm_Rational t;
1403 if term2str t = "(-3 * a + a ^^^ 2) / (a + -1 * b)" then ()
1404 else error "rational.sml: diff.behav. in norm_Rational 27";
1406 "----- SK12 works since 0707xx";
1407 val t = str2term "(a^^^3 - 9*a)*(a^^^2*b+a*b^^^2)/((a^^^3*b - a*b^^^3)*(a+3))";
1408 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
1409 if term2str t' = "(-3 * a + a ^^^ 2) / (a + -1 * b)" then ()
1410 else error "rational.sml: diff.behav. in norm_Rational 28";
1413 "-------- common denominator and multiplication ---------";
1414 "-------- common denominator and multiplication ---------";
1415 "-------- common denominator and multiplication ---------";
1416 (*SRAM Schalk I, p.69 Nr. 441b *)
1417 val t = str2term "(4*a/3 + 3*b^^^2/a^^^3 + b/(4*a))*(4*b/(3*a))";
1418 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1421 "(36 * b ^^^ 3 + 3 * a ^^^ 2 * b ^^^ 2 + 16 * a ^^^ 4 * b) / (9 * a ^^^ 4)"
1422 then () else error "rational.sml: diff.behav. in norm_Rational_mg 28";
1424 (*SRAM Schalk I, p.69 Nr. 442b *)
1425 val t = str2term "(15*a^^^2/x^^^3 - 5*b^^^4/x^^^2 + 25*c^^^2/x)*(x^^^3/(5*a*b^^^3*c^^^3)) + 1/c^^^3 * (b*x/a - 3*a/b^^^3)";
1426 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1429 "5 * x ^^^ 2 / (a * b ^^^ 3 * c)"
1430 then () else error "rational.sml: diff.behav. in norm_Rational_mg 29";
1432 (*SRAM Schalk I, p.69 Nr. 443b *)
1433 val t = str2term "(a/2 + b/3)*(b/3 - a/2)";
1434 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1437 "(-9 * a ^^^ 2 + 4 * b ^^^ 2) / 36"
1438 then () else error "rational.sml: diff.behav. in norm_Rational_mg 30";
1440 (*SRAM Schalk I, p.69 Nr. 445b *)
1441 val t = str2term "(a^^^2/9 + 2*a/(3*b) + 4/b^^^2)*(a/3 - 2/b) + 8/b^^^3";
1442 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1446 then () else error "rational.sml: diff.behav. in norm_Rational_mg 31";
1448 (*SRAM Schalk I, p.69 Nr. 446b *)
1449 val t = str2term "(x/(5*x + 4*y) - y/(5*x - 4*y) + 1)*(25*x^^^2 - 16*y^^^2)";
1450 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1453 "30 * x ^^^ 2 + -9 * x * y + -20 * y ^^^ 2"
1455 else error "rational.sml: diff.behav. in norm_Rational_mg 32";
1457 (*SRAM Schalk I, p.69 Nr. 449a *)(*Achtung: rechnet ca 8 Sekunden*)
1459 "(2*x^^^2/(3*y)+x/y^^^2)*(4*x^^^4/(9*y^^^2)+x^^^2/y^^^4)*(2*x^^^2/(3*y) - x/y^^^2)";
1460 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1462 if (term2str t) = "(-81 * x ^^^ 4 + 16 * x ^^^ 8 * y ^^^ 4) / (81 * y ^^^ 8)"
1463 then () else error "rational.sml: diff.behav. in norm_Rational_mg 33";
1466 (*SRAM Schalk I, p.69 Nr. 450a *)
1468 "(4*x/(3*y)+2*y/(3*x))^^^2 - (2*y/(3*x) - 2*x/y)*(2*y/(3*x)+2*x/y)";
1469 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1472 "(52 * x ^^^ 2 + 16 * y ^^^ 2) / (9 * y ^^^ 2)"
1474 else error "rational.sml: diff.behav. in norm_Rational_mg 34";
1477 "-------- double fractions ------------------------------";
1478 "-------- double fractions ------------------------------";
1479 "-------- double fractions ------------------------------";
1480 (*SRD Schalk I, p.69 Nr. 454b *)
1482 "((2 - x)/(2*a)) / (2*a/(x - 2))";
1483 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1486 "(-4 + 4 * x + -1 * x ^^^ 2) / (4 * a ^^^ 2)"
1488 else error "rational.sml: diff.behav. in norm_Rational_mg 35";
1490 (*SRD Schalk I, p.69 Nr. 455a *)
1492 "(a^^^2 + 1)/(a^^^2 - 1) / ((a+1)/(a - 1))";
1493 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1496 "(1 + a ^^^ 2) / (1 + 2 * a + a ^^^ 2)" then ()
1497 else error "rational.sml: diff.behav. in norm_Rational_mg 36";
1500 "----- Schalk I, p.69 Nr. 455b";
1501 val t = str2term "(x^^^2 - 4)/(y^^^2 - 9)/((2+x)/(3 - y))";
1502 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1503 if term2str t = "(2 + -1 * x) / (3 + y)" then ()
1504 else error "rational.sml: diff.behav. in norm_Rational_mg 37";
1506 "----- SK060904-1a non-termination of cancel_p_ ?: worked before 0707xx";
1507 val t = str2term "(x^^^2 - 4)*(3 - y)/((y^^^2 - 9)*(2+x))";
1508 val SOME (t,_) = rewrite_set_ thy false norm_Rational t;
1509 if term2str t = "(2 + -1 * x) / (3 + y)" then ()
1510 else error "rational.sml: diff.behav. in norm_Rational_mg 37b";
1512 "----- ?: worked before 0707xx";
1513 val t = str2term "(3 + -1 * y) / (-9 + y ^^^ 2)";
1514 val SOME (t,_) = rewrite_set_ thy false norm_Rational t;
1515 if term2str t = "-1 / (3 + y)" then ()
1516 else error "rational.sml: -1 / (3 + y) norm_Rational";
1518 (*SRD Schalk I, p.69 Nr. 456b *)
1520 "(b^^^3 - b^^^2)/(b^^^2+b)/(b^^^2 - 1)";
1521 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1523 if (term2str t) = "b / (1 + 2 * b + b ^^^ 2)" then ()
1524 else error "rational.sml: diff.behav. in norm_Rational_mg 38";
1526 (*SRD Schalk I, p.69 Nr. 457b *)
1528 "(16*a^^^2 - 9*b^^^2)/(2*a+3*a*b) / ((4*a+3*b)/(4*a^^^2 - 9*a^^^2*b^^^2))";
1529 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1532 "8 * a ^^^ 2 + -6 * a * b + -12 * a ^^^ 2 * b + 9 * a * b ^^^ 2"
1533 then () else error "rational.sml: diff.behav. in norm_Rational_mg 39";
1535 "----- Schalk I, p.69 Nr. 458b works since 0707";
1537 "(2*a^^^2*x - a^^^2)/(a*x - b*x) / (b^^^2*(2*x - 1)/(x*(a - b)))";
1538 val SOME (t,_) = rewrite_set_ thy false norm_Rational t;
1539 if term2str t = "a ^^^ 2 / b ^^^ 2" then ()
1540 else error "rational.sml: diff.behav. in norm_Rational_mg 39b";
1542 (*SRD Schalk I, p.69 Nr. 459b *)
1543 val t = str2term "(a^^^2 - b^^^2)/(a*b) / (4*(a+b)^^^2/a)";
1544 val SOME (t,_) = rewrite_set_ thy false norm_Rational t;
1545 if term2str t = "(a + -1 * b) / (4 * a * b + 4 * b ^^^ 2)" then ()
1546 else error "rational.sml: diff.behav. in norm_Rational_mg 41";
1549 (*Schalk I, p.69 Nr. 460b nonterm.SK
1551 "(9*(x^^^2 - 8*x+16)/(4*(y^^^2 - 2*y+1)))/((3*x - 12)/(16*y - 16))";
1552 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1555 else error "rational.sml: diff.behav. in norm_Rational_mg 42";
1558 "9*(x^^^2 - 8*x+16)*(16*y - 16)/(4*(y^^^2 - 2*y+1)*(3*x - 12))";
1559 val SOME (t',_) = rewrite_set_ thy false norm_Rational t;
1560 ... non terminating.
1561 val SOME (t',_) = rewrite_set_ thy false make_polynomial t;
1562 "(-2304 + 1152 * x + 2304 * y + -144 * x ^^^ 2 + -1152 * x * y + 144 * x ^^^ 2 * y) /(-48 + 12 * x + 96 * y + -24 * x * y + -48 * y ^^^ 2 + 12 * x * y ^^^ 2)";
1563 val SOME (t,_) = rewrite_set_ thy false cancel_p t';
1564 ... non terminating.*)
1566 (*SRD Schalk I, p.70 Nr. 472a *)
1567 val t = str2term ("((8*x^^^2 - 32*y^^^2)/(2*x + 4*y))/" ^
1568 "((4*x - 8*y)/(x + y))");
1569 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1574 else error "rational.sml: diff.behav. in norm_Rational_mg 43";
1577 (*----------------------------------------------------------------------*)
1578 (*---------------------- Einfache Dppelbrche --------------------------*)
1579 (*----------------------------------------------------------------------*)
1581 (*SRD Schalk I, p.69 Nr. 461a *)
1583 "(2/(x+3) + 2/(x - 3)) / (8*x/(x^^^2 - 9))";
1584 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1589 else error "rational.sml: diff.behav. in norm_Rational_mg 44";
1591 (*SRD Schalk I, p.69 Nr. 464b *)
1593 "(a - a/(a - 2)) / (a + a/(a - 2))";
1594 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1597 "(3 + -1 * a) / (1 + -1 * a)"
1599 else error "rational.sml: diff.behav. in norm_Rational_mg 45";
1601 (*SRD Schalk I, p.69 Nr. 465b *)
1603 "((x+3*y)/9 + (4*y^^^2 - 9*z^^^2)/(16*x)) /(x/9+y/6+z/4)";
1604 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1607 "(4 * x + 6 * y + -9 * z) / (4 * x)"
1609 else error "rational.sml: diff.behav. in norm_Rational_mg 46";
1611 (*SRD Schalk I, p.69 Nr. 466b *)
1613 "((1 - 7*(x - 2)/(x^^^2 - 4)) / (6/(x+2))) / (3/(x+5)+30/(x^^^2 - 25))";
1614 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1617 "(25 + -10 * x + x ^^^ 2) / 18"
1619 else error "rational.sml: diff.behav. in norm_Rational_mg 47";
1621 (*SRD Schalk I, p.70 Nr. 469 *)
1623 "3*b^^^2/(4*a^^^2 - 8*a*b + 4*b^^^2)/(a/(a^^^2*b - b^^^3) + (a - b)/(4*a*b^^^2+4*b^^^3) - 1/(4*b^^^2))";
1624 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1627 "3 * b ^^^ 3 / (2 * a + -2 * b)"
1629 else error "rational.sml: diff.behav. in norm_Rational_mg 48";
1631 (*----------------------------------------------------------------------*)
1632 (*---------------------- Mehrfache Dppelbrueche ------------------------*)
1633 (*----------------------------------------------------------------------*)
1635 (*SRD.test Schalk I, p.70 Nr. 476b *) (* Rechenzeit: 10 sec *)
1636 (*WN060419 crashes with method 'simplify' ????SK*)
1638 "((a^^^2 - b^^^2)/(2*a*b)+2*a*b/(a^^^2 - b^^^2))/((a^^^2+b^^^2)/(2*a*b)+1) / ((a^^^2+b^^^2)^^^2/(a+b)^^^2)";
1639 val SOME (t,_) = rewrite_set_ thy false norm_Rational t;
1640 if term2str t = "1 / (a ^^^ 2 + -1 * b ^^^ 2)" then ()
1641 else error "rational.sml: diff.behav. in norm_Rational_mg 49";
1643 "----- Schalk I, p.70 Nr. 477a";
1644 (* MG Achtung: terme explodieren; Bsp zu komplex;
1645 L???ung sollte (ziemlich grosser) Faktorisierter Ausdruck sein
1646 val t = str2term "b*y/(b - 2*y)/((b^^^2 - y^^^2)/(b+2*y)) /" ^
1647 "(b^^^2*y+b*y^^^2)*(a+x)^^^2/((b^^^2 - 4*y^^^2)*(a+2*x)^^^2)";
1648 val SOME (t',_) = rewrite_set_ thy false norm_Rational t;
1651 val t = str2term "b*y*(b+2*y)*(b^^^2 - 4*y^^^2)*(a+2*x)^^^2 / " ^
1652 "((b - 2*y)*(b^^^2 - y^^^2)*(b^^^2*y+b*y^^^2)*(a+x)^^^2)";
1653 val SOME (t,_) = rewrite_set_ thy false make_polynomial t;
1657 "----- Schalk I, p.70 Nr. 478b ----- Rechenzeit: 5 sec";
1658 val t = str2term ("(a - (a*b+b^^^2)/(a+b))/(b+(a - b)/(1+(a+b)/(a - b))) / " ^
1659 "((a - a^^^2/(a+b))/(a+(a*b)/(a - b)))");
1660 val SOME (t',_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1662 "(2 * a ^^^ 3 + 2 * a ^^^ 2 * b) / (a ^^^ 2 * b + b ^^^ 3)"
1664 else error "rational.sml: diff.behav. in norm_Rational_mg 51";
1666 (* TODO.new_c:WN050820 STOP_REW_SUB introduced gave ...
1667 if term2str t' = "(a ^^^ 4 + -1 * a ^^^ 2 * b ^^^ 2) /(a * b * (b + (a * (a + -1 * b) + -1 * b * (a + -1 * b)) / (2 * a)) * (a + -1 * b))" then ()
1668 else error "rational.sml: works again";
1669 re-outcommented with TODO.new_c: cvs before 071227, 11:50*)
1673 (*Schalk I, p.70 Nr. 480a *)
1674 (* Achtung: rechnet ewig; cancel_p kann nicht krzen: WN060831 nonterm.SK00
1676 "(1/x+1/y+1/z)/(1/x - 1/y - 1/z) / (2*x^^^2/(x^^^2 - z^^^2)/(x/(x+z)+x/(x - z)))";
1677 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1682 else error "rational.sml: diff.behav. in norm_Rational_mg 52";
1684 (*MG Berechne Zwischenergebnisse: WN060831 nonterm.SK00*)
1686 "(1/x+1/y+1/z)/(1/x - 1/y - 1/z)";
1687 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1689 "(x ^^^ 2 * y ^^^ 2 * z + x ^^^ 2 * y * z ^^^ 2 + x * y ^^^ 2 * z ^^^ 2) /
1690 (-1 * x ^^^ 2 * y ^^^ 2 * z + -1 * x ^^^ 2 * y * z ^^^ 2 + x * y ^^^ 2 * z ^^^ 2)";
1692 "2*x^^^2/(x^^^2 - z^^^2)/(x/(x+z)+x/(x - z))";
1693 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1697 (* SK 1. Ausdruck kann nicht weiter gekrzt werden; cancel_p !!!*)
1698 ### rls: cancel_p on:
1699 (x ^^^ 2 * (y ^^^ 2 * z) + x ^^^ 2 * (y * z ^^^ 2) + x * (y ^^^ 2 * z ^^^ 2)) /
1700 (-1 * (x ^^^ 2 * (y ^^^ 2 * z)) + -1 * (x ^^^ 2 * (y * z ^^^ 2)) + x * (y ^^^ 2 * z ^^^ 2))
1701 GC #3.61.81.101.197.17503: (0 ms)
1702 *** RATIONALS_DIRECT_CANCEL_EXCEPTION: Invalid fraction
1705 "(x^^^2 * (y^^^2 * z) + x^^^2 * (y * z^^^2) + x * (y^^^2 * z^^^2)) / (-1 * (x^^^2 * (y^^^2 * z)) + -1 * (x^^^2 * (y * z^^^2)) + x * (y^^^2 * z^^^2))";
1706 val SOME (t,_) = rewrite_set_ thy false cancel_p t;
1708 (*uncaught exception nonexhaustive binding failure*)
1710 (* Das kann er aber krzen !!????: *)
1712 "(x^^^2 * (y^^^2 * z) + x * (y^^^2 * z^^^2)) / (-1 * (x^^^2 * (y * z^^^2)) + x * (y^^^2 * z^^^2))";
1713 val SOME (t,_) = rewrite_set_ thy false cancel_p t;
1715 "(-1 * (y * x) + -1 * (z * y)) / (1 * (z * x) + -1 * (z * y))";
1719 "-------- crucial examples ------------------------------";
1720 "-------- crucial examples ------------------------------";
1721 "-------- crucial examples ------------------------------";
1722 (*Schalk I, p.60 Nr. 215d *)
1723 (* Achtung: rechnet ewig ...
1724 val t = str2term "(a-b)^^^3 * (x+y)^^^4 / ((x+y)^^^2 * (a-b)^^^5)";
1725 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1726 term2str t; noterm.SK
1729 (* Kein Wunder, denn Z???ler und Nenner extra als Polynom dargestellt ergibt:*)
1731 val t = str2term "(a-b)^^^3 * (x+y)^^^4";
1732 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1734 "a^^^3 * x^^^4 + 4 * a^^^3 * x^^^3 * y +6 * a^^^3 * x^^^2 * y^^^2 +4 * a^^^3 * x * y^^^3 +a^^^3 * y^^^4 +-3 * a^^^2 * b * x^^^4 +-12 * a^^^2 * b * x^^^3 * y +-18 * a^^^2 * b * x^^^2 * y^^^2 +-12 * a^^^2 * b * x * y^^^3 +-3 * a^^^2 * b * y^^^4 +3 * a * b^^^2 * x^^^4 +12 * a * b^^^2 * x^^^3 * y +18 * a * b^^^2 * x^^^2 * y^^^2 +12 * a * b^^^2 * x * y^^^3 +3 * a * b^^^2 * y^^^4 +-1 * b^^^3 * x^^^4 +-4 * b^^^3 * x^^^3 * y +-6 * b^^^3 * x^^^2 * y^^^2 +-4 * b^^^3 * x * y^^^3 +-1 * b^^^3 * y^^^4";
1735 val t = str2term "((x+y)^^^2 * (a-b)^^^5)";
1736 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1738 "a^^^5 * x^^^2 + 2 * a^^^5 * x * y + a^^^5 * y^^^2 +-5 * a^^^4 * b * x^^^2 +-10 * a^^^4 * b * x * y +-5 * a^^^4 * b * y^^^2 +10 * a^^^3 * b^^^2 * x^^^2 +20 * a^^^3 * b^^^2 * x * y +10 * a^^^3 * b^^^2 * y^^^2 +-10 * a^^^2 * b^^^3 * x^^^2 +-20 * a^^^2 * b^^^3 * x * y +-10 * a^^^2 * b^^^3 * y^^^2 +5 * a * b^^^4 * x^^^2 +10 * a * b^^^4 * x * y +5 * a * b^^^4 * y^^^2 +-1 * b^^^5 * x^^^2 +-2 * b^^^5 * x * y +-1 * b^^^5 * y^^^2";
1740 (*anscheinend macht dem Rechner das Krzen diese Bruches keinen Spass mehr ...*)
1742 (*--------------------------------------------------------------------*)
1743 (*Schalk I, p.70 Nr. 480b
1744 val t = str2term "((12*x*y/(9*x^^^2 - y^^^2))/" ^
1745 "(1/(3*x - y)^^^2 - 1/(3*x + y)^^^2)) *" ^
1746 "(1/(x - 5*y)^^^2 - 1/(x + 5*y)^^^2)/" ^
1747 "(20*x*y/(x^^^2 - 25*y^^^2))";
1748 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1750 Kann nicht weiter vereinfacht werden !!!!?? *)
1752 (*--------------------------------------------------------------------*)
1753 "---- MGs test set";
1754 val t = str2term " (1 + x^^^5) / (y + x) + x^^^3 / x ";
1755 val SOME (t,_) = rewrite_set_ thy false common_nominator_p t;
1756 if term2str t = "(1 + x ^^^ 3 + x ^^^ 5 + y * x ^^^ 2) / (x + y)" then()
1759 (*--------------------------------------------------------------------*)
1760 (* cancel_p liefert nicht immer Polynomnormalform (2): WN060831???SK3b
1761 ---> Sortierung FALSCH !! *)
1762 val t = str2term "b^^^3 * a^^^5/a ";
1763 val SOME (t,_) = rewrite_set_ thy false cancel_p t;
1765 "1 * (a^^^4 * b^^^3) / 1"; (*OK*)
1767 val t = str2term "b^^^3 * a^^^5/b ";
1768 val SOME (t,_) = rewrite_set_ thy false cancel_p t;
1770 "1 * (b^^^2 * a^^^5) / 1"; (*cancel_p sortiert hier falsch um!*)
1772 (* Problem liegt NICHT bei ord_make_polynomial! (siehe folgende Bsple) *)
1774 val x = str2term "x"; val bdv = str2term "bdv";
1775 val t1 = str2term "b^^^2 * a^^^5";
1776 val t2 = str2term "a^^^5 * b^^^2 ";
1777 ord_make_polynomial false Rational.thy [(x,bdv)] (t1,t2); (*false*)
1779 (* ==> "b^^^2 * a^^^5" > "a^^^5 * b^^^2 " ... OK!*)
1781 (*--------------------------------------------------------------------*)
1782 (* cancel_p liefert nicht immer Polynomnormalform (2): WN060831???SK3c
1783 ---> erzeugt berflssige "1 * ..."
1785 val t = str2term "-1 / (3 + y)";
1787 val SOME (t,_) = rewrite_set_ thy false cancel_p t;
1790 (********* Das ist das PROBLEM !!!!!!!??? *******************)
1791 (* -1 im Z???ler der Angabe verursacht das Problem !*)
1794 (* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *)
1795 "----- MGs test set";
1796 val t = str2term "(a^^^2 + -1)/(a+1)";
1797 val SOME (t',_) = rewrite_set_ thy false cancel_p t;
1798 if term2str t' = "(-1 + a) / 1" then ()
1799 else error "rational.sml MG tests 3d";
1801 "----- NOT TERMINATING ?: worked before 0707xx";
1802 val t = str2term "(a^^^2 - 1)*(b + 1) / ((b^^^2 - 1)*(a+1))";
1803 val SOME (t'',_) = rewrite_set_ thy false norm_Rational t;
1804 if term2str t'' = "(1 + -1 * a) / (1 + -1 * b)" then ()
1805 else error "rational.sml MG tests 3e";
1807 "----- corrected SK060905";
1808 val t = str2term "(4*x^^^2 - 20*x + 25)/(2*x - 5)^^^3";
1809 val SOME (t',_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1810 if term2str t' = "-1 / (5 + -2 * x)" then ()
1811 else error "rational.sml corrected SK060905";
1814 "-------- examples for Stefan Karnels thesis ------------";
1815 "-------- examples for Stefan Karnels thesis ------------";
1816 "-------- examples for Stefan Karnels thesis ------------";
1817 (*SRAM Schalk I, p.69 Nr. 442b --- abgewandelt*)
1819 "(15*a^^^4/(a*x^^^3) - 5*a*((b^^^4 - 5*c^^^2*x)/x^^^2))*(x^^^3/(5*a*b^^^3*c^^^3)) + a/c^^^3 * (x*(b/a) - 3*b*(a/b^^^4))";
1820 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1823 "5 * x ^^^ 2 / (b ^^^ 3 * c)"
1825 else error "rational.sml: diff.behav. in norm_Rational_mg 53";
1828 "-------- me Schalk I No.186 ----------------------------";
1829 "-------- me Schalk I No.186 ----------------------------";
1830 "-------- me Schalk I No.186 ----------------------------";
1831 val fmz = ["Term ((14 * x * y) / ( x * y ))",
1834 ("Rational",["rational","simplification"],
1835 ["simplification","of_rationals"]);
1836 val p = e_pos'; val c = [];
1837 val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
1838 val (p,_,f,nxt,_,pt) = me nxt p c pt;
1839 val (p,_,f,nxt,_,pt) = me nxt p c pt;
1840 val (p,_,f,nxt,_,pt) = me nxt p c pt;
1841 val (p,_,f,nxt,_,pt) = me nxt p c pt;
1842 val (p,_,f,nxt,_,pt) = me nxt p c pt;
1843 val (p,_,f,nxt,_,pt) = me nxt p c pt;
1844 val (p,_,f,nxt,_,pt) = me nxt p c pt;
1845 val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
1846 val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
1847 val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;(*++ for explicit script*)
1848 val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;(*++ for explicit script*)
1849 case (f2str f, nxt) of
1850 ("14", ("End_Proof'", _)) => ()
1851 | _ => error "rational.sml diff.behav. in me Schalk I No.186";
1854 "-------- interSteps ..Simp_Rat_Double_No-1.xml ---------";
1855 "-------- interSteps ..Simp_Rat_Double_No-1.xml ---------";
1856 "-------- interSteps ..Simp_Rat_Double_No-1.xml ---------";
1859 [(["Term (((2 - x)/(2*a)) / (2*a/(x - 2)))", "normalform N"],
1860 ("Rational",["rational","simplification"],
1861 ["simplification","of_rationals"]))];
1864 autoCalculate 1 CompleteCalc;
1865 val ((pt,p),_) = get_calc 1; show_pt pt;
1867 interSteps 1 ([1],Res);
1868 val ((pt,p),_) = get_calc 1; show_pt pt;
1871 "-------- interSteps ..Simp_Rat_Cancel_No-1.xml ---------";
1872 "-------- interSteps ..Simp_Rat_Cancel_No-1.xml ---------";
1873 "-------- interSteps ..Simp_Rat_Cancel_No-1.xml ---------";
1876 [(["Term ((a^2 + -1*b^2) / (a^2 + -2*a*b + b^2))", "normalform N"],
1877 ("Rational",["rational","simplification"],
1878 ["simplification","of_rationals"]))];
1881 autoCalculate 1 CompleteCalc;
1882 val ((pt,p),_) = get_calc 1; show_pt pt;
1883 (*========== inhibit exn 110314 ================================================
1884 (*with explicit script done already... and removed [1,..] at below...
1885 interSteps 1 ([1],Res);
1886 val ((pt,p),_) = get_calc 1; show_pt pt;
1888 interSteps 1 ([2],Res);
1889 val ((pt,p),_) = get_calc 1; show_pt pt;
1891 interSteps 1 ([2,1],Res);
1892 val ((pt,p),_) = get_calc 1; show_pt pt;
1893 val newnds = children (get_nd pt [2,1]) (*see "fun detailrls"*);
1894 (*if length newnds = 12 then () WN060905*)
1895 if length newnds = 13 then ()
1896 else error "rational.sml: interSteps cancel_p rev_rew_p";
1898 val p = ([2,1,9],Res);
1900 val (_, tac, _) = pt_extract (pt, p);
1901 (*case tac of SOME (Rewrite ("sym_real_plus_binom_times1", _)) => ()
1903 case tac of SOME (Rewrite ("sym_real_add_mult_distrib2", _)) => ()
1904 | _ => error "rational.sml: getTactic, sym_real_plus_binom_times1";
1905 ============ inhibit exn 110314 ==============================================*)
1908 "-------- investigate rulesets for cancel_p -------------";
1909 "-------- investigate rulesets for cancel_p -------------";
1910 "-------- investigate rulesets for cancel_p -------------";
1911 val thy = @{theory "Rational"};
1912 "---------------- (a^^^2 + -1*b^^^2) / (a^^^2 + -2*a*b + b^^^2)";
1913 val t = str2term "(a^^^2 + -1*b^^^2) / (a^^^2 + -2*a*b + b^^^2)";
1914 val tt = str2term "(1 * a + 1 * b) * (1 * a + -1 * b)"(*numerator only*);
1915 "----- with rewrite_set_";
1916 val SOME (tt',asm) = rewrite_set_ thy false make_polynomial tt;
1917 term2str tt'= "a ^^^ 2 + -1 * b ^^^ 2" (*true*);
1918 val tt = str2term "((1 * a + -1 * b) * (1 * a + -1 * b))"(*denominator only*);
1919 val SOME (tt',asm) = rewrite_set_ thy false make_polynomial tt;
1920 term2str tt' = "a ^^^ 2 + -2 * a * b + b ^^^ 2" (*true*);
1922 "----- with make_deriv";
1923 val SOME (tt, _) = factout_p_ thy t; term2str tt =
1924 "(1 * a + 1 * b) * (1 * a + -1 * b) / ((1 * a + -1 * b) * (1 * a + -1 * b))";
1926 "--- with ruleset as before 060829";
1927 val {rules, rew_ord=(_,ro),...} =
1928 rep_rls (assoc_rls "make_polynomial");
1929 val der = make_deriv thy Atools_erls rules ro NONE tt;
1930 print_depth 99; map (term2str o #1) der; print_depth 3;
1931 print_depth 99; map (rule2str o #2) der; print_depth 3;
1932 ... did not terminate*)
1933 "--- with simpler ruleset";
1934 val {rules, rew_ord=(_,ro),...} =
1935 rep_rls (assoc_rls "rev_rew_p");
1936 val der = make_deriv thy Atools_erls rules ro NONE tt;
1937 print_depth 99; writeln (deriv2str der); print_depth 3;
1939 print_depth 99; map (term2str o #1) der; print_depth 3;
1940 "...,(-1 * b ^^^ 2 + a ^^^ 2) / (-2 * (a * b) + a ^^^ 2 + (-1 * b) ^^^ 2) ]";
1941 print_depth 99; map (rule2str o #2) der; print_depth 3;
1942 print_depth 99; map (term2str o #1 o #3) der; print_depth 3;
1944 val der = make_deriv thy Atools_erls rules ro NONE
1945 (str2term "(1 * a + 1 * b) * (1 * a + -1 * b)");
1946 print_depth 99; writeln (deriv2str der); print_depth 3;
1948 val {rules, rew_ord=(_,ro),...} =
1949 rep_rls (assoc_rls "rev_rew_p");
1950 val der = make_deriv thy Atools_erls rules ro NONE
1951 (str2term "(1 * a + -1 * b) * (1 * a + -1 * b)");
1952 print_depth 99; writeln (deriv2str der); print_depth 3;
1953 print_depth 99; map (term2str o #1) der; print_depth 3;
1954 (*WN060829 ...postponed*)
1957 "-------- investigate format of factout_ and factout_p_ -";
1958 "-------- investigate format of factout_ and factout_p_ -";
1959 "-------- investigate format of factout_ and factout_p_ -";
1960 val {rules, rew_ord = (_,ro),...} = rep_rls (assoc_rls "make_polynomial");
1961 val (thy, eval_rls) = (@{theory "Rational"}, Atools_erls)(*see 'fun init_state'*);
1962 val Rrls {scr = Rfuns {init_state,...},...} = assoc_rls "cancel_p";
1964 "----- see Rational.ML, local cancel_p, fun init_state";
1965 val t = str2term "(a^^^2 + (-1)*b^^^2) / (a^^^2 + (-2)*a*b + b^^^2)";
1966 val SOME (t',_) = factout_p_ thy t; term2str t';
1968 val rtas = reverse_deriv thy eval_rls rules ro NONE t';
1969 writeln(trtas2str rst);
1973 "----- see Rational.ML, local cancel_p, fun init_state";
1974 val t = str2term "a^^^2 / a";
1975 val SOME (t',_) = factout_p_ thy t;
1976 term2str t' = "a * a / (1 * a)" (*true*);
1977 (*... can be canceled with
1978 real_mult_div_cancel2 ?k ~= 0 ==> ?m * ?k / (?n * ?k) = ?m / ?n"*)
1979 (* sml/ME/rewtools.sml:
1980 val rtas = reverse_deriv thy Atools_erls rules ro NONE t';
1981 writeln (deri2str rtas);
1985 "-------- SK 060904 ----------------------------------------------";
1986 "----- order on polynomials -- input + output";
1987 val thy = @{theory "Isac"};
1988 val t = str2term "(a + -1 * b) / (-1 * a + b)";
1989 val SOME (t', _) = factout_p_ thy t; term2str t';
1990 val SOME (t', _) = cancel_p_ thy t; term2str t';
1992 val t = str2term "a*b*c*d / (d*e*f*g)";
1993 val SOME (t', _) = cancel_p_ thy t; term2str t';
1995 val t = str2term "a*(b*(c*d)) / (b*(e*(f*g)))";
1996 val SOME (t', _) = cancel_p_ thy t; term2str t';
1999 "----- SK060904-1a non-termination of cancel_p_ ? worked before 0707xx";
2000 val t = str2term "(x^^^2 - 4)*(3 - y) / ((y^^^2 - 9)*(2+x))";
2001 val SOME (t',_) = rewrite_set_ thy false norm_Rational t;
2002 if term2str t' = "(2 + -1 * x) / (3 + y)" then ()
2003 else error "rational.sml SK060904-1a worked since 0707xx";
2005 "----- SK060904-1b non-termination of cancel_p_ ... worked before 0707xx";
2006 val t = str2term ("(9 * a ^^^ 2 + -16 * b ^^^ 2) /" ^
2007 "(36 * a^^^2 * c + (27 * a^^^2 * e + (-64 * b^^^2 * c + -48 * b^^^2 * e)))");
2008 val SOME (t',_) = cancel_p_ thy t;
2009 if term2str t' = "1 / (4 * c + 3 * e)" then ()
2010 else error "rational.sml SK060904-1b";
2013 "----- SK060904-2a non-termination of add_fraction_p_";
2014 val t = str2term (" (a + b * x) / (a + -1 * (b * x)) + " ^
2015 " (-1 * a + b * x) / (a + b * x) ");
2017 val SOME (t',_) = rewrite_set_ thy false common_nominator_p t;
2019 common_nominator_p_ thy t;
2020 " (a + b * x)*(a + b * x) / ((a + -1 * (b * x))*(a + -1 * (b * x))) + " ^
2021 " (-1 * a + b * x)*(a + -1 * (b * x)) / ((a + b * x)*(-1 * a + b * x)) ";
2023 add_fraction_p_ thy t;
2024 " ((a + b * x)*(a + b * x) + (-1 * a + b * x)*(a + -1 * (b * x))) /" ^
2025 " ((a + b * x)*(-1 * a + b * x)) ";
2029 "-------- how to stepwise construct Scripts -------------";
2030 "-------- how to stepwise construct Scripts -------------";
2031 "-------- how to stepwise construct Scripts -------------";
2032 val thy = @{theory "Rational"};
2034 val p1 = parse thy (
2035 "Script SimplifyScript (t_t::real) = " ^
2036 " (Rewrite_Set discard_minus False " ^
2039 (*required (): (Rewrite_Set discard_minus False)*)
2040 val p2 = parse thy (
2041 "Script SimplifyScript (t_t::real) = " ^
2042 " (Rewrite_Set discard_minus False " ^
2045 val p3 = parse thy (
2046 "Script SimplifyScript (t_t::real) = " ^
2047 " ((Rewrite_Set discard_minus False) " ^
2050 val p4 = parse thy (
2051 "Script SimplifyScript (t_t::real) = " ^
2052 " ((Rewrite_Set discard_minus False) " ^
2055 val p5 = parse thy (
2056 "Script SimplifyScript (t_t::real) = " ^
2057 " ((Try (Rewrite_Set discard_minus False) " ^
2058 " Try (Rewrite_Set discard_parentheses False)) " ^
2061 val p6 = parse thy (
2062 "Script SimplifyScript (t_t::real) = " ^
2063 " ((Try (Rewrite_Set discard_minus False) @@ " ^
2064 " Try (Rewrite_Set rat_mult_poly False) @@ " ^
2065 " Try (Rewrite_Set make_rat_poly_with_parentheses False) @@ " ^
2066 " Try (Rewrite_Set cancel_p_rls False) @@ " ^
2068 " ((Try (Rewrite_Set common_nominator_p_rls False) @@ " ^
2069 " Try (Rewrite_Set rat_mult_div_pow False) @@ " ^
2070 " Try (Rewrite_Set make_rat_poly_with_parentheses False) @@" ^
2071 " Try (Rewrite_Set cancel_p_rls False) @@ " ^
2072 " Try (Rewrite_Set rat_reduce_1 False)))) @@ " ^
2073 " Try (Rewrite_Set discard_parentheses False)) " ^
2077 "----------- get_denominator ----------------------------";
2078 "----------- get_denominator ----------------------------";
2079 "----------- get_denominator ----------------------------";
2080 val thy = @{theory Isac};
2081 val t = term_of (the (parse thy "get_denominator ((a +x)/b)"));
2082 val SOME (_, t') = eval_get_denominator "" 0 t thy;
2083 if term2str t' = "get_denominator ((a + x) / b) = b" then ()
2084 else error "get_denominator ((a + x) / b) = b"