4 (c) due to copyright terms
6 use"../smltest/IsacKnowledge/polyminus.sml";
9 val thy = PolyMinus.thy;
11 "-----------------------------------------------------------------";
12 "table of contents -----------------------------------------------";
13 "-----------------------------------------------------------------";
14 "----------- fun eval_ist_monom ----------------------------------";
15 "----------- watch order_add_mult -------------------------------";
16 "----------- build predicate for +- ordering ---------------------";
17 "----------- build fasse_zusammen --------------------------------";
18 "----------- build verschoenere ----------------------------------";
19 "----------- met simplification for_polynomials with_minus -------";
20 "----------- pbl polynom vereinfachen p.33 -----------------------";
21 "----------- met probe fuer_polynom ------------------------------";
22 "----------- pbl polynom probe -----------------------------------";
23 "----------- pbl klammer polynom vereinfachen p.34 ---------------";
24 "----------- try fun applyTactics --------------------------------";
25 "----------- pbl binom polynom vereinfachen p.39 -----------------";
26 "----------- pbl binom polynom vereinfachen: cube ----------------";
27 "----------- refine Vereinfache ----------------------------------";
28 "-----------------------------------------------------------------";
29 "-----------------------------------------------------------------";
30 "-----------------------------------------------------------------";
33 "----------- fun eval_ist_monom ----------------------------------";
34 "----------- fun eval_ist_monom ----------------------------------";
35 "----------- fun eval_ist_monom ----------------------------------";
36 ist_monom (str2term "12");
37 case eval_ist_monom 0 0 (str2term "12 ist_monom") 0 of
38 SOME ("12 ist_monom = True", _) => ()
39 | _ => raise error "polyminus.sml: 12 ist_monom = True";
41 case eval_ist_monom 0 0 (str2term "a ist_monom") 0 of
42 SOME ("a ist_monom = True", _) => ()
43 | _ => raise error "polyminus.sml: a ist_monom = True";
45 case eval_ist_monom 0 0 (str2term "(3*a) ist_monom") 0 of
46 SOME ("3 * a ist_monom = True", _) => ()
47 | _ => raise error "polyminus.sml: 3 * a ist_monom = True";
49 case eval_ist_monom 0 0 (str2term "(a^^^2) ist_monom") 0 of
50 SOME ("a ^^^ 2 ist_monom = True", _) => ()
51 | _ => raise error "polyminus.sml: a^^^2 ist_monom = True";
53 case eval_ist_monom 0 0 (str2term "(3*a^^^2) ist_monom") 0 of
54 SOME ("3 * a ^^^ 2 ist_monom = True", _) => ()
55 | _ => raise error "polyminus.sml: 3*a^^^2 ist_monom = True";
57 case eval_ist_monom 0 0 (str2term "(a*b) ist_monom") 0 of
58 SOME ("a * b ist_monom = True", _) => ()
59 | _ => raise error "polyminus.sml: a*b ist_monom = True";
61 case eval_ist_monom 0 0 (str2term "(3*a*b) ist_monom") 0 of
62 SOME ("3 * a * b ist_monom = True", _) => ()
63 | _ => raise error "polyminus.sml: 3*a*b ist_monom = True";
66 "----------- watch order_add_mult -------------------------------";
67 "----------- watch order_add_mult -------------------------------";
68 "----------- watch order_add_mult -------------------------------";
69 "----- with these simple variables it works...";
72 val t = str2term "((a + d) + c) + b";
73 val SOME (t,_) = rewrite_set_ thy false order_add_mult t; term2str t;
74 if term2str t = "a + (b + (c + d))" then ()
75 else raise error "polyminus.sml 1 watch order_add_mult";
78 "----- the same stepwise...";
79 val od = ord_make_polynomial true Poly.thy;
80 val t = str2term "((a + d) + c) + b";
82 val SOME (t,_) = rewrite_ thy od e_rls true real_add_commute t; term2str t;
84 val SOME (t,_) = rewrite_ thy od e_rls true real_add_commute t; term2str t;
86 val SOME (t,_) = rewrite_ thy od e_rls true real_add_left_commute t;term2str t;
88 val SOME (t,_) = rewrite_ thy od e_rls true real_add_left_commute t;term2str t;
90 if term2str t = "a + (b + (c + d))" then ()
91 else raise error "polyminus.sml 2 watch order_add_mult";
93 "----- if parentheses are right, left_commute is (almost) sufficient...";
94 val t = str2term "a + (d + (c + b))";
96 val SOME (t,_) = rewrite_ thy od e_rls true real_add_left_commute t;term2str t;
98 val SOME (t,_) = rewrite_ thy od e_rls true real_add_commute t;term2str t;
100 val SOME (t,_) = rewrite_ thy od e_rls true real_add_left_commute t;term2str t;
103 "----- but we do not want the parentheses at right; thus: cond.rew.";
104 "WN0712707 complicated monomials do not yet work ...";
105 val t = str2term "((5*a + 4*d) + 3*c) + 2*b";
106 val SOME (t,_) = rewrite_set_ thy false order_add_mult t; term2str t;
107 if term2str t = "2 * b + (3 * c + (4 * d + 5 * a))" then ()
108 else raise error "polyminus.sml: order_add_mult changed";
110 "----- here we see rew_sub going into subterm with ord.rew....";
111 val od = ord_make_polynomial false Poly.thy;
112 val t = str2term "b + a + c + d";
113 val SOME (t,_) = rewrite_ thy od e_rls false real_add_commute t; term2str t;
114 val SOME (t,_) = rewrite_ thy od e_rls false real_add_commute t; term2str t;
115 (*@@@ rew_sub gosub: t = d + (b + a + c)
116 @@@ rew_sub begin: t = b + a + c*)
119 "----------- build predicate for +- ordering ---------------------";
120 "----------- build predicate for +- ordering ---------------------";
121 "----------- build predicate for +- ordering ---------------------";
124 "123" < "a"; (*unused due to ---vvv*)
125 "12" < "3"; (*true !!!*)
127 " a kleiner b ==> (b + a) = (a + b)";
129 str2term "222 * aaa";
131 case eval_kleiner 0 0 (str2term "123 kleiner 32") 0 of
132 SOME ("12 kleiner 9 = False", _) => ()
133 | _ => raise error "polyminus.sml: 12 kleiner 9 = False";
135 case eval_kleiner 0 0 (str2term "a kleiner b") 0 of
136 SOME ("a kleiner b = True", _) => ()
137 | _ => raise error "polyminus.sml: a kleiner b = True";
139 case eval_kleiner 0 0 (str2term "(10*g) kleiner f") 0 of
140 SOME ("10 * g kleiner f = False", _) => ()
141 | _ => raise error "polyminus.sml: 10 * g kleiner f = False";
143 case eval_kleiner 0 0 (str2term "(a^^^2) kleiner b") 0 of
144 SOME ("a ^^^ 2 kleiner b = True", _) => ()
145 | _ => raise error "polyminus.sml: a ^^^ 2 kleiner b = True";
147 case eval_kleiner 0 0 (str2term "(3*a^^^2) kleiner b") 0 of
148 SOME ("3 * a ^^^ 2 kleiner b = True", _) => ()
149 | _ => raise error "polyminus.sml: 3 * a ^^^ 2 kleiner b = True";
151 case eval_kleiner 0 0 (str2term "(a*b) kleiner c") 0 of
152 SOME ("a * b kleiner c = True", _) => ()
153 | _ => raise error "polyminus.sml: a * b kleiner b = True";
155 case eval_kleiner 0 0 (str2term "(3*a*b) kleiner c") 0 of
156 SOME ("3 * a * b kleiner c = True", _) => ()
157 | _ => raise error "polyminus.sml: 3 * a * b kleiner b = True";
161 "----- compare tausche_plus with real_num_collect";
164 val erls = erls_ordne_alphabetisch;
165 val t = str2term "b + a";
166 val SOME (t,_) = rewrite_ thy od erls false tausche_plus t; term2str t;
167 if term2str t = "a + b" then ()
168 else raise error "polyminus.sml: ordne_alphabetisch1 b + a";
170 val erls = Atools_erls;
171 val t = str2term "2*a + 3*a";
172 val SOME (t,_) = rewrite_ thy od erls false real_num_collect t; term2str t;
174 "----- test rewrite_, rewrite_set_";
176 val erls = erls_ordne_alphabetisch;
177 val t = str2term "b + a";
178 val SOME (t,_) = rewrite_set_ thy false ordne_alphabetisch t; term2str t;
179 if term2str t = "a + b" then ()
180 else raise error "polyminus.sml: ordne_alphabetisch a + b";
182 val t = str2term "2*b + a";
183 val SOME (t,_) = rewrite_set_ thy false ordne_alphabetisch t; term2str t;
184 if term2str t = "a + 2 * b" then ()
185 else raise error "polyminus.sml: ordne_alphabetisch a + 2 * b";
187 val t = str2term "a + c + b";
188 val SOME (t,_) = rewrite_set_ thy false ordne_alphabetisch t; term2str t;
189 if term2str t = "a + b + c" then ()
190 else raise error "polyminus.sml: ordne_alphabetisch a + b + c";
192 "----- rewrite goes into subterms";
193 val t = str2term "a + c + b + d";
194 val SOME (t,_) = rewrite_ thy od erls false tausche_plus_plus t; term2str t;
195 if term2str t = "a + b + c + d" then ()
196 else raise error "polyminus.sml: ordne_alphabetisch1 a + b + c + d";
198 val t = str2term "a + c + d + b";
199 val SOME (t,_) = rewrite_set_ thy false ordne_alphabetisch t; term2str t;
200 if term2str t = "a + b + c + d" then ()
201 else raise error "polyminus.sml: ordne_alphabetisch2 a + b + c + d";
203 "----- here we see rew_sub going into subterm with cond.rew....";
204 val t = str2term "b + a + c + d";
205 val SOME (t,_) = rewrite_ thy od erls false tausche_plus t; term2str t;
206 if term2str t = "a + b + c + d" then ()
207 else raise error "polyminus.sml: ordne_alphabetisch3 a + b + c + d";
209 "----- compile rls for the most complicated terms";
210 val t = str2term "5*e + 6*f - 8*g - 9 - 7*e - 4*f + 10*g + 12";
211 "5 * e + 6 * f - 8 * g - 9 - 7 * e - 4 * f + 10 * g + 12";
212 val SOME (t,_) = rewrite_set_ thy false ordne_alphabetisch t;
213 if term2str t = "- 9 + 12 + 5 * e - 7 * e + 6 * f - 4 * f - 8 * g + 10 * g"
214 then () else raise error "polyminus.sml: ordne_alphabetisch finished";
217 "----------- build fasse_zusammen --------------------------------";
218 "----------- build fasse_zusammen --------------------------------";
219 "----------- build fasse_zusammen --------------------------------";
220 val t = str2term "- 9 + 12 + 5 * e - 7 * e + 6 * f - 4 * f - 8 * g + 10 * g";
221 val SOME (t,_) = rewrite_set_ thy false fasse_zusammen t;
222 if term2str t = "3 + -2 * e + 2 * f + 2 * g" then ()
223 else raise error "polyminus.sml: fasse_zusammen finished";
225 "----------- build verschoenere ----------------------------------";
226 "----------- build verschoenere ----------------------------------";
227 "----------- build verschoenere ----------------------------------";
228 val t = str2term "3 + -2 * e + 2 * f + 2 * g";
229 val SOME (t,_) = rewrite_set_ thy false verschoenere t;
230 if term2str t = "3 - 2 * e + 2 * f + 2 * g" then ()
231 else raise error "polyminus.sml: verschoenere 3 + -2 * e ...";
234 trace_rewrite:=false;
236 "----------- met simplification for_polynomials with_minus -------";
237 "----------- met simplification for_polynomials with_minus -------";
238 "----------- met simplification for_polynomials with_minus -------";
240 "Script SimplifyScript (t_::real) = \
241 \ (((Try (Rewrite_Set ordne_alphabetisch False)) @@ \
242 \ (Try (Rewrite_Set fasse_zusammen False)) @@ \
243 \ (Try (Rewrite_Set verschoenere False))) t_)"
244 val sc = ((inst_abs thy) o term_of o the o (parse thy)) str;
248 "----------- pbl polynom vereinfachen p.33 -----------------------";
249 "----------- pbl polynom vereinfachen p.33 -----------------------";
250 "----------- pbl polynom vereinfachen p.33 -----------------------";
251 "----------- 140 c ---";
253 CalcTree [(["TERM (5*e + 6*f - 8*g - 9 - 7*e - 4*f + 10*g + 12)",
255 ("PolyMinus.thy",["plus_minus","polynom","vereinfachen"],
256 ["simplification","for_polynomials","with_minus"]))];
258 autoCalculate 1 CompleteCalc;
259 val ((pt,p),_) = get_calc 1; show_pt pt;
260 if p = ([], Res) andalso
261 term2str (get_obj g_res pt (fst p)) = "3 - 2 * e + 2 * f + 2 * g"
262 then () else raise error "polyminus.sml: Vereinfache (3 - 2 * e + 2 * f...";
264 "----------- 140 d ---";
266 CalcTree [(["TERM (-r - 2*s - 3*t + 5 + 4*r + 8*s - 5*t - 2)",
268 ("PolyMinus.thy",["plus_minus","polynom","vereinfachen"],
269 ["simplification","for_polynomials","with_minus"]))];
271 autoCalculate 1 CompleteCalc;
272 val ((pt,p),_) = get_calc 1; show_pt pt;
273 if p = ([], Res) andalso
274 term2str (get_obj g_res pt (fst p)) = "3 + 3 * r + 6 * s - 8 * t"
275 then () else raise error "polyminus.sml: Vereinfache 140 d)";
278 "----------- 139 c ---";
280 CalcTree [(["TERM (3*e - 6*f - 8*e - 4*f + 5*e + 7*f)",
282 ("PolyMinus.thy",["plus_minus","polynom","vereinfachen"],
283 ["simplification","for_polynomials","with_minus"]))];
285 autoCalculate 1 CompleteCalc;
286 val ((pt,p),_) = get_calc 1; show_pt pt;
287 if p = ([], Res) andalso
288 term2str (get_obj g_res pt (fst p)) = "- (3 * f)"
289 then () else raise error "polyminus.sml: Vereinfache 139 c)";
291 "----------- 139 b ---";
293 CalcTree [(["TERM (8*u - 5*v - 5*u + 7*v - 6*u - 3*v)",
295 ("PolyMinus.thy",["plus_minus","polynom","vereinfachen"],
296 ["simplification","for_polynomials","with_minus"]))];
298 autoCalculate 1 CompleteCalc;
299 val ((pt,p),_) = get_calc 1; show_pt pt;
300 if p = ([], Res) andalso
301 term2str (get_obj g_res pt (fst p)) = "-3 * u - v"
302 then () else raise error "polyminus.sml: Vereinfache 139 b)";
304 "----------- 138 a ---";
306 CalcTree [(["TERM (2*u - 3*v - 6*u + 5*v)",
308 ("PolyMinus.thy",["plus_minus","polynom","vereinfachen"],
309 ["simplification","for_polynomials","with_minus"]))];
311 autoCalculate 1 CompleteCalc;
312 val ((pt,p),_) = get_calc 1; show_pt pt;
313 if p = ([], Res) andalso
314 term2str (get_obj g_res pt (fst p)) = "-4 * u + 2 * v"
315 then () else raise error "polyminus.sml: Vereinfache 138 a)";
318 "----------- met probe fuer_polynom ------------------------------";
319 "----------- met probe fuer_polynom ------------------------------";
320 "----------- met probe fuer_polynom ------------------------------";
322 "Script ProbeScript (e_::bool) (ws_::bool list) =\
323 \ (let e_ = Take e_; \
324 \ e_ = Substitute ws_ e_ \
325 \ in (Repeat((Try (Repeat (Calculate times))) @@ \
326 \ (Try (Repeat (Calculate plus ))) @@ \
327 \ (Try (Repeat (Calculate minus))))) e_)"
328 val sc = ((inst_abs thy) o term_of o the o (parse thy)) str;
332 "----------- pbl polynom probe -----------------------------------";
333 "----------- pbl polynom probe -----------------------------------";
334 "----------- pbl polynom probe -----------------------------------";
336 CalcTree [(["Pruefe (5*e + 6*f - 8*g - 9 - 7*e - 4*f + 10*g + 12 =\
337 \3 - 2 * e + 2 * f + 2 * g)",
338 "mitWert [e = 1, f = 2, g = 3]",
340 ("PolyMinus.thy",["polynom","probe"],
341 ["probe","fuer_polynom"]))];
343 autoCalculate 1 CompleteCalc;
344 (* autoCalculate 1 CompleteCalcHead;
345 autoCalculate 1 (Step 1);
346 autoCalculate 1 (Step 1);
347 val ((pt,p),_) = get_calc 1; term2str (get_obj g_res pt (fst p));
348 @@@@@WN081114 gives "??.empty", all "Pruefe" are the same,
349 although analogies work in interface.sml: FIXME.WN081114 in "Pruefe"*)
350 val ((pt,p),_) = get_calc 1;
351 if p = ([], Res) andalso term2str (get_obj g_res pt (fst p)) = "11 = 11"
352 then () else raise error "polyminus.sml: Probe 11 = 11";
356 "----------- pbl klammer polynom vereinfachen p.34 ---------------";
357 "----------- pbl klammer polynom vereinfachen p.34 ---------------";
358 "----------- pbl klammer polynom vereinfachen p.34 ---------------";
360 CalcTree [(["TERM (2*u - 5 - (3 - 4*u) + (8*u + 9))",
362 ("PolyMinus.thy",["klammer","polynom","vereinfachen"],
363 ["simplification","for_polynomials","with_parentheses"]))];
365 autoCalculate 1 CompleteCalc;
366 val ((pt,p),_) = get_calc 1;
367 if p = ([], Res) andalso
368 term2str (get_obj g_res pt (fst p)) = "1 + 14 * u"
369 then () else raise error "polyminus.sml: Vereinfache (2*u - 5 - (3 - ...";
372 "----- probe p.34 -----";
374 CalcTree [(["Pruefe (2*u - 5 - (3 - 4*u) + (8*u + 9) = 1 + 14 * u)",
377 ("PolyMinus.thy",["polynom","probe"],
378 ["probe","fuer_polynom"]))];
380 autoCalculate 1 CompleteCalc;
381 val ((pt,p),_) = get_calc 1;
382 if p = ([], Res) andalso term2str (get_obj g_res pt (fst p)) = "29 = 29"
383 then () else raise error "polyminus.sml: Probe 29 = 29";
387 "----------- try fun applyTactics --------------------------------";
388 "----------- try fun applyTactics --------------------------------";
389 "----------- try fun applyTactics --------------------------------";
391 CalcTree [(["TERM (5*e + 6*f - 8*g - 9 - 7*e - 4*f + 10*g + 12)",
393 ("PolyMinus.thy",["plus_minus","polynom","vereinfachen"],
394 ["simplification","for_polynomials","with_minus"]))];
396 autoCalculate 1 CompleteCalcHead;
397 autoCalculate 1 (Step 1);
398 autoCalculate 1 (Step 1);
399 val ((pt,p),_) = get_calc 1; show_pt pt;
401 fetchApplicableTactics 1 0 p;
402 val appltacs = sel_appl_atomic_tacs pt p;
403 applyTactic 1 p (hd appltacs) (*addiere_x_plus_minus*);
404 val ((pt,p),_) = get_calc 1; show_pt pt;
406 trace_rewrite := true;
407 val erls = erls_ordne_alphabetisch;
408 val t = str2term "- 9 + 12 + 5 * e - 7 * e + (6 - 4) * f - 8 * g + 10 * g";
410 rewrite_ Isac.thy e_rew_ord erls false tausche_minus t;
411 term2str t'; "- 9 + 12 + 5 * e - 7 * e + (- 4 + 6) * f - 8 * g + 10 * g";
413 val t = str2term "- 9 + 12 + 5 * e - 7 * e + (6 - 4) * f - 8 * g + 10 * g";
415 rewrite_ Isac.thy e_rew_ord erls false tausche_minus_plus t;
417 val t = str2term "- 9 + 12 + 5 * e - 7 * e + (6 - 4) * f - 8 * g + 10 * g";
419 rewrite_set_ Isac.thy false ordne_alphabetisch t;
420 term2str t'; "- 9 + 12 + 5 * e - 7 * e - 8 * g + 10 * g + (- 4 + 6) * f";
421 trace_rewrite := false;
424 applyTactic 1 p (hd (sel_appl_atomic_tacs pt p)) (*tausche_minus*);
425 val ((pt,p),_) = get_calc 1; show_pt pt;
427 applyTactic 1 p (hd (sel_appl_atomic_tacs pt p)) (**);
428 val ((pt,p),_) = get_calc 1; show_pt pt;
430 applyTactic 1 p (hd (sel_appl_atomic_tacs pt p)) (**);
431 val ((pt,p),_) = get_calc 1; show_pt pt;
433 applyTactic 1 p (hd (sel_appl_atomic_tacs pt p)) (**);
434 val ((pt,p),_) = get_calc 1; show_pt pt;
437 (*<CALCMESSAGE> failure </CALCMESSAGE>
438 applyTactic 1 p (hd (sel_appl_atomic_tacs pt p)) (**);
439 val ((pt,p),_) = get_calc 1; show_pt pt;
443 autoCalculate 1 CompleteCalc;
444 val ((pt,p),_) = get_calc 1; show_pt pt;
445 (*independent from failure above: met_simp_poly_minus not confluent:
446 (([9], Res), - (8 * g) + 10 * g + (3 - 2 * e + 2 * f)),
447 (([], Res), - (8 * g) + 10 * g + (3 - 2 * e + 2 * f))]
448 ~~~~~~~~~~~###~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*)
451 CalcTree [(["TERM (- (8 * g) + 10 * g + h)",
453 ("PolyMinus.thy",["plus_minus","polynom","vereinfachen"],
454 ["simplification","for_polynomials","with_minus"]))];
456 autoCalculate 1 CompleteCalc;
457 val ((pt,p),_) = get_calc 1; show_pt pt;
458 if p = ([], Res) andalso term2str (get_obj g_res pt (fst p)) = "2 * g + h"
459 then () else raise error "polyminus.sml: addiere_vor_minus";
463 CalcTree [(["TERM (- (8 * g) + 10 * g + f)",
465 ("PolyMinus.thy",["plus_minus","polynom","vereinfachen"],
466 ["simplification","for_polynomials","with_minus"]))];
468 autoCalculate 1 CompleteCalc;
469 val ((pt,p),_) = get_calc 1; show_pt pt;
470 if p = ([], Res) andalso term2str (get_obj g_res pt (fst p)) = "f + 2 * g"
471 then () else raise error "polyminus.sml: tausche_vor_plus";
474 "----------- pbl binom polynom vereinfachen p.39 -----------------";
475 "----------- pbl binom polynom vereinfachen p.39 -----------------";
476 "----------- pbl binom polynom vereinfachen p.39 -----------------";
477 val rls = klammern_ausmultiplizieren;
478 val t = str2term "(3 * a + 2) * (4 * a - 1)";
479 val SOME (t,_) = rewrite_set_ thy false rls t; term2str t;
480 "3 * a * (4 * a) - 3 * a * 1 + (2 * (4 * a) - 2 * 1)";
481 val rls = discard_parentheses;
482 val SOME (t,_) = rewrite_set_ thy false rls t; term2str t;
483 "3 * a * 4 * a - 3 * a * 1 + (2 * 4 * a - 2 * 1)";
484 val rls = ordne_monome;
485 val SOME (t,_) = rewrite_set_ thy false rls t; term2str t;
486 "3 * 4 * a * a - 1 * 3 * a + (2 * 4 * a - 1 * 2)";
488 val t = str2term "3 * a * 4 * a";
489 val rls = ordne_monome;
490 val SOME (t,_) = rewrite_set_ thy false rls t; term2str t;
492 val rls = klammern_aufloesen;
493 val SOME (t,_) = rewrite_set_ thy false rls t; term2str t;
494 "3 * 4 * a * a - 1 * 3 * a + 2 * 4 * a - 1 * 2";
495 val rls = ordne_alphabetisch;
496 (*TODO: make is_monom more general, a*a=a^2, ...*)
497 val SOME (t,_) = rewrite_set_ thy false rls t; term2str t;
498 "3 * 4 * a * a - 1 * 2 - 1 * 3 * a + 2 * 4 * a";
500 val rls = fasse_zusammen;
501 val SOME (t,_) = rewrite_set_ thy false rls t; term2str t;
502 val rls = verschoenere;
503 val SOME (t,_) = rewrite_set_ thy false rls t; term2str t;
507 trace_rewrite := true;
508 trace_rewrite := false;
512 CalcTree [(["TERM ((3*a + 2) * (4*a - 1))",
514 ("PolyMinus.thy",["binom_klammer","polynom","vereinfachen"],
515 ["simplification","for_polynomials","with_parentheses_mult"]))];
517 autoCalculate 1 CompleteCalc;
518 val ((pt,p),_) = get_calc 1; show_pt pt;
521 if p = ([], Res) andalso
522 term2str (get_obj g_res pt (fst p)) = "1 + 14 * u"
523 then () else raise error "polyminus.sml: Vereinfache (2*u - 5 - (3 - ...";
527 "----------- pbl binom polynom vereinfachen: cube ----------------";
528 "----------- pbl binom polynom vereinfachen: cube ----------------";
529 "----------- pbl binom polynom vereinfachen: cube ----------------";
531 CalcTree [(["TERM (8*(a - q) + a - 2*q + 3*(a - 2*q))",
533 ("PolyMinus.thy",["binom_klammer","polynom","vereinfachen"],
534 ["simplification","for_polynomials","with_parentheses_mult"]))];
536 autoCalculate 1 CompleteCalc;
537 val ((pt,p),_) = get_calc 1; show_pt pt;
540 "----------- refine Vereinfache ----------------------------------";
541 "----------- refine Vereinfache ----------------------------------";
542 "----------- refine Vereinfache ----------------------------------";
543 val fmz = ["TERM (8*(a - q) + a - 2*q + 3*(a - 2*q))",
546 val matches = refine fmz ["vereinfachen"];
549 "----- go into details, if it seems not to work -----";
550 "--- does the predicate evaluate correctly ?";
552 "matchsub (?a * (?b - ?c)) (8 * (a - q) + a - 2 * q + \
554 val ma = eval_matchsub "" "Tools.matchsub" t thy;
556 SOME ("matchsub (?a * (?b - ?c)) (8 * (a - q) + \
557 \a - 2 * q + 3 * (a - 2 * q)) = True", _) => ()
558 | _ => raise error "polyminus.sml matchsub (?a * (?b - ?c)...A";
560 "--- does the respective prls rewrite ?";
561 val prls = append_rls "prls_pbl_vereinf_poly" e_rls
562 [Calc ("Poly.is'_polyexp", eval_is_polyexp ""),
563 Calc ("Tools.matchsub", eval_matchsub ""),
564 Thm ("or_true",or_true),
565 (*"(?a | True) = True"*)
566 Thm ("or_false",or_false),
567 (*"(?a | False) = ?a"*)
568 Thm ("not_true",num_str @{not_true),
569 (*"(~ True) = False"*)
570 Thm ("not_false",num_str @{not_false)
571 (*"(~ False) = True"*)];
572 trace_rewrite := true;
573 val SOME (t', _) = rewrite_set_ thy false prls t;
574 trace_rewrite := false;
576 "--- does the respective prls rewrite the whole predicate ?";
578 "Not (matchsub (?a * (?b + ?c)) (8 * (a - q) + a - 2 * q) | \
579 \ matchsub (?a * (?b - ?c)) (8 * (a - q) + a - 2 * q) | \
580 \ matchsub ((?b + ?c) * ?a) (8 * (a - q) + a - 2 * q) | \
581 \ matchsub ((?b - ?c) * ?a) (8 * (a - q) + a - 2 * q) )";
582 trace_rewrite := true;
583 val SOME (t', _) = rewrite_set_ thy false prls t;
584 trace_rewrite := false;
585 if term2str t' = "False" then ()
586 else raise error "polyminus.sml Not (matchsub (?a * (?b + ?c)) (8 ...";
596 use"../smltest/IsacKnowledge/polyminus.sml";