intermed. usecase Diophant
located error with int in '= me' at first step specifying
fun is_known
1 (* Title: tests for rationals
3 Copyright (c) Stefan Karnel 2002
4 Use is subject to license terms.
6 12345678901234567890123456789012345678901234567890123456789012345678901234567890
7 10 20 30 40 50 60 70 80
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 "--------------------------------------------------------";
25 "table of contents --------------------------------------";
26 "--------------------------------------------------------";
27 "~~~~~BEGIN: decomment structure RationalI : RATIONALI ~~";
28 "-------- ... missing WN060103 --------------------------";
29 "-------- fun monom2term, fun poly2term' ---------------";
30 "~~~~~END: decomment structure RationalI : RATIONALI ~~~~";
31 "-------- external calculating functions test -----------";
32 "-------- cancel from: Mathematik 1 Schalk Reniets Verlag";
33 "-------- common_nominator_p ----------------------------";
34 "-------- reverse rewrite -------------------------------";
35 "-------- 'reverse-ruleset' cancel_p --------------------";
36 "-------- norm_Rational ---------------------------------";
37 "-------- numeral rationals -----------------------------";
38 "-------- cancellation ----------------------------------";
39 "-------- common denominator ----------------------------";
40 "-------- multiply and cancel ---------------------------";
41 "-------- common denominator and multiplication ---------";
42 "-------- double fractions ------------------------------";
43 "-------- crucial examples ------------------------------";
44 "-------- examples for Stefan Karnels thesis ------------";
45 "-------- me Schalk I No.186 ----------------------------";
46 "-------- interSteps ..Simp_Rat_Double_No-1.xml ---------";
47 "-------- interSteps ..Simp_Rat_Cancel_No-1.xml ---------";
48 "-------- investigate rulesets for cancel_p -------------";
49 "-------- investigate format of factout_ and factout_p_ -";
50 "-------- how to stepwise construct Scripts -------------";
51 "--------------------------------------------------------";
52 "--------------------------------------------------------";
53 "--------------------------------------------------------";
56 "~~~~~BEGIN: decomment structure RationalI : RATIONALI ~~";
57 (*.~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
58 tests of internal functions: to make them work,
59 out-comment (*!!!*) in knowledge/Rational.ML:
61 structure RationalI : RATIONALI =
68 !!!##*)~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~.*)
70 "-------- ... missing WN060103 --------------------------";
71 "-------- ... missing WN060103 --------------------------";
72 "-------- ... missing WN060103 --------------------------";
73 (*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
74 writeln ("********************* rational.sml - TESTS *************************");
75 writeln ("***** divide tests *****");
76 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_)));
77 (* result: [(1,[0,0,1]),(1,[0,0,0])] *)
78 if mv_pquot1=[(1,[0,0,1]),(1,[0,0,0])] then () else error ("rational.sml: example failed");
80 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_)));
81 (* result: [(1,[1,0,1]),(~1,[0,0,1])] *)
82 if mv_prest1=[(1,[1,0,1]),(~1,[0,0,1])] then () else error ("rational.sml: example failed");
84 val mv_pquot2 = (#1(mv_division([(4,[2]),(8,[1]),(16,[0])],[(1,[1]),(1,[0])],LEX_)));
85 (* result: [(4,[1]),(4,[0])] *)
86 if mv_pquot2=[(4,[1]),(4,[0])] then () else error ("rational.sml: example failed");
88 val mv_prest2 = (#2(mv_division([(4,[2]),(8,[1]),(16,[0])],[(1,[1]),(1,[0])],LEX_)));
89 (* result: [(12,[0]] *)
90 if mv_prest2=[(12,[0])] then () else error ("rational.sml: example failed");
92 val mv_pquot3 = (#1(mv_division([(4,[2]),(~4,[0])],[(2,[1]),(2,[0])],LEX_)));
93 (* [(2,[1]),(~2,[0])] *)
94 if mv_pquot3=[(2,[1]),(~2,[0])] then () else error ("rational.sml: example failed");
96 val mv_prest3 = (#2(mv_division([(1,[2]),(~1,[0])],[(2,[1]),(2,[0])],LEX_)));
97 (* [(1,[2]),(~1,[0])] *)
98 if mv_prest3=[(1,[2]),(~1,[0])] then () else error ("rational.sml: example failed");
100 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_)));
102 if mv_pquot4=[(1,[0,1,1])] then () else error ("rational.sml: example failed");
104 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_)));
105 (* [(1,[1,1,1]),(~4,[0,1,2]),(4,[1,0,1]),(3,[0,0,1])] *)
106 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");
108 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_)));
109 (* [(1,[2,2,0]),(6,[2,1,2]),(3,[1,1,0]),(4,[1,0,0]),(4,[0,4,0]),(3,[0,0,0])]*)
110 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");
112 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_)));
114 if mv_prest5=[] then () else error ("rational.sml: example failed");
116 (* (x^2 + 2(a+1)x + (a^2+2a+1)) / (x+a+1) = x+a+1 *)
117 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_)));
118 if mv_pquot6=[(1,[1,0,0]),(1,[0,1,0]),(1,[0,0,0])] then () else error ("rational.sml: example failed");
120 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_)));
121 if mv_prest6=[] then () else error ("rational.sml: example failed");
124 writeln ("***** MV_CONTENT-TESTS *****");
125 val mv_cont1=mv_content([(1,[2,1]),(1,[2,0]),(1,[1,1]),(1,[1,0]),(1,[0,1]),(1,[0,0])]);
126 (* [(1,[0,1]),(1,[0,0])] *)
127 if mv_cont1=[(1,[0,1]),(1,[0,0])] then () else error ("rational.sml: example failed");
129 val mv_pp1=mv_pp([(1,[1,1]),(1,[1,0]),(1,[0,1]),(1,[0,0])]);
130 (*[(1,[1,0]),(1,[0,0])]*)
131 if mv_pp1=[(1,[1,0]),(1,[0,0])] then () else error ("rational.sml: example failed");
133 val mv_cont2=mv_content([(2,[1]),(4,[0])]);
135 if mv_cont2=[(2,[0])] then () else error ("rational.sml: example failed");
137 val mv_pp2=mv_pp([(2,[1]),(4,[0])]);
138 (* [(1,[1]),(2,[0])] *)
139 if mv_pp2=[(1,[1]),(2,[0])] then () else error ("rational.sml: example failed");
141 val mv_cont3=mv_content[(8,[2,1,1]),(12,[1,0,2]),(10,[2,2,0]),(16,[1,1,1])];
143 if mv_cont3=[(2,[0,0,0])] then () else error ("rational.sml: example failed");
145 val mv_pp3=mv_pp[(8,[2,1,1]),(12,[1,0,2]),(10,[2,2,0]),(16,[1,1,1])];
146 (* [(5,[2,2,0]),(4,[2,1,1]),(8,[1,1,1]),(6,[1,0,2])] *)
147 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");
149 val mv_cont4=mv_content[(2,[2,1,0]),(3,[1,0,1]),(2,[1,1,0]),(3,[0,0,1])];
151 if mv_cont4=[(1,[0,0,0])] then () else error ("rational.sml: example failed");
153 val mv_pp4=mv_pp [(2,[2,1,0]),(3,[1,0,1]),(2,[1,1,0]),(3,[0,0,1])];
154 (* [(2,[2,1,0]),(2,[1,1,0]),(3,[1,0,1]),(3,[0,0,1])] *)
155 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");
157 val con1=mv_content([(9,[2,0]),(15,[1,1]),(12,[1,0]),(6,[0,2]),(12,[0,1])]);
159 if con1=[(3,[0,0])] then () else error ("rational.sml: example failed");
161 val pp1=mv_pp([(9,[2,0]),(15,[1,1]),(12,[1,0]),(6,[0,2]),(12,[0,1])]);
162 (* [(3,[2,0]),(5,[1,1]),(4,[1,0]),(2,[0,2]),(4,[0,1])] *)
163 if pp1=[(3,[2,0]),(5,[1,1]),(4,[1,0]),(2,[0,2]),(4,[0,1])] then () else error ("rational.sml: example failed");
165 val con2=mv_content([(1,[2,0]),(1,[1,1]),(1,[1,0]),(1,[0,2]),(1,[0,1])]);
167 if con2=[(1,[0,0])] then () else error ("rational.sml: example failed");
169 val pp2 =mv_pp([(1,[2,0]),(1,[1,1]),(1,[1,0]),(1,[0,2]),(1,[0,1])]);
170 (* [(1,[2,0]),(1,[1,1]),(1,[1,0]),(1,[0,2]),(1,[0,1])] *)
171 if pp2=[(1,[2,0]),(1,[1,1]),(1,[1,0]),(1,[0,2]),(1,[0,1])] then () else error ("rational.sml: example failed");
173 val cont1 = mv_content [(1,[2,1,0]),(2,[2,1,0])];
175 if cont1=[(3,[0,1,0])] then () else error ("rational.sml: example failed");
177 val pp1 = mv_pp [(1,[2,1,0]),(2,[2,1,0])];
179 if pp1=[(1,[2,0,0])] then () else error ("rational.sml: example failed");
181 val cont2 = mv_content [(4,[1,2,0]),(2,[2,1,0])];
183 if cont2=[(2,[0,1,0])] then () else error ("rational.sml: example failed");
185 val pp2 = mv_pp [(4,[1,2,0]),(2,[2,1,0])];
186 (* [(1,[2,0,0]),(2,[1,1,0])] *)
187 if pp2=[(1,[2,0,0]),(2,[1,1,0])] then () else error ("rational.sml: example failed");
189 writeln ("********************************************************");
190 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])];
191 if cont3=[(5,[0,2,1]),(4,[0,2,0]),(2,[0,1,1])] then () else error ("rational.sml: example failed");
192 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])];
195 "-------- fun monom2term, fun poly2term' ---------------";
196 "-------- fun monom2term, fun poly2term' ---------------";
197 "-------- fun monom2term, fun poly2term' ---------------";
198 val t = monom2term ((3,[2,1,0]), ["c","b","a"](*reverse ???SK-*));
199 term2str t = "3 * (c ^^^ 2 * b)" (*true*);
201 val t = monom2term ((1,[1,0]), ["b","a"]);
202 term2str t = "b" (*true*);
204 val t = poly2term ([(1,[0,0,0]),(2,[1,0,0]),(3,[2,1,0]),(4,[3,2,1])],
206 term2str t = "1 + 2 * c + 3 * (c ^^^ 2 * b) + 4 * (c ^^^ 3 * (b ^^^ 2 * a))";
208 val t = poly2term ([(1,[1,0]),(1,[0,1])], ["b","a"]);
209 term2str t = "a + b" (*true*);
211 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*)
212 "~~~~~END: decomment structure RationalI : RATIONALI ~~~~";
213 "~~~~~END: decomment structure RationalI : RATIONALI ~~~~";
214 "~~~~~END: decomment structure RationalI : RATIONALI ~~~~";
217 fun parse_rat str = (term_of o the o (parse thy)) str;
219 writeln ("***** mv_gcd-tests *****");
220 val ggt1 = mv_gcd [(4,[2,2]),(8,[1,1]),(4,[0,0])] [(2,[1,1]),(2,[0,0])];
221 (* [(2,[1,1]),(2,[0,0])] *)
222 if ggt1=[(2,[1,1]),(2,[0,0])] then () else error ("rational.sml: example failed");
224 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])];
225 (* [(2,[1,1,0]),(3,[0,0,1])] *)
226 if ggt2=[(2,[1,1,0]),(3,[0,0,1])] then () else error ("rational.sml: example failed");
229 val ggt3 = mv_gcd [(1,[2,0]),(~2,[1,1]),(1,[0,2])] [(1,[1,0]),(~1,[0,1])];
230 (* [(1,[1,0]),(~1,[0,1])] *)
231 if ggt3=[(1,[1,0]),(~1,[0,1])] then () else error ("rational.sml: example failed");
234 val ggt4 = mv_gcd [(1,[2,1,0]),(2,[2,1,0])] [(5,[1,0,0])];
236 if ggt4=[(1,[1,0,0])] then () else error ("rational.sml: example failed");
239 val ggt5 = mv_gcd [(4,[2,0]),(~8,[1,1]),(4,[0,2])] [(1,[2,0]),(~1,[0,2])];
240 (* [(1,[1,0]),(~1,[0,1])] *)
241 if ggt5=[(1,[1,0]),(~1,[0,1])] then () else error ("rational.sml: example failed");
244 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])];
246 if ggt6=[(1,[1,0,0])] then () else error ("rational.sml: example failed");
248 writeln ("***** kgv-tests *****");
249 val kgv1=mv_lcm [(10,[])] [(15,[])];
251 if kgv1=[(30,[])] then () else error ("rational.sml: example failed");
253 val kgv2=mv_lcm [(1,[2,0]),(~2,[1,1]),(1,[0,2])] [(1,[1,0]),(~1,[0,1])];
254 (* [(1,[2,0]),(~2,[1,1]),(1,[0,2])] *)
255 if kgv2=[(1,[2,0]),(~2,[1,1]),(1,[0,2])] then () else error ("rational.sml: example failed");
257 val kgv3=mv_lcm [(4,[2,0]),(~8,[1,1]),(4,[0,2])] [(1,[2,0]),(~1,[0,2])];
258 (* [(4,[3,0]),(~4,[2,1]),(~4,[1,2]),(4,[0,3])] *)
259 if kgv3=[(4,[3,0]),(~4,[2,1]),(~4,[1,2]),(4,[0,3])] then () else error ("rational.sml: example failed");
262 writeln ("***** STEP_CANCEL_TESTS: *****");
264 val term2 = (term_of o the o (parse thy)) " (9 * a^^^2 * b) / (6 * a * c)";
265 val div2 = term2str (step_cancel term2);
266 if div2 = "3 * (a * b) * (3 * a) / (2 * c * (3 * a))" then () else error ("rational.sml: example failed");
269 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";
270 val div1 = term2str(step_cancel term1);
271 if div1 = "(3 * c + 14 * b + 20 * (b ^^^ 2 * c) + 10 * (a * (b * c))) * a / (1 * a)" then () else error ("rational.sml: example failed");
273 val term3 = (term_of o the o (parse thy)) "(10 * a^^^2 * b * c) / (1 * x * y * z) ";
274 val div3 = term2str(step_cancel term3);
275 if div3="10 * a ^^^ 2 * b * c / (1 * x * y * z)" then () else error ("rational.sml: example failed");
277 --------------------------------------------------------------------------!!!*)
279 (*-----versuche 13.3.03-----
280 val t = str2term "1 - x^^^2 - 5 * x^^^5";
281 val vs=(((map free2str) o vars) t);
282 val SOME ml = expanded2poly t vs;
284 poly2term'(rev(sort (mv_geq LEX_) (ml)),vs);
285 poly2term'([(~5,[5]),(~1,[2]),(1,[0])], vs);
286 monom2term((~5,[5]),vs);
287 monom2term((~1,[2]),vs);
288 val t' = monom2term((1,[0]),vs);(*uncaught exception LIST*)
290 val (i,is) = (~1,[2]);
291 val ttt = Const ("Groups.times_class.times", [HOLogic.realT,HOLogic.realT]---> HOLogic.realT) $
292 (Const ("uminus", HOLogic.realT --> HOLogic.realT) $
293 Free ((str_of_int o abs) i, HOLogic.realT)) $
294 powerproduct2term(is, vs);
296 -------versuche 13.3.03-----*)
298 val t = str2term "1 - x^^^2 - 5 * x^^^5";
299 val SOME t' = expanded2polynomial t; term2str t';
300 "1 + - 1 * x ^^^ 2 + - 5 * x ^^^ 5";
301 val t = str2term "1 - x";
302 val SOME t' = expanded2polynomial t; term2str t';
304 val t = str2term "1 + (-1) * x";
305 val SOME t' = expanded2polynomial t; term2str t';
307 val t = (term_of o the o (parse thy)) "1 + (-1) * x ^^^ 2 + (-5) * x ^^^5";
308 val SOME t' = polynomial2expanded t; term2str t';
309 "1 - x ^^^ 2 - 5 * x ^^^ 5";
312 "-------- external calculating functions test -----------";
313 "-------- external calculating functions test -----------";
314 "-------- external calculating functions test -----------";
315 val t1 = (term_of o the o (parse thy)) "((3 * x^^^2 + 6 *x + 3) / (2*x + 2))";
316 val SOME (t1',asm)= factout_p_ thy t1;
317 term2str t1'; terms2str asm;
318 "(3 + 3 * x) * (1 + 1 * x) / (2 * (1 + 1 * x))";
320 val SOME (t1',asm)= cancel_p_ thy t1;
321 term2str t1'; terms2str asm;
323 "[\"1 + 1 * x ~= 0\"]";
325 val t = (term_of o the o (parse thy)) "((-3 * x^^^2 + 6 *x - 3) / (2*x - 2))";
326 val SOME (t',asm)= cancel_ thy t;
327 term2str t'; terms2str asm;
330 val SOME (t',asm)= factout_ thy t;
331 term2str t'; terms2str asm;
332 "(3 - 3 * x) * (-1 + x) / (2 * (-1 + x))";
335 val t = str2term "((x+ (-1)) / (x + 1)) + ((x + 1) / (x + (-1)))";
336 val SOME (t',asm) = add_fraction_p_ thy t;
337 term2str t'; terms2str asm;
338 "(2 + 2 * x ^^^ 2) / (-1 + 1 * x ^^^ 2)";
340 val SOME (t',asm) = common_nominator_p_ thy t;
341 term2str t'; terms2str asm;
342 "(-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))";
345 val t = str2term "((x - 1) / (x + 1)) + ((x + 1) / (x - 1))";
346 val SOME (t',asm) = add_fraction_ thy t;
347 term2str t'; terms2str asm;
348 "(2 + 2 * x ^^^ 2) / (-1 + x ^^^ 2)";
350 val SOME (t',asm) = common_nominator_ thy t;
351 term2str t'; terms2str asm;
352 "(-1 + x) * (-1 + x) / ((1 + x) * (-1 + x)) +\n(1 + x) * (1 + x) / ((1 + x) * (-1 + x))";
355 val t = str2term "((1) / (2*x + 2)) + ((1) / (2*x + (-2))) + ((1) / ( x^^^2 + (-1)))+((1) / (x^^^2 + (-2)*x + 1))";
356 val SOME (t',asm) = common_nominator_p_ thy t;
357 term2str t'; terms2str asm;
358 "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 * (#";
360 val SOME (t',asm) = add_fraction_p_ thy t;
361 term2str t'; terms2str asm;
362 "1 * x / (1 + -2 * x + 1 * x ^^^ 2)";
363 "[\"1 + 1 * x ~= 0\"]";
364 val SOME(t',asm) = norm_rational_ thy t;
365 term2str t'; terms2str asm;
366 "1 * x / (1 + -2 * x + 1 * x ^^^ 2)";
367 "[\"1 + 1 * x ~= 0\"]";
369 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))";
370 val SOME (t3',_) = common_nominator_ thy t3;
371 val SOME (t3'',_) = add_fraction_ thy t3;
375 val SOME(t4,t5) = norm_expanded_rat_ thy t3;
381 val t=(term_of o the o (parse thy)) "(9 - x^^^2)/(9 - 6*x + x^^^2)";
382 val SOME (t',_) = factout_ thy t;
383 val SOME (t'',_) = cancel_ thy t;
386 "(3 + x) * (3 - x) / ((3 - x) * (3 - x))";
389 val t=(term_of o the o (parse thy))
390 "(9 - x^^^2) / (9 - 6*x + x^^^2) + 1 / (3 - x)";
391 val SOME (t',_) = common_nominator_ thy t;
392 val SOME (t'',_) = add_fraction_ thy t;
395 "(9 - x ^^^ 2) / ((3 - x) * (3 - x)) + 1 * (3 - x) / ((3 - x) * (3 - x))";
398 (*WN021016 added -----vv---*)
399 val t = str2term "(9 - x^^^2) / (9 - 6*x + x^^^2) + 1";
400 val SOME (t',_) = common_nominator_ thy t;
401 val SOME (t'',_) = add_fraction_ thy t;
402 term2str t' = "(9 - x ^^^ 2) / (9 - 6 * x + x ^^^ 2) +\n1" ^
403 " * (9 - 6 * x + x ^^^ 2) / (9 - 6 * x + x ^^^ 2)" (*true*);
404 term2str t'' = "6 / (3 - x)" (*true*);
406 val t = str2term "1 + (9 - x^^^2) / (9 - 6*x + x^^^2)";
407 val SOME (t',_) = common_nominator_ thy t;
408 val SOME (t'',_) = add_fraction_ thy t;
409 term2str t' = "1 * (9 - 6 * x + x ^^^ 2) / (9 - 6 * x + x ^^^ 2) +\n" ^
410 "(9 - x ^^^ 2) / (9 - 6 * x + x ^^^ 2)" (*true*);
411 term2str t'' = "6 / (3 - x)" (*true*);
412 (*WN021016 added -----^^---*)
413 (*WN030602 added -----vv--- no rewrite -> NONE !*)
414 val t = str2term "1 / a";
415 val NONE = cancel_p_ thy t;
416 val NONE = rewrite_set_ thy false cancel_p t;
417 (*WN.2.6.03 added -------^^---*)
419 val t = str2term "(y^^^2 - x^^^2)/(y^^^2 - 2*y*x + x^^^2)";
420 val SOME (t',_) = factout_ thy t;
421 val SOME (t'',_) = cancel_ thy t;
422 term2str t' = "(y + x) * (y - x) / ((y - x) * (y - x))"(*true*);
423 term2str t'' = "(y + x) / (y - x)";
425 val t = str2term "(y^^^2 - x^^^2)/(y^^^2 - 2*y*x + x^^^2) + 1 / (y - x)";
426 val SOME (t',_) = common_nominator_ thy t;
427 val SOME (t'',_) = add_fraction_ thy t;
429 "(-1 * x ^^^ 2 + y ^^^ 2) / ((-1 * x + y) * (-1 * x + y)) +\n1" ^
430 " * (-1 * x + y) / ((-1 * x + y) * (-1 * x + y))" (*true*);
431 term2str t'' = "(-1 - x - y) / (x - y)" (*true*);
433 val t = str2term "(x^^^2 - y^^^2)/(x^^^2 - 2*x*y + y^^^2) + 1 / (x - y)";
434 val SOME (t',_) = common_nominator_ thy t;
435 val SOME (t'',_) = add_fraction_ thy t;
436 if term2str t' = "(-1 * y ^^^ 2 + x ^^^ 2) / ((-1 * y + x) * (-1 * y + x))" ^
437 " +\n1 * (-1 * y + x) / ((-1 * y + x) * (-1 * y + x))" then ()
438 else error "rational.sml lex-ord 1";
439 if term2str t'' = "(-1 - y - x) / (y - x)" then ()
440 else error "rational.sml lex-ord 2";
441 (*WN.16.10.02 WN070905 lexicographische Ordnung erhalten ! SK.ord*)
444 val t = str2term "(x^^^2 - y^^^2)/(x^^^2 - 2*x*y + y^^^2)";
445 val SOME (t',_) = norm_expanded_rat_ thy t;
446 if term2str t' = "(x + y) / (x - y)" then ()
447 else error "rational.sml term2poly: invalid x ^^^ 2 - y ^^^ 2 No.1";
448 (*val SOME (t'',_) = norm_rational_ thy t;
449 *** RATIONALS_TERM2POLY_EXCEPTION: Invalid Polynomial
450 WN.16.10.02 ?! + WN060831???SK4
451 WN070905 *** term2poly: invalid = x ^^^ 2 - y ^^^ 2*)
454 val t = str2term "(9 - x^^^2)/(9 - 6*x + x^^^2) + (1)/(3 + x)";
455 val SOME (t',_) = norm_expanded_rat_ thy t;
456 if term2str t' = "(12 + 5 * x + x ^^^ 2) / (9 - x ^^^ 2)" then ()
457 else error "rational.sml (9 - x^^^2)/(9 - 6*x + x^^^2) +...";
458 (*val SOME (t'',_) = norm_rational_ thy t;
459 *** RATIONALS_TERM2POLY_EXCEPTION: Invalid Polynomial WN.16.10.02 ?!
460 WN070906 *** term2poly: invalid = 9 - x ^^^ 2 SK.term2poly*)
462 val t=(term_of o the o (parse thy))
463 "(9 + (-1)* x^^^2)/(9 + (-1)* 6*x + x^^^2) + (1)/(3 + x)";
464 val SOME (t',_) = norm_expanded_rat_ thy t;
465 val SOME (t'',_) = norm_rational_ thy t;
468 "(12 + 5 * x + x ^^^ 2) / (9 - x ^^^ 2)";
469 "(12 + 5 * x + x ^^^ 2) / (9 + (-1) * x ^^^ 2)";
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 = @{theory "Rational"};
476 val thy' = "Rational";
478 val mp = "make_polynomial";
480 writeln ("example 186:");
482 val e186a'="(14 * x * y) / ( x * y )";(*SRC*)
483 rewrite_set_ thy false cancel (str2term e186a');
485 val e186a = the (rewrite_set thy' false "cancel" e186a');
486 is_expanded (parse_rat "14 * x * y");
487 is_expanded (parse_rat "x * y");
488 if e186a = ("14 / 1", "[\"y * x ~= 0\"]") then ()
489 else error "rational.sml cancel Schalk e186a";
492 val e186b'="(60 * a * b) / ( 15 * a * b )";
493 val e186b = the (rewrite_set thy' false "cancel" e186b');
495 val e186c'="(144 * a^^^2 * b * c) / (12 * a * b * c )";
496 val e186c = (the (rewrite_set thy' false "cancel" e186c'))
497 handle e => print_exn_G e;
498 val t = (term_of o the o (parse thy)) e186c';
499 if e186c = ("12 * a / 1", "[\"12 * (c * (b * a)) ~= 0\"]") then ()
500 else error "rational.sml cancel Schalk e186c";
502 writeln ("example 187:");
504 val e187a'="(12 * x * y) / (8 * y^^^2 )";(*SRC*)
505 val e187a = the (rewrite_set thy' false "cancel" e187a');
507 val e187b'="(8 * x^^^2 * y * z ) / (18 * x * y^^^2 * z )";
508 val e187b = the (rewrite_set thy' false "cancel" e187b');
510 val e187d'="(9 * x^^^5 * y^^^2 * z^^^4) / (15 * x^^^6 * y^^^3 * z )";(*SRC*)
511 val e187d = the (rewrite_set thy' false "cancel" e187d');
512 if e187d = ("3 * z ^^^ 3 / (5 * (y * x))",
513 "[\"3 * (z * (y ^^^ 2 * x ^^^ 5)) ~= 0\"]") then ()
514 else error "rational.sml cancel Schalk e186d";
516 writeln "example 188:";
517 val e188a'="(-8 + 8 * x) / (-9 + 9 * x)";(*SRC*)
518 val e188a = the (rewrite_set thy' false "cancel" e188a');
519 is_expanded (parse_rat "8 * x + -8");
520 (* e188a = ("8 / 9",["not ((-1) + x = 0)"]) then () 13.3.03*)
521 if e188a = ("8 / 9", "[\"-1 + x ~= 0\"]") then ()
522 else error "rational.sml: e188a new behaviour";
524 val SOME (t,_) = rewrite_set thy' false mp "(8*((-1) + x))/(9*((-1) + x))";
526 val e188b'="(-15 + 5 * x) / (-18 + 6 * x)";(*SRC*)
527 val SOME (t, asm) = rewrite_set thy' false "cancel" e188b';
528 t = "5 / 6" (*true*);
531 val e188c'="( a + -1 * b ) / ( b + -1 * a )";
532 val e188c = the (rewrite_set thy' false "cancel_p" e188c');
533 (*is_expanded (parse_rat "a + -1 * b");*)
535 rewrite_set thy' false mp "((-1)*(b + (-1) * a))/(1*(b + (-1) * a))";
536 if t= "(a + -1 * b) / (-1 * a + b)" then()
537 else error "rational.sml: e188c new behaviour";
539 writeln ("example 190:");
541 val e190c'="( 27 * a^^^3 + 9 * a^^^2 + 3 * a + 1 ) / ( 27 * a^^^3 + 18 * a^^^2 + 3 * a )";
542 val e190c = the (rewrite_set thy' false "cancel" e190c');
543 val SOME (t,_) = rewrite_set thy' false mp "((1 + 9 * a ^^^ 2)*(1 + 3 * a))/((3 * a + 9 * a ^^^ 2)*(1 + 3 * a))";
544 if t = "(1 + 3 * a + 9 * a ^^^ 2 + 27 * a ^^^ 3) /\n(3 * a + 18 * a ^^^ 2 + 27 * a ^^^ 3)" then ()
545 else error "rational.sml: e190c new behaviour";
547 writeln ("example 191:");
549 val e191a'="( x^^^2 + -1 * y^^^2 ) / ( x + y )";
551 val e191a = the (rewrite_set thy' false "cancel" e191a');
552 is_expanded (parse_rat "x^^^2 + -1 * y^^^2");
554 is_expanded (parse_rat "x + y");
556 val SOME (t,_) = rewrite_set thy' false mp "((x + (-1) * y)*(x + y))/((1)*(x + y))";
557 (* t="(x ^^^ 2 + -1 * y ^^^ 2) / (x + y)" then() WN.13.3.03*)
558 if t="(x ^^^ 2 + -1 * y ^^^ 2) / (x + y)" then()
559 else error "rational.sml: e191a new behaviour";
562 val e191c'="( 9 * x^^^2 + -30 * x + 25 ) / ( 9 * x^^^2 + -25 )";
564 val e191c = the (rewrite_set thy' false "cancel" e191c');
565 is_expanded (parse_rat "9 * x^^^2 + -30 * x + 25");
567 is_expanded (parse_rat "25 + -30*x + 9*x^^^2");
569 is_expanded (parse_rat "-25 + 9*x^^^2");
571 val SOME (t,_) = rewrite_set thy' false mp "(((-5) + 3 * x)*((-5) + 3 * x))/((5 + 3 * x)*((-5) + 3 * x))";
572 (* t="(25 + ((-30) * x + 9 * x ^^^ 2)) / ((-25) + 9 * x ^^^ 2)"then() 13.3.03*)
573 if t= "(25 + -30 * x + 9 * x ^^^ 2) / (-25 + 9 * x ^^^ 2)" then()
574 else error "rational.sml: 'e191c' new behaviour";
577 writeln ("example 192:");
579 val e192b'="( 7 * x^^^3 + -1 * x^^^2 * y ) / ( 7 * x * y^^^2 + -1 * y^^^3 )";
581 val e192b = the (rewrite_set thy' false "cancel" e192b');
582 -------------------*)
583 val SOME (t',_) = rewrite_set thy' false mp "((x ^^^ 2)*(7 * x + (-1) * y))/((y ^^^ 2)*(7 * x + (-1) * y))";
584 (*========== inhibit exn 110317 ================================================
585 if t' = "(7 * x ^^^ 3 + -1 * x ^^^ 2 * y) / (7 * x * y ^^^ 2 + -1 * y ^^^ 3)"
586 (*"(-1 * y * x ^^^ 2 + 7 * x ^^^ 3) / (-1 * y ^^^ 3 + 7 * x * y ^^^ 2)"WN050929*)
587 then () else error "rational.sml: 'e192b' new behaviour";
588 (*^^^ works with MG's simplifier vvv*)
589 val t =str2term"((x ^^^ 2)*(7 * x + (-1) * y))/((y ^^^ 2)*(7 * x + (-1) * y))";
590 val SOME (t',_) = rewrite_set_ thy false make_polynomial t;
591 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";
592 ============ inhibit exn 110317 ==============================================*)
594 writeln ("example 193:");
596 val e193a'="( x^^^2 + -6 * x + 9 ) / ( x^^^2 + -9 )";
598 val e193a = the (rewrite_set thy' false "cancel" e193a');
599 -------------------*)
601 val e193b'="( x^^^2 + -8 * x + 16 ) / ( 2 * x^^^2 + -32 )";
603 val e193b = the (rewrite_set thy' false "cancel" e193b');
605 val e193c'="( 2 * x + -50 * x^^^3 ) / ( 25 * x^^^2 + -10 * x + 1 )";
606 val SOME(t,_) = rewrite_set thy' false "cancel" e193c';
607 -------------------*)
609 val wn01 = "(-25 + 9*x^^^2)/(5 + 3*x)";
610 val SOME (t, asm) = rewrite_set thy' false "cancel" wn01;
611 (* t = "((-5) + 3 * x) / 1" then () WN.13.3.03*)
612 if t = "(-5 + 3 * x) / 1" andalso asm = "[\"5 + 3 * x ~= 0\"]" then ()
613 else error "rational.sml: new behav. in cancel wn01";
615 "-------- common_nominator_p ----------------------------";
616 "-------- common_nominator_p ----------------------------";
617 "-------- common_nominator_p ----------------------------";
618 val rls' = "common_nominator_p";
620 writeln ("example 204:");
622 val e204a'="((5 * x) / 9) + ((3 * x) / 9) + (x / 9)";
623 val e204a = the (rewrite_set thy' false "common_nominator_p" e204a');
625 val e204b'="5 / x + -3 / x + -1 / x";
626 val e204b = the (rewrite_set thy' false "common_nominator_p" e204b');
627 if e204b = ("1 / x", "[]") then ()
628 else error "rational.sml common_nominator_p example e204b";
630 writeln ("example 205:");
632 val e205a'="((4 * x + 7) / 8) + ((4 * x + 3) / 8)";
633 val e205a = the (rewrite_set thy' false "common_nominator_p" e205a');
635 val e205b'="((5 * x + 2) / 3) + ((-2 * x + 1) / 3)";
636 val e205b = the (rewrite_set thy' false "common_nominator_p" e205b');
637 if e205b = ("(1 + x) / 1", "[]") then ()
638 else error "rational.sml common_nominator_p example e204b";
640 writeln ("example 206:");
642 val e206a'="((5 * x + 4) / (2 * x + -1)) + ((9 * x + 5) / (2 * x + -1))";
643 val e206a = the (rewrite_set thy' false "common_nominator_p" e206a');
645 val e206b'="((17 * x + -23) / (5 * x + 4)) + ((-25 + -17 * x) / (5 * x + 4))";
646 val e206b = the (rewrite_set thy' false "common_nominator_p" e206b');
648 writeln ("example 207:");
649 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)) ";
650 val e207 = the (rewrite_set thy' false "common_nominator_p" e207');
652 writeln ("example 208:");
653 val e208'="((3 * x + 2) / (x + 2)) + ((5 * x + -1) / (x + 2)) + ((-7 * x + -3) / (x + 2)) + ((-1 * x + -3) / (x + 2)) ";
654 val e208 = the (rewrite_set thy' false "common_nominator_p" e208');
656 writeln ("example 209:");
657 val e209'="((3 * x + -7 * y + 3 * z) / (4)) + ((2 * x + 17 * y + 10 * z) / (4)) + ((-1 * x + 2 * y + z) / (4)) ";
658 val e209 = the (rewrite_set thy' false "common_nominator_p" e209');
660 writeln ("example 210:");
661 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)) ";
662 val e210 = the (rewrite_set thy' false "common_nominator_p" e210');
664 writeln ("example 211:");
666 val e211a'="((b) / (a + -1 * b)) + ((-1 * a) / (a + -1 * b))";
667 val e211a = the (rewrite_set thy' false "common_nominator_p" e211a');
669 val e211b'="((b) / (b^^^2 + -1 * a^^^2)) + ((-1 * a) / (b^^^2 + -1 * a^^^2))";
670 val e211b = the (rewrite_set thy' false "common_nominator_p" e211b');
672 writeln ("example 212:");
674 val e212a'="((4) / (x)) + ((-3) / (y)) + -1";
675 val e212a = the (rewrite_set thy' false "common_nominator_p" e212a');
677 val e212b'="((4) / (x)) + ((-5) / (y)) + ((6) / (x*y))";
678 val e212b = the (rewrite_set thy' false "common_nominator_p" e212b');
680 writeln ("example 213:");
682 val e213a'="((5 * x) / (3 * y^^^2)) + ((19 * z) / (6 * x * y)) + ((-2 * x) / (3 * y^^^2)) + ((7 * y^^^2) / (6 * x^^^2)) ";
683 val e213a = the (rewrite_set thy' false "common_nominator_p" e213a');
685 val e213b'="((2 * b) / (3 * a^^^2)) + ((3 * c) / (7 * a * b)) + ((4 * b) / (3 * a^^^2)) + ((3 * a) / (7 * b^^^2))";
686 val e213b = the (rewrite_set thy' false "common_nominator_p" e213b');
688 writeln ("example 214:");
690 val e214a'="((3 * x + 2 * y + 2 * z) / (4)) + ((-5 * x + -3 * y) / (3)) + ((x + y + -2 * z) / (2))";
691 val e214a = the (rewrite_set thy' false "common_nominator_p" e214a');
693 val e214b'="((5 * x + 2 * y + z) / (2)) + ((-7 * x + -3 * y) / (3)) + ((3 * x + 6 * y + -1 * z) / (12))";
694 val e214b = the (rewrite_set thy' false "common_nominator_p" e214b');
696 writeln ("example 216:");
698 val e216a'="((2 * b + 3 * c) / (a * c)) + ((3 * a + b) / (a * b)) + ((-2 * b^^^2 + -3 * a * c) / (a * b * c))";
699 val e216a = the (rewrite_set thy' false "common_nominator_p" e216a');
701 val e216b'="((2 * a + 3 * b) / (b * c)) + ((3 * c + a) / (a * c)) + ((-2 * a^^^2 + -3 * b * c) / (a * b * c))";
702 val e216b = the (rewrite_set thy' false "common_nominator_p" e216b');
704 writeln ("example 217:");
705 val e217'="((z + -1) / (z)) + ((3 * z ^^^2 + -6 * z + 5) / (z^^^2)) + ((-4 * z^^^3 + 7 * z^^^2 + -5 * z + 5) / (z^^^3))";
706 val e217 = the (rewrite_set thy' false "common_nominator_p" e217');
709 val rls' = "common_nominator";
710 writeln ("example 218:");
711 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))";
712 val e218 = the (rewrite_set thy' false "common_nominator" e218');
713 if e218 = ("(16 - 63 * a ^^^ 2 - 81 * a ^^^ 3) / (108 * a ^^^ 4)", "[]") then ()
714 else error "rationa.sml common_nominator example e218";
716 writeln ("example 219:");
718 val e219a'="((1) / (y + 1)) + ((1) / (y + 2)) + ((1) / (y + 3))";
719 val e219a = the (rewrite_set thy' false "common_nominator" e219a');
721 val e219b'="((1) / (x + 1)) + ((1) / (x + 2)) + ((-2) / (x + 3))";
722 val e219b = the (rewrite_set thy' false "common_nominator" e219b');
723 if e219b = ("(5 + 3 * x) / (6 + 11 * x + 6 * x ^^^ 2 + x ^^^ 3)", "[]") then ()
724 else error "rationa.sml common_nominator example e219b";
726 writeln ("example 220:");
728 val e220a'="((17) / (5 * r + -2)) + ((-13) / (2 * r + 3)) + ((4) / (3 * r + -5))";
729 val e220a = the (rewrite_set thy' false "common_nominator" e220a');
731 val e220b'="((20 * a) / (a + -3)) + ((-19 * a) / (a + -4)) + ((a) / (a + -5))";
732 val e220b = the (rewrite_set thy' false "common_nominator" e220b');
734 writeln ("example 221:");
736 val e221a'="((a + b) / (a + -1 * b)) + ((a + -1 * b) / (a + b))";
737 val e221a = the (rewrite_set thy' false "common_nominator" e221a');
739 val e221b'="((x + -1 * y) / (x + y)) + ((x + y) / (x + -1 * y)) ";
740 val e221b = the (rewrite_set thy' false "common_nominator" e221b');
742 writeln ("example 222:");
744 val e222a'="((1 + -1 * x) / (1 + x)) + ((-1 + -1 * x) / (1 + -1 * x)) + ((4 * x) / (1 + -1 * x^^^2))";
745 val e222a = the (rewrite_set thy' false "common_nominator" e222a');
747 val e222b'="((1 + x ) / (1 + -1 * x)) + ((-1 + x) / (1 + x)) + ((2 * x) / (1 + -1 * x^^^2))";
748 val e222b = the (rewrite_set thy' false "common_nominator" e222b');
750 writeln ("example 225:");
752 val e225a'="((6 * a) / (a^^^2 + -64)) + ((a + 2) / (2 * a + 16)) + ((-1) / (2))";
753 val e225a = the (rewrite_set thy' false "common_nominator" e225a');
755 val e225b'="((a + 2 ) / (2 * a + 12)) + ((4 * a) / (a^^^2 + -36)) + ((-1) / (2))";
756 val e225b = the (rewrite_set thy' false "common_nominator" e225b');
758 writeln ("example 226:");
760 val e226a'="((35 * z) / (49 * z^^^2 + -4)) + -1 + ((14 * z + -1) / (14 * z + 4)) ";
761 val e226a = the (rewrite_set thy' false "common_nominator" e226a');
763 val e226b'="((45 * a * b) / (25 * a^^^2 + -9 * b^^^2)) + ((20 * a + 3 * b) / (10 * a + 6 * b)) + -2";
764 val e226b = the (rewrite_set thy' false "common_nominator" e226b');
766 writeln ("example 227:");
768 val e227a'="((6 * z + 11) / (6 * z + 14)) + ((9 * z ) / (9 * z^^^2 + -49)) + -1 ";
769 val e227a = the (rewrite_set thy' false "common_nominator" e227a');
771 val e227b'="((16 * a + 37 * b) / (4 * a + 10 * b)) + ((6 * a * b) / (4 * a^^^2 + -25 * b^^^2)) + -4 ";
772 val e227b = the (rewrite_set thy' false "common_nominator" e227b');
774 writeln ("example 228:");
776 val e228a'="((7 * a + 11) / (3 * a^^^2 + -3)) + ((-2 * a + -1) / (a^^^2 + -1 * a)) + ((-1) / (3 * a + 3))";
777 val e228a = the (rewrite_set thy' false "common_nominator" e228a');
779 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))";
780 val e228b = the (rewrite_set thy' false "common_nominator" e228b');
783 writeln ("example 229:");
785 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))";
786 val e229a = the (rewrite_set thy' false "common_nominator" e229a');
788 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))";
789 val e229b = the (rewrite_set thy' false "common_nominator" e229b');
791 writeln ("example 230:");
793 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))";
794 val e230a = the (rewrite_set thy' false "common_nominator" e230a');
796 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))";
797 val e230b = the (rewrite_set thy' false "common_nominator" e230b');
799 writeln ("example 231:");
801 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))";
802 val e231a = the (rewrite_set thy' false "common_nominator" e231a');
804 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))";
805 val e231b = the (rewrite_set thy' false "common_nominator" e231b');
807 writeln ("example 232:");
809 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))";
810 val e232a = the (rewrite_set thy' false "common_nominator" e232a');
812 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))";
813 val e232b = the (rewrite_set thy' false "common_nominator" e232b');
815 writeln ("example 233:");
817 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))";
818 val e233a = the (rewrite_set thy' false "common_nominator" e233a');
820 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))";
821 val e233b = the (rewrite_set thy' false "common_nominator" e233b');
823 writeln ("example 234:");
825 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))";
826 val e234a = the (rewrite_set thy' false "common_nominator" e234a');
828 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)) ";
829 val e234b = the (rewrite_set thy' false "common_nominator" e234b');
831 writeln ("example 235:");
833 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))";
834 val e235a = the (rewrite_set thy' false "common_nominator" e235a');
836 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)) ";
837 val e235b = the (rewrite_set thy' false "common_nominator" e235b');
839 writeln ("example 236:");
841 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))";
842 val e236a = the (rewrite_set thy' false "common_nominator" e236a');
844 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)) ";
845 val e236b = the (rewrite_set thy' false "common_nominator" e236b');
849 writeln ("example heuberger:");
850 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)";
851 val eheu = the (rewrite_set thy' false "cancel" eheu');
853 val rls' = "common_nominator_p";
854 writeln ("example stiefel:");
855 val est1'="(7) / (-14) + (-2) / (4)";
856 val est1 = the (rewrite_set thy' false "common_nominator_p" est1');
857 if est1 = ("-1 / 1", "[]") then ()
858 else error "new behaviour in rational.sml: est1'";
860 val t = (term_of o the o (parse thy))
861 "(9 - x ^^^ 2) / (9 - 6 * x + x ^^^ 2)";
862 val SOME (t',_) = factout_ thy t;
863 if term2str t' = "(3 + x) * (3 - x) / ((3 - x) * (3 - x))" then ()
864 else error "rational.sml factout_ (9 - x ^^^ 2) / (9 - 6 * x + x ^^^ 2)";
867 "-------- reverse rewrite -------------------------------";
868 "-------- reverse rewrite -------------------------------";
869 "-------- reverse rewrite -------------------------------";
870 (*WN.28.8.02: tests for the 'reverse-rewrite' functions:
871 these are defined in Rationals.ML and stored in
872 the 'reverse-ruleset' cancel*)
874 (*the term for which reverse rewriting is demonstrated*)
875 val t = (term_of o the o (parse thy))
876 "(9 - x ^^^ 2) / (9 + 6 * x + x ^^^ 2)";
877 val Rrls {scr=Rfuns {init_state=ini,locate_rule=loc,
878 next_rule=nex,normal_form=nor,...},...} = cancel;
880 (*normal_form produces the result in ONE step*)
881 val SOME (t',_) = nor t;
882 if term2str t' = "(3 - x) / (3 + x)" then ()
883 else error "rational.sml normal_form (9 - x ^^^ 2) / (9 - 6 * x + x ^^^ 2)";
885 (*initialize the interpreter state used by the 'me'*)
886 val (t,_,revsets,_) = ini t;
888 (*find the rule 'r' to apply to term 't'*)
889 val SOME (r as (Thm (str, thm))) = nex revsets t;
890 if str = "sym_#power_Float ((3,0), (0,0)) __ ((2,0), (0,0))"
891 andalso string_of_thm thm =
892 (string_of_thm o make_thm o (cterm_of (@{theory "Isac"})))
893 (Trueprop $ (term_of o the o (parse thy)) "9 = 3 ^^^ 2") then ()
894 else error "rational.sml next_rule (9 - x ^^^ 2) / (9 - 6 * x + x ^^^ 2)";
895 (* before Isa02->09-2 was not checked automatically, ?was different?:
896 val SOME r = nex revsets t;
897 val r = Thm ("sym_#mult_2_3","6 = 2 * 3") : rule*)
899 (* check, if the rule 'r' applied by the user to 't' belongs to the ruleset;
900 if the rule is OK, the term resulting from applying the rule is returned,too;
901 there might be several rule applications inbetween,
902 which are listed after the head in reverse order *)
903 val (r, (t, asm))::_ = loc revsets t r;
904 if term2str t = "(9 - x ^^^ 2) / (3 ^^^ 2 + 6 * x + x ^^^ 2)" andalso asm = []
906 else error "rational.sml locate_rule (9 - x ^^^ 2) / (9 - 6 * x + x ^^^ 2)";
908 (* find the next rule to apply *)
909 val SOME (r as (Thm (str, thm))) = nex revsets t;
910 if str = "sym_#power_Float ((3,0), (0,0)) __ ((2,0), (0,0))" andalso
911 string_of_thm thm = (string_of_thm o make_thm o (cterm_of (@{theory "Isac"})))
912 (Trueprop $ (term_of o the o (parse thy)) "9 = 3 ^^^ 2") then ()
913 else error "rational.sml next_rule (9 - x ^^^ 2) / (9 - 6 * x + x ^^^ 2)";
915 (*check the next rule*)
916 val (r, (t, asm)) :: _ = loc revsets t r;
917 if term2str t = "(3 ^^^ 2 - x ^^^ 2) / (3 ^^^ 2 + 6 * x + x ^^^ 2)" then ()
918 else error "rational.sml locate_rule (9 - x ^^^ 2) / (9 - 6 * x + x ^^^ 2) II";
920 (*find and check the next rules, rewrite*)
921 val SOME r = nex revsets t;
922 val (r,(t,asm))::_ = loc revsets t r;
923 if term2str t = "(3 ^^^ 2 - x ^^^ 2) / (3 ^^^ 2 + 2 * 3 * x + x ^^^ 2)" then ()
924 else error "rational.sml locate_rule II";
926 val SOME r = nex revsets t;
927 val (r,(t,asm))::_ = loc revsets t r;
928 if term2str t = "(3 - x) * (3 + x) / (3 ^^^ 2 + 2 * 3 * x + x ^^^ 2)" then ()
929 else error "rational.sml next_rule II";
931 val SOME r = nex revsets t;
932 val (r,(t,asm))::_ = loc revsets t r;
933 if term2str t = "(3 - x) * (3 + x) / ((3 + x) * (3 + x))" then ()
934 else error "rational.sml next_rule III";
936 val SOME r = nex revsets t;
937 val (r, (t, asm)) :: _ = loc revsets t r;
939 if ss = "(3 - x) / (3 + x)" andalso terms2str asm = "[\"3 + x ~= 0\"]" then ()
940 else error "rational.sml: new behav. in rev-set cancel";
942 "-------- 'reverse-ruleset' cancel_p --------------------";
943 "-------- 'reverse-ruleset' cancel_p --------------------";
944 "-------- 'reverse-ruleset' cancel_p --------------------";
945 (*WN.11.9.02: the 'reverse-ruleset' cancel_p*)
947 (*the term for which reverse rewriting is demonstrated*)
948 val t = str2term "(9 + (-1)*x^^^2) / (9 + ((-6)*x + x^^^2))";
949 val Rrls {scr=Rfuns {init_state=ini,locate_rule=loc,
950 next_rule=nex,normal_form=nor,...},...} = cancel_p;
952 (*normal_form produces the result in ONE step*)
953 val SOME (t',_) = nor t;
954 term2str t' = "(3 + 1 * x) / (3 + -1 * x)";
956 (*initialize the interpreter state used by the 'me'*)
957 val SOME (t', asm) = cancel_p_ thy t;
958 term2str t' = "(3 + x) / (3 + -1 * x)" (*true*);
959 terms2str asm = "[\"3 + -1 * x ~= 0\"]" (*true*);
960 val (t,_,revsets,_) = ini t;
962 (* WN.10.10.02: dieser Fall terminiert nicht
963 (make_polynomial enth"alt zu viele rules)
964 WN060823 'init_state' requires rewriting on specified location in the term
965 print_depth 99; Rfuns; print_depth 3;
966 WN060831 cycling "sym_order_mult_rls_" "sym_real_mult_assoc"
967 as was with make_polynomial before ?!?*)
969 val SOME r = nex revsets t;
970 eq_Thm (r, Thm ("sym_#power_Float ((3,0), (0,0)) __ ((2,0), (0,0))",
971 mk_thm thy "9 = 3 ^^^ 2"));
972 (*WN060831 *** id_of_thm
973 Exception- ERROR raised ...
974 val (r,(t,asm))::_ = loc revsets t r;
977 val SOME r = nex revsets t;
978 val (r,(t,asm))::_ = loc revsets t r;
982 writeln "****************** all tests successfull *************************";
986 (*WN.17.3.03 =========================================================vvv---*)
987 "-------- norm_Rational ---------------------------------";
988 "-------- norm_Rational ---------------------------------";
989 "-------- norm_Rational ---------------------------------";
990 val t = str2term "(3*x+5)/18 - x/2 - -(3*x - 2)/9 = 0";
991 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
992 if term2str t' = "1 / 18 = 0" then () else error "rational.sml 1";
994 val t = str2term "(17*x - 51)/9 - (-(13*x - 3)/6) + 11 - (9*x - 7)/4 = 0";
995 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
996 if term2str t' = "(237 + 65 * x) / 36 = 0" then ()
997 else error "rational.sml 2";
999 val t = str2term "(1/2 + (5*x)/2)^^^2 - ((13*x)/2 - 5/2)^^^2 - (6*x)^^^2 + 29";
1000 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
1001 if term2str t' = "23 + 35 * x + -72 * x ^^^ 2" then ()
1002 else error "rational.sml 3";
1004 (*trace_rewrite:=true;*)
1005 val t = str2term "Not (6*x is_atom)";
1006 val SOME (t',_) = rewrite_set_ thy false powers_erls t; term2str t';
1008 val t = str2term "1 < 2";
1009 val SOME (t',_) = rewrite_set_ thy false powers_erls t; term2str t';
1012 val t = str2term "(6*x)^^^2";
1013 val SOME (t',_) = rewrite_ thy dummy_ord powers_erls false
1014 (num_str @{thm realpow_def_atom}) t;
1015 if term2str t' = "6 * x * (6 * x) ^^^ (2 + -1)" then ()
1016 else error "rational.sml powers_erls (6*x)^^^2";
1018 val t = str2term "-1 * (-2 * (5 / 2 * (13 * x / 2)))";
1019 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
1020 if term2str t' = "65 * x / 2" then () else error "rational.sml 4";
1022 val t = str2term "1 - ((13*x)/2 - 5/2)^^^2";
1023 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
1024 (*bef.040209: if term2str t' = "(-21 + (130 * x + -169 * x ^^^ 2)) / 4"then()*)
1025 if term2str t' = "(-21 + 130 * x + -169 * x ^^^ 2) / 4" then ()
1026 else error "rational.sml 5";
1028 (*SRAM Schalk I, p.92 Nr. 609a*)
1029 val t = str2term "2*(3 - x/5)/3 - 4*(1 - x/3) - x/3 - 2*(x/2 - 1/4)/27 +5/54";
1030 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
1031 if term2str t' = "(-255 + 112 * x) / 135" then ()
1032 else error "rational.sml 6";
1034 (*SRAM Schalk I, p.92 Nr. 610c*)
1035 val t = str2term "((x- 1)/(x+1) + 1) / ((x- 1)/(x+1) - (x+1)/(x- 1)) - 2";
1036 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
1037 if term2str t' = "(-3 + -1 * x) / 2" then () else error "rational.sml 7";
1039 (*SRAM Schalk I, p.92 Nr. 476a*)
1040 val t = str2term "(x^^^2/(1 - x^^^2) + 1)/(x/(1 - x) + 1) * (1 + x)";
1041 (*. a/b : c/d translated to a/b * d/c .*)
1042 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
1043 (*if term2str t' = "1 / 1" then () else error "rational.sml 8";3.6.03*)
1044 if term2str t' = "1" then () else error "rational.sml 8";
1046 (*............................vvv---TODO: sollte gehen mit poly_order *)
1047 (*Schalk I, p.92 Nr. 472a*)
1048 val t = str2term "((8*x^^^2 - 32*y^^^2)/(2*x + 4*y))/((4*x - 8*y)/(x + y))";
1049 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
1050 if term2str t' = "x + y" then () else error "rational.sml p.92 Nr. 472a";
1052 (*Schalk I, p.70 Nr. 480b; a/b : c/d translated to a/b * d/c*)
1053 val t = str2term ("((12*x*y/(9*x^^^2 - y^^^2))/" ^
1054 "(1/(3*x - y)^^^2 - 1/(3*x + y)^^^2)) *" ^
1055 "(1/(x - 5*y)^^^2 - 1/(x + 5*y)^^^2)/" ^
1056 "(20*x*y/(x^^^2 - 25*y^^^2))");
1057 (*... nicht simpl, zerlegt ...*)
1058 val t = str2term ("((12*x*y/(9*x^^^2 - y^^^2))/" ^
1059 "(1/(3*x - y)^^^2 - 1/(3*x + y)^^^2))");
1060 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
1061 "(-12 * (x * y ^^^ 3) + 108 * (x * (y * x ^^^ 2))) / (12 * (x * y))";
1062 (* ~~~~~~~~~~ poly_order notwendig!*)
1063 val t = str2term ("(1/(x - 5*y)^^^2 - 1/(x + 5*y)^^^2)/" ^
1064 "(20*x*y/(x^^^2 - 25*y^^^2))");
1065 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
1066 if term2str t' = "1 / (x ^^^ 2 + -25 * y ^^^ 2)" then ()
1067 else error "rational.sml norm_Rational 1 / (x ^^^ 2 + -25 * y ^^^ 2)";
1069 "nonterm.SK6 ----- SK060904-2a non-termination of add_fraction_p_";
1070 (*WN.2.6.03 from rlang.sml 56a
1071 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)";
1072 val NONE = rewrite_set_ thy false common_nominator_p t;
1074 WN060831 nonterm.SK7
1075 val t = str2term "(a + b * x) / (a + -1 * (b * x)) + (-1 * a + b * x) / (a + b * x)";
1076 val NONE = add_fraction_p_ thy t;
1080 (* ------------------------------------------------------------------- *)
1081 (*---------vvv------------ MG: ab 1.7.03 ----------------vvv-----------*)
1082 (* Simplifier fuer beliebige Buchterme *)
1083 (* ------------------------------------------------------------------- *)
1084 (*----------------------- norm_Rational_mg ----------------------------*)
1085 (* ------------------------------------------------------------------- *)
1087 "-------- numeral rationals -----------------------------";
1088 "-------- numeral rationals -----------------------------";
1089 "-------- numeral rationals -----------------------------";
1090 (*SRA Schalk I, p.40 Nr. 164b *)
1091 val t = str2term "(47/6 - 76/9 + 13/4)/(35/12)";
1092 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1094 if (term2str t) = "19 / 21" then ()
1095 else error "rational.sml: diff.behav. in norm_Rational_mg 1";
1097 (*SRA Schalk I, p.40 Nr. 166a *)
1098 val t = str2term "((5/4)/(4+22/7) + 37/20)*(110/3 - 110/9 * 23/11)";
1099 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1101 if (term2str t) = "45 / 2" then ()
1102 else error "rational.sml: diff.behav. in norm_Rational_mg 2";
1105 "-------- cancellation ----------------------------------";
1106 "-------- cancellation ----------------------------------";
1107 "-------- cancellation ----------------------------------";
1108 (* e190c Stefan K.*)
1110 "((1 + 9 * a ^^^ 2)*(1 + 3 * a))/((3 * a + 9 * a ^^^ 2)*(1 + 3 * a))";
1111 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1114 "(1 + 9 * a ^^^ 2) / (3 * a + 9 * a ^^^ 2)"
1116 else error "rational.sml: diff.behav. in norm_Rational_mg 3";
1118 (* e192b Stefan K.*)
1120 "((x ^^^ 2)*(7 * x + (-1) * y))/((y ^^^ 2)*(7 * x + (-1) * y))";
1121 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1126 else error "rational.sml: diff.behav. in norm_Rational_mg 4";
1128 (*SRC Schalk I, p.66 Nr. 379c *)
1131 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1136 else error "rational.sml: diff.behav. in norm_Rational_mg 5";
1138 (*SRC Schalk I, p.66 Nr. 380b *)
1140 "15*(3*x+3)*(4*x+9)/(12*(2*x+7)*(5*x+5))";
1141 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1144 "(27 + 12 * x) / (28 + 8 * x)"
1146 else error "rational.sml: diff.behav. in norm_Rational_mg 6";
1148 (*Schalk I, p.60 Nr. 215c *)
1149 (* Falsches Ergebnis: rechnet lange und cancel_p kann nicht weiter krzen!!!*)
1151 val t = str2term "(a+b)^^^4*(x - y)/((x - y)^^^3*(a+b)^^^2)";
1152 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1155 "(a ^^^ 4 * x + -1 * a ^^^ 4 * y + 4 * a ^^^ 3 * b * x + -4 * a ^^^ 3 * b * y + 6 * a ^^^ 2 * b ^^^ 2 * x + -6 * a ^^^ 2 * b ^^^ 2 * y + 4 * a * b ^^^ 3 * x + -4 * a * b ^^^ 3 * y + b ^^^ 4 * x + -1 * b ^^^ 4 * y) /(a ^^^ 2 * x ^^^ 3 + -3 * a ^^^ 2 * x ^^^ 2 * y + 3 * a ^^^ 2 * x * y ^^^ 2 + -1 * a ^^^ 2 * y ^^^ 3 + 2 * a * b * x ^^^ 3 + -6 * a * b * x ^^^ 2 * y + 6 * a * b * x * y ^^^ 2 + -2 * a * b * y ^^^ 3 + b ^^^ 2 * x ^^^ 3 + -3 * b ^^^ 2 * x ^^^ 2 * y + 3 * b ^^^ 2 * x * y ^^^ 2 + -1 * b ^^^ 2 * y ^^^ 3)"
1157 else error "rational.sml: diff.behav. in norm_Rational_mg 7";
1160 "(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)"
1161 val SOME (t,_) = rewrite_set_ thy false cancel_p t;
1163 (* uncaught exception nonexhaustive binding failure
1164 raised at: stdIn:93.1-93.51 *)
1166 (*Schalk I, p.66 Nr. 381a *)
1167 (* ACHTUNG: rechnet ca. 2 Minuten !!! *)
1169 val t = str2term "18*(a+b)^^^3*(a - b)^^^2/(72*(a - b)^^^3*(a+b)^^^2)";
1170 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1173 "(a + b) / (4 * a + -4 * b)"
1174 then () else error "rational.sml: diff.behav. in norm_Rational_mg 8";
1177 (*SRC Schalk I, p.66 Nr. 381b *)
1179 "(4*x^^^2 - 20*x + 25)/(2*x - 5)^^^3";
1180 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1185 else error "rational.sml: diff.behav. in norm_Rational_mg 9";
1187 (*SRC Schalk I, p.66 Nr. 381c *)
1189 "(27*a^^^3+9*a^^^2+3*a+1)/(27*a^^^3+18*a^^^2+3*a)";
1190 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1193 "(1 + 9 * a ^^^ 2) / (3 * a + 9 * a ^^^ 2)"
1195 else error "rational.sml: diff.behav. in norm_Rational_mg 10";
1197 (*SRC Schalk I, p.66 Nr. 383a *)
1199 "(5*a^^^2 - 5*a*b)/(a - b)^^^2";
1200 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1203 "5 * a / (a + -1 * b)"
1205 else error "rational.sml: diff.behav. in norm_Rational_mg 11";
1208 "-------- common denominator ----------------------------";
1209 "-------- common denominator ----------------------------";
1210 "-------- common denominator ----------------------------";
1211 (*SRA Schalk I, p.67 Nr. 403a *)
1214 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1217 "(-3 * x + 4 * y + -1 * x * y) / (x * y)"
1219 else error "rational.sml: diff.behav. in norm_Rational_mg 12";
1221 (*SRA Schalk I, p.67 Nr. 407b *)
1223 "(2*a+3*b)/(b*c) + (3*c+a)/(a*c) - (2*a^^^2+3*b*c)/(a*b*c)";
1224 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1229 else error "rational.sml: diff.behav. in norm_Rational_mg 13";
1231 (*SRA Schalk I, p.67 Nr. 410b *)
1233 "1/(x+1) + 1/(x+2) - 2/(x+3)";
1234 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1237 "(5 + 3 * x) / (6 + 11 * x + 6 * x ^^^ 2 + x ^^^ 3)"
1239 else error "rational.sml: diff.behav. in norm_Rational_mg 14";
1241 (*SRA Schalk I, p.67 Nr. 413b *)
1243 "(1+x)/(1 - x) - (1 - x)/(1+x) + 2*x/(1 - x^^^2)";
1244 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1247 "6 * x / (1 + -1 * x ^^^ 2)"
1249 else error "rational.sml: diff.behav. in norm_Rational_mg 15";
1251 (*SRA Schalk I, p.68 Nr. 414a *)
1253 "(x + 2)/(x - 1) + (x - 3)/(x - 2) - (x + 1)/((x - 1)*(x - 2))";
1254 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1257 "(-2 + -5 * x + 2 * x ^^^ 2) / (2 + -3 * x + x ^^^ 2)"
1259 else error "rational.sml: diff.behav. in norm_Rational_mg 16";
1261 (*SRA Schalk I, p.68 Nr. 423a *)
1263 "(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)";
1264 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1269 else error "rational.sml: diff.behav. in norm_Rational_mg 17";
1271 (*SRA Schalk I, p.68 Nr. 428b *)
1273 "1/(a - b)^^^2 + 1/(a+b)^^^2 - 2/(a^^^2 - b^^^2) - 4*(b^^^2 - 1)/(a^^^2 - b^^^2)^^^2";
1274 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1277 "4 / (a ^^^ 4 + -2 * a ^^^ 2 * b ^^^ 2 + b ^^^ 4)"
1279 else error "rational.sml: diff.behav. in norm_Rational_mg 18";
1281 (*SRA Schalk I, p.68 Nr. 430b *)
1283 "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";
1284 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1289 else error "rational.sml: diff.behav. in norm_Rational_mg 19";
1292 (*SRA Schalk I, p.68 Nr. 432 *)
1294 "(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)";
1295 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1300 else error "rational.sml: diff.behav. in norm_Rational_mg 20";
1305 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1308 "(3 * y + b * x) / (b * y)"
1310 else error "rational.sml: diff.behav. in norm_Rational_mg 21";
1313 "-------- multiply and cancel ---------------------------";
1314 "-------- multiply and cancel ---------------------------";
1315 "-------- multiply and cancel ---------------------------";
1316 (*SRM Schalk I, p.68 Nr. 436a *)
1318 "3*(x+y)/(15*(x - y)) * 25*(x - y)^^^2/(18*(x+y)^^^2)";
1319 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1322 "(5 * x + -5 * y) / (18 * x + 18 * y)"
1324 else error "rational.sml: diff.behav. in norm_Rational_mg 22";
1326 (*SRM.test Schalk I, p.68 Nr. 436b *)
1327 (*WN060420???MG3 crashes with method 'simplify' in
1328 IsacCore > Simplification > Rational Terms > Multiplication > No.2*)
1329 val t = str2term "5*a*(a - b)^^^2*(a + b)^^^3/(7*b*(a - b)^^^3) * 7*b/(a + b)^^^3";
1330 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1333 "5 * a / (a + -1 * b)"
1335 else error "rational.sml: diff.behav. in norm_Rational_mg 23";
1337 (*Schalk I, p.68 Nr. 437a *)
1338 val t = str2term "(3*a - 4*b)/(4*c+3*e) * (3*a+4*b)/(9*a^^^2 - 16*b^^^2)";
1339 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1340 if (term2str t) = "1 / (4 * c + 3 * e)" then ()
1341 else error "rational.sml: diff.behav. in norm_Rational_mg 24";
1343 "----- S.K. corrected non-termination 060904";
1344 val t = str2term "(3*a - 4*b) * (3*a+4*b)/((4*c+3*e)*(9*a^^^2 - 16*b^^^2))";
1345 val SOME (t',_) = rewrite_set_ thy false make_polynomial t;
1348 "(9 * a ^^^ 2 + -16 * b ^^^ 2) /\n(36 * a ^^^ 2 * c + 27 * a ^^^ 2 * e + -64 * b ^^^ 2 * c +\n -48 * b ^^^ 2 * e)"
1349 (*"(9 * a ^^^ 2 + -16 * b ^^^ 2) / (36 * a ^^^ 2 * c + 27 * a ^^^ 2 * e + -64 * b ^^^ 2 * c + -48 * b ^^^ 2 * e)"*)
1350 then () else error "rational.sml: S.K.8..corrected 060904-6";
1352 "----- S.K. corrected non-termination of cancel_p_";
1353 val t'' = str2term ("(9 * a ^^^ 2 + -16 * b ^^^ 2) /" ^
1354 "(36 * a^^^2 * c + (27 * a^^^2 * e + (-64 * b^^^2 * c + -48 * b^^^2 * e)))");
1355 val SOME (t',_) = rewrite_set_ thy false cancel_p t'';
1356 if term2str t' = "1 / (4 * c + 3 * e)" then ()
1357 else error "rational.sml: diff.behav. in cancel_p S.K.8";
1359 (*Schalk I, p.68 Nr. 437b *)
1360 (* nonterm.SK9 loops: cancel_p kann nicht weiter kuerzen!!! *)
1361 val t'' = str2term "(a + b)/(x^^^2 - y^^^2) * ((x - y)^^^2/(a^^^2 - b^^^2))";
1362 (* val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t'';
1365 "================delete===";
1366 (*a casual output from above*)
1368 "(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)";
1369 (* WN060831 nonterm.SK10
1370 val SOME (t,_) = rewrite_set_ thy false cancel_p t;
1374 (*SRM Schalk I, p.68 Nr. 438a *)
1376 "x*y/(x*y - y^^^2)*(x^^^2 - x*y)";
1377 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1382 else error "rational.sml: diff.behav. in norm_Rational_mg 24";
1384 (*SRM Schalk I, p.68 Nr. 439b *)
1386 "(4*x^^^2+4*x+1)*((x^^^2 - 2*x^^^3)/(4*x^^^2+2*x))";
1387 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1390 "(x + -4 * x ^^^ 3) / 2"
1392 else error "rational.sml: diff.behav. in norm_Rational_mg 25";
1394 (*SRM Schalk I, p.68 Nr. 440a *)
1396 "(x^^^2 - 2*x)/(x^^^2 - 3*x) * (x - 3)^^^2/(x^^^2 - 4)";
1397 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1400 "(-3 + x) / (2 + x)"
1402 else error "rational.sml: diff.behav. in norm_Rational_mg 26";
1404 "----- Schalk I, p.68 Nr. 440b SK11 works since 0707xx";
1406 "(a^^^3 - 9*a)/(a^^^3*b - a*b^^^3)*(a^^^2*b+a*b^^^2)/(a+3)";
1407 val SOME (t,_) = rewrite_set_ thy false norm_Rational t;
1408 if term2str t = "(-3 * a + a ^^^ 2) / (a + -1 * b)" then ()
1409 else error "rational.sml: diff.behav. in norm_Rational 27";
1411 "----- SK12 works since 0707xx";
1412 val t = str2term "(a^^^3 - 9*a)*(a^^^2*b+a*b^^^2)/((a^^^3*b - a*b^^^3)*(a+3))";
1413 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
1414 if term2str t' = "(-3 * a + a ^^^ 2) / (a + -1 * b)" then ()
1415 else error "rational.sml: diff.behav. in norm_Rational 28";
1418 "-------- common denominator and multiplication ---------";
1419 "-------- common denominator and multiplication ---------";
1420 "-------- common denominator and multiplication ---------";
1421 (*SRAM Schalk I, p.69 Nr. 441b *)
1422 val t = str2term "(4*a/3 + 3*b^^^2/a^^^3 + b/(4*a))*(4*b/(3*a))";
1423 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1426 "(36 * b ^^^ 3 + 3 * a ^^^ 2 * b ^^^ 2 + 16 * a ^^^ 4 * b) / (9 * a ^^^ 4)"
1427 then () else error "rational.sml: diff.behav. in norm_Rational_mg 28";
1429 (*SRAM Schalk I, p.69 Nr. 442b *)
1430 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)";
1431 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1434 "5 * x ^^^ 2 / (a * b ^^^ 3 * c)"
1435 then () else error "rational.sml: diff.behav. in norm_Rational_mg 29";
1437 (*SRAM Schalk I, p.69 Nr. 443b *)
1438 val t = str2term "(a/2 + b/3)*(b/3 - a/2)";
1439 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1442 "(-9 * a ^^^ 2 + 4 * b ^^^ 2) / 36"
1443 then () else error "rational.sml: diff.behav. in norm_Rational_mg 30";
1445 (*SRAM Schalk I, p.69 Nr. 445b *)
1446 val t = str2term "(a^^^2/9 + 2*a/(3*b) + 4/b^^^2)*(a/3 - 2/b) + 8/b^^^3";
1447 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1451 then () else error "rational.sml: diff.behav. in norm_Rational_mg 31";
1453 (*SRAM Schalk I, p.69 Nr. 446b *)
1454 val t = str2term "(x/(5*x + 4*y) - y/(5*x - 4*y) + 1)*(25*x^^^2 - 16*y^^^2)";
1455 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1458 "30 * x ^^^ 2 + -9 * x * y + -20 * y ^^^ 2"
1460 else error "rational.sml: diff.behav. in norm_Rational_mg 32";
1462 (*SRAM Schalk I, p.69 Nr. 449a *)(*Achtung: rechnet ca 8 Sekunden*)
1464 "(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)";
1465 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1467 if (term2str t) = "(-81 * x ^^^ 4 + 16 * x ^^^ 8 * y ^^^ 4) / (81 * y ^^^ 8)"
1468 then () else error "rational.sml: diff.behav. in norm_Rational_mg 33";
1471 (*SRAM Schalk I, p.69 Nr. 450a *)
1473 "(4*x/(3*y)+2*y/(3*x))^^^2 - (2*y/(3*x) - 2*x/y)*(2*y/(3*x)+2*x/y)";
1474 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1477 "(52 * x ^^^ 2 + 16 * y ^^^ 2) / (9 * y ^^^ 2)"
1479 else error "rational.sml: diff.behav. in norm_Rational_mg 34";
1482 "-------- double fractions ------------------------------";
1483 "-------- double fractions ------------------------------";
1484 "-------- double fractions ------------------------------";
1485 (*SRD Schalk I, p.69 Nr. 454b *)
1487 "((2 - x)/(2*a)) / (2*a/(x - 2))";
1488 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1491 "(-4 + 4 * x + -1 * x ^^^ 2) / (4 * a ^^^ 2)"
1493 else error "rational.sml: diff.behav. in norm_Rational_mg 35";
1495 (*SRD Schalk I, p.69 Nr. 455a *)
1497 "(a^^^2 + 1)/(a^^^2 - 1) / ((a+1)/(a - 1))";
1498 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1501 "(1 + a ^^^ 2) / (1 + 2 * a + a ^^^ 2)" then ()
1502 else error "rational.sml: diff.behav. in norm_Rational_mg 36";
1505 "----- Schalk I, p.69 Nr. 455b";
1506 val t = str2term "(x^^^2 - 4)/(y^^^2 - 9)/((2+x)/(3 - y))";
1507 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1508 if term2str t = "(2 + -1 * x) / (3 + y)" then ()
1509 else error "rational.sml: diff.behav. in norm_Rational_mg 37";
1511 "----- SK060904-1a non-termination of cancel_p_ ?: worked before 0707xx";
1512 val t = str2term "(x^^^2 - 4)*(3 - y)/((y^^^2 - 9)*(2+x))";
1513 val SOME (t,_) = rewrite_set_ thy false norm_Rational t;
1514 if term2str t = "(2 + -1 * x) / (3 + y)" then ()
1515 else error "rational.sml: diff.behav. in norm_Rational_mg 37b";
1517 "----- ?: worked before 0707xx";
1518 val t = str2term "(3 + -1 * y) / (-9 + y ^^^ 2)";
1519 val SOME (t,_) = rewrite_set_ thy false norm_Rational t;
1520 if term2str t = "-1 / (3 + y)" then ()
1521 else error "rational.sml: -1 / (3 + y) norm_Rational";
1523 (*SRD Schalk I, p.69 Nr. 456b *)
1525 "(b^^^3 - b^^^2)/(b^^^2+b)/(b^^^2 - 1)";
1526 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1528 if (term2str t) = "b / (1 + 2 * b + b ^^^ 2)" then ()
1529 else error "rational.sml: diff.behav. in norm_Rational_mg 38";
1531 (*SRD Schalk I, p.69 Nr. 457b *)
1533 "(16*a^^^2 - 9*b^^^2)/(2*a+3*a*b) / ((4*a+3*b)/(4*a^^^2 - 9*a^^^2*b^^^2))";
1534 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1537 "8 * a ^^^ 2 + -6 * a * b + -12 * a ^^^ 2 * b + 9 * a * b ^^^ 2"
1538 then () else error "rational.sml: diff.behav. in norm_Rational_mg 39";
1540 "----- Schalk I, p.69 Nr. 458b works since 0707";
1542 "(2*a^^^2*x - a^^^2)/(a*x - b*x) / (b^^^2*(2*x - 1)/(x*(a - b)))";
1543 val SOME (t,_) = rewrite_set_ thy false norm_Rational t;
1544 if term2str t = "a ^^^ 2 / b ^^^ 2" then ()
1545 else error "rational.sml: diff.behav. in norm_Rational_mg 39b";
1547 (*SRD Schalk I, p.69 Nr. 459b *)
1548 val t = str2term "(a^^^2 - b^^^2)/(a*b) / (4*(a+b)^^^2/a)";
1549 val SOME (t,_) = rewrite_set_ thy false norm_Rational t;
1550 if term2str t = "(a + -1 * b) / (4 * a * b + 4 * b ^^^ 2)" then ()
1551 else error "rational.sml: diff.behav. in norm_Rational_mg 41";
1554 (*Schalk I, p.69 Nr. 460b nonterm.SK
1556 "(9*(x^^^2 - 8*x+16)/(4*(y^^^2 - 2*y+1)))/((3*x - 12)/(16*y - 16))";
1557 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1560 else error "rational.sml: diff.behav. in norm_Rational_mg 42";
1563 "9*(x^^^2 - 8*x+16)*(16*y - 16)/(4*(y^^^2 - 2*y+1)*(3*x - 12))";
1564 val SOME (t',_) = rewrite_set_ thy false norm_Rational t;
1565 ... non terminating.
1566 val SOME (t',_) = rewrite_set_ thy false make_polynomial t;
1567 "(-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)";
1568 val SOME (t,_) = rewrite_set_ thy false cancel_p t';
1569 ... non terminating.*)
1571 (*SRD Schalk I, p.70 Nr. 472a *)
1572 val t = str2term ("((8*x^^^2 - 32*y^^^2)/(2*x + 4*y))/" ^
1573 "((4*x - 8*y)/(x + y))");
1574 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1579 else error "rational.sml: diff.behav. in norm_Rational_mg 43";
1582 (*----------------------------------------------------------------------*)
1583 (*---------------------- Einfache Dppelbrche --------------------------*)
1584 (*----------------------------------------------------------------------*)
1586 (*SRD Schalk I, p.69 Nr. 461a *)
1588 "(2/(x+3) + 2/(x - 3)) / (8*x/(x^^^2 - 9))";
1589 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1594 else error "rational.sml: diff.behav. in norm_Rational_mg 44";
1596 (*SRD Schalk I, p.69 Nr. 464b *)
1598 "(a - a/(a - 2)) / (a + a/(a - 2))";
1599 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1602 "(3 + -1 * a) / (1 + -1 * a)"
1604 else error "rational.sml: diff.behav. in norm_Rational_mg 45";
1606 (*SRD Schalk I, p.69 Nr. 465b *)
1608 "((x+3*y)/9 + (4*y^^^2 - 9*z^^^2)/(16*x)) /(x/9+y/6+z/4)";
1609 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1612 "(4 * x + 6 * y + -9 * z) / (4 * x)"
1614 else error "rational.sml: diff.behav. in norm_Rational_mg 46";
1616 (*SRD Schalk I, p.69 Nr. 466b *)
1618 "((1 - 7*(x - 2)/(x^^^2 - 4)) / (6/(x+2))) / (3/(x+5)+30/(x^^^2 - 25))";
1619 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1622 "(25 + -10 * x + x ^^^ 2) / 18"
1624 else error "rational.sml: diff.behav. in norm_Rational_mg 47";
1626 (*SRD Schalk I, p.70 Nr. 469 *)
1628 "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))";
1629 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1632 "3 * b ^^^ 3 / (2 * a + -2 * b)"
1634 else error "rational.sml: diff.behav. in norm_Rational_mg 48";
1636 (*----------------------------------------------------------------------*)
1637 (*---------------------- Mehrfache Dppelbrueche ------------------------*)
1638 (*----------------------------------------------------------------------*)
1640 (*SRD.test Schalk I, p.70 Nr. 476b *) (* Rechenzeit: 10 sec *)
1641 (*WN060419 crashes with method 'simplify' ????SK*)
1643 "((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)";
1644 val SOME (t,_) = rewrite_set_ thy false norm_Rational t;
1645 if term2str t = "1 / (a ^^^ 2 + -1 * b ^^^ 2)" then ()
1646 else error "rational.sml: diff.behav. in norm_Rational_mg 49";
1648 "----- Schalk I, p.70 Nr. 477a";
1649 (* MG Achtung: terme explodieren; Bsp zu komplex;
1650 L???ung sollte (ziemlich grosser) Faktorisierter Ausdruck sein
1651 val t = str2term "b*y/(b - 2*y)/((b^^^2 - y^^^2)/(b+2*y)) /" ^
1652 "(b^^^2*y+b*y^^^2)*(a+x)^^^2/((b^^^2 - 4*y^^^2)*(a+2*x)^^^2)";
1653 val SOME (t',_) = rewrite_set_ thy false norm_Rational t;
1656 val t = str2term "b*y*(b+2*y)*(b^^^2 - 4*y^^^2)*(a+2*x)^^^2 / " ^
1657 "((b - 2*y)*(b^^^2 - y^^^2)*(b^^^2*y+b*y^^^2)*(a+x)^^^2)";
1658 val SOME (t,_) = rewrite_set_ thy false make_polynomial t;
1662 "----- Schalk I, p.70 Nr. 478b ----- Rechenzeit: 5 sec";
1663 val t = str2term ("(a - (a*b+b^^^2)/(a+b))/(b+(a - b)/(1+(a+b)/(a - b))) / " ^
1664 "((a - a^^^2/(a+b))/(a+(a*b)/(a - b)))");
1665 val SOME (t',_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1667 "(2 * a ^^^ 3 + 2 * a ^^^ 2 * b) / (a ^^^ 2 * b + b ^^^ 3)"
1669 else error "rational.sml: diff.behav. in norm_Rational_mg 51";
1671 (* TODO.new_c:WN050820 STOP_REW_SUB introduced gave ...
1672 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 ()
1673 else error "rational.sml: works again";
1674 re-outcommented with TODO.new_c: cvs before 071227, 11:50*)
1678 (*Schalk I, p.70 Nr. 480a *)
1679 (* Achtung: rechnet ewig; cancel_p kann nicht krzen: WN060831 nonterm.SK00
1681 "(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)))";
1682 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1687 else error "rational.sml: diff.behav. in norm_Rational_mg 52";
1689 (*MG Berechne Zwischenergebnisse: WN060831 nonterm.SK00*)
1691 "(1/x+1/y+1/z)/(1/x - 1/y - 1/z)";
1692 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1694 "(x ^^^ 2 * y ^^^ 2 * z + x ^^^ 2 * y * z ^^^ 2 + x * y ^^^ 2 * z ^^^ 2) /
1695 (-1 * x ^^^ 2 * y ^^^ 2 * z + -1 * x ^^^ 2 * y * z ^^^ 2 + x * y ^^^ 2 * z ^^^ 2)";
1697 "2*x^^^2/(x^^^2 - z^^^2)/(x/(x+z)+x/(x - z))";
1698 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1702 (* SK 1. Ausdruck kann nicht weiter gekrzt werden; cancel_p !!!*)
1703 ### rls: cancel_p on:
1704 (x ^^^ 2 * (y ^^^ 2 * z) + x ^^^ 2 * (y * z ^^^ 2) + x * (y ^^^ 2 * z ^^^ 2)) /
1705 (-1 * (x ^^^ 2 * (y ^^^ 2 * z)) + -1 * (x ^^^ 2 * (y * z ^^^ 2)) + x * (y ^^^ 2 * z ^^^ 2))
1706 GC #3.61.81.101.197.17503: (0 ms)
1707 *** RATIONALS_DIRECT_CANCEL_EXCEPTION: Invalid fraction
1710 "(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))";
1711 val SOME (t,_) = rewrite_set_ thy false cancel_p t;
1713 (*uncaught exception nonexhaustive binding failure*)
1715 (* Das kann er aber krzen !!????: *)
1717 "(x^^^2 * (y^^^2 * z) + x * (y^^^2 * z^^^2)) / (-1 * (x^^^2 * (y * z^^^2)) + x * (y^^^2 * z^^^2))";
1718 val SOME (t,_) = rewrite_set_ thy false cancel_p t;
1720 "(-1 * (y * x) + -1 * (z * y)) / (1 * (z * x) + -1 * (z * y))";
1724 "-------- crucial examples ------------------------------";
1725 "-------- crucial examples ------------------------------";
1726 "-------- crucial examples ------------------------------";
1727 (*Schalk I, p.60 Nr. 215d *)
1728 (* Achtung: rechnet ewig ...
1729 val t = str2term "(a-b)^^^3 * (x+y)^^^4 / ((x+y)^^^2 * (a-b)^^^5)";
1730 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1731 term2str t; noterm.SK
1734 (* Kein Wunder, denn Z???ler und Nenner extra als Polynom dargestellt ergibt:*)
1736 val t = str2term "(a-b)^^^3 * (x+y)^^^4";
1737 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1739 "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";
1740 val t = str2term "((x+y)^^^2 * (a-b)^^^5)";
1741 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1743 "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";
1745 (*anscheinend macht dem Rechner das Krzen diese Bruches keinen Spass mehr ...*)
1747 (*--------------------------------------------------------------------*)
1748 (*Schalk I, p.70 Nr. 480b
1749 val t = str2term "((12*x*y/(9*x^^^2 - y^^^2))/" ^
1750 "(1/(3*x - y)^^^2 - 1/(3*x + y)^^^2)) *" ^
1751 "(1/(x - 5*y)^^^2 - 1/(x + 5*y)^^^2)/" ^
1752 "(20*x*y/(x^^^2 - 25*y^^^2))";
1753 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1755 Kann nicht weiter vereinfacht werden !!!!?? *)
1757 (*--------------------------------------------------------------------*)
1758 "---- MGs test set";
1759 val t = str2term " (1 + x^^^5) / (y + x) + x^^^3 / x ";
1760 val SOME (t,_) = rewrite_set_ thy false common_nominator_p t;
1761 if term2str t = "(1 + x ^^^ 3 + x ^^^ 5 + y * x ^^^ 2) / (x + y)" then()
1764 (*--------------------------------------------------------------------*)
1765 (* cancel_p liefert nicht immer Polynomnormalform (2): WN060831???SK3b
1766 ---> Sortierung FALSCH !! *)
1767 val t = str2term "b^^^3 * a^^^5/a ";
1768 val SOME (t,_) = rewrite_set_ thy false cancel_p t;
1770 "1 * (a^^^4 * b^^^3) / 1"; (*OK*)
1772 val t = str2term "b^^^3 * a^^^5/b ";
1773 val SOME (t,_) = rewrite_set_ thy false cancel_p t;
1775 "1 * (b^^^2 * a^^^5) / 1"; (*cancel_p sortiert hier falsch um!*)
1777 (* Problem liegt NICHT bei ord_make_polynomial! (siehe folgende Bsple) *)
1779 val x = str2term "x"; val bdv = str2term "bdv";
1780 val t1 = str2term "b^^^2 * a^^^5";
1781 val t2 = str2term "a^^^5 * b^^^2 ";
1782 ord_make_polynomial false Rational.thy [(x,bdv)] (t1,t2); (*false*)
1784 (* ==> "b^^^2 * a^^^5" > "a^^^5 * b^^^2 " ... OK!*)
1786 (*--------------------------------------------------------------------*)
1787 (* cancel_p liefert nicht immer Polynomnormalform (2): WN060831???SK3c
1788 ---> erzeugt berflssige "1 * ..."
1790 val t = str2term "-1 / (3 + y)";
1792 val SOME (t,_) = rewrite_set_ thy false cancel_p t;
1795 (********* Das ist das PROBLEM !!!!!!!??? *******************)
1796 (* -1 im Z???ler der Angabe verursacht das Problem !*)
1799 (* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *)
1800 "----- MGs test set";
1801 val t = str2term "(a^^^2 + -1)/(a+1)";
1802 val SOME (t',_) = rewrite_set_ thy false cancel_p t;
1803 if term2str t' = "(-1 + a) / 1" then ()
1804 else error "rational.sml MG tests 3d";
1806 "----- NOT TERMINATING ?: worked before 0707xx";
1807 val t = str2term "(a^^^2 - 1)*(b + 1) / ((b^^^2 - 1)*(a+1))";
1808 val SOME (t'',_) = rewrite_set_ thy false norm_Rational t;
1809 if term2str t'' = "(1 + -1 * a) / (1 + -1 * b)" then ()
1810 else error "rational.sml MG tests 3e";
1812 "----- corrected SK060905";
1813 val t = str2term "(4*x^^^2 - 20*x + 25)/(2*x - 5)^^^3";
1814 val SOME (t',_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1815 if term2str t' = "-1 / (5 + -2 * x)" then ()
1816 else error "rational.sml corrected SK060905";
1819 "-------- examples for Stefan Karnels thesis ------------";
1820 "-------- examples for Stefan Karnels thesis ------------";
1821 "-------- examples for Stefan Karnels thesis ------------";
1822 (*SRAM Schalk I, p.69 Nr. 442b --- abgewandelt*)
1824 "(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))";
1825 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1828 "5 * x ^^^ 2 / (b ^^^ 3 * c)"
1830 else error "rational.sml: diff.behav. in norm_Rational_mg 53";
1833 "-------- me Schalk I No.186 ----------------------------";
1834 "-------- me Schalk I No.186 ----------------------------";
1835 "-------- me Schalk I No.186 ----------------------------";
1836 val fmz = ["Term ((14 * x * y) / ( x * y ))",
1839 ("Rational",["rational","simplification"],
1840 ["simplification","of_rationals"]);
1841 val p = e_pos'; val c = [];
1842 val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
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;
1848 val (p,_,f,nxt,_,pt) = me nxt p c pt;
1849 val (p,_,f,nxt,_,pt) = me nxt p c pt;
1850 val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
1851 val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
1852 val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;(*++ for explicit script*)
1853 val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;(*++ for explicit script*)
1854 case (f2str f, nxt) of
1855 ("14", ("End_Proof'", _)) => ()
1856 | _ => error "rational.sml diff.behav. in me Schalk I No.186";
1859 "-------- interSteps ..Simp_Rat_Double_No-1.xml ---------";
1860 "-------- interSteps ..Simp_Rat_Double_No-1.xml ---------";
1861 "-------- interSteps ..Simp_Rat_Double_No-1.xml ---------";
1864 [(["Term (((2 - x)/(2*a)) / (2*a/(x - 2)))", "normalform N"],
1865 ("Rational",["rational","simplification"],
1866 ["simplification","of_rationals"]))];
1869 autoCalculate 1 CompleteCalc;
1870 val ((pt,p),_) = get_calc 1; show_pt pt;
1872 interSteps 1 ([1],Res);
1873 val ((pt,p),_) = get_calc 1; show_pt pt;
1876 "-------- interSteps ..Simp_Rat_Cancel_No-1.xml ---------";
1877 "-------- interSteps ..Simp_Rat_Cancel_No-1.xml ---------";
1878 "-------- interSteps ..Simp_Rat_Cancel_No-1.xml ---------";
1881 [(["Term ((a^2 + -1*b^2) / (a^2 + -2*a*b + b^2))", "normalform N"],
1882 ("Rational",["rational","simplification"],
1883 ["simplification","of_rationals"]))];
1886 autoCalculate 1 CompleteCalc;
1887 val ((pt,p),_) = get_calc 1; show_pt pt;
1888 (*========== inhibit exn 110314 ================================================
1889 (*with explicit script done already... and removed [1,..] at below...
1890 interSteps 1 ([1],Res);
1891 val ((pt,p),_) = get_calc 1; show_pt pt;
1893 interSteps 1 ([2],Res);
1894 val ((pt,p),_) = get_calc 1; show_pt pt;
1896 interSteps 1 ([2,1],Res);
1897 val ((pt,p),_) = get_calc 1; show_pt pt;
1898 val newnds = children (get_nd pt [2,1]) (*see "fun detailrls"*);
1899 (*if length newnds = 12 then () WN060905*)
1900 if length newnds = 13 then ()
1901 else error "rational.sml: interSteps cancel_p rev_rew_p";
1903 val p = ([2,1,9],Res);
1905 val (_, tac, _) = pt_extract (pt, p);
1906 (*case tac of SOME (Rewrite ("sym_real_plus_binom_times1", _)) => ()
1908 case tac of SOME (Rewrite ("sym_real_add_mult_distrib2", _)) => ()
1909 | _ => error "rational.sml: getTactic, sym_real_plus_binom_times1";
1910 ============ inhibit exn 110314 ==============================================*)
1913 "-------- investigate rulesets for cancel_p -------------";
1914 "-------- investigate rulesets for cancel_p -------------";
1915 "-------- investigate rulesets for cancel_p -------------";
1916 val thy = @{theory "Rational"};
1917 "---------------- (a^^^2 + -1*b^^^2) / (a^^^2 + -2*a*b + b^^^2)";
1918 val t = str2term "(a^^^2 + -1*b^^^2) / (a^^^2 + -2*a*b + b^^^2)";
1919 val tt = str2term "(1 * a + 1 * b) * (1 * a + -1 * b)"(*numerator only*);
1920 "----- with rewrite_set_";
1921 val SOME (tt',asm) = rewrite_set_ thy false make_polynomial tt;
1922 term2str tt'= "a ^^^ 2 + -1 * b ^^^ 2" (*true*);
1923 val tt = str2term "((1 * a + -1 * b) * (1 * a + -1 * b))"(*denominator only*);
1924 val SOME (tt',asm) = rewrite_set_ thy false make_polynomial tt;
1925 term2str tt' = "a ^^^ 2 + -2 * a * b + b ^^^ 2" (*true*);
1927 "----- with make_deriv";
1928 val SOME (tt, _) = factout_p_ thy t; term2str tt =
1929 "(1 * a + 1 * b) * (1 * a + -1 * b) / ((1 * a + -1 * b) * (1 * a + -1 * b))";
1931 "--- with ruleset as before 060829";
1932 val {rules, rew_ord=(_,ro),...} =
1933 rep_rls (assoc_rls "make_polynomial");
1934 val der = make_deriv thy Atools_erls rules ro NONE tt;
1935 print_depth 99; map (term2str o #1) der; print_depth 3;
1936 print_depth 99; map (rule2str o #2) der; print_depth 3;
1937 ... did not terminate*)
1938 "--- with simpler ruleset";
1939 val {rules, rew_ord=(_,ro),...} =
1940 rep_rls (assoc_rls "rev_rew_p");
1941 val der = make_deriv thy Atools_erls rules ro NONE tt;
1942 print_depth 99; writeln (deriv2str der); print_depth 3;
1944 print_depth 99; map (term2str o #1) der; print_depth 3;
1945 "...,(-1 * b ^^^ 2 + a ^^^ 2) / (-2 * (a * b) + a ^^^ 2 + (-1 * b) ^^^ 2) ]";
1946 print_depth 99; map (rule2str o #2) der; print_depth 3;
1947 print_depth 99; map (term2str o #1 o #3) der; print_depth 3;
1949 val der = make_deriv thy Atools_erls rules ro NONE
1950 (str2term "(1 * a + 1 * b) * (1 * a + -1 * b)");
1951 print_depth 99; writeln (deriv2str der); print_depth 3;
1953 val {rules, rew_ord=(_,ro),...} =
1954 rep_rls (assoc_rls "rev_rew_p");
1955 val der = make_deriv thy Atools_erls rules ro NONE
1956 (str2term "(1 * a + -1 * b) * (1 * a + -1 * b)");
1957 print_depth 99; writeln (deriv2str der); print_depth 3;
1958 print_depth 99; map (term2str o #1) der; print_depth 3;
1959 (*WN060829 ...postponed*)
1962 "-------- investigate format of factout_ and factout_p_ -";
1963 "-------- investigate format of factout_ and factout_p_ -";
1964 "-------- investigate format of factout_ and factout_p_ -";
1965 val {rules, rew_ord = (_,ro),...} = rep_rls (assoc_rls "make_polynomial");
1966 val (thy, eval_rls) = (@{theory "Rational"}, Atools_erls)(*see 'fun init_state'*);
1967 val Rrls {scr = Rfuns {init_state,...},...} = assoc_rls "cancel_p";
1969 "----- see Rational.ML, local cancel_p, fun init_state";
1970 val t = str2term "(a^^^2 + (-1)*b^^^2) / (a^^^2 + (-2)*a*b + b^^^2)";
1971 val SOME (t',_) = factout_p_ thy t; term2str t';
1973 val rtas = reverse_deriv thy eval_rls rules ro NONE t';
1974 writeln(trtas2str rst);
1978 "----- see Rational.ML, local cancel_p, fun init_state";
1979 val t = str2term "a^^^2 / a";
1980 val SOME (t',_) = factout_p_ thy t;
1981 term2str t' = "a * a / (1 * a)" (*true*);
1982 (*... can be canceled with
1983 real_mult_div_cancel2 ?k ~= 0 ==> ?m * ?k / (?n * ?k) = ?m / ?n"*)
1984 (* sml/ME/rewtools.sml:
1985 val rtas = reverse_deriv thy Atools_erls rules ro NONE t';
1986 writeln (deri2str rtas);
1990 "-------- SK 060904 ----------------------------------------------";
1991 "----- order on polynomials -- input + output";
1992 val thy = @{theory "Isac"};
1993 val t = str2term "(a + -1 * b) / (-1 * a + b)";
1994 val SOME (t', _) = factout_p_ thy t; term2str t';
1995 val SOME (t', _) = cancel_p_ thy t; term2str t';
1997 val t = str2term "a*b*c*d / (d*e*f*g)";
1998 val SOME (t', _) = cancel_p_ thy t; term2str t';
2000 val t = str2term "a*(b*(c*d)) / (b*(e*(f*g)))";
2001 val SOME (t', _) = cancel_p_ thy t; term2str t';
2004 "----- SK060904-1a non-termination of cancel_p_ ? worked before 0707xx";
2005 val t = str2term "(x^^^2 - 4)*(3 - y) / ((y^^^2 - 9)*(2+x))";
2006 val SOME (t',_) = rewrite_set_ thy false norm_Rational t;
2007 if term2str t' = "(2 + -1 * x) / (3 + y)" then ()
2008 else error "rational.sml SK060904-1a worked since 0707xx";
2010 "----- SK060904-1b non-termination of cancel_p_ ... worked before 0707xx";
2011 val t = str2term ("(9 * a ^^^ 2 + -16 * b ^^^ 2) /" ^
2012 "(36 * a^^^2 * c + (27 * a^^^2 * e + (-64 * b^^^2 * c + -48 * b^^^2 * e)))");
2013 val SOME (t',_) = cancel_p_ thy t;
2014 if term2str t' = "1 / (4 * c + 3 * e)" then ()
2015 else error "rational.sml SK060904-1b";
2018 "----- SK060904-2a non-termination of add_fraction_p_";
2019 val t = str2term (" (a + b * x) / (a + -1 * (b * x)) + " ^
2020 " (-1 * a + b * x) / (a + b * x) ");
2022 val SOME (t',_) = rewrite_set_ thy false common_nominator_p t;
2024 common_nominator_p_ thy t;
2025 " (a + b * x)*(a + b * x) / ((a + -1 * (b * x))*(a + -1 * (b * x))) + " ^
2026 " (-1 * a + b * x)*(a + -1 * (b * x)) / ((a + b * x)*(-1 * a + b * x)) ";
2028 add_fraction_p_ thy t;
2029 " ((a + b * x)*(a + b * x) + (-1 * a + b * x)*(a + -1 * (b * x))) /" ^
2030 " ((a + b * x)*(-1 * a + b * x)) ";
2034 "-------- how to stepwise construct Scripts -------------";
2035 "-------- how to stepwise construct Scripts -------------";
2036 "-------- how to stepwise construct Scripts -------------";
2037 val thy = @{theory "Rational"};
2039 val p1 = parse thy (
2040 "Script SimplifyScript (t_t::real) = " ^
2041 " (Rewrite_Set discard_minus False " ^
2044 (*required (): (Rewrite_Set discard_minus False)*)
2045 val p2 = parse thy (
2046 "Script SimplifyScript (t_t::real) = " ^
2047 " (Rewrite_Set discard_minus False " ^
2050 val p3 = parse thy (
2051 "Script SimplifyScript (t_t::real) = " ^
2052 " ((Rewrite_Set discard_minus False) " ^
2055 val p4 = parse thy (
2056 "Script SimplifyScript (t_t::real) = " ^
2057 " ((Rewrite_Set discard_minus False) " ^
2060 val p5 = parse thy (
2061 "Script SimplifyScript (t_t::real) = " ^
2062 " ((Try (Rewrite_Set discard_minus False) " ^
2063 " Try (Rewrite_Set discard_parentheses False)) " ^
2066 val p6 = parse thy (
2067 "Script SimplifyScript (t_t::real) = " ^
2068 " ((Try (Rewrite_Set discard_minus False) @@ " ^
2069 " Try (Rewrite_Set rat_mult_poly False) @@ " ^
2070 " Try (Rewrite_Set make_rat_poly_with_parentheses False) @@ " ^
2071 " Try (Rewrite_Set cancel_p_rls False) @@ " ^
2073 " ((Try (Rewrite_Set common_nominator_p_rls False) @@ " ^
2074 " Try (Rewrite_Set rat_mult_div_pow False) @@ " ^
2075 " Try (Rewrite_Set make_rat_poly_with_parentheses False) @@" ^
2076 " Try (Rewrite_Set cancel_p_rls False) @@ " ^
2077 " Try (Rewrite_Set rat_reduce_1 False)))) @@ " ^
2078 " Try (Rewrite_Set discard_parentheses False)) " ^