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";
344 "-------- cancel from: Mathematik 1 Schalk Reniets Verlag --------------------";
345 "-------- cancel from: Mathematik 1 Schalk Reniets Verlag --------------------";
346 "-------- cancel from: Mathematik 1 Schalk Reniets Verlag --------------------";
347 val thy = @{theory "Rational"};
348 val thy' = "Rational";
350 val mp = "make_polynomial";
352 "-------- example 186a";
353 val t = str2term "(14 * x * y) / (x * y)";
354 is_expanded (str2term "14 * x * y");
355 is_expanded (str2term "x * y");
356 val SOME (t', asm) = rewrite_set_ thy false cancel t;
357 if (term2str t', terms2str asm) = ("14 / 1", "[\"y * x ~= 0\"]")
358 then () else error "rational.sml cancel Schalk 186a";
360 "-------- example 186b";
361 val t = str2term "(60 * a * b) / ( 15 * a * b )";
362 val SOME (t', asm) = rewrite_set_ thy false cancel t;
363 if (term2str t', terms2str asm) = ("4 / 1", "[\"15 * (b * a) ~= 0\"]")
364 then () else error "rational.sml cancel Schalk 186b";
366 "-------- example 186c";
367 val t = str2term "(144 * a^^^2 * b * c) / (12 * a * b * c)";
368 val SOME (t', asm) = rewrite_set_ thy false cancel t;
369 if (term2str t', terms2str asm) = ("12 * a / 1", "[\"12 * (c * (b * a)) ~= 0\"]")
370 then () else error "rational.sml cancel Schalk 186c";
372 "-------- example 187a";
373 val t = str2term "(12 * x * y) / (8 * y^^^2 )";
374 val SOME (t', asm) = rewrite_set_ thy false cancel t;
375 if (term2str t', terms2str asm) = ("3 * x / (2 * y)", "[\"4 * y ~= 0\"]")
376 then () else error "rational.sml cancel Schalk 187a";
378 "-------- example 187b";
379 val t = str2term "(8 * x^^^2 * y * z ) / (18 * x * y^^^2 * z )";
380 val SOME (t', asm) = rewrite_set_ thy false cancel t;
381 if (term2str t', terms2str asm) = ("4 * x / (9 * y)", "[\"2 * (z * (y * x)) ~= 0\"]")
382 then () else error "rational.sml cancel Schalk 187b";
384 "-------- example 187c";
385 val t = str2term "(9 * x^^^5 * y^^^2 * z^^^4) / (15 * x^^^6 * y^^^3 * z )";
386 val SOME (t', asm) = rewrite_set_ thy false cancel t;
387 if (term2str t', terms2str asm) =
388 ("3 * z ^^^ 3 / (5 * (y * x))", "[\"3 * (z * (y ^^^ 2 * x ^^^ 5)) ~= 0\"]")
389 then () else error "rational.sml cancel Schalk 187c";
391 "-------- example 188a";
392 val t = str2term "(-8 + 8 * x) / (-9 + 9 * x)";
393 is_expanded (str2term "8 * x + -8");
394 val SOME (t', asm) = rewrite_set_ thy false cancel t;
395 if (term2str t', terms2str asm) = ("8 / 9", "[\"-1 + x ~= 0\"]")
396 then () else error "rational.sml cancel Schalk 188a";
398 val t = str2term "(8*((-1) + x))/(9*((-1) + x))";
399 val SOME (t,_) = rewrite_set_ thy false (*!!!!!!!!!!!!!!!!!!!!!!1*) make_polynomial t;
400 if (term2str t', terms2str asm) = ("8 / 9", "[\"-1 + x ~= 0\"]")
401 then () else error "rational.sml cancel Schalk make_polynomial 1";
403 "-------- example 188b";
404 val t = str2term "(-15 + 5 * x) / (-18 + 6 * x)";
405 val SOME (t', asm) = rewrite_set_ thy false cancel t;
406 if (term2str t', terms2str asm) = ("5 / 6", "[\"-3 + x ~= 0\"]")
407 then () else error "rational.sml cancel Schalk 188b";
409 "-------- example 188c";
410 val t = str2term "(a + -1 * b) / (b + -1 * a)";
411 val SOME (t', asm) = rewrite_set_ thy false (*!!!!! NONE with cancel !!!!!*) cancel_p t;
412 if (term2str t', terms2str asm) = ("-1 / 1", "[\"b + -1 * a ~= 0\"]")
413 then () else error "rational.sml cancel Schalk 188c";
415 is_expanded (str2term "a + -1 * b") = false (*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*);
416 val t = str2term "((-1)*(b + (-1) * a))/(1*(b + (-1) * a))";
417 val SOME (t', asm) = rewrite_set_ thy false make_polynomial t;
418 if (term2str t', terms2str asm) = ("(a + -1 * b) / (-1 * a + b)", "[]")
419 then () else error "rational.sml cancel Schalk make_polynomial 2";
421 "-------- example 190a";
422 val t = str2term "( 27 * a^^^3 + 9 * a^^^2 + 3 * a + 1 ) / ( 27 * a^^^3 + 18 * a^^^2 + 3 * a )";
423 val SOME (t', asm) = rewrite_set_ thy false cancel t;
424 if (term2str t', terms2str asm) =
425 ("(1 + 9 * a ^^^ 2) / (3 * a + 9 * a ^^^ 2)", "[\"1 + 3 * a ~= 0\"]")
426 then () else error "rational.sml cancel Schalk 190a";
428 "-------- example 190c";
429 val t = str2term "((1 + 9 * a ^^^ 2)*(1 + 3 * a))/((3 * a + 9 * a ^^^ 2)*(1 + 3 * a))";
430 val SOME (t', asm) = rewrite_set_ thy false make_polynomial t;
431 if (term2str t', terms2str asm) =
432 ("(1 + 3 * a + 9 * a ^^^ 2 + 27 * a ^^^ 3) /\n(3 * a + 18 * a ^^^ 2 + 27 * a ^^^ 3)", "[]")
433 then () else error "rational.sml make_polynomial Schalk 190c";
435 "-------- example 191a";
436 val t = str2term "( x^^^2 + -1 * y^^^2 ) / ( x + y )";
437 is_expanded (str2term "x^^^2 + -1 * y^^^2") = false; (*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*)
438 is_expanded (str2term "x + y") = true;
439 val NONE (*!!!!!!!! WN.23.10.02 !!!!!!!!!!!!!!!*) = rewrite_set_ thy false cancel t;
441 "-------- example 191b";
442 val t = str2term "((x + (-1) * y)*(x + y))/((1)*(x + y))";
443 val SOME (t', asm) = rewrite_set_ thy false make_polynomial t;
444 if (term2str t', terms2str asm) = ("(x ^^^ 2 + -1 * y ^^^ 2) / (x + y)", "[]")
445 then () else error "rational.sml make_polynomial Schalk 191b";
447 "-------- example 191c";
448 val t = str2term "( 9 * x^^^2 + -30 * x + 25 ) / ( 9 * x^^^2 + -25 )";
449 is_expanded (str2term "9 * x^^^2 + -30 * x + 25") = false; (*!!!!WN.23.10.02!!!!!!!!!!*)
450 is_expanded (str2term "25 + -30*x + 9*x^^^2") = false; (*!!!!!!!!WN.23.10.02!!!!!!!!!!*)
451 is_expanded (str2term "-25 + 9*x^^^2") = true;
453 val t = str2term "(((-5) + 3 * x)*((-5) + 3 * x))/((5 + 3 * x)*((-5) + 3 * x))";
454 val SOME (t', asm) = rewrite_set_ thy false make_polynomial t;
455 if (term2str t', terms2str asm) = ("(25 + -30 * x + 9 * x ^^^ 2) / (-25 + 9 * x ^^^ 2)", "[]")
456 then () else error "rational.sml make_polynomial Schalk 191c";
458 "-------- example 192b";
459 val t = str2term "( 7 * x^^^3 + -1 * x^^^2 * y ) / ( 7 * x * y^^^2 + -1 * y^^^3 )";
460 val NONE (*!!!!!!!! WN.23.10.02 !!!!!!!!!!!!!!!*) = rewrite_set_ thy false cancel t;
462 val t = str2term "((x ^^^ 2)*(7 * x + (-1) * y))/((y ^^^ 2)*(7 * x + (-1) * y))";
463 val SOME (t', asm) = rewrite_set_ thy false make_polynomial t;
464 if (term2str t', terms2str asm) =
465 ("(7 * x ^^^ 3 + -1 * x ^^^ 2 * y) / (7 * x * y ^^^ 2 + -1 * y ^^^ 3)", "[]")
466 then () else error "rational.sml make_polynomial Schalk 192b";
468 (*WN050929, === inhibit exn 110317 ===*)
469 val t = str2term "((x ^^^ 2)*(7 * x + (-1) * y))/((y ^^^ 2)*(7 * x + (-1) * y))";
470 val SOME (t', asm) = rewrite_set_ thy false make_polynomial t;
471 if (term2str t', terms2str asm) =
472 ("(7 * x ^^^ 3 + -1 * x ^^^ 2 * y) / (7 * x * y ^^^ 2 + -1 * y ^^^ 3)", "[]")
473 then () else error "rational.sml make_polynomial Schalk WN050929";
475 "-------- example 193a";
476 val t = str2term "( x^^^2 + -6 * x + 9 ) / ( x^^^2 + -9 )";
477 val NONE (*!!!!!!!!!!!WN.23.10.02!!!!!!!!!!!!!11*) = rewrite_set_ thy false cancel t;
479 "-------- example 193b";
480 val t = str2term "( x^^^2 + -8 * x + 16 ) / ( 2 * x^^^2 + -32 )";
481 val NONE (*!!!!!!!!!!!WN.23.10.02!!!!!!!!!!!!!11*) = rewrite_set_ thy false cancel t;
483 "-------- example 193c";
484 val t = str2term "( 2 * x + -50 * x^^^3 ) / ( 25 * x^^^2 + -10 * x + 1 )";
485 val NONE (*!!!!!!!!!!!WN.23.10.02!!!!!!!!!!!!!11*) = rewrite_set_ thy false cancel t;
488 val t = str2term "(-25 + 9*x^^^2)/(5 + 3*x)";
489 val SOME (t, asm) = rewrite_set_ thy false cancel t;
490 if (term2str t', terms2str asm) =
491 ("(7 * x ^^^ 3 + -1 * x ^^^ 2 * y) / (7 * x * y ^^^ 2 + -1 * y ^^^ 3)", "[\"5 + 3 * x ~= 0\"]")
492 then () else error "rational.sml cancel WN 1";
494 "-------- some old tests REVISE ! --------------------------------------------";
495 "-------- some old tests REVISE ! --------------------------------------------";
496 "-------- some old tests REVISE ! --------------------------------------------";
497 (*WAS --- external calculating functions test ---*)
498 val t = str2term "((3 * x^^^2 + 6 *x + 3) / (2*x + 2))";
499 val SOME (t', asm) = factout_p_ thy t;
500 if term2str t' = "(3 + 3 * x) * (1 + x) / (2 * (1 + x))" andalso terms2str asm = "[]"
501 then () else error "factout_p_ 1 changed";
502 val SOME (t', asm) = cancel_p_ thy t;
503 if term2str t' = "(3 + 3 * x) / 2" andalso terms2str asm = "[\"1 + x ~= 0\"]"
504 then () else error "cancel_p_ 1 changed";
506 val t = str2term "((-3 * x^^^2 + 6 *x - 3) / (2*x - 2))";
507 val SOME (t', asm) = factout_(*p_*) thy t;
508 if term2str t' = "(3 - 3 * x) * (-1 + x) / (2 * (-1 + x))" andalso terms2str asm = "[]"
509 then () else error "factout_ 2 changed";
510 val SOME (t', asm) = cancel_(*p_*) thy t;
511 if term2str t' = "(3 - 3 * x) / 2" andalso terms2str asm = "[\"-1 + x ~= 0\"]"
512 then () else error "cancel_ 2 changed";
514 val t = str2term "((x + (-1)) / (x + 1)) + ((x + 1) / (x + (-1)))";
515 val SOME (t', asm) = add_fraction_p_ thy t;
516 if term2str t' = "(2 + 2 * x ^^^ 2) / (-1 + x ^^^ 2)" andalso terms2str asm = "[]"
517 then () else error "add_fraction_p_ 3 changed";
518 val SOME (t', asm) = common_nominator_p_ thy t;
520 "(-1 + x) * (-1 + x) / ((1 + x) * (-1 + x)) +\n(1 + x) * (1 + x) / ((1 + x) * (-1 + x))"
521 andalso terms2str asm = "[]"
522 then () else error "common_nominator_p_ 3 changed";
524 val t = str2term "((x - 1) / (x + 1)) + ((x + 1) / (x - 1))";
525 val SOME (t', asm) = add_fraction_ thy t;
526 if term2str t' = "(2 + 2 * x ^^^ 2) / (-1 + x ^^^ 2)" andalso terms2str asm = "[]"
527 then () else error "factout_ 4 changed";
528 val SOME (t', asm) = common_nominator_ thy t;
530 "(-1 + x) * (-1 + x) / ((1 + x) * (-1 + x)) +\n(1 + x) * (1 + x) / ((1 + x) * (-1 + x))"
531 andalso terms2str asm = "[]"
532 then () else error "cancel_ 4 changed";
535 "((1) / (2*x + 2)) + ((1) / (2*x + (-2))) + ((1) / ( x^^^2 + (-1)))+((1) / (x^^^2 + (-2)*x + 1))";
536 val SOME (t', asm) = add_fraction_p_ thy t;
537 if term2str t' = "x / (1 + -2 * x + x ^^^ 2)" andalso terms2str asm = "[\"1 + x ~= 0\"]"
538 then () else error "add_fraction_p_ 5 changed";
539 val SOME (t', asm) = norm_rational_ thy t;
540 if term2str t' = "x / (1 + -2 * x + x ^^^ 2)" andalso terms2str asm = "[\"1 + x ~= 0\"]"
541 then () else error "norm_rational_ 5 changed";
544 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))";
545 val SOME (t3',_) = common_nominator_ thy t3;
546 val SOME (t3'',_) = add_fraction_ thy t3;
550 val SOME(t4,t5) = norm_expanded_rat_ thy t3;
556 val t=(term_of o the o (parse thy)) "(9 - x^^^2)/(9 - 6*x + x^^^2)";
557 val SOME (t',_) = factout_ thy t;
558 val SOME (t'',_) = cancel_ thy t;
561 "(3 + x) * (3 - x) / ((3 - x) * (3 - x))";
564 val t=(term_of o the o (parse thy))
565 "(9 - x^^^2) / (9 - 6*x + x^^^2) + 1 / (3 - x)";
566 val SOME (t',_) = common_nominator_ thy t;
567 val SOME (t'',_) = add_fraction_ thy t;
570 "(9 - x ^^^ 2) / ((3 - x) * (3 - x)) + 1 * (3 - x) / ((3 - x) * (3 - x))";
573 (*WN021016 added -----vv---*)
574 val t = str2term "(9 - x^^^2) / (9 - 6*x + x^^^2) + 1";
575 val SOME (t',_) = common_nominator_ thy t;
576 val SOME (t'',_) = add_fraction_ thy t;
577 term2str t' = "(9 - x ^^^ 2) / (9 - 6 * x + x ^^^ 2) +\n1" ^
578 " * (9 - 6 * x + x ^^^ 2) / (9 - 6 * x + x ^^^ 2)" (*true*);
579 term2str t'' = "6 / (3 - x)" (*true*);
581 val t = str2term "1 + (9 - x^^^2) / (9 - 6*x + x^^^2)";
582 val SOME (t',_) = common_nominator_ thy t;
583 val SOME (t'',_) = add_fraction_ thy t;
584 term2str t' = "1 * (9 - 6 * x + x ^^^ 2) / (9 - 6 * x + x ^^^ 2) +\n" ^
585 "(9 - x ^^^ 2) / (9 - 6 * x + x ^^^ 2)" (*true*);
586 term2str t'' = "6 / (3 - x)" (*true*);
587 (*WN021016 added -----^^---*)
588 (*WN030602 added -----vv--- no rewrite -> NONE !*)
589 val t = str2term "1 / a";
590 val NONE = cancel_p_ thy t;
591 val NONE = rewrite_set_ thy false cancel_p t;
592 (*WN.2.6.03 added -------^^---*)
594 val t = str2term "(y^^^2 - x^^^2)/(y^^^2 - 2*y*x + x^^^2)";
595 val SOME (t',_) = factout_ thy t;
596 val SOME (t'',_) = cancel_ thy t;
597 term2str t' = "(y + x) * (y - x) / ((y - x) * (y - x))"(*true*);
598 term2str t'' = "(y + x) / (y - x)";
600 val t = str2term "(y^^^2 - x^^^2)/(y^^^2 - 2*y*x + x^^^2) + 1 / (y - x)";
601 val SOME (t',_) = common_nominator_ thy t;
602 val SOME (t'',_) = add_fraction_ thy t;
604 "(-1 * x ^^^ 2 + y ^^^ 2) / ((-1 * x + y) * (-1 * x + y)) +\n1" ^
605 " * (-1 * x + y) / ((-1 * x + y) * (-1 * x + y))" (*true*);
606 term2str t'' = "(-1 - x - y) / (x - y)" (*true*);
608 val t = str2term "(x^^^2 - y^^^2)/(x^^^2 - 2*x*y + y^^^2) + 1 / (x - y)";
609 val SOME (t',_) = common_nominator_ thy t;
610 val SOME (t'',_) = add_fraction_ thy t;
611 if term2str t' = "(-1 * y ^^^ 2 + x ^^^ 2) / ((-1 * y + x) * (-1 * y + x))" ^
612 " +\n1 * (-1 * y + x) / ((-1 * y + x) * (-1 * y + x))" then ()
613 else error "rational.sml lex-ord 1";
614 if term2str t'' = "(-1 - y - x) / (y - x)" then ()
615 else error "rational.sml lex-ord 2";
616 (*WN.16.10.02 WN070905 lexicographische Ordnung erhalten *)
619 val t = str2term "(x^^^2 - y^^^2)/(x^^^2 - 2*x*y + y^^^2)";
620 val SOME (t',_) = norm_expanded_rat_ thy t;
621 if term2str t' = "(x + y) / (x - y)" then ()
622 else error "rational.sml term2poly: invalid x ^^^ 2 - y ^^^ 2 No.1";
623 (*val SOME (t'',_) = norm_rational_ thy t;
624 *** RATIONALS_TERM2POLY_EXCEPTION: Invalid Polynomial
625 WN.16.10.02 ?! + WN060831???SK4
626 WN070905 *** term2poly: invalid = x ^^^ 2 - y ^^^ 2*)
629 val t = str2term "(9 - x^^^2)/(9 - 6*x + x^^^2) + (1)/(3 + x)";
630 val SOME (t',_) = norm_expanded_rat_ thy t;
631 if term2str t' = "(12 + 5 * x + x ^^^ 2) / (9 - x ^^^ 2)" then ()
632 else error "rational.sml (9 - x^^^2)/(9 - 6*x + x^^^2) +...";
633 (*val SOME (t'',_) = norm_rational_ thy t;
634 *** RATIONALS_TERM2POLY_EXCEPTION: Invalid Polynomial WN.16.10.02 ?!
635 WN070906 *** term2poly: invalid = 9 - x ^^^ 2 SK.term2poly*)
637 val t=(term_of o the o (parse thy))
638 "(9 + (-1)* x^^^2)/(9 + (-1)* 6*x + x^^^2) + (1)/(3 + x)";
639 val SOME (t',_) = norm_expanded_rat_ thy t;
640 val SOME (t'',_) = norm_rational_ thy t;
643 "(12 + 5 * x + x ^^^ 2) / (9 - x ^^^ 2)";
644 "(12 + 5 * x + x ^^^ 2) / (9 + (-1) * x ^^^ 2)";
647 "-------- cancel from: Mathematik 1 Schalk Reniets Verlag";
648 "-------- cancel from: Mathematik 1 Schalk Reniets Verlag";
649 "-------- cancel from: Mathematik 1 Schalk Reniets Verlag";
650 val thy = @{theory "Rational"};
651 val thy' = "Rational";
653 val mp = "make_polynomial";
655 writeln ("example 186:");
657 val e186a'="(14 * x * y) / ( x * y )";(*SRC*)
658 rewrite_set_ thy false cancel (str2term e186a');
660 val e186a = the (rewrite_set thy' false "cancel" e186a');
661 is_expanded (parse_rat "14 * x * y");
662 is_expanded (parse_rat "x * y");
663 if e186a = ("14 / 1", "[\"y * x ~= 0\"]") then ()
664 else error "rational.sml cancel Schalk e186a";
667 val e186b'="(60 * a * b) / ( 15 * a * b )";
668 val e186b = the (rewrite_set thy' false "cancel" e186b');
670 val e186c'="(144 * a^^^2 * b * c) / (12 * a * b * c )";
671 val e186c = (the (rewrite_set thy' false "cancel" e186c'))
672 handle e => print_exn_G e;
673 val t = (term_of o the o (parse thy)) e186c';
674 if e186c = ("12 * a / 1", "[\"12 * (c * (b * a)) ~= 0\"]") then ()
675 else error "rational.sml cancel Schalk e186c";
677 writeln ("example 187:");
679 val e187a'="(12 * x * y) / (8 * y^^^2 )";(*SRC*)
680 val e187a = the (rewrite_set thy' false "cancel" e187a');
682 val e187b'="(8 * x^^^2 * y * z ) / (18 * x * y^^^2 * z )";
683 val e187b = the (rewrite_set thy' false "cancel" e187b');
685 val e187d'="(9 * x^^^5 * y^^^2 * z^^^4) / (15 * x^^^6 * y^^^3 * z )";(*SRC*)
686 val e187d = the (rewrite_set thy' false "cancel" e187d');
687 if e187d = ("3 * z ^^^ 3 / (5 * (y * x))",
688 "[\"3 * (z * (y ^^^ 2 * x ^^^ 5)) ~= 0\"]") then ()
689 else error "rational.sml cancel Schalk e186d";
691 writeln "example 188:";
692 val e188a'="(-8 + 8 * x) / (-9 + 9 * x)";(*SRC*)
693 val e188a = the (rewrite_set thy' false "cancel" e188a');
694 is_expanded (parse_rat "8 * x + -8");
695 (* e188a = ("8 / 9",["not ((-1) + x = 0)"]) then () 13.3.03*)
696 if e188a = ("8 / 9", "[\"-1 + x ~= 0\"]") then ()
697 else error "rational.sml: e188a new behaviour";
699 val SOME (t,_) = rewrite_set thy' false mp "(8*((-1) + x))/(9*((-1) + x))";
701 val e188b'="(-15 + 5 * x) / (-18 + 6 * x)";(*SRC*)
702 val SOME (t, asm) = rewrite_set thy' false "cancel" e188b';
703 t = "5 / 6" (*true*);
706 val e188c'="( a + -1 * b ) / ( b + -1 * a )";
707 val e188c = the (rewrite_set thy' false "cancel_p" e188c');
708 (*is_expanded (parse_rat "a + -1 * b");*)
710 rewrite_set thy' false mp "((-1)*(b + (-1) * a))/(1*(b + (-1) * a))";
711 if t= "(a + -1 * b) / (-1 * a + b)" then()
712 else error "rational.sml: e188c new behaviour";
714 writeln ("example 190:");
716 val e190c'="( 27 * a^^^3 + 9 * a^^^2 + 3 * a + 1 ) / ( 27 * a^^^3 + 18 * a^^^2 + 3 * a )";
717 val e190c = the (rewrite_set thy' false "cancel" e190c');
718 val SOME (t,_) = rewrite_set thy' false mp "((1 + 9 * a ^^^ 2)*(1 + 3 * a))/((3 * a + 9 * a ^^^ 2)*(1 + 3 * a))";
719 if t = "(1 + 3 * a + 9 * a ^^^ 2 + 27 * a ^^^ 3) /\n(3 * a + 18 * a ^^^ 2 + 27 * a ^^^ 3)" then ()
720 else error "rational.sml: e190c new behaviour";
722 writeln ("example 191:");
724 val e191a'="( x^^^2 + -1 * y^^^2 ) / ( x + y )";
726 val e191a = the (rewrite_set thy' false "cancel" e191a');
727 is_expanded (parse_rat "x^^^2 + -1 * y^^^2");
729 is_expanded (parse_rat "x + y");
731 val SOME (t,_) = rewrite_set thy' false mp "((x + (-1) * y)*(x + y))/((1)*(x + y))";
732 (* t="(x ^^^ 2 + -1 * y ^^^ 2) / (x + y)" then() WN.13.3.03*)
733 if t="(x ^^^ 2 + -1 * y ^^^ 2) / (x + y)" then()
734 else error "rational.sml: e191a new behaviour";
737 val e191c'="( 9 * x^^^2 + -30 * x + 25 ) / ( 9 * x^^^2 + -25 )";
739 val e191c = the (rewrite_set thy' false "cancel" e191c');
740 is_expanded (parse_rat "9 * x^^^2 + -30 * x + 25");
742 is_expanded (parse_rat "25 + -30*x + 9*x^^^2");
744 is_expanded (parse_rat "-25 + 9*x^^^2");
746 val SOME (t,_) = rewrite_set thy' false mp "(((-5) + 3 * x)*((-5) + 3 * x))/((5 + 3 * x)*((-5) + 3 * x))";
747 (* t="(25 + ((-30) * x + 9 * x ^^^ 2)) / ((-25) + 9 * x ^^^ 2)"then() 13.3.03*)
748 if t= "(25 + -30 * x + 9 * x ^^^ 2) / (-25 + 9 * x ^^^ 2)" then()
749 else error "rational.sml: 'e191c' new behaviour";
752 writeln ("example 192:");
754 val e192b'="( 7 * x^^^3 + -1 * x^^^2 * y ) / ( 7 * x * y^^^2 + -1 * y^^^3 )";
756 val e192b = the (rewrite_set thy' false "cancel" e192b');
757 -------------------*)
758 val SOME (t',_) = rewrite_set thy' false mp "((x ^^^ 2)*(7 * x + (-1) * y))/((y ^^^ 2)*(7 * x + (-1) * y))";
759 (*========== inhibit exn 110317 ================================================
760 if t' = "(7 * x ^^^ 3 + -1 * x ^^^ 2 * y) / (7 * x * y ^^^ 2 + -1 * y ^^^ 3)"
761 (*"(-1 * y * x ^^^ 2 + 7 * x ^^^ 3) / (-1 * y ^^^ 3 + 7 * x * y ^^^ 2)"WN050929*)
762 then () else error "rational.sml: 'e192b' new behaviour";
763 (*^^^ works with MG's simplifier vvv*)
764 val t =str2term"((x ^^^ 2)*(7 * x + (-1) * y))/((y ^^^ 2)*(7 * x + (-1) * y))";
765 val SOME (t',_) = rewrite_set_ thy false make_polynomial t;
766 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";
767 ============ inhibit exn 110317 ==============================================*)
769 writeln ("example 193:");
771 val e193a'="( x^^^2 + -6 * x + 9 ) / ( x^^^2 + -9 )";
773 val e193a = the (rewrite_set thy' false "cancel" e193a');
774 -------------------*)
776 val e193b'="( x^^^2 + -8 * x + 16 ) / ( 2 * x^^^2 + -32 )";
778 val e193b = the (rewrite_set thy' false "cancel" e193b');
780 val e193c'="( 2 * x + -50 * x^^^3 ) / ( 25 * x^^^2 + -10 * x + 1 )";
781 val SOME(t,_) = rewrite_set thy' false "cancel" e193c';
782 -------------------*)
784 val wn01 = "(-25 + 9*x^^^2)/(5 + 3*x)";
785 val SOME (t, asm) = rewrite_set thy' false "cancel" wn01;
786 (* t = "((-5) + 3 * x) / 1" then () WN.13.3.03*)
787 if t = "(-5 + 3 * x) / 1" andalso asm = "[\"5 + 3 * x ~= 0\"]" then ()
788 else error "rational.sml: new behav. in cancel wn01";
790 "-------- common_nominator_p ----------------------------";
791 "-------- common_nominator_p ----------------------------";
792 "-------- common_nominator_p ----------------------------";
793 val rls' = "common_nominator_p";
795 writeln ("example 204:");
797 val e204a'="((5 * x) / 9) + ((3 * x) / 9) + (x / 9)";
798 val e204a = the (rewrite_set thy' false "common_nominator_p" e204a');
800 val e204b'="5 / x + -3 / x + -1 / x";
801 val e204b = the (rewrite_set thy' false "common_nominator_p" e204b');
802 if e204b = ("1 / x", "[]") then ()
803 else error "rational.sml common_nominator_p example e204b";
805 writeln ("example 205:");
807 val e205a'="((4 * x + 7) / 8) + ((4 * x + 3) / 8)";
808 val e205a = the (rewrite_set thy' false "common_nominator_p" e205a');
810 val e205b'="((5 * x + 2) / 3) + ((-2 * x + 1) / 3)";
811 val e205b = the (rewrite_set thy' false "common_nominator_p" e205b');
812 if e205b = ("(1 + x) / 1", "[]") then ()
813 else error "rational.sml common_nominator_p example e204b";
815 writeln ("example 206:");
817 val e206a'="((5 * x + 4) / (2 * x + -1)) + ((9 * x + 5) / (2 * x + -1))";
818 val e206a = the (rewrite_set thy' false "common_nominator_p" e206a');
820 val e206b'="((17 * x + -23) / (5 * x + 4)) + ((-25 + -17 * x) / (5 * x + 4))";
821 val e206b = the (rewrite_set thy' false "common_nominator_p" e206b');
823 writeln ("example 207:");
824 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)) ";
825 val e207 = the (rewrite_set thy' false "common_nominator_p" e207');
827 writeln ("example 208:");
828 val e208'="((3 * x + 2) / (x + 2)) + ((5 * x + -1) / (x + 2)) + ((-7 * x + -3) / (x + 2)) + ((-1 * x + -3) / (x + 2)) ";
829 val e208 = the (rewrite_set thy' false "common_nominator_p" e208');
831 writeln ("example 209:");
832 val e209'="((3 * x + -7 * y + 3 * z) / (4)) + ((2 * x + 17 * y + 10 * z) / (4)) + ((-1 * x + 2 * y + z) / (4)) ";
833 val e209 = the (rewrite_set thy' false "common_nominator_p" e209');
835 writeln ("example 210:");
836 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)) ";
837 val e210 = the (rewrite_set thy' false "common_nominator_p" e210');
839 writeln ("example 211:");
841 val e211a'="((b) / (a + -1 * b)) + ((-1 * a) / (a + -1 * b))";
842 val e211a = the (rewrite_set thy' false "common_nominator_p" e211a');
844 val e211b'="((b) / (b^^^2 + -1 * a^^^2)) + ((-1 * a) / (b^^^2 + -1 * a^^^2))";
845 val e211b = the (rewrite_set thy' false "common_nominator_p" e211b');
847 writeln ("example 212:");
849 val e212a'="((4) / (x)) + ((-3) / (y)) + -1";
850 val e212a = the (rewrite_set thy' false "common_nominator_p" e212a');
852 val e212b'="((4) / (x)) + ((-5) / (y)) + ((6) / (x*y))";
853 val e212b = the (rewrite_set thy' false "common_nominator_p" e212b');
855 writeln ("example 213:");
857 val e213a'="((5 * x) / (3 * y^^^2)) + ((19 * z) / (6 * x * y)) + ((-2 * x) / (3 * y^^^2)) + ((7 * y^^^2) / (6 * x^^^2)) ";
858 val e213a = the (rewrite_set thy' false "common_nominator_p" e213a');
860 val e213b'="((2 * b) / (3 * a^^^2)) + ((3 * c) / (7 * a * b)) + ((4 * b) / (3 * a^^^2)) + ((3 * a) / (7 * b^^^2))";
861 val e213b = the (rewrite_set thy' false "common_nominator_p" e213b');
863 writeln ("example 214:");
865 val e214a'="((3 * x + 2 * y + 2 * z) / (4)) + ((-5 * x + -3 * y) / (3)) + ((x + y + -2 * z) / (2))";
866 val e214a = the (rewrite_set thy' false "common_nominator_p" e214a');
868 val e214b'="((5 * x + 2 * y + z) / (2)) + ((-7 * x + -3 * y) / (3)) + ((3 * x + 6 * y + -1 * z) / (12))";
869 val e214b = the (rewrite_set thy' false "common_nominator_p" e214b');
871 writeln ("example 216:");
873 val e216a'="((2 * b + 3 * c) / (a * c)) + ((3 * a + b) / (a * b)) + ((-2 * b^^^2 + -3 * a * c) / (a * b * c))";
874 val e216a = the (rewrite_set thy' false "common_nominator_p" e216a');
876 val e216b'="((2 * a + 3 * b) / (b * c)) + ((3 * c + a) / (a * c)) + ((-2 * a^^^2 + -3 * b * c) / (a * b * c))";
877 val e216b = the (rewrite_set thy' false "common_nominator_p" e216b');
879 writeln ("example 217:");
880 val e217'="((z + -1) / (z)) + ((3 * z ^^^2 + -6 * z + 5) / (z^^^2)) + ((-4 * z^^^3 + 7 * z^^^2 + -5 * z + 5) / (z^^^3))";
881 val e217 = the (rewrite_set thy' false "common_nominator_p" e217');
884 val rls' = "common_nominator";
885 writeln ("example 218:");
886 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))";
887 val e218 = the (rewrite_set thy' false "common_nominator" e218');
888 if e218 = ("(16 - 63 * a ^^^ 2 - 81 * a ^^^ 3) / (108 * a ^^^ 4)", "[]") then ()
889 else error "rationa.sml common_nominator example e218";
891 writeln ("example 219:");
893 val e219a'="((1) / (y + 1)) + ((1) / (y + 2)) + ((1) / (y + 3))";
894 val e219a = the (rewrite_set thy' false "common_nominator" e219a');
896 val e219b'="((1) / (x + 1)) + ((1) / (x + 2)) + ((-2) / (x + 3))";
897 val e219b = the (rewrite_set thy' false "common_nominator" e219b');
898 if e219b = ("(5 + 3 * x) / (6 + 11 * x + 6 * x ^^^ 2 + x ^^^ 3)", "[]") then ()
899 else error "rationa.sml common_nominator example e219b";
901 writeln ("example 220:");
903 val e220a'="((17) / (5 * r + -2)) + ((-13) / (2 * r + 3)) + ((4) / (3 * r + -5))";
904 val e220a = the (rewrite_set thy' false "common_nominator" e220a');
906 val e220b'="((20 * a) / (a + -3)) + ((-19 * a) / (a + -4)) + ((a) / (a + -5))";
907 val e220b = the (rewrite_set thy' false "common_nominator" e220b');
909 writeln ("example 221:");
911 val e221a'="((a + b) / (a + -1 * b)) + ((a + -1 * b) / (a + b))";
912 val e221a = the (rewrite_set thy' false "common_nominator" e221a');
914 val e221b'="((x + -1 * y) / (x + y)) + ((x + y) / (x + -1 * y)) ";
915 val e221b = the (rewrite_set thy' false "common_nominator" e221b');
917 writeln ("example 222:");
919 val e222a'="((1 + -1 * x) / (1 + x)) + ((-1 + -1 * x) / (1 + -1 * x)) + ((4 * x) / (1 + -1 * x^^^2))";
920 val e222a = the (rewrite_set thy' false "common_nominator" e222a');
922 val e222b'="((1 + x ) / (1 + -1 * x)) + ((-1 + x) / (1 + x)) + ((2 * x) / (1 + -1 * x^^^2))";
923 val e222b = the (rewrite_set thy' false "common_nominator" e222b');
925 writeln ("example 225:");
927 val e225a'="((6 * a) / (a^^^2 + -64)) + ((a + 2) / (2 * a + 16)) + ((-1) / (2))";
928 val e225a = the (rewrite_set thy' false "common_nominator" e225a');
930 val e225b'="((a + 2 ) / (2 * a + 12)) + ((4 * a) / (a^^^2 + -36)) + ((-1) / (2))";
931 val e225b = the (rewrite_set thy' false "common_nominator" e225b');
933 writeln ("example 226:");
935 val e226a'="((35 * z) / (49 * z^^^2 + -4)) + -1 + ((14 * z + -1) / (14 * z + 4)) ";
936 val e226a = the (rewrite_set thy' false "common_nominator" e226a');
938 val e226b'="((45 * a * b) / (25 * a^^^2 + -9 * b^^^2)) + ((20 * a + 3 * b) / (10 * a + 6 * b)) + -2";
939 val e226b = the (rewrite_set thy' false "common_nominator" e226b');
941 writeln ("example 227:");
943 val e227a'="((6 * z + 11) / (6 * z + 14)) + ((9 * z ) / (9 * z^^^2 + -49)) + -1 ";
944 val e227a = the (rewrite_set thy' false "common_nominator" e227a');
946 val e227b'="((16 * a + 37 * b) / (4 * a + 10 * b)) + ((6 * a * b) / (4 * a^^^2 + -25 * b^^^2)) + -4 ";
947 val e227b = the (rewrite_set thy' false "common_nominator" e227b');
949 writeln ("example 228:");
951 val e228a'="((7 * a + 11) / (3 * a^^^2 + -3)) + ((-2 * a + -1) / (a^^^2 + -1 * a)) + ((-1) / (3 * a + 3))";
952 val e228a = the (rewrite_set thy' false "common_nominator" e228a');
954 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))";
955 val e228b = the (rewrite_set thy' false "common_nominator" e228b');
958 writeln ("example 229:");
960 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))";
961 val e229a = the (rewrite_set thy' false "common_nominator" e229a');
963 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))";
964 val e229b = the (rewrite_set thy' false "common_nominator" e229b');
966 writeln ("example 230:");
968 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))";
969 val e230a = the (rewrite_set thy' false "common_nominator" e230a');
971 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))";
972 val e230b = the (rewrite_set thy' false "common_nominator" e230b');
974 writeln ("example 231:");
976 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))";
977 val e231a = the (rewrite_set thy' false "common_nominator" e231a');
979 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))";
980 val e231b = the (rewrite_set thy' false "common_nominator" e231b');
982 writeln ("example 232:");
984 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))";
985 val e232a = the (rewrite_set thy' false "common_nominator" e232a');
987 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))";
988 val e232b = the (rewrite_set thy' false "common_nominator" e232b');
990 writeln ("example 233:");
992 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))";
993 val e233a = the (rewrite_set thy' false "common_nominator" e233a');
995 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))";
996 val e233b = the (rewrite_set thy' false "common_nominator" e233b');
998 writeln ("example 234:");
1000 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))";
1001 val e234a = the (rewrite_set thy' false "common_nominator" e234a');
1003 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)) ";
1004 val e234b = the (rewrite_set thy' false "common_nominator" e234b');
1006 writeln ("example 235:");
1008 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))";
1009 val e235a = the (rewrite_set thy' false "common_nominator" e235a');
1011 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)) ";
1012 val e235b = the (rewrite_set thy' false "common_nominator" e235b');
1014 writeln ("example 236:");
1016 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))";
1017 val e236a = the (rewrite_set thy' false "common_nominator" e236a');
1019 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)) ";
1020 val e236b = the (rewrite_set thy' false "common_nominator" e236b');
1023 val rls' = "cancel";
1024 writeln ("example heuberger:");
1025 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)";
1026 val eheu = the (rewrite_set thy' false "cancel" eheu');
1028 val rls' = "common_nominator_p";
1029 writeln ("example stiefel:");
1030 val est1'="(7) / (-14) + (-2) / (4)";
1031 val est1 = the (rewrite_set thy' false "common_nominator_p" est1');
1032 if est1 = ("-1 / 1", "[]") then ()
1033 else error "new behaviour in rational.sml: est1'";
1035 val t = (term_of o the o (parse thy))
1036 "(9 - x ^^^ 2) / (9 - 6 * x + x ^^^ 2)";
1037 val SOME (t',_) = factout_ thy t;
1038 if term2str t' = "(3 + x) * (3 - x) / ((3 - x) * (3 - x))" then ()
1039 else error "rational.sml factout_ (9 - x ^^^ 2) / (9 - 6 * x + x ^^^ 2)";
1042 "-------- reverse rewrite -------------------------------";
1043 "-------- reverse rewrite -------------------------------";
1044 "-------- reverse rewrite -------------------------------";
1045 (*WN.28.8.02: tests for the 'reverse-rewrite' functions:
1046 these are defined in Rationals.ML and stored in
1047 the 'reverse-ruleset' cancel*)
1049 (*the term for which reverse rewriting is demonstrated*)
1050 val t = (term_of o the o (parse thy))
1051 "(9 - x ^^^ 2) / (9 + 6 * x + x ^^^ 2)";
1052 val Rrls {scr=Rfuns {init_state=ini,locate_rule=loc,
1053 next_rule=nex,normal_form=nor,...},...} = cancel;
1055 (*normal_form produces the result in ONE step*)
1056 val SOME (t',_) = nor t;
1057 if term2str t' = "(3 - x) / (3 + x)" then ()
1058 else error "rational.sml normal_form (9 - x ^^^ 2) / (9 - 6 * x + x ^^^ 2)";
1060 (*initialize the interpreter state used by the 'me'*)
1061 val (t,_,revsets,_) = ini t;
1063 (*find the rule 'r' to apply to term 't'*)
1064 val SOME (r as (Thm (str, thm))) = nex revsets t;
1065 if str = "sym_#power_Float ((3,0), (0,0)) __ ((2,0), (0,0))"
1066 andalso string_of_thm thm =
1067 (string_of_thm o make_thm o (cterm_of (@{theory "Isac"})))
1068 (Trueprop $ (term_of o the o (parse thy)) "9 = 3 ^^^ 2") then ()
1069 else error "rational.sml next_rule (9 - x ^^^ 2) / (9 - 6 * x + x ^^^ 2)";
1070 (* before Isa02->09-2 was not checked automatically, ?was different?:
1071 val SOME r = nex revsets t;
1072 val r = Thm ("sym_#mult_2_3","6 = 2 * 3") : rule*)
1074 (* check, if the rule 'r' applied by the user to 't' belongs to the ruleset;
1075 if the rule is OK, the term resulting from applying the rule is returned,too;
1076 there might be several rule applications inbetween,
1077 which are listed after the head in reverse order *)
1078 val (r, (t, asm))::_ = loc revsets t r;
1079 if term2str t = "(9 - x ^^^ 2) / (3 ^^^ 2 + 6 * x + x ^^^ 2)" andalso asm = []
1081 else error "rational.sml locate_rule (9 - x ^^^ 2) / (9 - 6 * x + x ^^^ 2)";
1083 (* find the next rule to apply *)
1084 val SOME (r as (Thm (str, thm))) = nex revsets t;
1085 if str = "sym_#power_Float ((3,0), (0,0)) __ ((2,0), (0,0))" andalso
1086 string_of_thm thm = (string_of_thm o make_thm o (cterm_of (@{theory "Isac"})))
1087 (Trueprop $ (term_of o the o (parse thy)) "9 = 3 ^^^ 2") then ()
1088 else error "rational.sml next_rule (9 - x ^^^ 2) / (9 - 6 * x + x ^^^ 2)";
1090 (*check the next rule*)
1091 val (r, (t, asm)) :: _ = loc revsets t r;
1092 if term2str t = "(3 ^^^ 2 - x ^^^ 2) / (3 ^^^ 2 + 6 * x + x ^^^ 2)" then ()
1093 else error "rational.sml locate_rule (9 - x ^^^ 2) / (9 - 6 * x + x ^^^ 2) II";
1095 (*find and check the next rules, rewrite*)
1096 val SOME r = nex revsets t;
1097 val (r,(t,asm))::_ = loc revsets t r;
1098 if term2str t = "(3 ^^^ 2 - x ^^^ 2) / (3 ^^^ 2 + 2 * 3 * x + x ^^^ 2)" then ()
1099 else error "rational.sml locate_rule II";
1101 val SOME r = nex revsets t;
1102 val (r,(t,asm))::_ = loc revsets t r;
1103 if term2str t = "(3 - x) * (3 + x) / (3 ^^^ 2 + 2 * 3 * x + x ^^^ 2)" then ()
1104 else error "rational.sml next_rule II";
1106 val SOME r = nex revsets t;
1107 val (r,(t,asm))::_ = loc revsets t r;
1108 if term2str t = "(3 - x) * (3 + x) / ((3 + x) * (3 + x))" then ()
1109 else error "rational.sml next_rule III";
1111 val SOME r = nex revsets t;
1112 val (r, (t, asm)) :: _ = loc revsets t r;
1113 val ss = term2str t;
1114 if ss = "(3 - x) / (3 + x)" andalso terms2str asm = "[\"3 + x ~= 0\"]" then ()
1115 else error "rational.sml: new behav. in rev-set cancel";
1117 "-------- 'reverse-ruleset' cancel_p --------------------";
1118 "-------- 'reverse-ruleset' cancel_p --------------------";
1119 "-------- 'reverse-ruleset' cancel_p --------------------";
1120 (*WN.11.9.02: the 'reverse-ruleset' cancel_p*)
1122 (*the term for which reverse rewriting is demonstrated*)
1123 val t = str2term "(9 + (-1)*x^^^2) / (9 + ((-6)*x + x^^^2))";
1124 val Rrls {scr=Rfuns {init_state=ini,locate_rule=loc,
1125 next_rule=nex,normal_form=nor,...},...} = cancel_p;
1127 (*normal_form produces the result in ONE step*)
1128 val SOME (t',_) = nor t;
1129 term2str t' = "(3 + 1 * x) / (3 + -1 * x)";
1131 (*initialize the interpreter state used by the 'me'*)
1132 val SOME (t', asm) = cancel_p_ thy t;
1133 term2str t' = "(3 + x) / (3 + -1 * x)" (*true*);
1134 terms2str asm = "[\"3 + -1 * x ~= 0\"]" (*true*);
1135 val (t,_,revsets,_) = ini t;
1137 (* WN.10.10.02: dieser Fall terminiert nicht
1138 (make_polynomial enth"alt zu viele rules)
1139 WN060823 'init_state' requires rewriting on specified location in the term
1140 print_depth 99; Rfuns; print_depth 3;
1141 WN060831 cycling "sym_order_mult_rls_" "sym_mult_assoc"
1142 as was with make_polynomial before ?!?*)
1144 val SOME r = nex revsets t;
1145 eq_Thm (r, Thm ("sym_#power_Float ((3,0), (0,0)) __ ((2,0), (0,0))",
1146 mk_thm thy "9 = 3 ^^^ 2"));
1147 (*WN060831 *** id_of_thm
1148 Exception- ERROR raised ...
1149 val (r,(t,asm))::_ = loc revsets t r;
1152 val SOME r = nex revsets t;
1153 val (r,(t,asm))::_ = loc revsets t r;
1157 writeln "****************** all tests successfull *************************";
1161 (*WN.17.3.03 =========================================================vvv---*)
1162 "-------- norm_Rational ---------------------------------";
1163 "-------- norm_Rational ---------------------------------";
1164 "-------- norm_Rational ---------------------------------";
1165 val t = str2term "(3*x+5)/18 - x/2 - -(3*x - 2)/9 = 0";
1166 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
1167 if term2str t' = "1 / 18 = 0" then () else error "rational.sml 1";
1169 val t = str2term "(17*x - 51)/9 - (-(13*x - 3)/6) + 11 - (9*x - 7)/4 = 0";
1170 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
1171 if term2str t' = "(237 + 65 * x) / 36 = 0" then ()
1172 else error "rational.sml 2";
1174 val t = str2term "(1/2 + (5*x)/2)^^^2 - ((13*x)/2 - 5/2)^^^2 - (6*x)^^^2 + 29";
1175 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
1176 if term2str t' = "23 + 35 * x + -72 * x ^^^ 2" then ()
1177 else error "rational.sml 3";
1179 (*trace_rewrite:=true;*)
1180 val t = str2term "Not (6*x is_atom)";
1181 val SOME (t',_) = rewrite_set_ thy false powers_erls t; term2str t';
1183 val t = str2term "1 < 2";
1184 val SOME (t',_) = rewrite_set_ thy false powers_erls t; term2str t';
1187 val t = str2term "(6*x)^^^2";
1188 val SOME (t',_) = rewrite_ thy dummy_ord powers_erls false
1189 (num_str @{thm realpow_def_atom}) t;
1190 if term2str t' = "6 * x * (6 * x) ^^^ (2 + -1)" then ()
1191 else error "rational.sml powers_erls (6*x)^^^2";
1193 val t = str2term "-1 * (-2 * (5 / 2 * (13 * x / 2)))";
1194 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
1195 if term2str t' = "65 * x / 2" then () else error "rational.sml 4";
1197 val t = str2term "1 - ((13*x)/2 - 5/2)^^^2";
1198 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
1199 (*bef.040209: if term2str t' = "(-21 + (130 * x + -169 * x ^^^ 2)) / 4"then()*)
1200 if term2str t' = "(-21 + 130 * x + -169 * x ^^^ 2) / 4" then ()
1201 else error "rational.sml 5";
1203 (*SRAM Schalk I, p.92 Nr. 609a*)
1204 val t = str2term "2*(3 - x/5)/3 - 4*(1 - x/3) - x/3 - 2*(x/2 - 1/4)/27 +5/54";
1205 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
1206 if term2str t' = "(-255 + 112 * x) / 135" then ()
1207 else error "rational.sml 6";
1209 (*SRAM Schalk I, p.92 Nr. 610c*)
1210 val t = str2term "((x- 1)/(x+1) + 1) / ((x- 1)/(x+1) - (x+1)/(x- 1)) - 2";
1211 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
1212 if term2str t' = "(-3 + -1 * x) / 2" then () else error "rational.sml 7";
1214 (*SRAM Schalk I, p.92 Nr. 476a*)
1215 val t = str2term "(x^^^2/(1 - x^^^2) + 1)/(x/(1 - x) + 1) * (1 + x)";
1216 (*. a/b : c/d translated to a/b * d/c .*)
1217 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
1218 (*if term2str t' = "1 / 1" then () else error "rational.sml 8";3.6.03*)
1219 if term2str t' = "1" then () else error "rational.sml 8";
1221 (*............................vvv---TODO: sollte gehen mit poly_order *)
1222 (*Schalk I, p.92 Nr. 472a*)
1223 val t = str2term "((8*x^^^2 - 32*y^^^2)/(2*x + 4*y))/((4*x - 8*y)/(x + y))";
1224 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
1225 if term2str t' = "x + y" then () else error "rational.sml p.92 Nr. 472a";
1227 (*Schalk I, p.70 Nr. 480b; a/b : c/d translated to a/b * d/c*)
1228 val t = str2term ("((12*x*y/(9*x^^^2 - y^^^2))/" ^
1229 "(1/(3*x - y)^^^2 - 1/(3*x + y)^^^2)) *" ^
1230 "(1/(x - 5*y)^^^2 - 1/(x + 5*y)^^^2)/" ^
1231 "(20*x*y/(x^^^2 - 25*y^^^2))");
1232 (*... nicht simpl, zerlegt ...*)
1233 val t = str2term ("((12*x*y/(9*x^^^2 - y^^^2))/" ^
1234 "(1/(3*x - y)^^^2 - 1/(3*x + y)^^^2))");
1235 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
1236 "(-12 * (x * y ^^^ 3) + 108 * (x * (y * x ^^^ 2))) / (12 * (x * y))";
1237 (* ~~~~~~~~~~ poly_order notwendig!*)
1238 val t = str2term ("(1/(x - 5*y)^^^2 - 1/(x + 5*y)^^^2)/" ^
1239 "(20*x*y/(x^^^2 - 25*y^^^2))");
1240 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
1241 if term2str t' = "1 / (x ^^^ 2 + -25 * y ^^^ 2)" then ()
1242 else error "rational.sml norm_Rational 1 / (x ^^^ 2 + -25 * y ^^^ 2)";
1244 "nonterm.SK6 ----- SK060904-2a non-termination of add_fraction_p_";
1245 (*WN.2.6.03 from rlang.sml 56a
1246 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)";
1247 val NONE = rewrite_set_ thy false common_nominator_p t;
1249 WN060831 nonterm.SK7
1250 val t = str2term "(a + b * x) / (a + -1 * (b * x)) + (-1 * a + b * x) / (a + b * x)";
1251 val NONE = add_fraction_p_ thy t;
1255 (* ------------------------------------------------------------------- *)
1256 (*---------vvv------------ MG: ab 1.7.03 ----------------vvv-----------*)
1257 (* Simplifier fuer beliebige Buchterme *)
1258 (* ------------------------------------------------------------------- *)
1259 (*----------------------- norm_Rational_mg ----------------------------*)
1260 (* ------------------------------------------------------------------- *)
1262 "-------- numeral rationals -----------------------------";
1263 "-------- numeral rationals -----------------------------";
1264 "-------- numeral rationals -----------------------------";
1265 (*SRA Schalk I, p.40 Nr. 164b *)
1266 val t = str2term "(47/6 - 76/9 + 13/4)/(35/12)";
1267 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1269 if (term2str t) = "19 / 21" then ()
1270 else error "rational.sml: diff.behav. in norm_Rational_mg 1";
1272 (*SRA Schalk I, p.40 Nr. 166a *)
1273 val t = str2term "((5/4)/(4+22/7) + 37/20)*(110/3 - 110/9 * 23/11)";
1274 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1276 if (term2str t) = "45 / 2" then ()
1277 else error "rational.sml: diff.behav. in norm_Rational_mg 2";
1280 "-------- cancellation ----------------------------------";
1281 "-------- cancellation ----------------------------------";
1282 "-------- cancellation ----------------------------------";
1283 (* e190c Stefan K.*)
1285 "((1 + 9 * a ^^^ 2)*(1 + 3 * a))/((3 * a + 9 * a ^^^ 2)*(1 + 3 * a))";
1286 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1289 "(1 + 9 * a ^^^ 2) / (3 * a + 9 * a ^^^ 2)"
1291 else error "rational.sml: diff.behav. in norm_Rational_mg 3";
1293 (* e192b Stefan K.*)
1295 "((x ^^^ 2)*(7 * x + (-1) * y))/((y ^^^ 2)*(7 * x + (-1) * y))";
1296 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1301 else error "rational.sml: diff.behav. in norm_Rational_mg 4";
1303 (*SRC Schalk I, p.66 Nr. 379c *)
1306 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1311 else error "rational.sml: diff.behav. in norm_Rational_mg 5";
1313 (*SRC Schalk I, p.66 Nr. 380b *)
1315 "15*(3*x+3)*(4*x+9)/(12*(2*x+7)*(5*x+5))";
1316 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1319 "(27 + 12 * x) / (28 + 8 * x)"
1321 else error "rational.sml: diff.behav. in norm_Rational_mg 6";
1323 (*Schalk I, p.60 Nr. 215c *)
1324 (* Falsches Ergebnis: rechnet lange und cancel_p kann nicht weiter krzen!!!*)
1326 val t = str2term "(a+b)^^^4*(x - y)/((x - y)^^^3*(a+b)^^^2)";
1327 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1330 "(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)"
1332 else error "rational.sml: diff.behav. in norm_Rational_mg 7";
1335 "(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)"
1336 val SOME (t,_) = rewrite_set_ thy false cancel_p t;
1338 (* uncaught exception nonexhaustive binding failure
1339 raised at: stdIn:93.1-93.51 *)
1341 (*Schalk I, p.66 Nr. 381a *)
1342 (* ACHTUNG: rechnet ca. 2 Minuten !!! *)
1344 val t = str2term "18*(a+b)^^^3*(a - b)^^^2/(72*(a - b)^^^3*(a+b)^^^2)";
1345 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1348 "(a + b) / (4 * a + -4 * b)"
1349 then () else error "rational.sml: diff.behav. in norm_Rational_mg 8";
1352 (*SRC Schalk I, p.66 Nr. 381b *)
1354 "(4*x^^^2 - 20*x + 25)/(2*x - 5)^^^3";
1355 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1360 else error "rational.sml: diff.behav. in norm_Rational_mg 9";
1362 (*SRC Schalk I, p.66 Nr. 381c *)
1364 "(27*a^^^3+9*a^^^2+3*a+1)/(27*a^^^3+18*a^^^2+3*a)";
1365 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1368 "(1 + 9 * a ^^^ 2) / (3 * a + 9 * a ^^^ 2)"
1370 else error "rational.sml: diff.behav. in norm_Rational_mg 10";
1372 (*SRC Schalk I, p.66 Nr. 383a *)
1374 "(5*a^^^2 - 5*a*b)/(a - b)^^^2";
1375 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1378 "5 * a / (a + -1 * b)"
1380 else error "rational.sml: diff.behav. in norm_Rational_mg 11";
1383 "-------- common denominator ----------------------------";
1384 "-------- common denominator ----------------------------";
1385 "-------- common denominator ----------------------------";
1386 (*SRA Schalk I, p.67 Nr. 403a *)
1389 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1392 "(-3 * x + 4 * y + -1 * x * y) / (x * y)"
1394 else error "rational.sml: diff.behav. in norm_Rational_mg 12";
1396 (*SRA Schalk I, p.67 Nr. 407b *)
1398 "(2*a+3*b)/(b*c) + (3*c+a)/(a*c) - (2*a^^^2+3*b*c)/(a*b*c)";
1399 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1404 else error "rational.sml: diff.behav. in norm_Rational_mg 13";
1406 (*SRA Schalk I, p.67 Nr. 410b *)
1408 "1/(x+1) + 1/(x+2) - 2/(x+3)";
1409 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1412 "(5 + 3 * x) / (6 + 11 * x + 6 * x ^^^ 2 + x ^^^ 3)"
1414 else error "rational.sml: diff.behav. in norm_Rational_mg 14";
1416 (*SRA Schalk I, p.67 Nr. 413b *)
1418 "(1+x)/(1 - x) - (1 - x)/(1+x) + 2*x/(1 - x^^^2)";
1419 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1422 "6 * x / (1 + -1 * x ^^^ 2)"
1424 else error "rational.sml: diff.behav. in norm_Rational_mg 15";
1426 (*SRA Schalk I, p.68 Nr. 414a *)
1428 "(x + 2)/(x - 1) + (x - 3)/(x - 2) - (x + 1)/((x - 1)*(x - 2))";
1429 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1432 "(-2 + -5 * x + 2 * x ^^^ 2) / (2 + -3 * x + x ^^^ 2)"
1434 else error "rational.sml: diff.behav. in norm_Rational_mg 16";
1436 (*SRA Schalk I, p.68 Nr. 423a *)
1438 "(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)";
1439 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1444 else error "rational.sml: diff.behav. in norm_Rational_mg 17";
1446 (*SRA Schalk I, p.68 Nr. 428b *)
1448 "1/(a - b)^^^2 + 1/(a+b)^^^2 - 2/(a^^^2 - b^^^2) - 4*(b^^^2 - 1)/(a^^^2 - b^^^2)^^^2";
1449 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1452 "4 / (a ^^^ 4 + -2 * a ^^^ 2 * b ^^^ 2 + b ^^^ 4)"
1454 else error "rational.sml: diff.behav. in norm_Rational_mg 18";
1456 (*SRA Schalk I, p.68 Nr. 430b *)
1458 "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";
1459 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1464 else error "rational.sml: diff.behav. in norm_Rational_mg 19";
1467 (*SRA Schalk I, p.68 Nr. 432 *)
1469 "(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)";
1470 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1475 else error "rational.sml: diff.behav. in norm_Rational_mg 20";
1480 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1483 "(3 * y + b * x) / (b * y)"
1485 else error "rational.sml: diff.behav. in norm_Rational_mg 21";
1488 "-------- multiply and cancel ---------------------------";
1489 "-------- multiply and cancel ---------------------------";
1490 "-------- multiply and cancel ---------------------------";
1491 (*SRM Schalk I, p.68 Nr. 436a *)
1493 "3*(x+y)/(15*(x - y)) * 25*(x - y)^^^2/(18*(x+y)^^^2)";
1494 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1497 "(5 * x + -5 * y) / (18 * x + 18 * y)"
1499 else error "rational.sml: diff.behav. in norm_Rational_mg 22";
1501 (*SRM.test Schalk I, p.68 Nr. 436b *)
1502 (*WN060420???MG3 crashes with method 'simplify' in
1503 IsacCore > Simplification > Rational Terms > Multiplication > No.2*)
1504 val t = str2term "5*a*(a - b)^^^2*(a + b)^^^3/(7*b*(a - b)^^^3) * 7*b/(a + b)^^^3";
1505 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1508 "5 * a / (a + -1 * b)"
1510 else error "rational.sml: diff.behav. in norm_Rational_mg 23";
1512 (*Schalk I, p.68 Nr. 437a *)
1513 val t = str2term "(3*a - 4*b)/(4*c+3*e) * (3*a+4*b)/(9*a^^^2 - 16*b^^^2)";
1514 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1515 if (term2str t) = "1 / (4 * c + 3 * e)" then ()
1516 else error "rational.sml: diff.behav. in norm_Rational_mg 24";
1518 "----- S.K. corrected non-termination 060904";
1519 val t = str2term "(3*a - 4*b) * (3*a+4*b)/((4*c+3*e)*(9*a^^^2 - 16*b^^^2))";
1520 val SOME (t',_) = rewrite_set_ thy false make_polynomial t;
1523 "(9 * a ^^^ 2 + -16 * b ^^^ 2) /\n(36 * a ^^^ 2 * c + 27 * a ^^^ 2 * e + -64 * b ^^^ 2 * c +\n -48 * b ^^^ 2 * e)"
1524 (*"(9 * a ^^^ 2 + -16 * b ^^^ 2) / (36 * a ^^^ 2 * c + 27 * a ^^^ 2 * e + -64 * b ^^^ 2 * c + -48 * b ^^^ 2 * e)"*)
1525 then () else error "rational.sml: S.K.8..corrected 060904-6";
1527 "----- S.K. corrected non-termination of cancel_p_";
1528 val t'' = str2term ("(9 * a ^^^ 2 + -16 * b ^^^ 2) /" ^
1529 "(36 * a^^^2 * c + (27 * a^^^2 * e + (-64 * b^^^2 * c + -48 * b^^^2 * e)))");
1530 val SOME (t',_) = rewrite_set_ thy false cancel_p t'';
1531 if term2str t' = "1 / (4 * c + 3 * e)" then ()
1532 else error "rational.sml: diff.behav. in cancel_p S.K.8";
1534 (*Schalk I, p.68 Nr. 437b *)
1535 (* nonterm.SK9 loops: cancel_p kann nicht weiter kuerzen!!! *)
1536 val t'' = str2term "(a + b)/(x^^^2 - y^^^2) * ((x - y)^^^2/(a^^^2 - b^^^2))";
1537 (* val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t'';
1540 "================delete===";
1541 (*a casual output from above*)
1543 "(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)";
1544 (* WN060831 nonterm.SK10
1545 val SOME (t,_) = rewrite_set_ thy false cancel_p t;
1549 (*SRM Schalk I, p.68 Nr. 438a *)
1551 "x*y/(x*y - y^^^2)*(x^^^2 - x*y)";
1552 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1557 else error "rational.sml: diff.behav. in norm_Rational_mg 24";
1559 (*SRM Schalk I, p.68 Nr. 439b *)
1561 "(4*x^^^2+4*x+1)*((x^^^2 - 2*x^^^3)/(4*x^^^2+2*x))";
1562 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1565 "(x + -4 * x ^^^ 3) / 2"
1567 else error "rational.sml: diff.behav. in norm_Rational_mg 25";
1569 (*SRM Schalk I, p.68 Nr. 440a *)
1571 "(x^^^2 - 2*x)/(x^^^2 - 3*x) * (x - 3)^^^2/(x^^^2 - 4)";
1572 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1575 "(-3 + x) / (2 + x)"
1577 else error "rational.sml: diff.behav. in norm_Rational_mg 26";
1579 "----- Schalk I, p.68 Nr. 440b SK11 works since 0707xx";
1581 "(a^^^3 - 9*a)/(a^^^3*b - a*b^^^3)*(a^^^2*b+a*b^^^2)/(a+3)";
1582 val SOME (t,_) = rewrite_set_ thy false norm_Rational t;
1583 if term2str t = "(-3 * a + a ^^^ 2) / (a + -1 * b)" then ()
1584 else error "rational.sml: diff.behav. in norm_Rational 27";
1586 "----- SK12 works since 0707xx";
1587 val t = str2term "(a^^^3 - 9*a)*(a^^^2*b+a*b^^^2)/((a^^^3*b - a*b^^^3)*(a+3))";
1588 val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
1589 if term2str t' = "(-3 * a + a ^^^ 2) / (a + -1 * b)" then ()
1590 else error "rational.sml: diff.behav. in norm_Rational 28";
1593 "-------- common denominator and multiplication ---------";
1594 "-------- common denominator and multiplication ---------";
1595 "-------- common denominator and multiplication ---------";
1596 (*SRAM Schalk I, p.69 Nr. 441b *)
1597 val t = str2term "(4*a/3 + 3*b^^^2/a^^^3 + b/(4*a))*(4*b/(3*a))";
1598 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1601 "(36 * b ^^^ 3 + 3 * a ^^^ 2 * b ^^^ 2 + 16 * a ^^^ 4 * b) / (9 * a ^^^ 4)"
1602 then () else error "rational.sml: diff.behav. in norm_Rational_mg 28";
1604 (*SRAM Schalk I, p.69 Nr. 442b *)
1605 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)";
1606 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1609 "5 * x ^^^ 2 / (a * b ^^^ 3 * c)"
1610 then () else error "rational.sml: diff.behav. in norm_Rational_mg 29";
1612 (*SRAM Schalk I, p.69 Nr. 443b *)
1613 val t = str2term "(a/2 + b/3)*(b/3 - a/2)";
1614 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1617 "(-9 * a ^^^ 2 + 4 * b ^^^ 2) / 36"
1618 then () else error "rational.sml: diff.behav. in norm_Rational_mg 30";
1620 (*SRAM Schalk I, p.69 Nr. 445b *)
1621 val t = str2term "(a^^^2/9 + 2*a/(3*b) + 4/b^^^2)*(a/3 - 2/b) + 8/b^^^3";
1622 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1626 then () else error "rational.sml: diff.behav. in norm_Rational_mg 31";
1628 (*SRAM Schalk I, p.69 Nr. 446b *)
1629 val t = str2term "(x/(5*x + 4*y) - y/(5*x - 4*y) + 1)*(25*x^^^2 - 16*y^^^2)";
1630 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1633 "30 * x ^^^ 2 + -9 * x * y + -20 * y ^^^ 2"
1635 else error "rational.sml: diff.behav. in norm_Rational_mg 32";
1637 (*SRAM Schalk I, p.69 Nr. 449a *)(*Achtung: rechnet ca 8 Sekunden*)
1639 "(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)";
1640 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1642 if (term2str t) = "(-81 * x ^^^ 4 + 16 * x ^^^ 8 * y ^^^ 4) / (81 * y ^^^ 8)"
1643 then () else error "rational.sml: diff.behav. in norm_Rational_mg 33";
1646 (*SRAM Schalk I, p.69 Nr. 450a *)
1648 "(4*x/(3*y)+2*y/(3*x))^^^2 - (2*y/(3*x) - 2*x/y)*(2*y/(3*x)+2*x/y)";
1649 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1652 "(52 * x ^^^ 2 + 16 * y ^^^ 2) / (9 * y ^^^ 2)"
1654 else error "rational.sml: diff.behav. in norm_Rational_mg 34";
1657 "-------- double fractions ------------------------------";
1658 "-------- double fractions ------------------------------";
1659 "-------- double fractions ------------------------------";
1660 (*SRD Schalk I, p.69 Nr. 454b *)
1662 "((2 - x)/(2*a)) / (2*a/(x - 2))";
1663 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1666 "(-4 + 4 * x + -1 * x ^^^ 2) / (4 * a ^^^ 2)"
1668 else error "rational.sml: diff.behav. in norm_Rational_mg 35";
1670 (*SRD Schalk I, p.69 Nr. 455a *)
1672 "(a^^^2 + 1)/(a^^^2 - 1) / ((a+1)/(a - 1))";
1673 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1676 "(1 + a ^^^ 2) / (1 + 2 * a + a ^^^ 2)" then ()
1677 else error "rational.sml: diff.behav. in norm_Rational_mg 36";
1680 "----- Schalk I, p.69 Nr. 455b";
1681 val t = str2term "(x^^^2 - 4)/(y^^^2 - 9)/((2+x)/(3 - y))";
1682 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1683 if term2str t = "(2 + -1 * x) / (3 + y)" then ()
1684 else error "rational.sml: diff.behav. in norm_Rational_mg 37";
1686 "----- SK060904-1a non-termination of cancel_p_ ?: worked before 0707xx";
1687 val t = str2term "(x^^^2 - 4)*(3 - y)/((y^^^2 - 9)*(2+x))";
1688 val SOME (t,_) = rewrite_set_ thy false norm_Rational t;
1689 if term2str t = "(2 + -1 * x) / (3 + y)" then ()
1690 else error "rational.sml: diff.behav. in norm_Rational_mg 37b";
1692 "----- ?: worked before 0707xx";
1693 val t = str2term "(3 + -1 * y) / (-9 + y ^^^ 2)";
1694 val SOME (t,_) = rewrite_set_ thy false norm_Rational t;
1695 if term2str t = "-1 / (3 + y)" then ()
1696 else error "rational.sml: -1 / (3 + y) norm_Rational";
1698 (*SRD Schalk I, p.69 Nr. 456b *)
1700 "(b^^^3 - b^^^2)/(b^^^2+b)/(b^^^2 - 1)";
1701 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1703 if (term2str t) = "b / (1 + 2 * b + b ^^^ 2)" then ()
1704 else error "rational.sml: diff.behav. in norm_Rational_mg 38";
1706 (*SRD Schalk I, p.69 Nr. 457b *)
1708 "(16*a^^^2 - 9*b^^^2)/(2*a+3*a*b) / ((4*a+3*b)/(4*a^^^2 - 9*a^^^2*b^^^2))";
1709 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1712 "8 * a ^^^ 2 + -6 * a * b + -12 * a ^^^ 2 * b + 9 * a * b ^^^ 2"
1713 then () else error "rational.sml: diff.behav. in norm_Rational_mg 39";
1715 "----- Schalk I, p.69 Nr. 458b works since 0707";
1717 "(2*a^^^2*x - a^^^2)/(a*x - b*x) / (b^^^2*(2*x - 1)/(x*(a - b)))";
1718 val SOME (t,_) = rewrite_set_ thy false norm_Rational t;
1719 if term2str t = "a ^^^ 2 / b ^^^ 2" then ()
1720 else error "rational.sml: diff.behav. in norm_Rational_mg 39b";
1722 (*SRD Schalk I, p.69 Nr. 459b *)
1723 val t = str2term "(a^^^2 - b^^^2)/(a*b) / (4*(a+b)^^^2/a)";
1724 val SOME (t,_) = rewrite_set_ thy false norm_Rational t;
1725 if term2str t = "(a + -1 * b) / (4 * a * b + 4 * b ^^^ 2)" then ()
1726 else error "rational.sml: diff.behav. in norm_Rational_mg 41";
1729 (*Schalk I, p.69 Nr. 460b nonterm.SK
1731 "(9*(x^^^2 - 8*x+16)/(4*(y^^^2 - 2*y+1)))/((3*x - 12)/(16*y - 16))";
1732 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1735 else error "rational.sml: diff.behav. in norm_Rational_mg 42";
1738 "9*(x^^^2 - 8*x+16)*(16*y - 16)/(4*(y^^^2 - 2*y+1)*(3*x - 12))";
1739 val SOME (t',_) = rewrite_set_ thy false norm_Rational t;
1740 ... non terminating.
1741 val SOME (t',_) = rewrite_set_ thy false make_polynomial t;
1742 "(-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)";
1743 val SOME (t,_) = rewrite_set_ thy false cancel_p t';
1744 ... non terminating.*)
1746 (*SRD Schalk I, p.70 Nr. 472a *)
1747 val t = str2term ("((8*x^^^2 - 32*y^^^2)/(2*x + 4*y))/" ^
1748 "((4*x - 8*y)/(x + y))");
1749 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1754 else error "rational.sml: diff.behav. in norm_Rational_mg 43";
1757 (*----------------------------------------------------------------------*)
1758 (*---------------------- Einfache Dppelbrche --------------------------*)
1759 (*----------------------------------------------------------------------*)
1761 (*SRD Schalk I, p.69 Nr. 461a *)
1763 "(2/(x+3) + 2/(x - 3)) / (8*x/(x^^^2 - 9))";
1764 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1769 else error "rational.sml: diff.behav. in norm_Rational_mg 44";
1771 (*SRD Schalk I, p.69 Nr. 464b *)
1773 "(a - a/(a - 2)) / (a + a/(a - 2))";
1774 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1777 "(3 + -1 * a) / (1 + -1 * a)"
1779 else error "rational.sml: diff.behav. in norm_Rational_mg 45";
1781 (*SRD Schalk I, p.69 Nr. 465b *)
1783 "((x+3*y)/9 + (4*y^^^2 - 9*z^^^2)/(16*x)) /(x/9+y/6+z/4)";
1784 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1787 "(4 * x + 6 * y + -9 * z) / (4 * x)"
1789 else error "rational.sml: diff.behav. in norm_Rational_mg 46";
1791 (*SRD Schalk I, p.69 Nr. 466b *)
1793 "((1 - 7*(x - 2)/(x^^^2 - 4)) / (6/(x+2))) / (3/(x+5)+30/(x^^^2 - 25))";
1794 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1797 "(25 + -10 * x + x ^^^ 2) / 18"
1799 else error "rational.sml: diff.behav. in norm_Rational_mg 47";
1801 (*SRD Schalk I, p.70 Nr. 469 *)
1803 "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))";
1804 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1807 "3 * b ^^^ 3 / (2 * a + -2 * b)"
1809 else error "rational.sml: diff.behav. in norm_Rational_mg 48";
1811 (*----------------------------------------------------------------------*)
1812 (*---------------------- Mehrfache Dppelbrueche ------------------------*)
1813 (*----------------------------------------------------------------------*)
1815 (*SRD.test Schalk I, p.70 Nr. 476b *) (* Rechenzeit: 10 sec *)
1816 (*WN060419 crashes with method 'simplify' ????SK*)
1818 "((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)";
1819 val SOME (t,_) = rewrite_set_ thy false norm_Rational t;
1820 if term2str t = "1 / (a ^^^ 2 + -1 * b ^^^ 2)" then ()
1821 else error "rational.sml: diff.behav. in norm_Rational_mg 49";
1823 "----- Schalk I, p.70 Nr. 477a";
1824 (* MG Achtung: terme explodieren; Bsp zu komplex;
1825 L???ung sollte (ziemlich grosser) Faktorisierter Ausdruck sein
1826 val t = str2term "b*y/(b - 2*y)/((b^^^2 - y^^^2)/(b+2*y)) /" ^
1827 "(b^^^2*y+b*y^^^2)*(a+x)^^^2/((b^^^2 - 4*y^^^2)*(a+2*x)^^^2)";
1828 val SOME (t',_) = rewrite_set_ thy false norm_Rational t;
1831 val t = str2term "b*y*(b+2*y)*(b^^^2 - 4*y^^^2)*(a+2*x)^^^2 / " ^
1832 "((b - 2*y)*(b^^^2 - y^^^2)*(b^^^2*y+b*y^^^2)*(a+x)^^^2)";
1833 val SOME (t,_) = rewrite_set_ thy false make_polynomial t;
1837 "----- Schalk I, p.70 Nr. 478b ----- Rechenzeit: 5 sec";
1838 val t = str2term ("(a - (a*b+b^^^2)/(a+b))/(b+(a - b)/(1+(a+b)/(a - b))) / " ^
1839 "((a - a^^^2/(a+b))/(a+(a*b)/(a - b)))");
1840 val SOME (t',_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1842 "(2 * a ^^^ 3 + 2 * a ^^^ 2 * b) / (a ^^^ 2 * b + b ^^^ 3)"
1844 else error "rational.sml: diff.behav. in norm_Rational_mg 51";
1846 (* TODO.new_c:WN050820 STOP_REW_SUB introduced gave ...
1847 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 ()
1848 else error "rational.sml: works again";
1849 re-outcommented with TODO.new_c: cvs before 071227, 11:50*)
1853 (*Schalk I, p.70 Nr. 480a *)
1854 (* Achtung: rechnet ewig; cancel_p kann nicht krzen: WN060831 nonterm.SK00
1856 "(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)))";
1857 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1862 else error "rational.sml: diff.behav. in norm_Rational_mg 52";
1864 (*MG Berechne Zwischenergebnisse: WN060831 nonterm.SK00*)
1866 "(1/x+1/y+1/z)/(1/x - 1/y - 1/z)";
1867 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1869 "(x ^^^ 2 * y ^^^ 2 * z + x ^^^ 2 * y * z ^^^ 2 + x * y ^^^ 2 * z ^^^ 2) /
1870 (-1 * x ^^^ 2 * y ^^^ 2 * z + -1 * x ^^^ 2 * y * z ^^^ 2 + x * y ^^^ 2 * z ^^^ 2)";
1872 "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;
1877 (* SK 1. Ausdruck kann nicht weiter gekrzt werden; cancel_p !!!*)
1878 ### rls: cancel_p on:
1879 (x ^^^ 2 * (y ^^^ 2 * z) + x ^^^ 2 * (y * z ^^^ 2) + x * (y ^^^ 2 * z ^^^ 2)) /
1880 (-1 * (x ^^^ 2 * (y ^^^ 2 * z)) + -1 * (x ^^^ 2 * (y * z ^^^ 2)) + x * (y ^^^ 2 * z ^^^ 2))
1881 GC #3.61.81.101.197.17503: (0 ms)
1882 *** RATIONALS_DIRECT_CANCEL_EXCEPTION: Invalid fraction
1885 "(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))";
1886 val SOME (t,_) = rewrite_set_ thy false cancel_p t;
1888 (*uncaught exception nonexhaustive binding failure*)
1890 (* Das kann er aber krzen !!????: *)
1892 "(x^^^2 * (y^^^2 * z) + x * (y^^^2 * z^^^2)) / (-1 * (x^^^2 * (y * z^^^2)) + x * (y^^^2 * z^^^2))";
1893 val SOME (t,_) = rewrite_set_ thy false cancel_p t;
1895 "(-1 * (y * x) + -1 * (z * y)) / (1 * (z * x) + -1 * (z * y))";
1899 "-------- crucial examples ------------------------------";
1900 "-------- crucial examples ------------------------------";
1901 "-------- crucial examples ------------------------------";
1902 (*Schalk I, p.60 Nr. 215d *)
1903 (* Achtung: rechnet ewig ...
1904 val t = str2term "(a-b)^^^3 * (x+y)^^^4 / ((x+y)^^^2 * (a-b)^^^5)";
1905 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1906 term2str t; noterm.SK
1909 (* Kein Wunder, denn Z???ler und Nenner extra als Polynom dargestellt ergibt:*)
1911 val t = str2term "(a-b)^^^3 * (x+y)^^^4";
1912 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1914 "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";
1915 val t = str2term "((x+y)^^^2 * (a-b)^^^5)";
1916 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1918 "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";
1920 (*anscheinend macht dem Rechner das Krzen diese Bruches keinen Spass mehr ...*)
1922 (*--------------------------------------------------------------------*)
1923 (*Schalk I, p.70 Nr. 480b
1924 val t = str2term "((12*x*y/(9*x^^^2 - y^^^2))/" ^
1925 "(1/(3*x - y)^^^2 - 1/(3*x + y)^^^2)) *" ^
1926 "(1/(x - 5*y)^^^2 - 1/(x + 5*y)^^^2)/" ^
1927 "(20*x*y/(x^^^2 - 25*y^^^2))";
1928 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1930 Kann nicht weiter vereinfacht werden !!!!?? *)
1932 (*--------------------------------------------------------------------*)
1933 "---- MGs test set";
1934 val t = str2term " (1 + x^^^5) / (y + x) + x^^^3 / x ";
1935 val SOME (t,_) = rewrite_set_ thy false common_nominator_p t;
1936 if term2str t = "(1 + x ^^^ 3 + x ^^^ 5 + y * x ^^^ 2) / (x + y)" then()
1939 (*--------------------------------------------------------------------*)
1940 (* cancel_p liefert nicht immer Polynomnormalform (2): WN060831???SK3b
1941 ---> Sortierung FALSCH !! *)
1942 val t = str2term "b^^^3 * a^^^5/a ";
1943 val SOME (t,_) = rewrite_set_ thy false cancel_p t;
1945 "1 * (a^^^4 * b^^^3) / 1"; (*OK*)
1947 val t = str2term "b^^^3 * a^^^5/b ";
1948 val SOME (t,_) = rewrite_set_ thy false cancel_p t;
1950 "1 * (b^^^2 * a^^^5) / 1"; (*cancel_p sortiert hier falsch um!*)
1952 (* Problem liegt NICHT bei ord_make_polynomial! (siehe folgende Bsple) *)
1954 val x = str2term "x"; val bdv = str2term "bdv";
1955 val t1 = str2term "b^^^2 * a^^^5";
1956 val t2 = str2term "a^^^5 * b^^^2 ";
1957 ord_make_polynomial false Rational.thy [(x,bdv)] (t1,t2); (*false*)
1959 (* ==> "b^^^2 * a^^^5" > "a^^^5 * b^^^2 " ... OK!*)
1961 (*--------------------------------------------------------------------*)
1962 (* cancel_p liefert nicht immer Polynomnormalform (2): WN060831???SK3c
1963 ---> erzeugt berflssige "1 * ..."
1965 val t = str2term "-1 / (3 + y)";
1967 val SOME (t,_) = rewrite_set_ thy false cancel_p t;
1970 (********* Das ist das PROBLEM !!!!!!!??? *******************)
1971 (* -1 im Z???ler der Angabe verursacht das Problem !*)
1974 (* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *)
1975 "----- MGs test set";
1976 val t = str2term "(a^^^2 + -1)/(a+1)";
1977 val SOME (t',_) = rewrite_set_ thy false cancel_p t;
1978 if term2str t' = "(-1 + a) / 1" then ()
1979 else error "rational.sml MG tests 3d";
1981 "----- NOT TERMINATING ?: worked before 0707xx";
1982 val t = str2term "(a^^^2 - 1)*(b + 1) / ((b^^^2 - 1)*(a+1))";
1983 val SOME (t'',_) = rewrite_set_ thy false norm_Rational t;
1984 if term2str t'' = "(1 + -1 * a) / (1 + -1 * b)" then ()
1985 else error "rational.sml MG tests 3e";
1987 "----- corrected SK060905";
1988 val t = str2term "(4*x^^^2 - 20*x + 25)/(2*x - 5)^^^3";
1989 val SOME (t',_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
1990 if term2str t' = "-1 / (5 + -2 * x)" then ()
1991 else error "rational.sml corrected SK060905";
1994 "-------- examples for Stefan Karnels thesis ------------";
1995 "-------- examples for Stefan Karnels thesis ------------";
1996 "-------- examples for Stefan Karnels thesis ------------";
1997 (*SRAM Schalk I, p.69 Nr. 442b --- abgewandelt*)
1999 "(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))";
2000 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
2003 "5 * x ^^^ 2 / (b ^^^ 3 * c)"
2005 else error "rational.sml: diff.behav. in norm_Rational_mg 53";
2008 "-------- me Schalk I No.186 ----------------------------";
2009 "-------- me Schalk I No.186 ----------------------------";
2010 "-------- me Schalk I No.186 ----------------------------";
2011 val fmz = ["Term ((14 * x * y) / ( x * y ))",
2014 ("Rational",["rational","simplification"],
2015 ["simplification","of_rationals"]);
2016 val p = e_pos'; val c = [];
2017 val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
2018 val (p,_,f,nxt,_,pt) = me nxt p c pt;
2019 val (p,_,f,nxt,_,pt) = me nxt p c pt;
2020 val (p,_,f,nxt,_,pt) = me nxt p c pt;
2021 val (p,_,f,nxt,_,pt) = me nxt p c pt;
2022 val (p,_,f,nxt,_,pt) = me nxt p c pt;
2023 val (p,_,f,nxt,_,pt) = me nxt p c pt;
2024 val (p,_,f,nxt,_,pt) = me nxt p c pt;
2025 val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
2026 val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
2027 val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;(*++ for explicit script*)
2028 val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;(*++ for explicit script*)
2029 case (f2str f, nxt) of
2030 ("14", ("End_Proof'", _)) => ()
2031 | _ => error "rational.sml diff.behav. in me Schalk I No.186";
2034 "-------- interSteps ..Simp_Rat_Double_No-1.xml ---------";
2035 "-------- interSteps ..Simp_Rat_Double_No-1.xml ---------";
2036 "-------- interSteps ..Simp_Rat_Double_No-1.xml ---------";
2039 [(["Term (((2 - x)/(2*a)) / (2*a/(x - 2)))", "normalform N"],
2040 ("Rational",["rational","simplification"],
2041 ["simplification","of_rationals"]))];
2044 autoCalculate 1 CompleteCalc;
2045 val ((pt,p),_) = get_calc 1; show_pt pt;
2047 interSteps 1 ([1],Res);
2048 val ((pt,p),_) = get_calc 1; show_pt pt;
2051 "-------- interSteps ..Simp_Rat_Cancel_No-1.xml ---------";
2052 "-------- interSteps ..Simp_Rat_Cancel_No-1.xml ---------";
2053 "-------- interSteps ..Simp_Rat_Cancel_No-1.xml ---------";
2056 [(["Term ((a^2 + -1*b^2) / (a^2 + -2*a*b + b^2))", "normalform N"],
2057 ("Rational",["rational","simplification"],
2058 ["simplification","of_rationals"]))];
2061 autoCalculate 1 CompleteCalc;
2062 val ((pt,p),_) = get_calc 1; show_pt pt;
2063 (*========== inhibit exn 110314 ================================================
2064 (*with explicit script done already... and removed [1,..] at below...
2065 interSteps 1 ([1],Res);
2066 val ((pt,p),_) = get_calc 1; show_pt pt;
2068 interSteps 1 ([2],Res);
2069 val ((pt,p),_) = get_calc 1; show_pt pt;
2071 interSteps 1 ([2,1],Res);
2072 val ((pt,p),_) = get_calc 1; show_pt pt;
2073 val newnds = children (get_nd pt [2,1]) (*see "fun detailrls"*);
2074 (*if length newnds = 12 then () WN060905*)
2075 if length newnds = 13 then ()
2076 else error "rational.sml: interSteps cancel_p rev_rew_p";
2078 val p = ([2,1,9],Res);
2080 val (_, tac, _) = pt_extract (pt, p);
2081 (*case tac of SOME (Rewrite ("sym_real_plus_binom_times1", _)) => ()
2083 case tac of SOME (Rewrite ("sym_real_add_mult_distrib2", _)) => ()
2084 | _ => error "rational.sml: getTactic, sym_real_plus_binom_times1";
2085 ============ inhibit exn 110314 ==============================================*)
2088 "-------- investigate rulesets for cancel_p -------------";
2089 "-------- investigate rulesets for cancel_p -------------";
2090 "-------- investigate rulesets for cancel_p -------------";
2091 val thy = @{theory "Rational"};
2092 "---------------- (a^^^2 + -1*b^^^2) / (a^^^2 + -2*a*b + b^^^2)";
2093 val t = str2term "(a^^^2 + -1*b^^^2) / (a^^^2 + -2*a*b + b^^^2)";
2094 val tt = str2term "(1 * a + 1 * b) * (1 * a + -1 * b)"(*numerator only*);
2095 "----- with rewrite_set_";
2096 val SOME (tt',asm) = rewrite_set_ thy false make_polynomial tt;
2097 term2str tt'= "a ^^^ 2 + -1 * b ^^^ 2" (*true*);
2098 val tt = str2term "((1 * a + -1 * b) * (1 * a + -1 * b))"(*denominator only*);
2099 val SOME (tt',asm) = rewrite_set_ thy false make_polynomial tt;
2100 term2str tt' = "a ^^^ 2 + -2 * a * b + b ^^^ 2" (*true*);
2102 "----- with make_deriv";
2103 val SOME (tt, _) = factout_p_ thy t; term2str tt =
2104 "(1 * a + 1 * b) * (1 * a + -1 * b) / ((1 * a + -1 * b) * (1 * a + -1 * b))";
2106 "--- with ruleset as before 060829";
2107 val {rules, rew_ord=(_,ro),...} =
2108 rep_rls (assoc_rls "make_polynomial");
2109 val der = make_deriv thy Atools_erls rules ro NONE tt;
2110 print_depth 99; map (term2str o #1) der; print_depth 3;
2111 print_depth 99; map (rule2str o #2) der; print_depth 3;
2112 ... did not terminate*)
2113 "--- with simpler ruleset";
2114 val {rules, rew_ord=(_,ro),...} =
2115 rep_rls (assoc_rls "rev_rew_p");
2116 val der = make_deriv thy Atools_erls rules ro NONE tt;
2117 print_depth 99; writeln (deriv2str der); print_depth 3;
2119 print_depth 99; map (term2str o #1) der; print_depth 3;
2120 "...,(-1 * b ^^^ 2 + a ^^^ 2) / (-2 * (a * b) + a ^^^ 2 + (-1 * b) ^^^ 2) ]";
2121 print_depth 99; map (rule2str o #2) der; print_depth 3;
2122 print_depth 99; map (term2str o #1 o #3) der; print_depth 3;
2124 val der = make_deriv thy Atools_erls rules ro NONE
2125 (str2term "(1 * a + 1 * b) * (1 * a + -1 * b)");
2126 print_depth 99; writeln (deriv2str der); print_depth 3;
2128 val {rules, rew_ord=(_,ro),...} =
2129 rep_rls (assoc_rls "rev_rew_p");
2130 val der = make_deriv thy Atools_erls rules ro NONE
2131 (str2term "(1 * a + -1 * b) * (1 * a + -1 * b)");
2132 print_depth 99; writeln (deriv2str der); print_depth 3;
2133 print_depth 99; map (term2str o #1) der; print_depth 3;
2134 (*WN060829 ...postponed*)
2137 "-------- investigate format of factout_ and factout_p_ -";
2138 "-------- investigate format of factout_ and factout_p_ -";
2139 "-------- investigate format of factout_ and factout_p_ -";
2140 val {rules, rew_ord = (_,ro),...} = rep_rls (assoc_rls "make_polynomial");
2141 val (thy, eval_rls) = (@{theory "Rational"}, Atools_erls)(*see 'fun init_state'*);
2142 val Rrls {scr = Rfuns {init_state,...},...} = assoc_rls "cancel_p";
2144 "----- see Rational.ML, local cancel_p, fun init_state";
2145 val t = str2term "(a^^^2 + (-1)*b^^^2) / (a^^^2 + (-2)*a*b + b^^^2)";
2146 val SOME (t',_) = factout_p_ thy t; term2str t';
2148 val rtas = reverse_deriv thy eval_rls rules ro NONE t';
2149 writeln(trtas2str rst);
2153 "----- see Rational.ML, local cancel_p, fun init_state";
2154 val t = str2term "a^^^2 / a";
2155 val SOME (t',_) = factout_p_ thy t;
2156 term2str t' = "a * a / (1 * a)" (*true*);
2157 (*... can be canceled with
2158 real_mult_div_cancel2 ?k ~= 0 ==> ?m * ?k / (?n * ?k) = ?m / ?n"*)
2159 (* sml/ME/rewtools.sml:
2160 val rtas = reverse_deriv thy Atools_erls rules ro NONE t';
2161 writeln (deri2str rtas);
2165 "-------- SK 060904 ----------------------------------------------";
2166 "----- order on polynomials -- input + output";
2167 val thy = @{theory "Isac"};
2168 val t = str2term "(a + -1 * b) / (-1 * a + b)";
2169 val SOME (t', _) = factout_p_ thy t; term2str t';
2170 val SOME (t', _) = cancel_p_ thy t; term2str t';
2172 val t = str2term "a*b*c*d / (d*e*f*g)";
2173 val SOME (t', _) = cancel_p_ thy t; term2str t';
2175 val t = str2term "a*(b*(c*d)) / (b*(e*(f*g)))";
2176 val SOME (t', _) = cancel_p_ thy t; term2str t';
2179 "----- SK060904-1a non-termination of cancel_p_ ? worked before 0707xx";
2180 val t = str2term "(x^^^2 - 4)*(3 - y) / ((y^^^2 - 9)*(2+x))";
2181 val SOME (t',_) = rewrite_set_ thy false norm_Rational t;
2182 if term2str t' = "(2 + -1 * x) / (3 + y)" then ()
2183 else error "rational.sml SK060904-1a worked since 0707xx";
2185 "----- SK060904-1b non-termination of cancel_p_ ... worked before 0707xx";
2186 val t = str2term ("(9 * a ^^^ 2 + -16 * b ^^^ 2) /" ^
2187 "(36 * a^^^2 * c + (27 * a^^^2 * e + (-64 * b^^^2 * c + -48 * b^^^2 * e)))");
2188 val SOME (t',_) = cancel_p_ thy t;
2189 if term2str t' = "1 / (4 * c + 3 * e)" then ()
2190 else error "rational.sml SK060904-1b";
2193 "----- SK060904-2a non-termination of add_fraction_p_";
2194 val t = str2term (" (a + b * x) / (a + -1 * (b * x)) + " ^
2195 " (-1 * a + b * x) / (a + b * x) ");
2197 val SOME (t',_) = rewrite_set_ thy false common_nominator_p t;
2199 common_nominator_p_ thy t;
2200 " (a + b * x)*(a + b * x) / ((a + -1 * (b * x))*(a + -1 * (b * x))) + " ^
2201 " (-1 * a + b * x)*(a + -1 * (b * x)) / ((a + b * x)*(-1 * a + b * x)) ";
2203 add_fraction_p_ thy t;
2204 " ((a + b * x)*(a + b * x) + (-1 * a + b * x)*(a + -1 * (b * x))) /" ^
2205 " ((a + b * x)*(-1 * a + b * x)) ";
2209 "-------- how to stepwise construct Scripts -------------";
2210 "-------- how to stepwise construct Scripts -------------";
2211 "-------- how to stepwise construct Scripts -------------";
2212 val thy = @{theory "Rational"};
2214 val p1 = parse thy (
2215 "Script SimplifyScript (t_t::real) = " ^
2216 " (Rewrite_Set discard_minus False " ^
2219 (*required (): (Rewrite_Set discard_minus False)*)
2220 val p2 = parse thy (
2221 "Script SimplifyScript (t_t::real) = " ^
2222 " (Rewrite_Set discard_minus False " ^
2225 val p3 = parse thy (
2226 "Script SimplifyScript (t_t::real) = " ^
2227 " ((Rewrite_Set discard_minus False) " ^
2230 val p4 = parse thy (
2231 "Script SimplifyScript (t_t::real) = " ^
2232 " ((Rewrite_Set discard_minus False) " ^
2235 val p5 = parse thy (
2236 "Script SimplifyScript (t_t::real) = " ^
2237 " ((Try (Rewrite_Set discard_minus False) " ^
2238 " Try (Rewrite_Set discard_parentheses False)) " ^
2241 val p6 = parse thy (
2242 "Script SimplifyScript (t_t::real) = " ^
2243 " ((Try (Rewrite_Set discard_minus False) @@ " ^
2244 " Try (Rewrite_Set rat_mult_poly False) @@ " ^
2245 " Try (Rewrite_Set make_rat_poly_with_parentheses False) @@ " ^
2246 " Try (Rewrite_Set cancel_p_rls False) @@ " ^
2248 " ((Try (Rewrite_Set common_nominator_p_rls False) @@ " ^
2249 " Try (Rewrite_Set rat_mult_div_pow False) @@ " ^
2250 " Try (Rewrite_Set make_rat_poly_with_parentheses False) @@" ^
2251 " Try (Rewrite_Set cancel_p_rls False) @@ " ^
2252 " Try (Rewrite_Set rat_reduce_1 False)))) @@ " ^
2253 " Try (Rewrite_Set discard_parentheses False)) " ^
2257 "----------- get_denominator ----------------------------";
2258 "----------- get_denominator ----------------------------";
2259 "----------- get_denominator ----------------------------";
2260 val thy = @{theory Isac};
2261 val t = term_of (the (parse thy "get_denominator ((a +x)/b)"));
2262 val SOME (_, t') = eval_get_denominator "" 0 t thy;
2263 if term2str t' = "get_denominator ((a + x) / b) = b" then ()
2264 else error "get_denominator ((a + x) / b) = b"
2267 "--------- several errpats in complicated term -------------------";
2268 "--------- several errpats in complicated term -------------------";
2269 "--------- several errpats in complicated term -------------------";
2270 (*TODO: instead of Gabriella's example here (27.Jul.12) find a simpler one*)
2273 [(["Term ((5*b + 25)/(a^2 - b^2) * (a - b)/(5*b))", "normalform N"],
2274 ("Rational",["rational","simplification"], ["simplification","of_rationals"]))];
2277 autoCalculate 1 CompleteCalc;
2278 val ((pt,p),_) = get_calc 1; show_pt pt;
2280 "-------- nonterminating cancel_p, norm_Rational 2002 ---";
2281 "-------- nonterminating cancel_p, norm_Rational 2002 ---";
2282 "-------- nonterminating cancel_p, norm_Rational 2002 ---";
2283 (*------------------------------------------------------------------------------------\
2284 "--- WN121204: searched rational.sml for "nonterm", added new numbering" ^
2285 " and thoroughly tested with this numbering subsequently";
2287 WN.2.6.03 from rlang.sml 56a
2288 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)";
2289 val NONE = rewrite_set_ thy false common_nominator_p t;
2291 WN060831 nonterm.SK7
2292 val t = str2term "(a + b * x) / (a + -1 * (b * x)) + (-1 * a + b * x) / (a + b * x)";
2293 val NONE = add_fraction_p_ thy t;
2295 nonterm.SK9 loops: cancel_p kann nicht weiter kuerzen!!! *)
2296 val t'' = str2term "(a + b)/(x^^^2 - y^^^2) * ((x - y)^^^2/(a^^^2 - b^^^2))";
2297 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t'';
2300 "(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)";
2301 WN060831 nonterm.SK10
2302 val SOME (t,_) = rewrite_set_ thy false cancel_p t;
2306 "(9*(x^^^2 - 8*x+16)/(4*(y^^^2 - 2*y+1)))/((3*x - 12)/(16*y - 16))";
2307 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
2310 else error "rational.sml: diff.behav. in norm_Rational_mg 42";
2313 "9*(x^^^2 - 8*x+16)*(16*y - 16)/(4*(y^^^2 - 2*y+1)*(3*x - 12))";
2314 val SOME (t',_) = rewrite_set_ thy false norm_Rational t;
2315 ... non terminating.
2317 val SOME (t',_) = rewrite_set_ thy false make_polynomial t;
2318 "(-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)";
2319 val SOME (t,_) = rewrite_set_ thy false cancel_p t';
2321 val t = str2term "(a-b)^^^3 * (x+y)^^^4 / ((x+y)^^^2 * (a-b)^^^5)";
2322 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
2324 val t = str2term "((12*x*y/(9*x^^^2 - y^^^2))/" ^
2325 "(1/(3*x - y)^^^2 - 1/(3*x + y)^^^2)) *" ^
2326 "(1/(x - 5*y)^^^2 - 1/(x + 5*y)^^^2)/" ^
2327 "(20*x*y/(x^^^2 - 25*y^^^2))";
2328 val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
2330 SK060904-2a non-termination of add_fraction_p_";
2331 val t = str2term (" (a + b * x) / (a + -1 * (b * x)) + " ^
2332 " (-1 * a + b * x) / (a + b * x) ");
2334 val SOME (t',_) = rewrite_set_ thy false common_nominator_p t;
2336 common_nominator_p_ thy t;
2337 " (a + b * x)*(a + b * x) / ((a + -1 * (b * x))*(a + -1 * (b * x))) + " ^
2338 " (-1 * a + b * x)*(a + -1 * (b * x)) / ((a + b * x)*(-1 * a + b * x)) ";
2340 add_fraction_p_ thy t;
2341 " ((a + b * x)*(a + b * x) + (-1 * a + b * x)*(a + -1 * (b * x))) /" ^
2342 " ((a + b * x)*(-1 * a + b * x)) ";
2343 --------------------------------------------------------------------------------------/*)
2345 (*------------------------------------------------------------------------------------\
2346 "WN121205: thoroughly tested with the above numbering.";
2347 " errors in cancel_p: --- 4,5,6,7.";
2348 " error in common_nominator_p, common_nominator_p_: --- 10; 1,2?.";
2349 " errors caused by ruleset norm_Rational: --- 8,9.";
2350 trace_rewrite := true;
2352 "--- 1 ---: non-terminating with ### add_fract: done t22 ";
2353 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)";
2354 trace_rewrite:= true;
2355 rewrite_set_ thy false common_nominator_p t;
2357 "--- 2 ---: non-terminating with ### add_fract: done t22 ";
2358 val t = str2term "(a + b * x) / (a + -1 * (b * x)) + (-1 * a + b * x) / (a + b * x)";
2359 add_fraction_p_ thy t;
2361 "--- 3 ---: norm_Rational calls Rrls cancel_p with non-normalised polys";
2362 val t = str2term "(a + b)/(x^^^2 - y^^^2) * ((x - y)^^^2/(a^^^2 - b^^^2))";
2363 rewrite_set_ thy false norm_Rational t;
2364 (*tracing end...#### rls: cancel_p on:
2365 (a * x ^^^ 2 + -2 * (a * (x * y)) + a * y ^^^ 2 + b * x ^^^ 2 + -2 * (b * (x * y)) + b * y ^^^ 2) /
2366 (a ^^^ 2 * x ^^^ 2 + -1 * (a ^^^ 2 * y ^^^ 2) + -1 * (b ^^^ 2 * x ^^^ 2) + b ^^^ 2 * y ^^^ 2) *)
2368 "--- 4 ---: non-terminating with Rrls cancel_p on plausible input";
2370 "(a * x ^^^ 2 + -2 * a * x * y + a * y ^^^ 2 + b * x ^^^ 2 + -2 * b * x * y + b * y ^^^ 2) /"^
2371 "(a ^^^ 2 * x ^^^ 2 + -1 * a ^^^ 2 * y ^^^ 2 + -1 * b ^^^ 2 * x ^^^ 2 + b ^^^ 2 * y ^^^ 2)");
2372 rewrite_set_ thy false cancel_p t;
2373 (*# rls: cancel_p on:
2374 (a * x ^^^ 2 + -2 * a * x * y + a * y ^^^ 2 + b * x ^^^ 2 + -2 * b * x * y + b * y ^^^ 2) /
2375 (a ^^^ 2 * x ^^^ 2 + -1 * a ^^^ 2 * y ^^^ 2 + -1 * b ^^^ 2 * x ^^^ 2 + b ^^^ 2 * y ^^^ 2) *)
2377 "--- 5 ---: non-terminating with Rrls cancel_p on plausible input";
2378 val t = str2term "(9*(x^^^2 - 8*x+16)/(4*(y^^^2 - 2*y+1)))/((3*x - 12)/(16*y - 16))";
2379 rewrite_set_ thy false norm_Rational t;
2380 (*#### rls: cancel_p on:
2381 (2304 + -1152 * x + -2304 * y + 144 * x ^^^ 2 + 1152 * (x * y) + -144 * (x ^^^ 2 * y)) /
2382 (48 + -12 * x + -96 * y + 24 * (x * y) + 48 * y ^^^ 2 + -12 * (x * y ^^^ 2)) *)
2384 "--- 6 ---: non-terminating with Rrls cancel_p on plausible input";
2386 "9*(x^^^2 - 8*x+16)*(16*y - 16)/(4*(y^^^2 - 2*y+1)*(3*x - 12))";
2387 rewrite_set_ thy false norm_Rational t;
2388 (*### rls: cancel_p on: (-2304 + 1152 * x + 2304 * y + -144 * x ^^^ 2 + -1152 * (x * y) +
2389 144 * (x ^^^ 2 * y)) /
2390 (-48 + 12 * x + 96 * y + -24 * (x * y) + -48 * y ^^^ 2 + 12 * (x * y ^^^ 2)) *)
2392 "--- 7 ---: non-terminating with Rrls cancel_p on plausible input";
2394 "(-2304 + 1152 * x + 2304 * y + -144 * x ^^^ 2 + -1152 * x * y + 144 * x ^^^ 2 * y) /"^
2395 "(-48 + 12 * x + 96 * y + -24 * x * y + -48 * y ^^^ 2 + 12 * x * y ^^^ 2)");
2396 rewrite_set_ thy false cancel_p t';
2398 "--- 8 ---: bottom of output cannot be looked ad (due to looping?)";
2399 val t = str2term "(a-b)^^^3 * (x+y)^^^4 / ((x+y)^^^2 * (a-b)^^^5)";
2400 val SOME (t,_) = rewrite_set_ thy false norm_Rational t;
2402 "--- 9 ---: probably error in norm_Rational";
2404 "((12*x*y / (9*x^^^2 - y^^^2)) / (1/(3*x - y)^^^2 - 1/(3*x + y)^^^2)) *" ^
2405 "(1/(x - 5*y)^^^2 - 1/(x + 5*y)^^^2) / (20*x*y/(x^^^2 - 25*y^^^2))");
2406 rewrite_set_ thy false norm_Rational t;
2407 (*#### rls: cancel_p on: (19440 * (x ^^^ 8 * y ^^^ 2) + -490320 * (x ^^^ 6 * y ^^^ 4) +
2408 108240 * (x ^^^ 4 * y ^^^ 6) +
2409 -6000 * (x ^^^ 2 * y ^^^ 8)) /
2410 (2160 * (x ^^^ 8 * y ^^^ 2) + -108240 * (x ^^^ 6 * y ^^^ 4) +
2411 1362000 * (x ^^^ 4 * y ^^^ 6) +
2412 -150000 * (x ^^^ 2 * y ^^^ 8)) *)
2414 "--- 10 ---: non-terminating with ### add_fract: done t22: error in common_nominator_p ";
2415 val t = str2term (" (a + b * x) / (a + -1 * (b * x)) + (-1 * a + b * x) / (a + b * x)");
2416 rewrite_set_ thy false common_nominator_p t; (*### add_fract: done t22 *)
2417 common_nominator_p_ thy t; (*loops without output*)
2418 "--- reformulated 10:";
2419 val t = str2term "(a + -1 * (b * x)) / (a + b * x)";
2420 rewrite_set_ thy false cancel_p t = NONE;
2423 "...both are to be considered after common_nominator_p_ is improved";
2424 --------------------------------------------------------------------------------------/*)
2425 ============ inhibit exn WN130824 TODO ======================================================*)