3 Copyright (c) Stefan Karnel 2002
4 Use is subject to license terms.
6 use"../smltest/IsacKnowledge/rational.sml";
10 nonterm.SK marks non-terminating examples
11 ord.SK PARTIALLY marks crucial ordering examples
12 *SK* of some (secondary) interest (on 070906)
13 ****************************************************************.*)
15 (******************************************************************
16 WN060104 transfer marked (*SR..*)examples to the exp-collection
17 # exp_IsacCore_Simp_Rat_Cancel.xml from rational.sml (*SRC*) 10 exp
18 # exp_IsacCore_Simp_Rat_Add.xml from rational.sml (*SRA*) 11 exp
19 # exp_IsacCore_Simp_Rat_Mult.xml from rational.sml (*SRM*) 5 exp
20 # exp_IsacCore_Simp_Rat_AddMult.xml from rational.sml (*SRAM*) 11 exp
21 # exp_IsacCore_Simp_Rat_Double.xml from rational.sml (*SRD*) 12 exp
22 *******************************************************************)
23 "-----------------------------------------------------------------";
24 "table of contents -----------------------------------------------";
25 "-----------------------------------------------------------------";
26 "~~~~~BEGIN: decomment structure RationalI : RATIONALI ~~~~~~~~~~~";
27 "-------- ... missing WN060103 -----------------------------------";
28 "-------- fun monom2term, fun poly2term' ------------------------";
29 "~~~~~END: decomment structure RationalI : RATIONALI ~~~~~~~~~~~~~";
30 "-------- cancel from: Mathematik 1 Schalk Reniets Verlag --------";
31 "-------- common_nominator_p ---------------------------- --------";
32 "-------- reverse rewrite ----------------------------------------";
33 "-------- 'reverse-ruleset' cancel_p -----------------------------";
34 "-------- norm_Rational ------------------------------------------";
35 "-------- numeral rationals --------------------------------------";
36 "-------- cancellation -------------------------------------------";
37 "-------- common denominator -------------------------------------";
38 "-------- multiply and cancel ------------------------------------";
39 "-------- common denominator and multiplication ------------------";
40 "-------- double fractions ---------------------------------------";
41 "-------- me Schalk I No.186 -------------------------------------";
42 "-------- interSteps ..Simp_Rat_Double_No-1.xml ------------------";
43 "-------- interSteps ..Simp_Rat_Cancel_No-1.xml ------------------";
44 "-------- investigate rulesets for cancel_p ----------------------";
45 "-------- investigate format of factout_ and factout_p_ ----------";
46 "-------- how to stepwise construct Scripts ----------------------";
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 (*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
67 print("\n\n********************* rational.sml - TESTS *************************\n\n");
68 print("\n\n***** divide tests *****\n");
69 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_)));
70 (* result: [(1,[0,0,1]),(1,[0,0,0])] *)
71 if mv_pquot1=[(1,[0,0,1]),(1,[0,0,0])] then () else error ("rational.sml: example failed");
73 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_)));
74 (* result: [(1,[1,0,1]),(~1,[0,0,1])] *)
75 if mv_prest1=[(1,[1,0,1]),(~1,[0,0,1])] then () else error ("rational.sml: example failed");
77 val mv_pquot2 = (#1(mv_division([(4,[2]),(8,[1]),(16,[0])],[(1,[1]),(1,[0])],LEX_)));
78 (* result: [(4,[1]),(4,[0])] *)
79 if mv_pquot2=[(4,[1]),(4,[0])] then () else error ("rational.sml: example failed");
81 val mv_prest2 = (#2(mv_division([(4,[2]),(8,[1]),(16,[0])],[(1,[1]),(1,[0])],LEX_)));
82 (* result: [(12,[0]] *)
83 if mv_prest2=[(12,[0])] then () else error ("rational.sml: example failed");
85 val mv_pquot3 = (#1(mv_division([(4,[2]),(~4,[0])],[(2,[1]),(2,[0])],LEX_)));
86 (* [(2,[1]),(~2,[0])] *)
87 if mv_pquot3=[(2,[1]),(~2,[0])] then () else error ("rational.sml: example failed");
89 val mv_prest3 = (#2(mv_division([(1,[2]),(~1,[0])],[(2,[1]),(2,[0])],LEX_)));
90 (* [(1,[2]),(~1,[0])] *)
91 if mv_prest3=[(1,[2]),(~1,[0])] then () else error ("rational.sml: example failed");
93 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_)));
95 if mv_pquot4=[(1,[0,1,1])] then () else error ("rational.sml: example failed");
97 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_)));
98 (* [(1,[1,1,1]),(~4,[0,1,2]),(4,[1,0,1]),(3,[0,0,1])] *)
99 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");
101 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_)));
102 (* [(1,[2,2,0]),(6,[2,1,2]),(3,[1,1,0]),(4,[1,0,0]),(4,[0,4,0]),(3,[0,0,0])]*)
103 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");
105 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_)));
107 if mv_prest5=[] then () else error ("rational.sml: example failed");
109 (* (x^2 + 2(a+1)x + (a^2+2a+1)) / (x+a+1) = x+a+1 *)
110 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_)));
111 if mv_pquot6=[(1,[1,0,0]),(1,[0,1,0]),(1,[0,0,0])] then () else error ("rational.sml: example failed");
113 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_)));
114 if mv_prest6=[] then () else error ("rational.sml: example failed");
117 print("\n\n***** MV_CONTENT-TESTS *****\n");
118 val mv_cont1=mv_content([(1,[2,1]),(1,[2,0]),(1,[1,1]),(1,[1,0]),(1,[0,1]),(1,[0,0])]);
119 (* [(1,[0,1]),(1,[0,0])] *)
120 if mv_cont1=[(1,[0,1]),(1,[0,0])] then () else error ("rational.sml: example failed");
122 val mv_pp1=mv_pp([(1,[1,1]),(1,[1,0]),(1,[0,1]),(1,[0,0])]);
123 (*[(1,[1,0]),(1,[0,0])]*)
124 if mv_pp1=[(1,[1,0]),(1,[0,0])] then () else error ("rational.sml: example failed");
126 val mv_cont2=mv_content([(2,[1]),(4,[0])]);
128 if mv_cont2=[(2,[0])] then () else error ("rational.sml: example failed");
130 val mv_pp2=mv_pp([(2,[1]),(4,[0])]);
131 (* [(1,[1]),(2,[0])] *)
132 if mv_pp2=[(1,[1]),(2,[0])] then () else error ("rational.sml: example failed");
134 val mv_cont3=mv_content[(8,[2,1,1]),(12,[1,0,2]),(10,[2,2,0]),(16,[1,1,1])];
136 if mv_cont3=[(2,[0,0,0])] then () else error ("rational.sml: example failed");
138 val mv_pp3=mv_pp[(8,[2,1,1]),(12,[1,0,2]),(10,[2,2,0]),(16,[1,1,1])];
139 (* [(5,[2,2,0]),(4,[2,1,1]),(8,[1,1,1]),(6,[1,0,2])] *)
140 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");
142 val mv_cont4=mv_content[(2,[2,1,0]),(3,[1,0,1]),(2,[1,1,0]),(3,[0,0,1])];
144 if mv_cont4=[(1,[0,0,0])] then () else error ("rational.sml: example failed");
146 val mv_pp4=mv_pp [(2,[2,1,0]),(3,[1,0,1]),(2,[1,1,0]),(3,[0,0,1])];
147 (* [(2,[2,1,0]),(2,[1,1,0]),(3,[1,0,1]),(3,[0,0,1])] *)
148 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");
150 val con1=mv_content([(9,[2,0]),(15,[1,1]),(12,[1,0]),(6,[0,2]),(12,[0,1])]);
152 if con1=[(3,[0,0])] then () else error ("rational.sml: example failed");
154 val pp1=mv_pp([(9,[2,0]),(15,[1,1]),(12,[1,0]),(6,[0,2]),(12,[0,1])]);
155 (* [(3,[2,0]),(5,[1,1]),(4,[1,0]),(2,[0,2]),(4,[0,1])] *)
156 if pp1=[(3,[2,0]),(5,[1,1]),(4,[1,0]),(2,[0,2]),(4,[0,1])] then () else error ("rational.sml: example failed");
158 val con2=mv_content([(1,[2,0]),(1,[1,1]),(1,[1,0]),(1,[0,2]),(1,[0,1])]);
160 if con2=[(1,[0,0])] then () else error ("rational.sml: example failed");
162 val pp2 =mv_pp([(1,[2,0]),(1,[1,1]),(1,[1,0]),(1,[0,2]),(1,[0,1])]);
163 (* [(1,[2,0]),(1,[1,1]),(1,[1,0]),(1,[0,2]),(1,[0,1])] *)
164 if pp2=[(1,[2,0]),(1,[1,1]),(1,[1,0]),(1,[0,2]),(1,[0,1])] then () else error ("rational.sml: example failed");
166 val cont1 = mv_content [(1,[2,1,0]),(2,[2,1,0])];
168 if cont1=[(3,[0,1,0])] then () else error ("rational.sml: example failed");
170 val pp1 = mv_pp [(1,[2,1,0]),(2,[2,1,0])];
172 if pp1=[(1,[2,0,0])] then () else error ("rational.sml: example failed");
174 val cont2 = mv_content [(4,[1,2,0]),(2,[2,1,0])];
176 if cont2=[(2,[0,1,0])] then () else error ("rational.sml: example failed");
178 val pp2 = mv_pp [(4,[1,2,0]),(2,[2,1,0])];
179 (* [(1,[2,0,0]),(2,[1,1,0])] *)
180 if pp2=[(1,[2,0,0]),(2,[1,1,0])] then () else error ("rational.sml: example failed");
182 print("\n\n\n\n********************************************************\n\n");
183 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])];
184 if cont3=[(5,[0,2,1]),(4,[0,2,0]),(2,[0,1,1])] then () else error ("rational.sml: example failed");
185 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])];
188 "-------- fun monom2term, fun poly2term' ------------------------";
189 "-------- fun monom2term, fun poly2term' ------------------------";
190 "-------- fun monom2term, fun poly2term' ------------------------";
191 val t = monom2term ((3,[2,1,0]), ["c","b","a"](*reverse ???SK-*));
192 term2str t = "3 * (c ^^^ 2 * b)" (*true*);
194 val t = monom2term ((1,[1,0]), ["b","a"]);
195 term2str t = "b" (*true*);
197 val t = poly2term ([(1,[0,0,0]),(2,[1,0,0]),(3,[2,1,0]),(4,[3,2,1])],
199 term2str t = "1 + 2 * c + 3 * (c ^^^ 2 * b) + 4 * (c ^^^ 3 * (b ^^^ 2 * a))";
201 val t = poly2term ([(1,[1,0]),(1,[0,1])], ["b","a"]);
202 term2str t = "a + b" (*true*);
205 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*)
206 "~~~~~END: decomment structure RationalI : RATIONALI ~~~~~~~~~~~~~";
207 "~~~~~END: decomment structure RationalI : RATIONALI ~~~~~~~~~~~~~";
208 "~~~~~END: decomment structure RationalI : RATIONALI ~~~~~~~~~~~~~";
211 fun parse_rat str = (term_of o the o (parse thy)) str;
213 print("\n\n***** mv_gcd-tests *****\n");
214 val ggt1 = mv_gcd [(4,[2,2]),(8,[1,1]),(4,[0,0])] [(2,[1,1]),(2,[0,0])];
215 (* [(2,[1,1]),(2,[0,0])] *)
216 if ggt1=[(2,[1,1]),(2,[0,0])] then () else error ("rational.sml: example failed");
218 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])];
219 (* [(2,[1,1,0]),(3,[0,0,1])] *)
220 if ggt2=[(2,[1,1,0]),(3,[0,0,1])] then () else error ("rational.sml: example failed");
223 val ggt3 = mv_gcd [(1,[2,0]),(~2,[1,1]),(1,[0,2])] [(1,[1,0]),(~1,[0,1])];
224 (* [(1,[1,0]),(~1,[0,1])] *)
225 if ggt3=[(1,[1,0]),(~1,[0,1])] then () else error ("rational.sml: example failed");
228 val ggt4 = mv_gcd [(1,[2,1,0]),(2,[2,1,0])] [(5,[1,0,0])];
230 if ggt4=[(1,[1,0,0])] then () else error ("rational.sml: example failed");
233 val ggt5 = mv_gcd [(4,[2,0]),(~8,[1,1]),(4,[0,2])] [(1,[2,0]),(~1,[0,2])];
234 (* [(1,[1,0]),(~1,[0,1])] *)
235 if ggt5=[(1,[1,0]),(~1,[0,1])] then () else error ("rational.sml: example failed");
238 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])];
240 if ggt6=[(1,[1,0,0])] then () else error ("rational.sml: example failed");
242 print("\n\n***** kgv-tests *****\n");
243 val kgv1=mv_lcm [(10,[])] [(15,[])];
245 if kgv1=[(30,[])] then () else error ("rational.sml: example failed");
247 val kgv2=mv_lcm [(1,[2,0]),(~2,[1,1]),(1,[0,2])] [(1,[1,0]),(~1,[0,1])];
248 (* [(1,[2,0]),(~2,[1,1]),(1,[0,2])] *)
249 if kgv2=[(1,[2,0]),(~2,[1,1]),(1,[0,2])] then () else error ("rational.sml: example failed");
251 val kgv3=mv_lcm [(4,[2,0]),(~8,[1,1]),(4,[0,2])] [(1,[2,0]),(~1,[0,2])];
252 (* [(4,[3,0]),(~4,[2,1]),(~4,[1,2]),(4,[0,3])] *)
253 if kgv3=[(4,[3,0]),(~4,[2,1]),(~4,[1,2]),(4,[0,3])] then () else error ("rational.sml: example failed");
256 print("\n\n***** STEP_CANCEL_TESTS: *****\n");
258 val term2 = (term_of o the o (parse thy)) " (9 * a^^^2 * b) / (6 * a * c)";
259 val div2 = term2str (step_cancel term2);
260 if div2 = "3 * (a * b) * (3 * a) / (2 * c * (3 * a))" then () else error ("rational.sml: example failed");
263 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";
264 val div1 = term2str(step_cancel term1);
265 if div1 = "(3 * c + 14 * b + 20 * (b ^^^ 2 * c) + 10 * (a * (b * c))) * a / (1 * a)" then () else error ("rational.sml: example failed");
267 val term3 = (term_of o the o (parse thy)) "(10 * a^^^2 * b * c) / (1 * x * y * z) ";
268 val div3 = term2str(step_cancel term3);
269 if div3="10 * a ^^^ 2 * b * c / (1 * x * y * z)" then () else error ("rational.sml: example failed");
271 --------------------------------------------------------------------------!!!*)
273 (*-----versuche 13.3.03-----
274 val t = str2term "1 - x^^^2 - 5 * x^^^5";
275 val vs=(((map free2str) o vars) t);
276 val SOME ml = expanded2poly t vs;
278 poly2term'(rev(sort (mv_geq LEX_) (ml)),vs);
279 poly2term'([(~5,[5]),(~1,[2]),(1,[0])], vs);
280 monom2term((~5,[5]),vs);
281 monom2term((~1,[2]),vs);
282 val t' = monom2term((1,[0]),vs);(*uncaught exception LIST*)
284 val (i,is) = (~1,[2]);
285 val ttt = Const ("op *", [HOLogic.realT,HOLogic.realT]---> HOLogic.realT) $
286 (Const ("uminus", HOLogic.realT --> HOLogic.realT) $
287 Free ((str_of_int o abs) i, HOLogic.realT)) $
288 powerproduct2term(is, vs);
290 -------versuche 13.3.03-----*)
292 val t = str2term "1 - x^^^2 - 5 * x^^^5";
293 val SOME t' = expanded2polynomial t; term2str t';
294 "1 + - 1 * x ^^^ 2 + - 5 * x ^^^ 5";
295 val t = str2term "1 - x";
296 val SOME t' = expanded2polynomial t; term2str t';
298 val t = str2term "1 + (-1) * x";
299 val SOME t' = expanded2polynomial t; term2str t';
301 val t = (term_of o the o (parse thy)) "1 + (-1) * x ^^^ 2 + (-5) * x ^^^5";
302 val SOME t' = polynomial2expanded t; term2str t';
303 "1 - x ^^^ 2 - 5 * x ^^^ 5";
306 " external calculating functions test ";
307 " external calculating functions test ";
308 " 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 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 " examples from: Mathematik 1 Schalk Reniets Verlag ";
468 " examples from: Mathematik 1 Schalk Reniets Verlag ";
469 " examples from: Mathematik 1 Schalk Reniets Verlag ";
472 "-------- cancel from: Mathematik 1 Schalk Reniets Verlag --------";
473 "-------- cancel from: Mathematik 1 Schalk Reniets Verlag --------";
474 "-------- cancel from: Mathematik 1 Schalk Reniets Verlag --------";
475 val thy' = "Rational";
477 val mp = "make_polynomial";
479 print("\n\nexample 186:\n");
481 val e186a'="(14 * x * y) / ( x * y )";(*SRC*)
482 val e186a = the (rewrite_set thy' false "cancel" e186a');
483 is_expanded (parse_rat "14 * x * y");
484 is_expanded (parse_rat "x * y");
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 e;
493 val t = (term_of o the o (parse thy)) e186c';
496 print("\n\nexample 187:\n");
498 val e187a'="(12 * x * y) / (8 * y^^^2 )";(*SRC*)
499 val e187a = the (rewrite_set thy' false "cancel" e187a');
501 val e187b'="(8 * x^^^2 * y * z ) / (18 * x * y^^^2 * z )";
502 val e187b = the (rewrite_set thy' false "cancel" e187b');
504 val e187c'="(9 * x^^^5 * y^^^2 * z^^^4) / (15 * x^^^6 * y^^^3 * z )";(*SRC*)
505 val e187c = the (rewrite_set thy' false "cancel" e187c');
508 val e188a'="(-8 + 8 * x) / (-9 + 9 * x)";(*SRC*)
509 val e188a = the (rewrite_set thy' false "cancel" e188a');
510 is_expanded (parse_rat "8 * x + -8");
511 (* e188a = ("8 / 9",["not ((-1) + x = 0)"]) then () 13.3.03*)
512 if e188a = ("8 / 9",["-1 + x ~= 0"]) then ()
513 else error "rational.sml: e188a new behaviour";
514 val SOME (t,_) = rewrite_set thy' false mp
515 "(8*((-1) + x))/(9*((-1) + x))";
517 val e188b'="(-15 + 5 * x) / (-18 + 6 * x)";(*SRC*)
518 val SOME (t,_) = rewrite_set thy' false "cancel" e188b';
519 t = "5 / 6" (*true*);
522 val e188c'="( a + -1 * b ) / ( b + -1 * a )";
523 val e188c = the (rewrite_set thy' false "cancel_p" e188c');
524 (*is_expanded (parse_rat "a + -1 * b");*)
526 rewrite_set thy' false mp "((-1)*(b + (-1) * a))/(1*(b + (-1) * a))";
527 if t= "(a + -1 * b) / (-1 * a + b)" then()
528 else error "rational.sml: e188c new behaviour";
530 print("\n\nexample 190:\n");
532 val e190c'="( 27 * a^^^3 + 9 * a^^^2 + 3 * a + 1 ) / ( 27 * a^^^3 + 18 * a^^^2 + 3 * a )";
533 val e190c = the (rewrite_set thy' false "cancel" e190c');
534 val SOME (t,_) = rewrite_set thy' false mp "((1 + 9 * a ^^^ 2)*(1 + 3 * a))/((3 * a + 9 * a ^^^ 2)*(1 + 3 * a))";
535 if t = "(1 + 3 * a + 9 * a ^^^ 2 + 27 * a ^^^ 3) /\n(3 * a + 18 * a ^^^ 2 + 27 * a ^^^ 3)" then ()
536 else error "rational.sml: e190c new behaviour";
538 print("\n\nexample 191:\n");
540 val e191a'="( x^^^2 + -1 * y^^^2 ) / ( x + y )";
542 val e191a = the (rewrite_set thy' false "cancel" e191a');
543 is_expanded (parse_rat "x^^^2 + -1 * y^^^2");
545 is_expanded (parse_rat "x + y");
547 val SOME (t,_) = rewrite_set thy' false mp "((x + (-1) * y)*(x + y))/((1)*(x + y))";
548 (* t="(x ^^^ 2 + -1 * y ^^^ 2) / (x + y)" then() WN.13.3.03*)
549 if t="(x ^^^ 2 + -1 * y ^^^ 2) / (x + y)" then()
550 else error "rational.sml: e191a new behaviour";
553 val e191c'="( 9 * x^^^2 + -30 * x + 25 ) / ( 9 * x^^^2 + -25 )";
555 val e191c = the (rewrite_set thy' false "cancel" e191c');
556 is_expanded (parse_rat "9 * x^^^2 + -30 * x + 25");
558 is_expanded (parse_rat "25 + -30*x + 9*x^^^2");
560 is_expanded (parse_rat "-25 + 9*x^^^2");
562 val SOME (t,_) = rewrite_set thy' false mp "(((-5) + 3 * x)*((-5) + 3 * x))/((5 + 3 * x)*((-5) + 3 * x))";
563 (* t="(25 + ((-30) * x + 9 * x ^^^ 2)) / ((-25) + 9 * x ^^^ 2)"then() 13.3.03*)
564 if t= "(25 + -30 * x + 9 * x ^^^ 2) / (-25 + 9 * x ^^^ 2)" then()
565 else error "rational.sml: 'e191c' new behaviour";
568 print("\n\nexample 192:\n");
570 val e192b'="( 7 * x^^^3 + -1 * x^^^2 * y ) / ( 7 * x * y^^^2 + -1 * y^^^3 )";
572 val e192b = the (rewrite_set thy' false "cancel" e192b');
573 -------------------*)
574 val SOME (t',_) = rewrite_set thy' false mp "((x ^^^ 2)*(7 * x + (-1) * y))/((y ^^^ 2)*(7 * x + (-1) * y))";
575 if t' = "(7 * x ^^^ 3 + -1 * x ^^^ 2 * y) / (7 * x * y ^^^ 2 + -1 * y ^^^ 3)"
576 (*"(-1 * y * x ^^^ 2 + 7 * x ^^^ 3) / (-1 * y ^^^ 3 + 7 * x * y ^^^ 2)"WN050929*)
577 then () else error "rational.sml: 'e192b' new behaviour";
578 (*^^^ works with MG's simplifier vvv*)
579 val t =str2term"((x ^^^ 2)*(7 * x + (-1) * y))/((y ^^^ 2)*(7 * x + (-1) * y))";
580 val SOME (t',_) = rewrite_set_ Isac.thy false make_polynomial t;
581 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";
584 print("\n\nexample 193:\n");
586 val e193a'="( x^^^2 + -6 * x + 9 ) / ( x^^^2 + -9 )";
588 val e193a = the (rewrite_set thy' false "cancel" e193a');
589 -------------------*)
591 val e193b'="( x^^^2 + -8 * x + 16 ) / ( 2 * x^^^2 + -32 )";
593 val e193b = the (rewrite_set thy' false "cancel" e193b');
595 val e193c'="( 2 * x + -50 * x^^^3 ) / ( 25 * x^^^2 + -10 * x + 1 )";
596 val SOME(t,_) = rewrite_set thy' false "cancel" e193c';
597 -------------------*)
599 val wn01 = "(-25 + 9*x^^^2)/(5 + 3*x)";
600 val SOME (t,_) = rewrite_set thy' false "cancel" wn01;
601 (* t = "((-5) + 3 * x) / 1" then () WN.13.3.03*)
602 if t = "(-5 + 3 * x) / 1" then ()
603 else error "rational.sml: new behav. in cancel wn01";
606 "-------- common_nominator_p ---------------------------- --------";
607 "-------- common_nominator_p ---------------------------- --------";
608 "-------- common_nominator_p ---------------------------- --------";
609 val rls' = "common_nominator_p";
611 print("\n\nexample 204:\n");
613 val e204a'="((5 * x) / 9) + ((3 * x) / 9) + (x / 9)";
614 val e204a = the (rewrite_set thy' false "common_nominator_p" e204a');
616 val e204b'="5 / x + -3 / x + -1 / x";
617 val e204b = the (rewrite_set thy' false "common_nominator_p" e204b');
619 print("\n\nexample 205:\n");
621 val e205a'="((4 * x + 7) / 8) + ((4 * x + 3) / 8)";
622 val e205a = the (rewrite_set thy' false "common_nominator_p" e205a');
624 val e205b'="((5 * x + 2) / 3) + ((-2 * x + 1) / 3)";
625 val e205b = the (rewrite_set thy' false "common_nominator_p" e205b');
627 print("\n\nexample 206:\n");
629 val e206a'="((5 * x + 4) / (2 * x + -1)) + ((9 * x + 5) / (2 * x + -1))";
630 val e206a = the (rewrite_set thy' false "common_nominator_p" e206a');
632 val e206b'="((17 * x + -23) / (5 * x + 4)) + ((-25 + -17 * x) / (5 * x + 4))";
633 val e206b = the (rewrite_set thy' false "common_nominator_p" e206b');
635 print("\n\nexample 207:\n");
636 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)) ";
637 val e207 = the (rewrite_set thy' false "common_nominator_p" e207');
639 print("\n\nexample 208:\n");
640 val e208'="((3 * x + 2) / (x + 2)) + ((5 * x + -1) / (x + 2)) + ((-7 * x + -3) / (x + 2)) + ((-1 * x + -3) / (x + 2)) ";
641 val e208 = the (rewrite_set thy' false "common_nominator_p" e208');
643 print("\n\nexample 209:\n");
644 val e209'="((3 * x + -7 * y + 3 * z) / (4)) + ((2 * x + 17 * y + 10 * z) / (4)) + ((-1 * x + 2 * y + z) / (4)) ";
645 val e209 = the (rewrite_set thy' false "common_nominator_p" e209');
647 print("\n\nexample 210:\n");
648 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)) ";
649 val e210 = the (rewrite_set thy' false "common_nominator_p" e210');
651 print("\n\nexample 211:\n");
653 val e211a'="((b) / (a + -1 * b)) + ((-1 * a) / (a + -1 * b))";
654 val e211a = the (rewrite_set thy' false "common_nominator_p" e211a');
656 val e211b'="((b) / (b^^^2 + -1 * a^^^2)) + ((-1 * a) / (b^^^2 + -1 * a^^^2))";
657 val e211b = the (rewrite_set thy' false "common_nominator_p" e211b');
659 print("\n\nexample 212:\n");
661 val e212a'="((4) / (x)) + ((-3) / (y)) + -1";
662 val e212a = the (rewrite_set thy' false "common_nominator_p" e212a');
664 val e212b'="((4) / (x)) + ((-5) / (y)) + ((6) / (x*y))";
665 val e212b = the (rewrite_set thy' false "common_nominator_p" e212b');
667 print("\n\nexample 213:\n");
669 val e213a'="((5 * x) / (3 * y^^^2)) + ((19 * z) / (6 * x * y)) + ((-2 * x) / (3 * y^^^2)) + ((7 * y^^^2) / (6 * x^^^2)) ";
670 val e213a = the (rewrite_set thy' false "common_nominator_p" e213a');
672 val e213b'="((2 * b) / (3 * a^^^2)) + ((3 * c) / (7 * a * b)) + ((4 * b) / (3 * a^^^2)) + ((3 * a) / (7 * b^^^2))";
673 val e213b = the (rewrite_set thy' false "common_nominator_p" e213b');
675 print("\n\nexample 214:\n");
677 val e214a'="((3 * x + 2 * y + 2 * z) / (4)) + ((-5 * x + -3 * y) / (3)) + ((x + y + -2 * z) / (2))";
678 val e214a = the (rewrite_set thy' false "common_nominator_p" e214a');
680 val e214b'="((5 * x + 2 * y + z) / (2)) + ((-7 * x + -3 * y) / (3)) + ((3 * x + 6 * y + -1 * z) / (12))";
681 val e214b = the (rewrite_set thy' false "common_nominator_p" e214b');
683 print("\n\nexample 216:\n");
685 val e216a'="((2 * b + 3 * c) / (a * c)) + ((3 * a + b) / (a * b)) + ((-2 * b^^^2 + -3 * a * c) / (a * b * c))";
686 val e216a = the (rewrite_set thy' false "common_nominator_p" e216a');
688 val e216b'="((2 * a + 3 * b) / (b * c)) + ((3 * c + a) / (a * c)) + ((-2 * a^^^2 + -3 * b * c) / (a * b * c))";
689 val e216b = the (rewrite_set thy' false "common_nominator_p" e216b');
691 print("\n\nexample 217:\n");
692 val e217'="((z + -1) / (z)) + ((3 * z ^^^2 + -6 * z + 5) / (z^^^2)) + ((-4 * z^^^3 + 7 * z^^^2 + -5 * z + 5) / (z^^^3))";
693 val e217 = the (rewrite_set thy' false "common_nominator_p" e217');
696 val rls' = "common_nominator";
697 print("\n\nexample 218:\n");
698 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))";
699 val e218 = the (rewrite_set thy' false "common_nominator" e218');
701 print("\n\nexample 219:\n");
703 val e219a'="((1) / (y + 1)) + ((1) / (y + 2)) + ((1) / (y + 3))";
704 val e219a = the (rewrite_set thy' false "common_nominator" e219a');
706 val e219b'="((1) / (x + 1)) + ((1) / (x + 2)) + ((-2) / (x + 3))";
707 val e219b = the (rewrite_set thy' false "common_nominator" e219b');
709 print("\n\nexample 220:\n");
711 val e220a'="((17) / (5 * r + -2)) + ((-13) / (2 * r + 3)) + ((4) / (3 * r + -5))";
712 val e220a = the (rewrite_set thy' false "common_nominator" e220a');
714 val e220b'="((20 * a) / (a + -3)) + ((-19 * a) / (a + -4)) + ((a) / (a + -5))";
715 val e220b = the (rewrite_set thy' false "common_nominator" e220b');
717 print("\n\nexample 221:\n");
719 val e221a'="((a + b) / (a + -1 * b)) + ((a + -1 * b) / (a + b))";
720 val e221a = the (rewrite_set thy' false "common_nominator" e221a');
722 val e221b'="((x + -1 * y) / (x + y)) + ((x + y) / (x + -1 * y)) ";
723 val e221b = the (rewrite_set thy' false "common_nominator" e221b');
725 print("\n\nexample 222:\n");
727 val e222a'="((1 + -1 * x) / (1 + x)) + ((-1 + -1 * x) / (1 + -1 * x)) + ((4 * x) / (1 + -1 * x^^^2))";
728 val e222a = the (rewrite_set thy' false "common_nominator" e222a');
730 val e222b'="((1 + x ) / (1 + -1 * x)) + ((-1 + x) / (1 + x)) + ((2 * x) / (1 + -1 * x^^^2))";
731 val e222b = the (rewrite_set thy' false "common_nominator" e222b');
733 print("\n\nexample 225:\n");
735 val e225a'="((6 * a) / (a^^^2 + -64)) + ((a + 2) / (2 * a + 16)) + ((-1) / (2))";
736 val e225a = the (rewrite_set thy' false "common_nominator" e225a');
738 val e225b'="((a + 2 ) / (2 * a + 12)) + ((4 * a) / (a^^^2 + -36)) + ((-1) / (2))";
739 val e225b = the (rewrite_set thy' false "common_nominator" e225b');
741 print("\n\nexample 226:\n");
743 val e226a'="((35 * z) / (49 * z^^^2 + -4)) + -1 + ((14 * z + -1) / (14 * z + 4)) ";
744 val e226a = the (rewrite_set thy' false "common_nominator" e226a');
746 val e226b'="((45 * a * b) / (25 * a^^^2 + -9 * b^^^2)) + ((20 * a + 3 * b) / (10 * a + 6 * b)) + -2";
747 val e226b = the (rewrite_set thy' false "common_nominator" e226b');
749 print("\n\nexample 227:\n");
751 val e227a'="((6 * z + 11) / (6 * z + 14)) + ((9 * z ) / (9 * z^^^2 + -49)) + -1 ";
752 val e227a = the (rewrite_set thy' false "common_nominator" e227a');
754 val e227b'="((16 * a + 37 * b) / (4 * a + 10 * b)) + ((6 * a * b) / (4 * a^^^2 + -25 * b^^^2)) + -4 ";
755 val e227b = the (rewrite_set thy' false "common_nominator" e227b');
757 print("\n\nexample 228:\n");
759 val e228a'="((7 * a + 11) / (3 * a^^^2 + -3)) + ((-2 * a + -1) / (a^^^2 + -1 * a)) + ((-1) / (3 * a + 3))";
760 val e228a = the (rewrite_set thy' false "common_nominator" e228a');
762 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))";
763 val e228b = the (rewrite_set thy' false "common_nominator" e228b');
766 print("\n\nexample 229:\n");
768 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))";
769 val e229a = the (rewrite_set thy' false "common_nominator" e229a');
771 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))";
772 val e229b = the (rewrite_set thy' false "common_nominator" e229b');
774 print("\n\nexample 230:\n");
776 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))";
777 val e230a = the (rewrite_set thy' false "common_nominator" e230a');
779 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))";
780 val e230b = the (rewrite_set thy' false "common_nominator" e230b');
782 print("\n\nexample 231:\n");
784 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))";
785 val e231a = the (rewrite_set thy' false "common_nominator" e231a');
787 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))";
788 val e231b = the (rewrite_set thy' false "common_nominator" e231b');
790 print("\n\nexample 232:\n");
792 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))";
793 val e232a = the (rewrite_set thy' false "common_nominator" e232a');
795 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))";
796 val e232b = the (rewrite_set thy' false "common_nominator" e232b');
798 print("\n\nexample 233:\n");
800 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))";
801 val e233a = the (rewrite_set thy' false "common_nominator" e233a');
803 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))";
804 val e233b = the (rewrite_set thy' false "common_nominator" e233b');
806 print("\n\nexample 234:\n");
808 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))";
809 val e234a = the (rewrite_set thy' false "common_nominator" e234a');
811 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)) ";
812 val e234b = the (rewrite_set thy' false "common_nominator" e234b');
814 print("\n\nexample 235:\n");
816 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))";
817 val e235a = the (rewrite_set thy' false "common_nominator" e235a');
819 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)) ";
820 val e235b = the (rewrite_set thy' false "common_nominator" e235b');
822 print("\n\nexample 236:\n");
824 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))";
825 val e236a = the (rewrite_set thy' false "common_nominator" e236a');
827 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)) ";
828 val e236b = the (rewrite_set thy' false "common_nominator" e236b');
832 print("\n\nexample heuberger:\n");
833 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)";
834 val eheu = the (rewrite_set thy' false "cancel" eheu');
836 val rls' = "common_nominator_p";
837 print("\n\nexample stiefel:\n");
838 val est1'="(7) / (-14) + (-2) / (4)";
839 val est1 = the (rewrite_set thy' false "common_nominator_p" est1');
840 if est1 = ("-1 / 1",[]) then ()
841 else error "new behaviour in rational.sml: est1'";
843 val t = (term_of o the o (parse thy))
844 "(9 - x ^^^ 2) / (9 - 6 * x + x ^^^ 2)";
845 val SOME (t',_) = factout_ thy t;
847 "(3 + x) * (3 - x) / ((3 - x) * (3 - x))";
850 "-------- reverse rewrite ----------------------------------------";
851 "-------- reverse rewrite ----------------------------------------";
852 "-------- reverse rewrite ----------------------------------------";
854 (*WN.28.8.02: tests for the 'reverse-rewrite' functions:
855 these are defined in Rationals.ML and stored in
856 the 'reverse-ruleset' cancel*)
858 (*the term for which reverse rewriting is demonstrated*)
859 val t = (term_of o the o (parse thy))
860 "(9 - x ^^^ 2) / (9 + 6 * x + x ^^^ 2)";
861 val Rrls {scr=Rfuns {init_state=ini,locate_rule=loc,
862 next_rule=nex,normal_form=nor,...},...} = cancel;
864 (*normal_form produces the result in ONE step*)
865 val SOME (t',_) = nor t;
868 (*initialize the interpreter state used by the 'me'*)
869 val (t,_,revsets,_) = ini t;
871 (*find the rule 'r' to apply to term 't'*)
872 val SOME r = nex revsets t;
873 (*val r = Thm ("sym_#mult_2_3","6 = 2 * 3") : rule*)
875 (*check, if the rule 'r' applied by the user to 't' belongs to the ruleset;
876 if the rule is OK, the term resulting from applying the rule is returned,too;
877 there might be several rule applications inbetween,
878 which are listed after the head in reverse order*)
879 val (r,(t,asm))::_ = loc revsets t r;
881 "(9 - x ^^^ 2) / (3 ^^^ 2 + 6 * x + x ^^^ 2)";
883 (*find the next rule to apply*)
884 val SOME r = nex revsets t;
885 (*val r = Thm ("sym_#power_3_2","9 = 3 ^^^ 2") : rule*)
887 (*check the next rule*)
888 val (r,(t,asm))::_ = loc revsets t r;
890 "(3 ^^^ 2 - x ^^^ 2) / (3 ^^^ 2 + 6 * x + x ^^^ 2)";
892 (*find and check the next rules, rewrite*)
893 val SOME r = nex revsets t;
894 val (r,(t,asm))::_ = loc revsets t r;
896 "(3 ^^^ 2 - x ^^^ 2) / (3 ^^^ 2 + 2 * 3 * x + x ^^^ 2)";
898 val SOME r = nex revsets t;
899 val (r,(t,asm))::_ = loc revsets t r;
901 "(3 - x) * (3 + x) / (3 ^^^ 2 + 2 * 3 * x + x ^^^ 2)";
903 val SOME r = nex revsets t;
904 val (r,(t,asm))::_ = loc revsets t r;
906 "(3 - x) * (3 + x) / ((3 + x) * (3 + x))";
908 val SOME r = nex revsets t;
909 val (r,(t,asm))::_ = loc revsets t r;
911 if ss = "(3 - x) / (3 + x)" then ()
912 else error "rational.sml: new behav. in rev-set cancel";
916 "-------- 'reverse-ruleset' cancel_p -----------------------------";
917 "-------- 'reverse-ruleset' cancel_p -----------------------------";
918 "-------- 'reverse-ruleset' cancel_p -----------------------------";
919 (*WN.11.9.02: the 'reverse-ruleset' cancel_p*)
921 (*the term for which reverse rewriting is demonstrated*)
922 val t = str2term "(9 + (-1)*x^^^2) / (9 + ((-6)*x + x^^^2))";
923 val Rrls {scr=Rfuns {init_state=ini,locate_rule=loc,
924 next_rule=nex,normal_form=nor,...},...} = cancel_p;
926 (*normal_form produces the result in ONE step*)
927 val SOME (t',_) = nor t;
928 term2str t' = "(3 + 1 * x) / (3 + -1 * x)";
930 (*initialize the interpreter state used by the 'me'*)
931 val SOME (t', asm) = cancel_p_ thy t;
932 term2str t' = "(3 + x) / (3 + -1 * x)" (*true*);
933 terms2str asm = "[\"3 + -1 * x ~= 0\"]" (*true*);
934 val (t,_,revsets,_) = ini t;
936 (* WN.10.10.02: dieser Fall terminiert nicht
937 (make_polynomial enth"alt zu viele rules)
938 WN060823 'init_state' requires rewriting on specified location in the term
939 print_depth 99; Rfuns; print_depth 3;
940 WN060831 cycling "sym_order_mult_rls_" "sym_real_mult_assoc"
941 as was with make_polynomial before ?!?*)
943 val SOME r = nex revsets t;
944 eq_Thm (r, Thm ("sym_#power_Float ((3,0), (0,0)) __ ((2,0), (0,0))",
945 mk_thm Rational.thy "9 = 3 ^^^ 2"));
946 (*WN060831 *** id_of_thm
947 Exception- ERROR raised ...
948 val (r,(t,asm))::_ = loc revsets t r;
951 val SOME r = nex revsets t;
952 val (r,(t,asm))::_ = loc revsets t r;
956 print "\n\n\n****************** all tests successfull *************************\n";
960 (*WN.17.3.03 =========================================================vvv---*)
961 "-------- norm_Rational ------------------------------------------";
962 "-------- norm_Rational ------------------------------------------";
963 "-------- norm_Rational ------------------------------------------";
964 val t = str2term "(3*x+5)/18 - x/2 - -(3*x - 2)/9 = 0";
965 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
966 if term2str t' = "1 / 18 = 0" then () else error "rational.sml 1";
968 val t = str2term "(17*x - 51)/9 - (-(13*x - 3)/6) + 11 - (9*x - 7)/4 = 0";
969 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
970 if term2str t' = "(237 + 65 * x) / 36 = 0" then ()
971 else error "rational.sml 2";
973 val t = str2term "(1/2 + (5*x)/2)^^^2 - ((13*x)/2 - 5/2)^^^2 - (6*x)^^^2 + 29";
974 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
975 (*before 040209:if term2str t' = "(23 + (35 * x + -72 * x ^^^ 2)) / 1"then()*)
976 if term2str t' = "23 + 35 * x + -72 * x ^^^ 2" then ()
977 else error "rational.sml 3";
978 (*trace_rewrite:=true;*)
979 val t = str2term "Not (6*x is_atom)";
980 val SOME (t',_) = rewrite_set_ thy false powers_erls t; term2str t';
982 val t = str2term "1 < 2";
983 val SOME (t',_) = rewrite_set_ thy false powers_erls t; term2str t';
985 val t = str2term "(6*x)^^^2";
986 val SOME (t',_) = rewrite_ thy dummy_ord powers_erls false
987 (num_str @{thm realpow_def_atom) t;
989 trace_rewrite:=false;
991 val t = str2term "-1 * (-2 * (5 / 2 * (13 * x / 2)))";
992 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
993 if term2str t' = "65 * x / 2" then () else error "rational.sml 4";
995 val t = str2term "1 - ((13*x)/2 - 5/2)^^^2";
996 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
997 (*bef.040209: if term2str t' = "(-21 + (130 * x + -169 * x ^^^ 2)) / 4"then()*)
998 if term2str t' = "(-21 + 130 * x + -169 * x ^^^ 2) / 4" then ()
999 else error "rational.sml 5";
1001 (*SRAM Schalk I, p.92 Nr. 609a*)
1002 val t = str2term "2*(3 - x/5)/3 - 4*(1 - x/3) - x/3 - 2*(x/2 - 1/4)/27 +5/54";
1003 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
1004 if term2str t' = "(-255 + 112 * x) / 135" then ()
1005 else error "rational.sml 6";
1007 (*SRAM Schalk I, p.92 Nr. 610c*)
1008 val t = str2term "((x- 1)/(x+1) + 1) / ((x- 1)/(x+1) - (x+1)/(x- 1)) - 2";
1009 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
1010 if term2str t' = "(-3 + -1 * x) / 2" then () else error "rational.sml 7";
1012 (*SRAM Schalk I, p.92 Nr. 476a*)
1013 val t = str2term "(x^^^2/(1 - x^^^2) + 1)/(x/(1 - x) + 1) *\
1014 \ (1 + x)";(*. a/b : c/d translated to a/b * d/c .*)
1015 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
1016 (*if term2str t' = "1 / 1" then () else error "rational.sml 8";3.6.03*)
1017 if term2str t' = "1" then () else error "rational.sml 8";
1019 (*............................vvv---TODO: sollte gehen mit poly_order *)
1020 (*Schalk I, p.92 Nr. 472a*)
1021 val t = str2term "((8*x^^^2 - 32*y^^^2)/(2*x + 4*y))/((4*x - 8*y)/(x + y))";
1022 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
1023 if term2str t' = "x + y" then () else error "rational.sml p.92 Nr. 472a";
1025 (*Schalk I, p.70 Nr. 480b; a/b : c/d translated to a/b * d/c*)
1026 val t = str2term "((12*x*y/(9*x^^^2 - y^^^2))/\
1027 \(1/(3*x - y)^^^2 - 1/(3*x + y)^^^2)) *\
1028 \(1/(x - 5*y)^^^2 - 1/(x + 5*y)^^^2)/\
1029 \(20*x*y/(x^^^2 - 25*y^^^2))";
1030 (*... nicht simpl, zerlegt ...*)
1031 val t = str2term "((12*x*y/(9*x^^^2 - y^^^2))/\
1032 \(1/(3*x - y)^^^2 - 1/(3*x + y)^^^2))";
1033 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
1034 "(-12 * (x * y ^^^ 3) + 108 * (x * (y * x ^^^ 2))) / (12 * (x * y))";
1035 (* ~~~~~~~~~~ poly_order notwendig!*)
1036 val t = str2term "(1/(x - 5*y)^^^2 - 1/(x + 5*y)^^^2)/\
1037 \(20*x*y/(x^^^2 - 25*y^^^2))";
1038 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
1039 "(-500 * (x * y ^^^ 3) /\n (x ^^^ 4 + (625 * y ^^^ 4 + -50 * (x ^^^ 2 * y ^^^ 2))) +\n 20 * (x * (y * x ^^^ 2)) /\n (x ^^^ 4 + (625 * y ^^^ 4 + -50 * (x ^^^ 2 * y ^^^ 2)))) /\n(20 * (x * y))";
1040 trace_rewrite:=true;
1041 trace_rewrite:=false;
1043 "nonterm.SK6 ----- SK060904-2a non-termination of add_fraction_p_";
1044 (*WN.2.6.03 from rlang.sml 56a
1045 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)";
1046 val NONE = rewrite_set_ thy false common_nominator_p t;
1048 WN060831 nonterm.SK7
1049 val t = str2term "(a + b * x) / (a + -1 * (b * x)) + (-1 * a + b * x) / (a + b * x)";
1050 val NONE = add_fraction_p_ thy t;
1054 (* ------------------------------------------------------------------- *)
1055 (*---------vvv------------ MG: ab 1.7.03 ----------------vvv-----------*)
1056 (* Simplifier fuer beliebige Buchterme *)
1057 (* ------------------------------------------------------------------- *)
1058 (*----------------------- norm_Rational_mg ----------------------------*)
1059 (* ------------------------------------------------------------------- *)
1061 "-------- numeral rationals --------------------------------------";
1062 "-------- numeral rationals --------------------------------------";
1063 "-------- numeral rationals --------------------------------------";
1065 (*SRA Schalk I, p.40 Nr. 164b *)
1066 val t = str2term "(47/6 - 76/9 + 13/4)/(35/12)";
1067 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1069 if (term2str t) = "19 / 21" then ()
1070 else error "rational.sml.sml: diff.behav. in norm_Rational_mg 1";
1072 (*SRA Schalk I, p.40 Nr. 166a *)
1073 val t = str2term "((5/4)/(4+22/7) + 37/20)*(110/3 - 110/9 * 23/11)";
1074 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1076 if (term2str t) = "45 / 2" then ()
1077 else error "rational.sml.sml: diff.behav. in norm_Rational_mg 2";
1080 "-------- cancellation -------------------------------------------";
1081 "-------- cancellation -------------------------------------------";
1082 "-------- cancellation -------------------------------------------";
1084 (* e190c Stefan K.*)
1086 "((1 + 9 * a ^^^ 2)*(1 + 3 * a))/((3 * a + 9 * a ^^^ 2)*(1 + 3 * a))";
1087 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1090 "(1 + 9 * a ^^^ 2) / (3 * a + 9 * a ^^^ 2)"
1092 else error "rational.sml.sml: diff.behav. in norm_Rational_mg 3";
1094 (* e192b Stefan K.*)
1096 "((x ^^^ 2)*(7 * x + (-1) * y))/((y ^^^ 2)*(7 * x + (-1) * y))";
1097 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1102 else error "rational.sml.sml: diff.behav. in norm_Rational_mg 4";
1104 (*SRC Schalk I, p.66 Nr. 379c *)
1107 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1112 else error "rational.sml.sml: diff.behav. in norm_Rational_mg 5";
1114 (*SRC Schalk I, p.66 Nr. 380b *)
1116 "15*(3*x+3)*(4*x+9)/(12*(2*x+7)*(5*x+5))";
1117 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1120 "(27 + 12 * x) / (28 + 8 * x)"
1122 else error "rational.sml.sml: diff.behav. in norm_Rational_mg 6";
1124 (*Schalk I, p.60 Nr. 215c *)
1125 (* Falsches Ergebnis: rechnet lange und cancel_p kann nicht weiter krzen!!!*)
1127 val t = str2term "(a+b)^^^4*(x - y)/((x - y)^^^3*(a+b)^^^2)";
1128 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1131 "(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)"
1133 else error "rational.sml.sml: diff.behav. in norm_Rational_mg 7";
1136 "(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)"
1137 val SOME (t,_) = rewrite_set_ thy false cancel_p t;
1139 (* uncaught exception nonexhaustive binding failure
1140 raised at: stdIn:93.1-93.51 *)
1142 (*Schalk I, p.66 Nr. 381a *)
1143 (* ACHTUNG: rechnet ca. 2 Minuten !!! *)
1145 val t = str2term "18*(a+b)^^^3*(a - b)^^^2/(72*(a - b)^^^3*(a+b)^^^2)";
1146 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1149 "(a + b) / (4 * a + -4 * b)"
1150 then () else error "rational.sml.sml: diff.behav. in norm_Rational_mg 8";
1153 (*SRC Schalk I, p.66 Nr. 381b *)
1155 "(4*x^^^2 - 20*x + 25)/(2*x - 5)^^^3";
1156 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1161 else error "rational.sml.sml: diff.behav. in norm_Rational_mg 9";
1163 (*SRC Schalk I, p.66 Nr. 381c *)
1165 "(27*a^^^3+9*a^^^2+3*a+1)/(27*a^^^3+18*a^^^2+3*a)";
1166 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1169 "(1 + 9 * a ^^^ 2) / (3 * a + 9 * a ^^^ 2)"
1171 else error "rational.sml.sml: diff.behav. in norm_Rational_mg 10";
1173 (*SRC Schalk I, p.66 Nr. 383a *)
1175 "(5*a^^^2 - 5*a*b)/(a - b)^^^2";
1176 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1179 "5 * a / (a + -1 * b)"
1181 else error "rational.sml.sml: diff.behav. in norm_Rational_mg 11";
1183 "-------- common denominator -------------------------------------";
1184 "-------- common denominator -------------------------------------";
1185 "-------- common denominator -------------------------------------";
1187 (*SRA Schalk I, p.67 Nr. 403a *)
1190 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1193 "(-3 * x + 4 * y + -1 * x * y) / (x * y)"
1195 else error "rational.sml.sml: diff.behav. in norm_Rational_mg 12";
1197 (*SRA Schalk I, p.67 Nr. 407b *)
1199 "(2*a+3*b)/(b*c) + (3*c+a)/(a*c) - (2*a^^^2+3*b*c)/(a*b*c)";
1200 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1205 else error "rational.sml.sml: diff.behav. in norm_Rational_mg 13";
1207 (*SRA Schalk I, p.67 Nr. 410b *)
1209 "1/(x+1) + 1/(x+2) - 2/(x+3)";
1210 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1213 "(5 + 3 * x) / (6 + 11 * x + 6 * x ^^^ 2 + x ^^^ 3)"
1215 else error "rational.sml.sml: diff.behav. in norm_Rational_mg 14";
1217 (*SRA Schalk I, p.67 Nr. 413b *)
1219 "(1+x)/(1 - x) - (1 - x)/(1+x) + 2*x/(1 - x^^^2)";
1220 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1223 "6 * x / (1 + -1 * x ^^^ 2)"
1225 else error "rational.sml.sml: diff.behav. in norm_Rational_mg 15";
1227 (*SRA Schalk I, p.68 Nr. 414a *)
1229 "(x + 2)/(x - 1) + (x - 3)/(x - 2) - (x + 1)/((x - 1)*(x - 2))";
1230 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1233 "(-2 + -5 * x + 2 * x ^^^ 2) / (2 + -3 * x + x ^^^ 2)"
1235 else error "rational.sml.sml: diff.behav. in norm_Rational_mg 16";
1237 (*SRA Schalk I, p.68 Nr. 423a *)
1239 "(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)";
1240 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1245 else error "rational.sml.sml: diff.behav. in norm_Rational_mg 17";
1247 (*SRA Schalk I, p.68 Nr. 428b *)
1249 "1/(a - b)^^^2 + 1/(a+b)^^^2 - 2/(a^^^2 - b^^^2) - 4*(b^^^2 - 1)/(a^^^2 - b^^^2)^^^2";
1250 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1253 "4 / (a ^^^ 4 + -2 * a ^^^ 2 * b ^^^ 2 + b ^^^ 4)"
1255 else error "rational.sml.sml: diff.behav. in norm_Rational_mg 18";
1257 (*SRA Schalk I, p.68 Nr. 430b *)
1259 "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";
1260 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1265 else error "rational.sml.sml: diff.behav. in norm_Rational_mg 19";
1268 (*SRA Schalk I, p.68 Nr. 432 *)
1270 "(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)";
1271 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1276 else error "rational.sml.sml: diff.behav. in norm_Rational_mg 20";
1281 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1284 "(3 * y + b * x) / (b * y)"
1286 else error "rational.sml.sml: diff.behav. in norm_Rational_mg 21";
1289 "-------- multiply and cancel ------------------------------------";
1290 "-------- multiply and cancel ------------------------------------";
1291 "-------- multiply and cancel ------------------------------------";
1293 (*SRM Schalk I, p.68 Nr. 436a *)
1295 "3*(x+y)/(15*(x - y)) * 25*(x - y)^^^2/(18*(x+y)^^^2)";
1296 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1299 "(5 * x + -5 * y) / (18 * x + 18 * y)"
1301 else error "rational.sml.sml: diff.behav. in norm_Rational_mg 22";
1303 (*SRM.test Schalk I, p.68 Nr. 436b *)
1304 (*WN060420???MG3 crashes with method 'simplify' in
1305 IsacCore > Simplification > Rational Terms > Multiplication > No.2*)
1306 val t = str2term "5*a*(a - b)^^^2*(a + b)^^^3/(7*b*(a - b)^^^3) * 7*b/(a + b)^^^3";
1307 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1310 "5 * a / (a + -1 * b)"
1312 else error "rational.sml.sml: diff.behav. in norm_Rational_mg 23";
1314 (*Schalk I, p.68 Nr. 437a *)
1315 val t = str2term "(3*a - 4*b)/(4*c+3*e) * (3*a+4*b)/(9*a^^^2 - 16*b^^^2)";
1316 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1317 if (term2str t) = "1 / (4 * c + 3 * e)" then ()
1318 else error "rational.sml.sml: diff.behav. in norm_Rational_mg 24";
1320 "----- S.K. corrected non-termination 060904";
1321 val t = str2term "(3*a - 4*b) * (3*a+4*b)/((4*c+3*e)*(9*a^^^2 - 16*b^^^2))";
1322 val SOME (t',_) = rewrite_set_ thy false make_polynomial t;
1323 if term2str t' = "(9 * a ^^^ 2 + -16 * b ^^^ 2) /\n(36 * a ^^^ 2 * c + 27 * a ^^^ 2 * e + -64 * b ^^^ 2 * c +\n -48 * b ^^^ 2 * e)" then ()
1324 else error "rational.sml.sml: S.K.8..corrected 060904-6";
1326 "----- S.K. corrected non-termination of cancel_p_";
1327 val t'' = str2term "(9 * a ^^^ 2 + -16 * b ^^^ 2) /\
1328 \(36 * a^^^2 * c + (27 * a^^^2 * e + (-64 * b^^^2 * c + -48 * b^^^2 * e)))";
1329 val SOME (t',_) = rewrite_set_ thy false cancel_p t'';
1330 if term2str t' = "1 / (4 * c + 3 * e)" then ()
1331 else error "rational.sml.sml: diff.behav. in cancel_p S.K.8";
1335 (*Schalk I, p.68 Nr. 437b *)
1336 (* nonterm.SK9 loops: cancel_p kann nicht weiter kuerzen!!! *)
1337 val t'' = str2term "(a + b)/(x^^^2 - y^^^2) * ((x - y)^^^2/(a^^^2 - b^^^2))";
1338 (* val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t'';
1341 (*a casual output from above*)
1343 "(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)";
1344 (* WN060831 nonterm.SK10
1345 val SOME (t,_) = rewrite_set_ thy false cancel_p t;
1349 (*SRM Schalk I, p.68 Nr. 438a *)
1351 "x*y/(x*y - y^^^2)*(x^^^2 - x*y)";
1352 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1357 else error "rational.sml.sml: diff.behav. in norm_Rational_mg 24";
1359 (*SRM Schalk I, p.68 Nr. 439b *)
1361 "(4*x^^^2+4*x+1)*((x^^^2 - 2*x^^^3)/(4*x^^^2+2*x))";
1362 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1365 "(x + -4 * x ^^^ 3) / 2"
1367 else error "rational.sml.sml: diff.behav. in norm_Rational_mg 25";
1369 (*SRM Schalk I, p.68 Nr. 440a *)
1371 "(x^^^2 - 2*x)/(x^^^2 - 3*x) * (x - 3)^^^2/(x^^^2 - 4)";
1372 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1375 "(-3 + x) / (2 + x)"
1377 else error "rational.sml.sml: diff.behav. in norm_Rational_mg 26";
1379 "----- Schalk I, p.68 Nr. 440b SK11 works since 0707xx";
1381 "(a^^^3 - 9*a)/(a^^^3*b - a*b^^^3)*(a^^^2*b+a*b^^^2)/(a+3)";
1382 val SOME (t,_) = rewrite_set_ thy false norm_Rational t;
1383 if term2str t = "(-3 * a + a ^^^ 2) / (a + -1 * b)" then ()
1384 else error "rational.sml.sml: diff.behav. in norm_Rational 27";
1386 "----- SK12 works since 0707xx";
1387 val t = str2term "(a^^^3 - 9*a)*(a^^^2*b+a*b^^^2)/((a^^^3*b - a*b^^^3)*(a+3))";
1388 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
1389 if term2str t' = "(-3 * a + a ^^^ 2) / (a + -1 * b)" then ()
1390 else error "rational.sml.sml: diff.behav. in norm_Rational 28";
1393 "-------- common denominator and multiplication ------------------";
1394 "-------- common denominator and multiplication ------------------";
1395 "-------- common denominator and multiplication ------------------";
1397 (*----------------------------------------------------------------------*)
1398 (*--------- Gemeinsamer Nenner und Multiplikation von Bruechen ---------*)
1399 (*----------------------------------------------------------------------*)
1402 (*SRAM Schalk I, p.69 Nr. 441b *)
1403 val t = str2term "(4*a/3 + 3*b^^^2/a^^^3 + b/(4*a))*(4*b/(3*a))";
1404 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1407 "(36 * b ^^^ 3 + 3 * a ^^^ 2 * b ^^^ 2 + 16 * a ^^^ 4 * b) / (9 * a ^^^ 4)"
1409 else error "rational.sml.sml: diff.behav. in norm_Rational_mg 28";
1411 (*SRAM Schalk I, p.69 Nr. 442b *)
1412 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)";
1413 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1416 "5 * x ^^^ 2 / (a * b ^^^ 3 * c)"
1418 else error "rational.sml.sml: diff.behav. in norm_Rational_mg 29";
1420 (*SRAM Schalk I, p.69 Nr. 443b *)
1421 val t = str2term "(a/2 + b/3)*(b/3 - a/2)";
1422 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1425 "(-9 * a ^^^ 2 + 4 * b ^^^ 2) / 36"
1427 else error "rational.sml.sml: diff.behav. in norm_Rational_mg 30";
1429 (*SRAM Schalk I, p.69 Nr. 445b *)
1430 val t = str2term "(a^^^2/9 + 2*a/(3*b) + 4/b^^^2)*(a/3 - 2/b) + 8/b^^^3";
1431 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1436 else error "rational.sml.sml: diff.behav. in norm_Rational_mg 31";
1438 (*SRAM Schalk I, p.69 Nr. 446b *)
1439 val t = str2term "(x/(5*x + 4*y) - y/(5*x - 4*y) + 1)*(25*x^^^2 - 16*y^^^2)";
1440 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1443 "30 * x ^^^ 2 + -9 * x * y + -20 * y ^^^ 2"
1445 else error "rational.sml.sml: diff.behav. in norm_Rational_mg 32";
1447 (*SRAM Schalk I, p.69 Nr. 449a *)(*Achtung: rechnet ca 8 Sekunden*)
1449 "(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)";
1450 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1453 "(-81 * x ^^^ 4 + 16 * x ^^^ 8 * y ^^^ 4) / (81 * y ^^^ 8)"
1455 else error "rational.sml.sml: diff.behav. in norm_Rational_mg 33";
1457 (*SRAM Schalk I, p.69 Nr. 450a *)
1459 "(4*x/(3*y)+2*y/(3*x))^^^2 - (2*y/(3*x) - 2*x/y)*(2*y/(3*x)+2*x/y)";
1460 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1463 "(52 * x ^^^ 2 + 16 * y ^^^ 2) / (9 * y ^^^ 2)"
1465 else error "rational.sml.sml: diff.behav. in norm_Rational_mg 34";
1467 "-------- double fractions ---------------------------------------";
1468 "-------- double fractions ---------------------------------------";
1469 "-------- double fractions ---------------------------------------";
1471 (*SRD Schalk I, p.69 Nr. 454b *)
1473 "((2 - x)/(2*a)) / (2*a/(x - 2))";
1474 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1477 "(-4 + 4 * x + -1 * x ^^^ 2) / (4 * a ^^^ 2)"
1479 else error "rational.sml.sml: diff.behav. in norm_Rational_mg 35";
1481 (*SRD Schalk I, p.69 Nr. 455a *)
1483 "(a^^^2 + 1)/(a^^^2 - 1) / ((a+1)/(a - 1))";
1484 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1487 "(1 + a ^^^ 2) / (1 + 2 * a + a ^^^ 2)" then ()
1488 else error "rational.sml.sml: diff.behav. in norm_Rational_mg 36";
1491 "----- Schalk I, p.69 Nr. 455b";
1492 val t = str2term "(x^^^2 - 4)/(y^^^2 - 9)/((2+x)/(3 - y))";
1493 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1494 if term2str t = "(2 + -1 * x) / (3 + y)" then ()
1495 else error "rational.sml.sml: diff.behav. in norm_Rational_mg 37";
1497 "----- SK060904-1a non-termination of cancel_p_ ?: worked before 0707xx";
1498 val t = str2term "(x^^^2 - 4)*(3 - y)/((y^^^2 - 9)*(2+x))";
1499 val SOME (t,_) = rewrite_set_ thy false norm_Rational t;
1500 if term2str t = "(2 + -1 * x) / (3 + y)" then ()
1501 else error "rational.sml.sml: diff.behav. in norm_Rational_mg 37b";
1503 "----- ?: worked before 0707xx";
1504 val t = str2term "(3 + -1 * y) / (-9 + y ^^^ 2)";
1505 val SOME (t,_) = rewrite_set_ thy false norm_Rational t;
1506 if term2str t = "-1 / (3 + y)" then ()
1507 else error "rational.sml: -1 / (3 + y) norm_Rational";
1509 (*SRD Schalk I, p.69 Nr. 456b *)
1511 "(b^^^3 - b^^^2)/(b^^^2+b)/(b^^^2 - 1)";
1512 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1514 if (term2str t) = "b / (1 + 2 * b + b ^^^ 2)" then ()
1515 else error "rational.sml.sml: diff.behav. in norm_Rational_mg 38";
1517 (*SRD Schalk I, p.69 Nr. 457b *)
1519 "(16*a^^^2 - 9*b^^^2)/(2*a+3*a*b) / ((4*a+3*b)/(4*a^^^2 - 9*a^^^2*b^^^2))";
1520 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1523 "8 * a ^^^ 2 + -6 * a * b + -12 * a ^^^ 2 * b + 9 * a * b ^^^ 2"
1525 else error "rational.sml.sml: diff.behav. in norm_Rational_mg 39";
1527 "----- Schalk I, p.69 Nr. 458b works since 0707";
1529 "(2*a^^^2*x - a^^^2)/(a*x - b*x) / (b^^^2*(2*x - 1)/(x*(a - b)))";
1530 val SOME (t,_) = rewrite_set_ thy false norm_Rational t;
1531 if term2str t = "a ^^^ 2 / b ^^^ 2" then ()
1532 else error "rational.sml.sml: diff.behav. in norm_Rational_mg 39b";
1534 (*SRD Schalk I, p.69 Nr. 459b *)
1535 val t = str2term "(a^^^2 - b^^^2)/(a*b) / (4*(a+b)^^^2/a)";
1536 val SOME (t,_) = rewrite_set_ thy false norm_Rational t;
1537 if term2str t = "(a + -1 * b) / (4 * a * b + 4 * b ^^^ 2)" then ()
1538 else error "rational.sml.sml: diff.behav. in norm_Rational_mg 41";
1541 (*Schalk I, p.69 Nr. 460b nonterm.SK
1543 "(9*(x^^^2 - 8*x+16)/(4*(y^^^2 - 2*y+1)))/((3*x - 12)/(16*y - 16))";
1544 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1547 else error "rational.sml.sml: diff.behav. in norm_Rational_mg 42";
1550 "9*(x^^^2 - 8*x+16)*(16*y - 16)/(4*(y^^^2 - 2*y+1)*(3*x - 12))";
1551 val SOME (t',_) = rewrite_set_ thy false norm_Rational t;
1552 ... non terminating.
1553 val SOME (t',_) = rewrite_set_ thy false make_polynomial t;
1554 "(-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)";
1555 val SOME (t,_) = rewrite_set_ thy false cancel_p t';
1556 ... non terminating.*)
1558 (*SRD Schalk I, p.70 Nr. 472a *)
1559 val t = str2term "((8*x^^^2 - 32*y^^^2)/(2*x + 4*y))/\
1560 \((4*x - 8*y)/(x + y))";
1561 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1566 else error "rational.sml.sml: diff.behav. in norm_Rational_mg 43";
1569 (*----------------------------------------------------------------------*)
1570 (*---------------------- Einfache Dppelbrche --------------------------*)
1571 (*----------------------------------------------------------------------*)
1573 (*SRD Schalk I, p.69 Nr. 461a *)
1575 "(2/(x+3) + 2/(x - 3)) / (8*x/(x^^^2 - 9))";
1576 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1581 else error "rational.sml.sml: diff.behav. in norm_Rational_mg 44";
1583 (*SRD Schalk I, p.69 Nr. 464b *)
1585 "(a - a/(a - 2)) / (a + a/(a - 2))";
1586 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1589 "(3 + -1 * a) / (1 + -1 * a)"
1591 else error "rational.sml.sml: diff.behav. in norm_Rational_mg 45";
1593 (*SRD Schalk I, p.69 Nr. 465b *)
1595 "((x+3*y)/9 + (4*y^^^2 - 9*z^^^2)/(16*x)) /(x/9+y/6+z/4)";
1596 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1599 "(4 * x + 6 * y + -9 * z) / (4 * x)"
1601 else error "rational.sml.sml: diff.behav. in norm_Rational_mg 46";
1603 (*SRD Schalk I, p.69 Nr. 466b *)
1605 "((1 - 7*(x - 2)/(x^^^2 - 4)) / (6/(x+2))) / (3/(x+5)+30/(x^^^2 - 25))";
1606 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1609 "(25 + -10 * x + x ^^^ 2) / 18"
1611 else error "rational.sml.sml: diff.behav. in norm_Rational_mg 47";
1613 (*SRD Schalk I, p.70 Nr. 469 *)
1615 "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))";
1616 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1619 "3 * b ^^^ 3 / (2 * a + -2 * b)"
1621 else error "rational.sml.sml: diff.behav. in norm_Rational_mg 48";
1623 (*----------------------------------------------------------------------*)
1624 (*---------------------- Mehrfache Dppelbrueche ------------------------*)
1625 (*----------------------------------------------------------------------*)
1627 (*SRD.test Schalk I, p.70 Nr. 476b *) (* Rechenzeit: 10 sec *)
1628 (*WN060419 crashes with method 'simplify' ????SK*)
1630 "((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)";
1631 val SOME (t,_) = rewrite_set_ thy false norm_Rational t;
1632 if term2str t = "1 / (a ^^^ 2 + -1 * b ^^^ 2)" then ()
1633 else error "rational.sml.sml: diff.behav. in norm_Rational_mg 49";
1635 "----- Schalk I, p.70 Nr. 477a";
1636 (* MG Achtung: terme explodieren; Bsp zu komplex;
1637 L???ung sollte (ziemlich grosser) Faktorisierter Ausdruck sein
1638 val t = str2term "b*y/(b - 2*y)/((b^^^2 - y^^^2)/(b+2*y)) /\
1639 \(b^^^2*y+b*y^^^2)*(a+x)^^^2/((b^^^2 - 4*y^^^2)*(a+2*x)^^^2)";
1640 val SOME (t',_) = rewrite_set_ thy false norm_Rational t;
1643 val t = str2term "b*y*(b+2*y)*(b^^^2 - 4*y^^^2)*(a+2*x)^^^2 / \
1644 \((b - 2*y)*(b^^^2 - y^^^2)*(b^^^2*y+b*y^^^2)*(a+x)^^^2)";
1645 val SOME (t,_) = rewrite_set_ thy false make_polynomial t;
1649 "----- Schalk I, p.70 Nr. 478b ----- Rechenzeit: 5 sec";
1650 val t = str2term "(a - (a*b+b^^^2)/(a+b))/(b+(a - b)/(1+(a+b)/(a - b))) / \
1651 \((a - a^^^2/(a+b))/(a+(a*b)/(a - b)))";
1652 val SOME (t',_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1654 "(2 * a ^^^ 3 + 2 * a ^^^ 2 * b) / (a ^^^ 2 * b + b ^^^ 3)"
1656 else error "rational.sml.sml: diff.behav. in norm_Rational_mg 51";
1658 (* TODO.new_c:WN050820 STOP_REW_SUB introduced gave ...
1659 if term2str t' = "(a ^^^ 4 + -1 * a ^^^ 2 * b ^^^ 2) /\n(a * b * (b + (a * (a + -1 * b) + -1 * b * (a + -1 * b)) / (2 * a)) *\n (a + -1 * b))" then ()
1660 else error "rational.sml: works again";
1661 re-outcommented with TODO.new_c: cvs before 071227, 11:50*)
1665 (*Schalk I, p.70 Nr. 480a *)
1666 (* Achtung: rechnet ewig; cancel_p kann nicht krzen: WN060831 nonterm.SK00
1668 "(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)))";
1669 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1674 else error "rational.sml.sml: diff.behav. in norm_Rational_mg 52";
1676 (*MG Berechne Zwischenergebnisse: WN060831 nonterm.SK00*)
1678 "(1/x+1/y+1/z)/(1/x - 1/y - 1/z)";
1679 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1681 "(x ^^^ 2 * y ^^^ 2 * z + x ^^^ 2 * y * z ^^^ 2 + x * y ^^^ 2 * z ^^^ 2) /
1682 (-1 * x ^^^ 2 * y ^^^ 2 * z + -1 * x ^^^ 2 * y * z ^^^ 2 + x * y ^^^ 2 * z ^^^ 2)";
1684 "2*x^^^2/(x^^^2 - z^^^2)/(x/(x+z)+x/(x - z))";
1685 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1689 (* SK 1. Ausdruck kann nicht weiter gekrzt werden; cancel_p !!!*)
1690 ### rls: cancel_p on:
1691 (x ^^^ 2 * (y ^^^ 2 * z) + x ^^^ 2 * (y * z ^^^ 2) + x * (y ^^^ 2 * z ^^^ 2)) /
1692 (-1 * (x ^^^ 2 * (y ^^^ 2 * z)) + -1 * (x ^^^ 2 * (y * z ^^^ 2)) + x * (y ^^^ 2 * z ^^^ 2))
1693 GC #3.61.81.101.197.17503: (0 ms)
1694 *** RATIONALS_DIRECT_CANCEL_EXCEPTION: Invalid fraction
1697 "(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))";
1698 val SOME (t,_) = rewrite_set_ thy false cancel_p t;
1700 (*uncaught exception nonexhaustive binding failure*)
1702 (* Das kann er aber krzen !!????: *)
1704 "(x^^^2 * (y^^^2 * z) + x * (y^^^2 * z^^^2)) / (-1 * (x^^^2 * (y * z^^^2)) + x * (y^^^2 * z^^^2))";
1705 val SOME (t,_) = rewrite_set_ thy false cancel_p t;
1707 "(-1 * (y * x) + -1 * (z * y)) / (1 * (z * x) + -1 * (z * y))";
1715 (*--------------------------------------------------------------------*)
1716 (*----------------------- Problem-Beispiele --------------------------*)
1717 (*--------------------------------------------------------------------*)
1719 (*Schalk I, p.60 Nr. 215d *)
1720 (* Achtung: rechnet ewig ...
1721 val t = str2term "(a-b)^^^3 * (x+y)^^^4 / ((x+y)^^^2 * (a-b)^^^5)";
1722 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1723 term2str t; noterm.SK
1726 (* Kein Wunder, denn Z???ler und Nenner extra als Polynom dargestellt ergibt:*)
1728 val t = str2term "(a-b)^^^3 * (x+y)^^^4";
1729 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1731 "a^^^3 * x^^^4 + 4 * a^^^3 * x^^^3 * y +\n6 * a^^^3 * x^^^2 * y^^^2 +\n4 * a^^^3 * x * y^^^3 +\na^^^3 * y^^^4 +\n-3 * a^^^2 * b * x^^^4 +\n-12 * a^^^2 * b * x^^^3 * y +\n-18 * a^^^2 * b * x^^^2 * y^^^2 +\n-12 * a^^^2 * b * x * y^^^3 +\n-3 * a^^^2 * b * y^^^4 +\n3 * a * b^^^2 * x^^^4 +\n12 * a * b^^^2 * x^^^3 * y +\n18 * a * b^^^2 * x^^^2 * y^^^2 +\n12 * a * b^^^2 * x * y^^^3 +\n3 * a * b^^^2 * y^^^4 +\n-1 * b^^^3 * x^^^4 +\n-4 * b^^^3 * x^^^3 * y +\n-6 * b^^^3 * x^^^2 * y^^^2 +\n-4 * b^^^3 * x * y^^^3 +\n-1 * b^^^3 * y^^^4";
1732 val t = str2term "((x+y)^^^2 * (a-b)^^^5)";
1733 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1735 "a^^^5 * x^^^2 + 2 * a^^^5 * x * y + a^^^5 * y^^^2 +\n-5 * a^^^4 * b * x^^^2 +\n-10 * a^^^4 * b * x * y +\n-5 * a^^^4 * b * y^^^2 +\n10 * a^^^3 * b^^^2 * x^^^2 +\n20 * a^^^3 * b^^^2 * x * y +\n10 * a^^^3 * b^^^2 * y^^^2 +\n-10 * a^^^2 * b^^^3 * x^^^2 +\n-20 * a^^^2 * b^^^3 * x * y +\n-10 * a^^^2 * b^^^3 * y^^^2 +\n5 * a * b^^^4 * x^^^2 +\n10 * a * b^^^4 * x * y +\n5 * a * b^^^4 * y^^^2 +\n-1 * b^^^5 * x^^^2 +\n-2 * b^^^5 * x * y +\n-1 * b^^^5 * y^^^2";
1737 (*anscheinend macht dem Rechner das Krzen diese Bruches keinen Spass mehr ...*)
1739 (*--------------------------------------------------------------------*)
1740 (*Schalk I, p.70 Nr. 480b
1741 val t = str2term "((12*x*y/(9*x^^^2 - y^^^2))/\
1742 \(1/(3*x - y)^^^2 - 1/(3*x + y)^^^2)) *\
1743 \(1/(x - 5*y)^^^2 - 1/(x + 5*y)^^^2)/\
1744 \(20*x*y/(x^^^2 - 25*y^^^2))";
1745 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1747 Kann nicht weiter vereinfacht werden !!!!?? *)
1749 (*--------------------------------------------------------------------*)
1750 "---- MGs test set";
1751 val t = str2term " (1 + x^^^5) / (y + x) + x^^^3 / x ";
1752 val SOME (t,_) = rewrite_set_ thy false common_nominator_p t;
1753 if term2str t = "(1 + x ^^^ 3 + x ^^^ 5 + y * x ^^^ 2) / (x + y)" then()
1756 (*--------------------------------------------------------------------*)
1757 (* cancel_p liefert nicht immer Polynomnormalform (2): WN060831???SK3b
1758 ---> Sortierung FALSCH !! *)
1759 val t = str2term "b^^^3 * a^^^5/a ";
1760 val SOME (t,_) = rewrite_set_ thy false cancel_p t;
1762 "1 * (a^^^4 * b^^^3) / 1"; (*OK*)
1764 val t = str2term "b^^^3 * a^^^5/b ";
1765 val SOME (t,_) = rewrite_set_ thy false cancel_p t;
1767 "1 * (b^^^2 * a^^^5) / 1"; (*cancel_p sortiert hier falsch um!*)
1769 (* Problem liegt NICHT bei ord_make_polynomial! (siehe folgende Bsple) *)
1771 val x = str2term "x"; val bdv = str2term "bdv";
1772 val t1 = str2term "b^^^2 * a^^^5";
1773 val t2 = str2term "a^^^5 * b^^^2 ";
1774 ord_make_polynomial false Rational.thy [(x,bdv)] (t1,t2); (*false*)
1776 (* ==> "b^^^2 * a^^^5" > "a^^^5 * b^^^2 " ... OK!*)
1778 (*--------------------------------------------------------------------*)
1779 (* cancel_p liefert nicht immer Polynomnormalform (2): WN060831???SK3c
1780 ---> erzeugt berflssige "1 * ..."
1782 val t = str2term "-1 / (3 + y)";
1784 val SOME (t,_) = rewrite_set_ thy false cancel_p t;
1787 (********* Das ist das PROBLEM !!!!!!!??? *******************)
1788 (* -1 im Z???ler der Angabe verursacht das Problem !*)
1791 (* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *)
1792 "----- MGs test set";
1793 val t = str2term "(a^^^2 + -1)/(a+1)";
1794 val SOME (t',_) = rewrite_set_ thy false cancel_p t;
1795 if term2str t' = "(-1 + a) / 1" then ()
1796 else error "rational.sml MG tests 3d";
1798 "----- NOT TERMINATING ?: worked before 0707xx";
1799 val t = str2term "(a^^^2 - 1)*(b + 1) / ((b^^^2 - 1)*(a+1))";
1800 val SOME (t'',_) = rewrite_set_ thy false norm_Rational t;
1801 if term2str t'' = "(1 + -1 * a) / (1 + -1 * b)" then ()
1802 else error "rational.sml MG tests 3e";
1804 "----- corrected SK060905";
1805 val t = str2term "(4*x^^^2 - 20*x + 25)/(2*x - 5)^^^3";
1806 val SOME (t',_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1807 if term2str t' = "-1 / (5 + -2 * x)" then ()
1808 else error "rational.sml corrected SK060905";
1811 "--------------------------------------------------------------------";
1812 "----------------------- Muster-Beispiele fuer DA -------------------";
1813 "--------------------------------------------------------------------";
1815 (*SRAM Schalk I, p.69 Nr. 442b --- abgewandelt*)
1817 "(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))";
1818 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1821 "5 * x ^^^ 2 / (b ^^^ 3 * c)"
1823 else error "rational.sml.sml: diff.behav. in norm_Rational_mg 53";
1825 "-------- me Schalk I No.186 -------------------------------------";
1826 "-------- me Schalk I No.186 -------------------------------------";
1827 "-------- me Schalk I No.186 -------------------------------------";
1828 val fmz = ["TERM ((14 * x * y) / ( x * y ))",
1831 ("Rational",["rational","simplification"],
1832 ["simplification","of_rationals"]);
1833 val p = e_pos'; val c = [];
1834 val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
1835 val (p,_,f,nxt,_,pt) = me nxt p c pt;
1836 val (p,_,f,nxt,_,pt) = me nxt p c pt;
1837 val (p,_,f,nxt,_,pt) = me nxt p c pt;
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; f2str f;
1843 val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
1844 val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;(*++ for explicit script*)
1845 val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;(*++ for explicit script*)
1846 case (f2str f, nxt) of
1847 ("14", ("End_Proof'", _)) => ()
1848 | _ => error "rational.sml diff.behav. in me Schalk I No.186";
1851 "-------- interSteps ..Simp_Rat_Double_No-1.xml ------------------";
1852 "-------- interSteps ..Simp_Rat_Double_No-1.xml ------------------";
1853 "-------- interSteps ..Simp_Rat_Double_No-1.xml ------------------";
1856 [(["TERM (((2 - x)/(2*a)) / (2*a/(x - 2)))", "normalform N"],
1857 ("Rational",["rational","simplification"],
1858 ["simplification","of_rationals"]))];
1861 autoCalculate 1 CompleteCalc;
1862 val ((pt,p),_) = get_calc 1; show_pt pt;
1864 interSteps 1 ([1],Res);
1865 val ((pt,p),_) = get_calc 1; show_pt pt;
1868 "-------- interSteps ..Simp_Rat_Cancel_No-1.xml ------------------";
1869 "-------- interSteps ..Simp_Rat_Cancel_No-1.xml ------------------";
1870 "-------- interSteps ..Simp_Rat_Cancel_No-1.xml ------------------";
1873 [(["TERM ((a^2 + -1*b^2) / (a^2 + -2*a*b + b^2))", "normalform N"],
1874 ("Rational",["rational","simplification"],
1875 ["simplification","of_rationals"]))];
1878 autoCalculate 1 CompleteCalc;
1879 val ((pt,p),_) = get_calc 1; show_pt pt;
1880 (*with explicit script done already... and removed [1,..] at below...
1881 interSteps 1 ([1],Res);
1882 val ((pt,p),_) = get_calc 1; show_pt pt;
1884 interSteps 1 ([2],Res);
1885 val ((pt,p),_) = get_calc 1; show_pt pt;
1887 interSteps 1 ([2,1],Res);
1888 val ((pt,p),_) = get_calc 1; show_pt pt;
1889 val newnds = children (get_nd pt [2,1]) (*see "fun detailrls"*);
1890 (*if length newnds = 12 then () WN060905*)
1891 if length newnds = 13 then ()
1892 else error "rational.sml: interSteps cancel_p rev_rew_p";
1894 val p = ([2,1,9],Res);
1896 val (_, tac, _) = pt_extract (pt, p);
1897 (*case tac of SOME (Rewrite ("sym_real_plus_binom_times1", _)) => ()
1899 case tac of SOME (Rewrite ("sym_real_add_mult_distrib2", _)) => ()
1900 | _ => error "rational.sml: getTactic, sym_real_plus_binom_times1";
1903 "-------- investigate rulesets for cancel_p ----------------------";
1904 "-------- investigate rulesets for cancel_p ----------------------";
1905 "-------- investigate rulesets for cancel_p ----------------------";
1906 val thy = Rational.thy;
1907 "---------------- (a^^^2 + -1*b^^^2) / (a^^^2 + -2*a*b + b^^^2)";
1908 val t = str2term "(a^^^2 + -1*b^^^2) / (a^^^2 + -2*a*b + b^^^2)";
1909 val tt = str2term "(1 * a + 1 * b) * (1 * a + -1 * b)"(*numerator only*);
1910 "----- with rewrite_set_";
1911 val SOME (tt',asm) = rewrite_set_ thy false make_polynomial tt;
1912 term2str tt'= "a ^^^ 2 + -1 * b ^^^ 2" (*true*);
1913 val tt = str2term "((1 * a + -1 * b) * (1 * a + -1 * b))"(*denominator only*);
1914 val SOME (tt',asm) = rewrite_set_ thy false make_polynomial tt;
1915 term2str tt' = "a ^^^ 2 + -2 * a * b + b ^^^ 2" (*true*);
1917 "----- with make_deriv";
1918 val SOME (tt, _) = factout_p_ Isac.thy t; term2str tt =
1919 "(1 * a + 1 * b) * (1 * a + -1 * b) / ((1 * a + -1 * b) * (1 * a + -1 * b))";
1921 "--- with ruleset as before 060829";
1922 val {rules, rew_ord=(_,ro),...} =
1923 rep_rls (assoc_rls "make_polynomial");
1924 val der = make_deriv thy Atools_erls rules ro NONE tt;
1925 print_depth 99; map (term2str o #1) der; print_depth 3;
1926 print_depth 99; map (rule2str o #2) der; print_depth 3;
1927 ... did not terminate"*)
1928 "--- with simpler ruleset";
1929 val {rules, rew_ord=(_,ro),...} =
1930 rep_rls (assoc_rls "rev_rew_p");
1931 val der = make_deriv thy Atools_erls rules ro NONE tt;
1932 print_depth 99; writeln (deriv2str der); print_depth 3;
1934 print_depth 99; map (term2str o #1) der; print_depth 3;
1935 "...,(-1 * b ^^^ 2 + a ^^^ 2) / (-2 * (a * b) + a ^^^ 2 + (-1 * b) ^^^ 2) ]";
1936 print_depth 99; map (rule2str o #2) der; print_depth 3;
1937 print_depth 99; map (term2str o #1 o #3) der; print_depth 3;
1939 val der = make_deriv thy Atools_erls rules ro NONE
1940 (str2term "(1 * a + 1 * b) * (1 * a + -1 * b)");
1941 print_depth 99; writeln (deriv2str der); print_depth 3;
1943 val {rules, rew_ord=(_,ro),...} =
1944 rep_rls (assoc_rls "rev_rew_p");
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;
1948 print_depth 99; map (term2str o #1) der; print_depth 3;
1949 (*WN060829 ...postponed*)
1952 "-------- investigate format of factout_ and factout_p_ ----------";
1953 "-------- investigate format of factout_ and factout_p_ ----------";
1954 "-------- investigate format of factout_ and factout_p_ ----------";
1955 val {rules, rew_ord = (_,ro),...} = rep_rls (assoc_rls "make_polynomial");
1956 val (thy, eval_rls) = (Rational.thy, Atools_erls)(*see 'fun init_state'*);
1957 val Rrls {scr = Rfuns {init_state,...},...} = assoc_rls "cancel_p";
1959 "----- see Rational.ML, local cancel_p, fun init_state";
1960 val t = str2term "(a^^^2 + (-1)*b^^^2) / (a^^^2 + (-2)*a*b + b^^^2)";
1961 val SOME (t',_) = factout_p_ thy t; term2str t';
1963 val rtas = reverse_deriv thy eval_rls rules ro NONE t';
1964 writeln(trtas2str rst);
1968 "----- see Rational.ML, local cancel_p, fun init_state";
1969 val t = str2term "a^^^2 / a";
1970 val SOME (t',_) = factout_p_ thy t;
1971 term2str t' = "a * a / (1 * a)" (*true*);
1972 (*... can be canceled with
1973 real_mult_div_cancel2 ?k ~= 0 ==> ?m * ?k / (?n * ?k) = ?m / ?n"*)
1974 (* sml/ME/rewtools.sml:
1975 val rtas = reverse_deriv thy Atools_erls rules ro NONE t';
1976 writeln (deri2str rtas);
1981 "-------- SK 060904 ----------------------------------------------";
1982 "-------- SK 060904 ----------------------------------------------";
1983 "-------- SK 060904 ----------------------------------------------";
1984 "----- order on polynomials -- input + output";
1986 val t = str2term "(a + -1 * b) / (-1 * a + b)";
1987 val SOME (t', _) = factout_p_ thy t; term2str t';
1988 val SOME (t', _) = cancel_p_ thy t; term2str t';
1990 val t = str2term "a*b*c*d / (d*e*f*g)";
1991 val SOME (t', _) = cancel_p_ thy t; term2str t';
1993 val t = str2term "a*(b*(c*d)) / (b*(e*(f*g)))";
1994 val SOME (t', _) = cancel_p_ thy t; term2str t';
1997 "----- SK060904-1a non-termination of cancel_p_ ? worked before 0707xx";
1998 val t = str2term "(x^^^2 - 4)*(3 - y) / ((y^^^2 - 9)*(2+x))";
1999 val SOME (t',_) = rewrite_set_ thy false norm_Rational t;
2000 if term2str t' = "(2 + -1 * x) / (3 + y)" then ()
2001 else error "rational.sml SK060904-1a worked since 0707xx";
2003 "----- SK060904-1b non-termination of cancel_p_ ... worked before 0707xx";
2004 val t = str2term "(9 * a ^^^ 2 + -16 * b ^^^ 2) /\
2005 \(36 * a^^^2 * c + (27 * a^^^2 * e + (-64 * b^^^2 * c + -48 * b^^^2 * e)))";
2006 val SOME (t',_) = cancel_p_ thy t;
2007 if term2str t' = "1 / (4 * c + 3 * e)" then ()
2008 else error "rational.sml SK060904-1b";
2011 "----- SK060904-2a non-termination of add_fraction_p_";
2012 val t = str2term " (a + b * x) / (a + -1 * (b * x)) + \
2013 \ (-1 * a + b * x) / (a + b * x) ";
2015 val SOME (t',_) = rewrite_set_ thy false common_nominator_p t;
2017 common_nominator_p_ thy t;
2018 " (a + b * x)*(a + b * x) / ((a + -1 * (b * x))*(a + -1 * (b * x))) + \
2019 \ (-1 * a + b * x)*(a + -1 * (b * x)) / ((a + b * x)*(-1 * a + b * x)) ";
2021 add_fraction_p_ thy t;
2022 " ((a + b * x)*(a + b * x) + (-1 * a + b * x)*(a + -1 * (b * x))) /\
2023 \ ((a + b * x)*(-1 * a + b * x)) ";
2027 "-------- how to stepwise construct Scripts ----------------------";
2028 "-------- how to stepwise construct Scripts ----------------------";
2029 "-------- how to stepwise construct Scripts ----------------------";
2030 lse error "rational.sml SK060904-1a worked since 0707xx";
2032 "----- SK060904-1b non-termination of cancel_p_ ... worked before 0707xx";
2033 val t = str2term "(9 * a ^^^ 2 + -16 * b ^^^ 2) /\
2034 \(36 * a^^^2 * c + (27 * a^^^2 * e + (-64 * b^^^2 * c + -48 * b^^^2 * e)))";
2035 val SOME (t',_) = cancel_p_ thy t;
2036 if term2str t' = "1 / (4 * c + 3 * e)" then ()
2037 else error "rational.sml SK060904-1b";
2040 "----- SK060904-2a non-termination of add_fraction_p_";
2041 val t = str2term " (a + b * x) / (a + -1 * (b * x)) + \
2042 \ (-1 * a + b * x) / (a + b * x) ";
2044 val SOME (t',_) = rewrite_set_ thy false common_nominator_p t;
2046 common_nominator_p_ thy t;
2047 " (a + b * x)*(a + b * x) / ((a + -1 * (b * x))*(a + -1 * (b * x))) + \
2048 \ (-1 * a + b * x)*(a + -1 * (b * x)) / ((a + b * x)*(-1 * a + b * x)) ";
2050 add_fraction_p_ thy t;
2051 " ((a + b * x)*(a + b * x) + (-1 * a + b * x)*(a + -1 * (b * x))) /\
2052 \ ((a + b * x)*(-1 * a + b * x)) ";
2056 "-------- how to stepwise construct Scripts ----------------------";
2057 "-------- how to stepwise construct Scripts ----------------------";
2058 "-------- how to stepwise construct Scripts ----------------------";
2059 lse error "rational.sml SK060904-1a worked since 0707xx";
2061 "----- SK060904-1b non-termination of cancel_p_ ... worked before 0707xx";
2062 val t = str2term "(9 * a ^^^ 2 + -16 * b ^^^ 2) /\
2063 \(36 * a^^^2 * c + (27 * a^^^2 * e + (-64 * b^^^2 * c + -48 * b^^^2 * e)))";
2064 val SOME (t',_) = cancel_p_ thy t;
2065 if term2str t' = "1 / (4 * c + 3 * e)" then ()
2066 else error "rational.sml SK060904-1b";
2069 "----- SK060904-2a non-termination of add_fraction_p_";
2070 val t = str2term " (a + b * x) / (a + -1 * (b * x)) + \
2071 \ (-1 * a + b * x) / (a + b * x) ";
2073 val SOME (t',_) = rewrite_set_ thy false common_nominator_p t;
2075 common_nominator_p_ thy t;
2076 " (a + b * x)*(a + b * x) / ((a + -1 * (b * x))*(a + -1 * (b * x))) + \
2077 \ (-1 * a + b * x)*(a + -1 * (b * x)) / ((a + b * x)*(-1 * a + b * x)) ";
2079 add_fraction_p_ thy t;
2080 " ((a + b * x)*(a + b * x) + (-1 * a + b * x)*(a + -1 * (b * x))) /\
2081 \ ((a + b * x)*(-1 * a + b * x)) ";
2085 "-------- how to stepwise construct Scripts ----------------------";
2086 "-------- how to stepwise construct Scripts ----------------------";
2087 "-------- how to stepwise construct Scripts ----------------------";
2088 val thy = (theory "Rational");
2089 val -------------------------------------------------- = "00000";
2091 val p1 = parse thy (
2092 "Script SimplifyScript (t_t::real) = " ^
2093 " (Rewrite_Set discard_minus False " ^
2096 (*required (): (Rewrite_Set discard_minus False)*)
2097 val p2 = parse thy (
2098 "Script SimplifyScript (t_t::real) = " ^
2099 " (Rewrite_Set discard_minus False " ^
2102 val p3 = parse thy (
2103 "Script SimplifyScript (t_t::real) = " ^
2104 " ((Rewrite_Set discard_minus False) " ^
2107 val p4 = parse thy (
2108 "Script SimplifyScript (t_t::real) = " ^
2109 " ((Rewrite_Set discard_minus False) " ^
2112 val p5 = parse thy (
2113 "Script SimplifyScript (t_t::real) = " ^
2114 " ((Try (Rewrite_Set discard_minus False) " ^
2115 " Try (Rewrite_Set discard_parentheses False)) " ^
2118 val --------------------------------------------------+ = "11111";
2119 val p6 = parse thy (
2120 "Script SimplifyScript (t_t::real) = " ^
2121 " ((Try (Rewrite_Set discard_minus False) @@ " ^
2122 " Try (Rewrite_Set rat_mult_poly False) @@ " ^
2123 " Try (Rewrite_Set make_rat_poly_with_parentheses False) @@ " ^
2124 " Try (Rewrite_Set cancel_p_rls False) @@ " ^
2126 " ((Try (Rewrite_Set common_nominator_p_rls False) @@ " ^
2127 " Try (Rewrite_Set rat_mult_div_pow False) @@ " ^
2128 " Try (Rewrite_Set make_rat_poly_with_parentheses False) @@" ^
2129 " Try (Rewrite_Set cancel_p_rls False) @@ " ^
2130 " Try (Rewrite_Set rat_reduce_1 False)))) @@ " ^
2131 " Try (Rewrite_Set discard_parentheses False)) " ^
2134 val --------------------------------------------------++ = "22222";