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 "-------- build errpat fillpat --------------------------";
47 "--------------------------------------------------------";
48 "--------------------------------------------------------";
49 "--------------------------------------------------------";
52 "~~~~~BEGIN: decomment structure RationalI : RATIONALI ~~";
53 (*.~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
54 tests of internal functions: to make them work,
55 out-comment (*!!!*) in knowledge/Rational.ML:
57 structure RationalI : RATIONALI =
64 !!!##*)~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~.*)
66 "-------- ... missing WN060103 --------------------------";
67 "-------- ... missing WN060103 --------------------------";
68 "-------- ... missing WN060103 --------------------------";
69 (*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
70 writeln ("********************* rational.sml - TESTS *************************");
71 writeln ("***** divide tests *****");
72 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_)));
73 (* result: [(1,[0,0,1]),(1,[0,0,0])] *)
74 if mv_pquot1=[(1,[0,0,1]),(1,[0,0,0])] then () else error ("rational.sml: example failed");
76 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_)));
77 (* result: [(1,[1,0,1]),(~1,[0,0,1])] *)
78 if mv_prest1=[(1,[1,0,1]),(~1,[0,0,1])] then () else error ("rational.sml: example failed");
80 val mv_pquot2 = (#1(mv_division([(4,[2]),(8,[1]),(16,[0])],[(1,[1]),(1,[0])],LEX_)));
81 (* result: [(4,[1]),(4,[0])] *)
82 if mv_pquot2=[(4,[1]),(4,[0])] then () else error ("rational.sml: example failed");
84 val mv_prest2 = (#2(mv_division([(4,[2]),(8,[1]),(16,[0])],[(1,[1]),(1,[0])],LEX_)));
85 (* result: [(12,[0]] *)
86 if mv_prest2=[(12,[0])] then () else error ("rational.sml: example failed");
88 val mv_pquot3 = (#1(mv_division([(4,[2]),(~4,[0])],[(2,[1]),(2,[0])],LEX_)));
89 (* [(2,[1]),(~2,[0])] *)
90 if mv_pquot3=[(2,[1]),(~2,[0])] then () else error ("rational.sml: example failed");
92 val mv_prest3 = (#2(mv_division([(1,[2]),(~1,[0])],[(2,[1]),(2,[0])],LEX_)));
93 (* [(1,[2]),(~1,[0])] *)
94 if mv_prest3=[(1,[2]),(~1,[0])] then () else error ("rational.sml: example failed");
96 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_)));
98 if mv_pquot4=[(1,[0,1,1])] then () else error ("rational.sml: example failed");
100 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_)));
101 (* [(1,[1,1,1]),(~4,[0,1,2]),(4,[1,0,1]),(3,[0,0,1])] *)
102 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");
104 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_)));
105 (* [(1,[2,2,0]),(6,[2,1,2]),(3,[1,1,0]),(4,[1,0,0]),(4,[0,4,0]),(3,[0,0,0])]*)
106 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");
108 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_)));
110 if mv_prest5=[] then () else error ("rational.sml: example failed");
112 (* (x^2 + 2(a+1)x + (a^2+2a+1)) / (x+a+1) = x+a+1 *)
113 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_)));
114 if mv_pquot6=[(1,[1,0,0]),(1,[0,1,0]),(1,[0,0,0])] then () else error ("rational.sml: example failed");
116 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_)));
117 if mv_prest6=[] then () else error ("rational.sml: example failed");
120 writeln ("***** MV_CONTENT-TESTS *****");
121 val mv_cont1=mv_content([(1,[2,1]),(1,[2,0]),(1,[1,1]),(1,[1,0]),(1,[0,1]),(1,[0,0])]);
122 (* [(1,[0,1]),(1,[0,0])] *)
123 if mv_cont1=[(1,[0,1]),(1,[0,0])] then () else error ("rational.sml: example failed");
125 val mv_pp1=mv_pp([(1,[1,1]),(1,[1,0]),(1,[0,1]),(1,[0,0])]);
126 (*[(1,[1,0]),(1,[0,0])]*)
127 if mv_pp1=[(1,[1,0]),(1,[0,0])] then () else error ("rational.sml: example failed");
129 val mv_cont2=mv_content([(2,[1]),(4,[0])]);
131 if mv_cont2=[(2,[0])] then () else error ("rational.sml: example failed");
133 val mv_pp2=mv_pp([(2,[1]),(4,[0])]);
134 (* [(1,[1]),(2,[0])] *)
135 if mv_pp2=[(1,[1]),(2,[0])] then () else error ("rational.sml: example failed");
137 val mv_cont3=mv_content[(8,[2,1,1]),(12,[1,0,2]),(10,[2,2,0]),(16,[1,1,1])];
139 if mv_cont3=[(2,[0,0,0])] then () else error ("rational.sml: example failed");
141 val mv_pp3=mv_pp[(8,[2,1,1]),(12,[1,0,2]),(10,[2,2,0]),(16,[1,1,1])];
142 (* [(5,[2,2,0]),(4,[2,1,1]),(8,[1,1,1]),(6,[1,0,2])] *)
143 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");
145 val mv_cont4=mv_content[(2,[2,1,0]),(3,[1,0,1]),(2,[1,1,0]),(3,[0,0,1])];
147 if mv_cont4=[(1,[0,0,0])] then () else error ("rational.sml: example failed");
149 val mv_pp4=mv_pp [(2,[2,1,0]),(3,[1,0,1]),(2,[1,1,0]),(3,[0,0,1])];
150 (* [(2,[2,1,0]),(2,[1,1,0]),(3,[1,0,1]),(3,[0,0,1])] *)
151 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");
153 val con1=mv_content([(9,[2,0]),(15,[1,1]),(12,[1,0]),(6,[0,2]),(12,[0,1])]);
155 if con1=[(3,[0,0])] then () else error ("rational.sml: example failed");
157 val pp1=mv_pp([(9,[2,0]),(15,[1,1]),(12,[1,0]),(6,[0,2]),(12,[0,1])]);
158 (* [(3,[2,0]),(5,[1,1]),(4,[1,0]),(2,[0,2]),(4,[0,1])] *)
159 if pp1=[(3,[2,0]),(5,[1,1]),(4,[1,0]),(2,[0,2]),(4,[0,1])] then () else error ("rational.sml: example failed");
161 val con2=mv_content([(1,[2,0]),(1,[1,1]),(1,[1,0]),(1,[0,2]),(1,[0,1])]);
163 if con2=[(1,[0,0])] then () else error ("rational.sml: example failed");
165 val pp2 =mv_pp([(1,[2,0]),(1,[1,1]),(1,[1,0]),(1,[0,2]),(1,[0,1])]);
166 (* [(1,[2,0]),(1,[1,1]),(1,[1,0]),(1,[0,2]),(1,[0,1])] *)
167 if pp2=[(1,[2,0]),(1,[1,1]),(1,[1,0]),(1,[0,2]),(1,[0,1])] then () else error ("rational.sml: example failed");
169 val cont1 = mv_content [(1,[2,1,0]),(2,[2,1,0])];
171 if cont1=[(3,[0,1,0])] then () else error ("rational.sml: example failed");
173 val pp1 = mv_pp [(1,[2,1,0]),(2,[2,1,0])];
175 if pp1=[(1,[2,0,0])] then () else error ("rational.sml: example failed");
177 val cont2 = mv_content [(4,[1,2,0]),(2,[2,1,0])];
179 if cont2=[(2,[0,1,0])] then () else error ("rational.sml: example failed");
181 val pp2 = mv_pp [(4,[1,2,0]),(2,[2,1,0])];
182 (* [(1,[2,0,0]),(2,[1,1,0])] *)
183 if pp2=[(1,[2,0,0]),(2,[1,1,0])] then () else error ("rational.sml: example failed");
185 writeln ("********************************************************");
186 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])];
187 if cont3=[(5,[0,2,1]),(4,[0,2,0]),(2,[0,1,1])] then () else error ("rational.sml: example failed");
188 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])];
191 "-------- fun monom2term, fun poly2term' ---------------";
192 "-------- fun monom2term, fun poly2term' ---------------";
193 "-------- fun monom2term, fun poly2term' ---------------";
194 val t = monom2term ((3,[2,1,0]), ["c","b","a"](*reverse ???SK-*));
195 term2str t = "3 * (c ^^^ 2 * b)" (*true*);
197 val t = monom2term ((1,[1,0]), ["b","a"]);
198 term2str t = "b" (*true*);
200 val t = poly2term ([(1,[0,0,0]),(2,[1,0,0]),(3,[2,1,0]),(4,[3,2,1])],
202 term2str t = "1 + 2 * c + 3 * (c ^^^ 2 * b) + 4 * (c ^^^ 3 * (b ^^^ 2 * a))";
204 val t = poly2term ([(1,[1,0]),(1,[0,1])], ["b","a"]);
205 term2str t = "a + b" (*true*);
207 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*)
208 "~~~~~END: decomment structure RationalI : RATIONALI ~~~~";
209 "~~~~~END: decomment structure RationalI : RATIONALI ~~~~";
210 "~~~~~END: decomment structure RationalI : RATIONALI ~~~~";
213 fun parse_rat str = (term_of o the o (parse thy)) str;
215 writeln ("***** mv_gcd-tests *****");
216 val ggt1 = mv_gcd [(4,[2,2]),(8,[1,1]),(4,[0,0])] [(2,[1,1]),(2,[0,0])];
217 (* [(2,[1,1]),(2,[0,0])] *)
218 if ggt1=[(2,[1,1]),(2,[0,0])] then () else error ("rational.sml: example failed");
220 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])];
221 (* [(2,[1,1,0]),(3,[0,0,1])] *)
222 if ggt2=[(2,[1,1,0]),(3,[0,0,1])] then () else error ("rational.sml: example failed");
225 val ggt3 = mv_gcd [(1,[2,0]),(~2,[1,1]),(1,[0,2])] [(1,[1,0]),(~1,[0,1])];
226 (* [(1,[1,0]),(~1,[0,1])] *)
227 if ggt3=[(1,[1,0]),(~1,[0,1])] then () else error ("rational.sml: example failed");
230 val ggt4 = mv_gcd [(1,[2,1,0]),(2,[2,1,0])] [(5,[1,0,0])];
232 if ggt4=[(1,[1,0,0])] then () else error ("rational.sml: example failed");
235 val ggt5 = mv_gcd [(4,[2,0]),(~8,[1,1]),(4,[0,2])] [(1,[2,0]),(~1,[0,2])];
236 (* [(1,[1,0]),(~1,[0,1])] *)
237 if ggt5=[(1,[1,0]),(~1,[0,1])] then () else error ("rational.sml: example failed");
240 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])];
242 if ggt6=[(1,[1,0,0])] then () else error ("rational.sml: example failed");
244 writeln ("***** kgv-tests *****");
245 val kgv1=mv_lcm [(10,[])] [(15,[])];
247 if kgv1=[(30,[])] then () else error ("rational.sml: example failed");
249 val kgv2=mv_lcm [(1,[2,0]),(~2,[1,1]),(1,[0,2])] [(1,[1,0]),(~1,[0,1])];
250 (* [(1,[2,0]),(~2,[1,1]),(1,[0,2])] *)
251 if kgv2=[(1,[2,0]),(~2,[1,1]),(1,[0,2])] then () else error ("rational.sml: example failed");
253 val kgv3=mv_lcm [(4,[2,0]),(~8,[1,1]),(4,[0,2])] [(1,[2,0]),(~1,[0,2])];
254 (* [(4,[3,0]),(~4,[2,1]),(~4,[1,2]),(4,[0,3])] *)
255 if kgv3=[(4,[3,0]),(~4,[2,1]),(~4,[1,2]),(4,[0,3])] then () else error ("rational.sml: example failed");
258 writeln ("***** STEP_CANCEL_TESTS: *****");
260 val term2 = (term_of o the o (parse thy)) " (9 * a^^^2 * b) / (6 * a * c)";
261 val div2 = term2str (step_cancel term2);
262 if div2 = "3 * (a * b) * (3 * a) / (2 * c * (3 * a))" then () else error ("rational.sml: example failed");
265 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";
266 val div1 = term2str(step_cancel term1);
267 if div1 = "(3 * c + 14 * b + 20 * (b ^^^ 2 * c) + 10 * (a * (b * c))) * a / (1 * a)" then () else error ("rational.sml: example failed");
269 val term3 = (term_of o the o (parse thy)) "(10 * a^^^2 * b * c) / (1 * x * y * z) ";
270 val div3 = term2str(step_cancel term3);
271 if div3="10 * a ^^^ 2 * b * c / (1 * x * y * z)" then () else error ("rational.sml: example failed");
273 --------------------------------------------------------------------------!!!*)
275 (*-----versuche 13.3.03-----
276 val t = str2term "1 - x^^^2 - 5 * x^^^5";
277 val vs=(((map free2str) o vars) t);
278 val SOME ml = expanded2poly t vs;
280 poly2term'(rev(sort (mv_geq LEX_) (ml)),vs);
281 poly2term'([(~5,[5]),(~1,[2]),(1,[0])], vs);
282 monom2term((~5,[5]),vs);
283 monom2term((~1,[2]),vs);
284 val t' = monom2term((1,[0]),vs);(*uncaught exception LIST*)
286 val (i,is) = (~1,[2]);
287 val ttt = Const ("Groups.times_class.times", [HOLogic.realT,HOLogic.realT]---> HOLogic.realT) $
288 (Const ("uminus", HOLogic.realT --> HOLogic.realT) $
289 Free ((str_of_int o abs) i, HOLogic.realT)) $
290 powerproduct2term(is, vs);
292 -------versuche 13.3.03-----*)
294 val t = str2term "1 - x^^^2 - 5 * x^^^5";
295 val SOME t' = expanded2polynomial t; term2str t';
296 "1 + - 1 * x ^^^ 2 + - 5 * x ^^^ 5";
297 val t = str2term "1 - x";
298 val SOME t' = expanded2polynomial t; term2str t';
300 val t = str2term "1 + (-1) * x";
301 val SOME t' = expanded2polynomial t; term2str t';
303 val t = (term_of o the o (parse thy)) "1 + (-1) * x ^^^ 2 + (-5) * x ^^^5";
304 val SOME t' = polynomial2expanded t; term2str t';
305 "1 - x ^^^ 2 - 5 * x ^^^ 5";
308 "-------- external calculating functions test -----------";
309 "-------- external calculating functions test -----------";
310 "-------- external calculating functions test -----------";
311 val t1 = (term_of o the o (parse thy)) "((3 * x^^^2 + 6 *x + 3) / (2*x + 2))";
312 val SOME (t1',asm)= factout_p_ thy t1;
313 term2str t1'; terms2str asm;
314 "(3 + 3 * x) * (1 + 1 * x) / (2 * (1 + 1 * x))";
316 val SOME (t1',asm)= cancel_p_ thy t1;
317 term2str t1'; terms2str asm;
319 "[\"1 + 1 * x ~= 0\"]";
321 val t = (term_of o the o (parse thy)) "((-3 * x^^^2 + 6 *x - 3) / (2*x - 2))";
322 val SOME (t',asm)= cancel_ thy t;
323 term2str t'; terms2str asm;
326 val SOME (t',asm)= factout_ thy t;
327 term2str t'; terms2str asm;
328 "(3 - 3 * x) * (-1 + x) / (2 * (-1 + x))";
331 val t = str2term "((x+ (-1)) / (x + 1)) + ((x + 1) / (x + (-1)))";
332 val SOME (t',asm) = add_fraction_p_ thy t;
333 term2str t'; terms2str asm;
334 "(2 + 2 * x ^^^ 2) / (-1 + 1 * x ^^^ 2)";
336 val SOME (t',asm) = common_nominator_p_ thy t;
337 term2str t'; terms2str asm;
338 "(-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))";
341 val t = str2term "((x - 1) / (x + 1)) + ((x + 1) / (x - 1))";
342 val SOME (t',asm) = add_fraction_ thy t;
343 term2str t'; terms2str asm;
344 "(2 + 2 * x ^^^ 2) / (-1 + x ^^^ 2)";
346 val SOME (t',asm) = common_nominator_ thy t;
347 term2str t'; terms2str asm;
348 "(-1 + x) * (-1 + x) / ((1 + x) * (-1 + x)) +\n(1 + x) * (1 + x) / ((1 + x) * (-1 + x))";
351 val t = str2term "((1) / (2*x + 2)) + ((1) / (2*x + (-2))) + ((1) / ( x^^^2 + (-1)))+((1) / (x^^^2 + (-2)*x + 1))";
352 val SOME (t',asm) = common_nominator_p_ thy t;
353 term2str t'; terms2str asm;
354 "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 * (#";
356 val SOME (t',asm) = add_fraction_p_ thy t;
357 term2str t'; terms2str asm;
358 "1 * x / (1 + -2 * x + 1 * x ^^^ 2)";
359 "[\"1 + 1 * x ~= 0\"]";
360 val SOME(t',asm) = norm_rational_ thy t;
361 term2str t'; terms2str asm;
362 "1 * x / (1 + -2 * x + 1 * x ^^^ 2)";
363 "[\"1 + 1 * x ~= 0\"]";
365 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))";
366 val SOME (t3',_) = common_nominator_ thy t3;
367 val SOME (t3'',_) = add_fraction_ thy t3;
371 val SOME(t4,t5) = norm_expanded_rat_ thy t3;
377 val t=(term_of o the o (parse thy)) "(9 - x^^^2)/(9 - 6*x + x^^^2)";
378 val SOME (t',_) = factout_ thy t;
379 val SOME (t'',_) = cancel_ thy t;
382 "(3 + x) * (3 - x) / ((3 - x) * (3 - x))";
385 val t=(term_of o the o (parse thy))
386 "(9 - x^^^2) / (9 - 6*x + x^^^2) + 1 / (3 - x)";
387 val SOME (t',_) = common_nominator_ thy t;
388 val SOME (t'',_) = add_fraction_ thy t;
391 "(9 - x ^^^ 2) / ((3 - x) * (3 - x)) + 1 * (3 - x) / ((3 - x) * (3 - x))";
394 (*WN021016 added -----vv---*)
395 val t = str2term "(9 - x^^^2) / (9 - 6*x + x^^^2) + 1";
396 val SOME (t',_) = common_nominator_ thy t;
397 val SOME (t'',_) = add_fraction_ thy t;
398 term2str t' = "(9 - x ^^^ 2) / (9 - 6 * x + x ^^^ 2) +\n1" ^
399 " * (9 - 6 * x + x ^^^ 2) / (9 - 6 * x + x ^^^ 2)" (*true*);
400 term2str t'' = "6 / (3 - x)" (*true*);
402 val t = str2term "1 + (9 - x^^^2) / (9 - 6*x + x^^^2)";
403 val SOME (t',_) = common_nominator_ thy t;
404 val SOME (t'',_) = add_fraction_ thy t;
405 term2str t' = "1 * (9 - 6 * x + x ^^^ 2) / (9 - 6 * x + x ^^^ 2) +\n" ^
406 "(9 - x ^^^ 2) / (9 - 6 * x + x ^^^ 2)" (*true*);
407 term2str t'' = "6 / (3 - x)" (*true*);
408 (*WN021016 added -----^^---*)
409 (*WN030602 added -----vv--- no rewrite -> NONE !*)
410 val t = str2term "1 / a";
411 val NONE = cancel_p_ thy t;
412 val NONE = rewrite_set_ thy false cancel_p t;
413 (*WN.2.6.03 added -------^^---*)
415 val t = str2term "(y^^^2 - x^^^2)/(y^^^2 - 2*y*x + x^^^2)";
416 val SOME (t',_) = factout_ thy t;
417 val SOME (t'',_) = cancel_ thy t;
418 term2str t' = "(y + x) * (y - x) / ((y - x) * (y - x))"(*true*);
419 term2str t'' = "(y + x) / (y - x)";
421 val t = str2term "(y^^^2 - x^^^2)/(y^^^2 - 2*y*x + x^^^2) + 1 / (y - x)";
422 val SOME (t',_) = common_nominator_ thy t;
423 val SOME (t'',_) = add_fraction_ thy t;
425 "(-1 * x ^^^ 2 + y ^^^ 2) / ((-1 * x + y) * (-1 * x + y)) +\n1" ^
426 " * (-1 * x + y) / ((-1 * x + y) * (-1 * x + y))" (*true*);
427 term2str t'' = "(-1 - x - y) / (x - y)" (*true*);
429 val t = str2term "(x^^^2 - y^^^2)/(x^^^2 - 2*x*y + y^^^2) + 1 / (x - y)";
430 val SOME (t',_) = common_nominator_ thy t;
431 val SOME (t'',_) = add_fraction_ thy t;
432 if term2str t' = "(-1 * y ^^^ 2 + x ^^^ 2) / ((-1 * y + x) * (-1 * y + x))" ^
433 " +\n1 * (-1 * y + x) / ((-1 * y + x) * (-1 * y + x))" then ()
434 else error "rational.sml lex-ord 1";
435 if term2str t'' = "(-1 - y - x) / (y - x)" then ()
436 else error "rational.sml lex-ord 2";
437 (*WN.16.10.02 WN070905 lexicographische Ordnung erhalten ! SK.ord*)
440 val t = str2term "(x^^^2 - y^^^2)/(x^^^2 - 2*x*y + y^^^2)";
441 val SOME (t',_) = norm_expanded_rat_ thy t;
442 if term2str t' = "(x + y) / (x - y)" then ()
443 else error "rational.sml term2poly: invalid x ^^^ 2 - y ^^^ 2 No.1";
444 (*val SOME (t'',_) = norm_rational_ thy t;
445 *** RATIONALS_TERM2POLY_EXCEPTION: Invalid Polynomial
446 WN.16.10.02 ?! + WN060831???SK4
447 WN070905 *** term2poly: invalid = x ^^^ 2 - y ^^^ 2*)
450 val t = str2term "(9 - x^^^2)/(9 - 6*x + x^^^2) + (1)/(3 + x)";
451 val SOME (t',_) = norm_expanded_rat_ thy t;
452 if term2str t' = "(12 + 5 * x + x ^^^ 2) / (9 - x ^^^ 2)" then ()
453 else error "rational.sml (9 - x^^^2)/(9 - 6*x + x^^^2) +...";
454 (*val SOME (t'',_) = norm_rational_ thy t;
455 *** RATIONALS_TERM2POLY_EXCEPTION: Invalid Polynomial WN.16.10.02 ?!
456 WN070906 *** term2poly: invalid = 9 - x ^^^ 2 SK.term2poly*)
458 val t=(term_of o the o (parse thy))
459 "(9 + (-1)* x^^^2)/(9 + (-1)* 6*x + x^^^2) + (1)/(3 + x)";
460 val SOME (t',_) = norm_expanded_rat_ thy t;
461 val SOME (t'',_) = norm_rational_ thy t;
464 "(12 + 5 * x + x ^^^ 2) / (9 - x ^^^ 2)";
465 "(12 + 5 * x + x ^^^ 2) / (9 + (-1) * x ^^^ 2)";
468 "-------- cancel from: Mathematik 1 Schalk Reniets Verlag";
469 "-------- cancel from: Mathematik 1 Schalk Reniets Verlag";
470 "-------- cancel from: Mathematik 1 Schalk Reniets Verlag";
471 val thy = @{theory "Rational"};
472 val thy' = "Rational";
474 val mp = "make_polynomial";
476 writeln ("example 186:");
478 val e186a'="(14 * x * y) / ( x * y )";(*SRC*)
479 rewrite_set_ thy false cancel (str2term e186a');
481 val e186a = the (rewrite_set thy' false "cancel" e186a');
482 is_expanded (parse_rat "14 * x * y");
483 is_expanded (parse_rat "x * y");
484 if e186a = ("14 / 1", "[\"y * x ~= 0\"]") then ()
485 else error "rational.sml cancel Schalk e186a";
488 val e186b'="(60 * a * b) / ( 15 * a * b )";
489 val e186b = the (rewrite_set thy' false "cancel" e186b');
491 val e186c'="(144 * a^^^2 * b * c) / (12 * a * b * c )";
492 val e186c = (the (rewrite_set thy' false "cancel" e186c'))
493 handle e => print_exn_G e;
494 val t = (term_of o the o (parse thy)) e186c';
495 if e186c = ("12 * a / 1", "[\"12 * (c * (b * a)) ~= 0\"]") then ()
496 else error "rational.sml cancel Schalk e186c";
498 writeln ("example 187:");
500 val e187a'="(12 * x * y) / (8 * y^^^2 )";(*SRC*)
501 val e187a = the (rewrite_set thy' false "cancel" e187a');
503 val e187b'="(8 * x^^^2 * y * z ) / (18 * x * y^^^2 * z )";
504 val e187b = the (rewrite_set thy' false "cancel" e187b');
506 val e187d'="(9 * x^^^5 * y^^^2 * z^^^4) / (15 * x^^^6 * y^^^3 * z )";(*SRC*)
507 val e187d = the (rewrite_set thy' false "cancel" e187d');
508 if e187d = ("3 * z ^^^ 3 / (5 * (y * x))",
509 "[\"3 * (z * (y ^^^ 2 * x ^^^ 5)) ~= 0\"]") then ()
510 else error "rational.sml cancel Schalk e186d";
512 writeln "example 188:";
513 val e188a'="(-8 + 8 * x) / (-9 + 9 * x)";(*SRC*)
514 val e188a = the (rewrite_set thy' false "cancel" e188a');
515 is_expanded (parse_rat "8 * x + -8");
516 (* e188a = ("8 / 9",["not ((-1) + x = 0)"]) then () 13.3.03*)
517 if e188a = ("8 / 9", "[\"-1 + x ~= 0\"]") then ()
518 else error "rational.sml: e188a new behaviour";
520 val SOME (t,_) = rewrite_set thy' false mp "(8*((-1) + x))/(9*((-1) + x))";
522 val e188b'="(-15 + 5 * x) / (-18 + 6 * x)";(*SRC*)
523 val SOME (t, asm) = rewrite_set thy' false "cancel" e188b';
524 t = "5 / 6" (*true*);
527 val e188c'="( a + -1 * b ) / ( b + -1 * a )";
528 val e188c = the (rewrite_set thy' false "cancel_p" e188c');
529 (*is_expanded (parse_rat "a + -1 * b");*)
531 rewrite_set thy' false mp "((-1)*(b + (-1) * a))/(1*(b + (-1) * a))";
532 if t= "(a + -1 * b) / (-1 * a + b)" then()
533 else error "rational.sml: e188c new behaviour";
535 writeln ("example 190:");
537 val e190c'="( 27 * a^^^3 + 9 * a^^^2 + 3 * a + 1 ) / ( 27 * a^^^3 + 18 * a^^^2 + 3 * a )";
538 val e190c = the (rewrite_set thy' false "cancel" e190c');
539 val SOME (t,_) = rewrite_set thy' false mp "((1 + 9 * a ^^^ 2)*(1 + 3 * a))/((3 * a + 9 * a ^^^ 2)*(1 + 3 * a))";
540 if t = "(1 + 3 * a + 9 * a ^^^ 2 + 27 * a ^^^ 3) /\n(3 * a + 18 * a ^^^ 2 + 27 * a ^^^ 3)" then ()
541 else error "rational.sml: e190c new behaviour";
543 writeln ("example 191:");
545 val e191a'="( x^^^2 + -1 * y^^^2 ) / ( x + y )";
547 val e191a = the (rewrite_set thy' false "cancel" e191a');
548 is_expanded (parse_rat "x^^^2 + -1 * y^^^2");
550 is_expanded (parse_rat "x + y");
552 val SOME (t,_) = rewrite_set thy' false mp "((x + (-1) * y)*(x + y))/((1)*(x + y))";
553 (* t="(x ^^^ 2 + -1 * y ^^^ 2) / (x + y)" then() WN.13.3.03*)
554 if t="(x ^^^ 2 + -1 * y ^^^ 2) / (x + y)" then()
555 else error "rational.sml: e191a new behaviour";
558 val e191c'="( 9 * x^^^2 + -30 * x + 25 ) / ( 9 * x^^^2 + -25 )";
560 val e191c = the (rewrite_set thy' false "cancel" e191c');
561 is_expanded (parse_rat "9 * x^^^2 + -30 * x + 25");
563 is_expanded (parse_rat "25 + -30*x + 9*x^^^2");
565 is_expanded (parse_rat "-25 + 9*x^^^2");
567 val SOME (t,_) = rewrite_set thy' false mp "(((-5) + 3 * x)*((-5) + 3 * x))/((5 + 3 * x)*((-5) + 3 * x))";
568 (* t="(25 + ((-30) * x + 9 * x ^^^ 2)) / ((-25) + 9 * x ^^^ 2)"then() 13.3.03*)
569 if t= "(25 + -30 * x + 9 * x ^^^ 2) / (-25 + 9 * x ^^^ 2)" then()
570 else error "rational.sml: 'e191c' new behaviour";
573 writeln ("example 192:");
575 val e192b'="( 7 * x^^^3 + -1 * x^^^2 * y ) / ( 7 * x * y^^^2 + -1 * y^^^3 )";
577 val e192b = the (rewrite_set thy' false "cancel" e192b');
578 -------------------*)
579 val SOME (t',_) = rewrite_set thy' false mp "((x ^^^ 2)*(7 * x + (-1) * y))/((y ^^^ 2)*(7 * x + (-1) * y))";
580 (*========== inhibit exn 110317 ================================================
581 if t' = "(7 * x ^^^ 3 + -1 * x ^^^ 2 * y) / (7 * x * y ^^^ 2 + -1 * y ^^^ 3)"
582 (*"(-1 * y * x ^^^ 2 + 7 * x ^^^ 3) / (-1 * y ^^^ 3 + 7 * x * y ^^^ 2)"WN050929*)
583 then () else error "rational.sml: 'e192b' new behaviour";
584 (*^^^ works with MG's simplifier vvv*)
585 val t =str2term"((x ^^^ 2)*(7 * x + (-1) * y))/((y ^^^ 2)*(7 * x + (-1) * y))";
586 val SOME (t',_) = rewrite_set_ thy false make_polynomial t;
587 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";
588 ============ inhibit exn 110317 ==============================================*)
590 writeln ("example 193:");
592 val e193a'="( x^^^2 + -6 * x + 9 ) / ( x^^^2 + -9 )";
594 val e193a = the (rewrite_set thy' false "cancel" e193a');
595 -------------------*)
597 val e193b'="( x^^^2 + -8 * x + 16 ) / ( 2 * x^^^2 + -32 )";
599 val e193b = the (rewrite_set thy' false "cancel" e193b');
601 val e193c'="( 2 * x + -50 * x^^^3 ) / ( 25 * x^^^2 + -10 * x + 1 )";
602 val SOME(t,_) = rewrite_set thy' false "cancel" e193c';
603 -------------------*)
605 val wn01 = "(-25 + 9*x^^^2)/(5 + 3*x)";
606 val SOME (t, asm) = rewrite_set thy' false "cancel" wn01;
607 (* t = "((-5) + 3 * x) / 1" then () WN.13.3.03*)
608 if t = "(-5 + 3 * x) / 1" andalso asm = "[\"5 + 3 * x ~= 0\"]" then ()
609 else error "rational.sml: new behav. in cancel wn01";
611 "-------- common_nominator_p ----------------------------";
612 "-------- common_nominator_p ----------------------------";
613 "-------- common_nominator_p ----------------------------";
614 val rls' = "common_nominator_p";
616 writeln ("example 204:");
618 val e204a'="((5 * x) / 9) + ((3 * x) / 9) + (x / 9)";
619 val e204a = the (rewrite_set thy' false "common_nominator_p" e204a');
621 val e204b'="5 / x + -3 / x + -1 / x";
622 val e204b = the (rewrite_set thy' false "common_nominator_p" e204b');
623 if e204b = ("1 / x", "[]") then ()
624 else error "rational.sml common_nominator_p example e204b";
626 writeln ("example 205:");
628 val e205a'="((4 * x + 7) / 8) + ((4 * x + 3) / 8)";
629 val e205a = the (rewrite_set thy' false "common_nominator_p" e205a');
631 val e205b'="((5 * x + 2) / 3) + ((-2 * x + 1) / 3)";
632 val e205b = the (rewrite_set thy' false "common_nominator_p" e205b');
633 if e205b = ("(1 + x) / 1", "[]") then ()
634 else error "rational.sml common_nominator_p example e204b";
636 writeln ("example 206:");
638 val e206a'="((5 * x + 4) / (2 * x + -1)) + ((9 * x + 5) / (2 * x + -1))";
639 val e206a = the (rewrite_set thy' false "common_nominator_p" e206a');
641 val e206b'="((17 * x + -23) / (5 * x + 4)) + ((-25 + -17 * x) / (5 * x + 4))";
642 val e206b = the (rewrite_set thy' false "common_nominator_p" e206b');
644 writeln ("example 207:");
645 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)) ";
646 val e207 = the (rewrite_set thy' false "common_nominator_p" e207');
648 writeln ("example 208:");
649 val e208'="((3 * x + 2) / (x + 2)) + ((5 * x + -1) / (x + 2)) + ((-7 * x + -3) / (x + 2)) + ((-1 * x + -3) / (x + 2)) ";
650 val e208 = the (rewrite_set thy' false "common_nominator_p" e208');
652 writeln ("example 209:");
653 val e209'="((3 * x + -7 * y + 3 * z) / (4)) + ((2 * x + 17 * y + 10 * z) / (4)) + ((-1 * x + 2 * y + z) / (4)) ";
654 val e209 = the (rewrite_set thy' false "common_nominator_p" e209');
656 writeln ("example 210:");
657 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)) ";
658 val e210 = the (rewrite_set thy' false "common_nominator_p" e210');
660 writeln ("example 211:");
662 val e211a'="((b) / (a + -1 * b)) + ((-1 * a) / (a + -1 * b))";
663 val e211a = the (rewrite_set thy' false "common_nominator_p" e211a');
665 val e211b'="((b) / (b^^^2 + -1 * a^^^2)) + ((-1 * a) / (b^^^2 + -1 * a^^^2))";
666 val e211b = the (rewrite_set thy' false "common_nominator_p" e211b');
668 writeln ("example 212:");
670 val e212a'="((4) / (x)) + ((-3) / (y)) + -1";
671 val e212a = the (rewrite_set thy' false "common_nominator_p" e212a');
673 val e212b'="((4) / (x)) + ((-5) / (y)) + ((6) / (x*y))";
674 val e212b = the (rewrite_set thy' false "common_nominator_p" e212b');
676 writeln ("example 213:");
678 val e213a'="((5 * x) / (3 * y^^^2)) + ((19 * z) / (6 * x * y)) + ((-2 * x) / (3 * y^^^2)) + ((7 * y^^^2) / (6 * x^^^2)) ";
679 val e213a = the (rewrite_set thy' false "common_nominator_p" e213a');
681 val e213b'="((2 * b) / (3 * a^^^2)) + ((3 * c) / (7 * a * b)) + ((4 * b) / (3 * a^^^2)) + ((3 * a) / (7 * b^^^2))";
682 val e213b = the (rewrite_set thy' false "common_nominator_p" e213b');
684 writeln ("example 214:");
686 val e214a'="((3 * x + 2 * y + 2 * z) / (4)) + ((-5 * x + -3 * y) / (3)) + ((x + y + -2 * z) / (2))";
687 val e214a = the (rewrite_set thy' false "common_nominator_p" e214a');
689 val e214b'="((5 * x + 2 * y + z) / (2)) + ((-7 * x + -3 * y) / (3)) + ((3 * x + 6 * y + -1 * z) / (12))";
690 val e214b = the (rewrite_set thy' false "common_nominator_p" e214b');
692 writeln ("example 216:");
694 val e216a'="((2 * b + 3 * c) / (a * c)) + ((3 * a + b) / (a * b)) + ((-2 * b^^^2 + -3 * a * c) / (a * b * c))";
695 val e216a = the (rewrite_set thy' false "common_nominator_p" e216a');
697 val e216b'="((2 * a + 3 * b) / (b * c)) + ((3 * c + a) / (a * c)) + ((-2 * a^^^2 + -3 * b * c) / (a * b * c))";
698 val e216b = the (rewrite_set thy' false "common_nominator_p" e216b');
700 writeln ("example 217:");
701 val e217'="((z + -1) / (z)) + ((3 * z ^^^2 + -6 * z + 5) / (z^^^2)) + ((-4 * z^^^3 + 7 * z^^^2 + -5 * z + 5) / (z^^^3))";
702 val e217 = the (rewrite_set thy' false "common_nominator_p" e217');
705 val rls' = "common_nominator";
706 writeln ("example 218:");
707 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))";
708 val e218 = the (rewrite_set thy' false "common_nominator" e218');
709 if e218 = ("(16 - 63 * a ^^^ 2 - 81 * a ^^^ 3) / (108 * a ^^^ 4)", "[]") then ()
710 else error "rationa.sml common_nominator example e218";
712 writeln ("example 219:");
714 val e219a'="((1) / (y + 1)) + ((1) / (y + 2)) + ((1) / (y + 3))";
715 val e219a = the (rewrite_set thy' false "common_nominator" e219a');
717 val e219b'="((1) / (x + 1)) + ((1) / (x + 2)) + ((-2) / (x + 3))";
718 val e219b = the (rewrite_set thy' false "common_nominator" e219b');
719 if e219b = ("(5 + 3 * x) / (6 + 11 * x + 6 * x ^^^ 2 + x ^^^ 3)", "[]") then ()
720 else error "rationa.sml common_nominator example e219b";
722 writeln ("example 220:");
724 val e220a'="((17) / (5 * r + -2)) + ((-13) / (2 * r + 3)) + ((4) / (3 * r + -5))";
725 val e220a = the (rewrite_set thy' false "common_nominator" e220a');
727 val e220b'="((20 * a) / (a + -3)) + ((-19 * a) / (a + -4)) + ((a) / (a + -5))";
728 val e220b = the (rewrite_set thy' false "common_nominator" e220b');
730 writeln ("example 221:");
732 val e221a'="((a + b) / (a + -1 * b)) + ((a + -1 * b) / (a + b))";
733 val e221a = the (rewrite_set thy' false "common_nominator" e221a');
735 val e221b'="((x + -1 * y) / (x + y)) + ((x + y) / (x + -1 * y)) ";
736 val e221b = the (rewrite_set thy' false "common_nominator" e221b');
738 writeln ("example 222:");
740 val e222a'="((1 + -1 * x) / (1 + x)) + ((-1 + -1 * x) / (1 + -1 * x)) + ((4 * x) / (1 + -1 * x^^^2))";
741 val e222a = the (rewrite_set thy' false "common_nominator" e222a');
743 val e222b'="((1 + x ) / (1 + -1 * x)) + ((-1 + x) / (1 + x)) + ((2 * x) / (1 + -1 * x^^^2))";
744 val e222b = the (rewrite_set thy' false "common_nominator" e222b');
746 writeln ("example 225:");
748 val e225a'="((6 * a) / (a^^^2 + -64)) + ((a + 2) / (2 * a + 16)) + ((-1) / (2))";
749 val e225a = the (rewrite_set thy' false "common_nominator" e225a');
751 val e225b'="((a + 2 ) / (2 * a + 12)) + ((4 * a) / (a^^^2 + -36)) + ((-1) / (2))";
752 val e225b = the (rewrite_set thy' false "common_nominator" e225b');
754 writeln ("example 226:");
756 val e226a'="((35 * z) / (49 * z^^^2 + -4)) + -1 + ((14 * z + -1) / (14 * z + 4)) ";
757 val e226a = the (rewrite_set thy' false "common_nominator" e226a');
759 val e226b'="((45 * a * b) / (25 * a^^^2 + -9 * b^^^2)) + ((20 * a + 3 * b) / (10 * a + 6 * b)) + -2";
760 val e226b = the (rewrite_set thy' false "common_nominator" e226b');
762 writeln ("example 227:");
764 val e227a'="((6 * z + 11) / (6 * z + 14)) + ((9 * z ) / (9 * z^^^2 + -49)) + -1 ";
765 val e227a = the (rewrite_set thy' false "common_nominator" e227a');
767 val e227b'="((16 * a + 37 * b) / (4 * a + 10 * b)) + ((6 * a * b) / (4 * a^^^2 + -25 * b^^^2)) + -4 ";
768 val e227b = the (rewrite_set thy' false "common_nominator" e227b');
770 writeln ("example 228:");
772 val e228a'="((7 * a + 11) / (3 * a^^^2 + -3)) + ((-2 * a + -1) / (a^^^2 + -1 * a)) + ((-1) / (3 * a + 3))";
773 val e228a = the (rewrite_set thy' false "common_nominator" e228a');
775 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))";
776 val e228b = the (rewrite_set thy' false "common_nominator" e228b');
779 writeln ("example 229:");
781 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))";
782 val e229a = the (rewrite_set thy' false "common_nominator" e229a');
784 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))";
785 val e229b = the (rewrite_set thy' false "common_nominator" e229b');
787 writeln ("example 230:");
789 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))";
790 val e230a = the (rewrite_set thy' false "common_nominator" e230a');
792 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))";
793 val e230b = the (rewrite_set thy' false "common_nominator" e230b');
795 writeln ("example 231:");
797 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))";
798 val e231a = the (rewrite_set thy' false "common_nominator" e231a');
800 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))";
801 val e231b = the (rewrite_set thy' false "common_nominator" e231b');
803 writeln ("example 232:");
805 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))";
806 val e232a = the (rewrite_set thy' false "common_nominator" e232a');
808 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))";
809 val e232b = the (rewrite_set thy' false "common_nominator" e232b');
811 writeln ("example 233:");
813 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))";
814 val e233a = the (rewrite_set thy' false "common_nominator" e233a');
816 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))";
817 val e233b = the (rewrite_set thy' false "common_nominator" e233b');
819 writeln ("example 234:");
821 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))";
822 val e234a = the (rewrite_set thy' false "common_nominator" e234a');
824 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)) ";
825 val e234b = the (rewrite_set thy' false "common_nominator" e234b');
827 writeln ("example 235:");
829 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))";
830 val e235a = the (rewrite_set thy' false "common_nominator" e235a');
832 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)) ";
833 val e235b = the (rewrite_set thy' false "common_nominator" e235b');
835 writeln ("example 236:");
837 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))";
838 val e236a = the (rewrite_set thy' false "common_nominator" e236a');
840 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)) ";
841 val e236b = the (rewrite_set thy' false "common_nominator" e236b');
845 writeln ("example heuberger:");
846 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)";
847 val eheu = the (rewrite_set thy' false "cancel" eheu');
849 val rls' = "common_nominator_p";
850 writeln ("example stiefel:");
851 val est1'="(7) / (-14) + (-2) / (4)";
852 val est1 = the (rewrite_set thy' false "common_nominator_p" est1');
853 if est1 = ("-1 / 1", "[]") then ()
854 else error "new behaviour in rational.sml: est1'";
856 val t = (term_of o the o (parse thy))
857 "(9 - x ^^^ 2) / (9 - 6 * x + x ^^^ 2)";
858 val SOME (t',_) = factout_ thy t;
859 if term2str t' = "(3 + x) * (3 - x) / ((3 - x) * (3 - x))" then ()
860 else error "rational.sml factout_ (9 - x ^^^ 2) / (9 - 6 * x + x ^^^ 2)";
863 "-------- reverse rewrite -------------------------------";
864 "-------- reverse rewrite -------------------------------";
865 "-------- reverse rewrite -------------------------------";
866 (*WN.28.8.02: tests for the 'reverse-rewrite' functions:
867 these are defined in Rationals.ML and stored in
868 the 'reverse-ruleset' cancel*)
870 (*the term for which reverse rewriting is demonstrated*)
871 val t = (term_of o the o (parse thy))
872 "(9 - x ^^^ 2) / (9 + 6 * x + x ^^^ 2)";
873 val Rrls {scr=Rfuns {init_state=ini,locate_rule=loc,
874 next_rule=nex,normal_form=nor,...},...} = cancel;
876 (*normal_form produces the result in ONE step*)
877 val SOME (t',_) = nor t;
878 if term2str t' = "(3 - x) / (3 + x)" then ()
879 else error "rational.sml normal_form (9 - x ^^^ 2) / (9 - 6 * x + x ^^^ 2)";
881 (*initialize the interpreter state used by the 'me'*)
882 val (t,_,revsets,_) = ini t;
884 (*find the rule 'r' to apply to term 't'*)
885 val SOME (r as (Thm (str, thm))) = nex revsets t;
886 if str = "sym_#power_Float ((3,0), (0,0)) __ ((2,0), (0,0))"
887 andalso string_of_thm thm =
888 (string_of_thm o make_thm o (cterm_of (@{theory "Isac"})))
889 (Trueprop $ (term_of o the o (parse thy)) "9 = 3 ^^^ 2") then ()
890 else error "rational.sml next_rule (9 - x ^^^ 2) / (9 - 6 * x + x ^^^ 2)";
891 (* before Isa02->09-2 was not checked automatically, ?was different?:
892 val SOME r = nex revsets t;
893 val r = Thm ("sym_#mult_2_3","6 = 2 * 3") : rule*)
895 (* check, if the rule 'r' applied by the user to 't' belongs to the ruleset;
896 if the rule is OK, the term resulting from applying the rule is returned,too;
897 there might be several rule applications inbetween,
898 which are listed after the head in reverse order *)
899 val (r, (t, asm))::_ = loc revsets t r;
900 if term2str t = "(9 - x ^^^ 2) / (3 ^^^ 2 + 6 * x + x ^^^ 2)" andalso asm = []
902 else error "rational.sml locate_rule (9 - x ^^^ 2) / (9 - 6 * x + x ^^^ 2)";
904 (* find the next rule to apply *)
905 val SOME (r as (Thm (str, thm))) = nex revsets t;
906 if str = "sym_#power_Float ((3,0), (0,0)) __ ((2,0), (0,0))" andalso
907 string_of_thm thm = (string_of_thm o make_thm o (cterm_of (@{theory "Isac"})))
908 (Trueprop $ (term_of o the o (parse thy)) "9 = 3 ^^^ 2") then ()
909 else error "rational.sml next_rule (9 - x ^^^ 2) / (9 - 6 * x + x ^^^ 2)";
911 (*check the next rule*)
912 val (r, (t, asm)) :: _ = loc revsets t r;
913 if term2str t = "(3 ^^^ 2 - x ^^^ 2) / (3 ^^^ 2 + 6 * x + x ^^^ 2)" then ()
914 else error "rational.sml locate_rule (9 - x ^^^ 2) / (9 - 6 * x + x ^^^ 2) II";
916 (*find and check the next rules, rewrite*)
917 val SOME r = nex revsets t;
918 val (r,(t,asm))::_ = loc revsets t r;
919 if term2str t = "(3 ^^^ 2 - x ^^^ 2) / (3 ^^^ 2 + 2 * 3 * x + x ^^^ 2)" then ()
920 else error "rational.sml locate_rule II";
922 val SOME r = nex revsets t;
923 val (r,(t,asm))::_ = loc revsets t r;
924 if term2str t = "(3 - x) * (3 + x) / (3 ^^^ 2 + 2 * 3 * x + x ^^^ 2)" then ()
925 else error "rational.sml next_rule II";
927 val SOME r = nex revsets t;
928 val (r,(t,asm))::_ = loc revsets t r;
929 if term2str t = "(3 - x) * (3 + x) / ((3 + x) * (3 + x))" then ()
930 else error "rational.sml next_rule III";
932 val SOME r = nex revsets t;
933 val (r, (t, asm)) :: _ = loc revsets t r;
935 if ss = "(3 - x) / (3 + x)" andalso terms2str asm = "[\"3 + x ~= 0\"]" then ()
936 else error "rational.sml: new behav. in rev-set cancel";
938 "-------- 'reverse-ruleset' cancel_p --------------------";
939 "-------- 'reverse-ruleset' cancel_p --------------------";
940 "-------- 'reverse-ruleset' cancel_p --------------------";
941 (*WN.11.9.02: the 'reverse-ruleset' cancel_p*)
943 (*the term for which reverse rewriting is demonstrated*)
944 val t = str2term "(9 + (-1)*x^^^2) / (9 + ((-6)*x + x^^^2))";
945 val Rrls {scr=Rfuns {init_state=ini,locate_rule=loc,
946 next_rule=nex,normal_form=nor,...},...} = cancel_p;
948 (*normal_form produces the result in ONE step*)
949 val SOME (t',_) = nor t;
950 term2str t' = "(3 + 1 * x) / (3 + -1 * x)";
952 (*initialize the interpreter state used by the 'me'*)
953 val SOME (t', asm) = cancel_p_ thy t;
954 term2str t' = "(3 + x) / (3 + -1 * x)" (*true*);
955 terms2str asm = "[\"3 + -1 * x ~= 0\"]" (*true*);
956 val (t,_,revsets,_) = ini t;
958 (* WN.10.10.02: dieser Fall terminiert nicht
959 (make_polynomial enth"alt zu viele rules)
960 WN060823 'init_state' requires rewriting on specified location in the term
961 print_depth 99; Rfuns; print_depth 3;
962 WN060831 cycling "sym_order_mult_rls_" "sym_real_mult_assoc"
963 as was with make_polynomial before ?!?*)
965 val SOME r = nex revsets t;
966 eq_Thm (r, Thm ("sym_#power_Float ((3,0), (0,0)) __ ((2,0), (0,0))",
967 mk_thm thy "9 = 3 ^^^ 2"));
968 (*WN060831 *** id_of_thm
969 Exception- ERROR raised ...
970 val (r,(t,asm))::_ = loc revsets t r;
973 val SOME r = nex revsets t;
974 val (r,(t,asm))::_ = loc revsets t r;
978 writeln "****************** all tests successfull *************************";
982 (*WN.17.3.03 =========================================================vvv---*)
983 "-------- norm_Rational ---------------------------------";
984 "-------- norm_Rational ---------------------------------";
985 "-------- norm_Rational ---------------------------------";
986 val t = str2term "(3*x+5)/18 - x/2 - -(3*x - 2)/9 = 0";
987 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
988 if term2str t' = "1 / 18 = 0" then () else error "rational.sml 1";
990 val t = str2term "(17*x - 51)/9 - (-(13*x - 3)/6) + 11 - (9*x - 7)/4 = 0";
991 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
992 if term2str t' = "(237 + 65 * x) / 36 = 0" then ()
993 else error "rational.sml 2";
995 val t = str2term "(1/2 + (5*x)/2)^^^2 - ((13*x)/2 - 5/2)^^^2 - (6*x)^^^2 + 29";
996 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
997 if term2str t' = "23 + 35 * x + -72 * x ^^^ 2" then ()
998 else error "rational.sml 3";
1000 (*trace_rewrite:=true;*)
1001 val t = str2term "Not (6*x is_atom)";
1002 val SOME (t',_) = rewrite_set_ thy false powers_erls t; term2str t';
1004 val t = str2term "1 < 2";
1005 val SOME (t',_) = rewrite_set_ thy false powers_erls t; term2str t';
1008 val t = str2term "(6*x)^^^2";
1009 val SOME (t',_) = rewrite_ thy dummy_ord powers_erls false
1010 (num_str @{thm realpow_def_atom}) t;
1011 if term2str t' = "6 * x * (6 * x) ^^^ (2 + -1)" then ()
1012 else error "rational.sml powers_erls (6*x)^^^2";
1014 val t = str2term "-1 * (-2 * (5 / 2 * (13 * x / 2)))";
1015 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
1016 if term2str t' = "65 * x / 2" then () else error "rational.sml 4";
1018 val t = str2term "1 - ((13*x)/2 - 5/2)^^^2";
1019 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
1020 (*bef.040209: if term2str t' = "(-21 + (130 * x + -169 * x ^^^ 2)) / 4"then()*)
1021 if term2str t' = "(-21 + 130 * x + -169 * x ^^^ 2) / 4" then ()
1022 else error "rational.sml 5";
1024 (*SRAM Schalk I, p.92 Nr. 609a*)
1025 val t = str2term "2*(3 - x/5)/3 - 4*(1 - x/3) - x/3 - 2*(x/2 - 1/4)/27 +5/54";
1026 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
1027 if term2str t' = "(-255 + 112 * x) / 135" then ()
1028 else error "rational.sml 6";
1030 (*SRAM Schalk I, p.92 Nr. 610c*)
1031 val t = str2term "((x- 1)/(x+1) + 1) / ((x- 1)/(x+1) - (x+1)/(x- 1)) - 2";
1032 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
1033 if term2str t' = "(-3 + -1 * x) / 2" then () else error "rational.sml 7";
1035 (*SRAM Schalk I, p.92 Nr. 476a*)
1036 val t = str2term "(x^^^2/(1 - x^^^2) + 1)/(x/(1 - x) + 1) * (1 + x)";
1037 (*. a/b : c/d translated to a/b * d/c .*)
1038 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
1039 (*if term2str t' = "1 / 1" then () else error "rational.sml 8";3.6.03*)
1040 if term2str t' = "1" then () else error "rational.sml 8";
1042 (*............................vvv---TODO: sollte gehen mit poly_order *)
1043 (*Schalk I, p.92 Nr. 472a*)
1044 val t = str2term "((8*x^^^2 - 32*y^^^2)/(2*x + 4*y))/((4*x - 8*y)/(x + y))";
1045 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
1046 if term2str t' = "x + y" then () else error "rational.sml p.92 Nr. 472a";
1048 (*Schalk I, p.70 Nr. 480b; a/b : c/d translated to a/b * d/c*)
1049 val t = str2term ("((12*x*y/(9*x^^^2 - y^^^2))/" ^
1050 "(1/(3*x - y)^^^2 - 1/(3*x + y)^^^2)) *" ^
1051 "(1/(x - 5*y)^^^2 - 1/(x + 5*y)^^^2)/" ^
1052 "(20*x*y/(x^^^2 - 25*y^^^2))");
1053 (*... nicht simpl, zerlegt ...*)
1054 val t = str2term ("((12*x*y/(9*x^^^2 - y^^^2))/" ^
1055 "(1/(3*x - y)^^^2 - 1/(3*x + y)^^^2))");
1056 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
1057 "(-12 * (x * y ^^^ 3) + 108 * (x * (y * x ^^^ 2))) / (12 * (x * y))";
1058 (* ~~~~~~~~~~ poly_order notwendig!*)
1059 val t = str2term ("(1/(x - 5*y)^^^2 - 1/(x + 5*y)^^^2)/" ^
1060 "(20*x*y/(x^^^2 - 25*y^^^2))");
1061 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
1062 if term2str t' = "1 / (x ^^^ 2 + -25 * y ^^^ 2)" then ()
1063 else error "rational.sml norm_Rational 1 / (x ^^^ 2 + -25 * y ^^^ 2)";
1065 "nonterm.SK6 ----- SK060904-2a non-termination of add_fraction_p_";
1066 (*WN.2.6.03 from rlang.sml 56a
1067 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)";
1068 val NONE = rewrite_set_ thy false common_nominator_p t;
1070 WN060831 nonterm.SK7
1071 val t = str2term "(a + b * x) / (a + -1 * (b * x)) + (-1 * a + b * x) / (a + b * x)";
1072 val NONE = add_fraction_p_ thy t;
1076 (* ------------------------------------------------------------------- *)
1077 (*---------vvv------------ MG: ab 1.7.03 ----------------vvv-----------*)
1078 (* Simplifier fuer beliebige Buchterme *)
1079 (* ------------------------------------------------------------------- *)
1080 (*----------------------- norm_Rational_mg ----------------------------*)
1081 (* ------------------------------------------------------------------- *)
1083 "-------- numeral rationals -----------------------------";
1084 "-------- numeral rationals -----------------------------";
1085 "-------- numeral rationals -----------------------------";
1086 (*SRA Schalk I, p.40 Nr. 164b *)
1087 val t = str2term "(47/6 - 76/9 + 13/4)/(35/12)";
1088 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1090 if (term2str t) = "19 / 21" then ()
1091 else error "rational.sml: diff.behav. in norm_Rational_mg 1";
1093 (*SRA Schalk I, p.40 Nr. 166a *)
1094 val t = str2term "((5/4)/(4+22/7) + 37/20)*(110/3 - 110/9 * 23/11)";
1095 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1097 if (term2str t) = "45 / 2" then ()
1098 else error "rational.sml: diff.behav. in norm_Rational_mg 2";
1101 "-------- cancellation ----------------------------------";
1102 "-------- cancellation ----------------------------------";
1103 "-------- cancellation ----------------------------------";
1104 (* e190c Stefan K.*)
1106 "((1 + 9 * a ^^^ 2)*(1 + 3 * a))/((3 * a + 9 * a ^^^ 2)*(1 + 3 * a))";
1107 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1110 "(1 + 9 * a ^^^ 2) / (3 * a + 9 * a ^^^ 2)"
1112 else error "rational.sml: diff.behav. in norm_Rational_mg 3";
1114 (* e192b Stefan K.*)
1116 "((x ^^^ 2)*(7 * x + (-1) * y))/((y ^^^ 2)*(7 * x + (-1) * y))";
1117 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1122 else error "rational.sml: diff.behav. in norm_Rational_mg 4";
1124 (*SRC Schalk I, p.66 Nr. 379c *)
1127 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1132 else error "rational.sml: diff.behav. in norm_Rational_mg 5";
1134 (*SRC Schalk I, p.66 Nr. 380b *)
1136 "15*(3*x+3)*(4*x+9)/(12*(2*x+7)*(5*x+5))";
1137 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1140 "(27 + 12 * x) / (28 + 8 * x)"
1142 else error "rational.sml: diff.behav. in norm_Rational_mg 6";
1144 (*Schalk I, p.60 Nr. 215c *)
1145 (* Falsches Ergebnis: rechnet lange und cancel_p kann nicht weiter krzen!!!*)
1147 val t = str2term "(a+b)^^^4*(x - y)/((x - y)^^^3*(a+b)^^^2)";
1148 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1151 "(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)"
1153 else error "rational.sml: diff.behav. in norm_Rational_mg 7";
1156 "(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)"
1157 val SOME (t,_) = rewrite_set_ thy false cancel_p t;
1159 (* uncaught exception nonexhaustive binding failure
1160 raised at: stdIn:93.1-93.51 *)
1162 (*Schalk I, p.66 Nr. 381a *)
1163 (* ACHTUNG: rechnet ca. 2 Minuten !!! *)
1165 val t = str2term "18*(a+b)^^^3*(a - b)^^^2/(72*(a - b)^^^3*(a+b)^^^2)";
1166 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1169 "(a + b) / (4 * a + -4 * b)"
1170 then () else error "rational.sml: diff.behav. in norm_Rational_mg 8";
1173 (*SRC Schalk I, p.66 Nr. 381b *)
1175 "(4*x^^^2 - 20*x + 25)/(2*x - 5)^^^3";
1176 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1181 else error "rational.sml: diff.behav. in norm_Rational_mg 9";
1183 (*SRC Schalk I, p.66 Nr. 381c *)
1185 "(27*a^^^3+9*a^^^2+3*a+1)/(27*a^^^3+18*a^^^2+3*a)";
1186 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1189 "(1 + 9 * a ^^^ 2) / (3 * a + 9 * a ^^^ 2)"
1191 else error "rational.sml: diff.behav. in norm_Rational_mg 10";
1193 (*SRC Schalk I, p.66 Nr. 383a *)
1195 "(5*a^^^2 - 5*a*b)/(a - b)^^^2";
1196 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1199 "5 * a / (a + -1 * b)"
1201 else error "rational.sml: diff.behav. in norm_Rational_mg 11";
1204 "-------- common denominator ----------------------------";
1205 "-------- common denominator ----------------------------";
1206 "-------- common denominator ----------------------------";
1207 (*SRA Schalk I, p.67 Nr. 403a *)
1210 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1213 "(-3 * x + 4 * y + -1 * x * y) / (x * y)"
1215 else error "rational.sml: diff.behav. in norm_Rational_mg 12";
1217 (*SRA Schalk I, p.67 Nr. 407b *)
1219 "(2*a+3*b)/(b*c) + (3*c+a)/(a*c) - (2*a^^^2+3*b*c)/(a*b*c)";
1220 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1225 else error "rational.sml: diff.behav. in norm_Rational_mg 13";
1227 (*SRA Schalk I, p.67 Nr. 410b *)
1229 "1/(x+1) + 1/(x+2) - 2/(x+3)";
1230 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1233 "(5 + 3 * x) / (6 + 11 * x + 6 * x ^^^ 2 + x ^^^ 3)"
1235 else error "rational.sml: diff.behav. in norm_Rational_mg 14";
1237 (*SRA Schalk I, p.67 Nr. 413b *)
1239 "(1+x)/(1 - x) - (1 - x)/(1+x) + 2*x/(1 - x^^^2)";
1240 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1243 "6 * x / (1 + -1 * x ^^^ 2)"
1245 else error "rational.sml: diff.behav. in norm_Rational_mg 15";
1247 (*SRA Schalk I, p.68 Nr. 414a *)
1249 "(x + 2)/(x - 1) + (x - 3)/(x - 2) - (x + 1)/((x - 1)*(x - 2))";
1250 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1253 "(-2 + -5 * x + 2 * x ^^^ 2) / (2 + -3 * x + x ^^^ 2)"
1255 else error "rational.sml: diff.behav. in norm_Rational_mg 16";
1257 (*SRA Schalk I, p.68 Nr. 423a *)
1259 "(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)";
1260 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1265 else error "rational.sml: diff.behav. in norm_Rational_mg 17";
1267 (*SRA Schalk I, p.68 Nr. 428b *)
1269 "1/(a - b)^^^2 + 1/(a+b)^^^2 - 2/(a^^^2 - b^^^2) - 4*(b^^^2 - 1)/(a^^^2 - b^^^2)^^^2";
1270 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1273 "4 / (a ^^^ 4 + -2 * a ^^^ 2 * b ^^^ 2 + b ^^^ 4)"
1275 else error "rational.sml: diff.behav. in norm_Rational_mg 18";
1277 (*SRA Schalk I, p.68 Nr. 430b *)
1279 "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";
1280 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1285 else error "rational.sml: diff.behav. in norm_Rational_mg 19";
1288 (*SRA Schalk I, p.68 Nr. 432 *)
1290 "(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)";
1291 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1296 else error "rational.sml: diff.behav. in norm_Rational_mg 20";
1301 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1304 "(3 * y + b * x) / (b * y)"
1306 else error "rational.sml: diff.behav. in norm_Rational_mg 21";
1309 "-------- multiply and cancel ---------------------------";
1310 "-------- multiply and cancel ---------------------------";
1311 "-------- multiply and cancel ---------------------------";
1312 (*SRM Schalk I, p.68 Nr. 436a *)
1314 "3*(x+y)/(15*(x - y)) * 25*(x - y)^^^2/(18*(x+y)^^^2)";
1315 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1318 "(5 * x + -5 * y) / (18 * x + 18 * y)"
1320 else error "rational.sml: diff.behav. in norm_Rational_mg 22";
1322 (*SRM.test Schalk I, p.68 Nr. 436b *)
1323 (*WN060420???MG3 crashes with method 'simplify' in
1324 IsacCore > Simplification > Rational Terms > Multiplication > No.2*)
1325 val t = str2term "5*a*(a - b)^^^2*(a + b)^^^3/(7*b*(a - b)^^^3) * 7*b/(a + b)^^^3";
1326 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1329 "5 * a / (a + -1 * b)"
1331 else error "rational.sml: diff.behav. in norm_Rational_mg 23";
1333 (*Schalk I, p.68 Nr. 437a *)
1334 val t = str2term "(3*a - 4*b)/(4*c+3*e) * (3*a+4*b)/(9*a^^^2 - 16*b^^^2)";
1335 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1336 if (term2str t) = "1 / (4 * c + 3 * e)" then ()
1337 else error "rational.sml: diff.behav. in norm_Rational_mg 24";
1339 "----- S.K. corrected non-termination 060904";
1340 val t = str2term "(3*a - 4*b) * (3*a+4*b)/((4*c+3*e)*(9*a^^^2 - 16*b^^^2))";
1341 val SOME (t',_) = rewrite_set_ thy false make_polynomial t;
1344 "(9 * a ^^^ 2 + -16 * b ^^^ 2) /\n(36 * a ^^^ 2 * c + 27 * a ^^^ 2 * e + -64 * b ^^^ 2 * c +\n -48 * b ^^^ 2 * e)"
1345 (*"(9 * a ^^^ 2 + -16 * b ^^^ 2) / (36 * a ^^^ 2 * c + 27 * a ^^^ 2 * e + -64 * b ^^^ 2 * c + -48 * b ^^^ 2 * e)"*)
1346 then () else error "rational.sml: S.K.8..corrected 060904-6";
1348 "----- S.K. corrected non-termination of cancel_p_";
1349 val t'' = str2term ("(9 * a ^^^ 2 + -16 * b ^^^ 2) /" ^
1350 "(36 * a^^^2 * c + (27 * a^^^2 * e + (-64 * b^^^2 * c + -48 * b^^^2 * e)))");
1351 val SOME (t',_) = rewrite_set_ thy false cancel_p t'';
1352 if term2str t' = "1 / (4 * c + 3 * e)" then ()
1353 else error "rational.sml: diff.behav. in cancel_p S.K.8";
1355 (*Schalk I, p.68 Nr. 437b *)
1356 (* nonterm.SK9 loops: cancel_p kann nicht weiter kuerzen!!! *)
1357 val t'' = str2term "(a + b)/(x^^^2 - y^^^2) * ((x - y)^^^2/(a^^^2 - b^^^2))";
1358 (* val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t'';
1361 "================delete===";
1362 (*a casual output from above*)
1364 "(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)";
1365 (* WN060831 nonterm.SK10
1366 val SOME (t,_) = rewrite_set_ thy false cancel_p t;
1370 (*SRM Schalk I, p.68 Nr. 438a *)
1372 "x*y/(x*y - y^^^2)*(x^^^2 - x*y)";
1373 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1378 else error "rational.sml: diff.behav. in norm_Rational_mg 24";
1380 (*SRM Schalk I, p.68 Nr. 439b *)
1382 "(4*x^^^2+4*x+1)*((x^^^2 - 2*x^^^3)/(4*x^^^2+2*x))";
1383 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1386 "(x + -4 * x ^^^ 3) / 2"
1388 else error "rational.sml: diff.behav. in norm_Rational_mg 25";
1390 (*SRM Schalk I, p.68 Nr. 440a *)
1392 "(x^^^2 - 2*x)/(x^^^2 - 3*x) * (x - 3)^^^2/(x^^^2 - 4)";
1393 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1396 "(-3 + x) / (2 + x)"
1398 else error "rational.sml: diff.behav. in norm_Rational_mg 26";
1400 "----- Schalk I, p.68 Nr. 440b SK11 works since 0707xx";
1402 "(a^^^3 - 9*a)/(a^^^3*b - a*b^^^3)*(a^^^2*b+a*b^^^2)/(a+3)";
1403 val SOME (t,_) = rewrite_set_ thy false norm_Rational t;
1404 if term2str t = "(-3 * a + a ^^^ 2) / (a + -1 * b)" then ()
1405 else error "rational.sml: diff.behav. in norm_Rational 27";
1407 "----- SK12 works since 0707xx";
1408 val t = str2term "(a^^^3 - 9*a)*(a^^^2*b+a*b^^^2)/((a^^^3*b - a*b^^^3)*(a+3))";
1409 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
1410 if term2str t' = "(-3 * a + a ^^^ 2) / (a + -1 * b)" then ()
1411 else error "rational.sml: diff.behav. in norm_Rational 28";
1414 "-------- common denominator and multiplication ---------";
1415 "-------- common denominator and multiplication ---------";
1416 "-------- common denominator and multiplication ---------";
1417 (*SRAM Schalk I, p.69 Nr. 441b *)
1418 val t = str2term "(4*a/3 + 3*b^^^2/a^^^3 + b/(4*a))*(4*b/(3*a))";
1419 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1422 "(36 * b ^^^ 3 + 3 * a ^^^ 2 * b ^^^ 2 + 16 * a ^^^ 4 * b) / (9 * a ^^^ 4)"
1423 then () else error "rational.sml: diff.behav. in norm_Rational_mg 28";
1425 (*SRAM Schalk I, p.69 Nr. 442b *)
1426 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)";
1427 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1430 "5 * x ^^^ 2 / (a * b ^^^ 3 * c)"
1431 then () else error "rational.sml: diff.behav. in norm_Rational_mg 29";
1433 (*SRAM Schalk I, p.69 Nr. 443b *)
1434 val t = str2term "(a/2 + b/3)*(b/3 - a/2)";
1435 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1438 "(-9 * a ^^^ 2 + 4 * b ^^^ 2) / 36"
1439 then () else error "rational.sml: diff.behav. in norm_Rational_mg 30";
1441 (*SRAM Schalk I, p.69 Nr. 445b *)
1442 val t = str2term "(a^^^2/9 + 2*a/(3*b) + 4/b^^^2)*(a/3 - 2/b) + 8/b^^^3";
1443 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1447 then () else error "rational.sml: diff.behav. in norm_Rational_mg 31";
1449 (*SRAM Schalk I, p.69 Nr. 446b *)
1450 val t = str2term "(x/(5*x + 4*y) - y/(5*x - 4*y) + 1)*(25*x^^^2 - 16*y^^^2)";
1451 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1454 "30 * x ^^^ 2 + -9 * x * y + -20 * y ^^^ 2"
1456 else error "rational.sml: diff.behav. in norm_Rational_mg 32";
1458 (*SRAM Schalk I, p.69 Nr. 449a *)(*Achtung: rechnet ca 8 Sekunden*)
1460 "(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)";
1461 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1463 if (term2str t) = "(-81 * x ^^^ 4 + 16 * x ^^^ 8 * y ^^^ 4) / (81 * y ^^^ 8)"
1464 then () else error "rational.sml: diff.behav. in norm_Rational_mg 33";
1467 (*SRAM Schalk I, p.69 Nr. 450a *)
1469 "(4*x/(3*y)+2*y/(3*x))^^^2 - (2*y/(3*x) - 2*x/y)*(2*y/(3*x)+2*x/y)";
1470 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1473 "(52 * x ^^^ 2 + 16 * y ^^^ 2) / (9 * y ^^^ 2)"
1475 else error "rational.sml: diff.behav. in norm_Rational_mg 34";
1478 "-------- double fractions ------------------------------";
1479 "-------- double fractions ------------------------------";
1480 "-------- double fractions ------------------------------";
1481 (*SRD Schalk I, p.69 Nr. 454b *)
1483 "((2 - x)/(2*a)) / (2*a/(x - 2))";
1484 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1487 "(-4 + 4 * x + -1 * x ^^^ 2) / (4 * a ^^^ 2)"
1489 else error "rational.sml: diff.behav. in norm_Rational_mg 35";
1491 (*SRD Schalk I, p.69 Nr. 455a *)
1493 "(a^^^2 + 1)/(a^^^2 - 1) / ((a+1)/(a - 1))";
1494 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1497 "(1 + a ^^^ 2) / (1 + 2 * a + a ^^^ 2)" then ()
1498 else error "rational.sml: diff.behav. in norm_Rational_mg 36";
1501 "----- Schalk I, p.69 Nr. 455b";
1502 val t = str2term "(x^^^2 - 4)/(y^^^2 - 9)/((2+x)/(3 - y))";
1503 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1504 if term2str t = "(2 + -1 * x) / (3 + y)" then ()
1505 else error "rational.sml: diff.behav. in norm_Rational_mg 37";
1507 "----- SK060904-1a non-termination of cancel_p_ ?: worked before 0707xx";
1508 val t = str2term "(x^^^2 - 4)*(3 - y)/((y^^^2 - 9)*(2+x))";
1509 val SOME (t,_) = rewrite_set_ thy false norm_Rational t;
1510 if term2str t = "(2 + -1 * x) / (3 + y)" then ()
1511 else error "rational.sml: diff.behav. in norm_Rational_mg 37b";
1513 "----- ?: worked before 0707xx";
1514 val t = str2term "(3 + -1 * y) / (-9 + y ^^^ 2)";
1515 val SOME (t,_) = rewrite_set_ thy false norm_Rational t;
1516 if term2str t = "-1 / (3 + y)" then ()
1517 else error "rational.sml: -1 / (3 + y) norm_Rational";
1519 (*SRD Schalk I, p.69 Nr. 456b *)
1521 "(b^^^3 - b^^^2)/(b^^^2+b)/(b^^^2 - 1)";
1522 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1524 if (term2str t) = "b / (1 + 2 * b + b ^^^ 2)" then ()
1525 else error "rational.sml: diff.behav. in norm_Rational_mg 38";
1527 (*SRD Schalk I, p.69 Nr. 457b *)
1529 "(16*a^^^2 - 9*b^^^2)/(2*a+3*a*b) / ((4*a+3*b)/(4*a^^^2 - 9*a^^^2*b^^^2))";
1530 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1533 "8 * a ^^^ 2 + -6 * a * b + -12 * a ^^^ 2 * b + 9 * a * b ^^^ 2"
1534 then () else error "rational.sml: diff.behav. in norm_Rational_mg 39";
1536 "----- Schalk I, p.69 Nr. 458b works since 0707";
1538 "(2*a^^^2*x - a^^^2)/(a*x - b*x) / (b^^^2*(2*x - 1)/(x*(a - b)))";
1539 val SOME (t,_) = rewrite_set_ thy false norm_Rational t;
1540 if term2str t = "a ^^^ 2 / b ^^^ 2" then ()
1541 else error "rational.sml: diff.behav. in norm_Rational_mg 39b";
1543 (*SRD Schalk I, p.69 Nr. 459b *)
1544 val t = str2term "(a^^^2 - b^^^2)/(a*b) / (4*(a+b)^^^2/a)";
1545 val SOME (t,_) = rewrite_set_ thy false norm_Rational t;
1546 if term2str t = "(a + -1 * b) / (4 * a * b + 4 * b ^^^ 2)" then ()
1547 else error "rational.sml: diff.behav. in norm_Rational_mg 41";
1550 (*Schalk I, p.69 Nr. 460b nonterm.SK
1552 "(9*(x^^^2 - 8*x+16)/(4*(y^^^2 - 2*y+1)))/((3*x - 12)/(16*y - 16))";
1553 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1556 else error "rational.sml: diff.behav. in norm_Rational_mg 42";
1559 "9*(x^^^2 - 8*x+16)*(16*y - 16)/(4*(y^^^2 - 2*y+1)*(3*x - 12))";
1560 val SOME (t',_) = rewrite_set_ thy false norm_Rational t;
1561 ... non terminating.
1562 val SOME (t',_) = rewrite_set_ thy false make_polynomial t;
1563 "(-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)";
1564 val SOME (t,_) = rewrite_set_ thy false cancel_p t';
1565 ... non terminating.*)
1567 (*SRD Schalk I, p.70 Nr. 472a *)
1568 val t = str2term ("((8*x^^^2 - 32*y^^^2)/(2*x + 4*y))/" ^
1569 "((4*x - 8*y)/(x + y))");
1570 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1575 else error "rational.sml: diff.behav. in norm_Rational_mg 43";
1578 (*----------------------------------------------------------------------*)
1579 (*---------------------- Einfache Dppelbrche --------------------------*)
1580 (*----------------------------------------------------------------------*)
1582 (*SRD Schalk I, p.69 Nr. 461a *)
1584 "(2/(x+3) + 2/(x - 3)) / (8*x/(x^^^2 - 9))";
1585 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1590 else error "rational.sml: diff.behav. in norm_Rational_mg 44";
1592 (*SRD Schalk I, p.69 Nr. 464b *)
1594 "(a - a/(a - 2)) / (a + a/(a - 2))";
1595 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1598 "(3 + -1 * a) / (1 + -1 * a)"
1600 else error "rational.sml: diff.behav. in norm_Rational_mg 45";
1602 (*SRD Schalk I, p.69 Nr. 465b *)
1604 "((x+3*y)/9 + (4*y^^^2 - 9*z^^^2)/(16*x)) /(x/9+y/6+z/4)";
1605 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1608 "(4 * x + 6 * y + -9 * z) / (4 * x)"
1610 else error "rational.sml: diff.behav. in norm_Rational_mg 46";
1612 (*SRD Schalk I, p.69 Nr. 466b *)
1614 "((1 - 7*(x - 2)/(x^^^2 - 4)) / (6/(x+2))) / (3/(x+5)+30/(x^^^2 - 25))";
1615 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1618 "(25 + -10 * x + x ^^^ 2) / 18"
1620 else error "rational.sml: diff.behav. in norm_Rational_mg 47";
1622 (*SRD Schalk I, p.70 Nr. 469 *)
1624 "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))";
1625 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1628 "3 * b ^^^ 3 / (2 * a + -2 * b)"
1630 else error "rational.sml: diff.behav. in norm_Rational_mg 48";
1632 (*----------------------------------------------------------------------*)
1633 (*---------------------- Mehrfache Dppelbrueche ------------------------*)
1634 (*----------------------------------------------------------------------*)
1636 (*SRD.test Schalk I, p.70 Nr. 476b *) (* Rechenzeit: 10 sec *)
1637 (*WN060419 crashes with method 'simplify' ????SK*)
1639 "((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)";
1640 val SOME (t,_) = rewrite_set_ thy false norm_Rational t;
1641 if term2str t = "1 / (a ^^^ 2 + -1 * b ^^^ 2)" then ()
1642 else error "rational.sml: diff.behav. in norm_Rational_mg 49";
1644 "----- Schalk I, p.70 Nr. 477a";
1645 (* MG Achtung: terme explodieren; Bsp zu komplex;
1646 L???ung sollte (ziemlich grosser) Faktorisierter Ausdruck sein
1647 val t = str2term "b*y/(b - 2*y)/((b^^^2 - y^^^2)/(b+2*y)) /" ^
1648 "(b^^^2*y+b*y^^^2)*(a+x)^^^2/((b^^^2 - 4*y^^^2)*(a+2*x)^^^2)";
1649 val SOME (t',_) = rewrite_set_ thy false norm_Rational t;
1652 val t = str2term "b*y*(b+2*y)*(b^^^2 - 4*y^^^2)*(a+2*x)^^^2 / " ^
1653 "((b - 2*y)*(b^^^2 - y^^^2)*(b^^^2*y+b*y^^^2)*(a+x)^^^2)";
1654 val SOME (t,_) = rewrite_set_ thy false make_polynomial t;
1658 "----- Schalk I, p.70 Nr. 478b ----- Rechenzeit: 5 sec";
1659 val t = str2term ("(a - (a*b+b^^^2)/(a+b))/(b+(a - b)/(1+(a+b)/(a - b))) / " ^
1660 "((a - a^^^2/(a+b))/(a+(a*b)/(a - b)))");
1661 val SOME (t',_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1663 "(2 * a ^^^ 3 + 2 * a ^^^ 2 * b) / (a ^^^ 2 * b + b ^^^ 3)"
1665 else error "rational.sml: diff.behav. in norm_Rational_mg 51";
1667 (* TODO.new_c:WN050820 STOP_REW_SUB introduced gave ...
1668 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 ()
1669 else error "rational.sml: works again";
1670 re-outcommented with TODO.new_c: cvs before 071227, 11:50*)
1674 (*Schalk I, p.70 Nr. 480a *)
1675 (* Achtung: rechnet ewig; cancel_p kann nicht krzen: WN060831 nonterm.SK00
1677 "(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)))";
1678 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1683 else error "rational.sml: diff.behav. in norm_Rational_mg 52";
1685 (*MG Berechne Zwischenergebnisse: WN060831 nonterm.SK00*)
1687 "(1/x+1/y+1/z)/(1/x - 1/y - 1/z)";
1688 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1690 "(x ^^^ 2 * y ^^^ 2 * z + x ^^^ 2 * y * z ^^^ 2 + x * y ^^^ 2 * z ^^^ 2) /
1691 (-1 * x ^^^ 2 * y ^^^ 2 * z + -1 * x ^^^ 2 * y * z ^^^ 2 + x * y ^^^ 2 * z ^^^ 2)";
1693 "2*x^^^2/(x^^^2 - z^^^2)/(x/(x+z)+x/(x - z))";
1694 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1698 (* SK 1. Ausdruck kann nicht weiter gekrzt werden; cancel_p !!!*)
1699 ### rls: cancel_p on:
1700 (x ^^^ 2 * (y ^^^ 2 * z) + x ^^^ 2 * (y * z ^^^ 2) + x * (y ^^^ 2 * z ^^^ 2)) /
1701 (-1 * (x ^^^ 2 * (y ^^^ 2 * z)) + -1 * (x ^^^ 2 * (y * z ^^^ 2)) + x * (y ^^^ 2 * z ^^^ 2))
1702 GC #3.61.81.101.197.17503: (0 ms)
1703 *** RATIONALS_DIRECT_CANCEL_EXCEPTION: Invalid fraction
1706 "(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))";
1707 val SOME (t,_) = rewrite_set_ thy false cancel_p t;
1709 (*uncaught exception nonexhaustive binding failure*)
1711 (* Das kann er aber krzen !!????: *)
1713 "(x^^^2 * (y^^^2 * z) + x * (y^^^2 * z^^^2)) / (-1 * (x^^^2 * (y * z^^^2)) + x * (y^^^2 * z^^^2))";
1714 val SOME (t,_) = rewrite_set_ thy false cancel_p t;
1716 "(-1 * (y * x) + -1 * (z * y)) / (1 * (z * x) + -1 * (z * y))";
1720 "-------- crucial examples ------------------------------";
1721 "-------- crucial examples ------------------------------";
1722 "-------- crucial examples ------------------------------";
1723 (*Schalk I, p.60 Nr. 215d *)
1724 (* Achtung: rechnet ewig ...
1725 val t = str2term "(a-b)^^^3 * (x+y)^^^4 / ((x+y)^^^2 * (a-b)^^^5)";
1726 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1727 term2str t; noterm.SK
1730 (* Kein Wunder, denn Z???ler und Nenner extra als Polynom dargestellt ergibt:*)
1732 val t = str2term "(a-b)^^^3 * (x+y)^^^4";
1733 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1735 "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";
1736 val t = str2term "((x+y)^^^2 * (a-b)^^^5)";
1737 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1739 "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";
1741 (*anscheinend macht dem Rechner das Krzen diese Bruches keinen Spass mehr ...*)
1743 (*--------------------------------------------------------------------*)
1744 (*Schalk I, p.70 Nr. 480b
1745 val t = str2term "((12*x*y/(9*x^^^2 - y^^^2))/" ^
1746 "(1/(3*x - y)^^^2 - 1/(3*x + y)^^^2)) *" ^
1747 "(1/(x - 5*y)^^^2 - 1/(x + 5*y)^^^2)/" ^
1748 "(20*x*y/(x^^^2 - 25*y^^^2))";
1749 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1751 Kann nicht weiter vereinfacht werden !!!!?? *)
1753 (*--------------------------------------------------------------------*)
1754 "---- MGs test set";
1755 val t = str2term " (1 + x^^^5) / (y + x) + x^^^3 / x ";
1756 val SOME (t,_) = rewrite_set_ thy false common_nominator_p t;
1757 if term2str t = "(1 + x ^^^ 3 + x ^^^ 5 + y * x ^^^ 2) / (x + y)" then()
1760 (*--------------------------------------------------------------------*)
1761 (* cancel_p liefert nicht immer Polynomnormalform (2): WN060831???SK3b
1762 ---> Sortierung FALSCH !! *)
1763 val t = str2term "b^^^3 * a^^^5/a ";
1764 val SOME (t,_) = rewrite_set_ thy false cancel_p t;
1766 "1 * (a^^^4 * b^^^3) / 1"; (*OK*)
1768 val t = str2term "b^^^3 * a^^^5/b ";
1769 val SOME (t,_) = rewrite_set_ thy false cancel_p t;
1771 "1 * (b^^^2 * a^^^5) / 1"; (*cancel_p sortiert hier falsch um!*)
1773 (* Problem liegt NICHT bei ord_make_polynomial! (siehe folgende Bsple) *)
1775 val x = str2term "x"; val bdv = str2term "bdv";
1776 val t1 = str2term "b^^^2 * a^^^5";
1777 val t2 = str2term "a^^^5 * b^^^2 ";
1778 ord_make_polynomial false Rational.thy [(x,bdv)] (t1,t2); (*false*)
1780 (* ==> "b^^^2 * a^^^5" > "a^^^5 * b^^^2 " ... OK!*)
1782 (*--------------------------------------------------------------------*)
1783 (* cancel_p liefert nicht immer Polynomnormalform (2): WN060831???SK3c
1784 ---> erzeugt berflssige "1 * ..."
1786 val t = str2term "-1 / (3 + y)";
1788 val SOME (t,_) = rewrite_set_ thy false cancel_p t;
1791 (********* Das ist das PROBLEM !!!!!!!??? *******************)
1792 (* -1 im Z???ler der Angabe verursacht das Problem !*)
1795 (* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *)
1796 "----- MGs test set";
1797 val t = str2term "(a^^^2 + -1)/(a+1)";
1798 val SOME (t',_) = rewrite_set_ thy false cancel_p t;
1799 if term2str t' = "(-1 + a) / 1" then ()
1800 else error "rational.sml MG tests 3d";
1802 "----- NOT TERMINATING ?: worked before 0707xx";
1803 val t = str2term "(a^^^2 - 1)*(b + 1) / ((b^^^2 - 1)*(a+1))";
1804 val SOME (t'',_) = rewrite_set_ thy false norm_Rational t;
1805 if term2str t'' = "(1 + -1 * a) / (1 + -1 * b)" then ()
1806 else error "rational.sml MG tests 3e";
1808 "----- corrected SK060905";
1809 val t = str2term "(4*x^^^2 - 20*x + 25)/(2*x - 5)^^^3";
1810 val SOME (t',_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1811 if term2str t' = "-1 / (5 + -2 * x)" then ()
1812 else error "rational.sml corrected SK060905";
1815 "-------- examples for Stefan Karnels thesis ------------";
1816 "-------- examples for Stefan Karnels thesis ------------";
1817 "-------- examples for Stefan Karnels thesis ------------";
1818 (*SRAM Schalk I, p.69 Nr. 442b --- abgewandelt*)
1820 "(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))";
1821 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1824 "5 * x ^^^ 2 / (b ^^^ 3 * c)"
1826 else error "rational.sml: diff.behav. in norm_Rational_mg 53";
1829 "-------- me Schalk I No.186 ----------------------------";
1830 "-------- me Schalk I No.186 ----------------------------";
1831 "-------- me Schalk I No.186 ----------------------------";
1832 val fmz = ["Term ((14 * x * y) / ( x * y ))",
1835 ("Rational",["rational","simplification"],
1836 ["simplification","of_rationals"]);
1837 val p = e_pos'; val c = [];
1838 val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
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;
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;
1848 val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;(*++ for explicit script*)
1849 val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;(*++ for explicit script*)
1850 case (f2str f, nxt) of
1851 ("14", ("End_Proof'", _)) => ()
1852 | _ => error "rational.sml diff.behav. in me Schalk I No.186";
1855 "-------- interSteps ..Simp_Rat_Double_No-1.xml ---------";
1856 "-------- interSteps ..Simp_Rat_Double_No-1.xml ---------";
1857 "-------- interSteps ..Simp_Rat_Double_No-1.xml ---------";
1860 [(["Term (((2 - x)/(2*a)) / (2*a/(x - 2)))", "normalform N"],
1861 ("Rational",["rational","simplification"],
1862 ["simplification","of_rationals"]))];
1865 autoCalculate 1 CompleteCalc;
1866 val ((pt,p),_) = get_calc 1; show_pt pt;
1868 interSteps 1 ([1],Res);
1869 val ((pt,p),_) = get_calc 1; show_pt pt;
1872 "-------- interSteps ..Simp_Rat_Cancel_No-1.xml ---------";
1873 "-------- interSteps ..Simp_Rat_Cancel_No-1.xml ---------";
1874 "-------- interSteps ..Simp_Rat_Cancel_No-1.xml ---------";
1877 [(["Term ((a^2 + -1*b^2) / (a^2 + -2*a*b + b^2))", "normalform N"],
1878 ("Rational",["rational","simplification"],
1879 ["simplification","of_rationals"]))];
1882 autoCalculate 1 CompleteCalc;
1883 val ((pt,p),_) = get_calc 1; show_pt pt;
1884 (*========== inhibit exn 110314 ================================================
1885 (*with explicit script done already... and removed [1,..] at below...
1886 interSteps 1 ([1],Res);
1887 val ((pt,p),_) = get_calc 1; show_pt pt;
1889 interSteps 1 ([2],Res);
1890 val ((pt,p),_) = get_calc 1; show_pt pt;
1892 interSteps 1 ([2,1],Res);
1893 val ((pt,p),_) = get_calc 1; show_pt pt;
1894 val newnds = children (get_nd pt [2,1]) (*see "fun detailrls"*);
1895 (*if length newnds = 12 then () WN060905*)
1896 if length newnds = 13 then ()
1897 else error "rational.sml: interSteps cancel_p rev_rew_p";
1899 val p = ([2,1,9],Res);
1901 val (_, tac, _) = pt_extract (pt, p);
1902 (*case tac of SOME (Rewrite ("sym_real_plus_binom_times1", _)) => ()
1904 case tac of SOME (Rewrite ("sym_real_add_mult_distrib2", _)) => ()
1905 | _ => error "rational.sml: getTactic, sym_real_plus_binom_times1";
1906 ============ inhibit exn 110314 ==============================================*)
1909 "-------- investigate rulesets for cancel_p -------------";
1910 "-------- investigate rulesets for cancel_p -------------";
1911 "-------- investigate rulesets for cancel_p -------------";
1912 val thy = @{theory "Rational"};
1913 "---------------- (a^^^2 + -1*b^^^2) / (a^^^2 + -2*a*b + b^^^2)";
1914 val t = str2term "(a^^^2 + -1*b^^^2) / (a^^^2 + -2*a*b + b^^^2)";
1915 val tt = str2term "(1 * a + 1 * b) * (1 * a + -1 * b)"(*numerator only*);
1916 "----- with rewrite_set_";
1917 val SOME (tt',asm) = rewrite_set_ thy false make_polynomial tt;
1918 term2str tt'= "a ^^^ 2 + -1 * b ^^^ 2" (*true*);
1919 val tt = str2term "((1 * a + -1 * b) * (1 * a + -1 * b))"(*denominator only*);
1920 val SOME (tt',asm) = rewrite_set_ thy false make_polynomial tt;
1921 term2str tt' = "a ^^^ 2 + -2 * a * b + b ^^^ 2" (*true*);
1923 "----- with make_deriv";
1924 val SOME (tt, _) = factout_p_ thy t; term2str tt =
1925 "(1 * a + 1 * b) * (1 * a + -1 * b) / ((1 * a + -1 * b) * (1 * a + -1 * b))";
1927 "--- with ruleset as before 060829";
1928 val {rules, rew_ord=(_,ro),...} =
1929 rep_rls (assoc_rls "make_polynomial");
1930 val der = make_deriv thy Atools_erls rules ro NONE tt;
1931 print_depth 99; map (term2str o #1) der; print_depth 3;
1932 print_depth 99; map (rule2str o #2) der; print_depth 3;
1933 ... did not terminate*)
1934 "--- with simpler ruleset";
1935 val {rules, rew_ord=(_,ro),...} =
1936 rep_rls (assoc_rls "rev_rew_p");
1937 val der = make_deriv thy Atools_erls rules ro NONE tt;
1938 print_depth 99; writeln (deriv2str der); print_depth 3;
1940 print_depth 99; map (term2str o #1) der; print_depth 3;
1941 "...,(-1 * b ^^^ 2 + a ^^^ 2) / (-2 * (a * b) + a ^^^ 2 + (-1 * b) ^^^ 2) ]";
1942 print_depth 99; map (rule2str o #2) der; print_depth 3;
1943 print_depth 99; map (term2str o #1 o #3) der; print_depth 3;
1945 val der = make_deriv thy Atools_erls rules ro NONE
1946 (str2term "(1 * a + 1 * b) * (1 * a + -1 * b)");
1947 print_depth 99; writeln (deriv2str der); print_depth 3;
1949 val {rules, rew_ord=(_,ro),...} =
1950 rep_rls (assoc_rls "rev_rew_p");
1951 val der = make_deriv thy Atools_erls rules ro NONE
1952 (str2term "(1 * a + -1 * b) * (1 * a + -1 * b)");
1953 print_depth 99; writeln (deriv2str der); print_depth 3;
1954 print_depth 99; map (term2str o #1) der; print_depth 3;
1955 (*WN060829 ...postponed*)
1958 "-------- investigate format of factout_ and factout_p_ -";
1959 "-------- investigate format of factout_ and factout_p_ -";
1960 "-------- investigate format of factout_ and factout_p_ -";
1961 val {rules, rew_ord = (_,ro),...} = rep_rls (assoc_rls "make_polynomial");
1962 val (thy, eval_rls) = (@{theory "Rational"}, Atools_erls)(*see 'fun init_state'*);
1963 val Rrls {scr = Rfuns {init_state,...},...} = assoc_rls "cancel_p";
1965 "----- see Rational.ML, local cancel_p, fun init_state";
1966 val t = str2term "(a^^^2 + (-1)*b^^^2) / (a^^^2 + (-2)*a*b + b^^^2)";
1967 val SOME (t',_) = factout_p_ thy t; term2str t';
1969 val rtas = reverse_deriv thy eval_rls rules ro NONE t';
1970 writeln(trtas2str rst);
1974 "----- see Rational.ML, local cancel_p, fun init_state";
1975 val t = str2term "a^^^2 / a";
1976 val SOME (t',_) = factout_p_ thy t;
1977 term2str t' = "a * a / (1 * a)" (*true*);
1978 (*... can be canceled with
1979 real_mult_div_cancel2 ?k ~= 0 ==> ?m * ?k / (?n * ?k) = ?m / ?n"*)
1980 (* sml/ME/rewtools.sml:
1981 val rtas = reverse_deriv thy Atools_erls rules ro NONE t';
1982 writeln (deri2str rtas);
1986 "-------- SK 060904 ----------------------------------------------";
1987 "----- order on polynomials -- input + output";
1988 val thy = @{theory "Isac"};
1989 val t = str2term "(a + -1 * b) / (-1 * a + b)";
1990 val SOME (t', _) = factout_p_ thy t; term2str t';
1991 val SOME (t', _) = cancel_p_ thy t; term2str t';
1993 val t = str2term "a*b*c*d / (d*e*f*g)";
1994 val SOME (t', _) = cancel_p_ thy t; term2str t';
1996 val t = str2term "a*(b*(c*d)) / (b*(e*(f*g)))";
1997 val SOME (t', _) = cancel_p_ thy t; term2str t';
2000 "----- SK060904-1a non-termination of cancel_p_ ? worked before 0707xx";
2001 val t = str2term "(x^^^2 - 4)*(3 - y) / ((y^^^2 - 9)*(2+x))";
2002 val SOME (t',_) = rewrite_set_ thy false norm_Rational t;
2003 if term2str t' = "(2 + -1 * x) / (3 + y)" then ()
2004 else error "rational.sml SK060904-1a worked since 0707xx";
2006 "----- SK060904-1b non-termination of cancel_p_ ... worked before 0707xx";
2007 val t = str2term ("(9 * a ^^^ 2 + -16 * b ^^^ 2) /" ^
2008 "(36 * a^^^2 * c + (27 * a^^^2 * e + (-64 * b^^^2 * c + -48 * b^^^2 * e)))");
2009 val SOME (t',_) = cancel_p_ thy t;
2010 if term2str t' = "1 / (4 * c + 3 * e)" then ()
2011 else error "rational.sml SK060904-1b";
2014 "----- SK060904-2a non-termination of add_fraction_p_";
2015 val t = str2term (" (a + b * x) / (a + -1 * (b * x)) + " ^
2016 " (-1 * a + b * x) / (a + b * x) ");
2018 val SOME (t',_) = rewrite_set_ thy false common_nominator_p t;
2020 common_nominator_p_ thy t;
2021 " (a + b * x)*(a + b * x) / ((a + -1 * (b * x))*(a + -1 * (b * x))) + " ^
2022 " (-1 * a + b * x)*(a + -1 * (b * x)) / ((a + b * x)*(-1 * a + b * x)) ";
2024 add_fraction_p_ thy t;
2025 " ((a + b * x)*(a + b * x) + (-1 * a + b * x)*(a + -1 * (b * x))) /" ^
2026 " ((a + b * x)*(-1 * a + b * x)) ";
2030 "-------- how to stepwise construct Scripts -------------";
2031 "-------- how to stepwise construct Scripts -------------";
2032 "-------- how to stepwise construct Scripts -------------";
2033 val thy = @{theory "Rational"};
2035 val p1 = parse thy (
2036 "Script SimplifyScript (t_t::real) = " ^
2037 " (Rewrite_Set discard_minus False " ^
2040 (*required (): (Rewrite_Set discard_minus False)*)
2041 val p2 = parse thy (
2042 "Script SimplifyScript (t_t::real) = " ^
2043 " (Rewrite_Set discard_minus False " ^
2046 val p3 = parse thy (
2047 "Script SimplifyScript (t_t::real) = " ^
2048 " ((Rewrite_Set discard_minus False) " ^
2051 val p4 = parse thy (
2052 "Script SimplifyScript (t_t::real) = " ^
2053 " ((Rewrite_Set discard_minus False) " ^
2056 val p5 = parse thy (
2057 "Script SimplifyScript (t_t::real) = " ^
2058 " ((Try (Rewrite_Set discard_minus False) " ^
2059 " Try (Rewrite_Set discard_parentheses False)) " ^
2062 val p6 = parse thy (
2063 "Script SimplifyScript (t_t::real) = " ^
2064 " ((Try (Rewrite_Set discard_minus False) @@ " ^
2065 " Try (Rewrite_Set rat_mult_poly False) @@ " ^
2066 " Try (Rewrite_Set make_rat_poly_with_parentheses False) @@ " ^
2067 " Try (Rewrite_Set cancel_p_rls False) @@ " ^
2069 " ((Try (Rewrite_Set common_nominator_p_rls False) @@ " ^
2070 " Try (Rewrite_Set rat_mult_div_pow False) @@ " ^
2071 " Try (Rewrite_Set make_rat_poly_with_parentheses False) @@" ^
2072 " Try (Rewrite_Set cancel_p_rls False) @@ " ^
2073 " Try (Rewrite_Set rat_reduce_1 False)))) @@ " ^
2074 " Try (Rewrite_Set discard_parentheses False)) " ^
2078 "----------- get_denominator ----------------------------";
2079 "----------- get_denominator ----------------------------";
2080 "----------- get_denominator ----------------------------";
2081 val thy = @{theory Isac};
2082 val t = term_of (the (parse thy "get_denominator ((a +x)/b)"));
2083 val SOME (_, t') = eval_get_denominator "" 0 t thy;
2084 if term2str t' = "get_denominator ((a + x) / b) = b" then ()
2085 else error "get_denominator ((a + x) / b) = b"
2087 "-------- build errpat fillpat --------------------------";
2088 "-------- build errpat fillpat --------------------------";
2089 "-------- build errpat fillpat --------------------------";