3 Copyright (c) Stefan Karnel 2002
4 Use is subject to license terms.
6 use"../smltest/IsacKnowledge/rational.sml";
8 ****************************************************************.*)
10 (******************************************************************
11 WN060104 transfer marked (*SR..*)examples to the exp-collection
12 # exp_IsacCore_Simp_Rat_Cancel.xml from rational.sml (*SRC*) 10 exp
13 # exp_IsacCore_Simp_Rat_Add.xml from rational.sml (*SRA*) 11 exp
14 # exp_IsacCore_Simp_Rat_Mult.xml from rational.sml (*SRM*) 5 exp
15 # exp_IsacCore_Simp_Rat_AddMult.xml from rational.sml (*SRAM*) 11 exp
16 # exp_IsacCore_Simp_Rat_Double.xml from rational.sml (*SRD*) 12 exp
17 *******************************************************************)
18 "-----------------------------------------------------------------";
19 "table of contents -----------------------------------------------";
20 "-----------------------------------------------------------------";
21 "-------- ... missing WN060103 -----------------------------------";
22 "-------- cancel from: Mathematik 1 Schalk Reniets Verlag --------";
23 "-------- common_nominator_p ---------------------------- --------";
24 "-------- reverse rewrite ----------------------------------------";
25 "-------- 'reverse-ruleset' cancel_p -----------------------------";
26 "-------- norm_Rational ------------------------------------------";
27 "-------- numeral rationals --------------------------------------";
28 "-------- cancellation -------------------------------------------";
29 "-------- common denominator -------------------------------------";
30 "-------- multiply and cancel ------------------------------------";
31 "-------- common denominator and multiplication ------------------";
32 "-------- double fractions ---------------------------------------";
33 "-------- me Schalk I No.186 -------------------------------------";
34 "-------- interSteps ..Simp_Rat_Double_No-1.xml ------------------";
35 "-------- interSteps ..Simp_Rat_Cancel_No-1.xml ------------------";
36 "-------- investigate rulesets for cancel_p ----------------------";
37 "-------- investigate format of factout_ and factout_p_ ----------";
38 "-----------------------------------------------------------------";
39 "-----------------------------------------------------------------";
40 "-----------------------------------------------------------------";
43 (*. tests of internal functions: to make them work,
44 out-comment (*!!!*) in knowledge/Rational.ML:
46 structure RationalI : RATIONALI =
55 print("\n\n********************* rational.sml - TESTS *************************\n\n");
56 print("\n\n***** divide tests *****\n");
57 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_)));
58 (* result: [(1,[0,0,1]),(1,[0,0,0])] *)
59 if mv_pquot1=[(1,[0,0,1]),(1,[0,0,0])] then () else raise error ("rational.sml: example failed");
61 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_)));
62 (* result: [(1,[1,0,1]),(~1,[0,0,1])] *)
63 if mv_prest1=[(1,[1,0,1]),(~1,[0,0,1])] then () else raise error ("rational.sml: example failed");
65 val mv_pquot2 = (#1(mv_division([(4,[2]),(8,[1]),(16,[0])],[(1,[1]),(1,[0])],LEX_)));
66 (* result: [(4,[1]),(4,[0])] *)
67 if mv_pquot2=[(4,[1]),(4,[0])] then () else raise error ("rational.sml: example failed");
69 val mv_prest2 = (#2(mv_division([(4,[2]),(8,[1]),(16,[0])],[(1,[1]),(1,[0])],LEX_)));
70 (* result: [(12,[0]] *)
71 if mv_prest2=[(12,[0])] then () else raise error ("rational.sml: example failed");
73 val mv_pquot3 = (#1(mv_division([(4,[2]),(~4,[0])],[(2,[1]),(2,[0])],LEX_)));
74 (* [(2,[1]),(~2,[0])] *)
75 if mv_pquot3=[(2,[1]),(~2,[0])] then () else raise error ("rational.sml: example failed");
77 val mv_prest3 = (#2(mv_division([(1,[2]),(~1,[0])],[(2,[1]),(2,[0])],LEX_)));
78 (* [(1,[2]),(~1,[0])] *)
79 if mv_prest3=[(1,[2]),(~1,[0])] then () else raise error ("rational.sml: example failed");
81 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_)));
83 if mv_pquot4=[(1,[0,1,1])] then () else raise error ("rational.sml: example failed");
85 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_)));
86 (* [(1,[1,1,1]),(~4,[0,1,2]),(4,[1,0,1]),(3,[0,0,1])] *)
87 if mv_prest4 =[(1,[1,1,1]),(~4,[0,1,2]),(4,[1,0,1]),(3,[0,0,1])] then () else raise error ("rational.sml: example failed");
89 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_)));
90 (* [(1,[2,2,0]),(6,[2,1,2]),(3,[1,1,0]),(4,[1,0,0]),(4,[0,4,0]),(3,[0,0,0])]*)
91 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 raise error ("rational.sml: example failed");
93 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_)));
95 if mv_prest5=[] then () else raise error ("rational.sml: example failed");
97 (* (x^2 + 2(a+1)x + (a^2+2a+1)) / (x+a+1) = x+a+1 *)
98 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_)));
99 if mv_pquot6=[(1,[1,0,0]),(1,[0,1,0]),(1,[0,0,0])] then () else raise error ("rational.sml: example failed");
101 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_)));
102 if mv_prest6=[] then () else raise error ("rational.sml: example failed");
105 print("\n\n***** MV_CONTENT-TESTS *****\n");
106 val mv_cont1=mv_content([(1,[2,1]),(1,[2,0]),(1,[1,1]),(1,[1,0]),(1,[0,1]),(1,[0,0])]);
107 (* [(1,[0,1]),(1,[0,0])] *)
108 if mv_cont1=[(1,[0,1]),(1,[0,0])] then () else raise error ("rational.sml: example failed");
110 val mv_pp1=mv_pp([(1,[1,1]),(1,[1,0]),(1,[0,1]),(1,[0,0])]);
111 (*[(1,[1,0]),(1,[0,0])]*)
112 if mv_pp1=[(1,[1,0]),(1,[0,0])] then () else raise error ("rational.sml: example failed");
114 val mv_cont2=mv_content([(2,[1]),(4,[0])]);
116 if mv_cont2=[(2,[0])] then () else raise error ("rational.sml: example failed");
118 val mv_pp2=mv_pp([(2,[1]),(4,[0])]);
119 (* [(1,[1]),(2,[0])] *)
120 if mv_pp2=[(1,[1]),(2,[0])] then () else raise error ("rational.sml: example failed");
122 val mv_cont3=mv_content[(8,[2,1,1]),(12,[1,0,2]),(10,[2,2,0]),(16,[1,1,1])];
124 if mv_cont3=[(2,[0,0,0])] then () else raise error ("rational.sml: example failed");
126 val mv_pp3=mv_pp[(8,[2,1,1]),(12,[1,0,2]),(10,[2,2,0]),(16,[1,1,1])];
127 (* [(5,[2,2,0]),(4,[2,1,1]),(8,[1,1,1]),(6,[1,0,2])] *)
128 if mv_pp3=[(5,[2,2,0]),(4,[2,1,1]),(8,[1,1,1]),(6,[1,0,2])] then () else raise error ("rational.sml: example failed");
130 val mv_cont4=mv_content[(2,[2,1,0]),(3,[1,0,1]),(2,[1,1,0]),(3,[0,0,1])];
132 if mv_cont4=[(1,[0,0,0])] then () else raise error ("rational.sml: example failed");
134 val mv_pp4=mv_pp [(2,[2,1,0]),(3,[1,0,1]),(2,[1,1,0]),(3,[0,0,1])];
135 (* [(2,[2,1,0]),(2,[1,1,0]),(3,[1,0,1]),(3,[0,0,1])] *)
136 if mv_pp4=[(2,[2,1,0]),(2,[1,1,0]),(3,[1,0,1]),(3,[0,0,1])] then () else raise error ("rational.sml: example failed");
138 val con1=mv_content([(9,[2,0]),(15,[1,1]),(12,[1,0]),(6,[0,2]),(12,[0,1])]);
140 if con1=[(3,[0,0])] then () else raise error ("rational.sml: example failed");
142 val pp1=mv_pp([(9,[2,0]),(15,[1,1]),(12,[1,0]),(6,[0,2]),(12,[0,1])]);
143 (* [(3,[2,0]),(5,[1,1]),(4,[1,0]),(2,[0,2]),(4,[0,1])] *)
144 if pp1=[(3,[2,0]),(5,[1,1]),(4,[1,0]),(2,[0,2]),(4,[0,1])] then () else raise error ("rational.sml: example failed");
146 val con2=mv_content([(1,[2,0]),(1,[1,1]),(1,[1,0]),(1,[0,2]),(1,[0,1])]);
148 if con2=[(1,[0,0])] then () else raise error ("rational.sml: example failed");
150 val pp2 =mv_pp([(1,[2,0]),(1,[1,1]),(1,[1,0]),(1,[0,2]),(1,[0,1])]);
151 (* [(1,[2,0]),(1,[1,1]),(1,[1,0]),(1,[0,2]),(1,[0,1])] *)
152 if pp2=[(1,[2,0]),(1,[1,1]),(1,[1,0]),(1,[0,2]),(1,[0,1])] then () else raise error ("rational.sml: example failed");
154 val cont1 = mv_content [(1,[2,1,0]),(2,[2,1,0])];
156 if cont1=[(3,[0,1,0])] then () else raise error ("rational.sml: example failed");
158 val pp1 = mv_pp [(1,[2,1,0]),(2,[2,1,0])];
160 if pp1=[(1,[2,0,0])] then () else raise error ("rational.sml: example failed");
162 val cont2 = mv_content [(4,[1,2,0]),(2,[2,1,0])];
164 if cont2=[(2,[0,1,0])] then () else raise error ("rational.sml: example failed");
166 val pp2 = mv_pp [(4,[1,2,0]),(2,[2,1,0])];
167 (* [(1,[2,0,0]),(2,[1,1,0])] *)
168 if pp2=[(1,[2,0,0]),(2,[1,1,0])] then () else raise error ("rational.sml: example failed");
170 print("\n\n\n\n********************************************************\n\n");
171 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])];
172 if cont3=[(5,[0,2,1]),(4,[0,2,0]),(2,[0,1,1])] then () else raise error ("rational.sml: example failed");
173 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])];
175 ---------------------------------------------------------------------------*)
177 fun parse_rat str = (term_of o the o (parse thy)) str;
179 print("\n\n***** mv_gcd-tests *****\n");
180 val ggt1 = mv_gcd [(4,[2,2]),(8,[1,1]),(4,[0,0])] [(2,[1,1]),(2,[0,0])];
181 (* [(2,[1,1]),(2,[0,0])] *)
182 if ggt1=[(2,[1,1]),(2,[0,0])] then () else raise error ("rational.sml: example failed");
184 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])];
185 (* [(2,[1,1,0]),(3,[0,0,1])] *)
186 if ggt2=[(2,[1,1,0]),(3,[0,0,1])] then () else raise error ("rational.sml: example failed");
189 val ggt3 = mv_gcd [(1,[2,0]),(~2,[1,1]),(1,[0,2])] [(1,[1,0]),(~1,[0,1])];
190 (* [(1,[1,0]),(~1,[0,1])] *)
191 if ggt3=[(1,[1,0]),(~1,[0,1])] then () else raise error ("rational.sml: example failed");
194 val ggt4 = mv_gcd [(1,[2,1,0]),(2,[2,1,0])] [(5,[1,0,0])];
196 if ggt4=[(1,[1,0,0])] then () else raise error ("rational.sml: example failed");
199 val ggt5 = mv_gcd [(4,[2,0]),(~8,[1,1]),(4,[0,2])] [(1,[2,0]),(~1,[0,2])];
200 (* [(1,[1,0]),(~1,[0,1])] *)
201 if ggt5=[(1,[1,0]),(~1,[0,1])] then () else raise error ("rational.sml: example failed");
204 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])];
206 if ggt6=[(1,[1,0,0])] then () else raise error ("rational.sml: example failed");
208 print("\n\n***** kgv-tests *****\n");
209 val kgv1=mv_lcm [(10,[])] [(15,[])];
211 if kgv1=[(30,[])] then () else raise error ("rational.sml: example failed");
213 val kgv2=mv_lcm [(1,[2,0]),(~2,[1,1]),(1,[0,2])] [(1,[1,0]),(~1,[0,1])];
214 (* [(1,[2,0]),(~2,[1,1]),(1,[0,2])] *)
215 if kgv2=[(1,[2,0]),(~2,[1,1]),(1,[0,2])] then () else raise error ("rational.sml: example failed");
217 val kgv3=mv_lcm [(4,[2,0]),(~8,[1,1]),(4,[0,2])] [(1,[2,0]),(~1,[0,2])];
218 (* [(4,[3,0]),(~4,[2,1]),(~4,[1,2]),(4,[0,3])] *)
219 if kgv3=[(4,[3,0]),(~4,[2,1]),(~4,[1,2]),(4,[0,3])] then () else raise error ("rational.sml: example failed");
222 print("\n\n***** STEP_CANCEL_TESTS: *****\n");
224 val term2 = (term_of o the o (parse thy)) " (9 * a^^^2 * b) / (6 * a * c)";
225 val div2 = term2str (step_cancel term2);
226 if div2 = "3 * (a * b) * (3 * a) / (2 * c * (3 * a))" then () else raise error ("rational.sml: example failed");
229 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";
230 val div1 = term2str(step_cancel term1);
231 if div1 = "(3 * c + 14 * b + 20 * (b ^^^ 2 * c) + 10 * (a * (b * c))) * a / (1 * a)" then () else raise error ("rational.sml: example failed");
233 val term3 = (term_of o the o (parse thy)) "(10 * a^^^2 * b * c) / (1 * x * y * z) ";
234 val div3 = term2str(step_cancel term3);
235 if div3="10 * a ^^^ 2 * b * c / (1 * x * y * z)" then () else raise error ("rational.sml: example failed");
237 --------------------------------------------------------------------------!!!*)
239 (*-----versuche 13.3.03-----
240 val t = str2term "1 - x^^^2 - 5 * x^^^5";
241 val vs=(((map free2str) o vars) t);
242 val Some ml = expanded2poly t vs;
244 poly2term'(rev(sort (mv_geq LEX_) (ml)),vs);
245 poly2term'([(~5,[5]),(~1,[2]),(1,[0])], vs);
246 monom2term((~5,[5]),vs);
247 monom2term((~1,[2]),vs);
248 val t' = monom2term((1,[0]),vs);(*uncaught exception LIST*)
250 val (i,is) = (~1,[2]);
251 val ttt = Const ("op *", [HOLogic.realT,HOLogic.realT]---> HOLogic.realT) $
252 (Const ("uminus", HOLogic.realT --> HOLogic.realT) $
253 Free ((str_of_int o abs) i, HOLogic.realT)) $
254 powerproduct2term(is, vs);
256 -------versuche 13.3.03-----*)
258 val t = str2term "1 - x^^^2 - 5 * x^^^5";
259 val Some t' = expanded2polynomial t; term2str t';
260 "1 + - 1 * x ^^^ 2 + - 5 * x ^^^ 5";
261 val t = str2term "1 - x";
262 val Some t' = expanded2polynomial t; term2str t';
264 val t = str2term "1 + (-1) * x";
265 val Some t' = expanded2polynomial t; term2str t';
267 val t = (term_of o the o (parse thy)) "1 + (-1) * x ^^^ 2 + (-5) * x ^^^5";
268 val Some t' = polynomial2expanded t; term2str t';
269 "1 - x ^^^ 2 - 5 * x ^^^ 5";
272 " external calculating functions test ";
273 " external calculating functions test ";
274 " external calculating functions test ";
276 val t1 = (term_of o the o (parse thy)) "((3 * x^^^2 + 6 *x + 3) / (2*x + 2))";
277 val Some (t1',asm)= factout_p_ thy t1;
278 term2str t1'; terms2str asm;
279 "(3 + 3 * x) * (1 + 1 * x) / (2 * (1 + 1 * x))";
281 val Some (t1',asm)= cancel_p_ thy t1;
282 term2str t1'; terms2str asm;
284 "[\"1 + 1 * x ~= 0\"]";
286 val t = (term_of o the o (parse thy)) "((-3 * x^^^2 + 6 *x - 3) / (2*x - 2))";
287 val Some (t',asm)= cancel_ thy t;
288 term2str t'; terms2str asm;
291 val Some (t',asm)= factout_ thy t;
292 term2str t'; terms2str asm;
293 "(3 - 3 * x) * (-1 + x) / (2 * (-1 + x))";
296 val t = str2term "((x+ (-1)) / (x + 1)) + ((x + 1) / (x + (-1)))";
297 val Some (t',asm) = add_fraction_p_ thy t;
298 term2str t'; terms2str asm;
299 "(2 + 2 * x ^^^ 2) / (-1 + 1 * x ^^^ 2)";
301 val Some (t',asm) = common_nominator_p_ thy t;
302 term2str t'; terms2str asm;
303 "(-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))";
306 val t = str2term "((x - 1) / (x + 1)) + ((x + 1) / (x - 1))";
307 val Some (t',asm) = add_fraction_ thy t;
308 term2str t'; terms2str asm;
309 "(2 + 2 * x ^^^ 2) / (-1 + x ^^^ 2)";
311 val Some (t',asm) = common_nominator_ thy t;
312 term2str t'; terms2str asm;
313 "(-1 + x) * (-1 + x) / ((1 + x) * (-1 + x)) +\n(1 + x) * (1 + x) / ((1 + x) * (-1 + x))";
316 val t = str2term "((1) / (2*x + 2)) + ((1) / (2*x + (-2))) + ((1) / ( x^^^2 + (-1)))+((1) / (x^^^2 + (-2)*x + 1))";
317 val Some (t',asm) = common_nominator_p_ thy t;
318 term2str t'; terms2str asm;
319 "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 * (#";
321 val Some (t',asm) = add_fraction_p_ thy t;
322 term2str t'; terms2str asm;
323 "1 * x / (1 + -2 * x + 1 * x ^^^ 2)";
324 "[\"1 + 1 * x ~= 0\"]";
325 val Some(t',asm) = norm_rational_ thy t;
326 term2str t'; terms2str asm;
327 "1 * x / (1 + -2 * x + 1 * x ^^^ 2)";
328 "[\"1 + 1 * x ~= 0\"]";
330 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))";
331 val Some (t3',_) = common_nominator_ thy t3;
332 val Some (t3'',_) = add_fraction_ thy t3;
336 val Some(t4,t5) = norm_expanded_rat_ thy t3;
342 val t=(term_of o the o (parse thy)) "(9 - x^^^2)/(9 - 6*x + x^^^2)";
343 val Some (t',_) = factout_ thy t;
344 val Some (t'',_) = cancel_ thy t;
347 "(3 + x) * (3 - x) / ((3 - x) * (3 - x))";
350 val t=(term_of o the o (parse thy))
351 "(9 - x^^^2) / (9 - 6*x + x^^^2) + 1 / (3 - x)";
352 val Some (t',_) = common_nominator_ thy t;
353 val Some (t'',_) = add_fraction_ thy t;
356 "(9 - x ^^^ 2) / ((3 - x) * (3 - x)) + 1 * (3 - x) / ((3 - x) * (3 - x))";
359 (*WN021016 added -----vv---*)
360 val t = str2term "(9 - x^^^2) / (9 - 6*x + x^^^2) + 1";
361 val Some (t',_) = common_nominator_ thy t;
362 val Some (t'',_) = add_fraction_ thy t;
363 term2str t' = "(9 - x ^^^ 2) / (9 - 6 * x + x ^^^ 2) +\n1\
364 \ * (9 - 6 * x + x ^^^ 2) / (9 - 6 * x + x ^^^ 2)" (*true*);
365 term2str t'' = "6 / (3 - x)" (*true*);
367 val t = str2term "1 + (9 - x^^^2) / (9 - 6*x + x^^^2)";
368 val Some (t',_) = common_nominator_ thy t;
369 val Some (t'',_) = add_fraction_ thy t;
370 term2str t' = "1 * (9 - 6 * x + x ^^^ 2) / (9 - 6 * x + x ^^^ 2) +\n\
371 \(9 - x ^^^ 2) / (9 - 6 * x + x ^^^ 2)" (*true*);
372 term2str t'' = "6 / (3 - x)" (*true*);
373 (*WN021016 added -----^^---*)
374 (*WN030602 added -----vv--- no rewrite -> None !*)
375 val t = str2term "1 / a";
376 val None = cancel_p_ thy t;
377 val None = rewrite_set_ thy false cancel_p t;
378 (*WN.2.6.03 added -------^^---*)
380 val t = str2term "(y^^^2 - x^^^2)/(y^^^2 - 2*y*x + x^^^2)";
381 val Some (t',_) = factout_ thy t;
382 val Some (t'',_) = cancel_ thy t;
383 term2str t'= "(1 * y + x) * (1 * y - x) / ((1 * y - x) * (1 * y - x))"(*true*);
384 (*sometime before 060831???SK..*)"(y + x) * (y - x) / ((y - x) * (y - x))";
385 term2str t'' = "(1 * y + x) / (1 * y - x)" (*true*);
386 (*sometime before 060831???SK1..*)"(y + x) / (y - x)";
388 val t = str2term "(y^^^2 - x^^^2)/(y^^^2 - 2*y*x + x^^^2) + 1 / (y - x)";
389 val Some (t',_) = common_nominator_ thy t;
390 val Some (t'',_) = add_fraction_ thy t;
392 "(-1 * x ^^^ 2 + y ^^^ 2) / ((-1 * x + y) * (-1 * x + y)) +\n1\
393 \ * (-1 * x + y) / ((-1 * x + y) * (-1 * x + y))" (*true*);
394 term2str t'' = "(-1 - x - y) / (1 * x - y)" (*true*);
395 (*sometime before 060831???SK2..*)
396 "((-1) * x ^^^ 2 + y ^^^ 2) / (((-1) * x + y) * ((-1) * x + y)) +\
397 \1 * ((-1) * x + y) / (((-1) * x + y) * ((-1) * x + y))";
398 (*sometime before 060831???SK2..*)"((-1) - x - y) / (x - y)";
400 val t = str2term "(x^^^2 - y^^^2)/(x^^^2 - 2*x*y + y^^^2) + 1 / (x - y)";
401 val Some (t',_) = common_nominator_ thy t;
402 val Some (t'',_) = add_fraction_ thy t;
404 "(-1 * y ^^^ 2 + x ^^^ 2) / ((-1 * y + x) * (-1 * y + x)) +\n1\
405 \ * (-1 * y + x) / ((-1 * y + x) * (-1 * y + x))" (*true*);
406 term2str t'' = "(-1 - y - x) / (1 * y - x)" (*true*);
407 (*sometime before 060831???SK3..*)
408 "((-1) * y ^^^ 2 + x ^^^ 2) / (((-1) * y + x) * ((-1) * y + x)) +\
409 \1 * ((-1) * y + x) / (((-1) * y + x) * ((-1) * y + x))";
410 (*sometime before 060831???SK3..*)"((-1) - y - x) / (y - x)";
411 (*WN.16.10.02 lexicographische Ordnung ^^^^^^^ ?!*)
414 val t=(term_of o the o (parse thy))
415 "(y^^^2 - x^^^2)/(y^^^2 - 2*y*x + x^^^2)";
416 val Some (t',_) = norm_expanded_rat_ thy t;
419 (*val Some (t'',_) = norm_rational_ thy t;
421 *** RATIONALS_TERM2POLY_EXCEPTION: Invalid Polynomial
422 WN.16.10.02 ?! + WN060831???SK4*)
424 val t=(term_of o the o (parse thy))
425 "(9 - x^^^2)/(9 - 6*x + x^^^2) + (1)/(3 + x)";
426 val Some (t',_) = norm_expanded_rat_ thy t;
428 "(12 + 5 * x + x ^^^ 2) / (9 - x ^^^ 2)";
429 (*val Some (t'',_) = norm_rational_ thy t;
431 *** RATIONALS_TERM2POLY_EXCEPTION: Invalid Polynomial
434 val t=(term_of o the o (parse thy))
435 "(9 + (-1)* x^^^2)/(9 + (-1)* 6*x + x^^^2) + (1)/(3 + x)";
436 val Some (t',_) = norm_expanded_rat_ thy t;
437 val Some (t'',_) = norm_rational_ thy t;
440 "(12 + 5 * x + x ^^^ 2) / (9 - x ^^^ 2)";
441 "(12 + 5 * x + x ^^^ 2) / (9 + (-1) * x ^^^ 2)";
444 " examples from: Mathematik 1 Schalk Reniets Verlag ";
445 " examples from: Mathematik 1 Schalk Reniets Verlag ";
446 " examples from: Mathematik 1 Schalk Reniets Verlag ";
449 "-------- cancel from: Mathematik 1 Schalk Reniets Verlag --------";
450 "-------- cancel from: Mathematik 1 Schalk Reniets Verlag --------";
451 "-------- cancel from: Mathematik 1 Schalk Reniets Verlag --------";
452 val thy' = "Rational.thy";
454 val mp = "make_polynomial";
456 print("\n\nexample 186:\n");
458 val e186a'="(14 * x * y) / ( x * y )";(*SRC*)
459 val e186a = the (rewrite_set thy' false "cancel" e186a');
460 is_expanded (parse_rat "14 * x * y");
461 is_expanded (parse_rat "x * y");
464 val e186b'="(60 * a * b) / ( 15 * a * b )";
465 val e186b = the (rewrite_set thy' false "cancel" e186b');
467 val e186c'="(144 * a^^^2 * b * c) / (12 * a * b * c )";
468 val e186c = (the (rewrite_set thy' false "cancel" e186c'))
469 handle e => print_exn e;
470 val t = (term_of o the o (parse thy)) e186c';
473 print("\n\nexample 187:\n");
475 val e187a'="(12 * x * y) / (8 * y^^^2 )";(*SRC*)
476 val e187a = the (rewrite_set thy' false "cancel" e187a');
478 val e187b'="(8 * x^^^2 * y * z ) / (18 * x * y^^^2 * z )";
479 val e187b = the (rewrite_set thy' false "cancel" e187b');
481 val e187c'="(9 * x^^^5 * y^^^2 * z^^^4) / (15 * x^^^6 * y^^^3 * z )";(*SRC*)
482 val e187c = the (rewrite_set thy' false "cancel" e187c');
485 val e188a'="(-8 + 8 * x) / (-9 + 9 * x)";(*SRC*)
486 val e188a = the (rewrite_set thy' false "cancel" e188a');
487 is_expanded (parse_rat "8 * x + -8");
488 (* e188a = ("8 / 9",["not ((-1) + x = 0)"]) then () 13.3.03*)
489 if e188a = ("8 / 9",["-1 + x ~= 0"]) then ()
490 else raise error "rational.sml: e188a new behaviour";
491 val Some (t,_) = rewrite_set thy' false mp
492 "(8*((-1) + x))/(9*((-1) + x))";
494 val e188b'="(-15 + 5 * x) / (-18 + 6 * x)";(*SRC*)
495 val Some (t,_) = rewrite_set thy' false "cancel" e188b';
496 t = "5 / 6" (*true*);
499 val e188c'="( a + -1 * b ) / ( b + -1 * a )";
500 val e188c = the (rewrite_set thy' false "cancel_p" e188c');
501 (*is_expanded (parse_rat "a + -1 * b");*)
503 rewrite_set thy' false mp "((-1)*(b + (-1) * a))/(1*(b + (-1) * a))";
504 if t= "(a + -1 * b) / (-1 * a + b)" then()
505 else raise error "rational.sml: e188c new behaviour";
507 print("\n\nexample 190:\n");
509 val e190c'="( 27 * a^^^3 + 9 * a^^^2 + 3 * a + 1 ) / ( 27 * a^^^3 + 18 * a^^^2 + 3 * a )";
510 val e190c = the (rewrite_set thy' false "cancel" e190c');
511 val Some (t,_) = rewrite_set thy' false mp "((1 + 9 * a ^^^ 2)*(1 + 3 * a))/((3 * a + 9 * a ^^^ 2)*(1 + 3 * a))";
512 if t = "(1 + 3 * a + 9 * a ^^^ 2 + 27 * a ^^^ 3) /\n(3 * a + 18 * a ^^^ 2 + 27 * a ^^^ 3)" then ()
513 else raise error "rational.sml: e190c new behaviour";
515 print("\n\nexample 191:\n");
517 val e191a'="( x^^^2 + -1 * y^^^2 ) / ( x + y )";
519 val e191a = the (rewrite_set thy' false "cancel" e191a');
520 is_expanded (parse_rat "x^^^2 + -1 * y^^^2");
522 is_expanded (parse_rat "x + y");
524 val Some (t,_) = rewrite_set thy' false mp "((x + (-1) * y)*(x + y))/((1)*(x + y))";
525 (* t="(x ^^^ 2 + -1 * y ^^^ 2) / (x + y)" then() WN.13.3.03*)
526 if t="(x ^^^ 2 + -1 * y ^^^ 2) / (x + y)" then()
527 else raise error "rational.sml: e191a new behaviour";
530 val e191c'="( 9 * x^^^2 + -30 * x + 25 ) / ( 9 * x^^^2 + -25 )";
532 val e191c = the (rewrite_set thy' false "cancel" e191c');
533 is_expanded (parse_rat "9 * x^^^2 + -30 * x + 25");
535 is_expanded (parse_rat "25 + -30*x + 9*x^^^2");
537 is_expanded (parse_rat "-25 + 9*x^^^2");
539 val Some (t,_) = rewrite_set thy' false mp "(((-5) + 3 * x)*((-5) + 3 * x))/((5 + 3 * x)*((-5) + 3 * x))";
540 (* t="(25 + ((-30) * x + 9 * x ^^^ 2)) / ((-25) + 9 * x ^^^ 2)"then() 13.3.03*)
541 if t= "(25 + -30 * x + 9 * x ^^^ 2) / (-25 + 9 * x ^^^ 2)" then()
542 else raise error "rational.sml: 'e191c' new behaviour";
545 print("\n\nexample 192:\n");
547 val e192b'="( 7 * x^^^3 + -1 * x^^^2 * y ) / ( 7 * x * y^^^2 + -1 * y^^^3 )";
549 val e192b = the (rewrite_set thy' false "cancel" e192b');
550 -------------------*)
551 val Some (t',_) = rewrite_set thy' false mp "((x ^^^ 2)*(7 * x + (-1) * y))/((y ^^^ 2)*(7 * x + (-1) * y))";
552 if t' = "(7 * x ^^^ 3 + -1 * x ^^^ 2 * y) / (7 * x * y ^^^ 2 + -1 * y ^^^ 3)"
553 (*"(-1 * y * x ^^^ 2 + 7 * x ^^^ 3) / (-1 * y ^^^ 3 + 7 * x * y ^^^ 2)"WN050929*)
554 then () else raise error "rational.sml: 'e192b' new behaviour";
555 (*^^^ works with MG's simplifier vvv*)
556 val t =str2term"((x ^^^ 2)*(7 * x + (-1) * y))/((y ^^^ 2)*(7 * x + (-1) * y))";
557 val Some (t',_) = rewrite_set_ Isac.thy false make_polynomial t;
558 if term2str t' = "(7 * x ^^^ 3 + -1 * x ^^^ 2 * y) / (7 * x * y ^^^ 2 + -1 * y ^^^ 3)" then () else raise error "rational.sml: 'e192b'MG new behaviour";
561 print("\n\nexample 193:\n");
563 val e193a'="( x^^^2 + -6 * x + 9 ) / ( x^^^2 + -9 )";
565 val e193a = the (rewrite_set thy' false "cancel" e193a');
566 -------------------*)
568 val e193b'="( x^^^2 + -8 * x + 16 ) / ( 2 * x^^^2 + -32 )";
570 val e193b = the (rewrite_set thy' false "cancel" e193b');
572 val e193c'="( 2 * x + -50 * x^^^3 ) / ( 25 * x^^^2 + -10 * x + 1 )";
573 val Some(t,_) = rewrite_set thy' false "cancel" e193c';
574 -------------------*)
576 val wn01 = "(-25 + 9*x^^^2)/(5 + 3*x)";
577 val Some (t,_) = rewrite_set thy' false "cancel" wn01;
578 (* t = "((-5) + 3 * x) / 1" then () WN.13.3.03*)
579 if t = "(-5 + 3 * x) / 1" then ()
580 else raise error "rational.sml: new behav. in cancel wn01";
583 "-------- common_nominator_p ---------------------------- --------";
584 "-------- common_nominator_p ---------------------------- --------";
585 "-------- common_nominator_p ---------------------------- --------";
586 val rls' = "common_nominator_p";
588 print("\n\nexample 204:\n");
590 val e204a'="((5 * x) / 9) + ((3 * x) / 9) + (x / 9)";
591 val e204a = the (rewrite_set thy' false "common_nominator_p" e204a');
593 val e204b'="5 / x + -3 / x + -1 / x";
594 val e204b = the (rewrite_set thy' false "common_nominator_p" e204b');
596 print("\n\nexample 205:\n");
598 val e205a'="((4 * x + 7) / 8) + ((4 * x + 3) / 8)";
599 val e205a = the (rewrite_set thy' false "common_nominator_p" e205a');
601 val e205b'="((5 * x + 2) / 3) + ((-2 * x + 1) / 3)";
602 val e205b = the (rewrite_set thy' false "common_nominator_p" e205b');
604 print("\n\nexample 206:\n");
606 val e206a'="((5 * x + 4) / (2 * x + -1)) + ((9 * x + 5) / (2 * x + -1))";
607 val e206a = the (rewrite_set thy' false "common_nominator_p" e206a');
609 val e206b'="((17 * x + -23) / (5 * x + 4)) + ((-25 + -17 * x) / (5 * x + 4))";
610 val e206b = the (rewrite_set thy' false "common_nominator_p" e206b');
612 print("\n\nexample 207:\n");
613 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)) ";
614 val e207 = the (rewrite_set thy' false "common_nominator_p" e207');
616 print("\n\nexample 208:\n");
617 val e208'="((3 * x + 2) / (x + 2)) + ((5 * x + -1) / (x + 2)) + ((-7 * x + -3) / (x + 2)) + ((-1 * x + -3) / (x + 2)) ";
618 val e208 = the (rewrite_set thy' false "common_nominator_p" e208');
620 print("\n\nexample 209:\n");
621 val e209'="((3 * x + -7 * y + 3 * z) / (4)) + ((2 * x + 17 * y + 10 * z) / (4)) + ((-1 * x + 2 * y + z) / (4)) ";
622 val e209 = the (rewrite_set thy' false "common_nominator_p" e209');
624 print("\n\nexample 210:\n");
625 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)) ";
626 val e210 = the (rewrite_set thy' false "common_nominator_p" e210');
628 print("\n\nexample 211:\n");
630 val e211a'="((b) / (a + -1 * b)) + ((-1 * a) / (a + -1 * b))";
631 val e211a = the (rewrite_set thy' false "common_nominator_p" e211a');
633 val e211b'="((b) / (b^^^2 + -1 * a^^^2)) + ((-1 * a) / (b^^^2 + -1 * a^^^2))";
634 val e211b = the (rewrite_set thy' false "common_nominator_p" e211b');
636 print("\n\nexample 212:\n");
638 val e212a'="((4) / (x)) + ((-3) / (y)) + -1";
639 val e212a = the (rewrite_set thy' false "common_nominator_p" e212a');
641 val e212b'="((4) / (x)) + ((-5) / (y)) + ((6) / (x*y))";
642 val e212b = the (rewrite_set thy' false "common_nominator_p" e212b');
644 print("\n\nexample 213:\n");
646 val e213a'="((5 * x) / (3 * y^^^2)) + ((19 * z) / (6 * x * y)) + ((-2 * x) / (3 * y^^^2)) + ((7 * y^^^2) / (6 * x^^^2)) ";
647 val e213a = the (rewrite_set thy' false "common_nominator_p" e213a');
649 val e213b'="((2 * b) / (3 * a^^^2)) + ((3 * c) / (7 * a * b)) + ((4 * b) / (3 * a^^^2)) + ((3 * a) / (7 * b^^^2))";
650 val e213b = the (rewrite_set thy' false "common_nominator_p" e213b');
652 print("\n\nexample 214:\n");
654 val e214a'="((3 * x + 2 * y + 2 * z) / (4)) + ((-5 * x + -3 * y) / (3)) + ((x + y + -2 * z) / (2))";
655 val e214a = the (rewrite_set thy' false "common_nominator_p" e214a');
657 val e214b'="((5 * x + 2 * y + z) / (2)) + ((-7 * x + -3 * y) / (3)) + ((3 * x + 6 * y + -1 * z) / (12))";
658 val e214b = the (rewrite_set thy' false "common_nominator_p" e214b');
660 print("\n\nexample 216:\n");
662 val e216a'="((2 * b + 3 * c) / (a * c)) + ((3 * a + b) / (a * b)) + ((-2 * b^^^2 + -3 * a * c) / (a * b * c))";
663 val e216a = the (rewrite_set thy' false "common_nominator_p" e216a');
665 val e216b'="((2 * a + 3 * b) / (b * c)) + ((3 * c + a) / (a * c)) + ((-2 * a^^^2 + -3 * b * c) / (a * b * c))";
666 val e216b = the (rewrite_set thy' false "common_nominator_p" e216b');
668 print("\n\nexample 217:\n");
669 val e217'="((z + -1) / (z)) + ((3 * z ^^^2 + -6 * z + 5) / (z^^^2)) + ((-4 * z^^^3 + 7 * z^^^2 + -5 * z + 5) / (z^^^3))";
670 val e217 = the (rewrite_set thy' false "common_nominator_p" e217');
673 val rls' = "common_nominator";
674 print("\n\nexample 218:\n");
675 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))";
676 val e218 = the (rewrite_set thy' false "common_nominator" e218');
678 print("\n\nexample 219:\n");
680 val e219a'="((1) / (y + 1)) + ((1) / (y + 2)) + ((1) / (y + 3))";
681 val e219a = the (rewrite_set thy' false "common_nominator" e219a');
683 val e219b'="((1) / (x + 1)) + ((1) / (x + 2)) + ((-2) / (x + 3))";
684 val e219b = the (rewrite_set thy' false "common_nominator" e219b');
686 print("\n\nexample 220:\n");
688 val e220a'="((17) / (5 * r + -2)) + ((-13) / (2 * r + 3)) + ((4) / (3 * r + -5))";
689 val e220a = the (rewrite_set thy' false "common_nominator" e220a');
691 val e220b'="((20 * a) / (a + -3)) + ((-19 * a) / (a + -4)) + ((a) / (a + -5))";
692 val e220b = the (rewrite_set thy' false "common_nominator" e220b');
694 print("\n\nexample 221:\n");
696 val e221a'="((a + b) / (a + -1 * b)) + ((a + -1 * b) / (a + b))";
697 val e221a = the (rewrite_set thy' false "common_nominator" e221a');
699 val e221b'="((x + -1 * y) / (x + y)) + ((x + y) / (x + -1 * y)) ";
700 val e221b = the (rewrite_set thy' false "common_nominator" e221b');
702 print("\n\nexample 222:\n");
704 val e222a'="((1 + -1 * x) / (1 + x)) + ((-1 + -1 * x) / (1 + -1 * x)) + ((4 * x) / (1 + -1 * x^^^2))";
705 val e222a = the (rewrite_set thy' false "common_nominator" e222a');
707 val e222b'="((1 + x ) / (1 + -1 * x)) + ((-1 + x) / (1 + x)) + ((2 * x) / (1 + -1 * x^^^2))";
708 val e222b = the (rewrite_set thy' false "common_nominator" e222b');
710 print("\n\nexample 225:\n");
712 val e225a'="((6 * a) / (a^^^2 + -64)) + ((a + 2) / (2 * a + 16)) + ((-1) / (2))";
713 val e225a = the (rewrite_set thy' false "common_nominator" e225a');
715 val e225b'="((a + 2 ) / (2 * a + 12)) + ((4 * a) / (a^^^2 + -36)) + ((-1) / (2))";
716 val e225b = the (rewrite_set thy' false "common_nominator" e225b');
718 print("\n\nexample 226:\n");
720 val e226a'="((35 * z) / (49 * z^^^2 + -4)) + -1 + ((14 * z + -1) / (14 * z + 4)) ";
721 val e226a = the (rewrite_set thy' false "common_nominator" e226a');
723 val e226b'="((45 * a * b) / (25 * a^^^2 + -9 * b^^^2)) + ((20 * a + 3 * b) / (10 * a + 6 * b)) + -2";
724 val e226b = the (rewrite_set thy' false "common_nominator" e226b');
726 print("\n\nexample 227:\n");
728 val e227a'="((6 * z + 11) / (6 * z + 14)) + ((9 * z ) / (9 * z^^^2 + -49)) + -1 ";
729 val e227a = the (rewrite_set thy' false "common_nominator" e227a');
731 val e227b'="((16 * a + 37 * b) / (4 * a + 10 * b)) + ((6 * a * b) / (4 * a^^^2 + -25 * b^^^2)) + -4 ";
732 val e227b = the (rewrite_set thy' false "common_nominator" e227b');
734 print("\n\nexample 228:\n");
736 val e228a'="((7 * a + 11) / (3 * a^^^2 + -3)) + ((-2 * a + -1) / (a^^^2 + -1 * a)) + ((-1) / (3 * a + 3))";
737 val e228a = the (rewrite_set thy' false "common_nominator" e228a');
739 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))";
740 val e228b = the (rewrite_set thy' false "common_nominator" e228b');
743 print("\n\nexample 229:\n");
745 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))";
746 val e229a = the (rewrite_set thy' false "common_nominator" e229a');
748 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))";
749 val e229b = the (rewrite_set thy' false "common_nominator" e229b');
751 print("\n\nexample 230:\n");
753 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))";
754 val e230a = the (rewrite_set thy' false "common_nominator" e230a');
756 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))";
757 val e230b = the (rewrite_set thy' false "common_nominator" e230b');
759 print("\n\nexample 231:\n");
761 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))";
762 val e231a = the (rewrite_set thy' false "common_nominator" e231a');
764 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))";
765 val e231b = the (rewrite_set thy' false "common_nominator" e231b');
767 print("\n\nexample 232:\n");
769 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))";
770 val e232a = the (rewrite_set thy' false "common_nominator" e232a');
772 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))";
773 val e232b = the (rewrite_set thy' false "common_nominator" e232b');
775 print("\n\nexample 233:\n");
777 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))";
778 val e233a = the (rewrite_set thy' false "common_nominator" e233a');
780 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))";
781 val e233b = the (rewrite_set thy' false "common_nominator" e233b');
783 print("\n\nexample 234:\n");
785 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))";
786 val e234a = the (rewrite_set thy' false "common_nominator" e234a');
788 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)) ";
789 val e234b = the (rewrite_set thy' false "common_nominator" e234b');
791 print("\n\nexample 235:\n");
793 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))";
794 val e235a = the (rewrite_set thy' false "common_nominator" e235a');
796 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)) ";
797 val e235b = the (rewrite_set thy' false "common_nominator" e235b');
799 print("\n\nexample 236:\n");
801 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))";
802 val e236a = the (rewrite_set thy' false "common_nominator" e236a');
804 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)) ";
805 val e236b = the (rewrite_set thy' false "common_nominator" e236b');
809 print("\n\nexample heuberger:\n");
810 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)";
811 val eheu = the (rewrite_set thy' false "cancel" eheu');
813 val rls' = "common_nominator_p";
814 print("\n\nexample stiefel:\n");
815 val est1'="(7) / (-14) + (-2) / (4)";
816 val est1 = the (rewrite_set thy' false "common_nominator_p" est1');
817 if est1 = ("-1 / 1",[]) then ()
818 else raise error "new behaviour in rational.sml: est1'";
820 val t = (term_of o the o (parse thy))
821 "(9 - x ^^^ 2) / (9 - 6 * x + x ^^^ 2)";
822 val Some (t',_) = factout_ thy t;
824 "(3 + x) * (3 - x) / ((3 - x) * (3 - x))";
827 "-------- reverse rewrite ----------------------------------------";
828 "-------- reverse rewrite ----------------------------------------";
829 "-------- reverse rewrite ----------------------------------------";
831 (*WN.28.8.02: tests for the 'reverse-rewrite' functions:
832 these are defined in Rationals.ML and stored in
833 the 'reverse-ruleset' cancel*)
835 (*the term for which reverse rewriting is demonstrated*)
836 val t = (term_of o the o (parse thy))
837 "(9 - x ^^^ 2) / (9 + 6 * x + x ^^^ 2)";
838 val Rrls {scr=Rfuns {init_state=ini,locate_rule=loc,
839 next_rule=nex,normal_form=nor,...},...} = cancel;
841 (*normal_form produces the result in ONE step*)
842 val Some (t',_) = nor t;
845 (*initialize the interpreter state used by the 'me'*)
846 val (t,_,revsets,_) = ini t;
848 (*find the rule 'r' to apply to term 't'*)
849 val Some r = nex revsets t;
850 (*val r = Thm ("sym_#mult_2_3","6 = 2 * 3") : rule*)
852 (*check, if the rule 'r' applied by the user to 't' belongs to the ruleset;
853 if the rule is OK, the term resulting from applying the rule is returned,too;
854 there might be several rule applications inbetween,
855 which are listed after the head in reverse order*)
856 val (r,(t,asm))::_ = loc revsets t r;
858 "(9 - x ^^^ 2) / (3 ^^^ 2 + 6 * x + x ^^^ 2)";
860 (*find the next rule to apply*)
861 val Some r = nex revsets t;
862 (*val r = Thm ("sym_#power_3_2","9 = 3 ^^^ 2") : rule*)
864 (*check the next rule*)
865 val (r,(t,asm))::_ = loc revsets t r;
867 "(3 ^^^ 2 - x ^^^ 2) / (3 ^^^ 2 + 6 * x + x ^^^ 2)";
869 (*find and check the next rules, rewrite*)
870 val Some r = nex revsets t;
871 val (r,(t,asm))::_ = loc revsets t r;
873 "(3 ^^^ 2 - x ^^^ 2) / (3 ^^^ 2 + 2 * 3 * x + x ^^^ 2)";
875 val Some r = nex revsets t;
876 val (r,(t,asm))::_ = loc revsets t r;
878 "(3 - x) * (3 + x) / (3 ^^^ 2 + 2 * 3 * x + x ^^^ 2)";
880 val Some r = nex revsets t;
881 val (r,(t,asm))::_ = loc revsets t r;
883 "(3 - x) * (3 + x) / ((3 + x) * (3 + x))";
885 val Some r = nex revsets t;
886 val (r,(t,asm))::_ = loc revsets t r;
888 if ss = "(3 - x) / (3 + x)" then ()
889 else raise error "rational.sml: new behav. in rev-set cancel";
893 "-------- 'reverse-ruleset' cancel_p -----------------------------";
894 "-------- 'reverse-ruleset' cancel_p -----------------------------";
895 "-------- 'reverse-ruleset' cancel_p -----------------------------";
896 (*WN.11.9.02: the 'reverse-ruleset' cancel_p*)
898 (*the term for which reverse rewriting is demonstrated*)
899 val t = str2term "(9 + (-1)*x^^^2) / (9 + ((-6)*x + x^^^2))";
900 val Rrls {scr=Rfuns {init_state=ini,locate_rule=loc,
901 next_rule=nex,normal_form=nor,...},...} = cancel_p;
903 (*normal_form produces the result in ONE step*)
904 val Some (t',_) = nor t;
905 term2str t' = "(3 + 1 * x) / (3 + -1 * x)";
907 (*initialize the interpreter state used by the 'me'*)
908 val Some (t', asm) = cancel_p_ thy t;
909 term2str t' = "(3 + 1 * x) / (3 + -1 * x)" (*true*);
910 terms2str asm = "[\"3 + -1 * x ~= 0\"]" (*true*);
911 val (t,_,revsets,_) = ini t;
913 (* WN.10.10.02: dieser Fall terminiert nicht
914 (make_polynomial enth"alt zu viele rules)
915 WN060823 'init_state' requires rewriting on specified location in the term
916 print_depth 99; Rfuns; print_depth 3;
917 WN060831 cycling "sym_order_mult_rls_" "sym_real_mult_assoc"
918 as was with make_polynomial before ?!?*)
920 val Some r = nex revsets t;
921 eq_Thm (r, Thm ("sym_#power_Float ((3,0), (0,0)) __ ((2,0), (0,0))",
922 mk_thm Rational.thy "9 = 3 ^^^ 2"));
923 (*WN060831 *** id_of_thm
924 Exception- ERROR raised ...
925 val (r,(t,asm))::_ = loc revsets t r;
928 val Some r = nex revsets t;
929 val (r,(t,asm))::_ = loc revsets t r;
933 print "\n\n\n****************** all tests successfull *************************\n";
937 (*WN.17.3.03 =========================================================vvv---*)
938 "-------- norm_Rational ------------------------------------------";
939 "-------- norm_Rational ------------------------------------------";
940 "-------- norm_Rational ------------------------------------------";
941 val t = str2term "(3*x+5)/18 - x/2 - -(3*x - 2)/9 = 0";
942 val Some (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
943 if term2str t' = "1 / 18 = 0" then () else raise error "rational.sml 1";
945 val t = str2term "(17*x - 51)/9 - (-(13*x - 3)/6) + 11 - (9*x - 7)/4 = 0";
946 val Some (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
947 if term2str t' = "(237 + 65 * x) / 36 = 0" then ()
948 else raise error "rational.sml 2";
950 val t = str2term "(1/2 + (5*x)/2)^^^2 - ((13*x)/2 - 5/2)^^^2 - (6*x)^^^2 + 29";
951 val Some (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
952 (*before 040209:if term2str t' = "(23 + (35 * x + -72 * x ^^^ 2)) / 1"then()*)
953 if term2str t' = "23 + 35 * x + -72 * x ^^^ 2" then ()
954 else raise error "rational.sml 3";
956 val t = str2term "Not (6*x is_atom)";
957 val Some (t',_) = rewrite_set_ thy false powers_erls t; term2str t';
959 val t = str2term "1 < 2";
960 val Some (t',_) = rewrite_set_ thy false powers_erls t; term2str t';
962 val t = str2term "(6*x)^^^2";
963 val Some (t',_) = rewrite_ thy dummy_ord powers_erls false
964 (num_str realpow_def_atom) t;
966 trace_rewrite:=false;
968 val t = str2term "-1 * (-2 * (5 / 2 * (13 * x / 2)))";
969 val Some (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
970 if term2str t' = "65 * x / 2" then () else raise error "rational.sml 4";
972 val t = str2term "1 - ((13*x)/2 - 5/2)^^^2";
973 val Some (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
974 (*bef.040209: if term2str t' = "(-21 + (130 * x + -169 * x ^^^ 2)) / 4"then()*)
975 if term2str t' = "(-21 + 130 * x + -169 * x ^^^ 2) / 4" then ()
976 else raise error "rational.sml 5";
978 (*SRAM Schalk I, p.92 Nr. 609a*)
979 val t = str2term "2*(3 - x/5)/3 - 4*(1 - x/3) - x/3 - 2*(x/2 - 1/4)/27 +5/54";
980 val Some (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
981 if term2str t' = "(-255 + 112 * x) / 135" then ()
982 else raise error "rational.sml 6";
984 (*SRAM Schalk I, p.92 Nr. 610c*)
985 val t = str2term "((x- 1)/(x+1) + 1) / ((x- 1)/(x+1) - (x+1)/(x- 1)) - 2";
986 val Some (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
987 if term2str t' = "(-3 + -1 * x) / 2" then () else raise error "rational.sml 7";
989 (*SRAM Schalk I, p.92 Nr. 476a*)
990 val t = str2term "(x^^^2/(1 - x^^^2) + 1)/(x/(1 - x) + 1) *\
991 \ (1 + x)";(*. a/b : c/d translated to a/b * d/c .*)
992 val Some (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
993 (*if term2str t' = "1 / 1" then () else raise error "rational.sml 8";3.6.03*)
994 if term2str t' = "1" then () else raise error "rational.sml 8";
996 (*............................vvv---TODO: sollte gehen mit poly_order *)
997 (*Schalk I, p.92 Nr. 472a*)
998 val t = str2term "((8*x^^^2 - 32*y^^^2)/(2*x + 4*y))/((4*x - 8*y)/(x + y))";
999 val Some (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
1000 if term2str t' = "x + y" then () else raise error "rational.sml p.92 Nr. 472a";
1002 (*Schalk I, p.70 Nr. 480b; a/b : c/d translated to a/b * d/c*)
1003 val t = str2term "((12*x*y/(9*x^^^2 - y^^^2))/\
1004 \(1/(3*x - y)^^^2 - 1/(3*x + y)^^^2)) *\
1005 \(1/(x - 5*y)^^^2 - 1/(x + 5*y)^^^2)/\
1006 \(20*x*y/(x^^^2 - 25*y^^^2))";
1007 (*... nicht simpl, zerlegt ...*)
1008 val t = str2term "((12*x*y/(9*x^^^2 - y^^^2))/\
1009 \(1/(3*x - y)^^^2 - 1/(3*x + y)^^^2))";
1010 val Some (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
1011 "(-12 * (x * y ^^^ 3) + 108 * (x * (y * x ^^^ 2))) / (12 * (x * y))";
1012 (* ~~~~~~~~~~ poly_order notwendig!*)
1013 val t = str2term "(1/(x - 5*y)^^^2 - 1/(x + 5*y)^^^2)/\
1014 \(20*x*y/(x^^^2 - 25*y^^^2))";
1015 val Some (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
1016 "(-500 * (x * y ^^^ 3) /\n (x ^^^ 4 + (625 * y ^^^ 4 + -50 * (x ^^^ 2 * y ^^^ 2))) +\n 20 * (x * (y * x ^^^ 2)) /\n (x ^^^ 4 + (625 * y ^^^ 4 + -50 * (x ^^^ 2 * y ^^^ 2)))) /\n(20 * (x * y))";
1017 trace_rewrite:=true;
1018 trace_rewrite:=false;
1020 (*WN.17.3.03 =========================================================^^^---*)
1023 (*WN.2.6.03 from rlang.sml 56a =======================================vvv---*)
1024 (*... takes uncredible much time:*)
1027 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)";
1028 val None = rewrite_set_ thy false common_nominator_p t;
1030 "----- rational.sml: add_fraction_p_ throws overflow exn ! -----\n\
1031 \----- rational.sml: add_fraction_p_ throws overflow exn ! -----\n\
1032 \----- rational.sml: add_fraction_p_ throws overflow exn ! -----\n\
1033 \----- rational.sml: add_fraction_p_ throws overflow exn ! -----\n\
1034 \----- rational.sml: add_fraction_p_ throws overflow exn ! -----\n";
1036 val t = str2term "(a + b * x) / (a + -1 * (b * x)) + (-1 * a + b * x) / (a + b * x)";
1037 val None = add_fraction_p_ thy t;
1041 GC #1.48.88.223.2775.290178: (0 ms)
1042 GC #1.48.88.223.2776.290363: (0 ms)
1043 GC #1.48.88.223.2777.290712: (0 ms)
1044 GC #1.48.88.223.2778.291102: (0 ms)
1045 GC #1.48.88.223.2779.291684: (0 ms)
1046 GC #1.48.88.223.2780.292389: (0 ms)
1047 GC #1.48.88.223.2781.293163: (0 ms)
1048 GC #1.48.88.223.2782.294133: (0 ms)
1049 GC #1.48.88.223.2783.295181: (0 ms)
1051 (*WN.2.6.03 from rlang.sml 56a =======================================^^^---*)
1055 (* 25.08.03: Durchlauf(rechen)zeit: 1 min *)
1057 (*---------vvv------------ MG: ab 1.7.03 ----------------vvv-----------*)
1059 (* ------------------------------------------------------------------- *)
1060 (* Simplifier für beliebige Buchterme *)
1061 (* ------------------------------------------------------------------- *)
1062 (*----------------------- norm_Rational_mg --------------------------*)
1063 (* ------------------------------------------------------------------- *)
1066 "-------- numeral rationals --------------------------------------";
1067 "-------- numeral rationals --------------------------------------";
1068 "-------- numeral rationals --------------------------------------";
1070 (*SRA Schalk I, p.40 Nr. 164b *)
1071 val t = str2term "(47/6 - 76/9 + 13/4)/(35/12)";
1072 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1077 else raise error "rational.sml.sml: diff.behav. in norm_Rational_mg 1";
1079 (*SRA Schalk I, p.40 Nr. 166a *)
1080 val t = str2term "((5/4)/(4+22/7) + 37/20)*(110/3 - 110/9 * 23/11)";
1081 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1086 else raise error "rational.sml.sml: diff.behav. in norm_Rational_mg 2";
1089 "-------- cancellation -------------------------------------------";
1090 "-------- cancellation -------------------------------------------";
1091 "-------- cancellation -------------------------------------------";
1093 (* e190c Stefan K.*)
1095 "((1 + 9 * a ^^^ 2)*(1 + 3 * a))/((3 * a + 9 * a ^^^ 2)*(1 + 3 * a))";
1096 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1099 "(1 + 9 * a ^^^ 2) / (3 * a + 9 * a ^^^ 2)"
1101 else raise error "rational.sml.sml: diff.behav. in norm_Rational_mg 3";
1103 (* e192b Stefan K.*)
1105 "((x ^^^ 2)*(7 * x + (-1) * y))/((y ^^^ 2)*(7 * x + (-1) * y))";
1106 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1111 else raise error "rational.sml.sml: diff.behav. in norm_Rational_mg 4";
1113 (*SRC Schalk I, p.66 Nr. 379c *)
1116 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1121 else raise error "rational.sml.sml: diff.behav. in norm_Rational_mg 5";
1123 (*SRC Schalk I, p.66 Nr. 380b *)
1125 "15*(3*x+3)*(4*x+9)/(12*(2*x+7)*(5*x+5))";
1126 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1129 "(27 + 12 * x) / (28 + 8 * x)"
1131 else raise error "rational.sml.sml: diff.behav. in norm_Rational_mg 6";
1133 (*Schalk I, p.60 Nr. 215c *)
1134 (* Falsches Ergebnis: rechnet lange und cancel_p kann nicht weiter kürzen!!!*)
1136 val t = str2term "(a+b)^^^4*(x - y)/((x - y)^^^3*(a+b)^^^2)";
1137 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1140 "(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)"
1142 else raise error "rational.sml.sml: diff.behav. in norm_Rational_mg 7";
1145 "(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)"
1146 val Some (t,_) = rewrite_set_ thy false cancel_p t;
1148 (* uncaught exception nonexhaustive binding failure
1149 raised at: stdIn:93.1-93.51 *)
1151 (*Schalk I, p.66 Nr. 381a *)
1152 (* ACHTUNG: rechnet ca. 2 Minuten !!! *)
1154 val t = str2term "18*(a+b)^^^3*(a - b)^^^2/(72*(a - b)^^^3*(a+b)^^^2)";
1155 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1158 "(a + b) / (4 * a + -4 * b)"
1159 then () else raise error "rational.sml.sml: diff.behav. in norm_Rational_mg 8";
1162 (*SRC Schalk I, p.66 Nr. 381b *)
1164 "(4*x^^^2 - 20*x + 25)/(2*x - 5)^^^3";
1165 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1170 else raise error "rational.sml.sml: diff.behav. in norm_Rational_mg 9";
1172 (*SRC Schalk I, p.66 Nr. 381c *)
1174 "(27*a^^^3+9*a^^^2+3*a+1)/(27*a^^^3+18*a^^^2+3*a)";
1175 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1178 "(1 + 9 * a ^^^ 2) / (3 * a + 9 * a ^^^ 2)"
1180 else raise error "rational.sml.sml: diff.behav. in norm_Rational_mg 10";
1182 (*SRC Schalk I, p.66 Nr. 383a *)
1184 "(5*a^^^2 - 5*a*b)/(a - b)^^^2";
1185 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1188 "5 * a / (a + -1 * b)"
1190 else raise error "rational.sml.sml: diff.behav. in norm_Rational_mg 11";
1192 "-------- common denominator -------------------------------------";
1193 "-------- common denominator -------------------------------------";
1194 "-------- common denominator -------------------------------------";
1196 (*SRA Schalk I, p.67 Nr. 403a *)
1199 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1202 "(-3 * x + 4 * y + -1 * x * y) / (x * y)"
1204 else raise error "rational.sml.sml: diff.behav. in norm_Rational_mg 12";
1206 (*SRA Schalk I, p.67 Nr. 407b *)
1208 "(2*a+3*b)/(b*c) + (3*c+a)/(a*c) - (2*a^^^2+3*b*c)/(a*b*c)";
1209 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1214 else raise error "rational.sml.sml: diff.behav. in norm_Rational_mg 13";
1216 (*SRA Schalk I, p.67 Nr. 410b *)
1218 "1/(x+1) + 1/(x+2) - 2/(x+3)";
1219 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1222 "(5 + 3 * x) / (6 + 11 * x + 6 * x ^^^ 2 + x ^^^ 3)"
1224 else raise error "rational.sml.sml: diff.behav. in norm_Rational_mg 14";
1226 (*SRA Schalk I, p.67 Nr. 413b *)
1228 "(1+x)/(1 - x) - (1 - x)/(1+x) + 2*x/(1 - x^^^2)";
1229 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1232 "6 * x / (1 + -1 * x ^^^ 2)"
1234 else raise error "rational.sml.sml: diff.behav. in norm_Rational_mg 15";
1236 (*SRA Schalk I, p.68 Nr. 414a *)
1238 "(x + 2)/(x - 1) + (x - 3)/(x - 2) - (x + 1)/((x - 1)*(x - 2))";
1239 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1242 "(-2 + -5 * x + 2 * x ^^^ 2) / (2 + -3 * x + x ^^^ 2)"
1244 else raise error "rational.sml.sml: diff.behav. in norm_Rational_mg 16";
1246 (*SRA Schalk I, p.68 Nr. 423a *)
1248 "(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)";
1249 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1254 else raise error "rational.sml.sml: diff.behav. in norm_Rational_mg 17";
1256 (*SRA Schalk I, p.68 Nr. 428b *)
1258 "1/(a - b)^^^2 + 1/(a+b)^^^2 - 2/(a^^^2 - b^^^2) - 4*(b^^^2 - 1)/(a^^^2 - b^^^2)^^^2";
1259 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1262 "4 / (a ^^^ 4 + -2 * a ^^^ 2 * b ^^^ 2 + b ^^^ 4)"
1264 else raise error "rational.sml.sml: diff.behav. in norm_Rational_mg 18";
1266 (*SRA Schalk I, p.68 Nr. 430b *)
1268 "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";
1269 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1274 else raise error "rational.sml.sml: diff.behav. in norm_Rational_mg 19";
1277 (*SRA Schalk I, p.68 Nr. 432 *)
1279 "(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)";
1280 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1285 else raise error "rational.sml.sml: diff.behav. in norm_Rational_mg 20";
1290 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1293 "(3 * y + b * x) / (b * y)"
1295 else raise error "rational.sml.sml: diff.behav. in norm_Rational_mg 21";
1298 "-------- multiply and cancel ------------------------------------";
1299 "-------- multiply and cancel ------------------------------------";
1300 "-------- multiply and cancel ------------------------------------";
1302 (*SRM Schalk I, p.68 Nr. 436a *)
1304 "3*(x+y)/(15*(x - y)) * 25*(x - y)^^^2/(18*(x+y)^^^2)";
1305 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1308 "(5 * x + -5 * y) / (18 * x + 18 * y)"
1310 else raise error "rational.sml.sml: diff.behav. in norm_Rational_mg 22";
1312 (*SRM.test Schalk I, p.68 Nr. 436b *)
1313 (*WN060420???MG3 crashes with method 'simplify' in
1314 IsacCore > Simplification > Rational Terms > Multiplication > No.2*)
1315 val t = str2term "5*a*(a - b)^^^2*(a + b)^^^3/(7*b*(a - b)^^^3) * 7*b/(a + b)^^^3";
1316 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1319 "5 * a / (a + -1 * b)"
1321 else raise error "rational.sml.sml: diff.behav. in norm_Rational_mg 23";
1323 (*Schalk I, p.68 Nr. 437a *)
1324 (* SK loops: rechnet ewig; cancel_p hängt sich auf... WN060420???MG4
1325 val t = str2term "(3*a - 4*b)/(4*c+3*e) * (3*a+4*b)/(9*a^^^2 - 16*b^^^2)";
1326 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1330 (*SK loops .. WN060420???MG5 not canceled to "1 / (4*c + 3*e)"*)
1331 val t = str2term "(3*a - 4*b) * (3*a+4*b)/((4*c+3*e)*(9*a^^^2 - 16*b^^^2))";
1332 val Some (t',_) = rewrite_set_ thy false make_polynomial t;
1333 term2str t' = "(9 * a ^^^ 2 + -16 * b ^^^ 2) /\n(36 * a ^^^ 2 * c + 27 * a ^^^ 2 * e + -64 * b ^^^ 2 * c +\n -48 * b ^^^ 2 * e)";
1334 (*..WN060831 _with_ parentheses ...*)
1335 val t'' = str2term "(9 * a ^^^ 2 + -16 * b ^^^ 2) /\
1336 \(36 * a^^^2 * c + (27 * a^^^2 * e + (-64 * b^^^2 * c + -48 * b^^^2 * e)))";
1338 val Some (t',_) = rewrite_set_ thy false cancel_p t'';
1342 (*Schalk I, p.68 Nr. 437b *)
1343 (* SK loops, Falsches Ergebnis: cancel_p kann nicht weiter kürzen!!!
1344 val t = str2term "(a + b)/(x^^^2 - y^^^2) * ((x - y)^^^2/(a^^^2 - b^^^2))";
1345 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1346 term2str t; WN060831???SK9
1347 "(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)";
1353 "(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)"; WN060831???SK10
1354 val Some (t,_) = rewrite_set_ thy false cancel_p t;
1356 uncaught exception nonexhaustive binding failure
1357 raised at: stdIn:270.1-270.51
1360 (*SRM Schalk I, p.68 Nr. 438a *)
1362 "x*y/(x*y - y^^^2)*(x^^^2 - x*y)";
1363 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1368 else raise error "rational.sml.sml: diff.behav. in norm_Rational_mg 24";
1370 (*SRM Schalk I, p.68 Nr. 439b *)
1372 "(4*x^^^2+4*x+1)*((x^^^2 - 2*x^^^3)/(4*x^^^2+2*x))";
1373 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1376 "(x + -4 * x ^^^ 3) / 2"
1378 else raise error "rational.sml.sml: diff.behav. in norm_Rational_mg 25";
1380 (*SRM Schalk I, p.68 Nr. 440a *)
1382 "(x^^^2 - 2*x)/(x^^^2 - 3*x) * (x - 3)^^^2/(x^^^2 - 4)";
1383 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1386 "(-3 + x) / (2 + x)"
1388 else raise error "rational.sml.sml: diff.behav. in norm_Rational_mg 26";
1390 (*Schalk I, p.68 Nr. 440b *)
1391 (* Achtung: rechnet ewig; cancel_p hängt sich auf... WN060831???SK11
1393 "(a^^^3 - 9*a)/(a^^^3*b - a*b^^^3)*(a^^^2*b+a*b^^^2)/(a+3)";
1394 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1399 else raise error "rational.sml.sml: diff.behav. in norm_Rational_mg 27";
1401 val t = str2term "(a^^^3 - 9*a)*(a^^^2*b+a*b^^^2)/((a^^^3*b - a*b^^^3)*(a+3))";
1402 val Some (t',_) = rewrite_set_ thy false make_polynomial t;
1404 "(-9 * a ^^^ 3 * b + -9 * a ^^^ 2 * b ^^^ 2 + a ^^^ 5 * b + a ^^^ 4 * b ^^^ 2)/
1405 (3 * a ^^^ 3 * b + -3 * a * b ^^^ 3 + a ^^^ 4 * b + -1 * a ^^^ 2 * b ^^^ 3)";
1406 val Some (t',_) = rewrite_set_ thy false cancel_p t;
1410 "-------- common denominator and multiplication ------------------";
1411 "-------- common denominator and multiplication ------------------";
1412 "-------- common denominator and multiplication ------------------";
1414 (*----------------------------------------------------------------------*)
1415 (*--------- Gemeinsamer Nenner und Multiplikation von Brüchen ----------*)
1416 (*----------------------------------------------------------------------*)
1419 (*SRAM Schalk I, p.69 Nr. 441b *)
1420 val t = str2term "(4*a/3 + 3*b^^^2/a^^^3 + b/(4*a))*(4*b/(3*a))";
1421 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1424 "(36 * b ^^^ 3 + 3 * a ^^^ 2 * b ^^^ 2 + 16 * a ^^^ 4 * b) / (9 * a ^^^ 4)"
1426 else raise error "rational.sml.sml: diff.behav. in norm_Rational_mg 28";
1428 (*SRAM Schalk I, p.69 Nr. 442b *)
1429 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)";
1430 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1433 "5 * x ^^^ 2 / (a * b ^^^ 3 * c)"
1435 else raise error "rational.sml.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"
1444 else raise error "rational.sml.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;
1453 else raise error "rational.sml.sml: diff.behav. in norm_Rational_mg 31";
1455 (*SRAM Schalk I, p.69 Nr. 446b *)
1456 val t = str2term "(x/(5*x + 4*y) - y/(5*x - 4*y) + 1)*(25*x^^^2 - 16*y^^^2)";
1457 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1460 "30 * x ^^^ 2 + -9 * x * y + -20 * y ^^^ 2"
1462 else raise error "rational.sml.sml: diff.behav. in norm_Rational_mg 32";
1464 (*SRAM Schalk I, p.69 Nr. 449a *)(*Achtung: rechnet ca 8 Sekunden*)
1466 "(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)";
1467 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1470 "(-81 * x ^^^ 4 + 16 * x ^^^ 8 * y ^^^ 4) / (81 * y ^^^ 8)"
1472 else raise error "rational.sml.sml: diff.behav. in norm_Rational_mg 33";
1474 (*SRAM Schalk I, p.69 Nr. 450a *)
1476 "(4*x/(3*y)+2*y/(3*x))^^^2 - (2*y/(3*x) - 2*x/y)*(2*y/(3*x)+2*x/y)";
1477 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1480 "(52 * x ^^^ 2 + 16 * y ^^^ 2) / (9 * y ^^^ 2)"
1482 else raise error "rational.sml.sml: diff.behav. in norm_Rational_mg 34";
1484 "-------- double fractions ---------------------------------------";
1485 "-------- double fractions ---------------------------------------";
1486 "-------- double fractions ---------------------------------------";
1488 (*SRD Schalk I, p.69 Nr. 454b *)
1490 "((2 - x)/(2*a)) / (2*a/(x - 2))";
1491 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1494 "(-4 + 4 * x + -1 * x ^^^ 2) / (4 * a ^^^ 2)"
1496 else raise error "rational.sml.sml: diff.behav. in norm_Rational_mg 35";
1498 (*SRD Schalk I, p.69 Nr. 455a *)
1500 "(a^^^2 + 1)/(a^^^2 - 1) / ((a+1)/(a - 1))";
1501 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1504 "(1 + a ^^^ 2) / (1 + 2 * a + a ^^^ 2)"
1506 else raise error "rational.sml.sml: diff.behav. in norm_Rational_mg 36";
1509 (*Schalk I, p.69 Nr. 455b *)
1510 (* Achtung: Endlosschleife
1511 val t = str2term "(x^^^2 - 4)/(y^^^2 - 9)/((2+x)/(3 - y))";
1512 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1517 else raise error "rational.sml.sml: diff.behav. in norm_Rational_mg 37";
1520 val t = str2term "(x^^^2 - 4)*(3 - y)/((y^^^2 - 9)*(2+x))";
1521 val Some (t,_) = rewrite_set_ thy false make_polynomial t;
1523 "(-12 + 4 * y + 3 * x ^^^ 2 + -1 * x ^^^ 2 * y) /
1524 (-18 + -9 * x + 2 * y ^^^ 2 + x * y ^^^ 2)"
1525 val Some (t,_) = rewrite_set_ thy false cancel_p t;
1527 (* Achtung: rechnet ewig; cancel_p hängt sich auf... ???SK*)
1529 val t = str2term "(3 + -1 * y) / (-9 + y ^^^ 2)";
1530 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1532 (*ENDLOSSCHLEIFE!!! ???MG!!!*)
1534 val t = str2term "-1 / (3 + y)";
1536 val Some (t,_) = rewrite_set_ thy false cancel_p t;
1537 term2str t = "-1 / (3 + 1 * y)";
1538 (********* Das ist das PROBLEM !!!!!!!??? *******************)
1539 (*MG: -1 im Zähler der Angabe verursacht das Problem ! WN060831???MG!!SK0*)
1542 (*SRD Schalk I, p.69 Nr. 456b *)
1544 "(b^^^3 - b^^^2)/(b^^^2+b)/(b^^^2 - 1)";
1545 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1548 "b / (1 + 2 * b + b ^^^ 2)"
1550 else raise error "rational.sml.sml: diff.behav. in norm_Rational_mg 38";
1552 (*SRD Schalk I, p.69 Nr. 457b *)
1554 "(16*a^^^2 - 9*b^^^2)/(2*a+3*a*b) / ((4*a+3*b)/(4*a^^^2 - 9*a^^^2*b^^^2))";
1555 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1558 "8 * a ^^^ 2 + -6 * a * b + -12 * a ^^^ 2 * b + 9 * a * b ^^^ 2"
1560 else raise error "rational.sml.sml: diff.behav. in norm_Rational_mg 39";
1562 (*Schalk I, p.69 Nr. 458b *)
1563 (* Achtung: rechnet ewig; cancel_p hängt sich auf... ???SK
1565 "(2*a^^^2*x - a^^^2)/(a*x - b*x) / (b^^^2*(2*x - 1)/(x*(a - b)))";
1566 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1571 else raise error "rational.sml.sml: diff.behav. in norm_Rational_mg 40";
1574 (*SRD Schalk I, p.69 Nr. 459b *)
1576 "(a^^^2 - b^^^2)/(a*b) / (4*(a+b)^^^2/a)";
1577 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1580 "(a + -1 * b) / (4 * a * b + 4 * b ^^^ 2)"
1582 else raise error "rational.sml.sml: diff.behav. in norm_Rational_mg 41";
1585 (*Schalk I, p.69 Nr. 460b *)
1586 (* Achtung: rechnet ewig; cancel_p hängt sich auf... ???SK
1588 "(9*(x^^^2 - 8*x+16)/(4*(y^^^2 - 2*y+1)))/((3*x - 12)/(16*y - 16))";
1589 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1594 else raise error "rational.sml.sml: diff.behav. in norm_Rational_mg 42";
1597 "9*(x^^^2 - 8*x+16)*(16*y - 16)/(4*(y^^^2 - 2*y+1)*(3*x - 12))";
1598 val Some (t,_) = rewrite_set_ thy false make_polynomial t;
1600 "(-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)";
1601 val Some (t,_) = rewrite_set_ thy false cancel_p t;
1605 (*SRD Schalk I, p.70 Nr. 472a *)
1606 val t = str2term "((8*x^^^2 - 32*y^^^2)/(2*x + 4*y))/\
1607 \((4*x - 8*y)/(x + y))";
1608 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1613 else raise error "rational.sml.sml: diff.behav. in norm_Rational_mg 43";
1616 (*----------------------------------------------------------------------*)
1617 (*---------------------- Einfache Dppelbrüche --------------------------*)
1618 (*----------------------------------------------------------------------*)
1620 (*SRD Schalk I, p.69 Nr. 461a *)
1622 "(2/(x+3) + 2/(x - 3)) / (8*x/(x^^^2 - 9))";
1623 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1628 else raise error "rational.sml.sml: diff.behav. in norm_Rational_mg 44";
1630 (*SRD Schalk I, p.69 Nr. 464b *)
1632 "(a - a/(a - 2)) / (a + a/(a - 2))";
1633 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1636 "(3 + -1 * a) / (1 + -1 * a)"
1638 else raise error "rational.sml.sml: diff.behav. in norm_Rational_mg 45";
1640 (*SRD Schalk I, p.69 Nr. 465b *)
1642 "((x+3*y)/9 + (4*y^^^2 - 9*z^^^2)/(16*x)) /(x/9+y/6+z/4)";
1643 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1646 "(4 * x + 6 * y + -9 * z) / (4 * x)"
1648 else raise error "rational.sml.sml: diff.behav. in norm_Rational_mg 46";
1650 (*SRD Schalk I, p.69 Nr. 466b *)
1652 "((1 - 7*(x - 2)/(x^^^2 - 4)) / (6/(x+2))) / (3/(x+5)+30/(x^^^2 - 25))";
1653 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1656 "(25 + -10 * x + x ^^^ 2) / 18"
1658 else raise error "rational.sml.sml: diff.behav. in norm_Rational_mg 47";
1660 (*SRD Schalk I, p.70 Nr. 469 *)
1662 "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))";
1663 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1666 "3 * b ^^^ 3 / (2 * a + -2 * b)"
1668 else raise error "rational.sml.sml: diff.behav. in norm_Rational_mg 48";
1670 (*----------------------------------------------------------------------*)
1671 (*---------------------- Mehrfache Dppelbrüche -------------------------*)
1672 (*----------------------------------------------------------------------*)
1674 (*SRD.test Schalk I, p.70 Nr. 476b *) (* Rechenzeit: 10 sec *)
1675 (*WN060419 crashes with method 'simplify' ???SK*)
1677 "((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)";
1678 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1681 "1 / (a ^^^ 2 + -1 * b ^^^ 2)"
1683 else raise error "rational.sml.sml: diff.behav. in norm_Rational_mg 49";
1685 (*Schalk I, p.70 Nr. 477a *)
1686 (* Achtung: rechnet ewig; Bsp zu komplex;
1687 Lösung sollte (ziemlich grosser) Faktorisierter Ausdruck sein
1688 val t = str2term "b*y/(b - 2*y)/((b^^^2 - y^^^2)/(b+2*y)) /\
1689 \(b^^^2*y+b*y^^^2)*(a+x)^^^2/((b^^^2 - 4*y^^^2)*(a+2*x)^^^2)";
1690 val Some (t',_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1692 if (term2str t') = ???SK ???MG
1695 else raise error "rational.sml.sml: diff.behav. in norm_Rational_mg 50";
1697 val t = str2term "b*y*(b+2*y)*(b^^^2 - 4*y^^^2)*(a+2*x)^^^2 / \
1698 \((b - 2*y)*(b^^^2 - y^^^2)*(b^^^2*y+b*y^^^2)*(a+x)^^^2)";
1699 val Some (t,_) = rewrite_set_ thy false make_polynomial t;
1700 term2str t; ???SK ???MG
1701 "(a ^^^ 2 * b ^^^ 4 * y + 2 * a ^^^ 2 * b ^^^ 3 * y ^^^ 2 +\n -4 * a ^^^ 2 * b ^^^ 2 * y ^^^ 3 +\n -8 * a ^^^ 2 * b * y ^^^ 4 +\n 4 * a * b ^^^ 4 * x * y +\n 8 * a * b ^^^ 3 * x * y ^^^ 2 +\n -16 * a * b ^^^ 2 * x * y ^^^ 3 +\n -32 * a * b * x * y ^^^ 4 +\n 4 * b ^^^ 4 * x ^^^ 2 * y +\n 8 * b ^^^ 3 * x ^^^ 2 * y ^^^ 2 +\n -16 * b ^^^ 2 * x ^^^ 2 * y ^^^ 3 +\n -32 * b * x ^^^ 2 * y ^^^ 4)
1702 /\n(a ^^^ 2 * b ^^^ 5 * y + -1 * a ^^^ 2 * b ^^^ 4 * y ^^^ 2 +\n -3 * a ^^^ 2 * b ^^^ 3 * y ^^^ 3 +\n a ^^^ 2 * b ^^^ 2 * y ^^^ 4 +\n 2 * a ^^^ 2 * b * y ^^^ 5 +\n 2 * a * b ^^^ 5 * x * y +\n -2 * a * b ^^^ 4 * x * y ^^^ 2 +\n -6 * a * b ^^^ 3 * x * y ^^^ 3 +\n 2 * a * b ^^^ 2 * x * y ^^^ 4 +\n 4 * a * b * x * y ^^^ 5 +\n b ^^^ 5 * x ^^^ 2 * y +\n -1 * b ^^^ 4 * x ^^^ 2 * y ^^^ 2 +\n -3 * b ^^^ 3 * x ^^^ 2 * y ^^^ 3 +\n b ^^^ 2 * x ^^^ 2 * y ^^^ 4 +\n 2 * b * x ^^^ 2 * y ^^^ 5)";
1705 (*Schalk I, p.70 Nr. 478b *) (* Rechenzeit: 5 sec *)
1706 val t = str2term "(a - (a*b+b^^^2)/(a+b))/(b+(a - b)/(1+(a+b)/(a - b))) / \
1707 \((a - a^^^2/(a+b))/(a+(a*b)/(a - b)))";
1708 val Some (t',_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1710 (* WN050820 was OK until STOP_REW_SUB introduced -- the ONLY change !!!
1713 "(2 * a ^^^ 3 + 2 * a ^^^ 2 * b) / (a ^^^ 2 * b + b ^^^ 3)"
1715 else raise error "rational.sml.sml: diff.behav. in norm_Rational_mg 51";
1716 -----------------------------------------------------------------------*)
1718 (*Schalk I, p.70 Nr. 480a *)
1719 (* SK Achtung: rechnet ewig; cancel_p kann nicht kürzen: WN060831???SK00
1721 "(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)))";
1722 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1727 else raise error "rational.sml.sml: diff.behav. in norm_Rational_mg 52";
1729 (*MG Berechne Zwischenergebnisse: WN060831???SK00*)
1731 "(1/x+1/y+1/z)/(1/x - 1/y - 1/z)";
1732 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1734 "(x ^^^ 2 * y ^^^ 2 * z + x ^^^ 2 * y * z ^^^ 2 + x * y ^^^ 2 * z ^^^ 2) /
1735 (-1 * x ^^^ 2 * y ^^^ 2 * z + -1 * x ^^^ 2 * y * z ^^^ 2 + x * y ^^^ 2 * z ^^^ 2)";
1737 "2*x^^^2/(x^^^2 - z^^^2)/(x/(x+z)+x/(x - z))";
1738 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1742 (* SK 1. Ausdruck kann nicht weiter gekürzt werden; cancel_p !!!*)
1743 ### rls: cancel_p on:
1744 (x ^^^ 2 * (y ^^^ 2 * z) + x ^^^ 2 * (y * z ^^^ 2) + x * (y ^^^ 2 * z ^^^ 2)) /
1745 (-1 * (x ^^^ 2 * (y ^^^ 2 * z)) + -1 * (x ^^^ 2 * (y * z ^^^ 2)) + x * (y ^^^ 2 * z ^^^ 2))
1746 GC #3.61.81.101.197.17503: (0 ms)
1747 *** RATIONALS_DIRECT_CANCEL_EXCEPTION: Invalid fraction
1750 "(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))";
1751 val Some (t,_) = rewrite_set_ thy false cancel_p t;
1753 (*uncaught exception nonexhaustive binding failure*)
1755 (* Das kann er aber kürzen !!???: *)
1757 "(x^^^2 * (y^^^2 * z) + x * (y^^^2 * z^^^2)) / (-1 * (x^^^2 * (y * z^^^2)) + x * (y^^^2 * z^^^2))";
1758 val Some (t,_) = rewrite_set_ thy false cancel_p t;
1760 "(-1 * (y * x) + -1 * (z * y)) / (1 * (z * x) + -1 * (z * y))";
1768 (*--------------------------------------------------------------------*)
1769 (*----------------------- Problem-Beispiele --------------------------*)
1770 (*--------------------------------------------------------------------*)
1772 (*Schalk I, p.60 Nr. 215d *)
1773 (* Achtung: rechnet ewig ...
1774 val t = str2term "(a-b)^^^3 * (x+y)^^^4 / ((x+y)^^^2 * (a-b)^^^5)";
1775 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1779 (* Kein Wunder, denn Zähler und Nenner extra als Polynom dargestellt ergibt:*)
1781 val t = str2term "(a-b)^^^3 * (x+y)^^^4";
1782 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1784 "a^^^3 * x^^^4 + 4 * a^^^3 * x^^^3 * y +\n6 * a^^^3 * x^^^2 * y^^^2 +\n4 * a^^^3 * x * y^^^3 +\na^^^3 * y^^^4 +\n-3 * a^^^2 * b * x^^^4 +\n-12 * a^^^2 * b * x^^^3 * y +\n-18 * a^^^2 * b * x^^^2 * y^^^2 +\n-12 * a^^^2 * b * x * y^^^3 +\n-3 * a^^^2 * b * y^^^4 +\n3 * a * b^^^2 * x^^^4 +\n12 * a * b^^^2 * x^^^3 * y +\n18 * a * b^^^2 * x^^^2 * y^^^2 +\n12 * a * b^^^2 * x * y^^^3 +\n3 * a * b^^^2 * y^^^4 +\n-1 * b^^^3 * x^^^4 +\n-4 * b^^^3 * x^^^3 * y +\n-6 * b^^^3 * x^^^2 * y^^^2 +\n-4 * b^^^3 * x * y^^^3 +\n-1 * b^^^3 * y^^^4";
1785 val t = str2term "((x+y)^^^2 * (a-b)^^^5)";
1786 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1788 "a^^^5 * x^^^2 + 2 * a^^^5 * x * y + a^^^5 * y^^^2 +\n-5 * a^^^4 * b * x^^^2 +\n-10 * a^^^4 * b * x * y +\n-5 * a^^^4 * b * y^^^2 +\n10 * a^^^3 * b^^^2 * x^^^2 +\n20 * a^^^3 * b^^^2 * x * y +\n10 * a^^^3 * b^^^2 * y^^^2 +\n-10 * a^^^2 * b^^^3 * x^^^2 +\n-20 * a^^^2 * b^^^3 * x * y +\n-10 * a^^^2 * b^^^3 * y^^^2 +\n5 * a * b^^^4 * x^^^2 +\n10 * a * b^^^4 * x * y +\n5 * a * b^^^4 * y^^^2 +\n-1 * b^^^5 * x^^^2 +\n-2 * b^^^5 * x * y +\n-1 * b^^^5 * y^^^2";
1790 (*anscheinend macht dem Rechner das Kürzen diese Bruches keinen Spass mehr ...*)
1792 (*--------------------------------------------------------------------*)
1793 (*Schalk I, p.70 Nr. 480b *)
1795 trace_rewrite:=false; (*sonst dauert Berechnung sehr lange!*)
1797 val t = str2term "((12*x*y/(9*x^^^2 - y^^^2))/\
1798 \(1/(3*x - y)^^^2 - 1/(3*x + y)^^^2)) *\
1799 \(1/(x - 5*y)^^^2 - 1/(x + 5*y)^^^2)/\
1800 \(20*x*y/(x^^^2 - 25*y^^^2))";
1801 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1803 "((180 * x^^^4 * y + 675 * x^^^3 * y^^^2 + 1105 * x^^^2 * y^^^3 +\n -75 * x * y^^^4 +\n -125 * y^^^5) /\n (x^^^3 + 5 * x^^^2 * y + -25 * x * y^^^2 + -125 * y^^^3) +\n (225 * x^^^2 * y^^^2 + -25 * y^^^4) /\n (x^^^2 + 10 * x * y + 25 * y^^^2)) /\n(20 * x * y)";
1805 (* Kann nicht weiter vereinfacht werden !!!!?? *)
1807 (*--------------------------------------------------------------------*)
1808 (*Seltsames in common_nominator_p: *)
1810 val t = str2term " (1 + x^^^5) / (x + y) + x^^^3 / x ";
1812 val Some (t,_) = rewrite_set_ thy false common_nominator_p t;
1815 (*### add_fraction_p_ called
1816 uncaught exception nonexhaustive binding failure
1817 raised at: stdIn:175.1-175.61*)
1819 val t = str2term " (1 + x^^^5) / (y + x) + x^^^3 / x ";
1821 val Some (t,_) = rewrite_set_ thy false common_nominator_p t;
1823 "(1 + 1 * x^^^3 + 1 * x^^^5 + 1 * (y * x^^^2)) / (1 * x + 1 * y)";
1825 (*--------------------------------------------------------------------*)
1826 (* cancel_p liefert nicht immer Polynomnormalform (2): WN060831???SK3b
1827 ---> Sortierung FALSCH !! *)
1828 val t = str2term "b^^^3 * a^^^5/a ";
1829 val Some (t,_) = rewrite_set_ thy false cancel_p t;
1831 "1 * (a^^^4 * b^^^3) / 1"; (*OK*)
1833 val t = str2term "b^^^3 * a^^^5/b ";
1834 val Some (t,_) = rewrite_set_ thy false cancel_p t;
1836 "1 * (b^^^2 * a^^^5) / 1"; (*cancel_p sortiert hier falsch um!*)
1838 (* Problem liegt NICHT bei ord_make_polynomial! (siehe folgende Bsple) *)
1840 val x = str2term "x"; val bdv = str2term "bdv";
1841 val t1 = str2term "b^^^2 * a^^^5";
1842 val t2 = str2term "a^^^5 * b^^^2 ";
1843 ord_make_polynomial false Rational.thy [(x,bdv)] (t1,t2); (*false*)
1845 (* ==> "b^^^2 * a^^^5" > "a^^^5 * b^^^2 " ... OK!*)
1847 (*--------------------------------------------------------------------*)
1848 (* cancel_p liefert nicht immer Polynomnormalform (2): WN060831???SK3c
1849 ---> erzeugt überflüssige "1 * ..."
1851 val t = str2term "-1 / (3 + y)";
1853 val Some (t,_) = rewrite_set_ thy false cancel_p t;
1856 (********* Das ist das PROBLEM !!!!!!!??? *******************)
1857 (* -1 im Zähler der Angabe verursacht das Problem !*)
1860 (* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *)
1862 (* Achtung: Endlosschleife bei cancel_p:
1863 val t = str2term "(a^^^2 - 1)/(a+1)";
1864 val Some (t,_) = rewrite_set_ thy false make_polynomial t;
1866 "(-1 + a^^^2) / (1 + a)";
1867 val Some (t,_) = rewrite_set_ thy false cancel_p t;
1869 "(-1 + 1 * a) / 1"; (*OK*)
1871 val t = str2term "(a^^^2 - 1)*(b + 1) / ((b^^^2 - 1)*(a+1))";
1872 val Some (t,_) = rewrite_set_ thy false make_polynomial t;
1874 "(-1 + -1 * b + a^^^2 + a^^^2 * b) /
1875 (-1 + -1 * a + b^^^2 + a * b^^^2)"
1876 val Some (t,_) = rewrite_set_ thy false cancel_p t;
1885 (*--------------------------------------------------------------------*)
1886 (* EHEMALIG (MG 2004) FEHLER *)
1887 (*--------------------------------------------------------------------*)
1889 (* cancel_p liefert nicht immer Polynomnormalform (2):
1890 ---> Minus (binärer Operator) wird erzeugt !!! *)
1892 val t = str2term "-1 / (5 + -2 * x)";
1893 val Some (t,_) = rewrite_set_ thy false cancel_p t;
1895 "-1 / (5 - 2 * x)";*)
1898 (*aber wenn im Zähler kein Minus tritt Problem nicht auf !!??:*)
1901 val Some (t,_) = rewrite_set_ thy false cancel_p t;
1903 "1 / (5 + -2 * x)";*)
1905 (* ACHTUNG: Endlosschleife !!! *)
1906 (*Schalk I, p.66 Nr. 381b *)
1908 "(4*x^^^2 - 20*x + 25)/(2*x - 5)^^^3";
1909 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1911 (*--------------------------------------------------------------------*)
1915 "--------------------------------------------------------------------";
1916 "----------------------- Muster-Beispiele fuer DA -------------------";
1917 "--------------------------------------------------------------------";
1919 (*SRAM Schalk I, p.69 Nr. 442b --- abgewandelt*)
1921 "(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))";
1922 val Some (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1925 "5 * x ^^^ 2 / (b ^^^ 3 * c)"
1927 else raise error "rational.sml.sml: diff.behav. in norm_Rational_mg 53";
1929 "-------- me Schalk I No.186 -------------------------------------";
1930 "-------- me Schalk I No.186 -------------------------------------";
1931 "-------- me Schalk I No.186 -------------------------------------";
1932 val fmz = ["term ((14 * x * y) / ( x * y ))",
1935 ("Rational.thy",["rational","simplification"],
1936 ["simplification","of_rationals"]);
1937 val p = e_pos'; val c = [];
1938 val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
1939 val (p,_,f,nxt,_,pt) = me nxt p c pt;
1940 val (p,_,f,nxt,_,pt) = me nxt p c pt;
1941 val (p,_,f,nxt,_,pt) = me nxt p c pt;
1942 val (p,_,f,nxt,_,pt) = me nxt p c pt;
1943 val (p,_,f,nxt,_,pt) = me nxt p c pt;
1944 val (p,_,f,nxt,_,pt) = me nxt p c pt;
1945 val (p,_,f,nxt,_,pt) = me nxt p c pt;
1946 val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
1947 val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
1948 if f2str f = "14" then ()
1949 else raise error "rational.sml diff.behav. in me Schalk I No.186";
1952 "-------- interSteps ..Simp_Rat_Double_No-1.xml ------------------";
1953 "-------- interSteps ..Simp_Rat_Double_No-1.xml ------------------";
1954 "-------- interSteps ..Simp_Rat_Double_No-1.xml ------------------";
1957 [(["term (((2 - x)/(2*a)) / (2*a/(x - 2)))", "normalform N"],
1958 ("Rational.thy",["rational","simplification"],
1959 ["simplification","of_rationals"]))];
1962 autoCalculate 1 CompleteCalc;
1963 val ((pt,p),_) = get_calc 1; show_pt pt;
1965 interSteps 1 ([1],Res);
1966 val ((pt,p),_) = get_calc 1; show_pt pt;
1969 "-------- interSteps ..Simp_Rat_Cancel_No-1.xml ------------------";
1970 "-------- interSteps ..Simp_Rat_Cancel_No-1.xml ------------------";
1971 "-------- interSteps ..Simp_Rat_Cancel_No-1.xml ------------------";
1974 [(["term ((a^2 + -1*b^2) / (a^2 + -2*a*b + b^2))", "normalform N"],
1975 ("Rational.thy",["rational","simplification"],
1976 ["simplification","of_rationals"]))];
1979 autoCalculate 1 CompleteCalc;
1980 val ((pt,p),_) = get_calc 1; show_pt pt;
1982 interSteps 1 ([1],Res);
1983 val ((pt,p),_) = get_calc 1; show_pt pt;
1985 interSteps 1 ([1,2],Res);
1986 val ((pt,p),_) = get_calc 1; show_pt pt;
1988 interSteps 1 ([1,2,1],Res);
1989 val ((pt,p),_) = get_calc 1; show_pt pt;
1990 val newnds = children (get_nd pt [1,2,1]) (*see "fun detailrls"*);
1991 if length newnds = 12 then ()
1992 else raise error "rational.sml: interSteps cancel_p rev_rew_p";
1994 val p = ([1,2,1,9],Res);
1996 val (_, tac, _) = pt_extract (pt, p);
1998 Some (Rewrite("sym_real_plus_binom_times1",
1999 "?a ^^^ 2 + -1 * ?b ^^^ 2 = (?a + 1 * ?b) * (?a + -1 * ?b)"))
2000 then () else raise error "rational.sml: getTactic, sym_real_plus_binom_times1";
2003 "-------- investigate rulesets for cancel_p ----------------------";
2004 "-------- investigate rulesets for cancel_p ----------------------";
2005 "-------- investigate rulesets for cancel_p ----------------------";
2006 val thy = Rational.thy;
2007 "---------------- (a^^^2 + -1*b^^^2) / (a^^^2 + -2*a*b + b^^^2)";
2008 val t = str2term "(a^^^2 + -1*b^^^2) / (a^^^2 + -2*a*b + b^^^2)";
2009 val tt = str2term "(1 * a + 1 * b) * (1 * a + -1 * b)"(*numerator only*);
2010 "----- with rewrite_set_";
2011 val Some (tt',asm) = rewrite_set_ thy false make_polynomial tt;
2012 term2str tt'= "a ^^^ 2 + -1 * b ^^^ 2" (*true*);
2013 val tt = str2term "((1 * a + -1 * b) * (1 * a + -1 * b))"(*denominator only*);
2014 val Some (tt',asm) = rewrite_set_ thy false make_polynomial tt;
2015 term2str tt' = "a ^^^ 2 + -2 * a * b + b ^^^ 2" (*true*);
2017 "----- with make_deriv";
2018 val Some (tt, _) = factout_p_ Isac.thy t; term2str tt =
2019 "(1 * a + 1 * b) * (1 * a + -1 * b) / ((1 * a + -1 * b) * (1 * a + -1 * b))";
2021 "--- with ruleset as before 060829";
2022 val {rules, rew_ord=(_,ro),...} =
2023 rep_rls (assoc_rls "make_polynomial");
2024 val der = make_deriv thy Atools_erls rules ro None tt;
2025 print_depth 99; map (term2str o #1) der; print_depth 3;
2026 print_depth 99; map (rule2str o #2) der; print_depth 3;
2027 ... did not terminate"*)
2028 "--- with simpler ruleset";
2029 val {rules, rew_ord=(_,ro),...} =
2030 rep_rls (assoc_rls "rev_rew_p");
2031 val der = make_deriv thy Atools_erls rules ro None tt;
2032 print_depth 99; writeln (deriv2str der); print_depth 3;
2034 print_depth 99; map (term2str o #1) der; print_depth 3;
2035 "...,(-1 * b ^^^ 2 + a ^^^ 2) / (-2 * (a * b) + a ^^^ 2 + (-1 * b) ^^^ 2) ]";
2036 print_depth 99; map (rule2str o #2) der; print_depth 3;
2037 print_depth 99; map (term2str o #1 o #3) der; print_depth 3;
2039 val der = make_deriv thy Atools_erls rules ro None
2040 (str2term "(1 * a + 1 * b) * (1 * a + -1 * b)");
2041 print_depth 99; writeln (deriv2str der); print_depth 3;
2043 val {rules, rew_ord=(_,ro),...} =
2044 rep_rls (assoc_rls "rev_rew_p");
2045 val der = make_deriv thy Atools_erls rules ro None
2046 (str2term "(1 * a + -1 * b) * (1 * a + -1 * b)");
2047 print_depth 99; writeln (deriv2str der); print_depth 3;
2048 print_depth 99; map (term2str o #1) der; print_depth 3;
2049 (*WN060829 ...postponed*)
2052 "-------- investigate format of factout_ and factout_p_ ----------";
2053 "-------- investigate format of factout_ and factout_p_ ----------";
2054 "-------- investigate format of factout_ and factout_p_ ----------";
2055 val {rules, rew_ord = (_,ro),...} = rep_rls (assoc_rls "make_polynomial");
2056 val (thy, eval_rls) = (Rational.thy, Atools_erls)(*see 'fun init_state'*);
2057 val Rrls {scr = Rfuns {init_state,...},...} = assoc_rls "cancel_p";
2059 "----- see Rational.ML, local cancel_p, fun init_state";
2060 val t = str2term "(a^^^2 + (-1)*b^^^2) / (a^^^2 + (-2)*a*b + b^^^2)";
2061 val Some (t',_) = factout_p_ thy t; term2str t';
2063 val rtas = reverse_deriv thy eval_rls rules ro None t';
2064 writeln(trtas2str rst);
2068 "----- see Rational.ML, local cancel_p, fun init_state";
2069 val t = str2term "a^^^2 / a";
2070 val Some (t',_) = factout_p_ thy t;
2071 term2str t' = "1 * a * (1 * a) / (1 * (1 * a))" (*true*);
2072 (*... can be canceled with
2073 real_mult_div_cancel2 ?k ~= 0 ==> ?m * ?k / (?n * ?k) = ?m / ?n"*)
2074 (* sml/ME/rewtools.sml:
2075 val rtas = reverse_deriv thy Atools_erls rules ro None t';
2076 writeln(deri2str rtas);
2081 "-------- SK 060904 ----------------------------------------------";
2082 "-------- SK 060904 ----------------------------------------------";
2083 "-------- SK 060904 ----------------------------------------------";
2084 "----- order on polynomials -- input + output";
2086 val t = str2term "(a + -1 * b) / (-1 * a + b)";
2087 val Some (t', _) = factout_p_ thy t; term2str t';
2088 val Some (t', _) = cancel_p_ thy t; term2str t';
2090 val t = str2term "a*b*c*d / (d*e*f*g)";
2091 val Some (t', _) = cancel_p_ thy t; term2str t';
2093 val t = str2term "a*(b*(c*d)) / (b*(e*(f*g)))";
2094 val Some (t', _) = cancel_p_ thy t; term2str t';
2097 "----- non-termination of cancel_p_ S";
2098 (*cancel_p_ does not terminate !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*)
2099 val t = str2term "(x^^^2 - 4)*(3 - y)/((y^^^2 - 9)*(2+x))";
2100 val Some (t',_) = rewrite_set_ thy false norm_Poly t;
2102 "(-12 + 4 * y + 3 * x ^^^ 2 + -1 * x ^^^ 2 * y) /\n(-18 + -9 * x + 2 * y ^^^ 2 + x * y ^^^ 2)" (*true*);
2103 (* cancel_p_ thy t';
2106 val mmm = (3,[2,1,1]);
2109 val xxx = [(1,[1,0,0]),(2,[1,1,0]),(3,[2,1,1])];