intermed. Build_Inverse_Z_Transform:
got ambiguous parse trees from get_denominator in 2 theories ?!?
thus get_denominator shifted to Rational.thy
ATTENTION: "Rational.is'_ratpolyexp" has '
but get_denominator only works without '
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 "----------- get_denominator ----------------------------";
52 "--------------------------------------------------------";
53 "--------------------------------------------------------";
54 "--------------------------------------------------------";
57 "~~~~~BEGIN: decomment structure RationalI : RATIONALI ~~";
58 (*.~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
59 tests of internal functions: to make them work,
60 out-comment (*!!!*) in knowledge/Rational.ML:
62 structure RationalI : RATIONALI =
69 !!!##*)~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~.*)
71 "-------- ... missing WN060103 --------------------------";
72 "-------- ... missing WN060103 --------------------------";
73 "-------- ... missing WN060103 --------------------------";
74 (*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
75 writeln ("********************* rational.sml - TESTS *************************");
76 writeln ("***** divide tests *****");
77 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_)));
78 (* result: [(1,[0,0,1]),(1,[0,0,0])] *)
79 if mv_pquot1=[(1,[0,0,1]),(1,[0,0,0])] then () else error ("rational.sml: example failed");
81 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_)));
82 (* result: [(1,[1,0,1]),(~1,[0,0,1])] *)
83 if mv_prest1=[(1,[1,0,1]),(~1,[0,0,1])] then () else error ("rational.sml: example failed");
85 val mv_pquot2 = (#1(mv_division([(4,[2]),(8,[1]),(16,[0])],[(1,[1]),(1,[0])],LEX_)));
86 (* result: [(4,[1]),(4,[0])] *)
87 if mv_pquot2=[(4,[1]),(4,[0])] then () else error ("rational.sml: example failed");
89 val mv_prest2 = (#2(mv_division([(4,[2]),(8,[1]),(16,[0])],[(1,[1]),(1,[0])],LEX_)));
90 (* result: [(12,[0]] *)
91 if mv_prest2=[(12,[0])] then () else error ("rational.sml: example failed");
93 val mv_pquot3 = (#1(mv_division([(4,[2]),(~4,[0])],[(2,[1]),(2,[0])],LEX_)));
94 (* [(2,[1]),(~2,[0])] *)
95 if mv_pquot3=[(2,[1]),(~2,[0])] then () else error ("rational.sml: example failed");
97 val mv_prest3 = (#2(mv_division([(1,[2]),(~1,[0])],[(2,[1]),(2,[0])],LEX_)));
98 (* [(1,[2]),(~1,[0])] *)
99 if mv_prest3=[(1,[2]),(~1,[0])] then () else error ("rational.sml: example failed");
101 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_)));
103 if mv_pquot4=[(1,[0,1,1])] then () else error ("rational.sml: example failed");
105 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_)));
106 (* [(1,[1,1,1]),(~4,[0,1,2]),(4,[1,0,1]),(3,[0,0,1])] *)
107 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");
109 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_)));
110 (* [(1,[2,2,0]),(6,[2,1,2]),(3,[1,1,0]),(4,[1,0,0]),(4,[0,4,0]),(3,[0,0,0])]*)
111 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");
113 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_)));
115 if mv_prest5=[] then () else error ("rational.sml: example failed");
117 (* (x^2 + 2(a+1)x + (a^2+2a+1)) / (x+a+1) = x+a+1 *)
118 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_)));
119 if mv_pquot6=[(1,[1,0,0]),(1,[0,1,0]),(1,[0,0,0])] then () else error ("rational.sml: example failed");
121 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_)));
122 if mv_prest6=[] then () else error ("rational.sml: example failed");
125 writeln ("***** MV_CONTENT-TESTS *****");
126 val mv_cont1=mv_content([(1,[2,1]),(1,[2,0]),(1,[1,1]),(1,[1,0]),(1,[0,1]),(1,[0,0])]);
127 (* [(1,[0,1]),(1,[0,0])] *)
128 if mv_cont1=[(1,[0,1]),(1,[0,0])] then () else error ("rational.sml: example failed");
130 val mv_pp1=mv_pp([(1,[1,1]),(1,[1,0]),(1,[0,1]),(1,[0,0])]);
131 (*[(1,[1,0]),(1,[0,0])]*)
132 if mv_pp1=[(1,[1,0]),(1,[0,0])] then () else error ("rational.sml: example failed");
134 val mv_cont2=mv_content([(2,[1]),(4,[0])]);
136 if mv_cont2=[(2,[0])] then () else error ("rational.sml: example failed");
138 val mv_pp2=mv_pp([(2,[1]),(4,[0])]);
139 (* [(1,[1]),(2,[0])] *)
140 if mv_pp2=[(1,[1]),(2,[0])] then () else error ("rational.sml: example failed");
142 val mv_cont3=mv_content[(8,[2,1,1]),(12,[1,0,2]),(10,[2,2,0]),(16,[1,1,1])];
144 if mv_cont3=[(2,[0,0,0])] then () else error ("rational.sml: example failed");
146 val mv_pp3=mv_pp[(8,[2,1,1]),(12,[1,0,2]),(10,[2,2,0]),(16,[1,1,1])];
147 (* [(5,[2,2,0]),(4,[2,1,1]),(8,[1,1,1]),(6,[1,0,2])] *)
148 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");
150 val mv_cont4=mv_content[(2,[2,1,0]),(3,[1,0,1]),(2,[1,1,0]),(3,[0,0,1])];
152 if mv_cont4=[(1,[0,0,0])] then () else error ("rational.sml: example failed");
154 val mv_pp4=mv_pp [(2,[2,1,0]),(3,[1,0,1]),(2,[1,1,0]),(3,[0,0,1])];
155 (* [(2,[2,1,0]),(2,[1,1,0]),(3,[1,0,1]),(3,[0,0,1])] *)
156 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");
158 val con1=mv_content([(9,[2,0]),(15,[1,1]),(12,[1,0]),(6,[0,2]),(12,[0,1])]);
160 if con1=[(3,[0,0])] then () else error ("rational.sml: example failed");
162 val pp1=mv_pp([(9,[2,0]),(15,[1,1]),(12,[1,0]),(6,[0,2]),(12,[0,1])]);
163 (* [(3,[2,0]),(5,[1,1]),(4,[1,0]),(2,[0,2]),(4,[0,1])] *)
164 if pp1=[(3,[2,0]),(5,[1,1]),(4,[1,0]),(2,[0,2]),(4,[0,1])] then () else error ("rational.sml: example failed");
166 val con2=mv_content([(1,[2,0]),(1,[1,1]),(1,[1,0]),(1,[0,2]),(1,[0,1])]);
168 if con2=[(1,[0,0])] then () else error ("rational.sml: example failed");
170 val pp2 =mv_pp([(1,[2,0]),(1,[1,1]),(1,[1,0]),(1,[0,2]),(1,[0,1])]);
171 (* [(1,[2,0]),(1,[1,1]),(1,[1,0]),(1,[0,2]),(1,[0,1])] *)
172 if pp2=[(1,[2,0]),(1,[1,1]),(1,[1,0]),(1,[0,2]),(1,[0,1])] then () else error ("rational.sml: example failed");
174 val cont1 = mv_content [(1,[2,1,0]),(2,[2,1,0])];
176 if cont1=[(3,[0,1,0])] then () else error ("rational.sml: example failed");
178 val pp1 = mv_pp [(1,[2,1,0]),(2,[2,1,0])];
180 if pp1=[(1,[2,0,0])] then () else error ("rational.sml: example failed");
182 val cont2 = mv_content [(4,[1,2,0]),(2,[2,1,0])];
184 if cont2=[(2,[0,1,0])] then () else error ("rational.sml: example failed");
186 val pp2 = mv_pp [(4,[1,2,0]),(2,[2,1,0])];
187 (* [(1,[2,0,0]),(2,[1,1,0])] *)
188 if pp2=[(1,[2,0,0]),(2,[1,1,0])] then () else error ("rational.sml: example failed");
190 writeln ("********************************************************");
191 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])];
192 if cont3=[(5,[0,2,1]),(4,[0,2,0]),(2,[0,1,1])] then () else error ("rational.sml: example failed");
193 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])];
196 "-------- fun monom2term, fun poly2term' ---------------";
197 "-------- fun monom2term, fun poly2term' ---------------";
198 "-------- fun monom2term, fun poly2term' ---------------";
199 val t = monom2term ((3,[2,1,0]), ["c","b","a"](*reverse ???SK-*));
200 term2str t = "3 * (c ^^^ 2 * b)" (*true*);
202 val t = monom2term ((1,[1,0]), ["b","a"]);
203 term2str t = "b" (*true*);
205 val t = poly2term ([(1,[0,0,0]),(2,[1,0,0]),(3,[2,1,0]),(4,[3,2,1])],
207 term2str t = "1 + 2 * c + 3 * (c ^^^ 2 * b) + 4 * (c ^^^ 3 * (b ^^^ 2 * a))";
209 val t = poly2term ([(1,[1,0]),(1,[0,1])], ["b","a"]);
210 term2str t = "a + b" (*true*);
212 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*)
213 "~~~~~END: decomment structure RationalI : RATIONALI ~~~~";
214 "~~~~~END: decomment structure RationalI : RATIONALI ~~~~";
215 "~~~~~END: decomment structure RationalI : RATIONALI ~~~~";
218 fun parse_rat str = (term_of o the o (parse thy)) str;
220 writeln ("***** mv_gcd-tests *****");
221 val ggt1 = mv_gcd [(4,[2,2]),(8,[1,1]),(4,[0,0])] [(2,[1,1]),(2,[0,0])];
222 (* [(2,[1,1]),(2,[0,0])] *)
223 if ggt1=[(2,[1,1]),(2,[0,0])] then () else error ("rational.sml: example failed");
225 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])];
226 (* [(2,[1,1,0]),(3,[0,0,1])] *)
227 if ggt2=[(2,[1,1,0]),(3,[0,0,1])] then () else error ("rational.sml: example failed");
230 val ggt3 = mv_gcd [(1,[2,0]),(~2,[1,1]),(1,[0,2])] [(1,[1,0]),(~1,[0,1])];
231 (* [(1,[1,0]),(~1,[0,1])] *)
232 if ggt3=[(1,[1,0]),(~1,[0,1])] then () else error ("rational.sml: example failed");
235 val ggt4 = mv_gcd [(1,[2,1,0]),(2,[2,1,0])] [(5,[1,0,0])];
237 if ggt4=[(1,[1,0,0])] then () else error ("rational.sml: example failed");
240 val ggt5 = mv_gcd [(4,[2,0]),(~8,[1,1]),(4,[0,2])] [(1,[2,0]),(~1,[0,2])];
241 (* [(1,[1,0]),(~1,[0,1])] *)
242 if ggt5=[(1,[1,0]),(~1,[0,1])] then () else error ("rational.sml: example failed");
245 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])];
247 if ggt6=[(1,[1,0,0])] then () else error ("rational.sml: example failed");
249 writeln ("***** kgv-tests *****");
250 val kgv1=mv_lcm [(10,[])] [(15,[])];
252 if kgv1=[(30,[])] then () else error ("rational.sml: example failed");
254 val kgv2=mv_lcm [(1,[2,0]),(~2,[1,1]),(1,[0,2])] [(1,[1,0]),(~1,[0,1])];
255 (* [(1,[2,0]),(~2,[1,1]),(1,[0,2])] *)
256 if kgv2=[(1,[2,0]),(~2,[1,1]),(1,[0,2])] then () else error ("rational.sml: example failed");
258 val kgv3=mv_lcm [(4,[2,0]),(~8,[1,1]),(4,[0,2])] [(1,[2,0]),(~1,[0,2])];
259 (* [(4,[3,0]),(~4,[2,1]),(~4,[1,2]),(4,[0,3])] *)
260 if kgv3=[(4,[3,0]),(~4,[2,1]),(~4,[1,2]),(4,[0,3])] then () else error ("rational.sml: example failed");
263 writeln ("***** STEP_CANCEL_TESTS: *****");
265 val term2 = (term_of o the o (parse thy)) " (9 * a^^^2 * b) / (6 * a * c)";
266 val div2 = term2str (step_cancel term2);
267 if div2 = "3 * (a * b) * (3 * a) / (2 * c * (3 * a))" then () else error ("rational.sml: example failed");
270 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";
271 val div1 = term2str(step_cancel term1);
272 if div1 = "(3 * c + 14 * b + 20 * (b ^^^ 2 * c) + 10 * (a * (b * c))) * a / (1 * a)" then () else error ("rational.sml: example failed");
274 val term3 = (term_of o the o (parse thy)) "(10 * a^^^2 * b * c) / (1 * x * y * z) ";
275 val div3 = term2str(step_cancel term3);
276 if div3="10 * a ^^^ 2 * b * c / (1 * x * y * z)" then () else error ("rational.sml: example failed");
278 --------------------------------------------------------------------------!!!*)
280 (*-----versuche 13.3.03-----
281 val t = str2term "1 - x^^^2 - 5 * x^^^5";
282 val vs=(((map free2str) o vars) t);
283 val SOME ml = expanded2poly t vs;
285 poly2term'(rev(sort (mv_geq LEX_) (ml)),vs);
286 poly2term'([(~5,[5]),(~1,[2]),(1,[0])], vs);
287 monom2term((~5,[5]),vs);
288 monom2term((~1,[2]),vs);
289 val t' = monom2term((1,[0]),vs);(*uncaught exception LIST*)
291 val (i,is) = (~1,[2]);
292 val ttt = Const ("Groups.times_class.times", [HOLogic.realT,HOLogic.realT]---> HOLogic.realT) $
293 (Const ("uminus", HOLogic.realT --> HOLogic.realT) $
294 Free ((str_of_int o abs) i, HOLogic.realT)) $
295 powerproduct2term(is, vs);
297 -------versuche 13.3.03-----*)
299 val t = str2term "1 - x^^^2 - 5 * x^^^5";
300 val SOME t' = expanded2polynomial t; term2str t';
301 "1 + - 1 * x ^^^ 2 + - 5 * x ^^^ 5";
302 val t = str2term "1 - x";
303 val SOME t' = expanded2polynomial t; term2str t';
305 val t = str2term "1 + (-1) * x";
306 val SOME t' = expanded2polynomial t; term2str t';
308 val t = (term_of o the o (parse thy)) "1 + (-1) * x ^^^ 2 + (-5) * x ^^^5";
309 val SOME t' = polynomial2expanded t; term2str t';
310 "1 - x ^^^ 2 - 5 * x ^^^ 5";
313 "-------- external calculating functions test -----------";
314 "-------- external calculating functions test -----------";
315 "-------- external calculating functions test -----------";
316 val t1 = (term_of o the o (parse thy)) "((3 * x^^^2 + 6 *x + 3) / (2*x + 2))";
317 val SOME (t1',asm)= factout_p_ thy t1;
318 term2str t1'; terms2str asm;
319 "(3 + 3 * x) * (1 + 1 * x) / (2 * (1 + 1 * x))";
321 val SOME (t1',asm)= cancel_p_ thy t1;
322 term2str t1'; terms2str asm;
324 "[\"1 + 1 * x ~= 0\"]";
326 val t = (term_of o the o (parse thy)) "((-3 * x^^^2 + 6 *x - 3) / (2*x - 2))";
327 val SOME (t',asm)= cancel_ thy t;
328 term2str t'; terms2str asm;
331 val SOME (t',asm)= factout_ thy t;
332 term2str t'; terms2str asm;
333 "(3 - 3 * x) * (-1 + x) / (2 * (-1 + x))";
336 val t = str2term "((x+ (-1)) / (x + 1)) + ((x + 1) / (x + (-1)))";
337 val SOME (t',asm) = add_fraction_p_ thy t;
338 term2str t'; terms2str asm;
339 "(2 + 2 * x ^^^ 2) / (-1 + 1 * x ^^^ 2)";
341 val SOME (t',asm) = common_nominator_p_ thy t;
342 term2str t'; terms2str asm;
343 "(-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))";
346 val t = str2term "((x - 1) / (x + 1)) + ((x + 1) / (x - 1))";
347 val SOME (t',asm) = add_fraction_ thy t;
348 term2str t'; terms2str asm;
349 "(2 + 2 * x ^^^ 2) / (-1 + x ^^^ 2)";
351 val SOME (t',asm) = common_nominator_ thy t;
352 term2str t'; terms2str asm;
353 "(-1 + x) * (-1 + x) / ((1 + x) * (-1 + x)) +\n(1 + x) * (1 + x) / ((1 + x) * (-1 + x))";
356 val t = str2term "((1) / (2*x + 2)) + ((1) / (2*x + (-2))) + ((1) / ( x^^^2 + (-1)))+((1) / (x^^^2 + (-2)*x + 1))";
357 val SOME (t',asm) = common_nominator_p_ thy t;
358 term2str t'; terms2str asm;
359 "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 * (#";
361 val SOME (t',asm) = add_fraction_p_ thy t;
362 term2str t'; terms2str asm;
363 "1 * x / (1 + -2 * x + 1 * x ^^^ 2)";
364 "[\"1 + 1 * x ~= 0\"]";
365 val SOME(t',asm) = norm_rational_ thy t;
366 term2str t'; terms2str asm;
367 "1 * x / (1 + -2 * x + 1 * x ^^^ 2)";
368 "[\"1 + 1 * x ~= 0\"]";
370 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))";
371 val SOME (t3',_) = common_nominator_ thy t3;
372 val SOME (t3'',_) = add_fraction_ thy t3;
376 val SOME(t4,t5) = norm_expanded_rat_ thy t3;
382 val t=(term_of o the o (parse thy)) "(9 - x^^^2)/(9 - 6*x + x^^^2)";
383 val SOME (t',_) = factout_ thy t;
384 val SOME (t'',_) = cancel_ thy t;
387 "(3 + x) * (3 - x) / ((3 - x) * (3 - x))";
390 val t=(term_of o the o (parse thy))
391 "(9 - x^^^2) / (9 - 6*x + x^^^2) + 1 / (3 - x)";
392 val SOME (t',_) = common_nominator_ thy t;
393 val SOME (t'',_) = add_fraction_ thy t;
396 "(9 - x ^^^ 2) / ((3 - x) * (3 - x)) + 1 * (3 - x) / ((3 - x) * (3 - x))";
399 (*WN021016 added -----vv---*)
400 val t = str2term "(9 - x^^^2) / (9 - 6*x + x^^^2) + 1";
401 val SOME (t',_) = common_nominator_ thy t;
402 val SOME (t'',_) = add_fraction_ thy t;
403 term2str t' = "(9 - x ^^^ 2) / (9 - 6 * x + x ^^^ 2) +\n1" ^
404 " * (9 - 6 * x + x ^^^ 2) / (9 - 6 * x + x ^^^ 2)" (*true*);
405 term2str t'' = "6 / (3 - x)" (*true*);
407 val t = str2term "1 + (9 - x^^^2) / (9 - 6*x + x^^^2)";
408 val SOME (t',_) = common_nominator_ thy t;
409 val SOME (t'',_) = add_fraction_ thy t;
410 term2str t' = "1 * (9 - 6 * x + x ^^^ 2) / (9 - 6 * x + x ^^^ 2) +\n" ^
411 "(9 - x ^^^ 2) / (9 - 6 * x + x ^^^ 2)" (*true*);
412 term2str t'' = "6 / (3 - x)" (*true*);
413 (*WN021016 added -----^^---*)
414 (*WN030602 added -----vv--- no rewrite -> NONE !*)
415 val t = str2term "1 / a";
416 val NONE = cancel_p_ thy t;
417 val NONE = rewrite_set_ thy false cancel_p t;
418 (*WN.2.6.03 added -------^^---*)
420 val t = str2term "(y^^^2 - x^^^2)/(y^^^2 - 2*y*x + x^^^2)";
421 val SOME (t',_) = factout_ thy t;
422 val SOME (t'',_) = cancel_ thy t;
423 term2str t' = "(y + x) * (y - x) / ((y - x) * (y - x))"(*true*);
424 term2str t'' = "(y + x) / (y - x)";
426 val t = str2term "(y^^^2 - x^^^2)/(y^^^2 - 2*y*x + x^^^2) + 1 / (y - x)";
427 val SOME (t',_) = common_nominator_ thy t;
428 val SOME (t'',_) = add_fraction_ thy t;
430 "(-1 * x ^^^ 2 + y ^^^ 2) / ((-1 * x + y) * (-1 * x + y)) +\n1" ^
431 " * (-1 * x + y) / ((-1 * x + y) * (-1 * x + y))" (*true*);
432 term2str t'' = "(-1 - x - y) / (x - y)" (*true*);
434 val t = str2term "(x^^^2 - y^^^2)/(x^^^2 - 2*x*y + y^^^2) + 1 / (x - y)";
435 val SOME (t',_) = common_nominator_ thy t;
436 val SOME (t'',_) = add_fraction_ thy t;
437 if term2str t' = "(-1 * y ^^^ 2 + x ^^^ 2) / ((-1 * y + x) * (-1 * y + x))" ^
438 " +\n1 * (-1 * y + x) / ((-1 * y + x) * (-1 * y + x))" then ()
439 else error "rational.sml lex-ord 1";
440 if term2str t'' = "(-1 - y - x) / (y - x)" then ()
441 else error "rational.sml lex-ord 2";
442 (*WN.16.10.02 WN070905 lexicographische Ordnung erhalten ! SK.ord*)
445 val t = str2term "(x^^^2 - y^^^2)/(x^^^2 - 2*x*y + y^^^2)";
446 val SOME (t',_) = norm_expanded_rat_ thy t;
447 if term2str t' = "(x + y) / (x - y)" then ()
448 else error "rational.sml term2poly: invalid x ^^^ 2 - y ^^^ 2 No.1";
449 (*val SOME (t'',_) = norm_rational_ thy t;
450 *** RATIONALS_TERM2POLY_EXCEPTION: Invalid Polynomial
451 WN.16.10.02 ?! + WN060831???SK4
452 WN070905 *** term2poly: invalid = x ^^^ 2 - y ^^^ 2*)
455 val t = str2term "(9 - x^^^2)/(9 - 6*x + x^^^2) + (1)/(3 + x)";
456 val SOME (t',_) = norm_expanded_rat_ thy t;
457 if term2str t' = "(12 + 5 * x + x ^^^ 2) / (9 - x ^^^ 2)" then ()
458 else error "rational.sml (9 - x^^^2)/(9 - 6*x + x^^^2) +...";
459 (*val SOME (t'',_) = norm_rational_ thy t;
460 *** RATIONALS_TERM2POLY_EXCEPTION: Invalid Polynomial WN.16.10.02 ?!
461 WN070906 *** term2poly: invalid = 9 - x ^^^ 2 SK.term2poly*)
463 val t=(term_of o the o (parse thy))
464 "(9 + (-1)* x^^^2)/(9 + (-1)* 6*x + x^^^2) + (1)/(3 + x)";
465 val SOME (t',_) = norm_expanded_rat_ thy t;
466 val SOME (t'',_) = norm_rational_ thy t;
469 "(12 + 5 * x + x ^^^ 2) / (9 - x ^^^ 2)";
470 "(12 + 5 * x + x ^^^ 2) / (9 + (-1) * x ^^^ 2)";
473 "-------- cancel from: Mathematik 1 Schalk Reniets Verlag";
474 "-------- cancel from: Mathematik 1 Schalk Reniets Verlag";
475 "-------- cancel from: Mathematik 1 Schalk Reniets Verlag";
476 val thy = @{theory "Rational"};
477 val thy' = "Rational";
479 val mp = "make_polynomial";
481 writeln ("example 186:");
483 val e186a'="(14 * x * y) / ( x * y )";(*SRC*)
484 rewrite_set_ thy false cancel (str2term e186a');
486 val e186a = the (rewrite_set thy' false "cancel" e186a');
487 is_expanded (parse_rat "14 * x * y");
488 is_expanded (parse_rat "x * y");
489 if e186a = ("14 / 1", "[\"y * x ~= 0\"]") then ()
490 else error "rational.sml cancel Schalk e186a";
493 val e186b'="(60 * a * b) / ( 15 * a * b )";
494 val e186b = the (rewrite_set thy' false "cancel" e186b');
496 val e186c'="(144 * a^^^2 * b * c) / (12 * a * b * c )";
497 val e186c = (the (rewrite_set thy' false "cancel" e186c'))
498 handle e => print_exn_G e;
499 val t = (term_of o the o (parse thy)) e186c';
500 if e186c = ("12 * a / 1", "[\"12 * (c * (b * a)) ~= 0\"]") then ()
501 else error "rational.sml cancel Schalk e186c";
503 writeln ("example 187:");
505 val e187a'="(12 * x * y) / (8 * y^^^2 )";(*SRC*)
506 val e187a = the (rewrite_set thy' false "cancel" e187a');
508 val e187b'="(8 * x^^^2 * y * z ) / (18 * x * y^^^2 * z )";
509 val e187b = the (rewrite_set thy' false "cancel" e187b');
511 val e187d'="(9 * x^^^5 * y^^^2 * z^^^4) / (15 * x^^^6 * y^^^3 * z )";(*SRC*)
512 val e187d = the (rewrite_set thy' false "cancel" e187d');
513 if e187d = ("3 * z ^^^ 3 / (5 * (y * x))",
514 "[\"3 * (z * (y ^^^ 2 * x ^^^ 5)) ~= 0\"]") then ()
515 else error "rational.sml cancel Schalk e186d";
517 writeln "example 188:";
518 val e188a'="(-8 + 8 * x) / (-9 + 9 * x)";(*SRC*)
519 val e188a = the (rewrite_set thy' false "cancel" e188a');
520 is_expanded (parse_rat "8 * x + -8");
521 (* e188a = ("8 / 9",["not ((-1) + x = 0)"]) then () 13.3.03*)
522 if e188a = ("8 / 9", "[\"-1 + x ~= 0\"]") then ()
523 else error "rational.sml: e188a new behaviour";
525 val SOME (t,_) = rewrite_set thy' false mp "(8*((-1) + x))/(9*((-1) + x))";
527 val e188b'="(-15 + 5 * x) / (-18 + 6 * x)";(*SRC*)
528 val SOME (t, asm) = rewrite_set thy' false "cancel" e188b';
529 t = "5 / 6" (*true*);
532 val e188c'="( a + -1 * b ) / ( b + -1 * a )";
533 val e188c = the (rewrite_set thy' false "cancel_p" e188c');
534 (*is_expanded (parse_rat "a + -1 * b");*)
536 rewrite_set thy' false mp "((-1)*(b + (-1) * a))/(1*(b + (-1) * a))";
537 if t= "(a + -1 * b) / (-1 * a + b)" then()
538 else error "rational.sml: e188c new behaviour";
540 writeln ("example 190:");
542 val e190c'="( 27 * a^^^3 + 9 * a^^^2 + 3 * a + 1 ) / ( 27 * a^^^3 + 18 * a^^^2 + 3 * a )";
543 val e190c = the (rewrite_set thy' false "cancel" e190c');
544 val SOME (t,_) = rewrite_set thy' false mp "((1 + 9 * a ^^^ 2)*(1 + 3 * a))/((3 * a + 9 * a ^^^ 2)*(1 + 3 * a))";
545 if t = "(1 + 3 * a + 9 * a ^^^ 2 + 27 * a ^^^ 3) /\n(3 * a + 18 * a ^^^ 2 + 27 * a ^^^ 3)" then ()
546 else error "rational.sml: e190c new behaviour";
548 writeln ("example 191:");
550 val e191a'="( x^^^2 + -1 * y^^^2 ) / ( x + y )";
552 val e191a = the (rewrite_set thy' false "cancel" e191a');
553 is_expanded (parse_rat "x^^^2 + -1 * y^^^2");
555 is_expanded (parse_rat "x + y");
557 val SOME (t,_) = rewrite_set thy' false mp "((x + (-1) * y)*(x + y))/((1)*(x + y))";
558 (* t="(x ^^^ 2 + -1 * y ^^^ 2) / (x + y)" then() WN.13.3.03*)
559 if t="(x ^^^ 2 + -1 * y ^^^ 2) / (x + y)" then()
560 else error "rational.sml: e191a new behaviour";
563 val e191c'="( 9 * x^^^2 + -30 * x + 25 ) / ( 9 * x^^^2 + -25 )";
565 val e191c = the (rewrite_set thy' false "cancel" e191c');
566 is_expanded (parse_rat "9 * x^^^2 + -30 * x + 25");
568 is_expanded (parse_rat "25 + -30*x + 9*x^^^2");
570 is_expanded (parse_rat "-25 + 9*x^^^2");
572 val SOME (t,_) = rewrite_set thy' false mp "(((-5) + 3 * x)*((-5) + 3 * x))/((5 + 3 * x)*((-5) + 3 * x))";
573 (* t="(25 + ((-30) * x + 9 * x ^^^ 2)) / ((-25) + 9 * x ^^^ 2)"then() 13.3.03*)
574 if t= "(25 + -30 * x + 9 * x ^^^ 2) / (-25 + 9 * x ^^^ 2)" then()
575 else error "rational.sml: 'e191c' new behaviour";
578 writeln ("example 192:");
580 val e192b'="( 7 * x^^^3 + -1 * x^^^2 * y ) / ( 7 * x * y^^^2 + -1 * y^^^3 )";
582 val e192b = the (rewrite_set thy' false "cancel" e192b');
583 -------------------*)
584 val SOME (t',_) = rewrite_set thy' false mp "((x ^^^ 2)*(7 * x + (-1) * y))/((y ^^^ 2)*(7 * x + (-1) * y))";
585 (*========== inhibit exn 110317 ================================================
586 if t' = "(7 * x ^^^ 3 + -1 * x ^^^ 2 * y) / (7 * x * y ^^^ 2 + -1 * y ^^^ 3)"
587 (*"(-1 * y * x ^^^ 2 + 7 * x ^^^ 3) / (-1 * y ^^^ 3 + 7 * x * y ^^^ 2)"WN050929*)
588 then () else error "rational.sml: 'e192b' new behaviour";
589 (*^^^ works with MG's simplifier vvv*)
590 val t =str2term"((x ^^^ 2)*(7 * x + (-1) * y))/((y ^^^ 2)*(7 * x + (-1) * y))";
591 val SOME (t',_) = rewrite_set_ thy false make_polynomial t;
592 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";
593 ============ inhibit exn 110317 ==============================================*)
595 writeln ("example 193:");
597 val e193a'="( x^^^2 + -6 * x + 9 ) / ( x^^^2 + -9 )";
599 val e193a = the (rewrite_set thy' false "cancel" e193a');
600 -------------------*)
602 val e193b'="( x^^^2 + -8 * x + 16 ) / ( 2 * x^^^2 + -32 )";
604 val e193b = the (rewrite_set thy' false "cancel" e193b');
606 val e193c'="( 2 * x + -50 * x^^^3 ) / ( 25 * x^^^2 + -10 * x + 1 )";
607 val SOME(t,_) = rewrite_set thy' false "cancel" e193c';
608 -------------------*)
610 val wn01 = "(-25 + 9*x^^^2)/(5 + 3*x)";
611 val SOME (t, asm) = rewrite_set thy' false "cancel" wn01;
612 (* t = "((-5) + 3 * x) / 1" then () WN.13.3.03*)
613 if t = "(-5 + 3 * x) / 1" andalso asm = "[\"5 + 3 * x ~= 0\"]" then ()
614 else error "rational.sml: new behav. in cancel wn01";
616 "-------- common_nominator_p ----------------------------";
617 "-------- common_nominator_p ----------------------------";
618 "-------- common_nominator_p ----------------------------";
619 val rls' = "common_nominator_p";
621 writeln ("example 204:");
623 val e204a'="((5 * x) / 9) + ((3 * x) / 9) + (x / 9)";
624 val e204a = the (rewrite_set thy' false "common_nominator_p" e204a');
626 val e204b'="5 / x + -3 / x + -1 / x";
627 val e204b = the (rewrite_set thy' false "common_nominator_p" e204b');
628 if e204b = ("1 / x", "[]") then ()
629 else error "rational.sml common_nominator_p example e204b";
631 writeln ("example 205:");
633 val e205a'="((4 * x + 7) / 8) + ((4 * x + 3) / 8)";
634 val e205a = the (rewrite_set thy' false "common_nominator_p" e205a');
636 val e205b'="((5 * x + 2) / 3) + ((-2 * x + 1) / 3)";
637 val e205b = the (rewrite_set thy' false "common_nominator_p" e205b');
638 if e205b = ("(1 + x) / 1", "[]") then ()
639 else error "rational.sml common_nominator_p example e204b";
641 writeln ("example 206:");
643 val e206a'="((5 * x + 4) / (2 * x + -1)) + ((9 * x + 5) / (2 * x + -1))";
644 val e206a = the (rewrite_set thy' false "common_nominator_p" e206a');
646 val e206b'="((17 * x + -23) / (5 * x + 4)) + ((-25 + -17 * x) / (5 * x + 4))";
647 val e206b = the (rewrite_set thy' false "common_nominator_p" e206b');
649 writeln ("example 207:");
650 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)) ";
651 val e207 = the (rewrite_set thy' false "common_nominator_p" e207');
653 writeln ("example 208:");
654 val e208'="((3 * x + 2) / (x + 2)) + ((5 * x + -1) / (x + 2)) + ((-7 * x + -3) / (x + 2)) + ((-1 * x + -3) / (x + 2)) ";
655 val e208 = the (rewrite_set thy' false "common_nominator_p" e208');
657 writeln ("example 209:");
658 val e209'="((3 * x + -7 * y + 3 * z) / (4)) + ((2 * x + 17 * y + 10 * z) / (4)) + ((-1 * x + 2 * y + z) / (4)) ";
659 val e209 = the (rewrite_set thy' false "common_nominator_p" e209');
661 writeln ("example 210:");
662 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)) ";
663 val e210 = the (rewrite_set thy' false "common_nominator_p" e210');
665 writeln ("example 211:");
667 val e211a'="((b) / (a + -1 * b)) + ((-1 * a) / (a + -1 * b))";
668 val e211a = the (rewrite_set thy' false "common_nominator_p" e211a');
670 val e211b'="((b) / (b^^^2 + -1 * a^^^2)) + ((-1 * a) / (b^^^2 + -1 * a^^^2))";
671 val e211b = the (rewrite_set thy' false "common_nominator_p" e211b');
673 writeln ("example 212:");
675 val e212a'="((4) / (x)) + ((-3) / (y)) + -1";
676 val e212a = the (rewrite_set thy' false "common_nominator_p" e212a');
678 val e212b'="((4) / (x)) + ((-5) / (y)) + ((6) / (x*y))";
679 val e212b = the (rewrite_set thy' false "common_nominator_p" e212b');
681 writeln ("example 213:");
683 val e213a'="((5 * x) / (3 * y^^^2)) + ((19 * z) / (6 * x * y)) + ((-2 * x) / (3 * y^^^2)) + ((7 * y^^^2) / (6 * x^^^2)) ";
684 val e213a = the (rewrite_set thy' false "common_nominator_p" e213a');
686 val e213b'="((2 * b) / (3 * a^^^2)) + ((3 * c) / (7 * a * b)) + ((4 * b) / (3 * a^^^2)) + ((3 * a) / (7 * b^^^2))";
687 val e213b = the (rewrite_set thy' false "common_nominator_p" e213b');
689 writeln ("example 214:");
691 val e214a'="((3 * x + 2 * y + 2 * z) / (4)) + ((-5 * x + -3 * y) / (3)) + ((x + y + -2 * z) / (2))";
692 val e214a = the (rewrite_set thy' false "common_nominator_p" e214a');
694 val e214b'="((5 * x + 2 * y + z) / (2)) + ((-7 * x + -3 * y) / (3)) + ((3 * x + 6 * y + -1 * z) / (12))";
695 val e214b = the (rewrite_set thy' false "common_nominator_p" e214b');
697 writeln ("example 216:");
699 val e216a'="((2 * b + 3 * c) / (a * c)) + ((3 * a + b) / (a * b)) + ((-2 * b^^^2 + -3 * a * c) / (a * b * c))";
700 val e216a = the (rewrite_set thy' false "common_nominator_p" e216a');
702 val e216b'="((2 * a + 3 * b) / (b * c)) + ((3 * c + a) / (a * c)) + ((-2 * a^^^2 + -3 * b * c) / (a * b * c))";
703 val e216b = the (rewrite_set thy' false "common_nominator_p" e216b');
705 writeln ("example 217:");
706 val e217'="((z + -1) / (z)) + ((3 * z ^^^2 + -6 * z + 5) / (z^^^2)) + ((-4 * z^^^3 + 7 * z^^^2 + -5 * z + 5) / (z^^^3))";
707 val e217 = the (rewrite_set thy' false "common_nominator_p" e217');
710 val rls' = "common_nominator";
711 writeln ("example 218:");
712 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))";
713 val e218 = the (rewrite_set thy' false "common_nominator" e218');
714 if e218 = ("(16 - 63 * a ^^^ 2 - 81 * a ^^^ 3) / (108 * a ^^^ 4)", "[]") then ()
715 else error "rationa.sml common_nominator example e218";
717 writeln ("example 219:");
719 val e219a'="((1) / (y + 1)) + ((1) / (y + 2)) + ((1) / (y + 3))";
720 val e219a = the (rewrite_set thy' false "common_nominator" e219a');
722 val e219b'="((1) / (x + 1)) + ((1) / (x + 2)) + ((-2) / (x + 3))";
723 val e219b = the (rewrite_set thy' false "common_nominator" e219b');
724 if e219b = ("(5 + 3 * x) / (6 + 11 * x + 6 * x ^^^ 2 + x ^^^ 3)", "[]") then ()
725 else error "rationa.sml common_nominator example e219b";
727 writeln ("example 220:");
729 val e220a'="((17) / (5 * r + -2)) + ((-13) / (2 * r + 3)) + ((4) / (3 * r + -5))";
730 val e220a = the (rewrite_set thy' false "common_nominator" e220a');
732 val e220b'="((20 * a) / (a + -3)) + ((-19 * a) / (a + -4)) + ((a) / (a + -5))";
733 val e220b = the (rewrite_set thy' false "common_nominator" e220b');
735 writeln ("example 221:");
737 val e221a'="((a + b) / (a + -1 * b)) + ((a + -1 * b) / (a + b))";
738 val e221a = the (rewrite_set thy' false "common_nominator" e221a');
740 val e221b'="((x + -1 * y) / (x + y)) + ((x + y) / (x + -1 * y)) ";
741 val e221b = the (rewrite_set thy' false "common_nominator" e221b');
743 writeln ("example 222:");
745 val e222a'="((1 + -1 * x) / (1 + x)) + ((-1 + -1 * x) / (1 + -1 * x)) + ((4 * x) / (1 + -1 * x^^^2))";
746 val e222a = the (rewrite_set thy' false "common_nominator" e222a');
748 val e222b'="((1 + x ) / (1 + -1 * x)) + ((-1 + x) / (1 + x)) + ((2 * x) / (1 + -1 * x^^^2))";
749 val e222b = the (rewrite_set thy' false "common_nominator" e222b');
751 writeln ("example 225:");
753 val e225a'="((6 * a) / (a^^^2 + -64)) + ((a + 2) / (2 * a + 16)) + ((-1) / (2))";
754 val e225a = the (rewrite_set thy' false "common_nominator" e225a');
756 val e225b'="((a + 2 ) / (2 * a + 12)) + ((4 * a) / (a^^^2 + -36)) + ((-1) / (2))";
757 val e225b = the (rewrite_set thy' false "common_nominator" e225b');
759 writeln ("example 226:");
761 val e226a'="((35 * z) / (49 * z^^^2 + -4)) + -1 + ((14 * z + -1) / (14 * z + 4)) ";
762 val e226a = the (rewrite_set thy' false "common_nominator" e226a');
764 val e226b'="((45 * a * b) / (25 * a^^^2 + -9 * b^^^2)) + ((20 * a + 3 * b) / (10 * a + 6 * b)) + -2";
765 val e226b = the (rewrite_set thy' false "common_nominator" e226b');
767 writeln ("example 227:");
769 val e227a'="((6 * z + 11) / (6 * z + 14)) + ((9 * z ) / (9 * z^^^2 + -49)) + -1 ";
770 val e227a = the (rewrite_set thy' false "common_nominator" e227a');
772 val e227b'="((16 * a + 37 * b) / (4 * a + 10 * b)) + ((6 * a * b) / (4 * a^^^2 + -25 * b^^^2)) + -4 ";
773 val e227b = the (rewrite_set thy' false "common_nominator" e227b');
775 writeln ("example 228:");
777 val e228a'="((7 * a + 11) / (3 * a^^^2 + -3)) + ((-2 * a + -1) / (a^^^2 + -1 * a)) + ((-1) / (3 * a + 3))";
778 val e228a = the (rewrite_set thy' false "common_nominator" e228a');
780 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))";
781 val e228b = the (rewrite_set thy' false "common_nominator" e228b');
784 writeln ("example 229:");
786 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))";
787 val e229a = the (rewrite_set thy' false "common_nominator" e229a');
789 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))";
790 val e229b = the (rewrite_set thy' false "common_nominator" e229b');
792 writeln ("example 230:");
794 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))";
795 val e230a = the (rewrite_set thy' false "common_nominator" e230a');
797 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))";
798 val e230b = the (rewrite_set thy' false "common_nominator" e230b');
800 writeln ("example 231:");
802 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))";
803 val e231a = the (rewrite_set thy' false "common_nominator" e231a');
805 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))";
806 val e231b = the (rewrite_set thy' false "common_nominator" e231b');
808 writeln ("example 232:");
810 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))";
811 val e232a = the (rewrite_set thy' false "common_nominator" e232a');
813 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))";
814 val e232b = the (rewrite_set thy' false "common_nominator" e232b');
816 writeln ("example 233:");
818 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))";
819 val e233a = the (rewrite_set thy' false "common_nominator" e233a');
821 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))";
822 val e233b = the (rewrite_set thy' false "common_nominator" e233b');
824 writeln ("example 234:");
826 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))";
827 val e234a = the (rewrite_set thy' false "common_nominator" e234a');
829 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)) ";
830 val e234b = the (rewrite_set thy' false "common_nominator" e234b');
832 writeln ("example 235:");
834 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))";
835 val e235a = the (rewrite_set thy' false "common_nominator" e235a');
837 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)) ";
838 val e235b = the (rewrite_set thy' false "common_nominator" e235b');
840 writeln ("example 236:");
842 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))";
843 val e236a = the (rewrite_set thy' false "common_nominator" e236a');
845 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)) ";
846 val e236b = the (rewrite_set thy' false "common_nominator" e236b');
850 writeln ("example heuberger:");
851 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)";
852 val eheu = the (rewrite_set thy' false "cancel" eheu');
854 val rls' = "common_nominator_p";
855 writeln ("example stiefel:");
856 val est1'="(7) / (-14) + (-2) / (4)";
857 val est1 = the (rewrite_set thy' false "common_nominator_p" est1');
858 if est1 = ("-1 / 1", "[]") then ()
859 else error "new behaviour in rational.sml: est1'";
861 val t = (term_of o the o (parse thy))
862 "(9 - x ^^^ 2) / (9 - 6 * x + x ^^^ 2)";
863 val SOME (t',_) = factout_ thy t;
864 if term2str t' = "(3 + x) * (3 - x) / ((3 - x) * (3 - x))" then ()
865 else error "rational.sml factout_ (9 - x ^^^ 2) / (9 - 6 * x + x ^^^ 2)";
868 "-------- reverse rewrite -------------------------------";
869 "-------- reverse rewrite -------------------------------";
870 "-------- reverse rewrite -------------------------------";
871 (*WN.28.8.02: tests for the 'reverse-rewrite' functions:
872 these are defined in Rationals.ML and stored in
873 the 'reverse-ruleset' cancel*)
875 (*the term for which reverse rewriting is demonstrated*)
876 val t = (term_of o the o (parse thy))
877 "(9 - x ^^^ 2) / (9 + 6 * x + x ^^^ 2)";
878 val Rrls {scr=Rfuns {init_state=ini,locate_rule=loc,
879 next_rule=nex,normal_form=nor,...},...} = cancel;
881 (*normal_form produces the result in ONE step*)
882 val SOME (t',_) = nor t;
883 if term2str t' = "(3 - x) / (3 + x)" then ()
884 else error "rational.sml normal_form (9 - x ^^^ 2) / (9 - 6 * x + x ^^^ 2)";
886 (*initialize the interpreter state used by the 'me'*)
887 val (t,_,revsets,_) = ini t;
889 (*find the rule 'r' to apply to term 't'*)
890 val SOME (r as (Thm (str, thm))) = nex revsets t;
891 if str = "sym_#power_Float ((3,0), (0,0)) __ ((2,0), (0,0))"
892 andalso string_of_thm thm =
893 (string_of_thm o make_thm o (cterm_of (@{theory "Isac"})))
894 (Trueprop $ (term_of o the o (parse thy)) "9 = 3 ^^^ 2") then ()
895 else error "rational.sml next_rule (9 - x ^^^ 2) / (9 - 6 * x + x ^^^ 2)";
896 (* before Isa02->09-2 was not checked automatically, ?was different?:
897 val SOME r = nex revsets t;
898 val r = Thm ("sym_#mult_2_3","6 = 2 * 3") : rule*)
900 (* check, if the rule 'r' applied by the user to 't' belongs to the ruleset;
901 if the rule is OK, the term resulting from applying the rule is returned,too;
902 there might be several rule applications inbetween,
903 which are listed after the head in reverse order *)
904 val (r, (t, asm))::_ = loc revsets t r;
905 if term2str t = "(9 - x ^^^ 2) / (3 ^^^ 2 + 6 * x + x ^^^ 2)" andalso asm = []
907 else error "rational.sml locate_rule (9 - x ^^^ 2) / (9 - 6 * x + x ^^^ 2)";
909 (* find the next rule to apply *)
910 val SOME (r as (Thm (str, thm))) = nex revsets t;
911 if str = "sym_#power_Float ((3,0), (0,0)) __ ((2,0), (0,0))" andalso
912 string_of_thm thm = (string_of_thm o make_thm o (cterm_of (@{theory "Isac"})))
913 (Trueprop $ (term_of o the o (parse thy)) "9 = 3 ^^^ 2") then ()
914 else error "rational.sml next_rule (9 - x ^^^ 2) / (9 - 6 * x + x ^^^ 2)";
916 (*check the next rule*)
917 val (r, (t, asm)) :: _ = loc revsets t r;
918 if term2str t = "(3 ^^^ 2 - x ^^^ 2) / (3 ^^^ 2 + 6 * x + x ^^^ 2)" then ()
919 else error "rational.sml locate_rule (9 - x ^^^ 2) / (9 - 6 * x + x ^^^ 2) II";
921 (*find and check the next rules, rewrite*)
922 val SOME r = nex revsets t;
923 val (r,(t,asm))::_ = loc revsets t r;
924 if term2str t = "(3 ^^^ 2 - x ^^^ 2) / (3 ^^^ 2 + 2 * 3 * x + x ^^^ 2)" then ()
925 else error "rational.sml locate_rule II";
927 val SOME r = nex revsets t;
928 val (r,(t,asm))::_ = loc revsets t r;
929 if term2str t = "(3 - x) * (3 + x) / (3 ^^^ 2 + 2 * 3 * x + x ^^^ 2)" then ()
930 else error "rational.sml next_rule II";
932 val SOME r = nex revsets t;
933 val (r,(t,asm))::_ = loc revsets t r;
934 if term2str t = "(3 - x) * (3 + x) / ((3 + x) * (3 + x))" then ()
935 else error "rational.sml next_rule III";
937 val SOME r = nex revsets t;
938 val (r, (t, asm)) :: _ = loc revsets t r;
940 if ss = "(3 - x) / (3 + x)" andalso terms2str asm = "[\"3 + x ~= 0\"]" then ()
941 else error "rational.sml: new behav. in rev-set cancel";
943 "-------- 'reverse-ruleset' cancel_p --------------------";
944 "-------- 'reverse-ruleset' cancel_p --------------------";
945 "-------- 'reverse-ruleset' cancel_p --------------------";
946 (*WN.11.9.02: the 'reverse-ruleset' cancel_p*)
948 (*the term for which reverse rewriting is demonstrated*)
949 val t = str2term "(9 + (-1)*x^^^2) / (9 + ((-6)*x + x^^^2))";
950 val Rrls {scr=Rfuns {init_state=ini,locate_rule=loc,
951 next_rule=nex,normal_form=nor,...},...} = cancel_p;
953 (*normal_form produces the result in ONE step*)
954 val SOME (t',_) = nor t;
955 term2str t' = "(3 + 1 * x) / (3 + -1 * x)";
957 (*initialize the interpreter state used by the 'me'*)
958 val SOME (t', asm) = cancel_p_ thy t;
959 term2str t' = "(3 + x) / (3 + -1 * x)" (*true*);
960 terms2str asm = "[\"3 + -1 * x ~= 0\"]" (*true*);
961 val (t,_,revsets,_) = ini t;
963 (* WN.10.10.02: dieser Fall terminiert nicht
964 (make_polynomial enth"alt zu viele rules)
965 WN060823 'init_state' requires rewriting on specified location in the term
966 print_depth 99; Rfuns; print_depth 3;
967 WN060831 cycling "sym_order_mult_rls_" "sym_real_mult_assoc"
968 as was with make_polynomial before ?!?*)
970 val SOME r = nex revsets t;
971 eq_Thm (r, Thm ("sym_#power_Float ((3,0), (0,0)) __ ((2,0), (0,0))",
972 mk_thm thy "9 = 3 ^^^ 2"));
973 (*WN060831 *** id_of_thm
974 Exception- ERROR raised ...
975 val (r,(t,asm))::_ = loc revsets t r;
978 val SOME r = nex revsets t;
979 val (r,(t,asm))::_ = loc revsets t r;
983 writeln "****************** all tests successfull *************************";
987 (*WN.17.3.03 =========================================================vvv---*)
988 "-------- norm_Rational ---------------------------------";
989 "-------- norm_Rational ---------------------------------";
990 "-------- norm_Rational ---------------------------------";
991 val t = str2term "(3*x+5)/18 - x/2 - -(3*x - 2)/9 = 0";
992 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
993 if term2str t' = "1 / 18 = 0" then () else error "rational.sml 1";
995 val t = str2term "(17*x - 51)/9 - (-(13*x - 3)/6) + 11 - (9*x - 7)/4 = 0";
996 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
997 if term2str t' = "(237 + 65 * x) / 36 = 0" then ()
998 else error "rational.sml 2";
1000 val t = str2term "(1/2 + (5*x)/2)^^^2 - ((13*x)/2 - 5/2)^^^2 - (6*x)^^^2 + 29";
1001 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
1002 if term2str t' = "23 + 35 * x + -72 * x ^^^ 2" then ()
1003 else error "rational.sml 3";
1005 (*trace_rewrite:=true;*)
1006 val t = str2term "Not (6*x is_atom)";
1007 val SOME (t',_) = rewrite_set_ thy false powers_erls t; term2str t';
1009 val t = str2term "1 < 2";
1010 val SOME (t',_) = rewrite_set_ thy false powers_erls t; term2str t';
1013 val t = str2term "(6*x)^^^2";
1014 val SOME (t',_) = rewrite_ thy dummy_ord powers_erls false
1015 (num_str @{thm realpow_def_atom}) t;
1016 if term2str t' = "6 * x * (6 * x) ^^^ (2 + -1)" then ()
1017 else error "rational.sml powers_erls (6*x)^^^2";
1019 val t = str2term "-1 * (-2 * (5 / 2 * (13 * x / 2)))";
1020 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
1021 if term2str t' = "65 * x / 2" then () else error "rational.sml 4";
1023 val t = str2term "1 - ((13*x)/2 - 5/2)^^^2";
1024 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
1025 (*bef.040209: if term2str t' = "(-21 + (130 * x + -169 * x ^^^ 2)) / 4"then()*)
1026 if term2str t' = "(-21 + 130 * x + -169 * x ^^^ 2) / 4" then ()
1027 else error "rational.sml 5";
1029 (*SRAM Schalk I, p.92 Nr. 609a*)
1030 val t = str2term "2*(3 - x/5)/3 - 4*(1 - x/3) - x/3 - 2*(x/2 - 1/4)/27 +5/54";
1031 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
1032 if term2str t' = "(-255 + 112 * x) / 135" then ()
1033 else error "rational.sml 6";
1035 (*SRAM Schalk I, p.92 Nr. 610c*)
1036 val t = str2term "((x- 1)/(x+1) + 1) / ((x- 1)/(x+1) - (x+1)/(x- 1)) - 2";
1037 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
1038 if term2str t' = "(-3 + -1 * x) / 2" then () else error "rational.sml 7";
1040 (*SRAM Schalk I, p.92 Nr. 476a*)
1041 val t = str2term "(x^^^2/(1 - x^^^2) + 1)/(x/(1 - x) + 1) * (1 + x)";
1042 (*. a/b : c/d translated to a/b * d/c .*)
1043 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
1044 (*if term2str t' = "1 / 1" then () else error "rational.sml 8";3.6.03*)
1045 if term2str t' = "1" then () else error "rational.sml 8";
1047 (*............................vvv---TODO: sollte gehen mit poly_order *)
1048 (*Schalk I, p.92 Nr. 472a*)
1049 val t = str2term "((8*x^^^2 - 32*y^^^2)/(2*x + 4*y))/((4*x - 8*y)/(x + y))";
1050 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
1051 if term2str t' = "x + y" then () else error "rational.sml p.92 Nr. 472a";
1053 (*Schalk I, p.70 Nr. 480b; a/b : c/d translated to a/b * d/c*)
1054 val t = str2term ("((12*x*y/(9*x^^^2 - y^^^2))/" ^
1055 "(1/(3*x - y)^^^2 - 1/(3*x + y)^^^2)) *" ^
1056 "(1/(x - 5*y)^^^2 - 1/(x + 5*y)^^^2)/" ^
1057 "(20*x*y/(x^^^2 - 25*y^^^2))");
1058 (*... nicht simpl, zerlegt ...*)
1059 val t = str2term ("((12*x*y/(9*x^^^2 - y^^^2))/" ^
1060 "(1/(3*x - y)^^^2 - 1/(3*x + y)^^^2))");
1061 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
1062 "(-12 * (x * y ^^^ 3) + 108 * (x * (y * x ^^^ 2))) / (12 * (x * y))";
1063 (* ~~~~~~~~~~ poly_order notwendig!*)
1064 val t = str2term ("(1/(x - 5*y)^^^2 - 1/(x + 5*y)^^^2)/" ^
1065 "(20*x*y/(x^^^2 - 25*y^^^2))");
1066 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
1067 if term2str t' = "1 / (x ^^^ 2 + -25 * y ^^^ 2)" then ()
1068 else error "rational.sml norm_Rational 1 / (x ^^^ 2 + -25 * y ^^^ 2)";
1070 "nonterm.SK6 ----- SK060904-2a non-termination of add_fraction_p_";
1071 (*WN.2.6.03 from rlang.sml 56a
1072 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)";
1073 val NONE = rewrite_set_ thy false common_nominator_p t;
1075 WN060831 nonterm.SK7
1076 val t = str2term "(a + b * x) / (a + -1 * (b * x)) + (-1 * a + b * x) / (a + b * x)";
1077 val NONE = add_fraction_p_ thy t;
1081 (* ------------------------------------------------------------------- *)
1082 (*---------vvv------------ MG: ab 1.7.03 ----------------vvv-----------*)
1083 (* Simplifier fuer beliebige Buchterme *)
1084 (* ------------------------------------------------------------------- *)
1085 (*----------------------- norm_Rational_mg ----------------------------*)
1086 (* ------------------------------------------------------------------- *)
1088 "-------- numeral rationals -----------------------------";
1089 "-------- numeral rationals -----------------------------";
1090 "-------- numeral rationals -----------------------------";
1091 (*SRA Schalk I, p.40 Nr. 164b *)
1092 val t = str2term "(47/6 - 76/9 + 13/4)/(35/12)";
1093 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1095 if (term2str t) = "19 / 21" then ()
1096 else error "rational.sml: diff.behav. in norm_Rational_mg 1";
1098 (*SRA Schalk I, p.40 Nr. 166a *)
1099 val t = str2term "((5/4)/(4+22/7) + 37/20)*(110/3 - 110/9 * 23/11)";
1100 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1102 if (term2str t) = "45 / 2" then ()
1103 else error "rational.sml: diff.behav. in norm_Rational_mg 2";
1106 "-------- cancellation ----------------------------------";
1107 "-------- cancellation ----------------------------------";
1108 "-------- cancellation ----------------------------------";
1109 (* e190c Stefan K.*)
1111 "((1 + 9 * a ^^^ 2)*(1 + 3 * a))/((3 * a + 9 * a ^^^ 2)*(1 + 3 * a))";
1112 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1115 "(1 + 9 * a ^^^ 2) / (3 * a + 9 * a ^^^ 2)"
1117 else error "rational.sml: diff.behav. in norm_Rational_mg 3";
1119 (* e192b Stefan K.*)
1121 "((x ^^^ 2)*(7 * x + (-1) * y))/((y ^^^ 2)*(7 * x + (-1) * y))";
1122 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1127 else error "rational.sml: diff.behav. in norm_Rational_mg 4";
1129 (*SRC Schalk I, p.66 Nr. 379c *)
1132 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1137 else error "rational.sml: diff.behav. in norm_Rational_mg 5";
1139 (*SRC Schalk I, p.66 Nr. 380b *)
1141 "15*(3*x+3)*(4*x+9)/(12*(2*x+7)*(5*x+5))";
1142 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1145 "(27 + 12 * x) / (28 + 8 * x)"
1147 else error "rational.sml: diff.behav. in norm_Rational_mg 6";
1149 (*Schalk I, p.60 Nr. 215c *)
1150 (* Falsches Ergebnis: rechnet lange und cancel_p kann nicht weiter krzen!!!*)
1152 val t = str2term "(a+b)^^^4*(x - y)/((x - y)^^^3*(a+b)^^^2)";
1153 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1156 "(a ^^^ 4 * x + -1 * a ^^^ 4 * y + 4 * a ^^^ 3 * b * x + -4 * a ^^^ 3 * b * y + 6 * a ^^^ 2 * b ^^^ 2 * x + -6 * a ^^^ 2 * b ^^^ 2 * y + 4 * a * b ^^^ 3 * x + -4 * a * b ^^^ 3 * y + b ^^^ 4 * x + -1 * b ^^^ 4 * y) /(a ^^^ 2 * x ^^^ 3 + -3 * a ^^^ 2 * x ^^^ 2 * y + 3 * a ^^^ 2 * x * y ^^^ 2 + -1 * a ^^^ 2 * y ^^^ 3 + 2 * a * b * x ^^^ 3 + -6 * a * b * x ^^^ 2 * y + 6 * a * b * x * y ^^^ 2 + -2 * a * b * y ^^^ 3 + b ^^^ 2 * x ^^^ 3 + -3 * b ^^^ 2 * x ^^^ 2 * y + 3 * b ^^^ 2 * x * y ^^^ 2 + -1 * b ^^^ 2 * y ^^^ 3)"
1158 else error "rational.sml: diff.behav. in norm_Rational_mg 7";
1161 "(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)"
1162 val SOME (t,_) = rewrite_set_ thy false cancel_p t;
1164 (* uncaught exception nonexhaustive binding failure
1165 raised at: stdIn:93.1-93.51 *)
1167 (*Schalk I, p.66 Nr. 381a *)
1168 (* ACHTUNG: rechnet ca. 2 Minuten !!! *)
1170 val t = str2term "18*(a+b)^^^3*(a - b)^^^2/(72*(a - b)^^^3*(a+b)^^^2)";
1171 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1174 "(a + b) / (4 * a + -4 * b)"
1175 then () else error "rational.sml: diff.behav. in norm_Rational_mg 8";
1178 (*SRC Schalk I, p.66 Nr. 381b *)
1180 "(4*x^^^2 - 20*x + 25)/(2*x - 5)^^^3";
1181 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1186 else error "rational.sml: diff.behav. in norm_Rational_mg 9";
1188 (*SRC Schalk I, p.66 Nr. 381c *)
1190 "(27*a^^^3+9*a^^^2+3*a+1)/(27*a^^^3+18*a^^^2+3*a)";
1191 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1194 "(1 + 9 * a ^^^ 2) / (3 * a + 9 * a ^^^ 2)"
1196 else error "rational.sml: diff.behav. in norm_Rational_mg 10";
1198 (*SRC Schalk I, p.66 Nr. 383a *)
1200 "(5*a^^^2 - 5*a*b)/(a - b)^^^2";
1201 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1204 "5 * a / (a + -1 * b)"
1206 else error "rational.sml: diff.behav. in norm_Rational_mg 11";
1209 "-------- common denominator ----------------------------";
1210 "-------- common denominator ----------------------------";
1211 "-------- common denominator ----------------------------";
1212 (*SRA Schalk I, p.67 Nr. 403a *)
1215 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1218 "(-3 * x + 4 * y + -1 * x * y) / (x * y)"
1220 else error "rational.sml: diff.behav. in norm_Rational_mg 12";
1222 (*SRA Schalk I, p.67 Nr. 407b *)
1224 "(2*a+3*b)/(b*c) + (3*c+a)/(a*c) - (2*a^^^2+3*b*c)/(a*b*c)";
1225 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1230 else error "rational.sml: diff.behav. in norm_Rational_mg 13";
1232 (*SRA Schalk I, p.67 Nr. 410b *)
1234 "1/(x+1) + 1/(x+2) - 2/(x+3)";
1235 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1238 "(5 + 3 * x) / (6 + 11 * x + 6 * x ^^^ 2 + x ^^^ 3)"
1240 else error "rational.sml: diff.behav. in norm_Rational_mg 14";
1242 (*SRA Schalk I, p.67 Nr. 413b *)
1244 "(1+x)/(1 - x) - (1 - x)/(1+x) + 2*x/(1 - x^^^2)";
1245 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1248 "6 * x / (1 + -1 * x ^^^ 2)"
1250 else error "rational.sml: diff.behav. in norm_Rational_mg 15";
1252 (*SRA Schalk I, p.68 Nr. 414a *)
1254 "(x + 2)/(x - 1) + (x - 3)/(x - 2) - (x + 1)/((x - 1)*(x - 2))";
1255 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1258 "(-2 + -5 * x + 2 * x ^^^ 2) / (2 + -3 * x + x ^^^ 2)"
1260 else error "rational.sml: diff.behav. in norm_Rational_mg 16";
1262 (*SRA Schalk I, p.68 Nr. 423a *)
1264 "(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)";
1265 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1270 else error "rational.sml: diff.behav. in norm_Rational_mg 17";
1272 (*SRA Schalk I, p.68 Nr. 428b *)
1274 "1/(a - b)^^^2 + 1/(a+b)^^^2 - 2/(a^^^2 - b^^^2) - 4*(b^^^2 - 1)/(a^^^2 - b^^^2)^^^2";
1275 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1278 "4 / (a ^^^ 4 + -2 * a ^^^ 2 * b ^^^ 2 + b ^^^ 4)"
1280 else error "rational.sml: diff.behav. in norm_Rational_mg 18";
1282 (*SRA Schalk I, p.68 Nr. 430b *)
1284 "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";
1285 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1290 else error "rational.sml: diff.behav. in norm_Rational_mg 19";
1293 (*SRA Schalk I, p.68 Nr. 432 *)
1295 "(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)";
1296 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1301 else error "rational.sml: diff.behav. in norm_Rational_mg 20";
1306 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1309 "(3 * y + b * x) / (b * y)"
1311 else error "rational.sml: diff.behav. in norm_Rational_mg 21";
1314 "-------- multiply and cancel ---------------------------";
1315 "-------- multiply and cancel ---------------------------";
1316 "-------- multiply and cancel ---------------------------";
1317 (*SRM Schalk I, p.68 Nr. 436a *)
1319 "3*(x+y)/(15*(x - y)) * 25*(x - y)^^^2/(18*(x+y)^^^2)";
1320 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1323 "(5 * x + -5 * y) / (18 * x + 18 * y)"
1325 else error "rational.sml: diff.behav. in norm_Rational_mg 22";
1327 (*SRM.test Schalk I, p.68 Nr. 436b *)
1328 (*WN060420???MG3 crashes with method 'simplify' in
1329 IsacCore > Simplification > Rational Terms > Multiplication > No.2*)
1330 val t = str2term "5*a*(a - b)^^^2*(a + b)^^^3/(7*b*(a - b)^^^3) * 7*b/(a + b)^^^3";
1331 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1334 "5 * a / (a + -1 * b)"
1336 else error "rational.sml: diff.behav. in norm_Rational_mg 23";
1338 (*Schalk I, p.68 Nr. 437a *)
1339 val t = str2term "(3*a - 4*b)/(4*c+3*e) * (3*a+4*b)/(9*a^^^2 - 16*b^^^2)";
1340 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1341 if (term2str t) = "1 / (4 * c + 3 * e)" then ()
1342 else error "rational.sml: diff.behav. in norm_Rational_mg 24";
1344 "----- S.K. corrected non-termination 060904";
1345 val t = str2term "(3*a - 4*b) * (3*a+4*b)/((4*c+3*e)*(9*a^^^2 - 16*b^^^2))";
1346 val SOME (t',_) = rewrite_set_ thy false make_polynomial t;
1349 "(9 * a ^^^ 2 + -16 * b ^^^ 2) /\n(36 * a ^^^ 2 * c + 27 * a ^^^ 2 * e + -64 * b ^^^ 2 * c +\n -48 * b ^^^ 2 * e)"
1350 (*"(9 * a ^^^ 2 + -16 * b ^^^ 2) / (36 * a ^^^ 2 * c + 27 * a ^^^ 2 * e + -64 * b ^^^ 2 * c + -48 * b ^^^ 2 * e)"*)
1351 then () else error "rational.sml: S.K.8..corrected 060904-6";
1353 "----- S.K. corrected non-termination of cancel_p_";
1354 val t'' = str2term ("(9 * a ^^^ 2 + -16 * b ^^^ 2) /" ^
1355 "(36 * a^^^2 * c + (27 * a^^^2 * e + (-64 * b^^^2 * c + -48 * b^^^2 * e)))");
1356 val SOME (t',_) = rewrite_set_ thy false cancel_p t'';
1357 if term2str t' = "1 / (4 * c + 3 * e)" then ()
1358 else error "rational.sml: diff.behav. in cancel_p S.K.8";
1360 (*Schalk I, p.68 Nr. 437b *)
1361 (* nonterm.SK9 loops: cancel_p kann nicht weiter kuerzen!!! *)
1362 val t'' = str2term "(a + b)/(x^^^2 - y^^^2) * ((x - y)^^^2/(a^^^2 - b^^^2))";
1363 (* val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t'';
1366 "================delete===";
1367 (*a casual output from above*)
1369 "(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)";
1370 (* WN060831 nonterm.SK10
1371 val SOME (t,_) = rewrite_set_ thy false cancel_p t;
1375 (*SRM Schalk I, p.68 Nr. 438a *)
1377 "x*y/(x*y - y^^^2)*(x^^^2 - x*y)";
1378 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1383 else error "rational.sml: diff.behav. in norm_Rational_mg 24";
1385 (*SRM Schalk I, p.68 Nr. 439b *)
1387 "(4*x^^^2+4*x+1)*((x^^^2 - 2*x^^^3)/(4*x^^^2+2*x))";
1388 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1391 "(x + -4 * x ^^^ 3) / 2"
1393 else error "rational.sml: diff.behav. in norm_Rational_mg 25";
1395 (*SRM Schalk I, p.68 Nr. 440a *)
1397 "(x^^^2 - 2*x)/(x^^^2 - 3*x) * (x - 3)^^^2/(x^^^2 - 4)";
1398 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1401 "(-3 + x) / (2 + x)"
1403 else error "rational.sml: diff.behav. in norm_Rational_mg 26";
1405 "----- Schalk I, p.68 Nr. 440b SK11 works since 0707xx";
1407 "(a^^^3 - 9*a)/(a^^^3*b - a*b^^^3)*(a^^^2*b+a*b^^^2)/(a+3)";
1408 val SOME (t,_) = rewrite_set_ thy false norm_Rational t;
1409 if term2str t = "(-3 * a + a ^^^ 2) / (a + -1 * b)" then ()
1410 else error "rational.sml: diff.behav. in norm_Rational 27";
1412 "----- SK12 works since 0707xx";
1413 val t = str2term "(a^^^3 - 9*a)*(a^^^2*b+a*b^^^2)/((a^^^3*b - a*b^^^3)*(a+3))";
1414 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
1415 if term2str t' = "(-3 * a + a ^^^ 2) / (a + -1 * b)" then ()
1416 else error "rational.sml: diff.behav. in norm_Rational 28";
1419 "-------- common denominator and multiplication ---------";
1420 "-------- common denominator and multiplication ---------";
1421 "-------- common denominator and multiplication ---------";
1422 (*SRAM Schalk I, p.69 Nr. 441b *)
1423 val t = str2term "(4*a/3 + 3*b^^^2/a^^^3 + b/(4*a))*(4*b/(3*a))";
1424 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1427 "(36 * b ^^^ 3 + 3 * a ^^^ 2 * b ^^^ 2 + 16 * a ^^^ 4 * b) / (9 * a ^^^ 4)"
1428 then () else error "rational.sml: diff.behav. in norm_Rational_mg 28";
1430 (*SRAM Schalk I, p.69 Nr. 442b *)
1431 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)";
1432 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1435 "5 * x ^^^ 2 / (a * b ^^^ 3 * c)"
1436 then () else error "rational.sml: diff.behav. in norm_Rational_mg 29";
1438 (*SRAM Schalk I, p.69 Nr. 443b *)
1439 val t = str2term "(a/2 + b/3)*(b/3 - a/2)";
1440 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1443 "(-9 * a ^^^ 2 + 4 * b ^^^ 2) / 36"
1444 then () else error "rational.sml: diff.behav. in norm_Rational_mg 30";
1446 (*SRAM Schalk I, p.69 Nr. 445b *)
1447 val t = str2term "(a^^^2/9 + 2*a/(3*b) + 4/b^^^2)*(a/3 - 2/b) + 8/b^^^3";
1448 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1452 then () else error "rational.sml: diff.behav. in norm_Rational_mg 31";
1454 (*SRAM Schalk I, p.69 Nr. 446b *)
1455 val t = str2term "(x/(5*x + 4*y) - y/(5*x - 4*y) + 1)*(25*x^^^2 - 16*y^^^2)";
1456 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1459 "30 * x ^^^ 2 + -9 * x * y + -20 * y ^^^ 2"
1461 else error "rational.sml: diff.behav. in norm_Rational_mg 32";
1463 (*SRAM Schalk I, p.69 Nr. 449a *)(*Achtung: rechnet ca 8 Sekunden*)
1465 "(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)";
1466 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1468 if (term2str t) = "(-81 * x ^^^ 4 + 16 * x ^^^ 8 * y ^^^ 4) / (81 * y ^^^ 8)"
1469 then () else error "rational.sml: diff.behav. in norm_Rational_mg 33";
1472 (*SRAM Schalk I, p.69 Nr. 450a *)
1474 "(4*x/(3*y)+2*y/(3*x))^^^2 - (2*y/(3*x) - 2*x/y)*(2*y/(3*x)+2*x/y)";
1475 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1478 "(52 * x ^^^ 2 + 16 * y ^^^ 2) / (9 * y ^^^ 2)"
1480 else error "rational.sml: diff.behav. in norm_Rational_mg 34";
1483 "-------- double fractions ------------------------------";
1484 "-------- double fractions ------------------------------";
1485 "-------- double fractions ------------------------------";
1486 (*SRD Schalk I, p.69 Nr. 454b *)
1488 "((2 - x)/(2*a)) / (2*a/(x - 2))";
1489 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1492 "(-4 + 4 * x + -1 * x ^^^ 2) / (4 * a ^^^ 2)"
1494 else error "rational.sml: diff.behav. in norm_Rational_mg 35";
1496 (*SRD Schalk I, p.69 Nr. 455a *)
1498 "(a^^^2 + 1)/(a^^^2 - 1) / ((a+1)/(a - 1))";
1499 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1502 "(1 + a ^^^ 2) / (1 + 2 * a + a ^^^ 2)" then ()
1503 else error "rational.sml: diff.behav. in norm_Rational_mg 36";
1506 "----- Schalk I, p.69 Nr. 455b";
1507 val t = str2term "(x^^^2 - 4)/(y^^^2 - 9)/((2+x)/(3 - y))";
1508 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1509 if term2str t = "(2 + -1 * x) / (3 + y)" then ()
1510 else error "rational.sml: diff.behav. in norm_Rational_mg 37";
1512 "----- SK060904-1a non-termination of cancel_p_ ?: worked before 0707xx";
1513 val t = str2term "(x^^^2 - 4)*(3 - y)/((y^^^2 - 9)*(2+x))";
1514 val SOME (t,_) = rewrite_set_ thy false norm_Rational t;
1515 if term2str t = "(2 + -1 * x) / (3 + y)" then ()
1516 else error "rational.sml: diff.behav. in norm_Rational_mg 37b";
1518 "----- ?: worked before 0707xx";
1519 val t = str2term "(3 + -1 * y) / (-9 + y ^^^ 2)";
1520 val SOME (t,_) = rewrite_set_ thy false norm_Rational t;
1521 if term2str t = "-1 / (3 + y)" then ()
1522 else error "rational.sml: -1 / (3 + y) norm_Rational";
1524 (*SRD Schalk I, p.69 Nr. 456b *)
1526 "(b^^^3 - b^^^2)/(b^^^2+b)/(b^^^2 - 1)";
1527 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1529 if (term2str t) = "b / (1 + 2 * b + b ^^^ 2)" then ()
1530 else error "rational.sml: diff.behav. in norm_Rational_mg 38";
1532 (*SRD Schalk I, p.69 Nr. 457b *)
1534 "(16*a^^^2 - 9*b^^^2)/(2*a+3*a*b) / ((4*a+3*b)/(4*a^^^2 - 9*a^^^2*b^^^2))";
1535 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1538 "8 * a ^^^ 2 + -6 * a * b + -12 * a ^^^ 2 * b + 9 * a * b ^^^ 2"
1539 then () else error "rational.sml: diff.behav. in norm_Rational_mg 39";
1541 "----- Schalk I, p.69 Nr. 458b works since 0707";
1543 "(2*a^^^2*x - a^^^2)/(a*x - b*x) / (b^^^2*(2*x - 1)/(x*(a - b)))";
1544 val SOME (t,_) = rewrite_set_ thy false norm_Rational t;
1545 if term2str t = "a ^^^ 2 / b ^^^ 2" then ()
1546 else error "rational.sml: diff.behav. in norm_Rational_mg 39b";
1548 (*SRD Schalk I, p.69 Nr. 459b *)
1549 val t = str2term "(a^^^2 - b^^^2)/(a*b) / (4*(a+b)^^^2/a)";
1550 val SOME (t,_) = rewrite_set_ thy false norm_Rational t;
1551 if term2str t = "(a + -1 * b) / (4 * a * b + 4 * b ^^^ 2)" then ()
1552 else error "rational.sml: diff.behav. in norm_Rational_mg 41";
1555 (*Schalk I, p.69 Nr. 460b nonterm.SK
1557 "(9*(x^^^2 - 8*x+16)/(4*(y^^^2 - 2*y+1)))/((3*x - 12)/(16*y - 16))";
1558 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1561 else error "rational.sml: diff.behav. in norm_Rational_mg 42";
1564 "9*(x^^^2 - 8*x+16)*(16*y - 16)/(4*(y^^^2 - 2*y+1)*(3*x - 12))";
1565 val SOME (t',_) = rewrite_set_ thy false norm_Rational t;
1566 ... non terminating.
1567 val SOME (t',_) = rewrite_set_ thy false make_polynomial t;
1568 "(-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)";
1569 val SOME (t,_) = rewrite_set_ thy false cancel_p t';
1570 ... non terminating.*)
1572 (*SRD Schalk I, p.70 Nr. 472a *)
1573 val t = str2term ("((8*x^^^2 - 32*y^^^2)/(2*x + 4*y))/" ^
1574 "((4*x - 8*y)/(x + y))");
1575 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1580 else error "rational.sml: diff.behav. in norm_Rational_mg 43";
1583 (*----------------------------------------------------------------------*)
1584 (*---------------------- Einfache Dppelbrche --------------------------*)
1585 (*----------------------------------------------------------------------*)
1587 (*SRD Schalk I, p.69 Nr. 461a *)
1589 "(2/(x+3) + 2/(x - 3)) / (8*x/(x^^^2 - 9))";
1590 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1595 else error "rational.sml: diff.behav. in norm_Rational_mg 44";
1597 (*SRD Schalk I, p.69 Nr. 464b *)
1599 "(a - a/(a - 2)) / (a + a/(a - 2))";
1600 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1603 "(3 + -1 * a) / (1 + -1 * a)"
1605 else error "rational.sml: diff.behav. in norm_Rational_mg 45";
1607 (*SRD Schalk I, p.69 Nr. 465b *)
1609 "((x+3*y)/9 + (4*y^^^2 - 9*z^^^2)/(16*x)) /(x/9+y/6+z/4)";
1610 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1613 "(4 * x + 6 * y + -9 * z) / (4 * x)"
1615 else error "rational.sml: diff.behav. in norm_Rational_mg 46";
1617 (*SRD Schalk I, p.69 Nr. 466b *)
1619 "((1 - 7*(x - 2)/(x^^^2 - 4)) / (6/(x+2))) / (3/(x+5)+30/(x^^^2 - 25))";
1620 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1623 "(25 + -10 * x + x ^^^ 2) / 18"
1625 else error "rational.sml: diff.behav. in norm_Rational_mg 47";
1627 (*SRD Schalk I, p.70 Nr. 469 *)
1629 "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))";
1630 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1633 "3 * b ^^^ 3 / (2 * a + -2 * b)"
1635 else error "rational.sml: diff.behav. in norm_Rational_mg 48";
1637 (*----------------------------------------------------------------------*)
1638 (*---------------------- Mehrfache Dppelbrueche ------------------------*)
1639 (*----------------------------------------------------------------------*)
1641 (*SRD.test Schalk I, p.70 Nr. 476b *) (* Rechenzeit: 10 sec *)
1642 (*WN060419 crashes with method 'simplify' ????SK*)
1644 "((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)";
1645 val SOME (t,_) = rewrite_set_ thy false norm_Rational t;
1646 if term2str t = "1 / (a ^^^ 2 + -1 * b ^^^ 2)" then ()
1647 else error "rational.sml: diff.behav. in norm_Rational_mg 49";
1649 "----- Schalk I, p.70 Nr. 477a";
1650 (* MG Achtung: terme explodieren; Bsp zu komplex;
1651 L???ung sollte (ziemlich grosser) Faktorisierter Ausdruck sein
1652 val t = str2term "b*y/(b - 2*y)/((b^^^2 - y^^^2)/(b+2*y)) /" ^
1653 "(b^^^2*y+b*y^^^2)*(a+x)^^^2/((b^^^2 - 4*y^^^2)*(a+2*x)^^^2)";
1654 val SOME (t',_) = rewrite_set_ thy false norm_Rational t;
1657 val t = str2term "b*y*(b+2*y)*(b^^^2 - 4*y^^^2)*(a+2*x)^^^2 / " ^
1658 "((b - 2*y)*(b^^^2 - y^^^2)*(b^^^2*y+b*y^^^2)*(a+x)^^^2)";
1659 val SOME (t,_) = rewrite_set_ thy false make_polynomial t;
1663 "----- Schalk I, p.70 Nr. 478b ----- Rechenzeit: 5 sec";
1664 val t = str2term ("(a - (a*b+b^^^2)/(a+b))/(b+(a - b)/(1+(a+b)/(a - b))) / " ^
1665 "((a - a^^^2/(a+b))/(a+(a*b)/(a - b)))");
1666 val SOME (t',_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1668 "(2 * a ^^^ 3 + 2 * a ^^^ 2 * b) / (a ^^^ 2 * b + b ^^^ 3)"
1670 else error "rational.sml: diff.behav. in norm_Rational_mg 51";
1672 (* TODO.new_c:WN050820 STOP_REW_SUB introduced gave ...
1673 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 ()
1674 else error "rational.sml: works again";
1675 re-outcommented with TODO.new_c: cvs before 071227, 11:50*)
1679 (*Schalk I, p.70 Nr. 480a *)
1680 (* Achtung: rechnet ewig; cancel_p kann nicht krzen: WN060831 nonterm.SK00
1682 "(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)))";
1683 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1688 else error "rational.sml: diff.behav. in norm_Rational_mg 52";
1690 (*MG Berechne Zwischenergebnisse: WN060831 nonterm.SK00*)
1692 "(1/x+1/y+1/z)/(1/x - 1/y - 1/z)";
1693 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1695 "(x ^^^ 2 * y ^^^ 2 * z + x ^^^ 2 * y * z ^^^ 2 + x * y ^^^ 2 * z ^^^ 2) /
1696 (-1 * x ^^^ 2 * y ^^^ 2 * z + -1 * x ^^^ 2 * y * z ^^^ 2 + x * y ^^^ 2 * z ^^^ 2)";
1698 "2*x^^^2/(x^^^2 - z^^^2)/(x/(x+z)+x/(x - z))";
1699 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1703 (* SK 1. Ausdruck kann nicht weiter gekrzt werden; cancel_p !!!*)
1704 ### rls: cancel_p on:
1705 (x ^^^ 2 * (y ^^^ 2 * z) + x ^^^ 2 * (y * z ^^^ 2) + x * (y ^^^ 2 * z ^^^ 2)) /
1706 (-1 * (x ^^^ 2 * (y ^^^ 2 * z)) + -1 * (x ^^^ 2 * (y * z ^^^ 2)) + x * (y ^^^ 2 * z ^^^ 2))
1707 GC #3.61.81.101.197.17503: (0 ms)
1708 *** RATIONALS_DIRECT_CANCEL_EXCEPTION: Invalid fraction
1711 "(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))";
1712 val SOME (t,_) = rewrite_set_ thy false cancel_p t;
1714 (*uncaught exception nonexhaustive binding failure*)
1716 (* Das kann er aber krzen !!????: *)
1718 "(x^^^2 * (y^^^2 * z) + x * (y^^^2 * z^^^2)) / (-1 * (x^^^2 * (y * z^^^2)) + x * (y^^^2 * z^^^2))";
1719 val SOME (t,_) = rewrite_set_ thy false cancel_p t;
1721 "(-1 * (y * x) + -1 * (z * y)) / (1 * (z * x) + -1 * (z * y))";
1725 "-------- crucial examples ------------------------------";
1726 "-------- crucial examples ------------------------------";
1727 "-------- crucial examples ------------------------------";
1728 (*Schalk I, p.60 Nr. 215d *)
1729 (* Achtung: rechnet ewig ...
1730 val t = str2term "(a-b)^^^3 * (x+y)^^^4 / ((x+y)^^^2 * (a-b)^^^5)";
1731 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1732 term2str t; noterm.SK
1735 (* Kein Wunder, denn Z???ler und Nenner extra als Polynom dargestellt ergibt:*)
1737 val t = str2term "(a-b)^^^3 * (x+y)^^^4";
1738 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1740 "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";
1741 val t = str2term "((x+y)^^^2 * (a-b)^^^5)";
1742 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1744 "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";
1746 (*anscheinend macht dem Rechner das Krzen diese Bruches keinen Spass mehr ...*)
1748 (*--------------------------------------------------------------------*)
1749 (*Schalk I, p.70 Nr. 480b
1750 val t = str2term "((12*x*y/(9*x^^^2 - y^^^2))/" ^
1751 "(1/(3*x - y)^^^2 - 1/(3*x + y)^^^2)) *" ^
1752 "(1/(x - 5*y)^^^2 - 1/(x + 5*y)^^^2)/" ^
1753 "(20*x*y/(x^^^2 - 25*y^^^2))";
1754 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1756 Kann nicht weiter vereinfacht werden !!!!?? *)
1758 (*--------------------------------------------------------------------*)
1759 "---- MGs test set";
1760 val t = str2term " (1 + x^^^5) / (y + x) + x^^^3 / x ";
1761 val SOME (t,_) = rewrite_set_ thy false common_nominator_p t;
1762 if term2str t = "(1 + x ^^^ 3 + x ^^^ 5 + y * x ^^^ 2) / (x + y)" then()
1765 (*--------------------------------------------------------------------*)
1766 (* cancel_p liefert nicht immer Polynomnormalform (2): WN060831???SK3b
1767 ---> Sortierung FALSCH !! *)
1768 val t = str2term "b^^^3 * a^^^5/a ";
1769 val SOME (t,_) = rewrite_set_ thy false cancel_p t;
1771 "1 * (a^^^4 * b^^^3) / 1"; (*OK*)
1773 val t = str2term "b^^^3 * a^^^5/b ";
1774 val SOME (t,_) = rewrite_set_ thy false cancel_p t;
1776 "1 * (b^^^2 * a^^^5) / 1"; (*cancel_p sortiert hier falsch um!*)
1778 (* Problem liegt NICHT bei ord_make_polynomial! (siehe folgende Bsple) *)
1780 val x = str2term "x"; val bdv = str2term "bdv";
1781 val t1 = str2term "b^^^2 * a^^^5";
1782 val t2 = str2term "a^^^5 * b^^^2 ";
1783 ord_make_polynomial false Rational.thy [(x,bdv)] (t1,t2); (*false*)
1785 (* ==> "b^^^2 * a^^^5" > "a^^^5 * b^^^2 " ... OK!*)
1787 (*--------------------------------------------------------------------*)
1788 (* cancel_p liefert nicht immer Polynomnormalform (2): WN060831???SK3c
1789 ---> erzeugt berflssige "1 * ..."
1791 val t = str2term "-1 / (3 + y)";
1793 val SOME (t,_) = rewrite_set_ thy false cancel_p t;
1796 (********* Das ist das PROBLEM !!!!!!!??? *******************)
1797 (* -1 im Z???ler der Angabe verursacht das Problem !*)
1800 (* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *)
1801 "----- MGs test set";
1802 val t = str2term "(a^^^2 + -1)/(a+1)";
1803 val SOME (t',_) = rewrite_set_ thy false cancel_p t;
1804 if term2str t' = "(-1 + a) / 1" then ()
1805 else error "rational.sml MG tests 3d";
1807 "----- NOT TERMINATING ?: worked before 0707xx";
1808 val t = str2term "(a^^^2 - 1)*(b + 1) / ((b^^^2 - 1)*(a+1))";
1809 val SOME (t'',_) = rewrite_set_ thy false norm_Rational t;
1810 if term2str t'' = "(1 + -1 * a) / (1 + -1 * b)" then ()
1811 else error "rational.sml MG tests 3e";
1813 "----- corrected SK060905";
1814 val t = str2term "(4*x^^^2 - 20*x + 25)/(2*x - 5)^^^3";
1815 val SOME (t',_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1816 if term2str t' = "-1 / (5 + -2 * x)" then ()
1817 else error "rational.sml corrected SK060905";
1820 "-------- examples for Stefan Karnels thesis ------------";
1821 "-------- examples for Stefan Karnels thesis ------------";
1822 "-------- examples for Stefan Karnels thesis ------------";
1823 (*SRAM Schalk I, p.69 Nr. 442b --- abgewandelt*)
1825 "(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))";
1826 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1829 "5 * x ^^^ 2 / (b ^^^ 3 * c)"
1831 else error "rational.sml: diff.behav. in norm_Rational_mg 53";
1834 "-------- me Schalk I No.186 ----------------------------";
1835 "-------- me Schalk I No.186 ----------------------------";
1836 "-------- me Schalk I No.186 ----------------------------";
1837 val fmz = ["Term ((14 * x * y) / ( x * y ))",
1840 ("Rational",["rational","simplification"],
1841 ["simplification","of_rationals"]);
1842 val p = e_pos'; val c = [];
1843 val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
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;
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;
1853 val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;(*++ for explicit script*)
1854 val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;(*++ for explicit script*)
1855 case (f2str f, nxt) of
1856 ("14", ("End_Proof'", _)) => ()
1857 | _ => error "rational.sml diff.behav. in me Schalk I No.186";
1860 "-------- interSteps ..Simp_Rat_Double_No-1.xml ---------";
1861 "-------- interSteps ..Simp_Rat_Double_No-1.xml ---------";
1862 "-------- interSteps ..Simp_Rat_Double_No-1.xml ---------";
1865 [(["Term (((2 - x)/(2*a)) / (2*a/(x - 2)))", "normalform N"],
1866 ("Rational",["rational","simplification"],
1867 ["simplification","of_rationals"]))];
1870 autoCalculate 1 CompleteCalc;
1871 val ((pt,p),_) = get_calc 1; show_pt pt;
1873 interSteps 1 ([1],Res);
1874 val ((pt,p),_) = get_calc 1; show_pt pt;
1877 "-------- interSteps ..Simp_Rat_Cancel_No-1.xml ---------";
1878 "-------- interSteps ..Simp_Rat_Cancel_No-1.xml ---------";
1879 "-------- interSteps ..Simp_Rat_Cancel_No-1.xml ---------";
1882 [(["Term ((a^2 + -1*b^2) / (a^2 + -2*a*b + b^2))", "normalform N"],
1883 ("Rational",["rational","simplification"],
1884 ["simplification","of_rationals"]))];
1887 autoCalculate 1 CompleteCalc;
1888 val ((pt,p),_) = get_calc 1; show_pt pt;
1889 (*========== inhibit exn 110314 ================================================
1890 (*with explicit script done already... and removed [1,..] at below...
1891 interSteps 1 ([1],Res);
1892 val ((pt,p),_) = get_calc 1; show_pt pt;
1894 interSteps 1 ([2],Res);
1895 val ((pt,p),_) = get_calc 1; show_pt pt;
1897 interSteps 1 ([2,1],Res);
1898 val ((pt,p),_) = get_calc 1; show_pt pt;
1899 val newnds = children (get_nd pt [2,1]) (*see "fun detailrls"*);
1900 (*if length newnds = 12 then () WN060905*)
1901 if length newnds = 13 then ()
1902 else error "rational.sml: interSteps cancel_p rev_rew_p";
1904 val p = ([2,1,9],Res);
1906 val (_, tac, _) = pt_extract (pt, p);
1907 (*case tac of SOME (Rewrite ("sym_real_plus_binom_times1", _)) => ()
1909 case tac of SOME (Rewrite ("sym_real_add_mult_distrib2", _)) => ()
1910 | _ => error "rational.sml: getTactic, sym_real_plus_binom_times1";
1911 ============ inhibit exn 110314 ==============================================*)
1914 "-------- investigate rulesets for cancel_p -------------";
1915 "-------- investigate rulesets for cancel_p -------------";
1916 "-------- investigate rulesets for cancel_p -------------";
1917 val thy = @{theory "Rational"};
1918 "---------------- (a^^^2 + -1*b^^^2) / (a^^^2 + -2*a*b + b^^^2)";
1919 val t = str2term "(a^^^2 + -1*b^^^2) / (a^^^2 + -2*a*b + b^^^2)";
1920 val tt = str2term "(1 * a + 1 * b) * (1 * a + -1 * b)"(*numerator only*);
1921 "----- with rewrite_set_";
1922 val SOME (tt',asm) = rewrite_set_ thy false make_polynomial tt;
1923 term2str tt'= "a ^^^ 2 + -1 * b ^^^ 2" (*true*);
1924 val tt = str2term "((1 * a + -1 * b) * (1 * a + -1 * b))"(*denominator only*);
1925 val SOME (tt',asm) = rewrite_set_ thy false make_polynomial tt;
1926 term2str tt' = "a ^^^ 2 + -2 * a * b + b ^^^ 2" (*true*);
1928 "----- with make_deriv";
1929 val SOME (tt, _) = factout_p_ thy t; term2str tt =
1930 "(1 * a + 1 * b) * (1 * a + -1 * b) / ((1 * a + -1 * b) * (1 * a + -1 * b))";
1932 "--- with ruleset as before 060829";
1933 val {rules, rew_ord=(_,ro),...} =
1934 rep_rls (assoc_rls "make_polynomial");
1935 val der = make_deriv thy Atools_erls rules ro NONE tt;
1936 print_depth 99; map (term2str o #1) der; print_depth 3;
1937 print_depth 99; map (rule2str o #2) der; print_depth 3;
1938 ... did not terminate*)
1939 "--- with simpler ruleset";
1940 val {rules, rew_ord=(_,ro),...} =
1941 rep_rls (assoc_rls "rev_rew_p");
1942 val der = make_deriv thy Atools_erls rules ro NONE tt;
1943 print_depth 99; writeln (deriv2str der); print_depth 3;
1945 print_depth 99; map (term2str o #1) der; print_depth 3;
1946 "...,(-1 * b ^^^ 2 + a ^^^ 2) / (-2 * (a * b) + a ^^^ 2 + (-1 * b) ^^^ 2) ]";
1947 print_depth 99; map (rule2str o #2) der; print_depth 3;
1948 print_depth 99; map (term2str o #1 o #3) der; print_depth 3;
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;
1954 val {rules, rew_ord=(_,ro),...} =
1955 rep_rls (assoc_rls "rev_rew_p");
1956 val der = make_deriv thy Atools_erls rules ro NONE
1957 (str2term "(1 * a + -1 * b) * (1 * a + -1 * b)");
1958 print_depth 99; writeln (deriv2str der); print_depth 3;
1959 print_depth 99; map (term2str o #1) der; print_depth 3;
1960 (*WN060829 ...postponed*)
1963 "-------- investigate format of factout_ and factout_p_ -";
1964 "-------- investigate format of factout_ and factout_p_ -";
1965 "-------- investigate format of factout_ and factout_p_ -";
1966 val {rules, rew_ord = (_,ro),...} = rep_rls (assoc_rls "make_polynomial");
1967 val (thy, eval_rls) = (@{theory "Rational"}, Atools_erls)(*see 'fun init_state'*);
1968 val Rrls {scr = Rfuns {init_state,...},...} = assoc_rls "cancel_p";
1970 "----- see Rational.ML, local cancel_p, fun init_state";
1971 val t = str2term "(a^^^2 + (-1)*b^^^2) / (a^^^2 + (-2)*a*b + b^^^2)";
1972 val SOME (t',_) = factout_p_ thy t; term2str t';
1974 val rtas = reverse_deriv thy eval_rls rules ro NONE t';
1975 writeln(trtas2str rst);
1979 "----- see Rational.ML, local cancel_p, fun init_state";
1980 val t = str2term "a^^^2 / a";
1981 val SOME (t',_) = factout_p_ thy t;
1982 term2str t' = "a * a / (1 * a)" (*true*);
1983 (*... can be canceled with
1984 real_mult_div_cancel2 ?k ~= 0 ==> ?m * ?k / (?n * ?k) = ?m / ?n"*)
1985 (* sml/ME/rewtools.sml:
1986 val rtas = reverse_deriv thy Atools_erls rules ro NONE t';
1987 writeln (deri2str rtas);
1991 "-------- SK 060904 ----------------------------------------------";
1992 "----- order on polynomials -- input + output";
1993 val thy = @{theory "Isac"};
1994 val t = str2term "(a + -1 * b) / (-1 * a + b)";
1995 val SOME (t', _) = factout_p_ thy t; term2str t';
1996 val SOME (t', _) = cancel_p_ thy t; term2str t';
1998 val t = str2term "a*b*c*d / (d*e*f*g)";
1999 val SOME (t', _) = cancel_p_ thy t; term2str t';
2001 val t = str2term "a*(b*(c*d)) / (b*(e*(f*g)))";
2002 val SOME (t', _) = cancel_p_ thy t; term2str t';
2005 "----- SK060904-1a non-termination of cancel_p_ ? worked before 0707xx";
2006 val t = str2term "(x^^^2 - 4)*(3 - y) / ((y^^^2 - 9)*(2+x))";
2007 val SOME (t',_) = rewrite_set_ thy false norm_Rational t;
2008 if term2str t' = "(2 + -1 * x) / (3 + y)" then ()
2009 else error "rational.sml SK060904-1a worked since 0707xx";
2011 "----- SK060904-1b non-termination of cancel_p_ ... worked before 0707xx";
2012 val t = str2term ("(9 * a ^^^ 2 + -16 * b ^^^ 2) /" ^
2013 "(36 * a^^^2 * c + (27 * a^^^2 * e + (-64 * b^^^2 * c + -48 * b^^^2 * e)))");
2014 val SOME (t',_) = cancel_p_ thy t;
2015 if term2str t' = "1 / (4 * c + 3 * e)" then ()
2016 else error "rational.sml SK060904-1b";
2019 "----- SK060904-2a non-termination of add_fraction_p_";
2020 val t = str2term (" (a + b * x) / (a + -1 * (b * x)) + " ^
2021 " (-1 * a + b * x) / (a + b * x) ");
2023 val SOME (t',_) = rewrite_set_ thy false common_nominator_p t;
2025 common_nominator_p_ thy t;
2026 " (a + b * x)*(a + b * x) / ((a + -1 * (b * x))*(a + -1 * (b * x))) + " ^
2027 " (-1 * a + b * x)*(a + -1 * (b * x)) / ((a + b * x)*(-1 * a + b * x)) ";
2029 add_fraction_p_ thy t;
2030 " ((a + b * x)*(a + b * x) + (-1 * a + b * x)*(a + -1 * (b * x))) /" ^
2031 " ((a + b * x)*(-1 * a + b * x)) ";
2035 "-------- how to stepwise construct Scripts -------------";
2036 "-------- how to stepwise construct Scripts -------------";
2037 "-------- how to stepwise construct Scripts -------------";
2038 val thy = @{theory "Rational"};
2040 val p1 = parse thy (
2041 "Script SimplifyScript (t_t::real) = " ^
2042 " (Rewrite_Set discard_minus False " ^
2045 (*required (): (Rewrite_Set discard_minus False)*)
2046 val p2 = parse thy (
2047 "Script SimplifyScript (t_t::real) = " ^
2048 " (Rewrite_Set discard_minus False " ^
2051 val p3 = parse thy (
2052 "Script SimplifyScript (t_t::real) = " ^
2053 " ((Rewrite_Set discard_minus False) " ^
2056 val p4 = parse thy (
2057 "Script SimplifyScript (t_t::real) = " ^
2058 " ((Rewrite_Set discard_minus False) " ^
2061 val p5 = parse thy (
2062 "Script SimplifyScript (t_t::real) = " ^
2063 " ((Try (Rewrite_Set discard_minus False) " ^
2064 " Try (Rewrite_Set discard_parentheses False)) " ^
2067 val p6 = parse thy (
2068 "Script SimplifyScript (t_t::real) = " ^
2069 " ((Try (Rewrite_Set discard_minus False) @@ " ^
2070 " Try (Rewrite_Set rat_mult_poly False) @@ " ^
2071 " Try (Rewrite_Set make_rat_poly_with_parentheses False) @@ " ^
2072 " Try (Rewrite_Set cancel_p_rls False) @@ " ^
2074 " ((Try (Rewrite_Set common_nominator_p_rls False) @@ " ^
2075 " Try (Rewrite_Set rat_mult_div_pow False) @@ " ^
2076 " Try (Rewrite_Set make_rat_poly_with_parentheses False) @@" ^
2077 " Try (Rewrite_Set cancel_p_rls False) @@ " ^
2078 " Try (Rewrite_Set rat_reduce_1 False)))) @@ " ^
2079 " Try (Rewrite_Set discard_parentheses False)) " ^
2083 "----------- get_denominator ----------------------------";
2084 "----------- get_denominator ----------------------------";
2085 "----------- get_denominator ----------------------------";
2086 val thy = @{theory Isac};
2087 val t = term_of (the (parse thy "get_denominator ((a +x)/b)"));
2088 val SOME (_, t') = eval_get_denominator "" 0 t thy;
2089 if term2str t' = "get_denominator ((a + x) / b) = b" then ()
2090 else error "get_denominator ((a + x) / b) = b"