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
9 WN120317.TODO postponed test/../ratinal,ratinal2.sml to joint work with dmeind
11 nonterm.SK marks non-terminating examples
12 ord.SK PARTIALLY marks crucial ordering examples
13 *SK* of some (secondary) interest (on 070906)
14 WN060104 transfer examples marked with (*SR..*) to the exp-collection
17 "-----------------------------------------------------------------------------";
18 "-----------------------------------------------------------------------------";
19 "table of contents -----------------------------------------------------------";
20 "-----------------------------------------------------------------------------";
21 "-------- fun poly_of_term ---------------------------------------------------";
22 "-------- fun is_poly --------------------------------------------------------";
23 "-------- fun term_of_poly ---------------------------------------------------";
24 "-------- fun factout_p_ -----------------------------------------------------";
25 "-------- fun cancel_p_ ------------------------------------------------------";
26 "-------- fun common_nominator_p_ --------------------------------------------";
27 "-------- fun add_fraction_p_ ------------------------------------------------";
28 "-------- TODO ---------------------------------------------------------------";
29 "-------- and app_rev --------------------------------------------------------";
30 "-------- external calculating functions test -----------";
31 "-------- cancel from: Mathematik 1 Schalk Reniets Verlag";
32 "-------- common_nominator_p ----------------------------";
33 "-------- reverse rewrite -------------------------------";
34 "-------- 'reverse-ruleset' cancel_p --------------------";
35 "-------- norm_Rational ---------------------------------";
36 "-------- numeral rationals -----------------------------";
37 "-------- cancellation ----------------------------------";
38 "-------- common denominator ----------------------------";
39 "-------- multiply and cancel ---------------------------";
40 "-------- common denominator and multiplication ---------";
41 "-------- double fractions ------------------------------";
42 "-------- crucial examples ------------------------------";
43 "-------- examples for Stefan Karnels thesis ------------";
44 "-------- me Schalk I No.186 ----------------------------";
45 "-------- interSteps ..Simp_Rat_Double_No-1.xml ---------";
46 "-------- interSteps ..Simp_Rat_Cancel_No-1.xml ---------";
47 "-------- investigate rulesets for cancel_p -------------";
48 "-------- investigate format of factout_ and factout_p_ -";
49 "-------- how to stepwise construct Scripts -------------";
50 "----------- get_denominator ----------------------------";
51 "--------- several errpats in complicated term -------------------";
52 "--------------------------------------------------------";
53 "-------- nonterminating cancel_p, norm_Rational 2002 ---";
54 "--------------------------------------------------------";
55 "--------------------------------------------------------";
58 "-------- fun poly_of_term ---------------------------------------------------";
59 "-------- fun poly_of_term ---------------------------------------------------";
60 "-------- fun poly_of_term ---------------------------------------------------";
61 val vs = "12 * x^^^3 * y^^^4 * z^^^6" |> str2term |> vars |> map free2str |> sort string_ord;
63 if poly_of_term vs (str2term "12::real") = SOME [(12, [0, 0, 0])]
64 then () else error "poly_of_term 1 changed";
65 if poly_of_term vs (str2term "x::real") = SOME [(1, [1, 0, 0])]
66 then () else error "poly_of_term 2 changed";
67 if poly_of_term vs (str2term "12 * x^^^3") = SOME [(12, [3, 0, 0])]
68 then () else error "poly_of_term 3 changed";
69 if poly_of_term vs (str2term "12 * x^^^3 * y^^^4 * z^^^6") = SOME [(12, [3, 4, 6])]
70 then () else error "poly_of_term 4 changed";
71 if poly_of_term vs (str2term "1 + 2 * x^^^3 * y^^^4 * z^^^6 + y") =
72 SOME [(1, [0, 0, 0]), (1, [0, 1, 0]), (2, [3, 4, 6])]
73 then () else error "poly_of_term 5 changed";
75 (*poly_of_term is quite liberal:*)
76 (*the coefficient may be somewhere, the order of variables and the parentheses
77 within a monomial are arbitrary*)
78 if poly_of_term vs (str2term "y^^^4 * (x^^^3 * 12 * z^^^6)") = SOME [(12, [3, 4, 6])]
79 then () else error "poly_of_term 6 changed";
81 (*there may even be more than 1 coefficient:*)
82 if poly_of_term vs (str2term "2 * y^^^4 * (x^^^3 * 6 * z^^^6)") = SOME [(12, [3, 4, 6])]
83 then () else error "poly_of_term 7 changed";
85 (*the order and the parentheses within monomials are arbitrary:*)
86 if poly_of_term vs (str2term "2 * x^^^3 * y^^^4 * z^^^6 + (7 * y^^^8 + 1)")
87 = SOME [(1, [0, 0, 0]), (7, [0, 8, 0]), (2, [3, 4, 6])]
88 then () else error "poly_of_term 8 changed";
90 "-------- fun is_poly --------------------------------------------------------";
91 "-------- fun is_poly --------------------------------------------------------";
92 "-------- fun is_poly --------------------------------------------------------";
93 if is_poly (str2term "2 * x^^^3 * y^^^4 * z^^^6 + 7 * y^^^8 + 1")
94 then () else error "is_poly 1 changed";
95 if not (is_poly (str2term "2 * (x^^^3 * y^^^4 * z^^^6 + 7) * y^^^8 + 1"))
96 then () else error "is_poly 2 changed";
98 "-------- fun term_of_poly ---------------------------------------------------";
99 "-------- fun term_of_poly ---------------------------------------------------";
100 "-------- fun term_of_poly ---------------------------------------------------";
101 val expT = HOLogic.realT
102 val Free (_, baseT) = (hd o vars o str2term) "12 * x^^^3 * y^^^4 * z^^^6";
103 val p = [(1, [0, 0, 0]), (7, [0, 8, 0]), (2, [3, 4, 5])]
104 val vs = ["x","y","z"]
105 (*precondition for [(c, es),...]: legth es = length vs*)
107 if term2str (term_of_poly baseT expT vs p) = "1 + 7 * y ^^^ 8 + 2 * x ^^^ 3 * y ^^^ 4 * z ^^^ 5"
108 then () else error "term_of_poly 1 changed";
110 "-------- fun factout_p_ -----------------------------------------------------";
111 "-------- fun factout_p_ -----------------------------------------------------";
112 "-------- fun factout_p_ -----------------------------------------------------";
113 val t = str2term "(x^^^2 + -1*y^^^2) / (x^^^2 + -1*x*y)"
114 val SOME (t', asm) = factout_p_ thy t;
115 if term2str t' = "(x + y) * (x + -1 * y) / (x * (x + -1 * y))"
116 then () else error ("factout_p_ term 1 changed: " ^ term2str t')
118 if terms2str asm = "[\"x ~= 0\",\"x + -1 * y ~= 0\"]"
119 then () else error "factout_p_ asm 1 changed"
121 val t = str2term "nothing + to_cancel ::real";
122 if NONE = factout_p_ thy t then () else error "factout_p_ doesn't report non-applicable";
124 val t = str2term "((3 * x^^^2 + 6 *x + 3) / (2*x + 2))";
125 val SOME (t', asm) = factout_p_ thy t;
126 if term2str t' = "(3 + 3 * x) * (1 + x) / (2 * (1 + x))" andalso
127 terms2str asm = "[\"1 + x ~= 0\"]"
128 then () else error "factout_p_ 1 changed";
130 "-------- fun cancel_p_ ------------------------------------------------------";
131 "-------- fun cancel_p_ ------------------------------------------------------";
132 "-------- fun cancel_p_ ------------------------------------------------------";
133 val t = str2term "(x^^^2 + -1*y^^^2) / (x^^^2 + -1*x*y)"
134 val SOME (t', asm) = cancel_p_ thy t;
135 if (term2str t', terms2str asm) = ("(x + y) / x", "[\"x ~= 0\"]")
136 then () else error ("cancel_p_ (t', asm) 1 changed: " ^ term2str t')
138 val t = str2term "nothing + to_cancel ::real";
139 if NONE = cancel_p_ thy t then () else error "cancel_p_ doesn't report non-applicable";
141 val t = str2term "((3 * x^^^2 + 6 *x + 3) / (2*x + 2))";
142 val SOME (t', asm) = cancel_p_ thy t;
143 if term2str t' = "(3 + 3 * x) / 2" andalso terms2str asm = "[]"
144 then () else error "cancel_p_ 1 changed";
146 "-------- fun common_nominator_p_ --------------------------------------------";
147 "-------- fun common_nominator_p_ --------------------------------------------";
148 "-------- fun common_nominator_p_ --------------------------------------------";
149 val t = str2term ("y / (a*x + b*x + c*x) " ^
153 val SOME (t', asm) = common_nominator_p_ thy t;
155 ("y * y / (x * ((a + b + c) * y)) " ^
156 (* n1 *d2'/ (c'* ( d1' *d2')) *)
157 "+ a * (a + b + c) / (x * ((a + b + c) * y))")
158 (* n2 * d1' / (c'* ( d1' *d2')) *)
159 then () else error "common_nominator_p_ term 1 changed";
160 if terms2str asm = "[\"a + b + c ~= 0\",\"y ~= 0\",\"x ~= 0\"]"
161 then () else error "common_nominator_p_ asm 1 changed"
163 "-------- example in mail Nipkow";
164 val t = str2term "x/(x^^^2 + -1*y^^^2) + y/(x^^^2 + -1*x*y)";
165 val SOME (t', asm) = common_nominator_p_ thy t;
166 if term2str t' = "x * x / " ^
167 "((x + -1 * y) * ((x + y) * x))" ^
170 "((x + -1 * y) * ((x + y) * x))"
171 then () else error "common_nominator_p_ term 2 changed"
173 if terms2str asm = "[\"x + y ~= 0\",\"x ~= 0\",\"x + -1 * y ~= 0\"]"
174 then () else error "common_nominator_p_ asm 2 changed"
176 "-------- example: applicable tested by SML code";
177 val t = str2term "nothing / to_add";
178 if NONE = common_nominator_p_ thy t then () else error "common_nominator_p_ term 3 changed";
180 val t = str2term "((x + (-1)) / (x + 1)) + ((x + 1) / (x + (-1)))";
181 val SOME (t', asm) = common_nominator_p_ thy t;
183 "(x + -1) * (-1 + x) / (1 * ((1 + x) * (-1 + x))) +\n(x + 1) * (1 + x) / (1 * ((1 + x) * (-1 + x)))"
184 andalso terms2str asm = "[\"1 + x ~= 0\",\"-1 + x ~= 0\"]"
185 then () else error "common_nominator_p_ 3 changed";
187 "-------- fun add_fraction_p_ ------------------------------------------------";
188 "-------- fun add_fraction_p_ ------------------------------------------------";
189 "-------- fun add_fraction_p_ ------------------------------------------------";
190 val t = str2term "((x + (-1)) / (x + 1)) + ((x + 1) / (x + (-1)))";
191 val SOME (t', asm) = add_fraction_p_ thy t;
192 if term2str t' = "(2 + 2 * x ^^^ 2) / (-1 + x ^^^ 2)"
193 then () else error "add_fraction_p_ 3 changed";
195 if terms2str asm = "[\"-1 + x ^^^ 2 ~= 0\"]"
196 then () else error "add_fraction_p_ 3 changed";
198 val t = str2term "nothing / to_add";
199 if NONE = add_fraction_p_ thy t then () else error "add_fraction_p_ term 3 changed";
201 val t = str2term "((x + (-1)) / (x + 1)) + ((x + 1) / (x + (-1)))";
202 val SOME (t', asm) = add_fraction_p_ thy t;
203 if term2str t' = "(2 + 2 * x ^^^ 2) / (-1 + x ^^^ 2)" andalso
204 terms2str asm = "[\"-1 + x ^^^ 2 ~= 0\"]"
205 then () else error "add_fraction_p_ 3 changed";
207 "-------- TODO ---------------------------------------------------------------";
208 "-------- TODO ---------------------------------------------------------------";
209 "-------- TODO ---------------------------------------------------------------";
213 "-------- and app_rev --------------------------------------------------------";
214 "-------- and app_rev --------------------------------------------------------";
215 "-------- and app_rev --------------------------------------------------------";
216 (* trace down until prepats are evaluated
217 (which does not to work, because substitution is not done -- compare rew_sub!);
218 keep this sequence for the case, factout_p, cancel_p, common_nominator_p, add_fraction_p
219 (again) get prepat = [] changed to <>[]. *)
220 val t = str2term "(x^^^2 + -1*y^^^2) / (x^^^2 + -1*x*y)";
222 (*rewrite_set_ @{theory Isac} true cancel t = NONE; !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*)
223 "~~~~~ fun rewrite_set_, args:"; val (thy, bool, rls, term) = (thy, false, cancel_p, t);
224 "~~~~~ fun rewrite__set_, args:"; val (thy, i, _, _, (rrls as Rrls _), t) =
225 (thy, 1, bool, [], rls, term);
226 (*val (t', asm, rew) = app_rev thy (i+1) rrls t; rew = false!!!!!!!!!!!!!!!!!!!!!*)
227 "~~~~~ and app_rev, args:"; val (thy, i, rrls, t) = (thy, (i+1), rrls, t);
228 fun chk_prepat thy erls [] t = true
229 | chk_prepat thy erls prepat t =
231 fun chk (pres, pat) =
233 val subst: Type.tyenv * Envir.tenv =
234 Pattern.match thy (pat, t) (Vartab.empty, Vartab.empty)
236 snd (eval__true thy (i + 1) (map (Envir.subst_term subst) pres) [] erls)
237 end) handle _ => false
238 fun scan_ f [] = false (*scan_ NEVER called by []*)
239 | scan_ f (pp::pps) =
240 if f pp then true else scan_ f pps;
241 in scan_ chk prepat end;
242 (* apply the normal_form of a rev-set *)
243 fun app_rev' thy (Rrls{erls,prepat,scr=Rfuns{normal_form,...},...}) t =
244 if chk_prepat thy erls prepat t
245 then ((*tracing("### app_rev': t = "^(term2str t));*) normal_form t)
247 (* val opt = app_rev' thy rrls t ..NONE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*)
248 "~~~~~ and app_rev', args:"; val (thy, (Rrls{erls,prepat,scr=Rfuns{normal_form,...},...}), t) =
250 (* chk_prepat thy erls prepat t = false!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*)
251 (* app_sub thy i rrls t = false!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*)
252 "~~~~~ fun chk_prepat, args:"; val (thy, erls, prepat, t) = (thy, erls, prepat, t);
253 fun chk (pres, pat) =
255 val subst: Type.tyenv * Envir.tenv =
256 Pattern.match thy (pat, t) (Vartab.empty, Vartab.empty)
258 snd (eval__true thy (i + 1) (map (Envir.subst_term subst) pres) [] erls)
259 end) handle _ => false
260 fun scan_ f [] = false (*scan_ NEVER called by []*)
261 | scan_ f (pp::pps) =
262 if f pp then true else scan_ f pps;
264 (*========== inhibit exn WN130823: prepat is empty ====================================
265 (* scan_ chk prepat = false!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*)
266 "~~~~~ fun , args:"; val (f, (pp::pps)) = (chk, prepat);
268 val ([t1, t2], t) = pp;
269 term2str t1 = "?r is_expanded";
270 term2str t2 = "?s is_expanded";
271 term2str t = "?r / ?s";
272 (* f pp = false!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*)
273 "~~~~~ fun chk, args:"; val (pres, pat) = (pp);
274 val subst: Type.tyenv * Envir.tenv =
275 Pattern.match thy (pat, t) (Vartab.empty, Vartab.empty)
277 ({}, {(("r", 0), ("real", Var (("r", 0), "real"))),
278 (("s", 0), ("real", Var (("s", 0), "real")))}*)
280 snd (eval__true thy (i + 1) (map (Envir.subst_term subst) pres) [] erls)
281 "~~~~~ fun eval__true, args:"; val (thy, i, asms, bdv, rls) =
282 (thy, (i + 1), (map (Envir.subst_term subst) pres), [], erls);
283 terms2str asms; (* = "[\"?r is_expanded\",\"?s is_expanded\"]"*)
284 asms = [@{term True}] orelse asms = []; (* = false*)
285 asms = [@{term False}] ; (* = false*)
286 "~~~~~ fun chk, args:"; val (indets, (a::asms)) = ([], asms);
287 bdv (*= []: _a list*);
288 val bdv : (term * term) list = [];
289 rewrite__set_ thy (i+1) false;
290 term2str a = "?r is_expanded"; (*hier m"usste doch der Numerator eingesetzt sein ??????????????*)
291 val SOME (Const ("HOL.False", _), []) = rewrite__set_ thy (i+1) false bdv rls a
292 ============ inhibit exn WN130823: prepat is empty ===================================*)
294 (*========== inhibit exn WN130824 TODO =======================================================
295 "-------- external calculating functions test -----------";
296 "-------- external calculating functions test -----------";
297 "-------- external calculating functions test -----------";
298 val t = str2term "((3 * x^^^2 + 6 *x + 3) / (2*x + 2))";
299 val SOME (t', asm) = factout_p_ thy t;
300 if term2str t' = "(3 + 3 * x) * (1 + x) / (2 * (1 + x))" andalso terms2str asm = "[]"
301 then () else error "factout_p_ 1 changed";
302 val SOME (t', asm) = cancel_p_ thy t;
303 if term2str t' = "(3 + 3 * x) / 2" andalso terms2str asm = "[\"1 + x ~= 0\"]"
304 then () else error "cancel_p_ 1 changed";
306 val t = str2term "((-3 * x^^^2 + 6 *x - 3) / (2*x - 2))";
307 val SOME (t', asm) = factout_(*p_*) thy t;
308 if term2str t' = "(3 - 3 * x) * (-1 + x) / (2 * (-1 + x))" andalso terms2str asm = "[]"
309 then () else error "factout_ 2 changed";
310 val SOME (t', asm) = cancel_(*p_*) thy t;
311 if term2str t' = "(3 - 3 * x) / 2" andalso terms2str asm = "[\"-1 + x ~= 0\"]"
312 then () else error "cancel_ 2 changed";
314 val t = str2term "((x + (-1)) / (x + 1)) + ((x + 1) / (x + (-1)))";
315 val SOME (t', asm) = add_fraction_p_ thy t;
316 if term2str t' = "(2 + 2 * x ^^^ 2) / (-1 + x ^^^ 2)" andalso terms2str asm = "[]"
317 then () else error "add_fraction_p_ 3 changed";
318 val SOME (t', asm) = common_nominator_p_ thy t;
320 "(-1 + x) * (-1 + x) / ((1 + x) * (-1 + x)) +\n(1 + x) * (1 + x) / ((1 + x) * (-1 + x))"
321 andalso terms2str asm = "[]"
322 then () else error "common_nominator_p_ 3 changed";
324 val t = str2term "((x - 1) / (x + 1)) + ((x + 1) / (x - 1))";
325 val SOME (t', asm) = add_fraction_ thy t;
326 if term2str t' = "(2 + 2 * x ^^^ 2) / (-1 + x ^^^ 2)" andalso terms2str asm = "[]"
327 then () else error "factout_ 4 changed";
328 val SOME (t', asm) = common_nominator_ thy t;
330 "(-1 + x) * (-1 + x) / ((1 + x) * (-1 + x)) +\n(1 + x) * (1 + x) / ((1 + x) * (-1 + x))"
331 andalso terms2str asm = "[]"
332 then () else error "cancel_ 4 changed";
335 "((1) / (2*x + 2)) + ((1) / (2*x + (-2))) + ((1) / ( x^^^2 + (-1)))+((1) / (x^^^2 + (-2)*x + 1))";
336 val SOME (t', asm) = add_fraction_p_ thy t;
337 if term2str t' = "x / (1 + -2 * x + x ^^^ 2)" andalso terms2str asm = "[\"1 + x ~= 0\"]"
338 then () else error "add_fraction_p_ 5 changed";
339 val SOME (t', asm) = norm_rational_ thy t;
340 if term2str t' = "x / (1 + -2 * x + x ^^^ 2)" andalso terms2str asm = "[\"1 + x ~= 0\"]"
341 then () else error "norm_rational_ 5 changed";
342 ============ inhibit exn WN130826 TODO ========================================================*)
345 "-------- cancel_p from: Mathematik 1 Schalk Reniets Verlag ------------------";
346 "-------- cancel_p from: Mathematik 1 Schalk Reniets Verlag ------------------";
347 "-------- cancel_p from: Mathematik 1 Schalk Reniets Verlag ------------------";
348 val thy = @{theory "Rational"};
349 "-------- example 186a";
350 val t = str2term "(14 * x * y) / (x * y)";
351 is_expanded (str2term "14 * x * y");
352 is_expanded (str2term "x * y");
353 val SOME (t', asm) = rewrite_set_ thy false cancel_p t;
354 if (term2str t', terms2str asm) = ("14 / 1", "[]")
355 then () else error "rational.sml cancel Schalk 186a";
357 "-------- example 186b";
358 val t = str2term "(60 * a * b) / ( 15 * a * b )";
359 val SOME (t', asm) = rewrite_set_ thy false cancel_p t;
360 if (term2str t', terms2str asm) = ("4 / 1", "[]")
361 then () else error "rational.sml cancel Schalk 186b";
363 "-------- example 186c";
364 val t = str2term "(144 * a^^^2 * b * c) / (12 * a * b * c)";
365 val SOME (t', asm) = rewrite_set_ thy false cancel_p t;
366 if (term2str t', terms2str asm) = ("12 * a / 1", "[]")
367 then () else error "rational.sml cancel Schalk 186c";
369 (* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! exception Div raised !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
370 see --- fun rewrite_set_ downto fun gcd_poly ---
371 "-------- example 187a";
372 val t = str2term "(12 * x * y) / (8 * y^^^2 )";
373 val SOME (t', asm) = rewrite_set_ thy false cancel_p t;
374 if (term2str t', terms2str asm) = ("3 * x / (2 * y)", "[\"4 * y ~= 0\"]")
375 then () else error "rational.sml cancel Schalk 187a";
378 (* doesn't terminate !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
379 see --- fun rewrite_set_ downto fun gcd_poly ---
380 "-------- example 187b";
381 val t = str2term "(8 * x^^^2 * y * z ) / (18 * x * y^^^2 * z )";
382 val SOME (t', asm) = rewrite_set_ thy false cancel_p t;
383 if (term2str t', terms2str asm) = ("4 * x / (9 * y)", "[\"2 * (z * (y * x)) ~= 0\"]")
384 then () else error "rational.sml cancel Schalk 187b";
387 (* doesn't terminate !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
388 see --- fun rewrite_set_ downto fun gcd_poly ---
389 "-------- example 187c";
390 val t = str2term "(9 * x^^^5 * y^^^2 * z^^^4) / (15 * x^^^6 * y^^^3 * z )";
391 val SOME (t', asm) = rewrite_set_ thy false cancel_p t;
392 if (term2str t', terms2str asm) =
393 ("3 * z ^^^ 3 / (5 * (y * x))", "[\"3 * (z * (y ^^^ 2 * x ^^^ 5)) ~= 0\"]")
394 then () else error "rational.sml cancel Schalk 187c";
397 "-------- example 188a";
398 val t = str2term "(-8 + 8 * x) / (-9 + 9 * x)";
399 is_expanded (str2term "8 * x + -8");
400 val SOME (t', asm) = rewrite_set_ thy false cancel_p t;
401 if (term2str t', terms2str asm) = ("8 / 9", "[]")
402 then () else error "rational.sml cancel Schalk 188a";
404 val t = str2term "(8*((-1) + x))/(9*((-1) + x))";
405 val SOME (t,_) = rewrite_set_ thy false make_polynomial t;
406 if (term2str t', terms2str asm) = ("8 / 9", "[]")
407 then () else error "rational.sml cancel Schalk make_polynomial 1";
409 "-------- example 188b";
410 val t = str2term "(-15 + 5 * x) / (-18 + 6 * x)";
411 val SOME (t', asm) = rewrite_set_ thy false cancel_p t;
412 if (term2str t', terms2str asm) = ("5 / 6", "[]")
413 then () else error "rational.sml cancel Schalk 188b";
415 "-------- example 188c";
416 val t = str2term "(a + -1 * b) / (b + -1 * a)";
417 val SOME (t', asm) = rewrite_set_ thy false cancel_p t;
418 if (term2str t', terms2str asm) = ("-1 / 1", "[]")
419 then () else error "rational.sml cancel Schalk 188c";
421 is_expanded (str2term "a + -1 * b") = true;
422 val t = str2term "((-1)*(b + (-1) * a))/(1*(b + (-1) * a))";
423 val SOME (t', asm) = rewrite_set_ thy false make_polynomial t;
424 if (term2str t', terms2str asm) = ("(a + -1 * b) / (-1 * a + b)", "[]")
425 then () else error "rational.sml cancel Schalk make_polynomial 2";
427 "-------- example 190a";
428 val t = str2term "( 27 * a^^^3 + 9 * a^^^2 + 3 * a + 1 ) / ( 27 * a^^^3 + 18 * a^^^2 + 3 * a )";
429 val SOME (t', asm) = rewrite_set_ thy false cancel_p t;
430 if (term2str t', terms2str asm) =
431 ("(1 + 9 * a ^^^ 2) / (3 * a + 9 * a ^^^ 2)", "[\"3 * a + 9 * a ^^^ 2 ~= 0\"]")
432 then () else error "rational.sml cancel Schalk 190a";
434 "-------- example 190c";
435 val t = str2term "((1 + 9 * a ^^^ 2)*(1 + 3 * a))/((3 * a + 9 * a ^^^ 2)*(1 + 3 * a))";
436 val SOME (t', asm) = rewrite_set_ thy false make_polynomial t;
437 if (term2str t', terms2str asm) =
438 ("(1 + 3 * a + 9 * a ^^^ 2 + 27 * a ^^^ 3) /\n(3 * a + 18 * a ^^^ 2 + 27 * a ^^^ 3)", "[]")
439 then () else error "rational.sml make_polynomial Schalk 190c";
441 "-------- example 191a";
442 val t = str2term "( x^^^2 + -1 * y^^^2 ) / ( x + y )";
443 is_expanded (str2term "x^^^2 + -1 * y^^^2") = false; (*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*)
444 is_expanded (str2term "x + y") = true;
445 val SOME (t', asm) = rewrite_set_ thy false cancel_p t;
446 if (term2str t', terms2str asm) = ("(x + -1 * y) / 1", "[]")
447 then () else error "rational.sml make_polynomial Schalk 191a";
449 "-------- example 191b";
450 val t = str2term "((x + (-1) * y)*(x + y))/((1)*(x + y))";
451 val SOME (t', asm) = rewrite_set_ thy false make_polynomial t;
452 if (term2str t', terms2str asm) = ("(x ^^^ 2 + -1 * y ^^^ 2) / (x + y)", "[]")
453 then () else error "rational.sml make_polynomial Schalk 191b";
455 "-------- example 191c";
456 val t = str2term "( 9 * x^^^2 + -30 * x + 25 ) / ( 9 * x^^^2 + -25 )";
457 is_expanded (str2term "9 * x^^^2 + -30 * x + 25") = true;
458 is_expanded (str2term "25 + -30*x + 9*x^^^2") = true;
459 is_expanded (str2term "-25 + 9*x^^^2") = true;
461 val t = str2term "(((-5) + 3 * x)*((-5) + 3 * x))/((5 + 3 * x)*((-5) + 3 * x))";
462 val SOME (t', asm) = rewrite_set_ thy false make_polynomial t;
463 if (term2str t', terms2str asm) = ("(25 + -30 * x + 9 * x ^^^ 2) / (-25 + 9 * x ^^^ 2)", "[]")
464 then () else error "rational.sml make_polynomial Schalk 191c";
466 "-------- example 192b";
467 val t = str2term "( 7 * x^^^3 + -1 * x^^^2 * y ) / ( 7 * x * y^^^2 + -1 * y^^^3 )";
468 val SOME (t', asm) = rewrite_set_ thy false cancel_p t;
469 if (term2str t', terms2str asm) = ("x ^^^ 2 / y ^^^ 2", "[\"y ^^^ 2 ~= 0\"]")
470 then () else error "rational.sml cancel_p Schalk 192b";
472 val t = str2term "((x ^^^ 2)*(7 * x + (-1) * y))/((y ^^^ 2)*(7 * x + (-1) * y))";
473 val SOME (t', asm) = rewrite_set_ thy false make_polynomial t;
474 if (term2str t', terms2str asm) =
475 ("(7 * x ^^^ 3 + -1 * x ^^^ 2 * y) / (7 * x * y ^^^ 2 + -1 * y ^^^ 3)", "[]")
476 then () else error "rational.sml make_polynomial Schalk 192b";
478 val t = str2term "((x ^^^ 2)*(7 * x + (-1) * y))/((y ^^^ 2)*(7 * x + (-1) * y))";
479 val SOME (t', asm) = rewrite_set_ thy false make_polynomial t;
480 if (term2str t', terms2str asm) =
481 ("(7 * x ^^^ 3 + -1 * x ^^^ 2 * y) / (7 * x * y ^^^ 2 + -1 * y ^^^ 3)", "[]")
482 then () else error "rational.sml make_polynomial Schalk WN050929 not working";
484 "-------- example 193a";
485 val t = str2term "( x^^^2 + -6 * x + 9 ) / ( x^^^2 + -9 )";
486 val SOME (t', asm) = rewrite_set_ thy false cancel_p t;
487 if (term2str t', terms2str asm) = ("(-3 + x) / (3 + x)", "[\"3 + x ~= 0\"]")
488 then () else error "rational.sml cancel_p Schalk 193a";
490 "-------- example 193b";
491 val t = str2term "( x^^^2 + -8 * x + 16 ) / ( 2 * x^^^2 + -32 )";
492 val SOME (t', asm) = rewrite_set_ thy false cancel_p t;
493 if (term2str t', terms2str asm) = ("(-4 + x) / (8 + 2 * x)", "[\"8 + 2 * x ~= 0\"]")
494 then () else error "rational.sml cancel_p Schalk 193b";
496 "-------- example 193c";
497 val t = str2term "( 2 * x + -50 * x^^^3 ) / ( 25 * x^^^2 + -10 * x + 1 )";
498 val SOME (t', asm) = rewrite_set_ thy false cancel_p t;
499 if (term2str t', terms2str asm) =
500 ("(2 * x + 10 * x ^^^ 2) / (1 + -5 * x)", "[\"1 + -5 * x ~= 0\"]")
501 then () else error "rational.sml cancel_p Schalk 193c";
504 val t = str2term "(-25 + 9*x^^^2)/(5 + 3*x)";
505 val SOME (t, asm) = rewrite_set_ thy false cancel_p t;
506 if (term2str t', terms2str asm) = ("(2 * x + 10 * x ^^^ 2) / (1 + -5 * x)", "[]")
507 then () else error "rational.sml cancel WN 1";
509 (*========== inhibit exn WN130826 TODO =========================================================
510 "-------- some old tests REVISE ! --------------------------------------------";
511 "-------- some old tests REVISE ! --------------------------------------------";
512 "-------- some old tests REVISE ! --------------------------------------------";
513 (*WAS --- external calculating functions test ---*)
514 val t = str2term "((3 * x^^^2 + 6 *x + 3) / (2*x + 2))";
515 val SOME (t', asm) = factout_p_ thy t;
516 if term2str t' = "(3 + 3 * x) * (1 + x) / (2 * (1 + x))" andalso terms2str asm = "[]"
517 then () else error "factout_p_ 1 changed";
518 val SOME (t', asm) = cancel_p_ thy t;
519 if term2str t' = "(3 + 3 * x) / 2" andalso terms2str asm = "[\"1 + x ~= 0\"]"
520 then () else error "cancel_p_ 1 changed";
522 val t = str2term "((-3 * x^^^2 + 6 *x - 3) / (2*x - 2))";
523 val SOME (t', asm) = factout_(*p_*) thy t;
524 if term2str t' = "(3 - 3 * x) * (-1 + x) / (2 * (-1 + x))" andalso terms2str asm = "[]"
525 then () else error "factout_ 2 changed";
526 val SOME (t', asm) = cancel_(*p_*) thy t;
527 if term2str t' = "(3 - 3 * x) / 2" andalso terms2str asm = "[\"-1 + x ~= 0\"]"
528 then () else error "cancel_ 2 changed";
530 val t = str2term "((x + (-1)) / (x + 1)) + ((x + 1) / (x + (-1)))";
531 val SOME (t', asm) = add_fraction_p_ thy t;
532 if term2str t' = "(2 + 2 * x ^^^ 2) / (-1 + x ^^^ 2)" andalso terms2str asm = "[]"
533 then () else error "add_fraction_p_ 3 changed";
534 val SOME (t', asm) = common_nominator_p_ thy t;
536 "(-1 + x) * (-1 + x) / ((1 + x) * (-1 + x)) +\n(1 + x) * (1 + x) / ((1 + x) * (-1 + x))"
537 andalso terms2str asm = "[]"
538 then () else error "common_nominator_p_ 3 changed";
540 val t = str2term "((x - 1) / (x + 1)) + ((x + 1) / (x - 1))";
541 val SOME (t', asm) = add_fraction_ thy t;
542 if term2str t' = "(2 + 2 * x ^^^ 2) / (-1 + x ^^^ 2)" andalso terms2str asm = "[]"
543 then () else error "factout_ 4 changed";
544 val SOME (t', asm) = common_nominator_ thy t;
546 "(-1 + x) * (-1 + x) / ((1 + x) * (-1 + x)) +\n(1 + x) * (1 + x) / ((1 + x) * (-1 + x))"
547 andalso terms2str asm = "[]"
548 then () else error "cancel_ 4 changed";
551 "((1) / (2*x + 2)) + ((1) / (2*x + (-2))) + ((1) / ( x^^^2 + (-1)))+((1) / (x^^^2 + (-2)*x + 1))";
552 val SOME (t', asm) = add_fraction_p_ thy t;
553 if term2str t' = "x / (1 + -2 * x + x ^^^ 2)" andalso terms2str asm = "[\"1 + x ~= 0\"]"
554 then () else error "add_fraction_p_ 5 changed";
555 val SOME (t', asm) = norm_rational_ thy t;
556 if term2str t' = "x / (1 + -2 * x + x ^^^ 2)" andalso terms2str asm = "[\"1 + x ~= 0\"]"
557 then () else error "norm_rational_ 5 changed";
560 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))";
561 val SOME (t3',_) = common_nominator_ thy t3;
562 val SOME (t3'',_) = add_fraction_ thy t3;
566 val SOME(t4,t5) = norm_expanded_rat_ thy t3;
572 val t=(term_of o the o (parse thy)) "(9 - x^^^2)/(9 - 6*x + x^^^2)";
573 val SOME (t',_) = factout_ thy t;
574 val SOME (t'',_) = cancel_ thy t;
577 "(3 + x) * (3 - x) / ((3 - x) * (3 - x))";
580 val t=(term_of o the o (parse thy))
581 "(9 - x^^^2) / (9 - 6*x + x^^^2) + 1 / (3 - x)";
582 val SOME (t',_) = common_nominator_ thy t;
583 val SOME (t'',_) = add_fraction_ thy t;
586 "(9 - x ^^^ 2) / ((3 - x) * (3 - x)) + 1 * (3 - x) / ((3 - x) * (3 - x))";
589 (*WN021016 added -----vv---*)
590 val t = str2term "(9 - x^^^2) / (9 - 6*x + x^^^2) + 1";
591 val SOME (t',_) = common_nominator_ thy t;
592 val SOME (t'',_) = add_fraction_ thy t;
593 term2str t' = "(9 - x ^^^ 2) / (9 - 6 * x + x ^^^ 2) +\n1" ^
594 " * (9 - 6 * x + x ^^^ 2) / (9 - 6 * x + x ^^^ 2)" (*true*);
595 term2str t'' = "6 / (3 - x)" (*true*);
597 val t = str2term "1 + (9 - x^^^2) / (9 - 6*x + x^^^2)";
598 val SOME (t',_) = common_nominator_ thy t;
599 val SOME (t'',_) = add_fraction_ thy t;
600 term2str t' = "1 * (9 - 6 * x + x ^^^ 2) / (9 - 6 * x + x ^^^ 2) +\n" ^
601 "(9 - x ^^^ 2) / (9 - 6 * x + x ^^^ 2)" (*true*);
602 term2str t'' = "6 / (3 - x)" (*true*);
603 (*WN021016 added -----^^---*)
604 (*WN030602 added -----vv--- no rewrite -> NONE !*)
605 val t = str2term "1 / a";
606 val NONE = cancel_p_ thy t;
607 val NONE = rewrite_set_ thy false cancel_p t;
608 (*WN.2.6.03 added -------^^---*)
610 val t = str2term "(y^^^2 - x^^^2)/(y^^^2 - 2*y*x + x^^^2)";
611 val SOME (t',_) = factout_ thy t;
612 val SOME (t'',_) = cancel_ thy t;
613 term2str t' = "(y + x) * (y - x) / ((y - x) * (y - x))"(*true*);
614 term2str t'' = "(y + x) / (y - x)";
616 val t = str2term "(y^^^2 - x^^^2)/(y^^^2 - 2*y*x + x^^^2) + 1 / (y - x)";
617 val SOME (t',_) = common_nominator_ thy t;
618 val SOME (t'',_) = add_fraction_ thy t;
620 "(-1 * x ^^^ 2 + y ^^^ 2) / ((-1 * x + y) * (-1 * x + y)) +\n1" ^
621 " * (-1 * x + y) / ((-1 * x + y) * (-1 * x + y))" (*true*);
622 term2str t'' = "(-1 - x - y) / (x - y)" (*true*);
624 val t = str2term "(x^^^2 - y^^^2)/(x^^^2 - 2*x*y + y^^^2) + 1 / (x - y)";
625 val SOME (t',_) = common_nominator_ thy t;
626 val SOME (t'',_) = add_fraction_ thy t;
627 if term2str t' = "(-1 * y ^^^ 2 + x ^^^ 2) / ((-1 * y + x) * (-1 * y + x))" ^
628 " +\n1 * (-1 * y + x) / ((-1 * y + x) * (-1 * y + x))" then ()
629 else error "rational.sml lex-ord 1";
630 if term2str t'' = "(-1 - y - x) / (y - x)" then ()
631 else error "rational.sml lex-ord 2";
632 (*WN.16.10.02 WN070905 lexicographische Ordnung erhalten *)
635 val t = str2term "(x^^^2 - y^^^2)/(x^^^2 - 2*x*y + y^^^2)";
636 val SOME (t',_) = norm_expanded_rat_ thy t;
637 if term2str t' = "(x + y) / (x - y)" then ()
638 else error "rational.sml term2poly: invalid x ^^^ 2 - y ^^^ 2 No.1";
639 (*val SOME (t'',_) = norm_rational_ thy t;
640 *** RATIONALS_TERM2POLY_EXCEPTION: Invalid Polynomial
641 WN.16.10.02 ?! + WN060831???SK4
642 WN070905 *** term2poly: invalid = x ^^^ 2 - y ^^^ 2*)
645 val t = str2term "(9 - x^^^2)/(9 - 6*x + x^^^2) + (1)/(3 + x)";
646 val SOME (t',_) = norm_expanded_rat_ thy t;
647 if term2str t' = "(12 + 5 * x + x ^^^ 2) / (9 - x ^^^ 2)" then ()
648 else error "rational.sml (9 - x^^^2)/(9 - 6*x + x^^^2) +...";
649 (*val SOME (t'',_) = norm_rational_ thy t;
650 *** RATIONALS_TERM2POLY_EXCEPTION: Invalid Polynomial WN.16.10.02 ?!
651 WN070906 *** term2poly: invalid = 9 - x ^^^ 2 SK.term2poly*)
653 val t=(term_of o the o (parse thy))
654 "(9 + (-1)* x^^^2)/(9 + (-1)* 6*x + x^^^2) + (1)/(3 + x)";
655 val SOME (t',_) = norm_expanded_rat_ thy t;
656 val SOME (t'',_) = norm_rational_ thy t;
659 "(12 + 5 * x + x ^^^ 2) / (9 - x ^^^ 2)";
660 "(12 + 5 * x + x ^^^ 2) / (9 + (-1) * x ^^^ 2)";
663 "-------- cancel from: Mathematik 1 Schalk Reniets Verlag";
664 "-------- cancel from: Mathematik 1 Schalk Reniets Verlag";
665 "-------- cancel from: Mathematik 1 Schalk Reniets Verlag";
666 val thy = @{theory "Rational"};
667 val thy' = "Rational";
669 val mp = "make_polynomial";
671 writeln ("example 186:");
673 val e186a'="(14 * x * y) / ( x * y )";(*SRC*)
674 rewrite_set_ thy false cancel (str2term e186a');
676 val e186a = the (rewrite_set thy' false "cancel" e186a');
677 is_expanded (parse_rat "14 * x * y");
678 is_expanded (parse_rat "x * y");
679 if e186a = ("14 / 1", "[\"y * x ~= 0\"]") then ()
680 else error "rational.sml cancel Schalk e186a";
683 val e186b'="(60 * a * b) / ( 15 * a * b )";
684 val e186b = the (rewrite_set thy' false "cancel" e186b');
686 val e186c'="(144 * a^^^2 * b * c) / (12 * a * b * c )";
687 val e186c = (the (rewrite_set thy' false "cancel" e186c'))
688 handle e => print_exn_G e;
689 val t = (term_of o the o (parse thy)) e186c';
690 if e186c = ("12 * a / 1", "[\"12 * (c * (b * a)) ~= 0\"]") then ()
691 else error "rational.sml cancel Schalk e186c";
693 writeln ("example 187:");
695 val e187a'="(12 * x * y) / (8 * y^^^2 )";(*SRC*)
696 val e187a = the (rewrite_set thy' false "cancel" e187a');
698 val e187b'="(8 * x^^^2 * y * z ) / (18 * x * y^^^2 * z )";
699 val e187b = the (rewrite_set thy' false "cancel" e187b');
701 val e187d'="(9 * x^^^5 * y^^^2 * z^^^4) / (15 * x^^^6 * y^^^3 * z )";(*SRC*)
702 val e187d = the (rewrite_set thy' false "cancel" e187d');
703 if e187d = ("3 * z ^^^ 3 / (5 * (y * x))",
704 "[\"3 * (z * (y ^^^ 2 * x ^^^ 5)) ~= 0\"]") then ()
705 else error "rational.sml cancel Schalk e186d";
707 writeln "example 188:";
708 val e188a'="(-8 + 8 * x) / (-9 + 9 * x)";(*SRC*)
709 val e188a = the (rewrite_set thy' false "cancel" e188a');
710 is_expanded (parse_rat "8 * x + -8");
711 (* e188a = ("8 / 9",["not ((-1) + x = 0)"]) then () 13.3.03*)
712 if e188a = ("8 / 9", "[\"-1 + x ~= 0\"]") then ()
713 else error "rational.sml: e188a new behaviour";
715 val SOME (t,_) = rewrite_set thy' false mp "(8*((-1) + x))/(9*((-1) + x))";
717 val e188b'="(-15 + 5 * x) / (-18 + 6 * x)";(*SRC*)
718 val SOME (t, asm) = rewrite_set thy' false "cancel" e188b';
719 t = "5 / 6" (*true*);
722 val e188c'="( a + -1 * b ) / ( b + -1 * a )";
723 val e188c = the (rewrite_set thy' false "cancel_p" e188c');
724 (*is_expanded (parse_rat "a + -1 * b");*)
726 rewrite_set thy' false mp "((-1)*(b + (-1) * a))/(1*(b + (-1) * a))";
727 if t= "(a + -1 * b) / (-1 * a + b)" then()
728 else error "rational.sml: e188c new behaviour";
730 writeln ("example 190:");
732 val e190c'="( 27 * a^^^3 + 9 * a^^^2 + 3 * a + 1 ) / ( 27 * a^^^3 + 18 * a^^^2 + 3 * a )";
733 val e190c = the (rewrite_set thy' false "cancel" e190c');
734 val SOME (t,_) = rewrite_set thy' false mp "((1 + 9 * a ^^^ 2)*(1 + 3 * a))/((3 * a + 9 * a ^^^ 2)*(1 + 3 * a))";
735 if t = "(1 + 3 * a + 9 * a ^^^ 2 + 27 * a ^^^ 3) /\n(3 * a + 18 * a ^^^ 2 + 27 * a ^^^ 3)" then ()
736 else error "rational.sml: e190c new behaviour";
738 writeln ("example 191:");
740 val e191a'="( x^^^2 + -1 * y^^^2 ) / ( x + y )";
742 val e191a = the (rewrite_set thy' false "cancel" e191a');
743 is_expanded (parse_rat "x^^^2 + -1 * y^^^2");
745 is_expanded (parse_rat "x + y");
747 val SOME (t,_) = rewrite_set thy' false mp "((x + (-1) * y)*(x + y))/((1)*(x + y))";
748 (* t="(x ^^^ 2 + -1 * y ^^^ 2) / (x + y)" then() WN.13.3.03*)
749 if t="(x ^^^ 2 + -1 * y ^^^ 2) / (x + y)" then()
750 else error "rational.sml: e191a new behaviour";
753 val e191c'="( 9 * x^^^2 + -30 * x + 25 ) / ( 9 * x^^^2 + -25 )";
755 val e191c = the (rewrite_set thy' false "cancel" e191c');
756 is_expanded (parse_rat "9 * x^^^2 + -30 * x + 25");
758 is_expanded (parse_rat "25 + -30*x + 9*x^^^2");
760 is_expanded (parse_rat "-25 + 9*x^^^2");
762 val SOME (t,_) = rewrite_set thy' false mp "(((-5) + 3 * x)*((-5) + 3 * x))/((5 + 3 * x)*((-5) + 3 * x))";
763 (* t="(25 + ((-30) * x + 9 * x ^^^ 2)) / ((-25) + 9 * x ^^^ 2)"then() 13.3.03*)
764 if t= "(25 + -30 * x + 9 * x ^^^ 2) / (-25 + 9 * x ^^^ 2)" then()
765 else error "rational.sml: 'e191c' new behaviour";
768 writeln ("example 192:");
770 val e192b'="( 7 * x^^^3 + -1 * x^^^2 * y ) / ( 7 * x * y^^^2 + -1 * y^^^3 )";
772 val e192b = the (rewrite_set thy' false "cancel" e192b');
773 -------------------*)
774 val SOME (t',_) = rewrite_set thy' false mp "((x ^^^ 2)*(7 * x + (-1) * y))/((y ^^^ 2)*(7 * x + (-1) * y))";
775 (*========== inhibit exn 110317 ================================================
776 if t' = "(7 * x ^^^ 3 + -1 * x ^^^ 2 * y) / (7 * x * y ^^^ 2 + -1 * y ^^^ 3)"
777 (*"(-1 * y * x ^^^ 2 + 7 * x ^^^ 3) / (-1 * y ^^^ 3 + 7 * x * y ^^^ 2)"WN050929*)
778 then () else error "rational.sml: 'e192b' new behaviour";
779 (*^^^ works with MG's simplifier vvv*)
780 val t =str2term"((x ^^^ 2)*(7 * x + (-1) * y))/((y ^^^ 2)*(7 * x + (-1) * y))";
781 val SOME (t',_) = rewrite_set_ thy false make_polynomial t;
782 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";
783 ============ inhibit exn 110317 ==============================================*)
785 writeln ("example 193:");
787 val e193a'="( x^^^2 + -6 * x + 9 ) / ( x^^^2 + -9 )";
789 val e193a = the (rewrite_set thy' false "cancel" e193a');
790 -------------------*)
792 val e193b'="( x^^^2 + -8 * x + 16 ) / ( 2 * x^^^2 + -32 )";
794 val e193b = the (rewrite_set thy' false "cancel" e193b');
796 val e193c'="( 2 * x + -50 * x^^^3 ) / ( 25 * x^^^2 + -10 * x + 1 )";
797 val SOME(t,_) = rewrite_set thy' false "cancel" e193c';
798 -------------------*)
800 val wn01 = "(-25 + 9*x^^^2)/(5 + 3*x)";
801 val SOME (t, asm) = rewrite_set thy' false "cancel" wn01;
802 (* t = "((-5) + 3 * x) / 1" then () WN.13.3.03*)
803 if t = "(-5 + 3 * x) / 1" andalso asm = "[\"5 + 3 * x ~= 0\"]" then ()
804 else error "rational.sml: new behav. in cancel wn01";
806 "-------- common_nominator_p ----------------------------";
807 "-------- common_nominator_p ----------------------------";
808 "-------- common_nominator_p ----------------------------";
809 val rls' = "common_nominator_p";
811 writeln ("example 204:");
813 val e204a'="((5 * x) / 9) + ((3 * x) / 9) + (x / 9)";
814 val e204a = the (rewrite_set thy' false "common_nominator_p" e204a');
816 val e204b'="5 / x + -3 / x + -1 / x";
817 val e204b = the (rewrite_set thy' false "common_nominator_p" e204b');
818 if e204b = ("1 / x", "[]") then ()
819 else error "rational.sml common_nominator_p example e204b";
821 writeln ("example 205:");
823 val e205a'="((4 * x + 7) / 8) + ((4 * x + 3) / 8)";
824 val e205a = the (rewrite_set thy' false "common_nominator_p" e205a');
826 val e205b'="((5 * x + 2) / 3) + ((-2 * x + 1) / 3)";
827 val e205b = the (rewrite_set thy' false "common_nominator_p" e205b');
828 if e205b = ("(1 + x) / 1", "[]") then ()
829 else error "rational.sml common_nominator_p example e204b";
831 writeln ("example 206:");
833 val e206a'="((5 * x + 4) / (2 * x + -1)) + ((9 * x + 5) / (2 * x + -1))";
834 val e206a = the (rewrite_set thy' false "common_nominator_p" e206a');
836 val e206b'="((17 * x + -23) / (5 * x + 4)) + ((-25 + -17 * x) / (5 * x + 4))";
837 val e206b = the (rewrite_set thy' false "common_nominator_p" e206b');
839 writeln ("example 207:");
840 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)) ";
841 val e207 = the (rewrite_set thy' false "common_nominator_p" e207');
843 writeln ("example 208:");
844 val e208'="((3 * x + 2) / (x + 2)) + ((5 * x + -1) / (x + 2)) + ((-7 * x + -3) / (x + 2)) + ((-1 * x + -3) / (x + 2)) ";
845 val e208 = the (rewrite_set thy' false "common_nominator_p" e208');
847 writeln ("example 209:");
848 val e209'="((3 * x + -7 * y + 3 * z) / (4)) + ((2 * x + 17 * y + 10 * z) / (4)) + ((-1 * x + 2 * y + z) / (4)) ";
849 val e209 = the (rewrite_set thy' false "common_nominator_p" e209');
851 writeln ("example 210:");
852 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)) ";
853 val e210 = the (rewrite_set thy' false "common_nominator_p" e210');
855 writeln ("example 211:");
857 val e211a'="((b) / (a + -1 * b)) + ((-1 * a) / (a + -1 * b))";
858 val e211a = the (rewrite_set thy' false "common_nominator_p" e211a');
860 val e211b'="((b) / (b^^^2 + -1 * a^^^2)) + ((-1 * a) / (b^^^2 + -1 * a^^^2))";
861 val e211b = the (rewrite_set thy' false "common_nominator_p" e211b');
863 writeln ("example 212:");
865 val e212a'="((4) / (x)) + ((-3) / (y)) + -1";
866 val e212a = the (rewrite_set thy' false "common_nominator_p" e212a');
868 val e212b'="((4) / (x)) + ((-5) / (y)) + ((6) / (x*y))";
869 val e212b = the (rewrite_set thy' false "common_nominator_p" e212b');
871 writeln ("example 213:");
873 val e213a'="((5 * x) / (3 * y^^^2)) + ((19 * z) / (6 * x * y)) + ((-2 * x) / (3 * y^^^2)) + ((7 * y^^^2) / (6 * x^^^2)) ";
874 val e213a = the (rewrite_set thy' false "common_nominator_p" e213a');
876 val e213b'="((2 * b) / (3 * a^^^2)) + ((3 * c) / (7 * a * b)) + ((4 * b) / (3 * a^^^2)) + ((3 * a) / (7 * b^^^2))";
877 val e213b = the (rewrite_set thy' false "common_nominator_p" e213b');
879 writeln ("example 214:");
881 val e214a'="((3 * x + 2 * y + 2 * z) / (4)) + ((-5 * x + -3 * y) / (3)) + ((x + y + -2 * z) / (2))";
882 val e214a = the (rewrite_set thy' false "common_nominator_p" e214a');
884 val e214b'="((5 * x + 2 * y + z) / (2)) + ((-7 * x + -3 * y) / (3)) + ((3 * x + 6 * y + -1 * z) / (12))";
885 val e214b = the (rewrite_set thy' false "common_nominator_p" e214b');
887 writeln ("example 216:");
889 val e216a'="((2 * b + 3 * c) / (a * c)) + ((3 * a + b) / (a * b)) + ((-2 * b^^^2 + -3 * a * c) / (a * b * c))";
890 val e216a = the (rewrite_set thy' false "common_nominator_p" e216a');
892 val e216b'="((2 * a + 3 * b) / (b * c)) + ((3 * c + a) / (a * c)) + ((-2 * a^^^2 + -3 * b * c) / (a * b * c))";
893 val e216b = the (rewrite_set thy' false "common_nominator_p" e216b');
895 writeln ("example 217:");
896 val e217'="((z + -1) / (z)) + ((3 * z ^^^2 + -6 * z + 5) / (z^^^2)) + ((-4 * z^^^3 + 7 * z^^^2 + -5 * z + 5) / (z^^^3))";
897 val e217 = the (rewrite_set thy' false "common_nominator_p" e217');
900 val rls' = "common_nominator";
901 writeln ("example 218:");
902 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))";
903 val e218 = the (rewrite_set thy' false "common_nominator" e218');
904 if e218 = ("(16 - 63 * a ^^^ 2 - 81 * a ^^^ 3) / (108 * a ^^^ 4)", "[]") then ()
905 else error "rationa.sml common_nominator example e218";
907 writeln ("example 219:");
909 val e219a'="((1) / (y + 1)) + ((1) / (y + 2)) + ((1) / (y + 3))";
910 val e219a = the (rewrite_set thy' false "common_nominator" e219a');
912 val e219b'="((1) / (x + 1)) + ((1) / (x + 2)) + ((-2) / (x + 3))";
913 val e219b = the (rewrite_set thy' false "common_nominator" e219b');
914 if e219b = ("(5 + 3 * x) / (6 + 11 * x + 6 * x ^^^ 2 + x ^^^ 3)", "[]") then ()
915 else error "rationa.sml common_nominator example e219b";
917 writeln ("example 220:");
919 val e220a'="((17) / (5 * r + -2)) + ((-13) / (2 * r + 3)) + ((4) / (3 * r + -5))";
920 val e220a = the (rewrite_set thy' false "common_nominator" e220a');
922 val e220b'="((20 * a) / (a + -3)) + ((-19 * a) / (a + -4)) + ((a) / (a + -5))";
923 val e220b = the (rewrite_set thy' false "common_nominator" e220b');
925 writeln ("example 221:");
927 val e221a'="((a + b) / (a + -1 * b)) + ((a + -1 * b) / (a + b))";
928 val e221a = the (rewrite_set thy' false "common_nominator" e221a');
930 val e221b'="((x + -1 * y) / (x + y)) + ((x + y) / (x + -1 * y)) ";
931 val e221b = the (rewrite_set thy' false "common_nominator" e221b');
933 writeln ("example 222:");
935 val e222a'="((1 + -1 * x) / (1 + x)) + ((-1 + -1 * x) / (1 + -1 * x)) + ((4 * x) / (1 + -1 * x^^^2))";
936 val e222a = the (rewrite_set thy' false "common_nominator" e222a');
938 val e222b'="((1 + x ) / (1 + -1 * x)) + ((-1 + x) / (1 + x)) + ((2 * x) / (1 + -1 * x^^^2))";
939 val e222b = the (rewrite_set thy' false "common_nominator" e222b');
941 writeln ("example 225:");
943 val e225a'="((6 * a) / (a^^^2 + -64)) + ((a + 2) / (2 * a + 16)) + ((-1) / (2))";
944 val e225a = the (rewrite_set thy' false "common_nominator" e225a');
946 val e225b'="((a + 2 ) / (2 * a + 12)) + ((4 * a) / (a^^^2 + -36)) + ((-1) / (2))";
947 val e225b = the (rewrite_set thy' false "common_nominator" e225b');
949 writeln ("example 226:");
951 val e226a'="((35 * z) / (49 * z^^^2 + -4)) + -1 + ((14 * z + -1) / (14 * z + 4)) ";
952 val e226a = the (rewrite_set thy' false "common_nominator" e226a');
954 val e226b'="((45 * a * b) / (25 * a^^^2 + -9 * b^^^2)) + ((20 * a + 3 * b) / (10 * a + 6 * b)) + -2";
955 val e226b = the (rewrite_set thy' false "common_nominator" e226b');
957 writeln ("example 227:");
959 val e227a'="((6 * z + 11) / (6 * z + 14)) + ((9 * z ) / (9 * z^^^2 + -49)) + -1 ";
960 val e227a = the (rewrite_set thy' false "common_nominator" e227a');
962 val e227b'="((16 * a + 37 * b) / (4 * a + 10 * b)) + ((6 * a * b) / (4 * a^^^2 + -25 * b^^^2)) + -4 ";
963 val e227b = the (rewrite_set thy' false "common_nominator" e227b');
965 writeln ("example 228:");
967 val e228a'="((7 * a + 11) / (3 * a^^^2 + -3)) + ((-2 * a + -1) / (a^^^2 + -1 * a)) + ((-1) / (3 * a + 3))";
968 val e228a = the (rewrite_set thy' false "common_nominator" e228a');
970 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))";
971 val e228b = the (rewrite_set thy' false "common_nominator" e228b');
974 writeln ("example 229:");
976 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))";
977 val e229a = the (rewrite_set thy' false "common_nominator" e229a');
979 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))";
980 val e229b = the (rewrite_set thy' false "common_nominator" e229b');
982 writeln ("example 230:");
984 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))";
985 val e230a = the (rewrite_set thy' false "common_nominator" e230a');
987 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))";
988 val e230b = the (rewrite_set thy' false "common_nominator" e230b');
990 writeln ("example 231:");
992 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))";
993 val e231a = the (rewrite_set thy' false "common_nominator" e231a');
995 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))";
996 val e231b = the (rewrite_set thy' false "common_nominator" e231b');
998 writeln ("example 232:");
1000 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))";
1001 val e232a = the (rewrite_set thy' false "common_nominator" e232a');
1003 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))";
1004 val e232b = the (rewrite_set thy' false "common_nominator" e232b');
1006 writeln ("example 233:");
1008 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))";
1009 val e233a = the (rewrite_set thy' false "common_nominator" e233a');
1011 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))";
1012 val e233b = the (rewrite_set thy' false "common_nominator" e233b');
1014 writeln ("example 234:");
1016 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))";
1017 val e234a = the (rewrite_set thy' false "common_nominator" e234a');
1019 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)) ";
1020 val e234b = the (rewrite_set thy' false "common_nominator" e234b');
1022 writeln ("example 235:");
1024 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))";
1025 val e235a = the (rewrite_set thy' false "common_nominator" e235a');
1027 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)) ";
1028 val e235b = the (rewrite_set thy' false "common_nominator" e235b');
1030 writeln ("example 236:");
1032 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))";
1033 val e236a = the (rewrite_set thy' false "common_nominator" e236a');
1035 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)) ";
1036 val e236b = the (rewrite_set thy' false "common_nominator" e236b');
1039 val rls' = "cancel";
1040 writeln ("example heuberger:");
1041 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)";
1042 val eheu = the (rewrite_set thy' false "cancel" eheu');
1044 val rls' = "common_nominator_p";
1045 writeln ("example stiefel:");
1046 val est1'="(7) / (-14) + (-2) / (4)";
1047 val est1 = the (rewrite_set thy' false "common_nominator_p" est1');
1048 if est1 = ("-1 / 1", "[]") then ()
1049 else error "new behaviour in rational.sml: est1'";
1051 val t = (term_of o the o (parse thy))
1052 "(9 - x ^^^ 2) / (9 - 6 * x + x ^^^ 2)";
1053 val SOME (t',_) = factout_ thy t;
1054 if term2str t' = "(3 + x) * (3 - x) / ((3 - x) * (3 - x))" then ()
1055 else error "rational.sml factout_ (9 - x ^^^ 2) / (9 - 6 * x + x ^^^ 2)";
1058 "-------- reverse rewrite -------------------------------";
1059 "-------- reverse rewrite -------------------------------";
1060 "-------- reverse rewrite -------------------------------";
1061 (*WN.28.8.02: tests for the 'reverse-rewrite' functions:
1062 these are defined in Rationals.ML and stored in
1063 the 'reverse-ruleset' cancel*)
1065 (*the term for which reverse rewriting is demonstrated*)
1066 val t = (term_of o the o (parse thy))
1067 "(9 - x ^^^ 2) / (9 + 6 * x + x ^^^ 2)";
1068 val Rrls {scr=Rfuns {init_state=ini,locate_rule=loc,
1069 next_rule=nex,normal_form=nor,...},...} = cancel;
1071 (*normal_form produces the result in ONE step*)
1072 val SOME (t',_) = nor t;
1073 if term2str t' = "(3 - x) / (3 + x)" then ()
1074 else error "rational.sml normal_form (9 - x ^^^ 2) / (9 - 6 * x + x ^^^ 2)";
1076 (*initialize the interpreter state used by the 'me'*)
1077 val (t,_,revsets,_) = ini t;
1079 (*find the rule 'r' to apply to term 't'*)
1080 val SOME (r as (Thm (str, thm))) = nex revsets t;
1081 if str = "sym_#power_Float ((3,0), (0,0)) __ ((2,0), (0,0))"
1082 andalso string_of_thm thm =
1083 (string_of_thm o make_thm o (cterm_of (@{theory "Isac"})))
1084 (Trueprop $ (term_of o the o (parse thy)) "9 = 3 ^^^ 2") then ()
1085 else error "rational.sml next_rule (9 - x ^^^ 2) / (9 - 6 * x + x ^^^ 2)";
1086 (* before Isa02->09-2 was not checked automatically, ?was different?:
1087 val SOME r = nex revsets t;
1088 val r = Thm ("sym_#mult_2_3","6 = 2 * 3") : rule*)
1090 (* check, if the rule 'r' applied by the user to 't' belongs to the ruleset;
1091 if the rule is OK, the term resulting from applying the rule is returned,too;
1092 there might be several rule applications inbetween,
1093 which are listed after the head in reverse order *)
1094 val (r, (t, asm))::_ = loc revsets t r;
1095 if term2str t = "(9 - x ^^^ 2) / (3 ^^^ 2 + 6 * x + x ^^^ 2)" andalso asm = []
1097 else error "rational.sml locate_rule (9 - x ^^^ 2) / (9 - 6 * x + x ^^^ 2)";
1099 (* find the next rule to apply *)
1100 val SOME (r as (Thm (str, thm))) = nex revsets t;
1101 if str = "sym_#power_Float ((3,0), (0,0)) __ ((2,0), (0,0))" andalso
1102 string_of_thm thm = (string_of_thm o make_thm o (cterm_of (@{theory "Isac"})))
1103 (Trueprop $ (term_of o the o (parse thy)) "9 = 3 ^^^ 2") then ()
1104 else error "rational.sml next_rule (9 - x ^^^ 2) / (9 - 6 * x + x ^^^ 2)";
1106 (*check the next rule*)
1107 val (r, (t, asm)) :: _ = loc revsets t r;
1108 if term2str t = "(3 ^^^ 2 - x ^^^ 2) / (3 ^^^ 2 + 6 * x + x ^^^ 2)" then ()
1109 else error "rational.sml locate_rule (9 - x ^^^ 2) / (9 - 6 * x + x ^^^ 2) II";
1111 (*find and check the next rules, rewrite*)
1112 val SOME r = nex revsets t;
1113 val (r,(t,asm))::_ = loc revsets t r;
1114 if term2str t = "(3 ^^^ 2 - x ^^^ 2) / (3 ^^^ 2 + 2 * 3 * x + x ^^^ 2)" then ()
1115 else error "rational.sml locate_rule II";
1117 val SOME r = nex revsets t;
1118 val (r,(t,asm))::_ = loc revsets t r;
1119 if term2str t = "(3 - x) * (3 + x) / (3 ^^^ 2 + 2 * 3 * x + x ^^^ 2)" then ()
1120 else error "rational.sml next_rule II";
1122 val SOME r = nex revsets t;
1123 val (r,(t,asm))::_ = loc revsets t r;
1124 if term2str t = "(3 - x) * (3 + x) / ((3 + x) * (3 + x))" then ()
1125 else error "rational.sml next_rule III";
1127 val SOME r = nex revsets t;
1128 val (r, (t, asm)) :: _ = loc revsets t r;
1129 val ss = term2str t;
1130 if ss = "(3 - x) / (3 + x)" andalso terms2str asm = "[\"3 + x ~= 0\"]" then ()
1131 else error "rational.sml: new behav. in rev-set cancel";
1133 "-------- 'reverse-ruleset' cancel_p --------------------";
1134 "-------- 'reverse-ruleset' cancel_p --------------------";
1135 "-------- 'reverse-ruleset' cancel_p --------------------";
1136 (*WN.11.9.02: the 'reverse-ruleset' cancel_p*)
1138 (*the term for which reverse rewriting is demonstrated*)
1139 val t = str2term "(9 + (-1)*x^^^2) / (9 + ((-6)*x + x^^^2))";
1140 val Rrls {scr=Rfuns {init_state=ini,locate_rule=loc,
1141 next_rule=nex,normal_form=nor,...},...} = cancel_p;
1143 (*normal_form produces the result in ONE step*)
1144 val SOME (t',_) = nor t;
1145 term2str t' = "(3 + 1 * x) / (3 + -1 * x)";
1147 (*initialize the interpreter state used by the 'me'*)
1148 val SOME (t', asm) = cancel_p_ thy t;
1149 term2str t' = "(3 + x) / (3 + -1 * x)" (*true*);
1150 terms2str asm = "[\"3 + -1 * x ~= 0\"]" (*true*);
1151 val (t,_,revsets,_) = ini t;
1153 (* WN.10.10.02: dieser Fall terminiert nicht
1154 (make_polynomial enth"alt zu viele rules)
1155 WN060823 'init_state' requires rewriting on specified location in the term
1156 print_depth 99; Rfuns; print_depth 3;
1157 WN060831 cycling "sym_order_mult_rls_" "sym_mult_assoc"
1158 as was with make_polynomial before ?!?*)
1160 val SOME r = nex revsets t;
1161 eq_Thm (r, Thm ("sym_#power_Float ((3,0), (0,0)) __ ((2,0), (0,0))",
1162 mk_thm thy "9 = 3 ^^^ 2"));
1163 (*WN060831 *** id_of_thm
1164 Exception- ERROR raised ...
1165 val (r,(t,asm))::_ = loc revsets t r;
1168 val SOME r = nex revsets t;
1169 val (r,(t,asm))::_ = loc revsets t r;
1173 writeln "****************** all tests successfull *************************";
1177 (*WN.17.3.03 =========================================================vvv---*)
1178 "-------- norm_Rational ---------------------------------";
1179 "-------- norm_Rational ---------------------------------";
1180 "-------- norm_Rational ---------------------------------";
1181 val t = str2term "(3*x+5)/18 - x/2 - -(3*x - 2)/9 = 0";
1182 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
1183 if term2str t' = "1 / 18 = 0" then () else error "rational.sml 1";
1185 val t = str2term "(17*x - 51)/9 - (-(13*x - 3)/6) + 11 - (9*x - 7)/4 = 0";
1186 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
1187 if term2str t' = "(237 + 65 * x) / 36 = 0" then ()
1188 else error "rational.sml 2";
1190 val t = str2term "(1/2 + (5*x)/2)^^^2 - ((13*x)/2 - 5/2)^^^2 - (6*x)^^^2 + 29";
1191 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
1192 if term2str t' = "23 + 35 * x + -72 * x ^^^ 2" then ()
1193 else error "rational.sml 3";
1195 (*trace_rewrite:=true;*)
1196 val t = str2term "Not (6*x is_atom)";
1197 val SOME (t',_) = rewrite_set_ thy false powers_erls t; term2str t';
1199 val t = str2term "1 < 2";
1200 val SOME (t',_) = rewrite_set_ thy false powers_erls t; term2str t';
1203 val t = str2term "(6*x)^^^2";
1204 val SOME (t',_) = rewrite_ thy dummy_ord powers_erls false
1205 (num_str @{thm realpow_def_atom}) t;
1206 if term2str t' = "6 * x * (6 * x) ^^^ (2 + -1)" then ()
1207 else error "rational.sml powers_erls (6*x)^^^2";
1209 val t = str2term "-1 * (-2 * (5 / 2 * (13 * x / 2)))";
1210 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
1211 if term2str t' = "65 * x / 2" then () else error "rational.sml 4";
1213 val t = str2term "1 - ((13*x)/2 - 5/2)^^^2";
1214 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
1215 (*bef.040209: if term2str t' = "(-21 + (130 * x + -169 * x ^^^ 2)) / 4"then()*)
1216 if term2str t' = "(-21 + 130 * x + -169 * x ^^^ 2) / 4" then ()
1217 else error "rational.sml 5";
1219 (*SRAM Schalk I, p.92 Nr. 609a*)
1220 val t = str2term "2*(3 - x/5)/3 - 4*(1 - x/3) - x/3 - 2*(x/2 - 1/4)/27 +5/54";
1221 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
1222 if term2str t' = "(-255 + 112 * x) / 135" then ()
1223 else error "rational.sml 6";
1225 (*SRAM Schalk I, p.92 Nr. 610c*)
1226 val t = str2term "((x- 1)/(x+1) + 1) / ((x- 1)/(x+1) - (x+1)/(x- 1)) - 2";
1227 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
1228 if term2str t' = "(-3 + -1 * x) / 2" then () else error "rational.sml 7";
1230 (*SRAM Schalk I, p.92 Nr. 476a*)
1231 val t = str2term "(x^^^2/(1 - x^^^2) + 1)/(x/(1 - x) + 1) * (1 + x)";
1232 (*. a/b : c/d translated to a/b * d/c .*)
1233 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
1234 (*if term2str t' = "1 / 1" then () else error "rational.sml 8";3.6.03*)
1235 if term2str t' = "1" then () else error "rational.sml 8";
1237 (*............................vvv---TODO: sollte gehen mit poly_order *)
1238 (*Schalk I, p.92 Nr. 472a*)
1239 val t = str2term "((8*x^^^2 - 32*y^^^2)/(2*x + 4*y))/((4*x - 8*y)/(x + y))";
1240 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
1241 if term2str t' = "x + y" then () else error "rational.sml p.92 Nr. 472a";
1243 (*Schalk I, p.70 Nr. 480b; a/b : c/d translated to a/b * d/c*)
1244 val t = str2term ("((12*x*y/(9*x^^^2 - y^^^2))/" ^
1245 "(1/(3*x - y)^^^2 - 1/(3*x + y)^^^2)) *" ^
1246 "(1/(x - 5*y)^^^2 - 1/(x + 5*y)^^^2)/" ^
1247 "(20*x*y/(x^^^2 - 25*y^^^2))");
1248 (*... nicht simpl, zerlegt ...*)
1249 val t = str2term ("((12*x*y/(9*x^^^2 - y^^^2))/" ^
1250 "(1/(3*x - y)^^^2 - 1/(3*x + y)^^^2))");
1251 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
1252 "(-12 * (x * y ^^^ 3) + 108 * (x * (y * x ^^^ 2))) / (12 * (x * y))";
1253 (* ~~~~~~~~~~ poly_order notwendig!*)
1254 val t = str2term ("(1/(x - 5*y)^^^2 - 1/(x + 5*y)^^^2)/" ^
1255 "(20*x*y/(x^^^2 - 25*y^^^2))");
1256 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
1257 if term2str t' = "1 / (x ^^^ 2 + -25 * y ^^^ 2)" then ()
1258 else error "rational.sml norm_Rational 1 / (x ^^^ 2 + -25 * y ^^^ 2)";
1260 "nonterm.SK6 ----- SK060904-2a non-termination of add_fraction_p_";
1261 (*WN.2.6.03 from rlang.sml 56a
1262 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)";
1263 val NONE = rewrite_set_ thy false common_nominator_p t;
1265 WN060831 nonterm.SK7
1266 val t = str2term "(a + b * x) / (a + -1 * (b * x)) + (-1 * a + b * x) / (a + b * x)";
1267 val NONE = add_fraction_p_ thy t;
1271 (* ------------------------------------------------------------------- *)
1272 (*---------vvv------------ MG: ab 1.7.03 ----------------vvv-----------*)
1273 (* Simplifier fuer beliebige Buchterme *)
1274 (* ------------------------------------------------------------------- *)
1275 (*----------------------- norm_Rational_mg ----------------------------*)
1276 (* ------------------------------------------------------------------- *)
1278 "-------- numeral rationals -----------------------------";
1279 "-------- numeral rationals -----------------------------";
1280 "-------- numeral rationals -----------------------------";
1281 (*SRA Schalk I, p.40 Nr. 164b *)
1282 val t = str2term "(47/6 - 76/9 + 13/4)/(35/12)";
1283 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1285 if (term2str t) = "19 / 21" then ()
1286 else error "rational.sml: diff.behav. in norm_Rational_mg 1";
1288 (*SRA Schalk I, p.40 Nr. 166a *)
1289 val t = str2term "((5/4)/(4+22/7) + 37/20)*(110/3 - 110/9 * 23/11)";
1290 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1292 if (term2str t) = "45 / 2" then ()
1293 else error "rational.sml: diff.behav. in norm_Rational_mg 2";
1296 "-------- cancellation ----------------------------------";
1297 "-------- cancellation ----------------------------------";
1298 "-------- cancellation ----------------------------------";
1299 (* e190c Stefan K.*)
1301 "((1 + 9 * a ^^^ 2)*(1 + 3 * a))/((3 * a + 9 * a ^^^ 2)*(1 + 3 * a))";
1302 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1305 "(1 + 9 * a ^^^ 2) / (3 * a + 9 * a ^^^ 2)"
1307 else error "rational.sml: diff.behav. in norm_Rational_mg 3";
1309 (* e192b Stefan K.*)
1311 "((x ^^^ 2)*(7 * x + (-1) * y))/((y ^^^ 2)*(7 * x + (-1) * y))";
1312 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1317 else error "rational.sml: diff.behav. in norm_Rational_mg 4";
1319 (*SRC Schalk I, p.66 Nr. 379c *)
1322 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1327 else error "rational.sml: diff.behav. in norm_Rational_mg 5";
1329 (*SRC Schalk I, p.66 Nr. 380b *)
1331 "15*(3*x+3)*(4*x+9)/(12*(2*x+7)*(5*x+5))";
1332 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1335 "(27 + 12 * x) / (28 + 8 * x)"
1337 else error "rational.sml: diff.behav. in norm_Rational_mg 6";
1339 (*Schalk I, p.60 Nr. 215c *)
1340 (* Falsches Ergebnis: rechnet lange und cancel_p kann nicht weiter krzen!!!*)
1342 val t = str2term "(a+b)^^^4*(x - y)/((x - y)^^^3*(a+b)^^^2)";
1343 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1346 "(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)"
1348 else error "rational.sml: diff.behav. in norm_Rational_mg 7";
1351 "(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)"
1352 val SOME (t,_) = rewrite_set_ thy false cancel_p t;
1354 (* uncaught exception nonexhaustive binding failure
1355 raised at: stdIn:93.1-93.51 *)
1357 (*Schalk I, p.66 Nr. 381a *)
1358 (* ACHTUNG: rechnet ca. 2 Minuten !!! *)
1360 val t = str2term "18*(a+b)^^^3*(a - b)^^^2/(72*(a - b)^^^3*(a+b)^^^2)";
1361 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1364 "(a + b) / (4 * a + -4 * b)"
1365 then () else error "rational.sml: diff.behav. in norm_Rational_mg 8";
1368 (*SRC Schalk I, p.66 Nr. 381b *)
1370 "(4*x^^^2 - 20*x + 25)/(2*x - 5)^^^3";
1371 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1376 else error "rational.sml: diff.behav. in norm_Rational_mg 9";
1378 (*SRC Schalk I, p.66 Nr. 381c *)
1380 "(27*a^^^3+9*a^^^2+3*a+1)/(27*a^^^3+18*a^^^2+3*a)";
1381 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1384 "(1 + 9 * a ^^^ 2) / (3 * a + 9 * a ^^^ 2)"
1386 else error "rational.sml: diff.behav. in norm_Rational_mg 10";
1388 (*SRC Schalk I, p.66 Nr. 383a *)
1390 "(5*a^^^2 - 5*a*b)/(a - b)^^^2";
1391 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1394 "5 * a / (a + -1 * b)"
1396 else error "rational.sml: diff.behav. in norm_Rational_mg 11";
1399 "-------- common denominator ----------------------------";
1400 "-------- common denominator ----------------------------";
1401 "-------- common denominator ----------------------------";
1402 (*SRA Schalk I, p.67 Nr. 403a *)
1405 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1408 "(-3 * x + 4 * y + -1 * x * y) / (x * y)"
1410 else error "rational.sml: diff.behav. in norm_Rational_mg 12";
1412 (*SRA Schalk I, p.67 Nr. 407b *)
1414 "(2*a+3*b)/(b*c) + (3*c+a)/(a*c) - (2*a^^^2+3*b*c)/(a*b*c)";
1415 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1420 else error "rational.sml: diff.behav. in norm_Rational_mg 13";
1422 (*SRA Schalk I, p.67 Nr. 410b *)
1424 "1/(x+1) + 1/(x+2) - 2/(x+3)";
1425 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1428 "(5 + 3 * x) / (6 + 11 * x + 6 * x ^^^ 2 + x ^^^ 3)"
1430 else error "rational.sml: diff.behav. in norm_Rational_mg 14";
1432 (*SRA Schalk I, p.67 Nr. 413b *)
1434 "(1+x)/(1 - x) - (1 - x)/(1+x) + 2*x/(1 - x^^^2)";
1435 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1438 "6 * x / (1 + -1 * x ^^^ 2)"
1440 else error "rational.sml: diff.behav. in norm_Rational_mg 15";
1442 (*SRA Schalk I, p.68 Nr. 414a *)
1444 "(x + 2)/(x - 1) + (x - 3)/(x - 2) - (x + 1)/((x - 1)*(x - 2))";
1445 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1448 "(-2 + -5 * x + 2 * x ^^^ 2) / (2 + -3 * x + x ^^^ 2)"
1450 else error "rational.sml: diff.behav. in norm_Rational_mg 16";
1452 (*SRA Schalk I, p.68 Nr. 423a *)
1454 "(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)";
1455 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1460 else error "rational.sml: diff.behav. in norm_Rational_mg 17";
1462 (*SRA Schalk I, p.68 Nr. 428b *)
1464 "1/(a - b)^^^2 + 1/(a+b)^^^2 - 2/(a^^^2 - b^^^2) - 4*(b^^^2 - 1)/(a^^^2 - b^^^2)^^^2";
1465 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1468 "4 / (a ^^^ 4 + -2 * a ^^^ 2 * b ^^^ 2 + b ^^^ 4)"
1470 else error "rational.sml: diff.behav. in norm_Rational_mg 18";
1472 (*SRA Schalk I, p.68 Nr. 430b *)
1474 "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";
1475 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1480 else error "rational.sml: diff.behav. in norm_Rational_mg 19";
1483 (*SRA Schalk I, p.68 Nr. 432 *)
1485 "(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)";
1486 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1491 else error "rational.sml: diff.behav. in norm_Rational_mg 20";
1496 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1499 "(3 * y + b * x) / (b * y)"
1501 else error "rational.sml: diff.behav. in norm_Rational_mg 21";
1504 "-------- multiply and cancel ---------------------------";
1505 "-------- multiply and cancel ---------------------------";
1506 "-------- multiply and cancel ---------------------------";
1507 (*SRM Schalk I, p.68 Nr. 436a *)
1509 "3*(x+y)/(15*(x - y)) * 25*(x - y)^^^2/(18*(x+y)^^^2)";
1510 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1513 "(5 * x + -5 * y) / (18 * x + 18 * y)"
1515 else error "rational.sml: diff.behav. in norm_Rational_mg 22";
1517 (*SRM.test Schalk I, p.68 Nr. 436b *)
1518 (*WN060420???MG3 crashes with method 'simplify' in
1519 IsacCore > Simplification > Rational Terms > Multiplication > No.2*)
1520 val t = str2term "5*a*(a - b)^^^2*(a + b)^^^3/(7*b*(a - b)^^^3) * 7*b/(a + b)^^^3";
1521 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1524 "5 * a / (a + -1 * b)"
1526 else error "rational.sml: diff.behav. in norm_Rational_mg 23";
1528 (*Schalk I, p.68 Nr. 437a *)
1529 val t = str2term "(3*a - 4*b)/(4*c+3*e) * (3*a+4*b)/(9*a^^^2 - 16*b^^^2)";
1530 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1531 if (term2str t) = "1 / (4 * c + 3 * e)" then ()
1532 else error "rational.sml: diff.behav. in norm_Rational_mg 24";
1534 "----- S.K. corrected non-termination 060904";
1535 val t = str2term "(3*a - 4*b) * (3*a+4*b)/((4*c+3*e)*(9*a^^^2 - 16*b^^^2))";
1536 val SOME (t',_) = rewrite_set_ thy false make_polynomial t;
1539 "(9 * a ^^^ 2 + -16 * b ^^^ 2) /\n(36 * a ^^^ 2 * c + 27 * a ^^^ 2 * e + -64 * b ^^^ 2 * c +\n -48 * b ^^^ 2 * e)"
1540 (*"(9 * a ^^^ 2 + -16 * b ^^^ 2) / (36 * a ^^^ 2 * c + 27 * a ^^^ 2 * e + -64 * b ^^^ 2 * c + -48 * b ^^^ 2 * e)"*)
1541 then () else error "rational.sml: S.K.8..corrected 060904-6";
1543 "----- S.K. corrected non-termination of cancel_p_";
1544 val t'' = str2term ("(9 * a ^^^ 2 + -16 * b ^^^ 2) /" ^
1545 "(36 * a^^^2 * c + (27 * a^^^2 * e + (-64 * b^^^2 * c + -48 * b^^^2 * e)))");
1546 val SOME (t',_) = rewrite_set_ thy false cancel_p t'';
1547 if term2str t' = "1 / (4 * c + 3 * e)" then ()
1548 else error "rational.sml: diff.behav. in cancel_p S.K.8";
1550 (*Schalk I, p.68 Nr. 437b *)
1551 (* nonterm.SK9 loops: cancel_p kann nicht weiter kuerzen!!! *)
1552 val t'' = str2term "(a + b)/(x^^^2 - y^^^2) * ((x - y)^^^2/(a^^^2 - b^^^2))";
1553 (* val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t'';
1556 "================delete===";
1557 (*a casual output from above*)
1559 "(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)";
1560 (* WN060831 nonterm.SK10
1561 val SOME (t,_) = rewrite_set_ thy false cancel_p t;
1565 (*SRM Schalk I, p.68 Nr. 438a *)
1567 "x*y/(x*y - y^^^2)*(x^^^2 - x*y)";
1568 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1573 else error "rational.sml: diff.behav. in norm_Rational_mg 24";
1575 (*SRM Schalk I, p.68 Nr. 439b *)
1577 "(4*x^^^2+4*x+1)*((x^^^2 - 2*x^^^3)/(4*x^^^2+2*x))";
1578 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1581 "(x + -4 * x ^^^ 3) / 2"
1583 else error "rational.sml: diff.behav. in norm_Rational_mg 25";
1585 (*SRM Schalk I, p.68 Nr. 440a *)
1587 "(x^^^2 - 2*x)/(x^^^2 - 3*x) * (x - 3)^^^2/(x^^^2 - 4)";
1588 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1591 "(-3 + x) / (2 + x)"
1593 else error "rational.sml: diff.behav. in norm_Rational_mg 26";
1595 "----- Schalk I, p.68 Nr. 440b SK11 works since 0707xx";
1597 "(a^^^3 - 9*a)/(a^^^3*b - a*b^^^3)*(a^^^2*b+a*b^^^2)/(a+3)";
1598 val SOME (t,_) = rewrite_set_ thy false norm_Rational t;
1599 if term2str t = "(-3 * a + a ^^^ 2) / (a + -1 * b)" then ()
1600 else error "rational.sml: diff.behav. in norm_Rational 27";
1602 "----- SK12 works since 0707xx";
1603 val t = str2term "(a^^^3 - 9*a)*(a^^^2*b+a*b^^^2)/((a^^^3*b - a*b^^^3)*(a+3))";
1604 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
1605 if term2str t' = "(-3 * a + a ^^^ 2) / (a + -1 * b)" then ()
1606 else error "rational.sml: diff.behav. in norm_Rational 28";
1609 "-------- common denominator and multiplication ---------";
1610 "-------- common denominator and multiplication ---------";
1611 "-------- common denominator and multiplication ---------";
1612 (*SRAM Schalk I, p.69 Nr. 441b *)
1613 val t = str2term "(4*a/3 + 3*b^^^2/a^^^3 + b/(4*a))*(4*b/(3*a))";
1614 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1617 "(36 * b ^^^ 3 + 3 * a ^^^ 2 * b ^^^ 2 + 16 * a ^^^ 4 * b) / (9 * a ^^^ 4)"
1618 then () else error "rational.sml: diff.behav. in norm_Rational_mg 28";
1620 (*SRAM Schalk I, p.69 Nr. 442b *)
1621 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)";
1622 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1625 "5 * x ^^^ 2 / (a * b ^^^ 3 * c)"
1626 then () else error "rational.sml: diff.behav. in norm_Rational_mg 29";
1628 (*SRAM Schalk I, p.69 Nr. 443b *)
1629 val t = str2term "(a/2 + b/3)*(b/3 - a/2)";
1630 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1633 "(-9 * a ^^^ 2 + 4 * b ^^^ 2) / 36"
1634 then () else error "rational.sml: diff.behav. in norm_Rational_mg 30";
1636 (*SRAM Schalk I, p.69 Nr. 445b *)
1637 val t = str2term "(a^^^2/9 + 2*a/(3*b) + 4/b^^^2)*(a/3 - 2/b) + 8/b^^^3";
1638 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1642 then () else error "rational.sml: diff.behav. in norm_Rational_mg 31";
1644 (*SRAM Schalk I, p.69 Nr. 446b *)
1645 val t = str2term "(x/(5*x + 4*y) - y/(5*x - 4*y) + 1)*(25*x^^^2 - 16*y^^^2)";
1646 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1649 "30 * x ^^^ 2 + -9 * x * y + -20 * y ^^^ 2"
1651 else error "rational.sml: diff.behav. in norm_Rational_mg 32";
1653 (*SRAM Schalk I, p.69 Nr. 449a *)(*Achtung: rechnet ca 8 Sekunden*)
1655 "(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)";
1656 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1658 if (term2str t) = "(-81 * x ^^^ 4 + 16 * x ^^^ 8 * y ^^^ 4) / (81 * y ^^^ 8)"
1659 then () else error "rational.sml: diff.behav. in norm_Rational_mg 33";
1662 (*SRAM Schalk I, p.69 Nr. 450a *)
1664 "(4*x/(3*y)+2*y/(3*x))^^^2 - (2*y/(3*x) - 2*x/y)*(2*y/(3*x)+2*x/y)";
1665 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1668 "(52 * x ^^^ 2 + 16 * y ^^^ 2) / (9 * y ^^^ 2)"
1670 else error "rational.sml: diff.behav. in norm_Rational_mg 34";
1673 "-------- double fractions ------------------------------";
1674 "-------- double fractions ------------------------------";
1675 "-------- double fractions ------------------------------";
1676 (*SRD Schalk I, p.69 Nr. 454b *)
1678 "((2 - x)/(2*a)) / (2*a/(x - 2))";
1679 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1682 "(-4 + 4 * x + -1 * x ^^^ 2) / (4 * a ^^^ 2)"
1684 else error "rational.sml: diff.behav. in norm_Rational_mg 35";
1686 (*SRD Schalk I, p.69 Nr. 455a *)
1688 "(a^^^2 + 1)/(a^^^2 - 1) / ((a+1)/(a - 1))";
1689 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1692 "(1 + a ^^^ 2) / (1 + 2 * a + a ^^^ 2)" then ()
1693 else error "rational.sml: diff.behav. in norm_Rational_mg 36";
1696 "----- Schalk I, p.69 Nr. 455b";
1697 val t = str2term "(x^^^2 - 4)/(y^^^2 - 9)/((2+x)/(3 - y))";
1698 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1699 if term2str t = "(2 + -1 * x) / (3 + y)" then ()
1700 else error "rational.sml: diff.behav. in norm_Rational_mg 37";
1702 "----- SK060904-1a non-termination of cancel_p_ ?: worked before 0707xx";
1703 val t = str2term "(x^^^2 - 4)*(3 - y)/((y^^^2 - 9)*(2+x))";
1704 val SOME (t,_) = rewrite_set_ thy false norm_Rational t;
1705 if term2str t = "(2 + -1 * x) / (3 + y)" then ()
1706 else error "rational.sml: diff.behav. in norm_Rational_mg 37b";
1708 "----- ?: worked before 0707xx";
1709 val t = str2term "(3 + -1 * y) / (-9 + y ^^^ 2)";
1710 val SOME (t,_) = rewrite_set_ thy false norm_Rational t;
1711 if term2str t = "-1 / (3 + y)" then ()
1712 else error "rational.sml: -1 / (3 + y) norm_Rational";
1714 (*SRD Schalk I, p.69 Nr. 456b *)
1716 "(b^^^3 - b^^^2)/(b^^^2+b)/(b^^^2 - 1)";
1717 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1719 if (term2str t) = "b / (1 + 2 * b + b ^^^ 2)" then ()
1720 else error "rational.sml: diff.behav. in norm_Rational_mg 38";
1722 (*SRD Schalk I, p.69 Nr. 457b *)
1724 "(16*a^^^2 - 9*b^^^2)/(2*a+3*a*b) / ((4*a+3*b)/(4*a^^^2 - 9*a^^^2*b^^^2))";
1725 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1728 "8 * a ^^^ 2 + -6 * a * b + -12 * a ^^^ 2 * b + 9 * a * b ^^^ 2"
1729 then () else error "rational.sml: diff.behav. in norm_Rational_mg 39";
1731 "----- Schalk I, p.69 Nr. 458b works since 0707";
1733 "(2*a^^^2*x - a^^^2)/(a*x - b*x) / (b^^^2*(2*x - 1)/(x*(a - b)))";
1734 val SOME (t,_) = rewrite_set_ thy false norm_Rational t;
1735 if term2str t = "a ^^^ 2 / b ^^^ 2" then ()
1736 else error "rational.sml: diff.behav. in norm_Rational_mg 39b";
1738 (*SRD Schalk I, p.69 Nr. 459b *)
1739 val t = str2term "(a^^^2 - b^^^2)/(a*b) / (4*(a+b)^^^2/a)";
1740 val SOME (t,_) = rewrite_set_ thy false norm_Rational t;
1741 if term2str t = "(a + -1 * b) / (4 * a * b + 4 * b ^^^ 2)" then ()
1742 else error "rational.sml: diff.behav. in norm_Rational_mg 41";
1745 (*Schalk I, p.69 Nr. 460b nonterm.SK
1747 "(9*(x^^^2 - 8*x+16)/(4*(y^^^2 - 2*y+1)))/((3*x - 12)/(16*y - 16))";
1748 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1751 else error "rational.sml: diff.behav. in norm_Rational_mg 42";
1754 "9*(x^^^2 - 8*x+16)*(16*y - 16)/(4*(y^^^2 - 2*y+1)*(3*x - 12))";
1755 val SOME (t',_) = rewrite_set_ thy false norm_Rational t;
1756 ... non terminating.
1757 val SOME (t',_) = rewrite_set_ thy false make_polynomial t;
1758 "(-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)";
1759 val SOME (t,_) = rewrite_set_ thy false cancel_p t';
1760 ... non terminating.*)
1762 (*SRD Schalk I, p.70 Nr. 472a *)
1763 val t = str2term ("((8*x^^^2 - 32*y^^^2)/(2*x + 4*y))/" ^
1764 "((4*x - 8*y)/(x + y))");
1765 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1770 else error "rational.sml: diff.behav. in norm_Rational_mg 43";
1773 (*----------------------------------------------------------------------*)
1774 (*---------------------- Einfache Dppelbrche --------------------------*)
1775 (*----------------------------------------------------------------------*)
1777 (*SRD Schalk I, p.69 Nr. 461a *)
1779 "(2/(x+3) + 2/(x - 3)) / (8*x/(x^^^2 - 9))";
1780 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1785 else error "rational.sml: diff.behav. in norm_Rational_mg 44";
1787 (*SRD Schalk I, p.69 Nr. 464b *)
1789 "(a - a/(a - 2)) / (a + a/(a - 2))";
1790 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1793 "(3 + -1 * a) / (1 + -1 * a)"
1795 else error "rational.sml: diff.behav. in norm_Rational_mg 45";
1797 (*SRD Schalk I, p.69 Nr. 465b *)
1799 "((x+3*y)/9 + (4*y^^^2 - 9*z^^^2)/(16*x)) /(x/9+y/6+z/4)";
1800 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1803 "(4 * x + 6 * y + -9 * z) / (4 * x)"
1805 else error "rational.sml: diff.behav. in norm_Rational_mg 46";
1807 (*SRD Schalk I, p.69 Nr. 466b *)
1809 "((1 - 7*(x - 2)/(x^^^2 - 4)) / (6/(x+2))) / (3/(x+5)+30/(x^^^2 - 25))";
1810 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1813 "(25 + -10 * x + x ^^^ 2) / 18"
1815 else error "rational.sml: diff.behav. in norm_Rational_mg 47";
1817 (*SRD Schalk I, p.70 Nr. 469 *)
1819 "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))";
1820 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1823 "3 * b ^^^ 3 / (2 * a + -2 * b)"
1825 else error "rational.sml: diff.behav. in norm_Rational_mg 48";
1827 (*----------------------------------------------------------------------*)
1828 (*---------------------- Mehrfache Dppelbrueche ------------------------*)
1829 (*----------------------------------------------------------------------*)
1831 (*SRD.test Schalk I, p.70 Nr. 476b *) (* Rechenzeit: 10 sec *)
1832 (*WN060419 crashes with method 'simplify' ????SK*)
1834 "((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)";
1835 val SOME (t,_) = rewrite_set_ thy false norm_Rational t;
1836 if term2str t = "1 / (a ^^^ 2 + -1 * b ^^^ 2)" then ()
1837 else error "rational.sml: diff.behav. in norm_Rational_mg 49";
1839 "----- Schalk I, p.70 Nr. 477a";
1840 (* MG Achtung: terme explodieren; Bsp zu komplex;
1841 L???ung sollte (ziemlich grosser) Faktorisierter Ausdruck sein
1842 val t = str2term "b*y/(b - 2*y)/((b^^^2 - y^^^2)/(b+2*y)) /" ^
1843 "(b^^^2*y+b*y^^^2)*(a+x)^^^2/((b^^^2 - 4*y^^^2)*(a+2*x)^^^2)";
1844 val SOME (t',_) = rewrite_set_ thy false norm_Rational t;
1847 val t = str2term "b*y*(b+2*y)*(b^^^2 - 4*y^^^2)*(a+2*x)^^^2 / " ^
1848 "((b - 2*y)*(b^^^2 - y^^^2)*(b^^^2*y+b*y^^^2)*(a+x)^^^2)";
1849 val SOME (t,_) = rewrite_set_ thy false make_polynomial t;
1853 "----- Schalk I, p.70 Nr. 478b ----- Rechenzeit: 5 sec";
1854 val t = str2term ("(a - (a*b+b^^^2)/(a+b))/(b+(a - b)/(1+(a+b)/(a - b))) / " ^
1855 "((a - a^^^2/(a+b))/(a+(a*b)/(a - b)))");
1856 val SOME (t',_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1858 "(2 * a ^^^ 3 + 2 * a ^^^ 2 * b) / (a ^^^ 2 * b + b ^^^ 3)"
1860 else error "rational.sml: diff.behav. in norm_Rational_mg 51";
1862 (* TODO.new_c:WN050820 STOP_REW_SUB introduced gave ...
1863 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 ()
1864 else error "rational.sml: works again";
1865 re-outcommented with TODO.new_c: cvs before 071227, 11:50*)
1869 (*Schalk I, p.70 Nr. 480a *)
1870 (* Achtung: rechnet ewig; cancel_p kann nicht krzen: WN060831 nonterm.SK00
1872 "(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)))";
1873 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1878 else error "rational.sml: diff.behav. in norm_Rational_mg 52";
1880 (*MG Berechne Zwischenergebnisse: WN060831 nonterm.SK00*)
1882 "(1/x+1/y+1/z)/(1/x - 1/y - 1/z)";
1883 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1885 "(x ^^^ 2 * y ^^^ 2 * z + x ^^^ 2 * y * z ^^^ 2 + x * y ^^^ 2 * z ^^^ 2) /
1886 (-1 * x ^^^ 2 * y ^^^ 2 * z + -1 * x ^^^ 2 * y * z ^^^ 2 + x * y ^^^ 2 * z ^^^ 2)";
1888 "2*x^^^2/(x^^^2 - z^^^2)/(x/(x+z)+x/(x - z))";
1889 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1893 (* SK 1. Ausdruck kann nicht weiter gekrzt werden; cancel_p !!!*)
1894 ### rls: cancel_p on:
1895 (x ^^^ 2 * (y ^^^ 2 * z) + x ^^^ 2 * (y * z ^^^ 2) + x * (y ^^^ 2 * z ^^^ 2)) /
1896 (-1 * (x ^^^ 2 * (y ^^^ 2 * z)) + -1 * (x ^^^ 2 * (y * z ^^^ 2)) + x * (y ^^^ 2 * z ^^^ 2))
1897 GC #3.61.81.101.197.17503: (0 ms)
1898 *** RATIONALS_DIRECT_CANCEL_EXCEPTION: Invalid fraction
1901 "(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))";
1902 val SOME (t,_) = rewrite_set_ thy false cancel_p t;
1904 (*uncaught exception nonexhaustive binding failure*)
1906 (* Das kann er aber krzen !!????: *)
1908 "(x^^^2 * (y^^^2 * z) + x * (y^^^2 * z^^^2)) / (-1 * (x^^^2 * (y * z^^^2)) + x * (y^^^2 * z^^^2))";
1909 val SOME (t,_) = rewrite_set_ thy false cancel_p t;
1911 "(-1 * (y * x) + -1 * (z * y)) / (1 * (z * x) + -1 * (z * y))";
1915 "-------- crucial examples ------------------------------";
1916 "-------- crucial examples ------------------------------";
1917 "-------- crucial examples ------------------------------";
1918 (*Schalk I, p.60 Nr. 215d *)
1919 (* Achtung: rechnet ewig ...
1920 val t = str2term "(a-b)^^^3 * (x+y)^^^4 / ((x+y)^^^2 * (a-b)^^^5)";
1921 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1922 term2str t; noterm.SK
1925 (* Kein Wunder, denn Z???ler und Nenner extra als Polynom dargestellt ergibt:*)
1927 val t = str2term "(a-b)^^^3 * (x+y)^^^4";
1928 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1930 "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";
1931 val t = str2term "((x+y)^^^2 * (a-b)^^^5)";
1932 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1934 "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";
1936 (*anscheinend macht dem Rechner das Krzen diese Bruches keinen Spass mehr ...*)
1938 (*--------------------------------------------------------------------*)
1939 (*Schalk I, p.70 Nr. 480b
1940 val t = str2term "((12*x*y/(9*x^^^2 - y^^^2))/" ^
1941 "(1/(3*x - y)^^^2 - 1/(3*x + y)^^^2)) *" ^
1942 "(1/(x - 5*y)^^^2 - 1/(x + 5*y)^^^2)/" ^
1943 "(20*x*y/(x^^^2 - 25*y^^^2))";
1944 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1946 Kann nicht weiter vereinfacht werden !!!!?? *)
1948 (*--------------------------------------------------------------------*)
1949 "---- MGs test set";
1950 val t = str2term " (1 + x^^^5) / (y + x) + x^^^3 / x ";
1951 val SOME (t,_) = rewrite_set_ thy false common_nominator_p t;
1952 if term2str t = "(1 + x ^^^ 3 + x ^^^ 5 + y * x ^^^ 2) / (x + y)" then()
1955 (*--------------------------------------------------------------------*)
1956 (* cancel_p liefert nicht immer Polynomnormalform (2): WN060831???SK3b
1957 ---> Sortierung FALSCH !! *)
1958 val t = str2term "b^^^3 * a^^^5/a ";
1959 val SOME (t,_) = rewrite_set_ thy false cancel_p t;
1961 "1 * (a^^^4 * b^^^3) / 1"; (*OK*)
1963 val t = str2term "b^^^3 * a^^^5/b ";
1964 val SOME (t,_) = rewrite_set_ thy false cancel_p t;
1966 "1 * (b^^^2 * a^^^5) / 1"; (*cancel_p sortiert hier falsch um!*)
1968 (* Problem liegt NICHT bei ord_make_polynomial! (siehe folgende Bsple) *)
1970 val x = str2term "x"; val bdv = str2term "bdv";
1971 val t1 = str2term "b^^^2 * a^^^5";
1972 val t2 = str2term "a^^^5 * b^^^2 ";
1973 ord_make_polynomial false Rational.thy [(x,bdv)] (t1,t2); (*false*)
1975 (* ==> "b^^^2 * a^^^5" > "a^^^5 * b^^^2 " ... OK!*)
1977 (*--------------------------------------------------------------------*)
1978 (* cancel_p liefert nicht immer Polynomnormalform (2): WN060831???SK3c
1979 ---> erzeugt berflssige "1 * ..."
1981 val t = str2term "-1 / (3 + y)";
1983 val SOME (t,_) = rewrite_set_ thy false cancel_p t;
1986 (********* Das ist das PROBLEM !!!!!!!??? *******************)
1987 (* -1 im Z???ler der Angabe verursacht das Problem !*)
1990 (* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *)
1991 "----- MGs test set";
1992 val t = str2term "(a^^^2 + -1)/(a+1)";
1993 val SOME (t',_) = rewrite_set_ thy false cancel_p t;
1994 if term2str t' = "(-1 + a) / 1" then ()
1995 else error "rational.sml MG tests 3d";
1997 "----- NOT TERMINATING ?: worked before 0707xx";
1998 val t = str2term "(a^^^2 - 1)*(b + 1) / ((b^^^2 - 1)*(a+1))";
1999 val SOME (t'',_) = rewrite_set_ thy false norm_Rational t;
2000 if term2str t'' = "(1 + -1 * a) / (1 + -1 * b)" then ()
2001 else error "rational.sml MG tests 3e";
2003 "----- corrected SK060905";
2004 val t = str2term "(4*x^^^2 - 20*x + 25)/(2*x - 5)^^^3";
2005 val SOME (t',_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
2006 if term2str t' = "-1 / (5 + -2 * x)" then ()
2007 else error "rational.sml corrected SK060905";
2010 "-------- examples for Stefan Karnels thesis ------------";
2011 "-------- examples for Stefan Karnels thesis ------------";
2012 "-------- examples for Stefan Karnels thesis ------------";
2013 (*SRAM Schalk I, p.69 Nr. 442b --- abgewandelt*)
2015 "(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))";
2016 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
2019 "5 * x ^^^ 2 / (b ^^^ 3 * c)"
2021 else error "rational.sml: diff.behav. in norm_Rational_mg 53";
2024 "-------- me Schalk I No.186 ----------------------------";
2025 "-------- me Schalk I No.186 ----------------------------";
2026 "-------- me Schalk I No.186 ----------------------------";
2027 val fmz = ["Term ((14 * x * y) / ( x * y ))",
2030 ("Rational",["rational","simplification"],
2031 ["simplification","of_rationals"]);
2032 val p = e_pos'; val c = [];
2033 val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
2034 val (p,_,f,nxt,_,pt) = me nxt p c pt;
2035 val (p,_,f,nxt,_,pt) = me nxt p c pt;
2036 val (p,_,f,nxt,_,pt) = me nxt p c pt;
2037 val (p,_,f,nxt,_,pt) = me nxt p c pt;
2038 val (p,_,f,nxt,_,pt) = me nxt p c pt;
2039 val (p,_,f,nxt,_,pt) = me nxt p c pt;
2040 val (p,_,f,nxt,_,pt) = me nxt p c pt;
2041 val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
2042 val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
2043 val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;(*++ for explicit script*)
2044 val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;(*++ for explicit script*)
2045 case (f2str f, nxt) of
2046 ("14", ("End_Proof'", _)) => ()
2047 | _ => error "rational.sml diff.behav. in me Schalk I No.186";
2050 "-------- interSteps ..Simp_Rat_Double_No-1.xml ---------";
2051 "-------- interSteps ..Simp_Rat_Double_No-1.xml ---------";
2052 "-------- interSteps ..Simp_Rat_Double_No-1.xml ---------";
2055 [(["Term (((2 - x)/(2*a)) / (2*a/(x - 2)))", "normalform N"],
2056 ("Rational",["rational","simplification"],
2057 ["simplification","of_rationals"]))];
2060 autoCalculate 1 CompleteCalc;
2061 val ((pt,p),_) = get_calc 1; show_pt pt;
2063 interSteps 1 ([1],Res);
2064 val ((pt,p),_) = get_calc 1; show_pt pt;
2067 "-------- interSteps ..Simp_Rat_Cancel_No-1.xml ---------";
2068 "-------- interSteps ..Simp_Rat_Cancel_No-1.xml ---------";
2069 "-------- interSteps ..Simp_Rat_Cancel_No-1.xml ---------";
2072 [(["Term ((a^2 + -1*b^2) / (a^2 + -2*a*b + b^2))", "normalform N"],
2073 ("Rational",["rational","simplification"],
2074 ["simplification","of_rationals"]))];
2077 autoCalculate 1 CompleteCalc;
2078 val ((pt,p),_) = get_calc 1; show_pt pt;
2079 (*========== inhibit exn 110314 ================================================
2080 (*with explicit script done already... and removed [1,..] at below...
2081 interSteps 1 ([1],Res);
2082 val ((pt,p),_) = get_calc 1; show_pt pt;
2084 interSteps 1 ([2],Res);
2085 val ((pt,p),_) = get_calc 1; show_pt pt;
2087 interSteps 1 ([2,1],Res);
2088 val ((pt,p),_) = get_calc 1; show_pt pt;
2089 val newnds = children (get_nd pt [2,1]) (*see "fun detailrls"*);
2090 (*if length newnds = 12 then () WN060905*)
2091 if length newnds = 13 then ()
2092 else error "rational.sml: interSteps cancel_p rev_rew_p";
2094 val p = ([2,1,9],Res);
2096 val (_, tac, _) = pt_extract (pt, p);
2097 (*case tac of SOME (Rewrite ("sym_real_plus_binom_times1", _)) => ()
2099 case tac of SOME (Rewrite ("sym_real_add_mult_distrib2", _)) => ()
2100 | _ => error "rational.sml: getTactic, sym_real_plus_binom_times1";
2101 ============ inhibit exn 110314 ==============================================*)
2104 "-------- investigate rulesets for cancel_p -------------";
2105 "-------- investigate rulesets for cancel_p -------------";
2106 "-------- investigate rulesets for cancel_p -------------";
2107 val thy = @{theory "Rational"};
2108 "---------------- (a^^^2 + -1*b^^^2) / (a^^^2 + -2*a*b + b^^^2)";
2109 val t = str2term "(a^^^2 + -1*b^^^2) / (a^^^2 + -2*a*b + b^^^2)";
2110 val tt = str2term "(1 * a + 1 * b) * (1 * a + -1 * b)"(*numerator only*);
2111 "----- with rewrite_set_";
2112 val SOME (tt',asm) = rewrite_set_ thy false make_polynomial tt;
2113 term2str tt'= "a ^^^ 2 + -1 * b ^^^ 2" (*true*);
2114 val tt = str2term "((1 * a + -1 * b) * (1 * a + -1 * b))"(*denominator only*);
2115 val SOME (tt',asm) = rewrite_set_ thy false make_polynomial tt;
2116 term2str tt' = "a ^^^ 2 + -2 * a * b + b ^^^ 2" (*true*);
2118 "----- with make_deriv";
2119 val SOME (tt, _) = factout_p_ thy t; term2str tt =
2120 "(1 * a + 1 * b) * (1 * a + -1 * b) / ((1 * a + -1 * b) * (1 * a + -1 * b))";
2122 "--- with ruleset as before 060829";
2123 val {rules, rew_ord=(_,ro),...} =
2124 rep_rls (assoc_rls "make_polynomial");
2125 val der = make_deriv thy Atools_erls rules ro NONE tt;
2126 print_depth 99; map (term2str o #1) der; print_depth 3;
2127 print_depth 99; map (rule2str o #2) der; print_depth 3;
2128 ... did not terminate*)
2129 "--- with simpler ruleset";
2130 val {rules, rew_ord=(_,ro),...} =
2131 rep_rls (assoc_rls "rev_rew_p");
2132 val der = make_deriv thy Atools_erls rules ro NONE tt;
2133 print_depth 99; writeln (deriv2str der); print_depth 3;
2135 print_depth 99; map (term2str o #1) der; print_depth 3;
2136 "...,(-1 * b ^^^ 2 + a ^^^ 2) / (-2 * (a * b) + a ^^^ 2 + (-1 * b) ^^^ 2) ]";
2137 print_depth 99; map (rule2str o #2) der; print_depth 3;
2138 print_depth 99; map (term2str o #1 o #3) der; print_depth 3;
2140 val der = make_deriv thy Atools_erls rules ro NONE
2141 (str2term "(1 * a + 1 * b) * (1 * a + -1 * b)");
2142 print_depth 99; writeln (deriv2str der); print_depth 3;
2144 val {rules, rew_ord=(_,ro),...} =
2145 rep_rls (assoc_rls "rev_rew_p");
2146 val der = make_deriv thy Atools_erls rules ro NONE
2147 (str2term "(1 * a + -1 * b) * (1 * a + -1 * b)");
2148 print_depth 99; writeln (deriv2str der); print_depth 3;
2149 print_depth 99; map (term2str o #1) der; print_depth 3;
2150 (*WN060829 ...postponed*)
2153 "-------- investigate format of factout_ and factout_p_ -";
2154 "-------- investigate format of factout_ and factout_p_ -";
2155 "-------- investigate format of factout_ and factout_p_ -";
2156 val {rules, rew_ord = (_,ro),...} = rep_rls (assoc_rls "make_polynomial");
2157 val (thy, eval_rls) = (@{theory "Rational"}, Atools_erls)(*see 'fun init_state'*);
2158 val Rrls {scr = Rfuns {init_state,...},...} = assoc_rls "cancel_p";
2160 "----- see Rational.ML, local cancel_p, fun init_state";
2161 val t = str2term "(a^^^2 + (-1)*b^^^2) / (a^^^2 + (-2)*a*b + b^^^2)";
2162 val SOME (t',_) = factout_p_ thy t; term2str t';
2164 val rtas = reverse_deriv thy eval_rls rules ro NONE t';
2165 writeln(trtas2str rst);
2169 "----- see Rational.ML, local cancel_p, fun init_state";
2170 val t = str2term "a^^^2 / a";
2171 val SOME (t',_) = factout_p_ thy t;
2172 term2str t' = "a * a / (1 * a)" (*true*);
2173 (*... can be canceled with
2174 real_mult_div_cancel2 ?k ~= 0 ==> ?m * ?k / (?n * ?k) = ?m / ?n"*)
2175 (* sml/ME/rewtools.sml:
2176 val rtas = reverse_deriv thy Atools_erls rules ro NONE t';
2177 writeln (deri2str rtas);
2181 "-------- SK 060904 ----------------------------------------------";
2182 "----- order on polynomials -- input + output";
2183 val thy = @{theory "Isac"};
2184 val t = str2term "(a + -1 * b) / (-1 * a + b)";
2185 val SOME (t', _) = factout_p_ thy t; term2str t';
2186 val SOME (t', _) = cancel_p_ thy t; term2str t';
2188 val t = str2term "a*b*c*d / (d*e*f*g)";
2189 val SOME (t', _) = cancel_p_ thy t; term2str t';
2191 val t = str2term "a*(b*(c*d)) / (b*(e*(f*g)))";
2192 val SOME (t', _) = cancel_p_ thy t; term2str t';
2195 "----- SK060904-1a non-termination of cancel_p_ ? worked before 0707xx";
2196 val t = str2term "(x^^^2 - 4)*(3 - y) / ((y^^^2 - 9)*(2+x))";
2197 val SOME (t',_) = rewrite_set_ thy false norm_Rational t;
2198 if term2str t' = "(2 + -1 * x) / (3 + y)" then ()
2199 else error "rational.sml SK060904-1a worked since 0707xx";
2201 "----- SK060904-1b non-termination of cancel_p_ ... worked before 0707xx";
2202 val t = str2term ("(9 * a ^^^ 2 + -16 * b ^^^ 2) /" ^
2203 "(36 * a^^^2 * c + (27 * a^^^2 * e + (-64 * b^^^2 * c + -48 * b^^^2 * e)))");
2204 val SOME (t',_) = cancel_p_ thy t;
2205 if term2str t' = "1 / (4 * c + 3 * e)" then ()
2206 else error "rational.sml SK060904-1b";
2209 "----- SK060904-2a non-termination of add_fraction_p_";
2210 val t = str2term (" (a + b * x) / (a + -1 * (b * x)) + " ^
2211 " (-1 * a + b * x) / (a + b * x) ");
2213 val SOME (t',_) = rewrite_set_ thy false common_nominator_p t;
2215 common_nominator_p_ thy t;
2216 " (a + b * x)*(a + b * x) / ((a + -1 * (b * x))*(a + -1 * (b * x))) + " ^
2217 " (-1 * a + b * x)*(a + -1 * (b * x)) / ((a + b * x)*(-1 * a + b * x)) ";
2219 add_fraction_p_ thy t;
2220 " ((a + b * x)*(a + b * x) + (-1 * a + b * x)*(a + -1 * (b * x))) /" ^
2221 " ((a + b * x)*(-1 * a + b * x)) ";
2225 "-------- how to stepwise construct Scripts -------------";
2226 "-------- how to stepwise construct Scripts -------------";
2227 "-------- how to stepwise construct Scripts -------------";
2228 val thy = @{theory "Rational"};
2230 val p1 = parse thy (
2231 "Script SimplifyScript (t_t::real) = " ^
2232 " (Rewrite_Set discard_minus False " ^
2235 (*required (): (Rewrite_Set discard_minus False)*)
2236 val p2 = parse thy (
2237 "Script SimplifyScript (t_t::real) = " ^
2238 " (Rewrite_Set discard_minus False " ^
2241 val p3 = parse thy (
2242 "Script SimplifyScript (t_t::real) = " ^
2243 " ((Rewrite_Set discard_minus False) " ^
2246 val p4 = parse thy (
2247 "Script SimplifyScript (t_t::real) = " ^
2248 " ((Rewrite_Set discard_minus False) " ^
2251 val p5 = parse thy (
2252 "Script SimplifyScript (t_t::real) = " ^
2253 " ((Try (Rewrite_Set discard_minus False) " ^
2254 " Try (Rewrite_Set discard_parentheses False)) " ^
2257 val p6 = parse thy (
2258 "Script SimplifyScript (t_t::real) = " ^
2259 " ((Try (Rewrite_Set discard_minus False) @@ " ^
2260 " Try (Rewrite_Set rat_mult_poly False) @@ " ^
2261 " Try (Rewrite_Set make_rat_poly_with_parentheses False) @@ " ^
2262 " Try (Rewrite_Set cancel_p_rls False) @@ " ^
2264 " ((Try (Rewrite_Set common_nominator_p_rls False) @@ " ^
2265 " Try (Rewrite_Set rat_mult_div_pow False) @@ " ^
2266 " Try (Rewrite_Set make_rat_poly_with_parentheses False) @@" ^
2267 " Try (Rewrite_Set cancel_p_rls False) @@ " ^
2268 " Try (Rewrite_Set rat_reduce_1 False)))) @@ " ^
2269 " Try (Rewrite_Set discard_parentheses False)) " ^
2273 "----------- get_denominator ----------------------------";
2274 "----------- get_denominator ----------------------------";
2275 "----------- get_denominator ----------------------------";
2276 val thy = @{theory Isac};
2277 val t = term_of (the (parse thy "get_denominator ((a +x)/b)"));
2278 val SOME (_, t') = eval_get_denominator "" 0 t thy;
2279 if term2str t' = "get_denominator ((a + x) / b) = b" then ()
2280 else error "get_denominator ((a + x) / b) = b"
2283 "--------- several errpats in complicated term -------------------";
2284 "--------- several errpats in complicated term -------------------";
2285 "--------- several errpats in complicated term -------------------";
2286 (*TODO: instead of Gabriella's example here (27.Jul.12) find a simpler one*)
2289 [(["Term ((5*b + 25)/(a^2 - b^2) * (a - b)/(5*b))", "normalform N"],
2290 ("Rational",["rational","simplification"], ["simplification","of_rationals"]))];
2293 autoCalculate 1 CompleteCalc;
2294 val ((pt,p),_) = get_calc 1; show_pt pt;
2296 "-------- nonterminating cancel_p, norm_Rational 2002 ---";
2297 "-------- nonterminating cancel_p, norm_Rational 2002 ---";
2298 "-------- nonterminating cancel_p, norm_Rational 2002 ---";
2299 (*------------------------------------------------------------------------------------\
2300 "--- WN121204: searched rational.sml for "nonterm", added new numbering" ^
2301 " and thoroughly tested with this numbering subsequently";
2303 WN.2.6.03 from rlang.sml 56a
2304 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)";
2305 val NONE = rewrite_set_ thy false common_nominator_p t;
2307 WN060831 nonterm.SK7
2308 val t = str2term "(a + b * x) / (a + -1 * (b * x)) + (-1 * a + b * x) / (a + b * x)";
2309 val NONE = add_fraction_p_ thy t;
2311 nonterm.SK9 loops: cancel_p kann nicht weiter kuerzen!!! *)
2312 val t'' = str2term "(a + b)/(x^^^2 - y^^^2) * ((x - y)^^^2/(a^^^2 - b^^^2))";
2313 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t'';
2316 "(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)";
2317 WN060831 nonterm.SK10
2318 val SOME (t,_) = rewrite_set_ thy false cancel_p t;
2322 "(9*(x^^^2 - 8*x+16)/(4*(y^^^2 - 2*y+1)))/((3*x - 12)/(16*y - 16))";
2323 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
2326 else error "rational.sml: diff.behav. in norm_Rational_mg 42";
2329 "9*(x^^^2 - 8*x+16)*(16*y - 16)/(4*(y^^^2 - 2*y+1)*(3*x - 12))";
2330 val SOME (t',_) = rewrite_set_ thy false norm_Rational t;
2331 ... non terminating.
2333 val SOME (t',_) = rewrite_set_ thy false make_polynomial t;
2334 "(-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)";
2335 val SOME (t,_) = rewrite_set_ thy false cancel_p t';
2337 val t = str2term "(a-b)^^^3 * (x+y)^^^4 / ((x+y)^^^2 * (a-b)^^^5)";
2338 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
2340 val t = str2term "((12*x*y/(9*x^^^2 - y^^^2))/" ^
2341 "(1/(3*x - y)^^^2 - 1/(3*x + y)^^^2)) *" ^
2342 "(1/(x - 5*y)^^^2 - 1/(x + 5*y)^^^2)/" ^
2343 "(20*x*y/(x^^^2 - 25*y^^^2))";
2344 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
2346 SK060904-2a non-termination of add_fraction_p_";
2347 val t = str2term (" (a + b * x) / (a + -1 * (b * x)) + " ^
2348 " (-1 * a + b * x) / (a + b * x) ");
2350 val SOME (t',_) = rewrite_set_ thy false common_nominator_p t;
2352 common_nominator_p_ thy t;
2353 " (a + b * x)*(a + b * x) / ((a + -1 * (b * x))*(a + -1 * (b * x))) + " ^
2354 " (-1 * a + b * x)*(a + -1 * (b * x)) / ((a + b * x)*(-1 * a + b * x)) ";
2356 add_fraction_p_ thy t;
2357 " ((a + b * x)*(a + b * x) + (-1 * a + b * x)*(a + -1 * (b * x))) /" ^
2358 " ((a + b * x)*(-1 * a + b * x)) ";
2359 --------------------------------------------------------------------------------------/*)
2361 (*------------------------------------------------------------------------------------\
2362 "WN121205: thoroughly tested with the above numbering.";
2363 " errors in cancel_p: --- 4,5,6,7.";
2364 " error in common_nominator_p, common_nominator_p_: --- 10; 1,2?.";
2365 " errors caused by ruleset norm_Rational: --- 8,9.";
2366 trace_rewrite := true;
2368 "--- 1 ---: non-terminating with ### add_fract: done t22 ";
2369 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)";
2370 trace_rewrite:= true;
2371 rewrite_set_ thy false common_nominator_p t;
2373 "--- 2 ---: non-terminating with ### add_fract: done t22 ";
2374 val t = str2term "(a + b * x) / (a + -1 * (b * x)) + (-1 * a + b * x) / (a + b * x)";
2375 add_fraction_p_ thy t;
2377 "--- 3 ---: norm_Rational calls Rrls cancel_p with non-normalised polys";
2378 val t = str2term "(a + b)/(x^^^2 - y^^^2) * ((x - y)^^^2/(a^^^2 - b^^^2))";
2379 rewrite_set_ thy false norm_Rational t;
2380 (*tracing end...#### rls: cancel_p on:
2381 (a * x ^^^ 2 + -2 * (a * (x * y)) + a * y ^^^ 2 + b * x ^^^ 2 + -2 * (b * (x * y)) + b * y ^^^ 2) /
2382 (a ^^^ 2 * x ^^^ 2 + -1 * (a ^^^ 2 * y ^^^ 2) + -1 * (b ^^^ 2 * x ^^^ 2) + b ^^^ 2 * y ^^^ 2) *)
2384 "--- 4 ---: non-terminating with Rrls cancel_p on plausible input";
2386 "(a * x ^^^ 2 + -2 * a * x * y + a * y ^^^ 2 + b * x ^^^ 2 + -2 * b * x * y + b * y ^^^ 2) /"^
2387 "(a ^^^ 2 * x ^^^ 2 + -1 * a ^^^ 2 * y ^^^ 2 + -1 * b ^^^ 2 * x ^^^ 2 + b ^^^ 2 * y ^^^ 2)");
2388 rewrite_set_ thy false cancel_p t;
2389 (*# rls: cancel_p on:
2390 (a * x ^^^ 2 + -2 * a * x * y + a * y ^^^ 2 + b * x ^^^ 2 + -2 * b * x * y + b * y ^^^ 2) /
2391 (a ^^^ 2 * x ^^^ 2 + -1 * a ^^^ 2 * y ^^^ 2 + -1 * b ^^^ 2 * x ^^^ 2 + b ^^^ 2 * y ^^^ 2) *)
2393 "--- 5 ---: non-terminating with Rrls cancel_p on plausible input";
2394 val t = str2term "(9*(x^^^2 - 8*x+16)/(4*(y^^^2 - 2*y+1)))/((3*x - 12)/(16*y - 16))";
2395 rewrite_set_ thy false norm_Rational t;
2396 (*#### rls: cancel_p on:
2397 (2304 + -1152 * x + -2304 * y + 144 * x ^^^ 2 + 1152 * (x * y) + -144 * (x ^^^ 2 * y)) /
2398 (48 + -12 * x + -96 * y + 24 * (x * y) + 48 * y ^^^ 2 + -12 * (x * y ^^^ 2)) *)
2400 "--- 6 ---: non-terminating with Rrls cancel_p on plausible input";
2402 "9*(x^^^2 - 8*x+16)*(16*y - 16)/(4*(y^^^2 - 2*y+1)*(3*x - 12))";
2403 rewrite_set_ thy false norm_Rational t;
2404 (*### rls: cancel_p on: (-2304 + 1152 * x + 2304 * y + -144 * x ^^^ 2 + -1152 * (x * y) +
2405 144 * (x ^^^ 2 * y)) /
2406 (-48 + 12 * x + 96 * y + -24 * (x * y) + -48 * y ^^^ 2 + 12 * (x * y ^^^ 2)) *)
2408 "--- 7 ---: non-terminating with Rrls cancel_p on plausible input";
2410 "(-2304 + 1152 * x + 2304 * y + -144 * x ^^^ 2 + -1152 * x * y + 144 * x ^^^ 2 * y) /"^
2411 "(-48 + 12 * x + 96 * y + -24 * x * y + -48 * y ^^^ 2 + 12 * x * y ^^^ 2)");
2412 rewrite_set_ thy false cancel_p t';
2414 "--- 8 ---: bottom of output cannot be looked ad (due to looping?)";
2415 val t = str2term "(a-b)^^^3 * (x+y)^^^4 / ((x+y)^^^2 * (a-b)^^^5)";
2416 val SOME (t,_) = rewrite_set_ thy false norm_Rational t;
2418 "--- 9 ---: probably error in norm_Rational";
2420 "((12*x*y / (9*x^^^2 - y^^^2)) / (1/(3*x - y)^^^2 - 1/(3*x + y)^^^2)) *" ^
2421 "(1/(x - 5*y)^^^2 - 1/(x + 5*y)^^^2) / (20*x*y/(x^^^2 - 25*y^^^2))");
2422 rewrite_set_ thy false norm_Rational t;
2423 (*#### rls: cancel_p on: (19440 * (x ^^^ 8 * y ^^^ 2) + -490320 * (x ^^^ 6 * y ^^^ 4) +
2424 108240 * (x ^^^ 4 * y ^^^ 6) +
2425 -6000 * (x ^^^ 2 * y ^^^ 8)) /
2426 (2160 * (x ^^^ 8 * y ^^^ 2) + -108240 * (x ^^^ 6 * y ^^^ 4) +
2427 1362000 * (x ^^^ 4 * y ^^^ 6) +
2428 -150000 * (x ^^^ 2 * y ^^^ 8)) *)
2430 "--- 10 ---: non-terminating with ### add_fract: done t22: error in common_nominator_p ";
2431 val t = str2term (" (a + b * x) / (a + -1 * (b * x)) + (-1 * a + b * x) / (a + b * x)");
2432 rewrite_set_ thy false common_nominator_p t; (*### add_fract: done t22 *)
2433 common_nominator_p_ thy t; (*loops without output*)
2434 "--- reformulated 10:";
2435 val t = str2term "(a + -1 * (b * x)) / (a + b * x)";
2436 rewrite_set_ thy false cancel_p t = NONE;
2439 "...both are to be considered after common_nominator_p_ is improved";
2440 --------------------------------------------------------------------------------------/*)
2441 ============ inhibit exn WN130824 TODO ======================================================*)