1 (* Title: tests for rationals
3 Copyright (c) Stefan Karnel 2002
4 Use is subject to license terms.
7 nonterm.SK marks non-terminating examples
8 ord.SK PARTIALLY marks crucial ordering examples
9 *SK* of some (secondary) interest (on 070906)
10 *******************************************************************)
12 (******************************************************************
13 WN060104 transfer marked (*SR..*)examples to the exp-collection
14 # exp_IsacCore_Simp_Rat_Cancel.xml from rational.sml (*SRC*) 10 exp
15 # exp_IsacCore_Simp_Rat_Add.xml from rational.sml (*SRA*) 11 exp
16 # exp_IsacCore_Simp_Rat_Mult.xml from rational.sml (*SRM*) 5 exp
17 # exp_IsacCore_Simp_Rat_AddMult.xml from rational.sml (*SRAM*) 11 exp
18 # exp_IsacCore_Simp_Rat_Double.xml from rational.sml (*SRD*) 12 exp
19 *******************************************************************)
20 "--------------------------------------------------------";
21 "--------------------------------------------------------";
22 "table of contents --------------------------------------";
23 "--------------------------------------------------------";
24 "~~~~~BEGIN: decomment structure RationalI : RATIONALI ~~";
25 "-------- ... missing WN060103 --------------------------";
26 "-------- fun monom2term, fun poly2term' ---------------";
27 "~~~~~END: decomment structure RationalI : RATIONALI ~~~~";
28 "-------- external calculating functions test -----------";
29 "-------- cancel from: Mathematik 1 Schalk Reniets Verlag";
30 "-------- common_nominator_p ----------------------------";
31 "-------- reverse rewrite -------------------------------";
32 "-------- 'reverse-ruleset' cancel_p --------------------";
33 "-------- norm_Rational ---------------------------------";
34 "-------- numeral rationals -----------------------------";
35 "-------- cancellation ----------------------------------";
36 "-------- common denominator ----------------------------";
37 "-------- multiply and cancel ---------------------------";
38 "-------- common denominator and multiplication ---------";
39 "-------- double fractions ------------------------------";
40 "-------- crucial examples ------------------------------";
41 "-------- examples for Stefan Karnels thesis ------------";
42 "-------- me Schalk I No.186 ----------------------------";
43 "-------- interSteps ..Simp_Rat_Double_No-1.xml ---------";
44 "-------- interSteps ..Simp_Rat_Cancel_No-1.xml ---------";
45 "-------- investigate rulesets for cancel_p -------------";
46 "-------- investigate format of factout_ and factout_p_ -";
47 "-------- how to stepwise construct Scripts -------------";
48 "--------------------------------------------------------";
49 "--------------------------------------------------------";
50 "--------------------------------------------------------";
53 "~~~~~BEGIN: decomment structure RationalI : RATIONALI ~~";
54 (*.~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
55 tests of internal functions: to make them work,
56 out-comment (*!!!*) in knowledge/Rational.ML:
58 structure RationalI : RATIONALI =
65 !!!##*)~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~.*)
67 "-------- ... missing WN060103 --------------------------";
68 "-------- ... missing WN060103 --------------------------";
69 "-------- ... missing WN060103 --------------------------";
70 (*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
71 writeln ("********************* rational.sml - TESTS *************************");
72 writeln ("***** divide tests *****");
73 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_)));
74 (* result: [(1,[0,0,1]),(1,[0,0,0])] *)
75 if mv_pquot1=[(1,[0,0,1]),(1,[0,0,0])] then () else error ("rational.sml: example failed");
77 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_)));
78 (* result: [(1,[1,0,1]),(~1,[0,0,1])] *)
79 if mv_prest1=[(1,[1,0,1]),(~1,[0,0,1])] then () else error ("rational.sml: example failed");
81 val mv_pquot2 = (#1(mv_division([(4,[2]),(8,[1]),(16,[0])],[(1,[1]),(1,[0])],LEX_)));
82 (* result: [(4,[1]),(4,[0])] *)
83 if mv_pquot2=[(4,[1]),(4,[0])] then () else error ("rational.sml: example failed");
85 val mv_prest2 = (#2(mv_division([(4,[2]),(8,[1]),(16,[0])],[(1,[1]),(1,[0])],LEX_)));
86 (* result: [(12,[0]] *)
87 if mv_prest2=[(12,[0])] then () else error ("rational.sml: example failed");
89 val mv_pquot3 = (#1(mv_division([(4,[2]),(~4,[0])],[(2,[1]),(2,[0])],LEX_)));
90 (* [(2,[1]),(~2,[0])] *)
91 if mv_pquot3=[(2,[1]),(~2,[0])] then () else error ("rational.sml: example failed");
93 val mv_prest3 = (#2(mv_division([(1,[2]),(~1,[0])],[(2,[1]),(2,[0])],LEX_)));
94 (* [(1,[2]),(~1,[0])] *)
95 if mv_prest3=[(1,[2]),(~1,[0])] then () else error ("rational.sml: example failed");
97 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_)));
99 if mv_pquot4=[(1,[0,1,1])] then () else error ("rational.sml: example failed");
101 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_)));
102 (* [(1,[1,1,1]),(~4,[0,1,2]),(4,[1,0,1]),(3,[0,0,1])] *)
103 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");
105 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_)));
106 (* [(1,[2,2,0]),(6,[2,1,2]),(3,[1,1,0]),(4,[1,0,0]),(4,[0,4,0]),(3,[0,0,0])]*)
107 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");
109 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_)));
111 if mv_prest5=[] then () else error ("rational.sml: example failed");
113 (* (x^2 + 2(a+1)x + (a^2+2a+1)) / (x+a+1) = x+a+1 *)
114 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_)));
115 if mv_pquot6=[(1,[1,0,0]),(1,[0,1,0]),(1,[0,0,0])] then () else error ("rational.sml: example failed");
117 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_)));
118 if mv_prest6=[] then () else error ("rational.sml: example failed");
121 writeln ("***** MV_CONTENT-TESTS *****");
122 val mv_cont1=mv_content([(1,[2,1]),(1,[2,0]),(1,[1,1]),(1,[1,0]),(1,[0,1]),(1,[0,0])]);
123 (* [(1,[0,1]),(1,[0,0])] *)
124 if mv_cont1=[(1,[0,1]),(1,[0,0])] then () else error ("rational.sml: example failed");
126 val mv_pp1=mv_pp([(1,[1,1]),(1,[1,0]),(1,[0,1]),(1,[0,0])]);
127 (*[(1,[1,0]),(1,[0,0])]*)
128 if mv_pp1=[(1,[1,0]),(1,[0,0])] then () else error ("rational.sml: example failed");
130 val mv_cont2=mv_content([(2,[1]),(4,[0])]);
132 if mv_cont2=[(2,[0])] then () else error ("rational.sml: example failed");
134 val mv_pp2=mv_pp([(2,[1]),(4,[0])]);
135 (* [(1,[1]),(2,[0])] *)
136 if mv_pp2=[(1,[1]),(2,[0])] then () else error ("rational.sml: example failed");
138 val mv_cont3=mv_content[(8,[2,1,1]),(12,[1,0,2]),(10,[2,2,0]),(16,[1,1,1])];
140 if mv_cont3=[(2,[0,0,0])] then () else error ("rational.sml: example failed");
142 val mv_pp3=mv_pp[(8,[2,1,1]),(12,[1,0,2]),(10,[2,2,0]),(16,[1,1,1])];
143 (* [(5,[2,2,0]),(4,[2,1,1]),(8,[1,1,1]),(6,[1,0,2])] *)
144 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");
146 val mv_cont4=mv_content[(2,[2,1,0]),(3,[1,0,1]),(2,[1,1,0]),(3,[0,0,1])];
148 if mv_cont4=[(1,[0,0,0])] then () else error ("rational.sml: example failed");
150 val mv_pp4=mv_pp [(2,[2,1,0]),(3,[1,0,1]),(2,[1,1,0]),(3,[0,0,1])];
151 (* [(2,[2,1,0]),(2,[1,1,0]),(3,[1,0,1]),(3,[0,0,1])] *)
152 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");
154 val con1=mv_content([(9,[2,0]),(15,[1,1]),(12,[1,0]),(6,[0,2]),(12,[0,1])]);
156 if con1=[(3,[0,0])] then () else error ("rational.sml: example failed");
158 val pp1=mv_pp([(9,[2,0]),(15,[1,1]),(12,[1,0]),(6,[0,2]),(12,[0,1])]);
159 (* [(3,[2,0]),(5,[1,1]),(4,[1,0]),(2,[0,2]),(4,[0,1])] *)
160 if pp1=[(3,[2,0]),(5,[1,1]),(4,[1,0]),(2,[0,2]),(4,[0,1])] then () else error ("rational.sml: example failed");
162 val con2=mv_content([(1,[2,0]),(1,[1,1]),(1,[1,0]),(1,[0,2]),(1,[0,1])]);
164 if con2=[(1,[0,0])] then () else error ("rational.sml: example failed");
166 val pp2 =mv_pp([(1,[2,0]),(1,[1,1]),(1,[1,0]),(1,[0,2]),(1,[0,1])]);
167 (* [(1,[2,0]),(1,[1,1]),(1,[1,0]),(1,[0,2]),(1,[0,1])] *)
168 if pp2=[(1,[2,0]),(1,[1,1]),(1,[1,0]),(1,[0,2]),(1,[0,1])] then () else error ("rational.sml: example failed");
170 val cont1 = mv_content [(1,[2,1,0]),(2,[2,1,0])];
172 if cont1=[(3,[0,1,0])] then () else error ("rational.sml: example failed");
174 val pp1 = mv_pp [(1,[2,1,0]),(2,[2,1,0])];
176 if pp1=[(1,[2,0,0])] then () else error ("rational.sml: example failed");
178 val cont2 = mv_content [(4,[1,2,0]),(2,[2,1,0])];
180 if cont2=[(2,[0,1,0])] then () else error ("rational.sml: example failed");
182 val pp2 = mv_pp [(4,[1,2,0]),(2,[2,1,0])];
183 (* [(1,[2,0,0]),(2,[1,1,0])] *)
184 if pp2=[(1,[2,0,0]),(2,[1,1,0])] then () else error ("rational.sml: example failed");
186 writeln ("********************************************************");
187 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])];
188 if cont3=[(5,[0,2,1]),(4,[0,2,0]),(2,[0,1,1])] then () else error ("rational.sml: example failed");
189 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])];
192 "-------- fun monom2term, fun poly2term' ---------------";
193 "-------- fun monom2term, fun poly2term' ---------------";
194 "-------- fun monom2term, fun poly2term' ---------------";
195 val t = monom2term ((3,[2,1,0]), ["c","b","a"](*reverse ???SK-*));
196 term2str t = "3 * (c ^^^ 2 * b)" (*true*);
198 val t = monom2term ((1,[1,0]), ["b","a"]);
199 term2str t = "b" (*true*);
201 val t = poly2term ([(1,[0,0,0]),(2,[1,0,0]),(3,[2,1,0]),(4,[3,2,1])],
203 term2str t = "1 + 2 * c + 3 * (c ^^^ 2 * b) + 4 * (c ^^^ 3 * (b ^^^ 2 * a))";
205 val t = poly2term ([(1,[1,0]),(1,[0,1])], ["b","a"]);
206 term2str t = "a + b" (*true*);
208 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*)
209 "~~~~~END: decomment structure RationalI : RATIONALI ~~~~";
210 "~~~~~END: decomment structure RationalI : RATIONALI ~~~~";
211 "~~~~~END: decomment structure RationalI : RATIONALI ~~~~";
214 fun parse_rat str = (term_of o the o (parse thy)) str;
216 writeln ("***** mv_gcd-tests *****");
217 val ggt1 = mv_gcd [(4,[2,2]),(8,[1,1]),(4,[0,0])] [(2,[1,1]),(2,[0,0])];
218 (* [(2,[1,1]),(2,[0,0])] *)
219 if ggt1=[(2,[1,1]),(2,[0,0])] then () else error ("rational.sml: example failed");
221 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])];
222 (* [(2,[1,1,0]),(3,[0,0,1])] *)
223 if ggt2=[(2,[1,1,0]),(3,[0,0,1])] then () else error ("rational.sml: example failed");
226 val ggt3 = mv_gcd [(1,[2,0]),(~2,[1,1]),(1,[0,2])] [(1,[1,0]),(~1,[0,1])];
227 (* [(1,[1,0]),(~1,[0,1])] *)
228 if ggt3=[(1,[1,0]),(~1,[0,1])] then () else error ("rational.sml: example failed");
231 val ggt4 = mv_gcd [(1,[2,1,0]),(2,[2,1,0])] [(5,[1,0,0])];
233 if ggt4=[(1,[1,0,0])] then () else error ("rational.sml: example failed");
236 val ggt5 = mv_gcd [(4,[2,0]),(~8,[1,1]),(4,[0,2])] [(1,[2,0]),(~1,[0,2])];
237 (* [(1,[1,0]),(~1,[0,1])] *)
238 if ggt5=[(1,[1,0]),(~1,[0,1])] then () else error ("rational.sml: example failed");
241 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])];
243 if ggt6=[(1,[1,0,0])] then () else error ("rational.sml: example failed");
245 writeln ("***** kgv-tests *****");
246 val kgv1=mv_lcm [(10,[])] [(15,[])];
248 if kgv1=[(30,[])] then () else error ("rational.sml: example failed");
250 val kgv2=mv_lcm [(1,[2,0]),(~2,[1,1]),(1,[0,2])] [(1,[1,0]),(~1,[0,1])];
251 (* [(1,[2,0]),(~2,[1,1]),(1,[0,2])] *)
252 if kgv2=[(1,[2,0]),(~2,[1,1]),(1,[0,2])] then () else error ("rational.sml: example failed");
254 val kgv3=mv_lcm [(4,[2,0]),(~8,[1,1]),(4,[0,2])] [(1,[2,0]),(~1,[0,2])];
255 (* [(4,[3,0]),(~4,[2,1]),(~4,[1,2]),(4,[0,3])] *)
256 if kgv3=[(4,[3,0]),(~4,[2,1]),(~4,[1,2]),(4,[0,3])] then () else error ("rational.sml: example failed");
259 writeln ("***** STEP_CANCEL_TESTS: *****");
261 val term2 = (term_of o the o (parse thy)) " (9 * a^^^2 * b) / (6 * a * c)";
262 val div2 = term2str (step_cancel term2);
263 if div2 = "3 * (a * b) * (3 * a) / (2 * c * (3 * a))" then () else error ("rational.sml: example failed");
266 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";
267 val div1 = term2str(step_cancel term1);
268 if div1 = "(3 * c + 14 * b + 20 * (b ^^^ 2 * c) + 10 * (a * (b * c))) * a / (1 * a)" then () else error ("rational.sml: example failed");
270 val term3 = (term_of o the o (parse thy)) "(10 * a^^^2 * b * c) / (1 * x * y * z) ";
271 val div3 = term2str(step_cancel term3);
272 if div3="10 * a ^^^ 2 * b * c / (1 * x * y * z)" then () else error ("rational.sml: example failed");
274 --------------------------------------------------------------------------!!!*)
276 (*-----versuche 13.3.03-----
277 val t = str2term "1 - x^^^2 - 5 * x^^^5";
278 val vs=(((map free2str) o vars) t);
279 val SOME ml = expanded2poly t vs;
281 poly2term'(rev(sort (mv_geq LEX_) (ml)),vs);
282 poly2term'([(~5,[5]),(~1,[2]),(1,[0])], vs);
283 monom2term((~5,[5]),vs);
284 monom2term((~1,[2]),vs);
285 val t' = monom2term((1,[0]),vs);(*uncaught exception LIST*)
287 val (i,is) = (~1,[2]);
288 val ttt = Const ("Groups.times_class.times", [HOLogic.realT,HOLogic.realT]---> HOLogic.realT) $
289 (Const ("uminus", HOLogic.realT --> HOLogic.realT) $
290 Free ((str_of_int o abs) i, HOLogic.realT)) $
291 powerproduct2term(is, vs);
293 -------versuche 13.3.03-----*)
295 val t = str2term "1 - x^^^2 - 5 * x^^^5";
296 val SOME t' = expanded2polynomial t; term2str t';
297 "1 + - 1 * x ^^^ 2 + - 5 * x ^^^ 5";
298 val t = str2term "1 - x";
299 val SOME t' = expanded2polynomial t; term2str t';
301 val t = str2term "1 + (-1) * x";
302 val SOME t' = expanded2polynomial t; term2str t';
304 val t = (term_of o the o (parse thy)) "1 + (-1) * x ^^^ 2 + (-5) * x ^^^5";
305 val SOME t' = polynomial2expanded t; term2str t';
306 "1 - x ^^^ 2 - 5 * x ^^^ 5";
309 "-------- external calculating functions test -----------";
310 "-------- external calculating functions test -----------";
311 "-------- external calculating functions test -----------";
312 val t1 = (term_of o the o (parse thy)) "((3 * x^^^2 + 6 *x + 3) / (2*x + 2))";
313 val SOME (t1',asm)= factout_p_ thy t1;
314 term2str t1'; terms2str asm;
315 "(3 + 3 * x) * (1 + 1 * x) / (2 * (1 + 1 * x))";
317 val SOME (t1',asm)= cancel_p_ thy t1;
318 term2str t1'; terms2str asm;
320 "[\"1 + 1 * x ~= 0\"]";
322 val t = (term_of o the o (parse thy)) "((-3 * x^^^2 + 6 *x - 3) / (2*x - 2))";
323 val SOME (t',asm)= cancel_ thy t;
324 term2str t'; terms2str asm;
327 val SOME (t',asm)= factout_ thy t;
328 term2str t'; terms2str asm;
329 "(3 - 3 * x) * (-1 + x) / (2 * (-1 + x))";
332 val t = str2term "((x+ (-1)) / (x + 1)) + ((x + 1) / (x + (-1)))";
333 val SOME (t',asm) = add_fraction_p_ thy t;
334 term2str t'; terms2str asm;
335 "(2 + 2 * x ^^^ 2) / (-1 + 1 * x ^^^ 2)";
337 val SOME (t',asm) = common_nominator_p_ thy t;
338 term2str t'; terms2str asm;
339 "(-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))";
342 val t = str2term "((x - 1) / (x + 1)) + ((x + 1) / (x - 1))";
343 val SOME (t',asm) = add_fraction_ thy t;
344 term2str t'; terms2str asm;
345 "(2 + 2 * x ^^^ 2) / (-1 + x ^^^ 2)";
347 val SOME (t',asm) = common_nominator_ thy t;
348 term2str t'; terms2str asm;
349 "(-1 + x) * (-1 + x) / ((1 + x) * (-1 + x)) +\n(1 + x) * (1 + x) / ((1 + x) * (-1 + x))";
352 val t = str2term "((1) / (2*x + 2)) + ((1) / (2*x + (-2))) + ((1) / ( x^^^2 + (-1)))+((1) / (x^^^2 + (-2)*x + 1))";
353 val SOME (t',asm) = common_nominator_p_ thy t;
354 term2str t'; terms2str asm;
355 "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 * (#";
357 val SOME (t',asm) = add_fraction_p_ thy t;
358 term2str t'; terms2str asm;
359 "1 * x / (1 + -2 * x + 1 * x ^^^ 2)";
360 "[\"1 + 1 * x ~= 0\"]";
361 val SOME(t',asm) = norm_rational_ thy t;
362 term2str t'; terms2str asm;
363 "1 * x / (1 + -2 * x + 1 * x ^^^ 2)";
364 "[\"1 + 1 * x ~= 0\"]";
366 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))";
367 val SOME (t3',_) = common_nominator_ thy t3;
368 val SOME (t3'',_) = add_fraction_ thy t3;
372 val SOME(t4,t5) = norm_expanded_rat_ thy t3;
378 val t=(term_of o the o (parse thy)) "(9 - x^^^2)/(9 - 6*x + x^^^2)";
379 val SOME (t',_) = factout_ thy t;
380 val SOME (t'',_) = cancel_ thy t;
383 "(3 + x) * (3 - x) / ((3 - x) * (3 - x))";
386 val t=(term_of o the o (parse thy))
387 "(9 - x^^^2) / (9 - 6*x + x^^^2) + 1 / (3 - x)";
388 val SOME (t',_) = common_nominator_ thy t;
389 val SOME (t'',_) = add_fraction_ thy t;
392 "(9 - x ^^^ 2) / ((3 - x) * (3 - x)) + 1 * (3 - x) / ((3 - x) * (3 - x))";
395 (*WN021016 added -----vv---*)
396 val t = str2term "(9 - x^^^2) / (9 - 6*x + x^^^2) + 1";
397 val SOME (t',_) = common_nominator_ thy t;
398 val SOME (t'',_) = add_fraction_ thy t;
399 term2str t' = "(9 - x ^^^ 2) / (9 - 6 * x + x ^^^ 2) +\n1" ^
400 " * (9 - 6 * x + x ^^^ 2) / (9 - 6 * x + x ^^^ 2)" (*true*);
401 term2str t'' = "6 / (3 - x)" (*true*);
403 val t = str2term "1 + (9 - x^^^2) / (9 - 6*x + x^^^2)";
404 val SOME (t',_) = common_nominator_ thy t;
405 val SOME (t'',_) = add_fraction_ thy t;
406 term2str t' = "1 * (9 - 6 * x + x ^^^ 2) / (9 - 6 * x + x ^^^ 2) +\n" ^
407 "(9 - x ^^^ 2) / (9 - 6 * x + x ^^^ 2)" (*true*);
408 term2str t'' = "6 / (3 - x)" (*true*);
409 (*WN021016 added -----^^---*)
410 (*WN030602 added -----vv--- no rewrite -> NONE !*)
411 val t = str2term "1 / a";
412 val NONE = cancel_p_ thy t;
413 val NONE = rewrite_set_ thy false cancel_p t;
414 (*WN.2.6.03 added -------^^---*)
416 val t = str2term "(y^^^2 - x^^^2)/(y^^^2 - 2*y*x + x^^^2)";
417 val SOME (t',_) = factout_ thy t;
418 val SOME (t'',_) = cancel_ thy t;
419 term2str t' = "(y + x) * (y - x) / ((y - x) * (y - x))"(*true*);
420 term2str t'' = "(y + x) / (y - x)";
422 val t = str2term "(y^^^2 - x^^^2)/(y^^^2 - 2*y*x + x^^^2) + 1 / (y - x)";
423 val SOME (t',_) = common_nominator_ thy t;
424 val SOME (t'',_) = add_fraction_ thy t;
426 "(-1 * x ^^^ 2 + y ^^^ 2) / ((-1 * x + y) * (-1 * x + y)) +\n1" ^
427 " * (-1 * x + y) / ((-1 * x + y) * (-1 * x + y))" (*true*);
428 term2str t'' = "(-1 - x - y) / (x - y)" (*true*);
430 val t = str2term "(x^^^2 - y^^^2)/(x^^^2 - 2*x*y + y^^^2) + 1 / (x - y)";
431 val SOME (t',_) = common_nominator_ thy t;
432 val SOME (t'',_) = add_fraction_ thy t;
433 if term2str t' = "(-1 * y ^^^ 2 + x ^^^ 2) / ((-1 * y + x) * (-1 * y + x))" ^
434 " +\n1 * (-1 * y + x) / ((-1 * y + x) * (-1 * y + x))" then ()
435 else error "rational.sml lex-ord 1";
436 if term2str t'' = "(-1 - y - x) / (y - x)" then ()
437 else error "rational.sml lex-ord 2";
438 (*WN.16.10.02 WN070905 lexicographische Ordnung erhalten ! SK.ord*)
441 val t = str2term "(x^^^2 - y^^^2)/(x^^^2 - 2*x*y + y^^^2)";
442 val SOME (t',_) = norm_expanded_rat_ thy t;
443 if term2str t' = "(x + y) / (x - y)" then ()
444 else error "rational.sml term2poly: invalid x ^^^ 2 - y ^^^ 2 No.1";
445 (*val SOME (t'',_) = norm_rational_ thy t;
446 *** RATIONALS_TERM2POLY_EXCEPTION: Invalid Polynomial
447 WN.16.10.02 ?! + WN060831???SK4
448 WN070905 *** term2poly: invalid = x ^^^ 2 - y ^^^ 2*)
451 val t = str2term "(9 - x^^^2)/(9 - 6*x + x^^^2) + (1)/(3 + x)";
452 val SOME (t',_) = norm_expanded_rat_ thy t;
453 if term2str t' = "(12 + 5 * x + x ^^^ 2) / (9 - x ^^^ 2)" then ()
454 else error "rational.sml (9 - x^^^2)/(9 - 6*x + x^^^2) +...";
455 (*val SOME (t'',_) = norm_rational_ thy t;
456 *** RATIONALS_TERM2POLY_EXCEPTION: Invalid Polynomial WN.16.10.02 ?!
457 WN070906 *** term2poly: invalid = 9 - x ^^^ 2 SK.term2poly*)
459 val t=(term_of o the o (parse thy))
460 "(9 + (-1)* x^^^2)/(9 + (-1)* 6*x + x^^^2) + (1)/(3 + x)";
461 val SOME (t',_) = norm_expanded_rat_ thy t;
462 val SOME (t'',_) = norm_rational_ thy t;
465 "(12 + 5 * x + x ^^^ 2) / (9 - x ^^^ 2)";
466 "(12 + 5 * x + x ^^^ 2) / (9 + (-1) * x ^^^ 2)";
469 "-------- cancel from: Mathematik 1 Schalk Reniets Verlag";
470 "-------- cancel from: Mathematik 1 Schalk Reniets Verlag";
471 "-------- cancel from: Mathematik 1 Schalk Reniets Verlag";
472 val thy = theory "Rational"
473 val thy' = "Rational";
475 val mp = "make_polynomial";
477 writeln ("example 186:");
479 val e186a'="(14 * x * y) / ( x * y )";(*SRC*)
480 rewrite_set_ thy false cancel (str2term e186a');
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");
485 if e186a = ("14 / 1", "[\"y * x ~= 0\"]") then ()
486 else error "rational.sml cancel Schalk e186a";
489 val e186b'="(60 * a * b) / ( 15 * a * b )";
490 val e186b = the (rewrite_set thy' false "cancel" e186b');
492 val e186c'="(144 * a^^^2 * b * c) / (12 * a * b * c )";
493 val e186c = (the (rewrite_set thy' false "cancel" e186c'))
494 handle e => OldGoals.print_exn e;
495 val t = (term_of o the o (parse thy)) e186c';
496 if e186c = ("12 * a / 1", "[\"12 * (c * (b * a)) ~= 0\"]") then ()
497 else error "rational.sml cancel Schalk e186c";
499 writeln ("example 187:");
501 val e187a'="(12 * x * y) / (8 * y^^^2 )";(*SRC*)
502 val e187a = the (rewrite_set thy' false "cancel" e187a');
504 val e187b'="(8 * x^^^2 * y * z ) / (18 * x * y^^^2 * z )";
505 val e187b = the (rewrite_set thy' false "cancel" e187b');
507 val e187d'="(9 * x^^^5 * y^^^2 * z^^^4) / (15 * x^^^6 * y^^^3 * z )";(*SRC*)
508 val e187d = the (rewrite_set thy' false "cancel" e187d');
509 if e187d = ("3 * z ^^^ 3 / (5 * (y * x))",
510 "[\"3 * (z * (y ^^^ 2 * x ^^^ 5)) ~= 0\"]") then ()
511 else error "rational.sml cancel Schalk e186d";
513 writeln "example 188:";
514 val e188a'="(-8 + 8 * x) / (-9 + 9 * x)";(*SRC*)
515 val e188a = the (rewrite_set thy' false "cancel" e188a');
516 is_expanded (parse_rat "8 * x + -8");
517 (* e188a = ("8 / 9",["not ((-1) + x = 0)"]) then () 13.3.03*)
518 if e188a = ("8 / 9", "[\"-1 + x ~= 0\"]") then ()
519 else error "rational.sml: e188a new behaviour";
521 val SOME (t,_) = rewrite_set thy' false mp "(8*((-1) + x))/(9*((-1) + x))";
523 val e188b'="(-15 + 5 * x) / (-18 + 6 * x)";(*SRC*)
524 val SOME (t, asm) = rewrite_set thy' false "cancel" e188b';
525 t = "5 / 6" (*true*);
528 val e188c'="( a + -1 * b ) / ( b + -1 * a )";
529 val e188c = the (rewrite_set thy' false "cancel_p" e188c');
530 (*is_expanded (parse_rat "a + -1 * b");*)
532 rewrite_set thy' false mp "((-1)*(b + (-1) * a))/(1*(b + (-1) * a))";
533 if t= "(a + -1 * b) / (-1 * a + b)" then()
534 else error "rational.sml: e188c new behaviour";
536 writeln ("example 190:");
538 val e190c'="( 27 * a^^^3 + 9 * a^^^2 + 3 * a + 1 ) / ( 27 * a^^^3 + 18 * a^^^2 + 3 * a )";
539 val e190c = the (rewrite_set thy' false "cancel" e190c');
540 val SOME (t,_) = rewrite_set thy' false mp "((1 + 9 * a ^^^ 2)*(1 + 3 * a))/((3 * a + 9 * a ^^^ 2)*(1 + 3 * a))";
541 if t = "(1 + 3 * a + 9 * a ^^^ 2 + 27 * a ^^^ 3) /\n(3 * a + 18 * a ^^^ 2 + 27 * a ^^^ 3)" then ()
542 else error "rational.sml: e190c new behaviour";
544 writeln ("example 191:");
546 val e191a'="( x^^^2 + -1 * y^^^2 ) / ( x + y )";
548 val e191a = the (rewrite_set thy' false "cancel" e191a');
549 is_expanded (parse_rat "x^^^2 + -1 * y^^^2");
551 is_expanded (parse_rat "x + y");
553 val SOME (t,_) = rewrite_set thy' false mp "((x + (-1) * y)*(x + y))/((1)*(x + y))";
554 (* t="(x ^^^ 2 + -1 * y ^^^ 2) / (x + y)" then() WN.13.3.03*)
555 if t="(x ^^^ 2 + -1 * y ^^^ 2) / (x + y)" then()
556 else error "rational.sml: e191a new behaviour";
559 val e191c'="( 9 * x^^^2 + -30 * x + 25 ) / ( 9 * x^^^2 + -25 )";
561 val e191c = the (rewrite_set thy' false "cancel" e191c');
562 is_expanded (parse_rat "9 * x^^^2 + -30 * x + 25");
564 is_expanded (parse_rat "25 + -30*x + 9*x^^^2");
566 is_expanded (parse_rat "-25 + 9*x^^^2");
568 val SOME (t,_) = rewrite_set thy' false mp "(((-5) + 3 * x)*((-5) + 3 * x))/((5 + 3 * x)*((-5) + 3 * x))";
569 (* t="(25 + ((-30) * x + 9 * x ^^^ 2)) / ((-25) + 9 * x ^^^ 2)"then() 13.3.03*)
570 if t= "(25 + -30 * x + 9 * x ^^^ 2) / (-25 + 9 * x ^^^ 2)" then()
571 else error "rational.sml: 'e191c' new behaviour";
574 writeln ("example 192:");
576 val e192b'="( 7 * x^^^3 + -1 * x^^^2 * y ) / ( 7 * x * y^^^2 + -1 * y^^^3 )";
578 val e192b = the (rewrite_set thy' false "cancel" e192b');
579 -------------------*)
580 val SOME (t',_) = rewrite_set thy' false mp "((x ^^^ 2)*(7 * x + (-1) * y))/((y ^^^ 2)*(7 * x + (-1) * y))";
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";
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";
612 "-------- common_nominator_p ----------------------------";
613 "-------- common_nominator_p ----------------------------";
614 "-------- common_nominator_p ----------------------------";
615 val rls' = "common_nominator_p";
617 writeln ("example 204:");
619 val e204a'="((5 * x) / 9) + ((3 * x) / 9) + (x / 9)";
620 val e204a = the (rewrite_set thy' false "common_nominator_p" e204a');
622 val e204b'="5 / x + -3 / x + -1 / x";
623 val e204b = the (rewrite_set thy' false "common_nominator_p" e204b');
624 if e204b = ("1 / x", "[]") then ()
625 else error "rational.sml common_nominator_p example e204b";
627 writeln ("example 205:");
629 val e205a'="((4 * x + 7) / 8) + ((4 * x + 3) / 8)";
630 val e205a = the (rewrite_set thy' false "common_nominator_p" e205a');
632 val e205b'="((5 * x + 2) / 3) + ((-2 * x + 1) / 3)";
633 val e205b = the (rewrite_set thy' false "common_nominator_p" e205b');
634 if e205b = ("(1 + x) / 1", "[]") then ()
635 else error "rational.sml common_nominator_p example e204b";
637 writeln ("example 206:");
639 val e206a'="((5 * x + 4) / (2 * x + -1)) + ((9 * x + 5) / (2 * x + -1))";
640 val e206a = the (rewrite_set thy' false "common_nominator_p" e206a');
642 val e206b'="((17 * x + -23) / (5 * x + 4)) + ((-25 + -17 * x) / (5 * x + 4))";
643 val e206b = the (rewrite_set thy' false "common_nominator_p" e206b');
645 writeln ("example 207:");
646 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)) ";
647 val e207 = the (rewrite_set thy' false "common_nominator_p" e207');
649 writeln ("example 208:");
650 val e208'="((3 * x + 2) / (x + 2)) + ((5 * x + -1) / (x + 2)) + ((-7 * x + -3) / (x + 2)) + ((-1 * x + -3) / (x + 2)) ";
651 val e208 = the (rewrite_set thy' false "common_nominator_p" e208');
653 writeln ("example 209:");
654 val e209'="((3 * x + -7 * y + 3 * z) / (4)) + ((2 * x + 17 * y + 10 * z) / (4)) + ((-1 * x + 2 * y + z) / (4)) ";
655 val e209 = the (rewrite_set thy' false "common_nominator_p" e209');
657 writeln ("example 210:");
658 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)) ";
659 val e210 = the (rewrite_set thy' false "common_nominator_p" e210');
661 writeln ("example 211:");
663 val e211a'="((b) / (a + -1 * b)) + ((-1 * a) / (a + -1 * b))";
664 val e211a = the (rewrite_set thy' false "common_nominator_p" e211a');
666 val e211b'="((b) / (b^^^2 + -1 * a^^^2)) + ((-1 * a) / (b^^^2 + -1 * a^^^2))";
667 val e211b = the (rewrite_set thy' false "common_nominator_p" e211b');
669 writeln ("example 212:");
671 val e212a'="((4) / (x)) + ((-3) / (y)) + -1";
672 val e212a = the (rewrite_set thy' false "common_nominator_p" e212a');
674 val e212b'="((4) / (x)) + ((-5) / (y)) + ((6) / (x*y))";
675 val e212b = the (rewrite_set thy' false "common_nominator_p" e212b');
677 writeln ("example 213:");
679 val e213a'="((5 * x) / (3 * y^^^2)) + ((19 * z) / (6 * x * y)) + ((-2 * x) / (3 * y^^^2)) + ((7 * y^^^2) / (6 * x^^^2)) ";
680 val e213a = the (rewrite_set thy' false "common_nominator_p" e213a');
682 val e213b'="((2 * b) / (3 * a^^^2)) + ((3 * c) / (7 * a * b)) + ((4 * b) / (3 * a^^^2)) + ((3 * a) / (7 * b^^^2))";
683 val e213b = the (rewrite_set thy' false "common_nominator_p" e213b');
685 writeln ("example 214:");
687 val e214a'="((3 * x + 2 * y + 2 * z) / (4)) + ((-5 * x + -3 * y) / (3)) + ((x + y + -2 * z) / (2))";
688 val e214a = the (rewrite_set thy' false "common_nominator_p" e214a');
690 val e214b'="((5 * x + 2 * y + z) / (2)) + ((-7 * x + -3 * y) / (3)) + ((3 * x + 6 * y + -1 * z) / (12))";
691 val e214b = the (rewrite_set thy' false "common_nominator_p" e214b');
693 writeln ("example 216:");
695 val e216a'="((2 * b + 3 * c) / (a * c)) + ((3 * a + b) / (a * b)) + ((-2 * b^^^2 + -3 * a * c) / (a * b * c))";
696 val e216a = the (rewrite_set thy' false "common_nominator_p" e216a');
698 val e216b'="((2 * a + 3 * b) / (b * c)) + ((3 * c + a) / (a * c)) + ((-2 * a^^^2 + -3 * b * c) / (a * b * c))";
699 val e216b = the (rewrite_set thy' false "common_nominator_p" e216b');
701 writeln ("example 217:");
702 val e217'="((z + -1) / (z)) + ((3 * z ^^^2 + -6 * z + 5) / (z^^^2)) + ((-4 * z^^^3 + 7 * z^^^2 + -5 * z + 5) / (z^^^3))";
703 val e217 = the (rewrite_set thy' false "common_nominator_p" e217');
706 val rls' = "common_nominator";
707 writeln ("example 218:");
708 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))";
709 val e218 = the (rewrite_set thy' false "common_nominator" e218');
710 if e218 = ("(16 - 63 * a ^^^ 2 - 81 * a ^^^ 3) / (108 * a ^^^ 4)", "[]") then ()
711 else error "rationa.sml common_nominator example e218";
713 writeln ("example 219:");
715 val e219a'="((1) / (y + 1)) + ((1) / (y + 2)) + ((1) / (y + 3))";
716 val e219a = the (rewrite_set thy' false "common_nominator" e219a');
718 val e219b'="((1) / (x + 1)) + ((1) / (x + 2)) + ((-2) / (x + 3))";
719 val e219b = the (rewrite_set thy' false "common_nominator" e219b');
720 if e219b = ("(5 + 3 * x) / (6 + 11 * x + 6 * x ^^^ 2 + x ^^^ 3)", "[]") then ()
721 else error "rationa.sml common_nominator example e219b";
723 writeln ("example 220:");
725 val e220a'="((17) / (5 * r + -2)) + ((-13) / (2 * r + 3)) + ((4) / (3 * r + -5))";
726 val e220a = the (rewrite_set thy' false "common_nominator" e220a');
728 val e220b'="((20 * a) / (a + -3)) + ((-19 * a) / (a + -4)) + ((a) / (a + -5))";
729 val e220b = the (rewrite_set thy' false "common_nominator" e220b');
731 writeln ("example 221:");
733 val e221a'="((a + b) / (a + -1 * b)) + ((a + -1 * b) / (a + b))";
734 val e221a = the (rewrite_set thy' false "common_nominator" e221a');
736 val e221b'="((x + -1 * y) / (x + y)) + ((x + y) / (x + -1 * y)) ";
737 val e221b = the (rewrite_set thy' false "common_nominator" e221b');
739 writeln ("example 222:");
741 val e222a'="((1 + -1 * x) / (1 + x)) + ((-1 + -1 * x) / (1 + -1 * x)) + ((4 * x) / (1 + -1 * x^^^2))";
742 val e222a = the (rewrite_set thy' false "common_nominator" e222a');
744 val e222b'="((1 + x ) / (1 + -1 * x)) + ((-1 + x) / (1 + x)) + ((2 * x) / (1 + -1 * x^^^2))";
745 val e222b = the (rewrite_set thy' false "common_nominator" e222b');
747 writeln ("example 225:");
749 val e225a'="((6 * a) / (a^^^2 + -64)) + ((a + 2) / (2 * a + 16)) + ((-1) / (2))";
750 val e225a = the (rewrite_set thy' false "common_nominator" e225a');
752 val e225b'="((a + 2 ) / (2 * a + 12)) + ((4 * a) / (a^^^2 + -36)) + ((-1) / (2))";
753 val e225b = the (rewrite_set thy' false "common_nominator" e225b');
755 writeln ("example 226:");
757 val e226a'="((35 * z) / (49 * z^^^2 + -4)) + -1 + ((14 * z + -1) / (14 * z + 4)) ";
758 val e226a = the (rewrite_set thy' false "common_nominator" e226a');
760 val e226b'="((45 * a * b) / (25 * a^^^2 + -9 * b^^^2)) + ((20 * a + 3 * b) / (10 * a + 6 * b)) + -2";
761 val e226b = the (rewrite_set thy' false "common_nominator" e226b');
763 writeln ("example 227:");
765 val e227a'="((6 * z + 11) / (6 * z + 14)) + ((9 * z ) / (9 * z^^^2 + -49)) + -1 ";
766 val e227a = the (rewrite_set thy' false "common_nominator" e227a');
768 val e227b'="((16 * a + 37 * b) / (4 * a + 10 * b)) + ((6 * a * b) / (4 * a^^^2 + -25 * b^^^2)) + -4 ";
769 val e227b = the (rewrite_set thy' false "common_nominator" e227b');
771 writeln ("example 228:");
773 val e228a'="((7 * a + 11) / (3 * a^^^2 + -3)) + ((-2 * a + -1) / (a^^^2 + -1 * a)) + ((-1) / (3 * a + 3))";
774 val e228a = the (rewrite_set thy' false "common_nominator" e228a');
776 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))";
777 val e228b = the (rewrite_set thy' false "common_nominator" e228b');
780 writeln ("example 229:");
782 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))";
783 val e229a = the (rewrite_set thy' false "common_nominator" e229a');
785 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))";
786 val e229b = the (rewrite_set thy' false "common_nominator" e229b');
788 writeln ("example 230:");
790 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))";
791 val e230a = the (rewrite_set thy' false "common_nominator" e230a');
793 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))";
794 val e230b = the (rewrite_set thy' false "common_nominator" e230b');
796 writeln ("example 231:");
798 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))";
799 val e231a = the (rewrite_set thy' false "common_nominator" e231a');
801 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))";
802 val e231b = the (rewrite_set thy' false "common_nominator" e231b');
804 writeln ("example 232:");
806 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))";
807 val e232a = the (rewrite_set thy' false "common_nominator" e232a');
809 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))";
810 val e232b = the (rewrite_set thy' false "common_nominator" e232b');
812 writeln ("example 233:");
814 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))";
815 val e233a = the (rewrite_set thy' false "common_nominator" e233a');
817 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))";
818 val e233b = the (rewrite_set thy' false "common_nominator" e233b');
820 writeln ("example 234:");
822 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))";
823 val e234a = the (rewrite_set thy' false "common_nominator" e234a');
825 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)) ";
826 val e234b = the (rewrite_set thy' false "common_nominator" e234b');
828 writeln ("example 235:");
830 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))";
831 val e235a = the (rewrite_set thy' false "common_nominator" e235a');
833 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)) ";
834 val e235b = the (rewrite_set thy' false "common_nominator" e235b');
836 writeln ("example 236:");
838 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))";
839 val e236a = the (rewrite_set thy' false "common_nominator" e236a');
841 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)) ";
842 val e236b = the (rewrite_set thy' false "common_nominator" e236b');
846 writeln ("example heuberger:");
847 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)";
848 val eheu = the (rewrite_set thy' false "cancel" eheu');
850 val rls' = "common_nominator_p";
851 writeln ("example stiefel:");
852 val est1'="(7) / (-14) + (-2) / (4)";
853 val est1 = the (rewrite_set thy' false "common_nominator_p" est1');
854 if est1 = ("-1 / 1", "[]") then ()
855 else error "new behaviour in rational.sml: est1'";
857 val t = (term_of o the o (parse thy))
858 "(9 - x ^^^ 2) / (9 - 6 * x + x ^^^ 2)";
859 val SOME (t',_) = factout_ thy t;
860 if term2str t' = "(3 + x) * (3 - x) / ((3 - x) * (3 - x))" then ()
861 else error "rational.sml factout_ (9 - x ^^^ 2) / (9 - 6 * x + x ^^^ 2)";
864 "-------- reverse rewrite -------------------------------";
865 "-------- reverse rewrite -------------------------------";
866 "-------- reverse rewrite -------------------------------";
867 (*WN.28.8.02: tests for the 'reverse-rewrite' functions:
868 these are defined in Rationals.ML and stored in
869 the 'reverse-ruleset' cancel*)
871 (*the term for which reverse rewriting is demonstrated*)
872 val t = (term_of o the o (parse thy))
873 "(9 - x ^^^ 2) / (9 + 6 * x + x ^^^ 2)";
874 val Rrls {scr=Rfuns {init_state=ini,locate_rule=loc,
875 next_rule=nex,normal_form=nor,...},...} = cancel;
877 (*normal_form produces the result in ONE step*)
878 val SOME (t',_) = nor t;
879 if term2str t' = "(3 - x) / (3 + x)" then ()
880 else error "rational.sml normal_form (9 - x ^^^ 2) / (9 - 6 * x + x ^^^ 2)";
882 (*initialize the interpreter state used by the 'me'*)
883 val (t,_,revsets,_) = ini t;
885 (*find the rule 'r' to apply to term 't'*)
886 val SOME (r as (Thm (str, thm))) = nex revsets t;
887 if str = "sym_#power_Float ((3,0), (0,0)) __ ((2,0), (0,0))"
888 andalso string_of_thm thm =
889 (string_of_thm o make_thm o (cterm_of (theory "Isac")))
890 (Trueprop $ (term_of o the o (parse thy)) "9 = 3 ^^^ 2") then ()
891 else error "rational.sml next_rule (9 - x ^^^ 2) / (9 - 6 * x + x ^^^ 2)";
892 (* before Isa02->09-2 was not checked automatically, ?was different?:
893 val SOME r = nex revsets t;
894 val r = Thm ("sym_#mult_2_3","6 = 2 * 3") : rule*)
896 (* check, if the rule 'r' applied by the user to 't' belongs to the ruleset;
897 if the rule is OK, the term resulting from applying the rule is returned,too;
898 there might be several rule applications inbetween,
899 which are listed after the head in reverse order *)
900 val (r, (t, asm))::_ = loc revsets t r;
901 if term2str t = "(9 - x ^^^ 2) / (3 ^^^ 2 + 6 * x + x ^^^ 2)" andalso asm = []
903 else error "rational.sml locate_rule (9 - x ^^^ 2) / (9 - 6 * x + x ^^^ 2)";
905 (* find the next rule to apply *)
906 val SOME (r as (Thm (str, thm))) = nex revsets t;
907 if str = "sym_#power_Float ((3,0), (0,0)) __ ((2,0), (0,0))" andalso
908 string_of_thm thm = (string_of_thm o make_thm o (cterm_of (theory "Isac")))
909 (Trueprop $ (term_of o the o (parse thy)) "9 = 3 ^^^ 2") then ()
910 else error "rational.sml next_rule (9 - x ^^^ 2) / (9 - 6 * x + x ^^^ 2)";
912 (*check the next rule*)
913 val (r, (t, asm)) :: _ = loc revsets t r;
914 if term2str t = "(3 ^^^ 2 - x ^^^ 2) / (3 ^^^ 2 + 6 * x + x ^^^ 2)" then ()
915 else error "rational.sml locate_rule (9 - x ^^^ 2) / (9 - 6 * x + x ^^^ 2) II";
917 (*find and check the next rules, rewrite*)
918 val SOME r = nex revsets t;
919 val (r,(t,asm))::_ = loc revsets t r;
920 if term2str t = "(3 ^^^ 2 - x ^^^ 2) / (3 ^^^ 2 + 2 * 3 * x + x ^^^ 2)" then ()
921 else error "rational.sml locate_rule II";
923 val SOME r = nex revsets t;
924 val (r,(t,asm))::_ = loc revsets t r;
925 if term2str t = "(3 - x) * (3 + x) / (3 ^^^ 2 + 2 * 3 * x + x ^^^ 2)" then ()
926 else error "rational.sml next_rule II";
928 val SOME r = nex revsets t;
929 val (r,(t,asm))::_ = loc revsets t r;
930 if term2str t = "(3 - x) * (3 + x) / ((3 + x) * (3 + x))" then ()
931 else error "rational.sml next_rule III";
933 val SOME r = nex revsets t;
934 val (r, (t, asm)) :: _ = loc revsets t r;
936 if ss = "(3 - x) / (3 + x)" andalso terms2str asm = "[\"3 + x ~= 0\"]" then ()
937 else error "rational.sml: new behav. in rev-set cancel";
940 "-------- 'reverse-ruleset' cancel_p --------------------";
941 "-------- 'reverse-ruleset' cancel_p --------------------";
942 "-------- 'reverse-ruleset' cancel_p --------------------";
943 (*WN.11.9.02: the 'reverse-ruleset' cancel_p*)
945 (*the term for which reverse rewriting is demonstrated*)
946 val t = str2term "(9 + (-1)*x^^^2) / (9 + ((-6)*x + x^^^2))";
947 val Rrls {scr=Rfuns {init_state=ini,locate_rule=loc,
948 next_rule=nex,normal_form=nor,...},...} = cancel_p;
950 (*normal_form produces the result in ONE step*)
951 val SOME (t',_) = nor t;
952 term2str t' = "(3 + 1 * x) / (3 + -1 * x)";
954 (*initialize the interpreter state used by the 'me'*)
955 val SOME (t', asm) = cancel_p_ thy t;
956 term2str t' = "(3 + x) / (3 + -1 * x)" (*true*);
957 terms2str asm = "[\"3 + -1 * x ~= 0\"]" (*true*);
958 val (t,_,revsets,_) = ini t;
960 (* WN.10.10.02: dieser Fall terminiert nicht
961 (make_polynomial enth"alt zu viele rules)
962 WN060823 'init_state' requires rewriting on specified location in the term
963 print_depth 99; Rfuns; print_depth 3;
964 WN060831 cycling "sym_order_mult_rls_" "sym_real_mult_assoc"
965 as was with make_polynomial before ?!?*)
967 val SOME r = nex revsets t;
968 eq_Thm (r, Thm ("sym_#power_Float ((3,0), (0,0)) __ ((2,0), (0,0))",
969 mk_thm thy "9 = 3 ^^^ 2"));
970 (*WN060831 *** id_of_thm
971 Exception- ERROR raised ...
972 val (r,(t,asm))::_ = loc revsets t r;
975 val SOME r = nex revsets t;
976 val (r,(t,asm))::_ = loc revsets t r;
980 writeln "****************** all tests successfull *************************";
984 (*WN.17.3.03 =========================================================vvv---*)
985 "-------- norm_Rational ---------------------------------";
986 "-------- norm_Rational ---------------------------------";
987 "-------- norm_Rational ---------------------------------";
988 val t = str2term "(3*x+5)/18 - x/2 - -(3*x - 2)/9 = 0";
989 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
990 if term2str t' = "1 / 18 = 0" then () else error "rational.sml 1";
992 val t = str2term "(17*x - 51)/9 - (-(13*x - 3)/6) + 11 - (9*x - 7)/4 = 0";
993 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
994 if term2str t' = "(237 + 65 * x) / 36 = 0" then ()
995 else error "rational.sml 2";
997 val t = str2term "(1/2 + (5*x)/2)^^^2 - ((13*x)/2 - 5/2)^^^2 - (6*x)^^^2 + 29";
998 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
999 if term2str t' = "23 + 35 * x + -72 * x ^^^ 2" then ()
1000 else error "rational.sml 3";
1002 (*trace_rewrite:=true;*)
1003 val t = str2term "Not (6*x is_atom)";
1004 val SOME (t',_) = rewrite_set_ thy false powers_erls t; term2str t';
1006 val t = str2term "1 < 2";
1007 val SOME (t',_) = rewrite_set_ thy false powers_erls t; term2str t';
1010 val t = str2term "(6*x)^^^2";
1011 val SOME (t',_) = rewrite_ thy dummy_ord powers_erls false
1012 (num_str @{thm realpow_def_atom}) t;
1013 if term2str t' = "6 * x * (6 * x) ^^^ (2 + -1)" then ()
1014 else error "rational.sml powers_erls (6*x)^^^2";
1016 val t = str2term "-1 * (-2 * (5 / 2 * (13 * x / 2)))";
1017 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
1018 if term2str t' = "65 * x / 2" then () else error "rational.sml 4";
1020 val t = str2term "1 - ((13*x)/2 - 5/2)^^^2";
1021 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
1022 (*bef.040209: if term2str t' = "(-21 + (130 * x + -169 * x ^^^ 2)) / 4"then()*)
1023 if term2str t' = "(-21 + 130 * x + -169 * x ^^^ 2) / 4" then ()
1024 else error "rational.sml 5";
1026 (*SRAM Schalk I, p.92 Nr. 609a*)
1027 val t = str2term "2*(3 - x/5)/3 - 4*(1 - x/3) - x/3 - 2*(x/2 - 1/4)/27 +5/54";
1028 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
1029 if term2str t' = "(-255 + 112 * x) / 135" then ()
1030 else error "rational.sml 6";
1032 (*SRAM Schalk I, p.92 Nr. 610c*)
1033 val t = str2term "((x- 1)/(x+1) + 1) / ((x- 1)/(x+1) - (x+1)/(x- 1)) - 2";
1034 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
1035 if term2str t' = "(-3 + -1 * x) / 2" then () else error "rational.sml 7";
1037 (*SRAM Schalk I, p.92 Nr. 476a*)
1038 val t = str2term "(x^^^2/(1 - x^^^2) + 1)/(x/(1 - x) + 1) * (1 + x)";
1039 (*. a/b : c/d translated to a/b * d/c .*)
1040 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
1041 (*if term2str t' = "1 / 1" then () else error "rational.sml 8";3.6.03*)
1042 if term2str t' = "1" then () else error "rational.sml 8";
1044 (*............................vvv---TODO: sollte gehen mit poly_order *)
1045 (*Schalk I, p.92 Nr. 472a*)
1046 val t = str2term "((8*x^^^2 - 32*y^^^2)/(2*x + 4*y))/((4*x - 8*y)/(x + y))";
1047 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
1048 if term2str t' = "x + y" then () else error "rational.sml p.92 Nr. 472a";
1050 (*Schalk I, p.70 Nr. 480b; a/b : c/d translated to a/b * d/c*)
1051 val t = str2term ("((12*x*y/(9*x^^^2 - y^^^2))/" ^
1052 "(1/(3*x - y)^^^2 - 1/(3*x + y)^^^2)) *" ^
1053 "(1/(x - 5*y)^^^2 - 1/(x + 5*y)^^^2)/" ^
1054 "(20*x*y/(x^^^2 - 25*y^^^2))");
1055 (*... nicht simpl, zerlegt ...*)
1056 val t = str2term ("((12*x*y/(9*x^^^2 - y^^^2))/" ^
1057 "(1/(3*x - y)^^^2 - 1/(3*x + y)^^^2))");
1058 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
1059 "(-12 * (x * y ^^^ 3) + 108 * (x * (y * x ^^^ 2))) / (12 * (x * y))";
1060 (* ~~~~~~~~~~ poly_order notwendig!*)
1061 val t = str2term ("(1/(x - 5*y)^^^2 - 1/(x + 5*y)^^^2)/" ^
1062 "(20*x*y/(x^^^2 - 25*y^^^2))");
1063 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
1064 if term2str t' = "1 / (x ^^^ 2 + -25 * y ^^^ 2)" then ()
1065 else error "rational.sml norm_Rational 1 / (x ^^^ 2 + -25 * y ^^^ 2)";
1067 "nonterm.SK6 ----- SK060904-2a non-termination of add_fraction_p_";
1068 (*WN.2.6.03 from rlang.sml 56a
1069 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)";
1070 val NONE = rewrite_set_ thy false common_nominator_p t;
1072 WN060831 nonterm.SK7
1073 val t = str2term "(a + b * x) / (a + -1 * (b * x)) + (-1 * a + b * x) / (a + b * x)";
1074 val NONE = add_fraction_p_ thy t;
1078 (* ------------------------------------------------------------------- *)
1079 (*---------vvv------------ MG: ab 1.7.03 ----------------vvv-----------*)
1080 (* Simplifier fuer beliebige Buchterme *)
1081 (* ------------------------------------------------------------------- *)
1082 (*----------------------- norm_Rational_mg ----------------------------*)
1083 (* ------------------------------------------------------------------- *)
1085 "-------- numeral rationals -----------------------------";
1086 "-------- numeral rationals -----------------------------";
1087 "-------- numeral rationals -----------------------------";
1088 (*SRA Schalk I, p.40 Nr. 164b *)
1089 val t = str2term "(47/6 - 76/9 + 13/4)/(35/12)";
1090 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1092 if (term2str t) = "19 / 21" then ()
1093 else error "rational.sml: diff.behav. in norm_Rational_mg 1";
1095 (*SRA Schalk I, p.40 Nr. 166a *)
1096 val t = str2term "((5/4)/(4+22/7) + 37/20)*(110/3 - 110/9 * 23/11)";
1097 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1099 if (term2str t) = "45 / 2" then ()
1100 else error "rational.sml: diff.behav. in norm_Rational_mg 2";
1103 "-------- cancellation ----------------------------------";
1104 "-------- cancellation ----------------------------------";
1105 "-------- cancellation ----------------------------------";
1106 (* e190c Stefan K.*)
1108 "((1 + 9 * a ^^^ 2)*(1 + 3 * a))/((3 * a + 9 * a ^^^ 2)*(1 + 3 * a))";
1109 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1112 "(1 + 9 * a ^^^ 2) / (3 * a + 9 * a ^^^ 2)"
1114 else error "rational.sml: diff.behav. in norm_Rational_mg 3";
1116 (* e192b Stefan K.*)
1118 "((x ^^^ 2)*(7 * x + (-1) * y))/((y ^^^ 2)*(7 * x + (-1) * y))";
1119 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1124 else error "rational.sml: diff.behav. in norm_Rational_mg 4";
1126 (*SRC Schalk I, p.66 Nr. 379c *)
1129 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1134 else error "rational.sml: diff.behav. in norm_Rational_mg 5";
1136 (*SRC Schalk I, p.66 Nr. 380b *)
1138 "15*(3*x+3)*(4*x+9)/(12*(2*x+7)*(5*x+5))";
1139 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1142 "(27 + 12 * x) / (28 + 8 * x)"
1144 else error "rational.sml: diff.behav. in norm_Rational_mg 6";
1146 (*Schalk I, p.60 Nr. 215c *)
1147 (* Falsches Ergebnis: rechnet lange und cancel_p kann nicht weiter krzen!!!*)
1149 val t = str2term "(a+b)^^^4*(x - y)/((x - y)^^^3*(a+b)^^^2)";
1150 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1153 "(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)"
1155 else error "rational.sml: diff.behav. in norm_Rational_mg 7";
1158 "(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)"
1159 val SOME (t,_) = rewrite_set_ thy false cancel_p t;
1161 (* uncaught exception nonexhaustive binding failure
1162 raised at: stdIn:93.1-93.51 *)
1164 (*Schalk I, p.66 Nr. 381a *)
1165 (* ACHTUNG: rechnet ca. 2 Minuten !!! *)
1167 val t = str2term "18*(a+b)^^^3*(a - b)^^^2/(72*(a - b)^^^3*(a+b)^^^2)";
1168 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1171 "(a + b) / (4 * a + -4 * b)"
1172 then () else error "rational.sml: diff.behav. in norm_Rational_mg 8";
1175 (*SRC Schalk I, p.66 Nr. 381b *)
1177 "(4*x^^^2 - 20*x + 25)/(2*x - 5)^^^3";
1178 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1183 else error "rational.sml: diff.behav. in norm_Rational_mg 9";
1185 (*SRC Schalk I, p.66 Nr. 381c *)
1187 "(27*a^^^3+9*a^^^2+3*a+1)/(27*a^^^3+18*a^^^2+3*a)";
1188 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1191 "(1 + 9 * a ^^^ 2) / (3 * a + 9 * a ^^^ 2)"
1193 else error "rational.sml: diff.behav. in norm_Rational_mg 10";
1195 (*SRC Schalk I, p.66 Nr. 383a *)
1197 "(5*a^^^2 - 5*a*b)/(a - b)^^^2";
1198 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1201 "5 * a / (a + -1 * b)"
1203 else error "rational.sml: diff.behav. in norm_Rational_mg 11";
1206 "-------- common denominator ----------------------------";
1207 "-------- common denominator ----------------------------";
1208 "-------- common denominator ----------------------------";
1209 (*SRA Schalk I, p.67 Nr. 403a *)
1212 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1215 "(-3 * x + 4 * y + -1 * x * y) / (x * y)"
1217 else error "rational.sml: diff.behav. in norm_Rational_mg 12";
1219 (*SRA Schalk I, p.67 Nr. 407b *)
1221 "(2*a+3*b)/(b*c) + (3*c+a)/(a*c) - (2*a^^^2+3*b*c)/(a*b*c)";
1222 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1227 else error "rational.sml: diff.behav. in norm_Rational_mg 13";
1229 (*SRA Schalk I, p.67 Nr. 410b *)
1231 "1/(x+1) + 1/(x+2) - 2/(x+3)";
1232 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1235 "(5 + 3 * x) / (6 + 11 * x + 6 * x ^^^ 2 + x ^^^ 3)"
1237 else error "rational.sml: diff.behav. in norm_Rational_mg 14";
1239 (*SRA Schalk I, p.67 Nr. 413b *)
1241 "(1+x)/(1 - x) - (1 - x)/(1+x) + 2*x/(1 - x^^^2)";
1242 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1245 "6 * x / (1 + -1 * x ^^^ 2)"
1247 else error "rational.sml: diff.behav. in norm_Rational_mg 15";
1249 (*SRA Schalk I, p.68 Nr. 414a *)
1251 "(x + 2)/(x - 1) + (x - 3)/(x - 2) - (x + 1)/((x - 1)*(x - 2))";
1252 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1255 "(-2 + -5 * x + 2 * x ^^^ 2) / (2 + -3 * x + x ^^^ 2)"
1257 else error "rational.sml: diff.behav. in norm_Rational_mg 16";
1259 (*SRA Schalk I, p.68 Nr. 423a *)
1261 "(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)";
1262 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1267 else error "rational.sml: diff.behav. in norm_Rational_mg 17";
1269 (*SRA Schalk I, p.68 Nr. 428b *)
1271 "1/(a - b)^^^2 + 1/(a+b)^^^2 - 2/(a^^^2 - b^^^2) - 4*(b^^^2 - 1)/(a^^^2 - b^^^2)^^^2";
1272 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1275 "4 / (a ^^^ 4 + -2 * a ^^^ 2 * b ^^^ 2 + b ^^^ 4)"
1277 else error "rational.sml: diff.behav. in norm_Rational_mg 18";
1279 (*SRA Schalk I, p.68 Nr. 430b *)
1281 "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";
1282 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1287 else error "rational.sml: diff.behav. in norm_Rational_mg 19";
1290 (*SRA Schalk I, p.68 Nr. 432 *)
1292 "(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)";
1293 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1298 else error "rational.sml: diff.behav. in norm_Rational_mg 20";
1303 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1306 "(3 * y + b * x) / (b * y)"
1308 else error "rational.sml: diff.behav. in norm_Rational_mg 21";
1311 "-------- multiply and cancel ---------------------------";
1312 "-------- multiply and cancel ---------------------------";
1313 "-------- multiply and cancel ---------------------------";
1314 (*SRM Schalk I, p.68 Nr. 436a *)
1316 "3*(x+y)/(15*(x - y)) * 25*(x - y)^^^2/(18*(x+y)^^^2)";
1317 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1320 "(5 * x + -5 * y) / (18 * x + 18 * y)"
1322 else error "rational.sml: diff.behav. in norm_Rational_mg 22";
1324 (*SRM.test Schalk I, p.68 Nr. 436b *)
1325 (*WN060420???MG3 crashes with method 'simplify' in
1326 IsacCore > Simplification > Rational Terms > Multiplication > No.2*)
1327 val t = str2term "5*a*(a - b)^^^2*(a + b)^^^3/(7*b*(a - b)^^^3) * 7*b/(a + b)^^^3";
1328 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1331 "5 * a / (a + -1 * b)"
1333 else error "rational.sml: diff.behav. in norm_Rational_mg 23";
1335 (*Schalk I, p.68 Nr. 437a *)
1336 val t = str2term "(3*a - 4*b)/(4*c+3*e) * (3*a+4*b)/(9*a^^^2 - 16*b^^^2)";
1337 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1338 if (term2str t) = "1 / (4 * c + 3 * e)" then ()
1339 else error "rational.sml: diff.behav. in norm_Rational_mg 24";
1341 "----- S.K. corrected non-termination 060904";
1342 val t = str2term "(3*a - 4*b) * (3*a+4*b)/((4*c+3*e)*(9*a^^^2 - 16*b^^^2))";
1343 val SOME (t',_) = rewrite_set_ thy false make_polynomial t;
1344 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 ()
1345 else error "rational.sml: S.K.8..corrected 060904-6";
1347 "----- S.K. corrected non-termination of cancel_p_";
1348 val t'' = str2term ("(9 * a ^^^ 2 + -16 * b ^^^ 2) /" ^
1349 "(36 * a^^^2 * c + (27 * a^^^2 * e + (-64 * b^^^2 * c + -48 * b^^^2 * e)))");
1350 val SOME (t',_) = rewrite_set_ thy false cancel_p t'';
1351 if term2str t' = "1 / (4 * c + 3 * e)" then ()
1352 else error "rational.sml: diff.behav. in cancel_p S.K.8";
1354 (*Schalk I, p.68 Nr. 437b *)
1355 (* nonterm.SK9 loops: cancel_p kann nicht weiter kuerzen!!! *)
1356 val t'' = str2term "(a + b)/(x^^^2 - y^^^2) * ((x - y)^^^2/(a^^^2 - b^^^2))";
1357 (* val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t'';
1360 "================delete===";
1361 (*a casual output from above*)
1363 "(a * x ^^^ 2 + -2 * a * x * y + a * y ^^^ 2 + b * x ^^^ 2 + -2 * b * x * y + b * y ^^^ 2) /(a ^^^ 2 * x ^^^ 2 + -1 * a ^^^ 2 * y ^^^ 2 + -1 * b ^^^ 2 * x ^^^ 2 + b ^^^ 2 * y ^^^ 2)";
1364 (* WN060831 nonterm.SK10
1365 val SOME (t,_) = rewrite_set_ thy false cancel_p t;
1369 (*SRM Schalk I, p.68 Nr. 438a *)
1371 "x*y/(x*y - y^^^2)*(x^^^2 - x*y)";
1372 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1377 else error "rational.sml: diff.behav. in norm_Rational_mg 24";
1379 (*SRM Schalk I, p.68 Nr. 439b *)
1381 "(4*x^^^2+4*x+1)*((x^^^2 - 2*x^^^3)/(4*x^^^2+2*x))";
1382 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1385 "(x + -4 * x ^^^ 3) / 2"
1387 else error "rational.sml: diff.behav. in norm_Rational_mg 25";
1389 (*SRM Schalk I, p.68 Nr. 440a *)
1391 "(x^^^2 - 2*x)/(x^^^2 - 3*x) * (x - 3)^^^2/(x^^^2 - 4)";
1392 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1395 "(-3 + x) / (2 + x)"
1397 else error "rational.sml: diff.behav. in norm_Rational_mg 26";
1399 "----- Schalk I, p.68 Nr. 440b SK11 works since 0707xx";
1401 "(a^^^3 - 9*a)/(a^^^3*b - a*b^^^3)*(a^^^2*b+a*b^^^2)/(a+3)";
1402 val SOME (t,_) = rewrite_set_ thy false norm_Rational t;
1403 if term2str t = "(-3 * a + a ^^^ 2) / (a + -1 * b)" then ()
1404 else error "rational.sml: diff.behav. in norm_Rational 27";
1406 "----- SK12 works since 0707xx";
1407 val t = str2term "(a^^^3 - 9*a)*(a^^^2*b+a*b^^^2)/((a^^^3*b - a*b^^^3)*(a+3))";
1408 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
1409 if term2str t' = "(-3 * a + a ^^^ 2) / (a + -1 * b)" then ()
1410 else error "rational.sml: diff.behav. in norm_Rational 28";
1413 "-------- common denominator and multiplication ---------";
1414 "-------- common denominator and multiplication ---------";
1415 "-------- common denominator and multiplication ---------";
1416 (*SRAM Schalk I, p.69 Nr. 441b *)
1417 val t = str2term "(4*a/3 + 3*b^^^2/a^^^3 + b/(4*a))*(4*b/(3*a))";
1418 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1421 "(36 * b ^^^ 3 + 3 * a ^^^ 2 * b ^^^ 2 + 16 * a ^^^ 4 * b) / (9 * a ^^^ 4)"
1422 then () else error "rational.sml: diff.behav. in norm_Rational_mg 28";
1424 (*SRAM Schalk I, p.69 Nr. 442b *)
1425 val t = str2term "(15*a^^^2/x^^^3 - 5*b^^^4/x^^^2 + 25*c^^^2/x)*(x^^^3/(5*a*b^^^3*c^^^3)) + 1/c^^^3 * (b*x/a - 3*a/b^^^3)";
1426 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1429 "5 * x ^^^ 2 / (a * b ^^^ 3 * c)"
1430 then () else error "rational.sml: diff.behav. in norm_Rational_mg 29";
1432 (*SRAM Schalk I, p.69 Nr. 443b *)
1433 val t = str2term "(a/2 + b/3)*(b/3 - a/2)";
1434 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1437 "(-9 * a ^^^ 2 + 4 * b ^^^ 2) / 36"
1438 then () else error "rational.sml: diff.behav. in norm_Rational_mg 30";
1440 (*SRAM Schalk I, p.69 Nr. 445b *)
1441 val t = str2term "(a^^^2/9 + 2*a/(3*b) + 4/b^^^2)*(a/3 - 2/b) + 8/b^^^3";
1442 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1446 then () else error "rational.sml: diff.behav. in norm_Rational_mg 31";
1448 (*SRAM Schalk I, p.69 Nr. 446b *)
1449 val t = str2term "(x/(5*x + 4*y) - y/(5*x - 4*y) + 1)*(25*x^^^2 - 16*y^^^2)";
1450 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1453 "30 * x ^^^ 2 + -9 * x * y + -20 * y ^^^ 2"
1455 else error "rational.sml: diff.behav. in norm_Rational_mg 32";
1457 (*SRAM Schalk I, p.69 Nr. 449a *)(*Achtung: rechnet ca 8 Sekunden*)
1459 "(2*x^^^2/(3*y)+x/y^^^2)*(4*x^^^4/(9*y^^^2)+x^^^2/y^^^4)*(2*x^^^2/(3*y) - x/y^^^2)";
1460 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1462 if (term2str t) = "(-81 * x ^^^ 4 + 16 * x ^^^ 8 * y ^^^ 4) / (81 * y ^^^ 8)"
1463 then () else error "rational.sml: diff.behav. in norm_Rational_mg 33";
1466 (*SRAM Schalk I, p.69 Nr. 450a *)
1468 "(4*x/(3*y)+2*y/(3*x))^^^2 - (2*y/(3*x) - 2*x/y)*(2*y/(3*x)+2*x/y)";
1469 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1472 "(52 * x ^^^ 2 + 16 * y ^^^ 2) / (9 * y ^^^ 2)"
1474 else error "rational.sml: diff.behav. in norm_Rational_mg 34";
1477 "-------- double fractions ------------------------------";
1478 "-------- double fractions ------------------------------";
1479 "-------- double fractions ------------------------------";
1480 (*SRD Schalk I, p.69 Nr. 454b *)
1482 "((2 - x)/(2*a)) / (2*a/(x - 2))";
1483 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1486 "(-4 + 4 * x + -1 * x ^^^ 2) / (4 * a ^^^ 2)"
1488 else error "rational.sml: diff.behav. in norm_Rational_mg 35";
1490 (*SRD Schalk I, p.69 Nr. 455a *)
1492 "(a^^^2 + 1)/(a^^^2 - 1) / ((a+1)/(a - 1))";
1493 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1496 "(1 + a ^^^ 2) / (1 + 2 * a + a ^^^ 2)" then ()
1497 else error "rational.sml: diff.behav. in norm_Rational_mg 36";
1500 "----- Schalk I, p.69 Nr. 455b";
1501 val t = str2term "(x^^^2 - 4)/(y^^^2 - 9)/((2+x)/(3 - y))";
1502 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1503 if term2str t = "(2 + -1 * x) / (3 + y)" then ()
1504 else error "rational.sml: diff.behav. in norm_Rational_mg 37";
1506 "----- SK060904-1a non-termination of cancel_p_ ?: worked before 0707xx";
1507 val t = str2term "(x^^^2 - 4)*(3 - y)/((y^^^2 - 9)*(2+x))";
1508 val SOME (t,_) = rewrite_set_ thy false norm_Rational t;
1509 if term2str t = "(2 + -1 * x) / (3 + y)" then ()
1510 else error "rational.sml: diff.behav. in norm_Rational_mg 37b";
1512 "----- ?: worked before 0707xx";
1513 val t = str2term "(3 + -1 * y) / (-9 + y ^^^ 2)";
1514 val SOME (t,_) = rewrite_set_ thy false norm_Rational t;
1515 if term2str t = "-1 / (3 + y)" then ()
1516 else error "rational.sml: -1 / (3 + y) norm_Rational";
1518 (*SRD Schalk I, p.69 Nr. 456b *)
1520 "(b^^^3 - b^^^2)/(b^^^2+b)/(b^^^2 - 1)";
1521 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1523 if (term2str t) = "b / (1 + 2 * b + b ^^^ 2)" then ()
1524 else error "rational.sml: diff.behav. in norm_Rational_mg 38";
1526 (*SRD Schalk I, p.69 Nr. 457b *)
1528 "(16*a^^^2 - 9*b^^^2)/(2*a+3*a*b) / ((4*a+3*b)/(4*a^^^2 - 9*a^^^2*b^^^2))";
1529 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1532 "8 * a ^^^ 2 + -6 * a * b + -12 * a ^^^ 2 * b + 9 * a * b ^^^ 2"
1534 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 (*========== inhibit exn =======================================================
1839 val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
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;
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;
1849 val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;(*++ for explicit script*)
1850 val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;(*++ for explicit script*)
1851 case (f2str f, nxt) of
1852 ("14", ("End_Proof'", _)) => ()
1853 | _ => error "rational.sml diff.behav. in me Schalk I No.186";
1856 "-------- interSteps ..Simp_Rat_Double_No-1.xml ---------";
1857 "-------- interSteps ..Simp_Rat_Double_No-1.xml ---------";
1858 "-------- interSteps ..Simp_Rat_Double_No-1.xml ---------";
1861 [(["TERM (((2 - x)/(2*a)) / (2*a/(x - 2)))", "normalform N"],
1862 ("Rational",["rational","simplification"],
1863 ["simplification","of_rationals"]))];
1866 autoCalculate 1 CompleteCalc;
1867 val ((pt,p),_) = get_calc 1; show_pt pt;
1869 interSteps 1 ([1],Res);
1870 val ((pt,p),_) = get_calc 1; show_pt pt;
1873 "-------- interSteps ..Simp_Rat_Cancel_No-1.xml ---------";
1874 "-------- interSteps ..Simp_Rat_Cancel_No-1.xml ---------";
1875 "-------- interSteps ..Simp_Rat_Cancel_No-1.xml ---------";
1878 [(["TERM ((a^2 + -1*b^2) / (a^2 + -2*a*b + b^2))", "normalform N"],
1879 ("Rational",["rational","simplification"],
1880 ["simplification","of_rationals"]))];
1883 autoCalculate 1 CompleteCalc;
1884 val ((pt,p),_) = get_calc 1; show_pt pt;
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";
1908 "-------- investigate rulesets for cancel_p -------------";
1909 "-------- investigate rulesets for cancel_p -------------";
1910 "-------- investigate rulesets for cancel_p -------------";
1911 val thy = Rational.thy;
1912 "---------------- (a^^^2 + -1*b^^^2) / (a^^^2 + -2*a*b + b^^^2)";
1913 val t = str2term "(a^^^2 + -1*b^^^2) / (a^^^2 + -2*a*b + b^^^2)";
1914 val tt = str2term "(1 * a + 1 * b) * (1 * a + -1 * b)"(*numerator only*);
1915 "----- with rewrite_set_";
1916 val SOME (tt',asm) = rewrite_set_ thy false make_polynomial tt;
1917 term2str tt'= "a ^^^ 2 + -1 * b ^^^ 2" (*true*);
1918 val tt = str2term "((1 * a + -1 * b) * (1 * a + -1 * b))"(*denominator only*);
1919 val SOME (tt',asm) = rewrite_set_ thy false make_polynomial tt;
1920 term2str tt' = "a ^^^ 2 + -2 * a * b + b ^^^ 2" (*true*);
1922 "----- with make_deriv";
1923 val SOME (tt, _) = factout_p_ thy t; term2str tt =
1924 "(1 * a + 1 * b) * (1 * a + -1 * b) / ((1 * a + -1 * b) * (1 * a + -1 * b))";
1926 "--- with ruleset as before 060829";
1927 val {rules, rew_ord=(_,ro),...} =
1928 rep_rls (assoc_rls "make_polynomial");
1929 val der = make_deriv thy Atools_erls rules ro NONE tt;
1930 print_depth 99; map (term2str o #1) der; print_depth 3;
1931 print_depth 99; map (rule2str o #2) der; print_depth 3;
1932 ... did not terminate*)
1933 "--- with simpler ruleset";
1934 val {rules, rew_ord=(_,ro),...} =
1935 rep_rls (assoc_rls "rev_rew_p");
1936 val der = make_deriv thy Atools_erls rules ro NONE tt;
1937 print_depth 99; writeln (deriv2str der); print_depth 3;
1939 print_depth 99; map (term2str o #1) der; print_depth 3;
1940 "...,(-1 * b ^^^ 2 + a ^^^ 2) / (-2 * (a * b) + a ^^^ 2 + (-1 * b) ^^^ 2) ]";
1941 print_depth 99; map (rule2str o #2) der; print_depth 3;
1942 print_depth 99; map (term2str o #1 o #3) der; print_depth 3;
1944 val der = make_deriv thy Atools_erls rules ro NONE
1945 (str2term "(1 * a + 1 * b) * (1 * a + -1 * b)");
1946 print_depth 99; writeln (deriv2str der); print_depth 3;
1948 val {rules, rew_ord=(_,ro),...} =
1949 rep_rls (assoc_rls "rev_rew_p");
1950 val der = make_deriv thy Atools_erls rules ro NONE
1951 (str2term "(1 * a + -1 * b) * (1 * a + -1 * b)");
1952 print_depth 99; writeln (deriv2str der); print_depth 3;
1953 print_depth 99; map (term2str o #1) der; print_depth 3;
1954 (*WN060829 ...postponed*)
1957 "-------- investigate format of factout_ and factout_p_ -";
1958 "-------- investigate format of factout_ and factout_p_ -";
1959 "-------- investigate format of factout_ and factout_p_ -";
1960 val {rules, rew_ord = (_,ro),...} = rep_rls (assoc_rls "make_polynomial");
1961 val (thy, eval_rls) = (Rational.thy, Atools_erls)(*see 'fun init_state'*);
1962 val Rrls {scr = Rfuns {init_state,...},...} = assoc_rls "cancel_p";
1964 "----- see Rational.ML, local cancel_p, fun init_state";
1965 val t = str2term "(a^^^2 + (-1)*b^^^2) / (a^^^2 + (-2)*a*b + b^^^2)";
1966 val SOME (t',_) = factout_p_ thy t; term2str t';
1968 val rtas = reverse_deriv thy eval_rls rules ro NONE t';
1969 writeln(trtas2str rst);
1973 "----- see Rational.ML, local cancel_p, fun init_state";
1974 val t = str2term "a^^^2 / a";
1975 val SOME (t',_) = factout_p_ thy t;
1976 term2str t' = "a * a / (1 * a)" (*true*);
1977 (*... can be canceled with
1978 real_mult_div_cancel2 ?k ~= 0 ==> ?m * ?k / (?n * ?k) = ?m / ?n"*)
1979 (* sml/ME/rewtools.sml:
1980 val rtas = reverse_deriv thy Atools_erls rules ro NONE t';
1981 writeln (deri2str rtas);
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 ============ inhibit exn =====================================================*)
2080 (*-.-.-.-.-.-isolate response.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
2081 -.-.-.-.-.-.-isolate response.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.*)